@saasicat/persistence-testing 1.0.0-rc.18 → 1.0.0-rc.19

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/dist/.build-stamp CHANGED
@@ -1 +1 @@
1
- ec457c9ef09c51121503a82c971c3de2ba82aead3348d11c442cc6018f83d99e
1
+ 0823f760e2b950bba7dbba20644e8a504d1b17e2432a66e8266dc0e594fdad6f
package/dist/index.cjs CHANGED
@@ -2185,6 +2185,83 @@ function persistenceAdapterContract(options) {
2185
2185
  "the contract followed a correction of the live record"
2186
2186
  );
2187
2187
  });
2188
+ (0, import_node_test.test)("the contracts still running say which issuer each names", async (t) => {
2189
+ const { adapter } = harness;
2190
+ const contracts = adapter.subscriptionContractRepository;
2191
+ const createSubscriber = harness.seed.createSubscriber;
2192
+ if (!contracts || !createSubscriber) {
2193
+ missing(t, "subscriptionContracts");
2194
+ return;
2195
+ }
2196
+ const { subscriberId } = await createSubscriber({ legalName: "Meier GmbH" });
2197
+ const parties = partiesWith(subscriberId, "Meier GmbH");
2198
+ const written = async (offerId, overrides) => contracts.create({ ...contractFromOffer(offerId, parties), ...overrides });
2199
+ const oldest = await written("running-oldest", {
2200
+ effectiveFrom: /* @__PURE__ */ new Date("2026-01-01T00:00:00.000Z")
2201
+ });
2202
+ const scheduled = await written("running-scheduled", {
2203
+ effectiveFrom: /* @__PURE__ */ new Date("2026-02-01T00:00:00.000Z"),
2204
+ status: "scheduled"
2205
+ });
2206
+ const lapsed = await written("running-lapsed", {
2207
+ effectiveFrom: /* @__PURE__ */ new Date("2026-03-01T00:00:00.000Z"),
2208
+ effectiveUntil: /* @__PURE__ */ new Date("2026-04-01T00:00:00.000Z")
2209
+ });
2210
+ const ending = await written("running-ending", {
2211
+ effectiveFrom: /* @__PURE__ */ new Date("2026-04-01T00:00:00.000Z"),
2212
+ effectiveUntil: /* @__PURE__ */ new Date("2026-12-01T00:00:00.000Z")
2213
+ });
2214
+ const noIssuer = await written("running-no-issuer", {
2215
+ effectiveFrom: /* @__PURE__ */ new Date("2026-05-01T00:00:00.000Z"),
2216
+ parties: { ...parties, issuer: null }
2217
+ });
2218
+ await written("running-terminated", {
2219
+ effectiveFrom: /* @__PURE__ */ new Date("2025-01-01T00:00:00.000Z"),
2220
+ status: "terminated"
2221
+ });
2222
+ await written("running-superseded", {
2223
+ effectiveFrom: /* @__PURE__ */ new Date("2025-02-01T00:00:00.000Z"),
2224
+ status: "superseded"
2225
+ });
2226
+ const asOf = /* @__PURE__ */ new Date("2026-06-01T00:00:00.000Z");
2227
+ const listed = await contracts.listRunningIssuers(10, asOf);
2228
+ import_strict.default.equal(listed.total, 4, "a contract that ended or was ended is not running");
2229
+ import_strict.default.deepEqual(
2230
+ listed.contracts.map((row) => row.id),
2231
+ [oldest.id, scheduled.id, ending.id, noIssuer.id],
2232
+ "oldest first, and the one whose term ran out is not among them"
2233
+ );
2234
+ import_strict.default.ok(
2235
+ !listed.contracts.some((row) => row.id === lapsed.id),
2236
+ "a window that closed ends a contract, whatever its status still says"
2237
+ );
2238
+ const earlier = await contracts.listRunningIssuers(
2239
+ 10,
2240
+ /* @__PURE__ */ new Date("2026-03-15T00:00:00.000Z")
2241
+ );
2242
+ import_strict.default.equal(earlier.total, 5);
2243
+ import_strict.default.ok(earlier.contracts.some((row) => row.id === lapsed.id));
2244
+ import_strict.default.equal(listed.contracts[0].tenantId, oldest.tenantId);
2245
+ import_strict.default.equal(
2246
+ listed.contracts[0].effectiveFrom.getTime(),
2247
+ (/* @__PURE__ */ new Date("2026-01-01T00:00:00.000Z")).getTime()
2248
+ );
2249
+ import_strict.default.equal(listed.contracts[0].issuerLegalName, "Example Software GmbH");
2250
+ import_strict.default.equal(
2251
+ listed.contracts[3].issuerLegalName,
2252
+ null,
2253
+ "a contract with no issuer copy says so rather than inventing one"
2254
+ );
2255
+ const capped = await contracts.listRunningIssuers(2, asOf);
2256
+ import_strict.default.equal(capped.total, 4, "the limit caps the list, not the count");
2257
+ import_strict.default.deepEqual(
2258
+ capped.contracts.map((row) => row.id),
2259
+ [oldest.id, scheduled.id]
2260
+ );
2261
+ const counted = await contracts.listRunningIssuers(0, asOf);
2262
+ import_strict.default.equal(counted.total, 4);
2263
+ import_strict.default.deepEqual(counted.contracts, []);
2264
+ });
2188
2265
  (0, import_node_test.test)("a gateway event is claimed once per account, and a duplicate leaves the transaction usable", async (t) => {
2189
2266
  const { adapter } = harness;
2190
2267
  const log = adapter.paymentEventLog;
package/dist/index.js CHANGED
@@ -2149,6 +2149,83 @@ function persistenceAdapterContract(options) {
2149
2149
  "the contract followed a correction of the live record"
2150
2150
  );
2151
2151
  });
2152
+ test("the contracts still running say which issuer each names", async (t) => {
2153
+ const { adapter } = harness;
2154
+ const contracts = adapter.subscriptionContractRepository;
2155
+ const createSubscriber = harness.seed.createSubscriber;
2156
+ if (!contracts || !createSubscriber) {
2157
+ missing(t, "subscriptionContracts");
2158
+ return;
2159
+ }
2160
+ const { subscriberId } = await createSubscriber({ legalName: "Meier GmbH" });
2161
+ const parties = partiesWith(subscriberId, "Meier GmbH");
2162
+ const written = async (offerId, overrides) => contracts.create({ ...contractFromOffer(offerId, parties), ...overrides });
2163
+ const oldest = await written("running-oldest", {
2164
+ effectiveFrom: /* @__PURE__ */ new Date("2026-01-01T00:00:00.000Z")
2165
+ });
2166
+ const scheduled = await written("running-scheduled", {
2167
+ effectiveFrom: /* @__PURE__ */ new Date("2026-02-01T00:00:00.000Z"),
2168
+ status: "scheduled"
2169
+ });
2170
+ const lapsed = await written("running-lapsed", {
2171
+ effectiveFrom: /* @__PURE__ */ new Date("2026-03-01T00:00:00.000Z"),
2172
+ effectiveUntil: /* @__PURE__ */ new Date("2026-04-01T00:00:00.000Z")
2173
+ });
2174
+ const ending = await written("running-ending", {
2175
+ effectiveFrom: /* @__PURE__ */ new Date("2026-04-01T00:00:00.000Z"),
2176
+ effectiveUntil: /* @__PURE__ */ new Date("2026-12-01T00:00:00.000Z")
2177
+ });
2178
+ const noIssuer = await written("running-no-issuer", {
2179
+ effectiveFrom: /* @__PURE__ */ new Date("2026-05-01T00:00:00.000Z"),
2180
+ parties: { ...parties, issuer: null }
2181
+ });
2182
+ await written("running-terminated", {
2183
+ effectiveFrom: /* @__PURE__ */ new Date("2025-01-01T00:00:00.000Z"),
2184
+ status: "terminated"
2185
+ });
2186
+ await written("running-superseded", {
2187
+ effectiveFrom: /* @__PURE__ */ new Date("2025-02-01T00:00:00.000Z"),
2188
+ status: "superseded"
2189
+ });
2190
+ const asOf = /* @__PURE__ */ new Date("2026-06-01T00:00:00.000Z");
2191
+ const listed = await contracts.listRunningIssuers(10, asOf);
2192
+ assert.equal(listed.total, 4, "a contract that ended or was ended is not running");
2193
+ assert.deepEqual(
2194
+ listed.contracts.map((row) => row.id),
2195
+ [oldest.id, scheduled.id, ending.id, noIssuer.id],
2196
+ "oldest first, and the one whose term ran out is not among them"
2197
+ );
2198
+ assert.ok(
2199
+ !listed.contracts.some((row) => row.id === lapsed.id),
2200
+ "a window that closed ends a contract, whatever its status still says"
2201
+ );
2202
+ const earlier = await contracts.listRunningIssuers(
2203
+ 10,
2204
+ /* @__PURE__ */ new Date("2026-03-15T00:00:00.000Z")
2205
+ );
2206
+ assert.equal(earlier.total, 5);
2207
+ assert.ok(earlier.contracts.some((row) => row.id === lapsed.id));
2208
+ assert.equal(listed.contracts[0].tenantId, oldest.tenantId);
2209
+ assert.equal(
2210
+ listed.contracts[0].effectiveFrom.getTime(),
2211
+ (/* @__PURE__ */ new Date("2026-01-01T00:00:00.000Z")).getTime()
2212
+ );
2213
+ assert.equal(listed.contracts[0].issuerLegalName, "Example Software GmbH");
2214
+ assert.equal(
2215
+ listed.contracts[3].issuerLegalName,
2216
+ null,
2217
+ "a contract with no issuer copy says so rather than inventing one"
2218
+ );
2219
+ const capped = await contracts.listRunningIssuers(2, asOf);
2220
+ assert.equal(capped.total, 4, "the limit caps the list, not the count");
2221
+ assert.deepEqual(
2222
+ capped.contracts.map((row) => row.id),
2223
+ [oldest.id, scheduled.id]
2224
+ );
2225
+ const counted = await contracts.listRunningIssuers(0, asOf);
2226
+ assert.equal(counted.total, 4);
2227
+ assert.deepEqual(counted.contracts, []);
2228
+ });
2152
2229
  test("a gateway event is claimed once per account, and a duplicate leaves the transaction usable", async (t) => {
2153
2230
  const { adapter } = harness;
2154
2231
  const log = adapter.paymentEventLog;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saasicat/persistence-testing",
3
- "version": "1.0.0-rc.18",
3
+ "version": "1.0.0-rc.19",
4
4
  "description": "Contract test kit for SaaSiCat persistence adapters: one node:test suite that every adapter (Prisma, Drizzle, ...) must pass against a real database — locks, transaction rollback, atomic promo claims, tenant isolation, audit/MFA roundtrips.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -23,7 +23,7 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@saasicat/core": "^1.0.0-rc.18"
26
+ "@saasicat/core": "^1.0.0-rc.19"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^25.6.0",