@zapier/zapier-sdk 0.46.0 → 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.
Files changed (212) hide show
  1. package/CHANGELOG.md +6 -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 +2994 -3633
  7. package/dist/index.d.mts +6532 -2055
  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 +2992 -3634
  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 +168 -0
  210. package/dist/utils/plugin-utils.d.ts.map +1 -0
  211. package/dist/utils/plugin-utils.js +132 -0
  212. package/package.json +1 -1
@@ -1,24 +1,72 @@
1
- import type { Plugin } from "../../../types/plugin";
2
- import { ListTableRecordsOptionsSchema, type ListTableRecordsOptions, type RecordItem } from "./schemas";
3
- import type { ApiPluginProvides } from "../../api";
4
- import type { EventEmissionProvides } from "../../eventEmission";
5
- export interface ListTableRecordsPluginProvides {
6
- listTableRecords: (options: ListTableRecordsOptions) => Promise<{
7
- data: RecordItem[];
8
- nextCursor?: string;
9
- }> & AsyncIterable<{
10
- data: RecordItem[];
11
- nextCursor?: string;
12
- }> & {
13
- items(): AsyncIterable<RecordItem>;
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 declare const listTableRecordsPlugin: Plugin<ApiPluginProvides & EventEmissionProvides, ListTableRecordsPluginProvides>;
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":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAEL,6BAA6B,EAG7B,KAAK,uBAAuB,EAC5B,KAAK,UAAU,EAChB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AA6BjE,MAAM,WAAW,8BAA8B;IAC7C,gBAAgB,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,OAAO,CAAC;QAC9D,IAAI,EAAE,UAAU,EAAE,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,UAAU,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAC3D,KAAK,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;KACpC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,gBAAgB,EAAE;gBAChB,WAAW,EAAE,OAAO,6BAA6B,CAAC;aACnD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,sBAAsB,EAAE,MAAM,CACzC,iBAAiB,GAAG,qBAAqB,EACzC,8BAA8B,CAmH/B,CAAC"}
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 { createPaginatedFunction } from "../../../utils/function-utils";
2
- import { ListTableRecordsApiResponseSchema, ListTableRecordsOptionsSchema, ListTableRecordsOptionsInputSchema, RecordItemSchema, } from "./schemas";
3
- import { createTelemetryCallback } from "../../../utils/telemetry-utils";
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
- function extractNextCursor(meta) {
11
- if (!meta?.pagination?.has_more || !meta.pagination.end_cursor) {
12
- return undefined;
13
- }
14
- return meta.pagination.end_cursor;
15
- }
16
- export const listTableRecordsPlugin = (sdk) => {
17
- async function listTableRecordsPage(options) {
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: extractNextCursor(response.meta),
72
+ nextCursor,
74
73
  };
75
- }
76
- const methodName = stripPageSuffix(listTableRecordsPage.name);
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,KAAK,EACV,yBAAyB,EACzB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAC/B,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,CA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,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 interface ListTablesPluginProvides {
7
- listTables: (options?: ListTablesOptions) => Promise<{
8
- data: TableItem[];
9
- nextCursor?: string;
10
- }> & AsyncIterable<{
11
- data: TableItem[];
12
- nextCursor?: string;
13
- }> & {
14
- items(): AsyncIterable<TableItem>;
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 declare const listTablesPlugin: Plugin<ApiPluginProvides & EventEmissionProvides & {
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":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAEL,uBAAuB,EAEvB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAOjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAmB9D,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,iBAAiB,KAAK,OAAO,CAAC;QACnD,IAAI,EAAE,SAAS,EAAE,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,GACA,aAAa,CAAC;QAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG;QAC1D,KAAK,IAAI,aAAa,CAAC,SAAS,CAAC,CAAC;KACnC,CAAC;IACJ,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,UAAU,EAAE;gBACV,WAAW,EAAE,OAAO,uBAAuB,CAAC;aAC7C,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,iBAAiB,GAAG,qBAAqB,GAAG;IAAE,OAAO,EAAE,mBAAmB,CAAA;CAAE,EAC5E,wBAAwB,CAsGzB,CAAC"}
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 { createPaginatedFunction } from "../../../utils/function-utils";
1
+ import { definePlugin } from "../../../utils/plugin-utils";
2
+ import { createPaginatedPluginMethod } from "../../../utils/plugin-utils";
2
3
  import { ListTablesApiResponseSchema, ListTablesOptionsSchema, TableItemSchema, } from "./schemas";
3
- import { createTelemetryCallback } from "../../../utils/telemetry-utils";
4
- import { stripPageSuffix } from "../../../utils/string-utils";
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
- function extractNextCursor(links) {
9
- if (!links?.next) {
10
- return undefined;
11
- }
12
- try {
13
- const url = new URL(links.next);
14
- const offset = url.searchParams.get("offset");
15
- return offset || undefined;
16
- }
17
- catch {
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 ? options.tables : options.tableIds;
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?.kind) {
32
+ if (options.kind) {
36
33
  searchParams.kind = options.kind;
37
34
  }
38
- if (options?.search) {
35
+ if (options.search) {
39
36
  searchParams.q = options.search;
40
37
  }
41
- if (options?.owner && options.owner !== "me" && !options.includeShared) {
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
- nextCursor: extractNextCursor(response.links),
63
+ links: response.links,
76
64
  };
77
- }
78
- const methodName = stripPageSuffix(listTablesPage.name);
79
- const listTablesDefinition = createPaginatedFunction(listTablesPage, ListTablesOptionsSchema, createTelemetryCallback(sdk.context.eventEmission.emitMethodCalled, methodName), methodName, DEFAULT_PAGE_SIZE);
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;AAErE,OAAO,KAAK,E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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
- import type { Plugin } from "../../../types/plugin";
2
- import { UpdateTableRecordsOptionsSchema, type UpdateTableRecordsOptions, type UpdateTableRecordsResult } from "./schemas";
3
- import type { ApiPluginProvides } from "../../api";
4
- import type { EventEmissionProvides } from "../../eventEmission";
5
- export interface UpdateTableRecordsPluginProvides {
6
- updateTableRecords: (options: UpdateTableRecordsOptions) => Promise<UpdateTableRecordsResult>;
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 declare const updateTableRecordsPlugin: Plugin<ApiPluginProvides & EventEmissionProvides, UpdateTableRecordsPluginProvides>;
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":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EACL,+BAA+B,EAI/B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC9B,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAejE,MAAM,WAAW,gCAAgC;IAC/C,kBAAkB,EAAE,CAClB,OAAO,EAAE,yBAAyB,KAC/B,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACvC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,kBAAkB,EAAE;gBAClB,WAAW,EAAE,OAAO,+BAA+B,CAAC;aACrD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAC3C,iBAAiB,GAAG,qBAAqB,EACzC,gCAAgC,CAwFjC,CAAC"}
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 { createFunction } from "../../../utils/function-utils";
2
- import { UpdateTableRecordsOptionsSchema, UpdateTableRecordsOptionsInputSchema, UpdateTableRecordsApiResponseSchema, 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 { 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
- export const updateTableRecordsPlugin = (sdk) => {
9
- async function updateTableRecords(options) {
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
- const updateTableRecordsDefinition = createFunction(updateTableRecords, UpdateTableRecordsOptionsInputSchema, createTelemetryCallback(sdk.context.eventEmission.emitMethodCalled, updateTableRecords.name));
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
  }