@pwrdrvr/microapps-router-lib 0.4.0-alpha.9 → 1.0.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 (44) hide show
  1. package/dist/get-app-info.d.ts +9 -0
  2. package/dist/get-app-info.d.ts.map +1 -0
  3. package/dist/get-app-info.js +25 -0
  4. package/dist/get-app-info.js.map +1 -0
  5. package/dist/get-route.d.ts +83 -0
  6. package/dist/get-route.d.ts.map +1 -0
  7. package/dist/get-route.js +171 -0
  8. package/dist/get-route.js.map +1 -0
  9. package/dist/index.d.ts +5 -96
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +11 -372
  12. package/dist/index.js.map +1 -1
  13. package/dist/load-app-frame.d.ts +8 -0
  14. package/dist/load-app-frame.d.ts.map +1 -0
  15. package/dist/load-app-frame.js +38 -0
  16. package/dist/load-app-frame.js.map +1 -0
  17. package/dist/normalize-path-prefix.d.ts +8 -0
  18. package/dist/normalize-path-prefix.d.ts.map +1 -0
  19. package/dist/normalize-path-prefix.js +21 -0
  20. package/dist/normalize-path-prefix.js.map +1 -0
  21. package/dist/redirect-default-file.d.ts +18 -0
  22. package/dist/redirect-default-file.d.ts.map +1 -0
  23. package/dist/redirect-default-file.js +54 -0
  24. package/dist/redirect-default-file.js.map +1 -0
  25. package/dist/route-app.d.ts +23 -0
  26. package/dist/route-app.d.ts.map +1 -0
  27. package/dist/route-app.js +169 -0
  28. package/dist/route-app.js.map +1 -0
  29. package/package.json +5 -3
  30. package/src/get-app-info.spec.ts +77 -0
  31. package/src/get-app-info.ts +31 -0
  32. package/src/get-route.spec.ts +585 -0
  33. package/src/get-route.ts +282 -0
  34. package/src/index.ts +5 -537
  35. package/src/load-app-frame.spec.ts +51 -0
  36. package/src/load-app-frame.ts +36 -0
  37. package/src/normalize-path-prefix.spec.ts +27 -0
  38. package/src/normalize-path-prefix.ts +18 -0
  39. package/src/redirect-default-file.spec.ts +98 -0
  40. package/src/redirect-default-file.ts +79 -0
  41. package/src/route-app.spec.ts +128 -0
  42. package/src/route-app.ts +202 -0
  43. package/src/index.spec.ts +0 -322
  44. /package/src/{index.prefix.spec.ts → get-route.prefix.spec.ts} +0 -0
package/dist/index.js CHANGED
@@ -1,375 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetAppInfo = exports.GetRoute = exports.normalizePathPrefix = exports.loadAppFrame = exports.AppVersionCache = void 0;
4
- const tslib_1 = require("tslib");
5
- require("source-map-support/register");
6
- const path_1 = tslib_1.__importDefault(require("path"));
7
- const fs_extra_1 = require("fs-extra");
8
- const log_1 = tslib_1.__importDefault(require("./lib/log"));
9
- const app_cache_1 = require("./app-cache");
10
- Object.defineProperty(exports, "AppVersionCache", { enumerable: true, get: function () { return app_cache_1.AppVersionCache; } });
11
- const log = log_1.default.Instance;
12
- /**
13
- * Find and load the appFrame file
14
- * @returns
15
- */
16
- function loadAppFrame({ basePath = '.' }) {
17
- const paths = [
18
- basePath,
19
- path_1.default.join(basePath, '..'),
20
- path_1.default.join(basePath, 'templates'),
21
- basePath,
22
- '/opt',
23
- '/opt/templates',
24
- ];
25
- for (const pathRoot of paths) {
26
- const fullPath = path_1.default.join(pathRoot, 'appFrame.html');
27
- try {
28
- if ((0, fs_extra_1.pathExistsSync)(fullPath)) {
29
- log.info('found html file', { fullPath });
30
- return (0, fs_extra_1.readFileSync)(fullPath, 'utf-8');
31
- }
32
- }
33
- catch (_a) {
34
- // Don't care - we get here if stat throws because the file does not exist
35
- }
36
- }
37
- log.error('appFrame.html not found');
38
- throw new Error('appFrame.html not found');
39
- }
40
- exports.loadAppFrame = loadAppFrame;
41
- /**
42
- * Ensure that the path starts with a / and does not end with a /
43
- *
44
- * @param pathPrefix
45
- * @returns
46
- */
47
- function normalizePathPrefix(pathPrefix) {
48
- let normalizedPathPrefix = pathPrefix;
49
- if (normalizedPathPrefix !== '' && !normalizedPathPrefix.startsWith('/')) {
50
- normalizedPathPrefix = '/' + pathPrefix;
51
- }
52
- if (normalizedPathPrefix.endsWith('/')) {
53
- normalizedPathPrefix.substring(0, normalizedPathPrefix.length - 1);
54
- }
55
- return normalizedPathPrefix;
56
- }
57
- exports.normalizePathPrefix = normalizePathPrefix;
58
- /**
59
- * Get information about immediate redirect, immediate response,
60
- * or which host to route the request to.
61
- *
62
- * @param event
63
- *
64
- * @returns IGetRouteResult
65
- */
66
- async function GetRoute(event) {
67
- const { dbManager, normalizedPathPrefix = '', queryStringParameters } = event;
68
- try {
69
- if (normalizedPathPrefix && !event.rawPath.startsWith(normalizedPathPrefix)) {
70
- // The prefix is required if configured, if missing we cannot serve this app
71
- return { statusCode: 404, errorMessage: 'Request not routable' };
72
- }
73
- const pathAfterPrefix = normalizedPathPrefix && event.rawPath.startsWith(normalizedPathPrefix)
74
- ? event.rawPath.slice(normalizedPathPrefix.length - 1)
75
- : event.rawPath;
76
- // /someapp will split into length 2 with ["", "someapp"] as results
77
- // /someapp/somepath will split into length 3 with ["", "someapp", "somepath"] as results
78
- // /someapp/somepath/ will split into length 3 with ["", "someapp", "somepath", ""] as results
79
- // /someapp/somepath/somefile.foo will split into length 4 with ["", "someapp", "somepath", "somefile.foo", ""] as results
80
- const partsAfterPrefix = pathAfterPrefix.split('/');
81
- const appName = await GetAppInfo({
82
- dbManager,
83
- appName: partsAfterPrefix.length >= 2 ? partsAfterPrefix[1] : '[root]',
84
- });
85
- if (!appName) {
86
- return { statusCode: 404, errorMessage: 'App not found' };
87
- }
88
- const isRootApp = appName === '[root]';
89
- const appNameOrRootTrailingSlash = isRootApp ? '' : `${appName}/`;
90
- // Strip the appName from the start of the path, if there was one
91
- const pathAfterAppName = isRootApp
92
- ? pathAfterPrefix
93
- : pathAfterPrefix.slice(appName.length + 1);
94
- const partsAfterAppName = pathAfterAppName.split('/');
95
- // Pass any parts after the appName/Version to the route handler
96
- let additionalParts = '';
97
- if (partsAfterAppName.length >= 2 && partsAfterAppName[1] !== '') {
98
- additionalParts = partsAfterAppName.slice(1).join('/');
99
- }
100
- // Route an app and version (only) to include the defaultFile
101
- // If the second part is not a version that exists, fall through to
102
- // routing the app and glomming the rest of the path on to the end
103
- if (partsAfterAppName.length === 2 ||
104
- (partsAfterAppName.length === 3 && !partsAfterAppName[2])) {
105
- // / semVer /
106
- // ^ ^^^^^^ ^
107
- // 0 1 2
108
- // This is an app and a version only
109
- // If the request got here it's likely a static app that has no
110
- // Lambda function (thus the API Gateway route fell through to the Router)
111
- const response = await RedirectToDefaultFile({
112
- dbManager,
113
- appName,
114
- normalizedPathPrefix,
115
- semVer: partsAfterAppName[1],
116
- appNameOrRootTrailingSlash,
117
- });
118
- if (response) {
119
- return response;
120
- }
121
- }
122
- // Check for a version in the path
123
- // Examples
124
- // / semVer / somepath
125
- // / _next / data / semVer / somepath
126
- const possibleSemVerPathNextData = partsAfterAppName.length >= 4 ? partsAfterAppName[3] : '';
127
- const possibleSemVerPathAfterApp = partsAfterAppName.length >= 2 ? partsAfterAppName[1] : '';
128
- // (/ something)?
129
- // ^ ^^^^^^^^^^^^
130
- // 0 1
131
- // Got at least an application name, try to route it
132
- const response = await RouteApp({
133
- dbManager,
134
- normalizedPathPrefix,
135
- event,
136
- appName,
137
- possibleSemVerPathNextData,
138
- possibleSemVerPathAfterApp,
139
- possibleSemVerQuery: (queryStringParameters === null || queryStringParameters === void 0 ? void 0 : queryStringParameters.get('appver')) || '',
140
- additionalParts,
141
- appNameOrRootTrailingSlash,
142
- });
143
- if (response) {
144
- return response;
145
- }
146
- return {
147
- statusCode: 599,
148
- errorMessage: `Router - Could not route: ${event.rawPath}, no matching route`,
149
- };
150
- }
151
- catch (error) {
152
- log.error('unexpected exception - returning 599', { statusCode: 599, error });
153
- return {
154
- statusCode: 599,
155
- errorMessage: `Router - Could not route: ${event.rawPath}, ${error.message}`,
156
- };
157
- }
158
- }
159
- exports.GetRoute = GetRoute;
160
- /**
161
- * Determine if we have an appname or a catch all app
162
- */
163
- async function GetAppInfo(opts) {
164
- const { dbManager, appName } = opts;
165
- let rules;
166
- const appVersionCache = app_cache_1.AppVersionCache.GetInstance({ dbManager });
167
- // Check if we got a matching app name
168
- rules = await appVersionCache.GetRules({ key: { AppName: appName } });
169
- if (rules && rules.AppName === appName.toLowerCase()) {
170
- return appName;
171
- }
172
- // Check if we have a `[root]` app that is a catch all
173
- rules = await appVersionCache.GetRules({ key: { AppName: '[root]' } });
174
- if (rules && rules.AppName === '[root]') {
175
- return '[root]';
176
- }
177
- return undefined;
178
- }
179
- exports.GetAppInfo = GetAppInfo;
180
- /**
181
- * Lookup the version of the app to run
182
- * @param event
183
- * @param response
184
- * @param appName
185
- * @param additionalParts
186
- * @param log
187
- * @returns
188
- */
189
- async function RouteApp(opts) {
190
- var _a;
191
- const { dbManager, event, normalizedPathPrefix = '', appName, possibleSemVerPathNextData, possibleSemVerPathAfterApp, possibleSemVerQuery, additionalParts, appNameOrRootTrailingSlash, } = opts;
192
- let versionInfoToUse;
193
- const appVersionCache = app_cache_1.AppVersionCache.GetInstance({ dbManager });
194
- // Check if the semver placeholder is actually a defined version
195
- const possibleSemVerPathAfterAppVersionInfo = possibleSemVerPathAfterApp
196
- ? await appVersionCache.GetVersionInfo({
197
- key: { AppName: appName, SemVer: possibleSemVerPathAfterApp },
198
- })
199
- : undefined;
200
- const possibleSemVerPathNextDataVersionInfo = possibleSemVerPathNextData
201
- ? await appVersionCache.GetVersionInfo({
202
- key: { AppName: appName, SemVer: possibleSemVerPathNextData },
203
- })
204
- : undefined;
205
- const possibleSemVerQueryVersionInfo = possibleSemVerQuery
206
- ? await appVersionCache.GetVersionInfo({
207
- key: { AppName: appName, SemVer: possibleSemVerQuery },
208
- })
209
- : undefined;
210
- // If there is a version in the path, use it
211
- const possibleSemVerPathVersionInfo = possibleSemVerPathAfterAppVersionInfo || possibleSemVerPathNextDataVersionInfo;
212
- if (possibleSemVerPathVersionInfo) {
213
- // This is a version, and it's in the path already, route the request to it
214
- // without creating iframe
215
- return {
216
- appName,
217
- semVer: possibleSemVerPathVersionInfo.SemVer,
218
- ...((possibleSemVerPathVersionInfo === null || possibleSemVerPathVersionInfo === void 0 ? void 0 : possibleSemVerPathVersionInfo.URL) ? { url: possibleSemVerPathVersionInfo === null || possibleSemVerPathVersionInfo === void 0 ? void 0 : possibleSemVerPathVersionInfo.URL } : {}),
219
- ...((possibleSemVerPathVersionInfo === null || possibleSemVerPathVersionInfo === void 0 ? void 0 : possibleSemVerPathVersionInfo.Type)
220
- ? {
221
- type: (possibleSemVerPathVersionInfo === null || possibleSemVerPathVersionInfo === void 0 ? void 0 : possibleSemVerPathVersionInfo.Type) === 'lambda'
222
- ? 'apigwy'
223
- : possibleSemVerPathVersionInfo === null || possibleSemVerPathVersionInfo === void 0 ? void 0 : possibleSemVerPathVersionInfo.Type,
224
- }
225
- : {}),
226
- };
227
- }
228
- else if (possibleSemVerQueryVersionInfo) {
229
- // We got a version for the query string, but it's not in the path,
230
- // so fall back to normal routing (create an iframe or direct route)
231
- versionInfoToUse = possibleSemVerQueryVersionInfo;
232
- }
233
- else if (possibleSemVerQuery) {
234
- // We got a version in the query string but it does not exist
235
- // This needs to 404 as this is a very specific request for a specific version
236
- log.error(`could not find app ${appName}, for path ${event.rawPath} - returning 404`, {
237
- statusCode: 404,
238
- });
239
- return {
240
- statusCode: 404,
241
- errorMessage: `Router - Could not find app: ${event.rawPath}, ${appName}`,
242
- };
243
- }
244
- else {
245
- //
246
- // TODO: Get the incoming attributes of user
247
- // For logged in users, these can be: department, product type,
248
- // employee, office, division, etc.
249
- // For anonymous users this can be: geo region, language,
250
- // browser, IP, CIDR, ASIN, etc.
251
- //
252
- // The Rules can be either a version or a distribution of versions,
253
- // including default, for example:
254
- // 80% to 1.1.0, 20% to default (1.0.3)
255
- //
256
- const rules = await appVersionCache.GetRules({ key: { AppName: appName } });
257
- const defaultVersion = (_a = rules === null || rules === void 0 ? void 0 : rules.RuleSet.default) === null || _a === void 0 ? void 0 : _a.SemVer;
258
- if (defaultVersion == null) {
259
- log.error(`could not find app ${appName}, for path ${event.rawPath} - returning 404`, {
260
- statusCode: 404,
261
- });
262
- return {
263
- statusCode: 404,
264
- errorMessage: `Router - Could not find app: ${event.rawPath}, ${appName}`,
265
- };
266
- }
267
- const defaultVersionInfo = await appVersionCache.GetVersionInfo({
268
- key: { AppName: appName, SemVer: defaultVersion },
269
- });
270
- versionInfoToUse = defaultVersionInfo;
271
- }
272
- if (!versionInfoToUse) {
273
- log.error(`could not find version info for app ${appName}, for path ${event.rawPath} - returning 404`, {
274
- statusCode: 404,
275
- });
276
- return {
277
- statusCode: 404,
278
- errorMessage: `Router - Could not find version info for app: ${event.rawPath}, ${appName}`,
279
- };
280
- }
281
- if ((versionInfoToUse === null || versionInfoToUse === void 0 ? void 0 : versionInfoToUse.StartupType) === 'iframe' || !(versionInfoToUse === null || versionInfoToUse === void 0 ? void 0 : versionInfoToUse.StartupType)) {
282
- // Prepare the iframe contents
283
- let appVersionPath;
284
- if ((versionInfoToUse === null || versionInfoToUse === void 0 ? void 0 : versionInfoToUse.Type) !== 'static' &&
285
- ((versionInfoToUse === null || versionInfoToUse === void 0 ? void 0 : versionInfoToUse.DefaultFile) === undefined ||
286
- (versionInfoToUse === null || versionInfoToUse === void 0 ? void 0 : versionInfoToUse.DefaultFile) === '' ||
287
- additionalParts !== '')) {
288
- // KLUDGE: We're going to take a missing default file to mean that the
289
- // app type is Next.js (or similar) and that it wants no trailing slash after the version
290
- // TODO: Move this to an attribute of the version
291
- appVersionPath = `${normalizedPathPrefix}/${appNameOrRootTrailingSlash}${versionInfoToUse.SemVer}`;
292
- if (additionalParts !== '') {
293
- appVersionPath += `/${additionalParts}`;
294
- }
295
- }
296
- else {
297
- // Linking to the file directly means this will be peeled off by the S3 route
298
- // That means we won't have to proxy this from S3
299
- appVersionPath = `${normalizedPathPrefix}/${appNameOrRootTrailingSlash}${versionInfoToUse.SemVer}/${versionInfoToUse.DefaultFile}`;
300
- }
301
- return {
302
- statusCode: 200,
303
- appName,
304
- semVer: versionInfoToUse.SemVer,
305
- startupType: 'iframe',
306
- ...((versionInfoToUse === null || versionInfoToUse === void 0 ? void 0 : versionInfoToUse.URL) ? { url: versionInfoToUse === null || versionInfoToUse === void 0 ? void 0 : versionInfoToUse.URL } : {}),
307
- ...((versionInfoToUse === null || versionInfoToUse === void 0 ? void 0 : versionInfoToUse.Type)
308
- ? { type: (versionInfoToUse === null || versionInfoToUse === void 0 ? void 0 : versionInfoToUse.Type) === 'lambda' ? 'apigwy' : versionInfoToUse === null || versionInfoToUse === void 0 ? void 0 : versionInfoToUse.Type }
309
- : {}),
310
- iFrameAppVersionPath: appVersionPath,
311
- };
312
- }
313
- else {
314
- // This is a direct app version, no iframe needed
315
- if ((versionInfoToUse === null || versionInfoToUse === void 0 ? void 0 : versionInfoToUse.Type) === 'lambda') {
316
- throw new Error('Invalid type for direct app version');
317
- }
318
- if (['apigwy', 'static'].includes((versionInfoToUse === null || versionInfoToUse === void 0 ? void 0 : versionInfoToUse.Type) || '')) {
319
- throw new Error('Invalid type for direct app version');
320
- }
321
- return {
322
- appName,
323
- semVer: versionInfoToUse.SemVer,
324
- startupType: 'direct',
325
- ...((versionInfoToUse === null || versionInfoToUse === void 0 ? void 0 : versionInfoToUse.URL) ? { url: versionInfoToUse === null || versionInfoToUse === void 0 ? void 0 : versionInfoToUse.URL } : {}),
326
- ...((versionInfoToUse === null || versionInfoToUse === void 0 ? void 0 : versionInfoToUse.Type) ? { type: versionInfoToUse === null || versionInfoToUse === void 0 ? void 0 : versionInfoToUse.Type } : {}),
327
- };
328
- }
329
- }
330
- /**
331
- * Redirect the request to app/x.y.z/? to app/x.y.z/{defaultFile}
332
- * @param response
333
- * @param normalizedPathPrefix
334
- * @param appName
335
- * @param semVer
336
- * @returns
337
- */
338
- async function RedirectToDefaultFile(opts) {
339
- const { dbManager, normalizedPathPrefix = '', appName, appNameOrRootTrailingSlash, semVer, } = opts;
340
- let versionInfo;
341
- try {
342
- // Get the cache
343
- const appVersionCache = app_cache_1.AppVersionCache.GetInstance({ dbManager });
344
- versionInfo = await appVersionCache.GetVersionInfo({
345
- key: { AppName: appName, SemVer: semVer },
346
- });
347
- }
348
- catch (error) {
349
- log.info(`LoadVersion threw for '${normalizedPathPrefix}/${appNameOrRootTrailingSlash}${semVer}' - falling through to app routing'`, {
350
- appName,
351
- semVer,
352
- error,
353
- });
354
- return undefined;
355
- }
356
- if (versionInfo === undefined) {
357
- log.info(`LoadVersion returned undefined for '${normalizedPathPrefix}/${appNameOrRootTrailingSlash}${semVer}', assuming not found - falling through to app routing'`, {
358
- appName,
359
- semVer,
360
- });
361
- return undefined;
362
- }
363
- if (!versionInfo.DefaultFile) {
364
- return undefined;
365
- }
366
- log.info(`found '${normalizedPathPrefix}/${appNameOrRootTrailingSlash}${semVer}' - returning 302 to ${normalizedPathPrefix}/${appNameOrRootTrailingSlash}${semVer}/${versionInfo.DefaultFile}`, {
367
- statusCode: 302,
368
- routedPath: `${normalizedPathPrefix}/${appNameOrRootTrailingSlash}${semVer}/${versionInfo.DefaultFile}`,
369
- });
370
- return {
371
- statusCode: 302,
372
- redirectLocation: `${normalizedPathPrefix}/${appNameOrRootTrailingSlash}${semVer}/${versionInfo.DefaultFile}`,
373
- };
374
- }
3
+ exports.RedirectToDefaultFile = exports.GetRoute = exports.normalizePathPrefix = exports.GetAppInfo = exports.loadAppFrame = void 0;
4
+ var load_app_frame_1 = require("./load-app-frame");
5
+ Object.defineProperty(exports, "loadAppFrame", { enumerable: true, get: function () { return load_app_frame_1.loadAppFrame; } });
6
+ var get_app_info_1 = require("./get-app-info");
7
+ Object.defineProperty(exports, "GetAppInfo", { enumerable: true, get: function () { return get_app_info_1.GetAppInfo; } });
8
+ var normalize_path_prefix_1 = require("./normalize-path-prefix");
9
+ Object.defineProperty(exports, "normalizePathPrefix", { enumerable: true, get: function () { return normalize_path_prefix_1.normalizePathPrefix; } });
10
+ var get_route_1 = require("./get-route");
11
+ Object.defineProperty(exports, "GetRoute", { enumerable: true, get: function () { return get_route_1.GetRoute; } });
12
+ var redirect_default_file_1 = require("./redirect-default-file");
13
+ Object.defineProperty(exports, "RedirectToDefaultFile", { enumerable: true, get: function () { return redirect_default_file_1.RedirectToDefaultFile; } });
375
14
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,uCAAqC;AACrC,wDAAwB;AACxB,uCAAwD;AAExD,4DAA4B;AAC5B,2CAA8C;AAIrC,gGAJA,2BAAe,OAIA;AAFxB,MAAM,GAAG,GAAG,aAAG,CAAC,QAAQ,CAAC;AAIzB;;;GAGG;AACH,SAAgB,YAAY,CAAC,EAAE,QAAQ,GAAG,GAAG,EAAyB;IACpE,MAAM,KAAK,GAAG;QACZ,QAAQ;QACR,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC;QACzB,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC;QAChC,QAAQ;QACR,MAAM;QACN,gBAAgB;KACjB,CAAC;IAEF,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE;QAC5B,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QACtD,IAAI;YACF,IAAI,IAAA,yBAAc,EAAC,QAAQ,CAAC,EAAE;gBAC5B,GAAG,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;gBAC1C,OAAO,IAAA,uBAAY,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;aACxC;SACF;QAAC,WAAM;YACN,0EAA0E;SAC3E;KACF;IAED,GAAG,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACrC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAC7C,CAAC;AAxBD,oCAwBC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,UA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;KACxG,CACF,CAAC;IAEF,OAAO;QACL,UAAU,EAAE,GAAG;QACf,gBAAgB,EAAE,GAAG,oBAAoB,IAAI,0BAA0B,GAAG,MAAM,IAAI,WAAW,CAAC,WAAW,EAAE;KAC9G,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAAvC,8GAAA,YAAY,OAAA;AACrB,+CAA4C;AAAnC,0GAAA,UAAU,OAAA;AACnB,iEAA8D;AAArD,4HAAA,mBAAmB,OAAA;AAC5B,yCAAwE;AAA/D,qGAAA,QAAQ,OAAA;AACjB,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Find and load the appFrame file
3
+ * @returns
4
+ */
5
+ export declare function loadAppFrame({ basePath }: {
6
+ basePath?: string;
7
+ }): string;
8
+ //# sourceMappingURL=load-app-frame.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-app-frame.d.ts","sourceRoot":"","sources":["../src/load-app-frame.ts"],"names":[],"mappings":"AAMA;;;GAGG;AAEH,wBAAgB,YAAY,CAAC,EAAE,QAAc,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAwB9E"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadAppFrame = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const path_1 = tslib_1.__importDefault(require("path"));
6
+ const fs_extra_1 = require("fs-extra");
7
+ const log_1 = tslib_1.__importDefault(require("./lib/log"));
8
+ const log = log_1.default.Instance;
9
+ /**
10
+ * Find and load the appFrame file
11
+ * @returns
12
+ */
13
+ function loadAppFrame({ basePath = '.' }) {
14
+ const paths = [
15
+ basePath,
16
+ path_1.default.join(basePath, '..'),
17
+ path_1.default.join(basePath, 'templates'),
18
+ basePath,
19
+ '/opt',
20
+ '/opt/templates',
21
+ ];
22
+ for (const pathRoot of paths) {
23
+ const fullPath = path_1.default.join(pathRoot, 'appFrame.html');
24
+ try {
25
+ if ((0, fs_extra_1.pathExistsSync)(fullPath)) {
26
+ log.info('found html file', { fullPath });
27
+ return (0, fs_extra_1.readFileSync)(fullPath, 'utf-8');
28
+ }
29
+ }
30
+ catch (_a) {
31
+ // Don't care - we get here if stat throws because the file does not exist
32
+ }
33
+ }
34
+ log.error('appFrame.html not found');
35
+ throw new Error('appFrame.html not found');
36
+ }
37
+ exports.loadAppFrame = loadAppFrame;
38
+ //# sourceMappingURL=load-app-frame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-app-frame.js","sourceRoot":"","sources":["../src/load-app-frame.ts"],"names":[],"mappings":";;;;AAAA,wDAAwB;AACxB,uCAAwD;AACxD,4DAA4B;AAE5B,MAAM,GAAG,GAAG,aAAG,CAAC,QAAQ,CAAC;AAEzB;;;GAGG;AAEH,SAAgB,YAAY,CAAC,EAAE,QAAQ,GAAG,GAAG,EAAyB;IACpE,MAAM,KAAK,GAAG;QACZ,QAAQ;QACR,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC;QACzB,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC;QAChC,QAAQ;QACR,MAAM;QACN,gBAAgB;KACjB,CAAC;IAEF,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE;QAC5B,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QACtD,IAAI;YACF,IAAI,IAAA,yBAAc,EAAC,QAAQ,CAAC,EAAE;gBAC5B,GAAG,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;gBAC1C,OAAO,IAAA,uBAAY,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;aACxC;SACF;QAAC,WAAM;YACN,0EAA0E;SAC3E;KACF;IAED,GAAG,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACrC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAC7C,CAAC;AAxBD,oCAwBC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Ensure that the path starts with a / and does not end with a /
3
+ *
4
+ * @param pathPrefix
5
+ * @returns
6
+ */
7
+ export declare function normalizePathPrefix(pathPrefix: string): string;
8
+ //# sourceMappingURL=normalize-path-prefix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-path-prefix.d.ts","sourceRoot":"","sources":["../src/normalize-path-prefix.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAU9D"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /**
3
+ * Ensure that the path starts with a / and does not end with a /
4
+ *
5
+ * @param pathPrefix
6
+ * @returns
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.normalizePathPrefix = void 0;
10
+ function normalizePathPrefix(pathPrefix) {
11
+ let normalizedPathPrefix = pathPrefix;
12
+ if (normalizedPathPrefix !== '' && !normalizedPathPrefix.startsWith('/')) {
13
+ normalizedPathPrefix = '/' + pathPrefix;
14
+ }
15
+ if (normalizedPathPrefix.endsWith('/')) {
16
+ normalizedPathPrefix = normalizedPathPrefix.substring(0, normalizedPathPrefix.length - 1);
17
+ }
18
+ return normalizedPathPrefix;
19
+ }
20
+ exports.normalizePathPrefix = normalizePathPrefix;
21
+ //# sourceMappingURL=normalize-path-prefix.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-path-prefix.js","sourceRoot":"","sources":["../src/normalize-path-prefix.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,SAAgB,mBAAmB,CAAC,UAAkB;IACpD,IAAI,oBAAoB,GAAG,UAAU,CAAC;IACtC,IAAI,oBAAoB,KAAK,EAAE,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QACxE,oBAAoB,GAAG,GAAG,GAAG,UAAU,CAAC;KACzC;IACD,IAAI,oBAAoB,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QACtC,oBAAoB,GAAG,oBAAoB,CAAC,SAAS,CAAC,CAAC,EAAE,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;KAC3F;IAED,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAVD,kDAUC"}
@@ -0,0 +1,18 @@
1
+ import { DBManager } from '@pwrdrvr/microapps-datalib';
2
+ import { IGetRouteResult } from './get-route';
3
+ /**
4
+ * Redirect the request to app/x.y.z/? to app/x.y.z/{defaultFile}
5
+ * @param response
6
+ * @param normalizedPathPrefix
7
+ * @param appName
8
+ * @param semVer
9
+ * @returns
10
+ */
11
+ export declare function RedirectToDefaultFile(opts: {
12
+ dbManager: DBManager;
13
+ normalizedPathPrefix?: string;
14
+ appName: string;
15
+ semVer: string;
16
+ appNameOrRootTrailingSlash: string;
17
+ }): Promise<IGetRouteResult | undefined>;
18
+ //# sourceMappingURL=redirect-default-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirect-default-file.d.ts","sourceRoot":"","sources":["../src/redirect-default-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAK9C;;;;;;;GAOG;AAEH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE;IAChD,SAAS,EAAE,SAAS,CAAC;IACrB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,0BAA0B,EAAE,MAAM,CAAC;CACpC,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAwDvC"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RedirectToDefaultFile = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const app_cache_1 = require("./app-cache");
6
+ const log_1 = tslib_1.__importDefault(require("./lib/log"));
7
+ const log = log_1.default.Instance;
8
+ /**
9
+ * Redirect the request to app/x.y.z/? to app/x.y.z/{defaultFile}
10
+ * @param response
11
+ * @param normalizedPathPrefix
12
+ * @param appName
13
+ * @param semVer
14
+ * @returns
15
+ */
16
+ async function RedirectToDefaultFile(opts) {
17
+ const { dbManager, normalizedPathPrefix = '', appName, appNameOrRootTrailingSlash, semVer, } = opts;
18
+ let versionInfo;
19
+ try {
20
+ // Get the cache
21
+ const appVersionCache = app_cache_1.AppVersionCache.GetInstance({ dbManager });
22
+ versionInfo = await appVersionCache.GetVersionInfo({
23
+ key: { AppName: appName, SemVer: semVer },
24
+ });
25
+ }
26
+ catch (error) {
27
+ log.info(`LoadVersion threw for '${normalizedPathPrefix}/${appNameOrRootTrailingSlash}${semVer}' - falling through to app routing'`, {
28
+ appName,
29
+ semVer,
30
+ error,
31
+ });
32
+ return undefined;
33
+ }
34
+ if (versionInfo === undefined) {
35
+ log.info(`LoadVersion returned undefined for '${normalizedPathPrefix}/${appNameOrRootTrailingSlash}${semVer}', assuming not found - falling through to app routing'`, {
36
+ appName,
37
+ semVer,
38
+ });
39
+ return undefined;
40
+ }
41
+ if (!versionInfo.DefaultFile) {
42
+ return undefined;
43
+ }
44
+ log.info(`found '${normalizedPathPrefix}/${appNameOrRootTrailingSlash}${semVer}' - returning 302 to ${normalizedPathPrefix}/${appNameOrRootTrailingSlash}${semVer}/${versionInfo.DefaultFile}`, {
45
+ statusCode: 302,
46
+ routedPath: `${normalizedPathPrefix}/${appNameOrRootTrailingSlash}${semVer}/${versionInfo.DefaultFile}`,
47
+ });
48
+ return {
49
+ statusCode: 302,
50
+ redirectLocation: `${normalizedPathPrefix}/${appNameOrRootTrailingSlash}${semVer}/${versionInfo.DefaultFile}`,
51
+ };
52
+ }
53
+ exports.RedirectToDefaultFile = RedirectToDefaultFile;
54
+ //# sourceMappingURL=redirect-default-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redirect-default-file.js","sourceRoot":"","sources":["../src/redirect-default-file.ts"],"names":[],"mappings":";;;;AACA,2CAA8C;AAE9C,4DAA4B;AAE5B,MAAM,GAAG,GAAG,aAAG,CAAC,QAAQ,CAAC;AAEzB;;;;;;;GAOG;AAEI,KAAK,UAAU,qBAAqB,CAAC,IAM3C;IACC,MAAM,EACJ,SAAS,EACT,oBAAoB,GAAG,EAAE,EACzB,OAAO,EACP,0BAA0B,EAC1B,MAAM,GACP,GAAG,IAAI,CAAC;IACT,IAAI,WAAgC,CAAC;IAErC,IAAI;QACF,gBAAgB;QAChB,MAAM,eAAe,GAAG,2BAAe,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;QAEnE,WAAW,GAAG,MAAM,eAAe,CAAC,cAAc,CAAC;YACjD,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE;SAC1C,CAAC,CAAC;KACJ;IAAC,OAAO,KAAK,EAAE;QACd,GAAG,CAAC,IAAI,CACN,0BAA0B,oBAAoB,IAAI,0BAA0B,GAAG,MAAM,qCAAqC,EAC1H;YACE,OAAO;YACP,MAAM;YACN,KAAK;SACN,CACF,CAAC;QACF,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,WAAW,KAAK,SAAS,EAAE;QAC7B,GAAG,CAAC,IAAI,CACN,uCAAuC,oBAAoB,IAAI,0BAA0B,GAAG,MAAM,yDAAyD,EAC3J;YACE,OAAO;YACP,MAAM;SACP,CACF,CAAC;QACF,OAAO,SAAS,CAAC;KAClB;IAED,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE;QAC5B,OAAO,SAAS,CAAC;KAClB;IAED,GAAG,CAAC,IAAI,CACN,UAAU,oBAAoB,IAAI,0BAA0B,GAAG,MAAM,wBAAwB,oBAAoB,IAAI,0BAA0B,GAAG,MAAM,IAAI,WAAW,CAAC,WAAW,EAAE,EACrL;QACE,UAAU,EAAE,GAAG;QACf,UAAU,EAAE,GAAG,oBAAoB,IAAI,0BAA0B,GAAG,MAAM,IAAI,WAAW,CAAC,WAAW,EAAE;KACxG,CACF,CAAC;IAEF,OAAO;QACL,UAAU,EAAE,GAAG;QACf,gBAAgB,EAAE,GAAG,oBAAoB,IAAI,0BAA0B,GAAG,MAAM,IAAI,WAAW,CAAC,WAAW,EAAE;KAC9G,CAAC;AACJ,CAAC;AA9DD,sDA8DC"}
@@ -0,0 +1,23 @@
1
+ import { DBManager } from '@pwrdrvr/microapps-datalib';
2
+ import { IGetRouteEvent, IGetRouteResult } from './get-route';
3
+ /**
4
+ * Lookup the version of the app to run
5
+ * @param event
6
+ * @param response
7
+ * @param appName
8
+ * @param additionalParts
9
+ * @param log
10
+ * @returns
11
+ */
12
+ export declare function RouteApp(opts: {
13
+ dbManager: DBManager;
14
+ event: IGetRouteEvent;
15
+ appName: string;
16
+ possibleSemVerPathNextData?: string;
17
+ possibleSemVerPathAfterApp?: string;
18
+ possibleSemVerQuery?: string;
19
+ additionalParts: string;
20
+ normalizedPathPrefix?: string;
21
+ appNameOrRootTrailingSlash: string;
22
+ }): Promise<IGetRouteResult>;
23
+ //# sourceMappingURL=route-app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-app.d.ts","sourceRoot":"","sources":["../src/route-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAK9D;;;;;;;;GAQG;AAEH,wBAAsB,QAAQ,CAAC,IAAI,EAAE;IACnC,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,cAAc,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,0BAA0B,EAAE,MAAM,CAAC;CACpC,GAAG,OAAO,CAAC,eAAe,CAAC,CA8K3B"}