@lwrjs/diagnostics 0.12.0-alpha.0 → 0.12.0-alpha.10

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.
@@ -134,5 +134,9 @@ var configParser = (0, import_core_diagnostics.createDiagnosticsCategory)({
134
134
  FALLBACK_NOT_IN_LOCALES: (fallback, locales) => ({
135
135
  category: "lwrConfig/invalidSchema",
136
136
  message: `Property "i18n.locales.fallback" must be in the list of "i18n.locales": ${fallback} [${locales}]`
137
+ }),
138
+ SSR_WITHOUT_PRELOAD: (configProperty) => ({
139
+ category: "lwrConfig/invalidSchema",
140
+ message: `A route cannot have preloadData disabled when ssr is enabled:": ${configProperty}`
137
141
  })
138
142
  });
@@ -17,7 +17,7 @@ function createDiagnosticsCategory(input) {
17
17
  if (typeof value === "function") {
18
18
  const callback = value;
19
19
  category[key] = function(...params) {
20
- const {message, advice = [], ...ret} = callback(...params);
20
+ const {message, advice = [], ...ret} = callback(...params.map((p) => escape(String(p))));
21
21
  return {
22
22
  ...ret,
23
23
  advice,
@@ -80,6 +80,10 @@ var unresolvable = (0, import_core_diagnostics.createDiagnosticsCategory)({
80
80
  category: "lwrUnresolvable/invalid",
81
81
  message: "400: Accept header and json query parameter are incompatible"
82
82
  }),
83
+ INVALID_API_VERSION: (apiVersion, expectedVersion) => ({
84
+ category: "lwrUnresolvable/invalid",
85
+ message: `400: API Version "${apiVersion}" is not supported. Expected "${expectedVersion}"`
86
+ }),
83
87
  INVALID_ENVIRONMENT: (environment) => ({
84
88
  category: "lwrUnresolvable/invalid",
85
89
  message: `400: Environment "${environment}" is not supported`
@@ -97,5 +101,9 @@ ${error}`
97
101
  category: "lwrUnresolvable/routes",
98
102
  message: `Invalid JSON: Route config file ${file} is invalid
99
103
  ${error}`
104
+ }),
105
+ PRELOAD_MODULE: (specifier) => ({
106
+ category: "lwrUnresolvable/invalid",
107
+ message: `Invalid preload module: ${specifier}`
100
108
  })
101
109
  });
@@ -34,6 +34,7 @@ __export(exports, {
34
34
  stringifyError: () => stringifyError
35
35
  });
36
36
  var import_errors = __toModule(require("./errors.cjs"));
37
+ var import_util = __toModule(require("util"));
37
38
  var SILENT = "silent";
38
39
  var VERBOSE = "verbose";
39
40
  var DEBUG = "debug";
@@ -76,7 +77,7 @@ function log(level, message, additionalInfo) {
76
77
  }
77
78
  }
78
79
  const logMessage = `[${level}]${gap(message)}${message}`;
79
- const additionalMessage = additionalInfo ? `Additional Info: ${JSON.stringify(additionalInfo)}` : void 0;
80
+ const additionalMessage = additionalInfo ? `Additional Info: ${(0, import_util.inspect)(additionalInfo)}` : void 0;
80
81
  if (level == ERROR) {
81
82
  console.error("%s", logMessage);
82
83
  if (additionalInfo) {
@@ -117,7 +118,7 @@ var stringifyError = (error) => {
117
118
  const descriptor = Object.getOwnPropertyDescriptor(error, property);
118
119
  retObj[property] = descriptor?.value;
119
120
  }
120
- return JSON.stringify(retObj);
121
+ return (0, import_util.inspect)(retObj);
121
122
  }
122
123
  };
123
124
  function gap(message) {
@@ -191,5 +191,12 @@ export declare const configParser: {
191
191
  advice: import("../types.js").DiagnosticAdvice;
192
192
  message: string;
193
193
  };
194
+ SSR_WITHOUT_PRELOAD: (configProperty: string) => Omit<{
195
+ category: "lwrConfig/invalidSchema";
196
+ message: string;
197
+ }, "message" | "advice"> & {
198
+ advice: import("../types.js").DiagnosticAdvice;
199
+ message: string;
200
+ };
194
201
  };
195
202
  //# sourceMappingURL=configParser.d.ts.map
@@ -107,5 +107,9 @@ export const configParser = createDiagnosticsCategory({
107
107
  category: 'lwrConfig/invalidSchema',
108
108
  message: `Property "i18n.locales.fallback" must be in the list of "i18n.locales": ${fallback} [${locales}]`,
109
109
  }),
110
+ SSR_WITHOUT_PRELOAD: (configProperty) => ({
111
+ category: 'lwrConfig/invalidSchema',
112
+ message: `A route cannot have preloadData disabled when ssr is enabled:": ${configProperty}`,
113
+ }),
110
114
  });
111
115
  //# sourceMappingURL=configParser.js.map
@@ -7,7 +7,7 @@ export function createDiagnosticsCategory(input) {
7
7
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
8
8
  // @ts-ignore
9
9
  category[key] = function (...params) {
10
- const { message, advice = [], ...ret } = callback(...params);
10
+ const { message, advice = [], ...ret } = callback(...params.map((p) => escape(String(p))));
11
11
  return {
12
12
  ...ret,
13
13
  advice,
@@ -191,6 +191,13 @@ export declare const descriptions: {
191
191
  advice: import("../types.js").DiagnosticAdvice;
192
192
  message: string;
193
193
  };
194
+ SSR_WITHOUT_PRELOAD: (configProperty: string) => Omit<{
195
+ category: "lwrConfig/invalidSchema";
196
+ message: string;
197
+ }, "message" | "advice"> & {
198
+ advice: import("../types.js").DiagnosticAdvice;
199
+ message: string;
200
+ };
194
201
  };
195
202
  UNRESOLVABLE: {
196
203
  ASSET: (assetPath: string) => Omit<{
@@ -284,6 +291,13 @@ export declare const descriptions: {
284
291
  advice: import("../types.js").DiagnosticAdvice;
285
292
  message: string;
286
293
  };
294
+ INVALID_API_VERSION: (apiVersion: string, expectedVersion: any) => Omit<{
295
+ category: "lwrUnresolvable/invalid";
296
+ message: string;
297
+ }, "message" | "advice"> & {
298
+ advice: import("../types.js").DiagnosticAdvice;
299
+ message: string;
300
+ };
287
301
  INVALID_ENVIRONMENT: (environment: string) => Omit<{
288
302
  category: "lwrUnresolvable/invalid";
289
303
  message: string;
@@ -312,6 +326,13 @@ export declare const descriptions: {
312
326
  advice: import("../types.js").DiagnosticAdvice;
313
327
  message: string;
314
328
  };
329
+ PRELOAD_MODULE: (specifier: string) => Omit<{
330
+ category: "lwrUnresolvable/invalid";
331
+ message: string;
332
+ }, "message" | "advice"> & {
333
+ advice: import("../types.js").DiagnosticAdvice;
334
+ message: string;
335
+ };
315
336
  };
316
337
  SERVER: {
317
338
  WARMUP_ERROR: (error: string) => Omit<{
@@ -90,6 +90,13 @@ export declare const unresolvable: {
90
90
  advice: import("../types.js").DiagnosticAdvice;
91
91
  message: string;
92
92
  };
93
+ INVALID_API_VERSION: (apiVersion: string, expectedVersion: any) => Omit<{
94
+ category: "lwrUnresolvable/invalid";
95
+ message: string;
96
+ }, "message" | "advice"> & {
97
+ advice: import("../types.js").DiagnosticAdvice;
98
+ message: string;
99
+ };
93
100
  INVALID_ENVIRONMENT: (environment: string) => Omit<{
94
101
  category: "lwrUnresolvable/invalid";
95
102
  message: string;
@@ -118,5 +125,12 @@ export declare const unresolvable: {
118
125
  advice: import("../types.js").DiagnosticAdvice;
119
126
  message: string;
120
127
  };
128
+ PRELOAD_MODULE: (specifier: string) => Omit<{
129
+ category: "lwrUnresolvable/invalid";
130
+ message: string;
131
+ }, "message" | "advice"> & {
132
+ advice: import("../types.js").DiagnosticAdvice;
133
+ message: string;
134
+ };
121
135
  };
122
136
  //# sourceMappingURL=unresolvable.d.ts.map
@@ -52,6 +52,10 @@ export const unresolvable = createDiagnosticsCategory({
52
52
  category: 'lwrUnresolvable/invalid',
53
53
  message: '400: Accept header and json query parameter are incompatible',
54
54
  }),
55
+ INVALID_API_VERSION: (apiVersion, expectedVersion) => ({
56
+ category: 'lwrUnresolvable/invalid',
57
+ message: `400: API Version "${apiVersion}" is not supported. Expected "${expectedVersion}"`,
58
+ }),
55
59
  INVALID_ENVIRONMENT: (environment) => ({
56
60
  category: 'lwrUnresolvable/invalid',
57
61
  message: `400: Environment "${environment}" is not supported`,
@@ -68,5 +72,9 @@ export const unresolvable = createDiagnosticsCategory({
68
72
  category: 'lwrUnresolvable/routes',
69
73
  message: `Invalid JSON: Route config file ${file} is invalid\n${error}`,
70
74
  }),
75
+ PRELOAD_MODULE: (specifier) => ({
76
+ category: 'lwrUnresolvable/invalid',
77
+ message: `Invalid preload module: ${specifier}`,
78
+ }),
71
79
  });
72
80
  //# sourceMappingURL=unresolvable.js.map
@@ -1,4 +1,5 @@
1
1
  import { DiagnosticsError } from './errors.js';
2
+ import { inspect } from 'util';
2
3
  export const SILENT = 'silent';
3
4
  export const VERBOSE = 'verbose';
4
5
  export const DEBUG = 'debug';
@@ -44,9 +45,7 @@ function log(level, message, additionalInfo) {
44
45
  }
45
46
  }
46
47
  const logMessage = `[${level}]${gap(message)}${message}`;
47
- const additionalMessage = additionalInfo
48
- ? `Additional Info: ${JSON.stringify(additionalInfo)}`
49
- : undefined;
48
+ const additionalMessage = additionalInfo ? `Additional Info: ${inspect(additionalInfo)}` : undefined;
50
49
  if (level == ERROR) {
51
50
  console.error('\x1b[31m%s\x1b[0m', logMessage); // red
52
51
  if (additionalInfo) {
@@ -91,7 +90,7 @@ export const stringifyError = (error) => {
91
90
  const descriptor = Object.getOwnPropertyDescriptor(error, property);
92
91
  retObj[property] = descriptor?.value;
93
92
  }
94
- return JSON.stringify(retObj);
93
+ return inspect(retObj);
95
94
  }
96
95
  };
97
96
  // Return a space if there should be a space between the message and the level
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.12.0-alpha.0",
7
+ "version": "0.12.0-alpha.10",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -35,13 +35,16 @@
35
35
  "test": "jest"
36
36
  },
37
37
  "devDependencies": {
38
- "@lwrjs/types": "0.12.0-alpha.0",
38
+ "@lwrjs/types": "0.12.0-alpha.10",
39
39
  "jest": "^26.6.3",
40
40
  "ts-jest": "^26.5.6",
41
41
  "typescript": "^4.9.5"
42
42
  },
43
43
  "engines": {
44
- "node": ">=16.0.0"
44
+ "node": ">=18.0.0"
45
45
  },
46
- "gitHead": "e79862bc238ededc3cf61f0d2c7d8120d1105a6b"
46
+ "volta": {
47
+ "extends": "../../../package.json"
48
+ },
49
+ "gitHead": "36759959f624aa40d371dc9ee698dd472813f19c"
47
50
  }