@ahoo-wang/wow-client 10.0.0-alpha.6 → 10.0.0-beta.1

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 (198) hide show
  1. package/README.md +77 -23
  2. package/README.zh-CN.md +67 -19
  3. package/dist/commands.cjs +1 -1
  4. package/dist/commands.cjs.map +1 -1
  5. package/dist/commands.d.cts +134 -61
  6. package/dist/commands.d.ts +134 -61
  7. package/dist/commands.es.js +129 -59
  8. package/dist/commands.es.js.map +1 -1
  9. package/dist/developmentCaller.cjs +2 -0
  10. package/dist/developmentCaller.cjs.map +1 -0
  11. package/dist/developmentCaller.d.cts +61 -0
  12. package/dist/developmentCaller.d.ts +61 -0
  13. package/dist/developmentCaller.es.js +26 -0
  14. package/dist/developmentCaller.es.js.map +1 -0
  15. package/dist/dsl/aggregation/admit.cjs +1 -1
  16. package/dist/dsl/aggregation/admit.cjs.map +1 -1
  17. package/dist/dsl/aggregation/admit.es.js +93 -93
  18. package/dist/dsl/aggregation/admit.es.js.map +1 -1
  19. package/dist/dsl/aggregation/builders.cjs +1 -1
  20. package/dist/dsl/aggregation/builders.cjs.map +1 -1
  21. package/dist/dsl/aggregation/builders.d.cts +20 -20
  22. package/dist/dsl/aggregation/builders.d.ts +20 -20
  23. package/dist/dsl/aggregation/builders.es.js +88 -88
  24. package/dist/dsl/aggregation/builders.es.js.map +1 -1
  25. package/dist/dsl/aggregation/derived.cjs.map +1 -1
  26. package/dist/dsl/aggregation/derived.d.cts +8 -8
  27. package/dist/dsl/aggregation/derived.d.ts +8 -8
  28. package/dist/dsl/aggregation/derived.es.js +1 -2
  29. package/dist/dsl/aggregation/derived.es.js.map +1 -1
  30. package/dist/dsl/aggregation/expressionTrees.cjs.map +1 -1
  31. package/dist/dsl/aggregation/expressionTrees.es.js +1 -2
  32. package/dist/dsl/aggregation/having.cjs +1 -1
  33. package/dist/dsl/aggregation/having.cjs.map +1 -1
  34. package/dist/dsl/aggregation/having.d.cts +12 -12
  35. package/dist/dsl/aggregation/having.d.ts +12 -12
  36. package/dist/dsl/aggregation/having.es.js +33 -33
  37. package/dist/dsl/aggregation/having.es.js.map +1 -1
  38. package/dist/dsl/aggregation/sort.cjs.map +1 -1
  39. package/dist/dsl/aggregation/sort.es.js +1 -2
  40. package/dist/dsl/aggregation/types.cjs +1 -1
  41. package/dist/dsl/aggregation/types.cjs.map +1 -1
  42. package/dist/dsl/aggregation/types.d.cts +69 -69
  43. package/dist/dsl/aggregation/types.d.ts +69 -69
  44. package/dist/dsl/aggregation/types.es.js +15 -16
  45. package/dist/dsl/aggregation/types.es.js.map +1 -1
  46. package/dist/dsl/constantName.cjs +2 -0
  47. package/dist/dsl/constantName.cjs.map +1 -0
  48. package/dist/dsl/constantName.d.cts +9 -0
  49. package/dist/dsl/constantName.d.ts +9 -0
  50. package/dist/dsl/constantName.es.js +7 -0
  51. package/dist/dsl/constantName.es.js.map +1 -0
  52. package/dist/dsl/cursorQuery.cjs.map +1 -1
  53. package/dist/dsl/cursorQuery.es.js +1 -2
  54. package/dist/dsl/deletionState.cjs +1 -1
  55. package/dist/dsl/deletionState.cjs.map +1 -1
  56. package/dist/dsl/deletionState.d.cts +3 -3
  57. package/dist/dsl/deletionState.d.ts +3 -3
  58. package/dist/dsl/deletionState.es.js +2 -3
  59. package/dist/dsl/deletionState.es.js.map +1 -1
  60. package/dist/dsl/descriptor.cjs +1 -1
  61. package/dist/dsl/descriptor.cjs.map +1 -1
  62. package/dist/dsl/descriptor.d.cts +99 -42
  63. package/dist/dsl/descriptor.d.ts +99 -42
  64. package/dist/dsl/descriptor.es.js +37 -29
  65. package/dist/dsl/descriptor.es.js.map +1 -1
  66. package/dist/dsl/field.cjs.map +1 -1
  67. package/dist/dsl/field.es.js +1 -2
  68. package/dist/dsl/filter/builders.cjs +1 -1
  69. package/dist/dsl/filter/builders.cjs.map +1 -1
  70. package/dist/dsl/filter/builders.d.cts +53 -53
  71. package/dist/dsl/filter/builders.d.ts +53 -53
  72. package/dist/dsl/filter/builders.es.js +111 -111
  73. package/dist/dsl/filter/builders.es.js.map +1 -1
  74. package/dist/dsl/filter/datePattern.cjs.map +1 -1
  75. package/dist/dsl/filter/datePattern.es.js +1 -2
  76. package/dist/dsl/filter/operator.cjs +1 -1
  77. package/dist/dsl/filter/operator.cjs.map +1 -1
  78. package/dist/dsl/filter/operator.d.cts +57 -57
  79. package/dist/dsl/filter/operator.d.ts +57 -57
  80. package/dist/dsl/filter/operator.es.js +4 -5
  81. package/dist/dsl/filter/operator.es.js.map +1 -1
  82. package/dist/dsl/filter/scope.cjs +1 -1
  83. package/dist/dsl/filter/scope.cjs.map +1 -1
  84. package/dist/dsl/filter/scope.es.js +12 -12
  85. package/dist/dsl/filter/scope.es.js.map +1 -1
  86. package/dist/dsl/filter/validate.cjs +1 -1
  87. package/dist/dsl/filter/validate.cjs.map +1 -1
  88. package/dist/dsl/filter/validate.es.js +23 -23
  89. package/dist/dsl/filter/validate.es.js.map +1 -1
  90. package/dist/dsl/pagination.cjs.map +1 -1
  91. package/dist/dsl/pagination.es.js +1 -2
  92. package/dist/dsl/projection.cjs.map +1 -1
  93. package/dist/dsl/projection.d.cts +1 -1
  94. package/dist/dsl/projection.d.ts +1 -1
  95. package/dist/dsl/projection.es.js +1 -2
  96. package/dist/dsl/projection.es.js.map +1 -1
  97. package/dist/dsl/queryErrorCodes.cjs +1 -1
  98. package/dist/dsl/queryErrorCodes.cjs.map +1 -1
  99. package/dist/dsl/queryErrorCodes.d.cts +59 -48
  100. package/dist/dsl/queryErrorCodes.d.ts +59 -48
  101. package/dist/dsl/queryErrorCodes.es.js +51 -50
  102. package/dist/dsl/queryErrorCodes.es.js.map +1 -1
  103. package/dist/dsl/queryable.cjs +1 -1
  104. package/dist/dsl/queryable.cjs.map +1 -1
  105. package/dist/dsl/queryable.d.cts +25 -21
  106. package/dist/dsl/queryable.d.ts +25 -21
  107. package/dist/dsl/queryable.es.js +5 -5
  108. package/dist/dsl/queryable.es.js.map +1 -1
  109. package/dist/dsl/sort.cjs +1 -1
  110. package/dist/dsl/sort.cjs.map +1 -1
  111. package/dist/dsl/sort.d.cts +2 -2
  112. package/dist/dsl/sort.d.ts +2 -2
  113. package/dist/dsl/sort.es.js +4 -5
  114. package/dist/dsl/sort.es.js.map +1 -1
  115. package/dist/dsl.cjs +1 -1
  116. package/dist/dsl.es.js +3 -3
  117. package/dist/exactJson.cjs.map +1 -1
  118. package/dist/exactJson.d.cts +4 -4
  119. package/dist/exactJson.d.ts +4 -4
  120. package/dist/exactJson.es.js +1 -2
  121. package/dist/exactJson.es.js.map +1 -1
  122. package/dist/frameworkErrors.cjs +2 -0
  123. package/dist/frameworkErrors.cjs.map +1 -0
  124. package/dist/frameworkErrors.d.cts +121 -0
  125. package/dist/frameworkErrors.d.ts +121 -0
  126. package/dist/frameworkErrors.es.js +95 -0
  127. package/dist/frameworkErrors.es.js.map +1 -0
  128. package/dist/http.cjs +1 -1
  129. package/dist/http.cjs.map +1 -1
  130. package/dist/http.d.cts +4 -7
  131. package/dist/http.d.ts +4 -7
  132. package/dist/http.es.js +12 -20
  133. package/dist/http.es.js.map +1 -1
  134. package/dist/index.cjs +1 -1
  135. package/dist/index.d.cts +9 -7
  136. package/dist/index.d.ts +9 -7
  137. package/dist/index.es.js +11 -9
  138. package/dist/manifest.cjs +1 -1
  139. package/dist/manifest.cjs.map +1 -1
  140. package/dist/manifest.d.cts +37 -95
  141. package/dist/manifest.d.ts +37 -95
  142. package/dist/manifest.es.js +12 -7
  143. package/dist/manifest.es.js.map +1 -1
  144. package/dist/manifestTypes.d.cts +195 -0
  145. package/dist/manifestTypes.d.ts +195 -0
  146. package/dist/problem.cjs +1 -1
  147. package/dist/problem.cjs.map +1 -1
  148. package/dist/problem.d.cts +76 -115
  149. package/dist/problem.d.ts +76 -115
  150. package/dist/problem.es.js +45 -80
  151. package/dist/problem.es.js.map +1 -1
  152. package/dist/queries.cjs +1 -1
  153. package/dist/queries.cjs.map +1 -1
  154. package/dist/queries.d.cts +28 -51
  155. package/dist/queries.d.ts +28 -51
  156. package/dist/queries.es.js +49 -40
  157. package/dist/queries.es.js.map +1 -1
  158. package/dist/routes.cjs +2 -0
  159. package/dist/routes.cjs.map +1 -0
  160. package/dist/routes.d.cts +49 -0
  161. package/dist/routes.d.ts +49 -0
  162. package/dist/routes.es.js +33 -0
  163. package/dist/routes.es.js.map +1 -0
  164. package/dist/state.cjs +1 -1
  165. package/dist/state.cjs.map +1 -1
  166. package/dist/state.d.cts +56 -11
  167. package/dist/state.d.ts +56 -11
  168. package/dist/state.es.js +56 -21
  169. package/dist/state.es.js.map +1 -1
  170. package/dist/streams.cjs +1 -1
  171. package/dist/streams.cjs.map +1 -1
  172. package/dist/streams.d.cts +17 -13
  173. package/dist/streams.d.ts +17 -13
  174. package/dist/streams.es.js +50 -50
  175. package/dist/streams.es.js.map +1 -1
  176. package/dist/testing/wire.cjs +2 -0
  177. package/dist/testing/wire.cjs.map +1 -0
  178. package/dist/testing/wire.d.cts +29 -0
  179. package/dist/testing/wire.d.ts +29 -0
  180. package/dist/testing/wire.es.js +88 -0
  181. package/dist/testing/wire.es.js.map +1 -0
  182. package/dist/testing.cjs +1 -0
  183. package/dist/testing.d.cts +12 -0
  184. package/dist/testing.d.ts +12 -0
  185. package/dist/testing.es.js +3 -0
  186. package/dist/wait.cjs +1 -1
  187. package/dist/wait.cjs.map +1 -1
  188. package/dist/wait.d.cts +68 -19
  189. package/dist/wait.d.ts +68 -19
  190. package/dist/wait.es.js +61 -14
  191. package/dist/wait.es.js.map +1 -1
  192. package/dist/wire.cjs +1 -1
  193. package/dist/wire.cjs.map +1 -1
  194. package/dist/wire.d.cts +101 -50
  195. package/dist/wire.d.ts +101 -50
  196. package/dist/wire.es.js +17 -6
  197. package/dist/wire.es.js.map +1 -1
  198. package/package.json +23 -3
@@ -0,0 +1,95 @@
1
+ // src/frameworkErrors.ts
2
+ var e = {
3
+ AUTH_UNAUTHENTICATED: "wow.auth.unauthenticated",
4
+ AUTH_FORBIDDEN: "wow.auth.forbidden",
5
+ AGGREGATE_FORBIDDEN: "wow.aggregate.forbidden",
6
+ REQUEST_MALFORMED: "wow.request.malformed",
7
+ COMMAND_MALFORMED: "wow.command.malformed",
8
+ COMMAND_INVALID: "wow.command.invalid",
9
+ WAIT_INVALID: "wow.wait.invalid",
10
+ COMMAND_UNHANDLED: "wow.command.unhandled",
11
+ AGGREGATE_NOT_FOUND: "wow.aggregate.not-found",
12
+ AGGREGATE_EXISTS: "wow.aggregate.exists",
13
+ AGGREGATE_VERSION_MISMATCH: "wow.aggregate.version-mismatch",
14
+ COMMAND_REQUEST_ID_REUSED: "wow.command.request-id-reused",
15
+ COMMAND_CONTENDED: "wow.command.contended",
16
+ AGGREGATE_DELETED: "wow.aggregate.deleted",
17
+ COMMAND_BUSY: "wow.command.busy",
18
+ COMMAND_UNKNOWN: "wow.command.unknown",
19
+ COMMAND_FAILED: "wow.command.failed",
20
+ COMMAND_REFUSED: "wow.command.refused",
21
+ COMMAND_UNDECLARED_EVENT: "wow.command.undeclared-event",
22
+ NODE_CLOSING: "wow.node.closing",
23
+ NODE_STANDBY: "wow.node.standby",
24
+ STORAGE_UNAVAILABLE: "wow.storage.unavailable",
25
+ SCHEDULE_NOT_DUE: "wow.schedule.not-due",
26
+ SCHEDULE_JOB_INVALID: "wow.schedule.job-invalid",
27
+ LEDGER_STALE: "wow.ledger.stale",
28
+ SUBSCRIPTION_PARKED: "wow.subscription.parked",
29
+ WAIT_TIMEOUT: "wow.wait.timeout",
30
+ ROUTE_MALFORMED: "wow.route.malformed",
31
+ QUERY_MALFORMED: "wow.query.malformed",
32
+ QUERY_INVALID: "wow.query.invalid",
33
+ QUERY_FAILED: "wow.query.failed",
34
+ QUERY_NOT_FOUND: "wow.query.not-found",
35
+ QUERY_DATASET_NOT_FOUND: "wow.query.dataset-not-found",
36
+ QUERY_TOO_MANY_GROUPS: "wow.query.too-many-groups",
37
+ QUERY_TIMEOUT: "wow.query.timeout",
38
+ QUERY_MIN_VERSION_NOT_REACHED: "wow.query.min-version-not-reached",
39
+ QUERY_BUSY: "wow.query.busy",
40
+ QUERY_DATASET_UNAVAILABLE: "wow.query.dataset-unavailable",
41
+ CALL_COMMAND_FORBIDDEN: "wow.call.command-forbidden",
42
+ PEER_UNAVAILABLE: "wow.peer.unavailable"
43
+ }, t = /* @__PURE__ */ new Map([
44
+ ["wow.command.contended", {
45
+ retry: "same-request",
46
+ retryAfterMs: 1e3
47
+ }],
48
+ ["wow.command.busy", {
49
+ retry: "same-request",
50
+ retryAfterMs: 1e3
51
+ }],
52
+ ["wow.command.unknown", {
53
+ retry: "same-request",
54
+ retryAfterMs: 1e3
55
+ }],
56
+ ["wow.node.closing", {
57
+ retry: "same-request",
58
+ retryAfterMs: 1e3
59
+ }],
60
+ ["wow.node.standby", {
61
+ retry: "same-request",
62
+ retryAfterMs: 1e3
63
+ }],
64
+ ["wow.storage.unavailable", {
65
+ retry: "same-request",
66
+ retryAfterMs: 1e3
67
+ }],
68
+ ["wow.schedule.not-due", {
69
+ retry: "same-request",
70
+ retryAfterMs: 1e3
71
+ }],
72
+ ["wow.wait.timeout", {
73
+ retry: "same-request",
74
+ retryAfterMs: 1e3
75
+ }],
76
+ ["wow.query.min-version-not-reached", {
77
+ retry: "new-request",
78
+ retryAfterMs: 1e3
79
+ }],
80
+ ["wow.query.busy", {
81
+ retry: "new-request",
82
+ retryAfterMs: 1e3
83
+ }],
84
+ ["wow.peer.unavailable", {
85
+ retry: "new-request",
86
+ retryAfterMs: 1e3
87
+ }]
88
+ ]), n = {
89
+ attempts: 5,
90
+ backoffMs: 200,
91
+ maxWaitMs: 5e3
92
+ };
93
+ export { n as DEFAULT_RETRY, t as FRAMEWORK_RETRIES, e as FrameworkErrorCodes };
94
+
95
+ //# sourceMappingURL=frameworkErrors.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frameworkErrors.es.js","names":["FrameworkErrorCodes","FRAMEWORK_RETRIES","DEFAULT_RETRY"],"sources":["../src/frameworkErrors.ts"],"sourcesContent":["// Code generated by scripts/framework-errors.mjs from the error catalog\n// (FrameworkErrors of :manifest, api/manifest/src/test/resources/framework-errors.json).\n// DO NOT EDIT: change FrameworkErrors and run the script.\n\n/**\n * What a retry of a request answered with an error may do, as the error\n * catalog declares it for the error's code and every problem carries it\n * (`retry`): `none`, a retry fails alike; `same-request`, send it again\n * with the same request id (`Wow-Request-Id`), so a command that did commit\n * is answered as its duplicate; `new-request`, send it again as it is.\n */\nexport type Retry = 'none' | 'same-request' | 'new-request';\n\n/**\n * The framework's error codes, each answered with the status of the error\n * catalog. A domain rejection has a code of its own, answered with 422 unless\n * the service configures another status.\n */\nexport const FrameworkErrorCodes = {\n /** 401 Unauthenticated: The request carries no valid credentials. */\n AUTH_UNAUTHENTICATED: 'wow.auth.unauthenticated',\n /** 403 Command forbidden: The caller may not send this command. */\n AUTH_FORBIDDEN: 'wow.auth.forbidden',\n /** 403 Aggregate out of scope: The aggregate is outside the caller's scope. */\n AGGREGATE_FORBIDDEN: 'wow.aggregate.forbidden',\n /** 400 Malformed request: A request header or parameter does not parse, or names what Wow does not take. */\n REQUEST_MALFORMED: 'wow.request.malformed',\n /** 400 Malformed command: The command body cannot be read as the command type. */\n COMMAND_MALFORMED: 'wow.command.malformed',\n /** 400 Invalid command: The command failed validation; the problem lists the violations. */\n COMMAND_INVALID: 'wow.command.invalid',\n /** 400 Invalid wait: The wait is not a chain the runtime can follow; the command was not run. */\n WAIT_INVALID: 'wow.wait.invalid',\n /** 400 Command not handled: The aggregate does not handle this command. */\n COMMAND_UNHANDLED: 'wow.command.unhandled',\n /** 404 Aggregate not found: The aggregate does not exist. */\n AGGREGATE_NOT_FOUND: 'wow.aggregate.not-found',\n /** 409 Aggregate exists: The aggregate already exists. */\n AGGREGATE_EXISTS: 'wow.aggregate.exists',\n /** 409 Version mismatch: The aggregate is not at the expected version (412 when the request carried If-Match). */\n AGGREGATE_VERSION_MISMATCH: 'wow.aggregate.version-mismatch',\n /** 409 Request id reused: The request id was used by another command. */\n COMMAND_REQUEST_ID_REUSED: 'wow.command.request-id-reused',\n /** 409 Command contended: Concurrent writers kept winning the version; retrying with the same request id is safe. */\n COMMAND_CONTENDED: 'wow.command.contended',\n /** 410 Aggregate deleted: The aggregate is deleted; only RestoreAggregate applies. */\n AGGREGATE_DELETED: 'wow.aggregate.deleted',\n /** 429 Command busy: The command was not taken: its aggregate has too many commands waiting, or the node too many in flight; retry later. */\n COMMAND_BUSY: 'wow.command.busy',\n /** 503 Command outcome unknown: Whether the command committed is unknown; retrying with the same request id is safe. */\n COMMAND_UNKNOWN: 'wow.command.unknown',\n /** 500 Command failed: The command's handling failed with an unexpected error; it committed nothing, and a retry fails alike. */\n COMMAND_FAILED: 'wow.command.failed',\n /** 409 Command refused: The aggregate's current state refuses the command (a check of its decide function); the message says why. */\n COMMAND_REFUSED: 'wow.command.refused',\n /** 500 Undeclared event: The command's handling produced an event its decide function or after hooks do not declare: a bug in the model, which the message names; it committed nothing. */\n COMMAND_UNDECLARED_EVENT: 'wow.command.undeclared-event',\n /** 503 Node closing: The node is shutting down; retry on another node. */\n NODE_CLOSING: 'wow.node.closing',\n /** 503 Node on standby: The node is on standby until the cut-over: it serves reads only. */\n NODE_STANDBY: 'wow.node.standby',\n /** 503 Storage unavailable: A store could not be reached or did not answer in time; retry later, a command with the same request id. */\n STORAGE_UNAVAILABLE: 'wow.storage.unavailable',\n /** 503 Schedule not due: A scheduled command arrived too long before its due time on this node's clock; it is sent again later. */\n SCHEDULE_NOT_DUE: 'wow.schedule.not-due',\n /** 400 Invalid schedule job: The job command does not fit its job or instance: an unknown job, another scope, or an instance not enabled. */\n SCHEDULE_JOB_INVALID: 'wow.schedule.job-invalid',\n /** 409 Stale ledger action: The action names a parking the entry no longer is: the aggregate was resolved and parked again since; read the entry again before acting on it. */\n LEDGER_STALE: 'wow.ledger.stale',\n /** 500 Subscription parked: A subscription on the wait chain parked the aggregate; the wait cannot be reached until the aggregate is retried. */\n SUBSCRIPTION_PARKED: 'wow.subscription.parked',\n /** 504 Wait timed out: The wait ran out of time; the command may have committed. The problem carries the last stage reached. */\n WAIT_TIMEOUT: 'wow.wait.timeout',\n /** 400 Malformed route request: A service route's parameter or body cannot be read as its type; the violation names the parameter. */\n ROUTE_MALFORMED: 'wow.route.malformed',\n /** 400 Malformed query: The query body cannot be read as a query. */\n QUERY_MALFORMED: 'wow.query.malformed',\n /** 400 Invalid query: The query failed admission; the problem lists the violations, each with its code (UNKNOWN_FIELD, ...). */\n QUERY_INVALID: 'wow.query.invalid',\n /** 500 Query failed: The query backend failed to run the query. */\n QUERY_FAILED: 'wow.query.failed',\n /** 404 No matching record: A single query matched no record: a query result, not a statement that an aggregate does not exist. */\n QUERY_NOT_FOUND: 'wow.query.not-found',\n /** 404 Dataset not found: No dataset of that name is served to the caller. */\n QUERY_DATASET_NOT_FOUND: 'wow.query.dataset-not-found',\n /** 400 Too many groups: An aggregation that names no sort has more groups than its limit; add a sort for a top-N, or raise limit. */\n QUERY_TOO_MANY_GROUPS: 'wow.query.too-many-groups',\n /** 504 Query timed out: The query ran longer than its budget allows; narrow it rather than run it again. */\n QUERY_TIMEOUT: 'wow.query.timeout',\n /** 409 Version not reached: The state read asked for a version the aggregate has not reached within the wait; the problem carries its current version: retry later. */\n QUERY_MIN_VERSION_NOT_REACHED: 'wow.query.min-version-not-reached',\n /** 429 Query busy: The query was not run: its store has as many queries running as it allows; retry later. */\n QUERY_BUSY: 'wow.query.busy',\n /** 409 Dataset unavailable: The dataset is served but cannot be queried now, for the reason the problem names (it needs revision). */\n QUERY_DATASET_UNAVAILABLE: 'wow.query.dataset-unavailable',\n /** 403 Call forbidden: The calling service may not call this command: its wow.callers.<service>.commands do not list it. */\n CALL_COMMAND_FORBIDDEN: 'wow.call.command-forbidden',\n /** 503 Peer unavailable: A client reached no node of the peer, or lost the connection before a query's answer; nothing was changed, so the request may be sent again. */\n PEER_UNAVAILABLE: 'wow.peer.unavailable',\n} as const;\n\n/** A {@link FrameworkErrorCodes} value. */\nexport type FrameworkErrorCode =\n (typeof FrameworkErrorCodes)[keyof typeof FrameworkErrorCodes];\n\n/** What a retry of a framework code may do, as the error catalog declares it. */\nexport interface FrameworkRetry {\n /** What a retry may do: never `none` here. */\n readonly retry: Retry;\n /** Its `Retry-After`, in milliseconds. */\n readonly retryAfterMs: number;\n}\n\n/**\n * What a retry may do of each framework code a retry may get past, by code;\n * a retry of every other code, a domain's among them, is `none`.\n */\nexport const FRAMEWORK_RETRIES: ReadonlyMap<string, FrameworkRetry> = new Map<\n string,\n FrameworkRetry\n>([\n ['wow.command.contended', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.command.busy', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.command.unknown', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.node.closing', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.node.standby', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.storage.unavailable', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.schedule.not-due', { retry: 'same-request', retryAfterMs: 1000 }],\n ['wow.wait.timeout', { retry: 'same-request', retryAfterMs: 1000 }],\n [\n 'wow.query.min-version-not-reached',\n { retry: 'new-request', retryAfterMs: 1000 },\n ],\n ['wow.query.busy', { retry: 'new-request', retryAfterMs: 1000 }],\n ['wow.peer.unavailable', { retry: 'new-request', retryAfterMs: 1000 }],\n]);\n\n/**\n * How often, and after how long, a client sends a request again by default\n * when a retry may get past its error, as the Kotlin client does\n * (`RetryPolicy.DEFAULT`): at most `attempts` attempts, the first included,\n * `backoffMs` before the first retry without a `Retry-After`, doubled at each\n * attempt up to `maxWaitMs`.\n */\nexport const DEFAULT_RETRY = {\n attempts: 5,\n backoffMs: 200,\n maxWaitMs: 5000,\n} as const;\n"],"mappings":";AAkBA,IAAaA,IAAsB;CAEjC,sBAAsB;CAEtB,gBAAgB;CAEhB,qBAAqB;CAErB,mBAAmB;CAEnB,mBAAmB;CAEnB,iBAAiB;CAEjB,cAAc;CAEd,mBAAmB;CAEnB,qBAAqB;CAErB,kBAAkB;CAElB,4BAA4B;CAE5B,2BAA2B;CAE3B,mBAAmB;CAEnB,mBAAmB;CAEnB,cAAc;CAEd,iBAAiB;CAEjB,gBAAgB;CAEhB,iBAAiB;CAEjB,0BAA0B;CAE1B,cAAc;CAEd,cAAc;CAEd,qBAAqB;CAErB,kBAAkB;CAElB,sBAAsB;CAEtB,cAAc;CAEd,qBAAqB;CAErB,cAAc;CAEd,iBAAiB;CAEjB,iBAAiB;CAEjB,eAAe;CAEf,cAAc;CAEd,iBAAiB;CAEjB,yBAAyB;CAEzB,uBAAuB;CAEvB,eAAe;CAEf,+BAA+B;CAE/B,YAAY;CAEZ,2BAA2B;CAE3B,wBAAwB;CAExB,kBAAkB;AACpB,GAkBaC,oBAAyD,IAAI,IAGxE;CACA,CAAC,yBAAyB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CACvE,CAAC,oBAAoB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CAClE,CAAC,uBAAuB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CACrE,CAAC,oBAAoB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CAClE,CAAC,oBAAoB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CAClE,CAAC,2BAA2B;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CACzE,CAAC,wBAAwB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CACtE,CAAC,oBAAoB;EAAE,OAAO;EAAgB,cAAc;CAAK,CAAC;CAClE,CACE,qCACA;EAAE,OAAO;EAAe,cAAc;CAAK,CAC7C;CACA,CAAC,kBAAkB;EAAE,OAAO;EAAe,cAAc;CAAK,CAAC;CAC/D,CAAC,wBAAwB;EAAE,OAAO;EAAe,cAAc;CAAK,CAAC;AACvE,CAAC,GASYC,IAAgB;CAC3B,UAAU;CACV,WAAW;CACX,WAAW;AACb"}
package/dist/http.cjs CHANGED
@@ -1,2 +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;
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){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 s(i,s){let c=s.options??{},l={};for(let[e,t]of Object.entries({...s.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=s.body!==void 0&&!e.marksNothing(s.bodyNumbers);u&&(l[`Content-Type`]=`application/json`);let d=`${i.basePath??``}${s.path}${o(s.query)}`;try{return await(i.fetcher??n.fetcher).fetch(d,{method:s.method,headers:l,...s.body===void 0?{}:{body:u?e.stringifyJson(s.body,s.bodyNumbers):s.body},...c.signal===void 0?{}:{signal:c.signal}})}catch(e){let n=e?.exchange?.response;if(s.notModified&&n?.status===304)return n;throw await t.toWowProblemError(e)??e}}async function c(t,n){return e.marksNothing(n)?await t.json():e.parseJson(await t.text(),n)}function l(e){let t=e.headers.get(r.ETAG);return t===null?void 0:t.replace(/^W\//,``).replace(/"/g,``)}exports.WowHeaders=r,exports.entityTag=l,exports.formatScope=a,exports.json=c,exports.send=s;
2
2
  //# sourceMappingURL=http.cjs.map
package/dist/http.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"http.cjs","names":["marksNothing","defaultFetcher","stringifyJson","toWowProblemError","parseJson","require_exactJson","require_problem","_ahoo_wang_fetcher","WowHeaders","quote","value","formatScope","members","scope","member","expandPath","path","params","name","queryString","query","text","send","options","call","headers","exact","url","client","error","response","json","numbers","entityTag","tag"],"sources":["../src/http.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type Fetcher, fetcher as defaultFetcher } from '@ahoo-wang/fetcher';\nimport {\n marksNothing,\n parseJson,\n stringifyJson,\n type TextNumbers,\n} from './exactJson.js';\nimport { toWowProblemError } from './problem.js';\n\n/**\n * The request headers of a Wow service's public port (decisions D95,\n * D96, D98, D99).\n */\nexport const WowHeaders = {\n /** The caller's id of the request: a retry with the same one is deduplicated. */\n REQUEST_ID: 'Wow-Request-Id',\n /** The wait plan (decision D99). */\n WAIT: 'Wow-Wait',\n /** How long to wait: `500ms`, `10s` or an ISO-8601 duration. */\n WAIT_TIMEOUT: 'Wow-Wait-Timeout',\n /** The scope to act in, for a caller allowed to act across scopes (decision D95). */\n SCOPE: 'Wow-Scope',\n /** The space, among the caller's own, to act in (decision D96). */\n SPACE: 'Wow-Space',\n /** The expected version of the aggregate, as an entity tag. */\n IF_MATCH: 'If-Match',\n /** The version, or descriptor version, a read already holds. */\n IF_NONE_MATCH: 'If-None-Match',\n /** The version of a state read, or of a query descriptor. */\n ETAG: 'ETag',\n /** The seconds after which a failed request may be retried. */\n RETRY_AFTER: 'Retry-After',\n /** The position a streamed list resumes after (decision D253). */\n LAST_EVENT_ID: 'Last-Event-ID',\n} as const;\n\n/** How a client reaches its service. */\nexport interface WowClientOptions {\n /**\n * The fetcher requests go through, with its base URL and interceptors\n * (authentication, say); the default fetcher when absent.\n */\n readonly fetcher?: Fetcher;\n /** A path put before every route, such as a gateway's prefix. */\n readonly basePath?: string;\n}\n\n/**\n * The scope a caller allowed to act across scopes acts in: the `Wow-Scope`\n * header (decision D95).\n */\nexport interface TargetScope {\n readonly tenantId?: string;\n readonly ownerId?: string;\n readonly spaceId?: string;\n}\n\nfunction quote(value: string): string {\n return `\"${value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')}\"`;\n}\n\n/**\n * A target scope as the `Wow-Scope` header spells it, an RFC 8941\n * dictionary: `tenant=\"t1\", owner=\"u1\", space=\"s1\"`.\n *\n * @param scope - The scope; at least one of its members is set\n */\nexport function formatScope(scope: TargetScope): string {\n const members = [\n scope.tenantId === undefined\n ? undefined\n : `tenant=${quote(scope.tenantId)}`,\n scope.ownerId === undefined ? undefined : `owner=${quote(scope.ownerId)}`,\n scope.spaceId === undefined ? undefined : `space=${quote(scope.spaceId)}`,\n ].filter(member => member !== undefined);\n if (members.length === 0) {\n throw new TypeError('Wow-Scope names a tenant, an owner or a space.');\n }\n return members.join(', ');\n}\n\n/** What every request may carry beside its own parameters. */\nexport interface RequestOptions {\n /** The scope to act in (`Wow-Scope`), for a caller allowed to. */\n readonly scope?: TargetScope;\n /** The space to act in (`Wow-Space`), among the caller's own. */\n readonly space?: string;\n /** More headers: the request facts the service records, say. */\n readonly headers?: Readonly<Record<string, string>>;\n /** Cancels the request. */\n readonly signal?: AbortSignal;\n}\n\n/** One request of a client. */\nexport interface Call {\n readonly method: 'GET' | 'POST' | 'DELETE';\n readonly path: string;\n readonly query?: Readonly<Record<string, string | number | undefined>>;\n readonly headers?: Readonly<Record<string, string | undefined>>;\n readonly body?: unknown;\n /** The body's numbers written as their exact text ({@link TextNumbers}). */\n readonly bodyNumbers?: TextNumbers;\n readonly options?: RequestOptions;\n /** Answers a 304 rather than rejecting with it. */\n readonly notModified?: boolean;\n}\n\n/** `{name}` segments of `path` filled from `params`, each encoded. */\nexport function expandPath(\n path: string,\n params: Readonly<Record<string, string>>,\n): string {\n return path.replace(/\\{([^}]+)\\}/g, (segment, name: string) => {\n const value = params[name];\n if (value === undefined || value === '') {\n throw new TypeError(`The path ${path} needs ${name}.`);\n }\n return encodeURIComponent(value);\n });\n}\n\nfunction queryString(\n query: Readonly<Record<string, string | number | undefined>> | undefined,\n): string {\n if (!query) return '';\n const params = new URLSearchParams();\n for (const [name, value] of Object.entries(query)) {\n if (value !== undefined) params.append(name, String(value));\n }\n const text = params.toString();\n return text ? `?${text}` : '';\n}\n\n/**\n * Sends one request through the client's fetcher and answers its response;\n * a response that is not 2xx rejects with a {@link WowProblemError}.\n *\n * @param client - The client's options\n * @param call - The request\n */\nexport async function send(\n client: WowClientOptions,\n call: Call,\n): Promise<Response> {\n const options = call.options ?? {};\n const headers: Record<string, string> = {};\n for (const [name, value] of Object.entries({\n ...call.headers,\n ...(options.scope === undefined\n ? {}\n : { [WowHeaders.SCOPE]: formatScope(options.scope) }),\n ...(options.space === undefined\n ? {}\n : { [WowHeaders.SPACE]: options.space }),\n ...options.headers,\n })) {\n if (value !== undefined) headers[name] = value;\n }\n // A body with exact numbers goes as its own JSON text, those numbers unquoted.\n const exact = call.body !== undefined && !marksNothing(call.bodyNumbers);\n if (exact) headers['Content-Type'] = 'application/json';\n const url = `${client.basePath ?? ''}${call.path}${queryString(call.query)}`;\n try {\n return await (client.fetcher ?? defaultFetcher).fetch(url, {\n method: call.method,\n headers,\n ...(call.body === undefined\n ? {}\n : {\n body: exact\n ? stringifyJson(call.body, call.bodyNumbers)\n : (call.body as object),\n }),\n ...(options.signal === undefined ? {} : { signal: options.signal }),\n });\n } catch (error) {\n const response = (error as { exchange?: { response?: Response } })?.exchange\n ?.response;\n if (call.notModified && response?.status === 304) return response;\n throw (await toWowProblemError(error)) ?? error;\n }\n}\n\n/**\n * The JSON body of a 2xx response; the numbers `numbers` marks come back as\n * their exact text (review R4-Q, Q-9), and without marks it is\n * `response.json()` itself.\n */\nexport async function json<T>(\n response: Response,\n numbers?: TextNumbers,\n): Promise<T> {\n if (marksNothing(numbers)) return (await response.json()) as T;\n return parseJson(await response.text(), numbers) as T;\n}\n\n/** The entity tag of a response without its quotes or weak marker. */\nexport function entityTag(response: Response): string | undefined {\n const tag = response.headers.get(WowHeaders.ETAG);\n return tag === null ? undefined : tag.replace(/^W\\//, '').replace(/\"/g, '');\n}\n"],"mappings":"kGA0BA,IAAaQ,EAAa,CAExB,WAAY,iBAEZ,KAAM,WAEN,aAAc,mBAEd,MAAO,YAEP,MAAO,YAEP,SAAU,WAEV,cAAe,gBAEf,KAAM,OAEN,YAAa,cAEb,cAAe,eACjB,EAuBA,SAASC,EAAM,EAAuB,CACpC,MAAO,IAAIC,EAAM,QAAQ,MAAO,MAAM,CAAC,CAAC,QAAQ,KAAM,KAAK,EAAE,EAC/D,CAQA,SAAgBC,EAAY,EAA4B,CACtD,IAAMC,EAAU,CACdC,EAAM,WAAa,IAAA,GACf,IAAA,GACA,UAAUJ,EAAMI,EAAM,QAAQ,IAClCA,EAAM,UAAY,IAAA,GAAY,IAAA,GAAY,SAASJ,EAAMI,EAAM,OAAO,IACtEA,EAAM,UAAY,IAAA,GAAY,IAAA,GAAY,SAASJ,EAAMI,EAAM,OAAO,GACxE,CAAC,CAAC,OAAO,GAAUC,IAAW,IAAA,EAAS,EACvC,GAAIF,EAAQ,SAAW,EACrB,MAAU,UAAU,gDAAgD,EAEtE,OAAOA,EAAQ,KAAK,IAAI,CAC1B,CA6BA,SAAgBG,EACd,EACA,EACQ,CACR,OAAOC,EAAK,QAAQ,gBAAiB,EAAS,IAAiB,CAC7D,IAAMN,EAAQO,EAAOC,GACrB,GAAIR,IAAU,IAAA,IAAaA,IAAU,GACnC,MAAU,UAAU,YAAYM,EAAK,SAASE,EAAK,EAAE,EAEvD,OAAO,mBAAmBR,CAAK,CACjC,CAAC,CACH,CAEA,SAASS,EACP,EACQ,CACR,GAAI,CAACC,EAAO,MAAO,GACnB,IAAMH,EAAS,IAAI,gBACnB,IAAK,GAAM,CAACC,EAAMR,KAAU,OAAO,QAAQU,CAAK,EAC1CV,IAAU,IAAA,IAAWO,EAAO,OAAOC,EAAM,OAAOR,CAAK,CAAC,EAE5D,IAAMW,EAAOJ,EAAO,SAAS,EAC7B,OAAOI,EAAO,IAAIA,IAAS,EAC7B,CASA,eAAsBC,EACpB,EACA,EACmB,CACnB,IAAMC,EAAUC,EAAK,SAAW,CAAC,EAC3BC,EAAkC,CAAC,EACzC,IAAK,GAAM,CAACP,EAAMR,KAAU,OAAO,QAAQ,CACzC,GAAGc,EAAK,QACR,GAAID,EAAQ,QAAU,IAAA,GAClB,CAAC,EACD,EAAGf,EAAW,OAAQG,EAAYY,EAAQ,KAAK,CAAE,EACrD,GAAIA,EAAQ,QAAU,IAAA,GAClB,CAAC,EACD,EAAGf,EAAW,OAAQe,EAAQ,KAAM,EACxC,GAAGA,EAAQ,OACb,CAAC,EACKb,IAAU,IAAA,KAAW,EAAQQ,GAAQR,GAG3C,IAAMgB,EAAQF,EAAK,OAAS,IAAA,IAAa,CAACxB,EAAAA,aAAawB,EAAK,WAAW,EACnEE,IAAO,EAAQ,gBAAkB,oBACrC,IAAMC,EAAM,GAAGC,EAAO,UAAY,KAAKJ,EAAK,OAAOL,EAAYK,EAAK,KAAK,IACzE,GAAI,CACF,OAAO,MAAOI,EAAO,SAAW3B,EAAAA,QAAAA,CAAgB,MAAM0B,EAAK,CACzD,OAAQH,EAAK,OACb,UACA,GAAIA,EAAK,OAAS,IAAA,GACd,CAAC,EACD,CACE,KAAME,EACFxB,EAAAA,cAAcsB,EAAK,KAAMA,EAAK,WAAW,EACxCA,EAAK,IACZ,EACJ,GAAID,EAAQ,SAAW,IAAA,GAAY,CAAC,EAAI,CAAE,OAAQA,EAAQ,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"}
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","queryString","query","params","name","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.\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.\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' | 'PUT' | 'PATCH' | '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\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, 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":"A,kGAyBA,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,CA4BA,SAASG,EACP,EACQ,CACR,GAAI,CAACC,EAAO,MAAO,GACnB,IAAMC,EAAS,IAAI,gBACnB,IAAK,GAAM,CAACC,EAAMR,KAAU,OAAO,QAAQM,CAAK,EAC1CN,IAAU,IAAA,IAAWO,EAAO,OAAOC,EAAM,OAAOR,CAAK,CAAC,EAE5D,IAAMS,EAAOF,EAAO,SAAS,EAC7B,OAAOE,EAAO,IAAIA,IAAS,EAC7B,CASA,eAAsBC,EACpB,EACA,EACmB,CACnB,IAAMC,EAAUC,EAAK,SAAW,CAAC,EAC3BC,EAAkC,CAAC,EACzC,IAAK,GAAM,CAACL,EAAMR,KAAU,OAAO,QAAQ,CACzC,GAAGY,EAAK,QACR,GAAID,EAAQ,QAAU,IAAA,GAClB,CAAC,EACD,EAAGb,EAAW,OAAQG,EAAYU,EAAQ,KAAK,CAAE,EACrD,GAAIA,EAAQ,QAAU,IAAA,GAClB,CAAC,EACD,EAAGb,EAAW,OAAQa,EAAQ,KAAM,EACxC,GAAGA,EAAQ,OACb,CAAC,EACKX,IAAU,IAAA,KAAW,EAAQQ,GAAQR,GAG3C,IAAMc,EAAQF,EAAK,OAAS,IAAA,IAAa,CAACtB,EAAAA,aAAasB,EAAK,WAAW,EACnEE,IAAO,EAAQ,gBAAkB,oBACrC,IAAMC,EAAM,GAAGC,EAAO,UAAY,KAAKJ,EAAK,OAAOP,EAAYO,EAAK,KAAK,IACzE,GAAI,CACF,OAAO,MAAOI,EAAO,SAAWzB,EAAAA,QAAAA,CAAgB,MAAMwB,EAAK,CACzD,OAAQH,EAAK,OACb,UACA,GAAIA,EAAK,OAAS,IAAA,GACd,CAAC,EACD,CACE,KAAME,EACFtB,EAAAA,cAAcoB,EAAK,KAAMA,EAAK,WAAW,EACxCA,EAAK,IACZ,EACJ,GAAID,EAAQ,SAAW,IAAA,GAAY,CAAC,EAAI,CAAE,OAAQA,EAAQ,MAAO,CACnE,CAAC,CACH,OAASM,EAAO,CACd,IAAMC,EAAYD,GAAkD,UAChE,SACJ,GAAIL,EAAK,aAAeM,GAAU,SAAW,IAAK,OAAOA,EACzD,MAAO,MAAMzB,EAAAA,kBAAkBwB,CAAK,GAAMA,CAC5C,CACF,CAOA,eAAsBE,EACpB,EACA,EACY,CAEZ,OADI7B,EAAAA,aAAa8B,CAAO,EAAW,MAAMF,EAAS,KAAK,EAChDxB,EAAAA,UAAU,MAAMwB,EAAS,KAAK,EAAGE,CAAO,CACjD,CAGA,SAAgBC,EAAU,EAAwC,CAChE,IAAMC,EAAMJ,EAAS,QAAQ,IAAIpB,EAAW,IAAI,EAChD,OAAOwB,IAAQ,KAAO,IAAA,GAAYA,EAAI,QAAQ,OAAQ,EAAE,CAAC,CAAC,QAAQ,KAAM,EAAE,CAC5E,C"}
package/dist/http.d.cts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { Fetcher } from '@ahoo-wang/fetcher';
2
2
  import { TextNumbers } from './exactJson.cjs';
3
3
  /**
4
- * The request headers of a Wow service's public port (decisions D95,
5
- * D96, D98, D99).
4
+ * The request headers of a Wow service's public port.
6
5
  */
7
6
  export declare const WowHeaders: {
8
7
  /** The caller's id of the request: a retry with the same one is deduplicated. */
@@ -38,7 +37,7 @@ export interface WowClientOptions {
38
37
  }
39
38
  /**
40
39
  * The scope a caller allowed to act across scopes acts in: the `Wow-Scope`
41
- * header (decision D95).
40
+ * header.
42
41
  */
43
42
  export interface TargetScope {
44
43
  readonly tenantId?: string;
@@ -65,7 +64,7 @@ export interface RequestOptions {
65
64
  }
66
65
  /** One request of a client. */
67
66
  export interface Call {
68
- readonly method: 'GET' | 'POST' | 'DELETE';
67
+ readonly method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
69
68
  readonly path: string;
70
69
  readonly query?: Readonly<Record<string, string | number | undefined>>;
71
70
  readonly headers?: Readonly<Record<string, string | undefined>>;
@@ -76,8 +75,6 @@ export interface Call {
76
75
  /** Answers a 304 rather than rejecting with it. */
77
76
  readonly notModified?: boolean;
78
77
  }
79
- /** `{name}` segments of `path` filled from `params`, each encoded. */
80
- export declare function expandPath(path: string, params: Readonly<Record<string, string>>): string;
81
78
  /**
82
79
  * Sends one request through the client's fetcher and answers its response;
83
80
  * a response that is not 2xx rejects with a {@link WowProblemError}.
@@ -88,7 +85,7 @@ export declare function expandPath(path: string, params: Readonly<Record<string,
88
85
  export declare function send(client: WowClientOptions, call: Call): Promise<Response>;
89
86
  /**
90
87
  * 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
88
+ * their exact text, and without marks it is
92
89
  * `response.json()` itself.
93
90
  */
94
91
  export declare function json<T>(response: Response, numbers?: TextNumbers): Promise<T>;
package/dist/http.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import { Fetcher } from '@ahoo-wang/fetcher';
2
2
  import { TextNumbers } from './exactJson.js';
3
3
  /**
4
- * The request headers of a Wow service's public port (decisions D95,
5
- * D96, D98, D99).
4
+ * The request headers of a Wow service's public port.
6
5
  */
7
6
  export declare const WowHeaders: {
8
7
  /** The caller's id of the request: a retry with the same one is deduplicated. */
@@ -38,7 +37,7 @@ export interface WowClientOptions {
38
37
  }
39
38
  /**
40
39
  * The scope a caller allowed to act across scopes acts in: the `Wow-Scope`
41
- * header (decision D95).
40
+ * header.
42
41
  */
43
42
  export interface TargetScope {
44
43
  readonly tenantId?: string;
@@ -65,7 +64,7 @@ export interface RequestOptions {
65
64
  }
66
65
  /** One request of a client. */
67
66
  export interface Call {
68
- readonly method: 'GET' | 'POST' | 'DELETE';
67
+ readonly method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
69
68
  readonly path: string;
70
69
  readonly query?: Readonly<Record<string, string | number | undefined>>;
71
70
  readonly headers?: Readonly<Record<string, string | undefined>>;
@@ -76,8 +75,6 @@ export interface Call {
76
75
  /** Answers a 304 rather than rejecting with it. */
77
76
  readonly notModified?: boolean;
78
77
  }
79
- /** `{name}` segments of `path` filled from `params`, each encoded. */
80
- export declare function expandPath(path: string, params: Readonly<Record<string, string>>): string;
81
78
  /**
82
79
  * Sends one request through the client's fetcher and answers its response;
83
80
  * a response that is not 2xx rejects with a {@link WowProblemError}.
@@ -88,7 +85,7 @@ export declare function expandPath(path: string, params: Readonly<Record<string,
88
85
  export declare function send(client: WowClientOptions, call: Call): Promise<Response>;
89
86
  /**
90
87
  * 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
88
+ * their exact text, and without marks it is
92
89
  * `response.json()` itself.
93
90
  */
94
91
  export declare function json<T>(response: Response, numbers?: TextNumbers): Promise<T>;
package/dist/http.es.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { marksNothing as e, parseJson as t, stringifyJson as n } from "./exactJson.es.js";
2
2
  import { toWowProblemError as r } from "./problem.es.js";
3
3
  import { fetcher as i } from "@ahoo-wang/fetcher";
4
- //#region src/http.ts
4
+ // src/http.ts
5
5
  var a = {
6
6
  REQUEST_ID: "Wow-Request-Id",
7
7
  WAIT: "Wow-Wait",
@@ -26,37 +26,30 @@ function s(e) {
26
26
  if (t.length === 0) throw TypeError("Wow-Scope names a tenant, an owner or a space.");
27
27
  return t.join(", ");
28
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) {
29
+ function c(e) {
37
30
  if (!e) return "";
38
31
  let t = new URLSearchParams();
39
32
  for (let [n, r] of Object.entries(e)) r !== void 0 && t.append(n, String(r));
40
33
  let n = t.toString();
41
34
  return n ? `?${n}` : "";
42
35
  }
43
- async function u(t, o) {
44
- let c = o.options ?? {}, u = {};
36
+ async function l(t, o) {
37
+ let l = o.options ?? {}, u = {};
45
38
  for (let [e, t] of Object.entries({
46
39
  ...o.headers,
47
- ...c.scope === void 0 ? {} : { [a.SCOPE]: s(c.scope) },
48
- ...c.space === void 0 ? {} : { [a.SPACE]: c.space },
49
- ...c.headers
40
+ ...l.scope === void 0 ? {} : { [a.SCOPE]: s(l.scope) },
41
+ ...l.space === void 0 ? {} : { [a.SPACE]: l.space },
42
+ ...l.headers
50
43
  })) t !== void 0 && (u[e] = t);
51
44
  let d = o.body !== void 0 && !e(o.bodyNumbers);
52
45
  d && (u["Content-Type"] = "application/json");
53
- let f = `${t.basePath ?? ""}${o.path}${l(o.query)}`;
46
+ let f = `${t.basePath ?? ""}${o.path}${c(o.query)}`;
54
47
  try {
55
48
  return await (t.fetcher ?? i).fetch(f, {
56
49
  method: o.method,
57
50
  headers: u,
58
51
  ...o.body === void 0 ? {} : { body: d ? n(o.body, o.bodyNumbers) : o.body },
59
- ...c.signal === void 0 ? {} : { signal: c.signal }
52
+ ...l.signal === void 0 ? {} : { signal: l.signal }
60
53
  });
61
54
  } catch (e) {
62
55
  let t = e?.exchange?.response;
@@ -64,14 +57,13 @@ async function u(t, o) {
64
57
  throw await r(e) ?? e;
65
58
  }
66
59
  }
67
- async function d(n, r) {
60
+ async function u(n, r) {
68
61
  return e(r) ? await n.json() : t(await n.text(), r);
69
62
  }
70
- function f(e) {
63
+ function d(e) {
71
64
  let t = e.headers.get(a.ETAG);
72
65
  return t === null ? void 0 : t.replace(/^W\//, "").replace(/"/g, "");
73
66
  }
74
- //#endregion
75
- export { a as WowHeaders, f as entityTag, c as expandPath, s as formatScope, d as json, u as send };
67
+ export { a as WowHeaders, d as entityTag, s as formatScope, u as json, l as send };
76
68
 
77
69
  //# sourceMappingURL=http.es.js.map
@@ -1 +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":"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"}
1
+ {"version":3,"file":"http.es.js","names":["defaultFetcher","WowHeaders","quote","value","formatScope","members","scope","member","queryString","query","params","name","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.\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.\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' | 'PUT' | 'PATCH' | '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\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, 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":";;;;AAyBA,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;AA4BA,SAASG,EACP,GACQ;CACR,IAAI,CAACC,GAAO,OAAO;CACnB,IAAMC,IAAS,IAAI,gBAAgB;CACnC,KAAK,IAAM,CAACC,GAAMR,MAAU,OAAO,QAAQM,CAAK,GAC9C,AAAIN,MAAU,KAAA,KAAWO,EAAO,OAAOC,GAAM,OAAOR,CAAK,CAAC;CAE5D,IAAMS,IAAOF,EAAO,SAAS;CAC7B,OAAOE,IAAO,IAAIA,MAAS;AAC7B;AASA,eAAsBC,EACpB,GACA,GACmB;CACnB,IAAMC,IAAUC,EAAK,WAAW,CAAC,GAC3BC,IAAkC,CAAC;CACzC,KAAK,IAAM,CAACL,GAAMR,MAAU,OAAO,QAAQ;EACzC,GAAGY,EAAK;EACR,GAAID,EAAQ,UAAU,KAAA,IAClB,CAAC,IACD,GAAGb,EAAW,QAAQG,EAAYU,EAAQ,KAAK,EAAE;EACrD,GAAIA,EAAQ,UAAU,KAAA,IAClB,CAAC,IACD,GAAGb,EAAW,QAAQa,EAAQ,MAAM;EACxC,GAAGA,EAAQ;CACb,CAAC,GACC,AAAIX,MAAU,KAAA,MAAW,EAAQQ,KAAQR;CAG3C,IAAMc,IAAQF,EAAK,SAAS,KAAA,KAAa,CAACG,EAAaH,EAAK,WAAW;CACvE,AAAIE,MAAO,EAAQ,kBAAkB;CACrC,IAAME,IAAM,GAAGC,EAAO,YAAY,KAAKL,EAAK,OAAOP,EAAYO,EAAK,KAAK;CACzE,IAAI;EACF,OAAO,OAAOK,EAAO,WAAWpB,EAAAA,CAAgB,MAAMmB,GAAK;GACzD,QAAQJ,EAAK;GACb;GACA,GAAIA,EAAK,SAAS,KAAA,IACd,CAAC,IACD,EACE,MAAME,IACFK,EAAcP,EAAK,MAAMA,EAAK,WAAW,IACxCA,EAAK,KACZ;GACJ,GAAID,EAAQ,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQA,EAAQ,OAAO;EACnE,CAAC;CACH,SAASS,GAAO;EACd,IAAMC,IAAYD,GAAkD,UAChE;EACJ,IAAIR,EAAK,eAAeS,GAAU,WAAW,KAAK,OAAOA;EACzD,MAAO,MAAMC,EAAkBF,CAAK,KAAMA;CAC5C;AACF;AAOA,eAAsBG,EACpB,GACA,GACY;CAEZ,OADIR,EAAaS,CAAO,IAAW,MAAMH,EAAS,KAAK,IAChDI,EAAU,MAAMJ,EAAS,KAAK,GAAGG,CAAO;AACjD;AAGA,SAAgBE,EAAU,GAAwC;CAChE,IAAMC,IAAMN,EAAS,QAAQ,IAAIvB,EAAW,IAAI;CAChD,OAAO6B,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("./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;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./exactJson.cjs"),t=require("./frameworkErrors.cjs"),n=require("./wire.cjs"),r=require("./problem.cjs"),i=require("./http.cjs"),a=require("./manifest.cjs"),o=require("./wait.cjs"),s=require("./commands.cjs"),c=require("./developmentCaller.cjs"),l=require("./queries.cjs"),u=require("./state.cjs");exports.CommandClient=s.CommandClient,exports.CommandRejectedError=r.CommandRejectedError,exports.CommandResultStatus=n.CommandResultStatus,exports.DEFAULT_RETRY=t.DEFAULT_RETRY,exports.DatasetClient=l.DatasetClient,exports.DevelopmentCallerHeaders=c.DevelopmentCallerHeaders,exports.EventQueryClient=l.EventQueryClient,exports.FRAMEWORK_ERROR_PREFIX=r.FRAMEWORK_ERROR_PREFIX,exports.FRAMEWORK_RETRIES=t.FRAMEWORK_RETRIES,exports.FrameworkErrorCodes=t.FrameworkErrorCodes,exports.FunctionKind=n.FunctionKind,exports.LifecycleCommands=s.LifecycleCommands,exports.MANIFEST_FEATURES=a.MANIFEST_FEATURES,exports.MANIFEST_FORMAT=a.MANIFEST_FORMAT,exports.OwnStateClient=u.OwnStateClient,exports.PROBLEM_TYPE_PREFIX=r.PROBLEM_TYPE_PREFIX,exports.QueryModelClient=l.QueryModelClient,exports.SNAPSHOT_SUBSCRIPTION=o.SNAPSHOT_SUBSCRIPTION,exports.SnapshotQueryClient=l.SnapshotQueryClient,exports.Stage=n.Stage,exports.StateClient=u.StateClient,exports.WaitPlan=o.WaitPlan,exports.WowHeaders=i.WowHeaders,exports.WowProblemError=r.WowProblemError,exports.checkManifest=a.checkManifest,exports.developmentCaller=c.developmentCaller,exports.developmentCallerHeaders=c.developmentCallerHeaders,exports.fetchManifest=a.fetchManifest,exports.formatHop=o.formatHop,exports.formatScope=i.formatScope,exports.formatWaitPlan=o.formatWaitPlan,exports.formatWaitTimeout=o.formatWaitTimeout,exports.isProblem=r.isProblem,exports.newRequestId=s.newRequestId,exports.parseHop=o.parseHop,exports.parseJson=e.parseJson,exports.parseRetryAfter=r.parseRetryAfter,exports.parseWaitPlan=o.parseWaitPlan,exports.queryPath=l.queryPath,exports.readProblem=r.readProblem,exports.requestIdOf=r.requestIdOf,exports.retryOf=r.retryOf,exports.stringifyJson=e.stringifyJson,exports.textNumbersBy=e.textNumbersBy,exports.toWowProblemError=r.toWowProblemError,exports.wait=o.wait;
package/dist/index.d.cts CHANGED
@@ -7,13 +7,15 @@
7
7
  *
8
8
  * Build queries with the DSL of `@ahoo-wang/wow-client/dsl`.
9
9
  */
10
- export { type ApplyTags, CommandGateway, type CommandOptions, commandSegment, type CreateCommandOptions, type LifecycleCommand, LifecycleCommands, newRequestId, type TransferOwner, type TransferSpace, } from './commands.cjs';
10
+ export { type ApplyTags, CommandClient, type CommandClientOptions, type CommandOptions, type CommandRequest, type CreateCommandOptions, type LifecycleCommand, LifecycleCommands, newRequestId, type TransferOwner, type TransferSpace, } from './commands.cjs';
11
11
  export { parseJson, stringifyJson, type TextNumbers, textNumbersBy, type TextNumbersByName, } from './exactJson.cjs';
12
+ export { type DevelopmentCaller, developmentCaller, developmentCallerHeaders, DevelopmentCallerHeaders, } from './developmentCaller.cjs';
12
13
  export { formatScope, type RequestOptions, type TargetScope, type WowClientOptions, WowHeaders, } from './http.cjs';
13
- export { type AggregateManifest, type CommandManifest, type ContextManifest, type Creation, type ErrorManifest, type EventManifest, fetchManifest, type Manifest, MANIFEST_FORMAT, type QueryManifest, type RouteManifest, type SubscriptionManifest, } from './manifest.cjs';
14
+ export { checkManifest, type Creation, fetchManifest, MANIFEST_FEATURES, MANIFEST_FORMAT, type RoutingCommand, type RoutingManifest, type RoutingServiceRoute, } from './manifest.cjs';
15
+ export type * from './manifestTypes.cjs';
14
16
  export * from './wire.cjs';
15
- export { FRAMEWORK_ERROR_PREFIX, type FrameworkErrorCode, FrameworkErrorCodes, isProblem, parseRetryAfter, type Problem, PROBLEM_TYPE_PREFIX, readProblem, requestIdOf, type RetryHint, retryHintOf, toWowProblemError, WowProblemError, } from './problem.cjs';
16
- export { type CountQuery, type CountResult, DatasetClient, type DescriptorResult, EventQueryClient, type ListStreamOptions, type Including, type PagedQuery, type PagedResult, QueryModelClient, queryPath, SnapshotQueryClient, type TotalMode, } from './queries.cjs';
17
- export { StateClient, type StateReadOptions, type StateReadResult, type StateTraceOptions, } from './state.cjs';
18
- export { type CommandResultStream, type StreamedRow, type StreamEnd, type StreamEndReason, type StreamResumeOptions, } from './streams.cjs';
19
- export { formatHop, formatWaitPlan, formatWaitTimeout, SNAPSHOT_SUBSCRIPTION, wait, type WaitOptions, } from './wait.cjs';
17
+ export { CommandRejectedError, DEFAULT_RETRY, FRAMEWORK_ERROR_PREFIX, FRAMEWORK_RETRIES, type FrameworkRetry, type FrameworkErrorCode, FrameworkErrorCodes, isProblem, parseRetryAfter, type Problem, PROBLEM_TYPE_PREFIX, readProblem, requestIdOf, type Retry, retryOf, toWowProblemError, WowProblemError, } from './problem.cjs';
18
+ export { type CountQuery, type CountResult, DatasetClient, EventQueryClient, type StreamOptions, type Including, QueryModelClient, queryPath, SnapshotQueryClient, } from './queries.cjs';
19
+ export { OwnStateClient, StateClient, type StateReadOptions, type StateReadResult, type StateTraceOptions, } from './state.cjs';
20
+ export { type CommandResultStream, type Positioned, type StreamEnd, type StreamEndReason, type StreamResumeOptions, } from './streams.cjs';
21
+ export { formatHop, formatWaitPlan, formatWaitTimeout, parseHop, parseWaitPlan, SNAPSHOT_SUBSCRIPTION, wait, WaitPlan, } from './wait.cjs';
package/dist/index.d.ts CHANGED
@@ -7,13 +7,15 @@
7
7
  *
8
8
  * Build queries with the DSL of `@ahoo-wang/wow-client/dsl`.
9
9
  */
10
- export { type ApplyTags, CommandGateway, type CommandOptions, commandSegment, type CreateCommandOptions, type LifecycleCommand, LifecycleCommands, newRequestId, type TransferOwner, type TransferSpace, } from './commands.js';
10
+ export { type ApplyTags, CommandClient, type CommandClientOptions, type CommandOptions, type CommandRequest, type CreateCommandOptions, type LifecycleCommand, LifecycleCommands, newRequestId, type TransferOwner, type TransferSpace, } from './commands.js';
11
11
  export { parseJson, stringifyJson, type TextNumbers, textNumbersBy, type TextNumbersByName, } from './exactJson.js';
12
+ export { type DevelopmentCaller, developmentCaller, developmentCallerHeaders, DevelopmentCallerHeaders, } from './developmentCaller.js';
12
13
  export { formatScope, type RequestOptions, type TargetScope, type WowClientOptions, WowHeaders, } from './http.js';
13
- export { type AggregateManifest, type CommandManifest, type ContextManifest, type Creation, type ErrorManifest, type EventManifest, fetchManifest, type Manifest, MANIFEST_FORMAT, type QueryManifest, type RouteManifest, type SubscriptionManifest, } from './manifest.js';
14
+ export { checkManifest, type Creation, fetchManifest, MANIFEST_FEATURES, MANIFEST_FORMAT, type RoutingCommand, type RoutingManifest, type RoutingServiceRoute, } from './manifest.js';
15
+ export type * from './manifestTypes.js';
14
16
  export * from './wire.js';
15
- export { FRAMEWORK_ERROR_PREFIX, type FrameworkErrorCode, FrameworkErrorCodes, isProblem, parseRetryAfter, type Problem, PROBLEM_TYPE_PREFIX, readProblem, requestIdOf, type RetryHint, retryHintOf, toWowProblemError, WowProblemError, } from './problem.js';
16
- export { type CountQuery, type CountResult, DatasetClient, type DescriptorResult, EventQueryClient, type ListStreamOptions, type Including, type PagedQuery, type PagedResult, QueryModelClient, queryPath, SnapshotQueryClient, type TotalMode, } from './queries.js';
17
- export { StateClient, type StateReadOptions, type StateReadResult, type StateTraceOptions, } from './state.js';
18
- export { type CommandResultStream, type StreamedRow, type StreamEnd, type StreamEndReason, type StreamResumeOptions, } from './streams.js';
19
- export { formatHop, formatWaitPlan, formatWaitTimeout, SNAPSHOT_SUBSCRIPTION, wait, type WaitOptions, } from './wait.js';
17
+ export { CommandRejectedError, DEFAULT_RETRY, FRAMEWORK_ERROR_PREFIX, FRAMEWORK_RETRIES, type FrameworkRetry, type FrameworkErrorCode, FrameworkErrorCodes, isProblem, parseRetryAfter, type Problem, PROBLEM_TYPE_PREFIX, readProblem, requestIdOf, type Retry, retryOf, toWowProblemError, WowProblemError, } from './problem.js';
18
+ export { type CountQuery, type CountResult, DatasetClient, EventQueryClient, type StreamOptions, type Including, QueryModelClient, queryPath, SnapshotQueryClient, } from './queries.js';
19
+ export { OwnStateClient, StateClient, type StateReadOptions, type StateReadResult, type StateTraceOptions, } from './state.js';
20
+ export { type CommandResultStream, type Positioned, type StreamEnd, type StreamEndReason, type StreamResumeOptions, } from './streams.js';
21
+ export { formatHop, formatWaitPlan, formatWaitTimeout, parseHop, parseWaitPlan, SNAPSHOT_SUBSCRIPTION, wait, WaitPlan, } from './wait.js';
package/dist/index.es.js CHANGED
@@ -1,10 +1,12 @@
1
1
  import { parseJson as e, stringifyJson as t, textNumbersBy as n } from "./exactJson.es.js";
2
- import { FRAMEWORK_ERROR_PREFIX as r, FrameworkErrorCodes as i, PROBLEM_TYPE_PREFIX as a, WowProblemError as o, isProblem as s, parseRetryAfter as c, readProblem as l, requestIdOf as u, retryHintOf as d, toWowProblemError as f } from "./problem.es.js";
3
- import { WowHeaders as p, formatScope as m } from "./http.es.js";
4
- import { Stage as h } from "./wire.es.js";
5
- import { SNAPSHOT_SUBSCRIPTION as g, formatHop as _, formatWaitPlan as v, formatWaitTimeout as y, wait as b } from "./wait.es.js";
6
- import { CommandGateway as x, LifecycleCommands as S, commandSegment as C, newRequestId as w } from "./commands.es.js";
7
- import { MANIFEST_FORMAT as T, fetchManifest as E } from "./manifest.es.js";
8
- import { DatasetClient as D, EventQueryClient as O, QueryModelClient as k, SnapshotQueryClient as A, queryPath as j } from "./queries.es.js";
9
- import { StateClient as M } from "./state.es.js";
10
- export { x as CommandGateway, D as DatasetClient, O as EventQueryClient, r as FRAMEWORK_ERROR_PREFIX, i as FrameworkErrorCodes, S as LifecycleCommands, T as MANIFEST_FORMAT, a as PROBLEM_TYPE_PREFIX, k as QueryModelClient, g as SNAPSHOT_SUBSCRIPTION, A as SnapshotQueryClient, h as Stage, M as StateClient, p as WowHeaders, o as WowProblemError, C as commandSegment, E as fetchManifest, _ as formatHop, m as formatScope, v as formatWaitPlan, y as formatWaitTimeout, s as isProblem, w as newRequestId, e as parseJson, c as parseRetryAfter, j as queryPath, l as readProblem, u as requestIdOf, d as retryHintOf, t as stringifyJson, n as textNumbersBy, f as toWowProblemError, b as wait };
2
+ import { DEFAULT_RETRY as r, FRAMEWORK_RETRIES as i, FrameworkErrorCodes as a } from "./frameworkErrors.es.js";
3
+ import { CommandResultStatus as o, FunctionKind as s, Stage as c } from "./wire.es.js";
4
+ import { CommandRejectedError as l, FRAMEWORK_ERROR_PREFIX as u, PROBLEM_TYPE_PREFIX as d, WowProblemError as f, isProblem as p, parseRetryAfter as m, readProblem as h, requestIdOf as g, retryOf as _, toWowProblemError as v } from "./problem.es.js";
5
+ import { WowHeaders as y, formatScope as b } from "./http.es.js";
6
+ import { MANIFEST_FEATURES as x, MANIFEST_FORMAT as S, checkManifest as C, fetchManifest as w } from "./manifest.es.js";
7
+ import { SNAPSHOT_SUBSCRIPTION as T, WaitPlan as E, formatHop as D, formatWaitPlan as O, formatWaitTimeout as k, parseHop as A, parseWaitPlan as j, wait as M } from "./wait.es.js";
8
+ import { CommandClient as N, LifecycleCommands as P, newRequestId as F } from "./commands.es.js";
9
+ import { DevelopmentCallerHeaders as I, developmentCaller as L, developmentCallerHeaders as R } from "./developmentCaller.es.js";
10
+ import { DatasetClient as z, EventQueryClient as B, QueryModelClient as V, SnapshotQueryClient as H, queryPath as U } from "./queries.es.js";
11
+ import { OwnStateClient as W, StateClient as G } from "./state.es.js";
12
+ export { N as CommandClient, l as CommandRejectedError, o as CommandResultStatus, r as DEFAULT_RETRY, z as DatasetClient, I as DevelopmentCallerHeaders, B as EventQueryClient, u as FRAMEWORK_ERROR_PREFIX, i as FRAMEWORK_RETRIES, a as FrameworkErrorCodes, s as FunctionKind, P as LifecycleCommands, x as MANIFEST_FEATURES, S as MANIFEST_FORMAT, W as OwnStateClient, d as PROBLEM_TYPE_PREFIX, V as QueryModelClient, T as SNAPSHOT_SUBSCRIPTION, H as SnapshotQueryClient, c as Stage, G as StateClient, E as WaitPlan, y as WowHeaders, f as WowProblemError, C as checkManifest, L as developmentCaller, R as developmentCallerHeaders, w as fetchManifest, D as formatHop, b as formatScope, O as formatWaitPlan, k as formatWaitTimeout, p as isProblem, F as newRequestId, A as parseHop, e as parseJson, m as parseRetryAfter, j as parseWaitPlan, U as queryPath, h as readProblem, g as requestIdOf, _ as retryOf, t as stringifyJson, n as textNumbersBy, v as toWowProblemError, M as wait };
package/dist/manifest.cjs CHANGED
@@ -1,2 +1,2 @@
1
- const e=require("./http.cjs");var t=1;async function n(t={},n){return e.json(await e.send(t,{method:`GET`,path:`/wow/manifest`,options:n}))}exports.MANIFEST_FORMAT=t,exports.fetchManifest=n;
1
+ const e=require("./http.cjs");var t=1,n=new Set;function r(e){if(e.format!==1)throw TypeError(`The Manifest is of format ${e.format}; this client reads format 1.`);let t=(e.requires??[]).filter(e=>!n.has(e));if(t.length>0)throw TypeError(`The Manifest requires ${t.join(`, `)}, which this client does not understand: use a newer @ahoo-wang/wow-client.`);return e}async function i(t={},n){return r(await e.json(await e.send(t,{method:`GET`,path:`/wow/manifest`,options:n})))}exports.MANIFEST_FEATURES=n,exports.MANIFEST_FORMAT=t,exports.checkManifest=r,exports.fetchManifest=i;
2
2
  //# sourceMappingURL=manifest.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.cjs","names":["json","send","require_http","MANIFEST_FORMAT","fetchManifest","client"],"sources":["../src/manifest.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n json,\n type RequestOptions,\n send,\n type WowClientOptions,\n} from './http.js';\nimport type { Ownership } from './wire.js';\n\n/** A route of the Manifest: a method and a path, `{id}` the aggregate id. */\nexport interface RouteManifest {\n readonly method: string;\n readonly path: string;\n}\n\n/** Whether a command creates its aggregate. */\nexport type Creation = 'NONE' | 'REQUIRED' | 'ALLOWED';\n\n/** A command of an aggregate (decisions D104, D176, D182). */\nexport interface CommandManifest {\n readonly name: string;\n readonly aliases?: readonly string[];\n /** `#/$defs/<key>`. */\n readonly schema: string;\n readonly creation?: Creation;\n readonly produces?: readonly string[];\n readonly routes?: readonly RouteManifest[];\n readonly mounted?: boolean;\n readonly transformsTo?: readonly string[];\n}\n\n/** An event of an aggregate and its revision. */\nexport interface EventManifest {\n readonly name: string;\n readonly aliases?: readonly string[];\n readonly revision?: number;\n readonly schema: string;\n}\n\n/** A query model of an aggregate: `snapshot` or `events` (decision D128). */\nexport interface QueryManifest {\n readonly model: string;\n readonly routes?: readonly RouteManifest[];\n}\n\n/** An aggregate of a bounded context. */\nexport interface AggregateManifest {\n readonly name: string;\n readonly description?: string;\n readonly state: { readonly schema: string; readonly fingerprint?: string };\n readonly snapshot?: { readonly enabled?: boolean };\n readonly commands?: readonly CommandManifest[];\n readonly events?: readonly EventManifest[];\n readonly lifecycle?: readonly string[];\n readonly queries?: readonly QueryManifest[];\n readonly schedules?: readonly string[];\n readonly ownership?: Ownership;\n}\n\n/** A subscription of a bounded context (design 04 §1). */\nexport interface SubscriptionManifest {\n /** `processor.function`, as a `handled` hop names it. */\n readonly name: string;\n readonly kind: 'PROJECTION' | 'REACTOR' | 'SAGA';\n readonly source: {\n readonly context?: string;\n readonly aggregates?: readonly string[];\n readonly events?: readonly string[];\n };\n readonly derives?: readonly string[];\n readonly rejected?: readonly string[];\n readonly committed?: readonly string[];\n readonly [property: string]: unknown;\n}\n\n/** An error code and the HTTP status it is answered with. */\nexport interface ErrorManifest {\n readonly code: string;\n readonly status: number;\n readonly description?: string;\n}\n\n/** A bounded context of the Manifest. */\nexport interface ContextManifest {\n readonly name: string;\n readonly description?: string;\n readonly aggregates?: readonly AggregateManifest[];\n readonly subscriptions?: readonly SubscriptionManifest[];\n readonly published?: readonly {\n readonly aggregate: string;\n readonly topic: string;\n readonly includeState?: boolean;\n }[];\n readonly errors?: readonly ErrorManifest[];\n}\n\n/**\n * A service's Manifest (decisions D17, D73–D76): its contexts, aggregates,\n * commands, events, routes and error codes, and the JSON Schemas they refer\n * to under `$defs`. `wow-generator` generates typed clients from it.\n */\nexport interface Manifest {\n readonly format: number;\n readonly service?: { readonly name: string; readonly version?: string };\n readonly contexts: readonly ContextManifest[];\n readonly errors?: readonly ErrorManifest[];\n readonly $defs?: Readonly<Record<string, unknown>>;\n}\n\n/** The format of the Manifest this client reads. */\nexport const MANIFEST_FORMAT = 1;\n\n/**\n * The service's Manifest, `GET /wow/manifest`, authorized as any API.\n *\n * @param client - How the service is reached\n * @param options - Headers and cancellation\n */\nexport async function fetchManifest(\n client: WowClientOptions = {},\n options?: RequestOptions,\n): Promise<Manifest> {\n return json<Manifest>(\n await send(client, { method: 'GET', path: '/wow/manifest', options }),\n );\n}\n"],"mappings":"8BA0HA,IAAaG,EAAkB,EAQ/B,eAAsBC,EACpB,EAA2B,CAAC,EAC5B,EACmB,CACnB,OAAOJ,EAAAA,KACL,MAAMC,EAAAA,KAAKI,EAAQ,CAAE,OAAQ,MAAO,KAAM,gBAAiB,SAAQ,CAAC,CACtE,CACF"}
1
+ {"version":3,"file":"manifest.cjs","names":["json","send","require_http","MANIFEST_FORMAT","MANIFEST_FEATURES","checkManifest","manifest","unknown","marker","fetchManifest","client"],"sources":["../src/manifest.ts"],"sourcesContent":["/*\n * Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n * http://www.apache.org/licenses/LICENSE-2.0\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n json,\n type RequestOptions,\n send,\n type WowClientOptions,\n} from './http.js';\nimport type {\n AggregateManifest,\n CommandManifest,\n ContextManifest,\n Manifest,\n ServiceRouteManifest,\n} from './manifestTypes.js';\n\nexport type * from './manifestTypes.js';\n\n/** Whether a command creates its aggregate. */\nexport type Creation = CommandManifest['creation'];\n\n/**\n * A command as a {@link RoutingManifest} lists it: its name, former names and\n * routes, and the property of its body that names its aggregate, for a command\n * whose body does (`idProperty`).\n */\nexport type RoutingCommand = Pick<CommandManifest, 'name' | 'routes'> &\n Partial<Pick<CommandManifest, 'aliases' | 'idProperty'>>;\n\n/** A service route as a {@link RoutingManifest} lists it: its name and its route. */\nexport type RoutingServiceRoute = Pick<ServiceRouteManifest, 'name' | 'route'>;\n\n/**\n * What a `CommandClient` reads of a Manifest to send a command: each\n * context's aggregates and their commands with their routes, and the context's\n * own system commands; and what a `ServiceRoutes` reads to call a service\n * route: the context's routes. A whole {@link Manifest} is one; a generated\n * client carries its service's as data (`manifest.ts`), with no schema.\n */\nexport interface RoutingManifest extends Pick<Manifest, 'format' | 'requires'> {\n readonly contexts: readonly (Pick<ContextManifest, 'name'> & {\n readonly aggregates?: readonly (Pick<AggregateManifest, 'name'> & {\n readonly commands?: readonly RoutingCommand[];\n })[];\n readonly commands?: readonly RoutingCommand[];\n readonly routes?: readonly RoutingServiceRoute[];\n })[];\n}\n\n/** The format of the Manifest this client reads. */\nexport const MANIFEST_FORMAT = 1;\n\n/**\n * The markers of a Manifest's `requires` this client understands, as the\n * Kotlin reader's `ManifestFeatures`: none yet.\n */\nexport const MANIFEST_FEATURES: ReadonlySet<string> = new Set<string>();\n\n/**\n * Checks that this client can read `manifest`: its format, and every marker it\n * requires.\n *\n * @param manifest - The Manifest\n * @throws TypeError naming what this client does not understand\n */\nexport function checkManifest<M extends RoutingManifest>(manifest: M): M {\n if (manifest.format !== MANIFEST_FORMAT) {\n throw new TypeError(\n `The Manifest is of format ${manifest.format}; this client reads format ${MANIFEST_FORMAT}.`,\n );\n }\n const unknown = (manifest.requires ?? []).filter(\n marker => !MANIFEST_FEATURES.has(marker),\n );\n if (unknown.length > 0) {\n throw new TypeError(\n `The Manifest requires ${unknown.join(', ')}, which this client does not understand: use a newer @ahoo-wang/wow-client.`,\n );\n }\n return manifest;\n}\n\n/**\n * The service's Manifest, `GET /wow/manifest`, authorized as any API.\n *\n * @param client - How the service is reached\n * @param options - Headers and cancellation\n */\nexport async function fetchManifest(\n client: WowClientOptions = {},\n options?: RequestOptions,\n): Promise<Manifest> {\n return checkManifest(\n await json<Manifest>(\n await send(client, { method: 'GET', path: '/wow/manifest', options }),\n ),\n );\n}\n"],"mappings":"A,8BA6DA,IAAaG,EAAkB,EAMlBC,EAAyC,IAAI,IAS1D,SAAgBC,EAAyC,EAAgB,CACvE,GAAIC,EAAS,SAAA,EACX,MAAU,UACR,6BAA6BA,EAAS,OAAO,8BAC/C,EAEF,IAAMC,GAAWD,EAAS,UAAY,CAAC,EAAA,CAAG,OACxC,GAAU,CAACF,EAAkB,IAAII,CAAM,CACzC,EACA,GAAID,EAAQ,OAAS,EACnB,MAAU,UACR,yBAAyBA,EAAQ,KAAK,IAAI,EAAE,4EAC9C,EAEF,OAAOD,CACT,CAQA,eAAsBG,EACpB,EAA2B,CAAC,EAC5B,EACmB,CACnB,OAAOJ,EACL,MAAML,EAAAA,KACJ,MAAMC,EAAAA,KAAKS,EAAQ,CAAE,OAAQ,MAAO,KAAM,gBAAiB,SAAQ,CAAC,CACtE,CACF,CACF,C"}