@substrat-run/kernel 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/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/scope-host.d.ts +99 -6
- package/dist/scope-host.d.ts.map +1 -1
- package/dist/scope-record.d.ts +27 -0
- package/dist/scope-record.d.ts.map +1 -0
- package/dist/scope-record.js +29 -0
- package/dist/scope-record.js.map +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export type { ConsumerHandler, GuardPredicate, HostAdmin, ModuleRegistration, OperationContext, OperationHandler, ProvisionScopeInput, ScopedSql, ScopeHost, ScopeStub, SqlMigration, SqlValue, } from './scope-host.js';
|
|
1
|
+
export type { AuditLogFilter, ConsumerHandler, GuardPredicate, HostAdmin, ModuleRegistration, OperationContext, OperationHandler, ProvisionScopeInput, RoleFilter, ScopedSql, ScopeFilter, ScopeHost, ScopeStub, SqlMigration, SqlValue, } from './scope-host.js';
|
|
2
|
+
export { resolveScopeRecord } from './scope-record.js';
|
|
3
|
+
export type { ResolvedScopeRecord } from './scope-record.js';
|
|
2
4
|
export { assertAllowed, denyAllChecker, PermissionDenied, UNSAFE_allowAllChecker, } from './permission-checker.js';
|
|
3
5
|
export type { PermissionChecker } from './permission-checker.js';
|
|
4
6
|
export { ulid } from './ulid.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,YAAY,EACV,eAAe,EACf,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,SAAS,EACT,SAAS,EACT,SAAS,EACT,YAAY,EACZ,QAAQ,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,eAAe,EACf,cAAc,EACd,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,SAAS,EACT,YAAY,EACZ,QAAQ,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EACL,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EACL,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/scope-host.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AdminLogEntry, CapabilityGrant, CreateTenantInput, Decision, DomainEvent, DomainEventInput, EntityRef, IdentityLink, Jurisdiction, ModuleManifest, Node, PermissionKey, PlatformActorId, PrincipalId, ResolvedIdentity, RoleAssignment, RoleDefinition, ScopeId, StorageShape, Tenant, TenantId, TenantStatus } from '@substrat-run/contracts';
|
|
1
|
+
import type { AdminAction, AdminLogEntry, CapabilityGrant, CreateTenantInput, Decision, DomainEvent, DomainEventInput, EntityRef, IdentityLink, Jurisdiction, ModuleManifest, Node, PermissionKey, PlatformActorId, PrincipalId, ResolvedIdentity, RoleAssignment, RoleDefinition, Scope, ScopeId, ScopeStatus, StorageShape, Tenant, TenantId, TenantRole, TenantStatus } from '@substrat-run/contracts';
|
|
2
2
|
/**
|
|
3
3
|
* The scope-host contract — the adapter seam (§5.1 of the design doc).
|
|
4
4
|
*
|
|
@@ -119,6 +119,20 @@ export interface ModuleRegistration {
|
|
|
119
119
|
*/
|
|
120
120
|
export interface HostAdmin {
|
|
121
121
|
defineRole(actor: PlatformActorId, tenantId: TenantId, role: RoleDefinition): Promise<void>;
|
|
122
|
+
/**
|
|
123
|
+
* Every role the directory holds, ordered by (tenantId, key).
|
|
124
|
+
*
|
|
125
|
+
* Roles were writable and not enumerable: `defineRole` has existed since the
|
|
126
|
+
* permission model shipped, and nothing could ask what roles exist. That makes
|
|
127
|
+
* the console's half of the permission checkpoint unbuildable — CI diffs the
|
|
128
|
+
* roles declared in CODE, and this is the only way to see what a live
|
|
129
|
+
* deployment actually holds, which is not the same question.
|
|
130
|
+
*
|
|
131
|
+
* Directory-local, unlike grants: `_substrat_roles` sits beside the tenant
|
|
132
|
+
* registry, so this is a read. A grant is a tuple in the scope's own database
|
|
133
|
+
* and needs §5.4's admin-query RPC — the two are not the same size of problem.
|
|
134
|
+
*/
|
|
135
|
+
listRoles(filter?: RoleFilter): Promise<TenantRole[]>;
|
|
122
136
|
assignRole(actor: PlatformActorId, assignment: RoleAssignment): Promise<void>;
|
|
123
137
|
grant(actor: PlatformActorId, grant: CapabilityGrant): Promise<void>;
|
|
124
138
|
/** Grant to an organization (portal customers); members reach it via membership tuples. */
|
|
@@ -140,6 +154,18 @@ export interface HostAdmin {
|
|
|
140
154
|
/** The tenant registry — the directory's inventory (control-plane.md §4.5 console item 1). */
|
|
141
155
|
listTenants(): Promise<Tenant[]>;
|
|
142
156
|
getTenant(tenantId: TenantId): Promise<Tenant | undefined>;
|
|
157
|
+
/** The scope inventory. Ordered by scope_id (ULID = chronological). */
|
|
158
|
+
listScopes(filter?: ScopeFilter): Promise<Scope[]>;
|
|
159
|
+
/**
|
|
160
|
+
* One scope's directory record. Cross-checks the (tenantId, scopeId) pair and
|
|
161
|
+
* returns undefined on a mismatch rather than another tenant's scope (K-3) —
|
|
162
|
+
* the same fail-closed rule `ScopeHost.getScope` applies when minting a stub.
|
|
163
|
+
*
|
|
164
|
+
* Distinct from `ScopeHost.getScope`, which mints a capability stub for a
|
|
165
|
+
* principal and grants no read of the record. This returns the record and
|
|
166
|
+
* grants no execution.
|
|
167
|
+
*/
|
|
168
|
+
getScopeRecord(tenantId: TenantId, scopeId: ScopeId): Promise<Scope | undefined>;
|
|
143
169
|
/** active → suspended. Reversible containment (incident, dispute). */
|
|
144
170
|
suspendScope(actor: PlatformActorId, tenantId: TenantId, scopeId: ScopeId): Promise<void>;
|
|
145
171
|
/** suspended → active. */
|
|
@@ -163,20 +189,87 @@ export interface HostAdmin {
|
|
|
163
189
|
/** Resolve an external identity to its principal + home node — the auth adapter's read path. */
|
|
164
190
|
resolveIdentity(provider: string, externalId: string): Promise<ResolvedIdentity | undefined>;
|
|
165
191
|
/**
|
|
166
|
-
* The append-only admin audit trail,
|
|
192
|
+
* The append-only admin audit trail, oldest first by default (ULID order is
|
|
167
193
|
* chronological). Read path for the console history and the permission-diff
|
|
168
|
-
* human checkpoint (control-plane.md §4.5)
|
|
194
|
+
* human checkpoint (control-plane.md §4.5) — where the interesting column is
|
|
195
|
+
* `before`/`after`: a redefined role captures its old and new shape there, and
|
|
196
|
+
* that diff IS the checkpoint.
|
|
169
197
|
*/
|
|
170
|
-
auditLog(filter?:
|
|
171
|
-
tenantId?: TenantId;
|
|
172
|
-
}): Promise<AdminLogEntry[]>;
|
|
198
|
+
auditLog(filter?: AuditLogFilter): Promise<AdminLogEntry[]>;
|
|
173
199
|
}
|
|
174
200
|
export interface ProvisionScopeInput {
|
|
175
201
|
tenantId: TenantId;
|
|
176
202
|
scopeId: ScopeId;
|
|
203
|
+
/**
|
|
204
|
+
* Unique within the tenant; the console's human handle for the scope, shown as
|
|
205
|
+
* `{tenant.slug}/{scope.slug}`. Optional and defaulted to the lowercased
|
|
206
|
+
* scopeId — a ULID lowercases into a valid slug, so the default is structurally
|
|
207
|
+
* valid and unique by construction. A caller that means something by the name
|
|
208
|
+
* supplies one; the default is a placeholder, not a convention.
|
|
209
|
+
*/
|
|
210
|
+
slug?: string;
|
|
211
|
+
/** Vertical vocabulary ('brf', 'filial'). The kernel never branches on it. Defaults to 'scope'. */
|
|
212
|
+
kind?: string;
|
|
213
|
+
/** Display name. Defaults to the slug. */
|
|
214
|
+
name?: string;
|
|
215
|
+
/** Which vertical's deployment executes this scope. Defaults to null. */
|
|
216
|
+
vertical?: string | null;
|
|
177
217
|
storageShape?: StorageShape;
|
|
178
218
|
jurisdiction?: Jurisdiction;
|
|
179
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Narrow `listRoles` (control-plane.md §4.5 console item 4 — the permission
|
|
222
|
+
* diff's runtime half).
|
|
223
|
+
*/
|
|
224
|
+
export interface RoleFilter {
|
|
225
|
+
tenantId?: TenantId;
|
|
226
|
+
/**
|
|
227
|
+
* A module id, or 'vertical'. Both mean "declared in code" — see
|
|
228
|
+
* `roleDefinition.source`. Filtering for operator-created roles is not
|
|
229
|
+
* possible until something can create one.
|
|
230
|
+
*/
|
|
231
|
+
source?: string;
|
|
232
|
+
}
|
|
233
|
+
/** Narrow `listScopes` (control-plane.md §4.5 console items 1 and 6). */
|
|
234
|
+
export interface ScopeFilter {
|
|
235
|
+
tenantId?: TenantId;
|
|
236
|
+
/** One status or any of several — the console's All / Suspended / Archived tabs. */
|
|
237
|
+
status?: ScopeStatus | ScopeStatus[];
|
|
238
|
+
vertical?: string;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Narrow the admin audit trail (control-plane.md §4.4/§4.5). Every field is a
|
|
242
|
+
* conjunctive AND; omitting all of them reads the whole log, which is why `limit`
|
|
243
|
+
* exists — the table is append-only and only grows.
|
|
244
|
+
*/
|
|
245
|
+
export interface AuditLogFilter {
|
|
246
|
+
tenantId?: TenantId;
|
|
247
|
+
scopeId?: ScopeId;
|
|
248
|
+
actor?: PlatformActorId;
|
|
249
|
+
/** One action or any of several. */
|
|
250
|
+
action?: AdminAction | AdminAction[];
|
|
251
|
+
/** Inclusive lower / exclusive upper bound on `at` (ISO 8601). */
|
|
252
|
+
since?: string;
|
|
253
|
+
until?: string;
|
|
254
|
+
/**
|
|
255
|
+
* Page size. Unset means unbounded — kept as the default because the read is
|
|
256
|
+
* `AdminLogEntry[]`, and a silent cap would let a caller mistake a truncated
|
|
257
|
+
* page for the whole log. The console always passes one.
|
|
258
|
+
*/
|
|
259
|
+
limit?: number;
|
|
260
|
+
/**
|
|
261
|
+
* Page anchor: the `id` of the last entry of the previous page. Entries are
|
|
262
|
+
* returned strictly after it in `asc` order, strictly before it in `desc` —
|
|
263
|
+
* ULID order is chronological, so the cursor is the entry id itself and needs
|
|
264
|
+
* no separate encoding. There is no `nextCursor`: it is `entries.at(-1)?.id`.
|
|
265
|
+
*/
|
|
266
|
+
cursor?: string;
|
|
267
|
+
/**
|
|
268
|
+
* Default 'asc' — oldest first, preserving the ordering the log shipped with.
|
|
269
|
+
* The console reads 'desc'.
|
|
270
|
+
*/
|
|
271
|
+
order?: 'asc' | 'desc';
|
|
272
|
+
}
|
|
180
273
|
export interface ScopeHost {
|
|
181
274
|
/**
|
|
182
275
|
* Mint a capability stub for a principal. Validates the (tenantId, scopeId)
|
package/dist/scope-host.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scope-host.d.ts","sourceRoot":"","sources":["../src/scope-host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,IAAI,EACJ,aAAa,EACb,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,OAAO,EACP,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,YAAY,EACb,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;;;;;GAcG;AAEH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC;AAEpE,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;IACpF,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,QAAQ,EAAE,GAAG;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACtE;AAED,iGAAiG;AACjG,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC;IAChC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,kGAAkG;IAClG,IAAI,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACpC,0FAA0F;IAC1F,KAAK,CAAC,UAAU,EAAE,aA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type { Jurisdiction, StorageShape } from '@substrat-run/contracts';
|
|
2
|
+
import type { ProvisionScopeInput } from './scope-host.js';
|
|
3
|
+
/** The directory columns `provisionScope` writes, with every optional resolved. */
|
|
4
|
+
export interface ResolvedScopeRecord {
|
|
5
|
+
slug: string;
|
|
6
|
+
kind: string;
|
|
7
|
+
name: string;
|
|
8
|
+
vertical: string | null;
|
|
9
|
+
storageShape: StorageShape;
|
|
10
|
+
jurisdiction: Jurisdiction;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Resolve `ProvisionScopeInput`'s optional naming fields into the row both
|
|
14
|
+
* adapters write.
|
|
15
|
+
*
|
|
16
|
+
* It lives in the kernel, not in either adapter, because these defaults are a
|
|
17
|
+
* CONTRACT: "an unnamed scope's slug is its lowercased id" has to be one fact
|
|
18
|
+
* with one implementation. Two copies would agree until the day they didn't, and
|
|
19
|
+
* the contract tests — which run the same suite against both adapters — would
|
|
20
|
+
* still pass, because each adapter would be consistent with itself.
|
|
21
|
+
*
|
|
22
|
+
* The slug is parsed rather than trusted (the boundary rule): an invalid slug
|
|
23
|
+
* fails here, at provisioning, instead of at the first `listScopes` read, when
|
|
24
|
+
* the scope already exists and the caller is someone else.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveScopeRecord(input: ProvisionScopeInput): ResolvedScopeRecord;
|
|
27
|
+
//# sourceMappingURL=scope-record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-record.d.ts","sourceRoot":"","sources":["../src/scope-record.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,mFAAmF;AACnF,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,CAYlF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { slug as slugSchema } from '@substrat-run/contracts';
|
|
2
|
+
/**
|
|
3
|
+
* Resolve `ProvisionScopeInput`'s optional naming fields into the row both
|
|
4
|
+
* adapters write.
|
|
5
|
+
*
|
|
6
|
+
* It lives in the kernel, not in either adapter, because these defaults are a
|
|
7
|
+
* CONTRACT: "an unnamed scope's slug is its lowercased id" has to be one fact
|
|
8
|
+
* with one implementation. Two copies would agree until the day they didn't, and
|
|
9
|
+
* the contract tests — which run the same suite against both adapters — would
|
|
10
|
+
* still pass, because each adapter would be consistent with itself.
|
|
11
|
+
*
|
|
12
|
+
* The slug is parsed rather than trusted (the boundary rule): an invalid slug
|
|
13
|
+
* fails here, at provisioning, instead of at the first `listScopes` read, when
|
|
14
|
+
* the scope already exists and the caller is someone else.
|
|
15
|
+
*/
|
|
16
|
+
export function resolveScopeRecord(input) {
|
|
17
|
+
// A ULID lowercases into a valid slug ([0-9a-hjkmnp-tv-z]), so the default is
|
|
18
|
+
// both structurally valid and unique within the tenant by construction.
|
|
19
|
+
const slug = slugSchema.parse(input.slug ?? input.scopeId.toLowerCase());
|
|
20
|
+
return {
|
|
21
|
+
slug,
|
|
22
|
+
kind: input.kind ?? 'scope',
|
|
23
|
+
name: input.name ?? slug,
|
|
24
|
+
vertical: input.vertical ?? null,
|
|
25
|
+
storageShape: input.storageShape ?? 'A',
|
|
26
|
+
jurisdiction: input.jurisdiction ?? null,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=scope-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scope-record.js","sourceRoot":"","sources":["../src/scope-record.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAc7D;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAA0B;IAC3D,8EAA8E;IAC9E,wEAAwE;IACxE,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IACzE,OAAO;QACL,IAAI;QACJ,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,OAAO;QAC3B,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,IAAI;QACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,IAAI;QAChC,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,GAAG;QACvC,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,IAAI;KACzC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@substrat-run/kernel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Substrat kernel contracts and services — pure TypeScript, no platform imports (D-14)",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@substrat-run/contracts": "^0.
|
|
25
|
+
"@substrat-run/contracts": "^0.5.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"typescript": "^5.6.0"
|