@zapier/zapier-sdk 0.109.1 → 0.110.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.
@@ -2,9 +2,10 @@ import { __require } from './chunk-Y6FXYEAI.mjs';
2
2
  import { z } from 'zod';
3
3
  import { withPositional, createDeprecationLogger, createAsyncContext, declareOptionalProperty, defineProperty, definePlugin, sendHttpRequestPlugin, retryHttpRequestPlugin, declareProperty, defineMethod, coreOptionsPluginRef, createValidator, defineFormatter, declareMethod, defineResolver, concatLists, openEnum, defineHook, getRegistryPlugin, paginate, toSnakeCase, isCoreError, toTitleCase, CORE_ERROR_SYMBOL, CoreErrorCode, CORE_SIGNAL_SYMBOL, isCoreSignal, createSdk, CORE_OPTIONS_ID, resolvePlugin } from '@zapier/kitcore';
4
4
  export { CONTEXT, CORE_ERROR_SYMBOL, CORE_OPTIONS_ID, CORE_SIGNAL_SYMBOL, CoreCancelledSignal, CoreDisposeError, CoreErrorCode, CoreSignal, addPlugin, composePlugins, createController, createCorePlugin, createFunction, createPaginatedFunction, createPaginatedPluginMethod, createPluginMethod, createPluginStack, createSdk, declareMethod, declareOptionalProperty, declarePlugin, declareProperty, defineFormatter, defineLegacyMerge, defineMethod, defineMethodOverride, defineOverride, definePlugin, defineProperty, defineResolver, disposeSdk, fromFunctionPlugin, getContext, getCoreErrorCause, getCoreErrorCode, getNegatable, getRegistryPlugin, isCoreCancelledSignal, isCoreError, isCoreSignal, isPositional, omitExports, resolvePlugin, runInMethodScope, runWithTelemetryContext, selectExports, toSnakeCase, toTitleCase } from '@zapier/kitcore';
5
+ import { ConnectionSchema, ConnectionsResponseSchema, ListConnectionsQuerySchema as ListConnectionsQuerySchema$1, ConnectionItemSchema } from '@zapier/zapier-sdk-core/v0/schemas/connections';
5
6
  import { buildHttpRequestContext, buildActionRunContext } from '@zapier/policy-context';
6
7
  import { ListAppsQuerySchema, AppItemSchema as AppItemSchema$1 } from '@zapier/zapier-sdk-core/v0/schemas/apps';
7
- import { ListConnectionsQuerySchema as ListConnectionsQuerySchema$1, ConnectionSchema, ConnectionsResponseSchema, ConnectionItemSchema } from '@zapier/zapier-sdk-core/v0/schemas/connections';
8
+ import { ImplementationMetaSchema, ImplementationsMetaResponseSchema } from '@zapier/zapier-sdk-core/v0/schemas/implementations';
8
9
  import { ListClientCredentialsQuerySchema as ListClientCredentialsQuerySchema$1, ClientCredentialsItemSchema as ClientCredentialsItemSchema$1, CreateClientCredentialsRequestSchema, ClientCredentialsCreatedItemSchema as ClientCredentialsCreatedItemSchema$1 } from '@zapier/zapier-sdk-core/v0/schemas/client-credentials';
9
10
 
10
11
  // src/constants.ts
@@ -2797,7 +2798,7 @@ function logRouteOverride({
2797
2798
  }
2798
2799
 
2799
2800
  // src/sdk-version.ts
2800
- var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.109.1" : void 0) || "unknown";
2801
+ var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.110.1" : void 0) || "unknown";
2801
2802
 
2802
2803
  // src/utils/open-url.ts
2803
2804
  var nodePrefix = "node:";
@@ -4348,17 +4349,6 @@ function splitVersionedKey(versionedKey) {
4348
4349
  }
4349
4350
  return [versionedKey, void 0];
4350
4351
  }
4351
- function normalizeImplementationMetaToAppItem(implementationMeta) {
4352
- const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
4353
- const { id, name, ...restOfImplementationMeta } = implementationMeta;
4354
- return {
4355
- ...restOfImplementationMeta,
4356
- title: name,
4357
- key: selectedApi,
4358
- implementation_id: id,
4359
- version: appVersion
4360
- };
4361
- }
4362
4352
  function normalizeActionItem(action) {
4363
4353
  const { name, type, selected_api: selectedApi } = action;
4364
4354
  const [appKey, appVersion] = selectedApi ? splitVersionedKey(selectedApi) : ["", void 0];
@@ -4455,6 +4445,141 @@ function getAppKeyList(app) {
4455
4445
  return Array.from(keys);
4456
4446
  }
4457
4447
 
4448
+ // src/normalizers/shared.ts
4449
+ function fastifyToString(value) {
4450
+ if (value === void 0) {
4451
+ return void 0;
4452
+ }
4453
+ if (typeof value === "string") {
4454
+ return value;
4455
+ }
4456
+ if (value === null) {
4457
+ return "";
4458
+ }
4459
+ if (value instanceof Date) {
4460
+ return value.toISOString();
4461
+ }
4462
+ if (value instanceof RegExp) {
4463
+ return value.source;
4464
+ }
4465
+ try {
4466
+ return String(value.toString());
4467
+ } catch {
4468
+ return "[unserializable]";
4469
+ }
4470
+ }
4471
+
4472
+ // src/normalizers/app.ts
4473
+ function normalizeImplementationMetaToAppItem(implementationMeta) {
4474
+ const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
4475
+ const { id, name, ...restOfImplementationMeta } = implementationMeta;
4476
+ return {
4477
+ ...restOfImplementationMeta,
4478
+ title: name,
4479
+ key: selectedApi,
4480
+ implementation_id: id,
4481
+ version: appVersion
4482
+ };
4483
+ }
4484
+ function normalizeAppItem({
4485
+ app
4486
+ }) {
4487
+ const {
4488
+ banner,
4489
+ auth_type: authType,
4490
+ description,
4491
+ primary_color: primaryColor,
4492
+ secondary_color: secondaryColor,
4493
+ classification,
4494
+ api_docs_url: apiDocsUrl,
4495
+ image,
4496
+ visibility,
4497
+ ...implementationMeta
4498
+ } = app;
4499
+ return normalizeImplementationMetaToAppItem({
4500
+ ...implementationMeta,
4501
+ ...banner !== void 0 && { banner: fastifyToString(banner) },
4502
+ ...authType !== void 0 && {
4503
+ auth_type: fastifyToString(authType)
4504
+ },
4505
+ ...description !== void 0 && {
4506
+ description: fastifyToString(description)
4507
+ },
4508
+ ...primaryColor !== void 0 && {
4509
+ primary_color: fastifyToString(primaryColor)
4510
+ },
4511
+ ...secondaryColor !== void 0 && {
4512
+ secondary_color: fastifyToString(secondaryColor)
4513
+ },
4514
+ ...classification !== void 0 && {
4515
+ classification: fastifyToString(classification)
4516
+ },
4517
+ ...apiDocsUrl !== void 0 && {
4518
+ api_docs_url: fastifyToString(apiDocsUrl)
4519
+ },
4520
+ ...image !== void 0 && { image: fastifyToString(image) },
4521
+ ...visibility !== void 0 && {
4522
+ visibility: fastifyToString(visibility)
4523
+ }
4524
+ });
4525
+ }
4526
+ var RawConnectionSchema = ConnectionSchema.extend({
4527
+ is_stale: z.boolean().optional(),
4528
+ is_shared: z.boolean().optional(),
4529
+ members: z.array(z.record(z.string(), z.any())).optional(),
4530
+ customuser_id: z.number().nullable().optional(),
4531
+ customuser_public_id: z.string().nullable().optional()
4532
+ });
4533
+ var RawConnectionsResponseSchema = ConnectionsResponseSchema.extend({
4534
+ results: z.array(RawConnectionSchema)
4535
+ });
4536
+
4537
+ // src/normalizers/connection.ts
4538
+ function normalizeConnectionItem({
4539
+ connection,
4540
+ appKey: providedAppKey,
4541
+ appVersion: providedAppVersion,
4542
+ adaptError
4543
+ }) {
4544
+ let appKey = providedAppKey;
4545
+ let appVersion = providedAppVersion;
4546
+ if (connection.selected_api && typeof connection.selected_api === "string") {
4547
+ const [extractedAppKey, extractedVersion] = splitVersionedKey(
4548
+ connection.selected_api
4549
+ );
4550
+ if (!appKey) {
4551
+ appKey = extractedAppKey;
4552
+ }
4553
+ if (!appVersion) {
4554
+ appVersion = extractedVersion;
4555
+ }
4556
+ }
4557
+ const {
4558
+ selected_api: selectedApi,
4559
+ customuser_id: profileId,
4560
+ id,
4561
+ account_id: accountId,
4562
+ ...restOfConnection
4563
+ } = connection;
4564
+ const normalized = {
4565
+ ...restOfConnection,
4566
+ id: String(id),
4567
+ account_id: String(accountId),
4568
+ implementation_id: selectedApi,
4569
+ title: connection.title || connection.label || void 0,
4570
+ is_stale: fastifyToString(connection.is_stale),
4571
+ is_expired: fastifyToString(connection.is_stale),
4572
+ is_shared: fastifyToString(connection.is_shared),
4573
+ members: fastifyToString(connection.members),
4574
+ customuser_public_id: fastifyToString(connection.customuser_public_id),
4575
+ expired_at: connection.marked_stale_at,
4576
+ app_key: appKey,
4577
+ app_version: appVersion,
4578
+ profile_id: profileId != null ? String(profileId) : void 0
4579
+ };
4580
+ return createValidator(ConnectionItemSchema, { adaptError })(normalized);
4581
+ }
4582
+
4458
4583
  // src/utils/pagination.ts
4459
4584
  function extractCursorFromUrl(url) {
4460
4585
  try {
@@ -5720,6 +5845,29 @@ var workflowDraftIdResolver = defineResolver({
5720
5845
  }))
5721
5846
  })
5722
5847
  });
5848
+ var getWorkflowDraftRef = declareMethod({ id: "getWorkflowDraft" });
5849
+ var workflowDraftRevisionResolver = defineResolver({
5850
+ imports: [getWorkflowDraftRef],
5851
+ requireParameters: ["workflow", "draft"],
5852
+ listItems: async ({
5853
+ imports,
5854
+ input
5855
+ }) => {
5856
+ const { data } = await imports.getWorkflowDraft({
5857
+ workflow: input.workflow,
5858
+ draft: input.draft
5859
+ });
5860
+ return { data: [data] };
5861
+ },
5862
+ prompt: ({ items }) => ({
5863
+ type: "list",
5864
+ message: "Confirm the draft revision to run:",
5865
+ choices: items.map((d) => ({
5866
+ label: `revision ${d.draft_revision} \u2014 last edited ${d.last_edited_at ?? "never"}`,
5867
+ value: d.draft_revision
5868
+ }))
5869
+ })
5870
+ });
5723
5871
  var listWorkflowRunsRef = declareMethod({ id: "listWorkflowRuns" });
5724
5872
  var workflowRunIdResolver = defineResolver({
5725
5873
  imports: [listWorkflowRunsRef],
@@ -7332,6 +7480,23 @@ var ListAppsSchema = ListAppsQuerySchema.omit({
7332
7480
  cursor: z.string().optional().describe("Cursor to start from")
7333
7481
  }).describe("List all available apps with optional filtering");
7334
7482
  var AppItemSchema = AppItemSchema$1;
7483
+ var RawImplementationMetaLookupSchema = ImplementationMetaSchema.extend({
7484
+ banner: z.string().nullish(),
7485
+ auth_type: z.string().nullish(),
7486
+ description: z.string().nullish(),
7487
+ primary_color: z.string().nullish(),
7488
+ secondary_color: z.string().nullish(),
7489
+ classification: z.string().nullish(),
7490
+ api_docs_url: z.string().nullish(),
7491
+ image: z.string().nullish(),
7492
+ visibility: z.string().nullish()
7493
+ });
7494
+ var RawImplementationsMetaLookupResponseSchema = ImplementationsMetaResponseSchema.extend({
7495
+ results: z.array(RawImplementationMetaLookupSchema)
7496
+ });
7497
+ var RawImplementationsMetaSearchResponseSchema = z.object({
7498
+ results: z.array(z.object({ id: z.string() }))
7499
+ });
7335
7500
  var appItemFormatter = defineFormatter({
7336
7501
  format: ({ item }) => ({
7337
7502
  title: item.title,
@@ -7344,10 +7509,237 @@ var appItemFormatter = defineFormatter({
7344
7509
  })
7345
7510
  });
7346
7511
 
7512
+ // src/plugins/listApps/ranking.ts
7513
+ var RANK = {
7514
+ CASE_SENSITIVE_EQUAL: 7,
7515
+ EQUAL: 6,
7516
+ STARTS_WITH: 5,
7517
+ WORD_STARTS_WITH: 4,
7518
+ CONTAINS: 3,
7519
+ ACRONYM: 2,
7520
+ FUZZY: 1,
7521
+ NO_MATCH: 0
7522
+ };
7523
+ var SEARCH_FIELDS = ["slug", "title"];
7524
+ var ACRONYM_DELIMITERS = /* @__PURE__ */ new Set([" ", "-"]);
7525
+ function foldAccents(value) {
7526
+ return value.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
7527
+ }
7528
+ function getAcronym(value) {
7529
+ let acronym = "";
7530
+ let previousWasDelimiter = true;
7531
+ for (let index = 0; index < value.length; index += 1) {
7532
+ const char = value.charAt(index);
7533
+ const isDelimiter = ACRONYM_DELIMITERS.has(char);
7534
+ if (previousWasDelimiter && !isDelimiter) {
7535
+ acronym += char;
7536
+ }
7537
+ previousWasDelimiter = isDelimiter;
7538
+ }
7539
+ return acronym;
7540
+ }
7541
+ function getClosenessRank(testValue, term) {
7542
+ const firstMatchEnd = testValue.indexOf(term[0]) + 1;
7543
+ if (firstMatchEnd === 0) {
7544
+ return RANK.NO_MATCH;
7545
+ }
7546
+ let cursor = firstMatchEnd;
7547
+ for (let i = 1; i < term.length; i++) {
7548
+ cursor = testValue.indexOf(term[i], cursor) + 1;
7549
+ if (cursor === 0) {
7550
+ return RANK.NO_MATCH;
7551
+ }
7552
+ }
7553
+ return RANK.FUZZY + 1 / (cursor - firstMatchEnd);
7554
+ }
7555
+ function getMatchRank(testValue, term) {
7556
+ const testFolded = foldAccents(testValue);
7557
+ if (term.folded.length > testFolded.length) {
7558
+ return RANK.NO_MATCH;
7559
+ }
7560
+ if (testFolded === term.folded) {
7561
+ return RANK.CASE_SENSITIVE_EQUAL;
7562
+ }
7563
+ const testLower = testFolded.toLowerCase();
7564
+ if (testLower === term.lowercase) {
7565
+ return RANK.EQUAL;
7566
+ }
7567
+ if (testLower.startsWith(term.lowercase)) {
7568
+ return RANK.STARTS_WITH;
7569
+ }
7570
+ if (testLower.includes(` ${term.lowercase}`)) {
7571
+ return RANK.WORD_STARTS_WITH;
7572
+ }
7573
+ if (testLower.includes(term.lowercase)) {
7574
+ return RANK.CONTAINS;
7575
+ }
7576
+ if (term.lowercase.length === 1) {
7577
+ return RANK.NO_MATCH;
7578
+ }
7579
+ if (getAcronym(testLower).includes(term.lowercase)) {
7580
+ return RANK.ACRONYM;
7581
+ }
7582
+ return getClosenessRank(testLower, term.lowercase);
7583
+ }
7584
+ function rankApp(app, term) {
7585
+ const firstRankedValue = app[SEARCH_FIELDS[0]];
7586
+ let bestRank = getMatchRank(firstRankedValue, term);
7587
+ let bestFieldPriority = 0;
7588
+ let bestRankedValue = firstRankedValue;
7589
+ for (let fieldPriority = 1; fieldPriority < SEARCH_FIELDS.length; fieldPriority += 1) {
7590
+ const rankedValue = app[SEARCH_FIELDS[fieldPriority]];
7591
+ const rank = getMatchRank(rankedValue, term);
7592
+ if (rank > bestRank) {
7593
+ bestRank = rank;
7594
+ bestFieldPriority = fieldPriority;
7595
+ bestRankedValue = rankedValue;
7596
+ }
7597
+ }
7598
+ return {
7599
+ app,
7600
+ rank: bestRank,
7601
+ fieldPriority: bestFieldPriority,
7602
+ rankedValue: bestRankedValue
7603
+ };
7604
+ }
7605
+ var TIE_BREAK_COLLATOR = new Intl.Collator("en-US");
7606
+ function compareRanked(a, b) {
7607
+ if (a.rank !== b.rank) {
7608
+ return b.rank - a.rank;
7609
+ }
7610
+ if (a.fieldPriority !== b.fieldPriority) {
7611
+ return a.fieldPriority - b.fieldPriority;
7612
+ }
7613
+ return TIE_BREAK_COLLATOR.compare(a.rankedValue, b.rankedValue);
7614
+ }
7615
+ function prioritizeSearchResults({
7616
+ apps,
7617
+ search
7618
+ }) {
7619
+ const foldedSearch = foldAccents(search);
7620
+ const term = {
7621
+ folded: foldedSearch,
7622
+ lowercase: foldedSearch.toLowerCase()
7623
+ };
7624
+ const matches = [];
7625
+ const nonMatches = [];
7626
+ for (const app of apps) {
7627
+ const ranked = rankApp(app, term);
7628
+ if (ranked.rank > RANK.NO_MATCH) {
7629
+ matches.push(ranked);
7630
+ } else {
7631
+ nonMatches.push(app);
7632
+ }
7633
+ }
7634
+ matches.sort(compareRanked);
7635
+ return [...matches.map(({ app }) => app), ...nonMatches];
7636
+ }
7637
+ async function augmentWithSearchResults({
7638
+ imports,
7639
+ searchTerm,
7640
+ implementationIds
7641
+ }) {
7642
+ const rawResponse = await imports.api.get(
7643
+ "/zapier/api/v4/implementations-meta/search/",
7644
+ { searchParams: { term: searchTerm } }
7645
+ );
7646
+ const { results } = createValidator(
7647
+ RawImplementationsMetaSearchResponseSchema,
7648
+ { adaptError: imports.coreOptions?.adaptError }
7649
+ )(rawResponse);
7650
+ const implementationNameSet = new Set(
7651
+ implementationIds.map((id) => {
7652
+ const [name] = splitVersionedKey(id);
7653
+ return name;
7654
+ })
7655
+ );
7656
+ const additionalIds = [];
7657
+ for (const { id } of results) {
7658
+ const [implementationName] = splitVersionedKey(id);
7659
+ if (!implementationNameSet.has(implementationName)) {
7660
+ implementationNameSet.add(implementationName);
7661
+ additionalIds.push(id);
7662
+ }
7663
+ }
7664
+ return [...implementationIds, ...additionalIds];
7665
+ }
7666
+
7667
+ // src/plugins/listApps/fetch.ts
7668
+ async function fetchListApps({
7669
+ imports,
7670
+ input,
7671
+ implementationIds: initialImplementationIds
7672
+ }) {
7673
+ const pageSize = input.pageSize ?? DEFAULT_PAGE_SIZE;
7674
+ let implementationIds = initialImplementationIds;
7675
+ if (input.search) {
7676
+ implementationIds = await augmentWithSearchResults({
7677
+ imports,
7678
+ searchTerm: input.search,
7679
+ implementationIds
7680
+ });
7681
+ }
7682
+ if (implementationIds.length === 0 && input.search) {
7683
+ return {
7684
+ data: [],
7685
+ links: { next: null },
7686
+ meta: {
7687
+ count: 0,
7688
+ limit: pageSize,
7689
+ offset: input.cursor ? parseInt(input.cursor) : 0
7690
+ }
7691
+ };
7692
+ }
7693
+ const searchParams = {
7694
+ limit: pageSize.toString()
7695
+ };
7696
+ if (implementationIds.length === 0) {
7697
+ searchParams.latest_only = "true";
7698
+ searchParams.selected_apis = "";
7699
+ } else {
7700
+ searchParams.selected_apis = implementationIds.join(",");
7701
+ }
7702
+ if (input.cursor) {
7703
+ searchParams.offset = input.cursor;
7704
+ }
7705
+ const rawResponse = await imports.api.get(
7706
+ "/zapier/api/v4/implementations-meta/lookup/",
7707
+ { searchParams }
7708
+ );
7709
+ const data = createValidator(RawImplementationsMetaLookupResponseSchema, {
7710
+ adaptError: imports.coreOptions?.adaptError
7711
+ })(rawResponse);
7712
+ let apps = data.results.map((app) => normalizeAppItem({ app }));
7713
+ if (input.search) {
7714
+ try {
7715
+ apps = prioritizeSearchResults({ apps, search: input.search });
7716
+ } catch (error) {
7717
+ createDebugLogger(imports.sdkOptions?.debug ?? false)(
7718
+ "listApps search-result ranking failed; preserving API order",
7719
+ error
7720
+ );
7721
+ }
7722
+ }
7723
+ return {
7724
+ data: apps,
7725
+ links: { next: data.next },
7726
+ meta: {
7727
+ count: apps.length,
7728
+ limit: pageSize,
7729
+ offset: input.cursor ? parseInt(input.cursor) : 0
7730
+ }
7731
+ };
7732
+ }
7733
+
7347
7734
  // src/plugins/listApps/index.ts
7348
7735
  var listAppsPlugin = defineMethod({
7349
7736
  name: "listApps",
7350
- imports: [manifestPluginRef, apiPluginRef],
7737
+ imports: [
7738
+ manifestPluginRef,
7739
+ apiPluginRef,
7740
+ sdkOptionsPluginRef,
7741
+ coreOptionsPluginRef
7742
+ ],
7351
7743
  categories: ["app"],
7352
7744
  itemType: "App",
7353
7745
  inputSchema: ListAppsSchema,
@@ -7360,7 +7752,6 @@ var listAppsPlugin = defineMethod({
7360
7752
  defaultPageSize: DEFAULT_PAGE_SIZE
7361
7753
  },
7362
7754
  run: async ({ imports, input }) => {
7363
- const api = imports.api;
7364
7755
  const resolveAppKeys2 = imports.manifest.resolveAppKeys;
7365
7756
  const appKeys = input.apps ?? input.appKeys ?? [];
7366
7757
  const appLocators = await resolveAppKeys2({ appKeys: [...appKeys] });
@@ -7388,16 +7779,7 @@ var listAppsPlugin = defineMethod({
7388
7779
  const version = locator.version || "latest";
7389
7780
  return `${locator.implementationName}@${version}`;
7390
7781
  });
7391
- return api.get("/api/v0/apps", {
7392
- searchParams: {
7393
- app_keys: implementationIds.join(","),
7394
- ...input.search && { search: input.search },
7395
- ...input.pageSize !== void 0 && {
7396
- page_size: input.pageSize.toString()
7397
- },
7398
- ...input.cursor && { offset: input.cursor }
7399
- }
7400
- });
7782
+ return fetchListApps({ imports, input, implementationIds });
7401
7783
  }
7402
7784
  });
7403
7785
  var ListInputFieldsDescription = "Get the input fields required for a specific action";
@@ -8120,86 +8502,6 @@ var ListConnectionsQuerySchema = ListConnectionsQuerySchema$1.omit({
8120
8502
  // SDK specific property for pagination/iterable helpers
8121
8503
  cursor: z.string().optional().describe("Cursor to start from")
8122
8504
  }).describe("List available connections with optional filtering");
8123
- var RawConnectionSchema = ConnectionSchema.extend({
8124
- is_stale: z.boolean().optional(),
8125
- is_shared: z.boolean().optional(),
8126
- members: z.array(z.record(z.string(), z.any())).optional(),
8127
- customuser_id: z.number().nullable().optional(),
8128
- customuser_public_id: z.string().nullable().optional()
8129
- });
8130
- var RawConnectionsResponseSchema = ConnectionsResponseSchema.extend({
8131
- results: z.array(RawConnectionSchema)
8132
- });
8133
-
8134
- // src/normalizers/shared.ts
8135
- function fastifyToString(value) {
8136
- if (value === void 0) {
8137
- return void 0;
8138
- }
8139
- if (typeof value === "string") {
8140
- return value;
8141
- }
8142
- if (value === null) {
8143
- return "";
8144
- }
8145
- if (value instanceof Date) {
8146
- return value.toISOString();
8147
- }
8148
- if (value instanceof RegExp) {
8149
- return value.source;
8150
- }
8151
- try {
8152
- return String(value.toString());
8153
- } catch {
8154
- return "[unserializable]";
8155
- }
8156
- }
8157
-
8158
- // src/normalizers/connection.ts
8159
- function normalizeConnectionItem({
8160
- connection,
8161
- appKey: providedAppKey,
8162
- appVersion: providedAppVersion,
8163
- adaptError
8164
- }) {
8165
- let appKey = providedAppKey;
8166
- let appVersion = providedAppVersion;
8167
- if (connection.selected_api && typeof connection.selected_api === "string") {
8168
- const [extractedAppKey, extractedVersion] = splitVersionedKey(
8169
- connection.selected_api
8170
- );
8171
- if (!appKey) {
8172
- appKey = extractedAppKey;
8173
- }
8174
- if (!appVersion) {
8175
- appVersion = extractedVersion;
8176
- }
8177
- }
8178
- const {
8179
- selected_api: selectedApi,
8180
- customuser_id: profileId,
8181
- id,
8182
- account_id: accountId,
8183
- ...restOfConnection
8184
- } = connection;
8185
- const normalized = {
8186
- ...restOfConnection,
8187
- id: String(id),
8188
- account_id: String(accountId),
8189
- implementation_id: selectedApi,
8190
- title: connection.title || connection.label || void 0,
8191
- is_stale: fastifyToString(connection.is_stale),
8192
- is_expired: fastifyToString(connection.is_stale),
8193
- is_shared: fastifyToString(connection.is_shared),
8194
- members: fastifyToString(connection.members),
8195
- customuser_public_id: fastifyToString(connection.customuser_public_id),
8196
- expired_at: connection.marked_stale_at,
8197
- app_key: appKey,
8198
- app_version: appVersion,
8199
- profile_id: profileId != null ? String(profileId) : void 0
8200
- };
8201
- return createValidator(ConnectionItemSchema, { adaptError })(normalized);
8202
- }
8203
8505
  function formatConnectionItem(item) {
8204
8506
  const details = [];
8205
8507
  const appKey = item.app_key ?? "unknown";
@@ -12874,4 +13176,4 @@ var registryPlugin = (_sdk) => {
12874
13176
  return {};
12875
13177
  };
12876
13178
 
12877
- export { ACTION_RUNS_PATH, API_ID, ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMillisecondsPropertySchema, ActionTimeoutSecondsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthMechanism, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONNECTIONS_ID, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MILLISECONDS, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MILLISECONDS, DEFAULT_APPROVAL_TIMEOUT_MILLISECONDS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DEPRECATION_NOTICE_EVENT, DebugPropertySchema, DrainTriggerInboxSchema, EVENT_EMISSION_ID, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MANIFEST_ID, MAX_CONCURRENCY_LIMIT, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RESOLVE_CREDENTIALS_ID, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, SDK_OPTIONS_ID, TablePropertySchema, TablesPropertySchema, TriggerInboxKeyPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, WatchTriggerInboxSchema, ZAPIER_BASE_URL, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MILLISECONDS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, apiPluginRef, appKeyResolver, appsPlugin, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, cleanupEventListeners, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, connectionsPluginRef, createActionRunPlugin, createBaseEvent, createClientCredentialsPlugin, createMemoryCache, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, durableRunIdResolver, eventEmissionHookPlugin, eventEmissionPlugin, eventEmissionPluginRef, extractErrorDetail, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getActionRunPlugin, getAgent, getAppPlugin, getBaseUrlFromCredentials, getCallerContext, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOrCreateApiClient, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getTtyContext, getZapierApprovalMode, getZapierCausationId, getZapierCorrelationId, getZapierDefaultApprovalMode, getZapierOpenAutoModeApprovalsInBrowser, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPermanentHttpError, isPkceCredentials, isZapierAbortDrainSignal, isZapierActionError, isZapierAppNotFoundError, isZapierApprovalError, isZapierAuthenticationError, isZapierBundleError, isZapierConflictError, isZapierError, isZapierNotFoundError, isZapierRateLimitError, isZapierReleaseTriggerMessageSignal, isZapierResourceNotFoundError, isZapierSignal, isZapierTimeoutError, isZapierValidationError, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, manifestPluginRef, operationAnnotatorPlugin, parseConcurrencyEnvVar, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuth, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, resolveCredentialsPlugin, resolveCredentialsPluginRef, runActionPlugin, runWithCallerContext, sdkOptionsPluginRef, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, triggerInboxResolver, triggerMessagesResolver, updateTableRecordsPlugin, workflowDraftIdResolver, workflowIdResolver, workflowRunIdResolver, workflowVersionIdResolver, zapierAdaptError, zapierCoreOptions, zapierSdkPlugin };
13179
+ export { ACTION_RUNS_PATH, API_ID, ActionKeyPropertySchema, ActionPropertySchema, ActionTimeoutMillisecondsPropertySchema, ActionTimeoutSecondsPropertySchema, ActionTypePropertySchema, AppKeyPropertySchema, AppPropertySchema, AppsPropertySchema, AuthMechanism, AuthenticationIdPropertySchema, BaseSdkOptionsSchema, CONNECTIONS_ID, CONTEXT_CACHE_MAX_SIZE, CONTEXT_CACHE_TTL_MILLISECONDS, ClientCredentialsObjectSchema, ConnectionEntrySchema, ConnectionIdPropertySchema, ConnectionPropertySchema, ConnectionsMapSchema, ConnectionsPropertySchema, CredentialsFunctionSchema, CredentialsObjectSchema, CredentialsSchema, DEFAULT_ACTION_TIMEOUT_MILLISECONDS, DEFAULT_APPROVAL_TIMEOUT_MILLISECONDS, DEFAULT_CONFIG_PATH, DEFAULT_MAX_APPROVAL_RETRIES, DEFAULT_PAGE_SIZE, DEPRECATION_NOTICE_EVENT, DebugPropertySchema, DrainTriggerInboxSchema, EVENT_EMISSION_ID, FieldsPropertySchema, InputFieldPropertySchema, InputsPropertySchema, LeaseLimitPropertySchema, LeasePropertySchema, LeaseSecondsPropertySchema, LimitPropertySchema, MANIFEST_ID, MAX_CONCURRENCY_LIMIT, MAX_PAGE_LIMIT, OffsetPropertySchema, OutputPropertySchema, ParamsPropertySchema, PkceCredentialsObjectSchema, RESOLVE_CREDENTIALS_ID, RecordPropertySchema, RecordsPropertySchema, RelayFetchSchema, RelayRequestSchema, ResolvedCredentialsSchema, SDK_OPTIONS_ID, TablePropertySchema, TablesPropertySchema, TriggerInboxKeyPropertySchema, TriggerInboxNamePropertySchema, TriggerInboxPropertySchema, WatchTriggerInboxSchema, ZAPIER_BASE_URL, ZAPIER_MAX_CONCURRENT_REQUESTS, ZAPIER_MAX_NETWORK_RETRIES, ZAPIER_MAX_NETWORK_RETRY_DELAY_MILLISECONDS, ZapierAbortDrainSignal, ZapierActionError, ZapierApiError, ZapierAppNotFoundError, ZapierApprovalError, ZapierAuthenticationError, ZapierBundleError, ZapierConfigurationError, ZapierConflictError, ZapierError, ZapierNotFoundError, ZapierRateLimitError, ZapierRelayError, ZapierReleaseTriggerMessageSignal, ZapierResourceNotFoundError, ZapierSignal, ZapierTimeoutError, ZapierUnknownError, ZapierValidationError, actionKeyResolver, actionTypeResolver, apiPlugin, apiPluginRef, appKeyResolver, appsPlugin, batch, buildApplicationLifecycleEvent, buildCapabilityMessage, buildErrorEvent, buildErrorEventWithContext, buildMethodCalledEvent, cleanupEventListeners, clearTokenCache, clientCredentialsNameResolver, clientIdResolver, connectionIdGenericResolver, connectionIdResolver, connectionsPlugin, connectionsPluginRef, createActionRunPlugin, createBaseEvent, createClientCredentialsPlugin, createMemoryCache, createTableFieldsPlugin, createTablePlugin, createTableRecordsPlugin, createZapierApi, createZapierSdk, createZapierSdkWithoutRegistry, deleteClientCredentialsPlugin, deleteTableFieldsPlugin, deleteTablePlugin, deleteTableRecordsPlugin, durableRunIdResolver, eventEmissionHookPlugin, eventEmissionPlugin, eventEmissionPluginRef, extractErrorDetail, fetchPlugin, findFirstConnectionPlugin, findManifestEntry, findUniqueConnectionPlugin, formatErrorMessage, generateEventId, getActionInputFieldsSchemaPlugin, getActionPlugin, getActionRunPlugin, getAgent, getAppPlugin, getBaseUrlFromCredentials, getCallerContext, getCiPlatform, getClientIdFromCredentials, getConnectionPlugin, getCpuTime, getCurrentTimestamp, getMemoryUsage, getOrCreateApiClient, getOsInfo, getPlatformVersions, getPreferredManifestEntryKey, getProfilePlugin, getReleaseId, getTablePlugin, getTableRecordPlugin, getTokenFromCliLogin, getTtyContext, getZapierApprovalMode, getZapierCausationId, getZapierCorrelationId, getZapierDefaultApprovalMode, getZapierOpenAutoModeApprovalsInBrowser, getZapierSdkService, injectCliLogin, inputFieldKeyResolver, inputsAllOptionalResolver, inputsResolver, invalidateCachedToken, invalidateCredentialsToken, isCi, isCliLoginAvailable, isClientCredentials, isCredentialsFunction, isCredentialsObject, isPermanentHttpError, isPkceCredentials, isZapierAbortDrainSignal, isZapierActionError, isZapierAppNotFoundError, isZapierApprovalError, isZapierAuthenticationError, isZapierBundleError, isZapierConflictError, isZapierError, isZapierNotFoundError, isZapierRateLimitError, isZapierReleaseTriggerMessageSignal, isZapierResourceNotFoundError, isZapierSignal, isZapierTimeoutError, isZapierValidationError, listActionInputFieldChoicesPlugin, listActionInputFieldsPlugin, listActionsPlugin, listAppsPlugin, listClientCredentialsPlugin, listConnectionsPlugin, listTableFieldsPlugin, listTableRecordsPlugin, listTablesPlugin, logDeprecation, manifestPlugin, manifestPluginRef, operationAnnotatorPlugin, parseConcurrencyEnvVar, readManifestFromFile, registryPlugin, requestPlugin, resetDeprecationWarnings, resolveAuth, resolveAuthToken, resolveCredentials, resolveCredentialsFromEnv, resolveCredentialsPlugin, resolveCredentialsPluginRef, runActionPlugin, runWithCallerContext, sdkOptionsPluginRef, tableFieldIdsResolver, tableFieldsResolver, tableFiltersResolver, tableIdResolver, tableNameResolver, tableRecordIdResolver, tableRecordIdsResolver, tableRecordsResolver, tableSortResolver, tableUpdateRecordsResolver, triggerInboxResolver, triggerMessagesResolver, updateTableRecordsPlugin, workflowDraftIdResolver, workflowDraftRevisionResolver, workflowIdResolver, workflowRunIdResolver, workflowVersionIdResolver, zapierAdaptError, zapierCoreOptions, zapierSdkPlugin };