@fluidframework/local-driver 1.4.0-115997 → 2.0.0-dev-rc.1.0.0.224419

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 (123) hide show
  1. package/.eslintrc.js +19 -22
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +127 -0
  4. package/README.md +38 -0
  5. package/api-extractor-lint.json +4 -0
  6. package/api-extractor.json +4 -0
  7. package/api-report/local-driver.api.md +129 -0
  8. package/dist/{auth.js → auth.cjs} +8 -6
  9. package/dist/auth.cjs.map +1 -0
  10. package/dist/auth.d.ts.map +1 -1
  11. package/dist/index.cjs +24 -0
  12. package/dist/index.cjs.map +1 -0
  13. package/dist/index.d.ts +7 -6
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/local-driver-alpha.d.ts +110 -0
  16. package/dist/local-driver-beta.d.ts +75 -0
  17. package/dist/local-driver-public.d.ts +75 -0
  18. package/dist/local-driver-untrimmed.d.ts +226 -0
  19. package/dist/localCreateDocument.cjs +28 -0
  20. package/dist/localCreateDocument.cjs.map +1 -0
  21. package/dist/localCreateDocument.d.ts +8 -0
  22. package/dist/localCreateDocument.d.ts.map +1 -0
  23. package/dist/{localDeltaStorageService.js → localDeltaStorageService.cjs} +3 -2
  24. package/dist/localDeltaStorageService.cjs.map +1 -0
  25. package/dist/localDeltaStorageService.d.ts +4 -3
  26. package/dist/localDeltaStorageService.d.ts.map +1 -1
  27. package/dist/{localDocumentDeltaConnection.js → localDocumentDeltaConnection.cjs} +9 -11
  28. package/dist/localDocumentDeltaConnection.cjs.map +1 -0
  29. package/dist/localDocumentDeltaConnection.d.ts +5 -4
  30. package/dist/localDocumentDeltaConnection.d.ts.map +1 -1
  31. package/dist/{localDocumentService.js → localDocumentService.cjs} +15 -30
  32. package/dist/localDocumentService.cjs.map +1 -0
  33. package/dist/localDocumentService.d.ts +15 -11
  34. package/dist/localDocumentService.d.ts.map +1 -1
  35. package/dist/{localDocumentServiceFactory.js → localDocumentServiceFactory.cjs} +14 -31
  36. package/dist/localDocumentServiceFactory.cjs.map +1 -0
  37. package/dist/localDocumentServiceFactory.d.ts +3 -2
  38. package/dist/localDocumentServiceFactory.d.ts.map +1 -1
  39. package/dist/localDocumentStorageService.cjs +88 -0
  40. package/dist/localDocumentStorageService.cjs.map +1 -0
  41. package/dist/localDocumentStorageService.d.ts +30 -0
  42. package/dist/localDocumentStorageService.d.ts.map +1 -0
  43. package/dist/{localResolver.js → localResolver.cjs} +10 -6
  44. package/dist/localResolver.cjs.map +1 -0
  45. package/dist/localResolver.d.ts +5 -0
  46. package/dist/localResolver.d.ts.map +1 -1
  47. package/dist/{localSessionStorageDb.js → localSessionStorageDb.cjs} +26 -18
  48. package/dist/localSessionStorageDb.cjs.map +1 -0
  49. package/dist/localSessionStorageDb.d.ts +1 -1
  50. package/dist/localSessionStorageDb.d.ts.map +1 -1
  51. package/dist/tsdoc-metadata.json +11 -0
  52. package/lib/auth.d.mts +12 -0
  53. package/lib/auth.d.mts.map +1 -0
  54. package/lib/auth.mjs +40 -0
  55. package/lib/auth.mjs.map +1 -0
  56. package/lib/index.d.mts +12 -0
  57. package/lib/index.d.mts.map +1 -0
  58. package/lib/index.mjs +12 -0
  59. package/lib/index.mjs.map +1 -0
  60. package/lib/local-driver-alpha.d.mts +110 -0
  61. package/lib/local-driver-beta.d.mts +75 -0
  62. package/lib/local-driver-public.d.mts +75 -0
  63. package/lib/local-driver-untrimmed.d.mts +226 -0
  64. package/lib/localCreateDocument.d.mts +8 -0
  65. package/lib/localCreateDocument.d.mts.map +1 -0
  66. package/lib/localCreateDocument.mjs +24 -0
  67. package/lib/localCreateDocument.mjs.map +1 -0
  68. package/lib/localDeltaStorageService.d.mts +20 -0
  69. package/lib/localDeltaStorageService.d.mts.map +1 -0
  70. package/lib/localDeltaStorageService.mjs +32 -0
  71. package/lib/localDeltaStorageService.mjs.map +1 -0
  72. package/lib/localDocumentDeltaConnection.d.mts +48 -0
  73. package/lib/localDocumentDeltaConnection.d.mts.map +1 -0
  74. package/lib/localDocumentDeltaConnection.mjs +86 -0
  75. package/lib/localDocumentDeltaConnection.mjs.map +1 -0
  76. package/lib/localDocumentService.d.mts +56 -0
  77. package/lib/localDocumentService.d.mts.map +1 -0
  78. package/lib/localDocumentService.mjs +84 -0
  79. package/lib/localDocumentService.mjs.map +1 -0
  80. package/lib/localDocumentServiceFactory.d.mts +45 -0
  81. package/lib/localDocumentServiceFactory.d.mts.map +1 -0
  82. package/lib/localDocumentServiceFactory.mjs +80 -0
  83. package/lib/localDocumentServiceFactory.mjs.map +1 -0
  84. package/lib/localDocumentStorageService.d.mts +30 -0
  85. package/lib/localDocumentStorageService.d.mts.map +1 -0
  86. package/lib/localDocumentStorageService.mjs +84 -0
  87. package/lib/localDocumentStorageService.mjs.map +1 -0
  88. package/lib/localResolver.d.mts +31 -0
  89. package/lib/localResolver.d.mts.map +1 -0
  90. package/lib/localResolver.mjs +74 -0
  91. package/lib/localResolver.mjs.map +1 -0
  92. package/lib/localSessionStorageDb.d.mts +11 -0
  93. package/lib/localSessionStorageDb.d.mts.map +1 -0
  94. package/lib/localSessionStorageDb.mjs +292 -0
  95. package/lib/localSessionStorageDb.mjs.map +1 -0
  96. package/package.json +102 -59
  97. package/prettier.config.cjs +8 -0
  98. package/src/auth.ts +42 -33
  99. package/src/index.ts +7 -6
  100. package/src/localCreateDocument.ts +48 -0
  101. package/src/localDeltaStorageService.ts +28 -27
  102. package/src/localDocumentDeltaConnection.ts +91 -88
  103. package/src/localDocumentService.ts +117 -97
  104. package/src/localDocumentServiceFactory.ts +95 -123
  105. package/src/localDocumentStorageService.ts +131 -0
  106. package/src/localResolver.ts +57 -59
  107. package/src/localSessionStorageDb.ts +272 -265
  108. package/tsc-multi.test.json +4 -0
  109. package/tsconfig.json +11 -13
  110. package/dist/auth.js.map +0 -1
  111. package/dist/index.js +0 -23
  112. package/dist/index.js.map +0 -1
  113. package/dist/localDeltaStorageService.js.map +0 -1
  114. package/dist/localDocumentDeltaConnection.js.map +0 -1
  115. package/dist/localDocumentService.js.map +0 -1
  116. package/dist/localDocumentServiceFactory.js.map +0 -1
  117. package/dist/localResolver.js.map +0 -1
  118. package/dist/localSessionStorageDb.js.map +0 -1
  119. package/dist/packageVersion.d.ts +0 -9
  120. package/dist/packageVersion.d.ts.map +0 -1
  121. package/dist/packageVersion.js +0 -12
  122. package/dist/packageVersion.js.map +0 -1
  123. package/src/packageVersion.ts +0 -9
@@ -0,0 +1,75 @@
1
+ import { DocumentDeltaConnection } from '@fluidframework/driver-base';
2
+ import { GitManager } from '@fluidframework/server-services-client';
3
+ import { IClient } from '@fluidframework/protocol-definitions';
4
+ import { ICreateBlobResponse } from '@fluidframework/protocol-definitions';
5
+ import { IDatabaseManager } from '@fluidframework/server-services-core';
6
+ import { IDb } from '@fluidframework/server-services-core';
7
+ import { IDocumentDeltaConnection } from '@fluidframework/driver-definitions';
8
+ import { IDocumentDeltaStorageService } from '@fluidframework/driver-definitions';
9
+ import { IDocumentMessage } from '@fluidframework/protocol-definitions';
10
+ import { IDocumentService } from '@fluidframework/driver-definitions';
11
+ import { IDocumentServiceFactory } from '@fluidframework/driver-definitions';
12
+ import { IDocumentServicePolicies } from '@fluidframework/driver-definitions';
13
+ import { IDocumentStorageService } from '@fluidframework/driver-definitions';
14
+ import { IDocumentStorageServicePolicies } from '@fluidframework/driver-definitions';
15
+ import { ILocalDeltaConnectionServer } from '@fluidframework/server-local-server';
16
+ import { IRequest } from '@fluidframework/core-interfaces';
17
+ import { IResolvedUrl } from '@fluidframework/driver-definitions';
18
+ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
19
+ import { ISnapshotTreeEx } from '@fluidframework/protocol-definitions';
20
+ import { IStream } from '@fluidframework/driver-definitions';
21
+ import { ISummaryContext } from '@fluidframework/driver-definitions';
22
+ import { ISummaryHandle } from '@fluidframework/protocol-definitions';
23
+ import { ISummaryTree } from '@fluidframework/protocol-definitions';
24
+ import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
25
+ import { ITestDbFactory } from '@fluidframework/server-test-utils';
26
+ import { ITokenProvider } from '@fluidframework/routerlicious-driver';
27
+ import { IUrlResolver } from '@fluidframework/driver-definitions';
28
+ import { IVersion } from '@fluidframework/protocol-definitions';
29
+ import { IWebSocketServer } from '@fluidframework/server-services-core';
30
+ import { NackErrorType } from '@fluidframework/protocol-definitions';
31
+ import type { Socket } from 'socket.io-client';
32
+
33
+ /* Excluded from this release type: createLocalDocumentService */
34
+
35
+ /* Excluded from this release type: createLocalResolverCreateNewRequest */
36
+
37
+ /* Excluded from this release type: DocumentDeltaConnection */
38
+
39
+ /* Excluded from this release type: IDocumentDeltaConnection */
40
+
41
+ /* Excluded from this release type: IDocumentDeltaStorageService */
42
+
43
+ /* Excluded from this release type: IDocumentService */
44
+
45
+ /* Excluded from this release type: IDocumentServiceFactory */
46
+
47
+ /* Excluded from this release type: IDocumentServicePolicies */
48
+
49
+ /* Excluded from this release type: IDocumentStorageService */
50
+
51
+ /* Excluded from this release type: IDocumentStorageServicePolicies */
52
+
53
+ /* Excluded from this release type: IResolvedUrl */
54
+
55
+ /* Excluded from this release type: IStream */
56
+
57
+ /* Excluded from this release type: ISummaryContext */
58
+
59
+ /* Excluded from this release type: IUrlResolver */
60
+
61
+ /* Excluded from this release type: LocalDeltaStorageService */
62
+
63
+ /* Excluded from this release type: LocalDocumentDeltaConnection */
64
+
65
+ /* Excluded from this release type: LocalDocumentService */
66
+
67
+ /* Excluded from this release type: LocalDocumentServiceFactory */
68
+
69
+ /* Excluded from this release type: LocalDocumentStorageService */
70
+
71
+ /* Excluded from this release type: LocalResolver */
72
+
73
+ /* Excluded from this release type: LocalSessionStorageDbFactory */
74
+
75
+ export { }
@@ -0,0 +1,75 @@
1
+ import { DocumentDeltaConnection } from '@fluidframework/driver-base';
2
+ import { GitManager } from '@fluidframework/server-services-client';
3
+ import { IClient } from '@fluidframework/protocol-definitions';
4
+ import { ICreateBlobResponse } from '@fluidframework/protocol-definitions';
5
+ import { IDatabaseManager } from '@fluidframework/server-services-core';
6
+ import { IDb } from '@fluidframework/server-services-core';
7
+ import { IDocumentDeltaConnection } from '@fluidframework/driver-definitions';
8
+ import { IDocumentDeltaStorageService } from '@fluidframework/driver-definitions';
9
+ import { IDocumentMessage } from '@fluidframework/protocol-definitions';
10
+ import { IDocumentService } from '@fluidframework/driver-definitions';
11
+ import { IDocumentServiceFactory } from '@fluidframework/driver-definitions';
12
+ import { IDocumentServicePolicies } from '@fluidframework/driver-definitions';
13
+ import { IDocumentStorageService } from '@fluidframework/driver-definitions';
14
+ import { IDocumentStorageServicePolicies } from '@fluidframework/driver-definitions';
15
+ import { ILocalDeltaConnectionServer } from '@fluidframework/server-local-server';
16
+ import { IRequest } from '@fluidframework/core-interfaces';
17
+ import { IResolvedUrl } from '@fluidframework/driver-definitions';
18
+ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
19
+ import { ISnapshotTreeEx } from '@fluidframework/protocol-definitions';
20
+ import { IStream } from '@fluidframework/driver-definitions';
21
+ import { ISummaryContext } from '@fluidframework/driver-definitions';
22
+ import { ISummaryHandle } from '@fluidframework/protocol-definitions';
23
+ import { ISummaryTree } from '@fluidframework/protocol-definitions';
24
+ import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
25
+ import { ITestDbFactory } from '@fluidframework/server-test-utils';
26
+ import { ITokenProvider } from '@fluidframework/routerlicious-driver';
27
+ import { IUrlResolver } from '@fluidframework/driver-definitions';
28
+ import { IVersion } from '@fluidframework/protocol-definitions';
29
+ import { IWebSocketServer } from '@fluidframework/server-services-core';
30
+ import { NackErrorType } from '@fluidframework/protocol-definitions';
31
+ import type { Socket } from 'socket.io-client';
32
+
33
+ /* Excluded from this release type: createLocalDocumentService */
34
+
35
+ /* Excluded from this release type: createLocalResolverCreateNewRequest */
36
+
37
+ /* Excluded from this release type: DocumentDeltaConnection */
38
+
39
+ /* Excluded from this release type: IDocumentDeltaConnection */
40
+
41
+ /* Excluded from this release type: IDocumentDeltaStorageService */
42
+
43
+ /* Excluded from this release type: IDocumentService */
44
+
45
+ /* Excluded from this release type: IDocumentServiceFactory */
46
+
47
+ /* Excluded from this release type: IDocumentServicePolicies */
48
+
49
+ /* Excluded from this release type: IDocumentStorageService */
50
+
51
+ /* Excluded from this release type: IDocumentStorageServicePolicies */
52
+
53
+ /* Excluded from this release type: IResolvedUrl */
54
+
55
+ /* Excluded from this release type: IStream */
56
+
57
+ /* Excluded from this release type: ISummaryContext */
58
+
59
+ /* Excluded from this release type: IUrlResolver */
60
+
61
+ /* Excluded from this release type: LocalDeltaStorageService */
62
+
63
+ /* Excluded from this release type: LocalDocumentDeltaConnection */
64
+
65
+ /* Excluded from this release type: LocalDocumentService */
66
+
67
+ /* Excluded from this release type: LocalDocumentServiceFactory */
68
+
69
+ /* Excluded from this release type: LocalDocumentStorageService */
70
+
71
+ /* Excluded from this release type: LocalResolver */
72
+
73
+ /* Excluded from this release type: LocalSessionStorageDbFactory */
74
+
75
+ export { }
@@ -0,0 +1,226 @@
1
+ import { DocumentDeltaConnection } from '@fluidframework/driver-base';
2
+ import { GitManager } from '@fluidframework/server-services-client';
3
+ import { IClient } from '@fluidframework/protocol-definitions';
4
+ import { ICreateBlobResponse } from '@fluidframework/protocol-definitions';
5
+ import { IDatabaseManager } from '@fluidframework/server-services-core';
6
+ import { IDb } from '@fluidframework/server-services-core';
7
+ import { IDocumentDeltaConnection } from '@fluidframework/driver-definitions';
8
+ import { IDocumentDeltaStorageService } from '@fluidframework/driver-definitions';
9
+ import { IDocumentMessage } from '@fluidframework/protocol-definitions';
10
+ import { IDocumentService } from '@fluidframework/driver-definitions';
11
+ import { IDocumentServiceFactory } from '@fluidframework/driver-definitions';
12
+ import { IDocumentServicePolicies } from '@fluidframework/driver-definitions';
13
+ import { IDocumentStorageService } from '@fluidframework/driver-definitions';
14
+ import { IDocumentStorageServicePolicies } from '@fluidframework/driver-definitions';
15
+ import { ILocalDeltaConnectionServer } from '@fluidframework/server-local-server';
16
+ import { IRequest } from '@fluidframework/core-interfaces';
17
+ import { IResolvedUrl } from '@fluidframework/driver-definitions';
18
+ import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
19
+ import { ISnapshotTreeEx } from '@fluidframework/protocol-definitions';
20
+ import { IStream } from '@fluidframework/driver-definitions';
21
+ import { ISummaryContext } from '@fluidframework/driver-definitions';
22
+ import { ISummaryHandle } from '@fluidframework/protocol-definitions';
23
+ import { ISummaryTree } from '@fluidframework/protocol-definitions';
24
+ import { ITelemetryBaseLogger } from '@fluidframework/core-interfaces';
25
+ import { ITestDbFactory } from '@fluidframework/server-test-utils';
26
+ import { ITokenProvider } from '@fluidframework/routerlicious-driver';
27
+ import { IUrlResolver } from '@fluidframework/driver-definitions';
28
+ import { IVersion } from '@fluidframework/protocol-definitions';
29
+ import { IWebSocketServer } from '@fluidframework/server-services-core';
30
+ import { NackErrorType } from '@fluidframework/protocol-definitions';
31
+ import type { Socket } from 'socket.io-client';
32
+
33
+ /**
34
+ * Creates and returns a document service for local use.
35
+ * @param localDeltaConnectionServer - delta connection server for ops
36
+ * @param tokenProvider - token provider with a single token
37
+ * @param tenantId - ID of tenant
38
+ * @param documentId - ID of document
39
+ * @internal
40
+ */
41
+ export declare function createLocalDocumentService(resolvedUrl: IResolvedUrl, localDeltaConnectionServer: ILocalDeltaConnectionServer, tokenProvider: ITokenProvider, tenantId: string, documentId: string, documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>, policies?: IDocumentServicePolicies, innerDocumentService?: IDocumentService, logger?: ITelemetryBaseLogger): IDocumentService;
42
+
43
+ /**
44
+ * @alpha
45
+ */
46
+ export declare function createLocalResolverCreateNewRequest(documentId: string): IRequest;
47
+
48
+ /**
49
+ * Provides access to the underlying delta storage on the server for local driver.
50
+ * @internal
51
+ */
52
+ export declare class LocalDeltaStorageService implements IDocumentDeltaStorageService {
53
+ private readonly tenantId;
54
+ private readonly id;
55
+ private readonly databaseManager;
56
+ constructor(tenantId: string, id: string, databaseManager: IDatabaseManager);
57
+ fetchMessages(from: number, to: number | undefined, abortSignal?: AbortSignal, cachedOnly?: boolean): IStream<ISequencedDocumentMessage[]>;
58
+ private getCore;
59
+ }
60
+
61
+ /**
62
+ * Represents a connection to a stream of delta updates
63
+ * @internal
64
+ */
65
+ export declare class LocalDocumentDeltaConnection extends DocumentDeltaConnection {
66
+ /**
67
+ * Create a LocalDocumentDeltaConnection
68
+ * Handle initial messages, contents or signals if they were in queue
69
+ *
70
+ * @param tenantId - the ID of the tenant
71
+ * @param id - document ID
72
+ * @param token - authorization token for storage service
73
+ * @param client - information about the client
74
+ * @param webSocketServer - web socket server to create connection
75
+ */
76
+ static create(tenantId: string, id: string, token: string, client: IClient, webSocketServer: IWebSocketServer, timeoutMs?: number, logger?: ITelemetryBaseLogger): Promise<LocalDocumentDeltaConnection>;
77
+ constructor(socket: Socket, documentId: string, logger?: ITelemetryBaseLogger);
78
+ /**
79
+ * Submits a new delta operation to the server
80
+ */
81
+ submit(messages: IDocumentMessage[]): void;
82
+ /**
83
+ * Submits a new signal to the server
84
+ */
85
+ submitSignal(message: any): void;
86
+ /**
87
+ * Send a "disconnect" message on the socket.
88
+ * @param disconnectReason - The reason of the disconnection.
89
+ */
90
+ disconnectClient(disconnectReason: string): void;
91
+ /**
92
+ * * Sends a "nack" message on the socket.
93
+ * @param code - An error code number that represents the error. It will be a valid HTTP error code.
94
+ * @param type - Type of the Nack.
95
+ * @param message - A message about the nack for debugging/logging/telemetry purposes.
96
+ */
97
+ nackClient(code: number | undefined, type: NackErrorType | undefined, message: any): void;
98
+ }
99
+
100
+ /**
101
+ * Basic implementation of a document service for local use.
102
+ * @internal
103
+ */
104
+ export declare class LocalDocumentService implements IDocumentService {
105
+ readonly resolvedUrl: IResolvedUrl;
106
+ private readonly localDeltaConnectionServer;
107
+ private readonly tokenProvider;
108
+ private readonly tenantId;
109
+ private readonly documentId;
110
+ private readonly documentDeltaConnectionsMap;
111
+ readonly policies: IDocumentServicePolicies;
112
+ private readonly innerDocumentService?;
113
+ private readonly logger?;
114
+ /**
115
+ * @param localDeltaConnectionServer - delta connection server for ops
116
+ * @param tokenProvider - token provider
117
+ * @param tenantId - ID of tenant
118
+ * @param documentId - ID of document
119
+ */
120
+ constructor(resolvedUrl: IResolvedUrl, localDeltaConnectionServer: ILocalDeltaConnectionServer, tokenProvider: ITokenProvider, tenantId: string, documentId: string, documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>, policies?: IDocumentServicePolicies, innerDocumentService?: IDocumentService | undefined, logger?: ITelemetryBaseLogger | undefined);
121
+ dispose(): void;
122
+ /**
123
+ * Creates and returns a document storage service for local use.
124
+ */
125
+ connectToStorage(): Promise<IDocumentStorageService>;
126
+ /**
127
+ * Creates and returns a delta storage service for local use.
128
+ */
129
+ connectToDeltaStorage(): Promise<IDocumentDeltaStorageService>;
130
+ /**
131
+ * Creates and returns a delta stream for local use.
132
+ * @param client - client data
133
+ */
134
+ connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection>;
135
+ }
136
+
137
+ /**
138
+ * Implementation of document service factory for local use.
139
+ * @alpha
140
+ */
141
+ export declare class LocalDocumentServiceFactory implements IDocumentServiceFactory {
142
+ private readonly localDeltaConnectionServer;
143
+ private readonly policies?;
144
+ private readonly innerDocumentService?;
145
+ private readonly documentDeltaConnectionsMap;
146
+ /**
147
+ * @param localDeltaConnectionServer - delta connection server for ops
148
+ * @alpha
149
+ */
150
+ constructor(localDeltaConnectionServer: ILocalDeltaConnectionServer, policies?: IDocumentServicePolicies | undefined, innerDocumentService?: IDocumentService | undefined);
151
+ createContainer(createNewSummary: ISummaryTree | undefined, resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
152
+ /**
153
+ * Creates and returns a document service for testing using the given resolved
154
+ * URL for the tenant ID, document ID, and token.
155
+ * @param resolvedUrl - resolved URL of document
156
+ */
157
+ createDocumentService(resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
158
+ /**
159
+ * Gets the document delta connection for the clientId and asks it to disconnect the client.
160
+ * @param clientId - The ID of the client to be disconnected.
161
+ * @param disconnectReason - The reason of the disconnection.
162
+ */
163
+ disconnectClient(clientId: string, disconnectReason: string): void;
164
+ /**
165
+ * Gets the document delta connection for the clientId and asks it to nack the client.
166
+ * @param clientId - The ID of the client to be Nack'd.
167
+ * @param code - An error code number that represents the error. It will be a valid HTTP error code.
168
+ * @param type - Type of the Nack.
169
+ * @param message - A message about the nack for debugging/logging/telemetry purposes.
170
+ */
171
+ nackClient(clientId: string, code?: number, type?: NackErrorType, message?: any): void;
172
+ }
173
+
174
+ /**
175
+ * @internal
176
+ */
177
+ export declare class LocalDocumentStorageService implements IDocumentStorageService {
178
+ private readonly id;
179
+ private readonly manager;
180
+ readonly policies: IDocumentStorageServicePolicies;
181
+ private readonly localDeltaConnectionServer?;
182
+ private readonly resolvedUrl?;
183
+ protected readonly blobsShaCache: Map<string, string>;
184
+ private readonly summaryTreeUploadManager;
185
+ readonly repositoryUrl: string;
186
+ constructor(id: string, manager: GitManager, policies: IDocumentStorageServicePolicies, localDeltaConnectionServer?: ILocalDeltaConnectionServer | undefined, resolvedUrl?: IResolvedUrl | undefined);
187
+ getVersions(versionId: string | null, count: number): Promise<IVersion[]>;
188
+ getSnapshotTree(version?: IVersion): Promise<ISnapshotTreeEx | null>;
189
+ readBlob(blobId: string): Promise<ArrayBufferLike>;
190
+ uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string>;
191
+ createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse>;
192
+ downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree>;
193
+ private getPreviousFullSnapshot;
194
+ }
195
+
196
+ /**
197
+ * Resolves URLs by providing fake URLs which succeed with the other
198
+ * related local classes.
199
+ * @alpha
200
+ */
201
+ export declare class LocalResolver implements IUrlResolver {
202
+ private readonly tenantId;
203
+ private readonly tokenKey;
204
+ constructor();
205
+ /**
206
+ * Resolves URL requests by providing fake URLs with an actually generated
207
+ * token from constant test strings. The root of the URL is fake, but the
208
+ * remaining relative URL can still be parsed.
209
+ * @param request - request to handle
210
+ * @alpha
211
+ */
212
+ resolve(request: IRequest): Promise<IResolvedUrl>;
213
+ getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string>;
214
+ createCreateNewRequest(documentId: string): IRequest;
215
+ }
216
+
217
+ /**
218
+ * A database factory for testing that stores data in the browsers session storage
219
+ * @internal
220
+ */
221
+ export declare class LocalSessionStorageDbFactory implements ITestDbFactory {
222
+ readonly testDatabase: IDb;
223
+ connect(): Promise<IDb>;
224
+ }
225
+
226
+ export { }
@@ -0,0 +1,28 @@
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.createDocument = void 0;
8
+ const driver_utils_1 = require("@fluidframework/driver-utils");
9
+ const server_services_client_1 = require("@fluidframework/server-services-client");
10
+ async function createDocument(localDeltaConnectionServer, resolvedUrl, summary) {
11
+ const pathName = new URL(resolvedUrl.url).pathname;
12
+ const pathArr = pathName.split("/");
13
+ const tenantId = pathArr[pathArr.length - 2];
14
+ const id = pathArr[pathArr.length - 1];
15
+ const documentStorage = localDeltaConnectionServer
16
+ .documentStorage;
17
+ if (!(0, driver_utils_1.isCombinedAppAndProtocolSummary)(summary)) {
18
+ throw new Error("Protocol and App Summary required in the full summary");
19
+ }
20
+ const protocolSummary = summary.tree[".protocol"];
21
+ const appSummary = summary.tree[".app"];
22
+ const documentAttributes = (0, driver_utils_1.getDocAttributesFromProtocolSummary)(protocolSummary);
23
+ const quorumValues = (0, driver_utils_1.getQuorumValuesFromProtocolSummary)(protocolSummary);
24
+ const sequenceNumber = documentAttributes.sequenceNumber;
25
+ await documentStorage.createDocument(tenantId, id, appSummary, sequenceNumber, server_services_client_1.defaultHash, resolvedUrl.endpoints.ordererUrl ?? "", resolvedUrl.endpoints.storageUrl ?? "", resolvedUrl.endpoints.deltaStorageUrl ?? "", quorumValues, false /* enableDiscovery */, false /* isEphemeralContainer */);
26
+ }
27
+ exports.createDocument = createDocument;
28
+ //# sourceMappingURL=localCreateDocument.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localCreateDocument.cjs","sourceRoot":"","sources":["../src/localCreateDocument.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAIsC;AAGtC,mFAAqE;AAE9D,KAAK,UAAU,cAAc,CACnC,0BAA0B,EAC1B,WAAyB,EACzB,OAAqB;IAErB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;IACnD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC7C,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACvC,MAAM,eAAe,GAAI,0BAAyD;SAChF,eAAe,CAAC;IAClB,IAAI,CAAC,IAAA,8CAA+B,EAAC,OAAO,CAAC,EAAE;QAC9C,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;KACzE;IACD,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,kBAAkB,GAAG,IAAA,kDAAmC,EAAC,eAAe,CAAC,CAAC;IAChF,MAAM,YAAY,GAAG,IAAA,iDAAkC,EAAC,eAAe,CAAC,CAAC;IACzE,MAAM,cAAc,GAAG,kBAAkB,CAAC,cAAc,CAAC;IACzD,MAAM,eAAe,CAAC,cAAc,CACnC,QAAQ,EACR,EAAE,EACF,UAAU,EACV,cAAc,EACd,oCAAW,EACX,WAAW,CAAC,SAAS,CAAC,UAAU,IAAI,EAAE,EACtC,WAAW,CAAC,SAAS,CAAC,UAAU,IAAI,EAAE,EACtC,WAAW,CAAC,SAAS,CAAC,eAAe,IAAI,EAAE,EAC3C,YAAY,EACZ,KAAK,CAAC,qBAAqB,EAC3B,KAAK,CAAC,0BAA0B,CAChC,CAAC;AACH,CAAC;AAhCD,wCAgCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { LocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport { defaultHash } from \"@fluidframework/server-services-client\";\n\nexport async function createDocument(\n\tlocalDeltaConnectionServer,\n\tresolvedUrl: IResolvedUrl,\n\tsummary: ISummaryTree,\n) {\n\tconst pathName = new URL(resolvedUrl.url).pathname;\n\tconst pathArr = pathName.split(\"/\");\n\tconst tenantId = pathArr[pathArr.length - 2];\n\tconst id = pathArr[pathArr.length - 1];\n\tconst documentStorage = (localDeltaConnectionServer as LocalDeltaConnectionServer)\n\t\t.documentStorage;\n\tif (!isCombinedAppAndProtocolSummary(summary)) {\n\t\tthrow new Error(\"Protocol and App Summary required in the full summary\");\n\t}\n\tconst protocolSummary = summary.tree[\".protocol\"];\n\tconst appSummary = summary.tree[\".app\"];\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);\n\tconst sequenceNumber = documentAttributes.sequenceNumber;\n\tawait documentStorage.createDocument(\n\t\ttenantId,\n\t\tid,\n\t\tappSummary,\n\t\tsequenceNumber,\n\t\tdefaultHash,\n\t\tresolvedUrl.endpoints.ordererUrl ?? \"\",\n\t\tresolvedUrl.endpoints.storageUrl ?? \"\",\n\t\tresolvedUrl.endpoints.deltaStorageUrl ?? \"\",\n\t\tquorumValues,\n\t\tfalse /* enableDiscovery */,\n\t\tfalse /* isEphemeralContainer */,\n\t);\n}\n"]}
@@ -0,0 +1,8 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { IResolvedUrl } from "@fluidframework/driver-definitions";
6
+ import { ISummaryTree } from "@fluidframework/protocol-definitions";
7
+ export declare function createDocument(localDeltaConnectionServer: any, resolvedUrl: IResolvedUrl, summary: ISummaryTree): Promise<void>;
8
+ //# sourceMappingURL=localCreateDocument.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localCreateDocument.d.ts","sourceRoot":"","sources":["../src/localCreateDocument.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAMlE,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAIpE,wBAAsB,cAAc,CACnC,0BAA0B,KAAA,EAC1B,WAAW,EAAE,YAAY,EACzB,OAAO,EAAE,YAAY,iBA6BrB"}
@@ -8,6 +8,7 @@ exports.LocalDeltaStorageService = void 0;
8
8
  const driver_utils_1 = require("@fluidframework/driver-utils");
9
9
  /**
10
10
  * Provides access to the underlying delta storage on the server for local driver.
11
+ * @internal
11
12
  */
12
13
  class LocalDeltaStorageService {
13
14
  constructor(tenantId, id, databaseManager) {
@@ -24,7 +25,7 @@ class LocalDeltaStorageService {
24
25
  query["operation.sequenceNumber"].$gt = from - 1; // from is inclusive
25
26
  // This looks like a bug. It used to work without setting $lt key. Now it does not
26
27
  // Need follow up
27
- query["operation.sequenceNumber"].$lt = to !== null && to !== void 0 ? to : Number.MAX_SAFE_INTEGER;
28
+ query["operation.sequenceNumber"].$lt = to ?? Number.MAX_SAFE_INTEGER;
28
29
  const allDeltas = await this.databaseManager.getDeltaCollection(this.tenantId, this.id);
29
30
  const dbDeltas = await allDeltas.find(query, { "operation.sequenceNumber": 1 });
30
31
  const messages = dbDeltas.map((delta) => delta.operation);
@@ -32,4 +33,4 @@ class LocalDeltaStorageService {
32
33
  }
33
34
  }
34
35
  exports.LocalDeltaStorageService = LocalDeltaStorageService;
35
- //# sourceMappingURL=localDeltaStorageService.js.map
36
+ //# sourceMappingURL=localDeltaStorageService.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localDeltaStorageService.cjs","sourceRoot":"","sources":["../src/localDeltaStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,+DAAkE;AAElE;;;GAGG;AACH,MAAa,wBAAwB;IACpC,YACkB,QAAgB,EAChB,EAAU,EACV,eAAiC;QAFjC,aAAQ,GAAR,QAAQ,CAAQ;QAChB,OAAE,GAAF,EAAE,CAAQ;QACV,oBAAe,GAAf,eAAe,CAAkB;IAChD,CAAC;IAEG,aAAa,CACnB,IAAY,EACZ,EAAsB,EACtB,WAAyB,EACzB,UAAoB;QAEpB,OAAO,IAAA,iCAAkB,EAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IACnD,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,EAAW;QAC9C,MAAM,KAAK,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC/D,KAAK,CAAC,0BAA0B,CAAC,GAAG,EAAE,CAAC;QACvC,KAAK,CAAC,0BAA0B,CAAC,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,oBAAoB;QAEtE,kFAAkF;QAClF,iBAAiB;QACjB,KAAK,CAAC,0BAA0B,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,MAAM,CAAC,gBAAgB,CAAC;QAEtE,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QACxF,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,0BAA0B,EAAE,CAAC,EAAE,CAAC,CAAC;QAChF,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC1D,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD;AA9BD,4DA8BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDocumentDeltaStorageService, IStream } from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { IDatabaseManager } from \"@fluidframework/server-services-core\";\nimport { streamFromMessages } from \"@fluidframework/driver-utils\";\n\n/**\n * Provides access to the underlying delta storage on the server for local driver.\n * @internal\n */\nexport class LocalDeltaStorageService implements IDocumentDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly id: string,\n\t\tprivate readonly databaseManager: IDatabaseManager,\n\t) {}\n\n\tpublic fetchMessages(\n\t\tfrom: number,\n\t\tto: number | undefined,\n\t\tabortSignal?: AbortSignal,\n\t\tcachedOnly?: boolean,\n\t): IStream<ISequencedDocumentMessage[]> {\n\t\treturn streamFromMessages(this.getCore(from, to));\n\t}\n\n\tprivate async getCore(from: number, to?: number) {\n\t\tconst query = { documentId: this.id, tenantId: this.tenantId };\n\t\tquery[\"operation.sequenceNumber\"] = {};\n\t\tquery[\"operation.sequenceNumber\"].$gt = from - 1; // from is inclusive\n\n\t\t// This looks like a bug. It used to work without setting $lt key. Now it does not\n\t\t// Need follow up\n\t\tquery[\"operation.sequenceNumber\"].$lt = to ?? Number.MAX_SAFE_INTEGER;\n\n\t\tconst allDeltas = await this.databaseManager.getDeltaCollection(this.tenantId, this.id);\n\t\tconst dbDeltas = await allDeltas.find(query, { \"operation.sequenceNumber\": 1 });\n\t\tconst messages = dbDeltas.map((delta) => delta.operation);\n\t\treturn messages;\n\t}\n}\n"]}
@@ -2,18 +2,19 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import * as api from "@fluidframework/driver-definitions";
5
+ import { IDocumentDeltaStorageService, IStream } from "@fluidframework/driver-definitions";
6
6
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
7
7
  import { IDatabaseManager } from "@fluidframework/server-services-core";
8
8
  /**
9
9
  * Provides access to the underlying delta storage on the server for local driver.
10
+ * @internal
10
11
  */
11
- export declare class LocalDeltaStorageService implements api.IDocumentDeltaStorageService {
12
+ export declare class LocalDeltaStorageService implements IDocumentDeltaStorageService {
12
13
  private readonly tenantId;
13
14
  private readonly id;
14
15
  private readonly databaseManager;
15
16
  constructor(tenantId: string, id: string, databaseManager: IDatabaseManager);
16
- fetchMessages(from: number, to: number | undefined, abortSignal?: AbortSignal, cachedOnly?: boolean): api.IStream<ISequencedDocumentMessage[]>;
17
+ fetchMessages(from: number, to: number | undefined, abortSignal?: AbortSignal, cachedOnly?: boolean): IStream<ISequencedDocumentMessage[]>;
17
18
  private getCore;
18
19
  }
19
20
  //# sourceMappingURL=localDeltaStorageService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"localDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/localDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,GAAG,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAGxE;;GAEG;AACH,qBAAa,wBAAyB,YAAW,GAAG,CAAC,4BAA4B;IAEzE,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAFf,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,gBAAgB;IAG/C,aAAa,CAChB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,WAAW,CAAC,EAAE,WAAW,EACzB,UAAU,CAAC,EAAE,OAAO,GACrB,GAAG,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC;YAI7B,OAAO;CAcxB"}
1
+ {"version":3,"file":"localDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/localDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,4BAA4B,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAGxE;;;GAGG;AACH,qBAAa,wBAAyB,YAAW,4BAA4B;IAE3E,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAFf,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,gBAAgB;IAG5C,aAAa,CACnB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,WAAW,CAAC,EAAE,WAAW,EACzB,UAAU,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,yBAAyB,EAAE,CAAC;YAIzB,OAAO;CAcrB"}
@@ -5,12 +5,13 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.LocalDocumentDeltaConnection = void 0;
8
- const common_utils_1 = require("@fluidframework/common-utils");
9
8
  const driver_base_1 = require("@fluidframework/driver-base");
10
9
  const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
10
+ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
11
11
  const testProtocolVersions = ["^0.3.0", "^0.2.0", "^0.1.0"];
12
12
  /**
13
13
  * Represents a connection to a stream of delta updates
14
+ * @internal
14
15
  */
15
16
  class LocalDocumentDeltaConnection extends driver_base_1.DocumentDeltaConnection {
16
17
  /**
@@ -23,12 +24,12 @@ class LocalDocumentDeltaConnection extends driver_base_1.DocumentDeltaConnection
23
24
  * @param client - information about the client
24
25
  * @param webSocketServer - web socket server to create connection
25
26
  */
26
- static async create(tenantId, id, token, client, webSocketServer, timeoutMs = 60000) {
27
+ static async create(tenantId, id, token, client, webSocketServer, timeoutMs = 60000, logger) {
27
28
  const socket = webSocketServer.createConnection();
28
29
  // Cast LocalWebSocket to SocketIOClient.Socket which is the socket that the base class needs. This is hacky
29
30
  // but should be fine because this delta connection is for local use only.
30
31
  const socketWithListener = socket;
31
- const deltaConnection = new LocalDocumentDeltaConnection(socketWithListener, id);
32
+ const deltaConnection = new LocalDocumentDeltaConnection(socketWithListener, id, logger);
32
33
  const connectMessage = {
33
34
  client,
34
35
  id,
@@ -40,11 +41,8 @@ class LocalDocumentDeltaConnection extends driver_base_1.DocumentDeltaConnection
40
41
  await deltaConnection.initialize(connectMessage, timeoutMs);
41
42
  return deltaConnection;
42
43
  }
43
- constructor(socket, documentId) {
44
- super(socket, documentId, new common_utils_1.TelemetryNullLogger());
45
- }
46
- submitCore(type, messages) {
47
- this.emitMessages(type, [messages]);
44
+ constructor(socket, documentId, logger) {
45
+ super(socket, documentId, (0, telemetry_utils_1.createChildLogger)({ logger }));
48
46
  }
49
47
  /**
50
48
  * Submits a new delta operation to the server
@@ -53,14 +51,14 @@ class LocalDocumentDeltaConnection extends driver_base_1.DocumentDeltaConnection
53
51
  // We use a promise resolve to force a turn break given message processing is sync
54
52
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
55
53
  Promise.resolve().then(() => {
56
- this.submitCore("submitOp", messages);
54
+ this.emitMessages("submitOp", [messages]);
57
55
  });
58
56
  }
59
57
  /**
60
58
  * Submits a new signal to the server
61
59
  */
62
60
  submitSignal(message) {
63
- this.submitCore("submitSignal", [message]);
61
+ this.emitMessages("submitSignal", [[message]]);
64
62
  }
65
63
  /**
66
64
  * Send a "disconnect" message on the socket.
@@ -89,4 +87,4 @@ class LocalDocumentDeltaConnection extends driver_base_1.DocumentDeltaConnection
89
87
  }
90
88
  }
91
89
  exports.LocalDocumentDeltaConnection = LocalDocumentDeltaConnection;
92
- //# sourceMappingURL=localDocumentDeltaConnection.js.map
90
+ //# sourceMappingURL=localDocumentDeltaConnection.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localDocumentDeltaConnection.cjs","sourceRoot":"","sources":["../src/localDocumentDeltaConnection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6DAAsE;AACtE,+EAK8C;AAC9C,qEAAoE;AAMpE,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAE5D;;;GAGG;AACH,MAAa,4BAA6B,SAAQ,qCAAuB;IACxE;;;;;;;;;OASG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CACzB,QAAgB,EAChB,EAAU,EACV,KAAa,EACb,MAAe,EACf,eAAiC,EACjC,SAAS,GAAG,KAAK,EACjB,MAA6B;QAE7B,MAAM,MAAM,GAAI,eAAwC,CAAC,gBAAgB,EAAE,CAAC;QAE5E,4GAA4G;QAC5G,0EAA0E;QAC1E,MAAM,kBAAkB,GAAG,MAA2B,CAAC;QAEvD,MAAM,eAAe,GAAG,IAAI,4BAA4B,CAAC,kBAAkB,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAEzF,MAAM,cAAc,GAAa;YAChC,MAAM;YACN,EAAE;YACF,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,QAAQ;YACR,KAAK;YACL,QAAQ,EAAE,oBAAoB;SAC9B,CAAC;QACF,MAAM,eAAe,CAAC,UAAU,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;QAC5D,OAAO,eAAe,CAAC;IACxB,CAAC;IAED,YAAY,MAAc,EAAE,UAAkB,EAAE,MAA6B;QAC5E,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,IAAA,mCAAiB,EAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAA4B;QACzC,kFAAkF;QAClF,mEAAmE;QACnE,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YAC3B,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,YAAY,CAAC,OAAY;QAC/B,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;;OAGG;IACI,gBAAgB,CAAC,gBAAwB;QAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IAClD,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAChB,OAAe,GAAG,EAClB,OAAsB,oCAAa,CAAC,eAAe,EACnD,OAAY;QAEZ,MAAM,WAAW,GAAG;YACnB,SAAS,EAAE,SAAS;YACpB,cAAc,EAAE,CAAC,CAAC;YAClB,OAAO,EAAE;gBACR,IAAI;gBACJ,IAAI;gBACJ,OAAO;aACP;SACD,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7C,CAAC;CACD;AA5FD,oEA4FC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DocumentDeltaConnection } from \"@fluidframework/driver-base\";\nimport {\n\tIClient,\n\tIConnect,\n\tIDocumentMessage,\n\tNackErrorType,\n} from \"@fluidframework/protocol-definitions\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { LocalWebSocketServer } from \"@fluidframework/server-local-server\";\nimport { IWebSocketServer } from \"@fluidframework/server-services-core\";\nimport type { Socket } from \"socket.io-client\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\n\nconst testProtocolVersions = [\"^0.3.0\", \"^0.2.0\", \"^0.1.0\"];\n\n/**\n * Represents a connection to a stream of delta updates\n * @internal\n */\nexport class LocalDocumentDeltaConnection extends DocumentDeltaConnection {\n\t/**\n\t * Create a LocalDocumentDeltaConnection\n\t * Handle initial messages, contents or signals if they were in queue\n\t *\n\t * @param tenantId - the ID of the tenant\n\t * @param id - document ID\n\t * @param token - authorization token for storage service\n\t * @param client - information about the client\n\t * @param webSocketServer - web socket server to create connection\n\t */\n\tpublic static async create(\n\t\ttenantId: string,\n\t\tid: string,\n\t\ttoken: string,\n\t\tclient: IClient,\n\t\twebSocketServer: IWebSocketServer,\n\t\ttimeoutMs = 60000,\n\t\tlogger?: ITelemetryBaseLogger,\n\t): Promise<LocalDocumentDeltaConnection> {\n\t\tconst socket = (webSocketServer as LocalWebSocketServer).createConnection();\n\n\t\t// Cast LocalWebSocket to SocketIOClient.Socket which is the socket that the base class needs. This is hacky\n\t\t// but should be fine because this delta connection is for local use only.\n\t\tconst socketWithListener = socket as unknown as Socket;\n\n\t\tconst deltaConnection = new LocalDocumentDeltaConnection(socketWithListener, id, logger);\n\n\t\tconst connectMessage: IConnect = {\n\t\t\tclient,\n\t\t\tid,\n\t\t\tmode: client.mode,\n\t\t\ttenantId,\n\t\t\ttoken, // Token is going to indicate tenant level information, etc...\n\t\t\tversions: testProtocolVersions,\n\t\t};\n\t\tawait deltaConnection.initialize(connectMessage, timeoutMs);\n\t\treturn deltaConnection;\n\t}\n\n\tconstructor(socket: Socket, documentId: string, logger?: ITelemetryBaseLogger) {\n\t\tsuper(socket, documentId, createChildLogger({ logger }));\n\t}\n\n\t/**\n\t * Submits a new delta operation to the server\n\t */\n\tpublic submit(messages: IDocumentMessage[]): void {\n\t\t// We use a promise resolve to force a turn break given message processing is sync\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tPromise.resolve().then(() => {\n\t\t\tthis.emitMessages(\"submitOp\", [messages]);\n\t\t});\n\t}\n\n\t/**\n\t * Submits a new signal to the server\n\t */\n\tpublic submitSignal(message: any): void {\n\t\tthis.emitMessages(\"submitSignal\", [[message]]);\n\t}\n\n\t/**\n\t * Send a \"disconnect\" message on the socket.\n\t * @param disconnectReason - The reason of the disconnection.\n\t */\n\tpublic disconnectClient(disconnectReason: string) {\n\t\tthis.socket.emit(\"disconnect\", disconnectReason);\n\t}\n\n\t/**\n\t * * Sends a \"nack\" message on the socket.\n\t * @param code - An error code number that represents the error. It will be a valid HTTP error code.\n\t * @param type - Type of the Nack.\n\t * @param message - A message about the nack for debugging/logging/telemetry purposes.\n\t */\n\tpublic nackClient(\n\t\tcode: number = 400,\n\t\ttype: NackErrorType = NackErrorType.ThrottlingError,\n\t\tmessage: any,\n\t) {\n\t\tconst nackMessage = {\n\t\t\toperation: undefined,\n\t\t\tsequenceNumber: -1,\n\t\t\tcontent: {\n\t\t\t\tcode,\n\t\t\t\ttype,\n\t\t\t\tmessage,\n\t\t\t},\n\t\t};\n\t\tthis.socket.emit(\"nack\", \"\", [nackMessage]);\n\t}\n}\n"]}
@@ -4,10 +4,12 @@
4
4
  */
5
5
  import { DocumentDeltaConnection } from "@fluidframework/driver-base";
6
6
  import { IClient, IDocumentMessage, NackErrorType } from "@fluidframework/protocol-definitions";
7
- import * as core from "@fluidframework/server-services-core";
7
+ import { IWebSocketServer } from "@fluidframework/server-services-core";
8
8
  import type { Socket } from "socket.io-client";
9
+ import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
9
10
  /**
10
11
  * Represents a connection to a stream of delta updates
12
+ * @internal
11
13
  */
12
14
  export declare class LocalDocumentDeltaConnection extends DocumentDeltaConnection {
13
15
  /**
@@ -20,9 +22,8 @@ export declare class LocalDocumentDeltaConnection extends DocumentDeltaConnectio
20
22
  * @param client - information about the client
21
23
  * @param webSocketServer - web socket server to create connection
22
24
  */
23
- static create(tenantId: string, id: string, token: string, client: IClient, webSocketServer: core.IWebSocketServer, timeoutMs?: number): Promise<LocalDocumentDeltaConnection>;
24
- constructor(socket: Socket, documentId: string);
25
- protected submitCore(type: string, messages: IDocumentMessage[]): void;
25
+ static create(tenantId: string, id: string, token: string, client: IClient, webSocketServer: IWebSocketServer, timeoutMs?: number, logger?: ITelemetryBaseLogger): Promise<LocalDocumentDeltaConnection>;
26
+ constructor(socket: Socket, documentId: string, logger?: ITelemetryBaseLogger);
26
27
  /**
27
28
  * Submits a new delta operation to the server
28
29
  */
@@ -1 +1 @@
1
- {"version":3,"file":"localDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/localDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EACH,OAAO,EAEP,gBAAgB,EAChB,aAAa,EAChB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,KAAK,IAAI,MAAM,sCAAsC,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI/C;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,uBAAuB;IACrE;;;;;;;;;OASG;WACiB,MAAM,CACtB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,OAAO,EACf,eAAe,EAAE,IAAI,CAAC,gBAAgB,EACtC,SAAS,SAAQ,GAClB,OAAO,CAAC,4BAA4B,CAAC;gBAqB5B,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAI9C,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE;IAI/D;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI;IAQjD;;OAEG;IACI,YAAY,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;IAIvC;;;OAGG;IACI,gBAAgB,CAAC,gBAAgB,EAAE,MAAM;IAIhD;;;;;OAKG;IACI,UAAU,CAAC,IAAI,oBAAc,EAAE,IAAI,2BAA+C,EAAE,OAAO,EAAE,GAAG;CAY1G"}
1
+ {"version":3,"file":"localDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/localDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EACN,OAAO,EAEP,gBAAgB,EAChB,aAAa,EACb,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAIvE;;;GAGG;AACH,qBAAa,4BAA6B,SAAQ,uBAAuB;IACxE;;;;;;;;;OASG;WACiB,MAAM,CACzB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,OAAO,EACf,eAAe,EAAE,gBAAgB,EACjC,SAAS,SAAQ,EACjB,MAAM,CAAC,EAAE,oBAAoB,GAC3B,OAAO,CAAC,4BAA4B,CAAC;gBAqB5B,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,oBAAoB;IAI7E;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI;IAQjD;;OAEG;IACI,YAAY,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;IAIvC;;;OAGG;IACI,gBAAgB,CAAC,gBAAgB,EAAE,MAAM;IAIhD;;;;;OAKG;IACI,UAAU,CAChB,IAAI,oBAAc,EAClB,IAAI,2BAA+C,EACnD,OAAO,EAAE,GAAG;CAab"}