@powerhousedao/powerhouse-vetra-packages 6.2.0-dev.1 → 6.2.0-dev.11
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/browser/assets/{entry-Bzani6_n.js → entry-D6VwthNk.js} +2 -2
- package/dist/browser/assets/{projection-entry-Bpu-8SnI.js → projection-entry-CemvPRT8.js} +2 -2
- package/dist/browser/{connect-ZnLjvmRt.js → connect-BMrgEG7X.js} +4 -4
- package/dist/browser/{connect-ZnLjvmRt.js.map → connect-BMrgEG7X.js.map} +1 -1
- package/dist/browser/{dist-C1nRM9t2.js → dist-B6zWOl4d.js} +44 -30
- package/dist/browser/dist-B6zWOl4d.js.map +1 -0
- package/dist/browser/{dist-DLFI75Zd.js → dist-DPeHVSov.js} +3 -3
- package/dist/browser/dist-DPeHVSov.js.map +1 -0
- package/dist/browser/{document-drive-oqv68jDU.js → document-drive-sTKoi6L4.js} +314 -9
- package/dist/browser/document-drive-sTKoi6L4.js.map +1 -0
- package/dist/browser/document-models/index.js +1 -1
- package/dist/browser/{editor-CoTq6fqT.js → editor-Clp9-uJE.js} +6 -6
- package/dist/browser/{editor-CoTq6fqT.js.map → editor-Clp9-uJE.js.map} +1 -1
- package/dist/browser/{editor-DC3bigBu.js → editor-CzsQw1pE.js} +5 -5
- package/dist/browser/{editor-DC3bigBu.js.map → editor-CzsQw1pE.js.map} +1 -1
- package/dist/browser/editors/document-model-editor/module.js +1 -1
- package/dist/browser/editors/generic-drive-explorer/index.js +4 -4
- package/dist/browser/editors/generic-drive-explorer/module.js +1 -1
- package/dist/browser/{folder-view-DmYBf2pP.js → folder-view-D9jBl4kJ.js} +3 -3
- package/dist/browser/{folder-view-DmYBf2pP.js.map → folder-view-D9jBl4kJ.js.map} +1 -1
- package/dist/browser/{graphql-editor-CiGd_Li7.js → graphql-editor-8bWqxqUN.js} +3 -3
- package/dist/browser/{graphql-editor-CiGd_Li7.js.map → graphql-editor-8bWqxqUN.js.map} +1 -1
- package/dist/browser/index.js +2 -2
- package/dist/browser/{json-editor-sEqd5piI.js → json-editor-DlvyzQQO.js} +3 -3
- package/dist/browser/{json-editor-sEqd5piI.js.map → json-editor-DlvyzQQO.js.map} +1 -1
- package/dist/browser/{state-schemas-DJmzG_M8.js → state-schemas-CVQyYhpH.js} +3 -3
- package/dist/browser/{state-schemas-DJmzG_M8.js.map → state-schemas-CVQyYhpH.js.map} +1 -1
- package/dist/node/{connect-BLC4PXD9.mjs → connect-C8Ur6M5x.mjs} +4 -4
- package/dist/node/{connect-BLC4PXD9.mjs.map → connect-C8Ur6M5x.mjs.map} +1 -1
- package/dist/node/{dist-Bm05eoTg.mjs → dist-D3qXr1ES.mjs} +44 -30
- package/dist/node/dist-D3qXr1ES.mjs.map +1 -0
- package/dist/node/{dist-Cn3iExnV.mjs → dist-vA9scgbK.mjs} +3 -3
- package/dist/node/dist-vA9scgbK.mjs.map +1 -0
- package/dist/node/{document-drive-sM33juXr.mjs → document-drive-DjL9iikf.mjs} +314 -9
- package/dist/node/document-drive-DjL9iikf.mjs.map +1 -0
- package/dist/node/document-models/index.mjs +1 -1
- package/dist/node/{editor-BrS98lEH.mjs → editor-B6gn6QpO.mjs} +5 -5
- package/dist/node/{editor-BrS98lEH.mjs.map → editor-B6gn6QpO.mjs.map} +1 -1
- package/dist/node/{editor-BFBa9nsO.mjs → editor-kdobbTut.mjs} +6 -6
- package/dist/node/{editor-BFBa9nsO.mjs.map → editor-kdobbTut.mjs.map} +1 -1
- package/dist/node/editors/document-model-editor/module.mjs +1 -1
- package/dist/node/editors/generic-drive-explorer/index.mjs +4 -4
- package/dist/node/editors/generic-drive-explorer/module.mjs +1 -1
- package/dist/node/{folder-view-DHph3Yuu.mjs → folder-view-C9m-Kbjh.mjs} +3 -3
- package/dist/node/{folder-view-DHph3Yuu.mjs.map → folder-view-C9m-Kbjh.mjs.map} +1 -1
- package/dist/node/{graphql-editor-CPq7oIbf.mjs → graphql-editor-BiK6s8_B.mjs} +3 -3
- package/dist/node/{graphql-editor-CPq7oIbf.mjs.map → graphql-editor-BiK6s8_B.mjs.map} +1 -1
- package/dist/node/index.mjs +2 -2
- package/dist/node/{json-editor-L32CP7TS.mjs → json-editor-rMZOlQFM.mjs} +3 -3
- package/dist/node/{json-editor-L32CP7TS.mjs.map → json-editor-rMZOlQFM.mjs.map} +1 -1
- package/dist/node/{state-schemas-XTTjQZOe.mjs → state-schemas-Dt2-S4R8.mjs} +3 -3
- package/dist/node/{state-schemas-XTTjQZOe.mjs.map → state-schemas-Dt2-S4R8.mjs.map} +1 -1
- package/package.json +6 -6
- package/dist/browser/dist-C1nRM9t2.js.map +0 -1
- package/dist/browser/dist-DLFI75Zd.js.map +0 -1
- package/dist/browser/document-drive-oqv68jDU.js.map +0 -1
- package/dist/node/dist-Bm05eoTg.mjs.map +0 -1
- package/dist/node/dist-Cn3iExnV.mjs.map +0 -1
- package/dist/node/document-drive-sM33juXr.mjs.map +0 -1
|
@@ -2963,6 +2963,21 @@ var InvalidActionInputZodError = class extends InvalidActionInputError {
|
|
|
2963
2963
|
this.name = "InvalidActionInputZodError";
|
|
2964
2964
|
}
|
|
2965
2965
|
};
|
|
2966
|
+
/**
|
|
2967
|
+
* Error thrown when attempting to downgrade a document version.
|
|
2968
|
+
*/
|
|
2969
|
+
var DowngradeNotSupportedError = class extends Error {
|
|
2970
|
+
documentType;
|
|
2971
|
+
fromVersion;
|
|
2972
|
+
toVersion;
|
|
2973
|
+
constructor(documentType, fromVersion, toVersion) {
|
|
2974
|
+
super(`Downgrade not supported for ${documentType}: cannot upgrade from version ${fromVersion} to ${toVersion}`);
|
|
2975
|
+
this.name = "DowngradeNotSupportedError";
|
|
2976
|
+
this.documentType = documentType;
|
|
2977
|
+
this.fromVersion = fromVersion;
|
|
2978
|
+
this.toVersion = toVersion;
|
|
2979
|
+
}
|
|
2980
|
+
};
|
|
2966
2981
|
var HashMismatchError = class extends Error {
|
|
2967
2982
|
_scope;
|
|
2968
2983
|
_document;
|
|
@@ -3496,16 +3511,16 @@ const noop = (scope = "global") => createAction("NOOP", {}, void 0, void 0, scop
|
|
|
3496
3511
|
*
|
|
3497
3512
|
* @param type - The type of the action.
|
|
3498
3513
|
* @param input - The input properties of the action.
|
|
3499
|
-
* @param
|
|
3514
|
+
* @param _attachments - Deprecated and ignored. Retained so action creators
|
|
3515
|
+
* generated before the attachment-system removal keep their 5-argument shape.
|
|
3500
3516
|
* @param validator - The validator to use for the input properties.
|
|
3501
3517
|
* @param scope - The scope of the action, can either be 'global' or 'local'.
|
|
3502
|
-
* @param skip - The number of operations to skip before this new action is applied.
|
|
3503
3518
|
*
|
|
3504
3519
|
* @throws Error if the type is empty or not a string.
|
|
3505
3520
|
*
|
|
3506
3521
|
* @returns The new action.
|
|
3507
3522
|
*/
|
|
3508
|
-
function createAction(type, input,
|
|
3523
|
+
function createAction(type, input, _attachments, validator, scope = "global") {
|
|
3509
3524
|
if (!type) throw new Error("Empty action type");
|
|
3510
3525
|
if (typeof type !== "string") throw new Error(`Invalid action type: ${JSON.stringify(type)}`);
|
|
3511
3526
|
const action = {
|
|
@@ -3515,7 +3530,6 @@ function createAction(type, input, attachments, validator, scope = "global") {
|
|
|
3515
3530
|
input,
|
|
3516
3531
|
scope
|
|
3517
3532
|
};
|
|
3518
|
-
if (attachments) action.attachments = attachments;
|
|
3519
3533
|
try {
|
|
3520
3534
|
validator?.().parse(action.input);
|
|
3521
3535
|
} catch (error) {
|
|
@@ -3535,8 +3549,7 @@ const actionFromAction = (action) => {
|
|
|
3535
3549
|
type: action.type,
|
|
3536
3550
|
input: action.input,
|
|
3537
3551
|
scope: action.scope,
|
|
3538
|
-
context: action.context
|
|
3539
|
-
attachments: action.attachments
|
|
3552
|
+
context: action.context
|
|
3540
3553
|
};
|
|
3541
3554
|
};
|
|
3542
3555
|
const operationFromAction = (action, index, skip, context) => {
|
|
@@ -5803,6 +5816,280 @@ const documentModelStateReducer = (state, action) => {
|
|
|
5803
5816
|
}
|
|
5804
5817
|
};
|
|
5805
5818
|
const documentModelReducer = createReducer(documentModelStateReducer);
|
|
5819
|
+
function applyInitialState(document, action) {
|
|
5820
|
+
const input = action.input;
|
|
5821
|
+
const newState = input.initialState || input.state;
|
|
5822
|
+
if (newState) {
|
|
5823
|
+
document.state = {
|
|
5824
|
+
...document.state,
|
|
5825
|
+
...newState
|
|
5826
|
+
};
|
|
5827
|
+
document.initialState = document.state;
|
|
5828
|
+
}
|
|
5829
|
+
}
|
|
5830
|
+
/**
|
|
5831
|
+
* Applies an UPGRADE_DOCUMENT action to a document.
|
|
5832
|
+
* Handles all upgrade scenarios including initial upgrades, no-ops, and multi-step upgrades.
|
|
5833
|
+
*
|
|
5834
|
+
* Behavior based on fromVersion/toVersion:
|
|
5835
|
+
* - fromVersion === toVersion (and fromVersion > 0): No-op - return unchanged document
|
|
5836
|
+
* - fromVersion > toVersion: Throw DowngradeNotSupportedError
|
|
5837
|
+
* - All other cases: Apply upgradePath transitions (if provided), then apply initialState, set version
|
|
5838
|
+
*/
|
|
5839
|
+
function applyUpgradeDocumentAction(document, action, upgradePath) {
|
|
5840
|
+
const fromVersion = action.input.fromVersion;
|
|
5841
|
+
const toVersion = action.input.toVersion;
|
|
5842
|
+
if (fromVersion === toVersion && fromVersion > 0) return document;
|
|
5843
|
+
if (fromVersion > toVersion) throw new DowngradeNotSupportedError(document.header.documentType, fromVersion, toVersion);
|
|
5844
|
+
if (upgradePath) for (const transition of upgradePath) document = transition.upgradeReducer(document, action);
|
|
5845
|
+
applyInitialState(document, action);
|
|
5846
|
+
document.state.document = {
|
|
5847
|
+
...document.state.document,
|
|
5848
|
+
version: toVersion
|
|
5849
|
+
};
|
|
5850
|
+
return document;
|
|
5851
|
+
}
|
|
5852
|
+
/**
|
|
5853
|
+
* Applies a DELETE_DOCUMENT action to a document.
|
|
5854
|
+
* Marks the document as deleted in the document scope state.
|
|
5855
|
+
*/
|
|
5856
|
+
function applyDeleteDocumentAction(document, action) {
|
|
5857
|
+
const deletedAt = action.timestampUtcMs || (/* @__PURE__ */ new Date()).toISOString();
|
|
5858
|
+
document.state = {
|
|
5859
|
+
...document.state,
|
|
5860
|
+
document: {
|
|
5861
|
+
...document.state.document,
|
|
5862
|
+
isDeleted: true,
|
|
5863
|
+
deletedAtUtcIso: deletedAt
|
|
5864
|
+
}
|
|
5865
|
+
};
|
|
5866
|
+
return document;
|
|
5867
|
+
}
|
|
5868
|
+
/**
|
|
5869
|
+
* Computes the ordered list of upgrade transitions needed to move from
|
|
5870
|
+
* fromVersion to toVersion using the provided manifest.
|
|
5871
|
+
* Walks keys v(fromVersion+1)..v(toVersion) and throws a descriptive Error
|
|
5872
|
+
* if the manifest is absent or any step is missing.
|
|
5873
|
+
*/
|
|
5874
|
+
function computeUpgradeTransitions(manifest, fromVersion, toVersion) {
|
|
5875
|
+
if (!manifest) throw new Error(`No upgrade manifest provided for transition from version ${fromVersion} to ${toVersion}`);
|
|
5876
|
+
const transitions = [];
|
|
5877
|
+
const upgrades = manifest.upgrades;
|
|
5878
|
+
for (let v = fromVersion + 1; v <= toVersion; v++) {
|
|
5879
|
+
const key = `v${v}`;
|
|
5880
|
+
const transition = upgrades[key];
|
|
5881
|
+
if (!transition) throw new Error(`Upgrade manifest for "${manifest.documentType}" is missing step "${key}" (from v${fromVersion} to v${toVersion}). Available keys: ${Object.keys(upgrades).join(", ")}`);
|
|
5882
|
+
transitions.push(transition);
|
|
5883
|
+
}
|
|
5884
|
+
return transitions;
|
|
5885
|
+
}
|
|
5886
|
+
const NON_DOMAIN_SCOPES$1 = new Set(["auth", "document"]);
|
|
5887
|
+
function highestReducerVersion(reducers) {
|
|
5888
|
+
const keys = Object.keys(reducers).map(Number);
|
|
5889
|
+
if (keys.length === 0) throw new Error("VersionedReplayConfig.reducers must not be empty");
|
|
5890
|
+
return Math.max(...keys);
|
|
5891
|
+
}
|
|
5892
|
+
/**
|
|
5893
|
+
* Version-aware document replay. Replays a versioned document through per-version
|
|
5894
|
+
* reducers, applying upgrade transitions at segment boundaries.
|
|
5895
|
+
*
|
|
5896
|
+
* Algorithm (D5):
|
|
5897
|
+
* a. Build spine from operations["document"]. Empty spine or no upgrades → legacy fallback.
|
|
5898
|
+
* b. Collect UPGRADE_DOCUMENT ops from the spine.
|
|
5899
|
+
* c. Seed state from the creation upgrade (fromVersion===0). Missing seed with validated
|
|
5900
|
+
* upgrades throws; otherwise falls back to legacy.
|
|
5901
|
+
* d. Identify validated upgrades (fromVersion > 0, version increases). Compute per-scope
|
|
5902
|
+
* boundaries using revision snapshot (preferred) or timestamp fallback.
|
|
5903
|
+
* e. Loop over version segments, replaying each scope's ops through the matching reducer,
|
|
5904
|
+
* then applying the upgrade transition before the next segment.
|
|
5905
|
+
* f. Set header.revision["document"], verify per-scope hashes against state at op-time
|
|
5906
|
+
* (not post-upgrade state) when checkHashes is false, and map timestamps from input.
|
|
5907
|
+
*
|
|
5908
|
+
* operations must include ALL scopes (document scope is NOT stripped).
|
|
5909
|
+
* reuseOperationResultingState is ignored by this function — zip operations never carry
|
|
5910
|
+
* resultingState.
|
|
5911
|
+
*/
|
|
5912
|
+
function replayDocumentVersioned(initialState, operations, config, header, dispatch, options) {
|
|
5913
|
+
const { checkHashes = true, skipIndexValidation } = options || {};
|
|
5914
|
+
const protocolVersion = header.protocolVersions?.["base-reducer"] ?? 1;
|
|
5915
|
+
const spine = (operations["document"] ?? []).slice().sort((a, b) => a.index - b.index);
|
|
5916
|
+
const upgrades = spine.filter((op) => op.action.type === "UPGRADE_DOCUMENT");
|
|
5917
|
+
const legacyFallback = () => {
|
|
5918
|
+
const domainOps = Object.fromEntries(Object.entries(operations).filter(([s]) => !NON_DOMAIN_SCOPES$1.has(s)));
|
|
5919
|
+
const latestVersion = highestReducerVersion(config.reducers);
|
|
5920
|
+
const reducer = config.reducers[latestVersion];
|
|
5921
|
+
return {
|
|
5922
|
+
...replayDocument(initialState, domainOps, reducer, header, dispatch, {}, options),
|
|
5923
|
+
operations
|
|
5924
|
+
};
|
|
5925
|
+
};
|
|
5926
|
+
if (spine.length === 0 || upgrades.length === 0) return legacyFallback();
|
|
5927
|
+
const seedOp = upgrades[0];
|
|
5928
|
+
if (!seedOp) return legacyFallback();
|
|
5929
|
+
const seedAction = seedOp.action;
|
|
5930
|
+
if (seedAction.input.fromVersion !== 0) return legacyFallback();
|
|
5931
|
+
const seedInput = seedAction.input;
|
|
5932
|
+
const seedState = seedInput.initialState ?? seedInput.state;
|
|
5933
|
+
if (!seedState) {
|
|
5934
|
+
const validatedUpgradeCount = upgrades.filter((op) => {
|
|
5935
|
+
const a = op.action;
|
|
5936
|
+
return a.input.fromVersion > 0 && a.input.fromVersion < a.input.toVersion;
|
|
5937
|
+
}).length;
|
|
5938
|
+
if (validatedUpgradeCount > 0) throw new Error(`Cannot reconstruct versioned history: the creation UPGRADE_DOCUMENT operation carries no initialState, but the document has ${validatedUpgradeCount} version-changing upgrade(s) recorded after creation. Pre-migration states cannot be reconstructed without the seeded initialState.`);
|
|
5939
|
+
return legacyFallback();
|
|
5940
|
+
}
|
|
5941
|
+
const startVersion = seedAction.input.toVersion;
|
|
5942
|
+
const validatedUpgrades = upgrades.filter((op) => {
|
|
5943
|
+
const a = op.action;
|
|
5944
|
+
return a.input.fromVersion > 0 && a.input.fromVersion < a.input.toVersion;
|
|
5945
|
+
});
|
|
5946
|
+
const domainScopes = Object.keys(operations).filter((s) => !NON_DOMAIN_SCOPES$1.has(s));
|
|
5947
|
+
const scopeOps = {};
|
|
5948
|
+
for (const s of domainScopes) scopeOps[s] = (operations[s] ?? []).slice().sort((a, b) => a.index - b.index);
|
|
5949
|
+
const boundaries = validatedUpgrades.map((upgradeOp) => {
|
|
5950
|
+
const revisionSnapshot = upgradeOp.action.input.revision;
|
|
5951
|
+
const upgradeTimestamp = upgradeOp.timestampUtcMs;
|
|
5952
|
+
const boundary = {};
|
|
5953
|
+
for (const s of domainScopes) {
|
|
5954
|
+
const ops = scopeOps[s] ?? [];
|
|
5955
|
+
if (revisionSnapshot !== void 0) {
|
|
5956
|
+
const rev = revisionSnapshot[s] ?? 0;
|
|
5957
|
+
let b = 0;
|
|
5958
|
+
for (let j = 0; j < ops.length; j++) if ((ops[j]?.index ?? 0) < rev) b = j + 1;
|
|
5959
|
+
boundary[s] = b;
|
|
5960
|
+
} else {
|
|
5961
|
+
let b = ops.length;
|
|
5962
|
+
for (let j = 0; j < ops.length; j++) if ((ops[j]?.timestampUtcMs ?? "") >= upgradeTimestamp) {
|
|
5963
|
+
b = j;
|
|
5964
|
+
break;
|
|
5965
|
+
}
|
|
5966
|
+
boundary[s] = b;
|
|
5967
|
+
}
|
|
5968
|
+
}
|
|
5969
|
+
return boundary;
|
|
5970
|
+
});
|
|
5971
|
+
for (let i = 1; i < boundaries.length; i++) for (const s of domainScopes) {
|
|
5972
|
+
const prev = boundaries[i - 1]?.[s] ?? 0;
|
|
5973
|
+
const curr = boundaries[i]?.[s] ?? 0;
|
|
5974
|
+
if (boundaries[i]) boundaries[i][s] = Math.max(prev, curr);
|
|
5975
|
+
}
|
|
5976
|
+
const allScopes = new Set([
|
|
5977
|
+
...Object.keys(operations),
|
|
5978
|
+
"global",
|
|
5979
|
+
"local"
|
|
5980
|
+
]);
|
|
5981
|
+
const initialOperations = {};
|
|
5982
|
+
for (const s of allScopes) initialOperations[s] = [];
|
|
5983
|
+
let document = {
|
|
5984
|
+
header,
|
|
5985
|
+
state: seedState,
|
|
5986
|
+
initialState: seedState,
|
|
5987
|
+
operations: initialOperations,
|
|
5988
|
+
clipboard: []
|
|
5989
|
+
};
|
|
5990
|
+
let currentVersion = startVersion;
|
|
5991
|
+
const segmentEndHashPerScope = /* @__PURE__ */ new Map();
|
|
5992
|
+
for (let k = 0; k <= validatedUpgrades.length; k++) {
|
|
5993
|
+
const reducer = config.reducers[currentVersion];
|
|
5994
|
+
if (!reducer) {
|
|
5995
|
+
const available = Object.keys(config.reducers).join(", ");
|
|
5996
|
+
throw new Error(`No reducer registered for document version ${currentVersion}. Available versions: ${available}`);
|
|
5997
|
+
}
|
|
5998
|
+
for (const s of domainScopes) {
|
|
5999
|
+
const ops = scopeOps[s] ?? [];
|
|
6000
|
+
const segStart = k === 0 ? 0 : boundaries[k - 1]?.[s] ?? 0;
|
|
6001
|
+
const segEnd = k < validatedUpgrades.length ? boundaries[k]?.[s] ?? ops.length : ops.length;
|
|
6002
|
+
const segOps = ops.slice(segStart, segEnd);
|
|
6003
|
+
for (const op of segOps) {
|
|
6004
|
+
document = reducer(document, op.action, dispatch, {
|
|
6005
|
+
ignoreSkipOperations: true,
|
|
6006
|
+
checkHashes,
|
|
6007
|
+
skipIndexValidation,
|
|
6008
|
+
replayOptions: { operation: op },
|
|
6009
|
+
protocolVersion
|
|
6010
|
+
});
|
|
6011
|
+
segmentEndHashPerScope.set(s, hashDocumentStateForScope(document, s));
|
|
6012
|
+
}
|
|
6013
|
+
}
|
|
6014
|
+
const prevUpgradeSpineIdx = k === 0 ? -1 : spine.indexOf(validatedUpgrades[k - 1]);
|
|
6015
|
+
const nextUpgradeSpineIdx = k < validatedUpgrades.length ? spine.indexOf(validatedUpgrades[k]) : spine.length;
|
|
6016
|
+
for (let si = prevUpgradeSpineIdx + 1; si < nextUpgradeSpineIdx; si++) {
|
|
6017
|
+
const spineOp = spine[si];
|
|
6018
|
+
if (!spineOp) continue;
|
|
6019
|
+
const spineActionType = spineOp.action.type;
|
|
6020
|
+
if (spineActionType === "CREATE_DOCUMENT" || spineActionType === "UPGRADE_DOCUMENT") continue;
|
|
6021
|
+
if (spineActionType === "DELETE_DOCUMENT") document = applyDeleteDocumentAction(document, spineOp.action);
|
|
6022
|
+
else document = reducer(document, spineOp.action, dispatch, {
|
|
6023
|
+
ignoreSkipOperations: true,
|
|
6024
|
+
checkHashes,
|
|
6025
|
+
skipIndexValidation,
|
|
6026
|
+
replayOptions: { operation: spineOp },
|
|
6027
|
+
protocolVersion
|
|
6028
|
+
});
|
|
6029
|
+
}
|
|
6030
|
+
if (k < validatedUpgrades.length) {
|
|
6031
|
+
const upgradeAction = validatedUpgrades[k].action;
|
|
6032
|
+
const fromVer = upgradeAction.input.fromVersion;
|
|
6033
|
+
const toVer = upgradeAction.input.toVersion;
|
|
6034
|
+
const transitions = computeUpgradeTransitions(config.upgradeManifest, fromVer, toVer);
|
|
6035
|
+
document = applyUpgradeDocumentAction(document, upgradeAction, transitions);
|
|
6036
|
+
currentVersion = toVer;
|
|
6037
|
+
}
|
|
6038
|
+
}
|
|
6039
|
+
const lastSpineOp = spine.at(-1);
|
|
6040
|
+
if (lastSpineOp !== void 0 && validatedUpgrades.length > 0) document = {
|
|
6041
|
+
...document,
|
|
6042
|
+
header: {
|
|
6043
|
+
...document.header,
|
|
6044
|
+
revision: {
|
|
6045
|
+
...document.header.revision,
|
|
6046
|
+
document: lastSpineOp.index + 1
|
|
6047
|
+
}
|
|
6048
|
+
}
|
|
6049
|
+
};
|
|
6050
|
+
if (!checkHashes) {
|
|
6051
|
+
const allReplayedOps = domainScopes.flatMap((s) => scopeOps[s] ?? []);
|
|
6052
|
+
for (const scope of Object.keys(document.state)) {
|
|
6053
|
+
const capturedHash = segmentEndHashPerScope.get(scope);
|
|
6054
|
+
const scopeHash = capturedHash !== void 0 ? capturedHash : hashDocumentStateForScope(document, scope);
|
|
6055
|
+
for (let i = allReplayedOps.length - 1; i >= 0; i--) {
|
|
6056
|
+
const operation = allReplayedOps[i];
|
|
6057
|
+
if (!operation || operation.action.scope !== scope) continue;
|
|
6058
|
+
if (operation.hash !== scopeHash) throw new HashMismatchError(scope, document, operation);
|
|
6059
|
+
else break;
|
|
6060
|
+
}
|
|
6061
|
+
}
|
|
6062
|
+
}
|
|
6063
|
+
const allResultScopes = new Set([
|
|
6064
|
+
...Object.keys(document.operations),
|
|
6065
|
+
...Object.keys(operations),
|
|
6066
|
+
"global",
|
|
6067
|
+
"local"
|
|
6068
|
+
]);
|
|
6069
|
+
allResultScopes.delete("document");
|
|
6070
|
+
const resultOperations = {};
|
|
6071
|
+
for (const s of allResultScopes) resultOperations[s] = (document.operations[s] ?? []).map((op, index) => ({
|
|
6072
|
+
...op,
|
|
6073
|
+
timestamp: operations[s]?.[index]?.timestampUtcMs ?? op.timestampUtcMs
|
|
6074
|
+
}));
|
|
6075
|
+
const lastModified = header.lastModifiedAtUtcIso ? header.lastModifiedAtUtcIso : Object.values(resultOperations).reduce((acc, curr) => {
|
|
6076
|
+
if (!curr) return acc;
|
|
6077
|
+
const last = curr.at(-1);
|
|
6078
|
+
if (last && last.timestampUtcMs > acc) return last.timestampUtcMs;
|
|
6079
|
+
return acc;
|
|
6080
|
+
}, document.header.lastModifiedAtUtcIso);
|
|
6081
|
+
return {
|
|
6082
|
+
...document,
|
|
6083
|
+
header: {
|
|
6084
|
+
...document.header,
|
|
6085
|
+
lastModifiedAtUtcIso: lastModified
|
|
6086
|
+
},
|
|
6087
|
+
operations: {
|
|
6088
|
+
...operations,
|
|
6089
|
+
...resultOperations
|
|
6090
|
+
}
|
|
6091
|
+
};
|
|
6092
|
+
}
|
|
5806
6093
|
const NON_DOMAIN_SCOPES = new Set(["auth", "document"]);
|
|
5807
6094
|
function zipAsync(data) {
|
|
5808
6095
|
return new Promise((resolve, reject) => {
|
|
@@ -5860,7 +6147,7 @@ function readEntry(files, name) {
|
|
|
5860
6147
|
if (!entry) throw new Error(`${name} not found in document zip`);
|
|
5861
6148
|
return strFromU8(entry);
|
|
5862
6149
|
}
|
|
5863
|
-
async function
|
|
6150
|
+
async function parseZipData(data) {
|
|
5864
6151
|
const files = await unzipAsync(data);
|
|
5865
6152
|
if (!files["state.json"]) throw new Error("Initial state not found");
|
|
5866
6153
|
const initialState = JSON.parse(readEntry(files, "state.json"));
|
|
@@ -5873,14 +6160,32 @@ async function loadFromZipData(data, reducer, options) {
|
|
|
5873
6160
|
const errorMessages = operationsError.map((err) => err.message);
|
|
5874
6161
|
throw new Error(errorMessages.join("\n"));
|
|
5875
6162
|
}
|
|
6163
|
+
return {
|
|
6164
|
+
initialState,
|
|
6165
|
+
header,
|
|
6166
|
+
clearedOperations
|
|
6167
|
+
};
|
|
6168
|
+
}
|
|
6169
|
+
async function loadFromZipData(data, reducer, options) {
|
|
6170
|
+
const { initialState, header, clearedOperations } = await parseZipData(data);
|
|
5876
6171
|
return {
|
|
5877
6172
|
...replayDocument(initialState, Object.fromEntries(Object.entries(clearedOperations).filter(([scope]) => !NON_DOMAIN_SCOPES.has(scope))), reducer, header, void 0, {}, options),
|
|
5878
6173
|
operations: clearedOperations
|
|
5879
6174
|
};
|
|
5880
6175
|
}
|
|
6176
|
+
async function loadFromZipDataVersioned(data, config, options) {
|
|
6177
|
+
const { initialState, header, clearedOperations } = await parseZipData(data);
|
|
6178
|
+
return {
|
|
6179
|
+
...replayDocumentVersioned(initialState, clearedOperations, config, header, void 0, options),
|
|
6180
|
+
operations: clearedOperations
|
|
6181
|
+
};
|
|
6182
|
+
}
|
|
5881
6183
|
async function baseLoadFromInput(input, reducer, options) {
|
|
5882
6184
|
return loadFromZipData(await toUint8Array(input), reducer, options);
|
|
5883
6185
|
}
|
|
6186
|
+
async function baseLoadFromInputVersioned(input, config, options) {
|
|
6187
|
+
return loadFromZipDataVersioned(await toUint8Array(input), config, options);
|
|
6188
|
+
}
|
|
5884
6189
|
const documentModelLoadFromInput = (input) => {
|
|
5885
6190
|
return baseLoadFromInput(input, documentModelReducer);
|
|
5886
6191
|
};
|
|
@@ -7055,6 +7360,6 @@ const driveDocumentModelModule = {
|
|
|
7055
7360
|
}
|
|
7056
7361
|
};
|
|
7057
7362
|
//#endregion
|
|
7058
|
-
export {
|
|
7363
|
+
export { redo as A, setName as B, createZip as C, deleteOperationError as D, deleteOperation as E, setModelDescription as F, setStateSchema as G, setOperationErrorName as H, setModelExtension as I, validateModules as J, undo as K, setModelId as L, setAuthorName as M, setAuthorWebsite as N, documentModelDocumentType as O, setInitialState as P, setModelName as R, createState as S, deleteModule as T, setOperationName as U, setOperationDescription as V, setOperationSchema as W, generateId as X, validateStateSchemaName as Y, baseLoadFromInputVersioned as _, handleTargetNameCollisions as a, createPresignedHeader as b, moveNode as c, logger as d, addModule as f, baseLoadFromInput as g, baseCreateDocument as h, generateNodesCopy as i, replayDocumentVersioned as j, isDocumentAction as k, updateNode as l, addOperationError as m, copyNode as n, isFileNode as o, addOperation as p, validateInitialState as q, driveDocumentModelModule as r, isFolderNode as s, addFolder as t, documentModelDocumentModelModule as u, baseSaveToFileHandle as v, defaultBaseState as w, createReducer as x, buildSignedAction as y, setModuleName as z };
|
|
7059
7364
|
|
|
7060
|
-
//# sourceMappingURL=document-drive-
|
|
7365
|
+
//# sourceMappingURL=document-drive-sTKoi6L4.js.map
|