@zapier/zapier-sdk 0.110.0 → 0.110.2
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.
- package/CHANGELOG.md +17 -0
- package/dist/{chunk-IHWWBHBO.cjs → chunk-MZR4HZXA.cjs} +385 -105
- package/dist/{chunk-KCJZMIEC.mjs → chunk-YYMYT6JV.mjs} +385 -106
- package/dist/experimental.cjs +430 -389
- package/dist/experimental.d.mts +399 -5
- package/dist/experimental.d.ts +399 -5
- package/dist/experimental.mjs +45 -7
- package/dist/{index-BRxVTixv.d.mts → index-ubhG9-NU.d.mts} +671 -95
- package/dist/{index-BRxVTixv.d.ts → index-ubhG9-NU.d.ts} +671 -95
- package/dist/index.cjs +280 -280
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
|
@@ -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 {
|
|
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.110.
|
|
2801
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.110.2" : 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 {
|
|
@@ -7355,6 +7480,23 @@ var ListAppsSchema = ListAppsQuerySchema.omit({
|
|
|
7355
7480
|
cursor: z.string().optional().describe("Cursor to start from")
|
|
7356
7481
|
}).describe("List all available apps with optional filtering");
|
|
7357
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
|
+
});
|
|
7358
7500
|
var appItemFormatter = defineFormatter({
|
|
7359
7501
|
format: ({ item }) => ({
|
|
7360
7502
|
title: item.title,
|
|
@@ -7367,10 +7509,237 @@ var appItemFormatter = defineFormatter({
|
|
|
7367
7509
|
})
|
|
7368
7510
|
});
|
|
7369
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
|
+
|
|
7370
7734
|
// src/plugins/listApps/index.ts
|
|
7371
7735
|
var listAppsPlugin = defineMethod({
|
|
7372
7736
|
name: "listApps",
|
|
7373
|
-
imports: [
|
|
7737
|
+
imports: [
|
|
7738
|
+
manifestPluginRef,
|
|
7739
|
+
apiPluginRef,
|
|
7740
|
+
sdkOptionsPluginRef,
|
|
7741
|
+
coreOptionsPluginRef
|
|
7742
|
+
],
|
|
7374
7743
|
categories: ["app"],
|
|
7375
7744
|
itemType: "App",
|
|
7376
7745
|
inputSchema: ListAppsSchema,
|
|
@@ -7383,7 +7752,6 @@ var listAppsPlugin = defineMethod({
|
|
|
7383
7752
|
defaultPageSize: DEFAULT_PAGE_SIZE
|
|
7384
7753
|
},
|
|
7385
7754
|
run: async ({ imports, input }) => {
|
|
7386
|
-
const api = imports.api;
|
|
7387
7755
|
const resolveAppKeys2 = imports.manifest.resolveAppKeys;
|
|
7388
7756
|
const appKeys = input.apps ?? input.appKeys ?? [];
|
|
7389
7757
|
const appLocators = await resolveAppKeys2({ appKeys: [...appKeys] });
|
|
@@ -7411,16 +7779,7 @@ var listAppsPlugin = defineMethod({
|
|
|
7411
7779
|
const version = locator.version || "latest";
|
|
7412
7780
|
return `${locator.implementationName}@${version}`;
|
|
7413
7781
|
});
|
|
7414
|
-
return
|
|
7415
|
-
searchParams: {
|
|
7416
|
-
app_keys: implementationIds.join(","),
|
|
7417
|
-
...input.search && { search: input.search },
|
|
7418
|
-
...input.pageSize !== void 0 && {
|
|
7419
|
-
page_size: input.pageSize.toString()
|
|
7420
|
-
},
|
|
7421
|
-
...input.cursor && { offset: input.cursor }
|
|
7422
|
-
}
|
|
7423
|
-
});
|
|
7782
|
+
return fetchListApps({ imports, input, implementationIds });
|
|
7424
7783
|
}
|
|
7425
7784
|
});
|
|
7426
7785
|
var ListInputFieldsDescription = "Get the input fields required for a specific action";
|
|
@@ -8143,86 +8502,6 @@ var ListConnectionsQuerySchema = ListConnectionsQuerySchema$1.omit({
|
|
|
8143
8502
|
// SDK specific property for pagination/iterable helpers
|
|
8144
8503
|
cursor: z.string().optional().describe("Cursor to start from")
|
|
8145
8504
|
}).describe("List available connections with optional filtering");
|
|
8146
|
-
var RawConnectionSchema = ConnectionSchema.extend({
|
|
8147
|
-
is_stale: z.boolean().optional(),
|
|
8148
|
-
is_shared: z.boolean().optional(),
|
|
8149
|
-
members: z.array(z.record(z.string(), z.any())).optional(),
|
|
8150
|
-
customuser_id: z.number().nullable().optional(),
|
|
8151
|
-
customuser_public_id: z.string().nullable().optional()
|
|
8152
|
-
});
|
|
8153
|
-
var RawConnectionsResponseSchema = ConnectionsResponseSchema.extend({
|
|
8154
|
-
results: z.array(RawConnectionSchema)
|
|
8155
|
-
});
|
|
8156
|
-
|
|
8157
|
-
// src/normalizers/shared.ts
|
|
8158
|
-
function fastifyToString(value) {
|
|
8159
|
-
if (value === void 0) {
|
|
8160
|
-
return void 0;
|
|
8161
|
-
}
|
|
8162
|
-
if (typeof value === "string") {
|
|
8163
|
-
return value;
|
|
8164
|
-
}
|
|
8165
|
-
if (value === null) {
|
|
8166
|
-
return "";
|
|
8167
|
-
}
|
|
8168
|
-
if (value instanceof Date) {
|
|
8169
|
-
return value.toISOString();
|
|
8170
|
-
}
|
|
8171
|
-
if (value instanceof RegExp) {
|
|
8172
|
-
return value.source;
|
|
8173
|
-
}
|
|
8174
|
-
try {
|
|
8175
|
-
return String(value.toString());
|
|
8176
|
-
} catch {
|
|
8177
|
-
return "[unserializable]";
|
|
8178
|
-
}
|
|
8179
|
-
}
|
|
8180
|
-
|
|
8181
|
-
// src/normalizers/connection.ts
|
|
8182
|
-
function normalizeConnectionItem({
|
|
8183
|
-
connection,
|
|
8184
|
-
appKey: providedAppKey,
|
|
8185
|
-
appVersion: providedAppVersion,
|
|
8186
|
-
adaptError
|
|
8187
|
-
}) {
|
|
8188
|
-
let appKey = providedAppKey;
|
|
8189
|
-
let appVersion = providedAppVersion;
|
|
8190
|
-
if (connection.selected_api && typeof connection.selected_api === "string") {
|
|
8191
|
-
const [extractedAppKey, extractedVersion] = splitVersionedKey(
|
|
8192
|
-
connection.selected_api
|
|
8193
|
-
);
|
|
8194
|
-
if (!appKey) {
|
|
8195
|
-
appKey = extractedAppKey;
|
|
8196
|
-
}
|
|
8197
|
-
if (!appVersion) {
|
|
8198
|
-
appVersion = extractedVersion;
|
|
8199
|
-
}
|
|
8200
|
-
}
|
|
8201
|
-
const {
|
|
8202
|
-
selected_api: selectedApi,
|
|
8203
|
-
customuser_id: profileId,
|
|
8204
|
-
id,
|
|
8205
|
-
account_id: accountId,
|
|
8206
|
-
...restOfConnection
|
|
8207
|
-
} = connection;
|
|
8208
|
-
const normalized = {
|
|
8209
|
-
...restOfConnection,
|
|
8210
|
-
id: String(id),
|
|
8211
|
-
account_id: String(accountId),
|
|
8212
|
-
implementation_id: selectedApi,
|
|
8213
|
-
title: connection.title || connection.label || void 0,
|
|
8214
|
-
is_stale: fastifyToString(connection.is_stale),
|
|
8215
|
-
is_expired: fastifyToString(connection.is_stale),
|
|
8216
|
-
is_shared: fastifyToString(connection.is_shared),
|
|
8217
|
-
members: fastifyToString(connection.members),
|
|
8218
|
-
customuser_public_id: fastifyToString(connection.customuser_public_id),
|
|
8219
|
-
expired_at: connection.marked_stale_at,
|
|
8220
|
-
app_key: appKey,
|
|
8221
|
-
app_version: appVersion,
|
|
8222
|
-
profile_id: profileId != null ? String(profileId) : void 0
|
|
8223
|
-
};
|
|
8224
|
-
return createValidator(ConnectionItemSchema, { adaptError })(normalized);
|
|
8225
|
-
}
|
|
8226
8505
|
function formatConnectionItem(item) {
|
|
8227
8506
|
const details = [];
|
|
8228
8507
|
const appKey = item.app_key ?? "unknown";
|
|
@@ -12897,4 +13176,4 @@ var registryPlugin = (_sdk) => {
|
|
|
12897
13176
|
return {};
|
|
12898
13177
|
};
|
|
12899
13178
|
|
|
12900
|
-
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 };
|
|
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, SDK_VERSION, 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 };
|