@fluidframework/local-driver 2.90.0 → 2.92.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/auth.d.ts +2 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +2 -2
- package/dist/auth.js.map +1 -1
- package/dist/legacy.d.ts +1 -1
- package/dist/localCreateDocument.d.ts +2 -2
- package/dist/localCreateDocument.d.ts.map +1 -1
- package/dist/localCreateDocument.js.map +1 -1
- package/dist/localDeltaStorageService.d.ts +2 -2
- package/dist/localDeltaStorageService.d.ts.map +1 -1
- package/dist/localDeltaStorageService.js.map +1 -1
- package/dist/localDocumentDeltaConnection.d.ts +5 -4
- package/dist/localDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/localDocumentDeltaConnection.js.map +1 -1
- package/dist/localDocumentService.d.ts +5 -5
- package/dist/localDocumentService.d.ts.map +1 -1
- package/dist/localDocumentService.js.map +1 -1
- package/dist/localDocumentServiceFactory.d.ts +4 -4
- package/dist/localDocumentServiceFactory.d.ts.map +1 -1
- package/dist/localDocumentServiceFactory.js.map +1 -1
- package/dist/localDocumentStorageService.d.ts +4 -4
- package/dist/localDocumentStorageService.d.ts.map +1 -1
- package/dist/localDocumentStorageService.js +1 -1
- package/dist/localDocumentStorageService.js.map +1 -1
- package/dist/localResolver.d.ts +2 -2
- package/dist/localResolver.d.ts.map +1 -1
- package/dist/localResolver.js +3 -3
- package/dist/localResolver.js.map +1 -1
- package/dist/localSessionStorageDb.d.ts +2 -2
- package/dist/localSessionStorageDb.d.ts.map +1 -1
- package/dist/localSessionStorageDb.js +13 -13
- package/dist/localSessionStorageDb.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/public.d.ts +1 -1
- package/eslint.config.mts +14 -2
- package/internal.d.ts +1 -1
- package/legacy.d.ts +1 -1
- package/lib/auth.d.ts +2 -2
- package/lib/auth.d.ts.map +1 -1
- package/lib/auth.js +2 -2
- package/lib/auth.js.map +1 -1
- package/lib/legacy.d.ts +1 -1
- package/lib/localCreateDocument.d.ts +2 -2
- package/lib/localCreateDocument.d.ts.map +1 -1
- package/lib/localCreateDocument.js.map +1 -1
- package/lib/localDeltaStorageService.d.ts +2 -2
- package/lib/localDeltaStorageService.d.ts.map +1 -1
- package/lib/localDeltaStorageService.js.map +1 -1
- package/lib/localDocumentDeltaConnection.d.ts +5 -4
- package/lib/localDocumentDeltaConnection.d.ts.map +1 -1
- package/lib/localDocumentDeltaConnection.js +1 -1
- package/lib/localDocumentDeltaConnection.js.map +1 -1
- package/lib/localDocumentService.d.ts +5 -5
- package/lib/localDocumentService.d.ts.map +1 -1
- package/lib/localDocumentService.js.map +1 -1
- package/lib/localDocumentServiceFactory.d.ts +4 -4
- package/lib/localDocumentServiceFactory.d.ts.map +1 -1
- package/lib/localDocumentServiceFactory.js.map +1 -1
- package/lib/localDocumentStorageService.d.ts +4 -4
- package/lib/localDocumentStorageService.d.ts.map +1 -1
- package/lib/localDocumentStorageService.js +2 -2
- package/lib/localDocumentStorageService.js.map +1 -1
- package/lib/localResolver.d.ts +2 -2
- package/lib/localResolver.d.ts.map +1 -1
- package/lib/localResolver.js +4 -4
- package/lib/localResolver.js.map +1 -1
- package/lib/localSessionStorageDb.d.ts +2 -2
- package/lib/localSessionStorageDb.d.ts.map +1 -1
- package/lib/localSessionStorageDb.js +13 -13
- package/lib/localSessionStorageDb.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/public.d.ts +1 -1
- package/package.json +17 -17
- package/src/auth.ts +4 -4
- package/src/localCreateDocument.ts +3 -3
- package/src/localDeltaStorageService.ts +2 -2
- package/src/localDocumentDeltaConnection.ts +6 -9
- package/src/localDocumentService.ts +5 -5
- package/src/localDocumentServiceFactory.ts +5 -5
- package/src/localDocumentStorageService.ts +10 -10
- package/src/localResolver.ts +6 -10
- package/src/localSessionStorageDb.ts +13 -13
- package/src/packageVersion.ts +1 -1
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ISummaryHandle, ISummaryTree } from "@fluidframework/driver-definitions";
|
|
6
|
-
import { IDocumentStorageService, IDocumentStorageServicePolicies, IResolvedUrl,
|
|
7
|
-
import { ILocalDeltaConnectionServer } from "@fluidframework/server-local-server";
|
|
8
|
-
import { GitManager } from "@fluidframework/server-services-client";
|
|
5
|
+
import type { ISummaryHandle, ISummaryTree } from "@fluidframework/driver-definitions";
|
|
6
|
+
import type { ICreateBlobResponse, IDocumentStorageService, IDocumentStorageServicePolicies, IResolvedUrl, ISnapshot, ISnapshotFetchOptions, ISnapshotTreeEx, ISummaryContext, IVersion } from "@fluidframework/driver-definitions/internal";
|
|
7
|
+
import type { ILocalDeltaConnectionServer } from "@fluidframework/server-local-server";
|
|
8
|
+
import type { GitManager } from "@fluidframework/server-services-client";
|
|
9
9
|
/**
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/localDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"localDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/localDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvF,OAAO,KAAK,EACX,mBAAmB,EACnB,uBAAuB,EACvB,+BAA+B,EAC/B,YAAY,EACZ,SAAS,EACT,qBAAqB,EACrB,eAAe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,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO/D,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;YAI7D,uBAAuB;CAWrC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { IsoBuffer, Uint8ArrayToString, bufferToString, stringToBuffer, } from "@fluid-internal/client-utils";
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { buildGitTreeHierarchy } from "@fluidframework/protocol-base";
|
|
8
|
-
import { SummaryTreeUploadManager
|
|
8
|
+
import { SummaryTreeUploadManager } from "@fluidframework/server-services-client";
|
|
9
9
|
import { createDocument } from "./localCreateDocument.js";
|
|
10
10
|
const minTTLInSeconds = 24 * 60 * 60; // Same TTL as ODSP
|
|
11
11
|
/**
|
|
@@ -146,7 +146,7 @@ export class LocalDocumentStorageService {
|
|
|
146
146
|
const descendants = await Promise.all(Object.values(tree.trees).map(async (childTree) => {
|
|
147
147
|
return this.filterTreeByLoadingGroupIds(childTree, loadingGroupIds, ancestorGroupIdInLoadingGroup || groupIdInLoadingGroupIds, blobContents);
|
|
148
148
|
}));
|
|
149
|
-
const isAncestorOfDescendantsWithGroupId = descendants.some(
|
|
149
|
+
const isAncestorOfDescendantsWithGroupId = descendants.some(Boolean);
|
|
150
150
|
// We don't want to return prematurely as we still may have children that we want to keep.
|
|
151
151
|
if (groupIdInLoadingGroupIds ||
|
|
152
152
|
isChildOfAncestorWithGroupId ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localDocumentStorageService.js","sourceRoot":"","sources":["../src/localDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,cAAc,GACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAa7D,OAAO,EAAE,qBAAqB,EAAE,MAA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,wBAAwB,CAAC,gBAAgB,CACpD,OAAO,EACP,OAAO,CAAC,SAAS,IAAI,EAAE,EACvB,SAAS,CACT,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,IAAqB;QAC5C,MAAM,cAAc,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC,OAAO;aACjB,UAAU,CAAC,kBAAkB,CAAC,cAAc,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC;aAClE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,MAAsB;QAClD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACrC,CAAC;IAEO,KAAK,CAAC,uBAAuB,CACpC,YAAoB;QAEpB,OAAO,YAAY;YAClB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;gBAC1D,mEAAmE;gBACnE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;gBAC3B,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC;YACH,CAAC,CAAC,SAAS,CAAC;IACd,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIsoBuffer,\n\tUint8ArrayToString,\n\tbufferToString,\n\tstringToBuffer,\n} from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tIResolvedUrl,\n\ttype ISnapshot,\n\ttype ISnapshotFetchOptions,\n\tISummaryContext,\n\tICreateBlobResponse,\n\tISnapshotTreeEx,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { buildGitTreeHierarchy } from \"@fluidframework/protocol-base\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport {\n\tGitManager,\n\tISummaryUploadManager,\n\tSummaryTreeUploadManager,\n} from \"@fluidframework/server-services-client\";\n\nimport { createDocument } from \"./localCreateDocument.js\";\n\nconst minTTLInSeconds = 24 * 60 * 60; // Same TTL as ODSP\n/**\n * @internal\n */\nexport class LocalDocumentStorageService implements IDocumentStorageService {\n\t// The values of this cache is useless. We only need the keys. So we are always putting\n\t// empty strings as values.\n\tprotected readonly blobsShaCache = new Map<string, string>();\n\tprivate readonly summaryTreeUploadManager: ISummaryUploadManager;\n\n\tconstructor(\n\t\tprivate readonly id: string,\n\t\tprivate readonly manager: GitManager,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly localDeltaConnectionServer?: ILocalDeltaConnectionServer,\n\t\tprivate readonly resolvedUrl?: IResolvedUrl,\n\t) {\n\t\tthis.summaryTreeUploadManager = new SummaryTreeUploadManager(\n\t\t\tmanager,\n\t\t\tthis.blobsShaCache,\n\t\t\tthis.getPreviousFullSnapshot.bind(this),\n\t\t);\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ?? could change behavior for falsy values\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await this.manager.getCommits(id, count);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTreeEx | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// Non null asserting here because of the length check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\trequestVersion = versions[0]!;\n\t\t}\n\n\t\tconst rawTree = await this.manager.getTree(requestVersion.treeId);\n\t\tconst tree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tawait this.populateGroupId(tree);\n\t\treturn tree;\n\t}\n\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\tlet versionId = snapshotFetchOptions?.versionId;\n\t\tif (!versionId) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\tthrow new Error(\"No versions for the document!\");\n\t\t\t}\n\n\t\t\t// Non null asserting here because of the length check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tversionId = versions[0]!.treeId;\n\t\t}\n\t\tconst rawTree = await this.manager.getTree(versionId);\n\t\tconst snapshotTree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tconst groupIds = new Set<string>(snapshotFetchOptions?.loadingGroupIds ?? []);\n\t\t// TODO Why are we non null asserting here\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst attributesBlobId = snapshotTree.trees[\".protocol\"]!.blobs.attributes!;\n\t\t// Only populate contents for the blobs which are supposed to be returned.\n\t\tconst blobContents = new Map<string, ArrayBuffer>();\n\t\tconst attributesBlobData = await this.readBlob(attributesBlobId);\n\t\tif (groupIds.has(\"\") || groupIds.size === 0) {\n\t\t\t// If the root is in the groupIds, we don't need to filter the tree.\n\t\t\t// We can just strip the of all groupIds as in collect the blobIds so that we can\n\t\t\t// return blob contents only for those ids.\n\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(snapshotTree, groupIds, blobContents);\n\t\t} else {\n\t\t\tconst hasFoundTree = await this.filterTreeByLoadingGroupIds(\n\t\t\t\tsnapshotTree,\n\t\t\t\tgroupIds,\n\t\t\t\tfalse,\n\t\t\t\tblobContents,\n\t\t\t);\n\t\t\tassert(hasFoundTree, 0x8dd /* No tree found for the given groupIds */);\n\t\t}\n\n\t\tconst attributesString = IsoBuffer.from(attributesBlobData).toString(\"utf-8\");\n\t\tconst attributes = JSON.parse(attributesString);\n\t\tconst sequenceNumber: number = attributes.sequenceNumber ?? 0;\n\t\treturn {\n\t\t\tsnapshotTree,\n\t\t\tblobContents,\n\t\t\tops: [],\n\t\t\tsnapshotFormatV: 1,\n\t\t\tsequenceNumber,\n\t\t\tlatestSequenceNumber: undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Collect the blobIds to keep in the snapshot for ungrouped snapshot plus\n\t * any other loading groupId along with it.\n\t *\n\t * @param tree - The tree to evaluate for loading groupIds\n\t * @returns a tree that has trees with groupIds that are empty\n\t */\n\tprivate async collectBlobContentsForUngroupedSnapshot(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t): Promise<void> {\n\t\tconst groupId = await this.readGroupId(tree);\n\t\tif (groupId === undefined || loadingGroupIds.has(groupId)) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t\tawait Promise.all(\n\t\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(\n\t\t\t\t\t\tchildTree,\n\t\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\t\tblobContents,\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Named differently as the algorithm is a little more involved.\n\t *\n\t * We want to strip the tree if it has a groupId that is not in the loadingGroupIds or if it doesn't have a descendent or ancestor\n\t * that has a groupId that is in the loadingGroupIds.\n\t *\n\t * We keep the tree in the opposite case.\n\t *\n\t * @param tree - the tree to strip of any data that is not in the loadingGroupIds\n\t * @param loadingGroupIds - the set of groupIds that are being loaded\n\t * @param ancestorGroupIdInLoadingGroup - whether the ancestor of the tree has a groupId that is in the loadingGroupIds\n\t * @returns whether or not it or descendant has a groupId that is in the loadingGroupIds\n\t */\n\tprivate async filterTreeByLoadingGroupIds(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tancestorGroupIdInLoadingGroup: boolean,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t): Promise<boolean> {\n\t\tassert(loadingGroupIds.size > 0, 0x8de /* loadingGroupIds should not be empty */);\n\t\tconst groupId = await this.readGroupId(tree);\n\n\t\t// Strip the tree if it has a groupId and it is not in the loadingGroupIds\n\t\t// This is an optimization here as we have other reasons to keep the tree.\n\t\tconst noGroupIdInLoadingGroupIds = groupId !== undefined && !loadingGroupIds.has(groupId);\n\t\tif (noGroupIdInLoadingGroupIds) {\n\t\t\tthis.stripTree(tree, groupId);\n\t\t\treturn false;\n\t\t}\n\n\t\t// Keep tree if it has a groupId and it is in the loadingGroupIds\n\t\tconst groupIdInLoadingGroupIds = groupId !== undefined && loadingGroupIds.has(groupId);\n\n\t\t// Keep tree if it has an ancestor that has a groupId that is in loadingGroupIds and it doesn't have groupId\n\t\tconst isChildOfAncestorWithGroupId =\n\t\t\tancestorGroupIdInLoadingGroup && groupId === undefined;\n\n\t\t// Collect blobsIds so that we can return blob contents only for these blobs.\n\t\tif (groupIdInLoadingGroupIds || isChildOfAncestorWithGroupId) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t}\n\t\t// Keep tree if it has a child that has a groupId that is in loadingGroupIds\n\t\tconst descendants = await Promise.all<boolean>(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\treturn this.filterTreeByLoadingGroupIds(\n\t\t\t\t\tchildTree,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tancestorGroupIdInLoadingGroup || groupIdInLoadingGroupIds,\n\t\t\t\t\tblobContents,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t\tconst isAncestorOfDescendantsWithGroupId = descendants.some((keep) => keep);\n\n\t\t// We don't want to return prematurely as we still may have children that we want to keep.\n\t\tif (\n\t\t\tgroupIdInLoadingGroupIds ||\n\t\t\tisChildOfAncestorWithGroupId ||\n\t\t\tisAncestorOfDescendantsWithGroupId\n\t\t) {\n\t\t\t// Keep this tree node\n\t\t\treturn true;\n\t\t}\n\n\t\t// This means we have no groupId and none of our ancestors or descendants have a groupId in the loadingGroupIds\n\t\tthis.stripTree(tree, groupId);\n\t\treturn false;\n\t}\n\n\t// Takes all the blobs of a tree and puts it into the blobContents\n\tprivate async populateBlobContents(\n\t\ttree: ISnapshotTreeEx,\n\t\tblobContents: Map<string, ArrayBufferLike>,\n\t\tblobIdsToKeep: Set<string>,\n\t): Promise<void> {\n\t\tawait Promise.all(\n\t\t\tObject.entries(tree.blobs).map(async ([path, blobId]) => {\n\t\t\t\tif (blobIdsToKeep.has(blobId)) {\n\t\t\t\t\tconst content = await this.readBlob(blobId);\n\t\t\t\t\tblobContents.set(blobId, content);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateBlobContents(childTree, blobContents, blobIdsToKeep);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate async populateGroupId(tree: ISnapshotTreeEx): Promise<void> {\n\t\tawait this.readGroupId(tree);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateGroupId(childTree);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate stripTree(tree: ISnapshotTreeEx, groupId: string | undefined): void {\n\t\ttree.blobs = {};\n\t\ttree.groupId = groupId;\n\t\ttree.trees = {};\n\t}\n\n\tprivate async readGroupId(tree: ISnapshotTreeEx): Promise<string | undefined> {\n\t\tconst groupIdBlobId = tree.blobs[\".groupId\"];\n\t\tif (groupIdBlobId !== undefined) {\n\t\t\tconst groupIdBuffer = await this.readBlob(groupIdBlobId);\n\t\t\tconst groupId = bufferToString(groupIdBuffer, \"utf8\");\n\t\t\ttree.groupId = groupId;\n\t\t\tdelete tree.blobs[\".groupId\"];\n\t\t\treturn groupId;\n\t\t}\n\n\t\treturn tree.groupId;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst blob = await this.manager.getBlob(blobId);\n\t\tthis.blobsShaCache.set(blob.sha, \"\");\n\t\tconst bufferContent = stringToBuffer(blob.content, blob.encoding);\n\t\treturn bufferContent;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tif (context.referenceSequenceNumber === 0) {\n\t\t\tif (this.localDeltaConnectionServer === undefined || this.resolvedUrl === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Insufficient constructor parameters. An ILocalDeltaConnectionServer and IResolvedUrl required\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait createDocument(this.localDeltaConnectionServer, this.resolvedUrl, summary);\n\t\t\tconst version = await this.getVersions(this.id, 1);\n\t\t\t// TODO Why are we non null asserting here\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\treturn version[0]!.id;\n\t\t}\n\t\treturn this.summaryTreeUploadManager.writeSummaryTree(\n\t\t\tsummary,\n\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\"channel\",\n\t\t);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn this.manager\n\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t.then((r) => ({ id: r.sha, url: r.url, minTTLInSeconds }));\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"NOT IMPLEMENTED!\");\n\t}\n\n\tprivate async getPreviousFullSnapshot(\n\t\tparentHandle: string,\n\t): Promise<ISnapshotTreeEx | null | undefined> {\n\t\treturn parentHandle\n\t\t\t? this.getVersions(parentHandle, 1).then(async (versions) => {\n\t\t\t\t\t// Clear the cache as the getSnapshotTree call will fill the cache.\n\t\t\t\t\tthis.blobsShaCache.clear();\n\t\t\t\t\treturn this.getSnapshotTree(versions[0]);\n\t\t\t\t})\n\t\t\t: undefined;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"localDocumentStorageService.js","sourceRoot":"","sources":["../src/localDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,cAAc,GACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAa7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAMtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAElF,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,mBAAmB;AACzD;;GAEG;AACH,MAAM,OAAO,2BAA2B;IAMvC,YACkB,EAAU,EACV,OAAmB,EACpB,QAAyC,EACxC,0BAAwD,EACxD,WAA0B;QAJ1B,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAY;QACpB,aAAQ,GAAR,QAAQ,CAAiC;QACxC,+BAA0B,GAA1B,0BAA0B,CAA8B;QACxD,gBAAW,GAAX,WAAW,CAAe;QAV5C,uFAAuF;QACv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QAClD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACrC,CAAC;IAEO,KAAK,CAAC,uBAAuB,CACpC,YAAoB;QAEpB,OAAO,YAAY;YAClB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;gBAC1D,mEAAmE;gBACnE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;gBAC3B,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC;YACH,CAAC,CAAC,SAAS,CAAC;IACd,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIsoBuffer,\n\tUint8ArrayToString,\n\tbufferToString,\n\tstringToBuffer,\n} from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport type {\n\tICreateBlobResponse,\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tIResolvedUrl,\n\tISnapshot,\n\tISnapshotFetchOptions,\n\tISnapshotTreeEx,\n\tISummaryContext,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { buildGitTreeHierarchy } from \"@fluidframework/protocol-base\";\nimport type { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport type {\n\tGitManager,\n\tISummaryUploadManager,\n} from \"@fluidframework/server-services-client\";\nimport { SummaryTreeUploadManager } from \"@fluidframework/server-services-client\";\n\nimport { createDocument } from \"./localCreateDocument.js\";\n\nconst minTTLInSeconds = 24 * 60 * 60; // Same TTL as ODSP\n/**\n * @internal\n */\nexport class LocalDocumentStorageService implements IDocumentStorageService {\n\t// The values of this cache is useless. We only need the keys. So we are always putting\n\t// empty strings as values.\n\tprotected readonly blobsShaCache = new Map<string, string>();\n\tprivate readonly summaryTreeUploadManager: ISummaryUploadManager;\n\n\tconstructor(\n\t\tprivate readonly id: string,\n\t\tprivate readonly manager: GitManager,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly localDeltaConnectionServer?: ILocalDeltaConnectionServer,\n\t\tprivate readonly resolvedUrl?: IResolvedUrl,\n\t) {\n\t\tthis.summaryTreeUploadManager = new SummaryTreeUploadManager(\n\t\t\tmanager,\n\t\t\tthis.blobsShaCache,\n\t\t\tthis.getPreviousFullSnapshot.bind(this),\n\t\t);\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ?? could change behavior for falsy values\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await this.manager.getCommits(id, count);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTreeEx | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// Non null asserting here because of the length check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\trequestVersion = versions[0]!;\n\t\t}\n\n\t\tconst rawTree = await this.manager.getTree(requestVersion.treeId);\n\t\tconst tree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tawait this.populateGroupId(tree);\n\t\treturn tree;\n\t}\n\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\tlet versionId = snapshotFetchOptions?.versionId;\n\t\tif (!versionId) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\tthrow new Error(\"No versions for the document!\");\n\t\t\t}\n\n\t\t\t// Non null asserting here because of the length check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tversionId = versions[0]!.treeId;\n\t\t}\n\t\tconst rawTree = await this.manager.getTree(versionId);\n\t\tconst snapshotTree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tconst groupIds = new Set<string>(snapshotFetchOptions?.loadingGroupIds ?? []);\n\t\t// TODO Why are we non null asserting here\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst attributesBlobId = snapshotTree.trees[\".protocol\"]!.blobs.attributes!;\n\t\t// Only populate contents for the blobs which are supposed to be returned.\n\t\tconst blobContents = new Map<string, ArrayBuffer>();\n\t\tconst attributesBlobData = await this.readBlob(attributesBlobId);\n\t\tif (groupIds.has(\"\") || groupIds.size === 0) {\n\t\t\t// If the root is in the groupIds, we don't need to filter the tree.\n\t\t\t// We can just strip the of all groupIds as in collect the blobIds so that we can\n\t\t\t// return blob contents only for those ids.\n\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(snapshotTree, groupIds, blobContents);\n\t\t} else {\n\t\t\tconst hasFoundTree = await this.filterTreeByLoadingGroupIds(\n\t\t\t\tsnapshotTree,\n\t\t\t\tgroupIds,\n\t\t\t\tfalse,\n\t\t\t\tblobContents,\n\t\t\t);\n\t\t\tassert(hasFoundTree, 0x8dd /* No tree found for the given groupIds */);\n\t\t}\n\n\t\tconst attributesString = IsoBuffer.from(attributesBlobData).toString(\"utf-8\");\n\t\tconst attributes = JSON.parse(attributesString);\n\t\tconst sequenceNumber: number = attributes.sequenceNumber ?? 0;\n\t\treturn {\n\t\t\tsnapshotTree,\n\t\t\tblobContents,\n\t\t\tops: [],\n\t\t\tsnapshotFormatV: 1,\n\t\t\tsequenceNumber,\n\t\t\tlatestSequenceNumber: undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Collect the blobIds to keep in the snapshot for ungrouped snapshot plus\n\t * any other loading groupId along with it.\n\t *\n\t * @param tree - The tree to evaluate for loading groupIds\n\t * @returns a tree that has trees with groupIds that are empty\n\t */\n\tprivate async collectBlobContentsForUngroupedSnapshot(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t): Promise<void> {\n\t\tconst groupId = await this.readGroupId(tree);\n\t\tif (groupId === undefined || loadingGroupIds.has(groupId)) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t\tawait Promise.all(\n\t\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(\n\t\t\t\t\t\tchildTree,\n\t\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\t\tblobContents,\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Named differently as the algorithm is a little more involved.\n\t *\n\t * We want to strip the tree if it has a groupId that is not in the loadingGroupIds or if it doesn't have a descendent or ancestor\n\t * that has a groupId that is in the loadingGroupIds.\n\t *\n\t * We keep the tree in the opposite case.\n\t *\n\t * @param tree - the tree to strip of any data that is not in the loadingGroupIds\n\t * @param loadingGroupIds - the set of groupIds that are being loaded\n\t * @param ancestorGroupIdInLoadingGroup - whether the ancestor of the tree has a groupId that is in the loadingGroupIds\n\t * @returns whether or not it or descendant has a groupId that is in the loadingGroupIds\n\t */\n\tprivate async filterTreeByLoadingGroupIds(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tancestorGroupIdInLoadingGroup: boolean,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t): Promise<boolean> {\n\t\tassert(loadingGroupIds.size > 0, 0x8de /* loadingGroupIds should not be empty */);\n\t\tconst groupId = await this.readGroupId(tree);\n\n\t\t// Strip the tree if it has a groupId and it is not in the loadingGroupIds\n\t\t// This is an optimization here as we have other reasons to keep the tree.\n\t\tconst noGroupIdInLoadingGroupIds = groupId !== undefined && !loadingGroupIds.has(groupId);\n\t\tif (noGroupIdInLoadingGroupIds) {\n\t\t\tthis.stripTree(tree, groupId);\n\t\t\treturn false;\n\t\t}\n\n\t\t// Keep tree if it has a groupId and it is in the loadingGroupIds\n\t\tconst groupIdInLoadingGroupIds = groupId !== undefined && loadingGroupIds.has(groupId);\n\n\t\t// Keep tree if it has an ancestor that has a groupId that is in loadingGroupIds and it doesn't have groupId\n\t\tconst isChildOfAncestorWithGroupId =\n\t\t\tancestorGroupIdInLoadingGroup && groupId === undefined;\n\n\t\t// Collect blobsIds so that we can return blob contents only for these blobs.\n\t\tif (groupIdInLoadingGroupIds || isChildOfAncestorWithGroupId) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t}\n\t\t// Keep tree if it has a child that has a groupId that is in loadingGroupIds\n\t\tconst descendants = await Promise.all<boolean>(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\treturn this.filterTreeByLoadingGroupIds(\n\t\t\t\t\tchildTree,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tancestorGroupIdInLoadingGroup || groupIdInLoadingGroupIds,\n\t\t\t\t\tblobContents,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t\tconst isAncestorOfDescendantsWithGroupId = descendants.some(Boolean);\n\n\t\t// We don't want to return prematurely as we still may have children that we want to keep.\n\t\tif (\n\t\t\tgroupIdInLoadingGroupIds ||\n\t\t\tisChildOfAncestorWithGroupId ||\n\t\t\tisAncestorOfDescendantsWithGroupId\n\t\t) {\n\t\t\t// Keep this tree node\n\t\t\treturn true;\n\t\t}\n\n\t\t// This means we have no groupId and none of our ancestors or descendants have a groupId in the loadingGroupIds\n\t\tthis.stripTree(tree, groupId);\n\t\treturn false;\n\t}\n\n\t// Takes all the blobs of a tree and puts it into the blobContents\n\tprivate async populateBlobContents(\n\t\ttree: ISnapshotTreeEx,\n\t\tblobContents: Map<string, ArrayBufferLike>,\n\t\tblobIdsToKeep: Set<string>,\n\t): Promise<void> {\n\t\tawait Promise.all(\n\t\t\tObject.entries(tree.blobs).map(async ([path, blobId]) => {\n\t\t\t\tif (blobIdsToKeep.has(blobId)) {\n\t\t\t\t\tconst content = await this.readBlob(blobId);\n\t\t\t\t\tblobContents.set(blobId, content);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateBlobContents(childTree, blobContents, blobIdsToKeep);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate async populateGroupId(tree: ISnapshotTreeEx): Promise<void> {\n\t\tawait this.readGroupId(tree);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateGroupId(childTree);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate stripTree(tree: ISnapshotTreeEx, groupId: string | undefined): void {\n\t\ttree.blobs = {};\n\t\ttree.groupId = groupId;\n\t\ttree.trees = {};\n\t}\n\n\tprivate async readGroupId(tree: ISnapshotTreeEx): Promise<string | undefined> {\n\t\tconst groupIdBlobId = tree.blobs[\".groupId\"];\n\t\tif (groupIdBlobId !== undefined) {\n\t\t\tconst groupIdBuffer = await this.readBlob(groupIdBlobId);\n\t\t\tconst groupId = bufferToString(groupIdBuffer, \"utf8\");\n\t\t\ttree.groupId = groupId;\n\t\t\tdelete tree.blobs[\".groupId\"];\n\t\t\treturn groupId;\n\t\t}\n\n\t\treturn tree.groupId;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst blob = await this.manager.getBlob(blobId);\n\t\tthis.blobsShaCache.set(blob.sha, \"\");\n\t\tconst bufferContent = stringToBuffer(blob.content, blob.encoding);\n\t\treturn bufferContent;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tif (context.referenceSequenceNumber === 0) {\n\t\t\tif (this.localDeltaConnectionServer === undefined || this.resolvedUrl === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Insufficient constructor parameters. An ILocalDeltaConnectionServer and IResolvedUrl required\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait createDocument(this.localDeltaConnectionServer, this.resolvedUrl, summary);\n\t\t\tconst version = await this.getVersions(this.id, 1);\n\t\t\t// TODO Why are we non null asserting here\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\treturn version[0]!.id;\n\t\t}\n\t\treturn this.summaryTreeUploadManager.writeSummaryTree(\n\t\t\tsummary,\n\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\"channel\",\n\t\t);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn this.manager\n\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t.then((r) => ({ id: r.sha, url: r.url, minTTLInSeconds }));\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"NOT IMPLEMENTED!\");\n\t}\n\n\tprivate async getPreviousFullSnapshot(\n\t\tparentHandle: string,\n\t): Promise<ISnapshotTreeEx | null | undefined> {\n\t\treturn parentHandle\n\t\t\t? this.getVersions(parentHandle, 1).then(async (versions) => {\n\t\t\t\t\t// Clear the cache as the getSnapshotTree call will fill the cache.\n\t\t\t\t\tthis.blobsShaCache.clear();\n\t\t\t\t\treturn this.getSnapshotTree(versions[0]);\n\t\t\t\t})\n\t\t\t: undefined;\n\t}\n}\n"]}
|
package/lib/localResolver.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IRequest } from "@fluidframework/core-interfaces";
|
|
6
|
-
import { IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions/internal";
|
|
5
|
+
import type { IRequest } from "@fluidframework/core-interfaces";
|
|
6
|
+
import type { IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions/internal";
|
|
7
7
|
/**
|
|
8
8
|
* Creates an {@link @fluidframework/core-interfaces#IRequest} for creating a new document with the local resolver.
|
|
9
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localResolver.d.ts","sourceRoot":"","sources":["../src/localResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"localResolver.d.ts","sourceRoot":"","sources":["../src/localResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAK9F;;;;GAIG;AACH,wBAAgB,mCAAmC,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAQhF;AAED;;;;GAIG;AACH,qBAAa,aAAc,YAAW,YAAY;IACjD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAc;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAc;;IAIvC;;;;;OAKG;IACU,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;IAsBjD,cAAc,CAC1B,WAAW,EAAE,YAAY,EACzB,WAAW,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC;IAoBX,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ;CAG3D"}
|
package/lib/localResolver.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
6
|
-
import { DriverHeader, ScopeType
|
|
6
|
+
import { DriverHeader, ScopeType } from "@fluidframework/driver-definitions/internal";
|
|
7
7
|
import { generateToken } from "./auth.js";
|
|
8
8
|
/**
|
|
9
9
|
* Creates an {@link @fluidframework/core-interfaces#IRequest} for creating a new document with the local resolver.
|
|
@@ -37,7 +37,7 @@ export class LocalResolver {
|
|
|
37
37
|
*/
|
|
38
38
|
async resolve(request) {
|
|
39
39
|
const parsedUrl = new URL(request.url);
|
|
40
|
-
const fullPath = `${parsedUrl.pathname.
|
|
40
|
+
const fullPath = `${parsedUrl.pathname.slice(1)}${parsedUrl.search}`;
|
|
41
41
|
// TODO Why are we non null asserting here
|
|
42
42
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
43
43
|
const documentId = fullPath.split("/")[0];
|
|
@@ -58,13 +58,13 @@ export class LocalResolver {
|
|
|
58
58
|
async getAbsoluteUrl(resolvedUrl, relativeUrl) {
|
|
59
59
|
let url = relativeUrl;
|
|
60
60
|
if (url.startsWith("/")) {
|
|
61
|
-
url = url.
|
|
61
|
+
url = url.slice(1);
|
|
62
62
|
}
|
|
63
63
|
const parsedUrl = new URL(resolvedUrl.url);
|
|
64
64
|
if (parsedUrl.pathname === null) {
|
|
65
65
|
throw new Error("Url should contain tenant and docId!!");
|
|
66
66
|
}
|
|
67
|
-
const
|
|
67
|
+
const documentId = parsedUrl.pathname.split("/")[2];
|
|
68
68
|
assert(!!documentId, 0x09a /* "'documentId' must be a defined, non-zero length string." */);
|
|
69
69
|
return url
|
|
70
70
|
? `http://localhost:3000/${documentId}/${url}`
|
package/lib/localResolver.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localResolver.js","sourceRoot":"","sources":["../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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IRequest } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport type { IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions/internal\";\nimport { DriverHeader, ScopeType } from \"@fluidframework/driver-definitions/internal\";\n\nimport { generateToken } from \"./auth.js\";\n\n/**\n * Creates an {@link @fluidframework/core-interfaces#IRequest} for creating a new document with the local resolver.\n *\n * @legacy @beta\n */\nexport function createLocalResolverCreateNewRequest(documentId: string): IRequest {\n\tconst createNewRequest: IRequest = {\n\t\turl: `http://localhost:3000/${documentId}`,\n\t\theaders: {\n\t\t\t[DriverHeader.createNew]: true,\n\t\t},\n\t};\n\treturn createNewRequest;\n}\n\n/**\n * Resolves URLs by providing fake URLs which succeed with the other\n * related local classes.\n * @legacy @beta\n */\nexport class LocalResolver implements IUrlResolver {\n\tprivate readonly tenantId = \"tenantId\";\n\tprivate readonly tokenKey = \"tokenKey\";\n\n\tconstructor() {}\n\n\t/**\n\t * Resolves URL requests by providing fake URLs with an actually generated\n\t * token from constant test strings. The root of the URL is fake, but the\n\t * remaining relative URL can still be parsed.\n\t * @param request - request to handle\n\t */\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl> {\n\t\tconst parsedUrl = new URL(request.url);\n\t\tconst fullPath = `${parsedUrl.pathname.slice(1)}${parsedUrl.search}`;\n\t\t// TODO Why are we non null asserting here\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst documentId = fullPath.split(\"/\")[0]!;\n\t\tconst scopes = [ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite];\n\t\tconst resolved: IResolvedUrl = {\n\t\t\tendpoints: {\n\t\t\t\tdeltaStorageUrl: `http://localhost:3000/deltas/${this.tenantId}/${documentId}`,\n\t\t\t\tordererUrl: \"http://localhost:3000\",\n\t\t\t\tstorageUrl: `http://localhost:3000/repos/${this.tenantId}`,\n\t\t\t},\n\t\t\tid: documentId,\n\t\t\ttokens: { jwt: generateToken(this.tenantId, documentId, this.tokenKey, scopes) },\n\t\t\ttype: \"fluid\",\n\t\t\turl: `https://localhost:3000/${this.tenantId}/${fullPath}`,\n\t\t};\n\n\t\treturn resolved;\n\t}\n\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t): Promise<string> {\n\t\tlet url = relativeUrl;\n\t\tif (url.startsWith(\"/\")) {\n\t\t\turl = url.slice(1);\n\t\t}\n\t\tconst parsedUrl = new URL(resolvedUrl.url);\n\t\tif (parsedUrl.pathname === null) {\n\t\t\tthrow new Error(\"Url should contain tenant and docId!!\");\n\t\t}\n\t\tconst documentId = parsedUrl.pathname.split(\"/\")[2];\n\t\tassert(\n\t\t\t!!documentId,\n\t\t\t0x09a /* \"'documentId' must be a defined, non-zero length string.\" */,\n\t\t);\n\n\t\treturn url\n\t\t\t? `http://localhost:3000/${documentId}/${url}`\n\t\t\t: `http://localhost:3000/${documentId}`;\n\t}\n\n\tpublic createCreateNewRequest(documentId: string): IRequest {\n\t\treturn createLocalResolverCreateNewRequest(documentId);\n\t}\n}\n"]}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { IDb } from "@fluidframework/server-services-core";
|
|
6
|
-
import { ITestDbFactory } from "@fluidframework/server-test-utils";
|
|
5
|
+
import type { IDb } from "@fluidframework/server-services-core";
|
|
6
|
+
import type { ITestDbFactory } from "@fluidframework/server-test-utils";
|
|
7
7
|
/**
|
|
8
8
|
* A database factory for testing that stores data in the browsers session storage
|
|
9
9
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localSessionStorageDb.d.ts","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAe,GAAG,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"localSessionStorageDb.d.ts","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAe,GAAG,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AA8SxE;;;GAGG;AACH,qBAAa,4BAA6B,YAAW,cAAc;IAClE,SAAgB,YAAY,EAAE,GAAG,CAA+B;IACnD,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC;CAGpC"}
|
|
@@ -39,17 +39,17 @@ class LocalSessionStorageCollection {
|
|
|
39
39
|
function getValueByKey(propertyBag, key) {
|
|
40
40
|
const keys = key.split(".");
|
|
41
41
|
let value = propertyBag;
|
|
42
|
-
|
|
42
|
+
for (const splitKey of keys) {
|
|
43
43
|
value = value[splitKey];
|
|
44
|
-
}
|
|
44
|
+
}
|
|
45
45
|
return value;
|
|
46
46
|
}
|
|
47
47
|
// getting keys of the query we are trying to find
|
|
48
48
|
const queryKeys = Object.keys(query);
|
|
49
49
|
let filteredCollection = this.getAllInternal();
|
|
50
|
-
|
|
50
|
+
for (const key of queryKeys) {
|
|
51
51
|
if (!query[key]) {
|
|
52
|
-
|
|
52
|
+
continue;
|
|
53
53
|
}
|
|
54
54
|
if (query[key].$gt > 0 || query[key].$lt > 0) {
|
|
55
55
|
if (query[key].$gt > 0) {
|
|
@@ -62,7 +62,7 @@ class LocalSessionStorageCollection {
|
|
|
62
62
|
else {
|
|
63
63
|
filteredCollection = filteredCollection.filter((value) => getValueByKey(value, key) === query[key]);
|
|
64
64
|
}
|
|
65
|
-
}
|
|
65
|
+
}
|
|
66
66
|
if (sort && Object.keys(sort).length === 1) {
|
|
67
67
|
function compare(a, b) {
|
|
68
68
|
// Non null asserting here because of the length check above
|
|
@@ -99,15 +99,15 @@ class LocalSessionStorageCollection {
|
|
|
99
99
|
*/
|
|
100
100
|
async update(query, set, addToSet) {
|
|
101
101
|
const value = this.findOneInternal(query);
|
|
102
|
-
if (
|
|
103
|
-
throw new Error("Not found");
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
102
|
+
if (value) {
|
|
106
103
|
for (const key of Object.keys(set)) {
|
|
107
104
|
value[key] = set[key];
|
|
108
105
|
}
|
|
109
106
|
this.insertInternal(value);
|
|
110
107
|
}
|
|
108
|
+
else {
|
|
109
|
+
throw new Error("Not found");
|
|
110
|
+
}
|
|
111
111
|
}
|
|
112
112
|
/**
|
|
113
113
|
* {@inheritDoc @fluidframework/server-services-core#ICollection.upsert}
|
|
@@ -117,15 +117,15 @@ class LocalSessionStorageCollection {
|
|
|
117
117
|
*/
|
|
118
118
|
async upsert(query, set, addToSet) {
|
|
119
119
|
const value = this.findOneInternal(query);
|
|
120
|
-
if (
|
|
121
|
-
this.insertInternal(set);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
120
|
+
if (value) {
|
|
124
121
|
for (const key of Object.keys(set)) {
|
|
125
122
|
value[key] = set[key];
|
|
126
123
|
}
|
|
127
124
|
this.insertInternal(value);
|
|
128
125
|
}
|
|
126
|
+
else {
|
|
127
|
+
this.insertInternal(set);
|
|
128
|
+
}
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
131
131
|
* {@inheritDoc @fluidframework/server-services-core#ICollection.insertOne}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localSessionStorageDb.js","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG5D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC;;;GAGG;AACH,MAAM,6BAA6B;IAClC;;OAEG;IACH,YAA6B,cAAsB;QAAtB,mBAAc,GAAd,cAAc,CAAQ;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GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,6BAA6B,CAAI,IAAI,CAAC,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAqC,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,IAAY;QACvC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACb,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,OAAO,4BAA4B;IAAzC;QACiB,iBAAY,GAAQ,IAAI,qBAAqB,EAAE,CAAC;IAIjE,CAAC;IAHO,KAAK,CAAC,OAAO;QACnB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"@fluid-internal/client-utils\";\nimport { ICollection, IDb } from \"@fluidframework/server-services-core\";\nimport { ITestDbFactory } from \"@fluidframework/server-test-utils\";\nimport { v4 as uuid } from \"uuid\";\n\n/**\n * A collection for local session storage, where data is stored in the browser\n * Functions include database operations such as queries, insertion and update.\n */\nclass LocalSessionStorageCollection<T> implements ICollection<T> {\n\t/**\n\t * @param collectionName - data type of the collection, e.g. blobs, deltas, trees, etc.\n\t */\n\tconstructor(private readonly collectionName: string) {}\n\n\tpublic aggregate(pipeline: any, options?: any): any {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\n\tpublic async updateMany(filter: any, set: any, addToSet: any): Promise<void> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async distinct(key: any, query: any): Promise<any> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async findAndUpdate(query: any, value: T): Promise<{ value: T; existing: boolean }> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.find}\n\t */\n\t/*\n\t * Each query key consists of several keys separated by '.' e.g: \"operation.sequenceNumber\".\n\t * The hierarchical syntax allows finding nested key patterns.\n\t */\n\tpublic async find(query: any, sort: any): Promise<any[]> {\n\t\t// split the keys and get the corresponding value\n\t\tfunction getValueByKey(propertyBag, key: string): any {\n\t\t\tconst keys = key.split(\".\");\n\t\t\tlet value = propertyBag;\n\t\t\tkeys.forEach((splitKey) => {\n\t\t\t\tvalue = value[splitKey];\n\t\t\t});\n\t\t\treturn value;\n\t\t}\n\n\t\t// getting keys of the query we are trying to find\n\t\tconst queryKeys = Object.keys(query);\n\t\tlet filteredCollection = this.getAllInternal();\n\t\tqueryKeys.forEach((key) => {\n\t\t\tif (!query[key]) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (query[key].$gt > 0 || query[key].$lt > 0) {\n\t\t\t\tif (query[key].$gt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) > query[key].$gt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (query[key].$lt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) < query[key].$lt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t(value) => getValueByKey(value, key) === query[key],\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tif (sort && Object.keys(sort).length === 1) {\n\t\t\tfunction compare(a, b): number {\n\t\t\t\t// Non null asserting here because of the length check above\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst sortKey = Object.keys(sort)[0]!;\n\t\t\t\treturn sort[sortKey] === 1\n\t\t\t\t\t? getValueByKey(a, sortKey) - getValueByKey(b, sortKey)\n\t\t\t\t\t: getValueByKey(b, sortKey) - getValueByKey(a, sortKey);\n\t\t\t}\n\n\t\t\tfilteredCollection = filteredCollection.sort(compare);\n\t\t}\n\t\treturn filteredCollection;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findAll}\n\t */\n\tpublic async findAll(): Promise<any[]> {\n\t\treturn this.getAllInternal();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOne}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async findOne(query: any): Promise<any> {\n\t\treturn this.findOneInternal(query);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.update}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async update(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (!value) {\n\t\t\tthrow new Error(\"Not found\");\n\t\t} else {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.upsert}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async upsert(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (!value) {\n\t\t\tthis.insertInternal(set);\n\t\t} else {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertOne}\n\t */\n\t/*\n\t * Value is expected to have a member \"_id\" which is a string used to search in the database.\n\t */\n\tpublic async insertOne(value: any): Promise<any> {\n\t\tconst presentVal = this.findOneInternal(value);\n\t\t// Only raise error when the object is present and the value is not equal.\n\t\tif (presentVal) {\n\t\t\tif (JSON.stringify(presentVal) === JSON.stringify(value)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(\"Existing Object!!\");\n\t\t}\n\n\t\treturn this.insertInternal(value);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOrCreate}\n\t */\n\t/*\n\t * Value and query are expected to have a member \"_id\" which is a string used to search or insert in the database.\n\t */\n\tpublic async findOrCreate(\n\t\tquery: any,\n\t\tvalue: any,\n\t): Promise<{ value: any; existing: boolean }> {\n\t\tconst existing = this.findOneInternal(query);\n\t\tif (existing) {\n\t\t\treturn { value: existing, existing: true };\n\t\t}\n\t\tthis.insertInternal(value);\n\t\treturn { value, existing: false };\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertMany}\n\t */\n\t/*\n\t * Each element in values is expected to have a member \"_id\" which is a string used to insert in the database.\n\t */\n\tpublic async insertMany(values: any[], ordered: boolean): Promise<void> {\n\t\tthis.insertInternal(...values);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteOne}\n\t */\n\tpublic async deleteOne(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteMany}\n\t */\n\tpublic async deleteMany(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.createIndex}\n\t */\n\tpublic async createIndex(index: any, unique: boolean): Promise<void> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * Return all values in the database\n\t */\n\tprivate getAllInternal(): any[] {\n\t\tconst values: string[] = [];\n\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\tconst key = sessionStorage.key(i);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (key!.startsWith(this.collectionName)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tvalues.push(JSON.parse(sessionStorage.getItem(key!)!));\n\t\t\t}\n\t\t}\n\t\treturn values;\n\t}\n\n\t/**\n\t * Inserts values into the session storge.\n\t * Values are expected to have a member \"_id\" which is a unique id, otherwise will be assigned one\n\t *\n\t * @param values - data to insert to the database\n\t */\n\tprivate insertInternal(...values: any[]): void {\n\t\tfor (const value of values) {\n\t\t\tif (value) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy\n\t\t\t\tif (!value._id) {\n\t\t\t\t\tvalue._id = uuid();\n\t\t\t\t}\n\t\t\t\tsessionStorage.setItem(`${this.collectionName}-${value._id}`, JSON.stringify(value));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Finds the query in session storage and returns its value.\n\t * Returns null if query is not found.\n\t * Query is expected to have a member \"_id\" which is a unique id.\n\t *\n\t * @param query - what to find in the database\n\t */\n\tprivate findOneInternal(query: any): any {\n\t\tif (query._id) {\n\t\t\tconst json = sessionStorage.getItem(`${this.collectionName}-${query._id}`);\n\t\t\tif (json) {\n\t\t\t\treturn JSON.parse(json);\n\t\t\t}\n\t\t} else {\n\t\t\tconst queryKeys = Object.keys(query);\n\t\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\t\tconst ssKey = sessionStorage.key(i);\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tif (!ssKey!.startsWith(this.collectionName)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst value = JSON.parse(sessionStorage.getItem(ssKey!)!);\n\t\t\t\tlet foundMismatch = false;\n\t\t\t\tfor (const qk of queryKeys) {\n\t\t\t\t\tif (value[qk] !== query[qk]) {\n\t\t\t\t\t\tfoundMismatch = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!foundMismatch) {\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n}\n\n/**\n * A database for testing that stores data in the browsers session storage\n */\nclass LocalSessionStorageDb extends EventEmitter implements IDb {\n\tprivate readonly collections = new Map<string, LocalSessionStorageCollection<any>>();\n\tpublic async close(): Promise<void> {}\n\tpublic collection<T>(name: string): ICollection<T> {\n\t\tif (!this.collections.has(name)) {\n\t\t\tthis.collections.set(name, new LocalSessionStorageCollection<T>(name));\n\t\t}\n\t\treturn this.collections.get(name) as LocalSessionStorageCollection<T>;\n\t}\n\n\tpublic async dropCollection(name: string): Promise<boolean> {\n\t\tif (!this.collections.has(name)) {\n\t\t\treturn true;\n\t\t}\n\t\tthis.collections.delete(name);\n\t\treturn true;\n\t}\n}\n\n/**\n * A database factory for testing that stores data in the browsers session storage\n * @internal\n */\nexport class LocalSessionStorageDbFactory implements ITestDbFactory {\n\tpublic readonly testDatabase: IDb = new LocalSessionStorageDb();\n\tpublic async connect(): Promise<IDb> {\n\t\treturn this.testDatabase;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"localSessionStorageDb.js","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG5D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC;;;GAGG;AACH,MAAM,6BAA6B;IAClC;;OAEG;IACH,YAA6B,cAAsB;QAAtB,mBAAc,GAAd,cAAc,CAAQ;IAAG,CAAC;IAEhD,SAAS,CAAC,QAAa,EAAE,OAAa;QAC5C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CAAI,IAAI,CAAC,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAqC,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,IAAY;QACvC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACb,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,OAAO,4BAA4B;IAAzC;QACiB,iBAAY,GAAQ,IAAI,qBAAqB,EAAE,CAAC;IAIjE,CAAC;IAHO,KAAK,CAAC,OAAO;QACnB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"@fluid-internal/client-utils\";\nimport type { ICollection, IDb } from \"@fluidframework/server-services-core\";\nimport type { ITestDbFactory } from \"@fluidframework/server-test-utils\";\nimport { v4 as uuid } from \"uuid\";\n\n/**\n * A collection for local session storage, where data is stored in the browser\n * Functions include database operations such as queries, insertion and update.\n */\nclass LocalSessionStorageCollection<T> implements ICollection<T> {\n\t/**\n\t * @param collectionName - data type of the collection, e.g. blobs, deltas, trees, etc.\n\t */\n\tconstructor(private readonly collectionName: string) {}\n\n\tpublic aggregate(pipeline: any, options?: any): any {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\n\tpublic async updateMany(filter: any, set: any, addToSet: any): Promise<void> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async distinct(key: any, query: any): Promise<any> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async findAndUpdate(query: any, value: T): Promise<{ value: T; existing: boolean }> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.find}\n\t */\n\t/*\n\t * Each query key consists of several keys separated by '.' e.g: \"operation.sequenceNumber\".\n\t * The hierarchical syntax allows finding nested key patterns.\n\t */\n\tpublic async find(query: any, sort: any): Promise<any[]> {\n\t\t// split the keys and get the corresponding value\n\t\tfunction getValueByKey(propertyBag, key: string): any {\n\t\t\tconst keys = key.split(\".\");\n\t\t\tlet value = propertyBag;\n\t\t\tfor (const splitKey of keys) {\n\t\t\t\tvalue = value[splitKey];\n\t\t\t}\n\t\t\treturn value;\n\t\t}\n\n\t\t// getting keys of the query we are trying to find\n\t\tconst queryKeys = Object.keys(query);\n\t\tlet filteredCollection = this.getAllInternal();\n\t\tfor (const key of queryKeys) {\n\t\t\tif (!query[key]) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (query[key].$gt > 0 || query[key].$lt > 0) {\n\t\t\t\tif (query[key].$gt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) > query[key].$gt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (query[key].$lt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) < query[key].$lt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t(value) => getValueByKey(value, key) === query[key],\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (sort && Object.keys(sort).length === 1) {\n\t\t\tfunction compare(a, b): number {\n\t\t\t\t// Non null asserting here because of the length check above\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst sortKey = Object.keys(sort)[0]!;\n\t\t\t\treturn sort[sortKey] === 1\n\t\t\t\t\t? getValueByKey(a, sortKey) - getValueByKey(b, sortKey)\n\t\t\t\t\t: getValueByKey(b, sortKey) - getValueByKey(a, sortKey);\n\t\t\t}\n\n\t\t\tfilteredCollection = filteredCollection.sort(compare);\n\t\t}\n\t\treturn filteredCollection;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findAll}\n\t */\n\tpublic async findAll(): Promise<any[]> {\n\t\treturn this.getAllInternal();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOne}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async findOne(query: any): Promise<any> {\n\t\treturn this.findOneInternal(query);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.update}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async update(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (value) {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t} else {\n\t\t\tthrow new Error(\"Not found\");\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.upsert}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async upsert(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (value) {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t} else {\n\t\t\tthis.insertInternal(set);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertOne}\n\t */\n\t/*\n\t * Value is expected to have a member \"_id\" which is a string used to search in the database.\n\t */\n\tpublic async insertOne(value: any): Promise<any> {\n\t\tconst presentVal = this.findOneInternal(value);\n\t\t// Only raise error when the object is present and the value is not equal.\n\t\tif (presentVal) {\n\t\t\tif (JSON.stringify(presentVal) === JSON.stringify(value)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(\"Existing Object!!\");\n\t\t}\n\n\t\treturn this.insertInternal(value);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOrCreate}\n\t */\n\t/*\n\t * Value and query are expected to have a member \"_id\" which is a string used to search or insert in the database.\n\t */\n\tpublic async findOrCreate(\n\t\tquery: any,\n\t\tvalue: any,\n\t): Promise<{ value: any; existing: boolean }> {\n\t\tconst existing = this.findOneInternal(query);\n\t\tif (existing) {\n\t\t\treturn { value: existing, existing: true };\n\t\t}\n\t\tthis.insertInternal(value);\n\t\treturn { value, existing: false };\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertMany}\n\t */\n\t/*\n\t * Each element in values is expected to have a member \"_id\" which is a string used to insert in the database.\n\t */\n\tpublic async insertMany(values: any[], ordered: boolean): Promise<void> {\n\t\tthis.insertInternal(...values);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteOne}\n\t */\n\tpublic async deleteOne(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteMany}\n\t */\n\tpublic async deleteMany(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.createIndex}\n\t */\n\tpublic async createIndex(index: any, unique: boolean): Promise<void> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * Return all values in the database\n\t */\n\tprivate getAllInternal(): any[] {\n\t\tconst values: string[] = [];\n\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\tconst key = sessionStorage.key(i);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (key!.startsWith(this.collectionName)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tvalues.push(JSON.parse(sessionStorage.getItem(key!)!));\n\t\t\t}\n\t\t}\n\t\treturn values;\n\t}\n\n\t/**\n\t * Inserts values into the session storge.\n\t * Values are expected to have a member \"_id\" which is a unique id, otherwise will be assigned one\n\t *\n\t * @param values - data to insert to the database\n\t */\n\tprivate insertInternal(...values: any[]): void {\n\t\tfor (const value of values) {\n\t\t\tif (value) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ??= could change behavior if value is falsy\n\t\t\t\tif (!value._id) {\n\t\t\t\t\tvalue._id = uuid();\n\t\t\t\t}\n\t\t\t\tsessionStorage.setItem(`${this.collectionName}-${value._id}`, JSON.stringify(value));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Finds the query in session storage and returns its value.\n\t * Returns null if query is not found.\n\t * Query is expected to have a member \"_id\" which is a unique id.\n\t *\n\t * @param query - what to find in the database\n\t */\n\tprivate findOneInternal(query: any): any {\n\t\tif (query._id) {\n\t\t\tconst json = sessionStorage.getItem(`${this.collectionName}-${query._id}`);\n\t\t\tif (json) {\n\t\t\t\treturn JSON.parse(json);\n\t\t\t}\n\t\t} else {\n\t\t\tconst queryKeys = Object.keys(query);\n\t\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\t\tconst ssKey = sessionStorage.key(i);\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tif (!ssKey!.startsWith(this.collectionName)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst value = JSON.parse(sessionStorage.getItem(ssKey!)!);\n\t\t\t\tlet foundMismatch = false;\n\t\t\t\tfor (const qk of queryKeys) {\n\t\t\t\t\tif (value[qk] !== query[qk]) {\n\t\t\t\t\t\tfoundMismatch = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!foundMismatch) {\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n}\n\n/**\n * A database for testing that stores data in the browsers session storage\n */\nclass LocalSessionStorageDb extends EventEmitter implements IDb {\n\tprivate readonly collections = new Map<string, LocalSessionStorageCollection<any>>();\n\tpublic async close(): Promise<void> {}\n\tpublic collection<T>(name: string): ICollection<T> {\n\t\tif (!this.collections.has(name)) {\n\t\t\tthis.collections.set(name, new LocalSessionStorageCollection<T>(name));\n\t\t}\n\t\treturn this.collections.get(name) as LocalSessionStorageCollection<T>;\n\t}\n\n\tpublic async dropCollection(name: string): Promise<boolean> {\n\t\tif (!this.collections.has(name)) {\n\t\t\treturn true;\n\t\t}\n\t\tthis.collections.delete(name);\n\t\treturn true;\n\t}\n}\n\n/**\n * A database factory for testing that stores data in the browsers session storage\n * @internal\n */\nexport class LocalSessionStorageDbFactory implements ITestDbFactory {\n\tpublic readonly testDatabase: IDb = new LocalSessionStorageDb();\n\tpublic async connect(): Promise<IDb> {\n\t\treturn this.testDatabase;\n\t}\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/local-driver";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.92.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,8BAA8B,CAAC;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/local-driver\";\nexport const pkgVersion = \"2.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,8BAA8B,CAAC;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/local-driver\";\nexport const pkgVersion = \"2.92.0\";\n"]}
|
package/lib/public.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
/*
|
|
7
7
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
|
8
|
-
* Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
|
|
8
|
+
* Generated by "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat" in @fluid-tools/build-cli.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/local-driver",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.92.0",
|
|
4
4
|
"description": "Fluid local driver",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -71,31 +71,31 @@
|
|
|
71
71
|
"temp-directory": "nyc/.nyc_output"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@fluid-internal/client-utils": "~2.
|
|
75
|
-
"@fluidframework/core-interfaces": "~2.
|
|
76
|
-
"@fluidframework/core-utils": "~2.
|
|
77
|
-
"@fluidframework/driver-base": "~2.
|
|
78
|
-
"@fluidframework/driver-definitions": "~2.
|
|
79
|
-
"@fluidframework/driver-utils": "~2.
|
|
74
|
+
"@fluid-internal/client-utils": "~2.92.0",
|
|
75
|
+
"@fluidframework/core-interfaces": "~2.92.0",
|
|
76
|
+
"@fluidframework/core-utils": "~2.92.0",
|
|
77
|
+
"@fluidframework/driver-base": "~2.92.0",
|
|
78
|
+
"@fluidframework/driver-definitions": "~2.92.0",
|
|
79
|
+
"@fluidframework/driver-utils": "~2.92.0",
|
|
80
80
|
"@fluidframework/protocol-base": "^7.0.0",
|
|
81
|
-
"@fluidframework/routerlicious-driver": "~2.
|
|
81
|
+
"@fluidframework/routerlicious-driver": "~2.92.0",
|
|
82
82
|
"@fluidframework/server-local-server": "^7.0.0",
|
|
83
83
|
"@fluidframework/server-services-client": "^7.0.0",
|
|
84
84
|
"@fluidframework/server-services-core": "^7.0.0",
|
|
85
85
|
"@fluidframework/server-test-utils": "^7.0.0",
|
|
86
|
-
"@fluidframework/telemetry-utils": "~2.
|
|
86
|
+
"@fluidframework/telemetry-utils": "~2.92.0",
|
|
87
87
|
"jsrsasign": "^11.0.0",
|
|
88
88
|
"uuid": "^11.1.0"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
92
|
-
"@biomejs/biome": "~
|
|
93
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
94
|
-
"@fluid-tools/build-cli": "^0.
|
|
92
|
+
"@biomejs/biome": "~2.4.5",
|
|
93
|
+
"@fluid-internal/mocha-test-setup": "~2.92.0",
|
|
94
|
+
"@fluid-tools/build-cli": "^0.64.0",
|
|
95
95
|
"@fluidframework/build-common": "^2.0.3",
|
|
96
|
-
"@fluidframework/build-tools": "^0.
|
|
97
|
-
"@fluidframework/eslint-config-fluid": "
|
|
98
|
-
"@fluidframework/local-driver-previous": "npm:@fluidframework/local-driver@2.
|
|
96
|
+
"@fluidframework/build-tools": "^0.64.0",
|
|
97
|
+
"@fluidframework/eslint-config-fluid": "^9.0.0",
|
|
98
|
+
"@fluidframework/local-driver-previous": "npm:@fluidframework/local-driver@2.91.0",
|
|
99
99
|
"@microsoft/api-extractor": "7.52.11",
|
|
100
100
|
"@types/jsrsasign": "^10.5.12",
|
|
101
101
|
"@types/mocha": "^10.0.10",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"mocha": "^11.7.5",
|
|
110
110
|
"mocha-multi-reporters": "^1.5.1",
|
|
111
111
|
"rimraf": "^6.1.3",
|
|
112
|
-
"socket.io-client": "
|
|
112
|
+
"socket.io-client": "^4.8.3",
|
|
113
113
|
"typescript": "~5.4.5"
|
|
114
114
|
},
|
|
115
115
|
"typeValidation": {
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
},
|
|
119
119
|
"scripts": {
|
|
120
120
|
"api": "fluid-build . --task api",
|
|
121
|
-
"api-extractor:commonjs": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./dist",
|
|
121
|
+
"api-extractor:commonjs": "flub generate entrypoints --resolutionConditions require --outFileLegacyBeta legacy --outDir ./dist",
|
|
122
122
|
"api-extractor:esnext": "flub generate entrypoints --outFileLegacyBeta legacy --outDir ./lib --node10TypeCompat",
|
|
123
123
|
"build": "fluid-build . --task build",
|
|
124
124
|
"build:api-reports": "concurrently \"npm:build:api-reports:*\"",
|
package/src/auth.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { IUser } from "@fluidframework/driver-definitions";
|
|
7
|
-
import { ITokenClaims, ScopeType } from "@fluidframework/driver-definitions/internal";
|
|
6
|
+
import type { IUser } from "@fluidframework/driver-definitions";
|
|
7
|
+
import type { ITokenClaims, ScopeType } from "@fluidframework/driver-definitions/internal";
|
|
8
8
|
import { KJUR as jsrsasign } from "jsrsasign";
|
|
9
9
|
import { v4 as uuid } from "uuid";
|
|
10
10
|
|
|
@@ -28,7 +28,7 @@ export function generateToken(
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
// Current time in seconds
|
|
31
|
-
const now = Math.round(
|
|
31
|
+
const now = Math.round(Date.now() / 1000);
|
|
32
32
|
|
|
33
33
|
const claims: ITokenClaims = {
|
|
34
34
|
documentId,
|
|
@@ -52,7 +52,7 @@ export function generateToken(
|
|
|
52
52
|
export function generateUser(): IUser {
|
|
53
53
|
const userId = uuid();
|
|
54
54
|
const match = /^([\da-f]{8})-([\da-f]{4})/.exec(userId);
|
|
55
|
-
const userName = match
|
|
55
|
+
const userName = match === null ? userId : match[0]; // Just use the first two segments of the (fake) userId as a fake name.
|
|
56
56
|
|
|
57
57
|
const randomUser = {
|
|
58
58
|
id: userId,
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { ISummaryTree } from "@fluidframework/driver-definitions";
|
|
7
|
-
import { IResolvedUrl } from "@fluidframework/driver-definitions/internal";
|
|
6
|
+
import type { ISummaryTree } from "@fluidframework/driver-definitions";
|
|
7
|
+
import type { IResolvedUrl } from "@fluidframework/driver-definitions/internal";
|
|
8
8
|
import {
|
|
9
9
|
getDocAttributesFromProtocolSummary,
|
|
10
10
|
getQuorumValuesFromProtocolSummary,
|
|
11
11
|
isCombinedAppAndProtocolSummary,
|
|
12
12
|
} from "@fluidframework/driver-utils/internal";
|
|
13
|
-
import { LocalDeltaConnectionServer } from "@fluidframework/server-local-server";
|
|
13
|
+
import type { LocalDeltaConnectionServer } from "@fluidframework/server-local-server";
|
|
14
14
|
import { defaultHash } from "@fluidframework/server-services-client";
|
|
15
15
|
|
|
16
16
|
export async function createDocument(
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import type {
|
|
7
7
|
IDocumentDeltaStorageService,
|
|
8
8
|
IStream,
|
|
9
9
|
ISequencedDocumentMessage,
|
|
10
10
|
} from "@fluidframework/driver-definitions/internal";
|
|
11
11
|
import { streamFromMessages } from "@fluidframework/driver-utils/internal";
|
|
12
|
-
import { IDatabaseManager } from "@fluidframework/server-services-core";
|
|
12
|
+
import type { IDatabaseManager } from "@fluidframework/server-services-core";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Provides access to the underlying delta storage on the server for local driver.
|
|
@@ -3,16 +3,13 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
6
|
+
import type { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { DocumentDeltaConnection } from "@fluidframework/driver-base/internal";
|
|
8
|
-
import { IClient } from "@fluidframework/driver-definitions";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from "@fluidframework/driver-definitions/internal";
|
|
14
|
-
import { LocalWebSocketServer } from "@fluidframework/server-local-server";
|
|
15
|
-
import { IWebSocketServer } from "@fluidframework/server-services-core";
|
|
8
|
+
import type { IClient } from "@fluidframework/driver-definitions";
|
|
9
|
+
import type { IConnect, IDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
10
|
+
import { NackErrorType } from "@fluidframework/driver-definitions/internal";
|
|
11
|
+
import type { LocalWebSocketServer } from "@fluidframework/server-local-server";
|
|
12
|
+
import type { IWebSocketServer } from "@fluidframework/server-services-core";
|
|
16
13
|
import { createChildLogger } from "@fluidframework/telemetry-utils/internal";
|
|
17
14
|
import type { Socket } from "socket.io-client";
|
|
18
15
|
|