@ahoo-wang/wow-client 9.2.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (404) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +291 -0
  3. package/README.zh-CN.md +267 -0
  4. package/dist/_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.cjs +1 -0
  5. package/dist/_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.es.js +9 -0
  6. package/dist/_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.cjs +1 -0
  7. package/dist/_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.es.js +6 -0
  8. package/dist/_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateParam.cjs +1 -0
  9. package/dist/_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateParam.es.js +8 -0
  10. package/dist/client/bindMethods.cjs +2 -0
  11. package/dist/client/bindMethods.cjs.map +1 -0
  12. package/dist/client/bindMethods.d.cts +13 -0
  13. package/dist/client/bindMethods.d.ts +13 -0
  14. package/dist/client/bindMethods.es.js +19 -0
  15. package/dist/client/bindMethods.es.js.map +1 -0
  16. package/dist/client/command/commandClient.cjs +2 -0
  17. package/dist/client/command/commandClient.cjs.map +1 -0
  18. package/dist/client/command/commandClient.d.cts +67 -0
  19. package/dist/client/command/commandClient.d.ts +67 -0
  20. package/dist/client/command/commandClient.es.js +38 -0
  21. package/dist/client/command/commandClient.es.js.map +1 -0
  22. package/dist/client/command/commandHeaders.cjs +2 -0
  23. package/dist/client/command/commandHeaders.cjs.map +1 -0
  24. package/dist/client/command/commandHeaders.d.cts +75 -0
  25. package/dist/client/command/commandHeaders.d.ts +75 -0
  26. package/dist/client/command/commandHeaders.es.js +31 -0
  27. package/dist/client/command/commandHeaders.es.js.map +1 -0
  28. package/dist/client/command/commandRequest.cjs +2 -0
  29. package/dist/client/command/commandRequest.cjs.map +1 -0
  30. package/dist/client/command/commandRequest.d.cts +180 -0
  31. package/dist/client/command/commandRequest.d.ts +180 -0
  32. package/dist/client/command/commandRequest.es.js +31 -0
  33. package/dist/client/command/commandRequest.es.js.map +1 -0
  34. package/dist/client/command/commandResult.d.cts +15 -0
  35. package/dist/client/command/commandResult.d.ts +15 -0
  36. package/dist/client/command/index.d.cts +5 -0
  37. package/dist/client/command/index.d.ts +5 -0
  38. package/dist/client/command/types.d.cts +71 -0
  39. package/dist/client/command/types.d.ts +71 -0
  40. package/dist/client/metadata/index.d.cts +2 -0
  41. package/dist/client/metadata/index.d.ts +2 -0
  42. package/dist/client/metadata/wowMetadata.d.cts +48 -0
  43. package/dist/client/metadata/wowMetadata.d.ts +48 -0
  44. package/dist/client/metadata/wowMetadataClient.cjs +2 -0
  45. package/dist/client/metadata/wowMetadataClient.cjs.map +1 -0
  46. package/dist/client/metadata/wowMetadataClient.d.cts +23 -0
  47. package/dist/client/metadata/wowMetadataClient.d.ts +23 -0
  48. package/dist/client/metadata/wowMetadataClient.es.js +25 -0
  49. package/dist/client/metadata/wowMetadataClient.es.js.map +1 -0
  50. package/dist/client/query/descriptor/descriptorEndpoints.cjs +2 -0
  51. package/dist/client/query/descriptor/descriptorEndpoints.cjs.map +1 -0
  52. package/dist/client/query/descriptor/descriptorEndpoints.d.cts +29 -0
  53. package/dist/client/query/descriptor/descriptorEndpoints.d.ts +29 -0
  54. package/dist/client/query/descriptor/descriptorEndpoints.es.js +69 -0
  55. package/dist/client/query/descriptor/descriptorEndpoints.es.js.map +1 -0
  56. package/dist/client/query/descriptor/endpointPaths.cjs +2 -0
  57. package/dist/client/query/descriptor/endpointPaths.cjs.map +1 -0
  58. package/dist/client/query/descriptor/endpointPaths.d.cts +4 -0
  59. package/dist/client/query/descriptor/endpointPaths.d.ts +4 -0
  60. package/dist/client/query/descriptor/endpointPaths.es.js +9 -0
  61. package/dist/client/query/descriptor/endpointPaths.es.js.map +1 -0
  62. package/dist/client/query/descriptor/index.d.cts +2 -0
  63. package/dist/client/query/descriptor/index.d.ts +2 -0
  64. package/dist/client/query/descriptor/queryDescriptorApi.d.cts +58 -0
  65. package/dist/client/query/descriptor/queryDescriptorApi.d.ts +58 -0
  66. package/dist/client/query/descriptor/queryDescriptorClient.cjs +2 -0
  67. package/dist/client/query/descriptor/queryDescriptorClient.cjs.map +1 -0
  68. package/dist/client/query/descriptor/queryDescriptorClient.d.cts +61 -0
  69. package/dist/client/query/descriptor/queryDescriptorClient.d.ts +61 -0
  70. package/dist/client/query/descriptor/queryDescriptorClient.es.js +20 -0
  71. package/dist/client/query/descriptor/queryDescriptorClient.es.js.map +1 -0
  72. package/dist/client/query/event/domainEventStream.cjs +2 -0
  73. package/dist/client/query/event/domainEventStream.cjs.map +1 -0
  74. package/dist/client/query/event/domainEventStream.d.cts +105 -0
  75. package/dist/client/query/event/domainEventStream.d.ts +105 -0
  76. package/dist/client/query/event/domainEventStream.es.js +23 -0
  77. package/dist/client/query/event/domainEventStream.es.js.map +1 -0
  78. package/dist/client/query/event/endpointPaths.cjs +2 -0
  79. package/dist/client/query/event/endpointPaths.cjs.map +1 -0
  80. package/dist/client/query/event/endpointPaths.d.cts +8 -0
  81. package/dist/client/query/event/endpointPaths.d.ts +8 -0
  82. package/dist/client/query/event/endpointPaths.es.js +13 -0
  83. package/dist/client/query/event/endpointPaths.es.js.map +1 -0
  84. package/dist/client/query/event/eventStreamQueryApi.d.cts +29 -0
  85. package/dist/client/query/event/eventStreamQueryApi.d.ts +29 -0
  86. package/dist/client/query/event/eventStreamQueryClient.cjs +2 -0
  87. package/dist/client/query/event/eventStreamQueryClient.cjs.map +1 -0
  88. package/dist/client/query/event/eventStreamQueryClient.d.cts +190 -0
  89. package/dist/client/query/event/eventStreamQueryClient.d.ts +190 -0
  90. package/dist/client/query/event/eventStreamQueryClient.es.js +160 -0
  91. package/dist/client/query/event/eventStreamQueryClient.es.js.map +1 -0
  92. package/dist/client/query/event/index.d.cts +3 -0
  93. package/dist/client/query/event/index.d.ts +3 -0
  94. package/dist/client/query/factory.cjs +2 -0
  95. package/dist/client/query/factory.cjs.map +1 -0
  96. package/dist/client/query/factory.d.cts +165 -0
  97. package/dist/client/query/factory.d.ts +165 -0
  98. package/dist/client/query/factory.es.js +45 -0
  99. package/dist/client/query/factory.es.js.map +1 -0
  100. package/dist/client/query/index.d.cts +6 -0
  101. package/dist/client/query/index.d.ts +6 -0
  102. package/dist/client/query/queryApi.d.cts +68 -0
  103. package/dist/client/query/queryApi.d.ts +68 -0
  104. package/dist/client/query/requests.d.cts +24 -0
  105. package/dist/client/query/requests.d.ts +24 -0
  106. package/dist/client/query/snapshot/endpointPaths.cjs +2 -0
  107. package/dist/client/query/snapshot/endpointPaths.cjs.map +1 -0
  108. package/dist/client/query/snapshot/endpointPaths.d.cts +12 -0
  109. package/dist/client/query/snapshot/endpointPaths.d.ts +12 -0
  110. package/dist/client/query/snapshot/endpointPaths.es.js +17 -0
  111. package/dist/client/query/snapshot/endpointPaths.es.js.map +1 -0
  112. package/dist/client/query/snapshot/index.d.cts +3 -0
  113. package/dist/client/query/snapshot/index.d.ts +3 -0
  114. package/dist/client/query/snapshot/snapshot.cjs +2 -0
  115. package/dist/client/query/snapshot/snapshot.cjs.map +1 -0
  116. package/dist/client/query/snapshot/snapshot.d.cts +51 -0
  117. package/dist/client/query/snapshot/snapshot.d.ts +51 -0
  118. package/dist/client/query/snapshot/snapshot.es.js +20 -0
  119. package/dist/client/query/snapshot/snapshot.es.js.map +1 -0
  120. package/dist/client/query/snapshot/snapshotQueryApi.d.cts +101 -0
  121. package/dist/client/query/snapshot/snapshotQueryApi.d.ts +101 -0
  122. package/dist/client/query/snapshot/snapshotQueryClient.cjs +2 -0
  123. package/dist/client/query/snapshot/snapshotQueryClient.cjs.map +1 -0
  124. package/dist/client/query/snapshot/snapshotQueryClient.d.cts +369 -0
  125. package/dist/client/query/snapshot/snapshotQueryClient.d.ts +369 -0
  126. package/dist/client/query/snapshot/snapshotQueryClient.es.js +239 -0
  127. package/dist/client/query/snapshot/snapshotQueryClient.es.js.map +1 -0
  128. package/dist/client/query/state/endpointPaths.cjs +2 -0
  129. package/dist/client/query/state/endpointPaths.cjs.map +1 -0
  130. package/dist/client/query/state/endpointPaths.d.cts +10 -0
  131. package/dist/client/query/state/endpointPaths.d.ts +10 -0
  132. package/dist/client/query/state/endpointPaths.es.js +14 -0
  133. package/dist/client/query/state/endpointPaths.es.js.map +1 -0
  134. package/dist/client/query/state/index.d.cts +4 -0
  135. package/dist/client/query/state/index.d.ts +4 -0
  136. package/dist/client/query/state/loadOwnerStateAggregateApi.d.cts +36 -0
  137. package/dist/client/query/state/loadOwnerStateAggregateApi.d.ts +36 -0
  138. package/dist/client/query/state/loadOwnerStateAggregateClient.cjs +2 -0
  139. package/dist/client/query/state/loadOwnerStateAggregateClient.cjs.map +1 -0
  140. package/dist/client/query/state/loadOwnerStateAggregateClient.d.cts +58 -0
  141. package/dist/client/query/state/loadOwnerStateAggregateClient.d.ts +58 -0
  142. package/dist/client/query/state/loadOwnerStateAggregateClient.es.js +56 -0
  143. package/dist/client/query/state/loadOwnerStateAggregateClient.es.js.map +1 -0
  144. package/dist/client/query/state/loadStateAggregateApi.d.cts +37 -0
  145. package/dist/client/query/state/loadStateAggregateApi.d.ts +37 -0
  146. package/dist/client/query/state/loadStateAggregateClient.cjs +2 -0
  147. package/dist/client/query/state/loadStateAggregateClient.cjs.map +1 -0
  148. package/dist/client/query/state/loadStateAggregateClient.d.cts +62 -0
  149. package/dist/client/query/state/loadStateAggregateClient.d.ts +62 -0
  150. package/dist/client/query/state/loadStateAggregateClient.es.js +65 -0
  151. package/dist/client/query/state/loadStateAggregateClient.es.js.map +1 -0
  152. package/dist/client/routing.cjs +2 -0
  153. package/dist/client/routing.cjs.map +1 -0
  154. package/dist/client/routing.d.cts +47 -0
  155. package/dist/client/routing.d.ts +47 -0
  156. package/dist/client/routing.es.js +8 -0
  157. package/dist/client/routing.es.js.map +1 -0
  158. package/dist/dsl/aggregation/admit.cjs +2 -0
  159. package/dist/dsl/aggregation/admit.cjs.map +1 -0
  160. package/dist/dsl/aggregation/admit.d.cts +6 -0
  161. package/dist/dsl/aggregation/admit.d.ts +6 -0
  162. package/dist/dsl/aggregation/admit.es.js +142 -0
  163. package/dist/dsl/aggregation/admit.es.js.map +1 -0
  164. package/dist/dsl/aggregation/builders.cjs +2 -0
  165. package/dist/dsl/aggregation/builders.cjs.map +1 -0
  166. package/dist/dsl/aggregation/builders.d.cts +309 -0
  167. package/dist/dsl/aggregation/builders.d.ts +309 -0
  168. package/dist/dsl/aggregation/builders.es.js +188 -0
  169. package/dist/dsl/aggregation/builders.es.js.map +1 -0
  170. package/dist/dsl/aggregation/derived.cjs +2 -0
  171. package/dist/dsl/aggregation/derived.cjs.map +1 -0
  172. package/dist/dsl/aggregation/derived.d.cts +33 -0
  173. package/dist/dsl/aggregation/derived.d.ts +33 -0
  174. package/dist/dsl/aggregation/derived.es.js +31 -0
  175. package/dist/dsl/aggregation/derived.es.js.map +1 -0
  176. package/dist/dsl/aggregation/expressionTrees.cjs +2 -0
  177. package/dist/dsl/aggregation/expressionTrees.cjs.map +1 -0
  178. package/dist/dsl/aggregation/expressionTrees.d.cts +10 -0
  179. package/dist/dsl/aggregation/expressionTrees.d.ts +10 -0
  180. package/dist/dsl/aggregation/expressionTrees.es.js +44 -0
  181. package/dist/dsl/aggregation/expressionTrees.es.js.map +1 -0
  182. package/dist/dsl/aggregation/having.cjs +2 -0
  183. package/dist/dsl/aggregation/having.cjs.map +1 -0
  184. package/dist/dsl/aggregation/having.d.cts +94 -0
  185. package/dist/dsl/aggregation/having.d.ts +94 -0
  186. package/dist/dsl/aggregation/having.es.js +62 -0
  187. package/dist/dsl/aggregation/having.es.js.map +1 -0
  188. package/dist/dsl/aggregation/index.d.cts +4 -0
  189. package/dist/dsl/aggregation/index.d.ts +4 -0
  190. package/dist/dsl/aggregation/sort.cjs +2 -0
  191. package/dist/dsl/aggregation/sort.cjs.map +1 -0
  192. package/dist/dsl/aggregation/sort.d.cts +7 -0
  193. package/dist/dsl/aggregation/sort.d.ts +7 -0
  194. package/dist/dsl/aggregation/sort.es.js +10 -0
  195. package/dist/dsl/aggregation/sort.es.js.map +1 -0
  196. package/dist/dsl/aggregation/types.cjs +2 -0
  197. package/dist/dsl/aggregation/types.cjs.map +1 -0
  198. package/dist/dsl/aggregation/types.d.cts +608 -0
  199. package/dist/dsl/aggregation/types.d.ts +608 -0
  200. package/dist/dsl/aggregation/types.es.js +37 -0
  201. package/dist/dsl/aggregation/types.es.js.map +1 -0
  202. package/dist/dsl/cursorQuery.cjs +2 -0
  203. package/dist/dsl/cursorQuery.cjs.map +1 -0
  204. package/dist/dsl/cursorQuery.d.cts +69 -0
  205. package/dist/dsl/cursorQuery.d.ts +69 -0
  206. package/dist/dsl/cursorQuery.es.js +19 -0
  207. package/dist/dsl/cursorQuery.es.js.map +1 -0
  208. package/dist/dsl/deletionState.cjs +2 -0
  209. package/dist/dsl/deletionState.cjs.map +1 -0
  210. package/dist/dsl/deletionState.d.cts +19 -0
  211. package/dist/dsl/deletionState.d.ts +19 -0
  212. package/dist/dsl/deletionState.es.js +8 -0
  213. package/dist/dsl/deletionState.es.js.map +1 -0
  214. package/dist/dsl/descriptor.cjs +2 -0
  215. package/dist/dsl/descriptor.cjs.map +1 -0
  216. package/dist/dsl/descriptor.d.cts +629 -0
  217. package/dist/dsl/descriptor.d.ts +629 -0
  218. package/dist/dsl/descriptor.es.js +37 -0
  219. package/dist/dsl/descriptor.es.js.map +1 -0
  220. package/dist/dsl/documents.d.cts +8 -0
  221. package/dist/dsl/documents.d.ts +8 -0
  222. package/dist/dsl/field.cjs +2 -0
  223. package/dist/dsl/field.cjs.map +1 -0
  224. package/dist/dsl/field.d.cts +2 -0
  225. package/dist/dsl/field.d.ts +2 -0
  226. package/dist/dsl/field.es.js +10 -0
  227. package/dist/dsl/field.es.js.map +1 -0
  228. package/dist/dsl/filter/builders.cjs +2 -0
  229. package/dist/dsl/filter/builders.cjs.map +1 -0
  230. package/dist/dsl/filter/builders.d.cts +962 -0
  231. package/dist/dsl/filter/builders.d.ts +962 -0
  232. package/dist/dsl/filter/builders.es.js +289 -0
  233. package/dist/dsl/filter/builders.es.js.map +1 -0
  234. package/dist/dsl/filter/datePattern.cjs +2 -0
  235. package/dist/dsl/filter/datePattern.cjs.map +1 -0
  236. package/dist/dsl/filter/datePattern.d.cts +8 -0
  237. package/dist/dsl/filter/datePattern.d.ts +8 -0
  238. package/dist/dsl/filter/datePattern.es.js +100 -0
  239. package/dist/dsl/filter/datePattern.es.js.map +1 -0
  240. package/dist/dsl/filter/index.d.cts +3 -0
  241. package/dist/dsl/filter/index.d.ts +3 -0
  242. package/dist/dsl/filter/operator.cjs +2 -0
  243. package/dist/dsl/filter/operator.cjs.map +1 -0
  244. package/dist/dsl/filter/operator.d.cts +113 -0
  245. package/dist/dsl/filter/operator.d.ts +113 -0
  246. package/dist/dsl/filter/operator.es.js +14 -0
  247. package/dist/dsl/filter/operator.es.js.map +1 -0
  248. package/dist/dsl/filter/scope.cjs +2 -0
  249. package/dist/dsl/filter/scope.cjs.map +1 -0
  250. package/dist/dsl/filter/scope.d.cts +15 -0
  251. package/dist/dsl/filter/scope.d.ts +15 -0
  252. package/dist/dsl/filter/scope.es.js +32 -0
  253. package/dist/dsl/filter/scope.es.js.map +1 -0
  254. package/dist/dsl/filter/types.d.cts +274 -0
  255. package/dist/dsl/filter/types.d.ts +274 -0
  256. package/dist/dsl/filter/validate.cjs +2 -0
  257. package/dist/dsl/filter/validate.cjs.map +1 -0
  258. package/dist/dsl/filter/validate.d.cts +18 -0
  259. package/dist/dsl/filter/validate.d.ts +18 -0
  260. package/dist/dsl/filter/validate.es.js +56 -0
  261. package/dist/dsl/filter/validate.es.js.map +1 -0
  262. package/dist/dsl/pagination.cjs +2 -0
  263. package/dist/dsl/pagination.cjs.map +1 -0
  264. package/dist/dsl/pagination.d.cts +28 -0
  265. package/dist/dsl/pagination.d.ts +28 -0
  266. package/dist/dsl/pagination.es.js +15 -0
  267. package/dist/dsl/pagination.es.js.map +1 -0
  268. package/dist/dsl/projection.cjs +2 -0
  269. package/dist/dsl/projection.cjs.map +1 -0
  270. package/dist/dsl/projection.d.cts +27 -0
  271. package/dist/dsl/projection.d.ts +27 -0
  272. package/dist/dsl/projection.es.js +12 -0
  273. package/dist/dsl/projection.es.js.map +1 -0
  274. package/dist/dsl/queryable.cjs +2 -0
  275. package/dist/dsl/queryable.cjs.map +1 -0
  276. package/dist/dsl/queryable.d.cts +101 -0
  277. package/dist/dsl/queryable.d.ts +101 -0
  278. package/dist/dsl/queryable.es.js +40 -0
  279. package/dist/dsl/queryable.es.js.map +1 -0
  280. package/dist/dsl/sort.cjs +2 -0
  281. package/dist/dsl/sort.cjs.map +1 -0
  282. package/dist/dsl/sort.d.cts +33 -0
  283. package/dist/dsl/sort.d.ts +33 -0
  284. package/dist/dsl/sort.es.js +21 -0
  285. package/dist/dsl/sort.es.js.map +1 -0
  286. package/dist/dsl.cjs +1 -0
  287. package/dist/dsl.d.cts +23 -0
  288. package/dist/dsl.d.ts +23 -0
  289. package/dist/dsl.es.js +14 -0
  290. package/dist/error/errorInfo.cjs +2 -0
  291. package/dist/error/errorInfo.cjs.map +1 -0
  292. package/dist/error/errorInfo.d.cts +139 -0
  293. package/dist/error/errorInfo.d.ts +139 -0
  294. package/dist/error/errorInfo.es.js +32 -0
  295. package/dist/error/errorInfo.es.js.map +1 -0
  296. package/dist/error/headers.cjs +2 -0
  297. package/dist/error/headers.cjs.map +1 -0
  298. package/dist/error/headers.d.cts +38 -0
  299. package/dist/error/headers.d.ts +38 -0
  300. package/dist/error/headers.es.js +10 -0
  301. package/dist/error/headers.es.js.map +1 -0
  302. package/dist/error/index.d.cts +21 -0
  303. package/dist/error/index.d.ts +21 -0
  304. package/dist/error/queryErrorCodes.cjs +2 -0
  305. package/dist/error/queryErrorCodes.cjs.map +1 -0
  306. package/dist/error/queryErrorCodes.d.cts +199 -0
  307. package/dist/error/queryErrorCodes.d.ts +199 -0
  308. package/dist/error/queryErrorCodes.es.js +53 -0
  309. package/dist/error/queryErrorCodes.es.js.map +1 -0
  310. package/dist/error/wowError.cjs +2 -0
  311. package/dist/error/wowError.cjs.map +1 -0
  312. package/dist/error/wowError.d.cts +99 -0
  313. package/dist/error/wowError.d.ts +99 -0
  314. package/dist/error/wowError.es.js +53 -0
  315. package/dist/error/wowError.es.js.map +1 -0
  316. package/dist/index.cjs +1 -0
  317. package/dist/index.d.cts +17 -0
  318. package/dist/index.d.ts +17 -0
  319. package/dist/index.es.js +34 -0
  320. package/dist/legacy/condition.cjs +2 -0
  321. package/dist/legacy/condition.cjs.map +1 -0
  322. package/dist/legacy/condition.d.cts +517 -0
  323. package/dist/legacy/condition.d.ts +517 -0
  324. package/dist/legacy/condition.es.js +338 -0
  325. package/dist/legacy/condition.es.js.map +1 -0
  326. package/dist/legacy/index.d.cts +16 -0
  327. package/dist/legacy/index.d.ts +16 -0
  328. package/dist/legacy/locale/en_US.cjs +2 -0
  329. package/dist/legacy/locale/en_US.cjs.map +1 -0
  330. package/dist/legacy/locale/en_US.d.cts +7 -0
  331. package/dist/legacy/locale/en_US.d.ts +7 -0
  332. package/dist/legacy/locale/en_US.es.js +50 -0
  333. package/dist/legacy/locale/en_US.es.js.map +1 -0
  334. package/dist/legacy/locale/operatorLocale.d.cts +10 -0
  335. package/dist/legacy/locale/operatorLocale.d.ts +10 -0
  336. package/dist/legacy/locale/zh_CN.cjs +2 -0
  337. package/dist/legacy/locale/zh_CN.cjs.map +1 -0
  338. package/dist/legacy/locale/zh_CN.d.cts +7 -0
  339. package/dist/legacy/locale/zh_CN.d.ts +7 -0
  340. package/dist/legacy/locale/zh_CN.es.js +50 -0
  341. package/dist/legacy/locale/zh_CN.es.js.map +1 -0
  342. package/dist/legacy/operator.cjs +2 -0
  343. package/dist/legacy/operator.cjs.map +1 -0
  344. package/dist/legacy/operator.d.cts +218 -0
  345. package/dist/legacy/operator.d.ts +218 -0
  346. package/dist/legacy/operator.es.js +25 -0
  347. package/dist/legacy/operator.es.js.map +1 -0
  348. package/dist/legacy/queryable.cjs +2 -0
  349. package/dist/legacy/queryable.cjs.map +1 -0
  350. package/dist/legacy/queryable.d.cts +61 -0
  351. package/dist/legacy/queryable.d.ts +61 -0
  352. package/dist/legacy/queryable.es.js +34 -0
  353. package/dist/legacy/queryable.es.js.map +1 -0
  354. package/dist/legacy.cjs +1 -0
  355. package/dist/legacy.es.js +6 -0
  356. package/dist/model/abac.cjs +2 -0
  357. package/dist/model/abac.cjs.map +1 -0
  358. package/dist/model/abac.d.cts +33 -0
  359. package/dist/model/abac.d.ts +33 -0
  360. package/dist/model/abac.es.js +6 -0
  361. package/dist/model/abac.es.js.map +1 -0
  362. package/dist/model/bi.cjs +2 -0
  363. package/dist/model/bi.cjs.map +1 -0
  364. package/dist/model/bi.d.cts +12 -0
  365. package/dist/model/bi.d.ts +12 -0
  366. package/dist/model/bi.es.js +8 -0
  367. package/dist/model/bi.es.js.map +1 -0
  368. package/dist/model/command.cjs +2 -0
  369. package/dist/model/command.cjs.map +1 -0
  370. package/dist/model/command.d.cts +137 -0
  371. package/dist/model/command.d.ts +137 -0
  372. package/dist/model/command.es.js +8 -0
  373. package/dist/model/command.es.js.map +1 -0
  374. package/dist/model/common.d.cts +19 -0
  375. package/dist/model/common.d.ts +19 -0
  376. package/dist/model/function.cjs +2 -0
  377. package/dist/model/function.cjs.map +1 -0
  378. package/dist/model/function.d.cts +41 -0
  379. package/dist/model/function.d.ts +41 -0
  380. package/dist/model/function.es.js +8 -0
  381. package/dist/model/function.es.js.map +1 -0
  382. package/dist/model/index.d.cts +22 -0
  383. package/dist/model/index.d.ts +22 -0
  384. package/dist/model/messaging.d.cts +5 -0
  385. package/dist/model/messaging.d.ts +5 -0
  386. package/dist/model/modeling.d.cts +145 -0
  387. package/dist/model/modeling.d.ts +145 -0
  388. package/dist/model/naming.d.cts +27 -0
  389. package/dist/model/naming.d.ts +27 -0
  390. package/dist/transport/endpoints.cjs +2 -0
  391. package/dist/transport/endpoints.cjs.map +1 -0
  392. package/dist/transport/endpoints.d.cts +79 -0
  393. package/dist/transport/endpoints.d.ts +79 -0
  394. package/dist/transport/endpoints.es.js +14 -0
  395. package/dist/transport/endpoints.es.js.map +1 -0
  396. package/dist/transport/eventStreams.cjs +2 -0
  397. package/dist/transport/eventStreams.cjs.map +1 -0
  398. package/dist/transport/eventStreams.d.cts +23 -0
  399. package/dist/transport/eventStreams.d.ts +23 -0
  400. package/dist/transport/eventStreams.es.js +22 -0
  401. package/dist/transport/eventStreams.es.js.map +1 -0
  402. package/dist/transport/index.d.cts +1 -0
  403. package/dist/transport/index.d.ts +1 -0
  404. package/package.json +110 -0
@@ -0,0 +1,267 @@
1
+ # `@ahoo-wang/wow-client`
2
+
3
+ 面向 Wow 命令、快照、领域事件、过滤、分页与聚合的类型化 Fetcher 客户端和契约。只在
4
+ 对接 Wow HTTP 端点时使用。
5
+
6
+ 支持的服务端:Wow 8.11 及以后通过 `filter` API;Wow 8.10 通过
7
+ [`/legacy`](#wow-810-服务端ahoo-wangwow-clientlegacy)。CI 用同版本的服务端测试
8
+ 客户端,并对 Wow 8.11.5、9.1.3、9.1.5 做运行时冒烟测试;对 8.10.8 只检查生成代码的类型。
9
+ Node `>=22.12.0` 或现代浏览器。TypeScript 6 或更高版本:CI 测试 6.0 到最新的 7.x。详见
10
+ [兼容性矩阵](https://wow.ahoo.me/zh/guide/typescript/compatibility)。
11
+
12
+ 随 Wow 9.2.0 发布,与 Wow 同一个 tag、同一个版本号。
13
+
14
+ ## 安装
15
+
16
+ ```bash
17
+ pnpm add @ahoo-wang/fetcher @ahoo-wang/fetcher-decorator \
18
+ @ahoo-wang/fetcher-eventstream @ahoo-wang/wow-client
19
+ ```
20
+
21
+ 版本号跟随 Wow,次版本可能带有破坏性改动:用 `save-prefix=~` 或 `--save-exact` 让 Wow 包停在同一个次版本上,见[版本范围](https://wow.ahoo.me/zh/guide/typescript/compatibility#版本范围)。
22
+
23
+ Peer 依赖:`fetcher`、`fetcher-decorator` 和 `fetcher-eventstream`。
24
+
25
+ ## 查询
26
+
27
+ ```ts
28
+ import { Fetcher } from '@ahoo-wang/fetcher';
29
+ import { SnapshotQueryClient, filter, listQuery } from '@ahoo-wang/wow-client';
30
+
31
+ interface CartState {
32
+ status: 'ACTIVE' | 'CHECKED_OUT';
33
+ }
34
+
35
+ const fetcher = new Fetcher({ baseURL: 'https://api.example.com' });
36
+ const snapshots = new SnapshotQueryClient<CartState>({
37
+ fetcher,
38
+ basePath: 'cart',
39
+ });
40
+
41
+ const carts = await snapshots.listState(
42
+ listQuery({
43
+ filter: filter.and([
44
+ filter.ownerId('u-42'),
45
+ filter.eq('state.status', 'ACTIVE'),
46
+ ]),
47
+ limit: 50,
48
+ }),
49
+ );
50
+ ```
51
+
52
+ `listQuery()`、`pagedQuery()`、`singleQuery()` 不传过滤条件时匹配全部。`listQuery()`
53
+ 只在给出 `limit` 时才发送它;不带 `limit` 时服务端怎么做,取决于它的版本:
54
+
55
+ - Wow 9.1.5 及以后:用服务端的默认列表大小(未另行配置时为 100)。
56
+ - Wow 8.11~9.1.3:以 `IllegalArgument` 拒绝,信息里有
57
+ `limit[0] must be between 1 and 1000`;列表是 HTTP 400,列表流以这个错误事件结束。对这些服务端请显式传 `limit`;
58
+ 这次拒绝得到的 `WowError` 也会这样提示。
59
+
60
+ 相对时间由服务端求值,不用浏览器的时钟。`filter.beforeNow` 与 `filter.afterNow`
61
+ 把时间字段与服务端的「现在 + ISO-8601 `offset`」做严格比较(默认 `PT0S`,负值表示回看),
62
+ 每个查询只取一次时钟,所以保存的视图在每个客户端上含义相同:
63
+
64
+ ```ts
65
+ import { filter } from '@ahoo-wang/wow-client';
66
+
67
+ const overdue = filter.beforeNow('state.timeoutAt');
68
+ const lastHalfHour = filter.afterNow('state.createTime', '-PT30M');
69
+ ```
70
+
71
+ `BEFORE_NOW` 与 `AFTER_NOW` 需要 Wow 9.2.0 及以上;更早的服务端会拒绝该查询。
72
+
73
+ ## 服务端能查什么:能力描述
74
+
75
+ `QueryDescriptorClient` 读取 `GET {aggregate}/snapshot/schema` 与
76
+ `GET {aggregate}/event/schema`(Wow 9.2.0 及以上):一份 `QueryModelDescriptor`,
77
+ 列出每个可查询字段允许的过滤算子、排序与聚合,哪些指标是估算值、日期直方图可用哪些单位、按日期部分分组可用哪些部分、日期差可用哪些单位、`FIRST` 与 `LAST` 未指定时按哪个字段排序,
78
+ 以及分页方式、全文检索(记录上的,以及存储支持时元素内的)和该入口的上限。
79
+ 它列出的每项能力单独使用都会被接受,没列出的都会被拒绝。用它只提供服务端接受的选项,
80
+ 不必把算子表和上限写死。
81
+
82
+ <!-- typecheck-context
83
+ import type { Fetcher } from '@ahoo-wang/fetcher';
84
+ declare const fetcher: Fetcher;
85
+ -->
86
+
87
+ ```ts
88
+ import { FilterOperator, QueryDescriptorClient } from '@ahoo-wang/wow-client';
89
+
90
+ // schema 路由没有租户、所有者段。
91
+ const descriptors = new QueryDescriptorClient({ fetcher, basePath: 'cart' });
92
+
93
+ const first = await descriptors.describeSnapshot();
94
+ if (!first.notModified) {
95
+ const productId = first.descriptor.fields.find(
96
+ field => field.path === 'state.items.productId',
97
+ );
98
+ const canSearchByPrefix = productId?.filter.operators.includes(
99
+ FilterOperator.STARTS_WITH,
100
+ );
101
+ }
102
+
103
+ // 重新验证手上的副本:304 时得到 { notModified: true, version }。
104
+ const again = await descriptors.describeSnapshot(first.version);
105
+ ```
106
+
107
+ 描述与调用者无关,`version` 同时是 ETag。持有它,下次把版本(或 ETag)传回:
108
+ 方法会发送 `If-None-Match`,服务端答 304 时得到 `{ notModified: true, version }`。
109
+ `QueryClientFactory.createQueryDescriptorClient()` 拼基础路径时不带工厂的资源归属。
110
+ 服务端每隔几分钟重新加载 schema,所以长时间打开的页面应当重新验证,而不是永久缓存。
111
+
112
+ ## 发送命令
113
+
114
+ <!-- typecheck-context
115
+ import { Fetcher } from '@ahoo-wang/fetcher';
116
+ declare const fetcher: Fetcher;
117
+ -->
118
+
119
+ ```ts
120
+ import {
121
+ CommandClient,
122
+ CommandStage,
123
+ commandHeaders,
124
+ waitStrategy,
125
+ } from '@ahoo-wang/wow-client';
126
+
127
+ const commands = new CommandClient({ fetcher, basePath: 'cart' });
128
+ const result = await commands.send({
129
+ path: 'add_cart_item',
130
+ method: 'POST',
131
+ headers: {
132
+ ...commandHeaders({ ownerId: 'u-42', requestId: crypto.randomUUID() }),
133
+ ...waitStrategy({ stage: CommandStage.SNAPSHOT, timeoutMs: 10_000 }),
134
+ },
135
+ body: { productId: 'p-1', quantity: 1 },
136
+ });
137
+ ```
138
+
139
+ `CommandRequestHeaders` 按服务端的解析方式给每个命令头定类型:等待阶段必须是
140
+ `CommandStage`,超时是整数毫秒。`waitStrategy()` 也能构建 Wow 的等待链
141
+ (`SAGA_HANDLED` 加 `tail`)。`sendAndWaitStream()` 在命令每到达一个阶段时产出一个
142
+ `CommandResult`。
143
+
144
+ ## 错误
145
+
146
+ 服务端返回的错误是 `WowError`,带着服务端的 `ErrorInfo`(`errorCode`、`errorMsg`、
147
+ `bindingErrors`)和 HTTP 状态码。用 `ErrorCodes` 比较 `errorCode`。Wow 以 HTTP 错误
148
+ 状态应答被拒绝的请求,包括命令处理函数失败的命令,所以调用会拒绝(reject)。
149
+
150
+ ```ts
151
+ import {
152
+ ErrorCodes,
153
+ toWowError,
154
+ type SnapshotQueryClient,
155
+ } from '@ahoo-wang/wow-client';
156
+
157
+ async function findCart(snapshots: SnapshotQueryClient<unknown>, id: string) {
158
+ try {
159
+ return await snapshots.getStateById(id);
160
+ } catch (error) {
161
+ const wowError = await toWowError(error);
162
+ if (wowError?.errorCode === ErrorCodes.NOT_FOUND) return undefined;
163
+ throw wowError ?? error;
164
+ }
165
+ }
166
+ ```
167
+
168
+ - 请求失败时抛出的是 fetcher 的错误。`toWowError()` 读取响应体里的 `ErrorInfo`,
169
+ 读不到时读 `Wow-Error-Code` 响应头;不是 Wow 服务端的应答(网络故障、超时、取消、
170
+ 代理自己的错误页)时返回 `undefined`。
171
+ - 流(`listStream`、`aggregateStream`、`sendAndWaitStream` 等)中途失败时,流以
172
+ `WowError` 结束,`for await` 会抛出它。服务端此时的 HTTP 状态仍是 200,错误作为
173
+ 最后一个事件发出;不这样处理的话,错误会被当成一行数据。
174
+ - 被拒绝的查询(解码阶段为 `IllegalArgument`,准入阶段为 `QuerySchemaValidation`)
175
+ 会说明违反了哪条规则、在哪里:`wowError.violation` 为 `{ code, path, message }`,
176
+ `code` 取自 `QueryErrorCodes`,`path` 是 JSON 路径(`filter.state`)或逻辑字段
177
+ (`state.items.sku`)。码的列表只增不改,未处理的码回退到 `errorMsg`。从 Wow 9.2
178
+ 起,预算与闸门类拒绝也带码(`SIZE_OUT_OF_RANGE`、`EXPENSIVE_OPERATOR_DISABLED` 等);更早的
179
+ 服务端只给文字(`HTTP list query limit[...]`)。服务端自身的故障应答 HTTP 500
180
+ `InternalServerError`,不带码。
181
+
182
+ <!-- typecheck-context
183
+ import type { WowError } from '@ahoo-wang/wow-client';
184
+ declare const wowError: WowError;
185
+ declare function markField(path: string, message: string): void;
186
+ -->
187
+
188
+ ```ts
189
+ import { QueryErrorCodes } from '@ahoo-wang/wow-client';
190
+
191
+ const violation = wowError.violation;
192
+ if (violation?.code === QueryErrorCodes.UNKNOWN_FIELD) {
193
+ markField(violation.path, violation.message);
194
+ }
195
+ ```
196
+
197
+ ## 取消
198
+
199
+ 每个查询方法的最后一个参数(在拦截器属性之后)接受 `AbortController` 或
200
+ `AbortSignal`:
201
+
202
+ <!-- typecheck-context
203
+ import type { FilterPagedQuery, SnapshotQueryClient } from '@ahoo-wang/wow-client';
204
+ declare const snapshots: SnapshotQueryClient<unknown>;
205
+ declare const query: FilterPagedQuery;
206
+ -->
207
+
208
+ ```ts
209
+ const page = await snapshots.pagedState(
210
+ query,
211
+ undefined,
212
+ AbortSignal.timeout(5_000),
213
+ );
214
+ ```
215
+
216
+ ## 不带 HTTP 的查询构建:`@ahoo-wang/wow-client/dsl`
217
+
218
+ `filter`、`aggregation`、排序、投影、分页、游标查询、查询工厂和能力描述的类型,不带客户端:不加载
219
+ Fetcher、装饰器、`reflect-metadata`,也不装 `fetcher-eventstream` 的全局流补丁。
220
+ 只构建查询的包从这里导入。
221
+
222
+ ## Wow 8.10 服务端:`@ahoo-wang/wow-client/legacy`
223
+
224
+ 根入口只使用 `FilterExpression`,Wow 8.11 及以后的服务端都支持。Wow 8.10 只认
225
+ 已弃用的 Condition 模型,本包把它放在单独的子路径里,保留到 v10:
226
+
227
+ <!-- typecheck-context
228
+ import type { SnapshotQueryClient } from '@ahoo-wang/wow-client';
229
+ declare const snapshots: SnapshotQueryClient<unknown>;
230
+ -->
231
+
232
+ ```ts
233
+ import { and, eq, listQuery, ownerId } from '@ahoo-wang/wow-client/legacy';
234
+
235
+ const carts = await snapshots.listState(
236
+ listQuery({ condition: and(ownerId('u-42'), eq('state.status', 'ACTIVE')) }),
237
+ );
238
+ ```
239
+
240
+ 查询客户端两种查询都接受,其余一切都从根入口导入。这个子路径在 v10 删除。
241
+
242
+ ## 核心能力
243
+
244
+ - 命令结果与流式等待阶段。
245
+ - 快照、领域事件、状态加载与所有者状态客户端;按版本区间加载事件流
246
+ (`EventStreamQueryClient.load`);服务端元数据(`WowMetadataClient`);
247
+ 支持条件请求的查询能力描述(`QueryDescriptorClient`)。
248
+ - 提前校验的数组优先 `FilterExpression` 构建器。
249
+ - 单条、列表、分页、游标、计数与流查询契约。
250
+ - 投影、排序、嵌套聚合、建模、ABAC 与元数据类型。
251
+ - `aggregation.query()` 按 Wow 服务端同样的规则校验整个聚合查询,
252
+ 让错误在构建处暴露,而不是等到请求被拒。
253
+
254
+ 暂时没有客户端的:`GET {id}/snapshot`、`GET {id}/state/tracing`,以及
255
+ `/wow/command/send` 路由(用 `CommandClient` 加上 `COMMAND_AGGREGATE_CONTEXT`、
256
+ `COMMAND_AGGREGATE_NAME`、`COMMAND_TYPE` 三个头发送)。
257
+
258
+ ## 文档
259
+
260
+ - [快速开始:调用 Wow 服务](https://wow.ahoo.me/zh/guide/typescript/quick-start)
261
+ - [错误处理](https://wow.ahoo.me/zh/guide/typescript/error-handling)与
262
+ [认证](https://wow.ahoo.me/zh/guide/typescript/authentication)
263
+ - [TypeScript 指南](https://wow.ahoo.me/zh/guide/typescript/)
264
+ - [wow-client 参考](https://wow.ahoo.me/zh/reference/typescript/wow-client/)
265
+ - [交互式查询 Story](https://wow.ahoo.me/storybook/)
266
+
267
+ [English](./README.md) · [许可证](https://github.com/Ahoo-Wang/Wow/blob/main/LICENSE)
@@ -0,0 +1 @@
1
+ function e(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}exports.default=e;
@@ -0,0 +1,9 @@
1
+ //#region \0@oxc-project+runtime@0.151.0/helpers/esm/decorate.js
2
+ function e(e, t, n, r) {
3
+ var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
4
+ if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
5
+ else for (var s = e.length - 1; s >= 0; s--) (o = e[s]) && (a = (i < 3 ? o(a) : i > 3 ? o(t, n, a) : o(t, n)) || a);
6
+ return i > 3 && a && Object.defineProperty(t, n, a), a;
7
+ }
8
+ //#endregion
9
+ export { e as default };
@@ -0,0 +1 @@
1
+ function e(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}exports.default=e;
@@ -0,0 +1,6 @@
1
+ //#region \0@oxc-project+runtime@0.151.0/helpers/esm/decorateMetadata.js
2
+ function e(e, t) {
3
+ if (typeof Reflect == "object" && typeof Reflect.metadata == "function") return Reflect.metadata(e, t);
4
+ }
5
+ //#endregion
6
+ export { e as default };
@@ -0,0 +1 @@
1
+ function e(e,t){return function(n,r){t(n,r,e)}}exports.default=e;
@@ -0,0 +1,8 @@
1
+ //#region \0@oxc-project+runtime@0.151.0/helpers/esm/decorateParam.js
2
+ function e(e, t) {
3
+ return function(n, r) {
4
+ t(n, r, e);
5
+ };
6
+ }
7
+ //#endregion
8
+ export { e as default };
@@ -0,0 +1,2 @@
1
+ function e(e){let t=new Set(Object.getOwnPropertyNames(e));for(let n=Object.getPrototypeOf(e);n!==null&&n!==Object.prototype;n=Object.getPrototypeOf(n))for(let r of Object.getOwnPropertyNames(n)){if(r===`constructor`||t.has(r))continue;t.add(r);let i=Object.getOwnPropertyDescriptor(n,r)?.value;typeof i==`function`&&Object.defineProperty(e,r,{value:i.bind(e),writable:!0,configurable:!0,enumerable:!1})}}exports.bindMethods=e;
2
+ //# sourceMappingURL=bindMethods.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bindMethods.cjs","names":["bindMethods","seen","client","prototype","name","method"],"sources":["../../src/client/bindMethods.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\n/**\n * (internal) Binds every method a client inherits to the client itself, so a\n * method handed on as a function — `execute: client.listState` in a\n * wow-react hook, `ids.map(client.getStateById)` — still reaches its fetcher.\n * The decorated methods read the client's metadata through `this`; unbound,\n * they failed with `Cannot read properties of undefined`.\n *\n * Each bound copy is an own, non-enumerable property, so spreading or\n * serialising a client is unchanged, and the prototype keeps the methods for\n * reflection. A subclass's override is the one bound: the lookup starts at\n * the instance.\n */\nexport function bindMethods(client: object): void {\n const seen = new Set(Object.getOwnPropertyNames(client));\n for (\n let prototype: object | null = Object.getPrototypeOf(client);\n prototype !== null && prototype !== Object.prototype;\n prototype = Object.getPrototypeOf(prototype)\n ) {\n for (const name of Object.getOwnPropertyNames(prototype)) {\n if (name === 'constructor' || seen.has(name)) continue;\n seen.add(name);\n // The first prototype that names it is the one a lookup finds; a\n // getter is left alone rather than run.\n const method: unknown = Object.getOwnPropertyDescriptor(\n prototype,\n name,\n )?.value;\n if (typeof method !== 'function') continue;\n Object.defineProperty(client, name, {\n value: method.bind(client),\n writable: true,\n configurable: true,\n enumerable: false,\n });\n }\n }\n}\n"],"mappings":"AAyBA,SAAgBA,EAAY,EAAsB,CAChD,IAAMC,EAAO,IAAI,IAAI,OAAO,oBAAoBC,CAAM,CAAC,EACvD,IACE,IAAIC,EAA2B,OAAO,eAAeD,CAAM,EAC3DC,IAAc,MAAQA,IAAc,OAAO,UAC3C,EAAY,OAAO,eAAeA,CAAS,EAE3C,IAAK,IAAMC,KAAQ,OAAO,oBAAoBD,CAAS,EAAG,CACxD,GAAIC,IAAS,eAAiBH,EAAK,IAAIG,CAAI,EAAG,SAC9CH,EAAK,IAAIG,CAAI,EAGb,IAAMC,EAAkB,OAAO,yBAC7BF,EACAC,CACF,CAAC,EAAE,MACC,OAAOC,GAAW,YACtB,OAAO,eAAeH,EAAQE,EAAM,CAClC,MAAOC,EAAO,KAAKH,CAAM,EACzB,SAAU,GACV,aAAc,GACd,WAAY,EACd,CAAC,CACH,CAEJ"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * (internal) Binds every method a client inherits to the client itself, so a
3
+ * method handed on as a function — `execute: client.listState` in a
4
+ * wow-react hook, `ids.map(client.getStateById)` — still reaches its fetcher.
5
+ * The decorated methods read the client's metadata through `this`; unbound,
6
+ * they failed with `Cannot read properties of undefined`.
7
+ *
8
+ * Each bound copy is an own, non-enumerable property, so spreading or
9
+ * serialising a client is unchanged, and the prototype keeps the methods for
10
+ * reflection. A subclass's override is the one bound: the lookup starts at
11
+ * the instance.
12
+ */
13
+ export declare function bindMethods(client: object): void;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * (internal) Binds every method a client inherits to the client itself, so a
3
+ * method handed on as a function — `execute: client.listState` in a
4
+ * wow-react hook, `ids.map(client.getStateById)` — still reaches its fetcher.
5
+ * The decorated methods read the client's metadata through `this`; unbound,
6
+ * they failed with `Cannot read properties of undefined`.
7
+ *
8
+ * Each bound copy is an own, non-enumerable property, so spreading or
9
+ * serialising a client is unchanged, and the prototype keeps the methods for
10
+ * reflection. A subclass's override is the one bound: the lookup starts at
11
+ * the instance.
12
+ */
13
+ export declare function bindMethods(client: object): void;
@@ -0,0 +1,19 @@
1
+ //#region src/client/bindMethods.ts
2
+ function e(e) {
3
+ let t = new Set(Object.getOwnPropertyNames(e));
4
+ for (let n = Object.getPrototypeOf(e); n !== null && n !== Object.prototype; n = Object.getPrototypeOf(n)) for (let r of Object.getOwnPropertyNames(n)) {
5
+ if (r === "constructor" || t.has(r)) continue;
6
+ t.add(r);
7
+ let i = Object.getOwnPropertyDescriptor(n, r)?.value;
8
+ typeof i == "function" && Object.defineProperty(e, r, {
9
+ value: i.bind(e),
10
+ writable: !0,
11
+ configurable: !0,
12
+ enumerable: !1
13
+ });
14
+ }
15
+ }
16
+ //#endregion
17
+ export { e as bindMethods };
18
+
19
+ //# sourceMappingURL=bindMethods.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bindMethods.es.js","names":["bindMethods","seen","client","prototype","name","method"],"sources":["../../src/client/bindMethods.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\n/**\n * (internal) Binds every method a client inherits to the client itself, so a\n * method handed on as a function — `execute: client.listState` in a\n * wow-react hook, `ids.map(client.getStateById)` — still reaches its fetcher.\n * The decorated methods read the client's metadata through `this`; unbound,\n * they failed with `Cannot read properties of undefined`.\n *\n * Each bound copy is an own, non-enumerable property, so spreading or\n * serialising a client is unchanged, and the prototype keeps the methods for\n * reflection. A subclass's override is the one bound: the lookup starts at\n * the instance.\n */\nexport function bindMethods(client: object): void {\n const seen = new Set(Object.getOwnPropertyNames(client));\n for (\n let prototype: object | null = Object.getPrototypeOf(client);\n prototype !== null && prototype !== Object.prototype;\n prototype = Object.getPrototypeOf(prototype)\n ) {\n for (const name of Object.getOwnPropertyNames(prototype)) {\n if (name === 'constructor' || seen.has(name)) continue;\n seen.add(name);\n // The first prototype that names it is the one a lookup finds; a\n // getter is left alone rather than run.\n const method: unknown = Object.getOwnPropertyDescriptor(\n prototype,\n name,\n )?.value;\n if (typeof method !== 'function') continue;\n Object.defineProperty(client, name, {\n value: method.bind(client),\n writable: true,\n configurable: true,\n enumerable: false,\n });\n }\n }\n}\n"],"mappings":";AAyBA,SAAgBA,EAAY,GAAsB;CAChD,IAAMC,IAAO,IAAI,IAAI,OAAO,oBAAoBC,CAAM,CAAC;CACvD,KACE,IAAIC,IAA2B,OAAO,eAAeD,CAAM,GAC3DC,MAAc,QAAQA,MAAc,OAAO,WAC3C,IAAY,OAAO,eAAeA,CAAS,GAE3C,KAAK,IAAMC,KAAQ,OAAO,oBAAoBD,CAAS,GAAG;EACxD,IAAIC,MAAS,iBAAiBH,EAAK,IAAIG,CAAI,GAAG;EAC9C,EAAK,IAAIA,CAAI;EAGb,IAAMC,IAAkB,OAAO,yBAC7BF,GACAC,CACF,CAAC,EAAE;EACH,AAAI,OAAOC,KAAW,cACtB,OAAO,eAAeH,GAAQE,GAAM;GAClC,OAAOC,EAAO,KAAKH,CAAM;GACzB,UAAU;GACV,cAAc;GACd,YAAY;EACd,CAAC;CACH;AAEJ"}
@@ -0,0 +1,2 @@
1
+ const e=require("../../transport/endpoints.cjs"),t=require("../bindMethods.cjs"),n=require("../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.cjs"),r=require("../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateParam.cjs"),i=require("../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.cjs");let a=require("@ahoo-wang/fetcher-decorator");var o=class{constructor(e){this.apiMetadata=e,t.bindMethods(this)}send(e,t){throw(0,a.autoGeneratedError)(e,t)}sendAndWaitStream(e,t){throw(0,a.autoGeneratedError)(e,t)}};i.default([(0,a.endpoint)(),r.default(0,(0,a.request)()),r.default(1,(0,a.attribute)()),n.default(`design:type`,Function),n.default(`design:paramtypes`,[Object,typeof Record>`u`?Object:Record]),n.default(`design:returntype`,typeof Promise>`u`?Object:Promise)],o.prototype,`send`,null),i.default([(0,a.endpoint)(void 0,void 0,e.COMMAND_STREAM_ENDPOINT),r.default(0,(0,a.request)()),r.default(1,(0,a.attribute)()),n.default(`design:type`,Function),n.default(`design:paramtypes`,[Object,typeof Record>`u`?Object:Record]),n.default(`design:returntype`,typeof Promise>`u`?Object:Promise)],o.prototype,`sendAndWaitStream`,null),o=i.default([(0,a.api)(),n.default(`design:paramtypes`,[Object])],o),Object.defineProperty(exports,"CommandClient",{enumerable:!0,get:function(){return o}});
2
+ //# sourceMappingURL=commandClient.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandClient.cjs","names":["autoGeneratedError","_decorate","endpoint","_decorateParam","request","attribute","_decorateMetadata","COMMAND_STREAM_ENDPOINT","api","require_endpoints","require_bindMethods","require_decorateMetadata","require_decorateParam","require_decorate","_ahoo_wang_fetcher_decorator","CommandClient","apiMetadata","commandRequest","attributes"],"sources":["../../../src/client/command/commandClient.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 CommandRequest } from './commandRequest.js';\nimport type { CommandResult } from '../../model/index.js';\nimport type { CommandResultEventStream } from './commandResult.js';\nimport { COMMAND_STREAM_ENDPOINT } from '../../transport/endpoints.js';\n\nimport type {\n ApiMetadata,\n ApiMetadataCapable,\n} from '@ahoo-wang/fetcher-decorator';\nimport {\n api,\n attribute,\n autoGeneratedError,\n endpoint,\n request,\n} from '@ahoo-wang/fetcher-decorator';\nimport { bindMethods } from '../bindMethods.js';\n\n/**\n * Sends commands to a Wow command route.\n *\n * The request's `path` names the command route, relative to the client's base\n * path; its `headers` say who the command is for and what to wait for (see\n * {@link commandHeaders} and {@link waitStrategy}); its `body` is the command.\n * The body type is chosen per call, so one client sends every command of an\n * aggregate.\n *\n * @example\n * ```typescript\n * const commandClient = new CommandClient({\n * fetcher: new Fetcher({ baseURL: 'http://localhost:8080/' }),\n * basePath: 'owner/{ownerId}/cart',\n * });\n *\n * const result = await commandClient.send<{ productId: string; quantity: number }>({\n * path: 'add_cart_item',\n * method: 'POST',\n * urlParams: { path: { ownerId: 'user-1' } },\n * headers: waitStrategy({ stage: CommandStage.SNAPSHOT }),\n * body: { productId: 'product-1', quantity: 1 },\n * });\n * ```\n */\n@api()\nexport class CommandClient implements ApiMetadataCapable {\n constructor(public readonly apiMetadata?: ApiMetadata) {\n bindMethods(this);\n }\n\n /**\n * Sends a command and resolves to the result of the stage it waited for\n * (`PROCESSED` unless the headers say otherwise). A command the server\n * refuses or fails to process rejects: Wow answers the failed result with\n * the HTTP status its `errorCode` maps to. Read it with `toWowError`.\n *\n * @param commandRequest - The route path, headers and body of the command\n * @param attributes - Optional shared attributes for the interceptors\n * @returns The command result\n */\n @endpoint()\n /* v8 ignore start */\n send<C extends object = object>(\n @request() commandRequest: CommandRequest<C>,\n @attribute() attributes?: Record<string, unknown>,\n ): Promise<CommandResult> {\n throw autoGeneratedError(commandRequest, attributes);\n }\n /* v8 ignore stop */\n\n /**\n * Sends a command and streams one result for every stage it reaches, up to\n * the one it waits for. The stream errors with a `WowError` if the server\n * fails midway, for example when the wait times out.\n *\n * @param commandRequest - The route path, headers and body of the command\n * @param attributes - Optional shared attributes for the interceptors\n * @returns A stream of command results\n *\n * @example\n * ```typescript\n * const results = await commandClient.sendAndWaitStream({\n * path: 'add_cart_item',\n * method: 'POST',\n * headers: waitStrategy({ stage: CommandStage.PROJECTED }),\n * body: { productId: 'product-1', quantity: 2 },\n * });\n * for await (const result of results) {\n * console.log(result.stage);\n * }\n * ```\n */\n @endpoint(undefined, undefined, COMMAND_STREAM_ENDPOINT)\n /* v8 ignore start */\n sendAndWaitStream<C extends object = object>(\n @request() commandRequest: CommandRequest<C>,\n @attribute() attributes?: Record<string, unknown>,\n ): Promise<CommandResultEventStream> {\n throw autoGeneratedError(commandRequest, attributes);\n }\n /* v8 ignore stop */\n}\n"],"mappings":"qYAyDO,IAAMe,EAAN,KAAkD,CACvD,YAAY,EAA2C,CAA3B,KAAA,YAAAC,EAC1BN,EAAA,YAAY,IAAI,CAClB,CAYA,KAGE,EACA,EACwB,CACxB,MAAA,EAAMV,EAAAA,mBAAAA,CAAmBiB,EAAgBC,CAAU,CACrD,CAyBA,kBAGE,EACA,EACmC,CACnC,MAAA,EAAMlB,EAAAA,mBAAAA,CAAmBiB,EAAgBC,CAAU,CACrD,CAEF,cAzCGhB,EAAAA,EAAAA,SAAAA,CAAS,EAGPC,EAAAA,QAAA,GAAA,EAAAC,EAAAA,QAAAA,CAAQ,CAAA,EACRD,EAAAA,QAAA,GAAA,EAAAE,EAAAA,UAAAA,CAAU,CAAA,mNA4BZH,EAAAA,EAAAA,SAAAA,CAAS,IAAA,GAAW,IAAA,GAAWK,EAAAA,uBAAuB,EAGpDJ,EAAAA,QAAA,GAAA,EAAAC,EAAAA,QAAAA,CAAQ,CAAA,EACRD,EAAAA,QAAA,GAAA,EAAAE,EAAAA,UAAAA,CAAU,CAAA,oNApDd,EAAAJ,EAAAA,QAAA,EAAA,EAAAO,EAAAA,IAAAA,CAAI,EAAAF,EAAAA,QAAA,oBAAA,CAAA,MAAA,CAAA,CAAA,EAAAS,CAAA"}
@@ -0,0 +1,67 @@
1
+ import { CommandRequest } from './commandRequest.cjs';
2
+ import { CommandResult } from '../../model/index.cjs';
3
+ import { CommandResultEventStream } from './commandResult.cjs';
4
+ import { ApiMetadata, ApiMetadataCapable } from '@ahoo-wang/fetcher-decorator';
5
+ /**
6
+ * Sends commands to a Wow command route.
7
+ *
8
+ * The request's `path` names the command route, relative to the client's base
9
+ * path; its `headers` say who the command is for and what to wait for (see
10
+ * {@link commandHeaders} and {@link waitStrategy}); its `body` is the command.
11
+ * The body type is chosen per call, so one client sends every command of an
12
+ * aggregate.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const commandClient = new CommandClient({
17
+ * fetcher: new Fetcher({ baseURL: 'http://localhost:8080/' }),
18
+ * basePath: 'owner/{ownerId}/cart',
19
+ * });
20
+ *
21
+ * const result = await commandClient.send<{ productId: string; quantity: number }>({
22
+ * path: 'add_cart_item',
23
+ * method: 'POST',
24
+ * urlParams: { path: { ownerId: 'user-1' } },
25
+ * headers: waitStrategy({ stage: CommandStage.SNAPSHOT }),
26
+ * body: { productId: 'product-1', quantity: 1 },
27
+ * });
28
+ * ```
29
+ */
30
+ export declare class CommandClient implements ApiMetadataCapable {
31
+ readonly apiMetadata?: ApiMetadata | undefined;
32
+ constructor(apiMetadata?: ApiMetadata | undefined);
33
+ /**
34
+ * Sends a command and resolves to the result of the stage it waited for
35
+ * (`PROCESSED` unless the headers say otherwise). A command the server
36
+ * refuses or fails to process rejects: Wow answers the failed result with
37
+ * the HTTP status its `errorCode` maps to. Read it with `toWowError`.
38
+ *
39
+ * @param commandRequest - The route path, headers and body of the command
40
+ * @param attributes - Optional shared attributes for the interceptors
41
+ * @returns The command result
42
+ */
43
+ send<C extends object = object>(commandRequest: CommandRequest<C>, attributes?: Record<string, unknown>): Promise<CommandResult>;
44
+ /**
45
+ * Sends a command and streams one result for every stage it reaches, up to
46
+ * the one it waits for. The stream errors with a `WowError` if the server
47
+ * fails midway, for example when the wait times out.
48
+ *
49
+ * @param commandRequest - The route path, headers and body of the command
50
+ * @param attributes - Optional shared attributes for the interceptors
51
+ * @returns A stream of command results
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const results = await commandClient.sendAndWaitStream({
56
+ * path: 'add_cart_item',
57
+ * method: 'POST',
58
+ * headers: waitStrategy({ stage: CommandStage.PROJECTED }),
59
+ * body: { productId: 'product-1', quantity: 2 },
60
+ * });
61
+ * for await (const result of results) {
62
+ * console.log(result.stage);
63
+ * }
64
+ * ```
65
+ */
66
+ sendAndWaitStream<C extends object = object>(commandRequest: CommandRequest<C>, attributes?: Record<string, unknown>): Promise<CommandResultEventStream>;
67
+ }
@@ -0,0 +1,67 @@
1
+ import { CommandRequest } from './commandRequest.js';
2
+ import { CommandResult } from '../../model/index.js';
3
+ import { CommandResultEventStream } from './commandResult.js';
4
+ import { ApiMetadata, ApiMetadataCapable } from '@ahoo-wang/fetcher-decorator';
5
+ /**
6
+ * Sends commands to a Wow command route.
7
+ *
8
+ * The request's `path` names the command route, relative to the client's base
9
+ * path; its `headers` say who the command is for and what to wait for (see
10
+ * {@link commandHeaders} and {@link waitStrategy}); its `body` is the command.
11
+ * The body type is chosen per call, so one client sends every command of an
12
+ * aggregate.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const commandClient = new CommandClient({
17
+ * fetcher: new Fetcher({ baseURL: 'http://localhost:8080/' }),
18
+ * basePath: 'owner/{ownerId}/cart',
19
+ * });
20
+ *
21
+ * const result = await commandClient.send<{ productId: string; quantity: number }>({
22
+ * path: 'add_cart_item',
23
+ * method: 'POST',
24
+ * urlParams: { path: { ownerId: 'user-1' } },
25
+ * headers: waitStrategy({ stage: CommandStage.SNAPSHOT }),
26
+ * body: { productId: 'product-1', quantity: 1 },
27
+ * });
28
+ * ```
29
+ */
30
+ export declare class CommandClient implements ApiMetadataCapable {
31
+ readonly apiMetadata?: ApiMetadata | undefined;
32
+ constructor(apiMetadata?: ApiMetadata | undefined);
33
+ /**
34
+ * Sends a command and resolves to the result of the stage it waited for
35
+ * (`PROCESSED` unless the headers say otherwise). A command the server
36
+ * refuses or fails to process rejects: Wow answers the failed result with
37
+ * the HTTP status its `errorCode` maps to. Read it with `toWowError`.
38
+ *
39
+ * @param commandRequest - The route path, headers and body of the command
40
+ * @param attributes - Optional shared attributes for the interceptors
41
+ * @returns The command result
42
+ */
43
+ send<C extends object = object>(commandRequest: CommandRequest<C>, attributes?: Record<string, unknown>): Promise<CommandResult>;
44
+ /**
45
+ * Sends a command and streams one result for every stage it reaches, up to
46
+ * the one it waits for. The stream errors with a `WowError` if the server
47
+ * fails midway, for example when the wait times out.
48
+ *
49
+ * @param commandRequest - The route path, headers and body of the command
50
+ * @param attributes - Optional shared attributes for the interceptors
51
+ * @returns A stream of command results
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const results = await commandClient.sendAndWaitStream({
56
+ * path: 'add_cart_item',
57
+ * method: 'POST',
58
+ * headers: waitStrategy({ stage: CommandStage.PROJECTED }),
59
+ * body: { productId: 'product-1', quantity: 2 },
60
+ * });
61
+ * for await (const result of results) {
62
+ * console.log(result.stage);
63
+ * }
64
+ * ```
65
+ */
66
+ sendAndWaitStream<C extends object = object>(commandRequest: CommandRequest<C>, attributes?: Record<string, unknown>): Promise<CommandResultEventStream>;
67
+ }
@@ -0,0 +1,38 @@
1
+ import { COMMAND_STREAM_ENDPOINT as e } from "../../transport/endpoints.es.js";
2
+ import { bindMethods as t } from "../bindMethods.es.js";
3
+ import n from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateMetadata.es.js";
4
+ import r from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorateParam.es.js";
5
+ import i from "../../_virtual/_@oxc-project_runtime@0.151.0/helpers/esm/decorate.es.js";
6
+ import { api as a, attribute as o, autoGeneratedError as s, endpoint as c, request as l } from "@ahoo-wang/fetcher-decorator";
7
+ //#region src/client/command/commandClient.ts
8
+ var u = class {
9
+ constructor(e) {
10
+ this.apiMetadata = e, t(this);
11
+ }
12
+ send(e, t) {
13
+ throw s(e, t);
14
+ }
15
+ /* v8 ignore stop */
16
+ sendAndWaitStream(e, t) {
17
+ throw s(e, t);
18
+ }
19
+ };
20
+ i([
21
+ c(),
22
+ r(0, l()),
23
+ r(1, o()),
24
+ n("design:type", Function),
25
+ n("design:paramtypes", [Object, typeof Record > "u" ? Object : Record]),
26
+ n("design:returntype", typeof Promise > "u" ? Object : Promise)
27
+ ], u.prototype, "send", null), i([
28
+ c(void 0, void 0, e),
29
+ r(0, l()),
30
+ r(1, o()),
31
+ n("design:type", Function),
32
+ n("design:paramtypes", [Object, typeof Record > "u" ? Object : Record]),
33
+ n("design:returntype", typeof Promise > "u" ? Object : Promise)
34
+ ], u.prototype, "sendAndWaitStream", null), u = i([a(), n("design:paramtypes", [Object])], u);
35
+ //#endregion
36
+ export { u as CommandClient };
37
+
38
+ //# sourceMappingURL=commandClient.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandClient.es.js","names":["_decorate","_decorateParam","_decorateMetadata","__decorateMetadata","__decorateParam","__decorate","CommandClient","apiMetadata","bindMethods","autoGeneratedError","commandRequest","attributes","endpoint","request","attribute","COMMAND_STREAM_ENDPOINT","api"],"sources":["../../../src/client/command/commandClient.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 CommandRequest } from './commandRequest.js';\nimport type { CommandResult } from '../../model/index.js';\nimport type { CommandResultEventStream } from './commandResult.js';\nimport { COMMAND_STREAM_ENDPOINT } from '../../transport/endpoints.js';\n\nimport type {\n ApiMetadata,\n ApiMetadataCapable,\n} from '@ahoo-wang/fetcher-decorator';\nimport {\n api,\n attribute,\n autoGeneratedError,\n endpoint,\n request,\n} from '@ahoo-wang/fetcher-decorator';\nimport { bindMethods } from '../bindMethods.js';\n\n/**\n * Sends commands to a Wow command route.\n *\n * The request's `path` names the command route, relative to the client's base\n * path; its `headers` say who the command is for and what to wait for (see\n * {@link commandHeaders} and {@link waitStrategy}); its `body` is the command.\n * The body type is chosen per call, so one client sends every command of an\n * aggregate.\n *\n * @example\n * ```typescript\n * const commandClient = new CommandClient({\n * fetcher: new Fetcher({ baseURL: 'http://localhost:8080/' }),\n * basePath: 'owner/{ownerId}/cart',\n * });\n *\n * const result = await commandClient.send<{ productId: string; quantity: number }>({\n * path: 'add_cart_item',\n * method: 'POST',\n * urlParams: { path: { ownerId: 'user-1' } },\n * headers: waitStrategy({ stage: CommandStage.SNAPSHOT }),\n * body: { productId: 'product-1', quantity: 1 },\n * });\n * ```\n */\n@api()\nexport class CommandClient implements ApiMetadataCapable {\n constructor(public readonly apiMetadata?: ApiMetadata) {\n bindMethods(this);\n }\n\n /**\n * Sends a command and resolves to the result of the stage it waited for\n * (`PROCESSED` unless the headers say otherwise). A command the server\n * refuses or fails to process rejects: Wow answers the failed result with\n * the HTTP status its `errorCode` maps to. Read it with `toWowError`.\n *\n * @param commandRequest - The route path, headers and body of the command\n * @param attributes - Optional shared attributes for the interceptors\n * @returns The command result\n */\n @endpoint()\n /* v8 ignore start */\n send<C extends object = object>(\n @request() commandRequest: CommandRequest<C>,\n @attribute() attributes?: Record<string, unknown>,\n ): Promise<CommandResult> {\n throw autoGeneratedError(commandRequest, attributes);\n }\n /* v8 ignore stop */\n\n /**\n * Sends a command and streams one result for every stage it reaches, up to\n * the one it waits for. The stream errors with a `WowError` if the server\n * fails midway, for example when the wait times out.\n *\n * @param commandRequest - The route path, headers and body of the command\n * @param attributes - Optional shared attributes for the interceptors\n * @returns A stream of command results\n *\n * @example\n * ```typescript\n * const results = await commandClient.sendAndWaitStream({\n * path: 'add_cart_item',\n * method: 'POST',\n * headers: waitStrategy({ stage: CommandStage.PROJECTED }),\n * body: { productId: 'product-1', quantity: 2 },\n * });\n * for await (const result of results) {\n * console.log(result.stage);\n * }\n * ```\n */\n @endpoint(undefined, undefined, COMMAND_STREAM_ENDPOINT)\n /* v8 ignore start */\n sendAndWaitStream<C extends object = object>(\n @request() commandRequest: CommandRequest<C>,\n @attribute() attributes?: Record<string, unknown>,\n ): Promise<CommandResultEventStream> {\n throw autoGeneratedError(commandRequest, attributes);\n }\n /* v8 ignore stop */\n}\n"],"mappings":";;;;;;;AAyDO,IAAMM,IAAN,MAAkD;CACvD,YAAY,GAA2C;EACrD,AAD0B,KAAA,cAAAC,GAC1BC,EAAY,IAAI;CAClB;CAYA,KAGE,GACA,GACwB;EACxB,MAAMC,EAAmBC,GAAgBC,CAAU;CACrD;;CAyBA,kBAGE,GACA,GACmC;EACnC,MAAMF,EAAmBC,GAAgBC,CAAU;CACrD;AAEF;;CAzCGC,EAAS;CAGPX,EAAA,GAAAY,EAAQ,CAAA;CACRZ,EAAA,GAAAa,EAAU,CAAA;;;;;CA4BZF,EAAS,KAAA,GAAW,KAAA,GAAWG,CAAuB;CAGpDd,EAAA,GAAAY,EAAQ,CAAA;CACRZ,EAAA,GAAAa,EAAU,CAAA;;;;4CApDd,IAAAd,EAAA,CAAAgB,EAAI,GAAAd,EAAA,qBAAA,CAAA,MAAA,CAAA,CAAA,GAAAI,CAAA"}
@@ -0,0 +1,2 @@
1
+ const e=require("../../error/headers.cjs");var t=Object.freeze({COMMAND_HEADERS_PREFIX:`Command-`,TENANT_ID:`Command-Tenant-Id`,OWNER_ID:`Command-Owner-Id`,SPACE_ID:e.WowHeaders.SPACE_ID,AGGREGATE_ID:`Command-Aggregate-Id`,AGGREGATE_VERSION:`Command-Aggregate-Version`,WAIT_PREFIX:`Command-Wait-`,WAIT_TIME_OUT:`Command-Wait-Timeout`,WAIT_STAGE:`Command-Wait-Stage`,WAIT_CONTEXT:`Command-Wait-Context`,WAIT_PROCESSOR:`Command-Wait-Processor`,WAIT_FUNCTION:`Command-Wait-Function`,WAIT_TAIL_PREFIX:`Command-Wait-Tail-`,WAIT_TAIL_STAGE:`Command-Wait-Tail-Stage`,WAIT_TAIL_CONTEXT:`Command-Wait-Tail-Context`,WAIT_TAIL_PROCESSOR:`Command-Wait-Tail-Processor`,WAIT_TAIL_FUNCTION:`Command-Wait-Tail-Function`,REQUEST_ID:`Command-Request-Id`,LOCAL_FIRST:`Command-Local-First`,COMMAND_AGGREGATE_CONTEXT:`Command-Aggregate-Context`,COMMAND_AGGREGATE_NAME:`Command-Aggregate-Name`,COMMAND_TYPE:`Command-Type`,COMMAND_HEADER_X_PREFIX:`Command-Header-`});exports.CommandHeaders=t;
2
+ //# sourceMappingURL=commandHeaders.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandHeaders.cjs","names":["WowHeaders","require_headers","CommandHeaders"],"sources":["../../../src/client/command/commandHeaders.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 { WowHeaders } from '../../error/headers.js';\n\n/**\n * Command Header Constants\n *\n * The HTTP headers a Wow command route reads. Each value is a string literal\n * type, so `CommandRequestHeaders` can type the value of every header by its\n * name. {@link commandHeaders} and {@link waitStrategy} build them from typed\n * options.\n *\n * Mirrors `CommandComponent.Header` in\n * `wow-openapi/src/main/kotlin/me/ahoo/wow/openapi/aggregate/command/CommandComponent.kt`.\n *\n * @example\n * ```typescript\n * const headers: CommandRequestHeaders = {\n * [CommandHeaders.TENANT_ID]: 'tenant-123',\n * [CommandHeaders.WAIT_STAGE]: CommandStage.SNAPSHOT,\n * };\n * ```\n */\nexport const CommandHeaders = Object.freeze({\n /** Prefix of the command headers */\n COMMAND_HEADERS_PREFIX: 'Command-',\n\n /** Tenant of the command, when the route has no tenant path segment */\n TENANT_ID: 'Command-Tenant-Id',\n\n /** Owner of the command, when the route has no owner path segment */\n OWNER_ID: 'Command-Owner-Id',\n\n /**\n * Space identifier header, `Wow-Space-Id`\n * Used to send the command into a space. The server reads it only for an\n * aggregate declared `@AggregateRoute(spaced = true)`; any other aggregate\n * ignores it and keeps the default space.\n *\n * The server shares this header with queries, so it has the `Wow-` prefix\n * rather than `Command-`; it is the same value as {@link WowHeaders.SPACE_ID}.\n */\n SPACE_ID: WowHeaders.SPACE_ID,\n\n /** Aggregate the command targets, when the route has no id path segment */\n AGGREGATE_ID: 'Command-Aggregate-Id',\n\n /** The aggregate version the command expects; a mismatch is a conflict */\n AGGREGATE_VERSION: 'Command-Aggregate-Version',\n\n /** Prefix of the wait headers */\n WAIT_PREFIX: 'Command-Wait-',\n\n /** How long the server waits for the wait stage, in milliseconds */\n WAIT_TIME_OUT: 'Command-Wait-Timeout',\n\n /** The stage to wait for; the server waits for `PROCESSED` when absent */\n WAIT_STAGE: 'Command-Wait-Stage',\n\n /** The bounded context whose processing the wait stage refers to */\n WAIT_CONTEXT: 'Command-Wait-Context',\n\n /** The processor whose processing the wait stage refers to */\n WAIT_PROCESSOR: 'Command-Wait-Processor',\n\n /** The function whose processing the wait stage refers to */\n WAIT_FUNCTION: 'Command-Wait-Function',\n\n /** Prefix of the wait-chain tail headers */\n WAIT_TAIL_PREFIX: 'Command-Wait-Tail-',\n\n /** The stage the command a saga sends must reach; only with `SAGA_HANDLED` */\n WAIT_TAIL_STAGE: 'Command-Wait-Tail-Stage',\n\n /** The bounded context of the wait-chain tail */\n WAIT_TAIL_CONTEXT: 'Command-Wait-Tail-Context',\n\n /** The processor of the wait-chain tail */\n WAIT_TAIL_PROCESSOR: 'Command-Wait-Tail-Processor',\n\n /** The function of the wait-chain tail */\n WAIT_TAIL_FUNCTION: 'Command-Wait-Tail-Function',\n\n /** Idempotency key of the command; a repeated one is refused */\n REQUEST_ID: 'Command-Request-Id',\n\n /** Whether the server may process the command locally, `true` or `false` */\n LOCAL_FIRST: 'Command-Local-First',\n\n /** Bounded context of the aggregate, for the `/wow/command/send` route */\n COMMAND_AGGREGATE_CONTEXT: 'Command-Aggregate-Context',\n\n /** Name of the aggregate, for the `/wow/command/send` route */\n COMMAND_AGGREGATE_NAME: 'Command-Aggregate-Name',\n\n /** Fully qualified command type, for the `/wow/command/send` route */\n COMMAND_TYPE: 'Command-Type',\n\n /** Prefix of the custom headers the server copies into the command header */\n COMMAND_HEADER_X_PREFIX: 'Command-Header-',\n} as const);\n"],"mappings":"2CAkCA,IAAaE,EAAiB,OAAO,OAAO,CAE1C,uBAAwB,WAGxB,UAAW,oBAGX,SAAU,mBAWV,SAAUF,EAAAA,WAAW,SAGrB,aAAc,uBAGd,kBAAmB,4BAGnB,YAAa,gBAGb,cAAe,uBAGf,WAAY,qBAGZ,aAAc,uBAGd,eAAgB,yBAGhB,cAAe,wBAGf,iBAAkB,qBAGlB,gBAAiB,0BAGjB,kBAAmB,4BAGnB,oBAAqB,8BAGrB,mBAAoB,6BAGpB,WAAY,qBAGZ,YAAa,sBAGb,0BAA2B,4BAG3B,uBAAwB,yBAGxB,aAAc,eAGd,wBAAyB,iBAC3B,CAAU"}