@fluidframework/driver-utils 2.74.0-365691 → 2.74.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts.map +1 -1
- package/dist/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js.map +1 -1
- package/dist/insecureUrlResolver.js.map +1 -1
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js.map +1 -1
- package/dist/networkUtils.d.ts.map +1 -1
- package/dist/networkUtils.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/parallelRequests.d.ts.map +1 -1
- package/dist/parallelRequests.js.map +1 -1
- package/dist/prefetchDocumentStorageService.d.ts.map +1 -1
- package/dist/prefetchDocumentStorageService.js.map +1 -1
- package/dist/rateLimiter.d.ts.map +1 -1
- package/dist/rateLimiter.js.map +1 -1
- package/eslint.config.mts +26 -0
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.d.ts.map +1 -1
- package/lib/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.js.map +1 -1
- package/lib/insecureUrlResolver.js.map +1 -1
- package/lib/network.d.ts.map +1 -1
- package/lib/network.js.map +1 -1
- package/lib/networkUtils.d.ts.map +1 -1
- package/lib/networkUtils.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/parallelRequests.d.ts.map +1 -1
- package/lib/parallelRequests.js.map +1 -1
- package/lib/prefetchDocumentStorageService.d.ts.map +1 -1
- package/lib/prefetchDocumentStorageService.js.map +1 -1
- package/lib/rateLimiter.d.ts.map +1 -1
- package/lib/rateLimiter.js.map +1 -1
- package/package.json +11 -10
- package/src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts +8 -4
- package/src/insecureUrlResolver.ts +1 -1
- package/src/network.ts +4 -1
- package/src/networkUtils.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/parallelRequests.ts +16 -16
- package/src/prefetchDocumentStorageService.ts +3 -3
- package/src/rateLimiter.ts +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefetchDocumentStorageService.js","sourceRoot":"","sources":["../src/prefetchDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAElF,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,2BAA2B;IAA/E;;QACC,qCAAqC;QACpB,kBAAa,GAAG,IAAI,GAAG,EAAoC,CAAC;QACrE,oBAAe,GAAG,IAAI,CAAC;IAgFhC,CAAC;IA9EA,IAAW,QAAQ;QAClB,MAAM,QAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;QACtD,IAAI,QAAQ,EAAE,CAAC;YACd,OAAO,EAAE,GAAG,QAAQ,EAAE,OAAO,EAAE,mBAAmB,CAAC,SAAS,EAAE,CAAC;QAChE,CAAC;IACF,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,OAAkB;QAC9C,MAAM,CAAC,GAAG,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;QAC/D,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1B,yCAAyC;YACzC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,IAAsC,EAAE,EAAE;gBACtD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,E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AAM,IAAI,IAAI,SAAS,EAAE,CAAC;YAC9B,yCAAyC;YACzC,KAAK,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;IACF,CAAC;IAEO,gBAAgB,CAAC,IAAmB,EAAE,SAAmB;QAChE,KAAK,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1D,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACrF,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;oBACnB,yCAAyC;oBACzC,KAAK,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;gBAC5B,CAAC;YACF,CAAC;iBAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC1C,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;oBACnB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACtB,CAAC;YACF,CAAC;QACF,CAAC;QAED,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACjD,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC3C,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIDocumentStorageServicePolicies,\n\tISnapshotTree,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { LoaderCachingPolicy } from \"@fluidframework/driver-definitions/internal\";\n\nimport { DocumentStorageServiceProxy } from \"./documentStorageServiceProxy.js\";\nimport { canRetryOnError } from \"./network.js\";\n\n/**\n * @internal\n */\nexport class PrefetchDocumentStorageService extends DocumentStorageServiceProxy {\n\t// BlobId -> blob prefetchCache cache\n\tprivate readonly prefetchCache = new Map<string, Promise<ArrayBufferLike>>();\n\tprivate prefetchEnabled = true;\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\tconst policies = this.internalStorageService.policies;\n\t\tif (policies) {\n\t\t\treturn { ...policies, caching: LoaderCachingPolicy.NoCaching };\n\t\t}\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tconst p = this.internalStorageService.getSnapshotTree(version);\n\t\tif (this.prefetchEnabled) {\n\t\t\t// We don't care if the prefetch succeeds\n\t\t\tvoid p.then((tree: ISnapshotTree | null | undefined) => {\n\t\t\t\tif (tree === null || tree === undefined) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.prefetchTree(tree);\n\t\t\t});\n\t\t}\n\t\treturn p;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\treturn this.cachedRead(blobId);\n\t}\n\tpublic stopPrefetch() {\n\t\tthis.prefetchEnabled = false;\n\t\tthis.prefetchCache.clear();\n\t}\n\n\tprivate async cachedRead(blobId: string): Promise<ArrayBufferLike> {\n\t\tif (this.prefetchEnabled) {\n\t\t\tconst prefetchedBlobP = this.prefetchCache.get(blobId);\n\t\t\tif (prefetchedBlobP !== undefined) {\n\t\t\t\treturn prefetchedBlobP;\n\t\t\t}\n\t\t\tconst prefetchedBlobPFromStorage = this.internalStorageService.readBlob(blobId);\n\t\t\tthis.prefetchCache.set(\n\t\t\t\tblobId,\n\t\t\t\tprefetchedBlobPFromStorage.catch((error) => {\n\t\t\t\t\tif (canRetryOnError(error)) {\n\t\t\t\t\t\tthis.prefetchCache.delete(blobId);\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn prefetchedBlobPFromStorage;\n\t\t}\n\t\treturn this.internalStorageService.readBlob(blobId);\n\t}\n\n\tprivate prefetchTree(tree: ISnapshotTree) {\n\t\tconst secondary: string[] = [];\n\t\tthis.prefetchTreeCore(tree, secondary);\n\n\t\tfor (const blob of secondary) {\n\t\t\t// We don't care if the prefetch succeeds\n\t\t\tvoid this.cachedRead(blob);\n\t\t}\n\t}\n\n\tprivate prefetchTreeCore(tree: ISnapshotTree, secondary: string[]) {\n\t\tfor (const [blobKey, blob] of Object.entries(tree.blobs)) {\n\t\t\tif (blobKey.startsWith(\".\") || blobKey === \"header\" || blobKey.startsWith(\"quorum\")) {\n\t\t\t\tif (blob !== null) {\n\t\t\t\t\t// We don't care if the prefetch succeeds\n\t\t\t\t\tvoid this.cachedRead(blob);\n\t\t\t\t}\n\t\t\t} else if (!blobKey.startsWith(\"deltas\")) {\n\t\t\t\tif (blob !== null) {\n\t\t\t\t\tsecondary.push(blob);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const subTree of Object.values(tree.trees)) {\n\t\t\tthis.prefetchTreeCore(subTree, secondary);\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"prefetchDocumentStorageService.js","sourceRoot":"","sources":["../src/prefetchDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAElF,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,2BAA2B;IAA/E;;QACC,qCAAqC;QACpB,kBAAa,GAAG,IAAI,GAAG,EAAoC,CAAC;QACrE,oBAAe,GAAG,IAAI,CAAC;IAgFhC,CAAC;IA9EA,IAAW,QAAQ;QAClB,MAAM,QAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;QACtD,IAAI,QAAQ,EAAE,CAAC;YACd,OAAO,EAAE,GAAG,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C,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC3C,CAAC;IACF,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIDocumentStorageServicePolicies,\n\tISnapshotTree,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { LoaderCachingPolicy } from \"@fluidframework/driver-definitions/internal\";\n\nimport { DocumentStorageServiceProxy } from \"./documentStorageServiceProxy.js\";\nimport { canRetryOnError } from \"./network.js\";\n\n/**\n * @internal\n */\nexport class PrefetchDocumentStorageService extends DocumentStorageServiceProxy {\n\t// BlobId -> blob prefetchCache cache\n\tprivate readonly prefetchCache = new Map<string, Promise<ArrayBufferLike>>();\n\tprivate prefetchEnabled = true;\n\n\tpublic get policies(): IDocumentStorageServicePolicies | undefined {\n\t\tconst policies = this.internalStorageService.policies;\n\t\tif (policies) {\n\t\t\treturn { ...policies, caching: LoaderCachingPolicy.NoCaching };\n\t\t}\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTree | null> {\n\t\tconst p = this.internalStorageService.getSnapshotTree(version);\n\t\tif (this.prefetchEnabled) {\n\t\t\t// We don't care if the prefetch succeeds\n\t\t\tvoid p.then((tree: ISnapshotTree | null | undefined) => {\n\t\t\t\tif (tree === null || tree === undefined) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthis.prefetchTree(tree);\n\t\t\t});\n\t\t}\n\t\treturn p;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\treturn this.cachedRead(blobId);\n\t}\n\tpublic stopPrefetch(): void {\n\t\tthis.prefetchEnabled = false;\n\t\tthis.prefetchCache.clear();\n\t}\n\n\tprivate async cachedRead(blobId: string): Promise<ArrayBufferLike> {\n\t\tif (this.prefetchEnabled) {\n\t\t\tconst prefetchedBlobP = this.prefetchCache.get(blobId);\n\t\t\tif (prefetchedBlobP !== undefined) {\n\t\t\t\treturn prefetchedBlobP;\n\t\t\t}\n\t\t\tconst prefetchedBlobPFromStorage = this.internalStorageService.readBlob(blobId);\n\t\t\tthis.prefetchCache.set(\n\t\t\t\tblobId,\n\t\t\t\tprefetchedBlobPFromStorage.catch((error) => {\n\t\t\t\t\tif (canRetryOnError(error)) {\n\t\t\t\t\t\tthis.prefetchCache.delete(blobId);\n\t\t\t\t\t}\n\t\t\t\t\tthrow error;\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn prefetchedBlobPFromStorage;\n\t\t}\n\t\treturn this.internalStorageService.readBlob(blobId);\n\t}\n\n\tprivate prefetchTree(tree: ISnapshotTree): void {\n\t\tconst secondary: string[] = [];\n\t\tthis.prefetchTreeCore(tree, secondary);\n\n\t\tfor (const blob of secondary) {\n\t\t\t// We don't care if the prefetch succeeds\n\t\t\tvoid this.cachedRead(blob);\n\t\t}\n\t}\n\n\tprivate prefetchTreeCore(tree: ISnapshotTree, secondary: string[]): void {\n\t\tfor (const [blobKey, blob] of Object.entries(tree.blobs)) {\n\t\t\tif (blobKey.startsWith(\".\") || blobKey === \"header\" || blobKey.startsWith(\"quorum\")) {\n\t\t\t\tif (blob !== null) {\n\t\t\t\t\t// We don't care if the prefetch succeeds\n\t\t\t\t\tvoid this.cachedRead(blob);\n\t\t\t\t}\n\t\t\t} else if (!blobKey.startsWith(\"deltas\")) {\n\t\t\t\tif (blob !== null) {\n\t\t\t\t\tsecondary.push(blob);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const subTree of Object.values(tree.trees)) {\n\t\t\tthis.prefetchTreeCore(subTree, secondary);\n\t\t}\n\t}\n}\n"]}
|
package/lib/rateLimiter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rateLimiter.d.ts","sourceRoot":"","sources":["../src/rateLimiter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,qBAAa,WAAW;IAEX,OAAO,CAAC,WAAW;IAD/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsB;gBACxB,WAAW,EAAE,MAAM;IAIvC,IAAW,eAAe,IAAI,MAAM,CAEnC;IAID,SAAS,CAAC,QAAQ,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"rateLimiter.d.ts","sourceRoot":"","sources":["../src/rateLimiter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,qBAAa,WAAW;IAEX,OAAO,CAAC,WAAW;IAD/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsB;gBACxB,WAAW,EAAE,MAAM;IAIvC,IAAW,eAAe,IAAI,MAAM,CAEnC;IAID,SAAS,CAAC,QAAQ,CAAC,OAAO,QAAO,IAAI,CAMnC;cAEc,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAW3B,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAI5D"}
|
package/lib/rateLimiter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rateLimiter.js","sourceRoot":"","sources":["../src/rateLimiter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D;;GAEG;AACH,MAAM,OAAO,WAAW;IAEvB,YAAoB,WAAmB;QAAnB,gBAAW,GAAX,WAAW,CAAQ;QADtB,UAAK,GAAmB,EAAE,CAAC;QAS5C,8CAA8C;QAC9C,0EAA0E;QACvD,YAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"rateLimiter.js","sourceRoot":"","sources":["../src/rateLimiter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D;;GAEG;AACH,MAAM,OAAO,WAAW;IAEvB,YAAoB,WAAmB;QAAnB,gBAAW,GAAX,WAAW,CAAQ;QADtB,UAAK,GAAmB,EAAE,CAAC;QAS5C,8CAA8C;QAC9C,0EAA0E;QACvD,YAAO,GAAG,GAAS,EAAE;YACvC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YAChC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACxB,OAAO,IAAI,EAAE,CAAC;YACf,CAAC;YACD,IAAI,CAAC,WAAW,EAAE,CAAC;QACpB,CAAC,CAAC;QAfD,MAAM,CAAC,WAAW,GAAG,CAAC,EAAE,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC1F,CAAC;IAED,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC1B,CAAC;IAYS,KAAK,CAAC,OAAO;QACtB,IAAI,IAAI,CAAC,WAAW,GAAG,CAAC,EAAE,CAAC;YAC1B,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,OAAO;QACR,CAAC;QAED,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YACpC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACJ,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAI,IAAsB;QAC9C,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,IAAI,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils/internal\";\n\n/**\n * @legacy @beta\n */\nexport class RateLimiter {\n\tprivate readonly tasks: (() => void)[] = [];\n\tconstructor(private maxRequests: number) {\n\t\tassert(maxRequests > 0, 0x0ae /* \"Tried to create rate limiter with 0 max requests!\" */);\n\t}\n\n\tpublic get waitQueueLength(): number {\n\t\treturn this.tasks.length;\n\t}\n\n\t// Run when one of the tasks finished running.\n\t// Release next task if we have one, or allow more tasks to run in future.\n\tprotected readonly release = (): void => {\n\t\tconst task = this.tasks.shift();\n\t\tif (task !== undefined) {\n\t\t\treturn task();\n\t\t}\n\t\tthis.maxRequests++;\n\t};\n\n\tprotected async acquire(): Promise<void> {\n\t\tif (this.maxRequests > 0) {\n\t\t\tthis.maxRequests--;\n\t\t\treturn;\n\t\t}\n\n\t\treturn new Promise<void>((resolve) => {\n\t\t\tthis.tasks.push(resolve);\n\t\t});\n\t}\n\n\tpublic async schedule<T>(work: () => Promise<T>): Promise<T> {\n\t\tawait this.acquire();\n\t\treturn work().finally(this.release);\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/driver-utils",
|
|
3
|
-
"version": "2.74.0
|
|
3
|
+
"version": "2.74.0",
|
|
4
4
|
"description": "Collection of utility functions for Fluid drivers",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -69,11 +69,11 @@
|
|
|
69
69
|
"temp-directory": "nyc/.nyc_output"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@fluid-internal/client-utils": "2.74.0
|
|
73
|
-
"@fluidframework/core-interfaces": "2.74.0
|
|
74
|
-
"@fluidframework/core-utils": "2.74.0
|
|
75
|
-
"@fluidframework/driver-definitions": "2.74.0
|
|
76
|
-
"@fluidframework/telemetry-utils": "2.74.0
|
|
72
|
+
"@fluid-internal/client-utils": "~2.74.0",
|
|
73
|
+
"@fluidframework/core-interfaces": "~2.74.0",
|
|
74
|
+
"@fluidframework/core-utils": "~2.74.0",
|
|
75
|
+
"@fluidframework/driver-definitions": "~2.74.0",
|
|
76
|
+
"@fluidframework/telemetry-utils": "~2.74.0",
|
|
77
77
|
"axios": "^1.8.4",
|
|
78
78
|
"lz4js": "^0.2.0",
|
|
79
79
|
"uuid": "^11.1.0"
|
|
@@ -81,12 +81,12 @@
|
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
83
83
|
"@biomejs/biome": "~1.9.3",
|
|
84
|
-
"@fluid-internal/mocha-test-setup": "2.74.0
|
|
85
|
-
"@fluid-tools/build-cli": "^0.
|
|
84
|
+
"@fluid-internal/mocha-test-setup": "~2.74.0",
|
|
85
|
+
"@fluid-tools/build-cli": "^0.61.0",
|
|
86
86
|
"@fluidframework/build-common": "^2.0.3",
|
|
87
|
-
"@fluidframework/build-tools": "^0.
|
|
87
|
+
"@fluidframework/build-tools": "^0.61.0",
|
|
88
88
|
"@fluidframework/driver-utils-previous": "npm:@fluidframework/driver-utils@2.73.0",
|
|
89
|
-
"@fluidframework/eslint-config-fluid": "2.74.0
|
|
89
|
+
"@fluidframework/eslint-config-fluid": "~2.74.0",
|
|
90
90
|
"@microsoft/api-extractor": "7.52.11",
|
|
91
91
|
"@types/mocha": "^10.0.10",
|
|
92
92
|
"@types/node": "^18.19.0",
|
|
@@ -96,6 +96,7 @@
|
|
|
96
96
|
"copyfiles": "^2.4.1",
|
|
97
97
|
"cross-env": "^7.0.3",
|
|
98
98
|
"eslint": "~8.57.1",
|
|
99
|
+
"jiti": "^2.6.1",
|
|
99
100
|
"mocha": "^10.8.2",
|
|
100
101
|
"mocha-multi-reporters": "^1.5.1",
|
|
101
102
|
"rimraf": "^4.4.0",
|
package/src/adapters/compression/summaryblob/documentStorageServiceSummaryBlobCompressionAdapter.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { IsoBuffer } from "@fluid-internal/client-utils";
|
|
6
|
+
import { type Buffer, IsoBuffer } from "@fluid-internal/client-utils";
|
|
7
7
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
8
8
|
import {
|
|
9
9
|
ISummaryBlob,
|
|
@@ -90,7 +90,7 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
|
|
|
90
90
|
private static writeAlgorithmToBlob(
|
|
91
91
|
blob: ArrayBufferLike,
|
|
92
92
|
algorithm: number,
|
|
93
|
-
): ArrayBufferLike {
|
|
93
|
+
): ArrayBufferLike | Buffer {
|
|
94
94
|
if (algorithm === SummaryCompressionAlgorithm.None) {
|
|
95
95
|
const firstByte = IsoBuffer.from(blob)[0];
|
|
96
96
|
// eslint-disable-next-line no-bitwise
|
|
@@ -114,7 +114,9 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
|
|
|
114
114
|
* @param blob - The blob to remove the prefix from.
|
|
115
115
|
* @returns The blob without the prefix.
|
|
116
116
|
*/
|
|
117
|
-
private static removePrefixFromBlobIfPresent(
|
|
117
|
+
private static removePrefixFromBlobIfPresent(
|
|
118
|
+
blob: ArrayBufferLike,
|
|
119
|
+
): ArrayBufferLike | Buffer {
|
|
118
120
|
const blobView = new Uint8Array(blob);
|
|
119
121
|
return this.hasPrefix(blob) ? IsoBuffer.from(blobView.subarray(1)) : blob;
|
|
120
122
|
}
|
|
@@ -315,7 +317,9 @@ export class DocumentStorageServiceCompressionAdapter extends DocumentStorageSer
|
|
|
315
317
|
* @param summary - The summary tree to traverse.
|
|
316
318
|
* @returns The content of the tree attribute of the summary tree containing the metadata blob.
|
|
317
319
|
*/
|
|
318
|
-
private static getMetadataHolderTree(summary: ISummaryTree) {
|
|
320
|
+
private static getMetadataHolderTree(summary: ISummaryTree): {
|
|
321
|
+
[path: string]: SummaryObject;
|
|
322
|
+
} {
|
|
319
323
|
const metadataHolder = this.findMetadataHolderSummary(summary);
|
|
320
324
|
assert(metadataHolder !== undefined, 0x6f8 /* metadataHolder must be a non-null object */);
|
|
321
325
|
const metadataHolderTree = metadataHolder.tree;
|
|
@@ -92,7 +92,7 @@ export class InsecureUrlResolver implements IUrlResolver {
|
|
|
92
92
|
documentId: string | null,
|
|
93
93
|
documentRelativePath: string = "",
|
|
94
94
|
queryParams: string = "",
|
|
95
|
-
) {
|
|
95
|
+
): IResolvedUrl {
|
|
96
96
|
const encodedTenantId = encodeURIComponent(this.tenantId);
|
|
97
97
|
const host = new URL(this.ordererUrl).host;
|
|
98
98
|
// when the document ID is not provided we need to resolve a special create new document URL.
|
package/src/network.ts
CHANGED
|
@@ -228,7 +228,10 @@ export class ThrottlingError
|
|
|
228
228
|
/**
|
|
229
229
|
* @internal
|
|
230
230
|
*/
|
|
231
|
-
export const createWriteError = (
|
|
231
|
+
export const createWriteError = (
|
|
232
|
+
message: string,
|
|
233
|
+
props: DriverErrorTelemetryProps,
|
|
234
|
+
): NonRetryableError<"writeError"> =>
|
|
232
235
|
new NonRetryableError(message, DriverErrorTypes.writeError, props);
|
|
233
236
|
|
|
234
237
|
/**
|
package/src/networkUtils.ts
CHANGED
package/src/packageVersion.ts
CHANGED
package/src/parallelRequests.ts
CHANGED
|
@@ -55,10 +55,10 @@ export class ParallelRequests<T> {
|
|
|
55
55
|
private requests = 0;
|
|
56
56
|
private readonly knewTo: boolean;
|
|
57
57
|
|
|
58
|
-
private get working() {
|
|
58
|
+
private get working(): boolean {
|
|
59
59
|
return this.workingState === "working";
|
|
60
60
|
}
|
|
61
|
-
public get canceled() {
|
|
61
|
+
public get canceled(): boolean {
|
|
62
62
|
return this.workingState === "canceled";
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -81,14 +81,14 @@ export class ParallelRequests<T> {
|
|
|
81
81
|
this.knewTo = to !== undefined;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
public cancel() {
|
|
84
|
+
public cancel(): void {
|
|
85
85
|
if (this.working) {
|
|
86
86
|
this.workingState = "canceled";
|
|
87
87
|
this.endEvent.resolve();
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
public async run(concurrency: number) {
|
|
91
|
+
public async run(concurrency: number): Promise<void> {
|
|
92
92
|
assert(concurrency > 0, 0x102 /* "invalid level of concurrency" */);
|
|
93
93
|
assert(this.working, 0x103 /* "trying to parallel run while not working" */);
|
|
94
94
|
|
|
@@ -101,7 +101,7 @@ export class ParallelRequests<T> {
|
|
|
101
101
|
return this.endEvent.promise;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
private done() {
|
|
104
|
+
private done(): void {
|
|
105
105
|
// We should satisfy request fully.
|
|
106
106
|
assert(this.to !== undefined, 0x104 /* "undefined end point for parallel fetch" */);
|
|
107
107
|
assert(
|
|
@@ -114,14 +114,14 @@ export class ParallelRequests<T> {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
private fail(error) {
|
|
117
|
+
private fail(error): void {
|
|
118
118
|
if (this.working) {
|
|
119
119
|
this.workingState = "done";
|
|
120
120
|
this.endEvent.reject(error);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
private dispatch() {
|
|
124
|
+
private dispatch(): void {
|
|
125
125
|
while (this.working) {
|
|
126
126
|
const value = this.results.get(this.nextToDeliver);
|
|
127
127
|
if (value === undefined) {
|
|
@@ -158,7 +158,7 @@ export class ParallelRequests<T> {
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
private getNextChunk() {
|
|
161
|
+
private getNextChunk(): { from: number; to: number } | undefined {
|
|
162
162
|
if (!this.working) {
|
|
163
163
|
return undefined;
|
|
164
164
|
}
|
|
@@ -183,7 +183,7 @@ export class ParallelRequests<T> {
|
|
|
183
183
|
return { from, to: this.latestRequested };
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
private addRequest() {
|
|
186
|
+
private addRequest(): void {
|
|
187
187
|
const chunk = this.getNextChunk();
|
|
188
188
|
if (chunk === undefined) {
|
|
189
189
|
return;
|
|
@@ -191,7 +191,7 @@ export class ParallelRequests<T> {
|
|
|
191
191
|
this.addRequestCore(chunk.from, chunk.to).catch(this.fail.bind(this));
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
private async addRequestCore(fromArg: number, toArg: number) {
|
|
194
|
+
private async addRequestCore(fromArg: number, toArg: number): Promise<void> {
|
|
195
195
|
assert(this.working, 0x10a /* "cannot add parallel request while not working" */);
|
|
196
196
|
|
|
197
197
|
let from = fromArg;
|
|
@@ -354,22 +354,22 @@ export class Queue<T> implements IStream<T> {
|
|
|
354
354
|
private deferred: Deferred<IStreamResult<T>> | undefined;
|
|
355
355
|
private done = false;
|
|
356
356
|
|
|
357
|
-
public pushValue(value: T) {
|
|
357
|
+
public pushValue(value: T): void {
|
|
358
358
|
this.pushCore(Promise.resolve({ done: false, value }));
|
|
359
359
|
}
|
|
360
360
|
|
|
361
|
-
public pushError(error: any) {
|
|
361
|
+
public pushError(error: any): void {
|
|
362
362
|
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
|
|
363
363
|
this.pushCore(Promise.reject(error));
|
|
364
364
|
this.done = true;
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
public pushDone() {
|
|
367
|
+
public pushDone(): void {
|
|
368
368
|
this.pushCore(Promise.resolve({ done: true }));
|
|
369
369
|
this.done = true;
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
-
protected pushCore(value: Promise<IStreamResult<T>>) {
|
|
372
|
+
protected pushCore(value: Promise<IStreamResult<T>>): void {
|
|
373
373
|
assert(!this.done, 0x112 /* "cannot push onto queue if done" */);
|
|
374
374
|
if (this.deferred) {
|
|
375
375
|
assert(this.queue.length === 0, 0x113 /* "deferred queue should be empty" */);
|
|
@@ -396,7 +396,7 @@ const waitForOnline = async (): Promise<void> => {
|
|
|
396
396
|
// Only wait if we have a strong signal that we're offline - otherwise assume we're online.
|
|
397
397
|
if (globalThis.navigator?.onLine === false && globalThis.addEventListener !== undefined) {
|
|
398
398
|
return new Promise<void>((resolve) => {
|
|
399
|
-
const resolveAndRemoveListener = () => {
|
|
399
|
+
const resolveAndRemoveListener = (): void => {
|
|
400
400
|
resolve();
|
|
401
401
|
globalThis.removeEventListener("online", resolveAndRemoveListener);
|
|
402
402
|
};
|
|
@@ -614,7 +614,7 @@ export function requestOps(
|
|
|
614
614
|
// waits (up to 10 seconds) and fetches (can take infinite amount of time).
|
|
615
615
|
// While every such case should be improved and take into account signal (and thus cancel immediately),
|
|
616
616
|
// it is beneficial to have catch-all
|
|
617
|
-
const listener = (event: Event) => {
|
|
617
|
+
const listener = (event: Event): void => {
|
|
618
618
|
manager.cancel();
|
|
619
619
|
};
|
|
620
620
|
if (signal !== undefined) {
|
|
@@ -45,7 +45,7 @@ export class PrefetchDocumentStorageService extends DocumentStorageServiceProxy
|
|
|
45
45
|
public async readBlob(blobId: string): Promise<ArrayBufferLike> {
|
|
46
46
|
return this.cachedRead(blobId);
|
|
47
47
|
}
|
|
48
|
-
public stopPrefetch() {
|
|
48
|
+
public stopPrefetch(): void {
|
|
49
49
|
this.prefetchEnabled = false;
|
|
50
50
|
this.prefetchCache.clear();
|
|
51
51
|
}
|
|
@@ -71,7 +71,7 @@ export class PrefetchDocumentStorageService extends DocumentStorageServiceProxy
|
|
|
71
71
|
return this.internalStorageService.readBlob(blobId);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
private prefetchTree(tree: ISnapshotTree) {
|
|
74
|
+
private prefetchTree(tree: ISnapshotTree): void {
|
|
75
75
|
const secondary: string[] = [];
|
|
76
76
|
this.prefetchTreeCore(tree, secondary);
|
|
77
77
|
|
|
@@ -81,7 +81,7 @@ export class PrefetchDocumentStorageService extends DocumentStorageServiceProxy
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
private prefetchTreeCore(tree: ISnapshotTree, secondary: string[]) {
|
|
84
|
+
private prefetchTreeCore(tree: ISnapshotTree, secondary: string[]): void {
|
|
85
85
|
for (const [blobKey, blob] of Object.entries(tree.blobs)) {
|
|
86
86
|
if (blobKey.startsWith(".") || blobKey === "header" || blobKey.startsWith("quorum")) {
|
|
87
87
|
if (blob !== null) {
|
package/src/rateLimiter.ts
CHANGED
|
@@ -20,7 +20,7 @@ export class RateLimiter {
|
|
|
20
20
|
|
|
21
21
|
// Run when one of the tasks finished running.
|
|
22
22
|
// Release next task if we have one, or allow more tasks to run in future.
|
|
23
|
-
protected readonly release = () => {
|
|
23
|
+
protected readonly release = (): void => {
|
|
24
24
|
const task = this.tasks.shift();
|
|
25
25
|
if (task !== undefined) {
|
|
26
26
|
return task();
|
|
@@ -28,7 +28,7 @@ export class RateLimiter {
|
|
|
28
28
|
this.maxRequests++;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
protected async acquire() {
|
|
31
|
+
protected async acquire(): Promise<void> {
|
|
32
32
|
if (this.maxRequests > 0) {
|
|
33
33
|
this.maxRequests--;
|
|
34
34
|
return;
|
|
@@ -39,7 +39,7 @@ export class RateLimiter {
|
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
public async schedule<T>(work: () => Promise<T>) {
|
|
42
|
+
public async schedule<T>(work: () => Promise<T>): Promise<T> {
|
|
43
43
|
await this.acquire();
|
|
44
44
|
return work().finally(this.release);
|
|
45
45
|
}
|