@fluidframework/runtime-definitions 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.225277
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/.eslintrc.cjs +12 -0
- package/CHANGELOG.md +330 -0
- package/README.md +43 -7
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/runtime-definitions.api.md +474 -0
- package/dist/attribution.d.ts +71 -0
- package/dist/attribution.d.ts.map +1 -0
- package/dist/attribution.js +7 -0
- package/dist/attribution.js.map +1 -0
- package/dist/dataStoreContext.d.ts +114 -61
- package/dist/dataStoreContext.d.ts.map +1 -1
- package/dist/dataStoreContext.js +27 -5
- package/dist/dataStoreContext.js.map +1 -1
- package/dist/dataStoreFactory.d.ts +7 -0
- package/dist/dataStoreFactory.d.ts.map +1 -1
- package/dist/dataStoreFactory.js +3 -0
- package/dist/dataStoreFactory.js.map +1 -1
- package/dist/dataStoreRegistry.d.ts +14 -4
- package/dist/dataStoreRegistry.d.ts.map +1 -1
- package/dist/dataStoreRegistry.js +3 -0
- package/dist/dataStoreRegistry.js.map +1 -1
- package/dist/garbageCollection.d.ts +35 -10
- package/dist/garbageCollection.d.ts.map +1 -1
- package/dist/garbageCollection.js +25 -3
- package/dist/garbageCollection.js.map +1 -1
- package/dist/index.d.ts +52 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -16
- package/dist/index.js.map +1 -1
- package/dist/protocol.d.ts +10 -3
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js.map +1 -1
- package/dist/runtime-definitions-alpha.d.ts +993 -0
- package/dist/runtime-definitions-beta.d.ts +264 -0
- package/dist/runtime-definitions-public.d.ts +264 -0
- package/dist/runtime-definitions-untrimmed.d.ts +1068 -0
- package/dist/summary.d.ts +138 -70
- package/dist/summary.d.ts.map +1 -1
- package/dist/summary.js +13 -1
- package/dist/summary.js.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/package.json +100 -40
- package/prettier.config.cjs +8 -0
- package/src/aliasing.md +42 -0
- package/src/attribution.ts +78 -0
- package/src/dataStoreContext.ts +432 -388
- package/src/dataStoreFactory.ts +21 -11
- package/src/dataStoreRegistry.ts +18 -6
- package/src/garbageCollection.ts +38 -15
- package/src/index.ts +111 -6
- package/src/protocol.ts +46 -38
- package/src/summary.ts +298 -225
- package/tsconfig.json +10 -12
- package/.eslintrc.js +0 -13
package/src/aliasing.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Aliasing and root datastores
|
|
2
|
+
|
|
3
|
+
## What is a root datastore? What is an aliased datastore?
|
|
4
|
+
|
|
5
|
+
A root datastore is a datastore which is addressable by a custom identifier (client supplied) and is a direct child of the container runtime. A root datastore will never be garbage collected and it is a singleton with regards to the runtime it belongs to. The concept of a root datastore is considered legacy, mainly due to the previous (deprecated and removed) APIs which referred to such datastores as root. 'Aliased datastore' is the preferred current term to refer to such datastores.
|
|
6
|
+
|
|
7
|
+
## When to alias datastores?
|
|
8
|
+
|
|
9
|
+
Alias needs to happen for datastores which:
|
|
10
|
+
|
|
11
|
+
- must be referenced by a custom id
|
|
12
|
+
- must never be garbage collected (as they are bound to a custom id which may be stored by the client, they must always be available to be referenced)
|
|
13
|
+
- must be singletons in the container
|
|
14
|
+
|
|
15
|
+
Creating root datastores was vulnerable to name conflicts, as two clients attempting to create the same root datastore with the same id risks corrupting the document. Aliasing changed the way to achieve the same goal, by enabling an asynchronous 'aliasing' operation on any newly created datastore. So in order to create such a datastore, the client needs to create an anonymous datastore (which will receive a newly generated UUID) and then explicitly attempt to bind it to a custom id (the alias) within a different operation which is decoupled from its creation.
|
|
16
|
+
|
|
17
|
+
## Aliasing API
|
|
18
|
+
|
|
19
|
+
The process of aliasing a datastore is split in two parts:
|
|
20
|
+
|
|
21
|
+
- Creating a regular datastore using the `IContainerRuntimeBase.createDataStore(pkg: string | string[]): Promise<IDataStore>` function
|
|
22
|
+
- Aliasing the resulting datastore by using the `IDataStore.trySetAlias(alias: string): Promise<AliasResult>` function and specifying a string value to serve as the alias to which the datastore needs to be bound. If successful, `"Success"` will be returned, and a call to `getAliasedDataStoreEntryPoint` with the alias as parameter will return the same datastore's entry point.
|
|
23
|
+
|
|
24
|
+
The alias API can fail in the following situations, per the `AliasResult` type (see `@fluidframework/runtime-definitions`) type:
|
|
25
|
+
|
|
26
|
+
- `"Conflict"` - the alias has already been taken. In this case, the client can call `getAliasedDataStoreEntryPoint` to get the entry point of the datastore already aliased for that value. The current datastore can be left alone unreferenced so it can eventually be garbage collected.
|
|
27
|
+
- `"AlreadyAliased"` - the datastore has already been aliased to a different id.
|
|
28
|
+
|
|
29
|
+
The alias API is idempotent. Repeatedly calling the trySetAlias function on the same datastore will return Success when the datastore has already been aliased to the same value.
|
|
30
|
+
|
|
31
|
+
Example:
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
const dataStore = await dataObject.context.containerRuntime.createDataStore("packageName");
|
|
35
|
+
// One client will receive "Success", the other client will receive "Conflict".
|
|
36
|
+
const aliasResult = await dataStore.trySetAlias("alias");
|
|
37
|
+
// Both clients will get the actual aliased datastore. However, the client with the "Conflict" result must fetch the datastore by name
|
|
38
|
+
const finalDataStore =
|
|
39
|
+
aliasResult === "Success"
|
|
40
|
+
? dataStore
|
|
41
|
+
: await dataObject.context.containerRuntime.getAliasedDataStoreEntryPoint("alias");
|
|
42
|
+
```
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { IUser } from "@fluidframework/protocol-definitions";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* AttributionKey representing a reference to some op in the op stream.
|
|
10
|
+
* Content associated with this key aligns with content modified by that op.
|
|
11
|
+
* @alpha
|
|
12
|
+
*/
|
|
13
|
+
export interface OpAttributionKey {
|
|
14
|
+
/**
|
|
15
|
+
* The type of attribution this key corresponds to.
|
|
16
|
+
*
|
|
17
|
+
* Keys currently all represent op-based attribution, so have the form `{ type: "op", key: sequenceNumber }`.
|
|
18
|
+
* Thus, they can be used with an `OpStreamAttributor` to recover timestamp/user information.
|
|
19
|
+
*/
|
|
20
|
+
type: "op";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The sequenceNumber of the op this attribution key is for.
|
|
24
|
+
*/
|
|
25
|
+
seq: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* AttributionKey associated with content that was inserted while the container was in a detached state.
|
|
30
|
+
*
|
|
31
|
+
* @remarks Retrieving an {@link AttributionInfo} from content associated with detached attribution keys
|
|
32
|
+
* is currently unsupported, as applications can effectively modify content anonymously while detached.
|
|
33
|
+
* The runtime has no mechanism for reliably obtaining the user. It would be reasonable to start supporting
|
|
34
|
+
* this functionality if the host provided additional context to their attributor or attach calls.
|
|
35
|
+
* @alpha
|
|
36
|
+
*/
|
|
37
|
+
export interface DetachedAttributionKey {
|
|
38
|
+
type: "detached";
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Arbitrary discriminator associated with content inserted while detached.
|
|
42
|
+
*
|
|
43
|
+
* @remarks For now, the runtime assumes all content created while detached is associated
|
|
44
|
+
* with the same user/timestamp.
|
|
45
|
+
* We could weaken this assumption in the future with further API support and
|
|
46
|
+
* allow arbitrary strings or numbers as part of this key.
|
|
47
|
+
*/
|
|
48
|
+
id: 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* AttributionKey associated with content that has been made locally but not yet acked by the server.
|
|
53
|
+
* @alpha
|
|
54
|
+
*/
|
|
55
|
+
export interface LocalAttributionKey {
|
|
56
|
+
type: "local";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Can be indexed into the ContainerRuntime in order to retrieve {@link AttributionInfo}.
|
|
61
|
+
* @alpha
|
|
62
|
+
*/
|
|
63
|
+
export type AttributionKey = OpAttributionKey | DetachedAttributionKey | LocalAttributionKey;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Attribution information associated with a change.
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
export interface AttributionInfo {
|
|
70
|
+
/**
|
|
71
|
+
* The user that performed the change.
|
|
72
|
+
*/
|
|
73
|
+
user: IUser;
|
|
74
|
+
/**
|
|
75
|
+
* When the change happened.
|
|
76
|
+
*/
|
|
77
|
+
timestamp: number;
|
|
78
|
+
}
|