@zapier/zapier-sdk 0.0.2 → 0.1.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.
Files changed (167) hide show
  1. package/dist/api/auth.d.ts +8 -0
  2. package/dist/api/auth.js +29 -0
  3. package/dist/api/client.d.ts +8 -0
  4. package/dist/api/client.js +102 -0
  5. package/dist/api/debug.d.ts +12 -0
  6. package/dist/api/debug.js +50 -0
  7. package/dist/api/index.d.ts +26 -0
  8. package/dist/api/index.js +51 -0
  9. package/dist/api/polling.d.ts +17 -0
  10. package/dist/api/polling.js +34 -0
  11. package/dist/{types.d.ts → api/types.d.ts} +37 -76
  12. package/dist/api/types.js +9 -0
  13. package/dist/functions/bundleCode/index.d.ts +11 -0
  14. package/dist/functions/bundleCode/index.js +91 -0
  15. package/dist/functions/bundleCode/info.d.ts +27 -0
  16. package/dist/functions/bundleCode/info.js +11 -0
  17. package/dist/functions/bundleCode/schemas.d.ts +27 -0
  18. package/dist/functions/bundleCode/schemas.js +22 -0
  19. package/dist/functions/generateTypes/index.d.ts +11 -0
  20. package/dist/functions/generateTypes/index.js +305 -0
  21. package/dist/functions/generateTypes/info.d.ts +21 -0
  22. package/dist/functions/generateTypes/info.js +11 -0
  23. package/dist/functions/generateTypes/schemas.d.ts +30 -0
  24. package/dist/functions/generateTypes/schemas.js +14 -0
  25. package/dist/functions/getAction/index.d.ts +12 -0
  26. package/dist/functions/getAction/index.js +26 -0
  27. package/dist/functions/getAction/info.d.ts +18 -0
  28. package/dist/functions/getAction/info.js +11 -0
  29. package/dist/functions/getAction/schemas.d.ts +30 -0
  30. package/dist/functions/getAction/schemas.js +13 -0
  31. package/dist/functions/getApp/index.d.ts +12 -0
  32. package/dist/functions/getApp/index.js +37 -0
  33. package/dist/functions/getApp/info.d.ts +12 -0
  34. package/dist/functions/getApp/info.js +11 -0
  35. package/dist/functions/getApp/schemas.d.ts +24 -0
  36. package/dist/functions/getApp/schemas.js +11 -0
  37. package/dist/functions/listActions/index.d.ts +12 -0
  38. package/dist/functions/listActions/index.js +128 -0
  39. package/dist/functions/listActions/info.d.ts +15 -0
  40. package/dist/functions/listActions/info.js +11 -0
  41. package/dist/functions/listActions/schemas.d.ts +27 -0
  42. package/dist/functions/listActions/schemas.js +14 -0
  43. package/dist/functions/listApps/index.d.ts +12 -0
  44. package/dist/functions/listApps/index.js +50 -0
  45. package/dist/functions/listApps/info.d.ts +18 -0
  46. package/dist/functions/listApps/info.js +11 -0
  47. package/dist/functions/listApps/schemas.d.ts +30 -0
  48. package/dist/functions/listApps/schemas.js +15 -0
  49. package/dist/functions/listAuths/index.d.ts +12 -0
  50. package/dist/functions/listAuths/index.js +118 -0
  51. package/dist/functions/listAuths/info.d.ts +24 -0
  52. package/dist/functions/listAuths/info.js +11 -0
  53. package/dist/functions/listAuths/schemas.d.ts +36 -0
  54. package/dist/functions/listAuths/schemas.js +17 -0
  55. package/dist/functions/listFields/index.d.ts +12 -0
  56. package/dist/functions/listFields/index.js +65 -0
  57. package/dist/functions/listFields/info.d.ts +24 -0
  58. package/dist/functions/listFields/info.js +11 -0
  59. package/dist/functions/listFields/schemas.d.ts +36 -0
  60. package/dist/functions/listFields/schemas.js +17 -0
  61. package/dist/functions/runAction/index.d.ts +12 -0
  62. package/dist/functions/runAction/index.js +157 -0
  63. package/dist/functions/runAction/info.d.ts +24 -0
  64. package/dist/functions/runAction/info.js +11 -0
  65. package/dist/functions/runAction/schemas.d.ts +36 -0
  66. package/dist/functions/runAction/schemas.js +15 -0
  67. package/dist/index.d.ts +15 -3
  68. package/dist/index.js +27 -4
  69. package/dist/plugins/apps/index.d.ts +8 -0
  70. package/dist/plugins/apps/index.js +77 -0
  71. package/dist/plugins/apps/info.d.ts +6 -0
  72. package/dist/plugins/apps/info.js +13 -0
  73. package/dist/plugins/apps/types.d.ts +21 -0
  74. package/dist/plugins/apps/types.js +2 -0
  75. package/dist/resolvers/actionKey.d.ts +8 -0
  76. package/dist/resolvers/actionKey.js +20 -0
  77. package/dist/resolvers/actionType.d.ts +8 -0
  78. package/dist/resolvers/actionType.js +21 -0
  79. package/dist/resolvers/appKey.d.ts +6 -0
  80. package/dist/resolvers/appKey.js +8 -0
  81. package/dist/resolvers/authenticationId.d.ts +8 -0
  82. package/dist/resolvers/authenticationId.js +29 -0
  83. package/dist/resolvers/index.d.ts +39 -0
  84. package/dist/resolvers/index.js +105 -0
  85. package/dist/resolvers/inputs.d.ts +7 -0
  86. package/dist/resolvers/inputs.js +15 -0
  87. package/dist/schema-utils.d.ts +39 -0
  88. package/dist/schema-utils.js +52 -0
  89. package/dist/schemas/Action.d.ts +21 -0
  90. package/dist/schemas/Action.js +31 -0
  91. package/dist/schemas/App.d.ts +19 -0
  92. package/dist/schemas/App.js +32 -0
  93. package/dist/schemas/Auth.d.ts +30 -0
  94. package/dist/schemas/Auth.js +49 -0
  95. package/dist/schemas/Field.d.ts +15 -0
  96. package/dist/schemas/Field.js +25 -0
  97. package/dist/sdk.d.ts +3 -4
  98. package/dist/sdk.js +96 -11
  99. package/dist/types/domain.d.ts +22 -0
  100. package/dist/types/domain.js +21 -0
  101. package/dist/types/properties.d.ts +21 -0
  102. package/dist/types/properties.js +45 -0
  103. package/dist/types/sdk.d.ts +21 -0
  104. package/dist/types/sdk.js +2 -0
  105. package/package.json +4 -2
  106. package/src/api/auth.ts +28 -0
  107. package/src/api/client.ts +148 -0
  108. package/src/api/debug.ts +58 -0
  109. package/src/api/index.ts +83 -0
  110. package/src/api/polling.ts +56 -0
  111. package/src/{types.ts → api/types.ts} +51 -118
  112. package/src/functions/bundleCode/index.ts +78 -0
  113. package/src/functions/bundleCode/info.ts +9 -0
  114. package/src/functions/bundleCode/schemas.ts +30 -0
  115. package/src/functions/generateTypes/index.ts +348 -0
  116. package/src/functions/generateTypes/info.ts +9 -0
  117. package/src/functions/generateTypes/schemas.ts +38 -0
  118. package/src/functions/getAction/index.ts +33 -0
  119. package/src/functions/getAction/info.ts +9 -0
  120. package/src/functions/getAction/schemas.ts +35 -0
  121. package/src/functions/getApp/index.ts +41 -0
  122. package/src/functions/getApp/info.ts +9 -0
  123. package/src/functions/getApp/schemas.ts +31 -0
  124. package/src/functions/listActions/index.ts +149 -0
  125. package/src/functions/listActions/info.ts +9 -0
  126. package/src/functions/listActions/schemas.ts +40 -0
  127. package/src/functions/listApps/index.ts +60 -0
  128. package/src/functions/listApps/info.ts +9 -0
  129. package/src/functions/listApps/schemas.ts +43 -0
  130. package/src/functions/listAuths/index.ts +153 -0
  131. package/src/functions/listAuths/info.ts +9 -0
  132. package/src/functions/listAuths/schemas.ts +48 -0
  133. package/src/functions/listFields/index.ts +86 -0
  134. package/src/functions/listFields/info.ts +9 -0
  135. package/src/functions/listFields/schemas.ts +46 -0
  136. package/src/functions/runAction/index.ts +258 -0
  137. package/src/functions/runAction/info.ts +9 -0
  138. package/src/functions/runAction/schemas.ts +41 -0
  139. package/src/index.ts +24 -4
  140. package/src/plugins/apps/index.ts +144 -0
  141. package/src/plugins/apps/info.ts +12 -0
  142. package/src/plugins/apps/types.ts +34 -0
  143. package/src/resolvers/actionKey.ts +33 -0
  144. package/src/resolvers/actionType.ts +30 -0
  145. package/src/resolvers/appKey.ts +11 -0
  146. package/src/resolvers/authenticationId.ts +38 -0
  147. package/src/resolvers/index.ts +117 -0
  148. package/src/resolvers/inputs.ts +23 -0
  149. package/src/schema-utils.ts +119 -0
  150. package/src/schemas/Action.ts +40 -0
  151. package/src/schemas/App.ts +43 -0
  152. package/src/schemas/Auth.ts +62 -0
  153. package/src/schemas/Field.ts +34 -0
  154. package/src/sdk.ts +153 -19
  155. package/src/types/domain.ts +54 -0
  156. package/src/types/properties.ts +67 -0
  157. package/src/types/sdk.ts +42 -0
  158. package/dist/actions-sdk.d.ts +0 -51
  159. package/dist/actions-sdk.js +0 -1194
  160. package/dist/output-schemas.d.ts +0 -95
  161. package/dist/output-schemas.js +0 -138
  162. package/dist/schemas.d.ts +0 -338
  163. package/dist/schemas.js +0 -336
  164. package/dist/types.js +0 -41
  165. package/src/actions-sdk.ts +0 -1685
  166. package/src/output-schemas.ts +0 -196
  167. package/src/schemas.ts +0 -467
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.authenticationIdResolver = void 0;
4
+ exports.authenticationIdResolver = {
5
+ type: "dynamic",
6
+ depends: ["appKey"],
7
+ fetch: async (sdk, resolvedParams) => {
8
+ // Get auths for the specific app (owned auths will be prioritized automatically)
9
+ return await sdk.listAuths({
10
+ appKey: resolvedParams.appKey,
11
+ limit: 1000,
12
+ });
13
+ },
14
+ prompt: (auths, params) => ({
15
+ type: "list",
16
+ name: "authenticationId",
17
+ message: `Select authentication for ${params.appKey}:`,
18
+ choices: [
19
+ ...auths.map((auth) => ({
20
+ name: `${auth.title || auth.label || "Authentication"} (ID: ${auth.id})`,
21
+ value: auth.id,
22
+ })),
23
+ {
24
+ name: "↗ Skip authentication (may fail)",
25
+ value: null,
26
+ },
27
+ ],
28
+ }),
29
+ };
@@ -0,0 +1,39 @@
1
+ export declare const resolverRegistry: {
2
+ readonly appKey: import("./appKey").AppKeyResolver;
3
+ readonly actionType: import("./actionType").ActionTypeResolver;
4
+ readonly actionKey: import("./actionKey").ActionKeyResolver;
5
+ readonly authenticationId: import("./authenticationId").AuthenticationIdResolver;
6
+ readonly inputs: import("./inputs").InputsResolver;
7
+ };
8
+ export type ResolverName = keyof typeof resolverRegistry;
9
+ export type ResolverType = (typeof resolverRegistry)[ResolverName];
10
+ /**
11
+ * Get a resolver by name
12
+ */
13
+ export declare function getResolver(name: string): ResolverType | undefined;
14
+ /**
15
+ * Get all resolvers for a list of missing parameters
16
+ */
17
+ export declare function getResolversForMissingParams(missingParams: string[]): Record<string, ResolverType>;
18
+ /**
19
+ * Check if a parameter has a resolver
20
+ */
21
+ export declare function hasResolver(paramName: string): boolean;
22
+ /**
23
+ * Get all parameter names that have resolvers
24
+ */
25
+ export declare function getResolvableParams(): string[];
26
+ /**
27
+ * Resolve dependency chain for a parameter
28
+ * Returns parameters in the order they need to be resolved
29
+ */
30
+ export declare function getResolutionOrder(paramName: string, resolved?: Set<string>): string[];
31
+ /**
32
+ * Get resolution order for multiple parameters
33
+ */
34
+ export declare function getResolutionOrderForParams(paramNames: string[]): string[];
35
+ export { appKeyResolver } from "./appKey";
36
+ export { actionTypeResolver } from "./actionType";
37
+ export { actionKeyResolver } from "./actionKey";
38
+ export { authenticationIdResolver } from "./authenticationId";
39
+ export { inputsResolver } from "./inputs";
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.inputsResolver = exports.authenticationIdResolver = exports.actionKeyResolver = exports.actionTypeResolver = exports.appKeyResolver = exports.resolverRegistry = void 0;
4
+ exports.getResolver = getResolver;
5
+ exports.getResolversForMissingParams = getResolversForMissingParams;
6
+ exports.hasResolver = hasResolver;
7
+ exports.getResolvableParams = getResolvableParams;
8
+ exports.getResolutionOrder = getResolutionOrder;
9
+ exports.getResolutionOrderForParams = getResolutionOrderForParams;
10
+ const appKey_1 = require("./appKey");
11
+ const actionType_1 = require("./actionType");
12
+ const actionKey_1 = require("./actionKey");
13
+ const authenticationId_1 = require("./authenticationId");
14
+ const inputs_1 = require("./inputs");
15
+ // Centralized resolver registry
16
+ exports.resolverRegistry = {
17
+ appKey: appKey_1.appKeyResolver,
18
+ actionType: actionType_1.actionTypeResolver,
19
+ actionKey: actionKey_1.actionKeyResolver,
20
+ authenticationId: authenticationId_1.authenticationIdResolver,
21
+ inputs: inputs_1.inputsResolver,
22
+ };
23
+ // Utility functions for working with resolvers
24
+ /**
25
+ * Get a resolver by name
26
+ */
27
+ function getResolver(name) {
28
+ return exports.resolverRegistry[name];
29
+ }
30
+ /**
31
+ * Get all resolvers for a list of missing parameters
32
+ */
33
+ function getResolversForMissingParams(missingParams) {
34
+ const resolvers = {};
35
+ for (const param of missingParams) {
36
+ const resolver = exports.resolverRegistry[param];
37
+ if (resolver) {
38
+ resolvers[param] = resolver;
39
+ }
40
+ }
41
+ return resolvers;
42
+ }
43
+ /**
44
+ * Check if a parameter has a resolver
45
+ */
46
+ function hasResolver(paramName) {
47
+ return paramName in exports.resolverRegistry;
48
+ }
49
+ /**
50
+ * Get all parameter names that have resolvers
51
+ */
52
+ function getResolvableParams() {
53
+ return Object.keys(exports.resolverRegistry);
54
+ }
55
+ /**
56
+ * Resolve dependency chain for a parameter
57
+ * Returns parameters in the order they need to be resolved
58
+ */
59
+ function getResolutionOrder(paramName, resolved = new Set()) {
60
+ const resolver = getResolver(paramName);
61
+ if (!resolver || resolver.type === "static") {
62
+ return [paramName];
63
+ }
64
+ const order = [];
65
+ if ("depends" in resolver && resolver.depends) {
66
+ for (const dependency of resolver.depends) {
67
+ if (!resolved.has(dependency)) {
68
+ order.push(...getResolutionOrder(dependency, resolved));
69
+ resolved.add(dependency);
70
+ }
71
+ }
72
+ }
73
+ if (!resolved.has(paramName)) {
74
+ order.push(paramName);
75
+ resolved.add(paramName);
76
+ }
77
+ return order;
78
+ }
79
+ /**
80
+ * Get resolution order for multiple parameters
81
+ */
82
+ function getResolutionOrderForParams(paramNames) {
83
+ const resolved = new Set();
84
+ const order = [];
85
+ for (const paramName of paramNames) {
86
+ const paramOrder = getResolutionOrder(paramName, resolved);
87
+ for (const param of paramOrder) {
88
+ if (!order.includes(param)) {
89
+ order.push(param);
90
+ }
91
+ }
92
+ }
93
+ return order;
94
+ }
95
+ // Re-export individual resolvers for direct access if needed
96
+ var appKey_2 = require("./appKey");
97
+ Object.defineProperty(exports, "appKeyResolver", { enumerable: true, get: function () { return appKey_2.appKeyResolver; } });
98
+ var actionType_2 = require("./actionType");
99
+ Object.defineProperty(exports, "actionTypeResolver", { enumerable: true, get: function () { return actionType_2.actionTypeResolver; } });
100
+ var actionKey_2 = require("./actionKey");
101
+ Object.defineProperty(exports, "actionKeyResolver", { enumerable: true, get: function () { return actionKey_2.actionKeyResolver; } });
102
+ var authenticationId_2 = require("./authenticationId");
103
+ Object.defineProperty(exports, "authenticationIdResolver", { enumerable: true, get: function () { return authenticationId_2.authenticationIdResolver; } });
104
+ var inputs_2 = require("./inputs");
105
+ Object.defineProperty(exports, "inputsResolver", { enumerable: true, get: function () { return inputs_2.inputsResolver; } });
@@ -0,0 +1,7 @@
1
+ import type { ZapierSdk } from "../types/sdk";
2
+ export interface InputsResolver {
3
+ type: "fields";
4
+ depends: readonly string[];
5
+ fetch: (sdk: ZapierSdk, resolvedParams: Record<string, any>) => Promise<any[]>;
6
+ }
7
+ export declare const inputsResolver: InputsResolver;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.inputsResolver = void 0;
4
+ exports.inputsResolver = {
5
+ type: "fields",
6
+ depends: ["appKey", "actionKey", "actionType", "authenticationId"],
7
+ fetch: async (sdk, resolvedParams) => {
8
+ return await sdk.listFields({
9
+ appKey: resolvedParams.appKey,
10
+ actionKey: resolvedParams.actionKey,
11
+ actionType: resolvedParams.actionType,
12
+ authenticationId: resolvedParams.authenticationId,
13
+ });
14
+ },
15
+ };
@@ -0,0 +1,39 @@
1
+ import { z } from "zod";
2
+ export interface FormattedItem {
3
+ title: string;
4
+ subtitle?: string;
5
+ details: Array<{
6
+ text: string;
7
+ style: "normal" | "dim" | "accent" | "warning" | "success";
8
+ }>;
9
+ }
10
+ export interface FormatMetadata {
11
+ format: (item: any) => FormattedItem;
12
+ }
13
+ export declare function withFormatter<T extends z.ZodType>(schema: T, formatMeta: FormatMetadata): T;
14
+ export declare function getFormatMetadata(schema: z.ZodType): FormatMetadata | undefined;
15
+ export declare function withOutputSchema<T extends z.ZodType>(inputSchema: T, outputSchema: z.ZodType): T;
16
+ export declare function getOutputSchema(inputSchema: z.ZodType): z.ZodType | undefined;
17
+ export interface StaticResolver {
18
+ type: "static";
19
+ inputType?: "text" | "password" | "email";
20
+ placeholder?: string;
21
+ }
22
+ export interface DynamicResolver {
23
+ type: "dynamic";
24
+ fetch: (sdk: any, resolvedParams: any) => Promise<any[]>;
25
+ prompt: (items: any[], params: any) => any;
26
+ depends?: string[];
27
+ }
28
+ export interface FieldsResolver {
29
+ type: "fields";
30
+ fetch: (sdk: any, resolvedParams: any) => Promise<any[]>;
31
+ depends?: string[];
32
+ }
33
+ export type ResolverMetadata = StaticResolver | DynamicResolver | FieldsResolver;
34
+ export interface ResolverConfig {
35
+ resolver: ResolverMetadata;
36
+ }
37
+ export declare function withResolver<T extends z.ZodType>(schema: T, config: ResolverConfig): T;
38
+ export declare function getSchemaDescription(schema: z.ZodSchema): string | undefined;
39
+ export declare function getFieldDescriptions(schema: z.ZodObject<any>): Record<string, string>;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withFormatter = withFormatter;
4
+ exports.getFormatMetadata = getFormatMetadata;
5
+ exports.withOutputSchema = withOutputSchema;
6
+ exports.getOutputSchema = getOutputSchema;
7
+ exports.withResolver = withResolver;
8
+ exports.getSchemaDescription = getSchemaDescription;
9
+ exports.getFieldDescriptions = getFieldDescriptions;
10
+ const zod_1 = require("zod");
11
+ // Helper function to add format metadata to schemas
12
+ function withFormatter(schema, formatMeta) {
13
+ // Store format metadata on the schema definition
14
+ schema._def.formatMeta = formatMeta;
15
+ return schema;
16
+ }
17
+ // Helper function to get format metadata from a schema
18
+ function getFormatMetadata(schema) {
19
+ return schema._def.formatMeta;
20
+ }
21
+ // Helper function to link input schemas to output schemas
22
+ function withOutputSchema(inputSchema, outputSchema) {
23
+ // Store output schema reference on the input schema
24
+ inputSchema._def.outputSchema = outputSchema;
25
+ return inputSchema;
26
+ }
27
+ // Helper function to get output schema from an input schema
28
+ function getOutputSchema(inputSchema) {
29
+ return inputSchema._def.outputSchema;
30
+ }
31
+ // Helper function to add resolver metadata to schemas
32
+ function withResolver(schema, config) {
33
+ // Store resolver metadata on the schema definition
34
+ schema._def.resolverMeta = config;
35
+ return schema;
36
+ }
37
+ // ============================================================================
38
+ // Schema Description Utilities
39
+ // ============================================================================
40
+ function getSchemaDescription(schema) {
41
+ return schema.description;
42
+ }
43
+ function getFieldDescriptions(schema) {
44
+ const descriptions = {};
45
+ const shape = schema.shape;
46
+ for (const [key, fieldSchema] of Object.entries(shape)) {
47
+ if (fieldSchema instanceof zod_1.z.ZodType && fieldSchema.description) {
48
+ descriptions[key] = fieldSchema.description;
49
+ }
50
+ }
51
+ return descriptions;
52
+ }
@@ -0,0 +1,21 @@
1
+ import { z } from "zod";
2
+ export declare const ActionItemSchema: z.ZodObject<{
3
+ key: z.ZodString;
4
+ name: z.ZodOptional<z.ZodString>;
5
+ type: z.ZodString;
6
+ appKey: z.ZodOptional<z.ZodString>;
7
+ description: z.ZodOptional<z.ZodString>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ type: string;
10
+ key: string;
11
+ appKey?: string | undefined;
12
+ name?: string | undefined;
13
+ description?: string | undefined;
14
+ }, {
15
+ type: string;
16
+ key: string;
17
+ appKey?: string | undefined;
18
+ name?: string | undefined;
19
+ description?: string | undefined;
20
+ }>;
21
+ export type ActionItem = z.infer<typeof ActionItemSchema>;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActionItemSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const schema_utils_1 = require("../schema-utils");
6
+ // ============================================================================
7
+ // Action Schemas
8
+ // ============================================================================
9
+ exports.ActionItemSchema = (0, schema_utils_1.withFormatter)(zod_1.z.object({
10
+ key: zod_1.z.string(),
11
+ name: zod_1.z.string().optional(),
12
+ type: zod_1.z.string(),
13
+ appKey: zod_1.z.string().optional(),
14
+ description: zod_1.z.string().optional(),
15
+ }), {
16
+ format: (item) => {
17
+ const details = [];
18
+ details.push({ text: `Type: ${item.type}`, style: "accent" });
19
+ if (item.appKey) {
20
+ details.push({ text: `App: ${item.appKey}`, style: "normal" });
21
+ }
22
+ if (item.description) {
23
+ details.push({ text: item.description, style: "dim" });
24
+ }
25
+ return {
26
+ title: item.name || item.key,
27
+ subtitle: `(${item.key})`,
28
+ details,
29
+ };
30
+ },
31
+ });
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+ export { FormattedItem, FormatMetadata } from "../schema-utils";
3
+ export declare const AppItemSchema: z.ZodObject<{
4
+ key: z.ZodString;
5
+ name: z.ZodOptional<z.ZodString>;
6
+ description: z.ZodOptional<z.ZodString>;
7
+ category: z.ZodOptional<z.ZodString>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ key: string;
10
+ name?: string | undefined;
11
+ description?: string | undefined;
12
+ category?: string | undefined;
13
+ }, {
14
+ key: string;
15
+ name?: string | undefined;
16
+ description?: string | undefined;
17
+ category?: string | undefined;
18
+ }>;
19
+ export type AppItem = z.infer<typeof AppItemSchema>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppItemSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const schema_utils_1 = require("../schema-utils");
6
+ // ============================================================================
7
+ // App Schemas
8
+ // ============================================================================
9
+ exports.AppItemSchema = (0, schema_utils_1.withFormatter)(zod_1.z.object({
10
+ key: zod_1.z.string(),
11
+ name: zod_1.z.string().optional(),
12
+ description: zod_1.z.string().optional(),
13
+ category: zod_1.z.string().optional(),
14
+ }), {
15
+ format: (item) => {
16
+ const details = [];
17
+ if (item.description) {
18
+ details.push({ text: item.description, style: "dim" });
19
+ }
20
+ if (item.category) {
21
+ details.push({
22
+ text: `Category: ${item.category}`,
23
+ style: "accent",
24
+ });
25
+ }
26
+ return {
27
+ title: item.name || item.key,
28
+ subtitle: `(${item.key})`,
29
+ details,
30
+ };
31
+ },
32
+ });
@@ -0,0 +1,30 @@
1
+ import { z } from "zod";
2
+ export declare const AuthItemSchema: z.ZodObject<{
3
+ id: z.ZodNumber;
4
+ title: z.ZodOptional<z.ZodString>;
5
+ label: z.ZodOptional<z.ZodString>;
6
+ identifier: z.ZodOptional<z.ZodString>;
7
+ account_id: z.ZodOptional<z.ZodString>;
8
+ is_private: z.ZodOptional<z.ZodBoolean>;
9
+ shared_with_all: z.ZodOptional<z.ZodBoolean>;
10
+ marked_stale_at: z.ZodOptional<z.ZodString>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ id: number;
13
+ title?: string | undefined;
14
+ label?: string | undefined;
15
+ identifier?: string | undefined;
16
+ account_id?: string | undefined;
17
+ is_private?: boolean | undefined;
18
+ shared_with_all?: boolean | undefined;
19
+ marked_stale_at?: string | undefined;
20
+ }, {
21
+ id: number;
22
+ title?: string | undefined;
23
+ label?: string | undefined;
24
+ identifier?: string | undefined;
25
+ account_id?: string | undefined;
26
+ is_private?: boolean | undefined;
27
+ shared_with_all?: boolean | undefined;
28
+ marked_stale_at?: string | undefined;
29
+ }>;
30
+ export type AuthItem = z.infer<typeof AuthItemSchema>;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthItemSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const schema_utils_1 = require("../schema-utils");
6
+ // ============================================================================
7
+ // Auth Schemas
8
+ // ============================================================================
9
+ exports.AuthItemSchema = (0, schema_utils_1.withFormatter)(zod_1.z.object({
10
+ id: zod_1.z.number(),
11
+ title: zod_1.z.string().optional(),
12
+ label: zod_1.z.string().optional(),
13
+ identifier: zod_1.z.string().optional(),
14
+ account_id: zod_1.z.string().optional(),
15
+ is_private: zod_1.z.boolean().optional(),
16
+ shared_with_all: zod_1.z.boolean().optional(),
17
+ marked_stale_at: zod_1.z.string().optional(),
18
+ }), {
19
+ format: (item) => {
20
+ const details = [];
21
+ if (item.identifier) {
22
+ details.push({
23
+ text: `Identifier: ${item.identifier}`,
24
+ style: "accent",
25
+ });
26
+ }
27
+ if (item.label && item.title && item.label !== item.title) {
28
+ details.push({
29
+ text: `Label: ${item.label}`,
30
+ style: "normal",
31
+ });
32
+ }
33
+ details.push({
34
+ text: `Account: ${item.account_id || "unknown"} | Private: ${item.is_private || false} | Shared: ${item.shared_with_all || false}`,
35
+ style: "dim",
36
+ });
37
+ if (item.marked_stale_at) {
38
+ details.push({
39
+ text: `⚠️ Marked stale: ${new Date(item.marked_stale_at).toLocaleDateString()}`,
40
+ style: "warning",
41
+ });
42
+ }
43
+ return {
44
+ title: item.title || item.label || `Authentication ${item.id}`,
45
+ subtitle: `(ID: ${item.id})`,
46
+ details,
47
+ };
48
+ },
49
+ });
@@ -0,0 +1,15 @@
1
+ import { z } from "zod";
2
+ export declare const FieldItemSchema: z.ZodObject<{
3
+ key: z.ZodString;
4
+ name: z.ZodOptional<z.ZodString>;
5
+ description: z.ZodOptional<z.ZodString>;
6
+ }, "strip", z.ZodTypeAny, {
7
+ key: string;
8
+ name?: string | undefined;
9
+ description?: string | undefined;
10
+ }, {
11
+ key: string;
12
+ name?: string | undefined;
13
+ description?: string | undefined;
14
+ }>;
15
+ export type FieldItem = z.infer<typeof FieldItemSchema>;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldItemSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const schema_utils_1 = require("../schema-utils");
6
+ // ============================================================================
7
+ // Field Schemas
8
+ // ============================================================================
9
+ exports.FieldItemSchema = (0, schema_utils_1.withFormatter)(zod_1.z.object({
10
+ key: zod_1.z.string(),
11
+ name: zod_1.z.string().optional(),
12
+ description: zod_1.z.string().optional(),
13
+ }), {
14
+ format: (item) => {
15
+ const details = [];
16
+ if (item.description) {
17
+ details.push({ text: item.description, style: "dim" });
18
+ }
19
+ return {
20
+ title: item.name || item.key,
21
+ subtitle: `(${item.key})`,
22
+ details,
23
+ };
24
+ },
25
+ });
package/dist/sdk.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { ActionsSdk } from "./actions-sdk";
2
- import { BaseSdkOptions } from "./types";
3
- export interface ZapierSdk extends ActionsSdk {
4
- }
1
+ import { BaseSdkOptions } from "./types/domain";
2
+ import type { ZapierSdk } from "./types/sdk";
3
+ export type { ZapierSdk } from "./types/sdk";
5
4
  export interface ZapierSdkOptions extends BaseSdkOptions {
6
5
  }
7
6
  export declare function createZapierSdk(options?: ZapierSdkOptions): ZapierSdk;
package/dist/sdk.js CHANGED
@@ -1,17 +1,102 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createZapierSdk = createZapierSdk;
4
- const actions_sdk_1 = require("./actions-sdk");
4
+ const api_1 = require("./api");
5
+ // Import function implementations
6
+ const listApps_1 = require("./functions/listApps");
7
+ const getApp_1 = require("./functions/getApp");
8
+ const listActions_1 = require("./functions/listActions");
9
+ const getAction_1 = require("./functions/getAction");
10
+ const runAction_1 = require("./functions/runAction");
11
+ const listAuths_1 = require("./functions/listAuths");
12
+ const listFields_1 = require("./functions/listFields");
13
+ const generateTypes_1 = require("./functions/generateTypes");
14
+ const bundleCode_1 = require("./functions/bundleCode");
15
+ // Import function registry info objects (only for CLI registry)
16
+ const info_1 = require("./functions/listApps/info");
17
+ const info_2 = require("./functions/getApp/info");
18
+ const info_3 = require("./functions/listActions/info");
19
+ const info_4 = require("./functions/getAction/info");
20
+ const info_5 = require("./functions/runAction/info");
21
+ const info_6 = require("./functions/listAuths/info");
22
+ const info_7 = require("./functions/listFields/info");
23
+ const info_8 = require("./functions/generateTypes/info");
24
+ const info_9 = require("./functions/bundleCode/info");
25
+ // Function registry as array - uses names from function info objects
26
+ const functionRegistry = [
27
+ info_1.listAppsInfo,
28
+ info_2.getAppInfo,
29
+ info_3.listActionsInfo,
30
+ info_4.getActionInfo,
31
+ info_5.runActionInfo,
32
+ info_6.listAuthsInfo,
33
+ info_7.listFieldsInfo,
34
+ info_8.generateTypesInfo,
35
+ info_9.bundleCodeInfo,
36
+ ];
37
+ // Import plugin functions
38
+ const index_1 = require("./plugins/apps/index");
39
+ function createBaseZapierSdk(options = {}) {
40
+ // Auto-load .env files (searches up directory tree)
41
+ try {
42
+ const { findUpSync } = require("find-up");
43
+ const envPath = findUpSync(".env");
44
+ if (envPath) {
45
+ require("dotenv").config({ path: envPath, quiet: true });
46
+ }
47
+ }
48
+ catch {
49
+ // Silently fail if dotenv/find-up not available or .env not found
50
+ }
51
+ const { fetch: customFetch = globalThis.fetch, baseUrl = "https://zapier.com", token, debug = false, } = options;
52
+ // If no token provided, try to get it from environment variable
53
+ const finalToken = token || process.env.ZAPIER_TOKEN;
54
+ // Create the API client
55
+ const api = (0, api_1.createZapierApi)({
56
+ baseUrl,
57
+ token: finalToken,
58
+ debug,
59
+ fetch: customFetch,
60
+ });
61
+ // Build SDK directly - TypeScript will enforce correct implementation
62
+ const sdk = {
63
+ // Registry for CLI
64
+ __registry: functionRegistry,
65
+ // Function implementations with API config injection
66
+ listApps: (options = {}) => (0, listApps_1.listApps)({ ...options, api, token: finalToken }),
67
+ getApp: (options) => (0, getApp_1.getApp)({ ...options, api, token: finalToken }),
68
+ listActions: (options = {}) => (0, listActions_1.listActions)({ ...options, api, token: finalToken }),
69
+ getAction: (options) => (0, getAction_1.getAction)({ ...options, api, token: finalToken }),
70
+ runAction: (options) => (0, runAction_1.runAction)({ ...options, api, token: finalToken }),
71
+ listAuths: (options = {}) => (0, listAuths_1.listAuths)({ ...options, api, token: finalToken }),
72
+ listFields: (options) => (0, listFields_1.listFields)({ ...options, api, token: finalToken }),
73
+ generateTypes: (options) => (0, generateTypes_1.generateTypes)({ ...options, api, token: finalToken }),
74
+ bundleCode: (options) => (0, bundleCode_1.bundleCode)(options), // No API config needed
75
+ };
76
+ return sdk;
77
+ }
5
78
  function createZapierSdk(options = {}) {
6
- // Create individual SDKs
7
- const actionsSdk = (0, actions_sdk_1.createActionsSdk)(options);
8
- // For now, we just return the actions SDK
9
- // Later we'll combine multiple SDKs here
10
- return {
11
- ...actionsSdk,
12
- // Future SDKs will be spread here:
13
- // ...workflowsSdk,
14
- // ...interfacesSdk,
15
- // ...tablesSdk,
79
+ // Create base SDK
80
+ const baseSdk = createBaseZapierSdk(options);
81
+ // Extract options needed for plugins
82
+ const { fetch: customFetch = globalThis.fetch, baseUrl = "https://zapier.com", token, debug = false, } = options;
83
+ const finalToken = token || process.env.ZAPIER_TOKEN;
84
+ // Create the API client for plugins
85
+ const api = (0, api_1.createZapierApi)({
86
+ baseUrl,
87
+ token: finalToken,
88
+ debug,
89
+ fetch: customFetch,
90
+ });
91
+ // Create plugins directly - TypeScript will enforce correct implementation
92
+ const appsPlugin = (0, index_1.createAppsPlugin)({
93
+ api,
94
+ token: finalToken,
95
+ });
96
+ // Compose final SDK - TypeScript will enforce we have all required properties
97
+ const fullSdk = {
98
+ ...baseSdk,
99
+ apps: appsPlugin,
16
100
  };
101
+ return fullSdk;
17
102
  }