@openfn/language-telerivet 0.1.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 +72 -0
- package/ast.json +370 -0
- package/configuration-schema.json +24 -0
- package/dist/index.cjs +117 -0
- package/dist/index.js +94 -0
- package/package.json +51 -0
- package/types/Adaptor.d.ts +25 -0
- package/types/Client.d.ts +5 -0
- package/types/index.d.ts +3 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
|
|
25
|
+
// src/index.js
|
|
26
|
+
var src_exports = {};
|
|
27
|
+
__export(src_exports, {
|
|
28
|
+
alterState: () => import_language_common2.alterState,
|
|
29
|
+
dataPath: () => import_language_common2.dataPath,
|
|
30
|
+
dataValue: () => import_language_common2.dataValue,
|
|
31
|
+
default: () => src_default,
|
|
32
|
+
execute: () => execute,
|
|
33
|
+
field: () => import_language_common2.field,
|
|
34
|
+
fields: () => import_language_common2.fields,
|
|
35
|
+
fn: () => import_language_common2.fn,
|
|
36
|
+
lastReferenceValue: () => import_language_common2.lastReferenceValue,
|
|
37
|
+
merge: () => import_language_common2.merge,
|
|
38
|
+
send: () => send,
|
|
39
|
+
sourceValue: () => import_language_common2.sourceValue
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(src_exports);
|
|
42
|
+
|
|
43
|
+
// src/Adaptor.js
|
|
44
|
+
var Adaptor_exports = {};
|
|
45
|
+
__export(Adaptor_exports, {
|
|
46
|
+
alterState: () => import_language_common2.alterState,
|
|
47
|
+
dataPath: () => import_language_common2.dataPath,
|
|
48
|
+
dataValue: () => import_language_common2.dataValue,
|
|
49
|
+
execute: () => execute,
|
|
50
|
+
field: () => import_language_common2.field,
|
|
51
|
+
fields: () => import_language_common2.fields,
|
|
52
|
+
fn: () => import_language_common2.fn,
|
|
53
|
+
lastReferenceValue: () => import_language_common2.lastReferenceValue,
|
|
54
|
+
merge: () => import_language_common2.merge,
|
|
55
|
+
send: () => send,
|
|
56
|
+
sourceValue: () => import_language_common2.sourceValue
|
|
57
|
+
});
|
|
58
|
+
var import_language_common = require("@openfn/language-common");
|
|
59
|
+
|
|
60
|
+
// src/Client.js
|
|
61
|
+
var import_superagent = __toESM(require("superagent"), 1);
|
|
62
|
+
function post({ apiKey, body, url }) {
|
|
63
|
+
return new Promise((resolve, reject) => {
|
|
64
|
+
import_superagent.default.post(url).type("json").accept("json").auth(apiKey).send(JSON.stringify(body)).end((error, res) => {
|
|
65
|
+
if (!!error || !res.ok) {
|
|
66
|
+
reject(error);
|
|
67
|
+
}
|
|
68
|
+
resolve(res);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/Adaptor.js
|
|
74
|
+
var import_language_common2 = require("@openfn/language-common");
|
|
75
|
+
function execute(...operations) {
|
|
76
|
+
const initialState = {
|
|
77
|
+
references: [],
|
|
78
|
+
data: null
|
|
79
|
+
};
|
|
80
|
+
return (state) => {
|
|
81
|
+
return (0, import_language_common.execute)(...operations)({ ...initialState, ...state });
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function send(sendData) {
|
|
85
|
+
return (state) => {
|
|
86
|
+
const body = (0, import_language_common.expandReferences)(sendData)(state);
|
|
87
|
+
const { projectId, apiKey } = state.configuration;
|
|
88
|
+
const url = "https://api.telerivet.com/v1/projects/".concat(
|
|
89
|
+
projectId,
|
|
90
|
+
"/messages/send"
|
|
91
|
+
);
|
|
92
|
+
console.log(url);
|
|
93
|
+
console.log("Posting message to send:");
|
|
94
|
+
console.log(body);
|
|
95
|
+
return post({ apiKey, body, url }).then((result) => {
|
|
96
|
+
console.log("Success:", result);
|
|
97
|
+
return { ...state, references: [result, ...state.references] };
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// src/index.js
|
|
103
|
+
var src_default = Adaptor_exports;
|
|
104
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
+
0 && (module.exports = {
|
|
106
|
+
alterState,
|
|
107
|
+
dataPath,
|
|
108
|
+
dataValue,
|
|
109
|
+
execute,
|
|
110
|
+
field,
|
|
111
|
+
fields,
|
|
112
|
+
fn,
|
|
113
|
+
lastReferenceValue,
|
|
114
|
+
merge,
|
|
115
|
+
send,
|
|
116
|
+
sourceValue
|
|
117
|
+
});
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
alterState: () => alterState,
|
|
11
|
+
dataPath: () => dataPath,
|
|
12
|
+
dataValue: () => dataValue,
|
|
13
|
+
execute: () => execute,
|
|
14
|
+
field: () => field,
|
|
15
|
+
fields: () => fields,
|
|
16
|
+
fn: () => fn,
|
|
17
|
+
lastReferenceValue: () => lastReferenceValue,
|
|
18
|
+
merge: () => merge,
|
|
19
|
+
send: () => send,
|
|
20
|
+
sourceValue: () => sourceValue
|
|
21
|
+
});
|
|
22
|
+
import {
|
|
23
|
+
execute as commonExecute,
|
|
24
|
+
expandReferences
|
|
25
|
+
} from "@openfn/language-common";
|
|
26
|
+
|
|
27
|
+
// src/Client.js
|
|
28
|
+
import request from "superagent";
|
|
29
|
+
function post({ apiKey, body, url }) {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
request.post(url).type("json").accept("json").auth(apiKey).send(JSON.stringify(body)).end((error, res) => {
|
|
32
|
+
if (!!error || !res.ok) {
|
|
33
|
+
reject(error);
|
|
34
|
+
}
|
|
35
|
+
resolve(res);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// src/Adaptor.js
|
|
41
|
+
import {
|
|
42
|
+
fn,
|
|
43
|
+
alterState,
|
|
44
|
+
field,
|
|
45
|
+
fields,
|
|
46
|
+
sourceValue,
|
|
47
|
+
merge,
|
|
48
|
+
dataPath,
|
|
49
|
+
dataValue,
|
|
50
|
+
lastReferenceValue
|
|
51
|
+
} from "@openfn/language-common";
|
|
52
|
+
function execute(...operations) {
|
|
53
|
+
const initialState = {
|
|
54
|
+
references: [],
|
|
55
|
+
data: null
|
|
56
|
+
};
|
|
57
|
+
return (state) => {
|
|
58
|
+
return commonExecute(...operations)({ ...initialState, ...state });
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function send(sendData) {
|
|
62
|
+
return (state) => {
|
|
63
|
+
const body = expandReferences(sendData)(state);
|
|
64
|
+
const { projectId, apiKey } = state.configuration;
|
|
65
|
+
const url = "https://api.telerivet.com/v1/projects/".concat(
|
|
66
|
+
projectId,
|
|
67
|
+
"/messages/send"
|
|
68
|
+
);
|
|
69
|
+
console.log(url);
|
|
70
|
+
console.log("Posting message to send:");
|
|
71
|
+
console.log(body);
|
|
72
|
+
return post({ apiKey, body, url }).then((result) => {
|
|
73
|
+
console.log("Success:", result);
|
|
74
|
+
return { ...state, references: [result, ...state.references] };
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// src/index.js
|
|
80
|
+
var src_default = Adaptor_exports;
|
|
81
|
+
export {
|
|
82
|
+
alterState,
|
|
83
|
+
dataPath,
|
|
84
|
+
dataValue,
|
|
85
|
+
src_default as default,
|
|
86
|
+
execute,
|
|
87
|
+
field,
|
|
88
|
+
fields,
|
|
89
|
+
fn,
|
|
90
|
+
lastReferenceValue,
|
|
91
|
+
merge,
|
|
92
|
+
send,
|
|
93
|
+
sourceValue
|
|
94
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openfn/language-telerivet",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "telerivet Language Pack for OpenFn",
|
|
5
|
+
"main": "dist/index.cjs",
|
|
6
|
+
"author": "Open Function Group",
|
|
7
|
+
"license": "LGPLv3",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist/",
|
|
10
|
+
"types/",
|
|
11
|
+
"ast.json",
|
|
12
|
+
"configuration-schema.json"
|
|
13
|
+
],
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@openfn/language-common": "^1.7.5",
|
|
16
|
+
"JSONPath": "^0.10.0",
|
|
17
|
+
"lodash-fp": "^0.10.4",
|
|
18
|
+
"superagent": "^1.8.5"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@openfn/buildtools": "^1.0.2",
|
|
22
|
+
"@openfn/simple-ast": "0.4.1",
|
|
23
|
+
"assertion-error": "^1.1.0",
|
|
24
|
+
"chai": "^3.5.0",
|
|
25
|
+
"deep-eql": "^0.1.3",
|
|
26
|
+
"esno": "^0.16.3",
|
|
27
|
+
"mocha": "^10.1.0",
|
|
28
|
+
"rimraf": "^3.0.2",
|
|
29
|
+
"superagent-mock": "^1.12.0"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/openfn/adaptors.git"
|
|
34
|
+
},
|
|
35
|
+
"type": "module",
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"import": "./dist/index.js",
|
|
39
|
+
"require": "./dist/index.cjs"
|
|
40
|
+
},
|
|
41
|
+
"./package.json": "./package.json"
|
|
42
|
+
},
|
|
43
|
+
"types": "types/index.d.ts",
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "pnpm clean && build-adaptor telerivet",
|
|
46
|
+
"test": "mocha --experimental-specifier-resolution=node --no-warnings",
|
|
47
|
+
"test:watch": "mocha -w --experimental-specifier-resolution=node --no-warnings",
|
|
48
|
+
"clean": "rimraf dist types docs",
|
|
49
|
+
"pack": "pnpm pack --pack-destination ../../dist"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execute a sequence of operations.
|
|
3
|
+
* Wraps `@openfn/language-common/execute`, and prepends initial state for telerivet.
|
|
4
|
+
* @example
|
|
5
|
+
* execute(
|
|
6
|
+
* create('foo'),
|
|
7
|
+
* delete('bar')
|
|
8
|
+
* )(state)
|
|
9
|
+
* @function
|
|
10
|
+
* @param {Operations} operations - Operations to be performed.
|
|
11
|
+
* @returns {Operation}
|
|
12
|
+
*/
|
|
13
|
+
export function execute(...operations: Operations): Operation;
|
|
14
|
+
/**
|
|
15
|
+
* Send a message
|
|
16
|
+
* @example
|
|
17
|
+
* execute(
|
|
18
|
+
* send(data)
|
|
19
|
+
* )(state)
|
|
20
|
+
* @function
|
|
21
|
+
* @param {object} sendData - Payload data for the message
|
|
22
|
+
* @returns {Operation}
|
|
23
|
+
*/
|
|
24
|
+
export function send(sendData: object): Operation;
|
|
25
|
+
export { fn, alterState, field, fields, sourceValue, merge, dataPath, dataValue, lastReferenceValue } from "@openfn/language-common";
|
package/types/index.d.ts
ADDED