@zapier/zapier-sdk 0.13.1 → 0.13.3
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/CHANGELOG.md +12 -0
- package/README.md +14 -2
- package/dist/api/debug.d.ts.map +1 -1
- package/dist/api/debug.js +36 -1
- package/dist/index.cjs +62 -14
- package/dist/index.d.mts +23 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.mjs +61 -15
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +3 -2
- package/dist/plugins/listInputFields/index.d.ts +2 -1
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +7 -2
- package/dist/plugins/listInputFields/index.test.js +36 -5
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +6 -1
- package/dist/schemas/App.d.ts.map +1 -1
- package/dist/schemas/App.js +11 -1
- package/dist/utils/domain-utils.d.ts.map +1 -1
- package/dist/utils/domain-utils.js +2 -6
- package/dist/utils/string-utils.d.ts +9 -0
- package/dist/utils/string-utils.d.ts.map +1 -1
- package/dist/utils/string-utils.js +25 -0
- package/package.json +1 -1
- package/src/api/debug.ts +44 -1
- package/src/index.ts +3 -0
- package/src/plugins/getAction/index.ts +5 -2
- package/src/plugins/listInputFields/index.test.ts +37 -5
- package/src/plugins/listInputFields/index.ts +10 -3
- package/src/plugins/runAction/index.ts +9 -0
- package/src/schemas/App.ts +12 -1
- package/src/utils/domain-utils.ts +2 -6
- package/src/utils/string-utils.ts +28 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @zapier/zapier-sdk
|
|
2
2
|
|
|
3
|
+
## 0.13.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 53fa85e: Show id and key properties when listing actions. Allow getAction to use an id or key. Make runAction pass action_id to API to ensure it always works.
|
|
8
|
+
|
|
9
|
+
## 0.13.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 325d5c2: Fix bug where adding apps with dashed slugs would create types with syntax errors. All valid keys are now valid properties on the apps interface.
|
|
14
|
+
|
|
3
15
|
## 0.13.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -47,14 +47,21 @@ npm install -D @zapier/zapier-sdk-cli @types/node typescript
|
|
|
47
47
|
npx zapier-sdk login
|
|
48
48
|
|
|
49
49
|
# Generate TypeScript types for actions and fields of any apps you want to use.
|
|
50
|
-
npx zapier-sdk add slack
|
|
50
|
+
npx zapier-sdk add slack google-sheets
|
|
51
|
+
|
|
52
|
+
# The names of apps are there slugs if available, otherwise internal keys. If
|
|
53
|
+
# you don't know the slug or key, just use `list-apps` search to find it.
|
|
54
|
+
zapier-sdk list-apps --search "google sheets"
|
|
55
|
+
|
|
56
|
+
# The output will show you the valid keys next to the app title like this:
|
|
57
|
+
# 1. Google Sheets (GoogleSheetsV2CLIAPI, google-sheets, google_sheets)
|
|
51
58
|
|
|
52
59
|
# By default, types will be generated inside your `src` or `lib` folder if you
|
|
53
60
|
# have one or otherwise the root folder. Make sure your `tsconfig.json` file
|
|
54
61
|
# includes the generated type files.
|
|
55
62
|
|
|
56
63
|
# Alternatively, you can specify a custom output directory.
|
|
57
|
-
npx zapier-sdk add slack
|
|
64
|
+
npx zapier-sdk add slack google-sheets --types-output ./types
|
|
58
65
|
```
|
|
59
66
|
|
|
60
67
|
```typescript
|
|
@@ -193,6 +200,11 @@ const { data: sameUsers } = await zapier.apps.slack.search.user_by_email({
|
|
|
193
200
|
console.log({
|
|
194
201
|
sameUsers,
|
|
195
202
|
});
|
|
203
|
+
|
|
204
|
+
// If the slug for an app has dashes, you can also use a snake_cased app key.
|
|
205
|
+
// For example, either of the following are valid:
|
|
206
|
+
// zapier.apps["google-sheets"]
|
|
207
|
+
// zapier.apps.google_sheets
|
|
196
208
|
```
|
|
197
209
|
|
|
198
210
|
## Available Functions
|
package/dist/api/debug.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/api/debug.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/api/debug.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAa3C,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAwC/D;AAED,wBAAgB,aAAa,CAC3B,OAAO,CAAC,EAAE,WAAW,GACpB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAwCpC;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,aAAa,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACvC,QAAQ,EAAE,WAAW,CAAC;CACvB,IAEe,OAAO,WAAW,GAAG,GAAG,EAAE,UAAU,WAAW,uBA0C9D"}
|
package/dist/api/debug.js
CHANGED
|
@@ -4,12 +4,47 @@
|
|
|
4
4
|
* This module provides debug logging capabilities for API requests and responses,
|
|
5
5
|
* including request timing and detailed logging of HTTP interactions.
|
|
6
6
|
*/
|
|
7
|
+
// We don't want to import util since it might not work in a browser. So we'll lazily load it and cache the result so
|
|
8
|
+
// we can use it synchronously after that. The types above are just to make our linter happy.
|
|
9
|
+
let utilModule = null;
|
|
10
|
+
let utilPromise = null;
|
|
7
11
|
export function createDebugLogger(enabled) {
|
|
8
12
|
if (!enabled) {
|
|
9
13
|
return () => { }; // No-op function when debug is disabled
|
|
10
14
|
}
|
|
15
|
+
// Try to load util module on first use.
|
|
16
|
+
if (!utilPromise) {
|
|
17
|
+
utilPromise = import("util")
|
|
18
|
+
.then((util) => {
|
|
19
|
+
utilModule = util;
|
|
20
|
+
return util;
|
|
21
|
+
})
|
|
22
|
+
.catch(() => {
|
|
23
|
+
utilModule = null;
|
|
24
|
+
return null;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
11
27
|
return (message, data) => {
|
|
12
|
-
|
|
28
|
+
if (data === undefined || data === "") {
|
|
29
|
+
console.log(`[Zapier SDK] ${message}`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// Use cached module if available for sync logging. Yes, this means if the util module isn't yet loaded, we'll fall
|
|
33
|
+
// back to a plain old console.log, which might mean we don't see proper formatting/nesting. But that's unlikely
|
|
34
|
+
// since this logging happens during async fetching. Alternatively, we could switch to async logging, but this
|
|
35
|
+
// seems fine since we have to have a fallback anyway.
|
|
36
|
+
if (utilModule) {
|
|
37
|
+
const formatted = utilModule.inspect(data, {
|
|
38
|
+
colors: true,
|
|
39
|
+
depth: null,
|
|
40
|
+
breakLength: 80,
|
|
41
|
+
});
|
|
42
|
+
console.log(`[Zapier SDK] ${message}`, formatted);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// Fallback - browser will handle formatting automatically
|
|
46
|
+
console.log(`[Zapier SDK] ${message}`, data);
|
|
47
|
+
}
|
|
13
48
|
};
|
|
14
49
|
}
|
|
15
50
|
export function censorHeaders(headers) {
|
package/dist/index.cjs
CHANGED
|
@@ -1082,6 +1082,18 @@ zod.z.object({
|
|
|
1082
1082
|
links: NeedChoicesResponseLinksSchema.optional()
|
|
1083
1083
|
});
|
|
1084
1084
|
|
|
1085
|
+
// src/utils/string-utils.ts
|
|
1086
|
+
function toTitleCase(input) {
|
|
1087
|
+
return input.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-]+/g, " ").replace(/\s+/g, " ").trim().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
1088
|
+
}
|
|
1089
|
+
function toSnakeCase(input) {
|
|
1090
|
+
let result = input.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s\-]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toLowerCase();
|
|
1091
|
+
if (/^[0-9]/.test(result)) {
|
|
1092
|
+
result = "_" + result;
|
|
1093
|
+
}
|
|
1094
|
+
return result;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1085
1097
|
// src/schemas/App.ts
|
|
1086
1098
|
var AppItemSchema = withFormatter(
|
|
1087
1099
|
ImplementationMetaSchema.omit({ name: true, id: true }).extend({
|
|
@@ -1094,10 +1106,18 @@ var AppItemSchema = withFormatter(
|
|
|
1094
1106
|
}),
|
|
1095
1107
|
{
|
|
1096
1108
|
format: (item) => {
|
|
1109
|
+
const additionalKeys = [];
|
|
1110
|
+
if (item.slug && item.slug !== item.key) {
|
|
1111
|
+
additionalKeys.push(item.slug);
|
|
1112
|
+
const snakeCaseSlug = toSnakeCase(item.slug);
|
|
1113
|
+
if (snakeCaseSlug !== item.slug && snakeCaseSlug !== item.key) {
|
|
1114
|
+
additionalKeys.push(snakeCaseSlug);
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1097
1117
|
return {
|
|
1098
1118
|
title: item.title,
|
|
1099
1119
|
key: item.key,
|
|
1100
|
-
keys: [item.
|
|
1120
|
+
keys: [item.key, ...additionalKeys],
|
|
1101
1121
|
description: item.description,
|
|
1102
1122
|
details: []
|
|
1103
1123
|
};
|
|
@@ -1119,15 +1139,11 @@ function normalizeImplementationMetaToAppItem(implementationMeta) {
|
|
|
1119
1139
|
const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
|
|
1120
1140
|
const { id, name, ...restOfImplementationMeta } = implementationMeta;
|
|
1121
1141
|
return {
|
|
1122
|
-
// Pass through all ImplementationMeta fields except id and name
|
|
1123
1142
|
...restOfImplementationMeta,
|
|
1124
|
-
// Transform key fields
|
|
1125
1143
|
title: name,
|
|
1126
1144
|
key: selectedApi,
|
|
1127
1145
|
implementation_id: id,
|
|
1128
|
-
// Keep the full versioned ID
|
|
1129
1146
|
version: appVersion
|
|
1130
|
-
// Extract version separately
|
|
1131
1147
|
};
|
|
1132
1148
|
}
|
|
1133
1149
|
function normalizeAuthenticationItem(auth, options = {}) {
|
|
@@ -1773,11 +1789,6 @@ var RootFieldItemSchema = zod.z.union([
|
|
|
1773
1789
|
FieldsetItemSchema
|
|
1774
1790
|
]);
|
|
1775
1791
|
|
|
1776
|
-
// src/utils/string-utils.ts
|
|
1777
|
-
function toTitleCase(input) {
|
|
1778
|
-
return input.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-]+/g, " ").replace(/\s+/g, " ").trim().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
1779
|
-
}
|
|
1780
|
-
|
|
1781
1792
|
// src/plugins/listInputFields/index.ts
|
|
1782
1793
|
function getInputFieldTypeFromNeed(need) {
|
|
1783
1794
|
if (need.list) {
|
|
@@ -1877,7 +1888,7 @@ function transformNeedsToFields(needs) {
|
|
|
1877
1888
|
}
|
|
1878
1889
|
return rootFields;
|
|
1879
1890
|
}
|
|
1880
|
-
var listInputFieldsPlugin = ({ context }) => {
|
|
1891
|
+
var listInputFieldsPlugin = ({ sdk, context }) => {
|
|
1881
1892
|
const listInputFields = createPaginatedFunction(
|
|
1882
1893
|
async function listInputFieldsPage(options) {
|
|
1883
1894
|
const { api, getVersionedImplementationId } = context;
|
|
@@ -1889,9 +1900,14 @@ var listInputFieldsPlugin = ({ context }) => {
|
|
|
1889
1900
|
{ configType: "current_implementation_id" }
|
|
1890
1901
|
);
|
|
1891
1902
|
}
|
|
1903
|
+
const { data: action } = await sdk.getAction({
|
|
1904
|
+
appKey,
|
|
1905
|
+
actionType,
|
|
1906
|
+
actionKey
|
|
1907
|
+
});
|
|
1892
1908
|
const needsRequest = {
|
|
1893
1909
|
selected_api: selectedApi,
|
|
1894
|
-
action:
|
|
1910
|
+
action: action.key,
|
|
1895
1911
|
type_of: actionType,
|
|
1896
1912
|
params: inputs || {}
|
|
1897
1913
|
};
|
|
@@ -2132,7 +2148,7 @@ var getActionPlugin = ({ sdk }) => {
|
|
|
2132
2148
|
const { actionKey, actionType, appKey } = options;
|
|
2133
2149
|
const actionsResult = await sdk.listActions({ appKey });
|
|
2134
2150
|
for (const action of actionsResult.data) {
|
|
2135
|
-
if (action.key === actionKey && action.action_type === actionType) {
|
|
2151
|
+
if ((action.key === actionKey || action.id === actionKey) && action.action_type === actionType) {
|
|
2136
2152
|
return { data: action };
|
|
2137
2153
|
}
|
|
2138
2154
|
}
|
|
@@ -2337,6 +2353,7 @@ async function executeAction(actionOptions) {
|
|
|
2337
2353
|
api,
|
|
2338
2354
|
context,
|
|
2339
2355
|
appKey,
|
|
2356
|
+
actionId,
|
|
2340
2357
|
actionKey,
|
|
2341
2358
|
actionType,
|
|
2342
2359
|
executionOptions,
|
|
@@ -2351,6 +2368,7 @@ async function executeAction(actionOptions) {
|
|
|
2351
2368
|
}
|
|
2352
2369
|
const runRequestData = {
|
|
2353
2370
|
selected_api: selectedApi,
|
|
2371
|
+
action_id: actionId,
|
|
2354
2372
|
action_key: actionKey,
|
|
2355
2373
|
action_type: actionType,
|
|
2356
2374
|
inputs: executionOptions.inputs || {}
|
|
@@ -2392,10 +2410,14 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
2392
2410
|
`Action type mismatch: expected ${actionType}, got ${actionData.data.action_type}`
|
|
2393
2411
|
);
|
|
2394
2412
|
}
|
|
2413
|
+
const actionId = actionData.data.id;
|
|
2395
2414
|
const result = await executeAction({
|
|
2396
2415
|
api,
|
|
2397
2416
|
context,
|
|
2398
2417
|
appKey,
|
|
2418
|
+
// Some actions require the action ID to run them, but technically the ID is not guaranteed to be available when
|
|
2419
|
+
// we retrieve actions (probably legacy reasons), so we just pass along all the things!
|
|
2420
|
+
actionId,
|
|
2399
2421
|
actionKey,
|
|
2400
2422
|
actionType,
|
|
2401
2423
|
executionOptions: { inputs },
|
|
@@ -2940,13 +2962,37 @@ function getAuthorizationHeader(token) {
|
|
|
2940
2962
|
}
|
|
2941
2963
|
|
|
2942
2964
|
// src/api/debug.ts
|
|
2965
|
+
var utilModule = null;
|
|
2966
|
+
var utilPromise = null;
|
|
2943
2967
|
function createDebugLogger(enabled) {
|
|
2944
2968
|
if (!enabled) {
|
|
2945
2969
|
return () => {
|
|
2946
2970
|
};
|
|
2947
2971
|
}
|
|
2972
|
+
if (!utilPromise) {
|
|
2973
|
+
utilPromise = import('util').then((util) => {
|
|
2974
|
+
utilModule = util;
|
|
2975
|
+
return util;
|
|
2976
|
+
}).catch(() => {
|
|
2977
|
+
utilModule = null;
|
|
2978
|
+
return null;
|
|
2979
|
+
});
|
|
2980
|
+
}
|
|
2948
2981
|
return (message, data) => {
|
|
2949
|
-
|
|
2982
|
+
if (data === void 0 || data === "") {
|
|
2983
|
+
console.log(`[Zapier SDK] ${message}`);
|
|
2984
|
+
return;
|
|
2985
|
+
}
|
|
2986
|
+
if (utilModule) {
|
|
2987
|
+
const formatted = utilModule.inspect(data, {
|
|
2988
|
+
colors: true,
|
|
2989
|
+
depth: null,
|
|
2990
|
+
breakLength: 80
|
|
2991
|
+
});
|
|
2992
|
+
console.log(`[Zapier SDK] ${message}`, formatted);
|
|
2993
|
+
} else {
|
|
2994
|
+
console.log(`[Zapier SDK] ${message}`, data);
|
|
2995
|
+
}
|
|
2950
2996
|
};
|
|
2951
2997
|
}
|
|
2952
2998
|
function censorHeaders(headers) {
|
|
@@ -3882,3 +3928,5 @@ exports.readManifestFromFile = readManifestFromFile;
|
|
|
3882
3928
|
exports.registryPlugin = registryPlugin;
|
|
3883
3929
|
exports.requestPlugin = requestPlugin;
|
|
3884
3930
|
exports.runActionPlugin = runActionPlugin;
|
|
3931
|
+
exports.toSnakeCase = toSnakeCase;
|
|
3932
|
+
exports.toTitleCase = toTitleCase;
|
package/dist/index.d.mts
CHANGED
|
@@ -1947,7 +1947,7 @@ interface ListInputFieldsPluginProvides {
|
|
|
1947
1947
|
};
|
|
1948
1948
|
};
|
|
1949
1949
|
}
|
|
1950
|
-
declare const listInputFieldsPlugin: Plugin<GetSdkType<GetAppPluginProvides>, // requires getApp in SDK
|
|
1950
|
+
declare const listInputFieldsPlugin: Plugin<GetSdkType<GetAppPluginProvides & GetActionPluginProvides>, // requires getApp and getAction in SDK
|
|
1951
1951
|
{
|
|
1952
1952
|
api: ApiClient;
|
|
1953
1953
|
getVersionedImplementationId: GetVersionedImplementationId;
|
|
@@ -2885,6 +2885,27 @@ type ParamsProperty = z.infer<typeof ParamsPropertySchema>;
|
|
|
2885
2885
|
*/
|
|
2886
2886
|
declare function createFunction<TOptions, TResult, TSchemaOptions extends TOptions = TOptions>(coreFn: (options: TOptions) => Promise<TResult>, schema?: z.ZodSchema<TSchemaOptions>): (options?: TOptions) => Promise<TResult>;
|
|
2887
2887
|
|
|
2888
|
+
/**
|
|
2889
|
+
* String utility functions for the Zapier SDK
|
|
2890
|
+
*/
|
|
2891
|
+
/**
|
|
2892
|
+
* Converts a string to title case, handling various input formats:
|
|
2893
|
+
* - camelCase: "firstName" → "First Name"
|
|
2894
|
+
* - snake_case: "first_name" → "First Name"
|
|
2895
|
+
* - kebab-case: "first-name" → "First Name"
|
|
2896
|
+
* - mixed formats: "first_name-value" → "First Name Value"
|
|
2897
|
+
*/
|
|
2898
|
+
declare function toTitleCase(input: string): string;
|
|
2899
|
+
/**
|
|
2900
|
+
* Converts a string to snake_case, handling various input formats:
|
|
2901
|
+
* - camelCase: "firstName" → "first_name"
|
|
2902
|
+
* - kebab-case: "first-name" → "first_name"
|
|
2903
|
+
* - title case: "First Name" → "first_name"
|
|
2904
|
+
* - mixed formats: "first-Name Value" → "first_name_value"
|
|
2905
|
+
* - starts with number: "123abc" → "_123abc"
|
|
2906
|
+
*/
|
|
2907
|
+
declare function toSnakeCase(input: string): string;
|
|
2908
|
+
|
|
2888
2909
|
declare const appKeyResolver: StaticResolver;
|
|
2889
2910
|
|
|
2890
2911
|
interface ActionTypeItem {
|
|
@@ -3081,4 +3102,4 @@ declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk
|
|
|
3081
3102
|
}>;
|
|
3082
3103
|
declare function createZapierSdk(options?: ZapierSdkOptions): ZapierSdk;
|
|
3083
3104
|
|
|
3084
|
-
export { type Action, type ActionExecutionOptions, type ActionExecutionResult, type ActionField, type ActionFieldChoice, type ActionItem$1 as ActionItem, type ActionKeyProperty, ActionKeyPropertySchema, type ActionTypeProperty, ActionTypePropertySchema, type ApiError, type ApiEvent, type ApiPluginOptions, type ApiPluginProvides, type App, type AppItem, type AppKeyProperty, AppKeyPropertySchema, type AppsPluginProvides, type AuthEvent, type AuthOptions, type Authentication, type AuthenticationIdProperty, AuthenticationIdPropertySchema, type AuthenticationItem, type AuthenticationsResponse, type Choice, DEFAULT_CONFIG_PATH, type DebugProperty, DebugPropertySchema, type ErrorOptions, type EventCallback, type FetchPluginProvides, type Field, type FieldsetItem, type FindFirstAuthenticationPluginProvides, type FindUniqueAuthenticationPluginProvides, type FormatMetadata, type FormattedItem, type FunctionOptions, type FunctionRegistryEntry, type GetActionPluginProvides, type GetAppPluginProvides, type GetAuthenticationPluginProvides, type GetContextType, type GetProfilePluginProvides, type GetSdkType, type InfoFieldItem, type InputFieldItem, type InputsProperty, InputsPropertySchema, type LimitProperty, LimitPropertySchema, type ListActionsPluginProvides, type ListAppsPluginProvides, type ListAuthenticationsPluginProvides, type ListInputFieldsPluginProvides, type LoadingEvent, type ManifestPluginOptions, type ManifestPluginProvides, type Need, type NeedsRequest, type NeedsResponse, type OffsetProperty, OffsetPropertySchema, type OutputProperty, OutputPropertySchema, type PaginatedSdkFunction, type ParamsProperty, ParamsPropertySchema, type Plugin, type PluginDependencies, type PluginOptions, type PluginProvides, type PositionalMetadata, RelayFetchSchema, RelayRequestSchema, type RequestPluginProvides, type RootFieldItem, type RunActionPluginProvides, type Sdk, type SdkEvent, type UserProfile, type UserProfileItem, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, type ZapierFetchInitOptions, ZapierNotFoundError, ZapierResourceNotFoundError, type ZapierSdk, type ZapierSdkApps, type ZapierSdkOptions, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, authenticationIdGenericResolver, authenticationIdResolver, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, fetchPlugin, findFirstAuthenticationPlugin, findManifestEntry, findUniqueAuthenticationPlugin, formatErrorMessage, getActionPlugin, getAppPlugin, getAuthenticationPlugin, getPreferredManifestEntryKey, getProfilePlugin, getTokenFromCliLogin, getTokenFromEnv, getTokenFromEnvOrConfig, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, isPositional, listActionsPlugin, listAppsPlugin, listAuthenticationsPlugin, listInputFieldsPlugin, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, runActionPlugin };
|
|
3105
|
+
export { type Action, type ActionExecutionOptions, type ActionExecutionResult, type ActionField, type ActionFieldChoice, type ActionItem$1 as ActionItem, type ActionKeyProperty, ActionKeyPropertySchema, type ActionTypeProperty, ActionTypePropertySchema, type ApiError, type ApiEvent, type ApiPluginOptions, type ApiPluginProvides, type App, type AppItem, type AppKeyProperty, AppKeyPropertySchema, type AppsPluginProvides, type AuthEvent, type AuthOptions, type Authentication, type AuthenticationIdProperty, AuthenticationIdPropertySchema, type AuthenticationItem, type AuthenticationsResponse, type Choice, DEFAULT_CONFIG_PATH, type DebugProperty, DebugPropertySchema, type ErrorOptions, type EventCallback, type FetchPluginProvides, type Field, type FieldsetItem, type FindFirstAuthenticationPluginProvides, type FindUniqueAuthenticationPluginProvides, type FormatMetadata, type FormattedItem, type FunctionOptions, type FunctionRegistryEntry, type GetActionPluginProvides, type GetAppPluginProvides, type GetAuthenticationPluginProvides, type GetContextType, type GetProfilePluginProvides, type GetSdkType, type InfoFieldItem, type InputFieldItem, type InputsProperty, InputsPropertySchema, type LimitProperty, LimitPropertySchema, type ListActionsPluginProvides, type ListAppsPluginProvides, type ListAuthenticationsPluginProvides, type ListInputFieldsPluginProvides, type LoadingEvent, type ManifestPluginOptions, type ManifestPluginProvides, type Need, type NeedsRequest, type NeedsResponse, type OffsetProperty, OffsetPropertySchema, type OutputProperty, OutputPropertySchema, type PaginatedSdkFunction, type ParamsProperty, ParamsPropertySchema, type Plugin, type PluginDependencies, type PluginOptions, type PluginProvides, type PositionalMetadata, RelayFetchSchema, RelayRequestSchema, type RequestPluginProvides, type RootFieldItem, type RunActionPluginProvides, type Sdk, type SdkEvent, type UserProfile, type UserProfileItem, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, type ZapierFetchInitOptions, ZapierNotFoundError, ZapierResourceNotFoundError, type ZapierSdk, type ZapierSdkApps, type ZapierSdkOptions, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, authenticationIdGenericResolver, authenticationIdResolver, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, fetchPlugin, findFirstAuthenticationPlugin, findManifestEntry, findUniqueAuthenticationPlugin, formatErrorMessage, getActionPlugin, getAppPlugin, getAuthenticationPlugin, getPreferredManifestEntryKey, getProfilePlugin, getTokenFromCliLogin, getTokenFromEnv, getTokenFromEnvOrConfig, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, isPositional, listActionsPlugin, listAppsPlugin, listAuthenticationsPlugin, listInputFieldsPlugin, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, runActionPlugin, toSnakeCase, toTitleCase };
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export type { Action, App, Need, Field, Choice, ActionExecutionResult, ActionFie
|
|
|
22
22
|
export { isPositional, PositionalMetadata } from "./utils/schema-utils";
|
|
23
23
|
export { createFunction } from "./utils/function-utils";
|
|
24
24
|
export type { FormattedItem, FormatMetadata } from "./utils/schema-utils";
|
|
25
|
+
export { toSnakeCase, toTitleCase } from "./utils/string-utils";
|
|
25
26
|
export * from "./resolvers";
|
|
26
27
|
export * from "./auth";
|
|
27
28
|
export { RelayRequestSchema, RelayFetchSchema, } from "./plugins/request/schemas";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC;AACnD,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAG9B,YAAY,EACV,MAAM,EACN,GAAG,EACH,IAAI,EACJ,KAAK,EACL,MAAM,EACN,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,uBAAuB,EACvB,WAAW,GACZ,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG1E,cAAc,aAAa,CAAC;AAG5B,cAAc,QAAQ,CAAC;AAIvB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,eAAe,EACf,8BAA8B,EAC9B,SAAS,EACT,gBAAgB,GACjB,MAAM,OAAO,CAAC;AAGf,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGzD,YAAY,EACV,MAAM,EACN,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,cAAc,EACd,GAAG,GACJ,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mCAAmC,CAAC;AAClD,cAAc,oCAAoC,CAAC;AACnD,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAG9B,YAAY,EACV,MAAM,EACN,GAAG,EACH,IAAI,EACJ,KAAK,EACL,MAAM,EACN,qBAAqB,EACrB,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,uBAAuB,EACvB,WAAW,GACZ,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG1E,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGhE,cAAc,aAAa,CAAC;AAG5B,cAAc,QAAQ,CAAC;AAIvB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,eAAe,EACf,8BAA8B,EAC9B,SAAS,EACT,gBAAgB,GACjB,MAAM,OAAO,CAAC;AAGf,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAGzD,YAAY,EACV,MAAM,EACN,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,cAAc,EACd,GAAG,GACJ,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,8 @@ export * from "./plugins/api";
|
|
|
22
22
|
// Export schema utilities for CLI
|
|
23
23
|
export { isPositional } from "./utils/schema-utils";
|
|
24
24
|
export { createFunction } from "./utils/function-utils";
|
|
25
|
+
// Export string utilities
|
|
26
|
+
export { toSnakeCase, toTitleCase } from "./utils/string-utils";
|
|
25
27
|
// Export resolver utilities for CLI
|
|
26
28
|
export * from "./resolvers";
|
|
27
29
|
// Export auth utilities for CLI use
|
package/dist/index.mjs
CHANGED
|
@@ -1080,6 +1080,18 @@ z.object({
|
|
|
1080
1080
|
links: NeedChoicesResponseLinksSchema.optional()
|
|
1081
1081
|
});
|
|
1082
1082
|
|
|
1083
|
+
// src/utils/string-utils.ts
|
|
1084
|
+
function toTitleCase(input) {
|
|
1085
|
+
return input.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-]+/g, " ").replace(/\s+/g, " ").trim().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
1086
|
+
}
|
|
1087
|
+
function toSnakeCase(input) {
|
|
1088
|
+
let result = input.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[\s\-]+/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "").toLowerCase();
|
|
1089
|
+
if (/^[0-9]/.test(result)) {
|
|
1090
|
+
result = "_" + result;
|
|
1091
|
+
}
|
|
1092
|
+
return result;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1083
1095
|
// src/schemas/App.ts
|
|
1084
1096
|
var AppItemSchema = withFormatter(
|
|
1085
1097
|
ImplementationMetaSchema.omit({ name: true, id: true }).extend({
|
|
@@ -1092,10 +1104,18 @@ var AppItemSchema = withFormatter(
|
|
|
1092
1104
|
}),
|
|
1093
1105
|
{
|
|
1094
1106
|
format: (item) => {
|
|
1107
|
+
const additionalKeys = [];
|
|
1108
|
+
if (item.slug && item.slug !== item.key) {
|
|
1109
|
+
additionalKeys.push(item.slug);
|
|
1110
|
+
const snakeCaseSlug = toSnakeCase(item.slug);
|
|
1111
|
+
if (snakeCaseSlug !== item.slug && snakeCaseSlug !== item.key) {
|
|
1112
|
+
additionalKeys.push(snakeCaseSlug);
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1095
1115
|
return {
|
|
1096
1116
|
title: item.title,
|
|
1097
1117
|
key: item.key,
|
|
1098
|
-
keys: [item.
|
|
1118
|
+
keys: [item.key, ...additionalKeys],
|
|
1099
1119
|
description: item.description,
|
|
1100
1120
|
details: []
|
|
1101
1121
|
};
|
|
@@ -1117,15 +1137,11 @@ function normalizeImplementationMetaToAppItem(implementationMeta) {
|
|
|
1117
1137
|
const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
|
|
1118
1138
|
const { id, name, ...restOfImplementationMeta } = implementationMeta;
|
|
1119
1139
|
return {
|
|
1120
|
-
// Pass through all ImplementationMeta fields except id and name
|
|
1121
1140
|
...restOfImplementationMeta,
|
|
1122
|
-
// Transform key fields
|
|
1123
1141
|
title: name,
|
|
1124
1142
|
key: selectedApi,
|
|
1125
1143
|
implementation_id: id,
|
|
1126
|
-
// Keep the full versioned ID
|
|
1127
1144
|
version: appVersion
|
|
1128
|
-
// Extract version separately
|
|
1129
1145
|
};
|
|
1130
1146
|
}
|
|
1131
1147
|
function normalizeAuthenticationItem(auth, options = {}) {
|
|
@@ -1771,11 +1787,6 @@ var RootFieldItemSchema = z.union([
|
|
|
1771
1787
|
FieldsetItemSchema
|
|
1772
1788
|
]);
|
|
1773
1789
|
|
|
1774
|
-
// src/utils/string-utils.ts
|
|
1775
|
-
function toTitleCase(input) {
|
|
1776
|
-
return input.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_\-]+/g, " ").replace(/\s+/g, " ").trim().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
|
|
1777
|
-
}
|
|
1778
|
-
|
|
1779
1790
|
// src/plugins/listInputFields/index.ts
|
|
1780
1791
|
function getInputFieldTypeFromNeed(need) {
|
|
1781
1792
|
if (need.list) {
|
|
@@ -1875,7 +1886,7 @@ function transformNeedsToFields(needs) {
|
|
|
1875
1886
|
}
|
|
1876
1887
|
return rootFields;
|
|
1877
1888
|
}
|
|
1878
|
-
var listInputFieldsPlugin = ({ context }) => {
|
|
1889
|
+
var listInputFieldsPlugin = ({ sdk, context }) => {
|
|
1879
1890
|
const listInputFields = createPaginatedFunction(
|
|
1880
1891
|
async function listInputFieldsPage(options) {
|
|
1881
1892
|
const { api, getVersionedImplementationId } = context;
|
|
@@ -1887,9 +1898,14 @@ var listInputFieldsPlugin = ({ context }) => {
|
|
|
1887
1898
|
{ configType: "current_implementation_id" }
|
|
1888
1899
|
);
|
|
1889
1900
|
}
|
|
1901
|
+
const { data: action } = await sdk.getAction({
|
|
1902
|
+
appKey,
|
|
1903
|
+
actionType,
|
|
1904
|
+
actionKey
|
|
1905
|
+
});
|
|
1890
1906
|
const needsRequest = {
|
|
1891
1907
|
selected_api: selectedApi,
|
|
1892
|
-
action:
|
|
1908
|
+
action: action.key,
|
|
1893
1909
|
type_of: actionType,
|
|
1894
1910
|
params: inputs || {}
|
|
1895
1911
|
};
|
|
@@ -2130,7 +2146,7 @@ var getActionPlugin = ({ sdk }) => {
|
|
|
2130
2146
|
const { actionKey, actionType, appKey } = options;
|
|
2131
2147
|
const actionsResult = await sdk.listActions({ appKey });
|
|
2132
2148
|
for (const action of actionsResult.data) {
|
|
2133
|
-
if (action.key === actionKey && action.action_type === actionType) {
|
|
2149
|
+
if ((action.key === actionKey || action.id === actionKey) && action.action_type === actionType) {
|
|
2134
2150
|
return { data: action };
|
|
2135
2151
|
}
|
|
2136
2152
|
}
|
|
@@ -2335,6 +2351,7 @@ async function executeAction(actionOptions) {
|
|
|
2335
2351
|
api,
|
|
2336
2352
|
context,
|
|
2337
2353
|
appKey,
|
|
2354
|
+
actionId,
|
|
2338
2355
|
actionKey,
|
|
2339
2356
|
actionType,
|
|
2340
2357
|
executionOptions,
|
|
@@ -2349,6 +2366,7 @@ async function executeAction(actionOptions) {
|
|
|
2349
2366
|
}
|
|
2350
2367
|
const runRequestData = {
|
|
2351
2368
|
selected_api: selectedApi,
|
|
2369
|
+
action_id: actionId,
|
|
2352
2370
|
action_key: actionKey,
|
|
2353
2371
|
action_type: actionType,
|
|
2354
2372
|
inputs: executionOptions.inputs || {}
|
|
@@ -2390,10 +2408,14 @@ var runActionPlugin = ({ sdk, context }) => {
|
|
|
2390
2408
|
`Action type mismatch: expected ${actionType}, got ${actionData.data.action_type}`
|
|
2391
2409
|
);
|
|
2392
2410
|
}
|
|
2411
|
+
const actionId = actionData.data.id;
|
|
2393
2412
|
const result = await executeAction({
|
|
2394
2413
|
api,
|
|
2395
2414
|
context,
|
|
2396
2415
|
appKey,
|
|
2416
|
+
// Some actions require the action ID to run them, but technically the ID is not guaranteed to be available when
|
|
2417
|
+
// we retrieve actions (probably legacy reasons), so we just pass along all the things!
|
|
2418
|
+
actionId,
|
|
2397
2419
|
actionKey,
|
|
2398
2420
|
actionType,
|
|
2399
2421
|
executionOptions: { inputs },
|
|
@@ -2938,13 +2960,37 @@ function getAuthorizationHeader(token) {
|
|
|
2938
2960
|
}
|
|
2939
2961
|
|
|
2940
2962
|
// src/api/debug.ts
|
|
2963
|
+
var utilModule = null;
|
|
2964
|
+
var utilPromise = null;
|
|
2941
2965
|
function createDebugLogger(enabled) {
|
|
2942
2966
|
if (!enabled) {
|
|
2943
2967
|
return () => {
|
|
2944
2968
|
};
|
|
2945
2969
|
}
|
|
2970
|
+
if (!utilPromise) {
|
|
2971
|
+
utilPromise = import('util').then((util) => {
|
|
2972
|
+
utilModule = util;
|
|
2973
|
+
return util;
|
|
2974
|
+
}).catch(() => {
|
|
2975
|
+
utilModule = null;
|
|
2976
|
+
return null;
|
|
2977
|
+
});
|
|
2978
|
+
}
|
|
2946
2979
|
return (message, data) => {
|
|
2947
|
-
|
|
2980
|
+
if (data === void 0 || data === "") {
|
|
2981
|
+
console.log(`[Zapier SDK] ${message}`);
|
|
2982
|
+
return;
|
|
2983
|
+
}
|
|
2984
|
+
if (utilModule) {
|
|
2985
|
+
const formatted = utilModule.inspect(data, {
|
|
2986
|
+
colors: true,
|
|
2987
|
+
depth: null,
|
|
2988
|
+
breakLength: 80
|
|
2989
|
+
});
|
|
2990
|
+
console.log(`[Zapier SDK] ${message}`, formatted);
|
|
2991
|
+
} else {
|
|
2992
|
+
console.log(`[Zapier SDK] ${message}`, data);
|
|
2993
|
+
}
|
|
2948
2994
|
};
|
|
2949
2995
|
}
|
|
2950
2996
|
function censorHeaders(headers) {
|
|
@@ -3818,4 +3864,4 @@ function createZapierSdk(options = {}) {
|
|
|
3818
3864
|
return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
|
|
3819
3865
|
}
|
|
3820
3866
|
|
|
3821
|
-
export { ActionKeyPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, DEFAULT_CONFIG_PATH, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, RelayFetchSchema, RelayRequestSchema, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, authenticationIdGenericResolver, authenticationIdResolver, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, fetchPlugin, findFirstAuthenticationPlugin, findManifestEntry, findUniqueAuthenticationPlugin, formatErrorMessage, getActionPlugin, getAppPlugin, getAuthenticationPlugin, getPreferredManifestEntryKey, getProfilePlugin, getTokenFromCliLogin, getTokenFromEnv, getTokenFromEnvOrConfig, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, isPositional, listActionsPlugin, listAppsPlugin, listAuthenticationsPlugin, listInputFieldsPlugin, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, runActionPlugin };
|
|
3867
|
+
export { ActionKeyPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AuthenticationIdPropertySchema, DEFAULT_CONFIG_PATH, DebugPropertySchema, InputsPropertySchema, LimitPropertySchema, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, RelayFetchSchema, RelayRequestSchema, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, authenticationIdGenericResolver, authenticationIdResolver, createFunction, createSdk, createZapierSdk, createZapierSdkWithoutRegistry, fetchPlugin, findFirstAuthenticationPlugin, findManifestEntry, findUniqueAuthenticationPlugin, formatErrorMessage, getActionPlugin, getAppPlugin, getAuthenticationPlugin, getPreferredManifestEntryKey, getProfilePlugin, getTokenFromCliLogin, getTokenFromEnv, getTokenFromEnvOrConfig, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, isPositional, listActionsPlugin, listAppsPlugin, listAuthenticationsPlugin, listInputFieldsPlugin, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, runActionPlugin, toSnakeCase, toTitleCase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAction/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAGnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAQhE,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC,CAAC;IACxE,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,SAAS,EAAE;gBACT,WAAW,EAAE,OAAO,eAAe,CAAC;aACrC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,UAAU,CAAC,yBAAyB,CAAC,EAAE,8BAA8B;AACrE;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getAction/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAGnE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAQhE,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC,CAAC;IACxE,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,SAAS,EAAE;gBACT,WAAW,EAAE,OAAO,eAAe,CAAC;aACrC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,UAAU,CAAC,yBAAyB,CAAC,EAAE,8BAA8B;AACrE;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,uBAAuB,CA8CxB,CAAC"}
|
|
@@ -8,9 +8,10 @@ export const getActionPlugin = ({ sdk }) => {
|
|
|
8
8
|
const { actionKey, actionType, appKey } = options;
|
|
9
9
|
// Use the listActions function from the SDK to search for the specific action
|
|
10
10
|
const actionsResult = await sdk.listActions({ appKey });
|
|
11
|
-
// Search through all actions to find the matching one
|
|
11
|
+
// Search through all actions to find the matching one (by key or ID)
|
|
12
12
|
for (const action of actionsResult.data) {
|
|
13
|
-
if (action.key === actionKey
|
|
13
|
+
if ((action.key === actionKey || action.id === actionKey) &&
|
|
14
|
+
action.action_type === actionType) {
|
|
14
15
|
return { data: action };
|
|
15
16
|
}
|
|
16
17
|
}
|
|
@@ -3,6 +3,7 @@ import type { ApiClient } from "../../api";
|
|
|
3
3
|
import type { InputFieldItem, InfoFieldItem, FieldsetItem, RootFieldItem } from "../../types/domain";
|
|
4
4
|
import { ListInputFieldsSchema, type ListInputFieldsOptions } from "./schemas";
|
|
5
5
|
import type { GetAppPluginProvides } from "../getApp";
|
|
6
|
+
import type { GetActionPluginProvides } from "../getAction";
|
|
6
7
|
import type { GetVersionedImplementationId } from "../manifest/schemas";
|
|
7
8
|
export interface ListInputFieldsPluginProvides {
|
|
8
9
|
listInputFields: (options?: ListInputFieldsOptions) => Promise<{
|
|
@@ -22,7 +23,7 @@ export interface ListInputFieldsPluginProvides {
|
|
|
22
23
|
};
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
|
-
export declare const listInputFieldsPlugin: Plugin<GetSdkType<GetAppPluginProvides>, // requires getApp in SDK
|
|
26
|
+
export declare const listInputFieldsPlugin: Plugin<GetSdkType<GetAppPluginProvides & GetActionPluginProvides>, // requires getApp and getAction in SDK
|
|
26
27
|
{
|
|
27
28
|
api: ApiClient;
|
|
28
29
|
getVersionedImplementationId: GetVersionedImplementationId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listInputFields/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,aAAa,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,qBAAqB,EACrB,KAAK,sBAAsB,EAE5B,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAmKxE,MAAM,WAAW,6BAA6B;IAC5C,eAAe,EAAE,CAAC,OAAO,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC;QAC7D,IAAI,EAAE,aAAa,EAAE,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,aAAa,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAC9D,KAAK,IAAI,aAAa,CAAC,cAAc,GAAG,aAAa,GAAG,YAAY,CAAC,CAAC;KACvE,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,eAAe,EAAE;gBACf,WAAW,EAAE,OAAO,qBAAqB,CAAC;aAC3C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,qBAAqB,EAAE,MAAM,CACxC,UAAU,CAAC,oBAAoB,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/listInputFields/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,YAAY,EACZ,aAAa,EACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,qBAAqB,EACrB,KAAK,sBAAsB,EAE5B,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAmKxE,MAAM,WAAW,6BAA6B;IAC5C,eAAe,EAAE,CAAC,OAAO,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC;QAC7D,IAAI,EAAE,aAAa,EAAE,CAAC;QACtB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,aAAa,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAC9D,KAAK,IAAI,aAAa,CAAC,cAAc,GAAG,aAAa,GAAG,YAAY,CAAC,CAAC;KACvE,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,eAAe,EAAE;gBACf,WAAW,EAAE,OAAO,qBAAqB,CAAC;aAC3C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,qBAAqB,EAAE,MAAM,CACxC,UAAU,CAAC,oBAAoB,GAAG,uBAAuB,CAAC,EAAE,uCAAuC;AACnG;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,EAAE,2DAA2D;AAC9D,6BAA6B,CAyF9B,CAAC"}
|
|
@@ -142,7 +142,7 @@ function transformNeedsToFields(needs) {
|
|
|
142
142
|
}
|
|
143
143
|
return rootFields;
|
|
144
144
|
}
|
|
145
|
-
export const listInputFieldsPlugin = ({ context }) => {
|
|
145
|
+
export const listInputFieldsPlugin = ({ sdk, context }) => {
|
|
146
146
|
const listInputFields = createPaginatedFunction(async function listInputFieldsPage(options) {
|
|
147
147
|
// Note: This function ignores pageSize and cursor since it's not actually paginated internally
|
|
148
148
|
const { api, getVersionedImplementationId } = context;
|
|
@@ -153,10 +153,15 @@ export const listInputFieldsPlugin = ({ context }) => {
|
|
|
153
153
|
if (!selectedApi) {
|
|
154
154
|
throw new ZapierConfigurationError("No current_implementation_id found for app", { configType: "current_implementation_id" });
|
|
155
155
|
}
|
|
156
|
+
const { data: action } = await sdk.getAction({
|
|
157
|
+
appKey,
|
|
158
|
+
actionType,
|
|
159
|
+
actionKey,
|
|
160
|
+
});
|
|
156
161
|
// Build needs request
|
|
157
162
|
const needsRequest = {
|
|
158
163
|
selected_api: selectedApi,
|
|
159
|
-
action:
|
|
164
|
+
action: action.key,
|
|
160
165
|
type_of: actionType,
|
|
161
166
|
params: inputs || {},
|
|
162
167
|
};
|