@classytic/supplier-performance 0.2.1 → 0.3.1
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 +86 -69
- package/dist/index.js +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,72 +1,89 @@
|
|
|
1
|
-
# Changelog
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.3.1] — 2026-07-16
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
### Fixed
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
- injectTenantField no longer force-indexes the tenant field: the compound
|
|
8
|
+
prepend makes the tenant the leading key of every index, so the bare single
|
|
9
|
+
was a redundant prefix paid on every insert (PACKAGE_RULES P11.1, fleet
|
|
10
|
+
index audit). A dedicated tenant index is still created when a schema
|
|
11
|
+
declares no compounds to prepend. Index-declaration change only.
|
|
6
12
|
|
|
7
|
-
## 0.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
###
|
|
24
|
-
|
|
25
|
-
- **
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
`
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- **
|
|
49
|
-
`
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
13
|
+
## [0.3.0] — unpublished (2026-07-15)
|
|
14
|
+
|
|
15
|
+
### Changed — kit refresh (peer floors: mongokit >=3.22.0, repo-core >=0.13.0, primitives >=0.11.0)
|
|
16
|
+
|
|
17
|
+
- Verified clean against the mongokit 3.22 sweep (no FSM boilerplate, no
|
|
18
|
+
fences needed). Clean registry install; suite green.
|
|
19
|
+
|
|
20
|
+
## 0.2.1
|
|
21
|
+
|
|
22
|
+
Patch — outbox support, §P8.1 session guard, awaited publish, tenant-isolation fix.
|
|
23
|
+
|
|
24
|
+
## 0.2.0
|
|
25
|
+
|
|
26
|
+
Stack upgrade + tenant-isolation fix + PACKAGE_RULES compliance + real test
|
|
27
|
+
coverage. No new features.
|
|
28
|
+
|
|
29
|
+
### Fixed (security)
|
|
30
|
+
|
|
31
|
+
- **Cross-tenant leak — `multiTenantPlugin` was never wired.** Both
|
|
32
|
+
repositories were constructed with only `methodRegistryPlugin()`, so reads
|
|
33
|
+
and writes were NOT tenant-scoped despite the schema carrying an
|
|
34
|
+
`organizationId` field. The engine now derives one resolved tenant config
|
|
35
|
+
(via repo-core's `resolveTenantConfig`) and wires `multiTenantPlugin` on
|
|
36
|
+
every repo — scoping is enforced at POLICY priority and missing
|
|
37
|
+
`organizationId` throws (fail-closed). A `tenant-plugin-probe` integration
|
|
38
|
+
test plus an end-to-end isolation test guard this.
|
|
39
|
+
|
|
40
|
+
### Changed (breaking)
|
|
41
|
+
|
|
42
|
+
- **Peers:** `@classytic/mongokit` `>=3.13.0` → `>=3.16.0`; **added**
|
|
43
|
+
`@classytic/repo-core >=0.6.0` (rule 11 — the code imports
|
|
44
|
+
`@classytic/repo-core/tenant` and `/errors`); **added** `zod >=4.0.0`
|
|
45
|
+
(event catalog). `@classytic/primitives` stays `>=0.5.0` (devDep bumped to
|
|
46
|
+
`^0.7.2`).
|
|
47
|
+
- **Tenant config clean break.** Dropped the legacy
|
|
48
|
+
`{ tenantFieldType, multiTenant }` shape and the `'string'` default. Tenant
|
|
49
|
+
config is now a repo-core `TenantConfig` (or boolean), defaulting to
|
|
50
|
+
repo-core's standard `fieldType: 'objectId'`, `required: true`. Hosts with
|
|
51
|
+
string/UUID org ids pass `{ fieldType: 'string' }`. Mongokit-runtime knobs
|
|
52
|
+
(`skipWhen`, `resolveContext`, `allowDataInjection`, `onMismatch`,
|
|
53
|
+
`skipOperations`) forward through the `tenant` object.
|
|
54
|
+
- **Errors.** Removed `RecordEventValidationError extends Error`. Validation now
|
|
55
|
+
throws `SupplierPerformanceValidationError implements HttpError` (status 400,
|
|
56
|
+
code `supplier_performance.validation.invalid_input`) so arc serializes it
|
|
57
|
+
correctly.
|
|
58
|
+
|
|
59
|
+
### Added
|
|
60
|
+
|
|
61
|
+
- **Zod event catalog (rule 18):** `supplierPerformanceEventDefinitions`
|
|
62
|
+
exported from the package root AND the new `./events` subpath; per-event Zod
|
|
63
|
+
schemas (`z.iso.datetime()` timestamps), a no-drift invariant test, and
|
|
64
|
+
safeParse happy/rejection tests.
|
|
65
|
+
- **Cancellation / retry threading:** `SupplierPerformanceContext` now carries
|
|
66
|
+
`signal` / `retryPolicy`, forwarded to repo calls via `repoOptionsFromCtx`.
|
|
67
|
+
- **Test coverage** raised from one unit file to five files / 21 tests:
|
|
68
|
+
event-catalog no-drift, tenant probe + isolation, computeScore aggregation +
|
|
69
|
+
idempotency (re-run does not double-aggregate, exactly one snapshot row),
|
|
70
|
+
model-collision policy.
|
|
71
|
+
|
|
72
|
+
### Build hygiene
|
|
73
|
+
|
|
74
|
+
- `tsconfig.json`: enabled `exactOptionalPropertyTypes`; disabled
|
|
75
|
+
`declarationMap` and `sourceMap` (no source leaks). `InProcessSupplierPerformanceBus`
|
|
76
|
+
gained `close()`. `CHANGELOG.md` added to published `files`.
|
|
77
|
+
|
|
78
|
+
### Notes (verified, intentionally NOT changed)
|
|
79
|
+
|
|
80
|
+
- **No outbox / P8 dispatch machinery.** Durable delivery is host-composed
|
|
81
|
+
(§5.5 / §16); only a transport is wired, so publish failures are swallowed
|
|
82
|
+
(rule 14). Not a gap.
|
|
83
|
+
- **No capabilities boot gate.** The package uses no transactions — every verb
|
|
84
|
+
is a single-doc read/write/upsert — so the gate (transactions-only) does not
|
|
85
|
+
apply.
|
|
86
|
+
- **No rating-state CAS.** Scorecards are recomputable snapshots, not a state
|
|
87
|
+
machine; `computeScore` idempotency rests on the unique index + upsert.
|
|
88
|
+
- **`recordEvent` dedup stays host-owned** by design (hosts key differently:
|
|
89
|
+
PO-line vs PO+SKU). The kernel does not enforce a metric-dedup unique index.
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,6 @@ function injectTenantField(schema, tenant) {
|
|
|
32
32
|
schema.add({ [tenant.tenantField]: {
|
|
33
33
|
type: isObjectId ? mongoose.Schema.Types.ObjectId : String,
|
|
34
34
|
...tenant.enabled && tenant.required ? { required: true } : {},
|
|
35
|
-
index: true,
|
|
36
35
|
...isObjectId && tenant.ref ? { ref: tenant.ref } : {}
|
|
37
36
|
} });
|
|
38
37
|
if (!tenant.enabled || !isFieldStrategy) return;
|
|
@@ -44,6 +43,7 @@ function injectTenantField(schema, tenant) {
|
|
|
44
43
|
for (const [key, val] of Object.entries(fields)) newFields[key] = val;
|
|
45
44
|
indexEntry[0] = newFields;
|
|
46
45
|
}
|
|
46
|
+
if (!(existingIndexes ?? []).some(([fields]) => Object.keys(fields)[0] === tenant.tenantField)) schema.index({ [tenant.tenantField]: 1 });
|
|
47
47
|
}
|
|
48
48
|
//#endregion
|
|
49
49
|
//#region src/models/performance-event.model.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@classytic/supplier-performance",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Framework-agnostic supplier performance engine — on-time-delivery, defect, and price-variance tracking with append-only event log + cached scorecards. Powered by MongoDB via @classytic/mongokit. Zero framework deps — usable from Arc, Express, Nest, Next.js, or raw Node.",
|
|
5
5
|
"author": "Classytic",
|
|
6
6
|
"license": "MIT",
|
|
@@ -60,17 +60,17 @@
|
|
|
60
60
|
"release": "npm run push -- main && npm run release:tag && npm publish"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@classytic/mongokit": ">=3.
|
|
64
|
-
"@classytic/repo-core": ">=0.
|
|
65
|
-
"@classytic/primitives": ">=0.
|
|
63
|
+
"@classytic/mongokit": ">=3.22.0",
|
|
64
|
+
"@classytic/repo-core": ">=0.13.0",
|
|
65
|
+
"@classytic/primitives": ">=0.11.0",
|
|
66
66
|
"mongoose": ">=9.4.1",
|
|
67
67
|
"zod": ">=4.0.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@classytic/dev-tools": "^0.2.0",
|
|
71
|
-
"@classytic/mongokit": "
|
|
72
|
-
"@classytic/repo-core": "
|
|
73
|
-
"@classytic/primitives": "^0.
|
|
71
|
+
"@classytic/mongokit": "^3.22.1",
|
|
72
|
+
"@classytic/repo-core": "^0.13.0",
|
|
73
|
+
"@classytic/primitives": "^0.11.0",
|
|
74
74
|
"@types/node": "^25.5.0",
|
|
75
75
|
"mongodb-memory-server": "^10.2.3",
|
|
76
76
|
"mongoose": "^9.4.1",
|