@zapier/zapier-sdk 0.16.1 → 0.16.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @zapier/zapier-sdk
2
2
 
3
+ ## 0.16.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 93cbb3c: Fix search to prefer public app versions over private when user has access to both
8
+
3
9
  ## 0.16.1
4
10
 
5
11
  ### 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 searchResults = searchResponse.results.map(
3901
- transformImplementationMetaToAppItem
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) => {
@@ -5018,7 +5027,7 @@ function getCpuTime() {
5018
5027
 
5019
5028
  // package.json
5020
5029
  var package_default = {
5021
- version: "0.16.1"};
5030
+ version: "0.16.2"};
5022
5031
 
5023
5032
  // src/plugins/eventEmission/builders.ts
5024
5033
  function createBaseEvent(context = {}) {
package/dist/index.mjs CHANGED
@@ -3875,8 +3875,17 @@ async function augmentWithSearchResults({
3875
3875
  searchParams: { term: searchTerm }
3876
3876
  }
3877
3877
  );
3878
- const searchResults = searchResponse.results.map(
3879
- transformImplementationMetaToAppItem
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) => {
@@ -4996,7 +5005,7 @@ function getCpuTime() {
4996
5005
 
4997
5006
  // package.json
4998
5007
  var package_default = {
4999
- version: "0.16.1"};
5008
+ version: "0.16.2"};
5000
5009
 
5001
5010
  // src/plugins/eventEmission/builders.ts
5002
5011
  function createBaseEvent(context = {}) {
@@ -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;AAwDD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,cAAc,EAAE,OAAO,CAClC,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,CA+EpB,CAAC"}
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
- const searchResults = searchResponse.results.map(transformImplementationMetaToAppItem);
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.1",
3
+ "version": "0.16.2",
4
4
  "description": "Complete Zapier SDK - combines all Zapier SDK packages",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",