@zapier/zapier-sdk 0.46.0 → 0.47.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 +18 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +17 -6
- package/dist/api/types.d.ts +11 -0
- package/dist/api/types.d.ts.map +1 -1
- package/dist/index.cjs +3048 -3629
- package/dist/index.d.mts +6700 -2148
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.mjs +3045 -3630
- package/dist/plugins/api/index.d.ts +22 -10
- package/dist/plugins/api/index.d.ts.map +1 -1
- package/dist/plugins/api/index.js +4 -4
- package/dist/plugins/apps/index.d.ts +108 -7
- package/dist/plugins/apps/index.d.ts.map +1 -1
- package/dist/plugins/apps/index.js +3 -4
- package/dist/plugins/capabilities/index.d.ts +9 -6
- package/dist/plugins/capabilities/index.d.ts.map +1 -1
- package/dist/plugins/capabilities/index.js +3 -2
- package/dist/plugins/connections/index.d.ts +15 -9
- package/dist/plugins/connections/index.d.ts.map +1 -1
- package/dist/plugins/connections/index.js +3 -2
- package/dist/plugins/createClientCredentials/index.d.ts +26 -14
- package/dist/plugins/createClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/createClientCredentials/index.js +16 -39
- package/dist/plugins/createClientCredentials/schemas.d.ts +0 -2
- package/dist/plugins/createClientCredentials/schemas.d.ts.map +1 -1
- package/dist/plugins/deleteClientCredentials/index.d.ts +20 -14
- package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/deleteClientCredentials/index.js +18 -37
- package/dist/plugins/deleteClientCredentials/schemas.d.ts +0 -2
- package/dist/plugins/deleteClientCredentials/schemas.d.ts.map +1 -1
- package/dist/plugins/deprecated/authentications.d.ts +597 -41
- package/dist/plugins/deprecated/authentications.d.ts.map +1 -1
- package/dist/plugins/deprecated/authentications.js +9 -8
- package/dist/plugins/eventEmission/index.d.ts +9 -6
- package/dist/plugins/eventEmission/index.d.ts.map +1 -1
- package/dist/plugins/eventEmission/index.js +3 -2
- package/dist/plugins/fetch/index.d.ts +40 -17
- package/dist/plugins/fetch/index.d.ts.map +1 -1
- package/dist/plugins/fetch/index.js +6 -4
- package/dist/plugins/findFirstConnection/index.d.ts +109 -14
- package/dist/plugins/findFirstConnection/index.d.ts.map +1 -1
- package/dist/plugins/findFirstConnection/index.js +14 -26
- package/dist/plugins/findFirstConnection/schemas.d.ts +0 -2
- package/dist/plugins/findFirstConnection/schemas.d.ts.map +1 -1
- package/dist/plugins/findUniqueConnection/index.d.ts +109 -14
- package/dist/plugins/findUniqueConnection/index.d.ts.map +1 -1
- package/dist/plugins/findUniqueConnection/index.js +14 -26
- package/dist/plugins/findUniqueConnection/schemas.d.ts +0 -2
- package/dist/plugins/findUniqueConnection/schemas.d.ts.map +1 -1
- package/dist/plugins/getAction/index.d.ts +68 -15
- package/dist/plugins/getAction/index.d.ts.map +1 -1
- package/dist/plugins/getAction/index.js +21 -31
- package/dist/plugins/getAction/schemas.d.ts +0 -2
- package/dist/plugins/getAction/schemas.d.ts.map +1 -1
- package/dist/plugins/getApp/index.d.ts +140 -14
- package/dist/plugins/getApp/index.d.ts.map +1 -1
- package/dist/plugins/getApp/index.js +16 -38
- package/dist/plugins/getApp/schemas.d.ts +0 -2
- package/dist/plugins/getApp/schemas.d.ts.map +1 -1
- package/dist/plugins/getConnection/index.d.ts +50 -16
- package/dist/plugins/getConnection/index.d.ts.map +1 -1
- package/dist/plugins/getConnection/index.js +22 -29
- package/dist/plugins/getConnection/schemas.d.ts +0 -2
- package/dist/plugins/getConnection/schemas.d.ts.map +1 -1
- package/dist/plugins/getInputFieldsSchema/index.d.ts +59 -13
- package/dist/plugins/getInputFieldsSchema/index.d.ts.map +1 -1
- package/dist/plugins/getInputFieldsSchema/index.js +21 -32
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts +0 -2
- package/dist/plugins/getInputFieldsSchema/schemas.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.d.ts +25 -18
- package/dist/plugins/getProfile/index.d.ts.map +1 -1
- package/dist/plugins/getProfile/index.js +13 -26
- package/dist/plugins/getProfile/schemas.d.ts +0 -8
- package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
- package/dist/plugins/getProfile/schemas.js +0 -1
- package/dist/plugins/listActions/index.d.ts +73 -23
- package/dist/plugins/listActions/index.d.ts.map +1 -1
- package/dist/plugins/listActions/index.js +25 -53
- package/dist/plugins/listActions/schemas.d.ts +0 -11
- package/dist/plugins/listActions/schemas.d.ts.map +1 -1
- package/dist/plugins/listApps/index.d.ts +121 -13
- package/dist/plugins/listApps/index.d.ts.map +1 -1
- package/dist/plugins/listApps/index.js +22 -31
- package/dist/plugins/listApps/schemas.d.ts +0 -2
- package/dist/plugins/listApps/schemas.d.ts.map +1 -1
- package/dist/plugins/listClientCredentials/index.d.ts +29 -16
- package/dist/plugins/listClientCredentials/index.d.ts.map +1 -1
- package/dist/plugins/listClientCredentials/index.js +17 -37
- package/dist/plugins/listClientCredentials/schemas.d.ts +0 -2
- package/dist/plugins/listClientCredentials/schemas.d.ts.map +1 -1
- package/dist/plugins/listConnections/index.d.ts +95 -17
- package/dist/plugins/listConnections/index.d.ts.map +1 -1
- package/dist/plugins/listConnections/index.js +25 -49
- package/dist/plugins/listConnections/schemas.d.ts +0 -2
- package/dist/plugins/listConnections/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.d.ts +77 -22
- package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
- package/dist/plugins/listInputFieldChoices/index.js +27 -50
- package/dist/plugins/listInputFieldChoices/schemas.d.ts +0 -2
- package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.d.ts +154 -22
- package/dist/plugins/listInputFields/index.d.ts.map +1 -1
- package/dist/plugins/listInputFields/index.js +28 -41
- package/dist/plugins/listInputFields/schemas.d.ts +0 -2
- package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
- package/dist/plugins/manifest/index.d.ts +40 -36
- package/dist/plugins/manifest/index.d.ts.map +1 -1
- package/dist/plugins/manifest/index.js +3 -2
- package/dist/plugins/registry/index.d.ts +11 -9
- package/dist/plugins/registry/index.d.ts.map +1 -1
- package/dist/plugins/registry/index.js +3 -2
- package/dist/plugins/request/index.d.ts +61 -15
- package/dist/plugins/request/index.d.ts.map +1 -1
- package/dist/plugins/request/index.js +14 -22
- package/dist/plugins/request/schemas.d.ts +0 -2
- package/dist/plugins/request/schemas.d.ts.map +1 -1
- package/dist/plugins/runAction/index.d.ts +137 -23
- package/dist/plugins/runAction/index.d.ts.map +1 -1
- package/dist/plugins/runAction/index.js +65 -78
- package/dist/plugins/runAction/schemas.d.ts +0 -10
- package/dist/plugins/runAction/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/createTable/index.d.ts +43 -11
- package/dist/plugins/tables/createTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/createTable/index.js +16 -44
- package/dist/plugins/tables/createTable/schemas.d.ts +0 -2
- package/dist/plugins/tables/createTable/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/createTableFields/index.d.ts +54 -11
- package/dist/plugins/tables/createTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/createTableFields/index.js +17 -41
- package/dist/plugins/tables/createTableFields/schemas.d.ts +0 -2
- package/dist/plugins/tables/createTableFields/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/createTableRecords/index.d.ts +47 -11
- package/dist/plugins/tables/createTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/createTableRecords/index.js +17 -43
- package/dist/plugins/tables/createTableRecords/schemas.d.ts +0 -2
- package/dist/plugins/tables/createTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTable/index.d.ts +36 -13
- package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTable/index.js +18 -40
- package/dist/plugins/tables/deleteTable/schemas.d.ts +0 -2
- package/dist/plugins/tables/deleteTable/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableFields/index.d.ts +36 -11
- package/dist/plugins/tables/deleteTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableFields/index.js +17 -39
- package/dist/plugins/tables/deleteTableFields/schemas.d.ts +0 -2
- package/dist/plugins/tables/deleteTableFields/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableRecords/index.d.ts +36 -11
- package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/deleteTableRecords/index.js +18 -41
- package/dist/plugins/tables/deleteTableRecords/schemas.d.ts +0 -2
- package/dist/plugins/tables/deleteTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/getTable/index.d.ts +43 -12
- package/dist/plugins/tables/getTable/index.d.ts.map +1 -1
- package/dist/plugins/tables/getTable/index.js +18 -43
- package/dist/plugins/tables/getTable/schemas.d.ts +0 -2
- package/dist/plugins/tables/getTable/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/getTableRecord/index.d.ts +43 -11
- package/dist/plugins/tables/getTableRecord/index.d.ts.map +1 -1
- package/dist/plugins/tables/getTableRecord/index.js +18 -42
- package/dist/plugins/tables/getTableRecord/schemas.d.ts +0 -2
- package/dist/plugins/tables/getTableRecord/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/listTableFields/index.d.ts +46 -11
- package/dist/plugins/tables/listTableFields/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTableFields/index.js +17 -41
- package/dist/plugins/tables/listTableFields/schemas.d.ts +0 -2
- package/dist/plugins/tables/listTableFields/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/listTableRecords/index.d.ts +66 -18
- package/dist/plugins/tables/listTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTableRecords/index.js +27 -50
- package/dist/plugins/tables/listTableRecords/schemas.d.ts +0 -2
- package/dist/plugins/tables/listTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/listTables/index.d.ts +53 -20
- package/dist/plugins/tables/listTables/index.d.ts.map +1 -1
- package/dist/plugins/tables/listTables/index.js +24 -51
- package/dist/plugins/tables/listTables/schemas.d.ts +0 -2
- package/dist/plugins/tables/listTables/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/shared.d.ts +10 -0
- package/dist/plugins/tables/shared.d.ts.map +1 -0
- package/dist/plugins/tables/shared.js +9 -0
- package/dist/plugins/tables/updateTableRecords/index.d.ts +49 -11
- package/dist/plugins/tables/updateTableRecords/index.d.ts.map +1 -1
- package/dist/plugins/tables/updateTableRecords/index.js +20 -43
- package/dist/plugins/tables/updateTableRecords/schemas.d.ts +0 -2
- package/dist/plugins/tables/updateTableRecords/schemas.d.ts.map +1 -1
- package/dist/plugins/tables/utils.d.ts.map +1 -1
- package/dist/plugins/tables/utils.js +1 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +21 -1
- package/dist/resolvers/actionKey.d.ts +1 -2
- package/dist/resolvers/actionKey.d.ts.map +1 -1
- package/dist/resolvers/actionType.d.ts +1 -2
- package/dist/resolvers/actionType.d.ts.map +1 -1
- package/dist/sdk.d.ts +2942 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/types/errors.d.ts +13 -10
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +15 -12
- package/dist/types/functions.d.ts +18 -2
- package/dist/types/functions.d.ts.map +1 -1
- package/dist/types/plugin.d.ts +1 -1
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/registry.d.ts +1 -1
- package/dist/types/registry.d.ts.map +1 -1
- package/dist/utils/function-utils.d.ts +11 -12
- package/dist/utils/function-utils.d.ts.map +1 -1
- package/dist/utils/plugin-utils.d.ts +243 -0
- package/dist/utils/plugin-utils.d.ts.map +1 -0
- package/dist/utils/plugin-utils.js +232 -0
- package/package.json +2 -1
|
@@ -1,46 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ZapierAuthenticationError } from "../../../types/errors";
|
|
1
|
+
import { definePlugin } from "../../../utils/plugin-utils";
|
|
2
|
+
import { createPluginMethod } from "../../../utils/plugin-utils";
|
|
3
|
+
import { DeleteTableRecordsOptionsInputSchema } from "./schemas";
|
|
5
4
|
import { tableIdResolver, tableRecordIdsResolver } from "../../../resolvers";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
import { tablesDefaults } from "../shared";
|
|
6
|
+
export const deleteTableRecordsPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
|
|
7
|
+
...tablesDefaults,
|
|
8
|
+
name: "deleteTableRecords",
|
|
9
|
+
type: "delete",
|
|
10
|
+
itemType: "Record",
|
|
11
|
+
inputSchema: DeleteTableRecordsOptionsInputSchema,
|
|
12
|
+
resolvers: { table: tableIdResolver, records: tableRecordIdsResolver },
|
|
13
|
+
confirm: "delete",
|
|
14
|
+
handler: async ({ sdk, options }) => {
|
|
9
15
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
10
16
|
const recordIds = "records" in options ? options.records : options.recordIds;
|
|
11
|
-
await api.delete(`/tables/api/v1/tables/${tableId}/records`, { record_ids: recordIds }, {
|
|
12
|
-
customErrorHandler: ({ status }) => {
|
|
13
|
-
if (status === 401) {
|
|
14
|
-
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to delete records or may be expired. (HTTP ${status})`, { statusCode: status });
|
|
15
|
-
}
|
|
16
|
-
if (status === 403) {
|
|
17
|
-
return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to delete records. (HTTP ${status})`, { statusCode: status });
|
|
18
|
-
}
|
|
19
|
-
return undefined;
|
|
20
|
-
},
|
|
17
|
+
await sdk.context.api.delete(`/tables/api/v1/tables/${tableId}/records`, { record_ids: recordIds }, {
|
|
21
18
|
authRequired: true,
|
|
19
|
+
resource: { type: "table", id: tableId },
|
|
22
20
|
});
|
|
23
|
-
return {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
const deleteTableRecordsDefinition = createFunction(deleteTableRecords, DeleteTableRecordsOptionsInputSchema, createTelemetryCallback(sdk.context.eventEmission.emitMethodCalled, deleteTableRecords.name));
|
|
28
|
-
return {
|
|
29
|
-
deleteTableRecords: deleteTableRecordsDefinition,
|
|
30
|
-
context: {
|
|
31
|
-
meta: {
|
|
32
|
-
deleteTableRecords: {
|
|
33
|
-
categories: ["table"],
|
|
34
|
-
type: "delete",
|
|
35
|
-
itemType: "Record",
|
|
36
|
-
inputSchema: DeleteTableRecordsOptionsSchema,
|
|
37
|
-
resolvers: {
|
|
38
|
-
table: tableIdResolver,
|
|
39
|
-
records: tableRecordIdsResolver,
|
|
40
|
-
},
|
|
41
|
-
confirm: "delete",
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
};
|
|
46
|
-
};
|
|
21
|
+
return { success: true };
|
|
22
|
+
},
|
|
23
|
+
}));
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { FunctionOptions } from "../../../types/functions";
|
|
3
|
-
import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../../types/errors";
|
|
4
3
|
export declare const DeleteTableRecordsOptionsSchema: z.ZodObject<{
|
|
5
4
|
table: z.ZodString & {
|
|
6
5
|
_def: z.core.$ZodStringDef & import("../../..").PositionalMetadata;
|
|
@@ -29,7 +28,6 @@ export type DeleteTableRecordsOptions = (z.infer<typeof DeleteTableRecordsOption
|
|
|
29
28
|
export interface DeleteTableRecordsResult {
|
|
30
29
|
success: boolean;
|
|
31
30
|
}
|
|
32
|
-
export type DeleteTableRecordsError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
33
31
|
export interface DeleteTableRecordsSdkFunction {
|
|
34
32
|
deleteTableRecords: (options: DeleteTableRecordsOptions) => Promise<DeleteTableRecordsResult>;
|
|
35
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/deleteTableRecords/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/deleteTableRecords/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAShE,eAAO,MAAM,+BAA+B;;;;;iBAMoB,CAAC;AAGjE,QAAA,MAAM,yCAAyC;;;iBAU7C,CAAC;AAGH,eAAO,MAAM,oCAAoC;;;;;;;;mBAKP,CAAC;AAG3C,MAAM,MAAM,yBAAyB,GACjC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,GAAG,eAAe,CAAC,GACnE,CAAC,IAAI,CACH,CAAC,CAAC,KAAK,CAAC,OAAO,yCAAyC,CAAC,EACzD,SAAS,GAAG,WAAW,CACxB,GAAG;IACF,uCAAuC;IACvC,OAAO,EAAE,CAAC,CAAC,KAAK,CACd,OAAO,yCAAyC,CACjD,CAAC,SAAS,CAAC,CAAC;IACb,yCAAyC;IACzC,SAAS,EAAE,CAAC,CAAC,KAAK,CAChB,OAAO,yCAAyC,CACjD,CAAC,WAAW,CAAC,CAAC;CAChB,GAAG,eAAe,CAAC,CAAC;AAEzB,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,6BAA6B;IAC5C,kBAAkB,EAAE,CAClB,OAAO,EAAE,yBAAyB,KAC/B,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACxC"}
|
|
@@ -1,18 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export declare const getTablePlugin: (sdk: {
|
|
2
|
+
context: {
|
|
3
|
+
api: import("../../../api").ApiClient;
|
|
4
|
+
resolveCredentials: () => Promise<string | {
|
|
5
|
+
clientId: string;
|
|
6
|
+
clientSecret: string;
|
|
7
|
+
type?: "client_credentials" | undefined;
|
|
8
|
+
baseUrl?: string | undefined;
|
|
9
|
+
scope?: string | undefined;
|
|
10
|
+
} | {
|
|
11
|
+
clientId: string;
|
|
12
|
+
type?: "pkce" | undefined;
|
|
13
|
+
baseUrl?: string | undefined;
|
|
14
|
+
scope?: string | undefined;
|
|
15
|
+
} | undefined>;
|
|
16
|
+
};
|
|
17
|
+
} & {
|
|
18
|
+
context: import("../../eventEmission").EventEmissionContext;
|
|
19
|
+
} & {
|
|
20
|
+
context: {
|
|
21
|
+
meta: Record<string, import("../../..").PluginMeta>;
|
|
22
|
+
};
|
|
23
|
+
}) => {
|
|
24
|
+
getTable: (options?: {
|
|
25
|
+
table: string;
|
|
26
|
+
} | {
|
|
27
|
+
tableId: string;
|
|
28
|
+
} | undefined) => Promise<{
|
|
29
|
+
data: {
|
|
30
|
+
id: string;
|
|
31
|
+
name: string;
|
|
32
|
+
created_at: string;
|
|
33
|
+
edited_at: string;
|
|
34
|
+
kind: "table" | "virtual_table";
|
|
35
|
+
account_id: string;
|
|
36
|
+
profile_id: string;
|
|
37
|
+
description?: string | undefined;
|
|
38
|
+
parent_table_id?: string | undefined;
|
|
39
|
+
};
|
|
8
40
|
}>;
|
|
41
|
+
} & {
|
|
9
42
|
context: {
|
|
10
43
|
meta: {
|
|
11
|
-
getTable:
|
|
12
|
-
inputSchema: typeof GetTableOptionsSchema;
|
|
13
|
-
};
|
|
44
|
+
getTable: import("../../..").PluginMeta;
|
|
14
45
|
};
|
|
15
46
|
};
|
|
16
|
-
}
|
|
17
|
-
export
|
|
47
|
+
};
|
|
48
|
+
export type GetTablePluginProvides = ReturnType<typeof getTablePlugin>;
|
|
18
49
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/getTable/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/getTable/index.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuB1B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC"}
|
|
@@ -1,49 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ZapierAuthenticationError } from "../../../types/errors";
|
|
1
|
+
import { definePlugin } from "../../../utils/plugin-utils";
|
|
2
|
+
import { createPluginMethod } from "../../../utils/plugin-utils";
|
|
3
|
+
import { GetTableApiResponseSchema, GetTableOptionsInputSchema, TableItemSchema, } from "./schemas";
|
|
5
4
|
import { tableIdResolver } from "../../../resolvers";
|
|
6
5
|
import { transformTableItem } from "../utils";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import { tablesDefaults } from "../shared";
|
|
7
|
+
export const getTablePlugin = definePlugin((sdk) => createPluginMethod(sdk, {
|
|
8
|
+
...tablesDefaults,
|
|
9
|
+
name: "getTable",
|
|
10
|
+
type: "item",
|
|
11
|
+
itemType: "Table",
|
|
12
|
+
inputSchema: GetTableOptionsInputSchema,
|
|
13
|
+
outputSchema: TableItemSchema,
|
|
14
|
+
resolvers: { table: tableIdResolver },
|
|
15
|
+
handler: async ({ sdk, options }) => {
|
|
10
16
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
11
|
-
const rawResponse = await api.get(`/tables/api/v1/tables/${tableId}`, {
|
|
12
|
-
customErrorHandler: ({ status }) => {
|
|
13
|
-
if (status === 401) {
|
|
14
|
-
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to access this table or may be expired. (HTTP ${status})`, { statusCode: status });
|
|
15
|
-
}
|
|
16
|
-
if (status === 403) {
|
|
17
|
-
return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to access this table. (HTTP ${status})`, { statusCode: status });
|
|
18
|
-
}
|
|
19
|
-
if (status === 404) {
|
|
20
|
-
return new Error(`Table not found: ${tableId}`);
|
|
21
|
-
}
|
|
22
|
-
return undefined;
|
|
23
|
-
},
|
|
17
|
+
const rawResponse = await sdk.context.api.get(`/tables/api/v1/tables/${tableId}`, {
|
|
24
18
|
authRequired: true,
|
|
19
|
+
resource: { type: "table", id: tableId },
|
|
25
20
|
});
|
|
26
21
|
const response = GetTableApiResponseSchema.parse(rawResponse);
|
|
27
|
-
return {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
const getTableDefinition = createFunction(getTable, GetTableOptionsInputSchema, createTelemetryCallback(sdk.context.eventEmission.emitMethodCalled, getTable.name));
|
|
32
|
-
return {
|
|
33
|
-
getTable: getTableDefinition,
|
|
34
|
-
context: {
|
|
35
|
-
meta: {
|
|
36
|
-
getTable: {
|
|
37
|
-
categories: ["table"],
|
|
38
|
-
type: "item",
|
|
39
|
-
itemType: "Table",
|
|
40
|
-
inputSchema: GetTableOptionsSchema,
|
|
41
|
-
outputSchema: TableItemSchema,
|
|
42
|
-
resolvers: {
|
|
43
|
-
table: tableIdResolver,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
};
|
|
22
|
+
return { data: transformTableItem(response.data) };
|
|
23
|
+
},
|
|
24
|
+
}));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../../types/errors";
|
|
3
2
|
import { TableItemSchema, TableApiItemSchema, type TableItem, type TableApiItem } from "../listTables/schemas";
|
|
4
3
|
export { TableItemSchema, TableApiItemSchema };
|
|
5
4
|
export type { TableItem, TableApiItem };
|
|
@@ -42,7 +41,6 @@ export type GetTableOptions = z.infer<typeof GetTableOptionsSchema> | (Omit<z.in
|
|
|
42
41
|
/** @deprecated Use `table` instead. */
|
|
43
42
|
tableId: z.infer<typeof GetTableOptionsSchemaDeprecated>["tableId"];
|
|
44
43
|
});
|
|
45
|
-
export type GetTableError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
46
44
|
export interface GetTableSdkFunction {
|
|
47
45
|
getTable: (options: GetTableOptions) => Promise<{
|
|
48
46
|
data: TableItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/getTable/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/getTable/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,KAAK,SAAS,EACd,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAC;AAC/C,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;AAExC,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;iBAEpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAK5E,eAAO,MAAM,qBAAqB;;;;iBAKQ,CAAC;AAG3C,QAAA,MAAM,+BAA+B;;iBAKnC,CAAC;AAGH,eAAO,MAAM,0BAA0B;;;;;;mBAEP,CAAC;AAGjC,MAAM,MAAM,eAAe,GACvB,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,GACrC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,EAAE,SAAS,CAAC,GAAG;IAClE,uCAAuC;IACvC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC,SAAS,CAAC,CAAC;CACrE,CAAC,CAAC;AAGP,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;CACtE"}
|
|
@@ -1,16 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export declare const getTableRecordPlugin: (sdk: {
|
|
2
|
+
context: {
|
|
3
|
+
api: import("../../../api").ApiClient;
|
|
4
|
+
resolveCredentials: () => Promise<string | {
|
|
5
|
+
clientId: string;
|
|
6
|
+
clientSecret: string;
|
|
7
|
+
type?: "client_credentials" | undefined;
|
|
8
|
+
baseUrl?: string | undefined;
|
|
9
|
+
scope?: string | undefined;
|
|
10
|
+
} | {
|
|
11
|
+
clientId: string;
|
|
12
|
+
type?: "pkce" | undefined;
|
|
13
|
+
baseUrl?: string | undefined;
|
|
14
|
+
scope?: string | undefined;
|
|
15
|
+
} | undefined>;
|
|
16
|
+
};
|
|
17
|
+
} & {
|
|
18
|
+
context: import("../../eventEmission").EventEmissionContext;
|
|
19
|
+
} & {
|
|
20
|
+
context: {
|
|
21
|
+
meta: Record<string, import("../../..").PluginMeta>;
|
|
22
|
+
};
|
|
23
|
+
}) => {
|
|
24
|
+
getTableRecord: (options?: {
|
|
25
|
+
table: string;
|
|
26
|
+
record: string;
|
|
27
|
+
keyMode: "names" | "ids";
|
|
28
|
+
} | {
|
|
29
|
+
tableId: string;
|
|
30
|
+
recordId: string;
|
|
31
|
+
keyMode: "names" | "ids";
|
|
32
|
+
} | undefined) => Promise<{
|
|
33
|
+
data: {
|
|
34
|
+
data: Record<string, unknown>;
|
|
35
|
+
id: string;
|
|
36
|
+
created_at: string;
|
|
37
|
+
edited_at: string;
|
|
38
|
+
};
|
|
39
|
+
}>;
|
|
40
|
+
} & {
|
|
7
41
|
context: {
|
|
8
42
|
meta: {
|
|
9
|
-
getTableRecord:
|
|
10
|
-
inputSchema: typeof GetTableRecordOptionsSchema;
|
|
11
|
-
};
|
|
43
|
+
getTableRecord: import("../../..").PluginMeta;
|
|
12
44
|
};
|
|
13
45
|
};
|
|
14
|
-
}
|
|
15
|
-
export
|
|
46
|
+
};
|
|
47
|
+
export type GetTableRecordPluginProvides = ReturnType<typeof getTableRecordPlugin>;
|
|
16
48
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/getTableRecord/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/getTableRecord/index.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwChC,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,UAAU,CACnD,OAAO,oBAAoB,CAC5B,CAAC"}
|
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ZapierAuthenticationError } from "../../../types/errors";
|
|
1
|
+
import { definePlugin } from "../../../utils/plugin-utils";
|
|
2
|
+
import { createPluginMethod } from "../../../utils/plugin-utils";
|
|
3
|
+
import { GetTableRecordOptionsInputSchema, GetTableRecordApiResponseSchema, RecordItemSchema, } from "./schemas";
|
|
5
4
|
import { tableIdResolver, tableRecordIdResolver } from "../../../resolvers";
|
|
6
5
|
import { tableRecordFormatter } from "../../../formatters";
|
|
7
|
-
import { createFieldKeyTranslator } from "../utils";
|
|
8
|
-
import {
|
|
9
|
-
export const getTableRecordPlugin = (sdk) => {
|
|
10
|
-
|
|
6
|
+
import { createFieldKeyTranslator, transformRecordItem } from "../utils";
|
|
7
|
+
import { tablesDefaults } from "../shared";
|
|
8
|
+
export const getTableRecordPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
|
|
9
|
+
...tablesDefaults,
|
|
10
|
+
name: "getTableRecord",
|
|
11
|
+
type: "item",
|
|
12
|
+
itemType: "Record",
|
|
13
|
+
inputSchema: GetTableRecordOptionsInputSchema,
|
|
14
|
+
outputSchema: RecordItemSchema,
|
|
15
|
+
resolvers: { table: tableIdResolver, record: tableRecordIdResolver },
|
|
16
|
+
formatter: tableRecordFormatter,
|
|
17
|
+
handler: async ({ sdk, options }) => {
|
|
11
18
|
const { api } = sdk.context;
|
|
12
19
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
13
20
|
const recordId = "record" in options ? options.record : options.recordId;
|
|
14
21
|
const rawResponse = await api.get(`/tables/api/v1/tables/${tableId}/records/${recordId}`, {
|
|
15
|
-
customErrorHandler: ({ status }) => {
|
|
16
|
-
if (status === 401) {
|
|
17
|
-
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to access this record or may be expired. (HTTP ${status})`, { statusCode: status });
|
|
18
|
-
}
|
|
19
|
-
if (status === 403) {
|
|
20
|
-
return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to access this record. (HTTP ${status})`, { statusCode: status });
|
|
21
|
-
}
|
|
22
|
-
if (status === 404) {
|
|
23
|
-
return new Error(`Record not found: ${recordId}`);
|
|
24
|
-
}
|
|
25
|
-
return undefined;
|
|
26
|
-
},
|
|
27
22
|
authRequired: true,
|
|
23
|
+
resource: { type: "record", id: recordId },
|
|
28
24
|
});
|
|
29
25
|
const response = GetTableRecordApiResponseSchema.parse(rawResponse);
|
|
30
26
|
const translator = await createFieldKeyTranslator({
|
|
@@ -38,25 +34,5 @@ export const getTableRecordPlugin = (sdk) => {
|
|
|
38
34
|
data: translator.translateOutput(response.data.data),
|
|
39
35
|
},
|
|
40
36
|
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
getTableRecord: getTableRecordDefinition,
|
|
45
|
-
context: {
|
|
46
|
-
meta: {
|
|
47
|
-
getTableRecord: {
|
|
48
|
-
categories: ["table"],
|
|
49
|
-
type: "item",
|
|
50
|
-
itemType: "Record",
|
|
51
|
-
inputSchema: GetTableRecordOptionsSchema,
|
|
52
|
-
outputSchema: RecordItemSchema,
|
|
53
|
-
resolvers: {
|
|
54
|
-
table: tableIdResolver,
|
|
55
|
-
record: tableRecordIdResolver,
|
|
56
|
-
},
|
|
57
|
-
formatter: tableRecordFormatter,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
};
|
|
37
|
+
},
|
|
38
|
+
}));
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { FunctionOptions } from "../../../types/functions";
|
|
3
|
-
import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../../types/errors";
|
|
4
3
|
export declare const RecordApiItemSchema: z.ZodObject<{
|
|
5
4
|
id: z.ZodString;
|
|
6
5
|
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
@@ -80,7 +79,6 @@ export type GetTableRecordOptions = (z.infer<typeof GetTableRecordOptionsSchema>
|
|
|
80
79
|
export interface GetTableRecordResult {
|
|
81
80
|
data: RecordItem;
|
|
82
81
|
}
|
|
83
|
-
export type GetTableRecordError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
84
82
|
export interface GetTableRecordSdkFunction {
|
|
85
83
|
getTableRecord: (options: GetTableRecordOptions) => Promise<GetTableRecordResult>;
|
|
86
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/getTableRecord/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/getTableRecord/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAQhE,eAAO,MAAM,mBAAmB;;;;;;;;;iBAS9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAUhE,eAAO,MAAM,gBAAgB;;;;;iBAO3B,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D,eAAO,MAAM,+BAA+B;;;;;;;;;;;iBAE1C,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,CAAC;AAUF,eAAO,MAAM,2BAA2B;;;;;;;;;;;iBAOsB,CAAC;AAG/D,QAAA,MAAM,qCAAqC;;;;;;;iBAWF,CAAC;AAG1C,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;mBAEP,CAAC;AAGvC,MAAM,MAAM,qBAAqB,GAC7B,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,GAAG,eAAe,CAAC,GAC/D,CAAC,IAAI,CACH,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,EACrD,SAAS,GAAG,UAAU,CACvB,GAAG;IACF,uCAAuC;IACvC,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC1E,wCAAwC;IACxC,QAAQ,EAAE,CAAC,CAAC,KAAK,CACf,OAAO,qCAAqC,CAC7C,CAAC,UAAU,CAAC,CAAC;CACf,GAAG,eAAe,CAAC,CAAC;AAEzB,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,WAAW,yBAAyB;IACxC,cAAc,EAAE,CACd,OAAO,EAAE,qBAAqB,KAC3B,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACpC"}
|
|
@@ -1,16 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export declare const listTableFieldsPlugin: (sdk: {
|
|
2
|
+
context: {
|
|
3
|
+
api: import("../../../api").ApiClient;
|
|
4
|
+
resolveCredentials: () => Promise<string | {
|
|
5
|
+
clientId: string;
|
|
6
|
+
clientSecret: string;
|
|
7
|
+
type?: "client_credentials" | undefined;
|
|
8
|
+
baseUrl?: string | undefined;
|
|
9
|
+
scope?: string | undefined;
|
|
10
|
+
} | {
|
|
11
|
+
clientId: string;
|
|
12
|
+
type?: "pkce" | undefined;
|
|
13
|
+
baseUrl?: string | undefined;
|
|
14
|
+
scope?: string | undefined;
|
|
15
|
+
} | undefined>;
|
|
16
|
+
};
|
|
17
|
+
} & {
|
|
18
|
+
context: import("../../eventEmission").EventEmissionContext;
|
|
19
|
+
} & {
|
|
20
|
+
context: {
|
|
21
|
+
meta: Record<string, import("../../..").PluginMeta>;
|
|
22
|
+
};
|
|
23
|
+
}) => {
|
|
24
|
+
listTableFields: (options?: {
|
|
25
|
+
table: string;
|
|
26
|
+
fields?: (string | number)[] | undefined;
|
|
27
|
+
fieldKeys?: (string | number)[] | undefined;
|
|
28
|
+
} | {
|
|
29
|
+
tableId: string;
|
|
30
|
+
fields?: (string | number)[] | undefined;
|
|
31
|
+
fieldKeys?: (string | number)[] | undefined;
|
|
32
|
+
} | undefined) => Promise<{
|
|
33
|
+
data: {
|
|
34
|
+
id: string;
|
|
35
|
+
type: "string" | "number" | "boolean" | "text" | "datetime" | "decimal" | "json" | "email" | "link" | "multiple_string" | "labeled_string" | "multiple_labeled_string" | "multiple_text" | "multiple_boolean" | "multiple_number" | "multiple_decimal" | "multiple_datetime" | "uuid" | "multiple_uuid" | "multiple_json" | "formula" | "button_trigger_zap" | "button_continue_zap" | "multiple_email" | "multiple_link" | "currency" | "phone_number" | "ai_formula" | "linked_record" | "multiple_linked_record";
|
|
36
|
+
name: string;
|
|
37
|
+
created_at?: string | undefined;
|
|
38
|
+
edited_at?: string | undefined;
|
|
39
|
+
options?: Record<string, unknown> | undefined;
|
|
40
|
+
config?: Record<string, unknown> | undefined;
|
|
41
|
+
}[];
|
|
42
|
+
}>;
|
|
43
|
+
} & {
|
|
7
44
|
context: {
|
|
8
45
|
meta: {
|
|
9
|
-
listTableFields:
|
|
10
|
-
inputSchema: typeof ListTableFieldsOptionsSchema;
|
|
11
|
-
};
|
|
46
|
+
listTableFields: import("../../..").PluginMeta;
|
|
12
47
|
};
|
|
13
48
|
};
|
|
14
|
-
}
|
|
15
|
-
export
|
|
49
|
+
};
|
|
50
|
+
export type ListTableFieldsPluginProvides = ReturnType<typeof listTableFieldsPlugin>;
|
|
16
51
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTableFields/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTableFields/index.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCjC,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,UAAU,CACpD,OAAO,qBAAqB,CAC7B,CAAC"}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { ZapierAuthenticationError } from "../../../types/errors";
|
|
1
|
+
import { definePlugin } from "../../../utils/plugin-utils";
|
|
2
|
+
import { createPluginMethod } from "../../../utils/plugin-utils";
|
|
3
|
+
import { ListTableFieldsOptionsInputSchema, ListTableFieldsApiResponseSchema, FieldItemSchema, } from "./schemas";
|
|
5
4
|
import { tableIdResolver } from "../../../resolvers";
|
|
6
5
|
import { resolveFieldKeys, transformFieldItem } from "../utils";
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import { tablesDefaults } from "../shared";
|
|
7
|
+
export const listTableFieldsPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
|
|
8
|
+
...tablesDefaults,
|
|
9
|
+
name: "listTableFields",
|
|
10
|
+
type: "list",
|
|
11
|
+
itemType: "Field",
|
|
12
|
+
inputSchema: ListTableFieldsOptionsInputSchema,
|
|
13
|
+
outputSchema: FieldItemSchema,
|
|
14
|
+
resolvers: { table: tableIdResolver },
|
|
15
|
+
handler: async ({ sdk, options }) => {
|
|
9
16
|
const { api } = sdk.context;
|
|
10
17
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
11
18
|
const fieldKeys = "fields" in options ? options.fields : options.fieldKeys;
|
|
@@ -20,41 +27,10 @@ export const listTableFieldsPlugin = (sdk) => {
|
|
|
20
27
|
}
|
|
21
28
|
const rawResponse = await api.get(`/tables/api/v1/tables/${tableId}/fields`, {
|
|
22
29
|
searchParams: Object.keys(searchParams).length > 0 ? searchParams : undefined,
|
|
23
|
-
customErrorHandler: ({ status }) => {
|
|
24
|
-
if (status === 401) {
|
|
25
|
-
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to access this table or may be expired. (HTTP ${status})`, { statusCode: status });
|
|
26
|
-
}
|
|
27
|
-
if (status === 403) {
|
|
28
|
-
return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to access this table. (HTTP ${status})`, { statusCode: status });
|
|
29
|
-
}
|
|
30
|
-
if (status === 404) {
|
|
31
|
-
return new Error(`Table not found: ${tableId}`);
|
|
32
|
-
}
|
|
33
|
-
return undefined;
|
|
34
|
-
},
|
|
35
30
|
authRequired: true,
|
|
31
|
+
resource: { type: "table", id: tableId },
|
|
36
32
|
});
|
|
37
33
|
const response = ListTableFieldsApiResponseSchema.parse(rawResponse);
|
|
38
|
-
return {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
const listTableFieldsDefinition = createFunction(listTableFields, ListTableFieldsOptionsInputSchema, createTelemetryCallback(sdk.context.eventEmission.emitMethodCalled, listTableFields.name));
|
|
43
|
-
return {
|
|
44
|
-
listTableFields: listTableFieldsDefinition,
|
|
45
|
-
context: {
|
|
46
|
-
meta: {
|
|
47
|
-
listTableFields: {
|
|
48
|
-
categories: ["table"],
|
|
49
|
-
type: "list",
|
|
50
|
-
itemType: "Field",
|
|
51
|
-
inputSchema: ListTableFieldsOptionsSchema,
|
|
52
|
-
outputSchema: FieldItemSchema,
|
|
53
|
-
resolvers: {
|
|
54
|
-
table: tableIdResolver,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
};
|
|
34
|
+
return { data: response.data.map(transformFieldItem) };
|
|
35
|
+
},
|
|
36
|
+
}));
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { FunctionOptions } from "../../../types/functions";
|
|
3
|
-
import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../../types/errors";
|
|
4
3
|
export declare const FieldTypeSchema: z.ZodEnum<{
|
|
5
4
|
string: "string";
|
|
6
5
|
number: "number";
|
|
@@ -197,7 +196,6 @@ export type ListTableFieldsOptions = (z.infer<typeof ListTableFieldsOptionsSchem
|
|
|
197
196
|
export interface ListTableFieldsResult {
|
|
198
197
|
data: FieldItem[];
|
|
199
198
|
}
|
|
200
|
-
export type ListTableFieldsError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
201
199
|
export interface ListTableFieldsSdkFunction {
|
|
202
200
|
listTableFields: (options: ListTableFieldsOptions) => Promise<ListTableFieldsResult>;
|
|
203
201
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTableFields/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTableFields/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAOhE,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+B1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAW7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAE3C,CAAC;AAEH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,gCAAgC,CACxC,CAAC;AAYF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAM1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAiBxD,eAAO,MAAM,4BAA4B;;;;;;iBAMsB,CAAC;AAGhE,QAAA,MAAM,sCAAsC;;;;iBAOF,CAAC;AAG3C,eAAO,MAAM,iCAAiC;;;;;;;;;;mBAEP,CAAC;AAGxC,MAAM,MAAM,sBAAsB,GAC9B,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,GAAG,eAAe,CAAC,GAChE,CAAC,IAAI,CACH,CAAC,CAAC,KAAK,CAAC,OAAO,sCAAsC,CAAC,EACtD,SAAS,GAAG,WAAW,CACxB,GAAG;IACF,uCAAuC;IACvC,OAAO,EAAE,CAAC,CAAC,KAAK,CACd,OAAO,sCAAsC,CAC9C,CAAC,SAAS,CAAC,CAAC;IACb,wCAAwC;IACxC,SAAS,CAAC,EAAE,CAAC,CAAC,KAAK,CACjB,OAAO,sCAAsC,CAC9C,CAAC,WAAW,CAAC,CAAC;CAChB,GAAG,eAAe,CAAC,CAAC;AAGzB,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,SAAS,EAAE,CAAC;CACnB;AAGD,MAAM,WAAW,0BAA0B;IACzC,eAAe,EAAE,CACf,OAAO,EAAE,sBAAsB,KAC5B,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACrC"}
|