@trayio/cdk-dsl 5.18.0-unstable → 5.18.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/dist/connector/operation/OperationHandler.d.ts +1 -27
- package/dist/connector/operation/OperationHandler.d.ts.map +1 -1
- package/dist/connector/operation/OperationHandler.js +3 -18
- package/dist/connector/operation/OperationHandlerSetup.d.ts +1 -11
- package/dist/connector/operation/OperationHandlerSetup.d.ts.map +1 -1
- package/dist/connector/operation/OperationHandlerSetup.js +0 -118
- package/dist/connector/operation/OperationHandlerUtils.test.d.ts +2 -0
- package/dist/connector/operation/OperationHandlerUtils.test.d.ts.map +1 -0
- package/package.json +3 -4
- package/dist/connector/operation/OperationHandlerSetup.polling.unit.test.d.ts +0 -2
- package/dist/connector/operation/OperationHandlerSetup.polling.unit.test.d.ts.map +0 -1
- package/dist/connector/operation/OperationHandlerSetup.polling.unit.test.js +0 -305
- package/dist/connector/operation/OperationHandlerUtils.unit.test.d.ts +0 -2
- package/dist/connector/operation/OperationHandlerUtils.unit.test.d.ts.map +0 -1
- package/dist/connector/operation/PollOperationHandler.d.ts +0 -44
- package/dist/connector/operation/PollOperationHandler.d.ts.map +0 -1
- package/dist/connector/operation/PollOperationHandler.js +0 -17
- package/dist/connector/operation/__fixtures__/polling_op/operation.json +0 -6
- package/dist/connector/operation/__fixtures__/regular_op/operation.json +0 -5
- /package/dist/connector/operation/{OperationHandlerUtils.unit.test.js → OperationHandlerUtils.test.js} +0 -0
|
@@ -44,10 +44,6 @@ export type OperationHandlerContext<AUTH extends OperationHandlerAuth<unknown, u
|
|
|
44
44
|
workspaceIdHash?: string;
|
|
45
45
|
datapotIdHash?: string;
|
|
46
46
|
executionLogUrlHash?: string;
|
|
47
|
-
connectorName?: string;
|
|
48
|
-
connectorVersion?: string;
|
|
49
|
-
executionToken?: string;
|
|
50
|
-
publicUrl?: string;
|
|
51
47
|
};
|
|
52
48
|
export type OperationHandlerReference<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT> = {
|
|
53
49
|
name: string;
|
|
@@ -100,19 +96,6 @@ export type TriggerResponseOperationInput<I, R> = {
|
|
|
100
96
|
input: I;
|
|
101
97
|
response: R;
|
|
102
98
|
};
|
|
103
|
-
export type TriggerPollRequestOperationInput<IN> = {
|
|
104
|
-
input: IN;
|
|
105
|
-
cursor: unknown;
|
|
106
|
-
};
|
|
107
|
-
export type TriggerPollRequestOperationOutput<EVENT> = {
|
|
108
|
-
events: EVENT[];
|
|
109
|
-
nextCursor: unknown;
|
|
110
|
-
canPollMore: boolean;
|
|
111
|
-
};
|
|
112
|
-
export type TriggerPollDedupOperationInput<IN, EVENT> = {
|
|
113
|
-
input: IN;
|
|
114
|
-
event: EVENT;
|
|
115
|
-
};
|
|
116
99
|
export type DDLOperationOutputElement<T extends string | number> = {
|
|
117
100
|
text: string;
|
|
118
101
|
value: T;
|
|
@@ -172,7 +155,6 @@ export type OperationHandlerResultUsageMetadata = {
|
|
|
172
155
|
};
|
|
173
156
|
export type OperationHandlerResultMetadata = {
|
|
174
157
|
usage?: Array<OperationHandlerResultUsageMetadata>;
|
|
175
|
-
triggerDeduplicationId?: string;
|
|
176
158
|
};
|
|
177
159
|
export type OperationHandlerResultHeaders = {
|
|
178
160
|
metadata?: OperationHandlerResultMetadata;
|
|
@@ -219,14 +201,6 @@ export declare enum OperationHandlerType {
|
|
|
219
201
|
TriggerEvent = "trigger-event",
|
|
220
202
|
TriggerRequest = "trigger-request",
|
|
221
203
|
TriggerDestroy = "trigger-destroy",
|
|
222
|
-
DynamicOutput = "dynamic-output"
|
|
223
|
-
TriggerPollCreate = "trigger-poll-create",
|
|
224
|
-
TriggerPollDestroy = "trigger-poll-destroy",
|
|
225
|
-
TriggerPollRequest = "trigger-poll-request",
|
|
226
|
-
TriggerPollDedup = "trigger-poll-dedup"
|
|
227
|
-
}
|
|
228
|
-
export declare enum TriggerType {
|
|
229
|
-
Normal = "normal",
|
|
230
|
-
Polling = "polling"
|
|
204
|
+
DynamicOutput = "dynamic-output"
|
|
231
205
|
}
|
|
232
206
|
//# sourceMappingURL=OperationHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationHandler.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,MAAM,MAAM,oBAAoB,CAAC,IAAI,EAAE,GAAG,IAAI;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,GAAG,CAAC;IACT,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,yBAAyB,CAAC,IAAI,EAAE,GAAG,IAAI,oBAAoB,CACtE,IAAI,EACJ,GAAG,CACH,GAAG;IACH,QAAQ,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,0BAA0B,CAAC,IAAI,EAAE,GAAG,IAAI,oBAAoB,CACvE,IAAI,EACJ,GAAG,CACH,GAAG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,0BAA0B,CAAC,IAAI,EAAE,GAAG,IAAI,oBAAoB,CACvE,IAAI,EACJ,GAAG,CACH,GAAG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,kCAAkC,CAAC,IAAI,EAAE,GAAG,IACvD,oBAAoB,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG;IACjC,QAAQ,EAAE,iBAAiB,CAAC;CAC5B,CAAC;AAEH,MAAM,MAAM,2CAA2C,CAAC,IAAI,EAAE,GAAG,IAChE,oBAAoB,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG;IACjC,QAAQ,EAAE,2BAA2B,CAAC;CACtC,CAAC;AAEH,MAAM,MAAM,2BAA2B,CAAC,IAAI,EAAE,GAAG,IAAI,oBAAoB,CACxE,IAAI,EACJ,GAAG,CACH,GAAG;IACH,QAAQ,EAAE,SAAS,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,uBAAuB,CAClC,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,IAChD;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mBAAmB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"OperationHandler.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC,MAAM,MAAM,oBAAoB,CAAC,IAAI,EAAE,GAAG,IAAI;IAC7C,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,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|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.OperationHandlerType = exports.OperationHandlerResultInternal = exports.OperationHandlerResult = exports.OperationHandlerError = exports.TriggerOperationHttpResponse = void 0;
|
|
27
27
|
const E = __importStar(require("fp-ts/Either"));
|
|
28
28
|
exports.TriggerOperationHttpResponse = {
|
|
29
29
|
withStatusCode: (statusCode) => ({
|
|
@@ -109,10 +109,7 @@ exports.OperationHandlerResult = {
|
|
|
109
109
|
if (result.isFailure) {
|
|
110
110
|
throw new Error(`Result could not be read because it is a failure: ${JSON.stringify(result.error)}`);
|
|
111
111
|
}
|
|
112
|
-
|
|
113
|
-
throw new Error(`Result could not be read because it is pending${result.message ? `: ${result.message}` : ''}`);
|
|
114
|
-
}
|
|
115
|
-
throw new Error('Result could not be read');
|
|
112
|
+
throw new Error(`Result could not be read because it is pending${result.message ? `: ${result.message}` : ''}`);
|
|
116
113
|
},
|
|
117
114
|
map: (result, mapping) => {
|
|
118
115
|
if (result.isSuccess) {
|
|
@@ -121,10 +118,7 @@ exports.OperationHandlerResult = {
|
|
|
121
118
|
if (result.isFailure) {
|
|
122
119
|
return exports.OperationHandlerResult.failure(result.error, result.metadata);
|
|
123
120
|
}
|
|
124
|
-
|
|
125
|
-
return exports.OperationHandlerResult.pending(result.message, result.metadata);
|
|
126
|
-
}
|
|
127
|
-
throw new Error('Unknown OperationHandlerResult state');
|
|
121
|
+
return exports.OperationHandlerResult.pending(result.message, result.metadata);
|
|
128
122
|
},
|
|
129
123
|
};
|
|
130
124
|
exports.OperationHandlerResultInternal = {
|
|
@@ -140,13 +134,4 @@ var OperationHandlerType;
|
|
|
140
134
|
OperationHandlerType["TriggerRequest"] = "trigger-request";
|
|
141
135
|
OperationHandlerType["TriggerDestroy"] = "trigger-destroy";
|
|
142
136
|
OperationHandlerType["DynamicOutput"] = "dynamic-output";
|
|
143
|
-
OperationHandlerType["TriggerPollCreate"] = "trigger-poll-create";
|
|
144
|
-
OperationHandlerType["TriggerPollDestroy"] = "trigger-poll-destroy";
|
|
145
|
-
OperationHandlerType["TriggerPollRequest"] = "trigger-poll-request";
|
|
146
|
-
OperationHandlerType["TriggerPollDedup"] = "trigger-poll-dedup";
|
|
147
137
|
})(OperationHandlerType || (exports.OperationHandlerType = OperationHandlerType = {}));
|
|
148
|
-
var TriggerType;
|
|
149
|
-
(function (TriggerType) {
|
|
150
|
-
TriggerType["Normal"] = "normal";
|
|
151
|
-
TriggerType["Polling"] = "polling";
|
|
152
|
-
})(TriggerType || (exports.TriggerType = TriggerType = {}));
|
|
@@ -2,9 +2,8 @@ import * as O from 'fp-ts/Option';
|
|
|
2
2
|
import { DynamicObject } from '@trayio/commons/dynamictype/DynamicType';
|
|
3
3
|
import { CompositeOperationHandler, CompositeOperationHandlerFunction } from './CompositeOperationHandler';
|
|
4
4
|
import { HttpOperationHandler, HttpOperationHandlerSetup } from './HttpOperationHandler';
|
|
5
|
-
import { PollingTriggerInput, PollRequestFunction, PollDedupFunction } from './PollOperationHandler';
|
|
6
5
|
import { OperationHandlerValidation, OperationHandlerInputValidationSetup, OperationHandlerOutputValidationSetup } from './OperationHandlerValidation';
|
|
7
|
-
import { DynamicOutput, OperationHandlerAuth, OperationHandlerReference, OperationHandlerType,
|
|
6
|
+
import { DynamicOutput, OperationHandlerAuth, OperationHandlerReference, OperationHandlerType, TriggerOperationHttpResponse, TriggerOperationHttpEvent, TriggerRequestOperationInput, TriggerRequestOperationOutput, TriggerResponseOperationInput } from './OperationHandler';
|
|
8
7
|
import { OperationGlobalConfigHttp } from './OperationGlobalConfig';
|
|
9
8
|
export type OperationHandlerImplementation<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT> = HttpOperationHandler<AUTH, IN, OUT> | CompositeOperationHandler<AUTH, IN, OUT>;
|
|
10
9
|
export declare class OperationHandler<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT> {
|
|
@@ -49,14 +48,6 @@ export interface OperationHandlerSetupInterface {
|
|
|
49
48
|
configureTriggerResponseHandler: <AUTH extends OperationHandlerAuth<unknown, unknown>, IN, RES>(handlerSetup: OperationHandlerSetup<AUTH, TriggerResponseOperationInput<IN, RES>, TriggerOperationHttpResponse>) => OperationHandlerReference<AUTH, TriggerResponseOperationInput<IN, RES>, TriggerOperationHttpResponse>;
|
|
50
49
|
configureTriggerEventHandler: <AUTH extends OperationHandlerAuth<unknown, unknown>, IN, RES>(handlerSetup: OperationHandlerSetup<AUTH, TriggerResponseOperationInput<IN, RES>, TriggerOperationHttpEvent>) => OperationHandlerReference<AUTH, TriggerResponseOperationInput<IN, RES>, TriggerOperationHttpEvent>;
|
|
51
50
|
configureDynamicOutputHandler: <AUTH extends OperationHandlerAuth<unknown, unknown>, IN>(handlerSetup: OperationHandlerSetup<AUTH, IN, DynamicOutput>) => OperationHandlerReference<AUTH, IN, DynamicOutput>;
|
|
52
|
-
configureTriggerPollCreateHandler: <AUTH extends OperationHandlerAuth<unknown, unknown>, IN extends PollingTriggerInput>() => OperationHandlerReference<AUTH, IN, DynamicObject>;
|
|
53
|
-
configureTriggerPollDestroyHandler: <AUTH extends OperationHandlerAuth<unknown, unknown>, IN extends PollingTriggerInput>() => OperationHandlerReference<AUTH, IN, DynamicObject>;
|
|
54
|
-
configureTriggerPollRequestHandler: <AUTH extends OperationHandlerAuth<unknown, unknown>, IN extends PollingTriggerInput, EVENT>(config: {
|
|
55
|
-
poll: PollRequestFunction<AUTH, IN, EVENT>;
|
|
56
|
-
}) => OperationHandlerReference<AUTH, TriggerPollRequestOperationInput<IN>, TriggerPollRequestOperationOutput<EVENT>>;
|
|
57
|
-
configureTriggerPollDedupHandler: <AUTH extends OperationHandlerAuth<unknown, unknown>, IN extends PollingTriggerInput, EVENT>(config: {
|
|
58
|
-
dedup: PollDedupFunction<EVENT>;
|
|
59
|
-
}) => OperationHandlerReference<AUTH, TriggerPollDedupOperationInput<IN, EVENT>, DynamicObject>;
|
|
60
51
|
}
|
|
61
52
|
export type OperationDescriptor = {
|
|
62
53
|
name: string;
|
|
@@ -65,7 +56,6 @@ export type OperationDescriptor = {
|
|
|
65
56
|
type?: string;
|
|
66
57
|
isPrivate?: boolean;
|
|
67
58
|
dynamic_output?: boolean;
|
|
68
|
-
triggerType?: TriggerType;
|
|
69
59
|
};
|
|
70
60
|
export declare const OperationHandlerSetup: OperationHandlerSetupInterface;
|
|
71
61
|
//# sourceMappingURL=OperationHandlerSetup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OperationHandlerSetup.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationHandlerSetup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAGlC,OAAO,EACN,aAAa,EAEb,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EACN,yBAAyB,EACzB,iCAAiC,EACjC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,oBAAoB,EAEpB,yBAAyB,EACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,
|
|
1
|
+
{"version":3,"file":"OperationHandlerSetup.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationHandlerSetup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAGlC,OAAO,EACN,aAAa,EAEb,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EACN,yBAAyB,EACzB,iCAAiC,EACjC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACN,oBAAoB,EAEpB,yBAAyB,EACzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,0BAA0B,EAE1B,oCAAoC,EAEpC,qCAAqC,EACrC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACN,aAAa,EACb,oBAAoB,EACpB,yBAAyB,EACzB,oBAAoB,EACpB,4BAA4B,EAC5B,yBAAyB,EACzB,4BAA4B,EAC5B,6BAA6B,EAC7B,6BAA6B,EAC7B,MAAM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,EAAE,OAAO,CAAC,EACnD,EAAE,EAEF,YAAY,EAAE,qBAAqB,CAAC,IAAI,EAAE,EAAE,EAAE,aAAa,CAAC,KACxD,yBAAyB,CAAC,IAAI,EAAE,EAAE,EAAE,aAAa,CAAC,CAAC;CACxD;AAED,MAAM,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAmBF,eAAO,MAAM,qBAAqB,EAAE,8BAmMnC,CAAC"}
|
|
@@ -32,7 +32,6 @@ const DynamicSchema_1 = require("@trayio/commons/dynamicschema/DynamicSchema");
|
|
|
32
32
|
const CallSite_1 = require("@trayio/commons/callsite/CallSite");
|
|
33
33
|
const CompositeOperationHandler_1 = require("./CompositeOperationHandler");
|
|
34
34
|
const HttpOperationHandler_1 = require("./HttpOperationHandler");
|
|
35
|
-
const PollOperationHandler_1 = require("./PollOperationHandler");
|
|
36
35
|
const OperationHandlerValidation_1 = require("./OperationHandlerValidation");
|
|
37
36
|
const OperationHandler_1 = require("./OperationHandler");
|
|
38
37
|
class OperationHandler {
|
|
@@ -127,13 +126,6 @@ const readOperationDescriptorFile = () => {
|
|
|
127
126
|
})(operationDescriptorOpt);
|
|
128
127
|
return operationDescriptor;
|
|
129
128
|
};
|
|
130
|
-
const assertPollingTriggerType = (descriptor, setupName) => {
|
|
131
|
-
if (descriptor.triggerType !== OperationHandler_1.TriggerType.Polling) {
|
|
132
|
-
throw new Error(`${setupName} requires operation.json to declare "triggerType": "${OperationHandler_1.TriggerType.Polling}" (got ${descriptor.triggerType === undefined
|
|
133
|
-
? 'undefined'
|
|
134
|
-
: `"${descriptor.triggerType}"`})`);
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
129
|
exports.OperationHandlerSetup = {
|
|
138
130
|
configureHandler: (handlerSetup) => {
|
|
139
131
|
const descriptor = readOperationDescriptorFile();
|
|
@@ -194,114 +186,4 @@ exports.OperationHandlerSetup = {
|
|
|
194
186
|
name: handler.name,
|
|
195
187
|
};
|
|
196
188
|
},
|
|
197
|
-
configureTriggerPollCreateHandler: () => {
|
|
198
|
-
const descriptor = readOperationDescriptorFile();
|
|
199
|
-
assertPollingTriggerType(descriptor, 'configureTriggerPollCreateHandler');
|
|
200
|
-
const { name } = descriptor;
|
|
201
|
-
const handler = OperationHandlerConfiguration.withNameAndHandlerType(`${name}_poll`, OperationHandler_1.OperationHandlerType.TriggerPollCreate)
|
|
202
|
-
.addInputValidation((v) => v
|
|
203
|
-
.condition((_ctx, input) => input.pollingInterval === undefined ||
|
|
204
|
-
(typeof input.pollingInterval.value === 'number' &&
|
|
205
|
-
Number.isFinite(input.pollingInterval.value)))
|
|
206
|
-
.errorMessage(() => 'pollingInterval.value must be a finite number'))
|
|
207
|
-
.addInputValidation((v) => v
|
|
208
|
-
.condition((_ctx, input) => input.pollingInterval === undefined ||
|
|
209
|
-
Object.values(PollOperationHandler_1.PollingIntervalUnit).includes(input.pollingInterval.unit))
|
|
210
|
-
.errorMessage(() => `pollingInterval.unit must be one of: ${Object.values(PollOperationHandler_1.PollingIntervalUnit).join(', ')}`))
|
|
211
|
-
.addInputValidation((v) => v
|
|
212
|
-
.condition((_ctx, input) => {
|
|
213
|
-
if (input.pollingInterval === undefined)
|
|
214
|
-
return true;
|
|
215
|
-
const { value, unit } = input.pollingInterval;
|
|
216
|
-
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
217
|
-
return true;
|
|
218
|
-
}
|
|
219
|
-
if (unit === PollOperationHandler_1.PollingIntervalUnit.Minutes) {
|
|
220
|
-
return value >= PollOperationHandler_1.MINIMUM_POLLING_INTERVAL_MINUTES;
|
|
221
|
-
}
|
|
222
|
-
if (unit === PollOperationHandler_1.PollingIntervalUnit.Hours) {
|
|
223
|
-
return value >= PollOperationHandler_1.MINIMUM_POLLING_INTERVAL_HOURS;
|
|
224
|
-
}
|
|
225
|
-
return true;
|
|
226
|
-
})
|
|
227
|
-
.errorMessage((_ctx, input) => {
|
|
228
|
-
const unit = input.pollingInterval?.unit;
|
|
229
|
-
const min = unit === PollOperationHandler_1.PollingIntervalUnit.Hours
|
|
230
|
-
? PollOperationHandler_1.MINIMUM_POLLING_INTERVAL_HOURS
|
|
231
|
-
: PollOperationHandler_1.MINIMUM_POLLING_INTERVAL_MINUTES;
|
|
232
|
-
return `pollingInterval.value must be at least ${min} ${unit ?? PollOperationHandler_1.PollingIntervalUnit.Minutes} (got ${input.pollingInterval?.value})`;
|
|
233
|
-
}))
|
|
234
|
-
.addInputValidation((v) => v
|
|
235
|
-
.condition((_ctx, input) => input.maxFailureCount === undefined ||
|
|
236
|
-
(typeof input.maxFailureCount === 'number' &&
|
|
237
|
-
Number.isInteger(input.maxFailureCount)))
|
|
238
|
-
.errorMessage(() => 'maxFailureCount must be an integer'))
|
|
239
|
-
.addInputValidation((v) => v
|
|
240
|
-
.condition((_ctx, input) => input.maxFailureCount === undefined ||
|
|
241
|
-
(input.maxFailureCount >= PollOperationHandler_1.MINIMUM_MAX_FAILURE_COUNT &&
|
|
242
|
-
input.maxFailureCount <= PollOperationHandler_1.MAXIMUM_MAX_FAILURE_COUNT))
|
|
243
|
-
.errorMessage((_ctx, input) => `maxFailureCount must be between ${PollOperationHandler_1.MINIMUM_MAX_FAILURE_COUNT} and ${PollOperationHandler_1.MAXIMUM_MAX_FAILURE_COUNT} (got ${input.maxFailureCount})`))
|
|
244
|
-
.usingComposite(async () => {
|
|
245
|
-
throw new Error('polling trigger _poll execution is not wired yet (will ship in cdk-runtime PR)');
|
|
246
|
-
});
|
|
247
|
-
OperationHandlerRegistry.register(handler);
|
|
248
|
-
return {
|
|
249
|
-
name: handler.name,
|
|
250
|
-
};
|
|
251
|
-
},
|
|
252
|
-
configureTriggerPollDestroyHandler: () => {
|
|
253
|
-
const descriptor = readOperationDescriptorFile();
|
|
254
|
-
assertPollingTriggerType(descriptor, 'configureTriggerPollDestroyHandler');
|
|
255
|
-
const { name } = descriptor;
|
|
256
|
-
const handler = OperationHandlerConfiguration.withNameAndHandlerType(`${name}_poll_destroy`, OperationHandler_1.OperationHandlerType.TriggerPollDestroy).usingComposite(async () => {
|
|
257
|
-
throw new Error('polling trigger _poll_destroy execution is not wired yet (will ship in cdk-runtime PR)');
|
|
258
|
-
});
|
|
259
|
-
OperationHandlerRegistry.register(handler);
|
|
260
|
-
return {
|
|
261
|
-
name: handler.name,
|
|
262
|
-
};
|
|
263
|
-
},
|
|
264
|
-
configureTriggerPollRequestHandler: (config) => {
|
|
265
|
-
if (typeof config.poll !== 'function') {
|
|
266
|
-
throw new Error('configureTriggerPollRequestHandler requires a poll function');
|
|
267
|
-
}
|
|
268
|
-
const descriptor = readOperationDescriptorFile();
|
|
269
|
-
assertPollingTriggerType(descriptor, 'configureTriggerPollRequestHandler');
|
|
270
|
-
const { name } = descriptor;
|
|
271
|
-
const handler = OperationHandlerConfiguration.withNameAndHandlerType(`${name}_poll_request`, OperationHandler_1.OperationHandlerType.TriggerPollRequest).usingComposite(async (ctx, { input, cursor }) => {
|
|
272
|
-
const result = await config.poll(cursor, {
|
|
273
|
-
auth: ctx.auth,
|
|
274
|
-
authId: ctx.auth?.authId ?? '',
|
|
275
|
-
input,
|
|
276
|
-
});
|
|
277
|
-
return OperationHandler_1.OperationHandlerResult.success(result);
|
|
278
|
-
});
|
|
279
|
-
OperationHandlerRegistry.register(handler);
|
|
280
|
-
return { name: handler.name };
|
|
281
|
-
},
|
|
282
|
-
configureTriggerPollDedupHandler: (config) => {
|
|
283
|
-
if (typeof config.dedup !== 'function') {
|
|
284
|
-
throw new Error('configureTriggerPollDedupHandler requires a dedup function');
|
|
285
|
-
}
|
|
286
|
-
const descriptor = readOperationDescriptorFile();
|
|
287
|
-
assertPollingTriggerType(descriptor, 'configureTriggerPollDedupHandler');
|
|
288
|
-
const { name } = descriptor;
|
|
289
|
-
const handler = OperationHandlerConfiguration.withNameAndHandlerType(`${name}_request`, OperationHandler_1.OperationHandlerType.TriggerPollDedup).usingComposite(async (_ctx, { event }) => {
|
|
290
|
-
// Failure-envelope short-circuit: Polling Service posts a `{error, message}`
|
|
291
|
-
// payload when it gives up after consecutive non-recoverable failures.
|
|
292
|
-
const failurePayload = event;
|
|
293
|
-
if (failurePayload !== null &&
|
|
294
|
-
typeof failurePayload === 'object' &&
|
|
295
|
-
'error' in failurePayload &&
|
|
296
|
-
'message' in failurePayload) {
|
|
297
|
-
return OperationHandler_1.OperationHandlerResult.failure(OperationHandler_1.OperationHandlerError.userInputError(typeof failurePayload.message === 'string'
|
|
298
|
-
? failurePayload.message
|
|
299
|
-
: JSON.stringify(failurePayload.message)));
|
|
300
|
-
}
|
|
301
|
-
const triggerDeduplicationId = config.dedup(event);
|
|
302
|
-
return OperationHandler_1.OperationHandlerResult.success({}, { triggerDeduplicationId });
|
|
303
|
-
});
|
|
304
|
-
OperationHandlerRegistry.register(handler);
|
|
305
|
-
return { name: handler.name };
|
|
306
|
-
},
|
|
307
189
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationHandlerUtils.test.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationHandlerUtils.test.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/cdk-dsl",
|
|
3
|
-
"version": "5.18.0
|
|
3
|
+
"version": "5.18.0",
|
|
4
4
|
"description": "A DSL for connector development",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./*": "./dist/*.js"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@trayio/commons": "5.18.0
|
|
17
|
+
"@trayio/commons": "5.18.0"
|
|
18
18
|
},
|
|
19
19
|
"typesVersions": {
|
|
20
20
|
"*": {
|
|
@@ -26,6 +26,5 @@
|
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"/dist"
|
|
29
|
-
]
|
|
30
|
-
"stableVersion": "0.0.0"
|
|
29
|
+
]
|
|
31
30
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OperationHandlerSetup.polling.unit.test.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationHandlerSetup.polling.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const O = __importStar(require("fp-ts/Option"));
|
|
27
|
-
const pathLib = __importStar(require("path"));
|
|
28
|
-
const CallSite_1 = require("@trayio/commons/callsite/CallSite");
|
|
29
|
-
const OperationHandlerSetup_1 = require("./OperationHandlerSetup");
|
|
30
|
-
const OperationHandler_1 = require("./OperationHandler");
|
|
31
|
-
const PollOperationHandler_1 = require("./PollOperationHandler");
|
|
32
|
-
jest.mock('@trayio/commons/callsite/CallSite', () => ({
|
|
33
|
-
CallSite: {
|
|
34
|
-
getCurrentCallSites: jest.fn(),
|
|
35
|
-
},
|
|
36
|
-
}));
|
|
37
|
-
const mockedCallSite = CallSite_1.CallSite;
|
|
38
|
-
const pollingFixtureFolder = pathLib.join(__dirname, '__fixtures__', 'polling_op');
|
|
39
|
-
const regularFixtureFolder = pathLib.join(__dirname, '__fixtures__', 'regular_op');
|
|
40
|
-
const pointCallSiteAt = (folderPath) => {
|
|
41
|
-
mockedCallSite.getCurrentCallSites.mockReturnValue([
|
|
42
|
-
{
|
|
43
|
-
filePath: pathLib.join(folderPath, 'handler.ts'),
|
|
44
|
-
folderPath,
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
filePath: pathLib.join(folderPath, 'handler.ts'),
|
|
48
|
-
folderPath,
|
|
49
|
-
},
|
|
50
|
-
]);
|
|
51
|
-
};
|
|
52
|
-
const resolveHandler = (ref) => {
|
|
53
|
-
const resolved = OperationHandlerSetup_1.OperationHandlerRegistry.resolve(ref);
|
|
54
|
-
if (resolved._tag !== 'Some') {
|
|
55
|
-
throw new Error(`handler ${ref.name} not registered`);
|
|
56
|
-
}
|
|
57
|
-
return resolved.value;
|
|
58
|
-
};
|
|
59
|
-
describe('OperationHandlerSetup polling', () => {
|
|
60
|
-
afterEach(() => {
|
|
61
|
-
jest.clearAllMocks();
|
|
62
|
-
});
|
|
63
|
-
describe('configureTriggerPollCreateHandler', () => {
|
|
64
|
-
it('registers TriggerPollCreate with _poll suffix when triggerType is polling', () => {
|
|
65
|
-
pointCallSiteAt(pollingFixtureFolder);
|
|
66
|
-
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollCreateHandler();
|
|
67
|
-
expect(ref.name).toBe('new_records_poll');
|
|
68
|
-
const handler = resolveHandler(ref);
|
|
69
|
-
expect(handler.handlerType).toBe(OperationHandler_1.OperationHandlerType.TriggerPollCreate);
|
|
70
|
-
expect(handler.implementation._tag).toBe('CompositeOperationHandler');
|
|
71
|
-
});
|
|
72
|
-
it('throws when triggerType is not polling', () => {
|
|
73
|
-
pointCallSiteAt(regularFixtureFolder);
|
|
74
|
-
expect(() => OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollCreateHandler()).toThrow(/triggerType.*polling/);
|
|
75
|
-
});
|
|
76
|
-
describe('attached input validations', () => {
|
|
77
|
-
const setup = () => {
|
|
78
|
-
pointCallSiteAt(pollingFixtureFolder);
|
|
79
|
-
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollCreateHandler();
|
|
80
|
-
const handler = resolveHandler(ref);
|
|
81
|
-
expect(O.isSome(handler.validation)).toBe(true);
|
|
82
|
-
return handler.validation.value.inputValidation;
|
|
83
|
-
};
|
|
84
|
-
const runConditions = (input) => setup().map((v) => ({
|
|
85
|
-
ok: v.condition({}, input),
|
|
86
|
-
message: v.errorMessage({}, input),
|
|
87
|
-
}));
|
|
88
|
-
it('allows input with no polling fields (runtime will default)', () => {
|
|
89
|
-
const results = runConditions({});
|
|
90
|
-
expect(results.every((r) => r.ok)).toBe(true);
|
|
91
|
-
});
|
|
92
|
-
it('allows input with valid minutes interval', () => {
|
|
93
|
-
const results = runConditions({
|
|
94
|
-
pollingInterval: { value: 5, unit: PollOperationHandler_1.PollingIntervalUnit.Minutes },
|
|
95
|
-
maxFailureCount: 30,
|
|
96
|
-
});
|
|
97
|
-
expect(results.every((r) => r.ok)).toBe(true);
|
|
98
|
-
});
|
|
99
|
-
it('allows input with valid hours interval', () => {
|
|
100
|
-
const results = runConditions({
|
|
101
|
-
pollingInterval: { value: 1, unit: PollOperationHandler_1.PollingIntervalUnit.Hours },
|
|
102
|
-
maxFailureCount: 30,
|
|
103
|
-
});
|
|
104
|
-
expect(results.every((r) => r.ok)).toBe(true);
|
|
105
|
-
});
|
|
106
|
-
it('flags non-finite pollingInterval.value', () => {
|
|
107
|
-
const results = runConditions({
|
|
108
|
-
pollingInterval: {
|
|
109
|
-
value: Number.NaN,
|
|
110
|
-
unit: PollOperationHandler_1.PollingIntervalUnit.Minutes,
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
const failed = results.filter((r) => !r.ok);
|
|
114
|
-
expect(failed).toHaveLength(1);
|
|
115
|
-
expect(failed[0].message).toMatch(/finite number/);
|
|
116
|
-
});
|
|
117
|
-
it('flags unknown pollingInterval.unit', () => {
|
|
118
|
-
const results = runConditions({
|
|
119
|
-
pollingInterval: { value: 5, unit: 'seconds' },
|
|
120
|
-
});
|
|
121
|
-
const failed = results.filter((r) => !r.ok);
|
|
122
|
-
expect(failed).toHaveLength(1);
|
|
123
|
-
expect(failed[0].message).toMatch(/must be one of: minutes, hours/);
|
|
124
|
-
});
|
|
125
|
-
it('flags minutes value below 5', () => {
|
|
126
|
-
const results = runConditions({
|
|
127
|
-
pollingInterval: { value: 4, unit: PollOperationHandler_1.PollingIntervalUnit.Minutes },
|
|
128
|
-
});
|
|
129
|
-
const failed = results.filter((r) => !r.ok);
|
|
130
|
-
expect(failed).toHaveLength(1);
|
|
131
|
-
expect(failed[0].message).toMatch(/at least 5 minutes/);
|
|
132
|
-
});
|
|
133
|
-
it('flags hours value below 1', () => {
|
|
134
|
-
const results = runConditions({
|
|
135
|
-
pollingInterval: { value: 0, unit: PollOperationHandler_1.PollingIntervalUnit.Hours },
|
|
136
|
-
});
|
|
137
|
-
const failed = results.filter((r) => !r.ok);
|
|
138
|
-
expect(failed).toHaveLength(1);
|
|
139
|
-
expect(failed[0].message).toMatch(/at least 1 hours/);
|
|
140
|
-
});
|
|
141
|
-
it('flags non-integer maxFailureCount', () => {
|
|
142
|
-
const results = runConditions({ maxFailureCount: 10.5 });
|
|
143
|
-
const failed = results.filter((r) => !r.ok);
|
|
144
|
-
expect(failed).toHaveLength(1);
|
|
145
|
-
expect(failed[0].message).toMatch(/integer/);
|
|
146
|
-
});
|
|
147
|
-
it('flags maxFailureCount out of range', () => {
|
|
148
|
-
const lo = runConditions({ maxFailureCount: 0 });
|
|
149
|
-
const loFailed = lo.filter((r) => !r.ok);
|
|
150
|
-
expect(loFailed).toHaveLength(1);
|
|
151
|
-
expect(loFailed[0].message).toMatch(/between 1 and 150/);
|
|
152
|
-
const hi = runConditions({ maxFailureCount: 151 });
|
|
153
|
-
const hiFailed = hi.filter((r) => !r.ok);
|
|
154
|
-
expect(hiFailed).toHaveLength(1);
|
|
155
|
-
expect(hiFailed[0].message).toMatch(/between 1 and 150/);
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
it('composite body throws a PR-2 "not wired" error if invoked', async () => {
|
|
159
|
-
pointCallSiteAt(pollingFixtureFolder);
|
|
160
|
-
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollCreateHandler();
|
|
161
|
-
const handler = resolveHandler(ref);
|
|
162
|
-
const fn = handler.implementation.handlerFunction;
|
|
163
|
-
await expect(fn({}, {}, {})).rejects.toThrow(/not wired/);
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
describe('configureTriggerPollDestroyHandler', () => {
|
|
167
|
-
it('registers TriggerPollDestroy with _poll_destroy suffix', () => {
|
|
168
|
-
pointCallSiteAt(pollingFixtureFolder);
|
|
169
|
-
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollDestroyHandler();
|
|
170
|
-
expect(ref.name).toBe('new_records_poll_destroy');
|
|
171
|
-
const handler = resolveHandler(ref);
|
|
172
|
-
expect(handler.handlerType).toBe(OperationHandler_1.OperationHandlerType.TriggerPollDestroy);
|
|
173
|
-
expect(handler.implementation._tag).toBe('CompositeOperationHandler');
|
|
174
|
-
});
|
|
175
|
-
it('throws when triggerType is not polling', () => {
|
|
176
|
-
pointCallSiteAt(regularFixtureFolder);
|
|
177
|
-
expect(() => OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollDestroyHandler()).toThrow(/triggerType.*polling/);
|
|
178
|
-
});
|
|
179
|
-
it('composite body throws a PR-2 "not wired" error if invoked', async () => {
|
|
180
|
-
pointCallSiteAt(pollingFixtureFolder);
|
|
181
|
-
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollDestroyHandler();
|
|
182
|
-
const handler = resolveHandler(ref);
|
|
183
|
-
const fn = handler.implementation.handlerFunction;
|
|
184
|
-
await expect(fn({}, {}, {})).rejects.toThrow(/not wired/);
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
describe('configureTriggerPollRequestHandler', () => {
|
|
188
|
-
it('registers TriggerPollRequest with _poll_request suffix', () => {
|
|
189
|
-
pointCallSiteAt(pollingFixtureFolder);
|
|
190
|
-
const poll = jest.fn();
|
|
191
|
-
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollRequestHandler({
|
|
192
|
-
poll,
|
|
193
|
-
});
|
|
194
|
-
expect(ref.name).toBe('new_records_poll_request');
|
|
195
|
-
const handler = resolveHandler(ref);
|
|
196
|
-
expect(handler.handlerType).toBe(OperationHandler_1.OperationHandlerType.TriggerPollRequest);
|
|
197
|
-
expect(handler.implementation._tag).toBe('CompositeOperationHandler');
|
|
198
|
-
});
|
|
199
|
-
it('throws when triggerType is not polling', () => {
|
|
200
|
-
pointCallSiteAt(regularFixtureFolder);
|
|
201
|
-
expect(() => OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollRequestHandler({
|
|
202
|
-
poll: jest.fn(),
|
|
203
|
-
})).toThrow(/triggerType.*polling/);
|
|
204
|
-
});
|
|
205
|
-
it('composite body invokes the dev-supplied poll function and wraps the result', async () => {
|
|
206
|
-
pointCallSiteAt(pollingFixtureFolder);
|
|
207
|
-
const pollResult = {
|
|
208
|
-
events: [{ id: 'e1' }],
|
|
209
|
-
nextCursor: { after: 'e1' },
|
|
210
|
-
canPollMore: true,
|
|
211
|
-
};
|
|
212
|
-
const poll = jest.fn().mockResolvedValue(pollResult);
|
|
213
|
-
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollRequestHandler({
|
|
214
|
-
poll,
|
|
215
|
-
});
|
|
216
|
-
const handler = resolveHandler(ref);
|
|
217
|
-
const fn = handler.implementation.handlerFunction;
|
|
218
|
-
const ctx = { auth: { authId: 'auth-123' } };
|
|
219
|
-
const result = await fn(ctx, { input: { some: 'thing' }, cursor: { after: 'e0' } }, {});
|
|
220
|
-
expect(poll).toHaveBeenCalledWith({ after: 'e0' }, expect.objectContaining({
|
|
221
|
-
authId: 'auth-123',
|
|
222
|
-
input: { some: 'thing' },
|
|
223
|
-
}));
|
|
224
|
-
expect(result.isSuccess).toBe(true);
|
|
225
|
-
expect(result.value).toEqual(pollResult);
|
|
226
|
-
});
|
|
227
|
-
it('throws at setup time when poll is not a function', () => {
|
|
228
|
-
pointCallSiteAt(pollingFixtureFolder);
|
|
229
|
-
expect(() => OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollRequestHandler({
|
|
230
|
-
poll: undefined,
|
|
231
|
-
})).toThrow(/poll function/);
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
describe('configureTriggerPollDedupHandler', () => {
|
|
235
|
-
it('registers TriggerPollDedup with _request suffix', () => {
|
|
236
|
-
pointCallSiteAt(pollingFixtureFolder);
|
|
237
|
-
const dedup = jest.fn().mockReturnValue('id-1');
|
|
238
|
-
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollDedupHandler({
|
|
239
|
-
dedup,
|
|
240
|
-
});
|
|
241
|
-
expect(ref.name).toBe('new_records_request');
|
|
242
|
-
const handler = resolveHandler(ref);
|
|
243
|
-
expect(handler.handlerType).toBe(OperationHandler_1.OperationHandlerType.TriggerPollDedup);
|
|
244
|
-
expect(handler.implementation._tag).toBe('CompositeOperationHandler');
|
|
245
|
-
});
|
|
246
|
-
it('throws when triggerType is not polling', () => {
|
|
247
|
-
pointCallSiteAt(regularFixtureFolder);
|
|
248
|
-
expect(() => OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollDedupHandler({
|
|
249
|
-
dedup: () => 'x',
|
|
250
|
-
})).toThrow(/triggerType.*polling/);
|
|
251
|
-
});
|
|
252
|
-
it('composite body invokes dev dedup on a normal event and returns triggerDeduplicationId in metadata', async () => {
|
|
253
|
-
pointCallSiteAt(pollingFixtureFolder);
|
|
254
|
-
const dedup = jest.fn().mockReturnValue('dedup-id-42');
|
|
255
|
-
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollDedupHandler({
|
|
256
|
-
dedup,
|
|
257
|
-
});
|
|
258
|
-
const handler = resolveHandler(ref);
|
|
259
|
-
const fn = handler.implementation.handlerFunction;
|
|
260
|
-
const event = { id: 'evt-1' };
|
|
261
|
-
const result = await fn({}, { input: {}, event }, {});
|
|
262
|
-
expect(dedup).toHaveBeenCalledWith(event);
|
|
263
|
-
expect(result.isSuccess).toBe(true);
|
|
264
|
-
expect(result.metadata).toEqual({
|
|
265
|
-
triggerDeduplicationId: 'dedup-id-42',
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
it('composite body short-circuits on a {error, message} failure envelope with UserInputError', async () => {
|
|
269
|
-
pointCallSiteAt(pollingFixtureFolder);
|
|
270
|
-
const dedup = jest.fn();
|
|
271
|
-
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollDedupHandler({
|
|
272
|
-
dedup,
|
|
273
|
-
});
|
|
274
|
-
const handler = resolveHandler(ref);
|
|
275
|
-
const fn = handler.implementation.handlerFunction;
|
|
276
|
-
const failureEnvelope = { error: 'upstream_gave_up', message: 'boom' };
|
|
277
|
-
const result = await fn({}, { input: {}, event: failureEnvelope }, {});
|
|
278
|
-
expect(dedup).not.toHaveBeenCalled();
|
|
279
|
-
expect(result.isFailure).toBe(true);
|
|
280
|
-
expect(result.error._tag).toBe('UserInputError');
|
|
281
|
-
expect(result.error.message).toBe('boom');
|
|
282
|
-
});
|
|
283
|
-
it('throws at setup time when dedup is not a function', () => {
|
|
284
|
-
pointCallSiteAt(pollingFixtureFolder);
|
|
285
|
-
expect(() => OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollDedupHandler({
|
|
286
|
-
dedup: undefined,
|
|
287
|
-
})).toThrow(/dedup function/);
|
|
288
|
-
});
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
describe('OperationHandlerSetup non-polling _request (regression baseline)', () => {
|
|
292
|
-
afterEach(() => {
|
|
293
|
-
jest.clearAllMocks();
|
|
294
|
-
});
|
|
295
|
-
it('configureTriggerRequestHandler registers under TriggerRequest with _request suffix for a regular trigger', () => {
|
|
296
|
-
pointCallSiteAt(regularFixtureFolder);
|
|
297
|
-
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerRequestHandler((handler) => handler.usingComposite(async () => OperationHandler_1.OperationHandlerResult.success({
|
|
298
|
-
output: {},
|
|
299
|
-
response: OperationHandler_1.TriggerOperationHttpResponse.withStatusCode(200),
|
|
300
|
-
})));
|
|
301
|
-
expect(ref.name).toBe('regular_op_request');
|
|
302
|
-
const handler = resolveHandler(ref);
|
|
303
|
-
expect(handler.handlerType).toBe(OperationHandler_1.OperationHandlerType.TriggerRequest);
|
|
304
|
-
});
|
|
305
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OperationHandlerUtils.unit.test.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationHandlerUtils.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { OperationHandlerAuth } from './OperationHandler';
|
|
2
|
-
export declare enum PollingIntervalUnit {
|
|
3
|
-
Minutes = "minutes",
|
|
4
|
-
Hours = "hours"
|
|
5
|
-
}
|
|
6
|
-
export type PollingInterval = {
|
|
7
|
-
value: number;
|
|
8
|
-
unit: PollingIntervalUnit;
|
|
9
|
-
};
|
|
10
|
-
export declare const MINIMUM_POLLING_INTERVAL_MINUTES = 5;
|
|
11
|
-
export declare const MINIMUM_POLLING_INTERVAL_HOURS = 1;
|
|
12
|
-
export declare const DEFAULT_POLLING_INTERVAL: PollingInterval;
|
|
13
|
-
export declare const DEFAULT_MAX_FAILURE_COUNT = 30;
|
|
14
|
-
export declare const MINIMUM_MAX_FAILURE_COUNT = 1;
|
|
15
|
-
export declare const MAXIMUM_MAX_FAILURE_COUNT = 150;
|
|
16
|
-
/**
|
|
17
|
-
* Base shape of the `input` that the platform delivers to polling-trigger ops at runtime.
|
|
18
|
-
*
|
|
19
|
-
* Connector devs intersect this with their own per-trigger input type via the
|
|
20
|
-
* generic constraint on the polling setup functions (e.g.
|
|
21
|
-
* `configureTriggerPollCreateHandler<AUTH, IN extends PollingTriggerInput>`).
|
|
22
|
-
*
|
|
23
|
-
* `pollingInterval` carries the user-entered value + unit selection from the
|
|
24
|
-
* platform trigger config form. Both fields are optional: when absent,
|
|
25
|
-
* cdk-runtime substitutes `DEFAULT_POLLING_INTERVAL` / `DEFAULT_MAX_FAILURE_COUNT`
|
|
26
|
-
* before forwarding to the Polling Service.
|
|
27
|
-
*/
|
|
28
|
-
export type PollingTriggerInput = {
|
|
29
|
-
pollingInterval?: PollingInterval;
|
|
30
|
-
maxFailureCount?: number;
|
|
31
|
-
};
|
|
32
|
-
export type PollRequestContext<AUTH extends OperationHandlerAuth<unknown, unknown>, IN> = {
|
|
33
|
-
auth?: AUTH;
|
|
34
|
-
authId: string;
|
|
35
|
-
input: IN;
|
|
36
|
-
};
|
|
37
|
-
export type PollRequestResult<EVENT> = {
|
|
38
|
-
events: EVENT[];
|
|
39
|
-
nextCursor: unknown;
|
|
40
|
-
canPollMore: boolean;
|
|
41
|
-
};
|
|
42
|
-
export type PollRequestFunction<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, EVENT> = (cursor: unknown, ctx: PollRequestContext<AUTH, IN>) => Promise<PollRequestResult<EVENT>>;
|
|
43
|
-
export type PollDedupFunction<EVENT> = (event: EVENT) => string;
|
|
44
|
-
//# sourceMappingURL=PollOperationHandler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PollOperationHandler.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/PollOperationHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D,oBAAY,mBAAmB;IAC9B,OAAO,YAAY;IACnB,KAAK,UAAU;CACf;AAED,MAAM,MAAM,eAAe,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,mBAAmB,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,gCAAgC,IAAI,CAAC;AAClD,eAAO,MAAM,8BAA8B,IAAI,CAAC;AAEhD,eAAO,MAAM,wBAAwB,EAAE,eAGtC,CAAC;AAEF,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAC5C,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAC3C,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAE7C;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,mBAAmB,GAAG;IACjC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAC7B,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EACnD,EAAE,IACC;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,EAAE,CAAC;CACV,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,KAAK,IAAI;IACtC,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAC9B,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EACnD,EAAE,EACF,KAAK,IACF,CACH,MAAM,EAAE,OAAO,EACf,GAAG,EAAE,kBAAkB,CAAC,IAAI,EAAE,EAAE,CAAC,KAC7B,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;AAEvC,MAAM,MAAM,iBAAiB,CAAC,KAAK,IAAI,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAXIMUM_MAX_FAILURE_COUNT = exports.MINIMUM_MAX_FAILURE_COUNT = exports.DEFAULT_MAX_FAILURE_COUNT = exports.DEFAULT_POLLING_INTERVAL = exports.MINIMUM_POLLING_INTERVAL_HOURS = exports.MINIMUM_POLLING_INTERVAL_MINUTES = exports.PollingIntervalUnit = void 0;
|
|
4
|
-
var PollingIntervalUnit;
|
|
5
|
-
(function (PollingIntervalUnit) {
|
|
6
|
-
PollingIntervalUnit["Minutes"] = "minutes";
|
|
7
|
-
PollingIntervalUnit["Hours"] = "hours";
|
|
8
|
-
})(PollingIntervalUnit || (exports.PollingIntervalUnit = PollingIntervalUnit = {}));
|
|
9
|
-
exports.MINIMUM_POLLING_INTERVAL_MINUTES = 5;
|
|
10
|
-
exports.MINIMUM_POLLING_INTERVAL_HOURS = 1;
|
|
11
|
-
exports.DEFAULT_POLLING_INTERVAL = {
|
|
12
|
-
value: 5,
|
|
13
|
-
unit: PollingIntervalUnit.Minutes,
|
|
14
|
-
};
|
|
15
|
-
exports.DEFAULT_MAX_FAILURE_COUNT = 30;
|
|
16
|
-
exports.MINIMUM_MAX_FAILURE_COUNT = 1;
|
|
17
|
-
exports.MAXIMUM_MAX_FAILURE_COUNT = 150;
|
|
File without changes
|