@zapier/zapier-sdk 0.0.3 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/auth.d.ts +8 -0
- package/dist/api/auth.js +29 -0
- package/dist/api/client.d.ts +8 -0
- package/dist/api/client.js +102 -0
- package/dist/api/debug.d.ts +12 -0
- package/dist/api/debug.js +50 -0
- package/dist/api/index.d.ts +26 -0
- package/dist/api/index.js +51 -0
- package/dist/api/polling.d.ts +17 -0
- package/dist/api/polling.js +34 -0
- package/dist/{types.d.ts → api/types.d.ts} +37 -88
- package/dist/api/types.js +9 -0
- package/dist/functions/{bundleCode.d.ts → bundleCode/index.d.ts} +1 -8
- package/dist/functions/bundleCode/info.d.ts +27 -0
- package/dist/functions/bundleCode/info.js +11 -0
- package/dist/functions/bundleCode/schemas.d.ts +27 -0
- package/dist/functions/bundleCode/schemas.js +22 -0
- package/dist/functions/findFirstAuthentication/index.d.ts +12 -0
- package/dist/functions/findFirstAuthentication/index.js +21 -0
- package/dist/functions/findFirstAuthentication/info.d.ts +30 -0
- package/dist/functions/findFirstAuthentication/info.js +11 -0
- package/dist/functions/findFirstAuthentication/schemas.d.ts +42 -0
- package/dist/functions/findFirstAuthentication/schemas.js +25 -0
- package/dist/functions/findUniqueAuthentication/index.d.ts +13 -0
- package/dist/functions/findUniqueAuthentication/index.js +28 -0
- package/dist/functions/findUniqueAuthentication/info.d.ts +30 -0
- package/dist/functions/findUniqueAuthentication/info.js +11 -0
- package/dist/functions/findUniqueAuthentication/schemas.d.ts +42 -0
- package/dist/functions/findUniqueAuthentication/schemas.js +25 -0
- package/dist/functions/{generateTypes.d.ts → generateTypes/index.d.ts} +2 -7
- package/dist/functions/{generateTypes.js → generateTypes/index.js} +58 -24
- package/dist/functions/generateTypes/info.d.ts +21 -0
- package/dist/functions/generateTypes/info.js +11 -0
- package/dist/functions/generateTypes/schemas.d.ts +30 -0
- package/dist/functions/generateTypes/schemas.js +14 -0
- package/dist/functions/{getAction.d.ts → getAction/index.d.ts} +2 -6
- package/dist/functions/{getAction.js → getAction/index.js} +6 -5
- package/dist/functions/getAction/info.d.ts +18 -0
- package/dist/functions/getAction/info.js +11 -0
- package/dist/functions/getAction/schemas.d.ts +30 -0
- package/dist/functions/getAction/schemas.js +13 -0
- package/dist/functions/{getApp.d.ts → getApp/index.d.ts} +2 -4
- package/dist/functions/{getApp.js → getApp/index.js} +6 -10
- package/dist/functions/getApp/info.d.ts +12 -0
- package/dist/functions/getApp/info.js +11 -0
- package/dist/functions/getApp/schemas.d.ts +24 -0
- package/dist/functions/getApp/schemas.js +11 -0
- package/dist/functions/{listActions.d.ts → listActions/index.d.ts} +3 -6
- package/dist/functions/{listActions.js → listActions/index.js} +4 -3
- package/dist/functions/listActions/info.d.ts +15 -0
- package/dist/functions/listActions/info.js +11 -0
- package/dist/functions/listActions/schemas.d.ts +27 -0
- package/dist/functions/listActions/schemas.js +14 -0
- package/dist/functions/{listApps.d.ts → listApps/index.d.ts} +2 -6
- package/dist/functions/{listApps.js → listApps/index.js} +1 -1
- package/dist/functions/listApps/info.d.ts +18 -0
- package/dist/functions/listApps/info.js +11 -0
- package/dist/functions/listApps/schemas.d.ts +30 -0
- package/dist/functions/listApps/schemas.js +15 -0
- package/dist/functions/{listAuths.d.ts → listAuthentications/index.d.ts} +3 -9
- package/dist/functions/{listAuths.js → listAuthentications/index.js} +28 -12
- package/dist/functions/listAuthentications/info.d.ts +30 -0
- package/dist/functions/listAuthentications/info.js +11 -0
- package/dist/functions/listAuthentications/schemas.d.ts +42 -0
- package/dist/functions/listAuthentications/schemas.js +25 -0
- package/dist/functions/{listFields.d.ts → listFields/index.d.ts} +3 -9
- package/dist/functions/{listFields.js → listFields/index.js} +8 -10
- package/dist/functions/listFields/info.d.ts +24 -0
- package/dist/functions/listFields/info.js +11 -0
- package/dist/functions/listFields/schemas.d.ts +36 -0
- package/dist/functions/listFields/schemas.js +17 -0
- package/dist/functions/{runAction.d.ts → runAction/index.d.ts} +2 -8
- package/dist/functions/{runAction.js → runAction/index.js} +15 -14
- package/dist/functions/runAction/info.d.ts +24 -0
- package/dist/functions/runAction/info.js +11 -0
- package/dist/functions/runAction/schemas.d.ts +36 -0
- package/dist/functions/runAction/schemas.js +15 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.js +17 -6
- package/dist/plugins/apps/index.d.ts +8 -0
- package/dist/plugins/apps/index.js +77 -0
- package/dist/plugins/apps/info.d.ts +6 -0
- package/dist/plugins/apps/info.js +13 -0
- package/dist/plugins/apps/types.d.ts +21 -0
- package/dist/plugins/apps/types.js +2 -0
- package/dist/resolvers/actionKey.d.ts +8 -0
- package/dist/resolvers/actionKey.js +20 -0
- package/dist/resolvers/actionType.d.ts +8 -0
- package/dist/resolvers/actionType.js +21 -0
- package/dist/resolvers/appKey.d.ts +6 -0
- package/dist/resolvers/appKey.js +8 -0
- package/dist/resolvers/authenticationId.d.ts +8 -0
- package/dist/resolvers/authenticationId.js +29 -0
- package/dist/resolvers/index.d.ts +39 -0
- package/dist/resolvers/index.js +105 -0
- package/dist/resolvers/inputs.d.ts +7 -0
- package/dist/resolvers/inputs.js +15 -0
- package/dist/schema-utils.d.ts +44 -0
- package/dist/schema-utils.js +76 -0
- package/dist/schemas/Action.d.ts +21 -0
- package/dist/schemas/Action.js +31 -0
- package/dist/schemas/App.d.ts +19 -0
- package/dist/schemas/App.js +32 -0
- package/dist/schemas/Auth.d.ts +27 -0
- package/dist/schemas/Auth.js +42 -0
- package/dist/schemas/Field.d.ts +15 -0
- package/dist/schemas/Field.js +25 -0
- package/dist/sdk.d.ts +3 -4
- package/dist/sdk.js +104 -11
- package/dist/types/domain.d.ts +22 -0
- package/dist/types/domain.js +21 -0
- package/dist/types/properties.d.ts +21 -0
- package/dist/types/properties.js +43 -0
- package/dist/types/sdk.d.ts +23 -0
- package/dist/types/sdk.js +2 -0
- package/package.json +4 -2
- package/src/api/auth.ts +28 -0
- package/src/api/client.ts +148 -0
- package/src/api/debug.ts +58 -0
- package/src/api/index.ts +83 -0
- package/src/api/polling.ts +56 -0
- package/src/api/types.ts +177 -0
- package/src/functions/{bundleCode.ts → bundleCode/index.ts} +1 -8
- package/src/functions/bundleCode/info.ts +9 -0
- package/src/functions/bundleCode/schemas.ts +30 -0
- package/src/functions/findFirstAuthentication/index.ts +24 -0
- package/src/functions/findFirstAuthentication/info.ts +9 -0
- package/src/functions/findFirstAuthentication/schemas.ts +60 -0
- package/src/functions/findUniqueAuthentication/index.ts +35 -0
- package/src/functions/findUniqueAuthentication/info.ts +9 -0
- package/src/functions/findUniqueAuthentication/schemas.ts +60 -0
- package/src/functions/{generateTypes.ts → generateTypes/index.ts} +70 -31
- package/src/functions/generateTypes/info.ts +9 -0
- package/src/functions/generateTypes/schemas.ts +38 -0
- package/src/functions/{getAction.ts → getAction/index.ts} +11 -12
- package/src/functions/getAction/info.ts +9 -0
- package/src/functions/getAction/schemas.ts +35 -0
- package/src/functions/{getApp.ts → getApp/index.ts} +9 -15
- package/src/functions/getApp/info.ts +9 -0
- package/src/functions/getApp/schemas.ts +31 -0
- package/src/functions/{listActions.ts → listActions/index.ts} +8 -10
- package/src/functions/listActions/info.ts +9 -0
- package/src/functions/listActions/schemas.ts +40 -0
- package/src/functions/{listApps.ts → listApps/index.ts} +3 -8
- package/src/functions/listApps/info.ts +9 -0
- package/src/functions/listApps/schemas.ts +43 -0
- package/src/functions/{listAuths.ts → listAuthentications/index.ts} +32 -23
- package/src/functions/listAuthentications/info.ts +9 -0
- package/src/functions/listAuthentications/schemas.ts +60 -0
- package/src/functions/{listFields.ts → listFields/index.ts} +11 -20
- package/src/functions/listFields/info.ts +9 -0
- package/src/functions/listFields/schemas.ts +46 -0
- package/src/functions/{runAction.ts → runAction/index.ts} +25 -23
- package/src/functions/runAction/info.ts +9 -0
- package/src/functions/runAction/schemas.ts +41 -0
- package/src/index.ts +19 -5
- package/src/plugins/apps/index.ts +144 -0
- package/src/plugins/apps/info.ts +12 -0
- package/src/plugins/apps/types.ts +34 -0
- package/src/resolvers/actionKey.ts +33 -0
- package/src/resolvers/actionType.ts +30 -0
- package/src/resolvers/appKey.ts +11 -0
- package/src/resolvers/authenticationId.ts +38 -0
- package/src/resolvers/index.ts +117 -0
- package/src/resolvers/inputs.ts +23 -0
- package/src/schema-utils.ts +154 -0
- package/src/schemas/Action.ts +40 -0
- package/src/schemas/App.ts +43 -0
- package/src/schemas/Auth.ts +54 -0
- package/src/schemas/Field.ts +34 -0
- package/src/sdk.ts +165 -19
- package/src/types/domain.ts +54 -0
- package/src/types/properties.ts +67 -0
- package/src/types/sdk.ts +46 -0
- package/dist/actions-sdk.d.ts +0 -47
- package/dist/actions-sdk.js +0 -208
- package/dist/api.d.ts +0 -62
- package/dist/api.js +0 -227
- package/dist/output-schemas.d.ts +0 -95
- package/dist/output-schemas.js +0 -138
- package/dist/schemas.d.ts +0 -338
- package/dist/schemas.js +0 -336
- package/dist/types.js +0 -41
- package/src/actions-sdk.ts +0 -356
- package/src/api.ts +0 -361
- package/src/output-schemas.ts +0 -196
- package/src/schemas.ts +0 -467
- package/src/types.ts +0 -257
- /package/dist/functions/{bundleCode.js → bundleCode/index.js} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { findFirstAuthentication } from "./index";
|
|
2
|
+
export declare const findFirstAuthenticationInfo: {
|
|
3
|
+
name: string;
|
|
4
|
+
inputSchema: import("zod").ZodObject<{
|
|
5
|
+
appKey: import("zod").ZodOptional<import("zod").ZodString>;
|
|
6
|
+
search: import("zod").ZodOptional<import("zod").ZodString>;
|
|
7
|
+
title: import("zod").ZodOptional<import("zod").ZodString>;
|
|
8
|
+
account_id: import("zod").ZodOptional<import("zod").ZodString>;
|
|
9
|
+
owner: import("zod").ZodOptional<import("zod").ZodString>;
|
|
10
|
+
limit: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>;
|
|
11
|
+
offset: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>;
|
|
12
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
13
|
+
search?: string | undefined;
|
|
14
|
+
appKey?: string | undefined;
|
|
15
|
+
title?: string | undefined;
|
|
16
|
+
account_id?: string | undefined;
|
|
17
|
+
owner?: string | undefined;
|
|
18
|
+
limit?: number | undefined;
|
|
19
|
+
offset?: number | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
search?: string | undefined;
|
|
22
|
+
appKey?: string | undefined;
|
|
23
|
+
title?: string | undefined;
|
|
24
|
+
account_id?: string | undefined;
|
|
25
|
+
owner?: string | undefined;
|
|
26
|
+
limit?: number | undefined;
|
|
27
|
+
offset?: number | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
implementation: typeof findFirstAuthentication;
|
|
30
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findFirstAuthenticationInfo = void 0;
|
|
4
|
+
const index_1 = require("./index");
|
|
5
|
+
const schemas_1 = require("./schemas");
|
|
6
|
+
// Function registry info - imports both function and schema
|
|
7
|
+
exports.findFirstAuthenticationInfo = {
|
|
8
|
+
name: index_1.findFirstAuthentication.name,
|
|
9
|
+
inputSchema: schemas_1.FindFirstAuthenticationSchema,
|
|
10
|
+
implementation: index_1.findFirstAuthentication,
|
|
11
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Authentication } from "../../types/domain";
|
|
3
|
+
export declare const FindFirstAuthenticationSchema: z.ZodObject<{
|
|
4
|
+
appKey: z.ZodOptional<z.ZodString>;
|
|
5
|
+
search: z.ZodOptional<z.ZodString>;
|
|
6
|
+
title: z.ZodOptional<z.ZodString>;
|
|
7
|
+
account_id: z.ZodOptional<z.ZodString>;
|
|
8
|
+
owner: z.ZodOptional<z.ZodString>;
|
|
9
|
+
limit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
10
|
+
offset: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
search?: string | undefined;
|
|
13
|
+
appKey?: string | undefined;
|
|
14
|
+
title?: string | undefined;
|
|
15
|
+
account_id?: string | undefined;
|
|
16
|
+
owner?: string | undefined;
|
|
17
|
+
limit?: number | undefined;
|
|
18
|
+
offset?: number | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
search?: string | undefined;
|
|
21
|
+
appKey?: string | undefined;
|
|
22
|
+
title?: string | undefined;
|
|
23
|
+
account_id?: string | undefined;
|
|
24
|
+
owner?: string | undefined;
|
|
25
|
+
limit?: number | undefined;
|
|
26
|
+
offset?: number | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
export type FindFirstAuthenticationOptions = z.infer<typeof FindFirstAuthenticationSchema> & {
|
|
29
|
+
/** Base URL for Zapier API */
|
|
30
|
+
baseUrl?: string;
|
|
31
|
+
/** Authentication token */
|
|
32
|
+
token?: string;
|
|
33
|
+
/** Optional pre-instantiated API client */
|
|
34
|
+
api?: any;
|
|
35
|
+
/** Enable debug logging */
|
|
36
|
+
debug?: boolean;
|
|
37
|
+
/** Custom fetch implementation */
|
|
38
|
+
fetch?: typeof globalThis.fetch;
|
|
39
|
+
};
|
|
40
|
+
export interface FindFirstAuthenticationSdkFunction {
|
|
41
|
+
findFirstAuthentication: (options?: Partial<FindFirstAuthenticationOptions>) => Promise<Authentication | null>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindFirstAuthenticationSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const properties_1 = require("../../types/properties");
|
|
6
|
+
const schema_utils_1 = require("../../schema-utils");
|
|
7
|
+
const Auth_1 = require("../../schemas/Auth");
|
|
8
|
+
// Pure Zod schema - no resolver metadata!
|
|
9
|
+
exports.FindFirstAuthenticationSchema = (0, schema_utils_1.withOutputSchema)(zod_1.z
|
|
10
|
+
.object({
|
|
11
|
+
appKey: properties_1.AppKeyPropertySchema.optional().describe("App slug to get authentications for (e.g., 'slack', 'github')"),
|
|
12
|
+
search: zod_1.z
|
|
13
|
+
.string()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe("Search term to filter authentications by title"),
|
|
16
|
+
title: zod_1.z
|
|
17
|
+
.string()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("Filter authentications by exact title match"),
|
|
20
|
+
account_id: zod_1.z.string().optional().describe("Filter by account ID"),
|
|
21
|
+
owner: zod_1.z.string().optional().describe("Filter by owner"),
|
|
22
|
+
limit: properties_1.LimitPropertySchema.optional().describe("Maximum number of items to return (1-200)"),
|
|
23
|
+
offset: properties_1.OffsetPropertySchema.optional().describe("Number of items to skip for pagination"),
|
|
24
|
+
})
|
|
25
|
+
.describe("Find the first authentication matching the criteria"), Auth_1.AuthItemSchema);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Authentication } from "../../types/domain";
|
|
2
|
+
import type { FindUniqueAuthenticationOptions } from "./schemas";
|
|
3
|
+
/**
|
|
4
|
+
* Find a unique authentication matching the given criteria
|
|
5
|
+
*
|
|
6
|
+
* This function can be used standalone without instantiating a full SDK,
|
|
7
|
+
* which enables better tree-shaking in applications that only need this functionality.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Filtering and API configuration options
|
|
10
|
+
* @returns Promise<Authentication> - The unique matching authentication
|
|
11
|
+
* @throws Error if no authentication found or multiple authentications found
|
|
12
|
+
*/
|
|
13
|
+
export declare function findUniqueAuthentication(options?: Partial<FindUniqueAuthenticationOptions>): Promise<Authentication>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findUniqueAuthentication = findUniqueAuthentication;
|
|
4
|
+
const listAuthentications_1 = require("../listAuthentications");
|
|
5
|
+
/**
|
|
6
|
+
* Find a unique authentication matching the given criteria
|
|
7
|
+
*
|
|
8
|
+
* This function can be used standalone without instantiating a full SDK,
|
|
9
|
+
* which enables better tree-shaking in applications that only need this functionality.
|
|
10
|
+
*
|
|
11
|
+
* @param options - Filtering and API configuration options
|
|
12
|
+
* @returns Promise<Authentication> - The unique matching authentication
|
|
13
|
+
* @throws Error if no authentication found or multiple authentications found
|
|
14
|
+
*/
|
|
15
|
+
async function findUniqueAuthentication(options = {}) {
|
|
16
|
+
// Use listAuthentications with a reasonable limit to check for uniqueness
|
|
17
|
+
const auths = await (0, listAuthentications_1.listAuthentications)({
|
|
18
|
+
...options,
|
|
19
|
+
limit: 2, // Get up to 2 to check for uniqueness
|
|
20
|
+
});
|
|
21
|
+
if (auths.length === 0) {
|
|
22
|
+
throw new Error("No authentication found matching the specified criteria");
|
|
23
|
+
}
|
|
24
|
+
if (auths.length > 1) {
|
|
25
|
+
throw new Error("Multiple authentications found matching the specified criteria. Expected exactly one.");
|
|
26
|
+
}
|
|
27
|
+
return auths[0];
|
|
28
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { findUniqueAuthentication } from "./index";
|
|
2
|
+
export declare const findUniqueAuthenticationInfo: {
|
|
3
|
+
name: string;
|
|
4
|
+
inputSchema: import("zod").ZodObject<{
|
|
5
|
+
appKey: import("zod").ZodOptional<import("zod").ZodString>;
|
|
6
|
+
search: import("zod").ZodOptional<import("zod").ZodString>;
|
|
7
|
+
title: import("zod").ZodOptional<import("zod").ZodString>;
|
|
8
|
+
account_id: import("zod").ZodOptional<import("zod").ZodString>;
|
|
9
|
+
owner: import("zod").ZodOptional<import("zod").ZodString>;
|
|
10
|
+
limit: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>;
|
|
11
|
+
offset: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>;
|
|
12
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
13
|
+
search?: string | undefined;
|
|
14
|
+
appKey?: string | undefined;
|
|
15
|
+
title?: string | undefined;
|
|
16
|
+
account_id?: string | undefined;
|
|
17
|
+
owner?: string | undefined;
|
|
18
|
+
limit?: number | undefined;
|
|
19
|
+
offset?: number | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
search?: string | undefined;
|
|
22
|
+
appKey?: string | undefined;
|
|
23
|
+
title?: string | undefined;
|
|
24
|
+
account_id?: string | undefined;
|
|
25
|
+
owner?: string | undefined;
|
|
26
|
+
limit?: number | undefined;
|
|
27
|
+
offset?: number | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
implementation: typeof findUniqueAuthentication;
|
|
30
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findUniqueAuthenticationInfo = void 0;
|
|
4
|
+
const index_1 = require("./index");
|
|
5
|
+
const schemas_1 = require("./schemas");
|
|
6
|
+
// Function registry info - imports both function and schema
|
|
7
|
+
exports.findUniqueAuthenticationInfo = {
|
|
8
|
+
name: index_1.findUniqueAuthentication.name,
|
|
9
|
+
inputSchema: schemas_1.FindUniqueAuthenticationSchema,
|
|
10
|
+
implementation: index_1.findUniqueAuthentication,
|
|
11
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Authentication } from "../../types/domain";
|
|
3
|
+
export declare const FindUniqueAuthenticationSchema: z.ZodObject<{
|
|
4
|
+
appKey: z.ZodOptional<z.ZodString>;
|
|
5
|
+
search: z.ZodOptional<z.ZodString>;
|
|
6
|
+
title: z.ZodOptional<z.ZodString>;
|
|
7
|
+
account_id: z.ZodOptional<z.ZodString>;
|
|
8
|
+
owner: z.ZodOptional<z.ZodString>;
|
|
9
|
+
limit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
10
|
+
offset: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
search?: string | undefined;
|
|
13
|
+
appKey?: string | undefined;
|
|
14
|
+
title?: string | undefined;
|
|
15
|
+
account_id?: string | undefined;
|
|
16
|
+
owner?: string | undefined;
|
|
17
|
+
limit?: number | undefined;
|
|
18
|
+
offset?: number | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
search?: string | undefined;
|
|
21
|
+
appKey?: string | undefined;
|
|
22
|
+
title?: string | undefined;
|
|
23
|
+
account_id?: string | undefined;
|
|
24
|
+
owner?: string | undefined;
|
|
25
|
+
limit?: number | undefined;
|
|
26
|
+
offset?: number | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
export type FindUniqueAuthenticationOptions = z.infer<typeof FindUniqueAuthenticationSchema> & {
|
|
29
|
+
/** Base URL for Zapier API */
|
|
30
|
+
baseUrl?: string;
|
|
31
|
+
/** Authentication token */
|
|
32
|
+
token?: string;
|
|
33
|
+
/** Optional pre-instantiated API client */
|
|
34
|
+
api?: any;
|
|
35
|
+
/** Enable debug logging */
|
|
36
|
+
debug?: boolean;
|
|
37
|
+
/** Custom fetch implementation */
|
|
38
|
+
fetch?: typeof globalThis.fetch;
|
|
39
|
+
};
|
|
40
|
+
export interface FindUniqueAuthenticationSdkFunction {
|
|
41
|
+
findUniqueAuthentication: (options?: Partial<FindUniqueAuthenticationOptions>) => Promise<Authentication>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FindUniqueAuthenticationSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const properties_1 = require("../../types/properties");
|
|
6
|
+
const schema_utils_1 = require("../../schema-utils");
|
|
7
|
+
const Auth_1 = require("../../schemas/Auth");
|
|
8
|
+
// Pure Zod schema - no resolver metadata!
|
|
9
|
+
exports.FindUniqueAuthenticationSchema = (0, schema_utils_1.withOutputSchema)(zod_1.z
|
|
10
|
+
.object({
|
|
11
|
+
appKey: properties_1.AppKeyPropertySchema.optional().describe("App slug to get authentications for (e.g., 'slack', 'github')"),
|
|
12
|
+
search: zod_1.z
|
|
13
|
+
.string()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe("Search term to filter authentications by title"),
|
|
16
|
+
title: zod_1.z
|
|
17
|
+
.string()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("Filter authentications by exact title match"),
|
|
20
|
+
account_id: zod_1.z.string().optional().describe("Filter by account ID"),
|
|
21
|
+
owner: zod_1.z.string().optional().describe("Filter by owner"),
|
|
22
|
+
limit: properties_1.LimitPropertySchema.optional().describe("Maximum number of items to return (1-200)"),
|
|
23
|
+
offset: properties_1.OffsetPropertySchema.optional().describe("Number of items to skip for pagination"),
|
|
24
|
+
})
|
|
25
|
+
.describe("Find a unique authentication matching the criteria"), Auth_1.AuthItemSchema);
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export interface GenerateTypesOptions extends FunctionConfig {
|
|
3
|
-
appKey: string;
|
|
4
|
-
authId?: number;
|
|
5
|
-
output?: string;
|
|
6
|
-
}
|
|
1
|
+
import type { GenerateTypesOptions } from "./schemas";
|
|
7
2
|
/**
|
|
8
3
|
* Generate TypeScript types for a specific app
|
|
9
4
|
*
|
|
10
5
|
* This function can be used standalone without instantiating a full SDK,
|
|
11
6
|
* which enables better tree-shaking in applications that only need this functionality.
|
|
12
7
|
*
|
|
13
|
-
* @param options - App key,
|
|
8
|
+
* @param options - App key, authentication ID, output path, and API configuration options
|
|
14
9
|
* @returns Promise<string> - Generated TypeScript code
|
|
15
10
|
*/
|
|
16
11
|
export declare function generateTypes(options: GenerateTypesOptions): Promise<string>;
|
|
@@ -34,19 +34,19 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.generateTypes = generateTypes;
|
|
37
|
-
const listActions_1 = require("
|
|
38
|
-
const listFields_1 = require("
|
|
37
|
+
const listActions_1 = require("../listActions");
|
|
38
|
+
const listFields_1 = require("../listFields");
|
|
39
39
|
/**
|
|
40
40
|
* Generate TypeScript types for a specific app
|
|
41
41
|
*
|
|
42
42
|
* This function can be used standalone without instantiating a full SDK,
|
|
43
43
|
* which enables better tree-shaking in applications that only need this functionality.
|
|
44
44
|
*
|
|
45
|
-
* @param options - App key,
|
|
45
|
+
* @param options - App key, authentication ID, output path, and API configuration options
|
|
46
46
|
* @returns Promise<string> - Generated TypeScript code
|
|
47
47
|
*/
|
|
48
48
|
async function generateTypes(options) {
|
|
49
|
-
const { appKey,
|
|
49
|
+
const { appKey, authenticationId, output = `./types/${appKey}.d.ts`, } = options;
|
|
50
50
|
// Parse app identifier (support app@version format)
|
|
51
51
|
const { app, version } = parseAppIdentifier(appKey);
|
|
52
52
|
// Fetch all actions for the app
|
|
@@ -66,15 +66,15 @@ async function generateTypes(options) {
|
|
|
66
66
|
}
|
|
67
67
|
// Fetch input fields for each action
|
|
68
68
|
const actionsWithFields = [];
|
|
69
|
-
if (
|
|
69
|
+
if (authenticationId) {
|
|
70
70
|
for (const action of actions) {
|
|
71
71
|
try {
|
|
72
72
|
const fields = await (0, listFields_1.listFields)({
|
|
73
73
|
...options,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
appKey: action.appKey,
|
|
75
|
+
actionKey: action.key,
|
|
76
|
+
actionType: action.type,
|
|
77
|
+
authenticationId: authenticationId,
|
|
78
78
|
});
|
|
79
79
|
actionsWithFields.push({ ...action, inputFields: fields });
|
|
80
80
|
}
|
|
@@ -132,8 +132,15 @@ ${versionComment}
|
|
|
132
132
|
* Generated on: ${new Date().toISOString()}
|
|
133
133
|
*
|
|
134
134
|
* Usage:
|
|
135
|
-
* import type { ${appName}
|
|
136
|
-
* const sdk
|
|
135
|
+
* import type { ${appName}Sdk } from './path/to/this/file'
|
|
136
|
+
* const sdk = createZapierSdk() as unknown as ${appName}Sdk
|
|
137
|
+
*
|
|
138
|
+
* // Direct usage (per-call auth):
|
|
139
|
+
* await sdk.apps.${appKey}.search.user_by_email({ authenticationId: 123, inputs: { email } })
|
|
140
|
+
*
|
|
141
|
+
* // Factory usage (pinned auth):
|
|
142
|
+
* const my${appName} = sdk.apps.${appKey}({ authenticationId: 123 })
|
|
143
|
+
* await my${appName}.search.user_by_email({ inputs: { email } })
|
|
137
144
|
*/
|
|
138
145
|
|
|
139
146
|
import type { ActionExecutionOptions, ActionExecutionResult } from '@zapier/zapier-sdk'
|
|
@@ -176,15 +183,24 @@ import type { ActionExecutionOptions, ActionExecutionResult } from '@zapier/zapi
|
|
|
176
183
|
});
|
|
177
184
|
output += `}\n\n`;
|
|
178
185
|
});
|
|
179
|
-
// Generate the main app
|
|
180
|
-
|
|
181
|
-
output += `
|
|
182
|
-
output += ` ${appKey}: {\n`;
|
|
186
|
+
// Generate the main app SDK interface with factory pattern support
|
|
187
|
+
// Generate the app proxy interface (actions grouped by type)
|
|
188
|
+
output += `interface ${appName}AppProxy {\n`;
|
|
183
189
|
Object.keys(actionsByType).forEach((actionType) => {
|
|
184
190
|
const typeName = `${appName}${capitalize(actionType)}Actions`;
|
|
185
|
-
output += `
|
|
191
|
+
output += ` ${actionType}: ${typeName}\n`;
|
|
186
192
|
});
|
|
187
|
-
output += `
|
|
193
|
+
output += `}\n\n`;
|
|
194
|
+
// Generate the factory function interface
|
|
195
|
+
output += `interface ${appName}AppFactory {\n`;
|
|
196
|
+
output += ` (options: { authenticationId: number }): ${appName}AppProxy\n`;
|
|
197
|
+
output += `}\n\n`;
|
|
198
|
+
// Combine factory and direct access
|
|
199
|
+
output += `type ${appName}AppWithFactory = ${appName}AppFactory & ${appName}AppProxy\n\n`;
|
|
200
|
+
// Generate the main SDK interface
|
|
201
|
+
output += `export interface ${appName}Sdk {\n`;
|
|
202
|
+
output += ` apps: {\n`;
|
|
203
|
+
output += ` ${appKey}: ${appName}AppWithFactory\n`;
|
|
188
204
|
output += ` }\n`;
|
|
189
205
|
output += `}\n`;
|
|
190
206
|
return output;
|
|
@@ -205,11 +221,19 @@ ${versionComment}
|
|
|
205
221
|
|
|
206
222
|
import type { ActionExecutionOptions, ActionExecutionResult } from '@zapier/zapier-sdk'
|
|
207
223
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
224
|
+
interface ${appName}AppProxy {
|
|
225
|
+
// No actions available
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
interface ${appName}AppFactory {
|
|
229
|
+
(options: { authenticationId: number }): ${appName}AppProxy
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
type ${appName}AppWithFactory = ${appName}AppFactory & ${appName}AppProxy
|
|
233
|
+
|
|
234
|
+
export interface ${appName}Sdk {
|
|
235
|
+
apps: {
|
|
236
|
+
${appKey}: ${appName}AppWithFactory
|
|
213
237
|
}
|
|
214
238
|
}
|
|
215
239
|
`;
|
|
@@ -219,11 +243,21 @@ function capitalize(str) {
|
|
|
219
243
|
}
|
|
220
244
|
function sanitizeActionName(actionKey) {
|
|
221
245
|
// Ensure the action name is a valid TypeScript identifier
|
|
222
|
-
|
|
246
|
+
let sanitized = actionKey.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
247
|
+
// If it starts with a number, prepend an underscore
|
|
248
|
+
if (/^[0-9]/.test(sanitized)) {
|
|
249
|
+
sanitized = "_" + sanitized;
|
|
250
|
+
}
|
|
251
|
+
return sanitized;
|
|
223
252
|
}
|
|
224
253
|
function sanitizeFieldName(fieldKey) {
|
|
225
254
|
// Ensure the field name is a valid TypeScript identifier
|
|
226
|
-
|
|
255
|
+
let sanitized = fieldKey.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
256
|
+
// If it starts with a number, prepend an underscore
|
|
257
|
+
if (/^[0-9]/.test(sanitized)) {
|
|
258
|
+
sanitized = "_" + sanitized;
|
|
259
|
+
}
|
|
260
|
+
return sanitized;
|
|
227
261
|
}
|
|
228
262
|
function escapeComment(comment) {
|
|
229
263
|
// Escape comment text to prevent breaking the JSDoc comment
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { generateTypes } from "./index";
|
|
2
|
+
export declare const generateTypesInfo: {
|
|
3
|
+
name: string;
|
|
4
|
+
inputSchema: import("zod").ZodObject<{
|
|
5
|
+
appKey: import("zod").ZodString;
|
|
6
|
+
authenticationId: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
7
|
+
output: import("zod").ZodOptional<import("zod").ZodString>;
|
|
8
|
+
debug: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
|
9
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
10
|
+
debug: boolean;
|
|
11
|
+
appKey: string;
|
|
12
|
+
authenticationId?: number | undefined;
|
|
13
|
+
output?: string | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
appKey: string;
|
|
16
|
+
debug?: boolean | undefined;
|
|
17
|
+
authenticationId?: number | undefined;
|
|
18
|
+
output?: string | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
implementation: typeof generateTypes;
|
|
21
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateTypesInfo = void 0;
|
|
4
|
+
const index_1 = require("./index");
|
|
5
|
+
const schemas_1 = require("./schemas");
|
|
6
|
+
// Function registry info - imports both function and schema
|
|
7
|
+
exports.generateTypesInfo = {
|
|
8
|
+
name: index_1.generateTypes.name,
|
|
9
|
+
inputSchema: schemas_1.GenerateTypesSchema,
|
|
10
|
+
implementation: index_1.generateTypes,
|
|
11
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const GenerateTypesSchema: z.ZodObject<{
|
|
3
|
+
appKey: z.ZodString;
|
|
4
|
+
authenticationId: z.ZodOptional<z.ZodNumber>;
|
|
5
|
+
output: z.ZodOptional<z.ZodString>;
|
|
6
|
+
debug: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
debug: boolean;
|
|
9
|
+
appKey: string;
|
|
10
|
+
authenticationId?: number | undefined;
|
|
11
|
+
output?: string | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
appKey: string;
|
|
14
|
+
debug?: boolean | undefined;
|
|
15
|
+
authenticationId?: number | undefined;
|
|
16
|
+
output?: string | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
export type GenerateTypesOptions = z.infer<typeof GenerateTypesSchema> & {
|
|
19
|
+
/** Base URL for Zapier API */
|
|
20
|
+
baseUrl?: string;
|
|
21
|
+
/** Authentication token */
|
|
22
|
+
token?: string;
|
|
23
|
+
/** Optional pre-instantiated API client */
|
|
24
|
+
api?: any;
|
|
25
|
+
/** Custom fetch implementation */
|
|
26
|
+
fetch?: typeof globalThis.fetch;
|
|
27
|
+
};
|
|
28
|
+
export interface GenerateTypesSdkFunction {
|
|
29
|
+
generateTypes: (options: GenerateTypesOptions) => Promise<string>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GenerateTypesSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const properties_1 = require("../../types/properties");
|
|
6
|
+
// Pure Zod schema - no resolver metadata!
|
|
7
|
+
exports.GenerateTypesSchema = zod_1.z
|
|
8
|
+
.object({
|
|
9
|
+
appKey: properties_1.AppKeyPropertySchema.describe("App key to generate SDK code for"),
|
|
10
|
+
authenticationId: properties_1.AuthenticationIdPropertySchema.optional(),
|
|
11
|
+
output: properties_1.OutputPropertySchema.optional().describe("Output file path (defaults to generated/<appKey>.ts)"),
|
|
12
|
+
debug: properties_1.DebugPropertySchema.describe("Enable debug logging during generation"),
|
|
13
|
+
})
|
|
14
|
+
.describe("Generate TypeScript SDK code for a specific app");
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type { Action
|
|
2
|
-
|
|
3
|
-
app: string;
|
|
4
|
-
action: string;
|
|
5
|
-
type: string;
|
|
6
|
-
}
|
|
1
|
+
import type { Action } from "../../types/domain";
|
|
2
|
+
import type { GetActionOptions } from "./schemas";
|
|
7
3
|
/**
|
|
8
4
|
* Get a specific action by app, action key, and type
|
|
9
5
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAction = getAction;
|
|
4
|
-
const listActions_1 = require("
|
|
4
|
+
const listActions_1 = require("../listActions");
|
|
5
5
|
/**
|
|
6
6
|
* Get a specific action by app, action key, and type
|
|
7
7
|
*
|
|
@@ -12,14 +12,15 @@ const listActions_1 = require("./listActions");
|
|
|
12
12
|
* @returns Promise<Action>
|
|
13
13
|
*/
|
|
14
14
|
async function getAction(options) {
|
|
15
|
-
const {
|
|
15
|
+
const { appKey, actionKey, actionType } = options;
|
|
16
16
|
const actions = await (0, listActions_1.listActions)({
|
|
17
17
|
...options,
|
|
18
|
-
appKey:
|
|
18
|
+
appKey: appKey,
|
|
19
19
|
});
|
|
20
|
-
const action = actions.find((a) => a.key === actionKey && a.type ===
|
|
20
|
+
const action = actions.find((a) => a.key === actionKey && a.type === actionType);
|
|
21
21
|
if (!action) {
|
|
22
|
-
throw new Error(`Action not found: ${actionKey} with type ${
|
|
22
|
+
throw new Error(`Action not found: ${actionKey} with type ${actionType}`);
|
|
23
23
|
}
|
|
24
24
|
return action;
|
|
25
25
|
}
|
|
26
|
+
// No registry info here - moved to info.ts for proper tree-shaking
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getAction } from "./index";
|
|
2
|
+
export declare const getActionInfo: {
|
|
3
|
+
name: string;
|
|
4
|
+
inputSchema: import("zod").ZodObject<{
|
|
5
|
+
appKey: import("zod").ZodString;
|
|
6
|
+
actionType: import("zod").ZodEnum<["read", "write", "search", "create", "update", "delete"]>;
|
|
7
|
+
actionKey: import("zod").ZodString;
|
|
8
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
9
|
+
appKey: string;
|
|
10
|
+
actionType: "create" | "update" | "search" | "delete" | "read" | "write";
|
|
11
|
+
actionKey: string;
|
|
12
|
+
}, {
|
|
13
|
+
appKey: string;
|
|
14
|
+
actionType: "create" | "update" | "search" | "delete" | "read" | "write";
|
|
15
|
+
actionKey: string;
|
|
16
|
+
}>;
|
|
17
|
+
implementation: typeof getAction;
|
|
18
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getActionInfo = void 0;
|
|
4
|
+
const index_1 = require("./index");
|
|
5
|
+
const schemas_1 = require("./schemas");
|
|
6
|
+
// Function registry info - imports both function and schema
|
|
7
|
+
exports.getActionInfo = {
|
|
8
|
+
name: index_1.getAction.name,
|
|
9
|
+
inputSchema: schemas_1.GetActionSchema,
|
|
10
|
+
implementation: index_1.getAction,
|
|
11
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { Action } from "../../types/domain";
|
|
3
|
+
export declare const GetActionSchema: z.ZodObject<{
|
|
4
|
+
appKey: z.ZodString;
|
|
5
|
+
actionType: z.ZodEnum<["read", "write", "search", "create", "update", "delete"]>;
|
|
6
|
+
actionKey: z.ZodString;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
appKey: string;
|
|
9
|
+
actionType: "create" | "update" | "search" | "delete" | "read" | "write";
|
|
10
|
+
actionKey: string;
|
|
11
|
+
}, {
|
|
12
|
+
appKey: string;
|
|
13
|
+
actionType: "create" | "update" | "search" | "delete" | "read" | "write";
|
|
14
|
+
actionKey: string;
|
|
15
|
+
}>;
|
|
16
|
+
export type GetActionOptions = z.infer<typeof GetActionSchema> & {
|
|
17
|
+
/** Base URL for Zapier API */
|
|
18
|
+
baseUrl?: string;
|
|
19
|
+
/** Authentication token */
|
|
20
|
+
token?: string;
|
|
21
|
+
/** Optional pre-instantiated API client */
|
|
22
|
+
api?: any;
|
|
23
|
+
/** Enable debug logging */
|
|
24
|
+
debug?: boolean;
|
|
25
|
+
/** Custom fetch implementation */
|
|
26
|
+
fetch?: typeof globalThis.fetch;
|
|
27
|
+
};
|
|
28
|
+
export interface GetActionSdkFunction {
|
|
29
|
+
getAction: (options: GetActionOptions) => Promise<Action>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetActionSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const properties_1 = require("../../types/properties");
|
|
6
|
+
// Pure Zod schema - no resolver metadata!
|
|
7
|
+
exports.GetActionSchema = zod_1.z
|
|
8
|
+
.object({
|
|
9
|
+
appKey: properties_1.AppKeyPropertySchema,
|
|
10
|
+
actionType: properties_1.ActionTypePropertySchema,
|
|
11
|
+
actionKey: properties_1.ActionKeyPropertySchema,
|
|
12
|
+
})
|
|
13
|
+
.describe("Get detailed information about a specific action");
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { Integration
|
|
2
|
-
|
|
3
|
-
key: string;
|
|
4
|
-
}
|
|
1
|
+
import type { Integration } from "../../types/domain";
|
|
2
|
+
import type { GetAppOptions } from "./schemas";
|
|
5
3
|
/**
|
|
6
4
|
* Get a specific app by key
|
|
7
5
|
*
|