@fluidframework/aqueduct 2.0.0-dev-rc.3.0.0.254866 → 2.0.0-dev-rc.5.0.0.263932

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 (59) hide show
  1. package/.eslintrc.cjs +14 -0
  2. package/.mocharc.cjs +12 -0
  3. package/CHANGELOG.md +346 -0
  4. package/api-extractor-lint.json +4 -0
  5. package/api-extractor.json +4 -0
  6. package/api-report/aqueduct.api.md +165 -0
  7. package/dist/container-runtime-factories/baseContainerRuntimeFactory.d.ts.map +1 -1
  8. package/dist/container-runtime-factories/baseContainerRuntimeFactory.js.map +1 -1
  9. package/dist/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -1
  10. package/dist/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
  11. package/dist/data-object-factories/dataObjectFactory.d.ts.map +1 -1
  12. package/dist/data-object-factories/dataObjectFactory.js +1 -0
  13. package/dist/data-object-factories/dataObjectFactory.js.map +1 -1
  14. package/dist/data-objects/dataObject.d.ts.map +1 -1
  15. package/dist/data-objects/dataObject.js +2 -0
  16. package/dist/data-objects/dataObject.js.map +1 -1
  17. package/dist/data-objects/pureDataObject.d.ts +4 -3
  18. package/dist/data-objects/pureDataObject.d.ts.map +1 -1
  19. package/dist/data-objects/pureDataObject.js.map +1 -1
  20. package/dist/{alpha.d.ts → legacy.d.ts} +2 -1
  21. package/dist/public.d.ts +3 -0
  22. package/{dist/beta.d.ts → internal.d.ts} +2 -0
  23. package/{lib/beta.d.ts → legacy.d.ts} +2 -0
  24. package/lib/container-runtime-factories/baseContainerRuntimeFactory.d.ts.map +1 -1
  25. package/lib/container-runtime-factories/baseContainerRuntimeFactory.js.map +1 -1
  26. package/lib/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -1
  27. package/lib/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.js.map +1 -1
  28. package/lib/data-object-factories/dataObjectFactory.d.ts.map +1 -1
  29. package/lib/data-object-factories/dataObjectFactory.js +4 -1
  30. package/lib/data-object-factories/dataObjectFactory.js.map +1 -1
  31. package/lib/data-objects/dataObject.d.ts.map +1 -1
  32. package/lib/data-objects/dataObject.js +2 -0
  33. package/lib/data-objects/dataObject.js.map +1 -1
  34. package/lib/data-objects/pureDataObject.d.ts +4 -3
  35. package/lib/data-objects/pureDataObject.d.ts.map +1 -1
  36. package/lib/data-objects/pureDataObject.js.map +1 -1
  37. package/lib/{alpha.d.ts → legacy.d.ts} +2 -1
  38. package/lib/public.d.ts +3 -0
  39. package/lib/tsdoc-metadata.json +1 -1
  40. package/package.json +34 -40
  41. package/prettier.config.cjs +8 -0
  42. package/src/container-runtime-factories/baseContainerRuntimeFactory.ts +145 -0
  43. package/src/container-runtime-factories/containerRuntimeFactoryWithDefaultDataStore.ts +112 -0
  44. package/src/container-runtime-factories/index.ts +13 -0
  45. package/src/data-object-factories/dataObjectFactory.ts +63 -0
  46. package/src/data-object-factories/index.ts +7 -0
  47. package/src/data-object-factories/pureDataObjectFactory.ts +379 -0
  48. package/src/data-objects/dataObject.ts +80 -0
  49. package/src/data-objects/index.ts +8 -0
  50. package/src/data-objects/pureDataObject.ts +186 -0
  51. package/src/data-objects/types.ts +40 -0
  52. package/src/index.ts +33 -0
  53. package/tsconfig.cjs.json +7 -0
  54. package/tsconfig.json +9 -0
  55. package/lib/test/aqueduct.spec.js +0 -8
  56. package/lib/test/aqueduct.spec.js.map +0 -1
  57. package/lib/test/tsconfig.tsbuildinfo +0 -1
  58. package/lib/test/types/validateAqueductPrevious.generated.js +0 -30
  59. package/lib/test/types/validateAqueductPrevious.generated.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/aqueduct",
3
- "version": "2.0.0-dev-rc.3.0.0.254866",
3
+ "version": "2.0.0-dev-rc.5.0.0.263932",
4
4
  "description": "A set of implementations for Fluid Framework interfaces.",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -23,13 +23,13 @@
23
23
  "default": "./dist/index.js"
24
24
  }
25
25
  },
26
- "./alpha": {
26
+ "./legacy": {
27
27
  "import": {
28
- "types": "./lib/alpha.d.ts",
28
+ "types": "./lib/legacy.d.ts",
29
29
  "default": "./lib/index.js"
30
30
  },
31
31
  "require": {
32
- "types": "./dist/alpha.d.ts",
32
+ "types": "./dist/legacy.d.ts",
33
33
  "default": "./dist/index.js"
34
34
  }
35
35
  },
@@ -44,13 +44,8 @@
44
44
  }
45
45
  }
46
46
  },
47
- "main": "dist/index.js",
48
- "types": "./dist/public.d.ts",
49
- "files": [
50
- "dist/**/*",
51
- "!dist/test/**",
52
- "lib/**/*"
53
- ],
47
+ "main": "lib/index.js",
48
+ "types": "lib/public.d.ts",
54
49
  "c8": {
55
50
  "all": true,
56
51
  "cache-dir": "nyc/.cache",
@@ -72,30 +67,30 @@
72
67
  "temp-directory": "nyc/.nyc_output"
73
68
  },
74
69
  "dependencies": {
75
- "@fluid-internal/client-utils": "2.0.0-dev-rc.3.0.0.254866",
76
- "@fluidframework/container-definitions": "2.0.0-dev-rc.3.0.0.254866",
77
- "@fluidframework/container-runtime": "2.0.0-dev-rc.3.0.0.254866",
78
- "@fluidframework/container-runtime-definitions": "2.0.0-dev-rc.3.0.0.254866",
79
- "@fluidframework/core-interfaces": "2.0.0-dev-rc.3.0.0.254866",
80
- "@fluidframework/core-utils": "2.0.0-dev-rc.3.0.0.254866",
81
- "@fluidframework/datastore": "2.0.0-dev-rc.3.0.0.254866",
82
- "@fluidframework/datastore-definitions": "2.0.0-dev-rc.3.0.0.254866",
83
- "@fluidframework/map": "2.0.0-dev-rc.3.0.0.254866",
84
- "@fluidframework/request-handler": "2.0.0-dev-rc.3.0.0.254866",
85
- "@fluidframework/runtime-definitions": "2.0.0-dev-rc.3.0.0.254866",
86
- "@fluidframework/runtime-utils": "2.0.0-dev-rc.3.0.0.254866",
87
- "@fluidframework/synthesize": "2.0.0-dev-rc.3.0.0.254866"
70
+ "@fluid-internal/client-utils": "2.0.0-dev-rc.5.0.0.263932",
71
+ "@fluidframework/container-definitions": "2.0.0-dev-rc.5.0.0.263932",
72
+ "@fluidframework/container-runtime": "2.0.0-dev-rc.5.0.0.263932",
73
+ "@fluidframework/container-runtime-definitions": "2.0.0-dev-rc.5.0.0.263932",
74
+ "@fluidframework/core-interfaces": "2.0.0-dev-rc.5.0.0.263932",
75
+ "@fluidframework/core-utils": "2.0.0-dev-rc.5.0.0.263932",
76
+ "@fluidframework/datastore": "2.0.0-dev-rc.5.0.0.263932",
77
+ "@fluidframework/datastore-definitions": "2.0.0-dev-rc.5.0.0.263932",
78
+ "@fluidframework/map": "2.0.0-dev-rc.5.0.0.263932",
79
+ "@fluidframework/request-handler": "2.0.0-dev-rc.5.0.0.263932",
80
+ "@fluidframework/runtime-definitions": "2.0.0-dev-rc.5.0.0.263932",
81
+ "@fluidframework/runtime-utils": "2.0.0-dev-rc.5.0.0.263932",
82
+ "@fluidframework/synthesize": "2.0.0-dev-rc.5.0.0.263932"
88
83
  },
89
84
  "devDependencies": {
90
85
  "@arethetypeswrong/cli": "^0.15.2",
91
86
  "@biomejs/biome": "^1.6.2",
92
- "@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.3.0.0.254866",
93
- "@fluid-tools/build-cli": "^0.35.0",
94
- "@fluidframework/aqueduct-previous": "npm:@fluidframework/aqueduct@2.0.0-internal.8.0.0",
87
+ "@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.5.0.0.263932",
88
+ "@fluid-tools/build-cli": "^0.38.0",
89
+ "@fluidframework/aqueduct-previous": "npm:@fluidframework/aqueduct@2.0.0-rc.3.0.0",
95
90
  "@fluidframework/build-common": "^2.0.3",
96
- "@fluidframework/build-tools": "^0.35.0",
91
+ "@fluidframework/build-tools": "^0.38.0",
97
92
  "@fluidframework/eslint-config-fluid": "^5.1.0",
98
- "@microsoft/api-extractor": "^7.42.3",
93
+ "@microsoft/api-extractor": "^7.43.1",
99
94
  "@types/mocha": "^9.1.1",
100
95
  "@types/node": "^18.19.0",
101
96
  "c8": "^8.0.1",
@@ -112,22 +107,21 @@
112
107
  },
113
108
  "typeValidation": {
114
109
  "broken": {
115
- "ClassDeclaration_DataObjectFactory": {
116
- "forwardCompat": false
110
+ "InterfaceDeclaration_IDataObjectProps": {
111
+ "backCompat": false
117
112
  },
118
- "ClassDeclaration_PureDataObjectFactory": {
113
+ "ClassDeclaration_DataObject": {
119
114
  "forwardCompat": false
120
115
  },
121
- "InterfaceDeclaration_IDataObjectProps": {
122
- "forwardCompat": false,
123
- "backCompat": false
116
+ "ClassDeclaration_PureDataObject": {
117
+ "forwardCompat": false
124
118
  }
125
119
  }
126
120
  },
127
121
  "scripts": {
128
122
  "api": "fluid-build . --task api",
129
- "api-extractor:commonjs": "flub generate entrypoints --outDir ./dist",
130
- "api-extractor:esnext": "flub generate entrypoints --outDir ./lib",
123
+ "api-extractor:commonjs": "flub generate entrypoints --outFileAlpha legacy --outDir ./dist",
124
+ "api-extractor:esnext": "flub generate entrypoints --outFileAlpha legacy --outDir ./lib --node10TypeCompat",
131
125
  "build": "fluid-build . --task build",
132
126
  "build:commonjs": "fluid-build . --task commonjs",
133
127
  "build:compile": "fluid-build . --task compile",
@@ -136,11 +130,11 @@
136
130
  "build:test": "npm run build:test:esm && npm run build:test:cjs",
137
131
  "build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
138
132
  "build:test:esm": "tsc --project ./src/test/tsconfig.json",
139
- "check:are-the-types-wrong": "attw --pack . --entrypoints .",
133
+ "check:are-the-types-wrong": "attw --pack .",
140
134
  "check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
141
135
  "check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
142
136
  "ci:build:docs": "api-extractor run",
143
- "clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
137
+ "clean": "rimraf --glob dist lib \"*.d.ts\" \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
144
138
  "eslint": "eslint --format stylish src",
145
139
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
146
140
  "format": "fluid-build --task format .",
@@ -154,7 +148,7 @@
154
148
  "test:mocha:esm": "mocha --recursive \"lib/test/**/*.spec.*js\" --exit -r node_modules/@fluid-internal/mocha-test-setup",
155
149
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
156
150
  "tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
157
- "typetests:gen": "fluid-type-test-generator",
151
+ "typetests:gen": "flub generate typetests --dir . -v --publicFallback",
158
152
  "typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
159
153
  }
160
154
  }
@@ -0,0 +1,8 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ module.exports = {
7
+ ...require("@fluidframework/build-common/prettier.config.cjs"),
8
+ };
@@ -0,0 +1,145 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { type IContainerContext } from "@fluidframework/container-definitions/internal";
7
+ import {
8
+ ContainerRuntime,
9
+ FluidDataStoreRegistry,
10
+ type IContainerRuntimeOptions,
11
+ } from "@fluidframework/container-runtime/internal";
12
+ import { type IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
13
+ import { type FluidObject } from "@fluidframework/core-interfaces";
14
+ import {
15
+ // eslint-disable-next-line import/no-deprecated
16
+ type RuntimeRequestHandler,
17
+ // eslint-disable-next-line import/no-deprecated
18
+ buildRuntimeRequestHandler,
19
+ } from "@fluidframework/request-handler/internal";
20
+ import {
21
+ type IFluidDataStoreRegistry,
22
+ type IProvideFluidDataStoreRegistry,
23
+ type NamedFluidDataStoreRegistryEntries,
24
+ } from "@fluidframework/runtime-definitions/internal";
25
+ import { RuntimeFactoryHelper } from "@fluidframework/runtime-utils/internal";
26
+ import {
27
+ DependencyContainer,
28
+ type IFluidDependencySynthesizer,
29
+ type IProvideFluidDependencySynthesizer,
30
+ } from "@fluidframework/synthesize/internal";
31
+
32
+ /**
33
+ * {@link BaseContainerRuntimeFactory} construction properties.
34
+ * @alpha
35
+ */
36
+ export interface BaseContainerRuntimeFactoryProps {
37
+ /**
38
+ * The data store registry for containers produced.
39
+ */
40
+ registryEntries: NamedFluidDataStoreRegistryEntries;
41
+ /**
42
+ * @deprecated Will be removed in a future release.
43
+ */
44
+ dependencyContainer?: IFluidDependencySynthesizer;
45
+ /**
46
+ * Request handlers for containers produced.
47
+ * @deprecated Will be removed once Loader LTS version is "2.0.0-internal.7.0.0". Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
48
+ */
49
+ // eslint-disable-next-line import/no-deprecated
50
+ requestHandlers?: RuntimeRequestHandler[];
51
+ /**
52
+ * The runtime options passed to the ContainerRuntime when instantiating it
53
+ */
54
+ runtimeOptions?: IContainerRuntimeOptions;
55
+ /**
56
+ * Function that will initialize the entryPoint of the ContainerRuntime instances
57
+ * created with this factory
58
+ */
59
+ provideEntryPoint: (runtime: IContainerRuntime) => Promise<FluidObject>;
60
+ }
61
+
62
+ /**
63
+ * BaseContainerRuntimeFactory produces container runtimes with the specified data store and service registries,
64
+ * request handlers, runtimeOptions, and entryPoint initialization function.
65
+ * It can be subclassed to implement a first-time initialization procedure for the containers it creates.
66
+ * @alpha
67
+ */
68
+ export class BaseContainerRuntimeFactory
69
+ extends RuntimeFactoryHelper
70
+ implements IProvideFluidDataStoreRegistry
71
+ {
72
+ /**
73
+ * {@inheritDoc @fluidframework/runtime-definitions#IProvideFluidDataStoreRegistry.IFluidDataStoreRegistry}
74
+ */
75
+ public get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {
76
+ return this.registry;
77
+ }
78
+ private readonly registry: IFluidDataStoreRegistry;
79
+
80
+ private readonly registryEntries: NamedFluidDataStoreRegistryEntries;
81
+ private readonly dependencyContainer?: IFluidDependencySynthesizer;
82
+ private readonly runtimeOptions?: IContainerRuntimeOptions;
83
+ // eslint-disable-next-line import/no-deprecated
84
+ private readonly requestHandlers: RuntimeRequestHandler[];
85
+ private readonly provideEntryPoint: (runtime: IContainerRuntime) => Promise<FluidObject>;
86
+
87
+ public constructor(props: BaseContainerRuntimeFactoryProps) {
88
+ super();
89
+
90
+ this.registryEntries = props.registryEntries;
91
+ this.dependencyContainer = props.dependencyContainer;
92
+ this.runtimeOptions = props.runtimeOptions;
93
+ this.provideEntryPoint = props.provideEntryPoint;
94
+ this.requestHandlers = props.requestHandlers ?? [];
95
+ this.registry = new FluidDataStoreRegistry(this.registryEntries);
96
+ }
97
+
98
+ public async instantiateFirstTime(runtime: ContainerRuntime): Promise<void> {
99
+ await this.containerInitializingFirstTime(runtime);
100
+ await this.containerHasInitialized(runtime);
101
+ }
102
+
103
+ public async instantiateFromExisting(runtime: ContainerRuntime): Promise<void> {
104
+ await this.containerHasInitialized(runtime);
105
+ }
106
+
107
+ public async preInitialize(
108
+ context: IContainerContext,
109
+ existing: boolean,
110
+ ): Promise<ContainerRuntime> {
111
+ const scope: Partial<IProvideFluidDependencySynthesizer> = context.scope;
112
+ if (this.dependencyContainer) {
113
+ const dc = new DependencyContainer<FluidObject>(
114
+ this.dependencyContainer,
115
+ scope.IFluidDependencySynthesizer,
116
+ );
117
+ scope.IFluidDependencySynthesizer = dc;
118
+ }
119
+
120
+ return ContainerRuntime.loadRuntime({
121
+ context,
122
+ existing,
123
+ runtimeOptions: this.runtimeOptions,
124
+ registryEntries: this.registryEntries,
125
+ containerScope: scope,
126
+ // eslint-disable-next-line import/no-deprecated
127
+ requestHandler: buildRuntimeRequestHandler(...this.requestHandlers),
128
+ provideEntryPoint: this.provideEntryPoint,
129
+ });
130
+ }
131
+
132
+ /**
133
+ * Subclasses may override containerInitializingFirstTime to perform any setup steps at the time the container
134
+ * is created. This likely includes creating any initial data stores that are expected to be there at the outset.
135
+ * @param runtime - The container runtime for the container being initialized
136
+ */
137
+ protected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {}
138
+
139
+ /**
140
+ * Subclasses may override containerHasInitialized to perform any steps after the container has initialized.
141
+ * This likely includes loading any data stores that are expected to be there at the outset.
142
+ * @param runtime - The container runtime for the container being initialized
143
+ */
144
+ protected async containerHasInitialized(runtime: IContainerRuntime): Promise<void> {}
145
+ }
@@ -0,0 +1,112 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import {
7
+ type ContainerRuntime,
8
+ type IContainerRuntimeOptions,
9
+ } from "@fluidframework/container-runtime/internal";
10
+ import { type IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
11
+ import { type FluidObject, type IRequest, type IResponse } from "@fluidframework/core-interfaces";
12
+ // eslint-disable-next-line import/no-deprecated
13
+ import { type RuntimeRequestHandler } from "@fluidframework/request-handler/internal";
14
+ import {
15
+ type IFluidDataStoreFactory,
16
+ type NamedFluidDataStoreRegistryEntries,
17
+ } from "@fluidframework/runtime-definitions/internal";
18
+ import { RequestParser } from "@fluidframework/runtime-utils/internal";
19
+ import { type IFluidDependencySynthesizer } from "@fluidframework/synthesize/internal";
20
+
21
+ import { BaseContainerRuntimeFactory } from "./baseContainerRuntimeFactory.js";
22
+
23
+ const defaultDataStoreId = "default";
24
+
25
+ async function getDefaultFluidObject(runtime: IContainerRuntime): Promise<FluidObject> {
26
+ const entryPoint = await runtime.getAliasedDataStoreEntryPoint("default");
27
+ if (entryPoint === undefined) {
28
+ throw new Error("default dataStore must exist");
29
+ }
30
+ return entryPoint.get();
31
+ }
32
+
33
+ /**
34
+ * {@link ContainerRuntimeFactoryWithDefaultDataStore} construction properties.
35
+ * @alpha
36
+ */
37
+ export interface ContainerRuntimeFactoryWithDefaultDataStoreProps {
38
+ defaultFactory: IFluidDataStoreFactory;
39
+ /**
40
+ * The data store registry for containers produced.
41
+ */
42
+ registryEntries: NamedFluidDataStoreRegistryEntries;
43
+ /**
44
+ * @deprecated Will be removed in a future release.
45
+ */
46
+ dependencyContainer?: IFluidDependencySynthesizer;
47
+ /**
48
+ * Request handlers for containers produced.
49
+ * @deprecated Will be removed once Loader LTS version is "2.0.0-internal.7.0.0". Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
50
+ */
51
+ // eslint-disable-next-line import/no-deprecated
52
+ requestHandlers?: RuntimeRequestHandler[];
53
+ /**
54
+ * The runtime options passed to the ContainerRuntime when instantiating it
55
+ */
56
+ runtimeOptions?: IContainerRuntimeOptions;
57
+ /**
58
+ * Function that will initialize the entryPoint of the ContainerRuntime instances
59
+ * created with this factory
60
+ */
61
+ provideEntryPoint?: (runtime: IContainerRuntime) => Promise<FluidObject>;
62
+ }
63
+
64
+ /**
65
+ * A ContainerRuntimeFactory that initializes Containers with a single default data store, which can be requested from
66
+ * the container with an empty URL.
67
+ *
68
+ * This factory should be exposed as fluidExport off the entry point to your module.
69
+ * @alpha
70
+ */
71
+ export class ContainerRuntimeFactoryWithDefaultDataStore extends BaseContainerRuntimeFactory {
72
+ public static readonly defaultDataStoreId = defaultDataStoreId;
73
+
74
+ protected readonly defaultFactory: IFluidDataStoreFactory;
75
+
76
+ public constructor(props: ContainerRuntimeFactoryWithDefaultDataStoreProps) {
77
+ const requestHandlers = props.requestHandlers ?? [];
78
+ const provideEntryPoint = props.provideEntryPoint ?? getDefaultFluidObject;
79
+
80
+ const getDefaultObject = async (
81
+ request: IRequest,
82
+ runtime: IContainerRuntime,
83
+ // eslint-disable-next-line unicorn/consistent-function-scoping
84
+ ): Promise<IResponse | undefined> => {
85
+ const parser = RequestParser.create(request);
86
+ if (parser.pathParts.length === 0) {
87
+ // This cast is safe as ContainerRuntime.loadRuntime is called in the base class
88
+ return (runtime as ContainerRuntime).resolveHandle({
89
+ url: `/${defaultDataStoreId}${parser.query}`,
90
+ headers: request.headers,
91
+ });
92
+ }
93
+ return undefined; // continue search
94
+ };
95
+
96
+ super({
97
+ ...props,
98
+ requestHandlers: [getDefaultObject, ...requestHandlers],
99
+ provideEntryPoint,
100
+ });
101
+
102
+ this.defaultFactory = props.defaultFactory;
103
+ }
104
+
105
+ /**
106
+ * {@inheritDoc BaseContainerRuntimeFactory.containerInitializingFirstTime}
107
+ */
108
+ protected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise<void> {
109
+ const dataStore = await runtime.createDataStore(this.defaultFactory.type);
110
+ await dataStore.trySetAlias(defaultDataStoreId);
111
+ }
112
+ }
@@ -0,0 +1,13 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ export {
7
+ BaseContainerRuntimeFactory,
8
+ type BaseContainerRuntimeFactoryProps,
9
+ } from "./baseContainerRuntimeFactory.js";
10
+ export {
11
+ ContainerRuntimeFactoryWithDefaultDataStore,
12
+ type ContainerRuntimeFactoryWithDefaultDataStoreProps,
13
+ } from "./containerRuntimeFactoryWithDefaultDataStore.js";
@@ -0,0 +1,63 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { FluidDataStoreRuntime } from "@fluidframework/datastore/internal";
7
+ import { type IChannelFactory } from "@fluidframework/datastore-definitions";
8
+ import {
9
+ SharedMap,
10
+ DirectoryFactory,
11
+ MapFactory,
12
+ // eslint-disable-next-line import/no-deprecated
13
+ SharedDirectory,
14
+ } from "@fluidframework/map/internal";
15
+ import { type NamedFluidDataStoreRegistryEntries } from "@fluidframework/runtime-definitions/internal";
16
+ import { type FluidObjectSymbolProvider } from "@fluidframework/synthesize/internal";
17
+
18
+ import {
19
+ type DataObject,
20
+ type DataObjectTypes,
21
+ type IDataObjectProps,
22
+ } from "../data-objects/index.js";
23
+
24
+ import { PureDataObjectFactory } from "./pureDataObjectFactory.js";
25
+
26
+ /**
27
+ * DataObjectFactory is the IFluidDataStoreFactory for use with DataObjects.
28
+ * It facilitates DataObject's features (such as its shared directory) by
29
+ * ensuring relevant shared objects etc are available to the factory.
30
+ *
31
+ * @typeParam TObj - DataObject (concrete type)
32
+ * @typeParam I - The input types for the DataObject
33
+ * @alpha
34
+ */
35
+ export class DataObjectFactory<
36
+ TObj extends DataObject<I>,
37
+ I extends DataObjectTypes = DataObjectTypes,
38
+ > extends PureDataObjectFactory<TObj, I> {
39
+ public constructor(
40
+ type: string,
41
+ ctor: new (props: IDataObjectProps<I>) => TObj,
42
+ sharedObjects: readonly IChannelFactory[] = [],
43
+ optionalProviders: FluidObjectSymbolProvider<I["OptionalProviders"]>,
44
+ registryEntries?: NamedFluidDataStoreRegistryEntries,
45
+ runtimeFactory: typeof FluidDataStoreRuntime = FluidDataStoreRuntime,
46
+ ) {
47
+ const mergedObjects = [...sharedObjects];
48
+
49
+ if (!sharedObjects.some((factory) => factory.type === DirectoryFactory.Type)) {
50
+ // User did not register for directory
51
+ // eslint-disable-next-line import/no-deprecated
52
+ mergedObjects.push(SharedDirectory.getFactory());
53
+ }
54
+
55
+ // TODO: Remove SharedMap factory when compatibility with SharedMap DataObject is no longer needed in 0.10
56
+ if (!sharedObjects.some((factory) => factory.type === MapFactory.Type)) {
57
+ // User did not register for map
58
+ mergedObjects.push(SharedMap.getFactory());
59
+ }
60
+
61
+ super(type, ctor, mergedObjects, optionalProviders, registryEntries, runtimeFactory);
62
+ }
63
+ }
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ export { DataObjectFactory } from "./dataObjectFactory.js";
7
+ export { PureDataObjectFactory } from "./pureDataObjectFactory.js";