@pwrdrvr/microapps-router-lib 0.4.0-alpha.9 → 1.0.0
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.
- package/dist/get-app-info.d.ts +9 -0
- package/dist/get-app-info.d.ts.map +1 -0
- package/dist/get-app-info.js +25 -0
- package/dist/get-app-info.js.map +1 -0
- package/dist/get-route.d.ts +83 -0
- package/dist/get-route.d.ts.map +1 -0
- package/dist/get-route.js +154 -0
- package/dist/get-route.js.map +1 -0
- package/dist/index.d.ts +5 -96
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -372
- package/dist/index.js.map +1 -1
- package/dist/load-app-frame.d.ts +8 -0
- package/dist/load-app-frame.d.ts.map +1 -0
- package/dist/load-app-frame.js +38 -0
- package/dist/load-app-frame.js.map +1 -0
- package/dist/normalize-path-prefix.d.ts +8 -0
- package/dist/normalize-path-prefix.d.ts.map +1 -0
- package/dist/normalize-path-prefix.js +21 -0
- package/dist/normalize-path-prefix.js.map +1 -0
- package/dist/redirect-default-file.d.ts +18 -0
- package/dist/redirect-default-file.d.ts.map +1 -0
- package/dist/redirect-default-file.js +54 -0
- package/dist/redirect-default-file.js.map +1 -0
- package/dist/route-app.d.ts +23 -0
- package/dist/route-app.d.ts.map +1 -0
- package/dist/route-app.js +169 -0
- package/dist/route-app.js.map +1 -0
- package/package.json +4 -2
- package/src/get-app-info.spec.ts +77 -0
- package/src/get-app-info.ts +31 -0
- package/src/get-route.spec.ts +585 -0
- package/src/get-route.ts +267 -0
- package/src/index.ts +5 -537
- package/src/load-app-frame.spec.ts +51 -0
- package/src/load-app-frame.ts +36 -0
- package/src/normalize-path-prefix.spec.ts +27 -0
- package/src/normalize-path-prefix.ts +18 -0
- package/src/redirect-default-file.spec.ts +98 -0
- package/src/redirect-default-file.ts +79 -0
- package/src/route-app.spec.ts +128 -0
- package/src/route-app.ts +202 -0
- package/src/index.spec.ts +0 -322
- /package/src/{index.prefix.spec.ts → get-route.prefix.spec.ts} +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DBManager } from '@pwrdrvr/microapps-datalib';
|
|
2
|
+
/**
|
|
3
|
+
* Determine if we have an appname or a catch all app
|
|
4
|
+
*/
|
|
5
|
+
export declare function GetAppInfo(opts: {
|
|
6
|
+
dbManager: DBManager;
|
|
7
|
+
appName: string;
|
|
8
|
+
}): Promise<string | undefined>;
|
|
9
|
+
//# sourceMappingURL=get-app-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-app-info.d.ts","sourceRoot":"","sources":["../src/get-app-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAS,MAAM,4BAA4B,CAAC;AAG9D;;GAEG;AAEH,wBAAsB,UAAU,CAAC,IAAI,EAAE;IACrC,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAoB9B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetAppInfo = void 0;
|
|
4
|
+
const app_cache_1 = require("./app-cache");
|
|
5
|
+
/**
|
|
6
|
+
* Determine if we have an appname or a catch all app
|
|
7
|
+
*/
|
|
8
|
+
async function GetAppInfo(opts) {
|
|
9
|
+
const { dbManager, appName } = opts;
|
|
10
|
+
let rules;
|
|
11
|
+
const appVersionCache = app_cache_1.AppVersionCache.GetInstance({ dbManager });
|
|
12
|
+
// Check if we got a matching app name
|
|
13
|
+
rules = await appVersionCache.GetRules({ key: { AppName: appName } });
|
|
14
|
+
if (rules && rules.AppName === appName.toLowerCase()) {
|
|
15
|
+
return appName;
|
|
16
|
+
}
|
|
17
|
+
// Check if we have a `[root]` app that is a catch all
|
|
18
|
+
rules = await appVersionCache.GetRules({ key: { AppName: '[root]' } });
|
|
19
|
+
if (rules && rules.AppName === '[root]') {
|
|
20
|
+
return '[root]';
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
exports.GetAppInfo = GetAppInfo;
|
|
25
|
+
//# sourceMappingURL=get-app-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-app-info.js","sourceRoot":"","sources":["../src/get-app-info.ts"],"names":[],"mappings":";;;AACA,2CAA8C;AAE9C;;GAEG;AAEI,KAAK,UAAU,UAAU,CAAC,IAGhC;IACC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEpC,IAAI,KAAwB,CAAC;IAE7B,MAAM,eAAe,GAAG,2BAAe,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;IAEnE,sCAAsC;IACtC,KAAK,GAAG,MAAM,eAAe,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;IACtE,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO,CAAC,WAAW,EAAE,EAAE;QACpD,OAAO,OAAO,CAAC;KAChB;IAED,sDAAsD;IACtD,KAAK,GAAG,MAAM,eAAe,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;IACvE,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE;QACvC,OAAO,QAAQ,CAAC;KACjB;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAvBD,gCAuBC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { DBManager } from '@pwrdrvr/microapps-datalib';
|
|
2
|
+
export interface IGetRouteResult {
|
|
3
|
+
/**
|
|
4
|
+
* HTTP status code for immediate response, immediate redirect, and errors
|
|
5
|
+
*/
|
|
6
|
+
readonly statusCode?: number;
|
|
7
|
+
/**
|
|
8
|
+
* Error message for errors
|
|
9
|
+
*/
|
|
10
|
+
readonly errorMessage?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Location to redirect to
|
|
13
|
+
*/
|
|
14
|
+
readonly redirectLocation?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Optional headers for immediate response, immediate redirect, and errors
|
|
17
|
+
*/
|
|
18
|
+
readonly headers?: Record<string, string>;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
*
|
|
22
|
+
* @example /myapp/1.0.0/index.html
|
|
23
|
+
* @example /myapp/1.0.1
|
|
24
|
+
* @example /myapp/1.0.2/some/path?query=string
|
|
25
|
+
*/
|
|
26
|
+
readonly iFrameAppVersionPath?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Name of the app if resolved
|
|
29
|
+
*/
|
|
30
|
+
readonly appName?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Version of the app if resolved
|
|
33
|
+
*/
|
|
34
|
+
readonly semVer?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Type of the app
|
|
37
|
+
*/
|
|
38
|
+
readonly type?: 'apigwy' | 'lambda-url' | 'url' | 'static';
|
|
39
|
+
/**
|
|
40
|
+
* Startup type of the app (indirect with iframe or direct)
|
|
41
|
+
*/
|
|
42
|
+
readonly startupType?: 'iframe' | 'direct';
|
|
43
|
+
/**
|
|
44
|
+
* URL to the app if resolved
|
|
45
|
+
*/
|
|
46
|
+
readonly url?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Does the extra app path start with /api/
|
|
49
|
+
*/
|
|
50
|
+
readonly isAPIPath?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface IGetRouteEvent {
|
|
53
|
+
readonly dbManager: DBManager;
|
|
54
|
+
/**
|
|
55
|
+
* rawPath from the Lambda event
|
|
56
|
+
*/
|
|
57
|
+
readonly rawPath: string;
|
|
58
|
+
/**
|
|
59
|
+
* List of locale prefixes after the normalizedPathPrefix
|
|
60
|
+
*
|
|
61
|
+
* @default []
|
|
62
|
+
*/
|
|
63
|
+
readonly locales?: string[];
|
|
64
|
+
/**
|
|
65
|
+
* Configured prefix of the deployment, must start with a / and not end with a /
|
|
66
|
+
*/
|
|
67
|
+
readonly normalizedPathPrefix?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Query string params, if any
|
|
70
|
+
* Checked for `appver=1.2.3` to override the app version
|
|
71
|
+
*/
|
|
72
|
+
readonly queryStringParameters?: URLSearchParams;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get information about immediate redirect, immediate response,
|
|
76
|
+
* or which host to route the request to.
|
|
77
|
+
*
|
|
78
|
+
* @param event
|
|
79
|
+
*
|
|
80
|
+
* @returns IGetRouteResult
|
|
81
|
+
*/
|
|
82
|
+
export declare function GetRoute(event: IGetRouteEvent): Promise<IGetRouteResult>;
|
|
83
|
+
//# sourceMappingURL=get-route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-route.d.ts","sourceRoot":"","sources":["../src/get-route.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAKvD,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAEnC;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE1C;;;;;;OAMG;IACH,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAEvC;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,KAAK,GAAG,QAAQ,CAAC;IAE3D;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAE3C;;OAEG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAEvC;;;OAGG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,eAAe,CAAC;CAClD;AAED;;;;;;;GAOG;AAEH,wBAAsB,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAgK9E"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetRoute = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const log_1 = tslib_1.__importDefault(require("./lib/log"));
|
|
6
|
+
const get_app_info_1 = require("./get-app-info");
|
|
7
|
+
const route_app_1 = require("./route-app");
|
|
8
|
+
const redirect_default_file_1 = require("./redirect-default-file");
|
|
9
|
+
const app_cache_1 = require("./app-cache");
|
|
10
|
+
const log = log_1.default.Instance;
|
|
11
|
+
/**
|
|
12
|
+
* Get information about immediate redirect, immediate response,
|
|
13
|
+
* or which host to route the request to.
|
|
14
|
+
*
|
|
15
|
+
* @param event
|
|
16
|
+
*
|
|
17
|
+
* @returns IGetRouteResult
|
|
18
|
+
*/
|
|
19
|
+
async function GetRoute(event) {
|
|
20
|
+
const { dbManager, normalizedPathPrefix = '', queryStringParameters, locales = [] } = event;
|
|
21
|
+
try {
|
|
22
|
+
const appVersionCache = app_cache_1.AppVersionCache.GetInstance({ dbManager });
|
|
23
|
+
if (!!normalizedPathPrefix && !event.rawPath.startsWith(normalizedPathPrefix)) {
|
|
24
|
+
// The prefix is required if configured, if missing we cannot serve this app
|
|
25
|
+
return { statusCode: 404, errorMessage: 'Request not routable' };
|
|
26
|
+
}
|
|
27
|
+
const pathAfterPrefix = normalizedPathPrefix && event.rawPath.startsWith(normalizedPathPrefix)
|
|
28
|
+
? event.rawPath.slice(normalizedPathPrefix.length - 1)
|
|
29
|
+
: event.rawPath;
|
|
30
|
+
const pathAfterPrefixAndLocale = locales.reduce((path, locale) => {
|
|
31
|
+
if (path.startsWith(`/${locale}/`)) {
|
|
32
|
+
return path.slice(locale.length + 1);
|
|
33
|
+
}
|
|
34
|
+
return path;
|
|
35
|
+
}, pathAfterPrefix);
|
|
36
|
+
// /someapp will split into length 2 with ["", "someapp"] as results
|
|
37
|
+
// /someapp/somepath will split into length 3 with ["", "someapp", "somepath"] as results
|
|
38
|
+
// /someapp/somepath/ will split into length 3 with ["", "someapp", "somepath", ""] as results
|
|
39
|
+
// /someapp/somepath/somefile.foo will split into length 4 with ["", "someapp", "somepath", "somefile.foo", ""] as results
|
|
40
|
+
const partsAfterPrefixAndLocale = pathAfterPrefixAndLocale.split('/');
|
|
41
|
+
// Handle ${prefix}/_next/data/${semver}[/${locale}]/${appname}/route
|
|
42
|
+
let appName;
|
|
43
|
+
if (partsAfterPrefixAndLocale.length >= 4 &&
|
|
44
|
+
partsAfterPrefixAndLocale[1] === '_next' &&
|
|
45
|
+
partsAfterPrefixAndLocale[2] === 'data') {
|
|
46
|
+
// Remove locale if present after SemVer
|
|
47
|
+
const localeIsPresent = partsAfterPrefixAndLocale.length >= 5 &&
|
|
48
|
+
locales.some((locale) => partsAfterPrefixAndLocale[4] === locale);
|
|
49
|
+
const possibleAppNamePart = localeIsPresent
|
|
50
|
+
? partsAfterPrefixAndLocale[5]
|
|
51
|
+
: partsAfterPrefixAndLocale[4];
|
|
52
|
+
// if partsAfterPrefix[4] has .json suffix, strip it
|
|
53
|
+
const possibleAppName = possibleAppNamePart.endsWith('.json')
|
|
54
|
+
? possibleAppNamePart.slice(0, possibleAppNamePart.length - 5)
|
|
55
|
+
: possibleAppNamePart;
|
|
56
|
+
appName = await (0, get_app_info_1.GetAppInfo)({
|
|
57
|
+
dbManager,
|
|
58
|
+
appName: possibleAppName,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (!appName) {
|
|
62
|
+
appName = await (0, get_app_info_1.GetAppInfo)({
|
|
63
|
+
dbManager,
|
|
64
|
+
appName: partsAfterPrefixAndLocale.length >= 2 ? partsAfterPrefixAndLocale[1] : '[root]',
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (!appName) {
|
|
68
|
+
return { statusCode: 404, errorMessage: 'App not found' };
|
|
69
|
+
}
|
|
70
|
+
const isRootApp = appName === '[root]';
|
|
71
|
+
const appNameOrRootTrailingSlash = isRootApp ? '' : `${appName}/`;
|
|
72
|
+
// Strip the appName from the start of the path, if there was one
|
|
73
|
+
const pathAfterAppName = isRootApp
|
|
74
|
+
? pathAfterPrefixAndLocale
|
|
75
|
+
: pathAfterPrefixAndLocale.slice(appName.length + 1);
|
|
76
|
+
const partsAfterAppName = pathAfterAppName.split('/');
|
|
77
|
+
// Pass any parts after the appName/Version to the route handler
|
|
78
|
+
let additionalParts = '';
|
|
79
|
+
if (partsAfterAppName.length >= 2 && partsAfterAppName[1] !== '') {
|
|
80
|
+
additionalParts = partsAfterAppName.slice(1).join('/');
|
|
81
|
+
}
|
|
82
|
+
// Route an app and version (only) to include the defaultFile
|
|
83
|
+
// If the second part is not a version that exists, fall through to
|
|
84
|
+
// routing the app and glomming the rest of the path on to the end
|
|
85
|
+
if (partsAfterAppName.length === 2 ||
|
|
86
|
+
(partsAfterAppName.length === 3 && !partsAfterAppName[2])) {
|
|
87
|
+
// / semVer /
|
|
88
|
+
// ^ ^^^^^^ ^
|
|
89
|
+
// 0 1 2
|
|
90
|
+
// This may be an app and a version only
|
|
91
|
+
// If the request got here it's likely a static app that has no
|
|
92
|
+
// Lambda function
|
|
93
|
+
// Let's check if the part is a version, if it is, route to the default file
|
|
94
|
+
const versionInfo = await appVersionCache.GetVersionInfo({
|
|
95
|
+
key: { AppName: appName, SemVer: partsAfterAppName[1] },
|
|
96
|
+
});
|
|
97
|
+
if (versionInfo) {
|
|
98
|
+
const response = await (0, redirect_default_file_1.RedirectToDefaultFile)({
|
|
99
|
+
dbManager,
|
|
100
|
+
appName,
|
|
101
|
+
normalizedPathPrefix,
|
|
102
|
+
semVer: partsAfterAppName[1],
|
|
103
|
+
appNameOrRootTrailingSlash,
|
|
104
|
+
});
|
|
105
|
+
if (response) {
|
|
106
|
+
return response;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Check for a version in the path
|
|
111
|
+
// Examples
|
|
112
|
+
// / semVer / somepath
|
|
113
|
+
// / _next / data / semVer / somepath
|
|
114
|
+
// Get the version afer `/_next/data/` from partsAfterPrefix
|
|
115
|
+
const possibleSemVerPathNextDataBasePath = partsAfterAppName.length >= 4 ? partsAfterAppName[3] : '';
|
|
116
|
+
const possibleSemVerPathNextData = partsAfterPrefixAndLocale.length >= 4 &&
|
|
117
|
+
partsAfterPrefixAndLocale[1] === '_next' &&
|
|
118
|
+
partsAfterPrefixAndLocale[2] == 'data'
|
|
119
|
+
? partsAfterPrefixAndLocale[3]
|
|
120
|
+
: possibleSemVerPathNextDataBasePath;
|
|
121
|
+
const possibleSemVerPathAfterApp = partsAfterAppName.length >= 2 ? partsAfterAppName[1] : '';
|
|
122
|
+
// (/ something)?
|
|
123
|
+
// ^ ^^^^^^^^^^^^
|
|
124
|
+
// 0 1
|
|
125
|
+
// Got at least an application name, try to route it
|
|
126
|
+
const response = await (0, route_app_1.RouteApp)({
|
|
127
|
+
dbManager,
|
|
128
|
+
normalizedPathPrefix,
|
|
129
|
+
event,
|
|
130
|
+
appName,
|
|
131
|
+
possibleSemVerPathNextData,
|
|
132
|
+
possibleSemVerPathAfterApp,
|
|
133
|
+
possibleSemVerQuery: (queryStringParameters === null || queryStringParameters === void 0 ? void 0 : queryStringParameters.get('appver')) || '',
|
|
134
|
+
additionalParts,
|
|
135
|
+
appNameOrRootTrailingSlash,
|
|
136
|
+
});
|
|
137
|
+
if (response) {
|
|
138
|
+
return response;
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
statusCode: 599,
|
|
142
|
+
errorMessage: `Router - Could not route: ${event.rawPath}, no matching route`,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
log.error('unexpected exception - returning 599', { statusCode: 599, error });
|
|
147
|
+
return {
|
|
148
|
+
statusCode: 599,
|
|
149
|
+
errorMessage: `Router - Could not route: ${event.rawPath}, ${error.message}`,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.GetRoute = GetRoute;
|
|
154
|
+
//# sourceMappingURL=get-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-route.js","sourceRoot":"","sources":["../src/get-route.ts"],"names":[],"mappings":";;;;AAAA,4DAA4B;AAC5B,iDAA4C;AAC5C,2CAAuC;AACvC,mEAAgE;AAEhE,2CAA8C;AAE9C,MAAM,GAAG,GAAG,aAAG,CAAC,QAAQ,CAAC;AA0FzB;;;;;;;GAOG;AAEI,KAAK,UAAU,QAAQ,CAAC,KAAqB;IAClD,MAAM,EAAE,SAAS,EAAE,oBAAoB,GAAG,EAAE,EAAE,qBAAqB,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,KAAK,CAAC;IAE5F,IAAI;QACF,MAAM,eAAe,GAAG,2BAAe,CAAC,WAAW,CAAC,EAAE,SAAS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AC,IAAI,MAAM;YACpC,CAAC,CAAC,yBAAyB,CAAC,CAAC,CAAC;YAC9B,CAAC,CAAC,kCAAkC,CAAC;QAEzC,MAAM,0BAA0B,GAAG,iBAAiB,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAE7F,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;QAClB,oDAAoD;QACpD,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAQ,EAAC;YAC9B,SAAS;YACT,oBAAoB;YACpB,KAAK;YACL,OAAO;YACP,0BAA0B;YAC1B,0BAA0B;YAC1B,mBAAmB,EAAE,CAAA,qBAAqB,aAArB,qBAAqB,uBAArB,qBAAqB,CAAE,GAAG,CAAC,QAAQ,CAAC,KAAI,EAAE;YAC/D,eAAe;YACf,0BAA0B;SAC3B,CAAC,CAAC;QACH,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,CAAC;SACjB;QAED,OAAO;YACL,UAAU,EAAE,GAAG;YACf,YAAY,EAAE,6BAA6B,KAAK,CAAC,OAAO,qBAAqB;SAC9E,CAAC;KACH;IAAC,OAAO,KAAU,EAAE;QACnB,GAAG,CAAC,KAAK,CAAC,sCAAsC,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9E,OAAO;YACL,UAAU,EAAE,GAAG;YACf,YAAY,EAAE,6BAA6B,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE;SAC7E,CAAC;KACH;AACH,CAAC;AAhKD,4BAgKC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,97 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
|
|
6
|
-
* Find and load the appFrame file
|
|
7
|
-
* @returns
|
|
8
|
-
*/
|
|
9
|
-
export declare function loadAppFrame({ basePath }: {
|
|
10
|
-
basePath?: string;
|
|
11
|
-
}): string;
|
|
12
|
-
/**
|
|
13
|
-
* Ensure that the path starts with a / and does not end with a /
|
|
14
|
-
*
|
|
15
|
-
* @param pathPrefix
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
export declare function normalizePathPrefix(pathPrefix: string): string;
|
|
19
|
-
export interface IGetRouteResult {
|
|
20
|
-
/**
|
|
21
|
-
* HTTP status code for immediate response, immediate redirect, and errors
|
|
22
|
-
*/
|
|
23
|
-
readonly statusCode?: number;
|
|
24
|
-
/**
|
|
25
|
-
* Error message for errors
|
|
26
|
-
*/
|
|
27
|
-
readonly errorMessage?: string;
|
|
28
|
-
/**
|
|
29
|
-
* Location to redirect to
|
|
30
|
-
*/
|
|
31
|
-
readonly redirectLocation?: string;
|
|
32
|
-
/**
|
|
33
|
-
* Optional headers for immediate response, immediate redirect, and errors
|
|
34
|
-
*/
|
|
35
|
-
readonly headers?: Record<string, string>;
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @example /myapp/1.0.0/index.html
|
|
40
|
-
* @example /myapp/1.0.1
|
|
41
|
-
* @example /myapp/1.0.2/some/path?query=string
|
|
42
|
-
*/
|
|
43
|
-
readonly iFrameAppVersionPath?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Name of the app if resolved
|
|
46
|
-
*/
|
|
47
|
-
readonly appName?: string;
|
|
48
|
-
/**
|
|
49
|
-
* Version of the app if resolved
|
|
50
|
-
*/
|
|
51
|
-
readonly semVer?: string;
|
|
52
|
-
/**
|
|
53
|
-
* Type of the app
|
|
54
|
-
*/
|
|
55
|
-
readonly type?: 'apigwy' | 'lambda-url' | 'url' | 'static';
|
|
56
|
-
/**
|
|
57
|
-
* Startup type of the app (indirect with iframe or direct)
|
|
58
|
-
*/
|
|
59
|
-
readonly startupType?: 'iframe' | 'direct';
|
|
60
|
-
/**
|
|
61
|
-
* URL to the app if resolved
|
|
62
|
-
*/
|
|
63
|
-
readonly url?: string;
|
|
64
|
-
}
|
|
65
|
-
export interface IGetRouteEvent {
|
|
66
|
-
readonly dbManager: DBManager;
|
|
67
|
-
/**
|
|
68
|
-
* rawPath from the Lambda event
|
|
69
|
-
*/
|
|
70
|
-
readonly rawPath: string;
|
|
71
|
-
/**
|
|
72
|
-
* Configured prefix of the deployment, must start with a / and not end with a /
|
|
73
|
-
*/
|
|
74
|
-
readonly normalizedPathPrefix?: string;
|
|
75
|
-
/**
|
|
76
|
-
* Query string params, if any
|
|
77
|
-
* Checked for `appver=1.2.3` to override the app version
|
|
78
|
-
*/
|
|
79
|
-
readonly queryStringParameters?: URLSearchParams;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Get information about immediate redirect, immediate response,
|
|
83
|
-
* or which host to route the request to.
|
|
84
|
-
*
|
|
85
|
-
* @param event
|
|
86
|
-
*
|
|
87
|
-
* @returns IGetRouteResult
|
|
88
|
-
*/
|
|
89
|
-
export declare function GetRoute(event: IGetRouteEvent): Promise<IGetRouteResult>;
|
|
90
|
-
/**
|
|
91
|
-
* Determine if we have an appname or a catch all app
|
|
92
|
-
*/
|
|
93
|
-
export declare function GetAppInfo(opts: {
|
|
94
|
-
dbManager: DBManager;
|
|
95
|
-
appName: string;
|
|
96
|
-
}): Promise<string | undefined>;
|
|
1
|
+
export { loadAppFrame } from './load-app-frame';
|
|
2
|
+
export { GetAppInfo } from './get-app-info';
|
|
3
|
+
export { normalizePathPrefix } from './normalize-path-prefix';
|
|
4
|
+
export { GetRoute, IGetRouteEvent, IGetRouteResult } from './get-route';
|
|
5
|
+
export { RedirectToDefaultFile } from './redirect-default-file';
|
|
97
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC"}
|