@lwrjs/core 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.
@@ -157,10 +157,8 @@ var LwrApp = class {
157
157
  try {
158
158
  await (0, import_server_warmup.warmupServer)(config, app.getInternalRequestKey());
159
159
  } catch (err) {
160
- const diagnostic = (0, import_diagnostics.createSingleDiagnosticError)({
161
- description: import_diagnostics.descriptions.SERVER.WARMUP_ERROR(err.message)
162
- }, import_diagnostics.LwrServerError);
163
- return reject(diagnostic);
160
+ const e = new import_diagnostics.LwrServerError(import_diagnostics.descriptions.SERVER.WARMUP_ERROR(err.message));
161
+ return reject(e);
164
162
  }
165
163
  }
166
164
  const opts = {serverMode, port};
@@ -92,7 +92,7 @@ function createAssetMiddleware(context) {
92
92
  }
93
93
  res.status(200).stream(asset.stream());
94
94
  } catch (error) {
95
- if (import_path.default.dirname(assetId.specifier) === (basePath ? basePath : "/") && error instanceof import_diagnostics.DiagnosticsError && error?.diagnostics[0]?.description.category === "lwrUnresolvable/asset") {
95
+ if (import_path.default.dirname(assetId.specifier) === (basePath ? basePath : "/") && error instanceof import_diagnostics.LwrUnresolvableError && error?.type === "asset") {
96
96
  await next();
97
97
  return;
98
98
  }
@@ -45,17 +45,17 @@ function createBundleMiddleware(context) {
45
45
  return async (req, res) => {
46
46
  if (!req.validateEnvironmentRequest(appConfig)) {
47
47
  res.status(400);
48
- res.send(import_diagnostics.descriptions.UNRESOLVABLE.INVALID_ENVIRONMENT(req.params.environment).message);
48
+ res.send(import_diagnostics.descriptions.APPLICATION.INVALID_ENVIRONMENT(req.params.environment));
49
49
  return;
50
50
  }
51
51
  if (!req.validateJsonRequest()) {
52
52
  res.status(400);
53
- res.send(import_diagnostics.descriptions.UNRESOLVABLE.INVALID_JSON().message);
53
+ res.send(import_diagnostics.descriptions.APPLICATION.INVALID_JSON());
54
54
  return;
55
55
  }
56
56
  if (!req.validateApiVersion(appConfig)) {
57
57
  res.status(400);
58
- res.send(import_diagnostics.descriptions.UNRESOLVABLE.INVALID_API_VERSION(req.params.apiVersion, appConfig.apiVersion).message);
58
+ res.send(import_diagnostics.descriptions.APPLICATION.INVALID_API_VERSION(req.params.apiVersion, appConfig.apiVersion));
59
59
  return;
60
60
  }
61
61
  const {runtimeEnvironment, runtimeParams} = req.getRuntimeContext(defaultRuntimeEnvironment);
@@ -92,7 +92,7 @@ function createSourceMapMiddleware(context) {
92
92
  return async (req, res) => {
93
93
  if (!req.validateEnvironmentRequest(appConfig)) {
94
94
  res.status(400);
95
- res.send(import_diagnostics.descriptions.UNRESOLVABLE.INVALID_ENVIRONMENT(req.params.environment).message);
95
+ res.send(import_diagnostics.descriptions.APPLICATION.INVALID_ENVIRONMENT(req.params.environment));
96
96
  return;
97
97
  }
98
98
  const {runtimeEnvironment} = req.getRuntimeContext(defaultRuntimeEnvironment);
@@ -41,7 +41,7 @@ function createMappingMiddleware(context) {
41
41
  return async (req, res) => {
42
42
  if (!req.validateEnvironmentRequest(appConfig)) {
43
43
  res.status(400);
44
- res.send(import_diagnostics.descriptions.UNRESOLVABLE.INVALID_ENVIRONMENT(req.params.environment).message);
44
+ res.send(import_diagnostics.descriptions.APPLICATION.INVALID_ENVIRONMENT(req.params.environment));
45
45
  return;
46
46
  }
47
47
  const {runtimeEnvironment, runtimeParams} = req.getRuntimeContext(defaultRuntimeEnvironment);
@@ -39,17 +39,17 @@ function createModuleMiddleware(context) {
39
39
  return async (req, res) => {
40
40
  if (!req.validateEnvironmentRequest(appConfig)) {
41
41
  res.status(400);
42
- res.send(import_diagnostics.descriptions.UNRESOLVABLE.INVALID_ENVIRONMENT(req.params.environment).message);
42
+ res.send(import_diagnostics.descriptions.APPLICATION.INVALID_ENVIRONMENT(req.params.environment));
43
43
  return;
44
44
  }
45
45
  if (!req.validateJsonRequest()) {
46
46
  res.status(400);
47
- res.send(import_diagnostics.descriptions.UNRESOLVABLE.INVALID_JSON().message);
47
+ res.send(import_diagnostics.descriptions.APPLICATION.INVALID_JSON());
48
48
  return;
49
49
  }
50
50
  if (!req.validateApiVersion(appConfig)) {
51
51
  res.status(400);
52
- res.send(import_diagnostics.descriptions.UNRESOLVABLE.INVALID_API_VERSION(req.params.apiVersion, appConfig.apiVersion).message);
52
+ res.send(import_diagnostics.descriptions.APPLICATION.INVALID_API_VERSION(req.params.apiVersion, appConfig.apiVersion));
53
53
  return;
54
54
  }
55
55
  const {runtimeEnvironment, runtimeParams} = req.getRuntimeContext(defaultRuntimeEnvironment);
@@ -70,7 +70,7 @@ function createModuleMiddleware(context) {
70
70
  });
71
71
  const {ownHash, linkedSource} = moduleDefinition;
72
72
  if (signature !== import_shared_utils.LATEST_SIGNATURE && ownHash !== signature) {
73
- res.status(404).send(import_diagnostics.descriptions.UNRESOLVABLE.SIGNED_MODULE(moduleId.specifier, signature).message);
73
+ res.status(404).send(import_diagnostics.descriptions.UNRESOLVABLE.SIGNED_MODULE(moduleId.specifier, signature));
74
74
  return;
75
75
  }
76
76
  if (req.isSiteGeneration()) {
@@ -33,7 +33,7 @@ function createResourceMiddleware(context) {
33
33
  const {appConfig, resourceRegistry, runtimeEnvironment: defaultRuntimeEnvironment} = context;
34
34
  return async (req, res) => {
35
35
  if (!req.validateEnvironmentRequest(appConfig)) {
36
- res.status(400).send(import_diagnostics.descriptions.UNRESOLVABLE.INVALID_ENVIRONMENT(req.params.environment).message);
36
+ res.status(400).send(import_diagnostics.descriptions.APPLICATION.INVALID_ENVIRONMENT(req.params.environment));
37
37
  return;
38
38
  }
39
39
  const {runtimeEnvironment, runtimeParams} = req.getRuntimeContext(defaultRuntimeEnvironment);
@@ -51,7 +51,7 @@ function createResourceMiddleware(context) {
51
51
  res.status(200).type(resource.type).stream(resource.stream());
52
52
  return;
53
53
  }
54
- res.status(404).send(import_diagnostics.descriptions.UNRESOLVABLE.RESOURCE(resourceId.specifier, resourceId.version).message);
54
+ res.status(404).send(import_diagnostics.descriptions.UNRESOLVABLE.RESOURCE(resourceId.specifier, resourceId.version));
55
55
  };
56
56
  }
57
57
  function resourceMiddleware(app, context) {
@@ -29,13 +29,13 @@ __export(exports, {
29
29
  var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
30
30
  var import_diagnostics2 = __toModule(require("@lwrjs/diagnostics"));
31
31
  function createReturnStatus(error, url) {
32
- if (error instanceof import_diagnostics.LwrUnresolvableError && error.diagnostics[0].description.category === "lwrUnresolvable/invalid") {
32
+ if (error instanceof import_diagnostics.LwrApplicationError) {
33
33
  return {status: 400, message: error.message};
34
34
  }
35
35
  if (error instanceof import_diagnostics.LwrUnresolvableError) {
36
36
  return {status: 404, message: error.message};
37
37
  }
38
- return {status: 500, message: `${import_diagnostics.descriptions.SERVER.SERVER_ERROR(url).message}: ${error.message}`};
38
+ return {status: 500, message: `${import_diagnostics.descriptions.SERVER.SERVER_ERROR(url)}: ${error.message}`};
39
39
  }
40
40
  function handleErrors(middleware) {
41
41
  return async (req, res, next) => {
@@ -37,9 +37,7 @@ function validateSpecifier(specifer) {
37
37
  function getModuleIdentity(req, importer) {
38
38
  const {specifier, signature} = req.params;
39
39
  if (validateSpecifier(specifier) === false) {
40
- throw (0, import_diagnostics.createSingleDiagnosticError)({
41
- description: import_diagnostics.descriptions.UNRESOLVABLE.INVALID_SPECIFIER(specifier)
42
- }, import_diagnostics.LwrUnresolvableError);
40
+ throw new import_diagnostics.LwrApplicationError(import_diagnostics.descriptions.APPLICATION.INVALID_SPECIFIER(specifier));
43
41
  }
44
42
  const moduleId = (0, import_shared_utils.explodeSpecifier)(specifier);
45
43
  return {
@@ -63,9 +61,7 @@ function getMappingIdentity(req) {
63
61
  function getResourceIdentity(req) {
64
62
  const {specifier, signature = import_shared_utils.LATEST_SIGNATURE} = req.params;
65
63
  if (validateSpecifier(specifier) === false) {
66
- throw (0, import_diagnostics.createSingleDiagnosticError)({
67
- description: import_diagnostics.descriptions.UNRESOLVABLE.INVALID_SPECIFIER(specifier)
68
- }, import_diagnostics.LwrUnresolvableError);
64
+ throw new import_diagnostics.LwrApplicationError(import_diagnostics.descriptions.APPLICATION.INVALID_SPECIFIER(specifier));
69
65
  }
70
66
  const resourceId = (0, import_shared_utils.explodeSpecifier)(specifier);
71
67
  return {
@@ -77,9 +73,7 @@ function getAssetIdentity(req) {
77
73
  const {signature, immutable, assetType: type} = req.params;
78
74
  const specifier = type ? process.platform === "win32" ? req.params[0] : "/" + req.params[0] : req.originalUrl.split("?")[0];
79
75
  if (validateSpecifier(specifier) === false) {
80
- throw (0, import_diagnostics.createSingleDiagnosticError)({
81
- description: import_diagnostics.descriptions.UNRESOLVABLE.INVALID_SPECIFIER(specifier)
82
- }, import_diagnostics.LwrUnresolvableError);
76
+ throw new import_diagnostics.LwrApplicationError(import_diagnostics.descriptions.APPLICATION.INVALID_SPECIFIER(specifier));
83
77
  }
84
78
  return {
85
79
  immutable,
@@ -45,12 +45,12 @@ function createViewMiddleware(route, errorRoutes, context, viewHandler) {
45
45
  return async (req, res) => {
46
46
  if (!req.validateEnvironmentRequest(appConfig)) {
47
47
  res.status(400);
48
- res.send(import_diagnostics.descriptions.UNRESOLVABLE.INVALID_ENVIRONMENT(req.params.environment).message);
48
+ res.send(import_diagnostics.descriptions.APPLICATION.INVALID_ENVIRONMENT(req.params.environment));
49
49
  return;
50
50
  }
51
51
  if (!req.validateJsonRequest()) {
52
52
  res.status(400);
53
- res.send(import_diagnostics.descriptions.UNRESOLVABLE.INVALID_JSON().message);
53
+ res.send(import_diagnostics.descriptions.APPLICATION.INVALID_JSON());
54
54
  return;
55
55
  }
56
56
  const {runtimeEnvironment, runtimeParams: defaultRuntimeParams} = req.getRuntimeContext(context.runtimeEnvironment);
@@ -187,7 +187,7 @@ function createConfigMiddleware(routes, context, viewHandler) {
187
187
  const {appId, encodedViewPath} = req.params;
188
188
  const route = routes.find((route2) => route2.id === appId);
189
189
  if (!route) {
190
- res.status(404).send(import_diagnostics.descriptions.UNRESOLVABLE.APP_CONFIG(appId).message);
190
+ res.status(404).send(import_diagnostics.descriptions.UNRESOLVABLE.APP_CONFIG(appId));
191
191
  return;
192
192
  }
193
193
  const url = (0, import_shared_utils.decodeViewPath)(encodedViewPath);
@@ -218,7 +218,7 @@ function createConfigMiddleware(routes, context, viewHandler) {
218
218
  };
219
219
  const viewResponse = await viewHandler.getViewConfiguration(viewRequest, route, runtimeEnvironment, runtimeParams);
220
220
  if (!viewResponse) {
221
- res.status(404).send(import_diagnostics.descriptions.UNRESOLVABLE.VIEW_CONFIG(url).message);
221
+ res.status(404).send(import_diagnostics.descriptions.UNRESOLVABLE.VIEW_CONFIG(url));
222
222
  return;
223
223
  }
224
224
  if (!res.hasHeader("cache-control")) {
@@ -238,7 +238,7 @@ function createNotFoundMiddleware(errorRoutes, context, viewHandler) {
238
238
  return createViewMiddleware(notFoundRoute, errorRoutes, context, viewHandler);
239
239
  }
240
240
  return (req, res) => {
241
- res.status(404).send(import_diagnostics.descriptions.UNRESOLVABLE.VIEW(req.originalUrl).message);
241
+ res.status(404).send(import_diagnostics.descriptions.UNRESOLVABLE.VIEW(req.originalUrl));
242
242
  };
243
243
  }
244
244
  function viewMiddleware(app, context) {
package/build/es/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { getFeatureFlags } from '@lwrjs/shared-utils';
2
2
  import { createInternalServer } from '@lwrjs/server';
3
- import { LwrServerError, createSingleDiagnosticError, descriptions, logger } from '@lwrjs/diagnostics';
3
+ import { LwrServerError, descriptions, logger } from '@lwrjs/diagnostics';
4
4
  import { DEFAULT_LWR_BOOTSTRAP_CONFIG, loadConfig, executeConfigHooks, executeStartHooks, executeInstrumentationHooks, executeContextHooks, } from '@lwrjs/config';
5
5
  import { loadHooks, loadServices, loadRouteHandlers } from '@lwrjs/config/modules';
6
6
  import SiteGenerator from './tools/static-generation.js';
@@ -152,10 +152,8 @@ export class LwrApp {
152
152
  await warmupServer(config, app.getInternalRequestKey());
153
153
  }
154
154
  catch (err) {
155
- const diagnostic = createSingleDiagnosticError({
156
- description: descriptions.SERVER.WARMUP_ERROR(err.message),
157
- }, LwrServerError);
158
- return reject(diagnostic);
155
+ const e = new LwrServerError(descriptions.SERVER.WARMUP_ERROR(err.message));
156
+ return reject(e);
159
157
  }
160
158
  }
161
159
  const opts = { serverMode, port };
@@ -1,6 +1,6 @@
1
1
  import { getFeatureFlags } from '@lwrjs/shared-utils';
2
2
  import path from 'path';
3
- import { DiagnosticsError, logger } from '@lwrjs/diagnostics';
3
+ import { LwrUnresolvableError, logger } from '@lwrjs/diagnostics';
4
4
  import { RequestHandlerSpan, getTracer } from '@lwrjs/instrumentation';
5
5
  import { getAssetIdentity } from './utils/identity.js';
6
6
  import { handleErrors } from './utils/error-handling.js';
@@ -76,8 +76,8 @@ function createAssetMiddleware(context) {
76
76
  catch (error) {
77
77
  // Ignore asset not found for root asset requests
78
78
  if (path.dirname(assetId.specifier) === (basePath ? basePath : '/') &&
79
- error instanceof DiagnosticsError &&
80
- error?.diagnostics[0]?.description.category === 'lwrUnresolvable/asset') {
79
+ error instanceof LwrUnresolvableError &&
80
+ error?.type === 'asset') {
81
81
  // Must await other middleware or this can respond before expected.
82
82
  await next();
83
83
  return;
@@ -12,18 +12,17 @@ function createBundleMiddleware(context) {
12
12
  return async (req, res) => {
13
13
  if (!req.validateEnvironmentRequest(appConfig)) {
14
14
  res.status(400);
15
- res.send(descriptions.UNRESOLVABLE.INVALID_ENVIRONMENT(req.params.environment).message);
15
+ res.send(descriptions.APPLICATION.INVALID_ENVIRONMENT(req.params.environment));
16
16
  return;
17
17
  }
18
18
  if (!req.validateJsonRequest()) {
19
19
  res.status(400);
20
- res.send(descriptions.UNRESOLVABLE.INVALID_JSON().message);
20
+ res.send(descriptions.APPLICATION.INVALID_JSON());
21
21
  return;
22
22
  }
23
23
  if (!req.validateApiVersion(appConfig)) {
24
24
  res.status(400);
25
- res.send(descriptions.UNRESOLVABLE.INVALID_API_VERSION(req.params.apiVersion, appConfig.apiVersion)
26
- .message);
25
+ res.send(descriptions.APPLICATION.INVALID_API_VERSION(req.params.apiVersion, appConfig.apiVersion));
27
26
  return;
28
27
  }
29
28
  const { runtimeEnvironment, runtimeParams } = req.getRuntimeContext(defaultRuntimeEnvironment);
@@ -66,7 +65,7 @@ function createSourceMapMiddleware(context) {
66
65
  return async (req, res) => {
67
66
  if (!req.validateEnvironmentRequest(appConfig)) {
68
67
  res.status(400);
69
- res.send(descriptions.UNRESOLVABLE.INVALID_ENVIRONMENT(req.params.environment).message);
68
+ res.send(descriptions.APPLICATION.INVALID_ENVIRONMENT(req.params.environment));
70
69
  return;
71
70
  }
72
71
  const { runtimeEnvironment } = req.getRuntimeContext(defaultRuntimeEnvironment);
@@ -8,7 +8,7 @@ function createMappingMiddleware(context) {
8
8
  return async (req, res) => {
9
9
  if (!req.validateEnvironmentRequest(appConfig)) {
10
10
  res.status(400);
11
- res.send(descriptions.UNRESOLVABLE.INVALID_ENVIRONMENT(req.params.environment).message);
11
+ res.send(descriptions.APPLICATION.INVALID_ENVIRONMENT(req.params.environment));
12
12
  return;
13
13
  }
14
14
  const { runtimeEnvironment, runtimeParams } = req.getRuntimeContext(defaultRuntimeEnvironment);
@@ -11,18 +11,17 @@ function createModuleMiddleware(context) {
11
11
  return async (req, res) => {
12
12
  if (!req.validateEnvironmentRequest(appConfig)) {
13
13
  res.status(400);
14
- res.send(descriptions.UNRESOLVABLE.INVALID_ENVIRONMENT(req.params.environment).message);
14
+ res.send(descriptions.APPLICATION.INVALID_ENVIRONMENT(req.params.environment));
15
15
  return;
16
16
  }
17
17
  if (!req.validateJsonRequest()) {
18
18
  res.status(400);
19
- res.send(descriptions.UNRESOLVABLE.INVALID_JSON().message);
19
+ res.send(descriptions.APPLICATION.INVALID_JSON());
20
20
  return;
21
21
  }
22
22
  if (!req.validateApiVersion(appConfig)) {
23
23
  res.status(400);
24
- res.send(descriptions.UNRESOLVABLE.INVALID_API_VERSION(req.params.apiVersion, appConfig.apiVersion)
25
- .message);
24
+ res.send(descriptions.APPLICATION.INVALID_API_VERSION(req.params.apiVersion, appConfig.apiVersion));
26
25
  return;
27
26
  }
28
27
  const { runtimeEnvironment, runtimeParams } = req.getRuntimeContext(defaultRuntimeEnvironment);
@@ -48,7 +47,7 @@ function createModuleMiddleware(context) {
48
47
  const { ownHash, linkedSource } = moduleDefinition;
49
48
  // validate the requested instances exists
50
49
  if (signature !== LATEST_SIGNATURE && ownHash !== signature) {
51
- res.status(404).send(descriptions.UNRESOLVABLE.SIGNED_MODULE(moduleId.specifier, signature).message);
50
+ res.status(404).send(descriptions.UNRESOLVABLE.SIGNED_MODULE(moduleId.specifier, signature));
52
51
  return;
53
52
  }
54
53
  if (req.isSiteGeneration()) {
@@ -5,7 +5,7 @@ function createResourceMiddleware(context) {
5
5
  const { appConfig, resourceRegistry, runtimeEnvironment: defaultRuntimeEnvironment } = context;
6
6
  return async (req, res) => {
7
7
  if (!req.validateEnvironmentRequest(appConfig)) {
8
- res.status(400).send(descriptions.UNRESOLVABLE.INVALID_ENVIRONMENT(req.params.environment).message);
8
+ res.status(400).send(descriptions.APPLICATION.INVALID_ENVIRONMENT(req.params.environment));
9
9
  return;
10
10
  }
11
11
  const { runtimeEnvironment, runtimeParams } = req.getRuntimeContext(defaultRuntimeEnvironment);
@@ -23,7 +23,7 @@ function createResourceMiddleware(context) {
23
23
  res.status(200).type(resource.type).stream(resource.stream());
24
24
  return;
25
25
  }
26
- res.status(404).send(descriptions.UNRESOLVABLE.RESOURCE(resourceId.specifier, resourceId.version).message);
26
+ res.status(404).send(descriptions.UNRESOLVABLE.RESOURCE(resourceId.specifier, resourceId.version));
27
27
  };
28
28
  }
29
29
  export function resourceMiddleware(app, context) {
@@ -1,14 +1,14 @@
1
- import { descriptions, DiagnosticsError, LwrUnresolvableError } from '@lwrjs/diagnostics';
1
+ import { descriptions, DiagnosticsError, LwrApplicationError, LwrUnresolvableError, } from '@lwrjs/diagnostics';
2
2
  import { logger } from '@lwrjs/diagnostics';
3
3
  function createReturnStatus(error, url) {
4
- if (error instanceof LwrUnresolvableError &&
5
- error.diagnostics[0].description.category === 'lwrUnresolvable/invalid') {
4
+ if (error instanceof LwrApplicationError) {
6
5
  return { status: 400, message: error.message };
7
6
  }
8
7
  if (error instanceof LwrUnresolvableError) {
9
8
  return { status: 404, message: error.message };
10
9
  }
11
- return { status: 500, message: `${descriptions.SERVER.SERVER_ERROR(url).message}: ${error.message}` };
10
+ // catchall: likely a LwrServerError
11
+ return { status: 500, message: `${descriptions.SERVER.SERVER_ERROR(url)}: ${error.message}` };
12
12
  }
13
13
  export function handleErrors(middleware) {
14
14
  return async (req, res, next) => {
@@ -1,14 +1,12 @@
1
1
  import { explodeSpecifier, explodeSpecifiers, LATEST_SIGNATURE } from '@lwrjs/shared-utils';
2
- import { createSingleDiagnosticError, descriptions, LwrUnresolvableError } from '@lwrjs/diagnostics';
2
+ import { descriptions, LwrApplicationError } from '@lwrjs/diagnostics';
3
3
  function validateSpecifier(specifer) {
4
4
  return specifer.indexOf('../') < 0;
5
5
  }
6
6
  export function getModuleIdentity(req, importer) {
7
7
  const { specifier, signature } = req.params;
8
8
  if (validateSpecifier(specifier) === false) {
9
- throw createSingleDiagnosticError({
10
- description: descriptions.UNRESOLVABLE.INVALID_SPECIFIER(specifier),
11
- }, LwrUnresolvableError);
9
+ throw new LwrApplicationError(descriptions.APPLICATION.INVALID_SPECIFIER(specifier));
12
10
  }
13
11
  const moduleId = explodeSpecifier(specifier);
14
12
  return {
@@ -32,9 +30,7 @@ export function getMappingIdentity(req) {
32
30
  export function getResourceIdentity(req) {
33
31
  const { specifier, signature = LATEST_SIGNATURE } = req.params;
34
32
  if (validateSpecifier(specifier) === false) {
35
- throw createSingleDiagnosticError({
36
- description: descriptions.UNRESOLVABLE.INVALID_SPECIFIER(specifier),
37
- }, LwrUnresolvableError);
33
+ throw new LwrApplicationError(descriptions.APPLICATION.INVALID_SPECIFIER(specifier));
38
34
  }
39
35
  const resourceId = explodeSpecifier(specifier);
40
36
  return {
@@ -50,9 +46,7 @@ export function getAssetIdentity(req) {
50
46
  : '/' + req.params[0]
51
47
  : req.originalUrl.split('?')[0];
52
48
  if (validateSpecifier(specifier) === false) {
53
- throw createSingleDiagnosticError({
54
- description: descriptions.UNRESOLVABLE.INVALID_SPECIFIER(specifier),
55
- }, LwrUnresolvableError);
49
+ throw new LwrApplicationError(descriptions.APPLICATION.INVALID_SPECIFIER(specifier));
56
50
  }
57
51
  return {
58
52
  immutable,
@@ -17,12 +17,12 @@ function createViewMiddleware(route, errorRoutes, context, viewHandler) {
17
17
  return async (req, res) => {
18
18
  if (!req.validateEnvironmentRequest(appConfig)) {
19
19
  res.status(400);
20
- res.send(descriptions.UNRESOLVABLE.INVALID_ENVIRONMENT(req.params.environment).message);
20
+ res.send(descriptions.APPLICATION.INVALID_ENVIRONMENT(req.params.environment));
21
21
  return;
22
22
  }
23
23
  if (!req.validateJsonRequest()) {
24
24
  res.status(400);
25
- res.send(descriptions.UNRESOLVABLE.INVALID_JSON().message);
25
+ res.send(descriptions.APPLICATION.INVALID_JSON());
26
26
  return;
27
27
  }
28
28
  const { runtimeEnvironment, runtimeParams: defaultRuntimeParams } = req.getRuntimeContext(context.runtimeEnvironment);
@@ -181,7 +181,7 @@ function createConfigMiddleware(routes, context, viewHandler) {
181
181
  // match the app id to a route
182
182
  const route = routes.find((route) => route.id === appId);
183
183
  if (!route) {
184
- res.status(404).send(descriptions.UNRESOLVABLE.APP_CONFIG(appId).message);
184
+ res.status(404).send(descriptions.UNRESOLVABLE.APP_CONFIG(appId));
185
185
  return;
186
186
  }
187
187
  // decode the resolved view path and extract any params.
@@ -217,7 +217,7 @@ function createConfigMiddleware(routes, context, viewHandler) {
217
217
  };
218
218
  const viewResponse = await viewHandler.getViewConfiguration(viewRequest, route, runtimeEnvironment, runtimeParams);
219
219
  if (!viewResponse) {
220
- res.status(404).send(descriptions.UNRESOLVABLE.VIEW_CONFIG(url).message);
220
+ res.status(404).send(descriptions.UNRESOLVABLE.VIEW_CONFIG(url));
221
221
  return;
222
222
  }
223
223
  // Pick the shortest TTL between the view response and route object
@@ -238,7 +238,7 @@ function createNotFoundMiddleware(errorRoutes, context, viewHandler) {
238
238
  return createViewMiddleware(notFoundRoute, errorRoutes, context, viewHandler);
239
239
  }
240
240
  return (req, res) => {
241
- res.status(404).send(descriptions.UNRESOLVABLE.VIEW(req.originalUrl).message);
241
+ res.status(404).send(descriptions.UNRESOLVABLE.VIEW(req.originalUrl));
242
242
  };
243
243
  }
244
244
  export function viewMiddleware(app, context) {
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",
@@ -43,34 +43,34 @@
43
43
  "build": "tsc -b"
44
44
  },
45
45
  "dependencies": {
46
- "@lwrjs/app-service": "0.17.2-alpha.0",
47
- "@lwrjs/asset-registry": "0.17.2-alpha.0",
48
- "@lwrjs/asset-transformer": "0.17.2-alpha.0",
49
- "@lwrjs/base-view-provider": "0.17.2-alpha.0",
50
- "@lwrjs/base-view-transformer": "0.17.2-alpha.0",
51
- "@lwrjs/client-modules": "0.17.2-alpha.0",
52
- "@lwrjs/config": "0.17.2-alpha.0",
53
- "@lwrjs/diagnostics": "0.17.2-alpha.0",
54
- "@lwrjs/esbuild": "0.17.2-alpha.0",
55
- "@lwrjs/fs-asset-provider": "0.17.2-alpha.0",
56
- "@lwrjs/fs-watch": "0.17.2-alpha.0",
57
- "@lwrjs/html-view-provider": "0.17.2-alpha.0",
58
- "@lwrjs/instrumentation": "0.17.2-alpha.0",
59
- "@lwrjs/loader": "0.17.2-alpha.0",
60
- "@lwrjs/lwc-module-provider": "0.17.2-alpha.0",
61
- "@lwrjs/lwc-ssr": "0.17.2-alpha.0",
62
- "@lwrjs/markdown-view-provider": "0.17.2-alpha.0",
63
- "@lwrjs/module-bundler": "0.17.2-alpha.0",
64
- "@lwrjs/module-registry": "0.17.2-alpha.0",
65
- "@lwrjs/npm-module-provider": "0.17.2-alpha.0",
66
- "@lwrjs/nunjucks-view-provider": "0.17.2-alpha.0",
67
- "@lwrjs/o11y": "0.17.2-alpha.0",
68
- "@lwrjs/resource-registry": "0.17.2-alpha.0",
69
- "@lwrjs/router": "0.17.2-alpha.0",
70
- "@lwrjs/server": "0.17.2-alpha.0",
71
- "@lwrjs/shared-utils": "0.17.2-alpha.0",
72
- "@lwrjs/static": "0.17.2-alpha.0",
73
- "@lwrjs/view-registry": "0.17.2-alpha.0",
46
+ "@lwrjs/app-service": "0.17.2-alpha.2",
47
+ "@lwrjs/asset-registry": "0.17.2-alpha.2",
48
+ "@lwrjs/asset-transformer": "0.17.2-alpha.2",
49
+ "@lwrjs/base-view-provider": "0.17.2-alpha.2",
50
+ "@lwrjs/base-view-transformer": "0.17.2-alpha.2",
51
+ "@lwrjs/client-modules": "0.17.2-alpha.2",
52
+ "@lwrjs/config": "0.17.2-alpha.2",
53
+ "@lwrjs/diagnostics": "0.17.2-alpha.2",
54
+ "@lwrjs/esbuild": "0.17.2-alpha.2",
55
+ "@lwrjs/fs-asset-provider": "0.17.2-alpha.2",
56
+ "@lwrjs/fs-watch": "0.17.2-alpha.2",
57
+ "@lwrjs/html-view-provider": "0.17.2-alpha.2",
58
+ "@lwrjs/instrumentation": "0.17.2-alpha.2",
59
+ "@lwrjs/loader": "0.17.2-alpha.2",
60
+ "@lwrjs/lwc-module-provider": "0.17.2-alpha.2",
61
+ "@lwrjs/lwc-ssr": "0.17.2-alpha.2",
62
+ "@lwrjs/markdown-view-provider": "0.17.2-alpha.2",
63
+ "@lwrjs/module-bundler": "0.17.2-alpha.2",
64
+ "@lwrjs/module-registry": "0.17.2-alpha.2",
65
+ "@lwrjs/npm-module-provider": "0.17.2-alpha.2",
66
+ "@lwrjs/nunjucks-view-provider": "0.17.2-alpha.2",
67
+ "@lwrjs/o11y": "0.17.2-alpha.2",
68
+ "@lwrjs/resource-registry": "0.17.2-alpha.2",
69
+ "@lwrjs/router": "0.17.2-alpha.2",
70
+ "@lwrjs/server": "0.17.2-alpha.2",
71
+ "@lwrjs/shared-utils": "0.17.2-alpha.2",
72
+ "@lwrjs/static": "0.17.2-alpha.2",
73
+ "@lwrjs/view-registry": "0.17.2-alpha.2",
74
74
  "chokidar": "^3.6.0",
75
75
  "esbuild": "^0.9.7",
76
76
  "fs-extra": "^11.2.0",
@@ -80,7 +80,7 @@
80
80
  "ws": "^8.18.0"
81
81
  },
82
82
  "devDependencies": {
83
- "@lwrjs/types": "0.17.2-alpha.0",
83
+ "@lwrjs/types": "0.17.2-alpha.2",
84
84
  "@types/ws": "^8.5.12",
85
85
  "memfs": "^4.13.0"
86
86
  },
@@ -93,5 +93,5 @@
93
93
  "volta": {
94
94
  "extends": "../../../package.json"
95
95
  },
96
- "gitHead": "128e2d6e17d05fb780523b60c2717ef8ebfd9b57"
96
+ "gitHead": "739b237f5d7f2c1989142cb505a56cc763f21976"
97
97
  }