@opra/client 0.7.0 → 0.8.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 (229) hide show
  1. package/README.md +1 -1
  2. package/cjs/714.min.cjs +1 -0
  3. package/cjs/antlr4ts.min.cjs +2 -0
  4. package/cjs/antlr4ts.min.cjs.LICENSE.txt +4 -0
  5. package/cjs/main.min.cjs +1 -0
  6. package/cjs/opra-common.min.cjs +1 -0
  7. package/cjs/vendors.min.cjs +2 -0
  8. package/cjs/vendors.min.cjs.LICENSE.txt +52 -0
  9. package/esm/714.min.mjs +1 -0
  10. package/esm/antlr4ts.min.mjs +2 -0
  11. package/esm/antlr4ts.min.mjs.LICENSE.txt +4 -0
  12. package/esm/main.min.mjs +1 -0
  13. package/esm/opra-common.min.mjs +1 -0
  14. package/esm/vendors.min.mjs +2 -0
  15. package/esm/vendors.min.mjs.LICENSE.txt +52 -0
  16. package/package.json +22 -50
  17. package/{esm → typings}/client-error.d.ts +1 -1
  18. package/typings/common/constants.d.ts +0 -0
  19. package/typings/common/exception/enums/issue-severity.enum.d.ts +13 -0
  20. package/typings/common/exception/error-issue.d.ts +9 -0
  21. package/typings/common/exception/http-errors/bad-request.error.d.ts +10 -0
  22. package/typings/common/exception/http-errors/failed-dependency.error.d.ts +9 -0
  23. package/typings/common/exception/http-errors/forbidden.error.d.ts +11 -0
  24. package/typings/common/exception/http-errors/internal-server.error.d.ts +9 -0
  25. package/typings/common/exception/http-errors/method-not-allowed.error.d.ts +10 -0
  26. package/typings/common/exception/http-errors/not-acceptable.error.d.ts +10 -0
  27. package/typings/common/exception/http-errors/not-found.error.d.ts +13 -0
  28. package/typings/common/exception/http-errors/unauthorized.error.d.ts +10 -0
  29. package/typings/common/exception/http-errors/unprocessable-entity.error.d.ts +9 -0
  30. package/typings/common/exception/index.d.ts +15 -0
  31. package/typings/common/exception/opra-exception.d.ts +15 -0
  32. package/typings/common/exception/resource-errors/resource-conflict.error.d.ts +5 -0
  33. package/typings/common/exception/resource-errors/resource-not-found.error.d.ts +4 -0
  34. package/typings/common/exception/wrap-exception.d.ts +2 -0
  35. package/typings/common/filter/antlr/OpraFilterLexer.d.ts +78 -0
  36. package/typings/common/filter/antlr/OpraFilterParser.d.ts +365 -0
  37. package/typings/common/filter/antlr/OpraFilterVisitor.d.ts +290 -0
  38. package/typings/common/filter/ast/abstract/ast.d.ts +5 -0
  39. package/typings/common/filter/ast/abstract/expression.d.ts +3 -0
  40. package/typings/common/filter/ast/abstract/literal.d.ts +6 -0
  41. package/typings/common/filter/ast/abstract/term.d.ts +3 -0
  42. package/typings/common/filter/ast/expressions/arithmetic-expression.d.ts +13 -0
  43. package/typings/common/filter/ast/expressions/array-expression.d.ts +7 -0
  44. package/typings/common/filter/ast/expressions/comparison-expression.d.ts +10 -0
  45. package/typings/common/filter/ast/expressions/logical-expression.d.ts +8 -0
  46. package/typings/common/filter/ast/expressions/parentheses-expression.d.ts +6 -0
  47. package/typings/common/filter/ast/index.d.ts +16 -0
  48. package/typings/common/filter/ast/terms/boolean-literal.d.ts +5 -0
  49. package/typings/common/filter/ast/terms/date-literal.d.ts +6 -0
  50. package/typings/common/filter/ast/terms/external-constant.d.ts +5 -0
  51. package/typings/common/filter/ast/terms/null-literal.d.ts +5 -0
  52. package/typings/common/filter/ast/terms/number-literal.d.ts +6 -0
  53. package/typings/common/filter/ast/terms/qualified-identifier.d.ts +4 -0
  54. package/typings/common/filter/ast/terms/string-literal.d.ts +5 -0
  55. package/typings/common/filter/ast/terms/time-literal.d.ts +6 -0
  56. package/typings/common/filter/build.d.ts +31 -0
  57. package/typings/common/filter/error-listener.d.ts +8 -0
  58. package/typings/common/filter/errors.d.ts +20 -0
  59. package/typings/common/filter/filter-tree-visitor.d.ts +30 -0
  60. package/typings/common/filter/index.d.ts +5 -0
  61. package/typings/common/filter/parse.d.ts +2 -0
  62. package/typings/common/filter/utils.d.ts +2 -0
  63. package/typings/common/helpers/index.d.ts +1 -0
  64. package/typings/common/helpers/responsive-map.d.ts +18 -0
  65. package/typings/common/http/enums/http-headers.enum.d.ts +379 -0
  66. package/typings/common/http/enums/http-status.enum.d.ts +290 -0
  67. package/typings/common/http/http-request.d.ts +34 -0
  68. package/typings/common/http/index.d.ts +6 -0
  69. package/typings/common/http/interfaces/client-http-headers.interface.d.ts +65 -0
  70. package/typings/common/http/interfaces/server-http-headers.interface.d.ts +1 -0
  71. package/typings/common/http/multipart/batch-multipart.d.ts +31 -0
  72. package/typings/common/http/multipart/http-request-content.d.ts +8 -0
  73. package/typings/common/http/multipart/http-response-content.d.ts +7 -0
  74. package/typings/common/http/multipart/index.d.ts +1 -0
  75. package/typings/common/http/utils/normalize-headers.d.ts +1 -0
  76. package/typings/common/i18n/i18n.d.ts +28 -0
  77. package/typings/common/i18n/index.d.ts +5 -0
  78. package/typings/common/i18n/string-utils.d.ts +2 -0
  79. package/typings/common/i18n/translate.d.ts +4 -0
  80. package/typings/common/index.d.ts +10 -0
  81. package/typings/common/schema/constants.d.ts +8 -0
  82. package/typings/common/schema/decorators/opr-collection-resource.decorator.d.ts +8 -0
  83. package/typings/common/schema/decorators/opr-complex-type.decorator.d.ts +6 -0
  84. package/typings/common/schema/decorators/opr-field.decorator.d.ts +3 -0
  85. package/typings/common/schema/decorators/opr-resolver.decorator.d.ts +8 -0
  86. package/typings/common/schema/decorators/opr-simple-type.decorator.d.ts +6 -0
  87. package/typings/common/schema/decorators/opr-singleton-resource.decorator.d.ts +8 -0
  88. package/typings/common/schema/implementation/data-type/builtin/any.type.d.ts +2 -0
  89. package/typings/common/schema/implementation/data-type/builtin/base64-binary.type.d.ts +2 -0
  90. package/typings/common/schema/implementation/data-type/builtin/bigint.type.d.ts +2 -0
  91. package/typings/common/schema/implementation/data-type/builtin/boolean.type.d.ts +2 -0
  92. package/typings/common/schema/implementation/data-type/builtin/date-string.type.d.ts +2 -0
  93. package/typings/common/schema/implementation/data-type/builtin/date.type.d.ts +2 -0
  94. package/typings/common/schema/implementation/data-type/builtin/guid.type.d.ts +2 -0
  95. package/typings/common/schema/implementation/data-type/builtin/integer.type.d.ts +2 -0
  96. package/typings/common/schema/implementation/data-type/builtin/number.type.d.ts +2 -0
  97. package/typings/common/schema/implementation/data-type/builtin/object.type.d.ts +2 -0
  98. package/typings/common/schema/implementation/data-type/builtin/string.type.d.ts +2 -0
  99. package/typings/common/schema/implementation/data-type/builtin-data-types.d.ts +4 -0
  100. package/typings/common/schema/implementation/data-type/complex-type.d.ts +29 -0
  101. package/typings/common/schema/implementation/data-type/data-type.d.ts +16 -0
  102. package/typings/common/schema/implementation/data-type/simple-type.d.ts +12 -0
  103. package/typings/common/schema/implementation/data-type/union-type.d.ts +16 -0
  104. package/typings/common/schema/implementation/document-builder.d.ts +16 -0
  105. package/typings/common/schema/implementation/opra-document.d.ts +44 -0
  106. package/typings/common/schema/implementation/query/collection-count-query.d.ts +14 -0
  107. package/typings/common/schema/implementation/query/collection-create-query.d.ts +18 -0
  108. package/typings/common/schema/implementation/query/collection-delete-many-query.d.ts +14 -0
  109. package/typings/common/schema/implementation/query/collection-delete-query.d.ts +10 -0
  110. package/typings/common/schema/implementation/query/collection-get-query.d.ts +21 -0
  111. package/typings/common/schema/implementation/query/collection-search-query.d.ts +30 -0
  112. package/typings/common/schema/implementation/query/collection-update-many-query.d.ts +15 -0
  113. package/typings/common/schema/implementation/query/collection-update-query.d.ts +19 -0
  114. package/typings/common/schema/implementation/query/field-get-query.d.ts +30 -0
  115. package/typings/common/schema/implementation/query/index.d.ts +27 -0
  116. package/typings/common/schema/implementation/query/singleton-get-query.d.ts +20 -0
  117. package/typings/common/schema/implementation/resource/collection-resource-info.d.ts +19 -0
  118. package/typings/common/schema/implementation/resource/container-resource-info.d.ts +13 -0
  119. package/typings/common/schema/implementation/resource/resource-info.d.ts +17 -0
  120. package/typings/common/schema/implementation/resource/singleton-resource-info.d.ts +14 -0
  121. package/typings/common/schema/implementation/schema-builder/extract-resource-metadata.util.d.ts +3 -0
  122. package/typings/common/schema/implementation/schema-builder/extract-type-metadata.util.d.ts +4 -0
  123. package/typings/common/schema/index.d.ts +25 -0
  124. package/typings/common/schema/interfaces/child-field-query.interface.d.ts +4 -0
  125. package/typings/common/schema/interfaces/data-type.metadata.d.ts +18 -0
  126. package/typings/common/schema/interfaces/resource-container.interface.d.ts +8 -0
  127. package/typings/common/schema/interfaces/resource.metadata.d.ts +18 -0
  128. package/typings/common/schema/opra-schema.definition.d.ts +178 -0
  129. package/typings/common/schema/type-helpers/extend-type.helper.d.ts +3 -0
  130. package/typings/common/schema/type-helpers/mixin-type.helper.d.ts +2 -0
  131. package/typings/common/schema/type-helpers/mixin.utils.d.ts +3 -0
  132. package/typings/common/schema/types.d.ts +14 -0
  133. package/typings/common/schema/utils/class.utils.d.ts +2 -0
  134. package/typings/common/schema/utils/clone-object.util.d.ts +1 -0
  135. package/typings/common/schema/utils/inspect.util.d.ts +4 -0
  136. package/typings/common/schema/utils/normalize-field-array.util.d.ts +3 -0
  137. package/typings/common/schema/utils/path-to-tree.util.d.ts +4 -0
  138. package/typings/common/schema/utils/string-compare.util.d.ts +1 -0
  139. package/typings/common/url/formats/boolean-format.d.ts +5 -0
  140. package/typings/common/url/formats/date-format.d.ts +16 -0
  141. package/typings/common/url/formats/filter-format.d.ts +6 -0
  142. package/typings/common/url/formats/format.d.ts +4 -0
  143. package/typings/common/url/formats/integer-format.d.ts +9 -0
  144. package/typings/common/url/formats/number-format.d.ts +12 -0
  145. package/typings/common/url/formats/string-format.d.ts +14 -0
  146. package/typings/common/url/index.d.ts +5 -0
  147. package/typings/common/url/opra-url-path-component.d.ts +15 -0
  148. package/typings/common/url/opra-url-path.d.ts +30 -0
  149. package/typings/common/url/opra-url-search-params.d.ts +44 -0
  150. package/typings/common/url/opra-url.d.ts +79 -0
  151. package/typings/common/url/utils/path-utils.d.ts +8 -0
  152. package/typings/common/utils/index.d.ts +3 -0
  153. package/typings/common/utils/is-url.d.ts +1 -0
  154. package/typings/common/utils/path-to-tree.d.ts +4 -0
  155. package/typings/common/utils/type-guards.d.ts +9 -0
  156. package/{esm → typings}/constants.d.ts +0 -0
  157. package/{esm → typings}/http/http-client.d.ts +1 -1
  158. package/{esm → typings}/http/http-collection-service.d.ts +1 -1
  159. package/{esm → typings}/http/http-request.d.ts +1 -1
  160. package/{esm → typings}/http/http-response.d.ts +0 -0
  161. package/{esm → typings}/http/http-singleton-service.d.ts +1 -1
  162. package/{esm → typings}/http/http-types.d.ts +1 -1
  163. package/{esm → typings}/http/requests/batch-request.d.ts +1 -1
  164. package/{esm → typings}/http/requests/collection-create-request.d.ts +1 -1
  165. package/{esm → typings}/http/requests/collection-delete-many-request.d.ts +1 -1
  166. package/{esm → typings}/http/requests/collection-delete-request.d.ts +1 -1
  167. package/{esm → typings}/http/requests/collection-get-request.d.ts +1 -1
  168. package/{esm → typings}/http/requests/collection-search-request.d.ts +1 -1
  169. package/{esm → typings}/http/requests/collection-update-many-request.d.ts +1 -1
  170. package/{esm → typings}/http/requests/collection-update-request.d.ts +1 -1
  171. package/{esm → typings}/http/requests/http-singleton-get-request.d.ts +1 -1
  172. package/{esm → typings}/http/utils/merge-raw-http-requests.util.d.ts +0 -0
  173. package/{esm → typings}/index.d.ts +0 -1
  174. package/{esm → typings}/interfaces/http-options.interface.d.ts +1 -4
  175. package/{esm → typings}/interfaces/http-request-config.interface.d.ts +1 -1
  176. package/umd/714.min.cjs +1 -0
  177. package/umd/antlr4ts.min.cjs +2 -0
  178. package/umd/antlr4ts.min.cjs.LICENSE.txt +4 -0
  179. package/umd/main.min.cjs +1 -0
  180. package/umd/opra-common.min.cjs +1 -0
  181. package/umd/vendors.min.cjs +2 -0
  182. package/umd/vendors.min.cjs.LICENSE.txt +52 -0
  183. package/cjs/client-error.js +0 -20
  184. package/cjs/constants.js +0 -6
  185. package/cjs/http/http-client.js +0 -164
  186. package/cjs/http/http-collection-service.js +0 -40
  187. package/cjs/http/http-request.js +0 -66
  188. package/cjs/http/http-response.js +0 -2
  189. package/cjs/http/http-singleton-service.js +0 -16
  190. package/cjs/http/http-types.js +0 -2
  191. package/cjs/http/requests/batch-request.js +0 -80
  192. package/cjs/http/requests/collection-create-request.js +0 -35
  193. package/cjs/http/requests/collection-delete-many-request.js +0 -28
  194. package/cjs/http/requests/collection-delete-request.js +0 -29
  195. package/cjs/http/requests/collection-get-request.js +0 -37
  196. package/cjs/http/requests/collection-search-request.js +0 -44
  197. package/cjs/http/requests/collection-update-many-request.js +0 -31
  198. package/cjs/http/requests/collection-update-request.js +0 -40
  199. package/cjs/http/requests/http-singleton-get-request.js +0 -31
  200. package/cjs/http/utils/merge-raw-http-requests.util.js +0 -29
  201. package/cjs/index.js +0 -20
  202. package/cjs/interfaces/http-options.interface.js +0 -2
  203. package/cjs/interfaces/http-request-config.interface.js +0 -2
  204. package/cjs/package.json +0 -3
  205. package/cjs/types.js +0 -2
  206. package/esm/client-error.js +0 -16
  207. package/esm/constants.js +0 -3
  208. package/esm/http/http-client.js +0 -160
  209. package/esm/http/http-collection-service.js +0 -36
  210. package/esm/http/http-request.js +0 -62
  211. package/esm/http/http-response.js +0 -1
  212. package/esm/http/http-singleton-service.js +0 -12
  213. package/esm/http/http-types.js +0 -1
  214. package/esm/http/requests/batch-request.js +0 -76
  215. package/esm/http/requests/collection-create-request.js +0 -31
  216. package/esm/http/requests/collection-delete-many-request.js +0 -24
  217. package/esm/http/requests/collection-delete-request.js +0 -25
  218. package/esm/http/requests/collection-get-request.js +0 -33
  219. package/esm/http/requests/collection-search-request.js +0 -40
  220. package/esm/http/requests/collection-update-many-request.js +0 -27
  221. package/esm/http/requests/collection-update-request.js +0 -36
  222. package/esm/http/requests/http-singleton-get-request.js +0 -27
  223. package/esm/http/utils/merge-raw-http-requests.util.js +0 -25
  224. package/esm/index.js +0 -17
  225. package/esm/interfaces/http-options.interface.js +0 -1
  226. package/esm/interfaces/http-request-config.interface.js +0 -1
  227. package/esm/types.d.ts +0 -7
  228. package/esm/types.js +0 -1
  229. package/umd/opra-client.umd.min.js +0 -1
@@ -1,27 +0,0 @@
1
- import { HttpRequest } from '../http-request.js';
2
- import { mergeRawHttpRequests } from '../utils/merge-raw-http-requests.util.js';
3
- export class HttpSingletonGetRequest extends HttpRequest {
4
- _handler;
5
- resource;
6
- options;
7
- constructor(_handler, resource, options = {}) {
8
- super(_handler, options);
9
- this._handler = _handler;
10
- this.resource = resource;
11
- this.options = options;
12
- }
13
- prepare() {
14
- const searchParams = new URLSearchParams();
15
- if (this.options.include)
16
- searchParams.set('$include', '' + this.options.include);
17
- if (this.options.pick)
18
- searchParams.set('$pick', '' + this.options.pick);
19
- if (this.options.omit)
20
- searchParams.set('$omit', '' + this.options.omit);
21
- return mergeRawHttpRequests({
22
- method: 'GET',
23
- path: this.resource.name,
24
- params: searchParams
25
- }, this.options.http);
26
- }
27
- }
@@ -1,25 +0,0 @@
1
- import { normalizeHeaders, OpraURLSearchParams } from '@opra/common';
2
- export function mergeRawHttpRequests(target, ...other) {
3
- let params;
4
- const arr = [target, ...other];
5
- let headers;
6
- for (let i = arr.length - 1; i >= 0; i--) {
7
- const o = arr[i];
8
- if (o?.headers) {
9
- headers = headers || {};
10
- Object.assign(headers, normalizeHeaders(o.headers));
11
- }
12
- }
13
- for (const o of arr) {
14
- if (!o)
15
- continue;
16
- Object.assign(target, o);
17
- if (o?.params) {
18
- params = params || new OpraURLSearchParams();
19
- o.params.forEach((v, n) => params?.append(n, v));
20
- }
21
- }
22
- target.headers = headers;
23
- target.params = params;
24
- return target;
25
- }
package/esm/index.js DELETED
@@ -1,17 +0,0 @@
1
- export * from './http/http-client.js';
2
- export * from './http/http-request.js';
3
- export * from './http/http-response.js';
4
- export * from './http/http-collection-service.js';
5
- export * from './http/http-singleton-service.js';
6
- export * from './http/http-types.js';
7
- export * from './types.js';
8
- export * from './client-error.js';
9
- export * from './http/requests/batch-request.js';
10
- export * from './http/requests/collection-create-request.js';
11
- export * from './http/requests/collection-delete-request.js';
12
- export * from './http/requests/collection-delete-many-request.js';
13
- export * from './http/requests/collection-get-request.js';
14
- export * from './http/requests/collection-search-request.js';
15
- export * from './http/requests/collection-update-request.js';
16
- export * from './http/requests/collection-update-many-request.js';
17
- export * from './http/requests/http-singleton-get-request.js';
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
package/esm/types.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import { AxiosAdapter, AxiosBasicCredentials, AxiosProxyConfig } from 'axios';
2
- import { StrictOmit } from 'ts-gems';
3
- import { HttpRequestConfig } from './interfaces/http-request-config.interface.js';
4
- export declare type OPCAdapter = AxiosAdapter;
5
- export declare type OPCProxyConfig = AxiosProxyConfig;
6
- export declare type OPCBasicCredentials = AxiosBasicCredentials;
7
- export declare type OPCHttpOptions = StrictOmit<HttpRequestConfig, 'method' | 'url' | 'body'>;
package/esm/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@opra/common"),require("rxjs")):"function"==typeof define&&define.amd?define("OpraClient",["@opra/common","rxjs"],e):"object"==typeof exports?exports.OpraClient=e(require("@opra/common"),require("rxjs")):t.OpraClient=e(t["@opra/common"],t.rxjs)}(self,((t,e)=>(()=>{"use strict";var s={780:e=>{e.exports=t},832:t=>{t.exports=e}},r={};function i(t){var e=r[t];if(void 0!==e)return e.exports;var o=r[t]={exports:{}};return s[t](o,o.exports,i),o.exports}i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};return(()=>{i.r(o),i.d(o,{BatchRequest:()=>g,ClientError:()=>e,CollectionCreateRequest:()=>u,CollectionDeleteManyRequest:()=>p,CollectionDeleteRequest:()=>l,CollectionGetRequest:()=>d,CollectionSearchRequest:()=>m,CollectionUpdateManyRequest:()=>y,CollectionUpdateRequest:()=>_,HttpCollectionService:()=>f,HttpRequest:()=>h,HttpSingletonGetRequest:()=>w,HttpSingletonService:()=>b,OpraHttpClient:()=>R});var t=i(780);class e extends Error{cause;issues;status;constructor(t,e){super(t.message),this.cause=e,this.issues=t.issues||[],this.status=t.status,e&&(this.cause=e,e.stack&&(this.stack=e.stack))}}const s=/^application\/([\w-]+\+)?\bjson\b/i,r=/^text\/.*$/i,a=/^multipart\/\bform-data\b/i;var n=i(832);class h extends n.Observable{_handler;options;contentId;_promise;_headers;constructor(e,s={}){super((t=>{"response"!==s.observe?this.resolve().then((e=>{t.next(e),t.complete()})).catch((e=>t.error(e))):this.fetch().then((e=>{t.next(e),t.complete()})).catch((e=>t.error(e)))})),this._handler=e,this.options=s,this.contentId=(0,t.uid)(6),this.options=s}header(t,e){return this._headers=this._headers||{},this._headers[t]=e,this}async fetch(){const t=this._promise||(this._promise=new Promise(((t,e)=>{setTimeout((()=>{this._execute().then(t).catch(e)}),0)})));return await t}async resolve(){return(await this.fetch()).data}with(t){return t(this),this}binding(){return{}}async _execute(){const t=this.prepare();return await this._handler(t)}}function c(e,...s){let r;const i=[e,...s];let o;for(let e=i.length-1;e>=0;e--){const s=i[e];s?.headers&&(o=o||{},Object.assign(o,(0,t.normalizeHeaders)(s.headers)))}for(const s of i)s&&(Object.assign(e,s),s?.params&&(r=r||new t.OpraURLSearchParams,s.params.forEach(((t,e)=>r?.append(e,t)))));return e.headers=o,e.params=r,e}class u extends h{_handler;resource;data;options;constructor(t,e,s,r={}){super(t,r),this._handler=t,this.resource=e,this.data=s,this.options=r}prepare(){const e=new t.OpraURLSearchParams;return this.options.include&&e.set("$include",this.options.include),this.options.pick&&e.set("$pick",this.options.pick),this.options.omit&&e.set("$omit",this.options.omit),c({method:"POST",path:this.resource.name,params:e,body:this.data},this.options.http)}}class p extends h{_handler;resource;options;constructor(t,e,s={}){super(t,s),this._handler=t,this.resource=e,this.options=s}prepare(){const e=new t.OpraURLSearchParams;return this.options.filter&&e.set("$filter",this.options.filter),c({method:"DELETE",path:this.resource.name,params:e},this.options.http)}}class l extends h{_handler;resource;keyValue;options;constructor(t,e,s,r={}){super(t,r),this._handler=t,this.resource=e,this.keyValue=s,this.options=r}prepare(){if(null==this.keyValue||""===this.keyValue)throw new TypeError('Key value required to perform "delete" request');return c({method:"DELETE",path:new t.OpraURLPath({resource:this.resource.name,key:this.keyValue}).toString()},this.options.http)}}class d extends h{_handler;resource;keyValue;options;constructor(t,e,s,r={}){super(t,r),this._handler=t,this.resource=e,this.keyValue=s,this.options=r}prepare(){if(null==this.keyValue||""===this.keyValue)throw new TypeError('Key value required to perform "get" request');const e=new t.OpraURLPath({resource:this.resource.name,key:this.keyValue}),s=new t.OpraURLSearchParams;return this.options.include&&s.set("$include",this.options.include),this.options.pick&&s.set("$pick",this.options.pick),this.options.omit&&s.set("$omit",this.options.omit),c({method:"GET",path:e.toString(),params:s},this.options.http)}}class m extends h{_handler;resource;options;constructor(t,e,s={}){super(t,s),this._handler=t,this.resource=e,this.options=s}prepare(){const e=new t.OpraURLSearchParams;return this.options.include&&e.set("$include",this.options.include),this.options.pick&&e.set("$pick",this.options.pick),this.options.omit&&e.set("$omit",this.options.omit),this.options.sort&&e.set("$sort",this.options.sort),this.options.filter&&e.set("$filter",this.options.filter),null!=this.options.limit&&e.set("$limit",this.options.limit),null!=this.options.skip&&e.set("$skip",this.options.skip),null!=this.options.count&&e.set("$count",this.options.count),null!=this.options.distinct&&e.set("$distinct",this.options.distinct),c({method:"GET",path:this.resource.name,params:e},this.options.http)}}class y extends h{_handler;resource;data;options;constructor(t,e,s,r={}){super(t,r),this._handler=t,this.resource=e,this.data=s,this.options=r}prepare(){const e=new t.OpraURLSearchParams;return this.options.filter&&e.set("$filter",this.options.filter),c({method:"PATCH",path:this.resource.name,params:e,body:this.data},this.options.http)}}class _ extends h{_handler;resource;keyValue;data;options;constructor(t,e,s,r,i={}){super(t,i),this._handler=t,this.resource=e,this.keyValue=s,this.data=r,this.options=i}prepare(){if(null==this.keyValue||""===this.keyValue)throw new TypeError('Key value required to perform "get" request');const e=new t.OpraURLPath({resource:this.resource.name,key:this.keyValue}),s=new t.OpraURLSearchParams;return this.options.include&&s.set("$include",this.options.include),this.options.pick&&s.set("$pick",this.options.pick),this.options.omit&&s.set("$omit",this.options.omit),c({method:"PATCH",path:e.toString(),params:s,body:this.data},this.options.http)}}class f{resource;_handler;constructor(t,e){this.resource=t,this._handler=e}create(t,e){return new u(this._handler,this.resource,t,e)}delete(t,e){return new l(this._handler,this.resource,t,e)}deleteMany(t){return new p(this._handler,this.resource,t)}get(t,e){return new d(this._handler,this.resource,t,e)}search(t){return new m(this._handler,this.resource,t)}update(t,e,s){return new _(this._handler,this.resource,t,e,s)}updateMany(t,e){return new y(this._handler,this.resource,t,e)}}class w extends h{_handler;resource;options;constructor(t,e,s={}){super(t,s),this._handler=t,this.resource=e,this.options=s}prepare(){const t=new URLSearchParams;return this.options.include&&t.set("$include",""+this.options.include),this.options.pick&&t.set("$pick",""+this.options.pick),this.options.omit&&t.set("$omit",""+this.options.omit),c({method:"GET",path:this.resource.name,params:t},this.options.http)}}class b{resource;_handler;constructor(t,e){this.resource=t,this._handler=e}get(t){return new w(this._handler,this.resource,t)}}class g extends h{_handler;requests;options;_results=new WeakMap;_listeners=new Set;constructor(t,e,s={}){super(t,s),this._handler=t,this.requests=e,this.options=s,e.forEach((t=>{Object.defineProperty(t,"_execute",{writable:!0,enumerable:!1,configurable:!0,value:()=>new Promise(((e,s)=>{const r=this._results.get(t);if(r)return r.error?s(r.error):e(r.response);const i=(t,r)=>{if(this._listeners.delete(i),t)return s(t);e(r)};this._listeners.add(i)}))})}))}prepare(){const t=this._buildBatchMultipart(this);return c({method:"POST",path:"/$batch",headers:{"content-type":"multipart/mixed;boundary="+t.boundary},body:t.stream()},this.options.http)}_buildBatchMultipart(e){const s=new t.BatchMultipart;for(const t of e.requests){const e=t.prepare();if(t instanceof g){const e=this._buildBatchMultipart(t);s.addBatch(e)}else s.addRequestPart({method:e.method,url:e.path,headers:e.headers,data:e.body})}return s}async _execute(){const t=this.prepare();return await this._handler(t)}}const k=new Map,x=new Map;class R{_serviceUrl;_metadata;defaults;constructor(t,e){if(this._serviceUrl=t,this._metadata=e?.document,!this._metadata){const t=k.get(this.serviceUrl.toLowerCase());t&&(this._metadata=t)}this.defaults=e?.defaults||{}}get serviceUrl(){return this._serviceUrl}get initialized(){return!!this._metadata}get metadata(){return this._assertMetadata(),this._metadata}async init(t){if(!t&&this.initialized)return;const e=this.serviceUrl.toLowerCase();let s=x.get(e);if(!s)return s=this._resolveMetadata(),x.set(e,s),s.catch((()=>{})).finally((()=>x.delete(e)));await s}batch(t){return this._assertMetadata(),new g((t=>this._handleRequest(t)),t)}collection(t){this._assertMetadata(),"function"==typeof t&&(t=t.name);const e=this.metadata.getCollectionResource(t);return new f(e,(t=>this._handleRequest(t)))}singleton(t){this._assertMetadata(),"function"==typeof t&&(t=t.name);const e=this.metadata.getSingletonResource(t);return new b(e,(t=>this._handleRequest(t)))}async _resolveMetadata(){const e=await this._handleRequest({method:"GET",path:"/$metadata",headers:{accept:"application/json"}});this._metadata=new t.OpraDocument(e.data)}async _handleRequest(e){c(e,this.defaults);let s=(0,t.joinPath)(this.serviceUrl,e.path);return e.params&&(s+="?"+e.params.toString()),e.body&&"object"==typeof e.body&&((0,t.isReadable)(e.body)||(0,t.isReadableStream)(e.body)||Buffer.isBuffer(e.body)||(e.headers?.["content-type"]||(e.headers=e.headers||{},e.headers["content-type"]="application/json"),e.body=JSON.stringify(e.body))),this._fetch(s,e)}async _fetch(t,i){const o=await fetch(t,i);let n;if(o.body&&(s.test(o.headers.get("Content-Type")||"")?(n=await o.json(),"string"==typeof n&&(n=JSON.parse(n))):n=r.test(o.headers.get("Content-Type")||"")?await o.text():a.test(o.headers.get("Content-Type")||"")?await o.formData():await o.arrayBuffer()),o.status>=400&&o.status<600)throw new e({message:o.status+" "+o.statusText,status:o.status,issues:n?.errors});return{get headers(){return o.headers},get ok(){return o.ok},get redirected(){return o.redirected},get status(){return o.status},get statusText(){return o.statusText},get type(){return o.type},get url(){return o.url},get contentId(){return o.headers.get("Content-ID")},get data(){return n}}}_assertMetadata(){if(!this._metadata)throw new Error("You must call init() to before using the client instance")}static async create(t,e){const s=new this(t,e);return s._metadata||await s.init(),s}}})(),o})()));