@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,54 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { withFormatter } from "../schema-utils";
|
|
3
|
+
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// Auth Schemas
|
|
6
|
+
// ============================================================================
|
|
7
|
+
|
|
8
|
+
export const AuthItemSchema = withFormatter(
|
|
9
|
+
z.object({
|
|
10
|
+
id: z.number(),
|
|
11
|
+
title: z.string().optional(),
|
|
12
|
+
identifier: z.string().optional(),
|
|
13
|
+
account_id: z.string().optional(),
|
|
14
|
+
is_private: z.boolean().optional(),
|
|
15
|
+
shared_with_all: z.boolean().optional(),
|
|
16
|
+
marked_stale_at: z.string().optional(),
|
|
17
|
+
}),
|
|
18
|
+
{
|
|
19
|
+
format: (item) => {
|
|
20
|
+
const details = [];
|
|
21
|
+
|
|
22
|
+
if (item.identifier) {
|
|
23
|
+
details.push({
|
|
24
|
+
text: `Identifier: ${item.identifier}`,
|
|
25
|
+
style: "accent" as const,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
details.push({
|
|
30
|
+
text: `Account: ${item.account_id || "unknown"} | Private: ${item.is_private || false} | Shared: ${item.shared_with_all || false}`,
|
|
31
|
+
style: "dim" as const,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (item.marked_stale_at) {
|
|
35
|
+
details.push({
|
|
36
|
+
text: `⚠️ Marked stale: ${new Date(item.marked_stale_at).toLocaleDateString()}`,
|
|
37
|
+
style: "warning" as const,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
title: item.title || `Authentication ${item.id}`,
|
|
43
|
+
subtitle: `(ID: ${item.id})`,
|
|
44
|
+
details,
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// ============================================================================
|
|
51
|
+
// Type Exports
|
|
52
|
+
// ============================================================================
|
|
53
|
+
|
|
54
|
+
export type AuthItem = z.infer<typeof AuthItemSchema>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { withFormatter } from "../schema-utils";
|
|
3
|
+
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// Field Schemas
|
|
6
|
+
// ============================================================================
|
|
7
|
+
|
|
8
|
+
export const FieldItemSchema = withFormatter(
|
|
9
|
+
z.object({
|
|
10
|
+
key: z.string(),
|
|
11
|
+
name: z.string().optional(),
|
|
12
|
+
description: z.string().optional(),
|
|
13
|
+
}),
|
|
14
|
+
{
|
|
15
|
+
format: (item) => {
|
|
16
|
+
const details = [];
|
|
17
|
+
if (item.description) {
|
|
18
|
+
details.push({ text: item.description, style: "dim" as const });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
title: item.name || item.key,
|
|
23
|
+
subtitle: `(${item.key})`,
|
|
24
|
+
details,
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
// ============================================================================
|
|
31
|
+
// Type Exports
|
|
32
|
+
// ============================================================================
|
|
33
|
+
|
|
34
|
+
export type FieldItem = z.infer<typeof FieldItemSchema>;
|
package/src/sdk.ts
CHANGED
|
@@ -1,26 +1,172 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseSdkOptions } from "./types";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { createZapierApi } from "./api";
|
|
2
|
+
import { BaseSdkOptions } from "./types/domain";
|
|
3
|
+
// Import function implementations
|
|
4
|
+
import { listApps } from "./functions/listApps";
|
|
5
|
+
import { getApp } from "./functions/getApp";
|
|
6
|
+
import { listActions } from "./functions/listActions";
|
|
7
|
+
import { getAction } from "./functions/getAction";
|
|
8
|
+
import { runAction } from "./functions/runAction";
|
|
9
|
+
import { listAuthentications } from "./functions/listAuthentications";
|
|
10
|
+
import { findFirstAuthentication } from "./functions/findFirstAuthentication";
|
|
11
|
+
import { findUniqueAuthentication } from "./functions/findUniqueAuthentication";
|
|
12
|
+
import { listFields } from "./functions/listFields";
|
|
13
|
+
import { generateTypes } from "./functions/generateTypes";
|
|
14
|
+
import { bundleCode } from "./functions/bundleCode";
|
|
15
|
+
|
|
16
|
+
// Import function registry info objects (only for CLI registry)
|
|
17
|
+
import { listAppsInfo } from "./functions/listApps/info";
|
|
18
|
+
import { getAppInfo } from "./functions/getApp/info";
|
|
19
|
+
import { listActionsInfo } from "./functions/listActions/info";
|
|
20
|
+
import { getActionInfo } from "./functions/getAction/info";
|
|
21
|
+
import { runActionInfo } from "./functions/runAction/info";
|
|
22
|
+
import { listAuthenticationsInfo } from "./functions/listAuthentications/info";
|
|
23
|
+
import { findFirstAuthenticationInfo } from "./functions/findFirstAuthentication/info";
|
|
24
|
+
import { findUniqueAuthenticationInfo } from "./functions/findUniqueAuthentication/info";
|
|
25
|
+
import { listFieldsInfo } from "./functions/listFields/info";
|
|
26
|
+
import { generateTypesInfo } from "./functions/generateTypes/info";
|
|
27
|
+
import { bundleCodeInfo } from "./functions/bundleCode/info";
|
|
28
|
+
|
|
29
|
+
// Function registry as array - uses names from function info objects
|
|
30
|
+
const functionRegistry = [
|
|
31
|
+
listAppsInfo,
|
|
32
|
+
getAppInfo,
|
|
33
|
+
listActionsInfo,
|
|
34
|
+
getActionInfo,
|
|
35
|
+
runActionInfo,
|
|
36
|
+
listAuthenticationsInfo,
|
|
37
|
+
findFirstAuthenticationInfo,
|
|
38
|
+
findUniqueAuthenticationInfo,
|
|
39
|
+
listFieldsInfo,
|
|
40
|
+
generateTypesInfo,
|
|
41
|
+
bundleCodeInfo,
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
// Import the properly typed SDK interface
|
|
45
|
+
import type { ZapierSdk } from "./types/sdk";
|
|
46
|
+
|
|
47
|
+
// Import plugin functions
|
|
48
|
+
import { createAppsPlugin } from "./plugins/apps/index";
|
|
49
|
+
|
|
50
|
+
// TODO: Add plugin registry back when needed for CLI compatibility
|
|
51
|
+
|
|
52
|
+
// Base SDK functions interface (functions + registry, no plugins)
|
|
53
|
+
interface BaseZapierSdkWithFunctions {
|
|
54
|
+
__registry: Array<{
|
|
55
|
+
name: string;
|
|
56
|
+
inputSchema: any;
|
|
57
|
+
implementation: Function;
|
|
58
|
+
}>;
|
|
59
|
+
listApps: ZapierSdk["listApps"];
|
|
60
|
+
getApp: ZapierSdk["getApp"];
|
|
61
|
+
listActions: ZapierSdk["listActions"];
|
|
62
|
+
getAction: ZapierSdk["getAction"];
|
|
63
|
+
runAction: ZapierSdk["runAction"];
|
|
64
|
+
listAuthentications: ZapierSdk["listAuthentications"];
|
|
65
|
+
findFirstAuthentication: ZapierSdk["findFirstAuthentication"];
|
|
66
|
+
findUniqueAuthentication: ZapierSdk["findUniqueAuthentication"];
|
|
67
|
+
listFields: ZapierSdk["listFields"];
|
|
68
|
+
generateTypes: ZapierSdk["generateTypes"];
|
|
69
|
+
bundleCode: ZapierSdk["bundleCode"];
|
|
9
70
|
}
|
|
10
71
|
|
|
72
|
+
// Full SDK interface with plugins applied
|
|
73
|
+
export type { ZapierSdk } from "./types/sdk";
|
|
74
|
+
|
|
11
75
|
export interface ZapierSdkOptions extends BaseSdkOptions {}
|
|
12
76
|
|
|
77
|
+
function createBaseZapierSdk(
|
|
78
|
+
options: ZapierSdkOptions = {},
|
|
79
|
+
): BaseZapierSdkWithFunctions {
|
|
80
|
+
// Auto-load .env files (searches up directory tree)
|
|
81
|
+
try {
|
|
82
|
+
const { findUpSync } = require("find-up");
|
|
83
|
+
const envPath = findUpSync(".env");
|
|
84
|
+
if (envPath) {
|
|
85
|
+
require("dotenv").config({ path: envPath, quiet: true });
|
|
86
|
+
}
|
|
87
|
+
} catch {
|
|
88
|
+
// Silently fail if dotenv/find-up not available or .env not found
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const {
|
|
92
|
+
fetch: customFetch = globalThis.fetch,
|
|
93
|
+
baseUrl = "https://zapier.com",
|
|
94
|
+
token,
|
|
95
|
+
debug = false,
|
|
96
|
+
} = options;
|
|
97
|
+
|
|
98
|
+
// If no token provided, try to get it from environment variable
|
|
99
|
+
const finalToken = token || process.env.ZAPIER_TOKEN;
|
|
100
|
+
|
|
101
|
+
// Create the API client
|
|
102
|
+
const api = createZapierApi({
|
|
103
|
+
baseUrl,
|
|
104
|
+
token: finalToken,
|
|
105
|
+
debug,
|
|
106
|
+
fetch: customFetch,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Build SDK directly - TypeScript will enforce correct implementation
|
|
110
|
+
const sdk: BaseZapierSdkWithFunctions = {
|
|
111
|
+
// Registry for CLI
|
|
112
|
+
__registry: functionRegistry,
|
|
113
|
+
|
|
114
|
+
// Function implementations with API config injection
|
|
115
|
+
listApps: (options = {}) =>
|
|
116
|
+
listApps({ ...options, api, token: finalToken }),
|
|
117
|
+
getApp: (options) => getApp({ ...options, api, token: finalToken }),
|
|
118
|
+
listActions: (options = {}) =>
|
|
119
|
+
listActions({ ...options, api, token: finalToken }),
|
|
120
|
+
getAction: (options) => getAction({ ...options, api, token: finalToken }),
|
|
121
|
+
runAction: (options) => runAction({ ...options, api, token: finalToken }),
|
|
122
|
+
listAuthentications: (options = {}) =>
|
|
123
|
+
listAuthentications({ ...options, api, token: finalToken }),
|
|
124
|
+
findFirstAuthentication: (options = {}) =>
|
|
125
|
+
findFirstAuthentication({ ...options, api, token: finalToken }),
|
|
126
|
+
findUniqueAuthentication: (options = {}) =>
|
|
127
|
+
findUniqueAuthentication({ ...options, api, token: finalToken }),
|
|
128
|
+
listFields: (options) => listFields({ ...options, api, token: finalToken }),
|
|
129
|
+
generateTypes: (options) =>
|
|
130
|
+
generateTypes({ ...options, api, token: finalToken }),
|
|
131
|
+
bundleCode: (options) => bundleCode(options), // No API config needed
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
return sdk;
|
|
135
|
+
}
|
|
136
|
+
|
|
13
137
|
export function createZapierSdk(options: ZapierSdkOptions = {}): ZapierSdk {
|
|
14
|
-
// Create
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
138
|
+
// Create base SDK
|
|
139
|
+
const baseSdk = createBaseZapierSdk(options);
|
|
140
|
+
|
|
141
|
+
// Extract options needed for plugins
|
|
142
|
+
const {
|
|
143
|
+
fetch: customFetch = globalThis.fetch,
|
|
144
|
+
baseUrl = "https://zapier.com",
|
|
145
|
+
token,
|
|
146
|
+
debug = false,
|
|
147
|
+
} = options;
|
|
148
|
+
|
|
149
|
+
const finalToken = token || process.env.ZAPIER_TOKEN;
|
|
150
|
+
|
|
151
|
+
// Create the API client for plugins
|
|
152
|
+
const api = createZapierApi({
|
|
153
|
+
baseUrl,
|
|
154
|
+
token: finalToken,
|
|
155
|
+
debug,
|
|
156
|
+
fetch: customFetch,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Create plugins directly - TypeScript will enforce correct implementation
|
|
160
|
+
const appsPlugin = createAppsPlugin({
|
|
161
|
+
api,
|
|
162
|
+
token: finalToken,
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Compose final SDK - TypeScript will enforce we have all required properties
|
|
166
|
+
const fullSdk: ZapierSdk = {
|
|
167
|
+
...baseSdk,
|
|
168
|
+
apps: appsPlugin,
|
|
25
169
|
};
|
|
170
|
+
|
|
171
|
+
return fullSdk;
|
|
26
172
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Re-export API types from the API module
|
|
2
|
+
export type {
|
|
3
|
+
Integration,
|
|
4
|
+
Action,
|
|
5
|
+
Trigger,
|
|
6
|
+
Field,
|
|
7
|
+
Choice,
|
|
8
|
+
ActionExecutionResult,
|
|
9
|
+
ActionField,
|
|
10
|
+
ActionFieldChoice,
|
|
11
|
+
NeedsRequest,
|
|
12
|
+
NeedsResponse,
|
|
13
|
+
Authentication,
|
|
14
|
+
AuthenticationsResponse,
|
|
15
|
+
} from "../api/types";
|
|
16
|
+
|
|
17
|
+
// SDK Configuration Types
|
|
18
|
+
export interface ActionExecutionOptions {
|
|
19
|
+
inputs?: Record<string, any>;
|
|
20
|
+
authenticationId?: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface AuthObject {
|
|
24
|
+
id: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface BaseSdkOptions {
|
|
28
|
+
token?: string;
|
|
29
|
+
fetch?: typeof fetch;
|
|
30
|
+
baseUrl?: string;
|
|
31
|
+
debug?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Error Classes
|
|
35
|
+
export class ZapierSdkError extends Error {
|
|
36
|
+
constructor(
|
|
37
|
+
message: string,
|
|
38
|
+
public code?: string,
|
|
39
|
+
) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.name = "ZapierSdkError";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export class AppNotFoundError extends ZapierSdkError {
|
|
46
|
+
appKey: string;
|
|
47
|
+
|
|
48
|
+
constructor(appKey: string) {
|
|
49
|
+
super(`App "${appKey}" not found`);
|
|
50
|
+
this.name = "AppNotFoundError";
|
|
51
|
+
this.code = "APP_NOT_FOUND";
|
|
52
|
+
this.appKey = appKey;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { withPositional } from "../schema-utils";
|
|
3
|
+
|
|
4
|
+
// Shared property definitions for common parameters across functions
|
|
5
|
+
// These can be reused in function schemas without duplication
|
|
6
|
+
|
|
7
|
+
export const AppKeyPropertySchema = withPositional(
|
|
8
|
+
z.string().min(1).describe("App slug (e.g., 'slack', 'github')"),
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
export const ActionTypePropertySchema = z
|
|
12
|
+
.enum(["read", "write", "search", "create", "update", "delete"])
|
|
13
|
+
.describe("Action type that matches the action's defined type");
|
|
14
|
+
|
|
15
|
+
export const ActionKeyPropertySchema = z
|
|
16
|
+
.string()
|
|
17
|
+
.min(1)
|
|
18
|
+
.describe("Action key to execute");
|
|
19
|
+
|
|
20
|
+
export const AuthenticationIdPropertySchema = z
|
|
21
|
+
.number()
|
|
22
|
+
.int()
|
|
23
|
+
.describe("Authentication ID to use for this action");
|
|
24
|
+
|
|
25
|
+
export const InputsPropertySchema = z
|
|
26
|
+
.record(z.any())
|
|
27
|
+
.describe("Input parameters for the action");
|
|
28
|
+
|
|
29
|
+
export const LimitPropertySchema = z
|
|
30
|
+
.number()
|
|
31
|
+
.int()
|
|
32
|
+
.min(1)
|
|
33
|
+
.max(1000)
|
|
34
|
+
.default(50)
|
|
35
|
+
.describe("Maximum number of items to return");
|
|
36
|
+
|
|
37
|
+
export const OffsetPropertySchema = z
|
|
38
|
+
.number()
|
|
39
|
+
.int()
|
|
40
|
+
.min(0)
|
|
41
|
+
.default(0)
|
|
42
|
+
.describe("Number of items to skip for pagination");
|
|
43
|
+
|
|
44
|
+
export const OutputPropertySchema = z.string().describe("Output file path");
|
|
45
|
+
|
|
46
|
+
export const DebugPropertySchema = z
|
|
47
|
+
.boolean()
|
|
48
|
+
.default(false)
|
|
49
|
+
.describe("Enable debug logging");
|
|
50
|
+
|
|
51
|
+
export const ParamsPropertySchema = z
|
|
52
|
+
.record(z.any())
|
|
53
|
+
.describe("Additional parameters");
|
|
54
|
+
|
|
55
|
+
// Inferred TypeScript types for the properties
|
|
56
|
+
export type AppKeyProperty = z.infer<typeof AppKeyPropertySchema>;
|
|
57
|
+
export type ActionTypeProperty = z.infer<typeof ActionTypePropertySchema>;
|
|
58
|
+
export type ActionKeyProperty = z.infer<typeof ActionKeyPropertySchema>;
|
|
59
|
+
export type AuthenticationIdProperty = z.infer<
|
|
60
|
+
typeof AuthenticationIdPropertySchema
|
|
61
|
+
>;
|
|
62
|
+
export type InputsProperty = z.infer<typeof InputsPropertySchema>;
|
|
63
|
+
export type LimitProperty = z.infer<typeof LimitPropertySchema>;
|
|
64
|
+
export type OffsetProperty = z.infer<typeof OffsetPropertySchema>;
|
|
65
|
+
export type OutputProperty = z.infer<typeof OutputPropertySchema>;
|
|
66
|
+
export type DebugProperty = z.infer<typeof DebugPropertySchema>;
|
|
67
|
+
export type ParamsProperty = z.infer<typeof ParamsPropertySchema>;
|
package/src/types/sdk.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// SDK interface composed from individual function interfaces
|
|
2
|
+
import type { ListActionsSdkFunction } from "../functions/listActions/schemas";
|
|
3
|
+
import type { GetActionSdkFunction } from "../functions/getAction/schemas";
|
|
4
|
+
import type { GetAppSdkFunction } from "../functions/getApp/schemas";
|
|
5
|
+
import type { RunActionSdkFunction } from "../functions/runAction/schemas";
|
|
6
|
+
import type { ListFieldsSdkFunction } from "../functions/listFields/schemas";
|
|
7
|
+
import type { ListAuthenticationsSdkFunction } from "../functions/listAuthentications/schemas";
|
|
8
|
+
import type { FindFirstAuthenticationSdkFunction } from "../functions/findFirstAuthentication/schemas";
|
|
9
|
+
import type { FindUniqueAuthenticationSdkFunction } from "../functions/findUniqueAuthentication/schemas";
|
|
10
|
+
import type { GenerateTypesSdkFunction } from "../functions/generateTypes/schemas";
|
|
11
|
+
import type { ListAppsSdkFunction } from "../functions/listApps/schemas";
|
|
12
|
+
import type { BundleCodeSdkFunction } from "../functions/bundleCode/schemas";
|
|
13
|
+
|
|
14
|
+
// Plugin interfaces
|
|
15
|
+
import type { AppsPluginSdkExtension } from "../plugins/apps/types";
|
|
16
|
+
|
|
17
|
+
// Compose SDK functions from individual function interfaces
|
|
18
|
+
export interface ZapierSdkFunctions
|
|
19
|
+
extends ListActionsSdkFunction,
|
|
20
|
+
GetActionSdkFunction,
|
|
21
|
+
GetAppSdkFunction,
|
|
22
|
+
RunActionSdkFunction,
|
|
23
|
+
ListFieldsSdkFunction,
|
|
24
|
+
ListAuthenticationsSdkFunction,
|
|
25
|
+
FindFirstAuthenticationSdkFunction,
|
|
26
|
+
FindUniqueAuthenticationSdkFunction,
|
|
27
|
+
GenerateTypesSdkFunction,
|
|
28
|
+
ListAppsSdkFunction,
|
|
29
|
+
BundleCodeSdkFunction {
|
|
30
|
+
// All functions now properly typed!
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Compose SDK plugins from individual plugin interfaces
|
|
34
|
+
export interface ZapierSdkPlugins extends AppsPluginSdkExtension {
|
|
35
|
+
// All plugins now properly typed!
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Main SDK interface with functions and plugins
|
|
39
|
+
export interface ZapierSdk extends ZapierSdkFunctions, ZapierSdkPlugins {
|
|
40
|
+
// Special property for CLI to access schemas
|
|
41
|
+
__registry: Array<{
|
|
42
|
+
name: string;
|
|
43
|
+
inputSchema: any;
|
|
44
|
+
implementation: Function;
|
|
45
|
+
}>;
|
|
46
|
+
}
|
package/dist/actions-sdk.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Integration, Action, ActionExecutionOptions, ActionExecutionResult, ActionField, Authentication, BaseSdkOptions } from "./types";
|
|
2
|
-
import { AppsListOptions, AppsGetOptions, ActionsListOptions, ActionsGetOptions, ActionsRunOptions, AuthsListOptions, AuthsFindOptions, FieldsListOptions, GenerateOptions, BundleOptions } from "./schemas";
|
|
3
|
-
export * from "./schemas";
|
|
4
|
-
export * from "./output-schemas";
|
|
5
|
-
export interface ActionsSdk {
|
|
6
|
-
apps: AppsService;
|
|
7
|
-
actions: ActionsService;
|
|
8
|
-
auths: AuthsService;
|
|
9
|
-
fields: FieldsService;
|
|
10
|
-
generate: GenerateFunction;
|
|
11
|
-
bundle: BundleFunction;
|
|
12
|
-
}
|
|
13
|
-
export interface AppsService {
|
|
14
|
-
list(options?: AppsListOptions): Promise<Integration[]>;
|
|
15
|
-
get(options: AppsGetOptions): Promise<Integration>;
|
|
16
|
-
}
|
|
17
|
-
interface ActionRunner {
|
|
18
|
-
(params: ActionsRunOptions): Promise<ActionExecutionResult>;
|
|
19
|
-
}
|
|
20
|
-
interface ActionProxy {
|
|
21
|
-
[app: string]: {
|
|
22
|
-
[type: string]: {
|
|
23
|
-
[action: string]: (options?: ActionExecutionOptions) => Promise<ActionExecutionResult>;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
export interface GenerateFunction {
|
|
28
|
-
(options: GenerateOptions): Promise<string>;
|
|
29
|
-
}
|
|
30
|
-
export interface BundleFunction {
|
|
31
|
-
(options: BundleOptions): Promise<string>;
|
|
32
|
-
}
|
|
33
|
-
export interface ActionsService {
|
|
34
|
-
list(options?: ActionsListOptions): Promise<Action[]>;
|
|
35
|
-
get(options: ActionsGetOptions): Promise<Action>;
|
|
36
|
-
run: ActionRunner & ActionProxy;
|
|
37
|
-
}
|
|
38
|
-
export interface AuthsService {
|
|
39
|
-
list(options?: AuthsListOptions): Promise<Authentication[]>;
|
|
40
|
-
find(options: AuthsFindOptions): number;
|
|
41
|
-
}
|
|
42
|
-
export interface FieldsService {
|
|
43
|
-
list(options: FieldsListOptions): Promise<ActionField[]>;
|
|
44
|
-
}
|
|
45
|
-
export interface ActionsSdkOptions extends BaseSdkOptions {
|
|
46
|
-
}
|
|
47
|
-
export declare function createActionsSdk(options?: ActionsSdkOptions): ActionsSdk;
|