@sixthsummit/ship-testing 0.0.0-stage → 1.2.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 ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ ShipAPI
2
+ Copyright 2026 Scott Gibson
3
+
4
+ Licensed under the Apache License, Version 2.0.
package/README.md CHANGED
@@ -1,3 +1,33 @@
1
- # Temporary Holding Version
1
+ # `@sixthsummit/ship-testing`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Reusable behavioral-parity fixtures and a Testcontainers-backed PostgreSQL
4
+ harness. Install this package as a development dependency; it is deliberately a
5
+ separate trust zone and is never pulled into Ship runtime packages.
6
+
7
+ `createInMemoryOutbox()`, `createInMemoryIdempotencyStore()` and
8
+ `drainOutbox()` let unit tests run the outbox dispatcher without a database.
9
+
10
+ ## Cache
11
+
12
+ `createInMemoryCacheBackend()` is an LRU `CacheBackend` for tests and
13
+ single-process development, and `cacheBackendConformance()` is the behavioral
14
+ suite every adapter passes — including that a scope-qualified tag
15
+ (`<tag>@tenant:<key>`, `<tag>@actor:<id>`) purges only its own entries while
16
+ the plain tag still reaches them all.
17
+
18
+ ## Realtime
19
+
20
+ - `createInMemoryRealtimeBackend({ channels, tenantScopes? })` is the process-local `RealtimeBackend` for unit tests and transport smoke fixtures.
21
+ - `collectPublishes(app)` recompiles a compiled application so every channel publication records into one in-memory backend; run the returned `application` and read `publishes()`.
22
+ - `realtimeBackendConformance({ createBackend, test })` registers the behavioral contract every adapter must pass (authorized delivery, fail-closed authorization, per-scope sequencing, presence dedupe, paged snapshots and `actorOnline`, coalescing, disconnect cleanup, health).
23
+
24
+ ## Webhooks
25
+
26
+ - `createInMemoryWebhookEventStore({ outbox, idempotency })` is the in-memory twin of the Drizzle webhook event store.
27
+ - `fakeWebhookProvider()` is a complete HMAC provider (verifier plus `sign()` helper) built only from the public kernel contract, proving a consumer-defined verifier binds without a registry.
28
+
29
+ ## Jobs
30
+
31
+ `createInMemoryJobBackend()`, `createInMemoryLockProvider()` and `runJobOnce()`
32
+ run declared jobs without Redis, and `jobBackendConformance()` is the shared
33
+ behavioral suite every `JobBackend` adapter passes.
package/lib/cache.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ import type { CacheBackend } from "@sixthsummit/ship-core";
2
+ /**
3
+ * In-process cache backend for tests and single-process development.
4
+ *
5
+ * Entries are evicted least-recently-used past `max`, expire on their declared
6
+ * TTL, and are indexed by tag so `delByTag` mirrors what a shared backend does
7
+ * when the cache-invalidation dispatcher performs a purge. Tag invalidation is
8
+ * process-local: a multi-instance deployment needs a shared backend.
9
+ */
10
+ export interface InMemoryCacheBackendOptions {
11
+ /** Entries retained before least-recently-used eviction. Defaults to 1000. */
12
+ readonly max?: number;
13
+ /** Injectable clock, in epoch milliseconds, for deterministic expiry tests. */
14
+ readonly now?: () => number;
15
+ }
16
+ export interface InMemoryCacheBackend extends CacheBackend {
17
+ /** Live entry count, after expiry of anything already past its TTL. */
18
+ size(): number;
19
+ clear(): void;
20
+ }
21
+ export declare function createInMemoryCacheBackend(options?: InMemoryCacheBackendOptions): InMemoryCacheBackend;
22
+ export interface CacheConformanceCheck {
23
+ readonly name: string;
24
+ run(): Promise<void>;
25
+ }
26
+ export declare class CacheConformanceError extends Error {
27
+ readonly check: string;
28
+ constructor(check: string, message: string);
29
+ }
30
+ /**
31
+ * The behavioral contract every CacheBackend adapter must satisfy, expressed as
32
+ * runner-agnostic checks so the same suite runs against the in-memory backend
33
+ * and a real Redis without this package depending on a test framework.
34
+ *
35
+ * `createBackend` must return an empty backend on every call.
36
+ */
37
+ export declare function cacheBackendConformance(createBackend: () => CacheBackend | Promise<CacheBackend>): readonly CacheConformanceCheck[];
38
+ /** Runs every conformance check and returns the failures, if any. */
39
+ export declare function runCacheBackendConformance(createBackend: () => CacheBackend | Promise<CacheBackend>): Promise<readonly {
40
+ readonly name: string;
41
+ readonly error?: Error;
42
+ }[]>;
43
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAqB,MAAM,wBAAwB,CAAC;AAG9E;;;;;;;GAOG;AACH,MAAM,WAAW,2BAA2B;IAC1C,8EAA8E;IAC9E,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,+EAA+E;IAC/E,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,uEAAuE;IACvE,IAAI,IAAI,MAAM,CAAC;IACf,KAAK,IAAI,IAAI,CAAC;CACf;AAQD,wBAAgB,0BAA0B,CACxC,OAAO,GAAE,2BAAgC,GACxC,oBAAoB,CAuEtB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACtB;AAED,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK3C;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,GACxD,SAAS,qBAAqB,EAAE,CAsJlC;AAED,qEAAqE;AACrE,wBAAsB,0BAA0B,CAC9C,aAAa,EAAE,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,GACxD,OAAO,CAAC,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,EAAE,CAAC,CAWvE"}
package/lib/cache.js ADDED
@@ -0,0 +1,199 @@
1
+ import { createSingleFlight } from "@sixthsummit/ship-core";
2
+ export function createInMemoryCacheBackend(options = {}) {
3
+ const max = options.max ?? 1000;
4
+ const now = options.now ?? (() => Date.now());
5
+ const entries = new Map();
6
+ const tagIndex = new Map();
7
+ const gate = createSingleFlight();
8
+ const forget = (key) => {
9
+ entries.delete(key);
10
+ for (const [tag, keys] of tagIndex) {
11
+ keys.delete(key);
12
+ if (keys.size === 0)
13
+ tagIndex.delete(tag);
14
+ }
15
+ };
16
+ const live = (key) => {
17
+ const entry = entries.get(key);
18
+ if (!entry)
19
+ return undefined;
20
+ if (entry.expiresAt <= now()) {
21
+ forget(key);
22
+ return undefined;
23
+ }
24
+ return entry;
25
+ };
26
+ return {
27
+ kind: "ship.cache-backend",
28
+ get: async (key) => {
29
+ const entry = live(key);
30
+ if (!entry)
31
+ return undefined;
32
+ // Refresh recency so eviction stays least-recently-used.
33
+ entries.delete(key);
34
+ entries.set(key, entry);
35
+ return entry.value;
36
+ },
37
+ set: async (key, value, storeOptions) => {
38
+ forget(key);
39
+ entries.set(key, {
40
+ value,
41
+ expiresAt: now() + storeOptions.ttlMs,
42
+ tags: Object.freeze([...(storeOptions.tags ?? [])]),
43
+ });
44
+ for (const tag of storeOptions.tags ?? []) {
45
+ const keys = tagIndex.get(tag) ?? new Set();
46
+ keys.add(key);
47
+ tagIndex.set(tag, keys);
48
+ }
49
+ while (entries.size > max) {
50
+ const oldest = entries.keys().next().value;
51
+ if (oldest === undefined)
52
+ break;
53
+ forget(oldest);
54
+ }
55
+ },
56
+ del: async (key) => {
57
+ forget(key);
58
+ },
59
+ delByTag: async (tag) => {
60
+ for (const key of [...(tagIndex.get(tag) ?? [])])
61
+ forget(key);
62
+ tagIndex.delete(tag);
63
+ },
64
+ health: async () => ({ available: true, detail: `${entries.size} entries` }),
65
+ singleFlight: gate,
66
+ size: () => {
67
+ for (const key of [...entries.keys()])
68
+ live(key);
69
+ return entries.size;
70
+ },
71
+ clear: () => {
72
+ entries.clear();
73
+ tagIndex.clear();
74
+ },
75
+ };
76
+ }
77
+ export class CacheConformanceError extends Error {
78
+ check;
79
+ constructor(check, message) {
80
+ super(`${check}: ${message}`);
81
+ this.name = "CacheConformanceError";
82
+ this.check = check;
83
+ }
84
+ }
85
+ /**
86
+ * The behavioral contract every CacheBackend adapter must satisfy, expressed as
87
+ * runner-agnostic checks so the same suite runs against the in-memory backend
88
+ * and a real Redis without this package depending on a test framework.
89
+ *
90
+ * `createBackend` must return an empty backend on every call.
91
+ */
92
+ export function cacheBackendConformance(createBackend) {
93
+ const check = (name, run) => ({
94
+ name,
95
+ run: async () => {
96
+ await run(await createBackend());
97
+ },
98
+ });
99
+ const expect = (name, condition, message) => {
100
+ if (!condition)
101
+ throw new CacheConformanceError(name, message);
102
+ };
103
+ return Object.freeze([
104
+ check("miss returns undefined", async (backend) => {
105
+ expect("miss returns undefined", (await backend.get("absent")) === undefined, "expected undefined for an unknown key");
106
+ }),
107
+ check("round-trips a stored value", async (backend) => {
108
+ await backend.set("key", { status: 200, data: { total: 7 } }, { ttlMs: 60_000 });
109
+ const stored = await backend.get("key");
110
+ expect("round-trips a stored value", JSON.stringify(stored) === JSON.stringify({ status: 200, data: { total: 7 } }), `expected the stored value back, received ${JSON.stringify(stored)}`);
111
+ }),
112
+ check("keeps a stored null distinct from a miss", async (backend) => {
113
+ await backend.set("key", { status: 200, data: null }, { ttlMs: 60_000 });
114
+ const stored = await backend.get("key");
115
+ expect("keeps a stored null distinct from a miss", stored !== undefined && stored.data === null, "expected a stored null payload to survive the round trip");
116
+ }),
117
+ check("expires an entry after its ttl", async (backend) => {
118
+ await backend.set("key", { status: 200, data: 1 }, { ttlMs: 30 });
119
+ await new Promise((resolve) => setTimeout(resolve, 80));
120
+ expect("expires an entry after its ttl", (await backend.get("key")) === undefined, "expected the entry to expire");
121
+ }),
122
+ check("deletes one key", async (backend) => {
123
+ await backend.set("a", { status: 200, data: 1 }, { ttlMs: 60_000 });
124
+ await backend.set("b", { status: 200, data: 2 }, { ttlMs: 60_000 });
125
+ await backend.del("a");
126
+ expect("deletes one key", (await backend.get("a")) === undefined, "expected a to be gone");
127
+ expect("deletes one key", (await backend.get("b")) !== undefined, "expected b to survive");
128
+ }),
129
+ check("deleting an unknown key is a no-op", async (backend) => {
130
+ await backend.del("absent");
131
+ await backend.delByTag("absent");
132
+ }),
133
+ check("purges every key under a tag", async (backend) => {
134
+ await backend.set("a", { status: 200, data: 1 }, { ttlMs: 60_000, tags: ["widgets"] });
135
+ await backend.set("b", { status: 200, data: 2 }, { ttlMs: 60_000, tags: ["widgets"] });
136
+ await backend.set("c", { status: 200, data: 3 }, { ttlMs: 60_000, tags: ["gadgets"] });
137
+ await backend.delByTag("widgets");
138
+ expect("purges every key under a tag", (await backend.get("a")) === undefined, "a survived");
139
+ expect("purges every key under a tag", (await backend.get("b")) === undefined, "b survived");
140
+ expect("purges every key under a tag", (await backend.get("c")) !== undefined, "an unrelated tag was purged");
141
+ }),
142
+ check("purges a scoped tag without touching entries stored under other scope keys", async (backend) => {
143
+ // The executor stores an actor- or tenant-scoped entry under its plain
144
+ // tag and under `<tag>@<scopeKey>`; a scoped purge names only the latter
145
+ // and must leave every other subject's entries warm, while the plain tag
146
+ // still reaches them all.
147
+ await backend.set("alpha", { status: 200, data: 1 }, { ttlMs: 60_000, tags: ["widgets", "widgets@tenant:salpha"] });
148
+ await backend.set("beta", { status: 200, data: 2 }, { ttlMs: 60_000, tags: ["widgets", "widgets@tenant:sbeta"] });
149
+ await backend.delByTag("widgets@tenant:salpha");
150
+ expect("purges a scoped tag without touching entries stored under other scope keys", (await backend.get("alpha")) === undefined, "alpha survived its scoped purge");
151
+ expect("purges a scoped tag without touching entries stored under other scope keys", (await backend.get("beta")) !== undefined, "beta was purged by another tenant's scoped tag");
152
+ await backend.delByTag("widgets");
153
+ expect("purges a scoped tag without touching entries stored under other scope keys", (await backend.get("beta")) === undefined, "the plain tag no longer reaches a scoped entry");
154
+ }),
155
+ check("rebuilds a tag after it is purged", async (backend) => {
156
+ await backend.set("a", { status: 200, data: 1 }, { ttlMs: 60_000, tags: ["widgets"] });
157
+ await backend.delByTag("widgets");
158
+ await backend.set("a", { status: 200, data: 2 }, { ttlMs: 60_000, tags: ["widgets"] });
159
+ await backend.delByTag("widgets");
160
+ expect("rebuilds a tag after it is purged", (await backend.get("a")) === undefined, "expected the re-tagged key to be purged again");
161
+ }),
162
+ check("overwrites an existing key", async (backend) => {
163
+ await backend.set("a", { status: 200, data: 1 }, { ttlMs: 60_000 });
164
+ await backend.set("a", { status: 200, data: 2 }, { ttlMs: 60_000 });
165
+ const stored = (await backend.get("a"));
166
+ expect("overwrites an existing key", stored?.data === 2, "expected the newer value");
167
+ }),
168
+ check("reports health", async (backend) => {
169
+ const health = await backend.health();
170
+ expect("reports health", health.available === true, "expected an available backend");
171
+ }),
172
+ check("coalesces concurrent misses for one key", async (backend) => {
173
+ if (!backend.singleFlight)
174
+ return;
175
+ let calls = 0;
176
+ const results = await Promise.all(Array.from({ length: 50 }, () => backend.singleFlight?.("key", async () => {
177
+ calls += 1;
178
+ await new Promise((resolve) => setTimeout(resolve, 5));
179
+ return calls;
180
+ })));
181
+ expect("coalesces concurrent misses for one key", calls === 1 && results.every((item) => item === 1), `expected one loader run, observed ${calls}`);
182
+ }),
183
+ ]);
184
+ }
185
+ /** Runs every conformance check and returns the failures, if any. */
186
+ export async function runCacheBackendConformance(createBackend) {
187
+ const results = [];
188
+ for (const check of cacheBackendConformance(createBackend)) {
189
+ try {
190
+ await check.run();
191
+ results.push({ name: check.name });
192
+ }
193
+ catch (error) {
194
+ results.push({ name: check.name, error: error });
195
+ }
196
+ }
197
+ return Object.freeze(results);
198
+ }
199
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],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CAAC,CAAC;QACrC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAc,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ export { type CacheConformanceCheck, CacheConformanceError, cacheBackendConformance, createInMemoryCacheBackend, type InMemoryCacheBackend, type InMemoryCacheBackendOptions, runCacheBackendConformance, } from "./cache.js";
2
+ export { createInMemoryJobBackend, createInMemoryLockProvider, type InMemoryDrainResult, type InMemoryJobBackend, type InMemoryJobBackendOptions, type InMemoryJobSchedule, type InMemoryLockProvider, nextOccurrence, type RunJobOnceOptions, runJobOnce, } from "./jobs.js";
3
+ export { type ConformanceBackendOptions, type ConformanceTestApi, conformanceJobs, type JobBackendConformanceOptions, jobBackendConformance, } from "./jobs-conformance.js";
4
+ export { createInMemoryIdempotencyStore, createInMemoryOutbox, type DrainOutboxOptions, drainOutbox, type InMemoryIdempotencyStore, type InMemoryOutbox, } from "./outbox.js";
5
+ export { type ParityCheck, type ParityFixture, type ParityResult, parseParityFixtures, type RequestableApp, runParityFixture, } from "./parity.js";
6
+ export { createPostgresTestPool, type PostgresTestDb, setupPostgresTestDb, truncateAll, } from "./postgres.js";
7
+ export { type CollectedPublishes, type ConformanceTest, collectPublishes, conformanceChannels, conformanceTenantScopes, createInMemoryRealtimeBackend, drainRealtimePublications, type InMemoryRealtimeBackend, type InMemoryRealtimeBackendOptions, type RealtimeConformanceOptions, type RealtimePublication, realtimeBackendConformance, } from "./realtime.js";
8
+ export { createInMemoryWebhookEventStore, type FakeWebhookProvider, type FakeWebhookProviderOptions, type FakeWebhookSignature, fakeWebhookProvider, type InMemoryWebhookEventStore, type InMemoryWebhookEventStoreOptions, } from "./webhooks.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAC1B,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAChC,0BAA0B,GAC3B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,cAAc,EACd,KAAK,iBAAiB,EACtB,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,eAAe,EACf,KAAK,4BAA4B,EACjC,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,8BAA8B,EAC9B,oBAAoB,EACpB,KAAK,kBAAkB,EACvB,WAAW,EACX,KAAK,wBAAwB,EAC7B,KAAK,cAAc,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,mBAAmB,EACnB,KAAK,cAAc,EACnB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,EACtB,KAAK,cAAc,EACnB,mBAAmB,EACnB,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,6BAA6B,EAC7B,yBAAyB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACnC,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,+BAA+B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,mBAAmB,EACnB,KAAK,yBAAyB,EAC9B,KAAK,gCAAgC,GACtC,MAAM,eAAe,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export { CacheConformanceError, cacheBackendConformance, createInMemoryCacheBackend, runCacheBackendConformance, } from "./cache.js";
2
+ export { createInMemoryJobBackend, createInMemoryLockProvider, nextOccurrence, runJobOnce, } from "./jobs.js";
3
+ export { conformanceJobs, jobBackendConformance, } from "./jobs-conformance.js";
4
+ export { createInMemoryIdempotencyStore, createInMemoryOutbox, drainOutbox, } from "./outbox.js";
5
+ export { parseParityFixtures, runParityFixture, } from "./parity.js";
6
+ export { createPostgresTestPool, setupPostgresTestDb, truncateAll, } from "./postgres.js";
7
+ export { collectPublishes, conformanceChannels, conformanceTenantScopes, createInMemoryRealtimeBackend, drainRealtimePublications, realtimeBackendConformance, } from "./realtime.js";
8
+ export { createInMemoryWebhookEventStore, fakeWebhookProvider, } from "./webhooks.js";
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAG1B,0BAA0B,GAC3B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAM1B,cAAc,EAEd,UAAU,GACX,MAAM,WAAW,CAAC;AACnB,OAAO,EAGL,eAAe,EAEf,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,8BAA8B,EAC9B,oBAAoB,EAEpB,WAAW,GAGZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAIL,mBAAmB,EAEnB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,EAEtB,mBAAmB,EACnB,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,6BAA6B,EAC7B,yBAAyB,EAKzB,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,+BAA+B,EAI/B,mBAAmB,GAGpB,MAAM,eAAe,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { JobBackend, JobRuntimeDeclaration } from "@sixthsummit/ship-core";
2
+ /** The minimal test-runner surface the conformance suite needs (Vitest satisfies it). */
3
+ export interface ConformanceTestApi {
4
+ describe(name: string, body: () => void): void;
5
+ it(name: string, body: () => Promise<void> | void, timeout?: number): void;
6
+ beforeEach(body: () => Promise<void> | void, timeout?: number): void;
7
+ afterEach(body: () => Promise<void> | void, timeout?: number): void;
8
+ expect: (value: unknown) => {
9
+ toBe(expected: unknown): void;
10
+ toEqual(expected: unknown): void;
11
+ toMatchObject(expected: object): void;
12
+ toBeGreaterThanOrEqual(expected: number): void;
13
+ toHaveLength(expected: number): void;
14
+ toBeUndefined(): void;
15
+ };
16
+ }
17
+ export interface ConformanceBackendOptions {
18
+ readonly maxQueueDepth: number;
19
+ readonly maxInFlight: number;
20
+ }
21
+ export interface JobBackendConformanceOptions {
22
+ /** Upper bound on waiting for a backend to reach a state, in milliseconds. */
23
+ readonly timeoutMs?: number;
24
+ /** Per-test timeout passed to the runner. */
25
+ readonly testTimeoutMs?: number;
26
+ }
27
+ /** Job declarations every conformance run attaches; retention is short so cleanup is observable. */
28
+ export declare function conformanceJobs(): readonly JobRuntimeDeclaration[];
29
+ /**
30
+ * Shared behavioral contract for `JobBackend` adapters. The in-memory backend
31
+ * and `@sixthsummit/ship-jobs-bullmq` both run it. `createBackend` receives the
32
+ * budget the suite expects and must return a fresh, unattached backend.
33
+ */
34
+ export declare function jobBackendConformance(name: string, createBackend: (options: ConformanceBackendOptions) => Promise<JobBackend> | JobBackend, test: ConformanceTestApi, options?: JobBackendConformanceOptions): void;
35
+ //# s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