@segment/actions-core 2.3.2-alpha.0 → 2.3.2-alpha.1
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/dist/cjs/destination-kit/action.d.ts +18 -20
- package/dist/cjs/destination-kit/action.js +46 -114
- package/dist/cjs/destination-kit/action.js.map +1 -1
- package/dist/cjs/destination-kit/fields-to-jsonschema.d.ts +4 -2
- package/dist/cjs/destination-kit/fields-to-jsonschema.js.map +1 -1
- package/dist/cjs/destination-kit/index.d.ts +10 -22
- package/dist/cjs/destination-kit/index.js +17 -55
- package/dist/cjs/destination-kit/index.js.map +1 -1
- package/dist/cjs/destination-kit/types.d.ts +13 -2
- package/dist/cjs/mapping-kit/index.d.ts +1 -1
- package/dist/cjs/mapping-kit/index.js +5 -5
- package/dist/cjs/mapping-kit/index.js.map +1 -1
- package/dist/cjs/schema-validation.d.ts +1 -0
- package/dist/cjs/schema-validation.js +42 -0
- package/dist/cjs/schema-validation.js.map +1 -0
- package/dist/esm/destination-kit/action.d.ts +18 -20
- package/dist/esm/destination-kit/action.js +45 -112
- package/dist/esm/destination-kit/action.js.map +1 -1
- package/dist/esm/destination-kit/fields-to-jsonschema.d.ts +4 -2
- package/dist/esm/destination-kit/fields-to-jsonschema.js.map +1 -1
- package/dist/esm/destination-kit/index.d.ts +10 -22
- package/dist/esm/destination-kit/index.js +19 -57
- package/dist/esm/destination-kit/index.js.map +1 -1
- package/dist/esm/destination-kit/types.d.ts +13 -2
- package/dist/esm/mapping-kit/index.d.ts +1 -1
- package/dist/esm/mapping-kit/index.js +5 -5
- package/dist/esm/mapping-kit/index.js.map +1 -1
- package/dist/esm/schema-validation.d.ts +1 -0
- package/dist/esm/schema-validation.js +35 -0
- package/dist/esm/schema-validation.js.map +1 -0
- package/package.json +2 -2
- package/dist/cjs/destination-kit/parse-settings.d.ts +0 -9
- package/dist/cjs/destination-kit/parse-settings.js +0 -32
- package/dist/cjs/destination-kit/parse-settings.js.map +0 -1
- package/dist/cjs/destination-kit/step.d.ts +0 -25
- package/dist/cjs/destination-kit/step.js +0 -47
- package/dist/cjs/destination-kit/step.js.map +0 -1
- package/dist/esm/destination-kit/parse-settings.d.ts +0 -9
- package/dist/esm/destination-kit/parse-settings.js +0 -26
- package/dist/esm/destination-kit/parse-settings.js.map +0 -1
- package/dist/esm/destination-kit/step.d.ts +0 -25
- package/dist/esm/destination-kit/step.js +0 -42
- package/dist/esm/destination-kit/step.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function validateSchema(obj: unknown, schema: object, schemaKey?: string): void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.validateSchema = void 0;
|
|
7
|
+
const ajv_human_errors_1 = require("@segment/ajv-human-errors");
|
|
8
|
+
const ajv_1 = __importDefault(require("ajv"));
|
|
9
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
10
|
+
const ajv = new ajv_1.default({
|
|
11
|
+
coerceTypes: true,
|
|
12
|
+
allErrors: true,
|
|
13
|
+
verbose: true,
|
|
14
|
+
removeAdditional: true,
|
|
15
|
+
jsonPointers: true
|
|
16
|
+
});
|
|
17
|
+
ajv.addFormat('password', () => true);
|
|
18
|
+
ajv.addFormat('text', () => true);
|
|
19
|
+
ajv.addFormat('date-like', (data) => {
|
|
20
|
+
let date = dayjs_1.default(data);
|
|
21
|
+
if (String(Number(data)) === data) {
|
|
22
|
+
if (data.length === 13) {
|
|
23
|
+
date = dayjs_1.default(Number(data));
|
|
24
|
+
}
|
|
25
|
+
date = dayjs_1.default.unix(Number(data));
|
|
26
|
+
}
|
|
27
|
+
return date.isValid();
|
|
28
|
+
});
|
|
29
|
+
function validateSchema(obj, schema, schemaKey) {
|
|
30
|
+
let validate;
|
|
31
|
+
if (schemaKey) {
|
|
32
|
+
validate = ajv.getSchema(schemaKey) || ajv.addSchema(schema, schemaKey).getSchema(schemaKey);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
validate = ajv.compile(schema);
|
|
36
|
+
}
|
|
37
|
+
if (!validate(obj)) {
|
|
38
|
+
throw new ajv_human_errors_1.AggregateAjvError(validate.errors);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.validateSchema = validateSchema;
|
|
42
|
+
//# sourceMappingURL=schema-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-validation.js","sourceRoot":"","sources":["../../src/schema-validation.ts"],"names":[],"mappings":";;;;;;AACA,gEAA6D;AAC7D,8CAAqB;AACrB,kDAAyB;AAEzB,MAAM,GAAG,GAAG,IAAI,aAAG,CAAC;IAElB,WAAW,EAAE,IAAI;IAEjB,SAAS,EAAE,IAAI;IAEf,OAAO,EAAE,IAAI;IAEb,gBAAgB,EAAE,IAAI;IAEtB,YAAY,EAAE,IAAI;CACnB,CAAC,CAAA;AAGF,GAAG,CAAC,SAAS,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;AACrC,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;AACjC,GAAG,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,IAAY,EAAE,EAAE;IAC1C,IAAI,IAAI,GAAG,eAAK,CAAC,IAAI,CAAC,CAAA;IAEtB,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,EAAE;QAEjC,IAAI,IAAI,CAAC,MAAM,KAAK,EAAE,EAAE;YACtB,IAAI,GAAG,eAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;SAC3B;QAED,IAAI,GAAG,eAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;KAChC;IAED,OAAO,IAAI,CAAC,OAAO,EAAE,CAAA;AACvB,CAAC,CAAC,CAAA;AAMF,SAAgB,cAAc,CAAC,GAAY,EAAE,MAAc,EAAE,SAAkB;IAC7E,IAAI,QAA8B,CAAA;IAElC,IAAI,SAAS,EAAE;QAEb,QAAQ,GAAG,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,SAAS,CAAC,SAAS,CAAE,CAAA;KAC9F;SAAM;QACL,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;KAC/B;IAED,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAElB,MAAM,IAAI,oCAAiB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;KAC7C;AACH,CAAC;AAdD,wCAcC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import Ajv from 'ajv';
|
|
3
2
|
import { EventEmitter } from 'events';
|
|
4
3
|
import createRequestClient from '../create-request-client';
|
|
5
|
-
import { JSONLikeObject } from '../json-object';
|
|
6
|
-
import {
|
|
7
|
-
import type {
|
|
4
|
+
import { JSONLikeObject, JSONObject } from '../json-object';
|
|
5
|
+
import type { DynamicFieldResponse, InputField, RequestExtension, ExecuteInput, Result } from './types';
|
|
6
|
+
import type { JSONSchema4 } from 'json-schema';
|
|
8
7
|
declare type MaybePromise<T> = T | Promise<T>;
|
|
9
8
|
declare type RequestClient = ReturnType<typeof createRequestClient>;
|
|
10
9
|
export declare type RequestFn<Settings, Payload, Return = any> = (request: RequestClient, data: ExecuteInput<Settings, Payload>) => MaybePromise<Return>;
|
|
11
10
|
export interface ActionDefinition<Settings, Payload = any> {
|
|
12
11
|
title: string;
|
|
13
12
|
description: string;
|
|
13
|
+
platform?: 'cloud' | 'web';
|
|
14
14
|
defaultSubscription?: string;
|
|
15
15
|
hidden?: boolean;
|
|
16
16
|
fields: Record<string, InputField>;
|
|
@@ -19,28 +19,26 @@ export interface ActionDefinition<Settings, Payload = any> {
|
|
|
19
19
|
};
|
|
20
20
|
perform: RequestFn<Settings, Payload>;
|
|
21
21
|
}
|
|
22
|
-
export declare class Validate<Settings, Payload> extends Step<Settings, Payload> {
|
|
23
|
-
field: ExecuteInputField;
|
|
24
|
-
validate: Ajv.ValidateFunction;
|
|
25
|
-
constructor(field: ExecuteInputField, schema: object);
|
|
26
|
-
executeStep(data: ExecuteInput<Settings, Payload>): Promise<string>;
|
|
27
|
-
}
|
|
28
22
|
interface ExecuteDynamicFieldInput<Settings, Payload> {
|
|
29
23
|
settings: Settings;
|
|
30
24
|
payload: Payload;
|
|
31
25
|
page?: string;
|
|
32
26
|
}
|
|
33
|
-
declare type ExecuteInputField = 'payload' | 'settings';
|
|
34
27
|
export declare class Action<Settings, Payload extends JSONLikeObject> extends EventEmitter {
|
|
35
|
-
readonly
|
|
28
|
+
readonly definition: ActionDefinition<Settings, Payload>;
|
|
29
|
+
readonly destinationName: string;
|
|
30
|
+
readonly schema?: JSONSchema4;
|
|
36
31
|
private extendRequest;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
private
|
|
32
|
+
constructor(destinationName: string, definition: ActionDefinition<Settings, Payload>, extendRequest?: RequestExtension<Settings, Payload>);
|
|
33
|
+
execute(bundle: {
|
|
34
|
+
data: unknown;
|
|
35
|
+
settings: Settings;
|
|
36
|
+
mapping: JSONObject;
|
|
37
|
+
}): Promise<Result[]>;
|
|
38
|
+
executeDynamicField(field: string, data: ExecuteDynamicFieldInput<Settings, Payload>): unknown;
|
|
39
|
+
private performRequest;
|
|
40
|
+
private createRequestClient;
|
|
41
|
+
private afterResponse;
|
|
42
|
+
private parseResponse;
|
|
45
43
|
}
|
|
46
44
|
export {};
|
|
@@ -1,137 +1,70 @@
|
|
|
1
|
-
import { AggregateAjvError } from '@segment/ajv-human-errors';
|
|
2
|
-
import Ajv from 'ajv';
|
|
3
|
-
import dayjs from 'dayjs';
|
|
4
1
|
import { EventEmitter } from 'events';
|
|
5
2
|
import createRequestClient from '../create-request-client';
|
|
6
3
|
import { transform } from '../mapping-kit';
|
|
7
4
|
import { fieldsToJsonSchema } from './fields-to-jsonschema';
|
|
8
5
|
import { Response } from '../fetch';
|
|
9
|
-
import {
|
|
10
|
-
class MapInput extends Step {
|
|
11
|
-
executeStep(data) {
|
|
12
|
-
if (data.mapping) {
|
|
13
|
-
data.payload = transform(data.mapping, data.payload);
|
|
14
|
-
}
|
|
15
|
-
return Promise.resolve('MapInput completed');
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
const ajv = new Ajv({
|
|
19
|
-
coerceTypes: true,
|
|
20
|
-
allErrors: true,
|
|
21
|
-
verbose: true,
|
|
22
|
-
removeAdditional: true,
|
|
23
|
-
jsonPointers: true
|
|
24
|
-
});
|
|
25
|
-
ajv.addFormat('password', () => true);
|
|
26
|
-
ajv.addFormat('text', () => true);
|
|
27
|
-
ajv.addFormat('date-like', (data) => {
|
|
28
|
-
let date = dayjs(data);
|
|
29
|
-
if (String(Number(data)) === data) {
|
|
30
|
-
if (data.length === 13) {
|
|
31
|
-
date = dayjs(Number(data));
|
|
32
|
-
}
|
|
33
|
-
date = dayjs.unix(Number(data));
|
|
34
|
-
}
|
|
35
|
-
return date.isValid();
|
|
36
|
-
});
|
|
37
|
-
export class Validate extends Step {
|
|
38
|
-
constructor(field, schema) {
|
|
39
|
-
super();
|
|
40
|
-
this.field = field;
|
|
41
|
-
this.validate = ajv.compile(schema);
|
|
42
|
-
}
|
|
43
|
-
executeStep(data) {
|
|
44
|
-
if (!this.validate(data[this.field])) {
|
|
45
|
-
throw new AggregateAjvError(this.validate.errors);
|
|
46
|
-
}
|
|
47
|
-
return Promise.resolve('Validate completed');
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
class Request extends Step {
|
|
51
|
-
constructor(extendRequest, requestFn) {
|
|
52
|
-
super();
|
|
53
|
-
this.extendRequest = extendRequest;
|
|
54
|
-
this.requestFn = requestFn;
|
|
55
|
-
}
|
|
56
|
-
async executeStep(data) {
|
|
57
|
-
if (!this.requestFn) {
|
|
58
|
-
return '';
|
|
59
|
-
}
|
|
60
|
-
const requestClient = this.createRequestClient(data);
|
|
61
|
-
const response = await this.requestFn(requestClient, data);
|
|
62
|
-
if (response instanceof Response) {
|
|
63
|
-
return response.data ?? response.content;
|
|
64
|
-
}
|
|
65
|
-
return response;
|
|
66
|
-
}
|
|
67
|
-
createRequestClient(data) {
|
|
68
|
-
const options = this.extendRequest?.(data) ?? {};
|
|
69
|
-
const client = createRequestClient(options, {
|
|
70
|
-
afterResponse: [
|
|
71
|
-
(request, options, response) => {
|
|
72
|
-
const modifiedResponse = response;
|
|
73
|
-
modifiedResponse.request = request;
|
|
74
|
-
modifiedResponse.options = options;
|
|
75
|
-
this.emit('response', modifiedResponse);
|
|
76
|
-
return modifiedResponse;
|
|
77
|
-
}
|
|
78
|
-
]
|
|
79
|
-
});
|
|
80
|
-
return client;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
6
|
+
import { validateSchema } from '../schema-validation';
|
|
83
7
|
export class Action extends EventEmitter {
|
|
84
|
-
constructor(definition, extendRequest) {
|
|
8
|
+
constructor(destinationName, definition, extendRequest) {
|
|
85
9
|
super();
|
|
86
|
-
this.
|
|
87
|
-
|
|
88
|
-
this.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
this.extendRequest = extendRequest;
|
|
10
|
+
this.definition = definition;
|
|
11
|
+
this.destinationName = destinationName;
|
|
12
|
+
this.extendRequest = extendRequest;
|
|
13
|
+
if (Object.keys(definition.fields ?? {}).length) {
|
|
14
|
+
this.schema = fieldsToJsonSchema(definition.fields);
|
|
92
15
|
}
|
|
93
|
-
this.loadDefinition(definition);
|
|
94
16
|
}
|
|
95
|
-
async execute(
|
|
96
|
-
const results =
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
17
|
+
async execute(bundle) {
|
|
18
|
+
const results = [];
|
|
19
|
+
const payload = transform(bundle.mapping, bundle.data);
|
|
20
|
+
results.push({ output: 'Mappings resolved' });
|
|
21
|
+
if (this.schema) {
|
|
22
|
+
validateSchema(payload, this.schema, `${this.destinationName}:${this.definition.title}`);
|
|
23
|
+
results.push({ output: 'Payload validated' });
|
|
100
24
|
}
|
|
25
|
+
const dataBundle = {
|
|
26
|
+
rawData: bundle.data,
|
|
27
|
+
rawMapping: bundle.mapping,
|
|
28
|
+
settings: bundle.settings,
|
|
29
|
+
payload
|
|
30
|
+
};
|
|
31
|
+
const output = await this.performRequest(this.definition.perform, dataBundle);
|
|
32
|
+
results.push({ output: output });
|
|
101
33
|
return results;
|
|
102
34
|
}
|
|
103
35
|
executeDynamicField(field, data) {
|
|
104
|
-
|
|
36
|
+
const fn = this.definition.dynamicFields?.[field];
|
|
37
|
+
if (typeof fn !== 'function') {
|
|
105
38
|
return {
|
|
106
39
|
data: [],
|
|
107
40
|
pagination: {}
|
|
108
41
|
};
|
|
109
42
|
}
|
|
110
|
-
|
|
111
|
-
return step.executeStep(data);
|
|
43
|
+
return this.performRequest(fn, data);
|
|
112
44
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
Object.entries(definition.dynamicFields ?? {}).forEach(([field, callback]) => {
|
|
118
|
-
this.dynamicField(field, callback);
|
|
119
|
-
});
|
|
120
|
-
if (definition.perform) {
|
|
121
|
-
this.request(definition.perform);
|
|
122
|
-
}
|
|
45
|
+
async performRequest(requestFn, data) {
|
|
46
|
+
const requestClient = this.createRequestClient(data);
|
|
47
|
+
const response = await requestFn(requestClient, data);
|
|
48
|
+
return this.parseResponse(response);
|
|
123
49
|
}
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
50
|
+
createRequestClient(data) {
|
|
51
|
+
const options = this.extendRequest?.(data) ?? {};
|
|
52
|
+
return createRequestClient(options, {
|
|
53
|
+
afterResponse: [this.afterResponse.bind(this)]
|
|
54
|
+
});
|
|
127
55
|
}
|
|
128
|
-
|
|
129
|
-
|
|
56
|
+
afterResponse(request, options, response) {
|
|
57
|
+
const modifiedResponse = response;
|
|
58
|
+
modifiedResponse.request = request;
|
|
59
|
+
modifiedResponse.options = options;
|
|
60
|
+
this.emit('response', modifiedResponse);
|
|
61
|
+
return modifiedResponse;
|
|
130
62
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
63
|
+
parseResponse(response) {
|
|
64
|
+
if (response instanceof Response) {
|
|
65
|
+
return response.data ?? response.content;
|
|
66
|
+
}
|
|
67
|
+
return response;
|
|
135
68
|
}
|
|
136
69
|
}
|
|
137
70
|
//# sourceMappingURL=action.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../../src/destination-kit/action.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../../src/destination-kit/action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,mBAAmB,MAAM,0BAA0B,CAAA;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAKnC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AA6DrD,MAAM,OAAO,MAAiD,SAAQ,YAAY;IAMhF,YACE,eAAuB,EACvB,UAA+C,EAC/C,aAAmD;QAEnD,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;QACtC,IAAI,CAAC,aAAa,GAAG,aAAa,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|
|
2
|
+
import type { InputField, Optional } from './types';
|
|
3
|
+
declare type MinimalInputField = Optional<InputField, 'description'>;
|
|
4
|
+
export declare function fieldsToJsonSchema(fields?: Record<string, MinimalInputField>): JSONSchema4;
|
|
5
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fields-to-jsonschema.js","sourceRoot":"","sources":["../../../src/destination-kit/fields-to-jsonschema.ts"],"names":[],"mappings":"AAGA,SAAS,gBAAgB,CAAC,IAAmB;IAC3C,QAAQ,IAAI,EAAE;QACZ,KAAK,QAAQ,CAAC;QACd,KAAK,MAAM,CAAC;QACZ,KAAK,UAAU;YACb,OAAO,QAAQ,CAAA;QACjB,KAAK,UAAU;YACb,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;QAC7B;YACE,OAAO,IAAI,CAAA;KACd;AACH,CAAC;
|
|
1
|
+
{"version":3,"file":"fields-to-jsonschema.js","sourceRoot":"","sources":["../../../src/destination-kit/fields-to-jsonschema.ts"],"names":[],"mappings":"AAGA,SAAS,gBAAgB,CAAC,IAAmB;IAC3C,QAAQ,IAAI,EAAE;QACZ,KAAK,QAAQ,CAAC;QACd,KAAK,MAAM,CAAC;QACZ,KAAK,UAAU;YACb,OAAO,QAAQ,CAAA;QACjB,KAAK,UAAU;YACb,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;QAC7B;YACE,OAAO,IAAI,CAAA;KACd;AACH,CAAC;AAID,MAAM,UAAU,kBAAkB,CAAC,SAA4C,EAAE;IAC/E,MAAM,QAAQ,GAAa,EAAE,CAAA;IAC7B,MAAM,UAAU,GAAgC,EAAE,CAAA;IAElD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACjD,MAAM,UAAU,GAAG,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAE/C,IAAI,MAAM,GAAgB;YACxB,KAAK,EA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UAAU,CAAC,CAAA;aACpD;iBAAM;gBACL,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,kBAAkB,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAA;aAChE;SACF;QAED,UAAU,CAAC,GAAG,CAAC,GAAG,MAAM,CAAA;QAGxB,IAAI,KAAK,CAAC,QAAQ,EAAE;YAClB,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;SACnB;KACF;IAED,OAAO;QACL,OAAO,EAAE,gCAAgC;QACzC,IAAI,EAAE,QAAQ;QACd,oBAAoB,EAAE,KAAK;QAC3B,UAAU;QACV,QAAQ;KACT,CAAA;AACH,CAAC"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { JSONSchema4 } from 'json-schema';
|
|
1
|
+
import type { JSONSchema4 } from 'json-schema';
|
|
2
2
|
import { Action, ActionDefinition, RequestFn } from './action';
|
|
3
|
-
import { ExecuteInput, StepResult } from './step';
|
|
4
|
-
import { JSONLikeObject, JSONObject } from '../json-object';
|
|
5
|
-
import { SegmentEvent } from '../segment-event';
|
|
6
3
|
import { fieldsToJsonSchema } from './fields-to-jsonschema';
|
|
7
4
|
import { RequestClient } from '../create-request-client';
|
|
5
|
+
import type { JSONLikeObject, JSONObject } from '../json-object';
|
|
6
|
+
import type { SegmentEvent } from '../segment-event';
|
|
8
7
|
import type { ModifiedResponse } from '../types';
|
|
9
|
-
import type { InputField, RequestExtension } from './types';
|
|
8
|
+
import type { InputField, RequestExtension, ExecuteInput, Result } from './types';
|
|
10
9
|
import type { AllRequestOptions } from '../request-client';
|
|
11
|
-
import { AuthTokens } from './parse-settings';
|
|
12
10
|
export type { ActionDefinition, ExecuteInput, RequestFn };
|
|
13
11
|
export { fieldsToJsonSchema };
|
|
14
12
|
export interface SubscriptionStats {
|
|
@@ -18,7 +16,7 @@ export interface SubscriptionStats {
|
|
|
18
16
|
subscribe: string;
|
|
19
17
|
state: string;
|
|
20
18
|
input: JSONLikeObject;
|
|
21
|
-
output:
|
|
19
|
+
output: Result[] | null;
|
|
22
20
|
}
|
|
23
21
|
interface PartnerActions<Settings, Payload extends JSONLikeObject> {
|
|
24
22
|
[key: string]: Action<Settings, Payload>;
|
|
@@ -40,7 +38,7 @@ export interface Subscription {
|
|
|
40
38
|
subscribe: string;
|
|
41
39
|
mapping?: JSONObject;
|
|
42
40
|
}
|
|
43
|
-
export interface OAuth2ClientCredentials
|
|
41
|
+
export interface OAuth2ClientCredentials {
|
|
44
42
|
clientId: string;
|
|
45
43
|
clientSecret: string;
|
|
46
44
|
}
|
|
@@ -50,11 +48,6 @@ export interface RefreshAccessTokenResult {
|
|
|
50
48
|
}
|
|
51
49
|
interface AuthSettings<Settings> {
|
|
52
50
|
settings: Settings;
|
|
53
|
-
auth: AuthTokens;
|
|
54
|
-
}
|
|
55
|
-
interface RefreshAuthSettings<Settings> {
|
|
56
|
-
settings: Settings;
|
|
57
|
-
auth: OAuth2ClientCredentials;
|
|
58
51
|
}
|
|
59
52
|
interface Authentication<Settings> {
|
|
60
53
|
scheme: 'basic' | 'custom' | 'oauth2';
|
|
@@ -69,14 +62,13 @@ export interface BasicAuthentication<Settings> extends Authentication<Settings>
|
|
|
69
62
|
}
|
|
70
63
|
export interface OAuth2Authentication<Settings> extends Authentication<Settings> {
|
|
71
64
|
scheme: 'oauth2';
|
|
72
|
-
refreshAccessToken?: (request: RequestClient, input:
|
|
65
|
+
refreshAccessToken?: (request: RequestClient, input: AuthSettings<Settings>, oauthConfig: OAuth2ClientCredentials) => Promise<RefreshAccessTokenResult> | undefined;
|
|
73
66
|
}
|
|
74
67
|
export declare type AuthenticationScheme<Settings = any> = BasicAuthentication<Settings> | CustomAuthentication<Settings> | OAuth2Authentication<Settings>;
|
|
75
68
|
interface EventInput<Settings> {
|
|
76
69
|
readonly event: SegmentEvent;
|
|
77
70
|
readonly mapping: JSONObject;
|
|
78
71
|
readonly settings: Settings;
|
|
79
|
-
readonly auth?: AuthTokens;
|
|
80
72
|
}
|
|
81
73
|
export interface DecoratedResponse extends ModifiedResponse {
|
|
82
74
|
request: Request;
|
|
@@ -92,15 +84,11 @@ export declare class Destination<Settings = JSONObject> {
|
|
|
92
84
|
readonly settingsSchema?: JSONSchema4;
|
|
93
85
|
constructor(destination: DestinationDefinition<Settings>);
|
|
94
86
|
testAuthentication(settings: Settings): Promise<void>;
|
|
95
|
-
refreshAccessToken(settings: Settings,
|
|
87
|
+
refreshAccessToken(settings: Settings, oauthClientCredentials: OAuth2ClientCredentials): Promise<RefreshAccessTokenResult> | undefined;
|
|
96
88
|
private partnerAction;
|
|
97
|
-
protected executeAction(actionSlug: string, { event, mapping, settings
|
|
89
|
+
protected executeAction(actionSlug: string, { event, mapping, settings }: EventInput<Settings>): Promise<Result[]>;
|
|
98
90
|
private onSubscription;
|
|
99
|
-
onEvent(event: SegmentEvent, settings: JSONObject,
|
|
100
|
-
onTokenRefresh?: (tokens: RefreshAccessTokenResult) => void;
|
|
101
|
-
onComplete?: (stats: SubscriptionStats) => void;
|
|
102
|
-
}): Promise<StepResult[]>;
|
|
103
|
-
private onEventInternal;
|
|
91
|
+
onEvent(event: SegmentEvent, settings: JSONObject, onComplete?: (stats: SubscriptionStats) => void): Promise<Result[]>;
|
|
104
92
|
private getSubscriptions;
|
|
105
93
|
private getDestinationSettings;
|
|
106
94
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { validate, parseFql } from '@segment/fab5-subscriptions';
|
|
2
|
-
import { Action
|
|
2
|
+
import { Action } from './action';
|
|
3
3
|
import { time, duration } from '../time';
|
|
4
4
|
import { fieldsToJsonSchema } from './fields-to-jsonschema';
|
|
5
5
|
import createRequestClient from '../create-request-client';
|
|
6
|
-
import { IntegrationError
|
|
7
|
-
import {
|
|
6
|
+
import { IntegrationError } from '../errors';
|
|
7
|
+
import { validateSchema } from '../schema-validation';
|
|
8
8
|
export { fieldsToJsonSchema };
|
|
9
|
-
const RETRY_ATTEMPTS = 2;
|
|
10
|
-
const OAUTH2_SCHEME = 'oauth2';
|
|
11
9
|
export class Destination {
|
|
12
10
|
constructor(destination) {
|
|
13
11
|
this.definition = destination;
|
|
@@ -24,13 +22,9 @@ export class Destination {
|
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
async testAuthentication(settings) {
|
|
27
|
-
const
|
|
28
|
-
const auth = getAuthData(settings);
|
|
29
|
-
const data = { settings: destinationSettings, auth };
|
|
30
|
-
const context = { settings: destinationSettings, payload: {}, auth };
|
|
25
|
+
const context = { settings, payload: {} };
|
|
31
26
|
if (this.settingsSchema) {
|
|
32
|
-
|
|
33
|
-
await step.executeStep(context);
|
|
27
|
+
validateSchema(settings, this.settingsSchema, `${this.name}:settings`);
|
|
34
28
|
}
|
|
35
29
|
if (!this.authentication?.testAuthentication) {
|
|
36
30
|
return;
|
|
@@ -38,30 +32,26 @@ export class Destination {
|
|
|
38
32
|
const options = this.extendRequest?.(context) ?? {};
|
|
39
33
|
const requestClient = createRequestClient(options);
|
|
40
34
|
try {
|
|
41
|
-
await this.authentication.testAuthentication(requestClient,
|
|
35
|
+
await this.authentication.testAuthentication(requestClient, { settings });
|
|
42
36
|
}
|
|
43
37
|
catch (error) {
|
|
44
38
|
throw new Error('Credentials are invalid');
|
|
45
39
|
}
|
|
46
40
|
}
|
|
47
|
-
refreshAccessToken(settings,
|
|
48
|
-
if (this.authentication?.scheme !==
|
|
41
|
+
refreshAccessToken(settings, oauthClientCredentials) {
|
|
42
|
+
if (this.authentication?.scheme !== 'oauth2') {
|
|
49
43
|
throw new IntegrationError('refreshAccessToken is only valid with oauth2 authentication scheme', 'NotImplemented', 501);
|
|
50
44
|
}
|
|
51
|
-
const context = {
|
|
52
|
-
settings,
|
|
53
|
-
payload: {},
|
|
54
|
-
auth: getAuthData(settings)
|
|
55
|
-
};
|
|
45
|
+
const context = { settings, payload: {} };
|
|
56
46
|
const options = this.extendRequest?.(context) ?? {};
|
|
57
47
|
const requestClient = createRequestClient(options);
|
|
58
48
|
if (!this.authentication?.refreshAccessToken) {
|
|
59
49
|
return undefined;
|
|
60
50
|
}
|
|
61
|
-
return this.authentication.refreshAccessToken(requestClient, { settings,
|
|
51
|
+
return this.authentication.refreshAccessToken(requestClient, { settings }, oauthClientCredentials);
|
|
62
52
|
}
|
|
63
53
|
partnerAction(slug, definition) {
|
|
64
|
-
const action = new Action(definition, this.extendRequest);
|
|
54
|
+
const action = new Action(this.name, definition, this.extendRequest);
|
|
65
55
|
action.on('response', (response) => {
|
|
66
56
|
if (response) {
|
|
67
57
|
this.responses.push(response);
|
|
@@ -70,26 +60,24 @@ export class Destination {
|
|
|
70
60
|
this.actions[slug] = action;
|
|
71
61
|
return this;
|
|
72
62
|
}
|
|
73
|
-
executeAction(actionSlug, { event, mapping, settings
|
|
63
|
+
executeAction(actionSlug, { event, mapping, settings }) {
|
|
74
64
|
const action = this.actions[actionSlug];
|
|
75
65
|
if (!action) {
|
|
76
66
|
return Promise.resolve([]);
|
|
77
67
|
}
|
|
78
68
|
return action.execute({
|
|
79
69
|
mapping,
|
|
80
|
-
|
|
81
|
-
settings
|
|
82
|
-
auth
|
|
70
|
+
data: event,
|
|
71
|
+
settings
|
|
83
72
|
});
|
|
84
73
|
}
|
|
85
|
-
async onSubscription(subscription, event, settings,
|
|
74
|
+
async onSubscription(subscription, event, settings, onComplete) {
|
|
86
75
|
const subscriptionStartedAt = time();
|
|
87
76
|
const actionSlug = subscription.partnerAction;
|
|
88
77
|
const input = {
|
|
89
78
|
event,
|
|
90
79
|
mapping: subscription.mapping || {},
|
|
91
|
-
settings
|
|
92
|
-
auth
|
|
80
|
+
settings
|
|
93
81
|
};
|
|
94
82
|
let state = 'pending';
|
|
95
83
|
let results = null;
|
|
@@ -141,33 +129,10 @@ export class Destination {
|
|
|
141
129
|
});
|
|
142
130
|
}
|
|
143
131
|
}
|
|
144
|
-
async onEvent(event, settings,
|
|
145
|
-
for (let i = 0; i < RETRY_ATTEMPTS; i++) {
|
|
146
|
-
try {
|
|
147
|
-
return await this.onEventInternal(event, settings, options?.onComplete);
|
|
148
|
-
}
|
|
149
|
-
catch (error) {
|
|
150
|
-
const statusCode = error?.status ?? error?.response?.status ?? 500;
|
|
151
|
-
if (!(statusCode === 401 && this.authentication?.scheme === OAUTH2_SCHEME)) {
|
|
152
|
-
throw error;
|
|
153
|
-
}
|
|
154
|
-
const destinationSettings = this.getDestinationSettings(settings);
|
|
155
|
-
const oauthSettings = getOAuth2Data(settings);
|
|
156
|
-
const newTokens = await this.refreshAccessToken(destinationSettings, oauthSettings);
|
|
157
|
-
if (!newTokens) {
|
|
158
|
-
throw new InvalidAuthenticationError('Failed to refresh access token');
|
|
159
|
-
}
|
|
160
|
-
settings = updateOAuthSettings(settings, newTokens);
|
|
161
|
-
options?.onTokenRefresh?.(newTokens);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
throw new InvalidAuthenticationError();
|
|
165
|
-
}
|
|
166
|
-
async onEventInternal(event, settings, onComplete) {
|
|
132
|
+
async onEvent(event, settings, onComplete) {
|
|
167
133
|
const subscriptions = this.getSubscriptions(settings);
|
|
168
134
|
const destinationSettings = this.getDestinationSettings(settings);
|
|
169
|
-
const
|
|
170
|
-
const promises = subscriptions.map((subscription) => this.onSubscription(subscription, event, destinationSettings, authData, onComplete));
|
|
135
|
+
const promises = subscriptions.map((subscription) => this.onSubscription(subscription, event, destinationSettings, onComplete));
|
|
171
136
|
const results = await Promise.all(promises);
|
|
172
137
|
return [].concat(...results);
|
|
173
138
|
}
|
|
@@ -177,9 +142,6 @@ export class Destination {
|
|
|
177
142
|
if (subscription) {
|
|
178
143
|
parsedSubscriptions = [subscription];
|
|
179
144
|
}
|
|
180
|
-
else if (typeof subscriptions === 'string') {
|
|
181
|
-
parsedSubscriptions = JSON.parse(subscriptions);
|
|
182
|
-
}
|
|
183
145
|
else if (Array.isArray(subscriptions)) {
|
|
184
146
|
parsedSubscriptions = subscriptions;
|
|
185
147
|
}
|
|
@@ -189,7 +151,7 @@ export class Destination {
|
|
|
189
151
|
return parsedSubscriptions;
|
|
190
152
|
}
|
|
191
153
|
getDestinationSettings(settings) {
|
|
192
|
-
const { subcription, subscriptions,
|
|
154
|
+
const { subcription, subscriptions, ...otherSettings } = settings;
|
|
193
155
|
return otherSettings;
|
|
194
156
|
}
|
|
195
157
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destination-kit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAkB,MAAM,6BAA6B,CAAA;AAEhF,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destination-kit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAkB,MAAM,6BAA6B,CAAA;AAEhF,OAAO,EAAE,MAAM,EAA+B,MAAM,UAAU,CAAA;AAC9D,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,mBAAsC,MAAM,0BAA0B,CAAA;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAQrD,OAAO,EAAE,kBAAkB,EAAE,CAAA;AAyH7B,MAAM,OAAO,WAAW;IAUtB,YAAY,WAA4C;QACtD,IAAI,CAAC,UAAU,GAAG,WAAW,CAAA;QAC7B,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAA;QAC5B,IAAI,CAAC,aAAa,GAAG,WAAW,CAAC,aAAa,CAAA;QAC9C,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;QACjB,IAAI,CAAC,cAAc,GAAG,WAAW,CAAC,cAAc,CAAA;QAChD,IAAI,CAAC,SAAS,GAAG,EAAE,CAAA;QAGnB,IAAI,IAAI,C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AY,EAAE,aAAa,EAAE,GAAG,QAAQ,CAAA;QAChD,IAAI,mBAA4B,CAAA;QAEhC,IAAI,YAAY,EAAE;YAChB,mBAAmB,GAAG,CAAC,YAAY,CAAC,CAAA;SACrC;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;YACvC,mBAAmB,GAAG,aAAa,CAAA;SACpC;aAAM;YACL,mBAAmB,GAAG,EAAE,CAAA;SACzB;QAED,OAAO,mBAAqC,CAAA;IAC9C,CAAC;IAEO,sBAAsB,CAAC,QAAoB;QACjD,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,aAAa,EAAE,GAAG,QAAQ,CAAA;QACjE,OAAO,aAAoC,CAAA;IAC7C,CAAC;CACF"}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import type { RequestOptions } from '../request-client';
|
|
2
|
-
import type {
|
|
2
|
+
import type { JSONObject } from '../json-object';
|
|
3
|
+
export declare type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;
|
|
4
|
+
export interface Result {
|
|
5
|
+
output?: JSONObject | string | null | undefined;
|
|
6
|
+
error?: JSONObject | null;
|
|
7
|
+
}
|
|
8
|
+
export interface ExecuteInput<Settings, Payload> {
|
|
9
|
+
readonly mapping?: JSONObject;
|
|
10
|
+
readonly settings: Settings;
|
|
11
|
+
payload: Payload;
|
|
12
|
+
page?: string;
|
|
13
|
+
}
|
|
3
14
|
export interface DynamicFieldResponse {
|
|
4
15
|
body: {
|
|
5
16
|
data: DynamicFieldItem[];
|
|
@@ -23,7 +34,7 @@ export interface InputField {
|
|
|
23
34
|
placeholder?: string;
|
|
24
35
|
dynamic?: boolean;
|
|
25
36
|
required?: boolean;
|
|
26
|
-
properties?: Record<string, InputField
|
|
37
|
+
properties?: Record<string, Optional<InputField, 'description'>>;
|
|
27
38
|
format?: 'date' | 'time' | 'date-time' | 'uri' | 'uri-reference' | 'uri-template' | 'email' | 'hostname' | 'ipv4' | 'ipv6' | 'regex' | 'uuid' | 'password' | 'text';
|
|
28
39
|
}
|
|
29
40
|
export declare type FieldValue = string | number | boolean | object | Directive;
|