@trayio/cdk-runtime 5.22.1-unstable → 5.23.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.
@@ -45,6 +45,10 @@ describe('CompositeOperationExecution polling lifecycle branch', () => {
45
45
  pollingInterval: { value: 15, unit: PollingTypes_1.PollingIntervalUnit.Minutes },
46
46
  maxFailureCount: 50,
47
47
  initialCursor: { since: 't0' },
48
+ operationInput: {
49
+ soqlQuery: 'SELECT Id, Name FROM Account',
50
+ objectType: 'Account',
51
+ },
48
52
  };
49
53
  const result = await execution.execute(fakePollingContext(), input);
50
54
  expect(result.isSuccess).toBe(true);
@@ -66,6 +70,10 @@ describe('CompositeOperationExecution polling lifecycle branch', () => {
66
70
  },
67
71
  maxFailureCount: 50,
68
72
  initialCursor: { since: 't0' },
73
+ operationInput: {
74
+ soqlQuery: 'SELECT Id, Name FROM Account',
75
+ objectType: 'Account',
76
+ },
69
77
  });
70
78
  expect(token).toBe('exec-jwt');
71
79
  });
@@ -101,12 +109,13 @@ describe('CompositeOperationExecution polling lifecycle branch', () => {
101
109
  expect(error).toMatch(/ctx\.executionToken/);
102
110
  expect(error).toMatch(/ctx\.publicUrl/);
103
111
  });
104
- it('fails register when the auth/org/workspace/project ctx fields are missing', async () => {
112
+ it('fails register when org/workspace/project ctx fields are missing (auth is optional)', async () => {
105
113
  const { client, registerCalls } = createFakePollingServiceClient();
106
114
  const handler = new CompositeOperationHandler_1.CompositeOperationHandler(jest.fn());
107
115
  const execution = new CompositeOperationExecution_1.CompositeOperationExecution(noopHandlerInvocationFactory, handler, OperationHandler_1.OperationHandlerType.TriggerPollCreate, 'new_records', client);
108
116
  // Base polling ctx is present, but the identity fields the PS register
109
- // payload requires are not.
117
+ // payload requires are not. `ctx.auth.authId` is intentionally omitted
118
+ // to cover the "no auth" case.
110
119
  const incompleteCtx = {
111
120
  connectorName: 'x',
112
121
  connectorVersion: '1',
@@ -117,7 +126,7 @@ describe('CompositeOperationExecution polling lifecycle branch', () => {
117
126
  expect(registerCalls).toHaveLength(0);
118
127
  expect(result.isFailure).toBe(true);
119
128
  const error = result._tag === 'Failure' ? result.error.message : '';
120
- expect(error).toMatch(/ctx\.auth\.authId/);
129
+ expect(error).not.toMatch(/ctx\.auth\.authId/);
121
130
  expect(error).toMatch(/ctx\.organizationId/);
122
131
  expect(error).toMatch(/ctx\.workspaceId/);
123
132
  expect(error).toMatch(/ctx\.projectId/);
@@ -1 +1 @@
1
- {"version":3,"file":"CompositeOperationExecutionPolling.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/CompositeOperationExecutionPolling.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oBAAoB,EACpB,uBAAuB,EAEvB,sBAAsB,EAEtB,oBAAoB,EAEpB,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,+DAA+D,CAAC;AAC1G,OAAO,EAAE,mBAAmB,EAAE,MAAM,kDAAkD,CAAC;AAEvF,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,MAAM,MAAM,6BAA6B,GAAG,mBAAmB,GAAG;IACjE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAuEF,eAAO,MAAM,kBAAkB,gBACjB,oBAAoB,KAC/B,OAEqD,CAAC;AAoCzD;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACxC,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EACnD,EAAE,EACF,GAAG,EACF,IAAI,EAAE;IACP,GAAG,EAAE,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACnC,KAAK,EAAE,EAAE,CAAC;IACV,OAAO,EAAE,yBAAyB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;IAClD,wBAAwB,EAAE,iCAAiC,CAAC;IAC5D,yBAAyB,EAAE,CAAC,CAAC,EAAE,sBAAsB,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;IACpE,cAAc,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,sBAAsB,CAAC,GAAG,CAAC,CAAC;CAC5D,GAAG,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAiCvC;AAED,wBAAgB,8BAA8B,CAC7C,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EAClD,IAAI,EAAE;IACP,GAAG,EAAE,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACnC,WAAW,EACR,oBAAoB,CAAC,iBAAiB,GACtC,oBAAoB,CAAC,kBAAkB,CAAC;IAC3C,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,6BAA6B,CAAC;IAC5C,oBAAoB,EAAE,oBAAoB,CAAC;CAC3C,GAAG,OAAO,CAAC,IAAI,CAAC,CAiDhB"}
1
+ {"version":3,"file":"CompositeOperationExecutionPolling.d.ts","sourceRoot":"","sources":["../../../src/connector/operation/CompositeOperationExecutionPolling.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oBAAoB,EACpB,uBAAuB,EAEvB,sBAAsB,EAEtB,oBAAoB,EAEpB,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,+DAA+D,CAAC;AAC1G,OAAO,EAAE,mBAAmB,EAAE,MAAM,kDAAkD,CAAC;AAEvF,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF,MAAM,MAAM,6BAA6B,GAAG,mBAAmB,GAAG;IACjE,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAsEF,eAAO,MAAM,kBAAkB,gBACjB,oBAAoB,KAC/B,OAEqD,CAAC;AAoCzD;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACxC,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EACnD,EAAE,EACF,GAAG,EACF,IAAI,EAAE;IACP,GAAG,EAAE,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACnC,KAAK,EAAE,EAAE,CAAC;IACV,OAAO,EAAE,yBAAyB,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;IAClD,wBAAwB,EAAE,iCAAiC,CAAC;IAC5D,yBAAyB,EAAE,CAAC,CAAC,EAAE,sBAAsB,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC;IACpE,cAAc,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,sBAAsB,CAAC,GAAG,CAAC,CAAC;CAC5D,GAAG,OAAO,CAAC,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAiCvC;AAED,wBAAgB,8BAA8B,CAC7C,IAAI,SAAS,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC,EAClD,IAAI,EAAE;IACP,GAAG,EAAE,uBAAuB,CAAC,IAAI,CAAC,CAAC;IACnC,WAAW,EACR,oBAAoB,CAAC,iBAAiB,GACtC,oBAAoB,CAAC,kBAAkB,CAAC;IAC3C,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,6BAA6B,CAAC;IAC5C,oBAAoB,EAAE,oBAAoB,CAAC;CAC3C,GAAG,OAAO,CAAC,IAAI,CAAC,CAkDhB"}
@@ -25,8 +25,6 @@ const requirePollingCtxFields = (ctx) => {
25
25
  const requirePollingRegisterCtxFields = (ctx) => {
26
26
  const base = requirePollingCtxFields(ctx);
27
27
  const missing = [];
28
- if (!ctx.auth?.authId)
29
- missing.push('ctx.auth.authId');
30
28
  if (!ctx.organizationId)
31
29
  missing.push('ctx.organizationId');
32
30
  if (!ctx.workspaceId)
@@ -38,7 +36,7 @@ const requirePollingRegisterCtxFields = (ctx) => {
38
36
  }
39
37
  return {
40
38
  ...base,
41
- authenticationId: ctx.auth.authId,
39
+ authenticationId: ctx.auth?.authId ?? null,
42
40
  organizationId: ctx.organizationId,
43
41
  workspaceId: ctx.workspaceId,
44
42
  projectId: ctx.projectId,
@@ -123,6 +121,7 @@ function runPollingRegisterOrDeregister(args) {
123
121
  pollingInterval: pollingInput.pollingInterval,
124
122
  maxFailureCount: pollingInput.maxFailureCount,
125
123
  initialCursor: pollingInput.initialCursor,
124
+ operationInput: pollingInput.operationInput,
126
125
  }, registerCtx.executionToken);
127
126
  }
128
127
  case OperationHandler_1.OperationHandlerType.TriggerPollDestroy: {
@@ -4,7 +4,7 @@ export type PollingServiceRegisterPayload = {
4
4
  connectorName: string;
5
5
  connectorVersion: string;
6
6
  registeredHandlerName: string;
7
- authenticationId: string;
7
+ authenticationId: string | null;
8
8
  organizationId: string;
9
9
  workspaceId: string;
10
10
  projectId: string;
@@ -12,6 +12,13 @@ export type PollingServiceRegisterPayload = {
12
12
  pollingInterval?: PollingInterval;
13
13
  maxFailureCount?: number;
14
14
  initialCursor?: string | null;
15
+ /**
16
+ * Connector-defined operation input (opaque to the platform). The
17
+ * Polling Service persists this against the subscription and replays it
18
+ * to the connector on every poll tick so the poll handler has the
19
+ * configuration it needs (e.g. the SOQL query for a Salesforce poll).
20
+ */
21
+ operationInput: unknown;
15
22
  };
16
23
  export type PollingServiceDeregisterPayload = {
17
24
  connectorName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"PollingServiceClient.d.ts","sourceRoot":"","sources":["../../../src/connector/polling/PollingServiceClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,OAAO,EAGN,eAAe,EAEf,MAAM,kDAAkD,CAAC;AAuB1D,MAAM,MAAM,6BAA6B,GAAG;IAC3C,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,cAAc,EAAE,OAAO,CAAC;CACxB,CAAC;AA4BF;;;;GAIG;AACH,qBAAa,oBAAoB;IACpB,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAEpC,QAAQ,CACb,OAAO,EAAE,6BAA6B,EACtC,cAAc,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC;IAwBV,UAAU,CACf,OAAO,EAAE,+BAA+B,EACxC,cAAc,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC;YAaF,QAAQ;CAgCtB"}
1
+ {"version":3,"file":"PollingServiceClient.d.ts","sourceRoot":"","sources":["../../../src/connector/polling/PollingServiceClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,OAAO,EAGN,eAAe,EAEf,MAAM,kDAAkD,CAAC;AAuB1D,MAAM,MAAM,6BAA6B,GAAG;IAC3C,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;;;OAKG;IACH,cAAc,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,cAAc,EAAE,OAAO,CAAC;CACxB,CAAC;AA4BF;;;;GAIG;AACH,qBAAa,oBAAoB;IACpB,OAAO,CAAC,UAAU;gBAAV,UAAU,EAAE,UAAU;IAEpC,QAAQ,CACb,OAAO,EAAE,6BAA6B,EACtC,cAAc,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC;IAyBV,UAAU,CACf,OAAO,EAAE,+BAA+B,EACxC,cAAc,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC;YAaF,QAAQ;CAgCtB"}
@@ -87,6 +87,7 @@ class PollingServiceClient {
87
87
  interval: intervalMinutes,
88
88
  maxFailureCount,
89
89
  initialCursor: payload.initialCursor ?? null,
90
+ operationInput: payload.operationInput ?? null,
90
91
  };
91
92
  await this.sendJson(Http_1.HttpMethod.Post, executionToken, body);
92
93
  }
@@ -60,6 +60,7 @@ const minimalRegister = (overrides = {}) => ({
60
60
  workspaceId: 'ws-id',
61
61
  projectId: 'project-uuid',
62
62
  publicUrl: 'u',
63
+ operationInput: {},
63
64
  ...overrides,
64
65
  });
65
66
  describe('PollingServiceClient', () => {
@@ -95,6 +96,10 @@ describe('PollingServiceClient', () => {
95
96
  },
96
97
  maxFailureCount: 42,
97
98
  initialCursor: 'cursor-0',
99
+ operationInput: {
100
+ soqlQuery: 'SELECT Id, Name FROM Account',
101
+ objectType: 'Account',
102
+ },
98
103
  }, 'exec-jwt-token');
99
104
  expect(captured).toHaveLength(1);
100
105
  const call = captured[0];
@@ -116,6 +121,10 @@ describe('PollingServiceClient', () => {
116
121
  interval: 10,
117
122
  maxFailureCount: 42,
118
123
  initialCursor: 'cursor-0',
124
+ operationInput: {
125
+ soqlQuery: 'SELECT Id, Name FROM Account',
126
+ objectType: 'Account',
127
+ },
119
128
  });
120
129
  });
121
130
  it('sends interval in minutes for PollingIntervalUnit.Minutes', async () => {
@@ -147,6 +156,32 @@ describe('PollingServiceClient', () => {
147
156
  initialCursor: null,
148
157
  });
149
158
  });
159
+ it('forwards operationInput verbatim to the PS register body', async () => {
160
+ const captured = [];
161
+ const client = new PollingServiceClient_1.PollingServiceClient(createMockHttpClient(captured));
162
+ const operationInput = {
163
+ soqlQuery: "SELECT Id FROM Account WHERE Name = 'Acme'",
164
+ nested: { folderId: 'fld_1', tags: ['a', 'b'] },
165
+ };
166
+ await client.register(minimalRegister({ operationInput }), 'tok');
167
+ const body = captured[0].body;
168
+ expect(body).toHaveProperty('operationInput');
169
+ expect(body.operationInput).toEqual(operationInput);
170
+ });
171
+ it('coerces an undefined operationInput to `null` on the wire so the key is always present', async () => {
172
+ const captured = [];
173
+ const client = new PollingServiceClient_1.PollingServiceClient(createMockHttpClient(captured));
174
+ await client.register(minimalRegister({ operationInput: undefined }), 'tok');
175
+ const body = captured[0].body;
176
+ expect(body).toHaveProperty('operationInput', null);
177
+ });
178
+ it('sends authenticationId as null on the wire when caller passes null', async () => {
179
+ const captured = [];
180
+ const client = new PollingServiceClient_1.PollingServiceClient(createMockHttpClient(captured));
181
+ await client.register(minimalRegister({ authenticationId: null }), 'tok');
182
+ const body = captured[0].body;
183
+ expect(body).toHaveProperty('authenticationId', null);
184
+ });
150
185
  it('trims trailing slashes from the PS base URL', async () => {
151
186
  process.env[ENV_VAR] = `${BASE_URL}/`;
152
187
  const captured = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/cdk-runtime",
3
- "version": "5.22.1-unstable",
3
+ "version": "5.23.0",
4
4
  "description": "A Runtime that executes connector operations defined using the CDK DSL",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js"
@@ -14,10 +14,10 @@
14
14
  "node": ">=18.x"
15
15
  },
16
16
  "dependencies": {
17
- "@trayio/axios": "5.22.1-unstable",
18
- "@trayio/cdk-dsl": "5.22.1-unstable",
19
- "@trayio/express": "5.22.1-unstable",
20
- "@trayio/winston": "5.22.1-unstable",
17
+ "@trayio/axios": "5.23.0",
18
+ "@trayio/cdk-dsl": "5.23.0",
19
+ "@trayio/express": "5.23.0",
20
+ "@trayio/winston": "5.23.0",
21
21
  "mime": "3.0.0",
22
22
  "uuid": "9.0.0"
23
23
  },
@@ -34,6 +34,5 @@
34
34
  ],
35
35
  "devDependencies": {
36
36
  "just-permutations": "^2.2.1"
37
- },
38
- "stableVersion": "0.0.0"
37
+ }
39
38
  }