@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
package/dist/sdk.js DELETED
@@ -1,90 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createZapierSdk = createZapierSdk;
4
- const api_1 = require("./api");
5
- const auth_1 = require("./auth");
6
- // Import function implementations
7
- const listApps_1 = require("./functions/listApps");
8
- const getApp_1 = require("./functions/getApp");
9
- const listActions_1 = require("./functions/listActions");
10
- const getAction_1 = require("./functions/getAction");
11
- const runAction_1 = require("./functions/runAction");
12
- const listAuthentications_1 = require("./functions/listAuthentications");
13
- const getAuthentication_1 = require("./functions/getAuthentication");
14
- const findFirstAuthentication_1 = require("./functions/findFirstAuthentication");
15
- const findUniqueAuthentication_1 = require("./functions/findUniqueAuthentication");
16
- const listFields_1 = require("./functions/listFields");
17
- const generateTypes_1 = require("./functions/generateTypes");
18
- const bundleCode_1 = require("./functions/bundleCode");
19
- // Import function registry info objects (only for CLI registry)
20
- const info_1 = require("./functions/listApps/info");
21
- const info_2 = require("./functions/getApp/info");
22
- const info_3 = require("./functions/listActions/info");
23
- const info_4 = require("./functions/getAction/info");
24
- const info_5 = require("./functions/runAction/info");
25
- const info_6 = require("./functions/listAuthentications/info");
26
- const info_7 = require("./functions/getAuthentication/info");
27
- const info_8 = require("./functions/findFirstAuthentication/info");
28
- const info_9 = require("./functions/findUniqueAuthentication/info");
29
- const info_10 = require("./functions/listFields/info");
30
- const info_11 = require("./functions/generateTypes/info");
31
- const info_12 = require("./functions/bundleCode/info");
32
- // Function registry as array - uses names from function info objects
33
- const functionRegistry = [
34
- info_1.listAppsInfo,
35
- info_2.getAppInfo,
36
- info_3.listActionsInfo,
37
- info_4.getActionInfo,
38
- info_5.runActionInfo,
39
- info_6.listAuthenticationsInfo,
40
- info_7.getAuthenticationInfo,
41
- info_8.findFirstAuthenticationInfo,
42
- info_9.findUniqueAuthenticationInfo,
43
- info_10.listFieldsInfo,
44
- info_11.generateTypesInfo,
45
- info_12.bundleCodeInfo,
46
- ];
47
- // Import plugin functions
48
- const index_1 = require("./plugins/apps/index");
49
- function createZapierSdk(options = {}) {
50
- const { fetch: customFetch = globalThis.fetch, baseUrl = "https://zapier.com", token, getToken, onEvent, debug = false, } = options;
51
- // If no explicit token or getToken provided, try env var then CLI config with event callbacks
52
- const resolvedGetToken = getToken ||
53
- (!token
54
- ? () => (0, auth_1.getTokenFromEnvOrConfig)({ onEvent, fetch: customFetch })
55
- : undefined);
56
- // Create the API client
57
- const api = (0, api_1.createZapierApi)({
58
- baseUrl,
59
- token,
60
- getToken: resolvedGetToken,
61
- debug,
62
- fetch: customFetch,
63
- });
64
- // Create plugins directly - TypeScript will enforce correct implementation
65
- const appsPlugin = (0, index_1.createAppsPlugin)({
66
- api,
67
- token,
68
- });
69
- // Compose final SDK - TypeScript will enforce we have all required properties
70
- const fullSdk = {
71
- // Registry for CLI
72
- __registry: functionRegistry,
73
- // Function implementations with API config injection
74
- listApps: (options = {}) => (0, listApps_1.listApps)({ ...options, api }),
75
- getApp: (options) => (0, getApp_1.getApp)({ ...options, api }),
76
- listActions: (options = {}) => (0, listActions_1.listActions)({ ...options, api }),
77
- getAction: (options) => (0, getAction_1.getAction)({ ...options, api }),
78
- runAction: (options) => (0, runAction_1.runAction)({ ...options, api }),
79
- listAuthentications: (options = {}) => (0, listAuthentications_1.listAuthentications)({ ...options, api }),
80
- getAuthentication: (options) => (0, getAuthentication_1.getAuthentication)({ ...options, api }),
81
- findFirstAuthentication: (options = {}) => (0, findFirstAuthentication_1.findFirstAuthentication)({ ...options, api }),
82
- findUniqueAuthentication: (options = {}) => (0, findUniqueAuthentication_1.findUniqueAuthentication)({ ...options, api }),
83
- listFields: (options) => (0, listFields_1.listFields)({ ...options, api }),
84
- generateTypes: (options) => (0, generateTypes_1.generateTypes)({ ...options, api }),
85
- bundleCode: (options) => (0, bundleCode_1.bundleCode)(options), // No API config needed
86
- // Add plugins
87
- apps: appsPlugin,
88
- };
89
- return fullSdk;
90
- }
@@ -1,25 +0,0 @@
1
- export type { Integration, Action, Trigger, Field, Choice, ActionExecutionResult, ActionField, ActionFieldChoice, NeedsRequest, NeedsResponse, Authentication, AuthenticationsResponse, } from "../api/types";
2
- import type { EventCallback } from "./events";
3
- export interface ActionExecutionOptions {
4
- inputs?: Record<string, any>;
5
- authenticationId?: number;
6
- }
7
- export interface AuthObject {
8
- id: number;
9
- }
10
- export interface BaseSdkOptions {
11
- token?: string;
12
- getToken?: () => Promise<string | undefined>;
13
- onEvent?: EventCallback;
14
- fetch?: typeof fetch;
15
- baseUrl?: string;
16
- debug?: boolean;
17
- }
18
- export declare class ZapierSdkError extends Error {
19
- code?: string | undefined;
20
- constructor(message: string, code?: string | undefined);
21
- }
22
- export declare class AppNotFoundError extends ZapierSdkError {
23
- appKey: string;
24
- constructor(appKey: string);
25
- }
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppNotFoundError = exports.ZapierSdkError = void 0;
4
- // Error Classes
5
- class ZapierSdkError extends Error {
6
- constructor(message, code) {
7
- super(message);
8
- this.code = code;
9
- this.name = "ZapierSdkError";
10
- }
11
- }
12
- exports.ZapierSdkError = ZapierSdkError;
13
- class AppNotFoundError extends ZapierSdkError {
14
- constructor(appKey) {
15
- super(`App "${appKey}" not found`);
16
- this.name = "AppNotFoundError";
17
- this.code = "APP_NOT_FOUND";
18
- this.appKey = appKey;
19
- }
20
- }
21
- exports.AppNotFoundError = AppNotFoundError;
@@ -1,37 +0,0 @@
1
- /**
2
- * SDK Event System
3
- *
4
- * This module provides common event type definitions for the SDK's
5
- * event system, including authentication, API, and loading events.
6
- */
7
- export interface SdkEvent {
8
- type: string;
9
- payload?: Record<string, any>;
10
- timestamp?: number;
11
- }
12
- export interface AuthEvent extends SdkEvent {
13
- type: "auth_refreshing" | "auth_success" | "auth_error" | "auth_logout";
14
- payload?: {
15
- message?: string;
16
- error?: string;
17
- operation?: string;
18
- };
19
- }
20
- export interface ApiEvent extends SdkEvent {
21
- type: "api_request" | "api_response" | "api_error";
22
- payload?: {
23
- url?: string;
24
- method?: string;
25
- status?: number;
26
- duration?: number;
27
- error?: string;
28
- };
29
- }
30
- export interface LoadingEvent extends SdkEvent {
31
- type: "loading_start" | "loading_end";
32
- payload?: {
33
- operation?: string;
34
- resource?: string;
35
- };
36
- }
37
- export type EventCallback = (event: SdkEvent) => void;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- /**
3
- * SDK Event System
4
- *
5
- * This module provides common event type definitions for the SDK's
6
- * event system, including authentication, API, and loading events.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,21 +0,0 @@
1
- import { z } from "zod";
2
- export declare const AppKeyPropertySchema: z.ZodString;
3
- export declare const ActionTypePropertySchema: z.ZodEnum<["read", "read_bulk", "write", "run", "search", "search_or_write", "search_and_write", "filter"]>;
4
- export declare const ActionKeyPropertySchema: z.ZodString;
5
- export declare const AuthenticationIdPropertySchema: z.ZodNumber;
6
- export declare const InputsPropertySchema: z.ZodRecord<z.ZodString, z.ZodAny>;
7
- export declare const LimitPropertySchema: z.ZodDefault<z.ZodNumber>;
8
- export declare const OffsetPropertySchema: z.ZodDefault<z.ZodNumber>;
9
- export declare const OutputPropertySchema: z.ZodString;
10
- export declare const DebugPropertySchema: z.ZodDefault<z.ZodBoolean>;
11
- export declare const ParamsPropertySchema: z.ZodRecord<z.ZodString, z.ZodAny>;
12
- export type AppKeyProperty = z.infer<typeof AppKeyPropertySchema>;
13
- export type ActionTypeProperty = z.infer<typeof ActionTypePropertySchema>;
14
- export type ActionKeyProperty = z.infer<typeof ActionKeyPropertySchema>;
15
- export type AuthenticationIdProperty = z.infer<typeof AuthenticationIdPropertySchema>;
16
- export type InputsProperty = z.infer<typeof InputsPropertySchema>;
17
- export type LimitProperty = z.infer<typeof LimitPropertySchema>;
18
- export type OffsetProperty = z.infer<typeof OffsetPropertySchema>;
19
- export type OutputProperty = z.infer<typeof OutputPropertySchema>;
20
- export type DebugProperty = z.infer<typeof DebugPropertySchema>;
21
- export type ParamsProperty = z.infer<typeof ParamsPropertySchema>;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParamsPropertySchema = exports.DebugPropertySchema = exports.OutputPropertySchema = exports.OffsetPropertySchema = exports.LimitPropertySchema = exports.InputsPropertySchema = exports.AuthenticationIdPropertySchema = exports.ActionKeyPropertySchema = exports.ActionTypePropertySchema = exports.AppKeyPropertySchema = void 0;
4
- const zod_1 = require("zod");
5
- const schema_utils_1 = require("../schema-utils");
6
- // Shared property definitions for common parameters across functions
7
- // These can be reused in function schemas without duplication
8
- exports.AppKeyPropertySchema = (0, schema_utils_1.withPositional)(zod_1.z.string().min(1).describe("App slug (e.g., 'slack', 'github')"));
9
- exports.ActionTypePropertySchema = zod_1.z
10
- .enum([
11
- "read",
12
- "read_bulk",
13
- "write",
14
- "run",
15
- "search",
16
- "search_or_write",
17
- "search_and_write",
18
- "filter",
19
- ])
20
- .describe("Action type that matches the action's defined type");
21
- exports.ActionKeyPropertySchema = zod_1.z
22
- .string()
23
- .min(1)
24
- .describe("Action key to execute");
25
- exports.AuthenticationIdPropertySchema = zod_1.z
26
- .number()
27
- .int()
28
- .describe("Authentication ID to use for this action");
29
- exports.InputsPropertySchema = zod_1.z
30
- .record(zod_1.z.any())
31
- .describe("Input parameters for the action");
32
- exports.LimitPropertySchema = zod_1.z
33
- .number()
34
- .int()
35
- .min(1)
36
- .max(1000)
37
- .default(50)
38
- .describe("Maximum number of items to return");
39
- exports.OffsetPropertySchema = zod_1.z
40
- .number()
41
- .int()
42
- .min(0)
43
- .default(0)
44
- .describe("Number of items to skip for pagination");
45
- exports.OutputPropertySchema = zod_1.z.string().describe("Output file path");
46
- exports.DebugPropertySchema = zod_1.z
47
- .boolean()
48
- .default(false)
49
- .describe("Enable debug logging");
50
- exports.ParamsPropertySchema = zod_1.z
51
- .record(zod_1.z.any())
52
- .describe("Additional parameters");
@@ -1,24 +0,0 @@
1
- import type { ListActionsSdkFunction } from "../functions/listActions/schemas";
2
- import type { GetActionSdkFunction } from "../functions/getAction/schemas";
3
- import type { GetAppSdkFunction } from "../functions/getApp/schemas";
4
- import type { RunActionSdkFunction } from "../functions/runAction/schemas";
5
- import type { ListFieldsSdkFunction } from "../functions/listFields/schemas";
6
- import type { ListAuthenticationsSdkFunction } from "../functions/listAuthentications/schemas";
7
- import type { GetAuthenticationSdkFunction } from "../functions/getAuthentication/schemas";
8
- import type { FindFirstAuthenticationSdkFunction } from "../functions/findFirstAuthentication/schemas";
9
- import type { FindUniqueAuthenticationSdkFunction } from "../functions/findUniqueAuthentication/schemas";
10
- import type { GenerateTypesSdkFunction } from "../functions/generateTypes/schemas";
11
- import type { ListAppsSdkFunction } from "../functions/listApps/schemas";
12
- import type { BundleCodeSdkFunction } from "../functions/bundleCode/schemas";
13
- import type { AppsPluginSdkExtension } from "../plugins/apps/types";
14
- export interface ZapierSdkFunctions extends ListActionsSdkFunction, GetActionSdkFunction, GetAppSdkFunction, RunActionSdkFunction, ListFieldsSdkFunction, ListAuthenticationsSdkFunction, GetAuthenticationSdkFunction, FindFirstAuthenticationSdkFunction, FindUniqueAuthenticationSdkFunction, GenerateTypesSdkFunction, ListAppsSdkFunction, BundleCodeSdkFunction {
15
- }
16
- export interface ZapierSdkPlugins extends AppsPluginSdkExtension {
17
- }
18
- export interface ZapierSdk extends ZapierSdkFunctions, ZapierSdkPlugins {
19
- __registry: Array<{
20
- name: string;
21
- inputSchema: any;
22
- implementation: Function;
23
- }>;
24
- }
package/dist/types/sdk.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });