@opra/common 0.31.1 → 0.31.2
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.
- package/browser.js +6 -2
- package/cjs/document/data-type/complex-type-class.js +2 -0
- package/cjs/document/data-type/data-type.js +2 -1
- package/cjs/document/data-type/field-class.js +5 -2
- package/esm/document/data-type/complex-type-class.js +2 -0
- package/esm/document/data-type/data-type.js +2 -1
- package/esm/document/data-type/field-class.js +5 -2
- package/package.json +1 -1
- package/types/document/data-type/complex-type.d.ts +2 -0
- package/types/document/data-type/data-type.d.ts +2 -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
|
-
|
|
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) {
|
|
@@ -1436,8 +1437,9 @@ 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 ?
|
|
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,
|
|
@@ -1516,12 +1518,14 @@ var ComplexTypeClass = class extends DataType {
|
|
|
1516
1518
|
own.ctor = own.ctor || init.base.ctor;
|
|
1517
1519
|
}
|
|
1518
1520
|
own.additionalFields = init?.additionalFields;
|
|
1521
|
+
own.anonymous = init?.anonymous;
|
|
1519
1522
|
own.fields = new ResponsiveMap();
|
|
1520
1523
|
this.kind = opra_schema_ns_exports.ComplexType.Kind;
|
|
1521
1524
|
this.base = init?.base;
|
|
1522
1525
|
this.ctor = own.ctor || Object;
|
|
1523
1526
|
this.abstract = init.abstract;
|
|
1524
1527
|
this.additionalFields = own.additionalFields;
|
|
1528
|
+
this.isAnonymous = this.isAnonymous || init.anonymous;
|
|
1525
1529
|
if (this.base?.additionalFields === true && this.additionalFields !== true)
|
|
1526
1530
|
this.additionalFields = true;
|
|
1527
1531
|
else if (this.base?.additionalFields === "error" && !this.additionalFields)
|
|
@@ -24,12 +24,14 @@ class ComplexTypeClass extends data_type_js_1.DataType {
|
|
|
24
24
|
own.ctor = own.ctor || init.base.ctor;
|
|
25
25
|
}
|
|
26
26
|
own.additionalFields = init?.additionalFields;
|
|
27
|
+
own.anonymous = init?.anonymous;
|
|
27
28
|
own.fields = new index_js_1.ResponsiveMap();
|
|
28
29
|
this.kind = index_js_3.OpraSchema.ComplexType.Kind;
|
|
29
30
|
this.base = init?.base;
|
|
30
31
|
this.ctor = own.ctor || Object;
|
|
31
32
|
this.abstract = init.abstract;
|
|
32
33
|
this.additionalFields = own.additionalFields;
|
|
34
|
+
this.isAnonymous = this.isAnonymous || init.anonymous;
|
|
33
35
|
if (this.base?.additionalFields === true && this.additionalFields !== true)
|
|
34
36
|
this.additionalFields = true;
|
|
35
37
|
else if (this.base?.additionalFields === 'error' && !this.additionalFields)
|
|
@@ -13,7 +13,8 @@ class DataType {
|
|
|
13
13
|
this.name = init?.name;
|
|
14
14
|
this.own = {};
|
|
15
15
|
this.description = init?.description;
|
|
16
|
-
|
|
16
|
+
if (!this.name)
|
|
17
|
+
this.isAnonymous = true;
|
|
17
18
|
}
|
|
18
19
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
19
20
|
exportSchema(options) {
|
|
@@ -24,9 +24,12 @@ class FieldClass {
|
|
|
24
24
|
this.format = init.format;
|
|
25
25
|
}
|
|
26
26
|
exportSchema(options) {
|
|
27
|
+
const isAnonymous = !this.type.name ||
|
|
28
|
+
(this.type.kind === 'ComplexType' && this.type.isAnonymous);
|
|
27
29
|
return (0, index_js_1.omitUndefined)({
|
|
28
|
-
type: this.type
|
|
29
|
-
(
|
|
30
|
+
type: this.type
|
|
31
|
+
? (isAnonymous ? this.type.exportSchema(options) : this.type.name)
|
|
32
|
+
: undefined,
|
|
30
33
|
description: this.description,
|
|
31
34
|
isArray: this.isArray,
|
|
32
35
|
default: this.default,
|
|
@@ -20,12 +20,14 @@ export class ComplexTypeClass extends DataType {
|
|
|
20
20
|
own.ctor = own.ctor || init.base.ctor;
|
|
21
21
|
}
|
|
22
22
|
own.additionalFields = init?.additionalFields;
|
|
23
|
+
own.anonymous = init?.anonymous;
|
|
23
24
|
own.fields = new ResponsiveMap();
|
|
24
25
|
this.kind = OpraSchema.ComplexType.Kind;
|
|
25
26
|
this.base = init?.base;
|
|
26
27
|
this.ctor = own.ctor || Object;
|
|
27
28
|
this.abstract = init.abstract;
|
|
28
29
|
this.additionalFields = own.additionalFields;
|
|
30
|
+
this.isAnonymous = this.isAnonymous || init.anonymous;
|
|
29
31
|
if (this.base?.additionalFields === true && this.additionalFields !== true)
|
|
30
32
|
this.additionalFields = true;
|
|
31
33
|
else if (this.base?.additionalFields === 'error' && !this.additionalFields)
|
|
@@ -10,7 +10,8 @@ export class DataType {
|
|
|
10
10
|
this.name = init?.name;
|
|
11
11
|
this.own = {};
|
|
12
12
|
this.description = init?.description;
|
|
13
|
-
|
|
13
|
+
if (!this.name)
|
|
14
|
+
this.isAnonymous = true;
|
|
14
15
|
}
|
|
15
16
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
16
17
|
exportSchema(options) {
|
|
@@ -20,9 +20,12 @@ export class FieldClass {
|
|
|
20
20
|
this.format = init.format;
|
|
21
21
|
}
|
|
22
22
|
exportSchema(options) {
|
|
23
|
+
const isAnonymous = !this.type.name ||
|
|
24
|
+
(this.type.kind === 'ComplexType' && this.type.isAnonymous);
|
|
23
25
|
return omitUndefined({
|
|
24
|
-
type: this.type
|
|
25
|
-
(
|
|
26
|
+
type: this.type
|
|
27
|
+
? (isAnonymous ? this.type.exportSchema(options) : this.type.name)
|
|
28
|
+
: undefined,
|
|
26
29
|
description: this.description,
|
|
27
30
|
isArray: this.isArray,
|
|
28
31
|
default: this.default,
|
package/package.json
CHANGED
|
@@ -32,11 +32,13 @@ export declare namespace ComplexType {
|
|
|
32
32
|
base?: ComplexType | MappedType | MixinType;
|
|
33
33
|
fields?: Record<string, ApiField.InitArguments>;
|
|
34
34
|
additionalFields?: boolean | DataType | 'error';
|
|
35
|
+
anonymous?: boolean;
|
|
35
36
|
}
|
|
36
37
|
interface OwnProperties extends DataType.OwnProperties {
|
|
37
38
|
ctor?: Type;
|
|
38
39
|
additionalFields?: boolean | DataType | 'error';
|
|
39
40
|
fields: ResponsiveMap<ApiField>;
|
|
41
|
+
anonymous?: boolean;
|
|
40
42
|
}
|
|
41
43
|
interface DecoratorOptions extends DataType.DecoratorOptions, Pick<InitArguments, 'ctor' | 'abstract'> {
|
|
42
44
|
anonymous?: boolean;
|
|
@@ -15,8 +15,8 @@ export declare abstract class DataType {
|
|
|
15
15
|
readonly name?: string;
|
|
16
16
|
readonly base?: DataType;
|
|
17
17
|
readonly own: DataType.OwnProperties;
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
description?: string;
|
|
19
|
+
isAnonymous?: boolean;
|
|
20
20
|
protected constructor(document: ApiDocument, init?: DataType.InitArguments);
|
|
21
21
|
abstract generateCodec(codec: 'decode' | 'encode', options?: DataType.GenerateCodecOptions): vg.Validator;
|
|
22
22
|
exportSchema(options?: {
|