@fluidframework/fluid-static 2.0.0-internal.7.3.0 → 2.0.0-internal.8.0.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.
- package/CHANGELOG.md +32 -0
- package/api-extractor-lint.json +13 -0
- package/api-extractor.json +3 -3
- package/api-report/fluid-static.api.md +45 -61
- package/dist/fluid-static-alpha.d.ts +408 -0
- package/dist/fluid-static-beta.d.ts +78 -0
- package/dist/fluid-static-public.d.ts +78 -0
- package/dist/fluid-static-untrimmed.d.ts +448 -0
- package/dist/fluidContainer.cjs +10 -4
- package/dist/fluidContainer.cjs.map +1 -1
- package/dist/fluidContainer.d.ts +8 -82
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/rootDataObject.cjs +34 -12
- package/dist/rootDataObject.cjs.map +1 -1
- package/dist/rootDataObject.d.ts +6 -58
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/serviceAudience.cjs +11 -3
- package/dist/serviceAudience.cjs.map +1 -1
- package/dist/serviceAudience.d.ts +7 -66
- package/dist/serviceAudience.d.ts.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +24 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.cjs +3 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +10 -2
- package/dist/utils.d.ts.map +1 -1
- package/lib/fluid-static-alpha.d.ts +408 -0
- package/lib/fluid-static-beta.d.ts +78 -0
- package/lib/fluid-static-public.d.ts +78 -0
- package/lib/fluid-static-untrimmed.d.ts +448 -0
- package/lib/fluidContainer.d.ts +9 -83
- package/lib/fluidContainer.d.ts.map +1 -1
- package/lib/fluidContainer.mjs +9 -3
- package/lib/fluidContainer.mjs.map +1 -1
- package/lib/index.d.ts +4 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.mjs +3 -3
- package/lib/index.mjs.map +1 -1
- package/lib/rootDataObject.d.ts +6 -58
- package/lib/rootDataObject.d.ts.map +1 -1
- package/lib/rootDataObject.mjs +36 -15
- package/lib/rootDataObject.mjs.map +1 -1
- package/lib/serviceAudience.d.ts +7 -66
- package/lib/serviceAudience.d.ts.map +1 -1
- package/lib/serviceAudience.mjs +10 -2
- package/lib/serviceAudience.mjs.map +1 -1
- package/lib/types.d.ts +24 -3
- package/lib/types.d.ts.map +1 -1
- package/lib/types.mjs.map +1 -1
- package/lib/utils.d.ts +11 -3
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.mjs +3 -1
- package/lib/utils.mjs.map +1 -1
- package/package.json +56 -32
- package/src/fluidContainer.ts +18 -3
- package/src/index.ts +4 -3
- package/src/rootDataObject.ts +48 -18
- package/src/serviceAudience.ts +17 -12
- package/src/types.ts +23 -3
- package/src/utils.ts +20 -3
package/lib/types.d.ts
CHANGED
|
@@ -4,20 +4,22 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { IEvent, IEventProvider, IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
7
|
-
import { IFluidDataStoreFactory } from "@fluidframework/runtime-definitions";
|
|
8
7
|
/**
|
|
9
8
|
* A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.
|
|
9
|
+
* @alpha
|
|
10
10
|
*/
|
|
11
11
|
export type LoadableObjectRecord = Record<string, IFluidLoadable>;
|
|
12
12
|
/**
|
|
13
13
|
* A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`
|
|
14
14
|
* or `SharedObject` in a {@link LoadableObjectRecord}.
|
|
15
|
+
* @alpha
|
|
15
16
|
*/
|
|
16
17
|
export type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;
|
|
17
18
|
/**
|
|
18
19
|
* A class object of `DataObject` or `SharedObject`.
|
|
19
20
|
*
|
|
20
21
|
* @typeParam T - The class of the `DataObject` or `SharedObject`.
|
|
22
|
+
* @alpha
|
|
21
23
|
*/
|
|
22
24
|
export type LoadableObjectClass<T extends IFluidLoadable> = DataObjectClass<T> | SharedObjectClass<T>;
|
|
23
25
|
/**
|
|
@@ -25,15 +27,19 @@ export type LoadableObjectClass<T extends IFluidLoadable> = DataObjectClass<T> |
|
|
|
25
27
|
* constructor that will return the type of the `DataObject`.
|
|
26
28
|
*
|
|
27
29
|
* @typeParam T - The class of the `DataObject`.
|
|
30
|
+
* @alpha
|
|
28
31
|
*/
|
|
29
32
|
export type DataObjectClass<T extends IFluidLoadable> = {
|
|
30
|
-
readonly factory:
|
|
33
|
+
readonly factory: {
|
|
34
|
+
IFluidDataStoreFactory: DataObjectClass<T>["factory"];
|
|
35
|
+
};
|
|
31
36
|
} & LoadableObjectCtor<T>;
|
|
32
37
|
/**
|
|
33
38
|
* A class that has a factory that can create a DDSes (`SharedObject`s) and a
|
|
34
39
|
* constructor that will return the type of the `DataObject`.
|
|
35
40
|
*
|
|
36
41
|
* @typeParam T - The class of the `SharedObject`.
|
|
42
|
+
* @alpha
|
|
37
43
|
*/
|
|
38
44
|
export type SharedObjectClass<T extends IFluidLoadable> = {
|
|
39
45
|
readonly getFactory: () => IChannelFactory;
|
|
@@ -42,6 +48,7 @@ export type SharedObjectClass<T extends IFluidLoadable> = {
|
|
|
42
48
|
* An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.
|
|
43
49
|
*
|
|
44
50
|
* @typeParam T - The class of the loadable object.
|
|
51
|
+
* @alpha
|
|
45
52
|
*/
|
|
46
53
|
export type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;
|
|
47
54
|
/**
|
|
@@ -51,6 +58,7 @@ export type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[])
|
|
|
51
58
|
*
|
|
52
59
|
* It includes both the instances of objects that are initially available upon `Container` creation, as well
|
|
53
60
|
* as the types of objects that may be dynamically created throughout the lifetime of the `Container`.
|
|
61
|
+
* @alpha
|
|
54
62
|
*/
|
|
55
63
|
export interface ContainerSchema {
|
|
56
64
|
/**
|
|
@@ -84,11 +92,18 @@ export interface ContainerSchema {
|
|
|
84
92
|
*/
|
|
85
93
|
dynamicObjectTypes?: LoadableObjectClass<any>[];
|
|
86
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* @internal
|
|
97
|
+
*/
|
|
98
|
+
export interface IProvideRootDataObject {
|
|
99
|
+
readonly IRootDataObject: IRootDataObject;
|
|
100
|
+
}
|
|
87
101
|
/**
|
|
88
102
|
* Holds the collection of objects that the container was initially created with, as well as provides the ability
|
|
89
103
|
* to dynamically create further objects during usage.
|
|
104
|
+
* @internal
|
|
90
105
|
*/
|
|
91
|
-
export interface IRootDataObject {
|
|
106
|
+
export interface IRootDataObject extends IProvideRootDataObject {
|
|
92
107
|
/**
|
|
93
108
|
* Provides a record of the initial objects defined on creation.
|
|
94
109
|
*/
|
|
@@ -109,6 +124,7 @@ export interface IRootDataObject {
|
|
|
109
124
|
* @param member - The service-specific member object for the client.
|
|
110
125
|
*
|
|
111
126
|
* @see See {@link IServiceAudienceEvents} for usage details.
|
|
127
|
+
* @alpha
|
|
112
128
|
*/
|
|
113
129
|
export type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;
|
|
114
130
|
/**
|
|
@@ -120,6 +136,7 @@ export type MemberChangedListener<M extends IMember> = (clientId: string, member
|
|
|
120
136
|
* {@link IServiceAudience.getMembers} method will emit events.
|
|
121
137
|
*
|
|
122
138
|
* @typeParam M - A service-specific {@link IMember} implementation.
|
|
139
|
+
* @alpha
|
|
123
140
|
*/
|
|
124
141
|
export interface IServiceAudienceEvents<M extends IMember> extends IEvent {
|
|
125
142
|
/**
|
|
@@ -150,6 +167,7 @@ export interface IServiceAudienceEvents<M extends IMember> extends IEvent {
|
|
|
150
167
|
* details about the connecting client, such as device information, environment, or a username.
|
|
151
168
|
*
|
|
152
169
|
* @typeParam M - A service-specific {@link IMember} type.
|
|
170
|
+
* @alpha
|
|
153
171
|
*/
|
|
154
172
|
export interface IServiceAudience<M extends IMember> extends IEventProvider<IServiceAudienceEvents<M>> {
|
|
155
173
|
/**
|
|
@@ -167,6 +185,7 @@ export interface IServiceAudience<M extends IMember> extends IEventProvider<ISer
|
|
|
167
185
|
* Base interface for information for each connection made to the Fluid session.
|
|
168
186
|
*
|
|
169
187
|
* @remarks This interface can be extended to provide additional information specific to each service.
|
|
188
|
+
* @alpha
|
|
170
189
|
*/
|
|
171
190
|
export interface IConnection {
|
|
172
191
|
/**
|
|
@@ -182,6 +201,7 @@ export interface IConnection {
|
|
|
182
201
|
* Base interface to be implemented to fetch each service's member.
|
|
183
202
|
*
|
|
184
203
|
* @remarks This interface can be extended by each service to provide additional service-specific user metadata.
|
|
204
|
+
* @alpha
|
|
185
205
|
*/
|
|
186
206
|
export interface IMember {
|
|
187
207
|
/**
|
|
@@ -195,6 +215,7 @@ export interface IMember {
|
|
|
195
215
|
}
|
|
196
216
|
/**
|
|
197
217
|
* An extended member object that includes currentConnection
|
|
218
|
+
* @alpha
|
|
198
219
|
*/
|
|
199
220
|
export type Myself<M extends IMember = IMember> = M & {
|
|
200
221
|
currentConnection: string;
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|
package/lib/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent, IEventProvider, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions\";\
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IEvent, IEventProvider, IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions\";\n\n/**\n * A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.\n * @alpha\n */\nexport type LoadableObjectRecord = Record<string, IFluidLoadable>;\n\n/**\n * A mapping of string identifiers to classes that will later be used to instantiate a corresponding `DataObject`\n * or `SharedObject` in a {@link LoadableObjectRecord}.\n * @alpha\n */\nexport type LoadableObjectClassRecord = Record<string, LoadableObjectClass<any>>;\n\n/**\n * A class object of `DataObject` or `SharedObject`.\n *\n * @typeParam T - The class of the `DataObject` or `SharedObject`.\n * @alpha\n */\nexport type LoadableObjectClass<T extends IFluidLoadable> =\n\t| DataObjectClass<T>\n\t| SharedObjectClass<T>;\n\n/**\n * A class that has a factory that can create a `DataObject` and a\n * constructor that will return the type of the `DataObject`.\n *\n * @typeParam T - The class of the `DataObject`.\n * @alpha\n */\nexport type DataObjectClass<T extends IFluidLoadable> = {\n\treadonly factory: { IFluidDataStoreFactory: DataObjectClass<T>[\"factory\"] };\n} & LoadableObjectCtor<T>;\n\n/**\n * A class that has a factory that can create a DDSes (`SharedObject`s) and a\n * constructor that will return the type of the `DataObject`.\n *\n * @typeParam T - The class of the `SharedObject`.\n * @alpha\n */\nexport type SharedObjectClass<T extends IFluidLoadable> = {\n\treadonly getFactory: () => IChannelFactory;\n} & LoadableObjectCtor<T>;\n\n/**\n * An object with a constructor that will return an {@link @fluidframework/core-interfaces#IFluidLoadable}.\n *\n * @typeParam T - The class of the loadable object.\n * @alpha\n */\nexport type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;\n\n/**\n * Declares the Fluid objects that will be available in the {@link IFluidContainer | Container}.\n *\n * @remarks\n *\n * It includes both the instances of objects that are initially available upon `Container` creation, as well\n * as the types of objects that may be dynamically created throughout the lifetime of the `Container`.\n * @alpha\n */\nexport interface ContainerSchema {\n\t/**\n\t * Defines loadable objects that will be created when the {@link IFluidContainer | Container} is first created.\n\t *\n\t * @remarks It uses the key as the id and the value as the loadable object to create.\n\t *\n\t * @example\n\t *\n\t * In the example below two objects will be created when the `Container` is first\n\t * created. One with id \"map1\" that will return a `SharedMap` and the other with\n\t * id \"pair1\" that will return a `KeyValueDataObject`.\n\t *\n\t * ```typescript\n\t * {\n\t * map1: SharedMap,\n\t * pair1: KeyValueDataObject,\n\t * }\n\t * ```\n\t */\n\tinitialObjects: LoadableObjectClassRecord;\n\n\t/**\n\t * Loadable objects that can be created after the initial {@link IFluidContainer | Container} creation.\n\t *\n\t * @remarks\n\t *\n\t * Types defined in `initialObjects` will always be available and are not required to be provided here.\n\t *\n\t * For best practice it's recommended to define all the dynamic types you create even if they are\n\t * included via initialObjects.\n\t */\n\tdynamicObjectTypes?: LoadableObjectClass<any>[];\n}\n\n/**\n * @internal\n */\nexport interface IProvideRootDataObject {\n\treadonly IRootDataObject: IRootDataObject;\n}\n\n/**\n * Holds the collection of objects that the container was initially created with, as well as provides the ability\n * to dynamically create further objects during usage.\n * @internal\n */\nexport interface IRootDataObject extends IProvideRootDataObject {\n\t/**\n\t * Provides a record of the initial objects defined on creation.\n\t */\n\treadonly initialObjects: LoadableObjectRecord;\n\n\t/**\n\t * Dynamically creates a new detached collaborative object (DDS/DataObject).\n\t *\n\t * @param objectClass - Type of the collaborative object to be created.\n\t *\n\t * @typeParam T - The class of the `DataObject` or `SharedObject`.\n\t */\n\tcreate<T extends IFluidLoadable>(objectClass: LoadableObjectClass<T>): Promise<T>;\n}\n\n/**\n * Signature for {@link IMember} change events.\n *\n * @param clientId - A unique identifier for the client.\n * @param member - The service-specific member object for the client.\n *\n * @see See {@link IServiceAudienceEvents} for usage details.\n * @alpha\n */\nexport type MemberChangedListener<M extends IMember> = (clientId: string, member: M) => void;\n\n/**\n * Events that trigger when the roster of members in the Fluid session change.\n *\n * @remarks\n *\n * Only changes that would be reflected in the returned map of {@link IServiceAudience}'s\n * {@link IServiceAudience.getMembers} method will emit events.\n *\n * @typeParam M - A service-specific {@link IMember} implementation.\n * @alpha\n */\nexport interface IServiceAudienceEvents<M extends IMember> extends IEvent {\n\t/**\n\t * Emitted when a {@link IMember | member}(s) are either added or removed.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"membersChanged\", listener: () => void): void;\n\n\t/**\n\t * Emitted when a {@link IMember | member} joins the audience.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"memberAdded\", listener: MemberChangedListener<M>): void;\n\n\t/**\n\t * Emitted when a {@link IMember | member} leaves the audience.\n\t *\n\t * @eventProperty\n\t */\n\t(event: \"memberRemoved\", listener: MemberChangedListener<M>): void;\n}\n\n/**\n * Base interface to be implemented to fetch each service's audience.\n *\n * @remarks\n *\n * The type parameter `M` allows consumers to further extend the client object with service-specific\n * details about the connecting client, such as device information, environment, or a username.\n *\n * @typeParam M - A service-specific {@link IMember} type.\n * @alpha\n */\nexport interface IServiceAudience<M extends IMember>\n\textends IEventProvider<IServiceAudienceEvents<M>> {\n\t/**\n\t * Returns an map of all users currently in the Fluid session where key is the userId and the value is the\n\t * member object. The implementation may choose to exclude certain connections from the returned map.\n\t * E.g. ServiceAudience excludes non-interactive connections to represent only the roster of live users.\n\t */\n\tgetMembers(): Map<string, M>;\n\n\t/**\n\t * Returns the current active user on this client once they are connected. Otherwise, returns undefined.\n\t */\n\tgetMyself(): Myself<M> | undefined;\n}\n\n/**\n * Base interface for information for each connection made to the Fluid session.\n *\n * @remarks This interface can be extended to provide additional information specific to each service.\n * @alpha\n */\nexport interface IConnection {\n\t/**\n\t * A unique ID for the connection. A single user may have multiple connections, each with a different ID.\n\t */\n\tid: string;\n\n\t/**\n\t * Whether the connection is in read or read/write mode.\n\t */\n\tmode: \"write\" | \"read\";\n}\n\n/**\n * Base interface to be implemented to fetch each service's member.\n *\n * @remarks This interface can be extended by each service to provide additional service-specific user metadata.\n * @alpha\n */\nexport interface IMember {\n\t/**\n\t * An ID for the user, unique among each individual user connecting to the session.\n\t */\n\tuserId: string;\n\n\t/**\n\t * The set of connections the user has made, e.g. from multiple tabs or devices.\n\t */\n\tconnections: IConnection[];\n}\n\n/**\n * An extended member object that includes currentConnection\n * @alpha\n */\nexport type Myself<M extends IMember = IMember> = M & { currentConnection: string };\n"]}
|
package/lib/utils.d.ts
CHANGED
|
@@ -3,12 +3,20 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
6
|
-
import { NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions";
|
|
7
|
-
import {
|
|
6
|
+
import { IFluidDataStoreFactory, NamedFluidDataStoreRegistryEntry } from "@fluidframework/runtime-definitions";
|
|
7
|
+
import { IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
8
|
+
import { ContainerSchema, DataObjectClass, SharedObjectClass } from "./types.mjs";
|
|
9
|
+
/**
|
|
10
|
+
* An internal type used by the internal type guard isDataObjectClass to cast a
|
|
11
|
+
* DataObjectClass to a type that is strongly coupled to IFluidDataStoreFactory.
|
|
12
|
+
* Unlike the external and exported type DataObjectClass which is
|
|
13
|
+
* weakly coupled to the IFluidDataStoreFactory to prevent leaking internals.
|
|
14
|
+
*/
|
|
15
|
+
export type InternalDataObjectClass<T extends IFluidLoadable> = DataObjectClass<T> & Record<"factory", IFluidDataStoreFactory>;
|
|
8
16
|
/**
|
|
9
17
|
* Runtime check to determine if a class is a DataObject type
|
|
10
18
|
*/
|
|
11
|
-
export declare const isDataObjectClass: (obj: any) => obj is
|
|
19
|
+
export declare const isDataObjectClass: (obj: any) => obj is InternalDataObjectClass<IFluidLoadable>;
|
|
12
20
|
/**
|
|
13
21
|
* Runtime check to determine if a class is a SharedObject type
|
|
14
22
|
*/
|
package/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,eAAe,EAAE,MAAM,uCAAuC;OAChE,EACN,sBAAsB,EACtB,gCAAgC,EAChC,MAAM,qCAAqC;OACrC,EAAE,cAAc,EAAE,MAAM,iCAAiC;OACzD,EAAE,eAAe,EAAE,eAAe,EAAuB,iBAAiB,EAAE;AAEnF;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,CAAC,CAAC,SAAS,cAAc,IAAI,eAAe,CAAC,CAAC,CAAC,GACjF,MAAM,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAS,GAAG,mDAMzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,QAAS,GAAG,kCAE3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,WACrC,eAAe,KACrB,CAAC,gCAAgC,EAAE,EAAE,eAAe,EAAE,CA0BxD,CAAC"}
|
package/lib/utils.mjs
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* Runtime check to determine if a class is a DataObject type
|
|
7
7
|
*/
|
|
8
8
|
export const isDataObjectClass = (obj) => {
|
|
9
|
-
|
|
9
|
+
const maybe = obj;
|
|
10
|
+
return (maybe?.factory?.IFluidDataStoreFactory !== undefined &&
|
|
11
|
+
maybe?.factory?.IFluidDataStoreFactory === maybe?.factory);
|
|
10
12
|
};
|
|
11
13
|
/**
|
|
12
14
|
* Runtime check to determine if a class is a SharedObject type
|
package/lib/utils.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"utils.mjs","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAmBH;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAQ,EAAkD,EAAE;IAC7F,MAAM,KAAK,GAAiE,GAAG,CAAC;IAChF,OAAO,CACN,KAAK,EAAE,OAAO,EAAE,sBAAsB,KAAK,SAAS;QACpD,KAAK,EAAE,OAAO,EAAE,sBAAsB,KAAK,KAAK,EAAE,OAAO,CACzD,CAAC;AACH,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAQ,EAAiC,EAAE;IAC9E,OAAO,GAAG,EAAE,UAAU,KAAK,SAAS,CAAC;AACtC,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAChD,MAAuB,EACmC,EAAE;IAC5D,MAAM,eAAe,GAAG,IAAI,GAAG,EAAoC,CAAC;IACpE,MAAM,aAAa,GAAG,IAAI,GAAG,EAAmB,CAAC;IAEjD,MAAM,YAAY,GAAG,CAAC,GAA6B,EAAE,EAAE;QACtD,IAAI,mBAAmB,CAAC,GAAG,CAAC,EAAE;YAC7B,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;SACpC;aAAM,IAAI,iBAAiB,CAAC,GAAG,CAAC,EAAE;YAClC,eAAe,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;SACtE;aAAM;YACN,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;SACnE;IACF,CAAC,CAAC;IAEF,gDAAgD;IAChD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;QAC9B,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;QACvC,GAAG,CAAC,MAAM,CAAC,kBAAkB,IAAI,EAAE,CAAC;KACpC,CAAC,CAAC;IACH,cAAc,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAErC,IAAI,eAAe,CAAC,IAAI,KAAK,CAAC,IAAI,aAAa,CAAC,IAAI,KAAK,CAAC,EAAE;QAC3D,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;KACzE;IAED,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;AACjE,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IChannelFactory } from \"@fluidframework/datastore-definitions\";\nimport {\n\tIFluidDataStoreFactory,\n\tNamedFluidDataStoreRegistryEntry,\n} from \"@fluidframework/runtime-definitions\";\nimport { IFluidLoadable } from \"@fluidframework/core-interfaces\";\nimport { ContainerSchema, DataObjectClass, LoadableObjectClass, SharedObjectClass } from \"./types\";\n\n/**\n * An internal type used by the internal type guard isDataObjectClass to cast a\n * DataObjectClass to a type that is strongly coupled to IFluidDataStoreFactory.\n * Unlike the external and exported type DataObjectClass which is\n * weakly coupled to the IFluidDataStoreFactory to prevent leaking internals.\n */\nexport type InternalDataObjectClass<T extends IFluidLoadable> = DataObjectClass<T> &\n\tRecord<\"factory\", IFluidDataStoreFactory>;\n\n/**\n * Runtime check to determine if a class is a DataObject type\n */\nexport const isDataObjectClass = (obj: any): obj is InternalDataObjectClass<IFluidLoadable> => {\n\tconst maybe: Partial<InternalDataObjectClass<IFluidLoadable>> | undefined = obj;\n\treturn (\n\t\tmaybe?.factory?.IFluidDataStoreFactory !== undefined &&\n\t\tmaybe?.factory?.IFluidDataStoreFactory === maybe?.factory\n\t);\n};\n\n/**\n * Runtime check to determine if a class is a SharedObject type\n */\nexport const isSharedObjectClass = (obj: any): obj is SharedObjectClass<any> => {\n\treturn obj?.getFactory !== undefined;\n};\n\n/**\n * The ContainerSchema consists of initialObjects and dynamicObjectTypes. These types can be\n * of both SharedObject or DataObject. This function seperates the two and returns a registery\n * of DataObject types and an array of SharedObjects.\n */\nexport const parseDataObjectsFromSharedObjects = (\n\tschema: ContainerSchema,\n): [NamedFluidDataStoreRegistryEntry[], IChannelFactory[]] => {\n\tconst registryEntries = new Set<NamedFluidDataStoreRegistryEntry>();\n\tconst sharedObjects = new Set<IChannelFactory>();\n\n\tconst tryAddObject = (obj: LoadableObjectClass<any>) => {\n\t\tif (isSharedObjectClass(obj)) {\n\t\t\tsharedObjects.add(obj.getFactory());\n\t\t} else if (isDataObjectClass(obj)) {\n\t\t\tregistryEntries.add([obj.factory.type, Promise.resolve(obj.factory)]);\n\t\t} else {\n\t\t\tthrow new Error(`Entry is neither a DataObject or a SharedObject`);\n\t\t}\n\t};\n\n\t// Add the object types that will be initialized\n\tconst dedupedObjects = new Set([\n\t\t...Object.values(schema.initialObjects),\n\t\t...(schema.dynamicObjectTypes ?? []),\n\t]);\n\tdedupedObjects.forEach(tryAddObject);\n\n\tif (registryEntries.size === 0 && sharedObjects.size === 0) {\n\t\tthrow new Error(\"Container cannot be initialized without any DataTypes\");\n\t}\n\n\treturn [Array.from(registryEntries), Array.from(sharedObjects)];\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/fluid-static",
|
|
3
|
-
"version": "2.0.0-internal.
|
|
3
|
+
"version": "2.0.0-internal.8.0.0",
|
|
4
4
|
"description": "A tool to enable consumption of Fluid Data Objects without requiring custom container code.",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -11,18 +11,6 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Microsoft and contributors",
|
|
13
13
|
"sideEffects": false,
|
|
14
|
-
"exports": {
|
|
15
|
-
".": {
|
|
16
|
-
"import": {
|
|
17
|
-
"types": "./lib/index.d.ts",
|
|
18
|
-
"default": "./lib/index.mjs"
|
|
19
|
-
},
|
|
20
|
-
"require": {
|
|
21
|
-
"types": "./dist/index.d.ts",
|
|
22
|
-
"default": "./dist/index.cjs"
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
14
|
"main": "dist/index.cjs",
|
|
27
15
|
"module": "lib/index.mjs",
|
|
28
16
|
"types": "dist/index.d.ts",
|
|
@@ -47,31 +35,34 @@
|
|
|
47
35
|
"temp-directory": "nyc/.nyc_output"
|
|
48
36
|
},
|
|
49
37
|
"dependencies": {
|
|
50
|
-
"@fluid-internal/client-utils": ">=2.0.0-internal.
|
|
51
|
-
"@fluidframework/aqueduct": ">=2.0.0-internal.
|
|
52
|
-
"@fluidframework/container-definitions": ">=2.0.0-internal.
|
|
53
|
-
"@fluidframework/container-loader": ">=2.0.0-internal.
|
|
54
|
-
"@fluidframework/container-runtime
|
|
55
|
-
"@fluidframework/
|
|
56
|
-
"@fluidframework/
|
|
38
|
+
"@fluid-internal/client-utils": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
39
|
+
"@fluidframework/aqueduct": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
40
|
+
"@fluidframework/container-definitions": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
41
|
+
"@fluidframework/container-loader": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
42
|
+
"@fluidframework/container-runtime": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
43
|
+
"@fluidframework/container-runtime-definitions": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
44
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
45
|
+
"@fluidframework/datastore-definitions": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
57
46
|
"@fluidframework/protocol-definitions": "^3.0.0",
|
|
58
|
-
"@fluidframework/request-handler": ">=2.0.0-internal.
|
|
59
|
-
"@fluidframework/runtime-definitions": ">=2.0.0-internal.
|
|
60
|
-
"@fluidframework/runtime-utils": ">=2.0.0-internal.
|
|
47
|
+
"@fluidframework/request-handler": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
48
|
+
"@fluidframework/runtime-definitions": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
49
|
+
"@fluidframework/runtime-utils": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0"
|
|
61
50
|
},
|
|
62
51
|
"devDependencies": {
|
|
52
|
+
"@arethetypeswrong/cli": "^0.13.3",
|
|
63
53
|
"@fluid-tools/build-cli": "^0.28.0",
|
|
64
54
|
"@fluidframework/build-common": "^2.0.3",
|
|
65
55
|
"@fluidframework/build-tools": "^0.28.0",
|
|
66
56
|
"@fluidframework/eslint-config-fluid": "^3.1.0",
|
|
67
57
|
"@fluidframework/fluid-static-previous": "npm:@fluidframework/fluid-static@2.0.0-internal.7.2.0",
|
|
68
|
-
"@fluidframework/map": ">=2.0.0-internal.
|
|
69
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.
|
|
70
|
-
"@fluidframework/sequence": ">=2.0.0-internal.
|
|
58
|
+
"@fluidframework/map": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
59
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
60
|
+
"@fluidframework/sequence": ">=2.0.0-internal.8.0.0 <2.0.0-internal.8.1.0",
|
|
71
61
|
"@microsoft/api-extractor": "^7.38.3",
|
|
72
62
|
"@types/mocha": "^9.1.1",
|
|
73
|
-
"@types/node": "^
|
|
63
|
+
"@types/node": "^18.19.0",
|
|
74
64
|
"c8": "^7.7.1",
|
|
65
|
+
"copyfiles": "^2.4.1",
|
|
75
66
|
"cross-env": "^7.0.3",
|
|
76
67
|
"eslint": "~8.50.0",
|
|
77
68
|
"mocha": "^10.2.0",
|
|
@@ -83,25 +74,58 @@
|
|
|
83
74
|
"tsc-multi": "^1.1.0",
|
|
84
75
|
"typescript": "~5.1.6"
|
|
85
76
|
},
|
|
77
|
+
"fluidBuild": {
|
|
78
|
+
"tasks": {
|
|
79
|
+
"build:docs": {
|
|
80
|
+
"dependsOn": [
|
|
81
|
+
"...",
|
|
82
|
+
"api-extractor:commonjs",
|
|
83
|
+
"api-extractor:esnext"
|
|
84
|
+
],
|
|
85
|
+
"script": false
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
86
89
|
"typeValidation": {
|
|
87
|
-
"broken": {
|
|
90
|
+
"broken": {
|
|
91
|
+
"RemovedClassDeclaration_DOProviderContainerRuntimeFactory": {
|
|
92
|
+
"forwardCompat": false,
|
|
93
|
+
"backCompat": false
|
|
94
|
+
},
|
|
95
|
+
"RemovedClassDeclaration_FluidContainer": {
|
|
96
|
+
"forwardCompat": false,
|
|
97
|
+
"backCompat": false
|
|
98
|
+
},
|
|
99
|
+
"RemovedClassDeclaration_ServiceAudience": {
|
|
100
|
+
"forwardCompat": false,
|
|
101
|
+
"backCompat": false
|
|
102
|
+
},
|
|
103
|
+
"InterfaceDeclaration_IRootDataObject": {
|
|
104
|
+
"forwardCompat": false
|
|
105
|
+
}
|
|
106
|
+
}
|
|
88
107
|
},
|
|
89
108
|
"scripts": {
|
|
109
|
+
"api": "fluid-build . --task api",
|
|
110
|
+
"api-extractor:commonjs": "api-extractor run --local",
|
|
111
|
+
"api-extractor:esnext": "copyfiles -u 1 \"dist/**/*-@(alpha|beta|public|untrimmed).d.ts\" lib",
|
|
90
112
|
"build": "fluid-build . --task build",
|
|
91
113
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
92
114
|
"build:compile": "fluid-build . --task compile",
|
|
93
|
-
"build:docs": "
|
|
115
|
+
"build:docs": "fluid-build . --task api",
|
|
94
116
|
"build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
|
|
95
117
|
"build:test": "tsc-multi --config ./tsc-multi.test.json",
|
|
118
|
+
"check:are-the-types-wrong": "attw --pack",
|
|
119
|
+
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
|
|
96
120
|
"ci:build:docs": "api-extractor run",
|
|
97
121
|
"clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
|
|
98
122
|
"eslint": "eslint --format stylish src",
|
|
99
123
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
100
124
|
"format": "npm run prettier:fix",
|
|
101
|
-
"lint": "npm run prettier && npm run eslint",
|
|
125
|
+
"lint": "npm run prettier && npm run check:release-tags && npm run eslint",
|
|
102
126
|
"lint:fix": "npm run prettier:fix && npm run eslint:fix",
|
|
103
|
-
"prettier": "prettier --check . --ignore-path ../../../.prettierignore",
|
|
104
|
-
"prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
|
|
127
|
+
"prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
|
|
128
|
+
"prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
105
129
|
"test": "npm run test:mocha",
|
|
106
130
|
"test:coverage": "c8 npm test",
|
|
107
131
|
"test:mocha": "mocha --recursive \"dist/test/**/*.spec.cjs\" -r node_modules/@fluidframework/mocha-test-setup",
|
package/src/fluidContainer.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type { ContainerSchema, IRootDataObject, LoadableObjectClass } from "./ty
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Extract the type of 'initialObjects' from the given {@link ContainerSchema} type.
|
|
17
|
+
* @alpha
|
|
17
18
|
*/
|
|
18
19
|
export type InitialObjects<T extends ContainerSchema> = {
|
|
19
20
|
// Construct a LoadableObjectRecord type by enumerating the keys of
|
|
@@ -30,6 +31,7 @@ export type InitialObjects<T extends ContainerSchema> = {
|
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* Events emitted from {@link IFluidContainer}.
|
|
34
|
+
* @alpha
|
|
33
35
|
*/
|
|
34
36
|
export interface IFluidContainerEvents extends IEvent {
|
|
35
37
|
/**
|
|
@@ -94,6 +96,7 @@ export interface IFluidContainerEvents extends IEvent {
|
|
|
94
96
|
* @typeparam TContainerSchema - Used to determine the type of 'initialObjects'.
|
|
95
97
|
*
|
|
96
98
|
* @remarks Note: external implementations of this interface are not supported.
|
|
99
|
+
* @alpha
|
|
97
100
|
*/
|
|
98
101
|
export interface IFluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
|
|
99
102
|
extends IEventProvider<IFluidContainerEvents> {
|
|
@@ -208,6 +211,18 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
|
|
|
208
211
|
dispose(): void;
|
|
209
212
|
}
|
|
210
213
|
|
|
214
|
+
/**
|
|
215
|
+
* @internal
|
|
216
|
+
*/
|
|
217
|
+
export function createFluidContainer<
|
|
218
|
+
TContainerSchema extends ContainerSchema = ContainerSchema,
|
|
219
|
+
>(props: {
|
|
220
|
+
container: IContainer;
|
|
221
|
+
rootDataObject: IRootDataObject;
|
|
222
|
+
}): IFluidContainer<TContainerSchema> {
|
|
223
|
+
return new FluidContainer<TContainerSchema>(props.container, props.rootDataObject);
|
|
224
|
+
}
|
|
225
|
+
|
|
211
226
|
/**
|
|
212
227
|
* Base {@link IFluidContainer} implementation.
|
|
213
228
|
*
|
|
@@ -216,8 +231,10 @@ export interface IFluidContainer<TContainerSchema extends ContainerSchema = Cont
|
|
|
216
231
|
*
|
|
217
232
|
* Note: this implementation is not complete. Consumers who rely on {@link IFluidContainer.attach}
|
|
218
233
|
* will need to utilize or provide a service-specific implementation of this type that implements that method.
|
|
234
|
+
* @deprecated use {@link createFluidContainer} and {@link IFluidContainer} instead
|
|
235
|
+
* @internal
|
|
219
236
|
*/
|
|
220
|
-
|
|
237
|
+
class FluidContainer<TContainerSchema extends ContainerSchema = ContainerSchema>
|
|
221
238
|
extends TypedEventEmitter<IFluidContainerEvents>
|
|
222
239
|
implements IFluidContainer<TContainerSchema>
|
|
223
240
|
{
|
|
@@ -334,8 +351,6 @@ export class FluidContainer<TContainerSchema extends ContainerSchema = Container
|
|
|
334
351
|
* Gets the underlying {@link @fluidframework/container-definitions#IContainer}.
|
|
335
352
|
*
|
|
336
353
|
* @remarks Used to power debug tooling.
|
|
337
|
-
*
|
|
338
|
-
* @internal
|
|
339
354
|
*/
|
|
340
355
|
public readonly INTERNAL_CONTAINER_DO_NOT_USE?: () => IContainer = () => {
|
|
341
356
|
return this.container;
|
package/src/index.ts
CHANGED
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
export {
|
|
13
|
-
|
|
13
|
+
createFluidContainer,
|
|
14
14
|
IFluidContainer,
|
|
15
15
|
IFluidContainerEvents,
|
|
16
16
|
InitialObjects,
|
|
17
17
|
} from "./fluidContainer";
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
18
|
+
export { createDOProviderContainerRuntimeFactory } from "./rootDataObject";
|
|
19
|
+
export { createServiceAudience } from "./serviceAudience";
|
|
20
20
|
export {
|
|
21
21
|
ContainerSchema,
|
|
22
22
|
DataObjectClass,
|
|
@@ -32,4 +32,5 @@ export {
|
|
|
32
32
|
MemberChangedListener,
|
|
33
33
|
Myself,
|
|
34
34
|
SharedObjectClass,
|
|
35
|
+
IProvideRootDataObject,
|
|
35
36
|
} from "./types";
|
package/src/rootDataObject.ts
CHANGED
|
@@ -6,22 +6,27 @@ import {
|
|
|
6
6
|
BaseContainerRuntimeFactory,
|
|
7
7
|
DataObject,
|
|
8
8
|
DataObjectFactory,
|
|
9
|
-
// eslint-disable-next-line import/no-deprecated
|
|
10
|
-
defaultRouteRequestHandler,
|
|
11
9
|
} from "@fluidframework/aqueduct";
|
|
12
10
|
import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
|
|
13
|
-
import { IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
11
|
+
import { IFluidLoadable, IRequest } from "@fluidframework/core-interfaces";
|
|
14
12
|
import { FlushMode } from "@fluidframework/runtime-definitions";
|
|
13
|
+
import { IRuntimeFactory } from "@fluidframework/container-definitions";
|
|
14
|
+
import { RequestParser } from "@fluidframework/runtime-utils";
|
|
15
|
+
import { ContainerRuntime } from "@fluidframework/container-runtime";
|
|
15
16
|
import {
|
|
16
17
|
ContainerSchema,
|
|
17
|
-
DataObjectClass,
|
|
18
18
|
IRootDataObject,
|
|
19
19
|
LoadableObjectClass,
|
|
20
20
|
LoadableObjectClassRecord,
|
|
21
21
|
LoadableObjectRecord,
|
|
22
22
|
SharedObjectClass,
|
|
23
23
|
} from "./types";
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
InternalDataObjectClass,
|
|
26
|
+
isDataObjectClass,
|
|
27
|
+
isSharedObjectClass,
|
|
28
|
+
parseDataObjectsFromSharedObjects,
|
|
29
|
+
} from "./utils";
|
|
25
30
|
|
|
26
31
|
/**
|
|
27
32
|
* Input props for {@link RootDataObject.initializingFirstTime}.
|
|
@@ -39,12 +44,15 @@ export interface RootDataObjectProps {
|
|
|
39
44
|
* The entry-point/root collaborative object of the {@link IFluidContainer | Fluid Container}.
|
|
40
45
|
* Abstracts the dynamic code required to build a Fluid Container into a static representation for end customers.
|
|
41
46
|
*/
|
|
42
|
-
|
|
47
|
+
class RootDataObject
|
|
43
48
|
extends DataObject<{ InitialState: RootDataObjectProps }>
|
|
44
49
|
implements IRootDataObject
|
|
45
50
|
{
|
|
46
51
|
private readonly initialObjectsDirKey = "initial-objects-key";
|
|
47
52
|
private readonly _initialObjects: LoadableObjectRecord = {};
|
|
53
|
+
public get IRootDataObject() {
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
48
56
|
|
|
49
57
|
private get initialObjectsDir() {
|
|
50
58
|
const dir = this.root.getSubDirectory(this.initialObjectsDirKey);
|
|
@@ -119,7 +127,7 @@ export class RootDataObject
|
|
|
119
127
|
}
|
|
120
128
|
|
|
121
129
|
private async createDataObject<T extends IFluidLoadable>(
|
|
122
|
-
dataObjectClass:
|
|
130
|
+
dataObjectClass: InternalDataObjectClass<T>,
|
|
123
131
|
): Promise<T> {
|
|
124
132
|
const factory = dataObjectClass.factory;
|
|
125
133
|
const packagePath = [...this.context.packagePath, factory.type];
|
|
@@ -139,6 +147,15 @@ export class RootDataObject
|
|
|
139
147
|
|
|
140
148
|
const rootDataStoreId = "rootDOId";
|
|
141
149
|
|
|
150
|
+
/**
|
|
151
|
+
* @internal
|
|
152
|
+
*/
|
|
153
|
+
export function createDOProviderContainerRuntimeFactory(props: {
|
|
154
|
+
schema: ContainerSchema;
|
|
155
|
+
}): IRuntimeFactory {
|
|
156
|
+
return new DOProviderContainerRuntimeFactory(props.schema);
|
|
157
|
+
}
|
|
158
|
+
|
|
142
159
|
/**
|
|
143
160
|
* Container code that provides a single {@link IRootDataObject}.
|
|
144
161
|
*
|
|
@@ -146,8 +163,10 @@ const rootDataStoreId = "rootDOId";
|
|
|
146
163
|
*
|
|
147
164
|
* This data object is dynamically customized (registry and initial objects) based on the schema provided.
|
|
148
165
|
* to the container runtime factory.
|
|
166
|
+
*
|
|
167
|
+
* @internal
|
|
149
168
|
*/
|
|
150
|
-
|
|
169
|
+
class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
151
170
|
private readonly rootDataObjectFactory: DataObjectFactory<
|
|
152
171
|
RootDataObject,
|
|
153
172
|
{
|
|
@@ -166,21 +185,32 @@ export class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFacto
|
|
|
166
185
|
{},
|
|
167
186
|
registryEntries,
|
|
168
187
|
);
|
|
188
|
+
const provideEntryPoint = async (containerRuntime: IContainerRuntime) => {
|
|
189
|
+
const entryPoint =
|
|
190
|
+
await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);
|
|
191
|
+
if (entryPoint === undefined) {
|
|
192
|
+
throw new Error(`default dataStore [${rootDataStoreId}] must exist`);
|
|
193
|
+
}
|
|
194
|
+
return entryPoint.get();
|
|
195
|
+
};
|
|
196
|
+
const getDefaultObject = async (request: IRequest, runtime: IContainerRuntime) => {
|
|
197
|
+
const parser = RequestParser.create(request);
|
|
198
|
+
if (parser.pathParts.length === 0) {
|
|
199
|
+
// This cast is safe as ContainerRuntime.loadRuntime is called in the base class
|
|
200
|
+
return (runtime as ContainerRuntime).resolveHandle({
|
|
201
|
+
url: `/${rootDataStoreId}${parser.query}`,
|
|
202
|
+
headers: request.headers,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return undefined; // continue search
|
|
206
|
+
};
|
|
169
207
|
super({
|
|
170
208
|
registryEntries: [rootDataObjectFactory.registryEntry],
|
|
171
|
-
|
|
172
|
-
requestHandlers: [defaultRouteRequestHandler(rootDataStoreId)],
|
|
209
|
+
requestHandlers: [getDefaultObject],
|
|
173
210
|
// temporary workaround to disable message batching until the message batch size issue is resolved
|
|
174
211
|
// resolution progress is tracked by the Feature 465 work item in AzDO
|
|
175
212
|
runtimeOptions: { flushMode: FlushMode.Immediate },
|
|
176
|
-
provideEntryPoint
|
|
177
|
-
const entryPoint =
|
|
178
|
-
await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);
|
|
179
|
-
if (entryPoint === undefined) {
|
|
180
|
-
throw new Error(`default dataStore [${rootDataStoreId}] must exist`);
|
|
181
|
-
}
|
|
182
|
-
return entryPoint.get();
|
|
183
|
-
},
|
|
213
|
+
provideEntryPoint,
|
|
184
214
|
});
|
|
185
215
|
this.rootDataObjectFactory = rootDataObjectFactory;
|
|
186
216
|
this.initialObjects = schema.initialObjects;
|