@opra/common 1.0.0-alpha.2 → 1.0.0-alpha.3

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 (64) hide show
  1. package/browser.js +155 -78
  2. package/cjs/document/api-document.js +18 -12
  3. package/cjs/document/common/data-type-map.js +1 -1
  4. package/cjs/document/constants.js +1 -1
  5. package/cjs/document/data-type/api-field.js +1 -1
  6. package/cjs/document/data-type/complex-type.js +2 -3
  7. package/cjs/document/data-type/extended-types/base64.type.js +2 -1
  8. package/cjs/document/data-type/extended-types/date-string.type.js +6 -3
  9. package/cjs/document/data-type/extended-types/date-time-string.type.js +6 -3
  10. package/cjs/document/data-type/extended-types/date-time.type.js +6 -3
  11. package/cjs/document/data-type/extended-types/date.type.js +6 -3
  12. package/cjs/document/data-type/extended-types/email.type.js +20 -10
  13. package/cjs/document/data-type/extended-types/field-path.type.js +8 -4
  14. package/cjs/document/data-type/extended-types/filter.type.js +6 -3
  15. package/cjs/document/data-type/extended-types/object-id.type.js +2 -1
  16. package/cjs/document/data-type/extended-types/operation-result.type.js +20 -10
  17. package/cjs/document/data-type/extended-types/time.type.js +6 -3
  18. package/cjs/document/data-type/extended-types/url.type.js +2 -1
  19. package/cjs/document/data-type/extended-types/uuid.type.js +4 -2
  20. package/cjs/document/data-type/primitive-types/any.type.js +2 -1
  21. package/cjs/document/data-type/primitive-types/bigint.type.js +2 -1
  22. package/cjs/document/data-type/primitive-types/boolean.type.js +2 -1
  23. package/cjs/document/data-type/primitive-types/integer.type.js +2 -1
  24. package/cjs/document/data-type/primitive-types/null.type.js +2 -1
  25. package/cjs/document/data-type/primitive-types/number.type.js +6 -3
  26. package/cjs/document/data-type/primitive-types/object.type.js +2 -1
  27. package/cjs/document/data-type/primitive-types/string.type.js +10 -5
  28. package/cjs/document/factory/api-document.factory.js +5 -0
  29. package/cjs/document/factory/data-type.factory.js +1 -1
  30. package/cjs/document/factory/http-api.factory.js +1 -1
  31. package/esm/document/api-document.js +18 -12
  32. package/esm/document/common/data-type-map.js +1 -1
  33. package/esm/document/constants.js +1 -1
  34. package/esm/document/data-type/api-field.js +1 -1
  35. package/esm/document/data-type/complex-type.js +2 -3
  36. package/esm/document/data-type/extended-types/base64.type.js +3 -2
  37. package/esm/document/data-type/extended-types/date-string.type.js +7 -4
  38. package/esm/document/data-type/extended-types/date-time-string.type.js +7 -4
  39. package/esm/document/data-type/extended-types/date-time.type.js +7 -4
  40. package/esm/document/data-type/extended-types/date.type.js +7 -4
  41. package/esm/document/data-type/extended-types/email.type.js +21 -11
  42. package/esm/document/data-type/extended-types/field-path.type.js +9 -5
  43. package/esm/document/data-type/extended-types/filter.type.js +7 -4
  44. package/esm/document/data-type/extended-types/object-id.type.js +3 -2
  45. package/esm/document/data-type/extended-types/operation-result.type.js +21 -11
  46. package/esm/document/data-type/extended-types/time.type.js +7 -4
  47. package/esm/document/data-type/extended-types/url.type.js +3 -2
  48. package/esm/document/data-type/extended-types/uuid.type.js +5 -3
  49. package/esm/document/data-type/primitive-types/any.type.js +3 -2
  50. package/esm/document/data-type/primitive-types/bigint.type.js +3 -2
  51. package/esm/document/data-type/primitive-types/boolean.type.js +3 -2
  52. package/esm/document/data-type/primitive-types/integer.type.js +3 -2
  53. package/esm/document/data-type/primitive-types/null.type.js +3 -2
  54. package/esm/document/data-type/primitive-types/number.type.js +7 -4
  55. package/esm/document/data-type/primitive-types/object.type.js +3 -2
  56. package/esm/document/data-type/primitive-types/string.type.js +11 -6
  57. package/esm/document/factory/api-document.factory.js +4 -0
  58. package/esm/document/factory/data-type.factory.js +1 -1
  59. package/esm/document/factory/http-api.factory.js +1 -1
  60. package/package.json +2 -2
  61. package/types/document/api-document.d.ts +3 -6
  62. package/types/document/factory/api-document.factory.d.ts +1 -1
  63. package/types/schema/document.interface.d.ts +13 -1
  64. package/types/schema/index.d.ts +1 -0
package/browser.js CHANGED
@@ -147,7 +147,7 @@ var DECODER = Symbol.for("opra.type.decoder");
147
147
  var ENCODER = Symbol("opra.type.encoder");
148
148
  var DECORATOR = Symbol.for("DECORATOR");
149
149
  var BUILTIN = Symbol.for("BUILTIN");
150
- var NAMESPACE_PATTERN = /([a-z$_]\w+)(:.+)/i;
150
+ var NAMESPACE_PATTERN = /([a-z$_]\w+):(.+)/i;
151
151
  var CLASS_NAME_PATTERN = /^[a-z][\w_]*$/i;
152
152
  var EXTRACT_TYPENAME_PATTERN = /^(.*)Type(\d*)$/;
153
153
  var kDataTypeMap = Symbol.for("kDataTypeMap");
@@ -1239,7 +1239,7 @@ var ApiFieldClass = class extends DocumentElement {
1239
1239
  toJSON() {
1240
1240
  const typeName = this.type ? this.node.getDataTypeNameWithNs(this.type) : void 0;
1241
1241
  return omitUndefined({
1242
- type: this.type ? typeName ? typeName : this.type?.toJSON() : void 0,
1242
+ type: typeName ? typeName : this.type?.toJSON(),
1243
1243
  description: this.description,
1244
1244
  isArray: this.isArray,
1245
1245
  default: this.default,
@@ -1312,7 +1312,8 @@ var ComplexTypeClass = class extends ComplexTypeBase {
1312
1312
  });
1313
1313
  if (this.additionalFields) {
1314
1314
  if (this.additionalFields instanceof DataType) {
1315
- out.additionalFields = this.additionalFields[1].name ? this.additionalFields[1].name : this.additionalFields[1].toJSON();
1315
+ const typeName = this.node.getDataTypeNameWithNs(this.additionalFields);
1316
+ out.additionalFields = typeName ? typeName : this.additionalFields.toJSON();
1316
1317
  } else
1317
1318
  out.additionalFields = this.additionalFields;
1318
1319
  }
@@ -2013,7 +2014,7 @@ var DataTypeFactory = class {
2013
2014
  const fieldMeta = typeof v === "string" ? { type: v } : v;
2014
2015
  if (fieldMeta.isArray && !fieldMeta.type)
2015
2016
  return context.addError(`"type" must be defined explicitly for array fields`);
2016
- const t = await this._importDataTypeArgs(context, owner, fieldMeta.type);
2017
+ const t = await this._importDataTypeArgs(context, owner, fieldMeta.type || "any");
2017
2018
  if (!t)
2018
2019
  return;
2019
2020
  initArgs.fields[k] = {
@@ -2259,7 +2260,7 @@ var DataTypeMap = class {
2259
2260
  }
2260
2261
  get(nameOrCtor) {
2261
2262
  let name = typeof nameOrCtor === "string" ? nameOrCtor : this[kCtorMap2].get(nameOrCtor);
2262
- if (!name) {
2263
+ if (!name && typeof nameOrCtor === "function") {
2263
2264
  const metadata2 = Reflect.getMetadata(DATATYPE_METADATA, nameOrCtor);
2264
2265
  name = metadata2?.name;
2265
2266
  }
@@ -3472,7 +3473,7 @@ var HttpApiFactory = class {
3472
3473
  });
3473
3474
  }
3474
3475
  if (metadata2.requestBody) {
3475
- await context.enter(".requestBody", async () => {
3476
+ await context.enterAsync(".requestBody", async () => {
3476
3477
  const requestBody = new HttpRequestBody(operation);
3477
3478
  await this._initHttpRequestBody(context, requestBody, metadata2.requestBody);
3478
3479
  operation.requestBody = requestBody;
@@ -3600,18 +3601,29 @@ var ApiDocument = class extends DocumentElement {
3600
3601
  if (dt)
3601
3602
  return this[kTypeNSMap].get(dt);
3602
3603
  }
3604
+ findDocument(id) {
3605
+ if (this.id === id)
3606
+ return this;
3607
+ for (const doc of this.references.values()) {
3608
+ if (doc.id === id)
3609
+ return doc;
3610
+ const d = doc.findDocument(id);
3611
+ if (d)
3612
+ return d;
3613
+ }
3614
+ }
3603
3615
  toJSON() {
3604
3616
  return this.export();
3605
3617
  }
3606
3618
  /**
3607
3619
  * Export as Opra schema definition object
3608
3620
  */
3609
- export(options) {
3621
+ export() {
3610
3622
  const out = omitUndefined({
3611
3623
  spec: OpraSchema.SpecVersion,
3624
+ id: this.id,
3612
3625
  url: this.url,
3613
3626
  info: cloneObject(this.info, true)
3614
- // api: this.api ? this.api.toJSON() : undefined,
3615
3627
  });
3616
3628
  if (this.references.size) {
3617
3629
  let i = 0;
@@ -3619,15 +3631,11 @@ var ApiDocument = class extends DocumentElement {
3619
3631
  for (const [ns, doc] of this.references.entries()) {
3620
3632
  if (doc[BUILTIN])
3621
3633
  continue;
3622
- if (options?.references === "external-url") {
3623
- if (doc.url)
3624
- references[ns] = doc.url;
3625
- else
3626
- references[ns] = `/$schema?ns=${ns}`;
3627
- } else if (options?.references === "relative-url")
3628
- references[ns] = `/$schema?ns=${ns}`;
3629
- else
3630
- references[ns] = doc.export(options);
3634
+ references[ns] = {
3635
+ id: doc.id,
3636
+ url: doc.url,
3637
+ info: cloneObject(doc.info, true)
3638
+ };
3631
3639
  i++;
3632
3640
  }
3633
3641
  if (i)
@@ -3769,6 +3777,10 @@ function __decorate(decorators, target, key, desc) {
3769
3777
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3770
3778
  }
3771
3779
  __name(__decorate, "__decorate");
3780
+ function __metadata(metadataKey, metadataValue) {
3781
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
3782
+ }
3783
+ __name(__metadata, "__metadata");
3772
3784
 
3773
3785
  // ../../build/common/esm/document/data-type/primitive-types/any.type.js
3774
3786
  import { isAny as isAny2 } from "valgen";
@@ -3790,7 +3802,8 @@ var AnyType = class AnyType2 {
3790
3802
  AnyType = __decorate([
3791
3803
  SimpleType2({
3792
3804
  description: "Represents any value"
3793
- })
3805
+ }),
3806
+ __metadata("design:paramtypes", [Object])
3794
3807
  ], AnyType);
3795
3808
 
3796
3809
  // ../../build/common/esm/document/data-type/primitive-types/bigint.type.js
@@ -3821,17 +3834,20 @@ var NumberType = class NumberType2 {
3821
3834
  __decorate([
3822
3835
  SimpleType2.Attribute({
3823
3836
  description: "Determines the minimum value"
3824
- })
3837
+ }),
3838
+ __metadata("design:type", Number)
3825
3839
  ], NumberType.prototype, "minValue", void 0);
3826
3840
  __decorate([
3827
3841
  SimpleType2.Attribute({
3828
3842
  description: "Determines the maximum value"
3829
- })
3843
+ }),
3844
+ __metadata("design:type", Number)
3830
3845
  ], NumberType.prototype, "maxValue", void 0);
3831
3846
  NumberType = __decorate([
3832
3847
  SimpleType2({
3833
3848
  description: "Both Integer as well as Floating-Point numbers"
3834
- })
3849
+ }),
3850
+ __metadata("design:paramtypes", [Object])
3835
3851
  ], NumberType);
3836
3852
 
3837
3853
  // ../../build/common/esm/document/data-type/primitive-types/bigint.type.js
@@ -3857,7 +3873,8 @@ var BigintType = class BigintType2 extends NumberType {
3857
3873
  BigintType = __decorate([
3858
3874
  SimpleType2({
3859
3875
  description: "BigInt number"
3860
- })
3876
+ }),
3877
+ __metadata("design:paramtypes", [Object])
3861
3878
  ], BigintType);
3862
3879
 
3863
3880
  // ../../build/common/esm/document/data-type/primitive-types/boolean.type.js
@@ -3880,7 +3897,8 @@ var BooleanType = class BooleanType2 {
3880
3897
  BooleanType = __decorate([
3881
3898
  SimpleType2({
3882
3899
  description: "Simple true/false value"
3883
- })
3900
+ }),
3901
+ __metadata("design:paramtypes", [Object])
3884
3902
  ], BooleanType);
3885
3903
 
3886
3904
  // ../../build/common/esm/document/data-type/primitive-types/integer.type.js
@@ -3907,7 +3925,8 @@ var IntegerType = class IntegerType2 extends NumberType {
3907
3925
  IntegerType = __decorate([
3908
3926
  SimpleType2({
3909
3927
  description: "An integer number"
3910
- })
3928
+ }),
3929
+ __metadata("design:paramtypes", [Object])
3911
3930
  ], IntegerType);
3912
3931
 
3913
3932
  // ../../build/common/esm/document/data-type/primitive-types/null.type.js
@@ -3930,7 +3949,8 @@ var NullType = class NullType2 {
3930
3949
  NullType = __decorate([
3931
3950
  SimpleType2({
3932
3951
  description: "A Null value"
3933
- })
3952
+ }),
3953
+ __metadata("design:paramtypes", [Object])
3934
3954
  ], NullType);
3935
3955
 
3936
3956
  // ../../build/common/esm/document/data-type/primitive-types/object.type.js
@@ -3948,7 +3968,8 @@ ObjectType = __decorate([
3948
3968
  name: "object",
3949
3969
  description: "A non modelled object",
3950
3970
  additionalFields: true
3951
- })
3971
+ }),
3972
+ __metadata("design:paramtypes", [Object])
3952
3973
  ], ObjectType);
3953
3974
  var metadata = Reflect.getMetadata(DATATYPE_METADATA, ObjectType);
3954
3975
  metadata.ctor = Object;
@@ -3986,27 +4007,32 @@ var StringType = class StringType2 {
3986
4007
  __decorate([
3987
4008
  SimpleType2.Attribute({
3988
4009
  description: "Regex pattern to be used for validation"
3989
- })
4010
+ }),
4011
+ __metadata("design:type", Object)
3990
4012
  ], StringType.prototype, "pattern", void 0);
3991
4013
  __decorate([
3992
4014
  SimpleType2.Attribute({
3993
4015
  description: "Name of the pattern"
3994
- })
4016
+ }),
4017
+ __metadata("design:type", String)
3995
4018
  ], StringType.prototype, "patternName", void 0);
3996
4019
  __decorate([
3997
4020
  SimpleType2.Attribute({
3998
4021
  description: "Minimum number of characters"
3999
- })
4022
+ }),
4023
+ __metadata("design:type", Number)
4000
4024
  ], StringType.prototype, "minLength", void 0);
4001
4025
  __decorate([
4002
4026
  SimpleType2.Attribute({
4003
4027
  description: "Minimum number of characters"
4004
- })
4028
+ }),
4029
+ __metadata("design:type", Number)
4005
4030
  ], StringType.prototype, "maxLength", void 0);
4006
4031
  StringType = __decorate([
4007
4032
  SimpleType2({
4008
4033
  description: "A sequence of characters"
4009
- })
4034
+ }),
4035
+ __metadata("design:paramtypes", [Object])
4010
4036
  ], StringType);
4011
4037
 
4012
4038
  // ../../build/common/esm/document/data-type/extended-types/base64.type.js
@@ -4029,7 +4055,8 @@ var Base64Type = class Base64Type2 {
4029
4055
  Base64Type = __decorate([
4030
4056
  SimpleType2({
4031
4057
  description: "A stream of bytes, base64 encoded"
4032
- })
4058
+ }),
4059
+ __metadata("design:paramtypes", [Object])
4033
4060
  ], Base64Type);
4034
4061
 
4035
4062
  // ../../build/common/esm/document/data-type/extended-types/date.type.js
@@ -4072,17 +4099,20 @@ var DateType = class DateType2 {
4072
4099
  __decorate([
4073
4100
  SimpleType2.Attribute({
4074
4101
  description: "Minimum value"
4075
- })
4102
+ }),
4103
+ __metadata("design:type", String)
4076
4104
  ], DateType.prototype, "minValue", void 0);
4077
4105
  __decorate([
4078
4106
  SimpleType2.Attribute({
4079
4107
  description: "Maximum value"
4080
- })
4108
+ }),
4109
+ __metadata("design:type", String)
4081
4110
  ], DateType.prototype, "maxValue", void 0);
4082
4111
  DateType = __decorate([
4083
4112
  SimpleType2({
4084
4113
  description: "A date without time"
4085
- }).Example("2021-04-18", "Full date value")
4114
+ }).Example("2021-04-18", "Full date value"),
4115
+ __metadata("design:paramtypes", [Object])
4086
4116
  ], DateType);
4087
4117
 
4088
4118
  // ../../build/common/esm/document/data-type/extended-types/date-string.type.js
@@ -4111,17 +4141,20 @@ var DateStringType = class DateStringType2 {
4111
4141
  __decorate([
4112
4142
  SimpleType2.Attribute({
4113
4143
  description: "Minimum value"
4114
- })
4144
+ }),
4145
+ __metadata("design:type", String)
4115
4146
  ], DateStringType.prototype, "minValue", void 0);
4116
4147
  __decorate([
4117
4148
  SimpleType2.Attribute({
4118
4149
  description: "Maximum value"
4119
- })
4150
+ }),
4151
+ __metadata("design:type", String)
4120
4152
  ], DateStringType.prototype, "maxValue", void 0);
4121
4153
  DateStringType = __decorate([
4122
4154
  SimpleType2({
4123
4155
  description: "Date string value"
4124
- }).Example("2021-04-18", "Full date value").Example("2021-04", "Date value without day").Example("2021", "Year only value")
4156
+ }).Example("2021-04-18", "Full date value").Example("2021-04", "Date value without day").Example("2021", "Year only value"),
4157
+ __metadata("design:paramtypes", [Object])
4125
4158
  ], DateStringType);
4126
4159
 
4127
4160
  // ../../build/common/esm/document/data-type/extended-types/date-time.type.js
@@ -4164,17 +4197,20 @@ var DateTimeType = class DateTimeType2 {
4164
4197
  __decorate([
4165
4198
  SimpleType2.Attribute({
4166
4199
  description: "Minimum value"
4167
- })
4200
+ }),
4201
+ __metadata("design:type", String)
4168
4202
  ], DateTimeType.prototype, "minValue", void 0);
4169
4203
  __decorate([
4170
4204
  SimpleType2.Attribute({
4171
4205
  description: "Maximum value"
4172
- })
4206
+ }),
4207
+ __metadata("design:type", String)
4173
4208
  ], DateTimeType.prototype, "maxValue", void 0);
4174
4209
  DateTimeType = __decorate([
4175
4210
  SimpleType2({
4176
4211
  description: "A full datetime value"
4177
- }).Example("2021-04-18T22:30:15").Example("2021-04-18 22:30:15").Example("2021-04-18 22:30")
4212
+ }).Example("2021-04-18T22:30:15").Example("2021-04-18 22:30:15").Example("2021-04-18 22:30"),
4213
+ __metadata("design:paramtypes", [Object])
4178
4214
  ], DateTimeType);
4179
4215
 
4180
4216
  // ../../build/common/esm/document/data-type/extended-types/date-time-string.type.js
@@ -4203,17 +4239,20 @@ var DateTimeStringType = class DateTimeStringType2 {
4203
4239
  __decorate([
4204
4240
  SimpleType2.Attribute({
4205
4241
  description: "Minimum value"
4206
- })
4242
+ }),
4243
+ __metadata("design:type", String)
4207
4244
  ], DateTimeStringType.prototype, "minValue", void 0);
4208
4245
  __decorate([
4209
4246
  SimpleType2.Attribute({
4210
4247
  description: "Maximum value"
4211
- })
4248
+ }),
4249
+ __metadata("design:type", String)
4212
4250
  ], DateTimeStringType.prototype, "maxValue", void 0);
4213
4251
  DateTimeStringType = __decorate([
4214
4252
  SimpleType2({
4215
4253
  description: "DateTime string value"
4216
- }).Example("2021-04-18T22:30:15+01:00", "Full date-time value with timezone").Example("2021-04-18T22:30:15", "Full date-time value without timezone").Example("2021-04-18 22:30", "Date-time value").Example("2021-04-18", "Date value").Example("2021-04", "Date value without day").Example("2021", "Year only value")
4254
+ }).Example("2021-04-18T22:30:15+01:00", "Full date-time value with timezone").Example("2021-04-18T22:30:15", "Full date-time value without timezone").Example("2021-04-18 22:30", "Date-time value").Example("2021-04-18", "Date value").Example("2021-04", "Date value without day").Example("2021", "Year only value"),
4255
+ __metadata("design:paramtypes", [Object])
4217
4256
  ], DateTimeStringType);
4218
4257
 
4219
4258
  // ../../build/common/esm/document/data-type/extended-types/email.type.js
@@ -4237,57 +4276,67 @@ __decorate([
4237
4276
  SimpleType2.Attribute({
4238
4277
  description: "If set to `true`, the validator will also match `Display Name <email-address>",
4239
4278
  default: false
4240
- })
4279
+ }),
4280
+ __metadata("design:type", Boolean)
4241
4281
  ], EmailType.prototype, "allowDisplayName", void 0);
4242
4282
  __decorate([
4243
4283
  SimpleType2.Attribute({
4244
4284
  description: "If set to `true`, the validator will reject strings without the format `Display Name <email-address>",
4245
4285
  default: false
4246
- })
4286
+ }),
4287
+ __metadata("design:type", Boolean)
4247
4288
  ], EmailType.prototype, "requireDisplayName", void 0);
4248
4289
  __decorate([
4249
4290
  SimpleType2.Attribute({
4250
4291
  description: "If set to `false`, the validator will not allow any non-English UTF8 character in email address's local part",
4251
4292
  default: true
4252
- })
4293
+ }),
4294
+ __metadata("design:type", Boolean)
4253
4295
  ], EmailType.prototype, "utf8LocalPart", void 0);
4254
4296
  __decorate([
4255
4297
  SimpleType2.Attribute({
4256
4298
  description: "If set to `true`, the validator will not check for the standard max length of an email",
4257
4299
  default: false
4258
- })
4300
+ }),
4301
+ __metadata("design:type", Boolean)
4259
4302
  ], EmailType.prototype, "ignoreMaxLength", void 0);
4260
4303
  __decorate([
4261
4304
  SimpleType2.Attribute({
4262
4305
  description: "If set to `true`, the validator will allow IP addresses in the host part",
4263
4306
  default: false
4264
- })
4307
+ }),
4308
+ __metadata("design:type", Boolean)
4265
4309
  ], EmailType.prototype, "allowIpDomain", void 0);
4266
4310
  __decorate([
4267
4311
  SimpleType2.Attribute({
4268
4312
  description: "If set to `true`, some additional validation will be enabled, e.g. disallowing certain syntactically valid email addresses that are rejected by GMail.",
4269
4313
  default: false
4270
- })
4314
+ }),
4315
+ __metadata("design:type", Boolean)
4271
4316
  ], EmailType.prototype, "domainSpecificValidation", void 0);
4272
4317
  __decorate([
4273
4318
  SimpleType2.Attribute({
4274
4319
  description: "If set to an array of strings and the part of the email after the @ symbol one of the strings defined in it, the validation fails."
4275
- })
4320
+ }),
4321
+ __metadata("design:type", Array)
4276
4322
  ], EmailType.prototype, "hostBlacklist", void 0);
4277
4323
  __decorate([
4278
4324
  SimpleType2.Attribute({
4279
4325
  description: "If set to an array of strings and the part of the email after the @ symbol matches none of the strings defined in it, the validation fails."
4280
- })
4326
+ }),
4327
+ __metadata("design:type", Array)
4281
4328
  ], EmailType.prototype, "hostWhitelist", void 0);
4282
4329
  __decorate([
4283
4330
  SimpleType2.Attribute({
4284
4331
  description: "If set to a string, then the validator will reject emails that include any of the characters in the string, in the name part."
4285
- })
4332
+ }),
4333
+ __metadata("design:type", String)
4286
4334
  ], EmailType.prototype, "blacklistedChars", void 0);
4287
4335
  EmailType = __decorate([
4288
4336
  SimpleType2({
4289
4337
  description: "An email value"
4290
- }).Example("some.body@example.com")
4338
+ }).Example("some.body@example.com"),
4339
+ __metadata("design:paramtypes", [Object])
4291
4340
  ], EmailType);
4292
4341
 
4293
4342
  // ../../build/common/esm/document/data-type/extended-types/field-path.type.js
@@ -4313,8 +4362,9 @@ var FieldPathType = class FieldPathType2 {
4313
4362
  }
4314
4363
  toJSON(properties, element) {
4315
4364
  const dataType = properties.dataType ? element.node.getComplexType(properties.dataType) : element.node.getComplexType("object");
4365
+ const typeName = dataType ? element.node.getDataTypeNameWithNs(dataType) : void 0;
4316
4366
  return {
4317
- dataType: dataType.name ? dataType.name : dataType.toJSON(),
4367
+ dataType: typeName ? typeName : dataType.toJSON(),
4318
4368
  allowSigns: properties.allowSigns
4319
4369
  };
4320
4370
  }
@@ -4322,17 +4372,20 @@ var FieldPathType = class FieldPathType2 {
4322
4372
  __decorate([
4323
4373
  SimpleType2.Attribute({
4324
4374
  description: "Data type which field belong to"
4325
- })
4375
+ }),
4376
+ __metadata("design:type", Object)
4326
4377
  ], FieldPathType.prototype, "dataType", void 0);
4327
4378
  __decorate([
4328
4379
  SimpleType2.Attribute({
4329
4380
  description: 'Determines if signs (+,-) are allowed. If set "first" signs are allowed only beginning of the field pathIf set "each" signs are allowed at each field in the path'
4330
- })
4381
+ }),
4382
+ __metadata("design:type", String)
4331
4383
  ], FieldPathType.prototype, "allowSigns", void 0);
4332
4384
  FieldPathType = __decorate([
4333
4385
  SimpleType2({
4334
4386
  description: "Field path"
4335
- })
4387
+ }),
4388
+ __metadata("design:paramtypes", [Object])
4336
4389
  ], FieldPathType);
4337
4390
 
4338
4391
  // ../../build/common/esm/document/data-type/extended-types/filter.type.js
@@ -12237,18 +12290,21 @@ var FilterType = class FilterType2 {
12237
12290
  __decorate([
12238
12291
  SimpleType2.Attribute({
12239
12292
  description: "Data type which filtering fields belong to"
12240
- })
12293
+ }),
12294
+ __metadata("design:type", Object)
12241
12295
  ], FilterType.prototype, "dataType", void 0);
12242
12296
  __decorate([
12243
12297
  SimpleType2.Attribute({
12244
12298
  description: "Stringified JSON object defines filtering rules",
12245
12299
  format: "string"
12246
- })
12300
+ }),
12301
+ __metadata("design:type", Object)
12247
12302
  ], FilterType.prototype, "rules", void 0);
12248
12303
  FilterType = __decorate([
12249
12304
  SimpleType2({
12250
12305
  description: "A query filter"
12251
- })
12306
+ }),
12307
+ __metadata("design:paramtypes", [Object])
12252
12308
  ], FilterType);
12253
12309
  var decodeFilter = /* @__PURE__ */ __name((dataType, rules) => {
12254
12310
  return validator3("decodeFilter", function(input, context, _this) {
@@ -12293,7 +12349,8 @@ var ObjectIdType = class ObjectIdType2 {
12293
12349
  ObjectIdType = __decorate([
12294
12350
  SimpleType2({
12295
12351
  description: "A MongoDB ObjectID value"
12296
- })
12352
+ }),
12353
+ __metadata("design:paramtypes", [Object])
12297
12354
  ], ObjectIdType);
12298
12355
 
12299
12356
  // ../../build/common/esm/document/data-type/extended-types/operation-result.type.js
@@ -12307,30 +12364,38 @@ var OperationResult = class OperationResult2 {
12307
12364
  }
12308
12365
  };
12309
12366
  __decorate([
12310
- ApiField()
12367
+ ApiField(),
12368
+ __metadata("design:type", Number)
12311
12369
  ], OperationResult.prototype, "affected", void 0);
12312
12370
  __decorate([
12313
- ApiField()
12371
+ ApiField(),
12372
+ __metadata("design:type", Number)
12314
12373
  ], OperationResult.prototype, "totalMatches", void 0);
12315
12374
  __decorate([
12316
- ApiField()
12375
+ ApiField(),
12376
+ __metadata("design:type", String)
12317
12377
  ], OperationResult.prototype, "context", void 0);
12318
12378
  __decorate([
12319
- ApiField()
12379
+ ApiField(),
12380
+ __metadata("design:type", String)
12320
12381
  ], OperationResult.prototype, "type", void 0);
12321
12382
  __decorate([
12322
- ApiField()
12383
+ ApiField(),
12384
+ __metadata("design:type", String)
12323
12385
  ], OperationResult.prototype, "message", void 0);
12324
12386
  __decorate([
12325
- ApiField({ type: "any" })
12387
+ ApiField({ type: "any" }),
12388
+ __metadata("design:type", Object)
12326
12389
  ], OperationResult.prototype, "payload", void 0);
12327
12390
  __decorate([
12328
- ApiField({ type: "object" })
12391
+ ApiField({ type: "object" }),
12392
+ __metadata("design:type", Array)
12329
12393
  ], OperationResult.prototype, "errors", void 0);
12330
12394
  OperationResult = __decorate([
12331
12395
  ComplexType2({
12332
12396
  description: "Operation result"
12333
- })
12397
+ }),
12398
+ __metadata("design:paramtypes", [Object])
12334
12399
  ], OperationResult);
12335
12400
  (function(OperationResult3) {
12336
12401
  function forPayload(type) {
@@ -12343,10 +12408,12 @@ OperationResult = __decorate([
12343
12408
  }
12344
12409
  };
12345
12410
  __decorate([
12346
- ApiField({ type, required: true })
12411
+ ApiField({ type, required: true }),
12412
+ __metadata("design:type", Object)
12347
12413
  ], OperationResult_.prototype, "payload", void 0);
12348
12414
  OperationResult_ = __decorate([
12349
- ComplexType2({ embedded: true })
12415
+ ComplexType2({ embedded: true }),
12416
+ __metadata("design:paramtypes", [Object])
12350
12417
  ], OperationResult_);
12351
12418
  return OperationResult_;
12352
12419
  }
@@ -12384,17 +12451,20 @@ var TimeType = class TimeType2 {
12384
12451
  __decorate([
12385
12452
  SimpleType2.Attribute({
12386
12453
  description: "Minimum value"
12387
- })
12454
+ }),
12455
+ __metadata("design:type", String)
12388
12456
  ], TimeType.prototype, "minValue", void 0);
12389
12457
  __decorate([
12390
12458
  SimpleType2.Attribute({
12391
12459
  description: "Maximum value"
12392
- })
12460
+ }),
12461
+ __metadata("design:type", String)
12393
12462
  ], TimeType.prototype, "maxValue", void 0);
12394
12463
  TimeType = __decorate([
12395
12464
  SimpleType2({
12396
12465
  description: "Time string in 24h format"
12397
- }).Example("18:23:00", "Full time value").Example("18:23:00", "Time value without seconds")
12466
+ }).Example("18:23:00", "Full time value").Example("18:23:00", "Time value without seconds"),
12467
+ __metadata("design:paramtypes", [Object])
12398
12468
  ], TimeType);
12399
12469
 
12400
12470
  // ../../build/common/esm/document/data-type/extended-types/url.type.js
@@ -12417,7 +12487,8 @@ var UrlType = class UrlType2 {
12417
12487
  UrlType = __decorate([
12418
12488
  SimpleType2({
12419
12489
  description: "A Uniform Resource Identifier Reference (RFC 3986 icon) value"
12420
- }).Example("http://tempuri.org")
12490
+ }).Example("http://tempuri.org"),
12491
+ __metadata("design:paramtypes", [Object])
12421
12492
  ], UrlType);
12422
12493
 
12423
12494
  // ../../build/common/esm/document/data-type/extended-types/uuid.type.js
@@ -12440,12 +12511,14 @@ var UuidType = class UuidType2 {
12440
12511
  __decorate([
12441
12512
  SimpleType2.Attribute({
12442
12513
  description: "Version of the UUID"
12443
- })
12514
+ }),
12515
+ __metadata("design:type", Number)
12444
12516
  ], UuidType.prototype, "version", void 0);
12445
12517
  UuidType = __decorate([
12446
12518
  SimpleType2({
12447
12519
  description: "A Universal Unique Identifier (UUID) value"
12448
- })
12520
+ }),
12521
+ __metadata("design:paramtypes", [Object])
12449
12522
  ], UuidType);
12450
12523
 
12451
12524
  // ../../build/common/esm/document/decorators/http-operation-entity.decorator.js
@@ -12825,6 +12898,8 @@ function getDataTypeName(typ) {
12825
12898
  __name(getDataTypeName, "getDataTypeName");
12826
12899
 
12827
12900
  // ../../build/common/esm/document/factory/api-document.factory.js
12901
+ import crypto from "node:crypto";
12902
+ import { asMutable as asMutable15 } from "ts-gems";
12828
12903
  var OPRA_SPEC_URL = "https://oprajs.com/spec/v" + OpraSchema.SpecVersion;
12829
12904
  var ApiDocumentFactory = class _ApiDocumentFactory {
12830
12905
  static {
@@ -12920,6 +12995,8 @@ var ApiDocumentFactory = class _ApiDocumentFactory {
12920
12995
  context.addError(`Unknown service protocol (${init.api.protocol})`);
12921
12996
  });
12922
12997
  }
12998
+ const x = document.export();
12999
+ asMutable15(document).id = crypto.createHash("md5").update(JSON.stringify(x)).digest("base64url");
12923
13000
  }
12924
13001
  /**
12925
13002
  *
@@ -30,18 +30,29 @@ class ApiDocument extends document_element_js_1.DocumentElement {
30
30
  if (dt)
31
31
  return this[constants_js_1.kTypeNSMap].get(dt);
32
32
  }
33
+ findDocument(id) {
34
+ if (this.id === id)
35
+ return this;
36
+ for (const doc of this.references.values()) {
37
+ if (doc.id === id)
38
+ return doc;
39
+ const d = doc.findDocument(id);
40
+ if (d)
41
+ return d;
42
+ }
43
+ }
33
44
  toJSON() {
34
45
  return this.export();
35
46
  }
36
47
  /**
37
48
  * Export as Opra schema definition object
38
49
  */
39
- export(options) {
50
+ export() {
40
51
  const out = (0, index_js_1.omitUndefined)({
41
52
  spec: index_js_2.OpraSchema.SpecVersion,
53
+ id: this.id,
42
54
  url: this.url,
43
55
  info: (0, index_js_1.cloneObject)(this.info, true),
44
- // api: this.api ? this.api.toJSON() : undefined,
45
56
  });
46
57
  if (this.references.size) {
47
58
  let i = 0;
@@ -49,16 +60,11 @@ class ApiDocument extends document_element_js_1.DocumentElement {
49
60
  for (const [ns, doc] of this.references.entries()) {
50
61
  if (doc[constants_js_1.BUILTIN])
51
62
  continue;
52
- if (options?.references === 'external-url') {
53
- if (doc.url)
54
- references[ns] = doc.url;
55
- else
56
- references[ns] = `/$schema?ns=${ns}`;
57
- }
58
- else if (options?.references === 'relative-url')
59
- references[ns] = `/$schema?ns=${ns}`;
60
- else
61
- references[ns] = doc.export(options);
63
+ references[ns] = {
64
+ id: doc.id,
65
+ url: doc.url,
66
+ info: (0, index_js_1.cloneObject)(doc.info, true),
67
+ };
62
68
  i++;
63
69
  }
64
70
  if (i)
@@ -23,7 +23,7 @@ class DataTypeMap {
23
23
  }
24
24
  get(nameOrCtor) {
25
25
  let name = typeof nameOrCtor === 'string' ? nameOrCtor : this[kCtorMap].get(nameOrCtor);
26
- if (!name) {
26
+ if (!name && typeof nameOrCtor === 'function') {
27
27
  const metadata = Reflect.getMetadata(constants_js_1.DATATYPE_METADATA, nameOrCtor);
28
28
  name = metadata?.name;
29
29
  }