@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.
Files changed (212) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/api/client.d.ts.map +1 -1
  3. package/dist/api/client.js +17 -6
  4. package/dist/api/types.d.ts +11 -0
  5. package/dist/api/types.d.ts.map +1 -1
  6. package/dist/index.cjs +3048 -3629
  7. package/dist/index.d.mts +6700 -2148
  8. package/dist/index.d.ts +5 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +1 -0
  11. package/dist/index.mjs +3045 -3630
  12. package/dist/plugins/api/index.d.ts +22 -10
  13. package/dist/plugins/api/index.d.ts.map +1 -1
  14. package/dist/plugins/api/index.js +4 -4
  15. package/dist/plugins/apps/index.d.ts +108 -7
  16. package/dist/plugins/apps/index.d.ts.map +1 -1
  17. package/dist/plugins/apps/index.js +3 -4
  18. package/dist/plugins/capabilities/index.d.ts +9 -6
  19. package/dist/plugins/capabilities/index.d.ts.map +1 -1
  20. package/dist/plugins/capabilities/index.js +3 -2
  21. package/dist/plugins/connections/index.d.ts +15 -9
  22. package/dist/plugins/connections/index.d.ts.map +1 -1
  23. package/dist/plugins/connections/index.js +3 -2
  24. package/dist/plugins/createClientCredentials/index.d.ts +26 -14
  25. package/dist/plugins/createClientCredentials/index.d.ts.map +1 -1
  26. package/dist/plugins/createClientCredentials/index.js +16 -39
  27. package/dist/plugins/createClientCredentials/schemas.d.ts +0 -2
  28. package/dist/plugins/createClientCredentials/schemas.d.ts.map +1 -1
  29. package/dist/plugins/deleteClientCredentials/index.d.ts +20 -14
  30. package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
  31. package/dist/plugins/deleteClientCredentials/index.js +18 -37
  32. package/dist/plugins/deleteClientCredentials/schemas.d.ts +0 -2
  33. package/dist/plugins/deleteClientCredentials/schemas.d.ts.map +1 -1
  34. package/dist/plugins/deprecated/authentications.d.ts +597 -41
  35. package/dist/plugins/deprecated/authentications.d.ts.map +1 -1
  36. package/dist/plugins/deprecated/authentications.js +9 -8
  37. package/dist/plugins/eventEmission/index.d.ts +9 -6
  38. package/dist/plugins/eventEmission/index.d.ts.map +1 -1
  39. package/dist/plugins/eventEmission/index.js +3 -2
  40. package/dist/plugins/fetch/index.d.ts +40 -17
  41. package/dist/plugins/fetch/index.d.ts.map +1 -1
  42. package/dist/plugins/fetch/index.js +6 -4
  43. package/dist/plugins/findFirstConnection/index.d.ts +109 -14
  44. package/dist/plugins/findFirstConnection/index.d.ts.map +1 -1
  45. package/dist/plugins/findFirstConnection/index.js +14 -26
  46. package/dist/plugins/findFirstConnection/schemas.d.ts +0 -2
  47. package/dist/plugins/findFirstConnection/schemas.d.ts.map +1 -1
  48. package/dist/plugins/findUniqueConnection/index.d.ts +109 -14
  49. package/dist/plugins/findUniqueConnection/index.d.ts.map +1 -1
  50. package/dist/plugins/findUniqueConnection/index.js +14 -26
  51. package/dist/plugins/findUniqueConnection/schemas.d.ts +0 -2
  52. package/dist/plugins/findUniqueConnection/schemas.d.ts.map +1 -1
  53. package/dist/plugins/getAction/index.d.ts +68 -15
  54. package/dist/plugins/getAction/index.d.ts.map +1 -1
  55. package/dist/plugins/getAction/index.js +21 -31
  56. package/dist/plugins/getAction/schemas.d.ts +0 -2
  57. package/dist/plugins/getAction/schemas.d.ts.map +1 -1
  58. package/dist/plugins/getApp/index.d.ts +140 -14
  59. package/dist/plugins/getApp/index.d.ts.map +1 -1
  60. package/dist/plugins/getApp/index.js +16 -38
  61. package/dist/plugins/getApp/schemas.d.ts +0 -2
  62. package/dist/plugins/getApp/schemas.d.ts.map +1 -1
  63. package/dist/plugins/getConnection/index.d.ts +50 -16
  64. package/dist/plugins/getConnection/index.d.ts.map +1 -1
  65. package/dist/plugins/getConnection/index.js +22 -29
  66. package/dist/plugins/getConnection/schemas.d.ts +0 -2
  67. package/dist/plugins/getConnection/schemas.d.ts.map +1 -1
  68. package/dist/plugins/getInputFieldsSchema/index.d.ts +59 -13
  69. package/dist/plugins/getInputFieldsSchema/index.d.ts.map +1 -1
  70. package/dist/plugins/getInputFieldsSchema/index.js +21 -32
  71. package/dist/plugins/getInputFieldsSchema/schemas.d.ts +0 -2
  72. package/dist/plugins/getInputFieldsSchema/schemas.d.ts.map +1 -1
  73. package/dist/plugins/getProfile/index.d.ts +25 -18
  74. package/dist/plugins/getProfile/index.d.ts.map +1 -1
  75. package/dist/plugins/getProfile/index.js +13 -26
  76. package/dist/plugins/getProfile/schemas.d.ts +0 -8
  77. package/dist/plugins/getProfile/schemas.d.ts.map +1 -1
  78. package/dist/plugins/getProfile/schemas.js +0 -1
  79. package/dist/plugins/listActions/index.d.ts +73 -23
  80. package/dist/plugins/listActions/index.d.ts.map +1 -1
  81. package/dist/plugins/listActions/index.js +25 -53
  82. package/dist/plugins/listActions/schemas.d.ts +0 -11
  83. package/dist/plugins/listActions/schemas.d.ts.map +1 -1
  84. package/dist/plugins/listApps/index.d.ts +121 -13
  85. package/dist/plugins/listApps/index.d.ts.map +1 -1
  86. package/dist/plugins/listApps/index.js +22 -31
  87. package/dist/plugins/listApps/schemas.d.ts +0 -2
  88. package/dist/plugins/listApps/schemas.d.ts.map +1 -1
  89. package/dist/plugins/listClientCredentials/index.d.ts +29 -16
  90. package/dist/plugins/listClientCredentials/index.d.ts.map +1 -1
  91. package/dist/plugins/listClientCredentials/index.js +17 -37
  92. package/dist/plugins/listClientCredentials/schemas.d.ts +0 -2
  93. package/dist/plugins/listClientCredentials/schemas.d.ts.map +1 -1
  94. package/dist/plugins/listConnections/index.d.ts +95 -17
  95. package/dist/plugins/listConnections/index.d.ts.map +1 -1
  96. package/dist/plugins/listConnections/index.js +25 -49
  97. package/dist/plugins/listConnections/schemas.d.ts +0 -2
  98. package/dist/plugins/listConnections/schemas.d.ts.map +1 -1
  99. package/dist/plugins/listInputFieldChoices/index.d.ts +77 -22
  100. package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
  101. package/dist/plugins/listInputFieldChoices/index.js +27 -50
  102. package/dist/plugins/listInputFieldChoices/schemas.d.ts +0 -2
  103. package/dist/plugins/listInputFieldChoices/schemas.d.ts.map +1 -1
  104. package/dist/plugins/listInputFields/index.d.ts +154 -22
  105. package/dist/plugins/listInputFields/index.d.ts.map +1 -1
  106. package/dist/plugins/listInputFields/index.js +28 -41
  107. package/dist/plugins/listInputFields/schemas.d.ts +0 -2
  108. package/dist/plugins/listInputFields/schemas.d.ts.map +1 -1
  109. package/dist/plugins/manifest/index.d.ts +40 -36
  110. package/dist/plugins/manifest/index.d.ts.map +1 -1
  111. package/dist/plugins/manifest/index.js +3 -2
  112. package/dist/plugins/registry/index.d.ts +11 -9
  113. package/dist/plugins/registry/index.d.ts.map +1 -1
  114. package/dist/plugins/registry/index.js +3 -2
  115. package/dist/plugins/request/index.d.ts +61 -15
  116. package/dist/plugins/request/index.d.ts.map +1 -1
  117. package/dist/plugins/request/index.js +14 -22
  118. package/dist/plugins/request/schemas.d.ts +0 -2
  119. package/dist/plugins/request/schemas.d.ts.map +1 -1
  120. package/dist/plugins/runAction/index.d.ts +137 -23
  121. package/dist/plugins/runAction/index.d.ts.map +1 -1
  122. package/dist/plugins/runAction/index.js +65 -78
  123. package/dist/plugins/runAction/schemas.d.ts +0 -10
  124. package/dist/plugins/runAction/schemas.d.ts.map +1 -1
  125. package/dist/plugins/tables/createTable/index.d.ts +43 -11
  126. package/dist/plugins/tables/createTable/index.d.ts.map +1 -1
  127. package/dist/plugins/tables/createTable/index.js +16 -44
  128. package/dist/plugins/tables/createTable/schemas.d.ts +0 -2
  129. package/dist/plugins/tables/createTable/schemas.d.ts.map +1 -1
  130. package/dist/plugins/tables/createTableFields/index.d.ts +54 -11
  131. package/dist/plugins/tables/createTableFields/index.d.ts.map +1 -1
  132. package/dist/plugins/tables/createTableFields/index.js +17 -41
  133. package/dist/plugins/tables/createTableFields/schemas.d.ts +0 -2
  134. package/dist/plugins/tables/createTableFields/schemas.d.ts.map +1 -1
  135. package/dist/plugins/tables/createTableRecords/index.d.ts +47 -11
  136. package/dist/plugins/tables/createTableRecords/index.d.ts.map +1 -1
  137. package/dist/plugins/tables/createTableRecords/index.js +17 -43
  138. package/dist/plugins/tables/createTableRecords/schemas.d.ts +0 -2
  139. package/dist/plugins/tables/createTableRecords/schemas.d.ts.map +1 -1
  140. package/dist/plugins/tables/deleteTable/index.d.ts +36 -13
  141. package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -1
  142. package/dist/plugins/tables/deleteTable/index.js +18 -40
  143. package/dist/plugins/tables/deleteTable/schemas.d.ts +0 -2
  144. package/dist/plugins/tables/deleteTable/schemas.d.ts.map +1 -1
  145. package/dist/plugins/tables/deleteTableFields/index.d.ts +36 -11
  146. package/dist/plugins/tables/deleteTableFields/index.d.ts.map +1 -1
  147. package/dist/plugins/tables/deleteTableFields/index.js +17 -39
  148. package/dist/plugins/tables/deleteTableFields/schemas.d.ts +0 -2
  149. package/dist/plugins/tables/deleteTableFields/schemas.d.ts.map +1 -1
  150. package/dist/plugins/tables/deleteTableRecords/index.d.ts +36 -11
  151. package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +1 -1
  152. package/dist/plugins/tables/deleteTableRecords/index.js +18 -41
  153. package/dist/plugins/tables/deleteTableRecords/schemas.d.ts +0 -2
  154. package/dist/plugins/tables/deleteTableRecords/schemas.d.ts.map +1 -1
  155. package/dist/plugins/tables/getTable/index.d.ts +43 -12
  156. package/dist/plugins/tables/getTable/index.d.ts.map +1 -1
  157. package/dist/plugins/tables/getTable/index.js +18 -43
  158. package/dist/plugins/tables/getTable/schemas.d.ts +0 -2
  159. package/dist/plugins/tables/getTable/schemas.d.ts.map +1 -1
  160. package/dist/plugins/tables/getTableRecord/index.d.ts +43 -11
  161. package/dist/plugins/tables/getTableRecord/index.d.ts.map +1 -1
  162. package/dist/plugins/tables/getTableRecord/index.js +18 -42
  163. package/dist/plugins/tables/getTableRecord/schemas.d.ts +0 -2
  164. package/dist/plugins/tables/getTableRecord/schemas.d.ts.map +1 -1
  165. package/dist/plugins/tables/listTableFields/index.d.ts +46 -11
  166. package/dist/plugins/tables/listTableFields/index.d.ts.map +1 -1
  167. package/dist/plugins/tables/listTableFields/index.js +17 -41
  168. package/dist/plugins/tables/listTableFields/schemas.d.ts +0 -2
  169. package/dist/plugins/tables/listTableFields/schemas.d.ts.map +1 -1
  170. package/dist/plugins/tables/listTableRecords/index.d.ts +66 -18
  171. package/dist/plugins/tables/listTableRecords/index.d.ts.map +1 -1
  172. package/dist/plugins/tables/listTableRecords/index.js +27 -50
  173. package/dist/plugins/tables/listTableRecords/schemas.d.ts +0 -2
  174. package/dist/plugins/tables/listTableRecords/schemas.d.ts.map +1 -1
  175. package/dist/plugins/tables/listTables/index.d.ts +53 -20
  176. package/dist/plugins/tables/listTables/index.d.ts.map +1 -1
  177. package/dist/plugins/tables/listTables/index.js +24 -51
  178. package/dist/plugins/tables/listTables/schemas.d.ts +0 -2
  179. package/dist/plugins/tables/listTables/schemas.d.ts.map +1 -1
  180. package/dist/plugins/tables/shared.d.ts +10 -0
  181. package/dist/plugins/tables/shared.d.ts.map +1 -0
  182. package/dist/plugins/tables/shared.js +9 -0
  183. package/dist/plugins/tables/updateTableRecords/index.d.ts +49 -11
  184. package/dist/plugins/tables/updateTableRecords/index.d.ts.map +1 -1
  185. package/dist/plugins/tables/updateTableRecords/index.js +20 -43
  186. package/dist/plugins/tables/updateTableRecords/schemas.d.ts +0 -2
  187. package/dist/plugins/tables/updateTableRecords/schemas.d.ts.map +1 -1
  188. package/dist/plugins/tables/utils.d.ts.map +1 -1
  189. package/dist/plugins/tables/utils.js +1 -0
  190. package/dist/registry.d.ts.map +1 -1
  191. package/dist/registry.js +21 -1
  192. package/dist/resolvers/actionKey.d.ts +1 -2
  193. package/dist/resolvers/actionKey.d.ts.map +1 -1
  194. package/dist/resolvers/actionType.d.ts +1 -2
  195. package/dist/resolvers/actionType.d.ts.map +1 -1
  196. package/dist/sdk.d.ts +2942 -2
  197. package/dist/sdk.d.ts.map +1 -1
  198. package/dist/types/errors.d.ts +13 -10
  199. package/dist/types/errors.d.ts.map +1 -1
  200. package/dist/types/errors.js +15 -12
  201. package/dist/types/functions.d.ts +18 -2
  202. package/dist/types/functions.d.ts.map +1 -1
  203. package/dist/types/plugin.d.ts +1 -1
  204. package/dist/types/plugin.d.ts.map +1 -1
  205. package/dist/types/registry.d.ts +1 -1
  206. package/dist/types/registry.d.ts.map +1 -1
  207. package/dist/utils/function-utils.d.ts +11 -12
  208. package/dist/utils/function-utils.d.ts.map +1 -1
  209. package/dist/utils/plugin-utils.d.ts +243 -0
  210. package/dist/utils/plugin-utils.d.ts.map +1 -0
  211. package/dist/utils/plugin-utils.js +232 -0
  212. package/package.json +2 -1
@@ -1,46 +1,23 @@
1
- import { createFunction } from "../../../utils/function-utils";
2
- import { DeleteTableRecordsOptionsSchema, DeleteTableRecordsOptionsInputSchema, } from "./schemas";
3
- import { createTelemetryCallback } from "../../../utils/telemetry-utils";
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
- export const deleteTableRecordsPlugin = (sdk) => {
7
- async function deleteTableRecords(options) {
8
- const { api } = sdk.context;
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
- success: true,
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;AAChE,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAS/B,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,MAAM,uBAAuB,GAC/B,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,kBAAkB,CAAC;AAEvB,MAAM,WAAW,6BAA6B;IAC5C,kBAAkB,EAAE,CAClB,OAAO,EAAE,yBAAyB,KAC/B,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACxC"}
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
- import type { Plugin } from "../../../types/plugin";
2
- import { GetTableOptionsSchema, type GetTableOptions, type TableItem } from "./schemas";
3
- import type { ApiPluginProvides } from "../../api";
4
- import type { EventEmissionProvides } from "../../eventEmission";
5
- export interface GetTablePluginProvides {
6
- getTable: (options: GetTableOptions) => Promise<{
7
- data: TableItem;
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 declare const getTablePlugin: Plugin<ApiPluginProvides & EventEmissionProvides, GetTablePluginProvides>;
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":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAEL,qBAAqB,EAGrB,KAAK,eAAe,EACpB,KAAK,SAAS,EACf,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAMjE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;IACrE,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,QAAQ,EAAE;gBACR,WAAW,EAAE,OAAO,qBAAqB,CAAC;aAC3C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,iBAAiB,GAAG,qBAAqB,EACzC,sBAAsB,CA8DvB,CAAC"}
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 { createFunction } from "../../../utils/function-utils";
2
- import { GetTableApiResponseSchema, GetTableOptionsSchema, GetTableOptionsInputSchema, TableItemSchema, } from "./schemas";
3
- import { createTelemetryCallback } from "../../../utils/telemetry-utils";
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
- export const getTablePlugin = (sdk) => {
8
- async function getTable(options) {
9
- const { api } = sdk.context;
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
- data: transformTableItem(response.data),
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;AACxB,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAE/B,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,MA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,CAAA;KAAE,CAAC,CAAC;CACtE"}
@@ -1,16 +1,48 @@
1
- import type { Plugin } from "../../../types/plugin";
2
- import { GetTableRecordOptionsSchema, type GetTableRecordOptions, type GetTableRecordResult } from "./schemas";
3
- import type { ApiPluginProvides } from "../../api";
4
- import type { EventEmissionProvides } from "../../eventEmission";
5
- export interface GetTableRecordPluginProvides {
6
- getTableRecord: (options: GetTableRecordOptions) => Promise<GetTableRecordResult>;
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 declare const getTableRecordPlugin: Plugin<ApiPluginProvides & EventEmissionProvides, GetTableRecordPluginProvides>;
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":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EACL,2BAA2B,EAI3B,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAC1B,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAQjE,MAAM,WAAW,4BAA4B;IAC3C,cAAc,EAAE,CACd,OAAO,EAAE,qBAAqB,KAC3B,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACnC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,cAAc,EAAE;gBACd,WAAW,EAAE,OAAO,2BAA2B,CAAC;aACjD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,oBAAoB,EAAE,MAAM,CACvC,iBAAiB,GAAG,qBAAqB,EACzC,4BAA4B,CA8E7B,CAAC"}
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 { createFunction } from "../../../utils/function-utils";
2
- import { GetTableRecordOptionsSchema, GetTableRecordOptionsInputSchema, GetTableRecordApiResponseSchema, RecordItemSchema, } from "./schemas";
3
- import { createTelemetryCallback } from "../../../utils/telemetry-utils";
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 { transformRecordItem } from "../utils";
9
- export const getTableRecordPlugin = (sdk) => {
10
- async function getTableRecord(options) {
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
- const getTableRecordDefinition = createFunction(getTableRecord, GetTableRecordOptionsInputSchema, createTelemetryCallback(sdk.context.eventEmission.emitMethodCalled, getTableRecord.name));
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;AAChE,OAAO,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAQ/B,eAAO,MAAM,mBAAmB;;;;;;;;;iBAS9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,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xC,cAAc,EAAE,CACd,OAAO,EAAE,qBAAqB,KAC3B,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACpC"}
@@ -1,16 +1,51 @@
1
- import type { Plugin } from "../../../types/plugin";
2
- import { ListTableFieldsOptionsSchema, type ListTableFieldsOptions, type ListTableFieldsResult } from "./schemas";
3
- import type { ApiPluginProvides } from "../../api";
4
- import type { EventEmissionProvides } from "../../eventEmission";
5
- export interface ListTableFieldsPluginProvides {
6
- listTableFields: (options: ListTableFieldsOptions) => Promise<ListTableFieldsResult>;
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 declare const listTableFieldsPlugin: Plugin<ApiPluginProvides & EventEmissionProvides, ListTableFieldsPluginProvides>;
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":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EACL,4BAA4B,EAI5B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC3B,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAMjE,MAAM,WAAW,6BAA6B;IAC5C,eAAe,EAAE,CACf,OAAO,EAAE,sBAAsB,KAC5B,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACpC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,eAAe,EAAE;gBACf,WAAW,EAAE,OAAO,4BAA4B,CAAC;aAClD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,qBAAqB,EAAE,MAAM,CACxC,iBAAiB,GAAG,qBAAqB,EACzC,6BAA6B,CA+E9B,CAAC"}
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 { createFunction } from "../../../utils/function-utils";
2
- import { ListTableFieldsOptionsSchema, ListTableFieldsOptionsInputSchema, ListTableFieldsApiResponseSchema, FieldItemSchema, } from "./schemas";
3
- import { createTelemetryCallback } from "../../../utils/telemetry-utils";
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
- export const listTableFieldsPlugin = (sdk) => {
8
- async function listTableFields(options) {
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
- data: response.data.map(transformFieldItem),
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":"AAA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