@opra/common 0.31.2 → 0.31.4

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.
Files changed (55) hide show
  1. package/browser.js +144 -106
  2. package/cjs/document/data-type/builtin/any.type.js +2 -1
  3. package/cjs/document/data-type/builtin/approx-date.type.js +21 -0
  4. package/cjs/document/data-type/builtin/approx-datetime.type.js +24 -0
  5. package/cjs/document/data-type/builtin/base64.type.js +2 -1
  6. package/cjs/document/data-type/builtin/bigint.type.js +2 -1
  7. package/cjs/document/data-type/builtin/boolean.type.js +2 -1
  8. package/cjs/document/data-type/builtin/date.type.js +6 -11
  9. package/cjs/document/data-type/builtin/datetime.type.js +21 -0
  10. package/cjs/document/data-type/builtin/index.js +3 -1
  11. package/cjs/document/data-type/builtin/integer.type.js +2 -1
  12. package/cjs/document/data-type/builtin/null.type.js +2 -1
  13. package/cjs/document/data-type/builtin/number.type.js +2 -1
  14. package/cjs/document/data-type/builtin/object-id.type.js +2 -1
  15. package/cjs/document/data-type/builtin/object.type.js +2 -1
  16. package/cjs/document/data-type/builtin/string.type.js +2 -1
  17. package/cjs/document/data-type/builtin/time.type.js +7 -4
  18. package/cjs/document/data-type/builtin/uuid.type.js +2 -1
  19. package/cjs/document/data-type/field-class.js +2 -3
  20. package/cjs/document/factory/type-document-factory.js +3 -6
  21. package/cjs/document/resource/types/operation-result.type.js +2 -1
  22. package/cjs/document/type-document.js +1 -1
  23. package/esm/document/data-type/builtin/any.type.js +2 -1
  24. package/esm/document/data-type/builtin/approx-date.type.js +18 -0
  25. package/esm/document/data-type/builtin/approx-datetime.type.js +21 -0
  26. package/esm/document/data-type/builtin/base64.type.js +2 -1
  27. package/esm/document/data-type/builtin/bigint.type.js +2 -1
  28. package/esm/document/data-type/builtin/boolean.type.js +2 -1
  29. package/esm/document/data-type/builtin/date.type.js +6 -11
  30. package/esm/document/data-type/builtin/datetime.type.js +18 -0
  31. package/esm/document/data-type/builtin/index.js +3 -1
  32. package/esm/document/data-type/builtin/integer.type.js +2 -1
  33. package/esm/document/data-type/builtin/null.type.js +2 -1
  34. package/esm/document/data-type/builtin/number.type.js +2 -1
  35. package/esm/document/data-type/builtin/object-id.type.js +2 -1
  36. package/esm/document/data-type/builtin/object.type.js +2 -1
  37. package/esm/document/data-type/builtin/string.type.js +2 -1
  38. package/esm/document/data-type/builtin/time.type.js +8 -5
  39. package/esm/document/data-type/builtin/uuid.type.js +2 -1
  40. package/esm/document/data-type/field-class.js +2 -3
  41. package/esm/document/factory/type-document-factory.js +4 -7
  42. package/esm/document/resource/types/operation-result.type.js +2 -1
  43. package/esm/document/type-document.js +1 -1
  44. package/package.json +5 -5
  45. package/types/document/data-type/builtin/approx-date.type.d.ts +2 -0
  46. package/types/document/data-type/builtin/approx-datetime.type.d.ts +2 -0
  47. package/types/document/data-type/builtin/datetime.type.d.ts +2 -0
  48. package/types/document/data-type/builtin/index.d.ts +3 -1
  49. package/types/document/data-type/data-type.d.ts +2 -0
  50. package/types/document/data-type/field-class.d.ts +2 -1
  51. package/types/document/data-type/field.d.ts +1 -0
  52. package/types/schema/data-type/field.interface.d.ts +0 -4
  53. package/cjs/document/data-type/builtin/timestamp.type.js +0 -17
  54. package/esm/document/data-type/builtin/timestamp.type.js +0 -14
  55. package/types/document/data-type/builtin/timestamp.type.d.ts +0 -2
package/browser.js CHANGED
@@ -1422,13 +1422,13 @@ var FieldClass = class {
1422
1422
  this.owner = owner;
1423
1423
  this.origin = init.origin || owner;
1424
1424
  this.type = init.type;
1425
+ this.designType = init.designType;
1425
1426
  this.name = init.name;
1426
1427
  this.description = init.description;
1427
1428
  this.isArray = init.isArray;
1428
1429
  this.default = init.default;
1429
1430
  this.fixed = init.fixed;
1430
1431
  this.required = init.required;
1431
- this.nullish = init.nullish;
1432
1432
  this.readonly = init.readonly;
1433
1433
  this.writeonly = init.writeonly;
1434
1434
  this.exclusive = init.exclusive;
@@ -1445,7 +1445,6 @@ var FieldClass = class {
1445
1445
  default: this.default,
1446
1446
  fixed: this.fixed,
1447
1447
  required: this.required,
1448
- nullish: this.nullish,
1449
1448
  readonly: this.readonly,
1450
1449
  writeonly: this.writeonly,
1451
1450
  exclusive: this.exclusive,
@@ -1459,7 +1458,7 @@ var FieldClass = class {
1459
1458
  return vg3.isUndefined();
1460
1459
  if (options?.operation === "write" && this.readonly)
1461
1460
  return vg3.isUndefined();
1462
- let fn = this.type.generateCodec(codec, options);
1461
+ let fn = this.type.generateCodec(codec, { ...options, designType: this.designType });
1463
1462
  if (this.isArray)
1464
1463
  fn = vg3.isArray(fn);
1465
1464
  return !options?.partial && this.required ? vg3.required(fn) : vg3.optional(fn);
@@ -1819,7 +1818,7 @@ var TypeDocument = class extends DocumentBase {
1819
1818
  this._designCtorMap.set(Number, "number");
1820
1819
  this._designCtorMap.set(Boolean, "boolean");
1821
1820
  this._designCtorMap.set(Object, "any");
1822
- this._designCtorMap.set(Date, "timestamp");
1821
+ this._designCtorMap.set(Date, "datetime");
1823
1822
  this._designCtorMap.set(BigIntConstructor, "bigint");
1824
1823
  this._designCtorMap.set(ArrayBuffer, "base64");
1825
1824
  this._designCtorMap.set(SharedArrayBuffer, "base64");
@@ -2108,6 +2107,49 @@ AnyType = __decorate([
2108
2107
  })
2109
2108
  ], AnyType);
2110
2109
 
2110
+ // ../../build/common/esm/document/data-type/builtin/approx-date.type.js
2111
+ import { isDateString } from "valgen";
2112
+ var ApproxDateType = class ApproxDateType2 {
2113
+ static {
2114
+ __name(this, "ApproxDateType");
2115
+ }
2116
+ };
2117
+ ApproxDateType = __decorate([
2118
+ SimpleType2({
2119
+ description: "An approximate date value",
2120
+ example: [
2121
+ "2021-04-18",
2122
+ "2021-04",
2123
+ "2021"
2124
+ ],
2125
+ decoder: isDateString({ trim: "date" }),
2126
+ encoder: isDateString({ trim: "date" })
2127
+ })
2128
+ ], ApproxDateType);
2129
+
2130
+ // ../../build/common/esm/document/data-type/builtin/approx-datetime.type.js
2131
+ import { isDateString as isDateString2 } from "valgen";
2132
+ var ApproxDatetimeType = class ApproxDatetimeType2 {
2133
+ static {
2134
+ __name(this, "ApproxDatetimeType");
2135
+ }
2136
+ };
2137
+ ApproxDatetimeType = __decorate([
2138
+ SimpleType2({
2139
+ description: "An approximate datetime value.",
2140
+ example: [
2141
+ "2021-04-18T22:30:15+01:00",
2142
+ "2021-04-18T22:30:15",
2143
+ "2021-04-18 22:30",
2144
+ "2021-04-18",
2145
+ "2021-04",
2146
+ "2021"
2147
+ ],
2148
+ decoder: isDateString2(),
2149
+ encoder: isDateString2()
2150
+ })
2151
+ ], ApproxDatetimeType);
2152
+
2111
2153
  // ../../build/common/esm/document/data-type/builtin/base64.type.js
2112
2154
  import { isBase64 } from "valgen";
2113
2155
  var Base64Type = class Base64Type2 {
@@ -2154,7 +2196,7 @@ BooleanType = __decorate([
2154
2196
  ], BooleanType);
2155
2197
 
2156
2198
  // ../../build/common/esm/document/data-type/builtin/date.type.js
2157
- import { isDate, isDateString } from "valgen";
2199
+ import { isDate, isDateString as isDateString3 } from "valgen";
2158
2200
  var DateType = class DateType2 {
2159
2201
  static {
2160
2202
  __name(this, "DateType");
@@ -2162,21 +2204,33 @@ var DateType = class DateType2 {
2162
2204
  };
2163
2205
  DateType = __decorate([
2164
2206
  SimpleType2({
2165
- description: "Date only string, for example, 2021-04-18",
2166
- decoder: isDate({
2167
- format: [
2168
- "YYYY-MM-DD",
2169
- "YYYY",
2170
- "YYYY-MM-DDTHH:mm:ss",
2171
- "YYYY-MM-DDTHH:mm",
2172
- "YYYY-MM-DD HH:mm:ss",
2173
- "YYYY-MM-DD HH:mm"
2174
- ]
2175
- }),
2176
- encoder: isDateString({ format: "YYYY-MM-DD" })
2207
+ description: "A date without time",
2208
+ example: ["2021-04-18"],
2209
+ decoder: isDate({ precision: "date" }),
2210
+ encoder: isDateString3({ precision: "date", trim: "date" })
2177
2211
  })
2178
2212
  ], DateType);
2179
2213
 
2214
+ // ../../build/common/esm/document/data-type/builtin/datetime.type.js
2215
+ import { isDate as isDate2, isDateString as isDateString4 } from "valgen";
2216
+ var DatetimeType = class DatetimeType2 {
2217
+ static {
2218
+ __name(this, "DatetimeType");
2219
+ }
2220
+ };
2221
+ DatetimeType = __decorate([
2222
+ SimpleType2({
2223
+ description: "A full datetime value",
2224
+ example: [
2225
+ "2021-04-18T22:30:15",
2226
+ "2021-04-18 22:30:15",
2227
+ "2021-04-18 22:30"
2228
+ ],
2229
+ decoder: isDate2({ precision: "time" }),
2230
+ encoder: isDateString4({ precision: "time", trim: "time" })
2231
+ })
2232
+ ], DatetimeType);
2233
+
2180
2234
  // ../../build/common/esm/document/data-type/builtin/uuid.type.js
2181
2235
  import { isUUID } from "valgen";
2182
2236
  var UuidType = class UuidType2 {
@@ -2283,7 +2337,8 @@ StringType = __decorate([
2283
2337
  ], StringType);
2284
2338
 
2285
2339
  // ../../build/common/esm/document/data-type/builtin/time.type.js
2286
- import { isDateString as isDateString2 } from "valgen";
2340
+ import { isMatches } from "valgen";
2341
+ var TIME_PATTERN = /^([0-1][0-9]|2[0-4]):([0-5][0-9])(?::([0-5][0-9]))?$/;
2287
2342
  var TimeType = class TimeType2 {
2288
2343
  static {
2289
2344
  __name(this, "TimeType");
@@ -2292,34 +2347,17 @@ var TimeType = class TimeType2 {
2292
2347
  TimeType = __decorate([
2293
2348
  SimpleType2({
2294
2349
  description: "Time string in 24h format, for example, 18:23:00",
2295
- decoder: isDateString2({
2296
- format: ["HH:mm:ss", "HH:mm"],
2350
+ decoder: isMatches(TIME_PATTERN, {
2351
+ formatName: "time",
2297
2352
  onFail: () => "{{label}} is not a valid time"
2298
2353
  }),
2299
- encoder: isDateString2({
2300
- format: ["HH:mm:ss", "HH:mm"],
2354
+ encoder: isMatches(TIME_PATTERN, {
2355
+ formatName: "time",
2301
2356
  onFail: () => "{{label}} is not a valid time"
2302
2357
  })
2303
2358
  })
2304
2359
  ], TimeType);
2305
2360
 
2306
- // ../../build/common/esm/document/data-type/builtin/timestamp.type.js
2307
- import { isDate as isDate2, isDateString as isDateString3 } from "valgen";
2308
- var TimestampType = class TimestampType2 {
2309
- static {
2310
- __name(this, "TimestampType");
2311
- }
2312
- };
2313
- TimestampType = __decorate([
2314
- SimpleType2({
2315
- description: "Timestamp, for example, 2021-04-18T09:12:53",
2316
- decoder: isDate2({
2317
- format: ["YYYY-MM-DDTHH:mm:ss", "YYYY-MM-DD HH:mm:ss", "YYYY-MM-DD", "YYYY"]
2318
- }),
2319
- encoder: isDateString3({ format: "YYYY-MM-DDTHH:mm:ss" })
2320
- })
2321
- ], TimestampType);
2322
-
2323
2361
  // ../../build/common/esm/document/data-type/mapped-type.js
2324
2362
  import "reflect-metadata";
2325
2363
  import merge8 from "putil-merge";
@@ -2491,66 +2529,6 @@ var MixinType2 = /* @__PURE__ */ __name(function(...args) {
2491
2529
  MixinType2.prototype = MixinTypeClass.prototype;
2492
2530
  MixinType2._applyMixin = () => void 0;
2493
2531
 
2494
- // ../../build/common/esm/document/resource/enums/metadata-mode.enum.js
2495
- var MetadataMode;
2496
- (function(MetadataMode2) {
2497
- MetadataMode2["none"] = "none";
2498
- MetadataMode2["minimal"] = "minimal";
2499
- MetadataMode2["full"] = "full";
2500
- })(MetadataMode || (MetadataMode = {}));
2501
- EnumType2(MetadataMode, {
2502
- name: "MetadataMode",
2503
- description: 'Parameter "enumeration" that controls how metadata information sent',
2504
- meanings: {
2505
- "none": "Specifies that the service will include NO metadata information in the response",
2506
- "minimal": "Specifies that the service will include ALL metadata information in the response",
2507
- "full": "Specifies that the service will include MINIMAL metadata information in the response"
2508
- }
2509
- });
2510
-
2511
- // ../../build/common/esm/document/resource/types/operation-result.type.js
2512
- var OperationResult = class OperationResult2 {
2513
- static {
2514
- __name(this, "OperationResult");
2515
- }
2516
- constructor(init) {
2517
- if (init)
2518
- Object.assign(this, init);
2519
- }
2520
- };
2521
- __decorate([
2522
- ApiField()
2523
- ], OperationResult.prototype, "context", void 0);
2524
- __decorate([
2525
- ApiField()
2526
- ], OperationResult.prototype, "contextUrl", void 0);
2527
- __decorate([
2528
- ApiField()
2529
- ], OperationResult.prototype, "type", void 0);
2530
- __decorate([
2531
- ApiField()
2532
- ], OperationResult.prototype, "typeUrl", void 0);
2533
- __decorate([
2534
- ApiField()
2535
- ], OperationResult.prototype, "affected", void 0);
2536
- __decorate([
2537
- ApiField()
2538
- ], OperationResult.prototype, "count", void 0);
2539
- __decorate([
2540
- ApiField()
2541
- ], OperationResult.prototype, "totalMatches", void 0);
2542
- __decorate([
2543
- ApiField({ type: "any" })
2544
- ], OperationResult.prototype, "payload", void 0);
2545
- __decorate([
2546
- ApiField({ type: "object" })
2547
- ], OperationResult.prototype, "errors", void 0);
2548
- OperationResult = __decorate([
2549
- ComplexType2({
2550
- description: "Operation result"
2551
- })
2552
- ], OperationResult);
2553
-
2554
2532
  // ../../build/common/esm/document/factory/type-document-factory.js
2555
2533
  var TypeDocumentFactory = class _TypeDocumentFactory {
2556
2534
  static {
@@ -2639,17 +2617,17 @@ var TypeDocumentFactory = class _TypeDocumentFactory {
2639
2617
  BigintType,
2640
2618
  BooleanType,
2641
2619
  DateType,
2642
- UuidType,
2643
2620
  IntegerType,
2644
2621
  NullType,
2645
2622
  NumberType,
2646
- ObjectType,
2647
2623
  ObjectIdType,
2624
+ ObjectType,
2625
+ ApproxDateType,
2626
+ ApproxDatetimeType,
2648
2627
  StringType,
2628
+ DatetimeType,
2649
2629
  TimeType,
2650
- TimestampType,
2651
- OperationResult,
2652
- MetadataMode
2630
+ UuidType
2653
2631
  ]
2654
2632
  };
2655
2633
  const factory = new _TypeDocumentFactory();
@@ -3200,7 +3178,7 @@ var StringLiteral = class extends Literal {
3200
3178
  };
3201
3179
 
3202
3180
  // ../../build/common/esm/filter/ast/terms/time-literal.js
3203
- var TIME_PATTERN = /^([01]\d|2[0-3]):([0-5]\d)(:[0-5]\d)?(\.(\d+))?$/;
3181
+ var TIME_PATTERN2 = /^([01]\d|2[0-3]):([0-5]\d)(:[0-5]\d)?(\.(\d+))?$/;
3204
3182
  var TimeLiteral = class extends Literal {
3205
3183
  static {
3206
3184
  __name(this, "TimeLiteral");
@@ -3211,7 +3189,7 @@ var TimeLiteral = class extends Literal {
3211
3189
  this.value = pad(value.getHours()) + ":" + pad(value.getMinutes()) + (value.getSeconds() ? ":" + pad(value.getSeconds()) : "") + (value.getMilliseconds() ? "." + pad(value.getMilliseconds()) : "");
3212
3190
  return;
3213
3191
  }
3214
- if (typeof value === "string" && TIME_PATTERN.test(value)) {
3192
+ if (typeof value === "string" && TIME_PATTERN2.test(value)) {
3215
3193
  this.value = value;
3216
3194
  return;
3217
3195
  }
@@ -11357,6 +11335,66 @@ var ApiDocumentFactory = class _ApiDocumentFactory extends TypeDocumentFactory {
11357
11335
  }
11358
11336
  };
11359
11337
 
11338
+ // ../../build/common/esm/document/resource/enums/metadata-mode.enum.js
11339
+ var MetadataMode;
11340
+ (function(MetadataMode2) {
11341
+ MetadataMode2["none"] = "none";
11342
+ MetadataMode2["minimal"] = "minimal";
11343
+ MetadataMode2["full"] = "full";
11344
+ })(MetadataMode || (MetadataMode = {}));
11345
+ EnumType2(MetadataMode, {
11346
+ name: "MetadataMode",
11347
+ description: 'Parameter "enumeration" that controls how metadata information sent',
11348
+ meanings: {
11349
+ "none": "Specifies that the service will include NO metadata information in the response",
11350
+ "minimal": "Specifies that the service will include ALL metadata information in the response",
11351
+ "full": "Specifies that the service will include MINIMAL metadata information in the response"
11352
+ }
11353
+ });
11354
+
11355
+ // ../../build/common/esm/document/resource/types/operation-result.type.js
11356
+ var OperationResult = class OperationResult2 {
11357
+ static {
11358
+ __name(this, "OperationResult");
11359
+ }
11360
+ constructor(init) {
11361
+ if (init)
11362
+ Object.assign(this, init);
11363
+ }
11364
+ };
11365
+ __decorate([
11366
+ ApiField()
11367
+ ], OperationResult.prototype, "context", void 0);
11368
+ __decorate([
11369
+ ApiField()
11370
+ ], OperationResult.prototype, "contextUrl", void 0);
11371
+ __decorate([
11372
+ ApiField()
11373
+ ], OperationResult.prototype, "type", void 0);
11374
+ __decorate([
11375
+ ApiField()
11376
+ ], OperationResult.prototype, "typeUrl", void 0);
11377
+ __decorate([
11378
+ ApiField()
11379
+ ], OperationResult.prototype, "affected", void 0);
11380
+ __decorate([
11381
+ ApiField()
11382
+ ], OperationResult.prototype, "count", void 0);
11383
+ __decorate([
11384
+ ApiField()
11385
+ ], OperationResult.prototype, "totalMatches", void 0);
11386
+ __decorate([
11387
+ ApiField({ type: "any" })
11388
+ ], OperationResult.prototype, "payload", void 0);
11389
+ __decorate([
11390
+ ApiField({ type: "object" })
11391
+ ], OperationResult.prototype, "errors", void 0);
11392
+ OperationResult = __decorate([
11393
+ ComplexType2({
11394
+ description: "Operation result"
11395
+ })
11396
+ ], OperationResult);
11397
+
11360
11398
  // ../../build/common/esm/http/opra-url.js
11361
11399
  import { splitString as splitString3, tokenize as tokenize3 } from "fast-tokenizer";
11362
11400
 
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AnyType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const simple_type_js_1 = require("../simple-type.js");
6
- let AnyType = exports.AnyType = class AnyType {
6
+ let AnyType = class AnyType {
7
7
  };
8
+ exports.AnyType = AnyType;
8
9
  exports.AnyType = AnyType = tslib_1.__decorate([
9
10
  (0, simple_type_js_1.SimpleType)({
10
11
  description: 'Represents any value'
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApproxDateType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const valgen_1 = require("valgen");
6
+ const simple_type_js_1 = require("../simple-type.js");
7
+ let ApproxDateType = class ApproxDateType {
8
+ };
9
+ exports.ApproxDateType = ApproxDateType;
10
+ exports.ApproxDateType = ApproxDateType = tslib_1.__decorate([
11
+ (0, simple_type_js_1.SimpleType)({
12
+ description: 'An approximate date value',
13
+ example: [
14
+ '2021-04-18',
15
+ '2021-04',
16
+ '2021',
17
+ ],
18
+ decoder: (0, valgen_1.isDateString)({ trim: 'date' }),
19
+ encoder: (0, valgen_1.isDateString)({ trim: 'date' })
20
+ })
21
+ ], ApproxDateType);
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApproxDatetimeType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const valgen_1 = require("valgen");
6
+ const simple_type_js_1 = require("../simple-type.js");
7
+ let ApproxDatetimeType = class ApproxDatetimeType {
8
+ };
9
+ exports.ApproxDatetimeType = ApproxDatetimeType;
10
+ exports.ApproxDatetimeType = ApproxDatetimeType = tslib_1.__decorate([
11
+ (0, simple_type_js_1.SimpleType)({
12
+ description: 'An approximate datetime value.',
13
+ example: [
14
+ '2021-04-18T22:30:15+01:00',
15
+ '2021-04-18T22:30:15',
16
+ '2021-04-18 22:30',
17
+ '2021-04-18',
18
+ '2021-04',
19
+ '2021',
20
+ ],
21
+ decoder: (0, valgen_1.isDateString)(),
22
+ encoder: (0, valgen_1.isDateString)()
23
+ })
24
+ ], ApproxDatetimeType);
@@ -4,8 +4,9 @@ exports.Base64Type = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const valgen_1 = require("valgen");
6
6
  const simple_type_js_1 = require("../simple-type.js");
7
- let Base64Type = exports.Base64Type = class Base64Type {
7
+ let Base64Type = class Base64Type {
8
8
  };
9
+ exports.Base64Type = Base64Type;
9
10
  exports.Base64Type = Base64Type = tslib_1.__decorate([
10
11
  (0, simple_type_js_1.SimpleType)({
11
12
  description: 'A stream of bytes, base64 encoded',
@@ -4,8 +4,9 @@ exports.BigintType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const valgen_1 = require("valgen");
6
6
  const simple_type_js_1 = require("../simple-type.js");
7
- let BigintType = exports.BigintType = class BigintType {
7
+ let BigintType = class BigintType {
8
8
  };
9
+ exports.BigintType = BigintType;
9
10
  exports.BigintType = BigintType = tslib_1.__decorate([
10
11
  (0, simple_type_js_1.SimpleType)({
11
12
  description: 'BigInt number',
@@ -4,8 +4,9 @@ exports.BooleanType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const valgen_1 = require("valgen");
6
6
  const simple_type_js_1 = require("../simple-type.js");
7
- let BooleanType = exports.BooleanType = class BooleanType {
7
+ let BooleanType = class BooleanType {
8
8
  };
9
+ exports.BooleanType = BooleanType;
9
10
  exports.BooleanType = BooleanType = tslib_1.__decorate([
10
11
  (0, simple_type_js_1.SimpleType)({
11
12
  description: 'Simple true/false value',
@@ -4,19 +4,14 @@ exports.DateType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const valgen_1 = require("valgen");
6
6
  const simple_type_js_1 = require("../simple-type.js");
7
- let DateType = exports.DateType = class DateType {
7
+ let DateType = class DateType {
8
8
  };
9
+ exports.DateType = DateType;
9
10
  exports.DateType = DateType = tslib_1.__decorate([
10
11
  (0, simple_type_js_1.SimpleType)({
11
- description: 'Date only string, for example, 2021-04-18',
12
- decoder: (0, valgen_1.isDate)({
13
- format: ['YYYY-MM-DD', 'YYYY',
14
- 'YYYY-MM-DDTHH:mm:ss',
15
- 'YYYY-MM-DDTHH:mm',
16
- 'YYYY-MM-DD HH:mm:ss',
17
- 'YYYY-MM-DD HH:mm'
18
- ]
19
- }),
20
- encoder: (0, valgen_1.isDateString)({ format: 'YYYY-MM-DD' })
12
+ description: 'A date without time',
13
+ example: ['2021-04-18'],
14
+ decoder: (0, valgen_1.isDate)({ precision: 'date' }),
15
+ encoder: (0, valgen_1.isDateString)({ precision: 'date', trim: 'date' })
21
16
  })
22
17
  ], DateType);
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DatetimeType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const valgen_1 = require("valgen");
6
+ const simple_type_js_1 = require("../simple-type.js");
7
+ let DatetimeType = class DatetimeType {
8
+ };
9
+ exports.DatetimeType = DatetimeType;
10
+ exports.DatetimeType = DatetimeType = tslib_1.__decorate([
11
+ (0, simple_type_js_1.SimpleType)({
12
+ description: 'A full datetime value',
13
+ example: [
14
+ '2021-04-18T22:30:15',
15
+ '2021-04-18 22:30:15',
16
+ '2021-04-18 22:30'
17
+ ],
18
+ decoder: (0, valgen_1.isDate)({ precision: 'time' }),
19
+ encoder: (0, valgen_1.isDateString)({ precision: 'time', trim: 'time' })
20
+ })
21
+ ], DatetimeType);
@@ -2,10 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./any.type.js"), exports);
5
+ tslib_1.__exportStar(require("./approx-date.type.js"), exports);
6
+ tslib_1.__exportStar(require("./approx-datetime.type.js"), exports);
5
7
  tslib_1.__exportStar(require("./base64.type.js"), exports);
6
8
  tslib_1.__exportStar(require("./bigint.type.js"), exports);
7
9
  tslib_1.__exportStar(require("./boolean.type.js"), exports);
8
10
  tslib_1.__exportStar(require("./date.type.js"), exports);
11
+ tslib_1.__exportStar(require("./datetime.type.js"), exports);
9
12
  tslib_1.__exportStar(require("./uuid.type.js"), exports);
10
13
  tslib_1.__exportStar(require("./integer.type.js"), exports);
11
14
  tslib_1.__exportStar(require("./null.type.js"), exports);
@@ -14,4 +17,3 @@ tslib_1.__exportStar(require("./object.type.js"), exports);
14
17
  tslib_1.__exportStar(require("./object-id.type.js"), exports);
15
18
  tslib_1.__exportStar(require("./string.type.js"), exports);
16
19
  tslib_1.__exportStar(require("./time.type.js"), exports);
17
- tslib_1.__exportStar(require("./timestamp.type.js"), exports);
@@ -4,8 +4,9 @@ exports.IntegerType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const valgen_1 = require("valgen");
6
6
  const simple_type_js_1 = require("../simple-type.js");
7
- let IntegerType = exports.IntegerType = class IntegerType {
7
+ let IntegerType = class IntegerType {
8
8
  };
9
+ exports.IntegerType = IntegerType;
9
10
  exports.IntegerType = IntegerType = tslib_1.__decorate([
10
11
  (0, simple_type_js_1.SimpleType)({
11
12
  description: 'An integer number',
@@ -4,8 +4,9 @@ exports.NullType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const valgen_1 = require("valgen");
6
6
  const simple_type_js_1 = require("../simple-type.js");
7
- let NullType = exports.NullType = class NullType {
7
+ let NullType = class NullType {
8
8
  };
9
+ exports.NullType = NullType;
9
10
  exports.NullType = NullType = tslib_1.__decorate([
10
11
  (0, simple_type_js_1.SimpleType)({
11
12
  description: 'A Null value',
@@ -4,8 +4,9 @@ exports.NumberType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const valgen_1 = require("valgen");
6
6
  const simple_type_js_1 = require("../simple-type.js");
7
- let NumberType = exports.NumberType = class NumberType {
7
+ let NumberType = class NumberType {
8
8
  };
9
+ exports.NumberType = NumberType;
9
10
  exports.NumberType = NumberType = tslib_1.__decorate([
10
11
  (0, simple_type_js_1.SimpleType)({
11
12
  description: 'Both Integer as well as Floating-Point numbers',
@@ -4,8 +4,9 @@ exports.ObjectIdType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const valgen_1 = require("valgen");
6
6
  const simple_type_js_1 = require("../simple-type.js");
7
- let ObjectIdType = exports.ObjectIdType = class ObjectIdType {
7
+ let ObjectIdType = class ObjectIdType {
8
8
  };
9
+ exports.ObjectIdType = ObjectIdType;
9
10
  exports.ObjectIdType = ObjectIdType = tslib_1.__decorate([
10
11
  (0, simple_type_js_1.SimpleType)({
11
12
  description: 'A MongoDB ObjectID value',
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ObjectType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const complex_type_js_1 = require("../complex-type.js");
6
- let ObjectType = exports.ObjectType = class ObjectType {
6
+ let ObjectType = class ObjectType {
7
7
  };
8
+ exports.ObjectType = ObjectType;
8
9
  exports.ObjectType = ObjectType = tslib_1.__decorate([
9
10
  (0, complex_type_js_1.ComplexType)({
10
11
  name: 'object',
@@ -4,8 +4,9 @@ exports.StringType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const valgen_1 = require("valgen");
6
6
  const simple_type_js_1 = require("../simple-type.js");
7
- let StringType = exports.StringType = class StringType {
7
+ let StringType = class StringType {
8
8
  };
9
+ exports.StringType = StringType;
9
10
  exports.StringType = StringType = tslib_1.__decorate([
10
11
  (0, simple_type_js_1.SimpleType)({
11
12
  description: 'A sequence of characters',
@@ -4,16 +4,19 @@ exports.TimeType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const valgen_1 = require("valgen");
6
6
  const simple_type_js_1 = require("../simple-type.js");
7
- let TimeType = exports.TimeType = class TimeType {
7
+ const TIME_PATTERN = /^([0-1][0-9]|2[0-4]):([0-5][0-9])(?::([0-5][0-9]))?$/;
8
+ let TimeType = class TimeType {
8
9
  };
10
+ exports.TimeType = TimeType;
9
11
  exports.TimeType = TimeType = tslib_1.__decorate([
10
12
  (0, simple_type_js_1.SimpleType)({
11
13
  description: 'Time string in 24h format, for example, 18:23:00',
12
- decoder: (0, valgen_1.isDateString)({
13
- format: ['HH:mm:ss', 'HH:mm'],
14
+ decoder: (0, valgen_1.isMatches)(TIME_PATTERN, {
15
+ formatName: 'time',
14
16
  onFail: () => '{{label}} is not a valid time'
15
17
  }),
16
- encoder: (0, valgen_1.isDateString)({ format: ['HH:mm:ss', 'HH:mm'],
18
+ encoder: (0, valgen_1.isMatches)(TIME_PATTERN, {
19
+ formatName: 'time',
17
20
  onFail: () => '{{label}} is not a valid time'
18
21
  })
19
22
  })
@@ -4,8 +4,9 @@ exports.UuidType = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const valgen_1 = require("valgen");
6
6
  const simple_type_js_1 = require("../simple-type.js");
7
- let UuidType = exports.UuidType = class UuidType {
7
+ let UuidType = class UuidType {
8
8
  };
9
+ exports.UuidType = UuidType;
9
10
  exports.UuidType = UuidType = tslib_1.__decorate([
10
11
  (0, simple_type_js_1.SimpleType)({
11
12
  description: 'A Universal Unique Identifier (UUID) value',
@@ -9,13 +9,13 @@ class FieldClass {
9
9
  this.owner = owner;
10
10
  this.origin = init.origin || owner;
11
11
  this.type = init.type;
12
+ this.designType = init.designType;
12
13
  this.name = init.name;
13
14
  this.description = init.description;
14
15
  this.isArray = init.isArray;
15
16
  this.default = init.default;
16
17
  this.fixed = init.fixed;
17
18
  this.required = init.required;
18
- this.nullish = init.nullish;
19
19
  this.readonly = init.readonly;
20
20
  this.writeonly = init.writeonly;
21
21
  this.exclusive = init.exclusive;
@@ -35,7 +35,6 @@ class FieldClass {
35
35
  default: this.default,
36
36
  fixed: this.fixed,
37
37
  required: this.required,
38
- nullish: this.nullish,
39
38
  readonly: this.readonly,
40
39
  writeonly: this.writeonly,
41
40
  exclusive: this.exclusive,
@@ -49,7 +48,7 @@ class FieldClass {
49
48
  return vg.isUndefined();
50
49
  if (options?.operation === 'write' && this.readonly)
51
50
  return vg.isUndefined();
52
- let fn = this.type.generateCodec(codec, options);
51
+ let fn = this.type.generateCodec(codec, { ...options, designType: this.designType });
53
52
  if (this.isArray)
54
53
  fn = vg.isArray(fn);
55
54
  return !options?.partial && this.required ? vg.required(fn) : vg.optional(fn);