@fluid-experimental/attributor 2.20.0 → 2.22.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 +8 -0
- package/README.md +1 -0
- package/dist/mixinAttributor.d.ts.map +1 -1
- package/dist/mixinAttributor.js +2 -3
- package/dist/mixinAttributor.js.map +1 -1
- package/dist/runtimeAttributor.js.map +1 -1
- package/lib/mixinAttributor.d.ts.map +1 -1
- package/lib/mixinAttributor.js +2 -3
- package/lib/mixinAttributor.js.map +1 -1
- package/lib/runtimeAttributor.js.map +1 -1
- package/package.json +21 -21
- package/src/mixinAttributor.ts +1 -11
- package/src/runtimeAttributor.ts +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -157,6 +157,7 @@ When making such a request please include if the configuration already works (an
|
|
|
157
157
|
### Supported Runtimes
|
|
158
158
|
|
|
159
159
|
- NodeJs ^20.10.0 except that we will drop support for it [when NodeJs 20 loses its upstream support on 2026-04-30](https://github.com/nodejs/release#release-schedule), and will support a newer LTS version of NodeJS (22) at least 1 year before 20 is end-of-life. This same policy applies to NodeJS 22 when it is end of life (2027-04-30).
|
|
160
|
+
- Running Fluid in a Node.js environment with the `--no-experimental-fetch` flag is not supported.
|
|
160
161
|
- Modern browsers supporting the es2022 standard library: in response to asks we can add explicit support for using babel to polyfill to target specific standards or runtimes (meaning we can avoid/remove use of things that don't polyfill robustly, but otherwise target modern standards).
|
|
161
162
|
|
|
162
163
|
### Supported Tools
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixinAttributor.d.ts","sourceRoot":"","sources":["../src/mixinAttributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"mixinAttributor.d.ts","sourceRoot":"","sources":["../src/mixinAttributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAK9E,OAAO,EACN,KAAK,qBAAqB,EAE1B,MAAM,8CAA8C,CAAC;AAGtD,OAAO,EAIN,KAAK,kBAAkB,EACvB,MAAM,0BAA0B,CAAC;AAGlC;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACzC,OAAO,EAAE,qBAAqB,GAC5B,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAMzC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,UACrB,uBAAuB,KAC3B,uBAgEqC,CAAC"}
|
package/dist/mixinAttributor.js
CHANGED
|
@@ -32,7 +32,7 @@ exports.getRuntimeAttributor = getRuntimeAttributor;
|
|
|
32
32
|
*/
|
|
33
33
|
const mixinAttributor = (Base = internal_1.ContainerRuntime) => class ContainerRuntimeWithAttributor extends Base {
|
|
34
34
|
static async loadRuntime(params) {
|
|
35
|
-
const { context, registryEntries, existing,
|
|
35
|
+
const { context, registryEntries, existing, provideEntryPoint, runtimeOptions, containerScope, containerRuntimeCtor = ContainerRuntimeWithAttributor, } = params;
|
|
36
36
|
const mc = (0, internal_3.loggerToMonitoringContext)(context.taggedLogger);
|
|
37
37
|
const factory = new runtimeAttributorDataStoreFactory_js_1.RuntimeAttributorFactory();
|
|
38
38
|
const registryEntriesCopy = [
|
|
@@ -43,13 +43,12 @@ const mixinAttributor = (Base = internal_1.ContainerRuntime) => class ContainerR
|
|
|
43
43
|
if (shouldTrackAttribution) {
|
|
44
44
|
const { options } = context;
|
|
45
45
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
46
|
-
(options.attribution
|
|
46
|
+
(options.attribution ??= {}).track = true;
|
|
47
47
|
}
|
|
48
48
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
49
49
|
const runtime = (await Base.loadRuntime({
|
|
50
50
|
context,
|
|
51
51
|
registryEntries: registryEntriesCopy,
|
|
52
|
-
requestHandler,
|
|
53
52
|
provideEntryPoint,
|
|
54
53
|
runtimeOptions,
|
|
55
54
|
containerScope,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixinAttributor.js","sourceRoot":"","sources":["../src/mixinAttributor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yEAA8E;
|
|
1
|
+
{"version":3,"file":"mixinAttributor.js","sourceRoot":"","sources":["../src/mixinAttributor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yEAA8E;AAI9E,kEAA6D;AAK7D,uEAAqF;AAErF,qEAKkC;AAClC,iGAAkF;AAElF;;;;;GAKG;AACI,KAAK,UAAU,oBAAoB,CACzC,OAA8B;IAE9B,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,6BAA6B,CAAC,iDAAwB,CAAC,CAAC;IACzF,MAAM,iBAAiB,GAAG,CAAC,MAAM,UAAU,EAAE,GAAG,EAAE,CAEtC,CAAC;IACb,OAAO,iBAAiB,EAAE,kBAAkB,CAAC;AAC9C,CAAC;AARD,oDAQC;AAED;;;;;;;GAOG;AACI,MAAM,eAAe,GAAG,CAC9B,OAAgC,2BAAgB,EACtB,EAAE,CAC5B,MAAM,8BAA+B,SAAQ,IAAI;IACzC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAQ/B;QACA,MAAM,EACL,OAAO,EACP,eAAe,EACf,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,oBAAoB,GAAG,8BAAoE,GAC3F,GAAG,MAAM,CAAC;QAEX,MAAM,EAAE,GAAG,IAAA,oCAAyB,EAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC3D,MAAM,OAAO,GAAG,IAAI,+DAAwB,EAAE,CAAC;QAC/C,MAAM,mBAAmB,GAAuC;YAC/D,GAAG,eAAe;YAClB,CAAC,+DAAwB,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;SACzD,CAAC;QACF,MAAM,sBAAsB,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,2CAAkB,CAAC,IAAI,KAAK,CAAC;QACjF,IAAI,sBAAsB,EAAE,CAAC;YAC5B,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;YAC5B,sEAAsE;YACtE,CAAC,OAAO,CAAC,WAAW,KAAK,EAAE,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC;QAC3C,CAAC;QAED,iEAAiE;QACjE,MAAM,OAAO,GAAG,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC;YACvC,OAAO;YACP,eAAe,EAAE,mBAAmB;YACpC,iBAAiB;YACjB,cAAc;YACd,cAAc;YACd,QAAQ;YACR,oBAAoB;YACpB,8DAA8D;SACvD,CAAC,CAAmC,CAAC;QAE7C,IAAI,iBAAiD,CAAC;QACtD,IAAI,sBAAsB,EAAE,CAAC;YAC5B,IAAI,QAAQ,EAAE,CAAC;gBACd,iBAAiB,GAAG,MAAM,oBAAoB,CAAC,OAAO,CAAC,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACP,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,+DAAwB,CAAC,IAAI,CAAC,CAAC;gBAC/E,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,iDAAwB,CAAC,CAAC;gBACrE,IAAA,iBAAM,EACL,MAAM,KAAK,SAAS,EACpB,KAAK,CAAC,mDAAmD,CACzD,CAAC;gBACF,iBAAiB,GAAG,CAAC,MAAM,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,CAAuB,CAAC;gBAC7E,IAAA,iBAAM,EAAC,iBAAiB,KAAK,SAAS,EAAE,KAAK,CAAC,kCAAkC,CAAC,CAAC;YACnF,CAAC;QACF,CAAC;QAED,OAAO,OAAO,CAAC;IAChB,CAAC;CACqC,CAAC;AAlE5B,QAAA,eAAe,mBAkEa","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type IContainerContext } from \"@fluidframework/container-definitions/internal\";\nimport { ContainerRuntime } from \"@fluidframework/container-runtime/internal\";\nimport type { IContainerRuntimeOptions } from \"@fluidframework/container-runtime/internal\";\nimport { type IContainerRuntime } from \"@fluidframework/container-runtime-definitions/internal\";\nimport { type FluidObject } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype IContainerRuntimeBase,\n\ttype NamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { loggerToMonitoringContext } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tattributorDataStoreAlias,\n\tenableOnNewFileKey,\n\ttype IProvideRuntimeAttributor,\n\ttype IRuntimeAttributor,\n} from \"./attributorContracts.js\";\nimport { RuntimeAttributorFactory } from \"./runtimeAttributorDataStoreFactory.js\";\n\n/**\n * Utility function to get the runtime attributor from the container runtime.\n * @param runtime - container runtime from which attributor is to be fetched.\n * @returns IRuntimeAttributor if it exists, otherwise undefined.\n * @internal\n */\nexport async function getRuntimeAttributor(\n\truntime: IContainerRuntimeBase,\n): Promise<IRuntimeAttributor | undefined> {\n\tconst entryPoint = await runtime.getAliasedDataStoreEntryPoint(attributorDataStoreAlias);\n\tconst runtimeAttributor = (await entryPoint?.get()) as\n\t\t| FluidObject<IProvideRuntimeAttributor>\n\t\t| undefined;\n\treturn runtimeAttributor?.IRuntimeAttributor;\n}\n\n/**\n * Mixes in logic to load and store runtime-based attribution functionality.\n *\n * Existing documents without stored attributor will not start storing attribution information. We only create the attributor\n * if its tracking is enabled and we are creating a new document.\n * @param Base - base class, inherits from FluidAttributorRuntime\n * @internal\n */\nexport const mixinAttributor = (\n\tBase: typeof ContainerRuntime = ContainerRuntime,\n): typeof ContainerRuntime =>\n\tclass ContainerRuntimeWithAttributor extends Base {\n\t\tpublic static async loadRuntime(params: {\n\t\t\tcontext: IContainerContext;\n\t\t\tregistryEntries: NamedFluidDataStoreRegistryEntries;\n\t\t\texisting: boolean;\n\t\t\truntimeOptions?: IContainerRuntimeOptions;\n\t\t\tcontainerScope?: FluidObject;\n\t\t\tcontainerRuntimeCtor?: typeof ContainerRuntime;\n\t\t\tprovideEntryPoint: (containerRuntime: IContainerRuntime) => Promise<FluidObject>;\n\t\t}): Promise<ContainerRuntime> {\n\t\t\tconst {\n\t\t\t\tcontext,\n\t\t\t\tregistryEntries,\n\t\t\t\texisting,\n\t\t\t\tprovideEntryPoint,\n\t\t\t\truntimeOptions,\n\t\t\t\tcontainerScope,\n\t\t\t\tcontainerRuntimeCtor = ContainerRuntimeWithAttributor as unknown as typeof ContainerRuntime,\n\t\t\t} = params;\n\n\t\t\tconst mc = loggerToMonitoringContext(context.taggedLogger);\n\t\t\tconst factory = new RuntimeAttributorFactory();\n\t\t\tconst registryEntriesCopy: NamedFluidDataStoreRegistryEntries = [\n\t\t\t\t...registryEntries,\n\t\t\t\t[RuntimeAttributorFactory.type, Promise.resolve(factory)],\n\t\t\t];\n\t\t\tconst shouldTrackAttribution = mc.config.getBoolean(enableOnNewFileKey) ?? false;\n\t\t\tif (shouldTrackAttribution) {\n\t\t\t\tconst { options } = context;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\t(options.attribution ??= {}).track = true;\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tconst runtime = (await Base.loadRuntime({\n\t\t\t\tcontext,\n\t\t\t\tregistryEntries: registryEntriesCopy,\n\t\t\t\tprovideEntryPoint,\n\t\t\t\truntimeOptions,\n\t\t\t\tcontainerScope,\n\t\t\t\texisting,\n\t\t\t\tcontainerRuntimeCtor,\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t} as any)) as ContainerRuntimeWithAttributor;\n\n\t\t\tlet runtimeAttributor: IRuntimeAttributor | undefined;\n\t\t\tif (shouldTrackAttribution) {\n\t\t\t\tif (existing) {\n\t\t\t\t\truntimeAttributor = await getRuntimeAttributor(runtime);\n\t\t\t\t} else {\n\t\t\t\t\tconst datastore = await runtime.createDataStore(RuntimeAttributorFactory.type);\n\t\t\t\t\tconst result = await datastore.trySetAlias(attributorDataStoreAlias);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tresult === \"Success\",\n\t\t\t\t\t\t0xa1b /* Failed to set alias for attributor data store */,\n\t\t\t\t\t);\n\t\t\t\t\truntimeAttributor = (await datastore.entryPoint.get()) as IRuntimeAttributor;\n\t\t\t\t\tassert(runtimeAttributor !== undefined, 0xa1c /* Attributor should be defined */);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn runtime;\n\t\t}\n\t} as unknown as typeof ContainerRuntime;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeAttributor.js","sourceRoot":"","sources":["../src/runtimeAttributor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAE9D,kEAA8E;AAY9E,qEAA4E;AAE5E,mDAAuE;AACvE,qEAA+E;AAC/E,+CAAwF;AACxF,mDAAiD;AAEjD,MAAa,iBAAiB;IAA9B;QAuCS,YAAO,GAAiC;YAC/C,MAAM,EAAE,0BAAe;YACvB,MAAM,EAAE,0BAAe;SACvB,CAAC;QAGK,cAAS,GAAG,IAAI,CAAC;IAuCzB,CAAC;IAnFA,IAAW,kBAAkB;QAC5B,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,GAAG,CAAC,GAAmB;QAC7B,IAAA,iBAAM,EACL,IAAI,CAAC,YAAY,KAAK,SAAS,EAC/B,KAAK,CAAC,mFAAmF,CACzF,CAAC;QAEF,IAAI,GAAG,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACvE,CAAC;QAED,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC1B,wGAAwG;YACxG,0GAA0G;YAC1G,wGAAwG;YACxG,qGAAqG;YAC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AChB,CAAC;QAEF,IAAI,6BAA6B,KAAK,SAAS,EAAE,CAAC;YACjD,IAAI,CAAC,YAAY,GAAG,IAAI,kCAAkB,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAClE,CAAC;aAAM,CAAC;YACP,MAAM,EAAE,GAAuB,6BAA6B,CAAC,KAAK,CAAC,mCAAU,CAAC,CAAC;YAC/E,IAAA,iBAAM,EACL,EAAE,KAAK,SAAS,EAChB,KAAK,CAAC,6DAA6D,CACnE,CAAC;YACF,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,EAAE,CAAC,CAAC;YACxC,MAAM,kBAAkB,GAAG,IAAA,6BAAc,EAAC,YAAY,EAAE,MAAM,CAAC,CAAC;YAChE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;QAC7D,CAAC;IACF,CAAC;IAEM,qBAAqB;QAC3B,IAAA,iBAAM,EACL,IAAI,CAAC,YAAY,KAAK,SAAS,EAC/B,KAAK,CAAC,kEAAkE,CACxE,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,6BAAkB,EAAE,CAAC;QACzC,OAAO,CAAC,OAAO,CAAC,mCAAU,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QACpE,OAAO,OAAO,CAAC,cAAc,EAAE,CAAC;IACjC,CAAC;CACD;AApFD,8CAoFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDocumentMessage,\n\ttype ISnapshotTree,\n\tISequencedDocumentMessage,\n\tIQuorumClients,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype AttributionInfo,\n\ttype AttributionKey,\n\ttype ISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\n\nimport { OpStreamAttributor, type IAttributor } from \"./attributor.js\";\nimport { opBlobName, type IRuntimeAttributor } from \"./attributorContracts.js\";\nimport { AttributorSerializer, chain, deltaEncoder, type Encoder } from \"./encoders.js\";\nimport { makeLZ4Encoder } from \"./lz4Encoder.js\";\n\nexport class RuntimeAttributor implements IRuntimeAttributor {\n\tpublic get IRuntimeAttributor(): IRuntimeAttributor {\n\t\treturn this;\n\t}\n\n\tpublic get(key: AttributionKey): AttributionInfo {\n\t\tassert(\n\t\t\tthis.opAttributor !== undefined,\n\t\t\t0x509 /* RuntimeAttributor must be initialized before getAttributionInfo can be called */,\n\t\t);\n\n\t\tif (key.type === \"detached\") {\n\t\t\tthrow new Error(\"Attribution of detached keys is not yet supported.\");\n\t\t}\n\n\t\tif (key.type === \"local\") {\n\t\t\t// Note: we can *almost* orchestrate this correctly with internal-only changes by looking up the current\n\t\t\t// client id in the audience. However, for read->write client transition, the container might have not yet\n\t\t\t// received a client id. This is left as a TODO as it might be more easily solved once the detached case\n\t\t\t// is settled (e.g. if it's reasonable for the host to know the current user information at container\n\t\t\t// creation time, we could just use that here as well).\n\t\t\tthrow new Error(\"Attribution of local keys is not yet supported.\");\n\t\t}\n\n\t\treturn this.opAttributor.getAttributionInfo(key.seq);\n\t}\n\n\tpublic has(key: AttributionKey): boolean {\n\t\tif (key.type === \"detached\") {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (key.type === \"local\") {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.opAttributor?.tryGetAttributionInfo(key.seq) !== undefined;\n\t}\n\n\tprivate encoder: Encoder<IAttributor, string> = {\n\t\tencode: unreachableCase,\n\t\tdecode: unreachableCase,\n\t};\n\n\tprivate opAttributor: IAttributor | undefined;\n\tpublic isEnabled = true;\n\n\tpublic async initialize(\n\t\tdeltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tquorum: IQuorumClients,\n\t\tbaseSnapshotForAttributorTree: ISnapshotTree | undefined,\n\t\treadBlob: (id: string) => Promise<ArrayBufferLike>,\n\t): Promise<void> {\n\t\tthis.encoder = chain(\n\t\t\tnew AttributorSerializer(\n\t\t\t\t(entries) => new OpStreamAttributor(deltaManager, quorum, entries),\n\t\t\t\tdeltaEncoder,\n\t\t\t),\n\t\t\tmakeLZ4Encoder(),\n\t\t);\n\n\t\tif (baseSnapshotForAttributorTree === undefined) {\n\t\t\tthis.opAttributor = new OpStreamAttributor(deltaManager, quorum);\n\t\t} else {\n\t\t\tconst id: string | undefined = baseSnapshotForAttributorTree.blobs[opBlobName];\n\t\t\tassert(\n\t\t\t\tid !== undefined,\n\t\t\t\t0x50a /* Attributor tree should have op attributor summary blob. */,\n\t\t\t);\n\t\t\tconst blobContents = await readBlob(id);\n\t\t\tconst attributorSnapshot = bufferToString(blobContents, \"utf8\");\n\t\t\tthis.opAttributor = this.encoder.decode(attributorSnapshot);\n\t\t}\n\t}\n\n\tpublic summarizeOpAttributor(): ISummaryTreeWithStats {\n\t\tassert(\n\t\t\tthis.opAttributor !== undefined,\n\t\t\t0xa1d /* RuntimeAttributor should be initialized before summarization */,\n\t\t);\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addBlob(opBlobName, this.encoder.encode(this.opAttributor));\n\t\treturn builder.getSummaryTree();\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixinAttributor.d.ts","sourceRoot":"","sources":["../src/mixinAttributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"mixinAttributor.d.ts","sourceRoot":"","sources":["../src/mixinAttributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAK9E,OAAO,EACN,KAAK,qBAAqB,EAE1B,MAAM,8CAA8C,CAAC;AAGtD,OAAO,EAIN,KAAK,kBAAkB,EACvB,MAAM,0BAA0B,CAAC;AAGlC;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACzC,OAAO,EAAE,qBAAqB,GAC5B,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAMzC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,UACrB,uBAAuB,KAC3B,uBAgEqC,CAAC"}
|
package/lib/mixinAttributor.js
CHANGED
|
@@ -28,7 +28,7 @@ export async function getRuntimeAttributor(runtime) {
|
|
|
28
28
|
*/
|
|
29
29
|
export const mixinAttributor = (Base = ContainerRuntime) => class ContainerRuntimeWithAttributor extends Base {
|
|
30
30
|
static async loadRuntime(params) {
|
|
31
|
-
const { context, registryEntries, existing,
|
|
31
|
+
const { context, registryEntries, existing, provideEntryPoint, runtimeOptions, containerScope, containerRuntimeCtor = ContainerRuntimeWithAttributor, } = params;
|
|
32
32
|
const mc = loggerToMonitoringContext(context.taggedLogger);
|
|
33
33
|
const factory = new RuntimeAttributorFactory();
|
|
34
34
|
const registryEntriesCopy = [
|
|
@@ -39,13 +39,12 @@ export const mixinAttributor = (Base = ContainerRuntime) => class ContainerRunti
|
|
|
39
39
|
if (shouldTrackAttribution) {
|
|
40
40
|
const { options } = context;
|
|
41
41
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
42
|
-
(options.attribution
|
|
42
|
+
(options.attribution ??= {}).track = true;
|
|
43
43
|
}
|
|
44
44
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
45
45
|
const runtime = (await Base.loadRuntime({
|
|
46
46
|
context,
|
|
47
47
|
registryEntries: registryEntriesCopy,
|
|
48
|
-
requestHandler,
|
|
49
48
|
provideEntryPoint,
|
|
50
49
|
runtimeOptions,
|
|
51
50
|
containerScope,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixinAttributor.js","sourceRoot":"","sources":["../src/mixinAttributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"mixinAttributor.js","sourceRoot":"","sources":["../src/mixinAttributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAI9E,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAK7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AAErF,OAAO,EACN,wBAAwB,EACxB,kBAAkB,GAGlB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAElF;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACzC,OAA8B;IAE9B,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,6BAA6B,CAAC,wBAAwB,CAAC,CAAC;IACzF,MAAM,iBAAiB,GAAG,CAAC,MAAM,UAAU,EAAE,GAAG,EAAE,CAEtC,CAAC;IACb,OAAO,iBAAiB,EAAE,kBAAkB,CAAC;AAC9C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC9B,OAAgC,gBAAgB,EACtB,EAAE,CAC5B,MAAM,8BAA+B,SAAQ,IAAI;IACzC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAQ/B;QACA,MAAM,EACL,OAAO,EACP,eAAe,EACf,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,oBAAoB,GAAG,8BAAoE,GAC3F,GAAG,MAAM,CAAC;QAEX,MAAM,EAAE,GAAG,yBAAyB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC3D,MAAM,OAAO,GAAG,IAAI,wBAAwB,EAAE,CAAC;QAC/C,MAAM,mBAAm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,CAAC;IAChB,CAAC;CACqC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type IContainerContext } from \"@fluidframework/container-definitions/internal\";\nimport { ContainerRuntime } from \"@fluidframework/container-runtime/internal\";\nimport type { IContainerRuntimeOptions } from \"@fluidframework/container-runtime/internal\";\nimport { type IContainerRuntime } from \"@fluidframework/container-runtime-definitions/internal\";\nimport { type FluidObject } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\ttype IContainerRuntimeBase,\n\ttype NamedFluidDataStoreRegistryEntries,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { loggerToMonitoringContext } from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tattributorDataStoreAlias,\n\tenableOnNewFileKey,\n\ttype IProvideRuntimeAttributor,\n\ttype IRuntimeAttributor,\n} from \"./attributorContracts.js\";\nimport { RuntimeAttributorFactory } from \"./runtimeAttributorDataStoreFactory.js\";\n\n/**\n * Utility function to get the runtime attributor from the container runtime.\n * @param runtime - container runtime from which attributor is to be fetched.\n * @returns IRuntimeAttributor if it exists, otherwise undefined.\n * @internal\n */\nexport async function getRuntimeAttributor(\n\truntime: IContainerRuntimeBase,\n): Promise<IRuntimeAttributor | undefined> {\n\tconst entryPoint = await runtime.getAliasedDataStoreEntryPoint(attributorDataStoreAlias);\n\tconst runtimeAttributor = (await entryPoint?.get()) as\n\t\t| FluidObject<IProvideRuntimeAttributor>\n\t\t| undefined;\n\treturn runtimeAttributor?.IRuntimeAttributor;\n}\n\n/**\n * Mixes in logic to load and store runtime-based attribution functionality.\n *\n * Existing documents without stored attributor will not start storing attribution information. We only create the attributor\n * if its tracking is enabled and we are creating a new document.\n * @param Base - base class, inherits from FluidAttributorRuntime\n * @internal\n */\nexport const mixinAttributor = (\n\tBase: typeof ContainerRuntime = ContainerRuntime,\n): typeof ContainerRuntime =>\n\tclass ContainerRuntimeWithAttributor extends Base {\n\t\tpublic static async loadRuntime(params: {\n\t\t\tcontext: IContainerContext;\n\t\t\tregistryEntries: NamedFluidDataStoreRegistryEntries;\n\t\t\texisting: boolean;\n\t\t\truntimeOptions?: IContainerRuntimeOptions;\n\t\t\tcontainerScope?: FluidObject;\n\t\t\tcontainerRuntimeCtor?: typeof ContainerRuntime;\n\t\t\tprovideEntryPoint: (containerRuntime: IContainerRuntime) => Promise<FluidObject>;\n\t\t}): Promise<ContainerRuntime> {\n\t\t\tconst {\n\t\t\t\tcontext,\n\t\t\t\tregistryEntries,\n\t\t\t\texisting,\n\t\t\t\tprovideEntryPoint,\n\t\t\t\truntimeOptions,\n\t\t\t\tcontainerScope,\n\t\t\t\tcontainerRuntimeCtor = ContainerRuntimeWithAttributor as unknown as typeof ContainerRuntime,\n\t\t\t} = params;\n\n\t\t\tconst mc = loggerToMonitoringContext(context.taggedLogger);\n\t\t\tconst factory = new RuntimeAttributorFactory();\n\t\t\tconst registryEntriesCopy: NamedFluidDataStoreRegistryEntries = [\n\t\t\t\t...registryEntries,\n\t\t\t\t[RuntimeAttributorFactory.type, Promise.resolve(factory)],\n\t\t\t];\n\t\t\tconst shouldTrackAttribution = mc.config.getBoolean(enableOnNewFileKey) ?? false;\n\t\t\tif (shouldTrackAttribution) {\n\t\t\t\tconst { options } = context;\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\t(options.attribution ??= {}).track = true;\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n\t\t\tconst runtime = (await Base.loadRuntime({\n\t\t\t\tcontext,\n\t\t\t\tregistryEntries: registryEntriesCopy,\n\t\t\t\tprovideEntryPoint,\n\t\t\t\truntimeOptions,\n\t\t\t\tcontainerScope,\n\t\t\t\texisting,\n\t\t\t\tcontainerRuntimeCtor,\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\t} as any)) as ContainerRuntimeWithAttributor;\n\n\t\t\tlet runtimeAttributor: IRuntimeAttributor | undefined;\n\t\t\tif (shouldTrackAttribution) {\n\t\t\t\tif (existing) {\n\t\t\t\t\truntimeAttributor = await getRuntimeAttributor(runtime);\n\t\t\t\t} else {\n\t\t\t\t\tconst datastore = await runtime.createDataStore(RuntimeAttributorFactory.type);\n\t\t\t\t\tconst result = await datastore.trySetAlias(attributorDataStoreAlias);\n\t\t\t\t\tassert(\n\t\t\t\t\t\tresult === \"Success\",\n\t\t\t\t\t\t0xa1b /* Failed to set alias for attributor data store */,\n\t\t\t\t\t);\n\t\t\t\t\truntimeAttributor = (await datastore.entryPoint.get()) as IRuntimeAttributor;\n\t\t\t\t\tassert(runtimeAttributor !== undefined, 0xa1c /* Attributor should be defined */);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn runtime;\n\t\t}\n\t} as unknown as typeof ContainerRuntime;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeAttributor.js","sourceRoot":"","sources":["../src/runtimeAttributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAY9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAE5E,OAAO,EAAE,kBAAkB,EAAoB,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,UAAU,EAA2B,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,YAAY,EAAgB,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,OAAO,iBAAiB;IAA9B;QAuCS,YAAO,GAAiC;YAC/C,MAAM,EAAE,eAAe;YACvB,MAAM,EAAE,eAAe;SACvB,CAAC;QAGK,cAAS,GAAG,IAAI,CAAC;IAuCzB,CA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MAAM,CACL,IAAI,CAAC,YAAY,KAAK,SAAS,EAC/B,KAAK,CAAC,kEAAkE,CACxE,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,kBAAkB,EAAE,CAAC;QACzC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QACpE,OAAO,OAAO,CAAC,cAAc,EAAE,CAAC;IACjC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluid-internal/client-utils\";\nimport { IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { assert, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport {\n\tIDocumentMessage,\n\ttype ISnapshotTree,\n\tISequencedDocumentMessage,\n\tIQuorumClients,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype AttributionInfo,\n\ttype AttributionKey,\n\ttype ISummaryTreeWithStats,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { SummaryTreeBuilder } from \"@fluidframework/runtime-utils/internal\";\n\nimport { OpStreamAttributor, type IAttributor } from \"./attributor.js\";\nimport { opBlobName, type IRuntimeAttributor } from \"./attributorContracts.js\";\nimport { AttributorSerializer, chain, deltaEncoder, type Encoder } from \"./encoders.js\";\nimport { makeLZ4Encoder } from \"./lz4Encoder.js\";\n\nexport class RuntimeAttributor implements IRuntimeAttributor {\n\tpublic get IRuntimeAttributor(): IRuntimeAttributor {\n\t\treturn this;\n\t}\n\n\tpublic get(key: AttributionKey): AttributionInfo {\n\t\tassert(\n\t\t\tthis.opAttributor !== undefined,\n\t\t\t0x509 /* RuntimeAttributor must be initialized before getAttributionInfo can be called */,\n\t\t);\n\n\t\tif (key.type === \"detached\") {\n\t\t\tthrow new Error(\"Attribution of detached keys is not yet supported.\");\n\t\t}\n\n\t\tif (key.type === \"local\") {\n\t\t\t// Note: we can *almost* orchestrate this correctly with internal-only changes by looking up the current\n\t\t\t// client id in the audience. However, for read->write client transition, the container might have not yet\n\t\t\t// received a client id. This is left as a TODO as it might be more easily solved once the detached case\n\t\t\t// is settled (e.g. if it's reasonable for the host to know the current user information at container\n\t\t\t// creation time, we could just use that here as well).\n\t\t\tthrow new Error(\"Attribution of local keys is not yet supported.\");\n\t\t}\n\n\t\treturn this.opAttributor.getAttributionInfo(key.seq);\n\t}\n\n\tpublic has(key: AttributionKey): boolean {\n\t\tif (key.type === \"detached\") {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (key.type === \"local\") {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.opAttributor?.tryGetAttributionInfo(key.seq) !== undefined;\n\t}\n\n\tprivate encoder: Encoder<IAttributor, string> = {\n\t\tencode: unreachableCase,\n\t\tdecode: unreachableCase,\n\t};\n\n\tprivate opAttributor: IAttributor | undefined;\n\tpublic isEnabled = true;\n\n\tpublic async initialize(\n\t\tdeltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n\t\tquorum: IQuorumClients,\n\t\tbaseSnapshotForAttributorTree: ISnapshotTree | undefined,\n\t\treadBlob: (id: string) => Promise<ArrayBufferLike>,\n\t): Promise<void> {\n\t\tthis.encoder = chain(\n\t\t\tnew AttributorSerializer(\n\t\t\t\t(entries) => new OpStreamAttributor(deltaManager, quorum, entries),\n\t\t\t\tdeltaEncoder,\n\t\t\t),\n\t\t\tmakeLZ4Encoder(),\n\t\t);\n\n\t\tif (baseSnapshotForAttributorTree === undefined) {\n\t\t\tthis.opAttributor = new OpStreamAttributor(deltaManager, quorum);\n\t\t} else {\n\t\t\tconst id: string | undefined = baseSnapshotForAttributorTree.blobs[opBlobName];\n\t\t\tassert(\n\t\t\t\tid !== undefined,\n\t\t\t\t0x50a /* Attributor tree should have op attributor summary blob. */,\n\t\t\t);\n\t\t\tconst blobContents = await readBlob(id);\n\t\t\tconst attributorSnapshot = bufferToString(blobContents, \"utf8\");\n\t\t\tthis.opAttributor = this.encoder.decode(attributorSnapshot);\n\t\t}\n\t}\n\n\tpublic summarizeOpAttributor(): ISummaryTreeWithStats {\n\t\tassert(\n\t\t\tthis.opAttributor !== undefined,\n\t\t\t0xa1d /* RuntimeAttributor should be initialized before summarization */,\n\t\t);\n\t\tconst builder = new SummaryTreeBuilder();\n\t\tbuilder.addBlob(opBlobName, this.encoder.encode(this.opAttributor));\n\t\treturn builder.getSummaryTree();\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-experimental/attributor",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.0",
|
|
4
4
|
"description": "Operation attributor",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -49,32 +49,32 @@
|
|
|
49
49
|
"temp-directory": "nyc/.nyc_output"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@fluid-internal/client-utils": "~2.
|
|
53
|
-
"@fluidframework/container-definitions": "~2.
|
|
54
|
-
"@fluidframework/container-runtime": "~2.
|
|
55
|
-
"@fluidframework/container-runtime-definitions": "~2.
|
|
56
|
-
"@fluidframework/core-interfaces": "~2.
|
|
57
|
-
"@fluidframework/core-utils": "~2.
|
|
58
|
-
"@fluidframework/datastore": "~2.
|
|
59
|
-
"@fluidframework/datastore-definitions": "~2.
|
|
60
|
-
"@fluidframework/driver-definitions": "~2.
|
|
61
|
-
"@fluidframework/runtime-definitions": "~2.
|
|
62
|
-
"@fluidframework/runtime-utils": "~2.
|
|
63
|
-
"@fluidframework/telemetry-utils": "~2.
|
|
52
|
+
"@fluid-internal/client-utils": "~2.22.0",
|
|
53
|
+
"@fluidframework/container-definitions": "~2.22.0",
|
|
54
|
+
"@fluidframework/container-runtime": "~2.22.0",
|
|
55
|
+
"@fluidframework/container-runtime-definitions": "~2.22.0",
|
|
56
|
+
"@fluidframework/core-interfaces": "~2.22.0",
|
|
57
|
+
"@fluidframework/core-utils": "~2.22.0",
|
|
58
|
+
"@fluidframework/datastore": "~2.22.0",
|
|
59
|
+
"@fluidframework/datastore-definitions": "~2.22.0",
|
|
60
|
+
"@fluidframework/driver-definitions": "~2.22.0",
|
|
61
|
+
"@fluidframework/runtime-definitions": "~2.22.0",
|
|
62
|
+
"@fluidframework/runtime-utils": "~2.22.0",
|
|
63
|
+
"@fluidframework/telemetry-utils": "~2.22.0",
|
|
64
64
|
"lz4js": "^0.2.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
68
68
|
"@biomejs/biome": "~1.9.3",
|
|
69
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
70
|
-
"@fluid-private/stochastic-test-utils": "~2.
|
|
69
|
+
"@fluid-internal/mocha-test-setup": "~2.22.0",
|
|
70
|
+
"@fluid-private/stochastic-test-utils": "~2.22.0",
|
|
71
71
|
"@fluid-tools/build-cli": "^0.51.0",
|
|
72
72
|
"@fluidframework/build-common": "^2.0.3",
|
|
73
73
|
"@fluidframework/build-tools": "^0.51.0",
|
|
74
|
-
"@fluidframework/eslint-config-fluid": "^5.
|
|
75
|
-
"@fluidframework/merge-tree": "~2.
|
|
76
|
-
"@fluidframework/sequence": "~2.
|
|
77
|
-
"@fluidframework/test-runtime-utils": "~2.
|
|
74
|
+
"@fluidframework/eslint-config-fluid": "^5.7.3",
|
|
75
|
+
"@fluidframework/merge-tree": "~2.22.0",
|
|
76
|
+
"@fluidframework/sequence": "~2.22.0",
|
|
77
|
+
"@fluidframework/test-runtime-utils": "~2.22.0",
|
|
78
78
|
"@microsoft/api-extractor": "7.47.8",
|
|
79
79
|
"@types/mocha": "^10.0.10",
|
|
80
80
|
"@types/node": "^18.19.0",
|
|
@@ -124,8 +124,8 @@
|
|
|
124
124
|
"test": "npm run test:mocha",
|
|
125
125
|
"test:coverage": "c8 npm test",
|
|
126
126
|
"test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
|
|
127
|
-
"test:mocha:cjs": "mocha --recursive \"dist/test/**/*.spec.*js\"
|
|
128
|
-
"test:mocha:esm": "mocha --recursive \"lib/test/**/*.spec.*js\"
|
|
127
|
+
"test:mocha:cjs": "mocha --recursive \"dist/test/**/*.spec.*js\"",
|
|
128
|
+
"test:mocha:esm": "mocha --recursive \"lib/test/**/*.spec.*js\"",
|
|
129
129
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
130
130
|
"tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
|
|
131
131
|
"typetests:gen": "flub generate typetests --dir . -v",
|
package/src/mixinAttributor.ts
CHANGED
|
@@ -7,11 +7,7 @@ import { type IContainerContext } from "@fluidframework/container-definitions/in
|
|
|
7
7
|
import { ContainerRuntime } from "@fluidframework/container-runtime/internal";
|
|
8
8
|
import type { IContainerRuntimeOptions } from "@fluidframework/container-runtime/internal";
|
|
9
9
|
import { type IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
|
|
10
|
-
import {
|
|
11
|
-
type FluidObject,
|
|
12
|
-
type IRequest,
|
|
13
|
-
type IResponse,
|
|
14
|
-
} from "@fluidframework/core-interfaces";
|
|
10
|
+
import { type FluidObject } from "@fluidframework/core-interfaces";
|
|
15
11
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
16
12
|
import {
|
|
17
13
|
type IContainerRuntimeBase,
|
|
@@ -62,17 +58,12 @@ export const mixinAttributor = (
|
|
|
62
58
|
runtimeOptions?: IContainerRuntimeOptions;
|
|
63
59
|
containerScope?: FluidObject;
|
|
64
60
|
containerRuntimeCtor?: typeof ContainerRuntime;
|
|
65
|
-
/**
|
|
66
|
-
* @deprecated Will be removed once Loader LTS version is "2.0.0-internal.7.0.0". Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
|
|
67
|
-
*/
|
|
68
|
-
requestHandler?: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>;
|
|
69
61
|
provideEntryPoint: (containerRuntime: IContainerRuntime) => Promise<FluidObject>;
|
|
70
62
|
}): Promise<ContainerRuntime> {
|
|
71
63
|
const {
|
|
72
64
|
context,
|
|
73
65
|
registryEntries,
|
|
74
66
|
existing,
|
|
75
|
-
requestHandler,
|
|
76
67
|
provideEntryPoint,
|
|
77
68
|
runtimeOptions,
|
|
78
69
|
containerScope,
|
|
@@ -96,7 +87,6 @@ export const mixinAttributor = (
|
|
|
96
87
|
const runtime = (await Base.loadRuntime({
|
|
97
88
|
context,
|
|
98
89
|
registryEntries: registryEntriesCopy,
|
|
99
|
-
requestHandler,
|
|
100
90
|
provideEntryPoint,
|
|
101
91
|
runtimeOptions,
|
|
102
92
|
containerScope,
|
package/src/runtimeAttributor.ts
CHANGED
|
@@ -88,7 +88,7 @@ export class RuntimeAttributor implements IRuntimeAttributor {
|
|
|
88
88
|
if (baseSnapshotForAttributorTree === undefined) {
|
|
89
89
|
this.opAttributor = new OpStreamAttributor(deltaManager, quorum);
|
|
90
90
|
} else {
|
|
91
|
-
const id = baseSnapshotForAttributorTree.blobs[opBlobName];
|
|
91
|
+
const id: string | undefined = baseSnapshotForAttributorTree.blobs[opBlobName];
|
|
92
92
|
assert(
|
|
93
93
|
id !== undefined,
|
|
94
94
|
0x50a /* Attributor tree should have op attributor summary blob. */,
|