@fluidframework/fluid-static 2.0.0-internal.7.4.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 +16 -0
- package/api-report/fluid-static.api.md +4 -43
- package/dist/fluid-static-alpha.d.ts +3 -12
- package/dist/fluid-static-beta.d.ts +0 -21
- package/dist/fluid-static-public.d.ts +0 -21
- package/dist/fluid-static-untrimmed.d.ts +4 -175
- package/dist/fluidContainer.cjs +1 -2
- package/dist/fluidContainer.cjs.map +1 -1
- package/dist/fluidContainer.d.ts +0 -84
- package/dist/fluidContainer.d.ts.map +1 -1
- package/dist/index.cjs +1 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/rootDataObject.cjs +23 -12
- package/dist/rootDataObject.cjs.map +1 -1
- package/dist/rootDataObject.d.ts +0 -25
- package/dist/rootDataObject.d.ts.map +1 -1
- package/dist/serviceAudience.cjs +4 -11
- package/dist/serviceAudience.cjs.map +1 -1
- package/dist/serviceAudience.d.ts +2 -70
- package/dist/serviceAudience.d.ts.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +4 -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 +3 -12
- package/lib/fluid-static-beta.d.ts +0 -21
- package/lib/fluid-static-public.d.ts +0 -21
- package/lib/fluid-static-untrimmed.d.ts +4 -175
- package/lib/fluidContainer.d.ts +0 -80
- package/lib/fluidContainer.d.ts.map +1 -1
- package/lib/fluidContainer.mjs +1 -1
- package/lib/fluidContainer.mjs.map +1 -1
- package/lib/index.d.ts +3 -3
- 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 +0 -21
- package/lib/rootDataObject.d.ts.map +1 -1
- package/lib/rootDataObject.mjs +25 -15
- package/lib/rootDataObject.mjs.map +1 -1
- package/lib/serviceAudience.d.ts +2 -70
- package/lib/serviceAudience.d.ts.map +1 -1
- package/lib/serviceAudience.mjs +4 -10
- package/lib/serviceAudience.mjs.map +1 -1
- package/lib/types.d.ts +4 -3
- package/lib/types.d.ts.map +1 -1
- package/lib/types.mjs.map +1 -1
- package/lib/utils.d.ts +10 -2
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.mjs +3 -1
- package/lib/utils.mjs.map +1 -1
- package/package.json +32 -15
- package/src/fluidContainer.ts +1 -1
- package/src/index.ts +2 -6
- package/src/rootDataObject.ts +33 -18
- package/src/serviceAudience.ts +7 -20
- package/src/types.ts +2 -3
- package/src/utils.ts +20 -3
package/src/index.ts
CHANGED
|
@@ -10,17 +10,13 @@
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
export {
|
|
13
|
-
FluidContainer,
|
|
14
13
|
createFluidContainer,
|
|
15
14
|
IFluidContainer,
|
|
16
15
|
IFluidContainerEvents,
|
|
17
16
|
InitialObjects,
|
|
18
17
|
} from "./fluidContainer";
|
|
19
|
-
export {
|
|
20
|
-
|
|
21
|
-
createDOProviderContainerRuntimeFactory,
|
|
22
|
-
} from "./rootDataObject";
|
|
23
|
-
export { ServiceAudience, createServiceAudience } from "./serviceAudience";
|
|
18
|
+
export { createDOProviderContainerRuntimeFactory } from "./rootDataObject";
|
|
19
|
+
export { createServiceAudience } from "./serviceAudience";
|
|
24
20
|
export {
|
|
25
21
|
ContainerSchema,
|
|
26
22
|
DataObjectClass,
|
package/src/rootDataObject.ts
CHANGED
|
@@ -6,23 +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";
|
|
15
13
|
import { IRuntimeFactory } from "@fluidframework/container-definitions";
|
|
14
|
+
import { RequestParser } from "@fluidframework/runtime-utils";
|
|
15
|
+
import { ContainerRuntime } from "@fluidframework/container-runtime";
|
|
16
16
|
import {
|
|
17
17
|
ContainerSchema,
|
|
18
|
-
DataObjectClass,
|
|
19
18
|
IRootDataObject,
|
|
20
19
|
LoadableObjectClass,
|
|
21
20
|
LoadableObjectClassRecord,
|
|
22
21
|
LoadableObjectRecord,
|
|
23
22
|
SharedObjectClass,
|
|
24
23
|
} from "./types";
|
|
25
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
InternalDataObjectClass,
|
|
26
|
+
isDataObjectClass,
|
|
27
|
+
isSharedObjectClass,
|
|
28
|
+
parseDataObjectsFromSharedObjects,
|
|
29
|
+
} from "./utils";
|
|
26
30
|
|
|
27
31
|
/**
|
|
28
32
|
* Input props for {@link RootDataObject.initializingFirstTime}.
|
|
@@ -123,7 +127,7 @@ class RootDataObject
|
|
|
123
127
|
}
|
|
124
128
|
|
|
125
129
|
private async createDataObject<T extends IFluidLoadable>(
|
|
126
|
-
dataObjectClass:
|
|
130
|
+
dataObjectClass: InternalDataObjectClass<T>,
|
|
127
131
|
): Promise<T> {
|
|
128
132
|
const factory = dataObjectClass.factory;
|
|
129
133
|
const packagePath = [...this.context.packagePath, factory.type];
|
|
@@ -159,10 +163,10 @@ export function createDOProviderContainerRuntimeFactory(props: {
|
|
|
159
163
|
*
|
|
160
164
|
* This data object is dynamically customized (registry and initial objects) based on the schema provided.
|
|
161
165
|
* to the container runtime factory.
|
|
162
|
-
*
|
|
166
|
+
*
|
|
163
167
|
* @internal
|
|
164
168
|
*/
|
|
165
|
-
|
|
169
|
+
class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFactory {
|
|
166
170
|
private readonly rootDataObjectFactory: DataObjectFactory<
|
|
167
171
|
RootDataObject,
|
|
168
172
|
{
|
|
@@ -181,21 +185,32 @@ export class DOProviderContainerRuntimeFactory extends BaseContainerRuntimeFacto
|
|
|
181
185
|
{},
|
|
182
186
|
registryEntries,
|
|
183
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
|
+
};
|
|
184
207
|
super({
|
|
185
208
|
registryEntries: [rootDataObjectFactory.registryEntry],
|
|
186
|
-
|
|
187
|
-
requestHandlers: [defaultRouteRequestHandler(rootDataStoreId)],
|
|
209
|
+
requestHandlers: [getDefaultObject],
|
|
188
210
|
// temporary workaround to disable message batching until the message batch size issue is resolved
|
|
189
211
|
// resolution progress is tracked by the Feature 465 work item in AzDO
|
|
190
212
|
runtimeOptions: { flushMode: FlushMode.Immediate },
|
|
191
|
-
provideEntryPoint
|
|
192
|
-
const entryPoint =
|
|
193
|
-
await containerRuntime.getAliasedDataStoreEntryPoint(rootDataStoreId);
|
|
194
|
-
if (entryPoint === undefined) {
|
|
195
|
-
throw new Error(`default dataStore [${rootDataStoreId}] must exist`);
|
|
196
|
-
}
|
|
197
|
-
return entryPoint.get();
|
|
198
|
-
},
|
|
213
|
+
provideEntryPoint,
|
|
199
214
|
});
|
|
200
215
|
this.rootDataObjectFactory = rootDataObjectFactory;
|
|
201
216
|
this.initialObjects = schema.initialObjects;
|
package/src/serviceAudience.ts
CHANGED
|
@@ -15,13 +15,7 @@ export function createServiceAudience<M extends IMember = IMember>(props: {
|
|
|
15
15
|
container: IContainer;
|
|
16
16
|
createServiceMember: (audienceMember: IClient) => M;
|
|
17
17
|
}): IServiceAudience<M> {
|
|
18
|
-
|
|
19
|
-
const c = class NewServiceAudience extends ServiceAudience<M> {
|
|
20
|
-
protected createServiceMember(audienceMember: IClient) {
|
|
21
|
-
return props.createServiceMember(audienceMember);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
return new c(props.container);
|
|
18
|
+
return new ServiceAudience(props.container, props.createServiceMember);
|
|
25
19
|
}
|
|
26
20
|
|
|
27
21
|
/**
|
|
@@ -33,17 +27,16 @@ export function createServiceAudience<M extends IMember = IMember>(props: {
|
|
|
33
27
|
* the user and client details returned in {@link IMember}.
|
|
34
28
|
*
|
|
35
29
|
* @typeParam M - A service-specific {@link IMember} implementation.
|
|
36
|
-
* @deprecated use {@link createServiceAudience} and {@link IServiceAudience} instead
|
|
37
30
|
* @internal
|
|
38
31
|
*/
|
|
39
|
-
|
|
32
|
+
class ServiceAudience<M extends IMember = IMember>
|
|
40
33
|
extends TypedEventEmitter<IServiceAudienceEvents<M>>
|
|
41
34
|
implements IServiceAudience<M>
|
|
42
35
|
{
|
|
43
36
|
/**
|
|
44
37
|
* Audience object which includes all the existing members of the {@link IFluidContainer | container}.
|
|
45
38
|
*/
|
|
46
|
-
|
|
39
|
+
private readonly audience: IAudience;
|
|
47
40
|
|
|
48
41
|
/**
|
|
49
42
|
* Retain the most recent member list.
|
|
@@ -62,13 +55,14 @@ export abstract class ServiceAudience<M extends IMember = IMember>
|
|
|
62
55
|
* every `addMember` event. It is mapped `clientId` to `M` to be better work with what the {@link IServiceAudience}
|
|
63
56
|
* events provide.
|
|
64
57
|
*/
|
|
65
|
-
|
|
58
|
+
private lastMembers = new Map<string, M>();
|
|
66
59
|
|
|
67
60
|
constructor(
|
|
68
61
|
/**
|
|
69
62
|
* Fluid Container to read the audience from.
|
|
70
63
|
*/
|
|
71
|
-
|
|
64
|
+
private readonly container: IContainer,
|
|
65
|
+
private readonly createServiceMember: (audienceMember: IClient) => M,
|
|
72
66
|
) {
|
|
73
67
|
super();
|
|
74
68
|
this.audience = container.audience;
|
|
@@ -95,13 +89,6 @@ export abstract class ServiceAudience<M extends IMember = IMember>
|
|
|
95
89
|
this.container.on("connected", () => this.emit("membersChanged"));
|
|
96
90
|
}
|
|
97
91
|
|
|
98
|
-
/**
|
|
99
|
-
* Provides ability for inheriting class to modify/extend the audience object.
|
|
100
|
-
*
|
|
101
|
-
* @param audienceMember - Record of a specific audience member.
|
|
102
|
-
*/
|
|
103
|
-
protected abstract createServiceMember(audienceMember: IClient): M;
|
|
104
|
-
|
|
105
92
|
/**
|
|
106
93
|
* {@inheritDoc IServiceAudience.getMembers}
|
|
107
94
|
*/
|
|
@@ -170,7 +157,7 @@ export abstract class ServiceAudience<M extends IMember = IMember>
|
|
|
170
157
|
*
|
|
171
158
|
* @param member - Member to be included/omitted.
|
|
172
159
|
*/
|
|
173
|
-
|
|
160
|
+
private shouldIncludeAsMember(member: IClient): boolean {
|
|
174
161
|
// Include only human members
|
|
175
162
|
return member.details.capabilities.interactive;
|
|
176
163
|
}
|
package/src/types.ts
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
import { IEvent, IEventProvider, IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
8
|
-
import { IFluidDataStoreFactory } from "@fluidframework/runtime-definitions";
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* A mapping of string identifiers to instantiated `DataObject`s or `SharedObject`s.
|
|
@@ -38,7 +37,7 @@ export type LoadableObjectClass<T extends IFluidLoadable> =
|
|
|
38
37
|
* @alpha
|
|
39
38
|
*/
|
|
40
39
|
export type DataObjectClass<T extends IFluidLoadable> = {
|
|
41
|
-
readonly factory: IFluidDataStoreFactory;
|
|
40
|
+
readonly factory: { IFluidDataStoreFactory: DataObjectClass<T>["factory"] };
|
|
42
41
|
} & LoadableObjectCtor<T>;
|
|
43
42
|
|
|
44
43
|
/**
|
|
@@ -107,7 +106,7 @@ export interface ContainerSchema {
|
|
|
107
106
|
* @internal
|
|
108
107
|
*/
|
|
109
108
|
export interface IProvideRootDataObject {
|
|
110
|
-
readonly IRootDataObject
|
|
109
|
+
readonly IRootDataObject: IRootDataObject;
|
|
111
110
|
}
|
|
112
111
|
|
|
113
112
|
/**
|
package/src/utils.ts
CHANGED
|
@@ -4,14 +4,31 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { IChannelFactory } from "@fluidframework/datastore-definitions";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
IFluidDataStoreFactory,
|
|
9
|
+
NamedFluidDataStoreRegistryEntry,
|
|
10
|
+
} from "@fluidframework/runtime-definitions";
|
|
11
|
+
import { IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
8
12
|
import { ContainerSchema, DataObjectClass, LoadableObjectClass, SharedObjectClass } from "./types";
|
|
9
13
|
|
|
14
|
+
/**
|
|
15
|
+
* An internal type used by the internal type guard isDataObjectClass to cast a
|
|
16
|
+
* DataObjectClass to a type that is strongly coupled to IFluidDataStoreFactory.
|
|
17
|
+
* Unlike the external and exported type DataObjectClass which is
|
|
18
|
+
* weakly coupled to the IFluidDataStoreFactory to prevent leaking internals.
|
|
19
|
+
*/
|
|
20
|
+
export type InternalDataObjectClass<T extends IFluidLoadable> = DataObjectClass<T> &
|
|
21
|
+
Record<"factory", IFluidDataStoreFactory>;
|
|
22
|
+
|
|
10
23
|
/**
|
|
11
24
|
* Runtime check to determine if a class is a DataObject type
|
|
12
25
|
*/
|
|
13
|
-
export const isDataObjectClass = (obj: any): obj is
|
|
14
|
-
|
|
26
|
+
export const isDataObjectClass = (obj: any): obj is InternalDataObjectClass<IFluidLoadable> => {
|
|
27
|
+
const maybe: Partial<InternalDataObjectClass<IFluidLoadable>> | undefined = obj;
|
|
28
|
+
return (
|
|
29
|
+
maybe?.factory?.IFluidDataStoreFactory !== undefined &&
|
|
30
|
+
maybe?.factory?.IFluidDataStoreFactory === maybe?.factory
|
|
31
|
+
);
|
|
15
32
|
};
|
|
16
33
|
|
|
17
34
|
/**
|