@fluidframework/datastore 2.70.0-361248 → 2.70.0-361788
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/api-report/datastore.legacy.beta.api.md +0 -2
- package/dist/dataStoreLayerCompatState.d.ts +3 -2
- package/dist/dataStoreLayerCompatState.d.ts.map +1 -1
- package/dist/dataStoreLayerCompatState.js +2 -18
- package/dist/dataStoreLayerCompatState.js.map +1 -1
- package/dist/dataStoreRuntime.d.ts +0 -6
- package/dist/dataStoreRuntime.d.ts.map +1 -1
- package/dist/dataStoreRuntime.js +9 -20
- package/dist/dataStoreRuntime.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/lib/dataStoreLayerCompatState.d.ts +3 -2
- package/lib/dataStoreLayerCompatState.d.ts.map +1 -1
- package/lib/dataStoreLayerCompatState.js +3 -19
- package/lib/dataStoreLayerCompatState.js.map +1 -1
- package/lib/dataStoreRuntime.d.ts +0 -6
- package/lib/dataStoreRuntime.d.ts.map +1 -1
- package/lib/dataStoreRuntime.js +9 -20
- package/lib/dataStoreRuntime.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +22 -15
- package/src/dataStoreLayerCompatState.ts +14 -21
- package/src/dataStoreRuntime.ts +14 -25
- package/src/packageVersion.ts +1 -1
- package/dist/localChannelStorageService.d.ts +0 -16
- package/dist/localChannelStorageService.d.ts.map +0 -1
- package/dist/localChannelStorageService.js +0 -54
- package/dist/localChannelStorageService.js.map +0 -1
- package/lib/localChannelStorageService.d.ts +0 -16
- package/lib/localChannelStorageService.d.ts.map +0 -1
- package/lib/localChannelStorageService.js +0 -50
- package/lib/localChannelStorageService.js.map +0 -1
- package/src/localChannelStorageService.ts +0 -62
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
type ILayerCompatSupportRequirements,
|
|
6
|
+
import type {
|
|
7
|
+
ILayerCompatDetails,
|
|
8
|
+
ILayerCompatSupportRequirements,
|
|
10
9
|
} from "@fluid-internal/client-utils";
|
|
11
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
validateLayerCompatibility,
|
|
12
|
+
type ITelemetryLoggerExt,
|
|
13
|
+
} from "@fluidframework/telemetry-utils/internal";
|
|
12
14
|
|
|
13
15
|
import { pkgVersion } from "./packageVersion.js";
|
|
14
16
|
|
|
@@ -62,24 +64,15 @@ export const runtimeSupportRequirementsForDataStore: ILayerCompatSupportRequirem
|
|
|
62
64
|
export function validateRuntimeCompatibility(
|
|
63
65
|
maybeRuntimeCompatDetails: ILayerCompatDetails | undefined,
|
|
64
66
|
disposeFn: () => void,
|
|
67
|
+
logger: ITelemetryLoggerExt,
|
|
65
68
|
): void {
|
|
66
|
-
|
|
69
|
+
validateLayerCompatibility(
|
|
70
|
+
"dataStore",
|
|
71
|
+
"runtime",
|
|
72
|
+
dataStoreCompatDetailsForRuntime,
|
|
67
73
|
runtimeSupportRequirementsForDataStore,
|
|
68
74
|
maybeRuntimeCompatDetails,
|
|
75
|
+
disposeFn,
|
|
76
|
+
logger,
|
|
69
77
|
);
|
|
70
|
-
if (!layerCheckResult.isCompatible) {
|
|
71
|
-
const error = new UsageError("DataStore is not compatible with Runtime", {
|
|
72
|
-
errorDetails: JSON.stringify({
|
|
73
|
-
dataStoreVersion: dataStoreCoreCompatDetails.pkgVersion,
|
|
74
|
-
runtimeVersion: maybeRuntimeCompatDetails?.pkgVersion,
|
|
75
|
-
dataStoreGeneration: dataStoreCoreCompatDetails.generation,
|
|
76
|
-
runtimeGeneration: maybeRuntimeCompatDetails?.generation,
|
|
77
|
-
minSupportedGeneration: runtimeSupportRequirementsForDataStore.minSupportedGeneration,
|
|
78
|
-
isGenerationCompatible: layerCheckResult.isGenerationCompatible,
|
|
79
|
-
unsupportedFeatures: layerCheckResult.unsupportedFeatures,
|
|
80
|
-
}),
|
|
81
|
-
});
|
|
82
|
-
disposeFn();
|
|
83
|
-
throw error;
|
|
84
|
-
}
|
|
85
78
|
}
|
package/src/dataStoreRuntime.ts
CHANGED
|
@@ -323,12 +323,22 @@ export class FluidDataStoreRuntime
|
|
|
323
323
|
0x30e /* Id cannot contain slashes. DataStoreContext should have validated this. */,
|
|
324
324
|
);
|
|
325
325
|
|
|
326
|
-
this.
|
|
326
|
+
this.mc = createChildMonitoringContext({
|
|
327
|
+
logger: dataStoreContext.baseLogger,
|
|
328
|
+
namespace: "FluidDataStoreRuntime",
|
|
329
|
+
properties: {
|
|
330
|
+
all: { dataStoreId: uuid(), dataStoreVersion: pkgVersion },
|
|
331
|
+
},
|
|
332
|
+
});
|
|
327
333
|
|
|
328
334
|
// Validate that the Runtime is compatible with this DataStore.
|
|
329
335
|
const { ILayerCompatDetails: runtimeCompatDetails } =
|
|
330
336
|
dataStoreContext as FluidObject<ILayerCompatDetails>;
|
|
331
|
-
validateRuntimeCompatibility(
|
|
337
|
+
validateRuntimeCompatibility(
|
|
338
|
+
runtimeCompatDetails,
|
|
339
|
+
this.dispose.bind(this),
|
|
340
|
+
this.mc.logger,
|
|
341
|
+
);
|
|
332
342
|
|
|
333
343
|
if (contextSupportsFeature(dataStoreContext, notifiesReadOnlyState)) {
|
|
334
344
|
this._readonly = dataStoreContext.isReadOnly();
|
|
@@ -339,6 +349,8 @@ export class FluidDataStoreRuntime
|
|
|
339
349
|
);
|
|
340
350
|
}
|
|
341
351
|
|
|
352
|
+
this.policies = { ...defaultPolicies, ...policies };
|
|
353
|
+
|
|
342
354
|
this.submitMessagesWithoutEncodingHandles = contextSupportsFeature(
|
|
343
355
|
dataStoreContext,
|
|
344
356
|
encodeHandlesInContainerRuntime,
|
|
@@ -346,14 +358,6 @@ export class FluidDataStoreRuntime
|
|
|
346
358
|
// We read this property here to avoid a compiler error (unused private member)
|
|
347
359
|
debugAssert(() => this.submitMessagesWithoutEncodingHandles !== undefined);
|
|
348
360
|
|
|
349
|
-
this.mc = createChildMonitoringContext({
|
|
350
|
-
logger: dataStoreContext.baseLogger,
|
|
351
|
-
namespace: "FluidDataStoreRuntime",
|
|
352
|
-
properties: {
|
|
353
|
-
all: { dataStoreId: uuid(), dataStoreVersion: pkgVersion },
|
|
354
|
-
},
|
|
355
|
-
});
|
|
356
|
-
|
|
357
361
|
this.id = dataStoreContext.id;
|
|
358
362
|
this.options = dataStoreContext.options;
|
|
359
363
|
this.deltaManagerInternal = dataStoreContext.deltaManager;
|
|
@@ -1166,21 +1170,6 @@ export class FluidDataStoreRuntime
|
|
|
1166
1170
|
}
|
|
1167
1171
|
}
|
|
1168
1172
|
|
|
1169
|
-
/**
|
|
1170
|
-
* Do not use.
|
|
1171
|
-
* @deprecated Use `IFluidDataStoreContext.submitMessage` instead.
|
|
1172
|
-
* @see https://github.com/microsoft/FluidFramework/issues/24406
|
|
1173
|
-
*/
|
|
1174
|
-
public submitMessage(
|
|
1175
|
-
type: DataStoreMessageType,
|
|
1176
|
-
// TODO: use something other than `any` here (breaking change)
|
|
1177
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
|
1178
|
-
content: any,
|
|
1179
|
-
localOpMetadata: unknown,
|
|
1180
|
-
): void {
|
|
1181
|
-
this.submit(type, content, localOpMetadata);
|
|
1182
|
-
}
|
|
1183
|
-
|
|
1184
1173
|
/**
|
|
1185
1174
|
* Submits the signal to be sent to other clients.
|
|
1186
1175
|
* @param type - Type of the signal.
|
package/src/packageVersion.ts
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import type { IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
|
|
6
|
-
import { type ITree } from "@fluidframework/driver-definitions/internal";
|
|
7
|
-
export declare class LocalChannelStorageService implements IChannelStorageService {
|
|
8
|
-
private readonly tree;
|
|
9
|
-
constructor(tree: ITree);
|
|
10
|
-
readBlob(path: string): Promise<ArrayBufferLike>;
|
|
11
|
-
contains(path: string): Promise<boolean>;
|
|
12
|
-
list(path: string): Promise<string[]>;
|
|
13
|
-
private readBlobSync;
|
|
14
|
-
private readBlobSyncInternal;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=localChannelStorageService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localChannelStorageService.d.ts","sourceRoot":"","sources":["../src/localChannelStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,EAEN,KAAK,KAAK,EAEV,MAAM,6CAA6C,CAAC;AAGrD,qBAAa,0BAA2B,YAAW,sBAAsB;IAC5D,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,KAAK;IAE3B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAQhD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKxC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAIlD,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,oBAAoB;CAuB5B"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.LocalChannelStorageService = void 0;
|
|
8
|
-
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
9
|
-
const internal_1 = require("@fluidframework/driver-definitions/internal");
|
|
10
|
-
const internal_2 = require("@fluidframework/runtime-utils/internal");
|
|
11
|
-
class LocalChannelStorageService {
|
|
12
|
-
constructor(tree) {
|
|
13
|
-
this.tree = tree;
|
|
14
|
-
}
|
|
15
|
-
async readBlob(path) {
|
|
16
|
-
const blob = this.readBlobSync(path);
|
|
17
|
-
if (blob === undefined) {
|
|
18
|
-
throw new Error("Blob Not Found");
|
|
19
|
-
}
|
|
20
|
-
return (0, client_utils_1.stringToBuffer)(blob.contents, blob.encoding);
|
|
21
|
-
}
|
|
22
|
-
async contains(path) {
|
|
23
|
-
const blob = this.readBlobSync(path);
|
|
24
|
-
return blob === undefined ? false : blob.contents !== undefined;
|
|
25
|
-
}
|
|
26
|
-
async list(path) {
|
|
27
|
-
return (0, internal_2.listBlobsAtTreePath)(this.tree, path);
|
|
28
|
-
}
|
|
29
|
-
readBlobSync(path) {
|
|
30
|
-
return this.readBlobSyncInternal(path, this.tree);
|
|
31
|
-
}
|
|
32
|
-
readBlobSyncInternal(path, tree) {
|
|
33
|
-
for (const entry of tree.entries) {
|
|
34
|
-
switch (entry.type) {
|
|
35
|
-
case internal_1.TreeEntry.Blob: {
|
|
36
|
-
if (path === entry.path) {
|
|
37
|
-
return entry.value;
|
|
38
|
-
}
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
case internal_1.TreeEntry.Tree: {
|
|
42
|
-
if (path.startsWith(entry.path)) {
|
|
43
|
-
return this.readBlobSyncInternal(path.slice(entry.path.length + 1), entry.value);
|
|
44
|
-
}
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
default:
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.LocalChannelStorageService = LocalChannelStorageService;
|
|
54
|
-
//# sourceMappingURL=localChannelStorageService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localChannelStorageService.js","sourceRoot":"","sources":["../src/localChannelStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAE9D,0EAIqD;AACrD,qEAA6E;AAE7E,MAAa,0BAA0B;IACtC,YAA6B,IAAW;QAAX,SAAI,GAAJ,IAAI,CAAO;IAAG,CAAC;IAErC,KAAK,CAAC,QAAQ,CAAC,IAAY;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,IAAA,6BAAc,EAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,IAAY;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACrC,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC;IACjE,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,IAAY;QAC7B,OAAO,IAAA,8BAAmB,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC;IAEO,YAAY,CAAC,IAAY;QAChC,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAEO,oBAAoB,CAAC,IAAY,EAAE,IAAW;QACrD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;gBACpB,KAAK,oBAAS,CAAC,IAAI,CAAC,CAAC,CAAC;oBACrB,IAAI,IAAI,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;wBACzB,OAAO,KAAK,CAAC,KAAK,CAAC;oBACpB,CAAC;oBACD,MAAM;gBACP,CAAC;gBAED,KAAK,oBAAS,CAAC,IAAI,CAAC,CAAC,CAAC;oBACrB,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;wBACjC,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;oBAClF,CAAC;oBACD,MAAM;gBACP,CAAC;gBAED,QAAQ;YACT,CAAC;QACF,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;CACD;AA/CD,gEA+CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { stringToBuffer } from \"@fluid-internal/client-utils\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\ttype IBlob,\n\ttype ITree,\n\tTreeEntry,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { listBlobsAtTreePath } from \"@fluidframework/runtime-utils/internal\";\n\nexport class LocalChannelStorageService implements IChannelStorageService {\n\tconstructor(private readonly tree: ITree) {}\n\n\tpublic async readBlob(path: string): Promise<ArrayBufferLike> {\n\t\tconst blob = this.readBlobSync(path);\n\t\tif (blob === undefined) {\n\t\t\tthrow new Error(\"Blob Not Found\");\n\t\t}\n\t\treturn stringToBuffer(blob.contents, blob.encoding);\n\t}\n\n\tpublic async contains(path: string): Promise<boolean> {\n\t\tconst blob = this.readBlobSync(path);\n\t\treturn blob === undefined ? false : blob.contents !== undefined;\n\t}\n\n\tpublic async list(path: string): Promise<string[]> {\n\t\treturn listBlobsAtTreePath(this.tree, path);\n\t}\n\n\tprivate readBlobSync(path: string): IBlob | undefined {\n\t\treturn this.readBlobSyncInternal(path, this.tree);\n\t}\n\n\tprivate readBlobSyncInternal(path: string, tree: ITree): IBlob | undefined {\n\t\tfor (const entry of tree.entries) {\n\t\t\tswitch (entry.type) {\n\t\t\t\tcase TreeEntry.Blob: {\n\t\t\t\t\tif (path === entry.path) {\n\t\t\t\t\t\treturn entry.value;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase TreeEntry.Tree: {\n\t\t\t\t\tif (path.startsWith(entry.path)) {\n\t\t\t\t\t\treturn this.readBlobSyncInternal(path.slice(entry.path.length + 1), entry.value);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n}\n"]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import type { IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
|
|
6
|
-
import { type ITree } from "@fluidframework/driver-definitions/internal";
|
|
7
|
-
export declare class LocalChannelStorageService implements IChannelStorageService {
|
|
8
|
-
private readonly tree;
|
|
9
|
-
constructor(tree: ITree);
|
|
10
|
-
readBlob(path: string): Promise<ArrayBufferLike>;
|
|
11
|
-
contains(path: string): Promise<boolean>;
|
|
12
|
-
list(path: string): Promise<string[]>;
|
|
13
|
-
private readBlobSync;
|
|
14
|
-
private readBlobSyncInternal;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=localChannelStorageService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localChannelStorageService.d.ts","sourceRoot":"","sources":["../src/localChannelStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,EAEN,KAAK,KAAK,EAEV,MAAM,6CAA6C,CAAC;AAGrD,qBAAa,0BAA2B,YAAW,sBAAsB;IAC5D,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,KAAK;IAE3B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAQhD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKxC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAIlD,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,oBAAoB;CAuB5B"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
import { stringToBuffer } from "@fluid-internal/client-utils";
|
|
6
|
-
import { TreeEntry, } from "@fluidframework/driver-definitions/internal";
|
|
7
|
-
import { listBlobsAtTreePath } from "@fluidframework/runtime-utils/internal";
|
|
8
|
-
export class LocalChannelStorageService {
|
|
9
|
-
constructor(tree) {
|
|
10
|
-
this.tree = tree;
|
|
11
|
-
}
|
|
12
|
-
async readBlob(path) {
|
|
13
|
-
const blob = this.readBlobSync(path);
|
|
14
|
-
if (blob === undefined) {
|
|
15
|
-
throw new Error("Blob Not Found");
|
|
16
|
-
}
|
|
17
|
-
return stringToBuffer(blob.contents, blob.encoding);
|
|
18
|
-
}
|
|
19
|
-
async contains(path) {
|
|
20
|
-
const blob = this.readBlobSync(path);
|
|
21
|
-
return blob === undefined ? false : blob.contents !== undefined;
|
|
22
|
-
}
|
|
23
|
-
async list(path) {
|
|
24
|
-
return listBlobsAtTreePath(this.tree, path);
|
|
25
|
-
}
|
|
26
|
-
readBlobSync(path) {
|
|
27
|
-
return this.readBlobSyncInternal(path, this.tree);
|
|
28
|
-
}
|
|
29
|
-
readBlobSyncInternal(path, tree) {
|
|
30
|
-
for (const entry of tree.entries) {
|
|
31
|
-
switch (entry.type) {
|
|
32
|
-
case TreeEntry.Blob: {
|
|
33
|
-
if (path === entry.path) {
|
|
34
|
-
return entry.value;
|
|
35
|
-
}
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
case TreeEntry.Tree: {
|
|
39
|
-
if (path.startsWith(entry.path)) {
|
|
40
|
-
return this.readBlobSyncInternal(path.slice(entry.path.length + 1), entry.value);
|
|
41
|
-
}
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
default:
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=localChannelStorageService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"localChannelStorageService.js","sourceRoot":"","sources":["../src/localChannelStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAGN,SAAS,GACT,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAE7E,MAAM,OAAO,0BAA0B;IACtC,YAA6B,IAAW;QAAX,SAAI,GAAJ,IAAI,CAAO;IAAG,CAAC;IAErC,KAAK,CAAC,QAAQ,CAAC,IAAY;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,IAAY;QACjC,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QACrC,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC;IACjE,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,IAAY;QAC7B,OAAO,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7C,CAAC;IAEO,YAAY,CAAC,IAAY;QAChC,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAEO,oBAAoB,CAAC,IAAY,EAAE,IAAW;QACrD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAClC,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;gBACpB,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;oBACrB,IAAI,IAAI,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;wBACzB,OAAO,KAAK,CAAC,KAAK,CAAC;oBACpB,CAAC;oBACD,MAAM;gBACP,CAAC;gBAED,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;oBACrB,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;wBACjC,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;oBAClF,CAAC;oBACD,MAAM;gBACP,CAAC;gBAED,QAAQ;YACT,CAAC;QACF,CAAC;QAED,OAAO,SAAS,CAAC;IAClB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { stringToBuffer } from \"@fluid-internal/client-utils\";\nimport type { IChannelStorageService } from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\ttype IBlob,\n\ttype ITree,\n\tTreeEntry,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { listBlobsAtTreePath } from \"@fluidframework/runtime-utils/internal\";\n\nexport class LocalChannelStorageService implements IChannelStorageService {\n\tconstructor(private readonly tree: ITree) {}\n\n\tpublic async readBlob(path: string): Promise<ArrayBufferLike> {\n\t\tconst blob = this.readBlobSync(path);\n\t\tif (blob === undefined) {\n\t\t\tthrow new Error(\"Blob Not Found\");\n\t\t}\n\t\treturn stringToBuffer(blob.contents, blob.encoding);\n\t}\n\n\tpublic async contains(path: string): Promise<boolean> {\n\t\tconst blob = this.readBlobSync(path);\n\t\treturn blob === undefined ? false : blob.contents !== undefined;\n\t}\n\n\tpublic async list(path: string): Promise<string[]> {\n\t\treturn listBlobsAtTreePath(this.tree, path);\n\t}\n\n\tprivate readBlobSync(path: string): IBlob | undefined {\n\t\treturn this.readBlobSyncInternal(path, this.tree);\n\t}\n\n\tprivate readBlobSyncInternal(path: string, tree: ITree): IBlob | undefined {\n\t\tfor (const entry of tree.entries) {\n\t\t\tswitch (entry.type) {\n\t\t\t\tcase TreeEntry.Blob: {\n\t\t\t\t\tif (path === entry.path) {\n\t\t\t\t\t\treturn entry.value;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase TreeEntry.Tree: {\n\t\t\t\t\tif (path.startsWith(entry.path)) {\n\t\t\t\t\t\treturn this.readBlobSyncInternal(path.slice(entry.path.length + 1), entry.value);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tdefault:\n\t\t\t}\n\t\t}\n\n\t\treturn undefined;\n\t}\n}\n"]}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { stringToBuffer } from "@fluid-internal/client-utils";
|
|
7
|
-
import type { IChannelStorageService } from "@fluidframework/datastore-definitions/internal";
|
|
8
|
-
import {
|
|
9
|
-
type IBlob,
|
|
10
|
-
type ITree,
|
|
11
|
-
TreeEntry,
|
|
12
|
-
} from "@fluidframework/driver-definitions/internal";
|
|
13
|
-
import { listBlobsAtTreePath } from "@fluidframework/runtime-utils/internal";
|
|
14
|
-
|
|
15
|
-
export class LocalChannelStorageService implements IChannelStorageService {
|
|
16
|
-
constructor(private readonly tree: ITree) {}
|
|
17
|
-
|
|
18
|
-
public async readBlob(path: string): Promise<ArrayBufferLike> {
|
|
19
|
-
const blob = this.readBlobSync(path);
|
|
20
|
-
if (blob === undefined) {
|
|
21
|
-
throw new Error("Blob Not Found");
|
|
22
|
-
}
|
|
23
|
-
return stringToBuffer(blob.contents, blob.encoding);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public async contains(path: string): Promise<boolean> {
|
|
27
|
-
const blob = this.readBlobSync(path);
|
|
28
|
-
return blob === undefined ? false : blob.contents !== undefined;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
public async list(path: string): Promise<string[]> {
|
|
32
|
-
return listBlobsAtTreePath(this.tree, path);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
private readBlobSync(path: string): IBlob | undefined {
|
|
36
|
-
return this.readBlobSyncInternal(path, this.tree);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
private readBlobSyncInternal(path: string, tree: ITree): IBlob | undefined {
|
|
40
|
-
for (const entry of tree.entries) {
|
|
41
|
-
switch (entry.type) {
|
|
42
|
-
case TreeEntry.Blob: {
|
|
43
|
-
if (path === entry.path) {
|
|
44
|
-
return entry.value;
|
|
45
|
-
}
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
case TreeEntry.Tree: {
|
|
50
|
-
if (path.startsWith(entry.path)) {
|
|
51
|
-
return this.readBlobSyncInternal(path.slice(entry.path.length + 1), entry.value);
|
|
52
|
-
}
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
default:
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
62
|
-
}
|