@classytic/repo-core 0.4.2 → 0.6.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.
@@ -1,3 +1,4 @@
1
+ import { AggregateOpsSupport, RepoCapabilities } from "../repository/capabilities.mjs";
1
2
  import { MinimalRepo, StandardRepo } from "../repository/types.mjs";
2
3
 
3
4
  //#region src/testing/types.d.ts
@@ -27,112 +28,18 @@ interface ConformanceDoc {
27
28
  createdAt: string;
28
29
  }
29
30
  /**
30
- * Per-aggregate-op support matrix. Some aggregate ops aren't
31
- * portable across every backend `percentile` requires Mongo 7+'s
32
- * `$percentile` accumulator or SQL's `PERCENTILE_CONT`, neither of
33
- * which sqlitekit ships. Scenarios that exercise a non-universal
34
- * op gate on the matching flag and `it.skip` on the off branch so
35
- * the suite runs cleanly across every environment.
31
+ * Per-backend feature flags an alias of the runtime
32
+ * {@link RepoCapabilities} descriptor (one shape, no drift). Scenarios
33
+ * that exercise a non-universal capability (transactions in D1, upsert
34
+ * in narrow stores) check the flag and `it.skip` on the off branch — so
35
+ * the suite runs on every environment without "optional test failed"
36
+ * noise.
36
37
  *
37
- * **Stability contract.** Adding a flag here is additive — kits
38
- * that don't declare the new key default to `false`, which is the
39
- * conservative choice. Renaming or removing a flag is a breaking
40
- * change.
41
- *
42
- * **Naming convention.** Flag names match the IR field they gate
43
- * (`percentile` → `AggMeasure.op === 'percentile'`). When in doubt,
44
- * grep the IR types and use the same identifier.
45
- */
46
- interface AggregateOpsSupport {
47
- /**
48
- * `{ op: 'percentile', field, p }` measure. Mongokit (Mongo 7+)
49
- * supports it; sqlitekit throws by design (no native function).
50
- * Hosts targeting percentile dashboards pin to a kit that supports it.
51
- */
52
- percentile?: boolean;
53
- /**
54
- * `{ op: 'stddev', field }` / `{ op: 'stddevPop', field }` measures.
55
- * Mongokit supports both via native `$stdDevSamp` / `$stdDevPop`
56
- * (Welford). Sqlitekit throws — SQLite has no native STDDEV and
57
- * the computational formula is numerically unstable. Hosts pin
58
- * to mongokit / future pgkit when stddev is load-bearing.
59
- */
60
- stddev?: boolean;
61
- /**
62
- * `topN: { partitionBy, sortBy, limit, ties }` filter. Both
63
- * mongokit and sqlitekit support it as of repo-core 0.4.x; the
64
- * flag exists for future kits that may not ship window-function
65
- * equivalents.
66
- */
67
- topN?: boolean;
68
- /**
69
- * `dateBuckets: { ..., interval: { every, unit } }` custom-bin
70
- * form. Kits that only support named-bucket form can leave this
71
- * `false`; tests for `'minute'` / `'hour'` named intervals are
72
- * gated separately via `dateBucketSubMinute`.
73
- */
74
- customDateBuckets?: boolean;
75
- /**
76
- * Sub-day-granularity named buckets (`'minute'` / `'hour'`).
77
- * Older kits may only support day+ named intervals; flag exists
78
- * to gate those scenarios cleanly.
79
- */
80
- dateBucketSubMinute?: boolean;
81
- /**
82
- * Per-request `cache?: AggCacheOptions` slot — TTL / tags / SWR /
83
- * bypass / `repo.invalidateAggregateCache(tags)`. Both mongokit
84
- * and sqlitekit support it as of repo-core 0.4.x. Future kits
85
- * without the wiring can leave this false to skip cache scenarios.
86
- *
87
- * Independent of which CACHE BACKEND the harness wires — test
88
- * scenarios construct their own `createMemoryCacheAdapter()` so
89
- * this flag is purely "does the kit honour the request slot".
90
- */
91
- cache?: boolean;
92
- }
93
- /**
94
- * Per-backend feature flags. Scenarios that exercise a non-universal
95
- * capability (transactions in D1, upsert in narrow stores) check the
96
- * flag and `it.skip` on the off branch — so the suite runs on every
97
- * environment without "optional test failed" noise.
38
+ * **Single source of truth.** Kits declare `repo.capabilities` at
39
+ * runtime and pass the SAME object as the harness's `features` what a
40
+ * kit claims to support is exactly what the conformance suite verifies.
98
41
  */
99
- interface ConformanceFeatures {
100
- /** `withTransaction(fn)` — D1 throws, standalone Mongo throws 263. */
101
- transactions: boolean;
102
- /**
103
- * True if calling `withTransaction` inside another `withTransaction`
104
- * callback is expected to work. Mongo's driver supports it via the
105
- * same session; SQL drivers typically reject it. Either behavior is
106
- * valid — the scenario asserts whichever the harness declares.
107
- */
108
- nestedTransactions: boolean;
109
- /** `findOneAndUpdate` with upsert: true. */
110
- upsert: boolean;
111
- /** `isDuplicateKeyError(err)` classifier. */
112
- duplicateKeyError: boolean;
113
- /** `distinct(field)`. */
114
- distinct: boolean;
115
- /**
116
- * Portable `aggregate({ measures, groupBy, having })`. Coarse
117
- * top-level flag — gates the entire `describe('aggregate')` block.
118
- * Per-op flags live on `aggregateOps` for asymmetric capabilities
119
- * (percentile, custom date bins, etc.) that some kits skip while
120
- * still supporting the core aggregate surface.
121
- */
122
- aggregate: boolean;
123
- /**
124
- * Per-op feature matrix for the aggregate surface. Optional —
125
- * absent matrix or absent key both mean "not supported", so kits
126
- * opt INTO scenarios for ops they implement. This avoids the
127
- * trap where a future kit silently fails percentile tests because
128
- * it forgot to set the flag.
129
- */
130
- aggregateOps?: AggregateOpsSupport;
131
- /** `getOrCreate(filter, data)`. */
132
- getOrCreate: boolean;
133
- /** `count(filter)` and `exists(filter)`. */
134
- countAndExists: boolean;
135
- }
42
+ type ConformanceFeatures = RepoCapabilities;
136
43
  /**
137
44
  * One-shot context produced by `harness.setup()`. Scenarios receive a
138
45
  * fresh context per test — the harness is responsible for isolation
@@ -207,4 +114,4 @@ interface ConformanceHarness<TDoc extends ConformanceDoc = ConformanceDoc> {
207
114
  makeDoc(overrides?: Partial<ConformanceDoc>): Partial<TDoc>;
208
115
  }
209
116
  //#endregion
210
- export { AggregateOpsSupport, ConformanceContext, ConformanceDoc, ConformanceFeatures, ConformanceHarness };
117
+ export { ConformanceContext, ConformanceDoc, ConformanceFeatures, ConformanceHarness };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classytic/repo-core",
3
- "version": "0.4.2",
3
+ "version": "0.6.0",
4
4
  "description": "Driver-agnostic repository primitives: hooks, Filter IR, operations, pagination, cache contract. Foundation for mongokit, sqlitekit, pgkit, and prismakit. Lean by design — no plugins ship here; each kit owns its own.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -54,6 +54,10 @@
54
54
  "types": "./dist/cache/index.d.mts",
55
55
  "default": "./dist/cache/index.mjs"
56
56
  },
57
+ "./events": {
58
+ "types": "./dist/events/index.d.mts",
59
+ "default": "./dist/events/index.mjs"
60
+ },
57
61
  "./schema": {
58
62
  "types": "./dist/schema/index.d.mts",
59
63
  "default": "./dist/schema/index.mjs"