@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,24 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
export declare const listTableRecordsPlugin: (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>;
|
|
14
22
|
};
|
|
23
|
+
}) => {
|
|
24
|
+
listTableRecords: (options?: (({
|
|
25
|
+
table: string;
|
|
26
|
+
keyMode: "names" | "ids";
|
|
27
|
+
filters?: {
|
|
28
|
+
fieldKey: string;
|
|
29
|
+
operator: "in" | "contains" | "gt" | "gte" | "lt" | "lte" | "search" | "exact" | "different" | "icontains" | "range" | "isnull" | "startswith" | "is_within";
|
|
30
|
+
value?: unknown;
|
|
31
|
+
}[] | undefined;
|
|
32
|
+
sort?: {
|
|
33
|
+
fieldKey: string;
|
|
34
|
+
direction: "asc" | "desc";
|
|
35
|
+
} | undefined;
|
|
36
|
+
pageSize?: number | undefined;
|
|
37
|
+
maxItems?: number | undefined;
|
|
38
|
+
cursor?: string | undefined;
|
|
39
|
+
} | {
|
|
40
|
+
tableId: string;
|
|
41
|
+
keyMode: "names" | "ids";
|
|
42
|
+
filters?: {
|
|
43
|
+
fieldKey: string;
|
|
44
|
+
operator: "in" | "contains" | "gt" | "gte" | "lt" | "lte" | "search" | "exact" | "different" | "icontains" | "range" | "isnull" | "startswith" | "is_within";
|
|
45
|
+
value?: unknown;
|
|
46
|
+
}[] | undefined;
|
|
47
|
+
sort?: {
|
|
48
|
+
fieldKey: string;
|
|
49
|
+
direction: "asc" | "desc";
|
|
50
|
+
} | undefined;
|
|
51
|
+
pageSize?: number | undefined;
|
|
52
|
+
maxItems?: number | undefined;
|
|
53
|
+
cursor?: string | undefined;
|
|
54
|
+
}) & {
|
|
55
|
+
cursor?: string;
|
|
56
|
+
pageSize?: number;
|
|
57
|
+
maxItems?: number;
|
|
58
|
+
}) | undefined) => import("../../..").PaginatedSdkResult<{
|
|
59
|
+
id: string;
|
|
60
|
+
data: Record<string, unknown>;
|
|
61
|
+
created_at: string;
|
|
62
|
+
edited_at: string;
|
|
63
|
+
}>;
|
|
64
|
+
} & {
|
|
15
65
|
context: {
|
|
16
66
|
meta: {
|
|
17
|
-
listTableRecords:
|
|
18
|
-
inputSchema: typeof ListTableRecordsOptionsSchema;
|
|
19
|
-
};
|
|
67
|
+
listTableRecords: import("../../..").PluginMeta;
|
|
20
68
|
};
|
|
21
69
|
};
|
|
22
|
-
}
|
|
23
|
-
export
|
|
70
|
+
};
|
|
71
|
+
export type ListTableRecordsPluginProvides = ReturnType<typeof listTableRecordsPlugin>;
|
|
24
72
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTableRecords/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTableRecords/index.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmFlC,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,UAAU,CACrD,OAAO,sBAAsB,CAC9B,CAAC"}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { stripPageSuffix } from "../../../utils/string-utils";
|
|
5
|
-
import { ZapierAuthenticationError } from "../../../types/errors";
|
|
1
|
+
import { definePlugin } from "../../../utils/plugin-utils";
|
|
2
|
+
import { createPaginatedPluginMethod } from "../../../utils/plugin-utils";
|
|
3
|
+
import { ListTableRecordsApiResponseSchema, ListTableRecordsOptionsInputSchema, RecordItemSchema, } from "./schemas";
|
|
6
4
|
import { tableIdResolver, tableFiltersResolver, tableSortResolver, } from "../../../resolvers";
|
|
7
5
|
import { tableRecordFormatter } from "../../../formatters";
|
|
8
6
|
import { createFieldKeyTranslator, transformRecordItem, throwOnResponseErrors, } from "../utils";
|
|
9
7
|
import { DEFAULT_PAGE_SIZE } from "../../../constants";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
import { tablesDefaults } from "../shared";
|
|
9
|
+
export const listTableRecordsPlugin = definePlugin((sdk) => createPaginatedPluginMethod(sdk, {
|
|
10
|
+
...tablesDefaults,
|
|
11
|
+
name: "listTableRecords",
|
|
12
|
+
type: "list",
|
|
13
|
+
itemType: "Record",
|
|
14
|
+
inputSchema: ListTableRecordsOptionsInputSchema,
|
|
15
|
+
outputSchema: RecordItemSchema,
|
|
16
|
+
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
17
|
+
resolvers: {
|
|
18
|
+
table: tableIdResolver,
|
|
19
|
+
filters: tableFiltersResolver,
|
|
20
|
+
sort: tableSortResolver,
|
|
21
|
+
},
|
|
22
|
+
formatter: tableRecordFormatter,
|
|
23
|
+
handler: async ({ sdk, options, }) => {
|
|
18
24
|
const { api } = sdk.context;
|
|
19
25
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
20
26
|
const translator = await createFieldKeyTranslator({
|
|
@@ -49,50 +55,21 @@ export const listTableRecordsPlugin = (sdk) => {
|
|
|
49
55
|
}
|
|
50
56
|
const rawResponse = await api.post(`/tables/api/v1/tables/${tableId}/records/query`, body, {
|
|
51
57
|
searchParams: { allow_nested_queries: "true" },
|
|
52
|
-
customErrorHandler: ({ status }) => {
|
|
53
|
-
if (status === 401) {
|
|
54
|
-
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to access this table or may be expired. (HTTP ${status})`, { statusCode: status });
|
|
55
|
-
}
|
|
56
|
-
if (status === 403) {
|
|
57
|
-
return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to access this table. (HTTP ${status})`, { statusCode: status });
|
|
58
|
-
}
|
|
59
|
-
if (status === 404) {
|
|
60
|
-
return new Error(`Table not found: ${tableId}`);
|
|
61
|
-
}
|
|
62
|
-
return undefined;
|
|
63
|
-
},
|
|
64
58
|
authRequired: true,
|
|
59
|
+
resource: { type: "table", id: tableId },
|
|
65
60
|
});
|
|
66
61
|
throwOnResponseErrors(rawResponse);
|
|
67
62
|
const response = ListTableRecordsApiResponseSchema.parse(rawResponse);
|
|
63
|
+
const pagination = response.meta?.pagination;
|
|
64
|
+
const nextCursor = pagination?.has_more && pagination.end_cursor
|
|
65
|
+
? pagination.end_cursor
|
|
66
|
+
: undefined;
|
|
68
67
|
return {
|
|
69
68
|
data: response.data.map((item) => ({
|
|
70
69
|
...transformRecordItem(item),
|
|
71
70
|
data: translator.translateOutput(item.data),
|
|
72
71
|
})),
|
|
73
|
-
nextCursor
|
|
72
|
+
nextCursor,
|
|
74
73
|
};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const listTableRecordsDefinition = createPaginatedFunction(listTableRecordsPage, ListTableRecordsOptionsInputSchema, createTelemetryCallback(sdk.context.eventEmission.emitMethodCalled, methodName), methodName, DEFAULT_PAGE_SIZE);
|
|
78
|
-
return {
|
|
79
|
-
listTableRecords: listTableRecordsDefinition,
|
|
80
|
-
context: {
|
|
81
|
-
meta: {
|
|
82
|
-
listTableRecords: {
|
|
83
|
-
categories: ["table"],
|
|
84
|
-
type: "list",
|
|
85
|
-
itemType: "Record",
|
|
86
|
-
inputSchema: ListTableRecordsOptionsSchema,
|
|
87
|
-
outputSchema: RecordItemSchema,
|
|
88
|
-
resolvers: {
|
|
89
|
-
table: tableIdResolver,
|
|
90
|
-
filters: tableFiltersResolver,
|
|
91
|
-
sort: tableSortResolver,
|
|
92
|
-
},
|
|
93
|
-
formatter: tableRecordFormatter,
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
};
|
|
74
|
+
},
|
|
75
|
+
}));
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { PaginatedSdkFunction } from "../../../types/functions";
|
|
3
|
-
import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../../types/errors";
|
|
4
3
|
import { RecordItemSchema, type RecordItem } from "../getTableRecord/schemas";
|
|
5
4
|
export { RecordItemSchema };
|
|
6
5
|
export type { RecordItem };
|
|
@@ -230,7 +229,6 @@ export interface ListTableRecordsPage {
|
|
|
230
229
|
data: RecordItem[];
|
|
231
230
|
nextCursor?: string;
|
|
232
231
|
}
|
|
233
|
-
export type ListTableRecordsError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
234
232
|
export interface ListTableRecordsSdkFunction {
|
|
235
233
|
listTableRecords: PaginatedSdkFunction<ListTableRecordsOptions, RecordItem>;
|
|
236
234
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTableRecords/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTableRecords/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,EAEL,gBAAgB,EAChB,KAAK,UAAU,EAChB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC5B,YAAY,EAAE,UAAU,EAAE,CAAC;AAE3B,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;iBAc5C,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,iCAAiC,CACzC,CAAC;AAEF,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;EAexB,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;iBAIzB,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAIpE,eAAO,MAAM,mBAAmB;;;;;;iBAK9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AA2BhE,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAMA,CAAC;AAG3C,QAAA,MAAM,uCAAuC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAOf,CAAC;AAG/B,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAKP,CAAC;AAGzC,MAAM,MAAM,uBAAuB,GAC/B,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,GAC7C,CAAC,IAAI,CACH,CAAC,CAAC,KAAK,CAAC,OAAO,uCAAuC,CAAC,EACvD,SAAS,CACV,GAAG;IACF,uCAAuC;IACvC,OAAO,EAAE,CAAC,CAAC,KAAK,CACd,OAAO,uCAAuC,CAC/C,CAAC,SAAS,CAAC,CAAC;CACd,CAAC,CAAC;AAEP,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,2BAA2B;IAC1C,gBAAgB,EAAE,oBAAoB,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC;CAC7E"}
|
|
@@ -1,27 +1,60 @@
|
|
|
1
|
-
import type { Plugin } from "../../../types/plugin";
|
|
2
|
-
import { ListTablesOptionsSchema, type ListTablesOptions, type TableItem } from "./schemas";
|
|
3
|
-
import type { ApiPluginProvides } from "../../api";
|
|
4
|
-
import type { EventEmissionProvides } from "../../eventEmission";
|
|
5
1
|
import type { CapabilitiesContext } from "../../capabilities";
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
export declare const listTablesPlugin: (sdk: {
|
|
3
|
+
context: {
|
|
4
|
+
api: import("../../../api").ApiClient;
|
|
5
|
+
resolveCredentials: () => Promise<string | {
|
|
6
|
+
clientId: string;
|
|
7
|
+
clientSecret: string;
|
|
8
|
+
type?: "client_credentials" | undefined;
|
|
9
|
+
baseUrl?: string | undefined;
|
|
10
|
+
scope?: string | undefined;
|
|
11
|
+
} | {
|
|
12
|
+
clientId: string;
|
|
13
|
+
type?: "pkce" | undefined;
|
|
14
|
+
baseUrl?: string | undefined;
|
|
15
|
+
scope?: string | undefined;
|
|
16
|
+
} | undefined>;
|
|
15
17
|
};
|
|
18
|
+
} & {
|
|
19
|
+
context: import("../../eventEmission").EventEmissionContext;
|
|
20
|
+
} & {
|
|
21
|
+
context: CapabilitiesContext;
|
|
22
|
+
} & {
|
|
23
|
+
context: {
|
|
24
|
+
meta: Record<string, import("../../..").PluginMeta>;
|
|
25
|
+
};
|
|
26
|
+
}) => {
|
|
27
|
+
listTables: (options?: ({
|
|
28
|
+
tables?: string[] | undefined;
|
|
29
|
+
tableIds?: string[] | undefined;
|
|
30
|
+
kind?: "table" | "virtual_table" | "both" | undefined;
|
|
31
|
+
search?: string | undefined;
|
|
32
|
+
owner?: string | undefined;
|
|
33
|
+
includeShared?: boolean | undefined;
|
|
34
|
+
pageSize?: number | undefined;
|
|
35
|
+
maxItems?: number | undefined;
|
|
36
|
+
cursor?: string | undefined;
|
|
37
|
+
} & {
|
|
38
|
+
cursor?: string;
|
|
39
|
+
pageSize?: number;
|
|
40
|
+
maxItems?: number;
|
|
41
|
+
}) | undefined) => import("../../..").PaginatedSdkResult<{
|
|
42
|
+
id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
created_at: string;
|
|
45
|
+
edited_at: string;
|
|
46
|
+
kind: "table" | "virtual_table";
|
|
47
|
+
account_id: string;
|
|
48
|
+
profile_id: string;
|
|
49
|
+
description?: string | undefined;
|
|
50
|
+
parent_table_id?: string | undefined;
|
|
51
|
+
}>;
|
|
52
|
+
} & {
|
|
16
53
|
context: {
|
|
17
54
|
meta: {
|
|
18
|
-
listTables:
|
|
19
|
-
inputSchema: typeof ListTablesOptionsSchema;
|
|
20
|
-
};
|
|
55
|
+
listTables: import("../../..").PluginMeta;
|
|
21
56
|
};
|
|
22
57
|
};
|
|
23
|
-
}
|
|
24
|
-
export
|
|
25
|
-
context: CapabilitiesContext;
|
|
26
|
-
}, ListTablesPluginProvides>;
|
|
58
|
+
};
|
|
59
|
+
export type ListTablesPluginProvides = ReturnType<typeof listTablesPlugin>;
|
|
27
60
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTables/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTables/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAK9D,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;aAGY,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoE3D,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { definePlugin } from "../../../utils/plugin-utils";
|
|
2
|
+
import { createPaginatedPluginMethod } from "../../../utils/plugin-utils";
|
|
2
3
|
import { ListTablesApiResponseSchema, ListTablesOptionsSchema, TableItemSchema, } from "./schemas";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { ZapierAuthenticationError, ZapierValidationError, } from "../../../types/errors";
|
|
4
|
+
import { extractCursor } from "../../../utils/function-utils";
|
|
5
|
+
import { ZapierValidationError } from "../../../types/errors";
|
|
6
6
|
import { transformTableItem } from "../utils";
|
|
7
7
|
import { DEFAULT_PAGE_SIZE } from "../../../constants";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return undefined;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
export const listTablesPlugin = (sdk) => {
|
|
22
|
-
async function listTablesPage(options) {
|
|
8
|
+
import { tablesDefaults } from "../shared";
|
|
9
|
+
export const listTablesPlugin = definePlugin((sdk) => createPaginatedPluginMethod(sdk, {
|
|
10
|
+
...tablesDefaults,
|
|
11
|
+
name: "listTables",
|
|
12
|
+
type: "list",
|
|
13
|
+
itemType: "Table",
|
|
14
|
+
inputSchema: ListTablesOptionsSchema,
|
|
15
|
+
outputSchema: TableItemSchema,
|
|
16
|
+
defaultPageSize: DEFAULT_PAGE_SIZE,
|
|
17
|
+
handler: async ({ sdk, options }) => {
|
|
23
18
|
if (options.includeShared) {
|
|
24
19
|
await sdk.context.checkCapability("canIncludeSharedTables");
|
|
25
20
|
}
|
|
@@ -28,17 +23,19 @@ export const listTablesPlugin = (sdk) => {
|
|
|
28
23
|
if (options.pageSize !== undefined) {
|
|
29
24
|
searchParams.limit = options.pageSize.toString();
|
|
30
25
|
}
|
|
31
|
-
const tableIds = "tables" in options && options.tables
|
|
26
|
+
const tableIds = "tables" in options && options.tables
|
|
27
|
+
? options.tables
|
|
28
|
+
: options.tableIds;
|
|
32
29
|
if (tableIds && tableIds.length > 0) {
|
|
33
30
|
searchParams.ids = tableIds.join(",");
|
|
34
31
|
}
|
|
35
|
-
if (options
|
|
32
|
+
if (options.kind) {
|
|
36
33
|
searchParams.kind = options.kind;
|
|
37
34
|
}
|
|
38
|
-
if (options
|
|
35
|
+
if (options.search) {
|
|
39
36
|
searchParams.q = options.search;
|
|
40
37
|
}
|
|
41
|
-
if (options
|
|
38
|
+
if (options.owner && options.owner !== "me" && !options.includeShared) {
|
|
42
39
|
throw new ZapierValidationError('The "owner" option requires "includeShared" to be true. Without includeShared, only your own tables are returned.');
|
|
43
40
|
}
|
|
44
41
|
const owner = options.includeShared ? options.owner : "me";
|
|
@@ -58,37 +55,13 @@ export const listTablesPlugin = (sdk) => {
|
|
|
58
55
|
}
|
|
59
56
|
const rawResponse = await api.get("/tables/api/v1/tables", {
|
|
60
57
|
searchParams,
|
|
61
|
-
customErrorHandler: ({ status }) => {
|
|
62
|
-
if (status === 401) {
|
|
63
|
-
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to list tables or may be expired. (HTTP ${status})`, { statusCode: status });
|
|
64
|
-
}
|
|
65
|
-
if (status === 403) {
|
|
66
|
-
return new ZapierAuthenticationError(`Access forbidden. Your token may not have the required scopes to list tables. (HTTP ${status})`, { statusCode: status });
|
|
67
|
-
}
|
|
68
|
-
return undefined;
|
|
69
|
-
},
|
|
70
58
|
authRequired: true,
|
|
71
59
|
});
|
|
72
60
|
const response = ListTablesApiResponseSchema.parse(rawResponse);
|
|
73
61
|
return {
|
|
74
62
|
data: response.data.map(transformTableItem),
|
|
75
|
-
|
|
63
|
+
links: response.links,
|
|
76
64
|
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return {
|
|
81
|
-
listTables: listTablesDefinition,
|
|
82
|
-
context: {
|
|
83
|
-
meta: {
|
|
84
|
-
listTables: {
|
|
85
|
-
categories: ["table"],
|
|
86
|
-
type: "list",
|
|
87
|
-
itemType: "Table",
|
|
88
|
-
inputSchema: ListTablesOptionsSchema,
|
|
89
|
-
outputSchema: TableItemSchema,
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
};
|
|
65
|
+
},
|
|
66
|
+
extractCursor: (response) => extractCursor(response.links),
|
|
67
|
+
}));
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { PaginatedSdkFunction } from "../../../types/functions";
|
|
3
|
-
import type { ZapierAuthenticationError, ZapierApiError, ZapierValidationError, ZapierUnknownError } from "../../../types/errors";
|
|
4
3
|
export declare const TableApiItemSchema: z.ZodObject<{
|
|
5
4
|
id: z.ZodString;
|
|
6
5
|
name: z.ZodString;
|
|
@@ -80,7 +79,6 @@ export interface ListTablesPage {
|
|
|
80
79
|
data: TableItem[];
|
|
81
80
|
nextCursor?: string;
|
|
82
81
|
}
|
|
83
|
-
export type ListTablesError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
84
82
|
export interface ListTablesSdkFunction {
|
|
85
83
|
listTables: PaginatedSdkFunction<ListTablesOptions, TableItem>;
|
|
86
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTables/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/listTables/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;iBAa7B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;iBAOtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,eAAO,MAAM,eAAe;;;;;;;;;;;;;iBAU1B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;iBAwC0B,CAAC;AAE/D,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,EACvC,UAAU,CACX,GAAG;IACF,wCAAwC;IACxC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC,UAAU,CAAC,CAAC;CAChE,CAAC;AAGF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,SAAS,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,oBAAoB,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC;CAChE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Method-meta defaults shared across every plugin in the `tables/` domain.
|
|
3
|
+
* Each plugin spreads `...tablesDefaults` into its `createPluginMethod` /
|
|
4
|
+
* `createPaginatedPluginMethod` config so we declare `categories: ["table"]`
|
|
5
|
+
* once instead of 12 times.
|
|
6
|
+
*/
|
|
7
|
+
export declare const tablesDefaults: {
|
|
8
|
+
categories: string[];
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../../src/plugins/tables/shared.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,cAAc;;CAEI,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Method-meta defaults shared across every plugin in the `tables/` domain.
|
|
3
|
+
* Each plugin spreads `...tablesDefaults` into its `createPluginMethod` /
|
|
4
|
+
* `createPaginatedPluginMethod` config so we declare `categories: ["table"]`
|
|
5
|
+
* once instead of 12 times.
|
|
6
|
+
*/
|
|
7
|
+
export const tablesDefaults = {
|
|
8
|
+
categories: ["table"],
|
|
9
|
+
};
|
|
@@ -1,16 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export declare const updateTableRecordsPlugin: (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
|
+
updateTableRecords: (options?: {
|
|
25
|
+
table: string;
|
|
26
|
+
records: {
|
|
27
|
+
id: string;
|
|
28
|
+
data: Record<string, unknown>;
|
|
29
|
+
}[];
|
|
30
|
+
keyMode: "names" | "ids";
|
|
31
|
+
} | {
|
|
32
|
+
tableId: string;
|
|
33
|
+
records: {
|
|
34
|
+
id: string;
|
|
35
|
+
data: Record<string, unknown>;
|
|
36
|
+
}[];
|
|
37
|
+
keyMode: "names" | "ids";
|
|
38
|
+
} | undefined) => Promise<{
|
|
39
|
+
data: {
|
|
40
|
+
data: Record<string, unknown>;
|
|
41
|
+
id: string;
|
|
42
|
+
created_at: string;
|
|
43
|
+
edited_at: string;
|
|
44
|
+
}[];
|
|
45
|
+
}>;
|
|
46
|
+
} & {
|
|
7
47
|
context: {
|
|
8
48
|
meta: {
|
|
9
|
-
updateTableRecords:
|
|
10
|
-
inputSchema: typeof UpdateTableRecordsOptionsSchema;
|
|
11
|
-
};
|
|
49
|
+
updateTableRecords: import("../../..").PluginMeta;
|
|
12
50
|
};
|
|
13
51
|
};
|
|
14
|
-
}
|
|
15
|
-
export
|
|
52
|
+
};
|
|
53
|
+
export type UpdateTableRecordsPluginProvides = ReturnType<typeof updateTableRecordsPlugin>;
|
|
16
54
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/updateTableRecords/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/tables/updateTableRecords/index.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDpC,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG,UAAU,CACvD,OAAO,wBAAwB,CAChC,CAAC"}
|
|
@@ -1,12 +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 { UpdateTableRecordsOptionsInputSchema, UpdateTableRecordsApiResponseSchema, RecordItemSchema, } from "./schemas";
|
|
5
4
|
import { tableIdResolver, tableUpdateRecordsResolver, } from "../../../resolvers";
|
|
6
5
|
import { tableRecordFormatter } from "../../../formatters";
|
|
7
6
|
import { createFieldKeyTranslator, transformRecordItem, throwOnRecordErrors, throwOnResponseErrors, } from "../utils";
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import { tablesDefaults } from "../shared";
|
|
8
|
+
export const updateTableRecordsPlugin = definePlugin((sdk) => createPluginMethod(sdk, {
|
|
9
|
+
...tablesDefaults,
|
|
10
|
+
name: "updateTableRecords",
|
|
11
|
+
type: "update",
|
|
12
|
+
itemType: "Record",
|
|
13
|
+
inputSchema: UpdateTableRecordsOptionsInputSchema,
|
|
14
|
+
outputSchema: RecordItemSchema,
|
|
15
|
+
resolvers: {
|
|
16
|
+
table: tableIdResolver,
|
|
17
|
+
records: tableUpdateRecordsResolver,
|
|
18
|
+
},
|
|
19
|
+
formatter: tableRecordFormatter,
|
|
20
|
+
handler: async ({ sdk, options }) => {
|
|
10
21
|
const { api } = sdk.context;
|
|
11
22
|
const tableId = "table" in options ? options.table : options.tableId;
|
|
12
23
|
const translator = await createFieldKeyTranslator({
|
|
@@ -19,21 +30,7 @@ export const updateTableRecordsPlugin = (sdk) => {
|
|
|
19
30
|
id: record.id,
|
|
20
31
|
data: translator.translateInput(record.data),
|
|
21
32
|
})),
|
|
22
|
-
}, {
|
|
23
|
-
customErrorHandler: ({ status }) => {
|
|
24
|
-
if (status === 401) {
|
|
25
|
-
return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to update records 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 update records. (HTTP ${status})`, { statusCode: status });
|
|
29
|
-
}
|
|
30
|
-
if (status === 404) {
|
|
31
|
-
return new Error(`Table not found: ${tableId}`);
|
|
32
|
-
}
|
|
33
|
-
return undefined;
|
|
34
|
-
},
|
|
35
|
-
authRequired: true,
|
|
36
|
-
});
|
|
33
|
+
}, { authRequired: true, resource: { type: "table", id: tableId } });
|
|
37
34
|
throwOnResponseErrors(rawResponse);
|
|
38
35
|
const response = UpdateTableRecordsApiResponseSchema.parse(rawResponse);
|
|
39
36
|
for (const changeset of response.data) {
|
|
@@ -45,25 +42,5 @@ export const updateTableRecordsPlugin = (sdk) => {
|
|
|
45
42
|
data: translator.translateOutput(changeset.new.data),
|
|
46
43
|
})),
|
|
47
44
|
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
updateTableRecords: updateTableRecordsDefinition,
|
|
52
|
-
context: {
|
|
53
|
-
meta: {
|
|
54
|
-
updateTableRecords: {
|
|
55
|
-
categories: ["table"],
|
|
56
|
-
type: "update",
|
|
57
|
-
itemType: "Record",
|
|
58
|
-
inputSchema: UpdateTableRecordsOptionsSchema,
|
|
59
|
-
outputSchema: RecordItemSchema,
|
|
60
|
-
resolvers: {
|
|
61
|
-
table: tableIdResolver,
|
|
62
|
-
records: tableUpdateRecordsResolver,
|
|
63
|
-
},
|
|
64
|
-
formatter: tableRecordFormatter,
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
};
|
|
45
|
+
},
|
|
46
|
+
}));
|
|
@@ -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
|
import { RecordItemSchema, type RecordItem } from "../getTableRecord/schemas";
|
|
5
4
|
export { RecordItemSchema };
|
|
6
5
|
export type { RecordItem };
|
|
@@ -91,7 +90,6 @@ export type UpdateTableRecordsOptions = (z.infer<typeof UpdateTableRecordsOption
|
|
|
91
90
|
export interface UpdateTableRecordsResult {
|
|
92
91
|
data: RecordItem[];
|
|
93
92
|
}
|
|
94
|
-
export type UpdateTableRecordsError = ZapierAuthenticationError | ZapierApiError | ZapierValidationError | ZapierUnknownError;
|
|
95
93
|
export interface UpdateTableRecordsSdkFunction {
|
|
96
94
|
updateTableRecords: (options: UpdateTableRecordsOptions) => Promise<UpdateTableRecordsResult>;
|
|
97
95
|
}
|