@zapier/zapier-sdk 0.13.9 → 0.15.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 (31) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/api/client.d.ts.map +1 -1
  3. package/dist/api/client.js +45 -22
  4. package/dist/index.cjs +210 -123
  5. package/dist/index.mjs +210 -123
  6. package/dist/plugins/getAuthentication/index.js +1 -1
  7. package/dist/plugins/getAuthentication/index.test.js +1 -1
  8. package/dist/plugins/getProfile/index.d.ts.map +1 -1
  9. package/dist/plugins/getProfile/index.js +1 -1
  10. package/dist/plugins/listActions/index.js +1 -1
  11. package/dist/plugins/listActions/index.test.js +1 -1
  12. package/dist/plugins/listApps/index.js +2 -2
  13. package/dist/plugins/listApps/index.test.js +1 -1
  14. package/dist/plugins/listAuthentications/index.js +1 -1
  15. package/dist/plugins/listAuthentications/index.test.js +13 -13
  16. package/dist/plugins/listInputFieldChoices/index.d.ts +3 -1
  17. package/dist/plugins/listInputFieldChoices/index.d.ts.map +1 -1
  18. package/dist/plugins/listInputFieldChoices/index.js +42 -21
  19. package/dist/plugins/listInputFieldChoices/index.test.js +188 -11
  20. package/dist/plugins/listInputFields/index.d.ts.map +1 -1
  21. package/dist/plugins/listInputFields/index.js +11 -16
  22. package/dist/plugins/listInputFields/index.test.js +8 -6
  23. package/dist/plugins/manifest/index.js +2 -2
  24. package/dist/plugins/manifest/index.test.js +3 -3
  25. package/dist/plugins/runAction/index.js +2 -2
  26. package/dist/plugins/runAction/index.test.js +4 -4
  27. package/dist/sdk.test.js +1 -1
  28. package/dist/services/implementations.d.ts +63 -0
  29. package/dist/services/implementations.d.ts.map +1 -0
  30. package/dist/services/implementations.js +79 -0
  31. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1273,7 +1273,7 @@ var listAppsPlugin = ({ context }) => {
1273
1273
  const searchParams2 = {};
1274
1274
  searchParams2.term = options.search;
1275
1275
  const searchEnvelope = await api.get(
1276
- "/api/v4/implementations-meta/search/",
1276
+ "/zapier/api/v4/implementations-meta/search/",
1277
1277
  {
1278
1278
  searchParams: searchParams2
1279
1279
  }
@@ -1313,7 +1313,7 @@ var listAppsPlugin = ({ context }) => {
1313
1313
  };
1314
1314
  }
1315
1315
  const implementationsEnvelope = await api.get(
1316
- "/api/v4/implementations-meta/lookup/",
1316
+ "/zapier/api/v4/implementations-meta/lookup/",
1317
1317
  {
1318
1318
  searchParams
1319
1319
  }
@@ -1599,7 +1599,7 @@ var listActionsPlugin = ({ context }) => {
1599
1599
  selected_apis: selectedApi
1600
1600
  };
1601
1601
  const data = await api.get(
1602
- "/api/v4/implementations/",
1602
+ "/zapier/api/v4/implementations/",
1603
1603
  {
1604
1604
  searchParams,
1605
1605
  customErrorHandler: ({ status }) => {
@@ -1790,6 +1790,64 @@ var RootFieldItemSchema = z.union([
1790
1790
  FieldsetItemSchema
1791
1791
  ]);
1792
1792
 
1793
+ // src/services/implementations.ts
1794
+ async function fetchImplementationNeeds({
1795
+ api,
1796
+ selectedApi,
1797
+ action,
1798
+ actionType,
1799
+ authenticationId,
1800
+ inputs
1801
+ }) {
1802
+ const request = {
1803
+ selected_api: selectedApi,
1804
+ action,
1805
+ type_of: actionType,
1806
+ params: inputs || {}
1807
+ };
1808
+ if (authenticationId !== null) {
1809
+ request.authentication_id = authenticationId;
1810
+ }
1811
+ const response = await api.post(
1812
+ "/zapier/api/v4/implementations/needs/",
1813
+ request
1814
+ );
1815
+ if (!response.success) {
1816
+ throw new ZapierApiError(
1817
+ `Failed to get input fields: ${response.errors?.join(", ") || "Unknown error"}`
1818
+ );
1819
+ }
1820
+ return response;
1821
+ }
1822
+ async function fetchImplementationChoices({
1823
+ api,
1824
+ actionId,
1825
+ inputFieldId,
1826
+ authenticationId,
1827
+ inputs,
1828
+ page
1829
+ }) {
1830
+ const request = {
1831
+ action_id: actionId,
1832
+ input_field_id: inputFieldId,
1833
+ page,
1834
+ params: inputs || {}
1835
+ };
1836
+ if (authenticationId !== null) {
1837
+ request.authentication_id = authenticationId;
1838
+ }
1839
+ const response = await api.post(
1840
+ "/zapier/api/v4/implementations/choices/",
1841
+ request
1842
+ );
1843
+ if (!response.success) {
1844
+ throw new ZapierApiError(
1845
+ `Failed to get input field choices: ${response.errors?.join(", ") || "Unknown error"}`
1846
+ );
1847
+ }
1848
+ return response;
1849
+ }
1850
+
1793
1851
  // src/plugins/listInputFields/index.ts
1794
1852
  function getInputFieldTypeFromNeed(need) {
1795
1853
  if (need.list) {
@@ -1893,7 +1951,13 @@ var listInputFieldsPlugin = ({ sdk, context }) => {
1893
1951
  const listInputFields = createPaginatedFunction(
1894
1952
  async function listInputFieldsPage(options) {
1895
1953
  const { api, getVersionedImplementationId } = context;
1896
- const { appKey, actionKey, actionType, authenticationId, inputs } = options;
1954
+ const {
1955
+ appKey,
1956
+ actionKey,
1957
+ actionType,
1958
+ authenticationId = null,
1959
+ inputs
1960
+ } = options;
1897
1961
  const selectedApi = await getVersionedImplementationId(appKey);
1898
1962
  if (!selectedApi) {
1899
1963
  throw new ZapierConfigurationError(
@@ -1906,24 +1970,14 @@ var listInputFieldsPlugin = ({ sdk, context }) => {
1906
1970
  actionType,
1907
1971
  actionKey
1908
1972
  });
1909
- const needsRequest = {
1910
- selected_api: selectedApi,
1973
+ const needsData = await fetchImplementationNeeds({
1974
+ api,
1975
+ selectedApi,
1911
1976
  action: action.key,
1912
- type_of: actionType,
1913
- params: inputs || {}
1914
- };
1915
- if (authenticationId !== null) {
1916
- needsRequest.authentication_id = authenticationId;
1917
- }
1918
- const needsData = await api.post(
1919
- "/api/v4/implementations/needs/",
1920
- needsRequest
1921
- );
1922
- if (!needsData.success) {
1923
- throw new ZapierApiError(
1924
- `Failed to get action fields: ${needsData.errors?.join(", ") || "Unknown error"}`
1925
- );
1926
- }
1977
+ actionType,
1978
+ authenticationId,
1979
+ inputs
1980
+ });
1927
1981
  const rootFieldset = transformNeedsToFields(needsData.needs || []);
1928
1982
  return {
1929
1983
  data: rootFieldset,
@@ -2048,7 +2102,7 @@ var listAuthenticationsPlugin = ({ context }) => {
2048
2102
  searchParams.offset = options.cursor;
2049
2103
  }
2050
2104
  const data = await api.get(
2051
- "/api/v4/authentications/",
2105
+ "/zapier/api/v4/authentications/",
2052
2106
  {
2053
2107
  searchParams,
2054
2108
  customErrorHandler: ({ status }) => {
@@ -2188,7 +2242,7 @@ var getAuthenticationPlugin = ({ context }) => {
2188
2242
  const { api } = context;
2189
2243
  const { authenticationId } = options;
2190
2244
  const data = await api.get(
2191
- `/api/v4/authentications/${authenticationId}/`,
2245
+ `/zapier/api/v4/authentications/${authenticationId}/`,
2192
2246
  {
2193
2247
  customErrorHandler: ({ status }) => {
2194
2248
  if (status === 401) {
@@ -2381,11 +2435,11 @@ async function executeAction(actionOptions) {
2381
2435
  data: runRequestData
2382
2436
  };
2383
2437
  const runData = await api.post(
2384
- "/api/actions/v1/runs",
2438
+ "/zapier/api/actions/v1/runs",
2385
2439
  runRequest
2386
2440
  );
2387
2441
  const runId = runData.data.id;
2388
- return await api.poll(`/api/actions/v1/runs/${runId}`, {
2442
+ return await api.poll(`/zapier/api/actions/v1/runs/${runId}`, {
2389
2443
  successStatus: 200,
2390
2444
  pendingStatus: 202,
2391
2445
  resultExtractor: (result) => result.data
@@ -2666,7 +2720,7 @@ async function getPreferredManifestEntryKey({
2666
2720
  }
2667
2721
  if (locator.implementationName) {
2668
2722
  try {
2669
- const implementationsEnvelope = await api.get(`/api/v4/implementations-meta/lookup/`, {
2723
+ const implementationsEnvelope = await api.get(`/zapier/api/v4/implementations-meta/lookup/`, {
2670
2724
  searchParams: {
2671
2725
  selected_apis: locator.implementationName
2672
2726
  }
@@ -2693,7 +2747,7 @@ async function listAppsForSlugsPage({
2693
2747
  searchParams.offset = cursor;
2694
2748
  }
2695
2749
  const implementationsEnvelope = await api.get(
2696
- "/api/v4/implementations-meta/lookup/",
2750
+ "/zapier/api/v4/implementations-meta/lookup/",
2697
2751
  {
2698
2752
  searchParams
2699
2753
  }
@@ -2932,9 +2986,12 @@ var UserProfileItemSchema = withFormatter(
2932
2986
  // src/plugins/getProfile/index.ts
2933
2987
  var getProfilePlugin = ({ context }) => {
2934
2988
  const getProfile = createFunction(async function getProfile2() {
2935
- const profile = await context.api.get("/api/v4/profile/", {
2936
- authRequired: true
2937
- });
2989
+ const profile = await context.api.get(
2990
+ "/zapier/api/v4/profile/",
2991
+ {
2992
+ authRequired: true
2993
+ }
2994
+ );
2938
2995
  const { user_id: _unusedUserId, ...data } = profile;
2939
2996
  return {
2940
2997
  data: {
@@ -3261,11 +3318,63 @@ async function getTokenFromEnvOrConfig(options = {}) {
3261
3318
  return getTokenFromCliLogin(options);
3262
3319
  }
3263
3320
 
3321
+ // src/utils/url-utils.ts
3322
+ function getZapierBaseUrl(baseUrl) {
3323
+ if (!baseUrl) {
3324
+ return void 0;
3325
+ }
3326
+ try {
3327
+ const url = new URL(baseUrl);
3328
+ const hostname = url.hostname;
3329
+ const hostParts = hostname.split(".");
3330
+ if (hostParts.length < 2) {
3331
+ return void 0;
3332
+ }
3333
+ const hasZapierPart = hostParts.some(
3334
+ (part) => part === "zapier" || part.startsWith("zapier-")
3335
+ );
3336
+ if (!hasZapierPart) {
3337
+ return void 0;
3338
+ }
3339
+ const rootDomain = hostParts.slice(-2).join(".");
3340
+ return `${url.protocol}//${rootDomain}`;
3341
+ } catch {
3342
+ return void 0;
3343
+ }
3344
+ }
3345
+ function getTrackingBaseUrl({
3346
+ trackingBaseUrl,
3347
+ baseUrl
3348
+ }) {
3349
+ if (trackingBaseUrl) {
3350
+ return trackingBaseUrl;
3351
+ }
3352
+ if (process.env.ZAPIER_TRACKING_BASE_URL) {
3353
+ return process.env.ZAPIER_TRACKING_BASE_URL;
3354
+ }
3355
+ if (baseUrl) {
3356
+ const zapierBaseUrl = getZapierBaseUrl(baseUrl);
3357
+ if (zapierBaseUrl) {
3358
+ return zapierBaseUrl;
3359
+ }
3360
+ }
3361
+ if (baseUrl) {
3362
+ return baseUrl;
3363
+ }
3364
+ return ZAPIER_BASE_URL;
3365
+ }
3366
+
3264
3367
  // src/api/client.ts
3265
- var SubdomainConfigMap = {
3266
- // e.g. https://relay.zapier.com
3267
- relay: {
3268
- authHeader: "X-Relay-Authorization"
3368
+ var pathConfig = {
3369
+ // e.g. /relay -> https://sdkapi.zapier.com/api/v0/sdk/relay/...
3370
+ "/relay": {
3371
+ authHeader: "X-Relay-Authorization",
3372
+ pathPrefix: "/api/v0/sdk/relay"
3373
+ },
3374
+ // e.g. /zapier -> https://sdkapi.zapier.com/api/v0/sdk/zapier/...
3375
+ "/zapier": {
3376
+ authHeader: "Authorization",
3377
+ pathPrefix: "/api/v0/sdk/zapier"
3269
3378
  }
3270
3379
  };
3271
3380
  var ZapierApiClient = class {
@@ -3454,39 +3563,47 @@ var ZapierApiClient = class {
3454
3563
  return { message: fallbackMessage };
3455
3564
  }
3456
3565
  }
3457
- // Check if this is a path that needs subdomain routing
3458
- // e.g. /relay/workflows -> relay.zapier.com/workflows
3459
- applySubdomainBehavior(path) {
3460
- const pathSegments = path.split("/").filter(Boolean);
3461
- if (pathSegments.length > 0 && pathSegments[0] in SubdomainConfigMap) {
3462
- const domainPrefix = pathSegments[0];
3463
- const subdomainConfig = SubdomainConfigMap[domainPrefix];
3566
+ // Apply any special routing logic for configured paths.
3567
+ applyPathConfiguration(path) {
3568
+ const matchingPathKey = Object.keys(pathConfig).find(
3569
+ (configPath) => path === configPath || path.startsWith(configPath + "/")
3570
+ );
3571
+ const config = matchingPathKey ? pathConfig[matchingPathKey] : void 0;
3572
+ const zapierBaseUrl = getZapierBaseUrl(this.options.baseUrl);
3573
+ if (zapierBaseUrl === this.options.baseUrl) {
3464
3574
  const originalBaseUrl = new URL(this.options.baseUrl);
3465
- const finalBaseUrl = `https://${domainPrefix}.${originalBaseUrl.hostname}`;
3466
- const pathWithoutPrefix = "/" + pathSegments.slice(1).join("/");
3467
- return { url: new URL(pathWithoutPrefix, finalBaseUrl), subdomainConfig };
3575
+ const finalBaseUrl = `https://sdkapi.${originalBaseUrl.hostname}`;
3576
+ let finalPath = path;
3577
+ if (config && "pathPrefix" in config && config.pathPrefix && matchingPathKey) {
3578
+ const pathWithoutPrefix = path.slice(matchingPathKey.length) || "/";
3579
+ finalPath = `${config.pathPrefix}${pathWithoutPrefix}`;
3580
+ }
3581
+ return {
3582
+ url: new URL(finalPath, finalBaseUrl),
3583
+ pathConfig: config
3584
+ };
3468
3585
  }
3469
3586
  return {
3470
3587
  url: new URL(path, this.options.baseUrl),
3471
- subdomainConfig: void 0
3588
+ pathConfig: config
3472
3589
  };
3473
3590
  }
3474
3591
  // Helper to build full URLs and return routing info
3475
3592
  buildUrl(path, searchParams) {
3476
- const { url, subdomainConfig } = this.applySubdomainBehavior(path);
3593
+ const { url, pathConfig: config } = this.applyPathConfiguration(path);
3477
3594
  if (searchParams) {
3478
3595
  Object.entries(searchParams).forEach(([key, value]) => {
3479
3596
  url.searchParams.set(key, value);
3480
3597
  });
3481
3598
  }
3482
- return { url: url.toString(), subdomainConfig };
3599
+ return { url: url.toString(), pathConfig: config };
3483
3600
  }
3484
3601
  // Helper to build headers
3485
- async buildHeaders(options = {}, subdomainConfig) {
3602
+ async buildHeaders(options = {}, pathConfig2) {
3486
3603
  const headers = new Headers(options.headers ?? {});
3487
3604
  const authToken = await this.getAuthToken();
3488
3605
  if (authToken) {
3489
- const authHeaderName = subdomainConfig?.authHeader || "Authorization";
3606
+ const authHeaderName = pathConfig2?.authHeader || "Authorization";
3490
3607
  headers.set(authHeaderName, getAuthorizationHeader(authToken));
3491
3608
  }
3492
3609
  if (options.authRequired) {
@@ -3533,13 +3650,10 @@ var ZapierApiClient = class {
3533
3650
  if (fetchOptions?.body && typeof fetchOptions.body === "object") {
3534
3651
  fetchOptions.body = JSON.stringify(fetchOptions.body);
3535
3652
  }
3536
- const { url, subdomainConfig } = this.buildUrl(
3537
- path,
3538
- fetchOptions?.searchParams
3539
- );
3653
+ const { url, pathConfig: pathConfig2 } = this.buildUrl(path, fetchOptions?.searchParams);
3540
3654
  const builtHeaders = await this.buildHeaders(
3541
3655
  fetchOptions,
3542
- subdomainConfig
3656
+ pathConfig2
3543
3657
  );
3544
3658
  const inputHeaders = new Headers(fetchOptions?.headers ?? {});
3545
3659
  const mergedHeaders = new Headers();
@@ -3833,43 +3947,62 @@ function transformNeedChoicesToInputFieldChoiceItem(choice) {
3833
3947
  }
3834
3948
  var listInputFieldChoicesPlugin = ({ context, sdk }) => {
3835
3949
  const listInputFieldChoices = createPaginatedFunction(async function listInputFieldChoicesPage(options) {
3836
- const { api } = context;
3950
+ const { api, getVersionedImplementationId } = context;
3837
3951
  const {
3838
3952
  appKey,
3839
3953
  actionType,
3840
3954
  actionKey,
3841
3955
  inputFieldKey,
3842
- authenticationId,
3956
+ authenticationId = null,
3843
3957
  inputs,
3844
3958
  page,
3845
3959
  cursor
3846
3960
  } = options;
3847
- const actionResult = await sdk.getAction({ appKey, actionType, actionKey });
3848
- const actionId = actionResult.data.id;
3849
- if (!actionId) {
3850
- throw new ZapierApiError(
3851
- `Action ${actionKey} does not have an ID - cannot retrieve input field choices`
3961
+ const selectedApi = await getVersionedImplementationId(appKey);
3962
+ if (!selectedApi) {
3963
+ throw new ZapierConfigurationError(
3964
+ "No current_implementation_id found for app",
3965
+ { configType: "current_implementation_id" }
3852
3966
  );
3853
3967
  }
3854
- const requestPage = cursor ? parseInt(cursor, 10) : page ?? 0;
3855
- const choicesRequest = {
3856
- action_id: actionId,
3857
- input_field_id: inputFieldKey,
3858
- page: requestPage,
3859
- params: inputs || {}
3860
- };
3861
- if (authenticationId !== null) {
3862
- choicesRequest.authentication_id = authenticationId;
3863
- }
3864
- const choicesData = await api.post(
3865
- "/api/v4/implementations/choices/",
3866
- choicesRequest
3968
+ const { data: action } = await sdk.getAction({
3969
+ appKey,
3970
+ actionType,
3971
+ actionKey
3972
+ });
3973
+ const needsData = await fetchImplementationNeeds({
3974
+ api,
3975
+ selectedApi,
3976
+ action: action.key,
3977
+ actionType,
3978
+ authenticationId,
3979
+ inputs
3980
+ });
3981
+ const targetNeed = needsData.needs?.find(
3982
+ (need) => need.key === inputFieldKey
3867
3983
  );
3868
- if (!choicesData.success) {
3984
+ if (targetNeed?.choices && targetNeed.choices.length > 0) {
3985
+ return {
3986
+ data: targetNeed.choices.map(
3987
+ transformNeedChoicesToInputFieldChoiceItem
3988
+ ),
3989
+ nextCursor: void 0
3990
+ };
3991
+ }
3992
+ if (!action.id) {
3869
3993
  throw new ZapierApiError(
3870
- `Failed to get input field choices: ${choicesData.errors?.join(", ") || "Unknown error"}`
3994
+ `Action ${actionKey} does not have an ID - cannot retrieve input field choices`
3871
3995
  );
3872
3996
  }
3997
+ const requestPage = cursor ? parseInt(cursor, 10) : page ?? 0;
3998
+ const choicesData = await fetchImplementationChoices({
3999
+ api,
4000
+ actionId: action.id,
4001
+ inputFieldId: inputFieldKey,
4002
+ authenticationId,
4003
+ inputs,
4004
+ page: requestPage
4005
+ });
3873
4006
  const choices = (choicesData.choices || []).map(
3874
4007
  transformNeedChoicesToInputFieldChoiceItem
3875
4008
  );
@@ -4067,7 +4200,7 @@ function getCpuTime() {
4067
4200
 
4068
4201
  // package.json
4069
4202
  var package_default = {
4070
- version: "0.13.9"};
4203
+ version: "0.15.0"};
4071
4204
 
4072
4205
  // src/plugins/eventEmission/builders.ts
4073
4206
  function createBaseEvent(context = {}) {
@@ -4137,52 +4270,6 @@ function buildErrorEventWithContext(data, context = {}) {
4137
4270
  };
4138
4271
  }
4139
4272
 
4140
- // src/utils/url-utils.ts
4141
- function getZapierBaseUrl(baseUrl) {
4142
- if (!baseUrl) {
4143
- return void 0;
4144
- }
4145
- try {
4146
- const url = new URL(baseUrl);
4147
- const hostname = url.hostname;
4148
- const hostParts = hostname.split(".");
4149
- if (hostParts.length < 2) {
4150
- return void 0;
4151
- }
4152
- const hasZapierPart = hostParts.some(
4153
- (part) => part === "zapier" || part.startsWith("zapier-")
4154
- );
4155
- if (!hasZapierPart) {
4156
- return void 0;
4157
- }
4158
- const rootDomain = hostParts.slice(-2).join(".");
4159
- return `${url.protocol}//${rootDomain}`;
4160
- } catch {
4161
- return void 0;
4162
- }
4163
- }
4164
- function getTrackingBaseUrl({
4165
- trackingBaseUrl,
4166
- baseUrl
4167
- }) {
4168
- if (trackingBaseUrl) {
4169
- return trackingBaseUrl;
4170
- }
4171
- if (process.env.ZAPIER_TRACKING_BASE_URL) {
4172
- return process.env.ZAPIER_TRACKING_BASE_URL;
4173
- }
4174
- if (baseUrl) {
4175
- const zapierBaseUrl = getZapierBaseUrl(baseUrl);
4176
- if (zapierBaseUrl) {
4177
- return zapierBaseUrl;
4178
- }
4179
- }
4180
- if (baseUrl) {
4181
- return baseUrl;
4182
- }
4183
- return ZAPIER_BASE_URL;
4184
- }
4185
-
4186
4273
  // src/plugins/eventEmission/index.ts
4187
4274
  var APPLICATION_LIFECYCLE_EVENT_SUBJECT = "platform.sdk.ApplicationLifecycleEvent";
4188
4275
  var ERROR_OCCURRED_EVENT_SUBJECT = "platform.sdk.ErrorOccurredEvent";
@@ -8,7 +8,7 @@ export const getAuthenticationPlugin = ({ context }) => {
8
8
  const getAuthentication = createFunction(async function getAuthentication(options) {
9
9
  const { api } = context;
10
10
  const { authenticationId } = options;
11
- const data = await api.get(`/api/v4/authentications/${authenticationId}/`, {
11
+ const data = await api.get(`/zapier/api/v4/authentications/${authenticationId}/`, {
12
12
  customErrorHandler: ({ status }) => {
13
13
  if (status === 401) {
14
14
  return new ZapierAuthenticationError(`Authentication failed. Your token may not have permission to access authentications or may be expired. (HTTP ${status})`, { statusCode: status });
@@ -72,7 +72,7 @@ describe("getAuthentication plugin", () => {
72
72
  it("should call the correct API endpoint", async () => {
73
73
  const sdk = createTestSdk();
74
74
  await sdk.getAuthentication({ authenticationId: 123 });
75
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v4/authentications/123/", expect.objectContaining({
75
+ expect(mockApiClient.get).toHaveBeenCalledWith("/zapier/api/v4/authentications/123/", expect.objectContaining({
76
76
  authRequired: true,
77
77
  customErrorHandler: expect.any(Function),
78
78
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getProfile/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAI7C,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,CACV,OAAO,CAAC,EAAE,iBAAiB,KACxB,OAAO,CAAC;QAAE,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC,CAAC;IACxC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,UAAU,EAAE;gBACV,WAAW,EAAE,OAAO,gBAAgB,CAAC;aACtC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAGD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,EAAE,EAAE,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,wBAAwB,CAiCzB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getProfile/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAI7C,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,CACV,OAAO,CAAC,EAAE,iBAAiB,KACxB,OAAO,CAAC;QAAE,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC,CAAC;IACxC,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,UAAU,EAAE;gBACV,WAAW,EAAE,OAAO,gBAAgB,CAAC;aACtC,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAGD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CACnC,EAAE,EAAE,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAAE,0BAA0B;AAC9C,wBAAwB,CAoCzB,CAAC"}
@@ -4,7 +4,7 @@ import { UserProfileItemSchema } from "../../schemas/UserProfile";
4
4
  // Direct plugin function - takes options + sdk + context in one object
5
5
  export const getProfilePlugin = ({ context }) => {
6
6
  const getProfile = createFunction(async function getProfile() {
7
- const profile = await context.api.get("/api/v4/profile/", {
7
+ const profile = await context.api.get("/zapier/api/v4/profile/", {
8
8
  authRequired: true,
9
9
  });
10
10
  // Remove user_id since that's our internal user ID which could confuse things!
@@ -17,7 +17,7 @@ export const listActionsPlugin = ({ context }) => {
17
17
  public_only: "true",
18
18
  selected_apis: selectedApi,
19
19
  };
20
- const data = await api.get("/api/v4/implementations/", {
20
+ const data = await api.get("/zapier/api/v4/implementations/", {
21
21
  searchParams,
22
22
  customErrorHandler: ({ status }) => {
23
23
  if (status === 401) {
@@ -335,7 +335,7 @@ describe("listActions plugin", () => {
335
335
  it("should pass correct search parameters to implementations API", async () => {
336
336
  const sdk = createTestSdk();
337
337
  await sdk.listActions({ appKey: "slack" });
338
- expect(mockApiClient.get).toHaveBeenCalledWith("/api/v4/implementations/", expect.objectContaining({
338
+ expect(mockApiClient.get).toHaveBeenCalledWith("/zapier/api/v4/implementations/", expect.objectContaining({
339
339
  searchParams: expect.objectContaining({
340
340
  global: "true",
341
341
  public_only: "true",
@@ -28,7 +28,7 @@ export const listAppsPlugin = ({ context }) => {
28
28
  if (options.search) {
29
29
  const searchParams = {};
30
30
  searchParams.term = options.search;
31
- const searchEnvelope = await api.get("/api/v4/implementations-meta/search/", {
31
+ const searchEnvelope = await api.get("/zapier/api/v4/implementations-meta/search/", {
32
32
  searchParams,
33
33
  });
34
34
  const implementations = searchEnvelope.results.map(normalizeImplementationMetaToAppItem);
@@ -65,7 +65,7 @@ export const listAppsPlugin = ({ context }) => {
65
65
  nextCursor: undefined,
66
66
  };
67
67
  }
68
- const implementationsEnvelope = await api.get("/api/v4/implementations-meta/lookup/", {
68
+ const implementationsEnvelope = await api.get("/zapier/api/v4/implementations-meta/lookup/", {
69
69
  searchParams,
70
70
  });
71
71
  return {
@@ -103,7 +103,7 @@ describe("listApps plugin", () => {
103
103
  key: "SlackCLIAPI",
104
104
  title: "Slack",
105
105
  });
106
- expect(context.api.get).toHaveBeenCalledWith("/api/v4/implementations-meta/lookup/", {
106
+ expect(context.api.get).toHaveBeenCalledWith("/zapier/api/v4/implementations-meta/lookup/", {
107
107
  searchParams: {
108
108
  latest_only: "true",
109
109
  limit: "100",
@@ -41,7 +41,7 @@ export const listAuthenticationsPlugin = ({ context }) => {
41
41
  // Convert cursor back to offset for the API
42
42
  searchParams.offset = options.cursor;
43
43
  }
44
- const data = await api.get("/api/v4/authentications/", {
44
+ const data = await api.get("/zapier/api/v4/authentications/", {
45
45
  searchParams,
46
46
  customErrorHandler: ({ status }) => {
47
47
  if (status === 401) {