@astram/engine 0.3.0 → 0.5.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/decorators/access-bundle.decorator.d.ts.map +1 -1
- package/dist/decorators/object-type.decorator.d.ts +2 -0
- package/dist/decorators/object-type.decorator.d.ts.map +1 -1
- package/dist/decorators/object-type.decorator.js +3 -0
- package/dist/index.d.ts +8 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/internal.d.ts +10 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +13 -0
- package/dist/pipe/context.d.ts +17 -6
- package/dist/pipe/context.d.ts.map +1 -1
- package/dist/pipe/record-engine.d.ts +38 -5
- package/dist/pipe/record-engine.d.ts.map +1 -1
- package/dist/pipe/record-engine.js +210 -75
- package/dist/pipe/records-service.d.ts +18 -1
- package/dist/pipe/records-service.d.ts.map +1 -1
- package/dist/pipe/records-service.js +42 -6
- package/dist/pipe/stages/audit.d.ts.map +1 -1
- package/dist/pipe/stages/derive-write-context.d.ts.map +1 -1
- package/dist/pipe/stages/derive-write-context.js +6 -0
- package/dist/pipe/stages/fetch-record.d.ts +56 -0
- package/dist/pipe/stages/fetch-record.d.ts.map +1 -0
- package/dist/pipe/stages/fetch-record.js +103 -0
- package/dist/pipe/stages/permission-gate.d.ts +29 -0
- package/dist/pipe/stages/permission-gate.d.ts.map +1 -1
- package/dist/pipe/stages/permission-gate.js +80 -22
- package/dist/pipe/stages/write.d.ts.map +1 -1
- package/dist/pipe/stages/write.js +75 -52
- package/dist/pipe/where-by-id.d.ts +33 -0
- package/dist/pipe/where-by-id.d.ts.map +1 -0
- package/dist/pipe/where-by-id.js +69 -0
- package/dist/registry.d.ts +8 -1
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +25 -1
- package/dist/types.d.ts +59 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +13 -2
- package/dist/adapters/mariadb-audit-sink.js.map +0 -1
- package/dist/adapters/mariadb-unit-of-work.js.map +0 -1
- package/dist/decorators/access-bundle.decorator.js.map +0 -1
- package/dist/decorators/object-type.decorator.js.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/module/engine.module.js.map +0 -1
- package/dist/module/tokens.js.map +0 -1
- package/dist/pipe/context.js.map +0 -1
- package/dist/pipe/record-engine.js.map +0 -1
- package/dist/pipe/records-service.js.map +0 -1
- package/dist/pipe/stages/audit.js.map +0 -1
- package/dist/pipe/stages/derive-write-context.js.map +0 -1
- package/dist/pipe/stages/fetch-owner.d.ts +0 -28
- package/dist/pipe/stages/fetch-owner.d.ts.map +0 -1
- package/dist/pipe/stages/fetch-owner.js +0 -99
- package/dist/pipe/stages/fetch-owner.js.map +0 -1
- package/dist/pipe/stages/junction-sync.js.map +0 -1
- package/dist/pipe/stages/permission-gate.js.map +0 -1
- package/dist/pipe/stages/validate.js.map +0 -1
- package/dist/pipe/stages/write.js.map +0 -1
- package/dist/ports.js.map +0 -1
- package/dist/registry.js.map +0 -1
- package/dist/types.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"access-bundle.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/access-bundle.decorator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,kBAAkB,CAAC;AAW1B;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAED,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,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AAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5C;AAID;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,mBAAmB,GAAG,cAAc,CAItE;AAID;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,QAAQ,GAAG,gBAAgB,CA8BnE"}
|
|
@@ -59,6 +59,8 @@ export interface FieldOptions {
|
|
|
59
59
|
readonly required?: boolean;
|
|
60
60
|
readonly trusted?: TrustedSource;
|
|
61
61
|
readonly role?: IdentityRole;
|
|
62
|
+
/** Create-only (ADR-0034): ignored on update. See `FieldSpec.immutable`. */
|
|
63
|
+
readonly immutable?: boolean;
|
|
62
64
|
}
|
|
63
65
|
/**
|
|
64
66
|
* `@PrimaryKey` options — the {@link PkStrategy} discriminated union verbatim, so it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-type.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/object-type.decorator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,kBAAkB,CAAC;AAG1B,OAAO,KAAK,EACV,iBAAiB,EAEjB,SAAS,EACT,YAAY,EACZ,YAAY,EAKZ,UAAU,IAAI,kBAAkB,EAChC,UAAU,EACV,SAAS,EACT,aAAa,EACd,MAAM,aAAa,CAAC;AAarB;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC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AAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IAC7C;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;CAChC;AAED,wFAAwF;AACxF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC;IAC7B,4EAA4E;IAC5E,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAI3C;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,iBAAiB,GAAG,cAAc,CAIlE;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,UAAW,SAAQ,kBAAkB;CAAG;AAEzD;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,iBAAiB,CAO3D;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,iBAAiB,GAAG,cAAc,CAIlE;AAuBD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,QAAQ,GAAG,kBAAkB,CA+BnE"}
|
|
@@ -103,6 +103,9 @@ function reflectField(spec) {
|
|
|
103
103
|
f.trusted = spec.trusted;
|
|
104
104
|
if (spec.role !== undefined)
|
|
105
105
|
f.role = spec.role;
|
|
106
|
+
// Reflected AS-IS when present (a non-boolean is rejected by the registry at boot).
|
|
107
|
+
if (spec.immutable !== undefined)
|
|
108
|
+
f.immutable = spec.immutable;
|
|
106
109
|
return f;
|
|
107
110
|
}
|
|
108
111
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -11,11 +11,13 @@
|
|
|
11
11
|
*
|
|
12
12
|
* FRAMEWORK-FACING (composition/tests; a FEATURE must NOT import these — the app's
|
|
13
13
|
* architectural lint rule blocks raw DB access under src/features/**):
|
|
14
|
-
* - the
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* - the `MariaDbAuditSink` adapter, the `RecordEngineImpl`, the `TableRegistry`, and the
|
|
15
|
+
* ports. Exported so the framework + integration tests can compose the engine
|
|
16
|
+
* directly; NOT for feature code.
|
|
17
|
+
* - The raw unit of work (`MariaDbUnitOfWork`, it owns a pool) is NOT here: it is on
|
|
18
|
+
* `@astram/engine/internal`, which only the composition root may import.
|
|
17
19
|
*/
|
|
18
|
-
export type { RecordEngine, AccessDeclaration, FieldSpec, FieldType, TrustedSource, IdentityRole, PkStrategy, JunctionSpec, RecordInput, RecordId, RecordView, ListQuery, RecordPage, Principal, ReadScope, } from './types.js';
|
|
20
|
+
export type { RecordEngine, AccessDeclaration, FieldSpec, FieldType, TrustedSource, IdentityRole, PkStrategy, JunctionSpec, RecordInput, RecordId, RecordView, ListQuery, RecordPage, Principal, ReadScope, ReadScopeCreateMode, } from './types.js';
|
|
19
21
|
export { READ_SCOPE_NODES_TOKEN } from './types.js';
|
|
20
22
|
export { EngineError, CapabilityNotSupportedError, RegistrationError, AuthorizationDeniedError, ValidationError, EngineUnavailableError, } from './errors.js';
|
|
21
23
|
export { ObjectType, Field, PrimaryKey, reflectObjectType, type ObjectTypeOptions, type FieldOptions, type PrimaryKeyOptions, } from './decorators/object-type.decorator.js';
|
|
@@ -24,8 +26,8 @@ export { EngineModule, RECORD_ENGINE, ENGINE_ALL_REGISTRATIONS, ENGINE_ALL_ACCES
|
|
|
24
26
|
export { TableRegistry, columnOf, uuidPkColumn, isOwned, ownerColumn, tenantColumnOf, columnForRole, requireRole, } from './registry.js';
|
|
25
27
|
export { RecordEngineImpl, type RecordEngineDeps } from './pipe/record-engine.js';
|
|
26
28
|
export { RecordsService, BoundRecords, type ServiceAccountResolver, SERVICE_ACCOUNT_RESOLVER, } from './pipe/records-service.js';
|
|
27
|
-
export {
|
|
29
|
+
export type { EngineDbConfig } from './adapters/mariadb-unit-of-work.js';
|
|
28
30
|
export { MariaDbAuditSink, type AuditSinkConfig } from './adapters/mariadb-audit-sink.js';
|
|
29
|
-
export type { QueryFn, UnitOfWork, DecisionPort, AuditPort
|
|
31
|
+
export type { QueryFn, UnitOfWork, DecisionPort, AuditPort } from './ports.js';
|
|
30
32
|
export type { Stage, WriteContext, WriteOp, PipeBase } from './pipe/context.js';
|
|
31
33
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
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,UAAU,EACV,SAAS,EACT,SAAS,EACT,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAKpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD,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,GACZ,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
|
@@ -12,12 +12,14 @@
|
|
|
12
12
|
*
|
|
13
13
|
* FRAMEWORK-FACING (composition/tests; a FEATURE must NOT import these — the app's
|
|
14
14
|
* architectural lint rule blocks raw DB access under src/features/**):
|
|
15
|
-
* - the
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* - the `MariaDbAuditSink` adapter, the `RecordEngineImpl`, the `TableRegistry`, and the
|
|
16
|
+
* ports. Exported so the framework + integration tests can compose the engine
|
|
17
|
+
* directly; NOT for feature code.
|
|
18
|
+
* - The raw unit of work (`MariaDbUnitOfWork`, it owns a pool) is NOT here: it is on
|
|
19
|
+
* `@astram/engine/internal`, which only the composition root may import.
|
|
18
20
|
*/
|
|
19
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.MariaDbAuditSink = exports.
|
|
22
|
+
exports.MariaDbAuditSink = exports.SERVICE_ACCOUNT_RESOLVER = exports.BoundRecords = exports.RecordsService = exports.RecordEngineImpl = 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.READ_SCOPE_NODES_TOKEN = void 0;
|
|
21
23
|
// The read-scope subtree-id placeholder token (ADR-0027) — a `subtreeSubquery` template
|
|
22
24
|
// uses it; the engine expands it to a `?`-list. Exported so per-type declarations can
|
|
23
25
|
// reference the canonical token (rather than a stringly-typed duplicate).
|
|
@@ -79,7 +81,5 @@ var records_service_js_1 = require("./pipe/records-service.js");
|
|
|
79
81
|
Object.defineProperty(exports, "RecordsService", { enumerable: true, get: function () { return records_service_js_1.RecordsService; } });
|
|
80
82
|
Object.defineProperty(exports, "BoundRecords", { enumerable: true, get: function () { return records_service_js_1.BoundRecords; } });
|
|
81
83
|
Object.defineProperty(exports, "SERVICE_ACCOUNT_RESOLVER", { enumerable: true, get: function () { return records_service_js_1.SERVICE_ACCOUNT_RESOLVER; } });
|
|
82
|
-
var mariadb_unit_of_work_js_1 = require("./adapters/mariadb-unit-of-work.js");
|
|
83
|
-
Object.defineProperty(exports, "MariaDbUnitOfWork", { enumerable: true, get: function () { return mariadb_unit_of_work_js_1.MariaDbUnitOfWork; } });
|
|
84
84
|
var mariadb_audit_sink_js_1 = require("./adapters/mariadb-audit-sink.js");
|
|
85
85
|
Object.defineProperty(exports, "MariaDbAuditSink", { enumerable: true, get: function () { return mariadb_audit_sink_js_1.MariaDbAuditSink; } });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @astram/engine/internal — composition-root and framework-test surface (Phase 8 #5).
|
|
3
|
+
*
|
|
4
|
+
* The raw unit of work is NOT on the package entry point (`@astram/engine`): feature code gets
|
|
5
|
+
* only the RecordEngine facade (`RECORD_ENGINE` / `RecordsService`). Wiring code (an app's
|
|
6
|
+
* `src/app.module.ts` / `src/main.ts`, and framework tests) imports the unit of work from here;
|
|
7
|
+
* the scaffolded app's lint wall rejects this subpath everywhere else.
|
|
8
|
+
*/
|
|
9
|
+
export { MariaDbUnitOfWork, type EngineDbConfig } from './adapters/mariadb-unit-of-work.js';
|
|
10
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,iBAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,oCAAoC,CAAC"}
|
package/dist/internal.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MariaDbUnitOfWork = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @astram/engine/internal — composition-root and framework-test surface (Phase 8 #5).
|
|
6
|
+
*
|
|
7
|
+
* The raw unit of work is NOT on the package entry point (`@astram/engine`): feature code gets
|
|
8
|
+
* only the RecordEngine facade (`RECORD_ENGINE` / `RecordsService`). Wiring code (an app's
|
|
9
|
+
* `src/app.module.ts` / `src/main.ts`, and framework tests) imports the unit of work from here;
|
|
10
|
+
* the scaffolded app's lint wall rejects this subpath everywhere else.
|
|
11
|
+
*/
|
|
12
|
+
var mariadb_unit_of_work_js_1 = require("./adapters/mariadb-unit-of-work.js");
|
|
13
|
+
Object.defineProperty(exports, "MariaDbUnitOfWork", { enumerable: true, get: function () { return mariadb_unit_of_work_js_1.MariaDbUnitOfWork; } });
|
package/dist/pipe/context.d.ts
CHANGED
|
@@ -35,14 +35,25 @@ export interface WriteContext extends PipeBase {
|
|
|
35
35
|
/** The id assigned/targeted by the write stage (set for create). */
|
|
36
36
|
resultId?: RecordId;
|
|
37
37
|
/**
|
|
38
|
-
* For
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
|
|
38
|
+
* For update/delete: the EXISTING row (the pre-image, D9) projected to registered field keys,
|
|
39
|
+
* read by the fetch-record stage BEFORE the permission gate with `SELECT * … FOR UPDATE`
|
|
40
|
+
* through the shared `whereById`. The gate passes it to `decide()` as
|
|
41
|
+
* `context.attributes`. A missing row never reaches the gate: fetch-record throws. NEVER set
|
|
42
|
+
* for create.
|
|
43
|
+
*/
|
|
44
|
+
existing?: Record<string, unknown>;
|
|
45
|
+
/**
|
|
46
|
+
* For update/delete: the existing row's `trusted:'actorId'` (owner) column, when it is a
|
|
47
|
+
* string. Passed to `decide()` as `context.attributes.ownerId` for core's owner baseline.
|
|
48
|
+
* NEVER set for create.
|
|
44
49
|
*/
|
|
45
50
|
ownerId?: string;
|
|
51
|
+
/**
|
|
52
|
+
* For update/delete: the existing row's `trusted:'tenantId'` column, when it is a string. The
|
|
53
|
+
* gate judges the record at ITS tenant (`resource.tenantId`); a type with no tenant column
|
|
54
|
+
* falls back to the actor's tenant. NEVER set for create.
|
|
55
|
+
*/
|
|
56
|
+
recordTenantId?: string;
|
|
46
57
|
}
|
|
47
58
|
/** A stage: a small, ordered, independently-testable unit of the pipe. */
|
|
48
59
|
export interface Stage {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/pipe/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,gDAAgD;AAChD,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAErD,6DAA6D;AAC7D,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC;IAClC,oFAAoF;IACpF,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,4EAA4E;IAC5E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,kCAAkC;AAClC,MAAM,WAAW,YAAa,SAAQ,QAAQ;IAC5C,+CAA+C;IAC/C,EAAE,CAAC,EAAE,QAAQ,CAAC;IACd,8CAA8C;IAC9C,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,8EAA8E;IAC9E,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IAC7C,oEAAoE;IACpE,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/pipe/context.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,gDAAgD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
@@ -3,15 +3,17 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Every write (create/update/delete) runs the FIXED, ordered stage sequence inside
|
|
5
5
|
* ONE transaction:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* type-pre-gate (update/delete) → fetch-record (update/delete) → permission-gate (MANDATORY) →
|
|
7
|
+
* derive-write-context →
|
|
8
|
+
* validate → compute (no-op Phase 1) → write → junction-sync → audit (MANDATORY) →
|
|
9
|
+
* emit-event (no-op).
|
|
8
10
|
* A caller cannot reorder, add, or drop stages — the pipe shape is fixed here, so
|
|
9
11
|
* the security gate + audit ALWAYS run (fixes ORS's optional gate + off-road writes).
|
|
10
12
|
* Any stage throwing aborts the transaction (rollback) — fail-closed.
|
|
11
13
|
*
|
|
12
|
-
* Reads (
|
|
13
|
-
* (
|
|
14
|
-
*
|
|
14
|
+
* Reads: get() is fetch → gate (on the row's fields + tenant) → project the same row;
|
|
15
|
+
* list() is gate (object type) → SQL-scoped query (list scope fragment, no fetch-then-
|
|
16
|
+
* discard) → project, ordered with a PK tiebreaker. (Column projection is still pending, G2.)
|
|
15
17
|
*/
|
|
16
18
|
import type { TableRegistry } from '../registry.js';
|
|
17
19
|
import type { AuditPort, DecisionPort, UnitOfWork, QueryFn } from '../ports.js';
|
|
@@ -75,17 +77,48 @@ export declare class RecordEngineImpl implements RecordEngine {
|
|
|
75
77
|
private readonly listScope;
|
|
76
78
|
/** The FIXED write-stage order. Built once; identical for every write. */
|
|
77
79
|
private readonly writeStages;
|
|
80
|
+
/** The ambient `transaction(fn)` (ADR-0034) so plain calls made inside `fn` join it. */
|
|
81
|
+
private readonly activeTx;
|
|
78
82
|
constructor(deps: RecordEngineDeps);
|
|
83
|
+
/**
|
|
84
|
+
* Run `fn` in ONE unit of work: every op on the handle, and every plain call on this engine
|
|
85
|
+
* made from inside `fn` (found via AsyncLocalStorage), shares the transaction. Each op still
|
|
86
|
+
* runs its full pipe. Commit on resolve, rollback on throw. ROLLBACK-ONLY once any write op
|
|
87
|
+
* (or a nested `fn`) inside it has failed, even if the caller swallowed the error — so the
|
|
88
|
+
* INSERT of a create the wall denied can never be committed by a careless `catch`. Nested calls
|
|
89
|
+
* reuse the outer transaction; a handle used after its transaction ended fails closed.
|
|
90
|
+
*/
|
|
91
|
+
transaction<T>(fn: (tx: RecordEngine) => Promise<T>): Promise<T>;
|
|
92
|
+
private transactionIn;
|
|
93
|
+
/** The transaction-bound engine handle passed to `transaction(fn)`. */
|
|
94
|
+
private handleFor;
|
|
95
|
+
/**
|
|
96
|
+
* Row lock on one record inside the open transaction (see `RecordEngine.lockForUpdate`). Keyed
|
|
97
|
+
* by the primary key only and returning nothing, so it reveals no data and needs no read gate.
|
|
98
|
+
*/
|
|
99
|
+
lockForUpdate(typeKey: string, id: RecordId, actor: Principal): Promise<void>;
|
|
100
|
+
private lockIn;
|
|
101
|
+
/**
|
|
102
|
+
* Run one op's body in the right unit of work: the bound/ambient transaction when there is
|
|
103
|
+
* one, else a fresh `uow.run` (the original per-op transaction). A WRITE failure inside a
|
|
104
|
+
* shared transaction marks it rollback-only.
|
|
105
|
+
*/
|
|
106
|
+
private inUnit;
|
|
79
107
|
private runWrite;
|
|
80
108
|
create(typeKey: string, input: RecordInput, actor: Principal): Promise<RecordId>;
|
|
81
109
|
update(typeKey: string, id: RecordId, input: RecordInput, actor: Principal): Promise<void>;
|
|
82
110
|
delete(typeKey: string, id: RecordId, actor: Principal): Promise<void>;
|
|
111
|
+
private createIn;
|
|
112
|
+
private updateIn;
|
|
113
|
+
private deleteIn;
|
|
83
114
|
private gateRead;
|
|
84
115
|
private qualified;
|
|
85
116
|
/** Project a raw DB row → RecordView (field keys, not columns). */
|
|
86
117
|
private project;
|
|
87
118
|
get(typeKey: string, id: RecordId, actor: Principal): Promise<RecordView | null>;
|
|
88
119
|
list(typeKey: string, query: ListQuery, actor: Principal): Promise<RecordPage>;
|
|
120
|
+
private getIn;
|
|
121
|
+
private listIn;
|
|
89
122
|
/** The physical column of a `tenantId`-trusted field, if the table has one. */
|
|
90
123
|
private tenantColumn;
|
|
91
124
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-engine.d.ts","sourceRoot":"","sources":["../../src/pipe/record-engine.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"record-engine.d.ts","sourceRoot":"","sources":["../../src/pipe/record-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEhF,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,UAAU,EACV,UAAU,EACV,UAAU,EACX,MAAM,aAAa,CAAC;AAsCrB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,sFAAsF;IACtF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;IAC9B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,CACzB,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,KACb,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnB;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,CACnB,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,KACX,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;Q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