@slicemachine/manager 0.17.6-beta.3 → 0.17.6-beta.4
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/dist/client/index.d.ts +1 -1
- package/dist/client.cjs +1 -0
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +2 -1
- package/dist/errors.cjs +27 -20
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +23 -15
- package/dist/errors.js +27 -20
- package/dist/errors.js.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/managers/prismicRepository/PrismicRepositoryManager.cjs +8 -34
- package/dist/managers/prismicRepository/PrismicRepositoryManager.cjs.map +1 -1
- package/dist/managers/prismicRepository/PrismicRepositoryManager.d.ts +9 -2
- package/dist/managers/prismicRepository/PrismicRepositoryManager.js +9 -35
- package/dist/managers/prismicRepository/PrismicRepositoryManager.js.map +1 -1
- package/dist/managers/project/ProjectManager.cjs +1 -1
- package/dist/managers/project/ProjectManager.cjs.map +1 -1
- package/dist/managers/project/ProjectManager.js +2 -2
- package/dist/managers/project/ProjectManager.js.map +1 -1
- package/package.json +2 -2
- package/src/client/index.ts +1 -0
- package/src/errors.ts +58 -34
- package/src/index.ts +1 -0
- package/src/managers/prismicRepository/PrismicRepositoryManager.ts +21 -52
- package/src/managers/project/ProjectManager.ts +2 -6
package/dist/client/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export type { CreateSliceMachineManagerClientArgs, SliceMachineManagerClient, }
|
|
|
3
3
|
export type { SimulatorManagerReadSliceSimulatorSetupStep, SimulatorManagerReadSliceSimulatorSetupStepsReturnType, } from "../managers/simulator/SimulatorManager";
|
|
4
4
|
export type { Environment } from "../managers/prismicRepository/types";
|
|
5
5
|
export type { SliceMachineManagerPushSliceReturnType } from "../managers/slices/SlicesManager";
|
|
6
|
-
export { InternalError, NotFoundError, SliceMachineError, UnauthenticatedError, UnauthorizedError, UnexpectedDataError, isInternalError, isNotFoundError, isPluginError, isSliceMachineError, isUnauthenticatedError, isUnauthorizedError, isUnexpectedDataError, } from "../errors";
|
|
6
|
+
export { InternalError, NotFoundError, SliceMachineError, UnauthenticatedError, UnauthorizedError, UnexpectedDataError, isInternalError, isNotFoundError, isPluginError, isSliceMachineError, isUnauthenticatedError, isUnauthorizedError, isUnexpectedDataError, isInvalidActiveEnvironmentError, } from "../errors";
|
|
7
7
|
export { DecodeError } from "../lib/DecodeError";
|
package/dist/client.cjs
CHANGED
|
@@ -11,6 +11,7 @@ exports.UnauthenticatedError = errors.UnauthenticatedError;
|
|
|
11
11
|
exports.UnauthorizedError = errors.UnauthorizedError;
|
|
12
12
|
exports.UnexpectedDataError = errors.UnexpectedDataError;
|
|
13
13
|
exports.isInternalError = errors.isInternalError;
|
|
14
|
+
exports.isInvalidActiveEnvironmentError = errors.isInvalidActiveEnvironmentError;
|
|
14
15
|
exports.isNotFoundError = errors.isNotFoundError;
|
|
15
16
|
exports.isPluginError = errors.isPluginError;
|
|
16
17
|
exports.isSliceMachineError = errors.isSliceMachineError;
|
package/dist/client.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createSliceMachineManagerClient } from "./managers/createSliceMachineManagerClient.js";
|
|
2
|
-
import { InternalError, NotFoundError, SliceMachineError, UnauthenticatedError, UnauthorizedError, UnexpectedDataError, isInternalError, isNotFoundError, isPluginError, isSliceMachineError, isUnauthenticatedError, isUnauthorizedError, isUnexpectedDataError } from "./errors.js";
|
|
2
|
+
import { InternalError, NotFoundError, SliceMachineError, UnauthenticatedError, UnauthorizedError, UnexpectedDataError, isInternalError, isInvalidActiveEnvironmentError, isNotFoundError, isPluginError, isSliceMachineError, isUnauthenticatedError, isUnauthorizedError, isUnexpectedDataError } from "./errors.js";
|
|
3
3
|
import { DecodeError } from "./lib/DecodeError.js";
|
|
4
4
|
export {
|
|
5
5
|
DecodeError,
|
|
@@ -11,6 +11,7 @@ export {
|
|
|
11
11
|
UnexpectedDataError,
|
|
12
12
|
createSliceMachineManagerClient,
|
|
13
13
|
isInternalError,
|
|
14
|
+
isInvalidActiveEnvironmentError,
|
|
14
15
|
isNotFoundError,
|
|
15
16
|
isPluginError,
|
|
16
17
|
isSliceMachineError,
|
package/dist/errors.cjs
CHANGED
|
@@ -9,45 +9,44 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
9
9
|
class SliceMachineError extends Error {
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments);
|
|
12
|
-
__publicField(this, "
|
|
13
|
-
__publicField(this, "name", "SliceMachineError");
|
|
12
|
+
__publicField(this, "name", "SMSliceMachineError");
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
15
|
class UnauthorizedError extends SliceMachineError {
|
|
17
16
|
constructor() {
|
|
18
17
|
super(...arguments);
|
|
19
|
-
__publicField(this, "name", "
|
|
18
|
+
__publicField(this, "name", "SMUnauthorizedError");
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
class UnauthenticatedError extends SliceMachineError {
|
|
23
22
|
constructor() {
|
|
24
23
|
super(...arguments);
|
|
25
|
-
__publicField(this, "name", "
|
|
24
|
+
__publicField(this, "name", "SMUnauthenticatedError");
|
|
26
25
|
__publicField(this, "message", "Authenticate before trying again.");
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
class NotFoundError extends SliceMachineError {
|
|
30
29
|
constructor() {
|
|
31
30
|
super(...arguments);
|
|
32
|
-
__publicField(this, "name", "
|
|
31
|
+
__publicField(this, "name", "SMNotFoundError");
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
class UnexpectedDataError extends SliceMachineError {
|
|
36
35
|
constructor() {
|
|
37
36
|
super(...arguments);
|
|
38
|
-
__publicField(this, "name", "
|
|
37
|
+
__publicField(this, "name", "SMUnexpectedDataError");
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
class InternalError extends SliceMachineError {
|
|
42
41
|
constructor() {
|
|
43
42
|
super(...arguments);
|
|
44
|
-
__publicField(this, "name", "
|
|
43
|
+
__publicField(this, "name", "SMInternalError");
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
class PluginError extends SliceMachineError {
|
|
48
47
|
constructor() {
|
|
49
48
|
super(...arguments);
|
|
50
|
-
__publicField(this, "name", "
|
|
49
|
+
__publicField(this, "name", "SMPluginError");
|
|
51
50
|
}
|
|
52
51
|
}
|
|
53
52
|
class PluginHookResultError extends SliceMachineError {
|
|
@@ -55,35 +54,42 @@ class PluginHookResultError extends SliceMachineError {
|
|
|
55
54
|
super(`${errors.length} error${errors.length === 1 ? "" : "s"} were returned by one or more plugins.`, {
|
|
56
55
|
cause: errors
|
|
57
56
|
});
|
|
58
|
-
__publicField(this, "name", "
|
|
57
|
+
__publicField(this, "name", "SMPluginHookResultError");
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return typeof error === "object" && error !== null && "_sliceMachineError" in error;
|
|
60
|
+
class InvalidActiveEnvironmentError extends SliceMachineError {
|
|
61
|
+
constructor() {
|
|
62
|
+
super(...arguments);
|
|
63
|
+
__publicField(this, "name", "SMInvalidActiveEnvironmentError");
|
|
66
64
|
}
|
|
65
|
+
}
|
|
66
|
+
const isSliceMachineError = (error, name) => {
|
|
67
|
+
const isErrorInstance = error instanceof Error;
|
|
68
|
+
return name === void 0 ? isErrorInstance && error.name.startsWith("SM") : isErrorInstance && error.name === name;
|
|
67
69
|
};
|
|
68
70
|
const isUnauthorizedError = (error) => {
|
|
69
|
-
return isSliceMachineError(error)
|
|
71
|
+
return isSliceMachineError(error, "SMUnauthorizedError");
|
|
70
72
|
};
|
|
71
73
|
const isUnauthenticatedError = (error) => {
|
|
72
|
-
return isSliceMachineError(error)
|
|
74
|
+
return isSliceMachineError(error, "SMUnauthenticatedError");
|
|
73
75
|
};
|
|
74
76
|
const isNotFoundError = (error) => {
|
|
75
|
-
return isSliceMachineError(error)
|
|
77
|
+
return isSliceMachineError(error, "SMNotFoundError");
|
|
76
78
|
};
|
|
77
79
|
const isUnexpectedDataError = (error) => {
|
|
78
|
-
return isSliceMachineError(error)
|
|
80
|
+
return isSliceMachineError(error, "SMUnexpectedDataError");
|
|
79
81
|
};
|
|
80
82
|
const isInternalError = (error) => {
|
|
81
|
-
return isSliceMachineError(error)
|
|
83
|
+
return isSliceMachineError(error, "SMInternalError");
|
|
82
84
|
};
|
|
83
85
|
const isPluginError = (error) => {
|
|
84
|
-
return isSliceMachineError(error)
|
|
86
|
+
return isSliceMachineError(error, "SMPluginError");
|
|
87
|
+
};
|
|
88
|
+
const isInvalidActiveEnvironmentError = (error) => {
|
|
89
|
+
return isSliceMachineError(error, "SMInvalidActiveEnvironmentError");
|
|
85
90
|
};
|
|
86
91
|
exports.InternalError = InternalError;
|
|
92
|
+
exports.InvalidActiveEnvironmentError = InvalidActiveEnvironmentError;
|
|
87
93
|
exports.NotFoundError = NotFoundError;
|
|
88
94
|
exports.PluginError = PluginError;
|
|
89
95
|
exports.PluginHookResultError = PluginHookResultError;
|
|
@@ -92,6 +98,7 @@ exports.UnauthenticatedError = UnauthenticatedError;
|
|
|
92
98
|
exports.UnauthorizedError = UnauthorizedError;
|
|
93
99
|
exports.UnexpectedDataError = UnexpectedDataError;
|
|
94
100
|
exports.isInternalError = isInternalError;
|
|
101
|
+
exports.isInvalidActiveEnvironmentError = isInvalidActiveEnvironmentError;
|
|
95
102
|
exports.isNotFoundError = isNotFoundError;
|
|
96
103
|
exports.isPluginError = isPluginError;
|
|
97
104
|
exports.isSliceMachineError = isSliceMachineError;
|
package/dist/errors.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","sources":["../../src/errors.ts"],"sourcesContent":["import { HookError } from \"@slicemachine/plugin-kit\";\n\nexport class SliceMachineError extends Error {\n\
|
|
1
|
+
{"version":3,"file":"errors.cjs","sources":["../../src/errors.ts"],"sourcesContent":["import { HookError } from \"@slicemachine/plugin-kit\";\n\nexport class SliceMachineError extends Error {\n\tname = \"SMSliceMachineError\";\n}\nexport class UnauthorizedError extends SliceMachineError {\n\tname = \"SMUnauthorizedError\" as const;\n}\nexport class UnauthenticatedError extends SliceMachineError {\n\tname = \"SMUnauthenticatedError\" as const;\n\tmessage = \"Authenticate before trying again.\";\n}\nexport class NotFoundError extends SliceMachineError {\n\tname = \"SMNotFoundError\" as const;\n}\nexport class UnexpectedDataError extends SliceMachineError {\n\tname = \"SMUnexpectedDataError\" as const;\n}\nexport class InternalError extends SliceMachineError {\n\tname = \"SMInternalError\" as const;\n}\nexport class PluginError extends SliceMachineError {\n\tname = \"SMPluginError\" as const;\n}\nexport class PluginHookResultError extends SliceMachineError {\n\tname = \"SMPluginHookResultError\" as const;\n\n\tconstructor(errors: HookError[]) {\n\t\tsuper(\n\t\t\t`${errors.length} error${\n\t\t\t\terrors.length === 1 ? \"\" : \"s\"\n\t\t\t} were returned by one or more plugins.`,\n\t\t\t{\n\t\t\t\tcause: errors,\n\t\t\t},\n\t\t);\n\t}\n}\nexport class InvalidActiveEnvironmentError extends SliceMachineError {\n\tname = \"SMInvalidActiveEnvironmentError\" as const;\n}\n\ntype SliceMachineErrorNames =\n\t| \"SMSliceMachineError\"\n\t| UnauthorizedError[\"name\"]\n\t| UnauthenticatedError[\"name\"]\n\t| NotFoundError[\"name\"]\n\t| UnexpectedDataError[\"name\"]\n\t| InternalError[\"name\"]\n\t| PluginError[\"name\"]\n\t| PluginHookResultError[\"name\"]\n\t| InvalidActiveEnvironmentError[\"name\"];\n\ntype ShallowSliceMachineError<TName extends SliceMachineErrorNames> = Error & {\n\tname: TName;\n};\n\nexport const isSliceMachineError = <TName extends SliceMachineErrorNames>(\n\terror: unknown,\n\tname?: TName,\n): error is TName extends string ? ShallowSliceMachineError<TName> : Error => {\n\tconst isErrorInstance = error instanceof Error;\n\n\treturn name === undefined\n\t\t? isErrorInstance && error.name.startsWith(\"SM\")\n\t\t: isErrorInstance && error.name === name;\n};\n\nexport const isUnauthorizedError = (\n\terror: unknown,\n): error is ShallowSliceMachineError<\"SMUnauthorizedError\"> => {\n\treturn isSliceMachineError(error, \"SMUnauthorizedError\");\n};\n\nexport const isUnauthenticatedError = (\n\terror: unknown,\n): error is ShallowSliceMachineError<\"SMUnauthenticatedError\"> => {\n\treturn isSliceMachineError(error, \"SMUnauthenticatedError\");\n};\n\nexport const isNotFoundError = (\n\terror: unknown,\n): error is ShallowSliceMachineError<\"SMNotFoundError\"> => {\n\treturn isSliceMachineError(error, \"SMNotFoundError\");\n};\n\nexport const isUnexpectedDataError = (\n\terror: unknown,\n): error is ShallowSliceMachineError<\"SMUnexpectedDataError\"> => {\n\treturn isSliceMachineError(error, \"SMUnexpectedDataError\");\n};\n\nexport const isInternalError = (\n\terror: unknown,\n): error is ShallowSliceMachineError<\"SMInternalError\"> => {\n\treturn isSliceMachineError(error, \"SMInternalError\");\n};\n\nexport const isPluginError = (\n\terror: unknown,\n): error is ShallowSliceMachineError<\"SMPluginError\"> => {\n\treturn isSliceMachineError(error, \"SMPluginError\");\n};\n\nexport const isInvalidActiveEnvironmentError = (\n\terror: unknown,\n): error is ShallowSliceMachineError<\"SMInvalidActiveEnvironmentError\"> => {\n\treturn isSliceMachineError(error, \"SMInvalidActiveEnvironmentError\");\n};\n"],"names":[],"mappings":";;;;;;;;AAEM,MAAO,0BAA0B,MAAK;AAAA,EAAtC;AAAA;AACL,gCAAO;AAAA;AACP;AACK,MAAO,0BAA0B,kBAAiB;AAAA,EAAlD;AAAA;AACL,gCAAO;AAAA;AACP;AACK,MAAO,6BAA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ClE,SAAA,oBAAoB,OAAO,iCAAiC;AACpE;;;;;;;;;;;;;;;;;;"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,35 +1,43 @@
|
|
|
1
1
|
import { HookError } from "@slicemachine/plugin-kit";
|
|
2
2
|
export declare class SliceMachineError extends Error {
|
|
3
|
-
_sliceMachineError: boolean;
|
|
4
3
|
name: string;
|
|
5
4
|
}
|
|
6
5
|
export declare class UnauthorizedError extends SliceMachineError {
|
|
7
|
-
name:
|
|
6
|
+
name: "SMUnauthorizedError";
|
|
8
7
|
}
|
|
9
8
|
export declare class UnauthenticatedError extends SliceMachineError {
|
|
10
|
-
name:
|
|
9
|
+
name: "SMUnauthenticatedError";
|
|
11
10
|
message: string;
|
|
12
11
|
}
|
|
13
12
|
export declare class NotFoundError extends SliceMachineError {
|
|
14
|
-
name:
|
|
13
|
+
name: "SMNotFoundError";
|
|
15
14
|
}
|
|
16
15
|
export declare class UnexpectedDataError extends SliceMachineError {
|
|
17
|
-
name:
|
|
16
|
+
name: "SMUnexpectedDataError";
|
|
18
17
|
}
|
|
19
18
|
export declare class InternalError extends SliceMachineError {
|
|
20
|
-
name:
|
|
19
|
+
name: "SMInternalError";
|
|
21
20
|
}
|
|
22
21
|
export declare class PluginError extends SliceMachineError {
|
|
23
|
-
name:
|
|
22
|
+
name: "SMPluginError";
|
|
24
23
|
}
|
|
25
24
|
export declare class PluginHookResultError extends SliceMachineError {
|
|
26
|
-
name:
|
|
25
|
+
name: "SMPluginHookResultError";
|
|
27
26
|
constructor(errors: HookError[]);
|
|
28
27
|
}
|
|
29
|
-
export declare
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
export declare class InvalidActiveEnvironmentError extends SliceMachineError {
|
|
29
|
+
name: "SMInvalidActiveEnvironmentError";
|
|
30
|
+
}
|
|
31
|
+
type SliceMachineErrorNames = "SMSliceMachineError" | UnauthorizedError["name"] | UnauthenticatedError["name"] | NotFoundError["name"] | UnexpectedDataError["name"] | InternalError["name"] | PluginError["name"] | PluginHookResultError["name"] | InvalidActiveEnvironmentError["name"];
|
|
32
|
+
type ShallowSliceMachineError<TName extends SliceMachineErrorNames> = Error & {
|
|
33
|
+
name: TName;
|
|
34
|
+
};
|
|
35
|
+
export declare const isSliceMachineError: <TName extends SliceMachineErrorNames>(error: unknown, name?: TName | undefined) => error is TName extends string ? ShallowSliceMachineError<TName> : Error;
|
|
36
|
+
export declare const isUnauthorizedError: (error: unknown) => error is ShallowSliceMachineError<"SMUnauthorizedError">;
|
|
37
|
+
export declare const isUnauthenticatedError: (error: unknown) => error is ShallowSliceMachineError<"SMUnauthenticatedError">;
|
|
38
|
+
export declare const isNotFoundError: (error: unknown) => error is ShallowSliceMachineError<"SMNotFoundError">;
|
|
39
|
+
export declare const isUnexpectedDataError: (error: unknown) => error is ShallowSliceMachineError<"SMUnexpectedDataError">;
|
|
40
|
+
export declare const isInternalError: (error: unknown) => error is ShallowSliceMachineError<"SMInternalError">;
|
|
41
|
+
export declare const isPluginError: (error: unknown) => error is ShallowSliceMachineError<"SMPluginError">;
|
|
42
|
+
export declare const isInvalidActiveEnvironmentError: (error: unknown) => error is ShallowSliceMachineError<"SMInvalidActiveEnvironmentError">;
|
|
43
|
+
export {};
|
package/dist/errors.js
CHANGED
|
@@ -7,45 +7,44 @@ var __publicField = (obj, key, value) => {
|
|
|
7
7
|
class SliceMachineError extends Error {
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
10
|
-
__publicField(this, "
|
|
11
|
-
__publicField(this, "name", "SliceMachineError");
|
|
10
|
+
__publicField(this, "name", "SMSliceMachineError");
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
13
|
class UnauthorizedError extends SliceMachineError {
|
|
15
14
|
constructor() {
|
|
16
15
|
super(...arguments);
|
|
17
|
-
__publicField(this, "name", "
|
|
16
|
+
__publicField(this, "name", "SMUnauthorizedError");
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
class UnauthenticatedError extends SliceMachineError {
|
|
21
20
|
constructor() {
|
|
22
21
|
super(...arguments);
|
|
23
|
-
__publicField(this, "name", "
|
|
22
|
+
__publicField(this, "name", "SMUnauthenticatedError");
|
|
24
23
|
__publicField(this, "message", "Authenticate before trying again.");
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
class NotFoundError extends SliceMachineError {
|
|
28
27
|
constructor() {
|
|
29
28
|
super(...arguments);
|
|
30
|
-
__publicField(this, "name", "
|
|
29
|
+
__publicField(this, "name", "SMNotFoundError");
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
class UnexpectedDataError extends SliceMachineError {
|
|
34
33
|
constructor() {
|
|
35
34
|
super(...arguments);
|
|
36
|
-
__publicField(this, "name", "
|
|
35
|
+
__publicField(this, "name", "SMUnexpectedDataError");
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
class InternalError extends SliceMachineError {
|
|
40
39
|
constructor() {
|
|
41
40
|
super(...arguments);
|
|
42
|
-
__publicField(this, "name", "
|
|
41
|
+
__publicField(this, "name", "SMInternalError");
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
class PluginError extends SliceMachineError {
|
|
46
45
|
constructor() {
|
|
47
46
|
super(...arguments);
|
|
48
|
-
__publicField(this, "name", "
|
|
47
|
+
__publicField(this, "name", "SMPluginError");
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
class PluginHookResultError extends SliceMachineError {
|
|
@@ -53,36 +52,43 @@ class PluginHookResultError extends SliceMachineError {
|
|
|
53
52
|
super(`${errors.length} error${errors.length === 1 ? "" : "s"} were returned by one or more plugins.`, {
|
|
54
53
|
cause: errors
|
|
55
54
|
});
|
|
56
|
-
__publicField(this, "name", "
|
|
55
|
+
__publicField(this, "name", "SMPluginHookResultError");
|
|
57
56
|
}
|
|
58
57
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return typeof error === "object" && error !== null && "_sliceMachineError" in error;
|
|
58
|
+
class InvalidActiveEnvironmentError extends SliceMachineError {
|
|
59
|
+
constructor() {
|
|
60
|
+
super(...arguments);
|
|
61
|
+
__publicField(this, "name", "SMInvalidActiveEnvironmentError");
|
|
64
62
|
}
|
|
63
|
+
}
|
|
64
|
+
const isSliceMachineError = (error, name) => {
|
|
65
|
+
const isErrorInstance = error instanceof Error;
|
|
66
|
+
return name === void 0 ? isErrorInstance && error.name.startsWith("SM") : isErrorInstance && error.name === name;
|
|
65
67
|
};
|
|
66
68
|
const isUnauthorizedError = (error) => {
|
|
67
|
-
return isSliceMachineError(error)
|
|
69
|
+
return isSliceMachineError(error, "SMUnauthorizedError");
|
|
68
70
|
};
|
|
69
71
|
const isUnauthenticatedError = (error) => {
|
|
70
|
-
return isSliceMachineError(error)
|
|
72
|
+
return isSliceMachineError(error, "SMUnauthenticatedError");
|
|
71
73
|
};
|
|
72
74
|
const isNotFoundError = (error) => {
|
|
73
|
-
return isSliceMachineError(error)
|
|
75
|
+
return isSliceMachineError(error, "SMNotFoundError");
|
|
74
76
|
};
|
|
75
77
|
const isUnexpectedDataError = (error) => {
|
|
76
|
-
return isSliceMachineError(error)
|
|
78
|
+
return isSliceMachineError(error, "SMUnexpectedDataError");
|
|
77
79
|
};
|
|
78
80
|
const isInternalError = (error) => {
|
|
79
|
-
return isSliceMachineError(error)
|
|
81
|
+
return isSliceMachineError(error, "SMInternalError");
|
|
80
82
|
};
|
|
81
83
|
const isPluginError = (error) => {
|
|
82
|
-
return isSliceMachineError(error)
|
|
84
|
+
return isSliceMachineError(error, "SMPluginError");
|
|
85
|
+
};
|
|
86
|
+
const isInvalidActiveEnvironmentError = (error) => {
|
|
87
|
+
return isSliceMachineError(error, "SMInvalidActiveEnvironmentError");
|
|
83
88
|
};
|
|
84
89
|
export {
|
|
85
90
|
InternalError,
|
|
91
|
+
InvalidActiveEnvironmentError,
|
|
86
92
|
NotFoundError,
|
|
87
93
|
PluginError,
|
|
88
94
|
PluginHookResultError,
|
|
@@ -91,6 +97,7 @@ export {
|
|
|
91
97
|
UnauthorizedError,
|
|
92
98
|
UnexpectedDataError,
|
|
93
99
|
isInternalError,
|
|
100
|
+
isInvalidActiveEnvironmentError,
|
|
94
101
|
isNotFoundError,
|
|
95
102
|
isPluginError,
|
|
96
103
|
isSliceMachineError,
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sources":["../../src/errors.ts"],"sourcesContent":["import { HookError } from \"@slicemachine/plugin-kit\";\n\nexport class SliceMachineError extends Error {\n\
|
|
1
|
+
{"version":3,"file":"errors.js","sources":["../../src/errors.ts"],"sourcesContent":["import { HookError } from \"@slicemachine/plugin-kit\";\n\nexport class SliceMachineError extends Error {\n\tname = \"SMSliceMachineError\";\n}\nexport class UnauthorizedError extends SliceMachineError {\n\tname = \"SMUnauthorizedError\" as const;\n}\nexport class UnauthenticatedError extends SliceMachineError {\n\tname = \"SMUnauthenticatedError\" as const;\n\tmessage = \"Authenticate before trying again.\";\n}\nexport class NotFoundError extends SliceMachineError {\n\tname = \"SMNotFoundError\" as const;\n}\nexport class UnexpectedDataError extends SliceMachineError {\n\tname = \"SMUnexpectedDataError\" as const;\n}\nexport class InternalError extends SliceMachineError {\n\tname = \"SMInternalError\" as const;\n}\nexport class PluginError extends SliceMachineError {\n\tname = \"SMPluginError\" as const;\n}\nexport class PluginHookResultError extends SliceMachineError {\n\tname = \"SMPluginHookResultError\" as const;\n\n\tconstructor(errors: HookError[]) {\n\t\tsuper(\n\t\t\t`${errors.length} error${\n\t\t\t\terrors.length === 1 ? \"\" : \"s\"\n\t\t\t} were returned by one or more plugins.`,\n\t\t\t{\n\t\t\t\tcause: errors,\n\t\t\t},\n\t\t);\n\t}\n}\nexport class InvalidActiveEnvironmentError extends SliceMachineError {\n\tname = \"SMInvalidActiveEnvironmentError\" as const;\n}\n\ntype SliceMachineErrorNames =\n\t| \"SMSliceMachineError\"\n\t| UnauthorizedError[\"name\"]\n\t| UnauthenticatedError[\"name\"]\n\t| NotFoundError[\"name\"]\n\t| UnexpectedDataError[\"name\"]\n\t| InternalError[\"name\"]\n\t| PluginError[\"name\"]\n\t| PluginHookResultError[\"name\"]\n\t| InvalidActiveEnvironmentError[\"name\"];\n\ntype ShallowSliceMachineError<TName extends SliceMachineErrorNames> = Error & {\n\tname: TName;\n};\n\nexport const isSliceMachineError = <TName extends SliceMachineErrorNames>(\n\terror: unknown,\n\tname?: TName,\n): error is TName extends string ? ShallowSliceMachineError<TName> : Error => {\n\tconst isErrorInstance = error instanceof Error;\n\n\treturn name === undefined\n\t\t? isErrorInstance && error.name.startsWith(\"SM\")\n\t\t: isErrorInstance && error.name === name;\n};\n\nexport const isUnauthorizedError = (\n\terror: unknown,\n): error is ShallowSliceMachineError<\"SMUnauthorizedError\"> => {\n\treturn isSliceMachineError(error, \"SMUnauthorizedError\");\n};\n\nexport const isUnauthenticatedError = (\n\terror: unknown,\n): error is ShallowSliceMachineError<\"SMUnauthenticatedError\"> => {\n\treturn isSliceMachineError(error, \"SMUnauthenticatedError\");\n};\n\nexport const isNotFoundError = (\n\terror: unknown,\n): error is ShallowSliceMachineError<\"SMNotFoundError\"> => {\n\treturn isSliceMachineError(error, \"SMNotFoundError\");\n};\n\nexport const isUnexpectedDataError = (\n\terror: unknown,\n): error is ShallowSliceMachineError<\"SMUnexpectedDataError\"> => {\n\treturn isSliceMachineError(error, \"SMUnexpectedDataError\");\n};\n\nexport const isInternalError = (\n\terror: unknown,\n): error is ShallowSliceMachineError<\"SMInternalError\"> => {\n\treturn isSliceMachineError(error, \"SMInternalError\");\n};\n\nexport const isPluginError = (\n\terror: unknown,\n): error is ShallowSliceMachineError<\"SMPluginError\"> => {\n\treturn isSliceMachineError(error, \"SMPluginError\");\n};\n\nexport const isInvalidActiveEnvironmentError = (\n\terror: unknown,\n): error is ShallowSliceMachineError<\"SMInvalidActiveEnvironmentError\"> => {\n\treturn isSliceMachineError(error, \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OAAO,uBAAuB;AAC1D;AAEa,MAAA,kBAAkB,CAC9B,UACyD;AAClD,SAAA,oBAAoB,OAAO,iBAAiB;AACpD;AAEa,MAAA,gBAAgB,CAC5B,UACuD;AAChD,SAAA,oBAAoB,OAAO,eAAe;AAClD;AAEa,MAAA,kCAAkC,CAC9C,UACyE;AAClE,SAAA,oBAAoB,OAAO,iCAAiC;AACpE;"}
|
package/dist/index.cjs
CHANGED
|
@@ -13,6 +13,7 @@ exports.createSliceMachineManagerMiddleware = createSliceMachineManagerMiddlewar
|
|
|
13
13
|
exports.createPrismicAuthManager = createPrismicAuthManager.createPrismicAuthManager;
|
|
14
14
|
exports.createPrismicAuthManagerMiddleware = createPrismicAuthManagerMiddleware.createPrismicAuthManagerMiddleware;
|
|
15
15
|
exports.InternalError = errors.InternalError;
|
|
16
|
+
exports.InvalidActiveEnvironmentError = errors.InvalidActiveEnvironmentError;
|
|
16
17
|
exports.NotFoundError = errors.NotFoundError;
|
|
17
18
|
exports.PluginError = errors.PluginError;
|
|
18
19
|
exports.PluginHookResultError = errors.PluginHookResultError;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type { PrismicAuthManager, PrismicUserProfile, PrismicAuthState, } from "
|
|
|
9
9
|
export { createPrismicAuthManager } from "./auth/createPrismicAuthManager";
|
|
10
10
|
export { createPrismicAuthManagerMiddleware } from "./auth/createPrismicAuthManagerMiddleware";
|
|
11
11
|
export type { CreatePrismicAuthManagerMiddlewareArgs, PrismicAuthCheckStatusResponse, } from "./auth/createPrismicAuthManagerMiddleware";
|
|
12
|
-
export { SliceMachineError, UnauthorizedError, UnauthenticatedError, NotFoundError, UnexpectedDataError, InternalError, PluginError, PluginHookResultError, } from "./errors";
|
|
12
|
+
export { SliceMachineError, UnauthorizedError, UnauthenticatedError, NotFoundError, UnexpectedDataError, InternalError, PluginError, PluginHookResultError, InvalidActiveEnvironmentError, } from "./errors";
|
|
13
13
|
export { getEnvironmentInfo } from "./getEnvironmentInfo";
|
|
14
14
|
export { DecodeError } from "./lib/DecodeError";
|
|
15
15
|
export type { SliceMachineConfig, PackageManager } from "./types";
|
package/dist/index.js
CHANGED
|
@@ -2,13 +2,14 @@ import { createSliceMachineManager } from "./managers/createSliceMachineManager.
|
|
|
2
2
|
import { createSliceMachineManagerMiddleware } from "./managers/createSliceMachineManagerMiddleware.js";
|
|
3
3
|
import { createPrismicAuthManager } from "./auth/createPrismicAuthManager.js";
|
|
4
4
|
import { createPrismicAuthManagerMiddleware } from "./auth/createPrismicAuthManagerMiddleware.js";
|
|
5
|
-
import { InternalError, NotFoundError, PluginError, PluginHookResultError, SliceMachineError, UnauthenticatedError, UnauthorizedError, UnexpectedDataError } from "./errors.js";
|
|
5
|
+
import { InternalError, InvalidActiveEnvironmentError, NotFoundError, PluginError, PluginHookResultError, SliceMachineError, UnauthenticatedError, UnauthorizedError, UnexpectedDataError } from "./errors.js";
|
|
6
6
|
import { getEnvironmentInfo } from "./getEnvironmentInfo.js";
|
|
7
7
|
import { DecodeError } from "./lib/DecodeError.js";
|
|
8
8
|
import { REPOSITORY_NAME_VALIDATION } from "./constants/REPOSITORY_NAME_VALIDATION.js";
|
|
9
9
|
export {
|
|
10
10
|
DecodeError,
|
|
11
11
|
InternalError,
|
|
12
|
+
InvalidActiveEnvironmentError,
|
|
12
13
|
NotFoundError,
|
|
13
14
|
PluginError,
|
|
14
15
|
PluginHookResultError,
|
|
@@ -317,17 +317,7 @@ class PrismicRepositoryManager extends BaseManager.BaseManager {
|
|
|
317
317
|
const repositoryName = await this.project.getRepositoryName();
|
|
318
318
|
const url = new URL(`./environments`, API_ENDPOINTS.API_ENDPOINTS.SliceMachineV1);
|
|
319
319
|
url.searchParams.set("repository", repositoryName);
|
|
320
|
-
|
|
321
|
-
try {
|
|
322
|
-
res = await this._fetch({ url });
|
|
323
|
-
} catch (error) {
|
|
324
|
-
if (errors.isUnauthenticatedError(error)) {
|
|
325
|
-
return { error };
|
|
326
|
-
}
|
|
327
|
-
return {
|
|
328
|
-
error: new errors.UnexpectedDataError("Unexpected Error while fetching Environments")
|
|
329
|
-
};
|
|
330
|
-
}
|
|
320
|
+
const res = await this._fetch({ url });
|
|
331
321
|
if (res.ok) {
|
|
332
322
|
const json = await res.json();
|
|
333
323
|
const { value, error } = decode.decode(t__namespace.union([
|
|
@@ -339,29 +329,13 @@ class PrismicRepositoryManager extends BaseManager.BaseManager {
|
|
|
339
329
|
})
|
|
340
330
|
]), json);
|
|
341
331
|
if (error) {
|
|
342
|
-
|
|
343
|
-
error: new errors.UnexpectedDataError(`Failed to decode environments: ${error.errors.join(", ")}`)
|
|
344
|
-
};
|
|
332
|
+
throw new errors.UnexpectedDataError(`Failed to decode environments: ${error.errors.join(", ")}`);
|
|
345
333
|
}
|
|
346
334
|
if ("results" in value) {
|
|
347
335
|
let environments = value.results;
|
|
348
|
-
if (!(args == null ? void 0 : args.
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
environments = environments.filter((environment) => {
|
|
352
|
-
if (environment.kind === "dev") {
|
|
353
|
-
return environment.users.some((user) => user.id === profile.shortId);
|
|
354
|
-
}
|
|
355
|
-
return true;
|
|
356
|
-
});
|
|
357
|
-
} catch (e) {
|
|
358
|
-
if (errors.isUnauthenticatedError(error)) {
|
|
359
|
-
return { error };
|
|
360
|
-
}
|
|
361
|
-
return {
|
|
362
|
-
error: new errors.UnexpectedDataError("Unexpected Error while fetching Environments")
|
|
363
|
-
};
|
|
364
|
-
}
|
|
336
|
+
if (!(args == null ? void 0 : args.includeAll)) {
|
|
337
|
+
const profile = await this.user.getProfile();
|
|
338
|
+
environments = environments.filter((environment) => environment.users.some((user) => user.id === profile.shortId));
|
|
365
339
|
}
|
|
366
340
|
return { environments: sortEnvironments.sortEnvironments(environments) };
|
|
367
341
|
}
|
|
@@ -369,11 +343,11 @@ class PrismicRepositoryManager extends BaseManager.BaseManager {
|
|
|
369
343
|
switch (res.status) {
|
|
370
344
|
case 400:
|
|
371
345
|
case 401:
|
|
372
|
-
|
|
346
|
+
throw new errors.UnauthenticatedError();
|
|
373
347
|
case 403:
|
|
374
|
-
|
|
348
|
+
throw new errors.UnauthorizedError();
|
|
375
349
|
default:
|
|
376
|
-
|
|
350
|
+
throw new Error("Failed to fetch environments.");
|
|
377
351
|
}
|
|
378
352
|
}
|
|
379
353
|
_decodeLimitOrThrow(potentialLimit, statusCode, limitType) {
|