@zapier/zapier-sdk 0.40.3 → 0.41.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 (43) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/api/polling.js +3 -4
  3. package/dist/api/schemas.d.ts +1 -0
  4. package/dist/api/schemas.d.ts.map +1 -1
  5. package/dist/api/schemas.js +1 -0
  6. package/dist/auth.d.ts.map +1 -1
  7. package/dist/auth.js +14 -7
  8. package/dist/constants.d.ts.map +1 -1
  9. package/dist/constants.js +2 -2
  10. package/dist/credentials.d.ts.map +1 -1
  11. package/dist/credentials.js +21 -19
  12. package/dist/index.cjs +143 -105
  13. package/dist/index.d.mts +2 -1
  14. package/dist/index.mjs +143 -85
  15. package/dist/plugins/capabilities/index.d.ts.map +1 -1
  16. package/dist/plugins/capabilities/index.js +1 -3
  17. package/dist/plugins/eventEmission/builders.d.ts.map +1 -1
  18. package/dist/plugins/eventEmission/builders.js +4 -4
  19. package/dist/plugins/eventEmission/index.d.ts.map +1 -1
  20. package/dist/plugins/eventEmission/index.js +11 -11
  21. package/dist/plugins/eventEmission/utils.d.ts.map +1 -1
  22. package/dist/plugins/eventEmission/utils.js +43 -36
  23. package/dist/plugins/getConnection/index.d.ts.map +1 -1
  24. package/dist/plugins/getConnection/index.js +6 -1
  25. package/dist/plugins/getProfile/index.js +1 -1
  26. package/dist/plugins/listConnections/index.d.ts.map +1 -1
  27. package/dist/plugins/listConnections/index.js +5 -2
  28. package/dist/plugins/tables/createTable/schemas.d.ts +2 -0
  29. package/dist/plugins/tables/createTable/schemas.d.ts.map +1 -1
  30. package/dist/plugins/tables/getTable/schemas.d.ts +2 -0
  31. package/dist/plugins/tables/getTable/schemas.d.ts.map +1 -1
  32. package/dist/plugins/tables/listTables/schemas.d.ts +5 -1
  33. package/dist/plugins/tables/listTables/schemas.d.ts.map +1 -1
  34. package/dist/plugins/tables/listTables/schemas.js +3 -1
  35. package/dist/plugins/tables/utils.d.ts.map +1 -1
  36. package/dist/plugins/tables/utils.js +3 -2
  37. package/dist/utils/batch-utils.d.ts.map +1 -1
  38. package/dist/utils/batch-utils.js +5 -6
  39. package/dist/utils/domain-utils.d.ts +7 -1
  40. package/dist/utils/domain-utils.d.ts.map +1 -1
  41. package/dist/utils/domain-utils.js +35 -0
  42. package/dist/utils/url-utils.js +2 -2
  43. package/package.json +6 -2
package/dist/index.cjs CHANGED
@@ -4,28 +4,6 @@ var zod = require('zod');
4
4
  var apps = require('@zapier/zapier-sdk-core/v0/schemas/apps');
5
5
  var connections = require('@zapier/zapier-sdk-core/v0/schemas/connections');
6
6
  var clientCredentials = require('@zapier/zapier-sdk-core/v0/schemas/client-credentials');
7
- var promises = require('timers/promises');
8
- var os = require('os');
9
-
10
- function _interopNamespace(e) {
11
- if (e && e.__esModule) return e;
12
- var n = Object.create(null);
13
- if (e) {
14
- Object.keys(e).forEach(function (k) {
15
- if (k !== 'default') {
16
- var d = Object.getOwnPropertyDescriptor(e, k);
17
- Object.defineProperty(n, k, d.get ? d : {
18
- enumerable: true,
19
- get: function () { return e[k]; }
20
- });
21
- }
22
- });
23
- }
24
- n.default = e;
25
- return Object.freeze(n);
26
- }
27
-
28
- var os__namespace = /*#__PURE__*/_interopNamespace(os);
29
7
 
30
8
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
31
9
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -62,12 +40,12 @@ function isPositional(schema) {
62
40
  }
63
41
 
64
42
  // src/constants.ts
65
- var ZAPIER_BASE_URL = process.env.ZAPIER_BASE_URL || "https://zapier.com";
43
+ var ZAPIER_BASE_URL = globalThis.process?.env?.ZAPIER_BASE_URL || "https://zapier.com";
66
44
  var MAX_PAGE_LIMIT = 1e4;
67
45
  var DEFAULT_PAGE_SIZE = 100;
68
46
  var DEFAULT_ACTION_TIMEOUT_MS = 18e4;
69
47
  function parseIntEnvVar(name) {
70
- const value = process.env[name];
48
+ const value = globalThis.process?.env?.[name];
71
49
  if (value === void 0) return void 0;
72
50
  const parsed = parseInt(value, 10);
73
51
  if (isNaN(parsed)) {
@@ -639,6 +617,34 @@ function normalizeActionItem(action) {
639
617
  type: "action"
640
618
  };
641
619
  }
620
+ function transformConnectionItem(item) {
621
+ const raw = item;
622
+ const publicId = raw.public_id;
623
+ const accountPublicId = raw.account_public_id;
624
+ const customuserPublicId = raw.customuser_public_id;
625
+ return {
626
+ id: String(publicId ?? item.id),
627
+ date: item.date,
628
+ account_id: String(accountPublicId ?? item.account_id),
629
+ is_invite_only: item.is_invite_only,
630
+ is_private: item.is_private,
631
+ shared_with_all: item.shared_with_all,
632
+ title: item.title,
633
+ lastchanged: item.lastchanged,
634
+ is_stale: item.is_stale,
635
+ is_shared: item.is_shared,
636
+ identifier: item.identifier,
637
+ groups: item.groups,
638
+ members: item.members,
639
+ permissions: item.permissions,
640
+ implementation_id: item.implementation_id,
641
+ profile_id: customuserPublicId ? String(customuserPublicId) : item.profile_id,
642
+ is_expired: item.is_expired,
643
+ expired_at: item.expired_at,
644
+ app_key: item.app_key,
645
+ app_version: item.app_version
646
+ };
647
+ }
642
648
  function isSlug(slug) {
643
649
  return !!slug.match(/^[a-z0-9]+(?:-[a-z0-9]+)*$/);
644
650
  }
@@ -1621,6 +1627,7 @@ zod.z.object({
1621
1627
  });
1622
1628
  zod.z.object({
1623
1629
  id: zod.z.number(),
1630
+ public_id: zod.z.string().optional(),
1624
1631
  code: zod.z.string(),
1625
1632
  user_id: zod.z.number(),
1626
1633
  auto_provisioned: zod.z.boolean(),
@@ -2126,8 +2133,12 @@ function transformTableItem(apiItem) {
2126
2133
  created_at: apiItem.created_at,
2127
2134
  edited_at: apiItem.edited_at,
2128
2135
  kind: apiItem.kind,
2129
- owner_account_id: String(apiItem.owner_account_id),
2130
- profile_id: String(apiItem.owner_zapier_customuser_id),
2136
+ account_id: String(
2137
+ apiItem.owner_account_public_id ?? apiItem.owner_account_id
2138
+ ),
2139
+ profile_id: String(
2140
+ apiItem.owner_zapier_customuser_public_id ?? apiItem.owner_zapier_customuser_id
2141
+ ),
2131
2142
  parent_table_id: apiItem.parent_table_id ?? void 0
2132
2143
  };
2133
2144
  }
@@ -3343,7 +3354,10 @@ var listConnectionsPlugin = ({ context }) => {
3343
3354
  authRequired: true
3344
3355
  }
3345
3356
  );
3346
- return response;
3357
+ return {
3358
+ ...response,
3359
+ data: response.data.map(transformConnectionItem)
3360
+ };
3347
3361
  }
3348
3362
  const methodName = stripPageSuffix(listConnectionsPage.name);
3349
3363
  const listConnectionsDefinition = createPaginatedFunction(
@@ -3740,9 +3754,13 @@ var getConnectionPlugin = ({ context }) => {
3740
3754
  if (!resolvedConnectionId) {
3741
3755
  throw new Error("connection is required");
3742
3756
  }
3743
- return await api.get(
3757
+ const response = await api.get(
3744
3758
  `/api/v0/connections/${encodeURIComponent(String(resolvedConnectionId))}`
3745
3759
  );
3760
+ return {
3761
+ ...response,
3762
+ data: transformConnectionItem(response.data)
3763
+ };
3746
3764
  }
3747
3765
  const getConnectionDefinition = createFunction(
3748
3766
  getConnection,
@@ -4702,7 +4720,7 @@ var getProfilePlugin = ({ context }) => {
4702
4720
  );
4703
4721
  return {
4704
4722
  data: {
4705
- id: String(profile.id),
4723
+ id: String(profile.public_id ?? profile.id),
4706
4724
  first_name: profile.first_name,
4707
4725
  last_name: profile.last_name,
4708
4726
  full_name: `${profile.first_name} ${profile.last_name}`,
@@ -5008,7 +5026,7 @@ async function pollUntilComplete(options) {
5008
5026
  let attempts = 0;
5009
5027
  let errorCount = 0;
5010
5028
  if (initialDelay > 0) {
5011
- await promises.setTimeout(initialDelay);
5029
+ await sleep(initialDelay);
5012
5030
  }
5013
5031
  while (true) {
5014
5032
  const elapsedTime = Date.now() - startTime;
@@ -5023,7 +5041,7 @@ async function pollUntilComplete(options) {
5023
5041
  if (attempts > 0) {
5024
5042
  const interval = getPollingInterval(elapsedTime);
5025
5043
  const waitTime = calculateErrorBackoffMs(interval, errorCount);
5026
- await promises.setTimeout(waitTime);
5044
+ await sleep(waitTime);
5027
5045
  }
5028
5046
  attempts++;
5029
5047
  try {
@@ -5135,8 +5153,8 @@ function getTrackingBaseUrl({
5135
5153
  if (trackingBaseUrl) {
5136
5154
  return trackingBaseUrl;
5137
5155
  }
5138
- if (process.env.ZAPIER_TRACKING_BASE_URL) {
5139
- return process.env.ZAPIER_TRACKING_BASE_URL;
5156
+ if (globalThis.process?.env?.ZAPIER_TRACKING_BASE_URL) {
5157
+ return globalThis.process?.env?.ZAPIER_TRACKING_BASE_URL;
5140
5158
  }
5141
5159
  if (baseUrl) {
5142
5160
  const zapierBaseUrl = getZapierBaseUrl(baseUrl);
@@ -5157,9 +5175,9 @@ function deriveAuthBaseUrl(sdkBaseUrl) {
5157
5175
  }
5158
5176
  function normalizeCredentialsObject(obj, sdkBaseUrl) {
5159
5177
  const merged = {
5160
- clientSecret: process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET,
5161
- baseUrl: process.env.ZAPIER_CREDENTIALS_BASE_URL,
5162
- scope: process.env.ZAPIER_CREDENTIALS_SCOPE,
5178
+ clientSecret: globalThis.process?.env?.ZAPIER_CREDENTIALS_CLIENT_SECRET,
5179
+ baseUrl: globalThis.process?.env?.ZAPIER_CREDENTIALS_BASE_URL,
5180
+ scope: globalThis.process?.env?.ZAPIER_CREDENTIALS_SCOPE,
5163
5181
  ...obj
5164
5182
  };
5165
5183
  const resolvedBaseUrl = merged.baseUrl || deriveAuthBaseUrl(sdkBaseUrl);
@@ -5180,47 +5198,47 @@ function normalizeCredentialsObject(obj, sdkBaseUrl) {
5180
5198
  };
5181
5199
  }
5182
5200
  function resolveCredentialsFromEnv(sdkBaseUrl) {
5183
- if (process.env.ZAPIER_CREDENTIALS) {
5184
- return process.env.ZAPIER_CREDENTIALS;
5201
+ if (globalThis.process?.env?.ZAPIER_CREDENTIALS) {
5202
+ return globalThis.process?.env?.ZAPIER_CREDENTIALS;
5185
5203
  }
5186
- if (process.env.ZAPIER_CREDENTIALS_CLIENT_ID) {
5187
- const resolvedBaseUrl = process.env.ZAPIER_CREDENTIALS_BASE_URL || deriveAuthBaseUrl(sdkBaseUrl);
5188
- if (process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET) {
5204
+ if (globalThis.process?.env?.ZAPIER_CREDENTIALS_CLIENT_ID) {
5205
+ const resolvedBaseUrl = globalThis.process?.env?.ZAPIER_CREDENTIALS_BASE_URL || deriveAuthBaseUrl(sdkBaseUrl);
5206
+ if (globalThis.process?.env?.ZAPIER_CREDENTIALS_CLIENT_SECRET) {
5189
5207
  return {
5190
5208
  type: "client_credentials",
5191
- clientId: process.env.ZAPIER_CREDENTIALS_CLIENT_ID,
5192
- clientSecret: process.env.ZAPIER_CREDENTIALS_CLIENT_SECRET,
5209
+ clientId: globalThis.process?.env?.ZAPIER_CREDENTIALS_CLIENT_ID,
5210
+ clientSecret: globalThis.process?.env?.ZAPIER_CREDENTIALS_CLIENT_SECRET,
5193
5211
  baseUrl: resolvedBaseUrl,
5194
- scope: process.env.ZAPIER_CREDENTIALS_SCOPE
5212
+ scope: globalThis.process?.env?.ZAPIER_CREDENTIALS_SCOPE
5195
5213
  };
5196
5214
  } else {
5197
5215
  return {
5198
5216
  type: "pkce",
5199
- clientId: process.env.ZAPIER_CREDENTIALS_CLIENT_ID,
5217
+ clientId: globalThis.process?.env?.ZAPIER_CREDENTIALS_CLIENT_ID,
5200
5218
  baseUrl: resolvedBaseUrl,
5201
- scope: process.env.ZAPIER_CREDENTIALS_SCOPE
5219
+ scope: globalThis.process?.env?.ZAPIER_CREDENTIALS_SCOPE
5202
5220
  };
5203
5221
  }
5204
5222
  }
5205
- if (process.env.ZAPIER_TOKEN) {
5223
+ if (globalThis.process?.env?.ZAPIER_TOKEN) {
5206
5224
  logDeprecation(
5207
5225
  "ZAPIER_TOKEN is deprecated. Use ZAPIER_CREDENTIALS instead."
5208
5226
  );
5209
- return process.env.ZAPIER_TOKEN;
5227
+ return globalThis.process?.env?.ZAPIER_TOKEN;
5210
5228
  }
5211
- if (process.env.ZAPIER_AUTH_CLIENT_ID) {
5229
+ if (globalThis.process?.env?.ZAPIER_AUTH_CLIENT_ID) {
5212
5230
  logDeprecation(
5213
5231
  "ZAPIER_AUTH_CLIENT_ID is deprecated. Use ZAPIER_CREDENTIALS_CLIENT_ID instead."
5214
5232
  );
5215
- if (process.env.ZAPIER_AUTH_BASE_URL) {
5233
+ if (globalThis.process?.env?.ZAPIER_AUTH_BASE_URL) {
5216
5234
  logDeprecation(
5217
5235
  "ZAPIER_AUTH_BASE_URL is deprecated. Use ZAPIER_CREDENTIALS_BASE_URL instead."
5218
5236
  );
5219
5237
  }
5220
- const resolvedBaseUrl = process.env.ZAPIER_AUTH_BASE_URL || deriveAuthBaseUrl(sdkBaseUrl);
5238
+ const resolvedBaseUrl = globalThis.process?.env?.ZAPIER_AUTH_BASE_URL || deriveAuthBaseUrl(sdkBaseUrl);
5221
5239
  return {
5222
5240
  type: "pkce",
5223
- clientId: process.env.ZAPIER_AUTH_CLIENT_ID,
5241
+ clientId: globalThis.process?.env?.ZAPIER_AUTH_CLIENT_ID,
5224
5242
  baseUrl: resolvedBaseUrl
5225
5243
  };
5226
5244
  }
@@ -5392,17 +5410,23 @@ async function getCliLogin() {
5392
5410
  return cachedCliLogin || void 0;
5393
5411
  }
5394
5412
  try {
5395
- cachedCliLogin = await import('@zapier/zapier-sdk-cli/login');
5396
- return cachedCliLogin;
5413
+ const mod = await import('@zapier/zapier-sdk-cli/login');
5414
+ if (typeof mod.getToken === "function") {
5415
+ cachedCliLogin = mod;
5416
+ return cachedCliLogin;
5417
+ }
5397
5418
  } catch {
5398
5419
  }
5399
5420
  try {
5400
- cachedCliLogin = await import('@zapier/zapier-sdk-cli-login');
5401
- return cachedCliLogin;
5421
+ const mod = await import('@zapier/zapier-sdk-cli-login');
5422
+ if (typeof mod.getToken === "function") {
5423
+ cachedCliLogin = mod;
5424
+ return cachedCliLogin;
5425
+ }
5402
5426
  } catch {
5403
- cachedCliLogin = false;
5404
- return void 0;
5405
5427
  }
5428
+ cachedCliLogin = false;
5429
+ return void 0;
5406
5430
  }
5407
5431
  function injectCliLogin(module) {
5408
5432
  cachedCliLogin = module;
@@ -5930,6 +5954,8 @@ var apiPlugin = (params) => {
5930
5954
  }
5931
5955
  };
5932
5956
  };
5957
+
5958
+ // src/utils/batch-utils.ts
5933
5959
  var DEFAULT_CONCURRENCY = 10;
5934
5960
  var BATCH_START_DELAY_MS = 25;
5935
5961
  var DEFAULT_BATCH_TIMEOUT_MS = 18e4;
@@ -5965,7 +5991,7 @@ async function batch(tasks, options = {}) {
5965
5991
  try {
5966
5992
  let result;
5967
5993
  if (taskTimeoutMs !== void 0) {
5968
- const timeoutPromise = promises.setTimeout(taskTimeoutMs).then(() => {
5994
+ const timeoutPromise = sleep(taskTimeoutMs).then(() => {
5969
5995
  throw new ZapierTimeoutError(
5970
5996
  `Task timed out after ${taskTimeoutMs}ms`
5971
5997
  );
@@ -5980,7 +6006,7 @@ async function batch(tasks, options = {}) {
5980
6006
  const isTimeout = error instanceof ZapierTimeoutError;
5981
6007
  if (retry && !isTimeout && newErrorCount < MAX_CONSECUTIVE_ERRORS) {
5982
6008
  const waitTime = calculateErrorBackoffMs(1e3, newErrorCount);
5983
- await promises.setTimeout(waitTime);
6009
+ await sleep(waitTime);
5984
6010
  taskQueue.push({
5985
6011
  index,
5986
6012
  task,
@@ -6003,7 +6029,7 @@ async function batch(tasks, options = {}) {
6003
6029
  if (!taskState) break;
6004
6030
  await executeTask(taskState);
6005
6031
  if (taskQueue.length > 0 && batchDelay > 0) {
6006
- await promises.setTimeout(batchDelay);
6032
+ await sleep(batchDelay);
6007
6033
  }
6008
6034
  }
6009
6035
  }
@@ -6012,7 +6038,7 @@ async function batch(tasks, options = {}) {
6012
6038
  for (let i = 0; i < workerCount; i++) {
6013
6039
  workers.push(worker());
6014
6040
  if (i < workerCount - 1 && batchDelay > 0) {
6015
- await promises.setTimeout(batchDelay / 10);
6041
+ await sleep(batchDelay / 10);
6016
6042
  }
6017
6043
  }
6018
6044
  await Promise.all(workers);
@@ -6066,8 +6092,7 @@ var GATED_FLAGS = [
6066
6092
  "canDeleteTables"
6067
6093
  ];
6068
6094
  function isEnabledByEnv(key) {
6069
- if (typeof process === "undefined") return void 0;
6070
- const value = process.env[toEnvVar(key)];
6095
+ const value = globalThis.process?.env?.[toEnvVar(key)];
6071
6096
  if (value === void 0) return void 0;
6072
6097
  if (value === "true" || value === "1") return true;
6073
6098
  if (value === "false" || value === "0") return false;
@@ -6112,8 +6137,10 @@ var TableApiItemSchema = zod.z.object({
6112
6137
  edited_at: zod.z.string(),
6113
6138
  kind: zod.z.enum(["table", "virtual_table"]),
6114
6139
  owner_account_id: zod.z.number(),
6140
+ owner_account_public_id: zod.z.string().optional(),
6115
6141
  owner_user_id: zod.z.number().nullable().optional(),
6116
6142
  owner_zapier_customuser_id: zod.z.number(),
6143
+ owner_zapier_customuser_public_id: zod.z.string().optional(),
6117
6144
  parent_table_id: zod.z.string().nullable().optional()
6118
6145
  });
6119
6146
  var ListTablesApiResponseSchema = zod.z.object({
@@ -6129,7 +6156,7 @@ var TableItemSchema = zod.z.object({
6129
6156
  created_at: zod.z.string(),
6130
6157
  edited_at: zod.z.string(),
6131
6158
  kind: zod.z.enum(["table", "virtual_table"]),
6132
- owner_account_id: zod.z.string(),
6159
+ account_id: zod.z.string(),
6133
6160
  profile_id: zod.z.string(),
6134
6161
  parent_table_id: zod.z.string().optional()
6135
6162
  });
@@ -7865,6 +7892,14 @@ function createTransport(config) {
7865
7892
  return createNoopTransport();
7866
7893
  }
7867
7894
  }
7895
+
7896
+ // src/plugins/eventEmission/utils.ts
7897
+ var osModule = null;
7898
+ try {
7899
+ osModule = __require("os");
7900
+ } catch {
7901
+ osModule = null;
7902
+ }
7868
7903
  function generateEventId() {
7869
7904
  return crypto.randomUUID();
7870
7905
  }
@@ -7872,65 +7907,65 @@ function getCurrentTimestamp() {
7872
7907
  return Date.now();
7873
7908
  }
7874
7909
  function getReleaseId() {
7875
- return process?.env?.SDK_RELEASE_ID || "development";
7910
+ return globalThis.process?.env?.SDK_RELEASE_ID || "development";
7876
7911
  }
7877
7912
  function getOsInfo() {
7913
+ if (!osModule) {
7914
+ return { platform: null, release: null, architecture: null };
7915
+ }
7878
7916
  try {
7879
7917
  return {
7880
- platform: os__namespace.platform() || null,
7881
- release: os__namespace.release() || null,
7882
- architecture: os__namespace.arch() || null
7918
+ platform: osModule.platform() || null,
7919
+ release: osModule.release() || null,
7920
+ architecture: osModule.arch() || null
7883
7921
  };
7884
7922
  } catch {
7885
- return {
7886
- platform: null,
7887
- release: null,
7888
- architecture: null
7889
- };
7923
+ return { platform: null, release: null, architecture: null };
7890
7924
  }
7891
7925
  }
7892
7926
  function getPlatformVersions() {
7893
7927
  const versions = {};
7894
- if (typeof process?.versions === "object") {
7895
- for (const [key, value] of Object.entries(process.versions)) {
7928
+ if (typeof globalThis.process?.versions === "object") {
7929
+ for (const [key, value] of Object.entries(globalThis.process.versions)) {
7896
7930
  versions[key] = value || null;
7897
7931
  }
7898
7932
  }
7899
7933
  return versions;
7900
7934
  }
7901
7935
  function isCi() {
7902
- return !!(process?.env?.CI || process?.env?.CONTINUOUS_INTEGRATION || process?.env?.GITHUB_ACTIONS || process?.env?.JENKINS_URL || process?.env?.GITLAB_CI || process?.env?.CIRCLECI || process?.env?.TRAVIS || process?.env?.BUILDKITE || process?.env?.DRONE || process?.env?.BITBUCKET_PIPELINES_UUID);
7936
+ return !!(globalThis.process?.env?.CI || globalThis.process?.env?.CONTINUOUS_INTEGRATION || globalThis.process?.env?.GITHUB_ACTIONS || globalThis.process?.env?.JENKINS_URL || globalThis.process?.env?.GITLAB_CI || globalThis.process?.env?.CIRCLECI || globalThis.process?.env?.TRAVIS || globalThis.process?.env?.BUILDKITE || globalThis.process?.env?.DRONE || globalThis.process?.env?.BITBUCKET_PIPELINES_UUID);
7903
7937
  }
7904
7938
  function getCiPlatform() {
7905
- if (process?.env?.GITHUB_ACTIONS) return "github-actions";
7906
- if (process?.env?.JENKINS_URL) return "jenkins";
7907
- if (process?.env?.GITLAB_CI) return "gitlab-ci";
7908
- if (process?.env?.CIRCLECI) return "circleci";
7909
- if (process?.env?.TRAVIS) return "travis";
7910
- if (process?.env?.BUILDKITE) return "buildkite";
7911
- if (process?.env?.DRONE) return "drone";
7912
- if (process?.env?.BITBUCKET_PIPELINES_UUID) return "bitbucket-pipelines";
7913
- if (process?.env?.CI || process?.env?.CONTINUOUS_INTEGRATION)
7939
+ if (globalThis.process?.env?.GITHUB_ACTIONS) return "github-actions";
7940
+ if (globalThis.process?.env?.JENKINS_URL) return "jenkins";
7941
+ if (globalThis.process?.env?.GITLAB_CI) return "gitlab-ci";
7942
+ if (globalThis.process?.env?.CIRCLECI) return "circleci";
7943
+ if (globalThis.process?.env?.TRAVIS) return "travis";
7944
+ if (globalThis.process?.env?.BUILDKITE) return "buildkite";
7945
+ if (globalThis.process?.env?.DRONE) return "drone";
7946
+ if (globalThis.process?.env?.BITBUCKET_PIPELINES_UUID)
7947
+ return "bitbucket-pipelines";
7948
+ if (globalThis.process?.env?.CI || globalThis.process?.env?.CONTINUOUS_INTEGRATION)
7914
7949
  return "unknown-ci";
7915
7950
  return null;
7916
7951
  }
7917
7952
  function getMemoryUsage() {
7918
- if (process?.memoryUsage) {
7919
- const usage = process.memoryUsage();
7953
+ if (globalThis.process?.memoryUsage) {
7954
+ const usage = globalThis.process.memoryUsage();
7920
7955
  return usage.rss || null;
7921
7956
  }
7922
7957
  return null;
7923
7958
  }
7924
7959
  function getCpuTime() {
7925
- if (process?.cpuUsage) {
7926
- const usage = process.cpuUsage();
7960
+ if (globalThis.process?.cpuUsage) {
7961
+ const usage = globalThis.process.cpuUsage();
7927
7962
  return Math.round((usage.user + usage.system) / 1e3);
7928
7963
  }
7929
7964
  return null;
7930
7965
  }
7931
7966
 
7932
7967
  // src/plugins/eventEmission/builders.ts
7933
- var SDK_VERSION = "0.40.3";
7968
+ var SDK_VERSION = globalThis.process?.env?.SDK_VERSION || "unknown";
7934
7969
  function createBaseEvent(context = {}) {
7935
7970
  return {
7936
7971
  event_id: generateEventId(),
@@ -7971,12 +8006,12 @@ function buildApplicationLifecycleEvent(data, context = {}) {
7971
8006
  os_release: osInfo.release,
7972
8007
  os_architecture: osInfo.architecture,
7973
8008
  platform_versions: platformVersions,
7974
- environment: context.environment ?? (process.env.NODE_ENV || null),
8009
+ environment: context.environment ?? (globalThis.process?.env?.NODE_ENV || null),
7975
8010
  is_ci_environment: isCi(),
7976
8011
  ci_platform: getCiPlatform(),
7977
8012
  session_id: null,
7978
8013
  metadata: null,
7979
- process_argv: process.argv || null,
8014
+ process_argv: globalThis.process?.argv || null,
7980
8015
  ...data,
7981
8016
  sdk_version: SDK_VERSION
7982
8017
  };
@@ -7990,7 +8025,7 @@ function buildErrorEventWithContext(data, context = {}) {
7990
8025
  selected_api: context.selected_api,
7991
8026
  app_id: context.app_id,
7992
8027
  app_version_id: context.app_version_id,
7993
- environment: context.environment ?? (process.env.NODE_ENV || null),
8028
+ environment: context.environment ?? (globalThis.process?.env?.NODE_ENV || null),
7994
8029
  execution_time_before_error_ms: executionTime,
7995
8030
  ...data,
7996
8031
  sdk_version: SDK_VERSION
@@ -8043,7 +8078,10 @@ function removeExistingListeners() {
8043
8078
  for (const event of events) {
8044
8079
  const listener = registeredListeners[event];
8045
8080
  if (listener) {
8046
- process.removeListener(event, listener);
8081
+ globalThis.process?.removeListener(
8082
+ event,
8083
+ listener
8084
+ );
8047
8085
  }
8048
8086
  }
8049
8087
  registeredListeners = {};
@@ -8089,14 +8127,14 @@ async function silentEmit(transport, subject, event, userContextPromise) {
8089
8127
  }
8090
8128
  }
8091
8129
  function getTransportConfig(options) {
8092
- const envTransport = process?.env?.ZAPIER_SDK_TELEMETRY_TRANSPORT;
8130
+ const envTransport = globalThis.process?.env?.ZAPIER_SDK_TELEMETRY_TRANSPORT;
8093
8131
  if (envTransport === "noop" || envTransport === "disabled") {
8094
8132
  return { type: "noop" };
8095
8133
  }
8096
8134
  if (envTransport === "console") {
8097
8135
  return { type: "console" };
8098
8136
  }
8099
- const endpoint = process?.env?.ZAPIER_SDK_TELEMETRY_ENDPOINT || `${getTrackingBaseUrl({
8137
+ const endpoint = globalThis.process?.env?.ZAPIER_SDK_TELEMETRY_ENDPOINT || `${getTrackingBaseUrl({
8100
8138
  trackingBaseUrl: options?.trackingBaseUrl,
8101
8139
  baseUrl: options?.baseUrl
8102
8140
  })}/api/v4/tracking/event/`;
@@ -8115,7 +8153,7 @@ var eventEmissionPlugin = ({ context }) => {
8115
8153
  callContext: context.options.eventEmission?.callContext,
8116
8154
  transport: (
8117
8155
  // If env var is set, use it (defaultTransport will be from env)
8118
- process?.env?.ZAPIER_SDK_TELEMETRY_TRANSPORT ? defaultTransport : (
8156
+ globalThis.process?.env?.ZAPIER_SDK_TELEMETRY_TRANSPORT ? defaultTransport : (
8119
8157
  // Otherwise, use option transport or default
8120
8158
  context.options.eventEmission?.transport ?? defaultTransport
8121
8159
  )
@@ -8214,7 +8252,7 @@ var eventEmissionPlugin = ({ context }) => {
8214
8252
  getUserContext
8215
8253
  )
8216
8254
  );
8217
- if (typeof process?.on === "function") {
8255
+ if (typeof globalThis.process?.on === "function") {
8218
8256
  removeExistingListeners();
8219
8257
  const exitHandler = (code) => {
8220
8258
  if (closed) return;
@@ -8237,7 +8275,7 @@ var eventEmissionPlugin = ({ context }) => {
8237
8275
  );
8238
8276
  };
8239
8277
  registeredListeners.exit = exitHandler;
8240
- process.on("exit", exitHandler);
8278
+ globalThis.process.on("exit", exitHandler);
8241
8279
  const uncaughtExceptionHandler = async (error) => {
8242
8280
  let errorEvent = buildErrorEventWithContext({
8243
8281
  error_message: error.message || "Unknown error",
@@ -8260,7 +8298,7 @@ var eventEmissionPlugin = ({ context }) => {
8260
8298
  );
8261
8299
  };
8262
8300
  registeredListeners.uncaughtException = uncaughtExceptionHandler;
8263
- process.on("uncaughtException", uncaughtExceptionHandler);
8301
+ globalThis.process.on("uncaughtException", uncaughtExceptionHandler);
8264
8302
  const unhandledRejectionHandler = async (reason, promise) => {
8265
8303
  const errorMessage = reason instanceof Error ? reason.message : typeof reason === "string" ? reason : "Unhandled promise rejection";
8266
8304
  const errorStack = reason instanceof Error ? reason.stack : null;
@@ -8288,7 +8326,7 @@ var eventEmissionPlugin = ({ context }) => {
8288
8326
  );
8289
8327
  };
8290
8328
  registeredListeners.unhandledRejection = unhandledRejectionHandler;
8291
- process.on("unhandledRejection", unhandledRejectionHandler);
8329
+ globalThis.process.on("unhandledRejection", unhandledRejectionHandler);
8292
8330
  const handleSignal = async (signal) => {
8293
8331
  shutdownStartTime = Date.now();
8294
8332
  const uptime = Date.now() - startupTime;
@@ -8309,14 +8347,14 @@ var eventEmissionPlugin = ({ context }) => {
8309
8347
  signalEvent
8310
8348
  );
8311
8349
  const exitCode = signal === "SIGINT" ? 130 : 143;
8312
- process.exit(exitCode);
8350
+ globalThis.process.exit(exitCode);
8313
8351
  };
8314
8352
  const sigintHandler = () => handleSignal("SIGINT");
8315
8353
  const sigtermHandler = () => handleSignal("SIGTERM");
8316
8354
  registeredListeners.SIGINT = sigintHandler;
8317
8355
  registeredListeners.SIGTERM = sigtermHandler;
8318
- process.on("SIGINT", sigintHandler);
8319
- process.on("SIGTERM", sigtermHandler);
8356
+ globalThis.process.on("SIGINT", sigintHandler);
8357
+ globalThis.process.on("SIGTERM", sigtermHandler);
8320
8358
  }
8321
8359
  }
8322
8360
  const close = async (exitCode) => {
package/dist/index.d.mts CHANGED
@@ -696,6 +696,7 @@ declare const ActionFieldSchema: z.ZodObject<{
696
696
  }, z.core.$strip>;
697
697
  declare const UserProfileSchema: z.ZodObject<{
698
698
  id: z.ZodNumber;
699
+ public_id: z.ZodOptional<z.ZodString>;
699
700
  code: z.ZodString;
700
701
  user_id: z.ZodNumber;
701
702
  auto_provisioned: z.ZodBoolean;
@@ -2376,7 +2377,7 @@ declare const TableItemSchema: z.ZodObject<{
2376
2377
  table: "table";
2377
2378
  virtual_table: "virtual_table";
2378
2379
  }>;
2379
- owner_account_id: z.ZodString;
2380
+ account_id: z.ZodString;
2380
2381
  profile_id: z.ZodString;
2381
2382
  parent_table_id: z.ZodOptional<z.ZodString>;
2382
2383
  }, z.core.$strip>;