@powerhousedao/powerhouse-vetra-packages 6.2.0-dev.10 → 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-DPNyOTBV.js → connect-BMrgEG7X.js} +4 -4
- package/dist/browser/{connect-DPNyOTBV.js.map → connect-BMrgEG7X.js.map} +1 -1
- package/dist/browser/{dist-Bha1Om6O.js → dist-B6zWOl4d.js} +43 -8
- package/dist/browser/dist-B6zWOl4d.js.map +1 -0
- package/dist/browser/{dist-DnQpckQ8.js → dist-DPeHVSov.js} +3 -3
- package/dist/browser/dist-DPeHVSov.js.map +1 -0
- package/dist/browser/{document-drive-CDaY4aIj.js → document-drive-sTKoi6L4.js} +310 -3
- package/dist/browser/document-drive-sTKoi6L4.js.map +1 -0
- package/dist/browser/document-models/index.js +1 -1
- package/dist/browser/{editor-CJFM1rC9.js → editor-Clp9-uJE.js} +6 -6
- package/dist/browser/{editor-CJFM1rC9.js.map → editor-Clp9-uJE.js.map} +1 -1
- package/dist/browser/{editor-BtOSWTjb.js → editor-CzsQw1pE.js} +5 -5
- package/dist/browser/{editor-BtOSWTjb.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-DAhpWssS.js → folder-view-D9jBl4kJ.js} +3 -3
- package/dist/browser/{folder-view-DAhpWssS.js.map → folder-view-D9jBl4kJ.js.map} +1 -1
- package/dist/browser/{graphql-editor-Dwgpm08w.js → graphql-editor-8bWqxqUN.js} +3 -3
- package/dist/browser/{graphql-editor-Dwgpm08w.js.map → graphql-editor-8bWqxqUN.js.map} +1 -1
- package/dist/browser/index.js +2 -2
- package/dist/browser/{json-editor-SKLjwlux.js → json-editor-DlvyzQQO.js} +3 -3
- package/dist/browser/{json-editor-SKLjwlux.js.map → json-editor-DlvyzQQO.js.map} +1 -1
- package/dist/browser/{state-schemas-S69fnpVk.js → state-schemas-CVQyYhpH.js} +3 -3
- package/dist/browser/{state-schemas-S69fnpVk.js.map → state-schemas-CVQyYhpH.js.map} +1 -1
- package/dist/node/{connect-5a3Nx0Jd.mjs → connect-C8Ur6M5x.mjs} +4 -4
- package/dist/node/{connect-5a3Nx0Jd.mjs.map → connect-C8Ur6M5x.mjs.map} +1 -1
- package/dist/node/{dist-QOGgRb-y.mjs → dist-D3qXr1ES.mjs} +43 -8
- package/dist/node/dist-D3qXr1ES.mjs.map +1 -0
- package/dist/node/{dist-C7ZmTHz4.mjs → dist-vA9scgbK.mjs} +3 -3
- package/dist/node/dist-vA9scgbK.mjs.map +1 -0
- package/dist/node/{document-drive-BK2-EDni.mjs → document-drive-DjL9iikf.mjs} +310 -3
- package/dist/node/document-drive-DjL9iikf.mjs.map +1 -0
- package/dist/node/document-models/index.mjs +1 -1
- package/dist/node/{editor-C_Gchmop.mjs → editor-B6gn6QpO.mjs} +5 -5
- package/dist/node/{editor-C_Gchmop.mjs.map → editor-B6gn6QpO.mjs.map} +1 -1
- package/dist/node/{editor-BNOTRmUU.mjs → editor-kdobbTut.mjs} +6 -6
- package/dist/node/{editor-BNOTRmUU.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-af4hVjjx.mjs → folder-view-C9m-Kbjh.mjs} +3 -3
- package/dist/node/{folder-view-af4hVjjx.mjs.map → folder-view-C9m-Kbjh.mjs.map} +1 -1
- package/dist/node/{graphql-editor-BoTCyC9n.mjs → graphql-editor-BiK6s8_B.mjs} +3 -3
- package/dist/node/{graphql-editor-BoTCyC9n.mjs.map → graphql-editor-BiK6s8_B.mjs.map} +1 -1
- package/dist/node/index.mjs +2 -2
- package/dist/node/{json-editor-Bk4_b03g.mjs → json-editor-rMZOlQFM.mjs} +3 -3
- package/dist/node/{json-editor-Bk4_b03g.mjs.map → json-editor-rMZOlQFM.mjs.map} +1 -1
- package/dist/node/{state-schemas-DMw1UvT8.mjs → state-schemas-Dt2-S4R8.mjs} +3 -3
- package/dist/node/{state-schemas-DMw1UvT8.mjs.map → state-schemas-Dt2-S4R8.mjs.map} +1 -1
- package/package.json +6 -6
- package/dist/browser/dist-Bha1Om6O.js.map +0 -1
- package/dist/browser/dist-DnQpckQ8.js.map +0 -1
- package/dist/browser/document-drive-CDaY4aIj.js.map +0 -1
- package/dist/node/dist-C7ZmTHz4.mjs.map +0 -1
- package/dist/node/dist-QOGgRb-y.mjs.map +0 -1
- package/dist/node/document-drive-BK2-EDni.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;
|
|
@@ -5801,6 +5816,280 @@ const documentModelStateReducer = (state, action) => {
|
|
|
5801
5816
|
}
|
|
5802
5817
|
};
|
|
5803
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
|
+
}
|
|
5804
6093
|
const NON_DOMAIN_SCOPES = new Set(["auth", "document"]);
|
|
5805
6094
|
function zipAsync(data) {
|
|
5806
6095
|
return new Promise((resolve, reject) => {
|
|
@@ -5858,7 +6147,7 @@ function readEntry(files, name) {
|
|
|
5858
6147
|
if (!entry) throw new Error(`${name} not found in document zip`);
|
|
5859
6148
|
return strFromU8(entry);
|
|
5860
6149
|
}
|
|
5861
|
-
async function
|
|
6150
|
+
async function parseZipData(data) {
|
|
5862
6151
|
const files = await unzipAsync(data);
|
|
5863
6152
|
if (!files["state.json"]) throw new Error("Initial state not found");
|
|
5864
6153
|
const initialState = JSON.parse(readEntry(files, "state.json"));
|
|
@@ -5871,14 +6160,32 @@ async function loadFromZipData(data, reducer, options) {
|
|
|
5871
6160
|
const errorMessages = operationsError.map((err) => err.message);
|
|
5872
6161
|
throw new Error(errorMessages.join("\n"));
|
|
5873
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);
|
|
5874
6171
|
return {
|
|
5875
6172
|
...replayDocument(initialState, Object.fromEntries(Object.entries(clearedOperations).filter(([scope]) => !NON_DOMAIN_SCOPES.has(scope))), reducer, header, void 0, {}, options),
|
|
5876
6173
|
operations: clearedOperations
|
|
5877
6174
|
};
|
|
5878
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
|
+
}
|
|
5879
6183
|
async function baseLoadFromInput(input, reducer, options) {
|
|
5880
6184
|
return loadFromZipData(await toUint8Array(input), reducer, options);
|
|
5881
6185
|
}
|
|
6186
|
+
async function baseLoadFromInputVersioned(input, config, options) {
|
|
6187
|
+
return loadFromZipDataVersioned(await toUint8Array(input), config, options);
|
|
6188
|
+
}
|
|
5882
6189
|
const documentModelLoadFromInput = (input) => {
|
|
5883
6190
|
return baseLoadFromInput(input, documentModelReducer);
|
|
5884
6191
|
};
|
|
@@ -7053,6 +7360,6 @@ const driveDocumentModelModule = {
|
|
|
7053
7360
|
}
|
|
7054
7361
|
};
|
|
7055
7362
|
//#endregion
|
|
7056
|
-
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 };
|
|
7057
7364
|
|
|
7058
|
-
//# sourceMappingURL=document-drive-
|
|
7365
|
+
//# sourceMappingURL=document-drive-sTKoi6L4.js.map
|