@fluidframework/aqueduct 2.30.0 → 2.31.1
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/CHANGELOG.md +221 -217
- package/dist/data-objects/createDataObjectKind.d.ts +13 -0
- package/dist/data-objects/createDataObjectKind.d.ts.map +1 -0
- package/dist/data-objects/createDataObjectKind.js +17 -0
- package/dist/data-objects/createDataObjectKind.js.map +1 -0
- package/dist/data-objects/dataObject.d.ts +1 -8
- package/dist/data-objects/dataObject.d.ts.map +1 -1
- package/dist/data-objects/dataObject.js +1 -10
- package/dist/data-objects/dataObject.js.map +1 -1
- package/dist/data-objects/index.d.ts +3 -1
- package/dist/data-objects/index.d.ts.map +1 -1
- package/dist/data-objects/index.js +5 -2
- package/dist/data-objects/index.js.map +1 -1
- package/dist/data-objects/treeDataObject.d.ts +49 -0
- package/dist/data-objects/treeDataObject.d.ts.map +1 -0
- package/dist/data-objects/treeDataObject.js +99 -0
- package/dist/data-objects/treeDataObject.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/lib/data-objects/createDataObjectKind.d.ts +13 -0
- package/lib/data-objects/createDataObjectKind.d.ts.map +1 -0
- package/lib/data-objects/createDataObjectKind.js +13 -0
- package/lib/data-objects/createDataObjectKind.js.map +1 -0
- package/lib/data-objects/dataObject.d.ts +1 -8
- package/lib/data-objects/dataObject.d.ts.map +1 -1
- package/lib/data-objects/dataObject.js +0 -8
- package/lib/data-objects/dataObject.js.map +1 -1
- package/lib/data-objects/index.d.ts +3 -1
- package/lib/data-objects/index.d.ts.map +1 -1
- package/lib/data-objects/index.js +3 -1
- package/lib/data-objects/index.js.map +1 -1
- package/lib/data-objects/treeDataObject.d.ts +49 -0
- package/lib/data-objects/treeDataObject.d.ts.map +1 -0
- package/lib/data-objects/treeDataObject.js +95 -0
- package/lib/data-objects/treeDataObject.js.map +1 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/package.json +20 -21
- package/src/data-objects/createDataObjectKind.ts +19 -0
- package/src/data-objects/dataObject.ts +1 -13
- package/src/data-objects/index.ts +3 -1
- package/src/data-objects/treeDataObject.ts +98 -0
- package/src/index.ts +5 -1
- package/prettier.config.cjs +0 -8
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
6
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
7
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
8
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
9
|
+
};
|
|
10
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
11
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
12
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
13
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
14
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
15
|
+
};
|
|
16
|
+
var _TreeDataObject_view;
|
|
17
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
18
|
+
import { SharedTree } from "@fluidframework/tree/internal";
|
|
19
|
+
import { PureDataObject } from "./pureDataObject.js";
|
|
20
|
+
/**
|
|
21
|
+
* Channel ID of {@link TreeDataObject}'s root {@link @fluidframework/tree#SharedTree}.
|
|
22
|
+
*/
|
|
23
|
+
const treeChannelId = "tree-data-object";
|
|
24
|
+
const uninitializedErrorString = "The tree has not yet been initialized. The data object must be initialized before accessing.";
|
|
25
|
+
/**
|
|
26
|
+
* {@link @fluidframework/tree#SharedTree}-backed {@link PureDataObject | data object}.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
*
|
|
30
|
+
* Note: to initialize the tree's data for initial creation, implementers of this class will need to override {@link PureDataObject.initializingFirstTime} and set the data in {@link TreeDataObject.treeView}.
|
|
31
|
+
*
|
|
32
|
+
* @typeParam TTreeView - View derived from the underlying tree.
|
|
33
|
+
* Can be used to derive schema-aware views of the tree.
|
|
34
|
+
* See {@link TreeDataObject.generateView}.
|
|
35
|
+
*
|
|
36
|
+
* @example Implementing `initializingFirstTime`
|
|
37
|
+
*
|
|
38
|
+
* ```typescript
|
|
39
|
+
* protected override async initializingFirstTime(): Promise<void> {
|
|
40
|
+
* this.tree.initialize(...);
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @privateRemarks
|
|
45
|
+
* TODO: Before promoting this beyond internal, we should consider alternative API patterns that don't depend on
|
|
46
|
+
* sub-classing and don't leak Fluid concepts that should ideally be internal.
|
|
47
|
+
* See `tree-react-api` for an example of a pattern that avoids unnecessary leakage of implementation details.
|
|
48
|
+
*
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
export class TreeDataObject extends PureDataObject {
|
|
52
|
+
constructor() {
|
|
53
|
+
super(...arguments);
|
|
54
|
+
/**
|
|
55
|
+
* View derived from the underlying tree.
|
|
56
|
+
* @remarks Populated via {@link TreeDataObject.generateView}.
|
|
57
|
+
*/
|
|
58
|
+
_TreeDataObject_view.set(this, void 0);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Gets the derived view of the underlying tree.
|
|
62
|
+
*
|
|
63
|
+
* @throws
|
|
64
|
+
* If the tree has not yet been initialized, this will throw an error.
|
|
65
|
+
*/
|
|
66
|
+
get treeView() {
|
|
67
|
+
if (__classPrivateFieldGet(this, _TreeDataObject_view, "f") === undefined) {
|
|
68
|
+
throw new UsageError(uninitializedErrorString);
|
|
69
|
+
}
|
|
70
|
+
return __classPrivateFieldGet(this, _TreeDataObject_view, "f");
|
|
71
|
+
}
|
|
72
|
+
async initializeInternal(existing) {
|
|
73
|
+
if (existing) {
|
|
74
|
+
// data store has a root tree so we just need to set it before calling initializingFromExisting
|
|
75
|
+
const channel = await this.runtime.getChannel(treeChannelId);
|
|
76
|
+
// TODO: Support using a Directory to Tree migration shim and DataObject's root channel ID
|
|
77
|
+
// to allow migrating from DataObject to TreeDataObject instead of just erroring in that case.
|
|
78
|
+
if (!SharedTree.is(channel)) {
|
|
79
|
+
throw new Error(`Content with id ${channel.id} is not a SharedTree and cannot be loaded with treeDataObject.`);
|
|
80
|
+
}
|
|
81
|
+
const sharedTree = channel;
|
|
82
|
+
__classPrivateFieldSet(this, _TreeDataObject_view, this.generateView(sharedTree), "f");
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const sharedTree = SharedTree.create(this.runtime, treeChannelId);
|
|
86
|
+
sharedTree.bindToContext();
|
|
87
|
+
__classPrivateFieldSet(this, _TreeDataObject_view, this.generateView(sharedTree), "f");
|
|
88
|
+
// Note, the implementer is responsible for initializing the tree with initial data.
|
|
89
|
+
// Generally, this can be done via `initializingFirstTime`.
|
|
90
|
+
}
|
|
91
|
+
await super.initializeInternal(existing);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
_TreeDataObject_view = new WeakMap();
|
|
95
|
+
//# sourceMappingURL=treeDataObject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treeDataObject.js","sourceRoot":"","sources":["../../src/data-objects/treeDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;;;;;;;;;;;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAc,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;GAEG;AACH,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAEzC,MAAM,wBAAwB,GAC7B,8FAA8F,CAAC;AAEhG;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAgB,cAA0B,SAAQ,cAAc;IAAtE;;QAOC;;;WAGG;QACH,uCAA6B;IAyC9B,CAAC;IAvCA;;;;;OAKG;IACH,IAAW,QAAQ;QAClB,IAAI,uBAAA,IAAI,4BAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,IAAI,UAAU,CAAC,wBAAwB,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,uBAAA,IAAI,4BAAM,CAAC;IACnB,CAAC;IAEe,KAAK,CAAC,kBAAkB,CAAC,QAAiB;QACzD,IAAI,QAAQ,EAAE,CAAC;YACd,+FAA+F;YAC/F,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;YAE7D,0FAA0F;YAC1F,8FAA8F;YAC9F,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC7B,MAAM,IAAI,KAAK,CACd,mBAAmB,OAAO,CAAC,EAAE,gEAAgE,CAC7F,CAAC;YACH,CAAC;YACD,MAAM,UAAU,GAAU,OAAO,CAAC;YAClC,uBAAA,IAAI,wBAAS,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,MAAA,CAAC;QAC5C,CAAC;aAAM,CAAC;YACP,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;YACjE,UAAuC,CAAC,aAAa,EAAE,CAAC;YAEzD,uBAAA,IAAI,wBAAS,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,MAAA,CAAC;YAE3C,oFAAoF;YACpF,2DAA2D;QAC5D,CAAC;QAED,MAAM,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ISharedObject } from \"@fluidframework/shared-object-base/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { type ITree, SharedTree } from \"@fluidframework/tree/internal\";\n\nimport { PureDataObject } from \"./pureDataObject.js\";\n\n/**\n * Channel ID of {@link TreeDataObject}'s root {@link @fluidframework/tree#SharedTree}.\n */\nconst treeChannelId = \"tree-data-object\";\n\nconst uninitializedErrorString =\n\t\"The tree has not yet been initialized. The data object must be initialized before accessing.\";\n\n/**\n * {@link @fluidframework/tree#SharedTree}-backed {@link PureDataObject | data object}.\n *\n * @remarks\n *\n * Note: to initialize the tree's data for initial creation, implementers of this class will need to override {@link PureDataObject.initializingFirstTime} and set the data in {@link TreeDataObject.treeView}.\n *\n * @typeParam TTreeView - View derived from the underlying tree.\n * Can be used to derive schema-aware views of the tree.\n * See {@link TreeDataObject.generateView}.\n *\n * @example Implementing `initializingFirstTime`\n *\n * ```typescript\n * protected override async initializingFirstTime(): Promise<void> {\n * \tthis.tree.initialize(...);\n * }\n * ```\n *\n * @privateRemarks\n * TODO: Before promoting this beyond internal, we should consider alternative API patterns that don't depend on\n * sub-classing and don't leak Fluid concepts that should ideally be internal.\n * See `tree-react-api` for an example of a pattern that avoids unnecessary leakage of implementation details.\n *\n * @internal\n */\nexport abstract class TreeDataObject<TTreeView> extends PureDataObject {\n\t/**\n\t * Generates a view of the data object's {@link @fluidframework/tree#ITree | tree}.\n\t * @remarks Called once during initialization.\n\t */\n\tprotected abstract generateView(tree: ITree): TTreeView;\n\n\t/**\n\t * View derived from the underlying tree.\n\t * @remarks Populated via {@link TreeDataObject.generateView}.\n\t */\n\t#view: TTreeView | undefined;\n\n\t/**\n\t * Gets the derived view of the underlying tree.\n\t *\n\t * @throws\n\t * If the tree has not yet been initialized, this will throw an error.\n\t */\n\tpublic get treeView(): TTreeView {\n\t\tif (this.#view === undefined) {\n\t\t\tthrow new UsageError(uninitializedErrorString);\n\t\t}\n\t\treturn this.#view;\n\t}\n\n\tpublic override async initializeInternal(existing: boolean): Promise<void> {\n\t\tif (existing) {\n\t\t\t// data store has a root tree so we just need to set it before calling initializingFromExisting\n\t\t\tconst channel = await this.runtime.getChannel(treeChannelId);\n\n\t\t\t// TODO: Support using a Directory to Tree migration shim and DataObject's root channel ID\n\t\t\t// to allow migrating from DataObject to TreeDataObject instead of just erroring in that case.\n\t\t\tif (!SharedTree.is(channel)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Content with id ${channel.id} is not a SharedTree and cannot be loaded with treeDataObject.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst sharedTree: ITree = channel;\n\t\t\tthis.#view = this.generateView(sharedTree);\n\t\t} else {\n\t\t\tconst sharedTree = SharedTree.create(this.runtime, treeChannelId);\n\t\t\t(sharedTree as unknown as ISharedObject).bindToContext();\n\n\t\t\tthis.#view = this.generateView(sharedTree);\n\n\t\t\t// Note, the implementer is responsible for initializing the tree with initial data.\n\t\t\t// Generally, this can be done via `initializingFirstTime`.\n\t\t}\n\n\t\tawait super.initializeInternal(existing);\n\t}\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @packageDocumentation
|
|
18
18
|
*/
|
|
19
|
-
export { DataObjectFactory, PureDataObjectFactory } from "./data-object-factories/index.js";
|
|
20
|
-
export { DataObject, type DataObjectKind, type DataObjectTypes, type IDataObjectProps, PureDataObject, createDataObjectKind, } from "./data-objects/index.js";
|
|
19
|
+
export { DataObjectFactory, PureDataObjectFactory, } from "./data-object-factories/index.js";
|
|
20
|
+
export { DataObject, type DataObjectKind, type DataObjectTypes, type IDataObjectProps, PureDataObject, TreeDataObject, createDataObjectKind, } from "./data-objects/index.js";
|
|
21
21
|
export { BaseContainerRuntimeFactory, type BaseContainerRuntimeFactoryProps, ContainerRuntimeFactoryWithDefaultDataStore, type ContainerRuntimeFactoryWithDefaultDataStoreProps, } from "./container-runtime-factories/index.js";
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACN,iBAAiB,EACjB,qBAAqB,GACrB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,cAAc,EACd,cAAc,EACd,oBAAoB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,2BAA2B,EAC3B,KAAK,gCAAgC,EACrC,2CAA2C,EAC3C,KAAK,gDAAgD,GACrD,MAAM,wCAAwC,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @packageDocumentation
|
|
18
18
|
*/
|
|
19
|
-
export { DataObjectFactory, PureDataObjectFactory } from "./data-object-factories/index.js";
|
|
20
|
-
export { DataObject, PureDataObject, createDataObjectKind, } from "./data-objects/index.js";
|
|
19
|
+
export { DataObjectFactory, PureDataObjectFactory, } from "./data-object-factories/index.js";
|
|
20
|
+
export { DataObject, PureDataObject, TreeDataObject, createDataObjectKind, } from "./data-objects/index.js";
|
|
21
21
|
export { BaseContainerRuntimeFactory, ContainerRuntimeFactoryWithDefaultDataStore, } from "./container-runtime-factories/index.js";
|
|
22
22
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACN,iBAAiB,EACjB,qBAAqB,GACrB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,UAAU,EAIV,cAAc,EACd,cAAc,EACd,oBAAoB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACN,2BAA2B,EAE3B,2CAA2C,GAE3C,MAAM,wCAAwC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * The `aqueduct` package is a library for building Fluid objects and Fluid\n * containers within the Fluid Framework. Its goal is to provide a thin base\n * layer over the existing Fluid Framework interfaces that allows developers to\n * get started quickly.\n *\n * @remarks\n * About the library name: An \"aqueduct\" is a way to transport water from a source\n * to another location. The library name was chosen because its purpose is to\n * facilitate using lower level constructs and therefore handle 'fluid' items\n * same as an aqueduct.\n *\n * @packageDocumentation\n */\n\nexport {\n\tDataObjectFactory,\n\tPureDataObjectFactory,\n} from \"./data-object-factories/index.js\";\nexport {\n\tDataObject,\n\ttype DataObjectKind,\n\ttype DataObjectTypes,\n\ttype IDataObjectProps,\n\tPureDataObject,\n\tTreeDataObject,\n\tcreateDataObjectKind,\n} from \"./data-objects/index.js\";\nexport {\n\tBaseContainerRuntimeFactory,\n\ttype BaseContainerRuntimeFactoryProps,\n\tContainerRuntimeFactoryWithDefaultDataStore,\n\ttype ContainerRuntimeFactoryWithDefaultDataStoreProps,\n} from \"./container-runtime-factories/index.js\";\n"]}
|
package/lib/tsdoc-metadata.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/aqueduct",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.31.1",
|
|
4
4
|
"description": "A set of implementations for Fluid Framework interfaces.",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -69,31 +69,33 @@
|
|
|
69
69
|
"temp-directory": "nyc/.nyc_output"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@fluid-internal/client-utils": "~2.
|
|
73
|
-
"@fluidframework/container-definitions": "~2.
|
|
74
|
-
"@fluidframework/container-runtime": "~2.
|
|
75
|
-
"@fluidframework/container-runtime-definitions": "~2.
|
|
76
|
-
"@fluidframework/core-interfaces": "~2.
|
|
77
|
-
"@fluidframework/core-utils": "~2.
|
|
78
|
-
"@fluidframework/datastore": "~2.
|
|
79
|
-
"@fluidframework/datastore-definitions": "~2.
|
|
80
|
-
"@fluidframework/map": "~2.
|
|
81
|
-
"@fluidframework/request-handler": "~2.
|
|
82
|
-
"@fluidframework/runtime-definitions": "~2.
|
|
83
|
-
"@fluidframework/runtime-utils": "~2.
|
|
84
|
-
"@fluidframework/shared-object-base": "~2.
|
|
85
|
-
"@fluidframework/synthesize": "~2.
|
|
72
|
+
"@fluid-internal/client-utils": "~2.31.1",
|
|
73
|
+
"@fluidframework/container-definitions": "~2.31.1",
|
|
74
|
+
"@fluidframework/container-runtime": "~2.31.1",
|
|
75
|
+
"@fluidframework/container-runtime-definitions": "~2.31.1",
|
|
76
|
+
"@fluidframework/core-interfaces": "~2.31.1",
|
|
77
|
+
"@fluidframework/core-utils": "~2.31.1",
|
|
78
|
+
"@fluidframework/datastore": "~2.31.1",
|
|
79
|
+
"@fluidframework/datastore-definitions": "~2.31.1",
|
|
80
|
+
"@fluidframework/map": "~2.31.1",
|
|
81
|
+
"@fluidframework/request-handler": "~2.31.1",
|
|
82
|
+
"@fluidframework/runtime-definitions": "~2.31.1",
|
|
83
|
+
"@fluidframework/runtime-utils": "~2.31.1",
|
|
84
|
+
"@fluidframework/shared-object-base": "~2.31.1",
|
|
85
|
+
"@fluidframework/synthesize": "~2.31.1",
|
|
86
|
+
"@fluidframework/telemetry-utils": "~2.31.1",
|
|
87
|
+
"@fluidframework/tree": "~2.31.1"
|
|
86
88
|
},
|
|
87
89
|
"devDependencies": {
|
|
88
90
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
89
91
|
"@biomejs/biome": "~1.9.3",
|
|
90
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
92
|
+
"@fluid-internal/mocha-test-setup": "~2.31.1",
|
|
91
93
|
"@fluid-tools/build-cli": "^0.54.0",
|
|
92
|
-
"@fluidframework/aqueduct-previous": "npm:@fluidframework/aqueduct@2.
|
|
94
|
+
"@fluidframework/aqueduct-previous": "npm:@fluidframework/aqueduct@2.31.0",
|
|
93
95
|
"@fluidframework/build-common": "^2.0.3",
|
|
94
96
|
"@fluidframework/build-tools": "^0.54.0",
|
|
95
97
|
"@fluidframework/eslint-config-fluid": "^5.7.3",
|
|
96
|
-
"@microsoft/api-extractor": "7.
|
|
98
|
+
"@microsoft/api-extractor": "7.50.1",
|
|
97
99
|
"@types/mocha": "^10.0.10",
|
|
98
100
|
"@types/node": "^18.19.0",
|
|
99
101
|
"c8": "^8.0.1",
|
|
@@ -104,7 +106,6 @@
|
|
|
104
106
|
"mocha": "^10.8.2",
|
|
105
107
|
"mocha-multi-reporters": "^1.5.1",
|
|
106
108
|
"moment": "^2.21.0",
|
|
107
|
-
"prettier": "~3.0.3",
|
|
108
109
|
"rimraf": "^4.4.0",
|
|
109
110
|
"typescript": "~5.4.5"
|
|
110
111
|
},
|
|
@@ -136,7 +137,6 @@
|
|
|
136
137
|
"check:exports:esm:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.esm.json",
|
|
137
138
|
"check:exports:esm:public": "api-extractor run --config api-extractor/api-extractor-lint-public.esm.json",
|
|
138
139
|
"check:format": "npm run check:biome",
|
|
139
|
-
"check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
|
|
140
140
|
"ci:build:api-reports": "concurrently \"npm:ci:build:api-reports:*\"",
|
|
141
141
|
"ci:build:api-reports:current": "api-extractor run --config api-extractor/api-extractor.current.json",
|
|
142
142
|
"ci:build:api-reports:legacy": "api-extractor run --config api-extractor/api-extractor.legacy.json",
|
|
@@ -146,7 +146,6 @@
|
|
|
146
146
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
147
147
|
"format": "npm run format:biome",
|
|
148
148
|
"format:biome": "biome check . --write",
|
|
149
|
-
"format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
150
149
|
"lint": "fluid-build . --task lint",
|
|
151
150
|
"lint:fix": "fluid-build . --task eslint:fix --task format",
|
|
152
151
|
"test": "npm run test:mocha",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { SharedObjectKind } from "@fluidframework/shared-object-base";
|
|
7
|
+
|
|
8
|
+
import type { DataObjectKind } from "./types.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Utility for creating SharedObjectKind instances for data objects.
|
|
12
|
+
* @typeParam T - The kind of data object.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export function createDataObjectKind<T extends DataObjectKind>(
|
|
16
|
+
factory: T,
|
|
17
|
+
): T & SharedObjectKind<T extends DataObjectKind<infer I> ? I : unknown> {
|
|
18
|
+
return factory as T & SharedObjectKind<T extends DataObjectKind<infer I> ? I : unknown>;
|
|
19
|
+
}
|
|
@@ -8,10 +8,9 @@ import {
|
|
|
8
8
|
MapFactory,
|
|
9
9
|
SharedDirectory,
|
|
10
10
|
} from "@fluidframework/map/internal";
|
|
11
|
-
import type { SharedObjectKind } from "@fluidframework/shared-object-base";
|
|
12
11
|
|
|
13
12
|
import { PureDataObject } from "./pureDataObject.js";
|
|
14
|
-
import type {
|
|
13
|
+
import type { DataObjectTypes } from "./types.js";
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* DataObject is a base data store that is primed with a root directory. It
|
|
@@ -82,14 +81,3 @@ export abstract class DataObject<
|
|
|
82
81
|
return `${item} must be initialized before being accessed.`;
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Utility for creating SharedObjectKind instances for data objects.
|
|
88
|
-
* @typeParam T - The kind of data object.
|
|
89
|
-
* @internal
|
|
90
|
-
*/
|
|
91
|
-
export function createDataObjectKind<T extends DataObjectKind>(
|
|
92
|
-
factory: T,
|
|
93
|
-
): T & SharedObjectKind<T extends DataObjectKind<infer I> ? I : unknown> {
|
|
94
|
-
return factory as T & SharedObjectKind<T extends DataObjectKind<infer I> ? I : unknown>;
|
|
95
|
-
}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export {
|
|
6
|
+
export { createDataObjectKind } from "./createDataObjectKind.js";
|
|
7
|
+
export { DataObject } from "./dataObject.js";
|
|
7
8
|
export { PureDataObject } from "./pureDataObject.js";
|
|
9
|
+
export { TreeDataObject } from "./treeDataObject.js";
|
|
8
10
|
export type { DataObjectKind, DataObjectTypes, IDataObjectProps } from "./types.js";
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { ISharedObject } from "@fluidframework/shared-object-base/internal";
|
|
7
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
8
|
+
import { type ITree, SharedTree } from "@fluidframework/tree/internal";
|
|
9
|
+
|
|
10
|
+
import { PureDataObject } from "./pureDataObject.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Channel ID of {@link TreeDataObject}'s root {@link @fluidframework/tree#SharedTree}.
|
|
14
|
+
*/
|
|
15
|
+
const treeChannelId = "tree-data-object";
|
|
16
|
+
|
|
17
|
+
const uninitializedErrorString =
|
|
18
|
+
"The tree has not yet been initialized. The data object must be initialized before accessing.";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* {@link @fluidframework/tree#SharedTree}-backed {@link PureDataObject | data object}.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
*
|
|
25
|
+
* Note: to initialize the tree's data for initial creation, implementers of this class will need to override {@link PureDataObject.initializingFirstTime} and set the data in {@link TreeDataObject.treeView}.
|
|
26
|
+
*
|
|
27
|
+
* @typeParam TTreeView - View derived from the underlying tree.
|
|
28
|
+
* Can be used to derive schema-aware views of the tree.
|
|
29
|
+
* See {@link TreeDataObject.generateView}.
|
|
30
|
+
*
|
|
31
|
+
* @example Implementing `initializingFirstTime`
|
|
32
|
+
*
|
|
33
|
+
* ```typescript
|
|
34
|
+
* protected override async initializingFirstTime(): Promise<void> {
|
|
35
|
+
* this.tree.initialize(...);
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @privateRemarks
|
|
40
|
+
* TODO: Before promoting this beyond internal, we should consider alternative API patterns that don't depend on
|
|
41
|
+
* sub-classing and don't leak Fluid concepts that should ideally be internal.
|
|
42
|
+
* See `tree-react-api` for an example of a pattern that avoids unnecessary leakage of implementation details.
|
|
43
|
+
*
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
export abstract class TreeDataObject<TTreeView> extends PureDataObject {
|
|
47
|
+
/**
|
|
48
|
+
* Generates a view of the data object's {@link @fluidframework/tree#ITree | tree}.
|
|
49
|
+
* @remarks Called once during initialization.
|
|
50
|
+
*/
|
|
51
|
+
protected abstract generateView(tree: ITree): TTreeView;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* View derived from the underlying tree.
|
|
55
|
+
* @remarks Populated via {@link TreeDataObject.generateView}.
|
|
56
|
+
*/
|
|
57
|
+
#view: TTreeView | undefined;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Gets the derived view of the underlying tree.
|
|
61
|
+
*
|
|
62
|
+
* @throws
|
|
63
|
+
* If the tree has not yet been initialized, this will throw an error.
|
|
64
|
+
*/
|
|
65
|
+
public get treeView(): TTreeView {
|
|
66
|
+
if (this.#view === undefined) {
|
|
67
|
+
throw new UsageError(uninitializedErrorString);
|
|
68
|
+
}
|
|
69
|
+
return this.#view;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public override async initializeInternal(existing: boolean): Promise<void> {
|
|
73
|
+
if (existing) {
|
|
74
|
+
// data store has a root tree so we just need to set it before calling initializingFromExisting
|
|
75
|
+
const channel = await this.runtime.getChannel(treeChannelId);
|
|
76
|
+
|
|
77
|
+
// TODO: Support using a Directory to Tree migration shim and DataObject's root channel ID
|
|
78
|
+
// to allow migrating from DataObject to TreeDataObject instead of just erroring in that case.
|
|
79
|
+
if (!SharedTree.is(channel)) {
|
|
80
|
+
throw new Error(
|
|
81
|
+
`Content with id ${channel.id} is not a SharedTree and cannot be loaded with treeDataObject.`,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
const sharedTree: ITree = channel;
|
|
85
|
+
this.#view = this.generateView(sharedTree);
|
|
86
|
+
} else {
|
|
87
|
+
const sharedTree = SharedTree.create(this.runtime, treeChannelId);
|
|
88
|
+
(sharedTree as unknown as ISharedObject).bindToContext();
|
|
89
|
+
|
|
90
|
+
this.#view = this.generateView(sharedTree);
|
|
91
|
+
|
|
92
|
+
// Note, the implementer is responsible for initializing the tree with initial data.
|
|
93
|
+
// Generally, this can be done via `initializingFirstTime`.
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
await super.initializeInternal(existing);
|
|
97
|
+
}
|
|
98
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -18,13 +18,17 @@
|
|
|
18
18
|
* @packageDocumentation
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
export {
|
|
21
|
+
export {
|
|
22
|
+
DataObjectFactory,
|
|
23
|
+
PureDataObjectFactory,
|
|
24
|
+
} from "./data-object-factories/index.js";
|
|
22
25
|
export {
|
|
23
26
|
DataObject,
|
|
24
27
|
type DataObjectKind,
|
|
25
28
|
type DataObjectTypes,
|
|
26
29
|
type IDataObjectProps,
|
|
27
30
|
PureDataObject,
|
|
31
|
+
TreeDataObject,
|
|
28
32
|
createDataObjectKind,
|
|
29
33
|
} from "./data-objects/index.js";
|
|
30
34
|
export {
|