@zapier/zapier-sdk 0.16.1 → 0.16.3
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 +15 -0
- package/dist/index.cjs +38 -13
- package/dist/index.mjs +38 -13
- package/dist/plugins/eventEmission/index.d.ts.map +1 -1
- package/dist/plugins/eventEmission/index.js +21 -5
- package/dist/plugins/eventEmission/transport.d.ts.map +1 -1
- package/dist/plugins/eventEmission/transport.js +6 -1
- package/dist/temporary-internal-core/handlers/listApps.d.ts.map +1 -1
- package/dist/temporary-internal-core/handlers/listApps.js +15 -2
- package/dist/temporary-internal-core/handlers/listApps.test.js +40 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @zapier/zapier-sdk
|
|
2
2
|
|
|
3
|
+
## 0.16.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 870f2aa: Fix CLI process hanging after login and on signal handling
|
|
8
|
+
- Clear login timeout timer after successful authentication to allow process exit
|
|
9
|
+
- Use timer.unref() on telemetry timeouts so they don't block process exit
|
|
10
|
+
- Add explicit process.exit() in signal handlers with correct exit codes
|
|
11
|
+
|
|
12
|
+
## 0.16.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 93cbb3c: Fix search to prefer public app versions over private when user has access to both
|
|
17
|
+
|
|
3
18
|
## 0.16.1
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -3897,8 +3897,17 @@ async function augmentWithSearchResults({
|
|
|
3897
3897
|
searchParams: { term: searchTerm }
|
|
3898
3898
|
}
|
|
3899
3899
|
);
|
|
3900
|
-
const
|
|
3901
|
-
|
|
3900
|
+
const byImplementationName = /* @__PURE__ */ new Map();
|
|
3901
|
+
for (const result of searchResponse.results) {
|
|
3902
|
+
const [implementationName] = splitVersionedKey2(result.id);
|
|
3903
|
+
const isPublic = result.visibility === "public";
|
|
3904
|
+
const existing = byImplementationName.get(implementationName);
|
|
3905
|
+
if (!existing || isPublic && !existing.isPublic) {
|
|
3906
|
+
byImplementationName.set(implementationName, { result, isPublic });
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
const searchResults = Array.from(byImplementationName.values()).map(
|
|
3910
|
+
(entry) => transformImplementationMetaToAppItem(entry.result)
|
|
3902
3911
|
);
|
|
3903
3912
|
const implementationNameSet = new Set(
|
|
3904
3913
|
implementationIds.map((id) => {
|
|
@@ -4911,7 +4920,12 @@ var HttpTransport = class {
|
|
|
4911
4920
|
}
|
|
4912
4921
|
}
|
|
4913
4922
|
async delay(ms) {
|
|
4914
|
-
return new Promise((resolve2) =>
|
|
4923
|
+
return new Promise((resolve2) => {
|
|
4924
|
+
const timer = setTimeout(resolve2, ms);
|
|
4925
|
+
if (typeof timer.unref === "function") {
|
|
4926
|
+
timer.unref();
|
|
4927
|
+
}
|
|
4928
|
+
});
|
|
4915
4929
|
}
|
|
4916
4930
|
};
|
|
4917
4931
|
var ConsoleTransport = class {
|
|
@@ -5018,7 +5032,7 @@ function getCpuTime() {
|
|
|
5018
5032
|
|
|
5019
5033
|
// package.json
|
|
5020
5034
|
var package_default = {
|
|
5021
|
-
version: "0.16.
|
|
5035
|
+
version: "0.16.3"};
|
|
5022
5036
|
|
|
5023
5037
|
// src/plugins/eventEmission/builders.ts
|
|
5024
5038
|
function createBaseEvent(context = {}) {
|
|
@@ -5302,9 +5316,12 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
5302
5316
|
try {
|
|
5303
5317
|
await Promise.race([
|
|
5304
5318
|
transport.emit(ERROR_OCCURRED_EVENT_SUBJECT, errorEvent),
|
|
5305
|
-
new Promise(
|
|
5306
|
-
|
|
5307
|
-
|
|
5319
|
+
new Promise((resolve2) => {
|
|
5320
|
+
const timer = setTimeout(resolve2, TELEMETRY_EMIT_TIMEOUT_MS);
|
|
5321
|
+
if (typeof timer.unref === "function") {
|
|
5322
|
+
timer.unref();
|
|
5323
|
+
}
|
|
5324
|
+
})
|
|
5308
5325
|
]);
|
|
5309
5326
|
} catch {
|
|
5310
5327
|
}
|
|
@@ -5334,9 +5351,12 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
5334
5351
|
try {
|
|
5335
5352
|
await Promise.race([
|
|
5336
5353
|
transport.emit(ERROR_OCCURRED_EVENT_SUBJECT, errorEvent),
|
|
5337
|
-
new Promise(
|
|
5338
|
-
|
|
5339
|
-
|
|
5354
|
+
new Promise((resolve2) => {
|
|
5355
|
+
const timer = setTimeout(resolve2, TELEMETRY_EMIT_TIMEOUT_MS);
|
|
5356
|
+
if (typeof timer.unref === "function") {
|
|
5357
|
+
timer.unref();
|
|
5358
|
+
}
|
|
5359
|
+
})
|
|
5340
5360
|
]);
|
|
5341
5361
|
} catch {
|
|
5342
5362
|
}
|
|
@@ -5359,12 +5379,17 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
5359
5379
|
try {
|
|
5360
5380
|
await Promise.race([
|
|
5361
5381
|
transport.emit(APPLICATION_LIFECYCLE_EVENT_SUBJECT, signalEvent),
|
|
5362
|
-
new Promise(
|
|
5363
|
-
|
|
5364
|
-
|
|
5382
|
+
new Promise((resolve2) => {
|
|
5383
|
+
const timer = setTimeout(resolve2, TELEMETRY_EMIT_TIMEOUT_MS);
|
|
5384
|
+
if (typeof timer.unref === "function") {
|
|
5385
|
+
timer.unref();
|
|
5386
|
+
}
|
|
5387
|
+
})
|
|
5365
5388
|
]);
|
|
5366
5389
|
} catch {
|
|
5367
5390
|
}
|
|
5391
|
+
const exitCode = signal === "SIGINT" ? 130 : 143;
|
|
5392
|
+
process.exit(exitCode);
|
|
5368
5393
|
};
|
|
5369
5394
|
["SIGINT", "SIGTERM"].forEach((signal) => {
|
|
5370
5395
|
process.on(signal, () => handleSignal(signal));
|
package/dist/index.mjs
CHANGED
|
@@ -3875,8 +3875,17 @@ async function augmentWithSearchResults({
|
|
|
3875
3875
|
searchParams: { term: searchTerm }
|
|
3876
3876
|
}
|
|
3877
3877
|
);
|
|
3878
|
-
const
|
|
3879
|
-
|
|
3878
|
+
const byImplementationName = /* @__PURE__ */ new Map();
|
|
3879
|
+
for (const result of searchResponse.results) {
|
|
3880
|
+
const [implementationName] = splitVersionedKey2(result.id);
|
|
3881
|
+
const isPublic = result.visibility === "public";
|
|
3882
|
+
const existing = byImplementationName.get(implementationName);
|
|
3883
|
+
if (!existing || isPublic && !existing.isPublic) {
|
|
3884
|
+
byImplementationName.set(implementationName, { result, isPublic });
|
|
3885
|
+
}
|
|
3886
|
+
}
|
|
3887
|
+
const searchResults = Array.from(byImplementationName.values()).map(
|
|
3888
|
+
(entry) => transformImplementationMetaToAppItem(entry.result)
|
|
3880
3889
|
);
|
|
3881
3890
|
const implementationNameSet = new Set(
|
|
3882
3891
|
implementationIds.map((id) => {
|
|
@@ -4889,7 +4898,12 @@ var HttpTransport = class {
|
|
|
4889
4898
|
}
|
|
4890
4899
|
}
|
|
4891
4900
|
async delay(ms) {
|
|
4892
|
-
return new Promise((resolve2) =>
|
|
4901
|
+
return new Promise((resolve2) => {
|
|
4902
|
+
const timer = setTimeout(resolve2, ms);
|
|
4903
|
+
if (typeof timer.unref === "function") {
|
|
4904
|
+
timer.unref();
|
|
4905
|
+
}
|
|
4906
|
+
});
|
|
4893
4907
|
}
|
|
4894
4908
|
};
|
|
4895
4909
|
var ConsoleTransport = class {
|
|
@@ -4996,7 +5010,7 @@ function getCpuTime() {
|
|
|
4996
5010
|
|
|
4997
5011
|
// package.json
|
|
4998
5012
|
var package_default = {
|
|
4999
|
-
version: "0.16.
|
|
5013
|
+
version: "0.16.3"};
|
|
5000
5014
|
|
|
5001
5015
|
// src/plugins/eventEmission/builders.ts
|
|
5002
5016
|
function createBaseEvent(context = {}) {
|
|
@@ -5280,9 +5294,12 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
5280
5294
|
try {
|
|
5281
5295
|
await Promise.race([
|
|
5282
5296
|
transport.emit(ERROR_OCCURRED_EVENT_SUBJECT, errorEvent),
|
|
5283
|
-
new Promise(
|
|
5284
|
-
|
|
5285
|
-
|
|
5297
|
+
new Promise((resolve2) => {
|
|
5298
|
+
const timer = setTimeout(resolve2, TELEMETRY_EMIT_TIMEOUT_MS);
|
|
5299
|
+
if (typeof timer.unref === "function") {
|
|
5300
|
+
timer.unref();
|
|
5301
|
+
}
|
|
5302
|
+
})
|
|
5286
5303
|
]);
|
|
5287
5304
|
} catch {
|
|
5288
5305
|
}
|
|
@@ -5312,9 +5329,12 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
5312
5329
|
try {
|
|
5313
5330
|
await Promise.race([
|
|
5314
5331
|
transport.emit(ERROR_OCCURRED_EVENT_SUBJECT, errorEvent),
|
|
5315
|
-
new Promise(
|
|
5316
|
-
|
|
5317
|
-
|
|
5332
|
+
new Promise((resolve2) => {
|
|
5333
|
+
const timer = setTimeout(resolve2, TELEMETRY_EMIT_TIMEOUT_MS);
|
|
5334
|
+
if (typeof timer.unref === "function") {
|
|
5335
|
+
timer.unref();
|
|
5336
|
+
}
|
|
5337
|
+
})
|
|
5318
5338
|
]);
|
|
5319
5339
|
} catch {
|
|
5320
5340
|
}
|
|
@@ -5337,12 +5357,17 @@ var eventEmissionPlugin = ({ context }) => {
|
|
|
5337
5357
|
try {
|
|
5338
5358
|
await Promise.race([
|
|
5339
5359
|
transport.emit(APPLICATION_LIFECYCLE_EVENT_SUBJECT, signalEvent),
|
|
5340
|
-
new Promise(
|
|
5341
|
-
|
|
5342
|
-
|
|
5360
|
+
new Promise((resolve2) => {
|
|
5361
|
+
const timer = setTimeout(resolve2, TELEMETRY_EMIT_TIMEOUT_MS);
|
|
5362
|
+
if (typeof timer.unref === "function") {
|
|
5363
|
+
timer.unref();
|
|
5364
|
+
}
|
|
5365
|
+
})
|
|
5343
5366
|
]);
|
|
5344
5367
|
} catch {
|
|
5345
5368
|
}
|
|
5369
|
+
const exitCode = signal === "SIGINT" ? 130 : 143;
|
|
5370
|
+
process.exit(exitCode);
|
|
5346
5371
|
};
|
|
5347
5372
|
["SIGINT", "SIGTERM"].forEach((signal) => {
|
|
5348
5373
|
process.on(signal, () => handleSignal(signal));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/eventEmission/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAWnE,OAAO,KAAK,EAAgB,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAMnE,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAGD,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE;QACb,SAAS,EAAE,cAAc,CAAC;QAC1B,MAAM,EAAE,mBAAmB,CAAC;QAE5B,IAAI,CAAC,CAAC,SAAS,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;QAErD,eAAe,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;QAEtC,gBAAgB,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAAC;KACrD,CAAC;CACH;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,oBAAoB,CAAC;CAC/B;AA6FD,eAAO,MAAM,mBAAmB,EAAE,MAAM,CACtC,EAAE,EACF;IACE,OAAO,EAAE;QACP,aAAa,CAAC,EAAE,mBAAmB,CAAC;QACpC,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH,EACD,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EACf,eAAe,EACf,sBAAsB,GACvB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,cAAc,SAAS,CAAC"}
|
|
@@ -216,13 +216,17 @@ export const eventEmissionPlugin = ({ context }) => {
|
|
|
216
216
|
try {
|
|
217
217
|
await Promise.race([
|
|
218
218
|
transport.emit(ERROR_OCCURRED_EVENT_SUBJECT, errorEvent),
|
|
219
|
-
new Promise((resolve) =>
|
|
219
|
+
new Promise((resolve) => {
|
|
220
|
+
const timer = setTimeout(resolve, TELEMETRY_EMIT_TIMEOUT_MS);
|
|
221
|
+
if (typeof timer.unref === "function") {
|
|
222
|
+
timer.unref();
|
|
223
|
+
}
|
|
224
|
+
}),
|
|
220
225
|
]);
|
|
221
226
|
}
|
|
222
227
|
catch {
|
|
223
228
|
// Silently ignore telemetry failures
|
|
224
229
|
}
|
|
225
|
-
// Let Node.js exit naturally after all handlers complete
|
|
226
230
|
});
|
|
227
231
|
// Handle unhandled promise rejections
|
|
228
232
|
process.on("unhandledRejection", async (reason, promise) => {
|
|
@@ -256,7 +260,12 @@ export const eventEmissionPlugin = ({ context }) => {
|
|
|
256
260
|
try {
|
|
257
261
|
await Promise.race([
|
|
258
262
|
transport.emit(ERROR_OCCURRED_EVENT_SUBJECT, errorEvent),
|
|
259
|
-
new Promise((resolve) =>
|
|
263
|
+
new Promise((resolve) => {
|
|
264
|
+
const timer = setTimeout(resolve, TELEMETRY_EMIT_TIMEOUT_MS);
|
|
265
|
+
if (typeof timer.unref === "function") {
|
|
266
|
+
timer.unref();
|
|
267
|
+
}
|
|
268
|
+
}),
|
|
260
269
|
]);
|
|
261
270
|
}
|
|
262
271
|
catch {
|
|
@@ -285,13 +294,20 @@ export const eventEmissionPlugin = ({ context }) => {
|
|
|
285
294
|
try {
|
|
286
295
|
await Promise.race([
|
|
287
296
|
transport.emit(APPLICATION_LIFECYCLE_EVENT_SUBJECT, signalEvent),
|
|
288
|
-
new Promise((resolve) =>
|
|
297
|
+
new Promise((resolve) => {
|
|
298
|
+
const timer = setTimeout(resolve, TELEMETRY_EMIT_TIMEOUT_MS);
|
|
299
|
+
if (typeof timer.unref === "function") {
|
|
300
|
+
timer.unref();
|
|
301
|
+
}
|
|
302
|
+
}),
|
|
289
303
|
]);
|
|
290
304
|
}
|
|
291
305
|
catch {
|
|
292
306
|
// Silently ignore telemetry failures
|
|
293
307
|
}
|
|
294
|
-
//
|
|
308
|
+
// Exit with appropriate code (128 + signal number)
|
|
309
|
+
const exitCode = signal === "SIGINT" ? 130 : 143;
|
|
310
|
+
process.exit(exitCode);
|
|
295
311
|
};
|
|
296
312
|
// Register signal handlers
|
|
297
313
|
["SIGINT", "SIGTERM"].forEach((signal) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/plugins/eventEmission/transport.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,CAAC,SAAS,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9D,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAGD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAGD,qBAAa,aAAc,YAAW,cAAc;IAEhD,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC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C,IAAI,CAAC,CAAC,SAAS,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAUpE;AAGD,qBAAa,aAAc,YAAW,cAAc;IAC5C,IAAI,CAAC,CAAC,SAAS,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAGtE;AAGD,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,cAAc,CAyBvE"}
|
|
@@ -48,7 +48,12 @@ export class HttpTransport {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
async delay(ms) {
|
|
51
|
-
return new Promise((resolve) =>
|
|
51
|
+
return new Promise((resolve) => {
|
|
52
|
+
const timer = setTimeout(resolve, ms);
|
|
53
|
+
if (typeof timer.unref === "function") {
|
|
54
|
+
timer.unref();
|
|
55
|
+
}
|
|
56
|
+
});
|
|
52
57
|
}
|
|
53
58
|
}
|
|
54
59
|
// Console Transport - logs events to console (for development)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listApps.d.ts","sourceRoot":"","sources":["../../../src/temporary-internal-core/handlers/listApps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACtB,MAAM,iBAAiB,CAAC;AAkBzB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,CAAC,GAAG,OAAO,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GAClD,OAAO,CAAC,CAAC,CAAC,CAAC;CACf;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,UAAU,EAAE,UAAU,CAAC;CACxB;
|
|
1
|
+
{"version":3,"file":"listApps.d.ts","sourceRoot":"","sources":["../../../src/temporary-internal-core/handlers/listApps.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAEL,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACtB,MAAM,iBAAiB,CAAC;AAkBzB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,CAAC,GAAG,OAAO,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GAClD,OAAO,CAAC,CAAC,CAAC,CAAC;CACf;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,mBAAoB,SAAQ,WAAW;IACtD,UAAU,EAAE,UAAU,CAAC;CACxB;AA2ED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,EAAE,OAAO,CAClC,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,CA+EpB,CAAC"}
|
|
@@ -25,13 +25,26 @@ const DEFAULT_PAGE_SIZE = 20;
|
|
|
25
25
|
* Augments implementation IDs with search results
|
|
26
26
|
*
|
|
27
27
|
* Calls the search endpoint and merges results with existing implementation IDs,
|
|
28
|
-
* deduplicating by implementation name (without version).
|
|
28
|
+
* deduplicating by implementation name (without version) and preferring public versions.
|
|
29
29
|
*/
|
|
30
30
|
async function augmentWithSearchResults({ searchTerm, implementationIds, httpClient, }) {
|
|
31
31
|
const searchResponse = await httpClient.get("/zapier/api/v4/implementations-meta/search/", {
|
|
32
32
|
searchParams: { term: searchTerm },
|
|
33
33
|
});
|
|
34
|
-
|
|
34
|
+
// Deduplicate by implementation name, preferring public versions
|
|
35
|
+
// This ensures that when a user has access to both a private version (e.g., 1.0.17)
|
|
36
|
+
// and a public version (e.g., 1.1.0), we use the public one for search results
|
|
37
|
+
const byImplementationName = new Map();
|
|
38
|
+
for (const result of searchResponse.results) {
|
|
39
|
+
const [implementationName] = splitVersionedKey(result.id);
|
|
40
|
+
const isPublic = result.visibility === "public";
|
|
41
|
+
const existing = byImplementationName.get(implementationName);
|
|
42
|
+
// Take this result if we don't have one yet, or if this one is public and existing is not
|
|
43
|
+
if (!existing || (isPublic && !existing.isPublic)) {
|
|
44
|
+
byImplementationName.set(implementationName, { result, isPublic });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const searchResults = Array.from(byImplementationName.values()).map((entry) => transformImplementationMetaToAppItem(entry.result));
|
|
35
48
|
const implementationNameSet = new Set(implementationIds.map((id) => {
|
|
36
49
|
const [name] = splitVersionedKey(id);
|
|
37
50
|
return name;
|
|
@@ -2,13 +2,14 @@ import { describe, it, expect, vi } from "vitest";
|
|
|
2
2
|
import { handleListApps, } from "./listApps";
|
|
3
3
|
import { ListAppsResponseSchema, } from "../schemas/apps";
|
|
4
4
|
describe("handleListApps", () => {
|
|
5
|
-
const mockImplementation = (id, name) => ({
|
|
5
|
+
const mockImplementation = (id, name, visibility = "public") => ({
|
|
6
6
|
id,
|
|
7
7
|
name,
|
|
8
8
|
slug: name.toLowerCase().replace(/\s+/g, "-"),
|
|
9
9
|
description: `${name} description`,
|
|
10
10
|
primary_color: "#000000",
|
|
11
11
|
categories: [{ id: 1, name: "test", slug: "test" }],
|
|
12
|
+
visibility,
|
|
12
13
|
});
|
|
13
14
|
describe("pageSize handling", () => {
|
|
14
15
|
it("should use default pageSize of 20 when not provided", async () => {
|
|
@@ -186,6 +187,44 @@ describe("handleListApps", () => {
|
|
|
186
187
|
}),
|
|
187
188
|
}));
|
|
188
189
|
});
|
|
190
|
+
it("should prefer public version when search returns multiple versions of same app", async () => {
|
|
191
|
+
// Simulates a user having access to both private (1.0.17) and public (1.1.0) versions
|
|
192
|
+
const mockSearchResponse = {
|
|
193
|
+
count: 2,
|
|
194
|
+
results: [
|
|
195
|
+
mockImplementation("LumAppsCLIAPI@1.0.17", "LumApps (1.0.17)", "private"),
|
|
196
|
+
mockImplementation("LumAppsCLIAPI@1.1.0", "LumApps", "public"),
|
|
197
|
+
],
|
|
198
|
+
};
|
|
199
|
+
const mockLookupResponse = {
|
|
200
|
+
count: 1,
|
|
201
|
+
results: [
|
|
202
|
+
mockImplementation("LumAppsCLIAPI@1.1.0", "LumApps", "public"),
|
|
203
|
+
],
|
|
204
|
+
next: null,
|
|
205
|
+
};
|
|
206
|
+
const mockHttpClient = {
|
|
207
|
+
get: vi
|
|
208
|
+
.fn()
|
|
209
|
+
.mockResolvedValueOnce(mockSearchResponse)
|
|
210
|
+
.mockResolvedValueOnce(mockLookupResponse),
|
|
211
|
+
};
|
|
212
|
+
await handleListApps({
|
|
213
|
+
request: {
|
|
214
|
+
implementationIds: [],
|
|
215
|
+
search: "lumapps",
|
|
216
|
+
pageSize: undefined,
|
|
217
|
+
cursor: undefined,
|
|
218
|
+
},
|
|
219
|
+
deps: { httpClient: mockHttpClient },
|
|
220
|
+
});
|
|
221
|
+
// Should request the public version (1.1.0), not the private one (1.0.17)
|
|
222
|
+
expect(mockHttpClient.get).toHaveBeenNthCalledWith(2, "/zapier/api/v4/implementations-meta/lookup/", expect.objectContaining({
|
|
223
|
+
searchParams: expect.objectContaining({
|
|
224
|
+
selected_apis: "LumAppsCLIAPI@1.1.0",
|
|
225
|
+
}),
|
|
226
|
+
}));
|
|
227
|
+
});
|
|
189
228
|
});
|
|
190
229
|
describe("specific implementation IDs", () => {
|
|
191
230
|
it("should fetch specific apps when implementationIds provided", async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zapier/zapier-sdk",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.3",
|
|
4
4
|
"description": "Complete Zapier SDK - combines all Zapier SDK packages",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"tsup": "^8.5.0",
|
|
52
52
|
"typescript": "^5.8.3",
|
|
53
53
|
"vitest": "^3.2.3",
|
|
54
|
-
"@zapier/zapier-sdk-cli-login": "0.3.
|
|
54
|
+
"@zapier/zapier-sdk-cli-login": "0.3.7"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "tsup",
|