@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.
- package/CHANGELOG.md +32 -0
- package/README.md +124 -35
- package/dist/{chunk-NTUEFDSW.cjs → chunk-BURXHBSW.cjs} +408 -105
- package/dist/{chunk-6TOSNLPZ.mjs → chunk-IRHF55YK.mjs} +408 -106
- package/dist/experimental.cjs +519 -395
- package/dist/experimental.d.mts +514 -13
- package/dist/experimental.d.ts +514 -13
- package/dist/experimental.mjs +139 -19
- package/dist/{index-Cum18GPG.d.mts → index-ubhG9-NU.d.mts} +673 -95
- package/dist/{index-Cum18GPG.d.ts → index-ubhG9-NU.d.ts} +673 -95
- package/dist/index.cjs +283 -279
- 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
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
var chunkOBGZSXTJ_cjs = require('./chunk-OBGZSXTJ.cjs');
|
|
4
4
|
var zod = require('zod');
|
|
5
5
|
var kitcore = require('@zapier/kitcore');
|
|
6
|
+
var connections = require('@zapier/zapier-sdk-core/v0/schemas/connections');
|
|
6
7
|
var policyContext = require('@zapier/policy-context');
|
|
7
8
|
var apps = require('@zapier/zapier-sdk-core/v0/schemas/apps');
|
|
8
|
-
var
|
|
9
|
+
var implementations = require('@zapier/zapier-sdk-core/v0/schemas/implementations');
|
|
9
10
|
var clientCredentials = require('@zapier/zapier-sdk-core/v0/schemas/client-credentials');
|
|
10
11
|
|
|
11
12
|
// src/constants.ts
|
|
@@ -2798,7 +2799,7 @@ function logRouteOverride({
|
|
|
2798
2799
|
}
|
|
2799
2800
|
|
|
2800
2801
|
// src/sdk-version.ts
|
|
2801
|
-
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.
|
|
2802
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.110.1" : void 0) || "unknown";
|
|
2802
2803
|
|
|
2803
2804
|
// src/utils/open-url.ts
|
|
2804
2805
|
var nodePrefix = "node:";
|
|
@@ -4349,17 +4350,6 @@ function splitVersionedKey(versionedKey) {
|
|
|
4349
4350
|
}
|
|
4350
4351
|
return [versionedKey, void 0];
|
|
4351
4352
|
}
|
|
4352
|
-
function normalizeImplementationMetaToAppItem(implementationMeta) {
|
|
4353
|
-
const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
|
|
4354
|
-
const { id, name, ...restOfImplementationMeta } = implementationMeta;
|
|
4355
|
-
return {
|
|
4356
|
-
...restOfImplementationMeta,
|
|
4357
|
-
title: name,
|
|
4358
|
-
key: selectedApi,
|
|
4359
|
-
implementation_id: id,
|
|
4360
|
-
version: appVersion
|
|
4361
|
-
};
|
|
4362
|
-
}
|
|
4363
4353
|
function normalizeActionItem(action) {
|
|
4364
4354
|
const { name, type, selected_api: selectedApi } = action;
|
|
4365
4355
|
const [appKey, appVersion] = selectedApi ? splitVersionedKey(selectedApi) : ["", void 0];
|
|
@@ -4456,6 +4446,141 @@ function getAppKeyList(app) {
|
|
|
4456
4446
|
return Array.from(keys);
|
|
4457
4447
|
}
|
|
4458
4448
|
|
|
4449
|
+
// src/normalizers/shared.ts
|
|
4450
|
+
function fastifyToString(value) {
|
|
4451
|
+
if (value === void 0) {
|
|
4452
|
+
return void 0;
|
|
4453
|
+
}
|
|
4454
|
+
if (typeof value === "string") {
|
|
4455
|
+
return value;
|
|
4456
|
+
}
|
|
4457
|
+
if (value === null) {
|
|
4458
|
+
return "";
|
|
4459
|
+
}
|
|
4460
|
+
if (value instanceof Date) {
|
|
4461
|
+
return value.toISOString();
|
|
4462
|
+
}
|
|
4463
|
+
if (value instanceof RegExp) {
|
|
4464
|
+
return value.source;
|
|
4465
|
+
}
|
|
4466
|
+
try {
|
|
4467
|
+
return String(value.toString());
|
|
4468
|
+
} catch {
|
|
4469
|
+
return "[unserializable]";
|
|
4470
|
+
}
|
|
4471
|
+
}
|
|
4472
|
+
|
|
4473
|
+
// src/normalizers/app.ts
|
|
4474
|
+
function normalizeImplementationMetaToAppItem(implementationMeta) {
|
|
4475
|
+
const [selectedApi, appVersion] = splitVersionedKey(implementationMeta.id);
|
|
4476
|
+
const { id, name, ...restOfImplementationMeta } = implementationMeta;
|
|
4477
|
+
return {
|
|
4478
|
+
...restOfImplementationMeta,
|
|
4479
|
+
title: name,
|
|
4480
|
+
key: selectedApi,
|
|
4481
|
+
implementation_id: id,
|
|
4482
|
+
version: appVersion
|
|
4483
|
+
};
|
|
4484
|
+
}
|
|
4485
|
+
function normalizeAppItem({
|
|
4486
|
+
app
|
|
4487
|
+
}) {
|
|
4488
|
+
const {
|
|
4489
|
+
banner,
|
|
4490
|
+
auth_type: authType,
|
|
4491
|
+
description,
|
|
4492
|
+
primary_color: primaryColor,
|
|
4493
|
+
secondary_color: secondaryColor,
|
|
4494
|
+
classification,
|
|
4495
|
+
api_docs_url: apiDocsUrl,
|
|
4496
|
+
image,
|
|
4497
|
+
visibility,
|
|
4498
|
+
...implementationMeta
|
|
4499
|
+
} = app;
|
|
4500
|
+
return normalizeImplementationMetaToAppItem({
|
|
4501
|
+
...implementationMeta,
|
|
4502
|
+
...banner !== void 0 && { banner: fastifyToString(banner) },
|
|
4503
|
+
...authType !== void 0 && {
|
|
4504
|
+
auth_type: fastifyToString(authType)
|
|
4505
|
+
},
|
|
4506
|
+
...description !== void 0 && {
|
|
4507
|
+
description: fastifyToString(description)
|
|
4508
|
+
},
|
|
4509
|
+
...primaryColor !== void 0 && {
|
|
4510
|
+
primary_color: fastifyToString(primaryColor)
|
|
4511
|
+
},
|
|
4512
|
+
...secondaryColor !== void 0 && {
|
|
4513
|
+
secondary_color: fastifyToString(secondaryColor)
|
|
4514
|
+
},
|
|
4515
|
+
...classification !== void 0 && {
|
|
4516
|
+
classification: fastifyToString(classification)
|
|
4517
|
+
},
|
|
4518
|
+
...apiDocsUrl !== void 0 && {
|
|
4519
|
+
api_docs_url: fastifyToString(apiDocsUrl)
|
|
4520
|
+
},
|
|
4521
|
+
...image !== void 0 && { image: fastifyToString(image) },
|
|
4522
|
+
...visibility !== void 0 && {
|
|
4523
|
+
visibility: fastifyToString(visibility)
|
|
4524
|
+
}
|
|
4525
|
+
});
|
|
4526
|
+
}
|
|
4527
|
+
var RawConnectionSchema = connections.ConnectionSchema.extend({
|
|
4528
|
+
is_stale: zod.z.boolean().optional(),
|
|
4529
|
+
is_shared: zod.z.boolean().optional(),
|
|
4530
|
+
members: zod.z.array(zod.z.record(zod.z.string(), zod.z.any())).optional(),
|
|
4531
|
+
customuser_id: zod.z.number().nullable().optional(),
|
|
4532
|
+
customuser_public_id: zod.z.string().nullable().optional()
|
|
4533
|
+
});
|
|
4534
|
+
var RawConnectionsResponseSchema = connections.ConnectionsResponseSchema.extend({
|
|
4535
|
+
results: zod.z.array(RawConnectionSchema)
|
|
4536
|
+
});
|
|
4537
|
+
|
|
4538
|
+
// src/normalizers/connection.ts
|
|
4539
|
+
function normalizeConnectionItem({
|
|
4540
|
+
connection,
|
|
4541
|
+
appKey: providedAppKey,
|
|
4542
|
+
appVersion: providedAppVersion,
|
|
4543
|
+
adaptError
|
|
4544
|
+
}) {
|
|
4545
|
+
let appKey = providedAppKey;
|
|
4546
|
+
let appVersion = providedAppVersion;
|
|
4547
|
+
if (connection.selected_api && typeof connection.selected_api === "string") {
|
|
4548
|
+
const [extractedAppKey, extractedVersion] = splitVersionedKey(
|
|
4549
|
+
connection.selected_api
|
|
4550
|
+
);
|
|
4551
|
+
if (!appKey) {
|
|
4552
|
+
appKey = extractedAppKey;
|
|
4553
|
+
}
|
|
4554
|
+
if (!appVersion) {
|
|
4555
|
+
appVersion = extractedVersion;
|
|
4556
|
+
}
|
|
4557
|
+
}
|
|
4558
|
+
const {
|
|
4559
|
+
selected_api: selectedApi,
|
|
4560
|
+
customuser_id: profileId,
|
|
4561
|
+
id,
|
|
4562
|
+
account_id: accountId,
|
|
4563
|
+
...restOfConnection
|
|
4564
|
+
} = connection;
|
|
4565
|
+
const normalized = {
|
|
4566
|
+
...restOfConnection,
|
|
4567
|
+
id: String(id),
|
|
4568
|
+
account_id: String(accountId),
|
|
4569
|
+
implementation_id: selectedApi,
|
|
4570
|
+
title: connection.title || connection.label || void 0,
|
|
4571
|
+
is_stale: fastifyToString(connection.is_stale),
|
|
4572
|
+
is_expired: fastifyToString(connection.is_stale),
|
|
4573
|
+
is_shared: fastifyToString(connection.is_shared),
|
|
4574
|
+
members: fastifyToString(connection.members),
|
|
4575
|
+
customuser_public_id: fastifyToString(connection.customuser_public_id),
|
|
4576
|
+
expired_at: connection.marked_stale_at,
|
|
4577
|
+
app_key: appKey,
|
|
4578
|
+
app_version: appVersion,
|
|
4579
|
+
profile_id: profileId != null ? String(profileId) : void 0
|
|
4580
|
+
};
|
|
4581
|
+
return kitcore.createValidator(connections.ConnectionItemSchema, { adaptError })(normalized);
|
|
4582
|
+
}
|
|
4583
|
+
|
|
4459
4584
|
// src/utils/pagination.ts
|
|
4460
4585
|
function extractCursorFromUrl(url) {
|
|
4461
4586
|
try {
|
|
@@ -5721,6 +5846,29 @@ var workflowDraftIdResolver = kitcore.defineResolver({
|
|
|
5721
5846
|
}))
|
|
5722
5847
|
})
|
|
5723
5848
|
});
|
|
5849
|
+
var getWorkflowDraftRef = kitcore.declareMethod({ id: "getWorkflowDraft" });
|
|
5850
|
+
var workflowDraftRevisionResolver = kitcore.defineResolver({
|
|
5851
|
+
imports: [getWorkflowDraftRef],
|
|
5852
|
+
requireParameters: ["workflow", "draft"],
|
|
5853
|
+
listItems: async ({
|
|
5854
|
+
imports,
|
|
5855
|
+
input
|
|
5856
|
+
}) => {
|
|
5857
|
+
const { data } = await imports.getWorkflowDraft({
|
|
5858
|
+
workflow: input.workflow,
|
|
5859
|
+
draft: input.draft
|
|
5860
|
+
});
|
|
5861
|
+
return { data: [data] };
|
|
5862
|
+
},
|
|
5863
|
+
prompt: ({ items }) => ({
|
|
5864
|
+
type: "list",
|
|
5865
|
+
message: "Confirm the draft revision to run:",
|
|
5866
|
+
choices: items.map((d) => ({
|
|
5867
|
+
label: `revision ${d.draft_revision} \u2014 last edited ${d.last_edited_at ?? "never"}`,
|
|
5868
|
+
value: d.draft_revision
|
|
5869
|
+
}))
|
|
5870
|
+
})
|
|
5871
|
+
});
|
|
5724
5872
|
var listWorkflowRunsRef = kitcore.declareMethod({ id: "listWorkflowRuns" });
|
|
5725
5873
|
var workflowRunIdResolver = kitcore.defineResolver({
|
|
5726
5874
|
imports: [listWorkflowRunsRef],
|
|
@@ -7333,6 +7481,23 @@ var ListAppsSchema = apps.ListAppsQuerySchema.omit({
|
|
|
7333
7481
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
7334
7482
|
}).describe("List all available apps with optional filtering");
|
|
7335
7483
|
var AppItemSchema = apps.AppItemSchema;
|
|
7484
|
+
var RawImplementationMetaLookupSchema = implementations.ImplementationMetaSchema.extend({
|
|
7485
|
+
banner: zod.z.string().nullish(),
|
|
7486
|
+
auth_type: zod.z.string().nullish(),
|
|
7487
|
+
description: zod.z.string().nullish(),
|
|
7488
|
+
primary_color: zod.z.string().nullish(),
|
|
7489
|
+
secondary_color: zod.z.string().nullish(),
|
|
7490
|
+
classification: zod.z.string().nullish(),
|
|
7491
|
+
api_docs_url: zod.z.string().nullish(),
|
|
7492
|
+
image: zod.z.string().nullish(),
|
|
7493
|
+
visibility: zod.z.string().nullish()
|
|
7494
|
+
});
|
|
7495
|
+
var RawImplementationsMetaLookupResponseSchema = implementations.ImplementationsMetaResponseSchema.extend({
|
|
7496
|
+
results: zod.z.array(RawImplementationMetaLookupSchema)
|
|
7497
|
+
});
|
|
7498
|
+
var RawImplementationsMetaSearchResponseSchema = zod.z.object({
|
|
7499
|
+
results: zod.z.array(zod.z.object({ id: zod.z.string() }))
|
|
7500
|
+
});
|
|
7336
7501
|
var appItemFormatter = kitcore.defineFormatter({
|
|
7337
7502
|
format: ({ item }) => ({
|
|
7338
7503
|
title: item.title,
|
|
@@ -7345,10 +7510,237 @@ var appItemFormatter = kitcore.defineFormatter({
|
|
|
7345
7510
|
})
|
|
7346
7511
|
});
|
|
7347
7512
|
|
|
7513
|
+
// src/plugins/listApps/ranking.ts
|
|
7514
|
+
var RANK = {
|
|
7515
|
+
CASE_SENSITIVE_EQUAL: 7,
|
|
7516
|
+
EQUAL: 6,
|
|
7517
|
+
STARTS_WITH: 5,
|
|
7518
|
+
WORD_STARTS_WITH: 4,
|
|
7519
|
+
CONTAINS: 3,
|
|
7520
|
+
ACRONYM: 2,
|
|
7521
|
+
FUZZY: 1,
|
|
7522
|
+
NO_MATCH: 0
|
|
7523
|
+
};
|
|
7524
|
+
var SEARCH_FIELDS = ["slug", "title"];
|
|
7525
|
+
var ACRONYM_DELIMITERS = /* @__PURE__ */ new Set([" ", "-"]);
|
|
7526
|
+
function foldAccents(value) {
|
|
7527
|
+
return value.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
7528
|
+
}
|
|
7529
|
+
function getAcronym(value) {
|
|
7530
|
+
let acronym = "";
|
|
7531
|
+
let previousWasDelimiter = true;
|
|
7532
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
7533
|
+
const char = value.charAt(index);
|
|
7534
|
+
const isDelimiter = ACRONYM_DELIMITERS.has(char);
|
|
7535
|
+
if (previousWasDelimiter && !isDelimiter) {
|
|
7536
|
+
acronym += char;
|
|
7537
|
+
}
|
|
7538
|
+
previousWasDelimiter = isDelimiter;
|
|
7539
|
+
}
|
|
7540
|
+
return acronym;
|
|
7541
|
+
}
|
|
7542
|
+
function getClosenessRank(testValue, term) {
|
|
7543
|
+
const firstMatchEnd = testValue.indexOf(term[0]) + 1;
|
|
7544
|
+
if (firstMatchEnd === 0) {
|
|
7545
|
+
return RANK.NO_MATCH;
|
|
7546
|
+
}
|
|
7547
|
+
let cursor = firstMatchEnd;
|
|
7548
|
+
for (let i = 1; i < term.length; i++) {
|
|
7549
|
+
cursor = testValue.indexOf(term[i], cursor) + 1;
|
|
7550
|
+
if (cursor === 0) {
|
|
7551
|
+
return RANK.NO_MATCH;
|
|
7552
|
+
}
|
|
7553
|
+
}
|
|
7554
|
+
return RANK.FUZZY + 1 / (cursor - firstMatchEnd);
|
|
7555
|
+
}
|
|
7556
|
+
function getMatchRank(testValue, term) {
|
|
7557
|
+
const testFolded = foldAccents(testValue);
|
|
7558
|
+
if (term.folded.length > testFolded.length) {
|
|
7559
|
+
return RANK.NO_MATCH;
|
|
7560
|
+
}
|
|
7561
|
+
if (testFolded === term.folded) {
|
|
7562
|
+
return RANK.CASE_SENSITIVE_EQUAL;
|
|
7563
|
+
}
|
|
7564
|
+
const testLower = testFolded.toLowerCase();
|
|
7565
|
+
if (testLower === term.lowercase) {
|
|
7566
|
+
return RANK.EQUAL;
|
|
7567
|
+
}
|
|
7568
|
+
if (testLower.startsWith(term.lowercase)) {
|
|
7569
|
+
return RANK.STARTS_WITH;
|
|
7570
|
+
}
|
|
7571
|
+
if (testLower.includes(` ${term.lowercase}`)) {
|
|
7572
|
+
return RANK.WORD_STARTS_WITH;
|
|
7573
|
+
}
|
|
7574
|
+
if (testLower.includes(term.lowercase)) {
|
|
7575
|
+
return RANK.CONTAINS;
|
|
7576
|
+
}
|
|
7577
|
+
if (term.lowercase.length === 1) {
|
|
7578
|
+
return RANK.NO_MATCH;
|
|
7579
|
+
}
|
|
7580
|
+
if (getAcronym(testLower).includes(term.lowercase)) {
|
|
7581
|
+
return RANK.ACRONYM;
|
|
7582
|
+
}
|
|
7583
|
+
return getClosenessRank(testLower, term.lowercase);
|
|
7584
|
+
}
|
|
7585
|
+
function rankApp(app, term) {
|
|
7586
|
+
const firstRankedValue = app[SEARCH_FIELDS[0]];
|
|
7587
|
+
let bestRank = getMatchRank(firstRankedValue, term);
|
|
7588
|
+
let bestFieldPriority = 0;
|
|
7589
|
+
let bestRankedValue = firstRankedValue;
|
|
7590
|
+
for (let fieldPriority = 1; fieldPriority < SEARCH_FIELDS.length; fieldPriority += 1) {
|
|
7591
|
+
const rankedValue = app[SEARCH_FIELDS[fieldPriority]];
|
|
7592
|
+
const rank = getMatchRank(rankedValue, term);
|
|
7593
|
+
if (rank > bestRank) {
|
|
7594
|
+
bestRank = rank;
|
|
7595
|
+
bestFieldPriority = fieldPriority;
|
|
7596
|
+
bestRankedValue = rankedValue;
|
|
7597
|
+
}
|
|
7598
|
+
}
|
|
7599
|
+
return {
|
|
7600
|
+
app,
|
|
7601
|
+
rank: bestRank,
|
|
7602
|
+
fieldPriority: bestFieldPriority,
|
|
7603
|
+
rankedValue: bestRankedValue
|
|
7604
|
+
};
|
|
7605
|
+
}
|
|
7606
|
+
var TIE_BREAK_COLLATOR = new Intl.Collator("en-US");
|
|
7607
|
+
function compareRanked(a, b) {
|
|
7608
|
+
if (a.rank !== b.rank) {
|
|
7609
|
+
return b.rank - a.rank;
|
|
7610
|
+
}
|
|
7611
|
+
if (a.fieldPriority !== b.fieldPriority) {
|
|
7612
|
+
return a.fieldPriority - b.fieldPriority;
|
|
7613
|
+
}
|
|
7614
|
+
return TIE_BREAK_COLLATOR.compare(a.rankedValue, b.rankedValue);
|
|
7615
|
+
}
|
|
7616
|
+
function prioritizeSearchResults({
|
|
7617
|
+
apps,
|
|
7618
|
+
search
|
|
7619
|
+
}) {
|
|
7620
|
+
const foldedSearch = foldAccents(search);
|
|
7621
|
+
const term = {
|
|
7622
|
+
folded: foldedSearch,
|
|
7623
|
+
lowercase: foldedSearch.toLowerCase()
|
|
7624
|
+
};
|
|
7625
|
+
const matches = [];
|
|
7626
|
+
const nonMatches = [];
|
|
7627
|
+
for (const app of apps) {
|
|
7628
|
+
const ranked = rankApp(app, term);
|
|
7629
|
+
if (ranked.rank > RANK.NO_MATCH) {
|
|
7630
|
+
matches.push(ranked);
|
|
7631
|
+
} else {
|
|
7632
|
+
nonMatches.push(app);
|
|
7633
|
+
}
|
|
7634
|
+
}
|
|
7635
|
+
matches.sort(compareRanked);
|
|
7636
|
+
return [...matches.map(({ app }) => app), ...nonMatches];
|
|
7637
|
+
}
|
|
7638
|
+
async function augmentWithSearchResults({
|
|
7639
|
+
imports,
|
|
7640
|
+
searchTerm,
|
|
7641
|
+
implementationIds
|
|
7642
|
+
}) {
|
|
7643
|
+
const rawResponse = await imports.api.get(
|
|
7644
|
+
"/zapier/api/v4/implementations-meta/search/",
|
|
7645
|
+
{ searchParams: { term: searchTerm } }
|
|
7646
|
+
);
|
|
7647
|
+
const { results } = kitcore.createValidator(
|
|
7648
|
+
RawImplementationsMetaSearchResponseSchema,
|
|
7649
|
+
{ adaptError: imports.coreOptions?.adaptError }
|
|
7650
|
+
)(rawResponse);
|
|
7651
|
+
const implementationNameSet = new Set(
|
|
7652
|
+
implementationIds.map((id) => {
|
|
7653
|
+
const [name] = splitVersionedKey(id);
|
|
7654
|
+
return name;
|
|
7655
|
+
})
|
|
7656
|
+
);
|
|
7657
|
+
const additionalIds = [];
|
|
7658
|
+
for (const { id } of results) {
|
|
7659
|
+
const [implementationName] = splitVersionedKey(id);
|
|
7660
|
+
if (!implementationNameSet.has(implementationName)) {
|
|
7661
|
+
implementationNameSet.add(implementationName);
|
|
7662
|
+
additionalIds.push(id);
|
|
7663
|
+
}
|
|
7664
|
+
}
|
|
7665
|
+
return [...implementationIds, ...additionalIds];
|
|
7666
|
+
}
|
|
7667
|
+
|
|
7668
|
+
// src/plugins/listApps/fetch.ts
|
|
7669
|
+
async function fetchListApps({
|
|
7670
|
+
imports,
|
|
7671
|
+
input,
|
|
7672
|
+
implementationIds: initialImplementationIds
|
|
7673
|
+
}) {
|
|
7674
|
+
const pageSize = input.pageSize ?? DEFAULT_PAGE_SIZE;
|
|
7675
|
+
let implementationIds = initialImplementationIds;
|
|
7676
|
+
if (input.search) {
|
|
7677
|
+
implementationIds = await augmentWithSearchResults({
|
|
7678
|
+
imports,
|
|
7679
|
+
searchTerm: input.search,
|
|
7680
|
+
implementationIds
|
|
7681
|
+
});
|
|
7682
|
+
}
|
|
7683
|
+
if (implementationIds.length === 0 && input.search) {
|
|
7684
|
+
return {
|
|
7685
|
+
data: [],
|
|
7686
|
+
links: { next: null },
|
|
7687
|
+
meta: {
|
|
7688
|
+
count: 0,
|
|
7689
|
+
limit: pageSize,
|
|
7690
|
+
offset: input.cursor ? parseInt(input.cursor) : 0
|
|
7691
|
+
}
|
|
7692
|
+
};
|
|
7693
|
+
}
|
|
7694
|
+
const searchParams = {
|
|
7695
|
+
limit: pageSize.toString()
|
|
7696
|
+
};
|
|
7697
|
+
if (implementationIds.length === 0) {
|
|
7698
|
+
searchParams.latest_only = "true";
|
|
7699
|
+
searchParams.selected_apis = "";
|
|
7700
|
+
} else {
|
|
7701
|
+
searchParams.selected_apis = implementationIds.join(",");
|
|
7702
|
+
}
|
|
7703
|
+
if (input.cursor) {
|
|
7704
|
+
searchParams.offset = input.cursor;
|
|
7705
|
+
}
|
|
7706
|
+
const rawResponse = await imports.api.get(
|
|
7707
|
+
"/zapier/api/v4/implementations-meta/lookup/",
|
|
7708
|
+
{ searchParams }
|
|
7709
|
+
);
|
|
7710
|
+
const data = kitcore.createValidator(RawImplementationsMetaLookupResponseSchema, {
|
|
7711
|
+
adaptError: imports.coreOptions?.adaptError
|
|
7712
|
+
})(rawResponse);
|
|
7713
|
+
let apps = data.results.map((app) => normalizeAppItem({ app }));
|
|
7714
|
+
if (input.search) {
|
|
7715
|
+
try {
|
|
7716
|
+
apps = prioritizeSearchResults({ apps, search: input.search });
|
|
7717
|
+
} catch (error) {
|
|
7718
|
+
createDebugLogger(imports.sdkOptions?.debug ?? false)(
|
|
7719
|
+
"listApps search-result ranking failed; preserving API order",
|
|
7720
|
+
error
|
|
7721
|
+
);
|
|
7722
|
+
}
|
|
7723
|
+
}
|
|
7724
|
+
return {
|
|
7725
|
+
data: apps,
|
|
7726
|
+
links: { next: data.next },
|
|
7727
|
+
meta: {
|
|
7728
|
+
count: apps.length,
|
|
7729
|
+
limit: pageSize,
|
|
7730
|
+
offset: input.cursor ? parseInt(input.cursor) : 0
|
|
7731
|
+
}
|
|
7732
|
+
};
|
|
7733
|
+
}
|
|
7734
|
+
|
|
7348
7735
|
// src/plugins/listApps/index.ts
|
|
7349
7736
|
var listAppsPlugin = kitcore.defineMethod({
|
|
7350
7737
|
name: "listApps",
|
|
7351
|
-
imports: [
|
|
7738
|
+
imports: [
|
|
7739
|
+
manifestPluginRef,
|
|
7740
|
+
apiPluginRef,
|
|
7741
|
+
sdkOptionsPluginRef,
|
|
7742
|
+
kitcore.coreOptionsPluginRef
|
|
7743
|
+
],
|
|
7352
7744
|
categories: ["app"],
|
|
7353
7745
|
itemType: "App",
|
|
7354
7746
|
inputSchema: ListAppsSchema,
|
|
@@ -7361,7 +7753,6 @@ var listAppsPlugin = kitcore.defineMethod({
|
|
|
7361
7753
|
defaultPageSize: DEFAULT_PAGE_SIZE
|
|
7362
7754
|
},
|
|
7363
7755
|
run: async ({ imports, input }) => {
|
|
7364
|
-
const api = imports.api;
|
|
7365
7756
|
const resolveAppKeys2 = imports.manifest.resolveAppKeys;
|
|
7366
7757
|
const appKeys = input.apps ?? input.appKeys ?? [];
|
|
7367
7758
|
const appLocators = await resolveAppKeys2({ appKeys: [...appKeys] });
|
|
@@ -7389,16 +7780,7 @@ var listAppsPlugin = kitcore.defineMethod({
|
|
|
7389
7780
|
const version = locator.version || "latest";
|
|
7390
7781
|
return `${locator.implementationName}@${version}`;
|
|
7391
7782
|
});
|
|
7392
|
-
return
|
|
7393
|
-
searchParams: {
|
|
7394
|
-
app_keys: implementationIds.join(","),
|
|
7395
|
-
...input.search && { search: input.search },
|
|
7396
|
-
...input.pageSize !== void 0 && {
|
|
7397
|
-
page_size: input.pageSize.toString()
|
|
7398
|
-
},
|
|
7399
|
-
...input.cursor && { offset: input.cursor }
|
|
7400
|
-
}
|
|
7401
|
-
});
|
|
7783
|
+
return fetchListApps({ imports, input, implementationIds });
|
|
7402
7784
|
}
|
|
7403
7785
|
});
|
|
7404
7786
|
var ListInputFieldsDescription = "Get the input fields required for a specific action";
|
|
@@ -8121,86 +8503,6 @@ var ListConnectionsQuerySchema = connections.ListConnectionsQuerySchema.omit({
|
|
|
8121
8503
|
// SDK specific property for pagination/iterable helpers
|
|
8122
8504
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
8123
8505
|
}).describe("List available connections with optional filtering");
|
|
8124
|
-
var RawConnectionSchema = connections.ConnectionSchema.extend({
|
|
8125
|
-
is_stale: zod.z.boolean().optional(),
|
|
8126
|
-
is_shared: zod.z.boolean().optional(),
|
|
8127
|
-
members: zod.z.array(zod.z.record(zod.z.string(), zod.z.any())).optional(),
|
|
8128
|
-
customuser_id: zod.z.number().nullable().optional(),
|
|
8129
|
-
customuser_public_id: zod.z.string().nullable().optional()
|
|
8130
|
-
});
|
|
8131
|
-
var RawConnectionsResponseSchema = connections.ConnectionsResponseSchema.extend({
|
|
8132
|
-
results: zod.z.array(RawConnectionSchema)
|
|
8133
|
-
});
|
|
8134
|
-
|
|
8135
|
-
// src/normalizers/shared.ts
|
|
8136
|
-
function fastifyToString(value) {
|
|
8137
|
-
if (value === void 0) {
|
|
8138
|
-
return void 0;
|
|
8139
|
-
}
|
|
8140
|
-
if (typeof value === "string") {
|
|
8141
|
-
return value;
|
|
8142
|
-
}
|
|
8143
|
-
if (value === null) {
|
|
8144
|
-
return "";
|
|
8145
|
-
}
|
|
8146
|
-
if (value instanceof Date) {
|
|
8147
|
-
return value.toISOString();
|
|
8148
|
-
}
|
|
8149
|
-
if (value instanceof RegExp) {
|
|
8150
|
-
return value.source;
|
|
8151
|
-
}
|
|
8152
|
-
try {
|
|
8153
|
-
return String(value.toString());
|
|
8154
|
-
} catch {
|
|
8155
|
-
return "[unserializable]";
|
|
8156
|
-
}
|
|
8157
|
-
}
|
|
8158
|
-
|
|
8159
|
-
// src/normalizers/connection.ts
|
|
8160
|
-
function normalizeConnectionItem({
|
|
8161
|
-
connection,
|
|
8162
|
-
appKey: providedAppKey,
|
|
8163
|
-
appVersion: providedAppVersion,
|
|
8164
|
-
adaptError
|
|
8165
|
-
}) {
|
|
8166
|
-
let appKey = providedAppKey;
|
|
8167
|
-
let appVersion = providedAppVersion;
|
|
8168
|
-
if (connection.selected_api && typeof connection.selected_api === "string") {
|
|
8169
|
-
const [extractedAppKey, extractedVersion] = splitVersionedKey(
|
|
8170
|
-
connection.selected_api
|
|
8171
|
-
);
|
|
8172
|
-
if (!appKey) {
|
|
8173
|
-
appKey = extractedAppKey;
|
|
8174
|
-
}
|
|
8175
|
-
if (!appVersion) {
|
|
8176
|
-
appVersion = extractedVersion;
|
|
8177
|
-
}
|
|
8178
|
-
}
|
|
8179
|
-
const {
|
|
8180
|
-
selected_api: selectedApi,
|
|
8181
|
-
customuser_id: profileId,
|
|
8182
|
-
id,
|
|
8183
|
-
account_id: accountId,
|
|
8184
|
-
...restOfConnection
|
|
8185
|
-
} = connection;
|
|
8186
|
-
const normalized = {
|
|
8187
|
-
...restOfConnection,
|
|
8188
|
-
id: String(id),
|
|
8189
|
-
account_id: String(accountId),
|
|
8190
|
-
implementation_id: selectedApi,
|
|
8191
|
-
title: connection.title || connection.label || void 0,
|
|
8192
|
-
is_stale: fastifyToString(connection.is_stale),
|
|
8193
|
-
is_expired: fastifyToString(connection.is_stale),
|
|
8194
|
-
is_shared: fastifyToString(connection.is_shared),
|
|
8195
|
-
members: fastifyToString(connection.members),
|
|
8196
|
-
customuser_public_id: fastifyToString(connection.customuser_public_id),
|
|
8197
|
-
expired_at: connection.marked_stale_at,
|
|
8198
|
-
app_key: appKey,
|
|
8199
|
-
app_version: appVersion,
|
|
8200
|
-
profile_id: profileId != null ? String(profileId) : void 0
|
|
8201
|
-
};
|
|
8202
|
-
return kitcore.createValidator(connections.ConnectionItemSchema, { adaptError })(normalized);
|
|
8203
|
-
}
|
|
8204
8506
|
function formatConnectionItem(item) {
|
|
8205
8507
|
const details = [];
|
|
8206
8508
|
const appKey = item.app_key ?? "unknown";
|
|
@@ -13294,6 +13596,7 @@ exports.triggerInboxResolver = triggerInboxResolver;
|
|
|
13294
13596
|
exports.triggerMessagesResolver = triggerMessagesResolver;
|
|
13295
13597
|
exports.updateTableRecordsPlugin = updateTableRecordsPlugin;
|
|
13296
13598
|
exports.workflowDraftIdResolver = workflowDraftIdResolver;
|
|
13599
|
+
exports.workflowDraftRevisionResolver = workflowDraftRevisionResolver;
|
|
13297
13600
|
exports.workflowIdResolver = workflowIdResolver;
|
|
13298
13601
|
exports.workflowRunIdResolver = workflowRunIdResolver;
|
|
13299
13602
|
exports.workflowVersionIdResolver = workflowVersionIdResolver;
|