@zapier/zapier-sdk 0.14.0 → 0.15.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 (48) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +28 -0
  3. package/dist/api/client.d.ts.map +1 -1
  4. package/dist/api/client.js +45 -22
  5. package/dist/api/schemas.d.ts +3 -0
  6. package/dist/api/schemas.d.ts.map +1 -1
  7. package/dist/api/schemas.js +1 -0
  8. package/dist/index.cjs +181 -87
  9. package/dist/index.d.mts +47 -2
  10. package/dist/index.mjs +181 -87
  11. package/dist/plugins/getAuthentication/index.js +1 -1
  12. package/dist/plugins/getAuthentication/index.test.js +1 -1
  13. package/dist/plugins/getInputFieldsSchema/index.d.ts +22 -0
  14. package/dist/plugins/getInputFieldsSchema/index.d.ts.map +1 -0
  15. package/dist/plugins/getInputFieldsSchema/index.js +51 -0
  16. package/dist/plugins/getInputFieldsSchema/index.test.d.ts +2 -0
  17. package/dist/plugins/getInputFieldsSchema/index.test.d.ts.map +1 -0
  18. package/dist/plugins/getInputFieldsSchema/index.test.js +288 -0
  19. package/dist/plugins/getInputFieldsSchema/schemas.d.ts +31 -0
  20. package/dist/plugins/getInputFieldsSchema/schemas.d.ts.map +1 -0
  21. package/dist/plugins/getInputFieldsSchema/schemas.js +13 -0
  22. package/dist/plugins/getProfile/index.d.ts.map +1 -1
  23. package/dist/plugins/getProfile/index.js +1 -1
  24. package/dist/plugins/listActions/index.js +1 -1
  25. package/dist/plugins/listActions/index.test.js +1 -1
  26. package/dist/plugins/listApps/index.js +2 -2
  27. package/dist/plugins/listApps/index.test.js +1 -1
  28. package/dist/plugins/listAuthentications/index.js +1 -1
  29. package/dist/plugins/listAuthentications/index.test.js +13 -13
  30. package/dist/plugins/listInputFieldChoices/index.test.js +19 -19
  31. package/dist/plugins/listInputFields/index.d.ts.map +1 -1
  32. package/dist/plugins/listInputFields/index.js +2 -0
  33. package/dist/plugins/listInputFields/index.test.js +4 -4
  34. package/dist/plugins/manifest/index.js +2 -2
  35. package/dist/plugins/manifest/index.test.js +3 -3
  36. package/dist/plugins/runAction/index.js +2 -2
  37. package/dist/plugins/runAction/index.test.js +4 -4
  38. package/dist/sdk.d.ts +7 -1
  39. package/dist/sdk.d.ts.map +1 -1
  40. package/dist/sdk.js +2 -0
  41. package/dist/sdk.test.js +1 -1
  42. package/dist/services/implementations.js +2 -2
  43. package/dist/temporary-internal-core/index.d.ts +14 -0
  44. package/dist/temporary-internal-core/index.d.ts.map +1 -0
  45. package/dist/temporary-internal-core/index.js +14 -0
  46. package/dist/types/sdk.d.ts +2 -1
  47. package/dist/types/sdk.d.ts.map +1 -1
  48. package/package.json +1 -1
package/dist/index.d.mts CHANGED
@@ -1157,6 +1157,7 @@ declare const NeedsResponseSchema: z.ZodObject<{
1157
1157
  }>, "many">>;
1158
1158
  errors: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1159
1159
  last_fetched_at: z.ZodOptional<z.ZodString>;
1160
+ schema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1160
1161
  }, "strip", z.ZodTypeAny, {
1161
1162
  success: boolean;
1162
1163
  needs?: {
@@ -1193,6 +1194,7 @@ declare const NeedsResponseSchema: z.ZodObject<{
1193
1194
  }[] | undefined;
1194
1195
  errors?: string[] | undefined;
1195
1196
  last_fetched_at?: string | undefined;
1197
+ schema?: Record<string, unknown> | undefined;
1196
1198
  }, {
1197
1199
  success: boolean;
1198
1200
  needs?: {
@@ -1229,6 +1231,7 @@ declare const NeedsResponseSchema: z.ZodObject<{
1229
1231
  }[] | undefined;
1230
1232
  errors?: string[] | undefined;
1231
1233
  last_fetched_at?: string | undefined;
1234
+ schema?: Record<string, unknown> | undefined;
1232
1235
  }>;
1233
1236
 
1234
1237
  /**
@@ -2184,6 +2187,42 @@ declare const listInputFieldsPlugin: Plugin<GetSdkType<GetAppPluginProvides & Ge
2184
2187
  }, // requires api and getVersionedImplementationId in context
2185
2188
  ListInputFieldsPluginProvides>;
2186
2189
 
2190
+ declare const GetInputFieldsSchemaSchema: z.ZodObject<{
2191
+ appKey: z.ZodString & {
2192
+ _def: z.ZodStringDef & PositionalMetadata;
2193
+ };
2194
+ actionType: z.ZodEnum<["read", "read_bulk", "write", "run", "search", "search_or_write", "search_and_write", "filter"]>;
2195
+ actionKey: z.ZodString;
2196
+ authenticationId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
2197
+ inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
2198
+ }, "strip", z.ZodTypeAny, {
2199
+ appKey: string;
2200
+ actionType: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
2201
+ actionKey: string;
2202
+ authenticationId?: number | null | undefined;
2203
+ inputs?: Record<string, unknown> | undefined;
2204
+ }, {
2205
+ appKey: string;
2206
+ actionType: "search" | "filter" | "read" | "read_bulk" | "run" | "search_and_write" | "search_or_write" | "write";
2207
+ actionKey: string;
2208
+ authenticationId?: number | null | undefined;
2209
+ inputs?: Record<string, unknown> | undefined;
2210
+ }>;
2211
+ type GetInputFieldsSchemaOptions = z.infer<typeof GetInputFieldsSchemaSchema>;
2212
+
2213
+ interface GetInputFieldsSchemaPluginProvides {
2214
+ getInputFieldsSchema: (options: GetInputFieldsSchemaOptions) => Promise<{
2215
+ data: Record<string, unknown>;
2216
+ }>;
2217
+ context: {
2218
+ meta: {
2219
+ getInputFieldsSchema: {
2220
+ inputSchema: typeof GetInputFieldsSchemaSchema;
2221
+ };
2222
+ };
2223
+ };
2224
+ }
2225
+
2187
2226
  declare const InputFieldChoiceItemSchema: z.ZodObject<{
2188
2227
  key: z.ZodOptional<z.ZodString>;
2189
2228
  label: z.ZodOptional<z.ZodString>;
@@ -2292,7 +2331,7 @@ interface FunctionRegistryEntry {
2292
2331
  resolvers?: Record<string, any>;
2293
2332
  packages?: string[];
2294
2333
  }
2295
- interface ZapierSdk extends GetSdkType<RegistryPluginProvides & FetchPluginProvides & AppsPluginProvides & ListAppsPluginProvides & ManifestPluginProvides & GetAppPluginProvides & ListActionsPluginProvides & GetActionPluginProvides & RunActionPluginProvides & ListAuthenticationsPluginProvides & GetAuthenticationPluginProvides & FindFirstAuthenticationPluginProvides & FindUniqueAuthenticationPluginProvides & ListInputFieldsPluginProvides & ListInputFieldChoicesPluginProvides & RequestPluginProvides & GetProfilePluginProvides & EventEmissionProvides & ApiPluginProvides> {
2334
+ interface ZapierSdk extends GetSdkType<RegistryPluginProvides & FetchPluginProvides & AppsPluginProvides & ListAppsPluginProvides & ManifestPluginProvides & GetAppPluginProvides & ListActionsPluginProvides & GetActionPluginProvides & RunActionPluginProvides & ListAuthenticationsPluginProvides & GetAuthenticationPluginProvides & FindFirstAuthenticationPluginProvides & FindUniqueAuthenticationPluginProvides & ListInputFieldsPluginProvides & GetInputFieldsSchemaPluginProvides & ListInputFieldChoicesPluginProvides & RequestPluginProvides & GetProfilePluginProvides & EventEmissionProvides & ApiPluginProvides> {
2296
2335
  apps: ActionProxy & ZapierSdkApps;
2297
2336
  }
2298
2337
 
@@ -3317,7 +3356,7 @@ declare function createSdk<TCurrentSdk = {}, TCurrentContext extends {
3317
3356
  getContext(): TCurrentContext;
3318
3357
  }, TRequiresContext, TProvides>, addPluginOptions?: Record<string, unknown>): Sdk<TCurrentSdk & ExtractSdkProperties<TProvides>, TCurrentContext & NonNullable<ExtractContextProperties<TProvides>>>;
3319
3358
  };
3320
- declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk<ExtractSdkProperties<EventEmissionProvides> & ExtractSdkProperties<ApiPluginProvides> & ExtractSdkProperties<ManifestPluginProvides> & ExtractSdkProperties<ListAppsPluginProvides> & ExtractSdkProperties<GetAppPluginProvides> & ExtractSdkProperties<ListActionsPluginProvides> & ExtractSdkProperties<GetActionPluginProvides> & ExtractSdkProperties<ListInputFieldsPluginProvides> & ExtractSdkProperties<ListInputFieldChoicesPluginProvides> & ExtractSdkProperties<RunActionPluginProvides> & ExtractSdkProperties<ListAuthenticationsPluginProvides> & ExtractSdkProperties<GetAuthenticationPluginProvides> & ExtractSdkProperties<FindFirstAuthenticationPluginProvides> & ExtractSdkProperties<FindUniqueAuthenticationPluginProvides> & ExtractSdkProperties<RequestPluginProvides> & ExtractSdkProperties<FetchPluginProvides> & ExtractSdkProperties<AppsPluginProvides> & ExtractSdkProperties<GetProfilePluginProvides>, {
3359
+ declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk<ExtractSdkProperties<EventEmissionProvides> & ExtractSdkProperties<ApiPluginProvides> & ExtractSdkProperties<ManifestPluginProvides> & ExtractSdkProperties<ListAppsPluginProvides> & ExtractSdkProperties<GetAppPluginProvides> & ExtractSdkProperties<ListActionsPluginProvides> & ExtractSdkProperties<GetActionPluginProvides> & ExtractSdkProperties<ListInputFieldsPluginProvides> & ExtractSdkProperties<GetInputFieldsSchemaPluginProvides> & ExtractSdkProperties<ListInputFieldChoicesPluginProvides> & ExtractSdkProperties<RunActionPluginProvides> & ExtractSdkProperties<ListAuthenticationsPluginProvides> & ExtractSdkProperties<GetAuthenticationPluginProvides> & ExtractSdkProperties<FindFirstAuthenticationPluginProvides> & ExtractSdkProperties<FindUniqueAuthenticationPluginProvides> & ExtractSdkProperties<RequestPluginProvides> & ExtractSdkProperties<FetchPluginProvides> & ExtractSdkProperties<AppsPluginProvides> & ExtractSdkProperties<GetProfilePluginProvides>, {
3321
3360
  meta: Record<string, PluginMeta>;
3322
3361
  } & EventEmissionContext & {
3323
3362
  api: ApiClient;
@@ -3355,6 +3394,12 @@ declare function createZapierSdkWithoutRegistry(options?: ZapierSdkOptions): Sdk
3355
3394
  inputSchema: typeof ListInputFieldsSchema;
3356
3395
  };
3357
3396
  };
3397
+ } & {
3398
+ meta: {
3399
+ getInputFieldsSchema: {
3400
+ inputSchema: typeof GetInputFieldsSchemaSchema;
3401
+ };
3402
+ };
3358
3403
  } & {
3359
3404
  meta: {
3360
3405
  listInputFieldChoices: {
package/dist/index.mjs CHANGED
@@ -956,7 +956,8 @@ z.object({
956
956
  success: z.boolean(),
957
957
  needs: z.array(NeedSchema).optional(),
958
958
  errors: z.array(z.string()).optional(),
959
- last_fetched_at: z.string().optional()
959
+ last_fetched_at: z.string().optional(),
960
+ schema: z.record(z.unknown()).optional()
960
961
  });
961
962
  var ImplementationSchema = z.object({
962
963
  selected_api: z.string(),
@@ -1273,7 +1274,7 @@ var listAppsPlugin = ({ context }) => {
1273
1274
  const searchParams2 = {};
1274
1275
  searchParams2.term = options.search;
1275
1276
  const searchEnvelope = await api.get(
1276
- "/api/v4/implementations-meta/search/",
1277
+ "/zapier/api/v4/implementations-meta/search/",
1277
1278
  {
1278
1279
  searchParams: searchParams2
1279
1280
  }
@@ -1313,7 +1314,7 @@ var listAppsPlugin = ({ context }) => {
1313
1314
  };
1314
1315
  }
1315
1316
  const implementationsEnvelope = await api.get(
1316
- "/api/v4/implementations-meta/lookup/",
1317
+ "/zapier/api/v4/implementations-meta/lookup/",
1317
1318
  {
1318
1319
  searchParams
1319
1320
  }
@@ -1599,7 +1600,7 @@ var listActionsPlugin = ({ context }) => {
1599
1600
  selected_apis: selectedApi
1600
1601
  };
1601
1602
  const data = await api.get(
1602
- "/api/v4/implementations/",
1603
+ "/zapier/api/v4/implementations/",
1603
1604
  {
1604
1605
  searchParams,
1605
1606
  customErrorHandler: ({ status }) => {
@@ -1809,7 +1810,7 @@ async function fetchImplementationNeeds({
1809
1810
  request.authentication_id = authenticationId;
1810
1811
  }
1811
1812
  const response = await api.post(
1812
- "/api/v4/implementations/needs/",
1813
+ "/zapier/api/v4/implementations/needs/",
1813
1814
  request
1814
1815
  );
1815
1816
  if (!response.success) {
@@ -1837,7 +1838,7 @@ async function fetchImplementationChoices({
1837
1838
  request.authentication_id = authenticationId;
1838
1839
  }
1839
1840
  const response = await api.post(
1840
- "/api/v4/implementations/choices/",
1841
+ "/zapier/api/v4/implementations/choices/",
1841
1842
  request
1842
1843
  );
1843
1844
  if (!response.success) {
@@ -2102,7 +2103,7 @@ var listAuthenticationsPlugin = ({ context }) => {
2102
2103
  searchParams.offset = options.cursor;
2103
2104
  }
2104
2105
  const data = await api.get(
2105
- "/api/v4/authentications/",
2106
+ "/zapier/api/v4/authentications/",
2106
2107
  {
2107
2108
  searchParams,
2108
2109
  customErrorHandler: ({ status }) => {
@@ -2242,7 +2243,7 @@ var getAuthenticationPlugin = ({ context }) => {
2242
2243
  const { api } = context;
2243
2244
  const { authenticationId } = options;
2244
2245
  const data = await api.get(
2245
- `/api/v4/authentications/${authenticationId}/`,
2246
+ `/zapier/api/v4/authentications/${authenticationId}/`,
2246
2247
  {
2247
2248
  customErrorHandler: ({ status }) => {
2248
2249
  if (status === 401) {
@@ -2435,11 +2436,11 @@ async function executeAction(actionOptions) {
2435
2436
  data: runRequestData
2436
2437
  };
2437
2438
  const runData = await api.post(
2438
- "/api/actions/v1/runs",
2439
+ "/zapier/api/actions/v1/runs",
2439
2440
  runRequest
2440
2441
  );
2441
2442
  const runId = runData.data.id;
2442
- return await api.poll(`/api/actions/v1/runs/${runId}`, {
2443
+ return await api.poll(`/zapier/api/actions/v1/runs/${runId}`, {
2443
2444
  successStatus: 200,
2444
2445
  pendingStatus: 202,
2445
2446
  resultExtractor: (result) => result.data
@@ -2720,7 +2721,7 @@ async function getPreferredManifestEntryKey({
2720
2721
  }
2721
2722
  if (locator.implementationName) {
2722
2723
  try {
2723
- const implementationsEnvelope = await api.get(`/api/v4/implementations-meta/lookup/`, {
2724
+ const implementationsEnvelope = await api.get(`/zapier/api/v4/implementations-meta/lookup/`, {
2724
2725
  searchParams: {
2725
2726
  selected_apis: locator.implementationName
2726
2727
  }
@@ -2747,7 +2748,7 @@ async function listAppsForSlugsPage({
2747
2748
  searchParams.offset = cursor;
2748
2749
  }
2749
2750
  const implementationsEnvelope = await api.get(
2750
- "/api/v4/implementations-meta/lookup/",
2751
+ "/zapier/api/v4/implementations-meta/lookup/",
2751
2752
  {
2752
2753
  searchParams
2753
2754
  }
@@ -2986,9 +2987,12 @@ var UserProfileItemSchema = withFormatter(
2986
2987
  // src/plugins/getProfile/index.ts
2987
2988
  var getProfilePlugin = ({ context }) => {
2988
2989
  const getProfile = createFunction(async function getProfile2() {
2989
- const profile = await context.api.get("/api/v4/profile/", {
2990
- authRequired: true
2991
- });
2990
+ const profile = await context.api.get(
2991
+ "/zapier/api/v4/profile/",
2992
+ {
2993
+ authRequired: true
2994
+ }
2995
+ );
2992
2996
  const { user_id: _unusedUserId, ...data } = profile;
2993
2997
  return {
2994
2998
  data: {
@@ -3315,11 +3319,63 @@ async function getTokenFromEnvOrConfig(options = {}) {
3315
3319
  return getTokenFromCliLogin(options);
3316
3320
  }
3317
3321
 
3322
+ // src/utils/url-utils.ts
3323
+ function getZapierBaseUrl(baseUrl) {
3324
+ if (!baseUrl) {
3325
+ return void 0;
3326
+ }
3327
+ try {
3328
+ const url = new URL(baseUrl);
3329
+ const hostname = url.hostname;
3330
+ const hostParts = hostname.split(".");
3331
+ if (hostParts.length < 2) {
3332
+ return void 0;
3333
+ }
3334
+ const hasZapierPart = hostParts.some(
3335
+ (part) => part === "zapier" || part.startsWith("zapier-")
3336
+ );
3337
+ if (!hasZapierPart) {
3338
+ return void 0;
3339
+ }
3340
+ const rootDomain = hostParts.slice(-2).join(".");
3341
+ return `${url.protocol}//${rootDomain}`;
3342
+ } catch {
3343
+ return void 0;
3344
+ }
3345
+ }
3346
+ function getTrackingBaseUrl({
3347
+ trackingBaseUrl,
3348
+ baseUrl
3349
+ }) {
3350
+ if (trackingBaseUrl) {
3351
+ return trackingBaseUrl;
3352
+ }
3353
+ if (process.env.ZAPIER_TRACKING_BASE_URL) {
3354
+ return process.env.ZAPIER_TRACKING_BASE_URL;
3355
+ }
3356
+ if (baseUrl) {
3357
+ const zapierBaseUrl = getZapierBaseUrl(baseUrl);
3358
+ if (zapierBaseUrl) {
3359
+ return zapierBaseUrl;
3360
+ }
3361
+ }
3362
+ if (baseUrl) {
3363
+ return baseUrl;
3364
+ }
3365
+ return ZAPIER_BASE_URL;
3366
+ }
3367
+
3318
3368
  // src/api/client.ts
3319
- var SubdomainConfigMap = {
3320
- // e.g. https://relay.zapier.com
3321
- relay: {
3322
- authHeader: "X-Relay-Authorization"
3369
+ var pathConfig = {
3370
+ // e.g. /relay -> https://sdkapi.zapier.com/api/v0/sdk/relay/...
3371
+ "/relay": {
3372
+ authHeader: "X-Relay-Authorization",
3373
+ pathPrefix: "/api/v0/sdk/relay"
3374
+ },
3375
+ // e.g. /zapier -> https://sdkapi.zapier.com/api/v0/sdk/zapier/...
3376
+ "/zapier": {
3377
+ authHeader: "Authorization",
3378
+ pathPrefix: "/api/v0/sdk/zapier"
3323
3379
  }
3324
3380
  };
3325
3381
  var ZapierApiClient = class {
@@ -3508,39 +3564,47 @@ var ZapierApiClient = class {
3508
3564
  return { message: fallbackMessage };
3509
3565
  }
3510
3566
  }
3511
- // Check if this is a path that needs subdomain routing
3512
- // e.g. /relay/workflows -> relay.zapier.com/workflows
3513
- applySubdomainBehavior(path) {
3514
- const pathSegments = path.split("/").filter(Boolean);
3515
- if (pathSegments.length > 0 && pathSegments[0] in SubdomainConfigMap) {
3516
- const domainPrefix = pathSegments[0];
3517
- const subdomainConfig = SubdomainConfigMap[domainPrefix];
3567
+ // Apply any special routing logic for configured paths.
3568
+ applyPathConfiguration(path) {
3569
+ const matchingPathKey = Object.keys(pathConfig).find(
3570
+ (configPath) => path === configPath || path.startsWith(configPath + "/")
3571
+ );
3572
+ const config = matchingPathKey ? pathConfig[matchingPathKey] : void 0;
3573
+ const zapierBaseUrl = getZapierBaseUrl(this.options.baseUrl);
3574
+ if (zapierBaseUrl === this.options.baseUrl) {
3518
3575
  const originalBaseUrl = new URL(this.options.baseUrl);
3519
- const finalBaseUrl = `https://${domainPrefix}.${originalBaseUrl.hostname}`;
3520
- const pathWithoutPrefix = "/" + pathSegments.slice(1).join("/");
3521
- return { url: new URL(pathWithoutPrefix, finalBaseUrl), subdomainConfig };
3576
+ const finalBaseUrl = `https://sdkapi.${originalBaseUrl.hostname}`;
3577
+ let finalPath = path;
3578
+ if (config && "pathPrefix" in config && config.pathPrefix && matchingPathKey) {
3579
+ const pathWithoutPrefix = path.slice(matchingPathKey.length) || "/";
3580
+ finalPath = `${config.pathPrefix}${pathWithoutPrefix}`;
3581
+ }
3582
+ return {
3583
+ url: new URL(finalPath, finalBaseUrl),
3584
+ pathConfig: config
3585
+ };
3522
3586
  }
3523
3587
  return {
3524
3588
  url: new URL(path, this.options.baseUrl),
3525
- subdomainConfig: void 0
3589
+ pathConfig: config
3526
3590
  };
3527
3591
  }
3528
3592
  // Helper to build full URLs and return routing info
3529
3593
  buildUrl(path, searchParams) {
3530
- const { url, subdomainConfig } = this.applySubdomainBehavior(path);
3594
+ const { url, pathConfig: config } = this.applyPathConfiguration(path);
3531
3595
  if (searchParams) {
3532
3596
  Object.entries(searchParams).forEach(([key, value]) => {
3533
3597
  url.searchParams.set(key, value);
3534
3598
  });
3535
3599
  }
3536
- return { url: url.toString(), subdomainConfig };
3600
+ return { url: url.toString(), pathConfig: config };
3537
3601
  }
3538
3602
  // Helper to build headers
3539
- async buildHeaders(options = {}, subdomainConfig) {
3603
+ async buildHeaders(options = {}, pathConfig2) {
3540
3604
  const headers = new Headers(options.headers ?? {});
3541
3605
  const authToken = await this.getAuthToken();
3542
3606
  if (authToken) {
3543
- const authHeaderName = subdomainConfig?.authHeader || "Authorization";
3607
+ const authHeaderName = pathConfig2?.authHeader || "Authorization";
3544
3608
  headers.set(authHeaderName, getAuthorizationHeader(authToken));
3545
3609
  }
3546
3610
  if (options.authRequired) {
@@ -3587,13 +3651,10 @@ var ZapierApiClient = class {
3587
3651
  if (fetchOptions?.body && typeof fetchOptions.body === "object") {
3588
3652
  fetchOptions.body = JSON.stringify(fetchOptions.body);
3589
3653
  }
3590
- const { url, subdomainConfig } = this.buildUrl(
3591
- path,
3592
- fetchOptions?.searchParams
3593
- );
3654
+ const { url, pathConfig: pathConfig2 } = this.buildUrl(path, fetchOptions?.searchParams);
3594
3655
  const builtHeaders = await this.buildHeaders(
3595
3656
  fetchOptions,
3596
- subdomainConfig
3657
+ pathConfig2
3597
3658
  );
3598
3659
  const inputHeaders = new Headers(fetchOptions?.headers ?? {});
3599
3660
  const mergedHeaders = new Headers();
@@ -3837,6 +3898,85 @@ var registryPlugin = ({ sdk, context }) => {
3837
3898
  getRegistry
3838
3899
  };
3839
3900
  };
3901
+ var GetInputFieldsSchemaSchema = z.object({
3902
+ appKey: AppKeyPropertySchema.describe(
3903
+ "App key (e.g., 'SlackCLIAPI' or slug like 'github') to get the input schema for"
3904
+ ),
3905
+ actionType: ActionTypePropertySchema.describe(
3906
+ "Action type that matches the action's defined type"
3907
+ ),
3908
+ actionKey: ActionKeyPropertySchema.describe(
3909
+ "Action key to get the input schema for"
3910
+ ),
3911
+ authenticationId: AuthenticationIdPropertySchema.nullable().optional().describe(
3912
+ "Authentication ID to use when fetching the schema. Required if the action needs authentication to determine available fields."
3913
+ ),
3914
+ inputs: InputsPropertySchema.optional().describe(
3915
+ "Current input values that may affect the schema (e.g., when fields depend on other field values)"
3916
+ )
3917
+ }).describe(
3918
+ "Get the JSON Schema representation of input fields for an action. Returns a JSON Schema object describing the structure, types, and validation rules for the action's input parameters."
3919
+ );
3920
+
3921
+ // src/plugins/getInputFieldsSchema/index.ts
3922
+ var getInputFieldsSchemaPlugin = ({ sdk, context }) => {
3923
+ const getInputFieldsSchema = createFunction(
3924
+ async function getInputFieldsSchema2(options) {
3925
+ const { api, getVersionedImplementationId } = context;
3926
+ const {
3927
+ appKey,
3928
+ actionKey,
3929
+ actionType,
3930
+ authenticationId = null,
3931
+ inputs
3932
+ } = options;
3933
+ const selectedApi = await getVersionedImplementationId(appKey);
3934
+ if (!selectedApi) {
3935
+ throw new ZapierConfigurationError(
3936
+ "No current_implementation_id found for app",
3937
+ { configType: "current_implementation_id" }
3938
+ );
3939
+ }
3940
+ const { data: action } = await sdk.getAction({
3941
+ appKey,
3942
+ actionType,
3943
+ actionKey
3944
+ });
3945
+ const needsData = await fetchImplementationNeeds({
3946
+ api,
3947
+ selectedApi,
3948
+ action: action.key,
3949
+ actionType,
3950
+ authenticationId,
3951
+ inputs
3952
+ });
3953
+ return {
3954
+ data: needsData.schema || {}
3955
+ };
3956
+ },
3957
+ GetInputFieldsSchemaSchema
3958
+ );
3959
+ return {
3960
+ getInputFieldsSchema,
3961
+ context: {
3962
+ meta: {
3963
+ getInputFieldsSchema: {
3964
+ categories: ["action"],
3965
+ type: "item",
3966
+ itemType: "InputSchema",
3967
+ inputSchema: GetInputFieldsSchemaSchema,
3968
+ resolvers: {
3969
+ appKey: appKeyResolver,
3970
+ actionType: actionTypeResolver,
3971
+ actionKey: actionKeyResolver,
3972
+ authenticationId: authenticationIdResolver,
3973
+ inputs: inputsAllOptionalResolver
3974
+ }
3975
+ }
3976
+ }
3977
+ }
3978
+ };
3979
+ };
3840
3980
  var InputFieldChoiceItemSchema = withFormatter(NeedChoicesSchema, {
3841
3981
  format: (item) => {
3842
3982
  const title = item.label || item.key || "Choice";
@@ -4140,7 +4280,7 @@ function getCpuTime() {
4140
4280
 
4141
4281
  // package.json
4142
4282
  var package_default = {
4143
- version: "0.14.0"};
4283
+ version: "0.15.1"};
4144
4284
 
4145
4285
  // src/plugins/eventEmission/builders.ts
4146
4286
  function createBaseEvent(context = {}) {
@@ -4210,52 +4350,6 @@ function buildErrorEventWithContext(data, context = {}) {
4210
4350
  };
4211
4351
  }
4212
4352
 
4213
- // src/utils/url-utils.ts
4214
- function getZapierBaseUrl(baseUrl) {
4215
- if (!baseUrl) {
4216
- return void 0;
4217
- }
4218
- try {
4219
- const url = new URL(baseUrl);
4220
- const hostname = url.hostname;
4221
- const hostParts = hostname.split(".");
4222
- if (hostParts.length < 2) {
4223
- return void 0;
4224
- }
4225
- const hasZapierPart = hostParts.some(
4226
- (part) => part === "zapier" || part.startsWith("zapier-")
4227
- );
4228
- if (!hasZapierPart) {
4229
- return void 0;
4230
- }
4231
- const rootDomain = hostParts.slice(-2).join(".");
4232
- return `${url.protocol}//${rootDomain}`;
4233
- } catch {
4234
- return void 0;
4235
- }
4236
- }
4237
- function getTrackingBaseUrl({
4238
- trackingBaseUrl,
4239
- baseUrl
4240
- }) {
4241
- if (trackingBaseUrl) {
4242
- return trackingBaseUrl;
4243
- }
4244
- if (process.env.ZAPIER_TRACKING_BASE_URL) {
4245
- return process.env.ZAPIER_TRACKING_BASE_URL;
4246
- }
4247
- if (baseUrl) {
4248
- const zapierBaseUrl = getZapierBaseUrl(baseUrl);
4249
- if (zapierBaseUrl) {
4250
- return zapierBaseUrl;
4251
- }
4252
- }
4253
- if (baseUrl) {
4254
- return baseUrl;
4255
- }
4256
- return ZAPIER_BASE_URL;
4257
- }
4258
-
4259
4353
  // src/plugins/eventEmission/index.ts
4260
4354
  var APPLICATION_LIFECYCLE_EVENT_SUBJECT = "platform.sdk.ApplicationLifecycleEvent";
4261
4355
  var ERROR_OCCURRED_EVENT_SUBJECT = "platform.sdk.ErrorOccurredEvent";
@@ -4502,7 +4596,7 @@ function createSdk(options = {}, initialSdk = {}, initialContext = { meta: {} })
4502
4596
  };
4503
4597
  }
4504
4598
  function createZapierSdkWithoutRegistry(options = {}) {
4505
- return createSdk(options).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listInputFieldsPlugin).addPlugin(listInputFieldChoicesPlugin).addPlugin(runActionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(requestPlugin).addPlugin(fetchPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
4599
+ return createSdk(options).addPlugin(eventEmissionPlugin).addPlugin(apiPlugin).addPlugin(manifestPlugin).addPlugin(listAppsPlugin).addPlugin(getAppPlugin).addPlugin(listActionsPlugin).addPlugin(getActionPlugin).addPlugin(listInputFieldsPlugin).addPlugin(getInputFieldsSchemaPlugin).addPlugin(listInputFieldChoicesPlugin).addPlugin(runActionPlugin).addPlugin(listAuthenticationsPlugin).addPlugin(getAuthenticationPlugin).addPlugin(findFirstAuthenticationPlugin).addPlugin(findUniqueAuthenticationPlugin).addPlugin(requestPlugin).addPlugin(fetchPlugin).addPlugin(appsPlugin).addPlugin(getProfilePlugin);
4506
4600
  }
4507
4601
  function createZapierSdk(options = {}) {
4508
4602
  return createZapierSdkWithoutRegistry(options).addPlugin(registryPlugin);
@@ -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
  }));
@@ -0,0 +1,22 @@
1
+ import type { Plugin, GetSdkType } from "../../types/plugin";
2
+ import type { ApiClient } from "../../api";
3
+ import { GetInputFieldsSchemaSchema, type GetInputFieldsSchemaOptions as GetInputFieldsSchemaOptions } from "./schemas";
4
+ import type { GetActionPluginProvides } from "../getAction";
5
+ import type { GetVersionedImplementationId } from "../manifest/schemas";
6
+ export interface GetInputFieldsSchemaPluginProvides {
7
+ getInputFieldsSchema: (options: GetInputFieldsSchemaOptions) => Promise<{
8
+ data: Record<string, unknown>;
9
+ }>;
10
+ context: {
11
+ meta: {
12
+ getInputFieldsSchema: {
13
+ inputSchema: typeof GetInputFieldsSchemaSchema;
14
+ };
15
+ };
16
+ };
17
+ }
18
+ export declare const getInputFieldsSchemaPlugin: Plugin<GetSdkType<GetActionPluginProvides>, {
19
+ api: ApiClient;
20
+ getVersionedImplementationId: GetVersionedImplementationId;
21
+ }, GetInputFieldsSchemaPluginProvides>;
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/getInputFieldsSchema/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,0BAA0B,EAC1B,KAAK,2BAA2B,IAAI,2BAA2B,EAChE,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAUxE,MAAM,WAAW,kCAAkC;IACjD,oBAAoB,EAAE,CACpB,OAAO,EAAE,2BAA2B,KACjC,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IAChD,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,oBAAoB,EAAE;gBACpB,WAAW,EAAE,OAAO,0BAA0B,CAAC;aAChD,CAAC;SACH,CAAC;KACH,CAAC;CACH;AAED,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAC7C,UAAU,CAAC,uBAAuB,CAAC,EACnC;IACE,GAAG,EAAE,SAAS,CAAC;IACf,4BAA4B,EAAE,4BAA4B,CAAC;CAC5D,EACD,kCAAkC,CAmEnC,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { GetInputFieldsSchemaSchema, } from "./schemas";
2
+ import { ZapierConfigurationError } from "../../types/errors";
3
+ import { createFunction } from "../../utils/function-utils";
4
+ import { appKeyResolver, actionTypeResolver, actionKeyResolver, authenticationIdResolver, inputsAllOptionalResolver, } from "../../resolvers";
5
+ import { fetchImplementationNeeds } from "../../services/implementations";
6
+ export const getInputFieldsSchemaPlugin = ({ sdk, context }) => {
7
+ const getInputFieldsSchema = createFunction(async function getInputFieldsSchema(options) {
8
+ const { api, getVersionedImplementationId } = context;
9
+ const { appKey, actionKey, actionType, authenticationId = null, inputs, } = options;
10
+ const selectedApi = await getVersionedImplementationId(appKey);
11
+ if (!selectedApi) {
12
+ throw new ZapierConfigurationError("No current_implementation_id found for app", { configType: "current_implementation_id" });
13
+ }
14
+ const { data: action } = await sdk.getAction({
15
+ appKey,
16
+ actionType,
17
+ actionKey,
18
+ });
19
+ const needsData = await fetchImplementationNeeds({
20
+ api,
21
+ selectedApi,
22
+ action: action.key,
23
+ actionType,
24
+ authenticationId,
25
+ inputs,
26
+ });
27
+ return {
28
+ data: needsData.schema || {},
29
+ };
30
+ }, GetInputFieldsSchemaSchema);
31
+ return {
32
+ getInputFieldsSchema,
33
+ context: {
34
+ meta: {
35
+ getInputFieldsSchema: {
36
+ categories: ["action"],
37
+ type: "item",
38
+ itemType: "InputSchema",
39
+ inputSchema: GetInputFieldsSchemaSchema,
40
+ resolvers: {
41
+ appKey: appKeyResolver,
42
+ actionType: actionTypeResolver,
43
+ actionKey: actionKeyResolver,
44
+ authenticationId: authenticationIdResolver,
45
+ inputs: inputsAllOptionalResolver,
46
+ },
47
+ },
48
+ },
49
+ },
50
+ };
51
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../../src/plugins/getInputFieldsSchema/index.test.ts"],"names":[],"mappings":""}