@openfn/language-intuit 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/LICENSE +674 -0
- package/LICENSE.LESSER +165 -0
- package/README.md +43 -0
- package/ast.json +525 -0
- package/configuration-schema.json +29 -0
- package/dist/index.cjs +148 -0
- package/dist/index.js +132 -0
- package/package.json +48 -0
- package/types/Adaptor.d.ts +1 -0
- package/types/Utils.d.ts +2 -0
- package/types/http.d.ts +82 -0
- package/types/index.d.ts +4 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/Adaptor.js
|
|
8
|
+
var Adaptor_exports = {};
|
|
9
|
+
__export(Adaptor_exports, {
|
|
10
|
+
cursor: () => cursor,
|
|
11
|
+
dataPath: () => dataPath,
|
|
12
|
+
dataValue: () => dataValue,
|
|
13
|
+
dateFns: () => dateFns,
|
|
14
|
+
each: () => each,
|
|
15
|
+
field: () => field,
|
|
16
|
+
fields: () => fields,
|
|
17
|
+
fn: () => fn,
|
|
18
|
+
lastReferenceValue: () => lastReferenceValue,
|
|
19
|
+
merge: () => merge,
|
|
20
|
+
sourceValue: () => sourceValue
|
|
21
|
+
});
|
|
22
|
+
import {
|
|
23
|
+
dataPath,
|
|
24
|
+
dataValue,
|
|
25
|
+
dateFns,
|
|
26
|
+
cursor,
|
|
27
|
+
each,
|
|
28
|
+
field,
|
|
29
|
+
fields,
|
|
30
|
+
fn,
|
|
31
|
+
lastReferenceValue,
|
|
32
|
+
merge,
|
|
33
|
+
sourceValue
|
|
34
|
+
} from "@openfn/language-common";
|
|
35
|
+
|
|
36
|
+
// src/http.js
|
|
37
|
+
var http_exports = {};
|
|
38
|
+
__export(http_exports, {
|
|
39
|
+
get: () => get,
|
|
40
|
+
post: () => post
|
|
41
|
+
});
|
|
42
|
+
import { expandReferences } from "@openfn/language-common/util";
|
|
43
|
+
|
|
44
|
+
// src/Utils.js
|
|
45
|
+
import { composeNextState } from "@openfn/language-common";
|
|
46
|
+
import {
|
|
47
|
+
request as commonRequest,
|
|
48
|
+
logResponse
|
|
49
|
+
} from "@openfn/language-common/util";
|
|
50
|
+
var prepareNextState = (state, response) => {
|
|
51
|
+
const { body, ...responseWithoutBody } = response;
|
|
52
|
+
if (!state.references) {
|
|
53
|
+
state.references = [];
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
...composeNextState(state, response.body),
|
|
57
|
+
response: responseWithoutBody
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
var request = (state, method, path, options = {}) => {
|
|
61
|
+
const { baseUrl, access_token } = state.configuration;
|
|
62
|
+
if (!access_token) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
"No access_token found in state.configuration. Please ensure you have authenticated before making a request."
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
const { query = {}, body = {}, headers = {}, parseAs = "json" } = options;
|
|
68
|
+
const opts = {
|
|
69
|
+
parseAs,
|
|
70
|
+
baseUrl,
|
|
71
|
+
body,
|
|
72
|
+
query,
|
|
73
|
+
headers: {
|
|
74
|
+
Authorization: `Bearer ${access_token}`,
|
|
75
|
+
"Content-type": "application/json",
|
|
76
|
+
Accept: "application/json",
|
|
77
|
+
...headers
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return commonRequest(method, path, opts).then(logResponse);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// src/http.js
|
|
84
|
+
function get(path, options = {}) {
|
|
85
|
+
return async (state) => {
|
|
86
|
+
const [resolvedPath, resolvedOptions = {}] = expandReferences(
|
|
87
|
+
state,
|
|
88
|
+
path,
|
|
89
|
+
options
|
|
90
|
+
);
|
|
91
|
+
const response = await request(
|
|
92
|
+
state,
|
|
93
|
+
"GET",
|
|
94
|
+
resolvedPath,
|
|
95
|
+
resolvedOptions
|
|
96
|
+
);
|
|
97
|
+
return prepareNextState(state, response);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function post(path, data, options = {}) {
|
|
101
|
+
return async (state) => {
|
|
102
|
+
const [resolvedPath, resolvedBody, resolvedOptions = {}] = expandReferences(
|
|
103
|
+
state,
|
|
104
|
+
path,
|
|
105
|
+
data,
|
|
106
|
+
options
|
|
107
|
+
);
|
|
108
|
+
const response = await request(state, "POST", resolvedPath, {
|
|
109
|
+
...resolvedOptions,
|
|
110
|
+
body: resolvedBody
|
|
111
|
+
});
|
|
112
|
+
return prepareNextState(state, response);
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// src/index.js
|
|
117
|
+
var src_default = Adaptor_exports;
|
|
118
|
+
export {
|
|
119
|
+
cursor,
|
|
120
|
+
dataPath,
|
|
121
|
+
dataValue,
|
|
122
|
+
dateFns,
|
|
123
|
+
src_default as default,
|
|
124
|
+
each,
|
|
125
|
+
field,
|
|
126
|
+
fields,
|
|
127
|
+
fn,
|
|
128
|
+
http_exports as http,
|
|
129
|
+
lastReferenceValue,
|
|
130
|
+
merge,
|
|
131
|
+
sourceValue
|
|
132
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openfn/language-intuit",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "OpenFn intuit 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.3.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"assertion-error": "2.0.0",
|
|
27
|
+
"chai": "4.3.6",
|
|
28
|
+
"deep-eql": "4.1.1",
|
|
29
|
+
"esno": "^0.16.3",
|
|
30
|
+
"mocha": "^10.7.3",
|
|
31
|
+
"rimraf": "3.0.2",
|
|
32
|
+
"undici": "^5.22.1"
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/openfn/adaptors.git"
|
|
37
|
+
},
|
|
38
|
+
"types": "types/index.d.ts",
|
|
39
|
+
"main": "dist/index.cjs",
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "pnpm clean && build-adaptor intuit",
|
|
42
|
+
"test": "mocha --experimental-specifier-resolution=node --no-warnings",
|
|
43
|
+
"test:watch": "mocha -w --experimental-specifier-resolution=node --no-warnings",
|
|
44
|
+
"clean": "rimraf dist types docs",
|
|
45
|
+
"pack": "pnpm pack --pack-destination ../../dist",
|
|
46
|
+
"lint": "eslint src"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { dataPath, dataValue, dateFns, cursor, each, field, fields, fn, lastReferenceValue, merge, sourceValue } from "@openfn/language-common";
|
package/types/Utils.d.ts
ADDED
package/types/http.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State object
|
|
3
|
+
* @typedef {Object} IntuitState
|
|
4
|
+
* @property data - The response body (as JSON)
|
|
5
|
+
* @property response - The HTTP response from the Quickbook(intuit) server (excluding the body)
|
|
6
|
+
* @property references - An array of all previous data objects used in the Job
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Options object
|
|
10
|
+
* @typedef {Object} IntuitOptions
|
|
11
|
+
* @property {object} query - An object of query parameters to be encoded into the URL
|
|
12
|
+
* @property {object} headers - An object of all request headers
|
|
13
|
+
* @property {string} [parseAs='json'] - The response format to parse (e.g., 'json', 'text', or 'stream')
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Make a GET request to any intuit endpoint
|
|
17
|
+
* @example <caption>Get intuit user company information.</caption>
|
|
18
|
+
* http.get("/v3/company/9341453908059456/companyinfo/9341453908059456");
|
|
19
|
+
* @function
|
|
20
|
+
* @public
|
|
21
|
+
* @param {string} path - Path to resource
|
|
22
|
+
* @param {IntuitOptions} [options={}] - An object containing query and headers for the request
|
|
23
|
+
* @state {IntuitState}
|
|
24
|
+
* @returns {Operation}
|
|
25
|
+
*/
|
|
26
|
+
export function get(path: string, options?: IntuitOptions): Operation;
|
|
27
|
+
/**
|
|
28
|
+
* Make a POST request to any Intuit endpoint
|
|
29
|
+
* @example <caption>Create an account on intuit.</caption>
|
|
30
|
+
* http.post("/v3/company/9341453908059456/account",
|
|
31
|
+
* {
|
|
32
|
+
* "Name": "MyJobs_testing",
|
|
33
|
+
* "AccountType": "Accounts Receivable"
|
|
34
|
+
* },
|
|
35
|
+
* {
|
|
36
|
+
* query: {
|
|
37
|
+
* minorversion: 40,
|
|
38
|
+
* },
|
|
39
|
+
* })
|
|
40
|
+
* @function
|
|
41
|
+
* @public
|
|
42
|
+
* @param {string} path - Path to resource
|
|
43
|
+
* @param {object} data - The request body (as JSON)
|
|
44
|
+
* @param {IntuitOptions} [options={}] - An object containing query, and headers for the request
|
|
45
|
+
* @state {IntuitState}
|
|
46
|
+
* @returns {Operation}
|
|
47
|
+
*/
|
|
48
|
+
export function post(path: string, data: object, options?: IntuitOptions): Operation;
|
|
49
|
+
/**
|
|
50
|
+
* State object
|
|
51
|
+
*/
|
|
52
|
+
export type IntuitState = {
|
|
53
|
+
/**
|
|
54
|
+
* - The response body (as JSON)
|
|
55
|
+
*/
|
|
56
|
+
data: any;
|
|
57
|
+
/**
|
|
58
|
+
* - The HTTP response from the Quickbook(intuit) server (excluding the body)
|
|
59
|
+
*/
|
|
60
|
+
response: any;
|
|
61
|
+
/**
|
|
62
|
+
* - An array of all previous data objects used in the Job
|
|
63
|
+
*/
|
|
64
|
+
references: any;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Options object
|
|
68
|
+
*/
|
|
69
|
+
export type IntuitOptions = {
|
|
70
|
+
/**
|
|
71
|
+
* - An object of query parameters to be encoded into the URL
|
|
72
|
+
*/
|
|
73
|
+
query: object;
|
|
74
|
+
/**
|
|
75
|
+
* - An object of all request headers
|
|
76
|
+
*/
|
|
77
|
+
headers: object;
|
|
78
|
+
/**
|
|
79
|
+
* - The response format to parse (e.g., 'json', 'text', or 'stream')
|
|
80
|
+
*/
|
|
81
|
+
parseAs?: string;
|
|
82
|
+
};
|
package/types/index.d.ts
ADDED