@zapier/zapier-sdk 0.18.3 → 1.0.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 +17 -0
- package/README.md +1 -1
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +11 -24
- package/dist/api/client.test.js +82 -27
- package/dist/api/index.d.ts +3 -2
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +2 -3
- package/dist/api/schemas.d.ts +5 -114
- package/dist/api/schemas.d.ts.map +1 -1
- package/dist/api/schemas.js +0 -67
- package/dist/api/types.d.ts +10 -4
- package/dist/api/types.d.ts.map +1 -1
- package/dist/auth.d.ts +54 -26
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +211 -39
- package/dist/auth.test.js +338 -64
- package/dist/constants.d.ts +14 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +14 -0
- package/dist/credentials.d.ts +57 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +174 -0
- package/dist/index.cjs +644 -685
- package/dist/index.d.mts +265 -134
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.mjs +624 -684
- package/dist/plugins/api/index.d.ts +2 -0
- package/dist/plugins/api/index.d.ts.map +1 -1
- package/dist/plugins/api/index.js +8 -4
- package/dist/plugins/eventEmission/index.d.ts.map +1 -1
- package/dist/plugins/eventEmission/index.js +1 -3
- package/dist/plugins/eventEmission/index.test.js +14 -17
- package/dist/plugins/getAction/schemas.d.ts +1 -1
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts +1 -1
- package/dist/plugins/listActions/index.test.js +1 -0
- package/dist/plugins/listActions/schemas.d.ts +1 -1
- package/dist/plugins/listApps/index.d.ts +2 -8
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +4 -6
- package/dist/plugins/listApps/index.test.js +62 -82
- package/dist/plugins/listApps/schemas.d.ts +35 -14
- package/dist/plugins/listApps/schemas.d.ts.map +1 -1
- package/dist/plugins/listApps/schemas.js +44 -14
- package/dist/plugins/listAuthentications/index.test.js +16 -0
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +1 -1
- package/dist/plugins/listInputFields/schemas.d.ts +1 -1
- package/dist/plugins/runAction/schemas.d.ts +1 -1
- package/dist/schemas/Action.d.ts +1 -1
- package/dist/schemas/App.d.ts +28 -28
- package/dist/schemas/App.d.ts.map +1 -1
- package/dist/schemas/App.js +3 -8
- package/dist/sdk.d.ts +2 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.test.js +17 -13
- package/dist/types/credentials.d.ts +65 -0
- package/dist/types/credentials.d.ts.map +1 -0
- package/dist/types/credentials.js +42 -0
- package/dist/types/properties.d.ts +1 -1
- package/dist/types/sdk.d.ts +12 -3
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/utils/logging.d.ts +13 -0
- package/dist/utils/logging.d.ts.map +1 -0
- package/dist/utils/logging.js +20 -0
- package/package.json +2 -2
- package/dist/api/client.integration.test.d.ts +0 -5
- package/dist/api/client.integration.test.d.ts.map +0 -1
- package/dist/api/client.integration.test.js +0 -318
- package/dist/api/client.methods.test.d.ts +0 -2
- package/dist/api/client.methods.test.d.ts.map +0 -1
- package/dist/api/client.methods.test.js +0 -158
- package/dist/api/router.d.ts +0 -16
- package/dist/api/router.d.ts.map +0 -1
- package/dist/api/router.js +0 -31
- package/dist/api/router.test.d.ts +0 -2
- package/dist/api/router.test.d.ts.map +0 -1
- package/dist/api/router.test.js +0 -103
- package/dist/temporary-internal-core/handlers/listApps.d.ts +0 -67
- package/dist/temporary-internal-core/handlers/listApps.d.ts.map +0 -1
- package/dist/temporary-internal-core/handlers/listApps.js +0 -134
- package/dist/temporary-internal-core/handlers/listApps.test.d.ts +0 -2
- package/dist/temporary-internal-core/handlers/listApps.test.d.ts.map +0 -1
- package/dist/temporary-internal-core/handlers/listApps.test.js +0 -367
- package/dist/temporary-internal-core/index.d.ts +0 -18
- package/dist/temporary-internal-core/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/index.js +0 -18
- package/dist/temporary-internal-core/schemas/apps/index.d.ts +0 -175
- package/dist/temporary-internal-core/schemas/apps/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/schemas/apps/index.js +0 -97
- package/dist/temporary-internal-core/schemas/errors/index.d.ts +0 -139
- package/dist/temporary-internal-core/schemas/errors/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/schemas/errors/index.js +0 -129
- package/dist/temporary-internal-core/schemas/implementations/index.d.ts +0 -127
- package/dist/temporary-internal-core/schemas/implementations/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/schemas/implementations/index.js +0 -79
- package/dist/temporary-internal-core/types/handler.d.ts +0 -51
- package/dist/temporary-internal-core/types/handler.d.ts.map +0 -1
- package/dist/temporary-internal-core/types/handler.js +0 -8
- package/dist/temporary-internal-core/types/index.d.ts +0 -5
- package/dist/temporary-internal-core/types/index.d.ts.map +0 -1
- package/dist/temporary-internal-core/types/index.js +0 -4
- package/dist/temporary-internal-core/utils/app-locators.d.ts +0 -34
- package/dist/temporary-internal-core/utils/app-locators.d.ts.map +0 -1
- package/dist/temporary-internal-core/utils/app-locators.js +0 -39
- package/dist/temporary-internal-core/utils/string-utils.d.ts +0 -28
- package/dist/temporary-internal-core/utils/string-utils.d.ts.map +0 -1
- package/dist/temporary-internal-core/utils/string-utils.js +0 -52
- package/dist/temporary-internal-core/utils/transformations.d.ts +0 -18
- package/dist/temporary-internal-core/utils/transformations.d.ts.map +0 -1
- package/dist/temporary-internal-core/utils/transformations.js +0 -36
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { ApiClient } from "../../api/types";
|
|
2
2
|
import type { BaseSdkOptions } from "../../types/sdk";
|
|
3
3
|
import type { Plugin } from "../../types/plugin";
|
|
4
|
+
import type { ResolvedCredentials } from "../../types/credentials";
|
|
4
5
|
export interface ApiPluginOptions extends BaseSdkOptions {
|
|
5
6
|
}
|
|
6
7
|
export interface ApiPluginProvides {
|
|
7
8
|
context: {
|
|
8
9
|
api: ApiClient;
|
|
10
|
+
resolveCredentials: () => Promise<ResolvedCredentials | undefined>;
|
|
9
11
|
};
|
|
10
12
|
}
|
|
11
13
|
export declare const apiPlugin: Plugin<{}, {}, ApiPluginProvides>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/api/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/api/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAInE,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG;AAG3D,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE;QACP,GAAG,EAAE,SAAS,CAAC;QACf,kBAAkB,EAAE,MAAM,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC;KACpE,CAAC;CACH;AAGD,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,iBAAiB,CAiCvD,CAAC"}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { createZapierApi } from "../../api";
|
|
2
|
+
import { resolveCredentials } from "../../credentials";
|
|
2
3
|
import { ZAPIER_BASE_URL } from "../../constants";
|
|
3
4
|
// API plugin requires no context and provides api in context
|
|
4
5
|
export const apiPlugin = (params) => {
|
|
5
6
|
// Extract all options - everything passed to the plugin
|
|
6
|
-
const { fetch: customFetch = globalThis.fetch, baseUrl = ZAPIER_BASE_URL,
|
|
7
|
+
const { fetch: customFetch = globalThis.fetch, baseUrl = ZAPIER_BASE_URL, credentials, token, onEvent, debug = false, } = params.context.options;
|
|
7
8
|
// Create the API client - it will handle token resolution internally
|
|
8
9
|
const api = createZapierApi({
|
|
9
10
|
baseUrl,
|
|
10
|
-
|
|
11
|
-
authClientId,
|
|
11
|
+
credentials,
|
|
12
12
|
token,
|
|
13
|
-
getToken,
|
|
14
13
|
debug,
|
|
15
14
|
fetch: customFetch,
|
|
16
15
|
onEvent,
|
|
@@ -19,6 +18,11 @@ export const apiPlugin = (params) => {
|
|
|
19
18
|
return {
|
|
20
19
|
context: {
|
|
21
20
|
api, // Provide API client in context for other plugins to use
|
|
21
|
+
resolveCredentials: () => resolveCredentials({
|
|
22
|
+
credentials,
|
|
23
|
+
token,
|
|
24
|
+
baseUrl,
|
|
25
|
+
}),
|
|
22
26
|
},
|
|
23
27
|
};
|
|
24
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/eventEmission/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAWnE,OAAO,KAAK,EAAgB,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAMnE,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAGD,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE;QACb,SAAS,EAAE,cAAc,CAAC;QAC1B,MAAM,EAAE,mBAAmB,CAAC;QAE5B,IAAI,CAAC,CAAC,SAAS,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;QAErD,eAAe,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;QAEtC,gBAAgB,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAAC;KACrD,CAAC;CACH;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,oBAAoB,CAAC;CAC/B;AA6FD,eAAO,MAAM,mBAAmB,EAAE,MAAM,CACtC,EAAE,EACF;IACE,OAAO,EAAE;QACP,aAAa,CAAC,EAAE,mBAAmB,CAAC;QACpC,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,EACD,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/eventEmission/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAWnE,OAAO,KAAK,EAAgB,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAMnE,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAGD,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE;QACb,SAAS,EAAE,cAAc,CAAC;QAC1B,MAAM,EAAE,mBAAmB,CAAC;QAE5B,IAAI,CAAC,CAAC,SAAS,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;QAErD,eAAe,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;QAEtC,gBAAgB,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAAC;KACrD,CAAC;CACH;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,oBAAoB,CAAC;CAC/B;AA6FD,eAAO,MAAM,mBAAmB,EAAE,MAAM,CACtC,EAAE,EACF;IACE,OAAO,EAAE;QACP,aAAa,CAAC,EAAE,mBAAmB,CAAC;QACpC,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,EACD,qBAAqB,CAgStB,CAAC;AAGF,YAAY,EACV,YAAY,EACZ,6BAA6B,EAC7B,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,EAC1B,eAAe,EACf,eAAe,EACf,sBAAsB,GACvB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,cAAc,SAAS,CAAC"}
|
|
@@ -97,11 +97,9 @@ export const eventEmissionPlugin = ({ context }) => {
|
|
|
97
97
|
const getUserContext = (async () => {
|
|
98
98
|
try {
|
|
99
99
|
const token = await resolveAuthToken({
|
|
100
|
+
credentials: context.options.credentials,
|
|
100
101
|
token: context.options.token,
|
|
101
|
-
getToken: context.options.getToken,
|
|
102
102
|
baseUrl: context.options.baseUrl,
|
|
103
|
-
authBaseUrl: context.options.authBaseUrl,
|
|
104
|
-
authClientId: context.options.authClientId,
|
|
105
103
|
onEvent: context.options.onEvent,
|
|
106
104
|
fetch: context.options.fetch,
|
|
107
105
|
});
|
|
@@ -448,7 +448,7 @@ describe("eventEmissionPlugin", () => {
|
|
|
448
448
|
// CLI login package should not be called when token is in options
|
|
449
449
|
expect(mockGetToken).not.toHaveBeenCalled();
|
|
450
450
|
});
|
|
451
|
-
it("should extract user IDs from
|
|
451
|
+
it("should extract user IDs from credentials function in SDK options", async () => {
|
|
452
452
|
// Create a test JWT token
|
|
453
453
|
const header = { alg: "HS256", typ: "JWT" };
|
|
454
454
|
const payload = {
|
|
@@ -459,13 +459,13 @@ describe("eventEmissionPlugin", () => {
|
|
|
459
459
|
const encodedHeader = Buffer.from(JSON.stringify(header)).toString("base64url");
|
|
460
460
|
const encodedPayload = Buffer.from(JSON.stringify(payload)).toString("base64url");
|
|
461
461
|
const testJwt = `${encodedHeader}.${encodedPayload}.custom-signature`;
|
|
462
|
-
const
|
|
462
|
+
const credentialsFn = vi.fn().mockResolvedValue(testJwt);
|
|
463
463
|
const plugin = eventEmissionPlugin({
|
|
464
464
|
sdk: {},
|
|
465
465
|
context: {
|
|
466
466
|
meta: {},
|
|
467
467
|
options: {
|
|
468
|
-
|
|
468
|
+
credentials: credentialsFn,
|
|
469
469
|
eventEmission: {
|
|
470
470
|
enabled: true,
|
|
471
471
|
transport: { type: "console" },
|
|
@@ -474,14 +474,14 @@ describe("eventEmissionPlugin", () => {
|
|
|
474
474
|
},
|
|
475
475
|
});
|
|
476
476
|
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
477
|
-
// Should extract from custom
|
|
477
|
+
// Should extract from custom credentials function
|
|
478
478
|
expect(baseEvent.customuser_id).toBe(44444);
|
|
479
479
|
expect(baseEvent.account_id).toBe(33333);
|
|
480
|
-
expect(
|
|
481
|
-
// CLI login package should not be called when
|
|
480
|
+
expect(credentialsFn).toHaveBeenCalled();
|
|
481
|
+
// CLI login package should not be called when credentials is in options
|
|
482
482
|
expect(mockGetToken).not.toHaveBeenCalled();
|
|
483
483
|
});
|
|
484
|
-
it("should prioritize
|
|
484
|
+
it("should prioritize string credentials over credentials function", async () => {
|
|
485
485
|
// Create test JWT tokens
|
|
486
486
|
const staticHeader = { alg: "HS256", typ: "JWT" };
|
|
487
487
|
const staticPayload = {
|
|
@@ -492,14 +492,12 @@ describe("eventEmissionPlugin", () => {
|
|
|
492
492
|
const staticEncodedHeader = Buffer.from(JSON.stringify(staticHeader)).toString("base64url");
|
|
493
493
|
const staticEncodedPayload = Buffer.from(JSON.stringify(staticPayload)).toString("base64url");
|
|
494
494
|
const staticJwt = `${staticEncodedHeader}.${staticEncodedPayload}.static-sig`;
|
|
495
|
-
const customGetToken = vi.fn().mockResolvedValue("should-not-be-used");
|
|
496
495
|
const plugin = eventEmissionPlugin({
|
|
497
496
|
sdk: {},
|
|
498
497
|
context: {
|
|
499
498
|
meta: {},
|
|
500
499
|
options: {
|
|
501
|
-
|
|
502
|
-
getToken: customGetToken,
|
|
500
|
+
credentials: staticJwt,
|
|
503
501
|
eventEmission: {
|
|
504
502
|
enabled: true,
|
|
505
503
|
transport: { type: "console" },
|
|
@@ -508,10 +506,9 @@ describe("eventEmissionPlugin", () => {
|
|
|
508
506
|
},
|
|
509
507
|
});
|
|
510
508
|
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
511
|
-
// Should use
|
|
509
|
+
// Should use string credentials
|
|
512
510
|
expect(baseEvent.customuser_id).toBe(66666);
|
|
513
511
|
expect(baseEvent.account_id).toBe(55555);
|
|
514
|
-
expect(customGetToken).not.toHaveBeenCalled();
|
|
515
512
|
expect(mockGetToken).not.toHaveBeenCalled();
|
|
516
513
|
});
|
|
517
514
|
it("should fall back to CLI login when SDK options have no token", async () => {
|
|
@@ -545,8 +542,8 @@ describe("eventEmissionPlugin", () => {
|
|
|
545
542
|
expect(baseEvent.account_id).toBe(77777);
|
|
546
543
|
expect(mockGetToken).toHaveBeenCalled();
|
|
547
544
|
});
|
|
548
|
-
it("should handle
|
|
549
|
-
const
|
|
545
|
+
it("should handle credentials function returning undefined and fall back to CLI login", async () => {
|
|
546
|
+
const credentialsFn = vi.fn().mockResolvedValue(undefined);
|
|
550
547
|
// Also mock CLI login to return a token
|
|
551
548
|
const header = { alg: "HS256", typ: "JWT" };
|
|
552
549
|
const payload = {
|
|
@@ -563,7 +560,7 @@ describe("eventEmissionPlugin", () => {
|
|
|
563
560
|
context: {
|
|
564
561
|
meta: {},
|
|
565
562
|
options: {
|
|
566
|
-
|
|
563
|
+
credentials: credentialsFn,
|
|
567
564
|
eventEmission: {
|
|
568
565
|
enabled: true,
|
|
569
566
|
transport: { type: "console" },
|
|
@@ -572,10 +569,10 @@ describe("eventEmissionPlugin", () => {
|
|
|
572
569
|
},
|
|
573
570
|
});
|
|
574
571
|
const baseEvent = await plugin.context.eventEmission.createBaseEvent();
|
|
575
|
-
//
|
|
572
|
+
// Since credentials function returns undefined, SDK falls back to CLI login
|
|
576
573
|
expect(baseEvent.customuser_id).toBe(10101);
|
|
577
574
|
expect(baseEvent.account_id).toBe(99999);
|
|
578
|
-
expect(
|
|
575
|
+
expect(credentialsFn).toHaveBeenCalled();
|
|
579
576
|
expect(mockGetToken).toHaveBeenCalled();
|
|
580
577
|
});
|
|
581
578
|
});
|
|
@@ -6,8 +6,8 @@ export declare const GetActionSchema: z.ZodObject<{
|
|
|
6
6
|
_def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
|
|
7
7
|
};
|
|
8
8
|
actionType: z.ZodEnum<{
|
|
9
|
-
search: "search";
|
|
10
9
|
filter: "filter";
|
|
10
|
+
search: "search";
|
|
11
11
|
read: "read";
|
|
12
12
|
read_bulk: "read_bulk";
|
|
13
13
|
run: "run";
|
|
@@ -5,8 +5,8 @@ export declare const GetInputFieldsSchemaSchema: z.ZodObject<{
|
|
|
5
5
|
_def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
|
|
6
6
|
};
|
|
7
7
|
actionType: z.ZodEnum<{
|
|
8
|
-
search: "search";
|
|
9
8
|
filter: "filter";
|
|
9
|
+
search: "search";
|
|
10
10
|
read: "read";
|
|
11
11
|
read_bulk: "read_bulk";
|
|
12
12
|
run: "run";
|
|
@@ -7,8 +7,8 @@ export declare const ListActionsSchema: z.ZodObject<{
|
|
|
7
7
|
_def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
|
|
8
8
|
};
|
|
9
9
|
actionType: z.ZodOptional<z.ZodEnum<{
|
|
10
|
-
search: "search";
|
|
11
10
|
filter: "filter";
|
|
11
|
+
search: "search";
|
|
12
12
|
read: "read";
|
|
13
13
|
read_bulk: "read_bulk";
|
|
14
14
|
run: "run";
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import type { GetContextType, Plugin } from "../../types/plugin";
|
|
2
|
-
import { ListAppsSchema, type ListAppsOptions, type AppItem } from "./schemas";
|
|
2
|
+
import { ListAppsSchema, type ListAppsOptions, type ListAppsPage, type AppItem } from "./schemas";
|
|
3
3
|
import type { ManifestPluginProvides } from "../manifest";
|
|
4
4
|
import type { ApiPluginProvides } from "../api";
|
|
5
5
|
import type { EventEmissionContext } from "../eventEmission";
|
|
6
6
|
export interface ListAppsPluginProvides {
|
|
7
|
-
listApps: (options?: ListAppsOptions) => Promise<{
|
|
8
|
-
data: AppItem[];
|
|
9
|
-
nextCursor?: string;
|
|
10
|
-
}> & AsyncIterable<{
|
|
11
|
-
data: AppItem[];
|
|
12
|
-
nextCursor?: string;
|
|
13
|
-
}> & {
|
|
7
|
+
listApps: (options?: ListAppsOptions) => Promise<ListAppsPage> & AsyncIterable<ListAppsPage> & {
|
|
14
8
|
items(): AsyncIterable<AppItem>;
|
|
15
9
|
};
|
|
16
10
|
context: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EACL,cAAc,EACd,KAAK,eAAe,EAEpB,KAAK,OAAO,EACb,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAI7D,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EACL,cAAc,EACd,KAAK,eAAe,EAEpB,KAAK,YAAY,EACjB,KAAK,OAAO,EACb,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAI7D,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,YAAY,CAAC,GAC5D,aAAa,CAAC,YAAY,CAAC,GAAG;QAC5B,KAAK,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;KACjC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,QAAQ,EAAE;gBACR,WAAW,EAAE,OAAO,cAAc,CAAC;aACpC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,EAAE,EACF,cAAc,CAAC,iBAAiB,GAAG,sBAAsB,CAAC,GACxD,oBAAoB,EACtB,sBAAsB,CA+EvB,CAAC"}
|
|
@@ -31,27 +31,25 @@ export const listAppsPlugin = ({ context }) => {
|
|
|
31
31
|
if (appKeys.length > 0 && appLocators.length === 0 && !options.search) {
|
|
32
32
|
return {
|
|
33
33
|
data: [],
|
|
34
|
-
|
|
34
|
+
links: { next: null },
|
|
35
|
+
meta: { count: 0, limit: 0, offset: 0 },
|
|
35
36
|
};
|
|
36
37
|
}
|
|
37
38
|
const implementationIds = appLocators.map((locator) => {
|
|
38
39
|
const version = locator.version || "latest";
|
|
39
40
|
return `${locator.implementationName}@${version}`;
|
|
40
41
|
});
|
|
41
|
-
// Call the API, which will be routed to the handler via handlerOverride in pathConfig.
|
|
42
|
-
// When the handler is migrated to sdkapi, this same API call will go over the network.
|
|
43
42
|
return await api.get("/api/v0/apps", {
|
|
44
43
|
searchParams: {
|
|
45
|
-
|
|
44
|
+
appKeys: implementationIds.join(","),
|
|
46
45
|
...(options.search && { search: options.search }),
|
|
47
46
|
pageSize: options.pageSize.toString(),
|
|
48
|
-
...(options.cursor && {
|
|
47
|
+
...(options.cursor && { offset: options.cursor }),
|
|
49
48
|
},
|
|
50
49
|
});
|
|
51
50
|
}
|
|
52
51
|
const methodName = stripPageSuffix(listAppsPage.name);
|
|
53
52
|
const listAppsDefinition = createPaginatedFunction(listAppsPage, ListAppsSchema, createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName), methodName);
|
|
54
|
-
// Return flat structure - listApps goes directly to SDK
|
|
55
53
|
return {
|
|
56
54
|
listApps: listAppsDefinition,
|
|
57
55
|
context: {
|
|
@@ -2,8 +2,19 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
|
2
2
|
import { ZapierValidationError } from "../../types/errors";
|
|
3
3
|
import { listAppsPlugin } from "./index";
|
|
4
4
|
import { createSdk } from "../../sdk";
|
|
5
|
-
import { apiPlugin } from "../api/index";
|
|
6
5
|
import { eventEmissionPlugin } from "../eventEmission";
|
|
6
|
+
// Mock transport for testing - prevents real HTTP telemetry requests
|
|
7
|
+
const mockTransport = {
|
|
8
|
+
emit: vi.fn().mockResolvedValue(undefined),
|
|
9
|
+
close: vi.fn().mockResolvedValue(undefined),
|
|
10
|
+
};
|
|
11
|
+
vi.mock("../eventEmission/transport", () => ({
|
|
12
|
+
createTransport: vi.fn(() => mockTransport),
|
|
13
|
+
}));
|
|
14
|
+
// Mock CLI login package - prevents real token resolution requests
|
|
15
|
+
vi.mock("@zapier/zapier-sdk-cli-login", () => ({
|
|
16
|
+
getToken: vi.fn().mockResolvedValue(undefined),
|
|
17
|
+
}));
|
|
7
18
|
const mockResolveAppKeys = vi
|
|
8
19
|
.fn()
|
|
9
20
|
.mockImplementation(async ({ appKeys }) => {
|
|
@@ -14,77 +25,61 @@ const mockResolveAppKeys = vi
|
|
|
14
25
|
version: undefined,
|
|
15
26
|
}));
|
|
16
27
|
});
|
|
17
|
-
function createTestSdk(mockFetch) {
|
|
18
|
-
return createSdk()
|
|
19
|
-
.addPlugin(() => ({
|
|
20
|
-
context: {
|
|
21
|
-
options: {},
|
|
22
|
-
},
|
|
23
|
-
}))
|
|
24
|
-
.addPlugin(apiPlugin, { fetch: mockFetch || global.fetch })
|
|
25
|
-
.addPlugin(eventEmissionPlugin)
|
|
26
|
-
.addPlugin(() => ({
|
|
27
|
-
context: {
|
|
28
|
-
resolveAppKeys: mockResolveAppKeys,
|
|
29
|
-
},
|
|
30
|
-
}))
|
|
31
|
-
.addPlugin(listAppsPlugin);
|
|
32
|
-
}
|
|
33
|
-
function createMockFetch(handlers) {
|
|
34
|
-
return vi.fn().mockImplementation(async (url, _init) => {
|
|
35
|
-
const urlString = typeof url === "string" ? url : url.toString();
|
|
36
|
-
const urlPath = new URL(urlString).pathname;
|
|
37
|
-
for (const [handlerPath, response] of Object.entries(handlers)) {
|
|
38
|
-
if (urlPath === handlerPath) {
|
|
39
|
-
const responseData = typeof response === "function" ? response() : response;
|
|
40
|
-
return {
|
|
41
|
-
ok: true,
|
|
42
|
-
status: 200,
|
|
43
|
-
statusText: "OK",
|
|
44
|
-
json: async () => responseData,
|
|
45
|
-
headers: new Headers({ "content-type": "application/json" }),
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
ok: false,
|
|
51
|
-
status: 404,
|
|
52
|
-
statusText: "Not Found",
|
|
53
|
-
json: async () => ({ message: `No mock for path: ${urlPath}` }),
|
|
54
|
-
headers: new Headers(),
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
28
|
describe("listApps plugin", () => {
|
|
29
|
+
let mockApiClient;
|
|
59
30
|
beforeEach(() => {
|
|
60
31
|
vi.clearAllMocks();
|
|
32
|
+
mockApiClient = {
|
|
33
|
+
get: vi.fn().mockResolvedValue({
|
|
34
|
+
data: [
|
|
35
|
+
{
|
|
36
|
+
title: "Slack",
|
|
37
|
+
key: "SlackCLIAPI",
|
|
38
|
+
implementation_id: "SlackCLIAPI@1.0.0",
|
|
39
|
+
version: "1.0.0",
|
|
40
|
+
slug: "slack",
|
|
41
|
+
description: "Team communication",
|
|
42
|
+
primary_color: "#4A154B",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
title: "Google Sheets",
|
|
46
|
+
key: "GoogleSheetsCLIAPI",
|
|
47
|
+
implementation_id: "GoogleSheetsCLIAPI@1.0.0",
|
|
48
|
+
version: "1.0.0",
|
|
49
|
+
slug: "google-sheets",
|
|
50
|
+
description: "Online spreadsheets",
|
|
51
|
+
primary_color: "#34A853",
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
links: { next: null },
|
|
55
|
+
meta: { count: 2, limit: 100, offset: 0 },
|
|
56
|
+
}),
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
const apiPlugin = () => ({
|
|
60
|
+
context: {
|
|
61
|
+
api: mockApiClient,
|
|
62
|
+
},
|
|
61
63
|
});
|
|
64
|
+
function createTestSdk() {
|
|
65
|
+
return createSdk()
|
|
66
|
+
.addPlugin(() => ({
|
|
67
|
+
context: {
|
|
68
|
+
options: {},
|
|
69
|
+
},
|
|
70
|
+
}))
|
|
71
|
+
.addPlugin(apiPlugin)
|
|
72
|
+
.addPlugin(eventEmissionPlugin)
|
|
73
|
+
.addPlugin(() => ({
|
|
74
|
+
context: {
|
|
75
|
+
resolveAppKeys: mockResolveAppKeys,
|
|
76
|
+
},
|
|
77
|
+
}))
|
|
78
|
+
.addPlugin(listAppsPlugin);
|
|
79
|
+
}
|
|
62
80
|
describe("basic functionality", () => {
|
|
63
81
|
it("should provide listApps method that returns apps", async () => {
|
|
64
|
-
const
|
|
65
|
-
"/api/v0/sdk/zapier/api/v4/implementations-meta/lookup/": {
|
|
66
|
-
count: 2,
|
|
67
|
-
results: [
|
|
68
|
-
{
|
|
69
|
-
id: "SlackCLIAPI@1.0.0",
|
|
70
|
-
name: "Slack",
|
|
71
|
-
description: "Team communication",
|
|
72
|
-
primary_color: "#4A154B",
|
|
73
|
-
categories: ["communication"],
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
id: "GoogleSheetsCLIAPI@1.0.0",
|
|
77
|
-
name: "Google Sheets",
|
|
78
|
-
description: "Online spreadsheets",
|
|
79
|
-
primary_color: "#34A853",
|
|
80
|
-
categories: ["productivity"],
|
|
81
|
-
},
|
|
82
|
-
],
|
|
83
|
-
next: null,
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
const sdk = createTestSdk(mockFetch);
|
|
87
|
-
// Provide explicit pageSize to limit results
|
|
82
|
+
const sdk = createTestSdk();
|
|
88
83
|
const result = await sdk.listApps({ pageSize: 2 });
|
|
89
84
|
// Just verify the structure - handler tests verify correct data
|
|
90
85
|
expect(result.data.length).toBeGreaterThan(0);
|
|
@@ -102,22 +97,7 @@ describe("listApps plugin", () => {
|
|
|
102
97
|
expect(context.meta.listApps.inputSchema).toBeDefined();
|
|
103
98
|
});
|
|
104
99
|
it("should integrate with resolveAppKeys", async () => {
|
|
105
|
-
const
|
|
106
|
-
"/api/v0/sdk/zapier/api/v4/implementations-meta/lookup/": {
|
|
107
|
-
count: 1,
|
|
108
|
-
results: [
|
|
109
|
-
{
|
|
110
|
-
id: "SlackCLIAPI@1.0.0",
|
|
111
|
-
name: "Slack",
|
|
112
|
-
description: "Team communication",
|
|
113
|
-
primary_color: "#4A154B",
|
|
114
|
-
categories: ["communication"],
|
|
115
|
-
},
|
|
116
|
-
],
|
|
117
|
-
next: null,
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
const sdk = createTestSdk(mockFetch);
|
|
100
|
+
const sdk = createTestSdk();
|
|
121
101
|
await sdk.listApps({ appKeys: ["SlackCLIAPI"] });
|
|
122
102
|
// Verify resolveAppKeys was called with the provided appKeys
|
|
123
103
|
expect(mockResolveAppKeys).toHaveBeenCalledWith(expect.objectContaining({
|
|
@@ -1,24 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Plugin schemas for listApps
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Imports base query schema from @zapier/zapier-sdk-core (sdkapi) and extends
|
|
5
|
+
* with SDK-specific options.
|
|
6
6
|
*
|
|
7
|
-
* Note: The
|
|
8
|
-
*
|
|
9
|
-
* - ListAppsOptions accepts
|
|
10
|
-
* -
|
|
11
|
-
* - The plugin
|
|
12
|
-
* 1. App key resolution (slugs, implementation names → implementation IDs)
|
|
13
|
-
* 2. Early returns for invalid appKeys (prevents returning all apps)
|
|
14
|
-
* - The handler is responsible for:
|
|
15
|
-
* 1. Search augmentation (merging search results with implementation IDs)
|
|
16
|
-
* 2. Empty search handling (returns empty, not all apps)
|
|
7
|
+
* Note: The sdkapi endpoint uses ListAppsQuerySchema (HTTP query params),
|
|
8
|
+
* but the SDK exposes ListAppsSchema (user-friendly options):
|
|
9
|
+
* - ListAppsOptions accepts `appKeys` as array, `cursor`, `maxItems`
|
|
10
|
+
* - ListAppsQuery accepts `appKeys` as comma-separated string, `offset`
|
|
11
|
+
* - The plugin transforms between these formats
|
|
17
12
|
*/
|
|
13
|
+
import { z } from "zod";
|
|
18
14
|
import type { PaginatedSdkFunction } from "../../types/functions";
|
|
19
15
|
import type { ZapierApiError, ZapierValidationError } from "../../types/errors";
|
|
20
|
-
import
|
|
21
|
-
export {
|
|
16
|
+
import { AppItemSchema as AppItemSchemaBase, ListAppsResponseSchema as ListAppsResponseSchemaBase, type AppItem, type ListAppsResponse } from "@zapier/zapier-sdk-core/v0/schemas/apps";
|
|
17
|
+
export { AppItemSchemaBase as AppItemSchema };
|
|
18
|
+
export { ListAppsResponseSchemaBase as ListAppsResponseSchema };
|
|
19
|
+
export type { AppItem, ListAppsResponse };
|
|
20
|
+
/**
|
|
21
|
+
* SDK user-facing options for listApps
|
|
22
|
+
*
|
|
23
|
+
* Extends ListAppsQuerySchema from zapier-sdk-core with SDK-specific options:
|
|
24
|
+
* - appKeys: array (not comma-separated string)
|
|
25
|
+
* - cursor: pagination cursor (not offset)
|
|
26
|
+
* - maxItems: SDK-specific pagination limit
|
|
27
|
+
*/
|
|
28
|
+
export declare const ListAppsSchema: z.ZodObject<{
|
|
29
|
+
search: z.ZodOptional<z.ZodString>;
|
|
30
|
+
appKeys: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
31
|
+
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
maxItems: z.ZodOptional<z.ZodNumber>;
|
|
33
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
34
|
+
_telemetry: z.ZodOptional<z.ZodObject<{
|
|
35
|
+
isNested: z.ZodOptional<z.ZodBoolean>;
|
|
36
|
+
}, z.core.$strip>>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
export type ListAppsOptions = z.infer<typeof ListAppsSchema>;
|
|
39
|
+
export interface ListAppsPage {
|
|
40
|
+
data: AppItem[];
|
|
41
|
+
nextCursor?: string;
|
|
42
|
+
}
|
|
22
43
|
export type ListAppsError = ZapierApiError | ZapierValidationError;
|
|
23
44
|
export interface ListAppsSdkFunction {
|
|
24
45
|
listApps: PaginatedSdkFunction<ListAppsOptions | undefined, AppItem>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/schemas.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/plugins/listApps/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAIhF,OAAO,EACL,aAAa,IAAI,iBAAiB,EAClC,sBAAsB,IAAI,0BAA0B,EAEpD,KAAK,OAAO,EACZ,KAAK,gBAAgB,EACtB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAAE,iBAAiB,IAAI,aAAa,EAAE,CAAC;AAC9C,OAAO,EAAE,0BAA0B,IAAI,sBAAsB,EAAE,CAAC;AAChE,YAAY,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE1C;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;;;;;;;;;iBAuBmC,CAAC;AAE/D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAG7D,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,qBAAqB,CAAC;AAGnE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,oBAAoB,CAAC,eAAe,GAAG,SAAS,EAAE,OAAO,CAAC,CAAC;CACtE"}
|
|
@@ -1,19 +1,49 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Plugin schemas for listApps
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Imports base query schema from @zapier/zapier-sdk-core (sdkapi) and extends
|
|
5
|
+
* with SDK-specific options.
|
|
6
6
|
*
|
|
7
|
-
* Note: The
|
|
8
|
-
*
|
|
9
|
-
* - ListAppsOptions accepts
|
|
10
|
-
* -
|
|
11
|
-
* - The plugin
|
|
12
|
-
* 1. App key resolution (slugs, implementation names → implementation IDs)
|
|
13
|
-
* 2. Early returns for invalid appKeys (prevents returning all apps)
|
|
14
|
-
* - The handler is responsible for:
|
|
15
|
-
* 1. Search augmentation (merging search results with implementation IDs)
|
|
16
|
-
* 2. Empty search handling (returns empty, not all apps)
|
|
7
|
+
* Note: The sdkapi endpoint uses ListAppsQuerySchema (HTTP query params),
|
|
8
|
+
* but the SDK exposes ListAppsSchema (user-friendly options):
|
|
9
|
+
* - ListAppsOptions accepts `appKeys` as array, `cursor`, `maxItems`
|
|
10
|
+
* - ListAppsQuery accepts `appKeys` as comma-separated string, `offset`
|
|
11
|
+
* - The plugin transforms between these formats
|
|
17
12
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
import { TelemetryMarkerSchema } from "../../utils/function-utils";
|
|
15
|
+
// Import schemas and types from @zapier/zapier-sdk-core (sdkapi)
|
|
16
|
+
import { AppItemSchema as AppItemSchemaBase, ListAppsResponseSchema as ListAppsResponseSchemaBase, ListAppsQuerySchema as ListAppsQueryBase, } from "@zapier/zapier-sdk-core/v0/schemas/apps";
|
|
17
|
+
// Re-export for consumers
|
|
18
|
+
export { AppItemSchemaBase as AppItemSchema };
|
|
19
|
+
export { ListAppsResponseSchemaBase as ListAppsResponseSchema };
|
|
20
|
+
/**
|
|
21
|
+
* SDK user-facing options for listApps
|
|
22
|
+
*
|
|
23
|
+
* Extends ListAppsQuerySchema from zapier-sdk-core with SDK-specific options:
|
|
24
|
+
* - appKeys: array (not comma-separated string)
|
|
25
|
+
* - cursor: pagination cursor (not offset)
|
|
26
|
+
* - maxItems: SDK-specific pagination limit
|
|
27
|
+
*/
|
|
28
|
+
export const ListAppsSchema = ListAppsQueryBase.omit({
|
|
29
|
+
offset: true,
|
|
30
|
+
})
|
|
31
|
+
.extend({
|
|
32
|
+
// Override appKeys to be an array instead of comma-separated string
|
|
33
|
+
appKeys: z
|
|
34
|
+
.array(z.string())
|
|
35
|
+
.optional()
|
|
36
|
+
.describe("Filter apps by app keys (e.g., 'SlackCLIAPI' or slug like 'github')"),
|
|
37
|
+
// Override pageSize to make optional (base has default value)
|
|
38
|
+
pageSize: z.number().min(1).optional().describe("Number of apps per page"),
|
|
39
|
+
// SDK specific property for pagination/iterator helpers
|
|
40
|
+
maxItems: z
|
|
41
|
+
.number()
|
|
42
|
+
.min(1)
|
|
43
|
+
.optional()
|
|
44
|
+
.describe("Maximum total items to return across all pages"),
|
|
45
|
+
// SDK specific property for pagination/iterator helpers
|
|
46
|
+
cursor: z.string().optional().describe("Cursor to start from"),
|
|
47
|
+
})
|
|
48
|
+
.merge(TelemetryMarkerSchema)
|
|
49
|
+
.describe("List all available apps with optional filtering");
|
|
@@ -3,6 +3,19 @@ import { ZapierValidationError, ZapierAuthenticationError, } from "../../types/e
|
|
|
3
3
|
import { listAuthenticationsPlugin } from "./index";
|
|
4
4
|
import { createSdk } from "../../sdk";
|
|
5
5
|
import { eventEmissionPlugin } from "../eventEmission";
|
|
6
|
+
// Mock transport for testing - prevents real HTTP telemetry requests
|
|
7
|
+
const mockTransport = {
|
|
8
|
+
emit: vi.fn().mockResolvedValue(undefined),
|
|
9
|
+
close: vi.fn().mockResolvedValue(undefined),
|
|
10
|
+
};
|
|
11
|
+
vi.mock("../eventEmission/transport", () => ({
|
|
12
|
+
createTransport: vi.fn(() => mockTransport),
|
|
13
|
+
}));
|
|
14
|
+
// Mock CLI login package - prevents real token resolution requests
|
|
15
|
+
vi.mock("@zapier/zapier-sdk-cli-login", () => ({
|
|
16
|
+
getToken: vi.fn().mockResolvedValue(undefined),
|
|
17
|
+
}));
|
|
18
|
+
// Mock response in the new API format (data array, not results)
|
|
6
19
|
const mockAuthenticationsResponse = {
|
|
7
20
|
data: [
|
|
8
21
|
{
|
|
@@ -206,6 +219,7 @@ describe("listAuthentications plugin", () => {
|
|
|
206
219
|
it("should pass through is_expired and expired_at fields", async () => {
|
|
207
220
|
const sdk = createTestSdk();
|
|
208
221
|
const result = await sdk.listAuthentications();
|
|
222
|
+
// API returns these fields directly (no client-side transformation)
|
|
209
223
|
expect(result.data[0].is_expired).toBe("false");
|
|
210
224
|
expect(result.data[0].expired_at).toBe(null);
|
|
211
225
|
expect(result.data[1].is_expired).toBe("true");
|
|
@@ -221,6 +235,7 @@ describe("listAuthentications plugin", () => {
|
|
|
221
235
|
label: "Label Only Auth",
|
|
222
236
|
},
|
|
223
237
|
],
|
|
238
|
+
nextCursor: undefined,
|
|
224
239
|
};
|
|
225
240
|
mockApiClient.get = vi.fn().mockResolvedValue(responseWithoutTitle);
|
|
226
241
|
const sdk = createTestSdk();
|
|
@@ -239,6 +254,7 @@ describe("listAuthentications plugin", () => {
|
|
|
239
254
|
label: undefined,
|
|
240
255
|
},
|
|
241
256
|
],
|
|
257
|
+
nextCursor: undefined,
|
|
242
258
|
};
|
|
243
259
|
mockApiClient.get = vi
|
|
244
260
|
.fn()
|
|
@@ -13,8 +13,8 @@ export declare const ListInputFieldChoicesSchema: z.ZodObject<{
|
|
|
13
13
|
_def: z.core.$ZodStringDef & import("../..").PositionalMetadata;
|
|
14
14
|
};
|
|
15
15
|
actionType: z.ZodEnum<{
|
|
16
|
-
search: "search";
|
|
17
16
|
filter: "filter";
|
|
17
|
+
search: "search";
|
|
18
18
|
read: "read";
|
|
19
19
|
read_bulk: "read_bulk";
|
|
20
20
|
run: "run";
|