@opra/client 0.13.0 → 0.15.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 (199) hide show
  1. package/cjs/content-disposition-d575fee5.js +473 -0
  2. package/cjs/cookie-signature-3e974173.js +64 -0
  3. package/cjs/index.min.mjs +7946 -7135
  4. package/cjs/mime-db-49f150d0.js +10719 -0
  5. package/cjs/mime-types-6e2bdb57.js +201 -0
  6. package/cjs/safe-buffer-8acd60c7.js +78 -0
  7. package/esm/content-disposition-65f281a9.js +470 -0
  8. package/esm/cookie-signature-bf274b6b.js +62 -0
  9. package/esm/index.min.mjs +7546 -6703
  10. package/esm/mime-db-d0f15d8f.js +10717 -0
  11. package/esm/mime-types-79c091fd.js +199 -0
  12. package/esm/safe-buffer-63383356.js +76 -0
  13. package/package.json +9 -3
  14. package/typings/common/document/api-document.d.ts +102 -0
  15. package/typings/common/document/constants.d.ts +3 -0
  16. package/typings/common/document/data-type/api-field.d.ts +41 -0
  17. package/typings/common/document/data-type/builtin/any.type.d.ts +2 -0
  18. package/typings/common/document/data-type/builtin/base64.type.d.ts +6 -0
  19. package/typings/common/document/data-type/builtin/bigint.type.d.ts +6 -0
  20. package/typings/common/document/data-type/builtin/boolean.type.d.ts +5 -0
  21. package/typings/common/document/data-type/builtin/date.type.d.ts +4 -0
  22. package/typings/common/document/data-type/builtin/guid.type.d.ts +7 -0
  23. package/typings/common/document/data-type/builtin/index.d.ts +10 -0
  24. package/typings/common/document/data-type/builtin/integer.type.d.ts +6 -0
  25. package/typings/common/document/data-type/builtin/number.type.d.ts +6 -0
  26. package/typings/common/document/data-type/builtin/object.type.d.ts +3 -0
  27. package/typings/common/document/data-type/builtin/string.type.d.ts +5 -0
  28. package/typings/common/document/data-type/builtin/time.type.d.ts +7 -0
  29. package/typings/common/document/data-type/builtin/timestamp.type.d.ts +5 -0
  30. package/typings/common/document/data-type/complex-type.d.ts +50 -0
  31. package/typings/common/document/data-type/data-type.d.ts +33 -0
  32. package/typings/common/document/data-type/enum-type.d.ts +32 -0
  33. package/typings/common/document/data-type/mapped-type.d.ts +53 -0
  34. package/typings/common/document/data-type/simple-type.d.ts +33 -0
  35. package/typings/common/document/data-type/union-type.d.ts +42 -0
  36. package/typings/common/document/factory/add-references.d.ts +4 -0
  37. package/typings/common/document/factory/create-document.d.ts +12 -0
  38. package/typings/common/document/factory/factory.d.ts +61 -0
  39. package/typings/common/document/factory/import-resource-class.d.ts +9 -0
  40. package/typings/common/document/factory/import-type-class.d.ts +17 -0
  41. package/typings/common/document/factory/index.d.ts +1 -0
  42. package/typings/common/document/factory/process-resources.d.ts +7 -0
  43. package/typings/common/document/factory/process-types.d.ts +6 -0
  44. package/typings/common/document/index.d.ts +14 -0
  45. package/typings/common/document/resource/collection.d.ts +67 -0
  46. package/typings/common/document/resource/resource.d.ts +29 -0
  47. package/typings/common/document/resource/singleton.d.ts +49 -0
  48. package/typings/common/exception/resource-errors/resource-not-found.error.d.ts +4 -0
  49. package/typings/common/helpers/function-utils.d.ts +4 -0
  50. package/typings/common/helpers/get-stack-filename.d.ts +1 -0
  51. package/typings/common/helpers/index.d.ts +7 -0
  52. package/typings/common/helpers/is-url.d.ts +1 -0
  53. package/typings/common/{schema/utils/clone-object.util.d.ts → helpers/object-utils.d.ts} +1 -0
  54. package/typings/common/helpers/path-to-object-tree.d.ts +4 -0
  55. package/typings/common/helpers/responsive-map.d.ts +15 -13
  56. package/typings/common/{utils → helpers}/type-guards.d.ts +3 -1
  57. package/typings/common/http/codecs/boolean-codec.d.ts +5 -0
  58. package/typings/common/http/{param-codec → codecs}/date-codec.d.ts +2 -2
  59. package/typings/common/http/{param-codec → codecs}/filter-codec.d.ts +2 -2
  60. package/typings/common/http/codecs/integer-codec.d.ts +11 -0
  61. package/typings/common/http/codecs/number-codec.d.ts +14 -0
  62. package/typings/common/http/codecs/string-codec.d.ts +16 -0
  63. package/typings/common/http/enums/http-headers-codes.enum.d.ts +13 -4
  64. package/typings/common/http/enums/http-status-messages.d.ts +65 -0
  65. package/typings/common/http/http-headers.d.ts +50 -34
  66. package/typings/common/http/http-message.host.d.ts +122 -0
  67. package/typings/common/http/http-params.d.ts +43 -29
  68. package/typings/common/http/http-request-message.d.ts +213 -0
  69. package/typings/common/http/http-response-message.d.ts +318 -0
  70. package/typings/common/http/index.d.ts +8 -11
  71. package/typings/common/http/interfaces/cookie-options.interface.d.ts +4 -0
  72. package/typings/common/http/multipart/batch-multipart.d.ts +0 -31
  73. package/typings/common/http/multipart/http-request-content.d.ts +0 -8
  74. package/typings/common/http/multipart/http-response-content.d.ts +0 -7
  75. package/typings/common/http/multipart/index.d.ts +0 -1
  76. package/typings/common/index.d.ts +6 -5
  77. package/typings/common/schema/constants.d.ts +2 -8
  78. package/typings/common/schema/data-type/complex-type.interface.d.ts +16 -0
  79. package/typings/common/schema/data-type/data-type.interface.d.ts +14 -0
  80. package/typings/common/schema/data-type/enum-type.interface.d.ts +15 -0
  81. package/typings/common/schema/data-type/field.interface.d.ts +21 -0
  82. package/typings/common/schema/data-type/mapped-type.interface.d.ts +11 -0
  83. package/typings/common/schema/data-type/simple-type.interface.d.ts +18 -0
  84. package/typings/common/schema/data-type/union-type.interface.d.ts +10 -0
  85. package/typings/common/schema/document.interface.d.ts +34 -0
  86. package/typings/common/schema/index.d.ts +51 -25
  87. package/typings/common/schema/resource/collection.interface.d.ts +33 -0
  88. package/typings/common/schema/resource/container.interface.d.ts +9 -0
  89. package/typings/common/schema/resource/endpoint.interface.d.ts +29 -0
  90. package/typings/common/schema/resource/resource.interface.d.ts +12 -0
  91. package/typings/common/schema/resource/singleton.interface.d.ts +22 -0
  92. package/typings/common/schema/type-guards.d.ts +20 -0
  93. package/typings/common/{schema/types.d.ts → types.d.ts} +0 -3
  94. package/typings/common/url/index.d.ts +2 -2
  95. package/typings/common/url/opra-url.d.ts +8 -27
  96. package/typings/common/url/utils/decode-path-component.d.ts +5 -0
  97. package/typings/common/url/utils/encode-path-component.d.ts +1 -0
  98. package/typings/common/utils/path-utils.d.ts +2 -0
  99. package/typings/constants.d.ts +1 -0
  100. package/typings/http/http-client.d.ts +27 -25
  101. package/typings/http/http-collection-node.d.ts +116 -0
  102. package/typings/http/http-request-observable.d.ts +28 -0
  103. package/typings/{common/http → http}/http-request.d.ts +4 -6
  104. package/typings/{common/http → http}/http-response.d.ts +12 -10
  105. package/typings/http/http-service-base.d.ts +5 -0
  106. package/typings/http/http-singleton-node.d.ts +65 -0
  107. package/typings/http/http-types.d.ts +17 -9
  108. package/typings/index.d.ts +7 -13
  109. package/typings/common/constants.d.ts +0 -0
  110. package/typings/common/http/http-param-codec.d.ts +0 -4
  111. package/typings/common/http/http-request-node.d.ts +0 -34
  112. package/typings/common/http/param-codec/boolean-codec.d.ts +0 -5
  113. package/typings/common/http/param-codec/integer-codec.d.ts +0 -9
  114. package/typings/common/http/param-codec/number-codec.d.ts +0 -12
  115. package/typings/common/http/param-codec/string-codec.d.ts +0 -14
  116. package/typings/common/http/utils/encodeURIParam.d.ts +0 -1
  117. package/typings/common/http/utils/normalize-headers.d.ts +0 -1
  118. package/typings/common/schema/decorators/opr-collection-resource.decorator.d.ts +0 -8
  119. package/typings/common/schema/decorators/opr-complex-type.decorator.d.ts +0 -6
  120. package/typings/common/schema/decorators/opr-field.decorator.d.ts +0 -3
  121. package/typings/common/schema/decorators/opr-resolver.decorator.d.ts +0 -8
  122. package/typings/common/schema/decorators/opr-simple-type.decorator.d.ts +0 -6
  123. package/typings/common/schema/decorators/opr-singleton-resource.decorator.d.ts +0 -8
  124. package/typings/common/schema/implementation/data-type/builtin/any.type.d.ts +0 -2
  125. package/typings/common/schema/implementation/data-type/builtin/base64-binary.type.d.ts +0 -2
  126. package/typings/common/schema/implementation/data-type/builtin/bigint.type.d.ts +0 -2
  127. package/typings/common/schema/implementation/data-type/builtin/boolean.type.d.ts +0 -2
  128. package/typings/common/schema/implementation/data-type/builtin/date-string.type.d.ts +0 -2
  129. package/typings/common/schema/implementation/data-type/builtin/date.type.d.ts +0 -2
  130. package/typings/common/schema/implementation/data-type/builtin/guid.type.d.ts +0 -2
  131. package/typings/common/schema/implementation/data-type/builtin/integer.type.d.ts +0 -2
  132. package/typings/common/schema/implementation/data-type/builtin/number.type.d.ts +0 -2
  133. package/typings/common/schema/implementation/data-type/builtin/object.type.d.ts +0 -2
  134. package/typings/common/schema/implementation/data-type/builtin/string.type.d.ts +0 -2
  135. package/typings/common/schema/implementation/data-type/builtin-data-types.d.ts +0 -4
  136. package/typings/common/schema/implementation/data-type/complex-type.d.ts +0 -29
  137. package/typings/common/schema/implementation/data-type/data-type.d.ts +0 -17
  138. package/typings/common/schema/implementation/data-type/simple-type.d.ts +0 -12
  139. package/typings/common/schema/implementation/data-type/union-type.d.ts +0 -16
  140. package/typings/common/schema/implementation/document-builder.d.ts +0 -16
  141. package/typings/common/schema/implementation/opra-document.d.ts +0 -44
  142. package/typings/common/schema/implementation/query/collection-count-query.d.ts +0 -14
  143. package/typings/common/schema/implementation/query/collection-create-query.d.ts +0 -18
  144. package/typings/common/schema/implementation/query/collection-delete-many-query.d.ts +0 -14
  145. package/typings/common/schema/implementation/query/collection-delete-query.d.ts +0 -10
  146. package/typings/common/schema/implementation/query/collection-get-query.d.ts +0 -21
  147. package/typings/common/schema/implementation/query/collection-search-query.d.ts +0 -30
  148. package/typings/common/schema/implementation/query/collection-update-many-query.d.ts +0 -15
  149. package/typings/common/schema/implementation/query/collection-update-query.d.ts +0 -19
  150. package/typings/common/schema/implementation/query/field-get-query.d.ts +0 -30
  151. package/typings/common/schema/implementation/query/index.d.ts +0 -27
  152. package/typings/common/schema/implementation/query/singleton-get-query.d.ts +0 -20
  153. package/typings/common/schema/implementation/resource/collection-resource-info.d.ts +0 -22
  154. package/typings/common/schema/implementation/resource/container-resource-info.d.ts +0 -13
  155. package/typings/common/schema/implementation/resource/resource-info.d.ts +0 -17
  156. package/typings/common/schema/implementation/resource/singleton-resource-info.d.ts +0 -15
  157. package/typings/common/schema/implementation/schema-builder/extract-resource-metadata.util.d.ts +0 -3
  158. package/typings/common/schema/implementation/schema-builder/extract-type-metadata.util.d.ts +0 -4
  159. package/typings/common/schema/interfaces/child-field-query.interface.d.ts +0 -4
  160. package/typings/common/schema/interfaces/data-type.metadata.d.ts +0 -18
  161. package/typings/common/schema/interfaces/resource-container.interface.d.ts +0 -8
  162. package/typings/common/schema/interfaces/resource.metadata.d.ts +0 -18
  163. package/typings/common/schema/opra-schema.definition.d.ts +0 -178
  164. package/typings/common/schema/type-helpers/extend-type.helper.d.ts +0 -3
  165. package/typings/common/schema/type-helpers/mixin-type.helper.d.ts +0 -2
  166. package/typings/common/schema/utils/class.utils.d.ts +0 -2
  167. package/typings/common/schema/utils/normalize-field-array.util.d.ts +0 -3
  168. package/typings/common/schema/utils/path-to-tree.util.d.ts +0 -4
  169. package/typings/common/url/formats/boolean-format.d.ts +0 -5
  170. package/typings/common/url/formats/date-format.d.ts +0 -16
  171. package/typings/common/url/formats/filter-format.d.ts +0 -6
  172. package/typings/common/url/formats/format.d.ts +0 -4
  173. package/typings/common/url/formats/integer-format.d.ts +0 -9
  174. package/typings/common/url/formats/number-format.d.ts +0 -12
  175. package/typings/common/url/formats/string-format.d.ts +0 -14
  176. package/typings/common/url/opra-url-search-params.d.ts +0 -5
  177. package/typings/common/url/utils/path-utils.d.ts +0 -8
  178. package/typings/common/utils/index.d.ts +0 -3
  179. package/typings/common/utils/is-url.d.ts +0 -1
  180. package/typings/common/utils/path-to-tree.d.ts +0 -4
  181. package/typings/http/http-collection-service.d.ts +0 -76
  182. package/typings/http/http-request-host.d.ts +0 -18
  183. package/typings/http/http-singleton-service.d.ts +0 -28
  184. package/typings/http/requests/collection-create-request.d.ts +0 -7
  185. package/typings/http/requests/collection-delete-many-request.d.ts +0 -7
  186. package/typings/http/requests/collection-delete-request.d.ts +0 -7
  187. package/typings/http/requests/collection-get-request.d.ts +0 -7
  188. package/typings/http/requests/collection-search-request.d.ts +0 -7
  189. package/typings/http/requests/collection-update-many-request.d.ts +0 -7
  190. package/typings/http/requests/collection-update-request.d.ts +0 -7
  191. package/typings/http/requests/singleton-create-request.d.ts +0 -7
  192. package/typings/http/requests/singleton-delete-request.d.ts +0 -7
  193. package/typings/http/requests/singleton-get-request.d.ts +0 -7
  194. package/typings/interfaces/http-options.interface.d.ts +0 -17
  195. package/typings/interfaces/http-request-config.interface.d.ts +0 -23
  196. /package/typings/common/{schema → document}/utils/inspect.util.d.ts +0 -0
  197. /package/typings/common/{schema → document}/utils/string-compare.util.d.ts +0 -0
  198. /package/typings/common/{schema/type-helpers/mixin.utils.d.ts → helpers/mixin-utils.d.ts} +0 -0
  199. /package/typings/http/{requests/batch-request.d.ts → batch-request.d.ts} +0 -0
@@ -0,0 +1,53 @@
1
+ import { Class, StrictOmit, Type } from 'ts-gems';
2
+ import { OpraSchema } from '../../schema/index.js';
3
+ import type { ApiDocument } from '../api-document.js';
4
+ import { ComplexType } from './complex-type.js';
5
+ import { DataType } from './data-type.js';
6
+ /**
7
+ * @namespace MappedType
8
+ */
9
+ export declare namespace MappedType {
10
+ interface InitArguments extends DataType.InitArguments, Pick<OpraSchema.MappedType, 'pick' | 'omit'> {
11
+ type: ComplexType;
12
+ }
13
+ interface OwnProperties extends DataType.OwnProperties, Pick<OpraSchema.MappedType, 'pick' | 'omit'> {
14
+ type: ComplexType;
15
+ }
16
+ interface Options<T, K = keyof T> {
17
+ pick?: readonly K[];
18
+ omit?: readonly K[];
19
+ }
20
+ interface Metadata extends StrictOmit<OpraSchema.MappedType, 'type'> {
21
+ type: Type;
22
+ }
23
+ }
24
+ /**
25
+ * Type definition of MappedType prototype
26
+ * @type MappedType
27
+ */
28
+ export interface MappedType extends StrictOmit<DataType, 'own' | 'exportSchema'>, Pick<ComplexType, 'additionalFields' | 'fields'>, MappedType.OwnProperties {
29
+ readonly own: MappedType.OwnProperties;
30
+ readonly type: ComplexType;
31
+ exportSchema(): OpraSchema.MappedType;
32
+ }
33
+ /**
34
+ * Type definition of MappedType constructor type
35
+ * @type MappedTypeConstructor
36
+ */
37
+ export interface MappedTypeConstructor {
38
+ prototype: MappedType;
39
+ new (document: ApiDocument, init: MappedType.InitArguments): MappedType;
40
+ <T extends any[], I1, S1, PickKey extends keyof I1, OmitKey extends keyof I1>(source: Class<T, I1, S1>, options: {
41
+ pickKeys?: readonly PickKey[];
42
+ omitKeys?: readonly OmitKey[];
43
+ }): Class<T, Omit<Pick<I1, PickKey>, OmitKey>>;
44
+ _applyMixin(target: Type, source: Type, options: MappedType.Options<any> & {
45
+ isInheritedPredicate: (fieldName: string) => boolean;
46
+ }): void;
47
+ }
48
+ /**
49
+ * @class MappedType
50
+ */
51
+ export declare const MappedType: MappedTypeConstructor;
52
+ export declare function PickType<T extends any[], I1, S1, K extends keyof I1>(classRef: Class<T, I1, S1>, keys: readonly K[]): Class<T, Pick<I1, K>> & Omit<Pick<S1, keyof typeof classRef>, 'prototype' | 'constructor'>;
53
+ export declare function OmitType<T extends any[], I1, S1, K extends keyof I1>(classRef: Class<T, I1, S1>, keys: readonly K[]): Class<T, Omit<I1, K>> & Omit<Pick<S1, keyof typeof classRef>, 'prototype' | 'constructor'>;
@@ -0,0 +1,33 @@
1
+ import { StrictOmit, Type } from 'ts-gems';
2
+ import { OpraSchema } from '../../schema/index.js';
3
+ import type { ApiDocument } from '../api-document.js';
4
+ import { DataType } from './data-type.js';
5
+ export declare namespace SimpleType {
6
+ interface InitArguments extends DataType.InitArguments, Pick<OpraSchema.SimpleType, 'ctor' | 'pattern' | 'codec'> {
7
+ base?: SimpleType;
8
+ }
9
+ interface OwnProperties extends DataType.OwnProperties, Readonly<Pick<OpraSchema.SimpleType, 'ctor' | 'pattern' | 'codec'>> {
10
+ }
11
+ interface DecoratorOptions extends DataType.DecoratorOptions, Pick<InitArguments, 'ctor' | 'pattern'> {
12
+ }
13
+ interface Metadata extends OpraSchema.SimpleType {
14
+ name: string;
15
+ }
16
+ }
17
+ export interface SimpleType extends StrictOmit<DataType, 'own' | 'exportSchema'>, SimpleType.OwnProperties {
18
+ readonly ctor: Type;
19
+ readonly base?: SimpleType;
20
+ readonly own: SimpleType.OwnProperties;
21
+ exportSchema(): OpraSchema.SimpleType;
22
+ decode(value: any): any;
23
+ encode(value: any): any;
24
+ }
25
+ export interface SimpleTypeConstructor {
26
+ new (document: ApiDocument, init?: SimpleType.InitArguments): SimpleType;
27
+ (init?: SimpleType.DecoratorOptions): ClassDecorator;
28
+ prototype: SimpleType;
29
+ }
30
+ /**
31
+ * @class SimpleType
32
+ */
33
+ export declare const SimpleType: SimpleTypeConstructor;
@@ -0,0 +1,42 @@
1
+ import { Class, StrictOmit, Type } from 'ts-gems';
2
+ import { OpraSchema } from '../../schema/index.js';
3
+ import type { ApiDocument } from '../api-document.js';
4
+ import { ComplexType } from './complex-type.js';
5
+ import { DataType } from './data-type.js';
6
+ import { MappedType } from './mapped-type.js';
7
+ /**
8
+ * @namespace UnionType
9
+ */
10
+ export declare namespace UnionType {
11
+ interface InitArguments extends DataType.InitArguments {
12
+ types: (ComplexType | UnionType | MappedType)[];
13
+ }
14
+ interface OwnProperties extends DataType.OwnProperties {
15
+ types: (ComplexType | UnionType | MappedType)[];
16
+ }
17
+ interface Metadata extends StrictOmit<OpraSchema.UnionType, 'types'> {
18
+ types: Type[];
19
+ }
20
+ }
21
+ /**
22
+ * Type definition of UnionType prototype
23
+ * @type UnionType
24
+ */
25
+ export interface UnionType extends StrictOmit<DataType, 'own' | 'exportSchema'>, Pick<ComplexType, 'additionalFields' | 'fields'>, UnionType.OwnProperties {
26
+ readonly own: UnionType.OwnProperties;
27
+ exportSchema(): OpraSchema.UnionType;
28
+ }
29
+ /**
30
+ * Type definition of UnionType constructor type
31
+ * @type UnionTypeConstructor
32
+ */
33
+ export interface UnionTypeConstructor {
34
+ prototype: UnionType;
35
+ new (document: ApiDocument, init: UnionType.InitArguments): UnionType;
36
+ <A1 extends any[], I1, S1, A2 extends any[], I2, S2, A3 extends any[], I3, S3, A4 extends any[], I4, S4>(c1: Class<A1, I1, S1>, c2: Class<A2, I2, S2>, c3?: Class<A3, I3, S3>, c4?: Class<A4, I4, S4>): Class<any[], I1 & I2 & I3 & I4, S1 & S2 & S3 & S4>;
37
+ _applyMixin(target: Type, ...sources: [Type]): void;
38
+ }
39
+ /**
40
+ * @class UnionType
41
+ */
42
+ export declare const UnionType: UnionTypeConstructor;
@@ -0,0 +1,4 @@
1
+ import type { OpraSchema } from '../../schema/index.js';
2
+ import { ApiDocument } from '../api-document.js';
3
+ import type { DocumentFactory } from './factory.js';
4
+ export declare function addReferences(this: DocumentFactory, references: Record<string, string | OpraSchema.ApiDocument | ApiDocument>): Promise<void>;
@@ -0,0 +1,12 @@
1
+ import { ApiDocument } from '../api-document.js';
2
+ import type { DocumentFactory } from './factory.js';
3
+ export declare function createDocument(this: DocumentFactory, init: DocumentFactory.InitArguments, options?: {
4
+ noBuiltinTypes?: boolean;
5
+ }): Promise<ApiDocument>;
6
+ /**
7
+ *
8
+ * @param url
9
+ * @protected
10
+ */
11
+ export declare function createDocumentFromUrl(this: DocumentFactory, url: string): Promise<ApiDocument>;
12
+ export declare function createBuiltinTypeDocument(this: DocumentFactory): Promise<ApiDocument>;
@@ -0,0 +1,61 @@
1
+ import { StrictOmit, Type } from 'ts-gems';
2
+ import { ResponsiveMap } from '../../helpers/index.js';
3
+ import { OpraSchema } from '../../schema/index.js';
4
+ import { ThunkAsync } from '../../types.js';
5
+ import { ApiDocument } from '../api-document.js';
6
+ import { addReferences } from './add-references.js';
7
+ import { createBuiltinTypeDocument, createDocument, createDocumentFromUrl } from './create-document.js';
8
+ import { extractCollectionSchema, extractSingletonSchema, importResourceClass } from './import-resource-class.js';
9
+ import { extractComplexTypeSchema, extractEnumTypeSchema, extractFieldSchema, extractMappedTypeSchema, extractSimpleTypeSchema, extractUnionTypeSchema, importTypeClass } from './import-type-class.js';
10
+ import { createCollection, createSingleton, processResourceQueue } from './process-resources.js';
11
+ import { addDataType, createDataTypeInstance, processTypes } from './process-types.js';
12
+ /**
13
+ * @namespace DocumentFactory
14
+ */
15
+ export declare namespace DocumentFactory {
16
+ type InitArguments = StrictOmit<OpraSchema.ApiDocument, 'references' | 'types' | 'resources'> & {
17
+ references?: Record<string, string | OpraSchema.ApiDocument | ApiDocument>;
18
+ resources?: ThunkAsync<Type | object>[] | Record<OpraSchema.Resource.Name, OpraSchema.Resource>;
19
+ types?: ThunkAsync<Type | OpraSchema.EnumThunk>[] | Record<string, OpraSchema.DataType>;
20
+ };
21
+ }
22
+ /**
23
+ * @class DocumentFactory
24
+ */
25
+ export declare class DocumentFactory {
26
+ protected document: ApiDocument;
27
+ protected typeQueue: ResponsiveMap<OpraSchema.DataType>;
28
+ protected resourceQueue: ResponsiveMap<OpraSchema.Resource>;
29
+ protected circularRefs: ResponsiveMap<any>;
30
+ protected curPath: string[];
31
+ protected cache: Map<any, any>;
32
+ protected createDocument: typeof createDocument;
33
+ protected createDocumentFromUrl: typeof createDocumentFromUrl;
34
+ protected createBuiltinTypeDocument: typeof createBuiltinTypeDocument;
35
+ protected addReferences: typeof addReferences;
36
+ protected importTypeClass: typeof importTypeClass;
37
+ protected extractSimpleTypeSchema: typeof extractSimpleTypeSchema;
38
+ protected extractComplexTypeSchema: typeof extractComplexTypeSchema;
39
+ protected extractMappedTypeSchema: typeof extractMappedTypeSchema;
40
+ protected extractUnionTypeSchema: typeof extractUnionTypeSchema;
41
+ protected extractEnumTypeSchema: typeof extractEnumTypeSchema;
42
+ protected extractFieldSchema: typeof extractFieldSchema;
43
+ protected processTypes: typeof processTypes;
44
+ protected createDataTypeInstance: typeof createDataTypeInstance;
45
+ protected addDataType: typeof addDataType;
46
+ protected importResourceClass: typeof importResourceClass;
47
+ protected extractSingletonSchema: typeof extractSingletonSchema;
48
+ protected extractCollectionSchema: typeof extractCollectionSchema;
49
+ protected processResourceQueue: typeof processResourceQueue;
50
+ protected createCollection: typeof createCollection;
51
+ protected createSingleton: typeof createSingleton;
52
+ /**
53
+ * Creates ApiDocument instance from given schema object
54
+ * @param init
55
+ */
56
+ static createDocument(init: DocumentFactory.InitArguments): Promise<ApiDocument>;
57
+ /**
58
+ * Downloads schema from the given URL and creates the document instance * @param url
59
+ */
60
+ static createDocumentFromUrl(url: string): Promise<ApiDocument>;
61
+ }
@@ -0,0 +1,9 @@
1
+ import { Type } from 'ts-gems';
2
+ import { OpraSchema } from '../../schema/index.js';
3
+ import type { ThunkAsync } from '../../types.js';
4
+ import type { Collection } from '../resource/collection.js';
5
+ import type { Singleton } from '../resource/singleton.js';
6
+ import type { DocumentFactory } from './factory.js';
7
+ export declare function importResourceClass(this: DocumentFactory, thunk: ThunkAsync<Type | object>): Promise<void>;
8
+ export declare function extractSingletonSchema(this: DocumentFactory, target: OpraSchema.Singleton, ctor: Type, metadata: Singleton.Metadata, controller: object | Type): Promise<void>;
9
+ export declare function extractCollectionSchema(this: DocumentFactory, target: OpraSchema.Collection, ctor: Type, metadata: Collection.Metadata, controller: object | Type): Promise<void>;
@@ -0,0 +1,17 @@
1
+ import { Type } from 'ts-gems';
2
+ import { OpraSchema } from '../../schema/index.js';
3
+ import type { ThunkAsync } from '../../types.js';
4
+ import type { ApiField } from '../data-type/api-field.js';
5
+ import type { ComplexType } from '../data-type/complex-type.js';
6
+ import type { EnumType } from '../data-type/enum-type.js';
7
+ import type { MappedType } from '../data-type/mapped-type.js';
8
+ import type { SimpleType } from '../data-type/simple-type.js';
9
+ import type { UnionType } from '../data-type/union-type.js';
10
+ import type { DocumentFactory } from './factory.js';
11
+ export declare function importTypeClass(this: DocumentFactory, typeThunk: ThunkAsync<Type | OpraSchema.EnumThunk>): Promise<string | OpraSchema.DataType>;
12
+ export declare function extractSimpleTypeSchema(this: DocumentFactory, target: OpraSchema.SimpleType, ctor: Type, metadata: SimpleType.Metadata): Promise<void>;
13
+ export declare function extractComplexTypeSchema(this: DocumentFactory, target: OpraSchema.ComplexType, ctor: Type, metadata: ComplexType.Metadata): Promise<void>;
14
+ export declare function extractMappedTypeSchema(this: DocumentFactory, target: OpraSchema.MappedType, ctor: Type, metadata: MappedType.Metadata): Promise<void>;
15
+ export declare function extractUnionTypeSchema(this: DocumentFactory, target: OpraSchema.UnionType, ctor: Type, metadata: UnionType.Metadata): Promise<void>;
16
+ export declare function extractEnumTypeSchema(this: DocumentFactory, target: OpraSchema.EnumType, enumObject: any, metadata: EnumType.Metadata): Promise<void>;
17
+ export declare function extractFieldSchema(this: DocumentFactory, target: OpraSchema.Field, ctor: Type, metadata: ApiField.Metadata, name: string): Promise<void>;
@@ -0,0 +1 @@
1
+ export * from './factory.js';
@@ -0,0 +1,7 @@
1
+ import { OpraSchema } from '../../schema/index.js';
2
+ import { Collection } from '../resource/collection.js';
3
+ import { Singleton } from '../resource/singleton.js';
4
+ import type { DocumentFactory } from './factory.js';
5
+ export declare function processResourceQueue(this: DocumentFactory): Promise<void>;
6
+ export declare function createCollection(this: DocumentFactory, name: string, schema: OpraSchema.Collection): Promise<Collection>;
7
+ export declare function createSingleton(this: DocumentFactory, name: string, schema: OpraSchema.Singleton): Promise<Singleton>;
@@ -0,0 +1,6 @@
1
+ import { OpraSchema } from '../../schema/index.js';
2
+ import { DataType } from '../data-type/data-type.js';
3
+ import type { DocumentFactory } from './factory.js';
4
+ export declare function processTypes(this: DocumentFactory): Promise<void>;
5
+ export declare function createDataTypeInstance(this: DocumentFactory, kind: OpraSchema.DataType.Kind, name?: string): DataType;
6
+ export declare function addDataType(this: DocumentFactory, schemaOrName: OpraSchema.DataType | string): DataType;
@@ -0,0 +1,14 @@
1
+ import 'reflect-metadata';
2
+ export * from './constants.js';
3
+ export * from './api-document.js';
4
+ export * from './factory/index.js';
5
+ export * from './data-type/data-type.js';
6
+ export * from './data-type/complex-type.js';
7
+ export * from './data-type/api-field.js';
8
+ export * from './data-type/enum-type.js';
9
+ export * from './data-type/mapped-type.js';
10
+ export * from './data-type/simple-type.js';
11
+ export * from './data-type/union-type.js';
12
+ export * from './resource/resource.js';
13
+ export * from './resource/collection.js';
14
+ export * from './resource/singleton.js';
@@ -0,0 +1,67 @@
1
+ import { StrictOmit } from 'ts-gems';
2
+ import { Expression } from '../../filter/index.js';
3
+ import { OpraSchema } from '../../schema/index.js';
4
+ import type { TypeThunkAsync } from '../../types.js';
5
+ import type { ApiDocument } from '../api-document.js';
6
+ import type { ComplexType } from '../data-type/complex-type.js';
7
+ import { Resource } from './resource.js';
8
+ export declare namespace Collection {
9
+ export interface InitArguments extends Resource.InitArguments, Pick<OpraSchema.Collection, 'primaryKey'> {
10
+ type: ComplexType;
11
+ operations: Operations;
12
+ }
13
+ export interface DecoratorOptions extends Resource.DecoratorOptions, Partial<Pick<OpraSchema.Collection, 'primaryKey'>> {
14
+ }
15
+ export interface Metadata extends StrictOmit<OpraSchema.Collection, 'type'> {
16
+ name: string;
17
+ type: TypeThunkAsync | string;
18
+ }
19
+ interface Operation {
20
+ handlerName?: string;
21
+ }
22
+ export interface Operations {
23
+ create?: OpraSchema.Collection.CreateOperation & Operation;
24
+ delete?: OpraSchema.Collection.DeleteOperation & Operation;
25
+ deleteMany?: OpraSchema.Collection.DeleteManyOperation & Operation;
26
+ get?: OpraSchema.Collection.GetOperation & Operation;
27
+ update?: OpraSchema.Collection.UpdateOperation & Operation;
28
+ updateMany?: OpraSchema.Collection.UpdateManyOperation & Operation;
29
+ search?: OpraSchema.Collection.SearchOperation & Operation;
30
+ }
31
+ export type CreateOperationOptions = StrictOmit<OpraSchema.Collection.CreateOperation, 'handler'>;
32
+ export type DeleteOperationOptions = StrictOmit<OpraSchema.Collection.DeleteOperation, 'handler'>;
33
+ export type DeleteManyOperationOptions = StrictOmit<OpraSchema.Collection.DeleteManyOperation, 'handler'>;
34
+ export type GetOperationOptions = StrictOmit<OpraSchema.Collection.GetOperation, 'handler'>;
35
+ export type UpdateOperationOptions = StrictOmit<OpraSchema.Collection.UpdateOperation, 'handler'>;
36
+ export type UpdateManyOperationOptions = StrictOmit<OpraSchema.Collection.UpdateManyOperation, 'handler'>;
37
+ export type SearchOperationOptions = StrictOmit<OpraSchema.Collection.SearchOperation, 'handler'>;
38
+ export {};
39
+ }
40
+ export interface Collection extends StrictOmit<Resource, 'exportSchema' | '_construct'> {
41
+ readonly type: ComplexType;
42
+ readonly operations: Collection.Operations;
43
+ readonly controller?: object;
44
+ readonly primaryKey: string[];
45
+ exportSchema(): OpraSchema.Collection;
46
+ parseKeyValue(value: any): any;
47
+ normalizeFieldNames(fields: string[]): string[] | undefined;
48
+ normalizeSortFields(fields: string[]): string[] | undefined;
49
+ normalizeFilterFields(ast: Expression): Expression;
50
+ _construct(init: Collection.InitArguments): void;
51
+ }
52
+ export interface CollectionConstructor {
53
+ prototype: Collection;
54
+ new (document: ApiDocument, init: Collection.InitArguments): Collection;
55
+ (type: TypeThunkAsync | string, options?: Collection.DecoratorOptions): ClassDecorator;
56
+ CreateOperation: (options?: Collection.CreateOperationOptions) => PropertyDecorator;
57
+ GetOperation: (options?: Collection.GetOperationOptions) => PropertyDecorator;
58
+ DeleteOperation: (options?: Collection.DeleteOperationOptions) => PropertyDecorator;
59
+ UpdateOperation: (options?: Collection.UpdateOperationOptions) => PropertyDecorator;
60
+ SearchOperation: (options?: Collection.SearchOperationOptions) => PropertyDecorator;
61
+ UpdateManyOperation: (options?: Collection.UpdateManyOperationOptions) => PropertyDecorator;
62
+ DeleteManyOperation: (options?: Collection.DeleteManyOperationOptions) => PropertyDecorator;
63
+ }
64
+ /**
65
+ *
66
+ */
67
+ export declare const Collection: CollectionConstructor;
@@ -0,0 +1,29 @@
1
+ import { StrictOmit, Type } from 'ts-gems';
2
+ import { OpraSchema } from '../../schema/index.js';
3
+ import type { ApiDocument } from '../api-document.js';
4
+ import { nodeInspectCustom } from '../utils/inspect.util.js';
5
+ export declare namespace Resource {
6
+ interface InitArguments extends StrictOmit<OpraSchema.ResourceBase, 'kind'> {
7
+ name: string;
8
+ controller?: object | Type;
9
+ }
10
+ interface DecoratorOptions extends Partial<Pick<InitArguments, 'name' | 'description'>> {
11
+ }
12
+ }
13
+ export interface Resource {
14
+ readonly document: ApiDocument;
15
+ readonly kind: OpraSchema.Resource.Kind;
16
+ readonly name: string;
17
+ readonly description?: string;
18
+ readonly controller?: object | Type;
19
+ exportSchema(): OpraSchema.ResourceBase;
20
+ toString(): string;
21
+ [nodeInspectCustom](): string;
22
+ _construct(init: Resource.InitArguments): void;
23
+ }
24
+ export interface ResourceConstructor {
25
+ readonly prototype: Resource;
26
+ new (document: ApiDocument, init: Resource.InitArguments): Resource;
27
+ (...args: any[]): void;
28
+ }
29
+ export declare const Resource: ResourceConstructor;
@@ -0,0 +1,49 @@
1
+ import { StrictOmit, Type } from 'ts-gems';
2
+ import { OpraSchema } from '../../schema/index.js';
3
+ import type { TypeThunkAsync } from '../../types.js';
4
+ import type { ApiDocument } from '../api-document.js';
5
+ import { ComplexType } from '../data-type/complex-type.js';
6
+ import { Resource } from './resource.js';
7
+ export declare namespace Singleton {
8
+ export interface InitArguments extends Resource.InitArguments, Pick<OpraSchema.Singleton, 'operations'> {
9
+ type: ComplexType;
10
+ }
11
+ export interface DecoratorOptions extends Resource.DecoratorOptions {
12
+ }
13
+ export interface Metadata extends StrictOmit<OpraSchema.Singleton, 'type'> {
14
+ name: string;
15
+ type: TypeThunkAsync | string;
16
+ }
17
+ interface Operation {
18
+ handlerName?: string;
19
+ }
20
+ export interface Operations {
21
+ create?: OpraSchema.Singleton.CreateOperation & Operation;
22
+ delete?: OpraSchema.Singleton.DeleteOperation & Operation;
23
+ get?: OpraSchema.Singleton.GetOperation & Operation;
24
+ update?: OpraSchema.Singleton.UpdateOperation & Operation;
25
+ }
26
+ export type CreateOperationOptions = StrictOmit<OpraSchema.Singleton.CreateOperation, 'handler'>;
27
+ export type DeleteOperationOptions = StrictOmit<OpraSchema.Singleton.DeleteOperation, 'handler'>;
28
+ export type GetOperationOptions = StrictOmit<OpraSchema.Singleton.GetOperation, 'handler'>;
29
+ export type UpdateOperationOptions = StrictOmit<OpraSchema.Singleton.UpdateOperation, 'handler'>;
30
+ export {};
31
+ }
32
+ export interface Singleton extends StrictOmit<Resource, 'exportSchema' | '_construct'> {
33
+ readonly type: ComplexType;
34
+ readonly operations: Singleton.Operations;
35
+ readonly controller?: object | Type;
36
+ exportSchema(): OpraSchema.Singleton;
37
+ normalizeFieldNames(fields: string[]): string[] | undefined;
38
+ _construct(init: Singleton.InitArguments): void;
39
+ }
40
+ export interface SingletonConstructor {
41
+ prototype: Singleton;
42
+ new (document: ApiDocument, init: Singleton.InitArguments): Singleton;
43
+ (type: TypeThunkAsync | string, options?: Singleton.DecoratorOptions): ClassDecorator;
44
+ CreateOperation: (options?: Singleton.CreateOperationOptions) => PropertyDecorator;
45
+ GetOperation: (options?: Singleton.GetOperationOptions) => PropertyDecorator;
46
+ DeleteOperation: (options?: Singleton.DeleteOperationOptions) => PropertyDecorator;
47
+ UpdateOperation: (options?: Singleton.UpdateOperationOptions) => PropertyDecorator;
48
+ }
49
+ export declare const Singleton: SingletonConstructor;
@@ -1,4 +1,8 @@
1
1
  import { OpraException } from '../opra-exception.js';
2
+ /**
3
+ * The server cannot find the requested resource.
4
+ * This can also mean that the endpoint is valid but the resource itself does not exist.
5
+ */
2
6
  export declare class ResourceNotFoundError extends OpraException {
3
7
  constructor(resource: string, keyValue?: any, cause?: Error);
4
8
  }
@@ -0,0 +1,4 @@
1
+ import { Type } from 'ts-gems';
2
+ import { ThunkAsync } from '../types.js';
3
+ export declare function resolveThunk(thunk: ThunkAsync<any>): Promise<any>;
4
+ export declare function resolveClass(thunk: ThunkAsync<Type>): Promise<Type>;
@@ -0,0 +1 @@
1
+ export declare function getStackFileName(position?: number): string;
@@ -1 +1,8 @@
1
+ export * from './function-utils.js';
2
+ export * from './get-stack-filename.js';
3
+ export * from './is-url.js';
4
+ export * from './mixin-utils.js';
5
+ export * from './object-utils.js';
6
+ export * from './path-to-object-tree.js';
1
7
  export * from './responsive-map.js';
8
+ export * from './type-guards.js';
@@ -0,0 +1 @@
1
+ export declare function isUrl(url: string): boolean;
@@ -1 +1,2 @@
1
1
  export declare function cloneObject<T extends {}>(obj: T, jsonOnly?: boolean): T;
2
+ export declare function omitUndefined(obj: any): any;
@@ -0,0 +1,4 @@
1
+ export interface ObjectTree {
2
+ [key: string]: boolean | ObjectTree;
3
+ }
4
+ export declare function pathToObjectTree(arr: string[], lowerCaseKeys?: boolean): ObjectTree | undefined;
@@ -2,7 +2,7 @@ export interface ResponsiveMapOptions {
2
2
  wellKnownKeys?: string[];
3
3
  caseSensitive?: boolean;
4
4
  }
5
- export type ResponsiveMapInit<K, V> = ResponsiveMap<K, V> | Map<K, V> | Record<any, V>;
5
+ export type ResponsiveMapInit<V> = ResponsiveMap<V> | Map<string, V> | Record<any, V>;
6
6
  declare const kKeyMap: unique symbol;
7
7
  declare const kKeyOrder: unique symbol;
8
8
  declare const kWellKnownKeys: unique symbol;
@@ -10,23 +10,25 @@ declare const kOptions: unique symbol;
10
10
  /**
11
11
  * A Map implementation that supports case-insensitivity and ordered keys
12
12
  */
13
- export declare class ResponsiveMap<K, V> extends Map<K, V> {
13
+ export declare class ResponsiveMap<V> extends Map<string, V> {
14
14
  private [kKeyMap];
15
15
  private [kKeyOrder];
16
16
  private [kWellKnownKeys];
17
17
  private [kOptions];
18
- constructor(init?: ResponsiveMapInit<K, V>, options?: ResponsiveMapOptions);
18
+ constructor(init?: ResponsiveMapInit<V> | null, options?: ResponsiveMapOptions);
19
19
  clear(): void;
20
- get(key: K): V | undefined;
21
- has(key: K): boolean;
22
- set(key: K, value: V): this;
23
- keys(): IterableIterator<K>;
20
+ get(key: string): V | undefined;
21
+ has(key: string): boolean;
22
+ set(key: string, value: V): this;
23
+ setAll(source: ResponsiveMapInit<V>): this;
24
+ keys(): IterableIterator<string>;
24
25
  values(): IterableIterator<V>;
25
- entries(): IterableIterator<[K, V]>;
26
- delete(key: K): boolean;
27
- sort(compareFn?: (a: K, b: K) => number): this;
28
- [Symbol.iterator](): IterableIterator<[K, V]>;
29
- protected _getOriginalKey(key: K): K;
30
- protected _getStoringKey(key: K): K;
26
+ entries(): IterableIterator<[string, V]>;
27
+ delete(key: string): boolean;
28
+ sort(compareFn?: (a: string, b: string) => number): this;
29
+ getProxy(handler?: ProxyHandler<Record<string, V>>): Record<string, V>;
30
+ [Symbol.iterator](): IterableIterator<[string, V]>;
31
+ protected _getOriginalKey(key: string): string;
32
+ protected _getStoringKey(key: string): string;
31
33
  }
32
34
  export {};
@@ -1,7 +1,9 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference lib="dom" />
3
3
  import { Readable } from 'stream';
4
- export declare function typeGuards(stream: any): boolean;
4
+ import { Type } from 'ts-gems';
5
+ export declare function isConstructor(fn: any): fn is Type;
6
+ export declare function isStream(stream: any): boolean;
5
7
  export declare function isReadable(x: any): x is Readable;
6
8
  export declare function isReadableStream(x: any): x is ReadableStream;
7
9
  export declare function isBlob(x: any): x is Blob;
@@ -0,0 +1,5 @@
1
+ import type { HttpParams } from '../http-params.js';
2
+ export declare class BooleanCodec implements HttpParams.Codec {
3
+ decode(value: string): boolean;
4
+ encode(value: any): string;
5
+ }
@@ -1,11 +1,11 @@
1
- import { HttpParamCodec } from '../http-param-codec.js';
1
+ import type { HttpParams } from '../http-params.js';
2
2
  export interface DateCodecOptions {
3
3
  time?: boolean;
4
4
  timeZone?: boolean;
5
5
  min?: string;
6
6
  max?: string;
7
7
  }
8
- export declare class DateCodec extends HttpParamCodec {
8
+ export declare class DateCodec implements HttpParams.Codec {
9
9
  time: boolean;
10
10
  timeZone: boolean;
11
11
  min?: string;
@@ -1,6 +1,6 @@
1
1
  import { Ast, Expression } from '../../filter/ast/index.js';
2
- import { HttpParamCodec } from '../http-param-codec.js';
3
- export declare class FilterCodec extends HttpParamCodec {
2
+ import type { HttpParams } from '../http-params.js';
3
+ export declare class FilterCodec implements HttpParams.Codec {
4
4
  decode(value: string | Expression): object;
5
5
  encode(value: Ast): string;
6
6
  }
@@ -0,0 +1,11 @@
1
+ import { NumberCodec } from './number-codec.js';
2
+ export declare namespace IntegerCodec {
3
+ interface Options extends NumberCodec.Options {
4
+ enum?: number[];
5
+ }
6
+ }
7
+ export declare class IntegerCodec extends NumberCodec {
8
+ enum?: number[];
9
+ constructor(options?: IntegerCodec.Options);
10
+ decode(value: string): number;
11
+ }
@@ -0,0 +1,14 @@
1
+ import type { HttpParams } from '../http-params.js';
2
+ export declare namespace NumberCodec {
3
+ interface Options {
4
+ max?: number;
5
+ min?: number;
6
+ }
7
+ }
8
+ export declare class NumberCodec implements HttpParams.Codec {
9
+ max?: number;
10
+ min?: number;
11
+ constructor(options?: NumberCodec.Options);
12
+ decode(value: string): number;
13
+ encode(value: any): string;
14
+ }
@@ -0,0 +1,16 @@
1
+ import type { HttpParams } from '../http-params.js';
2
+ export declare namespace StringCodec {
3
+ interface Options {
4
+ maxLength?: number;
5
+ minLength?: number;
6
+ enum?: string[];
7
+ }
8
+ }
9
+ export declare class StringCodec implements HttpParams.Codec {
10
+ maxLength?: number;
11
+ minLength?: number;
12
+ enum?: string[];
13
+ constructor(options?: StringCodec.Options);
14
+ decode(value: string): string;
15
+ encode(value: any): string;
16
+ }