@zapier/zapier-sdk 0.6.4 → 0.8.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 +12 -0
- package/README.md +55 -23
- package/dist/api/schemas.d.ts +114 -0
- package/dist/api/schemas.d.ts.map +1 -1
- package/dist/api/schemas.js +45 -0
- package/dist/api/types.d.ts +5 -1
- package/dist/api/types.d.ts.map +1 -1
- package/dist/index.cjs +171 -7
- package/dist/index.d.mts +84 -10
- package/dist/index.mjs +171 -7
- package/dist/plugins/findFirstAuthentication/index.test.js +3 -3
- package/dist/plugins/findFirstAuthentication/schemas.d.ts +3 -3
- package/dist/plugins/findFirstAuthentication/schemas.js +1 -1
- package/dist/plugins/findUniqueAuthentication/index.test.js +3 -3
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts +3 -3
- package/dist/plugins/findUniqueAuthentication/schemas.js +1 -1
- package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/index.js +2 -3
- package/dist/plugins/listAuthentications/index.test.js +5 -5
- package/dist/plugins/listAuthentications/schemas.d.ts +3 -3
- package/dist/plugins/listAuthentications/schemas.js +1 -1
- package/dist/plugins/listInputFieldChoices/index.d.ts +28 -0
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -0
- package/dist/plugins/listInputFieldChoices/index.js +78 -0
- package/dist/plugins/listInputFieldChoices/index.test.d.ts +2 -0
- package/dist/plugins/listInputFieldChoices/index.test.d.ts.map +1 -0
- package/dist/plugins/listInputFieldChoices/index.test.js +537 -0
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +61 -0
- package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -0
- package/dist/plugins/listInputFieldChoices/schemas.js +73 -0
- package/dist/sdk.d.ts +7 -1
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +2 -0
- package/package.json +1 -1
- package/src/api/schemas.ts +62 -0
- package/src/api/types.ts +14 -0
- package/src/plugins/findFirstAuthentication/index.test.ts +3 -3
- package/src/plugins/findFirstAuthentication/schemas.ts +1 -1
- package/src/plugins/findUniqueAuthentication/index.test.ts +3 -3
- package/src/plugins/findUniqueAuthentication/schemas.ts +1 -1
- package/src/plugins/listAuthentications/index.test.ts +5 -5
- package/src/plugins/listAuthentications/index.ts +2 -3
- package/src/plugins/listAuthentications/schemas.ts +1 -1
- package/src/plugins/listInputFieldChoices/index.test.ts +653 -0
- package/src/plugins/listInputFieldChoices/index.ts +152 -0
- package/src/plugins/listInputFieldChoices/schemas.ts +139 -0
- package/src/sdk.ts +2 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AuthenticationIdPropertySchema, AppKeyPropertySchema, ActionTypePropertySchema, ActionKeyPropertySchema, InputsPropertySchema, } from "../../types/properties";
|
|
3
|
+
import { withFormatter, withOutputSchema } from "../../utils/schema-utils";
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// Input Field Choice Item Schema
|
|
6
|
+
// ============================================================================
|
|
7
|
+
export const InputFieldChoiceItemSchema = withFormatter(z.object({
|
|
8
|
+
key: z.string().optional().describe("Unique key/value for the choice"),
|
|
9
|
+
label: z
|
|
10
|
+
.string()
|
|
11
|
+
.optional()
|
|
12
|
+
.describe("Human readable label for the choice"),
|
|
13
|
+
sample: z.string().optional().describe("Sample value for the choice"),
|
|
14
|
+
value: z
|
|
15
|
+
.string()
|
|
16
|
+
.optional()
|
|
17
|
+
.describe("Value to be submitted when selected"),
|
|
18
|
+
}), {
|
|
19
|
+
format: (item) => {
|
|
20
|
+
const title = item.label || item.key || "Choice";
|
|
21
|
+
const subtitle = item.label && item.key && item.label !== item.key
|
|
22
|
+
? `(${item.key})`
|
|
23
|
+
: undefined;
|
|
24
|
+
const details = [];
|
|
25
|
+
if (item.sample && item.sample !== item.key) {
|
|
26
|
+
details.push({ text: `Sample: ${item.sample}`, style: "dim" });
|
|
27
|
+
}
|
|
28
|
+
if (item.value && item.value !== item.key) {
|
|
29
|
+
details.push({ text: `Value: ${item.value}`, style: "normal" });
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
title,
|
|
33
|
+
subtitle,
|
|
34
|
+
details,
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
// ============================================================================
|
|
39
|
+
// Plugin Schema Definition
|
|
40
|
+
// ============================================================================
|
|
41
|
+
export const ListInputFieldChoicesSchema = withOutputSchema(z
|
|
42
|
+
.object({
|
|
43
|
+
// Required action identification
|
|
44
|
+
appKey: AppKeyPropertySchema,
|
|
45
|
+
actionType: ActionTypePropertySchema,
|
|
46
|
+
actionKey: ActionKeyPropertySchema,
|
|
47
|
+
// Input field specification
|
|
48
|
+
inputFieldKey: z
|
|
49
|
+
.string()
|
|
50
|
+
.min(1)
|
|
51
|
+
.describe("Input field key to get choices for."),
|
|
52
|
+
// Common parameters
|
|
53
|
+
authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
|
|
54
|
+
inputs: InputsPropertySchema.optional().describe("Current input values that may affect available choices"),
|
|
55
|
+
page: z
|
|
56
|
+
.number()
|
|
57
|
+
.int()
|
|
58
|
+
.min(0)
|
|
59
|
+
.optional()
|
|
60
|
+
.describe("Page number for paginated results"),
|
|
61
|
+
// Pagination options (SDK-level)
|
|
62
|
+
pageSize: z
|
|
63
|
+
.number()
|
|
64
|
+
.min(1)
|
|
65
|
+
.optional()
|
|
66
|
+
.describe("Number of choices per page"),
|
|
67
|
+
maxItems: z
|
|
68
|
+
.number()
|
|
69
|
+
.min(1)
|
|
70
|
+
.optional()
|
|
71
|
+
.describe("Maximum total items to return across all pages"),
|
|
72
|
+
})
|
|
73
|
+
.describe("Get the available choices for a dynamic dropdown input field"), InputFieldChoiceItemSchema);
|
package/dist/sdk.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface ZapierSdkOptions extends BaseSdkOptions {
|
|
|
6
6
|
export declare function createSdk<TCurrentSdk = {}, TCurrentContext = {
|
|
7
7
|
meta: Record<string, PluginMeta>;
|
|
8
8
|
}>(options?: ZapierSdkOptions, initialSdk?: TCurrentSdk, initialContext?: TCurrentContext): Sdk<TCurrentSdk, TCurrentContext>;
|
|
9
|
-
export declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk<import("./types/plugin").ExtractSdkProperties<import(".").ApiPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").ListAppsPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").ManifestPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").GetAppPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").ListActionsPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").GetActionPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").ListInputFieldsPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").RunActionPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").LockVersionPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").ListAuthenticationsPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").GetAuthenticationPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").FindFirstAuthenticationPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").FindUniqueAuthenticationPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").RequestPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").FetchPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").AppsPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").GetProfilePluginProvides>, {
|
|
9
|
+
export declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk<import("./types/plugin").ExtractSdkProperties<import(".").ApiPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").ListAppsPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").ManifestPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").GetAppPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").ListActionsPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").GetActionPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").ListInputFieldsPluginProvides> & import("./types/plugin").ExtractSdkProperties<import("./plugins/listInputFieldChoices").ListInputFieldChoicesPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").RunActionPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").LockVersionPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").ListAuthenticationsPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").GetAuthenticationPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").FindFirstAuthenticationPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").FindUniqueAuthenticationPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").RequestPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").FetchPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").AppsPluginProvides> & import("./types/plugin").ExtractSdkProperties<import(".").GetProfilePluginProvides>, {
|
|
10
10
|
meta: Record<string, PluginMeta>;
|
|
11
11
|
} & {
|
|
12
12
|
api: import("./api").ApiClient;
|
|
@@ -44,6 +44,12 @@ export declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOption
|
|
|
44
44
|
inputSchema: typeof import("./plugins/listInputFields/schemas").ListInputFieldsSchema;
|
|
45
45
|
};
|
|
46
46
|
};
|
|
47
|
+
} & {
|
|
48
|
+
meta: {
|
|
49
|
+
listInputFieldChoices: {
|
|
50
|
+
inputSchema: typeof import("./plugins/listInputFieldChoices/schemas").ListInputFieldChoicesSchema;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
47
53
|
} & {
|
|
48
54
|
meta: {
|
|
49
55
|
runAction: {
|
package/dist/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAM7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EACV,GAAG,EAIH,UAAU,EACX,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAM7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EACV,GAAG,EAIH,UAAU,EACX,MAAM,gBAAgB,CAAC;AA0BxB,MAAM,WAAW,gBAAiB,SAAQ,cAAc;CAAG;AAG3D,wBAAgB,SAAS,CACvB,WAAW,GAAG,EAAE,EAChB,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;CAAE,EAEtD,OAAO,GAAE,gBAAqB,EAC9B,UAAU,GAAE,WAA+B,EAC3C,cAAc,GAAE,eAAiD,GAChE,GAAG,CAAC,WAAW,EAAE,eAAe,CAAC,CAqEnC;AAED,wBAAgB,8BAA8B,CAAC,OAAO,GAAE,gBAAqB;UA5EjD,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmHrD;AAED,wBAAgB,eAAe,CAAC,OAAO,GAAE,gBAAqB,GAAG,SAAS,CAMzE"}
|
package/dist/sdk.js
CHANGED
|
@@ -14,6 +14,7 @@ import { getAuthenticationPlugin } from "./plugins/getAuthentication";
|
|
|
14
14
|
import { findFirstAuthenticationPlugin } from "./plugins/findFirstAuthentication";
|
|
15
15
|
import { findUniqueAuthenticationPlugin } from "./plugins/findUniqueAuthentication";
|
|
16
16
|
import { listInputFieldsPlugin } from "./plugins/listInputFields";
|
|
17
|
+
import { listInputFieldChoicesPlugin } from "./plugins/listInputFieldChoices";
|
|
17
18
|
import { requestPlugin } from "./plugins/request";
|
|
18
19
|
import { manifestPlugin } from "./plugins/manifest";
|
|
19
20
|
import { lockVersionPlugin } from "./plugins/lockVersion";
|
|
@@ -84,6 +85,7 @@ export function createZapierSdkWithoutRegistry(options = {}) {
|
|
|
84
85
|
.addPlugin(listActionsPlugin)
|
|
85
86
|
.addPlugin(getActionPlugin)
|
|
86
87
|
.addPlugin(listInputFieldsPlugin)
|
|
88
|
+
.addPlugin(listInputFieldChoicesPlugin)
|
|
87
89
|
// Run action
|
|
88
90
|
.addPlugin(runActionPlugin)
|
|
89
91
|
// Version locking
|
package/package.json
CHANGED
package/src/api/schemas.ts
CHANGED
|
@@ -385,3 +385,65 @@ export const ImplementationsMetaResponseSchema = z.object({
|
|
|
385
385
|
previous: z.string().nullable().optional(),
|
|
386
386
|
results: z.array(ImplementationMetaSchema),
|
|
387
387
|
});
|
|
388
|
+
|
|
389
|
+
// ============================================================================
|
|
390
|
+
// Need Choices Schemas (for listInputFieldChoices functionality)
|
|
391
|
+
// ============================================================================
|
|
392
|
+
|
|
393
|
+
export const NeedChoicesResponseMetaSchema = z.object({
|
|
394
|
+
page: z.string().nullable().optional(),
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
export const NeedChoicesResponseLinksSchema = z.object({
|
|
398
|
+
next: z.string().nullable().optional(),
|
|
399
|
+
prev: z.string().nullable().optional(),
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
export const NeedChoicesRequestSchema = z.object({
|
|
403
|
+
selected_api: z
|
|
404
|
+
.string()
|
|
405
|
+
.optional()
|
|
406
|
+
.describe(
|
|
407
|
+
"Something like `SlackAPI` (for Python apps) or `SplitwiseCLIAPI@1.0.0` (for CLI apps). Non-public apps are fine as long as the authed user can access them.",
|
|
408
|
+
),
|
|
409
|
+
authentication_id: z
|
|
410
|
+
.number()
|
|
411
|
+
.optional()
|
|
412
|
+
.describe(
|
|
413
|
+
"If the app needs auth, provide an `authentication_id` that has the `selected_api` of the app you want to run. Can be any auth visible to the user (including shared).",
|
|
414
|
+
),
|
|
415
|
+
params: z
|
|
416
|
+
.record(z.any())
|
|
417
|
+
.optional()
|
|
418
|
+
.describe(
|
|
419
|
+
"Object that matches the input the node would normally get. Has all the same keys/types as the `needs` of the action.",
|
|
420
|
+
),
|
|
421
|
+
page: z.number().optional().default(0),
|
|
422
|
+
prefill: z
|
|
423
|
+
.string()
|
|
424
|
+
.optional()
|
|
425
|
+
.describe(
|
|
426
|
+
"The prefill string to indicate what we're fetching choices for. Likely something like `spreadsheet.id.title`. Must be provided alongside `selected_api` if both `action_id` and `input_field_id` are not.",
|
|
427
|
+
),
|
|
428
|
+
action_id: z
|
|
429
|
+
.string()
|
|
430
|
+
.optional()
|
|
431
|
+
.describe(
|
|
432
|
+
"The id that will be used to lookup the Action for prefill lookup. If provided, `input_field_id` is required, else `prefill` must be provided.",
|
|
433
|
+
),
|
|
434
|
+
input_field_id: z
|
|
435
|
+
.string()
|
|
436
|
+
.optional()
|
|
437
|
+
.describe(
|
|
438
|
+
"The id (key) of the input field (Need) that dynamic choices are being retrieved for. If provided, `action_id` is required, else `prefill` must be provided.",
|
|
439
|
+
),
|
|
440
|
+
});
|
|
441
|
+
|
|
442
|
+
export const NeedChoicesResponseSchema = z.object({
|
|
443
|
+
success: z.boolean(),
|
|
444
|
+
choices: z.array(NeedChoicesSchema).optional(),
|
|
445
|
+
next_page: z.number().optional(),
|
|
446
|
+
errors: z.array(z.string()).optional(),
|
|
447
|
+
meta: NeedChoicesResponseMetaSchema.optional(),
|
|
448
|
+
links: NeedChoicesResponseLinksSchema.optional(),
|
|
449
|
+
});
|
package/src/api/types.ts
CHANGED
|
@@ -33,6 +33,10 @@ import {
|
|
|
33
33
|
ImplementationsMetaResponseSchema,
|
|
34
34
|
ServiceSchema,
|
|
35
35
|
ServicesResponseSchema,
|
|
36
|
+
NeedChoicesRequestSchema,
|
|
37
|
+
NeedChoicesResponseSchema,
|
|
38
|
+
NeedChoicesResponseMetaSchema,
|
|
39
|
+
NeedChoicesResponseLinksSchema,
|
|
36
40
|
} from "./schemas";
|
|
37
41
|
|
|
38
42
|
// ============================================================================
|
|
@@ -136,3 +140,13 @@ export type ImplementationMeta = z.infer<typeof ImplementationMetaSchema>;
|
|
|
136
140
|
export type ImplementationsMetaResponse = z.infer<
|
|
137
141
|
typeof ImplementationsMetaResponseSchema
|
|
138
142
|
>;
|
|
143
|
+
|
|
144
|
+
// Need Choices types (for listInputFieldChoices functionality)
|
|
145
|
+
export type NeedChoicesRequest = z.infer<typeof NeedChoicesRequestSchema>;
|
|
146
|
+
export type NeedChoicesResponse = z.infer<typeof NeedChoicesResponseSchema>;
|
|
147
|
+
export type NeedChoicesResponseMeta = z.infer<
|
|
148
|
+
typeof NeedChoicesResponseMetaSchema
|
|
149
|
+
>;
|
|
150
|
+
export type NeedChoicesResponseLinks = z.infer<
|
|
151
|
+
typeof NeedChoicesResponseLinksSchema
|
|
152
|
+
>;
|
|
@@ -97,7 +97,7 @@ describe("findFirstAuthentication plugin", () => {
|
|
|
97
97
|
await expect(
|
|
98
98
|
sdk.findFirstAuthentication({
|
|
99
99
|
title: 123 as any,
|
|
100
|
-
|
|
100
|
+
accountId: 456 as any,
|
|
101
101
|
owner: true as any,
|
|
102
102
|
}),
|
|
103
103
|
).rejects.toThrow(ZapierValidationError);
|
|
@@ -109,7 +109,7 @@ describe("findFirstAuthentication plugin", () => {
|
|
|
109
109
|
appKey: "slack",
|
|
110
110
|
search: "workspace",
|
|
111
111
|
title: "My Slack Workspace",
|
|
112
|
-
|
|
112
|
+
accountId: "acc_123",
|
|
113
113
|
owner: "me",
|
|
114
114
|
});
|
|
115
115
|
|
|
@@ -167,7 +167,7 @@ describe("findFirstAuthentication plugin", () => {
|
|
|
167
167
|
appKey: "slack",
|
|
168
168
|
search: "workspace",
|
|
169
169
|
title: "My Slack Workspace",
|
|
170
|
-
|
|
170
|
+
accountId: "acc_123",
|
|
171
171
|
owner: "me",
|
|
172
172
|
};
|
|
173
173
|
|
|
@@ -16,7 +16,7 @@ export const FindFirstAuthenticationSchema = z
|
|
|
16
16
|
.string()
|
|
17
17
|
.optional()
|
|
18
18
|
.describe("Filter authentications by exact title match"),
|
|
19
|
-
|
|
19
|
+
accountId: z.string().optional().describe("Filter by account ID"),
|
|
20
20
|
owner: z.string().optional().describe("Filter by owner"),
|
|
21
21
|
})
|
|
22
22
|
.describe("Find the first authentication matching the criteria");
|
|
@@ -88,7 +88,7 @@ describe("findUniqueAuthentication plugin", () => {
|
|
|
88
88
|
sdk.findUniqueAuthentication({
|
|
89
89
|
search: 123 as any,
|
|
90
90
|
title: 456 as any,
|
|
91
|
-
|
|
91
|
+
accountId: 789 as any,
|
|
92
92
|
owner: false as any,
|
|
93
93
|
}),
|
|
94
94
|
).rejects.toThrow(ZapierValidationError);
|
|
@@ -100,7 +100,7 @@ describe("findUniqueAuthentication plugin", () => {
|
|
|
100
100
|
appKey: "slack",
|
|
101
101
|
search: "Workspace",
|
|
102
102
|
title: "My Slack",
|
|
103
|
-
|
|
103
|
+
accountId: "acc_123",
|
|
104
104
|
owner: "me",
|
|
105
105
|
});
|
|
106
106
|
|
|
@@ -172,7 +172,7 @@ describe("findUniqueAuthentication plugin", () => {
|
|
|
172
172
|
appKey: "slack",
|
|
173
173
|
search: "workspace",
|
|
174
174
|
title: "My Slack Workspace",
|
|
175
|
-
|
|
175
|
+
accountId: "acc_123",
|
|
176
176
|
owner: "me",
|
|
177
177
|
};
|
|
178
178
|
|
|
@@ -16,7 +16,7 @@ export const FindUniqueAuthenticationSchema = z
|
|
|
16
16
|
.string()
|
|
17
17
|
.optional()
|
|
18
18
|
.describe("Filter authentications by exact title match"),
|
|
19
|
-
|
|
19
|
+
accountId: z.string().optional().describe("Filter by account ID"),
|
|
20
20
|
owner: z.string().optional().describe("Filter by owner"),
|
|
21
21
|
})
|
|
22
22
|
.describe("Find a unique authentication matching the criteria");
|
|
@@ -134,11 +134,11 @@ describe("listAuthentications plugin", () => {
|
|
|
134
134
|
}).toThrow(ZapierValidationError);
|
|
135
135
|
});
|
|
136
136
|
|
|
137
|
-
it("should throw validation error for invalid
|
|
137
|
+
it("should throw validation error for invalid accountId type", () => {
|
|
138
138
|
const sdk = createTestSdk();
|
|
139
139
|
expect(() => {
|
|
140
140
|
sdk.listAuthentications({
|
|
141
|
-
|
|
141
|
+
accountId: 123 as any,
|
|
142
142
|
});
|
|
143
143
|
}).toThrow(ZapierValidationError);
|
|
144
144
|
});
|
|
@@ -188,7 +188,7 @@ describe("listAuthentications plugin", () => {
|
|
|
188
188
|
appKey: "slack",
|
|
189
189
|
search: "workspace",
|
|
190
190
|
title: "My Slack Workspace",
|
|
191
|
-
|
|
191
|
+
accountId: "acc_123",
|
|
192
192
|
owner: "me",
|
|
193
193
|
pageSize: 10,
|
|
194
194
|
maxItems: 50,
|
|
@@ -309,9 +309,9 @@ describe("listAuthentications plugin", () => {
|
|
|
309
309
|
);
|
|
310
310
|
});
|
|
311
311
|
|
|
312
|
-
it("should pass
|
|
312
|
+
it("should pass accountId filter to API", async () => {
|
|
313
313
|
const sdk = createTestSdk();
|
|
314
|
-
await sdk.listAuthentications({
|
|
314
|
+
await sdk.listAuthentications({ accountId: "acc_123" });
|
|
315
315
|
|
|
316
316
|
expect(mockApiClient.get).toHaveBeenCalledWith(
|
|
317
317
|
"/api/v4/authentications/",
|
|
@@ -71,8 +71,8 @@ export const listAuthenticationsPlugin: Plugin<
|
|
|
71
71
|
} else if (options.title) {
|
|
72
72
|
searchParams.search = options.title;
|
|
73
73
|
}
|
|
74
|
-
if (options.
|
|
75
|
-
searchParams.account_id = options.
|
|
74
|
+
if (options.accountId) {
|
|
75
|
+
searchParams.account_id = options.accountId;
|
|
76
76
|
}
|
|
77
77
|
if (options.owner) {
|
|
78
78
|
searchParams.owner = options.owner;
|
|
@@ -83,7 +83,6 @@ export const listAuthenticationsPlugin: Plugin<
|
|
|
83
83
|
// Convert cursor back to offset for the API
|
|
84
84
|
searchParams.offset = options.cursor;
|
|
85
85
|
}
|
|
86
|
-
console.log({ searchParams });
|
|
87
86
|
const data: AuthenticationsResponse = await api.get(
|
|
88
87
|
"/api/v4/authentications/",
|
|
89
88
|
{
|
|
@@ -17,7 +17,7 @@ export const ListAuthenticationsSchema = z
|
|
|
17
17
|
.string()
|
|
18
18
|
.optional()
|
|
19
19
|
.describe("Filter authentications by exact title match"),
|
|
20
|
-
|
|
20
|
+
accountId: z.string().optional().describe("Filter by account ID"),
|
|
21
21
|
owner: z.string().optional().describe("Filter by owner"),
|
|
22
22
|
pageSize: z
|
|
23
23
|
.number()
|