@fluidframework/shared-object-base 2.113.0-411909 → 2.114.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 +73 -0
- package/dist/dataStoreKind.d.ts +118 -0
- package/dist/dataStoreKind.d.ts.map +1 -0
- package/dist/dataStoreKind.js +137 -0
- package/dist/dataStoreKind.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/sharedObject.d.ts +35 -1
- package/dist/sharedObject.d.ts.map +1 -1
- package/dist/sharedObject.js +27 -3
- package/dist/sharedObject.js.map +1 -1
- package/dist/sharedObjectKernel.d.ts +2 -2
- package/dist/sharedObjectKernel.d.ts.map +1 -1
- package/dist/sharedObjectKernel.js +1 -1
- package/dist/sharedObjectKernel.js.map +1 -1
- package/dist/stubSharedObject.d.ts +13 -0
- package/dist/stubSharedObject.d.ts.map +1 -0
- package/dist/stubSharedObject.js +58 -0
- package/dist/stubSharedObject.js.map +1 -0
- package/lib/dataStoreKind.d.ts +118 -0
- package/lib/dataStoreKind.d.ts.map +1 -0
- package/lib/dataStoreKind.js +132 -0
- package/lib/dataStoreKind.js.map +1 -0
- package/lib/index.d.ts +4 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/sharedObject.d.ts +35 -1
- package/lib/sharedObject.d.ts.map +1 -1
- package/lib/sharedObject.js +25 -2
- package/lib/sharedObject.js.map +1 -1
- package/lib/sharedObjectKernel.d.ts +2 -2
- package/lib/sharedObjectKernel.d.ts.map +1 -1
- package/lib/sharedObjectKernel.js +2 -2
- package/lib/sharedObjectKernel.js.map +1 -1
- package/lib/stubSharedObject.d.ts +13 -0
- package/lib/stubSharedObject.d.ts.map +1 -0
- package/lib/stubSharedObject.js +54 -0
- package/lib/stubSharedObject.js.map +1 -0
- package/package.json +20 -20
- package/src/dataStoreKind.ts +301 -0
- package/src/index.ts +11 -0
- package/src/packageVersion.ts +1 -1
- package/src/sharedObject.ts +60 -2
- package/src/sharedObjectKernel.ts +4 -4
- package/src/stubSharedObject.ts +66 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { IFluidLoadable } from "@fluidframework/core-interfaces";
|
|
6
|
+
import { type Registry, type DataStoreKind } from "@fluidframework/driver-definitions/internal";
|
|
7
|
+
import type { SharedObjectKey, SharedObjectKindAlpha } from "./sharedObject.js";
|
|
8
|
+
/**
|
|
9
|
+
* This file provides the implementation of {@link @fluidframework/driver-definitions#DataStoreKind}
|
|
10
|
+
* and is therefore a key part of the implementation of the {@link @fluidframework/driver-definitions#ServiceClient} API surface.
|
|
11
|
+
*
|
|
12
|
+
* Note that much of the API surface beyond {@link defineDataStore} could be removed/deduplicated
|
|
13
|
+
* if the unification noted in the TODOs in {@link SharedObjectRegistry} is implemented.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* A {@link @fluidframework/driver-definitions#Registry} of shared object kinds that can be created or loaded within a data store.
|
|
17
|
+
* @remarks
|
|
18
|
+
* Supports lazy code loading in a limited way (a single lazy load per registry).
|
|
19
|
+
* @privateRemarks
|
|
20
|
+
* TODO: The framework provided SharedObjects should be exposed in a way indistinguishable from custom sub-data stores.
|
|
21
|
+
* This can be done by unifying the DataStoreKind and SharedObjectKindAlpha types.
|
|
22
|
+
* For now, this would mean having DataStoreKind extend SharedObjectKindAlpha, since we can allow a data store in all places SharedObjects are allowed,
|
|
23
|
+
* but do not allow SharedObjects at the root.
|
|
24
|
+
* Fixing this, and allowing shared objects at the root (maybe use a trivial wrapper data store) could simplify things, allowing data stores and Containers to share some types (like how they create detached contents, have registries, have a root etc).
|
|
25
|
+
*
|
|
26
|
+
* Part of this unification could be to relax the output from the factories / registries. Allowing the output to be an arbitrary type, which might be a promise, and might not be one could help.
|
|
27
|
+
* Removal of the IFluidLoadable requirement, and allowing the returned type to expose handles to itself however it wants (or not at all) might be viable and simplify typing and allow for strongly typed handles at creation time at least).
|
|
28
|
+
* Maybe when Registry(type) gives a promise, it could instead give a factory which outputs a promise wrapped type? The check that the provided creation key is valid for that factory can be deferred until the promise resolves.
|
|
29
|
+
*
|
|
30
|
+
* Idea: creation key can have an interface that subsets the factory / SharedObjectKindAlpha / DataStoreKind so they can be used, or some branded key (string, and/or object with stronger identity what knows the type string) can be used.
|
|
31
|
+
* Have Key interface contain validation function to check that the factory used (or maybe the value produced from it) is valid for that key.
|
|
32
|
+
* During load, validation would simply check the factory's type string matches the key's type string.
|
|
33
|
+
* When using SharedObjectKindAlpha or DataStoreKind, validation can check factory object identity against key.
|
|
34
|
+
*
|
|
35
|
+
* Goal: Mostly unify container, data store and shared object abstractions.
|
|
36
|
+
* Maybe unify a bit with service client since it also has a way to create detached things with an initialized root then attach them.
|
|
37
|
+
* SharedObjects are just built in leaf data stores.
|
|
38
|
+
*
|
|
39
|
+
* @input
|
|
40
|
+
* @alpha
|
|
41
|
+
*/
|
|
42
|
+
export type SharedObjectRegistry = () => Promise<Registry<SharedObjectKindAlpha<IFluidLoadable>>>;
|
|
43
|
+
/**
|
|
44
|
+
* Creates a {@link SharedObjectRegistry} from an iterable of {@link SharedObjectKindAlpha}s or async getters for them.
|
|
45
|
+
* @alpha
|
|
46
|
+
*/
|
|
47
|
+
export declare function sharedObjectRegistryFromIterable(entries: Iterable<SharedObjectKindAlpha<IFluidLoadable> | {
|
|
48
|
+
type: string;
|
|
49
|
+
kind: () => Promise<SharedObjectKindAlpha<IFluidLoadable>>;
|
|
50
|
+
}>): SharedObjectRegistry;
|
|
51
|
+
/**
|
|
52
|
+
* Options which define how to construct a particular {@link @fluidframework/driver-definitions#DataStoreKind}.
|
|
53
|
+
* @remarks
|
|
54
|
+
* Use {@link defineDataStore} to create a {@link @fluidframework/driver-definitions#DataStoreKind} from these options.
|
|
55
|
+
* @input
|
|
56
|
+
* @alpha
|
|
57
|
+
*/
|
|
58
|
+
export interface DataStoreOptions<in out TRoot extends IFluidLoadable, out TOutput> {
|
|
59
|
+
/**
|
|
60
|
+
* The type identifier for the data object factory.
|
|
61
|
+
* @remarks
|
|
62
|
+
* Persisted identifier which specifies which {@link @fluidframework/driver-definitions#DataStoreKind} to use when loading it.
|
|
63
|
+
* @privateRemarks
|
|
64
|
+
* Equivalent to `DataObjectFactoryProps.type`.
|
|
65
|
+
*/
|
|
66
|
+
readonly type: string;
|
|
67
|
+
/**
|
|
68
|
+
* The registry of shared object kinds (including other data stores) that can be loaded or created within this data store.
|
|
69
|
+
*
|
|
70
|
+
* TODO: actually allow this to contain data stores.
|
|
71
|
+
*/
|
|
72
|
+
readonly registry: SharedObjectRegistry;
|
|
73
|
+
/**
|
|
74
|
+
* Create the initial content of the data store, and return the root shared object.
|
|
75
|
+
* @privateRemarks
|
|
76
|
+
* TODO:
|
|
77
|
+
* This requires the caller to produce a single root shared object (which is keyed by {@link rootSharedObjectId}).
|
|
78
|
+
* This should be fine for new code, but code migrated from legacy APIs might need more flexibility.
|
|
79
|
+
* Such use-cases could be accommodated providing a legacy alternative to `defineDataStore` where `instantiateFirstTime` and `view` directly expose access to named root shared objects.
|
|
80
|
+
* This should be easy to implement, but is currently not included.
|
|
81
|
+
*/
|
|
82
|
+
instantiateFirstTime(rootCreator: SharedObjectCreator<TRoot>, context: DataStoreContext): Promise<TRoot>;
|
|
83
|
+
/**
|
|
84
|
+
* Construct a view of the data store's root shared object.
|
|
85
|
+
*
|
|
86
|
+
* @param root - The root shared object of the data store, created by `instantiateFirstTime` (though possibly created by another client and loaded by this one).
|
|
87
|
+
* @param context - A {@link DataStoreContext} that can be used to create additional shared objects.
|
|
88
|
+
*/
|
|
89
|
+
view(root: TRoot, context: DataStoreContext): Promise<TOutput>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Creates a {@link @fluidframework/driver-definitions#DataStoreKind} from {@link DataStoreOptions}.
|
|
93
|
+
* @alpha
|
|
94
|
+
*/
|
|
95
|
+
export declare function defineDataStore<T, TRoot extends IFluidLoadable>(options: DataStoreOptions<TRoot, T>): DataStoreKind<T>;
|
|
96
|
+
/**
|
|
97
|
+
* Creates instances of SharedObjectKinds.
|
|
98
|
+
* @privateRemarks
|
|
99
|
+
* See IFluidContainer.create.
|
|
100
|
+
* @sealed
|
|
101
|
+
* @alpha
|
|
102
|
+
*/
|
|
103
|
+
export interface SharedObjectCreator<TConstraint = IFluidLoadable> {
|
|
104
|
+
/**
|
|
105
|
+
* Create an instance of `kind`, which must be registered in the registry of the surrounding data store.
|
|
106
|
+
*/
|
|
107
|
+
createSharedObject<T extends TConstraint>(kind: SharedObjectKey<T>): Promise<T>;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Contextual information about a data store which is provided when instantiating or loading it.
|
|
111
|
+
* @privateRemarks
|
|
112
|
+
* TODO: this can expose more contextual information about the data store as needed.
|
|
113
|
+
* @sealed
|
|
114
|
+
* @alpha
|
|
115
|
+
*/
|
|
116
|
+
export interface DataStoreContext extends SharedObjectCreator {
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=dataStoreKind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataStoreKind.d.ts","sourceRoot":"","sources":["../src/dataStoreKind.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,iCAAiC,CAAC;AAMnF,OAAO,EACN,KAAK,QAAQ,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,CAAC,WAAW,GAAG,cAAc;IAChE;;OAEG;IACH,kBAAkB,CAAC,CAAC,SAAS,WAAW,EAAE,IAAI,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAChF;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAiB,SAAQ,mBAAmB;CAAG"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { FluidDataStoreRuntime, } from "@fluidframework/datastore/internal";
|
|
6
|
+
import { lookupInRegistry, } from "@fluidframework/driver-definitions/internal";
|
|
7
|
+
import { DataStoreKindImplementation } from "@fluidframework/runtime-utils/internal";
|
|
8
|
+
import { UsageError } from "@fluidframework/telemetry-utils/internal";
|
|
9
|
+
/**
|
|
10
|
+
* Creates a {@link SharedObjectRegistry} from an iterable of {@link SharedObjectKindAlpha}s or async getters for them.
|
|
11
|
+
* @alpha
|
|
12
|
+
*/
|
|
13
|
+
export function sharedObjectRegistryFromIterable(entries) {
|
|
14
|
+
return async () => {
|
|
15
|
+
const map = new Map();
|
|
16
|
+
for (const entry of entries) {
|
|
17
|
+
if ("kind" in entry) {
|
|
18
|
+
map.set(entry.type, await entry.kind());
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
map.set(asSharedObjectKind(entry).getFactory().type, entry);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return (type) => {
|
|
25
|
+
const entry = map.get(type);
|
|
26
|
+
if (entry === undefined) {
|
|
27
|
+
throw new UsageError(`Unknown shared object type: ${type}`);
|
|
28
|
+
}
|
|
29
|
+
return entry;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Creates a {@link @fluidframework/driver-definitions#DataStoreKind} from {@link DataStoreOptions}.
|
|
35
|
+
* @alpha
|
|
36
|
+
*/
|
|
37
|
+
export function defineDataStore(options) {
|
|
38
|
+
return new DataStoreKindImplementation({
|
|
39
|
+
type: options.type,
|
|
40
|
+
async instantiateDataStore(context, existing) {
|
|
41
|
+
return createDataStore(context, existing, options);
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Casts a {@link SharedObjectKindAlpha} to its encapsulated {@link ISharedObjectKind} view.
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
* {@link SharedObjectKindAlpha} is a sealed type,
|
|
50
|
+
* so we can assume it implements {@link ISharedObjectKind} and down cast to it.
|
|
51
|
+
*/
|
|
52
|
+
function asSharedObjectKind(kind) {
|
|
53
|
+
const candidate = kind;
|
|
54
|
+
// Sanity check to help catch misuse since SharedObjectKindAlpha is typed structurally and seems implementable.
|
|
55
|
+
if (typeof candidate.getFactory !== "function" || typeof candidate.create !== "function") {
|
|
56
|
+
throw new UsageError("Invalid SharedObjectKindAlpha: this type is sealed and may not have custom implementations.");
|
|
57
|
+
}
|
|
58
|
+
return candidate;
|
|
59
|
+
}
|
|
60
|
+
function convertRegistry(lookup) {
|
|
61
|
+
return {
|
|
62
|
+
get: (type) => {
|
|
63
|
+
const entry = lookup(type);
|
|
64
|
+
return asSharedObjectKind(entry).getFactory();
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Data stores keep their shared objects inside channels which get names.
|
|
70
|
+
* This is the name of the channel which we conventionally use for the root shared object of a data store in most cases.
|
|
71
|
+
* @remarks
|
|
72
|
+
* There can be other named channels, or the root could use a different name, but we are trying to migrate away from such patterns.
|
|
73
|
+
* Currently the DataStoreKind pattern used in this file follows and requires this convention,
|
|
74
|
+
* but we may relax that in the future for interop with legacy data if necessary.
|
|
75
|
+
*/
|
|
76
|
+
const rootSharedObjectId = "root";
|
|
77
|
+
/**
|
|
78
|
+
* Creates a data store channel.
|
|
79
|
+
* @param context - The data store context.
|
|
80
|
+
* @param existing - Whether the data store already exists. When true, this loads it, when false a new one is created.
|
|
81
|
+
* @param options - The data store options.
|
|
82
|
+
* @returns A promise that resolves to the created data store channel.
|
|
83
|
+
* @remarks
|
|
84
|
+
* Currently this is limited to data stores which have a single named channel,
|
|
85
|
+
* which must have the {@link rootSharedObjectId} and is attached at creation time.
|
|
86
|
+
* This limitation may be relaxed in the future.
|
|
87
|
+
*/
|
|
88
|
+
async function createDataStore(context, existing, options) {
|
|
89
|
+
const sharedObjectRegistry = await options.registry();
|
|
90
|
+
const runtime = new FluidDataStoreRuntime(context, convertRegistry(sharedObjectRegistry), existing, async (runtimeInner) => {
|
|
91
|
+
const innerContext = {
|
|
92
|
+
async createSharedObject(key) {
|
|
93
|
+
const kind = lookupInRegistry(sharedObjectRegistry, key);
|
|
94
|
+
// Create detached channel.
|
|
95
|
+
return asSharedObjectKind(kind).create(runtimeInner);
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
let createdRoot;
|
|
99
|
+
const rootCreator = {
|
|
100
|
+
async createSharedObject(key) {
|
|
101
|
+
// Create named channel under the root id.
|
|
102
|
+
// Error if called twice.
|
|
103
|
+
if (createdRoot !== undefined) {
|
|
104
|
+
throw new UsageError("Root shared object already created");
|
|
105
|
+
}
|
|
106
|
+
const kind = lookupInRegistry(sharedObjectRegistry, key);
|
|
107
|
+
const result = asSharedObjectKind(kind).create(runtimeInner, rootSharedObjectId);
|
|
108
|
+
// Every shared object is also an ISharedObject;
|
|
109
|
+
const rootSharedObject = result;
|
|
110
|
+
// bind the newly created root so it becomes part of this data store.
|
|
111
|
+
rootSharedObject.bindToContext();
|
|
112
|
+
createdRoot = result;
|
|
113
|
+
return result;
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
let root;
|
|
117
|
+
if (existing) {
|
|
118
|
+
// getChannel returns the type-erased IChannel; the registered root kind guarantees it is a TRoot.
|
|
119
|
+
root = (await runtimeInner.getChannel(rootSharedObjectId));
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
root = await options.instantiateFirstTime(rootCreator, innerContext);
|
|
123
|
+
if (root !== createdRoot) {
|
|
124
|
+
throw new UsageError("instantiateFirstTime did not return root created with rootCreator");
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// view returns the data store's output type; the runtime only needs it as an opaque FluidObject entry point.
|
|
128
|
+
return (await options.view(root, innerContext));
|
|
129
|
+
});
|
|
130
|
+
return runtime;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=dataStoreKind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataStoreKind.js","sourceRoot":"","sources":["../src/dataStoreKind.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAEN,qBAAqB,GACrB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAGN,gBAAgB,GAChB,MAAM,6CAA6C,CAAC;AAKrD,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAgDtE;;;GAGG;AACH,MAAM,UAAU,gCAAgC,CAC/C,OAGC;IAED,OAAO,KAAK,IAAI,EAAE;QACjB,MAAM,GAAG,GAAG,IAAI,GAAG,EAAiD,CAAC;QACrE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;gBACrB,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;YACzC,CAAC;iBAAM,CAAC;gBACP,GAAG,CAAC,GAAG,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC7D,CAAC;QACF,CAAC;QACD,OAAO,CAAC,IAAY,EAAE,EAAE;YACvB,MAAM,KAAK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M,OAAO,CAAC,oBAAoB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;YACrE,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;gBAC1B,MAAM,IAAI,UAAU,CACnB,mEAAmE,CACnE,CAAC;YACH,CAAC;QACF,CAAC;QAED,6GAA6G;QAC7G,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAA2B,CAAC;IAC3E,CAAC,CACD,CAAC;IAEF,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IFluidLoadable, FluidObject } from \"@fluidframework/core-interfaces\";\nimport {\n\ttype ISharedObjectRegistry,\n\tFluidDataStoreRuntime,\n} from \"@fluidframework/datastore/internal\";\nimport type { IFluidDataStoreRuntime } from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\ttype Registry,\n\ttype DataStoreKind,\n\tlookupInRegistry,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tIFluidDataStoreContext,\n\tIFluidDataStoreChannel,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { DataStoreKindImplementation } from \"@fluidframework/runtime-utils/internal\";\nimport { UsageError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport type {\n\tISharedObjectKind,\n\tSharedObjectKey,\n\tSharedObjectKindAlpha,\n} from \"./sharedObject.js\";\nimport type { ISharedObject } from \"./types.js\";\n\n/**\n * This file provides the implementation of {@link @fluidframework/driver-definitions#DataStoreKind}\n * and is therefore a key part of the implementation of the {@link @fluidframework/driver-definitions#ServiceClient} API surface.\n *\n * Note that much of the API surface beyond {@link defineDataStore} could be removed/deduplicated\n * if the unification noted in the TODOs in {@link SharedObjectRegistry} is implemented.\n */\n\n/**\n * A {@link @fluidframework/driver-definitions#Registry} of shared object kinds that can be created or loaded within a data store.\n * @remarks\n * Supports lazy code loading in a limited way (a single lazy load per registry).\n * @privateRemarks\n * TODO: The framework provided SharedObjects should be exposed in a way indistinguishable from custom sub-data stores.\n * This can be done by unifying the DataStoreKind and SharedObjectKindAlpha types.\n * For now, this would mean having DataStoreKind extend SharedObjectKindAlpha, since we can allow a data store in all places SharedObjects are allowed,\n * but do not allow SharedObjects at the root.\n * Fixing this, and allowing shared objects at the root (maybe use a trivial wrapper data store) could simplify things, allowing data stores and Containers to share some types (like how they create detached contents, have registries, have a root etc).\n *\n * Part of this unification could be to relax the output from the factories / registries. Allowing the output to be an arbitrary type, which might be a promise, and might not be one could help.\n * Removal of the IFluidLoadable requirement, and allowing the returned type to expose handles to itself however it wants (or not at all) might be viable and simplify typing and allow for strongly typed handles at creation time at least).\n * Maybe when Registry(type) gives a promise, it could instead give a factory which outputs a promise wrapped type? The check that the provided creation key is valid for that factory can be deferred until the promise resolves.\n *\n * Idea: creation key can have an interface that subsets the factory / SharedObjectKindAlpha / DataStoreKind so they can be used, or some branded key (string, and/or object with stronger identity what knows the type string) can be used.\n * Have Key interface contain validation function to check that the factory used (or maybe the value produced from it) is valid for that key.\n * During load, validation would simply check the factory's type string matches the key's type string.\n * When using SharedObjectKindAlpha or DataStoreKind, validation can check factory object identity against key.\n *\n * Goal: Mostly unify container, data store and shared object abstractions.\n * Maybe unify a bit with service client since it also has a way to create detached things with an initialized root then attach them.\n * SharedObjects are just built in leaf data stores.\n *\n * @input\n * @alpha\n */\nexport type SharedObjectRegistry = () => Promise<\n\tRegistry<SharedObjectKindAlpha<IFluidLoadable>>\n>;\n\n/**\n * Creates a {@link SharedObjectRegistry} from an iterable of {@link SharedObjectKindAlpha}s or async getters for them.\n * @alpha\n */\nexport function sharedObjectRegistryFromIterable(\n\tentries: Iterable<\n\t\t| SharedObjectKindAlpha<IFluidLoadable>\n\t\t| { type: string; kind: () => Promise<SharedObjectKindAlpha<IFluidLoadable>> }\n\t>,\n): SharedObjectRegistry {\n\treturn async () => {\n\t\tconst map = new Map<string, SharedObjectKindAlpha<IFluidLoadable>>();\n\t\tfor (const entry of entries) {\n\t\t\tif (\"kind\" in entry) {\n\t\t\t\tmap.set(entry.type, await entry.kind());\n\t\t\t} else {\n\t\t\t\tmap.set(asSharedObjectKind(entry).getFactory().type, entry);\n\t\t\t}\n\t\t}\n\t\treturn (type: string) => {\n\t\t\tconst entry = map.get(type);\n\t\t\tif (entry === undefined) {\n\t\t\t\tthrow new UsageError(`Unknown shared object type: ${type}`);\n\t\t\t}\n\t\t\treturn entry;\n\t\t};\n\t};\n}\n\n/**\n * Options which define how to construct a particular {@link @fluidframework/driver-definitions#DataStoreKind}.\n * @remarks\n * Use {@link defineDataStore} to create a {@link @fluidframework/driver-definitions#DataStoreKind} from these options.\n * @input\n * @alpha\n */\nexport interface DataStoreOptions<in out TRoot extends IFluidLoadable, out TOutput> {\n\t/**\n\t * The type identifier for the data object factory.\n\t * @remarks\n\t * Persisted identifier which specifies which {@link @fluidframework/driver-definitions#DataStoreKind} to use when loading it.\n\t * @privateRemarks\n\t * Equivalent to `DataObjectFactoryProps.type`.\n\t */\n\treadonly type: string;\n\n\t/**\n\t * The registry of shared object kinds (including other data stores) that can be loaded or created within this data store.\n\t *\n\t * TODO: actually allow this to contain data stores.\n\t */\n\treadonly registry: SharedObjectRegistry;\n\n\t/**\n\t * Create the initial content of the data store, and return the root shared object.\n\t * @privateRemarks\n\t * TODO:\n\t * This requires the caller to produce a single root shared object (which is keyed by {@link rootSharedObjectId}).\n\t * This should be fine for new code, but code migrated from legacy APIs might need more flexibility.\n\t * Such use-cases could be accommodated providing a legacy alternative to `defineDataStore` where `instantiateFirstTime` and `view` directly expose access to named root shared objects.\n\t * This should be easy to implement, but is currently not included.\n\t */\n\tinstantiateFirstTime(\n\t\trootCreator: SharedObjectCreator<TRoot>,\n\t\tcontext: DataStoreContext,\n\t): Promise<TRoot>;\n\n\t/**\n\t * Construct a view of the data store's root shared object.\n\t *\n\t * @param root - The root shared object of the data store, created by `instantiateFirstTime` (though possibly created by another client and loaded by this one).\n\t * @param context - A {@link DataStoreContext} that can be used to create additional shared objects.\n\t */\n\tview(root: TRoot, context: DataStoreContext): Promise<TOutput>;\n}\n\n/**\n * Creates a {@link @fluidframework/driver-definitions#DataStoreKind} from {@link DataStoreOptions}.\n * @alpha\n */\nexport function defineDataStore<T, TRoot extends IFluidLoadable>(\n\toptions: DataStoreOptions<TRoot, T>,\n): DataStoreKind<T> {\n\treturn new DataStoreKindImplementation<T>({\n\t\ttype: options.type,\n\t\tasync instantiateDataStore(\n\t\t\tcontext: IFluidDataStoreContext,\n\t\t\texisting: boolean,\n\t\t): Promise<IFluidDataStoreChannel> {\n\t\t\treturn createDataStore(context, existing, options);\n\t\t},\n\t});\n}\n\n/**\n * Casts a {@link SharedObjectKindAlpha} to its encapsulated {@link ISharedObjectKind} view.\n *\n * @remarks\n * {@link SharedObjectKindAlpha} is a sealed type,\n * so we can assume it implements {@link ISharedObjectKind} and down cast to it.\n */\nfunction asSharedObjectKind<T extends IFluidLoadable>(\n\tkind: SharedObjectKindAlpha<T>,\n): ISharedObjectKind<T> {\n\tconst candidate = kind as unknown as Partial<ISharedObjectKind<T>>;\n\t// Sanity check to help catch misuse since SharedObjectKindAlpha is typed structurally and seems implementable.\n\tif (typeof candidate.getFactory !== \"function\" || typeof candidate.create !== \"function\") {\n\t\tthrow new UsageError(\n\t\t\t\"Invalid SharedObjectKindAlpha: this type is sealed and may not have custom implementations.\",\n\t\t);\n\t}\n\treturn candidate as ISharedObjectKind<T>;\n}\n\nfunction convertRegistry(\n\tlookup: Registry<SharedObjectKindAlpha<IFluidLoadable>>,\n): ISharedObjectRegistry {\n\treturn {\n\t\tget: (type: string) => {\n\t\t\tconst entry = lookup(type);\n\t\t\treturn asSharedObjectKind(entry).getFactory();\n\t\t},\n\t};\n}\n\n/**\n * Data stores keep their shared objects inside channels which get names.\n * This is the name of the channel which we conventionally use for the root shared object of a data store in most cases.\n * @remarks\n * There can be other named channels, or the root could use a different name, but we are trying to migrate away from such patterns.\n * Currently the DataStoreKind pattern used in this file follows and requires this convention,\n * but we may relax that in the future for interop with legacy data if necessary.\n */\nconst rootSharedObjectId = \"root\";\n\n/**\n * Creates a data store channel.\n * @param context - The data store context.\n * @param existing - Whether the data store already exists. When true, this loads it, when false a new one is created.\n * @param options - The data store options.\n * @returns A promise that resolves to the created data store channel.\n * @remarks\n * Currently this is limited to data stores which have a single named channel,\n * which must have the {@link rootSharedObjectId} and is attached at creation time.\n * This limitation may be relaxed in the future.\n */\nasync function createDataStore<T, TRoot extends IFluidLoadable>(\n\tcontext: IFluidDataStoreContext,\n\texisting: boolean,\n\toptions: DataStoreOptions<TRoot, T>,\n): Promise<IFluidDataStoreChannel> {\n\tconst sharedObjectRegistry = await options.registry();\n\tconst runtime: FluidDataStoreRuntime = new FluidDataStoreRuntime(\n\t\tcontext,\n\t\tconvertRegistry(sharedObjectRegistry),\n\t\texisting,\n\t\tasync (runtimeInner: IFluidDataStoreRuntime) => {\n\t\t\tconst innerContext: DataStoreContext = {\n\t\t\t\tasync createSharedObject<T2 extends IFluidLoadable>(\n\t\t\t\t\tkey: SharedObjectKey<T2>,\n\t\t\t\t): Promise<T2> {\n\t\t\t\t\tconst kind = lookupInRegistry(sharedObjectRegistry, key);\n\t\t\t\t\t// Create detached channel.\n\t\t\t\t\treturn asSharedObjectKind(kind).create(runtimeInner);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tlet createdRoot: TRoot | undefined;\n\n\t\t\tconst rootCreator: SharedObjectCreator<TRoot> = {\n\t\t\t\tasync createSharedObject<T2 extends TRoot>(key: SharedObjectKey<T2>): Promise<T2> {\n\t\t\t\t\t// Create named channel under the root id.\n\t\t\t\t\t// Error if called twice.\n\t\t\t\t\tif (createdRoot !== undefined) {\n\t\t\t\t\t\tthrow new UsageError(\"Root shared object already created\");\n\t\t\t\t\t}\n\t\t\t\t\tconst kind = lookupInRegistry(sharedObjectRegistry, key);\n\t\t\t\t\tconst result = asSharedObjectKind(kind).create(runtimeInner, rootSharedObjectId);\n\n\t\t\t\t\t// Every shared object is also an ISharedObject;\n\t\t\t\t\tconst rootSharedObject = result as IFluidLoadable as ISharedObject;\n\t\t\t\t\t// bind the newly created root so it becomes part of this data store.\n\t\t\t\t\trootSharedObject.bindToContext();\n\n\t\t\t\t\tcreatedRoot = result;\n\t\t\t\t\treturn result;\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tlet root: TRoot | undefined;\n\t\t\tif (existing) {\n\t\t\t\t// getChannel returns the type-erased IChannel; the registered root kind guarantees it is a TRoot.\n\t\t\t\troot = (await runtimeInner.getChannel(rootSharedObjectId)) as IFluidLoadable as TRoot;\n\t\t\t} else {\n\t\t\t\troot = await options.instantiateFirstTime(rootCreator, innerContext);\n\t\t\t\tif (root !== createdRoot) {\n\t\t\t\t\tthrow new UsageError(\n\t\t\t\t\t\t\"instantiateFirstTime did not return root created with rootCreator\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// view returns the data store's output type; the runtime only needs it as an opaque FluidObject entry point.\n\t\t\treturn (await options.view(root, innerContext)) as unknown as FluidObject;\n\t\t},\n\t);\n\n\treturn runtime;\n}\n\n/**\n * Creates instances of SharedObjectKinds.\n * @privateRemarks\n * See IFluidContainer.create.\n * @sealed\n * @alpha\n */\nexport interface SharedObjectCreator<TConstraint = IFluidLoadable> {\n\t/**\n\t * Create an instance of `kind`, which must be registered in the registry of the surrounding data store.\n\t */\n\tcreateSharedObject<T extends TConstraint>(kind: SharedObjectKey<T>): Promise<T>;\n}\n\n/**\n * Contextual information about a data store which is provided when instantiating or loading it.\n * @privateRemarks\n * TODO: this can expose more contextual information about the data store as needed.\n * @sealed\n * @alpha\n */\nexport interface DataStoreContext extends SharedObjectCreator {}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -4,9 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export { type ISharedObjectHandle, isISharedObjectHandle } from "./handle.js";
|
|
6
6
|
export { FluidSerializer, type IFluidSerializer } from "./serializer.js";
|
|
7
|
-
export { SharedObject, SharedObjectCore, type ISharedObjectKind, type SharedObjectKind, createSharedObjectKind, } from "./sharedObject.js";
|
|
7
|
+
export { SharedObject, SharedObjectCore, type ISharedObjectKind, type SharedObjectKind, type SharedObjectKindAlpha, createSharedObjectKind, createSharedObjectKindAlpha, type SharedObjectKey, } from "./sharedObject.js";
|
|
8
8
|
export type { ISharedObject, ISharedObjectEvents } from "./types.js";
|
|
9
9
|
export { createSingleBlobSummary, makeHandlesSerializable, parseHandles, serializeHandles, bindHandles, type IChannelView, } from "./utils.js";
|
|
10
10
|
export { ValueType } from "./valueType.js";
|
|
11
11
|
export { type SharedKernel, thisWrap, type KernelArgs, makeSharedObjectKind, type SharedKernelFactory, type FactoryOut, type SharedObjectOptions, mergeAPIs, } from "./sharedObjectKernel.js";
|
|
12
|
+
export { defineDataStore, sharedObjectRegistryFromIterable } from "./dataStoreKind.js";
|
|
13
|
+
export { makeStubDataStoreKind } from "./stubSharedObject.js";
|
|
14
|
+
export type { DataStoreOptions, SharedObjectCreator, SharedObjectRegistry, DataStoreContext, } from "./dataStoreKind.js";
|
|
12
15
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EACN,YAAY,EACZ,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EACN,YAAY,EACZ,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,sBAAsB,EACtB,2BAA2B,EAC3B,KAAK,eAAe,GACpB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EACN,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,KAAK,YAAY,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EACN,KAAK,YAAY,EACjB,QAAQ,EACR,KAAK,UAAU,EACf,oBAAoB,EACpB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,SAAS,GACT,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,YAAY,EACX,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,GAChB,MAAM,oBAAoB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export { isISharedObjectHandle } from "./handle.js";
|
|
6
6
|
export { FluidSerializer } from "./serializer.js";
|
|
7
|
-
export { SharedObject, SharedObjectCore, createSharedObjectKind, } from "./sharedObject.js";
|
|
7
|
+
export { SharedObject, SharedObjectCore, createSharedObjectKind, createSharedObjectKindAlpha, } from "./sharedObject.js";
|
|
8
8
|
export { createSingleBlobSummary, makeHandlesSerializable, parseHandles, serializeHandles, bindHandles, } from "./utils.js";
|
|
9
9
|
export { ValueType } from "./valueType.js";
|
|
10
10
|
export { thisWrap, makeSharedObjectKind, mergeAPIs, } from "./sharedObjectKernel.js";
|
|
11
|
+
export { defineDataStore, sharedObjectRegistryFromIterable } from "./dataStoreKind.js";
|
|
12
|
+
export { makeStubDataStoreKind } from "./stubSharedObject.js";
|
|
11
13
|
//# 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,OAAO,EAA4B,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAyB,MAAM,iBAAiB,CAAC;AACzE,OAAO,EACN,YAAY,EACZ,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA4B,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAyB,MAAM,iBAAiB,CAAC;AACzE,OAAO,EACN,YAAY,EACZ,gBAAgB,EAIhB,sBAAsB,EACtB,2BAA2B,GAE3B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACN,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,gBAAgB,EAChB,WAAW,GAEX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAEN,QAAQ,EAER,oBAAoB,EAIpB,SAAS,GACT,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { type ISharedObjectHandle, isISharedObjectHandle } from \"./handle.js\";\nexport { FluidSerializer, type IFluidSerializer } from \"./serializer.js\";\nexport {\n\tSharedObject,\n\tSharedObjectCore,\n\ttype ISharedObjectKind,\n\ttype SharedObjectKind,\n\ttype SharedObjectKindAlpha,\n\tcreateSharedObjectKind,\n\tcreateSharedObjectKindAlpha,\n\ttype SharedObjectKey,\n} from \"./sharedObject.js\";\nexport type { ISharedObject, ISharedObjectEvents } from \"./types.js\";\nexport {\n\tcreateSingleBlobSummary,\n\tmakeHandlesSerializable,\n\tparseHandles,\n\tserializeHandles,\n\tbindHandles,\n\ttype IChannelView,\n} from \"./utils.js\";\nexport { ValueType } from \"./valueType.js\";\nexport {\n\ttype SharedKernel,\n\tthisWrap,\n\ttype KernelArgs,\n\tmakeSharedObjectKind,\n\ttype SharedKernelFactory,\n\ttype FactoryOut,\n\ttype SharedObjectOptions,\n\tmergeAPIs,\n} from \"./sharedObjectKernel.js\";\nexport { defineDataStore, sharedObjectRegistryFromIterable } from \"./dataStoreKind.js\";\nexport { makeStubDataStoreKind } from \"./stubSharedObject.js\";\nexport type {\n\tDataStoreOptions,\n\tSharedObjectCreator,\n\tSharedObjectRegistry,\n\tDataStoreContext,\n} from \"./dataStoreKind.js\";\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/shared-object-base";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.114.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,uCAAuC,CAAC;AAC5D,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,uCAAuC,CAAC;AAC5D,eAAO,MAAM,UAAU,YAAY,CAAC"}
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,oCAAoC,CAAC;AAC5D,MAAM,CAAC,MAAM,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,oCAAoC,CAAC;AAC5D,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/shared-object-base\";\nexport const pkgVersion = \"2.114.0\";\n"]}
|
package/lib/sharedObject.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { IDeltaManager } from "@fluidframework/container-definitions/intern
|
|
|
7
7
|
import type { ErasedType } from "@fluidframework/core-interfaces";
|
|
8
8
|
import type { IFluidHandleInternal, IFluidLoadable } from "@fluidframework/core-interfaces/internal";
|
|
9
9
|
import type { IChannelServices, IChannelStorageService, IChannelAttributes, IChannelFactory, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions/internal";
|
|
10
|
-
import type { IDocumentMessage, ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
10
|
+
import type { IDocumentMessage, ISequencedDocumentMessage, RegistryKey } from "@fluidframework/driver-definitions/internal";
|
|
11
11
|
import { type IExperimentalIncrementalSummaryContext, type ISummaryTreeWithStats, type ITelemetryContext, type IGarbageCollectionData, type IRuntimeMessageCollection } from "@fluidframework/runtime-definitions/internal";
|
|
12
12
|
import { EventEmitterWithErrorHandling } from "@fluidframework/telemetry-utils/internal";
|
|
13
13
|
import type { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/legacy";
|
|
@@ -431,6 +431,28 @@ export interface SharedObjectKind<out TSharedObject = unknown> extends ErasedTyp
|
|
|
431
431
|
*/
|
|
432
432
|
is(value: IFluidLoadable): value is IFluidLoadable & TSharedObject;
|
|
433
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* A {@link @fluidframework/driver-definitions#RegistryKey} for a {@link SharedObjectKind}.
|
|
436
|
+
* @remarks
|
|
437
|
+
* This is implemented by {@link SharedObjectKind}, but alternative implementations can be used if needed.
|
|
438
|
+
*
|
|
439
|
+
* If you want lazy loading and need a key that does not eagerly load the {@link SharedObjectKind}, an alternative {@link SharedObjectKey} can be implemented.
|
|
440
|
+
* @privateRemarks
|
|
441
|
+
* TODO: A built in common pattern for the lazy key case should be provided.
|
|
442
|
+
* TODO: things probably break if "adapt" does anything except throw or return the result from the input promise.
|
|
443
|
+
* @input
|
|
444
|
+
* @alpha
|
|
445
|
+
*/
|
|
446
|
+
export type SharedObjectKey<T> = RegistryKey<SharedObjectKindAlpha<T>, SharedObjectKindAlpha>;
|
|
447
|
+
/**
|
|
448
|
+
* A {@link SharedObjectKind} that also implements {@link SharedObjectKey}.
|
|
449
|
+
* @privateRemarks
|
|
450
|
+
* All concrete shared object kinds (produced by {@link createSharedObjectKind}) implement this interface.
|
|
451
|
+
* @sealed
|
|
452
|
+
* @alpha
|
|
453
|
+
*/
|
|
454
|
+
export interface SharedObjectKindAlpha<out TSharedObject = unknown> extends SharedObjectKind<TSharedObject>, SharedObjectKey<TSharedObject> {
|
|
455
|
+
}
|
|
434
456
|
/**
|
|
435
457
|
* Utility for creating ISharedObjectKind instances.
|
|
436
458
|
* @remarks
|
|
@@ -443,4 +465,16 @@ export interface SharedObjectKind<out TSharedObject = unknown> extends ErasedTyp
|
|
|
443
465
|
export declare function createSharedObjectKind<TSharedObject>(factory: (new () => IChannelFactory<TSharedObject>) & {
|
|
444
466
|
readonly Type: string;
|
|
445
467
|
}): ISharedObjectKind<TSharedObject> & SharedObjectKind<TSharedObject>;
|
|
468
|
+
/**
|
|
469
|
+
* Utility for creating ISharedObjectKind instances.
|
|
470
|
+
* @remarks
|
|
471
|
+
* This takes in a class which implements IChannelFactory,
|
|
472
|
+
* and uses it to return a single value which is intended to be used as the API entry point for the corresponding shared object type.
|
|
473
|
+
* The returned value implements {@link ISharedObjectKind} for use in the encapsulated API, as well as the type erased {@link SharedObjectKind} used by the declarative API.
|
|
474
|
+
* See {@link @fluidframework/fluid-static#ContainerSchema} for how this is used in the declarative API.
|
|
475
|
+
* @internal
|
|
476
|
+
*/
|
|
477
|
+
export declare function createSharedObjectKindAlpha<TSharedObject>(factory: (new () => IChannelFactory<TSharedObject>) & {
|
|
478
|
+
readonly Type: string;
|
|
479
|
+
}): ISharedObjectKind<TSharedObject> & SharedObjectKindAlpha<TSharedObject>;
|
|
446
480
|
//# sourceMappingURL=sharedObject.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedObject.d.ts","sourceRoot":"","sources":["../src/sharedObject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE1E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AACpF,OAAO,KAAK,EAA4B,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,KAAK,EACX,oBAAoB,EACpB,cAAc,EACd,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EACX,gBAAgB,EAChB,sBAAsB,EAEtB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EAGtB,MAAM,gDA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AAC,aAAa,GAAG,OAAO,CAC5D,SAAQ,UAAU,CAAC,SAAS,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC;IAChE;;;OAGG;IACH,EAAE,CAAC,KAAK,EAAE,cAAc,GAAG,KAAK,IAAI,cAAc,GAAG,aAAa,CAAC;CACnE;AAED;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,WAAW,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,qBAAqB,CAAC,CAAC;AAE9F;;;;;;GAMG;AACH,MAAM,WAAW,qBAAqB,CAAC,GAAG,CAAC,aAAa,GAAG,OAAO,CACjE,SAAQ,gBAAgB,CAAC,aAAa,CAAC,EACtC,eAAe,CAAC,aAAa,CAAC;CAAG;AAEnC;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EACnD,OAAO,EAAE,CAAC,UAAU,eAAe,CAAC,aAAa,CAAC,CAAC,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC7E,iBAAiB,CAAC,aAAa,CAAC,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAEpE;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,aAAa,EACxD,OAAO,EAAE,CAAC,UAAU,eAAe,CAAC,aAAa,CAAC,CAAC,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC7E,iBAAiB,CAAC,aAAa,CAAC,GAAG,qBAAqB,CAAC,aAAa,CAAC,CAiCzE"}
|
package/lib/sharedObject.js
CHANGED
|
@@ -6,7 +6,7 @@ import { AttachState } from "@fluidframework/container-definitions";
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { blobCountPropertyName, totalBlobSizePropertyName, } from "@fluidframework/runtime-definitions/internal";
|
|
8
8
|
import { toDeltaManagerInternal, } from "@fluidframework/runtime-utils/internal";
|
|
9
|
-
import { DataProcessingError, EventEmitterWithErrorHandling, SampledTelemetryHelper, createChildLogger, loggerToMonitoringContext, tagCodeArtifacts, LoggingError, extractTelemetryLoggerExt, } from "@fluidframework/telemetry-utils/internal";
|
|
9
|
+
import { DataProcessingError, EventEmitterWithErrorHandling, SampledTelemetryHelper, createChildLogger, loggerToMonitoringContext, tagCodeArtifacts, LoggingError, UsageError, extractTelemetryLoggerExt, } from "@fluidframework/telemetry-utils/internal";
|
|
10
10
|
import { v4 as uuid } from "uuid";
|
|
11
11
|
import { GCHandleVisitor } from "./gcHandleVisitor.js";
|
|
12
12
|
import { SharedObjectHandle } from "./handle.js";
|
|
@@ -589,6 +589,18 @@ export class SharedObject extends SharedObjectCore {
|
|
|
589
589
|
* @internal
|
|
590
590
|
*/
|
|
591
591
|
export function createSharedObjectKind(factory) {
|
|
592
|
+
return createSharedObjectKindAlpha(factory);
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Utility for creating ISharedObjectKind instances.
|
|
596
|
+
* @remarks
|
|
597
|
+
* This takes in a class which implements IChannelFactory,
|
|
598
|
+
* and uses it to return a single value which is intended to be used as the API entry point for the corresponding shared object type.
|
|
599
|
+
* The returned value implements {@link ISharedObjectKind} for use in the encapsulated API, as well as the type erased {@link SharedObjectKind} used by the declarative API.
|
|
600
|
+
* See {@link @fluidframework/fluid-static#ContainerSchema} for how this is used in the declarative API.
|
|
601
|
+
* @internal
|
|
602
|
+
*/
|
|
603
|
+
export function createSharedObjectKindAlpha(factory) {
|
|
592
604
|
const result = {
|
|
593
605
|
getFactory() {
|
|
594
606
|
return new factory();
|
|
@@ -599,8 +611,19 @@ export function createSharedObjectKind(factory) {
|
|
|
599
611
|
is(value) {
|
|
600
612
|
return isChannel(value) && value.attributes.type === factory.Type;
|
|
601
613
|
},
|
|
614
|
+
type: factory.Type,
|
|
615
|
+
adapt: (value) => {
|
|
616
|
+
if (value === resultFinal) {
|
|
617
|
+
return resultFinal;
|
|
618
|
+
}
|
|
619
|
+
if (value.type === result.type) {
|
|
620
|
+
throw new UsageError(`Conflicting SharedObjectKinds with same type: ${result.type}`);
|
|
621
|
+
}
|
|
622
|
+
throw new UsageError(`Mismatched SharedObjectKind type. Expected: ${result.type}, got: ${value.type}`);
|
|
623
|
+
},
|
|
602
624
|
};
|
|
603
|
-
|
|
625
|
+
const resultFinal = result;
|
|
626
|
+
return resultFinal;
|
|
604
627
|
}
|
|
605
628
|
function isChannel(loadable) {
|
|
606
629
|
// This assumes no other IFluidLoadable has an `attributes` field, and thus may not be fully robust.
|