@progress/sitefinity-webservices-sdk 1.1.16 → 2.0.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 (233) hide show
  1. package/README.md +84 -51
  2. package/esm/chunks/chunk-2ID24RPE.mjs +179 -0
  3. package/esm/chunks/chunk-2ID24RPE.mjs.map +7 -0
  4. package/esm/chunks/chunk-AHDZ2CWQ.mjs +93 -0
  5. package/esm/chunks/chunk-AHDZ2CWQ.mjs.map +7 -0
  6. package/esm/chunks/chunk-BFLQBM7R.mjs +136 -0
  7. package/esm/chunks/chunk-BFLQBM7R.mjs.map +7 -0
  8. package/esm/chunks/chunk-CMGV26CS.mjs +66 -0
  9. package/esm/chunks/chunk-CMGV26CS.mjs.map +7 -0
  10. package/esm/chunks/chunk-DHWDJAGV.mjs +180 -0
  11. package/esm/chunks/chunk-DHWDJAGV.mjs.map +7 -0
  12. package/esm/chunks/chunk-EH4CERVO.mjs +82 -0
  13. package/esm/chunks/chunk-EH4CERVO.mjs.map +7 -0
  14. package/esm/chunks/chunk-F4CWOE7M.mjs +57 -0
  15. package/esm/chunks/chunk-F4CWOE7M.mjs.map +7 -0
  16. package/esm/chunks/chunk-FUFBYOIF.mjs +98 -0
  17. package/esm/chunks/chunk-FUFBYOIF.mjs.map +7 -0
  18. package/esm/chunks/chunk-J2B7UDVZ.mjs +132 -0
  19. package/esm/chunks/chunk-J2B7UDVZ.mjs.map +7 -0
  20. package/esm/chunks/chunk-L3IMDFA5.mjs +1 -0
  21. package/esm/chunks/chunk-L3IMDFA5.mjs.map +7 -0
  22. package/esm/chunks/chunk-NNYY2VBC.mjs +383 -0
  23. package/esm/chunks/chunk-NNYY2VBC.mjs.map +7 -0
  24. package/esm/chunks/chunk-PI55MBSL.mjs +256 -0
  25. package/esm/chunks/chunk-PI55MBSL.mjs.map +7 -0
  26. package/esm/chunks/chunk-PXPK2IV6.mjs +568 -0
  27. package/esm/chunks/chunk-PXPK2IV6.mjs.map +7 -0
  28. package/esm/chunks/chunk-QPSEKUOI.mjs +35 -0
  29. package/esm/chunks/chunk-QPSEKUOI.mjs.map +7 -0
  30. package/esm/chunks/chunk-RQAAYOY6.mjs +72 -0
  31. package/esm/chunks/chunk-RQAAYOY6.mjs.map +7 -0
  32. package/esm/chunks/chunk-TTVNTTW5.mjs +145 -0
  33. package/esm/chunks/chunk-TTVNTTW5.mjs.map +7 -0
  34. package/esm/chunks/chunk-VLDX2FH2.mjs +235 -0
  35. package/esm/chunks/chunk-VLDX2FH2.mjs.map +7 -0
  36. package/esm/chunks/chunk-VWT2RJET.mjs +102 -0
  37. package/esm/chunks/chunk-VWT2RJET.mjs.map +7 -0
  38. package/esm/chunks/chunk-W2OWM3L7.mjs +19 -0
  39. package/esm/chunks/chunk-W2OWM3L7.mjs.map +7 -0
  40. package/esm/chunks/chunk-WX5J7F5D.mjs +43 -0
  41. package/esm/chunks/chunk-WX5J7F5D.mjs.map +7 -0
  42. package/esm/chunks/chunk-YB2LMPUX.mjs +54 -0
  43. package/esm/chunks/chunk-YB2LMPUX.mjs.map +7 -0
  44. package/package.json +67 -36
  45. package/sitefinity-webservices-sdk.cjs +2761 -0
  46. package/sitefinity-webservices-sdk.cjs.map +7 -0
  47. package/sitefinity-webservices-sdk.d.mts +1 -0
  48. package/{dist/sitefinity-webservices-sdk.d.ts → sitefinity-webservices-sdk.d.ts} +6 -0
  49. package/sitefinity-webservices-sdk.global.d.ts +5 -0
  50. package/sitefinity-webservices-sdk.js +2764 -0
  51. package/sitefinity-webservices-sdk.js.map +7 -0
  52. package/sitefinity-webservices-sdk.min.js +3 -0
  53. package/sitefinity-webservices-sdk.mjs +124 -0
  54. package/sitefinity-webservices-sdk.mjs.map +7 -0
  55. package/src/BlobBuilder.d.ts +12 -0
  56. package/src/Data.d.ts +259 -0
  57. package/src/Expression.d.ts +37 -0
  58. package/src/OrderProperty.d.ts +24 -0
  59. package/src/Query.d.ts +104 -0
  60. package/src/QueryBase.d.ts +40 -0
  61. package/src/QueryBuilder.d.ts +29 -0
  62. package/src/Requests/BatchRequest.d.ts +174 -0
  63. package/src/Requests/ExecutableRequest.d.ts +43 -0
  64. package/src/Requests/Request.d.ts +225 -0
  65. package/src/Requests/RequestBase.d.ts +58 -0
  66. package/{dist/src → src}/Requests/RequestFactory.d.ts +24 -2
  67. package/src/Sitefinity.d.ts +141 -0
  68. package/src/Transport/FetchTransport.d.ts +17 -0
  69. package/src/Transport/HttpTransport.d.ts +69 -0
  70. package/src/Transport/XhrTransport.d.ts +8 -0
  71. package/src/WhereQuery.d.ts +88 -0
  72. package/src/chunk-upload/chunk-upload.sdk.d.ts +305 -0
  73. package/src/chunk-upload/chunked-file-upload.utilities.d.ts +58 -0
  74. package/{dist/src → src}/constants.d.ts +21 -0
  75. package/src/utils.d.ts +103 -0
  76. package/.editorconfig +0 -29
  77. package/.eslintignore +0 -4
  78. package/.eslintrc.js +0 -40
  79. package/.github/copilot-instructions.md +0 -72
  80. package/.github/instructions/sitefinity-webservices-sdk.instructions.md +0 -53
  81. package/config/helpers.ts +0 -8
  82. package/config/webpack.common.ts +0 -39
  83. package/config/webpack.dev.ts +0 -37
  84. package/config/webpack.prod.ts +0 -17
  85. package/dist/docs/.nojekyll +0 -1
  86. package/dist/docs/assets/highlight.css +0 -71
  87. package/dist/docs/assets/main.js +0 -58
  88. package/dist/docs/assets/search.js +0 -1
  89. package/dist/docs/assets/style.css +0 -1280
  90. package/dist/docs/classes/BlobBuilder.BlobBuilder.html +0 -137
  91. package/dist/docs/classes/Data.Data.html +0 -387
  92. package/dist/docs/classes/Expression.BinaryExpression.html +0 -184
  93. package/dist/docs/classes/Expression.ComplexExpression.html +0 -146
  94. package/dist/docs/classes/Expression.ExpressionBase.html +0 -125
  95. package/dist/docs/classes/OrderProperty.OrderProperty.html +0 -151
  96. package/dist/docs/classes/Query.Query.html +0 -353
  97. package/dist/docs/classes/QueryBase.QueryBase.html +0 -185
  98. package/dist/docs/classes/QueryBuilder.QueryBuilder.html +0 -206
  99. package/dist/docs/classes/Requests_BatchRequest.BatchRequest.html +0 -731
  100. package/dist/docs/classes/Requests_BatchRequest.Transaction.html +0 -332
  101. package/dist/docs/classes/Requests_ExecutableRequest.ExecutableRequest.html +0 -340
  102. package/dist/docs/classes/Requests_Request.CommitChunksRequest.html +0 -303
  103. package/dist/docs/classes/Requests_Request.CreateRelatedRequest.html +0 -310
  104. package/dist/docs/classes/Requests_Request.CreateRequest.html +0 -307
  105. package/dist/docs/classes/Requests_Request.DeleteRelatedByIdRequest.html +0 -309
  106. package/dist/docs/classes/Requests_Request.DeleteRelatedRequest.html +0 -302
  107. package/dist/docs/classes/Requests_Request.DeleteRequest.html +0 -298
  108. package/dist/docs/classes/Requests_Request.GetByIdRequest.html +0 -298
  109. package/dist/docs/classes/Requests_Request.GetRelatedByIdRequest.html +0 -309
  110. package/dist/docs/classes/Requests_Request.GetRelatedRequest.html +0 -302
  111. package/dist/docs/classes/Requests_Request.GetRequest.html +0 -295
  112. package/dist/docs/classes/Requests_Request.UpdateRequest.html +0 -309
  113. package/dist/docs/classes/Requests_Request.UploadChunkRequest.html +0 -359
  114. package/dist/docs/classes/Requests_Request.UploadRequest.html +0 -329
  115. package/dist/docs/classes/Requests_RequestBase.RequestBase.html +0 -275
  116. package/dist/docs/classes/Requests_RequestFactory.RequestFactory.html +0 -344
  117. package/dist/docs/classes/Sitefinity.Sitefinity.html +0 -188
  118. package/dist/docs/classes/WhereQuery.WhereQuery.html +0 -436
  119. package/dist/docs/classes/chunk_upload_chunk_upload_sdk.ChunkUploadSdk.html +0 -231
  120. package/dist/docs/classes/chunk_upload_chunked_file_upload_utilities.ChunkedFileUploadUtilities.html +0 -131
  121. package/dist/docs/classes/utils.utils.html +0 -303
  122. package/dist/docs/index.html +0 -129
  123. package/dist/docs/interfaces/Data.CreateRelatedRequestOptions.html +0 -155
  124. package/dist/docs/interfaces/Data.CreateRequestOptions.html +0 -153
  125. package/dist/docs/interfaces/Data.OperationsRequestOptions.html +0 -145
  126. package/dist/docs/interfaces/Data.PropertyRequestOptions.html +0 -149
  127. package/dist/docs/interfaces/Data.RequestOptionsBase.html +0 -136
  128. package/dist/docs/interfaces/Data.SingleRelatedItemRequestOptions.html +0 -155
  129. package/dist/docs/interfaces/Data.UpdateRequestOptions.html +0 -155
  130. package/dist/docs/interfaces/Data.UploadRequestOptions.html +0 -169
  131. package/dist/docs/interfaces/Requests_BatchRequest.BatchCreateRelatedRequestOptions.html +0 -161
  132. package/dist/docs/interfaces/Requests_BatchRequest.BatchCreateRequestOptions.html +0 -153
  133. package/dist/docs/interfaces/Requests_BatchRequest.BatchPropertyRequestOptions.html +0 -153
  134. package/dist/docs/interfaces/Requests_BatchRequest.BatchRequestOptionsBase.html +0 -145
  135. package/dist/docs/interfaces/Requests_BatchRequest.BatchRequestOptionsExtended.html +0 -153
  136. package/dist/docs/interfaces/Requests_BatchRequest.BatchSingleItemRequestOptions.html +0 -145
  137. package/dist/docs/interfaces/Requests_BatchRequest.BatchSingleRelatedItemRequestOptions.html +0 -161
  138. package/dist/docs/interfaces/Requests_BatchRequest.BatchUpdateRequestOptions.html +0 -161
  139. package/dist/docs/interfaces/Requests_ExecutableRequest.ResponseHandlers.html +0 -98
  140. package/dist/docs/interfaces/Requests_Request.CommitChunksRequestOptionsExtended.html +0 -215
  141. package/dist/docs/interfaces/Requests_Request.PostRequestOptionsExtended.html +0 -159
  142. package/dist/docs/interfaces/Requests_Request.PutRequestOptionsExtended.html +0 -161
  143. package/dist/docs/interfaces/Requests_Request.RelatedByIdRequestOptionsExtended.html +0 -169
  144. package/dist/docs/interfaces/Requests_Request.RelatedRequestOptionsExtended.html +0 -163
  145. package/dist/docs/interfaces/Requests_Request.UploadChunkRequestOptionsExtended.html +0 -217
  146. package/dist/docs/interfaces/Requests_Request.UploadRequestOptionsExtended.html +0 -180
  147. package/dist/docs/interfaces/Requests_RequestBase.RequestOptionsBaseExtended.html +0 -148
  148. package/dist/docs/interfaces/Sitefinity.SDKOptions.html +0 -128
  149. package/dist/docs/interfaces/Sitefinity.Token.html +0 -94
  150. package/dist/docs/interfaces/Sitefinity.TypeOptions.html +0 -160
  151. package/dist/docs/interfaces/chunk_upload_chunk_upload_sdk.ChunkUploadInfoDTO.html +0 -159
  152. package/dist/docs/interfaces/chunk_upload_chunk_upload_sdk.ChunkUploadResult.html +0 -111
  153. package/dist/docs/interfaces/chunk_upload_chunk_upload_sdk.CleanUpChunksRequestOptions.html +0 -171
  154. package/dist/docs/interfaces/chunk_upload_chunk_upload_sdk.CommitChunksRequestOptions.html +0 -204
  155. package/dist/docs/interfaces/chunk_upload_chunk_upload_sdk.GetChunkUploadInfoRequestOptions.html +0 -166
  156. package/dist/docs/interfaces/chunk_upload_chunk_upload_sdk.UploadChunkRequestOptions.html +0 -206
  157. package/dist/docs/interfaces/chunk_upload_chunked_file_upload_utilities.ChunkFileResult.html +0 -101
  158. package/dist/docs/interfaces/chunk_upload_chunked_file_upload_utilities.FileUploadChunk.html +0 -94
  159. package/dist/docs/modules/BlobBuilder.html +0 -73
  160. package/dist/docs/modules/Data.html +0 -92
  161. package/dist/docs/modules/Expression.html +0 -77
  162. package/dist/docs/modules/OrderProperty.html +0 -73
  163. package/dist/docs/modules/Query.html +0 -73
  164. package/dist/docs/modules/QueryBase.html +0 -73
  165. package/dist/docs/modules/QueryBuilder.html +0 -73
  166. package/dist/docs/modules/Requests_BatchRequest.html +0 -94
  167. package/dist/docs/modules/Requests_ExecutableRequest.html +0 -78
  168. package/dist/docs/modules/Requests_Request.html +0 -114
  169. package/dist/docs/modules/Requests_RequestBase.html +0 -78
  170. package/dist/docs/modules/Requests_RequestFactory.html +0 -73
  171. package/dist/docs/modules/Sitefinity.html +0 -82
  172. package/dist/docs/modules/WhereQuery.html +0 -73
  173. package/dist/docs/modules/chunk_upload_chunk_upload_sdk.html +0 -88
  174. package/dist/docs/modules/chunk_upload_chunked_file_upload_utilities.html +0 -80
  175. package/dist/docs/modules/constants.html +0 -83
  176. package/dist/docs/modules/utils.html +0 -73
  177. package/dist/docs/modules.html +0 -80
  178. package/dist/docs/variables/constants.CONTENT_TYPES.html +0 -76
  179. package/dist/docs/variables/constants.EXPRESSION_TYPE.html +0 -106
  180. package/dist/docs/variables/constants.HEADER_NAMES.html +0 -102
  181. package/dist/docs/variables/constants.HTTP_METHODS.html +0 -84
  182. package/dist/docs/variables/constants.ODATA_PARAMS.html +0 -90
  183. package/dist/docs/variables/constants.SF_PARAMS.html +0 -84
  184. package/dist/samples.html +0 -625
  185. package/dist/sitefinity-webservices-sdk.js +0 -3243
  186. package/dist/sitefinity-webservices-sdk.js.map +0 -1
  187. package/dist/sitefinity-webservices-sdk.min.js +0 -1
  188. package/dist/src/BlobBuilder.d.ts +0 -14
  189. package/dist/src/Data.d.ts +0 -154
  190. package/dist/src/Data.spec.d.ts +0 -1
  191. package/dist/src/Expression.d.ts +0 -19
  192. package/dist/src/OrderProperty.d.ts +0 -8
  193. package/dist/src/Query.d.ts +0 -59
  194. package/dist/src/QueryBase.d.ts +0 -18
  195. package/dist/src/QueryBuilder.d.ts +0 -13
  196. package/dist/src/Requests/BatchRequest.d.ts +0 -146
  197. package/dist/src/Requests/ExecutableRequest.d.ts +0 -22
  198. package/dist/src/Requests/Request.d.ts +0 -132
  199. package/dist/src/Requests/RequestBase.d.ts +0 -27
  200. package/dist/src/Requests/request.spec.d.ts +0 -1
  201. package/dist/src/Sitefinity.d.ts +0 -75
  202. package/dist/src/Sitefinity.spec.d.ts +0 -1
  203. package/dist/src/WhereQuery.d.ts +0 -72
  204. package/dist/src/chunk-upload/chunk-upload.sdk.d.ts +0 -295
  205. package/dist/src/chunk-upload/chunk-upload.sdk.spec.d.ts +0 -1
  206. package/dist/src/chunk-upload/chunked-file-upload.utilities.d.ts +0 -13
  207. package/dist/src/utils.d.ts +0 -16
  208. package/karma.conf.js +0 -29
  209. package/sitefinity-webservices-sdk.ts +0 -15
  210. package/src/BlobBuilder.ts +0 -20
  211. package/src/Data.spec.ts +0 -160
  212. package/src/Data.ts +0 -418
  213. package/src/Expression.ts +0 -36
  214. package/src/OrderProperty.ts +0 -39
  215. package/src/Query.ts +0 -106
  216. package/src/QueryBase.ts +0 -57
  217. package/src/QueryBuilder.ts +0 -180
  218. package/src/Requests/BatchRequest.ts +0 -807
  219. package/src/Requests/ExecutableRequest.ts +0 -117
  220. package/src/Requests/Request.ts +0 -327
  221. package/src/Requests/RequestBase.ts +0 -163
  222. package/src/Requests/RequestFactory.ts +0 -75
  223. package/src/Requests/request.spec.ts +0 -154
  224. package/src/Sitefinity.spec.ts +0 -483
  225. package/src/Sitefinity.ts +0 -125
  226. package/src/WhereQuery.ts +0 -145
  227. package/src/chunk-upload/chunk-upload.sdk.spec.ts +0 -347
  228. package/src/chunk-upload/chunk-upload.sdk.ts +0 -439
  229. package/src/chunk-upload/chunked-file-upload.utilities.ts +0 -64
  230. package/src/constants.ts +0 -66
  231. package/src/utils.ts +0 -125
  232. package/template.html +0 -625
  233. package/tsconfig.json +0 -38
package/README.md CHANGED
@@ -1,86 +1,119 @@
1
1
  # Sitefinity WebServices SDK
2
2
 
3
- ## Introduction
3
+ JavaScript SDK for the Sitefinity OData web services. It builds requests, sends them and hands you the response data.
4
4
 
5
- The Sitefinity WebServices JavaScript SDK is intended to help clients use the sitefinity OData web services by providing easy way to build requests and receive response data.
5
+ ## Installation
6
6
 
7
- ## Development
7
+ ```bash
8
+ npm install @progress/sitefinity-webservices-sdk
9
+ ```
8
10
 
9
- 1. Run `$ npm install` in the root of the project.
11
+ Requires Node.js 18 or later when used outside the browser.
10
12
 
11
- The source code is available in the *src* folder.
13
+ ## Usage
12
14
 
13
- To build the source code use:
15
+ ### ES modules and TypeScript
14
16
 
15
- ```bash
16
- npm run build:dev
17
- ```
17
+ ```ts
18
+ import { Query, Sitefinity } from "@progress/sitefinity-webservices-sdk";
18
19
 
19
- To build and serve the source code on each change:
20
+ const sdk = new Sitefinity({ baseUrl: "https://example.com/api/default/" });
21
+ sdk.setToken({ type: "Bearer", value: "<access token>" });
20
22
 
21
- ```bash
22
- npm start
23
+ const query = new Query().where().eq("Title", "Hello").done().take(10);
24
+
25
+ sdk.data({ entitySet: "newsitems", culture: "en" }).get({
26
+ query,
27
+ successCb: (data) => console.log(data),
28
+ failureCb: (error) => console.error(error)
29
+ });
23
30
  ```
24
31
 
25
- The output is located in the **dist** folder of the project - **sitefinity-webservices-sdk.js**
32
+ ### CommonJS
26
33
 
27
- ## Other commands
34
+ ```js
35
+ const { Sitefinity } = require("@progress/sitefinity-webservices-sdk");
36
+ ```
28
37
 
29
- To build minified source code:
38
+ ### Script tag
30
39
 
31
- ```bash
32
- npm run build:prod
40
+ ```html
41
+ <script src="https://unpkg.com/@progress/sitefinity-webservices-sdk"></script>
42
+ <script>
43
+ var sdk = new Sitefinity.Sitefinity({ baseUrl: "https://example.com/api/default/" });
44
+ </script>
33
45
  ```
34
46
 
35
- To prepare realese code (bulds minified source, creates documentation):
47
+ The script resolves to the minified bundle. `sitefinity-webservices-sdk.js` is the unminified build with a source map.
48
+ To type the `Sitefinity` global in TypeScript, add a reference:
36
49
 
37
- ```bash
38
- npm run build:release
50
+ ```ts
51
+ /// <reference types="@progress/sitefinity-webservices-sdk/browser-global" />
39
52
  ```
40
53
 
41
- The release output is located in the **dist** folder of the project. It contains the source and documentation.
54
+ ## Options
42
55
 
43
- ## Documentation
56
+ | Option | Description |
57
+ |--------------------------|----------------------------------------------------------------------------|
58
+ | `baseUrl` | Service URL, for example `https://example.com/api/default/`. |
59
+ | `siteId` | Site that requests run against. Can be overridden per `data()` or `batch()`. |
60
+ | `handlers` | Default `successCb` and `failureCb` used when a request does not set its own. |
61
+ | `enableUnlimitedChoices` | Sends the unlimited-choices request header. |
62
+ | `integrationMode` | Sends the integration-mode request header. |
63
+ | `transport` | Sends every HTTP request. Defaults to `XhrTransport`. See below. |
44
64
 
45
- To generate the SDK documentation `$ npm run build:release` command must be executed. Docs can be found inside the **dist/documentation** folder.
65
+ ## Transport
46
66
 
47
- ## Samples
67
+ By default the SDK sends requests with `XMLHttpRequest`, which does not exist in Node.js. Outside the browser, or to
68
+ route SDK traffic through another HTTP stack such as Angular's `HttpClient`, pass a transport:
48
69
 
49
- There are examples how to use the SDK and create various types of request. The file is located in the **dist** folder - **samples.html**
50
- To run it, you need to build the source code of the SDK.
51
- Then replace **my_sandbox_location** with the server location you are using.
70
+ ```ts
71
+ import { FetchTransport, Sitefinity } from "@progress/sitefinity-webservices-sdk";
52
72
 
53
- ```js
54
- var options = {
55
- serviceUrl: "my_sandbox_location" + "/api/default/"
56
- }
73
+ const sdk = new Sitefinity({ baseUrl: "https://example.com/api/default/", transport: new FetchTransport() });
57
74
  ```
58
75
 
59
- Also replace **username** and **password** with the credentials of your user.
76
+ `XhrTransport` (the default) and `FetchTransport` ship with the SDK. To use anything else, implement `HttpTransport`:
60
77
 
61
- ```js
62
- sf.authentication.login("username", "password");
78
+ ```ts
79
+ import { HttpTransport, HttpTransportRequest, HttpTransportResponse } from "@progress/sitefinity-webservices-sdk";
80
+
81
+ class MyTransport implements HttpTransport {
82
+ send(request: HttpTransportRequest, onComplete: (response: HttpTransportResponse) => void): void {
83
+ // Send request.method, request.url, request.headers and request.body, then call:
84
+ onComplete({ status: 200, body: "{}", headers: { "content-type": "application/json" } });
85
+ }
86
+ }
63
87
  ```
64
88
 
65
- ## License
89
+ The contract:
90
+
91
+ - Call `onComplete` exactly once, with the status the server returned. Do not turn error statuses into
92
+ exceptions; the SDK decides which statuses are successes or failures and calls `successCb` or `failureCb`.
93
+ - Report `status: 0` when no response was received. The SDK calls neither callback for `0`.
94
+ - `onComplete` may be called synchronously, and the SDK's callbacks run inside it.
95
+ - `headers` must use lower-case names. Only `$batch` reads them, for the `content-type` boundary.
96
+ - Honour `request.onUploadProgress` only when it is present. Transports that cannot report progress, such as
97
+ `FetchTransport`, ignore it.
66
98
 
67
- The MIT License (MIT)
99
+ ## Package contents
68
100
 
69
- Copyright (c) 2022 Progress Software Corporation
101
+ - `import` resolves to an ES module build that bundlers can tree-shake. `require` resolves to a single CommonJS file.
102
+ Both ship TypeScript declarations and source maps.
103
+ - The only public entry points are the package root, `@progress/sitefinity-webservices-sdk/browser-global` and
104
+ `package.json`. Deep imports such as `@progress/sitefinity-webservices-sdk/src/Query` are not supported.
105
+ Everything that used to need one, including `QueryBase` and the chunk-upload types and helpers, is exported
106
+ from the root.
107
+ - The ES module and CommonJS builds are separate copies of the code. If one application loads both, for example
108
+ `import` from your code and `require` from a dependency, classes from the two builds are not `instanceof`-compatible.
70
109
 
71
- Permission is hereby granted, free of charge, to any person obtaining a copy of
72
- this software and associated documentation files (the "Software"), to deal in
73
- the Software without restriction, including without limitation the rights to
74
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
75
- the Software, and to permit persons to whom the Software is furnished to do so,
76
- subject to the following conditions:
110
+ ## Upgrading from 1.x
77
111
 
78
- The above copyright notice and this permission notice shall be included in all
79
- copies or substantial portions of the Software.
112
+ - Replace imports that go through `dist/` or `src/` with imports from the package root:
113
+ `@progress/sitefinity-webservices-sdk/dist/sitefinity-webservices-sdk` becomes `@progress/sitefinity-webservices-sdk`.
114
+ - `samples.html` is no longer part of the package.
115
+ - Requests are sent through a pluggable `HttpTransport`. The default behaviour is unchanged.
116
+
117
+ ## License
80
118
 
81
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
82
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
83
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
84
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
85
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
86
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
119
+ [MIT](./LICENSE.txt) © Progress Software Corporation
@@ -0,0 +1,179 @@
1
+ // src/utils.ts
2
+ var utils = class _utils {
3
+ /**
4
+ * Determines whether a value is a primitive or boxed string.
5
+ *
6
+ * @param obj Value to inspect.
7
+ * @returns `true` when the value is a string.
8
+ */
9
+ static isString(obj) {
10
+ return typeof obj === "string" || obj instanceof String;
11
+ }
12
+ /**
13
+ * Determines whether a value is a boolean.
14
+ *
15
+ * @param obj Value to inspect.
16
+ * @returns `true` for primitive boolean values.
17
+ */
18
+ static isBoolean(obj) {
19
+ return typeof obj === "boolean";
20
+ }
21
+ /**
22
+ * Determines whether a value is a {@link Blob}.
23
+ *
24
+ * @param obj Value to inspect.
25
+ * @returns `true` when the value is a `Blob`.
26
+ */
27
+ static isBlob(obj) {
28
+ return obj instanceof Blob;
29
+ }
30
+ /**
31
+ * Determines whether a value is a finite number.
32
+ *
33
+ * @param value Value to inspect.
34
+ * @returns `true` for finite numeric values.
35
+ */
36
+ static isNumber(value) {
37
+ return typeof value === "number" && isFinite(value);
38
+ }
39
+ /**
40
+ * Determines whether a value is callable.
41
+ *
42
+ * @param func Value to inspect.
43
+ * @returns `true` when the value is a function.
44
+ */
45
+ static isFunction(func) {
46
+ return typeof func === "function";
47
+ }
48
+ /**
49
+ * Converts request data to its wire representation.
50
+ *
51
+ * Strings and blobs are returned unchanged. Other values are serialized with `JSON.stringify`.
52
+ *
53
+ * @param data Request body value.
54
+ * @returns The original string or blob, or a JSON string for other values.
55
+ */
56
+ static serializeToJSON(data) {
57
+ if (!_utils.isString(data) && !this.isBlob(data)) {
58
+ return JSON.stringify(data);
59
+ }
60
+ return data;
61
+ }
62
+ /**
63
+ * Parses a response string as a number or JSON value.
64
+ *
65
+ * ISO 8601 date strings in parsed objects and arrays are converted to {@link Date} instances.
66
+ * Non-JSON text returns `null`.
67
+ *
68
+ * @param data Response text to parse.
69
+ * @returns The parsed value, or `null` when the input is empty or not valid JSON.
70
+ */
71
+ static parseStringToJson(data) {
72
+ if (!data) {
73
+ return null;
74
+ }
75
+ const number = Number(data);
76
+ if (!isNaN(number)) {
77
+ return number;
78
+ }
79
+ let result = null;
80
+ try {
81
+ result = JSON.parse(data);
82
+ result = _utils._parseDateProperties(result);
83
+ } catch (e) {
84
+ }
85
+ return result;
86
+ }
87
+ /**
88
+ * Converts top-level {@link Date} properties to ISO 8601 strings in place.
89
+ *
90
+ * @param data Object that will be sent in a request.
91
+ * @returns The same object instance after conversion.
92
+ */
93
+ static convertDateFieldToISOString(data) {
94
+ for (const obj in data) {
95
+ if (data[obj] instanceof Date) {
96
+ data[obj] = data[obj].toISOString();
97
+ }
98
+ }
99
+ return data;
100
+ }
101
+ /**
102
+ * Generates a four-character hexadecimal segment.
103
+ *
104
+ * @returns A pseudo-random lowercase hexadecimal string.
105
+ */
106
+ static hex16() {
107
+ return Math.floor((1 + Math.random()) * 65536).toString(16).substr(1);
108
+ }
109
+ /**
110
+ * Ensures that a URL ends with exactly one slash.
111
+ *
112
+ * @param url URL to normalize.
113
+ * @returns The normalized URL.
114
+ */
115
+ static addTrailingSlash(url) {
116
+ url = _utils.removeSlashes(url);
117
+ url += "/";
118
+ return url;
119
+ }
120
+ /**
121
+ * Removes one trailing slash from a URL.
122
+ *
123
+ * @param url URL to normalize.
124
+ * @returns The URL without a trailing slash.
125
+ */
126
+ static removeSlashes(url) {
127
+ let ret = url;
128
+ const lastChar = ret.substr(-1);
129
+ if (lastChar == "/")
130
+ ret = ret.substr(0, ret.length - 1);
131
+ return ret;
132
+ }
133
+ /**
134
+ * Performs the SDK's backward-compatible shallow clone operation.
135
+ *
136
+ * The optional action is called while properties are copied and is used by fluent query
137
+ * objects to update the cloned instance.
138
+ *
139
+ * @param from Source object.
140
+ * @param to Optional target object.
141
+ * @param action Optional callback invoked with the target during copying.
142
+ * @returns The populated target object.
143
+ */
144
+ static clone(from, to = {}, action = null) {
145
+ if (!to)
146
+ to = {};
147
+ for (const property in from) {
148
+ if (from[property] && from[property].constructor && from[property].constructor === Object && typeof from[property] == "function") {
149
+ to[property] = to[property] || {};
150
+ arguments.callee(to[property], from[property]);
151
+ } else {
152
+ to[property] = from[property];
153
+ }
154
+ if (typeof action === "function")
155
+ action(to);
156
+ }
157
+ return to;
158
+ }
159
+ static _parseDateProperties(data) {
160
+ for (const obj in data) {
161
+ if (data[obj] instanceof Array || data[obj] instanceof Object && !(data[obj] instanceof Function))
162
+ this._parseDateProperties(data[obj]);
163
+ else
164
+ data[obj] = _utils._tryFormatFieldToDate(data[obj]);
165
+ }
166
+ return data;
167
+ }
168
+ static _tryFormatFieldToDate(date) {
169
+ if (/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*))(?:Z|(\+|-)([\d|:]*))?$/.test(date)) {
170
+ date = new Date(date);
171
+ }
172
+ return date;
173
+ }
174
+ };
175
+
176
+ export {
177
+ utils
178
+ };
179
+ //# sourceMappingURL=chunk-2ID24RPE.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/utils.ts"],
4
+ "sourcesContent": ["\uFEFF/**\n * General-purpose value, URL, serialization, and response conversion helpers used by the SDK.\n *\n * These helpers are exported for backward compatibility. Application code should normally use\n * the higher-level {@link Sitefinity}, {@link Data}, and {@link Query} APIs.\n */\nexport class utils {\n /**\n * Determines whether a value is a primitive or boxed string.\n *\n * @param obj Value to inspect.\n * @returns `true` when the value is a string.\n */\n static isString(obj: any): boolean {\n return typeof (obj) === \"string\" || obj instanceof String;\n }\n\n /**\n * Determines whether a value is a boolean.\n *\n * @param obj Value to inspect.\n * @returns `true` for primitive boolean values.\n */\n static isBoolean(obj: any): boolean {\n return typeof (obj) === \"boolean\";\n }\n\n /**\n * Determines whether a value is a {@link Blob}.\n *\n * @param obj Value to inspect.\n * @returns `true` when the value is a `Blob`.\n */\n static isBlob(obj: any): boolean {\n return obj instanceof Blob;\n }\n\n /**\n * Determines whether a value is a finite number.\n *\n * @param value Value to inspect.\n * @returns `true` for finite numeric values.\n */\n static isNumber(value: any): boolean {\n return typeof value === \"number\" && isFinite(value);\n }\n\n /**\n * Determines whether a value is callable.\n *\n * @param func Value to inspect.\n * @returns `true` when the value is a function.\n */\n static isFunction(func: any): boolean {\n return typeof func === \"function\";\n }\n\n /**\n * Converts request data to its wire representation.\n *\n * Strings and blobs are returned unchanged. Other values are serialized with `JSON.stringify`.\n *\n * @param data Request body value.\n * @returns The original string or blob, or a JSON string for other values.\n */\n static serializeToJSON(data): string {\n if (!utils.isString(data) && !this.isBlob(data)) {\n return JSON.stringify(data);\n }\n\n return data;\n }\n\n /**\n * Parses a response string as a number or JSON value.\n *\n * ISO 8601 date strings in parsed objects and arrays are converted to {@link Date} instances.\n * Non-JSON text returns `null`.\n *\n * @param data Response text to parse.\n * @returns The parsed value, or `null` when the input is empty or not valid JSON.\n */\n static parseStringToJson(data) {\n if (!data) {\n return null;\n }\n\n const number = Number(data);\n if (!isNaN(number)) {\n return number;\n }\n\n let result = null;\n\n try {\n result = JSON.parse(data);\n result = utils._parseDateProperties(result);\n } catch (e) {\n // Intentionally not logging it in the browser console because there are cases when the response is not a JSON string.\n }\n\n return result;\n }\n\n /**\n * Converts top-level {@link Date} properties to ISO 8601 strings in place.\n *\n * @param data Object that will be sent in a request.\n * @returns The same object instance after conversion.\n */\n static convertDateFieldToISOString(data: object): object {\n /*\n TODOSDK: when write tests for this try to use\n \"Object.keys(obj).forEach(function(){})\",\n Phantomjs does not recognize \"for..in\" operator.\n */\n for (const obj in data) {\n if (data[obj] instanceof Date) {\n data[obj] = data[obj].toISOString();\n }\n }\n\n return data;\n }\n\n /**\n * Generates a four-character hexadecimal segment.\n *\n * @returns A pseudo-random lowercase hexadecimal string.\n */\n static hex16() {\n return Math.floor((1 + Math.random()) * 0x10000).toString(16).substr(1);\n }\n\n /**\n * Ensures that a URL ends with exactly one slash.\n *\n * @param url URL to normalize.\n * @returns The normalized URL.\n */\n static addTrailingSlash(url: string): string {\n url = utils.removeSlashes(url);\n url += \"/\";\n return url;\n }\n\n /**\n * Removes one trailing slash from a URL.\n *\n * @param url URL to normalize.\n * @returns The URL without a trailing slash.\n */\n static removeSlashes(url: string) {\n let ret = url;\n\n const lastChar = ret.substr(-1);\n if (lastChar == \"/\")\n ret = ret.substr(0, ret.length - 1);\n\n return ret;\n }\n\n /**\n * Performs the SDK's backward-compatible shallow clone operation.\n *\n * The optional action is called while properties are copied and is used by fluent query\n * objects to update the cloned instance.\n *\n * @param from Source object.\n * @param to Optional target object.\n * @param action Optional callback invoked with the target during copying.\n * @returns The populated target object.\n */\n static clone(from: any, to = {}, action: Function = null): any {\n if (!to)\n to = {};\n\n for (const property in from) {\n if (from[property] && from[property].constructor && from[property].constructor === Object && typeof from[property] == \"function\") {\n to[property] = to[property] || {};\n arguments.callee(to[property], from[property]);\n } else {\n to[property] = from[property];\n }\n\n if (typeof action === \"function\")\n action(to);\n }\n\n return to;\n }\n\n private static _parseDateProperties(data) {\n for (const obj in data) {\n if (data[obj] instanceof Array || (data[obj] instanceof Object && !(data[obj] instanceof Function)))\n this._parseDateProperties(data[obj]);\n else\n data[obj] = utils._tryFormatFieldToDate(data[obj]);\n }\n\n return data;\n }\n\n private static _tryFormatFieldToDate(date) {\n if ((/^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2}(?:\\.\\d*))(?:Z|(\\+|-)([\\d|:]*))?$/).test(date)) {\n date = new Date(date);\n }\n\n return date;\n }\n}\n"],
5
+ "mappings": ";AAMO,IAAM,QAAN,MAAM,OAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOf,OAAO,SAAS,KAAmB;AAC/B,WAAO,OAAQ,QAAS,YAAY,eAAe;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,UAAU,KAAmB;AAChC,WAAO,OAAQ,QAAS;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,OAAO,KAAmB;AAC7B,WAAO,eAAe;A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AK,IAAI,GAAG;AACjG,aAAO,IAAI,KAAK,IAAI;AAAA,IACxB;AAEA,WAAO;AAAA,EACX;AACJ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,93 @@
1
+ import {
2
+ BatchRequest
3
+ } from "./chunk-PXPK2IV6.mjs";
4
+ import {
5
+ CommitChunksRequest,
6
+ CreateRelatedRequest,
7
+ CreateRequest,
8
+ DeleteRelatedByIdRequest,
9
+ DeleteRelatedRequest,
10
+ DeleteRequest,
11
+ GetByIdRequest,
12
+ GetRelatedByIdRequest,
13
+ GetRelatedRequest,
14
+ GetRequest,
15
+ UpdateRequest,
16
+ UploadChunkRequest,
17
+ UploadRequest
18
+ } from "./chunk-PI55MBSL.mjs";
19
+
20
+ // src/Requests/RequestFactory.ts
21
+ var RequestFactory = class {
22
+ /** Creates a request factory using the supplied SDK-wide options. */
23
+ constructor(options) {
24
+ this.options = options;
25
+ }
26
+ /** Creates a request for retrieving a collection. */
27
+ get(parameters) {
28
+ return new GetRequest(parameters, this.token, this.options);
29
+ }
30
+ /** Creates a request for retrieving one item by key. */
31
+ getSingle(parameters) {
32
+ return new GetByIdRequest(parameters, this.token, this.options);
33
+ }
34
+ /** Creates a request for creating one item. */
35
+ create(parameters) {
36
+ return new CreateRequest(parameters, this.token, this.options);
37
+ }
38
+ /** Creates a request for updating one item. */
39
+ update(parameters) {
40
+ return new UpdateRequest(parameters, this.token, this.options);
41
+ }
42
+ /** Creates a request for deleting one item. */
43
+ destroy(parameters) {
44
+ return new DeleteRequest(parameters, this.token, this.options);
45
+ }
46
+ /** Creates a request for retrieving a related property value. */
47
+ getProperty(parameters) {
48
+ return new GetRelatedRequest(parameters, this.token, this.options);
49
+ }
50
+ /** Creates a request for retrieving related items. */
51
+ getRelated(parameters) {
52
+ return new GetRelatedRequest(parameters, this.token, this.options);
53
+ }
54
+ /** Creates a request for retrieving one related item by key. */
55
+ getRelatedById(parameters) {
56
+ return new GetRelatedByIdRequest(parameters, this.token, this.options);
57
+ }
58
+ /** Creates a request for removing all related links for a property. */
59
+ destroyRelated(parameters) {
60
+ return new DeleteRelatedRequest(parameters, this.token, this.options);
61
+ }
62
+ /** Creates a request for removing one related link by key. */
63
+ destroyRelatedById(parameters) {
64
+ return new DeleteRelatedByIdRequest(parameters, this.token, this.options);
65
+ }
66
+ /** Creates a request for adding a related link. */
67
+ createRelated(parameters) {
68
+ return new CreateRelatedRequest(parameters, this.token, this.options);
69
+ }
70
+ /** Creates a request for uploading a file or binary payload. */
71
+ upload(parameters) {
72
+ return new UploadRequest(parameters, this.token, this.options);
73
+ }
74
+ /** Creates a request for uploading one file chunk. */
75
+ uploadChunk(parameters) {
76
+ return new UploadChunkRequest(parameters, this.token, this.options);
77
+ }
78
+ /** Creates a request that commits an uploaded chunk session. */
79
+ commitChunks(parameters) {
80
+ return new CommitChunksRequest(parameters, this.token, this.options);
81
+ }
82
+ /** Creates a multipart batch request; call its methods to add operations, then call `execute()`. */
83
+ batch(parameters) {
84
+ const batchParams = parameters;
85
+ batchParams.factory = this;
86
+ return new BatchRequest(batchParams, this.token, this.options);
87
+ }
88
+ };
89
+
90
+ export {
91
+ RequestFactory
92
+ };
93
+ //# sourceMappingURL=chunk-AHDZ2CWQ.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/Requests/RequestFactory.ts"],
4
+ "sourcesContent": ["\uFEFFimport { GetRequest, GetByIdRequest, CreateRequest, UpdateRequest, DeleteRequest, GetRelatedRequest, GetRelatedByIdRequest, DeleteRelatedRequest, DeleteRelatedByIdRequest, CreateRelatedRequest, UploadRequest, PostRequestOptionsExtended, PutRequestOptionsExtended, RelatedRequestOptionsExtended, RelatedByIdRequestOptionsExtended, UploadRequestOptionsExtended, UploadChunkRequest, CommitChunksRequest, CommitChunksRequestOptionsExtended, UploadChunkRequestOptionsExtended } from \"./Request\";\nimport { AuthorizationToken, SDKOptions } from \"../Sitefinity\";\nimport { BatchRequest, BatchRequestOptionsExtended } from \"./BatchRequest\";\nimport { RequestOptionsBaseExtended } from \"./RequestBase\";\n\n/**\n * Creates low-level request objects for data, relation, upload, and batch operations.\n *\n * This is an advanced API. Requests must be executed explicitly and report results through callbacks.\n */\nexport class RequestFactory {\n /** Authentication token applied to requests created by this factory. */\n public token: AuthorizationToken;\n private options: SDKOptions;\n\n /** Creates a request factory using the supplied SDK-wide options. */\n constructor(options: SDKOptions) {\n this.options = options;\n }\n\n /** Creates a request for retrieving a collection. */\n get(parameters: RequestOptionsBaseExtended) {\n return new GetRequest(parameters, this.token, this.options);\n }\n\n /** Creates a request for retrieving one item by key. */\n getSingle(parameters: RequestOptionsBaseExtended) {\n return new GetByIdRequest(parameters, this.token, this.options);\n }\n\n /** Creates a request for creating one item. */\n create(parameters: PostRequestOptionsExtended) {\n return new CreateRequest(parameters, this.token, this.options);\n }\n\n /** Creates a request for updating one item. */\n update(parameters: PutRequestOptionsExtended) {\n return new UpdateRequest(parameters, this.token, this.options);\n }\n\n /** Creates a request for deleting one item. */\n destroy(parameters: RequestOptionsBaseExtended) {\n return new DeleteRequest(parameters, this.token, this.options);\n }\n\n /** Creates a request for retrieving a related property value. */\n getProperty(parameters: RelatedRequestOptionsExtended) {\n return new GetRelatedRequest(parameters, this.token, this.options);\n }\n\n /** Creates a request for retrieving related items. */\n getRelated(parameters: RelatedRequestOptionsExtended) {\n return new GetRelatedRequest(parameters, this.token, this.options);\n }\n\n /** Creates a request for retrieving one related item by key. */\n getRelatedById(parameters: RelatedByIdRequestOptionsExtended) {\n return new GetRelatedByIdRequest(parameters, this.token, this.options);\n }\n\n /** Creates a request for removing all related links for a property. */\n destroyRelated(parameters: RelatedRequestOptionsExtended) {\n return new DeleteRelatedRequest(parameters, this.token, this.options);\n }\n\n /** Creates a request for removing one related link by key. */\n destroyRelatedById(parameters: RelatedByIdRequestOptionsExtended) {\n return new DeleteRelatedByIdRequest(parameters, this.token, this.options);\n }\n\n /** Creates a request for adding a related link. */\n createRelated(parameters: RelatedRequestOptionsExtended) {\n return new CreateRelatedRequest(parameters, this.token, this.options);\n }\n\n /** Creates a request for uploading a file or binary payload. */\n upload(parameters: UploadRequestOptionsExtended) {\n return new UploadRequest(parameters, this.token, this.options);\n }\n\n /** Creates a request for uploading one file chunk. */\n uploadChunk(parameters: UploadChunkRequestOptionsExtended) {\n return new UploadChunkRequest(parameters, this.token, this.options);\n }\n\n /** Creates a request that commits an uploaded chunk session. */\n commitChunks(parameters: CommitChunksRequestOptionsExtended) {\n return new CommitChunksRequest(parameters, this.token, this.options);\n }\n\n /** Creates a multipart batch request; call its methods to add operations, then call `execute()`. */\n batch(parameters: RequestOptionsBaseExtended) {\n const batchParams = parameters as BatchRequestOptionsExtended;\n batchParams.factory = this;\n return new BatchRequest(batchParams, this.token, this.options);\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAUO,IAAM,iBAAN,MAAqB;AAAA;AAAA,EAMxB,YAAY,SAAqB;AAC7B,SAAK,UAAU;AAAA,EACnB;AAAA;AAAA,EAGA,IAAI,YAAwC;AACxC,WAAO,IAAI,WAAW,YAAY,KAAK,OAAO,KAAK,OAAO;AAAA,EAC9D;AAAA;AAAA,EAGA,UAAU,YAAwC;AAC9C,WAAO,IAAI,eAAe,YAAY,KAAK,OAAO,KAAK,OAAO;AAAA,EAClE;AAAA;AAAA,EAGA,OAAO,YAAwC;AAC3C,WAAO,IAAI,cAAc,YAAY,KAAK,OAAO,KAAK,OAAO;AAAA,EACjE;AAAA;AAAA,EAGA,OAAO,YAAuC;AAC1C,WAAO,IAAI,cAAc,YAAY,KAAK,OAAO,KAAK,OAAO;AAAA,EACjE;AAAA;AAAA,EAGA,QAAQ,YAAwC;AAC5C,WAAO,IAAI,cAAc,YAAY,KAAK,OAAO,KAAK,OAAO;AAAA,EACjE;AAAA;AAAA,EAGA,YAAY,YAA2C;AACnD,WAAO,IAAI,kBAAkB,YAAY,KAAK,OAAO,KAAK,OAAO;AAAA,EACrE;AAAA;AAAA,EAGA,WAAW,YAA2C;AAClD,WAAO,IAAI,kBAAkB,YAAY,KAAK,OAAO,KAAK,OAAO;AAAA,EACrE;AAAA;AAAA,EAGA,eAAe,YAA+C;AAC1D,WAAO,IAAI,sBAAsB,YAAY,KAAK,OAAO,KAAK,OAAO;AAAA,EACzE;AAAA;AAAA,EAGA,eAAe,YAA2C;AACtD,WAAO,IAAI,qBAAqB,YAAY,KAAK,OAAO,KAAK,OAAO;AAAA,EACxE;AAAA;AAAA,EAGA,mBAAmB,YAA+C;AAC9D,WAAO,IAAI,yBAAyB,YAAY,KAAK,OAAO,KAAK,OAAO;AAAA,EAC5E;AAAA;AAAA,EAGA,cAAc,YAA2C;AACrD,WAAO,IAAI,qBAAqB,YAAY,KAAK,OAAO,KAAK,OAAO;AAAA,EACxE;AAAA;AAAA,EAGA,OAAO,YAA0C;AAC7C,WAAO,IAAI,cAAc,YAAY,KAAK,OAAO,KAAK,OAAO;AAAA,EACjE;AAAA;AAAA,EAGA,YAAY,YAA+C;AACvD,WAAO,IAAI,mBAAmB,YAAY,KAAK,OAAO,KAAK,OAAO;AAAA,EACtE;AAAA;AAAA,EAGA,aAAa,YAAgD;AACzD,WAAO,IAAI,oBAAoB,YAAY,KAAK,OAAO,KAAK,OAAO;AAAA,EACvE;AAAA;AAAA,EAGA,MAAM,YAAwC;AAC1C,UAAM,cAAc;AACpB,gBAAY,UAAU;AACtB,WAAO,IAAI,aAAa,aAAa,KAAK,OAAO,KAAK,OAAO;AAAA,EACjE;AACJ;",
6
+ "names": []
7
+ }
@@ -0,0 +1,136 @@
1
+ import {
2
+ EXPRESSION_TYPE
3
+ } from "./chunk-RQAAYOY6.mjs";
4
+ import {
5
+ BinaryExpression,
6
+ ComplexExpression
7
+ } from "./chunk-F4CWOE7M.mjs";
8
+
9
+ // src/WhereQuery.ts
10
+ var WhereQuery = class _WhereQuery {
11
+ /** Creates a logical group attached to the supplied parent. */
12
+ constructor(parent, type = EXPRESSION_TYPE.and) {
13
+ this.parent = parent;
14
+ this.expression = new ComplexExpression(type, []);
15
+ }
16
+ /**
17
+ * Starts a nested `and` group.
18
+ * @returns A nested builder whose `done()` returns this group.
19
+ */
20
+ and() {
21
+ return new _WhereQuery(this, EXPRESSION_TYPE.and);
22
+ }
23
+ /**
24
+ * Starts a nested `or` group.
25
+ * @returns A nested builder whose `done()` returns this group.
26
+ */
27
+ or() {
28
+ return new _WhereQuery(this, EXPRESSION_TYPE.or);
29
+ }
30
+ /**
31
+ * Starts an OData `any` group for collection-valued properties.
32
+ * @returns A nested builder whose `done()` returns this group.
33
+ */
34
+ any() {
35
+ return new _WhereQuery(this, EXPRESSION_TYPE.any);
36
+ }
37
+ /**
38
+ * Starts a negated group.
39
+ * @returns A nested builder whose `done()` returns this group.
40
+ * @throws Error If more than one direct condition is added to the group.
41
+ */
42
+ not() {
43
+ return new _WhereQuery(this, EXPRESSION_TYPE.not);
44
+ }
45
+ /**
46
+ * Adds an equality condition.
47
+ * @param parameter Property name.
48
+ * @param constant Value to compare with.
49
+ * @returns This filter builder.
50
+ */
51
+ eq(parameter, constant) {
52
+ return this.simple(EXPRESSION_TYPE.eq, parameter, constant);
53
+ }
54
+ /**
55
+ * Adds an inequality condition.
56
+ * @param parameter Property name.
57
+ * @param constant Value to compare with.
58
+ * @returns This filter builder.
59
+ */
60
+ ne(parameter, constant) {
61
+ return this.simple(EXPRESSION_TYPE.ne, parameter, constant);
62
+ }
63
+ /** Adds a greater-than condition for number, string, or date values. */
64
+ gt(parameter, constant) {
65
+ return this.simple(EXPRESSION_TYPE.gt, parameter, constant);
66
+ }
67
+ /** Adds a greater-than-or-equal condition for number, string, or date values. */
68
+ gte(parameter, constant) {
69
+ return this.simple(EXPRESSION_TYPE.ge, parameter, constant);
70
+ }
71
+ /** Adds a less-than condition for number, string, or date values. */
72
+ lt(parameter, constant) {
73
+ return this.simple(EXPRESSION_TYPE.lt, parameter, constant);
74
+ }
75
+ /** Adds a less-than-or-equal condition for number, string, or date values. */
76
+ lte(parameter, constant) {
77
+ return this.simple(EXPRESSION_TYPE.le, parameter, constant);
78
+ }
79
+ /** Adds a string-prefix condition, optionally using case-insensitive matching. */
80
+ startsWith(parameter, constant, caseSensitive = true) {
81
+ return this.simple(EXPRESSION_TYPE.startsWith, parameter, constant, caseSensitive);
82
+ }
83
+ /** Adds a string-contains condition, optionally using case-insensitive matching. */
84
+ contains(parameter, constant, caseSensitive = true) {
85
+ return this.simple(EXPRESSION_TYPE.contains, parameter, constant, caseSensitive);
86
+ }
87
+ /** Adds a string-suffix condition, optionally using case-insensitive matching. */
88
+ endsWith(parameter, constant, caseSensitive = true) {
89
+ return this.simple(EXPRESSION_TYPE.endsWith, parameter, constant, caseSensitive);
90
+ }
91
+ /**
92
+ * Adds an OData `in` condition.
93
+ *
94
+ * The constant must be an array; otherwise `build()` throws an error.
95
+ */
96
+ in(parameter, constant) {
97
+ return this.simple(EXPRESSION_TYPE.in, parameter, constant);
98
+ }
99
+ /**
100
+ * Completes this group and returns its parent.
101
+ *
102
+ * Call once for the root filter to return to `Query`, and once for each
103
+ * nested group to continue the surrounding chain.
104
+ *
105
+ * @returns The parent query or enclosing filter group.
106
+ */
107
+ done() {
108
+ if (this.parent instanceof _WhereQuery) {
109
+ this.parent.addComplexExpression(this);
110
+ if (this.expression.getType() === EXPRESSION_TYPE.not)
111
+ return this.parent;
112
+ }
113
+ return this.parent;
114
+ }
115
+ /** Returns the expression tree represented by this filter group. */
116
+ getExpression() {
117
+ return this.expression;
118
+ }
119
+ simple(type, parameter, constant, caseSensitive = true) {
120
+ const currentExpr = new BinaryExpression(type, parameter, constant, caseSensitive);
121
+ const subExpressions = this.expression.getExpressions();
122
+ subExpressions.push(currentExpr);
123
+ if (this.expression.getType() === EXPRESSION_TYPE.not && subExpressions.length > 1)
124
+ throw new Error("Invalid operators count!");
125
+ return this;
126
+ }
127
+ addComplexExpression(subQuery) {
128
+ const subExpression = subQuery.getExpression();
129
+ this.expression.getExpressions().push(subExpression);
130
+ }
131
+ };
132
+
133
+ export {
134
+ WhereQuery
135
+ };
136
+ //# sourceMappingURL=chunk-BFLQBM7R.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/WhereQuery.ts"],
4
+ "sourcesContent": ["import { ComplexExpression, BinaryExpression } from \"./Expression\";\nimport { EXPRESSION_TYPE } from \"./constants\";\n\n/**\n * Fluent builder for a query's `$filter` expression.\n *\n * Comparison methods add conditions to the current logical group and return\n * the same builder. Logical methods create nested groups; call `done()` once\n * for each group to return to the parent query or group.\n *\n * Supported comparisons are `eq`, `ne`, `gt`, `gte`, `lt`, `lte`, `in`,\n * `startsWith`, `contains`, and `endsWith`. Values are serialized by the query\n * builder when the query is built.\n *\n * @typeParam QueryType The parent type returned by `done()`.\n */\nexport class WhereQuery<QueryType> {\n private expression: ComplexExpression;\n\n /** Creates a logical group attached to the supplied parent. */\n constructor(private parent: QueryType, type: string = EXPRESSION_TYPE.and) {\n this.expression = new ComplexExpression(type, []);\n }\n\n /**\n * Starts a nested `and` group.\n * @returns A nested builder whose `done()` returns this group.\n */\n and(): WhereQuery<WhereQuery<QueryType>> {\n return new WhereQuery(this, EXPRESSION_TYPE.and);\n }\n\n /**\n * Starts a nested `or` group.\n * @returns A nested builder whose `done()` returns this group.\n */\n or(): WhereQuery<WhereQuery<QueryType>> {\n return new WhereQuery(this, EXPRESSION_TYPE.or);\n }\n\n /**\n * Starts an OData `any` group for collection-valued properties.\n * @returns A nested builder whose `done()` returns this group.\n */\n any(): WhereQuery<WhereQuery<QueryType>> {\n return new WhereQuery(this, EXPRESSION_TYPE.any);\n }\n\n /**\n * Starts a negated group.\n * @returns A nested builder whose `done()` returns this group.\n * @throws Error If more than one direct condition is added to the group.\n */\n not(): WhereQuery<WhereQuery<QueryType>> {\n return new WhereQuery(this, EXPRESSION_TYPE.not);\n }\n\n /**\n * Adds an equality condition.\n * @param parameter Property name.\n * @param constant Value to compare with.\n * @returns This filter builder.\n */\n eq(parameter: string, constant: any): WhereQuery<QueryType> {\n return this.simple(EXPRESSION_TYPE.eq, parameter, constant);\n }\n\n /**\n * Adds an inequality condition.\n * @param parameter Property name.\n * @param constant Value to compare with.\n * @returns This filter builder.\n */\n ne(parameter: string, constant: any): WhereQuery<QueryType> {\n return this.simple(EXPRESSION_TYPE.ne, parameter, constant);\n }\n\n /** Adds a greater-than condition for number, string, or date values. */\n gt(parameter: string, constant: any) {\n return this.simple(EXPRESSION_TYPE.gt, parameter, constant);\n }\n\n /** Adds a greater-than-or-equal condition for number, string, or date values. */\n gte(parameter: string, constant: any) {\n return this.simple(EXPRESSION_TYPE.ge, parameter, constant);\n }\n\n /** Adds a less-than condition for number, string, or date values. */\n lt(parameter: string, constant: any) {\n return this.simple(EXPRESSION_TYPE.lt, parameter, constant);\n }\n\n /** Adds a less-than-or-equal condition for number, string, or date values. */\n lte(parameter: string, constant: any) {\n return this.simple(EXPRESSION_TYPE.le, parameter, constant);\n }\n\n /** Adds a string-prefix condition, optionally using case-insensitive matching. */\n startsWith(parameter: string, constant: any, caseSensitive = true) {\n return this.simple(EXPRESSION_TYPE.startsWith, parameter, constant, caseSensitive);\n }\n\n /** Adds a string-contains condition, optionally using case-insensitive matching. */\n contains(parameter: string, constant: any, caseSensitive = true) {\n return this.simple(EXPRESSION_TYPE.contains, parameter, constant, caseSensitive);\n }\n\n /** Adds a string-suffix condition, optionally using case-insensitive matching. */\n endsWith(parameter: string, constant: any, caseSensitive = true) {\n return this.simple(EXPRESSION_TYPE.endsWith, parameter, constant, caseSensitive);\n }\n\n /**\n * Adds an OData `in` condition.\n *\n * The constant must be an array; otherwise `build()` throws an error.\n */\n in(parameter: string, constant: any) {\n return this.simple(EXPRESSION_TYPE.in, parameter, constant);\n }\n\n /**\n * Completes this group and returns its parent.\n *\n * Call once for the root filter to return to `Query`, and once for each\n * nested group to continue the surrounding chain.\n *\n * @returns The parent query or enclosing filter group.\n */\n done(): QueryType {\n if (this.parent instanceof WhereQuery) {\n this.parent.addComplexExpression(this);\n // TODO: If has and() || or() must call done() twice\n if (this.expression.getType() === EXPRESSION_TYPE.not)\n return this.parent;\n }\n\n return this.parent;\n }\n\n /** Returns the expression tree represented by this filter group. */\n getExpression(): ComplexExpression {\n return this.expression;\n }\n\n private simple(type: string, parameter: string, constant: any, caseSensitive = true): WhereQuery<QueryType> {\n const currentExpr = new BinaryExpression(type, parameter, constant, caseSensitive);\n const subExpressions = this.expression.getExpressions();\n subExpressions.push(currentExpr);\n\n if (this.expression.getType() === EXPRESSION_TYPE.not && subExpressions.length > 1)\n throw new Error(\"Invalid operators count!\");\n\n return this;\n }\n\n private addComplexExpression(subQuery: WhereQuery<QueryType>): void {\n const subExpression = subQuery.getExpression();\n this.expression.getExpressions().push(subExpression);\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;AAgBO,IAAM,aAAN,MAAM,YAAsB;AAAA;AAAA,EAI/B,YAAoB,QAAmB,OAAe,gBAAgB,KAAK;AAAvD;AAChB,SAAK,aAAa,IAAI,kBAAkB,MAAM,CAAC,CAAC;AAAA,EACpD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAyC;AACrC,WAAO,IAAI,YAAW,MAAM,gBAAgB,GAAG;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,KAAwC;AACpC,WAAO,IAAI,YAAW,MAAM,gBAAgB,EAAE;AAAA,EAClD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAyC;AACrC,WAAO,IAAI,YAAW,MAAM,gBAAgB,GAAG;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAyC;AACrC,WAAO,IAAI,YAAW,MAAM,gBAAgB,GAAG;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,GAAG,WAAmB,UAAsC;AACxD,WAAO,KAAK,OAAO,gBAAgB,IAAI,WAAW,QAAQ;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,GAAG,WA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