@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.
- package/CHANGELOG.md +69 -0
- package/README.md +65 -3
- package/dist/events/emit.d.mts +22 -0
- package/dist/events/emit.mjs +105 -0
- package/dist/events/index.d.mts +3 -0
- package/dist/events/index.mjs +2 -0
- package/dist/events/types.d.mts +73 -0
- package/dist/filter/from-record.d.mts +13 -0
- package/dist/filter/from-record.mjs +135 -0
- package/dist/filter/index.d.mts +2 -1
- package/dist/filter/index.mjs +2 -1
- package/dist/hooks/priority.d.mts +7 -1
- package/dist/hooks/priority.mjs +1 -0
- package/dist/repository/base.d.mts +32 -0
- package/dist/repository/base.mjs +25 -0
- package/dist/repository/capabilities.d.mts +159 -0
- package/dist/repository/index.d.mts +5 -2
- package/dist/repository/index.mjs +3 -1
- package/dist/repository/options.d.mts +5 -1
- package/dist/repository/options.mjs +6 -1
- package/dist/repository/purge.d.mts +57 -0
- package/dist/repository/purge.mjs +83 -0
- package/dist/repository/resilience.d.mts +55 -0
- package/dist/repository/resilience.mjs +39 -0
- package/dist/repository/types.d.mts +243 -1
- package/dist/schema/index.d.mts +2 -1
- package/dist/schema/index.mjs +2 -1
- package/dist/schema/standard-schema.d.mts +89 -0
- package/dist/schema/standard-schema.mjs +59 -0
- package/dist/testing/conformance.mjs +144 -0
- package/dist/testing/index.d.mts +2 -1
- package/dist/testing/types.d.mts +12 -105
- package/package.json +5 -1
package/dist/testing/types.d.mts
CHANGED
|
@@ -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-
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
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
|
-
* **
|
|
38
|
-
*
|
|
39
|
-
*
|
|
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
|
-
|
|
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 {
|
|
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.
|
|
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"
|