@zapier/zapier-sdk 0.9.0 → 0.10.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 +7 -7
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +14 -0
- package/dist/api/debug.d.ts +1 -0
- package/dist/api/debug.d.ts.map +1 -1
- package/dist/api/debug.js +42 -1
- package/dist/api/debug.test.d.ts +2 -0
- package/dist/api/debug.test.d.ts.map +1 -0
- package/dist/api/debug.test.js +59 -0
- package/dist/api/schemas.d.ts +451 -251
- package/dist/api/schemas.d.ts.map +1 -1
- package/dist/api/schemas.js +51 -29
- package/dist/index.cjs +834 -563
- package/dist/index.d.mts +2287 -2085
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.mjs +832 -557
- package/dist/plugins/findFirstAuthentication/index.d.ts +1 -1
- package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/findFirstAuthentication/index.js +9 -1
- package/dist/plugins/findFirstAuthentication/index.test.js +3 -4
- package/dist/plugins/findFirstAuthentication/schemas.d.ts +5 -3
- package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +1 -1
- package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/findUniqueAuthentication/index.js +4 -0
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts +5 -3
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +1 -1
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +10 -0
- package/dist/plugins/getAction/schemas.d.ts +5 -3
- package/dist/plugins/getAction/schemas.d.ts.map +1 -1
- package/dist/plugins/getApp/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.js +8 -0
- package/dist/plugins/getApp/index.test.js +2 -2
- package/dist/plugins/getApp/schemas.d.ts +3 -1
- package/dist/plugins/getApp/schemas.d.ts.map +1 -1
- package/dist/plugins/getApp/schemas.js +2 -4
- package/dist/plugins/getAuthentication/index.d.ts.map +1 -1
- package/dist/plugins/getAuthentication/index.js +8 -0
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +4 -0
- package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
- package/dist/plugins/getProfile/schemas.js +4 -3
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +9 -0
- package/dist/plugins/listActions/schemas.d.ts +5 -3
- package/dist/plugins/listActions/schemas.d.ts.map +1 -1
- package/dist/plugins/listActions/schemas.js +2 -4
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +4 -0
- package/dist/plugins/listApps/index.test.js +1 -1
- package/dist/plugins/listApps/schemas.d.ts.map +1 -1
- package/dist/plugins/listApps/schemas.js +3 -9
- package/dist/plugins/listAuthentications/index.d.ts.map +1 -1
- package/dist/plugins/listAuthentications/index.js +8 -0
- package/dist/plugins/listAuthentications/schemas.d.ts +5 -3
- package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.js +14 -2
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +5 -3
- package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/schemas.js +10 -19
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +14 -2
- package/dist/plugins/listInputFields/index.test.js +5 -9
- package/dist/plugins/listInputFields/schemas.d.ts +5 -3
- package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +8 -2
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +1 -0
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +12 -0
- package/dist/plugins/runAction/schemas.d.ts +5 -3
- package/dist/plugins/runAction/schemas.d.ts.map +1 -1
- package/dist/resolvers/actionKey.d.ts +13 -7
- package/dist/resolvers/actionKey.d.ts.map +1 -1
- package/dist/resolvers/actionType.d.ts +8 -7
- package/dist/resolvers/actionType.d.ts.map +1 -1
- package/dist/resolvers/appKey.d.ts +2 -6
- package/dist/resolvers/appKey.d.ts.map +1 -1
- package/dist/resolvers/authenticationId.d.ts +7 -7
- package/dist/resolvers/authenticationId.d.ts.map +1 -1
- package/dist/resolvers/authenticationId.js +16 -7
- package/dist/resolvers/index.d.ts +3 -35
- package/dist/resolvers/index.d.ts.map +1 -1
- package/dist/resolvers/index.js +4 -87
- package/dist/resolvers/inputFieldKey.d.ts +11 -0
- package/dist/resolvers/inputFieldKey.d.ts.map +1 -0
- package/dist/resolvers/inputFieldKey.js +23 -0
- package/dist/resolvers/inputs.d.ts +11 -6
- package/dist/resolvers/inputs.d.ts.map +1 -1
- package/dist/resolvers/inputs.js +17 -0
- package/dist/schemas/Action.d.ts +8 -8
- package/dist/schemas/Action.d.ts.map +1 -1
- package/dist/schemas/Action.js +8 -3
- package/dist/schemas/App.d.ts +183 -11
- package/dist/schemas/App.d.ts.map +1 -1
- package/dist/schemas/App.js +7 -9
- package/dist/schemas/Auth.d.ts +12 -12
- package/dist/schemas/Auth.js +1 -1
- package/dist/schemas/Field.d.ts +5 -98
- package/dist/schemas/Field.d.ts.map +1 -1
- package/dist/schemas/Field.js +24 -52
- package/dist/schemas/Run.d.ts +3 -0
- package/dist/schemas/Run.d.ts.map +1 -0
- package/dist/schemas/Run.js +31 -0
- package/dist/schemas/UserProfile.d.ts +11 -11
- package/dist/schemas/UserProfile.d.ts.map +1 -1
- package/dist/schemas/UserProfile.js +21 -7
- package/dist/sdk.d.ts +11 -4
- package/dist/sdk.d.ts.map +1 -1
- package/dist/types/plugin.d.ts +5 -0
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/properties.d.ts +3 -1
- package/dist/types/properties.d.ts.map +1 -1
- package/dist/types/sdk.d.ts +5 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/utils/domain-utils.d.ts +1 -16
- package/dist/utils/domain-utils.d.ts.map +1 -1
- package/dist/utils/domain-utils.js +7 -51
- package/dist/utils/schema-utils.d.ts +44 -21
- package/dist/utils/schema-utils.d.ts.map +1 -1
- package/dist/utils/schema-utils.js +17 -11
- package/package.json +1 -1
- package/src/api/client.ts +12 -0
- package/src/api/debug.test.ts +76 -0
- package/src/api/debug.ts +46 -2
- package/src/api/schemas.ts +51 -29
- package/src/index.ts +4 -5
- package/src/plugins/findFirstAuthentication/index.test.ts +8 -5
- package/src/plugins/findFirstAuthentication/index.ts +14 -2
- package/src/plugins/findUniqueAuthentication/index.ts +4 -0
- package/src/plugins/getAction/index.ts +14 -0
- package/src/plugins/getApp/index.test.ts +2 -2
- package/src/plugins/getApp/index.ts +8 -0
- package/src/plugins/getApp/schemas.ts +7 -12
- package/src/plugins/getAuthentication/index.ts +8 -0
- package/src/plugins/getProfile/index.ts +4 -0
- package/src/plugins/getProfile/schemas.ts +4 -6
- package/src/plugins/listActions/index.ts +9 -0
- package/src/plugins/listActions/schemas.ts +20 -25
- package/src/plugins/listApps/index.test.ts +1 -1
- package/src/plugins/listApps/index.ts +4 -0
- package/src/plugins/listApps/schemas.ts +17 -26
- package/src/plugins/listAuthentications/index.ts +8 -0
- package/src/plugins/listInputFieldChoices/index.ts +21 -1
- package/src/plugins/listInputFieldChoices/schemas.ts +61 -76
- package/src/plugins/listInputFields/index.test.ts +5 -9
- package/src/plugins/listInputFields/index.ts +20 -2
- package/src/plugins/registry/index.ts +8 -2
- package/src/plugins/request/index.ts +1 -0
- package/src/plugins/runAction/index.ts +18 -0
- package/src/resolvers/actionKey.ts +15 -13
- package/src/resolvers/actionType.ts +10 -12
- package/src/resolvers/appKey.ts +2 -6
- package/src/resolvers/authenticationId.ts +25 -19
- package/src/resolvers/index.ts +7 -113
- package/src/resolvers/inputFieldKey.ts +38 -0
- package/src/resolvers/inputs.ts +28 -10
- package/src/schemas/Action.ts +8 -3
- package/src/schemas/App.ts +7 -9
- package/src/schemas/Auth.ts +1 -1
- package/src/schemas/Field.ts +24 -57
- package/src/schemas/Run.ts +40 -0
- package/src/schemas/UserProfile.ts +24 -7
- package/src/sdk.ts +17 -7
- package/src/types/plugin.ts +5 -0
- package/src/types/sdk.ts +5 -0
- package/src/utils/domain-utils.ts +9 -67
- package/src/utils/schema-utils.ts +96 -44
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -20,42 +20,6 @@ export function splitVersionedKey(versionedKey) {
|
|
|
20
20
|
}
|
|
21
21
|
return [versionedKey, undefined];
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Converts an API App to an AppItem with normalized field names
|
|
25
|
-
*
|
|
26
|
-
* @param app - Raw App from API
|
|
27
|
-
* @returns Normalized AppItem
|
|
28
|
-
*/
|
|
29
|
-
export function normalizeAppItem(app) {
|
|
30
|
-
// Extract API name and version from current_implementation_id
|
|
31
|
-
const [apiName, appVersion] = app.current_implementation_id
|
|
32
|
-
? splitVersionedKey(app.current_implementation_id)
|
|
33
|
-
: [app.current_implementation_id || "", undefined];
|
|
34
|
-
return {
|
|
35
|
-
title: app.name,
|
|
36
|
-
key: app.slug || apiName,
|
|
37
|
-
current_implementation_id: app.current_implementation_id || "",
|
|
38
|
-
version: appVersion, // Extract version separately
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Converts an Implementation to an AppItem with normalized field names
|
|
43
|
-
*
|
|
44
|
-
* @param implementation - Raw Implementation from API
|
|
45
|
-
* @returns Normalized AppItem
|
|
46
|
-
*/
|
|
47
|
-
export function normalizeImplementationToAppItem(implementation) {
|
|
48
|
-
// Extract API name and version from selected_api
|
|
49
|
-
const [selectedApi, appVersion] = implementation.selected_api
|
|
50
|
-
? splitVersionedKey(implementation.selected_api)
|
|
51
|
-
: [implementation.selected_api || "", undefined];
|
|
52
|
-
return {
|
|
53
|
-
title: implementation.name || selectedApi,
|
|
54
|
-
key: selectedApi,
|
|
55
|
-
current_implementation_id: implementation.selected_api || "",
|
|
56
|
-
version: appVersion, // Extract version separately
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
23
|
/**
|
|
60
24
|
* Converts a lightweight ImplementationMeta to a slimmed AppItem
|
|
61
25
|
*
|
|
@@ -65,24 +29,16 @@ export function normalizeImplementationToAppItem(implementation) {
|
|
|
65
29
|
export function normalizeImplementationMetaToAppItem(implementationMeta) {
|
|
66
30
|
// Extract API name and version from the implementation ID
|
|
67
31
|
const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
|
|
32
|
+
// Destructure to exclude id and name before spreading
|
|
33
|
+
const { id, name, ...restOfImplementationMeta } = implementationMeta;
|
|
68
34
|
return {
|
|
69
|
-
|
|
35
|
+
// Pass through all ImplementationMeta fields except id and name
|
|
36
|
+
...restOfImplementationMeta,
|
|
37
|
+
// Transform key fields
|
|
38
|
+
title: name,
|
|
70
39
|
key: selectedApi,
|
|
71
|
-
|
|
40
|
+
implementation_id: id, // Keep the full versioned ID
|
|
72
41
|
version: appVersion, // Extract version separately
|
|
73
|
-
slug: implementationMeta.slug,
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
export function normalizeServiceToAppItem(service) {
|
|
77
|
-
const [selectedApi, appVersion] = service.current_implementation_id
|
|
78
|
-
? splitVersionedKey(service.current_implementation_id)
|
|
79
|
-
: ["", undefined];
|
|
80
|
-
return {
|
|
81
|
-
title: service.name,
|
|
82
|
-
key: selectedApi,
|
|
83
|
-
current_implementation_id: service.current_implementation_id,
|
|
84
|
-
version: appVersion,
|
|
85
|
-
description: service.description,
|
|
86
42
|
};
|
|
87
43
|
}
|
|
88
44
|
/**
|
|
@@ -1,45 +1,68 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import type { ZapierSdk } from "../types/sdk";
|
|
3
|
+
import type { InputFieldItem } from "../schemas/Field";
|
|
2
4
|
export interface FormattedItem {
|
|
3
5
|
title: string;
|
|
4
|
-
|
|
6
|
+
id?: string;
|
|
7
|
+
key?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
data?: unknown;
|
|
5
10
|
details: Array<{
|
|
6
11
|
text: string;
|
|
7
12
|
style: "normal" | "dim" | "accent" | "warning" | "success";
|
|
8
13
|
}>;
|
|
9
14
|
}
|
|
10
|
-
export interface FormatMetadata {
|
|
11
|
-
format: (item:
|
|
15
|
+
export interface FormatMetadata<TItem = unknown> {
|
|
16
|
+
format: (item: TItem) => FormattedItem;
|
|
12
17
|
}
|
|
13
|
-
export declare function withFormatter<T extends z.ZodType>(schema: T, formatMeta: FormatMetadata): T;
|
|
14
|
-
export declare function getFormatMetadata(schema: z.ZodType): FormatMetadata | undefined;
|
|
15
|
-
export declare function withOutputSchema<T extends z.ZodType>(inputSchema: T, outputSchema: z.ZodType): T;
|
|
18
|
+
export declare function withFormatter<T extends z.ZodType>(schema: T, formatMeta: FormatMetadata<z.infer<T>>): T;
|
|
16
19
|
export declare function getOutputSchema(inputSchema: z.ZodType): z.ZodType | undefined;
|
|
17
|
-
export
|
|
20
|
+
export declare function withOutputSchema<T extends z.ZodType>(inputSchema: T, outputSchema: z.ZodType): T & {
|
|
21
|
+
_def: T["_def"] & {
|
|
22
|
+
outputSchema: z.ZodType;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export interface PromptConfig {
|
|
26
|
+
type: "list";
|
|
27
|
+
name: string;
|
|
28
|
+
message: string;
|
|
29
|
+
choices: Array<{
|
|
30
|
+
name: string;
|
|
31
|
+
value: unknown;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
export interface Resolver {
|
|
35
|
+
type: string;
|
|
36
|
+
depends?: readonly string[] | string[];
|
|
37
|
+
}
|
|
38
|
+
export interface StaticResolver extends Resolver {
|
|
18
39
|
type: "static";
|
|
19
40
|
inputType?: "text" | "password" | "email";
|
|
20
41
|
placeholder?: string;
|
|
21
42
|
}
|
|
22
|
-
export interface DynamicResolver {
|
|
43
|
+
export interface DynamicResolver<TItem = unknown, TParams = Record<string, unknown>> extends Resolver {
|
|
23
44
|
type: "dynamic";
|
|
24
|
-
fetch: (sdk:
|
|
25
|
-
prompt: (items:
|
|
26
|
-
depends?: string[];
|
|
45
|
+
fetch: (sdk: ZapierSdk, resolvedParams: TParams) => Promise<TItem[]>;
|
|
46
|
+
prompt: (items: TItem[], params: TParams) => PromptConfig;
|
|
27
47
|
}
|
|
28
|
-
export interface FieldsResolver {
|
|
48
|
+
export interface FieldsResolver<TParams = Record<string, unknown>> extends Resolver {
|
|
29
49
|
type: "fields";
|
|
30
|
-
fetch: (sdk:
|
|
31
|
-
depends?: string[];
|
|
50
|
+
fetch: (sdk: ZapierSdk, resolvedParams: TParams) => Promise<InputFieldItem[]>;
|
|
32
51
|
}
|
|
33
|
-
export type ResolverMetadata = StaticResolver | DynamicResolver | FieldsResolver
|
|
34
|
-
export interface ResolverConfig {
|
|
35
|
-
resolver: ResolverMetadata
|
|
52
|
+
export type ResolverMetadata<TItem = unknown, TParams = Record<string, unknown>> = StaticResolver | DynamicResolver<TItem, TParams> | FieldsResolver<TParams>;
|
|
53
|
+
export interface ResolverConfig<TItem = unknown, TParams = Record<string, unknown>> {
|
|
54
|
+
resolver: ResolverMetadata<TItem, TParams>;
|
|
36
55
|
}
|
|
37
|
-
export declare function withResolver<T extends z.ZodType
|
|
56
|
+
export declare function withResolver<T extends z.ZodType, TItem = unknown, TParams = Record<string, unknown>>(schema: T, config: ResolverConfig<TItem, TParams>): T;
|
|
38
57
|
export declare function getSchemaDescription(schema: z.ZodSchema): string | undefined;
|
|
39
|
-
export declare function getFieldDescriptions(schema: z.ZodObject<
|
|
58
|
+
export declare function getFieldDescriptions(schema: z.ZodObject<z.ZodRawShape>): Record<string, string>;
|
|
40
59
|
export interface PositionalMetadata {
|
|
41
|
-
|
|
60
|
+
positionalMeta: {
|
|
61
|
+
positional: true;
|
|
62
|
+
};
|
|
42
63
|
}
|
|
43
|
-
export declare function withPositional<T extends z.ZodType>(schema: T): T
|
|
64
|
+
export declare function withPositional<T extends z.ZodType>(schema: T): T & {
|
|
65
|
+
_def: T["_def"] & PositionalMetadata;
|
|
66
|
+
};
|
|
44
67
|
export declare function isPositional(schema: z.ZodType): boolean;
|
|
45
68
|
//# sourceMappingURL=schema-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-utils.d.ts","sourceRoot":"","sources":["../../src/utils/schema-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schema-utils.d.ts","sourceRoot":"","sources":["../../src/utils/schema-utils.ts"],"names":[],"mappings":"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"}
|
|
@@ -2,23 +2,23 @@ import { z } from "zod";
|
|
|
2
2
|
// Helper function to add format metadata to schemas
|
|
3
3
|
export function withFormatter(schema, formatMeta) {
|
|
4
4
|
// Store format metadata on the schema definition
|
|
5
|
-
schema._def
|
|
5
|
+
Object.assign(schema._def, {
|
|
6
|
+
formatMeta: formatMeta,
|
|
7
|
+
});
|
|
6
8
|
return schema;
|
|
7
9
|
}
|
|
8
|
-
// Helper function to get
|
|
9
|
-
export function
|
|
10
|
-
return
|
|
10
|
+
// Helper function to get output schema from an input schema
|
|
11
|
+
export function getOutputSchema(inputSchema) {
|
|
12
|
+
return inputSchema._def.outputSchema;
|
|
11
13
|
}
|
|
12
14
|
// Helper function to link input schemas to output schemas
|
|
13
15
|
export function withOutputSchema(inputSchema, outputSchema) {
|
|
14
16
|
// Store output schema reference on the input schema
|
|
15
|
-
inputSchema._def
|
|
17
|
+
Object.assign(inputSchema._def, {
|
|
18
|
+
outputSchema,
|
|
19
|
+
});
|
|
16
20
|
return inputSchema;
|
|
17
21
|
}
|
|
18
|
-
// Helper function to get output schema from an input schema
|
|
19
|
-
export function getOutputSchema(inputSchema) {
|
|
20
|
-
return inputSchema._def.outputSchema;
|
|
21
|
-
}
|
|
22
22
|
// Helper function to add resolver metadata to schemas
|
|
23
23
|
export function withResolver(schema, config) {
|
|
24
24
|
// Store resolver metadata on the schema definition
|
|
@@ -44,13 +44,19 @@ export function getFieldDescriptions(schema) {
|
|
|
44
44
|
// Helper function to mark a parameter as positional for CLI
|
|
45
45
|
export function withPositional(schema) {
|
|
46
46
|
// Store positional metadata on the schema definition
|
|
47
|
-
schema._def
|
|
47
|
+
Object.assign(schema._def, {
|
|
48
|
+
positionalMeta: { positional: true },
|
|
49
|
+
});
|
|
48
50
|
return schema;
|
|
49
51
|
}
|
|
52
|
+
function schemaHasPositionalMeta(schema) {
|
|
53
|
+
return "positionalMeta" in schema._def;
|
|
54
|
+
}
|
|
50
55
|
// Helper function to check if a parameter should be positional
|
|
51
56
|
export function isPositional(schema) {
|
|
52
57
|
// Check the current schema first
|
|
53
|
-
if (schema
|
|
58
|
+
if (schemaHasPositionalMeta(schema) &&
|
|
59
|
+
schema._def.positionalMeta?.positional) {
|
|
54
60
|
return true;
|
|
55
61
|
}
|
|
56
62
|
// If this is a ZodOptional, check the inner type
|
package/package.json
CHANGED
package/src/api/client.ts
CHANGED
|
@@ -188,6 +188,18 @@ class ZapierApiClient implements ApiClient {
|
|
|
188
188
|
if ("errors" in data && Array.isArray(data.errors)) {
|
|
189
189
|
if (this.isApiErrorArray(data.errors)) {
|
|
190
190
|
return data.errors[0].detail || data.errors[0].title;
|
|
191
|
+
} else if (data.errors.length > 0) {
|
|
192
|
+
// Handle simple string errors array
|
|
193
|
+
const firstError = data.errors[0];
|
|
194
|
+
if (typeof firstError === "string") {
|
|
195
|
+
return firstError;
|
|
196
|
+
}
|
|
197
|
+
// For non-string errors, stringify them
|
|
198
|
+
try {
|
|
199
|
+
return JSON.stringify(firstError);
|
|
200
|
+
} catch {
|
|
201
|
+
return String(firstError);
|
|
202
|
+
}
|
|
191
203
|
}
|
|
192
204
|
}
|
|
193
205
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { censorHeaders } from "./debug";
|
|
3
|
+
|
|
4
|
+
describe("censorHeaders", () => {
|
|
5
|
+
it("should return undefined for undefined headers", () => {
|
|
6
|
+
expect(censorHeaders(undefined)).toBeUndefined();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("should return headers unchanged for non-auth headers", () => {
|
|
10
|
+
const headers = {
|
|
11
|
+
"Content-Type": "application/json",
|
|
12
|
+
"User-Agent": "test",
|
|
13
|
+
};
|
|
14
|
+
const result = censorHeaders(headers);
|
|
15
|
+
// Headers API normalizes header names to lowercase
|
|
16
|
+
expect(result!["content-type"]).toBe("application/json");
|
|
17
|
+
expect(result!["user-agent"]).toBe("test");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("should censor authorization header with Bearer prefix - long token", () => {
|
|
21
|
+
const headers = { authorization: "Bearer abcdef1234567890xyz" };
|
|
22
|
+
const result = censorHeaders(headers);
|
|
23
|
+
|
|
24
|
+
expect(result!.authorization).toBe("Bearer abcd...0xyz");
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should censor authorization header with Bearer prefix - short token", () => {
|
|
28
|
+
const headers = { authorization: "Bearer short123" };
|
|
29
|
+
const result = censorHeaders(headers);
|
|
30
|
+
|
|
31
|
+
expect(result!.authorization).toBe("Bearer s...");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should censor x-api-key header - long token", () => {
|
|
35
|
+
const headers = { "x-api-key": "sk-1234567890abcdefghij" };
|
|
36
|
+
const result = censorHeaders(headers);
|
|
37
|
+
|
|
38
|
+
expect(result!["x-api-key"]).toBe("sk-1...ghij");
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("should censor x-api-key header - short token", () => {
|
|
42
|
+
const headers = { "x-api-key": "short" };
|
|
43
|
+
const result = censorHeaders(headers);
|
|
44
|
+
|
|
45
|
+
expect(result!["x-api-key"]).toBe("s...");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("should handle Headers object input", () => {
|
|
49
|
+
const headers = new Headers();
|
|
50
|
+
headers.set("authorization", "Bearer verylongtoken123456789");
|
|
51
|
+
|
|
52
|
+
const result = censorHeaders(headers);
|
|
53
|
+
expect(result!.authorization).toBe("Bearer very...6789");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("should handle mixed case authorization headers", () => {
|
|
57
|
+
const headers = { Authorization: "Bearer mixedcasetoken123" };
|
|
58
|
+
const result = censorHeaders(headers);
|
|
59
|
+
|
|
60
|
+
expect(result!.authorization).toBe("Bearer mixe...n123");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("should preserve non-auth headers while censoring auth headers", () => {
|
|
64
|
+
const headers = {
|
|
65
|
+
"Content-Type": "application/json",
|
|
66
|
+
authorization: "Bearer shouldbecensored123456789",
|
|
67
|
+
"User-Agent": "test-agent",
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const result = censorHeaders(headers);
|
|
71
|
+
|
|
72
|
+
expect(result!["content-type"]).toBe("application/json");
|
|
73
|
+
expect(result!["user-agent"]).toBe("test-agent");
|
|
74
|
+
expect(result!.authorization).toBe("Bearer shou...6789");
|
|
75
|
+
});
|
|
76
|
+
});
|
package/src/api/debug.ts
CHANGED
|
@@ -12,11 +12,55 @@ export function createDebugLogger(enabled: boolean): DebugLogger {
|
|
|
12
12
|
return () => {}; // No-op function when debug is disabled
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
return (message: string, data?:
|
|
15
|
+
return (message: string, data?: unknown) => {
|
|
16
16
|
console.log(`[Zapier SDK] ${message}`, data || "");
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
export function censorHeaders(
|
|
21
|
+
headers?: HeadersInit,
|
|
22
|
+
): Record<string, string> | undefined {
|
|
23
|
+
if (!headers) return headers;
|
|
24
|
+
|
|
25
|
+
const headersObj = new Headers(headers);
|
|
26
|
+
const authKeys = ["authorization", "x-api-key"];
|
|
27
|
+
|
|
28
|
+
for (const [key, value] of headersObj.entries()) {
|
|
29
|
+
if (authKeys.some((authKey) => key.toLowerCase() === authKey)) {
|
|
30
|
+
// Find space after prefix (like "Bearer ")
|
|
31
|
+
const spaceIndex = value.indexOf(" ");
|
|
32
|
+
if (spaceIndex > 0 && spaceIndex < value.length - 1) {
|
|
33
|
+
const prefix = value.substring(0, spaceIndex + 1); // Include the space
|
|
34
|
+
const token = value.substring(spaceIndex + 1);
|
|
35
|
+
|
|
36
|
+
if (token.length > 12) {
|
|
37
|
+
// Show first 4 and last 4 chars, truncate middle
|
|
38
|
+
const start = token.substring(0, 4);
|
|
39
|
+
const end = token.substring(token.length - 4);
|
|
40
|
+
headersObj.set(key, `${prefix}${start}...${end}`);
|
|
41
|
+
} else {
|
|
42
|
+
// Short token, use first character + three dots
|
|
43
|
+
const firstChar = token.charAt(0);
|
|
44
|
+
headersObj.set(key, `${prefix}${firstChar}...`);
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
// No prefix found, truncate the whole value
|
|
48
|
+
if (value.length > 12) {
|
|
49
|
+
const start = value.substring(0, 4);
|
|
50
|
+
const end = value.substring(value.length - 4);
|
|
51
|
+
headersObj.set(key, `${start}...${end}`);
|
|
52
|
+
} else {
|
|
53
|
+
// Short token, use first character + three dots
|
|
54
|
+
const firstChar = value.charAt(0);
|
|
55
|
+
headersObj.set(key, `${firstChar}...`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return Object.fromEntries(headersObj);
|
|
62
|
+
}
|
|
63
|
+
|
|
20
64
|
export function createDebugFetch(options: {
|
|
21
65
|
originalFetch: typeof globalThis.fetch;
|
|
22
66
|
debugLog: DebugLogger;
|
|
@@ -30,7 +74,7 @@ export function createDebugFetch(options: {
|
|
|
30
74
|
const method = options?.method || "GET";
|
|
31
75
|
|
|
32
76
|
debugLog(`→ ${method} ${url}`, {
|
|
33
|
-
headers: options?.headers,
|
|
77
|
+
headers: censorHeaders(options?.headers),
|
|
34
78
|
body:
|
|
35
79
|
options?.body && typeof options.body === "string"
|
|
36
80
|
? (() => {
|
package/src/api/schemas.ts
CHANGED
|
@@ -118,7 +118,7 @@ export const FieldSchema = z.object({
|
|
|
118
118
|
});
|
|
119
119
|
|
|
120
120
|
export const ActionExecutionResultSchema = z.object({
|
|
121
|
-
data: z.array(z.
|
|
121
|
+
data: z.array(z.unknown()),
|
|
122
122
|
});
|
|
123
123
|
|
|
124
124
|
export const ActionFieldChoiceSchema = z.object({
|
|
@@ -217,9 +217,9 @@ export const UserProfileSchema = z.object({
|
|
|
217
217
|
enable_totp_2fa: z.boolean(),
|
|
218
218
|
viewed_help: z.record(z.boolean()),
|
|
219
219
|
show_editor_migration_mesaging: z.boolean(),
|
|
220
|
-
switches: z.record(z.
|
|
221
|
-
organizations: z.array(z.
|
|
222
|
-
primary_organization: z.
|
|
220
|
+
switches: z.record(z.unknown()),
|
|
221
|
+
organizations: z.array(z.record(z.unknown()).nullable()),
|
|
222
|
+
primary_organization: z.record(z.unknown()).nullable(),
|
|
223
223
|
has_active_zaps: z.boolean(),
|
|
224
224
|
has_google_sso: z.boolean(),
|
|
225
225
|
auth_realm: z.string(),
|
|
@@ -236,7 +236,7 @@ export const AppSchema = z.object({
|
|
|
236
236
|
api_docs_url: z.string().nullable().optional(),
|
|
237
237
|
app_profile_url: z.string(),
|
|
238
238
|
banner: z.string().optional(),
|
|
239
|
-
categories: z.array(z.
|
|
239
|
+
categories: z.array(z.string()).optional(), // Service category names
|
|
240
240
|
canonical_id: z.string().optional(),
|
|
241
241
|
current_implementation_id: z.string(),
|
|
242
242
|
days_since_last_update: z.string().optional(),
|
|
@@ -294,7 +294,7 @@ export const NeedsRequestSchema = z.object({
|
|
|
294
294
|
action: z.string(),
|
|
295
295
|
type_of: z.string(),
|
|
296
296
|
authentication_id: z.number().optional(),
|
|
297
|
-
params: z.record(z.
|
|
297
|
+
params: z.record(z.unknown()).optional(),
|
|
298
298
|
});
|
|
299
299
|
|
|
300
300
|
export const NeedsResponseSchema = z.object({
|
|
@@ -341,20 +341,11 @@ export const ImplementationsResponseSchema = z.object({
|
|
|
341
341
|
// ============================================================================
|
|
342
342
|
|
|
343
343
|
export const ImplementationMetaSchema = z.object({
|
|
344
|
-
id: z.string(), // e.g. "
|
|
344
|
+
id: z.string(), // e.g. "100HiresCLIAPI@1.2.1"
|
|
345
345
|
name: z.string(),
|
|
346
346
|
slug: z.string(),
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
url_16x16: z.string().optional(),
|
|
350
|
-
url_32x32: z.string().optional(),
|
|
351
|
-
url_64x64: z.string().optional(),
|
|
352
|
-
url_128x128: z.string().optional(),
|
|
353
|
-
})
|
|
354
|
-
.optional(),
|
|
355
|
-
// Include other fields for completeness but we'll only use what we need
|
|
356
|
-
ageInDays: z.union([z.string(), z.number()]).optional(),
|
|
357
|
-
authType: z.string().nullable().optional(),
|
|
347
|
+
age_in_days: z.number().optional(),
|
|
348
|
+
auth_type: z.string().optional(),
|
|
358
349
|
banner: z.string().optional(),
|
|
359
350
|
categories: z
|
|
360
351
|
.array(
|
|
@@ -365,18 +356,49 @@ export const ImplementationMetaSchema = z.object({
|
|
|
365
356
|
}),
|
|
366
357
|
)
|
|
367
358
|
.optional(),
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
isUpcoming: z.boolean().optional(),
|
|
359
|
+
images: z
|
|
360
|
+
.object({
|
|
361
|
+
url_16x16: z.string().optional(),
|
|
362
|
+
url_32x32: z.string().optional(),
|
|
363
|
+
url_64x64: z.string().optional(),
|
|
364
|
+
url_128x128: z.string().optional(),
|
|
365
|
+
})
|
|
366
|
+
.optional(),
|
|
377
367
|
popularity: z.number().optional(),
|
|
378
|
-
|
|
368
|
+
has_filters: z.boolean().optional(),
|
|
369
|
+
has_reads: z.boolean().optional(),
|
|
370
|
+
has_searches: z.boolean().optional(),
|
|
371
|
+
has_searches_or_writes: z.boolean().optional(),
|
|
372
|
+
has_upfront_fields: z.boolean().optional(),
|
|
373
|
+
has_writes: z.boolean().optional(),
|
|
374
|
+
is_beta: z.boolean().optional(),
|
|
375
|
+
is_built_in: z.boolean().optional(),
|
|
376
|
+
is_deprecated: z.boolean().optional(),
|
|
377
|
+
is_featured: z.boolean().optional(),
|
|
378
|
+
is_hidden: z.boolean().optional(),
|
|
379
|
+
is_invite: z.boolean().optional(),
|
|
380
|
+
is_premium: z.boolean().optional(),
|
|
381
|
+
is_public: z.boolean().optional(),
|
|
382
|
+
is_upcoming: z.boolean().optional(),
|
|
383
|
+
version: z.string().optional(),
|
|
384
|
+
visibility: z.string().optional(),
|
|
385
|
+
actions: z
|
|
386
|
+
.object({
|
|
387
|
+
read: z.number().optional(),
|
|
388
|
+
read_bulk: z.number().optional(),
|
|
389
|
+
write: z.number().optional(),
|
|
390
|
+
search: z.number().optional(),
|
|
391
|
+
search_or_write: z.number().optional(),
|
|
392
|
+
search_and_write: z.number().optional(),
|
|
393
|
+
filter: z.number().optional(),
|
|
394
|
+
})
|
|
395
|
+
.optional(),
|
|
396
|
+
description: z.string().optional(),
|
|
397
|
+
primary_color: z.string().optional(),
|
|
398
|
+
secondary_color: z.string().optional(),
|
|
379
399
|
classification: z.string().optional(),
|
|
400
|
+
api_docs_url: z.string().optional(),
|
|
401
|
+
image: z.string().optional(),
|
|
380
402
|
});
|
|
381
403
|
|
|
382
404
|
export const ImplementationsMetaResponseSchema = z.object({
|
|
@@ -413,7 +435,7 @@ export const NeedChoicesRequestSchema = z.object({
|
|
|
413
435
|
"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
436
|
),
|
|
415
437
|
params: z
|
|
416
|
-
.record(z.
|
|
438
|
+
.record(z.unknown())
|
|
417
439
|
.optional()
|
|
418
440
|
.describe(
|
|
419
441
|
"Object that matches the input the node would normally get. Has all the same keys/types as the `needs` of the action.",
|
package/src/index.ts
CHANGED
|
@@ -38,16 +38,15 @@ export type {
|
|
|
38
38
|
} from "./api/types";
|
|
39
39
|
|
|
40
40
|
// Export schema utilities for CLI
|
|
41
|
-
export { isPositional } from "./utils/schema-utils";
|
|
42
|
-
export { hasResolver } from "./resolvers";
|
|
41
|
+
export { isPositional, PositionalMetadata } from "./utils/schema-utils";
|
|
43
42
|
export { createFunction } from "./utils/function-utils";
|
|
44
43
|
|
|
44
|
+
// Export resolver utilities for CLI
|
|
45
|
+
export * from "./resolvers";
|
|
46
|
+
|
|
45
47
|
// Export auth utilities for CLI use
|
|
46
48
|
export * from "./auth";
|
|
47
49
|
|
|
48
|
-
// Export resolvers for CLI use
|
|
49
|
-
export * from "./resolvers";
|
|
50
|
-
|
|
51
50
|
// All functions now available through the plugin system via createZapierSdk()
|
|
52
51
|
// Export plugin schemas for external use
|
|
53
52
|
export {
|
|
@@ -132,17 +132,20 @@ describe("findFirstAuthentication plugin", () => {
|
|
|
132
132
|
expect(result.data).toEqual(mockAuth);
|
|
133
133
|
});
|
|
134
134
|
|
|
135
|
-
it("should
|
|
135
|
+
it("should throw error when no authentications found", async () => {
|
|
136
136
|
mockListAuthentications.mockResolvedValue({
|
|
137
137
|
data: [],
|
|
138
138
|
});
|
|
139
139
|
|
|
140
140
|
const sdk = createTestSdk();
|
|
141
|
-
const result = await sdk.findFirstAuthentication({
|
|
142
|
-
appKey: "nonexistent",
|
|
143
|
-
});
|
|
144
141
|
|
|
145
|
-
expect(
|
|
142
|
+
await expect(
|
|
143
|
+
sdk.findFirstAuthentication({
|
|
144
|
+
appKey: "nonexistent",
|
|
145
|
+
}),
|
|
146
|
+
).rejects.toThrow(
|
|
147
|
+
"No authentication found matching the specified criteria",
|
|
148
|
+
);
|
|
146
149
|
});
|
|
147
150
|
|
|
148
151
|
it("should return first authentication when multiple found", async () => {
|
|
@@ -6,11 +6,13 @@ import {
|
|
|
6
6
|
} from "./schemas";
|
|
7
7
|
import { createFunction } from "../../utils/function-utils";
|
|
8
8
|
import type { ListAuthenticationsPluginProvides } from "../listAuthentications";
|
|
9
|
+
import { AuthenticationItemSchema } from "../../schemas/Auth";
|
|
10
|
+
import { ZapierResourceNotFoundError } from "../../types/errors";
|
|
9
11
|
|
|
10
12
|
export interface FindFirstAuthenticationPluginProvides {
|
|
11
13
|
findFirstAuthentication: (
|
|
12
14
|
options?: FindFirstAuthenticationOptions,
|
|
13
|
-
) => Promise<{ data: AuthenticationItem
|
|
15
|
+
) => Promise<{ data: AuthenticationItem }>;
|
|
14
16
|
context: {
|
|
15
17
|
meta: {
|
|
16
18
|
findFirstAuthentication: {
|
|
@@ -35,8 +37,15 @@ export const findFirstAuthenticationPlugin: Plugin<
|
|
|
35
37
|
maxItems: 1,
|
|
36
38
|
});
|
|
37
39
|
|
|
40
|
+
if (authsResponse.data.length === 0) {
|
|
41
|
+
throw new ZapierResourceNotFoundError(
|
|
42
|
+
"No authentication found matching the specified criteria",
|
|
43
|
+
{ resourceType: "Authentication" },
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
38
47
|
return {
|
|
39
|
-
data: authsResponse.data
|
|
48
|
+
data: authsResponse.data[0],
|
|
40
49
|
};
|
|
41
50
|
},
|
|
42
51
|
FindFirstAuthenticationSchema,
|
|
@@ -48,7 +57,10 @@ export const findFirstAuthenticationPlugin: Plugin<
|
|
|
48
57
|
meta: {
|
|
49
58
|
findFirstAuthentication: {
|
|
50
59
|
categories: ["authentication"],
|
|
60
|
+
type: "item",
|
|
61
|
+
itemType: "Authentication",
|
|
51
62
|
inputSchema: FindFirstAuthenticationSchema,
|
|
63
|
+
outputSchema: AuthenticationItemSchema,
|
|
52
64
|
},
|
|
53
65
|
},
|
|
54
66
|
},
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from "../../types/errors";
|
|
11
11
|
import { createFunction } from "../../utils/function-utils";
|
|
12
12
|
import type { ListAuthenticationsPluginProvides } from "../listAuthentications";
|
|
13
|
+
import { AuthenticationItemSchema } from "../../schemas/Auth";
|
|
13
14
|
|
|
14
15
|
export interface FindUniqueAuthenticationPluginProvides {
|
|
15
16
|
findUniqueAuthentication: (
|
|
@@ -65,7 +66,10 @@ export const findUniqueAuthenticationPlugin: Plugin<
|
|
|
65
66
|
meta: {
|
|
66
67
|
findUniqueAuthentication: {
|
|
67
68
|
categories: ["authentication"],
|
|
69
|
+
type: "item",
|
|
70
|
+
itemType: "Authentication",
|
|
68
71
|
inputSchema: FindUniqueAuthenticationSchema,
|
|
72
|
+
outputSchema: AuthenticationItemSchema,
|
|
69
73
|
},
|
|
70
74
|
},
|
|
71
75
|
},
|