@zapier/zapier-sdk 0.4.1 → 0.5.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.
- package/CHANGELOG.md +7 -0
- package/dist/api/auth.d.ts +9 -0
- package/dist/api/auth.d.ts.map +1 -0
- package/dist/api/auth.js +25 -0
- package/dist/api/client.d.ts +9 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +322 -0
- package/dist/api/debug.d.ts +13 -0
- package/dist/api/debug.d.ts.map +1 -0
- package/dist/api/debug.js +55 -0
- package/dist/api/index.d.ts +29 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +41 -0
- package/dist/api/polling.d.ts +16 -0
- package/dist/api/polling.d.ts.map +1 -0
- package/dist/api/polling.js +45 -0
- package/dist/api/schemas.d.ts +2473 -0
- package/dist/api/schemas.d.ts.map +1 -0
- package/dist/api/schemas.js +355 -0
- package/dist/api/types.d.ts +75 -0
- package/dist/api/types.d.ts.map +1 -0
- package/dist/api/types.js +11 -0
- package/dist/auth.d.ts +34 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +47 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +9 -0
- package/dist/index.cjs +2108 -1379
- package/dist/index.d.mts +2440 -620
- package/dist/index.d.ts +17 -892
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.mjs +2093 -1362
- package/dist/plugins/api/index.d.ts +14 -0
- package/dist/plugins/api/index.d.ts.map +1 -0
- package/dist/plugins/api/index.js +21 -0
- package/dist/plugins/apps/index.d.ts +11 -0
- package/dist/plugins/apps/index.d.ts.map +1 -0
- package/dist/plugins/apps/index.js +91 -0
- package/dist/plugins/apps/types.d.ts +30 -0
- package/dist/plugins/apps/types.d.ts.map +1 -0
- package/dist/plugins/apps/types.js +2 -0
- package/dist/plugins/fetch/index.d.ts +21 -0
- package/dist/plugins/fetch/index.d.ts.map +1 -0
- package/dist/plugins/fetch/index.js +20 -0
- package/dist/plugins/findFirstAuthentication/index.d.ts +20 -0
- package/dist/plugins/findFirstAuthentication/index.d.ts.map +1 -0
- package/dist/plugins/findFirstAuthentication/index.js +24 -0
- package/dist/plugins/findFirstAuthentication/index.test.d.ts +2 -0
- package/dist/plugins/findFirstAuthentication/index.test.d.ts.map +1 -0
- package/dist/plugins/findFirstAuthentication/index.test.js +171 -0
- package/dist/plugins/findFirstAuthentication/schemas.d.ts +29 -0
- package/dist/plugins/findFirstAuthentication/schemas.d.ts.map +1 -0
- package/dist/plugins/findFirstAuthentication/schemas.js +18 -0
- package/dist/plugins/findUniqueAuthentication/index.d.ts +20 -0
- package/dist/plugins/findUniqueAuthentication/index.d.ts.map +1 -0
- package/dist/plugins/findUniqueAuthentication/index.js +31 -0
- package/dist/plugins/findUniqueAuthentication/index.test.d.ts +2 -0
- package/dist/plugins/findUniqueAuthentication/index.test.d.ts.map +1 -0
- package/dist/plugins/findUniqueAuthentication/index.test.js +152 -0
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts +29 -0
- package/dist/plugins/findUniqueAuthentication/schemas.d.ts.map +1 -0
- package/dist/plugins/findUniqueAuthentication/schemas.js +18 -0
- package/dist/plugins/getAction/index.d.ts +23 -0
- package/dist/plugins/getAction/index.d.ts.map +1 -0
- package/dist/plugins/getAction/index.js +28 -0
- package/dist/plugins/getAction/index.test.d.ts +2 -0
- package/dist/plugins/getAction/index.test.d.ts.map +1 -0
- package/dist/plugins/getAction/index.test.js +186 -0
- package/dist/plugins/getAction/schemas.d.ts +23 -0
- package/dist/plugins/getAction/schemas.d.ts.map +1 -0
- package/dist/plugins/getAction/schemas.js +10 -0
- package/dist/plugins/getApp/index.d.ts +22 -0
- package/dist/plugins/getApp/index.d.ts.map +1 -0
- package/dist/plugins/getApp/index.js +39 -0
- package/dist/plugins/getApp/index.test.d.ts +2 -0
- package/dist/plugins/getApp/index.test.d.ts.map +1 -0
- package/dist/plugins/getApp/index.test.js +100 -0
- package/dist/plugins/getApp/schemas.d.ts +18 -0
- package/dist/plugins/getApp/schemas.d.ts.map +1 -0
- package/dist/plugins/getApp/schemas.js +10 -0
- package/dist/plugins/getAuthentication/index.d.ts +22 -0
- package/dist/plugins/getAuthentication/index.d.ts.map +1 -0
- package/dist/plugins/getAuthentication/index.js +41 -0
- package/dist/plugins/getAuthentication/index.test.d.ts +2 -0
- package/dist/plugins/getAuthentication/index.test.d.ts.map +1 -0
- package/dist/plugins/getAuthentication/index.test.js +205 -0
- package/dist/plugins/getAuthentication/schemas.d.ts +17 -0
- package/dist/plugins/getAuthentication/schemas.d.ts.map +1 -0
- package/dist/plugins/getAuthentication/schemas.js +11 -0
- package/dist/plugins/getProfile/index.d.ts +23 -0
- package/dist/plugins/getProfile/index.d.ts.map +1 -0
- package/dist/plugins/getProfile/index.js +29 -0
- package/dist/plugins/getProfile/schemas.d.ts +13 -0
- package/dist/plugins/getProfile/schemas.d.ts.map +1 -0
- package/dist/plugins/getProfile/schemas.js +5 -0
- package/dist/plugins/listActions/index.d.ts +28 -0
- package/dist/plugins/listActions/index.d.ts.map +1 -0
- package/dist/plugins/listActions/index.js +61 -0
- package/dist/plugins/listActions/index.test.d.ts +2 -0
- package/dist/plugins/listActions/index.test.d.ts.map +1 -0
- package/dist/plugins/listActions/index.test.js +467 -0
- package/dist/plugins/listActions/schemas.d.ts +29 -0
- package/dist/plugins/listActions/schemas.d.ts.map +1 -0
- package/dist/plugins/listActions/schemas.js +21 -0
- package/dist/plugins/listApps/index.d.ts +28 -0
- package/dist/plugins/listApps/index.d.ts.map +1 -0
- package/dist/plugins/listApps/index.js +62 -0
- package/dist/plugins/listApps/index.test.d.ts +2 -0
- package/dist/plugins/listApps/index.test.d.ts.map +1 -0
- package/dist/plugins/listApps/index.test.js +313 -0
- package/dist/plugins/listApps/schemas.d.ts +30 -0
- package/dist/plugins/listApps/schemas.d.ts.map +1 -0
- package/dist/plugins/listApps/schemas.js +23 -0
- package/dist/plugins/listAuthentications/index.d.ts +28 -0
- package/dist/plugins/listAuthentications/index.d.ts.map +1 -0
- package/dist/plugins/listAuthentications/index.js +77 -0
- package/dist/plugins/listAuthentications/index.test.d.ts +2 -0
- package/dist/plugins/listAuthentications/index.test.d.ts.map +1 -0
- package/dist/plugins/listAuthentications/index.test.js +564 -0
- package/dist/plugins/listAuthentications/schemas.d.ts +38 -0
- package/dist/plugins/listAuthentications/schemas.d.ts.map +1 -0
- package/dist/plugins/listAuthentications/schemas.js +28 -0
- package/dist/plugins/listInputFields/index.d.ts +28 -0
- package/dist/plugins/listInputFields/index.d.ts.map +1 -0
- package/dist/plugins/listInputFields/index.js +133 -0
- package/dist/plugins/listInputFields/index.test.d.ts +2 -0
- package/dist/plugins/listInputFields/index.test.d.ts.map +1 -0
- package/dist/plugins/listInputFields/index.test.js +325 -0
- package/dist/plugins/listInputFields/schemas.d.ts +38 -0
- package/dist/plugins/listInputFields/schemas.d.ts.map +1 -0
- package/dist/plugins/listInputFields/schemas.js +22 -0
- package/dist/plugins/registry/index.d.ts +11 -0
- package/dist/plugins/registry/index.d.ts.map +1 -0
- package/dist/plugins/registry/index.js +14 -0
- package/dist/plugins/request/index.d.ts +19 -0
- package/dist/plugins/request/index.d.ts.map +1 -0
- package/dist/plugins/request/index.js +62 -0
- package/dist/plugins/request/index.test.d.ts +2 -0
- package/dist/plugins/request/index.test.d.ts.map +1 -0
- package/dist/plugins/request/index.test.js +256 -0
- package/dist/plugins/request/schemas.d.ts +69 -0
- package/dist/plugins/request/schemas.d.ts.map +1 -0
- package/dist/plugins/request/schemas.js +42 -0
- package/dist/plugins/runAction/index.d.ts +28 -0
- package/dist/plugins/runAction/index.d.ts.map +1 -0
- package/dist/plugins/runAction/index.js +86 -0
- package/dist/plugins/runAction/index.test.d.ts +2 -0
- package/dist/plugins/runAction/index.test.d.ts.map +1 -0
- package/dist/plugins/runAction/index.test.js +320 -0
- package/dist/plugins/runAction/schemas.d.ts +37 -0
- package/dist/plugins/runAction/schemas.d.ts.map +1 -0
- package/dist/plugins/runAction/schemas.js +22 -0
- package/dist/resolvers/actionKey.d.ts +9 -0
- package/dist/resolvers/actionKey.d.ts.map +1 -0
- package/dist/resolvers/actionKey.js +19 -0
- package/dist/resolvers/actionType.d.ts +9 -0
- package/dist/resolvers/actionType.d.ts.map +1 -0
- package/dist/resolvers/actionType.js +22 -0
- package/dist/resolvers/appKey.d.ts +7 -0
- package/dist/resolvers/appKey.d.ts.map +1 -0
- package/dist/resolvers/appKey.js +5 -0
- package/dist/resolvers/authenticationId.d.ts +9 -0
- package/dist/resolvers/authenticationId.d.ts.map +1 -0
- package/dist/resolvers/authenticationId.js +33 -0
- package/dist/resolvers/index.d.ts +40 -0
- package/dist/resolvers/index.d.ts.map +1 -0
- package/dist/resolvers/index.js +91 -0
- package/dist/resolvers/inputs.d.ts +8 -0
- package/dist/resolvers/inputs.d.ts.map +1 -0
- package/dist/resolvers/inputs.js +14 -0
- package/dist/schemas/Action.d.ts +243 -0
- package/dist/schemas/Action.d.ts.map +1 -0
- package/dist/schemas/Action.js +34 -0
- package/dist/schemas/App.d.ts +26 -0
- package/dist/schemas/App.d.ts.map +1 -0
- package/dist/schemas/App.js +22 -0
- package/dist/schemas/Auth.d.ts +161 -0
- package/dist/schemas/Auth.d.ts.map +1 -0
- package/dist/schemas/Auth.js +41 -0
- package/dist/schemas/Field.d.ts +144 -0
- package/dist/schemas/Field.d.ts.map +1 -0
- package/dist/schemas/Field.js +105 -0
- package/dist/schemas/UserProfile.d.ts +163 -0
- package/dist/schemas/UserProfile.d.ts.map +1 -0
- package/dist/schemas/UserProfile.js +29 -0
- package/dist/sdk.d.ts +10 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/sdk.js +94 -0
- package/dist/sdk.test.d.ts +2 -0
- package/dist/sdk.test.d.ts.map +1 -0
- package/dist/sdk.test.js +135 -0
- package/dist/types/domain.d.ts +36 -0
- package/dist/types/domain.d.ts.map +1 -0
- package/dist/types/domain.js +1 -0
- package/dist/types/domain.test.d.ts +2 -0
- package/dist/types/domain.test.d.ts.map +1 -0
- package/dist/types/domain.test.js +39 -0
- package/dist/types/errors.d.ts +143 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +187 -0
- package/dist/types/events.d.ts +38 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +7 -0
- package/dist/types/functions.d.ts +26 -0
- package/dist/types/functions.d.ts.map +1 -0
- package/dist/types/functions.js +4 -0
- package/dist/types/plugin.d.ts +61 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/plugin.js +9 -0
- package/dist/types/properties.d.ts +22 -0
- package/dist/types/properties.d.ts.map +1 -0
- package/dist/types/properties.js +50 -0
- package/dist/types/sdk.d.ts +43 -0
- package/dist/types/sdk.d.ts.map +1 -0
- package/dist/types/sdk.js +4 -0
- package/dist/utils/array-utils.d.ts +31 -0
- package/dist/utils/array-utils.d.ts.map +1 -0
- package/dist/utils/array-utils.js +36 -0
- package/dist/utils/array-utils.test.d.ts +2 -0
- package/dist/utils/array-utils.test.d.ts.map +1 -0
- package/dist/utils/array-utils.test.js +107 -0
- package/dist/utils/domain-utils.d.ts +78 -0
- package/dist/utils/domain-utils.d.ts.map +1 -0
- package/dist/utils/domain-utils.js +218 -0
- package/dist/utils/domain-utils.test.d.ts +2 -0
- package/dist/utils/domain-utils.test.d.ts.map +1 -0
- package/dist/utils/domain-utils.test.js +192 -0
- package/dist/utils/function-utils.d.ts +45 -0
- package/dist/utils/function-utils.d.ts.map +1 -0
- package/dist/utils/function-utils.js +158 -0
- package/dist/utils/function-utils.test.d.ts +2 -0
- package/dist/utils/function-utils.test.d.ts.map +1 -0
- package/dist/utils/function-utils.test.js +110 -0
- package/dist/utils/pagination-utils.d.ts +37 -0
- package/dist/utils/pagination-utils.d.ts.map +1 -0
- package/dist/utils/pagination-utils.js +165 -0
- package/dist/utils/pagination-utils.test.d.ts +17 -0
- package/dist/utils/pagination-utils.test.d.ts.map +1 -0
- package/dist/utils/pagination-utils.test.js +461 -0
- package/dist/utils/schema-utils.d.ts +45 -0
- package/dist/utils/schema-utils.d.ts.map +1 -0
- package/dist/utils/schema-utils.js +65 -0
- package/dist/utils/validation.d.ts +4 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +30 -0
- package/dist/utils/validation.test.d.ts +2 -0
- package/dist/utils/validation.test.d.ts.map +1 -0
- package/dist/utils/validation.test.js +43 -0
- package/package.json +12 -3
- package/src/api/client.ts +394 -171
- package/src/api/debug.ts +10 -1
- package/src/api/index.ts +0 -2
- package/src/api/polling.ts +28 -7
- package/src/api/schemas.ts +387 -0
- package/src/api/types.ts +72 -136
- package/src/constants.ts +10 -0
- package/src/index.ts +40 -19
- package/src/plugins/api/index.ts +47 -0
- package/src/plugins/apps/index.ts +25 -19
- package/src/plugins/apps/types.ts +7 -11
- package/src/plugins/fetch/index.ts +48 -40
- package/src/plugins/findFirstAuthentication/index.test.ts +206 -0
- package/src/plugins/findFirstAuthentication/index.ts +55 -0
- package/src/plugins/findFirstAuthentication/schemas.ts +41 -0
- package/src/plugins/findUniqueAuthentication/index.test.ts +197 -0
- package/src/plugins/findUniqueAuthentication/index.ts +72 -0
- package/src/plugins/findUniqueAuthentication/schemas.ts +42 -0
- package/src/plugins/getAction/index.test.ts +239 -0
- package/src/plugins/getAction/index.ts +57 -0
- package/src/plugins/getAction/schemas.ts +33 -0
- package/src/plugins/getApp/index.test.ts +127 -0
- package/src/plugins/getApp/index.ts +66 -0
- package/src/plugins/getApp/schemas.ts +38 -0
- package/src/plugins/getAuthentication/index.test.ts +284 -0
- package/src/plugins/getAuthentication/index.ts +86 -0
- package/src/plugins/getAuthentication/schemas.ts +31 -0
- package/src/plugins/getProfile/index.ts +55 -0
- package/src/plugins/getProfile/schemas.ts +26 -0
- package/src/plugins/listActions/index.test.ts +582 -0
- package/src/plugins/listActions/index.ts +115 -0
- package/src/plugins/listActions/schemas.ts +54 -0
- package/src/plugins/listApps/index.test.ts +357 -0
- package/src/plugins/listApps/index.ts +121 -0
- package/src/plugins/listApps/schemas.ts +49 -0
- package/src/plugins/listAuthentications/index.test.ts +709 -0
- package/src/plugins/listAuthentications/index.ts +136 -0
- package/src/plugins/listAuthentications/schemas.ts +60 -0
- package/src/plugins/listInputFields/index.test.ts +408 -0
- package/src/plugins/listInputFields/index.ts +204 -0
- package/src/plugins/listInputFields/schemas.ts +56 -0
- package/src/plugins/registry/index.ts +30 -0
- package/src/plugins/request/index.test.ts +329 -0
- package/src/plugins/request/index.ts +103 -0
- package/src/{functions → plugins}/request/schemas.ts +20 -9
- package/src/plugins/runAction/index.test.ts +387 -0
- package/src/plugins/runAction/index.ts +176 -0
- package/src/plugins/runAction/schemas.ts +53 -0
- package/src/resolvers/actionKey.ts +6 -4
- package/src/resolvers/actionType.ts +7 -2
- package/src/resolvers/appKey.ts +1 -1
- package/src/resolvers/authenticationId.ts +12 -3
- package/src/resolvers/inputs.ts +3 -1
- package/src/schemas/Action.ts +18 -12
- package/src/schemas/App.ts +11 -19
- package/src/schemas/Auth.ts +18 -13
- package/src/schemas/Field.ts +106 -11
- package/src/schemas/UserProfile.ts +43 -0
- package/src/sdk.test.ts +212 -0
- package/src/sdk.ts +132 -102
- package/src/types/domain.test.ts +50 -0
- package/src/types/domain.ts +43 -75
- package/src/types/errors.ts +275 -0
- package/src/types/functions.ts +27 -0
- package/src/types/optional-zapier-sdk-cli-login.d.ts +37 -0
- package/src/types/plugin.ts +105 -0
- package/src/types/properties.ts +4 -3
- package/src/types/sdk.ts +70 -48
- package/src/utils/array-utils.test.ts +131 -0
- package/src/utils/array-utils.ts +41 -0
- package/src/utils/domain-utils.test.ts +239 -0
- package/src/utils/domain-utils.ts +283 -0
- package/src/utils/function-utils.test.ts +141 -0
- package/src/utils/function-utils.ts +245 -0
- package/src/utils/pagination-utils.test.ts +620 -0
- package/src/utils/pagination-utils.ts +242 -0
- package/src/utils/validation.test.ts +50 -0
- package/src/utils/validation.ts +44 -0
- package/tsconfig.build.json +16 -2
- package/tsconfig.json +3 -1
- package/tsconfig.tsbuildinfo +1 -0
- package/tsup.config.ts +2 -0
- package/src/functions/bundleCode/index.ts +0 -78
- package/src/functions/bundleCode/info.ts +0 -9
- package/src/functions/bundleCode/schemas.ts +0 -30
- package/src/functions/findFirstAuthentication/index.ts +0 -24
- package/src/functions/findFirstAuthentication/info.ts +0 -9
- package/src/functions/findFirstAuthentication/schemas.ts +0 -50
- package/src/functions/findUniqueAuthentication/index.ts +0 -35
- package/src/functions/findUniqueAuthentication/info.ts +0 -9
- package/src/functions/findUniqueAuthentication/schemas.ts +0 -50
- package/src/functions/generateTypes/index.ts +0 -363
- package/src/functions/generateTypes/info.ts +0 -9
- package/src/functions/generateTypes/schemas.ts +0 -31
- package/src/functions/getAction/index.ts +0 -33
- package/src/functions/getAction/info.ts +0 -9
- package/src/functions/getAction/schemas.ts +0 -25
- package/src/functions/getApp/index.ts +0 -41
- package/src/functions/getApp/info.ts +0 -9
- package/src/functions/getApp/schemas.ts +0 -20
- package/src/functions/getAuthentication/index.ts +0 -50
- package/src/functions/getAuthentication/info.ts +0 -9
- package/src/functions/getAuthentication/schemas.ts +0 -29
- package/src/functions/listActions/index.ts +0 -149
- package/src/functions/listActions/info.ts +0 -9
- package/src/functions/listActions/schemas.ts +0 -30
- package/src/functions/listApps/index.ts +0 -60
- package/src/functions/listApps/info.ts +0 -9
- package/src/functions/listApps/schemas.ts +0 -32
- package/src/functions/listAuthentications/index.ts +0 -162
- package/src/functions/listAuthentications/info.ts +0 -9
- package/src/functions/listAuthentications/schemas.ts +0 -50
- package/src/functions/listFields/index.ts +0 -86
- package/src/functions/listFields/info.ts +0 -9
- package/src/functions/listFields/schemas.ts +0 -36
- package/src/functions/request/index.ts +0 -150
- package/src/functions/request/info.ts +0 -11
- package/src/functions/runAction/index.ts +0 -127
- package/src/functions/runAction/info.ts +0 -9
- package/src/functions/runAction/schemas.ts +0 -34
- package/src/plugins/apps/info.ts +0 -12
- package/src/plugins/fetch/types.ts +0 -2
- /package/src/{schema-utils.ts → utils/schema-utils.ts} +0 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import type { Plugin, GetSdkType } from "../../types/plugin";
|
|
2
|
+
import type { ApiClient } from "../../api";
|
|
3
|
+
import {
|
|
4
|
+
RunActionSchema,
|
|
5
|
+
type RunActionOptions,
|
|
6
|
+
type RunActionPage,
|
|
7
|
+
} from "./schemas";
|
|
8
|
+
import {
|
|
9
|
+
ZapierValidationError,
|
|
10
|
+
ZapierConfigurationError,
|
|
11
|
+
ZapierActionError,
|
|
12
|
+
} from "../../types/errors";
|
|
13
|
+
import { createPaginatedFunction } from "../../utils/function-utils";
|
|
14
|
+
import type { GetActionPluginProvides } from "../getAction";
|
|
15
|
+
import type { GetAppPluginProvides } from "../getApp";
|
|
16
|
+
|
|
17
|
+
export interface RunActionPluginProvides {
|
|
18
|
+
runAction: (options?: RunActionOptions) => Promise<{ data: any[] }> &
|
|
19
|
+
AsyncIterable<{ data: any[]; nextCursor?: string }> & {
|
|
20
|
+
items(): AsyncIterable<any>;
|
|
21
|
+
};
|
|
22
|
+
context: {
|
|
23
|
+
meta: {
|
|
24
|
+
runAction: {
|
|
25
|
+
inputSchema: typeof RunActionSchema;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface ExecuteActionOptions {
|
|
32
|
+
api: ApiClient;
|
|
33
|
+
sdk: GetSdkType<GetActionPluginProvides & GetAppPluginProvides>;
|
|
34
|
+
appKey: string;
|
|
35
|
+
actionKey: string;
|
|
36
|
+
actionType: string;
|
|
37
|
+
executionOptions: { inputs: Record<string, unknown> };
|
|
38
|
+
authenticationId?: number | null;
|
|
39
|
+
options: RunActionOptions;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function executeAction(actionOptions: ExecuteActionOptions): Promise<{
|
|
43
|
+
results: unknown[];
|
|
44
|
+
errors?: Array<{ detail?: string; title?: string }>;
|
|
45
|
+
}> {
|
|
46
|
+
const {
|
|
47
|
+
api,
|
|
48
|
+
sdk,
|
|
49
|
+
appKey,
|
|
50
|
+
actionKey,
|
|
51
|
+
actionType,
|
|
52
|
+
executionOptions,
|
|
53
|
+
authenticationId,
|
|
54
|
+
} = actionOptions;
|
|
55
|
+
|
|
56
|
+
// Use the getApp plugin to get the current implementation ID
|
|
57
|
+
const appData = await sdk.getApp({ appKey });
|
|
58
|
+
const selectedApi = appData.data.current_implementation_id;
|
|
59
|
+
|
|
60
|
+
if (!selectedApi) {
|
|
61
|
+
throw new ZapierConfigurationError(
|
|
62
|
+
"No current_implementation_id found for app",
|
|
63
|
+
{ configType: "current_implementation_id" },
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Step 1: POST to /actions/v1/runs to start execution
|
|
68
|
+
const runRequestData: {
|
|
69
|
+
selected_api: string;
|
|
70
|
+
action_key: string;
|
|
71
|
+
action_type: string;
|
|
72
|
+
inputs: Record<string, unknown>;
|
|
73
|
+
authentication_id?: number | null;
|
|
74
|
+
} = {
|
|
75
|
+
selected_api: selectedApi,
|
|
76
|
+
action_key: actionKey,
|
|
77
|
+
action_type: actionType,
|
|
78
|
+
inputs: executionOptions.inputs || {},
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Only include authentication_id if it's provided
|
|
82
|
+
if (authenticationId !== null && authenticationId !== undefined) {
|
|
83
|
+
runRequestData.authentication_id = authenticationId;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const runRequest = {
|
|
87
|
+
data: runRequestData,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const runData = await api.post("/api/actions/v1/runs", runRequest);
|
|
91
|
+
const runId = runData.data.id;
|
|
92
|
+
|
|
93
|
+
// Step 2: Poll GET /actions/v1/runs/{run_id} for results
|
|
94
|
+
return await api.poll(`/api/actions/v1/runs/${runId}`, {
|
|
95
|
+
successStatus: 200,
|
|
96
|
+
pendingStatus: 202,
|
|
97
|
+
resultExtractor: (result: { data: unknown }) => result.data,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export const runActionPlugin: Plugin<
|
|
102
|
+
GetSdkType<GetActionPluginProvides & GetAppPluginProvides>, // requires getAction and getApp in SDK
|
|
103
|
+
{ api: ApiClient }, // requires api in context
|
|
104
|
+
RunActionPluginProvides
|
|
105
|
+
> = ({ sdk, context }) => {
|
|
106
|
+
const runAction = createPaginatedFunction(async function runActionPage(
|
|
107
|
+
options: RunActionOptions & { cursor?: string } & { pageSize: number },
|
|
108
|
+
): Promise<RunActionPage> {
|
|
109
|
+
const { api } = context;
|
|
110
|
+
const {
|
|
111
|
+
appKey,
|
|
112
|
+
actionKey,
|
|
113
|
+
actionType,
|
|
114
|
+
authenticationId,
|
|
115
|
+
inputs = {},
|
|
116
|
+
} = options;
|
|
117
|
+
|
|
118
|
+
// Validate that the action exists using the getAction plugin
|
|
119
|
+
const actionData = await sdk.getAction({
|
|
120
|
+
appKey: appKey,
|
|
121
|
+
actionKey: actionKey,
|
|
122
|
+
actionType: actionType,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Validate action type matches
|
|
126
|
+
if (actionData.data.action_type !== actionType) {
|
|
127
|
+
throw new ZapierValidationError(
|
|
128
|
+
`Action type mismatch: expected ${actionType}, got ${actionData.data.action_type}`,
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Execute the action using the Actions API (supports all action types)
|
|
133
|
+
const result = await executeAction({
|
|
134
|
+
api,
|
|
135
|
+
sdk,
|
|
136
|
+
appKey,
|
|
137
|
+
actionKey,
|
|
138
|
+
actionType,
|
|
139
|
+
executionOptions: { inputs },
|
|
140
|
+
authenticationId,
|
|
141
|
+
options,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Check for errors in the result and throw if present
|
|
145
|
+
if (result.errors && result.errors.length > 0) {
|
|
146
|
+
const errorMessage = result.errors
|
|
147
|
+
.map(
|
|
148
|
+
(error: { detail?: string; title?: string }) =>
|
|
149
|
+
error.detail || error.title || "Unknown error",
|
|
150
|
+
)
|
|
151
|
+
.join("; ");
|
|
152
|
+
|
|
153
|
+
throw new ZapierActionError(`Action execution failed: ${errorMessage}`, {
|
|
154
|
+
appKey,
|
|
155
|
+
actionKey,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Return the results array wrapped in data with empty nextCursor (no pagination for action execution)
|
|
160
|
+
return {
|
|
161
|
+
data: result.results || [],
|
|
162
|
+
nextCursor: undefined, // No pagination implemented yet
|
|
163
|
+
};
|
|
164
|
+
}, RunActionSchema);
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
runAction,
|
|
168
|
+
context: {
|
|
169
|
+
meta: {
|
|
170
|
+
runAction: {
|
|
171
|
+
inputSchema: RunActionSchema,
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
AppKeyPropertySchema,
|
|
4
|
+
ActionTypePropertySchema,
|
|
5
|
+
ActionKeyPropertySchema,
|
|
6
|
+
AuthenticationIdPropertySchema,
|
|
7
|
+
InputsPropertySchema,
|
|
8
|
+
} from "../../types/properties";
|
|
9
|
+
import type { PaginatedSdkFunction } from "../../types/functions";
|
|
10
|
+
|
|
11
|
+
// Pure Zod schema - no resolver metadata!
|
|
12
|
+
export const RunActionSchema = z
|
|
13
|
+
.object({
|
|
14
|
+
appKey: AppKeyPropertySchema,
|
|
15
|
+
actionType: ActionTypePropertySchema,
|
|
16
|
+
actionKey: ActionKeyPropertySchema,
|
|
17
|
+
authenticationId: AuthenticationIdPropertySchema.nullable().optional(),
|
|
18
|
+
inputs: InputsPropertySchema.optional().describe(
|
|
19
|
+
"Input parameters for the action",
|
|
20
|
+
),
|
|
21
|
+
pageSize: z
|
|
22
|
+
.number()
|
|
23
|
+
.min(1)
|
|
24
|
+
.optional()
|
|
25
|
+
.describe("Number of results per page"),
|
|
26
|
+
maxItems: z
|
|
27
|
+
.number()
|
|
28
|
+
.min(1)
|
|
29
|
+
.optional()
|
|
30
|
+
.describe("Maximum total items to return across all pages"),
|
|
31
|
+
})
|
|
32
|
+
.describe("Execute an action with the given inputs");
|
|
33
|
+
|
|
34
|
+
// Type inferred from schema
|
|
35
|
+
export type RunActionOptions = z.infer<typeof RunActionSchema>;
|
|
36
|
+
|
|
37
|
+
// Page result structure (for consistency with other paginated functions)
|
|
38
|
+
export interface RunActionPage {
|
|
39
|
+
data: any[];
|
|
40
|
+
nextCursor?: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Error union for this function
|
|
44
|
+
export type RunActionError =
|
|
45
|
+
| import("../../types/errors").ZapierActionError
|
|
46
|
+
| import("../../types/errors").ZapierValidationError
|
|
47
|
+
| import("../../types/errors").ZapierConfigurationError
|
|
48
|
+
| import("../../types/errors").ZapierUnknownError;
|
|
49
|
+
|
|
50
|
+
// SDK function interface - ready to be mixed into main SDK interface
|
|
51
|
+
export interface RunActionSdkFunction {
|
|
52
|
+
runAction: PaginatedSdkFunction<RunActionOptions, any>;
|
|
53
|
+
}
|
|
@@ -14,9 +14,11 @@ export const actionKeyResolver: ActionKeyResolver = {
|
|
|
14
14
|
type: "dynamic",
|
|
15
15
|
depends: ["appKey", "actionType"] as const,
|
|
16
16
|
fetch: async (sdk: ZapierSdk, resolvedParams: Record<string, any>) => {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const actionsResponse = await sdk.listActions({
|
|
18
|
+
appKey: resolvedParams.appKey,
|
|
19
|
+
});
|
|
20
|
+
return actionsResponse.data.filter(
|
|
21
|
+
(action: any) => action.action_type === resolvedParams.actionType,
|
|
20
22
|
);
|
|
21
23
|
},
|
|
22
24
|
prompt: (actions: any[]) => ({
|
|
@@ -24,7 +26,7 @@ export const actionKeyResolver: ActionKeyResolver = {
|
|
|
24
26
|
name: "actionKey",
|
|
25
27
|
message: "Select action:",
|
|
26
28
|
choices: actions.map((action) => ({
|
|
27
|
-
name: `${action.name || action.key} - ${
|
|
29
|
+
name: `${action.title || action.name || action.key} - ${
|
|
28
30
|
action.description || "No description"
|
|
29
31
|
}`,
|
|
30
32
|
value: action.key,
|
|
@@ -14,8 +14,13 @@ export const actionTypeResolver: ActionTypeResolver = {
|
|
|
14
14
|
type: "dynamic",
|
|
15
15
|
depends: ["appKey"] as const,
|
|
16
16
|
fetch: async (sdk: ZapierSdk, resolvedParams: Record<string, any>) => {
|
|
17
|
-
const
|
|
18
|
-
|
|
17
|
+
const actionsResponse = await sdk.listActions({
|
|
18
|
+
appKey: resolvedParams.appKey,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const types = [
|
|
22
|
+
...new Set(actionsResponse.data.map((action) => action.action_type)),
|
|
23
|
+
];
|
|
19
24
|
return types.map((type) => ({ key: type, name: type }));
|
|
20
25
|
},
|
|
21
26
|
prompt: (types: any[]) => ({
|
package/src/resolvers/appKey.ts
CHANGED
|
@@ -14,11 +14,20 @@ export const authenticationIdResolver: AuthenticationIdResolver = {
|
|
|
14
14
|
type: "dynamic",
|
|
15
15
|
depends: ["appKey"] as const,
|
|
16
16
|
fetch: async (sdk: ZapierSdk, resolvedParams: Record<string, any>) => {
|
|
17
|
-
|
|
18
|
-
return await sdk.listAuthentications({
|
|
17
|
+
const myAuths = await sdk.listAuthentications({
|
|
19
18
|
appKey: resolvedParams.appKey,
|
|
20
|
-
|
|
19
|
+
maxItems: 1000,
|
|
20
|
+
owner: "me",
|
|
21
21
|
});
|
|
22
|
+
const allAuths = await sdk.listAuthentications({
|
|
23
|
+
appKey: resolvedParams.appKey,
|
|
24
|
+
maxItems: 1000,
|
|
25
|
+
});
|
|
26
|
+
// Filter out myAuths from allAuths
|
|
27
|
+
const otherAuths = allAuths.data.filter(
|
|
28
|
+
(auth) => !myAuths.data.some((myAuth) => myAuth.id === auth.id),
|
|
29
|
+
);
|
|
30
|
+
return [...myAuths.data, ...otherAuths];
|
|
22
31
|
},
|
|
23
32
|
prompt: (auths: any[], params: Record<string, any>) => ({
|
|
24
33
|
type: "list",
|
package/src/resolvers/inputs.ts
CHANGED
|
@@ -13,11 +13,13 @@ export const inputsResolver: InputsResolver = {
|
|
|
13
13
|
type: "fields",
|
|
14
14
|
depends: ["appKey", "actionKey", "actionType", "authenticationId"] as const,
|
|
15
15
|
fetch: async (sdk: ZapierSdk, resolvedParams: Record<string, any>) => {
|
|
16
|
-
|
|
16
|
+
const fieldsResponse = await sdk.listInputFields({
|
|
17
17
|
appKey: resolvedParams.appKey,
|
|
18
18
|
actionKey: resolvedParams.actionKey,
|
|
19
19
|
actionType: resolvedParams.actionType,
|
|
20
20
|
authenticationId: resolvedParams.authenticationId,
|
|
21
|
+
inputs: resolvedParams.inputs, // Pass along currently resolved inputs
|
|
21
22
|
});
|
|
23
|
+
return fieldsResponse.data;
|
|
22
24
|
},
|
|
23
25
|
};
|
package/src/schemas/Action.ts
CHANGED
|
@@ -1,31 +1,37 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { withFormatter } from "../schema-utils";
|
|
2
|
+
import { withFormatter } from "../utils/schema-utils";
|
|
3
|
+
import { ActionSchema } from "../api/schemas";
|
|
3
4
|
|
|
4
5
|
// ============================================================================
|
|
5
|
-
// Action
|
|
6
|
+
// Action Item Schema (extends API schema with computed fields and formatting)
|
|
6
7
|
// ============================================================================
|
|
7
8
|
|
|
8
9
|
export const ActionItemSchema = withFormatter(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
description: z.string().optional(),
|
|
10
|
+
ActionSchema.omit({ type: true, name: true }).extend({
|
|
11
|
+
app_key: z.string(), // Mapped from selected_api
|
|
12
|
+
action_type: ActionSchema.shape.type, // Mapped from original 'type' field
|
|
13
|
+
title: z.string(), // Mapped from original 'name' field
|
|
14
|
+
type: z.literal("action"), // Fixed type identifier
|
|
15
15
|
}),
|
|
16
16
|
{
|
|
17
17
|
format: (item) => {
|
|
18
18
|
const details = [];
|
|
19
|
-
details.push({
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
details.push({
|
|
20
|
+
text: `Type: ${item.action_type}`,
|
|
21
|
+
style: "accent" as const,
|
|
22
|
+
});
|
|
23
|
+
if (item.app_key) {
|
|
24
|
+
details.push({
|
|
25
|
+
text: `App: ${item.app_key}`,
|
|
26
|
+
style: "normal" as const,
|
|
27
|
+
});
|
|
22
28
|
}
|
|
23
29
|
if (item.description) {
|
|
24
30
|
details.push({ text: item.description, style: "dim" as const });
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
return {
|
|
28
|
-
title: item.name || item.key,
|
|
34
|
+
title: item.title || item.name || item.key,
|
|
29
35
|
subtitle: `(${item.key})`,
|
|
30
36
|
details,
|
|
31
37
|
};
|
package/src/schemas/App.ts
CHANGED
|
@@ -1,36 +1,28 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { withFormatter } from "../schema-utils";
|
|
2
|
+
import { withFormatter } from "../utils/schema-utils";
|
|
3
3
|
|
|
4
|
-
export { FormattedItem, FormatMetadata } from "../schema-utils";
|
|
4
|
+
export { FormattedItem, FormatMetadata } from "../utils/schema-utils";
|
|
5
5
|
|
|
6
6
|
// ============================================================================
|
|
7
|
-
// App
|
|
7
|
+
// App Item Schema (extends API schema with computed fields and formatting)
|
|
8
8
|
// ============================================================================
|
|
9
9
|
|
|
10
10
|
export const AppItemSchema = withFormatter(
|
|
11
11
|
z.object({
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
// Essential properties only
|
|
13
|
+
title: z.string(), // Mapped from name
|
|
14
|
+
key: z.string(), // Mapped from selected_api
|
|
15
|
+
current_implementation_id: z.string(), // From id, keeps the full version
|
|
16
|
+
version: z.string().optional(), // Extracted from implementation ID
|
|
14
17
|
description: z.string().optional(),
|
|
15
|
-
|
|
18
|
+
slug: z.string().optional(),
|
|
16
19
|
}),
|
|
17
20
|
{
|
|
18
21
|
format: (item) => {
|
|
19
|
-
const details = [];
|
|
20
|
-
if (item.description) {
|
|
21
|
-
details.push({ text: item.description, style: "dim" as const });
|
|
22
|
-
}
|
|
23
|
-
if (item.category) {
|
|
24
|
-
details.push({
|
|
25
|
-
text: `Category: ${item.category}`,
|
|
26
|
-
style: "accent" as const,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
22
|
return {
|
|
31
|
-
title: item.
|
|
23
|
+
title: item.title,
|
|
32
24
|
subtitle: `(${item.key})`,
|
|
33
|
-
details,
|
|
25
|
+
details: [],
|
|
34
26
|
};
|
|
35
27
|
},
|
|
36
28
|
},
|
package/src/schemas/Auth.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { withFormatter } from "../schema-utils";
|
|
2
|
+
import { withFormatter } from "../utils/schema-utils";
|
|
3
|
+
import { AuthenticationSchema } from "../api/schemas";
|
|
3
4
|
|
|
4
5
|
// ============================================================================
|
|
5
|
-
//
|
|
6
|
+
// Authentication Item Schema (extends API schema with computed fields and formatting)
|
|
6
7
|
// ============================================================================
|
|
7
8
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
export const AuthenticationItemSchema = withFormatter(
|
|
10
|
+
AuthenticationSchema.omit({ selected_api: true, customuser_id: true }).extend(
|
|
11
|
+
{
|
|
12
|
+
implementation_id: z.string().optional(), // Renamed from selected_api
|
|
13
|
+
is_expired: z.string().optional(), // Mapped from is_stale
|
|
14
|
+
expired_at: z.string().nullable().optional(), // Mapped from marked_stale_at
|
|
15
|
+
app_key: z.string().optional(), // App key from implementations endpoint
|
|
16
|
+
version: z.string().optional(), // Version extracted from implementation_id
|
|
17
|
+
user_id: z.number().optional(),
|
|
18
|
+
},
|
|
19
|
+
),
|
|
18
20
|
{
|
|
19
21
|
format: (item) => {
|
|
20
22
|
const details = [];
|
|
@@ -27,7 +29,7 @@ export const AuthItemSchema = withFormatter(
|
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
details.push({
|
|
30
|
-
text: `Account: ${item.account_id
|
|
32
|
+
text: `Account: ${item.account_id} | Private: ${item.is_private} | Shared: ${item.shared_with_all}`,
|
|
31
33
|
style: "dim" as const,
|
|
32
34
|
});
|
|
33
35
|
|
|
@@ -47,6 +49,9 @@ export const AuthItemSchema = withFormatter(
|
|
|
47
49
|
},
|
|
48
50
|
);
|
|
49
51
|
|
|
52
|
+
// Legacy alias for backward compatibility
|
|
53
|
+
export const AuthItemSchema = AuthenticationItemSchema;
|
|
54
|
+
|
|
50
55
|
// ============================================================================
|
|
51
56
|
// Type Exports
|
|
52
57
|
// ============================================================================
|
package/src/schemas/Field.ts
CHANGED
|
@@ -1,25 +1,117 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { withFormatter } from "../schema-utils";
|
|
2
|
+
import { withFormatter } from "../utils/schema-utils";
|
|
3
|
+
import { NeedSchema } from "../api/schemas";
|
|
3
4
|
|
|
4
5
|
// ============================================================================
|
|
5
|
-
// Field
|
|
6
|
+
// Input Field Item Schema (extends API Need schema with computed fields and formatting)
|
|
6
7
|
// ============================================================================
|
|
7
8
|
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export const InputFieldItemSchema = withFormatter(
|
|
10
|
+
NeedSchema.omit({
|
|
11
|
+
depends_on: true,
|
|
12
|
+
placeholder: true,
|
|
13
|
+
required: true,
|
|
14
|
+
format: true,
|
|
15
|
+
}).extend({
|
|
16
|
+
id: z.string(), // Mapped from 'key'
|
|
17
|
+
default_value: z.string(), // Mapped from 'default' with fallback to ""
|
|
18
|
+
depends_on: z.array(z.string()), // Override: mapped from 'depends_on' with fallback to []
|
|
19
|
+
description: z.string(), // Mapped from 'help_text' with fallback to ""
|
|
20
|
+
invalidates_input_fields: z.boolean(), // Mapped from 'alters_custom_fields' with fallback to false
|
|
21
|
+
is_required: z.boolean(), // Override: mapped from 'required' with fallback to false
|
|
22
|
+
placeholder: z.string(), // Override: mapped from 'placeholder' with fallback to ""
|
|
23
|
+
title: z.string(), // Mapped from 'label' with fallback to ""
|
|
24
|
+
value_type: z.string(), // Computed from InputFieldType enum
|
|
25
|
+
format: z.string().optional(), // Override: computed from InputFieldFormat enum (optional)
|
|
26
|
+
items: z.object({ type: z.string() }).optional(), // Computed from ItemsType enum (optional, only for arrays)
|
|
13
27
|
}),
|
|
14
28
|
{
|
|
15
29
|
format: (item) => {
|
|
16
30
|
const details = [];
|
|
17
|
-
|
|
18
|
-
|
|
31
|
+
|
|
32
|
+
// Type and required status
|
|
33
|
+
const typeInfo = [
|
|
34
|
+
item.type && `Type: ${item.type}`,
|
|
35
|
+
`Required: ${item.required ? "Yes" : "No"}`,
|
|
36
|
+
]
|
|
37
|
+
.filter(Boolean)
|
|
38
|
+
.join(" | ");
|
|
39
|
+
if (typeInfo) {
|
|
40
|
+
details.push({ text: typeInfo, style: "dim" as const });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Help text
|
|
44
|
+
if (item.helpText) {
|
|
45
|
+
details.push({ text: item.helpText, style: "normal" as const });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Default value
|
|
49
|
+
if (item.default !== undefined) {
|
|
50
|
+
details.push({
|
|
51
|
+
text: `Default: ${item.default}`,
|
|
52
|
+
style: "accent" as const,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Placeholder
|
|
57
|
+
if (item.placeholder) {
|
|
58
|
+
details.push({
|
|
59
|
+
text: `Placeholder: ${item.placeholder}`,
|
|
60
|
+
style: "dim" as const,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Choices
|
|
65
|
+
if (item.choices && item.choices.length > 0) {
|
|
66
|
+
const choiceText =
|
|
67
|
+
item.choices.length <= 3
|
|
68
|
+
? `Choices: ${item.choices.map((c: any) => c.label || c.value).join(", ")}`
|
|
69
|
+
: `Choices: ${item.choices
|
|
70
|
+
.slice(0, 3)
|
|
71
|
+
.map((c: any) => c.label || c.value)
|
|
72
|
+
.join(", ")} (+${item.choices.length - 3} more)`;
|
|
73
|
+
details.push({ text: choiceText, style: "accent" as const });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Dependencies
|
|
77
|
+
if (item.dependsOn && item.dependsOn.length > 0) {
|
|
78
|
+
details.push({
|
|
79
|
+
text: `Depends on: ${item.dependsOn.join(", ")}`,
|
|
80
|
+
style: "warning" as const,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Format information
|
|
85
|
+
if (item.format) {
|
|
86
|
+
details.push({ text: `Format: ${item.format}`, style: "dim" as const });
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Input format
|
|
90
|
+
if (item.inputFormat && item.inputFormat.length > 0) {
|
|
91
|
+
details.push({
|
|
92
|
+
text: `Input formats: ${item.inputFormat.join(", ")}`,
|
|
93
|
+
style: "dim" as const,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Special field flags
|
|
98
|
+
const flags = [];
|
|
99
|
+
if (item.computed) flags.push("computed");
|
|
100
|
+
if (item.customField) flags.push("custom");
|
|
101
|
+
if (flags.length > 0) {
|
|
102
|
+
details.push({
|
|
103
|
+
text: `Flags: ${flags.join(", ")}`,
|
|
104
|
+
style: "success" as const,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Backwards compatibility: show description if no helpText
|
|
109
|
+
if (item.description && !item.helpText) {
|
|
110
|
+
details.push({ text: item.description, style: "normal" as const });
|
|
19
111
|
}
|
|
20
112
|
|
|
21
113
|
return {
|
|
22
|
-
title: item.name || item.key,
|
|
114
|
+
title: item.label || item.name || item.key,
|
|
23
115
|
subtitle: `(${item.key})`,
|
|
24
116
|
details,
|
|
25
117
|
};
|
|
@@ -31,4 +123,7 @@ export const FieldItemSchema = withFormatter(
|
|
|
31
123
|
// Type Exports
|
|
32
124
|
// ============================================================================
|
|
33
125
|
|
|
34
|
-
export type
|
|
126
|
+
export type InputFieldItem = z.infer<typeof InputFieldItemSchema>;
|
|
127
|
+
|
|
128
|
+
// Legacy alias for backward compatibility
|
|
129
|
+
export type FieldItem = InputFieldItem;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { withFormatter } from "../utils/schema-utils";
|
|
3
|
+
import { UserProfileSchema } from "../api/schemas";
|
|
4
|
+
|
|
5
|
+
export { FormattedItem, FormatMetadata } from "../utils/schema-utils";
|
|
6
|
+
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// User Profile Item Schema (extends API schema with computed fields and formatting)
|
|
9
|
+
// ============================================================================
|
|
10
|
+
|
|
11
|
+
export const UserProfileItemSchema = withFormatter(
|
|
12
|
+
UserProfileSchema.omit({ user_id: true }).extend({
|
|
13
|
+
full_name: z.string(), // Computed field: first_name + " " + last_name
|
|
14
|
+
}),
|
|
15
|
+
{
|
|
16
|
+
format: (item) => {
|
|
17
|
+
const details = [];
|
|
18
|
+
details.push({ text: item.email, style: "dim" as const });
|
|
19
|
+
if (item.timezone) {
|
|
20
|
+
details.push({
|
|
21
|
+
text: `Timezone: ${item.timezone}`,
|
|
22
|
+
style: "accent" as const,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
details.push({
|
|
26
|
+
text: `Member since: ${item.since_signup}`,
|
|
27
|
+
style: "dim" as const,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
title: item.full_name,
|
|
32
|
+
subtitle: `@${item.username}`,
|
|
33
|
+
details,
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// ============================================================================
|
|
40
|
+
// Type Exports
|
|
41
|
+
// ============================================================================
|
|
42
|
+
|
|
43
|
+
export type UserProfileItem = z.infer<typeof UserProfileItemSchema>;
|