@skedulo/integration-sdk 0.8.1 → 0.9.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.
Files changed (75) hide show
  1. package/.claude/worktrees/agent-a16acadaf5412dffd/jest.config.js +12 -0
  2. package/.claude/worktrees/agent-a33c3e4636d488e49/jest.config.js +12 -0
  3. package/.claude/worktrees/agent-a5b1d2ffa4ceef4a6/jest.config.js +12 -0
  4. package/.claude/worktrees/agent-aa1db4c22eabbde8e/jest.config.js +12 -0
  5. package/.claude/worktrees/agent-ac197ae8c69d7061c/jest.config.js +12 -0
  6. package/CHANGELOG.md +19 -0
  7. package/dist/actions/data-flow/preview.action.d.ts.map +1 -1
  8. package/dist/actions/data-flow/preview.action.js +18 -3
  9. package/dist/actions/data-flow/preview.action.js.map +1 -1
  10. package/dist/actions/event/on-vendor.action.d.ts.map +1 -1
  11. package/dist/actions/event/on-vendor.action.js +32 -5
  12. package/dist/actions/event/on-vendor.action.js.map +1 -1
  13. package/dist/handlers/metadata.handler.d.ts +17 -0
  14. package/dist/handlers/metadata.handler.d.ts.map +1 -0
  15. package/dist/handlers/metadata.handler.js +50 -0
  16. package/dist/handlers/metadata.handler.js.map +1 -0
  17. package/dist/index.d.ts +2 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +5 -2
  20. package/dist/index.js.map +1 -1
  21. package/dist/interfaces/adapter.interface.d.ts +7 -3
  22. package/dist/interfaces/adapter.interface.d.ts.map +1 -1
  23. package/dist/services/field-mapping.service.d.ts +7 -0
  24. package/dist/services/field-mapping.service.d.ts.map +1 -1
  25. package/dist/services/field-mapping.service.js +16 -0
  26. package/dist/services/field-mapping.service.js.map +1 -1
  27. package/dist/services/sync-runner.d.ts +3 -4
  28. package/dist/services/sync-runner.d.ts.map +1 -1
  29. package/dist/services/sync-runner.js +53 -90
  30. package/dist/services/sync-runner.js.map +1 -1
  31. package/dist/services/sync.service.d.ts +10 -1
  32. package/dist/services/sync.service.d.ts.map +1 -1
  33. package/dist/services/sync.service.js +29 -3
  34. package/dist/services/sync.service.js.map +1 -1
  35. package/dist/utils/coerceFilterValues.d.ts +10 -0
  36. package/dist/utils/coerceFilterValues.d.ts.map +1 -0
  37. package/dist/utils/coerceFilterValues.js +51 -0
  38. package/dist/utils/coerceFilterValues.js.map +1 -0
  39. package/dist/utils/compileFilter.d.ts.map +1 -1
  40. package/dist/utils/compileFilter.js +40 -15
  41. package/dist/utils/compileFilter.js.map +1 -1
  42. package/dist/utils/normalizeDataFlow.d.ts +3 -0
  43. package/dist/utils/normalizeDataFlow.d.ts.map +1 -0
  44. package/dist/utils/normalizeDataFlow.js +37 -0
  45. package/dist/utils/normalizeDataFlow.js.map +1 -0
  46. package/dist/utils.d.ts +2 -0
  47. package/dist/utils.d.ts.map +1 -0
  48. package/dist/utils.js +10 -0
  49. package/dist/utils.js.map +1 -0
  50. package/package.json +1 -1
  51. package/yarn.lock +3 -3
  52. package/dist/actions/data-flow.action.d.ts +0 -62
  53. package/dist/actions/data-flow.action.d.ts.map +0 -1
  54. package/dist/actions/data-flow.action.js +0 -217
  55. package/dist/actions/data-flow.action.js.map +0 -1
  56. package/dist/actions/event.action.d.ts +0 -32
  57. package/dist/actions/event.action.d.ts.map +0 -1
  58. package/dist/actions/event.action.js +0 -113
  59. package/dist/actions/event.action.js.map +0 -1
  60. package/dist/actions/metadata.action.d.ts +0 -44
  61. package/dist/actions/metadata.action.d.ts.map +0 -1
  62. package/dist/actions/metadata.action.js +0 -96
  63. package/dist/actions/metadata.action.js.map +0 -1
  64. package/dist/actions/scheduled-job.action.d.ts +0 -73
  65. package/dist/actions/scheduled-job.action.d.ts.map +0 -1
  66. package/dist/actions/scheduled-job.action.js +0 -355
  67. package/dist/actions/scheduled-job.action.js.map +0 -1
  68. package/dist/actions/sync.action.d.ts +0 -26
  69. package/dist/actions/sync.action.d.ts.map +0 -1
  70. package/dist/actions/sync.action.js +0 -81
  71. package/dist/actions/sync.action.js.map +0 -1
  72. package/dist/services/artifact-builder.d.ts +0 -95
  73. package/dist/services/artifact-builder.d.ts.map +0 -1
  74. package/dist/services/artifact-builder.js +0 -142
  75. package/dist/services/artifact-builder.js.map +0 -1
@@ -1,81 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeRunFlowAction = makeRunFlowAction;
4
- const crypto_1 = require("crypto");
5
- const constants_1 = require("../constants");
6
- const sync_runner_1 = require("../services/sync-runner");
7
- const helpers_1 = require("../utils/helpers");
8
- const action_names_1 = require("./utils/action-names");
9
- const helpers_2 = require("./utils/helpers");
10
- const errors_1 = require("./utils/errors");
11
- function parsePositiveInt(raw, field) {
12
- const obj = (raw !== null && raw !== void 0 ? raw : {});
13
- const v = obj[field];
14
- if (!Number.isInteger(v) || v <= 0) {
15
- throw new errors_1.InvalidInputError(`${field} must be a positive integer`);
16
- }
17
- return v;
18
- }
19
- function parseSinceDate(value) {
20
- if (typeof value !== 'string') {
21
- throw new errors_1.InvalidInputError('since must be an ISO date-time string');
22
- }
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;
28
- }
29
- /**
30
- * Manually run a single flow. Admin-only. Supports a one-off backfill (`since`)
31
- * or full resync (`fullResync`) that overrides the persisted cursor.
32
- */
33
- function makeRunFlowAction(deps) {
34
- return {
35
- name: action_names_1.ACTIONS.sync.runFlow,
36
- parseInput(raw) {
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;
47
- },
48
- async handler(input, ctx) {
49
- var _a, _b;
50
- if (!(0, helpers_1.isAdminRequest)(ctx.skedContext)) {
51
- throw new errors_1.ActionError('FORBIDDEN', 'runFlow requires admin privileges');
52
- }
53
- const integrationType = deps.adapter.integrationType;
54
- const lookupStrategy = (0, helpers_2.resolveLookupStrategy)(deps.adapter);
55
- const runId = (0, crypto_1.randomUUID)();
56
- const flow = await ctx.dataFlowService.getFlowById(input.flowId);
57
- if (!flow) {
58
- throw new errors_1.ActionError('FLOW_NOT_FOUND', `Flow ${input.flowId} not found`);
59
- }
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
- : ''));
68
- const stats = await new sync_runner_1.SyncRunner(deps.registry).run({
69
- flowId: input.flowId,
70
- since: null,
71
- overrideSince,
72
- sourceSystem: (_a = flow.sourceSystem) !== null && _a !== void 0 ? _a : integrationType,
73
- targetSystem: (_b = flow.targetSystem) !== null && _b !== void 0 ? _b : constants_1.SKEDULO_SYSTEM,
74
- options: { lookupStrategy },
75
- }, ctx);
76
- ctx.logger.info(`[run-flow] done: ${JSON.stringify(stats)}`);
77
- return Object.assign({ runId, flowId: input.flowId }, stats);
78
- },
79
- };
80
- }
81
- //# sourceMappingURL=sync.action.js.map
@@ -1 +0,0 @@
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,IAA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AAI,CAAC,YAAY,mCAAI,0BAAc;gBACjD,OAAO,EAAE,EAAE,cAAc,EAAE;aAC5B,EACD,GAAG,CACJ,CAAC;YACF,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC7D,uBAAS,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,IAAK,KAAK,EAAG;QACnD,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,95 +0,0 @@
1
- import type { ArtifactClient } from '@skedulo/pulse-solution-services';
2
- import type { DataFlow } from '../interfaces/data-flow-spec.interface';
3
- import { ACTIONS } from '../actions/utils/action-names';
4
- /**
5
- * Deterministic artifact name used as the idempotency key for the
6
- * webhook / triggered action provisioned for a DataFlow.
7
- *
8
- * Format: `sked-int-${integrationType}-${sourceObject}-to-${targetObject}-flow${id}`
9
- * Throws if the result exceeds 100 chars (we don't truncate, since collisions
10
- * on the prefix would cause silent cross-flow overwrites).
11
- */
12
- export declare function buildArtifactName(flow: DataFlow, integrationType: string): string;
13
- /**
14
- * Convert `intervalMinutes` to a 5-field cron expression.
15
- * - n <= 1 → `* * * * *` (every minute)
16
- * - 1 < n < 60 → `*\/n * * * *`
17
- * - 60 <= n, multiples of 60 → `0 *\/h * * *` (every h hours)
18
- * - otherwise → fall back to `*\/n * * * *` (cron itself rejects > 59 in min field;
19
- * callers should pass a divisor of 60 for n >= 60)
20
- */
21
- export declare function intervalMinutesToCron(intervalMinutes: number): string;
22
- /**
23
- * GraphQL selection-set fragment for the triggered action's `action.query`.
24
- * ES executes this against the Skedulo schema and POSTs the result as the
25
- * function body, so it MUST include every Skedulo field the mapping reads.
26
- * `UID` is always included since we use it as the record identifier.
27
- */
28
- export declare function buildSkeduloQuery(flow: DataFlow): string;
29
- export interface BuildScheduledWebhookOpts {
30
- name: string;
31
- url: string;
32
- cron: string;
33
- /** Value placed on the dispatcher action header so the function knows which action to run. */
34
- action: typeof ACTIONS.sync.push | typeof ACTIONS.sync.scheduledPull;
35
- dataFlowId: number;
36
- }
37
- export declare function buildScheduledWebhookArtifact(opts: BuildScheduledWebhookOpts): {
38
- name: string;
39
- metadata: {
40
- type: string;
41
- };
42
- webhook: {
43
- type: string;
44
- url: string;
45
- cron: string;
46
- headers: {
47
- Authorization: string;
48
- "sked-integration-action": "sync.push" | "sync.scheduled-pull";
49
- 'sked-data-flow-id': string;
50
- };
51
- };
52
- };
53
- export interface BuildTriggeredActionOpts {
54
- name: string;
55
- url: string;
56
- /** Skedulo schema name to subscribe to (e.g. `"Jobs"`). */
57
- schemaName: string;
58
- /** GraphQL selection-set fragment, e.g. `"{ UID Name JobStatus }"`. */
59
- query: string;
60
- dataFlowId: number;
61
- }
62
- export declare function buildTriggeredActionArtifact(opts: BuildTriggeredActionOpts): {
63
- name: string;
64
- metadata: {
65
- type: string;
66
- };
67
- enabled: boolean;
68
- trigger: {
69
- type: string;
70
- schemaName: string;
71
- filter: string;
72
- };
73
- action: {
74
- type: string;
75
- url: string;
76
- headers: {
77
- Authorization: string;
78
- "sked-integration-action": "event.on-skedulo";
79
- 'sked-data-flow-id': string;
80
- };
81
- query: string;
82
- };
83
- };
84
- /**
85
- * Idempotent upsert: try `get` then `update`; on any error (including not-found)
86
- * fall back to `create`. The PSS artifact API is name-keyed, so this collapses
87
- * "create" and "replace" into a single safe call.
88
- */
89
- export declare function upsertArtifact(client: ArtifactClient, name: string, artifact: unknown): Promise<void>;
90
- /**
91
- * Delete by name, swallowing not-found errors so deactivate is idempotent.
92
- * The PSS client throws `Error("HTTP error! Status: 404. …")`; match on that.
93
- */
94
- export declare function deleteArtifactIfExists(client: ArtifactClient, name: string): Promise<void>;
95
- //# sourceMappingURL=artifact-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"artifact-builder.d.ts","sourceRoot":"","sources":["../../src/services/artifact-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MA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c,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOhG"}
@@ -1,142 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildArtifactName = buildArtifactName;
4
- exports.intervalMinutesToCron = intervalMinutesToCron;
5
- exports.buildSkeduloQuery = buildSkeduloQuery;
6
- exports.buildScheduledWebhookArtifact = buildScheduledWebhookArtifact;
7
- exports.buildTriggeredActionArtifact = buildTriggeredActionArtifact;
8
- exports.upsertArtifact = upsertArtifact;
9
- exports.deleteArtifactIfExists = deleteArtifactIfExists;
10
- const action_names_1 = require("../actions/utils/action-names");
11
- const MAX_NAME_LENGTH = 100;
12
- function slugify(value) {
13
- return value
14
- .toLowerCase()
15
- .replace(/[^a-z0-9]+/g, '-')
16
- .replace(/^-+|-+$/g, '');
17
- }
18
- /**
19
- * Deterministic artifact name used as the idempotency key for the
20
- * webhook / triggered action provisioned for a DataFlow.
21
- *
22
- * Format: `sked-int-${integrationType}-${sourceObject}-to-${targetObject}-flow${id}`
23
- * Throws if the result exceeds 100 chars (we don't truncate, since collisions
24
- * on the prefix would cause silent cross-flow overwrites).
25
- */
26
- function buildArtifactName(flow, integrationType) {
27
- if (!integrationType) {
28
- throw new Error('buildArtifactName requires an integrationType');
29
- }
30
- const name = `sked-int-${slugify(integrationType)}-${slugify(flow.sourceObject)}-to-${slugify(flow.targetObject)}-flow${flow.id}`;
31
- if (name.length > MAX_NAME_LENGTH) {
32
- throw new Error(`buildArtifactName produced a name of ${name.length} characters (max ${MAX_NAME_LENGTH}): "${name}"`);
33
- }
34
- return name;
35
- }
36
- /**
37
- * Convert `intervalMinutes` to a 5-field cron expression.
38
- * - n <= 1 → `* * * * *` (every minute)
39
- * - 1 < n < 60 → `*\/n * * * *`
40
- * - 60 <= n, multiples of 60 → `0 *\/h * * *` (every h hours)
41
- * - otherwise → fall back to `*\/n * * * *` (cron itself rejects > 59 in min field;
42
- * callers should pass a divisor of 60 for n >= 60)
43
- */
44
- function intervalMinutesToCron(intervalMinutes) {
45
- if (!Number.isInteger(intervalMinutes) || intervalMinutes <= 1)
46
- return '* * * * *';
47
- if (intervalMinutes < 60)
48
- return `*/${intervalMinutes} * * * *`;
49
- if (intervalMinutes % 60 === 0) {
50
- const hours = intervalMinutes / 60;
51
- return hours === 1 ? '0 * * * *' : `0 */${hours} * * *`;
52
- }
53
- return `*/${intervalMinutes} * * * *`;
54
- }
55
- /**
56
- * GraphQL selection-set fragment for the triggered action's `action.query`.
57
- * ES executes this against the Skedulo schema and POSTs the result as the
58
- * function body, so it MUST include every Skedulo field the mapping reads.
59
- * `UID` is always included since we use it as the record identifier.
60
- */
61
- function buildSkeduloQuery(flow) {
62
- var _a, _b, _c;
63
- const fields = new Set(['UID']);
64
- // IS does not return `sourceFields`; the Skedulo source fields are the
65
- // mapping expressions (mirrors skedulo.adapter fetch).
66
- const sourceFields = (_c = (_a = flow.sourceFields) !== null && _a !== void 0 ? _a : (_b = flow.mappingConfig) === null || _b === void 0 ? void 0 : _b.mappings.map((m) => m.expression)) !== null && _c !== void 0 ? _c : [];
67
- for (const f of sourceFields) {
68
- if (f && typeof f === 'string')
69
- fields.add(f);
70
- }
71
- return `{ ${Array.from(fields).join(' ')} }`;
72
- }
73
- // ── Artifact bodies ──────────────────────────────────────────────────────────
74
- const ADMIN_AUTH_HEADER = 'Bearer {{ INTEGRATION_ADMIN_TOKEN }}';
75
- function buildScheduledWebhookArtifact(opts) {
76
- return {
77
- name: opts.name,
78
- metadata: { type: 'Webhook' },
79
- webhook: {
80
- type: 'scheduled',
81
- url: opts.url,
82
- cron: opts.cron,
83
- headers: {
84
- Authorization: ADMIN_AUTH_HEADER,
85
- [action_names_1.ACTION_HEADER]: opts.action,
86
- 'sked-data-flow-id': String(opts.dataFlowId),
87
- },
88
- },
89
- };
90
- }
91
- function buildTriggeredActionArtifact(opts) {
92
- return {
93
- name: opts.name,
94
- metadata: { type: 'TriggeredAction' },
95
- enabled: true,
96
- trigger: {
97
- type: 'object_modified',
98
- schemaName: opts.schemaName,
99
- filter: "Operation == 'INSERT' OR Operation == 'UPDATE' OR Operation == 'DELETE'",
100
- },
101
- action: {
102
- type: 'call_url',
103
- url: opts.url,
104
- headers: {
105
- Authorization: ADMIN_AUTH_HEADER,
106
- [action_names_1.ACTION_HEADER]: action_names_1.ACTIONS.event.onSkedulo,
107
- 'sked-data-flow-id': String(opts.dataFlowId),
108
- },
109
- query: opts.query,
110
- },
111
- };
112
- }
113
- // ── Upsert / delete helpers ──────────────────────────────────────────────────
114
- /**
115
- * Idempotent upsert: try `get` then `update`; on any error (including not-found)
116
- * fall back to `create`. The PSS artifact API is name-keyed, so this collapses
117
- * "create" and "replace" into a single safe call.
118
- */
119
- async function upsertArtifact(client, name, artifact) {
120
- try {
121
- await client.get({ name });
122
- await client.update({ name }, artifact);
123
- }
124
- catch (_a) {
125
- await client.create({ name }, artifact);
126
- }
127
- }
128
- /**
129
- * Delete by name, swallowing not-found errors so deactivate is idempotent.
130
- * The PSS client throws `Error("HTTP error! Status: 404. …")`; match on that.
131
- */
132
- async function deleteArtifactIfExists(client, name) {
133
- try {
134
- await client.delete({ name });
135
- }
136
- catch (err) {
137
- if (err instanceof Error && /Status:\s*404\b/.test(err.message))
138
- return;
139
- throw err;
140
- }
141
- }
142
- //# sourceMappingURL=artifact-builder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"artifact-builder.js","sourceRoot":"","sources":["../../src/services/artifact-builder.ts"],"names":[],"mappings":";;AAqBA,8CAaC;AAUD,sDAQC;AAQD,8CAUC;AAeD,sEAeC;AAYD,oEAqBC;AASD,wCAWC;AAMD,wDAOC;AApKD,gEAAuE;AAEvE,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,SAAS,OAAO,CAAC,KAAa;IAC5B,OAAO,KAAK;SACT,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,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