@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @zapier/zapier-sdk
|
|
2
2
|
|
|
3
|
+
## 0.110.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 545562b: Experimental `createWorkflow` now supports optional creation-attribution metadata. Created, retrieved, and listed workflows retain attribution returned by the server.
|
|
8
|
+
|
|
9
|
+
## 0.110.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 58bd3f7: `listApps` and `getApp` now surface API errors as they are returned:
|
|
14
|
+
- Status codes and messages are preserved. Previously, some 4xx messages were
|
|
15
|
+
replaced with generic text and some 5xx responses were reported as generic
|
|
16
|
+
502 errors.
|
|
17
|
+
- A malformed response now throws `ZapierValidationError` instead of a generic
|
|
18
|
+
`TypeError`.
|
|
19
|
+
|
|
3
20
|
## 0.110.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
|
@@ -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.110.
|
|
2802
|
+
var SDK_VERSION = (typeof process !== "undefined" && process.env ? "0.110.2" : 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 {
|
|
@@ -7356,6 +7481,23 @@ var ListAppsSchema = apps.ListAppsQuerySchema.omit({
|
|
|
7356
7481
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
7357
7482
|
}).describe("List all available apps with optional filtering");
|
|
7358
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
|
+
});
|
|
7359
7501
|
var appItemFormatter = kitcore.defineFormatter({
|
|
7360
7502
|
format: ({ item }) => ({
|
|
7361
7503
|
title: item.title,
|
|
@@ -7368,10 +7510,237 @@ var appItemFormatter = kitcore.defineFormatter({
|
|
|
7368
7510
|
})
|
|
7369
7511
|
});
|
|
7370
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
|
+
|
|
7371
7735
|
// src/plugins/listApps/index.ts
|
|
7372
7736
|
var listAppsPlugin = kitcore.defineMethod({
|
|
7373
7737
|
name: "listApps",
|
|
7374
|
-
imports: [
|
|
7738
|
+
imports: [
|
|
7739
|
+
manifestPluginRef,
|
|
7740
|
+
apiPluginRef,
|
|
7741
|
+
sdkOptionsPluginRef,
|
|
7742
|
+
kitcore.coreOptionsPluginRef
|
|
7743
|
+
],
|
|
7375
7744
|
categories: ["app"],
|
|
7376
7745
|
itemType: "App",
|
|
7377
7746
|
inputSchema: ListAppsSchema,
|
|
@@ -7384,7 +7753,6 @@ var listAppsPlugin = kitcore.defineMethod({
|
|
|
7384
7753
|
defaultPageSize: DEFAULT_PAGE_SIZE
|
|
7385
7754
|
},
|
|
7386
7755
|
run: async ({ imports, input }) => {
|
|
7387
|
-
const api = imports.api;
|
|
7388
7756
|
const resolveAppKeys2 = imports.manifest.resolveAppKeys;
|
|
7389
7757
|
const appKeys = input.apps ?? input.appKeys ?? [];
|
|
7390
7758
|
const appLocators = await resolveAppKeys2({ appKeys: [...appKeys] });
|
|
@@ -7412,16 +7780,7 @@ var listAppsPlugin = kitcore.defineMethod({
|
|
|
7412
7780
|
const version = locator.version || "latest";
|
|
7413
7781
|
return `${locator.implementationName}@${version}`;
|
|
7414
7782
|
});
|
|
7415
|
-
return
|
|
7416
|
-
searchParams: {
|
|
7417
|
-
app_keys: implementationIds.join(","),
|
|
7418
|
-
...input.search && { search: input.search },
|
|
7419
|
-
...input.pageSize !== void 0 && {
|
|
7420
|
-
page_size: input.pageSize.toString()
|
|
7421
|
-
},
|
|
7422
|
-
...input.cursor && { offset: input.cursor }
|
|
7423
|
-
}
|
|
7424
|
-
});
|
|
7783
|
+
return fetchListApps({ imports, input, implementationIds });
|
|
7425
7784
|
}
|
|
7426
7785
|
});
|
|
7427
7786
|
var ListInputFieldsDescription = "Get the input fields required for a specific action";
|
|
@@ -8144,86 +8503,6 @@ var ListConnectionsQuerySchema = connections.ListConnectionsQuerySchema.omit({
|
|
|
8144
8503
|
// SDK specific property for pagination/iterable helpers
|
|
8145
8504
|
cursor: zod.z.string().optional().describe("Cursor to start from")
|
|
8146
8505
|
}).describe("List available connections with optional filtering");
|
|
8147
|
-
var RawConnectionSchema = connections.ConnectionSchema.extend({
|
|
8148
|
-
is_stale: zod.z.boolean().optional(),
|
|
8149
|
-
is_shared: zod.z.boolean().optional(),
|
|
8150
|
-
members: zod.z.array(zod.z.record(zod.z.string(), zod.z.any())).optional(),
|
|
8151
|
-
customuser_id: zod.z.number().nullable().optional(),
|
|
8152
|
-
customuser_public_id: zod.z.string().nullable().optional()
|
|
8153
|
-
});
|
|
8154
|
-
var RawConnectionsResponseSchema = connections.ConnectionsResponseSchema.extend({
|
|
8155
|
-
results: zod.z.array(RawConnectionSchema)
|
|
8156
|
-
});
|
|
8157
|
-
|
|
8158
|
-
// src/normalizers/shared.ts
|
|
8159
|
-
function fastifyToString(value) {
|
|
8160
|
-
if (value === void 0) {
|
|
8161
|
-
return void 0;
|
|
8162
|
-
}
|
|
8163
|
-
if (typeof value === "string") {
|
|
8164
|
-
return value;
|
|
8165
|
-
}
|
|
8166
|
-
if (value === null) {
|
|
8167
|
-
return "";
|
|
8168
|
-
}
|
|
8169
|
-
if (value instanceof Date) {
|
|
8170
|
-
return value.toISOString();
|
|
8171
|
-
}
|
|
8172
|
-
if (value instanceof RegExp) {
|
|
8173
|
-
return value.source;
|
|
8174
|
-
}
|
|
8175
|
-
try {
|
|
8176
|
-
return String(value.toString());
|
|
8177
|
-
} catch {
|
|
8178
|
-
return "[unserializable]";
|
|
8179
|
-
}
|
|
8180
|
-
}
|
|
8181
|
-
|
|
8182
|
-
// src/normalizers/connection.ts
|
|
8183
|
-
function normalizeConnectionItem({
|
|
8184
|
-
connection,
|
|
8185
|
-
appKey: providedAppKey,
|
|
8186
|
-
appVersion: providedAppVersion,
|
|
8187
|
-
adaptError
|
|
8188
|
-
}) {
|
|
8189
|
-
let appKey = providedAppKey;
|
|
8190
|
-
let appVersion = providedAppVersion;
|
|
8191
|
-
if (connection.selected_api && typeof connection.selected_api === "string") {
|
|
8192
|
-
const [extractedAppKey, extractedVersion] = splitVersionedKey(
|
|
8193
|
-
connection.selected_api
|
|
8194
|
-
);
|
|
8195
|
-
if (!appKey) {
|
|
8196
|
-
appKey = extractedAppKey;
|
|
8197
|
-
}
|
|
8198
|
-
if (!appVersion) {
|
|
8199
|
-
appVersion = extractedVersion;
|
|
8200
|
-
}
|
|
8201
|
-
}
|
|
8202
|
-
const {
|
|
8203
|
-
selected_api: selectedApi,
|
|
8204
|
-
customuser_id: profileId,
|
|
8205
|
-
id,
|
|
8206
|
-
account_id: accountId,
|
|
8207
|
-
...restOfConnection
|
|
8208
|
-
} = connection;
|
|
8209
|
-
const normalized = {
|
|
8210
|
-
...restOfConnection,
|
|
8211
|
-
id: String(id),
|
|
8212
|
-
account_id: String(accountId),
|
|
8213
|
-
implementation_id: selectedApi,
|
|
8214
|
-
title: connection.title || connection.label || void 0,
|
|
8215
|
-
is_stale: fastifyToString(connection.is_stale),
|
|
8216
|
-
is_expired: fastifyToString(connection.is_stale),
|
|
8217
|
-
is_shared: fastifyToString(connection.is_shared),
|
|
8218
|
-
members: fastifyToString(connection.members),
|
|
8219
|
-
customuser_public_id: fastifyToString(connection.customuser_public_id),
|
|
8220
|
-
expired_at: connection.marked_stale_at,
|
|
8221
|
-
app_key: appKey,
|
|
8222
|
-
app_version: appVersion,
|
|
8223
|
-
profile_id: profileId != null ? String(profileId) : void 0
|
|
8224
|
-
};
|
|
8225
|
-
return kitcore.createValidator(connections.ConnectionItemSchema, { adaptError })(normalized);
|
|
8226
|
-
}
|
|
8227
8506
|
function formatConnectionItem(item) {
|
|
8228
8507
|
const details = [];
|
|
8229
8508
|
const appKey = item.app_key ?? "unknown";
|
|
@@ -13145,6 +13424,7 @@ exports.RelayFetchSchema = RelayFetchSchema;
|
|
|
13145
13424
|
exports.RelayRequestSchema = RelayRequestSchema;
|
|
13146
13425
|
exports.ResolvedCredentialsSchema = ResolvedCredentialsSchema;
|
|
13147
13426
|
exports.SDK_OPTIONS_ID = SDK_OPTIONS_ID;
|
|
13427
|
+
exports.SDK_VERSION = SDK_VERSION;
|
|
13148
13428
|
exports.TablePropertySchema = TablePropertySchema;
|
|
13149
13429
|
exports.TablesPropertySchema = TablesPropertySchema;
|
|
13150
13430
|
exports.TriggerInboxKeyPropertySchema = TriggerInboxKeyPropertySchema;
|