@powerhousedao/shared 6.2.2-dev.42 → 6.2.2-dev.44
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/clis/args/{common-B_LcTLHX.d.mts → common-jbDGxlex.d.mts} +3 -3
- package/dist/clis/args/{common-B_LcTLHX.d.mts.map → common-jbDGxlex.d.mts.map} +1 -1
- package/dist/clis/args/common.d.mts +1 -1
- package/dist/clis/args/connect.d.mts +5 -5
- package/dist/clis/args/index.d.mts +2 -2
- package/dist/clis/args/{service-51afW_Hz.d.mts → service-C88bN_g_.d.mts} +2 -2
- package/dist/clis/args/{service-51afW_Hz.d.mts.map → service-C88bN_g_.d.mts.map} +1 -1
- package/dist/clis/args/service.d.mts +1 -1
- package/dist/clis/args/vetra.d.mts +1 -1
- package/dist/clis/index.d.mts +1 -1
- package/dist/connect/config-loader.d.ts +1 -1
- package/dist/connect/index.d.ts +1 -1
- package/dist/document-drive/index.d.ts +2 -2
- package/dist/document-model/index.d.ts +3 -3
- package/dist/document-model/index.js +257 -19
- package/dist/document-model/index.js.map +1 -1
- package/dist/{index-Dn1S-xxm.d.ts → index-Cvll3fU3.d.ts} +64 -10
- package/dist/index-Cvll3fU3.d.ts.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/processors/index.d.ts +1 -1
- package/dist/registry/index.d.ts +2 -2
- package/dist/registry/manifest-slim.d.ts +1 -1
- package/dist/{types-C_b4aIlv.d.ts → types-Bhq_MqKc.d.ts} +25 -2
- package/dist/types-Bhq_MqKc.d.ts.map +1 -0
- package/dist/{types-DctifWUG.d.ts → types-CL4NKiAO.d.ts} +2 -2
- package/dist/{types-DctifWUG.d.ts.map → types-CL4NKiAO.d.ts.map} +1 -1
- package/package.json +1 -1
- package/dist/index-Dn1S-xxm.d.ts.map +0 -1
- package/dist/types-C_b4aIlv.d.ts.map +0 -1
|
@@ -134,6 +134,25 @@ var HashMismatchError = class extends Error {
|
|
|
134
134
|
return this._operation;
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
|
+
/**
|
|
138
|
+
* Thrown when replay or import requires a document model version that is not
|
|
139
|
+
* registered. Carries the data the UI needs to explain the mismatch.
|
|
140
|
+
*/
|
|
141
|
+
var UnsupportedDocumentModelVersionError = class extends Error {
|
|
142
|
+
documentType;
|
|
143
|
+
requiredVersion;
|
|
144
|
+
availableVersions;
|
|
145
|
+
constructor(documentType, requiredVersion, availableVersions) {
|
|
146
|
+
super(`No reducer registered for document version ${requiredVersion}. Available versions: ${availableVersions.join(", ")}`);
|
|
147
|
+
this.name = "UnsupportedDocumentModelVersionError";
|
|
148
|
+
this.documentType = documentType;
|
|
149
|
+
this.requiredVersion = requiredVersion;
|
|
150
|
+
this.availableVersions = availableVersions;
|
|
151
|
+
}
|
|
152
|
+
static isError(error) {
|
|
153
|
+
return Error.isError(error) && error.name === "UnsupportedDocumentModelVersionError";
|
|
154
|
+
}
|
|
155
|
+
};
|
|
137
156
|
//#endregion
|
|
138
157
|
//#region document-model/schemas.ts
|
|
139
158
|
const isDefinedNonNullAny = (v) => v !== void 0 && v !== null;
|
|
@@ -1005,7 +1024,14 @@ const actions = {
|
|
|
1005
1024
|
//#endregion
|
|
1006
1025
|
//#region document-model/document-type.ts
|
|
1007
1026
|
const documentModelDocumentType = "powerhouse/document-model";
|
|
1008
|
-
const groupDocumentType = "
|
|
1027
|
+
const groupDocumentType = "powerhouse/reactor-group";
|
|
1028
|
+
/**
|
|
1029
|
+
* The group-model action types that change membership. The groups projection
|
|
1030
|
+
* filters its reads to these, so any other group operation is invisible to a
|
|
1031
|
+
* decision. Kept here so the reactor never depends on the group package; a
|
|
1032
|
+
* reactor-group test guards against drift.
|
|
1033
|
+
*/
|
|
1034
|
+
const groupMembershipActionTypes = ["ADD_MEMBER", "REMOVE_MEMBER"];
|
|
1009
1035
|
//#endregion
|
|
1010
1036
|
//#region document-model/auth-v1.ts
|
|
1011
1037
|
/** Maximum number of grants in a policy. */
|
|
@@ -1211,7 +1237,7 @@ function assertValidGrant(grant, documentType) {
|
|
|
1211
1237
|
const grantId = isPlainValue(grant) && typeof grant.id === "string" ? grant.id : "";
|
|
1212
1238
|
const problem = grantProblem(grant);
|
|
1213
1239
|
if (problem !== null) throw new InvalidGrantError(grantId, problem);
|
|
1214
|
-
if (documentType === "
|
|
1240
|
+
if (documentType === "powerhouse/reactor-group" && "group" in grant.principal) throw new GroupPrincipalNotAllowedError(grantId);
|
|
1215
1241
|
}
|
|
1216
1242
|
/**
|
|
1217
1243
|
* Validates an initial grant list: the count cap, every grant, and — on a
|
|
@@ -1285,6 +1311,158 @@ function assertAuthAdministrationRetained(creator, previous, next, grantId) {
|
|
|
1285
1311
|
if (creator !== void 0) return;
|
|
1286
1312
|
if (administrationReachable(previous) && !administrationReachable(next)) throw new AuthAdministrationLockoutError(grantId);
|
|
1287
1313
|
}
|
|
1314
|
+
/**
|
|
1315
|
+
* An operand whose shape validation would have rejected. Distinguished from
|
|
1316
|
+
* an unresolved path so a structurally malformed operand poisons its whole
|
|
1317
|
+
* condition to false rather than reading as "absent", which `not` would
|
|
1318
|
+
* otherwise widen to true.
|
|
1319
|
+
*/
|
|
1320
|
+
const INVALID_OPERAND = Symbol("invalid-operand");
|
|
1321
|
+
/**
|
|
1322
|
+
* Narrows to the values conditions compare. An object, array, or non-finite
|
|
1323
|
+
* number resolves to undefined, and every comparison involving undefined is
|
|
1324
|
+
* false.
|
|
1325
|
+
*/
|
|
1326
|
+
function asConditionValue(value) {
|
|
1327
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
1328
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* Resolves one operand. Attr roots: `subject.*`, `doc.<scope>.*` where the
|
|
1332
|
+
* scope must be the executing scope (validation already rejects any other,
|
|
1333
|
+
* but resolution stays total), and `action.input.*`. Path steps read own
|
|
1334
|
+
* properties only, so prototype members can never influence a verdict.
|
|
1335
|
+
*/
|
|
1336
|
+
function resolveOperand(operand, subject, request, conditions) {
|
|
1337
|
+
if (!isPlainValue(operand)) return INVALID_OPERAND;
|
|
1338
|
+
const keys = Object.keys(operand);
|
|
1339
|
+
if (keys.length !== 1) return INVALID_OPERAND;
|
|
1340
|
+
if (keys[0] === "lit") {
|
|
1341
|
+
const value = asConditionValue(operand.lit);
|
|
1342
|
+
return value === void 0 ? INVALID_OPERAND : value;
|
|
1343
|
+
}
|
|
1344
|
+
if (keys[0] !== "attr") return INVALID_OPERAND;
|
|
1345
|
+
const attr = operand.attr;
|
|
1346
|
+
if (typeof attr !== "string" || attr.length === 0) return INVALID_OPERAND;
|
|
1347
|
+
const path = attr.split(".");
|
|
1348
|
+
let value;
|
|
1349
|
+
let rest;
|
|
1350
|
+
if (path[0] === "subject") {
|
|
1351
|
+
value = subject;
|
|
1352
|
+
rest = path.slice(1);
|
|
1353
|
+
} else if (path[0] === "doc") {
|
|
1354
|
+
if (path[1] !== request.scope) return;
|
|
1355
|
+
value = conditions.scopeState;
|
|
1356
|
+
rest = path.slice(2);
|
|
1357
|
+
} else if (path[0] === "action" && path[1] === "input") {
|
|
1358
|
+
value = conditions.actionInput;
|
|
1359
|
+
rest = path.slice(2);
|
|
1360
|
+
} else return;
|
|
1361
|
+
for (const segment of rest) {
|
|
1362
|
+
if (!isPlainValue(value) || !Object.hasOwn(value, segment)) return;
|
|
1363
|
+
value = value[segment];
|
|
1364
|
+
}
|
|
1365
|
+
return asConditionValue(value);
|
|
1366
|
+
}
|
|
1367
|
+
/**
|
|
1368
|
+
* Total order within one type: numbers numerically, strings by code point.
|
|
1369
|
+
* Everything else, including mixed types, does not order.
|
|
1370
|
+
*/
|
|
1371
|
+
function compareValues(left, right) {
|
|
1372
|
+
if (typeof left === "number" && typeof right === "number") return left < right ? -1 : left > right ? 1 : 0;
|
|
1373
|
+
if (typeof left === "string" && typeof right === "string") {
|
|
1374
|
+
const leftPoints = Array.from(left);
|
|
1375
|
+
const rightPoints = Array.from(right);
|
|
1376
|
+
const shared = Math.min(leftPoints.length, rightPoints.length);
|
|
1377
|
+
for (let i = 0; i < shared; i++) {
|
|
1378
|
+
const a = leftPoints[i].codePointAt(0) ?? 0;
|
|
1379
|
+
const b = rightPoints[i].codePointAt(0) ?? 0;
|
|
1380
|
+
if (a !== b) return a < b ? -1 : 1;
|
|
1381
|
+
}
|
|
1382
|
+
return leftPoints.length === rightPoints.length ? 0 : leftPoints.length < rightPoints.length ? -1 : 1;
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
/**
|
|
1386
|
+
* Tri-state evaluation: undefined marks a structurally invalid node, which
|
|
1387
|
+
* poisons the whole tree to false at the top — and a structurally malformed
|
|
1388
|
+
* operand poisons its condition the same way. Both are distinct from an
|
|
1389
|
+
* operand whose path fails to resolve, which is a valid comparison that is
|
|
1390
|
+
* false. The distinction keeps `not` from widening over malformed input.
|
|
1391
|
+
*/
|
|
1392
|
+
function evaluateNode(node, subject, request, conditions) {
|
|
1393
|
+
if (!isPlainValue(node)) return;
|
|
1394
|
+
const keys = Object.keys(node);
|
|
1395
|
+
if (keys.length !== 1) return;
|
|
1396
|
+
const kind = keys[0];
|
|
1397
|
+
const body = node[kind];
|
|
1398
|
+
switch (kind) {
|
|
1399
|
+
case "eq":
|
|
1400
|
+
case "ne":
|
|
1401
|
+
case "lt":
|
|
1402
|
+
case "lte":
|
|
1403
|
+
case "gt":
|
|
1404
|
+
case "gte": {
|
|
1405
|
+
if (!Array.isArray(body) || body.length !== 2) return;
|
|
1406
|
+
const left = resolveOperand(body[0], subject, request, conditions);
|
|
1407
|
+
const right = resolveOperand(body[1], subject, request, conditions);
|
|
1408
|
+
if (left === INVALID_OPERAND || right === INVALID_OPERAND) return;
|
|
1409
|
+
if (left === void 0 || right === void 0) return false;
|
|
1410
|
+
if (kind === "eq") return left === right;
|
|
1411
|
+
if (kind === "ne") return left !== right;
|
|
1412
|
+
const order = compareValues(left, right);
|
|
1413
|
+
if (order === void 0) return false;
|
|
1414
|
+
switch (kind) {
|
|
1415
|
+
case "lt": return order < 0;
|
|
1416
|
+
case "lte": return order <= 0;
|
|
1417
|
+
case "gt": return order > 0;
|
|
1418
|
+
case "gte": return order >= 0;
|
|
1419
|
+
}
|
|
1420
|
+
return;
|
|
1421
|
+
}
|
|
1422
|
+
case "in":
|
|
1423
|
+
case "notIn": {
|
|
1424
|
+
if (!Array.isArray(body) || body.length !== 2 || !Array.isArray(body[1])) return;
|
|
1425
|
+
const left = resolveOperand(body[0], subject, request, conditions);
|
|
1426
|
+
if (left === INVALID_OPERAND) return;
|
|
1427
|
+
const elements = body[1].map((element) => resolveOperand(element, subject, request, conditions));
|
|
1428
|
+
if (elements.some((value) => value === INVALID_OPERAND)) return;
|
|
1429
|
+
if (left === void 0) return false;
|
|
1430
|
+
const found = elements.some((value) => value !== void 0 && value === left);
|
|
1431
|
+
return kind === "in" ? found : !found;
|
|
1432
|
+
}
|
|
1433
|
+
case "exists": {
|
|
1434
|
+
const value = resolveOperand(body, subject, request, conditions);
|
|
1435
|
+
if (value === INVALID_OPERAND) return;
|
|
1436
|
+
return value !== void 0;
|
|
1437
|
+
}
|
|
1438
|
+
case "and":
|
|
1439
|
+
case "or": {
|
|
1440
|
+
if (!Array.isArray(body)) return;
|
|
1441
|
+
let result = kind === "and";
|
|
1442
|
+
for (const child of body) {
|
|
1443
|
+
const value = evaluateNode(child, subject, request, conditions);
|
|
1444
|
+
if (value === void 0) return;
|
|
1445
|
+
if (kind === "and") result = result && value;
|
|
1446
|
+
else result = result || value;
|
|
1447
|
+
}
|
|
1448
|
+
return result;
|
|
1449
|
+
}
|
|
1450
|
+
case "not": {
|
|
1451
|
+
const value = evaluateNode(body, subject, request, conditions);
|
|
1452
|
+
return value === void 0 ? void 0 : !value;
|
|
1453
|
+
}
|
|
1454
|
+
default: return;
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
/**
|
|
1458
|
+
* Evaluates a version-1 condition. Deterministic, total, and pure: any input
|
|
1459
|
+
* shape yields a boolean and never throws, and a malformed condition is
|
|
1460
|
+
* false. These are consensus semantics, versioned by `PHAuthState.version`;
|
|
1461
|
+
* changing them requires a new version.
|
|
1462
|
+
*/
|
|
1463
|
+
function evaluateCondition(condition, subject, request, conditions) {
|
|
1464
|
+
return evaluateNode(condition, subject, request, conditions) === true;
|
|
1465
|
+
}
|
|
1288
1466
|
function capabilityCovers(capability, request) {
|
|
1289
1467
|
if (capability.can !== request.verb) return false;
|
|
1290
1468
|
const scope = capability.scope;
|
|
@@ -1295,21 +1473,46 @@ function capabilityCovers(capability, request) {
|
|
|
1295
1473
|
}
|
|
1296
1474
|
return true;
|
|
1297
1475
|
}
|
|
1298
|
-
function principalMatches(principal, subject) {
|
|
1476
|
+
function principalMatches(principal, subject, request, groups, conditions) {
|
|
1299
1477
|
if ("anyone" in principal) return true;
|
|
1300
1478
|
if ("address" in principal) return subject.address !== void 0 && subject.address.toLowerCase() === principal.address.toLowerCase();
|
|
1479
|
+
if ("group" in principal) {
|
|
1480
|
+
if (groups === void 0 || subject.address === void 0) return false;
|
|
1481
|
+
const group = groups[principal.group];
|
|
1482
|
+
if (group === void 0 || !Array.isArray(group.members)) return false;
|
|
1483
|
+
const address = subject.address.toLowerCase();
|
|
1484
|
+
return group.members.some((member) => member.toLowerCase() === address);
|
|
1485
|
+
}
|
|
1486
|
+
if ("match" in principal) {
|
|
1487
|
+
if (conditions === void 0) return false;
|
|
1488
|
+
return evaluateCondition(principal.match, subject, request, conditions);
|
|
1489
|
+
}
|
|
1301
1490
|
return false;
|
|
1302
1491
|
}
|
|
1303
1492
|
/**
|
|
1493
|
+
* The group document ids named by `{ group }` principals in a grant list, in
|
|
1494
|
+
* order of first appearance. These are the streams the groups projection reads.
|
|
1495
|
+
*/
|
|
1496
|
+
function referencedGroupIds(grants) {
|
|
1497
|
+
const ids = [];
|
|
1498
|
+
for (const grant of grants) if ("group" in grant.principal && !ids.includes(grant.principal.group)) ids.push(grant.principal.group);
|
|
1499
|
+
return ids;
|
|
1500
|
+
}
|
|
1501
|
+
/**
|
|
1304
1502
|
* Evaluates a v1 grant stack: default deny, last applicable grant wins, and
|
|
1305
|
-
* reports which grant decided it. Group
|
|
1306
|
-
*
|
|
1503
|
+
* reports which grant decided it. Group principals match only against a
|
|
1504
|
+
* supplied groups map, and `where` clauses and { match } principals evaluate
|
|
1505
|
+
* only against a supplied condition context; a grant that uses an unsupplied
|
|
1506
|
+
* feature never applies.
|
|
1307
1507
|
*/
|
|
1308
|
-
function evaluateGrantStack(grants, subject, request) {
|
|
1508
|
+
function evaluateGrantStack(grants, subject, request, groups, conditions) {
|
|
1309
1509
|
let applicable;
|
|
1310
1510
|
for (const grant of grants) {
|
|
1311
|
-
if (grant.where !== void 0)
|
|
1312
|
-
|
|
1511
|
+
if (grant.where !== void 0) {
|
|
1512
|
+
if (conditions === void 0) continue;
|
|
1513
|
+
if (!evaluateCondition(grant.where, subject, request, conditions)) continue;
|
|
1514
|
+
}
|
|
1515
|
+
if (capabilityCovers(grant.capability, request) && principalMatches(grant.principal, subject, request, groups, conditions)) applicable = grant;
|
|
1313
1516
|
}
|
|
1314
1517
|
if (applicable === void 0) return {
|
|
1315
1518
|
decision: "deny",
|
|
@@ -1326,8 +1529,8 @@ function evaluateGrantStack(grants, subject, request) {
|
|
|
1326
1529
|
* Evaluates a v1 grant stack: default deny, last applicable grant wins. This is
|
|
1327
1530
|
* {@link evaluateGrantStack} with the reason dropped.
|
|
1328
1531
|
*/
|
|
1329
|
-
function evaluateGrants(grants, subject, request) {
|
|
1330
|
-
return evaluateGrantStack(grants, subject, request).decision;
|
|
1532
|
+
function evaluateGrants(grants, subject, request, groups, conditions) {
|
|
1533
|
+
return evaluateGrantStack(grants, subject, request, groups, conditions).decision;
|
|
1331
1534
|
}
|
|
1332
1535
|
//#endregion
|
|
1333
1536
|
//#region document-model/constants.ts
|
|
@@ -2252,22 +2455,49 @@ function assertAuthScopeActionAllowed(action) {
|
|
|
2252
2455
|
* An uninitialized policy (version 0, absent auth state, or a legacy `{}`
|
|
2253
2456
|
* auth scope serialized before PHAuthState had a version) leaves the document
|
|
2254
2457
|
* open. Once a policy exists the default is deny, and grants stack in order.
|
|
2458
|
+
*
|
|
2459
|
+
* Group principals match only against a supplied groups map (the groups
|
|
2460
|
+
* projection, present when authGroups is on); with no map they never apply.
|
|
2461
|
+
* `where` clauses and { match } principals likewise evaluate only against a
|
|
2462
|
+
* supplied condition context (present when authConditions is on).
|
|
2255
2463
|
*/
|
|
2256
|
-
function evaluate(auth, subject, request) {
|
|
2464
|
+
function evaluate(auth, subject, request, groups, conditions) {
|
|
2257
2465
|
if (!auth || !auth.version) return { decision: "allow" };
|
|
2258
2466
|
if (request.verb === "execute" && request.scope === "auth" && subject.key !== void 0 && subject.key === auth.creator) return { decision: "allow" };
|
|
2259
2467
|
if (auth.version > 1) return {
|
|
2260
2468
|
decision: "deny",
|
|
2261
2469
|
refusal: "version-unsupported"
|
|
2262
2470
|
};
|
|
2263
|
-
return evaluateGrantStack(auth.grants, subject, request);
|
|
2471
|
+
return evaluateGrantStack(auth.grants, subject, request, groups, conditions);
|
|
2264
2472
|
}
|
|
2265
2473
|
/**
|
|
2266
2474
|
* Evaluates the auth policy for a single request. Pure and deterministic. This
|
|
2267
2475
|
* is {@link evaluate} with the reason dropped.
|
|
2268
2476
|
*/
|
|
2269
|
-
function decide(auth, subject, request) {
|
|
2270
|
-
return evaluate(auth, subject, request).decision;
|
|
2477
|
+
function decide(auth, subject, request, groups, conditions) {
|
|
2478
|
+
return evaluate(auth, subject, request, groups, conditions).decision;
|
|
2479
|
+
}
|
|
2480
|
+
/**
|
|
2481
|
+
* The group document ids a single auth action's input names with `{ group }`
|
|
2482
|
+
* principals. INITIALIZE_AUTH contributes the groups named across its grants,
|
|
2483
|
+
* SET_GRANT the groups named by its one grant; REMOVE_GRANT and MOVE_GRANT
|
|
2484
|
+
* contribute nothing. Total over any input shape, because references are read
|
|
2485
|
+
* from the input as it arrived, including inputs later stored as errors.
|
|
2486
|
+
*/
|
|
2487
|
+
function mentionedGroupIds(action) {
|
|
2488
|
+
const input = action.input;
|
|
2489
|
+
const candidates = [];
|
|
2490
|
+
if (action.type === "INITIALIZE_AUTH" && Array.isArray(input?.grants)) candidates.push(...input.grants);
|
|
2491
|
+
if (action.type === "SET_GRANT" && input?.grant !== void 0) candidates.push(input.grant);
|
|
2492
|
+
const ids = [];
|
|
2493
|
+
for (const candidate of candidates) {
|
|
2494
|
+
if (typeof candidate !== "object" || candidate === null) continue;
|
|
2495
|
+
const principal = candidate.principal;
|
|
2496
|
+
if (typeof principal !== "object" || principal === null) continue;
|
|
2497
|
+
const group = principal.group;
|
|
2498
|
+
if (typeof group === "string" && group !== "" && !ids.includes(group)) ids.push(group);
|
|
2499
|
+
}
|
|
2500
|
+
return ids;
|
|
2271
2501
|
}
|
|
2272
2502
|
//#endregion
|
|
2273
2503
|
//#region document-model/denied.ts
|
|
@@ -4318,6 +4548,17 @@ const documentModelStateReducer = (state, action) => {
|
|
|
4318
4548
|
const documentModelReducer = createReducer(documentModelStateReducer);
|
|
4319
4549
|
//#endregion
|
|
4320
4550
|
//#region document-model/upgrades.ts
|
|
4551
|
+
/**
|
|
4552
|
+
* Canonical document-model version normalization: documents stamped with 0
|
|
4553
|
+
* or nothing at all predate versioning and are treated as version 1, the
|
|
4554
|
+
* same version the registry assigns unversioned modules. Every consumer
|
|
4555
|
+
* that resolves a module or compares versions must use this rule; resolving
|
|
4556
|
+
* 0 to "latest" instead re-pins a legacy document's history to whichever
|
|
4557
|
+
* module happens to be newest.
|
|
4558
|
+
*/
|
|
4559
|
+
function normalizeDocumentModelVersion(version) {
|
|
4560
|
+
return version && version > 0 ? version : 1;
|
|
4561
|
+
}
|
|
4321
4562
|
function applyInitialState(document, action) {
|
|
4322
4563
|
const input = action.input;
|
|
4323
4564
|
const newState = input.initialState || input.state;
|
|
@@ -4497,10 +4738,7 @@ function replayDocumentVersioned(initialState, operations, config, header, dispa
|
|
|
4497
4738
|
const segmentEndHashPerScope = /* @__PURE__ */ new Map();
|
|
4498
4739
|
for (let k = 0; k <= validatedUpgrades.length; k++) {
|
|
4499
4740
|
const reducer = config.reducers[currentVersion];
|
|
4500
|
-
if (!reducer)
|
|
4501
|
-
const available = Object.keys(config.reducers).join(", ");
|
|
4502
|
-
throw new Error(`No reducer registered for document version ${currentVersion}. Available versions: ${available}`);
|
|
4503
|
-
}
|
|
4741
|
+
if (!reducer) throw new UnsupportedDocumentModelVersionError(header.documentType, currentVersion, Object.keys(config.reducers).map(Number).sort((a, b) => a - b));
|
|
4504
4742
|
for (const s of replayScopes) {
|
|
4505
4743
|
const ops = scopeOps[s] ?? [];
|
|
4506
4744
|
const segStart = k === 0 ? 0 : boundaries[k - 1]?.[s] ?? 0;
|
|
@@ -4742,6 +4980,6 @@ const getFileBrowser = (file) => {
|
|
|
4742
4980
|
return Promise.resolve().then(() => readFileBrowser(file));
|
|
4743
4981
|
};
|
|
4744
4982
|
//#endregion
|
|
4745
|
-
export { AUTH_ACTION_TYPES, AUTH_DENIED_BY_GRANT_REASON, AUTH_NO_GRANT_REASON, AUTH_VERSION_UNSUPPORTED_REASON, AddChangeLogItemInputSchema, AddModuleInputSchema, AddOperationErrorInputSchema, AddOperationExampleInputSchema, AddOperationInputSchema, AddStateExampleInputSchema, AuthActionNotAllowedError, AuthAdministrationLockoutError, AuthAdministrationMissingError, AuthAlreadyInitializedError, AuthInitializerNotCreatorError, AuthPolicyNotPreservedError, AuthorSchema, BaseDocumentHeaderSchema, BaseDocumentStateSchema, CodeExampleSchema, ConfigEntrySchema, ConfigEntryTypeSchema, DOCUMENT_DELETED_REASON, DeleteChangeLogItemInputSchema, DeleteModuleInputSchema, DeleteOperationErrorInputSchema, DeleteOperationExampleInputSchema, DeleteOperationInputSchema, DeleteStateExampleInputSchema, DocumentActionSchema, DocumentModelGlobalStateSchema, DocumentModelHeaderSchema, DocumentModelInputSchema, DocumentModelPHStateSchema, DocumentModelSchema, DocumentSpecificationSchema, DowngradeNotSupportedError, FileSystemError, GrantNotFoundError, GrantSchema, GroupPrincipalNotAllowedError, HASH_ALGORITHM_SHA1, HASH_ALGORITHM_SHA256, HASH_ALGORITHM_SHA512, HASH_ENCODING_BASE64, HASH_ENCODING_HEX, HashMismatchError, InitializeAuthActionInputSchema, IntegrityIssueSubType, IntegrityIssueType, InvalidActionInputError, InvalidActionInputZodError, InvalidAuthVersionError, InvalidGrantError, LoadStateActionInputSchema, LoadStateActionSchema, LoadStateActionStateInputSchema, Load_StateSchema, MAX_AUTH_GRANTS, MAX_CAPABILITY_OPERATIONS, MAX_CONDITION_DEPTH, MAX_CONDITION_NODES, MAX_SUPPORTED_AUTH_VERSION, ManifestSchema, ModuleSchema, MoveGrantActionInputSchema, MoveOperationInputSchema, OPERATION_NAME_PATTERN, OperationErrorSchema, OperationScopeSchema, OperationSpecificationSchema, PowerhouseModuleSchema, PowerhouseModulesSchema, PruneActionInputSchema, PruneActionSchema, PruneSchema, PublisherSchema, PwaConfigSchema, RESERVED_OPERATION_NAMES, RedoActionInputSchema, RedoActionSchema, RedoSchema, RemoveGrantActionInputSchema, ReorderChangeLogItemsInputSchema, ReorderModuleOperationsInputSchema, ReorderModulesInputSchema, ReorderOperationErrorsInputSchema, ReorderOperationExamplesInputSchema, ReorderStateExamplesInputSchema, ScopeStateSchema, SetAuthorNameInputSchema, SetAuthorWebsiteInputSchema, SetGrantActionInputSchema, SetInitialStateInputSchema, SetModelDescriptionInputSchema, SetModelExtensionInputSchema, SetModelIdInputSchema, SetModelNameInputSchema, SetModuleDescriptionInputSchema, SetModuleNameInputSchema, SetNameActionInputSchema, SetNameActionSchema, SetOperationDescriptionInputSchema, SetOperationErrorCodeInputSchema, SetOperationErrorDescriptionInputSchema, SetOperationErrorNameInputSchema, SetOperationErrorTemplateInputSchema, SetOperationNameInputSchema, SetOperationReducerInputSchema, SetOperationSchemaInputSchema, SetOperationScopeInputSchema, SetOperationTemplateInputSchema, SetPreferredEditorActionInputSchema, SetPreferredEditorActionSchema, SetStateSchemaInputSchema, Set_NameSchema, Set_PreferredEditorSchema, StateSchema, UndoActionInputSchema, UndoActionSchema, UndoSchema, UpdateChangeLogItemInputSchema, UpdateOperationExampleInputSchema, UpdateStateExampleInputSchema, ab2hex, actionContext, actionFromAction, actionSigner, actions, addChangeLogItem, addModule, addOperation, addOperationError, addOperationExample, addStateExample, addUndo, appendWithoutApplying, applyAuthAction, applyDeleteDocumentAction, applyInitializeAuthAction, applyMoveGrantAction, applyRemoveGrantAction, applySetGrantAction, applyUpgradeDocumentAction, assertAuthAdministrationRetained, assertAuthPreservedOnDuplicate, assertAuthScopeActionAllowed, assertIsDocumentModelDocument, assertIsDocumentModelState, assertModuleIdUnique, assertOperationErrorIdUnique, assertOperationExampleIdUnique, assertOperationIdUnique, assertValidGrant, assertValidGrantUpsert, assertValidInitialGrants, attachBranch, backfillAuthState, base58Decode, base64UrlToBytes, baseActions, baseCreateDocument, baseLoadFromInput, baseLoadFromInputVersioned, baseReducer, baseReducerVersion, baseSaveToFileHandle, buildOperationSignature, buildOperationSignatureMessage, buildOperationSignatureParams, buildSignedAction, checkCleanedOperationsIntegrity, checkOperationsIntegrity, computeUpgradeTransitions, createAction, createAuthState, createBaseState, createDocumentState, createGlobalState, createLocalState, createMinimalZip, createPresignedHeader, createReducer, createSignedHeader, createSignedHeaderForSigner, createState, createVerificationSigner, createZip, decide, defaultAuthState, defaultBaseState, defaultDocumentState, defaultGlobalState, defaultLocalState, defaultPHState, definedNonNullAnySchema, deleteChangeLogItem, deleteModule, deleteOperation, deleteOperationError, deleteOperationExample, deleteStateExample, deriveOperationId, diffOperations, documentModelActions, documentModelDocumentType, documentModelFileExtension, documentModelGlobalState, documentModelHeaderReducer, documentModelInitialGlobalState, documentModelInitialLocalState, documentModelLoadFromInput, documentModelModuleReducer, documentModelOperationErrorReducer, documentModelOperationExampleReducer, documentModelOperationReducer, documentModelReducer, documentModelSaveToFileHandle, documentModelStateReducer, documentModelStateSchemaReducer, documentModelVersioningReducer, evaluate, evaluateGrantStack, evaluateGrants, fetchFileBrowser, filterDocumentOperationsResultingState, filterDuplicatedOperations, findModuleOrThrow, findOperationErrorOrThrow, findOperationExampleOrThrow, findOperationOrThrow, garbageCollect, garbageCollectDocumentOperations, garbageCollectV2, generateId, generateMock, getAllOperationNames, getDocumentLastModified, getFileBrowser, getUnixTimestamp, grantProblem, groupDocumentType, groupOperationsByScope, hashBrowser, hashDocumentStateForScope, hex2ab, initializeAuth, isAuthAction, isDefinedNonNullAny, isDenied, isDocumentAction, isDocumentCreator, isDocumentModelDocument, isDocumentModelState, isNoopOperation, isPlainValue, isReservedOperationName, isUndo, isUndoRedo, isValidOperationNameFormat, loadState, loadStateOperation, mapSkippedOperations, mapSkippedOperationsV2, merge, moveGrant, moveOperation, nextSkipNumber, noop, operationExampleCreators, operationFromAction, operationFromOperation, operationOutcome, operationWithContext, operationsAreEqual, parseResultingState, precedes, prepareOperations, processUndoRedo, prune, pruneOperation, readFileBrowser, readOnly, redo, redoOperation, releaseNewVersion, removeExistingOperations, removeGrant, reorderChangeLogItems, reorderModuleOperations, reorderModules, reorderOperationErrors, reorderOperationExamples, reorderStateExamples, replayDocument, replayDocumentVersioned, replayOperations, reshuffleByTimestamp, reshuffleByTimestampAndIndex, resolveSnapshotAuth, setAuthorName, setAuthorWebsite, setGrant, setInitialState, setModelDescription, setModelExtension, setModelId, setModelName, setModuleDescription, setModuleName, setName, setNameOperation, setOperationDescription, setOperationErrorCode, setOperationErrorDescription, setOperationErrorName, setOperationErrorTemplate, setOperationName, setOperationReducer, setOperationSchema, setOperationScope, setOperationTemplate, setPreferredEditor, setPreferredEditorOperation, setStateSchema, sign, skipHeaderOperations, sortMappedOperations, sortOperations, split, undo, undoOperation, undoOperationV2, updateChangeLogItem, updateDocument, updateHeaderRevision, updateOperationExample, updateStateExample, validateHeader, validateInitialState, validateModule, validateModuleOperation, validateModules, validateOperationName, validateOperations, validateStateSchemaName, verify, verifyOperationSignature, writeFileBrowser };
|
|
4983
|
+
export { AUTH_ACTION_TYPES, AUTH_DENIED_BY_GRANT_REASON, AUTH_NO_GRANT_REASON, AUTH_VERSION_UNSUPPORTED_REASON, AddChangeLogItemInputSchema, AddModuleInputSchema, AddOperationErrorInputSchema, AddOperationExampleInputSchema, AddOperationInputSchema, AddStateExampleInputSchema, AuthActionNotAllowedError, AuthAdministrationLockoutError, AuthAdministrationMissingError, AuthAlreadyInitializedError, AuthInitializerNotCreatorError, AuthPolicyNotPreservedError, AuthorSchema, BaseDocumentHeaderSchema, BaseDocumentStateSchema, CodeExampleSchema, ConfigEntrySchema, ConfigEntryTypeSchema, DOCUMENT_DELETED_REASON, DeleteChangeLogItemInputSchema, DeleteModuleInputSchema, DeleteOperationErrorInputSchema, DeleteOperationExampleInputSchema, DeleteOperationInputSchema, DeleteStateExampleInputSchema, DocumentActionSchema, DocumentModelGlobalStateSchema, DocumentModelHeaderSchema, DocumentModelInputSchema, DocumentModelPHStateSchema, DocumentModelSchema, DocumentSpecificationSchema, DowngradeNotSupportedError, FileSystemError, GrantNotFoundError, GrantSchema, GroupPrincipalNotAllowedError, HASH_ALGORITHM_SHA1, HASH_ALGORITHM_SHA256, HASH_ALGORITHM_SHA512, HASH_ENCODING_BASE64, HASH_ENCODING_HEX, HashMismatchError, InitializeAuthActionInputSchema, IntegrityIssueSubType, IntegrityIssueType, InvalidActionInputError, InvalidActionInputZodError, InvalidAuthVersionError, InvalidGrantError, LoadStateActionInputSchema, LoadStateActionSchema, LoadStateActionStateInputSchema, Load_StateSchema, MAX_AUTH_GRANTS, MAX_CAPABILITY_OPERATIONS, MAX_CONDITION_DEPTH, MAX_CONDITION_NODES, MAX_SUPPORTED_AUTH_VERSION, ManifestSchema, ModuleSchema, MoveGrantActionInputSchema, MoveOperationInputSchema, OPERATION_NAME_PATTERN, OperationErrorSchema, OperationScopeSchema, OperationSpecificationSchema, PowerhouseModuleSchema, PowerhouseModulesSchema, PruneActionInputSchema, PruneActionSchema, PruneSchema, PublisherSchema, PwaConfigSchema, RESERVED_OPERATION_NAMES, RedoActionInputSchema, RedoActionSchema, RedoSchema, RemoveGrantActionInputSchema, ReorderChangeLogItemsInputSchema, ReorderModuleOperationsInputSchema, ReorderModulesInputSchema, ReorderOperationErrorsInputSchema, ReorderOperationExamplesInputSchema, ReorderStateExamplesInputSchema, ScopeStateSchema, SetAuthorNameInputSchema, SetAuthorWebsiteInputSchema, SetGrantActionInputSchema, SetInitialStateInputSchema, SetModelDescriptionInputSchema, SetModelExtensionInputSchema, SetModelIdInputSchema, SetModelNameInputSchema, SetModuleDescriptionInputSchema, SetModuleNameInputSchema, SetNameActionInputSchema, SetNameActionSchema, SetOperationDescriptionInputSchema, SetOperationErrorCodeInputSchema, SetOperationErrorDescriptionInputSchema, SetOperationErrorNameInputSchema, SetOperationErrorTemplateInputSchema, SetOperationNameInputSchema, SetOperationReducerInputSchema, SetOperationSchemaInputSchema, SetOperationScopeInputSchema, SetOperationTemplateInputSchema, SetPreferredEditorActionInputSchema, SetPreferredEditorActionSchema, SetStateSchemaInputSchema, Set_NameSchema, Set_PreferredEditorSchema, StateSchema, UndoActionInputSchema, UndoActionSchema, UndoSchema, UnsupportedDocumentModelVersionError, UpdateChangeLogItemInputSchema, UpdateOperationExampleInputSchema, UpdateStateExampleInputSchema, ab2hex, actionContext, actionFromAction, actionSigner, actions, addChangeLogItem, addModule, addOperation, addOperationError, addOperationExample, addStateExample, addUndo, appendWithoutApplying, applyAuthAction, applyDeleteDocumentAction, applyInitializeAuthAction, applyMoveGrantAction, applyRemoveGrantAction, applySetGrantAction, applyUpgradeDocumentAction, assertAuthAdministrationRetained, assertAuthPreservedOnDuplicate, assertAuthScopeActionAllowed, assertIsDocumentModelDocument, assertIsDocumentModelState, assertModuleIdUnique, assertOperationErrorIdUnique, assertOperationExampleIdUnique, assertOperationIdUnique, assertValidGrant, assertValidGrantUpsert, assertValidInitialGrants, attachBranch, backfillAuthState, base58Decode, base64UrlToBytes, baseActions, baseCreateDocument, baseLoadFromInput, baseLoadFromInputVersioned, baseReducer, baseReducerVersion, baseSaveToFileHandle, buildOperationSignature, buildOperationSignatureMessage, buildOperationSignatureParams, buildSignedAction, checkCleanedOperationsIntegrity, checkOperationsIntegrity, computeUpgradeTransitions, createAction, createAuthState, createBaseState, createDocumentState, createGlobalState, createLocalState, createMinimalZip, createPresignedHeader, createReducer, createSignedHeader, createSignedHeaderForSigner, createState, createVerificationSigner, createZip, decide, defaultAuthState, defaultBaseState, defaultDocumentState, defaultGlobalState, defaultLocalState, defaultPHState, definedNonNullAnySchema, deleteChangeLogItem, deleteModule, deleteOperation, deleteOperationError, deleteOperationExample, deleteStateExample, deriveOperationId, diffOperations, documentModelActions, documentModelDocumentType, documentModelFileExtension, documentModelGlobalState, documentModelHeaderReducer, documentModelInitialGlobalState, documentModelInitialLocalState, documentModelLoadFromInput, documentModelModuleReducer, documentModelOperationErrorReducer, documentModelOperationExampleReducer, documentModelOperationReducer, documentModelReducer, documentModelSaveToFileHandle, documentModelStateReducer, documentModelStateSchemaReducer, documentModelVersioningReducer, evaluate, evaluateCondition, evaluateGrantStack, evaluateGrants, fetchFileBrowser, filterDocumentOperationsResultingState, filterDuplicatedOperations, findModuleOrThrow, findOperationErrorOrThrow, findOperationExampleOrThrow, findOperationOrThrow, garbageCollect, garbageCollectDocumentOperations, garbageCollectV2, generateId, generateMock, getAllOperationNames, getDocumentLastModified, getFileBrowser, getUnixTimestamp, grantProblem, groupDocumentType, groupMembershipActionTypes, groupOperationsByScope, hashBrowser, hashDocumentStateForScope, hex2ab, initializeAuth, isAuthAction, isDefinedNonNullAny, isDenied, isDocumentAction, isDocumentCreator, isDocumentModelDocument, isDocumentModelState, isNoopOperation, isPlainValue, isReservedOperationName, isUndo, isUndoRedo, isValidOperationNameFormat, loadState, loadStateOperation, mapSkippedOperations, mapSkippedOperationsV2, mentionedGroupIds, merge, moveGrant, moveOperation, nextSkipNumber, noop, normalizeDocumentModelVersion, operationExampleCreators, operationFromAction, operationFromOperation, operationOutcome, operationWithContext, operationsAreEqual, parseResultingState, precedes, prepareOperations, processUndoRedo, prune, pruneOperation, readFileBrowser, readOnly, redo, redoOperation, referencedGroupIds, releaseNewVersion, removeExistingOperations, removeGrant, reorderChangeLogItems, reorderModuleOperations, reorderModules, reorderOperationErrors, reorderOperationExamples, reorderStateExamples, replayDocument, replayDocumentVersioned, replayOperations, reshuffleByTimestamp, reshuffleByTimestampAndIndex, resolveSnapshotAuth, setAuthorName, setAuthorWebsite, setGrant, setInitialState, setModelDescription, setModelExtension, setModelId, setModelName, setModuleDescription, setModuleName, setName, setNameOperation, setOperationDescription, setOperationErrorCode, setOperationErrorDescription, setOperationErrorName, setOperationErrorTemplate, setOperationName, setOperationReducer, setOperationSchema, setOperationScope, setOperationTemplate, setPreferredEditor, setPreferredEditorOperation, setStateSchema, sign, skipHeaderOperations, sortMappedOperations, sortOperations, split, undo, undoOperation, undoOperationV2, updateChangeLogItem, updateDocument, updateHeaderRevision, updateOperationExample, updateStateExample, validateHeader, validateInitialState, validateModule, validateModuleOperation, validateModules, validateOperationName, validateOperations, validateStateSchemaName, verify, verifyOperationSignature, writeFileBrowser };
|
|
4746
4984
|
|
|
4747
4985
|
//# sourceMappingURL=index.js.map
|