@openfn/language-inform 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@openfn/language-inform",
3
+ "version": "1.0.0",
4
+ "description": "OpenFn inform adaptor",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/index.js",
9
+ "types": "./types/index.d.ts",
10
+ "require": "./dist/index.cjs"
11
+ },
12
+ "./package.json": "./package.json"
13
+ },
14
+ "author": "Open Function Group",
15
+ "license": "LGPLv3",
16
+ "files": [
17
+ "dist/",
18
+ "types/",
19
+ "ast.json",
20
+ "configuration-schema.json"
21
+ ],
22
+ "dependencies": {
23
+ "@openfn/language-common": "2.4.0"
24
+ },
25
+ "devDependencies": {
26
+ "assertion-error": "2.0.0",
27
+ "chai": "4.3.6",
28
+ "deep-eql": "4.1.1",
29
+ "mocha": "^10.7.3",
30
+ "rimraf": "3.0.2",
31
+ "undici": "^5.22.1"
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/openfn/adaptors.git"
36
+ },
37
+ "types": "types/index.d.ts",
38
+ "main": "dist/index.cjs",
39
+ "scripts": {
40
+ "build": "pnpm clean && build-adaptor inform",
41
+ "test": "mocha --experimental-specifier-resolution=node --no-warnings",
42
+ "test:watch": "mocha -w --experimental-specifier-resolution=node --no-warnings",
43
+ "clean": "rimraf dist types docs",
44
+ "pack": "pnpm pack --pack-destination ../../dist",
45
+ "lint": "eslint src"
46
+ }
47
+ }
@@ -0,0 +1,109 @@
1
+ /**
2
+ * State object
3
+ * @typedef {Object} HttpState
4
+ * @private
5
+ * @property data - the parsed response body
6
+ * @property references - an array of all previous data objects used in the Job
7
+ **/
8
+ /**
9
+ * Fetch all forms
10
+ * @example <caption>Get all forms without filter options</caption>
11
+ * getForms()
12
+ * @example <caption>Get all forms with filter options</caption>
13
+ * getForms({
14
+ * public: true,
15
+ * page: 1,
16
+ * page_size: 5,
17
+ * });
18
+ * @function
19
+ * @public
20
+ * @param {object} options - Optional filter options. Some supported options are: `public`, `tags`, `page`, and `page_size`.
21
+ * @returns {Operation}
22
+ * @state {HttpState}
23
+ */
24
+ export function getForms(options?: object): Operation;
25
+ /**
26
+ * Get metadata or structural data for a single form
27
+ * @example <caption> Get a single form </caption>
28
+ * getForm('6225')
29
+ * @example <caption> Get a single form structure </caption>
30
+ * getForm('6225', {
31
+ * structureOnly: true,
32
+ * });
33
+ * @function
34
+ * @public
35
+ * @param {string} formId - Id of the form to be retrieved.
36
+ * @param {object} options
37
+ * @param {boolean} options.structureOnly - If true, only the form structure is returned in JSON format.
38
+ * @returns {Operation}
39
+ * @state {HttpState}
40
+ */
41
+ export function getForm(formId: string, options?: {
42
+ structureOnly: boolean;
43
+ }): Operation;
44
+ /**
45
+ * Get submission data of a single form
46
+ * @example <caption>Get submissions without filter options</caption>
47
+ * getSubmissions('6225');
48
+ * @example <caption>Get submissions with filter options</caption>
49
+ * getSubmissions('6225', {
50
+ * query: `{"_submission_time":{"$gte":"2024-11-05"}}`,
51
+ * limit: 1,
52
+ * });
53
+ * @function
54
+ * @public
55
+ * @param {string} formId - Id of the form's submissions to be retrieved.
56
+ * @param {object} options - Optional filter options. Some supported options are: `query`, `limit`, `start`, `page`, and `page_size`.
57
+ * @returns {Operation}
58
+ * @state {HttpState}
59
+ */
60
+ export function getSubmissions(formId: string, options?: object): Operation;
61
+ /**
62
+ * Get a single data submission for a single form
63
+ * @example
64
+ * getSubmission('6225', '7783155')
65
+ * @function
66
+ * @public
67
+ * @param {string} formId - Id of the form's submissions to be retrieved.
68
+ * @param {string} submissionId - Id of the submission to be retrieved.
69
+ * @returns {Operation}
70
+ * @state {HttpState}
71
+ */
72
+ export function getSubmission(formId: string, submissionId: string): Operation;
73
+ /**
74
+ * Fetch a single attachment's metadata
75
+ * @example
76
+ * getAttachmentMetadata('621985')
77
+ * @function
78
+ * @public
79
+ * @param {string} attachmentId - Id of the attachment to be retrieved.
80
+ * @returns {Operation}
81
+ * @state {HttpState}
82
+ */
83
+ export function getAttachmentMetadata(attachmentId: string): Operation;
84
+ /**
85
+ * Download an attachment in binary or base64 format
86
+ * @example <caption>Download an attachment</caption>
87
+ * downloadAttachment('622038', {
88
+ * filename:
89
+ * 'unicefbih/attachments/download_1.png',
90
+ * });
91
+ * @example <caption>Download an attachment in base64 format</caption>
92
+ * downloadAttachment('622038', {
93
+ * filename:
94
+ * 'unicefbih/attachments/download_1.png',
95
+ * parseAs: 'base64',
96
+ * });
97
+ * @function
98
+ * @public
99
+ * @param {string} attachmentId - Id of the attachment to be retrieved.
100
+ * @param {object} options - Optional request options. Supported options are: `filename` for the specific attachment to be downloaded, and `parseAs` for either 'stream` or 'base64`. Defaults to `parseAs: stream`.
101
+ * @returns {Operation}
102
+ * @state {HttpState}
103
+ */
104
+ export function downloadAttachment(attachmentId: string, options?: object): Operation;
105
+ /**
106
+ * State object
107
+ */
108
+ export type HttpState = any;
109
+ export { combine, cursor, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, group, lastReferenceValue, merge, scrubEmojis, sourceValue, util } from "@openfn/language-common";
@@ -0,0 +1,3 @@
1
+ export function prepareNextState(state: any, response: any): any;
2
+ export function prepareHttpNextState(state: any, response: any): any;
3
+ export function request(configuration: {}, method: any, path: any, options?: {}): any;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * State object
3
+ * @typedef {Object} HttpState
4
+ * @private
5
+ * @property data - the parsed response body
6
+ * @property response - the response from the Inform server, including headers, statusCode, etc
7
+ * @property references - an array of all previous data objects used in the Job
8
+ **/
9
+ /**
10
+ * Options provided to the Inform request
11
+ * @typedef {Object} RequestOptions
12
+ * @public
13
+ * @property {object|string} body - body data to append to the request. JSON will be converted to a string.
14
+ * @property {object} errors - Map of errorCodes -> error messages, ie, `{ 404: 'Resource not found;' }`. Pass `false` to suppress errors for this code.
15
+ * @property {object} query - An object of query parameters to be encoded into the URL.
16
+ * @property {object} headers - An object of headers to append to the request.
17
+ */
18
+ /**
19
+ * Make a GET request to Inform
20
+ * @example <caption>Get all forms</caption>
21
+ * http.get('forms')
22
+ * @function
23
+ * @public
24
+ * @param {string} path - Path to resource
25
+ * @param {RequestOptions} options - Optional request options
26
+ * @returns {Operation}
27
+ * @state {HttpState}
28
+ */
29
+ export function get(path: string, options: RequestOptions): Operation;
30
+ /**
31
+ * Make a general HTTP request to Inform
32
+ * @example <caption>Get all forms with a query</caption>
33
+ * http.request('GET', 'forms', {
34
+ * query: {
35
+ * public: true,
36
+ * page: 1,
37
+ * page_size: 5,
38
+ * },
39
+ * });
40
+ * @function
41
+ * @public
42
+ * @param {string} method - HTTP method to use
43
+ * @param {string} path - Path to resource
44
+ * @param {RequestOptions} options - Optional request options
45
+ * @returns {Operation}
46
+ * @state {HttpState}
47
+ */
48
+ export function request(method: string, path: string, options?: RequestOptions): Operation;
49
+ /**
50
+ * State object
51
+ */
52
+ export type HttpState = any;
53
+ /**
54
+ * Options provided to the Inform request
55
+ */
56
+ export type RequestOptions = any;
57
+ export { combine, cursor, dataPath, dataValue, dateFns, each, field, fields, fn, fnIf, group, lastReferenceValue, merge, scrubEmojis, sourceValue, util } from "@openfn/language-common";
@@ -0,0 +1,4 @@
1
+ export default Adaptor;
2
+ export * from "./Adaptor";
3
+ export * as http from "./http";
4
+ import * as Adaptor from "./Adaptor";