@lwrjs/diagnostics 0.17.2-alpha.0 → 0.17.2-alpha.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.
Files changed (34) hide show
  1. package/build/cjs/descriptions/application.cjs +11 -27
  2. package/build/cjs/descriptions/config.cjs +41 -0
  3. package/build/cjs/descriptions/index.cjs +2 -3
  4. package/build/cjs/descriptions/server.cjs +5 -31
  5. package/build/cjs/descriptions/unresolvable.cjs +16 -100
  6. package/build/cjs/errors.cjs +39 -33
  7. package/build/cjs/index.cjs +0 -1
  8. package/build/es/descriptions/application.d.ts +11 -10
  9. package/build/es/descriptions/application.js +11 -11
  10. package/build/es/descriptions/config.d.ts +30 -0
  11. package/build/es/descriptions/config.js +31 -0
  12. package/build/es/descriptions/index.d.ts +60 -234
  13. package/build/es/descriptions/index.js +2 -3
  14. package/build/es/descriptions/server.d.ts +5 -14
  15. package/build/es/descriptions/server.js +5 -15
  16. package/build/es/descriptions/unresolvable.d.ts +15 -82
  17. package/build/es/descriptions/unresolvable.js +15 -83
  18. package/build/es/errors.d.ts +36 -15
  19. package/build/es/errors.js +42 -34
  20. package/build/es/index.d.ts +0 -1
  21. package/build/es/index.js +0 -1
  22. package/package.json +3 -3
  23. package/build/cjs/descriptions/compiler.cjs +0 -35
  24. package/build/cjs/descriptions/configParser.cjs +0 -150
  25. package/build/cjs/descriptions/core-diagnostics.cjs +0 -37
  26. package/build/cjs/types.cjs +0 -5
  27. package/build/es/descriptions/compiler.d.ts +0 -7
  28. package/build/es/descriptions/compiler.js +0 -8
  29. package/build/es/descriptions/configParser.d.ts +0 -129
  30. package/build/es/descriptions/configParser.js +0 -123
  31. package/build/es/descriptions/core-diagnostics.d.ts +0 -3
  32. package/build/es/descriptions/core-diagnostics.js +0 -27
  33. package/build/es/types.d.ts +0 -160
  34. package/build/es/types.js +0 -2
@@ -2,48 +2,56 @@
2
2
  export function isNodeError(error) {
3
3
  return error instanceof Error;
4
4
  }
5
- export function createSingleDiagnosticError(diag, errorClass = DiagnosticsError) {
6
- return new errorClass(diag.description.message, [diag]);
7
- }
8
- export class DiagnosticsError extends Error {
9
- constructor(message, diagnostics) {
10
- if (diagnostics.length === 0) {
11
- throw new Error('No diagnostics');
12
- }
13
- super();
14
- this._memoMessage = undefined;
15
- this._message = message;
16
- this.diagnostics = diagnostics;
17
- this.name = 'DiagnosticsError';
5
+ // LWR-Node base error class from which all others extend
6
+ export class LwrError extends Error {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.name = 'LwrError';
18
10
  }
19
- // Lazily instantiate this. If we ever catchDiagnostics we wont even care about the `message`
20
- // so this avoids having to print it to a string
21
- get message() {
22
- if (this._memoMessage !== undefined) {
23
- return this._memoMessage;
24
- }
25
- const message = this._message === undefined ? '' : this._message + '\n';
26
- return message;
11
+ }
12
+ // 500 - All errors which are instances of Error or LwrServerError will impact availability metrics
13
+ export class LwrServerError extends LwrError {
14
+ constructor() {
15
+ super(...arguments);
16
+ this.name = 'LwrServerError';
27
17
  }
28
- // Allow set message can be called from rollup ModuleLoader.addModuleSource
29
- set message(message) {
30
- this._message = message;
18
+ }
19
+ // 400
20
+ export class LwrApplicationError extends LwrError {
21
+ constructor() {
22
+ super(...arguments);
23
+ this.name = 'LwrApplicationError';
31
24
  }
32
25
  }
33
- export class LwrConfigValidationError extends DiagnosticsError {
26
+ // 404
27
+ export class LwrUnresolvableError extends LwrError {
28
+ constructor(message, type) {
29
+ super(message);
30
+ this.name = 'LwrUnresolvableError';
31
+ this.type = type;
32
+ }
34
33
  }
35
- export class LwrUnresolvableError extends DiagnosticsError {
34
+ // 301, 302, 429, 503
35
+ export class LwrStatusError extends LwrError {
36
+ constructor(message, status, location) {
37
+ super(message);
38
+ this.name = 'LwrStatusError';
39
+ this.status = status;
40
+ this.location = location;
41
+ }
36
42
  }
37
- export class LwrServerError extends DiagnosticsError {
38
- constructor(message, diagnostics) {
39
- super(message, diagnostics);
40
- this.name = 'ServerError';
43
+ export class DiagnosticsError extends LwrError {
44
+ constructor(message, diagnostics = []) {
45
+ super(message);
46
+ this.diagnostics = diagnostics;
47
+ this.name = 'LwrDiagnosticsError';
41
48
  }
42
49
  }
43
- export class LwrApplicationError extends DiagnosticsError {
44
- constructor(message, diagnostics) {
45
- super(message, diagnostics);
46
- this.name = 'ApplicationError';
50
+ // fatal config validation issues
51
+ export class LwrConfigError extends DiagnosticsError {
52
+ constructor() {
53
+ super(...arguments);
54
+ this.name = 'LwrConfigError';
47
55
  }
48
56
  }
49
57
  //# sourceMappingURL=errors.js.map
@@ -1,4 +1,3 @@
1
- export * from './types.js';
2
1
  export * from './descriptions/index.js';
3
2
  export * from './errors.js';
4
3
  export * from './logger.js';
package/build/es/index.js CHANGED
@@ -1,4 +1,3 @@
1
- export * from './types.js';
2
1
  export * from './descriptions/index.js';
3
2
  export * from './errors.js';
4
3
  export * from './logger.js';
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.17.2-alpha.0",
7
+ "version": "0.17.2-alpha.2",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -35,7 +35,7 @@
35
35
  "test": "jest"
36
36
  },
37
37
  "devDependencies": {
38
- "@lwrjs/types": "0.17.2-alpha.0",
38
+ "@lwrjs/types": "0.17.2-alpha.2",
39
39
  "jest": "^26.6.3",
40
40
  "ts-jest": "^26.5.6",
41
41
  "typescript": "^4.9.5"
@@ -46,5 +46,5 @@
46
46
  "volta": {
47
47
  "extends": "../../../package.json"
48
48
  },
49
- "gitHead": "128e2d6e17d05fb780523b60c2717ef8ebfd9b57"
49
+ "gitHead": "739b237f5d7f2c1989142cb505a56cc763f21976"
50
50
  }
@@ -1,35 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, {get: all[name], enumerable: true});
11
- };
12
- var __exportStar = (target, module2, desc) => {
13
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
- for (let key of __getOwnPropNames(module2))
15
- if (!__hasOwnProp.call(target, key) && key !== "default")
16
- __defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
17
- }
18
- return target;
19
- };
20
- var __toModule = (module2) => {
21
- return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
22
- };
23
-
24
- // packages/@lwrjs/diagnostics/src/descriptions/compiler.ts
25
- __markAsModule(exports);
26
- __export(exports, {
27
- compiler: () => compiler
28
- });
29
- var import_core_diagnostics = __toModule(require("./core-diagnostics.cjs"));
30
- var compiler = (0, import_core_diagnostics.createDiagnosticsCategory)({
31
- UMD_TRANSFORM: {
32
- category: "compile/umd_transform",
33
- message: `Error`
34
- }
35
- });
@@ -1,150 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, {get: all[name], enumerable: true});
11
- };
12
- var __exportStar = (target, module2, desc) => {
13
- if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
- for (let key of __getOwnPropNames(module2))
15
- if (!__hasOwnProp.call(target, key) && key !== "default")
16
- __defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
17
- }
18
- return target;
19
- };
20
- var __toModule = (module2) => {
21
- return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
22
- };
23
-
24
- // packages/@lwrjs/diagnostics/src/descriptions/configParser.ts
25
- __markAsModule(exports);
26
- __export(exports, {
27
- configParser: () => configParser
28
- });
29
- var import_core_diagnostics = __toModule(require("./core-diagnostics.cjs"));
30
- var configParser = (0, import_core_diagnostics.createDiagnosticsCategory)({
31
- TEST: {message: "test"},
32
- TEST_ADVICE: (tagName, openLocation) => ({
33
- message: `Unclosed ${tagName} tag`,
34
- advice: [
35
- {type: "log", category: "info", text: `Tag started here`},
36
- {
37
- type: "frame",
38
- location: openLocation
39
- }
40
- ]
41
- }),
42
- INVALID_JSON: (invalidJsonError) => ({
43
- category: "lwrConfig/invalidJson",
44
- message: `Invalid JSON: ${invalidJsonError}`
45
- }),
46
- INCORRECT_NODE_TYPE: (configProperty, expectedNodeType, actualNodeType) => ({
47
- category: "lwrConfig/invalidSchema",
48
- message: `Incorrect node type for property "${configProperty}". Expected type: "${expectedNodeType}", got "${actualNodeType}"`
49
- }),
50
- INVALID_EMPTY_NODE: (configProperty) => ({
51
- category: "lwrConfig/invalidSchema",
52
- message: `Property "${configProperty}" must not be an empty object`
53
- }),
54
- INVALID_PROPERTY: (configProperty, prop) => ({
55
- category: "lwrConfig/invalidSchema",
56
- message: `Unexpected property "${prop}" in "${configProperty}" configuration`
57
- }),
58
- NON_EMPTY_STRING: (configProperty, actualProp) => ({
59
- category: "lwrConfig/invalidSchema",
60
- message: `Property "${configProperty}" must be a non-empty string, received ${actualProp}`
61
- }),
62
- NON_EMPTY_ARRAY: (configProperty, actualProp) => ({
63
- category: "lwrConfig/invalidSchema",
64
- message: `Property "${configProperty}" must be a non-empty array, received ${actualProp}`
65
- }),
66
- INVALID_PORT: (configProperty, actualProp) => ({
67
- category: "lwrConfig/invalidSchema",
68
- message: `Property "${configProperty}" must be a valid port number, received ${actualProp}`
69
- }),
70
- INVALID_METHOD: (configProperty, actualProp) => ({
71
- category: "lwrConfig/invalidSchema",
72
- message: `Property "${configProperty}" must be "get" or "post", received ${actualProp}`
73
- }),
74
- INVALID_SERVER_TYPE: (configProperty, actualProp) => ({
75
- category: "lwrConfig/invalidSchema",
76
- message: `Property "${configProperty}" must be one of ["express" | "koa" | "fs"] , received ${actualProp}`
77
- }),
78
- INVALID_GENERATOR_CONFIG: (configProperty, actualProp) => ({
79
- category: "lwrConfig/invalidSchema",
80
- message: `Property "${configProperty}" must be an object , received ${actualProp}`
81
- }),
82
- INVALID_STATUS: (configProperty, actualProp) => ({
83
- category: "lwrConfig/invalidSchema",
84
- message: `Property "${configProperty}" must be 404 or 500, received ${actualProp}`
85
- }),
86
- INVALID_SPECIFIER: (configProperty, actualProp) => ({
87
- category: "lwrConfig/invalidSchema",
88
- message: `Property "${configProperty}" must be a valid specifier, received ${actualProp}`
89
- }),
90
- INVALID_PATH: (configProperty, actualProp) => ({
91
- category: "lwrConfig/invalidSchema",
92
- message: `Property "${configProperty}" must be a URI path string which starts but does not end with a slash, received ${actualProp}`
93
- }),
94
- INVALID_ORIGIN: (configProperty, actualProp) => ({
95
- category: "lwrConfig/invalidSchema",
96
- message: `Property "${configProperty}" must be a full URI string with a scheme (eg: "https://site.com"), received ${actualProp}`
97
- }),
98
- INVALID_FILE_PATTERN: (configProperty, actualProp) => ({
99
- category: "lwrConfig/invalidSchema",
100
- message: `Property "${configProperty}" must use a valid regex but received ${actualProp === "" ? "empty string" : actualProp}`
101
- }),
102
- INVALID_BASEPATH: (configProperty, actualProp) => ({
103
- category: "lwrConfig/invalidSchema",
104
- message: `Property "${configProperty}" must be a URI base path string which starts with a slash, received ${actualProp}`
105
- }),
106
- INVALID_SERVICE: (configProperty, actualProp) => ({
107
- category: "lwrConfig/invalidSchema",
108
- message: `Property "${configProperty}" must be a valid service (a non-empty string or array with [non-empty string, any]), received ${actualProp}`
109
- }),
110
- INVALID_ENVIRONMENT: (configProperty) => ({
111
- category: "lwrConfig/invalidSchema",
112
- message: `Property "${configProperty}" must define a default environment`
113
- }),
114
- MISSING_ONE_OF: (configProperty, childProps) => ({
115
- category: "lwrConfig/invalidSchema",
116
- message: `A "${configProperty}" must contain at least one of [${childProps}]`
117
- }),
118
- TOO_MANY: (configProperty, childProps) => ({
119
- category: "lwrConfig/invalidSchema",
120
- message: `A "${configProperty}" must contain exactly one of [${childProps}]`
121
- }),
122
- MISSING_REQUIRED: (configProperty, childProps) => ({
123
- category: "lwrConfig/invalidSchema",
124
- message: `Property "${configProperty}" is missing required properties [${childProps}]`
125
- }),
126
- DUPLICATE_IDS: (configProperty, dupeIds) => ({
127
- category: "lwrConfig/invalidSchema",
128
- message: `Each "${configProperty}" must have a unique "id", found duplicates [${dupeIds}]`
129
- }),
130
- COMPILE_LOCKER_SSR: () => ({
131
- category: "lwrConfig/invalidSchema",
132
- message: 'If "locker.enabled: true" and any route sets "ssr: true", then "locker.clientOnly" must also be set to "true"'
133
- }),
134
- DUPLICATE_BUNDLE_CONFIG: (dupeIds) => ({
135
- category: "lwrConfig/invalidSchema",
136
- message: `Found duplicate specifiers in BundleConfig: [${dupeIds}]`
137
- }),
138
- DEFAULT_NOT_IN_LOCALES: (defaultLocale, locales) => ({
139
- category: "lwrConfig/invalidSchema",
140
- message: `Property "i18n.defaultLocale" must be in the list of "i18n.locales": ${defaultLocale} [${locales}]`
141
- }),
142
- FALLBACK_NOT_IN_LOCALES: (fallback, locales) => ({
143
- category: "lwrConfig/invalidSchema",
144
- message: `Property "i18n.locales.fallback" must be in the list of "i18n.locales": ${fallback} [${locales}]`
145
- }),
146
- SSR_WITHOUT_PRELOAD: (configProperty) => ({
147
- category: "lwrConfig/invalidSchema",
148
- message: `A route cannot have preloadData disabled when ssr is enabled:": ${configProperty}`
149
- })
150
- });
@@ -1,37 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
3
- var __export = (target, all) => {
4
- for (var name in all)
5
- __defProp(target, name, {get: all[name], enumerable: true});
6
- };
7
-
8
- // packages/@lwrjs/diagnostics/src/descriptions/core-diagnostics.ts
9
- __markAsModule(exports);
10
- __export(exports, {
11
- createDiagnosticsCategory: () => createDiagnosticsCategory
12
- });
13
- function createDiagnosticsCategory(input) {
14
- const category = {};
15
- for (const key in input) {
16
- const value = input[key];
17
- if (typeof value === "function") {
18
- const callback = value;
19
- category[key] = function(...params) {
20
- const {message, advice = [], ...ret} = callback(...params.map((p) => escape(String(p))));
21
- return {
22
- ...ret,
23
- advice,
24
- message
25
- };
26
- };
27
- } else {
28
- const {message, advice = [], ...obj} = value;
29
- category[key] = {
30
- ...obj,
31
- advice,
32
- message
33
- };
34
- }
35
- }
36
- return category;
37
- }
@@ -1,5 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
3
-
4
- // packages/@lwrjs/diagnostics/src/types.ts
5
- __markAsModule(exports);
@@ -1,7 +0,0 @@
1
- export declare const compiler: import("../types.js").OutputMessagesCategory<{
2
- UMD_TRANSFORM: {
3
- category: "compile/umd_transform";
4
- message: string;
5
- };
6
- }>;
7
- //# sourceMappingURL=compiler.d.ts.map
@@ -1,8 +0,0 @@
1
- import { createDiagnosticsCategory } from './core-diagnostics.js';
2
- export const compiler = createDiagnosticsCategory({
3
- UMD_TRANSFORM: {
4
- category: 'compile/umd_transform',
5
- message: `Error`,
6
- },
7
- });
8
- //# sourceMappingURL=compiler.js.map
@@ -1,129 +0,0 @@
1
- import type { DiagnosticLocation } from '../types.js';
2
- export declare const configParser: import("../types.js").OutputMessagesCategory<{
3
- TEST: {
4
- message: string;
5
- };
6
- TEST_ADVICE: (tagName: string, openLocation: DiagnosticLocation) => {
7
- message: string;
8
- advice: ({
9
- type: "log";
10
- category: "info";
11
- text: string;
12
- location?: undefined;
13
- } | {
14
- type: "frame";
15
- location: DiagnosticLocation;
16
- category?: undefined;
17
- text?: undefined;
18
- })[];
19
- };
20
- INVALID_JSON: (invalidJsonError: string) => {
21
- category: "lwrConfig/invalidJson";
22
- message: string;
23
- };
24
- INCORRECT_NODE_TYPE: (configProperty: string, expectedNodeType: string, actualNodeType: string) => {
25
- category: "lwrConfig/invalidSchema";
26
- message: string;
27
- };
28
- INVALID_EMPTY_NODE: (configProperty: string) => {
29
- category: "lwrConfig/invalidSchema";
30
- message: string;
31
- };
32
- INVALID_PROPERTY: (configProperty: string, prop: string) => {
33
- category: "lwrConfig/invalidSchema";
34
- message: string;
35
- };
36
- NON_EMPTY_STRING: (configProperty: string, actualProp: string) => {
37
- category: "lwrConfig/invalidSchema";
38
- message: string;
39
- };
40
- NON_EMPTY_ARRAY: (configProperty: string, actualProp: string) => {
41
- category: "lwrConfig/invalidSchema";
42
- message: string;
43
- };
44
- INVALID_PORT: (configProperty: string, actualProp: string) => {
45
- category: "lwrConfig/invalidSchema";
46
- message: string;
47
- };
48
- INVALID_METHOD: (configProperty: string, actualProp: string) => {
49
- category: "lwrConfig/invalidSchema";
50
- message: string;
51
- };
52
- INVALID_SERVER_TYPE: (configProperty: string, actualProp: string) => {
53
- category: "lwrConfig/invalidSchema";
54
- message: string;
55
- };
56
- INVALID_GENERATOR_CONFIG: (configProperty: string, actualProp: string) => {
57
- category: "lwrConfig/invalidSchema";
58
- message: string;
59
- };
60
- INVALID_STATUS: (configProperty: string, actualProp: string) => {
61
- category: "lwrConfig/invalidSchema";
62
- message: string;
63
- };
64
- INVALID_SPECIFIER: (configProperty: string, actualProp: string) => {
65
- category: "lwrConfig/invalidSchema";
66
- message: string;
67
- };
68
- INVALID_PATH: (configProperty: string, actualProp: string) => {
69
- category: "lwrConfig/invalidSchema";
70
- message: string;
71
- };
72
- INVALID_ORIGIN: (configProperty: string, actualProp: string) => {
73
- category: "lwrConfig/invalidSchema";
74
- message: string;
75
- };
76
- INVALID_FILE_PATTERN: (configProperty: string, actualProp: string | any[]) => {
77
- category: "lwrConfig/invalidSchema";
78
- message: string;
79
- };
80
- INVALID_BASEPATH: (configProperty: string, actualProp: string) => {
81
- category: "lwrConfig/invalidSchema";
82
- message: string;
83
- };
84
- INVALID_SERVICE: (configProperty: string, actualProp: string) => {
85
- category: "lwrConfig/invalidSchema";
86
- message: string;
87
- };
88
- INVALID_ENVIRONMENT: (configProperty: string) => {
89
- category: "lwrConfig/invalidSchema";
90
- message: string;
91
- };
92
- MISSING_ONE_OF: (configProperty: string, childProps: string[]) => {
93
- category: "lwrConfig/invalidSchema";
94
- message: string;
95
- };
96
- TOO_MANY: (configProperty: string, childProps: string[]) => {
97
- category: "lwrConfig/invalidSchema";
98
- message: string;
99
- };
100
- MISSING_REQUIRED: (configProperty: string, childProps: string[]) => {
101
- category: "lwrConfig/invalidSchema";
102
- message: string;
103
- };
104
- DUPLICATE_IDS: (configProperty: string, dupeIds: string[]) => {
105
- category: "lwrConfig/invalidSchema";
106
- message: string;
107
- };
108
- COMPILE_LOCKER_SSR: () => {
109
- category: "lwrConfig/invalidSchema";
110
- message: string;
111
- };
112
- DUPLICATE_BUNDLE_CONFIG: (dupeIds: string[]) => {
113
- category: "lwrConfig/invalidSchema";
114
- message: string;
115
- };
116
- DEFAULT_NOT_IN_LOCALES: (defaultLocale: string, locales: string[]) => {
117
- category: "lwrConfig/invalidSchema";
118
- message: string;
119
- };
120
- FALLBACK_NOT_IN_LOCALES: (fallback: string, locales: string[]) => {
121
- category: "lwrConfig/invalidSchema";
122
- message: string;
123
- };
124
- SSR_WITHOUT_PRELOAD: (configProperty: string) => {
125
- category: "lwrConfig/invalidSchema";
126
- message: string;
127
- };
128
- }>;
129
- //# sourceMappingURL=configParser.d.ts.map
@@ -1,123 +0,0 @@
1
- import { createDiagnosticsCategory } from './core-diagnostics.js';
2
- export const configParser = createDiagnosticsCategory({
3
- TEST: { message: 'test' },
4
- TEST_ADVICE: (tagName, openLocation) => ({
5
- message: `Unclosed ${tagName} tag`,
6
- advice: [
7
- { type: 'log', category: 'info', text: `Tag started here` },
8
- {
9
- type: 'frame',
10
- location: openLocation,
11
- },
12
- ],
13
- }),
14
- INVALID_JSON: (invalidJsonError) => ({
15
- category: 'lwrConfig/invalidJson',
16
- message: `Invalid JSON: ${invalidJsonError}`,
17
- }),
18
- INCORRECT_NODE_TYPE: (configProperty, expectedNodeType, actualNodeType) => ({
19
- category: 'lwrConfig/invalidSchema',
20
- message: `Incorrect node type for property "${configProperty}". Expected type: "${expectedNodeType}", got "${actualNodeType}"`,
21
- }),
22
- INVALID_EMPTY_NODE: (configProperty) => ({
23
- category: 'lwrConfig/invalidSchema',
24
- message: `Property "${configProperty}" must not be an empty object`,
25
- }),
26
- INVALID_PROPERTY: (configProperty, prop) => ({
27
- category: 'lwrConfig/invalidSchema',
28
- message: `Unexpected property "${prop}" in "${configProperty}" configuration`,
29
- }),
30
- NON_EMPTY_STRING: (configProperty, actualProp) => ({
31
- category: 'lwrConfig/invalidSchema',
32
- message: `Property "${configProperty}" must be a non-empty string, received ${actualProp}`,
33
- }),
34
- NON_EMPTY_ARRAY: (configProperty, actualProp) => ({
35
- category: 'lwrConfig/invalidSchema',
36
- message: `Property "${configProperty}" must be a non-empty array, received ${actualProp}`,
37
- }),
38
- INVALID_PORT: (configProperty, actualProp) => ({
39
- category: 'lwrConfig/invalidSchema',
40
- message: `Property "${configProperty}" must be a valid port number, received ${actualProp}`,
41
- }),
42
- INVALID_METHOD: (configProperty, actualProp) => ({
43
- category: 'lwrConfig/invalidSchema',
44
- message: `Property "${configProperty}" must be "get" or "post", received ${actualProp}`,
45
- }),
46
- INVALID_SERVER_TYPE: (configProperty, actualProp) => ({
47
- category: 'lwrConfig/invalidSchema',
48
- message: `Property "${configProperty}" must be one of ["express" | "koa" | "fs"] , received ${actualProp}`,
49
- }),
50
- INVALID_GENERATOR_CONFIG: (configProperty, actualProp) => ({
51
- category: 'lwrConfig/invalidSchema',
52
- message: `Property "${configProperty}" must be an object , received ${actualProp}`,
53
- }),
54
- INVALID_STATUS: (configProperty, actualProp) => ({
55
- category: 'lwrConfig/invalidSchema',
56
- message: `Property "${configProperty}" must be 404 or 500, received ${actualProp}`,
57
- }),
58
- INVALID_SPECIFIER: (configProperty, actualProp) => ({
59
- category: 'lwrConfig/invalidSchema',
60
- message: `Property "${configProperty}" must be a valid specifier, received ${actualProp}`,
61
- }),
62
- INVALID_PATH: (configProperty, actualProp) => ({
63
- category: 'lwrConfig/invalidSchema',
64
- message: `Property "${configProperty}" must be a URI path string which starts but does not end with a slash, received ${actualProp}`,
65
- }),
66
- INVALID_ORIGIN: (configProperty, actualProp) => ({
67
- category: 'lwrConfig/invalidSchema',
68
- message: `Property "${configProperty}" must be a full URI string with a scheme (eg: "https://site.com"), received ${actualProp}`,
69
- }),
70
- INVALID_FILE_PATTERN: (configProperty, actualProp) => ({
71
- category: 'lwrConfig/invalidSchema',
72
- message: `Property "${configProperty}" must use a valid regex but received ${actualProp === '' ? 'empty string' : actualProp}`,
73
- }),
74
- INVALID_BASEPATH: (configProperty, actualProp) => ({
75
- category: 'lwrConfig/invalidSchema',
76
- message: `Property "${configProperty}" must be a URI base path string which starts with a slash, received ${actualProp}`,
77
- }),
78
- INVALID_SERVICE: (configProperty, actualProp) => ({
79
- category: 'lwrConfig/invalidSchema',
80
- message: `Property "${configProperty}" must be a valid service (a non-empty string or array with [non-empty string, any]), received ${actualProp}`,
81
- }),
82
- INVALID_ENVIRONMENT: (configProperty) => ({
83
- category: 'lwrConfig/invalidSchema',
84
- message: `Property "${configProperty}" must define a default environment`,
85
- }),
86
- MISSING_ONE_OF: (configProperty, childProps) => ({
87
- category: 'lwrConfig/invalidSchema',
88
- message: `A "${configProperty}" must contain at least one of [${childProps}]`,
89
- }),
90
- TOO_MANY: (configProperty, childProps) => ({
91
- category: 'lwrConfig/invalidSchema',
92
- message: `A "${configProperty}" must contain exactly one of [${childProps}]`,
93
- }),
94
- MISSING_REQUIRED: (configProperty, childProps) => ({
95
- category: 'lwrConfig/invalidSchema',
96
- message: `Property "${configProperty}" is missing required properties [${childProps}]`,
97
- }),
98
- DUPLICATE_IDS: (configProperty, dupeIds) => ({
99
- category: 'lwrConfig/invalidSchema',
100
- message: `Each "${configProperty}" must have a unique "id", found duplicates [${dupeIds}]`,
101
- }),
102
- COMPILE_LOCKER_SSR: () => ({
103
- category: 'lwrConfig/invalidSchema',
104
- message: 'If "locker.enabled: true" and any route sets "ssr: true", then "locker.clientOnly" must also be set to "true"',
105
- }),
106
- DUPLICATE_BUNDLE_CONFIG: (dupeIds) => ({
107
- category: 'lwrConfig/invalidSchema',
108
- message: `Found duplicate specifiers in BundleConfig: [${dupeIds}]`,
109
- }),
110
- DEFAULT_NOT_IN_LOCALES: (defaultLocale, locales) => ({
111
- category: 'lwrConfig/invalidSchema',
112
- message: `Property "i18n.defaultLocale" must be in the list of "i18n.locales": ${defaultLocale} [${locales}]`,
113
- }),
114
- FALLBACK_NOT_IN_LOCALES: (fallback, locales) => ({
115
- category: 'lwrConfig/invalidSchema',
116
- message: `Property "i18n.locales.fallback" must be in the list of "i18n.locales": ${fallback} [${locales}]`,
117
- }),
118
- SSR_WITHOUT_PRELOAD: (configProperty) => ({
119
- category: 'lwrConfig/invalidSchema',
120
- message: `A route cannot have preloadData disabled when ssr is enabled:": ${configProperty}`,
121
- }),
122
- });
123
- //# sourceMappingURL=configParser.js.map
@@ -1,3 +0,0 @@
1
- import type { InputMessagesCategory, OutputMessagesCategory } from '../types.js';
2
- export declare function createDiagnosticsCategory<Input extends InputMessagesCategory>(input: Input): OutputMessagesCategory<Input>;
3
- //# sourceMappingURL=core-diagnostics.d.ts.map
@@ -1,27 +0,0 @@
1
- export function createDiagnosticsCategory(input) {
2
- const category = {};
3
- for (const key in input) {
4
- const value = input[key];
5
- if (typeof value === 'function') {
6
- const callback = value;
7
- category[key] = function (...params) {
8
- const { message, advice = [], ...ret } = callback(...params.map((p) => escape(String(p))));
9
- return {
10
- ...ret,
11
- advice,
12
- message,
13
- };
14
- };
15
- }
16
- else {
17
- const { message, advice = [], ...obj } = value;
18
- category[key] = {
19
- ...obj,
20
- advice,
21
- message,
22
- };
23
- }
24
- }
25
- return category;
26
- }
27
- //# sourceMappingURL=core-diagnostics.js.map