@ahoo-wang/wow-client 9.9.0 → 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 (385) 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/commands.d.cts +123 -0
  6. package/dist/commands.d.ts +123 -0
  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 +8 -1
  19. package/dist/dsl/descriptor.d.ts +8 -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/http.d.cts +96 -0
  48. package/dist/http.d.ts +96 -0
  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 +2 -0
  56. package/dist/manifest.cjs.map +1 -0
  57. package/dist/manifest.d.cts +109 -0
  58. package/dist/manifest.d.ts +109 -0
  59. package/dist/manifest.es.js +14 -0
  60. package/dist/manifest.es.js.map +1 -0
  61. package/dist/problem.cjs +2 -0
  62. package/dist/problem.cjs.map +1 -0
  63. package/dist/problem.d.cts +211 -0
  64. package/dist/problem.d.ts +211 -0
  65. package/dist/problem.es.js +138 -0
  66. package/dist/problem.es.js.map +1 -0
  67. package/dist/queries.cjs +2 -0
  68. package/dist/queries.cjs.map +1 -0
  69. package/dist/queries.d.cts +182 -0
  70. package/dist/queries.d.ts +182 -0
  71. package/dist/queries.es.js +112 -0
  72. package/dist/queries.es.js.map +1 -0
  73. package/dist/state.cjs +2 -0
  74. package/dist/state.cjs.map +1 -0
  75. package/dist/state.d.cts +75 -0
  76. package/dist/state.d.ts +75 -0
  77. package/dist/state.es.js +70 -0
  78. package/dist/state.es.js.map +1 -0
  79. package/dist/streams.cjs +2 -0
  80. package/dist/streams.cjs.map +1 -0
  81. package/dist/streams.d.cts +74 -0
  82. package/dist/streams.d.ts +74 -0
  83. package/dist/streams.es.js +103 -0
  84. package/dist/streams.es.js.map +1 -0
  85. package/dist/wait.cjs +2 -0
  86. package/dist/wait.cjs.map +1 -0
  87. package/dist/wait.d.cts +61 -0
  88. package/dist/wait.d.ts +61 -0
  89. package/dist/wait.es.js +44 -0
  90. package/dist/wait.es.js.map +1 -0
  91. package/dist/wire.cjs +2 -0
  92. package/dist/wire.cjs.map +1 -0
  93. package/dist/wire.d.cts +326 -0
  94. package/dist/wire.d.ts +326 -0
  95. package/dist/wire.es.js +10 -0
  96. package/dist/wire.es.js.map +1 -0
  97. package/package.json +4 -16
  98. package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorate.cjs +0 -1
  99. package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorate.es.js +0 -9
  100. package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorateMetadata.cjs +0 -1
  101. package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorateMetadata.es.js +0 -6
  102. package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorateParam.cjs +0 -1
  103. package/dist/_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/decorateParam.es.js +0 -8
  104. package/dist/client/bindMethods.cjs +0 -2
  105. package/dist/client/bindMethods.cjs.map +0 -1
  106. package/dist/client/bindMethods.d.cts +0 -13
  107. package/dist/client/bindMethods.d.ts +0 -13
  108. package/dist/client/bindMethods.es.js +0 -19
  109. package/dist/client/bindMethods.es.js.map +0 -1
  110. package/dist/client/command/commandClient.cjs +0 -2
  111. package/dist/client/command/commandClient.cjs.map +0 -1
  112. package/dist/client/command/commandClient.d.cts +0 -67
  113. package/dist/client/command/commandClient.d.ts +0 -67
  114. package/dist/client/command/commandClient.es.js +0 -38
  115. package/dist/client/command/commandClient.es.js.map +0 -1
  116. package/dist/client/command/commandHeaders.cjs +0 -2
  117. package/dist/client/command/commandHeaders.cjs.map +0 -1
  118. package/dist/client/command/commandHeaders.d.cts +0 -75
  119. package/dist/client/command/commandHeaders.d.ts +0 -75
  120. package/dist/client/command/commandHeaders.es.js +0 -31
  121. package/dist/client/command/commandHeaders.es.js.map +0 -1
  122. package/dist/client/command/commandRequest.cjs +0 -2
  123. package/dist/client/command/commandRequest.cjs.map +0 -1
  124. package/dist/client/command/commandRequest.d.cts +0 -180
  125. package/dist/client/command/commandRequest.d.ts +0 -180
  126. package/dist/client/command/commandRequest.es.js +0 -31
  127. package/dist/client/command/commandRequest.es.js.map +0 -1
  128. package/dist/client/command/commandResult.d.cts +0 -15
  129. package/dist/client/command/commandResult.d.ts +0 -15
  130. package/dist/client/command/index.d.cts +0 -5
  131. package/dist/client/command/index.d.ts +0 -5
  132. package/dist/client/command/types.d.cts +0 -71
  133. package/dist/client/command/types.d.ts +0 -71
  134. package/dist/client/metadata/index.d.cts +0 -2
  135. package/dist/client/metadata/index.d.ts +0 -2
  136. package/dist/client/metadata/wowMetadata.d.cts +0 -48
  137. package/dist/client/metadata/wowMetadata.d.ts +0 -48
  138. package/dist/client/metadata/wowMetadataClient.cjs +0 -2
  139. package/dist/client/metadata/wowMetadataClient.cjs.map +0 -1
  140. package/dist/client/metadata/wowMetadataClient.d.cts +0 -23
  141. package/dist/client/metadata/wowMetadataClient.d.ts +0 -23
  142. package/dist/client/metadata/wowMetadataClient.es.js +0 -25
  143. package/dist/client/metadata/wowMetadataClient.es.js.map +0 -1
  144. package/dist/client/query/dataset/datasetDescriptorEndpoint.cjs +0 -2
  145. package/dist/client/query/dataset/datasetDescriptorEndpoint.cjs.map +0 -1
  146. package/dist/client/query/dataset/datasetDescriptorEndpoint.d.cts +0 -8
  147. package/dist/client/query/dataset/datasetDescriptorEndpoint.d.ts +0 -8
  148. package/dist/client/query/dataset/datasetDescriptorEndpoint.es.js +0 -34
  149. package/dist/client/query/dataset/datasetDescriptorEndpoint.es.js.map +0 -1
  150. package/dist/client/query/dataset/datasetDirectoryClient.cjs +0 -2
  151. package/dist/client/query/dataset/datasetDirectoryClient.cjs.map +0 -1
  152. package/dist/client/query/dataset/datasetDirectoryClient.d.cts +0 -29
  153. package/dist/client/query/dataset/datasetDirectoryClient.d.ts +0 -29
  154. package/dist/client/query/dataset/datasetDirectoryClient.es.js +0 -25
  155. package/dist/client/query/dataset/datasetDirectoryClient.es.js.map +0 -1
  156. package/dist/client/query/dataset/datasetQueryApi.d.cts +0 -40
  157. package/dist/client/query/dataset/datasetQueryApi.d.ts +0 -40
  158. package/dist/client/query/dataset/datasetQueryClient.cjs +0 -2
  159. package/dist/client/query/dataset/datasetQueryClient.cjs.map +0 -1
  160. package/dist/client/query/dataset/datasetQueryClient.d.cts +0 -57
  161. package/dist/client/query/dataset/datasetQueryClient.d.ts +0 -57
  162. package/dist/client/query/dataset/datasetQueryClient.es.js +0 -154
  163. package/dist/client/query/dataset/datasetQueryClient.es.js.map +0 -1
  164. package/dist/client/query/dataset/endpointPaths.cjs +0 -2
  165. package/dist/client/query/dataset/endpointPaths.cjs.map +0 -1
  166. package/dist/client/query/dataset/endpointPaths.d.cts +0 -9
  167. package/dist/client/query/dataset/endpointPaths.d.ts +0 -9
  168. package/dist/client/query/dataset/endpointPaths.es.js +0 -14
  169. package/dist/client/query/dataset/endpointPaths.es.js.map +0 -1
  170. package/dist/client/query/dataset/index.d.cts +0 -3
  171. package/dist/client/query/dataset/index.d.ts +0 -3
  172. package/dist/client/query/descriptor/descriptorEndpoints.cjs +0 -2
  173. package/dist/client/query/descriptor/descriptorEndpoints.cjs.map +0 -1
  174. package/dist/client/query/descriptor/descriptorEndpoints.d.cts +0 -29
  175. package/dist/client/query/descriptor/descriptorEndpoints.d.ts +0 -29
  176. package/dist/client/query/descriptor/descriptorEndpoints.es.js +0 -69
  177. package/dist/client/query/descriptor/descriptorEndpoints.es.js.map +0 -1
  178. package/dist/client/query/descriptor/endpointPaths.cjs +0 -2
  179. package/dist/client/query/descriptor/endpointPaths.cjs.map +0 -1
  180. package/dist/client/query/descriptor/endpointPaths.d.cts +0 -4
  181. package/dist/client/query/descriptor/endpointPaths.d.ts +0 -4
  182. package/dist/client/query/descriptor/endpointPaths.es.js +0 -9
  183. package/dist/client/query/descriptor/endpointPaths.es.js.map +0 -1
  184. package/dist/client/query/descriptor/index.d.cts +0 -2
  185. package/dist/client/query/descriptor/index.d.ts +0 -2
  186. package/dist/client/query/descriptor/queryDescriptorApi.d.cts +0 -58
  187. package/dist/client/query/descriptor/queryDescriptorApi.d.ts +0 -58
  188. package/dist/client/query/descriptor/queryDescriptorClient.cjs +0 -2
  189. package/dist/client/query/descriptor/queryDescriptorClient.cjs.map +0 -1
  190. package/dist/client/query/descriptor/queryDescriptorClient.d.cts +0 -61
  191. package/dist/client/query/descriptor/queryDescriptorClient.d.ts +0 -61
  192. package/dist/client/query/descriptor/queryDescriptorClient.es.js +0 -20
  193. package/dist/client/query/descriptor/queryDescriptorClient.es.js.map +0 -1
  194. package/dist/client/query/event/endpointPaths.cjs +0 -2
  195. package/dist/client/query/event/endpointPaths.cjs.map +0 -1
  196. package/dist/client/query/event/endpointPaths.d.cts +0 -8
  197. package/dist/client/query/event/endpointPaths.d.ts +0 -8
  198. package/dist/client/query/event/endpointPaths.es.js +0 -13
  199. package/dist/client/query/event/endpointPaths.es.js.map +0 -1
  200. package/dist/client/query/event/eventStreamQueryApi.d.cts +0 -29
  201. package/dist/client/query/event/eventStreamQueryApi.d.ts +0 -29
  202. package/dist/client/query/event/eventStreamQueryClient.cjs +0 -2
  203. package/dist/client/query/event/eventStreamQueryClient.cjs.map +0 -1
  204. package/dist/client/query/event/eventStreamQueryClient.d.cts +0 -193
  205. package/dist/client/query/event/eventStreamQueryClient.d.ts +0 -193
  206. package/dist/client/query/event/eventStreamQueryClient.es.js +0 -160
  207. package/dist/client/query/event/eventStreamQueryClient.es.js.map +0 -1
  208. package/dist/client/query/event/index.d.cts +0 -2
  209. package/dist/client/query/event/index.d.ts +0 -2
  210. package/dist/client/query/factory.cjs +0 -2
  211. package/dist/client/query/factory.cjs.map +0 -1
  212. package/dist/client/query/factory.d.cts +0 -165
  213. package/dist/client/query/factory.d.ts +0 -165
  214. package/dist/client/query/factory.es.js +0 -45
  215. package/dist/client/query/factory.es.js.map +0 -1
  216. package/dist/client/query/index.d.cts +0 -7
  217. package/dist/client/query/index.d.ts +0 -7
  218. package/dist/client/query/queryApi.d.cts +0 -68
  219. package/dist/client/query/queryApi.d.ts +0 -68
  220. package/dist/client/query/requests.d.cts +0 -24
  221. package/dist/client/query/requests.d.ts +0 -24
  222. package/dist/client/query/snapshot/endpointPaths.cjs +0 -2
  223. package/dist/client/query/snapshot/endpointPaths.cjs.map +0 -1
  224. package/dist/client/query/snapshot/endpointPaths.d.cts +0 -12
  225. package/dist/client/query/snapshot/endpointPaths.d.ts +0 -12
  226. package/dist/client/query/snapshot/endpointPaths.es.js +0 -17
  227. package/dist/client/query/snapshot/endpointPaths.es.js.map +0 -1
  228. package/dist/client/query/snapshot/index.d.cts +0 -2
  229. package/dist/client/query/snapshot/index.d.ts +0 -2
  230. package/dist/client/query/snapshot/snapshotQueryApi.d.cts +0 -101
  231. package/dist/client/query/snapshot/snapshotQueryApi.d.ts +0 -101
  232. package/dist/client/query/snapshot/snapshotQueryClient.cjs +0 -2
  233. package/dist/client/query/snapshot/snapshotQueryClient.cjs.map +0 -1
  234. package/dist/client/query/snapshot/snapshotQueryClient.d.cts +0 -372
  235. package/dist/client/query/snapshot/snapshotQueryClient.d.ts +0 -372
  236. package/dist/client/query/snapshot/snapshotQueryClient.es.js +0 -239
  237. package/dist/client/query/snapshot/snapshotQueryClient.es.js.map +0 -1
  238. package/dist/client/query/state/endpointPaths.cjs +0 -2
  239. package/dist/client/query/state/endpointPaths.cjs.map +0 -1
  240. package/dist/client/query/state/endpointPaths.d.cts +0 -10
  241. package/dist/client/query/state/endpointPaths.d.ts +0 -10
  242. package/dist/client/query/state/endpointPaths.es.js +0 -14
  243. package/dist/client/query/state/endpointPaths.es.js.map +0 -1
  244. package/dist/client/query/state/index.d.cts +0 -4
  245. package/dist/client/query/state/index.d.ts +0 -4
  246. package/dist/client/query/state/loadOwnerStateAggregateApi.d.cts +0 -36
  247. package/dist/client/query/state/loadOwnerStateAggregateApi.d.ts +0 -36
  248. package/dist/client/query/state/loadOwnerStateAggregateClient.cjs +0 -2
  249. package/dist/client/query/state/loadOwnerStateAggregateClient.cjs.map +0 -1
  250. package/dist/client/query/state/loadOwnerStateAggregateClient.d.cts +0 -58
  251. package/dist/client/query/state/loadOwnerStateAggregateClient.d.ts +0 -58
  252. package/dist/client/query/state/loadOwnerStateAggregateClient.es.js +0 -56
  253. package/dist/client/query/state/loadOwnerStateAggregateClient.es.js.map +0 -1
  254. package/dist/client/query/state/loadStateAggregateApi.d.cts +0 -37
  255. package/dist/client/query/state/loadStateAggregateApi.d.ts +0 -37
  256. package/dist/client/query/state/loadStateAggregateClient.cjs +0 -2
  257. package/dist/client/query/state/loadStateAggregateClient.cjs.map +0 -1
  258. package/dist/client/query/state/loadStateAggregateClient.d.cts +0 -62
  259. package/dist/client/query/state/loadStateAggregateClient.d.ts +0 -62
  260. package/dist/client/query/state/loadStateAggregateClient.es.js +0 -65
  261. package/dist/client/query/state/loadStateAggregateClient.es.js.map +0 -1
  262. package/dist/client/routing.cjs +0 -2
  263. package/dist/client/routing.cjs.map +0 -1
  264. package/dist/client/routing.d.cts +0 -47
  265. package/dist/client/routing.d.ts +0 -47
  266. package/dist/client/routing.es.js +0 -8
  267. package/dist/client/routing.es.js.map +0 -1
  268. package/dist/error/errorInfo.cjs +0 -2
  269. package/dist/error/errorInfo.cjs.map +0 -1
  270. package/dist/error/errorInfo.d.cts +0 -139
  271. package/dist/error/errorInfo.d.ts +0 -139
  272. package/dist/error/errorInfo.es.js +0 -32
  273. package/dist/error/errorInfo.es.js.map +0 -1
  274. package/dist/error/headers.cjs +0 -2
  275. package/dist/error/headers.cjs.map +0 -1
  276. package/dist/error/headers.d.cts +0 -39
  277. package/dist/error/headers.d.ts +0 -39
  278. package/dist/error/headers.es.js +0 -10
  279. package/dist/error/headers.es.js.map +0 -1
  280. package/dist/error/index.d.cts +0 -21
  281. package/dist/error/index.d.ts +0 -21
  282. package/dist/error/queryErrorCodes.cjs +0 -2
  283. package/dist/error/queryErrorCodes.es.js.map +0 -1
  284. package/dist/error/wowError.cjs +0 -2
  285. package/dist/error/wowError.cjs.map +0 -1
  286. package/dist/error/wowError.d.cts +0 -99
  287. package/dist/error/wowError.d.ts +0 -99
  288. package/dist/error/wowError.es.js +0 -53
  289. package/dist/error/wowError.es.js.map +0 -1
  290. package/dist/legacy/condition.cjs +0 -2
  291. package/dist/legacy/condition.cjs.map +0 -1
  292. package/dist/legacy/condition.d.cts +0 -517
  293. package/dist/legacy/condition.d.ts +0 -517
  294. package/dist/legacy/condition.es.js +0 -338
  295. package/dist/legacy/condition.es.js.map +0 -1
  296. package/dist/legacy/index.d.cts +0 -16
  297. package/dist/legacy/index.d.ts +0 -16
  298. package/dist/legacy/locale/en_US.cjs +0 -2
  299. package/dist/legacy/locale/en_US.cjs.map +0 -1
  300. package/dist/legacy/locale/en_US.d.cts +0 -7
  301. package/dist/legacy/locale/en_US.d.ts +0 -7
  302. package/dist/legacy/locale/en_US.es.js +0 -50
  303. package/dist/legacy/locale/en_US.es.js.map +0 -1
  304. package/dist/legacy/locale/operatorLocale.d.cts +0 -10
  305. package/dist/legacy/locale/operatorLocale.d.ts +0 -10
  306. package/dist/legacy/locale/zh_CN.cjs +0 -2
  307. package/dist/legacy/locale/zh_CN.cjs.map +0 -1
  308. package/dist/legacy/locale/zh_CN.d.cts +0 -7
  309. package/dist/legacy/locale/zh_CN.d.ts +0 -7
  310. package/dist/legacy/locale/zh_CN.es.js +0 -50
  311. package/dist/legacy/locale/zh_CN.es.js.map +0 -1
  312. package/dist/legacy/operator.cjs +0 -2
  313. package/dist/legacy/operator.cjs.map +0 -1
  314. package/dist/legacy/operator.d.cts +0 -218
  315. package/dist/legacy/operator.d.ts +0 -218
  316. package/dist/legacy/operator.es.js +0 -25
  317. package/dist/legacy/operator.es.js.map +0 -1
  318. package/dist/legacy/queryable.cjs +0 -2
  319. package/dist/legacy/queryable.cjs.map +0 -1
  320. package/dist/legacy/queryable.d.cts +0 -61
  321. package/dist/legacy/queryable.d.ts +0 -61
  322. package/dist/legacy/queryable.es.js +0 -34
  323. package/dist/legacy/queryable.es.js.map +0 -1
  324. package/dist/legacy.cjs +0 -1
  325. package/dist/legacy.es.js +0 -6
  326. package/dist/model/abac.cjs +0 -2
  327. package/dist/model/abac.cjs.map +0 -1
  328. package/dist/model/abac.d.cts +0 -33
  329. package/dist/model/abac.d.ts +0 -33
  330. package/dist/model/abac.es.js +0 -6
  331. package/dist/model/abac.es.js.map +0 -1
  332. package/dist/model/bi.cjs +0 -2
  333. package/dist/model/bi.cjs.map +0 -1
  334. package/dist/model/bi.d.cts +0 -12
  335. package/dist/model/bi.d.ts +0 -12
  336. package/dist/model/bi.es.js +0 -8
  337. package/dist/model/bi.es.js.map +0 -1
  338. package/dist/model/command.cjs +0 -2
  339. package/dist/model/command.cjs.map +0 -1
  340. package/dist/model/command.d.cts +0 -137
  341. package/dist/model/command.d.ts +0 -137
  342. package/dist/model/command.es.js +0 -8
  343. package/dist/model/command.es.js.map +0 -1
  344. package/dist/model/common.d.cts +0 -19
  345. package/dist/model/common.d.ts +0 -19
  346. package/dist/model/domainEventStream.cjs +0 -2
  347. package/dist/model/domainEventStream.cjs.map +0 -1
  348. package/dist/model/domainEventStream.d.cts +0 -109
  349. package/dist/model/domainEventStream.d.ts +0 -109
  350. package/dist/model/domainEventStream.es.js +0 -23
  351. package/dist/model/domainEventStream.es.js.map +0 -1
  352. package/dist/model/function.cjs +0 -2
  353. package/dist/model/function.cjs.map +0 -1
  354. package/dist/model/function.d.cts +0 -41
  355. package/dist/model/function.d.ts +0 -41
  356. package/dist/model/function.es.js +0 -8
  357. package/dist/model/function.es.js.map +0 -1
  358. package/dist/model/index.d.cts +0 -24
  359. package/dist/model/index.d.ts +0 -24
  360. package/dist/model/messaging.d.cts +0 -5
  361. package/dist/model/messaging.d.ts +0 -5
  362. package/dist/model/modeling.d.cts +0 -145
  363. package/dist/model/modeling.d.ts +0 -145
  364. package/dist/model/naming.d.cts +0 -27
  365. package/dist/model/naming.d.ts +0 -27
  366. package/dist/model/snapshot.cjs +0 -2
  367. package/dist/model/snapshot.cjs.map +0 -1
  368. package/dist/model/snapshot.d.cts +0 -53
  369. package/dist/model/snapshot.d.ts +0 -53
  370. package/dist/model/snapshot.es.js +0 -20
  371. package/dist/model/snapshot.es.js.map +0 -1
  372. package/dist/transport/endpoints.cjs +0 -2
  373. package/dist/transport/endpoints.cjs.map +0 -1
  374. package/dist/transport/endpoints.d.cts +0 -79
  375. package/dist/transport/endpoints.d.ts +0 -79
  376. package/dist/transport/endpoints.es.js +0 -14
  377. package/dist/transport/endpoints.es.js.map +0 -1
  378. package/dist/transport/eventStreams.cjs +0 -2
  379. package/dist/transport/eventStreams.cjs.map +0 -1
  380. package/dist/transport/eventStreams.d.cts +0 -25
  381. package/dist/transport/eventStreams.d.ts +0 -25
  382. package/dist/transport/eventStreams.es.js +0 -21
  383. package/dist/transport/eventStreams.es.js.map +0 -1
  384. package/dist/transport/index.d.cts +0 -1
  385. package/dist/transport/index.d.ts +0 -1
@@ -0,0 +1,213 @@
1
+ //#region src/exactJson.ts
2
+ var e = Symbol("wow.textNumbersBy");
3
+ function t(t, n, r) {
4
+ return { [e]: {
5
+ discriminant: t,
6
+ member: n,
7
+ cases: r
8
+ } };
9
+ }
10
+ function n(t) {
11
+ return t === void 0 ? !0 : t === !0 ? !1 : e in t ? Object.values(t[e].cases).every(n) : Object.values(t).every(n);
12
+ }
13
+ var r = class {
14
+ constructor(e) {
15
+ this.text = e;
16
+ }
17
+ };
18
+ function i(t, n) {
19
+ if (!(t === void 0 || t === !0 || e in t)) return Object.prototype.hasOwnProperty.call(t, n) ? t[n] : Object.prototype.hasOwnProperty.call(t, "*") ? t["*"] : void 0;
20
+ }
21
+ function a(e, t, n) {
22
+ t === "__proto__" ? Object.defineProperty(e, t, {
23
+ value: n,
24
+ writable: !0,
25
+ enumerable: !0,
26
+ configurable: !0
27
+ }) : e[t] = n;
28
+ }
29
+ function o(t, n) {
30
+ if (t instanceof r) return n === !0 ? t.text : Number(t.text);
31
+ if (Array.isArray(t)) {
32
+ for (let e = 0; e < t.length; e++) t[e] = o(t[e], i(n, String(e)));
33
+ return t;
34
+ }
35
+ if (typeof t == "object" && t) {
36
+ let r = t, s = n !== void 0 && n !== !0 && e in n ? n[e] : void 0, c = s === void 0 ? void 0 : r[s.discriminant];
37
+ for (let e of Object.keys(r)) {
38
+ let t = s === void 0 ? i(n, e) : e === s.member && typeof c == "string" ? s.cases[c] : void 0;
39
+ a(r, e, o(r[e], t));
40
+ }
41
+ }
42
+ return t;
43
+ }
44
+ var s = {
45
+ TAB: 9,
46
+ LF: 10,
47
+ CR: 13,
48
+ SPACE: 32,
49
+ QUOTE: 34,
50
+ PLUS: 43,
51
+ COMMA: 44,
52
+ MINUS: 45,
53
+ DOT: 46,
54
+ ZERO: 48,
55
+ NINE: 57,
56
+ COLON: 58,
57
+ UPPER_E: 69,
58
+ OPEN_BRACKET: 91,
59
+ BACKSLASH: 92,
60
+ CLOSE_BRACKET: 93,
61
+ LOWER_E: 101,
62
+ OPEN_BRACE: 123,
63
+ CLOSE_BRACE: 125
64
+ }, c = {
65
+ "\"": "\"",
66
+ "\\": "\\",
67
+ "/": "/",
68
+ b: "\b",
69
+ f: "\f",
70
+ n: "\n",
71
+ r: "\r",
72
+ t: " "
73
+ }, l = class {
74
+ constructor(e) {
75
+ this.text = e, this.at = 0;
76
+ }
77
+ parse(e) {
78
+ this.skipSpaces();
79
+ let t = this.value(e, !1);
80
+ return this.skipSpaces(), this.at < this.text.length && this.fail(), t;
81
+ }
82
+ value(e, t) {
83
+ switch (this.text.charCodeAt(this.at)) {
84
+ case s.OPEN_BRACE: return this.object(e, t);
85
+ case s.OPEN_BRACKET: return this.array(e, t);
86
+ case s.QUOTE: return this.string();
87
+ case 116: return this.literal("true", !0);
88
+ case 102: return this.literal("false", !1);
89
+ case 110: return this.literal("null", null);
90
+ default: {
91
+ let n = this.number();
92
+ return t ? new r(n) : e === !0 ? n : Number(n);
93
+ }
94
+ }
95
+ }
96
+ object(t, n) {
97
+ this.at++;
98
+ let r = {}, c = !n && t !== void 0 && t !== !0 && e in t ? t[e] : void 0;
99
+ if (this.skipSpaces(), this.text.charCodeAt(this.at) === s.CLOSE_BRACE) return this.at++, r;
100
+ for (;;) {
101
+ this.text.charCodeAt(this.at) !== s.QUOTE && this.fail();
102
+ let e = this.string();
103
+ this.skipSpaces(), this.expect(s.COLON), this.skipSpaces(), a(r, e, c !== void 0 && e === c.member ? this.value(void 0, !0) : this.value(n ? void 0 : i(t, e), n)), this.skipSpaces();
104
+ let o = this.text.charCodeAt(this.at++);
105
+ if (o === s.CLOSE_BRACE) break;
106
+ o !== s.COMMA && this.fail(this.at - 1), this.skipSpaces();
107
+ }
108
+ if (c !== void 0 && Object.prototype.hasOwnProperty.call(r, c.member)) {
109
+ let e = r[c.discriminant];
110
+ a(r, c.member, o(r[c.member], typeof e == "string" ? c.cases[e] : void 0));
111
+ }
112
+ return r;
113
+ }
114
+ array(e, t) {
115
+ this.at++;
116
+ let n = [];
117
+ if (this.skipSpaces(), this.text.charCodeAt(this.at) === s.CLOSE_BRACKET) return this.at++, n;
118
+ let r = t ? void 0 : i(e, "*");
119
+ for (;;) {
120
+ n.push(this.value(r, t)), this.skipSpaces();
121
+ let e = this.text.charCodeAt(this.at++);
122
+ if (e === s.CLOSE_BRACKET) return n;
123
+ e !== s.COMMA && this.fail(this.at - 1), this.skipSpaces();
124
+ }
125
+ }
126
+ string() {
127
+ let e = this.text, t = ++this.at, n = "";
128
+ for (;;) {
129
+ let r = e.charCodeAt(this.at);
130
+ if (r === s.QUOTE) return n += e.slice(t, this.at++), n;
131
+ if (r === s.BACKSLASH) {
132
+ n += e.slice(t, this.at);
133
+ let r = e[this.at + 1];
134
+ if (r === "u") {
135
+ let t = e.slice(this.at + 2, this.at + 6);
136
+ /^[0-9a-fA-F]{4}$/.test(t) || this.fail(this.at), n += String.fromCharCode(Number.parseInt(t, 16)), this.at += 6;
137
+ } else {
138
+ let e = r === void 0 ? void 0 : c[r];
139
+ e === void 0 && this.fail(this.at), n += e, this.at += 2;
140
+ }
141
+ t = this.at;
142
+ } else r < s.SPACE || Number.isNaN(r) ? this.fail() : this.at++;
143
+ }
144
+ }
145
+ number() {
146
+ let e = this.text, t = this.at;
147
+ e.charCodeAt(this.at) === s.MINUS && this.at++;
148
+ let n = e.charCodeAt(this.at);
149
+ n === s.ZERO ? this.at++ : n > s.ZERO && n <= s.NINE ? this.digits() : this.fail(), e.charCodeAt(this.at) === s.DOT && (this.at++, this.digits() || this.fail());
150
+ let r = e.charCodeAt(this.at);
151
+ if (r === s.LOWER_E || r === s.UPPER_E) {
152
+ this.at++;
153
+ let t = e.charCodeAt(this.at);
154
+ (t === s.PLUS || t === s.MINUS) && this.at++, this.digits() || this.fail();
155
+ }
156
+ return e.slice(t, this.at);
157
+ }
158
+ digits() {
159
+ let e = this.at, t = this.text.charCodeAt(this.at);
160
+ for (; t >= s.ZERO && t <= s.NINE;) t = this.text.charCodeAt(++this.at);
161
+ return this.at > e;
162
+ }
163
+ literal(e, t) {
164
+ return this.text.startsWith(e, this.at) || this.fail(), this.at += e.length, t;
165
+ }
166
+ skipSpaces() {
167
+ let e = this.text.charCodeAt(this.at);
168
+ for (; e === s.SPACE || e === s.LF || e === s.CR || e === s.TAB;) e = this.text.charCodeAt(++this.at);
169
+ }
170
+ expect(e) {
171
+ this.text.charCodeAt(this.at) !== e && this.fail(), this.at++;
172
+ }
173
+ fail(e = this.at) {
174
+ throw SyntaxError(e >= this.text.length ? "Unexpected end of JSON input" : `Unexpected token in JSON at position ${e}`);
175
+ }
176
+ };
177
+ function u(e, t) {
178
+ return n(t) ? JSON.parse(e) : new l(e).parse(t);
179
+ }
180
+ var d = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
181
+ function f(e, t) {
182
+ if (n(t)) return JSON.stringify(e);
183
+ let r = [], i = `\u0000wow-number-${Math.random().toString(36).slice(2)}:`, a = p(e, t, r, i), o = JSON.stringify(a);
184
+ if (r.length === 0) return o;
185
+ let s = RegExp(`"${JSON.stringify(i).slice(1, -1).replace(/\\/g, "\\\\")}(\\d+)"`, "g");
186
+ return o.replace(s, (e, t) => r[Number(t)]);
187
+ }
188
+ function p(t, n, r, o) {
189
+ if (n === void 0 || t == null) return t;
190
+ if (n === !0) {
191
+ if (typeof t != "string") return t;
192
+ if (!d.test(t)) throw TypeError(`Not a JSON number: [${t}].`);
193
+ return r.push(t), `${o}${r.length - 1}`;
194
+ }
195
+ if (Array.isArray(t)) return t.map((e, t) => p(e, i(n, String(t)), r, o));
196
+ if (typeof t != "object") return t;
197
+ let s = t;
198
+ if (typeof s.toJSON == "function") return t;
199
+ let c = e in n ? n[e] : void 0, l = c === void 0 ? void 0 : s[c.discriminant], u = {};
200
+ for (let e of Object.keys(s)) {
201
+ let t = c === void 0 ? i(n, e) : e === c.member && typeof l == "string" ? c.cases[l] : void 0;
202
+ a(u, e, p(s[e], t, r, o));
203
+ }
204
+ return u;
205
+ }
206
+ function m(e) {
207
+ let n = e.textNumbers?.events;
208
+ return n === void 0 ? void 0 : t("name", "body", n);
209
+ }
210
+ //#endregion
211
+ export { m as eventNumbers, n as marksNothing, u as parseJson, f as stringifyJson, t as textNumbersBy };
212
+
213
+ //# sourceMappingURL=exactJson.es.js.map
@@ -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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;CAET,IAAIR,MAAU,IAAM;EAClB,IAAI,OAAOQ,KAAU,UAAU,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,S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Q,MAAO,CACnE,CAAC,CACH,OAASM,EAAO,CACd,IAAMC,EAAYD,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"}
@@ -0,0 +1,96 @@
1
+ import { Fetcher } from '@ahoo-wang/fetcher';
2
+ import { TextNumbers } from './exactJson.cjs';
3
+ /**
4
+ * The request headers of a Wow service's public port (decisions D95,
5
+ * D96, D98, D99).
6
+ */
7
+ export declare const WowHeaders: {
8
+ /** The caller's id of the request: a retry with the same one is deduplicated. */
9
+ readonly REQUEST_ID: "Wow-Request-Id";
10
+ /** The wait plan (decision D99). */
11
+ readonly WAIT: "Wow-Wait";
12
+ /** How long to wait: `500ms`, `10s` or an ISO-8601 duration. */
13
+ readonly WAIT_TIMEOUT: "Wow-Wait-Timeout";
14
+ /** The scope to act in, for a caller allowed to act across scopes (decision D95). */
15
+ readonly SCOPE: "Wow-Scope";
16
+ /** The space, among the caller's own, to act in (decision D96). */
17
+ readonly SPACE: "Wow-Space";
18
+ /** The expected version of the aggregate, as an entity tag. */
19
+ readonly IF_MATCH: "If-Match";
20
+ /** The version, or descriptor version, a read already holds. */
21
+ readonly IF_NONE_MATCH: "If-None-Match";
22
+ /** The version of a state read, or of a query descriptor. */
23
+ readonly ETAG: "ETag";
24
+ /** The seconds after which a failed request may be retried. */
25
+ readonly RETRY_AFTER: "Retry-After";
26
+ /** The position a streamed list resumes after (decision D253). */
27
+ readonly LAST_EVENT_ID: "Last-Event-ID";
28
+ };
29
+ /** How a client reaches its service. */
30
+ export interface WowClientOptions {
31
+ /**
32
+ * The fetcher requests go through, with its base URL and interceptors
33
+ * (authentication, say); the default fetcher when absent.
34
+ */
35
+ readonly fetcher?: Fetcher;
36
+ /** A path put before every route, such as a gateway's prefix. */
37
+ readonly basePath?: string;
38
+ }
39
+ /**
40
+ * The scope a caller allowed to act across scopes acts in: the `Wow-Scope`
41
+ * header (decision D95).
42
+ */
43
+ export interface TargetScope {
44
+ readonly tenantId?: string;
45
+ readonly ownerId?: string;
46
+ readonly spaceId?: string;
47
+ }
48
+ /**
49
+ * A target scope as the `Wow-Scope` header spells it, an RFC 8941
50
+ * dictionary: `tenant="t1", owner="u1", space="s1"`.
51
+ *
52
+ * @param scope - The scope; at least one of its members is set
53
+ */
54
+ export declare function formatScope(scope: TargetScope): string;
55
+ /** What every request may carry beside its own parameters. */
56
+ export interface RequestOptions {
57
+ /** The scope to act in (`Wow-Scope`), for a caller allowed to. */
58
+ readonly scope?: TargetScope;
59
+ /** The space to act in (`Wow-Space`), among the caller's own. */
60
+ readonly space?: string;
61
+ /** More headers: the request facts the service records, say. */
62
+ readonly headers?: Readonly<Record<string, string>>;
63
+ /** Cancels the request. */
64
+ readonly signal?: AbortSignal;
65
+ }
66
+ /** One request of a client. */
67
+ export interface Call {
68
+ readonly method: 'GET' | 'POST' | 'DELETE';
69
+ readonly path: string;
70
+ readonly query?: Readonly<Record<string, string | number | undefined>>;
71
+ readonly headers?: Readonly<Record<string, string | undefined>>;
72
+ readonly body?: unknown;
73
+ /** The body's numbers written as their exact text ({@link TextNumbers}). */
74
+ readonly bodyNumbers?: TextNumbers;
75
+ readonly options?: RequestOptions;
76
+ /** Answers a 304 rather than rejecting with it. */
77
+ readonly notModified?: boolean;
78
+ }
79
+ /** `{name}` segments of `path` filled from `params`, each encoded. */
80
+ export declare function expandPath(path: string, params: Readonly<Record<string, string>>): string;
81
+ /**
82
+ * Sends one request through the client's fetcher and answers its response;
83
+ * a response that is not 2xx rejects with a {@link WowProblemError}.
84
+ *
85
+ * @param client - The client's options
86
+ * @param call - The request
87
+ */
88
+ export declare function send(client: WowClientOptions, call: Call): Promise<Response>;
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>;
95
+ /** The entity tag of a response without its quotes or weak marker. */
96
+ export declare function entityTag(response: Response): string | undefined;
package/dist/http.d.ts ADDED
@@ -0,0 +1,96 @@
1
+ import { Fetcher } from '@ahoo-wang/fetcher';
2
+ import { TextNumbers } from './exactJson.js';
3
+ /**
4
+ * The request headers of a Wow service's public port (decisions D95,
5
+ * D96, D98, D99).
6
+ */
7
+ export declare const WowHeaders: {
8
+ /** The caller's id of the request: a retry with the same one is deduplicated. */
9
+ readonly REQUEST_ID: "Wow-Request-Id";
10
+ /** The wait plan (decision D99). */
11
+ readonly WAIT: "Wow-Wait";
12
+ /** How long to wait: `500ms`, `10s` or an ISO-8601 duration. */
13
+ readonly WAIT_TIMEOUT: "Wow-Wait-Timeout";
14
+ /** The scope to act in, for a caller allowed to act across scopes (decision D95). */
15
+ readonly SCOPE: "Wow-Scope";
16
+ /** The space, among the caller's own, to act in (decision D96). */
17
+ readonly SPACE: "Wow-Space";
18
+ /** The expected version of the aggregate, as an entity tag. */
19
+ readonly IF_MATCH: "If-Match";
20
+ /** The version, or descriptor version, a read already holds. */
21
+ readonly IF_NONE_MATCH: "If-None-Match";
22
+ /** The version of a state read, or of a query descriptor. */
23
+ readonly ETAG: "ETag";
24
+ /** The seconds after which a failed request may be retried. */
25
+ readonly RETRY_AFTER: "Retry-After";
26
+ /** The position a streamed list resumes after (decision D253). */
27
+ readonly LAST_EVENT_ID: "Last-Event-ID";
28
+ };
29
+ /** How a client reaches its service. */
30
+ export interface WowClientOptions {
31
+ /**
32
+ * The fetcher requests go through, with its base URL and interceptors
33
+ * (authentication, say); the default fetcher when absent.
34
+ */
35
+ readonly fetcher?: Fetcher;
36
+ /** A path put before every route, such as a gateway's prefix. */
37
+ readonly basePath?: string;
38
+ }
39
+ /**
40
+ * The scope a caller allowed to act across scopes acts in: the `Wow-Scope`
41
+ * header (decision D95).
42
+ */
43
+ export interface TargetScope {
44
+ readonly tenantId?: string;
45
+ readonly ownerId?: string;
46
+ readonly spaceId?: string;
47
+ }
48
+ /**
49
+ * A target scope as the `Wow-Scope` header spells it, an RFC 8941
50
+ * dictionary: `tenant="t1", owner="u1", space="s1"`.
51
+ *
52
+ * @param scope - The scope; at least one of its members is set
53
+ */
54
+ export declare function formatScope(scope: TargetScope): string;
55
+ /** What every request may carry beside its own parameters. */
56
+ export interface RequestOptions {
57
+ /** The scope to act in (`Wow-Scope`), for a caller allowed to. */
58
+ readonly scope?: TargetScope;
59
+ /** The space to act in (`Wow-Space`), among the caller's own. */
60
+ readonly space?: string;
61
+ /** More headers: the request facts the service records, say. */
62
+ readonly headers?: Readonly<Record<string, string>>;
63
+ /** Cancels the request. */
64
+ readonly signal?: AbortSignal;
65
+ }
66
+ /** One request of a client. */
67
+ export interface Call {
68
+ readonly method: 'GET' | 'POST' | 'DELETE';
69
+ readonly path: string;
70
+ readonly query?: Readonly<Record<string, string | number | undefined>>;
71
+ readonly headers?: Readonly<Record<string, string | undefined>>;
72
+ readonly body?: unknown;
73
+ /** The body's numbers written as their exact text ({@link TextNumbers}). */
74
+ readonly bodyNumbers?: TextNumbers;
75
+ readonly options?: RequestOptions;
76
+ /** Answers a 304 rather than rejecting with it. */
77
+ readonly notModified?: boolean;
78
+ }
79
+ /** `{name}` segments of `path` filled from `params`, each encoded. */
80
+ export declare function expandPath(path: string, params: Readonly<Record<string, string>>): string;
81
+ /**
82
+ * Sends one request through the client's fetcher and answers its response;
83
+ * a response that is not 2xx rejects with a {@link WowProblemError}.
84
+ *
85
+ * @param client - The client's options
86
+ * @param call - The request
87
+ */
88
+ export declare function send(client: WowClientOptions, call: Call): Promise<Response>;
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>;
95
+ /** The entity tag of a response without its quotes or weak marker. */
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;CAEd,OAAO;CAEP,OAAO;CAEP,UAAU;CAEV,eAAe;CAEf,MAAM;CAEN,aAAa;CAEb,eAAe;AACjB;AAuBA,SAASC,EAAM,GAAuB;CACpC,OAAO,IAAIC,EAAM,QAAQ,OAAO,MAAM,CAAC,CAAC,QAAQ,MAAM,MAAK,EAAE;AAC/D;AAQA,SAAgBC,EAAY,GAA4B;CACtD,IAAMC,IAAU;EACdC,EAAM,aAAa,KAAA,IACf,KAAA,IACA,UAAUJ,EAAMI,EAAM,QAAQ;EAClCA,EAAM,YAAY,KAAA,IAAY,KAAA,IAAY,SAASJ,EAAMI,EAAM,OAAO;EACtEA,EAAM,YAAY,KAAA,IAAY,KAAA,IAAY,SAASJ,EAAMI,EAAM,OAAO;CACxE,CAAC,CAAC,QAAO,MAAUC,MAAW,KAAA,CAAS;CACvC,IAAIF,EAAQ,WAAW,GACrB,MAAU,UAAU,gDAAgD;CAEtE,OAAOA,EAAQ,KAAK,IAAI;AAC1B;AA6BA,SAAgBG,EACd,GACA,GACQ;CACR,OAAOC,EAAK,QAAQ,iBAAiB,GAAS,MAAiB;EAC7D,IAAMN,IAAQO,EAAOC;EACrB,IAAIR,MAAU,KAAA,KAAaA,MAAU,IACnC,MAAU,UAAU,YAAYM,EAAK,SAASE,EAAK,EAAE;EAEvD,OAAO,mBAAmBR,CAAK;CACjC,CAAC;AACH;AAEA,SAASS,EACP,GACQ;CACR,IAAI,CAACC,GAAO,OAAO;CACnB,IAAMH,IAAS,IAAI,gBAAgB;CACnC,KAAK,IAAM,CAACC,GAAMR,MAAU,OAAO,QAAQU,CAAK,GAC9C,AAAIV,MAAU,KAAA,KAAWO,EAAO,OAAOC,GAAM,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ChDI,EAAU,MAAMJ,EAAS,KAAK,GAAGG,CAAO;AACjD;AAGA,SAAgBE,EAAU,GAAwC;CAChE,IAAMC,IAAMN,EAAS,QAAQ,IAAIzB,EAAW,IAAI;CAChD,OAAO+B,MAAQ,OAAO,KAAA,IAAYA,EAAI,QAAQ,QAAQ,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;