@trayio/cdk-dsl 5.21.0 → 5.22.1-unstable
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 +38 -1
- package/dist/connector/operation/OperationHandler.d.ts.map +1 -1
- package/dist/connector/operation/OperationHandler.js +18 -3
- package/dist/connector/operation/OperationHandlerSetup.d.ts +7 -1
- package/dist/connector/operation/OperationHandlerSetup.d.ts.map +1 -1
- package/dist/connector/operation/OperationHandlerSetup.js +94 -0
- package/dist/connector/operation/OperationHandlerSetup.polling.unit.test.d.ts +2 -0
- package/dist/connector/operation/OperationHandlerSetup.polling.unit.test.d.ts.map +1 -0
- package/dist/connector/operation/OperationHandlerSetup.polling.unit.test.js +278 -0
- package/dist/connector/operation/OperationHandlerUtils.unit.test.d.ts +2 -0
- package/dist/connector/operation/OperationHandlerUtils.unit.test.d.ts.map +1 -0
- package/dist/connector/operation/PollingTypes.d.ts +19 -0
- package/dist/connector/operation/PollingTypes.d.ts.map +1 -0
- package/dist/connector/operation/PollingTypes.js +17 -0
- package/dist/connector/operation/__fixtures__/polling_op/operation.json +6 -0
- package/dist/connector/operation/__fixtures__/regular_op/operation.json +5 -0
- package/package.json +4 -3
- package/dist/connector/operation/OperationHandlerUtils.test.d.ts +0 -2
- package/dist/connector/operation/OperationHandlerUtils.test.d.ts.map +0 -1
- /package/dist/connector/operation/{OperationHandlerUtils.test.js → OperationHandlerUtils.unit.test.js} +0 -0
|
@@ -44,6 +44,10 @@ 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;
|
|
47
51
|
};
|
|
48
52
|
export type OperationHandlerReference<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT> = {
|
|
49
53
|
name: string;
|
|
@@ -96,6 +100,30 @@ export type TriggerResponseOperationInput<I, R> = {
|
|
|
96
100
|
input: I;
|
|
97
101
|
response: R;
|
|
98
102
|
};
|
|
103
|
+
export type TriggerPollRequestOperationInput<IN> = {
|
|
104
|
+
input: IN;
|
|
105
|
+
cursor: string | null;
|
|
106
|
+
};
|
|
107
|
+
export type TriggerPollRequestOperationOutput<EVENT> = {
|
|
108
|
+
events: EVENT[];
|
|
109
|
+
nextCursor: string | null;
|
|
110
|
+
canPollMore: boolean;
|
|
111
|
+
};
|
|
112
|
+
export type TriggerPollDedupOperationInput<IN, EVENT> = {
|
|
113
|
+
input: IN;
|
|
114
|
+
event: EVENT;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Typed output body for a polling dedup handler. Carries the
|
|
118
|
+
* `triggerDeduplicationId` the dev computes per-event so TypeScript can
|
|
119
|
+
* enforce its presence at compile time. The cdk-runtime dispatcher lifts
|
|
120
|
+
* `triggerDeduplicationId` into `OperationHandlerResultMetadata` after the
|
|
121
|
+
* dev body returns; the field stays on the wire body too (see
|
|
122
|
+
* CompositeOperationExecution's TriggerPollDedup branch).
|
|
123
|
+
*/
|
|
124
|
+
export type TriggerPollDedupOperationOutput = {
|
|
125
|
+
triggerDeduplicationId: string;
|
|
126
|
+
};
|
|
99
127
|
export type DDLOperationOutputElement<T extends string | number> = {
|
|
100
128
|
text: string;
|
|
101
129
|
value: T;
|
|
@@ -155,6 +183,7 @@ export type OperationHandlerResultUsageMetadata = {
|
|
|
155
183
|
};
|
|
156
184
|
export type OperationHandlerResultMetadata = {
|
|
157
185
|
usage?: Array<OperationHandlerResultUsageMetadata>;
|
|
186
|
+
triggerDeduplicationId?: string;
|
|
158
187
|
};
|
|
159
188
|
export type OperationHandlerResultHeaders = {
|
|
160
189
|
metadata?: OperationHandlerResultMetadata;
|
|
@@ -201,6 +230,14 @@ export declare enum OperationHandlerType {
|
|
|
201
230
|
TriggerEvent = "trigger-event",
|
|
202
231
|
TriggerRequest = "trigger-request",
|
|
203
232
|
TriggerDestroy = "trigger-destroy",
|
|
204
|
-
DynamicOutput = "dynamic-output"
|
|
233
|
+
DynamicOutput = "dynamic-output",
|
|
234
|
+
TriggerPollCreate = "trigger-poll-create",
|
|
235
|
+
TriggerPollDestroy = "trigger-poll-destroy",
|
|
236
|
+
TriggerPollRequest = "trigger-poll-request",
|
|
237
|
+
TriggerPollDedup = "trigger-poll-dedup"
|
|
238
|
+
}
|
|
239
|
+
export declare enum TriggerType {
|
|
240
|
+
Normal = "normal",
|
|
241
|
+
Polling = "polling"
|
|
205
242
|
}
|
|
206
243
|
//# 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,o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};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.OperationHandlerType = exports.OperationHandlerResultInternal = exports.OperationHandlerResult = exports.OperationHandlerError = exports.TriggerOperationHttpResponse = void 0;
|
|
26
|
+
exports.TriggerType = 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,7 +109,10 @@ 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
|
-
|
|
112
|
+
if (result.isPending) {
|
|
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');
|
|
113
116
|
},
|
|
114
117
|
map: (result, mapping) => {
|
|
115
118
|
if (result.isSuccess) {
|
|
@@ -118,7 +121,10 @@ exports.OperationHandlerResult = {
|
|
|
118
121
|
if (result.isFailure) {
|
|
119
122
|
return exports.OperationHandlerResult.failure(result.error, result.metadata);
|
|
120
123
|
}
|
|
121
|
-
|
|
124
|
+
if (result.isPending) {
|
|
125
|
+
return exports.OperationHandlerResult.pending(result.message, result.metadata);
|
|
126
|
+
}
|
|
127
|
+
throw new Error('Unknown OperationHandlerResult state');
|
|
122
128
|
},
|
|
123
129
|
};
|
|
124
130
|
exports.OperationHandlerResultInternal = {
|
|
@@ -134,4 +140,13 @@ var OperationHandlerType;
|
|
|
134
140
|
OperationHandlerType["TriggerRequest"] = "trigger-request";
|
|
135
141
|
OperationHandlerType["TriggerDestroy"] = "trigger-destroy";
|
|
136
142
|
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";
|
|
137
147
|
})(OperationHandlerType || (exports.OperationHandlerType = OperationHandlerType = {}));
|
|
148
|
+
var TriggerType;
|
|
149
|
+
(function (TriggerType) {
|
|
150
|
+
TriggerType["Normal"] = "normal";
|
|
151
|
+
TriggerType["Polling"] = "polling";
|
|
152
|
+
})(TriggerType || (exports.TriggerType = TriggerType = {}));
|
|
@@ -2,8 +2,9 @@ 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 } from './PollingTypes';
|
|
5
6
|
import { OperationHandlerValidation, OperationHandlerInputValidationSetup, OperationHandlerOutputValidationSetup } from './OperationHandlerValidation';
|
|
6
|
-
import { DynamicOutput, OperationHandlerAuth, OperationHandlerReference, OperationHandlerType, TriggerOperationHttpResponse, TriggerOperationHttpEvent, TriggerRequestOperationInput, TriggerRequestOperationOutput, TriggerResponseOperationInput } from './OperationHandler';
|
|
7
|
+
import { DynamicOutput, OperationHandlerAuth, OperationHandlerReference, OperationHandlerType, TriggerType, TriggerOperationHttpResponse, TriggerOperationHttpEvent, TriggerRequestOperationInput, TriggerRequestOperationOutput, TriggerResponseOperationInput, TriggerPollRequestOperationInput, TriggerPollRequestOperationOutput, TriggerPollDedupOperationInput, TriggerPollDedupOperationOutput } from './OperationHandler';
|
|
7
8
|
import { OperationGlobalConfigHttp } from './OperationGlobalConfig';
|
|
8
9
|
export type OperationHandlerImplementation<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT> = HttpOperationHandler<AUTH, IN, OUT> | CompositeOperationHandler<AUTH, IN, OUT>;
|
|
9
10
|
export declare class OperationHandler<AUTH extends OperationHandlerAuth<unknown, unknown>, IN, OUT> {
|
|
@@ -48,6 +49,10 @@ export interface OperationHandlerSetupInterface {
|
|
|
48
49
|
configureTriggerResponseHandler: <AUTH extends OperationHandlerAuth<unknown, unknown>, IN, RES>(handlerSetup: OperationHandlerSetup<AUTH, TriggerResponseOperationInput<IN, RES>, TriggerOperationHttpResponse>) => OperationHandlerReference<AUTH, TriggerResponseOperationInput<IN, RES>, TriggerOperationHttpResponse>;
|
|
49
50
|
configureTriggerEventHandler: <AUTH extends OperationHandlerAuth<unknown, unknown>, IN, RES>(handlerSetup: OperationHandlerSetup<AUTH, TriggerResponseOperationInput<IN, RES>, TriggerOperationHttpEvent>) => OperationHandlerReference<AUTH, TriggerResponseOperationInput<IN, RES>, TriggerOperationHttpEvent>;
|
|
50
51
|
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>(handlerSetup: OperationHandlerSetup<AUTH, TriggerPollRequestOperationInput<IN>, TriggerPollRequestOperationOutput<EVENT>>) => OperationHandlerReference<AUTH, TriggerPollRequestOperationInput<IN>, TriggerPollRequestOperationOutput<EVENT>>;
|
|
55
|
+
configureTriggerPollDedupHandler: <AUTH extends OperationHandlerAuth<unknown, unknown>, IN extends PollingTriggerInput, EVENT>(handlerSetup: OperationHandlerSetup<AUTH, TriggerPollDedupOperationInput<IN, EVENT>, TriggerPollDedupOperationOutput>) => OperationHandlerReference<AUTH, TriggerPollDedupOperationInput<IN, EVENT>, TriggerPollDedupOperationOutput>;
|
|
51
56
|
}
|
|
52
57
|
export type OperationDescriptor = {
|
|
53
58
|
name: string;
|
|
@@ -56,6 +61,7 @@ export type OperationDescriptor = {
|
|
|
56
61
|
type?: string;
|
|
57
62
|
isPrivate?: boolean;
|
|
58
63
|
dynamic_output?: boolean;
|
|
64
|
+
triggerType?: TriggerType;
|
|
59
65
|
};
|
|
60
66
|
export declare const OperationHandlerSetup: OperationHandlerSetupInterface;
|
|
61
67
|
//# 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,0BAA0B,
|
|
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;A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,CAAC,OAAO,EAAE,OAAO,CAAC,EACnD,EAAE,SAAS,mBAAmB,EAC9B,KAAK,EAEL,YAAY,EAAE,qBAAqB,CAClC,IAAI,EACJ,8BAA8B,CAAC,EAAE,EAAE,KAAK,CAAC,EACzC,+BAA+B,CAC/B,KACG,yBAAyB,CAC7B,IAAI,EACJ,8BAA8B,CAAC,EAAE,EAAE,KAAK,CAAC,EACzC,+BAA+B,CAC/B,CAAC;CACF;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;IACzB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC1B,CAAC;AA6CF,eAAO,MAAM,qBAAqB,EAAE,8BA6XnC,CAAC"}
|
|
@@ -32,6 +32,7 @@ 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 PollingTypes_1 = require("./PollingTypes");
|
|
35
36
|
const OperationHandlerValidation_1 = require("./OperationHandlerValidation");
|
|
36
37
|
const OperationHandler_1 = require("./OperationHandler");
|
|
37
38
|
class OperationHandler {
|
|
@@ -126,6 +127,20 @@ const readOperationDescriptorFile = () => {
|
|
|
126
127
|
})(operationDescriptorOpt);
|
|
127
128
|
return operationDescriptor;
|
|
128
129
|
};
|
|
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
|
+
// Polling lifecycle operations (TriggerPollCreate / TriggerPollDestroy) are
|
|
138
|
+
// dispatched directly by cdk-runtime's CompositeOperationExecution to the
|
|
139
|
+
// Polling Service; their CompositeOperationHandler body is never invoked at
|
|
140
|
+
// runtime. OperationHandlerConfiguration still requires a terminator
|
|
141
|
+
// (usingComposite / usingHttp) to produce an OperationHandler, so we install
|
|
142
|
+
// this no-op body as a structural placeholder.
|
|
143
|
+
const pollingLifecycleNoOpBody = async () => OperationHandler_1.OperationHandlerResult.success({});
|
|
129
144
|
exports.OperationHandlerSetup = {
|
|
130
145
|
configureHandler: (handlerSetup) => {
|
|
131
146
|
const descriptor = readOperationDescriptorFile();
|
|
@@ -186,4 +201,83 @@ exports.OperationHandlerSetup = {
|
|
|
186
201
|
name: handler.name,
|
|
187
202
|
};
|
|
188
203
|
},
|
|
204
|
+
configureTriggerPollCreateHandler: () => {
|
|
205
|
+
const descriptor = readOperationDescriptorFile();
|
|
206
|
+
assertPollingTriggerType(descriptor, 'configureTriggerPollCreateHandler');
|
|
207
|
+
const { name } = descriptor;
|
|
208
|
+
const handler = OperationHandlerConfiguration.withNameAndHandlerType(`${name}`, OperationHandler_1.OperationHandlerType.TriggerPollCreate)
|
|
209
|
+
.addInputValidation((v) => v
|
|
210
|
+
.condition((_ctx, input) => input.pollingInterval === undefined ||
|
|
211
|
+
(typeof input.pollingInterval.value === 'number' &&
|
|
212
|
+
Number.isFinite(input.pollingInterval.value)))
|
|
213
|
+
.errorMessage(() => 'pollingInterval.value must be a finite number'))
|
|
214
|
+
.addInputValidation((v) => v
|
|
215
|
+
.condition((_ctx, input) => input.pollingInterval === undefined ||
|
|
216
|
+
Object.values(PollingTypes_1.PollingIntervalUnit).includes(input.pollingInterval.unit))
|
|
217
|
+
.errorMessage(() => `pollingInterval.unit must be one of: ${Object.values(PollingTypes_1.PollingIntervalUnit).join(', ')}`))
|
|
218
|
+
.addInputValidation((v) => v
|
|
219
|
+
.condition((_ctx, input) => {
|
|
220
|
+
if (input.pollingInterval === undefined)
|
|
221
|
+
return true;
|
|
222
|
+
const { value, unit } = input.pollingInterval;
|
|
223
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
if (unit === PollingTypes_1.PollingIntervalUnit.Minutes) {
|
|
227
|
+
return value >= PollingTypes_1.MINIMUM_POLLING_INTERVAL_MINUTES;
|
|
228
|
+
}
|
|
229
|
+
if (unit === PollingTypes_1.PollingIntervalUnit.Hours) {
|
|
230
|
+
return value >= PollingTypes_1.MINIMUM_POLLING_INTERVAL_HOURS;
|
|
231
|
+
}
|
|
232
|
+
return true;
|
|
233
|
+
})
|
|
234
|
+
.errorMessage((_ctx, input) => {
|
|
235
|
+
const unit = input.pollingInterval?.unit;
|
|
236
|
+
const min = unit === PollingTypes_1.PollingIntervalUnit.Hours
|
|
237
|
+
? PollingTypes_1.MINIMUM_POLLING_INTERVAL_HOURS
|
|
238
|
+
: PollingTypes_1.MINIMUM_POLLING_INTERVAL_MINUTES;
|
|
239
|
+
return `pollingInterval.value must be at least ${min} ${unit ?? PollingTypes_1.PollingIntervalUnit.Minutes} (got ${input.pollingInterval?.value})`;
|
|
240
|
+
}))
|
|
241
|
+
.addInputValidation((v) => v
|
|
242
|
+
.condition((_ctx, input) => input.maxFailureCount === undefined ||
|
|
243
|
+
(typeof input.maxFailureCount === 'number' &&
|
|
244
|
+
Number.isInteger(input.maxFailureCount)))
|
|
245
|
+
.errorMessage(() => 'maxFailureCount must be an integer'))
|
|
246
|
+
.addInputValidation((v) => v
|
|
247
|
+
.condition((_ctx, input) => input.maxFailureCount === undefined ||
|
|
248
|
+
(input.maxFailureCount >= PollingTypes_1.MINIMUM_MAX_FAILURE_COUNT &&
|
|
249
|
+
input.maxFailureCount <= PollingTypes_1.MAXIMUM_MAX_FAILURE_COUNT))
|
|
250
|
+
.errorMessage((_ctx, input) => `maxFailureCount must be between ${PollingTypes_1.MINIMUM_MAX_FAILURE_COUNT} and ${PollingTypes_1.MAXIMUM_MAX_FAILURE_COUNT} (got ${input.maxFailureCount})`))
|
|
251
|
+
.usingComposite(pollingLifecycleNoOpBody);
|
|
252
|
+
OperationHandlerRegistry.register(handler);
|
|
253
|
+
return {
|
|
254
|
+
name: handler.name,
|
|
255
|
+
};
|
|
256
|
+
},
|
|
257
|
+
configureTriggerPollDestroyHandler: () => {
|
|
258
|
+
const descriptor = readOperationDescriptorFile();
|
|
259
|
+
assertPollingTriggerType(descriptor, 'configureTriggerPollDestroyHandler');
|
|
260
|
+
const { name } = descriptor;
|
|
261
|
+
const handler = OperationHandlerConfiguration.withNameAndHandlerType(`${name}_destroy`, OperationHandler_1.OperationHandlerType.TriggerPollDestroy).usingComposite(pollingLifecycleNoOpBody);
|
|
262
|
+
OperationHandlerRegistry.register(handler);
|
|
263
|
+
return {
|
|
264
|
+
name: handler.name,
|
|
265
|
+
};
|
|
266
|
+
},
|
|
267
|
+
configureTriggerPollRequestHandler: (handlerSetup) => {
|
|
268
|
+
const descriptor = readOperationDescriptorFile();
|
|
269
|
+
assertPollingTriggerType(descriptor, 'configureTriggerPollRequestHandler');
|
|
270
|
+
const { name } = descriptor;
|
|
271
|
+
const handler = handlerSetup(OperationHandlerConfiguration.withNameAndHandlerType(`${name}_poll_request`, OperationHandler_1.OperationHandlerType.TriggerPollRequest));
|
|
272
|
+
OperationHandlerRegistry.register(handler);
|
|
273
|
+
return { name: handler.name };
|
|
274
|
+
},
|
|
275
|
+
configureTriggerPollDedupHandler: (handlerSetup) => {
|
|
276
|
+
const descriptor = readOperationDescriptorFile();
|
|
277
|
+
assertPollingTriggerType(descriptor, 'configureTriggerPollDedupHandler');
|
|
278
|
+
const { name } = descriptor;
|
|
279
|
+
const handler = handlerSetup(OperationHandlerConfiguration.withNameAndHandlerType(`${name}_request`, OperationHandler_1.OperationHandlerType.TriggerPollDedup));
|
|
280
|
+
OperationHandlerRegistry.register(handler);
|
|
281
|
+
return { name: handler.name };
|
|
282
|
+
},
|
|
189
283
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationHandlerSetup.polling.unit.test.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationHandlerSetup.polling.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,278 @@
|
|
|
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 PollingTypes_1 = require("./PollingTypes");
|
|
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 the base operation name when triggerType is polling', () => {
|
|
65
|
+
pointCallSiteAt(pollingFixtureFolder);
|
|
66
|
+
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollCreateHandler();
|
|
67
|
+
expect(ref.name).toBe('new_records');
|
|
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: PollingTypes_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: PollingTypes_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: PollingTypes_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: PollingTypes_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: PollingTypes_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
|
+
});
|
|
159
|
+
describe('configureTriggerPollDestroyHandler', () => {
|
|
160
|
+
it('registers TriggerPollDestroy with _destroy suffix', () => {
|
|
161
|
+
pointCallSiteAt(pollingFixtureFolder);
|
|
162
|
+
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollDestroyHandler();
|
|
163
|
+
expect(ref.name).toBe('new_records_destroy');
|
|
164
|
+
const handler = resolveHandler(ref);
|
|
165
|
+
expect(handler.handlerType).toBe(OperationHandler_1.OperationHandlerType.TriggerPollDestroy);
|
|
166
|
+
expect(handler.implementation._tag).toBe('CompositeOperationHandler');
|
|
167
|
+
});
|
|
168
|
+
it('throws when triggerType is not polling', () => {
|
|
169
|
+
pointCallSiteAt(regularFixtureFolder);
|
|
170
|
+
expect(() => OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollDestroyHandler()).toThrow(/triggerType.*polling/);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
describe('configureTriggerPollRequestHandler', () => {
|
|
174
|
+
it('registers TriggerPollRequest with _poll_request suffix', () => {
|
|
175
|
+
pointCallSiteAt(pollingFixtureFolder);
|
|
176
|
+
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollRequestHandler((handler) => handler.usingComposite(async () => OperationHandler_1.OperationHandlerResult.success({
|
|
177
|
+
events: [],
|
|
178
|
+
nextCursor: null,
|
|
179
|
+
canPollMore: false,
|
|
180
|
+
})));
|
|
181
|
+
expect(ref.name).toBe('new_records_poll_request');
|
|
182
|
+
const handler = resolveHandler(ref);
|
|
183
|
+
expect(handler.handlerType).toBe(OperationHandler_1.OperationHandlerType.TriggerPollRequest);
|
|
184
|
+
expect(handler.implementation._tag).toBe('CompositeOperationHandler');
|
|
185
|
+
});
|
|
186
|
+
it('throws when triggerType is not polling', () => {
|
|
187
|
+
pointCallSiteAt(regularFixtureFolder);
|
|
188
|
+
expect(() => OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollRequestHandler((handler) => handler.usingComposite(async () => OperationHandler_1.OperationHandlerResult.success({
|
|
189
|
+
events: [],
|
|
190
|
+
nextCursor: null,
|
|
191
|
+
canPollMore: false,
|
|
192
|
+
})))).toThrow(/triggerType.*polling/);
|
|
193
|
+
});
|
|
194
|
+
it("delegates to the dev's composite body and passes the envelope through untouched", async () => {
|
|
195
|
+
pointCallSiteAt(pollingFixtureFolder);
|
|
196
|
+
const body = jest.fn(async () => OperationHandler_1.OperationHandlerResult.success({
|
|
197
|
+
events: [{ id: 'e1' }],
|
|
198
|
+
nextCursor: 'e1',
|
|
199
|
+
canPollMore: true,
|
|
200
|
+
}));
|
|
201
|
+
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollRequestHandler((handler) => handler.usingComposite(body));
|
|
202
|
+
const handler = resolveHandler(ref);
|
|
203
|
+
const fn = handler.implementation.handlerFunction;
|
|
204
|
+
const ctx = { auth: { authId: 'auth-123' } };
|
|
205
|
+
const input = { input: { some: 'thing' }, cursor: 'e0' };
|
|
206
|
+
const invoke = {};
|
|
207
|
+
const result = await fn(ctx, input, invoke);
|
|
208
|
+
expect(body).toHaveBeenCalledTimes(1);
|
|
209
|
+
expect(body).toHaveBeenCalledWith(ctx, input, invoke);
|
|
210
|
+
expect(result.isSuccess).toBe(true);
|
|
211
|
+
expect(result.value).toEqual({
|
|
212
|
+
events: [{ id: 'e1' }],
|
|
213
|
+
nextCursor: 'e1',
|
|
214
|
+
canPollMore: true,
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
it('forwards a dev-returned failure result as-is (no implicit success wrap)', async () => {
|
|
218
|
+
pointCallSiteAt(pollingFixtureFolder);
|
|
219
|
+
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollRequestHandler((handler) => handler.usingComposite(async () => OperationHandler_1.OperationHandlerResult.failure(OperationHandler_1.OperationHandlerError.userInputError('nope'))));
|
|
220
|
+
const handler = resolveHandler(ref);
|
|
221
|
+
const fn = handler.implementation.handlerFunction;
|
|
222
|
+
const result = await fn({}, { input: {}, cursor: null }, {});
|
|
223
|
+
expect(result.isFailure).toBe(true);
|
|
224
|
+
expect(result.error._tag).toBe('UserInputError');
|
|
225
|
+
expect(result.error.message).toBe('nope');
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
describe('configureTriggerPollDedupHandler', () => {
|
|
229
|
+
it('registers TriggerPollDedup with _request suffix', () => {
|
|
230
|
+
pointCallSiteAt(pollingFixtureFolder);
|
|
231
|
+
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollDedupHandler((handler) => handler.usingComposite(async (_ctx, { event }) => OperationHandler_1.OperationHandlerResult.success({
|
|
232
|
+
triggerDeduplicationId: event.id,
|
|
233
|
+
})));
|
|
234
|
+
expect(ref.name).toBe('new_records_request');
|
|
235
|
+
const handler = resolveHandler(ref);
|
|
236
|
+
expect(handler.handlerType).toBe(OperationHandler_1.OperationHandlerType.TriggerPollDedup);
|
|
237
|
+
expect(handler.implementation._tag).toBe('CompositeOperationHandler');
|
|
238
|
+
});
|
|
239
|
+
it('throws when triggerType is not polling', () => {
|
|
240
|
+
pointCallSiteAt(regularFixtureFolder);
|
|
241
|
+
expect(() => OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollDedupHandler((handler) => handler.usingComposite(async (_ctx, { event }) => OperationHandler_1.OperationHandlerResult.success({
|
|
242
|
+
triggerDeduplicationId: event.id,
|
|
243
|
+
})))).toThrow(/triggerType.*polling/);
|
|
244
|
+
});
|
|
245
|
+
it("registers the dev's composite body verbatim (pass-through; failure-envelope and metadata lift live in cdk-runtime)", async () => {
|
|
246
|
+
pointCallSiteAt(pollingFixtureFolder);
|
|
247
|
+
const body = jest.fn(async (_ctx, { event }) => OperationHandler_1.OperationHandlerResult.success({ triggerDeduplicationId: event.id }));
|
|
248
|
+
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerPollDedupHandler((handler) => handler.usingComposite(body));
|
|
249
|
+
const handler = resolveHandler(ref);
|
|
250
|
+
const fn = handler.implementation.handlerFunction;
|
|
251
|
+
const ctx = {};
|
|
252
|
+
const input = { input: {}, event: { id: 'evt-1' } };
|
|
253
|
+
const invoke = {};
|
|
254
|
+
const result = await fn(ctx, input, invoke);
|
|
255
|
+
expect(body).toHaveBeenCalledTimes(1);
|
|
256
|
+
expect(body).toHaveBeenCalledWith(ctx, input, invoke);
|
|
257
|
+
expect(result.isSuccess).toBe(true);
|
|
258
|
+
expect(result.value).toEqual({ triggerDeduplicationId: 'evt-1' });
|
|
259
|
+
// DSL does not lift body -> metadata; that is cdk-runtime's job.
|
|
260
|
+
expect(result.metadata).toBeUndefined();
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
describe('OperationHandlerSetup non-polling _request (regression baseline)', () => {
|
|
265
|
+
afterEach(() => {
|
|
266
|
+
jest.clearAllMocks();
|
|
267
|
+
});
|
|
268
|
+
it('configureTriggerRequestHandler registers under TriggerRequest with _request suffix for a regular trigger', () => {
|
|
269
|
+
pointCallSiteAt(regularFixtureFolder);
|
|
270
|
+
const ref = OperationHandlerSetup_1.OperationHandlerSetup.configureTriggerRequestHandler((handler) => handler.usingComposite(async () => OperationHandler_1.OperationHandlerResult.success({
|
|
271
|
+
output: {},
|
|
272
|
+
response: OperationHandler_1.TriggerOperationHttpResponse.withStatusCode(200),
|
|
273
|
+
})));
|
|
274
|
+
expect(ref.name).toBe('regular_op_request');
|
|
275
|
+
const handler = resolveHandler(ref);
|
|
276
|
+
expect(handler.handlerType).toBe(OperationHandler_1.OperationHandlerType.TriggerRequest);
|
|
277
|
+
});
|
|
278
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationHandlerUtils.unit.test.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationHandlerUtils.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare enum PollingIntervalUnit {
|
|
2
|
+
Minutes = "minutes",
|
|
3
|
+
Hours = "hours"
|
|
4
|
+
}
|
|
5
|
+
export type PollingInterval = {
|
|
6
|
+
value: number;
|
|
7
|
+
unit: PollingIntervalUnit;
|
|
8
|
+
};
|
|
9
|
+
export declare const MINIMUM_POLLING_INTERVAL_MINUTES = 5;
|
|
10
|
+
export declare const MINIMUM_POLLING_INTERVAL_HOURS = 1;
|
|
11
|
+
export declare const DEFAULT_POLLING_INTERVAL: PollingInterval;
|
|
12
|
+
export declare const DEFAULT_MAX_FAILURE_COUNT = 30;
|
|
13
|
+
export declare const MINIMUM_MAX_FAILURE_COUNT = 1;
|
|
14
|
+
export declare const MAXIMUM_MAX_FAILURE_COUNT = 150;
|
|
15
|
+
export type PollingTriggerInput = {
|
|
16
|
+
pollingInterval?: PollingInterval;
|
|
17
|
+
maxFailureCount?: number;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=PollingTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PollingTypes.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/PollingTypes.ts"],"names":[],"mappings":"AAAA,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,MAAM,MAAM,mBAAmB,GAAG;IACjC,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/cdk-dsl",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.22.1-unstable",
|
|
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.
|
|
17
|
+
"@trayio/commons": "5.22.1-unstable"
|
|
18
18
|
},
|
|
19
19
|
"typesVersions": {
|
|
20
20
|
"*": {
|
|
@@ -26,5 +26,6 @@
|
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"/dist"
|
|
29
|
-
]
|
|
29
|
+
],
|
|
30
|
+
"stableVersion": "0.0.0"
|
|
30
31
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OperationHandlerUtils.test.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/OperationHandlerUtils.test.ts"],"names":[],"mappings":""}
|
|
File without changes
|