@zapier/zapier-sdk 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2001 -0
- package/dist/index.d.mts +840 -0
- package/dist/index.d.ts +840 -20
- package/dist/index.mjs +1955 -0
- package/package.json +19 -7
- package/src/api/client.ts +84 -16
- package/src/api/types.ts +9 -1
- package/src/auth.ts +19 -287
- package/src/functions/fetch/index.ts +180 -0
- package/src/functions/fetch/info.ts +8 -0
- package/src/functions/fetch/schemas.ts +46 -0
- package/src/functions/findFirstAuthentication/schemas.ts +3 -13
- package/src/functions/findUniqueAuthentication/schemas.ts +3 -13
- package/src/functions/generateTypes/index.ts +15 -0
- package/src/functions/generateTypes/schemas.ts +3 -10
- package/src/functions/getAction/schemas.ts +3 -13
- package/src/functions/getApp/schemas.ts +2 -13
- package/src/functions/getAuthentication/index.ts +0 -1
- package/src/functions/getAuthentication/schemas.ts +3 -17
- package/src/functions/listActions/schemas.ts +3 -13
- package/src/functions/listApps/schemas.ts +2 -13
- package/src/functions/listAuthentications/index.ts +0 -1
- package/src/functions/listAuthentications/schemas.ts +3 -15
- package/src/functions/listFields/schemas.ts +3 -13
- package/src/functions/runAction/index.ts +0 -1
- package/src/functions/runAction/schemas.ts +6 -15
- package/src/index.ts +4 -2
- package/src/plugins/apps/index.ts +35 -9
- package/src/sdk.ts +20 -22
- package/src/types/domain.ts +16 -0
- package/src/types/sdk.ts +13 -1
- package/tsconfig.json +2 -2
- package/tsup.config.ts +21 -0
- package/dist/api/auth.d.ts +0 -8
- package/dist/api/auth.js +0 -29
- package/dist/api/client.d.ts +0 -8
- package/dist/api/client.js +0 -119
- package/dist/api/debug.d.ts +0 -12
- package/dist/api/debug.js +0 -50
- package/dist/api/index.d.ts +0 -28
- package/dist/api/index.js +0 -52
- package/dist/api/polling.d.ts +0 -17
- package/dist/api/polling.js +0 -34
- package/dist/api/types.d.ts +0 -147
- package/dist/api/types.js +0 -9
- package/dist/auth.d.ts +0 -59
- package/dist/auth.js +0 -261
- package/dist/functions/bundleCode/index.d.ts +0 -11
- package/dist/functions/bundleCode/index.js +0 -91
- package/dist/functions/bundleCode/info.d.ts +0 -27
- package/dist/functions/bundleCode/info.js +0 -11
- package/dist/functions/bundleCode/schemas.d.ts +0 -27
- package/dist/functions/bundleCode/schemas.js +0 -22
- package/dist/functions/findFirstAuthentication/index.d.ts +0 -12
- package/dist/functions/findFirstAuthentication/index.js +0 -21
- package/dist/functions/findFirstAuthentication/info.d.ts +0 -30
- package/dist/functions/findFirstAuthentication/info.js +0 -11
- package/dist/functions/findFirstAuthentication/schemas.d.ts +0 -42
- package/dist/functions/findFirstAuthentication/schemas.js +0 -25
- package/dist/functions/findUniqueAuthentication/index.d.ts +0 -13
- package/dist/functions/findUniqueAuthentication/index.js +0 -28
- package/dist/functions/findUniqueAuthentication/info.d.ts +0 -30
- package/dist/functions/findUniqueAuthentication/info.js +0 -11
- package/dist/functions/findUniqueAuthentication/schemas.d.ts +0 -42
- package/dist/functions/findUniqueAuthentication/schemas.js +0 -25
- package/dist/functions/generateTypes/index.d.ts +0 -11
- package/dist/functions/generateTypes/index.js +0 -305
- package/dist/functions/generateTypes/info.d.ts +0 -21
- package/dist/functions/generateTypes/info.js +0 -11
- package/dist/functions/generateTypes/schemas.d.ts +0 -30
- package/dist/functions/generateTypes/schemas.js +0 -14
- package/dist/functions/getAction/index.d.ts +0 -12
- package/dist/functions/getAction/index.js +0 -26
- package/dist/functions/getAction/info.d.ts +0 -18
- package/dist/functions/getAction/info.js +0 -11
- package/dist/functions/getAction/schemas.d.ts +0 -30
- package/dist/functions/getAction/schemas.js +0 -13
- package/dist/functions/getApp/index.d.ts +0 -12
- package/dist/functions/getApp/index.js +0 -37
- package/dist/functions/getApp/info.d.ts +0 -12
- package/dist/functions/getApp/info.js +0 -11
- package/dist/functions/getApp/schemas.d.ts +0 -24
- package/dist/functions/getApp/schemas.js +0 -11
- package/dist/functions/getAuthentication/index.d.ts +0 -13
- package/dist/functions/getAuthentication/index.js +0 -38
- package/dist/functions/getAuthentication/info.d.ts +0 -12
- package/dist/functions/getAuthentication/info.js +0 -11
- package/dist/functions/getAuthentication/schemas.d.ts +0 -26
- package/dist/functions/getAuthentication/schemas.js +0 -16
- package/dist/functions/listActions/index.d.ts +0 -12
- package/dist/functions/listActions/index.js +0 -128
- package/dist/functions/listActions/info.d.ts +0 -15
- package/dist/functions/listActions/info.js +0 -11
- package/dist/functions/listActions/schemas.d.ts +0 -27
- package/dist/functions/listActions/schemas.js +0 -14
- package/dist/functions/listApps/index.d.ts +0 -12
- package/dist/functions/listApps/index.js +0 -50
- package/dist/functions/listApps/info.d.ts +0 -18
- package/dist/functions/listApps/info.js +0 -11
- package/dist/functions/listApps/schemas.d.ts +0 -30
- package/dist/functions/listApps/schemas.js +0 -15
- package/dist/functions/listAuthentications/index.d.ts +0 -12
- package/dist/functions/listAuthentications/index.js +0 -131
- package/dist/functions/listAuthentications/info.d.ts +0 -30
- package/dist/functions/listAuthentications/info.js +0 -11
- package/dist/functions/listAuthentications/schemas.d.ts +0 -44
- package/dist/functions/listAuthentications/schemas.js +0 -25
- package/dist/functions/listFields/index.d.ts +0 -12
- package/dist/functions/listFields/index.js +0 -65
- package/dist/functions/listFields/info.d.ts +0 -24
- package/dist/functions/listFields/info.js +0 -11
- package/dist/functions/listFields/schemas.d.ts +0 -36
- package/dist/functions/listFields/schemas.js +0 -17
- package/dist/functions/runAction/index.d.ts +0 -12
- package/dist/functions/runAction/index.js +0 -86
- package/dist/functions/runAction/info.d.ts +0 -24
- package/dist/functions/runAction/info.js +0 -11
- package/dist/functions/runAction/schemas.d.ts +0 -38
- package/dist/functions/runAction/schemas.js +0 -15
- package/dist/index.js +0 -57
- package/dist/plugins/apps/index.d.ts +0 -8
- package/dist/plugins/apps/index.js +0 -77
- package/dist/plugins/apps/info.d.ts +0 -6
- package/dist/plugins/apps/info.js +0 -13
- package/dist/plugins/apps/types.d.ts +0 -21
- package/dist/plugins/apps/types.js +0 -2
- package/dist/resolvers/actionKey.d.ts +0 -8
- package/dist/resolvers/actionKey.js +0 -20
- package/dist/resolvers/actionType.d.ts +0 -8
- package/dist/resolvers/actionType.js +0 -21
- package/dist/resolvers/appKey.d.ts +0 -6
- package/dist/resolvers/appKey.js +0 -8
- package/dist/resolvers/authenticationId.d.ts +0 -8
- package/dist/resolvers/authenticationId.js +0 -29
- package/dist/resolvers/index.d.ts +0 -39
- package/dist/resolvers/index.js +0 -105
- package/dist/resolvers/inputs.d.ts +0 -7
- package/dist/resolvers/inputs.js +0 -15
- package/dist/schema-utils.d.ts +0 -44
- package/dist/schema-utils.js +0 -76
- package/dist/schemas/Action.d.ts +0 -21
- package/dist/schemas/Action.js +0 -31
- package/dist/schemas/App.d.ts +0 -19
- package/dist/schemas/App.js +0 -32
- package/dist/schemas/Auth.d.ts +0 -27
- package/dist/schemas/Auth.js +0 -42
- package/dist/schemas/Field.d.ts +0 -15
- package/dist/schemas/Field.js +0 -25
- package/dist/sdk.d.ts +0 -6
- package/dist/sdk.js +0 -90
- package/dist/types/domain.d.ts +0 -25
- package/dist/types/domain.js +0 -21
- package/dist/types/events.d.ts +0 -37
- package/dist/types/events.js +0 -8
- package/dist/types/properties.d.ts +0 -21
- package/dist/types/properties.js +0 -52
- package/dist/types/sdk.d.ts +0 -24
- package/dist/types/sdk.js +0 -2
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.listApps = listApps;
|
|
4
|
-
const api_1 = require("../../api");
|
|
5
|
-
/**
|
|
6
|
-
* List available apps with optional filtering
|
|
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, pagination, and API configuration options
|
|
12
|
-
* @returns Promise<Integration[]> with pagination metadata
|
|
13
|
-
*/
|
|
14
|
-
async function listApps(options = {}) {
|
|
15
|
-
const api = (0, api_1.getOrCreateApiClient)(options);
|
|
16
|
-
// Build search parameters
|
|
17
|
-
const searchParams = {};
|
|
18
|
-
if (options.category) {
|
|
19
|
-
searchParams.category = options.category;
|
|
20
|
-
}
|
|
21
|
-
if (options.limit) {
|
|
22
|
-
searchParams.limit = options.limit.toString();
|
|
23
|
-
}
|
|
24
|
-
if (options.offset) {
|
|
25
|
-
searchParams.offset = options.offset.toString();
|
|
26
|
-
}
|
|
27
|
-
const data = await api.get("/api/v4/apps/", { searchParams });
|
|
28
|
-
// Transform API response to our Integration interface
|
|
29
|
-
const apps = data.results?.map((app) => ({
|
|
30
|
-
key: app.slug,
|
|
31
|
-
name: app.name,
|
|
32
|
-
description: app.description,
|
|
33
|
-
version: "1.0.0", // API doesn't provide version
|
|
34
|
-
category: app.category?.name,
|
|
35
|
-
actions: [], // Will be populated separately
|
|
36
|
-
triggers: [],
|
|
37
|
-
current_implementation_id: app.current_implementation_id,
|
|
38
|
-
})) || [];
|
|
39
|
-
// Add pagination metadata to the response
|
|
40
|
-
if (apps.length > 0) {
|
|
41
|
-
apps.__pagination = {
|
|
42
|
-
count: data.count,
|
|
43
|
-
hasNext: !!data.next,
|
|
44
|
-
hasPrevious: !!data.previous,
|
|
45
|
-
nextUrl: data.next,
|
|
46
|
-
previousUrl: data.previous,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
return apps;
|
|
50
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { listApps } from "./index";
|
|
2
|
-
export declare const listAppsInfo: {
|
|
3
|
-
name: string;
|
|
4
|
-
inputSchema: import("zod").ZodObject<{
|
|
5
|
-
category: import("zod").ZodOptional<import("zod").ZodString>;
|
|
6
|
-
limit: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>;
|
|
7
|
-
offset: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>;
|
|
8
|
-
}, "strip", import("zod").ZodTypeAny, {
|
|
9
|
-
category?: string | undefined;
|
|
10
|
-
limit?: number | undefined;
|
|
11
|
-
offset?: number | undefined;
|
|
12
|
-
}, {
|
|
13
|
-
category?: string | undefined;
|
|
14
|
-
limit?: number | undefined;
|
|
15
|
-
offset?: number | undefined;
|
|
16
|
-
}>;
|
|
17
|
-
implementation: typeof listApps;
|
|
18
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.listAppsInfo = 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.listAppsInfo = {
|
|
8
|
-
name: index_1.listApps.name,
|
|
9
|
-
inputSchema: schemas_1.ListAppsSchema,
|
|
10
|
-
implementation: index_1.listApps,
|
|
11
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { Integration } from "../../types/domain";
|
|
3
|
-
export declare const ListAppsSchema: z.ZodObject<{
|
|
4
|
-
category: z.ZodOptional<z.ZodString>;
|
|
5
|
-
limit: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
6
|
-
offset: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
7
|
-
}, "strip", z.ZodTypeAny, {
|
|
8
|
-
category?: string | undefined;
|
|
9
|
-
limit?: number | undefined;
|
|
10
|
-
offset?: number | undefined;
|
|
11
|
-
}, {
|
|
12
|
-
category?: string | undefined;
|
|
13
|
-
limit?: number | undefined;
|
|
14
|
-
offset?: number | undefined;
|
|
15
|
-
}>;
|
|
16
|
-
export type ListAppsOptions = z.infer<typeof ListAppsSchema> & {
|
|
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 ListAppsSdkFunction {
|
|
29
|
-
listApps: (options?: Partial<ListAppsOptions>) => Promise<Integration[]>;
|
|
30
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ListAppsSchema = 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 App_1 = require("../../schemas/App");
|
|
8
|
-
// Pure Zod schema - no resolver metadata!
|
|
9
|
-
exports.ListAppsSchema = (0, schema_utils_1.withOutputSchema)(zod_1.z
|
|
10
|
-
.object({
|
|
11
|
-
category: zod_1.z.string().optional().describe("Filter apps by category"),
|
|
12
|
-
limit: properties_1.LimitPropertySchema.optional().describe("Maximum number of items to return (1-200)"),
|
|
13
|
-
offset: properties_1.OffsetPropertySchema.optional().describe("Number of items to skip for pagination"),
|
|
14
|
-
})
|
|
15
|
-
.describe("List all available apps with optional filtering"), App_1.AppItemSchema);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Authentication } from "../../types/domain";
|
|
2
|
-
import type { ListAuthenticationsOptions } from "./schemas";
|
|
3
|
-
/**
|
|
4
|
-
* List available authentications with optional filtering
|
|
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, pagination, and API configuration options
|
|
10
|
-
* @returns Promise<Authentication[]> with pagination metadata
|
|
11
|
-
*/
|
|
12
|
-
export declare function listAuthentications(options?: Partial<ListAuthenticationsOptions>): Promise<Authentication[]>;
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.listAuthentications = listAuthentications;
|
|
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 listAuthentications(options = {}) {
|
|
16
|
-
const api = (0, api_1.getOrCreateApiClient)(options);
|
|
17
|
-
api.requireAuthTo("list authentications");
|
|
18
|
-
// Local function to handle the actual API fetching
|
|
19
|
-
const listAuthenticationsInternal = async (options = {}) => {
|
|
20
|
-
// Build search parameters
|
|
21
|
-
const searchParams = {};
|
|
22
|
-
// Handle appKey filtering by getting the selected_api first
|
|
23
|
-
if (options.appKey) {
|
|
24
|
-
try {
|
|
25
|
-
// Use the standalone getApp function
|
|
26
|
-
const app = await (0, getApp_1.getApp)({
|
|
27
|
-
appKey: options.appKey,
|
|
28
|
-
api,
|
|
29
|
-
token: options.token,
|
|
30
|
-
baseUrl: options.baseUrl,
|
|
31
|
-
debug: options.debug,
|
|
32
|
-
fetch: options.fetch,
|
|
33
|
-
});
|
|
34
|
-
const selectedApi = app.current_implementation_id;
|
|
35
|
-
if (selectedApi) {
|
|
36
|
-
// Use versionless_selected_api to find auths across all app versions
|
|
37
|
-
// Extract the base name without the version (e.g., "SlackCLIAPI" from "SlackCLIAPI@1.21.1")
|
|
38
|
-
const versionlessApi = selectedApi.split("@")[0];
|
|
39
|
-
searchParams.versionless_selected_api = versionlessApi;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
// If it's an AppNotFoundError, re-throw it
|
|
44
|
-
if (error instanceof Error && error.name === "AppNotFoundError") {
|
|
45
|
-
throw error;
|
|
46
|
-
}
|
|
47
|
-
// For other errors, continue without app filtering
|
|
48
|
-
console.warn(`Warning: Could not filter by app ${options.appKey}:`, error instanceof Error ? error.message : "Unknown error");
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
// Add other query parameters if provided
|
|
52
|
-
// Use title as search if no explicit search provided
|
|
53
|
-
if (options.search) {
|
|
54
|
-
searchParams.search = options.search;
|
|
55
|
-
}
|
|
56
|
-
else if (options.title) {
|
|
57
|
-
searchParams.search = options.title;
|
|
58
|
-
}
|
|
59
|
-
if (options.account_id) {
|
|
60
|
-
searchParams.account_id = options.account_id;
|
|
61
|
-
}
|
|
62
|
-
if (options.owner) {
|
|
63
|
-
searchParams.owner = options.owner;
|
|
64
|
-
}
|
|
65
|
-
if (options.limit) {
|
|
66
|
-
searchParams.limit = options.limit.toString();
|
|
67
|
-
}
|
|
68
|
-
if (options.offset) {
|
|
69
|
-
searchParams.offset = options.offset.toString();
|
|
70
|
-
}
|
|
71
|
-
const data = await api.get("/api/v4/authentications/", {
|
|
72
|
-
searchParams,
|
|
73
|
-
customErrorHandler: (response) => {
|
|
74
|
-
if (response.status === 401) {
|
|
75
|
-
return new Error(`Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP ${response.status})`);
|
|
76
|
-
}
|
|
77
|
-
if (response.status === 403) {
|
|
78
|
-
return new Error(`Access forbidden. Your token may not have the required scopes to list authentications. (HTTP ${response.status})`);
|
|
79
|
-
}
|
|
80
|
-
return undefined;
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
// Transform API response
|
|
84
|
-
let auths = data.results || [];
|
|
85
|
-
// Coerce title from label if title is missing (API cleanup)
|
|
86
|
-
auths = auths.map((auth) => ({
|
|
87
|
-
...auth,
|
|
88
|
-
title: auth.title || auth.label || undefined,
|
|
89
|
-
}));
|
|
90
|
-
// Filter by exact title match if specified
|
|
91
|
-
if (options.title) {
|
|
92
|
-
auths = auths.filter((auth) => auth.title === options.title);
|
|
93
|
-
}
|
|
94
|
-
// Add pagination metadata to the response
|
|
95
|
-
if (auths.length > 0) {
|
|
96
|
-
auths.__pagination = {
|
|
97
|
-
count: data.count,
|
|
98
|
-
hasNext: !!data.next,
|
|
99
|
-
hasPrevious: !!data.previous,
|
|
100
|
-
nextUrl: data.next,
|
|
101
|
-
previousUrl: data.previous,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
return auths;
|
|
105
|
-
};
|
|
106
|
-
// If a limit is provided and no specific owner filter, prioritize owned auths
|
|
107
|
-
if (options.limit && options.owner === undefined) {
|
|
108
|
-
// First get owned auths
|
|
109
|
-
const ownedAuths = await listAuthenticationsInternal({
|
|
110
|
-
...options,
|
|
111
|
-
owner: "me",
|
|
112
|
-
});
|
|
113
|
-
// If we have enough owned auths, just slice and return
|
|
114
|
-
if (ownedAuths.length >= options.limit) {
|
|
115
|
-
return ownedAuths.slice(0, options.limit);
|
|
116
|
-
}
|
|
117
|
-
// Get all auths up to the original limit to fill remaining slots
|
|
118
|
-
const allAuths = await listAuthenticationsInternal({
|
|
119
|
-
...options,
|
|
120
|
-
owner: undefined,
|
|
121
|
-
});
|
|
122
|
-
// Filter out auths the user already owns to avoid duplicates
|
|
123
|
-
const ownedAuthenticationIds = new Set(ownedAuths.map((auth) => auth.id));
|
|
124
|
-
const additionalAuths = allAuths.filter((auth) => !ownedAuthenticationIds.has(auth.id));
|
|
125
|
-
// Combine and slice to the requested limit
|
|
126
|
-
const combined = [...ownedAuths, ...additionalAuths];
|
|
127
|
-
return combined.slice(0, options.limit);
|
|
128
|
-
}
|
|
129
|
-
// Standard implementation for non-prioritized requests
|
|
130
|
-
return listAuthenticationsInternal(options);
|
|
131
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { listAuthentications } from "./index";
|
|
2
|
-
export declare const listAuthenticationsInfo: {
|
|
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 listAuthentications;
|
|
30
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.listAuthenticationsInfo = 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.listAuthenticationsInfo = {
|
|
8
|
-
name: index_1.listAuthentications.name,
|
|
9
|
-
inputSchema: schemas_1.ListAuthenticationsSchema,
|
|
10
|
-
implementation: index_1.listAuthentications,
|
|
11
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { Authentication } from "../../types/domain";
|
|
3
|
-
export declare const ListAuthenticationsSchema: 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 ListAuthenticationsOptions = z.infer<typeof ListAuthenticationsSchema> & {
|
|
29
|
-
/** Base URL for Zapier API */
|
|
30
|
-
baseUrl?: string;
|
|
31
|
-
/** Authentication token */
|
|
32
|
-
token?: string;
|
|
33
|
-
/** Function to dynamically resolve authentication token */
|
|
34
|
-
getToken?: () => Promise<string | undefined>;
|
|
35
|
-
/** Optional pre-instantiated API client */
|
|
36
|
-
api?: any;
|
|
37
|
-
/** Enable debug logging */
|
|
38
|
-
debug?: boolean;
|
|
39
|
-
/** Custom fetch implementation */
|
|
40
|
-
fetch?: typeof globalThis.fetch;
|
|
41
|
-
};
|
|
42
|
-
export interface ListAuthenticationsSdkFunction {
|
|
43
|
-
listAuthentications: (options?: Partial<ListAuthenticationsOptions>) => Promise<Authentication[]>;
|
|
44
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ListAuthenticationsSchema = 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.ListAuthenticationsSchema = (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("List available authentications with optional filtering"), Auth_1.AuthItemSchema);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ActionField } from "../../types/domain";
|
|
2
|
-
import type { ListFieldsOptions } from "./schemas";
|
|
3
|
-
/**
|
|
4
|
-
* List available fields for an action
|
|
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 - Action details, authentication ID, params, and API configuration options
|
|
10
|
-
* @returns Promise<ActionField[]>
|
|
11
|
-
*/
|
|
12
|
-
export declare function listFields(options: ListFieldsOptions): Promise<ActionField[]>;
|
|
@@ -1,65 +0,0 @@
|
|
|
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, authentication 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
|
-
// Extract parameters
|
|
18
|
-
const { appKey, actionKey, actionType, authenticationId, params } = options;
|
|
19
|
-
// Use the standalone getApp function
|
|
20
|
-
const appData = await (0, getApp_1.getApp)({
|
|
21
|
-
appKey,
|
|
22
|
-
api,
|
|
23
|
-
token: options.token,
|
|
24
|
-
baseUrl: options.baseUrl,
|
|
25
|
-
debug: options.debug,
|
|
26
|
-
fetch: options.fetch,
|
|
27
|
-
});
|
|
28
|
-
const selectedApi = appData.current_implementation_id;
|
|
29
|
-
if (!selectedApi) {
|
|
30
|
-
throw new Error("No current_implementation_id found for app");
|
|
31
|
-
}
|
|
32
|
-
// Build needs request
|
|
33
|
-
const needsRequest = {
|
|
34
|
-
selected_api: selectedApi,
|
|
35
|
-
action: actionKey,
|
|
36
|
-
type_of: actionType,
|
|
37
|
-
authentication_id: authenticationId,
|
|
38
|
-
params: params || {},
|
|
39
|
-
};
|
|
40
|
-
const needsData = await api.post("/api/v4/implementations/needs/", needsRequest);
|
|
41
|
-
if (!needsData.success) {
|
|
42
|
-
throw new Error(`Failed to get action fields: ${needsData.errors?.join(", ") || "Unknown error"}`);
|
|
43
|
-
}
|
|
44
|
-
// Transform API response to our ActionField interface
|
|
45
|
-
return (needsData.needs || []).map((need) => ({
|
|
46
|
-
key: need.key,
|
|
47
|
-
label: need.label,
|
|
48
|
-
required: need.required || false,
|
|
49
|
-
type: need.type,
|
|
50
|
-
helpText: need.help_text,
|
|
51
|
-
helpTextHtml: need.help_text_html,
|
|
52
|
-
choices: need.choices?.map((choice) => ({
|
|
53
|
-
value: choice.value,
|
|
54
|
-
label: choice.label,
|
|
55
|
-
})),
|
|
56
|
-
default: need.default,
|
|
57
|
-
placeholder: need.placeholder,
|
|
58
|
-
computed: need.computed,
|
|
59
|
-
customField: need.custom_field,
|
|
60
|
-
dependsOn: need.depends_on,
|
|
61
|
-
format: need.format,
|
|
62
|
-
inputFormat: need.input_format,
|
|
63
|
-
}));
|
|
64
|
-
}
|
|
65
|
-
// No registry info here - moved to info.ts for proper tree-shaking
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { listFields } from "./index";
|
|
2
|
-
export declare const listFieldsInfo: {
|
|
3
|
-
name: string;
|
|
4
|
-
inputSchema: import("zod").ZodObject<{
|
|
5
|
-
appKey: import("zod").ZodString;
|
|
6
|
-
actionType: import("zod").ZodEnum<["read", "read_bulk", "write", "run", "search", "search_or_write", "search_and_write", "filter"]>;
|
|
7
|
-
actionKey: import("zod").ZodString;
|
|
8
|
-
authenticationId: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
9
|
-
params: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>;
|
|
10
|
-
}, "strip", import("zod").ZodTypeAny, {
|
|
11
|
-
appKey: string;
|
|
12
|
-
actionType: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
|
|
13
|
-
actionKey: string;
|
|
14
|
-
params?: Record<string, any> | undefined;
|
|
15
|
-
authenticationId?: number | undefined;
|
|
16
|
-
}, {
|
|
17
|
-
appKey: string;
|
|
18
|
-
actionType: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
|
|
19
|
-
actionKey: string;
|
|
20
|
-
params?: Record<string, any> | undefined;
|
|
21
|
-
authenticationId?: number | undefined;
|
|
22
|
-
}>;
|
|
23
|
-
implementation: typeof listFields;
|
|
24
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.listFieldsInfo = 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.listFieldsInfo = {
|
|
8
|
-
name: index_1.listFields.name,
|
|
9
|
-
inputSchema: schemas_1.ListFieldsSchema,
|
|
10
|
-
implementation: index_1.listFields,
|
|
11
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { ActionField } from "../../types/domain";
|
|
3
|
-
export declare const ListFieldsSchema: z.ZodObject<{
|
|
4
|
-
appKey: z.ZodString;
|
|
5
|
-
actionType: z.ZodEnum<["read", "read_bulk", "write", "run", "search", "search_or_write", "search_and_write", "filter"]>;
|
|
6
|
-
actionKey: z.ZodString;
|
|
7
|
-
authenticationId: z.ZodOptional<z.ZodNumber>;
|
|
8
|
-
params: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
9
|
-
}, "strip", z.ZodTypeAny, {
|
|
10
|
-
appKey: string;
|
|
11
|
-
actionType: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
|
|
12
|
-
actionKey: string;
|
|
13
|
-
params?: Record<string, any> | undefined;
|
|
14
|
-
authenticationId?: number | undefined;
|
|
15
|
-
}, {
|
|
16
|
-
appKey: string;
|
|
17
|
-
actionType: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter";
|
|
18
|
-
actionKey: string;
|
|
19
|
-
params?: Record<string, any> | undefined;
|
|
20
|
-
authenticationId?: number | undefined;
|
|
21
|
-
}>;
|
|
22
|
-
export type ListFieldsOptions = z.infer<typeof ListFieldsSchema> & {
|
|
23
|
-
/** Base URL for Zapier API */
|
|
24
|
-
baseUrl?: string;
|
|
25
|
-
/** Authentication token */
|
|
26
|
-
token?: string;
|
|
27
|
-
/** Optional pre-instantiated API client */
|
|
28
|
-
api?: any;
|
|
29
|
-
/** Enable debug logging */
|
|
30
|
-
debug?: boolean;
|
|
31
|
-
/** Custom fetch implementation */
|
|
32
|
-
fetch?: typeof globalThis.fetch;
|
|
33
|
-
};
|
|
34
|
-
export interface ListFieldsSdkFunction {
|
|
35
|
-
listFields: (options: ListFieldsOptions) => Promise<ActionField[]>;
|
|
36
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ListFieldsSchema = 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 Field_1 = require("../../schemas/Field");
|
|
8
|
-
// Pure Zod schema - no resolver metadata!
|
|
9
|
-
exports.ListFieldsSchema = (0, schema_utils_1.withOutputSchema)(zod_1.z
|
|
10
|
-
.object({
|
|
11
|
-
appKey: properties_1.AppKeyPropertySchema,
|
|
12
|
-
actionType: properties_1.ActionTypePropertySchema,
|
|
13
|
-
actionKey: properties_1.ActionKeyPropertySchema,
|
|
14
|
-
authenticationId: properties_1.AuthenticationIdPropertySchema.optional(),
|
|
15
|
-
params: properties_1.ParamsPropertySchema.optional().describe("Additional parameters that may affect available fields"),
|
|
16
|
-
})
|
|
17
|
-
.describe("Get the input fields required for a specific action"), Field_1.FieldItemSchema);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ActionExecutionResult } from "../../types/domain";
|
|
2
|
-
import type { RunActionOptions } from "./schemas";
|
|
3
|
-
/**
|
|
4
|
-
* Execute an action
|
|
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 - Action execution parameters and API configuration options
|
|
10
|
-
* @returns Promise<ActionExecutionResult>
|
|
11
|
-
*/
|
|
12
|
-
export declare function runAction(options: RunActionOptions): Promise<ActionExecutionResult>;
|
|
@@ -1,86 +0,0 @@
|
|
|
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 { appKey, actionType, actionKey, inputs, authenticationId: providedAuthenticationId, } = options;
|
|
18
|
-
const api = (0, api_1.getOrCreateApiClient)(options);
|
|
19
|
-
api.requireAuthTo("run actions");
|
|
20
|
-
// Validate that the action exists
|
|
21
|
-
const actionData = await (0, getAction_1.getAction)({
|
|
22
|
-
...options,
|
|
23
|
-
appKey: appKey,
|
|
24
|
-
actionKey: actionKey,
|
|
25
|
-
actionType: actionType,
|
|
26
|
-
});
|
|
27
|
-
// Validate action type matches
|
|
28
|
-
if (actionData.type !== actionType) {
|
|
29
|
-
throw new Error(`Action type mismatch: expected ${actionType}, got ${actionData.type}`);
|
|
30
|
-
}
|
|
31
|
-
// Execute the action using the Actions API (supports all action types)
|
|
32
|
-
const startTime = Date.now();
|
|
33
|
-
const result = await executeAction({
|
|
34
|
-
api,
|
|
35
|
-
appSlug: appKey,
|
|
36
|
-
actionKey: actionKey,
|
|
37
|
-
actionType: actionData.type,
|
|
38
|
-
executionOptions: { inputs: inputs || {} },
|
|
39
|
-
authenticationId: providedAuthenticationId,
|
|
40
|
-
options,
|
|
41
|
-
});
|
|
42
|
-
const executionTime = Date.now() - startTime;
|
|
43
|
-
return {
|
|
44
|
-
success: true,
|
|
45
|
-
data: result,
|
|
46
|
-
metadata: {
|
|
47
|
-
executionTime,
|
|
48
|
-
requestId: (0, api_1.generateRequestId)(),
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
async function executeAction(actionOptions) {
|
|
53
|
-
const { api, appSlug, actionKey, actionType, executionOptions, authenticationId, options, } = actionOptions;
|
|
54
|
-
// Use the standalone getApp function
|
|
55
|
-
const appData = await (0, getApp_1.getApp)({
|
|
56
|
-
appKey: appSlug,
|
|
57
|
-
api,
|
|
58
|
-
token: options.token,
|
|
59
|
-
baseUrl: options.baseUrl,
|
|
60
|
-
debug: options.debug,
|
|
61
|
-
fetch: options.fetch,
|
|
62
|
-
});
|
|
63
|
-
const selectedApi = appData.current_implementation_id;
|
|
64
|
-
if (!selectedApi) {
|
|
65
|
-
throw new Error("No current_implementation_id found for app");
|
|
66
|
-
}
|
|
67
|
-
// Step 1: POST to /actions/v1/runs to start execution
|
|
68
|
-
const runRequest = {
|
|
69
|
-
data: {
|
|
70
|
-
authentication_id: authenticationId || 1,
|
|
71
|
-
selected_api: selectedApi,
|
|
72
|
-
action_key: actionKey,
|
|
73
|
-
action_type: actionType,
|
|
74
|
-
inputs: executionOptions.inputs || {},
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
const runData = await api.post("/api/actions/v1/runs", runRequest);
|
|
78
|
-
const runId = runData.data.id;
|
|
79
|
-
// Step 2: Poll GET /actions/v1/runs/{run_id} for results
|
|
80
|
-
return await api.poll(`/api/actions/v1/runs/${runId}`, {
|
|
81
|
-
successStatus: 200,
|
|
82
|
-
pendingStatus: 202,
|
|
83
|
-
resultExtractor: (result) => result.data,
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
// No registry info here - moved to info.ts for proper tree-shaking
|