@zapier/zapier-sdk 0.3.1 → 0.4.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.
Files changed (162) hide show
  1. package/dist/index.cjs +1962 -0
  2. package/dist/index.d.mts +892 -0
  3. package/dist/index.d.ts +892 -20
  4. package/dist/index.mjs +1914 -0
  5. package/package.json +19 -7
  6. package/src/api/client.ts +106 -25
  7. package/src/api/polling.ts +4 -8
  8. package/src/api/types.ts +8 -1
  9. package/src/auth.ts +19 -287
  10. package/src/functions/findFirstAuthentication/schemas.ts +3 -13
  11. package/src/functions/findUniqueAuthentication/schemas.ts +3 -13
  12. package/src/functions/generateTypes/index.ts +15 -0
  13. package/src/functions/generateTypes/schemas.ts +3 -10
  14. package/src/functions/getAction/schemas.ts +3 -13
  15. package/src/functions/getApp/schemas.ts +2 -13
  16. package/src/functions/getAuthentication/index.ts +0 -1
  17. package/src/functions/getAuthentication/schemas.ts +3 -17
  18. package/src/functions/listActions/schemas.ts +3 -13
  19. package/src/functions/listApps/schemas.ts +2 -13
  20. package/src/functions/listAuthentications/index.ts +0 -1
  21. package/src/functions/listAuthentications/schemas.ts +3 -15
  22. package/src/functions/listFields/schemas.ts +3 -13
  23. package/src/functions/request/index.ts +150 -0
  24. package/src/functions/request/info.ts +11 -0
  25. package/src/functions/request/schemas.ts +53 -0
  26. package/src/functions/runAction/index.ts +0 -1
  27. package/src/functions/runAction/schemas.ts +6 -15
  28. package/src/index.ts +8 -2
  29. package/src/plugins/apps/index.ts +34 -9
  30. package/src/plugins/apps/types.ts +17 -1
  31. package/src/plugins/fetch/index.ts +50 -0
  32. package/src/plugins/fetch/types.ts +2 -0
  33. package/src/sdk.ts +19 -23
  34. package/src/types/domain.ts +16 -0
  35. package/src/types/sdk.ts +17 -2
  36. package/tsconfig.json +2 -2
  37. package/tsup.config.ts +21 -0
  38. package/dist/api/auth.d.ts +0 -8
  39. package/dist/api/auth.js +0 -29
  40. package/dist/api/client.d.ts +0 -8
  41. package/dist/api/client.js +0 -119
  42. package/dist/api/debug.d.ts +0 -12
  43. package/dist/api/debug.js +0 -50
  44. package/dist/api/index.d.ts +0 -28
  45. package/dist/api/index.js +0 -52
  46. package/dist/api/polling.d.ts +0 -17
  47. package/dist/api/polling.js +0 -34
  48. package/dist/api/types.d.ts +0 -147
  49. package/dist/api/types.js +0 -9
  50. package/dist/auth.d.ts +0 -59
  51. package/dist/auth.js +0 -261
  52. package/dist/functions/bundleCode/index.d.ts +0 -11
  53. package/dist/functions/bundleCode/index.js +0 -91
  54. package/dist/functions/bundleCode/info.d.ts +0 -27
  55. package/dist/functions/bundleCode/info.js +0 -11
  56. package/dist/functions/bundleCode/schemas.d.ts +0 -27
  57. package/dist/functions/bundleCode/schemas.js +0 -22
  58. package/dist/functions/findFirstAuthentication/index.d.ts +0 -12
  59. package/dist/functions/findFirstAuthentication/index.js +0 -21
  60. package/dist/functions/findFirstAuthentication/info.d.ts +0 -30
  61. package/dist/functions/findFirstAuthentication/info.js +0 -11
  62. package/dist/functions/findFirstAuthentication/schemas.d.ts +0 -42
  63. package/dist/functions/findFirstAuthentication/schemas.js +0 -25
  64. package/dist/functions/findUniqueAuthentication/index.d.ts +0 -13
  65. package/dist/functions/findUniqueAuthentication/index.js +0 -28
  66. package/dist/functions/findUniqueAuthentication/info.d.ts +0 -30
  67. package/dist/functions/findUniqueAuthentication/info.js +0 -11
  68. package/dist/functions/findUniqueAuthentication/schemas.d.ts +0 -42
  69. package/dist/functions/findUniqueAuthentication/schemas.js +0 -25
  70. package/dist/functions/generateTypes/index.d.ts +0 -11
  71. package/dist/functions/generateTypes/index.js +0 -305
  72. package/dist/functions/generateTypes/info.d.ts +0 -21
  73. package/dist/functions/generateTypes/info.js +0 -11
  74. package/dist/functions/generateTypes/schemas.d.ts +0 -30
  75. package/dist/functions/generateTypes/schemas.js +0 -14
  76. package/dist/functions/getAction/index.d.ts +0 -12
  77. package/dist/functions/getAction/index.js +0 -26
  78. package/dist/functions/getAction/info.d.ts +0 -18
  79. package/dist/functions/getAction/info.js +0 -11
  80. package/dist/functions/getAction/schemas.d.ts +0 -30
  81. package/dist/functions/getAction/schemas.js +0 -13
  82. package/dist/functions/getApp/index.d.ts +0 -12
  83. package/dist/functions/getApp/index.js +0 -37
  84. package/dist/functions/getApp/info.d.ts +0 -12
  85. package/dist/functions/getApp/info.js +0 -11
  86. package/dist/functions/getApp/schemas.d.ts +0 -24
  87. package/dist/functions/getApp/schemas.js +0 -11
  88. package/dist/functions/getAuthentication/index.d.ts +0 -13
  89. package/dist/functions/getAuthentication/index.js +0 -38
  90. package/dist/functions/getAuthentication/info.d.ts +0 -12
  91. package/dist/functions/getAuthentication/info.js +0 -11
  92. package/dist/functions/getAuthentication/schemas.d.ts +0 -26
  93. package/dist/functions/getAuthentication/schemas.js +0 -16
  94. package/dist/functions/listActions/index.d.ts +0 -12
  95. package/dist/functions/listActions/index.js +0 -128
  96. package/dist/functions/listActions/info.d.ts +0 -15
  97. package/dist/functions/listActions/info.js +0 -11
  98. package/dist/functions/listActions/schemas.d.ts +0 -27
  99. package/dist/functions/listActions/schemas.js +0 -14
  100. package/dist/functions/listApps/index.d.ts +0 -12
  101. package/dist/functions/listApps/index.js +0 -50
  102. package/dist/functions/listApps/info.d.ts +0 -18
  103. package/dist/functions/listApps/info.js +0 -11
  104. package/dist/functions/listApps/schemas.d.ts +0 -30
  105. package/dist/functions/listApps/schemas.js +0 -15
  106. package/dist/functions/listAuthentications/index.d.ts +0 -12
  107. package/dist/functions/listAuthentications/index.js +0 -131
  108. package/dist/functions/listAuthentications/info.d.ts +0 -30
  109. package/dist/functions/listAuthentications/info.js +0 -11
  110. package/dist/functions/listAuthentications/schemas.d.ts +0 -44
  111. package/dist/functions/listAuthentications/schemas.js +0 -25
  112. package/dist/functions/listFields/index.d.ts +0 -12
  113. package/dist/functions/listFields/index.js +0 -65
  114. package/dist/functions/listFields/info.d.ts +0 -24
  115. package/dist/functions/listFields/info.js +0 -11
  116. package/dist/functions/listFields/schemas.d.ts +0 -36
  117. package/dist/functions/listFields/schemas.js +0 -17
  118. package/dist/functions/runAction/index.d.ts +0 -12
  119. package/dist/functions/runAction/index.js +0 -86
  120. package/dist/functions/runAction/info.d.ts +0 -24
  121. package/dist/functions/runAction/info.js +0 -11
  122. package/dist/functions/runAction/schemas.d.ts +0 -38
  123. package/dist/functions/runAction/schemas.js +0 -15
  124. package/dist/index.js +0 -57
  125. package/dist/plugins/apps/index.d.ts +0 -8
  126. package/dist/plugins/apps/index.js +0 -77
  127. package/dist/plugins/apps/info.d.ts +0 -6
  128. package/dist/plugins/apps/info.js +0 -13
  129. package/dist/plugins/apps/types.d.ts +0 -21
  130. package/dist/plugins/apps/types.js +0 -2
  131. package/dist/resolvers/actionKey.d.ts +0 -8
  132. package/dist/resolvers/actionKey.js +0 -20
  133. package/dist/resolvers/actionType.d.ts +0 -8
  134. package/dist/resolvers/actionType.js +0 -21
  135. package/dist/resolvers/appKey.d.ts +0 -6
  136. package/dist/resolvers/appKey.js +0 -8
  137. package/dist/resolvers/authenticationId.d.ts +0 -8
  138. package/dist/resolvers/authenticationId.js +0 -29
  139. package/dist/resolvers/index.d.ts +0 -39
  140. package/dist/resolvers/index.js +0 -105
  141. package/dist/resolvers/inputs.d.ts +0 -7
  142. package/dist/resolvers/inputs.js +0 -15
  143. package/dist/schema-utils.d.ts +0 -44
  144. package/dist/schema-utils.js +0 -76
  145. package/dist/schemas/Action.d.ts +0 -21
  146. package/dist/schemas/Action.js +0 -31
  147. package/dist/schemas/App.d.ts +0 -19
  148. package/dist/schemas/App.js +0 -32
  149. package/dist/schemas/Auth.d.ts +0 -27
  150. package/dist/schemas/Auth.js +0 -42
  151. package/dist/schemas/Field.d.ts +0 -15
  152. package/dist/schemas/Field.js +0 -25
  153. package/dist/sdk.d.ts +0 -6
  154. package/dist/sdk.js +0 -90
  155. package/dist/types/domain.d.ts +0 -25
  156. package/dist/types/domain.js +0 -21
  157. package/dist/types/events.d.ts +0 -37
  158. package/dist/types/events.js +0 -8
  159. package/dist/types/properties.d.ts +0 -21
  160. package/dist/types/properties.js +0 -52
  161. package/dist/types/sdk.d.ts +0 -24
  162. package/dist/types/sdk.js +0 -2
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAuthentication = getAuthentication;
4
- const api_1 = require("../../api");
5
- /**
6
- * Get a specific authentication by ID
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 - Authentication ID and API configuration options
12
- * @returns Promise<Authentication> - The authentication details
13
- * @throws Error if authentication not found or access denied
14
- */
15
- async function getAuthentication(options) {
16
- const { authenticationId } = options;
17
- const api = (0, api_1.getOrCreateApiClient)(options);
18
- api.requireAuthTo("get authentication");
19
- const data = await api.get(`/api/v4/authentications/${authenticationId}/`, {
20
- customErrorHandler: (response) => {
21
- if (response.status === 401) {
22
- return new Error(`Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP ${response.status})`);
23
- }
24
- if (response.status === 403) {
25
- return new Error(`Access forbidden. Your token may not have the required scopes to get authentication ${authenticationId}. (HTTP ${response.status})`);
26
- }
27
- if (response.status === 404) {
28
- return new Error(`Authentication ${authenticationId} not found. It may not exist or you may not have access to it. (HTTP ${response.status})`);
29
- }
30
- return undefined;
31
- },
32
- });
33
- // Coerce title from label if title is missing (API cleanup)
34
- return {
35
- ...data,
36
- title: data.title || data.label || undefined,
37
- };
38
- }
@@ -1,12 +0,0 @@
1
- import { getAuthentication } from "./index";
2
- export declare const getAuthenticationInfo: {
3
- name: string;
4
- inputSchema: import("zod").ZodObject<{
5
- authenticationId: import("zod").ZodNumber;
6
- }, "strip", import("zod").ZodTypeAny, {
7
- authenticationId: number;
8
- }, {
9
- authenticationId: number;
10
- }>;
11
- implementation: typeof getAuthentication;
12
- };
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAuthenticationInfo = 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.getAuthenticationInfo = {
8
- name: index_1.getAuthentication.name,
9
- inputSchema: schemas_1.GetAuthenticationSchema,
10
- implementation: index_1.getAuthentication,
11
- };
@@ -1,26 +0,0 @@
1
- import { z } from "zod";
2
- import type { Authentication } from "../../types/domain";
3
- export declare const GetAuthenticationSchema: z.ZodObject<{
4
- authenticationId: z.ZodNumber;
5
- }, "strip", z.ZodTypeAny, {
6
- authenticationId: number;
7
- }, {
8
- authenticationId: number;
9
- }>;
10
- export type GetAuthenticationOptions = z.infer<typeof GetAuthenticationSchema> & {
11
- /** Base URL for Zapier API */
12
- baseUrl?: string;
13
- /** Authentication token */
14
- token?: string;
15
- /** Function to dynamically resolve authentication token */
16
- getToken?: () => Promise<string | undefined>;
17
- /** Optional pre-instantiated API client */
18
- api?: any;
19
- /** Enable debug logging */
20
- debug?: boolean;
21
- /** Custom fetch implementation */
22
- fetch?: typeof globalThis.fetch;
23
- };
24
- export interface GetAuthenticationSdkFunction {
25
- getAuthentication: (options: GetAuthenticationOptions) => Promise<Authentication>;
26
- }
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetAuthenticationSchema = void 0;
4
- const zod_1 = require("zod");
5
- const schema_utils_1 = require("../../schema-utils");
6
- const Auth_1 = require("../../schemas/Auth");
7
- // Pure Zod schema - no resolver metadata!
8
- exports.GetAuthenticationSchema = (0, schema_utils_1.withOutputSchema)(zod_1.z
9
- .object({
10
- authenticationId: zod_1.z
11
- .number()
12
- .int()
13
- .positive()
14
- .describe("Authentication ID to retrieve"),
15
- })
16
- .describe("Get a specific authentication by ID"), Auth_1.AuthItemSchema);
@@ -1,12 +0,0 @@
1
- import type { Action } from "../../types/domain";
2
- import type { ListActionsOptions } from "./schemas";
3
- /**
4
- * List available actions 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 and API configuration options
10
- * @returns Promise<Action[]> with pagination metadata
11
- */
12
- export declare function listActions(options?: Partial<ListActionsOptions>): Promise<Action[]>;
@@ -1,128 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listActions = listActions;
4
- const api_1 = require("../../api");
5
- const getApp_1 = require("../getApp");
6
- /**
7
- * List available actions 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 and API configuration options
13
- * @returns Promise<Action[]> with pagination metadata
14
- */
15
- async function listActions(options = {}) {
16
- const api = (0, api_1.getOrCreateApiClient)(options);
17
- // If filtering by appKey, use optimized approach with selected_apis parameter
18
- if (options.appKey) {
19
- try {
20
- // Use the standalone getApp function
21
- const appData = await (0, getApp_1.getApp)({
22
- appKey: options.appKey,
23
- api,
24
- token: options.token,
25
- baseUrl: options.baseUrl,
26
- debug: options.debug,
27
- fetch: options.fetch,
28
- });
29
- // Extract implementation name from current_implementation_id (e.g., "SlackCLIAPI@1.20.0" -> "SlackCLIAPI")
30
- const implementationId = appData.current_implementation_id?.split("@")[0];
31
- if (!implementationId) {
32
- throw new Error("No current_implementation_id found for app");
33
- }
34
- const searchParams = {
35
- global: "true",
36
- public_only: "true",
37
- selected_apis: implementationId,
38
- };
39
- const data = await api.get("/api/v4/implementations/", {
40
- searchParams,
41
- });
42
- const actions = [];
43
- // Transform implementations to actions
44
- for (const implementation of data.results || []) {
45
- if (implementation.actions) {
46
- for (const action of implementation.actions) {
47
- const transformedAction = {
48
- key: action.key,
49
- name: action.name || action.label,
50
- description: action.description || "",
51
- appKey: implementation.slug || "",
52
- type: action.type || action.type_of || "read",
53
- inputFields: [], // Would need additional API call for detailed fields
54
- outputFields: [],
55
- };
56
- // Apply type filter if provided
57
- if (options?.type && transformedAction.type !== options.type) {
58
- continue;
59
- }
60
- actions.push(transformedAction);
61
- }
62
- }
63
- }
64
- // Add pagination metadata for app-specific queries
65
- if (actions.length > 0) {
66
- actions.__pagination = {
67
- count: data.count,
68
- hasNext: !!data.next,
69
- hasPrevious: !!data.previous,
70
- nextUrl: data.next,
71
- previousUrl: data.previous,
72
- };
73
- }
74
- return actions;
75
- }
76
- catch (error) {
77
- // If it's an AppNotFoundError, don't try fallback - just re-throw
78
- if (error instanceof Error && error.name === "AppNotFoundError") {
79
- throw error;
80
- }
81
- // Fallback to original approach if optimized approach fails
82
- console.warn("Optimized app lookup failed, falling back to full scan:", error);
83
- }
84
- }
85
- // Original approach for general queries or when optimization fails
86
- const searchParams = {
87
- global: "true",
88
- public_only: "true",
89
- };
90
- const data = await api.get("/api/v4/implementations/", { searchParams });
91
- const actions = [];
92
- // Transform implementations to actions
93
- for (const implementation of data.results || []) {
94
- if (implementation.actions) {
95
- for (const action of implementation.actions) {
96
- const transformedAction = {
97
- key: action.key,
98
- name: action.name || action.label,
99
- description: action.description || "",
100
- appKey: implementation.slug || "",
101
- type: action.type || action.type_of || "read",
102
- inputFields: [], // Would need additional API call for detailed fields
103
- outputFields: [],
104
- };
105
- // Apply filters
106
- if (options?.appKey && transformedAction.appKey !== options.appKey) {
107
- continue;
108
- }
109
- if (options?.type && transformedAction.type !== options.type) {
110
- continue;
111
- }
112
- actions.push(transformedAction);
113
- }
114
- }
115
- }
116
- // Add pagination metadata for general queries
117
- if (actions.length > 0) {
118
- actions.__pagination = {
119
- count: data.count,
120
- hasNext: !!data.next,
121
- hasPrevious: !!data.previous,
122
- nextUrl: data.next,
123
- previousUrl: data.previous,
124
- };
125
- }
126
- return actions;
127
- }
128
- // No registry info here - moved to info.ts for proper tree-shaking
@@ -1,15 +0,0 @@
1
- import { listActions } from "./index";
2
- export declare const listActionsInfo: {
3
- name: string;
4
- inputSchema: import("zod").ZodObject<{
5
- appKey: import("zod").ZodOptional<import("zod").ZodString>;
6
- type: import("zod").ZodOptional<import("zod").ZodEnum<["read", "read_bulk", "write", "run", "search", "search_or_write", "search_and_write", "filter"]>>;
7
- }, "strip", import("zod").ZodTypeAny, {
8
- type?: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter" | undefined;
9
- appKey?: string | undefined;
10
- }, {
11
- type?: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter" | undefined;
12
- appKey?: string | undefined;
13
- }>;
14
- implementation: typeof listActions;
15
- };
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listActionsInfo = 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.listActionsInfo = {
8
- name: index_1.listActions.name,
9
- inputSchema: schemas_1.ListActionsSchema,
10
- implementation: index_1.listActions,
11
- };
@@ -1,27 +0,0 @@
1
- import { z } from "zod";
2
- import type { Action } from "../../types/domain";
3
- export declare const ListActionsSchema: z.ZodObject<{
4
- appKey: z.ZodOptional<z.ZodString>;
5
- type: z.ZodOptional<z.ZodEnum<["read", "read_bulk", "write", "run", "search", "search_or_write", "search_and_write", "filter"]>>;
6
- }, "strip", z.ZodTypeAny, {
7
- type?: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter" | undefined;
8
- appKey?: string | undefined;
9
- }, {
10
- type?: "read" | "read_bulk" | "write" | "run" | "search" | "search_or_write" | "search_and_write" | "filter" | undefined;
11
- appKey?: string | undefined;
12
- }>;
13
- export type ListActionsOptions = z.infer<typeof ListActionsSchema> & {
14
- /** Base URL for Zapier API */
15
- baseUrl?: string;
16
- /** Authentication token */
17
- token?: string;
18
- /** Optional pre-instantiated API client */
19
- api?: any;
20
- /** Enable debug logging */
21
- debug?: boolean;
22
- /** Custom fetch implementation */
23
- fetch?: typeof globalThis.fetch;
24
- };
25
- export interface ListActionsSdkFunction {
26
- listActions: (options?: Partial<ListActionsOptions>) => Promise<Action[]>;
27
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ListActionsSchema = 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 Action_1 = require("../../schemas/Action");
8
- // Pure Zod schema - no resolver metadata!
9
- exports.ListActionsSchema = (0, schema_utils_1.withOutputSchema)(zod_1.z
10
- .object({
11
- appKey: properties_1.AppKeyPropertySchema.optional(),
12
- type: properties_1.ActionTypePropertySchema.optional().describe("Filter actions by type"),
13
- })
14
- .describe("List all actions for a specific app"), Action_1.ActionItemSchema);
@@ -1,12 +0,0 @@
1
- import type { Integration } from "../../types/domain";
2
- import type { ListAppsOptions } from "./schemas";
3
- /**
4
- * List available apps 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<Integration[]> with pagination metadata
11
- */
12
- export declare function listApps(options?: ListAppsOptions): Promise<Integration[]>;
@@ -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
- };