@zapier/zapier-sdk 0.0.3 → 0.1.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.
- package/dist/api/auth.d.ts +8 -0
- package/dist/api/auth.js +29 -0
- package/dist/api/client.d.ts +8 -0
- package/dist/api/client.js +102 -0
- package/dist/api/debug.d.ts +12 -0
- package/dist/api/debug.js +50 -0
- package/dist/api/index.d.ts +26 -0
- package/dist/api/index.js +51 -0
- package/dist/api/polling.d.ts +17 -0
- package/dist/api/polling.js +34 -0
- package/dist/{types.d.ts → api/types.d.ts} +37 -88
- package/dist/api/types.js +9 -0
- package/dist/functions/{bundleCode.d.ts → bundleCode/index.d.ts} +1 -8
- package/dist/functions/bundleCode/info.d.ts +27 -0
- package/dist/functions/bundleCode/info.js +11 -0
- package/dist/functions/bundleCode/schemas.d.ts +27 -0
- package/dist/functions/bundleCode/schemas.js +22 -0
- package/dist/functions/findFirstAuthentication/index.d.ts +12 -0
- package/dist/functions/findFirstAuthentication/index.js +21 -0
- package/dist/functions/findFirstAuthentication/info.d.ts +30 -0
- package/dist/functions/findFirstAuthentication/info.js +11 -0
- package/dist/functions/findFirstAuthentication/schemas.d.ts +42 -0
- package/dist/functions/findFirstAuthentication/schemas.js +25 -0
- package/dist/functions/findUniqueAuthentication/index.d.ts +13 -0
- package/dist/functions/findUniqueAuthentication/index.js +28 -0
- package/dist/functions/findUniqueAuthentication/info.d.ts +30 -0
- package/dist/functions/findUniqueAuthentication/info.js +11 -0
- package/dist/functions/findUniqueAuthentication/schemas.d.ts +42 -0
- package/dist/functions/findUniqueAuthentication/schemas.js +25 -0
- package/dist/functions/{generateTypes.d.ts → generateTypes/index.d.ts} +2 -7
- package/dist/functions/{generateTypes.js → generateTypes/index.js} +58 -24
- package/dist/functions/generateTypes/info.d.ts +21 -0
- package/dist/functions/generateTypes/info.js +11 -0
- package/dist/functions/generateTypes/schemas.d.ts +30 -0
- package/dist/functions/generateTypes/schemas.js +14 -0
- package/dist/functions/{getAction.d.ts → getAction/index.d.ts} +2 -6
- package/dist/functions/{getAction.js → getAction/index.js} +6 -5
- package/dist/functions/getAction/info.d.ts +18 -0
- package/dist/functions/getAction/info.js +11 -0
- package/dist/functions/getAction/schemas.d.ts +30 -0
- package/dist/functions/getAction/schemas.js +13 -0
- package/dist/functions/{getApp.d.ts → getApp/index.d.ts} +2 -4
- package/dist/functions/{getApp.js → getApp/index.js} +6 -10
- package/dist/functions/getApp/info.d.ts +12 -0
- package/dist/functions/getApp/info.js +11 -0
- package/dist/functions/getApp/schemas.d.ts +24 -0
- package/dist/functions/getApp/schemas.js +11 -0
- package/dist/functions/{listActions.d.ts → listActions/index.d.ts} +3 -6
- package/dist/functions/{listActions.js → listActions/index.js} +4 -3
- package/dist/functions/listActions/info.d.ts +15 -0
- package/dist/functions/listActions/info.js +11 -0
- package/dist/functions/listActions/schemas.d.ts +27 -0
- package/dist/functions/listActions/schemas.js +14 -0
- package/dist/functions/{listApps.d.ts → listApps/index.d.ts} +2 -6
- package/dist/functions/{listApps.js → listApps/index.js} +1 -1
- package/dist/functions/listApps/info.d.ts +18 -0
- package/dist/functions/listApps/info.js +11 -0
- package/dist/functions/listApps/schemas.d.ts +30 -0
- package/dist/functions/listApps/schemas.js +15 -0
- package/dist/functions/{listAuths.d.ts → listAuthentications/index.d.ts} +3 -9
- package/dist/functions/{listAuths.js → listAuthentications/index.js} +28 -12
- package/dist/functions/listAuthentications/info.d.ts +30 -0
- package/dist/functions/listAuthentications/info.js +11 -0
- package/dist/functions/listAuthentications/schemas.d.ts +42 -0
- package/dist/functions/listAuthentications/schemas.js +25 -0
- package/dist/functions/{listFields.d.ts → listFields/index.d.ts} +3 -9
- package/dist/functions/{listFields.js → listFields/index.js} +8 -10
- package/dist/functions/listFields/info.d.ts +24 -0
- package/dist/functions/listFields/info.js +11 -0
- package/dist/functions/listFields/schemas.d.ts +36 -0
- package/dist/functions/listFields/schemas.js +17 -0
- package/dist/functions/{runAction.d.ts → runAction/index.d.ts} +2 -8
- package/dist/functions/{runAction.js → runAction/index.js} +15 -14
- package/dist/functions/runAction/info.d.ts +24 -0
- package/dist/functions/runAction/info.js +11 -0
- package/dist/functions/runAction/schemas.d.ts +36 -0
- package/dist/functions/runAction/schemas.js +15 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.js +17 -6
- package/dist/plugins/apps/index.d.ts +8 -0
- package/dist/plugins/apps/index.js +77 -0
- package/dist/plugins/apps/info.d.ts +6 -0
- package/dist/plugins/apps/info.js +13 -0
- package/dist/plugins/apps/types.d.ts +21 -0
- package/dist/plugins/apps/types.js +2 -0
- package/dist/resolvers/actionKey.d.ts +8 -0
- package/dist/resolvers/actionKey.js +20 -0
- package/dist/resolvers/actionType.d.ts +8 -0
- package/dist/resolvers/actionType.js +21 -0
- package/dist/resolvers/appKey.d.ts +6 -0
- package/dist/resolvers/appKey.js +8 -0
- package/dist/resolvers/authenticationId.d.ts +8 -0
- package/dist/resolvers/authenticationId.js +29 -0
- package/dist/resolvers/index.d.ts +39 -0
- package/dist/resolvers/index.js +105 -0
- package/dist/resolvers/inputs.d.ts +7 -0
- package/dist/resolvers/inputs.js +15 -0
- package/dist/schema-utils.d.ts +44 -0
- package/dist/schema-utils.js +76 -0
- package/dist/schemas/Action.d.ts +21 -0
- package/dist/schemas/Action.js +31 -0
- package/dist/schemas/App.d.ts +19 -0
- package/dist/schemas/App.js +32 -0
- package/dist/schemas/Auth.d.ts +27 -0
- package/dist/schemas/Auth.js +42 -0
- package/dist/schemas/Field.d.ts +15 -0
- package/dist/schemas/Field.js +25 -0
- package/dist/sdk.d.ts +3 -4
- package/dist/sdk.js +104 -11
- package/dist/types/domain.d.ts +22 -0
- package/dist/types/domain.js +21 -0
- package/dist/types/properties.d.ts +21 -0
- package/dist/types/properties.js +43 -0
- package/dist/types/sdk.d.ts +23 -0
- package/dist/types/sdk.js +2 -0
- package/package.json +4 -2
- package/src/api/auth.ts +28 -0
- package/src/api/client.ts +148 -0
- package/src/api/debug.ts +58 -0
- package/src/api/index.ts +83 -0
- package/src/api/polling.ts +56 -0
- package/src/api/types.ts +177 -0
- package/src/functions/{bundleCode.ts → bundleCode/index.ts} +1 -8
- package/src/functions/bundleCode/info.ts +9 -0
- package/src/functions/bundleCode/schemas.ts +30 -0
- package/src/functions/findFirstAuthentication/index.ts +24 -0
- package/src/functions/findFirstAuthentication/info.ts +9 -0
- package/src/functions/findFirstAuthentication/schemas.ts +60 -0
- package/src/functions/findUniqueAuthentication/index.ts +35 -0
- package/src/functions/findUniqueAuthentication/info.ts +9 -0
- package/src/functions/findUniqueAuthentication/schemas.ts +60 -0
- package/src/functions/{generateTypes.ts → generateTypes/index.ts} +70 -31
- package/src/functions/generateTypes/info.ts +9 -0
- package/src/functions/generateTypes/schemas.ts +38 -0
- package/src/functions/{getAction.ts → getAction/index.ts} +11 -12
- package/src/functions/getAction/info.ts +9 -0
- package/src/functions/getAction/schemas.ts +35 -0
- package/src/functions/{getApp.ts → getApp/index.ts} +9 -15
- package/src/functions/getApp/info.ts +9 -0
- package/src/functions/getApp/schemas.ts +31 -0
- package/src/functions/{listActions.ts → listActions/index.ts} +8 -10
- package/src/functions/listActions/info.ts +9 -0
- package/src/functions/listActions/schemas.ts +40 -0
- package/src/functions/{listApps.ts → listApps/index.ts} +3 -8
- package/src/functions/listApps/info.ts +9 -0
- package/src/functions/listApps/schemas.ts +43 -0
- package/src/functions/{listAuths.ts → listAuthentications/index.ts} +32 -23
- package/src/functions/listAuthentications/info.ts +9 -0
- package/src/functions/listAuthentications/schemas.ts +60 -0
- package/src/functions/{listFields.ts → listFields/index.ts} +11 -20
- package/src/functions/listFields/info.ts +9 -0
- package/src/functions/listFields/schemas.ts +46 -0
- package/src/functions/{runAction.ts → runAction/index.ts} +25 -23
- package/src/functions/runAction/info.ts +9 -0
- package/src/functions/runAction/schemas.ts +41 -0
- package/src/index.ts +19 -5
- package/src/plugins/apps/index.ts +144 -0
- package/src/plugins/apps/info.ts +12 -0
- package/src/plugins/apps/types.ts +34 -0
- package/src/resolvers/actionKey.ts +33 -0
- package/src/resolvers/actionType.ts +30 -0
- package/src/resolvers/appKey.ts +11 -0
- package/src/resolvers/authenticationId.ts +38 -0
- package/src/resolvers/index.ts +117 -0
- package/src/resolvers/inputs.ts +23 -0
- package/src/schema-utils.ts +154 -0
- package/src/schemas/Action.ts +40 -0
- package/src/schemas/App.ts +43 -0
- package/src/schemas/Auth.ts +54 -0
- package/src/schemas/Field.ts +34 -0
- package/src/sdk.ts +165 -19
- package/src/types/domain.ts +54 -0
- package/src/types/properties.ts +67 -0
- package/src/types/sdk.ts +46 -0
- package/dist/actions-sdk.d.ts +0 -47
- package/dist/actions-sdk.js +0 -208
- package/dist/api.d.ts +0 -62
- package/dist/api.js +0 -227
- package/dist/output-schemas.d.ts +0 -95
- package/dist/output-schemas.js +0 -138
- package/dist/schemas.d.ts +0 -338
- package/dist/schemas.js +0 -336
- package/dist/types.js +0 -41
- package/src/actions-sdk.ts +0 -356
- package/src/api.ts +0 -361
- package/src/output-schemas.ts +0 -196
- package/src/schemas.ts +0 -467
- package/src/types.ts +0 -257
- /package/dist/functions/{bundleCode.js → bundleCode/index.js} +0 -0
|
@@ -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,44 @@
|
|
|
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>;
|
|
40
|
+
export interface PositionalMetadata {
|
|
41
|
+
positional: true;
|
|
42
|
+
}
|
|
43
|
+
export declare function withPositional<T extends z.ZodType>(schema: T): T;
|
|
44
|
+
export declare function isPositional(schema: z.ZodType): boolean;
|
|
@@ -0,0 +1,76 @@
|
|
|
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
|
+
exports.withPositional = withPositional;
|
|
11
|
+
exports.isPositional = isPositional;
|
|
12
|
+
const zod_1 = require("zod");
|
|
13
|
+
// Helper function to add format metadata to schemas
|
|
14
|
+
function withFormatter(schema, formatMeta) {
|
|
15
|
+
// Store format metadata on the schema definition
|
|
16
|
+
schema._def.formatMeta = formatMeta;
|
|
17
|
+
return schema;
|
|
18
|
+
}
|
|
19
|
+
// Helper function to get format metadata from a schema
|
|
20
|
+
function getFormatMetadata(schema) {
|
|
21
|
+
return schema._def.formatMeta;
|
|
22
|
+
}
|
|
23
|
+
// Helper function to link input schemas to output schemas
|
|
24
|
+
function withOutputSchema(inputSchema, outputSchema) {
|
|
25
|
+
// Store output schema reference on the input schema
|
|
26
|
+
inputSchema._def.outputSchema = outputSchema;
|
|
27
|
+
return inputSchema;
|
|
28
|
+
}
|
|
29
|
+
// Helper function to get output schema from an input schema
|
|
30
|
+
function getOutputSchema(inputSchema) {
|
|
31
|
+
return inputSchema._def.outputSchema;
|
|
32
|
+
}
|
|
33
|
+
// Helper function to add resolver metadata to schemas
|
|
34
|
+
function withResolver(schema, config) {
|
|
35
|
+
// Store resolver metadata on the schema definition
|
|
36
|
+
schema._def.resolverMeta = config;
|
|
37
|
+
return schema;
|
|
38
|
+
}
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// Schema Description Utilities
|
|
41
|
+
// ============================================================================
|
|
42
|
+
function getSchemaDescription(schema) {
|
|
43
|
+
return schema.description;
|
|
44
|
+
}
|
|
45
|
+
function getFieldDescriptions(schema) {
|
|
46
|
+
const descriptions = {};
|
|
47
|
+
const shape = schema.shape;
|
|
48
|
+
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
49
|
+
if (fieldSchema instanceof zod_1.z.ZodType && fieldSchema.description) {
|
|
50
|
+
descriptions[key] = fieldSchema.description;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return descriptions;
|
|
54
|
+
}
|
|
55
|
+
// Helper function to mark a parameter as positional for CLI
|
|
56
|
+
function withPositional(schema) {
|
|
57
|
+
// Store positional metadata on the schema definition
|
|
58
|
+
schema._def.positionalMeta = { positional: true };
|
|
59
|
+
return schema;
|
|
60
|
+
}
|
|
61
|
+
// Helper function to check if a parameter should be positional
|
|
62
|
+
function isPositional(schema) {
|
|
63
|
+
// Check the current schema first
|
|
64
|
+
if (schema._def.positionalMeta?.positional) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
// If this is a ZodOptional, check the inner type
|
|
68
|
+
if (schema instanceof zod_1.z.ZodOptional) {
|
|
69
|
+
return isPositional(schema._def.innerType);
|
|
70
|
+
}
|
|
71
|
+
// If this is a ZodDefault, check the inner type
|
|
72
|
+
if (schema instanceof zod_1.z.ZodDefault) {
|
|
73
|
+
return isPositional(schema._def.innerType);
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
@@ -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,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const AuthItemSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodNumber;
|
|
4
|
+
title: z.ZodOptional<z.ZodString>;
|
|
5
|
+
identifier: z.ZodOptional<z.ZodString>;
|
|
6
|
+
account_id: z.ZodOptional<z.ZodString>;
|
|
7
|
+
is_private: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
shared_with_all: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
marked_stale_at: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
id: number;
|
|
12
|
+
title?: string | undefined;
|
|
13
|
+
identifier?: string | undefined;
|
|
14
|
+
account_id?: string | undefined;
|
|
15
|
+
is_private?: boolean | undefined;
|
|
16
|
+
shared_with_all?: boolean | undefined;
|
|
17
|
+
marked_stale_at?: string | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
id: number;
|
|
20
|
+
title?: string | undefined;
|
|
21
|
+
identifier?: string | undefined;
|
|
22
|
+
account_id?: string | undefined;
|
|
23
|
+
is_private?: boolean | undefined;
|
|
24
|
+
shared_with_all?: boolean | undefined;
|
|
25
|
+
marked_stale_at?: string | undefined;
|
|
26
|
+
}>;
|
|
27
|
+
export type AuthItem = z.infer<typeof AuthItemSchema>;
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
identifier: zod_1.z.string().optional(),
|
|
13
|
+
account_id: zod_1.z.string().optional(),
|
|
14
|
+
is_private: zod_1.z.boolean().optional(),
|
|
15
|
+
shared_with_all: zod_1.z.boolean().optional(),
|
|
16
|
+
marked_stale_at: zod_1.z.string().optional(),
|
|
17
|
+
}), {
|
|
18
|
+
format: (item) => {
|
|
19
|
+
const details = [];
|
|
20
|
+
if (item.identifier) {
|
|
21
|
+
details.push({
|
|
22
|
+
text: `Identifier: ${item.identifier}`,
|
|
23
|
+
style: "accent",
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
details.push({
|
|
27
|
+
text: `Account: ${item.account_id || "unknown"} | Private: ${item.is_private || false} | Shared: ${item.shared_with_all || false}`,
|
|
28
|
+
style: "dim",
|
|
29
|
+
});
|
|
30
|
+
if (item.marked_stale_at) {
|
|
31
|
+
details.push({
|
|
32
|
+
text: `⚠️ Marked stale: ${new Date(item.marked_stale_at).toLocaleDateString()}`,
|
|
33
|
+
style: "warning",
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
title: item.title || `Authentication ${item.id}`,
|
|
38
|
+
subtitle: `(ID: ${item.id})`,
|
|
39
|
+
details,
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
});
|
|
@@ -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 {
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
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,110 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createZapierSdk = createZapierSdk;
|
|
4
|
-
const
|
|
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 listAuthentications_1 = require("./functions/listAuthentications");
|
|
12
|
+
const findFirstAuthentication_1 = require("./functions/findFirstAuthentication");
|
|
13
|
+
const findUniqueAuthentication_1 = require("./functions/findUniqueAuthentication");
|
|
14
|
+
const listFields_1 = require("./functions/listFields");
|
|
15
|
+
const generateTypes_1 = require("./functions/generateTypes");
|
|
16
|
+
const bundleCode_1 = require("./functions/bundleCode");
|
|
17
|
+
// Import function registry info objects (only for CLI registry)
|
|
18
|
+
const info_1 = require("./functions/listApps/info");
|
|
19
|
+
const info_2 = require("./functions/getApp/info");
|
|
20
|
+
const info_3 = require("./functions/listActions/info");
|
|
21
|
+
const info_4 = require("./functions/getAction/info");
|
|
22
|
+
const info_5 = require("./functions/runAction/info");
|
|
23
|
+
const info_6 = require("./functions/listAuthentications/info");
|
|
24
|
+
const info_7 = require("./functions/findFirstAuthentication/info");
|
|
25
|
+
const info_8 = require("./functions/findUniqueAuthentication/info");
|
|
26
|
+
const info_9 = require("./functions/listFields/info");
|
|
27
|
+
const info_10 = require("./functions/generateTypes/info");
|
|
28
|
+
const info_11 = require("./functions/bundleCode/info");
|
|
29
|
+
// Function registry as array - uses names from function info objects
|
|
30
|
+
const functionRegistry = [
|
|
31
|
+
info_1.listAppsInfo,
|
|
32
|
+
info_2.getAppInfo,
|
|
33
|
+
info_3.listActionsInfo,
|
|
34
|
+
info_4.getActionInfo,
|
|
35
|
+
info_5.runActionInfo,
|
|
36
|
+
info_6.listAuthenticationsInfo,
|
|
37
|
+
info_7.findFirstAuthenticationInfo,
|
|
38
|
+
info_8.findUniqueAuthenticationInfo,
|
|
39
|
+
info_9.listFieldsInfo,
|
|
40
|
+
info_10.generateTypesInfo,
|
|
41
|
+
info_11.bundleCodeInfo,
|
|
42
|
+
];
|
|
43
|
+
// Import plugin functions
|
|
44
|
+
const index_1 = require("./plugins/apps/index");
|
|
45
|
+
function createBaseZapierSdk(options = {}) {
|
|
46
|
+
// Auto-load .env files (searches up directory tree)
|
|
47
|
+
try {
|
|
48
|
+
const { findUpSync } = require("find-up");
|
|
49
|
+
const envPath = findUpSync(".env");
|
|
50
|
+
if (envPath) {
|
|
51
|
+
require("dotenv").config({ path: envPath, quiet: true });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// Silently fail if dotenv/find-up not available or .env not found
|
|
56
|
+
}
|
|
57
|
+
const { fetch: customFetch = globalThis.fetch, baseUrl = "https://zapier.com", token, debug = false, } = options;
|
|
58
|
+
// If no token provided, try to get it from environment variable
|
|
59
|
+
const finalToken = token || process.env.ZAPIER_TOKEN;
|
|
60
|
+
// Create the API client
|
|
61
|
+
const api = (0, api_1.createZapierApi)({
|
|
62
|
+
baseUrl,
|
|
63
|
+
token: finalToken,
|
|
64
|
+
debug,
|
|
65
|
+
fetch: customFetch,
|
|
66
|
+
});
|
|
67
|
+
// Build SDK directly - TypeScript will enforce correct implementation
|
|
68
|
+
const sdk = {
|
|
69
|
+
// Registry for CLI
|
|
70
|
+
__registry: functionRegistry,
|
|
71
|
+
// Function implementations with API config injection
|
|
72
|
+
listApps: (options = {}) => (0, listApps_1.listApps)({ ...options, api, token: finalToken }),
|
|
73
|
+
getApp: (options) => (0, getApp_1.getApp)({ ...options, api, token: finalToken }),
|
|
74
|
+
listActions: (options = {}) => (0, listActions_1.listActions)({ ...options, api, token: finalToken }),
|
|
75
|
+
getAction: (options) => (0, getAction_1.getAction)({ ...options, api, token: finalToken }),
|
|
76
|
+
runAction: (options) => (0, runAction_1.runAction)({ ...options, api, token: finalToken }),
|
|
77
|
+
listAuthentications: (options = {}) => (0, listAuthentications_1.listAuthentications)({ ...options, api, token: finalToken }),
|
|
78
|
+
findFirstAuthentication: (options = {}) => (0, findFirstAuthentication_1.findFirstAuthentication)({ ...options, api, token: finalToken }),
|
|
79
|
+
findUniqueAuthentication: (options = {}) => (0, findUniqueAuthentication_1.findUniqueAuthentication)({ ...options, api, token: finalToken }),
|
|
80
|
+
listFields: (options) => (0, listFields_1.listFields)({ ...options, api, token: finalToken }),
|
|
81
|
+
generateTypes: (options) => (0, generateTypes_1.generateTypes)({ ...options, api, token: finalToken }),
|
|
82
|
+
bundleCode: (options) => (0, bundleCode_1.bundleCode)(options), // No API config needed
|
|
83
|
+
};
|
|
84
|
+
return sdk;
|
|
85
|
+
}
|
|
5
86
|
function createZapierSdk(options = {}) {
|
|
6
|
-
// Create
|
|
7
|
-
const
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
87
|
+
// Create base SDK
|
|
88
|
+
const baseSdk = createBaseZapierSdk(options);
|
|
89
|
+
// Extract options needed for plugins
|
|
90
|
+
const { fetch: customFetch = globalThis.fetch, baseUrl = "https://zapier.com", token, debug = false, } = options;
|
|
91
|
+
const finalToken = token || process.env.ZAPIER_TOKEN;
|
|
92
|
+
// Create the API client for plugins
|
|
93
|
+
const api = (0, api_1.createZapierApi)({
|
|
94
|
+
baseUrl,
|
|
95
|
+
token: finalToken,
|
|
96
|
+
debug,
|
|
97
|
+
fetch: customFetch,
|
|
98
|
+
});
|
|
99
|
+
// Create plugins directly - TypeScript will enforce correct implementation
|
|
100
|
+
const appsPlugin = (0, index_1.createAppsPlugin)({
|
|
101
|
+
api,
|
|
102
|
+
token: finalToken,
|
|
103
|
+
});
|
|
104
|
+
// Compose final SDK - TypeScript will enforce we have all required properties
|
|
105
|
+
const fullSdk = {
|
|
106
|
+
...baseSdk,
|
|
107
|
+
apps: appsPlugin,
|
|
16
108
|
};
|
|
109
|
+
return fullSdk;
|
|
17
110
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type { Integration, Action, Trigger, Field, Choice, ActionExecutionResult, ActionField, ActionFieldChoice, NeedsRequest, NeedsResponse, Authentication, AuthenticationsResponse, } from "../api/types";
|
|
2
|
+
export interface ActionExecutionOptions {
|
|
3
|
+
inputs?: Record<string, any>;
|
|
4
|
+
authenticationId?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface AuthObject {
|
|
7
|
+
id: number;
|
|
8
|
+
}
|
|
9
|
+
export interface BaseSdkOptions {
|
|
10
|
+
token?: string;
|
|
11
|
+
fetch?: typeof fetch;
|
|
12
|
+
baseUrl?: string;
|
|
13
|
+
debug?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare class ZapierSdkError extends Error {
|
|
16
|
+
code?: string | undefined;
|
|
17
|
+
constructor(message: string, code?: string | undefined);
|
|
18
|
+
}
|
|
19
|
+
export declare class AppNotFoundError extends ZapierSdkError {
|
|
20
|
+
appKey: string;
|
|
21
|
+
constructor(appKey: string);
|
|
22
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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;
|