@skedulo/integration-sdk 0.3.4 → 0.5.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/CHANGELOG.md +24 -0
- package/README.md +84 -20
- package/dist/actions/action-registry.d.ts.map +1 -1
- package/dist/actions/action-registry.js +27 -23
- package/dist/actions/action-registry.js.map +1 -1
- package/dist/actions/data-flow/activate.action.d.ts +10 -0
- package/dist/actions/data-flow/activate.action.d.ts.map +1 -0
- package/dist/actions/data-flow/activate.action.js +22 -0
- package/dist/actions/data-flow/activate.action.js.map +1 -0
- package/dist/actions/data-flow/create.action.d.ts +9 -0
- package/dist/actions/data-flow/create.action.d.ts.map +1 -0
- package/dist/actions/data-flow/create.action.js +55 -0
- package/dist/actions/data-flow/create.action.js.map +1 -0
- package/dist/actions/data-flow/deactivate.action.d.ts +9 -0
- package/dist/actions/data-flow/deactivate.action.d.ts.map +1 -0
- package/dist/actions/data-flow/deactivate.action.js +21 -0
- package/dist/actions/data-flow/deactivate.action.js.map +1 -0
- package/dist/actions/data-flow/delete.action.d.ts +10 -0
- package/dist/actions/data-flow/delete.action.d.ts.map +1 -0
- package/dist/actions/data-flow/delete.action.js +33 -0
- package/dist/actions/data-flow/delete.action.js.map +1 -0
- package/dist/actions/data-flow/get.action.d.ts +5 -0
- package/dist/actions/data-flow/get.action.d.ts.map +1 -0
- package/dist/actions/data-flow/get.action.js +22 -0
- package/dist/actions/data-flow/get.action.js.map +1 -0
- package/dist/actions/data-flow/index.d.ts +9 -0
- package/dist/actions/data-flow/index.d.ts.map +1 -0
- package/dist/actions/data-flow/index.js +33 -0
- package/dist/actions/data-flow/index.js.map +1 -0
- package/dist/actions/data-flow/list.action.d.ts +6 -0
- package/dist/actions/data-flow/list.action.d.ts.map +1 -0
- package/dist/actions/data-flow/list.action.js +25 -0
- package/dist/actions/data-flow/list.action.js.map +1 -0
- package/dist/actions/data-flow/shared.d.ts +3 -0
- package/dist/actions/data-flow/shared.d.ts.map +1 -0
- package/dist/actions/data-flow/shared.js +16 -0
- package/dist/actions/data-flow/shared.js.map +1 -0
- package/dist/actions/data-flow/types.d.ts +21 -0
- package/dist/actions/data-flow/types.d.ts.map +1 -0
- package/dist/actions/data-flow/types.js +3 -0
- package/dist/actions/data-flow/types.js.map +1 -0
- package/dist/actions/data-flow/update.action.d.ts +16 -0
- package/dist/actions/data-flow/update.action.d.ts.map +1 -0
- package/dist/actions/data-flow/update.action.js +62 -0
- package/dist/actions/data-flow/update.action.js.map +1 -0
- package/dist/actions/data-flow.action.d.ts.map +1 -1
- package/dist/actions/data-flow.action.js +5 -9
- package/dist/actions/data-flow.action.js.map +1 -1
- package/dist/actions/event/index.d.ts +4 -0
- package/dist/actions/event/index.d.ts.map +1 -0
- package/dist/actions/event/index.js +23 -0
- package/dist/actions/event/index.js.map +1 -0
- package/dist/actions/event/on-skedulo.action.d.ts +4 -0
- package/dist/actions/event/on-skedulo.action.d.ts.map +1 -0
- package/dist/actions/event/on-skedulo.action.js +81 -0
- package/dist/actions/event/on-skedulo.action.js.map +1 -0
- package/dist/actions/event/on-vendor.action.d.ts +4 -0
- package/dist/actions/event/on-vendor.action.d.ts.map +1 -0
- package/dist/actions/event/on-vendor.action.js +43 -0
- package/dist/actions/event/on-vendor.action.js.map +1 -0
- package/dist/actions/event/types.d.ts +28 -0
- package/dist/actions/event/types.d.ts.map +1 -0
- package/dist/actions/event/types.js +3 -0
- package/dist/actions/event/types.js.map +1 -0
- package/dist/actions/metadata/get-fields.action.d.ts +5 -0
- package/dist/actions/metadata/get-fields.action.d.ts.map +1 -0
- package/dist/actions/metadata/get-fields.action.js +26 -0
- package/dist/actions/metadata/get-fields.action.js.map +1 -0
- package/dist/actions/metadata/get-objects.action.d.ts +5 -0
- package/dist/actions/metadata/get-objects.action.d.ts.map +1 -0
- package/dist/actions/metadata/get-objects.action.js +18 -0
- package/dist/actions/metadata/get-objects.action.js.map +1 -0
- package/dist/actions/metadata/get-sample-apis.action.d.ts +5 -0
- package/dist/actions/metadata/get-sample-apis.action.d.ts.map +1 -0
- package/dist/actions/metadata/get-sample-apis.action.js +19 -0
- package/dist/actions/metadata/get-sample-apis.action.js.map +1 -0
- package/dist/actions/metadata/get-sample-records.action.d.ts +5 -0
- package/dist/actions/metadata/get-sample-records.action.d.ts.map +1 -0
- package/dist/actions/metadata/get-sample-records.action.js +33 -0
- package/dist/actions/metadata/get-sample-records.action.js.map +1 -0
- package/dist/actions/metadata/get-templates.action.d.ts +5 -0
- package/dist/actions/metadata/get-templates.action.d.ts.map +1 -0
- package/dist/actions/metadata/get-templates.action.js +19 -0
- package/dist/actions/metadata/get-templates.action.js.map +1 -0
- package/dist/actions/metadata/index.d.ts +7 -0
- package/dist/actions/metadata/index.d.ts.map +1 -0
- package/dist/actions/metadata/index.js +29 -0
- package/dist/actions/metadata/index.js.map +1 -0
- package/dist/actions/metadata/shared.d.ts +6 -0
- package/dist/actions/metadata/shared.d.ts.map +1 -0
- package/dist/actions/metadata/shared.js +11 -0
- package/dist/actions/metadata/shared.js.map +1 -0
- package/dist/actions/metadata/types.d.ts +38 -0
- package/dist/actions/metadata/types.d.ts.map +1 -0
- package/dist/actions/metadata/types.js +3 -0
- package/dist/actions/metadata/types.js.map +1 -0
- package/dist/actions/scheduled-job/create.action.d.ts +5 -0
- package/dist/actions/scheduled-job/create.action.d.ts.map +1 -0
- package/dist/actions/scheduled-job/create.action.js +56 -0
- package/dist/actions/scheduled-job/create.action.js.map +1 -0
- package/dist/actions/scheduled-job/delete.action.d.ts +15 -0
- package/dist/actions/scheduled-job/delete.action.d.ts.map +1 -0
- package/dist/actions/scheduled-job/delete.action.js +42 -0
- package/dist/actions/scheduled-job/delete.action.js.map +1 -0
- package/dist/actions/scheduled-job/get.action.d.ts +7 -0
- package/dist/actions/scheduled-job/get.action.d.ts.map +1 -0
- package/dist/actions/scheduled-job/get.action.js +23 -0
- package/dist/actions/scheduled-job/get.action.js.map +1 -0
- package/dist/actions/scheduled-job/index.d.ts +7 -0
- package/dist/actions/scheduled-job/index.d.ts.map +1 -0
- package/dist/actions/scheduled-job/index.js +29 -0
- package/dist/actions/scheduled-job/index.js.map +1 -0
- package/dist/actions/scheduled-job/list.action.d.ts +5 -0
- package/dist/actions/scheduled-job/list.action.d.ts.map +1 -0
- package/dist/actions/scheduled-job/list.action.js +18 -0
- package/dist/actions/scheduled-job/list.action.js.map +1 -0
- package/dist/actions/scheduled-job/shared.d.ts +30 -0
- package/dist/actions/scheduled-job/shared.d.ts.map +1 -0
- package/dist/actions/scheduled-job/shared.js +129 -0
- package/dist/actions/scheduled-job/shared.js.map +1 -0
- package/dist/actions/scheduled-job/types.d.ts +23 -0
- package/dist/actions/scheduled-job/types.d.ts.map +1 -0
- package/dist/actions/scheduled-job/types.js +3 -0
- package/dist/actions/scheduled-job/types.js.map +1 -0
- package/dist/actions/scheduled-job/update.action.d.ts +5 -0
- package/dist/actions/scheduled-job/update.action.d.ts.map +1 -0
- package/dist/actions/scheduled-job/update.action.js +68 -0
- package/dist/actions/scheduled-job/update.action.js.map +1 -0
- package/dist/actions/scheduled-job.action.d.ts +73 -0
- package/dist/actions/scheduled-job.action.d.ts.map +1 -0
- package/dist/actions/scheduled-job.action.js +355 -0
- package/dist/actions/scheduled-job.action.js.map +1 -0
- package/dist/actions/setup.action.js +1 -1
- package/dist/actions/setup.action.js.map +1 -1
- package/dist/actions/sync/index.d.ts +4 -0
- package/dist/actions/sync/index.d.ts.map +1 -0
- package/dist/actions/sync/index.js +23 -0
- package/dist/actions/sync/index.js.map +1 -0
- package/dist/actions/sync/run-flow.action.d.ts +8 -0
- package/dist/actions/sync/run-flow.action.d.ts.map +1 -0
- package/dist/actions/sync/run-flow.action.js +81 -0
- package/dist/actions/sync/run-flow.action.js.map +1 -0
- package/dist/actions/sync/run-job.action.d.ts +11 -0
- package/dist/actions/sync/run-job.action.d.ts.map +1 -0
- package/dist/actions/sync/run-job.action.js +75 -0
- package/dist/actions/sync/run-job.action.js.map +1 -0
- package/dist/actions/sync/types.d.ts +41 -0
- package/dist/actions/sync/types.d.ts.map +1 -0
- package/dist/actions/sync/types.js +3 -0
- package/dist/actions/sync/types.js.map +1 -0
- package/dist/actions/sync.action.d.ts +8 -47
- package/dist/actions/sync.action.d.ts.map +1 -1
- package/dist/actions/sync.action.js +29 -162
- package/dist/actions/sync.action.js.map +1 -1
- package/dist/actions/utils/action-names.d.ts +19 -6
- package/dist/actions/utils/action-names.d.ts.map +1 -1
- package/dist/actions/utils/action-names.js +19 -6
- package/dist/actions/utils/action-names.js.map +1 -1
- package/dist/actions/utils/define-action.d.ts +36 -0
- package/dist/actions/utils/define-action.d.ts.map +1 -0
- package/dist/actions/utils/define-action.js +43 -0
- package/dist/actions/utils/define-action.js.map +1 -0
- package/dist/actions/utils/errors.d.ts +54 -8
- package/dist/actions/utils/errors.d.ts.map +1 -1
- package/dist/actions/utils/errors.js +107 -14
- package/dist/actions/utils/errors.js.map +1 -1
- package/dist/actions/utils/helpers.d.ts.map +1 -1
- package/dist/actions/utils/helpers.js +2 -1
- package/dist/actions/utils/helpers.js.map +1 -1
- package/dist/actions/utils/metrics.d.ts +12 -0
- package/dist/actions/utils/metrics.d.ts.map +1 -0
- package/dist/actions/utils/metrics.js +12 -0
- package/dist/actions/utils/metrics.js.map +1 -0
- package/dist/actions/utils/middleware.d.ts +39 -0
- package/dist/actions/utils/middleware.d.ts.map +1 -0
- package/dist/actions/utils/middleware.js +85 -0
- package/dist/actions/utils/middleware.js.map +1 -0
- package/dist/actions/utils/types.d.ts +5 -4
- package/dist/actions/utils/types.d.ts.map +1 -1
- package/dist/adapters/base-adapter-handler.d.ts +10 -0
- package/dist/adapters/base-adapter-handler.d.ts.map +1 -1
- package/dist/adapters/base-adapter-handler.js +18 -34
- package/dist/adapters/base-adapter-handler.js.map +1 -1
- package/dist/browser.d.ts +2 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +3 -1
- package/dist/browser.js.map +1 -1
- package/dist/clients/integration-config.client.d.ts +21 -0
- package/dist/clients/integration-config.client.d.ts.map +1 -0
- package/dist/clients/integration-config.client.js +44 -0
- package/dist/clients/integration-config.client.js.map +1 -0
- package/dist/context.d.ts +18 -3
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +21 -5
- package/dist/context.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces/data-flow-spec.interface.d.ts +14 -21
- package/dist/interfaces/data-flow-spec.interface.d.ts.map +1 -1
- package/dist/interfaces/data-flow-spec.interface.js +10 -26
- package/dist/interfaces/data-flow-spec.interface.js.map +1 -1
- package/dist/interfaces/integration-capabilities.interface.d.ts +2 -2
- package/dist/interfaces/scheduled-job.interface.d.ts +40 -0
- package/dist/interfaces/scheduled-job.interface.d.ts.map +1 -0
- package/dist/interfaces/scheduled-job.interface.js +39 -0
- package/dist/interfaces/scheduled-job.interface.js.map +1 -0
- package/dist/services/dataflow.service.d.ts +13 -6
- package/dist/services/dataflow.service.d.ts.map +1 -1
- package/dist/services/dataflow.service.js +34 -57
- package/dist/services/dataflow.service.js.map +1 -1
- package/dist/services/sync-runner.d.ts +1 -0
- package/dist/services/sync-runner.d.ts.map +1 -1
- package/dist/services/sync-runner.js +7 -27
- package/dist/services/sync-runner.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/artifact-builder.d.ts +40 -15
- package/dist/utils/artifact-builder.d.ts.map +1 -1
- package/dist/utils/artifact-builder.js +92 -17
- package/dist/utils/artifact-builder.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Adapter } from '../../interfaces/adapter.interface';
|
|
2
|
+
import type { AdapterRegistry } from '../../adapters/adapter-registry';
|
|
3
|
+
import type { BatchResult } from '../../interfaces/sync-result.interface';
|
|
4
|
+
export type SyncDeps = {
|
|
5
|
+
adapter: Adapter;
|
|
6
|
+
registry: AdapterRegistry;
|
|
7
|
+
};
|
|
8
|
+
export interface RunFlowInput {
|
|
9
|
+
flowId: number;
|
|
10
|
+
/** Manual backfill: sync from this time, overriding the persisted cursor. */
|
|
11
|
+
since?: Date;
|
|
12
|
+
/** Manual full resync: ignore the persisted cursor and pull everything. */
|
|
13
|
+
fullResync?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type RunFlowOutput = {
|
|
16
|
+
runId: string;
|
|
17
|
+
flowId: number;
|
|
18
|
+
} & BatchResult;
|
|
19
|
+
export interface RunJobInput {
|
|
20
|
+
webhookName: string;
|
|
21
|
+
}
|
|
22
|
+
type PerFlowResultBase = {
|
|
23
|
+
flowId: number;
|
|
24
|
+
sourceObject?: string;
|
|
25
|
+
targetObject?: string;
|
|
26
|
+
};
|
|
27
|
+
export type PerFlowResult = PerFlowResultBase & ({
|
|
28
|
+
skipped: true;
|
|
29
|
+
reason: string;
|
|
30
|
+
} | {
|
|
31
|
+
error: string;
|
|
32
|
+
} | (BatchResult & {
|
|
33
|
+
durationMs: number;
|
|
34
|
+
}));
|
|
35
|
+
export interface RunJobOutput {
|
|
36
|
+
webhookName: string;
|
|
37
|
+
skipped?: boolean;
|
|
38
|
+
results: PerFlowResult[];
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/actions/sync/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAE1E,MAAM,MAAM,QAAQ,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,eAAe,CAAA;CAAE,CAAC;AAEvE,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,2EAA2E;IAC3E,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AACD,MAAM,MAAM,aAAa,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,WAAW,CAAC;AAE5E,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,KAAK,iBAAiB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAC1F,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAC3C,CAAC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,CAAC,WAAW,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAAC;AAEnG,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,aAAa,EAAE,CAAC;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/actions/sync/types.ts"],"names":[],"mappings":""}
|
|
@@ -6,60 +6,21 @@ type SyncDeps = {
|
|
|
6
6
|
adapter: Adapter;
|
|
7
7
|
registry: AdapterRegistry;
|
|
8
8
|
};
|
|
9
|
-
export interface PushInput {
|
|
10
|
-
dataFlowId: number;
|
|
11
|
-
}
|
|
12
|
-
export type PushOutput = (BatchResult & {
|
|
13
|
-
durationMs: number;
|
|
14
|
-
flowId: number;
|
|
15
|
-
}) | {
|
|
16
|
-
flowId: number;
|
|
17
|
-
error: string;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Run a single outbound scheduled (push) data flow. One ElasticServer-triggered
|
|
21
|
-
* artifact per flow invokes this action with its own `dataFlowId`.
|
|
22
|
-
*/
|
|
23
|
-
export declare function makePushAction(deps: SyncDeps): Action<PushInput, PushOutput>;
|
|
24
|
-
export interface ScheduledPullInput {
|
|
25
|
-
dataFlowId: number;
|
|
26
|
-
}
|
|
27
|
-
export type ScheduledPullOutput = (BatchResult & {
|
|
28
|
-
durationMs: number;
|
|
29
|
-
flowId: number;
|
|
30
|
-
}) | {
|
|
31
|
-
flowId: number;
|
|
32
|
-
error: string;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Run a single inbound scheduled (pull) data flow. One ElasticServer-triggered
|
|
36
|
-
* artifact per flow invokes this action with its own `dataFlowId`.
|
|
37
|
-
*/
|
|
38
|
-
export declare function makeScheduledPullAction(deps: SyncDeps): Action<ScheduledPullInput, ScheduledPullOutput>;
|
|
39
9
|
export interface RunFlowInput {
|
|
40
10
|
flowId: number;
|
|
11
|
+
/** Manual backfill: sync from this time, overriding the persisted cursor. */
|
|
12
|
+
since?: Date;
|
|
13
|
+
/** Manual full resync: ignore the persisted cursor and pull everything. */
|
|
14
|
+
fullResync?: boolean;
|
|
41
15
|
}
|
|
42
16
|
export type RunFlowOutput = {
|
|
43
17
|
runId: string;
|
|
44
18
|
flowId: number;
|
|
45
19
|
} & BatchResult;
|
|
20
|
+
/**
|
|
21
|
+
* Manually run a single flow. Admin-only. Supports a one-off backfill (`since`)
|
|
22
|
+
* or full resync (`fullResync`) that overrides the persisted cursor.
|
|
23
|
+
*/
|
|
46
24
|
export declare function makeRunFlowAction(deps: SyncDeps): Action<RunFlowInput, RunFlowOutput>;
|
|
47
|
-
export type RunAllFlowsInput = void;
|
|
48
|
-
type RunAllFlowsEntryBase = {
|
|
49
|
-
flowId: number;
|
|
50
|
-
sourceObject: string;
|
|
51
|
-
targetObject: string;
|
|
52
|
-
};
|
|
53
|
-
export type RunAllFlowsEntry = RunAllFlowsEntryBase & ({
|
|
54
|
-
skipped: true;
|
|
55
|
-
reason: string;
|
|
56
|
-
} | {
|
|
57
|
-
error: string;
|
|
58
|
-
} | BatchResult);
|
|
59
|
-
export interface RunAllFlowsOutput {
|
|
60
|
-
message: string;
|
|
61
|
-
results: Record<string, RunAllFlowsEntry>;
|
|
62
|
-
}
|
|
63
|
-
export declare function makeRunAllFlowsAction(deps: SyncDeps): Action<RunAllFlowsInput, RunAllFlowsOutput>;
|
|
64
25
|
export {};
|
|
65
26
|
//# sourceMappingURL=sync.action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.action.d.ts","sourceRoot":"","sources":["../../src/actions/sync.action.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"sync.action.d.ts","sourceRoot":"","sources":["../../src/actions/sync.action.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAOvE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,KAAK,QAAQ,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,eAAe,CAAA;CAAE,CAAC;AAahE,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,KAAK,CAAC,EAAE,IAAI,CAAC;IACb,2EAA2E;IAC3E,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AACD,MAAM,MAAM,aAAa,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,WAAW,CAAC;AAa5E;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC,YAAY,EAAE,aAAa,CAAC,CAoDrF"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makePushAction = makePushAction;
|
|
4
|
-
exports.makeScheduledPullAction = makeScheduledPullAction;
|
|
5
3
|
exports.makeRunFlowAction = makeRunFlowAction;
|
|
6
|
-
exports.makeRunAllFlowsAction = makeRunAllFlowsAction;
|
|
7
4
|
const crypto_1 = require("crypto");
|
|
8
5
|
const constants_1 = require("../constants");
|
|
9
|
-
const data_flow_spec_interface_1 = require("../interfaces/data-flow-spec.interface");
|
|
10
6
|
const sync_runner_1 = require("../services/sync-runner");
|
|
11
7
|
const helpers_1 = require("../utils/helpers");
|
|
12
8
|
const action_names_1 = require("./utils/action-names");
|
|
@@ -20,112 +16,34 @@ function parsePositiveInt(raw, field) {
|
|
|
20
16
|
}
|
|
21
17
|
return v;
|
|
22
18
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
*/
|
|
27
|
-
function parseDataFlowId(raw, meta) {
|
|
28
|
-
if ((meta === null || meta === void 0 ? void 0 : meta.dataFlowId) !== undefined) {
|
|
29
|
-
if (!Number.isInteger(meta.dataFlowId) || meta.dataFlowId <= 0) {
|
|
30
|
-
throw new errors_1.InvalidInputError('dataFlowId must be a positive integer');
|
|
31
|
-
}
|
|
32
|
-
return meta.dataFlowId;
|
|
19
|
+
function parseSinceDate(value) {
|
|
20
|
+
if (typeof value !== 'string') {
|
|
21
|
+
throw new errors_1.InvalidInputError('since must be an ISO date-time string');
|
|
33
22
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*/
|
|
40
|
-
function makePushAction(deps) {
|
|
41
|
-
return {
|
|
42
|
-
name: action_names_1.ACTIONS.sync.push,
|
|
43
|
-
parseInput(raw, meta) {
|
|
44
|
-
return { dataFlowId: parseDataFlowId(raw, meta) };
|
|
45
|
-
},
|
|
46
|
-
async handler(input, ctx) {
|
|
47
|
-
const integrationType = deps.adapter.integrationType;
|
|
48
|
-
const lookupStrategy = (0, helpers_2.resolveLookupStrategy)(deps.adapter);
|
|
49
|
-
const flow = await ctx.dataFlowService.getFlowById(input.dataFlowId);
|
|
50
|
-
if (!flow) {
|
|
51
|
-
throw new errors_1.ActionError('FLOW_NOT_FOUND', `Flow ${input.dataFlowId} not found`);
|
|
52
|
-
}
|
|
53
|
-
const sc = (0, data_flow_spec_interface_1.asSyncConfig)(flow.triggerConfig);
|
|
54
|
-
if (!sc || sc.strategy !== data_flow_spec_interface_1.SyncStrategy.SCHEDULED) {
|
|
55
|
-
throw new errors_1.ActionError('UNSUPPORTED_STRATEGY', 'push action requires strategy=scheduled');
|
|
56
|
-
}
|
|
57
|
-
const runner = new sync_runner_1.SyncRunner(deps.registry);
|
|
58
|
-
const startedAt = Date.now();
|
|
59
|
-
try {
|
|
60
|
-
const stats = await runner.run({
|
|
61
|
-
flowId: flow.id,
|
|
62
|
-
since: null,
|
|
63
|
-
sourceSystem: constants_1.SKEDULO_SYSTEM,
|
|
64
|
-
targetSystem: integrationType,
|
|
65
|
-
options: { lookupStrategy },
|
|
66
|
-
}, ctx);
|
|
67
|
-
const durationMs = Date.now() - startedAt;
|
|
68
|
-
ctx.logger.info(`[push] flow=${flow.id} ${flow.sourceObject}→${flow.targetObject} ` +
|
|
69
|
-
`${JSON.stringify(stats)} took=${durationMs}ms`);
|
|
70
|
-
return Object.assign(Object.assign({}, stats), { durationMs, flowId: flow.id });
|
|
71
|
-
}
|
|
72
|
-
catch (err) {
|
|
73
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
74
|
-
ctx.logger.error(`[push] flow=${flow.id} failed: ${msg}`);
|
|
75
|
-
return { flowId: flow.id, error: msg };
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
};
|
|
23
|
+
const date = new Date(value);
|
|
24
|
+
if (Number.isNaN(date.getTime())) {
|
|
25
|
+
throw new errors_1.InvalidInputError(`since is not a valid date-time: "${value}"`);
|
|
26
|
+
}
|
|
27
|
+
return date;
|
|
79
28
|
}
|
|
80
29
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
30
|
+
* Manually run a single flow. Admin-only. Supports a one-off backfill (`since`)
|
|
31
|
+
* or full resync (`fullResync`) that overrides the persisted cursor.
|
|
83
32
|
*/
|
|
84
|
-
function makeScheduledPullAction(deps) {
|
|
85
|
-
return {
|
|
86
|
-
name: action_names_1.ACTIONS.sync.scheduledPull,
|
|
87
|
-
parseInput(raw, meta) {
|
|
88
|
-
return { dataFlowId: parseDataFlowId(raw, meta) };
|
|
89
|
-
},
|
|
90
|
-
async handler(input, ctx) {
|
|
91
|
-
const integrationType = deps.adapter.integrationType;
|
|
92
|
-
const lookupStrategy = (0, helpers_2.resolveLookupStrategy)(deps.adapter);
|
|
93
|
-
const flow = await ctx.dataFlowService.getFlowById(input.dataFlowId);
|
|
94
|
-
if (!flow) {
|
|
95
|
-
throw new errors_1.ActionError('FLOW_NOT_FOUND', `Flow ${input.dataFlowId} not found`);
|
|
96
|
-
}
|
|
97
|
-
const sc = (0, data_flow_spec_interface_1.asSyncConfig)(flow.triggerConfig);
|
|
98
|
-
if (!sc || sc.strategy !== data_flow_spec_interface_1.SyncStrategy.SCHEDULED) {
|
|
99
|
-
throw new errors_1.ActionError('UNSUPPORTED_STRATEGY', 'scheduledPull action requires strategy=scheduled');
|
|
100
|
-
}
|
|
101
|
-
const runner = new sync_runner_1.SyncRunner(deps.registry);
|
|
102
|
-
const startedAt = Date.now();
|
|
103
|
-
try {
|
|
104
|
-
const stats = await runner.run({
|
|
105
|
-
flowId: flow.id,
|
|
106
|
-
since: null,
|
|
107
|
-
sourceSystem: integrationType,
|
|
108
|
-
targetSystem: constants_1.SKEDULO_SYSTEM,
|
|
109
|
-
options: { lookupStrategy },
|
|
110
|
-
}, ctx);
|
|
111
|
-
const durationMs = Date.now() - startedAt;
|
|
112
|
-
ctx.logger.info(`[scheduled-pull] flow=${flow.id} ${flow.sourceObject}→${flow.targetObject} ` +
|
|
113
|
-
`${JSON.stringify(stats)} took=${durationMs}ms`);
|
|
114
|
-
return Object.assign(Object.assign({}, stats), { durationMs, flowId: flow.id });
|
|
115
|
-
}
|
|
116
|
-
catch (err) {
|
|
117
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
118
|
-
ctx.logger.error(`[scheduled-pull] flow=${flow.id} failed: ${msg}`);
|
|
119
|
-
return { flowId: flow.id, error: msg };
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
33
|
function makeRunFlowAction(deps) {
|
|
125
34
|
return {
|
|
126
35
|
name: action_names_1.ACTIONS.sync.runFlow,
|
|
127
36
|
parseInput(raw) {
|
|
128
|
-
|
|
37
|
+
const obj = (raw !== null && raw !== void 0 ? raw : {});
|
|
38
|
+
const input = { flowId: parsePositiveInt(raw, 'flowId') };
|
|
39
|
+
// fullResync takes precedence over since when both are supplied.
|
|
40
|
+
if (obj.fullResync === true) {
|
|
41
|
+
input.fullResync = true;
|
|
42
|
+
}
|
|
43
|
+
else if (obj.since !== undefined) {
|
|
44
|
+
input.since = parseSinceDate(obj.since);
|
|
45
|
+
}
|
|
46
|
+
return input;
|
|
129
47
|
},
|
|
130
48
|
async handler(input, ctx) {
|
|
131
49
|
var _a, _b;
|
|
@@ -139,10 +57,18 @@ function makeRunFlowAction(deps) {
|
|
|
139
57
|
if (!flow) {
|
|
140
58
|
throw new errors_1.ActionError('FLOW_NOT_FOUND', `Flow ${input.flowId} not found`);
|
|
141
59
|
}
|
|
142
|
-
|
|
60
|
+
// overrideSince: undefined = normal resume, null = full resync, Date = backfill from time.
|
|
61
|
+
const overrideSince = input.fullResync ? null : input.since;
|
|
62
|
+
ctx.logger.info(`[run-flow] flowId=${input.flowId} runId=${runId} starting` +
|
|
63
|
+
(overrideSince === null
|
|
64
|
+
? ' (full resync)'
|
|
65
|
+
: overrideSince
|
|
66
|
+
? ` (backfill since ${overrideSince.toISOString()})`
|
|
67
|
+
: ''));
|
|
143
68
|
const stats = await new sync_runner_1.SyncRunner(deps.registry).run({
|
|
144
69
|
flowId: input.flowId,
|
|
145
70
|
since: null,
|
|
71
|
+
overrideSince,
|
|
146
72
|
sourceSystem: (_a = flow.sourceSystem) !== null && _a !== void 0 ? _a : integrationType,
|
|
147
73
|
targetSystem: (_b = flow.targetSystem) !== null && _b !== void 0 ? _b : constants_1.SKEDULO_SYSTEM,
|
|
148
74
|
options: { lookupStrategy },
|
|
@@ -152,63 +78,4 @@ function makeRunFlowAction(deps) {
|
|
|
152
78
|
},
|
|
153
79
|
};
|
|
154
80
|
}
|
|
155
|
-
function makeRunAllFlowsAction(deps) {
|
|
156
|
-
return {
|
|
157
|
-
name: action_names_1.ACTIONS.sync.runAllFlows,
|
|
158
|
-
parseInput() {
|
|
159
|
-
return undefined;
|
|
160
|
-
},
|
|
161
|
-
async handler(_input, ctx) {
|
|
162
|
-
var _a, _b, _c, _d;
|
|
163
|
-
if (!(0, helpers_1.isAdminRequest)(ctx.skedContext)) {
|
|
164
|
-
throw new errors_1.ActionError('FORBIDDEN', 'runAllFlows requires admin privileges');
|
|
165
|
-
}
|
|
166
|
-
const integrationType = deps.adapter.integrationType;
|
|
167
|
-
const lookupStrategy = (0, helpers_2.resolveLookupStrategy)(deps.adapter);
|
|
168
|
-
const flows = await ctx.dataFlowService.listActive({ integrationType });
|
|
169
|
-
if (flows.length === 0) {
|
|
170
|
-
throw new errors_1.ActionError('NO_ACTIVE_FLOWS', `No active data flows found for ${integrationType}. Create flows first.`);
|
|
171
|
-
}
|
|
172
|
-
ctx.logger.info(`[run-all-flows] found ${flows.length} active flow(s): ` +
|
|
173
|
-
flows.map((f) => `${f.sourceObject}→${f.targetObject}`).join(', '));
|
|
174
|
-
const sorted = [...flows].sort((a, b) => { var _a, _b; return ((_a = a.executionOrder) !== null && _a !== void 0 ? _a : Infinity) - ((_b = b.executionOrder) !== null && _b !== void 0 ? _b : Infinity); });
|
|
175
|
-
const runner = new sync_runner_1.SyncRunner(deps.registry);
|
|
176
|
-
const results = {};
|
|
177
|
-
for (const flow of sorted) {
|
|
178
|
-
const startedAt = Date.now();
|
|
179
|
-
const base = {
|
|
180
|
-
flowId: flow.id,
|
|
181
|
-
sourceObject: flow.sourceObject,
|
|
182
|
-
targetObject: flow.targetObject,
|
|
183
|
-
};
|
|
184
|
-
try {
|
|
185
|
-
if (!((_b = (_a = flow.mappingConfig) === null || _a === void 0 ? void 0 : _a.mappings) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
186
|
-
ctx.logger.warn(`[run-all-flows] skipping flow ${flow.id} (${flow.sourceObject}) — no mappingConfig`);
|
|
187
|
-
results[String(flow.id)] = Object.assign(Object.assign({}, base), { skipped: true, reason: 'no mappingConfig' });
|
|
188
|
-
continue;
|
|
189
|
-
}
|
|
190
|
-
await ctx.dataFlowService.updateCursor(flow.id, null);
|
|
191
|
-
ctx.logger.info(`[run-all-flows] syncing ${flow.sourceObject} → ${flow.targetObject}`);
|
|
192
|
-
const stats = await runner.run({
|
|
193
|
-
flowId: flow.id,
|
|
194
|
-
since: null,
|
|
195
|
-
sourceSystem: (_c = flow.sourceSystem) !== null && _c !== void 0 ? _c : integrationType,
|
|
196
|
-
targetSystem: (_d = flow.targetSystem) !== null && _d !== void 0 ? _d : constants_1.SKEDULO_SYSTEM,
|
|
197
|
-
options: { lookupStrategy },
|
|
198
|
-
}, ctx);
|
|
199
|
-
const durationMs = Date.now() - startedAt;
|
|
200
|
-
ctx.logger.info(`[run-all-flows] flow=${flow.id} ${flow.sourceObject}→${flow.targetObject} ` +
|
|
201
|
-
`${JSON.stringify(stats)} took=${durationMs}ms`);
|
|
202
|
-
results[String(flow.id)] = Object.assign(Object.assign({}, base), stats);
|
|
203
|
-
}
|
|
204
|
-
catch (err) {
|
|
205
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
206
|
-
ctx.logger.error(`[run-all-flows] flow=${flow.id} failed: ${msg}`);
|
|
207
|
-
results[String(flow.id)] = Object.assign(Object.assign({}, base), { error: msg });
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return { message: 'All flows completed', results };
|
|
211
|
-
},
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
81
|
//# sourceMappingURL=sync.action.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.action.js","sourceRoot":"","sources":["../../src/actions/sync.action.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"sync.action.js","sourceRoot":"","sources":["../../src/actions/sync.action.ts"],"names":[],"mappings":";;AAiDA,8CAoDC;AArGD,mCAAoC;AAIpC,4CAA8C;AAC9C,yDAAqD;AACrD,8CAAkD;AAClD,uDAA+C;AAC/C,6CAAwD;AACxD,2CAAgE;AAKhE,SAAS,gBAAgB,CAAC,GAAY,EAAE,KAAa;IACnD,MAAM,GAAG,GAAG,CAAC,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,EAAE,CAA4B,CAAC;IACnD,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;IACrB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAK,CAAY,IAAI,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,0BAAiB,CAAC,GAAG,KAAK,6BAA6B,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,CAAW,CAAC;AACrB,CAAC;AAaD,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CA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,EAAG;QACnD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -5,10 +5,18 @@
|
|
|
5
5
|
export declare const ACTION_HEADER = "sked-integration-action";
|
|
6
6
|
/**
|
|
7
7
|
* HTTP header carrying the target flow id for per-flow actions. ElasticServer
|
|
8
|
-
* scheduled webhooks post an empty body
|
|
9
|
-
* the
|
|
8
|
+
* scheduled webhooks post an empty body (and triggered actions a bare array),
|
|
9
|
+
* so the flow id rides on this header; the dispatcher passes it to `parseInput`
|
|
10
|
+
* as `meta.dataFlowId`.
|
|
10
11
|
*/
|
|
11
12
|
export declare const DATA_FLOW_ID_HEADER = "sked-data-flow-id";
|
|
13
|
+
/**
|
|
14
|
+
* HTTP header carrying the target scheduled job's `webhook_name`. The ES
|
|
15
|
+
* scheduled webhook provisioned for a job posts an empty body, so the job
|
|
16
|
+
* identity rides on this header; the dispatcher passes it to `parseInput` as
|
|
17
|
+
* `meta.scheduledJobName`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const SCHEDULED_JOB_NAME_HEADER = "sked-scheduled-job-name";
|
|
12
20
|
/**
|
|
13
21
|
* Wire-format action names, grouped by domain. Use these instead of hardcoded
|
|
14
22
|
* strings on both sides of the dispatcher (SDK + UI / cross-function clients).
|
|
@@ -29,10 +37,15 @@ export declare const ACTIONS: Readonly<{
|
|
|
29
37
|
getSampleRecords: "metadata.get-sample-records";
|
|
30
38
|
}>;
|
|
31
39
|
readonly sync: Readonly<{
|
|
32
|
-
push: "sync.push";
|
|
33
|
-
scheduledPull: "sync.scheduled-pull";
|
|
34
40
|
runFlow: "sync.run-flow";
|
|
35
|
-
|
|
41
|
+
runJob: "sync.run-job";
|
|
42
|
+
}>;
|
|
43
|
+
readonly scheduledJob: Readonly<{
|
|
44
|
+
create: "scheduled-job.create";
|
|
45
|
+
update: "scheduled-job.update";
|
|
46
|
+
delete: "scheduled-job.delete";
|
|
47
|
+
list: "scheduled-job.list";
|
|
48
|
+
get: "scheduled-job.get";
|
|
36
49
|
}>;
|
|
37
50
|
readonly event: Readonly<{
|
|
38
51
|
onSkedulo: "event.on-skedulo";
|
|
@@ -48,5 +61,5 @@ export declare const ACTIONS: Readonly<{
|
|
|
48
61
|
list: "data-flow.list";
|
|
49
62
|
}>;
|
|
50
63
|
}>;
|
|
51
|
-
export type ActionName = typeof ACTIONS.capabilities | (typeof ACTIONS.setup)[keyof typeof ACTIONS.setup] | (typeof ACTIONS.metadata)[keyof typeof ACTIONS.metadata] | (typeof ACTIONS.sync)[keyof typeof ACTIONS.sync] | (typeof ACTIONS.event)[keyof typeof ACTIONS.event] | (typeof ACTIONS.dataFlow)[keyof typeof ACTIONS.dataFlow];
|
|
64
|
+
export type ActionName = typeof ACTIONS.capabilities | (typeof ACTIONS.setup)[keyof typeof ACTIONS.setup] | (typeof ACTIONS.metadata)[keyof typeof ACTIONS.metadata] | (typeof ACTIONS.sync)[keyof typeof ACTIONS.sync] | (typeof ACTIONS.scheduledJob)[keyof typeof ACTIONS.scheduledJob] | (typeof ACTIONS.event)[keyof typeof ACTIONS.event] | (typeof ACTIONS.dataFlow)[keyof typeof ACTIONS.dataFlow];
|
|
52
65
|
//# sourceMappingURL=action-names.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-names.d.ts","sourceRoot":"","sources":["../../../src/actions/utils/action-names.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,aAAa,4BAA4B,CAAC;AAEvD
|
|
1
|
+
{"version":3,"file":"action-names.d.ts","sourceRoot":"","sources":["../../../src/actions/utils/action-names.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,aAAa,4BAA4B,CAAC;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAEvD;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,4BAA4B,CAAC;AAEnE;;;;;GAKG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqCT,CAAC;AAEZ,MAAM,MAAM,UAAU,GAClB,OAAO,OAAO,CAAC,YAAY,GAC3B,CAAC,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,KAAK,CAAC,GAClD,CAAC,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,QAAQ,CAAC,GACxD,CAAC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,IAAI,CAAC,GAChD,CAAC,OAAO,OAAO,CAAC,YAAY,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,YAAY,CAAC,GAChE,CAAC,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,KAAK,CAAC,GAClD,CAAC,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ACTIONS = exports.DATA_FLOW_ID_HEADER = exports.ACTION_HEADER = void 0;
|
|
3
|
+
exports.ACTIONS = exports.SCHEDULED_JOB_NAME_HEADER = exports.DATA_FLOW_ID_HEADER = exports.ACTION_HEADER = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* HTTP header that carries the action name to the dispatcher.
|
|
6
6
|
* Exported so consumers (UI, cross-function clients) don't hardcode it.
|
|
@@ -8,10 +8,18 @@ exports.ACTIONS = exports.DATA_FLOW_ID_HEADER = exports.ACTION_HEADER = void 0;
|
|
|
8
8
|
exports.ACTION_HEADER = 'sked-integration-action';
|
|
9
9
|
/**
|
|
10
10
|
* HTTP header carrying the target flow id for per-flow actions. ElasticServer
|
|
11
|
-
* scheduled webhooks post an empty body
|
|
12
|
-
* the
|
|
11
|
+
* scheduled webhooks post an empty body (and triggered actions a bare array),
|
|
12
|
+
* so the flow id rides on this header; the dispatcher passes it to `parseInput`
|
|
13
|
+
* as `meta.dataFlowId`.
|
|
13
14
|
*/
|
|
14
15
|
exports.DATA_FLOW_ID_HEADER = 'sked-data-flow-id';
|
|
16
|
+
/**
|
|
17
|
+
* HTTP header carrying the target scheduled job's `webhook_name`. The ES
|
|
18
|
+
* scheduled webhook provisioned for a job posts an empty body, so the job
|
|
19
|
+
* identity rides on this header; the dispatcher passes it to `parseInput` as
|
|
20
|
+
* `meta.scheduledJobName`.
|
|
21
|
+
*/
|
|
22
|
+
exports.SCHEDULED_JOB_NAME_HEADER = 'sked-scheduled-job-name';
|
|
15
23
|
/**
|
|
16
24
|
* Wire-format action names, grouped by domain. Use these instead of hardcoded
|
|
17
25
|
* strings on both sides of the dispatcher (SDK + UI / cross-function clients).
|
|
@@ -32,10 +40,15 @@ exports.ACTIONS = Object.freeze({
|
|
|
32
40
|
getSampleRecords: 'metadata.get-sample-records',
|
|
33
41
|
}),
|
|
34
42
|
sync: Object.freeze({
|
|
35
|
-
push: 'sync.push',
|
|
36
|
-
scheduledPull: 'sync.scheduled-pull',
|
|
37
43
|
runFlow: 'sync.run-flow',
|
|
38
|
-
|
|
44
|
+
runJob: 'sync.run-job',
|
|
45
|
+
}),
|
|
46
|
+
scheduledJob: Object.freeze({
|
|
47
|
+
create: 'scheduled-job.create',
|
|
48
|
+
update: 'scheduled-job.update',
|
|
49
|
+
delete: 'scheduled-job.delete',
|
|
50
|
+
list: 'scheduled-job.list',
|
|
51
|
+
get: 'scheduled-job.get',
|
|
39
52
|
}),
|
|
40
53
|
event: Object.freeze({
|
|
41
54
|
onSkedulo: 'event.on-skedulo',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-names.js","sourceRoot":"","sources":["../../../src/actions/utils/action-names.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACU,QAAA,aAAa,GAAG,yBAAyB,CAAC;AAEvD
|
|
1
|
+
{"version":3,"file":"action-names.js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AgB;KACvB,CAAC;CACM,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { IntegrationContext } from '../../context';
|
|
2
|
+
import { type Middleware } from './middleware';
|
|
3
|
+
import type { Action, ParseMeta } from './types';
|
|
4
|
+
export interface DefineActionOpts<I, O> {
|
|
5
|
+
name: string;
|
|
6
|
+
parseInput: (raw: unknown, meta?: ParseMeta) => I;
|
|
7
|
+
handler: (input: I, ctx: IntegrationContext) => Promise<O>;
|
|
8
|
+
/**
|
|
9
|
+
* Whether the action is safe to retry without side-effect duplication.
|
|
10
|
+
* Echoed via the error envelope (for failures) and surfaced as metadata to
|
|
11
|
+
* the dispatcher. Mutating actions without an idempotency key should be `false`.
|
|
12
|
+
*/
|
|
13
|
+
idempotent?: boolean;
|
|
14
|
+
/** Emit an audit log on success. Set `true` for mutating actions. */
|
|
15
|
+
audit?: boolean;
|
|
16
|
+
/** Gate the handler on admin privileges before running the rest of the chain. */
|
|
17
|
+
requireAdmin?: boolean;
|
|
18
|
+
/** Extra middleware appended after the built-in stack (metrics, logging, audit). */
|
|
19
|
+
middleware?: ReadonlyArray<Middleware>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Build an `Action` with the standard cross-cutting concerns wired in.
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* defineAction({
|
|
26
|
+
* name: ACTIONS.scheduledJob.create,
|
|
27
|
+
* parseInput: parseCreate,
|
|
28
|
+
* requireAdmin: true,
|
|
29
|
+
* audit: true,
|
|
30
|
+
* idempotent: false,
|
|
31
|
+
* handler: async (input, ctx) => { ... },
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function defineAction<I, O>(opts: DefineActionOpts<I, O>): Action<I, O>;
|
|
36
|
+
//# sourceMappingURL=define-action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-action.d.ts","sourceRoot":"","sources":["../../../src/actions/utils/define-action.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAML,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEjD,MAAM,WAAW,gBAAgB,CAAC,CAAC,EAAE,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS,KAAK,CAAC,CAAC;IAClD,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,kBAAkB,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3D;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,qEAAqE;IACrE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,iFAAiF;IACjF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oFAAoF;IACpF,UAAU,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;CACxC;AAYD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAW7E"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defineAction = defineAction;
|
|
4
|
+
const middleware_1 = require("./middleware");
|
|
5
|
+
/**
|
|
6
|
+
* Stock middleware order (outermost → innermost):
|
|
7
|
+
* metrics → logging → audit → [requireAdmin?] → [extras...] → handler
|
|
8
|
+
*
|
|
9
|
+
* Metrics outermost so failures still record counters. Logging just inside so
|
|
10
|
+
* the start/end log lines bracket business logic. Audit only fires on success,
|
|
11
|
+
* after the handler returns.
|
|
12
|
+
*/
|
|
13
|
+
const DEFAULT_MIDDLEWARE = [middleware_1.withMetrics, middleware_1.withLogging, middleware_1.withAudit];
|
|
14
|
+
/**
|
|
15
|
+
* Build an `Action` with the standard cross-cutting concerns wired in.
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* defineAction({
|
|
19
|
+
* name: ACTIONS.scheduledJob.create,
|
|
20
|
+
* parseInput: parseCreate,
|
|
21
|
+
* requireAdmin: true,
|
|
22
|
+
* audit: true,
|
|
23
|
+
* idempotent: false,
|
|
24
|
+
* handler: async (input, ctx) => { ... },
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function defineAction(opts) {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
const meta = {
|
|
31
|
+
actionName: opts.name,
|
|
32
|
+
idempotent: (_a = opts.idempotent) !== null && _a !== void 0 ? _a : false,
|
|
33
|
+
audit: (_b = opts.audit) !== null && _b !== void 0 ? _b : false,
|
|
34
|
+
};
|
|
35
|
+
const stack = [...DEFAULT_MIDDLEWARE];
|
|
36
|
+
if (opts.requireAdmin)
|
|
37
|
+
stack.push(middleware_1.requireAdmin);
|
|
38
|
+
if (opts.middleware)
|
|
39
|
+
stack.push(...opts.middleware);
|
|
40
|
+
const composed = (0, middleware_1.compose)(stack, opts.handler, meta);
|
|
41
|
+
return { name: opts.name, parseInput: opts.parseInput, handler: composed };
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=define-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-action.js","sourceRoot":"","sources":["../../../src/actions/utils/define-action.ts"],"names":[],"mappings":";;AAqDA,oCAWC;AA/DD,6CAOsB;AAqBtB;;;;;;;GAOG;AACH,MAAM,kBAAkB,GAA8B,CAAC,wBAAW,EAAE,wBAAW,EAAE,sBAAS,CAAC,CAAC;AAE5F;;;;;;;;;;;;;GAaG;AACH,SAAgB,YAAY,CAAO,IAA4B;;IAC7D,MAAM,IAAI,GAAG;QACX,UAAU,EAAE,IAAI,CAAC,IAAI;QACrB,UAAU,EAAE,MAAA,IAAI,CAAC,UAAU,mCAAI,KAAK;QACpC,KAAK,EAAE,MAAA,IAAI,CAAC,KAAK,mCAAI,KAAK;KAC3B,CAAC;IACF,MAAM,KAAK,GAAiB,CAAC,GAAG,kBAAkB,CAAC,CAAC;IACpD,IAAI,IAAI,CAAC,YAAY;QAAE,KAAK,CAAC,IAAI,CAAC,yBAAc,CAAC,CAAC;IAClD,IAAI,IAAI,CAAC,UAAU;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;IACpD,MAAM,QAAQ,GAAG,IAAA,oBAAO,EAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACpD,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC7E,CAAC"}
|