@opra/common 0.32.5 → 0.33.0
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 +95 -89
- package/cjs/document/data-type/builtin/approx-date.type.js +2 -2
- package/cjs/document/data-type/builtin/approx-datetime.type.js +2 -2
- package/cjs/document/data-type/builtin/base64.type.js +2 -2
- package/cjs/document/data-type/builtin/bigint.type.js +2 -2
- package/cjs/document/data-type/builtin/boolean.type.js +2 -2
- package/cjs/document/data-type/builtin/date.type.js +2 -2
- package/cjs/document/data-type/builtin/datetime.type.js +2 -2
- package/cjs/document/data-type/builtin/email.type.js +2 -2
- package/cjs/document/data-type/builtin/integer.type.js +2 -2
- package/cjs/document/data-type/builtin/null.type.js +2 -2
- package/cjs/document/data-type/builtin/number.type.js +2 -2
- package/cjs/document/data-type/builtin/object-id.type.js +2 -2
- package/cjs/document/data-type/builtin/string.type.js +2 -2
- package/cjs/document/data-type/builtin/time.type.js +2 -2
- package/cjs/document/data-type/builtin/url.type.js +2 -2
- package/cjs/document/data-type/builtin/uuid.type.js +2 -2
- package/cjs/document/data-type/complex-type-class.js +2 -3
- package/cjs/document/data-type/enum-type-class.js +5 -5
- package/cjs/document/data-type/field-class.js +10 -8
- package/cjs/document/data-type/simple-type-class.js +3 -4
- package/cjs/document/resource/action.js +2 -3
- package/cjs/document/resource/collection-class.js +3 -3
- package/cjs/document/resource/container-class.js +1 -1
- package/cjs/document/resource/crud-operation.js +3 -4
- package/cjs/document/resource/parameter.js +3 -4
- package/cjs/exception/index.js +2 -2
- package/cjs/exception/resource-errors/permission.error.js +21 -0
- package/cjs/exception/resource-errors/resource-conflict.error.js +1 -1
- package/cjs/exception/resource-errors/resource-not-found.error.js +2 -2
- package/cjs/exception/resource-errors/resource-not.available.error.js +24 -0
- package/cjs/exception/resource-errors/resource-not.available.js +24 -0
- package/cjs/filter/ast/terms/date-literal.js +1 -1
- package/cjs/filter/ast/terms/number-literal.js +1 -1
- package/cjs/filter/ast/terms/time-literal.js +1 -1
- package/cjs/filter/errors.js +3 -3
- package/esm/document/data-type/builtin/approx-date.type.js +3 -3
- package/esm/document/data-type/builtin/approx-datetime.type.js +2 -2
- package/esm/document/data-type/builtin/base64.type.js +2 -2
- package/esm/document/data-type/builtin/bigint.type.js +3 -3
- package/esm/document/data-type/builtin/boolean.type.js +2 -2
- package/esm/document/data-type/builtin/date.type.js +3 -3
- package/esm/document/data-type/builtin/datetime.type.js +3 -3
- package/esm/document/data-type/builtin/email.type.js +3 -3
- package/esm/document/data-type/builtin/integer.type.js +2 -2
- package/esm/document/data-type/builtin/null.type.js +2 -2
- package/esm/document/data-type/builtin/number.type.js +2 -2
- package/esm/document/data-type/builtin/object-id.type.js +3 -3
- package/esm/document/data-type/builtin/string.type.js +2 -2
- package/esm/document/data-type/builtin/time.type.js +3 -3
- package/esm/document/data-type/builtin/url.type.js +2 -2
- package/esm/document/data-type/builtin/uuid.type.js +2 -2
- package/esm/document/data-type/complex-type-class.js +1 -1
- package/esm/document/data-type/enum-type-class.js +3 -2
- package/esm/document/data-type/field-class.js +8 -5
- package/esm/document/data-type/simple-type-class.js +3 -3
- package/esm/document/resource/action.js +2 -2
- package/esm/document/resource/collection-class.js +2 -1
- package/esm/document/resource/container-class.js +2 -2
- package/esm/document/resource/crud-operation.js +1 -1
- package/esm/document/resource/parameter.js +1 -1
- package/esm/exception/index.js +2 -2
- package/esm/exception/resource-errors/permission.error.js +17 -0
- package/esm/exception/resource-errors/resource-conflict.error.js +1 -1
- package/esm/exception/resource-errors/resource-not-found.error.js +2 -2
- package/esm/exception/resource-errors/resource-not.available.error.js +20 -0
- package/esm/exception/resource-errors/resource-not.available.js +20 -0
- package/esm/filter/ast/terms/date-literal.js +2 -2
- package/esm/filter/ast/terms/number-literal.js +2 -2
- package/esm/filter/ast/terms/time-literal.js +2 -2
- package/esm/filter/errors.js +1 -1
- package/package.json +3 -3
- package/types/document/data-type/complex-type-class.d.ts +4 -4
- package/types/document/data-type/data-type.d.ts +3 -3
- package/types/document/data-type/enum-type-class.d.ts +4 -4
- package/types/document/data-type/field-class.d.ts +3 -3
- package/types/document/data-type/field.d.ts +6 -3
- package/types/document/data-type/simple-type-class.d.ts +4 -4
- package/types/document/data-type/simple-type.d.ts +7 -7
- package/types/document/resource/action.d.ts +2 -2
- package/types/document/resource/crud-operation.d.ts +3 -3
- package/types/document/resource/parameter.d.ts +6 -6
- package/types/exception/index.d.ts +2 -2
- package/types/exception/resource-errors/permission.error.d.ts +11 -0
- package/types/exception/resource-errors/resource-not.available.d.ts +8 -0
- package/types/exception/resource-errors/resource-not.available.error.d.ts +8 -0
- package/types/filter/errors.d.ts +1 -1
- package/types/helpers/object-utils.d.ts +2 -2
- package/types/schema/data-type/complex-type.interface.d.ts +1 -1
- package/types/schema/data-type/field.interface.d.ts +4 -1
- package/types/schema/data-type/mapped-type.interface.d.ts +1 -1
- package/types/schema/data-type/simple-type.interface.d.ts +3 -3
- package/types/types.d.ts +6 -14
- package/cjs/exception/common-errors/validation.error.js +0 -11
- package/esm/exception/common-errors/validation.error.js +0 -7
- package/types/exception/common-errors/validation.error.d.ts +0 -4
package/browser.js
CHANGED
|
@@ -1546,6 +1546,20 @@ var ConflictError = class extends OpraException {
|
|
|
1546
1546
|
}
|
|
1547
1547
|
};
|
|
1548
1548
|
|
|
1549
|
+
// ../../build/common/esm/exception/resource-errors/permission.error.js
|
|
1550
|
+
var PermissionError = class extends ForbiddenError {
|
|
1551
|
+
static {
|
|
1552
|
+
__name(this, "PermissionError");
|
|
1553
|
+
}
|
|
1554
|
+
init(issue) {
|
|
1555
|
+
super.init({
|
|
1556
|
+
message: translate("error:PERMISSION_ERROR", "You dont have permission for this operation"),
|
|
1557
|
+
code: "PERMISSION_ERROR",
|
|
1558
|
+
...issue
|
|
1559
|
+
});
|
|
1560
|
+
}
|
|
1561
|
+
};
|
|
1562
|
+
|
|
1549
1563
|
// ../../build/common/esm/exception/resource-errors/resource-conflict.error.js
|
|
1550
1564
|
var ResourceConflictError = class extends OpraException {
|
|
1551
1565
|
static {
|
|
@@ -1553,7 +1567,7 @@ var ResourceConflictError = class extends OpraException {
|
|
|
1553
1567
|
}
|
|
1554
1568
|
constructor(resource, fields, cause) {
|
|
1555
1569
|
super({
|
|
1556
|
-
message: translate(`error:RESOURCE_CONFLICT`, { resource, fields }, `There is already an other {{resource}} resource with same
|
|
1570
|
+
message: translate(`error:RESOURCE_CONFLICT`, { resource, fields }, `There is already an other {{resource}} resource with same values ({{fields}})`),
|
|
1557
1571
|
severity: "error",
|
|
1558
1572
|
code: "RESOURCE_CONFLICT",
|
|
1559
1573
|
details: {
|
|
@@ -1565,16 +1579,16 @@ var ResourceConflictError = class extends OpraException {
|
|
|
1565
1579
|
}
|
|
1566
1580
|
};
|
|
1567
1581
|
|
|
1568
|
-
// ../../build/common/esm/exception/resource-errors/resource-not
|
|
1569
|
-
var
|
|
1582
|
+
// ../../build/common/esm/exception/resource-errors/resource-not.available.error.js
|
|
1583
|
+
var ResourceNotAvailableError = class extends OpraException {
|
|
1570
1584
|
static {
|
|
1571
|
-
__name(this, "
|
|
1585
|
+
__name(this, "ResourceNotAvailableError");
|
|
1572
1586
|
}
|
|
1573
1587
|
constructor(resource, keyValue, cause) {
|
|
1574
1588
|
super({
|
|
1575
|
-
message: translate(`error:
|
|
1589
|
+
message: translate(`error:RESOURCE_NOT_AVAILABLE`, `Resource "${resource}${keyValue ? "/" + keyValue : ""}" is not available or you dont have access`),
|
|
1576
1590
|
severity: "error",
|
|
1577
|
-
code: "
|
|
1591
|
+
code: "RESOURCE_NOT_AVAILABLE",
|
|
1578
1592
|
details: {
|
|
1579
1593
|
resource,
|
|
1580
1594
|
key: keyValue
|
|
@@ -1583,17 +1597,6 @@ var ResourceNotFoundError = class extends OpraException {
|
|
|
1583
1597
|
}
|
|
1584
1598
|
};
|
|
1585
1599
|
|
|
1586
|
-
// ../../build/common/esm/exception/common-errors/validation.error.js
|
|
1587
|
-
var ValidationError = class extends OpraException {
|
|
1588
|
-
static {
|
|
1589
|
-
__name(this, "ValidationError");
|
|
1590
|
-
}
|
|
1591
|
-
constructor() {
|
|
1592
|
-
super(...arguments);
|
|
1593
|
-
this.status = 400;
|
|
1594
|
-
}
|
|
1595
|
-
};
|
|
1596
|
-
|
|
1597
1600
|
// ../../build/common/esm/schema/opra-schema.ns.js
|
|
1598
1601
|
var opra_schema_ns_exports = {};
|
|
1599
1602
|
__export(opra_schema_ns_exports, {
|
|
@@ -1730,7 +1733,7 @@ var colorFgYellow = "\x1B[33m";
|
|
|
1730
1733
|
var colorFgMagenta = "\x1B[35m";
|
|
1731
1734
|
|
|
1732
1735
|
// ../../build/common/esm/document/resource/action.js
|
|
1733
|
-
import
|
|
1736
|
+
import { isAny } from "valgen";
|
|
1734
1737
|
|
|
1735
1738
|
// ../../build/common/esm/document/data-type/data-type.js
|
|
1736
1739
|
var DataType = class _DataType {
|
|
@@ -1771,7 +1774,7 @@ var DataType = class _DataType {
|
|
|
1771
1774
|
};
|
|
1772
1775
|
|
|
1773
1776
|
// ../../build/common/esm/document/resource/parameter.js
|
|
1774
|
-
import
|
|
1777
|
+
import { vg } from "valgen";
|
|
1775
1778
|
var Parameter = class {
|
|
1776
1779
|
static {
|
|
1777
1780
|
__name(this, "Parameter");
|
|
@@ -1877,7 +1880,7 @@ var Action = class extends Endpoint {
|
|
|
1877
1880
|
this.resource = resource;
|
|
1878
1881
|
this.name = name;
|
|
1879
1882
|
this.kind = "action";
|
|
1880
|
-
this.encodeReturning =
|
|
1883
|
+
this.encodeReturning = isAny;
|
|
1881
1884
|
if (init.returnType)
|
|
1882
1885
|
this.returnType = init.returnType instanceof DataType ? init.returnType : this.resource.document.getDataType(init.returnType);
|
|
1883
1886
|
this.returnMime = init.returnMime;
|
|
@@ -1987,7 +1990,7 @@ var ContainerClass = class _ContainerClass extends Resource {
|
|
|
1987
1990
|
resource = this.resources.get(path);
|
|
1988
1991
|
if (resource || silent)
|
|
1989
1992
|
return resource;
|
|
1990
|
-
throw new
|
|
1993
|
+
throw new ResourceNotAvailableError(path);
|
|
1991
1994
|
}
|
|
1992
1995
|
getContainer(path, silent) {
|
|
1993
1996
|
const t = this.getResource(path);
|
|
@@ -2138,13 +2141,13 @@ function ComplexTypeDecorator(options) {
|
|
|
2138
2141
|
__name(ComplexTypeDecorator, "ComplexTypeDecorator");
|
|
2139
2142
|
|
|
2140
2143
|
// ../../build/common/esm/document/data-type/complex-type-class.js
|
|
2141
|
-
import
|
|
2144
|
+
import { vg as vg3 } from "valgen";
|
|
2142
2145
|
|
|
2143
2146
|
// ../../build/common/esm/document/data-type/field.js
|
|
2144
2147
|
import merge4 from "putil-merge";
|
|
2145
2148
|
|
|
2146
2149
|
// ../../build/common/esm/document/data-type/field-class.js
|
|
2147
|
-
import
|
|
2150
|
+
import { isUndefined, vg as vg2 } from "valgen";
|
|
2148
2151
|
var FieldClass = class {
|
|
2149
2152
|
static {
|
|
2150
2153
|
__name(this, "FieldClass");
|
|
@@ -2166,7 +2169,7 @@ var FieldClass = class {
|
|
|
2166
2169
|
this.translatable = init.translatable;
|
|
2167
2170
|
this.deprecated = init.deprecated;
|
|
2168
2171
|
this.examples = init.examples;
|
|
2169
|
-
this.
|
|
2172
|
+
this.pattern = init.pattern ? init.pattern instanceof RegExp ? init.pattern : new RegExp(init.pattern) : void 0;
|
|
2170
2173
|
this.partialUpdate = init.partialUpdate;
|
|
2171
2174
|
}
|
|
2172
2175
|
exportSchema(options) {
|
|
@@ -2184,23 +2187,25 @@ var FieldClass = class {
|
|
|
2184
2187
|
translatable: this.translatable,
|
|
2185
2188
|
deprecated: this.deprecated,
|
|
2186
2189
|
examples: this.examples,
|
|
2187
|
-
|
|
2190
|
+
pattern: this.pattern ? String(this.pattern) : void 0,
|
|
2188
2191
|
partialUpdate: this.partialUpdate
|
|
2189
2192
|
});
|
|
2190
2193
|
}
|
|
2191
2194
|
generateCodec(codec, options) {
|
|
2192
2195
|
if (options?.operation === "read" && this.writeonly)
|
|
2193
|
-
return
|
|
2196
|
+
return isUndefined;
|
|
2194
2197
|
if (options?.operation === "write" && this.readonly)
|
|
2195
|
-
return
|
|
2198
|
+
return isUndefined;
|
|
2196
2199
|
let fn = this.type.generateCodec(codec, {
|
|
2197
2200
|
...options,
|
|
2198
2201
|
designType: this.designType,
|
|
2199
2202
|
partial: options?.partial && (this.partialUpdate || !this.isArray)
|
|
2200
2203
|
});
|
|
2204
|
+
if (this.pattern)
|
|
2205
|
+
fn = vg2.allOf(fn, vg2.isRegExp(this.pattern));
|
|
2201
2206
|
if (this.isArray)
|
|
2202
|
-
fn =
|
|
2203
|
-
return !options?.partial && this.required ?
|
|
2207
|
+
fn = vg2.isArray(fn);
|
|
2208
|
+
return !options?.partial && this.required ? vg2.required(fn) : vg2.optional(fn);
|
|
2204
2209
|
}
|
|
2205
2210
|
};
|
|
2206
2211
|
|
|
@@ -2399,7 +2404,7 @@ var ComplexTypeClass = class extends DataType {
|
|
|
2399
2404
|
caseSensitive: options?.caseSensitive,
|
|
2400
2405
|
partial: options?.partial
|
|
2401
2406
|
}) : this.additionalFields;
|
|
2402
|
-
return
|
|
2407
|
+
return vg3.isObject(schema, {
|
|
2403
2408
|
ctor: this.ctor,
|
|
2404
2409
|
additionalFields,
|
|
2405
2410
|
name: this.name,
|
|
@@ -2499,7 +2504,7 @@ import "reflect-metadata";
|
|
|
2499
2504
|
import merge6 from "putil-merge";
|
|
2500
2505
|
|
|
2501
2506
|
// ../../build/common/esm/document/data-type/enum-type-class.js
|
|
2502
|
-
import
|
|
2507
|
+
import { vg as vg4 } from "valgen";
|
|
2503
2508
|
var EnumTypeClass = class extends DataType {
|
|
2504
2509
|
static {
|
|
2505
2510
|
__name(this, "EnumTypeClass");
|
|
@@ -2511,11 +2516,11 @@ var EnumTypeClass = class extends DataType {
|
|
|
2511
2516
|
this.base = init.base;
|
|
2512
2517
|
this.ownValues = { ...init.values };
|
|
2513
2518
|
this.values = { ...this.base?.values, ...this.ownValues };
|
|
2514
|
-
this.decode =
|
|
2515
|
-
this.encode =
|
|
2519
|
+
this.decode = vg4.isEnum(Object.keys(this.values));
|
|
2520
|
+
this.encode = vg4.isEnum(Object.keys(this.values));
|
|
2516
2521
|
}
|
|
2517
2522
|
isTypeOf(t) {
|
|
2518
|
-
return t[DATATYPE_METADATA] === this.enumObject?.[DATATYPE_METADATA];
|
|
2523
|
+
return t[DATATYPE_METADATA] && t[DATATYPE_METADATA] === this.enumObject?.[DATATYPE_METADATA];
|
|
2519
2524
|
}
|
|
2520
2525
|
exportSchema() {
|
|
2521
2526
|
const out = super.exportSchema();
|
|
@@ -2847,7 +2852,7 @@ function SimpleTypeDecorator(options) {
|
|
|
2847
2852
|
__name(SimpleTypeDecorator, "SimpleTypeDecorator");
|
|
2848
2853
|
|
|
2849
2854
|
// ../../build/common/esm/document/data-type/simple-type-class.js
|
|
2850
|
-
import
|
|
2855
|
+
import { isAny as isAny2 } from "valgen";
|
|
2851
2856
|
var SimpleTypeClass = class extends DataType {
|
|
2852
2857
|
static {
|
|
2853
2858
|
__name(this, "SimpleTypeClass");
|
|
@@ -2856,8 +2861,8 @@ var SimpleTypeClass = class extends DataType {
|
|
|
2856
2861
|
super(document, init);
|
|
2857
2862
|
this.kind = opra_schema_ns_exports.SimpleType.Kind;
|
|
2858
2863
|
this.base = init.base;
|
|
2859
|
-
this.decode = init.decoder || init.base?.decode ||
|
|
2860
|
-
this.encode = init.encoder || init.base?.encode ||
|
|
2864
|
+
this.decode = init.decoder || init.base?.decode || isAny2;
|
|
2865
|
+
this.encode = init.encoder || init.base?.encode || isAny2;
|
|
2861
2866
|
}
|
|
2862
2867
|
exportSchema(options) {
|
|
2863
2868
|
const out = super.exportSchema(options);
|
|
@@ -2902,7 +2907,7 @@ AnyType = __decorate([
|
|
|
2902
2907
|
], AnyType);
|
|
2903
2908
|
|
|
2904
2909
|
// ../../build/common/esm/document/data-type/builtin/approx-date.type.js
|
|
2905
|
-
import {
|
|
2910
|
+
import { vg as vg5 } from "valgen";
|
|
2906
2911
|
var ApproxDateType = class ApproxDateType2 {
|
|
2907
2912
|
static {
|
|
2908
2913
|
__name(this, "ApproxDateType");
|
|
@@ -2916,13 +2921,13 @@ ApproxDateType = __decorate([
|
|
|
2916
2921
|
"2021-04",
|
|
2917
2922
|
"2021"
|
|
2918
2923
|
],
|
|
2919
|
-
decoder: isDateString({ trim: "date" }),
|
|
2920
|
-
encoder: isDateString({ trim: "date" })
|
|
2924
|
+
decoder: vg5.isDateString({ trim: "date" }),
|
|
2925
|
+
encoder: vg5.isDateString({ trim: "date" })
|
|
2921
2926
|
})
|
|
2922
2927
|
], ApproxDateType);
|
|
2923
2928
|
|
|
2924
2929
|
// ../../build/common/esm/document/data-type/builtin/approx-datetime.type.js
|
|
2925
|
-
import { isDateString
|
|
2930
|
+
import { isDateString } from "valgen";
|
|
2926
2931
|
var ApproxDatetimeType = class ApproxDatetimeType2 {
|
|
2927
2932
|
static {
|
|
2928
2933
|
__name(this, "ApproxDatetimeType");
|
|
@@ -2939,8 +2944,8 @@ ApproxDatetimeType = __decorate([
|
|
|
2939
2944
|
"2021-04",
|
|
2940
2945
|
"2021"
|
|
2941
2946
|
],
|
|
2942
|
-
decoder:
|
|
2943
|
-
encoder:
|
|
2947
|
+
decoder: isDateString,
|
|
2948
|
+
encoder: isDateString
|
|
2944
2949
|
})
|
|
2945
2950
|
], ApproxDatetimeType);
|
|
2946
2951
|
|
|
@@ -2954,13 +2959,13 @@ var Base64Type = class Base64Type2 {
|
|
|
2954
2959
|
Base64Type = __decorate([
|
|
2955
2960
|
SimpleType2({
|
|
2956
2961
|
description: "A stream of bytes, base64 encoded",
|
|
2957
|
-
decoder: isBase64
|
|
2958
|
-
encoder: isBase64
|
|
2962
|
+
decoder: isBase64,
|
|
2963
|
+
encoder: isBase64
|
|
2959
2964
|
})
|
|
2960
2965
|
], Base64Type);
|
|
2961
2966
|
|
|
2962
2967
|
// ../../build/common/esm/document/data-type/builtin/bigint.type.js
|
|
2963
|
-
import { isBigint, isString,
|
|
2968
|
+
import { isBigint, isString, vg as vg6 } from "valgen";
|
|
2964
2969
|
var BigintType = class BigintType2 {
|
|
2965
2970
|
static {
|
|
2966
2971
|
__name(this, "BigintType");
|
|
@@ -2969,8 +2974,8 @@ var BigintType = class BigintType2 {
|
|
|
2969
2974
|
BigintType = __decorate([
|
|
2970
2975
|
SimpleType2({
|
|
2971
2976
|
description: "BigInt number",
|
|
2972
|
-
decoder: isBigint
|
|
2973
|
-
encoder: pipe(isBigint
|
|
2977
|
+
decoder: isBigint,
|
|
2978
|
+
encoder: vg6.pipe(isBigint, isString)
|
|
2974
2979
|
})
|
|
2975
2980
|
], BigintType);
|
|
2976
2981
|
|
|
@@ -2984,13 +2989,13 @@ var BooleanType = class BooleanType2 {
|
|
|
2984
2989
|
BooleanType = __decorate([
|
|
2985
2990
|
SimpleType2({
|
|
2986
2991
|
description: "Simple true/false value",
|
|
2987
|
-
decoder: isBoolean
|
|
2988
|
-
encoder: isBoolean
|
|
2992
|
+
decoder: isBoolean,
|
|
2993
|
+
encoder: isBoolean
|
|
2989
2994
|
})
|
|
2990
2995
|
], BooleanType);
|
|
2991
2996
|
|
|
2992
2997
|
// ../../build/common/esm/document/data-type/builtin/date.type.js
|
|
2993
|
-
import {
|
|
2998
|
+
import { vg as vg7 } from "valgen";
|
|
2994
2999
|
var DateType = class DateType2 {
|
|
2995
3000
|
static {
|
|
2996
3001
|
__name(this, "DateType");
|
|
@@ -3000,13 +3005,13 @@ DateType = __decorate([
|
|
|
3000
3005
|
SimpleType2({
|
|
3001
3006
|
description: "A date without time",
|
|
3002
3007
|
example: ["2021-04-18"],
|
|
3003
|
-
decoder: isDate({ precision: "date" }),
|
|
3004
|
-
encoder:
|
|
3008
|
+
decoder: vg7.isDate({ precision: "date" }),
|
|
3009
|
+
encoder: vg7.isDateString({ precision: "date", trim: "date" })
|
|
3005
3010
|
})
|
|
3006
3011
|
], DateType);
|
|
3007
3012
|
|
|
3008
3013
|
// ../../build/common/esm/document/data-type/builtin/datetime.type.js
|
|
3009
|
-
import {
|
|
3014
|
+
import { vg as vg8 } from "valgen";
|
|
3010
3015
|
var DatetimeType = class DatetimeType2 {
|
|
3011
3016
|
static {
|
|
3012
3017
|
__name(this, "DatetimeType");
|
|
@@ -3020,13 +3025,13 @@ DatetimeType = __decorate([
|
|
|
3020
3025
|
"2021-04-18 22:30:15",
|
|
3021
3026
|
"2021-04-18 22:30"
|
|
3022
3027
|
],
|
|
3023
|
-
decoder:
|
|
3024
|
-
encoder:
|
|
3028
|
+
decoder: vg8.isDate({ precision: "time" }),
|
|
3029
|
+
encoder: vg8.isDateString({ precision: "time", trim: "time" })
|
|
3025
3030
|
})
|
|
3026
3031
|
], DatetimeType);
|
|
3027
3032
|
|
|
3028
3033
|
// ../../build/common/esm/document/data-type/builtin/email.type.js
|
|
3029
|
-
import {
|
|
3034
|
+
import { vg as vg9 } from "valgen";
|
|
3030
3035
|
var EmailType = class EmailType2 {
|
|
3031
3036
|
static {
|
|
3032
3037
|
__name(this, "EmailType");
|
|
@@ -3035,8 +3040,8 @@ var EmailType = class EmailType2 {
|
|
|
3035
3040
|
EmailType = __decorate([
|
|
3036
3041
|
SimpleType2({
|
|
3037
3042
|
description: "An email value",
|
|
3038
|
-
decoder: isEmail(),
|
|
3039
|
-
encoder: isEmail()
|
|
3043
|
+
decoder: vg9.isEmail(),
|
|
3044
|
+
encoder: vg9.isEmail()
|
|
3040
3045
|
})
|
|
3041
3046
|
], EmailType);
|
|
3042
3047
|
|
|
@@ -3050,8 +3055,8 @@ var IntegerType = class IntegerType2 {
|
|
|
3050
3055
|
IntegerType = __decorate([
|
|
3051
3056
|
SimpleType2({
|
|
3052
3057
|
description: "An integer number",
|
|
3053
|
-
decoder: isInteger
|
|
3054
|
-
encoder: isInteger
|
|
3058
|
+
decoder: isInteger,
|
|
3059
|
+
encoder: isInteger
|
|
3055
3060
|
})
|
|
3056
3061
|
], IntegerType);
|
|
3057
3062
|
|
|
@@ -3065,8 +3070,8 @@ var NullType = class NullType2 {
|
|
|
3065
3070
|
NullType = __decorate([
|
|
3066
3071
|
SimpleType2({
|
|
3067
3072
|
description: "A Null value",
|
|
3068
|
-
decoder: isNull
|
|
3069
|
-
encoder: isNull
|
|
3073
|
+
decoder: isNull,
|
|
3074
|
+
encoder: isNull
|
|
3070
3075
|
})
|
|
3071
3076
|
], NullType);
|
|
3072
3077
|
|
|
@@ -3080,8 +3085,8 @@ var NumberType = class NumberType2 {
|
|
|
3080
3085
|
NumberType = __decorate([
|
|
3081
3086
|
SimpleType2({
|
|
3082
3087
|
description: "Both Integer as well as Floating-Point numbers",
|
|
3083
|
-
decoder: isNumber
|
|
3084
|
-
encoder: isNumber
|
|
3088
|
+
decoder: isNumber,
|
|
3089
|
+
encoder: isNumber
|
|
3085
3090
|
})
|
|
3086
3091
|
], NumberType);
|
|
3087
3092
|
|
|
@@ -3101,7 +3106,7 @@ ObjectType = __decorate([
|
|
|
3101
3106
|
], ObjectType);
|
|
3102
3107
|
|
|
3103
3108
|
// ../../build/common/esm/document/data-type/builtin/object-id.type.js
|
|
3104
|
-
import { isObjectId, isString as isString2,
|
|
3109
|
+
import { isObjectId, isString as isString2, vg as vg10 } from "valgen";
|
|
3105
3110
|
var ObjectIdType = class ObjectIdType2 {
|
|
3106
3111
|
static {
|
|
3107
3112
|
__name(this, "ObjectIdType");
|
|
@@ -3110,8 +3115,8 @@ var ObjectIdType = class ObjectIdType2 {
|
|
|
3110
3115
|
ObjectIdType = __decorate([
|
|
3111
3116
|
SimpleType2({
|
|
3112
3117
|
description: "A MongoDB ObjectID value",
|
|
3113
|
-
decoder: isObjectId
|
|
3114
|
-
encoder:
|
|
3118
|
+
decoder: isObjectId,
|
|
3119
|
+
encoder: vg10.pipe(isObjectId, isString2)
|
|
3115
3120
|
})
|
|
3116
3121
|
], ObjectIdType);
|
|
3117
3122
|
|
|
@@ -3125,13 +3130,13 @@ var StringType = class StringType2 {
|
|
|
3125
3130
|
StringType = __decorate([
|
|
3126
3131
|
SimpleType2({
|
|
3127
3132
|
description: "A sequence of characters",
|
|
3128
|
-
decoder: isString3
|
|
3129
|
-
encoder: isString3
|
|
3133
|
+
decoder: isString3,
|
|
3134
|
+
encoder: isString3
|
|
3130
3135
|
})
|
|
3131
3136
|
], StringType);
|
|
3132
3137
|
|
|
3133
3138
|
// ../../build/common/esm/document/data-type/builtin/time.type.js
|
|
3134
|
-
import {
|
|
3139
|
+
import { vg as vg11 } from "valgen";
|
|
3135
3140
|
var TIME_PATTERN = /^([0-1][0-9]|2[0-4]):([0-5][0-9])(?::([0-5][0-9]))?$/;
|
|
3136
3141
|
var TimeType = class TimeType2 {
|
|
3137
3142
|
static {
|
|
@@ -3141,11 +3146,11 @@ var TimeType = class TimeType2 {
|
|
|
3141
3146
|
TimeType = __decorate([
|
|
3142
3147
|
SimpleType2({
|
|
3143
3148
|
description: "Time string in 24h format, for example, 18:23:00",
|
|
3144
|
-
decoder:
|
|
3149
|
+
decoder: vg11.isRegExp(TIME_PATTERN, {
|
|
3145
3150
|
formatName: "time",
|
|
3146
3151
|
onFail: () => "{{label}} is not a valid time"
|
|
3147
3152
|
}),
|
|
3148
|
-
encoder:
|
|
3153
|
+
encoder: vg11.isRegExp(TIME_PATTERN, {
|
|
3149
3154
|
formatName: "time",
|
|
3150
3155
|
onFail: () => "{{label}} is not a valid time"
|
|
3151
3156
|
})
|
|
@@ -3162,8 +3167,8 @@ var UrlType = class UrlType2 {
|
|
|
3162
3167
|
UrlType = __decorate([
|
|
3163
3168
|
SimpleType2({
|
|
3164
3169
|
description: "A Uniform Resource Identifier Reference (RFC 3986 icon) value",
|
|
3165
|
-
decoder: isURL2
|
|
3166
|
-
encoder: isURL2
|
|
3170
|
+
decoder: isURL2,
|
|
3171
|
+
encoder: isURL2
|
|
3167
3172
|
})
|
|
3168
3173
|
], UrlType);
|
|
3169
3174
|
|
|
@@ -3177,8 +3182,8 @@ var UuidType = class UuidType2 {
|
|
|
3177
3182
|
UuidType = __decorate([
|
|
3178
3183
|
SimpleType2({
|
|
3179
3184
|
description: "A Universal Unique Identifier (UUID) value",
|
|
3180
|
-
decoder: isUUID
|
|
3181
|
-
encoder: isUUID
|
|
3185
|
+
decoder: isUUID,
|
|
3186
|
+
encoder: isUUID
|
|
3182
3187
|
})
|
|
3183
3188
|
], UuidType);
|
|
3184
3189
|
|
|
@@ -3676,7 +3681,7 @@ TypeDocumentFactory.designTypeMap = /* @__PURE__ */ new Map();
|
|
|
3676
3681
|
import merge10 from "putil-merge";
|
|
3677
3682
|
|
|
3678
3683
|
// ../../build/common/esm/document/resource/collection-class.js
|
|
3679
|
-
import
|
|
3684
|
+
import { vg as vg13 } from "valgen";
|
|
3680
3685
|
|
|
3681
3686
|
// ../../build/common/esm/filter/opra-filter.ns.js
|
|
3682
3687
|
var opra_filter_ns_exports = {};
|
|
@@ -3886,9 +3891,9 @@ var SyntaxError = class extends TypeError {
|
|
|
3886
3891
|
__name(this, "SyntaxError");
|
|
3887
3892
|
}
|
|
3888
3893
|
};
|
|
3889
|
-
var
|
|
3894
|
+
var FilterValidationError = class extends TypeError {
|
|
3890
3895
|
static {
|
|
3891
|
-
__name(this, "
|
|
3896
|
+
__name(this, "FilterValidationError");
|
|
3892
3897
|
}
|
|
3893
3898
|
constructor(message) {
|
|
3894
3899
|
super(typeof message === "string" ? message : message?.message);
|
|
@@ -3946,7 +3951,7 @@ var DateLiteral = class extends Literal {
|
|
|
3946
3951
|
this.value = value;
|
|
3947
3952
|
return;
|
|
3948
3953
|
}
|
|
3949
|
-
throw new
|
|
3954
|
+
throw new FilterValidationError(`Invalid date value "${value}"`);
|
|
3950
3955
|
}
|
|
3951
3956
|
toString() {
|
|
3952
3957
|
return quoteFilterString(this.value);
|
|
@@ -3990,7 +3995,7 @@ var NumberLiteral = class extends Literal {
|
|
|
3990
3995
|
}
|
|
3991
3996
|
} catch {
|
|
3992
3997
|
}
|
|
3993
|
-
throw new
|
|
3998
|
+
throw new FilterValidationError(`Invalid number literal ${value}`);
|
|
3994
3999
|
}
|
|
3995
4000
|
toString() {
|
|
3996
4001
|
return typeof this.value === "bigint" ? ("" + this.value).replace(/n$/, "") : "" + this.value;
|
|
@@ -4036,7 +4041,7 @@ var TimeLiteral = class extends Literal {
|
|
|
4036
4041
|
this.value = value;
|
|
4037
4042
|
return;
|
|
4038
4043
|
}
|
|
4039
|
-
throw new
|
|
4044
|
+
throw new FilterValidationError(`Invalid time value "${value}"`);
|
|
4040
4045
|
}
|
|
4041
4046
|
toString() {
|
|
4042
4047
|
return quoteFilterString(this.value);
|
|
@@ -11190,7 +11195,7 @@ var _wrapEntryValue = /* @__PURE__ */ __name((v) => {
|
|
|
11190
11195
|
}, "_wrapEntryValue");
|
|
11191
11196
|
|
|
11192
11197
|
// ../../build/common/esm/document/resource/crud-operation.js
|
|
11193
|
-
import
|
|
11198
|
+
import { vg as vg12 } from "valgen";
|
|
11194
11199
|
var CrudOperation = class extends Endpoint {
|
|
11195
11200
|
static {
|
|
11196
11201
|
__name(this, "CrudOperation");
|
|
@@ -11200,8 +11205,8 @@ var CrudOperation = class extends Endpoint {
|
|
|
11200
11205
|
this.resource = resource;
|
|
11201
11206
|
this.name = name;
|
|
11202
11207
|
this.kind = "operation";
|
|
11203
|
-
this.decodeInput =
|
|
11204
|
-
this.encodeReturning =
|
|
11208
|
+
this.decodeInput = vg12.isAny();
|
|
11209
|
+
this.encodeReturning = vg12.isAny();
|
|
11205
11210
|
this.returnType = init.returnType instanceof DataType ? init.returnType : this.resource.document.getDataType(init.returnType || "any");
|
|
11206
11211
|
this.encodeReturning = this.returnType.generateCodec("encode", { operation: "read" });
|
|
11207
11212
|
this.inputOverwriteFields = init.options?.inputOverwriteFields;
|
|
@@ -11325,7 +11330,7 @@ var CollectionClass = class extends CrudResource {
|
|
|
11325
11330
|
endpoint.defineParameter("distinct", { type: "boolean", isBuiltin: true });
|
|
11326
11331
|
endpoint.defineParameter("count", { type: "boolean", isBuiltin: true });
|
|
11327
11332
|
endpoint.returnType = this.type;
|
|
11328
|
-
endpoint.encodeReturning =
|
|
11333
|
+
endpoint.encodeReturning = vg13.isArray(this.type.generateCodec("encode", {
|
|
11329
11334
|
partial: true,
|
|
11330
11335
|
pick: endpoint.options.outputPickFields,
|
|
11331
11336
|
omit: endpoint.options.outputOmitFields,
|
|
@@ -11358,6 +11363,7 @@ var CollectionClass = class extends CrudResource {
|
|
|
11358
11363
|
if (endpoint) {
|
|
11359
11364
|
endpoint.defineParameter("filter", { type: "string", isBuiltin: true });
|
|
11360
11365
|
endpoint.decodeInput = this.type.generateCodec("decode", {
|
|
11366
|
+
partial: true,
|
|
11361
11367
|
pick: endpoint.options.inputPickFields,
|
|
11362
11368
|
omit: endpoint.options.inputOmitFields,
|
|
11363
11369
|
operation: "write",
|
|
@@ -12291,11 +12297,12 @@ export {
|
|
|
12291
12297
|
OpraURLPathComponent,
|
|
12292
12298
|
Parameter,
|
|
12293
12299
|
PartialType,
|
|
12300
|
+
PermissionError,
|
|
12294
12301
|
PickType,
|
|
12295
12302
|
RESOURCE_METADATA,
|
|
12296
12303
|
Resource,
|
|
12297
12304
|
ResourceConflictError,
|
|
12298
|
-
|
|
12305
|
+
ResourceNotAvailableError,
|
|
12299
12306
|
ResponsiveMap,
|
|
12300
12307
|
SORT_FIELD_PATTERN,
|
|
12301
12308
|
SimpleType2 as SimpleType,
|
|
@@ -12306,7 +12313,6 @@ export {
|
|
|
12306
12313
|
TypeDocumentFactory,
|
|
12307
12314
|
UnauthorizedError,
|
|
12308
12315
|
UnprocessableEntityError,
|
|
12309
|
-
ValidationError,
|
|
12310
12316
|
cloneObject,
|
|
12311
12317
|
getStackFileName,
|
|
12312
12318
|
i18n,
|
|
@@ -15,7 +15,7 @@ exports.ApproxDateType = ApproxDateType = tslib_1.__decorate([
|
|
|
15
15
|
'2021-04',
|
|
16
16
|
'2021',
|
|
17
17
|
],
|
|
18
|
-
decoder:
|
|
19
|
-
encoder:
|
|
18
|
+
decoder: valgen_1.vg.isDateString({ trim: 'date' }),
|
|
19
|
+
encoder: valgen_1.vg.isDateString({ trim: 'date' })
|
|
20
20
|
})
|
|
21
21
|
], ApproxDateType);
|
|
@@ -18,7 +18,7 @@ exports.ApproxDatetimeType = ApproxDatetimeType = tslib_1.__decorate([
|
|
|
18
18
|
'2021-04',
|
|
19
19
|
'2021',
|
|
20
20
|
],
|
|
21
|
-
decoder:
|
|
22
|
-
encoder:
|
|
21
|
+
decoder: valgen_1.isDateString,
|
|
22
|
+
encoder: valgen_1.isDateString
|
|
23
23
|
})
|
|
24
24
|
], ApproxDatetimeType);
|
|
@@ -10,7 +10,7 @@ exports.Base64Type = Base64Type;
|
|
|
10
10
|
exports.Base64Type = Base64Type = tslib_1.__decorate([
|
|
11
11
|
(0, simple_type_js_1.SimpleType)({
|
|
12
12
|
description: 'A stream of bytes, base64 encoded',
|
|
13
|
-
decoder:
|
|
14
|
-
encoder:
|
|
13
|
+
decoder: valgen_1.isBase64,
|
|
14
|
+
encoder: valgen_1.isBase64,
|
|
15
15
|
})
|
|
16
16
|
], Base64Type);
|
|
@@ -10,7 +10,7 @@ exports.BigintType = BigintType;
|
|
|
10
10
|
exports.BigintType = BigintType = tslib_1.__decorate([
|
|
11
11
|
(0, simple_type_js_1.SimpleType)({
|
|
12
12
|
description: 'BigInt number',
|
|
13
|
-
decoder:
|
|
14
|
-
encoder:
|
|
13
|
+
decoder: valgen_1.isBigint,
|
|
14
|
+
encoder: valgen_1.vg.pipe(valgen_1.isBigint, valgen_1.isString)
|
|
15
15
|
})
|
|
16
16
|
], BigintType);
|
|
@@ -10,7 +10,7 @@ exports.BooleanType = BooleanType;
|
|
|
10
10
|
exports.BooleanType = BooleanType = tslib_1.__decorate([
|
|
11
11
|
(0, simple_type_js_1.SimpleType)({
|
|
12
12
|
description: 'Simple true/false value',
|
|
13
|
-
decoder:
|
|
14
|
-
encoder:
|
|
13
|
+
decoder: valgen_1.isBoolean,
|
|
14
|
+
encoder: valgen_1.isBoolean
|
|
15
15
|
})
|
|
16
16
|
], BooleanType);
|
|
@@ -11,7 +11,7 @@ exports.DateType = DateType = tslib_1.__decorate([
|
|
|
11
11
|
(0, simple_type_js_1.SimpleType)({
|
|
12
12
|
description: 'A date without time',
|
|
13
13
|
example: ['2021-04-18'],
|
|
14
|
-
decoder:
|
|
15
|
-
encoder:
|
|
14
|
+
decoder: valgen_1.vg.isDate({ precision: 'date' }),
|
|
15
|
+
encoder: valgen_1.vg.isDateString({ precision: 'date', trim: 'date' })
|
|
16
16
|
})
|
|
17
17
|
], DateType);
|
|
@@ -15,7 +15,7 @@ exports.DatetimeType = DatetimeType = tslib_1.__decorate([
|
|
|
15
15
|
'2021-04-18 22:30:15',
|
|
16
16
|
'2021-04-18 22:30'
|
|
17
17
|
],
|
|
18
|
-
decoder:
|
|
19
|
-
encoder:
|
|
18
|
+
decoder: valgen_1.vg.isDate({ precision: 'time' }),
|
|
19
|
+
encoder: valgen_1.vg.isDateString({ precision: 'time', trim: 'time' })
|
|
20
20
|
})
|
|
21
21
|
], DatetimeType);
|
|
@@ -10,7 +10,7 @@ exports.EmailType = EmailType;
|
|
|
10
10
|
exports.EmailType = EmailType = tslib_1.__decorate([
|
|
11
11
|
(0, simple_type_js_1.SimpleType)({
|
|
12
12
|
description: 'An email value',
|
|
13
|
-
decoder:
|
|
14
|
-
encoder:
|
|
13
|
+
decoder: valgen_1.vg.isEmail(),
|
|
14
|
+
encoder: valgen_1.vg.isEmail()
|
|
15
15
|
})
|
|
16
16
|
], EmailType);
|
|
@@ -10,7 +10,7 @@ exports.IntegerType = IntegerType;
|
|
|
10
10
|
exports.IntegerType = IntegerType = tslib_1.__decorate([
|
|
11
11
|
(0, simple_type_js_1.SimpleType)({
|
|
12
12
|
description: 'An integer number',
|
|
13
|
-
decoder:
|
|
14
|
-
encoder:
|
|
13
|
+
decoder: valgen_1.isInteger,
|
|
14
|
+
encoder: valgen_1.isInteger
|
|
15
15
|
})
|
|
16
16
|
], IntegerType);
|
|
@@ -10,7 +10,7 @@ exports.NullType = NullType;
|
|
|
10
10
|
exports.NullType = NullType = tslib_1.__decorate([
|
|
11
11
|
(0, simple_type_js_1.SimpleType)({
|
|
12
12
|
description: 'A Null value',
|
|
13
|
-
decoder:
|
|
14
|
-
encoder:
|
|
13
|
+
decoder: valgen_1.isNull,
|
|
14
|
+
encoder: valgen_1.isNull
|
|
15
15
|
})
|
|
16
16
|
], NullType);
|
|
@@ -10,7 +10,7 @@ exports.NumberType = NumberType;
|
|
|
10
10
|
exports.NumberType = NumberType = tslib_1.__decorate([
|
|
11
11
|
(0, simple_type_js_1.SimpleType)({
|
|
12
12
|
description: 'Both Integer as well as Floating-Point numbers',
|
|
13
|
-
decoder:
|
|
14
|
-
encoder:
|
|
13
|
+
decoder: valgen_1.isNumber,
|
|
14
|
+
encoder: valgen_1.isNumber
|
|
15
15
|
})
|
|
16
16
|
], NumberType);
|
|
@@ -10,7 +10,7 @@ exports.ObjectIdType = ObjectIdType;
|
|
|
10
10
|
exports.ObjectIdType = ObjectIdType = tslib_1.__decorate([
|
|
11
11
|
(0, simple_type_js_1.SimpleType)({
|
|
12
12
|
description: 'A MongoDB ObjectID value',
|
|
13
|
-
decoder:
|
|
14
|
-
encoder:
|
|
13
|
+
decoder: valgen_1.isObjectId,
|
|
14
|
+
encoder: valgen_1.vg.pipe(valgen_1.isObjectId, valgen_1.isString)
|
|
15
15
|
})
|
|
16
16
|
], ObjectIdType);
|