@squiz/edge-dev-render-runtime-lib 2.1.0 → 2.2.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/lib/ioc.d.ts CHANGED
@@ -2,14 +2,14 @@ import { Container } from 'inversify';
2
2
  import { IocContainer } from 'tsoa';
3
3
  import { ComponentSetService, ComponentFunctionService, ManifestService } from '@squiz/component-lib';
4
4
  import { Logger } from '@squiz/dx-logger-lib';
5
- import { ComponentRunnerService, ComponentRootUrlResolver } from './component-runner';
5
+ import { ComponentRootUrlResolver, DevelopmentComponentRunnerService } from './component-runner';
6
6
  import { ComponentPreviewService } from './PreviewComponentService';
7
7
  import { RenderInputService } from './RenderInputService';
8
8
  export interface Services {
9
9
  logger: Logger;
10
10
  componentSetService: ComponentSetService;
11
11
  manifestService: ManifestService;
12
- componentRunnerService: ComponentRunnerService;
12
+ developmentComponentRunnerService: DevelopmentComponentRunnerService;
13
13
  componentFunctionService: ComponentFunctionService;
14
14
  componentPreviewService: ComponentPreviewService;
15
15
  renderInputService: RenderInputService;
@@ -4874,59 +4874,31 @@
4874
4874
  "type": "object",
4875
4875
  "additionalProperties": false
4876
4876
  },
4877
- "ManifestV1Model": {
4877
+ "ComponentManifest": {
4878
4878
  "$ref": "#/components/schemas/MANIFEST_MODELS.v1.ComponentManifest"
4879
4879
  },
4880
- "ManifestModel": {
4881
- "$ref": "#/components/schemas/ManifestV1Model"
4882
- },
4883
- "MANIFEST_MODELS.v1.ComponentFunction": {
4884
- "description": "Component function definition, this object provides the runtime with input validation and what to execute",
4880
+ "ComponentSchema": {
4885
4881
  "properties": {
4886
- "name": {
4887
- "type": "string",
4888
- "description": "Function name, this will be used as part of the url to access this function"
4889
- },
4890
- "entry": {
4891
- "type": "string",
4892
- "description": "File path to the javascript file to execute. The file path must be relative to the manifest file and cannot be in a folder above the manifest file."
4893
- },
4894
- "input": {
4895
- "$ref": "#/components/schemas/DxComponentInputSchema"
4896
- },
4897
- "output": {
4898
- "anyOf": [
4899
- {
4900
- "$ref": "#/components/schemas/HtmlResponse"
4901
- },
4902
- {
4903
- "$ref": "#/components/schemas/JsonResponse"
4904
- }
4905
- ]
4906
- },
4907
- "queryParameters": {
4908
- "properties": {},
4909
- "additionalProperties": {
4910
- "$ref": "#/components/schemas/QueryParameterValueType"
4911
- },
4882
+ "schema": {
4883
+ "additionalProperties": false,
4912
4884
  "type": "object"
4885
+ },
4886
+ "name": {
4887
+ "type": "string"
4913
4888
  }
4914
4889
  },
4915
4890
  "required": [
4916
- "name",
4917
- "entry",
4918
- "input",
4919
- "output"
4891
+ "schema",
4892
+ "name"
4920
4893
  ],
4921
- "type": "object",
4922
- "additionalProperties": {}
4894
+ "type": "object"
4923
4895
  }
4924
4896
  },
4925
4897
  "securitySchemes": {}
4926
4898
  },
4927
4899
  "info": {
4928
4900
  "title": "@squiz/edge-dev-render-runtime-lib",
4929
- "version": "2.0.0",
4901
+ "version": "2.1.1",
4930
4902
  "description": "Package of Edge rendering utilities for components in dev mode",
4931
4903
  "license": {
4932
4904
  "name": "ISC"
@@ -4972,228 +4944,6 @@
4972
4944
  "security": [],
4973
4945
  "parameters": []
4974
4946
  }
4975
- },
4976
- "/d/{componentId}/manifest.json": {
4977
- "get": {
4978
- "operationId": "GetComponentVersionManifest",
4979
- "responses": {
4980
- "200": {
4981
- "description": "Ok",
4982
- "content": {
4983
- "application/json": {
4984
- "schema": {
4985
- "$ref": "#/components/schemas/ManifestModel"
4986
- }
4987
- }
4988
- }
4989
- }
4990
- },
4991
- "security": [],
4992
- "parameters": [
4993
- {
4994
- "in": "path",
4995
- "name": "componentId",
4996
- "required": true,
4997
- "schema": {
4998
- "type": "string"
4999
- }
5000
- },
5001
- {
5002
- "in": "query",
5003
- "name": "_previewKey",
5004
- "required": false,
5005
- "schema": {
5006
- "type": "string"
5007
- }
5008
- },
5009
- {
5010
- "in": "query",
5011
- "name": "_componentSet",
5012
- "required": false,
5013
- "schema": {
5014
- "type": "string"
5015
- }
5016
- }
5017
- ]
5018
- }
5019
- },
5020
- "/d/{componentId}": {
5021
- "get": {
5022
- "operationId": "GetDefaultFunctionDefinition",
5023
- "responses": {
5024
- "200": {
5025
- "description": "Ok",
5026
- "content": {
5027
- "application/json": {
5028
- "schema": {
5029
- "$ref": "#/components/schemas/MANIFEST_MODELS.v1.ComponentFunction"
5030
- }
5031
- }
5032
- }
5033
- }
5034
- },
5035
- "security": [],
5036
- "parameters": [
5037
- {
5038
- "in": "path",
5039
- "name": "componentId",
5040
- "required": true,
5041
- "schema": {
5042
- "type": "string"
5043
- }
5044
- },
5045
- {
5046
- "in": "query",
5047
- "name": "_previewKey",
5048
- "required": false,
5049
- "schema": {
5050
- "type": "string"
5051
- }
5052
- },
5053
- {
5054
- "in": "query",
5055
- "name": "_componentSet",
5056
- "required": false,
5057
- "schema": {
5058
- "type": "string"
5059
- }
5060
- }
5061
- ]
5062
- }
5063
- },
5064
- "/d/{componentId}/{functionName}": {
5065
- "get": {
5066
- "operationId": "GetGivenFunctionDefinition",
5067
- "responses": {
5068
- "200": {
5069
- "description": "Ok",
5070
- "content": {
5071
- "application/json": {
5072
- "schema": {
5073
- "$ref": "#/components/schemas/MANIFEST_MODELS.v1.ComponentFunction"
5074
- }
5075
- }
5076
- }
5077
- }
5078
- },
5079
- "security": [],
5080
- "parameters": [
5081
- {
5082
- "in": "path",
5083
- "name": "componentId",
5084
- "required": true,
5085
- "schema": {
5086
- "type": "string"
5087
- }
5088
- },
5089
- {
5090
- "in": "path",
5091
- "name": "functionName",
5092
- "required": true,
5093
- "schema": {
5094
- "type": "string"
5095
- }
5096
- },
5097
- {
5098
- "in": "query",
5099
- "name": "_previewKey",
5100
- "required": false,
5101
- "schema": {
5102
- "type": "string"
5103
- }
5104
- },
5105
- {
5106
- "in": "query",
5107
- "name": "_componentSet",
5108
- "required": false,
5109
- "schema": {
5110
- "type": "string"
5111
- }
5112
- }
5113
- ]
5114
- }
5115
- },
5116
- "/r/{componentId}": {
5117
- "get": {
5118
- "operationId": "GetDefaultFunctionRendering",
5119
- "responses": {
5120
- "204": {
5121
- "description": "No content"
5122
- }
5123
- },
5124
- "security": [],
5125
- "parameters": [
5126
- {
5127
- "in": "path",
5128
- "name": "componentId",
5129
- "required": true,
5130
- "schema": {
5131
- "type": "string"
5132
- }
5133
- },
5134
- {
5135
- "in": "query",
5136
- "name": "_componentSet",
5137
- "required": false,
5138
- "schema": {
5139
- "type": "string"
5140
- }
5141
- },
5142
- {
5143
- "in": "query",
5144
- "name": "_previewKey",
5145
- "required": false,
5146
- "schema": {
5147
- "type": "string"
5148
- }
5149
- }
5150
- ]
5151
- }
5152
- },
5153
- "/r/{componentId}/{functionName}": {
5154
- "get": {
5155
- "operationId": "GetGivenFunctionRendering",
5156
- "responses": {
5157
- "204": {
5158
- "description": "No content"
5159
- }
5160
- },
5161
- "security": [],
5162
- "parameters": [
5163
- {
5164
- "in": "path",
5165
- "name": "componentId",
5166
- "required": true,
5167
- "schema": {
5168
- "type": "string"
5169
- }
5170
- },
5171
- {
5172
- "in": "path",
5173
- "name": "functionName",
5174
- "required": true,
5175
- "schema": {
5176
- "type": "string"
5177
- }
5178
- },
5179
- {
5180
- "in": "query",
5181
- "name": "_componentSet",
5182
- "required": false,
5183
- "schema": {
5184
- "type": "string"
5185
- }
5186
- },
5187
- {
5188
- "in": "query",
5189
- "name": "_previewKey",
5190
- "required": false,
5191
- "schema": {
5192
- "type": "string"
5193
- }
5194
- }
5195
- ]
5196
- }
5197
4947
  }
5198
4948
  },
5199
4949
  "servers": [
@@ -0,0 +1,61 @@
1
+ import { Controller } from 'tsoa';
2
+ import { ComponentFunctionService, ManifestService } from '@squiz/component-lib';
3
+ import { MANIFEST_MODELS } from '@squiz/dx-json-schema-lib';
4
+ import { DevelopmentComponentRunnerService, FunctionReturnTypes } from '../../component-runner';
5
+ import { Config } from '../../ioc';
6
+ import { Request as ExpressRequest, Response as ExpressResponse } from 'express';
7
+ import { ComponentPreviewService } from '../../PreviewComponentService';
8
+ import { ComponentExecutionInput, RenderInputService } from '../../RenderInputService';
9
+ type ComponentManifest = MANIFEST_MODELS.v1.ComponentManifest;
10
+ type ComponentSchema = {
11
+ name: string;
12
+ schema: object;
13
+ };
14
+ export declare class DevelopmentController extends Controller {
15
+ private config;
16
+ private manifestService;
17
+ private componentRunnerService;
18
+ protected renderInputService: RenderInputService;
19
+ protected componentPreviewService: ComponentPreviewService;
20
+ protected componentFunctionService: ComponentFunctionService;
21
+ constructor(config: Config, manifestService: ManifestService, componentRunnerService: DevelopmentComponentRunnerService, renderInputService: RenderInputService, componentPreviewService: ComponentPreviewService, componentFunctionService: ComponentFunctionService);
22
+ /**
23
+ * Returns an array of all component manifests in the data mount point
24
+ * @return {*} {Promise<ComponentManifest[]>}
25
+ * @memberof EdgeDevelopmentController
26
+ */
27
+ getComponents(): Promise<ComponentManifest[]>;
28
+ /**
29
+ * Returns the manifest for the given componentId
30
+ * @param {string} componentId
31
+ * @return {*} {Promise<ComponentManifest>}
32
+ * @memberof EdgeDevelopmentController
33
+ */
34
+ Manifest(componentId: string): Promise<ComponentManifest>;
35
+ /**
36
+ * Returns the component schema for the given componentId
37
+ * @param {string} componentId
38
+ * @return {*} {Promise<ComponentSchema[]>}
39
+ * @memberof EdgeDevelopmentController
40
+ */
41
+ getContentSchema(componentId: string): Promise<ComponentSchema[]>;
42
+ /**
43
+ * Renders a temporary preview for a component using input data and configuration from query params, and mocking other required variables
44
+ * @param {ExpressRequest} req
45
+ * @param {string} componentId
46
+ * @param {string} functionName
47
+ * @param {*} [headers]
48
+ * @param {*} [envVars]
49
+ * @param {*} [data]
50
+ * @memberof DevelopmentController
51
+ */
52
+ TemporaryPreview(req: ExpressRequest, componentId: string, functionName: string, headers?: any, envVars?: any, data?: any): Promise<void>;
53
+ getDefaultFunctionRendering(expressRequest: ExpressRequest, componentId: string, componentSet?: string, previewKey?: string): Promise<void>;
54
+ getGivenFunctionRendering(expressRequest: ExpressRequest, componentId: string, functionName: string, componentSet?: string, previewKey?: string): Promise<void>;
55
+ protected handleResponse(input: ComponentExecutionInput, output: FunctionReturnTypes, response: ExpressResponse): void;
56
+ protected doFunctionRender(renderInput: ComponentExecutionInput): Promise<FunctionReturnTypes>;
57
+ private renderAndValidateOutput;
58
+ protected setHeadersOnResponse(renderInput: ComponentExecutionInput, response: ExpressResponse): void;
59
+ private checkDevMode;
60
+ }
61
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squiz/edge-dev-render-runtime-lib",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Package of Edge rendering utilities for components in dev mode",
5
5
  "homepage": "",
6
6
  "license": "ISC",
@@ -16,19 +16,19 @@
16
16
  "@opentelemetry/api": "^1.6.0",
17
17
  "@opentelemetry/resources": "^1.17.1",
18
18
  "@opentelemetry/semantic-conventions": "^1.17.1",
19
- "@squiz/component-lib": "^1.66.1",
20
- "@squiz/component-logger-lib": "^1.67.0",
21
- "@squiz/component-web-api-lib": "^1.65.0",
22
- "@squiz/dx-common-lib": "^1.66.1",
23
- "@squiz/dx-json-schema-lib": "^1.65.0",
19
+ "@squiz/component-lib": "^1.78.1",
20
+ "@squiz/component-logger-lib": "^1.71.1",
21
+ "@squiz/component-web-api-lib": "^1.65.1",
22
+ "@squiz/dx-common-lib": "^1.68.3",
23
+ "@squiz/dx-json-schema-lib": "^1.76.1",
24
24
  "@squiz/dx-logger-lib": "^1.64.0",
25
- "@squiz/formatted-text-lib": "^1.64.0",
26
- "@squiz/runtime-sandbox-common": "^1.64.0",
25
+ "@squiz/formatted-text-lib": "^1.68.1",
26
+ "@squiz/runtime-sandbox-common": "^1.65.1",
27
27
  "compression": "1.7.4",
28
28
  "cors": "2.8.5",
29
29
  "dotenv": "16.0.3",
30
30
  "esbuild": "^0.23.0",
31
- "express": "4.18.2",
31
+ "express": "4.20.0",
32
32
  "fs-extra": "11.1.0",
33
33
  "helmet": "6.0.1",
34
34
  "inversify": "6.0.2",
@@ -38,7 +38,7 @@
38
38
  "winston": "3.8.2"
39
39
  },
40
40
  "devDependencies": {
41
- "@squiz/runtime-sandbox-node": "^1.64.1",
41
+ "@squiz/runtime-sandbox-node": "^1.64.2",
42
42
  "@types/bunyan": "1.8.11",
43
43
  "@types/compression": "1.7.5",
44
44
  "@types/cors": "2.8.17",
@@ -1,10 +0,0 @@
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
- }
@@ -1,19 +0,0 @@
1
- import { BaseController } from './BaseController';
2
- import { type Request as ExpressRequest, type Response as ExpressResponse } from 'express';
3
- import { ManifestModel, ManifestService, ComponentFunctionService, ComponentSetService, Manifest, Headers } from '@squiz/component-lib';
4
- import { MANIFEST_MODELS } from '@squiz/dx-json-schema-lib';
5
- import { ComponentRootUrlResolver } from '../../component-runner';
6
- export declare class DefinitionController extends BaseController {
7
- protected componentSetService: ComponentSetService;
8
- protected manifestService: ManifestService;
9
- protected componentFunctionService: ComponentFunctionService;
10
- protected componentRootUrlResolver: ComponentRootUrlResolver;
11
- constructor(componentSetService: ComponentSetService, manifestService: ManifestService, componentFunctionService: ComponentFunctionService, componentRootUrlResolver: ComponentRootUrlResolver);
12
- getComponentVersionManifest(componentId: string, request: ExpressRequest, _previewKey?: string, _componentSet?: string): Promise<ManifestModel>;
13
- getDefaultFunctionDefinition(componentId: string, request: ExpressRequest, _previewKey?: string, _componentSet?: string): Promise<MANIFEST_MODELS.v1.ComponentFunction>;
14
- getGivenFunctionDefinition(componentId: string, functionName: string, request: ExpressRequest, _previewKey?: string, _componentSet?: string): Promise<MANIFEST_MODELS.v1.ComponentFunction>;
15
- private setHeadersFromComponentSet;
16
- protected setHeadersFromPreview(manifest: Manifest, _previewKey: string, functionName: string, response: ExpressResponse): void;
17
- protected setHeaders(headers: Headers, response: ExpressResponse): void;
18
- protected assertValidQueryParametersForDefinition(_previewKey: string | undefined, _componentSet: string | undefined): void;
19
- }
@@ -1,22 +0,0 @@
1
- import { BaseController } from './BaseController';
2
- import { type Request as ExpressRequest, type Response as ExpressResponse } from 'express';
3
- import { ComponentRunnerService } from '../../component-runner';
4
- import { ManifestService, ComponentFunctionService, ComponentSetService } from '@squiz/component-lib';
5
- import { RenderInputService, ComponentExecutionInput } from '../../RenderInputService';
6
- import { FunctionReturnTypes } from '../../component-runner/FunctionReturnTypes';
7
- import { ComponentPreviewService } from '../../PreviewComponentService';
8
- export declare class RenderController extends BaseController {
9
- protected componentSetService: ComponentSetService;
10
- protected manifestService: ManifestService;
11
- protected componentFunctionService: ComponentFunctionService;
12
- protected componentRunnerService: ComponentRunnerService;
13
- protected renderInputService: RenderInputService;
14
- protected componentPreviewService: ComponentPreviewService;
15
- constructor(componentSetService: ComponentSetService, manifestService: ManifestService, componentFunctionService: ComponentFunctionService, componentRunnerService: ComponentRunnerService, renderInputService: RenderInputService, componentPreviewService: ComponentPreviewService);
16
- getDefaultFunctionRendering(expressRequest: ExpressRequest, componentId: string, componentSet?: string, previewKey?: string): Promise<void>;
17
- getGivenFunctionRendering(expressRequest: ExpressRequest, componentId: string, functionName: string, componentSet?: string, previewKey?: string): Promise<void>;
18
- protected handleResponse(input: ComponentExecutionInput, output: FunctionReturnTypes, response: ExpressResponse): void;
19
- protected doFunctionRender(renderInput: ComponentExecutionInput): Promise<FunctionReturnTypes>;
20
- private renderAndValidateOutput;
21
- protected setHeadersOnResponse(renderInput: ComponentExecutionInput, response: ExpressResponse): void;
22
- }
@@ -1,2 +0,0 @@
1
- import supertest from 'supertest';
2
- export declare function definitionRouteTests(request: () => supertest.SuperTest<supertest.Test>, _rootUrl?: string): void;