@opra/common 0.16.1 → 0.17.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.
Files changed (148) hide show
  1. package/cjs/document/data-type/complex-type.js +69 -56
  2. package/cjs/document/data-type/simple-type.js +0 -1
  3. package/cjs/document/resource/collection.js +15 -16
  4. package/cjs/document/resource/singleton.js +2 -2
  5. package/cjs/http/http-params.js +10 -11
  6. package/esm/document/api-document.js +33 -37
  7. package/esm/document/constants.js +3 -6
  8. package/esm/document/data-type/api-field.js +12 -15
  9. package/esm/document/data-type/builtin/any.type.js +5 -8
  10. package/esm/document/data-type/builtin/base64.type.js +5 -8
  11. package/esm/document/data-type/builtin/bigint.type.js +5 -8
  12. package/esm/document/data-type/builtin/boolean.type.js +8 -11
  13. package/esm/document/data-type/builtin/date.type.js +7 -10
  14. package/esm/document/data-type/builtin/guid.type.js +9 -12
  15. package/esm/document/data-type/builtin/index.js +10 -13
  16. package/esm/document/data-type/builtin/integer.type.js +10 -13
  17. package/esm/document/data-type/builtin/number.type.js +7 -10
  18. package/esm/document/data-type/builtin/object.type.js +5 -8
  19. package/esm/document/data-type/builtin/string.type.js +8 -11
  20. package/esm/document/data-type/builtin/time.type.js +7 -10
  21. package/esm/document/data-type/builtin/timestamp.type.js +9 -12
  22. package/esm/document/data-type/complex-type.js +94 -85
  23. package/esm/document/data-type/data-type.js +9 -12
  24. package/esm/document/data-type/enum-type.js +15 -19
  25. package/esm/document/data-type/mapped-type.js +24 -29
  26. package/esm/document/data-type/simple-type.js +17 -22
  27. package/esm/document/data-type/union-type.js +26 -29
  28. package/esm/document/factory/add-references.js +3 -7
  29. package/esm/document/factory/create-document.js +10 -16
  30. package/esm/document/factory/factory.js +33 -37
  31. package/esm/document/factory/import-resource-class.js +16 -22
  32. package/esm/document/factory/import-type-class.js +24 -34
  33. package/esm/document/factory/index.js +1 -4
  34. package/esm/document/factory/process-resources.js +10 -16
  35. package/esm/document/factory/process-types.js +31 -37
  36. package/esm/document/index.js +14 -17
  37. package/esm/document/resource/collection.js +58 -63
  38. package/esm/document/resource/resource.js +9 -12
  39. package/esm/document/resource/singleton.js +27 -31
  40. package/esm/document/utils/inspect.util.js +4 -7
  41. package/esm/document/utils/string-compare.util.js +1 -5
  42. package/esm/exception/enums/issue-severity.enum.js +2 -5
  43. package/esm/exception/error-issue.js +1 -2
  44. package/esm/exception/http-errors/bad-request.error.js +4 -8
  45. package/esm/exception/http-errors/failed-dependency.error.js +4 -8
  46. package/esm/exception/http-errors/forbidden.error.js +4 -8
  47. package/esm/exception/http-errors/internal-server.error.js +4 -8
  48. package/esm/exception/http-errors/method-not-allowed.error.js +4 -8
  49. package/esm/exception/http-errors/not-acceptable.error.js +4 -8
  50. package/esm/exception/http-errors/not-found.error.js +4 -8
  51. package/esm/exception/http-errors/unauthorized.error.js +4 -8
  52. package/esm/exception/http-errors/unprocessable-entity.error.js +4 -8
  53. package/esm/exception/index.js +15 -18
  54. package/esm/exception/opra-exception.js +3 -7
  55. package/esm/exception/resource-errors/resource-conflict.error.js +4 -8
  56. package/esm/exception/resource-errors/resource-not-found.error.js +4 -8
  57. package/esm/exception/wrap-exception.js +20 -24
  58. package/esm/filter/antlr/OpraFilterLexer.js +6 -9
  59. package/esm/filter/antlr/OpraFilterListener.js +2 -5
  60. package/esm/filter/antlr/OpraFilterParser.js +79 -126
  61. package/esm/filter/antlr/OpraFilterVisitor.js +2 -5
  62. package/esm/filter/ast/abstract/ast.js +1 -5
  63. package/esm/filter/ast/abstract/expression.js +2 -6
  64. package/esm/filter/ast/abstract/literal.js +2 -6
  65. package/esm/filter/ast/abstract/term.js +2 -6
  66. package/esm/filter/ast/expressions/arithmetic-expression.js +3 -8
  67. package/esm/filter/ast/expressions/array-expression.js +2 -6
  68. package/esm/filter/ast/expressions/comparison-expression.js +2 -6
  69. package/esm/filter/ast/expressions/logical-expression.js +2 -6
  70. package/esm/filter/ast/expressions/parentheses-expression.js +2 -6
  71. package/esm/filter/ast/index.js +16 -19
  72. package/esm/filter/ast/terms/boolean-literal.js +2 -6
  73. package/esm/filter/ast/terms/date-literal.js +8 -12
  74. package/esm/filter/ast/terms/external-constant.js +2 -6
  75. package/esm/filter/ast/terms/null-literal.js +2 -6
  76. package/esm/filter/ast/terms/number-literal.js +4 -8
  77. package/esm/filter/ast/terms/qualified-identifier.js +2 -6
  78. package/esm/filter/ast/terms/string-literal.js +4 -8
  79. package/esm/filter/ast/terms/time-literal.js +6 -10
  80. package/esm/filter/build.js +45 -69
  81. package/esm/filter/errors.js +3 -9
  82. package/esm/filter/filter-tree-visitor.js +26 -31
  83. package/esm/filter/index.js +5 -8
  84. package/esm/filter/opra-error-listener.js +4 -8
  85. package/esm/filter/parse.js +14 -19
  86. package/esm/filter/utils.js +2 -7
  87. package/esm/helpers/function-utils.js +8 -14
  88. package/esm/helpers/get-stack-filename.js +1 -5
  89. package/esm/helpers/index.js +8 -11
  90. package/esm/helpers/is-url.js +1 -5
  91. package/esm/helpers/mixin-utils.js +2 -7
  92. package/esm/helpers/object-utils.js +6 -12
  93. package/esm/helpers/path-to-object-tree.js +1 -5
  94. package/esm/helpers/responsive-map.js +1 -5
  95. package/esm/helpers/type-guards.js +7 -17
  96. package/esm/http/codecs/boolean-codec.js +1 -5
  97. package/esm/http/codecs/date-codec.js +1 -5
  98. package/esm/http/codecs/filter-codec.js +5 -9
  99. package/esm/http/codecs/integer-codec.js +2 -6
  100. package/esm/http/codecs/number-codec.js +1 -5
  101. package/esm/http/codecs/string-codec.js +1 -5
  102. package/esm/http/enums/http-headers-codes.enum.js +2 -5
  103. package/esm/http/enums/http-status-codes.enum.js +2 -5
  104. package/esm/http/enums/http-status-messages.js +1 -4
  105. package/esm/http/http-headers.js +5 -9
  106. package/esm/http/http-message.host.js +13 -18
  107. package/esm/http/http-params.js +30 -36
  108. package/esm/http/http-request-message.js +18 -22
  109. package/esm/http/http-response-message.js +23 -28
  110. package/esm/http/index.js +14 -17
  111. package/esm/http/interfaces/client-http-headers.interface.js +1 -2
  112. package/esm/http/interfaces/cookie-options.interface.js +1 -2
  113. package/esm/http/interfaces/server-http-headers.interface.js +1 -2
  114. package/esm/i18n/i18n.js +23 -28
  115. package/esm/i18n/index.js +5 -9
  116. package/esm/i18n/string-utils.js +2 -7
  117. package/esm/i18n/translate.js +3 -7
  118. package/esm/index.js +11 -16
  119. package/esm/schema/constants.js +1 -4
  120. package/esm/schema/data-type/complex-type.interface.js +2 -5
  121. package/esm/schema/data-type/data-type.interface.js +1 -2
  122. package/esm/schema/data-type/enum-type.interface.js +2 -5
  123. package/esm/schema/data-type/field.interface.js +1 -2
  124. package/esm/schema/data-type/mapped-type.interface.js +2 -5
  125. package/esm/schema/data-type/simple-type.interface.js +2 -5
  126. package/esm/schema/data-type/union-type.interface.js +2 -5
  127. package/esm/schema/document.interface.js +1 -2
  128. package/esm/schema/index.js +31 -34
  129. package/esm/schema/resource/collection.interface.js +2 -5
  130. package/esm/schema/resource/container.interface.js +2 -5
  131. package/esm/schema/resource/endpoint.interface.js +1 -2
  132. package/esm/schema/resource/resource.interface.js +1 -2
  133. package/esm/schema/resource/singleton.interface.js +2 -5
  134. package/esm/schema/type-guards.js +40 -53
  135. package/esm/types.js +1 -2
  136. package/esm/url/index.js +5 -8
  137. package/esm/url/opra-url-path-component.js +3 -7
  138. package/esm/url/opra-url-path.js +14 -18
  139. package/esm/url/opra-url.js +15 -19
  140. package/esm/url/utils/decode-path-component.js +4 -8
  141. package/esm/url/utils/encode-path-component.js +3 -8
  142. package/esm/utils/path-utils.js +2 -7
  143. package/package.json +1 -1
  144. package/types/document/data-type/complex-type.d.ts +8 -2
  145. package/types/document/resource/collection.d.ts +5 -3
  146. package/types/document/resource/singleton.d.ts +3 -1
  147. package/types/filter/ast/terms/qualified-identifier.d.ts +4 -0
  148. package/types/http/http-params.d.ts +20 -19
@@ -1,13 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.unescapeString = exports.escapeString = void 0;
4
1
  const unescapeRegEx = /\\(.)/g;
5
2
  const escapeRegEx = /(\\)/g;
6
- function escapeString(s) {
3
+ export function escapeString(s) {
7
4
  return s.replace(escapeRegEx, '\\\\');
8
5
  }
9
- exports.escapeString = escapeString;
10
- function unescapeString(s) {
6
+ export function unescapeString(s) {
11
7
  return s.replace(unescapeRegEx, '$1');
12
8
  }
13
- exports.unescapeString = unescapeString;
@@ -1,15 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.translate = void 0;
4
- const string_utils_js_1 = require("./string-utils.js");
1
+ import { escapeString } from './string-utils.js';
5
2
  const bracketRegEx = /(\))/g;
6
- function translate(key, arg0, arg1) {
3
+ export function translate(key, arg0, arg1) {
7
4
  const options = arg0 && typeof arg0 === 'object' ? arg0 : undefined;
8
5
  const fallback = typeof arg0 === 'string' ? arg0 : arg1;
9
6
  return '$t(' +
10
7
  key +
11
8
  (options ? ',' + JSON.stringify(options) : '') +
12
- (fallback ? '?' + (0, string_utils_js_1.escapeString)(fallback).replace(bracketRegEx, '\\$1') : '') +
9
+ (fallback ? '?' + escapeString(fallback).replace(bracketRegEx, '\\$1') : '') +
13
10
  ')';
14
11
  }
15
- exports.translate = translate;
package/esm/index.js CHANGED
@@ -1,16 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uid = void 0;
4
- const tslib_1 = require("tslib");
5
- tslib_1.__exportStar(require("./types.js"), exports);
6
- tslib_1.__exportStar(require("./document/index.js"), exports);
7
- tslib_1.__exportStar(require("./exception/index.js"), exports);
8
- tslib_1.__exportStar(require("./filter/index.js"), exports); // todo review
9
- tslib_1.__exportStar(require("./helpers/index.js"), exports);
10
- tslib_1.__exportStar(require("./http/index.js"), exports);
11
- tslib_1.__exportStar(require("./i18n/index.js"), exports);
12
- tslib_1.__exportStar(require("./schema/index.js"), exports);
13
- tslib_1.__exportStar(require("./url/index.js"), exports);
14
- tslib_1.__exportStar(require("./utils/path-utils.js"), exports);
15
- var uid_1 = require("uid");
16
- Object.defineProperty(exports, "uid", { enumerable: true, get: function () { return uid_1.uid; } });
1
+ export * from './types.js';
2
+ export * from './document/index.js';
3
+ export * from './exception/index.js';
4
+ export * from './filter/index.js'; // todo review
5
+ export * from './helpers/index.js';
6
+ export * from './http/index.js';
7
+ export * from './i18n/index.js';
8
+ export * from './schema/index.js';
9
+ export * from './url/index.js';
10
+ export * from './utils/path-utils.js';
11
+ export { uid } from 'uid';
@@ -1,4 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SpecVersion = void 0;
4
- exports.SpecVersion = '1.0';
1
+ export const SpecVersion = '1.0';
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ComplexType = void 0;
4
- var ComplexType;
1
+ export var ComplexType;
5
2
  (function (ComplexType) {
6
3
  ComplexType.Kind = 'ComplexType';
7
- })(ComplexType = exports.ComplexType || (exports.ComplexType = {}));
4
+ })(ComplexType || (ComplexType = {}));
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EnumType = void 0;
4
- var EnumType;
1
+ export var EnumType;
5
2
  (function (EnumType) {
6
3
  EnumType.Kind = 'EnumType';
7
- })(EnumType = exports.EnumType || (exports.EnumType = {}));
4
+ })(EnumType || (EnumType = {}));
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MappedType = void 0;
4
- var MappedType;
1
+ export var MappedType;
5
2
  (function (MappedType) {
6
3
  MappedType.Kind = 'MappedType';
7
- })(MappedType = exports.MappedType || (exports.MappedType = {}));
4
+ })(MappedType || (MappedType = {}));
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SimpleType = void 0;
4
- var SimpleType;
1
+ export var SimpleType;
5
2
  (function (SimpleType) {
6
3
  SimpleType.Kind = 'SimpleType';
7
- })(SimpleType = exports.SimpleType || (exports.SimpleType = {}));
4
+ })(SimpleType || (SimpleType = {}));
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnionType = void 0;
4
- var UnionType;
1
+ export var UnionType;
5
2
  (function (UnionType) {
6
3
  UnionType.Kind = 'UnionType';
7
- })(UnionType = exports.UnionType || (exports.UnionType = {}));
4
+ })(UnionType || (UnionType = {}));
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,44 +1,41 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OpraSchema = void 0;
4
- const constants_js_1 = require("./constants.js");
5
- const complex_type_interface_js_1 = require("./data-type/complex-type.interface.js");
6
- const enum_type_interface_js_1 = require("./data-type/enum-type.interface.js");
7
- const mapped_type_interface_js_1 = require("./data-type/mapped-type.interface.js");
8
- const simple_type_interface_js_1 = require("./data-type/simple-type.interface.js");
9
- const union_type_interface_js_1 = require("./data-type/union-type.interface.js");
10
- const collection_interface_js_1 = require("./resource/collection.interface.js");
11
- const container_interface_js_1 = require("./resource/container.interface.js");
12
- const singleton_interface_js_1 = require("./resource/singleton.interface.js");
13
- const type_guards_js_1 = require("./type-guards.js");
14
- var OpraSchema;
1
+ import { SpecVersion as _SpecVersion } from './constants.js';
2
+ import { ComplexType as _ComplexType } from './data-type/complex-type.interface.js';
3
+ import { EnumType as _EnumType } from './data-type/enum-type.interface.js';
4
+ import { MappedType as _MappedType } from './data-type/mapped-type.interface.js';
5
+ import { SimpleType as _SimpleType } from './data-type/simple-type.interface.js';
6
+ import { UnionType as _UnionType } from './data-type/union-type.interface.js';
7
+ import { Collection as _Collection } from './resource/collection.interface.js';
8
+ import { Container as _Container } from './resource/container.interface.js';
9
+ import { Singleton as _Singleton } from './resource/singleton.interface.js';
10
+ import { isCollection as _isCollection, isComplexType as _isComplexType, isContainer as _isContainer, isDataType as _isDataType, isEnumType as _isEnumType, isMappedType as _isMappedType, isResource as _isResource, isSimpleType as _isSimpleType, isSingleton as _isSingleton, isUnionType as _isUnionType } from './type-guards.js';
11
+ export var OpraSchema;
15
12
  (function (OpraSchema) {
16
13
  // Re-export constants and types
17
- OpraSchema.SpecVersion = constants_js_1.SpecVersion;
14
+ OpraSchema.SpecVersion = _SpecVersion;
18
15
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
- OpraSchema.ComplexType = complex_type_interface_js_1.ComplexType;
16
+ OpraSchema.ComplexType = _ComplexType;
20
17
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
21
- OpraSchema.EnumType = enum_type_interface_js_1.EnumType;
18
+ OpraSchema.EnumType = _EnumType;
22
19
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
23
- OpraSchema.MappedType = mapped_type_interface_js_1.MappedType;
20
+ OpraSchema.MappedType = _MappedType;
24
21
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
25
- OpraSchema.SimpleType = simple_type_interface_js_1.SimpleType;
22
+ OpraSchema.SimpleType = _SimpleType;
26
23
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
27
- OpraSchema.UnionType = union_type_interface_js_1.UnionType;
24
+ OpraSchema.UnionType = _UnionType;
28
25
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
- OpraSchema.Collection = collection_interface_js_1.Collection;
26
+ OpraSchema.Collection = _Collection;
30
27
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
- OpraSchema.Container = container_interface_js_1.Container;
28
+ OpraSchema.Container = _Container;
32
29
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
- OpraSchema.Singleton = singleton_interface_js_1.Singleton;
34
- OpraSchema.isDataType = type_guards_js_1.isDataType;
35
- OpraSchema.isComplexType = type_guards_js_1.isComplexType;
36
- OpraSchema.isEnumType = type_guards_js_1.isEnumType;
37
- OpraSchema.isMappedType = type_guards_js_1.isMappedType;
38
- OpraSchema.isSimpleType = type_guards_js_1.isSimpleType;
39
- OpraSchema.isUnionType = type_guards_js_1.isUnionType;
40
- OpraSchema.isResource = type_guards_js_1.isResource;
41
- OpraSchema.isCollection = type_guards_js_1.isCollection;
42
- OpraSchema.isContainer = type_guards_js_1.isContainer;
43
- OpraSchema.isSingleton = type_guards_js_1.isSingleton;
44
- })(OpraSchema = exports.OpraSchema || (exports.OpraSchema = {}));
30
+ OpraSchema.Singleton = _Singleton;
31
+ OpraSchema.isDataType = _isDataType;
32
+ OpraSchema.isComplexType = _isComplexType;
33
+ OpraSchema.isEnumType = _isEnumType;
34
+ OpraSchema.isMappedType = _isMappedType;
35
+ OpraSchema.isSimpleType = _isSimpleType;
36
+ OpraSchema.isUnionType = _isUnionType;
37
+ OpraSchema.isResource = _isResource;
38
+ OpraSchema.isCollection = _isCollection;
39
+ OpraSchema.isContainer = _isContainer;
40
+ OpraSchema.isSingleton = _isSingleton;
41
+ })(OpraSchema || (OpraSchema = {}));
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Collection = void 0;
4
- var Collection;
1
+ export var Collection;
5
2
  (function (Collection) {
6
3
  Collection.Kind = 'Collection';
7
- })(Collection = exports.Collection || (exports.Collection = {}));
4
+ })(Collection || (Collection = {}));
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Container = void 0;
4
- var Container;
1
+ export var Container;
5
2
  (function (Container) {
6
3
  Container.Kind = 'Container';
7
- })(Container = exports.Container || (exports.Container = {}));
4
+ })(Container || (Container = {}));
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Singleton = void 0;
4
- var Singleton;
1
+ export var Singleton;
5
2
  (function (Singleton) {
6
3
  Singleton.Kind = 'Singleton';
7
- })(Singleton = exports.Singleton || (exports.Singleton = {}));
4
+ })(Singleton || (Singleton = {}));
@@ -1,59 +1,46 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isContainer = exports.isSingleton = exports.isCollection = exports.isResource = exports.isEnumType = exports.isMappedType = exports.isUnionType = exports.isSimpleType = exports.isComplexType = exports.isDataType = void 0;
4
- const complex_type_interface_js_1 = require("./data-type/complex-type.interface.js");
5
- const enum_type_interface_js_1 = require("./data-type/enum-type.interface.js");
6
- const mapped_type_interface_js_1 = require("./data-type/mapped-type.interface.js");
7
- const simple_type_interface_js_1 = require("./data-type/simple-type.interface.js");
8
- const union_type_interface_js_1 = require("./data-type/union-type.interface.js");
9
- const collection_interface_js_1 = require("./resource/collection.interface.js");
10
- const container_interface_js_1 = require("./resource/container.interface.js");
11
- const singleton_interface_js_1 = require("./resource/singleton.interface.js");
12
- function isDataType(obj) {
1
+ import { ComplexType } from './data-type/complex-type.interface.js';
2
+ import { EnumType } from './data-type/enum-type.interface.js';
3
+ import { MappedType } from './data-type/mapped-type.interface.js';
4
+ import { SimpleType } from './data-type/simple-type.interface.js';
5
+ import { UnionType } from './data-type/union-type.interface.js';
6
+ import { Collection } from './resource/collection.interface.js';
7
+ import { Container } from './resource/container.interface.js';
8
+ import { Singleton } from './resource/singleton.interface.js';
9
+ export function isDataType(obj) {
13
10
  return obj && typeof obj === 'object' &&
14
- (obj.kind === complex_type_interface_js_1.ComplexType.Kind ||
15
- obj.kind === enum_type_interface_js_1.EnumType.Kind ||
16
- obj.kind === mapped_type_interface_js_1.MappedType.Kind ||
17
- obj.kind === simple_type_interface_js_1.SimpleType.Kind ||
18
- obj.kind === union_type_interface_js_1.UnionType.Kind);
19
- }
20
- exports.isDataType = isDataType;
21
- function isComplexType(obj) {
22
- return obj && typeof obj === 'object' && obj.kind === complex_type_interface_js_1.ComplexType.Kind;
23
- }
24
- exports.isComplexType = isComplexType;
25
- function isSimpleType(obj) {
26
- return obj && typeof obj === 'object' && obj.kind === simple_type_interface_js_1.SimpleType.Kind;
27
- }
28
- exports.isSimpleType = isSimpleType;
29
- function isUnionType(obj) {
30
- return obj && typeof obj === 'object' && obj.kind === union_type_interface_js_1.UnionType.Kind;
31
- }
32
- exports.isUnionType = isUnionType;
33
- function isMappedType(obj) {
34
- return obj && typeof obj === 'object' && obj.kind === mapped_type_interface_js_1.MappedType.Kind;
35
- }
36
- exports.isMappedType = isMappedType;
37
- function isEnumType(obj) {
38
- return obj && typeof obj === 'object' && obj.kind === enum_type_interface_js_1.EnumType.Kind;
39
- }
40
- exports.isEnumType = isEnumType;
41
- function isResource(obj) {
11
+ (obj.kind === ComplexType.Kind ||
12
+ obj.kind === EnumType.Kind ||
13
+ obj.kind === MappedType.Kind ||
14
+ obj.kind === SimpleType.Kind ||
15
+ obj.kind === UnionType.Kind);
16
+ }
17
+ export function isComplexType(obj) {
18
+ return obj && typeof obj === 'object' && obj.kind === ComplexType.Kind;
19
+ }
20
+ export function isSimpleType(obj) {
21
+ return obj && typeof obj === 'object' && obj.kind === SimpleType.Kind;
22
+ }
23
+ export function isUnionType(obj) {
24
+ return obj && typeof obj === 'object' && obj.kind === UnionType.Kind;
25
+ }
26
+ export function isMappedType(obj) {
27
+ return obj && typeof obj === 'object' && obj.kind === MappedType.Kind;
28
+ }
29
+ export function isEnumType(obj) {
30
+ return obj && typeof obj === 'object' && obj.kind === EnumType.Kind;
31
+ }
32
+ export function isResource(obj) {
42
33
  return obj && typeof obj === 'object' &&
43
- (obj.kind === container_interface_js_1.Container.Kind ||
44
- obj.kind === collection_interface_js_1.Collection.Kind ||
45
- obj.kind === singleton_interface_js_1.Singleton.Kind);
34
+ (obj.kind === Container.Kind ||
35
+ obj.kind === Collection.Kind ||
36
+ obj.kind === Singleton.Kind);
46
37
  }
47
- exports.isResource = isResource;
48
- function isCollection(obj) {
49
- return obj && typeof obj === 'object' && obj.kind === collection_interface_js_1.Collection.Kind;
38
+ export function isCollection(obj) {
39
+ return obj && typeof obj === 'object' && obj.kind === Collection.Kind;
50
40
  }
51
- exports.isCollection = isCollection;
52
- function isSingleton(obj) {
53
- return obj && typeof obj === 'object' && obj.kind === singleton_interface_js_1.Singleton.Kind;
41
+ export function isSingleton(obj) {
42
+ return obj && typeof obj === 'object' && obj.kind === Singleton.Kind;
54
43
  }
55
- exports.isSingleton = isSingleton;
56
- function isContainer(obj) {
57
- return obj && typeof obj === 'object' && obj.kind === container_interface_js_1.Container.Kind;
44
+ export function isContainer(obj) {
45
+ return obj && typeof obj === 'object' && obj.kind === Container.Kind;
58
46
  }
59
- exports.isContainer = isContainer;
package/esm/types.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/esm/url/index.js CHANGED
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./opra-url.js"), exports);
5
- tslib_1.__exportStar(require("./opra-url-path.js"), exports);
6
- tslib_1.__exportStar(require("./opra-url-path-component.js"), exports);
7
- tslib_1.__exportStar(require("./utils/encode-path-component.js"), exports);
8
- tslib_1.__exportStar(require("./utils/decode-path-component.js"), exports);
1
+ export * from './opra-url.js';
2
+ export * from './opra-url-path.js';
3
+ export * from './opra-url-path-component.js';
4
+ export * from './utils/encode-path-component.js';
5
+ export * from './utils/decode-path-component.js';
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OpraURLPathComponent = void 0;
4
- const encode_path_component_js_1 = require("./utils/encode-path-component.js");
1
+ import { encodePathComponent } from './utils/encode-path-component.js';
5
2
  const nodeInspectCustom = Symbol.for('nodejs.util.inspect.custom');
6
- class OpraURLPathComponent {
3
+ export class OpraURLPathComponent {
7
4
  constructor(init) {
8
5
  this.resource = init.resource;
9
6
  this.key = init.key;
10
7
  this.typeCast = init.typeCast;
11
8
  }
12
9
  toString() {
13
- const obj = (0, encode_path_component_js_1.encodePathComponent)(this.resource, this.key, this.typeCast);
10
+ const obj = encodePathComponent(this.resource, this.key, this.typeCast);
14
11
  if (obj)
15
12
  Object.setPrototypeOf(obj, OpraURLPathComponent.prototype);
16
13
  return obj;
@@ -27,4 +24,3 @@ class OpraURLPathComponent {
27
24
  return out;
28
25
  }
29
26
  }
30
- exports.OpraURLPathComponent = OpraURLPathComponent;
@@ -1,17 +1,14 @@
1
- "use strict";
2
1
  var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.OpraURLPath = void 0;
5
- const fast_tokenizer_1 = require("fast-tokenizer");
6
- const index_js_1 = require("../helpers/index.js");
7
- const path_utils_js_1 = require("../utils/path-utils.js");
8
- const opra_url_path_component_js_1 = require("./opra-url-path-component.js");
9
- const decode_path_component_js_1 = require("./utils/decode-path-component.js");
10
- const encode_path_component_js_1 = require("./utils/encode-path-component.js");
2
+ import { tokenize } from 'fast-tokenizer';
3
+ import { isURL } from '../helpers/index.js';
4
+ import { normalizePath } from '../utils/path-utils.js';
5
+ import { OpraURLPathComponent } from './opra-url-path-component.js';
6
+ import { decodePathComponent } from './utils/decode-path-component.js';
7
+ import { encodePathComponent } from './utils/encode-path-component.js';
11
8
  const nodeInspectCustom = Symbol.for('nodejs.util.inspect.custom');
12
9
  const kEntries = Symbol('kEntries');
13
10
  const kOptions = Symbol('kOptions');
14
- class OpraURLPath {
11
+ export class OpraURLPath {
15
12
  constructor(init, options) {
16
13
  this[_a] = [];
17
14
  this[kOptions] = { ...options, onChange: undefined };
@@ -92,7 +89,7 @@ class OpraURLPath {
92
89
  }
93
90
  toString() {
94
91
  return this[kEntries]
95
- .map(x => (0, encode_path_component_js_1.encodePathComponent)(x.resource, x.key, x.typeCast)).join('/');
92
+ .map(x => encodePathComponent(x.resource, x.key, x.typeCast)).join('/');
96
93
  }
97
94
  values() {
98
95
  let i = -1;
@@ -112,24 +109,24 @@ class OpraURLPath {
112
109
  }
113
110
  _join(target, source) {
114
111
  if (typeof source === 'string') {
115
- const pathTokenizer = (0, fast_tokenizer_1.tokenize)((0, path_utils_js_1.normalizePath)(source, true), {
112
+ const pathTokenizer = tokenize(normalizePath(source, true), {
116
113
  delimiters: '/', quotes: true, brackets: true,
117
114
  });
118
115
  for (const x of pathTokenizer) {
119
- const p = (0, decode_path_component_js_1.decodePathComponent)(x);
120
- target.push(new opra_url_path_component_js_1.OpraURLPathComponent(p));
116
+ const p = decodePathComponent(x);
117
+ target.push(new OpraURLPathComponent(p));
121
118
  }
122
119
  return;
123
120
  }
124
121
  if (source instanceof OpraURLPath) {
125
- target.push(...source[kEntries].map(x => new opra_url_path_component_js_1.OpraURLPathComponent(x)));
122
+ target.push(...source[kEntries].map(x => new OpraURLPathComponent(x)));
126
123
  return;
127
124
  }
128
125
  if (typeof source === 'object' && source.path instanceof OpraURLPath) {
129
126
  this._join(target, source.path);
130
127
  return;
131
128
  }
132
- if ((0, index_js_1.isURL)(source)) {
129
+ if (isURL(source)) {
133
130
  this._join(target, source.pathname);
134
131
  return;
135
132
  }
@@ -137,7 +134,7 @@ class OpraURLPath {
137
134
  source.forEach(x => this._join(target, x));
138
135
  return;
139
136
  }
140
- target.push(new opra_url_path_component_js_1.OpraURLPathComponent(source));
137
+ target.push(new OpraURLPathComponent(source));
141
138
  }
142
139
  /* istanbul ignore next */
143
140
  [(_a = kEntries, nodeInspectCustom)]() {
@@ -150,6 +147,5 @@ class OpraURLPath {
150
147
  return 'OpraURLPath';
151
148
  }
152
149
  }
153
- exports.OpraURLPath = OpraURLPath;
154
150
  OpraURLPath.kEntries = kEntries;
155
151
  OpraURLPath.kOptions = kOptions;
@@ -1,12 +1,9 @@
1
- "use strict";
2
1
  var _a;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.OpraURL = void 0;
5
- const fast_tokenizer_1 = require("fast-tokenizer");
6
- const index_js_1 = require("../http/index.js");
7
- const path_utils_js_1 = require("../utils/path-utils.js");
8
- const opra_url_path_js_1 = require("./opra-url-path.js");
9
- const decode_path_component_js_1 = require("./utils/decode-path-component.js");
2
+ import { splitString, tokenize } from 'fast-tokenizer';
3
+ import { HttpParams } from '../http/index.js';
4
+ import { normalizePath } from '../utils/path-utils.js';
5
+ import { OpraURLPath } from './opra-url-path.js';
6
+ import { decodePathComponent } from './utils/decode-path-component.js';
10
7
  const nodeInspectCustom = Symbol.for('nodejs.util.inspect.custom');
11
8
  const urlRegEx = /^(?:((?:[A-Z][A-Z+-.]+:)+)\/\/([^/?]+))?(.*)?$/i;
12
9
  const schemeRegEx = /^([A-Z][A-Z+-.]+:?)+$/i;
@@ -15,7 +12,7 @@ const hostnameRegEx = /^([^/:]+)$/;
15
12
  const kContext = Symbol('kContext');
16
13
  const kPath = Symbol('kPath');
17
14
  const kParams = Symbol('kParams');
18
- class OpraURL {
15
+ export class OpraURL {
19
16
  constructor(input, base) {
20
17
  this[_a] = {
21
18
  protocol: '',
@@ -26,13 +23,13 @@ class OpraURL {
26
23
  hash: '',
27
24
  password: ''
28
25
  };
29
- this[kPath] = new opra_url_path_js_1.OpraURLPath('', {
26
+ this[kPath] = new OpraURLPath('', {
30
27
  onChange: () => {
31
28
  this[kContext].pathname = undefined;
32
29
  this[kContext].address = undefined;
33
30
  }
34
31
  });
35
- this[kParams] = new index_js_1.HttpParams('', {
32
+ this[kParams] = new HttpParams('', {
36
33
  onChange: () => {
37
34
  this[kContext].search = undefined;
38
35
  }
@@ -207,10 +204,10 @@ class OpraURL {
207
204
  this.protocol = m[1];
208
205
  const isAbsolute = !!m[2];
209
206
  if (isAbsolute) {
210
- let tokens = (0, fast_tokenizer_1.splitString)(m[2], { delimiters: '@' });
207
+ let tokens = splitString(m[2], { delimiters: '@' });
211
208
  if (tokens.length > 1) {
212
209
  this.host = tokens[1];
213
- tokens = (0, fast_tokenizer_1.splitString)(tokens[0], { delimiters: ':' });
210
+ tokens = splitString(tokens[0], { delimiters: ':' });
214
211
  this.username = tokens[0] ? decodeURIComponent(tokens[0]) : '';
215
212
  this.password = tokens[1] ? decodeURIComponent(tokens[1]) : '';
216
213
  }
@@ -223,10 +220,10 @@ class OpraURL {
223
220
  this.password = '';
224
221
  }
225
222
  input = m[3] || '';
226
- let tokenizer = (0, fast_tokenizer_1.tokenize)(input, { delimiters: '#', quotes: true, brackets: true });
223
+ let tokenizer = tokenize(input, { delimiters: '#', quotes: true, brackets: true });
227
224
  input = tokenizer.next() || '';
228
225
  this.hash = tokenizer.join('#');
229
- tokenizer = (0, fast_tokenizer_1.tokenize)(input, { delimiters: '?', quotes: true, brackets: true });
226
+ tokenizer = tokenize(input, { delimiters: '?', quotes: true, brackets: true });
230
227
  this._setPathname(tokenizer.next() || '', isAbsolute);
231
228
  this.search = tokenizer.join('&');
232
229
  }
@@ -281,11 +278,11 @@ class OpraURL {
281
278
  this.path.clear();
282
279
  if (!v)
283
280
  return;
284
- const pathTokenizer = (0, fast_tokenizer_1.tokenize)((0, path_utils_js_1.normalizePath)(v, true), {
281
+ const pathTokenizer = tokenize(normalizePath(v, true), {
285
282
  delimiters: '/', quotes: true, brackets: true,
286
283
  });
287
284
  if (trimPrefix && this.prefix) {
288
- const prefixTokenizer = (0, fast_tokenizer_1.tokenize)((0, path_utils_js_1.normalizePath)(this.prefix, true), {
285
+ const prefixTokenizer = tokenize(normalizePath(this.prefix, true), {
289
286
  delimiters: '/', quotes: true, brackets: true,
290
287
  });
291
288
  for (const a of prefixTokenizer) {
@@ -295,12 +292,11 @@ class OpraURL {
295
292
  }
296
293
  }
297
294
  for (const x of pathTokenizer) {
298
- const p = (0, decode_path_component_js_1.decodePathComponent)(x);
295
+ const p = decodePathComponent(x);
299
296
  this.path.join(p);
300
297
  }
301
298
  }
302
299
  }
303
- exports.OpraURL = OpraURL;
304
300
  OpraURL.kContext = kContext;
305
301
  OpraURL.kPath = kPath;
306
302
  OpraURL.kParams = kParams;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decodePathComponent = void 0;
4
- const fast_tokenizer_1 = require("fast-tokenizer");
1
+ import { splitString } from 'fast-tokenizer';
5
2
  const pathComponentRegEx = /^([^/?#:@]+)(?:@([^/?#:]*))?(?:::(.*))?$/;
6
- function decodePathComponent(input) {
3
+ export function decodePathComponent(input) {
7
4
  const m = pathComponentRegEx.exec(input);
8
5
  if (!m)
9
6
  throw Object.assign(new TypeError('Invalid URL path'), {
@@ -14,9 +11,9 @@ function decodePathComponent(input) {
14
11
  let key;
15
12
  if (m[2]) {
16
13
  const s = decodeURIComponent(m[2] || '');
17
- const b = (0, fast_tokenizer_1.splitString)(s, { delimiters: ';', quotes: true, escape: false });
14
+ const b = splitString(s, { delimiters: ';', quotes: true, escape: false });
18
15
  for (const k of b) {
19
- const c = (0, fast_tokenizer_1.splitString)(k, { delimiters: '=', quotes: true, escape: false });
16
+ const c = splitString(k, { delimiters: '=', quotes: true, escape: false });
20
17
  if ((b.length > 1 && c.length < 2) ||
21
18
  (key &&
22
19
  (c.length >= 2 && typeof key !== 'object') ||
@@ -38,4 +35,3 @@ function decodePathComponent(input) {
38
35
  }
39
36
  return { resource, key };
40
37
  }
41
- exports.decodePathComponent = decodePathComponent;