@ms-cloudpack/common-types
Advanced tools
Comparing version 0.19.2 to 0.19.3
@@ -0,1 +1,4 @@ | ||
/** | ||
* Expanded info about a source path, as used in processed route configs. | ||
*/ | ||
export interface ExpandedSourcePath { | ||
@@ -2,0 +5,0 @@ /** |
@@ -16,2 +16,3 @@ export { allFeatures } from './allFeatures.js'; | ||
export type { DevServer } from './DevServer.js'; | ||
export type { ExpandedSourcePath } from './ExpandedSourcePath.js'; | ||
export type { Feature } from './Feature.js'; | ||
@@ -23,4 +24,4 @@ export type { Features } from './Features.js'; | ||
export type { PackageSettings, PackageSettingsMatch, GeneratedPackageSettings } from './PackageSettings.js'; | ||
export type { BootstrapRoute, RedirectRoute, RenderedRoute, Route, SharedRouteOptions, ShorthandRenderedRoute, ShorthandRoute, StaticRoute, } from './Route.js'; | ||
export { isBootstrapRoute, isRenderedRoute, isStaticRoute, isRedirectRoute } from './Route.js'; | ||
export type { BootstrapRoute, RedirectRoute, RenderedRoute, Route, SharedRouteOptions, ShorthandRenderedRoute, ShorthandBootstrapRoute, ShorthandRoute, StaticRoute, } from './Route.js'; | ||
export { isBootstrapRoute, isRenderedRoute, isStaticRoute, isRedirectRoute, isShorthandBootstrapRoute, isShorthandRenderedRoute, } from './Route.js'; | ||
export type { TelemetryConfig } from './TelemetryConfig.js'; | ||
@@ -27,0 +28,0 @@ export type { AppConfig } from './AppConfig.js'; |
export { allFeatures } from './allFeatures.js'; | ||
export { isBootstrapRoute, isRenderedRoute, isStaticRoute, isRedirectRoute } from './Route.js'; | ||
export { isBootstrapRoute, isRenderedRoute, isStaticRoute, isRedirectRoute, isShorthandBootstrapRoute, isShorthandRenderedRoute, } from './Route.js'; | ||
//# sourceMappingURL=index.js.map |
import type { ExpandedSourcePath } from './ExpandedSourcePath.js'; | ||
export interface SharedRouteOptions { | ||
/** | ||
* The url path part to match. Start paths with a leading slash, e.g. `'/my-route'`. You can also | ||
* use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`. | ||
* The URL path to match. Paths should usually start with a slash, e.g. `'/my-route'`. | ||
* You can also use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`. | ||
* | ||
* See the [Express docs](https://expressjs.com/en/guide/routing.html#route-paths) for the full | ||
* supported routing syntax. | ||
* | ||
* Use an array to handle multiple paths with the same route handler. | ||
@@ -18,8 +21,9 @@ */ | ||
* Path to a .js or .html file used for rendering the route. If a script is provided, it must | ||
* export a default function implementing `RenderRouteFunction` defined in `@ms-cloudpack/app-server`. | ||
* export a default function implementing `RenderRouteFunction` defined in `@ms-cloudpack/common-types`. | ||
*/ | ||
renderScript?: string; | ||
/** | ||
* @deprecated - The key in the exports map which represents the entry point app script for this route. | ||
* The key in the exports map which represents the entry point app script for this route. | ||
* Default is '.', meaning the main package export key. | ||
* @deprecated Use `entry` instead. | ||
*/ | ||
@@ -38,3 +42,3 @@ exportEntry?: string; | ||
/** | ||
* To be implemented. The source entry or entries to be included on the page for this route. | ||
* The source entry or entries to be included on the page for this route. | ||
*/ | ||
@@ -55,6 +59,11 @@ entry?: ExpandedSourcePath[]; | ||
*/ | ||
export interface BootstrapRoute extends SharedRouteOptions, Pick<RenderedRoute, 'entry'> { | ||
export interface ShorthandBootstrapRoute extends SharedRouteOptions, Pick<ShorthandRenderedRoute, 'entry' | 'exportEntry'> { | ||
type: 'bootstrap'; | ||
} | ||
/** | ||
* A route that serves a bootstrap script. | ||
*/ | ||
export interface BootstrapRoute extends Omit<ShorthandBootstrapRoute, 'entry'>, Pick<RenderedRoute, 'entry'> { | ||
} | ||
/** | ||
* A route that redirects to another url. | ||
@@ -69,18 +78,13 @@ */ | ||
/** | ||
* Internal helper for all route types except `RenderedRoute`/`ShorthandRenderedRoute` | ||
* (to ensure any new route types are included in both `Route` and `ShorthandRoute`). | ||
*/ | ||
type OtherRoute = StaticRoute | BootstrapRoute | RedirectRoute; | ||
/** | ||
* Route as specified in `AppConfig` (`cloudpack.config.json`). | ||
*/ | ||
export type ShorthandRoute = ShorthandRenderedRoute | OtherRoute; | ||
export type ShorthandRoute = ShorthandRenderedRoute | ShorthandBootstrapRoute | StaticRoute | RedirectRoute; | ||
/** | ||
* Processed route as used in the processed `CloudpackConfig`. | ||
*/ | ||
export type Route = RenderedRoute | OtherRoute; | ||
export type Route = RenderedRoute | BootstrapRoute | StaticRoute | RedirectRoute; | ||
/** | ||
* Type guard to check if a route is a static route. | ||
*/ | ||
export declare function isStaticRoute(route: Route): route is StaticRoute; | ||
export declare function isStaticRoute(route: Route | ShorthandRoute): route is StaticRoute; | ||
/** | ||
@@ -90,8 +94,15 @@ * Type guard to check if a route is a bootstrap route. | ||
export declare function isBootstrapRoute(route: Route): route is BootstrapRoute; | ||
/** | ||
* Type guard to check if a route is a shorthand bootstrap route. | ||
*/ | ||
export declare function isShorthandBootstrapRoute(route: ShorthandRoute): route is ShorthandBootstrapRoute; | ||
export declare function isRenderedRoute(route: Route): route is RenderedRoute; | ||
/** | ||
* Type guard to check if a route is a shorthand rendered route. | ||
*/ | ||
export declare function isShorthandRenderedRoute(route: ShorthandRoute): route is ShorthandRenderedRoute; | ||
/** | ||
* Type guard to check if a route is a redirect route. | ||
*/ | ||
export declare function isRedirectRoute(route: Route): route is RedirectRoute; | ||
export {}; | ||
export declare function isRedirectRoute(route: Route | ShorthandRoute): route is RedirectRoute; | ||
//# sourceMappingURL=Route.d.ts.map |
@@ -13,2 +13,8 @@ /** | ||
} | ||
/** | ||
* Type guard to check if a route is a shorthand bootstrap route. | ||
*/ | ||
export function isShorthandBootstrapRoute(route) { | ||
return isBootstrapRoute(route); | ||
} | ||
/* | ||
@@ -22,2 +28,8 @@ * Type guard to check if a route is a rendered route. | ||
/** | ||
* Type guard to check if a route is a shorthand rendered route. | ||
*/ | ||
export function isShorthandRenderedRoute(route) { | ||
return isRenderedRoute(route) || 'exportEntry' in route; | ||
} | ||
/** | ||
* Type guard to check if a route is a redirect route. | ||
@@ -24,0 +36,0 @@ */ |
{ | ||
"name": "@ms-cloudpack/common-types", | ||
"version": "0.19.2", | ||
"version": "0.19.3", | ||
"description": "Common types for Cloudpack.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -523,14 +523,9 @@ { | ||
{ | ||
"anyOf": [ | ||
{ | ||
"$ref": "#/definitions/StaticRoute" | ||
}, | ||
{ | ||
"$ref": "#/definitions/BootstrapRoute" | ||
}, | ||
{ | ||
"$ref": "#/definitions/RedirectRoute" | ||
} | ||
], | ||
"description": "Internal helper for all route types except `RenderedRoute`/`ShorthandRenderedRoute` (to ensure any new route types are included in both `Route` and `ShorthandRoute`)." | ||
"$ref": "#/definitions/ShorthandBootstrapRoute" | ||
}, | ||
{ | ||
"$ref": "#/definitions/StaticRoute" | ||
}, | ||
{ | ||
"$ref": "#/definitions/RedirectRoute" | ||
} | ||
@@ -555,11 +550,12 @@ ], | ||
], | ||
"description": "The url path part to match. Start paths with a leading slash, e.g. `'/my-route'`. You can also use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`.\n\nUse an array to handle multiple paths with the same route handler." | ||
"description": "The URL path to match. Paths should usually start with a slash, e.g. `'/my-route'`. You can also use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`.\n\nSee the [Express docs](https://expressjs.com/en/guide/routing.html#route-paths) for the full supported routing syntax.\n\nUse an array to handle multiple paths with the same route handler." | ||
}, | ||
"renderScript": { | ||
"type": "string", | ||
"description": "Path to a .js or .html file used for rendering the route. If a script is provided, it must export a default function implementing `RenderRouteFunction` defined in `@ms-cloudpack/app-server`." | ||
"description": "Path to a .js or .html file used for rendering the route. If a script is provided, it must export a default function implementing `RenderRouteFunction` defined in `@ms-cloudpack/common-types`." | ||
}, | ||
"exportEntry": { | ||
"type": "string", | ||
"deprecated": "- The key in the exports map which represents the entry point app script for this route.\nDefault is '.', meaning the main package export key." | ||
"description": "The key in the exports map which represents the entry point app script for this route. Default is '.', meaning the main package export key.", | ||
"deprecated": "Use `entry` instead." | ||
}, | ||
@@ -587,6 +583,6 @@ "entry": { | ||
}, | ||
"StaticRoute": { | ||
"ShorthandBootstrapRoute": { | ||
"type": "object", | ||
"properties": { | ||
"match": { | ||
"entry": { | ||
"anyOf": [ | ||
@@ -603,25 +599,8 @@ { | ||
], | ||
"description": "The url path part to match. Start paths with a leading slash, e.g. `'/my-route'`. You can also use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`.\n\nUse an array to handle multiple paths with the same route handler." | ||
"description": "The source entry or entries to be included on the page for this route." | ||
}, | ||
"staticPath": { | ||
"exportEntry": { | ||
"type": "string", | ||
"description": "The path relative to the app root to static assets." | ||
} | ||
}, | ||
"required": [ | ||
"match", | ||
"staticPath" | ||
], | ||
"additionalProperties": false, | ||
"description": "A route with a staticPath property serves static files from the specified path." | ||
}, | ||
"BootstrapRoute": { | ||
"type": "object", | ||
"properties": { | ||
"entry": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/ExpandedSourcePath" | ||
}, | ||
"description": "To be implemented. The source entry or entries to be included on the page for this route." | ||
"description": "The key in the exports map which represents the entry point app script for this route. Default is '.', meaning the main package export key.", | ||
"deprecated": "Use `entry` instead." | ||
}, | ||
@@ -640,3 +619,3 @@ "match": { | ||
], | ||
"description": "The url path part to match. Start paths with a leading slash, e.g. `'/my-route'`. You can also use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`.\n\nUse an array to handle multiple paths with the same route handler." | ||
"description": "The URL path to match. Paths should usually start with a slash, e.g. `'/my-route'`. You can also use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`.\n\nSee the [Express docs](https://expressjs.com/en/guide/routing.html#route-paths) for the full supported routing syntax.\n\nUse an array to handle multiple paths with the same route handler." | ||
}, | ||
@@ -655,24 +634,30 @@ "type": { | ||
}, | ||
"ExpandedSourcePath": { | ||
"StaticRoute": { | ||
"type": "object", | ||
"properties": { | ||
"sourcePath": { | ||
"type": "string", | ||
"description": "The relative path to the source file. (e.g. `./src/index.ts`)" | ||
"match": { | ||
"anyOf": [ | ||
{ | ||
"type": "string" | ||
}, | ||
{ | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
], | ||
"description": "The URL path to match. Paths should usually start with a slash, e.g. `'/my-route'`. You can also use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`.\n\nSee the [Express docs](https://expressjs.com/en/guide/routing.html#route-paths) for the full supported routing syntax.\n\nUse an array to handle multiple paths with the same route handler." | ||
}, | ||
"importPath": { | ||
"staticPath": { | ||
"type": "string", | ||
"description": "The path to import the resulting bundled output from. This would represent the key in the import map entry to be imported. (e.g. `.` represents the default package export.)" | ||
}, | ||
"requestPath": { | ||
"type": "string", | ||
"description": "The path to be requested by the browser. This would present the value in the import map entry to be requested. (e.g. `./lib/index.js`)" | ||
"description": "The path relative to the app root to static assets." | ||
} | ||
}, | ||
"required": [ | ||
"sourcePath", | ||
"importPath", | ||
"requestPath" | ||
"match", | ||
"staticPath" | ||
], | ||
"additionalProperties": false | ||
"additionalProperties": false, | ||
"description": "A route with a staticPath property serves static files from the specified path." | ||
}, | ||
@@ -694,3 +679,3 @@ "RedirectRoute": { | ||
], | ||
"description": "The url path part to match. Start paths with a leading slash, e.g. `'/my-route'`. You can also use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`.\n\nUse an array to handle multiple paths with the same route handler." | ||
"description": "The URL path to match. Paths should usually start with a slash, e.g. `'/my-route'`. You can also use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`.\n\nSee the [Express docs](https://expressjs.com/en/guide/routing.html#route-paths) for the full supported routing syntax.\n\nUse an array to handle multiple paths with the same route handler." | ||
}, | ||
@@ -697,0 +682,0 @@ "redirectTo": { |
@@ -524,14 +524,9 @@ { | ||
{ | ||
"anyOf": [ | ||
{ | ||
"$ref": "#/definitions/StaticRoute" | ||
}, | ||
{ | ||
"$ref": "#/definitions/BootstrapRoute" | ||
}, | ||
{ | ||
"$ref": "#/definitions/RedirectRoute" | ||
} | ||
], | ||
"description": "Internal helper for all route types except `RenderedRoute`/`ShorthandRenderedRoute` (to ensure any new route types are included in both `Route` and `ShorthandRoute`)." | ||
"$ref": "#/definitions/ShorthandBootstrapRoute" | ||
}, | ||
{ | ||
"$ref": "#/definitions/StaticRoute" | ||
}, | ||
{ | ||
"$ref": "#/definitions/RedirectRoute" | ||
} | ||
@@ -556,11 +551,12 @@ ], | ||
], | ||
"description": "The url path part to match. Start paths with a leading slash, e.g. `'/my-route'`. You can also use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`.\n\nUse an array to handle multiple paths with the same route handler." | ||
"description": "The URL path to match. Paths should usually start with a slash, e.g. `'/my-route'`. You can also use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`.\n\nSee the [Express docs](https://expressjs.com/en/guide/routing.html#route-paths) for the full supported routing syntax.\n\nUse an array to handle multiple paths with the same route handler." | ||
}, | ||
"renderScript": { | ||
"type": "string", | ||
"description": "Path to a .js or .html file used for rendering the route. If a script is provided, it must export a default function implementing `RenderRouteFunction` defined in `@ms-cloudpack/app-server`." | ||
"description": "Path to a .js or .html file used for rendering the route. If a script is provided, it must export a default function implementing `RenderRouteFunction` defined in `@ms-cloudpack/common-types`." | ||
}, | ||
"exportEntry": { | ||
"type": "string", | ||
"deprecated": "- The key in the exports map which represents the entry point app script for this route.\nDefault is '.', meaning the main package export key." | ||
"description": "The key in the exports map which represents the entry point app script for this route. Default is '.', meaning the main package export key.", | ||
"deprecated": "Use `entry` instead." | ||
}, | ||
@@ -588,6 +584,6 @@ "entry": { | ||
}, | ||
"StaticRoute": { | ||
"ShorthandBootstrapRoute": { | ||
"type": "object", | ||
"properties": { | ||
"match": { | ||
"entry": { | ||
"anyOf": [ | ||
@@ -604,25 +600,8 @@ { | ||
], | ||
"description": "The url path part to match. Start paths with a leading slash, e.g. `'/my-route'`. You can also use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`.\n\nUse an array to handle multiple paths with the same route handler." | ||
"description": "The source entry or entries to be included on the page for this route." | ||
}, | ||
"staticPath": { | ||
"exportEntry": { | ||
"type": "string", | ||
"description": "The path relative to the app root to static assets." | ||
} | ||
}, | ||
"required": [ | ||
"match", | ||
"staticPath" | ||
], | ||
"additionalProperties": false, | ||
"description": "A route with a staticPath property serves static files from the specified path." | ||
}, | ||
"BootstrapRoute": { | ||
"type": "object", | ||
"properties": { | ||
"entry": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/ExpandedSourcePath" | ||
}, | ||
"description": "To be implemented. The source entry or entries to be included on the page for this route." | ||
"description": "The key in the exports map which represents the entry point app script for this route. Default is '.', meaning the main package export key.", | ||
"deprecated": "Use `entry` instead." | ||
}, | ||
@@ -641,3 +620,3 @@ "match": { | ||
], | ||
"description": "The url path part to match. Start paths with a leading slash, e.g. `'/my-route'`. You can also use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`.\n\nUse an array to handle multiple paths with the same route handler." | ||
"description": "The URL path to match. Paths should usually start with a slash, e.g. `'/my-route'`. You can also use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`.\n\nSee the [Express docs](https://expressjs.com/en/guide/routing.html#route-paths) for the full supported routing syntax.\n\nUse an array to handle multiple paths with the same route handler." | ||
}, | ||
@@ -656,24 +635,30 @@ "type": { | ||
}, | ||
"ExpandedSourcePath": { | ||
"StaticRoute": { | ||
"type": "object", | ||
"properties": { | ||
"sourcePath": { | ||
"type": "string", | ||
"description": "The relative path to the source file. (e.g. `./src/index.ts`)" | ||
"match": { | ||
"anyOf": [ | ||
{ | ||
"type": "string" | ||
}, | ||
{ | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
], | ||
"description": "The URL path to match. Paths should usually start with a slash, e.g. `'/my-route'`. You can also use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`.\n\nSee the [Express docs](https://expressjs.com/en/guide/routing.html#route-paths) for the full supported routing syntax.\n\nUse an array to handle multiple paths with the same route handler." | ||
}, | ||
"importPath": { | ||
"staticPath": { | ||
"type": "string", | ||
"description": "The path to import the resulting bundled output from. This would represent the key in the import map entry to be imported. (e.g. `.` represents the default package export.)" | ||
}, | ||
"requestPath": { | ||
"type": "string", | ||
"description": "The path to be requested by the browser. This would present the value in the import map entry to be requested. (e.g. `./lib/index.js`)" | ||
"description": "The path relative to the app root to static assets." | ||
} | ||
}, | ||
"required": [ | ||
"sourcePath", | ||
"importPath", | ||
"requestPath" | ||
"match", | ||
"staticPath" | ||
], | ||
"additionalProperties": false | ||
"additionalProperties": false, | ||
"description": "A route with a staticPath property serves static files from the specified path." | ||
}, | ||
@@ -695,3 +680,3 @@ "RedirectRoute": { | ||
], | ||
"description": "The url path part to match. Start paths with a leading slash, e.g. `'/my-route'`. You can also use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`.\n\nUse an array to handle multiple paths with the same route handler." | ||
"description": "The URL path to match. Paths should usually start with a slash, e.g. `'/my-route'`. You can also use wildcards (`*`), e.g. `'/my-route/*'` to match all paths starting with `'/my-route'`.\n\nSee the [Express docs](https://expressjs.com/en/guide/routing.html#route-paths) for the full supported routing syntax.\n\nUse an array to handle multiple paths with the same route handler." | ||
}, | ||
@@ -698,0 +683,0 @@ "redirectTo": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
241880
3629