@zapier/zapier-sdk 0.34.1 → 0.36.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 (156) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +341 -0
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/client.js +10 -2
  5. package/dist/api/types.d.ts +2 -1
  6. package/dist/api/types.d.ts.map +1 -1
  7. package/dist/constants.d.ts +4 -0
  8. package/dist/constants.d.ts.map +1 -1
  9. package/dist/constants.js +4 -0
  10. package/dist/formatters/index.d.ts +2 -0
  11. package/dist/formatters/index.d.ts.map +1 -0
  12. package/dist/formatters/index.js +1 -0
  13. package/dist/formatters/tableRecord.d.ts +6 -0
  14. package/dist/formatters/tableRecord.d.ts.map +1 -0
  15. package/dist/formatters/tableRecord.js +23 -0
  16. package/dist/index.cjs +2054 -191
  17. package/dist/index.d.mts +639 -59
  18. package/dist/index.d.ts +13 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +13 -0
  21. package/dist/index.mjs +2030 -192
  22. package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
  23. package/dist/plugins/deleteClientCredentials/index.js +1 -1
  24. package/dist/plugins/listActions/index.d.ts.map +1 -1
  25. package/dist/plugins/listActions/index.js +2 -1
  26. package/dist/plugins/listApps/index.d.ts.map +1 -1
  27. package/dist/plugins/listApps/index.js +5 -2
  28. package/dist/plugins/listClientCredentials/index.d.ts.map +1 -1
  29. package/dist/plugins/listClientCredentials/index.js +6 -4
  30. package/dist/plugins/listConnections/index.d.ts.map +1 -1
  31. package/dist/plugins/listConnections/index.js +6 -4
  32. package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
  33. package/dist/plugins/listInputFieldChoices/index.js +2 -1
  34. package/dist/plugins/listInputFields/index.d.ts.map +1 -1
  35. package/dist/plugins/listInputFields/index.js +2 -1
  36. package/dist/plugins/registry/index.d.ts.map +1 -1
  37. package/dist/plugins/registry/index.js +4 -0
  38. package/dist/plugins/runAction/index.d.ts +2 -0
  39. package/dist/plugins/runAction/index.d.ts.map +1 -1
  40. package/dist/plugins/runAction/index.js +73 -14
  41. package/dist/plugins/tables/createTable/index.d.ts +18 -0
  42. package/dist/plugins/tables/createTable/index.d.ts.map +1 -0
  43. package/dist/plugins/tables/createTable/index.js +48 -0
  44. package/dist/plugins/tables/createTable/schemas.d.ts +37 -0
  45. package/dist/plugins/tables/createTable/schemas.d.ts.map +1 -0
  46. package/dist/plugins/tables/createTable/schemas.js +16 -0
  47. package/dist/plugins/tables/createTableFields/index.d.ts +18 -0
  48. package/dist/plugins/tables/createTableFields/index.d.ts.map +1 -0
  49. package/dist/plugins/tables/createTableFields/index.js +49 -0
  50. package/dist/plugins/tables/createTableFields/schemas.d.ts +192 -0
  51. package/dist/plugins/tables/createTableFields/schemas.d.ts.map +1 -0
  52. package/dist/plugins/tables/createTableFields/schemas.js +42 -0
  53. package/dist/plugins/tables/createTableRecords/index.d.ts +18 -0
  54. package/dist/plugins/tables/createTableRecords/index.d.ts.map +1 -0
  55. package/dist/plugins/tables/createTableRecords/index.js +67 -0
  56. package/dist/plugins/tables/createTableRecords/schemas.d.ts +57 -0
  57. package/dist/plugins/tables/createTableRecords/schemas.d.ts.map +1 -0
  58. package/dist/plugins/tables/createTableRecords/schemas.js +35 -0
  59. package/dist/plugins/tables/deleteTable/index.d.ts +18 -0
  60. package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -0
  61. package/dist/plugins/tables/deleteTable/index.js +43 -0
  62. package/dist/plugins/tables/deleteTable/schemas.d.ts +15 -0
  63. package/dist/plugins/tables/deleteTable/schemas.d.ts.map +1 -0
  64. package/dist/plugins/tables/deleteTable/schemas.js +9 -0
  65. package/dist/plugins/tables/deleteTableFields/index.d.ts +18 -0
  66. package/dist/plugins/tables/deleteTableFields/index.d.ts.map +1 -0
  67. package/dist/plugins/tables/deleteTableFields/index.js +50 -0
  68. package/dist/plugins/tables/deleteTableFields/schemas.d.ts +16 -0
  69. package/dist/plugins/tables/deleteTableFields/schemas.d.ts.map +1 -0
  70. package/dist/plugins/tables/deleteTableFields/schemas.js +13 -0
  71. package/dist/plugins/tables/deleteTableRecords/index.d.ts +18 -0
  72. package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +1 -0
  73. package/dist/plugins/tables/deleteTableRecords/index.js +44 -0
  74. package/dist/plugins/tables/deleteTableRecords/schemas.d.ts +16 -0
  75. package/dist/plugins/tables/deleteTableRecords/schemas.d.ts.map +1 -0
  76. package/dist/plugins/tables/deleteTableRecords/schemas.js +14 -0
  77. package/dist/plugins/tables/getTable/index.d.ts +20 -0
  78. package/dist/plugins/tables/getTable/index.d.ts.map +1 -0
  79. package/dist/plugins/tables/getTable/index.js +48 -0
  80. package/dist/plugins/tables/getTable/schemas.d.ts +34 -0
  81. package/dist/plugins/tables/getTable/schemas.d.ts.map +1 -0
  82. package/dist/plugins/tables/getTable/schemas.js +15 -0
  83. package/dist/plugins/tables/getTableRecord/index.d.ts +18 -0
  84. package/dist/plugins/tables/getTableRecord/index.d.ts.map +1 -0
  85. package/dist/plugins/tables/getTableRecord/index.js +60 -0
  86. package/dist/plugins/tables/getTableRecord/schemas.d.ts +51 -0
  87. package/dist/plugins/tables/getTableRecord/schemas.d.ts.map +1 -0
  88. package/dist/plugins/tables/getTableRecord/schemas.js +44 -0
  89. package/dist/plugins/tables/listTableFields/index.d.ts +18 -0
  90. package/dist/plugins/tables/listTableFields/index.d.ts.map +1 -0
  91. package/dist/plugins/tables/listTableFields/index.js +58 -0
  92. package/dist/plugins/tables/listTableFields/schemas.d.ts +180 -0
  93. package/dist/plugins/tables/listTableFields/schemas.d.ts.map +1 -0
  94. package/dist/plugins/tables/listTableFields/schemas.js +77 -0
  95. package/dist/plugins/tables/listTableRecords/index.d.ts +24 -0
  96. package/dist/plugins/tables/listTableRecords/index.d.ts.map +1 -0
  97. package/dist/plugins/tables/listTableRecords/index.js +97 -0
  98. package/dist/plugins/tables/listTableRecords/schemas.d.ts +120 -0
  99. package/dist/plugins/tables/listTableRecords/schemas.d.ts.map +1 -0
  100. package/dist/plugins/tables/listTableRecords/schemas.js +74 -0
  101. package/dist/plugins/tables/listTables/index.d.ts +24 -0
  102. package/dist/plugins/tables/listTables/index.d.ts.map +1 -0
  103. package/dist/plugins/tables/listTables/index.js +85 -0
  104. package/dist/plugins/tables/listTables/schemas.d.ts +78 -0
  105. package/dist/plugins/tables/listTables/schemas.d.ts.map +1 -0
  106. package/dist/plugins/tables/listTables/schemas.js +63 -0
  107. package/dist/plugins/tables/updateTableRecords/index.d.ts +18 -0
  108. package/dist/plugins/tables/updateTableRecords/index.d.ts.map +1 -0
  109. package/dist/plugins/tables/updateTableRecords/index.js +68 -0
  110. package/dist/plugins/tables/updateTableRecords/schemas.d.ts +59 -0
  111. package/dist/plugins/tables/updateTableRecords/schemas.d.ts.map +1 -0
  112. package/dist/plugins/tables/updateTableRecords/schemas.js +35 -0
  113. package/dist/plugins/tables/utils.d.ts +63 -0
  114. package/dist/plugins/tables/utils.d.ts.map +1 -0
  115. package/dist/plugins/tables/utils.js +262 -0
  116. package/dist/resolvers/index.d.ts +8 -0
  117. package/dist/resolvers/index.d.ts.map +1 -1
  118. package/dist/resolvers/index.js +8 -0
  119. package/dist/resolvers/tableFieldIds.d.ts +6 -0
  120. package/dist/resolvers/tableFieldIds.d.ts.map +1 -0
  121. package/dist/resolvers/tableFieldIds.js +19 -0
  122. package/dist/resolvers/tableFields.d.ts +3 -0
  123. package/dist/resolvers/tableFields.d.ts.map +1 -0
  124. package/dist/resolvers/tableFields.js +31 -0
  125. package/dist/resolvers/tableFilters.d.ts +5 -0
  126. package/dist/resolvers/tableFilters.d.ts.map +1 -0
  127. package/dist/resolvers/tableFilters.js +74 -0
  128. package/dist/resolvers/tableId.d.ts +4 -0
  129. package/dist/resolvers/tableId.d.ts.map +1 -0
  130. package/dist/resolvers/tableId.js +19 -0
  131. package/dist/resolvers/tableName.d.ts +3 -0
  132. package/dist/resolvers/tableName.d.ts.map +1 -0
  133. package/dist/resolvers/tableName.js +5 -0
  134. package/dist/resolvers/tableRecordId.d.ts +9 -0
  135. package/dist/resolvers/tableRecordId.d.ts.map +1 -0
  136. package/dist/resolvers/tableRecordId.js +48 -0
  137. package/dist/resolvers/tableRecords.d.ts +8 -0
  138. package/dist/resolvers/tableRecords.d.ts.map +1 -0
  139. package/dist/resolvers/tableRecords.js +77 -0
  140. package/dist/resolvers/tableSort.d.ts +5 -0
  141. package/dist/resolvers/tableSort.d.ts.map +1 -0
  142. package/dist/resolvers/tableSort.js +43 -0
  143. package/dist/sdk.d.ts +73 -1
  144. package/dist/sdk.d.ts.map +1 -1
  145. package/dist/sdk.js +25 -0
  146. package/dist/types/sdk.d.ts +16 -1
  147. package/dist/types/sdk.d.ts.map +1 -1
  148. package/dist/utils/function-utils.d.ts +2 -2
  149. package/dist/utils/function-utils.d.ts.map +1 -1
  150. package/dist/utils/function-utils.js +2 -3
  151. package/dist/utils/pagination-utils.d.ts +24 -0
  152. package/dist/utils/pagination-utils.d.ts.map +1 -1
  153. package/dist/utils/pagination-utils.js +78 -0
  154. package/dist/utils/schema-utils.d.ts +33 -5
  155. package/dist/utils/schema-utils.d.ts.map +1 -1
  156. package/package.json +7 -2
package/dist/index.cjs CHANGED
@@ -64,6 +64,7 @@ function isPositional(schema) {
64
64
  // src/constants.ts
65
65
  var ZAPIER_BASE_URL = process.env.ZAPIER_BASE_URL || "https://zapier.com";
66
66
  var MAX_PAGE_LIMIT = 1e4;
67
+ var DEFAULT_PAGE_SIZE = 100;
67
68
  var DEFAULT_ACTION_TIMEOUT_MS = 18e4;
68
69
  function parseIntEnvVar(name) {
69
70
  const value = process.env[name];
@@ -832,6 +833,68 @@ async function* paginateBuffered(pageFunction, pageOptions) {
832
833
  }
833
834
  }
834
835
  var paginate = paginateBuffered;
836
+ function concatPaginated({
837
+ sources,
838
+ dedupe,
839
+ pageSize = 100
840
+ }) {
841
+ if (sources.length === 0) {
842
+ const empty = { data: [] };
843
+ return Object.assign(Promise.resolve(empty), {
844
+ [Symbol.asyncIterator]: async function* () {
845
+ yield empty;
846
+ }
847
+ });
848
+ }
849
+ let sourceIndex = 0;
850
+ let currentIterator = null;
851
+ const seen = /* @__PURE__ */ new Set();
852
+ const pageFunction = async (_options) => {
853
+ while (sourceIndex < sources.length) {
854
+ if (!currentIterator) {
855
+ const result = sources[sourceIndex]();
856
+ currentIterator = result[Symbol.asyncIterator]();
857
+ }
858
+ const next = await currentIterator.next();
859
+ if (next.done) {
860
+ sourceIndex++;
861
+ currentIterator = null;
862
+ continue;
863
+ }
864
+ let items = next.value.data;
865
+ if (dedupe) {
866
+ if (sourceIndex > 0) {
867
+ items = items.filter((item) => !seen.has(dedupe(item)));
868
+ }
869
+ for (const item of items) {
870
+ seen.add(dedupe(item));
871
+ }
872
+ }
873
+ const hasMoreInSource = next.value.nextCursor != null;
874
+ const hasMoreSources = sourceIndex < sources.length - 1;
875
+ return {
876
+ data: items,
877
+ nextCursor: hasMoreInSource || hasMoreSources ? "__has_more__" : void 0
878
+ };
879
+ }
880
+ return { data: [] };
881
+ };
882
+ const iterator = paginateBuffered(pageFunction, { pageSize });
883
+ const firstPagePromise = iterator.next().then((result) => {
884
+ if (result.done) {
885
+ return { data: [] };
886
+ }
887
+ return result.value;
888
+ });
889
+ return Object.assign(firstPagePromise, {
890
+ [Symbol.asyncIterator]: async function* () {
891
+ yield await firstPagePromise;
892
+ for await (const page of { [Symbol.asyncIterator]: () => iterator }) {
893
+ yield page;
894
+ }
895
+ }
896
+ });
897
+ }
835
898
 
836
899
  // src/utils/validation.ts
837
900
  var validate = (schema, input) => {
@@ -982,7 +1045,7 @@ function createPageFunction(coreFn) {
982
1045
  };
983
1046
  return namedFunctions[functionName];
984
1047
  }
985
- function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName) {
1048
+ function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName, defaultPageSize) {
986
1049
  const pageFunction = createPageFunction(coreFn);
987
1050
  const functionName = explicitFunctionName || coreFn.name;
988
1051
  const validator = schema ? createValidator(schema) : null;
@@ -996,7 +1059,7 @@ function createPaginatedFunction(coreFn, schema, telemetry, explicitFunctionName
996
1059
  ...normalizedOptions,
997
1060
  ...validator ? validator(normalizedOptions) : normalizedOptions
998
1061
  };
999
- const pageSize = validatedOptions.pageSize || 100;
1062
+ const pageSize = validatedOptions.pageSize ?? defaultPageSize;
1000
1063
  const optimizedOptions = {
1001
1064
  ...validatedOptions,
1002
1065
  pageSize
@@ -1170,7 +1233,9 @@ var listAppsPlugin = ({ context }) => {
1170
1233
  searchParams: {
1171
1234
  appKeys: implementationIds.join(","),
1172
1235
  ...options.search && { search: options.search },
1173
- pageSize: options.pageSize.toString(),
1236
+ ...options.pageSize !== void 0 && {
1237
+ pageSize: options.pageSize.toString()
1238
+ },
1174
1239
  ...options.cursor && { offset: options.cursor }
1175
1240
  }
1176
1241
  });
@@ -1180,7 +1245,8 @@ var listAppsPlugin = ({ context }) => {
1180
1245
  listAppsPage,
1181
1246
  ListAppsSchema,
1182
1247
  createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
1183
- methodName
1248
+ methodName,
1249
+ DEFAULT_PAGE_SIZE
1184
1250
  );
1185
1251
  return {
1186
1252
  listApps: listAppsDefinition,
@@ -1863,6 +1929,625 @@ var clientIdResolver = {
1863
1929
  })
1864
1930
  };
1865
1931
 
1932
+ // src/resolvers/tableId.ts
1933
+ var tableIdResolver = {
1934
+ type: "dynamic",
1935
+ fetch: (sdk) => {
1936
+ return concatPaginated({
1937
+ sources: [() => sdk.listTables({ owner: "me" }), () => sdk.listTables()],
1938
+ dedupe: (table) => table.id
1939
+ });
1940
+ },
1941
+ prompt: (tables) => ({
1942
+ type: "list",
1943
+ name: "tableId",
1944
+ message: "Select a table:",
1945
+ choices: tables.map((table) => ({
1946
+ name: `${table.name} (${table.id})`,
1947
+ value: table.id
1948
+ }))
1949
+ })
1950
+ };
1951
+ function formatFieldValue(v) {
1952
+ if (v == null) return "";
1953
+ if (typeof v === "object") {
1954
+ try {
1955
+ return JSON.stringify(v);
1956
+ } catch {
1957
+ return String(v);
1958
+ }
1959
+ }
1960
+ return String(v);
1961
+ }
1962
+ function toNumericFieldId(id) {
1963
+ if (typeof id === "number") return id;
1964
+ const num = parseInt(id.replace(/^f/, ""), 10);
1965
+ if (isNaN(num)) {
1966
+ throw new ZapierValidationError(
1967
+ `Invalid field ID: "${id}". Expected a numeric ID like "f6", "6", or 6.`
1968
+ );
1969
+ }
1970
+ return num;
1971
+ }
1972
+ function transformTableItem(apiItem) {
1973
+ return {
1974
+ id: apiItem.id,
1975
+ name: apiItem.name,
1976
+ description: apiItem.description ?? void 0,
1977
+ created_at: apiItem.created_at,
1978
+ edited_at: apiItem.edited_at,
1979
+ kind: apiItem.kind,
1980
+ owner_account_id: String(apiItem.owner_account_id),
1981
+ profile_id: String(apiItem.owner_zapier_customuser_id),
1982
+ parent_table_id: apiItem.parent_table_id ?? void 0
1983
+ };
1984
+ }
1985
+ function transformFieldItem(apiItem) {
1986
+ return {
1987
+ id: `f${apiItem.id}`,
1988
+ type: apiItem.type,
1989
+ name: apiItem.name,
1990
+ created_at: apiItem.created_at,
1991
+ edited_at: apiItem.edited_at,
1992
+ options: apiItem.options,
1993
+ config: apiItem.config
1994
+ };
1995
+ }
1996
+ function transformRecordItem(apiItem) {
1997
+ return {
1998
+ id: apiItem.id,
1999
+ data: apiItem.data,
2000
+ created_at: apiItem.created_at,
2001
+ edited_at: apiItem.edited_at
2002
+ };
2003
+ }
2004
+ function formatRecordError(fieldId, err) {
2005
+ const message = err.h || err.e || "validation error";
2006
+ if (err.v !== void 0) {
2007
+ return `Field ${fieldId}: ${message} (value: ${JSON.stringify(err.v)})`;
2008
+ }
2009
+ return `Field ${fieldId}: ${message}`;
2010
+ }
2011
+ function formatResponseError(err) {
2012
+ const message = err.human_title || err.title || "Unknown error";
2013
+ if (err.meta && Object.keys(err.meta).length > 0) {
2014
+ const metaParts = Object.entries(err.meta).map(([key, val]) => `${key}: ${JSON.stringify(val)}`).join(", ");
2015
+ return `${message} (${metaParts})`;
2016
+ }
2017
+ return message;
2018
+ }
2019
+ function throwOnRecordErrors(record) {
2020
+ if (!record.errors) return;
2021
+ const messages = [];
2022
+ for (const [fieldId, error] of Object.entries(record.errors)) {
2023
+ const err = error;
2024
+ if (err.s === "error") {
2025
+ messages.push(formatRecordError(fieldId, err));
2026
+ }
2027
+ }
2028
+ if (messages.length > 0) {
2029
+ throw new ZapierValidationError(
2030
+ `Record ${record.id} has errors: ${messages.join("; ")}`
2031
+ );
2032
+ }
2033
+ }
2034
+ function throwOnResponseErrors(response) {
2035
+ const errors = response.meta?.errors;
2036
+ if (!errors || errors.length === 0) return;
2037
+ const messages = errors.map(
2038
+ (err) => formatResponseError(err)
2039
+ );
2040
+ throw new ZapierValidationError(messages.join("; "));
2041
+ }
2042
+ var KeyModeSchema = zod.z.enum(["names", "ids"]).optional().default("names").describe(
2043
+ 'How to interpret field keys in record data. "names" (default) uses human-readable field names, "ids" uses raw field IDs (f1, f2).'
2044
+ );
2045
+ var FIELD_ID_PATTERN = /^f\d+$/;
2046
+ function isFieldId(key) {
2047
+ return FIELD_ID_PATTERN.test(key);
2048
+ }
2049
+ var NESTED_COMPONENTS = {
2050
+ labeled_string: /* @__PURE__ */ new Set(["value"]),
2051
+ ai_formula: /* @__PURE__ */ new Set(["value"]),
2052
+ link: /* @__PURE__ */ new Set(["link", "text"]),
2053
+ linked_record: /* @__PURE__ */ new Set(["label", "source"])
2054
+ };
2055
+ async function getFieldMapping(api, tableId, keyMode) {
2056
+ if (keyMode === "ids") {
2057
+ return null;
2058
+ }
2059
+ const rawResponse = await api.get(`/tables/api/v1/tables/${tableId}/fields`, {
2060
+ authRequired: true
2061
+ });
2062
+ const data = rawResponse.data;
2063
+ const nameToId = /* @__PURE__ */ new Map();
2064
+ const idToName = /* @__PURE__ */ new Map();
2065
+ const idToType = /* @__PURE__ */ new Map();
2066
+ for (const field of data) {
2067
+ const id = `f${field.id}`;
2068
+ if (!nameToId.has(field.name)) {
2069
+ nameToId.set(field.name, id);
2070
+ }
2071
+ if (!idToName.has(id)) {
2072
+ idToName.set(id, field.name);
2073
+ }
2074
+ idToType.set(id, field.type);
2075
+ }
2076
+ return { nameToId, idToName, idToType };
2077
+ }
2078
+ async function resolveFieldKeys({
2079
+ api,
2080
+ tableId,
2081
+ fieldKeys
2082
+ }) {
2083
+ const allAreIds = fieldKeys.every(
2084
+ (key) => typeof key === "number" || /^(f?\d+)$/.test(key)
2085
+ );
2086
+ if (allAreIds) {
2087
+ return fieldKeys.map(toNumericFieldId);
2088
+ }
2089
+ const mapping = await getFieldMapping(api, tableId, "names");
2090
+ if (!mapping) {
2091
+ return fieldKeys.map(toNumericFieldId);
2092
+ }
2093
+ return fieldKeys.map((key) => {
2094
+ if (typeof key === "number") return key;
2095
+ if (FIELD_ID_PATTERN.test(key)) return toNumericFieldId(key);
2096
+ const id = mapping.nameToId.get(key);
2097
+ if (!id) {
2098
+ throw new ZapierValidationError(
2099
+ `Unknown field name: "${key}". Use a valid field name or ID.`
2100
+ );
2101
+ }
2102
+ return toNumericFieldId(id);
2103
+ });
2104
+ }
2105
+ async function createFieldKeyTranslator({
2106
+ api,
2107
+ tableId,
2108
+ keyMode
2109
+ }) {
2110
+ const mapping = await getFieldMapping(api, tableId, keyMode);
2111
+ return {
2112
+ translateInput(data) {
2113
+ if (!mapping) return data;
2114
+ const result = {};
2115
+ for (const [key, value] of Object.entries(data)) {
2116
+ if (FIELD_ID_PATTERN.test(key) && mapping.idToName.has(key)) {
2117
+ result[key] = value;
2118
+ } else if (mapping.nameToId.has(key)) {
2119
+ result[mapping.nameToId.get(key)] = value;
2120
+ } else {
2121
+ result[key] = value;
2122
+ }
2123
+ }
2124
+ return result;
2125
+ },
2126
+ translateOutput(data) {
2127
+ if (!mapping) return data;
2128
+ const result = {};
2129
+ for (const [key, value] of Object.entries(data)) {
2130
+ if (mapping.idToName.has(key)) {
2131
+ result[mapping.idToName.get(key)] = value;
2132
+ } else {
2133
+ result[key] = value;
2134
+ }
2135
+ }
2136
+ return result;
2137
+ },
2138
+ translateFieldKey(key) {
2139
+ if (!mapping) return key;
2140
+ if (FIELD_ID_PATTERN.test(key) && mapping.idToName.has(key)) {
2141
+ const fieldType = mapping.idToType.get(key);
2142
+ if (fieldType) {
2143
+ const components = NESTED_COMPONENTS[fieldType];
2144
+ if (components?.size === 1) {
2145
+ return `${key}__${[...components][0]}`;
2146
+ }
2147
+ }
2148
+ return key;
2149
+ }
2150
+ if (mapping.nameToId.has(key)) {
2151
+ const fieldId = mapping.nameToId.get(key);
2152
+ const fieldType = mapping.idToType.get(fieldId);
2153
+ if (fieldType) {
2154
+ const components = NESTED_COMPONENTS[fieldType];
2155
+ if (components?.size === 1) {
2156
+ return `${fieldId}__${[...components][0]}`;
2157
+ }
2158
+ }
2159
+ return fieldId;
2160
+ }
2161
+ const sepIndex = key.lastIndexOf("__");
2162
+ if (sepIndex > 0) {
2163
+ const prefix = key.slice(0, sepIndex);
2164
+ const component = key.slice(sepIndex + 2);
2165
+ let fieldId;
2166
+ if (FIELD_ID_PATTERN.test(prefix) && mapping.idToName.has(prefix)) {
2167
+ fieldId = prefix;
2168
+ } else {
2169
+ fieldId = mapping.nameToId.get(prefix);
2170
+ }
2171
+ if (fieldId) {
2172
+ const fieldType = mapping.idToType.get(fieldId);
2173
+ if (fieldType && NESTED_COMPONENTS[fieldType]?.has(component)) {
2174
+ return `${fieldId}__${component}`;
2175
+ }
2176
+ }
2177
+ }
2178
+ return key;
2179
+ }
2180
+ };
2181
+ }
2182
+
2183
+ // src/resolvers/tableRecordId.ts
2184
+ function summarizeRecord(record) {
2185
+ const values = Object.values(record.data);
2186
+ const preview = values.slice(0, 3).map((v) => formatFieldValue(v).replace(/\s+/g, " ").trim()).filter((s) => s.length > 0).join(", ");
2187
+ const truncated = preview.length > 60 ? preview.slice(0, 57) + "..." : preview;
2188
+ return truncated ? `${record.id} \u2014 ${truncated}` : record.id;
2189
+ }
2190
+ function fetchRecords(sdk, params) {
2191
+ return sdk.listTableRecords({
2192
+ tableId: params.tableId,
2193
+ keyMode: "names"
2194
+ });
2195
+ }
2196
+ function recordChoices(records) {
2197
+ return records.map((record) => ({
2198
+ name: summarizeRecord(record),
2199
+ value: record.id
2200
+ }));
2201
+ }
2202
+ var tableRecordIdResolver = {
2203
+ type: "dynamic",
2204
+ depends: ["tableId"],
2205
+ fetch: fetchRecords,
2206
+ prompt: (records) => ({
2207
+ type: "list",
2208
+ name: "recordId",
2209
+ message: "Select a record:",
2210
+ choices: recordChoices(records)
2211
+ })
2212
+ };
2213
+ var tableRecordIdsResolver = {
2214
+ type: "dynamic",
2215
+ depends: ["tableId"],
2216
+ fetch: fetchRecords,
2217
+ prompt: (records) => ({
2218
+ type: "checkbox",
2219
+ name: "recordIds",
2220
+ message: "Select records to delete:",
2221
+ choices: recordChoices(records),
2222
+ validate: (value) => Array.isArray(value) && value.length > 0 ? true : "Select at least one record"
2223
+ })
2224
+ };
2225
+
2226
+ // src/resolvers/tableFieldIds.ts
2227
+ var tableFieldIdsResolver = {
2228
+ type: "dynamic",
2229
+ depends: ["tableId"],
2230
+ fetch: (sdk, params) => {
2231
+ return sdk.listTableFields({ tableId: params.tableId });
2232
+ },
2233
+ prompt: (fields) => ({
2234
+ type: "checkbox",
2235
+ name: "fieldKeys",
2236
+ message: "Select fields:",
2237
+ choices: fields.map((field) => ({
2238
+ name: `${field.name} (${field.id}, ${field.type})`,
2239
+ value: field.id
2240
+ })),
2241
+ validate: (value) => Array.isArray(value) && value.length > 0 ? true : "Select at least one field"
2242
+ })
2243
+ };
2244
+
2245
+ // src/resolvers/tableName.ts
2246
+ var tableNameResolver = {
2247
+ type: "static",
2248
+ inputType: "text",
2249
+ placeholder: "Enter a name for the table"
2250
+ };
2251
+ var FieldTypeSchema = zod.z.enum([
2252
+ "string",
2253
+ "multiple_string",
2254
+ "labeled_string",
2255
+ "multiple_labeled_string",
2256
+ "text",
2257
+ "multiple_text",
2258
+ "boolean",
2259
+ "multiple_boolean",
2260
+ "number",
2261
+ "multiple_number",
2262
+ "decimal",
2263
+ "multiple_decimal",
2264
+ "datetime",
2265
+ "multiple_datetime",
2266
+ "uuid",
2267
+ "multiple_uuid",
2268
+ "json",
2269
+ "multiple_json",
2270
+ "formula",
2271
+ "button_trigger_zap",
2272
+ "button_continue_zap",
2273
+ "email",
2274
+ "multiple_email",
2275
+ "link",
2276
+ "multiple_link",
2277
+ "currency",
2278
+ "phone_number",
2279
+ "ai_formula",
2280
+ "linked_record",
2281
+ "multiple_linked_record"
2282
+ ]);
2283
+ var FieldApiItemSchema = zod.z.object({
2284
+ id: zod.z.number(),
2285
+ type: FieldTypeSchema,
2286
+ name: zod.z.string(),
2287
+ created_at: zod.z.string().optional(),
2288
+ edited_at: zod.z.string().optional(),
2289
+ options: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
2290
+ config: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
2291
+ is_order_field: zod.z.boolean().optional(),
2292
+ is_filter_field: zod.z.boolean().optional(),
2293
+ is_selected_field: zod.z.boolean().optional()
2294
+ });
2295
+ var ListTableFieldsApiResponseSchema = zod.z.object({
2296
+ data: zod.z.array(FieldApiItemSchema)
2297
+ });
2298
+ var FieldItemSchemaBase = zod.z.object({
2299
+ id: zod.z.string(),
2300
+ type: FieldTypeSchema,
2301
+ name: zod.z.string(),
2302
+ created_at: zod.z.string().optional(),
2303
+ edited_at: zod.z.string().optional(),
2304
+ options: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
2305
+ config: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
2306
+ });
2307
+ var FieldItemSchema = withFormatter(FieldItemSchemaBase, {
2308
+ format: (item) => ({
2309
+ title: item.name,
2310
+ id: item.id,
2311
+ details: [{ text: `Type: ${item.type}`, style: "dim" }]
2312
+ })
2313
+ });
2314
+ var ListTableFieldsOptionsSchema = zod.z.object({
2315
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table"),
2316
+ fieldKeys: zod.z.array(zod.z.union([zod.z.string(), zod.z.number()])).optional().describe(
2317
+ 'Filter by specific fields. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
2318
+ )
2319
+ }).describe("List fields for a table");
2320
+
2321
+ // src/resolvers/tableFields.ts
2322
+ var fieldTypeChoices = FieldTypeSchema.options.map((type) => ({
2323
+ label: type,
2324
+ value: type
2325
+ }));
2326
+ var singleFieldResolver = {
2327
+ type: "fields",
2328
+ fetch: async () => {
2329
+ return [
2330
+ {
2331
+ type: "input_field",
2332
+ key: "type",
2333
+ title: "Field type",
2334
+ is_required: true,
2335
+ choices: fieldTypeChoices
2336
+ },
2337
+ {
2338
+ type: "input_field",
2339
+ key: "name",
2340
+ title: "Field name",
2341
+ is_required: true
2342
+ }
2343
+ ];
2344
+ }
2345
+ };
2346
+ var tableFieldsResolver = {
2347
+ type: "array",
2348
+ fetch: async () => singleFieldResolver,
2349
+ minItems: 1
2350
+ };
2351
+
2352
+ // src/resolvers/tableRecords.ts
2353
+ function tableFieldValueType(fieldType) {
2354
+ if (fieldType.startsWith("multiple_")) return "array";
2355
+ switch (fieldType) {
2356
+ case "number":
2357
+ case "decimal":
2358
+ case "currency":
2359
+ return "number";
2360
+ case "boolean":
2361
+ return "boolean";
2362
+ default:
2363
+ return void 0;
2364
+ }
2365
+ }
2366
+ function createSingleRecordResolver({
2367
+ sdk,
2368
+ tableId,
2369
+ includeRecordId
2370
+ }) {
2371
+ return {
2372
+ type: "fields",
2373
+ fetch: async () => {
2374
+ const { data: fields } = await sdk.listTableFields({ tableId });
2375
+ const inputFields = fields.map((field) => ({
2376
+ type: "input_field",
2377
+ key: field.id,
2378
+ title: field.name,
2379
+ is_required: false,
2380
+ ...tableFieldValueType(field.type) && {
2381
+ value_type: tableFieldValueType(field.type)
2382
+ }
2383
+ }));
2384
+ if (includeRecordId) {
2385
+ return [
2386
+ {
2387
+ type: "input_field",
2388
+ key: "_record_id",
2389
+ title: "Record",
2390
+ is_required: true,
2391
+ resolver: tableRecordIdResolver
2392
+ },
2393
+ ...inputFields
2394
+ ];
2395
+ }
2396
+ return inputFields;
2397
+ },
2398
+ transform: (values) => {
2399
+ if (includeRecordId) {
2400
+ const { _record_id: id, ...data } = values;
2401
+ return { id, data };
2402
+ }
2403
+ return { data: values };
2404
+ }
2405
+ };
2406
+ }
2407
+ var tableRecordsResolver = {
2408
+ type: "array",
2409
+ depends: ["tableId"],
2410
+ fetch: async (sdk, params) => {
2411
+ return createSingleRecordResolver({
2412
+ sdk,
2413
+ tableId: params.tableId
2414
+ });
2415
+ },
2416
+ minItems: 1
2417
+ };
2418
+ var tableUpdateRecordsResolver = {
2419
+ type: "array",
2420
+ depends: ["tableId"],
2421
+ fetch: async (sdk, params) => {
2422
+ return createSingleRecordResolver({
2423
+ sdk,
2424
+ tableId: params.tableId,
2425
+ includeRecordId: true
2426
+ });
2427
+ },
2428
+ minItems: 1
2429
+ };
2430
+
2431
+ // src/resolvers/tableFilters.ts
2432
+ var FILTER_OPERATORS = [
2433
+ { label: "equals", value: "exact" },
2434
+ { label: "not equals", value: "different" },
2435
+ { label: "contains", value: "contains" },
2436
+ { label: "contains (case-insensitive)", value: "icontains" },
2437
+ { label: "starts with", value: "startswith" },
2438
+ { label: "search", value: "search" },
2439
+ { label: "greater than", value: "gt" },
2440
+ { label: "greater than or equal", value: "gte" },
2441
+ { label: "less than", value: "lt" },
2442
+ { label: "less than or equal", value: "lte" },
2443
+ { label: "in range", value: "range" },
2444
+ { label: "in list", value: "in" },
2445
+ { label: "is empty", value: "isnull" },
2446
+ { label: "is within (date)", value: "is_within" }
2447
+ ];
2448
+ function createSingleFilterResolver({
2449
+ sdk,
2450
+ tableId
2451
+ }) {
2452
+ return {
2453
+ type: "fields",
2454
+ fetch: async () => {
2455
+ const { data: fields } = await sdk.listTableFields({ tableId });
2456
+ const fieldChoices = fields.flatMap((field) => {
2457
+ const components = NESTED_COMPONENTS[field.type];
2458
+ if (components && components.size > 1) {
2459
+ return [...components].map((component) => ({
2460
+ label: `${field.name}__${component} (${field.id}, ${field.type})`,
2461
+ value: `${field.name}__${component}`
2462
+ }));
2463
+ }
2464
+ return {
2465
+ label: `${field.name} (${field.id}${components ? `, ${field.type}` : ""})`,
2466
+ value: components ? `${field.name}__${[...components][0]}` : field.name
2467
+ };
2468
+ });
2469
+ const fieldItems = [
2470
+ {
2471
+ type: "input_field",
2472
+ key: "fieldKey",
2473
+ title: "Field",
2474
+ is_required: true,
2475
+ choices: fieldChoices
2476
+ },
2477
+ {
2478
+ type: "input_field",
2479
+ key: "operator",
2480
+ title: "Operator",
2481
+ is_required: true,
2482
+ choices: FILTER_OPERATORS
2483
+ },
2484
+ {
2485
+ type: "input_field",
2486
+ key: "value",
2487
+ title: "Value",
2488
+ is_required: false
2489
+ }
2490
+ ];
2491
+ return fieldItems;
2492
+ }
2493
+ };
2494
+ }
2495
+ var tableFiltersResolver = {
2496
+ type: "array",
2497
+ depends: ["tableId"],
2498
+ fetch: async (sdk, params) => {
2499
+ return createSingleFilterResolver({
2500
+ sdk,
2501
+ tableId: params.tableId
2502
+ });
2503
+ },
2504
+ minItems: 0
2505
+ };
2506
+
2507
+ // src/resolvers/tableSort.ts
2508
+ var tableSortResolver = {
2509
+ type: "fields",
2510
+ depends: ["tableId"],
2511
+ fetch: async (sdk, params) => {
2512
+ const { data: fields } = await sdk.listTableFields({
2513
+ tableId: params.tableId
2514
+ });
2515
+ const fieldChoices = fields.flatMap((field) => {
2516
+ const components = NESTED_COMPONENTS[field.type];
2517
+ if (components) {
2518
+ return [...components].map((component) => ({
2519
+ label: `${field.name}__${component} (${field.id}, ${field.type})`,
2520
+ value: `${field.name}__${component}`
2521
+ }));
2522
+ }
2523
+ return {
2524
+ label: `${field.name} (${field.id})`,
2525
+ value: field.name
2526
+ };
2527
+ });
2528
+ const fieldItems = [
2529
+ {
2530
+ type: "input_field",
2531
+ key: "fieldKey",
2532
+ title: "Field",
2533
+ is_required: true,
2534
+ choices: fieldChoices
2535
+ },
2536
+ {
2537
+ type: "input_field",
2538
+ key: "direction",
2539
+ title: "Direction",
2540
+ is_required: true,
2541
+ choices: [
2542
+ { label: "Ascending", value: "asc" },
2543
+ { label: "Descending", value: "desc" }
2544
+ ]
2545
+ }
2546
+ ];
2547
+ return fieldItems;
2548
+ }
2549
+ };
2550
+
1866
2551
  // src/plugins/listActions/index.ts
1867
2552
  var listActionsPlugin = ({ context }) => {
1868
2553
  const methodMeta = {
@@ -1942,7 +2627,8 @@ var listActionsPlugin = ({ context }) => {
1942
2627
  listActionsPage,
1943
2628
  ListActionsSchema,
1944
2629
  createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
1945
- methodName
2630
+ methodName,
2631
+ DEFAULT_PAGE_SIZE
1946
2632
  );
1947
2633
  return {
1948
2634
  listActions: listActionsDefinition,
@@ -2299,7 +2985,8 @@ var listInputFieldsPlugin = ({ sdk, context }) => {
2299
2985
  listInputFieldsPage,
2300
2986
  ListInputFieldsSchema,
2301
2987
  createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
2302
- methodName
2988
+ methodName,
2989
+ DEFAULT_PAGE_SIZE
2303
2990
  );
2304
2991
  return {
2305
2992
  listInputFields: listInputFieldsDefinition,
@@ -2385,9 +3072,10 @@ var ConnectionItemSchema = withFormatter(connections.ConnectionItemSchema, {
2385
3072
  var listConnectionsPlugin = ({ context }) => {
2386
3073
  async function listConnectionsPage(options) {
2387
3074
  const { api, getVersionedImplementationId } = context;
2388
- const searchParams = {
2389
- page_size: options.pageSize.toString()
2390
- };
3075
+ const searchParams = {};
3076
+ if (options.pageSize !== void 0) {
3077
+ searchParams.page_size = options.pageSize.toString();
3078
+ }
2391
3079
  if (options.appKey) {
2392
3080
  const implementationId = await getVersionedImplementationId(
2393
3081
  options.appKey
@@ -2451,7 +3139,8 @@ var listConnectionsPlugin = ({ context }) => {
2451
3139
  listConnectionsPage,
2452
3140
  ListConnectionsQuerySchema,
2453
3141
  createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
2454
- methodName
3142
+ methodName,
3143
+ DEFAULT_PAGE_SIZE
2455
3144
  );
2456
3145
  return {
2457
3146
  listConnections: listConnectionsDefinition,
@@ -2529,9 +3218,10 @@ var ClientCredentialsCreatedItemSchema = withFormatter(
2529
3218
  var listClientCredentialsPlugin = ({ context }) => {
2530
3219
  async function listClientCredentialsPage(options) {
2531
3220
  const { api } = context;
2532
- const searchParams = {
2533
- pageSize: options.pageSize.toString()
2534
- };
3221
+ const searchParams = {};
3222
+ if (options.pageSize !== void 0) {
3223
+ searchParams.pageSize = options.pageSize.toString();
3224
+ }
2535
3225
  if (options.cursor) {
2536
3226
  searchParams.offset = options.cursor;
2537
3227
  }
@@ -2565,7 +3255,8 @@ var listClientCredentialsPlugin = ({ context }) => {
2565
3255
  listClientCredentialsPage,
2566
3256
  ListClientCredentialsQuerySchema,
2567
3257
  createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
2568
- methodName
3258
+ methodName,
3259
+ DEFAULT_PAGE_SIZE
2569
3260
  );
2570
3261
  return {
2571
3262
  listClientCredentials: listClientCredentialsDefinition,
@@ -2655,25 +3346,29 @@ var DeleteClientCredentialsSchema = zod.z.object({
2655
3346
  var deleteClientCredentialsPlugin = ({ context }) => {
2656
3347
  async function deleteClientCredentials(options) {
2657
3348
  const { api } = context;
2658
- await api.delete(`/api/v0/client-credentials/${options.clientId}`, {
2659
- customErrorHandler: ({ status }) => {
2660
- if (status === 401) {
2661
- return new ZapierAuthenticationError(
2662
- `Authentication failed. Your token may not have permission to delete client credentials or may be expired. (HTTP ${status})`,
2663
- { statusCode: status }
2664
- );
2665
- }
2666
- if (status === 403) {
2667
- return new ZapierAuthenticationError(
2668
- `Access forbidden. Your token may not have the required scopes to delete client credentials. (HTTP ${status})`,
2669
- { statusCode: status }
2670
- );
2671
- }
2672
- return void 0;
2673
- },
2674
- authRequired: true,
2675
- requiredScopes: ["credentials"]
2676
- });
3349
+ await api.delete(
3350
+ `/api/v0/client-credentials/${options.clientId}`,
3351
+ void 0,
3352
+ {
3353
+ customErrorHandler: ({ status }) => {
3354
+ if (status === 401) {
3355
+ return new ZapierAuthenticationError(
3356
+ `Authentication failed. Your token may not have permission to delete client credentials or may be expired. (HTTP ${status})`,
3357
+ { statusCode: status }
3358
+ );
3359
+ }
3360
+ if (status === 403) {
3361
+ return new ZapierAuthenticationError(
3362
+ `Access forbidden. Your token may not have the required scopes to delete client credentials. (HTTP ${status})`,
3363
+ { statusCode: status }
3364
+ );
3365
+ }
3366
+ return void 0;
3367
+ },
3368
+ authRequired: true,
3369
+ requiredScopes: ["credentials"]
3370
+ }
3371
+ );
2677
3372
  return {
2678
3373
  success: true
2679
3374
  };
@@ -2980,6 +3675,7 @@ async function executeAction(actionOptions) {
2980
3675
  actionKey,
2981
3676
  actionType,
2982
3677
  executionOptions,
3678
+ cursor,
2983
3679
  connectionId,
2984
3680
  timeoutMs
2985
3681
  } = actionOptions;
@@ -2993,6 +3689,9 @@ async function executeAction(actionOptions) {
2993
3689
  if (connectionId !== null && connectionId !== void 0) {
2994
3690
  runRequestData.authentication_id = connectionId;
2995
3691
  }
3692
+ if (cursor) {
3693
+ runRequestData.page = cursor;
3694
+ }
2996
3695
  const runRequest = {
2997
3696
  data: runRequestData
2998
3697
  };
@@ -3012,19 +3711,52 @@ async function executeAction(actionOptions) {
3012
3711
  resultExtractor: (result) => result.data
3013
3712
  });
3014
3713
  }
3714
+ var CONTEXT_CACHE_TTL_MS = 6e4;
3715
+ var CONTEXT_CACHE_MAX_SIZE = 500;
3015
3716
  var runActionPlugin = ({ sdk, context }) => {
3016
- async function runActionPage(options) {
3017
- const { api } = context;
3018
- const {
3019
- appKey,
3020
- actionKey,
3021
- actionType,
3022
- connectionId,
3023
- authenticationId,
3024
- inputs = {},
3025
- timeoutMs
3026
- } = options;
3027
- const resolvedConnectionId = connectionId ?? authenticationId;
3717
+ const runActionContextCache = /* @__PURE__ */ new Map();
3718
+ function evictIfNeeded() {
3719
+ if (runActionContextCache.size < CONTEXT_CACHE_MAX_SIZE) return;
3720
+ const now = Date.now();
3721
+ let oldestKey;
3722
+ let oldestExpiry = Infinity;
3723
+ let evictedAny = false;
3724
+ for (const [key, entry] of runActionContextCache) {
3725
+ if (now >= entry.expiresAt) {
3726
+ runActionContextCache.delete(key);
3727
+ evictedAny = true;
3728
+ } else if (entry.expiresAt < oldestExpiry) {
3729
+ oldestExpiry = entry.expiresAt;
3730
+ oldestKey = key;
3731
+ }
3732
+ }
3733
+ if (!evictedAny && oldestKey) {
3734
+ runActionContextCache.delete(oldestKey);
3735
+ }
3736
+ }
3737
+ function getRunActionContext(options) {
3738
+ const { appKey, actionKey, actionType } = options;
3739
+ const contextKey = `${appKey}:${actionKey}:${actionType}`;
3740
+ const cached = runActionContextCache.get(contextKey);
3741
+ if (cached && Date.now() < cached.expiresAt) {
3742
+ return cached.promise;
3743
+ }
3744
+ const pendingContext = resolveRunActionContext(options).catch((error) => {
3745
+ const current = runActionContextCache.get(contextKey);
3746
+ if (current?.promise === pendingContext) {
3747
+ runActionContextCache.delete(contextKey);
3748
+ }
3749
+ throw error;
3750
+ });
3751
+ evictIfNeeded();
3752
+ runActionContextCache.set(contextKey, {
3753
+ promise: pendingContext,
3754
+ expiresAt: Date.now() + CONTEXT_CACHE_TTL_MS
3755
+ });
3756
+ return pendingContext;
3757
+ }
3758
+ async function resolveRunActionContext(options) {
3759
+ const { appKey, actionKey, actionType } = options;
3028
3760
  const selectedApi = await context.getVersionedImplementationId(appKey);
3029
3761
  if (!selectedApi) {
3030
3762
  throw new ZapierConfigurationError(
@@ -3032,11 +3764,6 @@ var runActionPlugin = ({ sdk, context }) => {
3032
3764
  { configType: "current_implementation_id" }
3033
3765
  );
3034
3766
  }
3035
- setMethodMetadata({
3036
- selectedApi,
3037
- operationType: actionType,
3038
- operationKey: actionKey
3039
- });
3040
3767
  const actionData = await sdk.getAction({
3041
3768
  appKey,
3042
3769
  actionKey,
@@ -3047,7 +3774,27 @@ var runActionPlugin = ({ sdk, context }) => {
3047
3774
  `Action type mismatch: expected ${actionType}, got ${actionData.data.action_type}`
3048
3775
  );
3049
3776
  }
3050
- const actionId = actionData.data.id;
3777
+ return { selectedApi, actionId: actionData.data.id };
3778
+ }
3779
+ async function runActionPage(options) {
3780
+ const { api } = context;
3781
+ const {
3782
+ appKey,
3783
+ actionKey,
3784
+ actionType,
3785
+ connectionId,
3786
+ authenticationId,
3787
+ inputs = {},
3788
+ cursor,
3789
+ timeoutMs
3790
+ } = options;
3791
+ const resolvedConnectionId = connectionId ?? authenticationId;
3792
+ const { selectedApi, actionId } = await getRunActionContext(options);
3793
+ setMethodMetadata({
3794
+ selectedApi,
3795
+ operationType: actionType,
3796
+ operationKey: actionKey
3797
+ });
3051
3798
  const result = await executeAction({
3052
3799
  api,
3053
3800
  selectedApi,
@@ -3057,6 +3804,7 @@ var runActionPlugin = ({ sdk, context }) => {
3057
3804
  actionKey,
3058
3805
  actionType,
3059
3806
  executionOptions: { inputs },
3807
+ cursor,
3060
3808
  connectionId: resolvedConnectionId,
3061
3809
  timeoutMs
3062
3810
  });
@@ -3071,8 +3819,7 @@ var runActionPlugin = ({ sdk, context }) => {
3071
3819
  }
3072
3820
  return {
3073
3821
  data: result.results || [],
3074
- nextCursor: void 0
3075
- // No pagination implemented yet
3822
+ nextCursor: result.next_page
3076
3823
  };
3077
3824
  }
3078
3825
  const methodName = stripPageSuffix(runActionPage.name);
@@ -4510,6 +5257,11 @@ var pathConfig = {
4510
5257
  "/zapier": {
4511
5258
  authHeader: "Authorization",
4512
5259
  pathPrefix: "/api/v0/sdk/zapier"
5260
+ },
5261
+ // e.g. /tables -> https://sdkapi.zapier.com/api/v0/sdk/tables/...
5262
+ "/tables": {
5263
+ authHeader: "Authorization",
5264
+ pathPrefix: "/api/v0/sdk/tables"
4513
5265
  }
4514
5266
  };
4515
5267
  var ZapierApiClient = class {
@@ -4577,8 +5329,11 @@ var ZapierApiClient = class {
4577
5329
  this.put = async (path, data, options = {}) => {
4578
5330
  return this.fetchJson("PUT", path, data, options);
4579
5331
  };
4580
- this.delete = async (path, options = {}) => {
4581
- return this.fetchJson("DELETE", path, void 0, options);
5332
+ this.patch = async (path, data, options = {}) => {
5333
+ return this.fetchJson("PATCH", path, data, options);
5334
+ };
5335
+ this.delete = async (path, data, options = {}) => {
5336
+ return this.fetchJson("DELETE", path, data, options);
4582
5337
  };
4583
5338
  this.poll = async (path, options = {}) => {
4584
5339
  return pollUntilComplete({
@@ -4982,155 +5737,1237 @@ async function batch(tasks, options = {}) {
4982
5737
  await Promise.all(workers);
4983
5738
  return results;
4984
5739
  }
5740
+ var TableApiItemSchema = zod.z.object({
5741
+ id: zod.z.string(),
5742
+ name: zod.z.string(),
5743
+ description: zod.z.string().nullable().optional(),
5744
+ created_at: zod.z.string(),
5745
+ edited_at: zod.z.string(),
5746
+ kind: zod.z.enum(["table", "virtual_table"]),
5747
+ owner_account_id: zod.z.number(),
5748
+ owner_user_id: zod.z.number().nullable().optional(),
5749
+ owner_zapier_customuser_id: zod.z.number(),
5750
+ parent_table_id: zod.z.string().nullable().optional()
5751
+ });
5752
+ var ListTablesApiResponseSchema = zod.z.object({
5753
+ data: zod.z.array(TableApiItemSchema),
5754
+ links: zod.z.object({
5755
+ next: zod.z.string().nullable().optional()
5756
+ }).optional()
5757
+ });
5758
+ var TableItemSchema = zod.z.object({
5759
+ id: zod.z.string(),
5760
+ name: zod.z.string(),
5761
+ description: zod.z.string().optional(),
5762
+ created_at: zod.z.string(),
5763
+ edited_at: zod.z.string(),
5764
+ kind: zod.z.enum(["table", "virtual_table"]),
5765
+ owner_account_id: zod.z.string(),
5766
+ profile_id: zod.z.string(),
5767
+ parent_table_id: zod.z.string().optional()
5768
+ });
5769
+ var ListTablesOptionsSchema = zod.z.object({
5770
+ tableIds: zod.z.array(zod.z.string()).optional().describe("Filter by specific table IDs"),
5771
+ kind: zod.z.enum(["table", "virtual_table", "both"]).optional().describe("Filter by table type"),
5772
+ search: zod.z.string().optional().describe("Search term to filter tables by name"),
5773
+ owner: zod.z.string().optional().describe(
5774
+ 'Filter by table owner. Use "me" for the current user, or a numeric user ID.'
5775
+ ),
5776
+ pageSize: zod.z.number().min(1).optional().describe("Number of tables per page"),
5777
+ maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
5778
+ cursor: zod.z.string().optional().describe("Cursor to start from")
5779
+ }).describe("List tables available to the authenticated user");
4985
5780
 
4986
- // src/plugins/registry/index.ts
4987
- var registryPlugin = ({ sdk, context }) => {
4988
- const metaKeys = Object.keys(context.meta || {});
4989
- const categoryDefinitions = {
4990
- account: {
4991
- title: "Account"
4992
- },
4993
- app: {
4994
- title: "App",
4995
- titlePlural: "Apps"
4996
- },
4997
- connection: {
4998
- title: "Connection"
4999
- },
5000
- action: {
5001
- title: "Action"
5002
- },
5003
- "client-credentials": {
5004
- title: "Client Credentials",
5005
- titlePlural: "Client Credentials"
5006
- },
5007
- http: {
5008
- title: "HTTP Request"
5009
- },
5010
- utility: {
5011
- title: "Utility",
5012
- titlePlural: "Utilities"
5013
- },
5014
- other: {
5015
- title: "Other"
5781
+ // src/plugins/tables/listTables/index.ts
5782
+ function extractNextCursor(links) {
5783
+ if (!links?.next) {
5784
+ return void 0;
5785
+ }
5786
+ try {
5787
+ const url = new URL(links.next);
5788
+ const offset = url.searchParams.get("offset");
5789
+ return offset || void 0;
5790
+ } catch {
5791
+ return void 0;
5792
+ }
5793
+ }
5794
+ var listTablesPlugin = ({ context }) => {
5795
+ async function listTablesPage(options) {
5796
+ const { api } = context;
5797
+ const searchParams = {};
5798
+ if (options.pageSize !== void 0) {
5799
+ searchParams.limit = options.pageSize.toString();
5016
5800
  }
5017
- };
5018
- const functions = metaKeys.filter((key) => {
5019
- const property = sdk[key];
5020
- if (typeof property === "function") {
5021
- return true;
5801
+ if (options?.tableIds && options.tableIds.length > 0) {
5802
+ searchParams.ids = options.tableIds.join(",");
5022
5803
  }
5023
- const [rootKey] = key.split(".");
5024
- const rootProperty = sdk[rootKey];
5025
- if (typeof rootProperty === "object" && rootProperty !== null) {
5026
- return true;
5804
+ if (options?.kind) {
5805
+ searchParams.kind = options.kind;
5027
5806
  }
5028
- return false;
5029
- }).map((key) => {
5030
- const meta = context.meta[key];
5031
- return {
5032
- name: key,
5033
- description: meta.description,
5034
- type: meta.type,
5035
- itemType: meta.itemType,
5036
- returnType: meta.returnType,
5037
- inputSchema: meta.inputSchema,
5038
- inputParameters: meta.inputParameters,
5039
- outputSchema: meta.outputSchema,
5040
- categories: meta.categories || [],
5041
- resolvers: meta.resolvers,
5042
- packages: meta.packages,
5043
- // Auto-infer confirm: "delete" from type: "delete" (all deletes should confirm)
5044
- confirm: meta.confirm ?? (meta.type === "delete" ? "delete" : void 0),
5045
- deprecation: meta.deprecation,
5046
- deprecatedParameters: meta.deprecatedParameters,
5047
- aliases: meta.aliases,
5048
- supportsJsonOutput: meta.supportsJsonOutput ?? true
5049
- };
5050
- }).sort((a, b) => a.name.localeCompare(b.name));
5051
- const knownCategories = Object.keys(categoryDefinitions);
5052
- const registryCache = /* @__PURE__ */ new Map();
5053
- function getRegistry(options) {
5054
- const packageFilter = options?.package;
5055
- const cacheKey = packageFilter || "__all__";
5056
- if (registryCache.has(cacheKey)) {
5057
- return registryCache.get(cacheKey);
5807
+ if (options?.search) {
5808
+ searchParams.q = options.search;
5058
5809
  }
5059
- const filteredFunctions = packageFilter ? functions.filter(
5060
- (f) => (
5061
- // Include if packages is undefined (belongs to all packages) or includes the specified package
5062
- !f.packages || f.packages.includes(packageFilter)
5063
- )
5064
- ) : functions;
5065
- const filteredCategories = knownCategories.sort((a, b) => {
5066
- if (a === "other") return 1;
5067
- if (b === "other") return -1;
5068
- const titleA = categoryDefinitions[a].title;
5069
- const titleB = categoryDefinitions[b].title;
5070
- return titleA.localeCompare(titleB);
5071
- }).map((categoryKey) => {
5072
- const categoryFunctions = filteredFunctions.filter(
5073
- (f) => f.categories.includes(categoryKey) || // If the category is "other" and the function is not in any other category, include it
5074
- categoryKey === "other" && !f.categories.some((c) => knownCategories.includes(c))
5075
- ).map((f) => f.name).sort();
5076
- const definition = categoryDefinitions[categoryKey];
5077
- const title = definition.title;
5078
- return {
5079
- key: categoryKey,
5080
- title,
5081
- titlePlural: definition.titlePlural ?? `${title}s`,
5082
- functions: categoryFunctions
5083
- };
5084
- }).filter((category) => category.functions.length > 0);
5085
- const result = {
5086
- functions: filteredFunctions,
5087
- categories: filteredCategories
5810
+ if (options?.owner) {
5811
+ let ownerId = options.owner;
5812
+ if (ownerId === "me") {
5813
+ const profile = await api.get("/zapier/api/v4/profile/", {
5814
+ authRequired: true
5815
+ });
5816
+ ownerId = String(profile.id);
5817
+ }
5818
+ searchParams.owner_customuser_id = ownerId;
5819
+ }
5820
+ if (options.cursor) {
5821
+ searchParams.offset = options.cursor;
5822
+ }
5823
+ const rawResponse = await api.get("/tables/api/v1/tables", {
5824
+ searchParams,
5825
+ customErrorHandler: ({ status }) => {
5826
+ if (status === 401) {
5827
+ return new ZapierAuthenticationError(
5828
+ `Authentication failed. Your token may not have permission to list tables or may be expired. (HTTP ${status})`,
5829
+ { statusCode: status }
5830
+ );
5831
+ }
5832
+ if (status === 403) {
5833
+ return new ZapierAuthenticationError(
5834
+ `Access forbidden. Your token may not have the required scopes to list tables. (HTTP ${status})`,
5835
+ { statusCode: status }
5836
+ );
5837
+ }
5838
+ return void 0;
5839
+ },
5840
+ authRequired: true
5841
+ });
5842
+ const response = ListTablesApiResponseSchema.parse(rawResponse);
5843
+ return {
5844
+ data: response.data.map(transformTableItem),
5845
+ nextCursor: extractNextCursor(response.links)
5088
5846
  };
5089
- registryCache.set(cacheKey, result);
5090
- return result;
5091
5847
  }
5848
+ const methodName = stripPageSuffix(listTablesPage.name);
5849
+ const listTablesDefinition = createPaginatedFunction(
5850
+ listTablesPage,
5851
+ ListTablesOptionsSchema,
5852
+ createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
5853
+ methodName,
5854
+ DEFAULT_PAGE_SIZE
5855
+ );
5092
5856
  return {
5093
- getRegistry
5857
+ listTables: listTablesDefinition,
5858
+ context: {
5859
+ meta: {
5860
+ listTables: {
5861
+ categories: ["table"],
5862
+ type: "list",
5863
+ itemType: "Table",
5864
+ inputSchema: ListTablesOptionsSchema,
5865
+ outputSchema: TableItemSchema
5866
+ }
5867
+ }
5868
+ }
5094
5869
  };
5095
5870
  };
5871
+ var GetTableApiResponseSchema = zod.z.object({
5872
+ data: TableApiItemSchema
5873
+ });
5874
+ var GetTableOptionsSchema = zod.z.object({
5875
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table to retrieve")
5876
+ }).describe("Get detailed information about a specific table");
5096
5877
 
5097
- // src/plugins/deprecated/authentications.ts
5098
- var listAuthenticationsPlugin = ({ sdk }) => ({
5099
- listAuthentications: sdk.listConnections,
5100
- context: {
5101
- meta: {
5102
- listAuthentications: {
5103
- packages: ["cli", "mcp"],
5104
- categories: ["connection", "deprecated"],
5105
- type: "list",
5106
- itemType: "Connection",
5107
- inputSchema: ListConnectionsQuerySchema,
5108
- outputSchema: ConnectionItemSchema
5878
+ // src/plugins/tables/getTable/index.ts
5879
+ var getTablePlugin = ({ context }) => {
5880
+ async function getTable(options) {
5881
+ const { api } = context;
5882
+ const rawResponse = await api.get(
5883
+ `/tables/api/v1/tables/${options.tableId}`,
5884
+ {
5885
+ customErrorHandler: ({ status }) => {
5886
+ if (status === 401) {
5887
+ return new ZapierAuthenticationError(
5888
+ `Authentication failed. Your token may not have permission to access this table or may be expired. (HTTP ${status})`,
5889
+ { statusCode: status }
5890
+ );
5891
+ }
5892
+ if (status === 403) {
5893
+ return new ZapierAuthenticationError(
5894
+ `Access forbidden. Your token may not have the required scopes to access this table. (HTTP ${status})`,
5895
+ { statusCode: status }
5896
+ );
5897
+ }
5898
+ if (status === 404) {
5899
+ return new Error(`Table not found: ${options.tableId}`);
5900
+ }
5901
+ return void 0;
5902
+ },
5903
+ authRequired: true
5109
5904
  }
5110
- }
5905
+ );
5906
+ const response = GetTableApiResponseSchema.parse(rawResponse);
5907
+ return {
5908
+ data: transformTableItem(response.data)
5909
+ };
5111
5910
  }
5112
- });
5113
- var getAuthenticationPlugin = ({ sdk }) => ({
5114
- getAuthentication: sdk.getConnection,
5115
- context: {
5116
- meta: {
5117
- getAuthentication: {
5118
- packages: ["cli", "mcp"],
5119
- categories: ["connection", "deprecated"],
5120
- type: "item",
5121
- itemType: "Connection",
5122
- inputSchema: GetConnectionParamSchema,
5123
- outputSchema: ConnectionItemSchema
5911
+ const getTableDefinition = createFunction(
5912
+ getTable,
5913
+ GetTableOptionsSchema,
5914
+ createTelemetryCallback(
5915
+ context.eventEmission.emitMethodCalled,
5916
+ getTable.name
5917
+ )
5918
+ );
5919
+ return {
5920
+ getTable: getTableDefinition,
5921
+ context: {
5922
+ meta: {
5923
+ getTable: {
5924
+ categories: ["table"],
5925
+ type: "item",
5926
+ itemType: "Table",
5927
+ inputSchema: GetTableOptionsSchema,
5928
+ outputSchema: TableItemSchema,
5929
+ resolvers: {
5930
+ tableId: tableIdResolver
5931
+ }
5932
+ }
5124
5933
  }
5125
5934
  }
5126
- }
5935
+ };
5936
+ };
5937
+ var CreateTableApiResponseSchema = zod.z.object({
5938
+ data: TableApiItemSchema
5127
5939
  });
5128
- var findFirstAuthenticationPlugin = ({ sdk }) => ({
5129
- findFirstAuthentication: sdk.findFirstConnection,
5130
- context: {
5131
- meta: {
5132
- findFirstAuthentication: {
5133
- packages: ["cli", "mcp"],
5940
+ var CreateTableOptionsSchema = zod.z.object({
5941
+ name: zod.z.string().min(1).describe("The name for the new table"),
5942
+ description: zod.z.string().optional().describe("An optional description of the table")
5943
+ }).describe("Create a new table");
5944
+
5945
+ // src/plugins/tables/createTable/index.ts
5946
+ var createTablePlugin = ({ context }) => {
5947
+ async function createTable(options) {
5948
+ const { api } = context;
5949
+ const rawResponse = await api.post(
5950
+ "/tables/api/v1/tables",
5951
+ {
5952
+ name: options.name,
5953
+ description: options.description
5954
+ },
5955
+ {
5956
+ customErrorHandler: ({ status }) => {
5957
+ if (status === 401) {
5958
+ return new ZapierAuthenticationError(
5959
+ `Authentication failed. Your token may not have permission to create tables or may be expired. (HTTP ${status})`,
5960
+ { statusCode: status }
5961
+ );
5962
+ }
5963
+ if (status === 403) {
5964
+ return new ZapierAuthenticationError(
5965
+ `Access forbidden. Your token may not have the required scopes to create tables. (HTTP ${status})`,
5966
+ { statusCode: status }
5967
+ );
5968
+ }
5969
+ return void 0;
5970
+ },
5971
+ authRequired: true
5972
+ }
5973
+ );
5974
+ const response = CreateTableApiResponseSchema.parse(rawResponse);
5975
+ return {
5976
+ data: transformTableItem(response.data)
5977
+ };
5978
+ }
5979
+ const createTableDefinition = createFunction(
5980
+ createTable,
5981
+ CreateTableOptionsSchema,
5982
+ createTelemetryCallback(
5983
+ context.eventEmission.emitMethodCalled,
5984
+ createTable.name
5985
+ )
5986
+ );
5987
+ return {
5988
+ createTable: createTableDefinition,
5989
+ context: {
5990
+ meta: {
5991
+ createTable: {
5992
+ categories: ["table"],
5993
+ type: "create",
5994
+ itemType: "Table",
5995
+ inputSchema: CreateTableOptionsSchema,
5996
+ outputSchema: TableItemSchema,
5997
+ resolvers: {
5998
+ name: tableNameResolver
5999
+ }
6000
+ }
6001
+ }
6002
+ }
6003
+ };
6004
+ };
6005
+ var DeleteTableOptionsSchema = zod.z.object({
6006
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table to delete")
6007
+ }).describe("Delete a table by its ID");
6008
+
6009
+ // src/plugins/tables/deleteTable/index.ts
6010
+ var deleteTablePlugin = ({ context }) => {
6011
+ async function deleteTable(options) {
6012
+ const { api } = context;
6013
+ await api.delete(`/tables/api/v1/tables/${options.tableId}`, void 0, {
6014
+ customErrorHandler: ({ status }) => {
6015
+ if (status === 401) {
6016
+ return new ZapierAuthenticationError(
6017
+ `Authentication failed. Your token may not have permission to delete tables or may be expired. (HTTP ${status})`,
6018
+ { statusCode: status }
6019
+ );
6020
+ }
6021
+ if (status === 403) {
6022
+ return new ZapierAuthenticationError(
6023
+ `Access forbidden. Your token may not have the required scopes to delete tables. (HTTP ${status})`,
6024
+ { statusCode: status }
6025
+ );
6026
+ }
6027
+ return void 0;
6028
+ },
6029
+ authRequired: true
6030
+ });
6031
+ return {
6032
+ success: true
6033
+ };
6034
+ }
6035
+ const deleteTableDefinition = createFunction(
6036
+ deleteTable,
6037
+ DeleteTableOptionsSchema,
6038
+ createTelemetryCallback(
6039
+ context.eventEmission.emitMethodCalled,
6040
+ deleteTable.name
6041
+ )
6042
+ );
6043
+ return {
6044
+ deleteTable: deleteTableDefinition,
6045
+ context: {
6046
+ meta: {
6047
+ deleteTable: {
6048
+ categories: ["table"],
6049
+ type: "delete",
6050
+ itemType: "Table",
6051
+ inputSchema: DeleteTableOptionsSchema,
6052
+ resolvers: {
6053
+ tableId: tableIdResolver
6054
+ },
6055
+ confirm: "delete"
6056
+ }
6057
+ }
6058
+ }
6059
+ };
6060
+ };
6061
+
6062
+ // src/plugins/tables/listTableFields/index.ts
6063
+ var listTableFieldsPlugin = ({ context }) => {
6064
+ async function listTableFields(options) {
6065
+ const { api } = context;
6066
+ const searchParams = {};
6067
+ if (options.fieldKeys && options.fieldKeys.length > 0) {
6068
+ const numericIds = await resolveFieldKeys({
6069
+ api,
6070
+ tableId: options.tableId,
6071
+ fieldKeys: options.fieldKeys
6072
+ });
6073
+ searchParams.field_ids = numericIds.join(",");
6074
+ }
6075
+ const rawResponse = await api.get(
6076
+ `/tables/api/v1/tables/${options.tableId}/fields`,
6077
+ {
6078
+ searchParams: Object.keys(searchParams).length > 0 ? searchParams : void 0,
6079
+ customErrorHandler: ({ status }) => {
6080
+ if (status === 401) {
6081
+ return new ZapierAuthenticationError(
6082
+ `Authentication failed. Your token may not have permission to access this table or may be expired. (HTTP ${status})`,
6083
+ { statusCode: status }
6084
+ );
6085
+ }
6086
+ if (status === 403) {
6087
+ return new ZapierAuthenticationError(
6088
+ `Access forbidden. Your token may not have the required scopes to access this table. (HTTP ${status})`,
6089
+ { statusCode: status }
6090
+ );
6091
+ }
6092
+ if (status === 404) {
6093
+ return new Error(`Table not found: ${options.tableId}`);
6094
+ }
6095
+ return void 0;
6096
+ },
6097
+ authRequired: true
6098
+ }
6099
+ );
6100
+ const response = ListTableFieldsApiResponseSchema.parse(rawResponse);
6101
+ return {
6102
+ data: response.data.map(transformFieldItem)
6103
+ };
6104
+ }
6105
+ const listTableFieldsDefinition = createFunction(
6106
+ listTableFields,
6107
+ ListTableFieldsOptionsSchema,
6108
+ createTelemetryCallback(
6109
+ context.eventEmission.emitMethodCalled,
6110
+ listTableFields.name
6111
+ )
6112
+ );
6113
+ return {
6114
+ listTableFields: listTableFieldsDefinition,
6115
+ context: {
6116
+ meta: {
6117
+ listTableFields: {
6118
+ categories: ["table"],
6119
+ type: "list",
6120
+ itemType: "Field",
6121
+ inputSchema: ListTableFieldsOptionsSchema,
6122
+ outputSchema: FieldItemSchema,
6123
+ resolvers: {
6124
+ tableId: tableIdResolver
6125
+ }
6126
+ }
6127
+ }
6128
+ }
6129
+ };
6130
+ };
6131
+ var FieldChangesetItemSchema = zod.z.object({
6132
+ new: FieldApiItemSchema,
6133
+ old: FieldApiItemSchema.nullable(),
6134
+ kind: zod.z.enum(["created", "updated", "deleted"])
6135
+ });
6136
+ var CreateTableFieldsApiResponseSchema = zod.z.object({
6137
+ data: zod.z.array(FieldChangesetItemSchema),
6138
+ meta: zod.z.object({
6139
+ did_change: zod.z.boolean()
6140
+ }).optional()
6141
+ });
6142
+ var NewFieldSchema = zod.z.object({
6143
+ type: FieldTypeSchema.describe("The data type of the field"),
6144
+ name: zod.z.string().min(1).describe("The display name of the field"),
6145
+ options: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe("Data configuration options for the field"),
6146
+ config: zod.z.record(zod.z.string(), zod.z.unknown()).optional().describe("Display configuration for the field")
6147
+ });
6148
+ var CreateTableFieldsOptionsSchema = zod.z.object({
6149
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table"),
6150
+ fields: zod.z.array(NewFieldSchema).min(1).describe("Array of field definitions to create")
6151
+ }).describe("Create one or more fields in a table");
6152
+
6153
+ // src/plugins/tables/createTableFields/index.ts
6154
+ var createTableFieldsPlugin = ({ context }) => {
6155
+ async function createTableFields(options) {
6156
+ const { api } = context;
6157
+ const rawResponse = await api.post(
6158
+ `/tables/api/v1/tables/${options.tableId}/fields`,
6159
+ {
6160
+ new_fields: options.fields
6161
+ },
6162
+ {
6163
+ customErrorHandler: ({ status }) => {
6164
+ if (status === 401) {
6165
+ return new ZapierAuthenticationError(
6166
+ `Authentication failed. Your token may not have permission to create fields or may be expired. (HTTP ${status})`,
6167
+ { statusCode: status }
6168
+ );
6169
+ }
6170
+ if (status === 403) {
6171
+ return new ZapierAuthenticationError(
6172
+ `Access forbidden. Your token may not have the required scopes to create fields. (HTTP ${status})`,
6173
+ { statusCode: status }
6174
+ );
6175
+ }
6176
+ return void 0;
6177
+ },
6178
+ authRequired: true
6179
+ }
6180
+ );
6181
+ const response = CreateTableFieldsApiResponseSchema.parse(rawResponse);
6182
+ return {
6183
+ data: response.data.map((changeset) => transformFieldItem(changeset.new))
6184
+ };
6185
+ }
6186
+ const createTableFieldsDefinition = createFunction(
6187
+ createTableFields,
6188
+ CreateTableFieldsOptionsSchema,
6189
+ createTelemetryCallback(
6190
+ context.eventEmission.emitMethodCalled,
6191
+ createTableFields.name
6192
+ )
6193
+ );
6194
+ return {
6195
+ createTableFields: createTableFieldsDefinition,
6196
+ context: {
6197
+ meta: {
6198
+ createTableFields: {
6199
+ categories: ["table"],
6200
+ type: "create",
6201
+ itemType: "Field",
6202
+ inputSchema: CreateTableFieldsOptionsSchema,
6203
+ outputSchema: FieldItemSchema,
6204
+ resolvers: {
6205
+ tableId: tableIdResolver,
6206
+ fields: tableFieldsResolver
6207
+ }
6208
+ }
6209
+ }
6210
+ }
6211
+ };
6212
+ };
6213
+ var DeleteTableFieldsOptionsSchema = zod.z.object({
6214
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table"),
6215
+ fieldKeys: zod.z.array(zod.z.union([zod.z.string(), zod.z.number()])).min(1).describe(
6216
+ 'Fields to delete. Accepts field names (e.g., "Email") or IDs (e.g., "f6", "6", or 6).'
6217
+ )
6218
+ }).describe("Delete one or more fields from a table");
6219
+
6220
+ // src/plugins/tables/deleteTableFields/index.ts
6221
+ var deleteTableFieldsPlugin = ({ context }) => {
6222
+ async function deleteTableFields(options) {
6223
+ const { api } = context;
6224
+ const numericFieldIds = await resolveFieldKeys({
6225
+ api,
6226
+ tableId: options.tableId,
6227
+ fieldKeys: options.fieldKeys
6228
+ });
6229
+ await api.delete(
6230
+ `/tables/api/v1/tables/${options.tableId}/fields`,
6231
+ { field_ids: numericFieldIds },
6232
+ {
6233
+ customErrorHandler: ({ status }) => {
6234
+ if (status === 401) {
6235
+ return new ZapierAuthenticationError(
6236
+ `Authentication failed. Your token may not have permission to delete fields or may be expired. (HTTP ${status})`,
6237
+ { statusCode: status }
6238
+ );
6239
+ }
6240
+ if (status === 403) {
6241
+ return new ZapierAuthenticationError(
6242
+ `Access forbidden. Your token may not have the required scopes to delete fields. (HTTP ${status})`,
6243
+ { statusCode: status }
6244
+ );
6245
+ }
6246
+ return void 0;
6247
+ },
6248
+ authRequired: true
6249
+ }
6250
+ );
6251
+ return {
6252
+ success: true
6253
+ };
6254
+ }
6255
+ const deleteTableFieldsDefinition = createFunction(
6256
+ deleteTableFields,
6257
+ DeleteTableFieldsOptionsSchema,
6258
+ createTelemetryCallback(
6259
+ context.eventEmission.emitMethodCalled,
6260
+ deleteTableFields.name
6261
+ )
6262
+ );
6263
+ return {
6264
+ deleteTableFields: deleteTableFieldsDefinition,
6265
+ context: {
6266
+ meta: {
6267
+ deleteTableFields: {
6268
+ categories: ["table"],
6269
+ type: "delete",
6270
+ itemType: "Field",
6271
+ inputSchema: DeleteTableFieldsOptionsSchema,
6272
+ resolvers: {
6273
+ tableId: tableIdResolver,
6274
+ fieldKeys: tableFieldIdsResolver
6275
+ },
6276
+ confirm: "delete"
6277
+ }
6278
+ }
6279
+ }
6280
+ };
6281
+ };
6282
+ var RecordApiItemSchema = zod.z.object({
6283
+ id: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID"),
6284
+ data: zod.z.record(zod.z.string(), zod.z.unknown()),
6285
+ created_at: zod.z.string(),
6286
+ edited_at: zod.z.string(),
6287
+ schema_revision_id: zod.z.number(),
6288
+ errors: zod.z.record(zod.z.string(), zod.z.unknown()).nullable().optional(),
6289
+ orig_data: zod.z.record(zod.z.string(), zod.z.unknown()).nullable().optional(),
6290
+ is_source_record: zod.z.boolean().nullable().optional()
6291
+ });
6292
+ var RecordItemSchemaBase = zod.z.object({
6293
+ id: zod.z.string(),
6294
+ data: zod.z.record(zod.z.string(), zod.z.unknown()),
6295
+ created_at: zod.z.string(),
6296
+ edited_at: zod.z.string()
6297
+ });
6298
+ var RecordItemSchema = withFormatter(RecordItemSchemaBase, {
6299
+ format: (item) => ({
6300
+ title: `Record ${item.id}`,
6301
+ id: item.id,
6302
+ data: item.data,
6303
+ details: []
6304
+ })
6305
+ });
6306
+ var GetTableRecordApiResponseSchema = zod.z.object({
6307
+ data: RecordApiItemSchema
6308
+ });
6309
+ var GetTableRecordOptionsSchema = zod.z.object({
6310
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table"),
6311
+ recordId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID").describe("The unique identifier of the record"),
6312
+ keyMode: KeyModeSchema
6313
+ }).describe("Get a single record from a table by ID");
6314
+
6315
+ // src/formatters/tableRecord.ts
6316
+ var tableRecordFormatter = {
6317
+ fetch: async (sdk, params, item, context) => {
6318
+ if (context) return context;
6319
+ const hasFieldIds = Object.keys(item.data).some(isFieldId);
6320
+ if (!hasFieldIds) return {};
6321
+ const { data: fields } = await sdk.listTableFields({
6322
+ tableId: params.tableId
6323
+ });
6324
+ return Object.fromEntries(fields.map((f) => [f.id, f.name]));
6325
+ },
6326
+ format: (item, fieldLabels) => ({
6327
+ title: `Record ${item.id}`,
6328
+ id: item.id,
6329
+ details: Object.entries(item.data).map(([k, v]) => ({
6330
+ label: fieldLabels?.[k] ?? k,
6331
+ text: formatFieldValue(v),
6332
+ style: "normal"
6333
+ }))
6334
+ })
6335
+ };
6336
+
6337
+ // src/plugins/tables/getTableRecord/index.ts
6338
+ var getTableRecordPlugin = ({ context }) => {
6339
+ async function getTableRecord(options) {
6340
+ const { api } = context;
6341
+ const rawResponse = await api.get(
6342
+ `/tables/api/v1/tables/${options.tableId}/records/${options.recordId}`,
6343
+ {
6344
+ customErrorHandler: ({ status }) => {
6345
+ if (status === 401) {
6346
+ return new ZapierAuthenticationError(
6347
+ `Authentication failed. Your token may not have permission to access this record or may be expired. (HTTP ${status})`,
6348
+ { statusCode: status }
6349
+ );
6350
+ }
6351
+ if (status === 403) {
6352
+ return new ZapierAuthenticationError(
6353
+ `Access forbidden. Your token may not have the required scopes to access this record. (HTTP ${status})`,
6354
+ { statusCode: status }
6355
+ );
6356
+ }
6357
+ if (status === 404) {
6358
+ return new Error(`Record not found: ${options.recordId}`);
6359
+ }
6360
+ return void 0;
6361
+ },
6362
+ authRequired: true
6363
+ }
6364
+ );
6365
+ const response = GetTableRecordApiResponseSchema.parse(rawResponse);
6366
+ const translator = await createFieldKeyTranslator({
6367
+ api,
6368
+ tableId: options.tableId,
6369
+ keyMode: options.keyMode
6370
+ });
6371
+ return {
6372
+ data: {
6373
+ ...transformRecordItem(response.data),
6374
+ data: translator.translateOutput(response.data.data)
6375
+ }
6376
+ };
6377
+ }
6378
+ const getTableRecordDefinition = createFunction(
6379
+ getTableRecord,
6380
+ GetTableRecordOptionsSchema,
6381
+ createTelemetryCallback(
6382
+ context.eventEmission.emitMethodCalled,
6383
+ getTableRecord.name
6384
+ )
6385
+ );
6386
+ return {
6387
+ getTableRecord: getTableRecordDefinition,
6388
+ context: {
6389
+ meta: {
6390
+ getTableRecord: {
6391
+ categories: ["table"],
6392
+ type: "item",
6393
+ itemType: "Record",
6394
+ inputSchema: GetTableRecordOptionsSchema,
6395
+ outputSchema: RecordItemSchema,
6396
+ resolvers: {
6397
+ tableId: tableIdResolver,
6398
+ recordId: tableRecordIdResolver
6399
+ },
6400
+ formatter: tableRecordFormatter
6401
+ }
6402
+ }
6403
+ }
6404
+ };
6405
+ };
6406
+ var ListTableRecordsApiResponseSchema = zod.z.object({
6407
+ data: zod.z.array(RecordApiItemSchema),
6408
+ meta: zod.z.object({
6409
+ pagination: zod.z.object({
6410
+ start_cursor: zod.z.string().nullable().optional(),
6411
+ end_cursor: zod.z.string().nullable().optional(),
6412
+ has_more: zod.z.boolean().optional(),
6413
+ has_less: zod.z.boolean().optional()
6414
+ }).optional()
6415
+ }).optional()
6416
+ });
6417
+ var FilterOperatorSchema = zod.z.enum([
6418
+ "exact",
6419
+ "different",
6420
+ "contains",
6421
+ "icontains",
6422
+ "gte",
6423
+ "gt",
6424
+ "lt",
6425
+ "lte",
6426
+ "range",
6427
+ "in",
6428
+ "isnull",
6429
+ "startswith",
6430
+ "search",
6431
+ "is_within"
6432
+ ]);
6433
+ var FilterConditionSchema = zod.z.object({
6434
+ fieldKey: zod.z.string().describe("The field key to filter on (e.g. f1, f2)"),
6435
+ operator: FilterOperatorSchema.describe("The comparison operator"),
6436
+ value: zod.z.unknown().optional().describe("The value to compare against")
6437
+ });
6438
+ var SortDirectionSchema = zod.z.enum(["asc", "desc"]);
6439
+ var SortConditionSchema = zod.z.object({
6440
+ fieldKey: zod.z.string().describe("The field key to sort by"),
6441
+ direction: SortDirectionSchema.optional().default("asc").describe("Sort direction")
6442
+ });
6443
+ var ListTableRecordsOptionsSchema = zod.z.object({
6444
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table"),
6445
+ filters: zod.z.array(FilterConditionSchema).optional().describe("Filter conditions for the query"),
6446
+ sort: SortConditionSchema.optional().describe("Sort records by a field"),
6447
+ pageSize: zod.z.number().min(1).max(1e3).optional().describe("Number of records per page (max 1000)"),
6448
+ maxItems: zod.z.number().min(1).optional().describe("Maximum total items to return across all pages"),
6449
+ cursor: zod.z.string().optional().describe("Cursor to start from"),
6450
+ keyMode: KeyModeSchema
6451
+ }).describe("List records in a table with optional filtering and sorting");
6452
+
6453
+ // src/plugins/tables/listTableRecords/index.ts
6454
+ function extractNextCursor2(meta) {
6455
+ if (!meta?.pagination?.has_more || !meta.pagination.end_cursor) {
6456
+ return void 0;
6457
+ }
6458
+ return meta.pagination.end_cursor;
6459
+ }
6460
+ var listTableRecordsPlugin = ({ context }) => {
6461
+ async function listTableRecordsPage(options) {
6462
+ const { api } = context;
6463
+ const translator = await createFieldKeyTranslator({
6464
+ api,
6465
+ tableId: options.tableId,
6466
+ keyMode: options.keyMode
6467
+ });
6468
+ const body = {};
6469
+ if (options.pageSize !== void 0) {
6470
+ body.limit = options.pageSize;
6471
+ }
6472
+ if (options.filters) {
6473
+ body.filters = options.filters.map((f) => ({
6474
+ key: translator.translateFieldKey(f.fieldKey),
6475
+ operator: f.operator,
6476
+ value: f.value
6477
+ }));
6478
+ }
6479
+ if (options.sort) {
6480
+ body.orders = [
6481
+ {
6482
+ key: translator.translateFieldKey(options.sort.fieldKey),
6483
+ direction: options.sort.direction
6484
+ }
6485
+ ];
6486
+ }
6487
+ if (options.cursor) {
6488
+ body.cursor_query = {
6489
+ query_type: "window",
6490
+ start_cursor: options.cursor
6491
+ };
6492
+ }
6493
+ const rawResponse = await api.post(
6494
+ `/tables/api/v1/tables/${options.tableId}/records/query`,
6495
+ body,
6496
+ {
6497
+ searchParams: { allow_nested_queries: "true" },
6498
+ customErrorHandler: ({ status }) => {
6499
+ if (status === 401) {
6500
+ return new ZapierAuthenticationError(
6501
+ `Authentication failed. Your token may not have permission to access this table or may be expired. (HTTP ${status})`,
6502
+ { statusCode: status }
6503
+ );
6504
+ }
6505
+ if (status === 403) {
6506
+ return new ZapierAuthenticationError(
6507
+ `Access forbidden. Your token may not have the required scopes to access this table. (HTTP ${status})`,
6508
+ { statusCode: status }
6509
+ );
6510
+ }
6511
+ if (status === 404) {
6512
+ return new Error(`Table not found: ${options.tableId}`);
6513
+ }
6514
+ return void 0;
6515
+ },
6516
+ authRequired: true
6517
+ }
6518
+ );
6519
+ throwOnResponseErrors(rawResponse);
6520
+ const response = ListTableRecordsApiResponseSchema.parse(rawResponse);
6521
+ return {
6522
+ data: response.data.map((item) => ({
6523
+ ...transformRecordItem(item),
6524
+ data: translator.translateOutput(item.data)
6525
+ })),
6526
+ nextCursor: extractNextCursor2(response.meta)
6527
+ };
6528
+ }
6529
+ const methodName = stripPageSuffix(listTableRecordsPage.name);
6530
+ const listTableRecordsDefinition = createPaginatedFunction(
6531
+ listTableRecordsPage,
6532
+ ListTableRecordsOptionsSchema,
6533
+ createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
6534
+ methodName,
6535
+ DEFAULT_PAGE_SIZE
6536
+ );
6537
+ return {
6538
+ listTableRecords: listTableRecordsDefinition,
6539
+ context: {
6540
+ meta: {
6541
+ listTableRecords: {
6542
+ categories: ["table"],
6543
+ type: "list",
6544
+ itemType: "Record",
6545
+ inputSchema: ListTableRecordsOptionsSchema,
6546
+ outputSchema: RecordItemSchema,
6547
+ resolvers: {
6548
+ tableId: tableIdResolver,
6549
+ filters: tableFiltersResolver,
6550
+ sort: tableSortResolver
6551
+ },
6552
+ formatter: tableRecordFormatter
6553
+ }
6554
+ }
6555
+ }
6556
+ };
6557
+ };
6558
+ var RecordChangesetSchema = zod.z.object({
6559
+ change_id: zod.z.string(),
6560
+ old: RecordApiItemSchema.nullable(),
6561
+ new: RecordApiItemSchema,
6562
+ changed_field_ids: zod.z.array(zod.z.number()).nullable(),
6563
+ record_id: zod.z.string()
6564
+ });
6565
+ var CreateTableRecordsApiResponseSchema = zod.z.object({
6566
+ data: zod.z.array(RecordChangesetSchema)
6567
+ });
6568
+ var NewRecordSchema = zod.z.object({
6569
+ data: zod.z.record(zod.z.string(), zod.z.unknown()).describe("The field values for the record, keyed by field ID")
6570
+ });
6571
+ var CreateTableRecordsOptionsSchema = zod.z.object({
6572
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table"),
6573
+ records: zod.z.array(NewRecordSchema).min(1).max(100).describe("Array of records to create (max 100)"),
6574
+ keyMode: KeyModeSchema
6575
+ }).describe("Create one or more records in a table");
6576
+
6577
+ // src/plugins/tables/createTableRecords/index.ts
6578
+ var createTableRecordsPlugin = ({ context }) => {
6579
+ async function createTableRecords(options) {
6580
+ const { api } = context;
6581
+ const translator = await createFieldKeyTranslator({
6582
+ api,
6583
+ tableId: options.tableId,
6584
+ keyMode: options.keyMode
6585
+ });
6586
+ const rawResponse = await api.post(
6587
+ `/tables/api/v1/tables/${options.tableId}/records`,
6588
+ {
6589
+ new_records: options.records.map((record) => ({
6590
+ data: translator.translateInput(record.data)
6591
+ }))
6592
+ },
6593
+ {
6594
+ customErrorHandler: ({ status }) => {
6595
+ if (status === 401) {
6596
+ return new ZapierAuthenticationError(
6597
+ `Authentication failed. Your token may not have permission to create records or may be expired. (HTTP ${status})`,
6598
+ { statusCode: status }
6599
+ );
6600
+ }
6601
+ if (status === 403) {
6602
+ return new ZapierAuthenticationError(
6603
+ `Access forbidden. Your token may not have the required scopes to create records. (HTTP ${status})`,
6604
+ { statusCode: status }
6605
+ );
6606
+ }
6607
+ if (status === 404) {
6608
+ return new Error(`Table not found: ${options.tableId}`);
6609
+ }
6610
+ return void 0;
6611
+ },
6612
+ authRequired: true
6613
+ }
6614
+ );
6615
+ throwOnResponseErrors(rawResponse);
6616
+ const response = CreateTableRecordsApiResponseSchema.parse(rawResponse);
6617
+ for (const changeset of response.data) {
6618
+ throwOnRecordErrors(changeset.new);
6619
+ }
6620
+ return {
6621
+ data: response.data.map((changeset) => ({
6622
+ ...transformRecordItem(changeset.new),
6623
+ data: translator.translateOutput(changeset.new.data)
6624
+ }))
6625
+ };
6626
+ }
6627
+ const createTableRecordsDefinition = createFunction(
6628
+ createTableRecords,
6629
+ CreateTableRecordsOptionsSchema,
6630
+ createTelemetryCallback(
6631
+ context.eventEmission.emitMethodCalled,
6632
+ createTableRecords.name
6633
+ )
6634
+ );
6635
+ return {
6636
+ createTableRecords: createTableRecordsDefinition,
6637
+ context: {
6638
+ meta: {
6639
+ createTableRecords: {
6640
+ categories: ["table"],
6641
+ type: "create",
6642
+ itemType: "Record",
6643
+ inputSchema: CreateTableRecordsOptionsSchema,
6644
+ outputSchema: RecordItemSchema,
6645
+ resolvers: {
6646
+ tableId: tableIdResolver,
6647
+ records: tableRecordsResolver
6648
+ },
6649
+ formatter: tableRecordFormatter
6650
+ }
6651
+ }
6652
+ }
6653
+ };
6654
+ };
6655
+ var DeleteTableRecordsOptionsSchema = zod.z.object({
6656
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table"),
6657
+ recordIds: zod.z.array(
6658
+ zod.z.string().regex(/^[A-Z0-9]{26}$/, "Record ID must be a valid ULID")
6659
+ ).min(1).max(100).describe("Array of record IDs to delete (max 100)")
6660
+ }).describe("Delete one or more records from a table");
6661
+
6662
+ // src/plugins/tables/deleteTableRecords/index.ts
6663
+ var deleteTableRecordsPlugin = ({ context }) => {
6664
+ async function deleteTableRecords(options) {
6665
+ const { api } = context;
6666
+ await api.delete(
6667
+ `/tables/api/v1/tables/${options.tableId}/records`,
6668
+ { record_ids: options.recordIds },
6669
+ {
6670
+ customErrorHandler: ({ status }) => {
6671
+ if (status === 401) {
6672
+ return new ZapierAuthenticationError(
6673
+ `Authentication failed. Your token may not have permission to delete records or may be expired. (HTTP ${status})`,
6674
+ { statusCode: status }
6675
+ );
6676
+ }
6677
+ if (status === 403) {
6678
+ return new ZapierAuthenticationError(
6679
+ `Access forbidden. Your token may not have the required scopes to delete records. (HTTP ${status})`,
6680
+ { statusCode: status }
6681
+ );
6682
+ }
6683
+ return void 0;
6684
+ },
6685
+ authRequired: true
6686
+ }
6687
+ );
6688
+ return {
6689
+ success: true
6690
+ };
6691
+ }
6692
+ const deleteTableRecordsDefinition = createFunction(
6693
+ deleteTableRecords,
6694
+ DeleteTableRecordsOptionsSchema,
6695
+ createTelemetryCallback(
6696
+ context.eventEmission.emitMethodCalled,
6697
+ deleteTableRecords.name
6698
+ )
6699
+ );
6700
+ return {
6701
+ deleteTableRecords: deleteTableRecordsDefinition,
6702
+ context: {
6703
+ meta: {
6704
+ deleteTableRecords: {
6705
+ categories: ["table"],
6706
+ type: "delete",
6707
+ itemType: "Record",
6708
+ inputSchema: DeleteTableRecordsOptionsSchema,
6709
+ resolvers: {
6710
+ tableId: tableIdResolver,
6711
+ recordIds: tableRecordIdsResolver
6712
+ },
6713
+ confirm: "delete"
6714
+ }
6715
+ }
6716
+ }
6717
+ };
6718
+ };
6719
+ var RecordChangesetSchema2 = zod.z.object({
6720
+ change_id: zod.z.string(),
6721
+ old: RecordApiItemSchema.nullable(),
6722
+ new: RecordApiItemSchema,
6723
+ changed_field_ids: zod.z.array(zod.z.number()).nullable(),
6724
+ record_id: zod.z.string()
6725
+ });
6726
+ var UpdateTableRecordsApiResponseSchema = zod.z.object({
6727
+ data: zod.z.array(RecordChangesetSchema2)
6728
+ });
6729
+ var UpdateRecordSchema = zod.z.object({
6730
+ id: zod.z.string().describe("The record ID to update"),
6731
+ data: zod.z.record(zod.z.string(), zod.z.unknown()).describe("The field values to update, keyed by field key")
6732
+ });
6733
+ var UpdateTableRecordsOptionsSchema = zod.z.object({
6734
+ tableId: zod.z.string().regex(/^[A-Z0-9]{26}$/, "Table ID must be a valid ULID").describe("The unique identifier of the table"),
6735
+ records: zod.z.array(UpdateRecordSchema).min(1).max(100).describe("Array of records to update (max 100)"),
6736
+ keyMode: KeyModeSchema
6737
+ }).describe("Update one or more records in a table");
6738
+
6739
+ // src/plugins/tables/updateTableRecords/index.ts
6740
+ var updateTableRecordsPlugin = ({ context }) => {
6741
+ async function updateTableRecords(options) {
6742
+ const { api } = context;
6743
+ const translator = await createFieldKeyTranslator({
6744
+ api,
6745
+ tableId: options.tableId,
6746
+ keyMode: options.keyMode
6747
+ });
6748
+ const rawResponse = await api.patch(
6749
+ `/tables/api/v1/tables/${options.tableId}/records`,
6750
+ {
6751
+ updated_records: options.records.map((record) => ({
6752
+ id: record.id,
6753
+ data: translator.translateInput(record.data)
6754
+ }))
6755
+ },
6756
+ {
6757
+ customErrorHandler: ({ status }) => {
6758
+ if (status === 401) {
6759
+ return new ZapierAuthenticationError(
6760
+ `Authentication failed. Your token may not have permission to update records or may be expired. (HTTP ${status})`,
6761
+ { statusCode: status }
6762
+ );
6763
+ }
6764
+ if (status === 403) {
6765
+ return new ZapierAuthenticationError(
6766
+ `Access forbidden. Your token may not have the required scopes to update records. (HTTP ${status})`,
6767
+ { statusCode: status }
6768
+ );
6769
+ }
6770
+ if (status === 404) {
6771
+ return new Error(`Table not found: ${options.tableId}`);
6772
+ }
6773
+ return void 0;
6774
+ },
6775
+ authRequired: true
6776
+ }
6777
+ );
6778
+ throwOnResponseErrors(rawResponse);
6779
+ const response = UpdateTableRecordsApiResponseSchema.parse(rawResponse);
6780
+ for (const changeset of response.data) {
6781
+ throwOnRecordErrors(changeset.new);
6782
+ }
6783
+ return {
6784
+ data: response.data.map((changeset) => ({
6785
+ ...transformRecordItem(changeset.new),
6786
+ data: translator.translateOutput(changeset.new.data)
6787
+ }))
6788
+ };
6789
+ }
6790
+ const updateTableRecordsDefinition = createFunction(
6791
+ updateTableRecords,
6792
+ UpdateTableRecordsOptionsSchema,
6793
+ createTelemetryCallback(
6794
+ context.eventEmission.emitMethodCalled,
6795
+ updateTableRecords.name
6796
+ )
6797
+ );
6798
+ return {
6799
+ updateTableRecords: updateTableRecordsDefinition,
6800
+ context: {
6801
+ meta: {
6802
+ updateTableRecords: {
6803
+ categories: ["table"],
6804
+ type: "update",
6805
+ itemType: "Record",
6806
+ inputSchema: UpdateTableRecordsOptionsSchema,
6807
+ outputSchema: RecordItemSchema,
6808
+ resolvers: {
6809
+ tableId: tableIdResolver,
6810
+ records: tableUpdateRecordsResolver
6811
+ },
6812
+ formatter: tableRecordFormatter
6813
+ }
6814
+ }
6815
+ }
6816
+ };
6817
+ };
6818
+
6819
+ // src/plugins/registry/index.ts
6820
+ var registryPlugin = ({ sdk, context }) => {
6821
+ const metaKeys = Object.keys(context.meta || {});
6822
+ const categoryDefinitions = {
6823
+ account: {
6824
+ title: "Account"
6825
+ },
6826
+ app: {
6827
+ title: "App",
6828
+ titlePlural: "Apps"
6829
+ },
6830
+ connection: {
6831
+ title: "Connection"
6832
+ },
6833
+ action: {
6834
+ title: "Action"
6835
+ },
6836
+ "client-credentials": {
6837
+ title: "Client Credentials",
6838
+ titlePlural: "Client Credentials"
6839
+ },
6840
+ table: {
6841
+ title: "Table"
6842
+ },
6843
+ http: {
6844
+ title: "HTTP Request"
6845
+ },
6846
+ utility: {
6847
+ title: "Utility",
6848
+ titlePlural: "Utilities"
6849
+ },
6850
+ other: {
6851
+ title: "Other"
6852
+ }
6853
+ };
6854
+ const functions = metaKeys.filter((key) => {
6855
+ const property = sdk[key];
6856
+ if (typeof property === "function") {
6857
+ return true;
6858
+ }
6859
+ const [rootKey] = key.split(".");
6860
+ const rootProperty = sdk[rootKey];
6861
+ if (typeof rootProperty === "object" && rootProperty !== null) {
6862
+ return true;
6863
+ }
6864
+ return false;
6865
+ }).map((key) => {
6866
+ const meta = context.meta[key];
6867
+ return {
6868
+ name: key,
6869
+ description: meta.description,
6870
+ type: meta.type,
6871
+ itemType: meta.itemType,
6872
+ returnType: meta.returnType,
6873
+ inputSchema: meta.inputSchema,
6874
+ inputParameters: meta.inputParameters,
6875
+ outputSchema: meta.outputSchema,
6876
+ categories: meta.categories || [],
6877
+ resolvers: meta.resolvers,
6878
+ formatter: meta.formatter,
6879
+ packages: meta.packages,
6880
+ // Auto-infer confirm: "delete" from type: "delete" (all deletes should confirm)
6881
+ confirm: meta.confirm ?? (meta.type === "delete" ? "delete" : void 0),
6882
+ deprecation: meta.deprecation,
6883
+ deprecatedParameters: meta.deprecatedParameters,
6884
+ aliases: meta.aliases,
6885
+ supportsJsonOutput: meta.supportsJsonOutput ?? true
6886
+ };
6887
+ }).sort((a, b) => a.name.localeCompare(b.name));
6888
+ const knownCategories = Object.keys(categoryDefinitions);
6889
+ const registryCache = /* @__PURE__ */ new Map();
6890
+ function getRegistry(options) {
6891
+ const packageFilter = options?.package;
6892
+ const cacheKey = packageFilter || "__all__";
6893
+ if (registryCache.has(cacheKey)) {
6894
+ return registryCache.get(cacheKey);
6895
+ }
6896
+ const filteredFunctions = packageFilter ? functions.filter(
6897
+ (f) => (
6898
+ // Include if packages is undefined (belongs to all packages) or includes the specified package
6899
+ !f.packages || f.packages.includes(packageFilter)
6900
+ )
6901
+ ) : functions;
6902
+ const filteredCategories = knownCategories.sort((a, b) => {
6903
+ if (a === "other") return 1;
6904
+ if (b === "other") return -1;
6905
+ const titleA = categoryDefinitions[a].title;
6906
+ const titleB = categoryDefinitions[b].title;
6907
+ return titleA.localeCompare(titleB);
6908
+ }).map((categoryKey) => {
6909
+ const categoryFunctions = filteredFunctions.filter(
6910
+ (f) => f.categories.includes(categoryKey) || // If the category is "other" and the function is not in any other category, include it
6911
+ categoryKey === "other" && !f.categories.some((c) => knownCategories.includes(c))
6912
+ ).map((f) => f.name).sort();
6913
+ const definition = categoryDefinitions[categoryKey];
6914
+ const title = definition.title;
6915
+ return {
6916
+ key: categoryKey,
6917
+ title,
6918
+ titlePlural: definition.titlePlural ?? `${title}s`,
6919
+ functions: categoryFunctions
6920
+ };
6921
+ }).filter((category) => category.functions.length > 0);
6922
+ const result = {
6923
+ functions: filteredFunctions,
6924
+ categories: filteredCategories
6925
+ };
6926
+ registryCache.set(cacheKey, result);
6927
+ return result;
6928
+ }
6929
+ return {
6930
+ getRegistry
6931
+ };
6932
+ };
6933
+
6934
+ // src/plugins/deprecated/authentications.ts
6935
+ var listAuthenticationsPlugin = ({ sdk }) => ({
6936
+ listAuthentications: sdk.listConnections,
6937
+ context: {
6938
+ meta: {
6939
+ listAuthentications: {
6940
+ packages: ["cli", "mcp"],
6941
+ categories: ["connection", "deprecated"],
6942
+ type: "list",
6943
+ itemType: "Connection",
6944
+ inputSchema: ListConnectionsQuerySchema,
6945
+ outputSchema: ConnectionItemSchema
6946
+ }
6947
+ }
6948
+ }
6949
+ });
6950
+ var getAuthenticationPlugin = ({ sdk }) => ({
6951
+ getAuthentication: sdk.getConnection,
6952
+ context: {
6953
+ meta: {
6954
+ getAuthentication: {
6955
+ packages: ["cli", "mcp"],
6956
+ categories: ["connection", "deprecated"],
6957
+ type: "item",
6958
+ itemType: "Connection",
6959
+ inputSchema: GetConnectionParamSchema,
6960
+ outputSchema: ConnectionItemSchema
6961
+ }
6962
+ }
6963
+ }
6964
+ });
6965
+ var findFirstAuthenticationPlugin = ({ sdk }) => ({
6966
+ findFirstAuthentication: sdk.findFirstConnection,
6967
+ context: {
6968
+ meta: {
6969
+ findFirstAuthentication: {
6970
+ packages: ["cli", "mcp"],
5134
6971
  categories: ["connection", "deprecated"],
5135
6972
  type: "item",
5136
6973
  itemType: "Connection",
@@ -5395,7 +7232,8 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
5395
7232
  listInputFieldChoicesPage,
5396
7233
  ListInputFieldChoicesSchema,
5397
7234
  createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
5398
- methodName
7235
+ methodName,
7236
+ DEFAULT_PAGE_SIZE
5399
7237
  );
5400
7238
  return {
5401
7239
  listInputFieldChoices: listInputFieldChoicesDefinition,
@@ -5580,7 +7418,7 @@ function getCpuTime() {
5580
7418
  }
5581
7419
 
5582
7420
  // src/plugins/eventEmission/builders.ts
5583
- var SDK_VERSION = "0.34.1";
7421
+ var SDK_VERSION = "0.36.0";
5584
7422
  function createBaseEvent(context = {}) {
5585
7423
  return {
5586
7424
  event_id: generateEventId(),
@@ -6073,7 +7911,7 @@ function createSdk(options = {}, initialSdk = {}, initialContext = { meta: {} })
6073
7911
  };
6074
7912
  }
6075
7913
  function createZapierSdkWithoutRegistry(options = {}) {
6076
- return createSdk(options).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listInputFieldsPlugin).addPlugin(getInputFieldsSchemaPlugin).addPlugin(listInputFieldChoicesPlugin).addPlugin(runActionPlugin).addPlugin(listConnectionsPlugin).addPlugin(getConnectionPlugin).addPlugin(findFirstConnectionPlugin).addPlugin(findUniqueConnectionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(listClientCredentialsPlugin).addPlugin(createClientCredentialsPlugin).addPlugin(deleteClientCredentialsPlugin).addPlugin(fetchPlugin).addPlugin(requestPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
7914
+ return createSdk(options).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listInputFieldsPlugin).addPlugin(getInputFieldsSchemaPlugin).addPlugin(listInputFieldChoicesPlugin).addPlugin(runActionPlugin).addPlugin(listConnectionsPlugin).addPlugin(getConnectionPlugin).addPlugin(findFirstConnectionPlugin).addPlugin(findUniqueConnectionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(listClientCredentialsPlugin).addPlugin(createClientCredentialsPlugin).addPlugin(deleteClientCredentialsPlugin).addPlugin(fetchPlugin).addPlugin(requestPlugin).addPlugin(listTablesPlugin).addPlugin(getTablePlugin).addPlugin(deleteTablePlugin).addPlugin(createTablePlugin).addPlugin(listTableFieldsPlugin).addPlugin(createTableFieldsPlugin).addPlugin(deleteTableFieldsPlugin).addPlugin(getTableRecordPlugin).addPlugin(listTableRecordsPlugin).addPlugin(createTableRecordsPlugin).addPlugin(deleteTableRecordsPlugin).addPlugin(updateTableRecordsPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
6077
7915
  }
6078
7916
  function createZapierSdk(options = {}) {
6079
7917
  return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
@@ -6113,6 +7951,8 @@ exports.ActionTypePropertySchema = ActionTypePropertySchema;
6113
7951
  exports.AppKeyPropertySchema = AppKeyPropertySchema;
6114
7952
  exports.AuthenticationIdPropertySchema = AuthenticationIdPropertySchema;
6115
7953
  exports.BaseSdkOptionsSchema = BaseSdkOptionsSchema;
7954
+ exports.CONTEXT_CACHE_MAX_SIZE = CONTEXT_CACHE_MAX_SIZE;
7955
+ exports.CONTEXT_CACHE_TTL_MS = CONTEXT_CACHE_TTL_MS;
6116
7956
  exports.ClientCredentialsObjectSchema = ClientCredentialsObjectSchema;
6117
7957
  exports.ConnectionIdPropertySchema = ConnectionIdPropertySchema;
6118
7958
  exports.CredentialsFunctionSchema = CredentialsFunctionSchema;
@@ -6120,6 +7960,7 @@ exports.CredentialsObjectSchema = CredentialsObjectSchema;
6120
7960
  exports.CredentialsSchema = CredentialsSchema;
6121
7961
  exports.DEFAULT_ACTION_TIMEOUT_MS = DEFAULT_ACTION_TIMEOUT_MS;
6122
7962
  exports.DEFAULT_CONFIG_PATH = DEFAULT_CONFIG_PATH;
7963
+ exports.DEFAULT_PAGE_SIZE = DEFAULT_PAGE_SIZE;
6123
7964
  exports.DebugPropertySchema = DebugPropertySchema;
6124
7965
  exports.InputsPropertySchema = InputsPropertySchema;
6125
7966
  exports.LimitPropertySchema = LimitPropertySchema;
@@ -6169,9 +8010,15 @@ exports.createBaseEvent = createBaseEvent;
6169
8010
  exports.createClientCredentialsPlugin = createClientCredentialsPlugin;
6170
8011
  exports.createFunction = createFunction;
6171
8012
  exports.createSdk = createSdk;
8013
+ exports.createTableFieldsPlugin = createTableFieldsPlugin;
8014
+ exports.createTablePlugin = createTablePlugin;
8015
+ exports.createTableRecordsPlugin = createTableRecordsPlugin;
6172
8016
  exports.createZapierSdk = createZapierSdk;
6173
8017
  exports.createZapierSdkWithoutRegistry = createZapierSdkWithoutRegistry;
6174
8018
  exports.deleteClientCredentialsPlugin = deleteClientCredentialsPlugin;
8019
+ exports.deleteTableFieldsPlugin = deleteTableFieldsPlugin;
8020
+ exports.deleteTablePlugin = deleteTablePlugin;
8021
+ exports.deleteTableRecordsPlugin = deleteTableRecordsPlugin;
6175
8022
  exports.fetchPlugin = fetchPlugin;
6176
8023
  exports.findFirstConnectionPlugin = findFirstConnectionPlugin;
6177
8024
  exports.findManifestEntry = findManifestEntry;
@@ -6192,6 +8039,8 @@ exports.getPlatformVersions = getPlatformVersions;
6192
8039
  exports.getPreferredManifestEntryKey = getPreferredManifestEntryKey;
6193
8040
  exports.getProfilePlugin = getProfilePlugin;
6194
8041
  exports.getReleaseId = getReleaseId;
8042
+ exports.getTablePlugin = getTablePlugin;
8043
+ exports.getTableRecordPlugin = getTableRecordPlugin;
6195
8044
  exports.getTokenFromCliLogin = getTokenFromCliLogin;
6196
8045
  exports.injectCliLogin = injectCliLogin;
6197
8046
  exports.inputFieldKeyResolver = inputFieldKeyResolver;
@@ -6211,6 +8060,9 @@ exports.listAppsPlugin = listAppsPlugin;
6211
8060
  exports.listClientCredentialsPlugin = listClientCredentialsPlugin;
6212
8061
  exports.listConnectionsPlugin = listConnectionsPlugin;
6213
8062
  exports.listInputFieldsPlugin = listInputFieldsPlugin;
8063
+ exports.listTableFieldsPlugin = listTableFieldsPlugin;
8064
+ exports.listTableRecordsPlugin = listTableRecordsPlugin;
8065
+ exports.listTablesPlugin = listTablesPlugin;
6214
8066
  exports.logDeprecation = logDeprecation;
6215
8067
  exports.manifestPlugin = manifestPlugin;
6216
8068
  exports.readManifestFromFile = readManifestFromFile;
@@ -6222,5 +8074,16 @@ exports.resolveCredentials = resolveCredentials;
6222
8074
  exports.resolveCredentialsFromEnv = resolveCredentialsFromEnv;
6223
8075
  exports.runActionPlugin = runActionPlugin;
6224
8076
  exports.runWithTelemetryContext = runWithTelemetryContext;
8077
+ exports.tableFieldIdsResolver = tableFieldIdsResolver;
8078
+ exports.tableFieldsResolver = tableFieldsResolver;
8079
+ exports.tableFiltersResolver = tableFiltersResolver;
8080
+ exports.tableIdResolver = tableIdResolver;
8081
+ exports.tableNameResolver = tableNameResolver;
8082
+ exports.tableRecordIdResolver = tableRecordIdResolver;
8083
+ exports.tableRecordIdsResolver = tableRecordIdsResolver;
8084
+ exports.tableRecordsResolver = tableRecordsResolver;
8085
+ exports.tableSortResolver = tableSortResolver;
8086
+ exports.tableUpdateRecordsResolver = tableUpdateRecordsResolver;
6225
8087
  exports.toSnakeCase = toSnakeCase;
6226
8088
  exports.toTitleCase = toTitleCase;
8089
+ exports.updateTableRecordsPlugin = updateTableRecordsPlugin;