@fluid-experimental/attributor 2.1.0 → 2.3.0-288113

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +2 -2
  3. package/dist/attributorContracts.d.ts +49 -0
  4. package/dist/attributorContracts.d.ts.map +1 -0
  5. package/dist/attributorContracts.js +22 -0
  6. package/dist/attributorContracts.js.map +1 -0
  7. package/dist/index.d.ts +2 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +6 -4
  10. package/dist/index.js.map +1 -1
  11. package/dist/mixinAttributor.d.ts +8 -49
  12. package/dist/mixinAttributor.d.ts.map +1 -1
  13. package/dist/mixinAttributor.js +35 -140
  14. package/dist/mixinAttributor.js.map +1 -1
  15. package/dist/runtimeAttributor.d.ts +19 -0
  16. package/dist/runtimeAttributor.d.ts.map +1 -0
  17. package/dist/runtimeAttributor.js +71 -0
  18. package/dist/runtimeAttributor.js.map +1 -0
  19. package/dist/runtimeAttributorDataStoreChannel.d.ts +92 -0
  20. package/dist/runtimeAttributorDataStoreChannel.d.ts.map +1 -0
  21. package/dist/runtimeAttributorDataStoreChannel.js +177 -0
  22. package/dist/runtimeAttributorDataStoreChannel.js.map +1 -0
  23. package/dist/runtimeAttributorDataStoreFactory.d.ts +15 -0
  24. package/dist/runtimeAttributorDataStoreFactory.d.ts.map +1 -0
  25. package/dist/runtimeAttributorDataStoreFactory.js +39 -0
  26. package/dist/runtimeAttributorDataStoreFactory.js.map +1 -0
  27. package/lib/attributorContracts.d.ts +49 -0
  28. package/lib/attributorContracts.d.ts.map +1 -0
  29. package/lib/attributorContracts.js +19 -0
  30. package/lib/attributorContracts.js.map +1 -0
  31. package/lib/index.d.ts +2 -1
  32. package/lib/index.d.ts.map +1 -1
  33. package/lib/index.js +2 -1
  34. package/lib/index.js.map +1 -1
  35. package/lib/mixinAttributor.d.ts +8 -49
  36. package/lib/mixinAttributor.d.ts.map +1 -1
  37. package/lib/mixinAttributor.js +33 -138
  38. package/lib/mixinAttributor.js.map +1 -1
  39. package/lib/runtimeAttributor.d.ts +19 -0
  40. package/lib/runtimeAttributor.d.ts.map +1 -0
  41. package/lib/runtimeAttributor.js +67 -0
  42. package/lib/runtimeAttributor.js.map +1 -0
  43. package/lib/runtimeAttributorDataStoreChannel.d.ts +92 -0
  44. package/lib/runtimeAttributorDataStoreChannel.d.ts.map +1 -0
  45. package/lib/runtimeAttributorDataStoreChannel.js +173 -0
  46. package/lib/runtimeAttributorDataStoreChannel.js.map +1 -0
  47. package/lib/runtimeAttributorDataStoreFactory.d.ts +15 -0
  48. package/lib/runtimeAttributorDataStoreFactory.d.ts.map +1 -0
  49. package/lib/runtimeAttributorDataStoreFactory.js +35 -0
  50. package/lib/runtimeAttributorDataStoreFactory.js.map +1 -0
  51. package/package.json +20 -19
  52. package/src/attributorContracts.ts +61 -0
  53. package/src/index.ts +3 -3
  54. package/src/mixinAttributor.ts +45 -267
  55. package/src/runtimeAttributor.ts +111 -0
  56. package/src/runtimeAttributorDataStoreChannel.ts +261 -0
  57. package/src/runtimeAttributorDataStoreFactory.ts +59 -0
@@ -0,0 +1,173 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
6
+ import { AttachState } from "@fluidframework/container-definitions/internal";
7
+ import { assert, Deferred, unreachableCase } from "@fluidframework/core-utils/internal";
8
+ import { FluidObjectHandle } from "@fluidframework/datastore/internal";
9
+ import { VisibilityState, } from "@fluidframework/runtime-definitions/internal";
10
+ import { raiseConnectedEvent, createChildMonitoringContext, } from "@fluidframework/telemetry-utils/internal";
11
+ import { RuntimeAttributor } from "./runtimeAttributor.js";
12
+ /**
13
+ * Data store channel for the runtime attributor. This channel is responsible for storing and managing the
14
+ */
15
+ export class RuntimeAttributorDataStoreChannel extends TypedEventEmitter {
16
+ constructor(dataStoreContext, existing) {
17
+ super();
18
+ this.dataStoreContext = dataStoreContext;
19
+ this._disposed = false;
20
+ this.isEnabled = true;
21
+ this.deferredAttached = new Deferred();
22
+ this.runtimeAttributor = new RuntimeAttributor();
23
+ this.mc = createChildMonitoringContext({
24
+ logger: dataStoreContext.baseLogger,
25
+ namespace: "Attributor",
26
+ });
27
+ this.attachState = dataStoreContext.attachState;
28
+ if (existing) {
29
+ this.visibilityState =
30
+ dataStoreContext.attachState === AttachState.Detached
31
+ ? VisibilityState.LocallyVisible
32
+ : VisibilityState.GloballyVisible;
33
+ }
34
+ else {
35
+ this.visibilityState = VisibilityState.NotVisible;
36
+ }
37
+ // If it's existing we know it has been attached.
38
+ if (existing) {
39
+ this.deferredAttached.resolve();
40
+ }
41
+ this.entryPoint = new FluidObjectHandle(this.runtimeAttributor, "", dataStoreContext.IFluidHandleContext);
42
+ }
43
+ get IFluidDataStoreChannel() {
44
+ return this;
45
+ }
46
+ get disposed() {
47
+ return this._disposed;
48
+ }
49
+ dispose() {
50
+ this._disposed = true;
51
+ }
52
+ get logger() {
53
+ return this.mc.logger;
54
+ }
55
+ async initialize(deltaManager, quorum, baseSnapshotForAttributorTree, readBlob) {
56
+ await this.runtimeAttributor.initialize(deltaManager, quorum, baseSnapshotForAttributorTree, readBlob);
57
+ }
58
+ /**
59
+ * {@inheritdoc IFluidDataStoreChannel.makeVisibleAndAttachGraph}
60
+ */
61
+ makeVisibleAndAttachGraph() {
62
+ if (this.visibilityState !== VisibilityState.NotVisible) {
63
+ return;
64
+ }
65
+ this.visibilityState = VisibilityState.LocallyVisible;
66
+ this.dataStoreContext.makeLocallyVisible();
67
+ }
68
+ /**
69
+ * {@inheritdoc IFluidDataStoreChannel.getAttachSummary}
70
+ */
71
+ getAttachSummary(telemetryContext) {
72
+ return this.runtimeAttributor.summarizeOpAttributor();
73
+ }
74
+ /**
75
+ * {@inheritdoc IFluidDataStoreChannel.getAttachGCData}
76
+ */
77
+ getAttachGCData(telemetryContext) {
78
+ return { gcNodes: {} };
79
+ }
80
+ /**
81
+ * {@inheritdoc IFluidDataStoreChannel.process}
82
+ */
83
+ process(message, local, localOpMetadata) {
84
+ throw new Error("Attributor should not receive messages yet");
85
+ }
86
+ /**
87
+ * {@inheritdoc IFluidDataStoreChannel.processSignal}
88
+ */
89
+ processSignal(message, local) {
90
+ throw new Error("Attributor should not receive signals");
91
+ }
92
+ /**
93
+ * {@inheritdoc IFluidDataStoreChannel.summarize}
94
+ */
95
+ async summarize(fullTree, trackState, telemetryContext) {
96
+ return this.runtimeAttributor.summarizeOpAttributor();
97
+ }
98
+ /**
99
+ * {@inheritdoc IFluidDataStoreChannel.getGCData}
100
+ */
101
+ async getGCData(fullGC) {
102
+ // Nothing to be GCed from the attributor.
103
+ const garbageCollectionData = { gcNodes: {} };
104
+ return garbageCollectionData;
105
+ }
106
+ /**
107
+ * {@inheritdoc IFluidDataStoreChannel.updateUsedRoutes}
108
+ */
109
+ updateUsedRoutes(usedRoutes) {
110
+ return;
111
+ }
112
+ /**
113
+ * {@inheritdoc IFluidDataStoreChannel.setConnectionState}
114
+ */
115
+ setConnectionState(connected, clientId) {
116
+ raiseConnectedEvent(this.logger, this, connected, clientId);
117
+ }
118
+ /**
119
+ * {@inheritdoc IFluidDataStoreChannel.reSubmit}
120
+ */
121
+ reSubmit(type, content, localOpMetadata) {
122
+ // Should not resubmit anything from the attributor as the attributor does not send ops yet.
123
+ throw new Error("Should not resubmit anything from the attributor");
124
+ }
125
+ /**
126
+ * {@inheritdoc IFluidDataStoreChannel.applyStashedOp}
127
+ */
128
+ async applyStashedOp(content) {
129
+ // Should not apply stashed ops to the attributor as the attributor does not send ops yet.
130
+ throw new Error("Should not apply stashed ops to the attributor");
131
+ }
132
+ /**
133
+ * {@inheritdoc IFluidDataStoreChannel.rollback}
134
+ */
135
+ rollback(type, content, localOpMetadata) {
136
+ // Should not rollback anything from the attributor as it does not send ops yet.
137
+ throw new Error("Should not rollback anything from the attributor");
138
+ }
139
+ /**
140
+ * {@inheritdoc IFluidDataStoreChannel.request}
141
+ */
142
+ async request(request) {
143
+ // Should not request anything from the attributor as the attributor does not have any channels further.
144
+ throw new Error("Should not request anything from the attributor");
145
+ }
146
+ /**
147
+ * {@inheritdoc IFluidDataStoreChannel.setAttachState}
148
+ */
149
+ setAttachState(attachState) {
150
+ switch (attachState) {
151
+ case AttachState.Attaching: {
152
+ this.attachState = AttachState.Attaching;
153
+ assert(this.visibilityState === VisibilityState.LocallyVisible, 0xa1e /* Data store should be locally visible before it can become globally visible. */);
154
+ // Mark the data store globally visible and make its child channels visible as well.
155
+ this.visibilityState = VisibilityState.GloballyVisible;
156
+ // This promise resolution will be moved to attached event once we fix the scheduler.
157
+ this.deferredAttached.resolve();
158
+ this.emit("attaching");
159
+ break;
160
+ }
161
+ case AttachState.Attached: {
162
+ assert(this.visibilityState === VisibilityState.GloballyVisible, 0xa1f /* Data store should be globally visible when its attached. */);
163
+ this.attachState = AttachState.Attached;
164
+ this.emit("attached");
165
+ break;
166
+ }
167
+ default: {
168
+ unreachableCase(attachState, "unreached");
169
+ }
170
+ }
171
+ }
172
+ }
173
+ //# sourceMappingURL=runtimeAttributorDataStoreChannel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeAttributorDataStoreChannel.js","sourceRoot":"","sources":["../src/runtimeAttributorDataStoreChannel.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAiB,MAAM,gDAAgD,CAAC;AAG5F,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAQvE,OAAO,EAKN,eAAe,GAGf,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAGN,mBAAmB,EACnB,4BAA4B,GAC5B,MAAM,0CAA0C,CAAC;AAElD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IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACvB,MAAM;YACP,CAAC;YACD,KAAK,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAC3B,MAAM,CACL,IAAI,CAAC,eAAe,KAAK,eAAe,CAAC,eAAe,EACxD,KAAK,CAAC,8DAA8D,CACpE,CAAC;gBACF,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC,QAAQ,CAAC;gBACxC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBACtB,MAAM;YACP,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACT,eAAe,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;YAC3C,CAAC;QACF,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { AttachState, IDeltaManager } from \"@fluidframework/container-definitions/internal\";\nimport { FluidObject, IRequest, IResponse } from \"@fluidframework/core-interfaces\";\nimport type { IFluidHandleInternal } from \"@fluidframework/core-interfaces/internal\";\nimport { assert, Deferred, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { FluidObjectHandle } from \"@fluidframework/datastore/internal\";\nimport { IFluidDataStoreRuntimeEvents } from \"@fluidframework/datastore-definitions/internal\";\nimport {\n\tIDocumentMessage,\n\ttype ISnapshotTree,\n\tISequencedDocumentMessage,\n\tIQuorumClients,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tIGarbageCollectionData,\n\tIFluidDataStoreChannel,\n\tIFluidDataStoreContext,\n\tIInboundSignalMessage,\n\tVisibilityState,\n\ttype ISummaryTreeWithStats,\n\ttype ITelemetryContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tMonitoringContext,\n\traiseConnectedEvent,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { RuntimeAttributor } from \"./runtimeAttributor.js\";\n\n/**\n * Data store channel for the runtime attributor. This channel is responsible for storing and managing the\n */\nexport class RuntimeAttributorDataStoreChannel\n\textends TypedEventEmitter<IFluidDataStoreRuntimeEvents>\n\timplements IFluidDataStoreChannel\n{\n\tpublic constructor(\n\t\tpublic readonly dataStoreContext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t) {\n\t\tsuper();\n\t\tthis.runtimeAttributor = new RuntimeAttributor();\n\t\tthis.mc = createChildMonitoringContext({\n\t\t\tlogger: dataStoreContext.baseLogger,\n\t\t\tnamespace: \"Attributor\",\n\t\t});\n\t\tthis.attachState = dataStoreContext.attachState;\n\t\tif (existing) {\n\t\t\tthis.visibilityState =\n\t\t\t\tdataStoreContext.attachState === AttachState.Detached\n\t\t\t\t\t? VisibilityState.LocallyVisible\n\t\t\t\t\t: VisibilityState.GloballyVisible;\n\t\t} else {\n\t\t\tthis.visibilityState = VisibilityState.NotVisible;\n\t\t}\n\t\t// If it's existing we know it has been attached.\n\t\tif (existing) {\n\t\t\tthis.deferredAttached.resolve();\n\t\t}\n\t\tthis.entryPoint = new FluidObjectHandle<FluidObject>(\n\t\t\tthis.runtimeAttributor,\n\t\t\t\"\",\n\t\t\tdataStoreContext.IFluidHandleContext,\n\t\t);\n\t}\n\n\tpublic get IFluidDataStoreChannel(): IFluidDataStoreChannel {\n\t\treturn this;\n\t}\n\n\tprivate _disposed = false;\n\tpublic get disposed(): boolean {\n\t\treturn this._disposed;\n\t}\n\n\tpublic dispose(): void {\n\t\tthis._disposed = true;\n\t}\n\n\tprivate readonly runtimeAttributor: RuntimeAttributor;\n\tpublic isEnabled = true;\n\tpublic attachState: AttachState;\n\tpublic visibilityState: VisibilityState;\n\tprivate readonly deferredAttached = new Deferred<void>();\n\tprivate readonly mc: MonitoringContext;\n\tpublic get logger(): ITelemetryLoggerExt {\n\t\treturn this.mc.logger;\n\t}\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\tawait this.runtimeAttributor.initialize(\n\t\t\tdeltaManager,\n\t\t\tquorum,\n\t\t\tbaseSnapshotForAttributorTree,\n\t\t\treadBlob,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.makeVisibleAndAttachGraph}\n\t */\n\tpublic makeVisibleAndAttachGraph(): void {\n\t\tif (this.visibilityState !== VisibilityState.NotVisible) {\n\t\t\treturn;\n\t\t}\n\t\tthis.visibilityState = VisibilityState.LocallyVisible;\n\n\t\tthis.dataStoreContext.makeLocallyVisible();\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.getAttachSummary}\n\t */\n\tpublic getAttachSummary(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats {\n\t\treturn this.runtimeAttributor.summarizeOpAttributor();\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.getAttachGCData}\n\t */\n\tpublic getAttachGCData(telemetryContext?: ITelemetryContext): IGarbageCollectionData {\n\t\treturn { gcNodes: {} };\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.process}\n\t */\n\tpublic process(\n\t\tmessage: ISequencedDocumentMessage,\n\t\tlocal: boolean,\n\t\tlocalOpMetadata: unknown,\n\t): void {\n\t\tthrow new Error(\"Attributor should not receive messages yet\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.processSignal}\n\t */\n\tpublic processSignal(message: IInboundSignalMessage, local: boolean): void {\n\t\tthrow new Error(\"Attributor should not receive signals\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.summarize}\n\t */\n\tpublic async summarize(\n\t\tfullTree?: boolean,\n\t\ttrackState?: boolean,\n\t\ttelemetryContext?: ITelemetryContext,\n\t): Promise<ISummaryTreeWithStats> {\n\t\treturn this.runtimeAttributor.summarizeOpAttributor();\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.getGCData}\n\t */\n\tpublic async getGCData(fullGC?: boolean): Promise<IGarbageCollectionData> {\n\t\t// Nothing to be GCed from the attributor.\n\t\tconst garbageCollectionData: IGarbageCollectionData = { gcNodes: {} };\n\t\treturn garbageCollectionData;\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.updateUsedRoutes}\n\t */\n\tpublic updateUsedRoutes(usedRoutes: string[]): void {\n\t\treturn;\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.setConnectionState}\n\t */\n\tpublic setConnectionState(connected: boolean, clientId?: string): void {\n\t\traiseConnectedEvent(this.logger, this, connected, clientId);\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.reSubmit}\n\t */\n\tpublic reSubmit(type: string, content: unknown, localOpMetadata: unknown): void {\n\t\t// Should not resubmit anything from the attributor as the attributor does not send ops yet.\n\t\tthrow new Error(\"Should not resubmit anything from the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.applyStashedOp}\n\t */\n\tpublic async applyStashedOp(content: unknown): Promise<unknown> {\n\t\t// Should not apply stashed ops to the attributor as the attributor does not send ops yet.\n\t\tthrow new Error(\"Should not apply stashed ops to the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.rollback}\n\t */\n\tpublic rollback?(type: string, content: unknown, localOpMetadata: unknown): void {\n\t\t// Should not rollback anything from the attributor as it does not send ops yet.\n\t\tthrow new Error(\"Should not rollback anything from the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.entryPoint}\n\t */\n\tpublic readonly entryPoint: IFluidHandleInternal<FluidObject>;\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.request}\n\t */\n\tpublic async request(request: IRequest): Promise<IResponse> {\n\t\t// Should not request anything from the attributor as the attributor does not have any channels further.\n\t\tthrow new Error(\"Should not request anything from the attributor\");\n\t}\n\n\t/**\n\t * {@inheritdoc IFluidDataStoreChannel.setAttachState}\n\t */\n\tpublic setAttachState(attachState: AttachState.Attaching | AttachState.Attached): void {\n\t\tswitch (attachState) {\n\t\t\tcase AttachState.Attaching: {\n\t\t\t\tthis.attachState = AttachState.Attaching;\n\n\t\t\t\tassert(\n\t\t\t\t\tthis.visibilityState === VisibilityState.LocallyVisible,\n\t\t\t\t\t0xa1e /* Data store should be locally visible before it can become globally visible. */,\n\t\t\t\t);\n\n\t\t\t\t// Mark the data store globally visible and make its child channels visible as well.\n\t\t\t\tthis.visibilityState = VisibilityState.GloballyVisible;\n\n\t\t\t\t// This promise resolution will be moved to attached event once we fix the scheduler.\n\t\t\t\tthis.deferredAttached.resolve();\n\t\t\t\tthis.emit(\"attaching\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase AttachState.Attached: {\n\t\t\t\tassert(\n\t\t\t\t\tthis.visibilityState === VisibilityState.GloballyVisible,\n\t\t\t\t\t0xa1f /* Data store should be globally visible when its attached. */,\n\t\t\t\t);\n\t\t\t\tthis.attachState = AttachState.Attached;\n\t\t\t\tthis.emit(\"attached\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(attachState, \"unreached\");\n\t\t\t}\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,15 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { IFluidDataStoreFactory, IFluidDataStoreChannel, IFluidDataStoreContext } from "@fluidframework/runtime-definitions/internal";
6
+ /**
7
+ * Factory for the runtime attributor data store channel.
8
+ */
9
+ export declare class RuntimeAttributorFactory implements IFluidDataStoreFactory {
10
+ static readonly type = "@fluid-experimental/attributor";
11
+ get type(): string;
12
+ get IFluidDataStoreFactory(): IFluidDataStoreFactory;
13
+ instantiateDataStore(context: IFluidDataStoreContext, existing: boolean): Promise<IFluidDataStoreChannel>;
14
+ }
15
+ //# sourceMappingURL=runtimeAttributorDataStoreFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeAttributorDataStoreFactory.d.ts","sourceRoot":"","sources":["../src/runtimeAttributorDataStoreFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,MAAM,8CAA8C,CAAC;AAKtD;;GAEG;AACH,qBAAa,wBAAyB,YAAW,sBAAsB;IACtE,gBAAuB,IAAI,oCAAoC;IAE/D,IAAW,IAAI,IAAI,MAAM,CAExB;IAED,IAAW,sBAAsB,IAAI,sBAAsB,CAE1D;IAEY,oBAAoB,CAChC,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,OAAO,GACf,OAAO,CAAC,sBAAsB,CAAC;CA2BlC"}
@@ -0,0 +1,35 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { PerformanceEvent, createChildLogger } from "@fluidframework/telemetry-utils/internal";
6
+ import { RuntimeAttributorDataStoreChannel } from "./runtimeAttributorDataStoreChannel.js";
7
+ /**
8
+ * Factory for the runtime attributor data store channel.
9
+ */
10
+ export class RuntimeAttributorFactory {
11
+ get type() {
12
+ return RuntimeAttributorFactory.type;
13
+ }
14
+ get IFluidDataStoreFactory() {
15
+ return this;
16
+ }
17
+ async instantiateDataStore(context, existing) {
18
+ const runtime = new RuntimeAttributorDataStoreChannel(context, existing);
19
+ const logger = createChildLogger({
20
+ logger: context.baseLogger,
21
+ namespace: "Attributor",
22
+ });
23
+ await PerformanceEvent.timedExecAsync(logger, {
24
+ eventName: "initialize",
25
+ }, async (event) => {
26
+ await runtime.initialize(context.deltaManager, context.getQuorum(), context.baseSnapshot, async (id) => context.storage.readBlob(id));
27
+ event.end({
28
+ attributionEnabledInDoc: true, // If we are instantiating the attributor, it is enabled
29
+ });
30
+ });
31
+ return runtime;
32
+ }
33
+ }
34
+ RuntimeAttributorFactory.type = "@fluid-experimental/attributor";
35
+ //# sourceMappingURL=runtimeAttributorDataStoreFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeAttributorDataStoreFactory.js","sourceRoot":"","sources":["../src/runtimeAttributorDataStoreFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAE/F,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAE3F;;GAEG;AACH,MAAM,OAAO,wBAAwB;IAGpC,IAAW,IAAI;QACd,OAAO,wBAAwB,CAAC,IAAI,CAAC;IACtC,CAAC;IAED,IAAW,sBAAsB;QAChC,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAChC,OAA+B,EAC/B,QAAiB;QAEjB,MAAM,OAAO,GAAG,IAAI,iCAAiC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAEzE,MAAM,MAAM,GAAG,iBAAiB,CAAC;YAChC,MAAM,EAAE,OAAO,CAAC,UAAU;YAC1B,SAAS,EAAE,YAAY;SACvB,CAAC,CAAC;QAEH,MAAM,gBAAgB,CAAC,cAAc,CACpC,MAAM,EACN;YACC,SAAS,EAAE,YAAY;SACvB,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;YACf,MAAM,OAAO,CAAC,UAAU,CACvB,OAAO,CAAC,YAAY,EACpB,OAAO,CAAC,SAAS,EAAE,EACnB,OAAO,CAAC,YAAY,EACpB,KAAK,EAAE,EAAU,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAClD,CAAC;YACF,KAAK,CAAC,GAAG,CAAC;gBACT,uBAAuB,EAAE,IAAI,EAAE,wDAAwD;aACvF,CAAC,CAAC;QACJ,CAAC,CACD,CAAC;QACF,OAAO,OAAO,CAAC;IAChB,CAAC;;AAvCsB,6BAAI,GAAG,gCAAgC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIFluidDataStoreFactory,\n\tIFluidDataStoreChannel,\n\tIFluidDataStoreContext,\n} from \"@fluidframework/runtime-definitions/internal\";\nimport { PerformanceEvent, createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { RuntimeAttributorDataStoreChannel } from \"./runtimeAttributorDataStoreChannel.js\";\n\n/**\n * Factory for the runtime attributor data store channel.\n */\nexport class RuntimeAttributorFactory implements IFluidDataStoreFactory {\n\tpublic static readonly type = \"@fluid-experimental/attributor\";\n\n\tpublic get type(): string {\n\t\treturn RuntimeAttributorFactory.type;\n\t}\n\n\tpublic get IFluidDataStoreFactory(): IFluidDataStoreFactory {\n\t\treturn this;\n\t}\n\n\tpublic async instantiateDataStore(\n\t\tcontext: IFluidDataStoreContext,\n\t\texisting: boolean,\n\t): Promise<IFluidDataStoreChannel> {\n\t\tconst runtime = new RuntimeAttributorDataStoreChannel(context, existing);\n\n\t\tconst logger = createChildLogger({\n\t\t\tlogger: context.baseLogger,\n\t\t\tnamespace: \"Attributor\",\n\t\t});\n\n\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"initialize\",\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tawait runtime.initialize(\n\t\t\t\t\tcontext.deltaManager,\n\t\t\t\t\tcontext.getQuorum(),\n\t\t\t\t\tcontext.baseSnapshot,\n\t\t\t\t\tasync (id: string) => context.storage.readBlob(id),\n\t\t\t\t);\n\t\t\t\tevent.end({\n\t\t\t\t\tattributionEnabledInDoc: true, // If we are instantiating the attributor, it is enabled\n\t\t\t\t});\n\t\t\t},\n\t\t);\n\t\treturn runtime;\n\t}\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-experimental/attributor",
3
- "version": "2.1.0",
3
+ "version": "2.3.0-288113",
4
4
  "description": "Operation attributor",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -47,31 +47,32 @@
47
47
  "temp-directory": "nyc/.nyc_output"
48
48
  },
49
49
  "dependencies": {
50
- "@fluid-internal/client-utils": "~2.1.0",
51
- "@fluidframework/container-definitions": "~2.1.0",
52
- "@fluidframework/container-runtime": "~2.1.0",
53
- "@fluidframework/container-runtime-definitions": "~2.1.0",
54
- "@fluidframework/core-interfaces": "~2.1.0",
55
- "@fluidframework/core-utils": "~2.1.0",
56
- "@fluidframework/datastore-definitions": "~2.1.0",
57
- "@fluidframework/driver-definitions": "~2.1.0",
58
- "@fluidframework/runtime-definitions": "~2.1.0",
59
- "@fluidframework/runtime-utils": "~2.1.0",
60
- "@fluidframework/telemetry-utils": "~2.1.0",
50
+ "@fluid-internal/client-utils": "2.3.0-288113",
51
+ "@fluidframework/container-definitions": "2.3.0-288113",
52
+ "@fluidframework/container-runtime": "2.3.0-288113",
53
+ "@fluidframework/container-runtime-definitions": "2.3.0-288113",
54
+ "@fluidframework/core-interfaces": "2.3.0-288113",
55
+ "@fluidframework/core-utils": "2.3.0-288113",
56
+ "@fluidframework/datastore": "2.3.0-288113",
57
+ "@fluidframework/datastore-definitions": "2.3.0-288113",
58
+ "@fluidframework/driver-definitions": "2.3.0-288113",
59
+ "@fluidframework/runtime-definitions": "2.3.0-288113",
60
+ "@fluidframework/runtime-utils": "2.3.0-288113",
61
+ "@fluidframework/telemetry-utils": "2.3.0-288113",
61
62
  "lz4js": "^0.2.0"
62
63
  },
63
64
  "devDependencies": {
64
65
  "@arethetypeswrong/cli": "^0.15.2",
65
66
  "@biomejs/biome": "~1.8.3",
66
- "@fluid-internal/mocha-test-setup": "~2.1.0",
67
- "@fluid-private/stochastic-test-utils": "~2.1.0",
68
- "@fluid-tools/build-cli": "^0.41.0",
67
+ "@fluid-internal/mocha-test-setup": "2.3.0-288113",
68
+ "@fluid-private/stochastic-test-utils": "2.3.0-288113",
69
+ "@fluid-tools/build-cli": "^0.43.0",
69
70
  "@fluidframework/build-common": "^2.0.3",
70
- "@fluidframework/build-tools": "^0.41.0",
71
+ "@fluidframework/build-tools": "^0.43.0",
71
72
  "@fluidframework/eslint-config-fluid": "^5.3.0",
72
- "@fluidframework/merge-tree": "~2.1.0",
73
- "@fluidframework/sequence": "~2.1.0",
74
- "@fluidframework/test-runtime-utils": "~2.1.0",
73
+ "@fluidframework/merge-tree": "2.3.0-288113",
74
+ "@fluidframework/sequence": "2.3.0-288113",
75
+ "@fluidframework/test-runtime-utils": "2.3.0-288113",
75
76
  "@microsoft/api-extractor": "^7.45.1",
76
77
  "@types/mocha": "^9.1.1",
77
78
  "@types/node": "^18.19.0",
@@ -0,0 +1,61 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import {
7
+ type AttributionInfo,
8
+ type AttributionKey,
9
+ } from "@fluidframework/runtime-definitions/internal";
10
+
11
+ // Summary tree keys
12
+ export const opBlobName = "opAttributor";
13
+
14
+ /**
15
+ * @internal
16
+ */
17
+ export const enableOnNewFileKey = "Fluid.Attribution.EnableOnNewFile";
18
+
19
+ /**
20
+ * @internal
21
+ */
22
+ export const IRuntimeAttributor: keyof IProvideRuntimeAttributor = "IRuntimeAttributor";
23
+
24
+ /**
25
+ * @internal
26
+ */
27
+ export interface IProvideRuntimeAttributor {
28
+ readonly IRuntimeAttributor: IRuntimeAttributor;
29
+ }
30
+
31
+ /**
32
+ * @internal
33
+ */
34
+ export const attributorDataStoreAlias = "attributor-cf9b6fe4-4c50-4a5d-9045-eb73b886f740";
35
+
36
+ /**
37
+ * Provides access to attribution information stored on the container runtime.
38
+ *
39
+ * @remarks Attributors are only populated after the container runtime into which they are being injected has initialized.
40
+ *
41
+ * @sealed
42
+ * @internal
43
+ */
44
+ export interface IRuntimeAttributor extends IProvideRuntimeAttributor {
45
+ /**
46
+ * @throws - If no AttributionInfo exists for this key.
47
+ */
48
+ get(key: AttributionKey): AttributionInfo;
49
+
50
+ /**
51
+ * @returns Whether any AttributionInfo exists for the provided key.
52
+ */
53
+ has(key: AttributionKey): boolean;
54
+
55
+ /**
56
+ * @returns Whether the runtime is currently tracking attribution information for the loaded container.
57
+ * If enabled, the runtime attributor can be asked for the attribution info for different keys.
58
+ * See {@link mixinAttributor} for more details on when this happens.
59
+ */
60
+ readonly isEnabled: boolean;
61
+ }
package/src/index.ts CHANGED
@@ -4,10 +4,10 @@
4
4
  */
5
5
 
6
6
  export { type IAttributor } from "./attributor.js";
7
+ export { mixinAttributor, getRuntimeAttributor } from "./mixinAttributor.js";
7
8
  export {
8
- createRuntimeAttributor,
9
+ attributorDataStoreAlias,
9
10
  enableOnNewFileKey,
10
11
  type IProvideRuntimeAttributor,
11
12
  IRuntimeAttributor,
12
- mixinAttributor,
13
- } from "./mixinAttributor.js";
13
+ } from "./attributorContracts.js";