@astram/engine 0.7.0 → 0.8.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/dist/adapters/mariadb-audit-sink.d.ts +10 -1
- package/dist/adapters/mariadb-audit-sink.d.ts.map +1 -1
- package/dist/adapters/mariadb-audit-sink.js +8 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -11
- package/dist/module/engine.module.d.ts +8 -0
- package/dist/module/engine.module.d.ts.map +1 -1
- package/dist/module/engine.module.js +7 -4
- package/dist/registry.d.ts +25 -2
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +62 -2
- package/dist/types.d.ts +21 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +17 -1
- package/package.json +2 -2
|
@@ -9,15 +9,24 @@
|
|
|
9
9
|
* resolves ids to labels (no raw ids to end users). Sensitive values are never put
|
|
10
10
|
* in the event by the pipe (the audit stage carries only op + typeKey attributes).
|
|
11
11
|
*/
|
|
12
|
+
import { type FrameworkSchemas } from '@astram/core';
|
|
12
13
|
import type { AuditEvent, AuditPort, QueryFn } from '../ports.js';
|
|
13
14
|
export interface AuditSinkConfig {
|
|
14
|
-
/** Schema holding the audit_log table
|
|
15
|
+
/** Schema holding the audit_log table. Wins over `schemas`. */
|
|
15
16
|
readonly schema?: string;
|
|
17
|
+
/** Resolved framework names; the sink uses `schemas.audit` when `schema` is absent. */
|
|
18
|
+
readonly schemas?: Pick<FrameworkSchemas, 'audit'>;
|
|
16
19
|
/** Table name (default audit_log). */
|
|
17
20
|
readonly table?: string;
|
|
18
21
|
}
|
|
19
22
|
export declare class MariaDbAuditSink implements AuditPort {
|
|
20
23
|
private readonly ref;
|
|
24
|
+
/**
|
|
25
|
+
* Default schema (configurable-framework-db, spec 5.B): `config.schema`, else
|
|
26
|
+
* `config.schemas.audit`, else the audit name resolved from `SHIELD_DB_NAMESPACE` once, here at
|
|
27
|
+
* construction (boot), never per event. Unset namespace ⇒ today's default audit database. An
|
|
28
|
+
* invalid namespace throws (fail closed).
|
|
29
|
+
*/
|
|
21
30
|
constructor(config?: AuditSinkConfig);
|
|
22
31
|
record(event: AuditEvent, query: QueryFn): Promise<void>;
|
|
23
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mariadb-audit-sink.d.ts","sourceRoot":"","sources":["../../src/adapters/mariadb-audit-sink.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAElE,MAAM,WAAW,eAAe;IAC9B
|
|
1
|
+
{"version":3,"file":"mariadb-audit-sink.d.ts","sourceRoot":"","sources":["../../src/adapters/mariadb-audit-sink.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAA2B,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAElE,MAAM,WAAW,eAAe;IAC9B,+DAA+D;IAC/D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,uFAAuF;IACvF,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACnD,sCAAsC;IACtC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,gBAAiB,YAAW,SAAS;IAChD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAE7B;;;;;OAKG;gBACS,MAAM,GAAE,eAAoB;IAOlC,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAmB/D"}
|
|
@@ -13,10 +13,17 @@
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.MariaDbAuditSink = void 0;
|
|
15
15
|
const node_crypto_1 = require("node:crypto");
|
|
16
|
+
const core_1 = require("@astram/core");
|
|
16
17
|
class MariaDbAuditSink {
|
|
17
18
|
ref;
|
|
19
|
+
/**
|
|
20
|
+
* Default schema (configurable-framework-db, spec 5.B): `config.schema`, else
|
|
21
|
+
* `config.schemas.audit`, else the audit name resolved from `SHIELD_DB_NAMESPACE` once, here at
|
|
22
|
+
* construction (boot), never per event. Unset namespace ⇒ today's default audit database. An
|
|
23
|
+
* invalid namespace throws (fail closed).
|
|
24
|
+
*/
|
|
18
25
|
constructor(config = {}) {
|
|
19
|
-
const schema = config.schema ??
|
|
26
|
+
const schema = config.schema ?? config.schemas?.audit ?? (0, core_1.resolveFrameworkSchemas)(process.env).audit;
|
|
20
27
|
const table = config.table ?? 'audit_log';
|
|
21
28
|
this.ref = `\`${schema}\`.\`${table}\``;
|
|
22
29
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
*/
|
|
20
20
|
export type { RecordEngine, AccessDeclaration, FieldSpec, FieldType, TrustedSource, IdentityRole, PkStrategy, JunctionSpec, RecordInput, RecordId, RecordView, ListQuery, FilterOperator, FilterValue, WhereClause, SearchQuery, RecordPage, AggregateFn, AggregateMeasure, AggregateQuery, AggregateGroup, AggregateResult, Principal, ReadScope, ReadScopeCreateMode, } from './types.js';
|
|
21
21
|
export { READ_SCOPE_NODES_TOKEN } from './types.js';
|
|
22
|
+
export { FRAMEWORK_SCHEMA } from './types.js';
|
|
23
|
+
export { resolveObjectTypeSchema, type FrameworkSchemaNames } from './registry.js';
|
|
22
24
|
export { canonicalUuid } from './uuid.js';
|
|
23
25
|
export { EngineError, CapabilityNotSupportedError, RegistrationError, AuthorizationDeniedError, ValidationError, EngineUnavailableError, } from './errors.js';
|
|
24
26
|
export { ObjectType, Field, PrimaryKey, reflectObjectType, type ObjectTypeOptions, type FieldOptions, type PrimaryKeyOptions, } from './decorators/object-type.decorator.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,SAAS,EACT,aAAa,EACb,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,UAAU,EACV,SAAS,EACT,cAAc,EACd,WAAW,EACX,WAAW,EACX,WAAW,EACX,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,eAAe,EACf,SAAS,EACT,SAAS,EACT,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAKpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,SAAS,EACT,SAAS,EACT,aAAa,EACb,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,UAAU,EACV,SAAS,EACT,cAAc,EACd,WAAW,EACX,WAAW,EACX,WAAW,EACX,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,eAAe,EACf,SAAS,EACT,SAAS,EACT,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAKpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAMpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAKnF,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EACL,WAAW,EACX,2BAA2B,EAC3B,iBAAiB,EACjB,wBAAwB,EACxB,eAAe,EACf,sBAAsB,GACvB,MAAM,aAAa,CAAC;AAiBrB,OAAO,EACL,UAAU,EACV,KAAK,EACL,UAAU,EACV,iBAAiB,EACjB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,iBAAiB,GACvB,MAAM,uCAAuC,CAAC;AAO/C,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,GACtB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EACL,YAAY,EACZ,aAAa,EACb,wBAAwB,EACxB,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,KAAK,eAAe,GACrB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,OAAO,EACP,WAAW,EACX,cAAc,EACd,aAAa,EACb,WAAW,EACX,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAClF,OAAO,EACL,cAAc,EACd,YAAY,EACZ,KAAK,sBAAsB,EAC3B,wBAAwB,GACzB,MAAM,2BAA2B,CAAC;AAGnC,YAAY,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAC1F,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC/E,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -19,12 +19,20 @@
|
|
|
19
19
|
* `@astram/engine/internal`, which only the composition root may import.
|
|
20
20
|
*/
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.MariaDbAuditSink = exports.SERVICE_ACCOUNT_RESOLVER = exports.BoundRecords = exports.RecordsService = exports.RecordEngineImpl = exports.effectiveActions = exports.requireRole = exports.columnForRole = exports.tenantColumnOf = exports.ownerColumn = exports.isOwned = exports.uuidPkColumn = exports.columnOf = exports.TableRegistry = exports.ENGINE_ALL_ACCESS_BUNDLES = exports.ENGINE_ALL_REGISTRATIONS = exports.RECORD_ENGINE = exports.EngineModule = exports.reflectAccessBundle = exports.AccessBundle = exports.reflectObjectType = exports.PrimaryKey = exports.Field = exports.ObjectType = exports.EngineUnavailableError = exports.ValidationError = exports.AuthorizationDeniedError = exports.RegistrationError = exports.CapabilityNotSupportedError = exports.EngineError = exports.canonicalUuid = exports.READ_SCOPE_NODES_TOKEN = void 0;
|
|
22
|
+
exports.MariaDbAuditSink = exports.SERVICE_ACCOUNT_RESOLVER = exports.BoundRecords = exports.RecordsService = exports.RecordEngineImpl = exports.effectiveActions = exports.requireRole = exports.columnForRole = exports.tenantColumnOf = exports.ownerColumn = exports.isOwned = exports.uuidPkColumn = exports.columnOf = exports.TableRegistry = exports.ENGINE_ALL_ACCESS_BUNDLES = exports.ENGINE_ALL_REGISTRATIONS = exports.RECORD_ENGINE = exports.EngineModule = exports.reflectAccessBundle = exports.AccessBundle = exports.reflectObjectType = exports.PrimaryKey = exports.Field = exports.ObjectType = exports.EngineUnavailableError = exports.ValidationError = exports.AuthorizationDeniedError = exports.RegistrationError = exports.CapabilityNotSupportedError = exports.EngineError = exports.canonicalUuid = exports.resolveObjectTypeSchema = exports.FRAMEWORK_SCHEMA = exports.READ_SCOPE_NODES_TOKEN = void 0;
|
|
23
23
|
// The read-scope subtree-id placeholder token (ADR-0027) — a `subtreeSubquery` template
|
|
24
24
|
// uses it; the engine expands it to a `?`-list. Exported so per-type declarations can
|
|
25
25
|
// reference the canonical token (rather than a stringly-typed duplicate).
|
|
26
26
|
var types_js_1 = require("./types.js");
|
|
27
27
|
Object.defineProperty(exports, "READ_SCOPE_NODES_TOKEN", { enumerable: true, get: function () { return types_js_1.READ_SCOPE_NODES_TOKEN; } });
|
|
28
|
+
// Framework database placeholder tokens (configurable-framework-db, ADR-0037): a framework object
|
|
29
|
+
// type declares `schema: FRAMEWORK_SCHEMA.app` (and may use the tokens in `readScope.subquerySql`);
|
|
30
|
+
// the engine resolves them at registration. Any other reader of an object type's schema calls
|
|
31
|
+
// `resolveObjectTypeSchema(reg, schemas)` before building SQL; an unresolved token throws.
|
|
32
|
+
var types_js_2 = require("./types.js");
|
|
33
|
+
Object.defineProperty(exports, "FRAMEWORK_SCHEMA", { enumerable: true, get: function () { return types_js_2.FRAMEWORK_SCHEMA; } });
|
|
34
|
+
var registry_js_1 = require("./registry.js");
|
|
35
|
+
Object.defineProperty(exports, "resolveObjectTypeSchema", { enumerable: true, get: function () { return registry_js_1.resolveObjectTypeSchema; } });
|
|
28
36
|
// The ONE uuid canonicaliser (Phase 11 #1): strict 8-4-4-4-12 ASCII hex, returned lower-cased;
|
|
29
37
|
// anything else (padded, fullwidth, ...) is null. Guard's `UuidPipe` and the identity body checks
|
|
30
38
|
// use it; consumers may too.
|
|
@@ -71,16 +79,16 @@ Object.defineProperty(exports, "RECORD_ENGINE", { enumerable: true, get: functio
|
|
|
71
79
|
Object.defineProperty(exports, "ENGINE_ALL_REGISTRATIONS", { enumerable: true, get: function () { return engine_module_js_1.ENGINE_ALL_REGISTRATIONS; } });
|
|
72
80
|
Object.defineProperty(exports, "ENGINE_ALL_ACCESS_BUNDLES", { enumerable: true, get: function () { return engine_module_js_1.ENGINE_ALL_ACCESS_BUNDLES; } });
|
|
73
81
|
// --- Framework-facing (composition + tests; NOT for feature code) ------------
|
|
74
|
-
var
|
|
75
|
-
Object.defineProperty(exports, "TableRegistry", { enumerable: true, get: function () { return
|
|
76
|
-
Object.defineProperty(exports, "columnOf", { enumerable: true, get: function () { return
|
|
77
|
-
Object.defineProperty(exports, "uuidPkColumn", { enumerable: true, get: function () { return
|
|
78
|
-
Object.defineProperty(exports, "isOwned", { enumerable: true, get: function () { return
|
|
79
|
-
Object.defineProperty(exports, "ownerColumn", { enumerable: true, get: function () { return
|
|
80
|
-
Object.defineProperty(exports, "tenantColumnOf", { enumerable: true, get: function () { return
|
|
81
|
-
Object.defineProperty(exports, "columnForRole", { enumerable: true, get: function () { return
|
|
82
|
-
Object.defineProperty(exports, "requireRole", { enumerable: true, get: function () { return
|
|
83
|
-
Object.defineProperty(exports, "effectiveActions", { enumerable: true, get: function () { return
|
|
82
|
+
var registry_js_2 = require("./registry.js");
|
|
83
|
+
Object.defineProperty(exports, "TableRegistry", { enumerable: true, get: function () { return registry_js_2.TableRegistry; } });
|
|
84
|
+
Object.defineProperty(exports, "columnOf", { enumerable: true, get: function () { return registry_js_2.columnOf; } });
|
|
85
|
+
Object.defineProperty(exports, "uuidPkColumn", { enumerable: true, get: function () { return registry_js_2.uuidPkColumn; } });
|
|
86
|
+
Object.defineProperty(exports, "isOwned", { enumerable: true, get: function () { return registry_js_2.isOwned; } });
|
|
87
|
+
Object.defineProperty(exports, "ownerColumn", { enumerable: true, get: function () { return registry_js_2.ownerColumn; } });
|
|
88
|
+
Object.defineProperty(exports, "tenantColumnOf", { enumerable: true, get: function () { return registry_js_2.tenantColumnOf; } });
|
|
89
|
+
Object.defineProperty(exports, "columnForRole", { enumerable: true, get: function () { return registry_js_2.columnForRole; } });
|
|
90
|
+
Object.defineProperty(exports, "requireRole", { enumerable: true, get: function () { return registry_js_2.requireRole; } });
|
|
91
|
+
Object.defineProperty(exports, "effectiveActions", { enumerable: true, get: function () { return registry_js_2.effectiveActions; } });
|
|
84
92
|
var record_engine_js_1 = require("./pipe/record-engine.js");
|
|
85
93
|
Object.defineProperty(exports, "RecordEngineImpl", { enumerable: true, get: function () { return record_engine_js_1.RecordEngineImpl; } });
|
|
86
94
|
var records_service_js_1 = require("./pipe/records-service.js");
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* Registrations are code-registered tables loaded at boot.
|
|
19
19
|
*/
|
|
20
20
|
import { type DynamicModule } from '@nestjs/common';
|
|
21
|
+
import { type FrameworkSchemas } from '@astram/core';
|
|
21
22
|
import type { QueryFn } from '../ports.js';
|
|
22
23
|
import { RECORD_ENGINE } from './tokens.js';
|
|
23
24
|
import { type EngineDbConfig } from '../adapters/mariadb-unit-of-work.js';
|
|
@@ -56,6 +57,13 @@ export interface EngineModuleOptions {
|
|
|
56
57
|
* feature module; anything passed here is merged as a base contribution. */
|
|
57
58
|
readonly registrations?: readonly ObjectTypeInput[];
|
|
58
59
|
readonly audit?: AuditSinkConfig;
|
|
60
|
+
/**
|
|
61
|
+
* OPTIONAL resolved framework database names (configurable-framework-db, ADR-0037).
|
|
62
|
+
* `FRAMEWORK_SCHEMA` tokens in registrations resolve to these, and the default audit sink
|
|
63
|
+
* writes to `schemas.audit`. Absent ⇒ resolved once from `SHIELD_DB_NAMESPACE` when
|
|
64
|
+
* `forRoot` is called (unset ⇒ today's names; invalid ⇒ throws, fail closed).
|
|
65
|
+
*/
|
|
66
|
+
readonly schemas?: FrameworkSchemas;
|
|
59
67
|
/** Test seam: a deterministic clock. */
|
|
60
68
|
readonly nowMs?: () => number;
|
|
61
69
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.module.d.ts","sourceRoot":"","sources":["../../src/module/engine.module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAEL,KAAK,aAAa,EAKnB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"engine.module.d.ts","sourceRoot":"","sources":["../../src/module/engine.module.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAEL,KAAK,aAAa,EAKnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAuC,OAAO,EAAE,MAAM,aAAa,CAAC;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AM,CAAC;QAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAA;KAAE,CAAC,CAAC;CAC3D;AAYD,qBACa,YAAY;IACvB;;;;;;;;;OASG;IACH,MAAM,CAAC,UAAU,CACf,aAAa,EAAE,SAAS,eAAe,EAAE,EACzC,IAAI,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,SAAS,CAAC,gBAAgB,GAAG,QAAQ,CAAC,EAAE,CAAA;KAAE,GAClE,aAAa;IAMhB;2FACuF;IACvF,MAAM,CAAC,aAAa,IAAI,IAAI;IAK5B,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,mBAAmB,GAAG,aAAa;CAqG5D"}
|
|
@@ -136,12 +136,15 @@ let EngineModule = EngineModule_1 = class EngineModule {
|
|
|
136
136
|
...featureRegistrations.flat(),
|
|
137
137
|
...(options.registrations ?? []),
|
|
138
138
|
].map(toObjectType);
|
|
139
|
-
// The
|
|
140
|
-
//
|
|
139
|
+
// The framework database names, resolved ONCE here (boot) and captured: registration
|
|
140
|
+
// tokens and the default audit sink use them; nothing reads env per request (Shield #12).
|
|
141
|
+
const schemas = options.schemas ?? (0, core_1.resolveFrameworkSchemas)(process.env);
|
|
142
|
+
// The registry is built from the merged set — same register() per registration (just from
|
|
143
|
+
// the collected set, not options only); `FRAMEWORK_SCHEMA` tokens resolve at register.
|
|
141
144
|
const registryProvider = {
|
|
142
145
|
provide: ENGINE_REGISTRY,
|
|
143
146
|
useFactory: () => {
|
|
144
|
-
const registry = new registry_js_1.TableRegistry();
|
|
147
|
+
const registry = new registry_js_1.TableRegistry(schemas);
|
|
145
148
|
for (const reg of allRegistrations)
|
|
146
149
|
registry.register(reg);
|
|
147
150
|
return registry;
|
|
@@ -169,7 +172,7 @@ let EngineModule = EngineModule_1 = class EngineModule {
|
|
|
169
172
|
};
|
|
170
173
|
const auditProvider = {
|
|
171
174
|
provide: ENGINE_AUDIT,
|
|
172
|
-
useFactory: () => new mariadb_audit_sink_js_1.MariaDbAuditSink(options.audit
|
|
175
|
+
useFactory: () => new mariadb_audit_sink_js_1.MariaDbAuditSink({ schemas, ...options.audit }),
|
|
173
176
|
};
|
|
174
177
|
const engineProvider = {
|
|
175
178
|
provide: tokens_js_1.RECORD_ENGINE,
|
package/dist/registry.d.ts
CHANGED
|
@@ -8,11 +8,34 @@
|
|
|
8
8
|
* Runtime-registered (no-code) tables will register through the SAME registry later
|
|
9
9
|
* (the no-code phase); the pipe does not distinguish how a registration arrived.
|
|
10
10
|
*/
|
|
11
|
+
import { type FrameworkSchemas } from '@astram/core';
|
|
11
12
|
import type { FieldSpec, PkStrategy, ObjectType, Principal } from './types.js';
|
|
13
|
+
/** The four resolved names `resolveObjectTypeSchema` needs (a core `FrameworkSchemas` fits). */
|
|
14
|
+
export type FrameworkSchemaNames = Pick<FrameworkSchemas, 'app' | 'identity' | 'authz' | 'audit'>;
|
|
15
|
+
/**
|
|
16
|
+
* Return `reg` with every {@link FRAMEWORK_SCHEMA} token in `schema` and
|
|
17
|
+
* `readScope.subquerySql` replaced by the resolved name (configurable-framework-db, spec 5.B).
|
|
18
|
+
* Pure: the input is not mutated. A literal schema or an absent one is returned unchanged.
|
|
19
|
+
*
|
|
20
|
+
* FAIL CLOSED (Shield #1): throws a `RegistrationError` when `schemas` is absent but a token is
|
|
21
|
+
* used, when a used token's resolved name is missing or not a plain identifier, or when any
|
|
22
|
+
* token-like text survives resolution. Every reader of an object type's schema outside the
|
|
23
|
+
* registry must call this before building SQL.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveObjectTypeSchema(reg: ObjectType, schemas: FrameworkSchemaNames | undefined): ObjectType;
|
|
12
26
|
export declare class TableRegistry {
|
|
27
|
+
private readonly schemas?;
|
|
13
28
|
private readonly byType;
|
|
14
|
-
/**
|
|
15
|
-
|
|
29
|
+
/**
|
|
30
|
+
* @param schemas the resolved framework database names `FRAMEWORK_SCHEMA` tokens resolve to.
|
|
31
|
+
* Absent ⇒ a registration that uses a token fails (fail closed); others are unaffected.
|
|
32
|
+
*/
|
|
33
|
+
constructor(schemas?: FrameworkSchemaNames | undefined);
|
|
34
|
+
/**
|
|
35
|
+
* Register a table. Resolves `FRAMEWORK_SCHEMA` tokens first (an unresolved token throws),
|
|
36
|
+
* then throws on a duplicate typeKey or an invalid registration.
|
|
37
|
+
*/
|
|
38
|
+
register(input: ObjectType): void;
|
|
16
39
|
/** Resolve a registration, or throw a RegistrationError if unknown. */
|
|
17
40
|
require(typeKey: string): ObjectType;
|
|
18
41
|
has(typeKey: string): boolean;
|
package/dist/registry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOrE,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE/E,gGAAgG;AAChG,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,gBAAgB,EAAE,KAAK,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC;AAOlG;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,oBAAoB,GAAG,SAAS,GACxC,UAAU,CAuCZ;AAED,qBAAa,aAAa;IAOZ,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IANrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;IAExD;;;OAGG;gBAC0B,OAAO,CAAC,EAAE,oBAAoB,YAAA;IAE3D;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IASjC,uEAAuE;IACvE,OAAO,CAAC,OAAO,EAAE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CAAC;AAgEF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,iBAAiB,GAAG,SAAS,MAAM,EAAE,CAI1E"}
|
package/dist/registry.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.TableRegistry = void 0;
|
|
14
|
+
exports.resolveObjectTypeSchema = resolveObjectTypeSchema;
|
|
14
15
|
exports.columnOf = columnOf;
|
|
15
16
|
exports.uuidPkColumn = uuidPkColumn;
|
|
16
17
|
exports.isOwned = isOwned;
|
|
@@ -24,10 +25,69 @@ exports.effectiveActions = effectiveActions;
|
|
|
24
25
|
const core_1 = require("@astram/core");
|
|
25
26
|
const errors_js_1 = require("./errors.js");
|
|
26
27
|
const types_js_1 = require("./types.js");
|
|
28
|
+
/** A resolved database name: unquoted identifier, MariaDB's 64-character limit. */
|
|
29
|
+
const RESOLVED_SCHEMA_NAME = /^[a-z][a-z0-9_]{0,63}$/;
|
|
30
|
+
const SCHEMA_KEYS = ['app', 'identity', 'authz', 'audit'];
|
|
31
|
+
/**
|
|
32
|
+
* Return `reg` with every {@link FRAMEWORK_SCHEMA} token in `schema` and
|
|
33
|
+
* `readScope.subquerySql` replaced by the resolved name (configurable-framework-db, spec 5.B).
|
|
34
|
+
* Pure: the input is not mutated. A literal schema or an absent one is returned unchanged.
|
|
35
|
+
*
|
|
36
|
+
* FAIL CLOSED (Shield #1): throws a `RegistrationError` when `schemas` is absent but a token is
|
|
37
|
+
* used, when a used token's resolved name is missing or not a plain identifier, or when any
|
|
38
|
+
* token-like text survives resolution. Every reader of an object type's schema outside the
|
|
39
|
+
* registry must call this before building SQL.
|
|
40
|
+
*/
|
|
41
|
+
function resolveObjectTypeSchema(reg, schemas) {
|
|
42
|
+
const usesToken = (text) => text !== undefined && text.includes(types_js_1.FRAMEWORK_SCHEMA_TOKEN_MARKER);
|
|
43
|
+
const subquerySql = reg.readScope?.kind === 'subtreeSubquery' ? reg.readScope.subquerySql : undefined;
|
|
44
|
+
if (!usesToken(reg.schema) && !usesToken(subquerySql))
|
|
45
|
+
return reg;
|
|
46
|
+
const nameFor = (key) => {
|
|
47
|
+
const name = schemas?.[key];
|
|
48
|
+
if (typeof name !== 'string' || !RESOLVED_SCHEMA_NAME.test(name)) {
|
|
49
|
+
throw new errors_js_1.RegistrationError(`registration '${reg.typeKey}': framework schema '${key}' is not resolved; ` +
|
|
50
|
+
`the engine needs the resolved framework database names (SHIELD_DB_NAMESPACE).`);
|
|
51
|
+
}
|
|
52
|
+
return name;
|
|
53
|
+
};
|
|
54
|
+
const leftover = (where) => new errors_js_1.RegistrationError(`registration '${reg.typeKey}': unresolved framework schema token in ${where}.`);
|
|
55
|
+
let out = reg;
|
|
56
|
+
if (usesToken(reg.schema)) {
|
|
57
|
+
// The schema is exactly one token, never a token inside a longer name.
|
|
58
|
+
const key = SCHEMA_KEYS.find((k) => types_js_1.FRAMEWORK_SCHEMA[k] === reg.schema);
|
|
59
|
+
if (key === undefined)
|
|
60
|
+
throw leftover('schema');
|
|
61
|
+
out = { ...out, schema: nameFor(key) };
|
|
62
|
+
}
|
|
63
|
+
if (usesToken(subquerySql) && reg.readScope?.kind === 'subtreeSubquery') {
|
|
64
|
+
let sql = reg.readScope.subquerySql;
|
|
65
|
+
for (const key of SCHEMA_KEYS) {
|
|
66
|
+
if (sql.includes(types_js_1.FRAMEWORK_SCHEMA[key]))
|
|
67
|
+
sql = sql.split(types_js_1.FRAMEWORK_SCHEMA[key]).join(nameFor(key));
|
|
68
|
+
}
|
|
69
|
+
if (usesToken(sql))
|
|
70
|
+
throw leftover('readScope.subquerySql');
|
|
71
|
+
out = { ...out, readScope: { ...reg.readScope, subquerySql: sql } };
|
|
72
|
+
}
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
27
75
|
class TableRegistry {
|
|
76
|
+
schemas;
|
|
28
77
|
byType = new Map();
|
|
29
|
-
/**
|
|
30
|
-
|
|
78
|
+
/**
|
|
79
|
+
* @param schemas the resolved framework database names `FRAMEWORK_SCHEMA` tokens resolve to.
|
|
80
|
+
* Absent ⇒ a registration that uses a token fails (fail closed); others are unaffected.
|
|
81
|
+
*/
|
|
82
|
+
constructor(schemas) {
|
|
83
|
+
this.schemas = schemas;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Register a table. Resolves `FRAMEWORK_SCHEMA` tokens first (an unresolved token throws),
|
|
87
|
+
* then throws on a duplicate typeKey or an invalid registration.
|
|
88
|
+
*/
|
|
89
|
+
register(input) {
|
|
90
|
+
const reg = resolveObjectTypeSchema(input, this.schemas);
|
|
31
91
|
validate(reg);
|
|
32
92
|
if (this.byType.has(reg.typeKey)) {
|
|
33
93
|
throw new errors_js_1.RegistrationError(`duplicate table registration for typeKey '${reg.typeKey}'`);
|
package/dist/types.d.ts
CHANGED
|
@@ -164,6 +164,22 @@ export type ReadScope = {
|
|
|
164
164
|
export type ReadScopeCreateMode = 'walled' | 'unscoped';
|
|
165
165
|
/** The token a `subtreeSubquery` template uses for the engine-expanded subtree id list. */
|
|
166
166
|
export declare const READ_SCOPE_NODES_TOKEN = ":nodes";
|
|
167
|
+
/** The marker every {@link FRAMEWORK_SCHEMA} token starts with (leftover detection). */
|
|
168
|
+
export declare const FRAMEWORK_SCHEMA_TOKEN_MARKER = "{{framework_schema:";
|
|
169
|
+
/**
|
|
170
|
+
* Placeholder tokens for the four framework databases (configurable-framework-db, ADR-0037).
|
|
171
|
+
* A framework object type declares `@ObjectType({ schema: FRAMEWORK_SCHEMA.app })` (and may use
|
|
172
|
+
* the tokens inside `readScope.subquerySql`) so object files never read env at import time. The
|
|
173
|
+
* engine replaces each token with the resolved name (`<namespace>_app`, ...) at registration via
|
|
174
|
+
* `resolveObjectTypeSchema`; a token left unresolved fails registration (fail closed) and never
|
|
175
|
+
* reaches SQL. Token text contains no backtick and is never a valid database name.
|
|
176
|
+
*/
|
|
177
|
+
export declare const FRAMEWORK_SCHEMA: Readonly<{
|
|
178
|
+
readonly app: "{{framework_schema:app}}";
|
|
179
|
+
readonly identity: "{{framework_schema:identity}}";
|
|
180
|
+
readonly authz: "{{framework_schema:authz}}";
|
|
181
|
+
readonly audit: "{{framework_schema:audit}}";
|
|
182
|
+
}>;
|
|
167
183
|
/** Primary-key strategy for a registered table. */
|
|
168
184
|
export type PkStrategy = {
|
|
169
185
|
readonly kind: 'uuid';
|
|
@@ -191,7 +207,11 @@ export interface ObjectType {
|
|
|
191
207
|
readonly typeKey: string;
|
|
192
208
|
/** Physical table name. */
|
|
193
209
|
readonly table: string;
|
|
194
|
-
/**
|
|
210
|
+
/**
|
|
211
|
+
* Schema/database the table lives in, or a {@link FRAMEWORK_SCHEMA} token resolved at
|
|
212
|
+
* registration. Absent ⇒ the table name is unqualified and resolves against the pool's
|
|
213
|
+
* default database (the `database` of the engine's `db` config).
|
|
214
|
+
*/
|
|
195
215
|
readonly schema?: string;
|
|
196
216
|
readonly primaryKey: PkStrategy;
|
|
197
217
|
readonly fields: readonly FieldSpec[];
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/D,iFAAiF;AACjF,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;AAExF,qDAAqD;AACrD,MAAM,WAAW,SAAS;IACxB,yEAAyE;IACzE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,CAA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AAE,QAAQ,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9E;;;;;;;;;OASG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1F;;;;OAIG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC9F;;;;;;;OAOG;IACH,UAAU,CACR,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,SAAS,WAAW,EAAE,EAC9B,KAAK,EAAE,SAAS,GACf,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;CACxB;AAED,YAAY,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -13,6 +13,22 @@
|
|
|
13
13
|
* surface.
|
|
14
14
|
*/
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.READ_SCOPE_NODES_TOKEN = void 0;
|
|
16
|
+
exports.FRAMEWORK_SCHEMA = exports.FRAMEWORK_SCHEMA_TOKEN_MARKER = exports.READ_SCOPE_NODES_TOKEN = void 0;
|
|
17
17
|
/** The token a `subtreeSubquery` template uses for the engine-expanded subtree id list. */
|
|
18
18
|
exports.READ_SCOPE_NODES_TOKEN = ':nodes';
|
|
19
|
+
/** The marker every {@link FRAMEWORK_SCHEMA} token starts with (leftover detection). */
|
|
20
|
+
exports.FRAMEWORK_SCHEMA_TOKEN_MARKER = '{{framework_schema:';
|
|
21
|
+
/**
|
|
22
|
+
* Placeholder tokens for the four framework databases (configurable-framework-db, ADR-0037).
|
|
23
|
+
* A framework object type declares `@ObjectType({ schema: FRAMEWORK_SCHEMA.app })` (and may use
|
|
24
|
+
* the tokens inside `readScope.subquerySql`) so object files never read env at import time. The
|
|
25
|
+
* engine replaces each token with the resolved name (`<namespace>_app`, ...) at registration via
|
|
26
|
+
* `resolveObjectTypeSchema`; a token left unresolved fails registration (fail closed) and never
|
|
27
|
+
* reaches SQL. Token text contains no backtick and is never a valid database name.
|
|
28
|
+
*/
|
|
29
|
+
exports.FRAMEWORK_SCHEMA = Object.freeze({
|
|
30
|
+
app: '{{framework_schema:app}}',
|
|
31
|
+
identity: '{{framework_schema:identity}}',
|
|
32
|
+
authz: '{{framework_schema:authz}}',
|
|
33
|
+
audit: '{{framework_schema:audit}}',
|
|
34
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astram/engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Astram framework — the paved road. ONE unbypassable write pipe (resolve-schema → permission gate → derive-write-context → validate → compute → write → junction-sync → audit → emit-event) over real physical tables, that every feature's CRUD flows through. Feature code receives ONLY the RecordEngine facade — never a raw pool/DataSource/QueryRunner (the physical wall). Security-gate + audit are mandatory stages. Missing capability → a typed CapabilityNotSupportedError (the gap-flag STOP). Builds on @astram/core (metadata contract, decide(), audit) + @astram/guard (decision authority).",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"mariadb": "^3.5.4",
|
|
35
|
-
"@astram/core": "1.
|
|
35
|
+
"@astram/core": "1.7.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@nestjs/common": "^11",
|