@opra/common 0.16.2 → 0.17.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.
Files changed (149) hide show
  1. package/cjs/document/constants.js +1 -1
  2. package/cjs/document/data-type/complex-type.js +69 -56
  3. package/cjs/document/data-type/simple-type.js +0 -1
  4. package/cjs/document/resource/collection.js +15 -16
  5. package/cjs/document/resource/singleton.js +2 -2
  6. package/cjs/http/http-params.js +10 -11
  7. package/esm/document/api-document.js +33 -37
  8. package/esm/document/constants.js +3 -6
  9. package/esm/document/data-type/api-field.js +12 -15
  10. package/esm/document/data-type/builtin/any.type.js +5 -8
  11. package/esm/document/data-type/builtin/base64.type.js +5 -8
  12. package/esm/document/data-type/builtin/bigint.type.js +5 -8
  13. package/esm/document/data-type/builtin/boolean.type.js +8 -11
  14. package/esm/document/data-type/builtin/date.type.js +7 -10
  15. package/esm/document/data-type/builtin/guid.type.js +9 -12
  16. package/esm/document/data-type/builtin/index.js +10 -13
  17. package/esm/document/data-type/builtin/integer.type.js +10 -13
  18. package/esm/document/data-type/builtin/number.type.js +7 -10
  19. package/esm/document/data-type/builtin/object.type.js +5 -8
  20. package/esm/document/data-type/builtin/string.type.js +8 -11
  21. package/esm/document/data-type/builtin/time.type.js +7 -10
  22. package/esm/document/data-type/builtin/timestamp.type.js +9 -12
  23. package/esm/document/data-type/complex-type.js +94 -85
  24. package/esm/document/data-type/data-type.js +9 -12
  25. package/esm/document/data-type/enum-type.js +15 -19
  26. package/esm/document/data-type/mapped-type.js +24 -29
  27. package/esm/document/data-type/simple-type.js +17 -22
  28. package/esm/document/data-type/union-type.js +26 -29
  29. package/esm/document/factory/add-references.js +3 -7
  30. package/esm/document/factory/create-document.js +10 -16
  31. package/esm/document/factory/factory.js +33 -37
  32. package/esm/document/factory/import-resource-class.js +16 -22
  33. package/esm/document/factory/import-type-class.js +24 -34
  34. package/esm/document/factory/index.js +1 -4
  35. package/esm/document/factory/process-resources.js +10 -16
  36. package/esm/document/factory/process-types.js +31 -37
  37. package/esm/document/index.js +14 -17
  38. package/esm/document/resource/collection.js +58 -63
  39. package/esm/document/resource/resource.js +9 -12
  40. package/esm/document/resource/singleton.js +27 -31
  41. package/esm/document/utils/inspect.util.js +4 -7
  42. package/esm/document/utils/string-compare.util.js +1 -5
  43. package/esm/exception/enums/issue-severity.enum.js +2 -5
  44. package/esm/exception/error-issue.js +1 -2
  45. package/esm/exception/http-errors/bad-request.error.js +4 -8
  46. package/esm/exception/http-errors/failed-dependency.error.js +4 -8
  47. package/esm/exception/http-errors/forbidden.error.js +4 -8
  48. package/esm/exception/http-errors/internal-server.error.js +4 -8
  49. package/esm/exception/http-errors/method-not-allowed.error.js +4 -8
  50. package/esm/exception/http-errors/not-acceptable.error.js +4 -8
  51. package/esm/exception/http-errors/not-found.error.js +4 -8
  52. package/esm/exception/http-errors/unauthorized.error.js +4 -8
  53. package/esm/exception/http-errors/unprocessable-entity.error.js +4 -8
  54. package/esm/exception/index.js +15 -18
  55. package/esm/exception/opra-exception.js +3 -7
  56. package/esm/exception/resource-errors/resource-conflict.error.js +4 -8
  57. package/esm/exception/resource-errors/resource-not-found.error.js +4 -8
  58. package/esm/exception/wrap-exception.js +20 -24
  59. package/esm/filter/antlr/OpraFilterLexer.js +6 -9
  60. package/esm/filter/antlr/OpraFilterListener.js +2 -5
  61. package/esm/filter/antlr/OpraFilterParser.js +79 -126
  62. package/esm/filter/antlr/OpraFilterVisitor.js +2 -5
  63. package/esm/filter/ast/abstract/ast.js +1 -5
  64. package/esm/filter/ast/abstract/expression.js +2 -6
  65. package/esm/filter/ast/abstract/literal.js +2 -6
  66. package/esm/filter/ast/abstract/term.js +2 -6
  67. package/esm/filter/ast/expressions/arithmetic-expression.js +3 -8
  68. package/esm/filter/ast/expressions/array-expression.js +2 -6
  69. package/esm/filter/ast/expressions/comparison-expression.js +2 -6
  70. package/esm/filter/ast/expressions/logical-expression.js +2 -6
  71. package/esm/filter/ast/expressions/parentheses-expression.js +2 -6
  72. package/esm/filter/ast/index.js +16 -19
  73. package/esm/filter/ast/terms/boolean-literal.js +2 -6
  74. package/esm/filter/ast/terms/date-literal.js +8 -12
  75. package/esm/filter/ast/terms/external-constant.js +2 -6
  76. package/esm/filter/ast/terms/null-literal.js +2 -6
  77. package/esm/filter/ast/terms/number-literal.js +4 -8
  78. package/esm/filter/ast/terms/qualified-identifier.js +2 -6
  79. package/esm/filter/ast/terms/string-literal.js +4 -8
  80. package/esm/filter/ast/terms/time-literal.js +6 -10
  81. package/esm/filter/build.js +45 -69
  82. package/esm/filter/errors.js +3 -9
  83. package/esm/filter/filter-tree-visitor.js +26 -31
  84. package/esm/filter/index.js +5 -8
  85. package/esm/filter/opra-error-listener.js +4 -8
  86. package/esm/filter/parse.js +14 -19
  87. package/esm/filter/utils.js +2 -7
  88. package/esm/helpers/function-utils.js +8 -14
  89. package/esm/helpers/get-stack-filename.js +1 -5
  90. package/esm/helpers/index.js +8 -11
  91. package/esm/helpers/is-url.js +1 -5
  92. package/esm/helpers/mixin-utils.js +2 -7
  93. package/esm/helpers/object-utils.js +6 -12
  94. package/esm/helpers/path-to-object-tree.js +1 -5
  95. package/esm/helpers/responsive-map.js +1 -5
  96. package/esm/helpers/type-guards.js +7 -17
  97. package/esm/http/codecs/boolean-codec.js +1 -5
  98. package/esm/http/codecs/date-codec.js +1 -5
  99. package/esm/http/codecs/filter-codec.js +5 -9
  100. package/esm/http/codecs/integer-codec.js +2 -6
  101. package/esm/http/codecs/number-codec.js +1 -5
  102. package/esm/http/codecs/string-codec.js +1 -5
  103. package/esm/http/enums/http-headers-codes.enum.js +2 -5
  104. package/esm/http/enums/http-status-codes.enum.js +2 -5
  105. package/esm/http/enums/http-status-messages.js +1 -4
  106. package/esm/http/http-headers.js +5 -9
  107. package/esm/http/http-message.host.js +13 -18
  108. package/esm/http/http-params.js +30 -36
  109. package/esm/http/http-request-message.js +18 -22
  110. package/esm/http/http-response-message.js +23 -28
  111. package/esm/http/index.js +14 -17
  112. package/esm/http/interfaces/client-http-headers.interface.js +1 -2
  113. package/esm/http/interfaces/cookie-options.interface.js +1 -2
  114. package/esm/http/interfaces/server-http-headers.interface.js +1 -2
  115. package/esm/i18n/i18n.js +23 -28
  116. package/esm/i18n/index.js +5 -9
  117. package/esm/i18n/string-utils.js +2 -7
  118. package/esm/i18n/translate.js +3 -7
  119. package/esm/index.js +11 -16
  120. package/esm/schema/constants.js +1 -4
  121. package/esm/schema/data-type/complex-type.interface.js +2 -5
  122. package/esm/schema/data-type/data-type.interface.js +1 -2
  123. package/esm/schema/data-type/enum-type.interface.js +2 -5
  124. package/esm/schema/data-type/field.interface.js +1 -2
  125. package/esm/schema/data-type/mapped-type.interface.js +2 -5
  126. package/esm/schema/data-type/simple-type.interface.js +2 -5
  127. package/esm/schema/data-type/union-type.interface.js +2 -5
  128. package/esm/schema/document.interface.js +1 -2
  129. package/esm/schema/index.js +31 -34
  130. package/esm/schema/resource/collection.interface.js +2 -5
  131. package/esm/schema/resource/container.interface.js +2 -5
  132. package/esm/schema/resource/endpoint.interface.js +1 -2
  133. package/esm/schema/resource/resource.interface.js +1 -2
  134. package/esm/schema/resource/singleton.interface.js +2 -5
  135. package/esm/schema/type-guards.js +40 -53
  136. package/esm/types.js +1 -2
  137. package/esm/url/index.js +5 -8
  138. package/esm/url/opra-url-path-component.js +3 -7
  139. package/esm/url/opra-url-path.js +14 -18
  140. package/esm/url/opra-url.js +15 -19
  141. package/esm/url/utils/decode-path-component.js +4 -8
  142. package/esm/url/utils/encode-path-component.js +3 -8
  143. package/esm/utils/path-utils.js +2 -7
  144. package/package.json +1 -1
  145. package/types/document/data-type/complex-type.d.ts +8 -2
  146. package/types/document/resource/collection.d.ts +5 -3
  147. package/types/document/resource/singleton.d.ts +3 -1
  148. package/types/filter/ast/terms/qualified-identifier.d.ts +4 -0
  149. package/types/http/http-params.d.ts +20 -19
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encodePathComponent = void 0;
4
- const tslib_1 = require("tslib");
5
- const putil_isplainobject_1 = tslib_1.__importDefault(require("putil-isplainobject"));
6
- function encodePathComponent(resource, key, typeCast) {
1
+ import isPlainObject from 'putil-isplainobject';
2
+ export function encodePathComponent(resource, key, typeCast) {
7
3
  if (resource == null)
8
4
  return '';
9
5
  let keyString = '';
10
6
  if (key !== '' && key != null) {
11
- if ((0, putil_isplainobject_1.default)(key)) {
7
+ if (isPlainObject(key)) {
12
8
  const arr = [];
13
9
  for (const k of Object.keys(key)) {
14
10
  arr.push(encodeURIComponent(k) + '=' + encodeURIComponent(key[k]));
@@ -24,4 +20,3 @@ function encodePathComponent(resource, key, typeCast) {
24
20
  (keyString ? '@' + keyString : '') +
25
21
  (typeCast ? '::' + typeCast : '');
26
22
  }
27
- exports.encodePathComponent = encodePathComponent;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.joinPath = exports.normalizePath = void 0;
4
- function normalizePath(p, noLeadingSlash) {
1
+ export function normalizePath(p, noLeadingSlash) {
5
2
  if (!p)
6
3
  return '';
7
4
  while (noLeadingSlash && p.startsWith('/'))
@@ -10,8 +7,7 @@ function normalizePath(p, noLeadingSlash) {
10
7
  p = p.substring(0, p.length - 1);
11
8
  return p;
12
9
  }
13
- exports.normalizePath = normalizePath;
14
- function joinPath(...p) {
10
+ export function joinPath(...p) {
15
11
  const out = [];
16
12
  let s;
17
13
  for (let i = 0, l = p.length; i < l; i++) {
@@ -21,4 +17,3 @@ function joinPath(...p) {
21
17
  }
22
18
  return out.join('/');
23
19
  }
24
- exports.joinPath = joinPath;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/common",
3
- "version": "0.16.2",
3
+ "version": "0.17.1",
4
4
  "description": "Opra internationalization package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -30,10 +30,16 @@ export interface ComplexType extends StrictOmit<DataType, 'own' | 'exportSchema'
30
30
  readonly ctor: Type;
31
31
  readonly base?: ComplexType | UnionType;
32
32
  readonly own: ComplexType.OwnProperties;
33
+ readonly abstract?: boolean;
34
+ readonly additionalFields?: boolean;
33
35
  exportSchema(): OpraSchema.ComplexType;
34
36
  addField(init: ApiField.InitArguments): ApiField;
35
- getField(name: string): ApiField;
36
- normalizeFieldNames(fields: string | string[]): string[] | undefined;
37
+ iteratePath(path: string, silent?: boolean): IterableIterator<[string, ApiField | undefined, string]>;
38
+ getField(nameOrPath: string): ApiField;
39
+ findField(nameOrPath: string): ApiField | undefined;
40
+ normalizeFieldPath(fields: string): string;
41
+ normalizeFieldPath(fields: string[]): string[];
42
+ normalizeFieldPath(fields: string | string[]): string | string[];
37
43
  }
38
44
  /**
39
45
  * Type definition of ComplexType constructor type
@@ -44,9 +44,11 @@ export interface Collection extends StrictOmit<Resource, 'exportSchema' | '_cons
44
44
  readonly primaryKey: string[];
45
45
  exportSchema(): OpraSchema.Collection;
46
46
  parseKeyValue(value: any): any;
47
- normalizeFieldNames(fields: string[]): string[] | undefined;
48
- normalizeSortFields(fields: string[]): string[] | undefined;
49
- normalizeFilterFields(ast: Expression): Expression;
47
+ normalizeFieldPath(fields: string): string;
48
+ normalizeFieldPath(fields: string[]): string[];
49
+ normalizeFieldPath(fields: string | string[]): string | string[];
50
+ normalizeSortFields(fields: string | string[]): string[];
51
+ normalizeFilter(ast: Expression): Expression;
50
52
  _construct(init: Collection.InitArguments): void;
51
53
  }
52
54
  export interface CollectionConstructor {
@@ -34,7 +34,9 @@ export interface Singleton extends StrictOmit<Resource, 'exportSchema' | '_const
34
34
  readonly operations: Singleton.Operations;
35
35
  readonly controller?: object | Type;
36
36
  exportSchema(): OpraSchema.Singleton;
37
- normalizeFieldNames(fields: string[]): string[] | undefined;
37
+ normalizeFieldPath(fields: string): string;
38
+ normalizeFieldPath(fields: string[]): string[];
39
+ normalizeFieldPath(fields: string | string[]): string | string[];
38
40
  _construct(init: Singleton.InitArguments): void;
39
41
  }
40
42
  export interface SingletonConstructor {
@@ -1,4 +1,8 @@
1
+ import type { ApiField } from '../../../document/data-type/api-field.js';
2
+ import { DataType } from '../../../document/data-type/data-type.js';
1
3
  import { Literal } from '../abstract/literal.js';
2
4
  export declare class QualifiedIdentifier extends Literal {
5
+ dataType: DataType;
6
+ field?: ApiField;
3
7
  constructor(value: string);
4
8
  }
@@ -7,7 +7,8 @@ import { IntegerCodec } from './codecs/integer-codec.js';
7
7
  import { NumberCodec } from './codecs/number-codec.js';
8
8
  import { StringCodec } from './codecs/string-codec.js';
9
9
  export declare namespace HttpParams {
10
- type Initiator = string | URLSearchParams | HttpParams | Map<string, any> | Record<string, any>;
10
+ type Initiator = string | URLSearchParams | HttpParams | Map<string, HttpParams.Value> | Record<string, HttpParams.Value>;
11
+ type Value = string | number | boolean | object | null;
11
12
  interface Options {
12
13
  onChange?: () => void;
13
14
  params?: Record<string, ParamDefinition>;
@@ -16,8 +17,8 @@ export declare namespace HttpParams {
16
17
  codec?: Codec | string;
17
18
  };
18
19
  interface Codec {
19
- decode(value: string): any;
20
- encode(value: any): string;
20
+ decode(value: string): HttpParams.Value;
21
+ encode(value: HttpParams.Value): string;
21
22
  }
22
23
  }
23
24
  interface HttpParamMetadata {
@@ -36,7 +37,7 @@ export declare class HttpParams {
36
37
  protected static kSize: symbol;
37
38
  protected static kParamDefs: symbol;
38
39
  protected static kOptions: symbol;
39
- protected [kEntries]: ResponsiveMap<any[]>;
40
+ protected [kEntries]: ResponsiveMap<HttpParams.Value[]>;
40
41
  protected [kSize]: number;
41
42
  protected [kOptions]: HttpParams.Options;
42
43
  protected [kParamDefs]: Map<string, HttpParamMetadata>;
@@ -46,27 +47,27 @@ export declare class HttpParams {
46
47
  * Appends a new value to the existing set of values for a parameter
47
48
  * and returns this instance
48
49
  */
49
- append(name: string, value?: any): this;
50
+ append(name: string, value?: HttpParams.Value): this;
50
51
  appendAll(input: HttpParams.Initiator): this;
51
52
  changed(): void;
52
53
  clear(): void;
53
54
  /**
54
55
  * Deletes values for a given parameter
55
56
  */
56
- delete(name: string, value?: any): this;
57
+ delete(name: string, value?: HttpParams.Value): this;
57
58
  /**
58
59
  * Returns an iterable of key, value pairs for every entry in the map.
59
60
  */
60
- entries(): IterableIterator<[string, string]>;
61
- forEach(callbackFn: (value: string, key: string, parent: HttpParams) => void, thisArg?: any): void;
61
+ entries(): IterableIterator<[string, HttpParams.Value]>;
62
+ forEach(callbackFn: (value: HttpParams.Value, key: string, parent: HttpParams) => void, thisArg?: any): void;
62
63
  /**
63
64
  * Retrieves value of a given parameter at given index
64
65
  */
65
- get(name: string, index?: number): any;
66
+ get(name: string, index?: number): HttpParams.Value;
66
67
  /**
67
68
  * Retrieves an array of values for a given parameter.
68
69
  */
69
- getAll(name: string): any[] | null;
70
+ getAll(name: string): HttpParams.Value[] | null;
70
71
  /**
71
72
  * Retrieves the names of the parameters.
72
73
  */
@@ -74,7 +75,7 @@ export declare class HttpParams {
74
75
  /**
75
76
  * Retrieves the names of the parameters.
76
77
  */
77
- values(): IterableIterator<any>;
78
+ values(): IterableIterator<HttpParams.Value>;
78
79
  /**
79
80
  * Checks for existence of a parameter.
80
81
  */
@@ -83,23 +84,23 @@ export declare class HttpParams {
83
84
  * Sets or modifies a value for a given parameter.
84
85
  * If the header already exists, its value is replaced with the given value
85
86
  */
86
- set(name: string, value: any): this;
87
+ set(name: string, value?: HttpParams.Value): this;
87
88
  sort(compareFn?: (a: string, b: string) => number): this;
88
89
  /**
89
90
  * Serializes the body to an encoded string, where key-value pairs (separated by `=`) are
90
91
  * separated by `&`s.
91
92
  */
92
93
  toString(): string;
93
- getProxy(): Record<string, any>;
94
+ getProxy(): Record<string, HttpParams.Value>;
94
95
  define(params: Record<string, HttpParams.ParamDefinition>): this;
95
96
  define(name: string, options: HttpParams.ParamDefinition): this;
96
- encodeValue(value: any, key: string): string;
97
- decodeValue(value: string, key: string): any;
98
- protected _append(name: string, value?: any): void;
99
- protected _delete(name: string, value?: string | string[]): boolean;
100
- protected _set(name: string, value: any, index?: number): void;
101
- [Symbol.iterator](): IterableIterator<[string, string]>;
97
+ encodeValue(value: HttpParams.Value, key: string): string;
98
+ decodeValue(value: string, key: string): HttpParams.Value;
99
+ [Symbol.iterator](): IterableIterator<[string, HttpParams.Value]>;
102
100
  get [Symbol.toStringTag](): string;
101
+ protected _append(name: string, value?: HttpParams.Value): void;
102
+ protected _delete(name: string, value?: HttpParams.Value): boolean;
103
+ protected _set(name: string, value?: HttpParams.Value, index?: number): void;
103
104
  static codecs: {
104
105
  boolean: BooleanCodec;
105
106
  date: DateCodec;