@trayio/cdk-runtime 5.25.0 → 5.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connector/operation/CompositeOperationExecution.unit.test.js +15 -12
- package/dist/connector/operation/CompositeOperationExecutionPolling.d.ts.map +1 -1
- package/dist/connector/operation/CompositeOperationExecutionPolling.js +3 -13
- package/dist/connector/polling/PollingServiceClient.d.ts +3 -3
- package/dist/connector/polling/PollingServiceClient.d.ts.map +1 -1
- package/dist/connector/polling/PollingServiceClient.js +13 -3
- package/dist/connector/polling/PollingServiceClient.unit.test.js +13 -0
- package/package.json +5 -5
|
@@ -111,26 +111,29 @@ describe('CompositeOperationExecution polling lifecycle branch', () => {
|
|
|
111
111
|
expect(error).toMatch(/ctx\.connectorVersion/);
|
|
112
112
|
expect(error).toMatch(/ctx\.executionToken/);
|
|
113
113
|
});
|
|
114
|
-
it('
|
|
114
|
+
it('register succeeds when org/workspace/project ctx fields are missing and forwards them as null', async () => {
|
|
115
115
|
const { client, registerCalls } = createFakePollingServiceClient();
|
|
116
116
|
const handler = new CompositeOperationHandler_1.CompositeOperationHandler(jest.fn());
|
|
117
117
|
const execution = new CompositeOperationExecution_1.CompositeOperationExecution(noopHandlerInvocationFactory, handler, OperationHandler_1.OperationHandlerType.TriggerPollCreate, 'new_records', client);
|
|
118
|
-
// Base polling ctx is present, but the identity fields
|
|
119
|
-
//
|
|
120
|
-
//
|
|
118
|
+
// Base polling ctx is present, but the identity fields are not. These
|
|
119
|
+
// are best-effort and must not block registration (e.g. agent-driven
|
|
120
|
+
// invocations have no project context). `ctx.auth.authId` is also
|
|
121
|
+
// omitted to cover the "no auth" case.
|
|
121
122
|
const incompleteCtx = {
|
|
122
123
|
connectorName: 'x',
|
|
123
124
|
connectorVersion: '1',
|
|
124
125
|
executionToken: 'tok',
|
|
125
126
|
};
|
|
126
|
-
const result = await execution.execute(incompleteCtx,
|
|
127
|
-
expect(
|
|
128
|
-
expect(
|
|
129
|
-
const
|
|
130
|
-
expect(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
127
|
+
const result = await execution.execute(incompleteCtx, fakePollingInput());
|
|
128
|
+
expect(result.isSuccess).toBe(true);
|
|
129
|
+
expect(registerCalls).toHaveLength(1);
|
|
130
|
+
const [payload] = registerCalls[0];
|
|
131
|
+
expect(payload).toMatchObject({
|
|
132
|
+
authenticationId: null,
|
|
133
|
+
organizationId: null,
|
|
134
|
+
workspaceId: null,
|
|
135
|
+
projectId: null,
|
|
136
|
+
});
|
|
134
137
|
});
|
|
135
138
|
it('deregister does NOT require the register-only ctx fields', async () => {
|
|
136
139
|
const { client, deregisterCalls } = createFakePollingServiceClient();
|
|
@@ -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,EAEN,mBAAmB,EACnB,MAAM,kDAAkD,CAAC;AAE1D,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;
|
|
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,EA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AAE,oBAAoB,CAAC;CAC3C,GAAG,OAAO,CAAC,IAAI,CAAC,CAoDhB"}
|
|
@@ -48,22 +48,12 @@ const requirePollingCtxFields = (ctx) => {
|
|
|
48
48
|
};
|
|
49
49
|
const requirePollingRegisterCtxFields = (ctx) => {
|
|
50
50
|
const base = requirePollingCtxFields(ctx);
|
|
51
|
-
const missing = [];
|
|
52
|
-
if (!ctx.organizationId)
|
|
53
|
-
missing.push('ctx.organizationId');
|
|
54
|
-
if (!ctx.workspaceId)
|
|
55
|
-
missing.push('ctx.workspaceId');
|
|
56
|
-
if (!ctx.projectId)
|
|
57
|
-
missing.push('ctx.projectId');
|
|
58
|
-
if (missing.length > 0) {
|
|
59
|
-
throw new Error(`polling register is missing required context fields: ${missing.join(', ')}`);
|
|
60
|
-
}
|
|
61
51
|
return {
|
|
62
52
|
...base,
|
|
63
53
|
authenticationId: ctx.auth?.authId ?? null,
|
|
64
|
-
organizationId: ctx.organizationId,
|
|
65
|
-
workspaceId: ctx.workspaceId,
|
|
66
|
-
projectId: ctx.projectId,
|
|
54
|
+
organizationId: ctx.organizationId ?? null,
|
|
55
|
+
workspaceId: ctx.workspaceId ?? null,
|
|
56
|
+
projectId: ctx.projectId ?? null,
|
|
67
57
|
};
|
|
68
58
|
};
|
|
69
59
|
const requirePollingPublicUrl = (pollingInput) => {
|
|
@@ -5,9 +5,9 @@ export type PollingServiceRegisterPayload = {
|
|
|
5
5
|
connectorVersion: string;
|
|
6
6
|
registeredHandlerName: string;
|
|
7
7
|
authenticationId: string | null;
|
|
8
|
-
organizationId: string;
|
|
9
|
-
workspaceId: string;
|
|
10
|
-
projectId: string;
|
|
8
|
+
organizationId: string | null;
|
|
9
|
+
workspaceId: string | null;
|
|
10
|
+
projectId: string | null;
|
|
11
11
|
publicUrl: string;
|
|
12
12
|
pollingInterval?: PollingInterval;
|
|
13
13
|
maxFailureCount?: number;
|
|
@@ -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,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,MAAM,CAAC;
|
|
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,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,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;IAmCV,UAAU,CACf,OAAO,EAAE,+BAA+B,EACxC,cAAc,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC;YAaF,QAAQ;CAgCtB"}
|
|
@@ -80,15 +80,25 @@ class PollingServiceClient {
|
|
|
80
80
|
connectorVersion: payload.connectorVersion,
|
|
81
81
|
operationName: toCanonicalPollOperationName(payload.registeredHandlerName),
|
|
82
82
|
authenticationId: payload.authenticationId,
|
|
83
|
-
organizationId: payload.organizationId,
|
|
84
|
-
workspaceId: payload.workspaceId,
|
|
85
|
-
projectId: payload.projectId,
|
|
86
83
|
publicUrl: payload.publicUrl,
|
|
87
84
|
interval: intervalMinutes,
|
|
88
85
|
maxFailureCount,
|
|
89
86
|
initialCursor: payload.initialCursor ?? null,
|
|
90
87
|
operationInput: payload.operationInput ?? null,
|
|
91
88
|
};
|
|
89
|
+
// organizationId / workspaceId / projectId are best-effort identity
|
|
90
|
+
// fields. Some callsites (e.g. agent-driven invocations) don't have a
|
|
91
|
+
// project context, so we omit the keys from the wire payload entirely
|
|
92
|
+
// when they're absent rather than sending `null`.
|
|
93
|
+
if (payload.organizationId) {
|
|
94
|
+
body.organizationId = payload.organizationId;
|
|
95
|
+
}
|
|
96
|
+
if (payload.workspaceId) {
|
|
97
|
+
body.workspaceId = payload.workspaceId;
|
|
98
|
+
}
|
|
99
|
+
if (payload.projectId) {
|
|
100
|
+
body.projectId = payload.projectId;
|
|
101
|
+
}
|
|
92
102
|
await this.sendJson(Http_1.HttpMethod.Post, executionToken, body);
|
|
93
103
|
}
|
|
94
104
|
async deregister(payload, executionToken) {
|
|
@@ -182,6 +182,19 @@ describe('PollingServiceClient', () => {
|
|
|
182
182
|
const body = captured[0].body;
|
|
183
183
|
expect(body).toHaveProperty('authenticationId', null);
|
|
184
184
|
});
|
|
185
|
+
it('omits organizationId, workspaceId, and projectId from the wire body when null', async () => {
|
|
186
|
+
const captured = [];
|
|
187
|
+
const client = new PollingServiceClient_1.PollingServiceClient(createMockHttpClient(captured));
|
|
188
|
+
await client.register(minimalRegister({
|
|
189
|
+
organizationId: null,
|
|
190
|
+
workspaceId: null,
|
|
191
|
+
projectId: null,
|
|
192
|
+
}), 'tok');
|
|
193
|
+
const body = captured[0].body;
|
|
194
|
+
expect(body).not.toHaveProperty('organizationId');
|
|
195
|
+
expect(body).not.toHaveProperty('workspaceId');
|
|
196
|
+
expect(body).not.toHaveProperty('projectId');
|
|
197
|
+
});
|
|
185
198
|
it('trims trailing slashes from the PS base URL', async () => {
|
|
186
199
|
process.env[ENV_VAR] = `${BASE_URL}/`;
|
|
187
200
|
const captured = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/cdk-runtime",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.27.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.
|
|
18
|
-
"@trayio/cdk-dsl": "5.
|
|
19
|
-
"@trayio/express": "5.
|
|
20
|
-
"@trayio/winston": "5.
|
|
17
|
+
"@trayio/axios": "5.27.0",
|
|
18
|
+
"@trayio/cdk-dsl": "5.27.0",
|
|
19
|
+
"@trayio/express": "5.27.0",
|
|
20
|
+
"@trayio/winston": "5.27.0",
|
|
21
21
|
"mime": "3.0.0",
|
|
22
22
|
"uuid": "9.0.0"
|
|
23
23
|
},
|