@zapier/zapier-sdk 0.0.1 → 0.0.3
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/actions-sdk.d.ts +47 -0
- package/dist/actions-sdk.js +208 -0
- package/dist/api.d.ts +62 -0
- package/dist/api.js +227 -0
- package/dist/functions/bundleCode.d.ts +18 -0
- package/dist/functions/bundleCode.js +91 -0
- package/dist/functions/generateTypes.d.ts +16 -0
- package/dist/functions/generateTypes.js +271 -0
- package/dist/functions/getAction.d.ts +16 -0
- package/dist/functions/getAction.js +25 -0
- package/dist/functions/getApp.d.ts +14 -0
- package/dist/functions/getApp.js +41 -0
- package/dist/functions/listActions.d.ts +15 -0
- package/dist/functions/listActions.js +127 -0
- package/dist/functions/listApps.d.ts +16 -0
- package/dist/functions/listApps.js +50 -0
- package/dist/functions/listAuths.d.ts +18 -0
- package/dist/functions/listAuths.js +118 -0
- package/dist/functions/listFields.d.ts +18 -0
- package/dist/functions/listFields.js +67 -0
- package/dist/functions/runAction.d.ts +18 -0
- package/dist/functions/runAction.js +156 -0
- package/dist/index.d.ts +12 -3
- package/dist/index.js +24 -5
- package/dist/output-schemas.d.ts +95 -0
- package/dist/output-schemas.js +138 -0
- package/dist/schemas.d.ts +338 -0
- package/dist/schemas.js +336 -0
- package/dist/sdk.d.ts +5 -5
- package/dist/sdk.js +8 -8
- package/dist/types.d.ts +196 -0
- package/dist/types.js +41 -0
- package/package.json +5 -3
- package/src/actions-sdk.ts +356 -0
- package/src/api.ts +361 -0
- package/src/functions/bundleCode.ts +85 -0
- package/src/functions/generateTypes.ts +309 -0
- package/src/functions/getAction.ts +34 -0
- package/src/functions/getApp.ts +47 -0
- package/src/functions/listActions.ts +151 -0
- package/src/functions/listApps.ts +65 -0
- package/src/functions/listAuths.ts +161 -0
- package/src/functions/listFields.ts +95 -0
- package/src/functions/runAction.ts +256 -0
- package/src/index.ts +15 -4
- package/src/output-schemas.ts +196 -0
- package/src/schemas.ts +467 -0
- package/src/sdk.ts +13 -13
- package/src/types.ts +257 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listAuths = listAuths;
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const getApp_1 = require("./getApp");
|
|
6
|
+
/**
|
|
7
|
+
* List available authentications with optional filtering
|
|
8
|
+
*
|
|
9
|
+
* This function can be used standalone without instantiating a full SDK,
|
|
10
|
+
* which enables better tree-shaking in applications that only need this functionality.
|
|
11
|
+
*
|
|
12
|
+
* @param options - Filtering, pagination, and API configuration options
|
|
13
|
+
* @returns Promise<Authentication[]> with pagination metadata
|
|
14
|
+
*/
|
|
15
|
+
async function listAuths(options = {}) {
|
|
16
|
+
const { token } = options;
|
|
17
|
+
if (!token && !process.env.ZAPIER_TOKEN) {
|
|
18
|
+
throw new Error("Authentication token is required to list authentications. Please provide token in options or set ZAPIER_TOKEN environment variable.");
|
|
19
|
+
}
|
|
20
|
+
const api = (0, api_1.getOrCreateApiClient)(options);
|
|
21
|
+
// Local function to handle the actual API fetching
|
|
22
|
+
const listAuthsInternal = async (options = {}) => {
|
|
23
|
+
// Build search parameters
|
|
24
|
+
const searchParams = {};
|
|
25
|
+
// Handle appKey filtering by getting the selected_api first
|
|
26
|
+
if (options.appKey) {
|
|
27
|
+
try {
|
|
28
|
+
// Use the standalone getApp function
|
|
29
|
+
const app = await (0, getApp_1.getApp)({
|
|
30
|
+
key: options.appKey,
|
|
31
|
+
api,
|
|
32
|
+
token: options.token,
|
|
33
|
+
baseUrl: options.baseUrl,
|
|
34
|
+
debug: options.debug,
|
|
35
|
+
fetch: options.fetch,
|
|
36
|
+
});
|
|
37
|
+
const selectedApi = app.current_implementation_id;
|
|
38
|
+
if (selectedApi) {
|
|
39
|
+
// Use versionless_selected_api to find auths across all app versions
|
|
40
|
+
// Extract the base name without the version (e.g., "SlackCLIAPI" from "SlackCLIAPI@1.21.1")
|
|
41
|
+
const versionlessApi = selectedApi.split("@")[0];
|
|
42
|
+
searchParams.versionless_selected_api = versionlessApi;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
// If it's an AppNotFoundError, re-throw it
|
|
47
|
+
if (error instanceof Error && error.name === "AppNotFoundError") {
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
// For other errors, continue without app filtering
|
|
51
|
+
console.warn(`Warning: Could not filter by app ${options.appKey}:`, error instanceof Error ? error.message : "Unknown error");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
// Add other query parameters if provided
|
|
55
|
+
if (options.account_id) {
|
|
56
|
+
searchParams.account_id = options.account_id;
|
|
57
|
+
}
|
|
58
|
+
if (options.owner) {
|
|
59
|
+
searchParams.owner = options.owner;
|
|
60
|
+
}
|
|
61
|
+
if (options.limit) {
|
|
62
|
+
searchParams.limit = options.limit.toString();
|
|
63
|
+
}
|
|
64
|
+
if (options.offset) {
|
|
65
|
+
searchParams.offset = options.offset.toString();
|
|
66
|
+
}
|
|
67
|
+
const data = await api.get("/api/v4/authentications/", {
|
|
68
|
+
searchParams,
|
|
69
|
+
customErrorHandler: (response) => {
|
|
70
|
+
if (response.status === 401) {
|
|
71
|
+
return new Error(`Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP ${response.status})`);
|
|
72
|
+
}
|
|
73
|
+
if (response.status === 403) {
|
|
74
|
+
return new Error(`Access forbidden. Your token may not have the required scopes to list authentications. (HTTP ${response.status})`);
|
|
75
|
+
}
|
|
76
|
+
return undefined;
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
// Transform API response
|
|
80
|
+
const auths = data.results || [];
|
|
81
|
+
// Add pagination metadata to the response
|
|
82
|
+
if (auths.length > 0) {
|
|
83
|
+
auths.__pagination = {
|
|
84
|
+
count: data.count,
|
|
85
|
+
hasNext: !!data.next,
|
|
86
|
+
hasPrevious: !!data.previous,
|
|
87
|
+
nextUrl: data.next,
|
|
88
|
+
previousUrl: data.previous,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return auths;
|
|
92
|
+
};
|
|
93
|
+
// If a limit is provided and no specific owner filter, prioritize owned auths
|
|
94
|
+
if (options.limit && options.owner === undefined) {
|
|
95
|
+
// First get owned auths
|
|
96
|
+
const ownedAuths = await listAuthsInternal({
|
|
97
|
+
...options,
|
|
98
|
+
owner: "me",
|
|
99
|
+
});
|
|
100
|
+
// If we have enough owned auths, just slice and return
|
|
101
|
+
if (ownedAuths.length >= options.limit) {
|
|
102
|
+
return ownedAuths.slice(0, options.limit);
|
|
103
|
+
}
|
|
104
|
+
// Get all auths up to the original limit to fill remaining slots
|
|
105
|
+
const allAuths = await listAuthsInternal({
|
|
106
|
+
...options,
|
|
107
|
+
owner: undefined,
|
|
108
|
+
});
|
|
109
|
+
// Filter out auths the user already owns to avoid duplicates
|
|
110
|
+
const ownedAuthIds = new Set(ownedAuths.map((auth) => auth.id));
|
|
111
|
+
const additionalAuths = allAuths.filter((auth) => !ownedAuthIds.has(auth.id));
|
|
112
|
+
// Combine and slice to the requested limit
|
|
113
|
+
const combined = [...ownedAuths, ...additionalAuths];
|
|
114
|
+
return combined.slice(0, options.limit);
|
|
115
|
+
}
|
|
116
|
+
// Standard implementation for non-prioritized requests
|
|
117
|
+
return listAuthsInternal(options);
|
|
118
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ActionField, FunctionConfig } from "../types";
|
|
2
|
+
export interface ListFieldsOptions extends FunctionConfig {
|
|
3
|
+
app: string;
|
|
4
|
+
action: string;
|
|
5
|
+
type: string;
|
|
6
|
+
authId?: number;
|
|
7
|
+
params?: Record<string, any>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* List available fields for an action
|
|
11
|
+
*
|
|
12
|
+
* This function can be used standalone without instantiating a full SDK,
|
|
13
|
+
* which enables better tree-shaking in applications that only need this functionality.
|
|
14
|
+
*
|
|
15
|
+
* @param options - Action details, auth ID, params, and API configuration options
|
|
16
|
+
* @returns Promise<ActionField[]>
|
|
17
|
+
*/
|
|
18
|
+
export declare function listFields(options: ListFieldsOptions): Promise<ActionField[]>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listFields = listFields;
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const getApp_1 = require("./getApp");
|
|
6
|
+
/**
|
|
7
|
+
* List available fields for an action
|
|
8
|
+
*
|
|
9
|
+
* This function can be used standalone without instantiating a full SDK,
|
|
10
|
+
* which enables better tree-shaking in applications that only need this functionality.
|
|
11
|
+
*
|
|
12
|
+
* @param options - Action details, auth ID, params, and API configuration options
|
|
13
|
+
* @returns Promise<ActionField[]>
|
|
14
|
+
*/
|
|
15
|
+
async function listFields(options) {
|
|
16
|
+
const api = (0, api_1.getOrCreateApiClient)(options);
|
|
17
|
+
// Map consistent parameter names to internal API names
|
|
18
|
+
const { app, action, type, authId, params } = options;
|
|
19
|
+
const appKey = app;
|
|
20
|
+
const actionKey = action;
|
|
21
|
+
const actionType = type;
|
|
22
|
+
// Use the standalone getApp function
|
|
23
|
+
const appData = await (0, getApp_1.getApp)({
|
|
24
|
+
key: appKey,
|
|
25
|
+
api,
|
|
26
|
+
token: options.token,
|
|
27
|
+
baseUrl: options.baseUrl,
|
|
28
|
+
debug: options.debug,
|
|
29
|
+
fetch: options.fetch,
|
|
30
|
+
});
|
|
31
|
+
const selectedApi = appData.current_implementation_id;
|
|
32
|
+
if (!selectedApi) {
|
|
33
|
+
throw new Error("No current_implementation_id found for app");
|
|
34
|
+
}
|
|
35
|
+
// Build needs request
|
|
36
|
+
const needsRequest = {
|
|
37
|
+
selected_api: selectedApi,
|
|
38
|
+
action: actionKey,
|
|
39
|
+
type_of: actionType,
|
|
40
|
+
authentication_id: authId,
|
|
41
|
+
params: params || {},
|
|
42
|
+
};
|
|
43
|
+
const needsData = await api.post("/api/v4/implementations/needs/", needsRequest);
|
|
44
|
+
if (!needsData.success) {
|
|
45
|
+
throw new Error(`Failed to get action fields: ${needsData.errors?.join(", ") || "Unknown error"}`);
|
|
46
|
+
}
|
|
47
|
+
// Transform API response to our ActionField interface
|
|
48
|
+
return (needsData.needs || []).map((need) => ({
|
|
49
|
+
key: need.key,
|
|
50
|
+
label: need.label,
|
|
51
|
+
required: need.required || false,
|
|
52
|
+
type: need.type,
|
|
53
|
+
helpText: need.help_text,
|
|
54
|
+
helpTextHtml: need.help_text_html,
|
|
55
|
+
choices: need.choices?.map((choice) => ({
|
|
56
|
+
value: choice.value,
|
|
57
|
+
label: choice.label,
|
|
58
|
+
})),
|
|
59
|
+
default: need.default,
|
|
60
|
+
placeholder: need.placeholder,
|
|
61
|
+
computed: need.computed,
|
|
62
|
+
customField: need.custom_field,
|
|
63
|
+
dependsOn: need.depends_on,
|
|
64
|
+
format: need.format,
|
|
65
|
+
inputFormat: need.input_format,
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ActionExecutionResult, FunctionConfig } from "../types";
|
|
2
|
+
export interface RunActionOptions extends FunctionConfig {
|
|
3
|
+
app: string;
|
|
4
|
+
type: string;
|
|
5
|
+
action: string;
|
|
6
|
+
inputs?: Record<string, any>;
|
|
7
|
+
authId?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Execute an action
|
|
11
|
+
*
|
|
12
|
+
* This function can be used standalone without instantiating a full SDK,
|
|
13
|
+
* which enables better tree-shaking in applications that only need this functionality.
|
|
14
|
+
*
|
|
15
|
+
* @param options - Action execution parameters and API configuration options
|
|
16
|
+
* @returns Promise<ActionExecutionResult>
|
|
17
|
+
*/
|
|
18
|
+
export declare function runAction(options: RunActionOptions): Promise<ActionExecutionResult>;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runAction = runAction;
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const getAction_1 = require("./getAction");
|
|
6
|
+
const getApp_1 = require("./getApp");
|
|
7
|
+
/**
|
|
8
|
+
* Execute an action
|
|
9
|
+
*
|
|
10
|
+
* This function can be used standalone without instantiating a full SDK,
|
|
11
|
+
* which enables better tree-shaking in applications that only need this functionality.
|
|
12
|
+
*
|
|
13
|
+
* @param options - Action execution parameters and API configuration options
|
|
14
|
+
* @returns Promise<ActionExecutionResult>
|
|
15
|
+
*/
|
|
16
|
+
async function runAction(options) {
|
|
17
|
+
const { app, type, action, inputs, authId: providedAuthId, token } = options;
|
|
18
|
+
if (!token && !process.env.ZAPIER_TOKEN) {
|
|
19
|
+
throw new Error("Authentication token is required to run actions. Please provide token in options or set ZAPIER_TOKEN environment variable.");
|
|
20
|
+
}
|
|
21
|
+
const api = (0, api_1.getOrCreateApiClient)(options);
|
|
22
|
+
// Validate that the action exists
|
|
23
|
+
const actionData = await (0, getAction_1.getAction)({
|
|
24
|
+
...options,
|
|
25
|
+
app: app,
|
|
26
|
+
action: action,
|
|
27
|
+
type: type,
|
|
28
|
+
});
|
|
29
|
+
// Validate action type matches
|
|
30
|
+
if (actionData.type !== type) {
|
|
31
|
+
throw new Error(`Action type mismatch: expected ${type}, got ${actionData.type}`);
|
|
32
|
+
}
|
|
33
|
+
// Execute the action using the appropriate API based on action type
|
|
34
|
+
const startTime = Date.now();
|
|
35
|
+
const result = await executeActionWithStrategy({
|
|
36
|
+
api,
|
|
37
|
+
appSlug: app,
|
|
38
|
+
actionKey: action,
|
|
39
|
+
actionType: actionData.type,
|
|
40
|
+
executionOptions: { inputs: inputs || {} },
|
|
41
|
+
auth: token
|
|
42
|
+
? { token: token, authentication_id: providedAuthId }
|
|
43
|
+
: undefined,
|
|
44
|
+
options,
|
|
45
|
+
});
|
|
46
|
+
const executionTime = Date.now() - startTime;
|
|
47
|
+
return {
|
|
48
|
+
success: true,
|
|
49
|
+
data: result,
|
|
50
|
+
metadata: {
|
|
51
|
+
executionTime,
|
|
52
|
+
requestId: (0, api_1.generateRequestId)(),
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
async function executeActionWithStrategy(strategyOptions) {
|
|
57
|
+
const { api, appSlug, actionKey, actionType, executionOptions, auth, options, } = strategyOptions;
|
|
58
|
+
// Actions API supports: read, read_bulk, write
|
|
59
|
+
// Invoke API supports: search, read, write, read_bulk, and more
|
|
60
|
+
const actionsApiTypes = ["read", "read_bulk", "write"];
|
|
61
|
+
const useActionsApi = actionsApiTypes.includes(actionType);
|
|
62
|
+
if (useActionsApi) {
|
|
63
|
+
return executeActionViaActionsApi({
|
|
64
|
+
api,
|
|
65
|
+
appSlug,
|
|
66
|
+
actionKey,
|
|
67
|
+
actionType,
|
|
68
|
+
executionOptions,
|
|
69
|
+
auth,
|
|
70
|
+
options,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
return executeActionViaInvokeApi({
|
|
75
|
+
api,
|
|
76
|
+
appSlug,
|
|
77
|
+
actionKey,
|
|
78
|
+
actionType,
|
|
79
|
+
executionOptions,
|
|
80
|
+
auth,
|
|
81
|
+
options,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function executeActionViaActionsApi(apiOptions) {
|
|
86
|
+
const { api, appSlug, actionKey, actionType, executionOptions, auth, options, } = apiOptions;
|
|
87
|
+
// Use the standalone getApp function
|
|
88
|
+
const appData = await (0, getApp_1.getApp)({
|
|
89
|
+
key: appSlug,
|
|
90
|
+
api,
|
|
91
|
+
token: options.token,
|
|
92
|
+
baseUrl: options.baseUrl,
|
|
93
|
+
debug: options.debug,
|
|
94
|
+
fetch: options.fetch,
|
|
95
|
+
});
|
|
96
|
+
const selectedApi = appData.current_implementation_id;
|
|
97
|
+
if (!selectedApi) {
|
|
98
|
+
throw new Error("No current_implementation_id found for app");
|
|
99
|
+
}
|
|
100
|
+
if (!auth?.token) {
|
|
101
|
+
throw new Error("Authentication token is required. Please provide token when creating the SDK.");
|
|
102
|
+
}
|
|
103
|
+
// Step 1: POST to /actions/v1/runs to start execution
|
|
104
|
+
const runRequest = {
|
|
105
|
+
data: {
|
|
106
|
+
authentication_id: auth.authentication_id || 1,
|
|
107
|
+
selected_api: selectedApi,
|
|
108
|
+
action_key: actionKey,
|
|
109
|
+
action_type: actionType,
|
|
110
|
+
inputs: executionOptions.inputs || {},
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
const runData = await api.post("/api/actions/v1/runs", runRequest);
|
|
114
|
+
const runId = runData.data.id;
|
|
115
|
+
// Step 2: Poll GET /actions/v1/runs/{run_id} for results
|
|
116
|
+
return await api.poll(`/api/actions/v1/runs/${runId}`, {
|
|
117
|
+
successStatus: 200,
|
|
118
|
+
pendingStatus: 202,
|
|
119
|
+
resultExtractor: (result) => result.data,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
async function executeActionViaInvokeApi(apiOptions) {
|
|
123
|
+
const { api, appSlug, actionKey, actionType, executionOptions, auth, options, } = apiOptions;
|
|
124
|
+
// Use the standalone getApp function
|
|
125
|
+
const appData = await (0, getApp_1.getApp)({
|
|
126
|
+
key: appSlug,
|
|
127
|
+
api,
|
|
128
|
+
token: options.token,
|
|
129
|
+
baseUrl: options.baseUrl,
|
|
130
|
+
debug: options.debug,
|
|
131
|
+
fetch: options.fetch,
|
|
132
|
+
});
|
|
133
|
+
const selectedApi = appData.current_implementation_id;
|
|
134
|
+
if (!selectedApi) {
|
|
135
|
+
throw new Error("No current_implementation_id found for app");
|
|
136
|
+
}
|
|
137
|
+
if (!auth?.token) {
|
|
138
|
+
throw new Error("Authentication token is required. Please provide token when creating the SDK.");
|
|
139
|
+
}
|
|
140
|
+
// Step 1: POST to /invoke/v1/invoke to start execution
|
|
141
|
+
const invokeRequest = {
|
|
142
|
+
selected_api: selectedApi,
|
|
143
|
+
action: actionKey,
|
|
144
|
+
type_of: actionType,
|
|
145
|
+
authentication_id: auth.authentication_id || 1,
|
|
146
|
+
params: executionOptions.inputs || {},
|
|
147
|
+
};
|
|
148
|
+
const invokeData = await api.post("/api/invoke/v1/invoke", invokeRequest);
|
|
149
|
+
const invocationId = invokeData.invocation_id;
|
|
150
|
+
// Step 2: Poll GET /invoke/v1/invoke/{invocation_id} for results
|
|
151
|
+
return await api.poll(`/api/invoke/v1/invoke/${invocationId}`, {
|
|
152
|
+
successStatus: 200,
|
|
153
|
+
pendingStatus: 202,
|
|
154
|
+
resultExtractor: (result) => result.results || result,
|
|
155
|
+
});
|
|
156
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
export * from "
|
|
2
|
-
export * from "
|
|
3
|
-
export {
|
|
1
|
+
export * from "./types";
|
|
2
|
+
export * from "./actions-sdk";
|
|
3
|
+
export { listAuths } from "./functions/listAuths";
|
|
4
|
+
export { listApps } from "./functions/listApps";
|
|
5
|
+
export { getApp } from "./functions/getApp";
|
|
6
|
+
export { listActions } from "./functions/listActions";
|
|
7
|
+
export { getAction } from "./functions/getAction";
|
|
8
|
+
export { runAction } from "./functions/runAction";
|
|
9
|
+
export { listFields } from "./functions/listFields";
|
|
10
|
+
export { generateTypes } from "./functions/generateTypes";
|
|
11
|
+
export { bundleCode } from "./functions/bundleCode";
|
|
12
|
+
export { createZapierSdk, ZapierSdk, ZapierSdkOptions } from "./sdk";
|
package/dist/index.js
CHANGED
|
@@ -14,10 +14,29 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
// Export everything from
|
|
19
|
-
__exportStar(require("
|
|
20
|
-
__exportStar(require("
|
|
17
|
+
exports.createZapierSdk = exports.bundleCode = exports.generateTypes = exports.listFields = exports.runAction = exports.getAction = exports.listActions = exports.getApp = exports.listApps = exports.listAuths = void 0;
|
|
18
|
+
// Export everything from types and actions-sdk
|
|
19
|
+
__exportStar(require("./types"), exports);
|
|
20
|
+
__exportStar(require("./actions-sdk"), exports);
|
|
21
|
+
// Export individual functions for tree-shaking
|
|
22
|
+
var listAuths_1 = require("./functions/listAuths");
|
|
23
|
+
Object.defineProperty(exports, "listAuths", { enumerable: true, get: function () { return listAuths_1.listAuths; } });
|
|
24
|
+
var listApps_1 = require("./functions/listApps");
|
|
25
|
+
Object.defineProperty(exports, "listApps", { enumerable: true, get: function () { return listApps_1.listApps; } });
|
|
26
|
+
var getApp_1 = require("./functions/getApp");
|
|
27
|
+
Object.defineProperty(exports, "getApp", { enumerable: true, get: function () { return getApp_1.getApp; } });
|
|
28
|
+
var listActions_1 = require("./functions/listActions");
|
|
29
|
+
Object.defineProperty(exports, "listActions", { enumerable: true, get: function () { return listActions_1.listActions; } });
|
|
30
|
+
var getAction_1 = require("./functions/getAction");
|
|
31
|
+
Object.defineProperty(exports, "getAction", { enumerable: true, get: function () { return getAction_1.getAction; } });
|
|
32
|
+
var runAction_1 = require("./functions/runAction");
|
|
33
|
+
Object.defineProperty(exports, "runAction", { enumerable: true, get: function () { return runAction_1.runAction; } });
|
|
34
|
+
var listFields_1 = require("./functions/listFields");
|
|
35
|
+
Object.defineProperty(exports, "listFields", { enumerable: true, get: function () { return listFields_1.listFields; } });
|
|
36
|
+
var generateTypes_1 = require("./functions/generateTypes");
|
|
37
|
+
Object.defineProperty(exports, "generateTypes", { enumerable: true, get: function () { return generateTypes_1.generateTypes; } });
|
|
38
|
+
var bundleCode_1 = require("./functions/bundleCode");
|
|
39
|
+
Object.defineProperty(exports, "bundleCode", { enumerable: true, get: function () { return bundleCode_1.bundleCode; } });
|
|
21
40
|
// Export the main combined SDK
|
|
22
41
|
var sdk_1 = require("./sdk");
|
|
23
|
-
Object.defineProperty(exports, "
|
|
42
|
+
Object.defineProperty(exports, "createZapierSdk", { enumerable: true, get: function () { return sdk_1.createZapierSdk; } });
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export interface FormattedItem {
|
|
3
|
+
title: string;
|
|
4
|
+
subtitle?: string;
|
|
5
|
+
details: Array<{
|
|
6
|
+
text: string;
|
|
7
|
+
style: "normal" | "dim" | "accent" | "warning" | "success";
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
export interface FormatMetadata {
|
|
11
|
+
format: (item: any) => FormattedItem;
|
|
12
|
+
}
|
|
13
|
+
export declare function withOutputSchema<T extends z.ZodType>(inputSchema: T, outputSchema: z.ZodType): T;
|
|
14
|
+
export declare function getFormatMetadata(schema: z.ZodType): FormatMetadata | undefined;
|
|
15
|
+
export declare function getOutputSchema(inputSchema: z.ZodType): z.ZodType | undefined;
|
|
16
|
+
export declare const AppItemSchema: z.ZodObject<{
|
|
17
|
+
key: z.ZodString;
|
|
18
|
+
name: z.ZodOptional<z.ZodString>;
|
|
19
|
+
description: z.ZodOptional<z.ZodString>;
|
|
20
|
+
category: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
key: string;
|
|
23
|
+
name?: string | undefined;
|
|
24
|
+
description?: string | undefined;
|
|
25
|
+
category?: string | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
key: string;
|
|
28
|
+
name?: string | undefined;
|
|
29
|
+
description?: string | undefined;
|
|
30
|
+
category?: string | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
export declare const ActionItemSchema: z.ZodObject<{
|
|
33
|
+
key: z.ZodString;
|
|
34
|
+
name: z.ZodOptional<z.ZodString>;
|
|
35
|
+
type: z.ZodString;
|
|
36
|
+
appKey: z.ZodOptional<z.ZodString>;
|
|
37
|
+
description: z.ZodOptional<z.ZodString>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
key: string;
|
|
40
|
+
type: string;
|
|
41
|
+
name?: string | undefined;
|
|
42
|
+
description?: string | undefined;
|
|
43
|
+
appKey?: string | undefined;
|
|
44
|
+
}, {
|
|
45
|
+
key: string;
|
|
46
|
+
type: string;
|
|
47
|
+
name?: string | undefined;
|
|
48
|
+
description?: string | undefined;
|
|
49
|
+
appKey?: string | undefined;
|
|
50
|
+
}>;
|
|
51
|
+
export declare const AuthItemSchema: z.ZodObject<{
|
|
52
|
+
id: z.ZodNumber;
|
|
53
|
+
title: z.ZodOptional<z.ZodString>;
|
|
54
|
+
label: z.ZodOptional<z.ZodString>;
|
|
55
|
+
identifier: z.ZodOptional<z.ZodString>;
|
|
56
|
+
account_id: z.ZodOptional<z.ZodString>;
|
|
57
|
+
is_private: z.ZodOptional<z.ZodBoolean>;
|
|
58
|
+
shared_with_all: z.ZodOptional<z.ZodBoolean>;
|
|
59
|
+
marked_stale_at: z.ZodOptional<z.ZodString>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
id: number;
|
|
62
|
+
account_id?: string | undefined;
|
|
63
|
+
title?: string | undefined;
|
|
64
|
+
label?: string | undefined;
|
|
65
|
+
identifier?: string | undefined;
|
|
66
|
+
is_private?: boolean | undefined;
|
|
67
|
+
shared_with_all?: boolean | undefined;
|
|
68
|
+
marked_stale_at?: string | undefined;
|
|
69
|
+
}, {
|
|
70
|
+
id: number;
|
|
71
|
+
account_id?: string | undefined;
|
|
72
|
+
title?: string | undefined;
|
|
73
|
+
label?: string | undefined;
|
|
74
|
+
identifier?: string | undefined;
|
|
75
|
+
is_private?: boolean | undefined;
|
|
76
|
+
shared_with_all?: boolean | undefined;
|
|
77
|
+
marked_stale_at?: string | undefined;
|
|
78
|
+
}>;
|
|
79
|
+
export declare const FieldItemSchema: z.ZodObject<{
|
|
80
|
+
key: z.ZodString;
|
|
81
|
+
name: z.ZodOptional<z.ZodString>;
|
|
82
|
+
description: z.ZodOptional<z.ZodString>;
|
|
83
|
+
}, "strip", z.ZodTypeAny, {
|
|
84
|
+
key: string;
|
|
85
|
+
name?: string | undefined;
|
|
86
|
+
description?: string | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
key: string;
|
|
89
|
+
name?: string | undefined;
|
|
90
|
+
description?: string | undefined;
|
|
91
|
+
}>;
|
|
92
|
+
export type AppItem = z.infer<typeof AppItemSchema>;
|
|
93
|
+
export type ActionItem = z.infer<typeof ActionItemSchema>;
|
|
94
|
+
export type AuthItem = z.infer<typeof AuthItemSchema>;
|
|
95
|
+
export type FieldItem = z.infer<typeof FieldItemSchema>;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FieldItemSchema = exports.AuthItemSchema = exports.ActionItemSchema = exports.AppItemSchema = void 0;
|
|
4
|
+
exports.withOutputSchema = withOutputSchema;
|
|
5
|
+
exports.getFormatMetadata = getFormatMetadata;
|
|
6
|
+
exports.getOutputSchema = getOutputSchema;
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Schema Enhancement Helpers
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Helper function to add format metadata to schemas
|
|
12
|
+
function withFormatter(schema, formatMeta) {
|
|
13
|
+
// Store format metadata on the schema definition
|
|
14
|
+
schema._def.formatMeta = formatMeta;
|
|
15
|
+
return schema;
|
|
16
|
+
}
|
|
17
|
+
// Helper function to link input schemas to output schemas
|
|
18
|
+
function withOutputSchema(inputSchema, outputSchema) {
|
|
19
|
+
// Store output schema reference on the input schema
|
|
20
|
+
inputSchema._def.outputSchema = outputSchema;
|
|
21
|
+
return inputSchema;
|
|
22
|
+
}
|
|
23
|
+
// Helper function to get format metadata from a schema
|
|
24
|
+
function getFormatMetadata(schema) {
|
|
25
|
+
return schema._def.formatMeta;
|
|
26
|
+
}
|
|
27
|
+
// Helper function to get output schema from an input schema
|
|
28
|
+
function getOutputSchema(inputSchema) {
|
|
29
|
+
return inputSchema._def.outputSchema;
|
|
30
|
+
}
|
|
31
|
+
// ============================================================================
|
|
32
|
+
// Output Item Schemas
|
|
33
|
+
// ============================================================================
|
|
34
|
+
exports.AppItemSchema = withFormatter(zod_1.z.object({
|
|
35
|
+
key: zod_1.z.string(),
|
|
36
|
+
name: zod_1.z.string().optional(),
|
|
37
|
+
description: zod_1.z.string().optional(),
|
|
38
|
+
category: zod_1.z.string().optional(),
|
|
39
|
+
}), {
|
|
40
|
+
format: (item) => {
|
|
41
|
+
const details = [];
|
|
42
|
+
if (item.description) {
|
|
43
|
+
details.push({ text: item.description, style: "dim" });
|
|
44
|
+
}
|
|
45
|
+
if (item.category) {
|
|
46
|
+
details.push({
|
|
47
|
+
text: `Category: ${item.category}`,
|
|
48
|
+
style: "accent",
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
title: item.name || item.key,
|
|
53
|
+
subtitle: `(${item.key})`,
|
|
54
|
+
details,
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
exports.ActionItemSchema = withFormatter(zod_1.z.object({
|
|
59
|
+
key: zod_1.z.string(),
|
|
60
|
+
name: zod_1.z.string().optional(),
|
|
61
|
+
type: zod_1.z.string(),
|
|
62
|
+
appKey: zod_1.z.string().optional(),
|
|
63
|
+
description: zod_1.z.string().optional(),
|
|
64
|
+
}), {
|
|
65
|
+
format: (item) => {
|
|
66
|
+
const details = [];
|
|
67
|
+
details.push({ text: `Type: ${item.type}`, style: "accent" });
|
|
68
|
+
if (item.appKey) {
|
|
69
|
+
details.push({ text: `App: ${item.appKey}`, style: "normal" });
|
|
70
|
+
}
|
|
71
|
+
if (item.description) {
|
|
72
|
+
details.push({ text: item.description, style: "dim" });
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
title: item.name || item.key,
|
|
76
|
+
subtitle: `(${item.key})`,
|
|
77
|
+
details,
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
exports.AuthItemSchema = withFormatter(zod_1.z.object({
|
|
82
|
+
id: zod_1.z.number(),
|
|
83
|
+
title: zod_1.z.string().optional(),
|
|
84
|
+
label: zod_1.z.string().optional(),
|
|
85
|
+
identifier: zod_1.z.string().optional(),
|
|
86
|
+
account_id: zod_1.z.string().optional(),
|
|
87
|
+
is_private: zod_1.z.boolean().optional(),
|
|
88
|
+
shared_with_all: zod_1.z.boolean().optional(),
|
|
89
|
+
marked_stale_at: zod_1.z.string().optional(),
|
|
90
|
+
}), {
|
|
91
|
+
format: (item) => {
|
|
92
|
+
const details = [];
|
|
93
|
+
if (item.identifier) {
|
|
94
|
+
details.push({
|
|
95
|
+
text: `Identifier: ${item.identifier}`,
|
|
96
|
+
style: "accent",
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (item.label && item.title && item.label !== item.title) {
|
|
100
|
+
details.push({
|
|
101
|
+
text: `Label: ${item.label}`,
|
|
102
|
+
style: "normal",
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
details.push({
|
|
106
|
+
text: `Account: ${item.account_id || "unknown"} | Private: ${item.is_private || false} | Shared: ${item.shared_with_all || false}`,
|
|
107
|
+
style: "dim",
|
|
108
|
+
});
|
|
109
|
+
if (item.marked_stale_at) {
|
|
110
|
+
details.push({
|
|
111
|
+
text: `⚠️ Marked stale: ${new Date(item.marked_stale_at).toLocaleDateString()}`,
|
|
112
|
+
style: "warning",
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
title: item.title || item.label || `Authentication ${item.id}`,
|
|
117
|
+
subtitle: `(ID: ${item.id})`,
|
|
118
|
+
details,
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
exports.FieldItemSchema = withFormatter(zod_1.z.object({
|
|
123
|
+
key: zod_1.z.string(),
|
|
124
|
+
name: zod_1.z.string().optional(),
|
|
125
|
+
description: zod_1.z.string().optional(),
|
|
126
|
+
}), {
|
|
127
|
+
format: (item) => {
|
|
128
|
+
const details = [];
|
|
129
|
+
if (item.description) {
|
|
130
|
+
details.push({ text: item.description, style: "dim" });
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
title: item.name || item.key,
|
|
134
|
+
subtitle: `(${item.key})`,
|
|
135
|
+
details,
|
|
136
|
+
};
|
|
137
|
+
},
|
|
138
|
+
});
|