@eventsdk/sdk 0.0.0-stage → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +9 -0
- package/dist/compatibility-http/bridge/receive.d.ts +3 -0
- package/dist/compatibility-http/bridge/types.d.ts +44 -0
- package/dist/compatibility-http/index.d.ts +4 -0
- package/dist/compatibility-http/index.js +1 -0
- package/dist/compatibility-http/policy/validate-policy.d.ts +3 -0
- package/dist/conformance/admission/harness.d.ts +20 -0
- package/dist/conformance/admission/run-suite.d.ts +2 -0
- package/dist/conformance/consumer/harness.d.ts +24 -0
- package/dist/conformance/consumer/run-apply-suite.d.ts +2 -0
- package/dist/conformance/consumer/run-worker-suite.d.ts +2 -0
- package/dist/conformance/event-link/harness.d.ts +13 -0
- package/dist/conformance/event-link/run-suite.d.ts +2 -0
- package/dist/conformance/fanout/harness.d.ts +39 -0
- package/dist/conformance/fanout/run-suite.d.ts +2 -0
- package/dist/conformance/gap/harness.d.ts +19 -0
- package/dist/conformance/gap/run-suite.d.ts +2 -0
- package/dist/conformance/index.d.ts +22 -0
- package/dist/conformance/index.js +1 -0
- package/dist/conformance/producer/harness.d.ts +21 -0
- package/dist/conformance/producer/run-suite.d.ts +2 -0
- package/dist/conformance/receipt/harness.d.ts +12 -0
- package/dist/conformance/receipt/projection-harness.d.ts +9 -0
- package/dist/conformance/receipt/run-projection-suite.d.ts +2 -0
- package/dist/conformance/receipt/run-suite.d.ts +2 -0
- package/dist/conformance/reliability/checks.d.ts +4 -0
- package/dist/conformance/result/harness.d.ts +15 -0
- package/dist/conformance/result/run-suite.d.ts +2 -0
- package/dist/conformance/version/compatibility.d.ts +13 -0
- package/dist/contracts/canonical/canonical-json.d.ts +1 -0
- package/dist/contracts/contract-types.d.ts +34 -0
- package/dist/contracts/generated/business-receipt.d.ts +21 -0
- package/dist/contracts/generated/cloud-event-context.d.ts +32 -0
- package/dist/contracts/generated/cloud-event-fanout.d.ts +33 -0
- package/dist/contracts/generated/cloud-event.d.ts +24 -0
- package/dist/contracts/generated/event-link-authorization-request.d.ts +22 -0
- package/dist/contracts/generated/event-link-proposal.d.ts +27 -0
- package/dist/contracts/generated/event-link-token-request.d.ts +7 -0
- package/dist/contracts/generated/event-origin-claims.d.ts +13 -0
- package/dist/contracts/generated/exchange-grant.d.ts +11 -0
- package/dist/contracts/generated/exchange-registration.d.ts +24 -0
- package/dist/contracts/generated/fanout-event-draft.d.ts +28 -0
- package/dist/contracts/generated/gap-baseline.d.ts +18 -0
- package/dist/contracts/generated/gap-recovery-command.d.ts +7 -0
- package/dist/contracts/generated/identity-context.d.ts +15 -0
- package/dist/contracts/generated/namespaced-reference.d.ts +4 -0
- package/dist/contracts/generated/native-event-catalog.d.ts +19 -0
- package/dist/contracts/generated/node-connection-profile.d.ts +217 -0
- package/dist/contracts/generated/node-worker-observation.d.ts +7 -0
- package/dist/contracts/generated/outbox-recovery-command.d.ts +8 -0
- package/dist/contracts/generated/portable-event-link-authorization-request.d.ts +98 -0
- package/dist/contracts/generated/portable-event-link-proposal.d.ts +121 -0
- package/dist/contracts/generated/portable-event-link-token-request.d.ts +34 -0
- package/dist/contracts/generated/portable-exchange-registration.d.ts +109 -0
- package/dist/contracts/generated/portable-gap-baseline.d.ts +93 -0
- package/dist/contracts/generated/portable-gap-recovery-command.d.ts +35 -0
- package/dist/contracts/generated/portable-outbox-recovery-command.d.ts +37 -0
- package/dist/contracts/generated/public-jwks-snapshot.d.ts +141 -0
- package/dist/contracts/generated/result-ref.d.ts +8 -0
- package/dist/contracts/generated/supported-profiles.d.ts +3 -0
- package/dist/contracts/generated/tenant-connection.d.ts +13 -0
- package/dist/contracts/generated/tenant-context.d.ts +4 -0
- package/dist/contracts/index.d.ts +31 -0
- package/dist/contracts/index.js +1 -0
- package/dist/contracts/validation/contract-error.d.ts +16 -0
- package/dist/contracts/validation/contracts.d.ts +316 -0
- package/dist/contracts/validation/decode-cloud-event.d.ts +2 -0
- package/dist/contracts/validation/event-link.d.ts +9 -0
- package/dist/contracts/validation/identity-context.d.ts +3 -0
- package/dist/contracts/validation/origin-proof-wire.d.ts +3 -0
- package/dist/contracts/validation/strict-json.d.ts +1 -0
- package/dist/core/inbox/accept-delivery.d.ts +26 -0
- package/dist/core/inbox/apply-delivery.d.ts +29 -0
- package/dist/core/inbox/domain-apply-result.d.ts +13 -0
- package/dist/core/inbox/inbox-worker.d.ts +2 -0
- package/dist/core/inbox/read-result.d.ts +12 -0
- package/dist/core/inbox/worker-types.d.ts +21 -0
- package/dist/core/index.d.ts +50 -0
- package/dist/core/index.js +1 -0
- package/dist/core/outbox/authorize-recovery.d.ts +75 -0
- package/dist/core/outbox/outbox-relay.d.ts +26 -0
- package/dist/core/outbox/record-event.d.ts +10 -0
- package/dist/core/outbox/record-fanout.d.ts +16 -0
- package/dist/core/ports/dead-letter.d.ts +29 -0
- package/dist/core/ports/inbox.d.ts +43 -0
- package/dist/core/ports/observability.d.ts +21 -0
- package/dist/core/ports/origin-refresh.d.ts +5 -0
- package/dist/core/ports/outbox.d.ts +46 -0
- package/dist/core/ports/result-reader.d.ts +14 -0
- package/dist/core/ports/transport.d.ts +13 -0
- package/dist/core/receipt/receipt-state.d.ts +3 -0
- package/dist/core/recovery/event-log.d.ts +28 -0
- package/dist/core/recovery/gap-baseline-binding.d.ts +2 -0
- package/dist/core/recovery/gap-recovery.d.ts +15 -0
- package/dist/core/recovery/receipt-identity-recovery.d.ts +8 -0
- package/dist/core/recovery/receipt-recovery.d.ts +14 -0
- package/dist/core/recovery/replay-dead-letter.d.ts +4 -0
- package/dist/core/runtime/dependencies.d.ts +19 -0
- package/dist/core/runtime/errors.d.ts +6 -0
- package/dist/core/runtime/event-identity.d.ts +14 -0
- package/dist/core/runtime/exchange-connection.d.ts +7 -0
- package/dist/core/runtime/fanout-identity.d.ts +6 -0
- package/dist/core/runtime/lease.d.ts +6 -0
- package/dist/core/runtime/observe-health.d.ts +3 -0
- package/dist/core/runtime/operation.d.ts +2 -0
- package/dist/core/runtime/retry.d.ts +14 -0
- package/dist/event-link/errors.d.ts +5 -0
- package/dist/event-link/exchange.d.ts +9 -0
- package/dist/event-link/index.d.ts +12 -0
- package/dist/event-link/index.js +1 -0
- package/dist/event-link/primitives.d.ts +10 -0
- package/dist/event-link/protocol.d.ts +21 -0
- package/dist/event-link/receiver-ports.d.ts +42 -0
- package/dist/event-link/receiver.d.ts +18 -0
- package/dist/event-link/registration.d.ts +21 -0
- package/dist/event-link/sender.d.ts +22 -0
- package/dist/identity-contracts/authorization/authorization-port.d.ts +35 -0
- package/dist/identity-contracts/index.d.ts +2 -0
- package/dist/identity-contracts/index.js +0 -0
- package/dist/identity-contracts/origin/verified-origin.d.ts +28 -0
- package/dist/identity-verifier/index.d.ts +6 -0
- package/dist/identity-verifier/index.js +1 -0
- package/dist/identity-verifier/jwt/service-token-verifier.d.ts +15 -0
- package/dist/identity-verifier/origin/event-origin-policy.d.ts +36 -0
- package/dist/identity-verifier/origin/event-origin-signer.d.ts +6 -0
- package/dist/identity-verifier/origin/event-origin-verifier.d.ts +6 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +22 -0
- package/dist/node-config/configuration-error.d.ts +4 -0
- package/dist/node-config/diagnostics/check-configuration.d.ts +40 -0
- package/dist/node-config/identity/load-identity.d.ts +14 -0
- package/dist/node-config/identity/local-recovery-origin.d.ts +3 -0
- package/dist/node-config/identity/public-identity.d.ts +87 -0
- package/dist/node-config/identity/public-snapshot.d.ts +2 -0
- package/dist/node-config/identity/signing-identity.d.ts +5 -0
- package/dist/node-config/index.d.ts +12 -0
- package/dist/node-config/index.js +1 -0
- package/dist/node-config/main.js +3 -0
- package/dist/node-config/operations/export-own-public.d.ts +8 -0
- package/dist/node-config/operations/refresh-trust.d.ts +10 -0
- package/dist/node-config/profile/load-profile.d.ts +6 -0
- package/dist/node-config/profile/validate-profile.d.ts +2 -0
- package/dist/node-worker/index.d.ts +3 -0
- package/dist/node-worker/index.js +1 -0
- package/dist/node-worker/lifecycle.d.ts +19 -0
- package/dist/node-worker/route-scheduler.d.ts +17 -0
- package/dist/node-worker/session.d.ts +15 -0
- package/dist/provisioner/application/apply.d.ts +11 -0
- package/dist/provisioner/application/ports.d.ts +44 -0
- package/dist/provisioner/application/verify.d.ts +7 -0
- package/dist/provisioner/cli/arguments.d.ts +9 -0
- package/dist/provisioner/cli/live-command.d.ts +7 -0
- package/dist/provisioner/cli/main.js +2 -0
- package/dist/provisioner/cli/run.d.ts +2 -0
- package/dist/provisioner/cli/session-types.d.ts +26 -0
- package/dist/provisioner/conformance/policy.d.ts +9 -0
- package/dist/provisioner/index.d.ts +17 -0
- package/dist/provisioner/index.js +1 -0
- package/dist/provisioner/manifest/types.d.ts +55 -0
- package/dist/provisioner/manifest/validate.d.ts +3 -0
- package/dist/provisioner/nats/inspector.d.ts +13 -0
- package/dist/provisioner/nats/types.d.ts +38 -0
- package/dist/provisioner/nats/writer-types.d.ts +11 -0
- package/dist/provisioner/nats/writer.d.ts +18 -0
- package/dist/provisioner/planning/digest.d.ts +1 -0
- package/dist/provisioner/planning/plan.d.ts +18 -0
- package/dist/transport-nats/connection/delivery-session.d.ts +10 -0
- package/dist/transport-nats/connection/verified-connection.d.ts +12 -0
- package/dist/transport-nats/consume/delivery-handler.d.ts +34 -0
- package/dist/transport-nats/consume/nats-consumer.d.ts +18 -0
- package/dist/transport-nats/index.d.ts +12 -0
- package/dist/transport-nats/index.js +3 -0
- package/dist/transport-nats/publish/nats-publisher.d.ts +24 -0
- package/dist/transport-nats/transport-error.d.ts +5 -0
- package/licenses/NATS-LICENSE +201 -0
- package/package.json +79 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2013-2018 The NATS Authors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
EventSDK
|
|
2
|
+
Copyright 2026 EventSDK contributors
|
|
3
|
+
Licensed under Apache-2.0.
|
|
4
|
+
|
|
5
|
+
Includes modified @nats-io/transport-node 3.4.0.
|
|
6
|
+
Copyright 2013-2020 The NATS Authors.
|
|
7
|
+
Copyright 2020-2024 The NATS Authors.
|
|
8
|
+
EventSDK modifications: bounded initial dial, INFO and TLS socket cleanup.
|
|
9
|
+
Distributed under Apache-2.0; see licenses/NATS-LICENSE.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DurableAdmission, OperationOptions } from '@eventsdk/sdk/core';
|
|
2
|
+
import type { BridgeDependencies, LegacyHttpRequest } from './types.js';
|
|
3
|
+
export declare function receiveLegacyHttp(input: LegacyHttpRequest, deps: BridgeDependencies, options: OperationOptions): Promise<DurableAdmission>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CloudEvent } from '@eventsdk/sdk/contracts';
|
|
2
|
+
import type { VerifiedOrigin } from '@eventsdk/sdk/identity-contracts';
|
|
3
|
+
import type { AdmissionDependencies } from '@eventsdk/sdk/core';
|
|
4
|
+
export interface MigrationPolicy {
|
|
5
|
+
readonly migrationRef: string;
|
|
6
|
+
readonly owner: string;
|
|
7
|
+
readonly mappingVersion: string;
|
|
8
|
+
readonly expiresAt: string;
|
|
9
|
+
readonly decommissionRef: string;
|
|
10
|
+
readonly maxBodyBytes: number;
|
|
11
|
+
readonly source: string;
|
|
12
|
+
readonly sourceService: string;
|
|
13
|
+
readonly idField: string;
|
|
14
|
+
readonly timeField: string;
|
|
15
|
+
readonly allowedTypes: readonly string[];
|
|
16
|
+
}
|
|
17
|
+
export interface LegacyHttpRequest {
|
|
18
|
+
readonly body: Uint8Array;
|
|
19
|
+
readonly contentType: string;
|
|
20
|
+
readonly sourceProof: string;
|
|
21
|
+
readonly deliveryRef: string;
|
|
22
|
+
readonly consumerRef: string;
|
|
23
|
+
}
|
|
24
|
+
export interface SourceProofPort {
|
|
25
|
+
verify(input: {
|
|
26
|
+
readonly body: Uint8Array;
|
|
27
|
+
readonly proof: string;
|
|
28
|
+
readonly sourceService: string;
|
|
29
|
+
readonly signal: AbortSignal;
|
|
30
|
+
}): Promise<VerifiedOrigin>;
|
|
31
|
+
}
|
|
32
|
+
export interface LegacyMappingPort {
|
|
33
|
+
map(input: unknown, mappingVersion: string): CloudEvent;
|
|
34
|
+
}
|
|
35
|
+
export interface BridgeDependencies {
|
|
36
|
+
readonly policy: MigrationPolicy;
|
|
37
|
+
readonly proof: SourceProofPort;
|
|
38
|
+
readonly mapping: LegacyMappingPort;
|
|
39
|
+
readonly admission: AdmissionDependencies;
|
|
40
|
+
}
|
|
41
|
+
export declare class BridgeError extends Error {
|
|
42
|
+
readonly code: string;
|
|
43
|
+
constructor(code: string);
|
|
44
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { BridgeError } from './bridge/types.js';
|
|
2
|
+
export type { MigrationPolicy, LegacyHttpRequest, SourceProofPort, LegacyMappingPort, BridgeDependencies, } from './bridge/types.js';
|
|
3
|
+
export { receiveLegacyHttp } from './bridge/receive.js';
|
|
4
|
+
export { assertMigrationActive, assertNoCredentials } from './policy/validate-policy.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var BridgeError=class extends Error{constructor(code){super(code);this.code=code;this.name="BridgeError"}code};import{parseCloudEvent,parseJsonStrict}from"@eventsdk/sdk/contracts";import{acceptDelivery,boundedOperation}from"@eventsdk/sdk/core";function assertMigrationActive(policy,now){if(!policy.migrationRef||!policy.owner||!policy.mappingVersion||!policy.decommissionRef||!policy.source||!policy.sourceService||!policy.idField||!policy.timeField||!policy.allowedTypes.length||!Number.isSafeInteger(policy.maxBodyBytes)||policy.maxBodyBytes<1||policy.maxBodyBytes>1048576)throw new BridgeError("INVALID_MIGRATION_POLICY");const deadline=Date.parse(policy.expiresAt);if(!Number.isFinite(deadline)||!Number.isFinite(now)||deadline<=now){throw new BridgeError("MIGRATION_EXPIRED")}}var credentialKey=/^(?:password|passwd|secret|token|access[_-]?token|refresh[_-]?token|api[_-]?key|private[_-]?key|authorization|cookie|credential|credentials|recovery[_-]?key)$/i;function assertNoCredentials(value,depth=0){if(depth>64)throw new BridgeError("PAYLOAD_TOO_DEEP");if(Array.isArray(value)){for(const entry of value)assertNoCredentials(entry,depth+1)}else if(value&&typeof value==="object"){for(const[key,entry]of Object.entries(value)){if(credentialKey.test(key))throw new BridgeError("CREDENTIAL_PAYLOAD_REJECTED");assertNoCredentials(entry,depth+1)}}}function decode(request,policy){if(!/^application\/json(?:\s*;\s*charset=utf-8)?$/i.test(request.contentType)){throw new BridgeError("UNSUPPORTED_CONTENT_TYPE")}if(request.body.byteLength>policy.maxBodyBytes)throw new BridgeError("BODY_TOO_LARGE");if(!request.sourceProof||request.sourceProof.length>16384){throw new BridgeError("SOURCE_PROOF_REQUIRED")}const value=parseJsonStrict(request.body);assertNoCredentials(value);return value}function identity(value,field){if(!value||typeof value!=="object"||Array.isArray(value))throw new BridgeError("INVALID_LEGACY_EVENT");const id=value[field];if(typeof id!=="string"||!id||id.length>512)throw new BridgeError("STABLE_EVENT_ID_REQUIRED");return id}async function receiveLegacyHttp(input,deps,options){const request={...input,body:new Uint8Array(input.body)};const policy=structuredClone(deps.policy);assertMigrationActive(policy,deps.admission.clock.now());const value=decode(request,policy);const id=identity(value,policy.idField);const occurredAt=identity(value,policy.timeField);return boundedOperation(options,async signal=>{const origin=await deps.proof.verify({body:new Uint8Array(request.body),proof:request.sourceProof,sourceService:policy.sourceService,signal});if(origin.serviceRef!==policy.sourceService)throw new BridgeError("SOURCE_PROOF_MISMATCH");assertMigrationActive(policy,deps.admission.clock.now());const event=parseCloudEvent(deps.mapping.map(structuredClone(value),policy.mappingVersion));assertNoCredentials(event.data);if(event.id!==id||event.time!==occurredAt||event.source!==policy.source||event.serviceorigin!==policy.sourceService||!policy.allowedTypes.includes(event.type))throw new BridgeError("MAPPING_IDENTITY_MISMATCH");return acceptDelivery({event,origin,deliveryRef:request.deliveryRef,consumerRef:request.consumerRef},{...deps.admission,authorization:{authorize:async authorizationRequest=>{const decision=await deps.admission.authorization.authorize(authorizationRequest);assertMigrationActive(policy,deps.admission.clock.now());return decision}}},{signal,timeoutMs:options.timeoutMs})})}export{BridgeError,assertMigrationActive,assertNoCredentials,receiveLegacyHttp};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CloudEvent } from '@eventsdk/sdk/contracts';
|
|
2
|
+
import type { AdmissionDependencies, AcceptedEvent, QuarantineRecord } from '@eventsdk/sdk/core';
|
|
3
|
+
import type { AuthorizationDecision, VerifiedOrigin } from '@eventsdk/sdk/identity-contracts';
|
|
4
|
+
export interface AdmissionHarness {
|
|
5
|
+
readonly event: CloudEvent;
|
|
6
|
+
readonly origin: VerifiedOrigin;
|
|
7
|
+
dependencies(): AdmissionDependencies;
|
|
8
|
+
setAuthorization(decision: AuthorizationDecision): void;
|
|
9
|
+
failNextCommit(): void;
|
|
10
|
+
accepted(): Promise<readonly AcceptedEvent[]>;
|
|
11
|
+
quarantined(): Promise<readonly QuarantineRecord[]>;
|
|
12
|
+
reopen(): Promise<void>;
|
|
13
|
+
close(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export type AdmissionHarnessFactory = () => Promise<AdmissionHarness>;
|
|
16
|
+
export interface ConformanceCaseResult {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly passed: boolean;
|
|
19
|
+
readonly failureCode?: 'ASSERTION_FAILED';
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BusinessReceipt } from '@eventsdk/sdk/contracts';
|
|
2
|
+
import type { ApplyDependencies, ClaimedInbox, DeadLetterEntry, DeadLetterPort, InboxWorkPort, OperationOptions } from '@eventsdk/sdk/core';
|
|
3
|
+
export interface ConsumerObservation {
|
|
4
|
+
readonly receipt: BusinessReceipt;
|
|
5
|
+
readonly effects: number;
|
|
6
|
+
readonly quarantined: boolean;
|
|
7
|
+
readonly deadLetters: readonly DeadLetterEntry[];
|
|
8
|
+
}
|
|
9
|
+
export interface ConsumerHarness<T> {
|
|
10
|
+
readonly options: OperationOptions;
|
|
11
|
+
dependencies(): Omit<ApplyDependencies<T>, 'domain'>;
|
|
12
|
+
work(): InboxWorkPort;
|
|
13
|
+
deadLetters(): DeadLetterPort<T>;
|
|
14
|
+
claim(): Promise<ClaimedInbox>;
|
|
15
|
+
writeEffect(tx: T, claim: ClaimedInbox): Promise<void>;
|
|
16
|
+
inspect(): Promise<ConsumerObservation>;
|
|
17
|
+
setAuthorized(allowed: boolean): Promise<void>;
|
|
18
|
+
invalidateLease(): Promise<void>;
|
|
19
|
+
failNextReceiptCommit(): Promise<void>;
|
|
20
|
+
seedUnknown(): Promise<void>;
|
|
21
|
+
reopen(): Promise<void>;
|
|
22
|
+
close(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
export type ConsumerHarnessFactory<T> = () => Promise<ConsumerHarness<T>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { EventLinkTokenRequest } from '@eventsdk/sdk/contracts';
|
|
2
|
+
import type { EventLinkReceiver, EventLinkReceiverActor } from '@eventsdk/sdk/event-link';
|
|
3
|
+
export interface EventLinkReceiverHarness {
|
|
4
|
+
readonly receiver: EventLinkReceiver;
|
|
5
|
+
readonly params: URLSearchParams;
|
|
6
|
+
readonly actor: EventLinkReceiverActor;
|
|
7
|
+
token(code: string): EventLinkTokenRequest;
|
|
8
|
+
revokeActor(): Promise<void>;
|
|
9
|
+
revokeGrant(): Promise<void>;
|
|
10
|
+
reopen(): Promise<void>;
|
|
11
|
+
close(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export type EventLinkReceiverHarnessFactory = () => Promise<EventLinkReceiverHarness>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { CloudEventV12, FanoutEventDraft, BusinessReceipt } from '@eventsdk/sdk/contracts';
|
|
2
|
+
import type { AdmissionDependencies, ApplyDependencies, ClaimedInbox, FanoutRecipient, InboxKey, OperationOptions, RecordDependencies, RelayDependencies } from '@eventsdk/sdk/core';
|
|
3
|
+
export interface FanoutTarget {
|
|
4
|
+
readonly recipient: FanoutRecipient;
|
|
5
|
+
readonly consumerRef: string;
|
|
6
|
+
readonly targetScope: string;
|
|
7
|
+
}
|
|
8
|
+
export interface FanoutObservation {
|
|
9
|
+
readonly domainWrites: number;
|
|
10
|
+
readonly logicalFacts: number;
|
|
11
|
+
readonly outbound: readonly {
|
|
12
|
+
readonly event: CloudEventV12;
|
|
13
|
+
readonly status: string;
|
|
14
|
+
}[];
|
|
15
|
+
readonly accepted: readonly {
|
|
16
|
+
readonly key: InboxKey;
|
|
17
|
+
readonly event: CloudEventV12;
|
|
18
|
+
readonly receipt: BusinessReceipt;
|
|
19
|
+
}[];
|
|
20
|
+
readonly inboundDeliveries: number;
|
|
21
|
+
readonly effects: readonly InboxKey[];
|
|
22
|
+
}
|
|
23
|
+
export interface FanoutHarness<T> {
|
|
24
|
+
readonly draft: FanoutEventDraft;
|
|
25
|
+
readonly targets: readonly [FanoutTarget, FanoutTarget, FanoutTarget];
|
|
26
|
+
readonly options: OperationOptions;
|
|
27
|
+
producer(): RecordDependencies<T> & Omit<RelayDependencies, 'publisher'>;
|
|
28
|
+
admission(target: FanoutTarget): AdmissionDependencies;
|
|
29
|
+
application(): ApplyDependencies<T>;
|
|
30
|
+
claim(key: InboxKey): Promise<ClaimedInbox | null>;
|
|
31
|
+
transaction(operation: (tx: T) => Promise<void>): Promise<void>;
|
|
32
|
+
writeDomain(tx: T): Promise<void>;
|
|
33
|
+
inspect(): Promise<FanoutObservation>;
|
|
34
|
+
setAuthorized(target: FanoutTarget, allowed: boolean): Promise<void>;
|
|
35
|
+
replacementGrant(target: FanoutTarget): Promise<FanoutTarget>;
|
|
36
|
+
reopen(): Promise<void>;
|
|
37
|
+
close(): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
export type FanoutHarnessFactory<T> = () => Promise<FanoutHarness<T>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AuthorizedSnapshot, OperationOptions, SnapshotRecoveryPort } from '@eventsdk/sdk/core';
|
|
2
|
+
export interface GapObservation {
|
|
3
|
+
readonly watermark: string;
|
|
4
|
+
readonly snapshot: AuthorizedSnapshot;
|
|
5
|
+
}
|
|
6
|
+
export interface GapHarness {
|
|
7
|
+
readonly source: string;
|
|
8
|
+
readonly scope: string;
|
|
9
|
+
readonly initialWatermark: string;
|
|
10
|
+
readonly expected: AuthorizedSnapshot;
|
|
11
|
+
readonly options: OperationOptions;
|
|
12
|
+
port(): SnapshotRecoveryPort;
|
|
13
|
+
inspect(): Promise<GapObservation>;
|
|
14
|
+
setAuthorized(side: 'SOURCE' | 'TARGET', allowed: boolean): Promise<void>;
|
|
15
|
+
failAfterCheckpoint(): Promise<void>;
|
|
16
|
+
reopen(): Promise<void>;
|
|
17
|
+
close(): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export type GapHarnessFactory = () => Promise<GapHarness>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { runAdmissionConformance } from './admission/run-suite.js';
|
|
2
|
+
export type { AdmissionHarness, AdmissionHarnessFactory, ConformanceCaseResult, } from './admission/harness.js';
|
|
3
|
+
export { checkCompatibility } from './version/compatibility.js';
|
|
4
|
+
export type { VersionSet, Compatibility } from './version/compatibility.js';
|
|
5
|
+
export { checkRetryAndFence, checkGapIsNotSkipped, checkUnknownReceipt, } from './reliability/checks.js';
|
|
6
|
+
export { runProducerConformance } from './producer/run-suite.js';
|
|
7
|
+
export type { ProducerHarness, ProducerHarnessFactory, ProducerObservation, } from './producer/harness.js';
|
|
8
|
+
export { runReceiptConformance } from './receipt/run-suite.js';
|
|
9
|
+
export type { ReceiptHarness, ReceiptHarnessFactory } from './receipt/harness.js';
|
|
10
|
+
export { runResultConformance } from './result/run-suite.js';
|
|
11
|
+
export type { ResultHarness, ResultHarnessFactory } from './result/harness.js';
|
|
12
|
+
export { runApplyConformance } from './consumer/run-apply-suite.js';
|
|
13
|
+
export { runWorkerConformance } from './consumer/run-worker-suite.js';
|
|
14
|
+
export type { ConsumerHarness, ConsumerHarnessFactory, ConsumerObservation, } from './consumer/harness.js';
|
|
15
|
+
export { runGapConformance } from './gap/run-suite.js';
|
|
16
|
+
export type { GapHarness, GapHarnessFactory, GapObservation } from './gap/harness.js';
|
|
17
|
+
export { runReceiptProjectionConformance } from './receipt/run-projection-suite.js';
|
|
18
|
+
export type { ReceiptProjectionHarness, ReceiptProjectionHarnessFactory, } from './receipt/projection-harness.js';
|
|
19
|
+
export { runFanoutConformance } from './fanout/run-suite.js';
|
|
20
|
+
export type { FanoutHarness, FanoutHarnessFactory, FanoutTarget, FanoutObservation, } from './fanout/harness.js';
|
|
21
|
+
export { runEventLinkReceiverConformance } from './event-link/run-suite.js';
|
|
22
|
+
export type { EventLinkReceiverHarness, EventLinkReceiverHarnessFactory, } from './event-link/harness.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import assert from"node:assert/strict";import{acceptDelivery}from"@eventsdk/sdk/core";var options={timeoutMs:1e3};function input(harness,consumerRef="conformance-consumer"){return{event:harness.event,origin:harness.origin,deliveryRef:"delivery-1",consumerRef}}async function duplicateCase(harness){const first=await acceptDelivery(input(harness),harness.dependencies(),options);const second=await acceptDelivery(input(harness),harness.dependencies(),options);assert.equal(first.kind,"RECEIVED");assert.equal(second.kind,"DUPLICATE");assert.equal((await harness.accepted()).length,1)}async function conflictCase(harness){await acceptDelivery(input(harness),harness.dependencies(),options);const changed={...input(harness),event:{...harness.event,data:{conflict:true}}};const result=await acceptDelivery(changed,harness.dependencies(),options);assert.equal(result.kind,"REJECTED");assert.equal((await harness.accepted()).length,1);assert.equal((await harness.quarantined())[0]?.reasonCode,"EVENT_ID_CONFLICT")}async function consumerIsolationCase(harness){await acceptDelivery(input(harness,"consumer-a"),harness.dependencies(),options);await acceptDelivery(input(harness,"consumer-b"),harness.dependencies(),options);assert.equal((await harness.accepted()).length,2)}async function tenantIsolationCase(harness){await acceptDelivery(input(harness),harness.dependencies(),options);harness.setAuthorization({decision:"ALLOW",source:harness.event.source,targetScope:"urn:target:tenant:other",connectionRef:harness.event.connectionref,grantRef:harness.event.grantref,grantVersion:harness.event.grantversion});await acceptDelivery(input(harness),harness.dependencies(),options);const records=await harness.accepted();assert.equal(records.length,2);assert.notEqual(records[0]?.key.targetScope,records[1]?.key.targetScope)}async function commitFailureCase(harness){harness.failNextCommit();await assert.rejects(acceptDelivery(input(harness),harness.dependencies(),options));assert.equal((await harness.accepted()).length,0);const retry=await acceptDelivery(input(harness),harness.dependencies(),options);assert.equal(retry.kind,"RECEIVED")}async function reopenCase(harness){await acceptDelivery(input(harness),harness.dependencies(),options);await harness.reopen();const retry=await acceptDelivery(input(harness),harness.dependencies(),options);assert.equal(retry.kind,"DUPLICATE")}async function revokedCase(harness){harness.setAuthorization({decision:"DENY",reasonCode:"GRANT_REVOKED"});const result=await acceptDelivery(input(harness),harness.dependencies(),options);assert.equal(result.kind,"REJECTED");assert.equal((await harness.accepted()).length,0)}async function unknownCase(harness){harness.setAuthorization({decision:"UNKNOWN",reasonCode:"AUTHORITY_UNAVAILABLE"});await assert.rejects(acceptDelivery(input(harness),harness.dependencies(),options),{code:"AUTHORIZATION_UNKNOWN"});assert.equal((await harness.accepted()).length,0)}async function spoofedOriginCase(harness){const delivery={...input(harness),origin:{...harness.origin,serviceRef:"spoofed"}};const result=await acceptDelivery(delivery,harness.dependencies(),options);assert.equal(result.kind,"REJECTED");assert.equal((await harness.accepted()).length,0)}var scenarios=[["E4.DEDUPLICATE",duplicateCase],["E1.EVENT_ID_CONFLICT",conflictCase],["E4.CONSUMER_ISOLATION",consumerIsolationCase],["E2.TENANT_ISOLATION",tenantIsolationCase],["E4.COMMIT_BEFORE_ACK",commitFailureCase],["E5.REOPEN_DEDUPLICATION",reopenCase],["E2.GRANT_REVOKED",revokedCase],["E2.UNKNOWN_FAIL_CLOSED",unknownCase],["E2.ORIGIN_MISMATCH",spoofedOriginCase]];async function runAdmissionConformance(factory){const results=[];for(const[id,scenario]of scenarios){const harness=await factory();try{await scenario(harness);results.push({id,passed:true})}catch{results.push({id,passed:false,failureCode:"ASSERTION_FAILED"})}finally{await harness.close()}}return results}var profilesBySdk={"0.1.0":["eventsdk/1.0"],"0.2.0":["eventsdk/1.0","eventsdk/1.1"],"0.3.0":["eventsdk/1.0","eventsdk/1.1","eventsdk/1.2"],"0.3.1":["eventsdk/1.0","eventsdk/1.1","eventsdk/1.2"],"0.4.0":["eventsdk/1.0","eventsdk/1.1","eventsdk/1.2"]};function checkCompatibility(producer,consumer){for(const version of[producer,consumer]){if(!Object.hasOwn(profilesBySdk,version.sdkVersion)||version.schemaMajor!==1||version.cloudEvents!=="1.0")return{compatible:false,reason:"UNSUPPORTED_VERSION"}}if(producer.profile!==consumer.profile)return{compatible:false,reason:"PROFILE_MISMATCH"};for(const version of[producer,consumer]){if(!profilesBySdk[version.sdkVersion]?.includes(version.profile))return{compatible:false,reason:"UNSUPPORTED_VERSION"}}return{compatible:true}}import assert2 from"node:assert/strict";import{assertLiveLease,decideRetry,recoverGap,recoverReceipt,stageEventLogPage}from"@eventsdk/sdk/core";function checkRetryAndFence(){const policy={maxAttempts:4,baseDelayMs:100,maxDelayMs:250,jitterRatio:.25};for(const sample of[0,.5,.999999]){for(let attempt=1;attempt<4;attempt++){const result=decideRetry(attempt,1e3,policy,{next:()=>sample});assert2.equal(result.kind,"RETRY");if(result.kind==="RETRY")assert2.ok(result.nextAttemptAt>=1e3&&result.nextAttemptAt<=1250)}}assert2.deepEqual(decideRetry(4,1e3,policy,{next:()=>0}),{kind:"EXHAUSTED"});for(const lease of[{token:"old",generation:1,expiresAt:999},{token:"",generation:1,expiresAt:2e3},{token:"token",generation:0,expiresAt:2e3}])assert2.throws(()=>assertLiveLease(lease,1e3),{code:"STALE_LEASE"})}async function checkGapIsNotSkipped(){let staged=false;let gapRecorded=false;const result=await stageEventLogPage("3",10,{readAfter:async()=>({kind:"GAP",oldestAvailableCursor:"9"})},{recordGap:async(expected,oldest)=>{assert2.equal(expected,"3");assert2.equal(oldest,"9");gapRecorded=true},stageAndAdvance:async()=>{staged=true}},{timeoutMs:1e3});assert2.equal(result,"GAP");assert2.equal(gapRecorded,true);assert2.equal(staged,false);await assert2.rejects(recoverGap("source-a","tenant-a","3",{readAuthorized:async()=>null,applyAndCheckpoint:async()=>{staged=true}},{timeoutMs:1e3}),{code:"RECOVERY_REQUIRED"});assert2.equal(staged,false)}async function checkUnknownReceipt(receipt){const key2={source:receipt.originSource,id:receipt.originEventId,consumerRef:receipt.consumerRef,targetScope:receipt.targetScope};for(const disposition of["RECEIVED","UNKNOWN","HOLD"]){const observation=await recoverReceipt(key2,receipt.deliveryRef,{read:async()=>({...receipt,disposition})},{timeoutMs:1e3});assert2.equal(observation.status,"WAIT")}await assert2.rejects(recoverReceipt(key2,receipt.deliveryRef,{read:async()=>({...receipt,originEventId:"different-event"})},{timeoutMs:1e3}),{code:"RECEIPT_MISMATCH"})}async function runCases(factory,cases){const results=[];for(const[id,check]of cases){const harness=await factory();try{await check(harness);results.push({id,passed:true})}catch{results.push({id,passed:false,failureCode:"ASSERTION_FAILED"})}finally{await harness.close()}}return results}import assert3 from"node:assert/strict";import{recordEvent,relayOutbox}from"@eventsdk/sdk/core";var options2={timeoutMs:2e3};var relayOptions={...options2,batchSize:1,leaseMs:1e4,retry:{maxAttempts:4,baseDelayMs:0,maxDelayMs:1,jitterRatio:0}};async function record(h){await h.transaction(async tx=>{await h.writeDomain(tx);await recordEvent(tx,h.event,h.origin,h.dependencies(),options2)})}async function rollbackCase(h){await assert3.rejects(h.transaction(async tx=>{await h.writeDomain(tx);await recordEvent(tx,h.event,h.origin,h.dependencies(),options2);throw new Error("SYNTHETIC_DOMAIN_ROLLBACK")}),{message:"SYNTHETIC_DOMAIN_ROLLBACK"});assert3.deepEqual(await h.inspect(),{domainCount:0,outboxCount:0,states:[]})}async function unknownReopenCase(h){await record(h);const ids=[];const first=await relayOutbox({...h.dependencies(),publisher:{publish:async(event,context)=>{assert3.equal(event.source,h.event.source);assert3.equal(event.id,h.event.id);ids.push(context.messageId);throw new Error("SYNTHETIC_PUBACK_LOSS")}}},relayOptions);assert3.equal(first.unknown,1);assert3.deepEqual((await h.inspect()).states,["UNKNOWN"]);await h.reopen();assert3.deepEqual((await h.inspect()).states,["UNKNOWN"]);const second=await relayOutbox({...h.dependencies(),publisher:{publish:async(event,context)=>{assert3.equal(event.id,h.event.id);ids.push(context.messageId);return{stream:"probe",sequence:1,duplicate:true}}}},relayOptions);assert3.equal(second.published,1);assert3.equal(ids.length,2);assert3.equal(ids[0],ids[1]);assert3.deepEqual(await h.inspect(),{domainCount:1,outboxCount:1,states:["PUBLISHED"]})}function settleClaim(outbox,claim,outcome,signal){if(claim.event.profile==="eventsdk/1.2"){assert3.ok(outbox.settleFanoutPublish,"profile1.2 requires per-delivery fenced settlement");return outbox.settleFanoutPublish(claim.event,claim.lease,outcome,signal)}return outbox.settlePublish(claim.event,claim.lease,outcome,signal)}async function fencingCase(h){await record(h);const deps=h.dependencies();const claimInput={limit:1,now:deps.clock.now(),leaseMs:1e4,signal:AbortSignal.timeout(2e3)};const old=(await deps.outbox.claimReady(claimInput))[0];assert3.ok(old);await h.expireLease();const fresh=(await deps.outbox.claimReady({...claimInput,now:deps.clock.now()}))[0];assert3.ok(fresh);assert3.ok(fresh.lease.generation>old.lease.generation);const published={status:"PUBLISHED",ack:{stream:"probe",sequence:1,duplicate:false}};await assert3.rejects(settleClaim(deps.outbox,old,published,claimInput.signal),{code:"STALE_LEASE"});await settleClaim(deps.outbox,fresh,published,claimInput.signal);assert3.deepEqual((await h.inspect()).states,["PUBLISHED"])}async function revocationCase(h){await record(h);await h.setAuthorized(false);let calls=0;const result=await relayOutbox({...h.dependencies(),publisher:{publish:async()=>{calls++;return{stream:"probe",sequence:1,duplicate:false}}}},relayOptions);assert3.equal(result.held,1);assert3.equal(calls,0);assert3.deepEqual((await h.inspect()).states,["HOLD"])}function runProducerConformance(factory){return runCases(factory,[["E4.PRODUCER_ATOMIC_ROLLBACK",rollbackCase],["E5.PRODUCER_UNKNOWN_REOPEN_STABLE_ID",unknownReopenCase],["E5.PRODUCER_FENCING",fencingCase],["E2.PRODUCER_CURRENT_AUTHORIZATION",revocationCase]])}import assert4 from"node:assert/strict";import{recoverReceipt as recoverReceipt2}from"@eventsdk/sdk/core";var read=h=>recoverReceipt2(h.key,h.receipt.deliveryRef,h.reader(),{timeoutMs:2e3});async function waiting(h){for(const disposition of["RECEIVED","HOLD","UNKNOWN"]){await h.persist({...h.receipt,disposition});assert4.equal((await read(h)).status,"WAIT")}}async function correlation(h){for(const field of["originSource","originEventId","deliveryRef","consumerRef","targetScope"]){await h.persist({...h.receipt,[field]:h.receipt[field]+"-wrong"});await assert4.rejects(read(h),{code:"RECEIPT_MISMATCH"})}}async function durable(h){const receipt={...h.receipt,disposition:"APPLIED"};await h.persist(receipt);await h.reopen();assert4.deepEqual(await read(h),{status:"RESOLVED",receipt})}async function rejected(h){const receipt={...h.receipt,disposition:"REJECTED",reasonCode:"BUSINESS_REFUSED"};await h.persist(receipt);await h.reopen();assert4.deepEqual(await read(h),{status:"RESOLVED",receipt})}async function denial(h){await h.persist(h.receipt);await h.setAuthorized(false);await assert4.rejects(read(h),{code:"AUTHORIZATION_DENIED"})}function runReceiptConformance(factory){return runCases(factory,[["E6.RECEIPT_UNKNOWN_WAIT",waiting],["E6.RECEIPT_EXACT_CORRELATION",correlation],["E6.RECEIPT_DURABLE_REOPEN",durable],["E6.RECEIPT_REJECTED_DURABLE_REOPEN",rejected],["E2.RECEIPT_CURRENT_AUTHORIZATION",denial]])}import assert5 from"node:assert/strict";import{readAuthorizedResult}from"@eventsdk/sdk/core";var read2=h=>readAuthorizedResult(h.request,h.reader,h.authorization,h.digest,AbortSignal.timeout(2e3),h.clock);async function exact(h){assert5.deepEqual((await read2(h)).reference,h.request.reference)}async function revision(h){await h.mutateSource("REVISION");await assert5.rejects(read2(h),{code:"RESULT_MISMATCH"})}async function digest(h){await h.mutateSource("VALUE");await assert5.rejects(read2(h),{code:"RESULT_MISMATCH"})}async function missing(h){await h.mutateSource("ABSENT");await assert5.rejects(read2(h),{code:"RECOVERY_REQUIRED"})}async function sourceDenial(h){await h.setSourceAuthorized(false);await assert5.rejects(read2(h),{code:"AUTHORIZATION_DENIED"})}async function sourceScope(h){await assert5.rejects(h.reader.read(h.request.reference,{event:h.request.event,origin:h.request.origin,targetScope:h.request.targetScope+"-unauthorized",signal:AbortSignal.timeout(2e3)}),{code:"AUTHORIZATION_DENIED"})}async function receiverDenial(h){await h.setReceiverAuthorized(false);await assert5.rejects(read2(h),{code:"AUTHORIZATION_DENIED"});assert5.equal(h.sourceReads(),0)}function runResultConformance(factory){return runCases(factory,[["E7.RESULT_EXACT_REFERENCE",exact],["E7.RESULT_REVISION_MISMATCH",revision],["E7.RESULT_DIGEST_MISMATCH",digest],["E7.RESULT_MISSING",missing],["E2.RESULT_SOURCE_AUTHORIZATION",sourceDenial],["E2.RESULT_SOURCE_SCOPE",sourceScope],["E2.RESULT_RECEIVER_DENIAL_NO_READ",receiverDenial]])}import assert6 from"node:assert/strict";import{applyDelivery}from"@eventsdk/sdk/core";function observedEffect(h,claim){let calls=0;return{calls:()=>calls,domain:{apply:async tx=>{calls++;await h.writeEffect(tx,claim)}}}}async function rollback(h){const claim=await h.claim();const before=await h.inspect();await assert6.rejects(applyDelivery(claim,{...h.dependencies(),domain:{apply:async(tx,current)=>{await h.writeEffect(tx,current);throw new Error("CONFORMANCE_AFTER_EFFECT")}}},h.options));assert6.deepEqual(await h.inspect(),before)}async function terminal(h){const claim=await h.claim();const effect=observedEffect(h,claim);const deps={...h.dependencies(),domain:effect.domain};const receipt=await applyDelivery(claim,deps,h.options);assert6.equal(receipt.disposition,"APPLIED");await assert6.rejects(applyDelivery(claim,deps,h.options));assert6.equal(effect.calls(),1);await h.reopen();const actual=await h.inspect();assert6.deepEqual(actual.receipt,receipt);assert6.equal(actual.effects,1)}async function receiptFailure(h){const claim=await h.claim();const effect=observedEffect(h,claim);const before=await h.inspect();await h.failNextReceiptCommit();await assert6.rejects(applyDelivery(claim,{...h.dependencies(),domain:effect.domain},h.options));assert6.equal(effect.calls(),1);assert6.deepEqual(await h.inspect(),before)}async function staleFence(h){const claim=await h.claim();const effect=observedEffect(h,claim);const before=await h.inspect();await h.invalidateLease();await assert6.rejects(applyDelivery(claim,{...h.dependencies(),domain:effect.domain},h.options));assert6.equal(effect.calls(),0);assert6.deepEqual(await h.inspect(),before)}async function revoked(h){const claim=await h.claim();const effect=observedEffect(h,claim);await h.setAuthorized(false);const receipt=await applyDelivery(claim,{...h.dependencies(),domain:effect.domain},h.options);assert6.equal(effect.calls(),0);assert6.equal(receipt.disposition,"REJECTED");assert6.equal((await h.inspect()).effects,0);await h.reopen();assert6.deepEqual((await h.inspect()).receipt,receipt)}async function businessOutcome(h,disposition){const claim=await h.claim();const receipt=await applyDelivery(claim,{...h.dependencies(),domain:{apply:async tx=>{await h.writeEffect(tx,claim);return{disposition,reasonCode:"BUSINESS_CONDITION_UNMET"}}}},h.options);assert6.equal(receipt.disposition,disposition);assert6.equal(receipt.reasonCode,"BUSINESS_CONDITION_UNMET");assert6.equal((await h.inspect()).effects,0);await h.reopen();assert6.deepEqual((await h.inspect()).receipt,receipt)}function runApplyConformance(factory){return runCases(factory,[["E4.APPLY_EFFECT_ROLLBACK",rollback],["E4.APPLY_TERMINAL_DURABLE_ONCE",terminal],["E4.APPLY_RECEIPT_FAILURE_ROLLBACK",receiptFailure],["E5.APPLY_STALE_FENCE",staleFence],["E2.APPLY_REVOKED",revoked],["E6.BUSINESS_REJECTED_NO_EFFECT",h=>businessOutcome(h,"REJECTED")],["E6.BUSINESS_HOLD_NO_EFFECT",h=>businessOutcome(h,"HOLD")]])}import assert7 from"node:assert/strict";import{applyDelivery as applyDelivery2}from"@eventsdk/sdk/core";function gate(){let resolve=()=>{};const promise=new Promise(done=>{resolve=done});return{promise,resolve}}async function lateCommit(h){const claim=await h.claim();const before=await h.inspect();const entered=gate();const release=gate();let called=false;const applying=applyDelivery2(claim,{...h.dependencies(),domain:{apply:async tx=>{await h.writeEffect(tx,claim);called=true;entered.resolve();await release.promise}}},h.options);try{await Promise.race([entered.promise,applying]);assert7.equal(called,true);const deferring=h.work().defer(claim.key,claim.lease,claim.receipt,0,"CONFORMANCE_CONCURRENT_DEFER",AbortSignal.timeout(h.options.timeoutMs));const joined=Promise.allSettled([applying,deferring]);release.resolve();const results=await joined;assert7.equal(results.filter(result=>result.status==="fulfilled").length,1);const actual=await h.inspect();if(results[0]?.status==="fulfilled"){assert7.equal(actual.receipt.disposition,"APPLIED");assert7.equal(actual.effects,1)}else{assert7.deepEqual(actual.receipt,before.receipt);assert7.equal(actual.effects,0)}await h.reopen();assert7.deepEqual(await h.inspect(),actual)}finally{release.resolve();await applying.catch(()=>{})}}import assert8 from"node:assert/strict";import{applyDelivery as applyDelivery3,replayDeadLetter,runInboxWorker}from"@eventsdk/sdk/core";function options3(h){return{...h.options,batchSize:1,leaseMs:h.options.timeoutMs*4,retry:{maxAttempts:2,baseDelayMs:0,maxDelayMs:0,jitterRatio:0}}}function dependencies(h){let sequence=0;return{work:h.work(),receipts:h.dependencies().inbox,deadLetters:h.deadLetters(),clock:h.dependencies().clock,random:{next:()=>0},ids:{next:()=>`conformance-dlq-${++sequence}`},process:claim=>applyDelivery3(claim,{...h.dependencies(),domain:{apply:tx=>h.writeEffect(tx,claim)}},h.options)}}async function exhaust(h){const deps={...dependencies(h),process:async()=>{throw new Error("CONFORMANCE_POISON")}};assert8.equal((await runInboxWorker(deps,options3(h))).RETRY,1);assert8.equal((await runInboxWorker(deps,options3(h))).QUARANTINED,1);const before=await h.inspect();assert8.equal(before.effects,0);assert8.equal(before.quarantined,true);assert8.equal(before.deadLetters.length,1);const entry=before.deadLetters[0];assert8.ok(entry);assert8.equal(entry.originalDeliveryRef,before.receipt.deliveryRef);assert8.equal(entry.key.id,before.receipt.originEventId);assert8.equal(entry.attempts,2);await h.reopen();assert8.deepEqual(await h.inspect(),before);return entry}async function lostReply(h){const deps=dependencies(h);const result=await runInboxWorker({...deps,process:async(claim,opts)=>{await deps.process(claim,opts);throw new Error("CONFORMANCE_COMMITTED_REPLY_LOST")}},options3(h));assert8.equal(result.APPLIED,1);await h.reopen();assert8.equal((await h.inspect()).effects,1);assert8.equal((await h.inspect()).receipt.disposition,"APPLIED");assert8.equal((await runInboxWorker(dependencies(h),options3(h))).APPLIED,0);assert8.equal((await h.inspect()).effects,1)}async function replay(h){const entry=await exhaust(h);await h.setAuthorized(false);await assert8.rejects(replayDeadLetter(entry,h.deadLetters(),h.dependencies().authorization,h.options));assert8.equal((await h.inspect()).quarantined,true);await h.setAuthorized(true);const letters=h.deadLetters();const races=await Promise.allSettled([1,2].map(()=>replayDeadLetter(entry,letters,h.dependencies().authorization,h.options)));assert8.equal(races.filter(r=>r.status==="fulfilled").length,1);assert8.equal((await runInboxWorker(dependencies(h),options3(h))).APPLIED,1);const actual=await h.inspect();assert8.equal(actual.effects,1);assert8.equal(actual.receipt.originEventId,entry.key.id);assert8.equal(actual.receipt.deliveryRef,entry.originalDeliveryRef)}async function unknown(h){await h.seedUnknown();let called=0;const result=await runInboxWorker({...dependencies(h),process:async()=>{called++;throw new Error("UNKNOWN_MUST_NOT_PROCESS")}},options3(h));assert8.equal(called,0);assert8.equal(result.QUARANTINED,1);await h.reopen();const actual=await h.inspect();assert8.equal(actual.effects,0);assert8.equal(actual.receipt.disposition,"UNKNOWN");assert8.equal(actual.quarantined,true);const entry=actual.deadLetters[0];assert8.ok(entry);await assert8.rejects(replayDeadLetter(entry,h.deadLetters(),h.dependencies().authorization,h.options));assert8.deepEqual(await h.inspect(),actual)}async function exclusive(h){const request={limit:1,now:h.dependencies().clock.now(),leaseMs:h.options.timeoutMs*4,signal:new AbortController().signal};const results=await Promise.all([h.work().claimReady(request),h.work().claimReady(request)]);assert8.equal(results.flat().length,1)}async function deferFence(h){const claim=await h.claim();const before=await h.inspect();await h.work().defer(claim.key,claim.lease,claim.receipt,0,"CONFORMANCE_DEFER",new AbortController().signal);await assert8.rejects(applyDelivery3(claim,{...h.dependencies(),domain:{apply:tx=>h.writeEffect(tx,claim)}},h.options));assert8.deepEqual(await h.inspect(),before);assert8.equal((await runInboxWorker(dependencies(h),options3(h))).APPLIED,1);assert8.equal((await h.inspect()).effects,1)}function runWorkerConformance(factory){return runCases(factory,[["E5.WORKER_LOST_REPLY_READBACK",lostReply],["E5.DLQ_DURABLE_AUTHORIZED_REPLAY",replay],["E5.UNKNOWN_NEVER_REAPPLIED",unknown],["E5.WORKER_EXCLUSIVE_CLAIM",exclusive],["E5.WORKER_DEFER_FENCES_OLD_APPLY",deferFence],["E5.WORKER_LATE_COMMIT_VS_DEFER",lateCommit]])}import assert9 from"node:assert/strict";import{recoverGap as recoverGap2}from"@eventsdk/sdk/core";var recover=(h,expected=h.initialWatermark)=>recoverGap2(h.source,h.scope,expected,h.port(),h.options);async function denied(h){const before=await h.inspect();for(const side of["SOURCE","TARGET"]){await h.setAuthorized(side,false);await assert9.rejects(recover(h));assert9.deepEqual(await h.inspect(),before);await h.setAuthorized(side,true)}}async function rollback2(h){const before=await h.inspect();await h.failAfterCheckpoint();await assert9.rejects(recover(h));assert9.deepEqual(await h.inspect(),before);await h.reopen();assert9.deepEqual(await h.inspect(),before)}async function stale(h){const before=await h.inspect();await assert9.rejects(recover(h,h.initialWatermark+"-stale"));assert9.deepEqual(await h.inspect(),before)}async function durableWinner(h){const results=await Promise.allSettled([recover(h),recover(h)]);assert9.equal(results.filter(result=>result.status==="fulfilled").length,1);const expected={watermark:h.expected.watermark,snapshot:h.expected};assert9.deepEqual(await h.inspect(),expected);await h.reopen();assert9.deepEqual(await h.inspect(),expected);await assert9.rejects(recover(h));assert9.deepEqual(await h.inspect(),expected)}function runGapConformance(factory){return runCases(factory,[["E5.GAP_CURRENT_BOTH_AUTHORIZATIONS",denied],["E5.GAP_SNAPSHOT_CHECKPOINT_ROLLBACK",rollback2],["E5.GAP_STALE_WATERMARK_NO_EFFECT",stale],["E5.GAP_DURABLE_SINGLE_WINNER",durableWinner]])}import assert10 from"node:assert/strict";async function terminal2(h,disposition){const initial=h.initial;const final={...initial,revision:initial.revision+2,disposition,...disposition==="REJECTED"?{reasonCode:"BUSINESS_REFUSED"}:{}};await h.deliver(initial);await h.deliver(final);await h.deliver(final);await h.deliver({...initial,revision:initial.revision+1,disposition:"HOLD",reasonCode:"OLDER_HOLD"});assert10.deepEqual(await h.read(),final);await h.reopen();assert10.deepEqual(await h.read(),final);await assert10.rejects(h.deliver({...final,revision:final.revision+1,disposition:disposition==="APPLIED"?"REJECTED":"APPLIED"}));assert10.deepEqual(await h.read(),final)}async function conflict(h){await h.deliver(h.initial);await assert10.rejects(h.deliver({...h.initial,disposition:"HOLD",reasonCode:"CONFLICTING_REVISION"}));assert10.deepEqual(await h.read(),h.initial)}function runReceiptProjectionConformance(factory){return runCases(factory,[["E6.PROJECTION_APPLIED_TERMINAL_ORDERING",h=>terminal2(h,"APPLIED")],["E6.PROJECTION_REJECTED_TERMINAL_ORDERING",h=>terminal2(h,"REJECTED")],["E6.PROJECTION_SAME_REVISION_CONFLICT",conflict]])}import assert12 from"node:assert/strict";import{relayOutbox as relayOutbox2}from"@eventsdk/sdk/core";import assert11 from"node:assert/strict";import{acceptDelivery as acceptDelivery2,applyDelivery as applyDelivery4,prepareFanoutDelivery,recordFanoutEvent}from"@eventsdk/sdk/core";function key(h,target){return{source:h.draft.source,id:h.draft.id,consumerRef:target.consumerRef,targetScope:target.targetScope}}async function record2(h,targets=h.targets.slice(0,2),draft=h.draft){let deliveries=[];await h.transaction(async tx=>{deliveries=await recordFanoutEvent(tx,draft,targets.map(t=>t.recipient),h.producer(),h.options)});return deliveries}async function receive(h,target,event){const delivery=event??await prepareFanoutDelivery(h.draft,target.recipient.route,h.producer().digest);return acceptDelivery2({event:delivery,origin:target.recipient.origin,deliveryRef:`fanout-${delivery.deliveryid}`,consumerRef:target.consumerRef},h.admission(target),h.options)}async function apply(h,target){const claim=await h.claim(key(h,target));assert11.ok(claim);return applyDelivery4(claim,h.application(),h.options)}async function independentRoutes(h){const deliveries=await record2(h);assert12.equal(deliveries.length,2);assert12.equal(new Set(deliveries.map(event=>event.deliveryid)).size,2);assert12.ok(deliveries.every(event=>event.source===h.draft.source&&event.id===h.draft.id));assert12.notDeepEqual(key(h,h.targets[0]),key(h,h.targets[1]));const failed=deliveries[1];assert12.ok(failed);await settleIndependently(h,failed.deliveryid);for(const target of h.targets.slice(0,2)){assert12.equal((await receive(h,target)).kind,"RECEIVED");assert12.equal((await apply(h,target)).disposition,"APPLIED");assert12.equal((await receive(h,target)).kind,"DUPLICATE")}const actual=await h.inspect();assert12.equal(actual.effects.length,2);for(const target of h.targets.slice(0,2))assert12.deepEqual(actual.effects.find(item=>item.targetScope===target.targetScope&&item.consumerRef===target.consumerRef),key(h,target));assert12.equal(actual.accepted.length,2);assert12.equal(actual.inboundDeliveries,2)}async function settleIndependently(h,failedDelivery){const options4={...h.options,batchSize:2,leaseMs:h.options.timeoutMs*4,retry:{maxAttempts:3,baseDelayMs:0,maxDelayMs:0,jitterRatio:0}};const first=await relayOutbox2({...h.producer(),publisher:{publish:async event=>{if(event.profile!=="eventsdk/1.2")throw new Error("WRONG_FANOUT_PROFILE");if(event.deliveryid===failedDelivery)throw new Error("CONFORMANCE_ONE_ROUTE_ACK_LOST");return{stream:"conformance",sequence:1,duplicate:false}}}},options4);assert12.deepEqual(first,{published:1,unknown:1,held:0});const before=await h.inspect();assert12.equal(before.logicalFacts,1);assert12.equal(before.outbound.find(r=>r.event.deliveryid===failedDelivery)?.status,"UNKNOWN");assert12.equal(before.outbound.find(r=>r.event.deliveryid!==failedDelivery)?.status,"PUBLISHED");await h.reopen();assert12.deepEqual(await h.inspect(),before);const published=[];const retry=await relayOutbox2({...h.producer(),publisher:{publish:async event=>{if(event.profile!=="eventsdk/1.2")throw new Error("WRONG_FANOUT_PROFILE");published.push(event.deliveryid);return{stream:"conformance",sequence:2,duplicate:true}}}},options4);assert12.deepEqual(retry,{published:1,unknown:0,held:0});assert12.deepEqual(published,[failedDelivery])}import assert13 from"node:assert/strict";import{prepareFanoutDelivery as prepareFanoutDelivery2,recordFanoutEvent as recordFanoutEvent2}from"@eventsdk/sdk/core";async function logicalConflict(h){await record2(h);assert13.equal((await receive(h,h.targets[0])).kind,"RECEIVED");const before=await h.inspect();const changedDraft={...h.draft,data:{conformanceOriginal:h.draft.data}};await assert13.rejects(record2(h,h.targets.slice(0,2),changedDraft),{code:"EVENT_ID_CONFLICT"});const alias=h.targets[2];const changed=await prepareFanoutDelivery2(changedDraft,alias.recipient.route,h.producer().digest);assert13.deepEqual(await receive(h,alias,changed),{kind:"REJECTED",reasonCode:"EVENT_ID_CONFLICT"});assert13.deepEqual(await h.inspect(),before)}async function deliveryConflict(h){const target=h.targets[0];await record2(h,[target]);assert13.equal((await receive(h,target)).kind,"RECEIVED");const before=await h.inspect();const replacement=await h.replacementGrant(target);const original=await prepareFanoutDelivery2(h.draft,target.recipient.route,h.producer().digest);const changed=await prepareFanoutDelivery2(h.draft,replacement.recipient.route,h.producer().digest);assert13.equal(original.deliveryid,changed.deliveryid);await assert13.rejects(record2(h,[replacement]),{code:"EVENT_ID_CONFLICT"});assert13.deepEqual(await receive(h,replacement,changed),{kind:"REJECTED",reasonCode:"EVENT_ID_CONFLICT"});assert13.deepEqual(await h.inspect(),before)}async function aliasDedup(h){const first=h.targets[0];const alias=h.targets[2];assert13.deepEqual(key(h,alias),key(h,first));assert13.notEqual(first.recipient.route.connectionref,alias.recipient.route.connectionref);await record2(h,[first,alias]);assert13.equal((await receive(h,first)).kind,"RECEIVED");assert13.equal((await apply(h,first)).disposition,"APPLIED");const accepted=(await h.inspect()).accepted;assert13.equal((await receive(h,alias)).kind,"DUPLICATE");assert13.equal(await h.claim(key(h,alias)),null);const actual=await h.inspect();assert13.deepEqual(actual.accepted,accepted);assert13.deepEqual(actual.effects,[key(h,first)]);assert13.equal(actual.inboundDeliveries,2);await h.reopen();assert13.equal((await receive(h,alias)).kind,"DUPLICATE");assert13.deepEqual(await h.inspect(),actual)}async function rollback3(h){const before=await h.inspect();await assert13.rejects(h.transaction(async tx=>{await h.writeDomain(tx);await recordFanoutEvent2(tx,h.draft,h.targets.map(t=>t.recipient),h.producer(),h.options);throw new Error("CONFORMANCE_AFTER_ALL_ROUTES")}),/CONFORMANCE_AFTER_ALL_ROUTES/);assert13.deepEqual(await h.inspect(),before);await h.reopen();assert13.deepEqual(await h.inspect(),before)}async function deniedRouteRollback(h){const before=await h.inspect();await h.setAuthorized(h.targets[1],false);await assert13.rejects(h.transaction(async tx=>{await h.writeDomain(tx);await recordFanoutEvent2(tx,h.draft,h.targets.slice(0,2).map(t=>t.recipient),h.producer(),h.options)}),{code:"AUTHORIZATION_DENIED"});assert13.deepEqual(await h.inspect(),before)}async function concurrentRecord(h){await Promise.all([record2(h),record2(h)]);const actual=await h.inspect();assert13.equal(actual.logicalFacts,1);assert13.equal(actual.outbound.length,2);await h.reopen();await record2(h);assert13.deepEqual(await h.inspect(),actual)}function runFanoutConformance(factory){return runCases(factory,[["E4.FANOUT_INDEPENDENT_DELIVERY_SETTLEMENT",independentRoutes],["E1.FANOUT_LOGICAL_CONTENT_CONFLICT",logicalConflict],["E2.FANOUT_DELIVERY_GRANT_CONFLICT",deliveryConflict],["E4.FANOUT_SAME_SCOPE_ALIAS_DEDUP",aliasDedup],["E4.FANOUT_ENTIRE_TRANSACTION_ROLLBACK",rollback3],["E2.FANOUT_DENIED_ROUTE_ROLLBACK",deniedRouteRollback],["E5.FANOUT_CONCURRENT_RECORD_REOPEN",concurrentRecord]])}import assert14 from"node:assert/strict";async function approve(h){const pending=await h.receiver.begin(h.params);const consent=await h.receiver.consent(pending.ref,pending.proof,h.actor);const redirect=await h.receiver.decide(pending.ref,pending.proof,h.actor,consent.consentBinding,"allow");const code=new URL(redirect.location).searchParams.get("code");assert14.ok(code);return h.token(code)}async function singleUse(h){const token=await approve(h);const result=await h.receiver.exchange(token);assert14.equal(result.requestId,h.params.get("request_id"));await assert14.rejects(h.receiver.exchange(token))}async function concurrent(h){const token=await approve(h);const results=await Promise.allSettled([h.receiver.exchange(token),h.receiver.exchange(token)]);assert14.equal(results.filter(result=>result.status==="fulfilled").length,1)}async function durable2(h){const token=await approve(h);await h.reopen();await h.receiver.exchange(token);await h.reopen();await assert14.rejects(h.receiver.exchange(token))}async function actorRevoked(h){const token=await approve(h);await h.revokeActor();await assert14.rejects(h.receiver.exchange(token))}async function grantRevoked(h){const token=await approve(h);await h.revokeGrant();await assert14.rejects(h.receiver.exchange(token))}async function pkce(h){const token=await approve(h);await assert14.rejects(h.receiver.exchange({...token,code_verifier:"x".repeat(64)}));await assert14.rejects(h.receiver.exchange({...token,client_id:token.client_id+"-wrong"}));await assert14.rejects(h.receiver.exchange({...token,redirect_uri:token.redirect_uri+"/wrong"}));await h.receiver.exchange(token)}async function deny(h){const pending=await h.receiver.begin(h.params);const consent=await h.receiver.consent(pending.ref,pending.proof,h.actor);const result=await h.receiver.decide(pending.ref,pending.proof,h.actor,consent.consentBinding,"deny");assert14.equal(new URL(result.location).searchParams.get("error"),"access_denied");await assert14.rejects(h.receiver.decide(pending.ref,pending.proof,h.actor,consent.consentBinding,"allow"));await assert14.rejects(h.receiver.begin(h.params))}function runEventLinkReceiverConformance(factory){return runCases(factory,[["EVENT_LINK.ONE_TIME_CODE",singleUse],["EVENT_LINK.CONCURRENT_CONSUMPTION",concurrent],["EVENT_LINK.DURABLE_REOPEN",durable2],["EVENT_LINK.CURRENT_ACTOR",actorRevoked],["EVENT_LINK.CURRENT_GRANT",grantRevoked],["EVENT_LINK.PKCE_CLIENT_CALLBACK",pkce],["EVENT_LINK.DENIAL_NO_REPLAY",deny]])}export{checkCompatibility,checkGapIsNotSkipped,checkRetryAndFence,checkUnknownReceipt,runAdmissionConformance,runApplyConformance,runEventLinkReceiverConformance,runFanoutConformance,runGapConformance,runProducerConformance,runReceiptConformance,runReceiptProjectionConformance,runResultConformance,runWorkerConformance};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CloudEvent } from '@eventsdk/sdk/contracts';
|
|
2
|
+
import type { VerifiedOrigin } from '@eventsdk/sdk/identity-contracts';
|
|
3
|
+
import type { RelayDependencies, RecordDependencies } from '@eventsdk/sdk/core';
|
|
4
|
+
export interface ProducerObservation {
|
|
5
|
+
readonly domainCount: number;
|
|
6
|
+
readonly outboxCount: number;
|
|
7
|
+
readonly states: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
export interface ProducerHarness<TTransaction> {
|
|
10
|
+
readonly event: CloudEvent;
|
|
11
|
+
readonly origin: VerifiedOrigin;
|
|
12
|
+
dependencies(): Omit<RelayDependencies, 'publisher'> & RecordDependencies<TTransaction>;
|
|
13
|
+
transaction(operation: (tx: TTransaction) => Promise<void>): Promise<void>;
|
|
14
|
+
writeDomain(tx: TTransaction): Promise<void>;
|
|
15
|
+
inspect(): Promise<ProducerObservation>;
|
|
16
|
+
expireLease(): Promise<void>;
|
|
17
|
+
setAuthorized(authorized: boolean): Promise<void>;
|
|
18
|
+
reopen(): Promise<void>;
|
|
19
|
+
close(): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
export type ProducerHarnessFactory<TTransaction> = () => Promise<ProducerHarness<TTransaction>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BusinessReceipt } from '@eventsdk/sdk/contracts';
|
|
2
|
+
import type { InboxKey, ReceiptLookupPort } from '@eventsdk/sdk/core';
|
|
3
|
+
export interface ReceiptHarness {
|
|
4
|
+
readonly key: InboxKey;
|
|
5
|
+
readonly receipt: BusinessReceipt;
|
|
6
|
+
reader(): ReceiptLookupPort;
|
|
7
|
+
persist(receipt: BusinessReceipt): Promise<void>;
|
|
8
|
+
setAuthorized(authorized: boolean): Promise<void>;
|
|
9
|
+
reopen(): Promise<void>;
|
|
10
|
+
close(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export type ReceiptHarnessFactory = () => Promise<ReceiptHarness>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BusinessReceipt } from '@eventsdk/sdk/contracts';
|
|
2
|
+
export interface ReceiptProjectionHarness {
|
|
3
|
+
readonly initial: BusinessReceipt;
|
|
4
|
+
deliver(receipt: BusinessReceipt): Promise<void>;
|
|
5
|
+
read(): Promise<BusinessReceipt | null>;
|
|
6
|
+
reopen(): Promise<void>;
|
|
7
|
+
close(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export type ReceiptProjectionHarnessFactory = () => Promise<ReceiptProjectionHarness>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AuthorizationPort } from '@eventsdk/sdk/identity-contracts';
|
|
2
|
+
import type { Clock, Digest, ResultReadPort, ResultReadRequest } from '@eventsdk/sdk/core';
|
|
3
|
+
export interface ResultHarness {
|
|
4
|
+
readonly request: ResultReadRequest;
|
|
5
|
+
readonly digest: Digest;
|
|
6
|
+
readonly clock: Clock;
|
|
7
|
+
readonly authorization: AuthorizationPort;
|
|
8
|
+
readonly reader: ResultReadPort;
|
|
9
|
+
mutateSource(change: 'REVISION' | 'VALUE' | 'ABSENT'): Promise<void>;
|
|
10
|
+
setSourceAuthorized(authorized: boolean): Promise<void>;
|
|
11
|
+
setReceiverAuthorized(authorized: boolean): Promise<void>;
|
|
12
|
+
sourceReads(): number;
|
|
13
|
+
close(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export type ResultHarnessFactory = () => Promise<ResultHarness>;
|