@fluidframework/container-loader 2.0.0-dev-rc.1.0.0.228517 → 2.0.0-dev-rc.1.0.0.232845
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/README.md +3 -3
- package/dist/attachment.d.ts +116 -0
- package/dist/attachment.d.ts.map +1 -0
- package/dist/attachment.js +82 -0
- package/dist/attachment.js.map +1 -0
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +1 -2
- package/dist/connectionManager.js.map +1 -1
- package/dist/container-loader-alpha.d.ts +1 -1
- package/dist/container-loader-untrimmed.d.ts +1 -1
- package/dist/container.d.ts +21 -8
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +177 -149
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +3 -2
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +2 -1
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts +3 -3
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +10 -11
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/loader.d.ts +1 -1
- package/dist/loader.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts +1 -0
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/protocolTreeDocumentStorageService.js +1 -0
- package/dist/protocolTreeDocumentStorageService.js.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts +2 -1
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +8 -0
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/utils.d.ts +13 -7
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +98 -29
- package/dist/utils.js.map +1 -1
- package/lib/attachment.d.mts +112 -0
- package/lib/attachment.d.mts.map +1 -0
- package/lib/attachment.mjs +74 -0
- package/lib/attachment.mjs.map +1 -0
- package/lib/connectionManager.d.mts.map +1 -1
- package/lib/connectionManager.mjs +2 -5
- package/lib/connectionManager.mjs.map +1 -1
- package/lib/container-loader-alpha.d.mts +1 -1
- package/lib/container-loader-untrimmed.d.mts +1 -1
- package/lib/container.d.mts +21 -8
- package/lib/container.d.mts.map +1 -1
- package/lib/container.mjs +176 -151
- package/lib/container.mjs.map +1 -1
- package/lib/containerContext.d.mts +3 -2
- package/lib/containerContext.d.mts.map +1 -1
- package/lib/containerContext.mjs +2 -1
- package/lib/containerContext.mjs.map +1 -1
- package/lib/containerStorageAdapter.d.mts +3 -3
- package/lib/containerStorageAdapter.d.mts.map +1 -1
- package/lib/containerStorageAdapter.mjs +10 -11
- package/lib/containerStorageAdapter.mjs.map +1 -1
- package/lib/loader.d.mts +1 -1
- package/lib/loader.mjs.map +1 -1
- package/lib/packageVersion.d.mts +1 -1
- package/lib/packageVersion.mjs +1 -1
- package/lib/packageVersion.mjs.map +1 -1
- package/lib/protocolTreeDocumentStorageService.d.mts +1 -0
- package/lib/protocolTreeDocumentStorageService.d.mts.map +1 -1
- package/lib/protocolTreeDocumentStorageService.mjs +1 -0
- package/lib/protocolTreeDocumentStorageService.mjs.map +1 -1
- package/lib/retriableDocumentStorageService.d.mts +2 -1
- package/lib/retriableDocumentStorageService.d.mts.map +1 -1
- package/lib/retriableDocumentStorageService.mjs +9 -1
- package/lib/retriableDocumentStorageService.mjs.map +1 -1
- package/lib/utils.d.mts +13 -7
- package/lib/utils.d.mts.map +1 -1
- package/lib/utils.mjs +96 -29
- package/lib/utils.mjs.map +1 -1
- package/package.json +21 -15
- package/src/attachment.ts +219 -0
- package/src/connectionManager.ts +2 -4
- package/src/container.ts +260 -191
- package/src/containerContext.ts +2 -1
- package/src/containerStorageAdapter.ts +15 -12
- package/src/loader.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/protocolTreeDocumentStorageService.ts +1 -0
- package/src/retriableDocumentStorageService.ts +18 -1
- package/src/utils.ts +128 -36
- /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
package/dist/utils.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.isDeltaStreamConnectionForbiddenError = exports.
|
|
7
|
+
exports.runSingle = exports.getDetachedContainerStateFromSerializedContainer = exports.isDeltaStreamConnectionForbiddenError = exports.combineSnapshotTreeAndSnapshotBlobs = exports.getProtocolSnapshotTree = exports.getSnapshotTreeAndBlobsFromSerializedContainer = exports.combineAppAndProtocolSummary = exports.tryParseCompatibleResolvedUrl = void 0;
|
|
8
8
|
const url_1 = require("url");
|
|
9
9
|
const uuid_1 = require("uuid");
|
|
10
10
|
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
@@ -55,19 +55,14 @@ function combineAppAndProtocolSummary(appSummary, protocolSummary) {
|
|
|
55
55
|
}
|
|
56
56
|
exports.combineAppAndProtocolSummary = combineAppAndProtocolSummary;
|
|
57
57
|
/**
|
|
58
|
-
* Converts summary
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* snapshot tree for each blob in the summary tree. One will be the regular
|
|
62
|
-
* path pointing to a uniquely generated ID. Then there will be another
|
|
63
|
-
* entry with the path as that uniquely generated ID, and value as the
|
|
64
|
-
* blob contents as a base-64 string.
|
|
65
|
-
* @param summary - summary to convert
|
|
58
|
+
* Converts a summary to snapshot tree and separate its blob contents
|
|
59
|
+
* to align detached container format with IPendingContainerState
|
|
60
|
+
* @param summary - ISummaryTree
|
|
66
61
|
*/
|
|
67
|
-
function
|
|
62
|
+
function convertSummaryToSnapshotAndBlobs(summary) {
|
|
63
|
+
let blobContents = {};
|
|
68
64
|
const treeNode = {
|
|
69
65
|
blobs: {},
|
|
70
|
-
blobsContents: {},
|
|
71
66
|
trees: {},
|
|
72
67
|
id: (0, uuid_1.v4)(),
|
|
73
68
|
unreferenced: summary.unreferenced,
|
|
@@ -77,8 +72,9 @@ function convertSummaryToSnapshotWithEmbeddedBlobContents(summary) {
|
|
|
77
72
|
const summaryObject = summary.tree[key];
|
|
78
73
|
switch (summaryObject.type) {
|
|
79
74
|
case protocol_definitions_1.SummaryType.Tree: {
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
const { tree, blobs } = convertSummaryToSnapshotAndBlobs(summaryObject);
|
|
76
|
+
treeNode.trees[key] = tree;
|
|
77
|
+
blobContents = { ...blobContents, ...blobs };
|
|
82
78
|
break;
|
|
83
79
|
}
|
|
84
80
|
case protocol_definitions_1.SummaryType.Attachment:
|
|
@@ -87,10 +83,10 @@ function convertSummaryToSnapshotWithEmbeddedBlobContents(summary) {
|
|
|
87
83
|
case protocol_definitions_1.SummaryType.Blob: {
|
|
88
84
|
const blobId = (0, uuid_1.v4)();
|
|
89
85
|
treeNode.blobs[key] = blobId;
|
|
90
|
-
const
|
|
91
|
-
? (0, client_utils_1.
|
|
92
|
-
:
|
|
93
|
-
|
|
86
|
+
const contentString = summaryObject.content instanceof Uint8Array
|
|
87
|
+
? (0, client_utils_1.Uint8ArrayToString)(summaryObject.content)
|
|
88
|
+
: summaryObject.content;
|
|
89
|
+
blobContents[blobId] = contentString;
|
|
94
90
|
break;
|
|
95
91
|
}
|
|
96
92
|
case protocol_definitions_1.SummaryType.Handle:
|
|
@@ -101,42 +97,115 @@ function convertSummaryToSnapshotWithEmbeddedBlobContents(summary) {
|
|
|
101
97
|
}
|
|
102
98
|
}
|
|
103
99
|
}
|
|
104
|
-
return treeNode;
|
|
100
|
+
return { tree: treeNode, blobs: blobContents };
|
|
105
101
|
}
|
|
106
102
|
/**
|
|
107
|
-
*
|
|
103
|
+
* Converts summary parts into a SnapshotTree and its blob contents.
|
|
108
104
|
* @param protocolSummaryTree - Protocol Summary Tree
|
|
109
105
|
* @param appSummaryTree - App Summary Tree
|
|
110
106
|
*/
|
|
111
|
-
function
|
|
112
|
-
// Shallow copy is fine, since we are doing a deep clone below.
|
|
107
|
+
function convertProtocolAndAppSummaryToSnapshotAndBlobs(protocolSummaryTree, appSummaryTree) {
|
|
113
108
|
const combinedSummary = {
|
|
114
109
|
type: protocol_definitions_1.SummaryType.Tree,
|
|
115
110
|
tree: { ...appSummaryTree.tree },
|
|
116
111
|
};
|
|
117
112
|
combinedSummary.tree[".protocol"] = protocolSummaryTree;
|
|
118
|
-
const snapshotTreeWithBlobContents =
|
|
113
|
+
const snapshotTreeWithBlobContents = convertSummaryToSnapshotAndBlobs(combinedSummary);
|
|
119
114
|
return snapshotTreeWithBlobContents;
|
|
120
115
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
// a detached container can be rehydrated.
|
|
124
|
-
const getSnapshotTreeFromSerializedContainer = (detachedContainerSnapshot) => {
|
|
125
|
-
(0, core_utils_1.assert)((0, driver_utils_1.isCombinedAppAndProtocolSummary)(detachedContainerSnapshot), 0x1e0 /* "Protocol and App summary trees should be present" */);
|
|
116
|
+
const getSnapshotTreeAndBlobsFromSerializedContainer = (detachedContainerSnapshot) => {
|
|
117
|
+
(0, core_utils_1.assert)((0, driver_utils_1.isCombinedAppAndProtocolSummary)(detachedContainerSnapshot), "Protocol and App summary trees should be present");
|
|
126
118
|
const protocolSummaryTree = detachedContainerSnapshot.tree[".protocol"];
|
|
127
119
|
const appSummaryTree = detachedContainerSnapshot.tree[".app"];
|
|
128
|
-
const snapshotTreeWithBlobContents =
|
|
120
|
+
const snapshotTreeWithBlobContents = convertProtocolAndAppSummaryToSnapshotAndBlobs(protocolSummaryTree, appSummaryTree);
|
|
129
121
|
return snapshotTreeWithBlobContents;
|
|
130
122
|
};
|
|
131
|
-
exports.
|
|
123
|
+
exports.getSnapshotTreeAndBlobsFromSerializedContainer = getSnapshotTreeAndBlobsFromSerializedContainer;
|
|
132
124
|
function getProtocolSnapshotTree(snapshot) {
|
|
133
125
|
return ".protocol" in snapshot.trees ? snapshot.trees[".protocol"] : snapshot;
|
|
134
126
|
}
|
|
135
127
|
exports.getProtocolSnapshotTree = getProtocolSnapshotTree;
|
|
128
|
+
const combineSnapshotTreeAndSnapshotBlobs = (baseSnapshot, snapshotBlobs) => {
|
|
129
|
+
const blobsContents = {};
|
|
130
|
+
// Process blobs in the current level
|
|
131
|
+
for (const [, id] of Object.entries(baseSnapshot.blobs)) {
|
|
132
|
+
if (snapshotBlobs[id]) {
|
|
133
|
+
blobsContents[id] = (0, client_utils_1.stringToBuffer)(snapshotBlobs[id], "utf8");
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Recursively process trees in the current level
|
|
137
|
+
const trees = {};
|
|
138
|
+
for (const [path, tree] of Object.entries(baseSnapshot.trees)) {
|
|
139
|
+
trees[path] = (0, exports.combineSnapshotTreeAndSnapshotBlobs)(tree, snapshotBlobs);
|
|
140
|
+
}
|
|
141
|
+
// Create a new snapshot tree with blob contents and processed trees
|
|
142
|
+
const snapshotTreeWithBlobContents = {
|
|
143
|
+
...baseSnapshot,
|
|
144
|
+
blobsContents,
|
|
145
|
+
trees,
|
|
146
|
+
};
|
|
147
|
+
return snapshotTreeWithBlobContents;
|
|
148
|
+
};
|
|
149
|
+
exports.combineSnapshotTreeAndSnapshotBlobs = combineSnapshotTreeAndSnapshotBlobs;
|
|
136
150
|
function isDeltaStreamConnectionForbiddenError(error) {
|
|
137
151
|
return (typeof error === "object" &&
|
|
138
152
|
error !== null &&
|
|
139
153
|
error?.errorType === driver_definitions_1.DriverErrorTypes.deltaStreamConnectionForbidden);
|
|
140
154
|
}
|
|
141
155
|
exports.isDeltaStreamConnectionForbiddenError = isDeltaStreamConnectionForbiddenError;
|
|
156
|
+
/**
|
|
157
|
+
* Validates format in parsed string get from detached container
|
|
158
|
+
* serialization using IPendingDetachedContainerState format.
|
|
159
|
+
*/
|
|
160
|
+
function isPendingDetachedContainerState(detachedContainerState) {
|
|
161
|
+
if (detachedContainerState?.attached === undefined ||
|
|
162
|
+
detachedContainerState?.baseSnapshot === undefined ||
|
|
163
|
+
detachedContainerState?.snapshotBlobs === undefined ||
|
|
164
|
+
detachedContainerState?.hasAttachmentBlobs === undefined) {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
function getDetachedContainerStateFromSerializedContainer(serializedContainer) {
|
|
170
|
+
const hasBlobsSummaryTree = ".hasAttachmentBlobs";
|
|
171
|
+
const parsedContainerState = JSON.parse(serializedContainer);
|
|
172
|
+
if (isPendingDetachedContainerState(parsedContainerState)) {
|
|
173
|
+
return parsedContainerState;
|
|
174
|
+
}
|
|
175
|
+
else if ((0, driver_utils_1.isCombinedAppAndProtocolSummary)(parsedContainerState)) {
|
|
176
|
+
const { tree, blobs } = (0, exports.getSnapshotTreeAndBlobsFromSerializedContainer)(parsedContainerState);
|
|
177
|
+
const detachedContainerState = {
|
|
178
|
+
attached: false,
|
|
179
|
+
baseSnapshot: tree,
|
|
180
|
+
snapshotBlobs: blobs,
|
|
181
|
+
hasAttachmentBlobs: parsedContainerState.tree[hasBlobsSummaryTree] !== undefined,
|
|
182
|
+
};
|
|
183
|
+
return detachedContainerState;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
throw new telemetry_utils_1.UsageError("Cannot rehydrate detached container. Incorrect format");
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
exports.getDetachedContainerStateFromSerializedContainer = getDetachedContainerStateFromSerializedContainer;
|
|
190
|
+
/**
|
|
191
|
+
* Ensures only a single instance of the provided async function is running.
|
|
192
|
+
* If there are multiple calls they will all get the same promise to wait on.
|
|
193
|
+
*/
|
|
194
|
+
const runSingle = (func) => {
|
|
195
|
+
let running;
|
|
196
|
+
// don't mark this function async, so we return the same promise,
|
|
197
|
+
// rather than one that is wrapped due to async
|
|
198
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
199
|
+
return (...args) => {
|
|
200
|
+
if (running !== undefined) {
|
|
201
|
+
if (!(0, core_utils_1.compareArrays)(running.args, args)) {
|
|
202
|
+
return Promise.reject(new telemetry_utils_1.UsageError("Subsequent calls cannot use different arguments."));
|
|
203
|
+
}
|
|
204
|
+
return running.result;
|
|
205
|
+
}
|
|
206
|
+
running = { args, result: func(...args).finally(() => (running = undefined)) };
|
|
207
|
+
return running.result;
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
exports.runSingle = runSingle;
|
|
142
211
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAA4B;AAC5B,+BAAkC;AAClC,+DAAuF;AACvF,2DAAqE;AACrE,+EAAgG;AAChG,qEAA+D;AAC/D,+DAIsC;AACtC,2EAAsE;AAoCtE;;;;;;;;GAQG;AACH,SAAgB,6BAA6B,CAAC,GAAW;IACxD,MAAM,MAAM,GAAG,IAAA,WAAK,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAChC,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE;QACxC,MAAM,IAAI,8BAAY,CAAC,0BAA0B,CAAC,CAAC;KACnD;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;IAClC,MAAM,KAAK,GAAG,2BAA2B,CAAC;IAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1C,OAAO,KAAK,EAAE,MAAM,KAAK,CAAC;QACzB,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,OAAiB,EAAE;QAClF,CAAC,CAAC,SAAS,CAAC;A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CAAC;IACF,MAAM,mBAAmB,GAAG,yBAAyB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACxE,MAAM,cAAc,GAAG,yBAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9D,MAAM,4BAA4B,GAAG,0CAA0C,CAC9E,mBAAmB,EACnB,cAAc,CACd,CAAC;IACF,OAAO,4BAA4B,CAAC;AACrC,CAAC,CAAC;AAdW,QAAA,sCAAsC,0CAcjD;AAEF,SAAgB,uBAAuB,CAAC,QAAuB;IAC9D,OAAO,WAAW,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC/E,CAAC;AAFD,0DAEC;AAED,SAAgB,qCAAqC,CACpD,KAAU;IAEV,OAAO,CACN,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,KAAK,EAAE,SAAS,KAAK,qCAAgB,CAAC,8BAA8B,CACpE,CAAC;AACH,CAAC;AARD,sFAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport { v4 as uuid } from \"uuid\";\nimport { stringToBuffer, Uint8ArrayToArrayBuffer } from \"@fluid-internal/client-utils\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils\";\nimport { ISummaryTree, ISnapshotTree, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport { LoggingError } from \"@fluidframework/telemetry-utils\";\nimport {\n\tCombinedAppAndProtocolSummary,\n\tDeltaStreamConnectionForbiddenError,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions\";\n\n// This is used when we rehydrate a container from the snapshot. Here we put the blob contents\n// in separate property: blobContents.\nexport interface ISnapshotTreeWithBlobContents extends ISnapshotTree {\n\tblobsContents: { [path: string]: ArrayBufferLike };\n\ttrees: { [path: string]: ISnapshotTreeWithBlobContents };\n}\n\n/**\n * Interface to represent the parsed parts of IResolvedUrl.url to help\n * in getting info about different parts of the url.\n * May not be compatible or relevant for any Url Resolver\n * @internal\n */\nexport interface IParsedUrl {\n\t/**\n\t * It is combination of tenantid/docId part of the url.\n\t */\n\tid: string;\n\t/**\n\t * It is the deep link path in the url.\n\t */\n\tpath: string;\n\t/**\n\t * Query string part of the url.\n\t */\n\tquery: string;\n\t/**\n\t * Null means do not use snapshots, undefined means load latest snapshot\n\t * otherwise it's version ID passed to IDocumentStorageService.getVersions() to figure out what snapshot to use.\n\t * If needed, can add undefined which is treated by Container.load() as load latest snapshot.\n\t */\n\tversion: string | null | undefined;\n}\n\n/**\n * Utility api to parse the IResolvedUrl.url into specific parts like querystring, path to get\n * deep link info etc.\n * Warning - This function may not be compatible with any Url Resolver's resolved url. It works\n * with urls of type: protocol://<string>/.../..?<querystring>\n * @param url - This is the IResolvedUrl.url part of the resolved url.\n * @returns The IParsedUrl representing the input URL, or undefined if the format was not supported\n * @internal\n */\nexport function tryParseCompatibleResolvedUrl(url: string): IParsedUrl | undefined {\n\tconst parsed = parse(url, true);\n\tif (typeof parsed.pathname !== \"string\") {\n\t\tthrow new LoggingError(\"Failed to parse pathname\");\n\t}\n\tconst query = parsed.search ?? \"\";\n\tconst regex = /^\\/([^/]*\\/[^/]*)(\\/?.*)$/;\n\tconst match = regex.exec(parsed.pathname);\n\treturn match?.length === 3\n\t\t? { id: match[1], path: match[2], query, version: parsed.query.version as string }\n\t\t: undefined;\n}\n\n/**\n * Combine the app summary and protocol summary in 1 tree.\n * @param appSummary - Summary of the app.\n * @param protocolSummary - Summary of the protocol.\n * @internal\n */\nexport function combineAppAndProtocolSummary(\n\tappSummary: ISummaryTree,\n\tprotocolSummary: ISummaryTree,\n): CombinedAppAndProtocolSummary {\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(appSummary),\n\t\t0x5a8 /* app summary is already a combined tree! */,\n\t);\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(protocolSummary),\n\t\t0x5a9 /* protocol summary is already a combined tree! */,\n\t);\n\tconst createNewSummary: CombinedAppAndProtocolSummary = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\treturn createNewSummary;\n}\n\n/**\n * Converts summary tree (for upload) to snapshot tree (for download).\n * Summary tree blobs contain contents, but snapshot tree blobs normally\n * contain IDs pointing to storage. This will create 2 blob entries in the\n * snapshot tree for each blob in the summary tree. One will be the regular\n * path pointing to a uniquely generated ID. Then there will be another\n * entry with the path as that uniquely generated ID, and value as the\n * blob contents as a base-64 string.\n * @param summary - summary to convert\n */\nfunction convertSummaryToSnapshotWithEmbeddedBlobContents(\n\tsummary: ISummaryTree,\n): ISnapshotTreeWithBlobContents {\n\tconst treeNode: ISnapshotTreeWithBlobContents = {\n\t\tblobs: {},\n\t\tblobsContents: {},\n\t\ttrees: {},\n\t\tid: uuid(),\n\t\tunreferenced: summary.unreferenced,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\ttreeNode.trees[key] =\n\t\t\t\t\tconvertSummaryToSnapshotWithEmbeddedBlobContents(summaryObject);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Attachment:\n\t\t\t\ttreeNode.blobs[key] = summaryObject.id;\n\t\t\t\tbreak;\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tconst contentBuffer =\n\t\t\t\t\ttypeof summaryObject.content === \"string\"\n\t\t\t\t\t\t? stringToBuffer(summaryObject.content, \"utf8\")\n\t\t\t\t\t\t: Uint8ArrayToArrayBuffer(summaryObject.content);\n\t\t\t\ttreeNode.blobsContents[blobId] = contentBuffer;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\t\tthrow new LoggingError(\n\t\t\t\t\t\"No handles should be there in summary in detached container!!\",\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(summaryObject, `Unknown tree type ${(summaryObject as any).type}`);\n\t\t\t}\n\t\t}\n\t}\n\treturn treeNode;\n}\n\n/**\n * Combine and convert protocol and app summary tree to format which is readable by container while rehydrating.\n * @param protocolSummaryTree - Protocol Summary Tree\n * @param appSummaryTree - App Summary Tree\n */\nexport function convertProtocolAndAppSummaryToSnapshotTree(\n\tprotocolSummaryTree: ISummaryTree,\n\tappSummaryTree: ISummaryTree,\n): ISnapshotTreeWithBlobContents {\n\t// Shallow copy is fine, since we are doing a deep clone below.\n\tconst combinedSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: { ...appSummaryTree.tree },\n\t};\n\n\tcombinedSummary.tree[\".protocol\"] = protocolSummaryTree;\n\tconst snapshotTreeWithBlobContents =\n\t\tconvertSummaryToSnapshotWithEmbeddedBlobContents(combinedSummary);\n\treturn snapshotTreeWithBlobContents;\n}\n\n// This function converts the snapshot taken in detached container(by serialize api) to snapshotTree with which\n// a detached container can be rehydrated.\nexport const getSnapshotTreeFromSerializedContainer = (\n\tdetachedContainerSnapshot: ISummaryTree,\n): ISnapshotTreeWithBlobContents => {\n\tassert(\n\t\tisCombinedAppAndProtocolSummary(detachedContainerSnapshot),\n\t\t0x1e0 /* \"Protocol and App summary trees should be present\" */,\n\t);\n\tconst protocolSummaryTree = detachedContainerSnapshot.tree[\".protocol\"];\n\tconst appSummaryTree = detachedContainerSnapshot.tree[\".app\"];\n\tconst snapshotTreeWithBlobContents = convertProtocolAndAppSummaryToSnapshotTree(\n\t\tprotocolSummaryTree,\n\t\tappSummaryTree,\n\t);\n\treturn snapshotTreeWithBlobContents;\n};\n\nexport function getProtocolSnapshotTree(snapshot: ISnapshotTree): ISnapshotTree {\n\treturn \".protocol\" in snapshot.trees ? snapshot.trees[\".protocol\"] : snapshot;\n}\n\nexport function isDeltaStreamConnectionForbiddenError(\n\terror: any,\n): error is DeltaStreamConnectionForbiddenError {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\terror?.errorType === DriverErrorTypes.deltaStreamConnectionForbidden\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAA4B;AAC5B,+BAAkC;AAClC,+DAAkF;AAClF,2DAAoF;AACpF,+EAAgG;AAChG,qEAA2E;AAC3E,+DAIsC;AACtC,2EAAsE;AAsCtE;;;;;;;;GAQG;AACH,SAAgB,6BAA6B,CAAC,GAAW;IACxD,MAAM,MAAM,GAAG,IAAA,WAAK,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAChC,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE;QACxC,MAAM,IAAI,8BAAY,CAAC,0BAA0B,CAAC,CAAC;KACnD;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;IAClC,MAAM,KAAK,GAAG,2BAA2B,CAAC;IAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1C,OAAO,KAAK,EAAE,MAAM,KAAK,CAAC;QACzB,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,OAAiB,EAAE;QAClF,CAAC,CAAC,SAAS,CAAC;AACd,CAAC;AAXD,sEAWC;AAED;;;;;GAKG;AACH,SAAgB,4BAA4B,CAC3C,UAAwB,EACxB,eAA6B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E;IACjF,IAAI,OAKQ,CAAC;IACb,iEAAiE;IACjE,+CAA+C;IAC/C,qEAAqE;IACrE,OAAO,CAAC,GAAG,IAAO,EAAE,EAAE;QACrB,IAAI,OAAO,KAAK,SAAS,EAAE;YAC1B,IAAI,CAAC,IAAA,0BAAa,EAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE;gBACvC,OAAO,OAAO,CAAC,MAAM,CACpB,IAAI,4BAAU,CAAC,kDAAkD,CAAC,CAClE,CAAC;aACF;YACD,OAAO,OAAO,CAAC,MAAM,CAAC;SACtB;QACD,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC;QAC/E,OAAO,OAAO,CAAC,MAAM,CAAC;IACvB,CAAC,CAAC;AACH,CAAC,CAAC;AAtBW,QAAA,SAAS,aAsBpB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport { v4 as uuid } from \"uuid\";\nimport { Uint8ArrayToString, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { assert, compareArrays, unreachableCase } from \"@fluidframework/core-utils\";\nimport { ISummaryTree, ISnapshotTree, SummaryType } from \"@fluidframework/protocol-definitions\";\nimport { LoggingError, UsageError } from \"@fluidframework/telemetry-utils\";\nimport {\n\tCombinedAppAndProtocolSummary,\n\tDeltaStreamConnectionForbiddenError,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions\";\nimport { ISerializableBlobContents } from \"./containerStorageAdapter\";\nimport { IPendingDetachedContainerState } from \"./container\";\n\n// This is used when we rehydrate a container from the snapshot. Here we put the blob contents\n// in separate property: blobContents.\nexport interface ISnapshotTreeWithBlobContents extends ISnapshotTree {\n\tblobsContents: { [path: string]: ArrayBufferLike };\n\ttrees: { [path: string]: ISnapshotTreeWithBlobContents };\n}\n\n/**\n * Interface to represent the parsed parts of IResolvedUrl.url to help\n * in getting info about different parts of the url.\n * May not be compatible or relevant for any Url Resolver\n * @internal\n */\nexport interface IParsedUrl {\n\t/**\n\t * It is combination of tenantid/docId part of the url.\n\t */\n\tid: string;\n\t/**\n\t * It is the deep link path in the url.\n\t */\n\tpath: string;\n\t/**\n\t * Query string part of the url.\n\t */\n\tquery: string;\n\t/**\n\t * Null means do not use snapshots, undefined means load latest snapshot\n\t * otherwise it's version ID passed to IDocumentStorageService.getVersions() to figure out what snapshot to use.\n\t * If needed, can add undefined which is treated by Container.load() as load latest snapshot.\n\t */\n\tversion: string | null | undefined;\n}\n\n/**\n * Utility api to parse the IResolvedUrl.url into specific parts like querystring, path to get\n * deep link info etc.\n * Warning - This function may not be compatible with any Url Resolver's resolved url. It works\n * with urls of type: protocol://<string>/.../..?<querystring>\n * @param url - This is the IResolvedUrl.url part of the resolved url.\n * @returns The IParsedUrl representing the input URL, or undefined if the format was not supported\n * @internal\n */\nexport function tryParseCompatibleResolvedUrl(url: string): IParsedUrl | undefined {\n\tconst parsed = parse(url, true);\n\tif (typeof parsed.pathname !== \"string\") {\n\t\tthrow new LoggingError(\"Failed to parse pathname\");\n\t}\n\tconst query = parsed.search ?? \"\";\n\tconst regex = /^\\/([^/]*\\/[^/]*)(\\/?.*)$/;\n\tconst match = regex.exec(parsed.pathname);\n\treturn match?.length === 3\n\t\t? { id: match[1], path: match[2], query, version: parsed.query.version as string }\n\t\t: undefined;\n}\n\n/**\n * Combine the app summary and protocol summary in 1 tree.\n * @param appSummary - Summary of the app.\n * @param protocolSummary - Summary of the protocol.\n * @internal\n */\nexport function combineAppAndProtocolSummary(\n\tappSummary: ISummaryTree,\n\tprotocolSummary: ISummaryTree,\n): CombinedAppAndProtocolSummary {\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(appSummary),\n\t\t0x5a8 /* app summary is already a combined tree! */,\n\t);\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(protocolSummary),\n\t\t0x5a9 /* protocol summary is already a combined tree! */,\n\t);\n\tconst createNewSummary: CombinedAppAndProtocolSummary = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\treturn createNewSummary;\n}\n\n/**\n * Converts a summary to snapshot tree and separate its blob contents\n * to align detached container format with IPendingContainerState\n * @param summary - ISummaryTree\n */\nfunction convertSummaryToSnapshotAndBlobs(summary: ISummaryTree): {\n\ttree: ISnapshotTree;\n\tblobs: ISerializableBlobContents;\n} {\n\tlet blobContents: ISerializableBlobContents = {};\n\tconst treeNode: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees: {},\n\t\tid: uuid(),\n\t\tunreferenced: summary.unreferenced,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tconst { tree, blobs } = convertSummaryToSnapshotAndBlobs(summaryObject);\n\t\t\t\ttreeNode.trees[key] = tree;\n\t\t\t\tblobContents = { ...blobContents, ...blobs };\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Attachment:\n\t\t\t\ttreeNode.blobs[key] = summaryObject.id;\n\t\t\t\tbreak;\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tconst contentString: string =\n\t\t\t\t\tsummaryObject.content instanceof Uint8Array\n\t\t\t\t\t\t? Uint8ArrayToString(summaryObject.content)\n\t\t\t\t\t\t: summaryObject.content;\n\t\t\t\tblobContents[blobId] = contentString;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\t\tthrow new LoggingError(\n\t\t\t\t\t\"No handles should be there in summary in detached container!!\",\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(summaryObject, `Unknown tree type ${(summaryObject as any).type}`);\n\t\t\t}\n\t\t}\n\t}\n\treturn { tree: treeNode, blobs: blobContents };\n}\n\n/**\n * Converts summary parts into a SnapshotTree and its blob contents.\n * @param protocolSummaryTree - Protocol Summary Tree\n * @param appSummaryTree - App Summary Tree\n */\nfunction convertProtocolAndAppSummaryToSnapshotAndBlobs(\n\tprotocolSummaryTree: ISummaryTree,\n\tappSummaryTree: ISummaryTree,\n): { tree: ISnapshotTree; blobs: ISerializableBlobContents } {\n\tconst combinedSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: { ...appSummaryTree.tree },\n\t};\n\n\tcombinedSummary.tree[\".protocol\"] = protocolSummaryTree;\n\tconst snapshotTreeWithBlobContents = convertSummaryToSnapshotAndBlobs(combinedSummary);\n\treturn snapshotTreeWithBlobContents;\n}\n\nexport const getSnapshotTreeAndBlobsFromSerializedContainer = (\n\tdetachedContainerSnapshot: ISummaryTree,\n): { tree: ISnapshotTree; blobs: ISerializableBlobContents } => {\n\tassert(\n\t\tisCombinedAppAndProtocolSummary(detachedContainerSnapshot),\n\t\t\"Protocol and App summary trees should be present\",\n\t);\n\tconst protocolSummaryTree = detachedContainerSnapshot.tree[\".protocol\"];\n\tconst appSummaryTree = detachedContainerSnapshot.tree[\".app\"];\n\tconst snapshotTreeWithBlobContents = convertProtocolAndAppSummaryToSnapshotAndBlobs(\n\t\tprotocolSummaryTree,\n\t\tappSummaryTree,\n\t);\n\treturn snapshotTreeWithBlobContents;\n};\n\nexport function getProtocolSnapshotTree(snapshot: ISnapshotTree): ISnapshotTree {\n\treturn \".protocol\" in snapshot.trees ? snapshot.trees[\".protocol\"] : snapshot;\n}\n\nexport const combineSnapshotTreeAndSnapshotBlobs = (\n\tbaseSnapshot: ISnapshotTree,\n\tsnapshotBlobs: ISerializableBlobContents,\n): ISnapshotTreeWithBlobContents => {\n\tconst blobsContents: { [path: string]: ArrayBufferLike } = {};\n\n\t// Process blobs in the current level\n\tfor (const [, id] of Object.entries(baseSnapshot.blobs)) {\n\t\tif (snapshotBlobs[id]) {\n\t\t\tblobsContents[id] = stringToBuffer(snapshotBlobs[id], \"utf8\");\n\t\t}\n\t}\n\n\t// Recursively process trees in the current level\n\tconst trees: { [path: string]: ISnapshotTreeWithBlobContents } = {};\n\tfor (const [path, tree] of Object.entries(baseSnapshot.trees)) {\n\t\ttrees[path] = combineSnapshotTreeAndSnapshotBlobs(tree, snapshotBlobs);\n\t}\n\n\t// Create a new snapshot tree with blob contents and processed trees\n\tconst snapshotTreeWithBlobContents: ISnapshotTreeWithBlobContents = {\n\t\t...baseSnapshot,\n\t\tblobsContents,\n\t\ttrees,\n\t};\n\n\treturn snapshotTreeWithBlobContents;\n};\n\nexport function isDeltaStreamConnectionForbiddenError(\n\terror: any,\n): error is DeltaStreamConnectionForbiddenError {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\terror?.errorType === DriverErrorTypes.deltaStreamConnectionForbidden\n\t);\n}\n\n/**\n * Validates format in parsed string get from detached container\n * serialization using IPendingDetachedContainerState format.\n */\nfunction isPendingDetachedContainerState(\n\tdetachedContainerState: IPendingDetachedContainerState,\n): detachedContainerState is IPendingDetachedContainerState {\n\tif (\n\t\tdetachedContainerState?.attached === undefined ||\n\t\tdetachedContainerState?.baseSnapshot === undefined ||\n\t\tdetachedContainerState?.snapshotBlobs === undefined ||\n\t\tdetachedContainerState?.hasAttachmentBlobs === undefined\n\t) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\nexport function getDetachedContainerStateFromSerializedContainer(\n\tserializedContainer: string,\n): IPendingDetachedContainerState {\n\tconst hasBlobsSummaryTree = \".hasAttachmentBlobs\";\n\tconst parsedContainerState = JSON.parse(serializedContainer);\n\tif (isPendingDetachedContainerState(parsedContainerState)) {\n\t\treturn parsedContainerState;\n\t} else if (isCombinedAppAndProtocolSummary(parsedContainerState)) {\n\t\tconst { tree, blobs } =\n\t\t\tgetSnapshotTreeAndBlobsFromSerializedContainer(parsedContainerState);\n\t\tconst detachedContainerState: IPendingDetachedContainerState = {\n\t\t\tattached: false,\n\t\t\tbaseSnapshot: tree,\n\t\t\tsnapshotBlobs: blobs,\n\t\t\thasAttachmentBlobs: parsedContainerState.tree[hasBlobsSummaryTree] !== undefined,\n\t\t};\n\t\treturn detachedContainerState;\n\t} else {\n\t\tthrow new UsageError(\"Cannot rehydrate detached container. Incorrect format\");\n\t}\n}\n\n/**\n * Ensures only a single instance of the provided async function is running.\n * If there are multiple calls they will all get the same promise to wait on.\n */\nexport const runSingle = <A extends any[], R>(func: (...args: A) => Promise<R>) => {\n\tlet running:\n\t\t| {\n\t\t\t\targs: A;\n\t\t\t\tresult: Promise<R>;\n\t\t }\n\t\t| undefined;\n\t// don't mark this function async, so we return the same promise,\n\t// rather than one that is wrapped due to async\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\treturn (...args: A) => {\n\t\tif (running !== undefined) {\n\t\t\tif (!compareArrays(running.args, args)) {\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew UsageError(\"Subsequent calls cannot use different arguments.\"),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn running.result;\n\t\t}\n\t\trunning = { args, result: func(...args).finally(() => (running = undefined)) };\n\t\treturn running.result;\n\t};\n};\n"]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { AttachState } from "@fluidframework/container-definitions";
|
|
2
|
+
import { CombinedAppAndProtocolSummary } from "@fluidframework/driver-utils";
|
|
3
|
+
import { ISnapshotTree, ISummaryTree } from "@fluidframework/protocol-definitions";
|
|
4
|
+
import { IDocumentStorageService } from "@fluidframework/driver-definitions";
|
|
5
|
+
import { ISerializableBlobContents } from "./containerStorageAdapter.mjs";
|
|
6
|
+
import { IDetachedBlobStorage } from ".";
|
|
7
|
+
/**
|
|
8
|
+
* The default state a newly created detached container will have.
|
|
9
|
+
* All but the state are optional and undefined, they just exist
|
|
10
|
+
* to make the union easy to deal with for both Detached types
|
|
11
|
+
*/
|
|
12
|
+
export interface DetachedDefaultData {
|
|
13
|
+
readonly state: AttachState.Detached;
|
|
14
|
+
readonly blobs?: undefined;
|
|
15
|
+
readonly summary?: undefined;
|
|
16
|
+
readonly redirectTable?: undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* This always follows DetachedDefaultData when there are
|
|
20
|
+
* outstanding blobs in the detached blob storage.
|
|
21
|
+
* The redirect table will get filled up to include data
|
|
22
|
+
* about the blobs as they are uploaded.
|
|
23
|
+
*/
|
|
24
|
+
export interface DetachedDataWithOutstandingBlobs {
|
|
25
|
+
readonly state: AttachState.Detached;
|
|
26
|
+
readonly blobs: "outstanding";
|
|
27
|
+
readonly summary?: undefined;
|
|
28
|
+
readonly redirectTable: Map<string, string>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* This state always follows DetachedDataWithOutstandingBlobs.
|
|
32
|
+
* It signals that all outstanding blobs are done being uploaded,
|
|
33
|
+
* so the container can move to the attaching state.
|
|
34
|
+
*/
|
|
35
|
+
export interface AttachingDataWithBlobs {
|
|
36
|
+
readonly state: AttachState.Attaching;
|
|
37
|
+
readonly blobs: "done";
|
|
38
|
+
readonly summary: CombinedAppAndProtocolSummary;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* This always follows DefaultDetachedState when there are
|
|
42
|
+
* no blobs in the detached blob storage. Because there are
|
|
43
|
+
* no blobs we can immediately get the summary and transition
|
|
44
|
+
* to the attaching state.
|
|
45
|
+
*/
|
|
46
|
+
export interface AttachingDataWithoutBlobs {
|
|
47
|
+
readonly state: AttachState.Attaching;
|
|
48
|
+
readonly summary: CombinedAppAndProtocolSummary;
|
|
49
|
+
readonly blobs: "none";
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* The final attachment state which signals the container is fully attached.
|
|
53
|
+
* The baseSnapshotAndBlobs will only be enabled when offline load is enabled.
|
|
54
|
+
*/
|
|
55
|
+
export interface AttachedData {
|
|
56
|
+
readonly state: AttachState.Attached;
|
|
57
|
+
readonly snapshot?: {
|
|
58
|
+
tree: ISnapshotTree;
|
|
59
|
+
blobs: ISerializableBlobContents;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A union of all the attachment data types for
|
|
64
|
+
* tracking across all container attachment states
|
|
65
|
+
*/
|
|
66
|
+
export type AttachmentData = DetachedDefaultData | DetachedDataWithOutstandingBlobs | AttachingDataWithoutBlobs | AttachingDataWithBlobs | AttachedData;
|
|
67
|
+
/**
|
|
68
|
+
* The data and services necessary for runRetriableAttachProcess.
|
|
69
|
+
*/
|
|
70
|
+
export interface AttachProcessProps {
|
|
71
|
+
/**
|
|
72
|
+
* The initial attachment data this call should start with
|
|
73
|
+
*/
|
|
74
|
+
readonly initialAttachmentData: Exclude<AttachmentData, AttachedData>;
|
|
75
|
+
/**
|
|
76
|
+
* The caller should use this callback to keep track of the current
|
|
77
|
+
* attachment data, and perform any other operations necessary
|
|
78
|
+
* for dealing with attachment state changes, like emitting events
|
|
79
|
+
*
|
|
80
|
+
* @param attachmentData - the updated attachment data */
|
|
81
|
+
readonly setAttachmentData: (attachmentData: AttachmentData) => void;
|
|
82
|
+
/**
|
|
83
|
+
* The caller should create and or get services based on the data, and its own information.
|
|
84
|
+
* @param data - the data to create services from,
|
|
85
|
+
* the summary property being the most relevant part of the data.
|
|
86
|
+
* @returns A compatible storage service
|
|
87
|
+
*/
|
|
88
|
+
readonly createOrGetStorageService: (data: ISummaryTree | undefined) => Promise<Pick<IDocumentStorageService, "createBlob" | "uploadSummaryWithContext">>;
|
|
89
|
+
/**
|
|
90
|
+
* The detached blob storage if it exists.
|
|
91
|
+
*/
|
|
92
|
+
readonly detachedBlobStorage?: Pick<IDetachedBlobStorage, "getBlobIds" | "readBlob" | "size">;
|
|
93
|
+
/**
|
|
94
|
+
* The caller should create the attachment summary for the container.
|
|
95
|
+
* @param redirectTable - Maps local blob ids to remote blobs ids.
|
|
96
|
+
* @returns The attachment summary for the container.
|
|
97
|
+
*/
|
|
98
|
+
readonly createAttachmentSummary: (redirectTable?: Map<string, string>) => CombinedAppAndProtocolSummary;
|
|
99
|
+
/**
|
|
100
|
+
* Whether offline load is enabled or not.
|
|
101
|
+
*/
|
|
102
|
+
readonly offlineLoadEnabled: boolean;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Executes the attach process state machine based on the provided data and services.
|
|
106
|
+
* This method is retriable on failure. Based on the provided initialAttachmentData
|
|
107
|
+
* this method will resume the attachment process and attempt to complete it.
|
|
108
|
+
*
|
|
109
|
+
* @param props - The data and services necessary to run the attachment process
|
|
110
|
+
*/
|
|
111
|
+
export declare const runRetriableAttachProcess: (props: AttachProcessProps) => Promise<void>;
|
|
112
|
+
//# sourceMappingURL=attachment.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment.d.mts","sourceRoot":"","sources":["../src/attachment.ts"],"names":[],"mappings":"OAIO,EAAE,WAAW,EAAE,MAAM,uCAAuC;OAC5D,EAAE,6BAA6B,EAAE,MAAM,8BAA8B;OACrE,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sCAAsC;OAE3E,EAAE,uBAAuB,EAAE,MAAM,oCAAoC;OAErE,EAAE,yBAAyB,EAAE;OAC7B,EAAE,oBAAoB,EAAE,MAAM,GAAG;AAExC;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,QAAQ,CAAC;IACrC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC;CACnC;AAED;;;;;GAKG;AACH,MAAM,WAA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I,EAAE,YAAY,GAAG,SAAS,KAC1B,OAAO,CAAC,IAAI,CAAC,uBAAuB,EAAE,YAAY,GAAG,0BAA0B,CAAC,CAAC,CAAC;IAEvF;;OAEG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,YAAY,GAAG,UAAU,GAAG,MAAM,CAAC,CAAC;IAE9F;;;;OAIG;IACH,QAAQ,CAAC,uBAAuB,EAAE,CACjC,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,KAC/B,6BAA6B,CAAC;IAEnC;;OAEG;IACH,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;CACrC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,UAAiB,kBAAkB,KAAG,QAAQ,IAAI,CAgFvF,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { AttachState } from "@fluidframework/container-definitions";
|
|
2
|
+
import { assert } from "@fluidframework/core-utils";
|
|
3
|
+
import { getSnapshotTreeAndBlobsFromSerializedContainer } from "./utils.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Executes the attach process state machine based on the provided data and services.
|
|
6
|
+
* This method is retriable on failure. Based on the provided initialAttachmentData
|
|
7
|
+
* this method will resume the attachment process and attempt to complete it.
|
|
8
|
+
*
|
|
9
|
+
* @param props - The data and services necessary to run the attachment process
|
|
10
|
+
*/
|
|
11
|
+
export const runRetriableAttachProcess = async (props) => {
|
|
12
|
+
const { detachedBlobStorage, createOrGetStorageService, setAttachmentData, createAttachmentSummary, offlineLoadEnabled, } = props;
|
|
13
|
+
let currentData = props.initialAttachmentData;
|
|
14
|
+
if (currentData.blobs === undefined) {
|
|
15
|
+
// If attachment blobs were uploaded in detached state we will go through a different attach flow
|
|
16
|
+
const outstandingAttachmentBlobs = detachedBlobStorage !== undefined && detachedBlobStorage.size > 0;
|
|
17
|
+
// Determine the next phase of attaching which depends on if there are attachment blobs
|
|
18
|
+
// if there are, we will stay detached, so an empty file can be created, and the blobs
|
|
19
|
+
// uploaded, otherwise we will get the summary to create the file with and move to attaching
|
|
20
|
+
currentData = outstandingAttachmentBlobs
|
|
21
|
+
? {
|
|
22
|
+
state: AttachState.Detached,
|
|
23
|
+
blobs: "outstanding",
|
|
24
|
+
redirectTable: new Map(),
|
|
25
|
+
}
|
|
26
|
+
: {
|
|
27
|
+
state: AttachState.Attaching,
|
|
28
|
+
summary: props.createAttachmentSummary(),
|
|
29
|
+
blobs: "none",
|
|
30
|
+
};
|
|
31
|
+
setAttachmentData(currentData);
|
|
32
|
+
}
|
|
33
|
+
// this has to run here, as it is what creates the file
|
|
34
|
+
// and we need to file for all possible cases after this point
|
|
35
|
+
const storage = await createOrGetStorageService(currentData.summary);
|
|
36
|
+
if (currentData.blobs === "outstanding") {
|
|
37
|
+
const { redirectTable } = currentData;
|
|
38
|
+
// upload blobs to storage
|
|
39
|
+
assert(!!detachedBlobStorage, 0x24e /* "assertion for type narrowing" */);
|
|
40
|
+
// build a table mapping IDs assigned locally to IDs assigned by storage and pass it to runtime to
|
|
41
|
+
// support blob handles that only know about the local IDs
|
|
42
|
+
while (redirectTable.size < detachedBlobStorage.size) {
|
|
43
|
+
const newIds = detachedBlobStorage.getBlobIds().filter((id) => !redirectTable.has(id));
|
|
44
|
+
for (const id of newIds) {
|
|
45
|
+
const blob = await detachedBlobStorage.readBlob(id);
|
|
46
|
+
const response = await storage.createBlob(blob);
|
|
47
|
+
redirectTable.set(id, response.id);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
setAttachmentData((currentData = {
|
|
51
|
+
state: AttachState.Attaching,
|
|
52
|
+
summary: createAttachmentSummary(redirectTable),
|
|
53
|
+
blobs: "done",
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
assert(currentData.state === AttachState.Attaching, "must be attaching by this point");
|
|
57
|
+
if (currentData.blobs === "done") {
|
|
58
|
+
// done means outstanding blobs were uploaded.
|
|
59
|
+
// in that case an empty file was created, the blobs were uploaded
|
|
60
|
+
// and now this finally uploads the summary
|
|
61
|
+
await storage.uploadSummaryWithContext(currentData.summary, {
|
|
62
|
+
referenceSequenceNumber: 0,
|
|
63
|
+
ackHandle: undefined,
|
|
64
|
+
proposalHandle: undefined,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
setAttachmentData((currentData = {
|
|
68
|
+
state: AttachState.Attached,
|
|
69
|
+
snapshot: offlineLoadEnabled
|
|
70
|
+
? getSnapshotTreeAndBlobsFromSerializedContainer(currentData.summary)
|
|
71
|
+
: undefined,
|
|
72
|
+
}));
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=attachment.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachment.mjs","sourceRoot":"","sources":["../src/attachment.ts"],"names":[],"mappings":"OAIO,EAAE,WAAW,EAAE,MAAM,uCAAuC;OAG5D,EAAE,MAAM,EAAE,MAAM,4BAA4B;OAE5C,EAAE,8CAA8C,EAAE;AA0HzD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,KAAK,EAAE,KAAyB,EAAiB,EAAE;IAC3F,MAAM,EACL,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,GAClB,GAAG,KAAK,CAAC;IACV,IAAI,WAAW,GAAmB,KAAK,CAAC,qBAAqB,CAAC;IAE9D,IAAI,WAAW,CAAC,KAAK,KAAK,SAAS,EAAE;QACpC,iGAAiG;QACjG,MAAM,0BAA0B,GAC/B,mBAAmB,KAAK,SAAS,IAAI,mBAAmB,CAAC,IAAI,GAAG,CAAC,CAAC;QACnE,uFAAuF;QACvF,sFAAsF;QACtF,4FAA4F;QAC5F,WAAW,GAAG,0BAA0B;YACvC,CAAC,CAAC;gBACA,KAAK,EAAE,WAAW,CAAC,QAAQ;gBAC3B,KAAK,EAAE,aAAa;gBACpB,aAAa,EAAE,IAAI,GAAG,EAAkB;aACv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AAE,iCAAiC,CAAC,CAAC;IAEvF,IAAI,WAAW,CAAC,KAAK,KAAK,MAAM,EAAE;QACjC,8CAA8C;QAC9C,kEAAkE;QAClE,2CAA2C;QAC3C,MAAM,OAAO,CAAC,wBAAwB,CAAC,WAAW,CAAC,OAAO,EAAE;YAC3D,uBAAuB,EAAE,CAAC;YAC1B,SAAS,EAAE,SAAS;YACpB,cAAc,EAAE,SAAS;SACzB,CAAC,CAAC;KACH;IAED,iBAAiB,CAChB,CAAC,WAAW,GAAG;QACd,KAAK,EAAE,WAAW,CAAC,QAAQ;QAC3B,QAAQ,EAAE,kBAAkB;YAC3B,CAAC,CAAC,8CAA8C,CAAC,WAAW,CAAC,OAAO,CAAC;YACrE,CAAC,CAAC,SAAS;KACZ,CAAC,CACF,CAAC;AACH,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { CombinedAppAndProtocolSummary } from \"@fluidframework/driver-utils\";\nimport { ISnapshotTree, ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\nimport { getSnapshotTreeAndBlobsFromSerializedContainer } from \"./utils\";\nimport { ISerializableBlobContents } from \"./containerStorageAdapter\";\nimport { IDetachedBlobStorage } from \".\";\n\n/**\n * The default state a newly created detached container will have.\n * All but the state are optional and undefined, they just exist\n * to make the union easy to deal with for both Detached types\n */\nexport interface DetachedDefaultData {\n\treadonly state: AttachState.Detached;\n\treadonly blobs?: undefined;\n\treadonly summary?: undefined;\n\treadonly redirectTable?: undefined;\n}\n\n/**\n * This always follows DetachedDefaultData when there are\n * outstanding blobs in the detached blob storage.\n * The redirect table will get filled up to include data\n * about the blobs as they are uploaded.\n */\nexport interface DetachedDataWithOutstandingBlobs {\n\treadonly state: AttachState.Detached;\n\treadonly blobs: \"outstanding\";\n\treadonly summary?: undefined;\n\treadonly redirectTable: Map<string, string>;\n}\n\n/**\n * This state always follows DetachedDataWithOutstandingBlobs.\n * It signals that all outstanding blobs are done being uploaded,\n * so the container can move to the attaching state.\n */\nexport interface AttachingDataWithBlobs {\n\treadonly state: AttachState.Attaching;\n\treadonly blobs: \"done\";\n\treadonly summary: CombinedAppAndProtocolSummary;\n}\n\n/**\n * This always follows DefaultDetachedState when there are\n * no blobs in the detached blob storage. Because there are\n * no blobs we can immediately get the summary and transition\n * to the attaching state.\n */\nexport interface AttachingDataWithoutBlobs {\n\treadonly state: AttachState.Attaching;\n\treadonly summary: CombinedAppAndProtocolSummary;\n\treadonly blobs: \"none\";\n}\n\n/**\n * The final attachment state which signals the container is fully attached.\n * The baseSnapshotAndBlobs will only be enabled when offline load is enabled.\n */\nexport interface AttachedData {\n\treadonly state: AttachState.Attached;\n\treadonly snapshot?: {\n\t\ttree: ISnapshotTree;\n\t\tblobs: ISerializableBlobContents;\n\t};\n}\n\n/**\n * A union of all the attachment data types for\n * tracking across all container attachment states\n */\nexport type AttachmentData =\n\t| DetachedDefaultData\n\t| DetachedDataWithOutstandingBlobs\n\t| AttachingDataWithoutBlobs\n\t| AttachingDataWithBlobs\n\t| AttachedData;\n\n/**\n * The data and services necessary for runRetriableAttachProcess.\n */\nexport interface AttachProcessProps {\n\t/**\n\t * The initial attachment data this call should start with\n\t */\n\treadonly initialAttachmentData: Exclude<AttachmentData, AttachedData>;\n\n\t/**\n\t * The caller should use this callback to keep track of the current\n\t * attachment data, and perform any other operations necessary\n\t * for dealing with attachment state changes, like emitting events\n\t *\n\t * @param attachmentData - the updated attachment data\t */\n\treadonly setAttachmentData: (attachmentData: AttachmentData) => void;\n\n\t/**\n\t * The caller should create and or get services based on the data, and its own information.\n\t * @param data - the data to create services from,\n\t * the summary property being the most relevant part of the data.\n\t * @returns A compatible storage service\n\t */\n\treadonly createOrGetStorageService: (\n\t\tdata: ISummaryTree | undefined,\n\t) => Promise<Pick<IDocumentStorageService, \"createBlob\" | \"uploadSummaryWithContext\">>;\n\n\t/**\n\t * The detached blob storage if it exists.\n\t */\n\treadonly detachedBlobStorage?: Pick<IDetachedBlobStorage, \"getBlobIds\" | \"readBlob\" | \"size\">;\n\n\t/**\n\t * The caller should create the attachment summary for the container.\n\t * @param redirectTable - Maps local blob ids to remote blobs ids.\n\t * @returns The attachment summary for the container.\n\t */\n\treadonly createAttachmentSummary: (\n\t\tredirectTable?: Map<string, string>,\n\t) => CombinedAppAndProtocolSummary;\n\n\t/**\n\t * Whether offline load is enabled or not.\n\t */\n\treadonly offlineLoadEnabled: boolean;\n}\n\n/**\n * Executes the attach process state machine based on the provided data and services.\n * This method is retriable on failure. Based on the provided initialAttachmentData\n * this method will resume the attachment process and attempt to complete it.\n *\n * @param props - The data and services necessary to run the attachment process\n */\nexport const runRetriableAttachProcess = async (props: AttachProcessProps): Promise<void> => {\n\tconst {\n\t\tdetachedBlobStorage,\n\t\tcreateOrGetStorageService,\n\t\tsetAttachmentData,\n\t\tcreateAttachmentSummary,\n\t\tofflineLoadEnabled,\n\t} = props;\n\tlet currentData: AttachmentData = props.initialAttachmentData;\n\n\tif (currentData.blobs === undefined) {\n\t\t// If attachment blobs were uploaded in detached state we will go through a different attach flow\n\t\tconst outstandingAttachmentBlobs =\n\t\t\tdetachedBlobStorage !== undefined && detachedBlobStorage.size > 0;\n\t\t// Determine the next phase of attaching which depends on if there are attachment blobs\n\t\t// if there are, we will stay detached, so an empty file can be created, and the blobs\n\t\t// uploaded, otherwise we will get the summary to create the file with and move to attaching\n\t\tcurrentData = outstandingAttachmentBlobs\n\t\t\t? {\n\t\t\t\t\tstate: AttachState.Detached,\n\t\t\t\t\tblobs: \"outstanding\",\n\t\t\t\t\tredirectTable: new Map<string, string>(),\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\tstate: AttachState.Attaching,\n\t\t\t\t\tsummary: props.createAttachmentSummary(),\n\t\t\t\t\tblobs: \"none\",\n\t\t\t };\n\t\tsetAttachmentData(currentData);\n\t}\n\n\t// this has to run here, as it is what creates the file\n\t// and we need to file for all possible cases after this point\n\tconst storage = await createOrGetStorageService(currentData.summary);\n\n\tif (currentData.blobs === \"outstanding\") {\n\t\tconst { redirectTable } = currentData;\n\t\t// upload blobs to storage\n\t\tassert(!!detachedBlobStorage, 0x24e /* \"assertion for type narrowing\" */);\n\n\t\t// build a table mapping IDs assigned locally to IDs assigned by storage and pass it to runtime to\n\t\t// support blob handles that only know about the local IDs\n\t\twhile (redirectTable.size < detachedBlobStorage.size) {\n\t\t\tconst newIds = detachedBlobStorage.getBlobIds().filter((id) => !redirectTable.has(id));\n\t\t\tfor (const id of newIds) {\n\t\t\t\tconst blob = await detachedBlobStorage.readBlob(id);\n\t\t\t\tconst response = await storage.createBlob(blob);\n\t\t\t\tredirectTable.set(id, response.id);\n\t\t\t}\n\t\t}\n\t\tsetAttachmentData(\n\t\t\t(currentData = {\n\t\t\t\tstate: AttachState.Attaching,\n\t\t\t\tsummary: createAttachmentSummary(redirectTable),\n\t\t\t\tblobs: \"done\",\n\t\t\t}),\n\t\t);\n\t}\n\n\tassert(currentData.state === AttachState.Attaching, \"must be attaching by this point\");\n\n\tif (currentData.blobs === \"done\") {\n\t\t// done means outstanding blobs were uploaded.\n\t\t// in that case an empty file was created, the blobs were uploaded\n\t\t// and now this finally uploads the summary\n\t\tawait storage.uploadSummaryWithContext(currentData.summary, {\n\t\t\treferenceSequenceNumber: 0,\n\t\t\tackHandle: undefined,\n\t\t\tproposalHandle: undefined,\n\t\t});\n\t}\n\n\tsetAttachmentData(\n\t\t(currentData = {\n\t\t\tstate: AttachState.Attached,\n\t\t\tsnapshot: offlineLoadEnabled\n\t\t\t\t? getSnapshotTreeAndBlobsFromSerializedContainer(currentData.summary)\n\t\t\t\t: undefined,\n\t\t}),\n\t);\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectionManager.d.mts","sourceRoot":"","sources":["../src/connectionManager.ts"],"names":[],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C,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,4BAA4B,GAAG,IAAI;IAcxF;;OAEG;IACI,aAAa,CAAC,QAAQ,EAAE,OAAO;IAoCtC,OAAO,CAAC,uBAAuB;IAWxB,OAAO,CAAC,MAAM,EAAE,4BAA4B,EAAE,cAAc,CAAC,EAAE,cAAc;YAOtE,WAAW;IA4MzB;;;;OAIG;IACH,OAAO,CAAC,cAAc;IActB;;;;;OAKG;IACH,OAAO,CAAC,yBAAyB;IAwCjC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAcxB;;;;OAIG;IACH,OAAO,CAAC,4BAA4B;IAwJpC;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IAMxB;;;;;;OAMG;YACW,SAAS;IA8DhB,oBAAoB,CAC1B,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,sBAAsB,CAAC,GACrD,gBAAgB,GAAG,SAAS;IAuCxB,YAAY,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,CAAC,EAAE,MAAM;IAQlD,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE;IA+BzC,0BAA0B,CAAC,OAAO,EAAE,yBAAyB;IAgDpE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAGxB;IAEF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAG5B;IAGF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAkB1B;IAGF,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAIxC;IAEF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAE3B;CACF"}
|
|
@@ -5,9 +5,7 @@
|
|
|
5
5
|
import { LogLevel } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { assert } from "@fluidframework/core-utils";
|
|
7
7
|
import { performance, TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
8
|
-
import {
|
|
9
|
-
// eslint-disable-next-line import/no-deprecated
|
|
10
|
-
DriverErrorType, } from "@fluidframework/driver-definitions";
|
|
8
|
+
import { DriverErrorTypes, } from "@fluidframework/driver-definitions";
|
|
11
9
|
import { canRetryOnError, createWriteError, createGenericNetworkError, getRetryDelayFromError, logNetworkFailure, isRuntimeMessage, calculateMaxWaitTime, } from "@fluidframework/driver-utils";
|
|
12
10
|
import { MessageType, ScopeType, } from "@fluidframework/protocol-definitions";
|
|
13
11
|
import { formatTick, GenericError, isFluidError, normalizeError, UsageError, } from "@fluidframework/telemetry-utils";
|
|
@@ -456,8 +454,7 @@ export class ConnectionManager {
|
|
|
456
454
|
break;
|
|
457
455
|
}
|
|
458
456
|
else if (isFluidError(origError) &&
|
|
459
|
-
|
|
460
|
-
origError.errorType === DriverErrorType.outOfStorageError) {
|
|
457
|
+
origError.errorType === DriverErrorTypes.outOfStorageError) {
|
|
461
458
|
// If we get out of storage error from calling joinsession, then use the NoDeltaStream object so
|
|
462
459
|
// that user can at least load the container.
|
|
463
460
|
connection = new NoDeltaStream(undefined, {
|