@opra/common 0.15.0 → 0.16.1
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/cjs/document/factory/import-resource-class.js +1 -0
- package/cjs/document/factory/import-type-class.js +9 -2
- package/cjs/document/resource/collection.js +9 -9
- package/cjs/document/resource/singleton.js +4 -4
- package/cjs/url/opra-url.js +7 -7
- package/esm/document/api-document.js +37 -33
- package/esm/document/constants.js +6 -3
- package/esm/document/data-type/api-field.js +15 -12
- package/esm/document/data-type/builtin/any.type.js +8 -5
- package/esm/document/data-type/builtin/base64.type.js +8 -5
- package/esm/document/data-type/builtin/bigint.type.js +8 -5
- package/esm/document/data-type/builtin/boolean.type.js +11 -8
- package/esm/document/data-type/builtin/date.type.js +10 -7
- package/esm/document/data-type/builtin/guid.type.js +12 -9
- package/esm/document/data-type/builtin/index.js +13 -10
- package/esm/document/data-type/builtin/integer.type.js +13 -10
- package/esm/document/data-type/builtin/number.type.js +10 -7
- package/esm/document/data-type/builtin/object.type.js +8 -5
- package/esm/document/data-type/builtin/string.type.js +11 -8
- package/esm/document/data-type/builtin/time.type.js +10 -7
- package/esm/document/data-type/builtin/timestamp.type.js +12 -9
- package/esm/document/data-type/complex-type.js +34 -30
- package/esm/document/data-type/data-type.js +12 -9
- package/esm/document/data-type/enum-type.js +19 -15
- package/esm/document/data-type/mapped-type.js +29 -24
- package/esm/document/data-type/simple-type.js +21 -17
- package/esm/document/data-type/union-type.js +29 -26
- package/esm/document/factory/add-references.js +7 -3
- package/esm/document/factory/create-document.js +16 -10
- package/esm/document/factory/factory.js +37 -33
- package/esm/document/factory/import-resource-class.js +22 -15
- package/esm/document/factory/import-type-class.js +43 -26
- package/esm/document/factory/index.js +4 -1
- package/esm/document/factory/process-resources.js +16 -10
- package/esm/document/factory/process-types.js +37 -31
- package/esm/document/index.js +17 -14
- package/esm/document/resource/collection.js +50 -46
- package/esm/document/resource/resource.js +12 -9
- package/esm/document/resource/singleton.js +29 -25
- package/esm/document/utils/inspect.util.js +7 -4
- package/esm/document/utils/string-compare.util.js +5 -1
- package/esm/exception/enums/issue-severity.enum.js +5 -2
- package/esm/exception/error-issue.js +2 -1
- package/esm/exception/http-errors/bad-request.error.js +8 -4
- package/esm/exception/http-errors/failed-dependency.error.js +8 -4
- package/esm/exception/http-errors/forbidden.error.js +8 -4
- package/esm/exception/http-errors/internal-server.error.js +8 -4
- package/esm/exception/http-errors/method-not-allowed.error.js +8 -4
- package/esm/exception/http-errors/not-acceptable.error.js +8 -4
- package/esm/exception/http-errors/not-found.error.js +8 -4
- package/esm/exception/http-errors/unauthorized.error.js +8 -4
- package/esm/exception/http-errors/unprocessable-entity.error.js +8 -4
- package/esm/exception/index.js +18 -15
- package/esm/exception/opra-exception.js +7 -3
- package/esm/exception/resource-errors/resource-conflict.error.js +8 -4
- package/esm/exception/resource-errors/resource-not-found.error.js +8 -4
- package/esm/exception/wrap-exception.js +24 -20
- package/esm/filter/antlr/OpraFilterLexer.js +9 -6
- package/esm/filter/antlr/OpraFilterListener.js +5 -2
- package/esm/filter/antlr/OpraFilterParser.js +126 -79
- package/esm/filter/antlr/OpraFilterVisitor.js +5 -2
- package/esm/filter/ast/abstract/ast.js +5 -1
- package/esm/filter/ast/abstract/expression.js +6 -2
- package/esm/filter/ast/abstract/literal.js +6 -2
- package/esm/filter/ast/abstract/term.js +6 -2
- package/esm/filter/ast/expressions/arithmetic-expression.js +8 -3
- package/esm/filter/ast/expressions/array-expression.js +6 -2
- package/esm/filter/ast/expressions/comparison-expression.js +6 -2
- package/esm/filter/ast/expressions/logical-expression.js +6 -2
- package/esm/filter/ast/expressions/parentheses-expression.js +6 -2
- package/esm/filter/ast/index.js +19 -16
- package/esm/filter/ast/terms/boolean-literal.js +6 -2
- package/esm/filter/ast/terms/date-literal.js +12 -8
- package/esm/filter/ast/terms/external-constant.js +6 -2
- package/esm/filter/ast/terms/null-literal.js +6 -2
- package/esm/filter/ast/terms/number-literal.js +8 -4
- package/esm/filter/ast/terms/qualified-identifier.js +6 -2
- package/esm/filter/ast/terms/string-literal.js +8 -4
- package/esm/filter/ast/terms/time-literal.js +10 -6
- package/esm/filter/build.js +69 -45
- package/esm/filter/errors.js +9 -3
- package/esm/filter/filter-tree-visitor.js +31 -26
- package/esm/filter/index.js +8 -5
- package/esm/filter/opra-error-listener.js +8 -4
- package/esm/filter/parse.js +19 -14
- package/esm/filter/utils.js +7 -2
- package/esm/helpers/function-utils.js +14 -8
- package/esm/helpers/get-stack-filename.js +5 -1
- package/esm/helpers/index.js +11 -8
- package/esm/helpers/is-url.js +5 -1
- package/esm/helpers/mixin-utils.js +7 -2
- package/esm/helpers/object-utils.js +12 -6
- package/esm/helpers/path-to-object-tree.js +5 -1
- package/esm/helpers/responsive-map.js +5 -1
- package/esm/helpers/type-guards.js +17 -7
- package/esm/http/codecs/boolean-codec.js +5 -1
- package/esm/http/codecs/date-codec.js +5 -1
- package/esm/http/codecs/filter-codec.js +9 -5
- package/esm/http/codecs/integer-codec.js +6 -2
- package/esm/http/codecs/number-codec.js +5 -1
- package/esm/http/codecs/string-codec.js +5 -1
- package/esm/http/enums/http-headers-codes.enum.js +5 -2
- package/esm/http/enums/http-status-codes.enum.js +5 -2
- package/esm/http/enums/http-status-messages.js +4 -1
- package/esm/http/http-headers.js +9 -5
- package/esm/http/http-message.host.js +18 -13
- package/esm/http/http-params.js +25 -20
- package/esm/http/http-request-message.js +22 -18
- package/esm/http/http-response-message.js +28 -23
- package/esm/http/index.js +17 -14
- package/esm/http/interfaces/client-http-headers.interface.js +2 -1
- package/esm/http/interfaces/cookie-options.interface.js +2 -1
- package/esm/http/interfaces/server-http-headers.interface.js +2 -1
- package/esm/i18n/i18n.js +28 -23
- package/esm/i18n/index.js +9 -5
- package/esm/i18n/string-utils.js +7 -2
- package/esm/i18n/translate.js +7 -3
- package/esm/index.js +16 -11
- package/esm/schema/constants.js +4 -1
- package/esm/schema/data-type/complex-type.interface.js +5 -2
- package/esm/schema/data-type/data-type.interface.js +2 -1
- package/esm/schema/data-type/enum-type.interface.js +5 -2
- package/esm/schema/data-type/field.interface.js +2 -1
- package/esm/schema/data-type/mapped-type.interface.js +5 -2
- package/esm/schema/data-type/simple-type.interface.js +5 -2
- package/esm/schema/data-type/union-type.interface.js +5 -2
- package/esm/schema/document.interface.js +2 -1
- package/esm/schema/index.js +34 -31
- package/esm/schema/resource/collection.interface.js +5 -2
- package/esm/schema/resource/container.interface.js +5 -2
- package/esm/schema/resource/endpoint.interface.js +2 -1
- package/esm/schema/resource/resource.interface.js +2 -1
- package/esm/schema/resource/singleton.interface.js +5 -2
- package/esm/schema/type-guards.js +53 -40
- package/esm/types.js +2 -1
- package/esm/url/index.js +8 -5
- package/esm/url/opra-url-path-component.js +7 -3
- package/esm/url/opra-url-path.js +18 -14
- package/esm/url/opra-url.js +25 -21
- package/esm/url/utils/decode-path-component.js +8 -4
- package/esm/url/utils/encode-path-component.js +8 -3
- package/esm/utils/path-utils.js +7 -2
- package/package.json +5 -4
- package/{esm → types}/document/factory/import-resource-class.d.ts +1 -0
- package/{esm → types}/document/resource/collection.d.ts +10 -10
- package/{esm → types}/document/resource/singleton.d.ts +4 -4
- package/{esm → types}/schema/resource/collection.interface.d.ts +6 -6
- package/{esm → types}/url/opra-url.d.ts +3 -3
- package/{esm → types}/document/api-document.d.ts +0 -0
- package/{esm → types}/document/constants.d.ts +0 -0
- package/{esm → types}/document/data-type/api-field.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/any.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/base64.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/bigint.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/boolean.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/date.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/guid.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/index.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/integer.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/number.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/object.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/string.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/time.type.d.ts +0 -0
- package/{esm → types}/document/data-type/builtin/timestamp.type.d.ts +0 -0
- package/{esm → types}/document/data-type/complex-type.d.ts +0 -0
- package/{esm → types}/document/data-type/data-type.d.ts +0 -0
- package/{esm → types}/document/data-type/enum-type.d.ts +0 -0
- package/{esm → types}/document/data-type/mapped-type.d.ts +0 -0
- package/{esm → types}/document/data-type/simple-type.d.ts +0 -0
- package/{esm → types}/document/data-type/union-type.d.ts +0 -0
- package/{esm → types}/document/factory/add-references.d.ts +0 -0
- package/{esm → types}/document/factory/create-document.d.ts +0 -0
- package/{esm → types}/document/factory/factory.d.ts +0 -0
- package/{esm → types}/document/factory/import-type-class.d.ts +0 -0
- package/{esm → types}/document/factory/index.d.ts +0 -0
- package/{esm → types}/document/factory/process-resources.d.ts +0 -0
- package/{esm → types}/document/factory/process-types.d.ts +0 -0
- package/{esm → types}/document/index.d.ts +0 -0
- package/{esm → types}/document/resource/resource.d.ts +0 -0
- package/{esm → types}/document/utils/inspect.util.d.ts +0 -0
- package/{esm → types}/document/utils/string-compare.util.d.ts +0 -0
- package/{esm → types}/exception/enums/issue-severity.enum.d.ts +0 -0
- package/{esm → types}/exception/error-issue.d.ts +0 -0
- package/{esm → types}/exception/http-errors/bad-request.error.d.ts +0 -0
- package/{esm → types}/exception/http-errors/failed-dependency.error.d.ts +0 -0
- package/{esm → types}/exception/http-errors/forbidden.error.d.ts +0 -0
- package/{esm → types}/exception/http-errors/internal-server.error.d.ts +0 -0
- package/{esm → types}/exception/http-errors/method-not-allowed.error.d.ts +0 -0
- package/{esm → types}/exception/http-errors/not-acceptable.error.d.ts +0 -0
- package/{esm → types}/exception/http-errors/not-found.error.d.ts +0 -0
- package/{esm → types}/exception/http-errors/unauthorized.error.d.ts +0 -0
- package/{esm → types}/exception/http-errors/unprocessable-entity.error.d.ts +0 -0
- package/{esm → types}/exception/index.d.ts +0 -0
- package/{esm → types}/exception/opra-exception.d.ts +0 -0
- package/{esm → types}/exception/resource-errors/resource-conflict.error.d.ts +0 -0
- package/{esm → types}/exception/resource-errors/resource-not-found.error.d.ts +0 -0
- package/{esm → types}/exception/wrap-exception.d.ts +0 -0
- package/{esm → types}/filter/antlr/OpraFilterLexer.d.ts +0 -0
- package/{esm → types}/filter/antlr/OpraFilterListener.d.ts +0 -0
- package/{esm → types}/filter/antlr/OpraFilterParser.d.ts +0 -0
- package/{esm → types}/filter/antlr/OpraFilterVisitor.d.ts +0 -0
- package/{esm → types}/filter/ast/abstract/ast.d.ts +0 -0
- package/{esm → types}/filter/ast/abstract/expression.d.ts +0 -0
- package/{esm → types}/filter/ast/abstract/literal.d.ts +0 -0
- package/{esm → types}/filter/ast/abstract/term.d.ts +0 -0
- package/{esm → types}/filter/ast/expressions/arithmetic-expression.d.ts +0 -0
- package/{esm → types}/filter/ast/expressions/array-expression.d.ts +0 -0
- package/{esm → types}/filter/ast/expressions/comparison-expression.d.ts +0 -0
- package/{esm → types}/filter/ast/expressions/logical-expression.d.ts +0 -0
- package/{esm → types}/filter/ast/expressions/parentheses-expression.d.ts +0 -0
- package/{esm → types}/filter/ast/index.d.ts +0 -0
- package/{esm → types}/filter/ast/terms/boolean-literal.d.ts +0 -0
- package/{esm → types}/filter/ast/terms/date-literal.d.ts +0 -0
- package/{esm → types}/filter/ast/terms/external-constant.d.ts +0 -0
- package/{esm → types}/filter/ast/terms/null-literal.d.ts +0 -0
- package/{esm → types}/filter/ast/terms/number-literal.d.ts +0 -0
- package/{esm → types}/filter/ast/terms/qualified-identifier.d.ts +0 -0
- package/{esm → types}/filter/ast/terms/string-literal.d.ts +0 -0
- package/{esm → types}/filter/ast/terms/time-literal.d.ts +0 -0
- package/{esm → types}/filter/build.d.ts +0 -0
- package/{esm → types}/filter/errors.d.ts +0 -0
- package/{esm → types}/filter/filter-tree-visitor.d.ts +0 -0
- package/{esm → types}/filter/index.d.ts +0 -0
- package/{esm → types}/filter/opra-error-listener.d.ts +0 -0
- package/{esm → types}/filter/parse.d.ts +0 -0
- package/{esm → types}/filter/utils.d.ts +0 -0
- package/{esm → types}/helpers/function-utils.d.ts +0 -0
- package/{esm → types}/helpers/get-stack-filename.d.ts +0 -0
- package/{esm → types}/helpers/index.d.ts +0 -0
- package/{esm → types}/helpers/is-url.d.ts +0 -0
- package/{esm → types}/helpers/mixin-utils.d.ts +0 -0
- package/{esm → types}/helpers/object-utils.d.ts +0 -0
- package/{esm → types}/helpers/path-to-object-tree.d.ts +0 -0
- package/{esm → types}/helpers/responsive-map.d.ts +0 -0
- package/{esm → types}/helpers/type-guards.d.ts +0 -0
- package/{esm → types}/http/codecs/boolean-codec.d.ts +0 -0
- package/{esm → types}/http/codecs/date-codec.d.ts +0 -0
- package/{esm → types}/http/codecs/filter-codec.d.ts +0 -0
- package/{esm → types}/http/codecs/integer-codec.d.ts +0 -0
- package/{esm → types}/http/codecs/number-codec.d.ts +0 -0
- package/{esm → types}/http/codecs/string-codec.d.ts +0 -0
- package/{esm → types}/http/enums/http-headers-codes.enum.d.ts +0 -0
- package/{esm → types}/http/enums/http-status-codes.enum.d.ts +0 -0
- package/{esm → types}/http/enums/http-status-messages.d.ts +0 -0
- package/{esm → types}/http/http-headers.d.ts +0 -0
- package/{esm → types}/http/http-message.host.d.ts +0 -0
- package/{esm → types}/http/http-params.d.ts +0 -0
- package/{esm → types}/http/http-request-message.d.ts +0 -0
- package/{esm → types}/http/http-response-message.d.ts +0 -0
- package/{esm → types}/http/index.d.ts +0 -0
- package/{esm → types}/http/interfaces/client-http-headers.interface.d.ts +0 -0
- package/{esm → types}/http/interfaces/cookie-options.interface.d.ts +0 -0
- package/{esm → types}/http/interfaces/server-http-headers.interface.d.ts +0 -0
- package/{esm → types}/http/multipart/batch-multipart.d.ts +0 -0
- package/{esm → types}/http/multipart/http-request-content.d.ts +0 -0
- package/{esm → types}/http/multipart/http-response-content.d.ts +0 -0
- package/{esm → types}/http/multipart/index.d.ts +0 -0
- package/{esm → types}/i18n/i18n.d.ts +0 -0
- package/{esm → types}/i18n/index.d.ts +0 -0
- package/{esm → types}/i18n/string-utils.d.ts +0 -0
- package/{esm → types}/i18n/translate.d.ts +0 -0
- package/{esm → types}/index.d.ts +0 -0
- package/{esm → types}/schema/constants.d.ts +0 -0
- package/{esm → types}/schema/data-type/complex-type.interface.d.ts +0 -0
- package/{esm → types}/schema/data-type/data-type.interface.d.ts +0 -0
- package/{esm → types}/schema/data-type/enum-type.interface.d.ts +0 -0
- package/{esm → types}/schema/data-type/field.interface.d.ts +0 -0
- package/{esm → types}/schema/data-type/mapped-type.interface.d.ts +0 -0
- package/{esm → types}/schema/data-type/simple-type.interface.d.ts +0 -0
- package/{esm → types}/schema/data-type/union-type.interface.d.ts +0 -0
- package/{esm → types}/schema/document.interface.d.ts +0 -0
- package/{esm → types}/schema/index.d.ts +0 -0
- package/{esm → types}/schema/resource/container.interface.d.ts +0 -0
- package/{esm → types}/schema/resource/endpoint.interface.d.ts +0 -0
- package/{esm → types}/schema/resource/resource.interface.d.ts +0 -0
- package/{esm → types}/schema/resource/singleton.interface.d.ts +2 -2
- /package/{esm → types}/schema/type-guards.d.ts +0 -0
- /package/{esm → types}/types.d.ts +0 -0
- /package/{esm → types}/url/index.d.ts +0 -0
- /package/{esm → types}/url/opra-url-path-component.d.ts +0 -0
- /package/{esm → types}/url/opra-url-path.d.ts +0 -0
- /package/{esm → types}/url/utils/decode-path-component.d.ts +0 -0
- /package/{esm → types}/url/utils/encode-path-component.d.ts +0 -0
- /package/{esm → types}/utils/path-utils.d.ts +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractCollectionSchema = exports.extractSingletonSchema = exports.importResourceClass = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
4
5
|
const index_js_1 = require("../../helpers/index.js");
|
|
5
6
|
const index_js_2 = require("../../schema/index.js");
|
|
6
7
|
const constants_js_1 = require("../constants.js");
|
|
@@ -26,6 +26,8 @@ async function importTypeClass(typeThunk) {
|
|
|
26
26
|
const schema = (0, index_js_1.cloneObject)(metadata);
|
|
27
27
|
const result = name || schema;
|
|
28
28
|
if (name) {
|
|
29
|
+
if (this.document.types.has(name) || typeQueue.has(name))
|
|
30
|
+
throw new TypeError(`Type "${name}" already imported`);
|
|
29
31
|
cache.set(thunk, result);
|
|
30
32
|
typeQueue.set(name, schema);
|
|
31
33
|
}
|
|
@@ -58,6 +60,7 @@ async function importTypeClass(typeThunk) {
|
|
|
58
60
|
throw new TypeError(`No EnumType metadata found for object ${JSON.stringify(enumObject).substring(0, 20)}...`);
|
|
59
61
|
}
|
|
60
62
|
exports.importTypeClass = importTypeClass;
|
|
63
|
+
// noinspection JSUnusedLocalSymbols
|
|
61
64
|
async function extractSimpleTypeSchema(target, ctor,
|
|
62
65
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
63
66
|
metadata) {
|
|
@@ -85,12 +88,14 @@ async function extractComplexTypeSchema(target, ctor, metadata) {
|
|
|
85
88
|
...elemMeta,
|
|
86
89
|
type
|
|
87
90
|
};
|
|
88
|
-
if (elemMeta.enum)
|
|
91
|
+
if (elemMeta.enum)
|
|
89
92
|
elemSchema.type = await this.importTypeClass(elemMeta.enum);
|
|
90
|
-
}
|
|
91
93
|
if (!elemSchema.type && elemMeta.designType)
|
|
92
94
|
elemSchema.type = await this.importTypeClass(elemMeta.designType);
|
|
93
95
|
await this.extractFieldSchema(elemSchema, ctor, elemMeta, elemName);
|
|
96
|
+
// Check enum again. External packages may modify enum value
|
|
97
|
+
if (elemMeta.enum)
|
|
98
|
+
elemSchema.type = await this.importTypeClass(elemMeta.enum);
|
|
94
99
|
if (typeof elemSchema.type === 'function')
|
|
95
100
|
elemSchema.type = await this.importTypeClass(elemSchema.type);
|
|
96
101
|
if (elemSchema.isArray && !elemSchema.type)
|
|
@@ -116,12 +121,14 @@ async function extractUnionTypeSchema(target, ctor, metadata) {
|
|
|
116
121
|
target.types.push(await this.importTypeClass(type));
|
|
117
122
|
}
|
|
118
123
|
exports.extractUnionTypeSchema = extractUnionTypeSchema;
|
|
124
|
+
// noinspection JSUnusedLocalSymbols
|
|
119
125
|
async function extractEnumTypeSchema(
|
|
120
126
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
121
127
|
target, enumObject, metadata) {
|
|
122
128
|
// Do nothing. This method is used by external modules for extending the factory
|
|
123
129
|
}
|
|
124
130
|
exports.extractEnumTypeSchema = extractEnumTypeSchema;
|
|
131
|
+
// noinspection JSUnusedLocalSymbols
|
|
125
132
|
async function extractFieldSchema(
|
|
126
133
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
127
134
|
target, ctor, metadata, name) {
|
|
@@ -129,8 +129,8 @@ const proto = {
|
|
|
129
129
|
const normalized = this.normalizeFieldNames(fields);
|
|
130
130
|
if (!normalized)
|
|
131
131
|
return;
|
|
132
|
-
const
|
|
133
|
-
const sortFields =
|
|
132
|
+
const findManyEndpoint = this.operations.findMany;
|
|
133
|
+
const sortFields = findManyEndpoint && findManyEndpoint.sortFields;
|
|
134
134
|
normalized.forEach(field => {
|
|
135
135
|
if (!sortFields?.find(x => x === field))
|
|
136
136
|
throw new index_js_1.BadRequestError({
|
|
@@ -176,10 +176,10 @@ function createOperationDecorator(operation) {
|
|
|
176
176
|
Reflect.defineMetadata(constants_js_1.METADATA_KEY, resourceMetadata, target.constructor);
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
|
-
exports.Collection.
|
|
180
|
-
exports.Collection.
|
|
181
|
-
exports.Collection.
|
|
182
|
-
exports.Collection.
|
|
183
|
-
exports.Collection.
|
|
184
|
-
exports.Collection.
|
|
185
|
-
exports.Collection.
|
|
179
|
+
exports.Collection.Create = createOperationDecorator('create');
|
|
180
|
+
exports.Collection.Delete = createOperationDecorator('delete');
|
|
181
|
+
exports.Collection.DeleteMany = createOperationDecorator('deleteMany');
|
|
182
|
+
exports.Collection.Get = createOperationDecorator('get');
|
|
183
|
+
exports.Collection.FindMany = createOperationDecorator('findMany');
|
|
184
|
+
exports.Collection.Update = createOperationDecorator('update');
|
|
185
|
+
exports.Collection.UpdateMany = createOperationDecorator('updateMany');
|
|
@@ -85,7 +85,7 @@ function createOperationDecorator(operation) {
|
|
|
85
85
|
Reflect.defineMetadata(constants_js_1.METADATA_KEY, resourceMetadata, target.constructor);
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
exports.Singleton.
|
|
89
|
-
exports.Singleton.
|
|
90
|
-
exports.Singleton.
|
|
91
|
-
exports.Singleton.
|
|
88
|
+
exports.Singleton.Create = createOperationDecorator('create');
|
|
89
|
+
exports.Singleton.Get = createOperationDecorator('get');
|
|
90
|
+
exports.Singleton.Delete = createOperationDecorator('delete');
|
|
91
|
+
exports.Singleton.Update = createOperationDecorator('update');
|
package/cjs/url/opra-url.js
CHANGED
|
@@ -14,7 +14,7 @@ const hostRegEx = /^([^/:]+)(?::(\d+))?$/;
|
|
|
14
14
|
const hostnameRegEx = /^([^/:]+)$/;
|
|
15
15
|
const kContext = Symbol('kContext');
|
|
16
16
|
const kPath = Symbol('kPath');
|
|
17
|
-
const
|
|
17
|
+
const kParams = Symbol('kParams');
|
|
18
18
|
class OpraURL {
|
|
19
19
|
constructor(input, base) {
|
|
20
20
|
this[_a] = {
|
|
@@ -32,7 +32,7 @@ class OpraURL {
|
|
|
32
32
|
this[kContext].address = undefined;
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
|
-
this[
|
|
35
|
+
this[kParams] = new index_js_1.HttpParams('', {
|
|
36
36
|
onChange: () => {
|
|
37
37
|
this[kContext].search = undefined;
|
|
38
38
|
}
|
|
@@ -182,20 +182,20 @@ class OpraURL {
|
|
|
182
182
|
}
|
|
183
183
|
get search() {
|
|
184
184
|
if (this[kContext].search == null) {
|
|
185
|
-
const s = this[
|
|
185
|
+
const s = this[kParams].toString();
|
|
186
186
|
this[kContext].search = s ? ('?' + s) : '';
|
|
187
187
|
}
|
|
188
188
|
return this[kContext].search;
|
|
189
189
|
}
|
|
190
190
|
set search(v) {
|
|
191
191
|
if (v) {
|
|
192
|
-
this[
|
|
193
|
-
this[
|
|
192
|
+
this[kParams].clear();
|
|
193
|
+
this[kParams].appendAll(v);
|
|
194
194
|
}
|
|
195
195
|
this[kContext].search = undefined;
|
|
196
196
|
}
|
|
197
197
|
get searchParams() {
|
|
198
|
-
return this[
|
|
198
|
+
return this[kParams];
|
|
199
199
|
}
|
|
200
200
|
parse(input) {
|
|
201
201
|
const m = urlRegEx.exec(input);
|
|
@@ -303,4 +303,4 @@ class OpraURL {
|
|
|
303
303
|
exports.OpraURL = OpraURL;
|
|
304
304
|
OpraURL.kContext = kContext;
|
|
305
305
|
OpraURL.kPath = kPath;
|
|
306
|
-
OpraURL.
|
|
306
|
+
OpraURL.kParams = kParams;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiDocument = void 0;
|
|
4
|
+
const index_js_1 = require("../exception/index.js");
|
|
5
|
+
const index_js_2 = require("../helpers/index.js");
|
|
6
|
+
const index_js_3 = require("../schema/index.js");
|
|
7
|
+
const constants_js_1 = require("./constants.js");
|
|
8
|
+
const complex_type_js_1 = require("./data-type/complex-type.js");
|
|
9
|
+
const simple_type_js_1 = require("./data-type/simple-type.js");
|
|
10
|
+
class ApiDocument {
|
|
8
11
|
constructor() {
|
|
9
|
-
this._typeCache = new ResponsiveMap();
|
|
12
|
+
this._typeCache = new index_js_2.ResponsiveMap();
|
|
10
13
|
this._typesCacheByCtor = new Map();
|
|
11
|
-
this.references = new ResponsiveMap();
|
|
12
|
-
this.types = new ResponsiveMap();
|
|
13
|
-
this.resources = new ResponsiveMap();
|
|
14
|
+
this.references = new index_js_2.ResponsiveMap();
|
|
15
|
+
this.types = new index_js_2.ResponsiveMap();
|
|
16
|
+
this.resources = new index_js_2.ResponsiveMap();
|
|
14
17
|
this.info = {
|
|
15
18
|
version: '',
|
|
16
19
|
title: ''
|
|
@@ -30,19 +33,19 @@ export class ApiDocument {
|
|
|
30
33
|
if (t === null) {
|
|
31
34
|
if (silent)
|
|
32
35
|
return;
|
|
33
|
-
throw new NotFoundError(`Data type "${nameOrCtorName}" does not exists`);
|
|
36
|
+
throw new index_js_1.NotFoundError(`Data type "${nameOrCtorName}" does not exists`);
|
|
34
37
|
}
|
|
35
38
|
if (typeof nameOrCtor === 'string') {
|
|
36
|
-
const m = NAMESPACE_PATTERN.exec(nameOrCtor);
|
|
39
|
+
const m = constants_js_1.NAMESPACE_PATTERN.exec(nameOrCtor);
|
|
37
40
|
if (!m)
|
|
38
|
-
throw new NotFoundError(`Invalid data type name "${nameOrCtorName}"`);
|
|
41
|
+
throw new index_js_1.NotFoundError(`Invalid data type name "${nameOrCtorName}"`);
|
|
39
42
|
// If given string has namespace pattern (ns:type_name)
|
|
40
43
|
if (m[2]) {
|
|
41
44
|
const ref = this.references.get(m[1]);
|
|
42
45
|
if (!ref) {
|
|
43
46
|
if (silent)
|
|
44
47
|
return;
|
|
45
|
-
throw new NotFoundError(`Reference "${m[1]}" not found`);
|
|
48
|
+
throw new index_js_1.NotFoundError(`Reference "${m[1]}" not found`);
|
|
46
49
|
}
|
|
47
50
|
dataType = ref.getDataType(m[2]);
|
|
48
51
|
this._typeCache.set(nameOrCtor, dataType);
|
|
@@ -67,7 +70,7 @@ export class ApiDocument {
|
|
|
67
70
|
else if (typeof nameOrCtor === 'function') {
|
|
68
71
|
const types = Array.from(this.types.values()).reverse();
|
|
69
72
|
for (const dt of types) {
|
|
70
|
-
if ((dt instanceof ComplexType || dt instanceof SimpleType) && dt.own.ctor === nameOrCtor) {
|
|
73
|
+
if ((dt instanceof complex_type_js_1.ComplexType || dt instanceof simple_type_js_1.SimpleType) && dt.own.ctor === nameOrCtor) {
|
|
71
74
|
dataType = dt;
|
|
72
75
|
break;
|
|
73
76
|
}
|
|
@@ -83,7 +86,7 @@ export class ApiDocument {
|
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
88
|
if (dataType) {
|
|
86
|
-
if ((dataType instanceof ComplexType || dataType instanceof SimpleType) &&
|
|
89
|
+
if ((dataType instanceof complex_type_js_1.ComplexType || dataType instanceof simple_type_js_1.SimpleType) &&
|
|
87
90
|
dataType.own?.ctor && dataType.own.ctor !== Object)
|
|
88
91
|
this._typesCacheByCtor.set(dataType.own.ctor, dataType);
|
|
89
92
|
return dataType;
|
|
@@ -96,7 +99,7 @@ export class ApiDocument {
|
|
|
96
99
|
}
|
|
97
100
|
if (silent)
|
|
98
101
|
return;
|
|
99
|
-
throw new NotFoundError(`Data type "${nameOrCtorName}" does not exists`);
|
|
102
|
+
throw new index_js_1.NotFoundError(`Data type "${nameOrCtorName}" does not exists`);
|
|
100
103
|
}
|
|
101
104
|
getComplexType(nameOrCtor, silent) {
|
|
102
105
|
if (nameOrCtor === Object)
|
|
@@ -104,30 +107,30 @@ export class ApiDocument {
|
|
|
104
107
|
const t = this.getDataType(nameOrCtor);
|
|
105
108
|
if (!t && silent)
|
|
106
109
|
return;
|
|
107
|
-
if (t && t.kind === OpraSchema.ComplexType.Kind)
|
|
110
|
+
if (t && t.kind === index_js_3.OpraSchema.ComplexType.Kind)
|
|
108
111
|
return t;
|
|
109
|
-
throw new NotAcceptableError(`Data type "${t.name}" is not a ComplexType`);
|
|
112
|
+
throw new index_js_1.NotAcceptableError(`Data type "${t.name}" is not a ComplexType`);
|
|
110
113
|
}
|
|
111
114
|
getSimpleType(nameOrCtor, silent) {
|
|
112
115
|
const t = this.getDataType(nameOrCtor);
|
|
113
116
|
if (!t && silent)
|
|
114
117
|
return;
|
|
115
|
-
if (t && t.kind === OpraSchema.SimpleType.Kind)
|
|
118
|
+
if (t && t.kind === index_js_3.OpraSchema.SimpleType.Kind)
|
|
116
119
|
return t;
|
|
117
|
-
throw new NotAcceptableError(`Data type "${t.name || t}" is not a SimpleType`);
|
|
120
|
+
throw new index_js_1.NotAcceptableError(`Data type "${t.name || t}" is not a SimpleType`);
|
|
118
121
|
}
|
|
119
122
|
getResource(path, silent) {
|
|
120
123
|
let resource;
|
|
121
|
-
const m = NAMESPACE_PATTERN.exec(path);
|
|
124
|
+
const m = constants_js_1.NAMESPACE_PATTERN.exec(path);
|
|
122
125
|
if (!m)
|
|
123
|
-
throw new NotFoundError(`Invalid resource path "${path}"`);
|
|
126
|
+
throw new index_js_1.NotFoundError(`Invalid resource path "${path}"`);
|
|
124
127
|
// If given string has namespace pattern (ns:type_name)
|
|
125
128
|
if (m[2]) {
|
|
126
129
|
const ref = this.references.get(m[1]);
|
|
127
130
|
if (!ref) {
|
|
128
131
|
if (silent)
|
|
129
132
|
return;
|
|
130
|
-
throw new NotFoundError(`Reference "${m[1]}" not found`);
|
|
133
|
+
throw new index_js_1.NotFoundError(`Reference "${m[1]}" not found`);
|
|
131
134
|
}
|
|
132
135
|
return ref.getResource(m[2]);
|
|
133
136
|
}
|
|
@@ -147,32 +150,32 @@ export class ApiDocument {
|
|
|
147
150
|
}
|
|
148
151
|
if (silent)
|
|
149
152
|
return;
|
|
150
|
-
throw new NotFoundError(`Resource not found (${path})`);
|
|
153
|
+
throw new index_js_1.NotFoundError(`Resource not found (${path})`);
|
|
151
154
|
}
|
|
152
155
|
getCollection(path, silent) {
|
|
153
156
|
const t = this.getResource(path);
|
|
154
157
|
if (!t && silent)
|
|
155
158
|
return;
|
|
156
|
-
if (t && t.kind === OpraSchema.Collection.Kind)
|
|
159
|
+
if (t && t.kind === index_js_3.OpraSchema.Collection.Kind)
|
|
157
160
|
return t;
|
|
158
|
-
throw new NotAcceptableError(`Resource type "${t.name}" is not a Collection`);
|
|
161
|
+
throw new index_js_1.NotAcceptableError(`Resource type "${t.name}" is not a Collection`);
|
|
159
162
|
}
|
|
160
163
|
getSingleton(path, silent) {
|
|
161
164
|
const t = this.getResource(path);
|
|
162
165
|
if (!t && silent)
|
|
163
166
|
return;
|
|
164
|
-
if (t && t.kind === OpraSchema.Singleton.Kind)
|
|
167
|
+
if (t && t.kind === index_js_3.OpraSchema.Singleton.Kind)
|
|
165
168
|
return t;
|
|
166
|
-
throw new NotAcceptableError(`Resource type "${t.name}" is not a Singleton`);
|
|
169
|
+
throw new index_js_1.NotAcceptableError(`Resource type "${t.name}" is not a Singleton`);
|
|
167
170
|
}
|
|
168
171
|
/**
|
|
169
172
|
* Export as Opra schema definition object
|
|
170
173
|
*/
|
|
171
174
|
exportSchema() {
|
|
172
175
|
const schema = {
|
|
173
|
-
version: OpraSchema.SpecVersion,
|
|
176
|
+
version: index_js_3.OpraSchema.SpecVersion,
|
|
174
177
|
url: this.url,
|
|
175
|
-
info: cloneObject(this.info)
|
|
178
|
+
info: (0, index_js_2.cloneObject)(this.info)
|
|
176
179
|
};
|
|
177
180
|
if (this.references.size) {
|
|
178
181
|
const references = {};
|
|
@@ -198,10 +201,11 @@ export class ApiDocument {
|
|
|
198
201
|
types[name] = r.exportSchema();
|
|
199
202
|
}
|
|
200
203
|
}
|
|
201
|
-
return omitUndefined(schema);
|
|
204
|
+
return (0, index_js_2.omitUndefined)(schema);
|
|
202
205
|
}
|
|
203
206
|
invalidate() {
|
|
204
207
|
this._typeCache.clear();
|
|
205
208
|
this._typesCacheByCtor.clear();
|
|
206
209
|
}
|
|
207
210
|
}
|
|
211
|
+
exports.ApiDocument = ApiDocument;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TYPENAME_PATTERN = exports.NAMESPACE_PATTERN = exports.METADATA_KEY = void 0;
|
|
4
|
+
exports.METADATA_KEY = Symbol.for('opra.metadata');
|
|
5
|
+
exports.NAMESPACE_PATTERN = /([A-Z$_]\w+)(?::.+)?/i;
|
|
6
|
+
exports.TYPENAME_PATTERN = /^(.*)Type$/;
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiField = void 0;
|
|
4
|
+
const index_js_1 = require("../../helpers/index.js");
|
|
5
|
+
const index_js_2 = require("../../schema/index.js");
|
|
6
|
+
const constants_js_1 = require("../constants.js");
|
|
7
|
+
const enum_type_js_1 = require("./enum-type.js");
|
|
5
8
|
/**
|
|
6
9
|
* @class ComplexType
|
|
7
10
|
*/
|
|
8
|
-
|
|
11
|
+
exports.ApiField = function (...args) {
|
|
9
12
|
// ClassDecorator
|
|
10
13
|
if (!this) {
|
|
11
14
|
const [options] = args;
|
|
12
15
|
return function (target, propertyKey) {
|
|
13
16
|
if (typeof propertyKey !== 'string')
|
|
14
17
|
throw new TypeError(`Symbol properties can't be used as a field`);
|
|
15
|
-
const metadata = Reflect.getOwnMetadata(METADATA_KEY, target.constructor) || {};
|
|
16
|
-
metadata.kind = OpraSchema.ComplexType.Kind;
|
|
18
|
+
const metadata = Reflect.getOwnMetadata(constants_js_1.METADATA_KEY, target.constructor) || {};
|
|
19
|
+
metadata.kind = index_js_2.OpraSchema.ComplexType.Kind;
|
|
17
20
|
metadata.fields = metadata.fields || {};
|
|
18
21
|
const designType = Reflect.getMetadata('design:type', target, propertyKey);
|
|
19
22
|
const isArray = designType === Array;
|
|
@@ -31,17 +34,17 @@ export const ApiField = function (...args) {
|
|
|
31
34
|
o[v] = v;
|
|
32
35
|
return o;
|
|
33
36
|
}, {});
|
|
34
|
-
EnumType(enumObj);
|
|
37
|
+
(0, enum_type_js_1.EnumType)(enumObj);
|
|
35
38
|
elemMeta.enum = enumObj;
|
|
36
39
|
}
|
|
37
40
|
else {
|
|
38
|
-
const m = Reflect.getOwnMetadata(METADATA_KEY, options?.enum);
|
|
39
|
-
if (!OpraSchema.isEnumType(m))
|
|
41
|
+
const m = Reflect.getOwnMetadata(constants_js_1.METADATA_KEY, options?.enum);
|
|
42
|
+
if (!index_js_2.OpraSchema.isEnumType(m))
|
|
40
43
|
throw new TypeError(`Invalid "enum" value. Did you forget to set metadata using EnumType() method?`);
|
|
41
44
|
elemMeta.enum = options.enum;
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
|
-
Reflect.defineMetadata(METADATA_KEY, omitUndefined(metadata), target.constructor);
|
|
47
|
+
Reflect.defineMetadata(constants_js_1.METADATA_KEY, (0, index_js_1.omitUndefined)(metadata), target.constructor);
|
|
45
48
|
};
|
|
46
49
|
}
|
|
47
50
|
// Constructor
|
|
@@ -76,4 +79,4 @@ const proto = {
|
|
|
76
79
|
return out;
|
|
77
80
|
}
|
|
78
81
|
};
|
|
79
|
-
Object.assign(ApiField.prototype, proto);
|
|
82
|
+
Object.assign(exports.ApiField.prototype, proto);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnyType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
3
6
|
let AnyType = class AnyType {
|
|
4
7
|
};
|
|
5
|
-
AnyType = __decorate([
|
|
6
|
-
SimpleType({
|
|
8
|
+
AnyType = tslib_1.__decorate([
|
|
9
|
+
(0, simple_type_js_1.SimpleType)({
|
|
7
10
|
description: 'Any value',
|
|
8
11
|
ctor: Object
|
|
9
12
|
})
|
|
10
13
|
], AnyType);
|
|
11
|
-
|
|
14
|
+
exports.AnyType = AnyType;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Base64Type = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
3
6
|
const BASE64_PATTERN = /^(?:[A-Za-z0-9+/]{4})*(?:(?:[A-Za-z0-9+/][AQgw](:?==)?)|(?:[A-Za-z0-9+/]{2}[AEIMQUYcgkosw048]=?))?$/;
|
|
4
7
|
let Base64Type = class Base64Type {
|
|
5
8
|
decode(v) {
|
|
@@ -26,10 +29,10 @@ let Base64Type = class Base64Type {
|
|
|
26
29
|
throw new TypeError(`Invalid base64 value "${String(v).substring(0, 10)}..."`);
|
|
27
30
|
}
|
|
28
31
|
};
|
|
29
|
-
Base64Type = __decorate([
|
|
30
|
-
SimpleType({
|
|
32
|
+
Base64Type = tslib_1.__decorate([
|
|
33
|
+
(0, simple_type_js_1.SimpleType)({
|
|
31
34
|
description: 'A stream of bytes, base64 encoded',
|
|
32
35
|
ctor: ArrayBuffer
|
|
33
36
|
})
|
|
34
37
|
], Base64Type);
|
|
35
|
-
|
|
38
|
+
exports.Base64Type = Base64Type;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BigIntType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
3
6
|
const BigIntConstructor = Object.getPrototypeOf(BigInt(0)).constructor;
|
|
4
7
|
let BigIntType = class BigIntType {
|
|
5
8
|
decode(v) {
|
|
@@ -20,11 +23,11 @@ let BigIntType = class BigIntType {
|
|
|
20
23
|
throw new TypeError(`Invalid number value "${v}"`);
|
|
21
24
|
}
|
|
22
25
|
};
|
|
23
|
-
BigIntType = __decorate([
|
|
24
|
-
SimpleType({
|
|
26
|
+
BigIntType = tslib_1.__decorate([
|
|
27
|
+
(0, simple_type_js_1.SimpleType)({
|
|
25
28
|
name: 'bigint',
|
|
26
29
|
description: 'BigInt number',
|
|
27
30
|
ctor: BigIntConstructor
|
|
28
31
|
})
|
|
29
32
|
], BigIntType);
|
|
30
|
-
|
|
33
|
+
exports.BigIntType = BigIntType;
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BooleanType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
6
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
4
7
|
let BooleanType = class BooleanType {
|
|
5
8
|
decode(v) {
|
|
6
9
|
if (v == null)
|
|
7
10
|
return v;
|
|
8
|
-
return toBoolean(v);
|
|
11
|
+
return (0, putil_varhelpers_1.toBoolean)(v);
|
|
9
12
|
}
|
|
10
13
|
encode(v) {
|
|
11
14
|
if (v == null)
|
|
12
15
|
return v;
|
|
13
|
-
return toBoolean(v);
|
|
16
|
+
return (0, putil_varhelpers_1.toBoolean)(v);
|
|
14
17
|
}
|
|
15
18
|
coerce(v) {
|
|
16
19
|
return this.decode(v);
|
|
17
20
|
}
|
|
18
21
|
};
|
|
19
|
-
BooleanType = __decorate([
|
|
20
|
-
SimpleType({
|
|
22
|
+
BooleanType = tslib_1.__decorate([
|
|
23
|
+
(0, simple_type_js_1.SimpleType)({
|
|
21
24
|
description: 'Simple true/false value',
|
|
22
25
|
ctor: Boolean
|
|
23
26
|
})
|
|
24
27
|
], BooleanType);
|
|
25
|
-
|
|
28
|
+
exports.BooleanType = BooleanType;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DateType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
6
|
+
const timestamp_type_js_1 = require("./timestamp.type.js");
|
|
7
|
+
let DateType = class DateType extends timestamp_type_js_1.TimestampType {
|
|
5
8
|
constructor() {
|
|
6
9
|
super(...arguments);
|
|
7
10
|
this.format = 'YYYY-MM-DD';
|
|
8
11
|
}
|
|
9
12
|
};
|
|
10
|
-
DateType = __decorate([
|
|
11
|
-
SimpleType({
|
|
13
|
+
DateType = tslib_1.__decorate([
|
|
14
|
+
(0, simple_type_js_1.SimpleType)({
|
|
12
15
|
description: 'full-date notation as defined by RFC 3339, section 5.6, for example, 2021-04-18',
|
|
13
16
|
})
|
|
14
17
|
], DateType);
|
|
15
|
-
|
|
18
|
+
exports.DateType = DateType;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuidType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
6
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
+
const string_type_js_1 = require("./string.type.js");
|
|
5
8
|
const GUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
6
|
-
let GuidType = class GuidType extends StringType {
|
|
9
|
+
let GuidType = class GuidType extends string_type_js_1.StringType {
|
|
7
10
|
decode(v) {
|
|
8
11
|
if (v == null)
|
|
9
12
|
return v;
|
|
10
|
-
const s = toString(v);
|
|
13
|
+
const s = (0, putil_varhelpers_1.toString)(v);
|
|
11
14
|
if (s)
|
|
12
15
|
this.validate(s);
|
|
13
16
|
return s;
|
|
@@ -24,9 +27,9 @@ let GuidType = class GuidType extends StringType {
|
|
|
24
27
|
throw new TypeError(`Invalid GUID value "${v}"`);
|
|
25
28
|
}
|
|
26
29
|
};
|
|
27
|
-
GuidType = __decorate([
|
|
28
|
-
SimpleType({
|
|
30
|
+
GuidType = tslib_1.__decorate([
|
|
31
|
+
(0, simple_type_js_1.SimpleType)({
|
|
29
32
|
description: 'A Globally Unique Identifier (GUID) value',
|
|
30
33
|
})
|
|
31
34
|
], GuidType);
|
|
32
|
-
|
|
35
|
+
exports.GuidType = GuidType;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./any.type.js"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./base64.type.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./bigint.type.js"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./boolean.type.js"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./date.type.js"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./guid.type.js"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./integer.type.js"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./number.type.js"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./object.type.js"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./string.type.js"), exports);
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntegerType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
6
|
+
const simple_type_js_1 = require("../simple-type.js");
|
|
7
|
+
const number_type_js_1 = require("./number.type.js");
|
|
8
|
+
let IntegerType = class IntegerType extends number_type_js_1.NumberType {
|
|
6
9
|
decode(v) {
|
|
7
10
|
if (v == null)
|
|
8
11
|
return v;
|
|
9
|
-
return toInt(super.decode(v));
|
|
12
|
+
return (0, putil_varhelpers_1.toInt)(super.decode(v));
|
|
10
13
|
}
|
|
11
14
|
encode(v) {
|
|
12
15
|
if (v == null)
|
|
13
16
|
return v;
|
|
14
|
-
return toInt(super.encode(v));
|
|
17
|
+
return (0, putil_varhelpers_1.toInt)(super.encode(v));
|
|
15
18
|
}
|
|
16
19
|
coerce(v) {
|
|
17
20
|
return this.decode(v);
|
|
18
21
|
}
|
|
19
22
|
};
|
|
20
|
-
IntegerType = __decorate([
|
|
21
|
-
SimpleType({
|
|
23
|
+
IntegerType = tslib_1.__decorate([
|
|
24
|
+
(0, simple_type_js_1.SimpleType)({
|
|
22
25
|
description: 'An integer number',
|
|
23
26
|
})
|
|
24
27
|
], IntegerType);
|
|
25
|
-
|
|
28
|
+
exports.IntegerType = IntegerType;
|