@squiz/db-lib 1.33.1-alpha.4 → 1.33.1-alpha.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,37 +1,37 @@
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 2ms
4
+ 3 timing npm:load:whichnode Completed in 1ms
5
5
  4 timing config:load:defaults Completed in 2ms
6
- 5 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 1ms
7
- 6 timing config:load:builtin Completed in 1ms
6
+ 5 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 0ms
7
+ 6 timing config:load:builtin Completed in 0ms
8
8
  7 timing config:load:cli Completed in 1ms
9
- 8 timing config:load:env Completed in 1ms
9
+ 8 timing config:load:env Completed in 2ms
10
10
  9 info found workspace root at /builds/developer-experience/cmp
11
- 10 timing config:load:file:/builds/developer-experience/cmp/.npmrc Completed in 0ms
12
- 11 timing config:load:project Completed in 22ms
11
+ 10 timing config:load:file:/builds/developer-experience/cmp/.npmrc Completed in 1ms
12
+ 11 timing config:load:project Completed in 21ms
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
16
- 15 timing config:load:global Completed in 1ms
15
+ 14 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
16
+ 15 timing config:load:global Completed in 0ms
17
17
  16 timing config:load:setEnvs Completed in 1ms
18
- 17 timing config:load Completed in 31ms
18
+ 17 timing config:load Completed in 29ms
19
19
  18 timing npm:load:configload Completed in 31ms
20
20
  19 timing npm:load:mkdirpcache Completed in 0ms
21
- 20 timing npm:load:mkdirplogs 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-05-12T02_45_24_620Z-
28
- 27 verbose logfile /builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-05-12T02_45_24_620Z-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-05-15T01_10_19_239Z-
28
+ 27 verbose logfile /builds/developer-experience/cmp/packages/db-lib/.npm/_logs/2023-05-15T01_10_19_239Z-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 45ms
32
+ 31 timing npm:load Completed in 43ms
33
33
  32 silly logfile done cleaning log files
34
- 33 timing command:run Completed in 3618ms
34
+ 33 timing command:run Completed in 3406ms
35
35
  34 verbose exit 0
36
- 35 timing npm Completed in 3681ms
36
+ 35 timing npm Completed in 3462ms
37
37
  36 info ok
package/lib/index.js CHANGED
@@ -56286,6 +56286,62 @@ var require_matrixAssetValidator = __commonJS({
56286
56286
  }
56287
56287
  });
56288
56288
 
56289
+ // ../dx-json-schema-lib/lib/validators/utils/getValidationDataForMatrixUri.js
56290
+ var require_getValidationDataForMatrixUri = __commonJS({
56291
+ "../dx-json-schema-lib/lib/validators/utils/getValidationDataForMatrixUri.js"(exports2) {
56292
+ "use strict";
56293
+ Object.defineProperty(exports2, "__esModule", { value: true });
56294
+ exports2.getValidationDataForMatrixUri = void 0;
56295
+ function getValidationDataForMatrixUri(uri) {
56296
+ let validationDataMap = {};
56297
+ const [scheme, path2] = uri.split("://");
56298
+ if (scheme !== "matrix-asset") {
56299
+ const validationData = {
56300
+ message: 'Uri scheme is invalid, must match "matrix-asset"',
56301
+ data: {
56302
+ expected: "matrix-asset",
56303
+ received: scheme
56304
+ }
56305
+ };
56306
+ validationDataMap = {
56307
+ ...validationDataMap,
56308
+ scheme: validationData
56309
+ };
56310
+ }
56311
+ const [identifier, ...assetIdArray] = path2.split("/");
56312
+ const assetId = assetIdArray.join("/");
56313
+ const identifierRegex = /^[a-zA-Z0-9.-]+$/;
56314
+ if (identifierRegex.test(identifier) === false) {
56315
+ validationDataMap = {
56316
+ ...validationDataMap,
56317
+ identifier: {
56318
+ message: "Matrix Identifier has invalid format, must match /^[a-zA-Z0-9.-]+$/",
56319
+ data: {
56320
+ expected: /^[a-zA-Z0-9.-]+$/,
56321
+ received: identifier
56322
+ }
56323
+ }
56324
+ };
56325
+ }
56326
+ const assetIdRegex = /^\d+(?::.+)?$/;
56327
+ if (assetIdRegex.test(assetId) === false) {
56328
+ validationDataMap = {
56329
+ ...validationDataMap,
56330
+ assetId: {
56331
+ message: "Matrix Asset Id has invalid format, must match /^d+(?::.+)?$/",
56332
+ data: {
56333
+ expected: /^\d+(?::.+)?$/,
56334
+ received: assetId
56335
+ }
56336
+ }
56337
+ };
56338
+ }
56339
+ return Object.keys(validationDataMap).length > 0 ? validationDataMap : void 0;
56340
+ }
56341
+ exports2.getValidationDataForMatrixUri = getValidationDataForMatrixUri;
56342
+ }
56343
+ });
56344
+
56289
56345
  // ../dx-json-schema-lib/lib/validators/customFormatValidators.js
56290
56346
  var require_customFormatValidators = __commonJS({
56291
56347
  "../dx-json-schema-lib/lib/validators/customFormatValidators.js"(exports2) {
@@ -56294,10 +56350,14 @@ var require_customFormatValidators = __commonJS({
56294
56350
  exports2.customFormatValidators = void 0;
56295
56351
  var SchemaValidationError_1 = require_SchemaValidationError();
56296
56352
  var matrixAssetValidator_1 = require_matrixAssetValidator();
56353
+ var getValidationDataForMatrixUri_1 = require_getValidationDataForMatrixUri();
56297
56354
  exports2.customFormatValidators = {
56298
56355
  "matrix-asset-uri": (core, schema, value) => {
56299
56356
  if ((0, matrixAssetValidator_1.isMatrixAssetUri)(value) === false) {
56300
- throw new SchemaValidationError_1.SchemaValidationError(`value "${value}" isn't a valid matrix asset uri`);
56357
+ if (typeof value !== "string")
56358
+ throw new SchemaValidationError_1.SchemaValidationError(`matrix asset uri "${value}" isn't a string`);
56359
+ const validationData = (0, getValidationDataForMatrixUri_1.getValidationDataForMatrixUri)(value);
56360
+ throw new SchemaValidationError_1.SchemaValidationError(`matrix asset uri "${value}" isn't a valid matrix asset uri`, void 0, validationData);
56301
56361
  }
56302
56362
  return;
56303
56363
  }
@@ -56385,6 +56445,23 @@ var require_JsonValidationService = __commonJS({
56385
56445
  message: `${value} \`${data.pointer}\` does not match any schema`,
56386
56446
  data
56387
56447
  };
56448
+ },
56449
+ typeError(data) {
56450
+ let value = `${data.value}`;
56451
+ if (data.received == "object") {
56452
+ value = `Object ${JSON.stringify(data.value)}`;
56453
+ }
56454
+ if (data.received == "array") {
56455
+ value = `Array ${JSON.stringify(data.value)}`;
56456
+ }
56457
+ const expected = JSON.stringify(data.expected).replace(/"/g, "`");
56458
+ return {
56459
+ type: "error",
56460
+ name: "TypeError",
56461
+ code: "type-error",
56462
+ message: `Expected \`${value}\` (${data.received}) in \`${data.pointer}\` to be of type ${expected}`,
56463
+ data
56464
+ };
56388
56465
  }
56389
56466
  }
56390
56467
  };
@@ -56493,13 +56570,7 @@ var require_JsonValidationService = __commonJS({
56493
56570
  validateInput(input, inputSchema = this.schema.rootSchema) {
56494
56571
  inputSchema = this.schema.compileSchema(inputSchema);
56495
56572
  const errors = this.schema.validate(input, inputSchema);
56496
- return this.processValidationResult(errors);
56497
- }
56498
- processValidationResult(errors) {
56499
- if (errors.length > 0) {
56500
- throw new SchemaValidationError_1.SchemaValidationError(errors.map((a) => a.message).join(",\n"));
56501
- }
56502
- return true;
56573
+ return processValidationResult(errors);
56503
56574
  }
56504
56575
  /**
56505
56576
  * Resolve an input object by replacing all resolvable shapes with their resolved values
@@ -56543,43 +56614,43 @@ ${potentialResolutionErrors.join("\n")}`);
56543
56614
  switch (version2) {
56544
56615
  case "v1": {
56545
56616
  const validationResult = v1Schema.validate(manifest);
56546
- return this.processValidationResult(validationResult);
56617
+ return processValidationResult(validationResult);
56547
56618
  }
56548
56619
  default:
56549
56620
  throw new SchemaValidationError_1.SchemaValidationError("Invalid manifest version");
56550
56621
  }
56551
56622
  }
56552
56623
  validateContentSchema(contentSchema) {
56553
- return this.processValidationResult(exports2.ComponentInputSchema.validate(contentSchema));
56624
+ return processValidationResult(exports2.ComponentInputSchema.validate(contentSchema));
56554
56625
  }
56555
56626
  validateComponentInput(functionInputSchema, inputValue) {
56556
56627
  const inputSchema = exports2.ComponentInputSchema.compileSchema(functionInputSchema);
56557
56628
  const errors = exports2.ComponentInputSchema.validate(inputValue, inputSchema);
56558
- return this.processValidationResult(errors);
56629
+ return processValidationResult(errors);
56559
56630
  }
56560
56631
  validateRenderInput(functionInputSchema, inputValue) {
56561
56632
  const inputSchema = exports2.RenderInputSchema.compileSchema(functionInputSchema);
56562
56633
  const errors = exports2.RenderInputSchema.validate(inputValue, inputSchema);
56563
- return this.processValidationResult(errors);
56564
- }
56565
- processValidationResult(errors) {
56566
- if (errors.length > 0) {
56567
- const ValidationDataMap = errors.reduce((acc, error) => {
56568
- var _a;
56569
- const pointer = (_a = error === null || error === void 0 ? void 0 : error.data) === null || _a === void 0 ? void 0 : _a.pointer;
56570
- const validationData = {
56571
- message: error.message,
56572
- data: error.data
56573
- };
56574
- Object.keys(acc).includes(pointer) && Array.isArray(acc[pointer]) ? acc[pointer].push(validationData) : acc[pointer] = [validationData];
56575
- return acc;
56576
- }, {});
56577
- throw new SchemaValidationError_1.SchemaValidationError(errors.map((a) => a.message).join(",\n"), void 0, ValidationDataMap);
56578
- }
56579
- return true;
56634
+ return processValidationResult(errors);
56580
56635
  }
56581
56636
  };
56582
56637
  exports2.JsonValidationService = JsonValidationService;
56638
+ function processValidationResult(errors) {
56639
+ if (errors.length > 0) {
56640
+ const ValidationDataMap = errors.reduce((acc, error) => {
56641
+ var _a;
56642
+ const pointer = (_a = error === null || error === void 0 ? void 0 : error.data) === null || _a === void 0 ? void 0 : _a.pointer;
56643
+ const validationData = {
56644
+ message: error.message,
56645
+ data: error.data
56646
+ };
56647
+ Object.keys(acc).includes(pointer) && Array.isArray(acc[pointer]) ? acc[pointer].push(validationData) : acc[pointer] = [validationData];
56648
+ return acc;
56649
+ }, {});
56650
+ throw new SchemaValidationError_1.SchemaValidationError(errors.map((a) => a.message).join(",\n"), void 0, ValidationDataMap);
56651
+ }
56652
+ return true;
56653
+ }
56583
56654
  }
56584
56655
  });
56585
56656