Profound.js API List

Profound.js API List

Overview

The Profound.js API is the built-in library that Profound.js modules use to work with IBM i resources and RPG-style data. It covers database access, program and command calls, data areas, printer files, the IFS, date/time and string handling, error handling, and server management, so that these operations can be coded directly in JavaScript or TypeScript.

Most of the API are called through the pjs namespace object that Profound.js makes available to every module (for example, pjs.query() or pjs.getDataArea()). The remaining API fall into three groups:

  • Object methods - The definition API create objects that carry their own methods. A file created with pjs.defineTable() provides file.open(), file.fetchNext(), and the other Record Level Access methods; a display created with pjs.defineDisplay() provides display.read() and related methods; and a printer file created with pjs.definePrinter() provides printerFile.write().

  • Extensions to JavaScript types - Profound.js adds RPG-style operations to the standard String, Number, Date, and Buffer types, and to Profound.js array fields. Examples include string.scan(), Number.halfAdjust(), date.addDays(), and array.lookup().

  • Server-level API - A smaller set of API is exposed on the module object returned by require("profoundjs"). These are used in server startup and configuration code rather than in application modules, and are documented on the Server Management API page.

API Categories

Each category page below lists the individual API it contains. Open a category page to see the syntax, parameters, and usage details for a specific API.

Database and File Access

  • SQL API - Running SQL against local and remote databases, including pjs.query(), prepared statements built with pjs.prepare() and pjs.execute(), cursor fetching, and connection handling.

  • Record Level Access API - Native record-level I/O against database files, including defining a file with pjs.defineTable(), positioning and reading with file.positionTo() and file.fetchNext(), writing, updating, and deleting records, and commitment control with pjs.commit() and pjs.rollBack().

  • Data Area API - Creating, reading, updating, and unlocking IBM i data areas.

  • IFS API - Locating, reading, and writing stream files in the Integrated File System with pjs.findIFSFile(), pjs.readIFSFile(), and pjs.writeIFSFile().

  • Printer File API - Defining a printer file with pjs.definePrinter() and generating print output with printerFile.open(), printerFile.write(), and printerFile.close().

Program Flow and Integration

  • Call API - Calling other Profound.js modules, programs, service program procedures, and IBM i commands, passing parameters, making outbound HTTP requests, and transferring control.

  • Error Handling API - Raising, inspecting, and trapping errors with pjs.error(), pjs.setError(), and pjs.status().

  • Information/Logging API - Writing to the log, dumping field values, sending messages and email, and retrieving information about the current user and database driver.

  • Server Management API - Configuring and starting the Profound.js server, including profoundjs.applyConfig() and profoundjs.server.listen(), and access to the underlying Express application.

Data Definition and Structure

  • Declaration/Initialization API - Declaring fields with pjs.define() and returning them to their initial or default values with pjs.clear() and pjs.reset().

  • Data Structure API - Defining data structures with pjs.ds() and moving values between structures, subfields, and plain JavaScript objects.

  • Data Conversion API - Converting between character and numeric representations with pjs.char(), pjs.move(), pjs.moveLeft(), pjs.getInt(), and pjs.setInt().

  • Memory Management API - Lower-level work with storage and buffers, including allocating and freeing pointer-based memory, bit and zone operations, null indicators, switches, and session storage.

Working with Values

  • String API - RPG-style string handling such as scanning, replacing, trimming, and translating, plus conversion to and from EBCDIC hexadecimal.

  • Number API - Numeric formatting and arithmetic helpers, including edit codes, edit words, half adjust rounding, and numeric parsing.

  • Date/Time API - Building, comparing, and adjusting dates, times, and timestamps, along with Lilian date conversions and date/time format patterns.

  • Array API - RPG-style array operations such as lookups and their GE, GT, LE, and LT variants, summing, sorting, and moving array data.

User Interface

  • User Interface API - Working with Rich Display Files from a module, including pjs.defineDisplay(), reading and writing display record formats, grid handling, and message boxes.

Other

  • Encryption API - Encrypting and decrypting values with pjs.encrypt() and pjs.decrypt().

  • Miscellaneous PJS APIs - API that do not belong to one of the categories above, such as pjs.newUUID(), pjs.setOptions(), and pjs.askAgent().

 


Related Pages