@ahoo-wang/wow-client 10.0.0-alpha.3 → 10.0.0-alpha.4

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 (420) hide show
  1. package/README.md +85 -230
  2. package/README.zh-CN.md +74 -209
  3. package/dist/commands.cjs +2 -0
  4. package/dist/commands.cjs.map +1 -0
  5. package/dist/{v10/commands.d.cts → commands.d.cts} +21 -3
  6. package/dist/{v10/commands.d.ts → commands.d.ts} +21 -3
  7. package/dist/commands.es.js +96 -0
  8. package/dist/commands.es.js.map +1 -0
  9. package/dist/dsl/aggregation/types.cjs.map +1 -1
  10. package/dist/dsl/aggregation/types.d.cts +1 -1
  11. package/dist/dsl/aggregation/types.d.ts +1 -1
  12. package/dist/dsl/aggregation/types.es.js.map +1 -1
  13. package/dist/dsl/cursorQuery.cjs.map +1 -1
  14. package/dist/dsl/cursorQuery.d.cts +7 -8
  15. package/dist/dsl/cursorQuery.d.ts +7 -8
  16. package/dist/dsl/cursorQuery.es.js.map +1 -1
  17. package/dist/dsl/descriptor.cjs.map +1 -1
  18. package/dist/dsl/descriptor.d.cts +1 -1
  19. package/dist/dsl/descriptor.d.ts +1 -1
  20. package/dist/dsl/descriptor.es.js.map +1 -1
  21. package/dist/dsl/documents.d.cts +1 -1
  22. package/dist/dsl/documents.d.ts +1 -1
  23. package/dist/dsl/filter/types.d.cts +2 -1
  24. package/dist/dsl/filter/types.d.ts +2 -1
  25. package/dist/dsl/projection.cjs.map +1 -1
  26. package/dist/dsl/projection.d.cts +22 -0
  27. package/dist/dsl/projection.d.ts +22 -0
  28. package/dist/dsl/projection.es.js.map +1 -1
  29. package/dist/dsl/queryErrorCodes.cjs +2 -0
  30. package/dist/dsl/queryErrorCodes.cjs.map +1 -0
  31. package/dist/{error → dsl}/queryErrorCodes.d.cts +25 -24
  32. package/dist/{error → dsl}/queryErrorCodes.d.ts +25 -24
  33. package/dist/{error → dsl}/queryErrorCodes.es.js +2 -1
  34. package/dist/{error/queryErrorCodes.cjs.map → dsl/queryErrorCodes.es.js.map} +1 -1
  35. package/dist/dsl.cjs +1 -1
  36. package/dist/dsl.d.cts +1 -2
  37. package/dist/dsl.d.ts +1 -2
  38. package/dist/dsl.es.js +2 -3
  39. package/dist/exactJson.cjs +3 -0
  40. package/dist/exactJson.cjs.map +1 -0
  41. package/dist/exactJson.d.cts +54 -0
  42. package/dist/exactJson.d.ts +54 -0
  43. package/dist/exactJson.es.js +213 -0
  44. package/dist/exactJson.es.js.map +1 -0
  45. package/dist/http.cjs +2 -0
  46. package/dist/http.cjs.map +1 -0
  47. package/dist/{v10/http.d.cts → http.d.cts} +16 -7
  48. package/dist/{v10/http.d.ts → http.d.ts} +16 -7
  49. package/dist/http.es.js +77 -0
  50. package/dist/http.es.js.map +1 -0
  51. package/dist/index.cjs +1 -1
  52. package/dist/index.d.cts +19 -17
  53. package/dist/index.d.ts +19 -17
  54. package/dist/index.es.js +10 -36
  55. package/dist/manifest.cjs.map +1 -0
  56. package/dist/{v10/manifest.es.js → manifest.es.js} +1 -1
  57. package/dist/manifest.es.js.map +1 -0
  58. package/dist/problem.cjs +2 -0
  59. package/dist/problem.cjs.map +1 -0
  60. package/dist/{v10/problem.d.cts → problem.d.cts} +51 -4
  61. package/dist/{v10/problem.d.ts → problem.d.ts} +51 -4
  62. package/dist/{v10/problem.es.js → problem.es.js} +30 -11
  63. package/dist/problem.es.js.map +1 -0
  64. package/dist/queries.cjs +2 -0
  65. package/dist/queries.cjs.map +1 -0
  66. package/dist/{v10/queries.d.cts → queries.d.cts} +63 -17
  67. package/dist/{v10/queries.d.ts → queries.d.ts} +63 -17
  68. package/dist/queries.es.js +112 -0
  69. package/dist/queries.es.js.map +1 -0
  70. package/dist/state.cjs +2 -0
  71. package/dist/state.cjs.map +1 -0
  72. package/dist/{v10/state.d.cts → state.d.cts} +26 -4
  73. package/dist/{v10/state.d.ts → state.d.ts} +26 -4
  74. package/dist/state.es.js +70 -0
  75. package/dist/state.es.js.map +1 -0
  76. package/dist/streams.cjs +2 -0
  77. package/dist/streams.cjs.map +1 -0
  78. package/dist/streams.d.cts +74 -0
  79. package/dist/streams.d.ts +74 -0
  80. package/dist/streams.es.js +103 -0
  81. package/dist/streams.es.js.map +1 -0
  82. package/dist/wait.cjs.map +1 -0
  83. package/dist/{v10/wait.es.js → wait.es.js} +1 -1
  84. package/dist/wait.es.js.map +1 -0
  85. package/dist/wire.cjs.map +1 -0
  86. package/dist/{v10/wire.d.cts → wire.d.cts} +32 -7
  87. package/dist/{v10/wire.d.ts → wire.d.ts} +32 -7
  88. package/dist/{v10/wire.es.js → wire.es.js} +1 -1
  89. package/dist/wire.es.js.map +1 -0
  90. package/package.json +4 -26
  91. package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorate.cjs +0 -1
  92. package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorate.es.js +0 -9
  93. package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorateMetadata.cjs +0 -1
  94. package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorateMetadata.es.js +0 -6
  95. package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorateParam.cjs +0 -1
  96. package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorateParam.es.js +0 -8
  97. package/dist/client/bindMethods.cjs +0 -2
  98. package/dist/client/bindMethods.cjs.map +0 -1
  99. package/dist/client/bindMethods.d.cts +0 -13
  100. package/dist/client/bindMethods.d.ts +0 -13
  101. package/dist/client/bindMethods.es.js +0 -19
  102. package/dist/client/bindMethods.es.js.map +0 -1
  103. package/dist/client/command/commandClient.cjs +0 -2
  104. package/dist/client/command/commandClient.cjs.map +0 -1
  105. package/dist/client/command/commandClient.d.cts +0 -67
  106. package/dist/client/command/commandClient.d.ts +0 -67
  107. package/dist/client/command/commandClient.es.js +0 -38
  108. package/dist/client/command/commandClient.es.js.map +0 -1
  109. package/dist/client/command/commandHeaders.cjs +0 -2
  110. package/dist/client/command/commandHeaders.cjs.map +0 -1
  111. package/dist/client/command/commandHeaders.d.cts +0 -75
  112. package/dist/client/command/commandHeaders.d.ts +0 -75
  113. package/dist/client/command/commandHeaders.es.js +0 -31
  114. package/dist/client/command/commandHeaders.es.js.map +0 -1
  115. package/dist/client/command/commandRequest.cjs +0 -2
  116. package/dist/client/command/commandRequest.cjs.map +0 -1
  117. package/dist/client/command/commandRequest.d.cts +0 -180
  118. package/dist/client/command/commandRequest.d.ts +0 -180
  119. package/dist/client/command/commandRequest.es.js +0 -31
  120. package/dist/client/command/commandRequest.es.js.map +0 -1
  121. package/dist/client/command/commandResult.d.cts +0 -15
  122. package/dist/client/command/commandResult.d.ts +0 -15
  123. package/dist/client/command/index.d.cts +0 -5
  124. package/dist/client/command/index.d.ts +0 -5
  125. package/dist/client/command/types.d.cts +0 -71
  126. package/dist/client/command/types.d.ts +0 -71
  127. package/dist/client/metadata/index.d.cts +0 -2
  128. package/dist/client/metadata/index.d.ts +0 -2
  129. package/dist/client/metadata/wowMetadata.d.cts +0 -48
  130. package/dist/client/metadata/wowMetadata.d.ts +0 -48
  131. package/dist/client/metadata/wowMetadataClient.cjs +0 -2
  132. package/dist/client/metadata/wowMetadataClient.cjs.map +0 -1
  133. package/dist/client/metadata/wowMetadataClient.d.cts +0 -23
  134. package/dist/client/metadata/wowMetadataClient.d.ts +0 -23
  135. package/dist/client/metadata/wowMetadataClient.es.js +0 -25
  136. package/dist/client/metadata/wowMetadataClient.es.js.map +0 -1
  137. package/dist/client/query/dataset/datasetDescriptorEndpoint.cjs +0 -2
  138. package/dist/client/query/dataset/datasetDescriptorEndpoint.cjs.map +0 -1
  139. package/dist/client/query/dataset/datasetDescriptorEndpoint.d.cts +0 -8
  140. package/dist/client/query/dataset/datasetDescriptorEndpoint.d.ts +0 -8
  141. package/dist/client/query/dataset/datasetDescriptorEndpoint.es.js +0 -34
  142. package/dist/client/query/dataset/datasetDescriptorEndpoint.es.js.map +0 -1
  143. package/dist/client/query/dataset/datasetDirectoryClient.cjs +0 -2
  144. package/dist/client/query/dataset/datasetDirectoryClient.cjs.map +0 -1
  145. package/dist/client/query/dataset/datasetDirectoryClient.d.cts +0 -29
  146. package/dist/client/query/dataset/datasetDirectoryClient.d.ts +0 -29
  147. package/dist/client/query/dataset/datasetDirectoryClient.es.js +0 -25
  148. package/dist/client/query/dataset/datasetDirectoryClient.es.js.map +0 -1
  149. package/dist/client/query/dataset/datasetQueryApi.d.cts +0 -40
  150. package/dist/client/query/dataset/datasetQueryApi.d.ts +0 -40
  151. package/dist/client/query/dataset/datasetQueryClient.cjs +0 -2
  152. package/dist/client/query/dataset/datasetQueryClient.cjs.map +0 -1
  153. package/dist/client/query/dataset/datasetQueryClient.d.cts +0 -57
  154. package/dist/client/query/dataset/datasetQueryClient.d.ts +0 -57
  155. package/dist/client/query/dataset/datasetQueryClient.es.js +0 -154
  156. package/dist/client/query/dataset/datasetQueryClient.es.js.map +0 -1
  157. package/dist/client/query/dataset/endpointPaths.cjs +0 -2
  158. package/dist/client/query/dataset/endpointPaths.cjs.map +0 -1
  159. package/dist/client/query/dataset/endpointPaths.d.cts +0 -9
  160. package/dist/client/query/dataset/endpointPaths.d.ts +0 -9
  161. package/dist/client/query/dataset/endpointPaths.es.js +0 -14
  162. package/dist/client/query/dataset/endpointPaths.es.js.map +0 -1
  163. package/dist/client/query/dataset/index.d.cts +0 -3
  164. package/dist/client/query/dataset/index.d.ts +0 -3
  165. package/dist/client/query/descriptor/descriptorEndpoints.cjs +0 -2
  166. package/dist/client/query/descriptor/descriptorEndpoints.cjs.map +0 -1
  167. package/dist/client/query/descriptor/descriptorEndpoints.d.cts +0 -29
  168. package/dist/client/query/descriptor/descriptorEndpoints.d.ts +0 -29
  169. package/dist/client/query/descriptor/descriptorEndpoints.es.js +0 -69
  170. package/dist/client/query/descriptor/descriptorEndpoints.es.js.map +0 -1
  171. package/dist/client/query/descriptor/endpointPaths.cjs +0 -2
  172. package/dist/client/query/descriptor/endpointPaths.cjs.map +0 -1
  173. package/dist/client/query/descriptor/endpointPaths.d.cts +0 -4
  174. package/dist/client/query/descriptor/endpointPaths.d.ts +0 -4
  175. package/dist/client/query/descriptor/endpointPaths.es.js +0 -9
  176. package/dist/client/query/descriptor/endpointPaths.es.js.map +0 -1
  177. package/dist/client/query/descriptor/index.d.cts +0 -2
  178. package/dist/client/query/descriptor/index.d.ts +0 -2
  179. package/dist/client/query/descriptor/queryDescriptorApi.d.cts +0 -58
  180. package/dist/client/query/descriptor/queryDescriptorApi.d.ts +0 -58
  181. package/dist/client/query/descriptor/queryDescriptorClient.cjs +0 -2
  182. package/dist/client/query/descriptor/queryDescriptorClient.cjs.map +0 -1
  183. package/dist/client/query/descriptor/queryDescriptorClient.d.cts +0 -61
  184. package/dist/client/query/descriptor/queryDescriptorClient.d.ts +0 -61
  185. package/dist/client/query/descriptor/queryDescriptorClient.es.js +0 -20
  186. package/dist/client/query/descriptor/queryDescriptorClient.es.js.map +0 -1
  187. package/dist/client/query/event/endpointPaths.cjs +0 -2
  188. package/dist/client/query/event/endpointPaths.cjs.map +0 -1
  189. package/dist/client/query/event/endpointPaths.d.cts +0 -8
  190. package/dist/client/query/event/endpointPaths.d.ts +0 -8
  191. package/dist/client/query/event/endpointPaths.es.js +0 -13
  192. package/dist/client/query/event/endpointPaths.es.js.map +0 -1
  193. package/dist/client/query/event/eventStreamQueryApi.d.cts +0 -29
  194. package/dist/client/query/event/eventStreamQueryApi.d.ts +0 -29
  195. package/dist/client/query/event/eventStreamQueryClient.cjs +0 -2
  196. package/dist/client/query/event/eventStreamQueryClient.cjs.map +0 -1
  197. package/dist/client/query/event/eventStreamQueryClient.d.cts +0 -193
  198. package/dist/client/query/event/eventStreamQueryClient.d.ts +0 -193
  199. package/dist/client/query/event/eventStreamQueryClient.es.js +0 -160
  200. package/dist/client/query/event/eventStreamQueryClient.es.js.map +0 -1
  201. package/dist/client/query/event/index.d.cts +0 -2
  202. package/dist/client/query/event/index.d.ts +0 -2
  203. package/dist/client/query/factory.cjs +0 -2
  204. package/dist/client/query/factory.cjs.map +0 -1
  205. package/dist/client/query/factory.d.cts +0 -165
  206. package/dist/client/query/factory.d.ts +0 -165
  207. package/dist/client/query/factory.es.js +0 -45
  208. package/dist/client/query/factory.es.js.map +0 -1
  209. package/dist/client/query/index.d.cts +0 -7
  210. package/dist/client/query/index.d.ts +0 -7
  211. package/dist/client/query/queryApi.d.cts +0 -68
  212. package/dist/client/query/queryApi.d.ts +0 -68
  213. package/dist/client/query/requests.d.cts +0 -24
  214. package/dist/client/query/requests.d.ts +0 -24
  215. package/dist/client/query/snapshot/endpointPaths.cjs +0 -2
  216. package/dist/client/query/snapshot/endpointPaths.cjs.map +0 -1
  217. package/dist/client/query/snapshot/endpointPaths.d.cts +0 -12
  218. package/dist/client/query/snapshot/endpointPaths.d.ts +0 -12
  219. package/dist/client/query/snapshot/endpointPaths.es.js +0 -17
  220. package/dist/client/query/snapshot/endpointPaths.es.js.map +0 -1
  221. package/dist/client/query/snapshot/index.d.cts +0 -2
  222. package/dist/client/query/snapshot/index.d.ts +0 -2
  223. package/dist/client/query/snapshot/snapshotQueryApi.d.cts +0 -101
  224. package/dist/client/query/snapshot/snapshotQueryApi.d.ts +0 -101
  225. package/dist/client/query/snapshot/snapshotQueryClient.cjs +0 -2
  226. package/dist/client/query/snapshot/snapshotQueryClient.cjs.map +0 -1
  227. package/dist/client/query/snapshot/snapshotQueryClient.d.cts +0 -372
  228. package/dist/client/query/snapshot/snapshotQueryClient.d.ts +0 -372
  229. package/dist/client/query/snapshot/snapshotQueryClient.es.js +0 -239
  230. package/dist/client/query/snapshot/snapshotQueryClient.es.js.map +0 -1
  231. package/dist/client/query/state/endpointPaths.cjs +0 -2
  232. package/dist/client/query/state/endpointPaths.cjs.map +0 -1
  233. package/dist/client/query/state/endpointPaths.d.cts +0 -10
  234. package/dist/client/query/state/endpointPaths.d.ts +0 -10
  235. package/dist/client/query/state/endpointPaths.es.js +0 -14
  236. package/dist/client/query/state/endpointPaths.es.js.map +0 -1
  237. package/dist/client/query/state/index.d.cts +0 -4
  238. package/dist/client/query/state/index.d.ts +0 -4
  239. package/dist/client/query/state/loadOwnerStateAggregateApi.d.cts +0 -36
  240. package/dist/client/query/state/loadOwnerStateAggregateApi.d.ts +0 -36
  241. package/dist/client/query/state/loadOwnerStateAggregateClient.cjs +0 -2
  242. package/dist/client/query/state/loadOwnerStateAggregateClient.cjs.map +0 -1
  243. package/dist/client/query/state/loadOwnerStateAggregateClient.d.cts +0 -58
  244. package/dist/client/query/state/loadOwnerStateAggregateClient.d.ts +0 -58
  245. package/dist/client/query/state/loadOwnerStateAggregateClient.es.js +0 -56
  246. package/dist/client/query/state/loadOwnerStateAggregateClient.es.js.map +0 -1
  247. package/dist/client/query/state/loadStateAggregateApi.d.cts +0 -37
  248. package/dist/client/query/state/loadStateAggregateApi.d.ts +0 -37
  249. package/dist/client/query/state/loadStateAggregateClient.cjs +0 -2
  250. package/dist/client/query/state/loadStateAggregateClient.cjs.map +0 -1
  251. package/dist/client/query/state/loadStateAggregateClient.d.cts +0 -62
  252. package/dist/client/query/state/loadStateAggregateClient.d.ts +0 -62
  253. package/dist/client/query/state/loadStateAggregateClient.es.js +0 -65
  254. package/dist/client/query/state/loadStateAggregateClient.es.js.map +0 -1
  255. package/dist/client/routing.cjs +0 -2
  256. package/dist/client/routing.cjs.map +0 -1
  257. package/dist/client/routing.d.cts +0 -47
  258. package/dist/client/routing.d.ts +0 -47
  259. package/dist/client/routing.es.js +0 -8
  260. package/dist/client/routing.es.js.map +0 -1
  261. package/dist/error/errorInfo.cjs +0 -2
  262. package/dist/error/errorInfo.cjs.map +0 -1
  263. package/dist/error/errorInfo.d.cts +0 -139
  264. package/dist/error/errorInfo.d.ts +0 -139
  265. package/dist/error/errorInfo.es.js +0 -32
  266. package/dist/error/errorInfo.es.js.map +0 -1
  267. package/dist/error/headers.cjs +0 -2
  268. package/dist/error/headers.cjs.map +0 -1
  269. package/dist/error/headers.d.cts +0 -39
  270. package/dist/error/headers.d.ts +0 -39
  271. package/dist/error/headers.es.js +0 -10
  272. package/dist/error/headers.es.js.map +0 -1
  273. package/dist/error/index.d.cts +0 -21
  274. package/dist/error/index.d.ts +0 -21
  275. package/dist/error/queryErrorCodes.cjs +0 -2
  276. package/dist/error/queryErrorCodes.es.js.map +0 -1
  277. package/dist/error/wowError.cjs +0 -2
  278. package/dist/error/wowError.cjs.map +0 -1
  279. package/dist/error/wowError.d.cts +0 -99
  280. package/dist/error/wowError.d.ts +0 -99
  281. package/dist/error/wowError.es.js +0 -53
  282. package/dist/error/wowError.es.js.map +0 -1
  283. package/dist/legacy/condition.cjs +0 -2
  284. package/dist/legacy/condition.cjs.map +0 -1
  285. package/dist/legacy/condition.d.cts +0 -517
  286. package/dist/legacy/condition.d.ts +0 -517
  287. package/dist/legacy/condition.es.js +0 -338
  288. package/dist/legacy/condition.es.js.map +0 -1
  289. package/dist/legacy/index.d.cts +0 -16
  290. package/dist/legacy/index.d.ts +0 -16
  291. package/dist/legacy/locale/en_US.cjs +0 -2
  292. package/dist/legacy/locale/en_US.cjs.map +0 -1
  293. package/dist/legacy/locale/en_US.d.cts +0 -7
  294. package/dist/legacy/locale/en_US.d.ts +0 -7
  295. package/dist/legacy/locale/en_US.es.js +0 -50
  296. package/dist/legacy/locale/en_US.es.js.map +0 -1
  297. package/dist/legacy/locale/operatorLocale.d.cts +0 -10
  298. package/dist/legacy/locale/operatorLocale.d.ts +0 -10
  299. package/dist/legacy/locale/zh_CN.cjs +0 -2
  300. package/dist/legacy/locale/zh_CN.cjs.map +0 -1
  301. package/dist/legacy/locale/zh_CN.d.cts +0 -7
  302. package/dist/legacy/locale/zh_CN.d.ts +0 -7
  303. package/dist/legacy/locale/zh_CN.es.js +0 -50
  304. package/dist/legacy/locale/zh_CN.es.js.map +0 -1
  305. package/dist/legacy/operator.cjs +0 -2
  306. package/dist/legacy/operator.cjs.map +0 -1
  307. package/dist/legacy/operator.d.cts +0 -218
  308. package/dist/legacy/operator.d.ts +0 -218
  309. package/dist/legacy/operator.es.js +0 -25
  310. package/dist/legacy/operator.es.js.map +0 -1
  311. package/dist/legacy/queryable.cjs +0 -2
  312. package/dist/legacy/queryable.cjs.map +0 -1
  313. package/dist/legacy/queryable.d.cts +0 -61
  314. package/dist/legacy/queryable.d.ts +0 -61
  315. package/dist/legacy/queryable.es.js +0 -34
  316. package/dist/legacy/queryable.es.js.map +0 -1
  317. package/dist/legacy.cjs +0 -1
  318. package/dist/legacy.es.js +0 -6
  319. package/dist/model/abac.cjs +0 -2
  320. package/dist/model/abac.cjs.map +0 -1
  321. package/dist/model/abac.d.cts +0 -33
  322. package/dist/model/abac.d.ts +0 -33
  323. package/dist/model/abac.es.js +0 -6
  324. package/dist/model/abac.es.js.map +0 -1
  325. package/dist/model/bi.cjs +0 -2
  326. package/dist/model/bi.cjs.map +0 -1
  327. package/dist/model/bi.d.cts +0 -12
  328. package/dist/model/bi.d.ts +0 -12
  329. package/dist/model/bi.es.js +0 -8
  330. package/dist/model/bi.es.js.map +0 -1
  331. package/dist/model/command.cjs +0 -2
  332. package/dist/model/command.cjs.map +0 -1
  333. package/dist/model/command.d.cts +0 -137
  334. package/dist/model/command.d.ts +0 -137
  335. package/dist/model/command.es.js +0 -8
  336. package/dist/model/command.es.js.map +0 -1
  337. package/dist/model/common.d.cts +0 -19
  338. package/dist/model/common.d.ts +0 -19
  339. package/dist/model/domainEventStream.cjs +0 -2
  340. package/dist/model/domainEventStream.cjs.map +0 -1
  341. package/dist/model/domainEventStream.d.cts +0 -109
  342. package/dist/model/domainEventStream.d.ts +0 -109
  343. package/dist/model/domainEventStream.es.js +0 -23
  344. package/dist/model/domainEventStream.es.js.map +0 -1
  345. package/dist/model/function.cjs +0 -2
  346. package/dist/model/function.cjs.map +0 -1
  347. package/dist/model/function.d.cts +0 -41
  348. package/dist/model/function.d.ts +0 -41
  349. package/dist/model/function.es.js +0 -8
  350. package/dist/model/function.es.js.map +0 -1
  351. package/dist/model/index.d.cts +0 -24
  352. package/dist/model/index.d.ts +0 -24
  353. package/dist/model/messaging.d.cts +0 -5
  354. package/dist/model/messaging.d.ts +0 -5
  355. package/dist/model/modeling.d.cts +0 -145
  356. package/dist/model/modeling.d.ts +0 -145
  357. package/dist/model/naming.d.cts +0 -27
  358. package/dist/model/naming.d.ts +0 -27
  359. package/dist/model/snapshot.cjs +0 -2
  360. package/dist/model/snapshot.cjs.map +0 -1
  361. package/dist/model/snapshot.d.cts +0 -53
  362. package/dist/model/snapshot.d.ts +0 -53
  363. package/dist/model/snapshot.es.js +0 -20
  364. package/dist/model/snapshot.es.js.map +0 -1
  365. package/dist/transport/endpoints.cjs +0 -2
  366. package/dist/transport/endpoints.cjs.map +0 -1
  367. package/dist/transport/endpoints.d.cts +0 -79
  368. package/dist/transport/endpoints.d.ts +0 -79
  369. package/dist/transport/endpoints.es.js +0 -14
  370. package/dist/transport/endpoints.es.js.map +0 -1
  371. package/dist/transport/eventStreams.cjs +0 -2
  372. package/dist/transport/eventStreams.cjs.map +0 -1
  373. package/dist/transport/eventStreams.d.cts +0 -25
  374. package/dist/transport/eventStreams.d.ts +0 -25
  375. package/dist/transport/eventStreams.es.js +0 -21
  376. package/dist/transport/eventStreams.es.js.map +0 -1
  377. package/dist/transport/index.d.cts +0 -1
  378. package/dist/transport/index.d.ts +0 -1
  379. package/dist/v10/commands.cjs +0 -2
  380. package/dist/v10/commands.cjs.map +0 -1
  381. package/dist/v10/commands.es.js +0 -68
  382. package/dist/v10/commands.es.js.map +0 -1
  383. package/dist/v10/http.cjs +0 -2
  384. package/dist/v10/http.cjs.map +0 -1
  385. package/dist/v10/http.es.js +0 -73
  386. package/dist/v10/http.es.js.map +0 -1
  387. package/dist/v10/index.d.cts +0 -19
  388. package/dist/v10/index.d.ts +0 -19
  389. package/dist/v10/manifest.cjs.map +0 -1
  390. package/dist/v10/manifest.es.js.map +0 -1
  391. package/dist/v10/problem.cjs +0 -2
  392. package/dist/v10/problem.cjs.map +0 -1
  393. package/dist/v10/problem.es.js.map +0 -1
  394. package/dist/v10/queries.cjs +0 -2
  395. package/dist/v10/queries.cjs.map +0 -1
  396. package/dist/v10/queries.es.js +0 -88
  397. package/dist/v10/queries.es.js.map +0 -1
  398. package/dist/v10/state.cjs +0 -2
  399. package/dist/v10/state.cjs.map +0 -1
  400. package/dist/v10/state.es.js +0 -51
  401. package/dist/v10/state.es.js.map +0 -1
  402. package/dist/v10/streams.cjs +0 -2
  403. package/dist/v10/streams.cjs.map +0 -1
  404. package/dist/v10/streams.d.cts +0 -14
  405. package/dist/v10/streams.d.ts +0 -14
  406. package/dist/v10/streams.es.js +0 -22
  407. package/dist/v10/streams.es.js.map +0 -1
  408. package/dist/v10/wait.cjs.map +0 -1
  409. package/dist/v10/wait.es.js.map +0 -1
  410. package/dist/v10/wire.cjs.map +0 -1
  411. package/dist/v10/wire.es.js.map +0 -1
  412. package/dist/v10.cjs +0 -1
  413. package/dist/v10.es.js +0 -9
  414. /package/dist/{v10/manifest.cjs → manifest.cjs} +0 -0
  415. /package/dist/{v10/manifest.d.cts → manifest.d.cts} +0 -0
  416. /package/dist/{v10/manifest.d.ts → manifest.d.ts} +0 -0
  417. /package/dist/{v10/wait.cjs → wait.cjs} +0 -0
  418. /package/dist/{v10/wait.d.cts → wait.d.cts} +0 -0
  419. /package/dist/{v10/wait.d.ts → wait.d.ts} +0 -0
  420. /package/dist/{v10/wire.cjs → wire.cjs} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exactJson.es.js","names":["BY","textNumbersBy","marksNothing","marks","Captured","text","child","name","define","key","target","value","resolve","index","object","by","discriminant","marksOf","Code","ESCAPES","Parser","capture","next","array","items","start","code","escape","hex","unescaped","first","exponent","sign","word","at","parseJson","JSON_NUMBER","stringifyJson","numbers","prefix","replaced","replace","placeholder","item","copy","eventNumbers","events","type"],"sources":["../src/exactJson.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { AggregateType } from './wire.js';\n\n/**\n * Which numbers of a JSON value a client reads and writes as their exact\n * text (review R4-Q, Q-9; decision D254): an `int64`, `bigint` or `decimal`\n * field of a Manifest, which JavaScript's `number` would round. The wire\n * keeps JSON numbers (decision D122); such a field is a `string` in the\n * generated types, its digits exactly as the server wrote them.\n *\n * - `true`: this value is such a number.\n * - An object: the marks of its members by name, `'*'` for every item of an\n * array and every value of a map.\n * - {@link textNumbersBy}: the marks of one member chosen by a sibling's\n * value, such as an event's `body` by its `name`.\n */\nexport type TextNumbers =\n true | TextNumbersByName | { readonly [member: string]: TextNumbers };\n\n/** The key of a {@link TextNumbersByName}: a symbol, so no member name is mistaken for it. */\nconst BY: unique symbol = Symbol('wow.textNumbersBy');\n\n/** The marks of one member of an object chosen by the value of another. */\nexport interface TextNumbersByName {\n readonly [BY]: {\n readonly discriminant: string;\n readonly member: string;\n readonly cases: Readonly<Record<string, TextNumbers>>;\n };\n}\n\n/**\n * The marks of `member` chosen by the string value of `discriminant`, its\n * sibling: `textNumbersBy('name', 'body', { 'shop.cart.ItemAdded': { price:\n * true } })` reads an event's body by the event's name.\n */\nexport function textNumbersBy(\n discriminant: string,\n member: string,\n cases: Readonly<Record<string, TextNumbers>>,\n): TextNumbersByName {\n return { [BY]: { discriminant, member, cases } };\n}\n\n/** Whether `marks` marks nothing, so plain `JSON.parse` reads the value. */\nexport function marksNothing(marks: TextNumbers | undefined): boolean {\n if (marks === undefined) return true;\n if (marks === true) return false;\n if (BY in marks) {\n return Object.values(marks[BY].cases).every(marksNothing);\n }\n return Object.values(marks).every(marksNothing);\n}\n\n/** A number of a captured member, kept as its text until its marks are known. */\nclass Captured {\n constructor(readonly text: string) {}\n}\n\n/** The marks of a member or item of a value marked `marks`. */\nfunction child(\n marks: TextNumbers | undefined,\n name: string,\n): TextNumbers | undefined {\n if (marks === undefined || marks === true || BY in marks) return undefined;\n return Object.prototype.hasOwnProperty.call(marks, name)\n ? marks[name]\n : Object.prototype.hasOwnProperty.call(marks, '*')\n ? marks['*']\n : undefined;\n}\n\n/** Sets a member as `JSON.parse` does: an own data property, `__proto__` too. */\nfunction define(target: Record<string, unknown>, key: string, value: unknown) {\n if (key === '__proto__') {\n Object.defineProperty(target, key, {\n value,\n writable: true,\n enumerable: true,\n configurable: true,\n });\n } else {\n target[key] = value;\n }\n}\n\n/** Resolves the numbers of a captured value against its now known marks. */\nfunction resolve(value: unknown, marks: TextNumbers | undefined): unknown {\n if (value instanceof Captured) {\n return marks === true ? value.text : Number(value.text);\n }\n if (Array.isArray(value)) {\n for (let index = 0; index < value.length; index++) {\n value[index] = resolve(value[index], child(marks, String(index)));\n }\n return value;\n }\n if (value !== null && typeof value === 'object') {\n const object = value as Record<string, unknown>;\n const by =\n marks !== undefined && marks !== true && BY in marks\n ? marks[BY]\n : undefined;\n const discriminant = by === undefined ? undefined : object[by.discriminant];\n for (const key of Object.keys(object)) {\n const marksOf =\n by === undefined\n ? child(marks, key)\n : key === by.member && typeof discriminant === 'string'\n ? by.cases[discriminant]\n : undefined;\n define(object, key, resolve(object[key], marksOf));\n }\n }\n return value;\n}\n\nconst Code = {\n TAB: 0x09,\n LF: 0x0a,\n CR: 0x0d,\n SPACE: 0x20,\n QUOTE: 0x22,\n PLUS: 0x2b,\n COMMA: 0x2c,\n MINUS: 0x2d,\n DOT: 0x2e,\n ZERO: 0x30,\n NINE: 0x39,\n COLON: 0x3a,\n UPPER_E: 0x45,\n OPEN_BRACKET: 0x5b,\n BACKSLASH: 0x5c,\n CLOSE_BRACKET: 0x5d,\n LOWER_E: 0x65,\n OPEN_BRACE: 0x7b,\n CLOSE_BRACE: 0x7d,\n} as const;\n\nconst ESCAPES: Readonly<Record<string, string>> = {\n '\"': '\"',\n '\\\\': '\\\\',\n '/': '/',\n b: '\\b',\n f: '\\f',\n n: '\\n',\n r: '\\r',\n t: '\\t',\n};\n\n/** A JSON text read as `JSON.parse` reads it, but for the numbers `marks` marks. */\nclass Parser {\n private at = 0;\n\n constructor(private readonly text: string) {}\n\n parse(marks: TextNumbers | undefined): unknown {\n this.skipSpaces();\n const value = this.value(marks, false);\n this.skipSpaces();\n if (this.at < this.text.length) this.fail();\n return value;\n }\n\n /** A value; `capture` keeps its numbers as {@link Captured} text. */\n private value(marks: TextNumbers | undefined, capture: boolean): unknown {\n const code = this.text.charCodeAt(this.at);\n switch (code) {\n case Code.OPEN_BRACE:\n return this.object(marks, capture);\n case Code.OPEN_BRACKET:\n return this.array(marks, capture);\n case Code.QUOTE:\n return this.string();\n case 0x74: // t\n return this.literal('true', true);\n case 0x66: // f\n return this.literal('false', false);\n case 0x6e: // n\n return this.literal('null', null);\n default: {\n const text = this.number();\n if (capture) return new Captured(text);\n return marks === true ? text : Number(text);\n }\n }\n }\n\n private object(marks: TextNumbers | undefined, capture: boolean): unknown {\n this.at++;\n const object: Record<string, unknown> = {};\n const by =\n !capture && marks !== undefined && marks !== true && BY in marks\n ? marks[BY]\n : undefined;\n this.skipSpaces();\n if (this.text.charCodeAt(this.at) === Code.CLOSE_BRACE) {\n this.at++;\n return object;\n }\n for (;;) {\n if (this.text.charCodeAt(this.at) !== Code.QUOTE) this.fail();\n const key = this.string();\n this.skipSpaces();\n this.expect(Code.COLON);\n this.skipSpaces();\n const member =\n by !== undefined && key === by.member\n ? this.value(undefined, true)\n : this.value(capture ? undefined : child(marks, key), capture);\n define(object, key, member);\n this.skipSpaces();\n const next = this.text.charCodeAt(this.at++);\n if (next === Code.CLOSE_BRACE) break;\n if (next !== Code.COMMA) this.fail(this.at - 1);\n this.skipSpaces();\n }\n if (\n by !== undefined &&\n Object.prototype.hasOwnProperty.call(object, by.member)\n ) {\n const discriminant = object[by.discriminant];\n define(\n object,\n by.member,\n resolve(\n object[by.member],\n typeof discriminant === 'string' ? by.cases[discriminant] : undefined,\n ),\n );\n }\n return object;\n }\n\n private array(marks: TextNumbers | undefined, capture: boolean): unknown[] {\n this.at++;\n const array: unknown[] = [];\n this.skipSpaces();\n if (this.text.charCodeAt(this.at) === Code.CLOSE_BRACKET) {\n this.at++;\n return array;\n }\n const items = capture ? undefined : child(marks, '*');\n for (;;) {\n array.push(this.value(items, capture));\n this.skipSpaces();\n const next = this.text.charCodeAt(this.at++);\n if (next === Code.CLOSE_BRACKET) return array;\n if (next !== Code.COMMA) this.fail(this.at - 1);\n this.skipSpaces();\n }\n }\n\n private string(): string {\n const text = this.text;\n let start = ++this.at;\n let value = '';\n for (;;) {\n const code = text.charCodeAt(this.at);\n if (code === Code.QUOTE) {\n value += text.slice(start, this.at++);\n return value;\n }\n if (code === Code.BACKSLASH) {\n value += text.slice(start, this.at);\n const escape = text[this.at + 1];\n if (escape === 'u') {\n const hex = text.slice(this.at + 2, this.at + 6);\n if (!/^[0-9a-fA-F]{4}$/.test(hex)) this.fail(this.at);\n value += String.fromCharCode(Number.parseInt(hex, 16));\n this.at += 6;\n } else {\n const unescaped = escape === undefined ? undefined : ESCAPES[escape];\n if (unescaped === undefined) this.fail(this.at);\n value += unescaped;\n this.at += 2;\n }\n start = this.at;\n } else if (code < Code.SPACE || Number.isNaN(code)) {\n this.fail();\n } else {\n this.at++;\n }\n }\n }\n\n /** The text of a number, checked against JSON's grammar. */\n private number(): string {\n const text = this.text;\n const start = this.at;\n if (text.charCodeAt(this.at) === Code.MINUS) this.at++;\n const first = text.charCodeAt(this.at);\n if (first === Code.ZERO) {\n this.at++;\n } else if (first > Code.ZERO && first <= Code.NINE) {\n this.digits();\n } else {\n this.fail();\n }\n if (text.charCodeAt(this.at) === Code.DOT) {\n this.at++;\n if (!this.digits()) this.fail();\n }\n const exponent = text.charCodeAt(this.at);\n if (exponent === Code.LOWER_E || exponent === Code.UPPER_E) {\n this.at++;\n const sign = text.charCodeAt(this.at);\n if (sign === Code.PLUS || sign === Code.MINUS) this.at++;\n if (!this.digits()) this.fail();\n }\n return text.slice(start, this.at);\n }\n\n /** Skips digits; whether there was one. */\n private digits(): boolean {\n const start = this.at;\n let code = this.text.charCodeAt(this.at);\n while (code >= Code.ZERO && code <= Code.NINE) {\n code = this.text.charCodeAt(++this.at);\n }\n return this.at > start;\n }\n\n private literal<T>(word: string, value: T): T {\n if (!this.text.startsWith(word, this.at)) this.fail();\n this.at += word.length;\n return value;\n }\n\n private skipSpaces(): void {\n let code = this.text.charCodeAt(this.at);\n while (\n code === Code.SPACE ||\n code === Code.LF ||\n code === Code.CR ||\n code === Code.TAB\n ) {\n code = this.text.charCodeAt(++this.at);\n }\n }\n\n private expect(code: number): void {\n if (this.text.charCodeAt(this.at) !== code) this.fail();\n this.at++;\n }\n\n private fail(at: number = this.at): never {\n throw new SyntaxError(\n at >= this.text.length\n ? 'Unexpected end of JSON input'\n : `Unexpected token in JSON at position ${at}`,\n );\n }\n}\n\n/**\n * `text` read as `JSON.parse` reads it, but each number `marks` marks comes\n * back as its exact text, a string (review R4-Q, Q-9). Without marks it is\n * `JSON.parse` itself. Malformed text throws a `SyntaxError`.\n */\nexport function parseJson(text: string, marks?: TextNumbers): unknown {\n if (marksNothing(marks)) return JSON.parse(text);\n return new Parser(text).parse(marks);\n}\n\n/** JSON's number grammar. */\nconst JSON_NUMBER = /^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$/;\n\n/**\n * `value` written as `JSON.stringify` writes it, but each string `marks`\n * marks goes on the wire as the JSON number it spells, unquoted (decision\n * D122): `{\"price\": \"19.99\"}` marked `{price: true}` is `{\"price\":19.99}`.\n * A marked string that is not a JSON number is a `TypeError`.\n */\nexport function stringifyJson(value: unknown, marks?: TextNumbers): string {\n if (marksNothing(marks)) return JSON.stringify(value);\n const numbers: string[] = [];\n // A NUL and a fresh nonce: no string of the value is the placeholder.\n const prefix = `\\u0000wow-number-${Math.random().toString(36).slice(2)}:`;\n const replaced = replace(value, marks, numbers, prefix);\n const text = JSON.stringify(replaced);\n if (numbers.length === 0) return text;\n const placeholder = new RegExp(\n `\"${JSON.stringify(prefix).slice(1, -1).replace(/\\\\/g, '\\\\\\\\')}(\\\\d+)\"`,\n 'g',\n );\n return text.replace(\n placeholder,\n (_, index: string) => numbers[Number(index)]!,\n );\n}\n\n/**\n * A copy of `value` along the marked paths, each marked string replaced by a\n * placeholder of its number; everything else shared.\n */\nfunction replace(\n value: unknown,\n marks: TextNumbers | undefined,\n numbers: string[],\n prefix: string,\n): unknown {\n if (marks === undefined || value === null || value === undefined) {\n return value;\n }\n if (marks === true) {\n if (typeof value !== 'string') return value;\n if (!JSON_NUMBER.test(value)) {\n throw new TypeError(`Not a JSON number: [${value}].`);\n }\n numbers.push(value);\n return `${prefix}${numbers.length - 1}`;\n }\n if (Array.isArray(value)) {\n return value.map((item, index) =>\n replace(item, child(marks, String(index)), numbers, prefix),\n );\n }\n if (typeof value !== 'object') return value;\n const object = value as Record<string, unknown>;\n // `JSON.stringify` writes what `toJSON` returns (a `Date`, say): not a path.\n if (typeof object.toJSON === 'function') return value;\n const by = BY in marks ? marks[BY] : undefined;\n const discriminant = by === undefined ? undefined : object[by.discriminant];\n const copy: Record<string, unknown> = {};\n for (const key of Object.keys(object)) {\n const marksOf =\n by === undefined\n ? child(marks, key)\n : key === by.member && typeof discriminant === 'string'\n ? by.cases[discriminant]\n : undefined;\n define(copy, key, replace(object[key], marksOf, numbers, prefix));\n }\n return copy;\n}\n\n/**\n * The exact numbers ({@link TextNumbers}) of an aggregate type's events: each\n * event's `body` by its `name`.\n */\nexport function eventNumbers(type: AggregateType): TextNumbers | undefined {\n const events = type.textNumbers?.events;\n return events === undefined\n ? undefined\n : textNumbersBy('name', 'body', events);\n}\n"],"mappings":";AAgCA,IAAMA,IA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U,OAAOA;EACtC,IAAI,CAACyB,EAAY,KAAKzB,CAAK,GACzB,MAAU,UAAU,uBAAuBA,EAAM,GAAG;EAGtD,OADA2B,EAAQ,KAAK3B,CAAK,GACX,GAAG4B,IAASD,EAAQ,SAAS;CACtC;CACA,IAAI,MAAM,QAAQ3B,CAAK,GACrB,OAAOA,EAAM,KAAK,GAAM,MACtB8B,EAAQE,GAAMrC,EAAMH,GAAO,OAAOU,CAAK,CAAC,GAAGyB,GAASC,CAAM,CAC5D;CAEF,IAAI,OAAO5B,KAAU,UAAU,OAAOA;CACtC,IAAMG,IAASH;CAEf,IAAI,OAAOG,EAAO,UAAW,YAAY,OAAOH;CAChD,IAAMI,IAAKf,KAAMG,IAAQA,EAAMH,KAAM,KAAA,GAC/BgB,IAAeD,MAAO,KAAA,IAAY,KAAA,IAAYD,EAAOC,EAAG,eACxD6B,IAAgC,CAAC;CACvC,KAAK,IAAMnC,KAAO,OAAO,KAAKK,CAAM,GAAG;EACrC,IAAMG,IACJF,MAAO,KAAA,IACHT,EAAMH,GAAOM,CAAG,IAChBA,MAAQM,EAAG,UAAU,OAAOC,KAAiB,WAC3CD,EAAG,MAAMC,KACT,KAAA;EACR,EAAO4B,GAAMnC,GAAKgC,EAAQ3B,EAAOL,IAAMQ,GAASqB,GAASC,CAAM,CAAC;CAClE;CACA,OAAOK;AACT;AAMA,SAAgBC,EAAa,GAA8C;CACzE,IAAMC,IAASC,EAAK,aAAa;CACjC,OAAOD,MAAW,KAAA,IACd,KAAA,IACA7C,EAAc,QAAQ,QAAQ6C,CAAM;AAC1C"}
package/dist/http.cjs ADDED
@@ -0,0 +1,2 @@
1
+ const e=require("./exactJson.cjs"),t=require("./problem.cjs");let n=require("@ahoo-wang/fetcher");var r={REQUEST_ID:`Wow-Request-Id`,WAIT:`Wow-Wait`,WAIT_TIMEOUT:`Wow-Wait-Timeout`,SCOPE:`Wow-Scope`,SPACE:`Wow-Space`,IF_MATCH:`If-Match`,IF_NONE_MATCH:`If-None-Match`,ETAG:`ETag`,RETRY_AFTER:`Retry-After`,LAST_EVENT_ID:`Last-Event-ID`};function i(e){return`"${e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`)}"`}function a(e){let t=[e.tenantId===void 0?void 0:`tenant=${i(e.tenantId)}`,e.ownerId===void 0?void 0:`owner=${i(e.ownerId)}`,e.spaceId===void 0?void 0:`space=${i(e.spaceId)}`].filter(e=>e!==void 0);if(t.length===0)throw TypeError(`Wow-Scope names a tenant, an owner or a space.`);return t.join(`, `)}function o(e,t){return e.replace(/\{([^}]+)\}/g,(n,r)=>{let i=t[r];if(i===void 0||i===``)throw TypeError(`The path ${e} needs ${r}.`);return encodeURIComponent(i)})}function s(e){if(!e)return``;let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r!==void 0&&t.append(n,String(r));let n=t.toString();return n?`?${n}`:``}async function c(i,o){let c=o.options??{},l={};for(let[e,t]of Object.entries({...o.headers,...c.scope===void 0?{}:{[r.SCOPE]:a(c.scope)},...c.space===void 0?{}:{[r.SPACE]:c.space},...c.headers}))t!==void 0&&(l[e]=t);let u=o.body!==void 0&&!e.marksNothing(o.bodyNumbers);u&&(l[`Content-Type`]=`application/json`);let d=`${i.basePath??``}${o.path}${s(o.query)}`;try{return await(i.fetcher??n.fetcher).fetch(d,{method:o.method,headers:l,...o.body===void 0?{}:{body:u?e.stringifyJson(o.body,o.bodyNumbers):o.body},...c.signal===void 0?{}:{signal:c.signal}})}catch(e){let n=e?.exchange?.response;if(o.notModified&&n?.status===304)return n;throw await t.toWowProblemError(e)??e}}async function l(t,n){return e.marksNothing(n)?await t.json():e.parseJson(await t.text(),n)}function u(e){let t=e.headers.get(r.ETAG);return t===null?void 0:t.replace(/^W\//,``).replace(/"/g,``)}exports.WowHeaders=r,exports.entityTag=u,exports.expandPath=o,exports.formatScope=a,exports.json=l,exports.send=c;
2
+ //# sourceMappingURL=http.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.cjs","names":["marksNothing","defaultFetcher","stringifyJson","toWowProblemError","parseJson","require_exactJson","require_problem","_ahoo_wang_fetcher","WowHeaders","quote","value","formatScope","members","scope","member","expandPath","path","params","name","queryString","query","text","send","options","call","headers","exact","url","client","error","response","json","numbers","entityTag","tag"],"sources":["../src/http.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type Fetcher, fetcher as defaultFetcher } from '@ahoo-wang/fetcher';\nimport {\n marksNothing,\n parseJson,\n stringifyJson,\n type TextNumbers,\n} from './exactJson.js';\nimport { toWowProblemError } from './problem.js';\n\n/**\n * The request headers of a Wow service's public port (decisions D95,\n * D96, D98, D99).\n */\nexport const WowHeaders = {\n /** The caller's id of the request: a retry with the same one is deduplicated. */\n REQUEST_ID: 'Wow-Request-Id',\n /** The wait plan (decision D99). */\n WAIT: 'Wow-Wait',\n /** How long to wait: `500ms`, `10s` or an ISO-8601 duration. */\n WAIT_TIMEOUT: 'Wow-Wait-Timeout',\n /** The scope to act in, for a caller allowed to act across scopes (decision D95). */\n SCOPE: 'Wow-Scope',\n /** The space, among the caller's own, to act in (decision D96). */\n SPACE: 'Wow-Space',\n /** The expected version of the aggregate, as an entity tag. */\n IF_MATCH: 'If-Match',\n /** The version, or descriptor version, a read already holds. */\n IF_NONE_MATCH: 'If-None-Match',\n /** The version of a state read, or of a query descriptor. */\n ETAG: 'ETag',\n /** The seconds after which a failed request may be retried. */\n RETRY_AFTER: 'Retry-After',\n /** The position a streamed list resumes after (decision D253). */\n LAST_EVENT_ID: 'Last-Event-ID',\n} as const;\n\n/** How a client reaches its service. */\nexport interface WowClientOptions {\n /**\n * The fetcher requests go through, with its base URL and interceptors\n * (authentication, say); the default fetcher when absent.\n */\n readonly fetcher?: Fetcher;\n /** A path put before every route, such as a gateway's prefix. */\n readonly basePath?: string;\n}\n\n/**\n * The scope a caller allowed to act across scopes acts in: the `Wow-Scope`\n * header (decision D95).\n */\nexport interface TargetScope {\n readonly tenantId?: string;\n readonly ownerId?: string;\n readonly spaceId?: string;\n}\n\nfunction quote(value: string): string {\n return `\"${value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')}\"`;\n}\n\n/**\n * A target scope as the `Wow-Scope` header spells it, an RFC 8941\n * dictionary: `tenant=\"t1\", owner=\"u1\", space=\"s1\"`.\n *\n * @param scope - The scope; at least one of its members is set\n */\nexport function formatScope(scope: TargetScope): string {\n const members = [\n scope.tenantId === undefined\n ? undefined\n : `tenant=${quote(scope.tenantId)}`,\n scope.ownerId === undefined ? undefined : `owner=${quote(scope.ownerId)}`,\n scope.spaceId === undefined ? undefined : `space=${quote(scope.spaceId)}`,\n ].filter(member => member !== undefined);\n if (members.length === 0) {\n throw new TypeError('Wow-Scope names a tenant, an owner or a space.');\n }\n return members.join(', ');\n}\n\n/** What every request may carry beside its own parameters. */\nexport interface RequestOptions {\n /** The scope to act in (`Wow-Scope`), for a caller allowed to. */\n readonly scope?: TargetScope;\n /** The space to act in (`Wow-Space`), among the caller's own. */\n readonly space?: string;\n /** More headers: the request facts the service records, say. */\n readonly headers?: Readonly<Record<string, string>>;\n /** Cancels the request. */\n readonly signal?: AbortSignal;\n}\n\n/** One request of a client. */\nexport interface Call {\n readonly method: 'GET' | 'POST' | 'DELETE';\n readonly path: string;\n readonly query?: Readonly<Record<string, string | number | undefined>>;\n readonly headers?: Readonly<Record<string, string | undefined>>;\n readonly body?: unknown;\n /** The body's numbers written as their exact text ({@link TextNumbers}). */\n readonly bodyNumbers?: TextNumbers;\n readonly options?: RequestOptions;\n /** Answers a 304 rather than rejecting with it. */\n readonly notModified?: boolean;\n}\n\n/** `{name}` segments of `path` filled from `params`, each encoded. */\nexport function expandPath(\n path: string,\n params: Readonly<Record<string, string>>,\n): string {\n return path.replace(/\\{([^}]+)\\}/g, (segment, name: string) => {\n const value = params[name];\n if (value === undefined || value === '') {\n throw new TypeError(`The path ${path} needs ${name}.`);\n }\n return encodeURIComponent(value);\n });\n}\n\nfunction queryString(\n query: Readonly<Record<string, string | number | undefined>> | undefined,\n): string {\n if (!query) return '';\n const params = new URLSearchParams();\n for (const [name, value] of Object.entries(query)) {\n if (value !== undefined) params.append(name, String(value));\n }\n const text = params.toString();\n return text ? `?${text}` : '';\n}\n\n/**\n * Sends one request through the client's fetcher and answers its response;\n * a response that is not 2xx rejects with a {@link WowProblemError}.\n *\n * @param client - The client's options\n * @param call - The request\n */\nexport async function send(\n client: WowClientOptions,\n call: Call,\n): Promise<Response> {\n const options = call.options ?? {};\n const headers: Record<string, string> = {};\n for (const [name, value] of Object.entries({\n ...call.headers,\n ...(options.scope === undefined\n ? {}\n : { [WowHeaders.SCOPE]: formatScope(options.scope) }),\n ...(options.space === undefined\n ? {}\n : { [WowHeaders.SPACE]: options.space }),\n ...options.headers,\n })) {\n if (value !== undefined) headers[name] = value;\n }\n // A body with exact numbers goes as its own JSON text, those numbers unquoted.\n const exact = call.body !== undefined && !marksNothing(call.bodyNumbers);\n if (exact) headers['Content-Type'] = 'application/json';\n const url = `${client.basePath ?? ''}${call.path}${queryString(call.query)}`;\n try {\n return await (client.fetcher ?? defaultFetcher).fetch(url, {\n method: call.method,\n headers,\n ...(call.body === undefined\n ? {}\n : {\n body: exact\n ? stringifyJson(call.body, call.bodyNumbers)\n : (call.body as object),\n }),\n ...(options.signal === undefined ? {} : { signal: options.signal }),\n });\n } catch (error) {\n const response = (error as { exchange?: { response?: Response } })?.exchange\n ?.response;\n if (call.notModified && response?.status === 304) return response;\n throw (await toWowProblemError(error)) ?? error;\n }\n}\n\n/**\n * The JSON body of a 2xx response; the numbers `numbers` marks come back as\n * their exact text (review R4-Q, Q-9), and without marks it is\n * `response.json()` itself.\n */\nexport async function json<T>(\n response: Response,\n numbers?: TextNumbers,\n): Promise<T> {\n if (marksNothing(numbers)) return (await response.json()) as T;\n return parseJson(await response.text(), numbers) as T;\n}\n\n/** The entity tag of a response without its quotes or weak marker. */\nexport function entityTag(response: Response): string | undefined {\n const tag = response.headers.get(WowHeaders.ETAG);\n return tag === null ? undefined : tag.replace(/^W\\//, '').replace(/\"/g, '');\n}\n"],"mappings":"kGA0BA,IAAaQ,EAAa,CAExB,WAAY,iBAEZ,KAAM,WAEN,aAAc,mBAEd,MAAO,YAEP,MAAO,YAEP,SAAU,WAEV,cAAe,gBAEf,KAAM,OAEN,YAAa,cAEb,cAAe,eACjB,EAuBA,SAASC,EAAM,EAAuB,CACpC,MAAO,IAAIC,EAAM,QAAQ,MAAO,MAAM,CAAC,CAAC,QAAQ,KAAM,KAAK,EAAE,EAC/D,CAQA,SAAgBC,EAAY,EAA4B,CACtD,IAAMC,EAAU,CACdC,EAAM,WAAa,IAAA,GACf,IAAA,GACA,UAAUJ,EAAMI,EAAM,QAAQ,IAClCA,EAAM,UAAY,IAAA,GAAY,IAAA,GAAY,SAASJ,EAAMI,EAAM,OAAO,IACtEA,EAAM,UAAY,IAAA,GAAY,IAAA,GAAY,SAASJ,EAAMI,EAAM,OAAO,GACxE,CAAC,CAAC,OAAO,GAAUC,IAAW,IAAA,EAAS,EACvC,GAAIF,EAAQ,SAAW,EACrB,MAAU,UAAU,gDAAgD,EAEtE,OAAOA,EAAQ,KAAK,IAAI,CAC1B,CA6BA,SAAgBG,EACd,EACA,EACQ,CACR,OAAOC,EAAK,QAAQ,gBAAiB,EAAS,IAAiB,CAC7D,IAAMN,EAAQO,EAAOC,GACrB,GAAIR,IAAU,IAAA,IAAaA,IAAU,GACnC,MAAU,UAAU,YAAYM,EAAK,SAASE,EAAK,EAAE,EAEvD,OAAO,mBAAmBR,CAAK,CACjC,CAA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D,GAAkD,UAChE,SACJ,GAAIL,EAAK,aAAeM,GAAU,SAAW,IAAK,OAAOA,EACzD,MAAO,MAAM3B,EAAAA,kBAAkB0B,CAAK,GAAMA,CAC5C,CACF,CAOA,eAAsBE,EACpB,EACA,EACY,CAEZ,OADI/B,EAAAA,aAAagC,CAAO,EAAW,MAAMF,EAAS,KAAK,EAChD1B,EAAAA,UAAU,MAAM0B,EAAS,KAAK,EAAGE,CAAO,CACjD,CAGA,SAAgBC,EAAU,EAAwC,CAChE,IAAMC,EAAMJ,EAAS,QAAQ,IAAItB,EAAW,IAAI,EAChD,OAAO0B,IAAQ,KAAO,IAAA,GAAYA,EAAI,QAAQ,OAAQ,EAAE,CAAC,CAAC,QAAQ,KAAM,EAAE,CAC5E"}
@@ -1,9 +1,10 @@
1
1
  import { Fetcher } from '@ahoo-wang/fetcher';
2
+ import { TextNumbers } from './exactJson.cjs';
2
3
  /**
3
- * The request headers of a Wow V10 service's public port (decisions D95,
4
+ * The request headers of a Wow service's public port (decisions D95,
4
5
  * D96, D98, D99).
5
6
  */
6
- export declare const WowV10Headers: {
7
+ export declare const WowHeaders: {
7
8
  /** The caller's id of the request: a retry with the same one is deduplicated. */
8
9
  readonly REQUEST_ID: "Wow-Request-Id";
9
10
  /** The wait plan (decision D99). */
@@ -22,8 +23,10 @@ export declare const WowV10Headers: {
22
23
  readonly ETAG: "ETag";
23
24
  /** The seconds after which a failed request may be retried. */
24
25
  readonly RETRY_AFTER: "Retry-After";
26
+ /** The position a streamed list resumes after (decision D253). */
27
+ readonly LAST_EVENT_ID: "Last-Event-ID";
25
28
  };
26
- /** How a V10 client reaches its service. */
29
+ /** How a client reaches its service. */
27
30
  export interface WowClientOptions {
28
31
  /**
29
32
  * The fetcher requests go through, with its base URL and interceptors
@@ -49,7 +52,7 @@ export interface TargetScope {
49
52
  * @param scope - The scope; at least one of its members is set
50
53
  */
51
54
  export declare function formatScope(scope: TargetScope): string;
52
- /** What every V10 request may carry beside its own parameters. */
55
+ /** What every request may carry beside its own parameters. */
53
56
  export interface RequestOptions {
54
57
  /** The scope to act in (`Wow-Scope`), for a caller allowed to. */
55
58
  readonly scope?: TargetScope;
@@ -60,13 +63,15 @@ export interface RequestOptions {
60
63
  /** Cancels the request. */
61
64
  readonly signal?: AbortSignal;
62
65
  }
63
- /** One request of a V10 client. */
66
+ /** One request of a client. */
64
67
  export interface Call {
65
68
  readonly method: 'GET' | 'POST' | 'DELETE';
66
69
  readonly path: string;
67
70
  readonly query?: Readonly<Record<string, string | number | undefined>>;
68
71
  readonly headers?: Readonly<Record<string, string | undefined>>;
69
72
  readonly body?: unknown;
73
+ /** The body's numbers written as their exact text ({@link TextNumbers}). */
74
+ readonly bodyNumbers?: TextNumbers;
70
75
  readonly options?: RequestOptions;
71
76
  /** Answers a 304 rather than rejecting with it. */
72
77
  readonly notModified?: boolean;
@@ -81,7 +86,11 @@ export declare function expandPath(path: string, params: Readonly<Record<string,
81
86
  * @param call - The request
82
87
  */
83
88
  export declare function send(client: WowClientOptions, call: Call): Promise<Response>;
84
- /** The JSON body of a 2xx response. */
85
- export declare function json<T>(response: Response): Promise<T>;
89
+ /**
90
+ * The JSON body of a 2xx response; the numbers `numbers` marks come back as
91
+ * their exact text (review R4-Q, Q-9), and without marks it is
92
+ * `response.json()` itself.
93
+ */
94
+ export declare function json<T>(response: Response, numbers?: TextNumbers): Promise<T>;
86
95
  /** The entity tag of a response without its quotes or weak marker. */
87
96
  export declare function entityTag(response: Response): string | undefined;
@@ -1,9 +1,10 @@
1
1
  import { Fetcher } from '@ahoo-wang/fetcher';
2
+ import { TextNumbers } from './exactJson.js';
2
3
  /**
3
- * The request headers of a Wow V10 service's public port (decisions D95,
4
+ * The request headers of a Wow service's public port (decisions D95,
4
5
  * D96, D98, D99).
5
6
  */
6
- export declare const WowV10Headers: {
7
+ export declare const WowHeaders: {
7
8
  /** The caller's id of the request: a retry with the same one is deduplicated. */
8
9
  readonly REQUEST_ID: "Wow-Request-Id";
9
10
  /** The wait plan (decision D99). */
@@ -22,8 +23,10 @@ export declare const WowV10Headers: {
22
23
  readonly ETAG: "ETag";
23
24
  /** The seconds after which a failed request may be retried. */
24
25
  readonly RETRY_AFTER: "Retry-After";
26
+ /** The position a streamed list resumes after (decision D253). */
27
+ readonly LAST_EVENT_ID: "Last-Event-ID";
25
28
  };
26
- /** How a V10 client reaches its service. */
29
+ /** How a client reaches its service. */
27
30
  export interface WowClientOptions {
28
31
  /**
29
32
  * The fetcher requests go through, with its base URL and interceptors
@@ -49,7 +52,7 @@ export interface TargetScope {
49
52
  * @param scope - The scope; at least one of its members is set
50
53
  */
51
54
  export declare function formatScope(scope: TargetScope): string;
52
- /** What every V10 request may carry beside its own parameters. */
55
+ /** What every request may carry beside its own parameters. */
53
56
  export interface RequestOptions {
54
57
  /** The scope to act in (`Wow-Scope`), for a caller allowed to. */
55
58
  readonly scope?: TargetScope;
@@ -60,13 +63,15 @@ export interface RequestOptions {
60
63
  /** Cancels the request. */
61
64
  readonly signal?: AbortSignal;
62
65
  }
63
- /** One request of a V10 client. */
66
+ /** One request of a client. */
64
67
  export interface Call {
65
68
  readonly method: 'GET' | 'POST' | 'DELETE';
66
69
  readonly path: string;
67
70
  readonly query?: Readonly<Record<string, string | number | undefined>>;
68
71
  readonly headers?: Readonly<Record<string, string | undefined>>;
69
72
  readonly body?: unknown;
73
+ /** The body's numbers written as their exact text ({@link TextNumbers}). */
74
+ readonly bodyNumbers?: TextNumbers;
70
75
  readonly options?: RequestOptions;
71
76
  /** Answers a 304 rather than rejecting with it. */
72
77
  readonly notModified?: boolean;
@@ -81,7 +86,11 @@ export declare function expandPath(path: string, params: Readonly<Record<string,
81
86
  * @param call - The request
82
87
  */
83
88
  export declare function send(client: WowClientOptions, call: Call): Promise<Response>;
84
- /** The JSON body of a 2xx response. */
85
- export declare function json<T>(response: Response): Promise<T>;
89
+ /**
90
+ * The JSON body of a 2xx response; the numbers `numbers` marks come back as
91
+ * their exact text (review R4-Q, Q-9), and without marks it is
92
+ * `response.json()` itself.
93
+ */
94
+ export declare function json<T>(response: Response, numbers?: TextNumbers): Promise<T>;
86
95
  /** The entity tag of a response without its quotes or weak marker. */
87
96
  export declare function entityTag(response: Response): string | undefined;
@@ -0,0 +1,77 @@
1
+ import { marksNothing as e, parseJson as t, stringifyJson as n } from "./exactJson.es.js";
2
+ import { toWowProblemError as r } from "./problem.es.js";
3
+ import { fetcher as i } from "@ahoo-wang/fetcher";
4
+ //#region src/http.ts
5
+ var a = {
6
+ REQUEST_ID: "Wow-Request-Id",
7
+ WAIT: "Wow-Wait",
8
+ WAIT_TIMEOUT: "Wow-Wait-Timeout",
9
+ SCOPE: "Wow-Scope",
10
+ SPACE: "Wow-Space",
11
+ IF_MATCH: "If-Match",
12
+ IF_NONE_MATCH: "If-None-Match",
13
+ ETAG: "ETag",
14
+ RETRY_AFTER: "Retry-After",
15
+ LAST_EVENT_ID: "Last-Event-ID"
16
+ };
17
+ function o(e) {
18
+ return `"${e.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`;
19
+ }
20
+ function s(e) {
21
+ let t = [
22
+ e.tenantId === void 0 ? void 0 : `tenant=${o(e.tenantId)}`,
23
+ e.ownerId === void 0 ? void 0 : `owner=${o(e.ownerId)}`,
24
+ e.spaceId === void 0 ? void 0 : `space=${o(e.spaceId)}`
25
+ ].filter((e) => e !== void 0);
26
+ if (t.length === 0) throw TypeError("Wow-Scope names a tenant, an owner or a space.");
27
+ return t.join(", ");
28
+ }
29
+ function c(e, t) {
30
+ return e.replace(/\{([^}]+)\}/g, (n, r) => {
31
+ let i = t[r];
32
+ if (i === void 0 || i === "") throw TypeError(`The path ${e} needs ${r}.`);
33
+ return encodeURIComponent(i);
34
+ });
35
+ }
36
+ function l(e) {
37
+ if (!e) return "";
38
+ let t = new URLSearchParams();
39
+ for (let [n, r] of Object.entries(e)) r !== void 0 && t.append(n, String(r));
40
+ let n = t.toString();
41
+ return n ? `?${n}` : "";
42
+ }
43
+ async function u(t, o) {
44
+ let c = o.options ?? {}, u = {};
45
+ for (let [e, t] of Object.entries({
46
+ ...o.headers,
47
+ ...c.scope === void 0 ? {} : { [a.SCOPE]: s(c.scope) },
48
+ ...c.space === void 0 ? {} : { [a.SPACE]: c.space },
49
+ ...c.headers
50
+ })) t !== void 0 && (u[e] = t);
51
+ let d = o.body !== void 0 && !e(o.bodyNumbers);
52
+ d && (u["Content-Type"] = "application/json");
53
+ let f = `${t.basePath ?? ""}${o.path}${l(o.query)}`;
54
+ try {
55
+ return await (t.fetcher ?? i).fetch(f, {
56
+ method: o.method,
57
+ headers: u,
58
+ ...o.body === void 0 ? {} : { body: d ? n(o.body, o.bodyNumbers) : o.body },
59
+ ...c.signal === void 0 ? {} : { signal: c.signal }
60
+ });
61
+ } catch (e) {
62
+ let t = e?.exchange?.response;
63
+ if (o.notModified && t?.status === 304) return t;
64
+ throw await r(e) ?? e;
65
+ }
66
+ }
67
+ async function d(n, r) {
68
+ return e(r) ? await n.json() : t(await n.text(), r);
69
+ }
70
+ function f(e) {
71
+ let t = e.headers.get(a.ETAG);
72
+ return t === null ? void 0 : t.replace(/^W\//, "").replace(/"/g, "");
73
+ }
74
+ //#endregion
75
+ export { a as WowHeaders, f as entityTag, c as expandPath, s as formatScope, d as json, u as send };
76
+
77
+ //# sourceMappingURL=http.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.es.js","names":["defaultFetcher","WowHeaders","quote","value","formatScope","members","scope","member","expandPath","path","params","name","queryString","query","text","send","options","call","headers","exact","marksNothing","url","client","fetcher","stringifyJson","error","response","toWowProblemError","json","numbers","parseJson","entityTag","tag"],"sources":["../src/http.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type Fetcher, fetcher as defaultFetcher } from '@ahoo-wang/fetcher';\nimport {\n marksNothing,\n parseJson,\n stringifyJson,\n type TextNumbers,\n} from './exactJson.js';\nimport { toWowProblemError } from './problem.js';\n\n/**\n * The request headers of a Wow service's public port (decisions D95,\n * D96, D98, D99).\n */\nexport const WowHeaders = {\n /** The caller's id of the request: a retry with the same one is deduplicated. */\n REQUEST_ID: 'Wow-Request-Id',\n /** The wait plan (decision D99). */\n WAIT: 'Wow-Wait',\n /** How long to wait: `500ms`, `10s` or an ISO-8601 duration. */\n WAIT_TIMEOUT: 'Wow-Wait-Timeout',\n /** The scope to act in, for a caller allowed to act across scopes (decision D95). */\n SCOPE: 'Wow-Scope',\n /** The space, among the caller's own, to act in (decision D96). */\n SPACE: 'Wow-Space',\n /** The expected version of the aggregate, as an entity tag. */\n IF_MATCH: 'If-Match',\n /** The version, or descriptor version, a read already holds. */\n IF_NONE_MATCH: 'If-None-Match',\n /** The version of a state read, or of a query descriptor. */\n ETAG: 'ETag',\n /** The seconds after which a failed request may be retried. */\n RETRY_AFTER: 'Retry-After',\n /** The position a streamed list resumes after (decision D253). */\n LAST_EVENT_ID: 'Last-Event-ID',\n} as const;\n\n/** How a client reaches its service. */\nexport interface WowClientOptions {\n /**\n * The fetcher requests go through, with its base URL and interceptors\n * (authentication, say); the default fetcher when absent.\n */\n readonly fetcher?: Fetcher;\n /** A path put before every route, such as a gateway's prefix. */\n readonly basePath?: string;\n}\n\n/**\n * The scope a caller allowed to act across scopes acts in: the `Wow-Scope`\n * header (decision D95).\n */\nexport interface TargetScope {\n readonly tenantId?: string;\n readonly ownerId?: string;\n readonly spaceId?: string;\n}\n\nfunction quote(value: string): string {\n return `\"${value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')}\"`;\n}\n\n/**\n * A target scope as the `Wow-Scope` header spells it, an RFC 8941\n * dictionary: `tenant=\"t1\", owner=\"u1\", space=\"s1\"`.\n *\n * @param scope - The scope; at least one of its members is set\n */\nexport function formatScope(scope: TargetScope): string {\n const members = [\n scope.tenantId === undefined\n ? undefined\n : `tenant=${quote(scope.tenantId)}`,\n scope.ownerId === undefined ? undefined : `owner=${quote(scope.ownerId)}`,\n scope.spaceId === undefined ? undefined : `space=${quote(scope.spaceId)}`,\n ].filter(member => member !== undefined);\n if (members.length === 0) {\n throw new TypeError('Wow-Scope names a tenant, an owner or a space.');\n }\n return members.join(', ');\n}\n\n/** What every request may carry beside its own parameters. */\nexport interface RequestOptions {\n /** The scope to act in (`Wow-Scope`), for a caller allowed to. */\n readonly scope?: TargetScope;\n /** The space to act in (`Wow-Space`), among the caller's own. */\n readonly space?: string;\n /** More headers: the request facts the service records, say. */\n readonly headers?: Readonly<Record<string, string>>;\n /** Cancels the request. */\n readonly signal?: AbortSignal;\n}\n\n/** One request of a client. */\nexport interface Call {\n readonly method: 'GET' | 'POST' | 'DELETE';\n readonly path: string;\n readonly query?: Readonly<Record<string, string | number | undefined>>;\n readonly headers?: Readonly<Record<string, string | undefined>>;\n readonly body?: unknown;\n /** The body's numbers written as their exact text ({@link TextNumbers}). */\n readonly bodyNumbers?: TextNumbers;\n readonly options?: RequestOptions;\n /** Answers a 304 rather than rejecting with it. */\n readonly notModified?: boolean;\n}\n\n/** `{name}` segments of `path` filled from `params`, each encoded. */\nexport function expandPath(\n path: string,\n params: Readonly<Record<string, string>>,\n): string {\n return path.replace(/\\{([^}]+)\\}/g, (segment, name: string) => {\n const value = params[name];\n if (value === undefined || value === '') {\n throw new TypeError(`The path ${path} needs ${name}.`);\n }\n return encodeURIComponent(value);\n });\n}\n\nfunction queryString(\n query: Readonly<Record<string, string | number | undefined>> | undefined,\n): string {\n if (!query) return '';\n const params = new URLSearchParams();\n for (const [name, value] of Object.entries(query)) {\n if (value !== undefined) params.append(name, String(value));\n }\n const text = params.toString();\n return text ? `?${text}` : '';\n}\n\n/**\n * Sends one request through the client's fetcher and answers its response;\n * a response that is not 2xx rejects with a {@link WowProblemError}.\n *\n * @param client - The client's options\n * @param call - The request\n */\nexport async function send(\n client: WowClientOptions,\n call: Call,\n): Promise<Response> {\n const options = call.options ?? {};\n const headers: Record<string, string> = {};\n for (const [name, value] of Object.entries({\n ...call.headers,\n ...(options.scope === undefined\n ? {}\n : { [WowHeaders.SCOPE]: formatScope(options.scope) }),\n ...(options.space === undefined\n ? {}\n : { [WowHeaders.SPACE]: options.space }),\n ...options.headers,\n })) {\n if (value !== undefined) headers[name] = value;\n }\n // A body with exact numbers goes as its own JSON text, those numbers unquoted.\n const exact = call.body !== undefined && !marksNothing(call.bodyNumbers);\n if (exact) headers['Content-Type'] = 'application/json';\n const url = `${client.basePath ?? ''}${call.path}${queryString(call.query)}`;\n try {\n return await (client.fetcher ?? defaultFetcher).fetch(url, {\n method: call.method,\n headers,\n ...(call.body === undefined\n ? {}\n : {\n body: exact\n ? stringifyJson(call.body, call.bodyNumbers)\n : (call.body as object),\n }),\n ...(options.signal === undefined ? {} : { signal: options.signal }),\n });\n } catch (error) {\n const response = (error as { exchange?: { response?: Response } })?.exchange\n ?.response;\n if (call.notModified && response?.status === 304) return response;\n throw (await toWowProblemError(error)) ?? error;\n }\n}\n\n/**\n * The JSON body of a 2xx response; the numbers `numbers` marks come back as\n * their exact text (review R4-Q, Q-9), and without marks it is\n * `response.json()` itself.\n */\nexport async function json<T>(\n response: Response,\n numbers?: TextNumbers,\n): Promise<T> {\n if (marksNothing(numbers)) return (await response.json()) as T;\n return parseJson(await response.text(), numbers) as T;\n}\n\n/** The entity tag of a response without its quotes or weak marker. */\nexport function entityTag(response: Response): string | undefined {\n const tag = response.headers.get(WowHeaders.ETAG);\n return tag === null ? undefined : tag.replace(/^W\\//, '').replace(/\"/g, '');\n}\n"],"mappings":";;;;AA0BA,IAAaC,IAAa;CAExB,YAAY;CAEZ,MAAM;CAEN,cAAc;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,EAAE,CAAC,CAAC,QAAQ,MAAM,EAAE;AAC5E"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./dsl/filter/operator.cjs"),t=require("./dsl/aggregation/types.cjs"),n=require("./dsl/deletionState.cjs"),r=require("./dsl/filter/builders.cjs"),i=require("./dsl/sort.cjs"),a=require("./dsl/aggregation/builders.cjs"),o=require("./dsl/projection.cjs"),s=require("./dsl/pagination.cjs"),c=require("./dsl/cursorQuery.cjs"),l=require("./dsl/queryable.cjs"),u=require("./dsl/descriptor.cjs"),d=require("./error/errorInfo.cjs"),f=require("./error/headers.cjs"),p=require("./error/wowError.cjs"),m=require("./model/command.cjs"),h=require("./transport/endpoints.cjs"),g=require("./client/command/commandClient.cjs"),_=require("./client/command/commandHeaders.cjs"),v=require("./model/abac.cjs"),y=require("./model/bi.cjs"),b=require("./model/domainEventStream.cjs"),x=require("./model/function.cjs"),S=require("./model/snapshot.cjs"),C=require("./client/command/commandRequest.cjs"),w=require("./client/metadata/wowMetadataClient.cjs"),T=require("./client/query/event/eventStreamQueryClient.cjs"),E=require("./client/query/snapshot/snapshotQueryClient.cjs"),D=require("./client/query/state/loadStateAggregateClient.cjs"),O=require("./client/query/state/loadOwnerStateAggregateClient.cjs"),k=require("./client/query/descriptor/queryDescriptorClient.cjs"),A=require("./client/routing.cjs"),j=require("./client/query/dataset/datasetQueryClient.cjs"),M=require("./client/query/dataset/datasetDirectoryClient.cjs"),N=require("./client/query/factory.cjs"),P=require("./error/queryErrorCodes.cjs");exports.AGGREGATION_LIMITS=t.AGGREGATION_LIMITS,exports.AggregationDatePart=t.AggregationDatePart,exports.AggregationDateUnit=t.AggregationDateUnit,exports.AggregationExpressionOperator=t.AggregationExpressionOperator,exports.AggregationExpressionType=t.AggregationExpressionType,exports.AggregationFunction=t.AggregationFunction,exports.AggregationGroupScope=t.AggregationGroupScope,exports.AggregationGroupType=t.AggregationGroupType,exports.AggregationMetricType=t.AggregationMetricType,exports.COMMAND_STREAM_ENDPOINT=h.COMMAND_STREAM_ENDPOINT,Object.defineProperty(exports,"CommandClient",{enumerable:!0,get:function(){return g.CommandClient}}),exports.CommandHeaders=_.CommandHeaders,exports.CommandStage=m.CommandStage,exports.ComparisonOperator=t.ComparisonOperator,exports.DEFAULT_CURSOR_SIZE=c.DEFAULT_CURSOR_SIZE,exports.DEFAULT_PAGINATION=s.DEFAULT_PAGINATION,Object.defineProperty(exports,"DatasetDirectoryClient",{enumerable:!0,get:function(){return M.DatasetDirectoryClient}}),Object.defineProperty(exports,"DatasetQueryClient",{enumerable:!0,get:function(){return j.DatasetQueryClient}}),exports.DateDiffUnit=t.DateDiffUnit,exports.DeletionState=n.DeletionState,exports.DerivedExpressionType=t.DerivedExpressionType,exports.DomainEventStreamMetadataFields=b.DomainEventStreamMetadataFields,exports.EMPTY_ABAC_TAGS=v.EMPTY_ABAC_TAGS,exports.ErrorCodes=d.ErrorCodes,Object.defineProperty(exports,"EventStreamQueryClient",{enumerable:!0,get:function(){return T.EventStreamQueryClient}}),exports.FilterOperator=e.FilterOperator,exports.FunctionKind=x.FunctionKind,exports.HavingExpressionType=t.HavingExpressionType,Object.defineProperty(exports,"LoadOwnerStateAggregateClient",{enumerable:!0,get:function(){return O.LoadOwnerStateAggregateClient}}),Object.defineProperty(exports,"LoadStateAggregateClient",{enumerable:!0,get:function(){return D.LoadStateAggregateClient}}),exports.MAX_CURSOR_SIZE=c.MAX_CURSOR_SIZE,exports.MAX_CURSOR_SORT_FIELDS=c.MAX_CURSOR_SORT_FIELDS,exports.MessageHeaderSqlType=y.MessageHeaderSqlType,exports.PagingMode=u.PagingMode,exports.QUERY_STREAM_ENDPOINT=h.QUERY_STREAM_ENDPOINT,exports.QueryClientFactory=N.QueryClientFactory,exports.QueryConstraintTypes=u.QueryConstraintTypes,exports.QueryDescriptorClient=k.QueryDescriptorClient,exports.QueryErrorCodes=P.QueryErrorCodes,exports.QueryFieldRoles=u.QueryFieldRoles,exports.QueryModels=u.QueryModels,exports.QueryValueKind=u.QueryValueKind,exports.QueryValueTypes=u.QueryValueTypes,exports.RecoverableType=d.RecoverableType,exports.ResourceAttributionPathSpec=A.ResourceAttributionPathSpec,exports.RunningFunction=t.RunningFunction,exports.SearchMode=e.SearchMode,exports.SensitivityLevel=u.SensitivityLevel,exports.SnapshotMetadataFields=S.SnapshotMetadataFields,Object.defineProperty(exports,"SnapshotQueryClient",{enumerable:!0,get:function(){return E.SnapshotQueryClient}}),exports.SortDirection=i.SortDirection,exports.StringComparison=e.StringComparison,exports.TimeUnit=e.TimeUnit,exports.WILDCARD_ABAC_TAG_VALUES=v.WILDCARD_ABAC_TAG_VALUES,exports.WindowFunction=t.WindowFunction,exports.WowError=p.WowError,exports.WowHeaders=f.WowHeaders,Object.defineProperty(exports,"WowMetadataClient",{enumerable:!0,get:function(){return w.WowMetadataClient}}),exports.aggregation=a.aggregation,exports.asc=i.asc,exports.commandHeaders=C.commandHeaders,exports.cursorQuery=c.cursorQuery,exports.datasetBasePath=j.datasetBasePath,exports.desc=i.desc,exports.filter=r.filter,exports.isErrorInfo=p.isErrorInfo,exports.listQuery=l.listQuery,exports.pagedList=l.pagedList,exports.pagedQuery=l.pagedQuery,exports.pagination=s.pagination,exports.projection=o.projection,exports.singleQuery=l.singleQuery,exports.toWowError=p.toWowError,exports.waitStrategy=C.waitStrategy;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./exactJson.cjs"),t=require("./problem.cjs"),n=require("./http.cjs"),r=require("./wire.cjs"),i=require("./wait.cjs"),a=require("./commands.cjs"),o=require("./manifest.cjs"),s=require("./queries.cjs"),c=require("./state.cjs");exports.CommandGateway=a.CommandGateway,exports.DatasetClient=s.DatasetClient,exports.EventQueryClient=s.EventQueryClient,exports.FRAMEWORK_ERROR_PREFIX=t.FRAMEWORK_ERROR_PREFIX,exports.FrameworkErrorCodes=t.FrameworkErrorCodes,exports.LifecycleCommands=a.LifecycleCommands,exports.MANIFEST_FORMAT=o.MANIFEST_FORMAT,exports.PROBLEM_TYPE_PREFIX=t.PROBLEM_TYPE_PREFIX,exports.QueryModelClient=s.QueryModelClient,exports.SNAPSHOT_SUBSCRIPTION=i.SNAPSHOT_SUBSCRIPTION,exports.SnapshotQueryClient=s.SnapshotQueryClient,exports.Stage=r.Stage,exports.StateClient=c.StateClient,exports.WowHeaders=n.WowHeaders,exports.WowProblemError=t.WowProblemError,exports.commandSegment=a.commandSegment,exports.fetchManifest=o.fetchManifest,exports.formatHop=i.formatHop,exports.formatScope=n.formatScope,exports.formatWaitPlan=i.formatWaitPlan,exports.formatWaitTimeout=i.formatWaitTimeout,exports.isProblem=t.isProblem,exports.newRequestId=a.newRequestId,exports.parseJson=e.parseJson,exports.parseRetryAfter=t.parseRetryAfter,exports.queryPath=s.queryPath,exports.readProblem=t.readProblem,exports.requestIdOf=t.requestIdOf,exports.retryHintOf=t.retryHintOf,exports.stringifyJson=e.stringifyJson,exports.textNumbersBy=e.textNumbersBy,exports.toWowProblemError=t.toWowProblemError,exports.wait=i.wait;
package/dist/index.d.cts CHANGED
@@ -1,17 +1,19 @@
1
- export * from './dsl/filter/index.cjs';
2
- export * from './dsl/aggregation/index.cjs';
3
- export * from './dsl/sort.cjs';
4
- export * from './dsl/projection.cjs';
5
- export * from './dsl/pagination.cjs';
6
- export * from './dsl/cursorQuery.cjs';
7
- export * from './dsl/queryable.cjs';
8
- export * from './dsl/deletionState.cjs';
9
- export * from './dsl/documents.cjs';
10
- export * from './dsl/descriptor.cjs';
11
- export * from './client/command/index.cjs';
12
- export * from './client/metadata/index.cjs';
13
- export * from './client/query/index.cjs';
14
- export * from './client/routing.cjs';
15
- export * from './transport/index.cjs';
16
- export * from './model/index.cjs';
17
- export * from './error/index.cjs';
1
+ /**
2
+ * `@ahoo-wang/wow-client`: the client of a Wow service's public
3
+ * routes — commands with `Wow-Wait` and their event streams, state reads and
4
+ * traces, the snapshot, event and dataset query routes, the Manifest, and
5
+ * RFC 9457 problems as {@link WowProblemError}s with retry hints. Code
6
+ * `wow-generator` generates from a Manifest builds on it.
7
+ *
8
+ * Build queries with the DSL of `@ahoo-wang/wow-client/dsl`.
9
+ */
10
+ export { type ApplyTags, CommandGateway, type CommandOptions, commandSegment, type CreateCommandOptions, type LifecycleCommand, LifecycleCommands, newRequestId, type TransferOwner, type TransferSpace, } from './commands.cjs';
11
+ export { parseJson, stringifyJson, type TextNumbers, textNumbersBy, type TextNumbersByName, } from './exactJson.cjs';
12
+ export { formatScope, type RequestOptions, type TargetScope, type WowClientOptions, WowHeaders, } from './http.cjs';
13
+ export { type AggregateManifest, type CommandManifest, type ContextManifest, type Creation, type ErrorManifest, type EventManifest, fetchManifest, type Manifest, MANIFEST_FORMAT, type QueryManifest, type RouteManifest, type SubscriptionManifest, } from './manifest.cjs';
14
+ export * from './wire.cjs';
15
+ export { FRAMEWORK_ERROR_PREFIX, type FrameworkErrorCode, FrameworkErrorCodes, isProblem, parseRetryAfter, type Problem, PROBLEM_TYPE_PREFIX, readProblem, requestIdOf, type RetryHint, retryHintOf, toWowProblemError, WowProblemError, } from './problem.cjs';
16
+ export { type CountQuery, type CountResult, DatasetClient, type DescriptorResult, EventQueryClient, type ListStreamOptions, type Including, type PagedQuery, type PagedResult, QueryModelClient, queryPath, SnapshotQueryClient, type TotalMode, } from './queries.cjs';
17
+ export { StateClient, type StateReadOptions, type StateReadResult, type StateTraceOptions, } from './state.cjs';
18
+ export { type CommandResultStream, type StreamedRow, type StreamEnd, type StreamEndReason, type StreamResumeOptions, } from './streams.cjs';
19
+ export { formatHop, formatWaitPlan, formatWaitTimeout, SNAPSHOT_SUBSCRIPTION, wait, type WaitOptions, } from './wait.cjs';
package/dist/index.d.ts CHANGED
@@ -1,17 +1,19 @@
1
- export * from './dsl/filter/index.js';
2
- export * from './dsl/aggregation/index.js';
3
- export * from './dsl/sort.js';
4
- export * from './dsl/projection.js';
5
- export * from './dsl/pagination.js';
6
- export * from './dsl/cursorQuery.js';
7
- export * from './dsl/queryable.js';
8
- export * from './dsl/deletionState.js';
9
- export * from './dsl/documents.js';
10
- export * from './dsl/descriptor.js';
11
- export * from './client/command/index.js';
12
- export * from './client/metadata/index.js';
13
- export * from './client/query/index.js';
14
- export * from './client/routing.js';
15
- export * from './transport/index.js';
16
- export * from './model/index.js';
17
- export * from './error/index.js';
1
+ /**
2
+ * `@ahoo-wang/wow-client`: the client of a Wow service's public
3
+ * routes — commands with `Wow-Wait` and their event streams, state reads and
4
+ * traces, the snapshot, event and dataset query routes, the Manifest, and
5
+ * RFC 9457 problems as {@link WowProblemError}s with retry hints. Code
6
+ * `wow-generator` generates from a Manifest builds on it.
7
+ *
8
+ * Build queries with the DSL of `@ahoo-wang/wow-client/dsl`.
9
+ */
10
+ export { type ApplyTags, CommandGateway, type CommandOptions, commandSegment, type CreateCommandOptions, type LifecycleCommand, LifecycleCommands, newRequestId, type TransferOwner, type TransferSpace, } from './commands.js';
11
+ export { parseJson, stringifyJson, type TextNumbers, textNumbersBy, type TextNumbersByName, } from './exactJson.js';
12
+ export { formatScope, type RequestOptions, type TargetScope, type WowClientOptions, WowHeaders, } from './http.js';
13
+ export { type AggregateManifest, type CommandManifest, type ContextManifest, type Creation, type ErrorManifest, type EventManifest, fetchManifest, type Manifest, MANIFEST_FORMAT, type QueryManifest, type RouteManifest, type SubscriptionManifest, } from './manifest.js';
14
+ export * from './wire.js';
15
+ export { FRAMEWORK_ERROR_PREFIX, type FrameworkErrorCode, FrameworkErrorCodes, isProblem, parseRetryAfter, type Problem, PROBLEM_TYPE_PREFIX, readProblem, requestIdOf, type RetryHint, retryHintOf, toWowProblemError, WowProblemError, } from './problem.js';
16
+ export { type CountQuery, type CountResult, DatasetClient, type DescriptorResult, EventQueryClient, type ListStreamOptions, type Including, type PagedQuery, type PagedResult, QueryModelClient, queryPath, SnapshotQueryClient, type TotalMode, } from './queries.js';
17
+ export { StateClient, type StateReadOptions, type StateReadResult, type StateTraceOptions, } from './state.js';
18
+ export { type CommandResultStream, type StreamedRow, type StreamEnd, type StreamEndReason, type StreamResumeOptions, } from './streams.js';
19
+ export { formatHop, formatWaitPlan, formatWaitTimeout, SNAPSHOT_SUBSCRIPTION, wait, type WaitOptions, } from './wait.js';
package/dist/index.es.js CHANGED
@@ -1,36 +1,10 @@
1
- import { FilterOperator as e, SearchMode as t, StringComparison as n, TimeUnit as r } from "./dsl/filter/operator.es.js";
2
- import { AGGREGATION_LIMITS as i, AggregationDatePart as a, AggregationDateUnit as o, AggregationExpressionOperator as s, AggregationExpressionType as c, AggregationFunction as l, AggregationGroupScope as u, AggregationGroupType as d, AggregationMetricType as f, ComparisonOperator as p, DateDiffUnit as m, DerivedExpressionType as h, HavingExpressionType as g, RunningFunction as _, WindowFunction as v } from "./dsl/aggregation/types.es.js";
3
- import { DeletionState as y } from "./dsl/deletionState.es.js";
4
- import { filter as b } from "./dsl/filter/builders.es.js";
5
- import { SortDirection as x, asc as S, desc as C } from "./dsl/sort.es.js";
6
- import { aggregation as w } from "./dsl/aggregation/builders.es.js";
7
- import { projection as T } from "./dsl/projection.es.js";
8
- import { DEFAULT_PAGINATION as E, pagination as D } from "./dsl/pagination.es.js";
9
- import { DEFAULT_CURSOR_SIZE as O, MAX_CURSOR_SIZE as k, MAX_CURSOR_SORT_FIELDS as A, cursorQuery as j } from "./dsl/cursorQuery.es.js";
10
- import { listQuery as M, pagedList as N, pagedQuery as P, singleQuery as F } from "./dsl/queryable.es.js";
11
- import { PagingMode as I, QueryConstraintTypes as L, QueryFieldRoles as R, QueryModels as z, QueryValueKind as B, QueryValueTypes as V, SensitivityLevel as H } from "./dsl/descriptor.es.js";
12
- import { ErrorCodes as U, RecoverableType as W } from "./error/errorInfo.es.js";
13
- import { WowHeaders as G } from "./error/headers.es.js";
14
- import { WowError as K, isErrorInfo as q, toWowError as J } from "./error/wowError.es.js";
15
- import { CommandStage as Y } from "./model/command.es.js";
16
- import { COMMAND_STREAM_ENDPOINT as X, QUERY_STREAM_ENDPOINT as Z } from "./transport/endpoints.es.js";
17
- import { CommandClient as Q } from "./client/command/commandClient.es.js";
18
- import { CommandHeaders as $ } from "./client/command/commandHeaders.es.js";
19
- import { EMPTY_ABAC_TAGS as ee, WILDCARD_ABAC_TAG_VALUES as te } from "./model/abac.es.js";
20
- import { MessageHeaderSqlType as ne } from "./model/bi.es.js";
21
- import { DomainEventStreamMetadataFields as re } from "./model/domainEventStream.es.js";
22
- import { FunctionKind as ie } from "./model/function.es.js";
23
- import { SnapshotMetadataFields as ae } from "./model/snapshot.es.js";
24
- import { commandHeaders as oe, waitStrategy as se } from "./client/command/commandRequest.es.js";
25
- import { WowMetadataClient as ce } from "./client/metadata/wowMetadataClient.es.js";
26
- import { EventStreamQueryClient as le } from "./client/query/event/eventStreamQueryClient.es.js";
27
- import { SnapshotQueryClient as ue } from "./client/query/snapshot/snapshotQueryClient.es.js";
28
- import { LoadStateAggregateClient as de } from "./client/query/state/loadStateAggregateClient.es.js";
29
- import { LoadOwnerStateAggregateClient as fe } from "./client/query/state/loadOwnerStateAggregateClient.es.js";
30
- import { QueryDescriptorClient as pe } from "./client/query/descriptor/queryDescriptorClient.es.js";
31
- import { ResourceAttributionPathSpec as me } from "./client/routing.es.js";
32
- import { DatasetQueryClient as he, datasetBasePath as ge } from "./client/query/dataset/datasetQueryClient.es.js";
33
- import { DatasetDirectoryClient as _e } from "./client/query/dataset/datasetDirectoryClient.es.js";
34
- import { QueryClientFactory as ve } from "./client/query/factory.es.js";
35
- import { QueryErrorCodes as ye } from "./error/queryErrorCodes.es.js";
36
- export { i as AGGREGATION_LIMITS, a as AggregationDatePart, o as AggregationDateUnit, s as AggregationExpressionOperator, c as AggregationExpressionType, l as AggregationFunction, u as AggregationGroupScope, d as AggregationGroupType, f as AggregationMetricType, X as COMMAND_STREAM_ENDPOINT, Q as CommandClient, $ as CommandHeaders, Y as CommandStage, p as ComparisonOperator, O as DEFAULT_CURSOR_SIZE, E as DEFAULT_PAGINATION, _e as DatasetDirectoryClient, he as DatasetQueryClient, m as DateDiffUnit, y as DeletionState, h as DerivedExpressionType, re as DomainEventStreamMetadataFields, ee as EMPTY_ABAC_TAGS, U as ErrorCodes, le as EventStreamQueryClient, e as FilterOperator, ie as FunctionKind, g as HavingExpressionType, fe as LoadOwnerStateAggregateClient, de as LoadStateAggregateClient, k as MAX_CURSOR_SIZE, A as MAX_CURSOR_SORT_FIELDS, ne as MessageHeaderSqlType, I as PagingMode, Z as QUERY_STREAM_ENDPOINT, ve as QueryClientFactory, L as QueryConstraintTypes, pe as QueryDescriptorClient, ye as QueryErrorCodes, R as QueryFieldRoles, z as QueryModels, B as QueryValueKind, V as QueryValueTypes, W as RecoverableType, me as ResourceAttributionPathSpec, _ as RunningFunction, t as SearchMode, H as SensitivityLevel, ae as SnapshotMetadataFields, ue as SnapshotQueryClient, x as SortDirection, n as StringComparison, r as TimeUnit, te as WILDCARD_ABAC_TAG_VALUES, v as WindowFunction, K as WowError, G as WowHeaders, ce as WowMetadataClient, w as aggregation, S as asc, oe as commandHeaders, j as cursorQuery, ge as datasetBasePath, C as desc, b as filter, q as isErrorInfo, M as listQuery, N as pagedList, P as pagedQuery, D as pagination, T as projection, F as singleQuery, J as toWowError, se as waitStrategy };
1
+ import { parseJson as e, stringifyJson as t, textNumbersBy as n } from "./exactJson.es.js";
2
+ import { FRAMEWORK_ERROR_PREFIX as r, FrameworkErrorCodes as i, PROBLEM_TYPE_PREFIX as a, WowProblemError as o, isProblem as s, parseRetryAfter as c, readProblem as l, requestIdOf as u, retryHintOf as d, toWowProblemError as f } from "./problem.es.js";
3
+ import { WowHeaders as p, formatScope as m } from "./http.es.js";
4
+ import { Stage as h } from "./wire.es.js";
5
+ import { SNAPSHOT_SUBSCRIPTION as g, formatHop as _, formatWaitPlan as v, formatWaitTimeout as y, wait as b } from "./wait.es.js";
6
+ import { CommandGateway as x, LifecycleCommands as S, commandSegment as C, newRequestId as w } from "./commands.es.js";
7
+ import { MANIFEST_FORMAT as T, fetchManifest as E } from "./manifest.es.js";
8
+ import { DatasetClient as D, EventQueryClient as O, QueryModelClient as k, SnapshotQueryClient as A, queryPath as j } from "./queries.es.js";
9
+ import { StateClient as M } from "./state.es.js";
10
+ export { x as CommandGateway, D as DatasetClient, O as EventQueryClient, r as FRAMEWORK_ERROR_PREFIX, i as FrameworkErrorCodes, S as LifecycleCommands, T as MANIFEST_FORMAT, a as PROBLEM_TYPE_PREFIX, k as QueryModelClient, g as SNAPSHOT_SUBSCRIPTION, A as SnapshotQueryClient, h as Stage, M as StateClient, p as WowHeaders, o as WowProblemError, C as commandSegment, E as fetchManifest, _ as formatHop, m as formatScope, v as formatWaitPlan, y as formatWaitTimeout, s as isProblem, w as newRequestId, e as parseJson, c as parseRetryAfter, j as queryPath, l as readProblem, u as requestIdOf, d as retryHintOf, t as stringifyJson, n as textNumbersBy, f as toWowProblemError, b as wait };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.cjs","names":["json","send","require_http","MANIFEST_FORMAT","fetchManifest","client"],"sources":["../src/manifest.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n json,\n type RequestOptions,\n send,\n type WowClientOptions,\n} from './http.js';\nimport type { Ownership } from './wire.js';\n\n/** A route of the Manifest: a method and a path, `{id}` the aggregate id. */\nexport interface RouteManifest {\n readonly method: string;\n readonly path: string;\n}\n\n/** Whether a command creates its aggregate. */\nexport type Creation = 'NONE' | 'REQUIRED' | 'ALLOWED';\n\n/** A command of an aggregate (decisions D104, D176, D182). */\nexport interface CommandManifest {\n readonly name: string;\n readonly aliases?: readonly string[];\n /** `#/$defs/<key>`. */\n readonly schema: string;\n readonly creation?: Creation;\n readonly produces?: readonly string[];\n readonly routes?: readonly RouteManifest[];\n readonly mounted?: boolean;\n readonly transformsTo?: readonly string[];\n}\n\n/** An event of an aggregate and its revision. */\nexport interface EventManifest {\n readonly name: string;\n readonly aliases?: readonly string[];\n readonly revision?: number;\n readonly schema: string;\n}\n\n/** A query model of an aggregate: `snapshot` or `events` (decision D128). */\nexport interface QueryManifest {\n readonly model: string;\n readonly routes?: readonly RouteManifest[];\n}\n\n/** An aggregate of a bounded context. */\nexport interface AggregateManifest {\n readonly name: string;\n readonly description?: string;\n readonly state: { readonly schema: string; readonly fingerprint?: string };\n readonly snapshot?: { readonly enabled?: boolean };\n readonly commands?: readonly CommandManifest[];\n readonly events?: readonly EventManifest[];\n readonly lifecycle?: readonly string[];\n readonly queries?: readonly QueryManifest[];\n readonly schedules?: readonly string[];\n readonly ownership?: Ownership;\n}\n\n/** A subscription of a bounded context (design 04 §1). */\nexport interface SubscriptionManifest {\n /** `processor.function`, as a `handled` hop names it. */\n readonly name: string;\n readonly kind: 'PROJECTION' | 'REACTOR' | 'SAGA';\n readonly source: {\n readonly context?: string;\n readonly aggregates?: readonly string[];\n readonly events?: readonly string[];\n };\n readonly derives?: readonly string[];\n readonly rejected?: readonly string[];\n readonly committed?: readonly string[];\n readonly [property: string]: unknown;\n}\n\n/** An error code and the HTTP status it is answered with. */\nexport interface ErrorManifest {\n readonly code: string;\n readonly status: number;\n readonly description?: string;\n}\n\n/** A bounded context of the Manifest. */\nexport interface ContextManifest {\n readonly name: string;\n readonly description?: string;\n readonly aggregates?: readonly AggregateManifest[];\n readonly subscriptions?: readonly SubscriptionManifest[];\n readonly published?: readonly {\n readonly aggregate: string;\n readonly topic: string;\n readonly includeState?: boolean;\n }[];\n readonly errors?: readonly ErrorManifest[];\n}\n\n/**\n * A service's Manifest (decisions D17, D73–D76): its contexts, aggregates,\n * commands, events, routes and error codes, and the JSON Schemas they refer\n * to under `$defs`. `wow-generator` generates typed clients from it.\n */\nexport interface Manifest {\n readonly format: number;\n readonly service?: { readonly name: string; readonly version?: string };\n readonly contexts: readonly ContextManifest[];\n readonly errors?: readonly ErrorManifest[];\n readonly $defs?: Readonly<Record<string, unknown>>;\n}\n\n/** The format of the Manifest this client reads. */\nexport const MANIFEST_FORMAT = 1;\n\n/**\n * The service's Manifest, `GET /wow/manifest`, authorized as any API.\n *\n * @param client - How the service is reached\n * @param options - Headers and cancellation\n */\nexport async function fetchManifest(\n client: WowClientOptions = {},\n options?: RequestOptions,\n): Promise<Manifest> {\n return json<Manifest>(\n await send(client, { method: 'GET', path: '/wow/manifest', options }),\n );\n}\n"],"mappings":"8BA0HA,IAAaG,EAAkB,EAQ/B,eAAsBC,EACpB,EAA2B,CAAC,EAC5B,EACmB,CACnB,OAAOJ,EAAAA,KACL,MAAMC,EAAAA,KAAKI,EAAQ,CAAE,OAAQ,MAAO,KAAM,gBAAiB,SAAQ,CAAC,CACtE,CACF"}
@@ -1,5 +1,5 @@
1
1
  import { json as e, send as t } from "./http.es.js";
2
- //#region src/v10/manifest.ts
2
+ //#region src/manifest.ts
3
3
  var n = 1;
4
4
  async function r(n = {}, r) {
5
5
  return e(await t(n, {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.es.js","names":["MANIFEST_FORMAT","fetchManifest","json","send","client"],"sources":["../src/manifest.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n json,\n type RequestOptions,\n send,\n type WowClientOptions,\n} from './http.js';\nimport type { Ownership } from './wire.js';\n\n/** A route of the Manifest: a method and a path, `{id}` the aggregate id. */\nexport interface RouteManifest {\n readonly method: string;\n readonly path: string;\n}\n\n/** Whether a command creates its aggregate. */\nexport type Creation = 'NONE' | 'REQUIRED' | 'ALLOWED';\n\n/** A command of an aggregate (decisions D104, D176, D182). */\nexport interface CommandManifest {\n readonly name: string;\n readonly aliases?: readonly string[];\n /** `#/$defs/<key>`. */\n readonly schema: string;\n readonly creation?: Creation;\n readonly produces?: readonly string[];\n readonly routes?: readonly RouteManifest[];\n readonly mounted?: boolean;\n readonly transformsTo?: readonly string[];\n}\n\n/** An event of an aggregate and its revision. */\nexport interface EventManifest {\n readonly name: string;\n readonly aliases?: readonly string[];\n readonly revision?: number;\n readonly schema: string;\n}\n\n/** A query model of an aggregate: `snapshot` or `events` (decision D128). */\nexport interface QueryManifest {\n readonly model: string;\n readonly routes?: readonly RouteManifest[];\n}\n\n/** An aggregate of a bounded context. */\nexport interface AggregateManifest {\n readonly name: string;\n readonly description?: string;\n readonly state: { readonly schema: string; readonly fingerprint?: string };\n readonly snapshot?: { readonly enabled?: boolean };\n readonly commands?: readonly CommandManifest[];\n readonly events?: readonly EventManifest[];\n readonly lifecycle?: readonly string[];\n readonly queries?: readonly QueryManifest[];\n readonly schedules?: readonly string[];\n readonly ownership?: Ownership;\n}\n\n/** A subscription of a bounded context (design 04 §1). */\nexport interface SubscriptionManifest {\n /** `processor.function`, as a `handled` hop names it. */\n readonly name: string;\n readonly kind: 'PROJECTION' | 'REACTOR' | 'SAGA';\n readonly source: {\n readonly context?: string;\n readonly aggregates?: readonly string[];\n readonly events?: readonly string[];\n };\n readonly derives?: readonly string[];\n readonly rejected?: readonly string[];\n readonly committed?: readonly string[];\n readonly [property: string]: unknown;\n}\n\n/** An error code and the HTTP status it is answered with. */\nexport interface ErrorManifest {\n readonly code: string;\n readonly status: number;\n readonly description?: string;\n}\n\n/** A bounded context of the Manifest. */\nexport interface ContextManifest {\n readonly name: string;\n readonly description?: string;\n readonly aggregates?: readonly AggregateManifest[];\n readonly subscriptions?: readonly SubscriptionManifest[];\n readonly published?: readonly {\n readonly aggregate: string;\n readonly topic: string;\n readonly includeState?: boolean;\n }[];\n readonly errors?: readonly ErrorManifest[];\n}\n\n/**\n * A service's Manifest (decisions D17, D73–D76): its contexts, aggregates,\n * commands, events, routes and error codes, and the JSON Schemas they refer\n * to under `$defs`. `wow-generator` generates typed clients from it.\n */\nexport interface Manifest {\n readonly format: number;\n readonly service?: { readonly name: string; readonly version?: string };\n readonly contexts: readonly ContextManifest[];\n readonly errors?: readonly ErrorManifest[];\n readonly $defs?: Readonly<Record<string, unknown>>;\n}\n\n/** The format of the Manifest this client reads. */\nexport const MANIFEST_FORMAT = 1;\n\n/**\n * The service's Manifest, `GET /wow/manifest`, authorized as any API.\n *\n * @param client - How the service is reached\n * @param options - Headers and cancellation\n */\nexport async function fetchManifest(\n client: WowClientOptions = {},\n options?: RequestOptions,\n): Promise<Manifest> {\n return json<Manifest>(\n await send(client, { method: 'GET', path: '/wow/manifest', options }),\n );\n}\n"],"mappings":";;AA0HA,IAAaA,IAAkB;AAQ/B,eAAsBC,EACpB,IAA2B,CAAC,GAC5B,GACmB;CACnB,OAAOC,EACL,MAAMC,EAAKC,GAAQ;EAAE,QAAQ;EAAO,MAAM;EAAiB;CAAQ,CAAC,CACtE;AACF"}
@@ -0,0 +1,2 @@
1
+ var e={AUTH_UNAUTHENTICATED:`wow.auth.unauthenticated`,AUTH_FORBIDDEN:`wow.auth.forbidden`,AGGREGATE_FORBIDDEN:`wow.aggregate.forbidden`,COMMAND_MALFORMED:`wow.command.malformed`,COMMAND_INVALID:`wow.command.invalid`,WAIT_INVALID:`wow.wait.invalid`,COMMAND_UNHANDLED:`wow.command.unhandled`,AGGREGATE_NOT_FOUND:`wow.aggregate.not-found`,AGGREGATE_EXISTS:`wow.aggregate.exists`,AGGREGATE_VERSION_MISMATCH:`wow.aggregate.version-mismatch`,COMMAND_REQUEST_ID_REUSED:`wow.command.request-id-reused`,COMMAND_CONTENDED:`wow.command.contended`,AGGREGATE_DELETED:`wow.aggregate.deleted`,COMMAND_BUSY:`wow.command.busy`,COMMAND_UNKNOWN:`wow.command.unknown`,COMMAND_FAILED:`wow.command.failed`,NODE_CLOSING:`wow.node.closing`,NODE_STANDBY:`wow.node.standby`,STORAGE_UNAVAILABLE:`wow.storage.unavailable`,SCHEDULE_NOT_DUE:`wow.schedule.not-due`,SCHEDULE_JOB_INVALID:`wow.schedule.job-invalid`,SUBSCRIPTION_PARKED:`wow.subscription.parked`,WAIT_TIMEOUT:`wow.wait.timeout`,QUERY_MALFORMED:`wow.query.malformed`,QUERY_INVALID:`wow.query.invalid`,QUERY_FAILED:`wow.query.failed`,QUERY_TIMEOUT:`wow.query.timeout`,QUERY_BUSY:`wow.query.busy`,QUERY_NOT_FOUND:`wow.query.not-found`,QUERY_DATASET_NOT_FOUND:`wow.query.dataset-not-found`,QUERY_MIN_VERSION_NOT_REACHED:`wow.query.min-version-not-reached`,QUERY_DATASET_UNAVAILABLE:`wow.query.dataset-unavailable`,CALL_COMMAND_FORBIDDEN:`wow.call.command-forbidden`},t=`wow.`,n=`urn:wow:error:`,r=new Set([`type`,`title`,`status`,`detail`,`instance`,`code`,`violations`,`result`,`extensions`]);function i(e){if(e.extensions!==void 0)return e;let t=Object.fromEntries(Object.entries(e).filter(([e])=>!r.has(e)));return Object.keys(t).length===0?e:{...e,extensions:t}}var a=new Map([[e.COMMAND_UNKNOWN,!0],[e.NODE_CLOSING,!0],[e.NODE_STANDBY,!0],[e.STORAGE_UNAVAILABLE,!0],[e.SCHEDULE_NOT_DUE,!0],[e.COMMAND_BUSY,!0],[e.QUERY_BUSY,!1],[e.QUERY_MIN_VERSION_NOT_REACHED,!1],[e.COMMAND_CONTENDED,!0],[e.WAIT_TIMEOUT,!0]]);function o(e,t,n){let r=e===void 0?void 0:a.get(e),i=r!==void 0||e===void 0&&t===503;return{retryable:i,sameRequestId:r??i,...n===void 0?{}:{afterMs:n}}}var s=class extends Error{get requestId(){return this.result?.requestId??c.get(this)}constructor(e,t={}){super(e.code?`[${e.code}] ${e.detail??e.title}`:`${e.status} ${e.detail??e.title}`),this.name=`WowProblemError`,this.problem=i(e),this.status=e.status,e.code!==void 0&&(this.code=e.code),this.violations=e.violations??[],e.result!==void 0&&(this.result=e.result),this.retry=o(e.code,e.status,t.retryAfterMs),t.cause!==void 0&&(this.cause=t.cause)}get isFramework(){return this.code?.startsWith(`wow.`)??!1}},c=new WeakMap;function l(e,t){(typeof e==`object`&&e||typeof e==`function`)&&(c.has(e)||c.set(e,t))}function u(e){return e instanceof s?e.requestId:typeof e==`object`&&e||typeof e==`function`?c.get(e):void 0}function d(e){return typeof e==`object`&&!!e&&typeof e.status==`number`}function f(e,t=Date.now()){if(!e)return;let n=e.trim();if(/^\d+$/.test(n))return Number(n)*1e3;let r=Date.parse(n);return Number.isNaN(r)?void 0:Math.max(0,r-t)}async function p(e){let t;try{t=await e.clone().json()}catch{}if(d(t)){let n=t.code??(t.type?.startsWith(`urn:wow:error:`)?t.type.slice(14):void 0);return i({...t,type:t.type??`about:blank`,title:t.title??e.statusText,...n===void 0?{}:{code:n}})}return{type:`about:blank`,title:e.statusText,status:e.status}}async function m(e){if(e instanceof s)return e;if(typeof e!=`object`||!e)return;let{exchange:t,cause:n}=e;if(n instanceof s)return n;let r=t?.response;if(!r||r.ok)return;let i=await p(r),a=f(r.headers.get(`Retry-After`));return new s(i,{cause:e,...a===void 0?{}:{retryAfterMs:a}})}exports.FRAMEWORK_ERROR_PREFIX=t,exports.FrameworkErrorCodes=e,exports.PROBLEM_TYPE_PREFIX=n,exports.WowProblemError=s,exports.isProblem=d,exports.parseRetryAfter=f,exports.readProblem=p,exports.rememberRequestId=l,exports.requestIdOf=u,exports.retryHintOf=o,exports.toWowProblemError=m;
2
+ //# sourceMappingURL=problem.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"problem.cjs","names":["FrameworkErrorCodes","FRAMEWORK_ERROR_PREFIX","PROBLEM_TYPE_PREFIX","PROBLEM_MEMBERS","withExtensions","problem","extensions","name","RETRYABLE","retryHintOf","sameRequestId","code","retryable","status","afterMs","WowProblemError","SENT_REQUEST_IDS","options","rememberRequestId","error","requestId","requestIdOf","isProblem","value","parseRetryAfter","trimmed","date","now","readProblem","body","response","toWowProblemError","cause","exchange","retryAfterMs"],"sources":["../src/problem.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { CommandResult, Violation } from './wire.js';\n\n/**\n * The framework's error codes (design 05 §3, decisions D102, D103, D130),\n * each answered with the status of the Manifest's `errors` table. A domain\n * rejection has a code of its own, answered with 422 unless the service\n * configures another status.\n */\nexport const FrameworkErrorCodes = {\n /** 401: the request carries no valid credentials. */\n AUTH_UNAUTHENTICATED: 'wow.auth.unauthenticated',\n /** 403: the caller may not send this command. */\n AUTH_FORBIDDEN: 'wow.auth.forbidden',\n /** 403: the aggregate is outside the caller's scope. */\n AGGREGATE_FORBIDDEN: 'wow.aggregate.forbidden',\n /** 400: the command body cannot be read as the command type. */\n COMMAND_MALFORMED: 'wow.command.malformed',\n /** 400: the command failed validation; the problem lists the violations. */\n COMMAND_INVALID: 'wow.command.invalid',\n /** 400: the wait is not a chain the runtime can follow. */\n WAIT_INVALID: 'wow.wait.invalid',\n /** 400: the aggregate does not handle this command. */\n COMMAND_UNHANDLED: 'wow.command.unhandled',\n /** 404: the aggregate does not exist. */\n AGGREGATE_NOT_FOUND: 'wow.aggregate.not-found',\n /** 409: the aggregate already exists. */\n AGGREGATE_EXISTS: 'wow.aggregate.exists',\n /** 409, or 412 with `If-Match`: the aggregate is not at the expected version. */\n AGGREGATE_VERSION_MISMATCH: 'wow.aggregate.version-mismatch',\n /** 409: the request id was used by another command. */\n COMMAND_REQUEST_ID_REUSED: 'wow.command.request-id-reused',\n /** 409: concurrent writers kept winning; retrying with the same request id is safe. */\n COMMAND_CONTENDED: 'wow.command.contended',\n /** 410: the aggregate is deleted; only RestoreAggregate applies. */\n AGGREGATE_DELETED: 'wow.aggregate.deleted',\n /** 429: the command was not taken, its aggregate or the node being busy; retry later. */\n COMMAND_BUSY: 'wow.command.busy',\n /** 503: whether the command committed is unknown; retrying with the same request id is safe. */\n COMMAND_UNKNOWN: 'wow.command.unknown',\n /** 500: the command's handling failed with an unexpected error; it committed nothing, and a retry fails alike. */\n COMMAND_FAILED: 'wow.command.failed',\n /** 503: the node is shutting down; retry on another node. */\n NODE_CLOSING: 'wow.node.closing',\n /** 503: the node is on standby until a migration's cut-over; it serves reads only. */\n NODE_STANDBY: 'wow.node.standby',\n /** 503, with `Retry-After`: a store could not be reached in time; retry later. */\n STORAGE_UNAVAILABLE: 'wow.storage.unavailable',\n /** 503: a scheduled command arrived too long before its due time; it is sent again later. */\n SCHEDULE_NOT_DUE: 'wow.schedule.not-due',\n /** 400: the job command does not fit its job or instance (decision D198). */\n SCHEDULE_JOB_INVALID: 'wow.schedule.job-invalid',\n /** 500: a subscription on the wait chain parked the aggregate. */\n SUBSCRIPTION_PARKED: 'wow.subscription.parked',\n /** 504: the wait ran out of time; the command may have committed. */\n WAIT_TIMEOUT: 'wow.wait.timeout',\n /** 400: the query body cannot be read as a query. */\n QUERY_MALFORMED: 'wow.query.malformed',\n /** 400: the query failed admission; each violation has its code. */\n QUERY_INVALID: 'wow.query.invalid',\n /** 500: the query backend failed to run the query. */\n QUERY_FAILED: 'wow.query.failed',\n /** 504: the query ran longer than its budget allows; not retried (decision D254 ③). */\n QUERY_TIMEOUT: 'wow.query.timeout',\n /** 429, with `Retry-After`: the query's store runs as many queries as it allows; retry later. */\n QUERY_BUSY: 'wow.query.busy',\n /**\n * 404: a `single` query matched no record, whatever its model (review R4-Q,\n * Q-4); a state read by id that finds none is `wow.aggregate.not-found`.\n */\n QUERY_NOT_FOUND: 'wow.query.not-found',\n /** 404: no dataset of that name is served to the caller. */\n QUERY_DATASET_NOT_FOUND: 'wow.query.dataset-not-found',\n /**\n * 409, with `Retry-After`: a state read asked for a version (`minVersion`) the\n * aggregate has not reached within the wait; the problem's `version` is its\n * current one (review R4-Q, Q-13).\n */\n QUERY_MIN_VERSION_NOT_REACHED: 'wow.query.min-version-not-reached',\n /** 409: the dataset is served but cannot be queried now (it needs revision, decision D259). */\n QUERY_DATASET_UNAVAILABLE: 'wow.query.dataset-unavailable',\n /** 403: the calling service may not call this command (a synchronous call on the internal port, decision D226). */\n CALL_COMMAND_FORBIDDEN: 'wow.call.command-forbidden',\n} as const;\n\n/** A {@link FrameworkErrorCodes} value. */\nexport type FrameworkErrorCode =\n (typeof FrameworkErrorCodes)[keyof typeof FrameworkErrorCodes];\n\n/** The prefix of every framework code, and of no domain code. */\nexport const FRAMEWORK_ERROR_PREFIX = 'wow.';\n\n/** The prefix of a problem's `type` that carries a Wow code. */\nexport const PROBLEM_TYPE_PREFIX = 'urn:wow:error:';\n\n/**\n * An RFC 9457 problem as a Wow service writes it (decisions D101, D102):\n * `type` is `urn:wow:error:<code>`, or `about:blank` for an error that is\n * only HTTP's (a missing route, 406, 415).\n */\nexport interface Problem {\n readonly type: string;\n readonly title: string;\n readonly status: number;\n readonly detail?: string;\n /** The Wow code; absent for an error that is only HTTP's. */\n readonly code?: string;\n readonly violations?: readonly Violation[];\n /** The whole result of a command that has a ref. */\n readonly result?: CommandResult;\n /**\n * The problem's extension members (RFC 9457): every member the server\n * wrote besides the ones above and `instance`, such as a rejection's\n * structured data (decision D211). Absent when it wrote none.\n */\n readonly extensions?: Readonly<Record<string, unknown>>;\n}\n\n/** The members of a problem that are not extension members. */\nconst PROBLEM_MEMBERS: ReadonlySet<string> = new Set([\n 'type',\n 'title',\n 'status',\n 'detail',\n 'instance',\n 'code',\n 'violations',\n 'result',\n 'extensions',\n]);\n\n/**\n * `problem` with its extension members gathered as `extensions` (internal):\n * a problem read from the wire carries them as top-level members.\n */\nfunction withExtensions(problem: Problem): Problem {\n if (problem.extensions !== undefined) return problem;\n const extensions = Object.fromEntries(\n Object.entries(problem).filter(([name]) => !PROBLEM_MEMBERS.has(name)),\n );\n return Object.keys(extensions).length === 0\n ? problem\n : { ...problem, extensions };\n}\n\n/**\n * What a client may do about a failed request: whether retrying can succeed,\n * whether to keep the request id (`Wow-Request-Id`) so the server\n * deduplicates a command that did commit, and how long to wait first.\n */\nexport interface RetryHint {\n readonly retryable: boolean;\n /** Retry with the same `Wow-Request-Id`: a commit is then answered as a duplicate. */\n readonly sameRequestId: boolean;\n /** The server's `Retry-After`, in milliseconds. */\n readonly afterMs?: number;\n}\n\n/**\n * The codes a retry may get past, each with whether to keep the request id:\n * the 503s (`wow.command.unknown`, `wow.node.closing`, `wow.node.standby`,\n * `wow.storage.unavailable`, `wow.schedule.not-due`),\n * the 429s `wow.command.busy` and `wow.query.busy`, the 409s `wow.command.contended` and\n * `wow.query.min-version-not-reached` (once the command commits), and the 504\n * `wow.wait.timeout`, whose command may have committed.\n */\nconst RETRYABLE: ReadonlyMap<string, boolean> = new Map([\n [FrameworkErrorCodes.COMMAND_UNKNOWN, true],\n [FrameworkErrorCodes.NODE_CLOSING, true],\n [FrameworkErrorCodes.NODE_STANDBY, true],\n [FrameworkErrorCodes.STORAGE_UNAVAILABLE, true],\n [FrameworkErrorCodes.SCHEDULE_NOT_DUE, true],\n [FrameworkErrorCodes.COMMAND_BUSY, true],\n [FrameworkErrorCodes.QUERY_BUSY, false],\n [FrameworkErrorCodes.QUERY_MIN_VERSION_NOT_REACHED, false],\n [FrameworkErrorCodes.COMMAND_CONTENDED, true],\n [FrameworkErrorCodes.WAIT_TIMEOUT, true],\n]);\n\n/**\n * The retry hint of a problem with `code` and `status`: a code of the\n * retryable table, or a 503 without a code (a proxy's), may be retried.\n *\n * @param code - The problem's Wow code, if any\n * @param status - The HTTP status\n * @param afterMs - The `Retry-After` the response carried, in milliseconds\n */\nexport function retryHintOf(\n code: string | undefined,\n status: number,\n afterMs?: number,\n): RetryHint {\n const sameRequestId = code === undefined ? undefined : RETRYABLE.get(code);\n const retryable =\n sameRequestId !== undefined || (code === undefined && status === 503);\n return {\n retryable,\n sameRequestId: sameRequestId ?? retryable,\n ...(afterMs === undefined ? {} : { afterMs }),\n };\n}\n\n/**\n * A request a Wow service answered with a problem: a non-2xx response, a\n * command result that did not succeed, or the `error` event that ends a\n * streamed query.\n */\nexport class WowProblemError extends Error {\n override readonly name = 'WowProblemError';\n /** The problem as the server wrote it. */\n readonly problem: Problem;\n /** The HTTP status. */\n readonly status: number;\n /** The Wow code; absent for an error that is only HTTP's. */\n readonly code?: string;\n readonly violations: readonly Violation[];\n /** The command's result, when the command had a ref. */\n readonly result?: CommandResult;\n /** What a client may do about it. */\n readonly retry: RetryHint;\n /** The error this one explains: the fetcher's, or the stream's. */\n readonly cause?: unknown;\n\n /**\n * The request id (`Wow-Request-Id`) of the command this answers: its\n * result's, else the one the client sent. Retry with it when\n * {@link RetryHint.sameRequestId} says so.\n */\n get requestId(): string | undefined {\n return this.result?.requestId ?? SENT_REQUEST_IDS.get(this);\n }\n\n /**\n * @param problem - The problem the server answered with\n * @param options - The response's `Retry-After` in milliseconds, and the\n * error this one explains\n */\n constructor(\n problem: Problem,\n options: { retryAfterMs?: number; cause?: unknown } = {},\n ) {\n super(\n problem.code\n ? `[${problem.code}] ${problem.detail ?? problem.title}`\n : `${problem.status} ${problem.detail ?? problem.title}`,\n );\n this.problem = withExtensions(problem);\n this.status = problem.status;\n if (problem.code !== undefined) this.code = problem.code;\n this.violations = problem.violations ?? [];\n if (problem.result !== undefined) this.result = problem.result;\n this.retry = retryHintOf(\n problem.code,\n problem.status,\n options.retryAfterMs,\n );\n if (options.cause !== undefined) this.cause = options.cause;\n }\n\n /** Whether the code is a framework one (`wow.*`) rather than the domain's. */\n get isFramework(): boolean {\n return this.code?.startsWith(FRAMEWORK_ERROR_PREFIX) ?? false;\n }\n}\n\n/** The request ids the client sent, by the errors the requests failed with. */\nconst SENT_REQUEST_IDS = new WeakMap<object, string>();\n\n/**\n * Remembers that the request that failed with `error` was sent with\n * `requestId` (internal): {@link requestIdOf} answers it.\n *\n * @param error - What the request failed with\n * @param requestId - The `Wow-Request-Id` it was sent with\n */\nexport function rememberRequestId(error: unknown, requestId: string): void {\n if (\n (typeof error === 'object' && error !== null) ||\n typeof error === 'function'\n ) {\n if (!SENT_REQUEST_IDS.has(error)) SENT_REQUEST_IDS.set(error, requestId);\n }\n}\n\n/**\n * The request id (`Wow-Request-Id`) a command that failed with `error` was\n * sent with: also after a failure no server answered (the network, a proxy,\n * an abort), so the command can be retried with the same id and the service\n * answers a commit that did happen as a duplicate (decision D223).\n * Undefined for an error of no command the client sent.\n *\n * @param error - What a command rejected with\n */\nexport function requestIdOf(error: unknown): string | undefined {\n if (error instanceof WowProblemError) return error.requestId;\n return (typeof error === 'object' && error !== null) ||\n typeof error === 'function'\n ? SENT_REQUEST_IDS.get(error)\n : undefined;\n}\n\n/** Whether `value` reads as a problem: an object with a numeric `status`. */\nexport function isProblem(value: unknown): value is Problem {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as { status?: unknown }).status === 'number'\n );\n}\n\n/**\n * The milliseconds of a `Retry-After` header: delay seconds or an HTTP date.\n *\n * @param value - The header's value\n * @param now - The current time, in epoch milliseconds\n */\nexport function parseRetryAfter(\n value: string | null | undefined,\n now: number = Date.now(),\n): number | undefined {\n if (!value) return undefined;\n const trimmed = value.trim();\n if (/^\\d+$/.test(trimmed)) return Number(trimmed) * 1000;\n const date = Date.parse(trimmed);\n return Number.isNaN(date) ? undefined : Math.max(0, date - now);\n}\n\n/**\n * The problem a response that did not succeed carries: its body when it is\n * a problem (or a code the `type` names), else one made of its status.\n *\n * @param response - A response that is not 2xx\n */\nexport async function readProblem(response: Response): Promise<Problem> {\n let body: unknown;\n try {\n body = await response.clone().json();\n } catch {\n // Not JSON, or already read: the status is all there is.\n }\n if (isProblem(body)) {\n const code =\n body.code ??\n (body.type?.startsWith(PROBLEM_TYPE_PREFIX)\n ? body.type.slice(PROBLEM_TYPE_PREFIX.length)\n : undefined);\n return withExtensions({\n ...body,\n type: body.type ?? 'about:blank',\n title: body.title ?? response.statusText,\n ...(code === undefined ? {} : { code }),\n });\n }\n return {\n type: 'about:blank',\n title: response.statusText,\n status: response.status,\n };\n}\n\ninterface ExchangeLike {\n exchange?: { response?: Response };\n cause?: unknown;\n}\n\n/**\n * The {@link WowProblemError} of an error a request rejected with: the\n * fetcher's `ExchangeError` of a response that is not 2xx, read as a problem.\n * Undefined for a failure no server answered (a network error, an abort).\n *\n * @param error - What the request rejected with\n */\nexport async function toWowProblemError(\n error: unknown,\n): Promise<WowProblemError | undefined> {\n if (error instanceof WowProblemError) return error;\n if (typeof error !== 'object' || error === null) return undefined;\n const { exchange, cause } = error as ExchangeLike;\n if (cause instanceof WowProblemError) return cause;\n const response = exchange?.response;\n if (!response || response.ok) return undefined;\n const problem = await readProblem(response);\n const retryAfterMs = parseRetryAfter(response.headers.get('Retry-After'));\n return new WowProblemError(problem, {\n cause: error,\n ...(retryAfterMs === undefined ? {} : { retryAfterMs }),\n });\n}\n"],"mappings":"AAqBA,IAAaA,EAAsB,CAEjC,qBAAsB,2BAEtB,eAAgB,qBAEhB,oBAAqB,0BAErB,kBAAmB,wBAEnB,gBAAiB,sBAEjB,aAAc,mBAEd,kBAAmB,wBAEnB,oBAAqB,0BAErB,iBAAkB,uBAElB,2BAA4B,iCAE5B,0BAA2B,gCAE3B,kBAAmB,wBAEnB,kBAAmB,wBAEnB,aAAc,mBAEd,gBAAiB,sBAEjB,eAAgB,qBAEhB,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