@fluidframework/driver-definitions 2.113.1 → 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 +69 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/serviceClient.d.ts +345 -0
- package/dist/serviceClient.d.ts.map +1 -0
- package/dist/serviceClient.js +51 -0
- package/dist/serviceClient.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/serviceClient.d.ts +345 -0
- package/lib/serviceClient.d.ts.map +1 -0
- package/lib/serviceClient.js +45 -0
- package/lib/serviceClient.js.map +1 -0
- package/package.json +7 -7
- package/src/index.ts +15 -0
- package/src/serviceClient.ts +406 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,74 @@
|
|
|
1
1
|
# @fluidframework/driver-definitions
|
|
2
2
|
|
|
3
|
+
## 2.114.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Add new @alpha ServiceClient API for creating and loading Fluid containers ([#27693](https://github.com/microsoft/FluidFramework/pull/27693)) [ee47192d4a](https://github.com/microsoft/FluidFramework/commit/ee47192d4ae91bc28f9154c4d1ead2acad762f3c)
|
|
8
|
+
|
|
9
|
+
This introduces an experimental (`@alpha`), service-agnostic API for working with Fluid containers whose root is an arbitrary data store, along with an in-memory implementation for testing.
|
|
10
|
+
|
|
11
|
+
The new surface is made up of:
|
|
12
|
+
- `ServiceClient` (`@fluidframework/driver-definitions`): the entry point for creating and loading containers. Along with it come the supporting container types (`FluidContainer`, `FluidContainerWithService`, `FluidContainerAttached`), the data store model (`DataStoreKind`, `DataStoreKey`, `DataStoreRegistry`, `DataStoreCreator`), and the generic registry primitives (`Registry`, `RegistryKey`, `lookupInRegistry`, `createBasicRegistryKey`).
|
|
13
|
+
- `defineDataStore` and `sharedObjectRegistryFromIterable` (`@fluidframework/shared-object-base`): build a `DataStoreKind` from a root shared object and a registry of shared object kinds.
|
|
14
|
+
- `defineTreeDataStore` and `instantiateTreeFirstTime` (`@fluidframework/tree`): a SharedTree-specific convenience wrapper that produces a `DataStoreKind` backed by a `TreeView`.
|
|
15
|
+
- `startEphemeralService` (`@fluidframework/local-driver`): starts an in-memory `EphemeralService` for tests. The service owns the lifetime of the in-memory documents and resources, and produces `ServiceClient`s connected to it (via `EphemeralService.newClient` or `EphemeralService.defaultClient`). The helpers `cleanupEphemeralService` and `getDefaultEphemeralService` manage an optional default service instance.
|
|
16
|
+
|
|
17
|
+
Apart from the `@fluidframework/local-driver` helpers (which come from `@fluidframework/local-driver/alpha`), these APIs are also re-exported from `fluid-framework`. None reference any `@legacy` types.
|
|
18
|
+
|
|
19
|
+
Example:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { startEphemeralService } from "@fluidframework/local-driver/alpha";
|
|
23
|
+
import {
|
|
24
|
+
ServiceClient,
|
|
25
|
+
defineTreeDataStore,
|
|
26
|
+
TreeViewConfiguration,
|
|
27
|
+
SchemaFactory,
|
|
28
|
+
} from "fluid-framework/alpha";
|
|
29
|
+
import { strict as assert } from "node:assert";
|
|
30
|
+
|
|
31
|
+
// Start an ephemeral in-memory service and get a ServiceClient connected to it.
|
|
32
|
+
const service = startEphemeralService();
|
|
33
|
+
const client: ServiceClient = service.defaultClient;
|
|
34
|
+
// Define a DataStoreKind which uses a SharedTree.
|
|
35
|
+
// In this case the schema is for a single number with an initializer that starts the it at 1.
|
|
36
|
+
// This schema is captures in the type allowing for strongly typed access to the data in the tree,
|
|
37
|
+
// where the type matches the schema based runtime enforcement of the schema.
|
|
38
|
+
const numberStore = defineTreeDataStore({
|
|
39
|
+
type: "my-app-root",
|
|
40
|
+
config: new TreeViewConfiguration({ schema: SchemaFactory.number }),
|
|
41
|
+
initializer: () => 1,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Create a container in the service with the above DataStoreKind.
|
|
45
|
+
// Ideally this creation would use a service independent API, and only the attach call would be service dependent,
|
|
46
|
+
// but that is not supported yet.
|
|
47
|
+
const detachedContainer1 = await client.createContainer(numberStore);
|
|
48
|
+
const container1 = await detachedContainer1.attach();
|
|
49
|
+
|
|
50
|
+
// We now have easy and type safe access to the data in the tree, which will be synced over the service.
|
|
51
|
+
assert.equal(container1.data.root, 1);
|
|
52
|
+
|
|
53
|
+
// A second client can load the same container from the service, and will see the same data.
|
|
54
|
+
const container2 = await client.loadContainer(container1.id, numberStore);
|
|
55
|
+
assert.equal(container2.data.root, 1);
|
|
56
|
+
|
|
57
|
+
// Both clients can modify the data, and the changes will be synced over the service.
|
|
58
|
+
container2.data.root = 2;
|
|
59
|
+
// Since we are using an ephemeral service, we can await the synchronization using service.synchronize.
|
|
60
|
+
await service.synchronize();
|
|
61
|
+
|
|
62
|
+
// And now the changes are visible for all clients.
|
|
63
|
+
assert.equal(container1.data.root, 2);
|
|
64
|
+
assert.equal(container2.data.root, 2);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Note that this example does a couple of things which are difficult to do with the other API surfaces:
|
|
68
|
+
1. It creates a container, then loads a second copy of it, allowing for collaboration. There is currently no non-legacy API surface which allows this without spawning a server process. This is also cleaner than the exacting legacy API options, and can replace the test specific APIs for this as well.
|
|
69
|
+
2. It creates a container which has a SharedTree at the root, and nothing else. This avoids depending on legacy DDS implementations, which is great for long-term document support and bundle size. This is currently impossible using `fluid-static`, which forces a special root data store. It is also impossible if using `aqueduct`, which forces a root directory in every data store. It can be done using the low level legacy APIs directly, but this new API for it is much simpler.
|
|
70
|
+
3. There is a common interface all services implement (`ServiceClient`), making the container creation part of the code work for any service implementation.
|
|
71
|
+
|
|
3
72
|
## 2.113.0
|
|
4
73
|
|
|
5
74
|
Dependency updates only.
|
package/dist/index.d.ts
CHANGED
|
@@ -12,4 +12,6 @@ export { DriverHeader } from "./urlResolver.js";
|
|
|
12
12
|
export type { ConnectionMode, IApprovedProposal, IAttachment, IBlob, IBranchOrigin, ICapabilities, IClient, IClientConfiguration, IClientDetails, IClientJoin, ICommittedProposal, IConnect, IConnected, ICreateBlobResponse, IDocumentAttributes, IDocumentMessage, IDocumentSystemMessage, INack, INackContent, IProcessMessageResult, IProposal, IProtocolState, IQuorum, IQuorumClients, IQuorumProposals, ISentSignalMessage, ISequencedClient, ISequencedDocumentAugmentedMessage, ISequencedDocumentMessage, ISequencedDocumentMessageExperimental, ISequencedDocumentSystemMessage, ISequencedProposal, IServerError, ISignalClient, ISignalMessage, ISignalMessageBase, ISnapshotTree, ISnapshotTreeEx, IsoDate, ISummaryAck, ISummaryAttachment, ISummaryBlob, ISummaryContent, ISummaryHandle, ISummaryNack, ISummaryProposal, ISummaryTree, ITokenClaims, ITrace, ITree, ITreeEntry, IUploadedSummaryDetails, IUser, IVersion, SummaryObject, SummaryTree, SummaryTypeNoHandle, } from "./protocol/index.js";
|
|
13
13
|
export { FileMode, MessageType, NackErrorType, ScopeType, SignalType, SummaryType, TreeEntry, } from "./protocol/index.js";
|
|
14
14
|
export type { IGitAuthor, IGitBlob, IGitCommitDetails, IGitCommitHash, IGitCommitter, IGitCreateBlobParams, IGitCreateBlobResponse, IGitCreateTreeEntry, IGitCreateTreeParams, IGitTree, IGitTreeEntry, } from "./git/index.js";
|
|
15
|
+
export type { DataStoreCreator, DataStoreKey, DataStoreKind, DataStoreRegistry, FluidContainer, FluidContainerAttached, FluidContainerWithService, MinimumVersionForCollaboration, Registry, RegistryKey, ServiceClient, ServiceOptions, } from "./serviceClient.js";
|
|
16
|
+
export { createBasicRegistryKey, lookupInRegistry, featureVersion } from "./serviceClient.js";
|
|
15
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA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d,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,OAAO,EACP,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,KAAK,EACL,UAAU,EACV,uBAAuB,EACvB,KAAK,EACL,QAAQ,EACR,aAAa,EACb,WAAW,EACX,mBAAmB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,QAAQ,EACR,WAAW,EACX,aAAa,EACb,SAAS,EACT,UAAU,EACV,WAAW,EACX,SAAS,GACT,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACX,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,QAAQ,EACR,aAAa,GACb,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EACX,WAAW,EACX,MAAM,EACN,UAAU,EACV,eAAe,GACf,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACX,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,YAAY,EACX,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,8BAA8B,EAC9B,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACvB,+BAA+B,EAC/B,SAAS,EACT,qBAAqB,EACrB,OAAO,EACP,aAAa,EACb,eAAe,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE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C;AACxB,YAAY,EACX,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,sBAAsB,EACtB,yBAAyB,EACzB,8BAA8B,EAC9B,QAAQ,EACR,WAAW,EACX,aAAa,EACb,cAAc,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.TreeEntry = exports.SummaryType = exports.SignalType = exports.ScopeType = exports.NackErrorType = exports.MessageType = exports.FileMode = exports.DriverHeader = exports.LoaderCachingPolicy = exports.FetchSource = exports.DriverErrorTypes = void 0;
|
|
7
|
+
exports.featureVersion = exports.lookupInRegistry = exports.createBasicRegistryKey = exports.TreeEntry = exports.SummaryType = exports.SignalType = exports.ScopeType = exports.NackErrorType = exports.MessageType = exports.FileMode = exports.DriverHeader = exports.LoaderCachingPolicy = exports.FetchSource = exports.DriverErrorTypes = void 0;
|
|
8
8
|
var driverError_js_1 = require("./driverError.js");
|
|
9
9
|
Object.defineProperty(exports, "DriverErrorTypes", { enumerable: true, get: function () { return driverError_js_1.DriverErrorTypes; } });
|
|
10
10
|
var storage_js_1 = require("./storage.js");
|
|
@@ -20,4 +20,8 @@ Object.defineProperty(exports, "ScopeType", { enumerable: true, get: function ()
|
|
|
20
20
|
Object.defineProperty(exports, "SignalType", { enumerable: true, get: function () { return index_js_1.SignalType; } });
|
|
21
21
|
Object.defineProperty(exports, "SummaryType", { enumerable: true, get: function () { return index_js_1.SummaryType; } });
|
|
22
22
|
Object.defineProperty(exports, "TreeEntry", { enumerable: true, get: function () { return index_js_1.TreeEntry; } });
|
|
23
|
+
var serviceClient_js_1 = require("./serviceClient.js");
|
|
24
|
+
Object.defineProperty(exports, "createBasicRegistryKey", { enumerable: true, get: function () { return serviceClient_js_1.createBasicRegistryKey; } });
|
|
25
|
+
Object.defineProperty(exports, "lookupInRegistry", { enumerable: true, get: function () { return serviceClient_js_1.lookupInRegistry; } });
|
|
26
|
+
Object.defineProperty(exports, "featureVersion", { enumerable: true, get: function () { return serviceClient_js_1.featureVersion; } });
|
|
23
27
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAmBH,mDAAoD;AAA3C,kHAAA,gBAAgB,OAAA;AAoBzB,2CAAgE;AAAvD,yGAAA,WAAW,OAAA;AAAE,iHAAA,mBAAmB,OAAA;AAQzC,mDAAgD;AAAvC,8GAAA,YAAY,OAAA;AA6DrB,gDAQ6B;AAP5B,oGAAA,QAAQ,OAAA;AACR,uGAAA,WAAW,OAAA;AACX,yGAAA,aAAa,OAAA;AACb,qGAAA,SAAS,OAAA;AACT,sGAAA,UAAU,OAAA;AACV,uGAAA,WAAW,OAAA;AACX,qGAAA,SAAS,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport type {\n\tICacheEntry,\n\tIEntry,\n\tIFileEntry,\n\tIPersistedCache,\n} from \"./cacheDefinitions.js\";\n\nexport type {\n\tDriverError,\n\tIAnyDriverError,\n\tIAuthorizationError,\n\tIDriverErrorBase,\n\tIDriverBasicError,\n\tIGenericNetworkError,\n\tILocationRedirectionError,\n\tIThrottlingWarning,\n} from \"./driverError.js\";\nexport { DriverErrorTypes } from \"./driverError.js\";\nexport type {\n\tFiveDaysMs,\n\tIDeltasFetchResult,\n\tIDeltaStorageService,\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaConnectionEvents,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIDocumentServiceEvents,\n\tIDocumentServiceFactory,\n\tIDocumentServicePolicies,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISnapshot,\n\tISnapshotFetchOptions,\n\tIStream,\n\tIStreamResult,\n\tISummaryContext,\n} from \"./storage.js\";\nexport { FetchSource, LoaderCachingPolicy } from \"./storage.js\";\nexport type {\n\tDriverPreCheckInfo,\n\tIContainerPackageInfo,\n\tIDriverHeader,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"./urlResolver.js\";\nexport { DriverHeader } from \"./urlResolver.js\";\n\nexport type {\n\tConnectionMode,\n\tIApprovedProposal,\n\tIAttachment,\n\tIBlob,\n\tIBranchOrigin,\n\tICapabilities,\n\tIClient,\n\tIClientConfiguration,\n\tIClientDetails,\n\tIClientJoin,\n\tICommittedProposal,\n\tIConnect,\n\tIConnected,\n\tICreateBlobResponse,\n\tIDocumentAttributes,\n\tIDocumentMessage,\n\tIDocumentSystemMessage,\n\tINack,\n\tINackContent,\n\tIProcessMessageResult,\n\tIProposal,\n\tIProtocolState,\n\tIQuorum,\n\tIQuorumClients,\n\tIQuorumProposals,\n\tISentSignalMessage,\n\tISequencedClient,\n\tISequencedDocumentAugmentedMessage,\n\tISequencedDocumentMessage,\n\tISequencedDocumentMessageExperimental,\n\tISequencedDocumentSystemMessage,\n\tISequencedProposal,\n\tIServerError,\n\tISignalClient,\n\tISignalMessage,\n\tISignalMessageBase,\n\tISnapshotTree,\n\tISnapshotTreeEx,\n\tIsoDate,\n\tISummaryAck,\n\tISummaryAttachment,\n\tISummaryBlob,\n\tISummaryContent,\n\tISummaryHandle,\n\tISummaryNack,\n\tISummaryProposal,\n\tISummaryTree,\n\tITokenClaims,\n\tITrace,\n\tITree,\n\tITreeEntry,\n\tIUploadedSummaryDetails,\n\tIUser,\n\tIVersion,\n\tSummaryObject,\n\tSummaryTree,\n\tSummaryTypeNoHandle,\n} from \"./protocol/index.js\";\nexport {\n\tFileMode,\n\tMessageType,\n\tNackErrorType,\n\tScopeType,\n\tSignalType,\n\tSummaryType,\n\tTreeEntry,\n} from \"./protocol/index.js\";\nexport type {\n\tIGitAuthor,\n\tIGitBlob,\n\tIGitCommitDetails,\n\tIGitCommitHash,\n\tIGitCommitter,\n\tIGitCreateBlobParams,\n\tIGitCreateBlobResponse,\n\tIGitCreateTreeEntry,\n\tIGitCreateTreeParams,\n\tIGitTree,\n\tIGitTreeEntry,\n} from \"./git/index.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAmBH,mDAAoD;AAA3C,kHAAA,gBAAgB,OAAA;AAoBzB,2CAAgE;AAAvD,yGAAA,WAAW,OAAA;AAAE,iHAAA,mBAAmB,OAAA;AAQzC,mDAAgD;AAAvC,8GAAA,YAAY,OAAA;AA6DrB,gDAQ6B;AAP5B,oGAAA,QAAQ,OAAA;AACR,uGAAA,WAAW,OAAA;AACX,yGAAA,aAAa,OAAA;AACb,qGAAA,SAAS,OAAA;AACT,sGAAA,UAAU,OAAA;AACV,uGAAA,WAAW,OAAA;AACX,qGAAA,SAAS,OAAA;AA6BV,uDAA8F;AAArF,0HAAA,sBAAsB,OAAA;AAAE,oHAAA,gBAAgB,OAAA;AAAE,kHAAA,cAAc,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport type {\n\tICacheEntry,\n\tIEntry,\n\tIFileEntry,\n\tIPersistedCache,\n} from \"./cacheDefinitions.js\";\n\nexport type {\n\tDriverError,\n\tIAnyDriverError,\n\tIAuthorizationError,\n\tIDriverErrorBase,\n\tIDriverBasicError,\n\tIGenericNetworkError,\n\tILocationRedirectionError,\n\tIThrottlingWarning,\n} from \"./driverError.js\";\nexport { DriverErrorTypes } from \"./driverError.js\";\nexport type {\n\tFiveDaysMs,\n\tIDeltasFetchResult,\n\tIDeltaStorageService,\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaConnectionEvents,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIDocumentServiceEvents,\n\tIDocumentServiceFactory,\n\tIDocumentServicePolicies,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISnapshot,\n\tISnapshotFetchOptions,\n\tIStream,\n\tIStreamResult,\n\tISummaryContext,\n} from \"./storage.js\";\nexport { FetchSource, LoaderCachingPolicy } from \"./storage.js\";\nexport type {\n\tDriverPreCheckInfo,\n\tIContainerPackageInfo,\n\tIDriverHeader,\n\tIResolvedUrl,\n\tIUrlResolver,\n} from \"./urlResolver.js\";\nexport { DriverHeader } from \"./urlResolver.js\";\n\nexport type {\n\tConnectionMode,\n\tIApprovedProposal,\n\tIAttachment,\n\tIBlob,\n\tIBranchOrigin,\n\tICapabilities,\n\tIClient,\n\tIClientConfiguration,\n\tIClientDetails,\n\tIClientJoin,\n\tICommittedProposal,\n\tIConnect,\n\tIConnected,\n\tICreateBlobResponse,\n\tIDocumentAttributes,\n\tIDocumentMessage,\n\tIDocumentSystemMessage,\n\tINack,\n\tINackContent,\n\tIProcessMessageResult,\n\tIProposal,\n\tIProtocolState,\n\tIQuorum,\n\tIQuorumClients,\n\tIQuorumProposals,\n\tISentSignalMessage,\n\tISequencedClient,\n\tISequencedDocumentAugmentedMessage,\n\tISequencedDocumentMessage,\n\tISequencedDocumentMessageExperimental,\n\tISequencedDocumentSystemMessage,\n\tISequencedProposal,\n\tIServerError,\n\tISignalClient,\n\tISignalMessage,\n\tISignalMessageBase,\n\tISnapshotTree,\n\tISnapshotTreeEx,\n\tIsoDate,\n\tISummaryAck,\n\tISummaryAttachment,\n\tISummaryBlob,\n\tISummaryContent,\n\tISummaryHandle,\n\tISummaryNack,\n\tISummaryProposal,\n\tISummaryTree,\n\tITokenClaims,\n\tITrace,\n\tITree,\n\tITreeEntry,\n\tIUploadedSummaryDetails,\n\tIUser,\n\tIVersion,\n\tSummaryObject,\n\tSummaryTree,\n\tSummaryTypeNoHandle,\n} from \"./protocol/index.js\";\nexport {\n\tFileMode,\n\tMessageType,\n\tNackErrorType,\n\tScopeType,\n\tSignalType,\n\tSummaryType,\n\tTreeEntry,\n} from \"./protocol/index.js\";\nexport type {\n\tIGitAuthor,\n\tIGitBlob,\n\tIGitCommitDetails,\n\tIGitCommitHash,\n\tIGitCommitter,\n\tIGitCreateBlobParams,\n\tIGitCreateBlobResponse,\n\tIGitCreateTreeEntry,\n\tIGitCreateTreeParams,\n\tIGitTree,\n\tIGitTreeEntry,\n} from \"./git/index.js\";\nexport type {\n\tDataStoreCreator,\n\tDataStoreKey,\n\tDataStoreKind,\n\tDataStoreRegistry,\n\tFluidContainer,\n\tFluidContainerAttached,\n\tFluidContainerWithService,\n\tMinimumVersionForCollaboration,\n\tRegistry,\n\tRegistryKey,\n\tServiceClient,\n\tServiceOptions,\n} from \"./serviceClient.js\";\nexport { createBasicRegistryKey, lookupInRegistry, featureVersion } from \"./serviceClient.js\";\n"]}
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { ErasedBaseType } from "@fluidframework/core-interfaces/internal";
|
|
6
|
+
/**
|
|
7
|
+
* This file defines the external facing API for the {@link ServiceClient} and related types.
|
|
8
|
+
*
|
|
9
|
+
* It provides an API surface at a similar abstraction level to aqueduct and fluid-static, but is intended to be a replacement for those which solves several problems with them.
|
|
10
|
+
* Mainly it strives to have the encapsulation of implementation details (including all legacy APIs from aqueduct and lower level internals) like fluid-static
|
|
11
|
+
* while being both more flexible and simpler.
|
|
12
|
+
*
|
|
13
|
+
* This aims to be the cleanest practical way to build applications on the Fluid Framework Client.
|
|
14
|
+
* There are however several known cases where the API quality was sacrificed to ease initial implementation,
|
|
15
|
+
* since some of the unification desired in this API's design are not yet implemented in the underlying Fluid Framework Client code or require additional work to implement.
|
|
16
|
+
* These cases are called out with TODOs in this file.
|
|
17
|
+
* These should be considered and addressed before stabilizing this API past alpha.
|
|
18
|
+
*
|
|
19
|
+
* All code interacting through this API surface within a single client must avoid using multiple copies of any Fluid Framework client package (at the same or different versions).
|
|
20
|
+
* This mirrors the `@public` "declarative model" APIs and is a deliberate simplification of what is allowed in the legacy API surface.
|
|
21
|
+
* It is enforced best-effort only: `@sealed` nominal erased types catch many mismatches at compile time, and factory identity checks throw a UsageError ("Conflicting ... with same type") at run time, but the checking is not exhaustive.
|
|
22
|
+
* See `LayerCompatibilityUnified.md` for the full policy, rationale, and failure signatures.
|
|
23
|
+
*
|
|
24
|
+
* TODO:
|
|
25
|
+
* Before stabilizing any of this past beta, evaluate whether this single-copy requirement must be relaxed, and if so how.
|
|
26
|
+
* Whatever rule is chosen (relaxed or not) should be enforced at both compile time and run time as much as possible.
|
|
27
|
+
*
|
|
28
|
+
* TODO:
|
|
29
|
+
* Fault isolation should be considered in this API design.
|
|
30
|
+
* When are exceptions recoverable and how?
|
|
31
|
+
* Likely we can fault isolate exceptions to containers in most cases,
|
|
32
|
+
* and containers can indicate their status by being closed or disposed.
|
|
33
|
+
* Non fatal errors should not be exceptions.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* A collection of entries looked up by a `type` string.
|
|
37
|
+
* @remarks
|
|
38
|
+
* Use of a function for this allows a few things that most collections would not:
|
|
39
|
+
* 1. It's possible to generate placeholder / error values on demand.
|
|
40
|
+
* 2. It makes loading from some external registry on demand practical.
|
|
41
|
+
* 3. The lookup can throw an exception if appropriate (this would typically indicate a bug and produce a fatal error).
|
|
42
|
+
* 4. Generation of values can be lazy, and even asynchronous if `T` allows for a promise.
|
|
43
|
+
*
|
|
44
|
+
* This flexibility lets the implementer decide how to handle requests for unknown types.
|
|
45
|
+
* They can produce placeholders, assert, fall back to a generic implementation etc.
|
|
46
|
+
* @typeParam T - The type of entry produced for any given `type` string.
|
|
47
|
+
* @input
|
|
48
|
+
* @alpha
|
|
49
|
+
*/
|
|
50
|
+
export type Registry<T> = (type: string) => T;
|
|
51
|
+
/**
|
|
52
|
+
* A strongly typed key for a {@link Registry}.
|
|
53
|
+
* Use with {@link lookupInRegistry}.
|
|
54
|
+
* @remarks
|
|
55
|
+
* Used to look up a `TIn` in a `Registry<TIn>`, and produce a `TOut` from it.
|
|
56
|
+
* @typeParam TOut - The type produced by {@link RegistryKey.adapt} from a looked-up entry.
|
|
57
|
+
* @typeParam TIn - The type of the entries in the {@link Registry} this key is used with.
|
|
58
|
+
* @privateRemarks
|
|
59
|
+
* This is currently input and sealed, meaning effectively type erased since the design might change.
|
|
60
|
+
* @input
|
|
61
|
+
* @sealed
|
|
62
|
+
* @alpha
|
|
63
|
+
*/
|
|
64
|
+
export interface RegistryKey<TOut, TIn = unknown> {
|
|
65
|
+
/**
|
|
66
|
+
* Identifier to provide to the {@link Registry}.
|
|
67
|
+
*/
|
|
68
|
+
readonly type: string;
|
|
69
|
+
/**
|
|
70
|
+
* Convert a value from the registry to the desired output type.
|
|
71
|
+
* @remarks
|
|
72
|
+
* How this is done is up to the implementation.
|
|
73
|
+
*
|
|
74
|
+
* This might be a type guard which throws if the input is not valid.
|
|
75
|
+
* Or it could be a conversion, an identity function, or something else.
|
|
76
|
+
*
|
|
77
|
+
* @param value - The value from the registry.
|
|
78
|
+
* @returns The converted value.
|
|
79
|
+
*/
|
|
80
|
+
adapt(value: TIn): TOut;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Lookup an entry in a {@link Registry} using a {@link RegistryKey}.
|
|
84
|
+
* @typeParam TOut - The type produced from the looked-up entry.
|
|
85
|
+
* @typeParam TIn - The type of the entries in `registry`.
|
|
86
|
+
* @alpha
|
|
87
|
+
*/
|
|
88
|
+
export declare function lookupInRegistry<TOut, TIn>(registry: Registry<TIn>, key: RegistryKey<TOut, TIn>): TOut;
|
|
89
|
+
/**
|
|
90
|
+
* Creates a simple {@link RegistryKey} which does no type conversion.
|
|
91
|
+
* @typeParam T - The type of the registry entry, which is returned unchanged by the key.
|
|
92
|
+
* @alpha
|
|
93
|
+
*/
|
|
94
|
+
export declare function createBasicRegistryKey<T>(type: string): RegistryKey<T, T>;
|
|
95
|
+
/**
|
|
96
|
+
* Oldest version of Fluid Framework client packages to support collaborating with.
|
|
97
|
+
* @remarks
|
|
98
|
+
* A string in SemVer format indicating a specific version of the Fluid Framework client package, or the special case of {@link @fluidframework/runtime-utils#defaultMinVersionForCollab}.
|
|
99
|
+
*
|
|
100
|
+
* Collaboration with other clients is only supported when all Fluid Framework client packages used by the client have a version that is greater than or equal
|
|
101
|
+
* to the specified `MinimumVersionForCollaboration`.
|
|
102
|
+
*
|
|
103
|
+
* Cannot exceed the version of any Fluid Framework client package in use by the local client.
|
|
104
|
+
*
|
|
105
|
+
* The higher the version specified, the more features and optimizations will be enabled. *
|
|
106
|
+
* @privateRemarks
|
|
107
|
+
* This is similar to, and a subset of, the `MinimumVersionForCollab` type in `@fluidframework/runtime-definitions`.
|
|
108
|
+
* This differs in that:
|
|
109
|
+
* - This avoids the shorthand "collab" to instead align with our preferred whole word naming convention.
|
|
110
|
+
* - This is `alpha` instead of `public`.
|
|
111
|
+
* - This is available to drivers due to its location in `driver-definitions` instead of `runtime-definitions`.
|
|
112
|
+
* - This does not allow requesting collaboration with pre-2.0.0 versions, including the special case of `2.0.0-defaults`.
|
|
113
|
+
* - Patch versions cannot be set: a given minor release is not guaranteed to be greater or equal compat wise to all patches of the previous release, so we do not enable features based on patch versions (instead fall back to the next minor if needed).
|
|
114
|
+
* Therefore allowing patch versions here could be misleading and could lead to bugs.
|
|
115
|
+
*
|
|
116
|
+
* @input
|
|
117
|
+
* @alpha
|
|
118
|
+
*/
|
|
119
|
+
export type MinimumVersionForCollaboration = `2.${bigint}.0`;
|
|
120
|
+
/**
|
|
121
|
+
* Strips patch and prerelease from a SemVer string, returning only the major and minor version.
|
|
122
|
+
* @remarks
|
|
123
|
+
* This formats a version in the same style used by {@link MinimumVersionForCollaboration}, specifying only the major and minor versions,
|
|
124
|
+
* which are the portions used for feature selection.
|
|
125
|
+
* @typeParam major - The major version number of `version` as a string, preserved in the result type.
|
|
126
|
+
* @typeParam minor - The minor version number of `version` as a string, preserved in the result type.
|
|
127
|
+
* @privateRemarks
|
|
128
|
+
* This fills a similar role as cleanedPackageVersion in `@fluidframework/runtime-utils`.
|
|
129
|
+
* It can be used to workaround our generated pkgVersion values being invalid `MinimumVersionForCollaboration` on CI (due to prerelease) or patched release branches.
|
|
130
|
+
* @alpha
|
|
131
|
+
*/
|
|
132
|
+
export declare function featureVersion<major extends `${bigint}`, minor extends `${bigint}`>(version: `${major}.${minor}.${bigint}-${string}` | `${major}.${minor}.${bigint}`): `${major}.${minor}.0`;
|
|
133
|
+
/**
|
|
134
|
+
* Options for configuring a {@link ServiceClient}.
|
|
135
|
+
* @remarks
|
|
136
|
+
* These are the options which apply to all services.
|
|
137
|
+
*
|
|
138
|
+
* Individual services will extend with additional options.
|
|
139
|
+
*
|
|
140
|
+
* @input
|
|
141
|
+
* @alpha
|
|
142
|
+
*/
|
|
143
|
+
export interface ServiceOptions {
|
|
144
|
+
readonly minVersionForCollaboration: MinimumVersionForCollaboration;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* A {@link RegistryKey} for a {@link DataStoreKind}.
|
|
148
|
+
* @remarks
|
|
149
|
+
* This is implemented by {@link DataStoreKind}, but alternative implementations can be used if needed.
|
|
150
|
+
*
|
|
151
|
+
* If you want lazy loading and need a key that does not eagerly load the {@link DataStoreKind}, an alternative {@link DataStoreKey} can be implemented.
|
|
152
|
+
* @typeParam T - The type to expose from the {@link DataStoreKind} this key resolves to.
|
|
153
|
+
* @typeParam TAll - The type covering all {@link DataStoreKind}s in the {@link Registry} this key is used with.
|
|
154
|
+
* @privateRemarks
|
|
155
|
+
* TODO: A built in common pattern for the lazy key case should be provided.
|
|
156
|
+
* TODO: things probably break if "adapt" does anything except throw or return the result from the input promise.
|
|
157
|
+
* @input
|
|
158
|
+
* @alpha
|
|
159
|
+
*/
|
|
160
|
+
export type DataStoreKey<T, TAll = unknown> = RegistryKey<Promise<DataStoreKind<T>>, Promise<DataStoreKind<TAll>>>;
|
|
161
|
+
/**
|
|
162
|
+
* A context which has a registry and can create data stores using it.
|
|
163
|
+
* @sealed
|
|
164
|
+
* @alpha
|
|
165
|
+
*/
|
|
166
|
+
export interface DataStoreCreator {
|
|
167
|
+
/**
|
|
168
|
+
* Create a new detached data store `T` which can be attached to the {@link FluidContainer}.
|
|
169
|
+
* by adding a handle to a data store or shared object which is already attached to the {@link FluidContainer}.
|
|
170
|
+
* @remarks
|
|
171
|
+
* `kind` will be looked up in the {@link Registry} used to create or load this {@link DataStoreCreator}.
|
|
172
|
+
* It is up to that registry to decide how it handles unknown types, for example by throwing an exception or returning a placeholder.
|
|
173
|
+
* @typeParam T - type implemented by the data store to expose in the result, as defined by `kind`.
|
|
174
|
+
*/
|
|
175
|
+
createDataStore<T>(kind: DataStoreKey<T>): Promise<T>;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* A Fluid container.
|
|
179
|
+
* @remarks
|
|
180
|
+
* A document which can be stored to or loaded from a Fluid service using a {@link ServiceClient}.
|
|
181
|
+
*
|
|
182
|
+
* @typeParam TData - The type of the container's root data store, exposed via {@link FluidContainer.data}.
|
|
183
|
+
* @privateRemarks
|
|
184
|
+
* This will likely end up needing many of IFluidContainer's APIs, like disconnect, connectionState, events etc.
|
|
185
|
+
* Before adding them though, care should be taken to consider if they can be improved or simplified.
|
|
186
|
+
* For example maybe a single status enum for `detached -> attaching -> dirty -> saved -> closed` would be good.
|
|
187
|
+
* Or maybe `detached -> attaching -> attached -> closed` and a timer for how long since the last unsaved change was created.
|
|
188
|
+
*
|
|
189
|
+
* The underlying IContainer has a lifecycle which includes both a closed and disposed state.
|
|
190
|
+
* This should be avoidable: the closed but not disposed state exists so its possible to read out some state at that time.
|
|
191
|
+
* We have made the close remove all the timers, so the the dispose step should be unnecessary and we can just have a single closed state.
|
|
192
|
+
*
|
|
193
|
+
* @sealed
|
|
194
|
+
* @alpha
|
|
195
|
+
*/
|
|
196
|
+
export interface FluidContainer<TData = unknown> extends DataStoreCreator, ErasedBaseType<readonly ["FluidContainer", TData]> {
|
|
197
|
+
/**
|
|
198
|
+
* The unique identifier for this container within its service.
|
|
199
|
+
* @remarks
|
|
200
|
+
* `undefined` if the container has not yet been attached to a service.
|
|
201
|
+
* This can be used to load another instance of this container from the service using {@link ServiceClient.loadContainer}.
|
|
202
|
+
*/
|
|
203
|
+
readonly id?: string | undefined;
|
|
204
|
+
/**
|
|
205
|
+
* The root data store of the container.
|
|
206
|
+
* @remarks
|
|
207
|
+
* The type of the root data store is defined by the {@link DataStoreKind} used to create the container.
|
|
208
|
+
*/
|
|
209
|
+
readonly data: TData;
|
|
210
|
+
/**
|
|
211
|
+
* Close the container, stopping all networking and cancelling runtime timers.
|
|
212
|
+
*
|
|
213
|
+
* @remarks
|
|
214
|
+
* After calling `close()`, the container's data can still be read but no further operations can be sent.
|
|
215
|
+
* @privateRemarks
|
|
216
|
+
* TODO: we should document the what the expected behavior is if one tries to modify the data after close, or tries to call close multiple times.
|
|
217
|
+
* TODO: we also likely want to have a way to detect if closed and events for on close.
|
|
218
|
+
* TODO: ensure this truly closes all timers: it seems like we might still leak some related to the summarizer.
|
|
219
|
+
* TODO: we should clarify how this interacts with unsaved content including inprogress summaries,
|
|
220
|
+
* and likely also provide an async API with some options for how to handle that.
|
|
221
|
+
*/
|
|
222
|
+
close(): void;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* A Fluid container with an associated {@link ServiceClient} it can attach to.
|
|
226
|
+
* @typeParam TData - The type of the container's root data store.
|
|
227
|
+
* @sealed
|
|
228
|
+
* @alpha
|
|
229
|
+
*/
|
|
230
|
+
export interface FluidContainerWithService<TData = unknown> extends FluidContainer<TData> {
|
|
231
|
+
/**
|
|
232
|
+
* Attaches this container to the associated service client.
|
|
233
|
+
*
|
|
234
|
+
* The returned promise resolves once the container is attached: the container from the promise is the same one passed in as the argument.
|
|
235
|
+
*/
|
|
236
|
+
attach(): Promise<FluidContainerAttached<TData>>;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* A Fluid container that has been attached to a service.
|
|
240
|
+
* @typeParam TData - The type of the container's root data store.
|
|
241
|
+
* @sealed
|
|
242
|
+
* @alpha
|
|
243
|
+
*/
|
|
244
|
+
export interface FluidContainerAttached<TData = unknown> extends FluidContainer<TData> {
|
|
245
|
+
/**
|
|
246
|
+
* {@inheritdoc FluidContainer.id}
|
|
247
|
+
*/
|
|
248
|
+
readonly id: string;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Defines a {@link https://en.wikipedia.org/wiki/Kind_(type_theory) | kind} of data store, allowing creating and loading instances of it.
|
|
252
|
+
* @remarks
|
|
253
|
+
* A `DataStoreKind` acts as the factory and type descriptor for a category of data store:
|
|
254
|
+
* it defines the `type` used to identify the data store in a {@link DataStoreRegistry},
|
|
255
|
+
* and the `T` API surface that instances of that data store expose.
|
|
256
|
+
*
|
|
257
|
+
* Provide a `DataStoreKind` to {@link ServiceClient.(createContainer:1)} or {@link DataStoreCreator.createDataStore}
|
|
258
|
+
* to create new instances, and to {@link ServiceClient.loadContainer} to load existing ones.
|
|
259
|
+
*
|
|
260
|
+
* A `DataStoreKind` is not constructed directly.
|
|
261
|
+
* Instead, obtain one from a framework-provided factory:
|
|
262
|
+
* use {@link @fluidframework/shared-object-base#defineDataStore} to define a data store which wraps a root shared object,
|
|
263
|
+
* or use a more specific wrapper around that,
|
|
264
|
+
* such as {@link @fluidframework/tree#defineTreeDataStore} for a {@link @fluidframework/tree#TreeView}-backed data store.
|
|
265
|
+
*
|
|
266
|
+
* Since it implements {@link DataStoreKey}, a `DataStoreKind` can also be used directly as the key to look
|
|
267
|
+
* itself up in a {@link Registry}.
|
|
268
|
+
* @typeParam T - The API surface that instances of this data store kind expose.
|
|
269
|
+
* @privateRemarks
|
|
270
|
+
* TODO:
|
|
271
|
+
* SharedObjects should be usable as these (though putting shared objects directly in the container might need special logic).
|
|
272
|
+
* Type erased {@link IFluidDataStoreFactory}.
|
|
273
|
+
* @sealed
|
|
274
|
+
* @alpha
|
|
275
|
+
*/
|
|
276
|
+
export interface DataStoreKind<out T = unknown> extends DataStoreKey<T>, ErasedBaseType<readonly ["DataStoreKind", T]> {
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* A registry of {@link DataStoreKind}s.
|
|
280
|
+
* @privateRemarks
|
|
281
|
+
* TODO: unify this with SharedObjectRegistry.
|
|
282
|
+
*
|
|
283
|
+
* @typeParam T - The type covering all {@link DataStoreKind}s in the registry.
|
|
284
|
+
* @input
|
|
285
|
+
* @alpha
|
|
286
|
+
*/
|
|
287
|
+
export type DataStoreRegistry<out T = unknown> = Registry<Promise<DataStoreKind<T>>>;
|
|
288
|
+
/**
|
|
289
|
+
* A connection to a Fluid storage service.
|
|
290
|
+
* @sealed
|
|
291
|
+
* @alpha
|
|
292
|
+
*/
|
|
293
|
+
export interface ServiceClient {
|
|
294
|
+
/**
|
|
295
|
+
* Creates a detached container associated with this service client.
|
|
296
|
+
* @typeParam T - The type of the container's root data store, as defined by `root`.
|
|
297
|
+
* @param root - A {@link DataStoreKind} to use for the root.
|
|
298
|
+
* @remarks
|
|
299
|
+
* This overload is a shorthand for a simple case of {@link ServiceClient.(createContainer:2)}
|
|
300
|
+
* where a single item registry is produced which contains only the root.
|
|
301
|
+
* This is usable only when the root {@link DataStoreKind} is available eagerly (e.g. not lazy loaded),
|
|
302
|
+
* and when the container does not need a registry for creating additional data stores beyond the root.
|
|
303
|
+
* @privateRemarks
|
|
304
|
+
* TODO: As this is a detached container, it should be able to be created synchronously.
|
|
305
|
+
*
|
|
306
|
+
* TODO: Provide more general alternative to this in the form of a service-independent `createContainer` free function.
|
|
307
|
+
* It would work with a `ServiceClient.attachContainer<T>(detached: FluidContainer<T>): Promise<FluidContainerAttached<T>>`
|
|
308
|
+
* which returns a promise that resolves once the detached container has been attached
|
|
309
|
+
* (pointing to the same container object, but with the new type).
|
|
310
|
+
*
|
|
311
|
+
* Challenges:
|
|
312
|
+
*
|
|
313
|
+
* Currently the service must be provided at creation time because `IContainer.attach` does not accept a service client,
|
|
314
|
+
* making it unclear whether a truly service-independent path is feasible in the near term.
|
|
315
|
+
*/
|
|
316
|
+
createContainer<T>(root: DataStoreKind<T>): Promise<FluidContainerWithService<T>>;
|
|
317
|
+
/**
|
|
318
|
+
* Creates a detached container associated with this service client.
|
|
319
|
+
* @typeParam T - The type of the container's root data store, as defined by `root`.
|
|
320
|
+
* @param root - A {@link DataStoreKey} used to look up the root's {@link DataStoreKind} from `registry`.
|
|
321
|
+
* @param registry - The {@link DataStoreRegistry} supplying the {@link DataStoreKind} for the root and any other data stores the container may need to create.
|
|
322
|
+
* @remarks
|
|
323
|
+
* Use this overload when the root {@link DataStoreKind} is not available eagerly (e.g. for lazy loading),
|
|
324
|
+
* or when the container needs a registry for creating additional data stores beyond the root.
|
|
325
|
+
*/
|
|
326
|
+
createContainer<T>(root: DataStoreKey<T>, registry: DataStoreRegistry): Promise<FluidContainerWithService<T>>;
|
|
327
|
+
/**
|
|
328
|
+
* Loads an existing container from the service.
|
|
329
|
+
* @typeParam T - The type of the container's root data store.
|
|
330
|
+
* @param id - The unique identifier of the container to load.
|
|
331
|
+
* @param root - The {@link DataStoreKind} for the root, or a registry which will be used to look up the root based on its type.
|
|
332
|
+
*
|
|
333
|
+
* @throws a {@link @fluidframework/telemetry-utils#UsageError} if the DataStoreKind's type (either the root directly or looked up from the registry) does not match the type of the root data store in the container.
|
|
334
|
+
*
|
|
335
|
+
* @privateRemarks
|
|
336
|
+
* The ability to provide a registry here means that it's possible to:
|
|
337
|
+
* 1. Load a container which might have a few different possible roots, for example because of versioning.
|
|
338
|
+
* 2. Generate the DataStoreKind on demand based on the type: this approach could be used for things like debug tools which can load any possible container.
|
|
339
|
+
* 3. Generating the DataStoreKind if the type is unrecognized, for example to provide a placeholder which might support some minimal functionality (like debug inspection, and summary).
|
|
340
|
+
*
|
|
341
|
+
* The ability to provide just a single DataStoreKind<T> is purely a convenience to make it cleaner to use this in simple cases.
|
|
342
|
+
*/
|
|
343
|
+
loadContainer<T>(id: string, root: DataStoreKind<T> | DataStoreRegistry<T>): Promise<FluidContainerAttached<T>>;
|
|
344
|
+
}
|
|
345
|
+
//# sourceMappingURL=serviceClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serviceClient.d.ts","sourceRoot":"","sources":["../src/serviceClient.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC,CAAC;AAE9C;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,WAAW,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO;IAC/C;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;;;;;;;;OAUG;IACH,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,GAAG,EACzC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,EACvB,GAAG,EAAE,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,GACzB,IAAI,CAEN;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAKzE;AAMD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,8BAA8B,GAAG,KAAK,MAAM,IAAI,CAAC;AAE7D;;;;;;;;;;;GAW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copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.featureVersion = exports.createBasicRegistryKey = exports.lookupInRegistry = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Lookup an entry in a {@link Registry} using a {@link RegistryKey}.
|
|
10
|
+
* @typeParam TOut - The type produced from the looked-up entry.
|
|
11
|
+
* @typeParam TIn - The type of the entries in `registry`.
|
|
12
|
+
* @alpha
|
|
13
|
+
*/
|
|
14
|
+
function lookupInRegistry(registry, key) {
|
|
15
|
+
return key.adapt(registry(key.type));
|
|
16
|
+
}
|
|
17
|
+
exports.lookupInRegistry = lookupInRegistry;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a simple {@link RegistryKey} which does no type conversion.
|
|
20
|
+
* @typeParam T - The type of the registry entry, which is returned unchanged by the key.
|
|
21
|
+
* @alpha
|
|
22
|
+
*/
|
|
23
|
+
function createBasicRegistryKey(type) {
|
|
24
|
+
return {
|
|
25
|
+
type,
|
|
26
|
+
adapt: (value) => value,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.createBasicRegistryKey = createBasicRegistryKey;
|
|
30
|
+
/**
|
|
31
|
+
* Strips patch and prerelease from a SemVer string, returning only the major and minor version.
|
|
32
|
+
* @remarks
|
|
33
|
+
* This formats a version in the same style used by {@link MinimumVersionForCollaboration}, specifying only the major and minor versions,
|
|
34
|
+
* which are the portions used for feature selection.
|
|
35
|
+
* @typeParam major - The major version number of `version` as a string, preserved in the result type.
|
|
36
|
+
* @typeParam minor - The minor version number of `version` as a string, preserved in the result type.
|
|
37
|
+
* @privateRemarks
|
|
38
|
+
* This fills a similar role as cleanedPackageVersion in `@fluidframework/runtime-utils`.
|
|
39
|
+
* It can be used to workaround our generated pkgVersion values being invalid `MinimumVersionForCollaboration` on CI (due to prerelease) or patched release branches.
|
|
40
|
+
* @alpha
|
|
41
|
+
*/
|
|
42
|
+
function featureVersion(version) {
|
|
43
|
+
// The SemVer package could be used to parse this version, but it wouldn't gain us anything, and would just make it harder to determine that the down casting below is valid.
|
|
44
|
+
// Since we have a strongly typed string input, we know exactly which formats are allowed, so we don't need its more general parsing and validation either.
|
|
45
|
+
// If we wanted to preserve the patch or prerelease version, that would require more complex parsing and would justify using the SemVer package, but we don't need that here.
|
|
46
|
+
const parsed = version.split(".");
|
|
47
|
+
return `${parsed[0]}.${parsed[1]}.0`;
|
|
48
|
+
}
|
|
49
|
+
exports.featureVersion = featureVersion;
|
|
50
|
+
// #endregion
|
|
51
|
+
//# sourceMappingURL=serviceClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serviceClient.js","sourceRoot":"","sources":["../src/serviceClient.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAsFH;;;;;GAKG;AACH,SAAgB,gBAAgB,CAC/B,QAAuB,EACvB,GAA2B;IAE3B,OAAO,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AACtC,CAAC;AALD,4CAKC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB,CAAI,IAAY;IACrD,OAAO;QACN,IAAI;QACJ,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK;KACvB,CAAC;AACH,CAAC;AALD,wDAKC;AAgCD;;;;;;;;;;;GAWG;AACH,SAAgB,cAAc,CAC7B,OAAgF;IAEhF,6KAA6K;IAC7K,2JAA2J;IAC3J,6KAA6K;IAC7K,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,GAAG,MAAM,CAAC,CAAC,CAAU,IAAI,MAAM,CAAC,CAAC,CAAU,IAAI,CAAC;AACxD,CAAC;AARD,wCAQC;AAiPD,aAAa","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ErasedBaseType } from \"@fluidframework/core-interfaces/internal\";\n\n/**\n * This file defines the external facing API for the {@link ServiceClient} and related types.\n *\n * It provides an API surface at a similar abstraction level to aqueduct and fluid-static, but is intended to be a replacement for those which solves several problems with them.\n * Mainly it strives to have the encapsulation of implementation details (including all legacy APIs from aqueduct and lower level internals) like fluid-static\n * while being both more flexible and simpler.\n *\n * This aims to be the cleanest practical way to build applications on the Fluid Framework Client.\n * There are however several known cases where the API quality was sacrificed to ease initial implementation,\n * since some of the unification desired in this API's design are not yet implemented in the underlying Fluid Framework Client code or require additional work to implement.\n * These cases are called out with TODOs in this file.\n * These should be considered and addressed before stabilizing this API past alpha.\n *\n * All code interacting through this API surface within a single client must avoid using multiple copies of any Fluid Framework client package (at the same or different versions).\n * This mirrors the `@public` \"declarative model\" APIs and is a deliberate simplification of what is allowed in the legacy API surface.\n * It is enforced best-effort only: `@sealed` nominal erased types catch many mismatches at compile time, and factory identity checks throw a UsageError (\"Conflicting ... with same type\") at run time, but the checking is not exhaustive.\n * See `LayerCompatibilityUnified.md` for the full policy, rationale, and failure signatures.\n *\n * TODO:\n * Before stabilizing any of this past beta, evaluate whether this single-copy requirement must be relaxed, and if so how.\n * Whatever rule is chosen (relaxed or not) should be enforced at both compile time and run time as much as possible.\n *\n * TODO:\n * Fault isolation should be considered in this API design.\n * When are exceptions recoverable and how?\n * Likely we can fault isolate exceptions to containers in most cases,\n * and containers can indicate their status by being closed or disposed.\n * Non fatal errors should not be exceptions.\n */\n\n// #region Registry types\n\n/**\n * A collection of entries looked up by a `type` string.\n * @remarks\n * Use of a function for this allows a few things that most collections would not:\n * 1. It's possible to generate placeholder / error values on demand.\n * 2. It makes loading from some external registry on demand practical.\n * 3. The lookup can throw an exception if appropriate (this would typically indicate a bug and produce a fatal error).\n * 4. Generation of values can be lazy, and even asynchronous if `T` allows for a promise.\n *\n * This flexibility lets the implementer decide how to handle requests for unknown types.\n * They can produce placeholders, assert, fall back to a generic implementation etc.\n * @typeParam T - The type of entry produced for any given `type` string.\n * @input\n * @alpha\n */\nexport type Registry<T> = (type: string) => T;\n\n/**\n * A strongly typed key for a {@link Registry}.\n * Use with {@link lookupInRegistry}.\n * @remarks\n * Used to look up a `TIn` in a `Registry<TIn>`, and produce a `TOut` from it.\n * @typeParam TOut - The type produced by {@link RegistryKey.adapt} from a looked-up entry.\n * @typeParam TIn - The type of the entries in the {@link Registry} this key is used with.\n * @privateRemarks\n * This is currently input and sealed, meaning effectively type erased since the design might change.\n * @input\n * @sealed\n * @alpha\n */\nexport interface RegistryKey<TOut, TIn = unknown> {\n\t/**\n\t * Identifier to provide to the {@link Registry}.\n\t */\n\treadonly type: string;\n\n\t/**\n\t * Convert a value from the registry to the desired output type.\n\t * @remarks\n\t * How this is done is up to the implementation.\n\t *\n\t * This might be a type guard which throws if the input is not valid.\n\t * Or it could be a conversion, an identity function, or something else.\n\t *\n\t * @param value - The value from the registry.\n\t * @returns The converted value.\n\t */\n\tadapt(value: TIn): TOut;\n}\n\n/**\n * Lookup an entry in a {@link Registry} using a {@link RegistryKey}.\n * @typeParam TOut - The type produced from the looked-up entry.\n * @typeParam TIn - The type of the entries in `registry`.\n * @alpha\n */\nexport function lookupInRegistry<TOut, TIn>(\n\tregistry: Registry<TIn>,\n\tkey: RegistryKey<TOut, TIn>,\n): TOut {\n\treturn key.adapt(registry(key.type));\n}\n\n/**\n * Creates a simple {@link RegistryKey} which does no type conversion.\n * @typeParam T - The type of the registry entry, which is returned unchanged by the key.\n * @alpha\n */\nexport function createBasicRegistryKey<T>(type: string): RegistryKey<T, T> {\n\treturn {\n\t\ttype,\n\t\tadapt: (value) => value,\n\t};\n}\n\n// #endregion\n\n// #region ServiceClient types\n\n/**\n * Oldest version of Fluid Framework client packages to support collaborating with.\n * @remarks\n * A string in SemVer format indicating a specific version of the Fluid Framework client package, or the special case of {@link @fluidframework/runtime-utils#defaultMinVersionForCollab}.\n *\n * Collaboration with other clients is only supported when all Fluid Framework client packages used by the client have a version that is greater than or equal\n * to the specified `MinimumVersionForCollaboration`.\n *\n * Cannot exceed the version of any Fluid Framework client package in use by the local client.\n *\n * The higher the version specified, the more features and optimizations will be enabled. *\n * @privateRemarks\n * This is similar to, and a subset of, the `MinimumVersionForCollab` type in `@fluidframework/runtime-definitions`.\n * This differs in that:\n * - This avoids the shorthand \"collab\" to instead align with our preferred whole word naming convention.\n * - This is `alpha` instead of `public`.\n * - This is available to drivers due to its location in `driver-definitions` instead of `runtime-definitions`.\n * - This does not allow requesting collaboration with pre-2.0.0 versions, including the special case of `2.0.0-defaults`.\n * - Patch versions cannot be set: a given minor release is not guaranteed to be greater or equal compat wise to all patches of the previous release, so we do not enable features based on patch versions (instead fall back to the next minor if needed).\n * Therefore allowing patch versions here could be misleading and could lead to bugs.\n *\n * @input\n * @alpha\n */\nexport type MinimumVersionForCollaboration = `2.${bigint}.0`;\n\n/**\n * Strips patch and prerelease from a SemVer string, returning only the major and minor version.\n * @remarks\n * This formats a version in the same style used by {@link MinimumVersionForCollaboration}, specifying only the major and minor versions,\n * which are the portions used for feature selection.\n * @typeParam major - The major version number of `version` as a string, preserved in the result type.\n * @typeParam minor - The minor version number of `version` as a string, preserved in the result type.\n * @privateRemarks\n * This fills a similar role as cleanedPackageVersion in `@fluidframework/runtime-utils`.\n * It can be used to workaround our generated pkgVersion values being invalid `MinimumVersionForCollaboration` on CI (due to prerelease) or patched release branches.\n * @alpha\n */\nexport function featureVersion<major extends `${bigint}`, minor extends `${bigint}`>(\n\tversion: `${major}.${minor}.${bigint}-${string}` | `${major}.${minor}.${bigint}`,\n): `${major}.${minor}.0` {\n\t// The SemVer package could be used to parse this version, but it wouldn't gain us anything, and would just make it harder to determine that the down casting below is valid.\n\t// Since we have a strongly typed string input, we know exactly which formats are allowed, so we don't need its more general parsing and validation either.\n\t// If we wanted to preserve the patch or prerelease version, that would require more complex parsing and would justify using the SemVer package, but we don't need that here.\n\tconst parsed = version.split(\".\");\n\treturn `${parsed[0] as major}.${parsed[1] as minor}.0`;\n}\n\n/**\n * Options for configuring a {@link ServiceClient}.\n * @remarks\n * These are the options which apply to all services.\n *\n * Individual services will extend with additional options.\n *\n * @input\n * @alpha\n */\nexport interface ServiceOptions {\n\treadonly minVersionForCollaboration: MinimumVersionForCollaboration;\n}\n\n/**\n * A {@link RegistryKey} for a {@link DataStoreKind}.\n * @remarks\n * This is implemented by {@link DataStoreKind}, but alternative implementations can be used if needed.\n *\n * If you want lazy loading and need a key that does not eagerly load the {@link DataStoreKind}, an alternative {@link DataStoreKey} can be implemented.\n * @typeParam T - The type to expose from the {@link DataStoreKind} this key resolves to.\n * @typeParam TAll - The type covering all {@link DataStoreKind}s in the {@link Registry} this key is used with.\n * @privateRemarks\n * TODO: A built in common pattern for the lazy key case should be provided.\n * TODO: things probably break if \"adapt\" does anything except throw or return the result from the input promise.\n * @input\n * @alpha\n */\nexport type DataStoreKey<T, TAll = unknown> = RegistryKey<\n\tPromise<DataStoreKind<T>>,\n\tPromise<DataStoreKind<TAll>>\n>;\n\n/**\n * A context which has a registry and can create data stores using it.\n * @sealed\n * @alpha\n */\nexport interface DataStoreCreator {\n\t/**\n\t * Create a new detached data store `T` which can be attached to the {@link FluidContainer}.\n\t * by adding a handle to a data store or shared object which is already attached to the {@link FluidContainer}.\n\t * @remarks\n\t * `kind` will be looked up in the {@link Registry} used to create or load this {@link DataStoreCreator}.\n\t * It is up to that registry to decide how it handles unknown types, for example by throwing an exception or returning a placeholder.\n\t * @typeParam T - type implemented by the data store to expose in the result, as defined by `kind`.\n\t */\n\tcreateDataStore<T>(kind: DataStoreKey<T>): Promise<T>;\n}\n\n/**\n * A Fluid container.\n * @remarks\n * A document which can be stored to or loaded from a Fluid service using a {@link ServiceClient}.\n *\n * @typeParam TData - The type of the container's root data store, exposed via {@link FluidContainer.data}.\n * @privateRemarks\n * This will likely end up needing many of IFluidContainer's APIs, like disconnect, connectionState, events etc.\n * Before adding them though, care should be taken to consider if they can be improved or simplified.\n * For example maybe a single status enum for `detached -> attaching -> dirty -> saved -> closed` would be good.\n * Or maybe `detached -> attaching -> attached -> closed` and a timer for how long since the last unsaved change was created.\n *\n * The underlying IContainer has a lifecycle which includes both a closed and disposed state.\n * This should be avoidable: the closed but not disposed state exists so its possible to read out some state at that time.\n * We have made the close remove all the timers, so the the dispose step should be unnecessary and we can just have a single closed state.\n *\n * @sealed\n * @alpha\n */\nexport interface FluidContainer<TData = unknown>\n\textends DataStoreCreator,\n\t\tErasedBaseType<readonly [\"FluidContainer\", TData]> {\n\t/**\n\t * The unique identifier for this container within its service.\n\t * @remarks\n\t * `undefined` if the container has not yet been attached to a service.\n\t * This can be used to load another instance of this container from the service using {@link ServiceClient.loadContainer}.\n\t */\n\treadonly id?: string | undefined;\n\n\t/**\n\t * The root data store of the container.\n\t * @remarks\n\t * The type of the root data store is defined by the {@link DataStoreKind} used to create the container.\n\t */\n\treadonly data: TData;\n\n\t/**\n\t * Close the container, stopping all networking and cancelling runtime timers.\n\t *\n\t * @remarks\n\t * After calling `close()`, the container's data can still be read but no further operations can be sent.\n\t * @privateRemarks\n\t * TODO: we should document the what the expected behavior is if one tries to modify the data after close, or tries to call close multiple times.\n\t * TODO: we also likely want to have a way to detect if closed and events for on close.\n\t * TODO: ensure this truly closes all timers: it seems like we might still leak some related to the summarizer.\n\t * TODO: we should clarify how this interacts with unsaved content including inprogress summaries,\n\t * and likely also provide an async API with some options for how to handle that.\n\t */\n\tclose(): void;\n}\n\n/**\n * A Fluid container with an associated {@link ServiceClient} it can attach to.\n * @typeParam TData - The type of the container's root data store.\n * @sealed\n * @alpha\n */\nexport interface FluidContainerWithService<TData = unknown> extends FluidContainer<TData> {\n\t/**\n\t * Attaches this container to the associated service client.\n\t *\n\t * The returned promise resolves once the container is attached: the container from the promise is the same one passed in as the argument.\n\t */\n\tattach(): Promise<FluidContainerAttached<TData>>;\n\n\t// This could expose access to the ServiceClient if needed.\n}\n\n/**\n * A Fluid container that has been attached to a service.\n * @typeParam TData - The type of the container's root data store.\n * @sealed\n * @alpha\n */\nexport interface FluidContainerAttached<TData = unknown> extends FluidContainer<TData> {\n\t/**\n\t * {@inheritdoc FluidContainer.id}\n\t */\n\treadonly id: string;\n}\n\n/**\n * Defines a {@link https://en.wikipedia.org/wiki/Kind_(type_theory) | kind} of data store, allowing creating and loading instances of it.\n * @remarks\n * A `DataStoreKind` acts as the factory and type descriptor for a category of data store:\n * it defines the `type` used to identify the data store in a {@link DataStoreRegistry},\n * and the `T` API surface that instances of that data store expose.\n *\n * Provide a `DataStoreKind` to {@link ServiceClient.(createContainer:1)} or {@link DataStoreCreator.createDataStore}\n * to create new instances, and to {@link ServiceClient.loadContainer} to load existing ones.\n *\n * A `DataStoreKind` is not constructed directly.\n * Instead, obtain one from a framework-provided factory:\n * use {@link @fluidframework/shared-object-base#defineDataStore} to define a data store which wraps a root shared object,\n * or use a more specific wrapper around that,\n * such as {@link @fluidframework/tree#defineTreeDataStore} for a {@link @fluidframework/tree#TreeView}-backed data store.\n *\n * Since it implements {@link DataStoreKey}, a `DataStoreKind` can also be used directly as the key to look\n * itself up in a {@link Registry}.\n * @typeParam T - The API surface that instances of this data store kind expose.\n * @privateRemarks\n * TODO:\n * SharedObjects should be usable as these (though putting shared objects directly in the container might need special logic).\n * Type erased {@link IFluidDataStoreFactory}.\n * @sealed\n * @alpha\n */\nexport interface DataStoreKind<out T = unknown>\n\textends DataStoreKey<T>,\n\t\tErasedBaseType<readonly [\"DataStoreKind\", T]> {}\n\n/**\n * A registry of {@link DataStoreKind}s.\n * @privateRemarks\n * TODO: unify this with SharedObjectRegistry.\n *\n * @typeParam T - The type covering all {@link DataStoreKind}s in the registry.\n * @input\n * @alpha\n */\nexport type DataStoreRegistry<out T = unknown> = Registry<Promise<DataStoreKind<T>>>;\n\n/**\n * A connection to a Fluid storage service.\n * @sealed\n * @alpha\n */\nexport interface ServiceClient {\n\t/**\n\t * Creates a detached container associated with this service client.\n\t * @typeParam T - The type of the container's root data store, as defined by `root`.\n\t * @param root - A {@link DataStoreKind} to use for the root.\n\t * @remarks\n\t * This overload is a shorthand for a simple case of {@link ServiceClient.(createContainer:2)}\n\t * where a single item registry is produced which contains only the root.\n\t * This is usable only when the root {@link DataStoreKind} is available eagerly (e.g. not lazy loaded),\n\t * and when the container does not need a registry for creating additional data stores beyond the root.\n\t * @privateRemarks\n\t * TODO: As this is a detached container, it should be able to be created synchronously.\n\t *\n\t * TODO: Provide more general alternative to this in the form of a service-independent `createContainer` free function.\n\t * It would work with a `ServiceClient.attachContainer<T>(detached: FluidContainer<T>): Promise<FluidContainerAttached<T>>`\n\t * which returns a promise that resolves once the detached container has been attached\n\t * (pointing to the same container object, but with the new type).\n\t *\n\t * Challenges:\n\t *\n\t * Currently the service must be provided at creation time because `IContainer.attach` does not accept a service client,\n\t * making it unclear whether a truly service-independent path is feasible in the near term.\n\t */\n\tcreateContainer<T>(root: DataStoreKind<T>): Promise<FluidContainerWithService<T>>;\n\n\t/**\n\t * Creates a detached container associated with this service client.\n\t * @typeParam T - The type of the container's root data store, as defined by `root`.\n\t * @param root - A {@link DataStoreKey} used to look up the root's {@link DataStoreKind} from `registry`.\n\t * @param registry - The {@link DataStoreRegistry} supplying the {@link DataStoreKind} for the root and any other data stores the container may need to create.\n\t * @remarks\n\t * Use this overload when the root {@link DataStoreKind} is not available eagerly (e.g. for lazy loading),\n\t * or when the container needs a registry for creating additional data stores beyond the root.\n\t */\n\tcreateContainer<T>(\n\t\troot: DataStoreKey<T>,\n\t\tregistry: DataStoreRegistry,\n\t): Promise<FluidContainerWithService<T>>;\n\n\t/**\n\t * Loads an existing container from the service.\n\t * @typeParam T - The type of the container's root data store.\n\t * @param id - The unique identifier of the container to load.\n\t * @param root - The {@link DataStoreKind} for the root, or a registry which will be used to look up the root based on its type.\n\t *\n\t * @throws a {@link @fluidframework/telemetry-utils#UsageError} if the DataStoreKind's type (either the root directly or looked up from the registry) does not match the type of the root data store in the container.\n\t *\n\t * @privateRemarks\n\t * The ability to provide a registry here means that it's possible to:\n\t * 1. Load a container which might have a few different possible roots, for example because of versioning.\n\t * 2. Generate the DataStoreKind on demand based on the type: this approach could be used for things like debug tools which can load any possible container.\n\t * 3. Generating the DataStoreKind if the type is unrecognized, for example to provide a placeholder which might support some minimal functionality (like debug inspection, and summary).\n\t *\n\t * The ability to provide just a single DataStoreKind<T> is purely a convenience to make it cleaner to use this in simple cases.\n\t */\n\tloadContainer<T>(\n\t\tid: string,\n\t\troot: DataStoreKind<T> | DataStoreRegistry<T>,\n\t): Promise<FluidContainerAttached<T>>;\n}\n\n// #endregion\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -12,4 +12,6 @@ export { DriverHeader } from "./urlResolver.js";
|
|
|
12
12
|
export type { ConnectionMode, IApprovedProposal, IAttachment, IBlob, IBranchOrigin, ICapabilities, IClient, IClientConfiguration, IClientDetails, IClientJoin, ICommittedProposal, IConnect, IConnected, ICreateBlobResponse, IDocumentAttributes, IDocumentMessage, IDocumentSystemMessage, INack, INackContent, IProcessMessageResult, IProposal, IProtocolState, IQuorum, IQuorumClients, IQuorumProposals, ISentSignalMessage, ISequencedClient, ISequencedDocumentAugmentedMessage, ISequencedDocumentMessage, ISequencedDocumentMessageExperimental, ISequencedDocumentSystemMessage, ISequencedProposal, IServerError, ISignalClient, ISignalMessage, ISignalMessageBase, ISnapshotTree, ISnapshotTreeEx, IsoDate, ISummaryAck, ISummaryAttachment, ISummaryBlob, ISummaryContent, ISummaryHandle, ISummaryNack, ISummaryProposal, ISummaryTree, ITokenClaims, ITrace, ITree, ITreeEntry, IUploadedSummaryDetails, IUser, IVersion, SummaryObject, SummaryTree, SummaryTypeNoHandle, } from "./protocol/index.js";
|
|
13
13
|
export { FileMode, MessageType, NackErrorType, ScopeType, SignalType, SummaryType, TreeEntry, } from "./protocol/index.js";
|
|
14
14
|
export type { IGitAuthor, IGitBlob, IGitCommitDetails, IGitCommitHash, IGitCommitter, IGitCreateBlobParams, IGitCreateBlobResponse, IGitCreateTreeEntry, IGitCreateTreeParams, IGitTree, IGitTreeEntry, } from "./git/index.js";
|
|
15
|
+
export type { DataStoreCreator, DataStoreKey, DataStoreKind, DataStoreRegistry, FluidContainer, FluidContainerAttached, FluidContainerWithService, MinimumVersionForCollaboration, Registry, RegistryKey, ServiceClient, ServiceOptions, } from "./serviceClient.js";
|
|
16
|
+
export { createBasicRegistryKey, lookupInRegistry, featureVersion } from "./serviceClient.js";
|
|
15
17
|
//# 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,YAAY,EACX,WAAW,EACX,MAAM,EACN,UAAU,EACV,eAAe,GACf,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACX,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,YAAY,EACX,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,8BAA8B,EAC9B,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,uBAAuB,EACvB,+BAA+B,EAC/B,SAAS,EACT,qBAAqB,EACrB,OAAO,EACP,aAAa,EACb,eAAe,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAChE,YAAY,EACX,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,YAAY,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,YAAY,EACX,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,KAAK,EACL,aAAa,EACb,aAAa,EACb,OAAO,EACP,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,KAAK,EACL,YAAY,EACZ,qBAAqB,EACrB,SAAS,EACT,cAAc,EACd,OAAO,EACP,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,kCAAkC,EAClC,yBAAyB,EACzB,qCAAqC,EACrC,+BAA+B,EAC/B,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,OAAO,EACP,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,MAAM,EACN,KAAK,EACL,UAAU,EACV,uBAAuB,EACvB,KAAK,EACL,QAAQ,EACR,aAAa,EACb,WAAW,EACX,mBAAmB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,QAAQ,EACR,WAAW,EACX,aAAa,EACb,SAAS,EACT,UAAU,EACV,WAAW,EACX,SAAS,GACT,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACX,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,QAAQ,EACR,aAAa,GACb,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY,EACX,WAAW,EACX,MAAM,EACN,UAAU,EACV,eAAe,GACf,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACX,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,oBA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,UAAU,EACV,uBAAuB,EACvB,KAAK,EACL,QAAQ,EACR,aAAa,EACb,WAAW,EACX,mBAAmB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,QAAQ,EACR,WAAW,EACX,aAAa,EACb,SAAS,EACT,UAAU,EACV,WAAW,EACX,SAAS,GACT,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACX,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,QAAQ,EACR,aAAa,GACb,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACX,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,sBAAsB,EACtB,yBAAyB,EACzB,8BAA8B,EAC9B,QAAQ,EACR,WAAW,EACX,aAAa,EACb,cAAc,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -6,4 +6,5 @@ export { DriverErrorTypes } from "./driverError.js";
|
|
|
6
6
|
export { FetchSource, LoaderCachingPolicy } from "./storage.js";
|
|
7
7
|
export { DriverHeader } from "./urlResolver.js";
|
|
8
8
|
export { FileMode, MessageType, NackErrorType, ScopeType, SignalType, SummaryType, TreeEntry, } from "./protocol/index.js";
|
|
9
|
+
export { createBasicRegistryKey, lookupInRegistry, featureVersion } from "./serviceClient.js";
|
|
9
10
|
//# sourceMappingURL=index.js.map
|