@zapier/zapier-sdk 0.42.0 → 0.42.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/index.cjs +185 -159
  3. package/dist/index.d.mts +163 -408
  4. package/dist/index.d.ts +3 -3
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/index.mjs +185 -160
  8. package/dist/plugins/api/index.d.ts +5 -1
  9. package/dist/plugins/api/index.d.ts.map +1 -1
  10. package/dist/plugins/api/index.js +2 -3
  11. package/dist/plugins/apps/index.d.ts +2 -3
  12. package/dist/plugins/apps/index.d.ts.map +1 -1
  13. package/dist/plugins/apps/index.js +1 -1
  14. package/dist/plugins/capabilities/index.d.ts +8 -6
  15. package/dist/plugins/capabilities/index.d.ts.map +1 -1
  16. package/dist/plugins/capabilities/index.js +3 -3
  17. package/dist/plugins/connections/index.d.ts +3 -1
  18. package/dist/plugins/connections/index.d.ts.map +1 -1
  19. package/dist/plugins/connections/index.js +2 -3
  20. package/dist/plugins/createClientCredentials/index.d.ts +6 -4
  21. package/dist/plugins/createClientCredentials/index.d.ts.map +1 -1
  22. package/dist/plugins/createClientCredentials/index.js +3 -3
  23. package/dist/plugins/deleteClientCredentials/index.d.ts +6 -4
  24. package/dist/plugins/deleteClientCredentials/index.d.ts.map +1 -1
  25. package/dist/plugins/deleteClientCredentials/index.js +3 -3
  26. package/dist/plugins/deprecated/authentications.d.ts +9 -9
  27. package/dist/plugins/deprecated/authentications.d.ts.map +1 -1
  28. package/dist/plugins/deprecated/authentications.js +4 -4
  29. package/dist/plugins/eventEmission/index.d.ts +4 -5
  30. package/dist/plugins/eventEmission/index.d.ts.map +1 -1
  31. package/dist/plugins/eventEmission/index.js +8 -7
  32. package/dist/plugins/fetch/index.d.ts +6 -6
  33. package/dist/plugins/fetch/index.d.ts.map +1 -1
  34. package/dist/plugins/fetch/index.js +5 -5
  35. package/dist/plugins/findFirstConnection/index.d.ts +3 -4
  36. package/dist/plugins/findFirstConnection/index.d.ts.map +1 -1
  37. package/dist/plugins/findFirstConnection/index.js +2 -2
  38. package/dist/plugins/findUniqueConnection/index.d.ts +3 -4
  39. package/dist/plugins/findUniqueConnection/index.d.ts.map +1 -1
  40. package/dist/plugins/findUniqueConnection/index.js +2 -2
  41. package/dist/plugins/getAction/index.d.ts +7 -7
  42. package/dist/plugins/getAction/index.d.ts.map +1 -1
  43. package/dist/plugins/getAction/index.js +2 -2
  44. package/dist/plugins/getApp/index.d.ts +2 -3
  45. package/dist/plugins/getApp/index.d.ts.map +1 -1
  46. package/dist/plugins/getApp/index.js +2 -2
  47. package/dist/plugins/getConnection/index.d.ts +6 -6
  48. package/dist/plugins/getConnection/index.d.ts.map +1 -1
  49. package/dist/plugins/getConnection/index.js +3 -3
  50. package/dist/plugins/getInputFieldsSchema/index.d.ts +8 -6
  51. package/dist/plugins/getInputFieldsSchema/index.d.ts.map +1 -1
  52. package/dist/plugins/getInputFieldsSchema/index.js +4 -4
  53. package/dist/plugins/getProfile/index.d.ts +6 -6
  54. package/dist/plugins/getProfile/index.d.ts.map +1 -1
  55. package/dist/plugins/getProfile/index.js +3 -3
  56. package/dist/plugins/listActions/index.d.ts +8 -6
  57. package/dist/plugins/listActions/index.d.ts.map +1 -1
  58. package/dist/plugins/listActions/index.js +3 -3
  59. package/dist/plugins/listApps/index.d.ts +3 -3
  60. package/dist/plugins/listApps/index.d.ts.map +1 -1
  61. package/dist/plugins/listApps/index.js +3 -3
  62. package/dist/plugins/listClientCredentials/index.d.ts +6 -4
  63. package/dist/plugins/listClientCredentials/index.d.ts.map +1 -1
  64. package/dist/plugins/listClientCredentials/index.js +3 -3
  65. package/dist/plugins/listConnections/index.d.ts +8 -6
  66. package/dist/plugins/listConnections/index.d.ts.map +1 -1
  67. package/dist/plugins/listConnections/index.js +5 -5
  68. package/dist/plugins/listInputFieldChoices/index.d.ts +9 -8
  69. package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
  70. package/dist/plugins/listInputFieldChoices/index.js +4 -4
  71. package/dist/plugins/listInputFields/index.d.ts +8 -8
  72. package/dist/plugins/listInputFields/index.d.ts.map +1 -1
  73. package/dist/plugins/listInputFields/index.js +4 -4
  74. package/dist/plugins/manifest/index.d.ts +8 -3
  75. package/dist/plugins/manifest/index.d.ts.map +1 -1
  76. package/dist/plugins/manifest/index.js +2 -3
  77. package/dist/plugins/registry/index.d.ts +1 -2
  78. package/dist/plugins/registry/index.d.ts.map +1 -1
  79. package/dist/plugins/registry/index.js +3 -3
  80. package/dist/plugins/request/index.d.ts +3 -4
  81. package/dist/plugins/request/index.d.ts.map +1 -1
  82. package/dist/plugins/request/index.js +2 -2
  83. package/dist/plugins/runAction/index.d.ts +8 -8
  84. package/dist/plugins/runAction/index.d.ts.map +1 -1
  85. package/dist/plugins/runAction/index.js +5 -5
  86. package/dist/plugins/tables/createTable/index.d.ts +3 -5
  87. package/dist/plugins/tables/createTable/index.d.ts.map +1 -1
  88. package/dist/plugins/tables/createTable/index.js +3 -3
  89. package/dist/plugins/tables/createTableFields/index.d.ts +3 -5
  90. package/dist/plugins/tables/createTableFields/index.d.ts.map +1 -1
  91. package/dist/plugins/tables/createTableFields/index.js +3 -3
  92. package/dist/plugins/tables/createTableRecords/index.d.ts +3 -5
  93. package/dist/plugins/tables/createTableRecords/index.d.ts.map +1 -1
  94. package/dist/plugins/tables/createTableRecords/index.js +3 -3
  95. package/dist/plugins/tables/deleteTable/index.d.ts +5 -5
  96. package/dist/plugins/tables/deleteTable/index.d.ts.map +1 -1
  97. package/dist/plugins/tables/deleteTable/index.js +4 -4
  98. package/dist/plugins/tables/deleteTableFields/index.d.ts +3 -5
  99. package/dist/plugins/tables/deleteTableFields/index.d.ts.map +1 -1
  100. package/dist/plugins/tables/deleteTableFields/index.js +3 -3
  101. package/dist/plugins/tables/deleteTableRecords/index.d.ts +3 -5
  102. package/dist/plugins/tables/deleteTableRecords/index.d.ts.map +1 -1
  103. package/dist/plugins/tables/deleteTableRecords/index.js +3 -3
  104. package/dist/plugins/tables/getTable/index.d.ts +3 -5
  105. package/dist/plugins/tables/getTable/index.d.ts.map +1 -1
  106. package/dist/plugins/tables/getTable/index.js +3 -3
  107. package/dist/plugins/tables/getTableRecord/index.d.ts +3 -5
  108. package/dist/plugins/tables/getTableRecord/index.d.ts.map +1 -1
  109. package/dist/plugins/tables/getTableRecord/index.js +3 -3
  110. package/dist/plugins/tables/listTableFields/index.d.ts +3 -5
  111. package/dist/plugins/tables/listTableFields/index.d.ts.map +1 -1
  112. package/dist/plugins/tables/listTableFields/index.js +3 -3
  113. package/dist/plugins/tables/listTableRecords/index.d.ts +3 -3
  114. package/dist/plugins/tables/listTableRecords/index.d.ts.map +1 -1
  115. package/dist/plugins/tables/listTableRecords/index.js +3 -3
  116. package/dist/plugins/tables/listTables/index.d.ts +5 -3
  117. package/dist/plugins/tables/listTables/index.d.ts.map +1 -1
  118. package/dist/plugins/tables/listTables/index.js +4 -4
  119. package/dist/plugins/tables/updateTableRecords/index.d.ts +3 -5
  120. package/dist/plugins/tables/updateTableRecords/index.d.ts.map +1 -1
  121. package/dist/plugins/tables/updateTableRecords/index.js +3 -3
  122. package/dist/resolvers/connectionId.js +1 -1
  123. package/dist/resolvers/tableId.js +1 -1
  124. package/dist/sdk.d.ts +29 -257
  125. package/dist/sdk.d.ts.map +1 -1
  126. package/dist/sdk.js +33 -43
  127. package/dist/types/plugin.d.ts +29 -48
  128. package/dist/types/plugin.d.ts.map +1 -1
  129. package/dist/types/plugin.js +7 -3
  130. package/dist/types/sdk.d.ts +2 -3
  131. package/dist/types/sdk.d.ts.map +1 -1
  132. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -515,7 +515,7 @@ function createAppsProxy(options) {
515
515
  });
516
516
  return appsProxy;
517
517
  }
518
- var appsPlugin = ({ sdk }) => {
518
+ var appsPlugin = (sdk) => {
519
519
  return {
520
520
  apps: createAppsProxy({ sdk }),
521
521
  context: {
@@ -925,11 +925,11 @@ function buildAbortHandle({
925
925
  }
926
926
  var FetchInitSdkValidationSchema = z.looseObject(FetchInitZapierFieldsSchema.shape).optional();
927
927
  var validateFetchInit = createValidator(FetchInitSdkValidationSchema);
928
- var fetchPlugin = ({ context }) => {
928
+ var fetchPlugin = (sdk) => {
929
929
  return {
930
930
  fetch: async function fetch2(url, init) {
931
931
  return runWithTelemetryContext(async () => {
932
- const { api } = context;
932
+ const { api } = sdk.context;
933
933
  const startTime = Date.now();
934
934
  const isNested = isTelemetryNested();
935
935
  try {
@@ -948,7 +948,7 @@ var fetchPlugin = ({ context }) => {
948
948
  connectionId,
949
949
  connection,
950
950
  authenticationId,
951
- resolveConnection: context.resolveConnection,
951
+ resolveConnection: sdk.context.resolveConnection,
952
952
  label: "fetch"
953
953
  });
954
954
  const relayPath = transformUrlToRelayPath(url);
@@ -995,7 +995,7 @@ var fetchPlugin = ({ context }) => {
995
995
  });
996
996
  }
997
997
  if (!isNested) {
998
- context.eventEmission.emitMethodCalled({
998
+ sdk.context.eventEmission.emitMethodCalled({
999
999
  method_name: "fetch",
1000
1000
  execution_duration_ms: Date.now() - startTime,
1001
1001
  success_flag: true,
@@ -1017,7 +1017,7 @@ var fetchPlugin = ({ context }) => {
1017
1017
  }
1018
1018
  } catch (error) {
1019
1019
  if (!isNested) {
1020
- context.eventEmission.emitMethodCalled({
1020
+ sdk.context.eventEmission.emitMethodCalled({
1021
1021
  method_name: "fetch",
1022
1022
  execution_duration_ms: Date.now() - startTime,
1023
1023
  success_flag: false,
@@ -1581,9 +1581,9 @@ function createTelemetryCallback(emitMethodCalled, methodName) {
1581
1581
  }
1582
1582
 
1583
1583
  // src/plugins/listApps/index.ts
1584
- var listAppsPlugin = ({ context }) => {
1584
+ var listAppsPlugin = (sdk) => {
1585
1585
  async function listAppsPage(options) {
1586
- const { api, resolveAppKeys: resolveAppKeys2 } = context;
1586
+ const { api, resolveAppKeys: resolveAppKeys2 } = sdk.context;
1587
1587
  const appKeys = options.apps ?? options.appKeys ?? [];
1588
1588
  const appLocators = await resolveAppKeys2({
1589
1589
  appKeys: [...appKeys]
@@ -1627,7 +1627,10 @@ var listAppsPlugin = ({ context }) => {
1627
1627
  const listAppsDefinition = createPaginatedFunction(
1628
1628
  listAppsPage,
1629
1629
  ListAppsSchema,
1630
- createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
1630
+ createTelemetryCallback(
1631
+ sdk.context.eventEmission.emitMethodCalled,
1632
+ methodName
1633
+ ),
1631
1634
  methodName,
1632
1635
  DEFAULT_PAGE_SIZE
1633
1636
  );
@@ -2068,7 +2071,7 @@ var actionKeyResolver = {
2068
2071
 
2069
2072
  // src/resolvers/connectionId.ts
2070
2073
  async function fetchConnections(sdk, resolvedParams) {
2071
- const context = sdk.getContext();
2074
+ const context = sdk.context;
2072
2075
  const includeShared = await context.hasCapability?.(
2073
2076
  "canIncludeSharedConnections"
2074
2077
  );
@@ -2236,7 +2239,7 @@ var tableIdResolver = {
2236
2239
  type: "dynamic",
2237
2240
  requireCapabilities: ["canIncludeSharedTables"],
2238
2241
  fetch: async (sdk) => {
2239
- const context = sdk.getContext();
2242
+ const context = sdk.context;
2240
2243
  const includeShared = await context.hasCapability?.(
2241
2244
  "canIncludeSharedTables"
2242
2245
  );
@@ -2876,7 +2879,7 @@ var tableSortResolver = {
2876
2879
  };
2877
2880
 
2878
2881
  // src/plugins/listActions/index.ts
2879
- var listActionsPlugin = ({ context }) => {
2882
+ var listActionsPlugin = (sdk) => {
2880
2883
  const methodMeta = {
2881
2884
  categories: ["action"],
2882
2885
  type: "list",
@@ -2889,7 +2892,7 @@ var listActionsPlugin = ({ context }) => {
2889
2892
  }
2890
2893
  };
2891
2894
  async function listActionsPage(options) {
2892
- const { api, getVersionedImplementationId } = context;
2895
+ const { api, getVersionedImplementationId } = sdk.context;
2893
2896
  const appKey = "app" in options ? options.app : options.appKey;
2894
2897
  const selectedApi = await getVersionedImplementationId(appKey);
2895
2898
  if (!selectedApi) {
@@ -2954,7 +2957,10 @@ var listActionsPlugin = ({ context }) => {
2954
2957
  const listActionsDefinition = createPaginatedFunction(
2955
2958
  listActionsPage,
2956
2959
  ListActionsInputSchema,
2957
- createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
2960
+ createTelemetryCallback(
2961
+ sdk.context.eventEmission.emitMethodCalled,
2962
+ methodName
2963
+ ),
2958
2964
  methodName,
2959
2965
  DEFAULT_PAGE_SIZE
2960
2966
  );
@@ -3277,9 +3283,9 @@ function transformNeedsToFields(needs) {
3277
3283
  }
3278
3284
  return rootFields;
3279
3285
  }
3280
- var listInputFieldsPlugin = ({ sdk, context }) => {
3286
+ var listInputFieldsPlugin = (sdk) => {
3281
3287
  async function listInputFieldsPage(options) {
3282
- const { api, getVersionedImplementationId } = context;
3288
+ const { api, getVersionedImplementationId } = sdk.context;
3283
3289
  const appKey = "app" in options ? options.app : options.appKey;
3284
3290
  const actionKey = "action" in options ? options.action : options.actionKey;
3285
3291
  const { actionType, connection, connectionId, authenticationId, inputs } = options;
@@ -3287,7 +3293,7 @@ var listInputFieldsPlugin = ({ sdk, context }) => {
3287
3293
  connection,
3288
3294
  connectionId,
3289
3295
  authenticationId,
3290
- resolveConnection: context.resolveConnection
3296
+ resolveConnection: sdk.context.resolveConnection
3291
3297
  });
3292
3298
  const selectedApi = await getVersionedImplementationId(appKey);
3293
3299
  if (!selectedApi) {
@@ -3325,7 +3331,10 @@ var listInputFieldsPlugin = ({ sdk, context }) => {
3325
3331
  const listInputFieldsDefinition = createPaginatedFunction(
3326
3332
  listInputFieldsPage,
3327
3333
  ListInputFieldsInputSchema,
3328
- createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
3334
+ createTelemetryCallback(
3335
+ sdk.context.eventEmission.emitMethodCalled,
3336
+ methodName
3337
+ ),
3329
3338
  methodName,
3330
3339
  DEFAULT_PAGE_SIZE
3331
3340
  );
@@ -3428,12 +3437,12 @@ var ConnectionItemSchema = withFormatter(ConnectionItemSchema$1, {
3428
3437
  });
3429
3438
 
3430
3439
  // src/plugins/listConnections/index.ts
3431
- var listConnectionsPlugin = ({ context }) => {
3440
+ var listConnectionsPlugin = (sdk) => {
3432
3441
  async function listConnectionsPage(options) {
3433
3442
  if (options.includeShared) {
3434
- await context.checkCapability("canIncludeSharedConnections");
3443
+ await sdk.context.checkCapability("canIncludeSharedConnections");
3435
3444
  }
3436
- const { api, getVersionedImplementationId } = context;
3445
+ const { api, getVersionedImplementationId } = sdk.context;
3437
3446
  const searchParams = {};
3438
3447
  if (options.pageSize !== void 0) {
3439
3448
  searchParams.page_size = options.pageSize.toString();
@@ -3456,7 +3465,7 @@ var listConnectionsPlugin = ({ context }) => {
3456
3465
  connectionRefs.map(
3457
3466
  (ref) => resolveConnectionId({
3458
3467
  connection: ref,
3459
- resolveConnection: context.resolveConnection
3468
+ resolveConnection: sdk.context.resolveConnection
3460
3469
  })
3461
3470
  )
3462
3471
  );
@@ -3522,7 +3531,10 @@ var listConnectionsPlugin = ({ context }) => {
3522
3531
  const listConnectionsDefinition = createPaginatedFunction(
3523
3532
  listConnectionsPage,
3524
3533
  ListConnectionsQuerySchema,
3525
- createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
3534
+ createTelemetryCallback(
3535
+ sdk.context.eventEmission.emitMethodCalled,
3536
+ methodName
3537
+ ),
3526
3538
  methodName,
3527
3539
  DEFAULT_PAGE_SIZE
3528
3540
  );
@@ -3598,9 +3610,9 @@ var ClientCredentialsCreatedItemSchema = withFormatter(
3598
3610
  );
3599
3611
 
3600
3612
  // src/plugins/listClientCredentials/index.ts
3601
- var listClientCredentialsPlugin = ({ context }) => {
3613
+ var listClientCredentialsPlugin = (sdk) => {
3602
3614
  async function listClientCredentialsPage(options) {
3603
- const { api } = context;
3615
+ const { api } = sdk.context;
3604
3616
  const searchParams = {};
3605
3617
  if (options.pageSize !== void 0) {
3606
3618
  searchParams.pageSize = options.pageSize.toString();
@@ -3637,7 +3649,10 @@ var listClientCredentialsPlugin = ({ context }) => {
3637
3649
  const listClientCredentialsDefinition = createPaginatedFunction(
3638
3650
  listClientCredentialsPage,
3639
3651
  ListClientCredentialsQuerySchema,
3640
- createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
3652
+ createTelemetryCallback(
3653
+ sdk.context.eventEmission.emitMethodCalled,
3654
+ methodName
3655
+ ),
3641
3656
  methodName,
3642
3657
  DEFAULT_PAGE_SIZE
3643
3658
  );
@@ -3661,9 +3676,9 @@ var CreateClientCredentialsSchema = CreateClientCredentialsRequestSchema.omit({
3661
3676
  }).describe("Create new client credentials for the authenticated user");
3662
3677
 
3663
3678
  // src/plugins/createClientCredentials/index.ts
3664
- var createClientCredentialsPlugin = ({ context }) => {
3679
+ var createClientCredentialsPlugin = (sdk) => {
3665
3680
  async function createClientCredentials(options) {
3666
- const { api } = context;
3681
+ const { api } = sdk.context;
3667
3682
  const response = await api.post(
3668
3683
  "/api/v0/client-credentials",
3669
3684
  {
@@ -3698,7 +3713,7 @@ var createClientCredentialsPlugin = ({ context }) => {
3698
3713
  createClientCredentials,
3699
3714
  CreateClientCredentialsSchema,
3700
3715
  createTelemetryCallback(
3701
- context.eventEmission.emitMethodCalled,
3716
+ sdk.context.eventEmission.emitMethodCalled,
3702
3717
  createClientCredentials.name
3703
3718
  )
3704
3719
  );
@@ -3726,9 +3741,9 @@ var DeleteClientCredentialsSchema = z.object({
3726
3741
  }).describe("Delete client credentials by client ID");
3727
3742
 
3728
3743
  // src/plugins/deleteClientCredentials/index.ts
3729
- var deleteClientCredentialsPlugin = ({ context }) => {
3744
+ var deleteClientCredentialsPlugin = (sdk) => {
3730
3745
  async function deleteClientCredentials(options) {
3731
- const { api } = context;
3746
+ const { api } = sdk.context;
3732
3747
  await api.delete(
3733
3748
  `/api/v0/client-credentials/${options.clientId}`,
3734
3749
  void 0,
@@ -3760,7 +3775,7 @@ var deleteClientCredentialsPlugin = ({ context }) => {
3760
3775
  deleteClientCredentials,
3761
3776
  DeleteClientCredentialsSchema,
3762
3777
  createTelemetryCallback(
3763
- context.eventEmission.emitMethodCalled,
3778
+ sdk.context.eventEmission.emitMethodCalled,
3764
3779
  deleteClientCredentials.name
3765
3780
  )
3766
3781
  );
@@ -3791,7 +3806,7 @@ var GetAppSchemaDeprecated = z.object({
3791
3806
  var GetAppInputSchema = z.union([GetAppSchema, GetAppSchemaDeprecated]).describe(GetAppDescription);
3792
3807
 
3793
3808
  // src/plugins/getApp/index.ts
3794
- var getAppPlugin = ({ sdk, context }) => {
3809
+ var getAppPlugin = (sdk) => {
3795
3810
  async function getApp(options) {
3796
3811
  const appKey = "app" in options ? options.app : options.appKey;
3797
3812
  const appsIterable = sdk.listApps({
@@ -3810,7 +3825,7 @@ var getAppPlugin = ({ sdk, context }) => {
3810
3825
  getApp,
3811
3826
  GetAppInputSchema,
3812
3827
  createTelemetryCallback(
3813
- context.eventEmission.emitMethodCalled,
3828
+ sdk.context.eventEmission.emitMethodCalled,
3814
3829
  getApp.name
3815
3830
  )
3816
3831
  );
@@ -3846,7 +3861,7 @@ var GetActionSchemaDeprecated = z.object({
3846
3861
  var GetActionInputSchema = z.union([GetActionSchema, GetActionSchemaDeprecated]).describe(GetActionDescription);
3847
3862
 
3848
3863
  // src/plugins/getAction/index.ts
3849
- var getActionPlugin = ({ sdk, context }) => {
3864
+ var getActionPlugin = (sdk) => {
3850
3865
  async function getAction(options) {
3851
3866
  const appKey = "app" in options ? options.app : options.appKey;
3852
3867
  const actionKey = "action" in options ? options.action : options.actionKey;
@@ -3869,7 +3884,7 @@ var getActionPlugin = ({ sdk, context }) => {
3869
3884
  getAction,
3870
3885
  GetActionInputSchema,
3871
3886
  createTelemetryCallback(
3872
- context.eventEmission.emitMethodCalled,
3887
+ sdk.context.eventEmission.emitMethodCalled,
3873
3888
  getAction.name
3874
3889
  )
3875
3890
  );
@@ -3906,9 +3921,9 @@ var GetConnectionParamSchema = z.object({
3906
3921
  });
3907
3922
 
3908
3923
  // src/plugins/getConnection/index.ts
3909
- var getConnectionPlugin = ({ context }) => {
3924
+ var getConnectionPlugin = (sdk) => {
3910
3925
  async function getConnection(options) {
3911
- const { api } = context;
3926
+ const { api } = sdk.context;
3912
3927
  const resolvedConnectionId = options.connection ?? options.connectionId ?? options.authenticationId;
3913
3928
  if (!resolvedConnectionId) {
3914
3929
  throw new Error("connection is required");
@@ -3925,7 +3940,7 @@ var getConnectionPlugin = ({ context }) => {
3925
3940
  getConnection,
3926
3941
  GetConnectionParamSchema,
3927
3942
  createTelemetryCallback(
3928
- context.eventEmission.emitMethodCalled,
3943
+ sdk.context.eventEmission.emitMethodCalled,
3929
3944
  getConnection.name
3930
3945
  )
3931
3946
  );
@@ -3959,7 +3974,7 @@ var FindFirstConnectionSchema = ListConnectionsQuerySchema.omit({
3959
3974
  }).describe("Find the first connection matching the criteria");
3960
3975
 
3961
3976
  // src/plugins/findFirstConnection/index.ts
3962
- var findFirstConnectionPlugin = ({ sdk, context }) => {
3977
+ var findFirstConnectionPlugin = (sdk) => {
3963
3978
  async function findFirstConnection(options = {}) {
3964
3979
  const connectionsResponse = await sdk.listConnections({
3965
3980
  ...options,
@@ -3979,7 +3994,7 @@ var findFirstConnectionPlugin = ({ sdk, context }) => {
3979
3994
  findFirstConnection,
3980
3995
  FindFirstConnectionSchema,
3981
3996
  createTelemetryCallback(
3982
- context.eventEmission.emitMethodCalled,
3997
+ sdk.context.eventEmission.emitMethodCalled,
3983
3998
  findFirstConnection.name
3984
3999
  )
3985
4000
  );
@@ -4010,7 +4025,7 @@ var FindUniqueConnectionSchema = ListConnectionsQuerySchema.omit({
4010
4025
  }).describe("Find a unique connection matching the criteria");
4011
4026
 
4012
4027
  // src/plugins/findUniqueConnection/index.ts
4013
- var findUniqueConnectionPlugin = ({ sdk, context }) => {
4028
+ var findUniqueConnectionPlugin = (sdk) => {
4014
4029
  async function findUniqueConnection(options = {}) {
4015
4030
  const connectionsResponse = await sdk.listConnections({
4016
4031
  ...options,
@@ -4036,7 +4051,7 @@ var findUniqueConnectionPlugin = ({ sdk, context }) => {
4036
4051
  findUniqueConnection,
4037
4052
  FindUniqueConnectionSchema,
4038
4053
  createTelemetryCallback(
4039
- context.eventEmission.emitMethodCalled,
4054
+ sdk.context.eventEmission.emitMethodCalled,
4040
4055
  findUniqueConnection.name
4041
4056
  )
4042
4057
  );
@@ -4139,7 +4154,7 @@ async function executeAction(actionOptions) {
4139
4154
  }
4140
4155
  var CONTEXT_CACHE_TTL_MS = 6e4;
4141
4156
  var CONTEXT_CACHE_MAX_SIZE = 500;
4142
- var runActionPlugin = ({ sdk, context }) => {
4157
+ var runActionPlugin = (sdk) => {
4143
4158
  const runActionContextCache = /* @__PURE__ */ new Map();
4144
4159
  function evictIfNeeded() {
4145
4160
  if (runActionContextCache.size < CONTEXT_CACHE_MAX_SIZE) return;
@@ -4183,7 +4198,7 @@ var runActionPlugin = ({ sdk, context }) => {
4183
4198
  }
4184
4199
  async function resolveRunActionContext(options) {
4185
4200
  const { appKey, actionKey, actionType } = options;
4186
- const selectedApi = await context.getVersionedImplementationId(appKey);
4201
+ const selectedApi = await sdk.context.getVersionedImplementationId(appKey);
4187
4202
  if (!selectedApi) {
4188
4203
  throw new ZapierConfigurationError(
4189
4204
  "No current_implementation_id found for app",
@@ -4203,7 +4218,7 @@ var runActionPlugin = ({ sdk, context }) => {
4203
4218
  return { selectedApi, actionId: actionData.data.id };
4204
4219
  }
4205
4220
  async function runActionPage(options) {
4206
- const { api } = context;
4221
+ const { api } = sdk.context;
4207
4222
  const appKey = "app" in options ? options.app : options.appKey;
4208
4223
  const actionKey = "action" in options ? options.action : options.actionKey;
4209
4224
  const {
@@ -4219,7 +4234,7 @@ var runActionPlugin = ({ sdk, context }) => {
4219
4234
  connectionId,
4220
4235
  connection,
4221
4236
  authenticationId,
4222
- resolveConnection: context.resolveConnection
4237
+ resolveConnection: sdk.context.resolveConnection
4223
4238
  });
4224
4239
  const { selectedApi, actionId } = await getRunActionContext({
4225
4240
  appKey,
@@ -4262,7 +4277,10 @@ var runActionPlugin = ({ sdk, context }) => {
4262
4277
  const runActionDefinition = createPaginatedFunction(
4263
4278
  runActionPage,
4264
4279
  RunActionInputSchema,
4265
- createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
4280
+ createTelemetryCallback(
4281
+ sdk.context.eventEmission.emitMethodCalled,
4282
+ methodName
4283
+ ),
4266
4284
  methodName
4267
4285
  );
4268
4286
  return {
@@ -4322,7 +4340,7 @@ function resetDeprecationWarnings() {
4322
4340
  }
4323
4341
 
4324
4342
  // src/plugins/request/index.ts
4325
- var requestPlugin = ({ sdk, context }) => {
4343
+ var requestPlugin = (sdk) => {
4326
4344
  async function request(options) {
4327
4345
  logDeprecation("request() is deprecated. Use fetch() instead.");
4328
4346
  const {
@@ -4347,7 +4365,7 @@ var requestPlugin = ({ sdk, context }) => {
4347
4365
  request,
4348
4366
  RelayRequestSchema,
4349
4367
  createTelemetryCallback(
4350
- context.eventEmission.emitMethodCalled,
4368
+ sdk.context.eventEmission.emitMethodCalled,
4351
4369
  request.name
4352
4370
  )
4353
4371
  );
@@ -4656,9 +4674,8 @@ async function resolveAppKeys({
4656
4674
  });
4657
4675
  return slugResolvedLocators.filter(isResolvedAppLocator);
4658
4676
  }
4659
- var manifestPlugin = (params) => {
4660
- const { context } = params;
4661
- const { api, options } = context;
4677
+ var manifestPlugin = (sdk) => {
4678
+ const { api, options } = sdk.context;
4662
4679
  const { manifestPath = DEFAULT_CONFIG_PATH, manifest } = options || {};
4663
4680
  let resolvedManifest;
4664
4681
  async function resolveManifest() {
@@ -4869,9 +4886,9 @@ var UserProfileItemSchema = withFormatter(
4869
4886
  );
4870
4887
 
4871
4888
  // src/plugins/getProfile/index.ts
4872
- var getProfilePlugin = ({ context }) => {
4889
+ var getProfilePlugin = (sdk) => {
4873
4890
  async function getProfile() {
4874
- const profile = await context.api.get(
4891
+ const profile = await sdk.context.api.get(
4875
4892
  "/zapier/api/v4/profile/",
4876
4893
  {
4877
4894
  authRequired: true
@@ -4893,7 +4910,7 @@ var getProfilePlugin = ({ context }) => {
4893
4910
  getProfile,
4894
4911
  GetProfileSchema,
4895
4912
  createTelemetryCallback(
4896
- context.eventEmission.emitMethodCalled,
4913
+ sdk.context.eventEmission.emitMethodCalled,
4897
4914
  getProfile.name
4898
4915
  )
4899
4916
  );
@@ -6080,7 +6097,7 @@ var createZapierApi = (options) => {
6080
6097
  };
6081
6098
 
6082
6099
  // src/plugins/api/index.ts
6083
- var apiPlugin = (params) => {
6100
+ var apiPlugin = (sdk) => {
6084
6101
  const {
6085
6102
  fetch: customFetch = globalThis.fetch,
6086
6103
  baseUrl = ZAPIER_BASE_URL,
@@ -6090,7 +6107,7 @@ var apiPlugin = (params) => {
6090
6107
  debug = false,
6091
6108
  maxNetworkRetries = ZAPIER_MAX_NETWORK_RETRIES,
6092
6109
  maxNetworkRetryDelayMs = ZAPIER_MAX_NETWORK_RETRY_DELAY_MS
6093
- } = params.context.options;
6110
+ } = sdk.context.options;
6094
6111
  const api = createZapierApi({
6095
6112
  baseUrl,
6096
6113
  credentials,
@@ -6205,12 +6222,11 @@ async function batch(tasks, options = {}) {
6205
6222
  }
6206
6223
 
6207
6224
  // src/plugins/connections/index.ts
6208
- var connectionsPlugin = (params) => {
6209
- const { context } = params;
6225
+ var connectionsPlugin = (sdk) => {
6210
6226
  let cachedMap;
6211
6227
  async function loadConnectionsMap() {
6212
6228
  if (cachedMap === void 0) {
6213
- cachedMap = await context.getManifestConnections() ?? null;
6229
+ cachedMap = await sdk.context.getManifestConnections() ?? null;
6214
6230
  }
6215
6231
  return cachedMap;
6216
6232
  }
@@ -6257,12 +6273,12 @@ function isEnabledByEnv(key) {
6257
6273
  if (value === "false" || value === "0") return false;
6258
6274
  return void 0;
6259
6275
  }
6260
- var capabilitiesPlugin = ({ context }) => {
6261
- const options = context.options ?? {};
6276
+ var capabilitiesPlugin = (sdk) => {
6277
+ const options = sdk.context.options ?? {};
6262
6278
  let cached;
6263
6279
  async function resolveFlags() {
6264
6280
  if (cached) return cached;
6265
- const manifest = await context.getResolvedManifest();
6281
+ const manifest = await sdk.context.getResolvedManifest();
6266
6282
  cached = {};
6267
6283
  for (const flag of GATED_FLAGS) {
6268
6284
  cached[flag] = Boolean(
@@ -6348,12 +6364,12 @@ function extractNextCursor(links) {
6348
6364
  return void 0;
6349
6365
  }
6350
6366
  }
6351
- var listTablesPlugin = ({ context }) => {
6367
+ var listTablesPlugin = (sdk) => {
6352
6368
  async function listTablesPage(options) {
6353
6369
  if (options.includeShared) {
6354
- await context.checkCapability("canIncludeSharedTables");
6370
+ await sdk.context.checkCapability("canIncludeSharedTables");
6355
6371
  }
6356
- const { api } = context;
6372
+ const { api } = sdk.context;
6357
6373
  const searchParams = {};
6358
6374
  if (options.pageSize !== void 0) {
6359
6375
  searchParams.limit = options.pageSize.toString();
@@ -6418,7 +6434,10 @@ var listTablesPlugin = ({ context }) => {
6418
6434
  const listTablesDefinition = createPaginatedFunction(
6419
6435
  listTablesPage,
6420
6436
  ListTablesOptionsSchema,
6421
- createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
6437
+ createTelemetryCallback(
6438
+ sdk.context.eventEmission.emitMethodCalled,
6439
+ methodName
6440
+ ),
6422
6441
  methodName,
6423
6442
  DEFAULT_PAGE_SIZE
6424
6443
  );
@@ -6450,9 +6469,9 @@ var GetTableOptionsSchemaDeprecated = z.object({
6450
6469
  var GetTableOptionsInputSchema = z.union([GetTableOptionsSchema, GetTableOptionsSchemaDeprecated]).describe(GetTableDescription);
6451
6470
 
6452
6471
  // src/plugins/tables/getTable/index.ts
6453
- var getTablePlugin = ({ context }) => {
6472
+ var getTablePlugin = (sdk) => {
6454
6473
  async function getTable(options) {
6455
- const { api } = context;
6474
+ const { api } = sdk.context;
6456
6475
  const tableId = "table" in options ? options.table : options.tableId;
6457
6476
  const rawResponse = await api.get(`/tables/api/v1/tables/${tableId}`, {
6458
6477
  customErrorHandler: ({ status }) => {
@@ -6484,7 +6503,7 @@ var getTablePlugin = ({ context }) => {
6484
6503
  getTable,
6485
6504
  GetTableOptionsInputSchema,
6486
6505
  createTelemetryCallback(
6487
- context.eventEmission.emitMethodCalled,
6506
+ sdk.context.eventEmission.emitMethodCalled,
6488
6507
  getTable.name
6489
6508
  )
6490
6509
  );
@@ -6515,9 +6534,9 @@ var CreateTableOptionsSchema = z.object({
6515
6534
  }).describe("Create a new table");
6516
6535
 
6517
6536
  // src/plugins/tables/createTable/index.ts
6518
- var createTablePlugin = ({ context }) => {
6537
+ var createTablePlugin = (sdk) => {
6519
6538
  async function createTable(options) {
6520
- const { api } = context;
6539
+ const { api } = sdk.context;
6521
6540
  const rawResponse = await api.post(
6522
6541
  "/tables/api/v1/tables",
6523
6542
  {
@@ -6552,7 +6571,7 @@ var createTablePlugin = ({ context }) => {
6552
6571
  createTable,
6553
6572
  CreateTableOptionsSchema,
6554
6573
  createTelemetryCallback(
6555
- context.eventEmission.emitMethodCalled,
6574
+ sdk.context.eventEmission.emitMethodCalled,
6556
6575
  createTable.name
6557
6576
  )
6558
6577
  );
@@ -6584,10 +6603,10 @@ var DeleteTableOptionsSchemaDeprecated = z.object({
6584
6603
  var DeleteTableOptionsInputSchema = z.union([DeleteTableOptionsSchema, DeleteTableOptionsSchemaDeprecated]).describe(DeleteTableDescription);
6585
6604
 
6586
6605
  // src/plugins/tables/deleteTable/index.ts
6587
- var deleteTablePlugin = ({ context }) => {
6606
+ var deleteTablePlugin = (sdk) => {
6588
6607
  async function deleteTable(options) {
6589
- await context.checkCapability("canDeleteTables");
6590
- const { api } = context;
6608
+ await sdk.context.checkCapability("canDeleteTables");
6609
+ const { api } = sdk.context;
6591
6610
  const tableId = "table" in options ? options.table : options.tableId;
6592
6611
  await api.delete(`/tables/api/v1/tables/${tableId}`, void 0, {
6593
6612
  customErrorHandler: ({ status }) => {
@@ -6615,7 +6634,7 @@ var deleteTablePlugin = ({ context }) => {
6615
6634
  deleteTable,
6616
6635
  DeleteTableOptionsInputSchema,
6617
6636
  createTelemetryCallback(
6618
- context.eventEmission.emitMethodCalled,
6637
+ sdk.context.eventEmission.emitMethodCalled,
6619
6638
  deleteTable.name
6620
6639
  )
6621
6640
  );
@@ -6639,9 +6658,9 @@ var deleteTablePlugin = ({ context }) => {
6639
6658
  };
6640
6659
 
6641
6660
  // src/plugins/tables/listTableFields/index.ts
6642
- var listTableFieldsPlugin = ({ context }) => {
6661
+ var listTableFieldsPlugin = (sdk) => {
6643
6662
  async function listTableFields(options) {
6644
- const { api } = context;
6663
+ const { api } = sdk.context;
6645
6664
  const tableId = "table" in options ? options.table : options.tableId;
6646
6665
  const fieldKeys = "fields" in options ? options.fields : options.fieldKeys;
6647
6666
  const searchParams = {};
@@ -6687,7 +6706,7 @@ var listTableFieldsPlugin = ({ context }) => {
6687
6706
  listTableFields,
6688
6707
  ListTableFieldsOptionsInputSchema,
6689
6708
  createTelemetryCallback(
6690
- context.eventEmission.emitMethodCalled,
6709
+ sdk.context.eventEmission.emitMethodCalled,
6691
6710
  listTableFields.name
6692
6711
  )
6693
6712
  );
@@ -6742,9 +6761,9 @@ var CreateTableFieldsOptionsInputSchema = z.union([
6742
6761
  ]).describe(CreateTableFieldsDescription);
6743
6762
 
6744
6763
  // src/plugins/tables/createTableFields/index.ts
6745
- var createTableFieldsPlugin = ({ context }) => {
6764
+ var createTableFieldsPlugin = (sdk) => {
6746
6765
  async function createTableFields(options) {
6747
- const { api } = context;
6766
+ const { api } = sdk.context;
6748
6767
  const tableId = "table" in options ? options.table : options.tableId;
6749
6768
  const rawResponse = await api.post(
6750
6769
  `/tables/api/v1/tables/${tableId}/fields`,
@@ -6779,7 +6798,7 @@ var createTableFieldsPlugin = ({ context }) => {
6779
6798
  createTableFields,
6780
6799
  CreateTableFieldsOptionsInputSchema,
6781
6800
  createTelemetryCallback(
6782
- context.eventEmission.emitMethodCalled,
6801
+ sdk.context.eventEmission.emitMethodCalled,
6783
6802
  createTableFields.name
6784
6803
  )
6785
6804
  );
@@ -6819,9 +6838,9 @@ var DeleteTableFieldsOptionsInputSchema = z.union([
6819
6838
  ]).describe(DeleteTableFieldsDescription);
6820
6839
 
6821
6840
  // src/plugins/tables/deleteTableFields/index.ts
6822
- var deleteTableFieldsPlugin = ({ context }) => {
6841
+ var deleteTableFieldsPlugin = (sdk) => {
6823
6842
  async function deleteTableFields(options) {
6824
- const { api } = context;
6843
+ const { api } = sdk.context;
6825
6844
  const tableId = "table" in options ? options.table : options.tableId;
6826
6845
  const fieldKeys = "fields" in options ? options.fields : options.fieldKeys;
6827
6846
  const numericFieldIds = await resolveFieldKeys({
@@ -6859,7 +6878,7 @@ var deleteTableFieldsPlugin = ({ context }) => {
6859
6878
  deleteTableFields,
6860
6879
  DeleteTableFieldsOptionsInputSchema,
6861
6880
  createTelemetryCallback(
6862
- context.eventEmission.emitMethodCalled,
6881
+ sdk.context.eventEmission.emitMethodCalled,
6863
6882
  deleteTableFields.name
6864
6883
  )
6865
6884
  );
@@ -6946,9 +6965,9 @@ var tableRecordFormatter = {
6946
6965
  };
6947
6966
 
6948
6967
  // src/plugins/tables/getTableRecord/index.ts
6949
- var getTableRecordPlugin = ({ context }) => {
6968
+ var getTableRecordPlugin = (sdk) => {
6950
6969
  async function getTableRecord(options) {
6951
- const { api } = context;
6970
+ const { api } = sdk.context;
6952
6971
  const tableId = "table" in options ? options.table : options.tableId;
6953
6972
  const recordId = "record" in options ? options.record : options.recordId;
6954
6973
  const rawResponse = await api.get(
@@ -6992,7 +7011,7 @@ var getTableRecordPlugin = ({ context }) => {
6992
7011
  getTableRecord,
6993
7012
  GetTableRecordOptionsInputSchema,
6994
7013
  createTelemetryCallback(
6995
- context.eventEmission.emitMethodCalled,
7014
+ sdk.context.eventEmission.emitMethodCalled,
6996
7015
  getTableRecord.name
6997
7016
  )
6998
7017
  );
@@ -7080,9 +7099,9 @@ function extractNextCursor2(meta) {
7080
7099
  }
7081
7100
  return meta.pagination.end_cursor;
7082
7101
  }
7083
- var listTableRecordsPlugin = ({ context }) => {
7102
+ var listTableRecordsPlugin = (sdk) => {
7084
7103
  async function listTableRecordsPage(options) {
7085
- const { api } = context;
7104
+ const { api } = sdk.context;
7086
7105
  const tableId = "table" in options ? options.table : options.tableId;
7087
7106
  const translator = await createFieldKeyTranslator({
7088
7107
  api,
@@ -7154,7 +7173,10 @@ var listTableRecordsPlugin = ({ context }) => {
7154
7173
  const listTableRecordsDefinition = createPaginatedFunction(
7155
7174
  listTableRecordsPage,
7156
7175
  ListTableRecordsOptionsInputSchema,
7157
- createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
7176
+ createTelemetryCallback(
7177
+ sdk.context.eventEmission.emitMethodCalled,
7178
+ methodName
7179
+ ),
7158
7180
  methodName,
7159
7181
  DEFAULT_PAGE_SIZE
7160
7182
  );
@@ -7209,9 +7231,9 @@ var CreateTableRecordsOptionsInputSchema = z.union([
7209
7231
  ]).describe(CreateTableRecordsDescription);
7210
7232
 
7211
7233
  // src/plugins/tables/createTableRecords/index.ts
7212
- var createTableRecordsPlugin = ({ context }) => {
7234
+ var createTableRecordsPlugin = (sdk) => {
7213
7235
  async function createTableRecords(options) {
7214
- const { api } = context;
7236
+ const { api } = sdk.context;
7215
7237
  const tableId = "table" in options ? options.table : options.tableId;
7216
7238
  const translator = await createFieldKeyTranslator({
7217
7239
  api,
@@ -7263,7 +7285,7 @@ var createTableRecordsPlugin = ({ context }) => {
7263
7285
  createTableRecords,
7264
7286
  CreateTableRecordsOptionsInputSchema,
7265
7287
  createTelemetryCallback(
7266
- context.eventEmission.emitMethodCalled,
7288
+ sdk.context.eventEmission.emitMethodCalled,
7267
7289
  createTableRecords.name
7268
7290
  )
7269
7291
  );
@@ -7302,9 +7324,9 @@ var DeleteTableRecordsOptionsInputSchema = z.union([
7302
7324
  ]).describe(DeleteTableRecordsDescription);
7303
7325
 
7304
7326
  // src/plugins/tables/deleteTableRecords/index.ts
7305
- var deleteTableRecordsPlugin = ({ context }) => {
7327
+ var deleteTableRecordsPlugin = (sdk) => {
7306
7328
  async function deleteTableRecords(options) {
7307
- const { api } = context;
7329
+ const { api } = sdk.context;
7308
7330
  const tableId = "table" in options ? options.table : options.tableId;
7309
7331
  const recordIds = "records" in options ? options.records : options.recordIds;
7310
7332
  await api.delete(
@@ -7337,7 +7359,7 @@ var deleteTableRecordsPlugin = ({ context }) => {
7337
7359
  deleteTableRecords,
7338
7360
  DeleteTableRecordsOptionsInputSchema,
7339
7361
  createTelemetryCallback(
7340
- context.eventEmission.emitMethodCalled,
7362
+ sdk.context.eventEmission.emitMethodCalled,
7341
7363
  deleteTableRecords.name
7342
7364
  )
7343
7365
  );
@@ -7391,9 +7413,9 @@ var UpdateTableRecordsOptionsInputSchema = z.union([
7391
7413
  ]).describe(UpdateTableRecordsDescription);
7392
7414
 
7393
7415
  // src/plugins/tables/updateTableRecords/index.ts
7394
- var updateTableRecordsPlugin = ({ context }) => {
7416
+ var updateTableRecordsPlugin = (sdk) => {
7395
7417
  async function updateTableRecords(options) {
7396
- const { api } = context;
7418
+ const { api } = sdk.context;
7397
7419
  const tableId = "table" in options ? options.table : options.tableId;
7398
7420
  const translator = await createFieldKeyTranslator({
7399
7421
  api,
@@ -7446,7 +7468,7 @@ var updateTableRecordsPlugin = ({ context }) => {
7446
7468
  updateTableRecords,
7447
7469
  UpdateTableRecordsOptionsInputSchema,
7448
7470
  createTelemetryCallback(
7449
- context.eventEmission.emitMethodCalled,
7471
+ sdk.context.eventEmission.emitMethodCalled,
7450
7472
  updateTableRecords.name
7451
7473
  )
7452
7474
  );
@@ -7472,8 +7494,8 @@ var updateTableRecordsPlugin = ({ context }) => {
7472
7494
  };
7473
7495
 
7474
7496
  // src/plugins/registry/index.ts
7475
- var registryPlugin = ({ sdk, context }) => {
7476
- const metaKeys = Object.keys(context.meta || {});
7497
+ var registryPlugin = (sdk) => {
7498
+ const metaKeys = Object.keys(sdk.context.meta || {});
7477
7499
  const categoryDefinitions = {
7478
7500
  account: {
7479
7501
  title: "Account"
@@ -7518,7 +7540,7 @@ var registryPlugin = ({ sdk, context }) => {
7518
7540
  }
7519
7541
  return false;
7520
7542
  }).map((key) => {
7521
- const meta = context.meta[key];
7543
+ const meta = sdk.context.meta[key];
7522
7544
  return {
7523
7545
  name: key,
7524
7546
  description: meta.description,
@@ -7586,7 +7608,7 @@ var registryPlugin = ({ sdk, context }) => {
7586
7608
  };
7587
7609
 
7588
7610
  // src/plugins/deprecated/authentications.ts
7589
- var listAuthenticationsPlugin = ({ sdk }) => ({
7611
+ var listAuthenticationsPlugin = (sdk) => ({
7590
7612
  listAuthentications: sdk.listConnections,
7591
7613
  context: {
7592
7614
  meta: {
@@ -7601,7 +7623,7 @@ var listAuthenticationsPlugin = ({ sdk }) => ({
7601
7623
  }
7602
7624
  }
7603
7625
  });
7604
- var getAuthenticationPlugin = ({ sdk }) => ({
7626
+ var getAuthenticationPlugin = (sdk) => ({
7605
7627
  getAuthentication: sdk.getConnection,
7606
7628
  context: {
7607
7629
  meta: {
@@ -7616,7 +7638,7 @@ var getAuthenticationPlugin = ({ sdk }) => ({
7616
7638
  }
7617
7639
  }
7618
7640
  });
7619
- var findFirstAuthenticationPlugin = ({ sdk }) => ({
7641
+ var findFirstAuthenticationPlugin = (sdk) => ({
7620
7642
  findFirstAuthentication: sdk.findFirstConnection,
7621
7643
  context: {
7622
7644
  meta: {
@@ -7631,7 +7653,7 @@ var findFirstAuthenticationPlugin = ({ sdk }) => ({
7631
7653
  }
7632
7654
  }
7633
7655
  });
7634
- var findUniqueAuthenticationPlugin = ({ sdk }) => ({
7656
+ var findUniqueAuthenticationPlugin = (sdk) => ({
7635
7657
  findUniqueAuthentication: sdk.findUniqueConnection,
7636
7658
  context: {
7637
7659
  meta: {
@@ -7694,9 +7716,9 @@ var GetInputFieldsSchemaSchemaDeprecated = z.object({
7694
7716
  var GetInputFieldsSchemaInputSchema = z.union([GetInputFieldsSchemaSchema, GetInputFieldsSchemaSchemaDeprecated]).describe(GetInputFieldsSchemaDescription);
7695
7717
 
7696
7718
  // src/plugins/getInputFieldsSchema/index.ts
7697
- var getInputFieldsSchemaPlugin = ({ sdk, context }) => {
7719
+ var getInputFieldsSchemaPlugin = (sdk) => {
7698
7720
  async function getInputFieldsSchema(options) {
7699
- const { api, getVersionedImplementationId } = context;
7721
+ const { api, getVersionedImplementationId } = sdk.context;
7700
7722
  const appKey = "app" in options ? options.app : options.appKey;
7701
7723
  const actionKey = "action" in options ? options.action : options.actionKey;
7702
7724
  const { actionType, connection, connectionId, authenticationId, inputs } = options;
@@ -7704,7 +7726,7 @@ var getInputFieldsSchemaPlugin = ({ sdk, context }) => {
7704
7726
  connection,
7705
7727
  connectionId,
7706
7728
  authenticationId,
7707
- resolveConnection: context.resolveConnection
7729
+ resolveConnection: sdk.context.resolveConnection
7708
7730
  });
7709
7731
  const selectedApi = await getVersionedImplementationId(appKey);
7710
7732
  if (!selectedApi) {
@@ -7739,7 +7761,7 @@ var getInputFieldsSchemaPlugin = ({ sdk, context }) => {
7739
7761
  getInputFieldsSchema,
7740
7762
  GetInputFieldsSchemaInputSchema,
7741
7763
  createTelemetryCallback(
7742
- context.eventEmission.emitMethodCalled,
7764
+ sdk.context.eventEmission.emitMethodCalled,
7743
7765
  getInputFieldsSchema.name
7744
7766
  )
7745
7767
  );
@@ -7833,9 +7855,9 @@ function transformNeedChoicesToInputFieldChoiceItem(choice) {
7833
7855
  value: choice.value
7834
7856
  };
7835
7857
  }
7836
- var listInputFieldChoicesPlugin = ({ context, sdk }) => {
7858
+ var listInputFieldChoicesPlugin = (sdk) => {
7837
7859
  async function listInputFieldChoicesPage(options) {
7838
- const { api, getVersionedImplementationId } = context;
7860
+ const { api, getVersionedImplementationId } = sdk.context;
7839
7861
  const appKey = "app" in options ? options.app : options.appKey;
7840
7862
  const actionKey = "action" in options ? options.action : options.actionKey;
7841
7863
  const inputFieldKey = "inputField" in options ? options.inputField : options.inputFieldKey;
@@ -7852,7 +7874,7 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
7852
7874
  connection,
7853
7875
  connectionId,
7854
7876
  authenticationId,
7855
- resolveConnection: context.resolveConnection
7877
+ resolveConnection: sdk.context.resolveConnection
7856
7878
  });
7857
7879
  const selectedApi = await getVersionedImplementationId(appKey);
7858
7880
  if (!selectedApi) {
@@ -7930,7 +7952,10 @@ var listInputFieldChoicesPlugin = ({ context, sdk }) => {
7930
7952
  const listInputFieldChoicesDefinition = createPaginatedFunction(
7931
7953
  listInputFieldChoicesPage,
7932
7954
  ListInputFieldChoicesInputSchema,
7933
- createTelemetryCallback(context.eventEmission.emitMethodCalled, methodName),
7955
+ createTelemetryCallback(
7956
+ sdk.context.eventEmission.emitMethodCalled,
7957
+ methodName
7958
+ ),
7934
7959
  methodName,
7935
7960
  DEFAULT_PAGE_SIZE
7936
7961
  );
@@ -8302,19 +8327,20 @@ function getTransportConfig(options) {
8302
8327
  endpoint
8303
8328
  };
8304
8329
  }
8305
- var eventEmissionPlugin = ({ context }) => {
8330
+ var eventEmissionPlugin = (sdk) => {
8331
+ const options = sdk.context.options ?? {};
8306
8332
  const defaultTransport = getTransportConfig({
8307
- trackingBaseUrl: context.options.trackingBaseUrl,
8308
- baseUrl: context.options.baseUrl
8333
+ trackingBaseUrl: options.trackingBaseUrl,
8334
+ baseUrl: options.baseUrl
8309
8335
  });
8310
8336
  const config = {
8311
- enabled: context.options.eventEmission?.enabled ?? true,
8312
- callContext: context.options.eventEmission?.callContext,
8337
+ enabled: options.eventEmission?.enabled ?? true,
8338
+ callContext: options.eventEmission?.callContext,
8313
8339
  transport: (
8314
8340
  // If env var is set, use it (defaultTransport will be from env)
8315
8341
  globalThis.process?.env?.ZAPIER_SDK_TELEMETRY_TRANSPORT ? defaultTransport : (
8316
8342
  // Otherwise, use option transport or default
8317
- context.options.eventEmission?.transport ?? defaultTransport
8343
+ options.eventEmission?.transport ?? defaultTransport
8318
8344
  )
8319
8345
  )
8320
8346
  };
@@ -8322,7 +8348,7 @@ var eventEmissionPlugin = ({ context }) => {
8322
8348
  if (config.enabled) {
8323
8349
  try {
8324
8350
  const token = await resolveAuthToken({
8325
- ...context.options
8351
+ ...options
8326
8352
  });
8327
8353
  if (token) {
8328
8354
  return extractUserIdsFromJwt(token);
@@ -8572,55 +8598,54 @@ var eventEmissionPlugin = ({ context }) => {
8572
8598
  };
8573
8599
 
8574
8600
  // src/sdk.ts
8575
- function createSdk(options = {}, initialSdk = {}, initialContext = { meta: {} }) {
8601
+ function createOptionsPlugin(options) {
8602
+ return () => ({ context: { options } });
8603
+ }
8604
+ function createSdk() {
8605
+ return buildSdk({}, { meta: {} });
8606
+ }
8607
+ function buildSdk(properties, context) {
8608
+ const frozenContext = Object.freeze(context);
8576
8609
  return {
8577
- ...initialSdk,
8578
- getContext: () => initialContext,
8579
- addPlugin(plugin, addPluginOptions = {}) {
8580
- const currentSdkWithContext = {
8581
- ...initialSdk,
8582
- getContext: () => initialContext
8583
- };
8610
+ ...properties,
8611
+ get context() {
8612
+ return frozenContext;
8613
+ },
8614
+ getContext: () => frozenContext,
8615
+ // runtime compat shim, not in types
8616
+ addPlugin(plugin) {
8584
8617
  const pluginResult = plugin({
8585
- sdk: currentSdkWithContext,
8586
- context: {
8587
- ...initialContext,
8588
- // Add the options that createSdk was called with to context
8589
- options
8590
- },
8591
- ...addPluginOptions
8618
+ ...properties,
8619
+ context: frozenContext
8592
8620
  });
8593
- const { context: pluginContext, ...sdkProperties } = pluginResult;
8594
- const newSdk = { ...initialSdk, ...sdkProperties };
8595
- let newContext = {
8596
- ...initialContext,
8597
- ...addPluginOptions,
8598
- meta: initialContext.meta || {}
8621
+ const { context: pluginContext, ...pluginProperties } = pluginResult;
8622
+ const mergedProperties = { ...properties, ...pluginProperties };
8623
+ let mergedContext = {
8624
+ ...context,
8625
+ meta: context.meta || {}
8599
8626
  };
8600
8627
  if (pluginContext) {
8601
- const { meta: pluginMeta, ...otherPluginContext } = pluginContext;
8602
- newContext = {
8603
- ...newContext,
8604
- ...otherPluginContext
8628
+ const { meta: pluginMeta, ...pluginContextRest } = pluginContext;
8629
+ mergedContext = {
8630
+ ...mergedContext,
8631
+ ...pluginContextRest
8605
8632
  };
8606
8633
  if (pluginMeta) {
8607
- newContext = {
8608
- ...newContext,
8609
- meta: {
8610
- ...newContext.meta,
8611
- // Existing meta (now guaranteed to exist)
8612
- ...pluginMeta
8613
- // New meta from plugin
8614
- }
8634
+ mergedContext = {
8635
+ ...mergedContext,
8636
+ meta: { ...mergedContext.meta, ...pluginMeta }
8615
8637
  };
8616
8638
  }
8617
8639
  }
8618
- return createSdk(options, newSdk, newContext);
8640
+ return buildSdk(
8641
+ mergedProperties,
8642
+ mergedContext
8643
+ );
8619
8644
  }
8620
8645
  };
8621
8646
  }
8622
8647
  function createZapierSdkWithoutRegistry(options = {}) {
8623
- return createSdk(options).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(capabilitiesPlugin).addPlugin(connectionsPlugin).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);
8648
+ return createSdk().addPlugin(createOptionsPlugin(options)).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(capabilitiesPlugin).addPlugin(connectionsPlugin).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);
8624
8649
  }
8625
8650
  function createZapierSdk(options = {}) {
8626
8651
  return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
@@ -8657,4 +8682,4 @@ var BaseSdkOptionsSchema = z.object({
8657
8682
  // Use credentials instead
8658
8683
  });
8659
8684
 
8660
- export { ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_PAGE_SIZE, DebugPropertySchema, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, TablePropertySchema, TablesPropertySchema, ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createFunction, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, updateTableRecordsPlugin };
8685
+ export { ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MS, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MS, DEFAULT_CONFIG_PATH, DEFAULT_PAGE_SIZE, DebugPropertySchema, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LimitPropertySchema, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, TablePropertySchema, TablesPropertySchema, ZAPIER_BASE_URL, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MS, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierResourceNotFoundError, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, appKeyResolver, appsPlugin, connectionIdGenericResolver as authenticationIdGenericResolver, connectionIdResolver as authenticationIdResolver, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, createBaseEvent, createClientCredentialsPlugin, createFunction, createOptionsPlugin, createSdk, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionPlugin, getAppPlugin, getBaseUrlFromCredentials, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPkceCredentials, isPositional, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listInputFieldsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, runActionPlugin, runWithTelemetryContext, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, toSnakeCase, toTitleCase, updateTableRecordsPlugin };