@opra/common 0.31.1 → 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 (60) hide show
  1. package/browser.js +150 -108
  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/complex-type-class.js +2 -0
  20. package/cjs/document/data-type/data-type.js +2 -1
  21. package/cjs/document/data-type/field-class.js +7 -5
  22. package/cjs/document/factory/type-document-factory.js +3 -6
  23. package/cjs/document/resource/types/operation-result.type.js +2 -1
  24. package/cjs/document/type-document.js +1 -1
  25. package/esm/document/data-type/builtin/any.type.js +2 -1
  26. package/esm/document/data-type/builtin/approx-date.type.js +18 -0
  27. package/esm/document/data-type/builtin/approx-datetime.type.js +21 -0
  28. package/esm/document/data-type/builtin/base64.type.js +2 -1
  29. package/esm/document/data-type/builtin/bigint.type.js +2 -1
  30. package/esm/document/data-type/builtin/boolean.type.js +2 -1
  31. package/esm/document/data-type/builtin/date.type.js +6 -11
  32. package/esm/document/data-type/builtin/datetime.type.js +18 -0
  33. package/esm/document/data-type/builtin/index.js +3 -1
  34. package/esm/document/data-type/builtin/integer.type.js +2 -1
  35. package/esm/document/data-type/builtin/null.type.js +2 -1
  36. package/esm/document/data-type/builtin/number.type.js +2 -1
  37. package/esm/document/data-type/builtin/object-id.type.js +2 -1
  38. package/esm/document/data-type/builtin/object.type.js +2 -1
  39. package/esm/document/data-type/builtin/string.type.js +2 -1
  40. package/esm/document/data-type/builtin/time.type.js +8 -5
  41. package/esm/document/data-type/builtin/uuid.type.js +2 -1
  42. package/esm/document/data-type/complex-type-class.js +2 -0
  43. package/esm/document/data-type/data-type.js +2 -1
  44. package/esm/document/data-type/field-class.js +7 -5
  45. package/esm/document/factory/type-document-factory.js +4 -7
  46. package/esm/document/resource/types/operation-result.type.js +2 -1
  47. package/esm/document/type-document.js +1 -1
  48. package/package.json +5 -5
  49. package/types/document/data-type/builtin/approx-date.type.d.ts +2 -0
  50. package/types/document/data-type/builtin/approx-datetime.type.d.ts +2 -0
  51. package/types/document/data-type/builtin/datetime.type.d.ts +2 -0
  52. package/types/document/data-type/builtin/index.d.ts +3 -1
  53. package/types/document/data-type/complex-type.d.ts +2 -0
  54. package/types/document/data-type/data-type.d.ts +4 -2
  55. package/types/document/data-type/field-class.d.ts +2 -1
  56. package/types/document/data-type/field.d.ts +1 -0
  57. package/types/schema/data-type/field.interface.d.ts +0 -4
  58. package/cjs/document/data-type/builtin/timestamp.type.js +0 -17
  59. package/esm/document/data-type/builtin/timestamp.type.js +0 -14
  60. package/types/document/data-type/builtin/timestamp.type.d.ts +0 -2
package/browser.js CHANGED
@@ -1011,7 +1011,8 @@ var DataType = class _DataType {
1011
1011
  this.name = init?.name;
1012
1012
  this.own = {};
1013
1013
  this.description = init?.description;
1014
- this.isAnonymous = !this.name;
1014
+ if (!this.name)
1015
+ this.isAnonymous = true;
1015
1016
  }
1016
1017
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1017
1018
  exportSchema(options) {
@@ -1421,13 +1422,13 @@ var FieldClass = class {
1421
1422
  this.owner = owner;
1422
1423
  this.origin = init.origin || owner;
1423
1424
  this.type = init.type;
1425
+ this.designType = init.designType;
1424
1426
  this.name = init.name;
1425
1427
  this.description = init.description;
1426
1428
  this.isArray = init.isArray;
1427
1429
  this.default = init.default;
1428
1430
  this.fixed = init.fixed;
1429
1431
  this.required = init.required;
1430
- this.nullish = init.nullish;
1431
1432
  this.readonly = init.readonly;
1432
1433
  this.writeonly = init.writeonly;
1433
1434
  this.exclusive = init.exclusive;
@@ -1436,14 +1437,14 @@ var FieldClass = class {
1436
1437
  this.format = init.format;
1437
1438
  }
1438
1439
  exportSchema(options) {
1440
+ const isAnonymous = !this.type.name || this.type.kind === "ComplexType" && this.type.isAnonymous;
1439
1441
  return omitUndefined({
1440
- type: this.type ? this.type.name ? this.type.name : this.type.exportSchema(options) : void 0,
1442
+ type: this.type ? isAnonymous ? this.type.exportSchema(options) : this.type.name : void 0,
1441
1443
  description: this.description,
1442
1444
  isArray: this.isArray,
1443
1445
  default: this.default,
1444
1446
  fixed: this.fixed,
1445
1447
  required: this.required,
1446
- nullish: this.nullish,
1447
1448
  readonly: this.readonly,
1448
1449
  writeonly: this.writeonly,
1449
1450
  exclusive: this.exclusive,
@@ -1457,7 +1458,7 @@ var FieldClass = class {
1457
1458
  return vg3.isUndefined();
1458
1459
  if (options?.operation === "write" && this.readonly)
1459
1460
  return vg3.isUndefined();
1460
- let fn = this.type.generateCodec(codec, options);
1461
+ let fn = this.type.generateCodec(codec, { ...options, designType: this.designType });
1461
1462
  if (this.isArray)
1462
1463
  fn = vg3.isArray(fn);
1463
1464
  return !options?.partial && this.required ? vg3.required(fn) : vg3.optional(fn);
@@ -1516,12 +1517,14 @@ var ComplexTypeClass = class extends DataType {
1516
1517
  own.ctor = own.ctor || init.base.ctor;
1517
1518
  }
1518
1519
  own.additionalFields = init?.additionalFields;
1520
+ own.anonymous = init?.anonymous;
1519
1521
  own.fields = new ResponsiveMap();
1520
1522
  this.kind = opra_schema_ns_exports.ComplexType.Kind;
1521
1523
  this.base = init?.base;
1522
1524
  this.ctor = own.ctor || Object;
1523
1525
  this.abstract = init.abstract;
1524
1526
  this.additionalFields = own.additionalFields;
1527
+ this.isAnonymous = this.isAnonymous || init.anonymous;
1525
1528
  if (this.base?.additionalFields === true && this.additionalFields !== true)
1526
1529
  this.additionalFields = true;
1527
1530
  else if (this.base?.additionalFields === "error" && !this.additionalFields)
@@ -1815,7 +1818,7 @@ var TypeDocument = class extends DocumentBase {
1815
1818
  this._designCtorMap.set(Number, "number");
1816
1819
  this._designCtorMap.set(Boolean, "boolean");
1817
1820
  this._designCtorMap.set(Object, "any");
1818
- this._designCtorMap.set(Date, "timestamp");
1821
+ this._designCtorMap.set(Date, "datetime");
1819
1822
  this._designCtorMap.set(BigIntConstructor, "bigint");
1820
1823
  this._designCtorMap.set(ArrayBuffer, "base64");
1821
1824
  this._designCtorMap.set(SharedArrayBuffer, "base64");
@@ -2104,6 +2107,49 @@ AnyType = __decorate([
2104
2107
  })
2105
2108
  ], AnyType);
2106
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
+
2107
2153
  // ../../build/common/esm/document/data-type/builtin/base64.type.js
2108
2154
  import { isBase64 } from "valgen";
2109
2155
  var Base64Type = class Base64Type2 {
@@ -2150,7 +2196,7 @@ BooleanType = __decorate([
2150
2196
  ], BooleanType);
2151
2197
 
2152
2198
  // ../../build/common/esm/document/data-type/builtin/date.type.js
2153
- import { isDate, isDateString } from "valgen";
2199
+ import { isDate, isDateString as isDateString3 } from "valgen";
2154
2200
  var DateType = class DateType2 {
2155
2201
  static {
2156
2202
  __name(this, "DateType");
@@ -2158,21 +2204,33 @@ var DateType = class DateType2 {
2158
2204
  };
2159
2205
  DateType = __decorate([
2160
2206
  SimpleType2({
2161
- description: "Date only string, for example, 2021-04-18",
2162
- decoder: isDate({
2163
- format: [
2164
- "YYYY-MM-DD",
2165
- "YYYY",
2166
- "YYYY-MM-DDTHH:mm:ss",
2167
- "YYYY-MM-DDTHH:mm",
2168
- "YYYY-MM-DD HH:mm:ss",
2169
- "YYYY-MM-DD HH:mm"
2170
- ]
2171
- }),
2172
- 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" })
2173
2211
  })
2174
2212
  ], DateType);
2175
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
+
2176
2234
  // ../../build/common/esm/document/data-type/builtin/uuid.type.js
2177
2235
  import { isUUID } from "valgen";
2178
2236
  var UuidType = class UuidType2 {
@@ -2279,7 +2337,8 @@ StringType = __decorate([
2279
2337
  ], StringType);
2280
2338
 
2281
2339
  // ../../build/common/esm/document/data-type/builtin/time.type.js
2282
- 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]))?$/;
2283
2342
  var TimeType = class TimeType2 {
2284
2343
  static {
2285
2344
  __name(this, "TimeType");
@@ -2288,34 +2347,17 @@ var TimeType = class TimeType2 {
2288
2347
  TimeType = __decorate([
2289
2348
  SimpleType2({
2290
2349
  description: "Time string in 24h format, for example, 18:23:00",
2291
- decoder: isDateString2({
2292
- format: ["HH:mm:ss", "HH:mm"],
2350
+ decoder: isMatches(TIME_PATTERN, {
2351
+ formatName: "time",
2293
2352
  onFail: () => "{{label}} is not a valid time"
2294
2353
  }),
2295
- encoder: isDateString2({
2296
- format: ["HH:mm:ss", "HH:mm"],
2354
+ encoder: isMatches(TIME_PATTERN, {
2355
+ formatName: "time",
2297
2356
  onFail: () => "{{label}} is not a valid time"
2298
2357
  })
2299
2358
  })
2300
2359
  ], TimeType);
2301
2360
 
2302
- // ../../build/common/esm/document/data-type/builtin/timestamp.type.js
2303
- import { isDate as isDate2, isDateString as isDateString3 } from "valgen";
2304
- var TimestampType = class TimestampType2 {
2305
- static {
2306
- __name(this, "TimestampType");
2307
- }
2308
- };
2309
- TimestampType = __decorate([
2310
- SimpleType2({
2311
- description: "Timestamp, for example, 2021-04-18T09:12:53",
2312
- decoder: isDate2({
2313
- format: ["YYYY-MM-DDTHH:mm:ss", "YYYY-MM-DD HH:mm:ss", "YYYY-MM-DD", "YYYY"]
2314
- }),
2315
- encoder: isDateString3({ format: "YYYY-MM-DDTHH:mm:ss" })
2316
- })
2317
- ], TimestampType);
2318
-
2319
2361
  // ../../build/common/esm/document/data-type/mapped-type.js
2320
2362
  import "reflect-metadata";
2321
2363
  import merge8 from "putil-merge";
@@ -2487,66 +2529,6 @@ var MixinType2 = /* @__PURE__ */ __name(function(...args) {
2487
2529
  MixinType2.prototype = MixinTypeClass.prototype;
2488
2530
  MixinType2._applyMixin = () => void 0;
2489
2531
 
2490
- // ../../build/common/esm/document/resource/enums/metadata-mode.enum.js
2491
- var MetadataMode;
2492
- (function(MetadataMode2) {
2493
- MetadataMode2["none"] = "none";
2494
- MetadataMode2["minimal"] = "minimal";
2495
- MetadataMode2["full"] = "full";
2496
- })(MetadataMode || (MetadataMode = {}));
2497
- EnumType2(MetadataMode, {
2498
- name: "MetadataMode",
2499
- description: 'Parameter "enumeration" that controls how metadata information sent',
2500
- meanings: {
2501
- "none": "Specifies that the service will include NO metadata information in the response",
2502
- "minimal": "Specifies that the service will include ALL metadata information in the response",
2503
- "full": "Specifies that the service will include MINIMAL metadata information in the response"
2504
- }
2505
- });
2506
-
2507
- // ../../build/common/esm/document/resource/types/operation-result.type.js
2508
- var OperationResult = class OperationResult2 {
2509
- static {
2510
- __name(this, "OperationResult");
2511
- }
2512
- constructor(init) {
2513
- if (init)
2514
- Object.assign(this, init);
2515
- }
2516
- };
2517
- __decorate([
2518
- ApiField()
2519
- ], OperationResult.prototype, "context", void 0);
2520
- __decorate([
2521
- ApiField()
2522
- ], OperationResult.prototype, "contextUrl", void 0);
2523
- __decorate([
2524
- ApiField()
2525
- ], OperationResult.prototype, "type", void 0);
2526
- __decorate([
2527
- ApiField()
2528
- ], OperationResult.prototype, "typeUrl", void 0);
2529
- __decorate([
2530
- ApiField()
2531
- ], OperationResult.prototype, "affected", void 0);
2532
- __decorate([
2533
- ApiField()
2534
- ], OperationResult.prototype, "count", void 0);
2535
- __decorate([
2536
- ApiField()
2537
- ], OperationResult.prototype, "totalMatches", void 0);
2538
- __decorate([
2539
- ApiField({ type: "any" })
2540
- ], OperationResult.prototype, "payload", void 0);
2541
- __decorate([
2542
- ApiField({ type: "object" })
2543
- ], OperationResult.prototype, "errors", void 0);
2544
- OperationResult = __decorate([
2545
- ComplexType2({
2546
- description: "Operation result"
2547
- })
2548
- ], OperationResult);
2549
-
2550
2532
  // ../../build/common/esm/document/factory/type-document-factory.js
2551
2533
  var TypeDocumentFactory = class _TypeDocumentFactory {
2552
2534
  static {
@@ -2635,17 +2617,17 @@ var TypeDocumentFactory = class _TypeDocumentFactory {
2635
2617
  BigintType,
2636
2618
  BooleanType,
2637
2619
  DateType,
2638
- UuidType,
2639
2620
  IntegerType,
2640
2621
  NullType,
2641
2622
  NumberType,
2642
- ObjectType,
2643
2623
  ObjectIdType,
2624
+ ObjectType,
2625
+ ApproxDateType,
2626
+ ApproxDatetimeType,
2644
2627
  StringType,
2628
+ DatetimeType,
2645
2629
  TimeType,
2646
- TimestampType,
2647
- OperationResult,
2648
- MetadataMode
2630
+ UuidType
2649
2631
  ]
2650
2632
  };
2651
2633
  const factory = new _TypeDocumentFactory();
@@ -3196,7 +3178,7 @@ var StringLiteral = class extends Literal {
3196
3178
  };
3197
3179
 
3198
3180
  // ../../build/common/esm/filter/ast/terms/time-literal.js
3199
- 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+))?$/;
3200
3182
  var TimeLiteral = class extends Literal {
3201
3183
  static {
3202
3184
  __name(this, "TimeLiteral");
@@ -3207,7 +3189,7 @@ var TimeLiteral = class extends Literal {
3207
3189
  this.value = pad(value.getHours()) + ":" + pad(value.getMinutes()) + (value.getSeconds() ? ":" + pad(value.getSeconds()) : "") + (value.getMilliseconds() ? "." + pad(value.getMilliseconds()) : "");
3208
3190
  return;
3209
3191
  }
3210
- if (typeof value === "string" && TIME_PATTERN.test(value)) {
3192
+ if (typeof value === "string" && TIME_PATTERN2.test(value)) {
3211
3193
  this.value = value;
3212
3194
  return;
3213
3195
  }
@@ -11353,6 +11335,66 @@ var ApiDocumentFactory = class _ApiDocumentFactory extends TypeDocumentFactory {
11353
11335
  }
11354
11336
  };
11355
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
+
11356
11398
  // ../../build/common/esm/http/opra-url.js
11357
11399
  import { splitString as splitString3, tokenize as tokenize3 } from "fast-tokenizer";
11358
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',