@squiz/db-lib 1.40.1-alpha.17 → 1.40.1-alpha.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  0 verbose cli /usr/local/bin/node /usr/local/bin/npm
2
2
  1 info using npm@9.5.0
3
3
  2 info using node@v18.15.0
4
- 3 timing npm:load:whichnode Completed in 1ms
4
+ 3 timing npm:load:whichnode Completed in 2ms
5
5
  4 timing config:load:defaults Completed in 2ms
6
6
  5 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 0ms
7
7
  6 timing config:load:builtin Completed in 1ms
@@ -9,29 +9,29 @@
9
9
  8 timing config:load:env Completed in 1ms
10
10
  9 info found workspace root at /builds/developer-experience/cmp
11
11
  10 timing config:load:file:/builds/developer-experience/cmp/.npmrc Completed in 0ms
12
- 11 timing config:load:project Completed in 26ms
12
+ 11 timing config:load:project Completed in 32ms
13
13
  12 timing config:load:file:/root/.npmrc Completed in 1ms
14
14
  13 timing config:load:user Completed in 1ms
15
- 14 timing config:load:file:/usr/local/etc/npmrc Completed in 1ms
15
+ 14 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
16
16
  15 timing config:load:global Completed in 1ms
17
17
  16 timing config:load:setEnvs Completed in 1ms
18
- 17 timing config:load Completed in 35ms
19
- 18 timing npm:load:configload Completed in 36ms
20
- 19 timing npm:load:mkdirpcache Completed in 0ms
21
- 20 timing npm:load:mkdirplogs Completed in 1ms
18
+ 17 timing config:load Completed in 43ms
19
+ 18 timing npm:load:configload Completed in 43ms
20
+ 19 timing npm:load:mkdirpcache Completed in 1ms
21
+ 20 timing npm:load:mkdirplogs Completed in 0ms
22
22
  21 verbose title npm run compile
23
23
  22 verbose argv "run" "compile" "--"
24
- 23 timing npm:load:setTitle Completed in 1ms
25
- 24 timing config:load:flatten Completed in 5ms
26
- 25 timing npm:load:display Completed in 6ms
27
- 26 verbose logfile logs-max:10 dir:/builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-07-19T01_43_48_817Z-
28
- 27 verbose logfile /builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-07-19T01_43_48_817Z-debug-0.log
24
+ 23 timing npm:load:setTitle Completed in 2ms
25
+ 24 timing config:load:flatten Completed in 4ms
26
+ 25 timing npm:load:display Completed in 5ms
27
+ 26 verbose logfile logs-max:10 dir:/builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-07-20T22_08_38_377Z-
28
+ 27 verbose logfile /builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-07-20T22_08_38_377Z-debug-0.log
29
29
  28 timing npm:load:logFile Completed in 3ms
30
30
  29 timing npm:load:timers Completed in 0ms
31
31
  30 timing npm:load:configScope Completed in 0ms
32
- 31 timing npm:load Completed in 50ms
32
+ 31 timing npm:load Completed in 58ms
33
33
  32 silly logfile done cleaning log files
34
- 33 timing command:run Completed in 3465ms
34
+ 33 timing command:run Completed in 3649ms
35
35
  34 verbose exit 0
36
- 35 timing npm Completed in 3525ms
36
+ 35 timing npm Completed in 3720ms
37
37
  36 info ok
package/lib/index.js CHANGED
@@ -20185,8 +20185,17 @@ var require_errorMiddleware = __commonJS({
20185
20185
  exports2.errorMiddleware = void 0;
20186
20186
  function errorMiddleware(error, req, res, _next) {
20187
20187
  const statusCode = error.statusCode || 500;
20188
- error.message = (error === null || error === void 0 ? void 0 : error.message) || "An error occurred with no additional information available";
20188
+ if (!error.message) {
20189
+ error.message = "An error occurred with no additional information available";
20190
+ }
20189
20191
  res = res.setHeader("cache-control", "no-cache, no-store, max-age=0");
20192
+ if (error.name === "ZodError") {
20193
+ req.log.error(`Caught validation error for ${req.path}:`, error.issues);
20194
+ return res.status(400).json({
20195
+ message: "Validation failed",
20196
+ details: error.issues
20197
+ });
20198
+ }
20190
20199
  if ((error === null || error === void 0 ? void 0 : error.name) === "ComponentError") {
20191
20200
  req.log.error({
20192
20201
  message: error,
@@ -50302,118 +50311,6 @@ var require_manifestSchemas = __commonJS({
50302
50311
  }
50303
50312
  });
50304
50313
 
50305
- // ../dx-json-schema-lib/lib/pageContents/v1/pageContents.js
50306
- var require_pageContents = __commonJS({
50307
- "../dx-json-schema-lib/lib/pageContents/v1/pageContents.js"(exports2) {
50308
- "use strict";
50309
- Object.defineProperty(exports2, "__esModule", { value: true });
50310
- }
50311
- });
50312
-
50313
- // ../dx-json-schema-lib/lib/pageContents/pageContentsModels.js
50314
- var require_pageContentsModels = __commonJS({
50315
- "../dx-json-schema-lib/lib/pageContents/pageContentsModels.js"(exports2) {
50316
- "use strict";
50317
- var __createBinding2 = exports2 && exports2.__createBinding || (Object.create ? function(o, m, k, k2) {
50318
- if (k2 === void 0)
50319
- k2 = k;
50320
- var desc = Object.getOwnPropertyDescriptor(m, k);
50321
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
50322
- desc = { enumerable: true, get: function() {
50323
- return m[k];
50324
- } };
50325
- }
50326
- Object.defineProperty(o, k2, desc);
50327
- } : function(o, m, k, k2) {
50328
- if (k2 === void 0)
50329
- k2 = k;
50330
- o[k2] = m[k];
50331
- });
50332
- var __setModuleDefault2 = exports2 && exports2.__setModuleDefault || (Object.create ? function(o, v) {
50333
- Object.defineProperty(o, "default", { enumerable: true, value: v });
50334
- } : function(o, v) {
50335
- o["default"] = v;
50336
- });
50337
- var __importStar2 = exports2 && exports2.__importStar || function(mod) {
50338
- if (mod && mod.__esModule)
50339
- return mod;
50340
- var result = {};
50341
- if (mod != null) {
50342
- for (var k in mod)
50343
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
50344
- __createBinding2(result, mod, k);
50345
- }
50346
- __setModuleDefault2(result, mod);
50347
- return result;
50348
- };
50349
- Object.defineProperty(exports2, "__esModule", { value: true });
50350
- exports2.v1 = void 0;
50351
- exports2.v1 = __importStar2(require_pageContents());
50352
- }
50353
- });
50354
-
50355
- // ../dx-json-schema-lib/lib/pageContents/v1/pageContents.json
50356
- var require_pageContents2 = __commonJS({
50357
- "../dx-json-schema-lib/lib/pageContents/v1/pageContents.json"(exports2, module2) {
50358
- module2.exports = {
50359
- $schema: "http://json-schema.org/draft-07/schema#",
50360
- type: "object",
50361
- properties: {
50362
- id: {
50363
- type: "string"
50364
- },
50365
- name: {
50366
- type: "string"
50367
- },
50368
- layouts: {
50369
- type: "array",
50370
- items: {
50371
- $ref: "#/definitions/layout"
50372
- }
50373
- }
50374
- },
50375
- required: ["name", "layouts"],
50376
- definitions: {
50377
- layout: {
50378
- type: "object",
50379
- properties: {
50380
- schemaName: {
50381
- type: "string"
50382
- },
50383
- content: {
50384
- type: "object",
50385
- properties: {
50386
- contentItemId: {
50387
- type: "string"
50388
- }
50389
- },
50390
- required: ["contentItemId"],
50391
- additionalProperties: false
50392
- }
50393
- },
50394
- required: ["schemaName", "content"],
50395
- additionalProperties: false
50396
- }
50397
- },
50398
- additionalProperties: false
50399
- };
50400
- }
50401
- });
50402
-
50403
- // ../dx-json-schema-lib/lib/pageContents/pageContentsSchemas.js
50404
- var require_pageContentsSchemas = __commonJS({
50405
- "../dx-json-schema-lib/lib/pageContents/pageContentsSchemas.js"(exports2) {
50406
- "use strict";
50407
- var __importDefault2 = exports2 && exports2.__importDefault || function(mod) {
50408
- return mod && mod.__esModule ? mod : { "default": mod };
50409
- };
50410
- Object.defineProperty(exports2, "__esModule", { value: true });
50411
- exports2.v1 = void 0;
50412
- var pageContents_json_1 = __importDefault2(require_pageContents2());
50413
- exports2.v1 = pageContents_json_1.default;
50414
- }
50415
- });
50416
-
50417
50314
  // ../dx-json-schema-lib/lib/formatted-text/v1/formattedText.js
50418
50315
  var require_formattedText = __commonJS({
50419
50316
  "../dx-json-schema-lib/lib/formatted-text/v1/formattedText.js"(exports2) {
@@ -50552,19 +50449,20 @@ var require_formattedText2 = __commonJS({
50552
50449
  additionalProperties: false,
50553
50450
  properties: {
50554
50451
  type: { const: "component" },
50555
- schemaName: { type: "string" },
50452
+ componentId: {
50453
+ type: "string"
50454
+ },
50556
50455
  componentSet: { type: "string" },
50557
- content: {
50456
+ contentItem: {
50558
50457
  type: "object",
50559
50458
  title: "ContentItemReference",
50560
50459
  properties: {
50561
- contentItemId: { type: "string" }
50460
+ id: { type: "string" }
50562
50461
  },
50563
- required: ["contentItemId"],
50564
- additionalProperties: false
50462
+ required: []
50565
50463
  }
50566
50464
  },
50567
- required: ["type", "schemaName", "componentSet"]
50465
+ required: ["type", "componentSet", "componentId"]
50568
50466
  },
50569
50467
  FormattedTextLinkToMatrixAsset: {
50570
50468
  type: "object",
@@ -56691,7 +56589,7 @@ var require_JsonValidationService = __commonJS({
56691
56589
  return mod && mod.__esModule ? mod : { "default": mod };
56692
56590
  };
56693
56591
  Object.defineProperty(exports2, "__esModule", { value: true });
56694
- exports2.JsonValidationService = exports2.JSONSchemaService = exports2.ManifestV1MetaSchema = exports2.PageContentsMetaSchema = exports2.RenderInputMetaSchema = exports2.ComponentInputMetaSchema = exports2.RenderInputSchema = exports2.ComponentInputSchema = void 0;
56592
+ exports2.JsonValidationService = exports2.JSONSchemaService = exports2.ManifestV1MetaSchema = exports2.RenderInputMetaSchema = exports2.ComponentInputMetaSchema = exports2.RenderInputSchema = exports2.ComponentInputSchema = void 0;
56695
56593
  var json_query_1 = __importDefault2(require_jsonQuery());
56696
56594
  var DxComponentInputSchema_json_1 = __importDefault2(require_DxComponentInputSchema());
56697
56595
  var DxComponentIcons_json_1 = __importDefault2(require_DxComponentIcons());
@@ -56699,7 +56597,6 @@ var require_JsonValidationService = __commonJS({
56699
56597
  var MatrixAssetSchema_json_1 = __importDefault2(require_MatrixAssetSchema());
56700
56598
  var Draft_07_json_1 = __importDefault2(require_Draft_07());
56701
56599
  var formattedText_json_1 = __importDefault2(require_formattedText2());
56702
- var pageContents_json_1 = __importDefault2(require_pageContents2());
56703
56600
  var v1_json_1 = __importDefault2(require_v12());
56704
56601
  var JobV1_json_1 = __importDefault2(require_JobV12());
56705
56602
  var SchemaValidationError_1 = require_SchemaValidationError();
@@ -56827,7 +56724,6 @@ var require_JsonValidationService = __commonJS({
56827
56724
  exports2.RenderInputMetaSchema = {
56828
56725
  root: Draft_07_json_1.default
56829
56726
  };
56830
- exports2.PageContentsMetaSchema = new json_schema_library_1.Draft07(pageContents_json_1.default, defaultConfig);
56831
56727
  exports2.ManifestV1MetaSchema = {
56832
56728
  root: v1_json_1.default,
56833
56729
  remotes: {
@@ -56943,9 +56839,6 @@ ${potentialResolutionErrors.join("\n")}`);
56943
56839
  const errors = exports2.RenderInputSchema.validate(inputValue, inputSchema);
56944
56840
  return processValidationResult(errors);
56945
56841
  }
56946
- validatePageContents(pageContents) {
56947
- return processValidationResult(exports2.PageContentsMetaSchema.validate(pageContents));
56948
- }
56949
56842
  };
56950
56843
  exports2.JsonValidationService = JsonValidationService;
56951
56844
  function processValidationResult(errors) {
@@ -57375,11 +57268,9 @@ var require_lib5 = __commonJS({
57375
57268
  __createBinding2(exports3, m, p);
57376
57269
  };
57377
57270
  Object.defineProperty(exports2, "__esModule", { value: true });
57378
- exports2.SUB_SCHEMAS = exports2.FORMATTED_TEXT_SCHEMAS = exports2.FORMATTED_TEXT_MODELS = exports2.PAGE_CONTENT_SCHEMAS = exports2.PAGE_CONTENTS_MODELS = exports2.MANIFEST_SCHEMAS = exports2.MANIFEST_MODELS = void 0;
57271
+ exports2.SUB_SCHEMAS = exports2.FORMATTED_TEXT_SCHEMAS = exports2.FORMATTED_TEXT_MODELS = exports2.MANIFEST_SCHEMAS = exports2.MANIFEST_MODELS = void 0;
57379
57272
  exports2.MANIFEST_MODELS = __importStar2(require_manifestModels());
57380
57273
  exports2.MANIFEST_SCHEMAS = __importStar2(require_manifestSchemas());
57381
- exports2.PAGE_CONTENTS_MODELS = __importStar2(require_pageContentsModels());
57382
- exports2.PAGE_CONTENT_SCHEMAS = __importStar2(require_pageContentsSchemas());
57383
57274
  exports2.FORMATTED_TEXT_MODELS = __importStar2(require_formattedTextModels());
57384
57275
  exports2.FORMATTED_TEXT_SCHEMAS = __importStar2(require_formattedTextSchemas());
57385
57276
  __exportStar2(require_resolveFormattedTextNodes(), exports2);
@@ -70725,6 +70616,7 @@ var require_formattedTextToHtmlString = __commonJS({
70725
70616
  exports2.buildFontClasses = exports2.buildAttributesString = exports2.formattedTextToHtmlString = exports2.formattedTextToHtmlStringResolvers = void 0;
70726
70617
  var dx_json_schema_lib_1 = require_lib5();
70727
70618
  var axios_1 = __importDefault2(require_axios());
70619
+ var error_1 = require_error();
70728
70620
  exports2.formattedTextToHtmlStringResolvers = {
70729
70621
  tag: async (node) => buildTagHTML(node),
70730
70622
  text: async (node) => node.value,
@@ -70808,21 +70700,20 @@ var require_formattedTextToHtmlString = __commonJS({
70808
70700
  exports2.buildFontClasses = buildFontClasses;
70809
70701
  function buildComponentRenderUrl(node) {
70810
70702
  var _a;
70811
- const [baseUrl, namespace, name, version2] = getComponentDetails(node.schemaName);
70703
+ if (node.componentId === void 0) {
70704
+ throw new error_1.InternalServerError("component node could not be resolved to html as schemaName was undefined");
70705
+ }
70706
+ if (process.env.COMPONENT_RENDER_SERVICE_URL === void 0) {
70707
+ throw new error_1.InternalServerError("component node could not be resolved as render service url was undefined");
70708
+ }
70709
+ const baseUrl = process.env.COMPONENT_RENDER_SERVICE_URL;
70812
70710
  let query = `_componentSet=${node.componentSet}`;
70813
- if ((_a = node.content) === null || _a === void 0 ? void 0 : _a.contentItemId.length) {
70814
- query = query.concat(`&_contentItemId=${node.content.contentItemId}`);
70711
+ if ((_a = node.contentItem) === null || _a === void 0 ? void 0 : _a.id) {
70712
+ query += `&_contentItemId=${node.contentItem.id}`;
70815
70713
  }
70816
- const renderUrl = `${baseUrl}/r/${namespace}/${name}/${version2}?${query}`;
70714
+ const renderUrl = `${baseUrl}/r/${node.componentId}?${query}`;
70817
70715
  return renderUrl;
70818
70716
  }
70819
- function getComponentDetails(str) {
70820
- const baseUrl = str.split("/d/")[0];
70821
- const sections = str.split("/");
70822
- const lastThreeSections = sections.slice(-3);
70823
- const [namespace, version2, name] = lastThreeSections;
70824
- return [baseUrl, namespace, version2, name];
70825
- }
70826
70717
  }
70827
70718
  });
70828
70719