@zapier/zapier-sdk 0.45.2 → 0.46.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +24 -7
- package/dist/api/schemas.d.ts +5 -5
- package/dist/api/types.d.ts +17 -0
- package/dist/api/types.d.ts.map +1 -1
- package/dist/auth.d.ts +27 -6
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +130 -92
- package/dist/cache.d.ts +50 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +47 -0
- package/dist/index.cjs +3108 -3695
- package/dist/index.d.mts +6735 -2188
- 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 +3105 -3696
- 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 +4 -6
- 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 +4 -6
- 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 +4 -15
- 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 +4 -6
- 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 +4 -6
- 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 +4 -14
- 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 +21 -23
- 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 +12 -14
- 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 +6 -8
- 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/schemas/Action.d.ts +1 -1
- package/dist/sdk.d.ts +2942 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/types/credentials.d.ts +2 -1
- package/dist/types/credentials.d.ts.map +1 -1
- package/dist/types/credentials.js +2 -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/properties.d.ts +1 -1
- package/dist/types/registry.d.ts +1 -1
- package/dist/types/registry.d.ts.map +1 -1
- package/dist/types/sdk.d.ts +2 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/dist/types/sdk.js +1 -0
- 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 +168 -0
- package/dist/utils/plugin-utils.d.ts.map +1 -0
- package/dist/utils/plugin-utils.js +132 -0
- package/package.json +2 -4
|
@@ -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,17 +1,15 @@
|
|
|
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";
|
|
7
6
|
boolean: "boolean";
|
|
8
|
-
link: "link";
|
|
9
|
-
email: "email";
|
|
10
|
-
uuid: "uuid";
|
|
11
7
|
text: "text";
|
|
12
8
|
datetime: "datetime";
|
|
13
9
|
decimal: "decimal";
|
|
14
10
|
json: "json";
|
|
11
|
+
email: "email";
|
|
12
|
+
link: "link";
|
|
15
13
|
multiple_string: "multiple_string";
|
|
16
14
|
labeled_string: "labeled_string";
|
|
17
15
|
multiple_labeled_string: "multiple_labeled_string";
|
|
@@ -20,6 +18,7 @@ export declare const FieldTypeSchema: z.ZodEnum<{
|
|
|
20
18
|
multiple_number: "multiple_number";
|
|
21
19
|
multiple_decimal: "multiple_decimal";
|
|
22
20
|
multiple_datetime: "multiple_datetime";
|
|
21
|
+
uuid: "uuid";
|
|
23
22
|
multiple_uuid: "multiple_uuid";
|
|
24
23
|
multiple_json: "multiple_json";
|
|
25
24
|
formula: "formula";
|
|
@@ -40,13 +39,12 @@ export declare const FieldApiItemSchema: z.ZodObject<{
|
|
|
40
39
|
string: "string";
|
|
41
40
|
number: "number";
|
|
42
41
|
boolean: "boolean";
|
|
43
|
-
link: "link";
|
|
44
|
-
email: "email";
|
|
45
|
-
uuid: "uuid";
|
|
46
42
|
text: "text";
|
|
47
43
|
datetime: "datetime";
|
|
48
44
|
decimal: "decimal";
|
|
49
45
|
json: "json";
|
|
46
|
+
email: "email";
|
|
47
|
+
link: "link";
|
|
50
48
|
multiple_string: "multiple_string";
|
|
51
49
|
labeled_string: "labeled_string";
|
|
52
50
|
multiple_labeled_string: "multiple_labeled_string";
|
|
@@ -55,6 +53,7 @@ export declare const FieldApiItemSchema: z.ZodObject<{
|
|
|
55
53
|
multiple_number: "multiple_number";
|
|
56
54
|
multiple_decimal: "multiple_decimal";
|
|
57
55
|
multiple_datetime: "multiple_datetime";
|
|
56
|
+
uuid: "uuid";
|
|
58
57
|
multiple_uuid: "multiple_uuid";
|
|
59
58
|
multiple_json: "multiple_json";
|
|
60
59
|
formula: "formula";
|
|
@@ -85,13 +84,12 @@ export declare const ListTableFieldsApiResponseSchema: z.ZodObject<{
|
|
|
85
84
|
string: "string";
|
|
86
85
|
number: "number";
|
|
87
86
|
boolean: "boolean";
|
|
88
|
-
link: "link";
|
|
89
|
-
email: "email";
|
|
90
|
-
uuid: "uuid";
|
|
91
87
|
text: "text";
|
|
92
88
|
datetime: "datetime";
|
|
93
89
|
decimal: "decimal";
|
|
94
90
|
json: "json";
|
|
91
|
+
email: "email";
|
|
92
|
+
link: "link";
|
|
95
93
|
multiple_string: "multiple_string";
|
|
96
94
|
labeled_string: "labeled_string";
|
|
97
95
|
multiple_labeled_string: "multiple_labeled_string";
|
|
@@ -100,6 +98,7 @@ export declare const ListTableFieldsApiResponseSchema: z.ZodObject<{
|
|
|
100
98
|
multiple_number: "multiple_number";
|
|
101
99
|
multiple_decimal: "multiple_decimal";
|
|
102
100
|
multiple_datetime: "multiple_datetime";
|
|
101
|
+
uuid: "uuid";
|
|
103
102
|
multiple_uuid: "multiple_uuid";
|
|
104
103
|
multiple_json: "multiple_json";
|
|
105
104
|
formula: "formula";
|
|
@@ -130,13 +129,12 @@ export declare const FieldItemSchema: z.ZodObject<{
|
|
|
130
129
|
string: "string";
|
|
131
130
|
number: "number";
|
|
132
131
|
boolean: "boolean";
|
|
133
|
-
link: "link";
|
|
134
|
-
email: "email";
|
|
135
|
-
uuid: "uuid";
|
|
136
132
|
text: "text";
|
|
137
133
|
datetime: "datetime";
|
|
138
134
|
decimal: "decimal";
|
|
139
135
|
json: "json";
|
|
136
|
+
email: "email";
|
|
137
|
+
link: "link";
|
|
140
138
|
multiple_string: "multiple_string";
|
|
141
139
|
labeled_string: "labeled_string";
|
|
142
140
|
multiple_labeled_string: "multiple_labeled_string";
|
|
@@ -145,6 +143,7 @@ export declare const FieldItemSchema: z.ZodObject<{
|
|
|
145
143
|
multiple_number: "multiple_number";
|
|
146
144
|
multiple_decimal: "multiple_decimal";
|
|
147
145
|
multiple_datetime: "multiple_datetime";
|
|
146
|
+
uuid: "uuid";
|
|
148
147
|
multiple_uuid: "multiple_uuid";
|
|
149
148
|
multiple_json: "multiple_json";
|
|
150
149
|
formula: "formula";
|
|
@@ -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"}
|
|
@@ -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
|
+
}));
|