@zapier/zapier-sdk 1.0.0 → 1.0.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 +12 -0
- package/README.md +12 -3
- package/dist/index.cjs +6 -3
- package/dist/index.mjs +6 -3
- package/dist/plugins/manifest/index.d.ts.map +1 -1
- package/dist/plugins/manifest/index.js +10 -2
- package/dist/plugins/manifest/index.test.js +46 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @zapier/zapier-sdk
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 00ef417: Resolved confusing "Failed to read manifest from .zapierrc" error
|
|
8
|
+
|
|
9
|
+
## 1.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- aba842a: Updated docs to remove reference to deprecated token option.
|
|
14
|
+
|
|
3
15
|
## 1.0.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -69,12 +69,21 @@ npx zapier-sdk add slack google-sheets --types-output ./types
|
|
|
69
69
|
import { createZapierSdk } from "@zapier/zapier-sdk";
|
|
70
70
|
|
|
71
71
|
// ######## Initialize Zapier SDK ########
|
|
72
|
-
// Running `zapier-sdk login` authenticates through your browser,
|
|
72
|
+
// Option 1: Running `zapier-sdk login` authenticates through your browser,
|
|
73
|
+
// automatically handling token management.
|
|
73
74
|
const zapier = createZapierSdk();
|
|
74
75
|
|
|
75
|
-
// Option 2: Manually provide a token
|
|
76
|
+
// Option 2: Manually provide a token.
|
|
76
77
|
// const zapier = createZapierSdk({
|
|
77
|
-
//
|
|
78
|
+
// credentials: "your_zapier_token_here", // or use ZAPIER_CREDENTIALS env var
|
|
79
|
+
// });
|
|
80
|
+
|
|
81
|
+
// Option 3: Manually provide a client ID and client secret.
|
|
82
|
+
// const zapier = createZapierSdk({
|
|
83
|
+
// credentials: {
|
|
84
|
+
// clientId: "your_client_id_here", // or use ZAPIER_CREDENTIALS_CLIENT_ID env var
|
|
85
|
+
// clientSecret: "your_client_secret_here", // or use ZAPIER_CREDENTIALS_CLIENT_SECRET env var
|
|
86
|
+
// },
|
|
78
87
|
// });
|
|
79
88
|
|
|
80
89
|
// ######## Access Apps ########
|
package/dist/index.cjs
CHANGED
|
@@ -2759,8 +2759,11 @@ async function readManifestFromFile(filePath) {
|
|
|
2759
2759
|
const resolvedPath = await resolve(filePath);
|
|
2760
2760
|
const content = await readFile(resolvedPath);
|
|
2761
2761
|
return parseManifestContent(content, resolvedPath);
|
|
2762
|
-
} catch {
|
|
2763
|
-
|
|
2762
|
+
} catch (error) {
|
|
2763
|
+
const isFileNotFound = error && typeof error === "object" && "code" in error && error.code === "ENOENT" || error instanceof Error && error.message.includes("File not found");
|
|
2764
|
+
if (!isFileNotFound) {
|
|
2765
|
+
console.warn(`\u26A0\uFE0F Failed to read manifest from ${filePath}`);
|
|
2766
|
+
}
|
|
2764
2767
|
return null;
|
|
2765
2768
|
}
|
|
2766
2769
|
}
|
|
@@ -4751,7 +4754,7 @@ function getCpuTime() {
|
|
|
4751
4754
|
|
|
4752
4755
|
// package.json
|
|
4753
4756
|
var package_default = {
|
|
4754
|
-
version: "1.0.
|
|
4757
|
+
version: "1.0.2"};
|
|
4755
4758
|
|
|
4756
4759
|
// src/plugins/eventEmission/builders.ts
|
|
4757
4760
|
function createBaseEvent(context = {}) {
|
package/dist/index.mjs
CHANGED
|
@@ -2737,8 +2737,11 @@ async function readManifestFromFile(filePath) {
|
|
|
2737
2737
|
const resolvedPath = await resolve(filePath);
|
|
2738
2738
|
const content = await readFile(resolvedPath);
|
|
2739
2739
|
return parseManifestContent(content, resolvedPath);
|
|
2740
|
-
} catch {
|
|
2741
|
-
|
|
2740
|
+
} catch (error) {
|
|
2741
|
+
const isFileNotFound = error && typeof error === "object" && "code" in error && error.code === "ENOENT" || error instanceof Error && error.message.includes("File not found");
|
|
2742
|
+
if (!isFileNotFound) {
|
|
2743
|
+
console.warn(`\u26A0\uFE0F Failed to read manifest from ${filePath}`);
|
|
2744
|
+
}
|
|
2742
2745
|
return null;
|
|
2743
2746
|
}
|
|
2744
2747
|
}
|
|
@@ -4729,7 +4732,7 @@ function getCpuTime() {
|
|
|
4729
4732
|
|
|
4730
4733
|
// package.json
|
|
4731
4734
|
var package_default = {
|
|
4732
|
-
version: "1.0.
|
|
4735
|
+
version: "1.0.2"};
|
|
4733
4736
|
|
|
4734
4737
|
// src/plugins/eventEmission/builders.ts
|
|
4735
4738
|
function createBaseEvent(context = {}) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/manifest/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,4BAA4B,EAC5B,QAAQ,EACR,aAAa,EACb,2BAA2B,EAC3B,cAAc,EACd,WAAW,EACZ,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAgB3C,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,aAAa,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,WAAW,yBAAyB;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,M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AM,EAAE,aAAa,CAAC,GAAG,IAAI,CAAC;QACrC,oBAAoB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;KACtE,CAAC;CACH;AA2BD;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAoB1B;AAcD;;;GAGG;AACH,wBAAsB,4BAA4B,CAAC,EACjD,MAAM,EACN,GAAG,GACJ,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,SAAS,CAAC;CAChB,GAAG,OAAO,CAAC,MAAM,CAAC,CAkClB;AAoCD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,QAAQ,GACT,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;CACpB,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,IAAI,CAyBjC;AA8GD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAEtE,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,EAAE,EAAE,sBAAsB;AAC1B;IAAE,GAAG,EAAE,SAAS,CAAA;CAAE,EAClB,sBAAsB,CAsPvB,CAAC"}
|
|
@@ -35,8 +35,16 @@ export async function readManifestFromFile(filePath) {
|
|
|
35
35
|
const content = await readFile(resolvedPath);
|
|
36
36
|
return parseManifestContent(content, resolvedPath);
|
|
37
37
|
}
|
|
38
|
-
catch {
|
|
39
|
-
|
|
38
|
+
catch (error) {
|
|
39
|
+
// Silently return null for "file not found" errors (expected for first-time users)
|
|
40
|
+
const isFileNotFound = (error &&
|
|
41
|
+
typeof error === "object" &&
|
|
42
|
+
"code" in error &&
|
|
43
|
+
error.code === "ENOENT") ||
|
|
44
|
+
(error instanceof Error && error.message.includes("File not found"));
|
|
45
|
+
if (!isFileNotFound) {
|
|
46
|
+
console.warn(`⚠️ Failed to read manifest from ${filePath}`);
|
|
47
|
+
}
|
|
40
48
|
return null;
|
|
41
49
|
}
|
|
42
50
|
}
|
|
@@ -247,14 +247,35 @@ describe("manifestPlugin", () => {
|
|
|
247
247
|
expect(mockResolve).toHaveBeenCalledWith("manifest.json");
|
|
248
248
|
expect(mockReadFile).toHaveBeenCalledWith("/resolved/manifest.json");
|
|
249
249
|
});
|
|
250
|
-
it("should
|
|
251
|
-
|
|
250
|
+
it("should silently return null when file does not exist (ENOENT)", async () => {
|
|
251
|
+
const enoentError = Object.assign(new Error("ENOENT: no such file"), {
|
|
252
|
+
code: "ENOENT",
|
|
253
|
+
});
|
|
254
|
+
mockReadFile.mockRejectedValue(enoentError);
|
|
252
255
|
const sdk = createTestSdk({ manifestPath: "nonexistent.json" });
|
|
253
256
|
const context = sdk.getContext();
|
|
254
257
|
// Trigger file loading by calling a function
|
|
255
258
|
await context.getVersionedImplementationId("slack");
|
|
256
|
-
// Verify
|
|
257
|
-
expect(console.warn).
|
|
259
|
+
// Verify no warning is logged when file simply doesn't exist
|
|
260
|
+
expect(console.warn).not.toHaveBeenCalled();
|
|
261
|
+
});
|
|
262
|
+
it("should silently return null when file does not exist (browser fallback)", async () => {
|
|
263
|
+
mockReadFile.mockRejectedValue(new Error("File not found: /some/path"));
|
|
264
|
+
const sdk = createTestSdk({ manifestPath: "nonexistent.json" });
|
|
265
|
+
const context = sdk.getContext();
|
|
266
|
+
// Trigger file loading by calling a function
|
|
267
|
+
await context.getVersionedImplementationId("slack");
|
|
268
|
+
// Verify no warning is logged when file simply doesn't exist
|
|
269
|
+
expect(console.warn).not.toHaveBeenCalled();
|
|
270
|
+
});
|
|
271
|
+
it("should handle file read errors gracefully", async () => {
|
|
272
|
+
mockReadFile.mockRejectedValue(new Error("Permission denied"));
|
|
273
|
+
const sdk = createTestSdk({ manifestPath: "protected.json" });
|
|
274
|
+
const context = sdk.getContext();
|
|
275
|
+
// Trigger file loading by calling a function
|
|
276
|
+
await context.getVersionedImplementationId("slack");
|
|
277
|
+
// Verify file loading errors (other than file not found) are logged
|
|
278
|
+
expect(console.warn).toHaveBeenCalledWith(expect.stringContaining("Failed to read manifest from protected.json"));
|
|
258
279
|
});
|
|
259
280
|
it("should handle invalid JSON gracefully", async () => {
|
|
260
281
|
mockReadFile.mockResolvedValue("invalid json content");
|
|
@@ -558,10 +579,29 @@ describe("readManifestFromFile", () => {
|
|
|
558
579
|
},
|
|
559
580
|
});
|
|
560
581
|
});
|
|
561
|
-
it("should
|
|
562
|
-
|
|
582
|
+
it("should return null without warning when file does not exist (ENOENT)", async () => {
|
|
583
|
+
vi.spyOn(console, "warn").mockImplementation(() => { });
|
|
584
|
+
const enoentError = Object.assign(new Error("ENOENT: no such file"), {
|
|
585
|
+
code: "ENOENT",
|
|
586
|
+
});
|
|
587
|
+
mockReadFile.mockRejectedValue(enoentError);
|
|
588
|
+
const result = await readManifestFromFile("nonexistent.json");
|
|
589
|
+
expect(result).toBeNull();
|
|
590
|
+
expect(console.warn).not.toHaveBeenCalled();
|
|
591
|
+
});
|
|
592
|
+
it("should return null without warning when file does not exist (browser fallback)", async () => {
|
|
593
|
+
vi.spyOn(console, "warn").mockImplementation(() => { });
|
|
594
|
+
mockReadFile.mockRejectedValue(new Error("File not found: /some/path"));
|
|
563
595
|
const result = await readManifestFromFile("nonexistent.json");
|
|
564
596
|
expect(result).toBeNull();
|
|
597
|
+
expect(console.warn).not.toHaveBeenCalled();
|
|
598
|
+
});
|
|
599
|
+
it("should handle file read errors with warning", async () => {
|
|
600
|
+
vi.spyOn(console, "warn").mockImplementation(() => { });
|
|
601
|
+
mockReadFile.mockRejectedValue(new Error("Permission denied"));
|
|
602
|
+
const result = await readManifestFromFile("protected.json");
|
|
603
|
+
expect(result).toBeNull();
|
|
604
|
+
expect(console.warn).toHaveBeenCalledWith(expect.stringContaining("Failed to read manifest from protected.json"));
|
|
565
605
|
});
|
|
566
606
|
it("should handle invalid JSON content", async () => {
|
|
567
607
|
mockReadFile.mockResolvedValue("invalid json");
|