@intuned/runtime 1.3.11 → 1.3.13
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/bin/intuned-get-headless-user-agent +4 -0
- package/dist/commands/get-headless-user-agent.d.ts +1 -0
- package/dist/commands/get-headless-user-agent.js +18 -0
- package/dist/commands/intuned-cli/controller/authSession.d.ts +12 -12
- package/dist/commands/intuned-cli/helpers/auth.d.ts +2 -2
- package/dist/commands/intuned-cli/helpers/errors.d.ts +1 -1
- package/dist/commands/intuned-cli/helpers/errors.js +2 -2
- package/dist/commands/intuned-cli/helpers/intunedJson.d.ts +7 -139
- package/dist/commands/intuned-cli/helpers/intunedJson.js +12 -79
- package/dist/common/binStartupScript.js +8 -5
- package/dist/common/constants.d.ts +2 -0
- package/dist/common/constants.js +4 -2
- package/dist/common/intunedJson.d.ts +229 -0
- package/dist/common/intunedJson.js +133 -0
- package/dist/common/launchBrowser.d.ts +6 -0
- package/dist/common/launchBrowser.js +39 -16
- package/dist/common/runApi/index.js +11 -1
- package/dist/common/runApi/types.d.ts +40 -40
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -0
- package/dist/runtime/attemptStore.d.ts +2 -2
- package/dist/runtime/export.d.ts +69 -13
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +7 -0
- package/dist/runtime/persistentStore.d.ts +2 -0
- package/dist/runtime/persistentStore.js +37 -0
- package/dist/runtime/persistentStore.test.js +101 -0
- package/package.json +3 -1
- package/WebTemplate.zip +0 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _vitest = require("vitest");
|
|
4
|
+
var _zod = require("zod");
|
|
5
|
+
var _persistentStore = require("./persistentStore");
|
|
6
|
+
var _jwtTokenManager = require("../common/jwtTokenManager");
|
|
7
|
+
_vitest.vi.mock("../common/jwtTokenManager", () => ({
|
|
8
|
+
callBackendFunctionWithToken: _vitest.vi.fn()
|
|
9
|
+
}));
|
|
10
|
+
(0, _vitest.describe)("Cache", () => {
|
|
11
|
+
(0, _vitest.beforeEach)(() => {
|
|
12
|
+
_vitest.vi.clearAllMocks();
|
|
13
|
+
});
|
|
14
|
+
(0, _vitest.describe)("get", () => {
|
|
15
|
+
(0, _vitest.it)("should return value when successful", async () => {
|
|
16
|
+
const mockResponse = {
|
|
17
|
+
ok: true,
|
|
18
|
+
json: _vitest.vi.fn().mockResolvedValue({
|
|
19
|
+
value: "cached_data"
|
|
20
|
+
})
|
|
21
|
+
};
|
|
22
|
+
_vitest.vi.mocked(_jwtTokenManager.callBackendFunctionWithToken).mockResolvedValue(mockResponse);
|
|
23
|
+
const result = await _persistentStore.persistentStore.get("test_key");
|
|
24
|
+
(0, _vitest.expect)(result).toBe("cached_data");
|
|
25
|
+
(0, _vitest.expect)(_jwtTokenManager.callBackendFunctionWithToken).toHaveBeenCalledWith("kv-store/test_key", {
|
|
26
|
+
method: "GET"
|
|
27
|
+
});
|
|
28
|
+
(0, _vitest.expect)(mockResponse.json).toHaveBeenCalled();
|
|
29
|
+
});
|
|
30
|
+
(0, _vitest.it)("should throw error when response is not ok", async () => {
|
|
31
|
+
const mockResponse = {
|
|
32
|
+
ok: false,
|
|
33
|
+
json: _vitest.vi.fn().mockResolvedValue({
|
|
34
|
+
message: "Cache miss"
|
|
35
|
+
})
|
|
36
|
+
};
|
|
37
|
+
_vitest.vi.mocked(_jwtTokenManager.callBackendFunctionWithToken).mockResolvedValue(mockResponse);
|
|
38
|
+
await (0, _vitest.expect)(_persistentStore.persistentStore.get("test_key")).rejects.toThrow("Cache miss");
|
|
39
|
+
});
|
|
40
|
+
(0, _vitest.it)("should throw error for empty key", async () => {
|
|
41
|
+
await (0, _vitest.expect)(_persistentStore.persistentStore.get("")).rejects.toThrow(_zod.ZodError);
|
|
42
|
+
});
|
|
43
|
+
(0, _vitest.it)("should throw error for key with colon", async () => {
|
|
44
|
+
await (0, _vitest.expect)(_persistentStore.persistentStore.get("invalid:key")).rejects.toThrow(_zod.ZodError);
|
|
45
|
+
});
|
|
46
|
+
(0, _vitest.it)("should throw error for key with hash", async () => {
|
|
47
|
+
await (0, _vitest.expect)(_persistentStore.persistentStore.get("invalid#key")).rejects.toThrow(_zod.ZodError);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
(0, _vitest.describe)("set", () => {
|
|
51
|
+
(0, _vitest.it)("should call backend correctly when successful", async () => {
|
|
52
|
+
const mockResponse = {
|
|
53
|
+
ok: true,
|
|
54
|
+
json: _vitest.vi.fn().mockResolvedValue({})
|
|
55
|
+
};
|
|
56
|
+
_vitest.vi.mocked(_jwtTokenManager.callBackendFunctionWithToken).mockResolvedValue(mockResponse);
|
|
57
|
+
const testValue = {
|
|
58
|
+
data: "test"
|
|
59
|
+
};
|
|
60
|
+
await _persistentStore.persistentStore.set("test_key", testValue);
|
|
61
|
+
(0, _vitest.expect)(_jwtTokenManager.callBackendFunctionWithToken).toHaveBeenCalledWith("kv-store/test_key", {
|
|
62
|
+
method: "PUT",
|
|
63
|
+
body: JSON.stringify(testValue),
|
|
64
|
+
headers: {
|
|
65
|
+
"Content-Type": "application/json"
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
(0, _vitest.expect)(mockResponse.json).toHaveBeenCalled();
|
|
69
|
+
});
|
|
70
|
+
(0, _vitest.it)("should throw error when response is not ok", async () => {
|
|
71
|
+
const mockResponse = {
|
|
72
|
+
ok: false,
|
|
73
|
+
json: _vitest.vi.fn().mockResolvedValue({
|
|
74
|
+
message: "Set failed"
|
|
75
|
+
})
|
|
76
|
+
};
|
|
77
|
+
_vitest.vi.mocked(_jwtTokenManager.callBackendFunctionWithToken).mockResolvedValue(mockResponse);
|
|
78
|
+
await (0, _vitest.expect)(_persistentStore.persistentStore.set("test_key", "value")).rejects.toThrow("Set failed");
|
|
79
|
+
});
|
|
80
|
+
(0, _vitest.it)("should throw error for empty key", async () => {
|
|
81
|
+
await (0, _vitest.expect)(_persistentStore.persistentStore.set("", "value")).rejects.toThrow(_zod.ZodError);
|
|
82
|
+
});
|
|
83
|
+
(0, _vitest.it)("should throw error for key with forbidden characters", async () => {
|
|
84
|
+
await (0, _vitest.expect)(_persistentStore.persistentStore.set("invalid:key", "value")).rejects.toThrow(_zod.ZodError);
|
|
85
|
+
await (0, _vitest.expect)(_persistentStore.persistentStore.set("invalid#key", "value")).rejects.toThrow(_zod.ZodError);
|
|
86
|
+
});
|
|
87
|
+
(0, _vitest.it)("should handle different value types", async () => {
|
|
88
|
+
const mockResponse = {
|
|
89
|
+
ok: true,
|
|
90
|
+
json: _vitest.vi.fn().mockResolvedValue({})
|
|
91
|
+
};
|
|
92
|
+
_vitest.vi.mocked(_jwtTokenManager.callBackendFunctionWithToken).mockResolvedValue(mockResponse);
|
|
93
|
+
await _persistentStore.persistentStore.set("key1", "string_value");
|
|
94
|
+
await _persistentStore.persistentStore.set("key2", {
|
|
95
|
+
object: "value"
|
|
96
|
+
});
|
|
97
|
+
await _persistentStore.persistentStore.set("key3", 123);
|
|
98
|
+
(0, _vitest.expect)(_jwtTokenManager.callBackendFunctionWithToken).toHaveBeenCalledTimes(3);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intuned/runtime",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.13",
|
|
4
4
|
"description": "Intuned runtime",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"intuned-auth-session-load": "vite-node ./src/commands/auth/load.ts",
|
|
31
31
|
"intuned-ts-check": "yarn prepublishOnly && vite-node ./src/commands/ts-check.ts",
|
|
32
32
|
"intuned": "vite-node ./src/commands/intuned-cli/main.ts",
|
|
33
|
+
"intuned-get-headless-user-agent": "vite-node ./src/commands/get-headless-user-agent.ts",
|
|
33
34
|
"build": "rm -rf dist && tsc -p tsconfig.json && yarn copy-dts && babel src --out-dir dist --extensions '.ts' && cp -r ./src/common/assets dist/common/assets",
|
|
34
35
|
"test": "vitest run",
|
|
35
36
|
"test:watch": "vitest",
|
|
@@ -50,6 +51,7 @@
|
|
|
50
51
|
"intuned-browser-start": "bin/intuned-browser-start",
|
|
51
52
|
"intuned-browser-save-state": "bin/intuned-browser-save-state",
|
|
52
53
|
"intuned-ts-check": "bin/intuned-ts-check",
|
|
54
|
+
"intuned-get-headless-user-agent": "bin/intuned-get-headless-user-agent",
|
|
53
55
|
"intuned": "bin/intuned"
|
|
54
56
|
},
|
|
55
57
|
"dependencies": {
|
package/WebTemplate.zip
DELETED
|
Binary file
|