@squiz/edge-dev-render-runtime-lib 2.4.0 → 2.4.1
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.
|
@@ -4,8 +4,12 @@ export interface ComponentRunnerService {
|
|
|
4
4
|
executeServerComponentFunction(task: ExecuteComponentTask): Promise<FunctionReturnTypes>;
|
|
5
5
|
executeEdgeComponentFunction(task: ExecuteComponentTask): Promise<FunctionReturnTypes>;
|
|
6
6
|
}
|
|
7
|
+
export type ContextAwareness = {
|
|
8
|
+
matrixUrl?: string;
|
|
9
|
+
matrixAssetId?: string;
|
|
10
|
+
};
|
|
7
11
|
export declare class DevelopmentComponentRunnerService implements ComponentRunnerService {
|
|
8
|
-
executeEdgeComponentFunction(task: ExecuteComponentTask): Promise<FunctionReturnTypes>;
|
|
12
|
+
executeEdgeComponentFunction(task: ExecuteComponentTask, contextAwareness?: ContextAwareness): Promise<FunctionReturnTypes>;
|
|
9
13
|
executeServerComponentFunction(task: ExecuteComponentTask): Promise<FunctionReturnTypes>;
|
|
10
14
|
private setUpWebRequestEventForResolveUri;
|
|
11
15
|
private transformCode;
|
package/lib/index.js
CHANGED
|
@@ -237,7 +237,7 @@ var DevelopmentController = class extends import_tsoa3.Controller {
|
|
|
237
237
|
});
|
|
238
238
|
return schemaResult;
|
|
239
239
|
}
|
|
240
|
-
async TemporaryPreview(req, componentId, functionName, headers, envVars, data) {
|
|
240
|
+
async TemporaryPreview(req, componentId, functionName, headers, envVars, data, contextMatrixAssetId, contextMatrixUrl) {
|
|
241
241
|
this.checkDevMode();
|
|
242
242
|
const { namespace, componentName, version } = getComponentInfoFromComponentId(componentId);
|
|
243
243
|
const res = req.res;
|
|
@@ -263,7 +263,11 @@ var DevelopmentController = class extends import_tsoa3.Controller {
|
|
|
263
263
|
previewKey: void 0,
|
|
264
264
|
queryParameters: void 0
|
|
265
265
|
};
|
|
266
|
-
|
|
266
|
+
const ctx = {
|
|
267
|
+
matrixAssetId: contextMatrixAssetId,
|
|
268
|
+
matrixUrl: contextMatrixUrl
|
|
269
|
+
};
|
|
270
|
+
let result = componentManifest.type === "edge" ? await this.componentRunnerService.executeEdgeComponentFunction(componentTask, ctx) : await this.componentRunnerService.executeServerComponentFunction(componentTask);
|
|
267
271
|
const responseHeaders = headers ?? {};
|
|
268
272
|
switch (componentFunction.output.responseType) {
|
|
269
273
|
case "html":
|
|
@@ -285,10 +289,18 @@ var DevelopmentController = class extends import_tsoa3.Controller {
|
|
|
285
289
|
setHeadersOnExpressResponse(responseHeaders ?? {}, res);
|
|
286
290
|
res.send(result);
|
|
287
291
|
}
|
|
288
|
-
async getDefaultFunctionRendering(expressRequest, componentId, componentSet, previewKey) {
|
|
289
|
-
await this.getGivenFunctionRendering(
|
|
292
|
+
async getDefaultFunctionRendering(expressRequest, componentId, componentSet, previewKey, contextMatrixAssetId, contextMatrixUrl) {
|
|
293
|
+
await this.getGivenFunctionRendering(
|
|
294
|
+
expressRequest,
|
|
295
|
+
componentId,
|
|
296
|
+
"",
|
|
297
|
+
componentSet,
|
|
298
|
+
previewKey,
|
|
299
|
+
contextMatrixAssetId,
|
|
300
|
+
contextMatrixUrl
|
|
301
|
+
);
|
|
290
302
|
}
|
|
291
|
-
async getGivenFunctionRendering(expressRequest, componentId, functionName, componentSet, previewKey) {
|
|
303
|
+
async getGivenFunctionRendering(expressRequest, componentId, functionName, componentSet, previewKey, contextMatrixAssetId, contextMatrixUrl) {
|
|
292
304
|
const response = expressRequest.res;
|
|
293
305
|
(0, import_dx_common_lib2.assertIsDefined)(response);
|
|
294
306
|
const { path: path6, query } = expressRequest;
|
|
@@ -303,6 +315,10 @@ var DevelopmentController = class extends import_tsoa3.Controller {
|
|
|
303
315
|
response.redirect(url);
|
|
304
316
|
return;
|
|
305
317
|
}
|
|
318
|
+
const ctx = {
|
|
319
|
+
matrixAssetId: contextMatrixAssetId,
|
|
320
|
+
matrixUrl: contextMatrixUrl
|
|
321
|
+
};
|
|
306
322
|
const { namespace, componentName, version } = getComponentInfoFromComponentId(componentId);
|
|
307
323
|
const renderInput = await this.renderInputService.resolveInput({
|
|
308
324
|
componentSet,
|
|
@@ -313,15 +329,15 @@ var DevelopmentController = class extends import_tsoa3.Controller {
|
|
|
313
329
|
expressRequest,
|
|
314
330
|
functionName
|
|
315
331
|
});
|
|
316
|
-
const renderedOutput = await this.doFunctionRender(renderInput);
|
|
332
|
+
const renderedOutput = await this.doFunctionRender(renderInput, ctx);
|
|
317
333
|
this.handleResponse(renderInput, renderedOutput, response);
|
|
318
334
|
}
|
|
319
335
|
handleResponse(input, output, response) {
|
|
320
336
|
this.setHeadersOnResponse(input, response);
|
|
321
337
|
response.send(output);
|
|
322
338
|
}
|
|
323
|
-
async doFunctionRender(renderInput) {
|
|
324
|
-
let result = await this.renderAndValidateOutput(renderInput, renderInput.manifest.type ?? "server");
|
|
339
|
+
async doFunctionRender(renderInput, ctx) {
|
|
340
|
+
let result = await this.renderAndValidateOutput(renderInput, renderInput.manifest.type ?? "server", ctx);
|
|
325
341
|
if (renderInput.previewKey !== void 0) {
|
|
326
342
|
result = await this.componentPreviewService.dressRenderedOutputForPreview(
|
|
327
343
|
renderInput.manifest,
|
|
@@ -332,14 +348,14 @@ var DevelopmentController = class extends import_tsoa3.Controller {
|
|
|
332
348
|
}
|
|
333
349
|
return result;
|
|
334
350
|
}
|
|
335
|
-
async renderAndValidateOutput(renderInput, componentType) {
|
|
351
|
+
async renderAndValidateOutput(renderInput, componentType, ctx) {
|
|
336
352
|
const executeComponentTask = {
|
|
337
353
|
...renderInput,
|
|
338
354
|
args: [renderInput.input],
|
|
339
355
|
manifest: renderInput.manifestForWeb,
|
|
340
356
|
environment: renderInput.runtimeSet.environment
|
|
341
357
|
};
|
|
342
|
-
const result = componentType === "edge" ? await this.componentRunnerService.executeEdgeComponentFunction(executeComponentTask) : await this.componentRunnerService.executeServerComponentFunction(executeComponentTask);
|
|
358
|
+
const result = componentType === "edge" ? await this.componentRunnerService.executeEdgeComponentFunction(executeComponentTask, ctx) : await this.componentRunnerService.executeServerComponentFunction(executeComponentTask);
|
|
343
359
|
try {
|
|
344
360
|
this.componentFunctionService.assertOutputValidForComponentFunction(result, renderInput.componentFunction);
|
|
345
361
|
} catch (e) {
|
|
@@ -398,14 +414,18 @@ __decorateClass([
|
|
|
398
414
|
__decorateParam(2, (0, import_tsoa3.Path)()),
|
|
399
415
|
__decorateParam(3, (0, import_tsoa3.Query)()),
|
|
400
416
|
__decorateParam(4, (0, import_tsoa3.Query)()),
|
|
401
|
-
__decorateParam(5, (0, import_tsoa3.Query)())
|
|
417
|
+
__decorateParam(5, (0, import_tsoa3.Query)()),
|
|
418
|
+
__decorateParam(6, (0, import_tsoa3.Query)()),
|
|
419
|
+
__decorateParam(7, (0, import_tsoa3.Query)())
|
|
402
420
|
], DevelopmentController.prototype, "TemporaryPreview", 1);
|
|
403
421
|
__decorateClass([
|
|
404
422
|
(0, import_tsoa3.Get)("/render/:componentId"),
|
|
405
423
|
__decorateParam(0, (0, import_tsoa3.Request)()),
|
|
406
424
|
__decorateParam(1, (0, import_tsoa3.Path)()),
|
|
407
425
|
__decorateParam(2, (0, import_tsoa3.Query)("_componentSet")),
|
|
408
|
-
__decorateParam(3, (0, import_tsoa3.Query)("_previewKey"))
|
|
426
|
+
__decorateParam(3, (0, import_tsoa3.Query)("_previewKey")),
|
|
427
|
+
__decorateParam(4, (0, import_tsoa3.Query)()),
|
|
428
|
+
__decorateParam(5, (0, import_tsoa3.Query)())
|
|
409
429
|
], DevelopmentController.prototype, "getDefaultFunctionRendering", 1);
|
|
410
430
|
__decorateClass([
|
|
411
431
|
(0, import_tsoa3.Get)("/render/:componentId/:functionName"),
|
|
@@ -413,7 +433,9 @@ __decorateClass([
|
|
|
413
433
|
__decorateParam(1, (0, import_tsoa3.Path)()),
|
|
414
434
|
__decorateParam(2, (0, import_tsoa3.Path)()),
|
|
415
435
|
__decorateParam(3, (0, import_tsoa3.Query)("_componentSet")),
|
|
416
|
-
__decorateParam(4, (0, import_tsoa3.Query)("_previewKey"))
|
|
436
|
+
__decorateParam(4, (0, import_tsoa3.Query)("_previewKey")),
|
|
437
|
+
__decorateParam(5, (0, import_tsoa3.Query)()),
|
|
438
|
+
__decorateParam(6, (0, import_tsoa3.Query)())
|
|
417
439
|
], DevelopmentController.prototype, "getGivenFunctionRendering", 1);
|
|
418
440
|
DevelopmentController = __decorateClass([
|
|
419
441
|
(0, import_inversify_binding_decorators2.provide)(DevelopmentController),
|
|
@@ -477,6 +499,11 @@ var models = {
|
|
|
477
499
|
"additionalProperties": false
|
|
478
500
|
},
|
|
479
501
|
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
|
502
|
+
"UiMetadata": {
|
|
503
|
+
"dataType": "refAlias",
|
|
504
|
+
"type": { "dataType": "intersection", "subSchemas": [{ "dataType": "nestedObjectLiteral", "nestedProperties": { "autoReload": { "dataType": "boolean" } }, "additionalProperties": { "dataType": "any" } }, { "dataType": "union", "subSchemas": [{ "dataType": "nestedObjectLiteral", "nestedProperties": { "collapsedByDefault": { "dataType": "boolean" } } }, { "dataType": "nestedObjectLiteral", "nestedProperties": { "quickOption": { "dataType": "boolean" }, "inlineEditable": { "dataType": "boolean" } } }] }], "validators": {} }
|
|
505
|
+
},
|
|
506
|
+
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
|
480
507
|
"CoreSchemaMetaSchema2": {
|
|
481
508
|
"dataType": "refAlias",
|
|
482
509
|
"type": { "dataType": "union", "subSchemas": [{ "dataType": "nestedObjectLiteral", "nestedProperties": { "not": { "ref": "CoreSchemaMetaSchema2" }, "oneOf": { "ref": "SchemaArray" }, "anyOf": { "ref": "SchemaArray" }, "allOf": { "ref": "SchemaArray" }, "else": { "ref": "CoreSchemaMetaSchema2" }, "then": { "ref": "CoreSchemaMetaSchema2" }, "if": { "ref": "CoreSchemaMetaSchema2" }, "contentEncoding": { "dataType": "string" }, "contentMediaType": { "dataType": "string" }, "matrixAssetTypes": { "dataType": "array", "array": { "dataType": "union", "subSchemas": [{ "dataType": "enum", "enums": ["audioFile"] }, { "dataType": "enum", "enums": ["bodycopyContainer"] }, { "dataType": "enum", "enums": ["bodycopyDiv"] }, { "dataType": "enum", "enums": ["calendarEventsSearchPage"] }, { "dataType": "enum", "enums": ["contentContainerTemplate"] }, { "dataType": "enum", "enums": ["contentTypeMarkdown"] }, { "dataType": "enum", "enums": ["contentTypeNestContent"] }, { "dataType": "enum", "enums": ["contentTypeRawHtml"] }, { "dataType": "enum", "enums": ["contentTypeSnippet"] }, { "dataType": "enum", "enums": ["contentTypeWysiwyg"] }, { "dataType": "enum", "enums": ["cssFileFolder"] }, { "dataType": "enum", "enums": ["cssFile"] }, { "dataType": "enum", "enums": ["customForm"] }, { "dataType": "enum", "enums": ["dataRecord"] }, { "dataType": "enum", "enums": ["designAreaAssetLineage"] }, { "dataType": "enum", "enums": ["designAreaBody"] }, { "dataType": "enum", "enums": ["designAreaMenuNormal"] }, { "dataType": "enum", "enums": ["designAreaNestContent"] }, { "dataType": "enum", "enums": ["designCssCustomisation"] }, { "dataType": "enum", "enums": ["designCss"] }, { "dataType": "enum", "enums": ["designCustomisation"] }, { "dataType": "enum", "enums": ["designScss"] }, { "dataType": "enum", "enums": ["design"] }, { "dataType": "enum", "enums": ["docx"] }, { "dataType": "enum", "enums": ["excelDoc"] }, { "dataType": "enum", "enums": ["file"] }, { "dataType": "enum", "enums": ["folder"] }, { "dataType": "enum", "enums": ["gitBridge"] }, { "dataType": "enum", "enums": ["googleAnalyticsConnector"] }, { "dataType": "enum", "enums": ["googleAnalyticsView"] }, { "dataType": "enum", "enums": ["image"] }, { "dataType": "enum", "enums": ["jsFileFolder"] }, { "dataType": "enum", "enums": ["jsFile"] }, { "dataType": "enum", "enums": ["jsonWebToken"] }, { "dataType": "enum", "enums": ["layoutManager"] }, { "dataType": "enum", "enums": ["layout"] }, { "dataType": "enum", "enums": ["link"] }, { "dataType": "enum", "enums": ["metadataFieldDate"] }, { "dataType": "enum", "enums": ["metadataFieldRelatedAsset"] }, { "dataType": "enum", "enums": ["metadataFieldSelect"] }, { "dataType": "enum", "enums": ["metadataFieldText"] }, { "dataType": "enum", "enums": ["metadataFieldWysiwyg"] }, { "dataType": "enum", "enums": ["metadataSchema"] }, { "dataType": "enum", "enums": ["metadataSection"] }, { "dataType": "enum", "enums": ["newsItem"] }, { "dataType": "enum", "enums": ["oauthAccountManager"] }, { "dataType": "enum", "enums": ["pageAccountManager"] }, { "dataType": "enum", "enums": ["pageAssetListing"] }, { "dataType": "enum", "enums": ["pageCalendarEventsSearch"] }, { "dataType": "enum", "enums": ["pageCalendar"] }, { "dataType": "enum", "enums": ["pagePasswordReset"] }, { "dataType": "enum", "enums": ["pageRemoteContent"] }, { "dataType": "enum", "enums": ["pageRestResourceJs"] }, { "dataType": "enum", "enums": ["pageRestResourceOauthSession"] }, { "dataType": "enum", "enums": ["pageRestResourceOauthTwoLegged"] }, { "dataType": "enum", "enums": ["pageRestResource"] }, { "dataType": "enum", "enums": ["pageSiteMap"] }, { "dataType": "enum", "enums": ["pageStandard"] }, { "dataType": "enum", "enums": ["paintLayoutBodycopy"] }, { "dataType": "enum", "enums": ["paintLayoutPage"] }, { "dataType": "enum", "enums": ["pdfFile"] }, { "dataType": "enum", "enums": ["pdf"] }, { "dataType": "enum", "enums": ["persona"] }, { "dataType": "enum", "enums": ["powerpointDoc"] }, { "dataType": "enum", "enums": ["pptx"] }, { "dataType": "enum", "enums": ["redirectPage"] }, { "dataType": "enum", "enums": ["regex"] }, { "dataType": "enum", "enums": ["regularExpression"] }, { "dataType": "enum", "enums": ["rtfFile"] }, { "dataType": "enum", "enums": ["samlAccountManager"] }, { "dataType": "enum", "enums": ["saml2Acs"] }, { "dataType": "enum", "enums": ["saml2Sls"] }, { "dataType": "enum", "enums": ["searchPage"] }, { "dataType": "enum", "enums": ["site"] }, { "dataType": "enum", "enums": ["textFile"] }, { "dataType": "enum", "enums": ["TriggerTypes?"] }, { "dataType": "enum", "enums": ["userGroup"] }, { "dataType": "enum", "enums": ["wordDoc"] }, { "dataType": "enum", "enums": ["workflowSchema"] }, { "dataType": "enum", "enums": ["workflowStepCondition"] }, { "dataType": "enum", "enums": ["workflowStep"] }, { "dataType": "enum", "enums": ["workflowStream"] }, { "dataType": "enum", "enums": ["xlsx"] }, { "dataType": "enum", "enums": ["xmlFile"] }] } }, "format": { "dataType": "union", "subSchemas": [{ "dataType": "enum", "enums": ["date-time"] }, { "dataType": "enum", "enums": ["email"] }, { "dataType": "enum", "enums": ["hostname"] }, { "dataType": "enum", "enums": ["ipv4"] }, { "dataType": "enum", "enums": ["ipv6"] }, { "dataType": "enum", "enums": ["json-pointer"] }, { "dataType": "enum", "enums": ["matrix-asset-uri"] }, { "dataType": "enum", "enums": ["multi-line"] }, { "dataType": "enum", "enums": ["password"] }, { "dataType": "enum", "enums": ["phone"] }, { "dataType": "enum", "enums": ["regex"] }, { "dataType": "enum", "enums": ["relative-json-pointer"] }, { "dataType": "enum", "enums": ["uri-reference"] }, { "dataType": "enum", "enums": ["uri-template"] }, { "dataType": "enum", "enums": ["uri"] }, { "dataType": "enum", "enums": ["uuid"] }] }, "type": { "dataType": "union", "subSchemas": [{ "dataType": "union", "subSchemas": [{ "dataType": "enum", "enums": ["array"] }, { "dataType": "enum", "enums": ["boolean"] }, { "dataType": "enum", "enums": ["integer"] }, { "dataType": "enum", "enums": ["null"] }, { "dataType": "enum", "enums": ["number"] }, { "dataType": "enum", "enums": ["object"] }, { "dataType": "enum", "enums": ["string"] }, { "dataType": "enum", "enums": ["FormattedText"] }, { "dataType": "enum", "enums": ["SquizImage"] }, { "dataType": "enum", "enums": ["SquizLink"] }] }, { "dataType": "array", "array": { "dataType": "union", "subSchemas": [{ "dataType": "enum", "enums": ["array"] }, { "dataType": "enum", "enums": ["boolean"] }, { "dataType": "enum", "enums": ["integer"] }, { "dataType": "enum", "enums": ["null"] }, { "dataType": "enum", "enums": ["number"] }, { "dataType": "enum", "enums": ["object"] }, { "dataType": "enum", "enums": ["string"] }, { "dataType": "enum", "enums": ["FormattedText"] }, { "dataType": "enum", "enums": ["SquizImage"] }, { "dataType": "enum", "enums": ["SquizLink"] }] } }] }, "enum": { "dataType": "array", "array": { "dataType": "enum", "enums": [true] }, "validators": { "minItems": { "value": 1 } } }, "const": { "dataType": "enum", "enums": [true] }, "propertyNames": { "ref": "CoreSchemaMetaSchema2" }, "dependencies": { "dataType": "nestedObjectLiteral", "nestedProperties": {}, "additionalProperties": { "dataType": "union", "subSchemas": [{ "ref": "CoreSchemaMetaSchema2" }, { "ref": "StringArray" }] } }, "patternProperties": { "dataType": "nestedObjectLiteral", "nestedProperties": {}, "additionalProperties": { "ref": "CoreSchemaMetaSchema2" } }, "properties": { "dataType": "nestedObjectLiteral", "nestedProperties": {}, "additionalProperties": { "ref": "CoreSchemaMetaSchema2" } }, "definitions": { "dataType": "nestedObjectLiteral", "nestedProperties": {}, "additionalProperties": { "ref": "CoreSchemaMetaSchema2" } }, "additionalProperties": { "ref": "CoreSchemaMetaSchema2" }, "required": { "ref": "StringArray" }, "minProperties": { "dataType": "intersection", "subSchemas": [{ "dataType": "double" }, { "dataType": "double" }] }, "maxProperties": { "dataType": "double" }, "contains": { "ref": "CoreSchemaMetaSchema2" }, "uniqueItems": { "dataType": "boolean" }, "minItems": { "dataType": "intersection", "subSchemas": [{ "dataType": "double" }, { "dataType": "double" }] }, "maxItems": { "dataType": "double" }, "items": { "dataType": "union", "subSchemas": [{ "ref": "CoreSchemaMetaSchema2" }, { "ref": "SchemaArray" }] }, "additionalItems": { "ref": "CoreSchemaMetaSchema2" }, "pattern": { "dataType": "string" }, "minLength": { "dataType": "intersection", "subSchemas": [{ "dataType": "double" }, { "dataType": "double" }] }, "maxLength": { "dataType": "double" }, "exclusiveMinimum": { "dataType": "double" }, "minimum": { "dataType": "double" }, "exclusiveMaximum": { "dataType": "double" }, "maximum": { "dataType": "double" }, "multipleOf": { "dataType": "double" }, "examples": { "dataType": "array", "array": { "dataType": "enum", "enums": [true] } }, "writeOnly": { "dataType": "boolean" }, "readOnly": { "dataType": "boolean" }, "default": { "dataType": "enum", "enums": [true] }, "description": { "dataType": "string" }, "title": { "dataType": "string" }, "$comment": { "dataType": "string" }, "$ref": { "dataType": "string" }, "$schema": { "dataType": "string" }, "ui:metadata": { "dataType": "union", "subSchemas": [{ "dataType": "nestedObjectLiteral", "nestedProperties": { "collapsedByDefault": { "dataType": "boolean" } } }, { "dataType": "nestedObjectLiteral", "nestedProperties": { "quickOption": { "dataType": "boolean" }, "inlineEditable": { "dataType": "boolean" } } }] }, "$id": { "dataType": "string" } } }, { "dataType": "boolean" }], "validators": {} }
|
|
@@ -496,7 +523,7 @@ var models = {
|
|
|
496
523
|
"dataType": "refObject",
|
|
497
524
|
"properties": {
|
|
498
525
|
"$id": { "dataType": "string" },
|
|
499
|
-
"ui:metadata": { "
|
|
526
|
+
"ui:metadata": { "ref": "UiMetadata" },
|
|
500
527
|
"$schema": { "dataType": "string" },
|
|
501
528
|
"$ref": { "dataType": "string" },
|
|
502
529
|
"$comment": { "dataType": "string" },
|
|
@@ -852,7 +879,8 @@ var models = {
|
|
|
852
879
|
"staticFiles": { "dataType": "nestedObjectLiteral", "nestedProperties": { "locationRoot": { "dataType": "string", "required": true } }, "additionalProperties": { "dataType": "any" } },
|
|
853
880
|
"functions": { "dataType": "array", "array": { "dataType": "refObject", "ref": "ComponentFunction" }, "required": true, "validators": { "minItems": { "value": 0 } } },
|
|
854
881
|
"previews": { "dataType": "nestedObjectLiteral", "nestedProperties": {}, "additionalProperties": { "ref": "PreviewDefinition" } },
|
|
855
|
-
"mockedUris": { "dataType": "nestedObjectLiteral", "nestedProperties": {}, "additionalProperties": { "dataType": "union", "subSchemas": [{ "dataType": "nestedObjectLiteral", "nestedProperties": { "path": { "dataType": "string", "required": true }, "type": { "dataType": "enum", "enums": ["file"], "required": true } }, "additionalProperties": { "dataType": "any" } }, { "dataType": "nestedObjectLiteral", "nestedProperties": { "value": { "ref": "MatrixAssetSchema", "required": true }, "type": { "dataType": "enum", "enums": ["inline"], "required": true } }, "additionalProperties": { "dataType": "any" } }] } }
|
|
882
|
+
"mockedUris": { "dataType": "nestedObjectLiteral", "nestedProperties": {}, "additionalProperties": { "dataType": "union", "subSchemas": [{ "dataType": "nestedObjectLiteral", "nestedProperties": { "path": { "dataType": "string", "required": true }, "type": { "dataType": "enum", "enums": ["file"], "required": true } }, "additionalProperties": { "dataType": "any" } }, { "dataType": "nestedObjectLiteral", "nestedProperties": { "value": { "ref": "MatrixAssetSchema", "required": true }, "type": { "dataType": "enum", "enums": ["inline"], "required": true } }, "additionalProperties": { "dataType": "any" } }] } },
|
|
883
|
+
"ui:metadata": { "dataType": "nestedObjectLiteral", "nestedProperties": { "autoReload": { "dataType": "intersection", "subSchemas": [{ "dataType": "boolean" }, { "dataType": "string" }], "required": true } }, "additionalProperties": { "dataType": "any" } }
|
|
856
884
|
},
|
|
857
885
|
"additionalProperties": false
|
|
858
886
|
},
|
|
@@ -994,7 +1022,9 @@ function RegisterRoutes(app) {
|
|
|
994
1022
|
functionName: { "in": "path", "name": "functionName", "required": true, "dataType": "string" },
|
|
995
1023
|
headers: { "in": "query", "name": "headers", "dataType": "any" },
|
|
996
1024
|
envVars: { "in": "query", "name": "envVars", "dataType": "any" },
|
|
997
|
-
data: { "in": "query", "name": "data", "dataType": "any" }
|
|
1025
|
+
data: { "in": "query", "name": "data", "dataType": "any" },
|
|
1026
|
+
contextMatrixAssetId: { "in": "query", "name": "contextMatrixAssetId", "dataType": "string" },
|
|
1027
|
+
contextMatrixUrl: { "in": "query", "name": "contextMatrixUrl", "dataType": "string" }
|
|
998
1028
|
};
|
|
999
1029
|
let validatedArgs = [];
|
|
1000
1030
|
try {
|
|
@@ -1020,7 +1050,9 @@ function RegisterRoutes(app) {
|
|
|
1020
1050
|
expressRequest: { "in": "request", "name": "expressRequest", "required": true, "dataType": "object" },
|
|
1021
1051
|
componentId: { "in": "path", "name": "componentId", "required": true, "dataType": "string" },
|
|
1022
1052
|
componentSet: { "in": "query", "name": "_componentSet", "dataType": "string" },
|
|
1023
|
-
previewKey: { "in": "query", "name": "_previewKey", "dataType": "string" }
|
|
1053
|
+
previewKey: { "in": "query", "name": "_previewKey", "dataType": "string" },
|
|
1054
|
+
contextMatrixAssetId: { "in": "query", "name": "contextMatrixAssetId", "dataType": "string" },
|
|
1055
|
+
contextMatrixUrl: { "in": "query", "name": "contextMatrixUrl", "dataType": "string" }
|
|
1024
1056
|
};
|
|
1025
1057
|
let validatedArgs = [];
|
|
1026
1058
|
try {
|
|
@@ -1047,7 +1079,9 @@ function RegisterRoutes(app) {
|
|
|
1047
1079
|
componentId: { "in": "path", "name": "componentId", "required": true, "dataType": "string" },
|
|
1048
1080
|
functionName: { "in": "path", "name": "functionName", "required": true, "dataType": "string" },
|
|
1049
1081
|
componentSet: { "in": "query", "name": "_componentSet", "dataType": "string" },
|
|
1050
|
-
previewKey: { "in": "query", "name": "_previewKey", "dataType": "string" }
|
|
1082
|
+
previewKey: { "in": "query", "name": "_previewKey", "dataType": "string" },
|
|
1083
|
+
contextMatrixAssetId: { "in": "query", "name": "contextMatrixAssetId", "dataType": "string" },
|
|
1084
|
+
contextMatrixUrl: { "in": "query", "name": "contextMatrixUrl", "dataType": "string" }
|
|
1051
1085
|
};
|
|
1052
1086
|
let validatedArgs = [];
|
|
1053
1087
|
try {
|
|
@@ -1236,7 +1270,7 @@ var import_node_vm = __toESM(require("node:vm"));
|
|
|
1236
1270
|
var import_os = require("os");
|
|
1237
1271
|
var import_module = require("module");
|
|
1238
1272
|
var DevelopmentComponentRunnerService = class {
|
|
1239
|
-
async executeEdgeComponentFunction(task) {
|
|
1273
|
+
async executeEdgeComponentFunction(task, contextAwareness) {
|
|
1240
1274
|
const webRequestEvents = await this.setUpWebRequestEventForResolveUri(task);
|
|
1241
1275
|
const builtComponent = await esbuild.build({
|
|
1242
1276
|
entryPoints: [task.functionEntryFilePath],
|
|
@@ -1254,7 +1288,7 @@ var DevelopmentComponentRunnerService = class {
|
|
|
1254
1288
|
}
|
|
1255
1289
|
throw new Error("Failed to build component");
|
|
1256
1290
|
}
|
|
1257
|
-
const componentContext = this.getComponentContext(task, webRequestEvents);
|
|
1291
|
+
const componentContext = this.getComponentContext(task, webRequestEvents, contextAwareness);
|
|
1258
1292
|
const vmContext = import_node_vm.default.createContext({
|
|
1259
1293
|
...globalThis,
|
|
1260
1294
|
module: {},
|
|
@@ -1323,7 +1357,7 @@ var DevelopmentComponentRunnerService = class {
|
|
|
1323
1357
|
console.error("Error during esbuild transformation:", error);
|
|
1324
1358
|
}
|
|
1325
1359
|
}
|
|
1326
|
-
getComponentContext(task, webRequestEvents) {
|
|
1360
|
+
getComponentContext(task, webRequestEvents, contextAwareness) {
|
|
1327
1361
|
const ctxInput = {
|
|
1328
1362
|
componentName: task.componentFullName,
|
|
1329
1363
|
manifest: task.manifest,
|
|
@@ -1343,7 +1377,71 @@ var DevelopmentComponentRunnerService = class {
|
|
|
1343
1377
|
previewKey: task.previewKey,
|
|
1344
1378
|
queryParameters: task.queryParameters,
|
|
1345
1379
|
ctx: (0, import_component_lib3.createComponentContextualFunctions)(ctxInput),
|
|
1346
|
-
fns:
|
|
1380
|
+
fns: {
|
|
1381
|
+
...(0, import_component_lib3.createComponentContextualFunctions)(ctxInput),
|
|
1382
|
+
resolveMatrixAssetById: function(assetId, attributes) {
|
|
1383
|
+
const mockAsset = {
|
|
1384
|
+
id: contextAwareness?.matrixAssetId ?? assetId,
|
|
1385
|
+
type: "page",
|
|
1386
|
+
type_name: "page",
|
|
1387
|
+
version: "1.0.0",
|
|
1388
|
+
name: "Mock Asset",
|
|
1389
|
+
short_name: "page",
|
|
1390
|
+
status: {
|
|
1391
|
+
code: "archived",
|
|
1392
|
+
id: 1
|
|
1393
|
+
},
|
|
1394
|
+
created: {
|
|
1395
|
+
user_id: "123",
|
|
1396
|
+
date: "2019-08-24T14:15:22Z"
|
|
1397
|
+
},
|
|
1398
|
+
updated: {
|
|
1399
|
+
user_id: "123",
|
|
1400
|
+
date: "2019-08-24T14:15:22Z"
|
|
1401
|
+
},
|
|
1402
|
+
published: {
|
|
1403
|
+
user_id: "123",
|
|
1404
|
+
date: "2019-08-24T14:15:22Z"
|
|
1405
|
+
},
|
|
1406
|
+
url: "",
|
|
1407
|
+
urls: [],
|
|
1408
|
+
attributes,
|
|
1409
|
+
additional: []
|
|
1410
|
+
};
|
|
1411
|
+
return mockAsset;
|
|
1412
|
+
},
|
|
1413
|
+
resolveMatrixAssetByUrl: function(url, attributes) {
|
|
1414
|
+
const mockAsset = {
|
|
1415
|
+
id: contextAwareness?.matrixUrl ?? url,
|
|
1416
|
+
type: "page",
|
|
1417
|
+
type_name: "page",
|
|
1418
|
+
version: "1.0.0",
|
|
1419
|
+
name: "Mock Asset",
|
|
1420
|
+
short_name: "page",
|
|
1421
|
+
status: {
|
|
1422
|
+
code: "archived",
|
|
1423
|
+
id: 1
|
|
1424
|
+
},
|
|
1425
|
+
created: {
|
|
1426
|
+
user_id: "123",
|
|
1427
|
+
date: "2019-08-24T14:15:22Z"
|
|
1428
|
+
},
|
|
1429
|
+
updated: {
|
|
1430
|
+
user_id: "123",
|
|
1431
|
+
date: "2019-08-24T14:15:22Z"
|
|
1432
|
+
},
|
|
1433
|
+
published: {
|
|
1434
|
+
user_id: "123",
|
|
1435
|
+
date: "2019-08-24T14:15:22Z"
|
|
1436
|
+
},
|
|
1437
|
+
url,
|
|
1438
|
+
urls: [],
|
|
1439
|
+
attributes,
|
|
1440
|
+
additional: {}
|
|
1441
|
+
};
|
|
1442
|
+
return mockAsset;
|
|
1443
|
+
}
|
|
1444
|
+
},
|
|
1347
1445
|
env: task.runtimeSet.environment
|
|
1348
1446
|
};
|
|
1349
1447
|
return componentContext;
|