@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,92 @@
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, IDeltaManager } from "@fluidframework/container-definitions/internal";
7
+ import { FluidObject, IRequest, IResponse } from "@fluidframework/core-interfaces";
8
+ import type { IFluidHandleInternal } from "@fluidframework/core-interfaces/internal";
9
+ import { IFluidDataStoreRuntimeEvents } from "@fluidframework/datastore-definitions/internal";
10
+ import { IDocumentMessage, type ISnapshotTree, ISequencedDocumentMessage, IQuorumClients } from "@fluidframework/driver-definitions/internal";
11
+ import { IGarbageCollectionData, IFluidDataStoreChannel, IFluidDataStoreContext, IInboundSignalMessage, VisibilityState, type ISummaryTreeWithStats, type ITelemetryContext } from "@fluidframework/runtime-definitions/internal";
12
+ import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
13
+ /**
14
+ * Data store channel for the runtime attributor. This channel is responsible for storing and managing the
15
+ */
16
+ export declare class RuntimeAttributorDataStoreChannel extends TypedEventEmitter<IFluidDataStoreRuntimeEvents> implements IFluidDataStoreChannel {
17
+ readonly dataStoreContext: IFluidDataStoreContext;
18
+ constructor(dataStoreContext: IFluidDataStoreContext, existing: boolean);
19
+ get IFluidDataStoreChannel(): IFluidDataStoreChannel;
20
+ private _disposed;
21
+ get disposed(): boolean;
22
+ dispose(): void;
23
+ private readonly runtimeAttributor;
24
+ isEnabled: boolean;
25
+ attachState: AttachState;
26
+ visibilityState: VisibilityState;
27
+ private readonly deferredAttached;
28
+ private readonly mc;
29
+ get logger(): ITelemetryLoggerExt;
30
+ initialize(deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>, quorum: IQuorumClients, baseSnapshotForAttributorTree: ISnapshotTree | undefined, readBlob: (id: string) => Promise<ArrayBufferLike>): Promise<void>;
31
+ /**
32
+ * {@inheritdoc IFluidDataStoreChannel.makeVisibleAndAttachGraph}
33
+ */
34
+ makeVisibleAndAttachGraph(): void;
35
+ /**
36
+ * {@inheritdoc IFluidDataStoreChannel.getAttachSummary}
37
+ */
38
+ getAttachSummary(telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
39
+ /**
40
+ * {@inheritdoc IFluidDataStoreChannel.getAttachGCData}
41
+ */
42
+ getAttachGCData(telemetryContext?: ITelemetryContext): IGarbageCollectionData;
43
+ /**
44
+ * {@inheritdoc IFluidDataStoreChannel.process}
45
+ */
46
+ process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
47
+ /**
48
+ * {@inheritdoc IFluidDataStoreChannel.processSignal}
49
+ */
50
+ processSignal(message: IInboundSignalMessage, local: boolean): void;
51
+ /**
52
+ * {@inheritdoc IFluidDataStoreChannel.summarize}
53
+ */
54
+ summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummaryTreeWithStats>;
55
+ /**
56
+ * {@inheritdoc IFluidDataStoreChannel.getGCData}
57
+ */
58
+ getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;
59
+ /**
60
+ * {@inheritdoc IFluidDataStoreChannel.updateUsedRoutes}
61
+ */
62
+ updateUsedRoutes(usedRoutes: string[]): void;
63
+ /**
64
+ * {@inheritdoc IFluidDataStoreChannel.setConnectionState}
65
+ */
66
+ setConnectionState(connected: boolean, clientId?: string): void;
67
+ /**
68
+ * {@inheritdoc IFluidDataStoreChannel.reSubmit}
69
+ */
70
+ reSubmit(type: string, content: unknown, localOpMetadata: unknown): void;
71
+ /**
72
+ * {@inheritdoc IFluidDataStoreChannel.applyStashedOp}
73
+ */
74
+ applyStashedOp(content: unknown): Promise<unknown>;
75
+ /**
76
+ * {@inheritdoc IFluidDataStoreChannel.rollback}
77
+ */
78
+ rollback?(type: string, content: unknown, localOpMetadata: unknown): void;
79
+ /**
80
+ * {@inheritdoc IFluidDataStoreChannel.entryPoint}
81
+ */
82
+ readonly entryPoint: IFluidHandleInternal<FluidObject>;
83
+ /**
84
+ * {@inheritdoc IFluidDataStoreChannel.request}
85
+ */
86
+ request(request: IRequest): Promise<IResponse>;
87
+ /**
88
+ * {@inheritdoc IFluidDataStoreChannel.setAttachState}
89
+ */
90
+ setAttachState(attachState: AttachState.Attaching | AttachState.Attached): void;
91
+ }
92
+ //# sourceMappingURL=runtimeAttributorDataStoreChannel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeAttributorDataStoreChannel.d.ts","sourceRoot":"","sources":["../src/runtimeAttributorDataStoreChannel.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAC5F,OAAO,EAAE,WAAW,EAAE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EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IAK3D;;OAEG;IACI,cAAc,CAAC,WAAW,EAAE,WAAW,CAAC,SAAS,GAAG,WAAW,CAAC,QAAQ,GAAG,IAAI;CAgCtF"}
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ /*!
3
+ * 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.RuntimeAttributorDataStoreChannel = void 0;
8
+ const client_utils_1 = require("@fluid-internal/client-utils");
9
+ const internal_1 = require("@fluidframework/container-definitions/internal");
10
+ const internal_2 = require("@fluidframework/core-utils/internal");
11
+ const internal_3 = require("@fluidframework/datastore/internal");
12
+ const internal_4 = require("@fluidframework/runtime-definitions/internal");
13
+ const internal_5 = require("@fluidframework/telemetry-utils/internal");
14
+ const runtimeAttributor_js_1 = require("./runtimeAttributor.js");
15
+ /**
16
+ * Data store channel for the runtime attributor. This channel is responsible for storing and managing the
17
+ */
18
+ class RuntimeAttributorDataStoreChannel extends client_utils_1.TypedEventEmitter {
19
+ constructor(dataStoreContext, existing) {
20
+ super();
21
+ this.dataStoreContext = dataStoreContext;
22
+ this._disposed = false;
23
+ this.isEnabled = true;
24
+ this.deferredAttached = new internal_2.Deferred();
25
+ this.runtimeAttributor = new runtimeAttributor_js_1.RuntimeAttributor();
26
+ this.mc = (0, internal_5.createChildMonitoringContext)({
27
+ logger: dataStoreContext.baseLogger,
28
+ namespace: "Attributor",
29
+ });
30
+ this.attachState = dataStoreContext.attachState;
31
+ if (existing) {
32
+ this.visibilityState =
33
+ dataStoreContext.attachState === internal_1.AttachState.Detached
34
+ ? internal_4.VisibilityState.LocallyVisible
35
+ : internal_4.VisibilityState.GloballyVisible;
36
+ }
37
+ else {
38
+ this.visibilityState = internal_4.VisibilityState.NotVisible;
39
+ }
40
+ // If it's existing we know it has been attached.
41
+ if (existing) {
42
+ this.deferredAttached.resolve();
43
+ }
44
+ this.entryPoint = new internal_3.FluidObjectHandle(this.runtimeAttributor, "", dataStoreContext.IFluidHandleContext);
45
+ }
46
+ get IFluidDataStoreChannel() {
47
+ return this;
48
+ }
49
+ get disposed() {
50
+ return this._disposed;
51
+ }
52
+ dispose() {
53
+ this._disposed = true;
54
+ }
55
+ get logger() {
56
+ return this.mc.logger;
57
+ }
58
+ async initialize(deltaManager, quorum, baseSnapshotForAttributorTree, readBlob) {
59
+ await this.runtimeAttributor.initialize(deltaManager, quorum, baseSnapshotForAttributorTree, readBlob);
60
+ }
61
+ /**
62
+ * {@inheritdoc IFluidDataStoreChannel.makeVisibleAndAttachGraph}
63
+ */
64
+ makeVisibleAndAttachGraph() {
65
+ if (this.visibilityState !== internal_4.VisibilityState.NotVisible) {
66
+ return;
67
+ }
68
+ this.visibilityState = internal_4.VisibilityState.LocallyVisible;
69
+ this.dataStoreContext.makeLocallyVisible();
70
+ }
71
+ /**
72
+ * {@inheritdoc IFluidDataStoreChannel.getAttachSummary}
73
+ */
74
+ getAttachSummary(telemetryContext) {
75
+ return this.runtimeAttributor.summarizeOpAttributor();
76
+ }
77
+ /**
78
+ * {@inheritdoc IFluidDataStoreChannel.getAttachGCData}
79
+ */
80
+ getAttachGCData(telemetryContext) {
81
+ return { gcNodes: {} };
82
+ }
83
+ /**
84
+ * {@inheritdoc IFluidDataStoreChannel.process}
85
+ */
86
+ process(message, local, localOpMetadata) {
87
+ throw new Error("Attributor should not receive messages yet");
88
+ }
89
+ /**
90
+ * {@inheritdoc IFluidDataStoreChannel.processSignal}
91
+ */
92
+ processSignal(message, local) {
93
+ throw new Error("Attributor should not receive signals");
94
+ }
95
+ /**
96
+ * {@inheritdoc IFluidDataStoreChannel.summarize}
97
+ */
98
+ async summarize(fullTree, trackState, telemetryContext) {
99
+ return this.runtimeAttributor.summarizeOpAttributor();
100
+ }
101
+ /**
102
+ * {@inheritdoc IFluidDataStoreChannel.getGCData}
103
+ */
104
+ async getGCData(fullGC) {
105
+ // Nothing to be GCed from the attributor.
106
+ const garbageCollectionData = { gcNodes: {} };
107
+ return garbageCollectionData;
108
+ }
109
+ /**
110
+ * {@inheritdoc IFluidDataStoreChannel.updateUsedRoutes}
111
+ */
112
+ updateUsedRoutes(usedRoutes) {
113
+ return;
114
+ }
115
+ /**
116
+ * {@inheritdoc IFluidDataStoreChannel.setConnectionState}
117
+ */
118
+ setConnectionState(connected, clientId) {
119
+ (0, internal_5.raiseConnectedEvent)(this.logger, this, connected, clientId);
120
+ }
121
+ /**
122
+ * {@inheritdoc IFluidDataStoreChannel.reSubmit}
123
+ */
124
+ reSubmit(type, content, localOpMetadata) {
125
+ // Should not resubmit anything from the attributor as the attributor does not send ops yet.
126
+ throw new Error("Should not resubmit anything from the attributor");
127
+ }
128
+ /**
129
+ * {@inheritdoc IFluidDataStoreChannel.applyStashedOp}
130
+ */
131
+ async applyStashedOp(content) {
132
+ // Should not apply stashed ops to the attributor as the attributor does not send ops yet.
133
+ throw new Error("Should not apply stashed ops to the attributor");
134
+ }
135
+ /**
136
+ * {@inheritdoc IFluidDataStoreChannel.rollback}
137
+ */
138
+ rollback(type, content, localOpMetadata) {
139
+ // Should not rollback anything from the attributor as it does not send ops yet.
140
+ throw new Error("Should not rollback anything from the attributor");
141
+ }
142
+ /**
143
+ * {@inheritdoc IFluidDataStoreChannel.request}
144
+ */
145
+ async request(request) {
146
+ // Should not request anything from the attributor as the attributor does not have any channels further.
147
+ throw new Error("Should not request anything from the attributor");
148
+ }
149
+ /**
150
+ * {@inheritdoc IFluidDataStoreChannel.setAttachState}
151
+ */
152
+ setAttachState(attachState) {
153
+ switch (attachState) {
154
+ case internal_1.AttachState.Attaching: {
155
+ this.attachState = internal_1.AttachState.Attaching;
156
+ (0, internal_2.assert)(this.visibilityState === internal_4.VisibilityState.LocallyVisible, 0xa1e /* Data store should be locally visible before it can become globally visible. */);
157
+ // Mark the data store globally visible and make its child channels visible as well.
158
+ this.visibilityState = internal_4.VisibilityState.GloballyVisible;
159
+ // This promise resolution will be moved to attached event once we fix the scheduler.
160
+ this.deferredAttached.resolve();
161
+ this.emit("attaching");
162
+ break;
163
+ }
164
+ case internal_1.AttachState.Attached: {
165
+ (0, internal_2.assert)(this.visibilityState === internal_4.VisibilityState.GloballyVisible, 0xa1f /* Data store should be globally visible when its attached. */);
166
+ this.attachState = internal_1.AttachState.Attached;
167
+ this.emit("attached");
168
+ break;
169
+ }
170
+ default: {
171
+ (0, internal_2.unreachableCase)(attachState, "unreached");
172
+ }
173
+ }
174
+ }
175
+ }
176
+ exports.RuntimeAttributorDataStoreChannel = RuntimeAttributorDataStoreChannel;
177
+ //# sourceMappingURL=runtimeAttributorDataStoreChannel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeAttributorDataStoreChannel.js","sourceRoot":"","sources":["../src/runtimeAttributorDataStoreChannel.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiE;AACjE,6EAA4F;AAG5F,kEAAwF;AACxF,iEAAuE;AAQvE,2EAQsD;AACtD,uEAKkD;AAElD,iEAA2D;AAE3D;;GAEG;AACH,MAAa,iCACZ,SAAQ,gCAA+C;IAGvD,YACiB,gBAAwC,EACxD,QAAiB;QAEjB,KAAK,EAAE,CAAC;QAHQ,qBAAgB,GAAhB,gBAAgB,CAAwB;QAiCjD,cAAS,GAAG,KAAK,CAAC;QAUnB,cAAS,GAAG,IAAI,CAAC;QAGP,qBAAgB,GAAG,IAAI,mBAAQ,EAAQ,CAAC;QA1CxD,IAAI,CAAC,iBAAiB,GAAG,IAAI,wCAAiB,EAAE,CAAC;QACjD,IAAI,CAAC,EAAE,GAAG,IAAA,uCAA4B,EAAC;YACtC,MAAM,EAAE,gBAAgB,CAAC,UAAU;YACnC,SAAS,EAAE,YAAY;SACvB,CAAC,CAAC;QACH,IAAI,CAAC,WAAW,GAAG,gBAAgB,CAAC,WAAW,CAAC;QAChD,IAAI,QAAQ,EAAE,CAAC;YACd,IAAI,CAAC,eAAe;gBACnB,g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AAwB;QACxE,gFAAgF;QAChF,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACrE,CAAC;IAOD;;OAEG;IACI,KAAK,CAAC,OAAO,CAAC,OAAiB;QACrC,wGAAwG;QACxG,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACpE,CAAC;IAED;;OAEG;IACI,cAAc,CAAC,WAAyD;QAC9E,QAAQ,WAAW,EAAE,CAAC;YACrB,KAAK,sBAAW,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC5B,IAAI,CAAC,WAAW,GAAG,sBAAW,CAAC,SAAS,CAAC;gBAEzC,IAAA,iBAAM,EACL,IAAI,CAAC,eAAe,KAAK,0BAAe,CAAC,cAAc,EACvD,KAAK,CAAC,iFAAiF,CACvF,CAAC;gBAEF,oFAAoF;gBACpF,IAAI,CAAC,eAAe,GAAG,0BAAe,CAAC,eAAe,CAAC;gBAEvD,qFAAqF;gBACrF,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;gBAChC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACvB,MAAM;YACP,CAAC;YACD,KAAK,sBAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAC3B,IAAA,iBAAM,EACL,IAAI,CAAC,eAAe,KAAK,0BAAe,CAAC,eAAe,EACxD,KAAK,CAAC,8DAA8D,CACpE,CAAC;gBACF,IAAI,CAAC,WAAW,GAAG,sBAAW,CAAC,QAAQ,CAAC;gBACxC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBACtB,MAAM;YACP,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACT,IAAA,0BAAe,EAAC,WAAW,EAAE,WAAW,CAAC,CAAC;YAC3C,CAAC;QACF,CAAC;IACF,CAAC;CACD;AA7ND,8EA6NC","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,39 @@
1
+ "use strict";
2
+ /*!
3
+ * 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.RuntimeAttributorFactory = void 0;
8
+ const internal_1 = require("@fluidframework/telemetry-utils/internal");
9
+ const runtimeAttributorDataStoreChannel_js_1 = require("./runtimeAttributorDataStoreChannel.js");
10
+ /**
11
+ * Factory for the runtime attributor data store channel.
12
+ */
13
+ class RuntimeAttributorFactory {
14
+ get type() {
15
+ return RuntimeAttributorFactory.type;
16
+ }
17
+ get IFluidDataStoreFactory() {
18
+ return this;
19
+ }
20
+ async instantiateDataStore(context, existing) {
21
+ const runtime = new runtimeAttributorDataStoreChannel_js_1.RuntimeAttributorDataStoreChannel(context, existing);
22
+ const logger = (0, internal_1.createChildLogger)({
23
+ logger: context.baseLogger,
24
+ namespace: "Attributor",
25
+ });
26
+ await internal_1.PerformanceEvent.timedExecAsync(logger, {
27
+ eventName: "initialize",
28
+ }, async (event) => {
29
+ await runtime.initialize(context.deltaManager, context.getQuorum(), context.baseSnapshot, async (id) => context.storage.readBlob(id));
30
+ event.end({
31
+ attributionEnabledInDoc: true, // If we are instantiating the attributor, it is enabled
32
+ });
33
+ });
34
+ return runtime;
35
+ }
36
+ }
37
+ exports.RuntimeAttributorFactory = RuntimeAttributorFactory;
38
+ RuntimeAttributorFactory.type = "@fluid-experimental/attributor";
39
+ //# sourceMappingURL=runtimeAttributorDataStoreFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeAttributorDataStoreFactory.js","sourceRoot":"","sources":["../src/runtimeAttributorDataStoreFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,uEAA+F;AAE/F,iGAA2F;AAE3F;;GAEG;AACH,MAAa,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,wEAAiC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAEzE,MAAM,MAAM,GAAG,IAAA,4BAAiB,EAAC;YAChC,MAAM,EAAE,OAAO,CAAC,UAAU;YAC1B,SAAS,EAAE,YAAY;SACvB,CAAC,CAAC;QAEH,MAAM,2BAAgB,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;;AAxCF,4DAyCC;AAxCuB,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"]}
@@ -0,0 +1,49 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { type AttributionInfo, type AttributionKey } from "@fluidframework/runtime-definitions/internal";
6
+ export declare const opBlobName = "opAttributor";
7
+ /**
8
+ * @internal
9
+ */
10
+ export declare const enableOnNewFileKey = "Fluid.Attribution.EnableOnNewFile";
11
+ /**
12
+ * @internal
13
+ */
14
+ export declare const IRuntimeAttributor: keyof IProvideRuntimeAttributor;
15
+ /**
16
+ * @internal
17
+ */
18
+ export interface IProvideRuntimeAttributor {
19
+ readonly IRuntimeAttributor: IRuntimeAttributor;
20
+ }
21
+ /**
22
+ * @internal
23
+ */
24
+ export declare const attributorDataStoreAlias = "attributor-cf9b6fe4-4c50-4a5d-9045-eb73b886f740";
25
+ /**
26
+ * Provides access to attribution information stored on the container runtime.
27
+ *
28
+ * @remarks Attributors are only populated after the container runtime into which they are being injected has initialized.
29
+ *
30
+ * @sealed
31
+ * @internal
32
+ */
33
+ export interface IRuntimeAttributor extends IProvideRuntimeAttributor {
34
+ /**
35
+ * @throws - If no AttributionInfo exists for this key.
36
+ */
37
+ get(key: AttributionKey): AttributionInfo;
38
+ /**
39
+ * @returns Whether any AttributionInfo exists for the provided key.
40
+ */
41
+ has(key: AttributionKey): boolean;
42
+ /**
43
+ * @returns Whether the runtime is currently tracking attribution information for the loaded container.
44
+ * If enabled, the runtime attributor can be asked for the attribution info for different keys.
45
+ * See {@link mixinAttributor} for more details on when this happens.
46
+ */
47
+ readonly isEnabled: boolean;
48
+ }
49
+ //# sourceMappingURL=attributorContracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attributorContracts.d.ts","sourceRoot":"","sources":["../src/attributorContracts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,MAAM,8CAA8C,CAAC;AAGtD,eAAO,MAAM,UAAU,iBAAiB,CAAC;AAEzC;;GAEG;AACH,eAAO,MAAM,kBAAkB,sCAAsC,CAAC;AAEtE;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,yBAAgD,CAAC;AAExF;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;CAChD;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,oDAAoD,CAAC;AAE1F;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAmB,SAAQ,yBAAyB;IACpE;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,cAAc,GAAG,eAAe,CAAC;IAE1C;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC;IAElC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC5B"}
@@ -0,0 +1,19 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ // Summary tree keys
6
+ export const opBlobName = "opAttributor";
7
+ /**
8
+ * @internal
9
+ */
10
+ export const enableOnNewFileKey = "Fluid.Attribution.EnableOnNewFile";
11
+ /**
12
+ * @internal
13
+ */
14
+ export const IRuntimeAttributor = "IRuntimeAttributor";
15
+ /**
16
+ * @internal
17
+ */
18
+ export const attributorDataStoreAlias = "attributor-cf9b6fe4-4c50-4a5d-9045-eb73b886f740";
19
+ //# sourceMappingURL=attributorContracts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attributorContracts.js","sourceRoot":"","sources":["../src/attributorContracts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,oBAAoB;AACpB,MAAM,CAAC,MAAM,UAAU,GAAG,cAAc,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,mCAAmC,CAAC;AAEtE;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAoC,oBAAoB,CAAC;AASxF;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,iDAAiD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\ttype AttributionInfo,\n\ttype AttributionKey,\n} from \"@fluidframework/runtime-definitions/internal\";\n\n// Summary tree keys\nexport const opBlobName = \"opAttributor\";\n\n/**\n * @internal\n */\nexport const enableOnNewFileKey = \"Fluid.Attribution.EnableOnNewFile\";\n\n/**\n * @internal\n */\nexport const IRuntimeAttributor: keyof IProvideRuntimeAttributor = \"IRuntimeAttributor\";\n\n/**\n * @internal\n */\nexport interface IProvideRuntimeAttributor {\n\treadonly IRuntimeAttributor: IRuntimeAttributor;\n}\n\n/**\n * @internal\n */\nexport const attributorDataStoreAlias = \"attributor-cf9b6fe4-4c50-4a5d-9045-eb73b886f740\";\n\n/**\n * Provides access to attribution information stored on the container runtime.\n *\n * @remarks Attributors are only populated after the container runtime into which they are being injected has initialized.\n *\n * @sealed\n * @internal\n */\nexport interface IRuntimeAttributor extends IProvideRuntimeAttributor {\n\t/**\n\t * @throws - If no AttributionInfo exists for this key.\n\t */\n\tget(key: AttributionKey): AttributionInfo;\n\n\t/**\n\t * @returns Whether any AttributionInfo exists for the provided key.\n\t */\n\thas(key: AttributionKey): boolean;\n\n\t/**\n\t * @returns Whether the runtime is currently tracking attribution information for the loaded container.\n\t * If enabled, the runtime attributor can be asked for the attribution info for different keys.\n\t * See {@link mixinAttributor} for more details on when this happens.\n\t */\n\treadonly isEnabled: boolean;\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -3,5 +3,6 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  export { type IAttributor } from "./attributor.js";
6
- export { createRuntimeAttributor, enableOnNewFileKey, type IProvideRuntimeAttributor, IRuntimeAttributor, mixinAttributor, } from "./mixinAttributor.js";
6
+ export { mixinAttributor, getRuntimeAttributor } from "./mixinAttributor.js";
7
+ export { attributorDataStoreAlias, enableOnNewFileKey, type IProvideRuntimeAttributor, IRuntimeAttributor, } from "./attributorContracts.js";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EACN,uBAAuB,EACvB,kBAAkB,EAClB,KAAK,yBAAyB,EAC9B,kBAAkB,EAClB,eAAe,GACf,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EACN,wBAAwB,EACxB,kBAAkB,EAClB,KAAK,yBAAyB,EAC9B,kBAAkB,GAClB,MAAM,0BAA0B,CAAC"}
package/lib/index.js CHANGED
@@ -2,5 +2,6 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export { createRuntimeAttributor, enableOnNewFileKey, IRuntimeAttributor, mixinAttributor, } from "./mixinAttributor.js";
5
+ export { mixinAttributor, getRuntimeAttributor } from "./mixinAttributor.js";
6
+ export { attributorDataStoreAlias, enableOnNewFileKey, IRuntimeAttributor, } from "./attributorContracts.js";
6
7
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,uBAAuB,EACvB,kBAAkB,EAElB,kBAAkB,EAClB,eAAe,GACf,MAAM,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { type IAttributor } from \"./attributor.js\";\nexport {\n\tcreateRuntimeAttributor,\n\tenableOnNewFileKey,\n\ttype IProvideRuntimeAttributor,\n\tIRuntimeAttributor,\n\tmixinAttributor,\n} from \"./mixinAttributor.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EACN,wBAAwB,EACxB,kBAAkB,EAElB,kBAAkB,GAClB,MAAM,0BAA0B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { type IAttributor } from \"./attributor.js\";\nexport { mixinAttributor, getRuntimeAttributor } from \"./mixinAttributor.js\";\nexport {\n\tattributorDataStoreAlias,\n\tenableOnNewFileKey,\n\ttype IProvideRuntimeAttributor,\n\tIRuntimeAttributor,\n} from \"./attributorContracts.js\";\n"]}
@@ -3,61 +3,20 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { ContainerRuntime } from "@fluidframework/container-runtime/internal";
6
- import { type AttributionInfo, type AttributionKey } from "@fluidframework/runtime-definitions/internal";
6
+ import { type IContainerRuntime } from "@fluidframework/container-runtime-definitions/internal";
7
+ import { type IRuntimeAttributor } from "./attributorContracts.js";
7
8
  /**
9
+ * Utility function to get the runtime attributor from the container runtime.
10
+ * @param runtime - container runtime from which attributor is to be fetched.
11
+ * @returns IRuntimeAttributor if it exists, otherwise undefined.
8
12
  * @internal
9
13
  */
10
- export declare const enableOnNewFileKey = "Fluid.Attribution.EnableOnNewFile";
11
- /**
12
- * @internal
13
- */
14
- export declare const IRuntimeAttributor: keyof IProvideRuntimeAttributor;
15
- /**
16
- * @internal
17
- */
18
- export interface IProvideRuntimeAttributor {
19
- readonly IRuntimeAttributor: IRuntimeAttributor;
20
- }
21
- /**
22
- * Provides access to attribution information stored on the container runtime.
23
- *
24
- * @remarks Attributors are only populated after the container runtime into which they are being injected has initialized.
25
- *
26
- * @sealed
27
- * @internal
28
- */
29
- export interface IRuntimeAttributor extends IProvideRuntimeAttributor {
30
- /**
31
- * @throws - If no AttributionInfo exists for this key.
32
- */
33
- get(key: AttributionKey): AttributionInfo;
34
- /**
35
- * @returns Whether any AttributionInfo exists for the provided key.
36
- */
37
- has(key: AttributionKey): boolean;
38
- /**
39
- * @returns Whether the runtime is currently tracking attribution information for the loaded container.
40
- * If enabled, the runtime attributor can be asked for the attribution info for different keys.
41
- * See {@link mixinAttributor} for more details on when this happens.
42
- */
43
- readonly isEnabled: boolean;
44
- }
45
- /**
46
- * Creates an `IRuntimeAttributor` for usage with {@link mixinAttributor}.
47
- *
48
- * @remarks The attributor will only be populated with data once it's passed via scope to a container runtime load flow.
49
- *
50
- * @internal
51
- */
52
- export declare function createRuntimeAttributor(): IRuntimeAttributor;
14
+ export declare function getRuntimeAttributor(runtime: IContainerRuntime): Promise<IRuntimeAttributor | undefined>;
53
15
  /**
54
16
  * Mixes in logic to load and store runtime-based attribution functionality.
55
17
  *
56
- * The `scope` passed to `load` should implement `IProvideRuntimeAttributor`.
57
- *
58
- * Existing documents without stored attributors will not start storing attribution information: if an
59
- * IRuntimeAttributor is passed via scope to load a document that never previously had attribution information,
60
- * that attributor's `has` method will always return `false`.
18
+ * Existing documents without stored attributor will not start storing attribution information. We only create the attributor
19
+ * if its tracking is enabled and we are creating a new document.
61
20
  * @param Base - base class, inherits from FluidAttributorRuntime
62
21
  * @internal
63
22
  */
@@ -1 +1 @@
1
- {"version":3,"file":"mixinAttributor.d.ts","sourceRoot":"","sources":["../src/mixinAttributor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAe9E,OAAO,EAGN,KAAK,eAAe,EACpB,KAAK,cAAc,EAEnB,MAAM,8CAA8C,CAAC;AAoBtD;;GAEG;AACH,eAAO,MAAM,kBAAkB,sCAAsC,CAAC;AAEtE;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAM,yBAAgD,CAAC;AAExF;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;CAChD;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAmB,SAAQ,yBAAyB;IACpE;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,cAAc,GAAG,eAAe,CAAC;IAE1C;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC;IAElC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;GAMG;AAC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