@lwrjs/core 0.12.0-alpha.0 → 0.12.0-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.
@@ -112,7 +112,7 @@ function createViewMiddleware(route, errorRoutes, context, viewHandler) {
112
112
  }
113
113
  function createConfigMiddleware(routes, context, viewHandler) {
114
114
  return async (req, res) => {
115
- const {runtimeEnvironment, runtimeParams} = req.getRuntimeContext(context.runtimeEnvironment);
115
+ const {runtimeEnvironment, runtimeParams: defaultRuntimeParams} = req.getRuntimeContext(context.runtimeEnvironment);
116
116
  const {appId, encodedViewPath} = req.params;
117
117
  const route = routes.find((route2) => route2.id === appId);
118
118
  if (!route) {
@@ -120,16 +120,31 @@ function createConfigMiddleware(routes, context, viewHandler) {
120
120
  return;
121
121
  }
122
122
  const url = (0, import_shared_utils.decodeViewPath)(encodedViewPath);
123
+ let requestPath = url;
124
+ const query = {};
125
+ if (url.indexOf("?") !== -1) {
126
+ requestPath = url.substring(0, url.indexOf("?"));
127
+ const searchParams = new URLSearchParams(url.substring(url.indexOf("?")));
128
+ for (const [key, value] of searchParams.entries()) {
129
+ query[key] = value;
130
+ }
131
+ }
123
132
  const originalUrl = req.originalUrl;
124
- const requestPath = route.path;
125
- const params = (0, import_shared_utils.extractRequestParams)(requestPath, url, req.params);
133
+ const routePath = route.path;
134
+ const params = (0, import_shared_utils.extractRequestParams)(routePath, url, req.params);
126
135
  const viewRequest = {
127
136
  url,
128
137
  originalUrl,
129
138
  params,
130
- query: req.query,
139
+ query,
131
140
  requestPath
132
141
  };
142
+ const runtimeParams = {
143
+ ...defaultRuntimeParams,
144
+ url: viewRequest.url,
145
+ params: viewRequest.params,
146
+ query: viewRequest.query
147
+ };
133
148
  const viewResponse = await viewHandler.getViewConfiguration(viewRequest, route, runtimeEnvironment, runtimeParams);
134
149
  if (!viewResponse) {
135
150
  res.status(404).send(import_diagnostics.descriptions.UNRESOLVABLE.VIEW_CONFIG(url).message);
@@ -91,7 +91,7 @@ function createViewMiddleware(route, errorRoutes, context, viewHandler) {
91
91
  }
92
92
  function createConfigMiddleware(routes, context, viewHandler) {
93
93
  return async (req, res) => {
94
- const { runtimeEnvironment, runtimeParams } = req.getRuntimeContext(context.runtimeEnvironment);
94
+ const { runtimeEnvironment, runtimeParams: defaultRuntimeParams } = req.getRuntimeContext(context.runtimeEnvironment);
95
95
  const { appId, encodedViewPath } = req.params;
96
96
  // match the app id to a route
97
97
  const route = routes.find((route) => route.id === appId);
@@ -101,16 +101,35 @@ function createConfigMiddleware(routes, context, viewHandler) {
101
101
  }
102
102
  // decode the resolved view path and extract any params.
103
103
  const url = decodeViewPath(encodedViewPath);
104
+ let requestPath = url;
105
+ // Create an empty object to store the key-value pairs
106
+ const query = {};
107
+ if (url.indexOf('?') !== -1) {
108
+ // Remove query string from the requestPath
109
+ requestPath = url.substring(0, url.indexOf('?'));
110
+ const searchParams = new URLSearchParams(url.substring(url.indexOf('?')));
111
+ // Iterate over the entries of the URLSearchParams and populate the object
112
+ for (const [key, value] of searchParams.entries()) {
113
+ query[key] = value;
114
+ }
115
+ }
104
116
  const originalUrl = req.originalUrl;
105
- const requestPath = route.path;
106
- const params = extractRequestParams(requestPath, url, req.params);
117
+ const routePath = route.path;
118
+ const params = extractRequestParams(routePath, url, req.params);
107
119
  const viewRequest = {
108
120
  url,
109
121
  originalUrl,
110
122
  params,
111
- query: req.query,
123
+ query,
112
124
  requestPath,
113
125
  };
126
+ // Augment runtime params with viewRequest info
127
+ const runtimeParams = {
128
+ ...defaultRuntimeParams,
129
+ url: viewRequest.url,
130
+ params: viewRequest.params,
131
+ query: viewRequest.query,
132
+ };
114
133
  const viewResponse = await viewHandler.getViewConfiguration(viewRequest, route, runtimeEnvironment, runtimeParams);
115
134
  if (!viewResponse) {
116
135
  res.status(404).send(descriptions.UNRESOLVABLE.VIEW_CONFIG(url).message);
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.2",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -39,33 +39,33 @@
39
39
  "build": "tsc -b"
40
40
  },
41
41
  "dependencies": {
42
- "@lwrjs/app-service": "0.12.0-alpha.0",
43
- "@lwrjs/asset-registry": "0.12.0-alpha.0",
44
- "@lwrjs/asset-transformer": "0.12.0-alpha.0",
45
- "@lwrjs/base-view-provider": "0.12.0-alpha.0",
46
- "@lwrjs/base-view-transformer": "0.12.0-alpha.0",
47
- "@lwrjs/client-modules": "0.12.0-alpha.0",
48
- "@lwrjs/config": "0.12.0-alpha.0",
49
- "@lwrjs/diagnostics": "0.12.0-alpha.0",
50
- "@lwrjs/esbuild": "0.12.0-alpha.0",
51
- "@lwrjs/fs-asset-provider": "0.12.0-alpha.0",
52
- "@lwrjs/fs-watch": "0.12.0-alpha.0",
53
- "@lwrjs/html-view-provider": "0.12.0-alpha.0",
54
- "@lwrjs/instrumentation": "0.12.0-alpha.0",
55
- "@lwrjs/loader": "0.12.0-alpha.0",
56
- "@lwrjs/lwc-module-provider": "0.12.0-alpha.0",
57
- "@lwrjs/markdown-view-provider": "0.12.0-alpha.0",
58
- "@lwrjs/module-bundler": "0.12.0-alpha.0",
59
- "@lwrjs/module-registry": "0.12.0-alpha.0",
60
- "@lwrjs/npm-module-provider": "0.12.0-alpha.0",
61
- "@lwrjs/nunjucks-view-provider": "0.12.0-alpha.0",
62
- "@lwrjs/o11y": "0.12.0-alpha.0",
63
- "@lwrjs/resource-registry": "0.12.0-alpha.0",
64
- "@lwrjs/router": "0.12.0-alpha.0",
65
- "@lwrjs/server": "0.12.0-alpha.0",
66
- "@lwrjs/shared-utils": "0.12.0-alpha.0",
67
- "@lwrjs/static": "0.12.0-alpha.0",
68
- "@lwrjs/view-registry": "0.12.0-alpha.0",
42
+ "@lwrjs/app-service": "0.12.0-alpha.2",
43
+ "@lwrjs/asset-registry": "0.12.0-alpha.2",
44
+ "@lwrjs/asset-transformer": "0.12.0-alpha.2",
45
+ "@lwrjs/base-view-provider": "0.12.0-alpha.2",
46
+ "@lwrjs/base-view-transformer": "0.12.0-alpha.2",
47
+ "@lwrjs/client-modules": "0.12.0-alpha.2",
48
+ "@lwrjs/config": "0.12.0-alpha.2",
49
+ "@lwrjs/diagnostics": "0.12.0-alpha.2",
50
+ "@lwrjs/esbuild": "0.12.0-alpha.2",
51
+ "@lwrjs/fs-asset-provider": "0.12.0-alpha.2",
52
+ "@lwrjs/fs-watch": "0.12.0-alpha.2",
53
+ "@lwrjs/html-view-provider": "0.12.0-alpha.2",
54
+ "@lwrjs/instrumentation": "0.12.0-alpha.2",
55
+ "@lwrjs/loader": "0.12.0-alpha.2",
56
+ "@lwrjs/lwc-module-provider": "0.12.0-alpha.2",
57
+ "@lwrjs/markdown-view-provider": "0.12.0-alpha.2",
58
+ "@lwrjs/module-bundler": "0.12.0-alpha.2",
59
+ "@lwrjs/module-registry": "0.12.0-alpha.2",
60
+ "@lwrjs/npm-module-provider": "0.12.0-alpha.2",
61
+ "@lwrjs/nunjucks-view-provider": "0.12.0-alpha.2",
62
+ "@lwrjs/o11y": "0.12.0-alpha.2",
63
+ "@lwrjs/resource-registry": "0.12.0-alpha.2",
64
+ "@lwrjs/router": "0.12.0-alpha.2",
65
+ "@lwrjs/server": "0.12.0-alpha.2",
66
+ "@lwrjs/shared-utils": "0.12.0-alpha.2",
67
+ "@lwrjs/static": "0.12.0-alpha.2",
68
+ "@lwrjs/view-registry": "0.12.0-alpha.2",
69
69
  "chokidar": "^3.5.3",
70
70
  "esbuild": "^0.9.7",
71
71
  "fs-extra": "^11.1.1",
@@ -75,17 +75,17 @@
75
75
  "ws": "^8.8.1"
76
76
  },
77
77
  "devDependencies": {
78
- "@lwrjs/types": "0.12.0-alpha.0",
78
+ "@lwrjs/types": "0.12.0-alpha.2",
79
79
  "@types/ws": "^8.5.3"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "lwc": ">= 2.x"
83
83
  },
84
84
  "engines": {
85
- "node": ">=16.0.0"
85
+ "node": ">=18.0.0"
86
86
  },
87
87
  "volta": {
88
88
  "extends": "../../../package.json"
89
89
  },
90
- "gitHead": "e79862bc238ededc3cf61f0d2c7d8120d1105a6b"
90
+ "gitHead": "586a2aa659882483af9249dc3db7fe07bc842a25"
91
91
  }