@fluidframework/aqueduct 2.50.0 → 2.51.0

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/api-report/aqueduct.legacy.alpha.api.md +12 -0
  3. package/dist/data-object-factories/index.d.ts +1 -0
  4. package/dist/data-object-factories/index.d.ts.map +1 -1
  5. package/dist/data-object-factories/index.js +3 -1
  6. package/dist/data-object-factories/index.js.map +1 -1
  7. package/dist/data-object-factories/treeDataObjectFactory.d.ts +18 -0
  8. package/dist/data-object-factories/treeDataObjectFactory.d.ts.map +1 -0
  9. package/dist/data-object-factories/treeDataObjectFactory.js +32 -0
  10. package/dist/data-object-factories/treeDataObjectFactory.js.map +1 -0
  11. package/dist/data-objects/treeDataObject.d.ts +31 -25
  12. package/dist/data-objects/treeDataObject.d.ts.map +1 -1
  13. package/dist/data-objects/treeDataObject.js +40 -41
  14. package/dist/data-objects/treeDataObject.js.map +1 -1
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +2 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/legacy.d.ts +3 -1
  20. package/lib/data-object-factories/index.d.ts +1 -0
  21. package/lib/data-object-factories/index.d.ts.map +1 -1
  22. package/lib/data-object-factories/index.js +1 -0
  23. package/lib/data-object-factories/index.js.map +1 -1
  24. package/lib/data-object-factories/treeDataObjectFactory.d.ts +18 -0
  25. package/lib/data-object-factories/treeDataObjectFactory.d.ts.map +1 -0
  26. package/lib/data-object-factories/treeDataObjectFactory.js +28 -0
  27. package/lib/data-object-factories/treeDataObjectFactory.js.map +1 -0
  28. package/lib/data-objects/treeDataObject.d.ts +31 -25
  29. package/lib/data-objects/treeDataObject.d.ts.map +1 -1
  30. package/lib/data-objects/treeDataObject.js +40 -41
  31. package/lib/data-objects/treeDataObject.js.map +1 -1
  32. package/lib/index.d.ts +1 -1
  33. package/lib/index.d.ts.map +1 -1
  34. package/lib/index.js +1 -1
  35. package/lib/index.js.map +1 -1
  36. package/lib/legacy.d.ts +3 -1
  37. package/package.json +20 -36
  38. package/src/data-object-factories/index.ts +1 -0
  39. package/src/data-object-factories/treeDataObjectFactory.ts +44 -0
  40. package/src/data-objects/treeDataObject.ts +46 -49
  41. package/src/index.ts +2 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @fluidframework/aqueduct
2
2
 
3
+ ## 2.51.0
4
+
5
+ ### Minor Changes
6
+
7
+ - New "PureDataObject" implementation "TreeDataObject" added ([#25025](https://github.com/microsoft/FluidFramework/pull/25025)) [f4fbd2f582c](https://github.com/microsoft/FluidFramework/commit/f4fbd2f582c22e0b6fd06986b9b5dbb6b73396a4)
8
+
9
+ A new implementation of `PureDataObject` has been added: `TreeDataObject`.
10
+ Where `DataObject` stores its contents in a `SharedDirectory`, `TreeDataObject` stores its contents in a `SharedTree`.
11
+
3
12
  ## 2.50.0
4
13
 
5
14
  Dependency updates only.
@@ -139,4 +139,16 @@ export class PureDataObjectFactory<TObj extends PureDataObject<I>, I extends Dat
139
139
  readonly type: string;
140
140
  }
141
141
 
142
+ // @alpha @legacy
143
+ export abstract class TreeDataObject<TDataObjectTypes extends DataObjectTypes = DataObjectTypes> extends PureDataObject<TDataObjectTypes> {
144
+ // (undocumented)
145
+ initializeInternal(existing: boolean): Promise<void>;
146
+ protected get tree(): ITree;
147
+ }
148
+
149
+ // @alpha @legacy
150
+ export class TreeDataObjectFactory<TDataObject extends TreeDataObject<TDataObjectTypes>, TDataObjectTypes extends DataObjectTypes = DataObjectTypes> extends PureDataObjectFactory<TDataObject, TDataObjectTypes> {
151
+ constructor(props: DataObjectFactoryProps<TDataObject, TDataObjectTypes>);
152
+ }
153
+
142
154
  ```
@@ -4,4 +4,5 @@
4
4
  */
5
5
  export { DataObjectFactory } from "./dataObjectFactory.js";
6
6
  export { type DataObjectFactoryProps, PureDataObjectFactory, } from "./pureDataObjectFactory.js";
7
+ export { TreeDataObjectFactory } from "./treeDataObjectFactory.js";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data-object-factories/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACN,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data-object-factories/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACN,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -4,9 +4,11 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.PureDataObjectFactory = exports.DataObjectFactory = void 0;
7
+ exports.TreeDataObjectFactory = exports.PureDataObjectFactory = exports.DataObjectFactory = void 0;
8
8
  var dataObjectFactory_js_1 = require("./dataObjectFactory.js");
9
9
  Object.defineProperty(exports, "DataObjectFactory", { enumerable: true, get: function () { return dataObjectFactory_js_1.DataObjectFactory; } });
10
10
  var pureDataObjectFactory_js_1 = require("./pureDataObjectFactory.js");
11
11
  Object.defineProperty(exports, "PureDataObjectFactory", { enumerable: true, get: function () { return pureDataObjectFactory_js_1.PureDataObjectFactory; } });
12
+ var treeDataObjectFactory_js_1 = require("./treeDataObjectFactory.js");
13
+ Object.defineProperty(exports, "TreeDataObjectFactory", { enumerable: true, get: function () { return treeDataObjectFactory_js_1.TreeDataObjectFactory; } });
12
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-object-factories/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,uEAGoC;AADnC,iIAAA,qBAAqB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { DataObjectFactory } from \"./dataObjectFactory.js\";\nexport {\n\ttype DataObjectFactoryProps,\n\tPureDataObjectFactory,\n} from \"./pureDataObjectFactory.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-object-factories/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA2D;AAAlD,yHAAA,iBAAiB,OAAA;AAC1B,uEAGoC;AADnC,iIAAA,qBAAqB,OAAA;AAEtB,uEAAmE;AAA1D,iIAAA,qBAAqB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { DataObjectFactory } from \"./dataObjectFactory.js\";\nexport {\n\ttype DataObjectFactoryProps,\n\tPureDataObjectFactory,\n} from \"./pureDataObjectFactory.js\";\nexport { TreeDataObjectFactory } from \"./treeDataObjectFactory.js\";\n"]}
@@ -0,0 +1,18 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { DataObjectTypes, TreeDataObject } from "../data-objects/index.js";
6
+ import { PureDataObjectFactory, type DataObjectFactoryProps } from "./pureDataObjectFactory.js";
7
+ /**
8
+ * {@link @fluidframework/runtime-definitions#IFluidDataStoreFactory} for use with {@link TreeDataObject}s.
9
+ *
10
+ * @typeParam TDataObject - The concrete TreeDataObject implementation.
11
+ * @typeParam TDataObjectTypes - The input types for the DataObject
12
+ *
13
+ * @legacy @alpha
14
+ */
15
+ export declare class TreeDataObjectFactory<TDataObject extends TreeDataObject<TDataObjectTypes>, TDataObjectTypes extends DataObjectTypes = DataObjectTypes> extends PureDataObjectFactory<TDataObject, TDataObjectTypes> {
16
+ constructor(props: DataObjectFactoryProps<TDataObject, TDataObjectTypes>);
17
+ }
18
+ //# sourceMappingURL=treeDataObjectFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeDataObjectFactory.d.ts","sourceRoot":"","sources":["../../src/data-object-factories/treeDataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEhF,OAAO,EACN,qBAAqB,EACrB,KAAK,sBAAsB,EAC3B,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;GAOG;AACH,qBAAa,qBAAqB,CACjC,WAAW,SAAS,cAAc,CAAC,gBAAgB,CAAC,EACpD,gBAAgB,SAAS,eAAe,GAAG,eAAe,CACzD,SAAQ,qBAAqB,CAAC,WAAW,EAAE,gBAAgB,CAAC;gBAC1C,KAAK,EAAE,sBAAsB,CAAC,WAAW,EAAE,gBAAgB,CAAC;CAiB/E"}
@@ -0,0 +1,32 @@
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.TreeDataObjectFactory = void 0;
8
+ const internal_1 = require("@fluidframework/tree/internal");
9
+ const pureDataObjectFactory_js_1 = require("./pureDataObjectFactory.js");
10
+ /**
11
+ * {@link @fluidframework/runtime-definitions#IFluidDataStoreFactory} for use with {@link TreeDataObject}s.
12
+ *
13
+ * @typeParam TDataObject - The concrete TreeDataObject implementation.
14
+ * @typeParam TDataObjectTypes - The input types for the DataObject
15
+ *
16
+ * @legacy @alpha
17
+ */
18
+ class TreeDataObjectFactory extends pureDataObjectFactory_js_1.PureDataObjectFactory {
19
+ constructor(props) {
20
+ const newProps = {
21
+ ...props,
22
+ sharedObjects: props.sharedObjects ? [...props.sharedObjects] : [],
23
+ };
24
+ // If the user did not specify a SharedTree factory, add it to the shared objects.
25
+ if (!newProps.sharedObjects.some((sharedObject) => sharedObject.type === internal_1.SharedTree.getFactory().type)) {
26
+ newProps.sharedObjects.push(internal_1.SharedTree.getFactory());
27
+ }
28
+ super(newProps);
29
+ }
30
+ }
31
+ exports.TreeDataObjectFactory = TreeDataObjectFactory;
32
+ //# sourceMappingURL=treeDataObjectFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeDataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/treeDataObjectFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4DAA2D;AAI3D,yEAGoC;AAEpC;;;;;;;GAOG;AACH,MAAa,qBAGX,SAAQ,gDAAoD;IAC7D,YAAmB,KAA4D;QAC9E,MAAM,QAAQ,GAAG;YAChB,GAAG,KAAK;YACR,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE;SAClE,CAAC;QAEF,kFAAkF;QAClF,IACC,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAC3B,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,KAAK,qBAAU,CAAC,UAAU,EAAE,CAAC,IAAI,CACpE,EACA,CAAC;YACF,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,qBAAU,CAAC,UAAU,EAAE,CAAC,CAAC;QACtD,CAAC;QAED,KAAK,CAAC,QAAQ,CAAC,CAAC;IACjB,CAAC;CACD;AArBD,sDAqBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { SharedTree } from \"@fluidframework/tree/internal\";\n\nimport type { DataObjectTypes, TreeDataObject } from \"../data-objects/index.js\";\n\nimport {\n\tPureDataObjectFactory,\n\ttype DataObjectFactoryProps,\n} from \"./pureDataObjectFactory.js\";\n\n/**\n * {@link @fluidframework/runtime-definitions#IFluidDataStoreFactory} for use with {@link TreeDataObject}s.\n *\n * @typeParam TDataObject - The concrete TreeDataObject implementation.\n * @typeParam TDataObjectTypes - The input types for the DataObject\n *\n * @legacy @alpha\n */\nexport class TreeDataObjectFactory<\n\tTDataObject extends TreeDataObject<TDataObjectTypes>,\n\tTDataObjectTypes extends DataObjectTypes = DataObjectTypes,\n> extends PureDataObjectFactory<TDataObject, TDataObjectTypes> {\n\tpublic constructor(props: DataObjectFactoryProps<TDataObject, TDataObjectTypes>) {\n\t\tconst newProps = {\n\t\t\t...props,\n\t\t\tsharedObjects: props.sharedObjects ? [...props.sharedObjects] : [],\n\t\t};\n\n\t\t// If the user did not specify a SharedTree factory, add it to the shared objects.\n\t\tif (\n\t\t\t!newProps.sharedObjects.some(\n\t\t\t\t(sharedObject) => sharedObject.type === SharedTree.getFactory().type,\n\t\t\t)\n\t\t) {\n\t\t\tnewProps.sharedObjects.push(SharedTree.getFactory());\n\t\t}\n\n\t\tsuper(newProps);\n\t}\n}\n"]}
@@ -4,48 +4,54 @@
4
4
  */
5
5
  import { type ITree } from "@fluidframework/tree/internal";
6
6
  import { PureDataObject } from "./pureDataObject.js";
7
+ import type { DataObjectTypes } from "./types.js";
7
8
  /**
8
- * {@link @fluidframework/tree#SharedTree}-backed {@link PureDataObject | data object}.
9
+ * A {@link PureDataObject | data object} backed by a {@link @fluidframework/tree#ITree}.
9
10
  *
10
11
  * @remarks
11
12
  *
12
- * 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}.
13
+ * In order to view the tree's data, consumers of this type will need to apply the appropriate view schema to the {@link TreeDataObject.tree}.
14
+ * This will generally be done via {@link PureDataObject.initializingFromExisting} and {@link PureDataObject.initializingFirstTime} methods.
13
15
  *
14
- * @typeParam TTreeView - View derived from the underlying tree.
15
- * Can be used to derive schema-aware views of the tree.
16
- * See {@link TreeDataObject.generateView}.
16
+ * 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 the schema-aware view.
17
+ *
18
+ * @typeParam TDataObjectTypes - The optional input types used to strongly type the data object.
17
19
  *
18
20
  * @example Implementing `initializingFirstTime`
19
21
  *
20
22
  * ```typescript
21
23
  * protected override async initializingFirstTime(): Promise<void> {
22
- * this.tree.initialize(...);
24
+ * // Generate the schema-aware view of the tree.
25
+ * this.treeView = this.tree.viewWith(treeViewConfiguration);
26
+ *
27
+ * // Initialize the tree with initial data.
28
+ * this.treeView.initialize(initialTree);
29
+ * }
30
+ * ```
31
+ *
32
+ * @example Implementing `initializingFromExisting`
33
+ *
34
+ * ```typescript
35
+ * protected override async initializingFromExisting(): Promise<void> {
36
+ * // Generate the schema-aware view of the tree.
37
+ * this.treeView = this.tree.viewWith(treeViewConfiguration);
38
+ *
39
+ * // Ensure the loaded tree is compatible with the view schema.
40
+ * if (!this.treeView.compatibility.canView) {
41
+ * // Handle out-of-schema data as appropriate.
42
+ * }
23
43
  * }
24
44
  * ```
25
45
  *
26
- * @internal
46
+ * @legacy @alpha
27
47
  */
28
- export declare abstract class TreeDataObject<TTreeView> extends PureDataObject {
48
+ export declare abstract class TreeDataObject<TDataObjectTypes extends DataObjectTypes = DataObjectTypes> extends PureDataObject<TDataObjectTypes> {
29
49
  #private;
30
50
  /**
31
- * Generates a view of the data object's {@link @fluidframework/tree#ITree | tree}.
32
- * @remarks Called once during initialization.
33
- */
34
- protected abstract generateView(tree: ITree): TTreeView;
35
- /**
36
- * Gets the underlying {@link @fluidframework/tree#ITree | tree}.
37
- * @remarks
38
- * Note: in most cases, you will want to use {@link TreeDataObject.treeView} instead.
39
- * Created once during initialization.
40
- */
41
- protected get sharedTree(): ITree;
42
- /**
43
- * Gets the derived view of the underlying tree.
44
- *
45
- * @throws
46
- * If the tree has not yet been initialized, this will throw an error.
51
+ * The underlying {@link @fluidframework/tree#ITree | tree}.
52
+ * @remarks Created once during initialization.
47
53
  */
48
- get treeView(): TTreeView;
54
+ protected get tree(): ITree;
49
55
  initializeInternal(existing: boolean): Promise<void>;
50
56
  }
51
57
  //# sourceMappingURL=treeDataObject.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"treeDataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/treeDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,KAAK,EAAc,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAUrD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,8BAAsB,cAAc,CAAC,SAAS,CAAE,SAAQ,cAAc;;IACrE;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,GAAG,SAAS;IAQvD;;;;;OAKG;IACH,SAAS,KAAK,UAAU,IAAI,KAAK,CAKhC;IAQD;;;;;OAKG;IACH,IAAW,QAAQ,IAAI,SAAS,CAK/B;IAEqB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CA6B1E"}
1
+ {"version":3,"file":"treeDataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/treeDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAWlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,8BAAsB,cAAc,CACnC,gBAAgB,SAAS,eAAe,GAAG,eAAe,CACzD,SAAQ,cAAc,CAAC,gBAAgB,CAAC;;IAOzC;;;OAGG;IACH,SAAS,KAAK,IAAI,IAAI,KAAK,CAK1B;IAEqB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CA8B1E"}
@@ -14,7 +14,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
14
14
  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");
15
15
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
16
16
  };
17
- var _TreeDataObject_sharedTree, _TreeDataObject_view;
17
+ var _TreeDataObject_tree;
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.TreeDataObject = void 0;
20
20
  const internal_1 = require("@fluidframework/telemetry-utils/internal");
@@ -22,67 +22,68 @@ const internal_2 = require("@fluidframework/tree/internal");
22
22
  const pureDataObject_js_1 = require("./pureDataObject.js");
23
23
  /**
24
24
  * Channel ID of {@link TreeDataObject}'s root {@link @fluidframework/tree#SharedTree}.
25
+ * @privateRemarks This key is persisted and should not be changed without a migration strategy.
25
26
  */
26
- const treeChannelId = "tree-data-object";
27
+ const treeChannelId = "root-tree";
27
28
  const uninitializedErrorString = "The tree has not yet been initialized. The data object must be initialized before accessing.";
28
29
  /**
29
- * {@link @fluidframework/tree#SharedTree}-backed {@link PureDataObject | data object}.
30
+ * A {@link PureDataObject | data object} backed by a {@link @fluidframework/tree#ITree}.
30
31
  *
31
32
  * @remarks
32
33
  *
33
- * 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}.
34
+ * In order to view the tree's data, consumers of this type will need to apply the appropriate view schema to the {@link TreeDataObject.tree}.
35
+ * This will generally be done via {@link PureDataObject.initializingFromExisting} and {@link PureDataObject.initializingFirstTime} methods.
34
36
  *
35
- * @typeParam TTreeView - View derived from the underlying tree.
36
- * Can be used to derive schema-aware views of the tree.
37
- * See {@link TreeDataObject.generateView}.
37
+ * 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 the schema-aware view.
38
+ *
39
+ * @typeParam TDataObjectTypes - The optional input types used to strongly type the data object.
38
40
  *
39
41
  * @example Implementing `initializingFirstTime`
40
42
  *
41
43
  * ```typescript
42
44
  * protected override async initializingFirstTime(): Promise<void> {
43
- * this.tree.initialize(...);
45
+ * // Generate the schema-aware view of the tree.
46
+ * this.treeView = this.tree.viewWith(treeViewConfiguration);
47
+ *
48
+ * // Initialize the tree with initial data.
49
+ * this.treeView.initialize(initialTree);
50
+ * }
51
+ * ```
52
+ *
53
+ * @example Implementing `initializingFromExisting`
54
+ *
55
+ * ```typescript
56
+ * protected override async initializingFromExisting(): Promise<void> {
57
+ * // Generate the schema-aware view of the tree.
58
+ * this.treeView = this.tree.viewWith(treeViewConfiguration);
59
+ *
60
+ * // Ensure the loaded tree is compatible with the view schema.
61
+ * if (!this.treeView.compatibility.canView) {
62
+ * // Handle out-of-schema data as appropriate.
63
+ * }
44
64
  * }
45
65
  * ```
46
66
  *
47
- * @internal
67
+ * @legacy @alpha
48
68
  */
49
69
  class TreeDataObject extends pureDataObject_js_1.PureDataObject {
50
70
  constructor() {
51
71
  super(...arguments);
52
72
  /**
53
- * Implementation of SharedTree which is used to generate the view.
73
+ * The underlying {@link @fluidframework/tree#ITree | tree}.
54
74
  * @remarks Created once during initialization.
55
75
  */
56
- _TreeDataObject_sharedTree.set(this, void 0);
57
- /**
58
- * View derived from the underlying tree.
59
- * @remarks Populated via {@link TreeDataObject.generateView}.
60
- */
61
- _TreeDataObject_view.set(this, void 0);
62
- }
63
- /**
64
- * Gets the underlying {@link @fluidframework/tree#ITree | tree}.
65
- * @remarks
66
- * Note: in most cases, you will want to use {@link TreeDataObject.treeView} instead.
67
- * Created once during initialization.
68
- */
69
- get sharedTree() {
70
- if (__classPrivateFieldGet(this, _TreeDataObject_sharedTree, "f") === undefined) {
71
- throw new internal_1.UsageError(uninitializedErrorString);
72
- }
73
- return __classPrivateFieldGet(this, _TreeDataObject_sharedTree, "f");
76
+ _TreeDataObject_tree.set(this, void 0);
74
77
  }
75
78
  /**
76
- * Gets the derived view of the underlying tree.
77
- *
78
- * @throws
79
- * If the tree has not yet been initialized, this will throw an error.
79
+ * The underlying {@link @fluidframework/tree#ITree | tree}.
80
+ * @remarks Created once during initialization.
80
81
  */
81
- get treeView() {
82
- if (__classPrivateFieldGet(this, _TreeDataObject_view, "f") === undefined) {
82
+ get tree() {
83
+ if (__classPrivateFieldGet(this, _TreeDataObject_tree, "f") === undefined) {
83
84
  throw new internal_1.UsageError(uninitializedErrorString);
84
85
  }
85
- return __classPrivateFieldGet(this, _TreeDataObject_view, "f");
86
+ return __classPrivateFieldGet(this, _TreeDataObject_tree, "f");
86
87
  }
87
88
  async initializeInternal(existing) {
88
89
  if (existing) {
@@ -94,14 +95,12 @@ class TreeDataObject extends pureDataObject_js_1.PureDataObject {
94
95
  throw new Error(`Content with id ${channel.id} is not a SharedTree and cannot be loaded with treeDataObject.`);
95
96
  }
96
97
  const sharedTree = channel;
97
- __classPrivateFieldSet(this, _TreeDataObject_sharedTree, sharedTree, "f");
98
- __classPrivateFieldSet(this, _TreeDataObject_view, this.generateView(sharedTree), "f");
98
+ __classPrivateFieldSet(this, _TreeDataObject_tree, sharedTree, "f");
99
99
  }
100
100
  else {
101
- const sharedTree = internal_2.SharedTree.create(this.runtime, treeChannelId);
101
+ const sharedTree = this.runtime.createChannel(treeChannelId, internal_2.SharedTree.getFactory().type);
102
102
  sharedTree.bindToContext();
103
- __classPrivateFieldSet(this, _TreeDataObject_sharedTree, sharedTree, "f");
104
- __classPrivateFieldSet(this, _TreeDataObject_view, this.generateView(sharedTree), "f");
103
+ __classPrivateFieldSet(this, _TreeDataObject_tree, sharedTree, "f");
105
104
  // Note, the implementer is responsible for initializing the tree with initial data.
106
105
  // Generally, this can be done via `initializingFirstTime`.
107
106
  }
@@ -109,5 +108,5 @@ class TreeDataObject extends pureDataObject_js_1.PureDataObject {
109
108
  }
110
109
  }
111
110
  exports.TreeDataObject = TreeDataObject;
112
- _TreeDataObject_sharedTree = new WeakMap(), _TreeDataObject_view = new WeakMap();
111
+ _TreeDataObject_tree = new WeakMap();
113
112
  //# sourceMappingURL=treeDataObject.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"treeDataObject.js","sourceRoot":"","sources":["../../src/data-objects/treeDataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAGH,uEAAsE;AACtE,4DAAuE;AAEvE,2DAAqD;AAErD;;GAEG;AACH,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAEzC,MAAM,wBAAwB,GAC7B,8FAA8F,CAAC;AAEhG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAsB,cAA0B,SAAQ,kCAAc;IAAtE;;QAOC;;;WAGG;QACH,6CAA+B;QAe/B;;;WAGG;QACH,uCAA6B;IA4C9B,CAAC;IA7DA;;;;;OAKG;IACH,IAAc,UAAU;QACvB,IAAI,uBAAA,IAAI,kCAAY,KAAK,SAAS,EAAE,CAAC;YACpC,MAAM,IAAI,qBAAU,CAAC,wBAAwB,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,uBAAA,IAAI,kCAAY,CAAC;IACzB,CAAC;IAQD;;;;;OAKG;IACH,IAAW,QAAQ;QAClB,IAAI,uBAAA,IAAI,4BAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,IAAI,qBAAU,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,qBAAU,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;YAElC,uBAAA,IAAI,8BAAe,UAAU,MAAA,CAAC;YAC9B,uBAAA,IAAI,wBAAS,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,MAAA,CAAC;QAC5C,CAAC;aAAM,CAAC;YACP,MAAM,UAAU,GAAG,qBAAU,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;YACjE,UAAuC,CAAC,aAAa,EAAE,CAAC;YAEzD,uBAAA,IAAI,8BAAe,UAAU,MAAA,CAAC;YAC9B,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;AA1ED,wCA0EC","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 * @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 * Implementation of SharedTree which is used to generate the view.\n\t * @remarks Created once during initialization.\n\t */\n\t#sharedTree: ITree | undefined;\n\n\t/**\n\t * Gets the underlying {@link @fluidframework/tree#ITree | tree}.\n\t * @remarks\n\t * Note: in most cases, you will want to use {@link TreeDataObject.treeView} instead.\n\t * Created once during initialization.\n\t */\n\tprotected get sharedTree(): ITree {\n\t\tif (this.#sharedTree === undefined) {\n\t\t\tthrow new UsageError(uninitializedErrorString);\n\t\t}\n\t\treturn this.#sharedTree;\n\t}\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\n\t\t\tthis.#sharedTree = sharedTree;\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.#sharedTree = sharedTree;\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"]}
1
+ {"version":3,"file":"treeDataObject.js","sourceRoot":"","sources":["../../src/data-objects/treeDataObject.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;AAGH,uEAAsE;AACtE,4DAAuE;AAEvE,2DAAqD;AAGrD;;;GAGG;AACH,MAAM,aAAa,GAAG,WAAW,CAAC;AAElC,MAAM,wBAAwB,GAC7B,8FAA8F,CAAC;AAEhG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAsB,cAEpB,SAAQ,kCAAgC;IAF1C;;QAGC;;;WAGG;QACH,uCAAyB;IA2C1B,CAAC;IAzCA;;;OAGG;IACH,IAAc,IAAI;QACjB,IAAI,uBAAA,IAAI,4BAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,IAAI,qBAAU,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,qBAAU,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;YAElC,uBAAA,IAAI,wBAAS,UAAU,MAAA,CAAC;QACzB,CAAC;aAAM,CAAC;YACP,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAC5C,aAAa,EACb,qBAAU,CAAC,UAAU,EAAE,CAAC,IAAI,CACR,CAAC;YACrB,UAAuC,CAAC,aAAa,EAAE,CAAC;YAEzD,uBAAA,IAAI,wBAAS,UAAU,MAAA,CAAC;YAExB,oFAAoF;YACpF,2DAA2D;QAC5D,CAAC;QAED,MAAM,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;CACD;AAlDD,wCAkDC","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 { SharedTree, type ITree } from \"@fluidframework/tree/internal\";\n\nimport { PureDataObject } from \"./pureDataObject.js\";\nimport type { DataObjectTypes } from \"./types.js\";\n\n/**\n * Channel ID of {@link TreeDataObject}'s root {@link @fluidframework/tree#SharedTree}.\n * @privateRemarks This key is persisted and should not be changed without a migration strategy.\n */\nconst treeChannelId = \"root-tree\";\n\nconst uninitializedErrorString =\n\t\"The tree has not yet been initialized. The data object must be initialized before accessing.\";\n\n/**\n * A {@link PureDataObject | data object} backed by a {@link @fluidframework/tree#ITree}.\n *\n * @remarks\n *\n * In order to view the tree's data, consumers of this type will need to apply the appropriate view schema to the {@link TreeDataObject.tree}.\n * This will generally be done via {@link PureDataObject.initializingFromExisting} and {@link PureDataObject.initializingFirstTime} methods.\n *\n * 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 the schema-aware view.\n *\n * @typeParam TDataObjectTypes - The optional input types used to strongly type the data object.\n *\n * @example Implementing `initializingFirstTime`\n *\n * ```typescript\n * protected override async initializingFirstTime(): Promise<void> {\n * \t// Generate the schema-aware view of the tree.\n * \tthis.treeView = this.tree.viewWith(treeViewConfiguration);\n *\n * \t// Initialize the tree with initial data.\n * \tthis.treeView.initialize(initialTree);\n * }\n * ```\n *\n * @example Implementing `initializingFromExisting`\n *\n * ```typescript\n * protected override async initializingFromExisting(): Promise<void> {\n * \t// Generate the schema-aware view of the tree.\n * \tthis.treeView = this.tree.viewWith(treeViewConfiguration);\n *\n * // Ensure the loaded tree is compatible with the view schema.\n * \tif (!this.treeView.compatibility.canView) {\n * \t\t// Handle out-of-schema data as appropriate.\n * \t}\n * }\n * ```\n *\n * @legacy @alpha\n */\nexport abstract class TreeDataObject<\n\tTDataObjectTypes extends DataObjectTypes = DataObjectTypes,\n> extends PureDataObject<TDataObjectTypes> {\n\t/**\n\t * The underlying {@link @fluidframework/tree#ITree | tree}.\n\t * @remarks Created once during initialization.\n\t */\n\t#tree: ITree | undefined;\n\n\t/**\n\t * The underlying {@link @fluidframework/tree#ITree | tree}.\n\t * @remarks Created once during initialization.\n\t */\n\tprotected get tree(): ITree {\n\t\tif (this.#tree === undefined) {\n\t\t\tthrow new UsageError(uninitializedErrorString);\n\t\t}\n\t\treturn this.#tree;\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\n\t\t\tthis.#tree = sharedTree;\n\t\t} else {\n\t\t\tconst sharedTree = this.runtime.createChannel(\n\t\t\t\ttreeChannelId,\n\t\t\t\tSharedTree.getFactory().type,\n\t\t\t) as unknown as ITree;\n\t\t\t(sharedTree as unknown as ISharedObject).bindToContext();\n\n\t\t\tthis.#tree = 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/dist/index.d.ts CHANGED
@@ -16,7 +16,7 @@
16
16
  *
17
17
  * @packageDocumentation
18
18
  */
19
- export { DataObjectFactory, PureDataObjectFactory, type DataObjectFactoryProps, } from "./data-object-factories/index.js";
19
+ export { DataObjectFactory, type DataObjectFactoryProps, PureDataObjectFactory, TreeDataObjectFactory, } from "./data-object-factories/index.js";
20
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACN,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,sBAAsB,GAC3B,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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACN,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,qBAAqB,EACrB,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/dist/index.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.ContainerRuntimeFactoryWithDefaultDataStore = exports.BaseContainerRuntimeFactory = exports.createDataObjectKind = exports.TreeDataObject = exports.PureDataObject = exports.DataObject = exports.PureDataObjectFactory = exports.DataObjectFactory = void 0;
7
+ exports.ContainerRuntimeFactoryWithDefaultDataStore = exports.BaseContainerRuntimeFactory = exports.createDataObjectKind = exports.TreeDataObject = exports.PureDataObject = exports.DataObject = exports.TreeDataObjectFactory = exports.PureDataObjectFactory = exports.DataObjectFactory = void 0;
8
8
  /**
9
9
  * The `aqueduct` package is a library for building Fluid objects and Fluid
10
10
  * containers within the Fluid Framework. Its goal is to provide a thin base
@@ -22,6 +22,7 @@ exports.ContainerRuntimeFactoryWithDefaultDataStore = exports.BaseContainerRunti
22
22
  var index_js_1 = require("./data-object-factories/index.js");
23
23
  Object.defineProperty(exports, "DataObjectFactory", { enumerable: true, get: function () { return index_js_1.DataObjectFactory; } });
24
24
  Object.defineProperty(exports, "PureDataObjectFactory", { enumerable: true, get: function () { return index_js_1.PureDataObjectFactory; } });
25
+ Object.defineProperty(exports, "TreeDataObjectFactory", { enumerable: true, get: function () { return index_js_1.TreeDataObjectFactory; } });
25
26
  var index_js_2 = require("./data-objects/index.js");
26
27
  Object.defineProperty(exports, "DataObject", { enumerable: true, get: function () { return index_js_2.DataObject; } });
27
28
  Object.defineProperty(exports, "PureDataObject", { enumerable: true, get: function () { return index_js_2.PureDataObject; } });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;;;;;;;;;GAaG;AAEH,6DAI0C;AAHzC,6GAAA,iBAAiB,OAAA;AACjB,iHAAA,qBAAqB,OAAA;AAGtB,oDAQiC;AAPhC,sGAAA,UAAU,OAAA;AAIV,0GAAA,cAAc,OAAA;AACd,0GAAA,cAAc,OAAA;AACd,gHAAA,oBAAoB,OAAA;AAErB,mEAKgD;AAJ/C,uHAAA,2BAA2B,OAAA;AAE3B,uIAAA,2CAA2C,OAAA","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\ttype DataObjectFactoryProps,\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"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;;;;;;;;;;GAaG;AAEH,6DAK0C;AAJzC,6GAAA,iBAAiB,OAAA;AAEjB,iHAAA,qBAAqB,OAAA;AACrB,iHAAA,qBAAqB,OAAA;AAEtB,oDAQiC;AAPhC,sGAAA,UAAU,OAAA;AAIV,0GAAA,cAAc,OAAA;AACd,0GAAA,cAAc,OAAA;AACd,gHAAA,oBAAoB,OAAA;AAErB,mEAKgD;AAJ/C,uHAAA,2BAA2B,OAAA;AAE3B,uIAAA,2CAA2C,OAAA","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\ttype DataObjectFactoryProps,\n\tPureDataObjectFactory,\n\tTreeDataObjectFactory,\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/dist/legacy.d.ts CHANGED
@@ -35,5 +35,7 @@ export {
35
35
  DataObjectTypes,
36
36
  IDataObjectProps,
37
37
  PureDataObject,
38
- PureDataObjectFactory
38
+ PureDataObjectFactory,
39
+ TreeDataObject,
40
+ TreeDataObjectFactory
39
41
  } from "./index.js";
@@ -4,4 +4,5 @@
4
4
  */
5
5
  export { DataObjectFactory } from "./dataObjectFactory.js";
6
6
  export { type DataObjectFactoryProps, PureDataObjectFactory, } from "./pureDataObjectFactory.js";
7
+ export { TreeDataObjectFactory } from "./treeDataObjectFactory.js";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data-object-factories/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACN,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/data-object-factories/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACN,KAAK,sBAAsB,EAC3B,qBAAqB,GACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -4,4 +4,5 @@
4
4
  */
5
5
  export { DataObjectFactory } from "./dataObjectFactory.js";
6
6
  export { PureDataObjectFactory, } from "./pureDataObjectFactory.js";
7
+ export { TreeDataObjectFactory } from "./treeDataObjectFactory.js";
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-object-factories/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAEN,qBAAqB,GACrB,MAAM,4BAA4B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { DataObjectFactory } from \"./dataObjectFactory.js\";\nexport {\n\ttype DataObjectFactoryProps,\n\tPureDataObjectFactory,\n} from \"./pureDataObjectFactory.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/data-object-factories/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAEN,qBAAqB,GACrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { DataObjectFactory } from \"./dataObjectFactory.js\";\nexport {\n\ttype DataObjectFactoryProps,\n\tPureDataObjectFactory,\n} from \"./pureDataObjectFactory.js\";\nexport { TreeDataObjectFactory } from \"./treeDataObjectFactory.js\";\n"]}
@@ -0,0 +1,18 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import type { DataObjectTypes, TreeDataObject } from "../data-objects/index.js";
6
+ import { PureDataObjectFactory, type DataObjectFactoryProps } from "./pureDataObjectFactory.js";
7
+ /**
8
+ * {@link @fluidframework/runtime-definitions#IFluidDataStoreFactory} for use with {@link TreeDataObject}s.
9
+ *
10
+ * @typeParam TDataObject - The concrete TreeDataObject implementation.
11
+ * @typeParam TDataObjectTypes - The input types for the DataObject
12
+ *
13
+ * @legacy @alpha
14
+ */
15
+ export declare class TreeDataObjectFactory<TDataObject extends TreeDataObject<TDataObjectTypes>, TDataObjectTypes extends DataObjectTypes = DataObjectTypes> extends PureDataObjectFactory<TDataObject, TDataObjectTypes> {
16
+ constructor(props: DataObjectFactoryProps<TDataObject, TDataObjectTypes>);
17
+ }
18
+ //# sourceMappingURL=treeDataObjectFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeDataObjectFactory.d.ts","sourceRoot":"","sources":["../../src/data-object-factories/treeDataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAEhF,OAAO,EACN,qBAAqB,EACrB,KAAK,sBAAsB,EAC3B,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;GAOG;AACH,qBAAa,qBAAqB,CACjC,WAAW,SAAS,cAAc,CAAC,gBAAgB,CAAC,EACpD,gBAAgB,SAAS,eAAe,GAAG,eAAe,CACzD,SAAQ,qBAAqB,CAAC,WAAW,EAAE,gBAAgB,CAAC;gBAC1C,KAAK,EAAE,sBAAsB,CAAC,WAAW,EAAE,gBAAgB,CAAC;CAiB/E"}
@@ -0,0 +1,28 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { SharedTree } from "@fluidframework/tree/internal";
6
+ import { PureDataObjectFactory, } from "./pureDataObjectFactory.js";
7
+ /**
8
+ * {@link @fluidframework/runtime-definitions#IFluidDataStoreFactory} for use with {@link TreeDataObject}s.
9
+ *
10
+ * @typeParam TDataObject - The concrete TreeDataObject implementation.
11
+ * @typeParam TDataObjectTypes - The input types for the DataObject
12
+ *
13
+ * @legacy @alpha
14
+ */
15
+ export class TreeDataObjectFactory extends PureDataObjectFactory {
16
+ constructor(props) {
17
+ const newProps = {
18
+ ...props,
19
+ sharedObjects: props.sharedObjects ? [...props.sharedObjects] : [],
20
+ };
21
+ // If the user did not specify a SharedTree factory, add it to the shared objects.
22
+ if (!newProps.sharedObjects.some((sharedObject) => sharedObject.type === SharedTree.getFactory().type)) {
23
+ newProps.sharedObjects.push(SharedTree.getFactory());
24
+ }
25
+ super(newProps);
26
+ }
27
+ }
28
+ //# sourceMappingURL=treeDataObjectFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"treeDataObjectFactory.js","sourceRoot":"","sources":["../../src/data-object-factories/treeDataObjectFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAI3D,OAAO,EACN,qBAAqB,GAErB,MAAM,4BAA4B,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAM,OAAO,qBAGX,SAAQ,qBAAoD;IAC7D,YAAmB,KAA4D;QAC9E,MAAM,QAAQ,GAAG;YAChB,GAAG,KAAK;YACR,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE;SAClE,CAAC;QAEF,kFAAkF;QAClF,IACC,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAC3B,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,KAAK,UAAU,CAAC,UAAU,EAAE,CAAC,IAAI,CACpE,EACA,CAAC;YACF,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,CAAC;QACtD,CAAC;QAED,KAAK,CAAC,QAAQ,CAAC,CAAC;IACjB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { SharedTree } from \"@fluidframework/tree/internal\";\n\nimport type { DataObjectTypes, TreeDataObject } from \"../data-objects/index.js\";\n\nimport {\n\tPureDataObjectFactory,\n\ttype DataObjectFactoryProps,\n} from \"./pureDataObjectFactory.js\";\n\n/**\n * {@link @fluidframework/runtime-definitions#IFluidDataStoreFactory} for use with {@link TreeDataObject}s.\n *\n * @typeParam TDataObject - The concrete TreeDataObject implementation.\n * @typeParam TDataObjectTypes - The input types for the DataObject\n *\n * @legacy @alpha\n */\nexport class TreeDataObjectFactory<\n\tTDataObject extends TreeDataObject<TDataObjectTypes>,\n\tTDataObjectTypes extends DataObjectTypes = DataObjectTypes,\n> extends PureDataObjectFactory<TDataObject, TDataObjectTypes> {\n\tpublic constructor(props: DataObjectFactoryProps<TDataObject, TDataObjectTypes>) {\n\t\tconst newProps = {\n\t\t\t...props,\n\t\t\tsharedObjects: props.sharedObjects ? [...props.sharedObjects] : [],\n\t\t};\n\n\t\t// If the user did not specify a SharedTree factory, add it to the shared objects.\n\t\tif (\n\t\t\t!newProps.sharedObjects.some(\n\t\t\t\t(sharedObject) => sharedObject.type === SharedTree.getFactory().type,\n\t\t\t)\n\t\t) {\n\t\t\tnewProps.sharedObjects.push(SharedTree.getFactory());\n\t\t}\n\n\t\tsuper(newProps);\n\t}\n}\n"]}
@@ -4,48 +4,54 @@
4
4
  */
5
5
  import { type ITree } from "@fluidframework/tree/internal";
6
6
  import { PureDataObject } from "./pureDataObject.js";
7
+ import type { DataObjectTypes } from "./types.js";
7
8
  /**
8
- * {@link @fluidframework/tree#SharedTree}-backed {@link PureDataObject | data object}.
9
+ * A {@link PureDataObject | data object} backed by a {@link @fluidframework/tree#ITree}.
9
10
  *
10
11
  * @remarks
11
12
  *
12
- * 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}.
13
+ * In order to view the tree's data, consumers of this type will need to apply the appropriate view schema to the {@link TreeDataObject.tree}.
14
+ * This will generally be done via {@link PureDataObject.initializingFromExisting} and {@link PureDataObject.initializingFirstTime} methods.
13
15
  *
14
- * @typeParam TTreeView - View derived from the underlying tree.
15
- * Can be used to derive schema-aware views of the tree.
16
- * See {@link TreeDataObject.generateView}.
16
+ * 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 the schema-aware view.
17
+ *
18
+ * @typeParam TDataObjectTypes - The optional input types used to strongly type the data object.
17
19
  *
18
20
  * @example Implementing `initializingFirstTime`
19
21
  *
20
22
  * ```typescript
21
23
  * protected override async initializingFirstTime(): Promise<void> {
22
- * this.tree.initialize(...);
24
+ * // Generate the schema-aware view of the tree.
25
+ * this.treeView = this.tree.viewWith(treeViewConfiguration);
26
+ *
27
+ * // Initialize the tree with initial data.
28
+ * this.treeView.initialize(initialTree);
29
+ * }
30
+ * ```
31
+ *
32
+ * @example Implementing `initializingFromExisting`
33
+ *
34
+ * ```typescript
35
+ * protected override async initializingFromExisting(): Promise<void> {
36
+ * // Generate the schema-aware view of the tree.
37
+ * this.treeView = this.tree.viewWith(treeViewConfiguration);
38
+ *
39
+ * // Ensure the loaded tree is compatible with the view schema.
40
+ * if (!this.treeView.compatibility.canView) {
41
+ * // Handle out-of-schema data as appropriate.
42
+ * }
23
43
  * }
24
44
  * ```
25
45
  *
26
- * @internal
46
+ * @legacy @alpha
27
47
  */
28
- export declare abstract class TreeDataObject<TTreeView> extends PureDataObject {
48
+ export declare abstract class TreeDataObject<TDataObjectTypes extends DataObjectTypes = DataObjectTypes> extends PureDataObject<TDataObjectTypes> {
29
49
  #private;
30
50
  /**
31
- * Generates a view of the data object's {@link @fluidframework/tree#ITree | tree}.
32
- * @remarks Called once during initialization.
33
- */
34
- protected abstract generateView(tree: ITree): TTreeView;
35
- /**
36
- * Gets the underlying {@link @fluidframework/tree#ITree | tree}.
37
- * @remarks
38
- * Note: in most cases, you will want to use {@link TreeDataObject.treeView} instead.
39
- * Created once during initialization.
40
- */
41
- protected get sharedTree(): ITree;
42
- /**
43
- * Gets the derived view of the underlying tree.
44
- *
45
- * @throws
46
- * If the tree has not yet been initialized, this will throw an error.
51
+ * The underlying {@link @fluidframework/tree#ITree | tree}.
52
+ * @remarks Created once during initialization.
47
53
  */
48
- get treeView(): TTreeView;
54
+ protected get tree(): ITree;
49
55
  initializeInternal(existing: boolean): Promise<void>;
50
56
  }
51
57
  //# sourceMappingURL=treeDataObject.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"treeDataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/treeDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,KAAK,EAAc,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAUrD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,8BAAsB,cAAc,CAAC,SAAS,CAAE,SAAQ,cAAc;;IACrE;;;OAGG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,GAAG,SAAS;IAQvD;;;;;OAKG;IACH,SAAS,KAAK,UAAU,IAAI,KAAK,CAKhC;IAQD;;;;;OAKG;IACH,IAAW,QAAQ,IAAI,SAAS,CAK/B;IAEqB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CA6B1E"}
1
+ {"version":3,"file":"treeDataObject.d.ts","sourceRoot":"","sources":["../../src/data-objects/treeDataObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAWlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,8BAAsB,cAAc,CACnC,gBAAgB,SAAS,eAAe,GAAG,eAAe,CACzD,SAAQ,cAAc,CAAC,gBAAgB,CAAC;;IAOzC;;;OAGG;IACH,SAAS,KAAK,IAAI,IAAI,KAAK,CAK1B;IAEqB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CA8B1E"}
@@ -13,73 +13,74 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
13
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
14
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
15
15
  };
16
- var _TreeDataObject_sharedTree, _TreeDataObject_view;
16
+ var _TreeDataObject_tree;
17
17
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
18
18
  import { SharedTree } from "@fluidframework/tree/internal";
19
19
  import { PureDataObject } from "./pureDataObject.js";
20
20
  /**
21
21
  * Channel ID of {@link TreeDataObject}'s root {@link @fluidframework/tree#SharedTree}.
22
+ * @privateRemarks This key is persisted and should not be changed without a migration strategy.
22
23
  */
23
- const treeChannelId = "tree-data-object";
24
+ const treeChannelId = "root-tree";
24
25
  const uninitializedErrorString = "The tree has not yet been initialized. The data object must be initialized before accessing.";
25
26
  /**
26
- * {@link @fluidframework/tree#SharedTree}-backed {@link PureDataObject | data object}.
27
+ * A {@link PureDataObject | data object} backed by a {@link @fluidframework/tree#ITree}.
27
28
  *
28
29
  * @remarks
29
30
  *
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
+ * In order to view the tree's data, consumers of this type will need to apply the appropriate view schema to the {@link TreeDataObject.tree}.
32
+ * This will generally be done via {@link PureDataObject.initializingFromExisting} and {@link PureDataObject.initializingFirstTime} methods.
31
33
  *
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}.
34
+ * 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 the schema-aware view.
35
+ *
36
+ * @typeParam TDataObjectTypes - The optional input types used to strongly type the data object.
35
37
  *
36
38
  * @example Implementing `initializingFirstTime`
37
39
  *
38
40
  * ```typescript
39
41
  * protected override async initializingFirstTime(): Promise<void> {
40
- * this.tree.initialize(...);
42
+ * // Generate the schema-aware view of the tree.
43
+ * this.treeView = this.tree.viewWith(treeViewConfiguration);
44
+ *
45
+ * // Initialize the tree with initial data.
46
+ * this.treeView.initialize(initialTree);
47
+ * }
48
+ * ```
49
+ *
50
+ * @example Implementing `initializingFromExisting`
51
+ *
52
+ * ```typescript
53
+ * protected override async initializingFromExisting(): Promise<void> {
54
+ * // Generate the schema-aware view of the tree.
55
+ * this.treeView = this.tree.viewWith(treeViewConfiguration);
56
+ *
57
+ * // Ensure the loaded tree is compatible with the view schema.
58
+ * if (!this.treeView.compatibility.canView) {
59
+ * // Handle out-of-schema data as appropriate.
60
+ * }
41
61
  * }
42
62
  * ```
43
63
  *
44
- * @internal
64
+ * @legacy @alpha
45
65
  */
46
66
  export class TreeDataObject extends PureDataObject {
47
67
  constructor() {
48
68
  super(...arguments);
49
69
  /**
50
- * Implementation of SharedTree which is used to generate the view.
70
+ * The underlying {@link @fluidframework/tree#ITree | tree}.
51
71
  * @remarks Created once during initialization.
52
72
  */
53
- _TreeDataObject_sharedTree.set(this, void 0);
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 underlying {@link @fluidframework/tree#ITree | tree}.
62
- * @remarks
63
- * Note: in most cases, you will want to use {@link TreeDataObject.treeView} instead.
64
- * Created once during initialization.
65
- */
66
- get sharedTree() {
67
- if (__classPrivateFieldGet(this, _TreeDataObject_sharedTree, "f") === undefined) {
68
- throw new UsageError(uninitializedErrorString);
69
- }
70
- return __classPrivateFieldGet(this, _TreeDataObject_sharedTree, "f");
73
+ _TreeDataObject_tree.set(this, void 0);
71
74
  }
72
75
  /**
73
- * Gets the derived view of the underlying tree.
74
- *
75
- * @throws
76
- * If the tree has not yet been initialized, this will throw an error.
76
+ * The underlying {@link @fluidframework/tree#ITree | tree}.
77
+ * @remarks Created once during initialization.
77
78
  */
78
- get treeView() {
79
- if (__classPrivateFieldGet(this, _TreeDataObject_view, "f") === undefined) {
79
+ get tree() {
80
+ if (__classPrivateFieldGet(this, _TreeDataObject_tree, "f") === undefined) {
80
81
  throw new UsageError(uninitializedErrorString);
81
82
  }
82
- return __classPrivateFieldGet(this, _TreeDataObject_view, "f");
83
+ return __classPrivateFieldGet(this, _TreeDataObject_tree, "f");
83
84
  }
84
85
  async initializeInternal(existing) {
85
86
  if (existing) {
@@ -91,19 +92,17 @@ export class TreeDataObject extends PureDataObject {
91
92
  throw new Error(`Content with id ${channel.id} is not a SharedTree and cannot be loaded with treeDataObject.`);
92
93
  }
93
94
  const sharedTree = channel;
94
- __classPrivateFieldSet(this, _TreeDataObject_sharedTree, sharedTree, "f");
95
- __classPrivateFieldSet(this, _TreeDataObject_view, this.generateView(sharedTree), "f");
95
+ __classPrivateFieldSet(this, _TreeDataObject_tree, sharedTree, "f");
96
96
  }
97
97
  else {
98
- const sharedTree = SharedTree.create(this.runtime, treeChannelId);
98
+ const sharedTree = this.runtime.createChannel(treeChannelId, SharedTree.getFactory().type);
99
99
  sharedTree.bindToContext();
100
- __classPrivateFieldSet(this, _TreeDataObject_sharedTree, sharedTree, "f");
101
- __classPrivateFieldSet(this, _TreeDataObject_view, this.generateView(sharedTree), "f");
100
+ __classPrivateFieldSet(this, _TreeDataObject_tree, sharedTree, "f");
102
101
  // Note, the implementer is responsible for initializing the tree with initial data.
103
102
  // Generally, this can be done via `initializingFirstTime`.
104
103
  }
105
104
  await super.initializeInternal(existing);
106
105
  }
107
106
  }
108
- _TreeDataObject_sharedTree = new WeakMap(), _TreeDataObject_view = new WeakMap();
107
+ _TreeDataObject_tree = new WeakMap();
109
108
  //# sourceMappingURL=treeDataObject.js.map
@@ -1 +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;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAgB,cAA0B,SAAQ,cAAc;IAAtE;;QAOC;;;WAGG;QACH,6CAA+B;QAe/B;;;WAGG;QACH,uCAA6B;IA4C9B,CAAC;IA7DA;;;;;OAKG;IACH,IAAc,UAAU;QACvB,IAAI,uBAAA,IAAI,kCAAY,KAAK,SAAS,EAAE,CAAC;YACpC,MAAM,IAAI,UAAU,CAAC,wBAAwB,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,uBAAA,IAAI,kCAAY,CAAC;IACzB,CAAC;IAQD;;;;;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;YAElC,uBAAA,IAAI,8BAAe,UAAU,MAAA,CAAC;YAC9B,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,8BAAe,UAAU,MAAA,CAAC;YAC9B,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 * @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 * Implementation of SharedTree which is used to generate the view.\n\t * @remarks Created once during initialization.\n\t */\n\t#sharedTree: ITree | undefined;\n\n\t/**\n\t * Gets the underlying {@link @fluidframework/tree#ITree | tree}.\n\t * @remarks\n\t * Note: in most cases, you will want to use {@link TreeDataObject.treeView} instead.\n\t * Created once during initialization.\n\t */\n\tprotected get sharedTree(): ITree {\n\t\tif (this.#sharedTree === undefined) {\n\t\t\tthrow new UsageError(uninitializedErrorString);\n\t\t}\n\t\treturn this.#sharedTree;\n\t}\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\n\t\t\tthis.#sharedTree = sharedTree;\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.#sharedTree = sharedTree;\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"]}
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,EAAE,UAAU,EAAc,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;;;GAGG;AACH,MAAM,aAAa,GAAG,WAAW,CAAC;AAElC,MAAM,wBAAwB,GAC7B,8FAA8F,CAAC;AAEhG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,OAAgB,cAEpB,SAAQ,cAAgC;IAF1C;;QAGC;;;WAGG;QACH,uCAAyB;IA2C1B,CAAC;IAzCA;;;OAGG;IACH,IAAc,IAAI;QACjB,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;YAElC,uBAAA,IAAI,wBAAS,UAAU,MAAA,CAAC;QACzB,CAAC;aAAM,CAAC;YACP,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAC5C,aAAa,EACb,UAAU,CAAC,UAAU,EAAE,CAAC,IAAI,CACR,CAAC;YACrB,UAAuC,CAAC,aAAa,EAAE,CAAC;YAEzD,uBAAA,IAAI,wBAAS,UAAU,MAAA,CAAC;YAExB,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 { SharedTree, type ITree } from \"@fluidframework/tree/internal\";\n\nimport { PureDataObject } from \"./pureDataObject.js\";\nimport type { DataObjectTypes } from \"./types.js\";\n\n/**\n * Channel ID of {@link TreeDataObject}'s root {@link @fluidframework/tree#SharedTree}.\n * @privateRemarks This key is persisted and should not be changed without a migration strategy.\n */\nconst treeChannelId = \"root-tree\";\n\nconst uninitializedErrorString =\n\t\"The tree has not yet been initialized. The data object must be initialized before accessing.\";\n\n/**\n * A {@link PureDataObject | data object} backed by a {@link @fluidframework/tree#ITree}.\n *\n * @remarks\n *\n * In order to view the tree's data, consumers of this type will need to apply the appropriate view schema to the {@link TreeDataObject.tree}.\n * This will generally be done via {@link PureDataObject.initializingFromExisting} and {@link PureDataObject.initializingFirstTime} methods.\n *\n * 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 the schema-aware view.\n *\n * @typeParam TDataObjectTypes - The optional input types used to strongly type the data object.\n *\n * @example Implementing `initializingFirstTime`\n *\n * ```typescript\n * protected override async initializingFirstTime(): Promise<void> {\n * \t// Generate the schema-aware view of the tree.\n * \tthis.treeView = this.tree.viewWith(treeViewConfiguration);\n *\n * \t// Initialize the tree with initial data.\n * \tthis.treeView.initialize(initialTree);\n * }\n * ```\n *\n * @example Implementing `initializingFromExisting`\n *\n * ```typescript\n * protected override async initializingFromExisting(): Promise<void> {\n * \t// Generate the schema-aware view of the tree.\n * \tthis.treeView = this.tree.viewWith(treeViewConfiguration);\n *\n * // Ensure the loaded tree is compatible with the view schema.\n * \tif (!this.treeView.compatibility.canView) {\n * \t\t// Handle out-of-schema data as appropriate.\n * \t}\n * }\n * ```\n *\n * @legacy @alpha\n */\nexport abstract class TreeDataObject<\n\tTDataObjectTypes extends DataObjectTypes = DataObjectTypes,\n> extends PureDataObject<TDataObjectTypes> {\n\t/**\n\t * The underlying {@link @fluidframework/tree#ITree | tree}.\n\t * @remarks Created once during initialization.\n\t */\n\t#tree: ITree | undefined;\n\n\t/**\n\t * The underlying {@link @fluidframework/tree#ITree | tree}.\n\t * @remarks Created once during initialization.\n\t */\n\tprotected get tree(): ITree {\n\t\tif (this.#tree === undefined) {\n\t\t\tthrow new UsageError(uninitializedErrorString);\n\t\t}\n\t\treturn this.#tree;\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\n\t\t\tthis.#tree = sharedTree;\n\t\t} else {\n\t\t\tconst sharedTree = this.runtime.createChannel(\n\t\t\t\ttreeChannelId,\n\t\t\t\tSharedTree.getFactory().type,\n\t\t\t) as unknown as ITree;\n\t\t\t(sharedTree as unknown as ISharedObject).bindToContext();\n\n\t\t\tthis.#tree = 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, type DataObjectFactoryProps, } from "./data-object-factories/index.js";
19
+ export { DataObjectFactory, type DataObjectFactoryProps, PureDataObjectFactory, TreeDataObjectFactory, } from "./data-object-factories/index.js";
20
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACN,iBAAiB,EACjB,qBAAqB,EACrB,KAAK,sBAAsB,GAC3B,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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACN,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,qBAAqB,EACrB,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";
19
+ export { DataObjectFactory, PureDataObjectFactory, TreeDataObjectFactory, } from "./data-object-factories/index.js";
20
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,EACN,iBAAiB,EACjB,qBAAqB,GAErB,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\ttype DataObjectFactoryProps,\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"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACN,iBAAiB,EAEjB,qBAAqB,EACrB,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\ttype DataObjectFactoryProps,\n\tPureDataObjectFactory,\n\tTreeDataObjectFactory,\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/legacy.d.ts CHANGED
@@ -35,5 +35,7 @@ export {
35
35
  DataObjectTypes,
36
36
  IDataObjectProps,
37
37
  PureDataObject,
38
- PureDataObjectFactory
38
+ PureDataObjectFactory,
39
+ TreeDataObject,
40
+ TreeDataObjectFactory
39
41
  } from "./index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/aqueduct",
3
- "version": "2.50.0",
3
+ "version": "2.51.0",
4
4
  "description": "A set of implementations for Fluid Framework interfaces.",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -69,29 +69,29 @@
69
69
  "temp-directory": "nyc/.nyc_output"
70
70
  },
71
71
  "dependencies": {
72
- "@fluid-internal/client-utils": "~2.50.0",
73
- "@fluidframework/container-definitions": "~2.50.0",
74
- "@fluidframework/container-runtime": "~2.50.0",
75
- "@fluidframework/container-runtime-definitions": "~2.50.0",
76
- "@fluidframework/core-interfaces": "~2.50.0",
77
- "@fluidframework/core-utils": "~2.50.0",
78
- "@fluidframework/datastore": "~2.50.0",
79
- "@fluidframework/datastore-definitions": "~2.50.0",
80
- "@fluidframework/map": "~2.50.0",
81
- "@fluidframework/request-handler": "~2.50.0",
82
- "@fluidframework/runtime-definitions": "~2.50.0",
83
- "@fluidframework/runtime-utils": "~2.50.0",
84
- "@fluidframework/shared-object-base": "~2.50.0",
85
- "@fluidframework/synthesize": "~2.50.0",
86
- "@fluidframework/telemetry-utils": "~2.50.0",
87
- "@fluidframework/tree": "~2.50.0"
72
+ "@fluid-internal/client-utils": "~2.51.0",
73
+ "@fluidframework/container-definitions": "~2.51.0",
74
+ "@fluidframework/container-runtime": "~2.51.0",
75
+ "@fluidframework/container-runtime-definitions": "~2.51.0",
76
+ "@fluidframework/core-interfaces": "~2.51.0",
77
+ "@fluidframework/core-utils": "~2.51.0",
78
+ "@fluidframework/datastore": "~2.51.0",
79
+ "@fluidframework/datastore-definitions": "~2.51.0",
80
+ "@fluidframework/map": "~2.51.0",
81
+ "@fluidframework/request-handler": "~2.51.0",
82
+ "@fluidframework/runtime-definitions": "~2.51.0",
83
+ "@fluidframework/runtime-utils": "~2.51.0",
84
+ "@fluidframework/shared-object-base": "~2.51.0",
85
+ "@fluidframework/synthesize": "~2.51.0",
86
+ "@fluidframework/telemetry-utils": "~2.51.0",
87
+ "@fluidframework/tree": "~2.51.0"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@arethetypeswrong/cli": "^0.17.1",
91
91
  "@biomejs/biome": "~1.9.3",
92
- "@fluid-internal/mocha-test-setup": "~2.50.0",
92
+ "@fluid-internal/mocha-test-setup": "~2.51.0",
93
93
  "@fluid-tools/build-cli": "^0.56.0",
94
- "@fluidframework/aqueduct-previous": "npm:@fluidframework/aqueduct@2.43.0",
94
+ "@fluidframework/aqueduct-previous": "npm:@fluidframework/aqueduct@2.50.0",
95
95
  "@fluidframework/build-common": "^2.0.3",
96
96
  "@fluidframework/build-tools": "^0.56.0",
97
97
  "@fluidframework/eslint-config-fluid": "^5.7.4",
@@ -109,23 +109,7 @@
109
109
  "typescript": "~5.4.5"
110
110
  },
111
111
  "typeValidation": {
112
- "broken": {
113
- "Class_DataObject": {
114
- "backCompat": false
115
- },
116
- "Class_PureDataObject": {
117
- "backCompat": false
118
- },
119
- "ClassStatics_DataObject": {
120
- "backCompat": false
121
- },
122
- "ClassStatics_PureDataObject": {
123
- "backCompat": false
124
- },
125
- "Interface_DataObjectFactoryProps": {
126
- "backCompat": false
127
- }
128
- },
112
+ "broken": {},
129
113
  "entrypoint": "legacy"
130
114
  },
131
115
  "scripts": {
@@ -8,3 +8,4 @@ export {
8
8
  type DataObjectFactoryProps,
9
9
  PureDataObjectFactory,
10
10
  } from "./pureDataObjectFactory.js";
11
+ export { TreeDataObjectFactory } from "./treeDataObjectFactory.js";
@@ -0,0 +1,44 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { SharedTree } from "@fluidframework/tree/internal";
7
+
8
+ import type { DataObjectTypes, TreeDataObject } from "../data-objects/index.js";
9
+
10
+ import {
11
+ PureDataObjectFactory,
12
+ type DataObjectFactoryProps,
13
+ } from "./pureDataObjectFactory.js";
14
+
15
+ /**
16
+ * {@link @fluidframework/runtime-definitions#IFluidDataStoreFactory} for use with {@link TreeDataObject}s.
17
+ *
18
+ * @typeParam TDataObject - The concrete TreeDataObject implementation.
19
+ * @typeParam TDataObjectTypes - The input types for the DataObject
20
+ *
21
+ * @legacy @alpha
22
+ */
23
+ export class TreeDataObjectFactory<
24
+ TDataObject extends TreeDataObject<TDataObjectTypes>,
25
+ TDataObjectTypes extends DataObjectTypes = DataObjectTypes,
26
+ > extends PureDataObjectFactory<TDataObject, TDataObjectTypes> {
27
+ public constructor(props: DataObjectFactoryProps<TDataObject, TDataObjectTypes>) {
28
+ const newProps = {
29
+ ...props,
30
+ sharedObjects: props.sharedObjects ? [...props.sharedObjects] : [],
31
+ };
32
+
33
+ // If the user did not specify a SharedTree factory, add it to the shared objects.
34
+ if (
35
+ !newProps.sharedObjects.some(
36
+ (sharedObject) => sharedObject.type === SharedTree.getFactory().type,
37
+ )
38
+ ) {
39
+ newProps.sharedObjects.push(SharedTree.getFactory());
40
+ }
41
+
42
+ super(newProps);
43
+ }
44
+ }
@@ -5,82 +5,78 @@
5
5
 
6
6
  import type { ISharedObject } from "@fluidframework/shared-object-base/internal";
7
7
  import { UsageError } from "@fluidframework/telemetry-utils/internal";
8
- import { type ITree, SharedTree } from "@fluidframework/tree/internal";
8
+ import { SharedTree, type ITree } from "@fluidframework/tree/internal";
9
9
 
10
10
  import { PureDataObject } from "./pureDataObject.js";
11
+ import type { DataObjectTypes } from "./types.js";
11
12
 
12
13
  /**
13
14
  * Channel ID of {@link TreeDataObject}'s root {@link @fluidframework/tree#SharedTree}.
15
+ * @privateRemarks This key is persisted and should not be changed without a migration strategy.
14
16
  */
15
- const treeChannelId = "tree-data-object";
17
+ const treeChannelId = "root-tree";
16
18
 
17
19
  const uninitializedErrorString =
18
20
  "The tree has not yet been initialized. The data object must be initialized before accessing.";
19
21
 
20
22
  /**
21
- * {@link @fluidframework/tree#SharedTree}-backed {@link PureDataObject | data object}.
23
+ * A {@link PureDataObject | data object} backed by a {@link @fluidframework/tree#ITree}.
22
24
  *
23
25
  * @remarks
24
26
  *
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}.
27
+ * In order to view the tree's data, consumers of this type will need to apply the appropriate view schema to the {@link TreeDataObject.tree}.
28
+ * This will generally be done via {@link PureDataObject.initializingFromExisting} and {@link PureDataObject.initializingFirstTime} methods.
26
29
  *
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
+ * 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 the schema-aware view.
31
+ *
32
+ * @typeParam TDataObjectTypes - The optional input types used to strongly type the data object.
30
33
  *
31
34
  * @example Implementing `initializingFirstTime`
32
35
  *
33
36
  * ```typescript
34
37
  * protected override async initializingFirstTime(): Promise<void> {
35
- * this.tree.initialize(...);
38
+ * // Generate the schema-aware view of the tree.
39
+ * this.treeView = this.tree.viewWith(treeViewConfiguration);
40
+ *
41
+ * // Initialize the tree with initial data.
42
+ * this.treeView.initialize(initialTree);
36
43
  * }
37
44
  * ```
38
45
  *
39
- * @internal
46
+ * @example Implementing `initializingFromExisting`
47
+ *
48
+ * ```typescript
49
+ * protected override async initializingFromExisting(): Promise<void> {
50
+ * // Generate the schema-aware view of the tree.
51
+ * this.treeView = this.tree.viewWith(treeViewConfiguration);
52
+ *
53
+ * // Ensure the loaded tree is compatible with the view schema.
54
+ * if (!this.treeView.compatibility.canView) {
55
+ * // Handle out-of-schema data as appropriate.
56
+ * }
57
+ * }
58
+ * ```
59
+ *
60
+ * @legacy @alpha
40
61
  */
41
- export abstract class TreeDataObject<TTreeView> extends PureDataObject {
42
- /**
43
- * Generates a view of the data object's {@link @fluidframework/tree#ITree | tree}.
44
- * @remarks Called once during initialization.
45
- */
46
- protected abstract generateView(tree: ITree): TTreeView;
47
-
62
+ export abstract class TreeDataObject<
63
+ TDataObjectTypes extends DataObjectTypes = DataObjectTypes,
64
+ > extends PureDataObject<TDataObjectTypes> {
48
65
  /**
49
- * Implementation of SharedTree which is used to generate the view.
66
+ * The underlying {@link @fluidframework/tree#ITree | tree}.
50
67
  * @remarks Created once during initialization.
51
68
  */
52
- #sharedTree: ITree | undefined;
69
+ #tree: ITree | undefined;
53
70
 
54
71
  /**
55
- * Gets the underlying {@link @fluidframework/tree#ITree | tree}.
56
- * @remarks
57
- * Note: in most cases, you will want to use {@link TreeDataObject.treeView} instead.
58
- * Created once during initialization.
59
- */
60
- protected get sharedTree(): ITree {
61
- if (this.#sharedTree === undefined) {
62
- throw new UsageError(uninitializedErrorString);
63
- }
64
- return this.#sharedTree;
65
- }
66
-
67
- /**
68
- * View derived from the underlying tree.
69
- * @remarks Populated via {@link TreeDataObject.generateView}.
70
- */
71
- #view: TTreeView | undefined;
72
-
73
- /**
74
- * Gets the derived view of the underlying tree.
75
- *
76
- * @throws
77
- * If the tree has not yet been initialized, this will throw an error.
72
+ * The underlying {@link @fluidframework/tree#ITree | tree}.
73
+ * @remarks Created once during initialization.
78
74
  */
79
- public get treeView(): TTreeView {
80
- if (this.#view === undefined) {
75
+ protected get tree(): ITree {
76
+ if (this.#tree === undefined) {
81
77
  throw new UsageError(uninitializedErrorString);
82
78
  }
83
- return this.#view;
79
+ return this.#tree;
84
80
  }
85
81
 
86
82
  public override async initializeInternal(existing: boolean): Promise<void> {
@@ -97,14 +93,15 @@ export abstract class TreeDataObject<TTreeView> extends PureDataObject {
97
93
  }
98
94
  const sharedTree: ITree = channel;
99
95
 
100
- this.#sharedTree = sharedTree;
101
- this.#view = this.generateView(sharedTree);
96
+ this.#tree = sharedTree;
102
97
  } else {
103
- const sharedTree = SharedTree.create(this.runtime, treeChannelId);
98
+ const sharedTree = this.runtime.createChannel(
99
+ treeChannelId,
100
+ SharedTree.getFactory().type,
101
+ ) as unknown as ITree;
104
102
  (sharedTree as unknown as ISharedObject).bindToContext();
105
103
 
106
- this.#sharedTree = sharedTree;
107
- this.#view = this.generateView(sharedTree);
104
+ this.#tree = sharedTree;
108
105
 
109
106
  // Note, the implementer is responsible for initializing the tree with initial data.
110
107
  // Generally, this can be done via `initializingFirstTime`.
package/src/index.ts CHANGED
@@ -20,8 +20,9 @@
20
20
 
21
21
  export {
22
22
  DataObjectFactory,
23
- PureDataObjectFactory,
24
23
  type DataObjectFactoryProps,
24
+ PureDataObjectFactory,
25
+ TreeDataObjectFactory,
25
26
  } from "./data-object-factories/index.js";
26
27
  export {
27
28
  DataObject,