@opra/common 1.0.0-alpha.3 → 1.0.0-alpha.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.
- package/browser.js +181 -58
- package/cjs/document/data-type/api-field.js +4 -0
- package/cjs/document/data-type/complex-type-base.js +4 -0
- package/cjs/document/data-type/complex-type.js +2 -0
- package/cjs/document/data-type/enum-type.js +2 -0
- package/cjs/document/data-type/extended-types/base64.type.js +4 -0
- package/cjs/document/data-type/extended-types/date-string.type.js +4 -0
- package/cjs/document/data-type/extended-types/date-time-string.type.js +4 -0
- package/cjs/document/data-type/extended-types/date-time.type.js +4 -0
- package/cjs/document/data-type/extended-types/date.type.js +4 -0
- package/cjs/document/data-type/extended-types/email.type.js +4 -0
- package/cjs/document/data-type/extended-types/field-path.type.js +4 -0
- package/cjs/document/data-type/extended-types/filter.type.js +4 -0
- package/cjs/document/data-type/extended-types/object-id.type.js +4 -0
- package/cjs/document/data-type/extended-types/time.type.js +4 -0
- package/cjs/document/data-type/extended-types/url.type.js +4 -0
- package/cjs/document/data-type/extended-types/uuid.type.js +4 -0
- package/cjs/document/data-type/mapped-type.js +3 -0
- package/cjs/document/data-type/mixin-type.js +3 -0
- package/cjs/document/data-type/primitive-types/bigint.type.js +4 -0
- package/cjs/document/data-type/primitive-types/boolean.type.js +4 -0
- package/cjs/document/data-type/primitive-types/integer.type.js +4 -0
- package/cjs/document/data-type/primitive-types/null.type.js +4 -0
- package/cjs/document/data-type/primitive-types/number.type.js +4 -0
- package/cjs/document/data-type/primitive-types/string.type.js +4 -0
- package/cjs/document/data-type/simple-type.js +8 -1
- package/cjs/document/decorators/http-operation-entity.decorator.js +7 -7
- package/cjs/document/factory/data-type.factory.js +61 -38
- package/esm/document/data-type/api-field.js +4 -0
- package/esm/document/data-type/complex-type-base.js +4 -0
- package/esm/document/data-type/complex-type.js +2 -0
- package/esm/document/data-type/enum-type.js +2 -0
- package/esm/document/data-type/extended-types/base64.type.js +4 -0
- package/esm/document/data-type/extended-types/date-string.type.js +4 -0
- package/esm/document/data-type/extended-types/date-time-string.type.js +4 -0
- package/esm/document/data-type/extended-types/date-time.type.js +4 -0
- package/esm/document/data-type/extended-types/date.type.js +4 -0
- package/esm/document/data-type/extended-types/email.type.js +4 -0
- package/esm/document/data-type/extended-types/field-path.type.js +4 -0
- package/esm/document/data-type/extended-types/filter.type.js +4 -0
- package/esm/document/data-type/extended-types/object-id.type.js +4 -0
- package/esm/document/data-type/extended-types/time.type.js +4 -0
- package/esm/document/data-type/extended-types/url.type.js +4 -0
- package/esm/document/data-type/extended-types/uuid.type.js +4 -0
- package/esm/document/data-type/mapped-type.js +3 -0
- package/esm/document/data-type/mixin-type.js +3 -0
- package/esm/document/data-type/primitive-types/bigint.type.js +4 -0
- package/esm/document/data-type/primitive-types/boolean.type.js +4 -0
- package/esm/document/data-type/primitive-types/integer.type.js +4 -0
- package/esm/document/data-type/primitive-types/null.type.js +4 -0
- package/esm/document/data-type/primitive-types/number.type.js +4 -0
- package/esm/document/data-type/primitive-types/string.type.js +4 -0
- package/esm/document/data-type/simple-type.js +8 -1
- package/esm/document/decorators/http-operation-entity.decorator.js +7 -7
- package/esm/document/factory/data-type.factory.js +61 -38
- package/package.json +3 -3
- package/types/document/data-type/api-field.d.ts +2 -0
- package/types/document/data-type/complex-type.d.ts +1 -1
- package/types/document/data-type/data-type.d.ts +4 -2
- package/types/document/data-type/enum-type.d.ts +2 -2
- package/types/document/data-type/mapped-type.d.ts +2 -2
- package/types/document/data-type/mixin-type.d.ts +2 -2
- package/types/document/data-type/simple-type.d.ts +4 -2
- package/types/document/factory/data-type.factory.d.ts +5 -0
- package/types/schema/data-type/simple-type.interface.d.ts +4 -0
package/browser.js
CHANGED
|
@@ -1172,6 +1172,10 @@ var ComplexTypeBaseClass = class extends DataType {
|
|
|
1172
1172
|
const pickList = !!(projection && Object.values(projection).find((p) => !p.sign));
|
|
1173
1173
|
let fieldName;
|
|
1174
1174
|
for (const field of this.fields.values()) {
|
|
1175
|
+
if (context.ignoreReadonlyFields && field.readonly || context.ignoreWriteonlyFields && field.writeonly) {
|
|
1176
|
+
schema[field.name] = vg.isUndefined({ coerce: true });
|
|
1177
|
+
continue;
|
|
1178
|
+
}
|
|
1175
1179
|
fieldName = field.name;
|
|
1176
1180
|
let p;
|
|
1177
1181
|
if (projection !== "*") {
|
|
@@ -1230,6 +1234,8 @@ var ApiField = /* @__PURE__ */ __name(function(...args) {
|
|
|
1230
1234
|
_this.exclusive = initArgs.exclusive;
|
|
1231
1235
|
_this.translatable = initArgs.translatable;
|
|
1232
1236
|
_this.deprecated = initArgs.deprecated;
|
|
1237
|
+
_this.readonly = initArgs.readonly;
|
|
1238
|
+
_this.writeonly = initArgs.writeonly;
|
|
1233
1239
|
_this.examples = initArgs.examples;
|
|
1234
1240
|
}, "ApiField");
|
|
1235
1241
|
var ApiFieldClass = class extends DocumentElement {
|
|
@@ -1248,6 +1254,8 @@ var ApiFieldClass = class extends DocumentElement {
|
|
|
1248
1254
|
exclusive: this.exclusive,
|
|
1249
1255
|
translatable: this.translatable,
|
|
1250
1256
|
deprecated: this.deprecated,
|
|
1257
|
+
readonly: this.readonly,
|
|
1258
|
+
writeonly: this.writeonly,
|
|
1251
1259
|
examples: this.examples
|
|
1252
1260
|
});
|
|
1253
1261
|
}
|
|
@@ -1297,6 +1305,8 @@ var ComplexTypeClass = class extends ComplexTypeBase {
|
|
|
1297
1305
|
__name(this, "ComplexTypeClass");
|
|
1298
1306
|
}
|
|
1299
1307
|
extendsFrom(baseType) {
|
|
1308
|
+
if (!(baseType instanceof DataType))
|
|
1309
|
+
baseType = this.node.getDataType(baseType);
|
|
1300
1310
|
if (!(baseType instanceof ComplexTypeBase))
|
|
1301
1311
|
return false;
|
|
1302
1312
|
if (baseType === this)
|
|
@@ -1364,6 +1374,8 @@ var EnumTypeClass = class extends DataType {
|
|
|
1364
1374
|
__name(this, "EnumTypeClass");
|
|
1365
1375
|
}
|
|
1366
1376
|
extendsFrom(baseType) {
|
|
1377
|
+
if (!(baseType instanceof DataType))
|
|
1378
|
+
baseType = this.node.getDataType(baseType);
|
|
1367
1379
|
if (!(baseType instanceof EnumType2))
|
|
1368
1380
|
return false;
|
|
1369
1381
|
if (baseType === this)
|
|
@@ -1495,6 +1507,8 @@ var MappedTypeClass = class extends ComplexTypeBase {
|
|
|
1495
1507
|
__name(this, "MappedTypeClass");
|
|
1496
1508
|
}
|
|
1497
1509
|
extendsFrom(baseType) {
|
|
1510
|
+
if (!(baseType instanceof DataType))
|
|
1511
|
+
baseType = this.node.getDataType(baseType);
|
|
1498
1512
|
if (!(baseType instanceof ComplexTypeBase))
|
|
1499
1513
|
return false;
|
|
1500
1514
|
if (baseType === this)
|
|
@@ -1549,6 +1563,8 @@ var MixinTypeClass = class extends ComplexTypeBase {
|
|
|
1549
1563
|
__name(this, "MixinTypeClass");
|
|
1550
1564
|
}
|
|
1551
1565
|
extendsFrom(baseType) {
|
|
1566
|
+
if (!(baseType instanceof DataType))
|
|
1567
|
+
baseType = this.node.getDataType(baseType);
|
|
1552
1568
|
if (!(baseType instanceof ComplexTypeBase))
|
|
1553
1569
|
return false;
|
|
1554
1570
|
if (baseType === this)
|
|
@@ -1683,6 +1699,8 @@ var SimpleType2 = /* @__PURE__ */ __name(function(...args) {
|
|
|
1683
1699
|
_this.base = initArgs.base;
|
|
1684
1700
|
}
|
|
1685
1701
|
_this.properties = initArgs.properties;
|
|
1702
|
+
_this.ownNameMappings = { ...initArgs.nameMappings };
|
|
1703
|
+
_this.nameMappings = { ..._this.base?.nameMappings, ...initArgs.nameMappings };
|
|
1686
1704
|
_this.ownAttributes = cloneObject(initArgs.attributes || {});
|
|
1687
1705
|
_this.attributes = _this.base ? cloneObject(_this.base.attributes) : {};
|
|
1688
1706
|
if (_this.ownAttributes) {
|
|
@@ -1700,6 +1718,8 @@ var SimpleTypeClass = class extends DataType {
|
|
|
1700
1718
|
__name(this, "SimpleTypeClass");
|
|
1701
1719
|
}
|
|
1702
1720
|
extendsFrom(baseType) {
|
|
1721
|
+
if (!(baseType instanceof DataType))
|
|
1722
|
+
baseType = this.node.getDataType(baseType);
|
|
1703
1723
|
if (!(baseType instanceof SimpleType2))
|
|
1704
1724
|
return false;
|
|
1705
1725
|
if (baseType === this)
|
|
@@ -1742,12 +1762,15 @@ var SimpleTypeClass = class extends DataType {
|
|
|
1742
1762
|
return o;
|
|
1743
1763
|
}, {});
|
|
1744
1764
|
const baseName = this.base ? this.node.getDataTypeNameWithNs(this.base) : void 0;
|
|
1745
|
-
|
|
1765
|
+
const out = omitUndefined({
|
|
1746
1766
|
...DataType.prototype.toJSON.apply(this),
|
|
1747
1767
|
base: this.base ? baseName ? baseName : this.base.toJSON() : void 0,
|
|
1748
1768
|
attributes: attributes && Object.keys(attributes).length ? attributes : void 0,
|
|
1749
1769
|
properties: Object.keys(properties).length ? properties : void 0
|
|
1750
1770
|
});
|
|
1771
|
+
if (Object.keys(this.ownNameMappings).length)
|
|
1772
|
+
out.nameMappings = { ...this.ownNameMappings };
|
|
1773
|
+
return out;
|
|
1751
1774
|
}
|
|
1752
1775
|
};
|
|
1753
1776
|
SimpleType2.prototype = SimpleTypeClass.prototype;
|
|
@@ -1872,7 +1895,7 @@ var DataTypeFactory = class {
|
|
|
1872
1895
|
thunk = await resolveThunk(thunk);
|
|
1873
1896
|
const { importQueue, initArgsMap } = context;
|
|
1874
1897
|
const dataType = owner.node.findDataType(thunk);
|
|
1875
|
-
if (dataType)
|
|
1898
|
+
if (dataType instanceof DataType)
|
|
1876
1899
|
return dataType.name;
|
|
1877
1900
|
let metadata2;
|
|
1878
1901
|
let ctor;
|
|
@@ -1941,10 +1964,14 @@ var DataTypeFactory = class {
|
|
|
1941
1964
|
};
|
|
1942
1965
|
out[initializingSymbol] = true;
|
|
1943
1966
|
try {
|
|
1944
|
-
if (out.name
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1967
|
+
if (out.name) {
|
|
1968
|
+
if (importQueue?.has(out.name)) {
|
|
1969
|
+
initArgsMap?.set(metadata2.name, out);
|
|
1970
|
+
out._instance = { name: metadata2.name };
|
|
1971
|
+
out[kDataTypeMap] = owner.node[kDataTypeMap];
|
|
1972
|
+
} else
|
|
1973
|
+
return context.addError(`Data Type (${out.name}) must be explicitly added to type list in the document scope`);
|
|
1974
|
+
}
|
|
1948
1975
|
switch (out.kind) {
|
|
1949
1976
|
case OpraSchema.ComplexType.Kind:
|
|
1950
1977
|
out.ctor = ctor;
|
|
@@ -2055,6 +2082,7 @@ var DataTypeFactory = class {
|
|
|
2055
2082
|
initArgs.ctor = initArgs.ctor || baseArgs.ctor;
|
|
2056
2083
|
});
|
|
2057
2084
|
initArgs.properties = metadata2.properties;
|
|
2085
|
+
initArgs.nameMappings = metadata2.nameMappings;
|
|
2058
2086
|
if (!initArgs.properties && initArgs.ctor)
|
|
2059
2087
|
initArgs.properties = new initArgs.ctor();
|
|
2060
2088
|
if (metadata2.attributes)
|
|
@@ -2106,26 +2134,40 @@ var DataTypeFactory = class {
|
|
|
2106
2134
|
});
|
|
2107
2135
|
}
|
|
2108
2136
|
static _createDataType(context, owner, args) {
|
|
2137
|
+
let dataType = owner.node.findDataType(typeof args === "string" ? args : args.name || "");
|
|
2138
|
+
if (dataType instanceof DataType)
|
|
2139
|
+
return dataType;
|
|
2109
2140
|
const initArgs = typeof args === "string" ? context.initArgsMap?.get(args) : args;
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2141
|
+
if (initArgs) {
|
|
2142
|
+
const dataTypeMap = initArgs[kDataTypeMap];
|
|
2143
|
+
if (!dataTypeMap)
|
|
2144
|
+
delete initArgs._instance;
|
|
2145
|
+
dataType = initArgs._instance;
|
|
2146
|
+
if (dataType?.name && dataTypeMap) {
|
|
2147
|
+
dataTypeMap.set(dataType.name, dataType);
|
|
2148
|
+
}
|
|
2149
|
+
switch (initArgs?.kind) {
|
|
2150
|
+
case OpraSchema.ComplexType.Kind:
|
|
2151
|
+
return this._createComplexType(context, owner, initArgs);
|
|
2152
|
+
case OpraSchema.EnumType.Kind:
|
|
2153
|
+
return this._createEnumType(context, owner, initArgs);
|
|
2154
|
+
case OpraSchema.MappedType.Kind:
|
|
2155
|
+
return this._createMappedType(context, owner, initArgs);
|
|
2156
|
+
case OpraSchema.MixinType.Kind:
|
|
2157
|
+
return this._createMixinType(context, owner, initArgs);
|
|
2158
|
+
case OpraSchema.SimpleType.Kind:
|
|
2159
|
+
return this._createSimpleType(context, owner, initArgs);
|
|
2160
|
+
}
|
|
2121
2161
|
}
|
|
2122
2162
|
context.addError(`Unknown data type (${String(args)})`);
|
|
2123
2163
|
}
|
|
2124
2164
|
static _createComplexType(context, owner, args) {
|
|
2165
|
+
const dataType = args._instance || {};
|
|
2166
|
+
Object.setPrototypeOf(dataType, ComplexType2.prototype);
|
|
2125
2167
|
const initArgs = cloneObject(args);
|
|
2126
2168
|
if (args.base) {
|
|
2127
2169
|
context.enter(".base", () => {
|
|
2128
|
-
initArgs.base =
|
|
2170
|
+
initArgs.base = this._createDataType(context, owner, args.base);
|
|
2129
2171
|
});
|
|
2130
2172
|
}
|
|
2131
2173
|
if (args.additionalFields) {
|
|
@@ -2133,11 +2175,7 @@ var DataTypeFactory = class {
|
|
|
2133
2175
|
if (typeof args.additionalFields === "boolean" || Array.isArray(args.additionalFields))
|
|
2134
2176
|
initArgs.additionalFields = args.additionalFields;
|
|
2135
2177
|
else {
|
|
2136
|
-
|
|
2137
|
-
initArgs.additionalFields = owner.node.findDataType(args.additionalFields) || this._createDataType(context, owner, args.additionalFields);
|
|
2138
|
-
} else {
|
|
2139
|
-
initArgs.additionalFields = this._createDataType(context, owner, args.additionalFields);
|
|
2140
|
-
}
|
|
2178
|
+
initArgs.additionalFields = this._createDataType(context, owner, args.additionalFields);
|
|
2141
2179
|
}
|
|
2142
2180
|
});
|
|
2143
2181
|
}
|
|
@@ -2146,7 +2184,7 @@ var DataTypeFactory = class {
|
|
|
2146
2184
|
context.enter(".fields", () => {
|
|
2147
2185
|
for (const [k, v] of Object.entries(args.fields)) {
|
|
2148
2186
|
context.enter(`[${k}]`, () => {
|
|
2149
|
-
const type =
|
|
2187
|
+
const type = this._createDataType(context, owner, v.type);
|
|
2150
2188
|
if (type)
|
|
2151
2189
|
initArgs.fields[k] = {
|
|
2152
2190
|
...v,
|
|
@@ -2157,28 +2195,37 @@ var DataTypeFactory = class {
|
|
|
2157
2195
|
}
|
|
2158
2196
|
});
|
|
2159
2197
|
}
|
|
2160
|
-
|
|
2198
|
+
ComplexType2.apply(dataType, [owner, initArgs]);
|
|
2199
|
+
return dataType;
|
|
2161
2200
|
}
|
|
2162
2201
|
static _createEnumType(context, owner, args) {
|
|
2202
|
+
const dataType = args._instance || {};
|
|
2203
|
+
Object.setPrototypeOf(dataType, EnumType2.prototype);
|
|
2163
2204
|
const initArgs = cloneObject(args);
|
|
2164
2205
|
if (args.base) {
|
|
2165
2206
|
context.enter(".base", () => {
|
|
2166
|
-
initArgs.base =
|
|
2207
|
+
initArgs.base = this._createDataType(context, owner, args.base);
|
|
2167
2208
|
});
|
|
2168
2209
|
}
|
|
2169
2210
|
initArgs.attributes = args.attributes;
|
|
2170
|
-
|
|
2211
|
+
EnumType2.apply(dataType, [owner, initArgs]);
|
|
2212
|
+
return dataType;
|
|
2171
2213
|
}
|
|
2172
2214
|
static _createMappedType(context, owner, args) {
|
|
2215
|
+
const dataType = args._instance || {};
|
|
2216
|
+
Object.setPrototypeOf(dataType, MappedType2.prototype);
|
|
2173
2217
|
const initArgs = cloneObject(args);
|
|
2174
2218
|
if (args.base) {
|
|
2175
2219
|
context.enter(".base", () => {
|
|
2176
|
-
initArgs.base =
|
|
2220
|
+
initArgs.base = this._createDataType(context, owner, args.base);
|
|
2177
2221
|
});
|
|
2178
2222
|
}
|
|
2179
|
-
|
|
2223
|
+
MappedType2.apply(dataType, [owner, initArgs]);
|
|
2224
|
+
return dataType;
|
|
2180
2225
|
}
|
|
2181
2226
|
static _createMixinType(context, owner, args) {
|
|
2227
|
+
const dataType = args._instance || {};
|
|
2228
|
+
Object.setPrototypeOf(dataType, MixinType2.prototype);
|
|
2182
2229
|
const initArgs = cloneObject(args);
|
|
2183
2230
|
if (args.types) {
|
|
2184
2231
|
context.enter(".types", () => {
|
|
@@ -2186,7 +2233,7 @@ var DataTypeFactory = class {
|
|
|
2186
2233
|
let i = 0;
|
|
2187
2234
|
for (const t of args.types) {
|
|
2188
2235
|
context.enter(`[${i++}]`, () => {
|
|
2189
|
-
const base =
|
|
2236
|
+
const base = this._createDataType(context, owner, t);
|
|
2190
2237
|
if (!(base instanceof ComplexTypeBase))
|
|
2191
2238
|
throw new TypeError(`"${base?.kind}" can't be set as base for a "${initArgs.kind}"`);
|
|
2192
2239
|
initArgs.types.push(base);
|
|
@@ -2194,16 +2241,20 @@ var DataTypeFactory = class {
|
|
|
2194
2241
|
}
|
|
2195
2242
|
});
|
|
2196
2243
|
}
|
|
2197
|
-
|
|
2244
|
+
MixinType2.apply(dataType, [owner, initArgs]);
|
|
2245
|
+
return dataType;
|
|
2198
2246
|
}
|
|
2199
2247
|
static _createSimpleType(context, owner, args) {
|
|
2248
|
+
const dataType = args._instance || {};
|
|
2249
|
+
Object.setPrototypeOf(dataType, SimpleType2.prototype);
|
|
2200
2250
|
const initArgs = cloneObject(args);
|
|
2201
2251
|
if (args.base) {
|
|
2202
2252
|
context.enter(".base", () => {
|
|
2203
|
-
initArgs.base =
|
|
2253
|
+
initArgs.base = this._createDataType(context, owner, args.base);
|
|
2204
2254
|
});
|
|
2205
2255
|
}
|
|
2206
|
-
|
|
2256
|
+
SimpleType2.apply(dataType, [owner, initArgs]);
|
|
2257
|
+
return dataType;
|
|
2207
2258
|
}
|
|
2208
2259
|
};
|
|
2209
2260
|
function preferName(initArgs) {
|
|
@@ -3845,7 +3896,11 @@ __decorate([
|
|
|
3845
3896
|
], NumberType.prototype, "maxValue", void 0);
|
|
3846
3897
|
NumberType = __decorate([
|
|
3847
3898
|
SimpleType2({
|
|
3848
|
-
description: "Both Integer as well as Floating-Point numbers"
|
|
3899
|
+
description: "Both Integer as well as Floating-Point numbers",
|
|
3900
|
+
nameMappings: {
|
|
3901
|
+
js: "number",
|
|
3902
|
+
json: "number"
|
|
3903
|
+
}
|
|
3849
3904
|
}),
|
|
3850
3905
|
__metadata("design:paramtypes", [Object])
|
|
3851
3906
|
], NumberType);
|
|
@@ -3872,7 +3927,11 @@ var BigintType = class BigintType2 extends NumberType {
|
|
|
3872
3927
|
};
|
|
3873
3928
|
BigintType = __decorate([
|
|
3874
3929
|
SimpleType2({
|
|
3875
|
-
description: "BigInt number"
|
|
3930
|
+
description: "BigInt number",
|
|
3931
|
+
nameMappings: {
|
|
3932
|
+
js: "bigint",
|
|
3933
|
+
json: "string"
|
|
3934
|
+
}
|
|
3876
3935
|
}),
|
|
3877
3936
|
__metadata("design:paramtypes", [Object])
|
|
3878
3937
|
], BigintType);
|
|
@@ -3896,7 +3955,11 @@ var BooleanType = class BooleanType2 {
|
|
|
3896
3955
|
};
|
|
3897
3956
|
BooleanType = __decorate([
|
|
3898
3957
|
SimpleType2({
|
|
3899
|
-
description: "Simple true/false value"
|
|
3958
|
+
description: "Simple true/false value",
|
|
3959
|
+
nameMappings: {
|
|
3960
|
+
js: "boolean",
|
|
3961
|
+
json: "boolean"
|
|
3962
|
+
}
|
|
3900
3963
|
}),
|
|
3901
3964
|
__metadata("design:paramtypes", [Object])
|
|
3902
3965
|
], BooleanType);
|
|
@@ -3924,7 +3987,11 @@ var IntegerType = class IntegerType2 extends NumberType {
|
|
|
3924
3987
|
};
|
|
3925
3988
|
IntegerType = __decorate([
|
|
3926
3989
|
SimpleType2({
|
|
3927
|
-
description: "An integer number"
|
|
3990
|
+
description: "An integer number",
|
|
3991
|
+
nameMappings: {
|
|
3992
|
+
js: "number",
|
|
3993
|
+
json: "number"
|
|
3994
|
+
}
|
|
3928
3995
|
}),
|
|
3929
3996
|
__metadata("design:paramtypes", [Object])
|
|
3930
3997
|
], IntegerType);
|
|
@@ -3948,7 +4015,11 @@ var NullType = class NullType2 {
|
|
|
3948
4015
|
};
|
|
3949
4016
|
NullType = __decorate([
|
|
3950
4017
|
SimpleType2({
|
|
3951
|
-
description: "A Null value"
|
|
4018
|
+
description: "A Null value",
|
|
4019
|
+
nameMappings: {
|
|
4020
|
+
js: "null",
|
|
4021
|
+
json: "null"
|
|
4022
|
+
}
|
|
3952
4023
|
}),
|
|
3953
4024
|
__metadata("design:paramtypes", [Object])
|
|
3954
4025
|
], NullType);
|
|
@@ -4030,7 +4101,11 @@ __decorate([
|
|
|
4030
4101
|
], StringType.prototype, "maxLength", void 0);
|
|
4031
4102
|
StringType = __decorate([
|
|
4032
4103
|
SimpleType2({
|
|
4033
|
-
description: "A sequence of characters"
|
|
4104
|
+
description: "A sequence of characters",
|
|
4105
|
+
nameMappings: {
|
|
4106
|
+
js: "string",
|
|
4107
|
+
json: "string"
|
|
4108
|
+
}
|
|
4034
4109
|
}),
|
|
4035
4110
|
__metadata("design:paramtypes", [Object])
|
|
4036
4111
|
], StringType);
|
|
@@ -4054,7 +4129,11 @@ var Base64Type = class Base64Type2 {
|
|
|
4054
4129
|
};
|
|
4055
4130
|
Base64Type = __decorate([
|
|
4056
4131
|
SimpleType2({
|
|
4057
|
-
description: "A stream of bytes, base64 encoded"
|
|
4132
|
+
description: "A stream of bytes, base64 encoded",
|
|
4133
|
+
nameMappings: {
|
|
4134
|
+
js: "string",
|
|
4135
|
+
json: "string"
|
|
4136
|
+
}
|
|
4058
4137
|
}),
|
|
4059
4138
|
__metadata("design:paramtypes", [Object])
|
|
4060
4139
|
], Base64Type);
|
|
@@ -4110,7 +4189,11 @@ __decorate([
|
|
|
4110
4189
|
], DateType.prototype, "maxValue", void 0);
|
|
4111
4190
|
DateType = __decorate([
|
|
4112
4191
|
SimpleType2({
|
|
4113
|
-
description: "A date without time"
|
|
4192
|
+
description: "A date without time",
|
|
4193
|
+
nameMappings: {
|
|
4194
|
+
js: "Date",
|
|
4195
|
+
json: "string"
|
|
4196
|
+
}
|
|
4114
4197
|
}).Example("2021-04-18", "Full date value"),
|
|
4115
4198
|
__metadata("design:paramtypes", [Object])
|
|
4116
4199
|
], DateType);
|
|
@@ -4152,7 +4235,11 @@ __decorate([
|
|
|
4152
4235
|
], DateStringType.prototype, "maxValue", void 0);
|
|
4153
4236
|
DateStringType = __decorate([
|
|
4154
4237
|
SimpleType2({
|
|
4155
|
-
description: "Date string value"
|
|
4238
|
+
description: "Date string value",
|
|
4239
|
+
nameMappings: {
|
|
4240
|
+
js: "string",
|
|
4241
|
+
json: "string"
|
|
4242
|
+
}
|
|
4156
4243
|
}).Example("2021-04-18", "Full date value").Example("2021-04", "Date value without day").Example("2021", "Year only value"),
|
|
4157
4244
|
__metadata("design:paramtypes", [Object])
|
|
4158
4245
|
], DateStringType);
|
|
@@ -4208,7 +4295,11 @@ __decorate([
|
|
|
4208
4295
|
], DateTimeType.prototype, "maxValue", void 0);
|
|
4209
4296
|
DateTimeType = __decorate([
|
|
4210
4297
|
SimpleType2({
|
|
4211
|
-
description: "A full datetime value"
|
|
4298
|
+
description: "A full datetime value",
|
|
4299
|
+
nameMappings: {
|
|
4300
|
+
js: "string",
|
|
4301
|
+
json: "string"
|
|
4302
|
+
}
|
|
4212
4303
|
}).Example("2021-04-18T22:30:15").Example("2021-04-18 22:30:15").Example("2021-04-18 22:30"),
|
|
4213
4304
|
__metadata("design:paramtypes", [Object])
|
|
4214
4305
|
], DateTimeType);
|
|
@@ -4250,7 +4341,11 @@ __decorate([
|
|
|
4250
4341
|
], DateTimeStringType.prototype, "maxValue", void 0);
|
|
4251
4342
|
DateTimeStringType = __decorate([
|
|
4252
4343
|
SimpleType2({
|
|
4253
|
-
description: "DateTime string value"
|
|
4344
|
+
description: "DateTime string value",
|
|
4345
|
+
nameMappings: {
|
|
4346
|
+
js: "string",
|
|
4347
|
+
json: "string"
|
|
4348
|
+
}
|
|
4254
4349
|
}).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
4350
|
__metadata("design:paramtypes", [Object])
|
|
4256
4351
|
], DateTimeStringType);
|
|
@@ -4334,7 +4429,11 @@ __decorate([
|
|
|
4334
4429
|
], EmailType.prototype, "blacklistedChars", void 0);
|
|
4335
4430
|
EmailType = __decorate([
|
|
4336
4431
|
SimpleType2({
|
|
4337
|
-
description: "An email value"
|
|
4432
|
+
description: "An email value",
|
|
4433
|
+
nameMappings: {
|
|
4434
|
+
js: "string",
|
|
4435
|
+
json: "string"
|
|
4436
|
+
}
|
|
4338
4437
|
}).Example("some.body@example.com"),
|
|
4339
4438
|
__metadata("design:paramtypes", [Object])
|
|
4340
4439
|
], EmailType);
|
|
@@ -4383,7 +4482,11 @@ __decorate([
|
|
|
4383
4482
|
], FieldPathType.prototype, "allowSigns", void 0);
|
|
4384
4483
|
FieldPathType = __decorate([
|
|
4385
4484
|
SimpleType2({
|
|
4386
|
-
description: "Field path"
|
|
4485
|
+
description: "Field path",
|
|
4486
|
+
nameMappings: {
|
|
4487
|
+
js: "string",
|
|
4488
|
+
json: "string"
|
|
4489
|
+
}
|
|
4387
4490
|
}),
|
|
4388
4491
|
__metadata("design:paramtypes", [Object])
|
|
4389
4492
|
], FieldPathType);
|
|
@@ -12302,7 +12405,11 @@ __decorate([
|
|
|
12302
12405
|
], FilterType.prototype, "rules", void 0);
|
|
12303
12406
|
FilterType = __decorate([
|
|
12304
12407
|
SimpleType2({
|
|
12305
|
-
description: "A query filter"
|
|
12408
|
+
description: "A query filter",
|
|
12409
|
+
nameMappings: {
|
|
12410
|
+
js: "object",
|
|
12411
|
+
json: "string"
|
|
12412
|
+
}
|
|
12306
12413
|
}),
|
|
12307
12414
|
__metadata("design:paramtypes", [Object])
|
|
12308
12415
|
], FilterType);
|
|
@@ -12348,7 +12455,11 @@ var ObjectIdType = class ObjectIdType2 {
|
|
|
12348
12455
|
};
|
|
12349
12456
|
ObjectIdType = __decorate([
|
|
12350
12457
|
SimpleType2({
|
|
12351
|
-
description: "A MongoDB ObjectID value"
|
|
12458
|
+
description: "A MongoDB ObjectID value",
|
|
12459
|
+
nameMappings: {
|
|
12460
|
+
js: "object",
|
|
12461
|
+
json: "string"
|
|
12462
|
+
}
|
|
12352
12463
|
}),
|
|
12353
12464
|
__metadata("design:paramtypes", [Object])
|
|
12354
12465
|
], ObjectIdType);
|
|
@@ -12462,7 +12573,11 @@ __decorate([
|
|
|
12462
12573
|
], TimeType.prototype, "maxValue", void 0);
|
|
12463
12574
|
TimeType = __decorate([
|
|
12464
12575
|
SimpleType2({
|
|
12465
|
-
description: "Time string in 24h format"
|
|
12576
|
+
description: "Time string in 24h format",
|
|
12577
|
+
nameMappings: {
|
|
12578
|
+
js: "string",
|
|
12579
|
+
json: "string"
|
|
12580
|
+
}
|
|
12466
12581
|
}).Example("18:23:00", "Full time value").Example("18:23:00", "Time value without seconds"),
|
|
12467
12582
|
__metadata("design:paramtypes", [Object])
|
|
12468
12583
|
], TimeType);
|
|
@@ -12486,7 +12601,11 @@ var UrlType = class UrlType2 {
|
|
|
12486
12601
|
};
|
|
12487
12602
|
UrlType = __decorate([
|
|
12488
12603
|
SimpleType2({
|
|
12489
|
-
description: "A Uniform Resource Identifier Reference (RFC 3986 icon) value"
|
|
12604
|
+
description: "A Uniform Resource Identifier Reference (RFC 3986 icon) value",
|
|
12605
|
+
nameMappings: {
|
|
12606
|
+
js: "string",
|
|
12607
|
+
json: "string"
|
|
12608
|
+
}
|
|
12490
12609
|
}).Example("http://tempuri.org"),
|
|
12491
12610
|
__metadata("design:paramtypes", [Object])
|
|
12492
12611
|
], UrlType);
|
|
@@ -12516,7 +12635,11 @@ __decorate([
|
|
|
12516
12635
|
], UuidType.prototype, "version", void 0);
|
|
12517
12636
|
UuidType = __decorate([
|
|
12518
12637
|
SimpleType2({
|
|
12519
|
-
description: "A Universal Unique Identifier (UUID) value"
|
|
12638
|
+
description: "A Universal Unique Identifier (UUID) value",
|
|
12639
|
+
nameMappings: {
|
|
12640
|
+
js: "string",
|
|
12641
|
+
json: "string"
|
|
12642
|
+
}
|
|
12520
12643
|
}),
|
|
12521
12644
|
__metadata("design:paramtypes", [Object])
|
|
12522
12645
|
], UuidType);
|
|
@@ -12531,8 +12654,8 @@ HttpOperation2.Entity.Create = function(arg0, arg1) {
|
|
|
12531
12654
|
args = { ...arg1, type: arg0 };
|
|
12532
12655
|
const decoratorChain = [];
|
|
12533
12656
|
const decorator = HttpOperationDecoratorFactory(decoratorChain, omitUndefined({
|
|
12534
|
-
description: args.description,
|
|
12535
12657
|
method: "POST",
|
|
12658
|
+
...args,
|
|
12536
12659
|
composition: "Entity.Create",
|
|
12537
12660
|
requestBody: {
|
|
12538
12661
|
immediateFetch: true,
|
|
@@ -12573,8 +12696,8 @@ HttpOperation2.Entity.Delete = function(arg0, arg1) {
|
|
|
12573
12696
|
args = { ...arg1, type: arg0 };
|
|
12574
12697
|
const decoratorChain = [];
|
|
12575
12698
|
const decorator = HttpOperationDecoratorFactory(decoratorChain, omitUndefined({
|
|
12576
|
-
description: args.description,
|
|
12577
12699
|
method: "DELETE",
|
|
12700
|
+
...args,
|
|
12578
12701
|
composition: "Entity.Delete"
|
|
12579
12702
|
}));
|
|
12580
12703
|
decorator.Response(HttpStatusCode.OK, {
|
|
@@ -12612,8 +12735,8 @@ HttpOperation2.Entity.DeleteMany = function(arg0, arg1) {
|
|
|
12612
12735
|
const filterType = new FilterType({ dataType: args.type });
|
|
12613
12736
|
filterType.rules = {};
|
|
12614
12737
|
const decorator = HttpOperationDecoratorFactory(decoratorChain, omitUndefined({
|
|
12615
|
-
description: args.description,
|
|
12616
12738
|
method: "DELETE",
|
|
12739
|
+
...args,
|
|
12617
12740
|
composition: "Entity.DeleteMany"
|
|
12618
12741
|
}));
|
|
12619
12742
|
decorator.Response(HttpStatusCode.OK, {
|
|
@@ -12652,8 +12775,8 @@ HttpOperation2.Entity.FindMany = function(arg0, arg1) {
|
|
|
12652
12775
|
const filterType = new FilterType({ dataType: args.type });
|
|
12653
12776
|
filterType.rules = {};
|
|
12654
12777
|
const decorator = HttpOperationDecoratorFactory(decoratorChain, omitUndefined({
|
|
12655
|
-
description: args.description,
|
|
12656
12778
|
method: "GET",
|
|
12779
|
+
...args,
|
|
12657
12780
|
composition: "Entity.FindMany"
|
|
12658
12781
|
}));
|
|
12659
12782
|
decorator.Response(HttpStatusCode.OK, {
|
|
@@ -12731,8 +12854,8 @@ HttpOperation2.Entity.Get = function(arg0, arg1) {
|
|
|
12731
12854
|
args = { ...arg1, type: arg0 };
|
|
12732
12855
|
const decoratorChain = [];
|
|
12733
12856
|
const decorator = HttpOperationDecoratorFactory(decoratorChain, omitUndefined({
|
|
12734
|
-
description: args.description,
|
|
12735
12857
|
method: "GET",
|
|
12858
|
+
...args,
|
|
12736
12859
|
composition: "Entity.Get"
|
|
12737
12860
|
}));
|
|
12738
12861
|
decorator.QueryParam("projection", {
|
|
@@ -12782,8 +12905,8 @@ HttpOperation2.Entity.UpdateMany = function(arg0, arg1) {
|
|
|
12782
12905
|
filterType.rules = {};
|
|
12783
12906
|
const filterRules = new FilterRules();
|
|
12784
12907
|
const decorator = HttpOperationDecoratorFactory(decoratorChain, omitUndefined({
|
|
12785
|
-
description: args.description,
|
|
12786
12908
|
method: "PATCH",
|
|
12909
|
+
...args,
|
|
12787
12910
|
composition: "Entity.UpdateMany",
|
|
12788
12911
|
requestBody: {
|
|
12789
12912
|
immediateFetch: true,
|
|
@@ -12829,8 +12952,8 @@ HttpOperation2.Entity.Update = function(arg0, arg1) {
|
|
|
12829
12952
|
const filterType = new FilterType({ dataType: args.type });
|
|
12830
12953
|
filterType.rules = {};
|
|
12831
12954
|
const decorator = HttpOperationDecoratorFactory(decoratorChain, omitUndefined({
|
|
12832
|
-
description: args.description,
|
|
12833
12955
|
method: "PATCH",
|
|
12956
|
+
...args,
|
|
12834
12957
|
composition: "Entity.Update",
|
|
12835
12958
|
requestBody: {
|
|
12836
12959
|
partial: "deep",
|
|
@@ -36,6 +36,8 @@ exports.ApiField = function (...args) {
|
|
|
36
36
|
_this.exclusive = initArgs.exclusive;
|
|
37
37
|
_this.translatable = initArgs.translatable;
|
|
38
38
|
_this.deprecated = initArgs.deprecated;
|
|
39
|
+
_this.readonly = initArgs.readonly;
|
|
40
|
+
_this.writeonly = initArgs.writeonly;
|
|
39
41
|
_this.examples = initArgs.examples;
|
|
40
42
|
};
|
|
41
43
|
/**
|
|
@@ -55,6 +57,8 @@ class ApiFieldClass extends document_element_js_1.DocumentElement {
|
|
|
55
57
|
exclusive: this.exclusive,
|
|
56
58
|
translatable: this.translatable,
|
|
57
59
|
deprecated: this.deprecated,
|
|
60
|
+
readonly: this.readonly,
|
|
61
|
+
writeonly: this.writeonly,
|
|
58
62
|
examples: this.examples,
|
|
59
63
|
});
|
|
60
64
|
}
|
|
@@ -146,6 +146,10 @@ class ComplexTypeBaseClass extends data_type_js_1.DataType {
|
|
|
146
146
|
// Process fields
|
|
147
147
|
let fieldName;
|
|
148
148
|
for (const field of this.fields.values()) {
|
|
149
|
+
if ((context.ignoreReadonlyFields && field.readonly) || (context.ignoreWriteonlyFields && field.writeonly)) {
|
|
150
|
+
schema[field.name] = valgen_1.vg.isUndefined({ coerce: true });
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
149
153
|
fieldName = field.name;
|
|
150
154
|
let p;
|
|
151
155
|
if (projection !== '*') {
|
|
@@ -60,6 +60,8 @@ exports.ComplexType = function (...args) {
|
|
|
60
60
|
*/
|
|
61
61
|
class ComplexTypeClass extends complex_type_base_js_1.ComplexTypeBase {
|
|
62
62
|
extendsFrom(baseType) {
|
|
63
|
+
if (!(baseType instanceof data_type_js_1.DataType))
|
|
64
|
+
baseType = this.node.getDataType(baseType);
|
|
63
65
|
if (!(baseType instanceof complex_type_base_js_1.ComplexTypeBase))
|
|
64
66
|
return false;
|
|
65
67
|
if (baseType === this)
|
|
@@ -38,6 +38,8 @@ exports.EnumType = function (...args) {
|
|
|
38
38
|
*/
|
|
39
39
|
class EnumTypeClass extends data_type_js_1.DataType {
|
|
40
40
|
extendsFrom(baseType) {
|
|
41
|
+
if (!(baseType instanceof data_type_js_1.DataType))
|
|
42
|
+
baseType = this.node.getDataType(baseType);
|
|
41
43
|
if (!(baseType instanceof exports.EnumType))
|
|
42
44
|
return false;
|
|
43
45
|
if (baseType === this)
|
|
@@ -21,6 +21,10 @@ exports.Base64Type = Base64Type;
|
|
|
21
21
|
exports.Base64Type = Base64Type = tslib_1.__decorate([
|
|
22
22
|
(0, simple_type_js_1.SimpleType)({
|
|
23
23
|
description: 'A stream of bytes, base64 encoded',
|
|
24
|
+
nameMappings: {
|
|
25
|
+
js: 'string',
|
|
26
|
+
json: 'string',
|
|
27
|
+
},
|
|
24
28
|
}),
|
|
25
29
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
26
30
|
], Base64Type);
|
|
@@ -39,6 +39,10 @@ tslib_1.__decorate([
|
|
|
39
39
|
exports.DateStringType = DateStringType = tslib_1.__decorate([
|
|
40
40
|
(0, simple_type_js_1.SimpleType)({
|
|
41
41
|
description: 'Date string value',
|
|
42
|
+
nameMappings: {
|
|
43
|
+
js: 'string',
|
|
44
|
+
json: 'string',
|
|
45
|
+
},
|
|
42
46
|
})
|
|
43
47
|
.Example('2021-04-18', 'Full date value')
|
|
44
48
|
.Example('2021-04', 'Date value without day')
|
|
@@ -39,6 +39,10 @@ tslib_1.__decorate([
|
|
|
39
39
|
exports.DateTimeStringType = DateTimeStringType = tslib_1.__decorate([
|
|
40
40
|
(0, simple_type_js_1.SimpleType)({
|
|
41
41
|
description: 'DateTime string value',
|
|
42
|
+
nameMappings: {
|
|
43
|
+
js: 'string',
|
|
44
|
+
json: 'string',
|
|
45
|
+
},
|
|
42
46
|
})
|
|
43
47
|
.Example('2021-04-18T22:30:15+01:00', 'Full date-time value with timezone')
|
|
44
48
|
.Example('2021-04-18T22:30:15', 'Full date-time value without timezone')
|
|
@@ -53,6 +53,10 @@ tslib_1.__decorate([
|
|
|
53
53
|
exports.DateTimeType = DateTimeType = tslib_1.__decorate([
|
|
54
54
|
(0, simple_type_js_1.SimpleType)({
|
|
55
55
|
description: 'A full datetime value',
|
|
56
|
+
nameMappings: {
|
|
57
|
+
js: 'string',
|
|
58
|
+
json: 'string',
|
|
59
|
+
},
|
|
56
60
|
})
|
|
57
61
|
.Example('2021-04-18T22:30:15')
|
|
58
62
|
.Example('2021-04-18 22:30:15')
|