@fluidframework/local-driver 2.0.0-internal.1.1.2 → 2.0.0-internal.1.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"localDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/localDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,YAAY,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EAAE,2BAA2B,EAA8B,MAAM,qCAAqC,CAAC;AAM9G,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAKnF;;GAEG;AACH,qBAAa,2BAA4B,YAAW,uBAAuB;IAUnE,OAAO,CAAC,QAAQ,CAAC,0BAA0B;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC;IAX1C,SAAgB,YAAY,iBAAiB;IAG7C,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAAwD;IAEpG;;OAEG;gBAEkB,0BAA0B,EAAE,2BAA2B,EACvD,QAAQ,CAAC,sCAA0B,EACnC,oBAAoB,CAAC,8BAAkB;IAE/C,eAAe,CACxB,gBAAgB,EAAE,YAAY,GAAG,SAAS,EAC1C,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IAqC5B;;;;OAIG;IACU,qBAAqB,CAC9B,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IA4B5B;;;;OAIG;I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AAC,EAAE,OAAO,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IA4B5B;;;;OAIG;IACI,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM;IAQlE;;;;;;OAMG;IACI,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,GAAG;CAOzF"}
@@ -26,7 +26,7 @@ class LocalDocumentServiceFactory {
26
26
  this.documentDeltaConnectionsMap = new Map();
27
27
  }
28
28
  async createContainer(createNewSummary, resolvedUrl, logger, clientIsSummarizer) {
29
- var _a, _b, _c;
29
+ var _a, _b, _c, _d, _e;
30
30
  (0, driver_utils_1.ensureFluidResolvedUrl)(resolvedUrl);
31
31
  if (createNewSummary === undefined) {
32
32
  throw new Error("Empty file summary creation isn't supported in this driver.");
@@ -47,7 +47,7 @@ class LocalDocumentServiceFactory {
47
47
  const documentAttributes = (0, driver_utils_1.getDocAttributesFromProtocolSummary)(protocolSummary);
48
48
  const quorumValues = (0, driver_utils_1.getQuorumValuesFromProtocolSummary)(protocolSummary);
49
49
  const sequenceNumber = documentAttributes.sequenceNumber;
50
- await documentStorage.createDocument(tenantId, id, appSummary, sequenceNumber, (_a = documentAttributes.term) !== null && _a !== void 0 ? _a : 1, server_services_client_1.defaultHash, (_b = resolvedUrl.endpoints.ordererUrl) !== null && _b !== void 0 ? _b : "", (_c = resolvedUrl.endpoints.storageUrl) !== null && _c !== void 0 ? _c : "", quorumValues, false);
50
+ await documentStorage.createDocument(tenantId, id, appSummary, sequenceNumber, (_a = documentAttributes.term) !== null && _a !== void 0 ? _a : 1, server_services_client_1.defaultHash, (_b = resolvedUrl.endpoints.ordererUrl) !== null && _b !== void 0 ? _b : "", (_c = resolvedUrl.endpoints.storageUrl) !== null && _c !== void 0 ? _c : "", (_e = (_d = resolvedUrl.endpoints.deltaStreamUrl) !== null && _d !== void 0 ? _d : resolvedUrl.endpoints.ordererUrl) !== null && _e !== void 0 ? _e : "", quorumValues, false);
51
51
  return this.createDocumentService(resolvedUrl, logger, clientIsSummarizer);
52
52
  }
53
53
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"localDocumentServiceFactory.js","sourceRoot":"","sources":["../src/localDocumentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAA4B;AAQ5B,+EAA4E;AAE5E,+DAIsC;AAEtC,mFAAqE;AAErE,iEAAoE;AAEpE;;GAEG;AACH,MAAa,2BAA2B;IAMpC;;OAEG;IACH,YACqB,0BAAuD,EACvD,QAAmC,EACnC,oBAAuC;QAFvC,+BAA0B,GAA1B,0BAA0B,CAA6B;QACvD,aAAQ,GAAR,QAAQ,CAA2B;QACnC,yBAAoB,GAApB,oBAAoB,CAAmB;QAX5C,iBAAY,GAAG,aAAa,CAAC;QAE7C,6CAA6C;QAC5B,gCAA2B,GAA8C,IAAI,GAAG,EAAE,CAAC;IAQpC,CAAC;IAE1D,KAAK,CAAC,eAAe,CACxB,gBAA0C,EAC1C,WAAyB,EACzB,MAA6B,EAC7B,kBAA4B;;QAE5B,IAAA,qCAAsB,EAAC,WAAW,CAAC,CAAC;QACpC,IAAI,gBAAgB,KAAK,SAAS,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;SAClF;QACD,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;QACnD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACpC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAC7C,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,CAAC,0BAA0B,EAAE;YAClC,MAAM,IAAI,KAAK,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,QAAQ,CAAE,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACpF,CAAC;CACJ;AAxHD,kEAwHC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport {\n IDocumentService,\n IDocumentServiceFactory,\n IDocumentServicePolicies,\n IResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport { DefaultTokenProvider } from \"@fluidframework/routerlicious-driver\";\nimport { ILocalDeltaConnectionServer, LocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport {\n ensureFluidResolvedUrl,\n getDocAttributesFromProtocolSummary,\n getQuorumValuesFromProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport { ISummaryTree, NackErrorType } from \"@fluidframework/protocol-definitions\";\nimport { defaultHash } from \"@fluidframework/server-services-client\";\nimport { LocalDocumentDeltaConnection } from \"./localDocumentDeltaConnection\";\nimport { createLocalDocumentService } from \"./localDocumentService\";\n\n/**\n * Implementation of document service factory for local use.\n */\nexport class LocalDocumentServiceFactory implements IDocumentServiceFactory {\n public readonly protocolName = \"fluid-test:\";\n\n // A map of clientId to LocalDocumentService.\n private readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection> = new Map();\n\n /**\n * @param localDeltaConnectionServer - delta connection server for ops\n */\n constructor(\n private readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,\n private readonly policies?: IDocumentServicePolicies,\n private readonly innerDocumentService?: IDocumentService) { }\n\n public async createContainer(\n createNewSummary: ISummaryTree | undefined,\n resolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n ensureFluidResolvedUrl(resolvedUrl);\n if (createNewSummary === undefined) {\n throw new Error(\"Empty file summary creation isn't supported in this driver.\");\n }\n const pathName = new URL(resolvedUrl.url).pathname;\n const pathArr = pathName.split(\"/\");\n const tenantId = pathArr[pathArr.length - 2];\n const id = pathArr[pathArr.length - 1];\n if (!this.localDeltaConnectionServer) {\n throw new Error(\"Provide the localDeltaConnectionServer!!\");\n }\n const documentStorage = (this.localDeltaConnectionServer as LocalDeltaConnectionServer).documentStorage;\n\n const protocolSummary = createNewSummary.tree[\".protocol\"] as ISummaryTree;\n const appSummary = createNewSummary.tree[\".app\"] as ISummaryTree;\n if (!(protocolSummary && appSummary)) {\n throw new Error(\"Protocol and App Summary required in the full summary\");\n }\n const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n const quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);\n const sequenceNumber = documentAttributes.sequenceNumber;\n await documentStorage.createDocument(\n tenantId,\n id,\n appSummary,\n sequenceNumber,\n documentAttributes.term ?? 1,\n defaultHash,\n resolvedUrl.endpoints.ordererUrl ?? \"\",\n resolvedUrl.endpoints.storageUrl ?? \"\",\n quorumValues,\n false,\n );\n return this.createDocumentService(resolvedUrl, logger, clientIsSummarizer);\n }\n\n /**\n * Creates and returns a document service for testing using the given resolved\n * URL for the tenant ID, document ID, and token.\n * @param resolvedUrl - resolved URL of document\n */\n public async createDocumentService(\n resolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n ensureFluidResolvedUrl(resolvedUrl);\n\n const parsedUrl = parse(resolvedUrl.url);\n const [, tenantId, documentId] = parsedUrl.path ? parsedUrl.path.split(\"/\") : [];\n if (!documentId || !tenantId) {\n throw new Error(`Couldn't parse resolved url. [documentId:${documentId}][tenantId:${tenantId}]`);\n }\n\n const fluidResolvedUrl = resolvedUrl;\n const jwtToken = fluidResolvedUrl.tokens.jwt;\n if (!jwtToken) {\n throw new Error(`Token was not provided.`);\n }\n\n const tokenProvider = new DefaultTokenProvider(jwtToken);\n\n return createLocalDocumentService(\n resolvedUrl,\n this.localDeltaConnectionServer,\n tokenProvider,\n tenantId,\n documentId,\n this.documentDeltaConnectionsMap,\n this.policies,\n this.innerDocumentService);\n }\n\n /**\n * Gets the document delta connection for the clientId and asks it to disconnect the client.\n * @param clientId - The ID of the client to be disconnected.\n * @param disconnectReason - The reason of the disconnection.\n */\n public disconnectClient(clientId: string, disconnectReason: string) {\n if (!this.documentDeltaConnectionsMap.has(clientId)) {\n throw new Error(`No client with the id: ${clientId}`);\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.documentDeltaConnectionsMap.get(clientId)!.disconnectClient(disconnectReason);\n }\n\n /**\n * Gets the document delta connection for the clientId and asks it to nack the client.\n * @param clientId - The ID of the client to be Nack'd.\n * @param code - An error code number that represents the error. It will be a valid HTTP error code.\n * @param type - Type of the Nack.\n * @param message - A message about the nack for debugging/logging/telemetry purposes.\n */\n public nackClient(clientId: string, code?: number, type?: NackErrorType, message?: any) {\n if (!this.documentDeltaConnectionsMap.has(clientId)) {\n throw new Error(`No client with the id: ${clientId}`);\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.documentDeltaConnectionsMap.get(clientId)!.nackClient(code, type, message);\n }\n}\n"]}
1
+ {"version":3,"file":"localDocumentServiceFactory.js","sourceRoot":"","sources":["../src/localDocumentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAA4B;AAQ5B,+EAA4E;AAE5E,+DAIsC;AAEtC,mFAAqE;AAErE,iEAAoE;AAEpE;;GAEG;AACH,MAAa,2BAA2B;IAMpC;;OAEG;IACH,YACqB,0BAAuD,EACvD,QAAmC,EACnC,oBAAuC;QAFvC,+BAA0B,GAA1B,0BAA0B,CAA6B;QACvD,aAAQ,GAAR,QAAQ,CAA2B;QACnC,yBAAoB,GAApB,oBAAoB,CAAmB;QAX5C,iBAAY,GAAG,aAAa,CAAC;QAE7C,6CAA6C;QAC5B,gCAA2B,GAA8C,IAAI,GAAG,EAAE,CAAC;IAQpC,CAAC;IAE1D,KAAK,CA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2BAA2B,EAChC,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACI,gBAAgB,CAAC,QAAgB,EAAE,gBAAwB;QAC9D,IAAI,CAAC,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YACjD,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;SACzD;QACD,oEAAoE;QACpE,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACvF,CAAC;IAED;;;;;;OAMG;IACI,UAAU,CAAC,QAAgB,EAAE,IAAa,EAAE,IAAoB,EAAE,OAAa;QAClF,IAAI,CAAC,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YACjD,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;SACzD;QACD,oEAAoE;QACpE,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACpF,CAAC;CACJ;AAzHD,kEAyHC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport {\n IDocumentService,\n IDocumentServiceFactory,\n IDocumentServicePolicies,\n IResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport { DefaultTokenProvider } from \"@fluidframework/routerlicious-driver\";\nimport { ILocalDeltaConnectionServer, LocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport {\n ensureFluidResolvedUrl,\n getDocAttributesFromProtocolSummary,\n getQuorumValuesFromProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport { ISummaryTree, NackErrorType } from \"@fluidframework/protocol-definitions\";\nimport { defaultHash } from \"@fluidframework/server-services-client\";\nimport { LocalDocumentDeltaConnection } from \"./localDocumentDeltaConnection\";\nimport { createLocalDocumentService } from \"./localDocumentService\";\n\n/**\n * Implementation of document service factory for local use.\n */\nexport class LocalDocumentServiceFactory implements IDocumentServiceFactory {\n public readonly protocolName = \"fluid-test:\";\n\n // A map of clientId to LocalDocumentService.\n private readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection> = new Map();\n\n /**\n * @param localDeltaConnectionServer - delta connection server for ops\n */\n constructor(\n private readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,\n private readonly policies?: IDocumentServicePolicies,\n private readonly innerDocumentService?: IDocumentService) { }\n\n public async createContainer(\n createNewSummary: ISummaryTree | undefined,\n resolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n ensureFluidResolvedUrl(resolvedUrl);\n if (createNewSummary === undefined) {\n throw new Error(\"Empty file summary creation isn't supported in this driver.\");\n }\n const pathName = new URL(resolvedUrl.url).pathname;\n const pathArr = pathName.split(\"/\");\n const tenantId = pathArr[pathArr.length - 2];\n const id = pathArr[pathArr.length - 1];\n if (!this.localDeltaConnectionServer) {\n throw new Error(\"Provide the localDeltaConnectionServer!!\");\n }\n const documentStorage = (this.localDeltaConnectionServer as LocalDeltaConnectionServer).documentStorage;\n\n const protocolSummary = createNewSummary.tree[\".protocol\"] as ISummaryTree;\n const appSummary = createNewSummary.tree[\".app\"] as ISummaryTree;\n if (!(protocolSummary && appSummary)) {\n throw new Error(\"Protocol and App Summary required in the full summary\");\n }\n const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n const quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);\n const sequenceNumber = documentAttributes.sequenceNumber;\n await documentStorage.createDocument(\n tenantId,\n id,\n appSummary,\n sequenceNumber,\n documentAttributes.term ?? 1,\n defaultHash,\n resolvedUrl.endpoints.ordererUrl ?? \"\",\n resolvedUrl.endpoints.storageUrl ?? \"\",\n resolvedUrl.endpoints.deltaStreamUrl ?? resolvedUrl.endpoints.ordererUrl ?? \"\",\n quorumValues,\n false, /* enableDiscovery */\n );\n return this.createDocumentService(resolvedUrl, logger, clientIsSummarizer);\n }\n\n /**\n * Creates and returns a document service for testing using the given resolved\n * URL for the tenant ID, document ID, and token.\n * @param resolvedUrl - resolved URL of document\n */\n public async createDocumentService(\n resolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n ensureFluidResolvedUrl(resolvedUrl);\n\n const parsedUrl = parse(resolvedUrl.url);\n const [, tenantId, documentId] = parsedUrl.path ? parsedUrl.path.split(\"/\") : [];\n if (!documentId || !tenantId) {\n throw new Error(`Couldn't parse resolved url. [documentId:${documentId}][tenantId:${tenantId}]`);\n }\n\n const fluidResolvedUrl = resolvedUrl;\n const jwtToken = fluidResolvedUrl.tokens.jwt;\n if (!jwtToken) {\n throw new Error(`Token was not provided.`);\n }\n\n const tokenProvider = new DefaultTokenProvider(jwtToken);\n\n return createLocalDocumentService(\n resolvedUrl,\n this.localDeltaConnectionServer,\n tokenProvider,\n tenantId,\n documentId,\n this.documentDeltaConnectionsMap,\n this.policies,\n this.innerDocumentService);\n }\n\n /**\n * Gets the document delta connection for the clientId and asks it to disconnect the client.\n * @param clientId - The ID of the client to be disconnected.\n * @param disconnectReason - The reason of the disconnection.\n */\n public disconnectClient(clientId: string, disconnectReason: string) {\n if (!this.documentDeltaConnectionsMap.has(clientId)) {\n throw new Error(`No client with the id: ${clientId}`);\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.documentDeltaConnectionsMap.get(clientId)!.disconnectClient(disconnectReason);\n }\n\n /**\n * Gets the document delta connection for the clientId and asks it to nack the client.\n * @param clientId - The ID of the client to be Nack'd.\n * @param code - An error code number that represents the error. It will be a valid HTTP error code.\n * @param type - Type of the Nack.\n * @param message - A message about the nack for debugging/logging/telemetry purposes.\n */\n public nackClient(clientId: string, code?: number, type?: NackErrorType, message?: any) {\n if (!this.documentDeltaConnectionsMap.has(clientId)) {\n throw new Error(`No client with the id: ${clientId}`);\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.documentDeltaConnectionsMap.get(clientId)!.nackClient(code, type, message);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"localSessionStorageDb.d.ts","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":"AAKA,OAAO,EAAe,GAAG,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAuSnE;;GAEG;AACH,qBAAa,4BAA6B,YAAW,cAAc;IAC/D,SAAgB,YAAY,EAAE,GAAG,CAAC;gBACtB,SAAS,EAAE,MAAM;IAGhB,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC;CAGvC"}
1
+ {"version":3,"file":"localSessionStorageDb.d.ts","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":"AAKA,OAAO,EAAe,GAAG,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AA4SnE;;GAEG;AACH,qBAAa,4BAA6B,YAAW,cAAc;IAC/D,SAAgB,YAAY,EAAE,GAAG,CAAC;gBACtB,SAAS,EAAE,MAAM;IAGhB,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC;CAGvC"}
@@ -239,13 +239,17 @@ class LocalSessionStorageCollection {
239
239
  }
240
240
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
241
241
  const value = JSON.parse(sessionStorage.getItem(ssKey));
242
+ let foundMismatch = false;
242
243
  for (const qk of queryKeys) {
243
244
  if (value[qk] !== query[qk]) {
244
- continue;
245
+ foundMismatch = true;
246
+ break;
245
247
  }
246
248
  }
247
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
248
- return value;
249
+ if (!foundMismatch) {
250
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
251
+ return value;
252
+ }
249
253
  }
250
254
  }
251
255
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"localSessionStorageDb.js","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,mCAAsC;AAGtC,+BAAkC;AAElC;;;GAGG;AACH,MAAM,6BAA6B;IAE/B,YAAY,SAAS,EAAE,IAAI;QACvB,IAAI,CAAC,cAAc,GAAG,GAAG,SAAS,IAAI,IAAI,EAAE,CAAC;IACjD,CAAC;IAEM,SAAS,CAAC,QAAa,EAAE,OAAa;QACzC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC9C,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,MAAW,EAAE,GAAQ,EAAE,QAAa;QACxD,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC9C,CAAC;IACM,KAAK,CAAC,QAAQ,CAAC,GAAQ,EAAE,KAAU;QACtC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC9C,CAAC;IAED;;OAEG;IACH;;;OAGG;IACI,KAAK,CAAC,IAAI,CAAC,KAAU,EAAE,IAAS;QACnC,iDAAiD;QACjD,SAAS,aAAa,CAAC,WAAW,EAAE,GAAW;YAC3C,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC5B,IAAI,KAAK,GAAG,WAAW,CAAC;YACxB,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACtB,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;YAC5B,CAAC,CAAC,CAAC;YACH,+DAA+D;YAC/D,OAAO,KAAK,CAAC;QACjB,CAAC;QAED,kDAAkD;QAClD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,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IACM,UAAU,CAAI,IAAY;QAC7B,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC7B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,6BAA6B,CAAI,GAAG,IAAI,CAAC,SAAS,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;SAClG;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAqC,CAAC;IAC1E,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,IAAY;QACpC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC7B,OAAO,IAAI,CAAC;SACf;QACD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED;;GAEG;AACH,MAAa,4BAA4B;IAErC,YAAY,SAAiB;QACzB,IAAI,CAAC,YAAY,GAAG,IAAI,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC;IACM,KAAK,CAAC,OAAO;QAChB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;CACJ;AARD,oEAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { EventEmitter } from \"events\";\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 private readonly collectionName: string;\n constructor(namespace, name) {\n this.collectionName = `${namespace}-${name}`;\n }\n\n public aggregate(pipeline: any, options?: any): any {\n throw new Error(\"Method Not Implemented\");\n }\n\n public async updateMany(filter: any, set: any, addToSet: any): Promise<void> {\n throw new Error(\"Method Not Implemented\");\n }\n public async distinct(key: any, query: any): Promise<any> {\n throw new Error(\"Method Not Implemented\");\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.find}\n */\n /*\n * Each query key consists of several keys separated by '.' e.g: \"operation.sequenceNumber\".\n * The hierarchical syntax allows finding nested key patterns.\n */\n public async find(query: any, sort: any): Promise<any[]> {\n // split the keys and get the corresponding value\n function getValueByKey(propertyBag, key: string) {\n const keys = key.split(\".\");\n let value = propertyBag;\n keys.forEach((splitKey) => {\n value = value[splitKey];\n });\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return value;\n }\n\n // getting keys of the query we are trying to find\n const queryKeys = Object.keys(query);\n let filteredCollection = this.getAllInternal();\n queryKeys.forEach((key) => {\n if (!query[key]) {\n return;\n }\n if (query[key].$gt > 0 || query[key].$lt > 0) {\n if (query[key].$gt > 0) {\n filteredCollection = filteredCollection.filter(\n (value) => getValueByKey(value, key) > query[key].$gt);\n }\n if (query[key].$lt > 0) {\n filteredCollection = filteredCollection.filter(\n (value) => getValueByKey(value, key) < query[key].$lt);\n }\n } else {\n filteredCollection = filteredCollection.filter(\n (value) => getValueByKey(value, key) === query[key]);\n }\n });\n\n if (sort && Object.keys(sort).length === 1) {\n // eslint-disable-next-line no-inner-declarations\n function compare(a, b) {\n const sortKey = Object.keys(sort)[0];\n return sort[sortKey] === 1\n ? getValueByKey(a, sortKey) - getValueByKey(b, sortKey)\n : getValueByKey(b, sortKey) - getValueByKey(a, sortKey);\n }\n\n filteredCollection = filteredCollection.sort(compare);\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return filteredCollection;\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.findAll}\n */\n public async findAll(): Promise<any[]> {\n return Promise.resolve(this.getAllInternal());\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.findOne}\n */\n /*\n * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n */\n public async findOne(query: any): Promise<any> {\n return Promise.resolve(this.findOneInternal(query));\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.update}\n */\n /*\n * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n */\n public async update(query: any, set: any, addToSet: any): Promise<void> {\n const value = this.findOneInternal(query);\n if (!value) {\n throw new Error(\"Not found\");\n } else {\n for (const key of Object.keys(set)) {\n value[key] = set[key];\n }\n this.insertInternal(value);\n }\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.upsert}\n */\n /*\n * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n */\n public async upsert(query: any, set: any, addToSet: any): Promise<void> {\n const value = this.findOneInternal(query);\n if (!value) {\n this.insertInternal(set);\n } else {\n for (const key of Object.keys(set)) {\n value[key] = set[key];\n }\n this.insertInternal(value);\n }\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.insertOne}\n */\n /*\n * Value is expected to have a member \"_id\" which is a string used to search in the database.\n */\n public async insertOne(value: any): Promise<any> {\n const presentVal = this.findOneInternal(value);\n // Only raise error when the object is present and the value is not equal.\n if (presentVal) {\n if (JSON.stringify(presentVal) === JSON.stringify(value)) {\n return;\n }\n throw new Error(\"Existing Object!!\");\n }\n\n return this.insertInternal(value);\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.findOrCreate}\n */\n /*\n * Value and query are expected to have a member \"_id\" which is a string used to search or insert in the database.\n */\n public async findOrCreate(query: any, value: any): Promise<{ value: any; existing: boolean; }> {\n const existing = this.findOneInternal(query);\n if (existing) {\n return { value: existing, existing: true };\n }\n this.insertInternal(value);\n return { value, existing: false };\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.insertMany}\n */\n /*\n * Each element in values is expected to have a member \"_id\" which is a string used to insert in the database.\n */\n public async insertMany(values: any[], ordered: boolean): Promise<void> {\n this.insertInternal(...values);\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteOne}\n */\n public async deleteOne(query: any): Promise<any> {\n throw new Error(\"Method not implemented.\");\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteMany}\n */\n public async deleteMany(query: any): Promise<any> {\n throw new Error(\"Method not implemented.\");\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.createIndex}\n */\n public async createIndex(index: any, unique: boolean): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n /**\n * Return all values in the database\n */\n private getAllInternal(): any[] {\n const values: string[] = [];\n for (let i = 0; i < sessionStorage.length; i++) {\n const key = sessionStorage.key(i);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n if (key!.startsWith(this.collectionName)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n values.push(JSON.parse(sessionStorage.getItem(key!)!));\n }\n }\n return values;\n }\n\n /**\n * Inserts values into the session storge.\n * Values are expected to have a member \"_id\" which is a unique id, otherwise will be assigned one\n *\n * @param values - data to insert to the database\n */\n private insertInternal(...values: any[]) {\n for (const value of values) {\n if (value) {\n if (!value._id) {\n value._id = uuid();\n }\n sessionStorage.setItem(`${this.collectionName}-${value._id}`, JSON.stringify(value));\n }\n }\n }\n\n /**\n * Finds the query in session storage and returns its value.\n * Returns null if query is not found.\n * Query is expected to have a member \"_id\" which is a unique id.\n *\n * @param query - what to find in the database\n */\n private findOneInternal(query: any): any {\n if (query._id) {\n const json = sessionStorage.getItem(`${this.collectionName}-${query._id}`);\n if (json) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(json);\n }\n } else {\n const queryKeys = Object.keys(query);\n for (let i = 0; i < sessionStorage.length; i++) {\n const ssKey = sessionStorage.key(i);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n if (!ssKey!.startsWith(this.collectionName)) {\n continue;\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const value = JSON.parse(sessionStorage.getItem(ssKey!)!);\n for (const qk of queryKeys) {\n if (value[qk] !== query[qk]) {\n continue;\n }\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return value;\n }\n }\n return null;\n }\n}\n\n/**\n * A database for testing that stores data in the browsers session storage\n */\nclass LocalSessionStorageDb extends EventEmitter implements IDb {\n private readonly collections = new Map<string, LocalSessionStorageCollection<any>>();\n constructor(private readonly namespace) {\n super();\n }\n public async close(): Promise<void> {\n return Promise.resolve();\n }\n public collection<T>(name: string): ICollection<T> {\n if (!this.collections.has(name)) {\n this.collections.set(name, new LocalSessionStorageCollection<T>(`${this.namespace}-db`, name));\n }\n return this.collections.get(name) as LocalSessionStorageCollection<T>;\n }\n\n public async dropCollection(name: string): Promise<boolean> {\n if (!this.collections.has(name)) {\n return true;\n }\n this.collections.delete(name);\n return true;\n }\n}\n\n/**\n * A database factory for testing that stores data in the browsers session storage\n */\nexport class LocalSessionStorageDbFactory implements ITestDbFactory {\n public readonly testDatabase: IDb;\n constructor(namespace: string) {\n this.testDatabase = new LocalSessionStorageDb(namespace);\n }\n public async connect(): Promise<IDb> {\n return this.testDatabase;\n }\n}\n"]}
1
+ {"version":3,"file":"localSessionStorageDb.js","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,mCAAsC;AAGtC,+BAAkC;AAElC;;;GAGG;AACH,MAAM,6BAA6B;IAE/B,YAAY,SAAS,EAAE,IAAI;QACvB,IAAI,CAAC,cAAc,GAAG,GAAG,SAAS,IAAI,IAAI,EAAE,CAAC;IACjD,CAAC;IAEM,SAAS,CAAC,QAAa,EAAE,OAAa;QACzC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC9C,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,MAAW,EAAE,GAAQ,EAAE,QAAa;QACxD,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC9C,CAAC;IACM,KAAK,CAAC,QAAQ,CAAC,GAAQ,EAAE,KAAU;QACtC,MAAM,IAAI,KAAK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;QACzB,IAAI,CAAC,YAAY,GAAG,IAAI,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC;IACM,KAAK,CAAC,OAAO;QAChB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;CACJ;AARD,oEAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { EventEmitter } from \"events\";\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 private readonly collectionName: string;\n constructor(namespace, name) {\n this.collectionName = `${namespace}-${name}`;\n }\n\n public aggregate(pipeline: any, options?: any): any {\n throw new Error(\"Method Not Implemented\");\n }\n\n public async updateMany(filter: any, set: any, addToSet: any): Promise<void> {\n throw new Error(\"Method Not Implemented\");\n }\n public async distinct(key: any, query: any): Promise<any> {\n throw new Error(\"Method Not Implemented\");\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.find}\n */\n /*\n * Each query key consists of several keys separated by '.' e.g: \"operation.sequenceNumber\".\n * The hierarchical syntax allows finding nested key patterns.\n */\n public async find(query: any, sort: any): Promise<any[]> {\n // split the keys and get the corresponding value\n function getValueByKey(propertyBag, key: string) {\n const keys = key.split(\".\");\n let value = propertyBag;\n keys.forEach((splitKey) => {\n value = value[splitKey];\n });\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return value;\n }\n\n // getting keys of the query we are trying to find\n const queryKeys = Object.keys(query);\n let filteredCollection = this.getAllInternal();\n queryKeys.forEach((key) => {\n if (!query[key]) {\n return;\n }\n if (query[key].$gt > 0 || query[key].$lt > 0) {\n if (query[key].$gt > 0) {\n filteredCollection = filteredCollection.filter(\n (value) => getValueByKey(value, key) > query[key].$gt);\n }\n if (query[key].$lt > 0) {\n filteredCollection = filteredCollection.filter(\n (value) => getValueByKey(value, key) < query[key].$lt);\n }\n } else {\n filteredCollection = filteredCollection.filter(\n (value) => getValueByKey(value, key) === query[key]);\n }\n });\n\n if (sort && Object.keys(sort).length === 1) {\n // eslint-disable-next-line no-inner-declarations\n function compare(a, b) {\n const sortKey = Object.keys(sort)[0];\n return sort[sortKey] === 1\n ? getValueByKey(a, sortKey) - getValueByKey(b, sortKey)\n : getValueByKey(b, sortKey) - getValueByKey(a, sortKey);\n }\n\n filteredCollection = filteredCollection.sort(compare);\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return filteredCollection;\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.findAll}\n */\n public async findAll(): Promise<any[]> {\n return Promise.resolve(this.getAllInternal());\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.findOne}\n */\n /*\n * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n */\n public async findOne(query: any): Promise<any> {\n return Promise.resolve(this.findOneInternal(query));\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.update}\n */\n /*\n * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n */\n public async update(query: any, set: any, addToSet: any): Promise<void> {\n const value = this.findOneInternal(query);\n if (!value) {\n throw new Error(\"Not found\");\n } else {\n for (const key of Object.keys(set)) {\n value[key] = set[key];\n }\n this.insertInternal(value);\n }\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.upsert}\n */\n /*\n * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n */\n public async upsert(query: any, set: any, addToSet: any): Promise<void> {\n const value = this.findOneInternal(query);\n if (!value) {\n this.insertInternal(set);\n } else {\n for (const key of Object.keys(set)) {\n value[key] = set[key];\n }\n this.insertInternal(value);\n }\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.insertOne}\n */\n /*\n * Value is expected to have a member \"_id\" which is a string used to search in the database.\n */\n public async insertOne(value: any): Promise<any> {\n const presentVal = this.findOneInternal(value);\n // Only raise error when the object is present and the value is not equal.\n if (presentVal) {\n if (JSON.stringify(presentVal) === JSON.stringify(value)) {\n return;\n }\n throw new Error(\"Existing Object!!\");\n }\n\n return this.insertInternal(value);\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.findOrCreate}\n */\n /*\n * Value and query are expected to have a member \"_id\" which is a string used to search or insert in the database.\n */\n public async findOrCreate(query: any, value: any): Promise<{ value: any; existing: boolean; }> {\n const existing = this.findOneInternal(query);\n if (existing) {\n return { value: existing, existing: true };\n }\n this.insertInternal(value);\n return { value, existing: false };\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.insertMany}\n */\n /*\n * Each element in values is expected to have a member \"_id\" which is a string used to insert in the database.\n */\n public async insertMany(values: any[], ordered: boolean): Promise<void> {\n this.insertInternal(...values);\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteOne}\n */\n public async deleteOne(query: any): Promise<any> {\n throw new Error(\"Method not implemented.\");\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteMany}\n */\n public async deleteMany(query: any): Promise<any> {\n throw new Error(\"Method not implemented.\");\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.createIndex}\n */\n public async createIndex(index: any, unique: boolean): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n /**\n * Return all values in the database\n */\n private getAllInternal(): any[] {\n const values: string[] = [];\n for (let i = 0; i < sessionStorage.length; i++) {\n const key = sessionStorage.key(i);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n if (key!.startsWith(this.collectionName)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n values.push(JSON.parse(sessionStorage.getItem(key!)!));\n }\n }\n return values;\n }\n\n /**\n * Inserts values into the session storge.\n * Values are expected to have a member \"_id\" which is a unique id, otherwise will be assigned one\n *\n * @param values - data to insert to the database\n */\n private insertInternal(...values: any[]) {\n for (const value of values) {\n if (value) {\n if (!value._id) {\n value._id = uuid();\n }\n sessionStorage.setItem(`${this.collectionName}-${value._id}`, JSON.stringify(value));\n }\n }\n }\n\n /**\n * Finds the query in session storage and returns its value.\n * Returns null if query is not found.\n * Query is expected to have a member \"_id\" which is a unique id.\n *\n * @param query - what to find in the database\n */\n private findOneInternal(query: any): any {\n if (query._id) {\n const json = sessionStorage.getItem(`${this.collectionName}-${query._id}`);\n if (json) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(json);\n }\n } else {\n const queryKeys = Object.keys(query);\n for (let i = 0; i < sessionStorage.length; i++) {\n const ssKey = sessionStorage.key(i);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n if (!ssKey!.startsWith(this.collectionName)) {\n continue;\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const value = JSON.parse(sessionStorage.getItem(ssKey!)!);\n let foundMismatch = false;\n for (const qk of queryKeys) {\n if (value[qk] !== query[qk]) {\n foundMismatch = true;\n break;\n }\n }\n\n if (!foundMismatch) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return value;\n }\n }\n }\n return null;\n }\n}\n\n/**\n * A database for testing that stores data in the browsers session storage\n */\nclass LocalSessionStorageDb extends EventEmitter implements IDb {\n private readonly collections = new Map<string, LocalSessionStorageCollection<any>>();\n constructor(private readonly namespace) {\n super();\n }\n public async close(): Promise<void> {\n return Promise.resolve();\n }\n public collection<T>(name: string): ICollection<T> {\n if (!this.collections.has(name)) {\n this.collections.set(name, new LocalSessionStorageCollection<T>(`${this.namespace}-db`, name));\n }\n return this.collections.get(name) as LocalSessionStorageCollection<T>;\n }\n\n public async dropCollection(name: string): Promise<boolean> {\n if (!this.collections.has(name)) {\n return true;\n }\n this.collections.delete(name);\n return true;\n }\n}\n\n/**\n * A database factory for testing that stores data in the browsers session storage\n */\nexport class LocalSessionStorageDbFactory implements ITestDbFactory {\n public readonly testDatabase: IDb;\n constructor(namespace: string) {\n this.testDatabase = new LocalSessionStorageDb(namespace);\n }\n public async connect(): Promise<IDb> {\n return this.testDatabase;\n }\n}\n"]}
@@ -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.0.0-internal.1.1.2";
8
+ export declare const pkgVersion = "2.0.0-internal.1.2.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/local-driver";
11
- exports.pkgVersion = "2.0.0-internal.1.1.2";
11
+ exports.pkgVersion = "2.0.0-internal.1.2.0";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,8BAA8B,CAAC;AACzC,QAAA,UAAU,GAAG,sBAAsB,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.0.0-internal.1.1.2\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,8BAA8B,CAAC;AACzC,QAAA,UAAU,GAAG,sBAAsB,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.0.0-internal.1.2.0\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/local-driver",
3
- "version": "2.0.0-internal.1.1.2",
3
+ "version": "2.0.0-internal.1.2.0",
4
4
  "description": "Fluid local driver",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -58,24 +58,24 @@
58
58
  "dependencies": {
59
59
  "@fluidframework/common-definitions": "^0.20.1",
60
60
  "@fluidframework/common-utils": "^1.0.0",
61
- "@fluidframework/core-interfaces": "^2.0.0-internal.1.1.2",
62
- "@fluidframework/driver-base": "^2.0.0-internal.1.1.2",
63
- "@fluidframework/driver-definitions": "^2.0.0-internal.1.1.2",
64
- "@fluidframework/driver-utils": "^2.0.0-internal.1.1.2",
61
+ "@fluidframework/core-interfaces": "^2.0.0-internal.1.2.0",
62
+ "@fluidframework/driver-base": "^2.0.0-internal.1.2.0",
63
+ "@fluidframework/driver-definitions": "^2.0.0-internal.1.2.0",
64
+ "@fluidframework/driver-utils": "^2.0.0-internal.1.2.0",
65
65
  "@fluidframework/protocol-definitions": "^1.0.0",
66
- "@fluidframework/routerlicious-driver": "^2.0.0-internal.1.1.2",
67
- "@fluidframework/server-local-server": "^0.1037.1000",
68
- "@fluidframework/server-services-client": "^0.1037.1000",
69
- "@fluidframework/server-services-core": "^0.1037.1000",
70
- "@fluidframework/server-test-utils": "^0.1037.1000",
66
+ "@fluidframework/routerlicious-driver": "^2.0.0-internal.1.2.0",
67
+ "@fluidframework/server-local-server": "^0.1038.1000",
68
+ "@fluidframework/server-services-client": "^0.1038.1000",
69
+ "@fluidframework/server-services-core": "^0.1038.1000",
70
+ "@fluidframework/server-test-utils": "^0.1038.1000",
71
71
  "jsrsasign": "^10.5.25",
72
72
  "uuid": "^8.3.1"
73
73
  },
74
74
  "devDependencies": {
75
- "@fluidframework/build-common": "^0.24.0",
76
- "@fluidframework/eslint-config-fluid": "^0.28.2000",
75
+ "@fluidframework/build-common": "^1.0.0",
76
+ "@fluidframework/eslint-config-fluid": "^1.0.0",
77
77
  "@fluidframework/local-driver-previous": "npm:@fluidframework/local-driver@^1.0.0",
78
- "@fluidframework/mocha-test-setup": "^2.0.0-internal.1.1.2",
78
+ "@fluidframework/mocha-test-setup": "^2.0.0-internal.1.2.0",
79
79
  "@rushstack/eslint-config": "^2.5.1",
80
80
  "@types/jsrsasign": "^8.0.8",
81
81
  "@types/mocha": "^9.1.1",
@@ -76,8 +76,9 @@ export class LocalDocumentServiceFactory implements IDocumentServiceFactory {
76
76
  defaultHash,
77
77
  resolvedUrl.endpoints.ordererUrl ?? "",
78
78
  resolvedUrl.endpoints.storageUrl ?? "",
79
+ resolvedUrl.endpoints.deltaStreamUrl ?? resolvedUrl.endpoints.ordererUrl ?? "",
79
80
  quorumValues,
80
- false,
81
+ false, /* enableDiscovery */
81
82
  );
82
83
  return this.createDocumentService(resolvedUrl, logger, clientIsSummarizer);
83
84
  }
@@ -259,13 +259,18 @@ class LocalSessionStorageCollection<T> implements ICollection<T> {
259
259
  }
260
260
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
261
261
  const value = JSON.parse(sessionStorage.getItem(ssKey!)!);
262
+ let foundMismatch = false;
262
263
  for (const qk of queryKeys) {
263
264
  if (value[qk] !== query[qk]) {
264
- continue;
265
+ foundMismatch = true;
266
+ break;
265
267
  }
266
268
  }
267
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
268
- return value;
269
+
270
+ if (!foundMismatch) {
271
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
272
+ return value;
273
+ }
269
274
  }
270
275
  }
271
276
  return null;
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/local-driver";
9
- export const pkgVersion = "2.0.0-internal.1.1.2";
9
+ export const pkgVersion = "2.0.0-internal.1.2.0";