@substrat-run/kernel 0.143.0 → 0.145.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/capability.d.ts +20 -2
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +73 -13
- package/dist/capability.js.map +1 -1
- package/dist/derived-handlers.d.ts +2 -0
- package/dist/derived-handlers.d.ts.map +1 -1
- package/dist/derived-handlers.js +116 -22
- package/dist/derived-handlers.js.map +1 -1
- package/dist/entity-binding.d.ts +121 -0
- package/dist/entity-binding.d.ts.map +1 -0
- package/dist/entity-binding.js +235 -0
- package/dist/entity-binding.js.map +1 -0
- package/dist/entity-grant-shape.d.ts +54 -8
- package/dist/entity-grant-shape.d.ts.map +1 -1
- package/dist/entity-grant-shape.js +266 -98
- package/dist/entity-grant-shape.js.map +1 -1
- package/dist/entity-grant.d.ts +19 -2
- package/dist/entity-grant.d.ts.map +1 -1
- package/dist/entity-grant.js +24 -3
- package/dist/entity-grant.js.map +1 -1
- package/dist/entity-stamps.d.ts +50 -0
- package/dist/entity-stamps.d.ts.map +1 -0
- package/dist/entity-stamps.js +93 -0
- package/dist/entity-stamps.js.map +1 -0
- package/dist/entity-state.d.ts +2 -0
- package/dist/entity-state.d.ts.map +1 -1
- package/dist/entity-state.js +4 -0
- package/dist/entity-state.js.map +1 -1
- package/dist/entity-trash.d.ts +14 -2
- package/dist/entity-trash.d.ts.map +1 -1
- package/dist/entity-trash.js +28 -5
- package/dist/entity-trash.js.map +1 -1
- package/dist/entity-version.d.ts +29 -15
- package/dist/entity-version.d.ts.map +1 -1
- package/dist/entity-version.js +13 -9
- package/dist/entity-version.js.map +1 -1
- package/dist/findings.d.ts +6 -3
- package/dist/findings.d.ts.map +1 -1
- package/dist/findings.js +25 -5
- package/dist/findings.js.map +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/module-erasure.d.ts +2 -1
- package/dist/module-erasure.d.ts.map +1 -1
- package/dist/module-erasure.js +12 -1
- package/dist/module-erasure.js.map +1 -1
- package/dist/permission-eval.d.ts +16 -3
- package/dist/permission-eval.d.ts.map +1 -1
- package/dist/permission-eval.js +52 -9
- package/dist/permission-eval.js.map +1 -1
- package/dist/platform-sweep.d.ts +124 -2
- package/dist/platform-sweep.d.ts.map +1 -1
- package/dist/platform-sweep.js +199 -8
- package/dist/platform-sweep.js.map +1 -1
- package/dist/scope-host.d.ts +39 -6
- package/dist/scope-host.d.ts.map +1 -1
- package/dist/scope-host.js.map +1 -1
- package/dist/sql-identifier.d.ts +3 -0
- package/dist/sql-identifier.d.ts.map +1 -1
- package/dist/sql-identifier.js +2 -0
- package/dist/sql-identifier.js.map +1 -1
- package/dist/system-switch.d.ts +5 -0
- package/dist/system-switch.d.ts.map +1 -1
- package/dist/system-switch.js +7 -0
- package/dist/system-switch.js.map +1 -1
- package/dist/timeline.d.ts +2 -1
- package/dist/timeline.d.ts.map +1 -1
- package/dist/timeline.js.map +1 -1
- package/package.json +2 -2
- package/dist/connect-state.d.ts +0 -103
- package/dist/connect-state.d.ts.map +0 -1
- package/dist/connect-state.js +0 -128
- package/dist/connect-state.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derived-handlers.js","sourceRoot":"","sources":["../src/derived-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,aAAa,EACb,aAAa,
|
|
1
|
+
{"version":3,"file":"derived-handlers.js","sourceRoot":"","sources":["../src/derived-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,aAAa,EACb,aAAa,GAMd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAKjC,2GAA2G;AAC3G,MAAM,CAAC,MAAM,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CAAC,KAAK,CAAC,KAAK,SAAS;YAAE,GAAG,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/D,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,8FAA8F;AAC9F,SAAS,OAAO,CAAC,IAAiB,EAAE,MAAiB,EAAE,MAAW;IAChE,MAAM,OAAO,GAAQ,EAAE,CAAC;IACxB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO;QAAE,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACjE,OAAO;QACL,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,aAAa,EAAE,IAAI,CAAC,aAAa;QACjC,MAAM;QACN,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,GAAG,CAAC,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9E,OAAO;KACmC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { type BoundedUnbind, type CapabilityId, type Coverage, type DomainEventInput, type EntityRef, type PermissionKey, type PrincipalId } from '@substrat-run/contracts';
|
|
2
|
+
import type { ScopedSql } from './scope-host.js';
|
|
3
|
+
/**
|
|
4
|
+
* A BINDING shape (#1686): a record names its own person in a declared column, and the person
|
|
5
|
+
* it names holds the record's declared shape there. What makes a customer invite a binding
|
|
6
|
+
* rather than a delegation: the link names WHICH record, the reviewed registry says WHAT the
|
|
7
|
+
* person bound to it holds, and the minter vouches for the record with an ordinary key.
|
|
8
|
+
*
|
|
9
|
+
* Three writes, each one statement set shared by both adapters:
|
|
10
|
+
* - {@link bindIn}: inside a `become` exchange's transaction, once {@link judgeBind} said yes and
|
|
11
|
+
* the use is taken — the column set to the claimant, the shape granted (marker and keys), and
|
|
12
|
+
* `entity.holder-bound` emitted.
|
|
13
|
+
* - {@link unbindEntityHolderBounded}: the column cleared, and every holder of the shape on the
|
|
14
|
+
* record released from the SPINE — their marker and everything they hold there tombstoned (K-21).
|
|
15
|
+
* - {@link captureBoundOf} / {@link releaseBound}: the erasure's half — on every type that binds or
|
|
16
|
+
* ever bound here, the holders on the erased record and the erased person's own markers, read
|
|
17
|
+
* before any module erasure runs and released after the hooks whether or not a row survived.
|
|
18
|
+
*
|
|
19
|
+
* People already bound keep the shape until they are released — an unbind (while the shape still
|
|
20
|
+
* binds), an erasure, or the retirement of its keys — whatever a later version declares.
|
|
21
|
+
*
|
|
22
|
+
* Read from the scope's record of its reconciled registry (`shape-bind-*` tuples), never from the
|
|
23
|
+
* vertical's code: a scope not yet reconciled with a binding declaration binds nothing.
|
|
24
|
+
*/
|
|
25
|
+
interface EntityBinding {
|
|
26
|
+
entityType: string;
|
|
27
|
+
table: string;
|
|
28
|
+
idColumn: string;
|
|
29
|
+
principalColumn: string;
|
|
30
|
+
/**
|
|
31
|
+
* Who holds this on a record may bind its person with a link, and unbind them — null once a
|
|
32
|
+
* version dropped `bind` and kept the shape: nobody may, and an erasure still releases.
|
|
33
|
+
*/
|
|
34
|
+
permission: PermissionKey | null;
|
|
35
|
+
/** The shape's current keys — what a claim gives. */
|
|
36
|
+
keys: PermissionKey[];
|
|
37
|
+
/** Every key of the shape, current and retired — what an unbind takes back. */
|
|
38
|
+
every: PermissionKey[];
|
|
39
|
+
}
|
|
40
|
+
/** The bind key's refusal, in the shape every bounded verb answers a missing key with. */
|
|
41
|
+
declare const lacking: (permission: PermissionKey) => {
|
|
42
|
+
ok: false;
|
|
43
|
+
coverage: Extract<Coverage, {
|
|
44
|
+
covered: false;
|
|
45
|
+
}>;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* May `entity` be bound by a link its minter vouches for, now? The scope's recorded binding for
|
|
49
|
+
* the type, the record present, its column naming nobody, nobody holding its shape there on the
|
|
50
|
+
* spine (`bind-record-held`: unbind them first), and the minter holding the binding's
|
|
51
|
+
* permission on it (`allowed`, the checker's `check` for the minter). The same judgement at mint
|
|
52
|
+
* and at the exchange, so a link whose minter has since lost the key, or left, is refused.
|
|
53
|
+
*/
|
|
54
|
+
export declare function judgeBind(sql: ScopedSql, allowed: (permission: PermissionKey, entity: EntityRef) => Promise<boolean>, entity: EntityRef): Promise<{
|
|
55
|
+
ok: true;
|
|
56
|
+
binding: EntityBinding;
|
|
57
|
+
} | {
|
|
58
|
+
ok: false;
|
|
59
|
+
refused: 'bind-not-declared' | 'bind-record-missing' | 'bind-record-ambiguous' | 'bind-record-bound' | 'bind-record-held';
|
|
60
|
+
} | ReturnType<typeof lacking>>;
|
|
61
|
+
/**
|
|
62
|
+
* The claim's write, inside the exchange's transaction once {@link judgeBind} has said yes there
|
|
63
|
+
* and the use is taken: the record's column set to `principal` — only while it still names nobody —
|
|
64
|
+
* the shape's current keys given with its marker, and `entity.holder-bound` emitted with the
|
|
65
|
+
* capability as actor. Nothing can have moved since the judgement inside one transaction, so a
|
|
66
|
+
* column that no longer reads empty is a fault: thrown, so the use rolls back with it.
|
|
67
|
+
*/
|
|
68
|
+
export declare function bindIn(sql: ScopedSql, binding: EntityBinding, entity: EntityRef, principal: PrincipalId, link: {
|
|
69
|
+
capabilityId: CapabilityId;
|
|
70
|
+
mintedBy: PrincipalId;
|
|
71
|
+
}, emit: (event: DomainEventInput) => void): void;
|
|
72
|
+
/** The pseudo-operation an unbind's spine event names, on `capabilities.mint-become`'s pattern. */
|
|
73
|
+
export declare const ENTITY_UNBIND_OPERATION = "entities.unbind";
|
|
74
|
+
/**
|
|
75
|
+
* A principal's unbind of `entity` (#1686) — the lever beside a binding invite, run by a host in one
|
|
76
|
+
* scope task and transaction. Bounded here: the caller must hold the binding's key on the record
|
|
77
|
+
* (`allowed`, the checker's `check` for the caller). Clears the record's column (every row with
|
|
78
|
+
* its id) and releases every holder of the shape on it from the spine — whoever a link bound,
|
|
79
|
+
* whatever the column says now, and a holder given the shape before the column was written —
|
|
80
|
+
* with one `entity.holder-unbound` event each through `emit`, whose actor the host stamps as the
|
|
81
|
+
* caller. `unbound` names everyone released; a refusal writes nothing.
|
|
82
|
+
*/
|
|
83
|
+
export declare function unbindEntityHolderBounded(deps: {
|
|
84
|
+
sql: ScopedSql;
|
|
85
|
+
now: string;
|
|
86
|
+
allowed: (permission: PermissionKey, entity: EntityRef) => Promise<boolean>;
|
|
87
|
+
emit: (event: DomainEventInput) => void;
|
|
88
|
+
}, entity: EntityRef): Promise<BoundedUnbind>;
|
|
89
|
+
/** What an erasure releases, read before any of it runs. */
|
|
90
|
+
export interface ErasureBindings {
|
|
91
|
+
/** Shape holders to release: on a record that IS the subject (any holder), or the subject's own markers. */
|
|
92
|
+
holders: {
|
|
93
|
+
object: string;
|
|
94
|
+
only?: string;
|
|
95
|
+
}[];
|
|
96
|
+
/** Rows whose column names someone the erasure reaches, to clear where they survive. */
|
|
97
|
+
columns: {
|
|
98
|
+
binding: EntityBinding;
|
|
99
|
+
entityId: string;
|
|
100
|
+
principal: string;
|
|
101
|
+
}[];
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Every binding the erasure of `subjectId` reaches, by the spine and by the column: on each type the
|
|
105
|
+
* scope binds or has ever bound (`shape-bound`) — the id matched against every such type, as a
|
|
106
|
+
* module's declared erasure matches its subject columns whatever the type, so ids that are not
|
|
107
|
+
* ULIDs (an integer, say) can collide across types — the record that IS the subject (every holder on it) and every record the subject
|
|
108
|
+
* holds the shape on (their own marker), plus the rows whose column names the subject or that are
|
|
109
|
+
* the subject. Read BEFORE any declared blank, delete or hook runs, so a row a module's erasure
|
|
110
|
+
* deletes is still known. A scope that binds nothing pays the one read of its shape records.
|
|
111
|
+
*/
|
|
112
|
+
export declare function captureBoundOf(sql: ScopedSql, subjectId: string): ErasureBindings;
|
|
113
|
+
/**
|
|
114
|
+
* The erasure's unbind, after the module hooks: each captured column cleared where the row survived
|
|
115
|
+
* and still names that person, and each captured holder released from the spine whether or not
|
|
116
|
+
* its row survived. No event: an event naming the erased subject would be a new copy of what is
|
|
117
|
+
* being erased.
|
|
118
|
+
*/
|
|
119
|
+
export declare function releaseBound(sql: ScopedSql, captured: ErasureBindings, now: string): void;
|
|
120
|
+
export {};
|
|
121
|
+
//# sourceMappingURL=entity-binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-binding.d.ts","sourceRoot":"","sources":["../src/entity-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,gBAAgB,EAGrB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAIjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,UAAU,aAAa;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,UAAU,EAAE,aAAa,GAAG,IAAI,CAAC;IACjC,qDAAqD;IACrD,IAAI,EAAE,aAAa,EAAE,CAAC;IACtB,+EAA+E;IAC/E,KAAK,EAAE,aAAa,EAAE,CAAC;CACxB;AA+ED,0FAA0F;AAC1F,QAAA,MAAM,OAAO,eAAgB,aAAa,KAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE;QAAE,OAAO,EAAE,KAAK,CAAA;KAAE,CAAC,CAAA;CAGvG,CAAC;AAEH;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,CAAC,UAAU,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,KAAK,OAAO,CAAC,OAAO,CA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,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC5E;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,eAAe,CAmCjF;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAGzF"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { ENTITY_HOLDER_BOUND, ENTITY_HOLDER_UNBOUND, ENTITY_SHAPE_MARKER_RELATION, entityObjectRef, permissionKey, substratError, } from '@substrat-run/contracts';
|
|
2
|
+
import { BIND_HOLDER_RELATION, BIND_KEY_RELATION, BIND_PERMISSION_RELATION, BOUND_EVER_RELATION, grantEntityShapeIn } from './entity-grant-shape.js';
|
|
3
|
+
import { SHAPE_PROTECTED_KEY_RELATION } from './entity-grant.js';
|
|
4
|
+
import { assertSqlIdentifier, tableExists } from './sql-identifier.js';
|
|
5
|
+
import { switchSqlOf } from './system-switch.js';
|
|
6
|
+
const PRINCIPAL = 'principal:';
|
|
7
|
+
const GRANTED = 'granted:';
|
|
8
|
+
const BINDING_RELATIONS = [BIND_HOLDER_RELATION, BIND_PERMISSION_RELATION, BIND_KEY_RELATION, SHAPE_PROTECTED_KEY_RELATION];
|
|
9
|
+
/** One shape's recorded facts as a binding, or null when they do not make one. */
|
|
10
|
+
function bindingFrom(entityType, rows) {
|
|
11
|
+
const of = (relation) => rows.filter((r) => r.relation === relation).map((r) => r.object);
|
|
12
|
+
const holder = of(BIND_HOLDER_RELATION);
|
|
13
|
+
const permission = of(BIND_PERMISSION_RELATION);
|
|
14
|
+
if (holder.length !== 1 || permission.length > 1)
|
|
15
|
+
return null;
|
|
16
|
+
const parts = holder[0].split('.');
|
|
17
|
+
if (parts.length !== 3)
|
|
18
|
+
return null;
|
|
19
|
+
const [table, idColumn, principalColumn] = parts.map((n) => assertSqlIdentifier('entityBinding', 'an identifier', n, `the recorded binding of '${entityType}'`));
|
|
20
|
+
const keys = (relation) => of(relation).map((o) => permissionKey.parse(o.slice(GRANTED.length))).sort();
|
|
21
|
+
return {
|
|
22
|
+
entityType,
|
|
23
|
+
table,
|
|
24
|
+
idColumn,
|
|
25
|
+
principalColumn,
|
|
26
|
+
permission: permission[0] === undefined ? null : permissionKey.parse(permission[0]),
|
|
27
|
+
keys: keys(BIND_KEY_RELATION),
|
|
28
|
+
every: keys(SHAPE_PROTECTED_KEY_RELATION),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The scope's recorded binding for `entityType` that still declares its bind key — what a mint, a
|
|
33
|
+
* claim and an unbind need — or null when its reconciled registry binds nothing there.
|
|
34
|
+
*/
|
|
35
|
+
function entityBindingOf(sql, entityType) {
|
|
36
|
+
const binding = bindingFrom(entityType, sql.query(`SELECT relation, object FROM _substrat_tuples WHERE subject = ? AND relation IN (?, ?, ?, ?)`, [`shape:${entityType}`, ...BINDING_RELATIONS]));
|
|
37
|
+
return binding?.permission ? { ...binding, permission: binding.permission } : null;
|
|
38
|
+
}
|
|
39
|
+
/** Every binding the scope's reconciled registry records, bind key or not — what an erasure releases — in one read. */
|
|
40
|
+
function entityBindingsOf(sql) {
|
|
41
|
+
const bySubject = new Map();
|
|
42
|
+
for (const row of sql.query(`SELECT subject, relation, object FROM _substrat_tuples
|
|
43
|
+
WHERE subject >= 'shape:' AND subject < 'shape;' AND relation IN (?, ?, ?, ?)`, [...BINDING_RELATIONS])) {
|
|
44
|
+
bySubject.set(row.subject, [...(bySubject.get(row.subject) ?? []), row]);
|
|
45
|
+
}
|
|
46
|
+
return [...bySubject].flatMap(([subject, rows]) => bindingFrom(subject.slice('shape:'.length), rows) ?? []);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The record as the binding sees it: how many rows carry its id, and whom the first row that names
|
|
50
|
+
* someone names. Every row is read: the id column should be unique, and a record any of whose rows
|
|
51
|
+
* names someone is bound.
|
|
52
|
+
*/
|
|
53
|
+
function boundRecord(sql, b, entityId) {
|
|
54
|
+
if (!tableExists(switchSqlOf(sql), b.table))
|
|
55
|
+
return { rows: 0, principal: null };
|
|
56
|
+
const rows = sql.query(`SELECT "${b.principalColumn}" AS principal FROM "${b.table}" WHERE "${b.idColumn}" = ?`, [entityId]);
|
|
57
|
+
return { rows: rows.length, principal: rows.find((r) => r.principal !== null)?.principal ?? null };
|
|
58
|
+
}
|
|
59
|
+
/** Does anyone hold a live shape marker on `object`? */
|
|
60
|
+
const heldBySomeone = (sql, object) => sql.query(`SELECT 1 FROM _substrat_tuples WHERE object = ? AND relation = '${ENTITY_SHAPE_MARKER_RELATION}' AND revoked_at IS NULL
|
|
61
|
+
AND subject >= '${PRINCIPAL}' AND subject < 'principal;' LIMIT 1`, [object]).length > 0;
|
|
62
|
+
/** The bind key's refusal, in the shape every bounded verb answers a missing key with. */
|
|
63
|
+
const lacking = (permission) => ({
|
|
64
|
+
ok: false,
|
|
65
|
+
coverage: { covered: false, missing: [permission] },
|
|
66
|
+
});
|
|
67
|
+
/**
|
|
68
|
+
* May `entity` be bound by a link its minter vouches for, now? The scope's recorded binding for
|
|
69
|
+
* the type, the record present, its column naming nobody, nobody holding its shape there on the
|
|
70
|
+
* spine (`bind-record-held`: unbind them first), and the minter holding the binding's
|
|
71
|
+
* permission on it (`allowed`, the checker's `check` for the minter). The same judgement at mint
|
|
72
|
+
* and at the exchange, so a link whose minter has since lost the key, or left, is refused.
|
|
73
|
+
*/
|
|
74
|
+
export async function judgeBind(sql, allowed, entity) {
|
|
75
|
+
entityObjectRef(entity, 'bind');
|
|
76
|
+
const binding = entityBindingOf(sql, entity.entityType);
|
|
77
|
+
if (!binding)
|
|
78
|
+
return { ok: false, refused: 'bind-not-declared' };
|
|
79
|
+
// The key before anything about the record: a minter without it on this record learns nothing
|
|
80
|
+
// of whether it exists, names someone, or is held — the same refusal for every record they lack.
|
|
81
|
+
if (!(await allowed(binding.permission, entity)))
|
|
82
|
+
return lacking(binding.permission);
|
|
83
|
+
const record = boundRecord(sql, binding, entity.entityId);
|
|
84
|
+
if (record.rows === 0)
|
|
85
|
+
return { ok: false, refused: 'bind-record-missing' };
|
|
86
|
+
if (record.principal !== null)
|
|
87
|
+
return { ok: false, refused: 'bind-record-bound' };
|
|
88
|
+
// Two rows carrying one id are no one record: there is nothing a claim could bind exactly once.
|
|
89
|
+
if (record.rows > 1)
|
|
90
|
+
return { ok: false, refused: 'bind-record-ambiguous' };
|
|
91
|
+
// The spine as well as the column: someone already holding the record's shape there — given it
|
|
92
|
+
// before the column was written, or left by a holder column a later version moved — is a holder
|
|
93
|
+
// a new link would bind a second person beside. Unbind them first.
|
|
94
|
+
if (heldBySomeone(sql, entityObjectRef(entity, 'bind')))
|
|
95
|
+
return { ok: false, refused: 'bind-record-held' };
|
|
96
|
+
return { ok: true, binding };
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The claim's write, inside the exchange's transaction once {@link judgeBind} has said yes there
|
|
100
|
+
* and the use is taken: the record's column set to `principal` — only while it still names nobody —
|
|
101
|
+
* the shape's current keys given with its marker, and `entity.holder-bound` emitted with the
|
|
102
|
+
* capability as actor. Nothing can have moved since the judgement inside one transaction, so a
|
|
103
|
+
* column that no longer reads empty is a fault: thrown, so the use rolls back with it.
|
|
104
|
+
*/
|
|
105
|
+
export function bindIn(sql, binding, entity, principal, link, emit) {
|
|
106
|
+
// Counted by RETURNING, never by `changes`: on a Durable Object that is `rowsWritten`, which
|
|
107
|
+
// counts index entries too, so an index on the principal column reads one row as two. Exactly one
|
|
108
|
+
// row: an id two rows carry is no one record, and the claim refuses it rather than bind both.
|
|
109
|
+
const set = sql.query(`UPDATE "${binding.table}" SET "${binding.principalColumn}" = ? WHERE "${binding.idColumn}" = ? AND "${binding.principalColumn}" IS NULL RETURNING 1 AS one`, [principal, entity.entityId]);
|
|
110
|
+
if (set.length !== 1) {
|
|
111
|
+
throw substratError('internal', `capability ${link.capabilityId}: its bind on ${entity.entityType} was refused after it was judged`);
|
|
112
|
+
}
|
|
113
|
+
grantEntityShapeIn(switchSqlOf(sql), principal, entity, binding.keys);
|
|
114
|
+
// Sticky (the reconcile that recorded the binding wrote it too): an erasure releases this type's
|
|
115
|
+
// holders whatever a later version declares.
|
|
116
|
+
sql.exec('INSERT OR IGNORE INTO _substrat_tuples (subject, relation, object) VALUES (?, ?, ?)', [
|
|
117
|
+
`shape:${entity.entityType}`,
|
|
118
|
+
BOUND_EVER_RELATION,
|
|
119
|
+
'bound',
|
|
120
|
+
]);
|
|
121
|
+
const payload = { entity, principal, ...link, granted: binding.keys };
|
|
122
|
+
emit({ type: ENTITY_HOLDER_BOUND, schemaVersion: 1, entity, piiClass: 'none', payload });
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Release the record's shape holders from the SPINE: every principal holding a live marker on
|
|
126
|
+
* `object` (or only `only`), and with each marker everything that principal holds on the record —
|
|
127
|
+
* every `granted:` tuple there, whatever the shape's keys are now. A binding shape's marker and its
|
|
128
|
+
* keys come only from its own grant (its keys are refused to every direct grant on a record of the
|
|
129
|
+
* type), so the marker is the person's holding of the record, and what they hold on it goes with it:
|
|
130
|
+
* a key the shape has since dropped without retiring it included. That is broader than the shape:
|
|
131
|
+
* it ALSO revokes a direct grant of a key the shape does not declare, made to the same holder on the
|
|
132
|
+
* same record (a `bind:member` granted to a bound person goes with the unbind) — reported in
|
|
133
|
+
* `removed`, never silent. Judged by the spine, never the column, so a column module code rewrote
|
|
134
|
+
* cannot strand the person a link bound. One tombstone statement per holder (K-21).
|
|
135
|
+
*/
|
|
136
|
+
function releaseHolders(sql, object, now, only) {
|
|
137
|
+
const holders = sql.query(`SELECT subject FROM _substrat_tuples
|
|
138
|
+
WHERE object = ? AND relation = '${ENTITY_SHAPE_MARKER_RELATION}' AND revoked_at IS NULL
|
|
139
|
+
AND subject >= '${PRINCIPAL}' AND subject < 'principal;'${only === undefined ? '' : ' AND subject = ?'}`, only === undefined ? [object] : [object, `${PRINCIPAL}${only}`]);
|
|
140
|
+
return holders.map(({ subject }) => ({
|
|
141
|
+
principal: subject.slice(PRINCIPAL.length),
|
|
142
|
+
removed: sql
|
|
143
|
+
.query(`UPDATE _substrat_tuples SET revoked_at = ?
|
|
144
|
+
WHERE subject = ? AND object = ? AND revoked_at IS NULL
|
|
145
|
+
AND (relation = '${ENTITY_SHAPE_MARKER_RELATION}' OR (relation >= '${GRANTED}' AND relation < 'granted;'))
|
|
146
|
+
RETURNING relation`, [now, subject, object])
|
|
147
|
+
.flatMap((r) => (r.relation === ENTITY_SHAPE_MARKER_RELATION ? [] : [permissionKey.parse(r.relation.slice(GRANTED.length))]))
|
|
148
|
+
.sort(),
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
/** Clear the record's column — every row carrying its id, or only where it still names `principal`. */
|
|
152
|
+
function clearColumn(sql, binding, entityId, principal) {
|
|
153
|
+
if (!tableExists(switchSqlOf(sql), binding.table))
|
|
154
|
+
return;
|
|
155
|
+
sql.exec(`UPDATE "${binding.table}" SET "${binding.principalColumn}" = NULL WHERE "${binding.idColumn}" = ? AND ${principal === undefined ? `"${binding.principalColumn}" IS NOT NULL` : `"${binding.principalColumn}" = ?`}`, principal === undefined ? [entityId] : [entityId, principal]);
|
|
156
|
+
}
|
|
157
|
+
/** The pseudo-operation an unbind's spine event names, on `capabilities.mint-become`'s pattern. */
|
|
158
|
+
export const ENTITY_UNBIND_OPERATION = 'entities.unbind';
|
|
159
|
+
/**
|
|
160
|
+
* A principal's unbind of `entity` (#1686) — the lever beside a binding invite, run by a host in one
|
|
161
|
+
* scope task and transaction. Bounded here: the caller must hold the binding's key on the record
|
|
162
|
+
* (`allowed`, the checker's `check` for the caller). Clears the record's column (every row with
|
|
163
|
+
* its id) and releases every holder of the shape on it from the spine — whoever a link bound,
|
|
164
|
+
* whatever the column says now, and a holder given the shape before the column was written —
|
|
165
|
+
* with one `entity.holder-unbound` event each through `emit`, whose actor the host stamps as the
|
|
166
|
+
* caller. `unbound` names everyone released; a refusal writes nothing.
|
|
167
|
+
*/
|
|
168
|
+
export async function unbindEntityHolderBounded(deps, entity) {
|
|
169
|
+
const object = entityObjectRef(entity, 'unbind');
|
|
170
|
+
const binding = entityBindingOf(deps.sql, entity.entityType);
|
|
171
|
+
if (!binding)
|
|
172
|
+
return { ok: false, refused: 'bind-not-declared' };
|
|
173
|
+
if (!(await deps.allowed(binding.permission, entity)))
|
|
174
|
+
return lacking(binding.permission);
|
|
175
|
+
clearColumn(deps.sql, binding, entity.entityId);
|
|
176
|
+
const released = releaseHolders(deps.sql, object, deps.now);
|
|
177
|
+
for (const { principal, removed } of released) {
|
|
178
|
+
const payload = { entity, principal, removed };
|
|
179
|
+
deps.emit({ type: ENTITY_HOLDER_UNBOUND, schemaVersion: 1, entity, piiClass: 'none', payload });
|
|
180
|
+
}
|
|
181
|
+
return { ok: true, unbound: released.map((r) => r.principal) };
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Every binding the erasure of `subjectId` reaches, by the spine and by the column: on each type the
|
|
185
|
+
* scope binds or has ever bound (`shape-bound`) — the id matched against every such type, as a
|
|
186
|
+
* module's declared erasure matches its subject columns whatever the type, so ids that are not
|
|
187
|
+
* ULIDs (an integer, say) can collide across types — the record that IS the subject (every holder on it) and every record the subject
|
|
188
|
+
* holds the shape on (their own marker), plus the rows whose column names the subject or that are
|
|
189
|
+
* the subject. Read BEFORE any declared blank, delete or hook runs, so a row a module's erasure
|
|
190
|
+
* deletes is still known. A scope that binds nothing pays the one read of its shape records.
|
|
191
|
+
*/
|
|
192
|
+
export function captureBoundOf(sql, subjectId) {
|
|
193
|
+
const out = { holders: [], columns: [] };
|
|
194
|
+
const bindings = new Map(entityBindingsOf(sql).map((b) => [b.entityType, b]));
|
|
195
|
+
// Every type that binds now, and every type that ever bound here (`shape-bound`, sticky).
|
|
196
|
+
const types = new Set([
|
|
197
|
+
...bindings.keys(),
|
|
198
|
+
...sql
|
|
199
|
+
.query(`SELECT subject FROM _substrat_tuples WHERE subject >= 'shape:' AND subject < 'shape;' AND relation = ?`, [
|
|
200
|
+
BOUND_EVER_RELATION,
|
|
201
|
+
])
|
|
202
|
+
.map((r) => r.subject.slice('shape:'.length)),
|
|
203
|
+
]);
|
|
204
|
+
for (const entityType of types) {
|
|
205
|
+
const prefix = `${entityType}:`;
|
|
206
|
+
out.holders.push({ object: `${prefix}${subjectId}` });
|
|
207
|
+
for (const { object } of sql.query(`SELECT object FROM _substrat_tuples
|
|
208
|
+
WHERE subject = ? AND relation = '${ENTITY_SHAPE_MARKER_RELATION}' AND revoked_at IS NULL AND object >= ? AND object < ?`, [`${PRINCIPAL}${subjectId}`, prefix, `${entityType};`])) {
|
|
209
|
+
out.holders.push({ object, only: subjectId });
|
|
210
|
+
}
|
|
211
|
+
// The column only where the holder is still recorded: a type a later version stopped binding
|
|
212
|
+
// has no column the kernel still knows, and its holders are released from the spine alone.
|
|
213
|
+
const binding = bindings.get(entityType);
|
|
214
|
+
if (!binding || !tableExists(switchSqlOf(sql), binding.table))
|
|
215
|
+
continue;
|
|
216
|
+
for (const r of sql.query(`SELECT "${binding.idColumn}" AS id, "${binding.principalColumn}" AS principal FROM "${binding.table}"
|
|
217
|
+
WHERE ("${binding.idColumn}" = ? OR "${binding.principalColumn}" = ?) AND "${binding.principalColumn}" IS NOT NULL`, [subjectId, subjectId])) {
|
|
218
|
+
out.columns.push({ binding, entityId: String(r.id), principal: r.principal });
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return out;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* The erasure's unbind, after the module hooks: each captured column cleared where the row survived
|
|
225
|
+
* and still names that person, and each captured holder released from the spine whether or not
|
|
226
|
+
* its row survived. No event: an event naming the erased subject would be a new copy of what is
|
|
227
|
+
* being erased.
|
|
228
|
+
*/
|
|
229
|
+
export function releaseBound(sql, captured, now) {
|
|
230
|
+
for (const { binding, entityId, principal } of captured.columns)
|
|
231
|
+
clearColumn(sql, binding, entityId, principal);
|
|
232
|
+
for (const { object, only } of captured.holders)
|
|
233
|
+
releaseHolders(sql, object, now, only);
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=entity-binding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-binding.js","sourceRoot":"","sources":["../src/entity-binding.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,4BAA4B,EAC5B,eAAe,EACf,aAAa,EACb,aAAa,GAUd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACrJ,OAAO,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAwCjD,MAAM,SAAS,GAAG,YAAY,CAAC;AAC/B,MAAM,OAAO,GAAG,UAAU,CAAC;AAC3B,MAAM,iBAAiB,GAAG,CAAC,oBAAoB,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,4BAA4B,CAAU,CAAC;AAErI,kFAAkF;AAClF,SAAS,WAAW,CAAC,UAAkB,EAAE,IAAqD;IAC5F,MAAM,EAAE,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAClG,MAAM,MAAM,GAAG,EAAE,CAAC,oBAAoB,CAAC,CAAC;IACxC,MAAM,UAAU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QAChF,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,GAAc,EAAE,QAAyB,EAAE,GAAW;IACjF,KAAK,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,QAAQ,CAAC,OAAO;QAAE,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAChH,KAAK,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,QAAQ,CAAC,OAAO;QAAE,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -36,13 +36,25 @@ import type { SwitchSql } from './system-switch.js';
|
|
|
36
36
|
* the principal; a table column naming the principal), and a person is marked only on their
|
|
37
37
|
* own record, and only when they hold a row there (live or tombstoned) for some key of the
|
|
38
38
|
* shape — evidence they were given it. Someone `ctx.grant`ed even the whole shape on another
|
|
39
|
-
* person's record is never marked. A shape with no `holder` gets no backfill.
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
39
|
+
* person's record is never marked. A shape with no `holder` gets no backfill. It is read in
|
|
40
|
+
* windows like the walks (#2154): each pass reads at most its read budget of rows, in an index
|
|
41
|
+
* order, marks at most its write budget, and hands back the last row it read as the cursor's
|
|
42
|
+
* `row`, so the next pass seeks past it rather than re-reading from the start. A record tuple
|
|
43
|
+
* (`shape:<type>`, `shape-backfilled`, `scope:<id>`) ends it once a read reaches the end of the
|
|
44
|
+
* range, and never before. A table holder's read is keyed on `idColumn` and then the row's own
|
|
45
|
+
* identity (its `rowid`, or a `WITHOUT ROWID` table's primary key), because nothing makes
|
|
46
|
+
* `idColumn` unique or the principal non-NULL, and a key that ties lets a window's edge skip a row.
|
|
47
|
+
*
|
|
48
|
+
* The cut-off is the cursor. Evidence that lands behind it while the backfill runs (a direct
|
|
49
|
+
* grant of a shape key to the person on their own record, for `'self'` or a table holder) is not
|
|
50
|
+
* marked, and once the record is written nothing is: the same accepted gap as a grant landing
|
|
51
|
+
* after the record. There is deliberately no confirming walk, as a retirement has: it would
|
|
52
|
+
* double every first backfill's reads to catch a grant that a shape grant should have made. For
|
|
53
|
+
* `'grantee'` nothing can land at all, since the first pass records the grantee keys and the
|
|
54
|
+
* tuple writer refuses them to every other grant from then on.
|
|
43
55
|
* - `holder: 'grantee'` (#2083), for a record that names no principal (a portal customer, a
|
|
44
56
|
* contact): whoever holds a live current or retired key of the shape on such an entity was given it.
|
|
45
|
-
* Each
|
|
57
|
+
* Each reconcile records current and retired keys (`shape-grantee-key`), and the explicit tuple
|
|
46
58
|
* writer makes non-shape grants refuse them on that entity type. A tuple from before the
|
|
47
59
|
* first such pass cannot be told apart. A marker already written by a shape grant persists
|
|
48
60
|
* through retirement, so its holder receives the new keys even if their old key was K alone.
|
|
@@ -65,7 +77,8 @@ export declare const SHAPE_MARKER_INDEX_DDL = "CREATE INDEX IF NOT EXISTS _subst
|
|
|
65
77
|
/** Holders topped up per pass — one transaction each, so a large scope never holds one long. */
|
|
66
78
|
export declare const SHAPE_TOP_UP_BATCH = 500;
|
|
67
79
|
/**
|
|
68
|
-
*
|
|
80
|
+
* Rows a pass may READ, per row of work it may write: markers on a walk, and the tuples or table
|
|
81
|
+
* rows the backfill reads for candidates (#2154). The budget bounds writes, but finding
|
|
69
82
|
* the holders who need one means reading past the ones who do not, and on a scope where nobody
|
|
70
83
|
* does (the common reconcile: nothing changed) that is every marker. Ten per row keeps a pass at
|
|
71
84
|
* 5000 index rows by default, short on any scope, while a rollout still spends most of each pass
|
|
@@ -121,6 +134,15 @@ export interface ShapeCursor {
|
|
|
121
134
|
object: string;
|
|
122
135
|
subject: string;
|
|
123
136
|
} | null;
|
|
137
|
+
/**
|
|
138
|
+
* The backfill only (#2154): the sort key of the last row its read reached, `[object, relation,
|
|
139
|
+
* subject]` of a tuple for a `'self'` or `'grantee'` holder, `[id, rowid]` for a table holder
|
|
140
|
+
* (`[id, …primary key]` for a `WITHOUT ROWID` table). Absent
|
|
141
|
+
* or `null` reads the backfill from its start, which is always safe: a pair it already marked
|
|
142
|
+
* is no longer a candidate, so a cursor from before this field (or one a rollback ignores) only
|
|
143
|
+
* costs a re-read.
|
|
144
|
+
*/
|
|
145
|
+
row?: readonly (string | number)[] | null;
|
|
124
146
|
/**
|
|
125
147
|
* A confirming retire walk only: whether it has taken nothing so far, and how many confirming
|
|
126
148
|
* walks before it, on this shape in this reconcile, took keys.
|
|
@@ -148,12 +170,15 @@ export interface ShapePass {
|
|
|
148
170
|
}
|
|
149
171
|
/**
|
|
150
172
|
* One pass of the reconcile over one scope, at most `limit` rows of work and
|
|
151
|
-
* `limit × SHAPE_MARKER_READS_PER_ROW`
|
|
173
|
+
* `limit × SHAPE_MARKER_READS_PER_ROW` rows read (markers, and the backfill's tuples or table
|
|
174
|
+
* rows): backfill marks for any shape whose backfill
|
|
152
175
|
* is not done here, then holders whose retired keys are taken back, each with its
|
|
153
176
|
* `entity.grants-retired` event, then holders topped up, each with its `entity.grants-topped-up`
|
|
154
177
|
* event. `next` is `null` once the scope is done; otherwise the caller runs another pass with it
|
|
155
178
|
* as `after`. `retirementsLeftOpen` counts the shapes whose retirement this pass gave up on at
|
|
156
|
-
* `SHAPE_RETIRE_CONFIRMS_MAX`, for the next reconcile to run again.
|
|
179
|
+
* `SHAPE_RETIRE_CONFIRMS_MAX`, for the next reconcile to run again. The last pass (`next: null`)
|
|
180
|
+
* also answers `boundEver` (#2184): every type this scope has ever bound (`shape-bound`), read
|
|
181
|
+
* after this reconcile recorded its facts, for the platform's binding-shape gate. Run it inside ONE
|
|
157
182
|
* transaction, so the keys and their events commit together. Re-running a finished scope writes
|
|
158
183
|
* nothing.
|
|
159
184
|
*/
|
|
@@ -162,5 +187,26 @@ export declare function topUpEntityGrantShapes(db: SwitchSql, pass: ShapePass):
|
|
|
162
187
|
retired: number;
|
|
163
188
|
retirementsLeftOpen: number;
|
|
164
189
|
next: ShapeCursor | null;
|
|
190
|
+
boundEver?: string[];
|
|
165
191
|
};
|
|
192
|
+
/**
|
|
193
|
+
* A BINDING shape's record (#1686), on the scope's tuple spine beside the grantee keys: which
|
|
194
|
+
* table column names the record's person (`<table>.<idColumn>.<principalColumn>`), the key that
|
|
195
|
+
* lets someone bind or unbind them, and the shape's current keys — what a binding invite's claim
|
|
196
|
+
* gives. The claim and an unbind read these, never the vertical's code: the shape is the reviewed
|
|
197
|
+
* registry the platform last reconciled this scope with. Each identifier is a SQL identifier, so
|
|
198
|
+
* `.` cannot occur inside one.
|
|
199
|
+
*/
|
|
200
|
+
export declare const BIND_HOLDER_RELATION = "shape-bind-holder";
|
|
201
|
+
export declare const BIND_PERMISSION_RELATION = "shape-bind-permission";
|
|
202
|
+
export declare const BIND_KEY_RELATION = "shape-bind-key";
|
|
203
|
+
/**
|
|
204
|
+
* `(shape:<type>, shape-bound, bound)`: this scope has declared a binding for `<type>` (#1686).
|
|
205
|
+
* Written by the first reconcile that records the binding (and by every claim, to the same effect)
|
|
206
|
+
* and STICKY — no reconcile removes it, whatever later
|
|
207
|
+
* versions declare — so an erasure keeps releasing that type's holders after a version drops the
|
|
208
|
+
* shape, drops its `bind` or moves its holder column. A spine tuple like the others here, so
|
|
209
|
+
* module code can never write one (`ctx.sql` refuses every `_substrat_*` write).
|
|
210
|
+
*/
|
|
211
|
+
export declare const BOUND_EVER_RELATION = "shape-bound";
|
|
166
212
|
//# sourceMappingURL=entity-grant-shape.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity-grant-shape.d.ts","sourceRoot":"","sources":["../src/entity-grant-shape.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"entity-grant-shape.d.ts","sourceRoot":"","sources":["../src/entity-grant-shape.ts"],"names":[],"mappings":"AAAA,OAAO,EAWL,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,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