@squiz/edge-dev-render-runtime-lib 2.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/README.md +3 -0
- package/lib/PreviewComponentService.d.ts +8 -0
- package/lib/PreviewComponentService.spec.d.ts +1 -0
- package/lib/RenderInputService.d.ts +53 -0
- package/lib/RenderInputService.spec.d.ts +1 -0
- package/lib/component-runner/ComponentRootUrlResolver.d.ts +2 -0
- package/lib/component-runner/ComponentRunnerServiceWithWorkers.d.ts +10 -0
- package/lib/component-runner/ComponentRuntimeContext.d.ts +15 -0
- package/lib/component-runner/ContentRuntimeService.d.ts +9 -0
- package/lib/component-runner/ExecuteComponentTask.d.ts +13 -0
- package/lib/component-runner/FunctionReturnTypes.d.ts +1 -0
- package/lib/component-runner/index.d.ts +3 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.js +2493 -0
- package/lib/index.js.map +7 -0
- package/lib/ioc.d.ts +23 -0
- package/lib/public/docs.json +5204 -0
- package/lib/test/helpers/fixtures.d.ts +31 -0
- package/lib/test/helpers/stack.d.ts +23 -0
- package/lib/test/index.d.ts +2 -0
- package/lib/utils/getComponentInfoFromComponentId.d.ts +7 -0
- package/lib/utils/getContentItemIdFromInput.d.ts +3 -0
- package/lib/utils/getContentItemIdFromInput.spec.d.ts +1 -0
- package/lib/utils/resolvePreviewOutput.d.ts +4 -0
- package/lib/utils/resolvePreviewOutput.spec.d.ts +1 -0
- package/lib/utils/setHeadersOnExpressResponse.d.ts +3 -0
- package/lib/utils/setHeadersOnExpressResponse.sepc.d.ts +1 -0
- package/lib/webserver/app.d.ts +3 -0
- package/lib/webserver/controllers/CoreController.d.ts +19 -0
- package/lib/webserver/controllers/CoreController.spec.d.ts +1 -0
- package/lib/webserver/controllers/DefinitionController.d.ts +19 -0
- package/lib/webserver/controllers/DefinitionController.spec.d.ts +1 -0
- package/lib/webserver/controllers/PreviewController.spec.d.ts +1 -0
- package/lib/webserver/controllers/RenderController.d.ts +22 -0
- package/lib/webserver/controllers/RenderController.spec.d.ts +1 -0
- package/lib/webserver/controllers/test/definition-route-tests.d.ts +2 -0
- package/lib/webserver/controllers/test/preview-route-tests.d.ts +2 -0
- package/lib/webserver/controllers/test/render-route-tests.d.ts +2 -0
- package/lib/webserver/index.d.ts +1 -0
- package/lib/webserver/routes/routes.d.ts +2 -0
- package/package.json +96 -0
package/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Manifest } from '@squiz/component-lib';
|
|
2
|
+
import { FunctionReturnTypes } from './component-runner/FunctionReturnTypes';
|
|
3
|
+
import { MANIFEST_MODELS } from '@squiz/dx-json-schema-lib';
|
|
4
|
+
export declare const PREVIEW_COMPONENT_SET = "unknown";
|
|
5
|
+
export declare class ComponentPreviewService {
|
|
6
|
+
dressRenderedOutputForPreview(componentManifest: Manifest, functionDefinition: MANIFEST_MODELS.v1.ComponentFunction, previewKey: string, componentOutput: FunctionReturnTypes): Promise<FunctionReturnTypes>;
|
|
7
|
+
private embedComponentIntoWrapper;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type Request as ExpressRequest } from 'express';
|
|
2
|
+
import { ComponentFunctionService, ComponentSetService, Headers, Manifest, ManifestModel, ManifestService, ManifestV1, ManifestV1Model, RuntimeComponentSet } from '@squiz/component-lib';
|
|
3
|
+
import { MANIFEST_MODELS } from '@squiz/dx-json-schema-lib';
|
|
4
|
+
import { ComponentRootUrlResolver } from './component-runner';
|
|
5
|
+
export type QueryParameters = Record<string, string>;
|
|
6
|
+
export type RenderRequestInput = {
|
|
7
|
+
componentSet: string | undefined;
|
|
8
|
+
namespace: string;
|
|
9
|
+
componentName: string;
|
|
10
|
+
version: string;
|
|
11
|
+
previewKey: string | undefined;
|
|
12
|
+
expressRequest: ExpressRequest;
|
|
13
|
+
functionName: string | undefined;
|
|
14
|
+
previewEnvVars?: Record<string, string>;
|
|
15
|
+
};
|
|
16
|
+
export type ComponentExecutionInput = {
|
|
17
|
+
requestId: string;
|
|
18
|
+
previewKey: string | undefined;
|
|
19
|
+
manifestPath: string;
|
|
20
|
+
functionEntryFilePath: string;
|
|
21
|
+
runtimeSet: RuntimeComponentSet;
|
|
22
|
+
input: any;
|
|
23
|
+
componentRootUrl: string;
|
|
24
|
+
componentFullName: string;
|
|
25
|
+
functionName: string;
|
|
26
|
+
manifestForWeb: ManifestModel;
|
|
27
|
+
manifest: Manifest;
|
|
28
|
+
componentFunction: MANIFEST_MODELS.v1.ComponentFunction;
|
|
29
|
+
headers: Headers;
|
|
30
|
+
queryParameters: QueryParameters;
|
|
31
|
+
};
|
|
32
|
+
export declare class RenderInputService {
|
|
33
|
+
protected componentSetService: ComponentSetService;
|
|
34
|
+
protected manifestService: ManifestService;
|
|
35
|
+
protected componentFunctionService: ComponentFunctionService;
|
|
36
|
+
protected rootUrlResolver: ComponentRootUrlResolver;
|
|
37
|
+
constructor(componentSetService: ComponentSetService, manifestService: ManifestService, componentFunctionService: ComponentFunctionService, rootUrlResolver: ComponentRootUrlResolver);
|
|
38
|
+
resolveInput(request: RenderRequestInput): Promise<ComponentExecutionInput>;
|
|
39
|
+
protected getQueryParametersFromRequest(request: RenderRequestInput, componentFunction: MANIFEST_MODELS.v1.ComponentFunction): QueryParameters;
|
|
40
|
+
protected getPreviewRuntimeSet(manifest: ManifestV1, previewEnvVars?: Record<string, string>): {
|
|
41
|
+
webPath: string;
|
|
42
|
+
displayName: string;
|
|
43
|
+
environment: {
|
|
44
|
+
[k: string]: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
protected assertInputIsValid(input: any, componentFunction: MANIFEST_MODELS.v1.ComponentFunction): void;
|
|
48
|
+
protected assertRenderInputIsValid(input: any, componentFunction: MANIFEST_MODELS.v1.ComponentFunction): void;
|
|
49
|
+
protected getInputForPreview(request: RenderRequestInput, manifest: ManifestV1): Promise<any>;
|
|
50
|
+
protected loadEnvironmentVariablesForPreview(manifest: ManifestV1Model, fallbackVars?: Record<string, string>): {
|
|
51
|
+
[k: string]: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ExecuteComponentTask } from './ExecuteComponentTask';
|
|
2
|
+
import { FunctionReturnTypes } from './FunctionReturnTypes';
|
|
3
|
+
export interface ComponentRunnerService {
|
|
4
|
+
executeComponentFunction(task: ExecuteComponentTask): Promise<FunctionReturnTypes>;
|
|
5
|
+
}
|
|
6
|
+
export declare class ComponentRunnerServiceWithWorkers implements ComponentRunnerService {
|
|
7
|
+
executeComponentFunction(task: ExecuteComponentTask): Promise<FunctionReturnTypes>;
|
|
8
|
+
private getComponentContext;
|
|
9
|
+
private getOutputLocation;
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ComponentContextualFunctions, ManifestModel, RuntimeComponentSet } from '@squiz/component-lib';
|
|
2
|
+
/**
|
|
3
|
+
* This is the object passed into the second
|
|
4
|
+
* argument of a component function at run time
|
|
5
|
+
*/
|
|
6
|
+
export interface ComponentRuntimeContext {
|
|
7
|
+
manifest: ManifestModel;
|
|
8
|
+
set: RuntimeComponentSet;
|
|
9
|
+
componentName: string;
|
|
10
|
+
version: string;
|
|
11
|
+
functionName: string;
|
|
12
|
+
previewKey?: string;
|
|
13
|
+
ctx: ComponentContextualFunctions;
|
|
14
|
+
queryParameters?: any;
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ManifestModel } from '@squiz/component-lib';
|
|
2
|
+
import { ComponentContentUriResolverForPreview, UriResource } from '@squiz/component-lib';
|
|
3
|
+
export declare class ContentRuntimeService {
|
|
4
|
+
private manifest;
|
|
5
|
+
private manifestPath?;
|
|
6
|
+
previewResolver: ComponentContentUriResolverForPreview;
|
|
7
|
+
constructor(manifest: ManifestModel, manifestPath?: string | undefined);
|
|
8
|
+
getContentItemPreview(uri: string): Promise<UriResource | undefined>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ManifestModel, RuntimeComponentSet } from '@squiz/component-lib';
|
|
2
|
+
import { MANIFEST_MODELS } from '@squiz/dx-json-schema-lib';
|
|
3
|
+
import { SandboxTask } from '@squiz/runtime-sandbox-common';
|
|
4
|
+
export interface ExecuteComponentTask extends SandboxTask {
|
|
5
|
+
runtimeSet: RuntimeComponentSet;
|
|
6
|
+
queryParameters?: any;
|
|
7
|
+
componentRootUrl: string;
|
|
8
|
+
manifest: ManifestModel;
|
|
9
|
+
manifestPath?: string;
|
|
10
|
+
componentFullName: string;
|
|
11
|
+
previewKey?: string;
|
|
12
|
+
componentFunction: MANIFEST_MODELS.v1.ComponentFunction;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type FunctionReturnTypes = string | object;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as TestHelpers from './test';
|
|
2
|
+
import { definitionRouteTests } from './webserver/controllers/test/definition-route-tests';
|
|
3
|
+
import { renderRouteTests } from './webserver/controllers/test/render-route-tests';
|
|
4
|
+
import { previewRouteTests } from './webserver/controllers/test/preview-route-tests';
|
|
5
|
+
export { Config, Services } from './ioc';
|
|
6
|
+
export * from './component-runner';
|
|
7
|
+
export * from './PreviewComponentService';
|
|
8
|
+
export * from './RenderInputService';
|
|
9
|
+
export { setupApp as setupRenderRuntimeServer } from './webserver';
|
|
10
|
+
declare const routeTests: {
|
|
11
|
+
definition: typeof definitionRouteTests;
|
|
12
|
+
render: typeof renderRouteTests;
|
|
13
|
+
preview: typeof previewRouteTests;
|
|
14
|
+
};
|
|
15
|
+
export { TestHelpers, routeTests };
|