@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
|
@@ -42,17 +42,17 @@ class LocalSessionStorageCollection {
|
|
|
42
42
|
function getValueByKey(propertyBag, key) {
|
|
43
43
|
const keys = key.split(".");
|
|
44
44
|
let value = propertyBag;
|
|
45
|
-
|
|
45
|
+
for (const splitKey of keys) {
|
|
46
46
|
value = value[splitKey];
|
|
47
|
-
}
|
|
47
|
+
}
|
|
48
48
|
return value;
|
|
49
49
|
}
|
|
50
50
|
// getting keys of the query we are trying to find
|
|
51
51
|
const queryKeys = Object.keys(query);
|
|
52
52
|
let filteredCollection = this.getAllInternal();
|
|
53
|
-
|
|
53
|
+
for (const key of queryKeys) {
|
|
54
54
|
if (!query[key]) {
|
|
55
|
-
|
|
55
|
+
continue;
|
|
56
56
|
}
|
|
57
57
|
if (query[key].$gt > 0 || query[key].$lt > 0) {
|
|
58
58
|
if (query[key].$gt > 0) {
|
|
@@ -65,7 +65,7 @@ class LocalSessionStorageCollection {
|
|
|
65
65
|
else {
|
|
66
66
|
filteredCollection = filteredCollection.filter((value) => getValueByKey(value, key) === query[key]);
|
|
67
67
|
}
|
|
68
|
-
}
|
|
68
|
+
}
|
|
69
69
|
if (sort && Object.keys(sort).length === 1) {
|
|
70
70
|
function compare(a, b) {
|
|
71
71
|
// Non null asserting here because of the length check above
|
|
@@ -102,15 +102,15 @@ class LocalSessionStorageCollection {
|
|
|
102
102
|
*/
|
|
103
103
|
async update(query, set, addToSet) {
|
|
104
104
|
const value = this.findOneInternal(query);
|
|
105
|
-
if (
|
|
106
|
-
throw new Error("Not found");
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
105
|
+
if (value) {
|
|
109
106
|
for (const key of Object.keys(set)) {
|
|
110
107
|
value[key] = set[key];
|
|
111
108
|
}
|
|
112
109
|
this.insertInternal(value);
|
|
113
110
|
}
|
|
111
|
+
else {
|
|
112
|
+
throw new Error("Not found");
|
|
113
|
+
}
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
116
|
* {@inheritDoc @fluidframework/server-services-core#ICollection.upsert}
|
|
@@ -120,15 +120,15 @@ class LocalSessionStorageCollection {
|
|
|
120
120
|
*/
|
|
121
121
|
async upsert(query, set, addToSet) {
|
|
122
122
|
const value = this.findOneInternal(query);
|
|
123
|
-
if (
|
|
124
|
-
this.insertInternal(set);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
123
|
+
if (value) {
|
|
127
124
|
for (const key of Object.keys(set)) {
|
|
128
125
|
value[key] = set[key];
|
|
129
126
|
}
|
|
130
127
|
this.insertInternal(value);
|
|
131
128
|
}
|
|
129
|
+
else {
|
|
130
|
+
this.insertInternal(set);
|
|
131
|
+
}
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
134
134
|
* {@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,+DAA4D;AAG5D,+BAAkC;AAElC;;;GAGG;AACH,MAAM,6BAA6B;IAClC;;OAEG;IACH,YAA6B,cAAsB;QAAtB,mBAAc,GAAd,cAAc,CAAQ;IAAG,CAAC;IAEhD,SAAS,CAAC,QAAa,EAAE,OAAa;QAC5C,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC3C,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,MAAW,EAAE,GAAQ,EAAE,QAAa;QAC3D,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC3C,CAAC;IACM,KAAK,CAAC,QAAQ,CAAC,GAAQ,EAAE,KAAU;QACzC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC3C,CAAC;IACM,KAAK,CAAC,aAAa,CAAC,KAAU,EAAE,KAAQ;QAC9C,MAAM,IAAI,KA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AAI,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED;;;GAGG;AACH,MAAa,4BAA4B;IAAzC;QACiB,iBAAY,GAAQ,IAAI,qBAAqB,EAAE,CAAC;IAIjE,CAAC;IAHO,KAAK,CAAC,OAAO;QACnB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;CACD;AALD,oEAKC","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,+DAA4D;AAG5D,+BAAkC;AAElC;;;GAGG;AACH,MAAM,6BAA6B;IAClC;;OAEG;IACH,YAA6B,cAAsB;QAAtB,mBAAc,GAAd,cAAc,CAAQ;IAAG,CAAC;IAEhD,SAAS,CAAC,QAAa,EAAE,OAAa;QAC5C,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC3C,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,MAAW,EAAE,GAAQ,EAAE,QAAa;QAC3D,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC3C,CAAC;IACM,KAAK,CAAC,QAAQ,CAAC,GAAQ,EAAE,KAAU;QACzC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC3C,CAAC;IACM,KAAK,CAAC,aAAa,CAAC,KAAU,EAAE,KAAQ;QAC9C,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH;;;OAGG;IACI,KAAK,CAAC,IAAI,CAAC,KAAU,EAAE,IAAS;QACtC,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AAC,OAAO;QACnB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;CACD;AALD,oEAKC","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/dist/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/dist/packageVersion.js
CHANGED
|
@@ -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.
|
|
11
|
+
exports.pkgVersion = "2.92.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,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;;;AAEU,QAAA,OAAO,GAAG,8BAA8B,CAAC;AACzC,QAAA,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/dist/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 --resolutionConditions require --outFileLegacyBeta legacy --outDir ./dist" in @fluid-tools/build-cli.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export {}
|
package/eslint.config.mts
CHANGED
|
@@ -4,13 +4,25 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import type { Linter } from "eslint";
|
|
7
|
-
import {
|
|
7
|
+
import { recommended } from "../../../common/build/eslint-config-fluid/flat.mts";
|
|
8
8
|
|
|
9
9
|
const config: Linter.Config[] = [
|
|
10
|
-
...
|
|
10
|
+
...recommended,
|
|
11
11
|
{
|
|
12
12
|
rules: {
|
|
13
|
+
"@rushstack/no-new-null": "off",
|
|
14
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
15
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
16
|
+
"@typescript-eslint/no-unsafe-argument": "off",
|
|
17
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
18
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
13
19
|
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
20
|
+
"require-atomic-updates": "off",
|
|
21
|
+
"unicorn/no-array-method-this-argument": "off",
|
|
22
|
+
"unicorn/no-null": "off",
|
|
23
|
+
"unicorn/prefer-logical-operator-over-ternary": "off",
|
|
24
|
+
"unicorn/prefer-node-protocol": "off",
|
|
25
|
+
"unicorn/text-encoding-identifier-case": "off",
|
|
14
26
|
},
|
|
15
27
|
},
|
|
16
28
|
{
|
package/internal.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 * from "./lib/index.js";
|
package/legacy.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 * from "./lib/legacy.js";
|
package/lib/auth.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 { IUser } from "@fluidframework/driver-definitions";
|
|
6
|
-
import { ScopeType } from "@fluidframework/driver-definitions/internal";
|
|
5
|
+
import type { IUser } from "@fluidframework/driver-definitions";
|
|
6
|
+
import type { ScopeType } from "@fluidframework/driver-definitions/internal";
|
|
7
7
|
/**
|
|
8
8
|
* Generates a JWT token to authorize against. We do not use the implementation in
|
|
9
9
|
* services-client since it cannot run in the browser without polyfills.
|
package/lib/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,6CAA6C,CAAC;AAI3F;;;GAGG;AACH,wBAAgB,aAAa,CAC5B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,SAAS,EAAE,EACnB,IAAI,CAAC,EAAE,KAAK,EACZ,QAAQ,GAAE,MAAgB,EAC1B,GAAG,GAAE,MAAc,GACjB,MAAM,CA2BR;AAED,wBAAgB,YAAY,IAAI,KAAK,CAWpC"}
|
package/lib/auth.js
CHANGED
|
@@ -15,7 +15,7 @@ export function generateToken(tenantId, documentId, key, scopes, user, lifetime
|
|
|
15
15
|
userClaim = generateUser();
|
|
16
16
|
}
|
|
17
17
|
// Current time in seconds
|
|
18
|
-
const now = Math.round(
|
|
18
|
+
const now = Math.round(Date.now() / 1000);
|
|
19
19
|
const claims = {
|
|
20
20
|
documentId,
|
|
21
21
|
scopes,
|
|
@@ -31,7 +31,7 @@ export function generateToken(tenantId, documentId, key, scopes, user, lifetime
|
|
|
31
31
|
export function generateUser() {
|
|
32
32
|
const userId = uuid();
|
|
33
33
|
const match = /^([\da-f]{8})-([\da-f]{4})/.exec(userId);
|
|
34
|
-
const userName = match
|
|
34
|
+
const userName = match === null ? userId : match[0]; // Just use the first two segments of the (fake) userId as a fake name.
|
|
35
35
|
const randomUser = {
|
|
36
36
|
id: userId,
|
|
37
37
|
name: userName,
|
package/lib/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC5B,QAAgB,EAChB,UAAkB,EAClB,GAAW,EACX,MAAmB,EACnB,IAAY,EACZ,WAAmB,EAAE,GAAG,EAAE,EAC1B,MAAc,KAAK;IAEnB,2HAA2H;IAC3H,IAAI,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;IAC7C,IAAI,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,SAAS,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;QACvD,SAAS,GAAG,YAAY,EAAE,CAAC;IAC5B,CAAC;IAED,0BAA0B;IAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC5B,QAAgB,EAChB,UAAkB,EAClB,GAAW,EACX,MAAmB,EACnB,IAAY,EACZ,WAAmB,EAAE,GAAG,EAAE,EAC1B,MAAc,KAAK;IAEnB,2HAA2H;IAC3H,IAAI,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;IAC7C,IAAI,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,SAAS,CAAC,EAAE,KAAK,SAAS,EAAE,CAAC;QACvD,SAAS,GAAG,YAAY,EAAE,CAAC;IAC5B,CAAC;IAED,0BAA0B;IAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAE1C,MAAM,MAAM,GAAiB;QAC5B,UAAU;QACV,MAAM;QACN,QAAQ;QACR,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG,GAAG,QAAQ;QACnB,GAAG;KACH,CAAC;IAEF,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAC9B,OAAO,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAC5B,IAAI,EACJ,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAC5C,MAAM,EACN,OAAO,CACP,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY;IAC3B,MAAM,MAAM,GAAG,IAAI,EAAE,CAAC;IACtB,MAAM,KAAK,GAAG,4BAA4B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxD,MAAM,QAAQ,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,uEAAuE;IAE5H,MAAM,UAAU,GAAG;QAClB,EAAE,EAAE,MAAM;QACV,IAAI,EAAE,QAAQ;KACd,CAAC;IAEF,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { IUser } from \"@fluidframework/driver-definitions\";\nimport type { ITokenClaims, ScopeType } from \"@fluidframework/driver-definitions/internal\";\nimport { KJUR as jsrsasign } from \"jsrsasign\";\nimport { v4 as uuid } from \"uuid\";\n\n/**\n * Generates a JWT token to authorize against. We do not use the implementation in\n * services-client since it cannot run in the browser without polyfills.\n */\nexport function generateToken(\n\ttenantId: string,\n\tdocumentId: string,\n\tkey: string,\n\tscopes: ScopeType[],\n\tuser?: IUser,\n\tlifetime: number = 60 * 60,\n\tver: string = \"1.0\",\n): string {\n\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- using ?? could change behavior for falsy values\n\tlet userClaim = user ? user : generateUser();\n\tif (userClaim.id === \"\" || userClaim.id === undefined) {\n\t\tuserClaim = generateUser();\n\t}\n\n\t// Current time in seconds\n\tconst now = Math.round(Date.now() / 1000);\n\n\tconst claims: ITokenClaims = {\n\t\tdocumentId,\n\t\tscopes,\n\t\ttenantId,\n\t\tuser: userClaim,\n\t\tiat: now,\n\t\texp: now + lifetime,\n\t\tver,\n\t};\n\n\tconst utf8Key = { utf8: key };\n\treturn jsrsasign.jws.JWS.sign(\n\t\tnull,\n\t\tJSON.stringify({ alg: \"HS256\", typ: \"JWT\" }),\n\t\tclaims,\n\t\tutf8Key,\n\t);\n}\n\nexport function generateUser(): IUser {\n\tconst userId = uuid();\n\tconst match = /^([\\da-f]{8})-([\\da-f]{4})/.exec(userId);\n\tconst userName = match === null ? userId : match[0]; // Just use the first two segments of the (fake) userId as a fake name.\n\n\tconst randomUser = {\n\t\tid: userId,\n\t\tname: userName,\n\t};\n\n\treturn randomUser;\n}\n"]}
|
package/lib/legacy.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 {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ISummaryTree } from "@fluidframework/driver-definitions";
|
|
6
|
-
import { IResolvedUrl } from "@fluidframework/driver-definitions/internal";
|
|
5
|
+
import type { ISummaryTree } from "@fluidframework/driver-definitions";
|
|
6
|
+
import type { IResolvedUrl } from "@fluidframework/driver-definitions/internal";
|
|
7
7
|
export declare function createDocument(localDeltaConnectionServer: any, resolvedUrl: IResolvedUrl, summary: ISummaryTree): Promise<void>;
|
|
8
8
|
//# sourceMappingURL=localCreateDocument.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localCreateDocument.d.ts","sourceRoot":"","sources":["../src/localCreateDocument.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"localCreateDocument.d.ts","sourceRoot":"","sources":["../src/localCreateDocument.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAShF,wBAAsB,cAAc,CACnC,0BAA0B,KAAA,EAC1B,WAAW,EAAE,YAAY,EACzB,OAAO,EAAE,YAAY,GACnB,OAAO,CAAC,IAAI,CAAC,CAgCf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localCreateDocument.js","sourceRoot":"","sources":["../src/localCreateDocument.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,mCAAmC,EACnC,kCAAkC,EAClC,+BAA+B,GAC/B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,WAAW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AAC,0BAA0B,CAChC,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils/internal\";\nimport { LocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport { defaultHash } from \"@fluidframework/server-services-client\";\n\nexport async function createDocument(\n\tlocalDeltaConnectionServer,\n\tresolvedUrl: IResolvedUrl,\n\tsummary: ISummaryTree,\n): Promise<void> {\n\tconst pathName = new URL(resolvedUrl.url).pathname;\n\tconst pathArr = pathName.split(\"/\");\n\t// TODO Why are we non null asserting here\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst tenantId = pathArr[pathArr.length - 2]!;\n\t// TODO Why are we non null asserting here\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst id = pathArr[pathArr.length - 1]!;\n\tconst documentStorage = (localDeltaConnectionServer as LocalDeltaConnectionServer)\n\t\t.documentStorage;\n\tif (!isCombinedAppAndProtocolSummary(summary)) {\n\t\tthrow new Error(\"Protocol and App Summary required in the full summary\");\n\t}\n\tconst protocolSummary = summary.tree[\".protocol\"];\n\tconst appSummary = summary.tree[\".app\"];\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);\n\tconst sequenceNumber = documentAttributes.sequenceNumber;\n\tawait documentStorage.createDocument(\n\t\ttenantId,\n\t\tid,\n\t\tappSummary,\n\t\tsequenceNumber,\n\t\tdefaultHash,\n\t\tresolvedUrl.endpoints.ordererUrl ?? \"\",\n\t\tresolvedUrl.endpoints.storageUrl ?? \"\",\n\t\tresolvedUrl.endpoints.deltaStorageUrl ?? \"\",\n\t\tquorumValues,\n\t\tfalse /* enableDiscovery */,\n\t\tfalse /* isEphemeralContainer */,\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"localCreateDocument.js","sourceRoot":"","sources":["../src/localCreateDocument.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,mCAAmC,EACnC,kCAAkC,EAClC,+BAA+B,GAC/B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAErE,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,0BAA0B,EAC1B,WAAyB,EACzB,OAAqB;IAErB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;IACnD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,0CAA0C;IAC1C,oEAAoE;IACpE,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC;IAC9C,0CAA0C;IAC1C,oEAAoE;IACpE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC;IACxC,MAAM,eAAe,GAAI,0BAAyD;SAChF,eAAe,CAAC;IAClB,IAAI,CAAC,+BAA+B,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC1E,CAAC;IACD,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,kBAAkB,GAAG,mCAAmC,CAAC,eAAe,CAAC,CAAC;IAChF,MAAM,YAAY,GAAG,kCAAkC,CAAC,eAAe,CAAC,CAAC;IACzE,MAAM,cAAc,GAAG,kBAAkB,CAAC,cAAc,CAAC;IACzD,MAAM,eAAe,CAAC,cAAc,CACnC,QAAQ,EACR,EAAE,EACF,UAAU,EACV,cAAc,EACd,WAAW,EACX,WAAW,CAAC,SAAS,CAAC,UAAU,IAAI,EAAE,EACtC,WAAW,CAAC,SAAS,CAAC,UAAU,IAAI,EAAE,EACtC,WAAW,CAAC,SAAS,CAAC,eAAe,IAAI,EAAE,EAC3C,YAAY,EACZ,KAAK,CAAC,qBAAqB,EAC3B,KAAK,CAAC,0BAA0B,CAChC,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport type { IResolvedUrl } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils/internal\";\nimport type { LocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport { defaultHash } from \"@fluidframework/server-services-client\";\n\nexport async function createDocument(\n\tlocalDeltaConnectionServer,\n\tresolvedUrl: IResolvedUrl,\n\tsummary: ISummaryTree,\n): Promise<void> {\n\tconst pathName = new URL(resolvedUrl.url).pathname;\n\tconst pathArr = pathName.split(\"/\");\n\t// TODO Why are we non null asserting here\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst tenantId = pathArr[pathArr.length - 2]!;\n\t// TODO Why are we non null asserting here\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst id = pathArr[pathArr.length - 1]!;\n\tconst documentStorage = (localDeltaConnectionServer as LocalDeltaConnectionServer)\n\t\t.documentStorage;\n\tif (!isCombinedAppAndProtocolSummary(summary)) {\n\t\tthrow new Error(\"Protocol and App Summary required in the full summary\");\n\t}\n\tconst protocolSummary = summary.tree[\".protocol\"];\n\tconst appSummary = summary.tree[\".app\"];\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);\n\tconst sequenceNumber = documentAttributes.sequenceNumber;\n\tawait documentStorage.createDocument(\n\t\ttenantId,\n\t\tid,\n\t\tappSummary,\n\t\tsequenceNumber,\n\t\tdefaultHash,\n\t\tresolvedUrl.endpoints.ordererUrl ?? \"\",\n\t\tresolvedUrl.endpoints.storageUrl ?? \"\",\n\t\tresolvedUrl.endpoints.deltaStorageUrl ?? \"\",\n\t\tquorumValues,\n\t\tfalse /* enableDiscovery */,\n\t\tfalse /* isEphemeralContainer */,\n\t);\n}\n"]}
|
|
@@ -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 { IDocumentDeltaStorageService, IStream, ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
6
|
-
import { IDatabaseManager } from "@fluidframework/server-services-core";
|
|
5
|
+
import type { IDocumentDeltaStorageService, IStream, ISequencedDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
6
|
+
import type { IDatabaseManager } from "@fluidframework/server-services-core";
|
|
7
7
|
/**
|
|
8
8
|
* Provides access to the underlying delta storage on the server for local driver.
|
|
9
9
|
* @internal
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/localDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"localDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/localDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,4BAA4B,EAC5B,OAAO,EACP,yBAAyB,EACzB,MAAM,6CAA6C,CAAC;AAErD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CA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AG,IAAI,GAAG,CAAC,CAAC,CAAC,oBAAoB;QAEtE,kFAAkF;QAClF,iBAAiB;QACjB,KAAK,CAAC,0BAA0B,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,MAAM,CAAC,gBAAgB,CAAC;QAEtE,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QACxF,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,0BAA0B,EAAE,CAAC,EAAE,CAAC,CAAC;QAChF,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC1D,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDocumentDeltaStorageService,\n\tIStream,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { streamFromMessages } from \"@fluidframework/driver-utils/internal\";\nimport { IDatabaseManager } from \"@fluidframework/server-services-core\";\n\n/**\n * Provides access to the underlying delta storage on the server for local driver.\n * @internal\n */\nexport class LocalDeltaStorageService implements IDocumentDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly id: string,\n\t\tprivate readonly databaseManager: IDatabaseManager,\n\t) {}\n\n\tpublic fetchMessages(\n\t\tfrom: number,\n\t\tto: number | undefined,\n\t\tabortSignal?: AbortSignal,\n\t\tcachedOnly?: boolean,\n\t): IStream<ISequencedDocumentMessage[]> {\n\t\treturn streamFromMessages(this.getCore(from, to));\n\t}\n\n\tprivate async getCore(from: number, to?: number): Promise<ISequencedDocumentMessage[]> {\n\t\tconst query = { documentId: this.id, tenantId: this.tenantId };\n\t\tquery[\"operation.sequenceNumber\"] = {};\n\t\tquery[\"operation.sequenceNumber\"].$gt = from - 1; // from is inclusive\n\n\t\t// This looks like a bug. It used to work without setting $lt key. Now it does not\n\t\t// Need follow up\n\t\tquery[\"operation.sequenceNumber\"].$lt = to ?? Number.MAX_SAFE_INTEGER;\n\n\t\tconst allDeltas = await this.databaseManager.getDeltaCollection(this.tenantId, this.id);\n\t\tconst dbDeltas = await allDeltas.find(query, { \"operation.sequenceNumber\": 1 });\n\t\tconst messages = dbDeltas.map((delta) => delta.operation);\n\t\treturn messages;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"localDeltaStorageService.js","sourceRoot":"","sources":["../src/localDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAG3E;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IACpC,YACkB,QAAgB,EAChB,EAAU,EACV,eAAiC;QAFjC,aAAQ,GAAR,QAAQ,CAAQ;QAChB,OAAE,GAAF,EAAE,CAAQ;QACV,oBAAe,GAAf,eAAe,CAAkB;IAChD,CAAC;IAEG,aAAa,CACnB,IAAY,EACZ,EAAsB,EACtB,WAAyB,EACzB,UAAoB;QAEpB,OAAO,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IACnD,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,EAAW;QAC9C,MAAM,KAAK,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC/D,KAAK,CAAC,0BAA0B,CAAC,GAAG,EAAE,CAAC;QACvC,KAAK,CAAC,0BAA0B,CAAC,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,oBAAoB;QAEtE,kFAAkF;QAClF,iBAAiB;QACjB,KAAK,CAAC,0BAA0B,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,MAAM,CAAC,gBAAgB,CAAC;QAEtE,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QACxF,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,0BAA0B,EAAE,CAAC,EAAE,CAAC,CAAC;QAChF,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC1D,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIDocumentDeltaStorageService,\n\tIStream,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { streamFromMessages } from \"@fluidframework/driver-utils/internal\";\nimport type { IDatabaseManager } from \"@fluidframework/server-services-core\";\n\n/**\n * Provides access to the underlying delta storage on the server for local driver.\n * @internal\n */\nexport class LocalDeltaStorageService implements IDocumentDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly id: string,\n\t\tprivate readonly databaseManager: IDatabaseManager,\n\t) {}\n\n\tpublic fetchMessages(\n\t\tfrom: number,\n\t\tto: number | undefined,\n\t\tabortSignal?: AbortSignal,\n\t\tcachedOnly?: boolean,\n\t): IStream<ISequencedDocumentMessage[]> {\n\t\treturn streamFromMessages(this.getCore(from, to));\n\t}\n\n\tprivate async getCore(from: number, to?: number): Promise<ISequencedDocumentMessage[]> {\n\t\tconst query = { documentId: this.id, tenantId: this.tenantId };\n\t\tquery[\"operation.sequenceNumber\"] = {};\n\t\tquery[\"operation.sequenceNumber\"].$gt = from - 1; // from is inclusive\n\n\t\t// This looks like a bug. It used to work without setting $lt key. Now it does not\n\t\t// Need follow up\n\t\tquery[\"operation.sequenceNumber\"].$lt = to ?? Number.MAX_SAFE_INTEGER;\n\n\t\tconst allDeltas = await this.databaseManager.getDeltaCollection(this.tenantId, this.id);\n\t\tconst dbDeltas = await allDeltas.find(query, { \"operation.sequenceNumber\": 1 });\n\t\tconst messages = dbDeltas.map((delta) => delta.operation);\n\t\treturn messages;\n\t}\n}\n"]}
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
5
|
+
import type { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { DocumentDeltaConnection } from "@fluidframework/driver-base/internal";
|
|
7
|
-
import { IClient } from "@fluidframework/driver-definitions";
|
|
8
|
-
import { IDocumentMessage
|
|
9
|
-
import {
|
|
7
|
+
import type { IClient } from "@fluidframework/driver-definitions";
|
|
8
|
+
import type { IDocumentMessage } from "@fluidframework/driver-definitions/internal";
|
|
9
|
+
import { NackErrorType } from "@fluidframework/driver-definitions/internal";
|
|
10
|
+
import type { IWebSocketServer } from "@fluidframework/server-services-core";
|
|
10
11
|
import type { Socket } from "socket.io-client";
|
|
11
12
|
/**
|
|
12
13
|
* Represents a connection to a stream of delta updates
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/localDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"localDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/localDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,KAAK,EAAY,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC9F,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAE5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI/C;;;GAGG;AACH,qBAAa,4BAA6B,SAAQ,uBAAuB;IACxE;;;;;;;;;OASG;WACiB,MAAM,CACzB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,OAAO,EACf,eAAe,EAAE,gBAAgB,EACjC,SAAS,SAAQ,EACjB,MAAM,CAAC,EAAE,oBAAoB,GAC3B,OAAO,CAAC,4BAA4B,CAAC;gBAqB5B,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,oBAAoB;IAI7E;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI;IAQjD;;;OAGG;IACI,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI;IAIvD;;;;;OAKG;IACI,UAAU,CAChB,IAAI,oBAAc,EAClB,IAAI,2BAA+C,EACnD,OAAO,EAAE,GAAG,GACV,IAAI;CAYP"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { DocumentDeltaConnection } from "@fluidframework/driver-base/internal";
|
|
6
|
-
import { NackErrorType
|
|
6
|
+
import { NackErrorType } from "@fluidframework/driver-definitions/internal";
|
|
7
7
|
import { createChildLogger } from "@fluidframework/telemetry-utils/internal";
|
|
8
8
|
const testProtocolVersions = ["^0.3.0", "^0.2.0", "^0.1.0"];
|
|
9
9
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/localDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"localDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/localDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAG/E,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAG5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAG7E,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAE5D;;;GAGG;AACH,MAAM,OAAO,4BAA6B,SAAQ,uBAAuB;IACxE;;;;;;;;;OASG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CACzB,QAAgB,EAChB,EAAU,EACV,KAAa,EACb,MAAe,EACf,eAAiC,EACjC,SAAS,GAAG,KAAK,EACjB,MAA6B;QAE7B,MAAM,MAAM,GAAI,eAAwC,CAAC,gBAAgB,EAAE,CAAC;QAE5E,4GAA4G;QAC5G,0EAA0E;QAC1E,MAAM,kBAAkB,GAAG,MAA2B,CAAC;QAEvD,MAAM,eAAe,GAAG,IAAI,4BAA4B,CAAC,kBAAkB,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAEzF,MAAM,cAAc,GAAa;YAChC,MAAM;YACN,EAAE;YACF,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,QAAQ;YACR,KAAK,EAAE,8DAA8D;YACrE,QAAQ,EAAE,oBAAoB;SAC9B,CAAC;QACF,MAAM,eAAe,CAAC,UAAU,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;QAC5D,OAAO,eAAe,CAAC;IACxB,CAAC;IAED,YAAY,MAAc,EAAE,UAAkB,EAAE,MAA6B;QAC5E,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAA4B;QACzC,kFAAkF;QAClF,mEAAmE;QACnE,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YAC3B,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,gBAAgB,CAAC,gBAAwB;QAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IAClD,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAChB,OAAe,GAAG,EAClB,OAAsB,aAAa,CAAC,eAAe,EACnD,OAAY;QAEZ,MAAM,WAAW,GAAG;YACnB,SAAS,EAAE,SAAS;YACpB,cAAc,EAAE,CAAC,CAAC;YAClB,OAAO,EAAE;gBACR,IAAI;gBACJ,IAAI;gBACJ,OAAO;aACP;SACD,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { DocumentDeltaConnection } from \"@fluidframework/driver-base/internal\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport type { IConnect, IDocumentMessage } from \"@fluidframework/driver-definitions/internal\";\nimport { NackErrorType } from \"@fluidframework/driver-definitions/internal\";\nimport type { LocalWebSocketServer } from \"@fluidframework/server-local-server\";\nimport type { IWebSocketServer } from \"@fluidframework/server-services-core\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\nimport type { Socket } from \"socket.io-client\";\n\nconst testProtocolVersions = [\"^0.3.0\", \"^0.2.0\", \"^0.1.0\"];\n\n/**\n * Represents a connection to a stream of delta updates\n * @internal\n */\nexport class LocalDocumentDeltaConnection extends DocumentDeltaConnection {\n\t/**\n\t * Create a LocalDocumentDeltaConnection\n\t * Handle initial messages, contents or signals if they were in queue\n\t *\n\t * @param tenantId - the ID of the tenant\n\t * @param id - document ID\n\t * @param token - authorization token for storage service\n\t * @param client - information about the client\n\t * @param webSocketServer - web socket server to create connection\n\t */\n\tpublic static async create(\n\t\ttenantId: string,\n\t\tid: string,\n\t\ttoken: string,\n\t\tclient: IClient,\n\t\twebSocketServer: IWebSocketServer,\n\t\ttimeoutMs = 60000,\n\t\tlogger?: ITelemetryBaseLogger,\n\t): Promise<LocalDocumentDeltaConnection> {\n\t\tconst socket = (webSocketServer as LocalWebSocketServer).createConnection();\n\n\t\t// Cast LocalWebSocket to SocketIOClient.Socket which is the socket that the base class needs. This is hacky\n\t\t// but should be fine because this delta connection is for local use only.\n\t\tconst socketWithListener = socket as unknown as Socket;\n\n\t\tconst deltaConnection = new LocalDocumentDeltaConnection(socketWithListener, id, logger);\n\n\t\tconst connectMessage: IConnect = {\n\t\t\tclient,\n\t\t\tid,\n\t\t\tmode: client.mode,\n\t\t\ttenantId,\n\t\t\ttoken, // Token is going to indicate tenant level information, etc...\n\t\t\tversions: testProtocolVersions,\n\t\t};\n\t\tawait deltaConnection.initialize(connectMessage, timeoutMs);\n\t\treturn deltaConnection;\n\t}\n\n\tconstructor(socket: Socket, documentId: string, logger?: ITelemetryBaseLogger) {\n\t\tsuper(socket, documentId, createChildLogger({ logger }));\n\t}\n\n\t/**\n\t * Submits a new delta operation to the server\n\t */\n\tpublic submit(messages: IDocumentMessage[]): void {\n\t\t// We use a promise resolve to force a turn break given message processing is sync\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tPromise.resolve().then(() => {\n\t\t\tthis.emitMessages(\"submitOp\", [messages]);\n\t\t});\n\t}\n\n\t/**\n\t * Send a \"disconnect\" message on the socket.\n\t * @param disconnectReason - The reason of the disconnection.\n\t */\n\tpublic disconnectClient(disconnectReason: string): void {\n\t\tthis.socket.emit(\"disconnect\", disconnectReason);\n\t}\n\n\t/**\n\t * * Sends a \"nack\" message on the socket.\n\t * @param code - An error code number that represents the error. It will be a valid HTTP error code.\n\t * @param type - Type of the Nack.\n\t * @param message - A message about the nack for debugging/logging/telemetry purposes.\n\t */\n\tpublic nackClient(\n\t\tcode: number = 400,\n\t\ttype: NackErrorType = NackErrorType.ThrottlingError,\n\t\tmessage: any,\n\t): void {\n\t\tconst nackMessage = {\n\t\t\toperation: undefined,\n\t\t\tsequenceNumber: -1,\n\t\t\tcontent: {\n\t\t\t\tcode,\n\t\t\t\ttype,\n\t\t\t\tmessage,\n\t\t\t},\n\t\t};\n\t\tthis.socket.emit(\"nack\", \"\", [nackMessage]);\n\t}\n}\n"]}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
6
|
-
import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
7
|
-
import { IClient } from "@fluidframework/driver-definitions";
|
|
8
|
-
import { IDocumentDeltaConnection, IDocumentDeltaStorageService, IDocumentService, IDocumentServiceEvents, IDocumentServicePolicies, IDocumentStorageService, IResolvedUrl } from "@fluidframework/driver-definitions/internal";
|
|
9
|
-
import { ITokenProvider } from "@fluidframework/routerlicious-driver";
|
|
10
|
-
import { ILocalDeltaConnectionServer } from "@fluidframework/server-local-server";
|
|
6
|
+
import type { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
7
|
+
import type { IClient } from "@fluidframework/driver-definitions";
|
|
8
|
+
import type { IDocumentDeltaConnection, IDocumentDeltaStorageService, IDocumentService, IDocumentServiceEvents, IDocumentServicePolicies, IDocumentStorageService, IResolvedUrl } from "@fluidframework/driver-definitions/internal";
|
|
9
|
+
import type { ITokenProvider } from "@fluidframework/routerlicious-driver";
|
|
10
|
+
import type { ILocalDeltaConnectionServer } from "@fluidframework/server-local-server";
|
|
11
11
|
import { LocalDocumentDeltaConnection } from "./localDocumentDeltaConnection.js";
|
|
12
12
|
/**
|
|
13
13
|
* Basic implementation of a document service for local use.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localDocumentService.d.ts","sourceRoot":"","sources":["../src/localDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"localDocumentService.d.ts","sourceRoot":"","sources":["../src/localDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,KAAK,EACX,wBAAwB,EACxB,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,YAAY,EACZ,MAAM,6CAA6C,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAKvF,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAGjF;;;GAGG;AACH,qBAAa,oBACZ,SAAQ,iBAAiB,CAAC,sBAAsB,CAChD,YAAW,gBAAgB;aASV,WAAW,EAAE,YAAY;IACzC,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C7C,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;QAEH,OAAO,uBAAuB,CAAC;IAChC,CAAC;CACD;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CACzC,WAAyB,EACzB,0BAAuD,EACvD,aAA6B,EAC7B,QAAgB,EAChB,UAAkB,EAClB,2BAAsE,EACtE,QAAmC,EACnC,oBAAuC,EACvC,MAA6B;IAE7B,OAAO,IAAI,oBAAoB,CAC9B,WAAW,EACX,0BAA0B,EAC1B,aAAa,EACb,QAAQ,EACR,UAAU,EACV,2BAA2B,EAC3B,QAAQ,EACR,oBAAoB,EACpB,MAAM,CACN,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIDocumentServiceEvents,\n\tIDocumentServicePolicies,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ITokenProvider } from \"@fluidframework/routerlicious-driver\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport { GitManager } from \"@fluidframework/server-services-client\";\nimport { TestHistorian } from \"@fluidframework/server-test-utils\";\n\nimport { LocalDeltaStorageService } from \"./localDeltaStorageService.js\";\nimport { LocalDocumentDeltaConnection } from \"./localDocumentDeltaConnection.js\";\nimport { LocalDocumentStorageService } from \"./localDocumentStorageService.js\";\n\n/**\n * Basic implementation of a document service for local use.\n * @internal\n */\nexport class LocalDocumentService\n\textends TypedEventEmitter<IDocumentServiceEvents>\n\timplements IDocumentService\n{\n\t/**\n\t * @param localDeltaConnectionServer - delta connection server for ops\n\t * @param tokenProvider - token provider\n\t * @param tenantId - ID of tenant\n\t * @param documentId - ID of document\n\t */\n\tconstructor(\n\t\tpublic readonly resolvedUrl: IResolvedUrl,\n\t\tprivate readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,\n\t\tprivate readonly tokenProvider: ITokenProvider,\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly documentId: string,\n\t\tprivate readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>,\n\t\tpublic readonly policies: IDocumentServicePolicies = { supportGetSnapshotApi: true },\n\t\tprivate readonly innerDocumentService?: IDocumentService,\n\t\tprivate readonly logger?: ITelemetryBaseLogger,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic dispose(): void {}\n\n\t/**\n\t * Creates and returns a document storage service for local use.\n\t */\n\tpublic async connectToStorage(): Promise<IDocumentStorageService> {\n\t\treturn new LocalDocumentStorageService(\n\t\t\tthis.documentId,\n\t\t\tnew GitManager(\n\t\t\t\tnew TestHistorian(this.localDeltaConnectionServer.testDbFactory.testDatabase),\n\t\t\t),\n\t\t\t{\n\t\t\t\tmaximumCacheDurationMs: 432_000_000, // 5 days in ms. Not actually enforced but shouldn't matter for any local driver scenario\n\t\t\t},\n\t\t\tthis.localDeltaConnectionServer,\n\t\t\tthis.resolvedUrl,\n\t\t);\n\t}\n\n\t/**\n\t * Creates and returns a delta storage service for local use.\n\t */\n\tpublic async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n\t\tif (this.innerDocumentService) {\n\t\t\treturn this.innerDocumentService.connectToDeltaStorage();\n\t\t}\n\t\treturn new LocalDeltaStorageService(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t\tthis.localDeltaConnectionServer.databaseManager,\n\t\t);\n\t}\n\n\t/**\n\t * Creates and returns a delta stream for local use.\n\t * @param client - client data\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n\t\tif (this.policies.storageOnly === true) {\n\t\t\tthrow new Error(\"can't connect to delta stream in storage-only mode\");\n\t\t}\n\t\tif (this.innerDocumentService) {\n\t\t\treturn this.innerDocumentService.connectToDeltaStream(client);\n\t\t}\n\t\tconst ordererToken = await this.tokenProvider.fetchOrdererToken(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t);\n\t\tconst documentDeltaConnection = await LocalDocumentDeltaConnection.create(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t\tordererToken.jwt,\n\t\t\tclient,\n\t\t\tthis.localDeltaConnectionServer.webSocketServer,\n\t\t\tundefined,\n\t\t\tthis.logger,\n\t\t);\n\t\tconst clientId = documentDeltaConnection.clientId;\n\n\t\t// Add this document service for the clientId in the document service factory.\n\t\tthis.documentDeltaConnectionsMap.set(clientId, documentDeltaConnection);\n\n\t\t// Add a listener to remove this document service when the client is disconnected.\n\t\tdocumentDeltaConnection.on(\"disconnect\", () => {\n\t\t\tthis.documentDeltaConnectionsMap.delete(clientId);\n\t\t});\n\n\t\treturn documentDeltaConnection;\n\t}\n}\n\n/**\n * Creates and returns a document service for local use.\n * @param localDeltaConnectionServer - delta connection server for ops\n * @param tokenProvider - token provider with a single token\n * @param tenantId - ID of tenant\n * @param documentId - ID of document\n * @internal\n */\nexport function createLocalDocumentService(\n\tresolvedUrl: IResolvedUrl,\n\tlocalDeltaConnectionServer: ILocalDeltaConnectionServer,\n\ttokenProvider: ITokenProvider,\n\ttenantId: string,\n\tdocumentId: string,\n\tdocumentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>,\n\tpolicies?: IDocumentServicePolicies,\n\tinnerDocumentService?: IDocumentService,\n\tlogger?: ITelemetryBaseLogger,\n): IDocumentService {\n\treturn new LocalDocumentService(\n\t\tresolvedUrl,\n\t\tlocalDeltaConnectionServer,\n\t\ttokenProvider,\n\t\ttenantId,\n\t\tdocumentId,\n\t\tdocumentDeltaConnectionsMap,\n\t\tpolicies,\n\t\tinnerDocumentService,\n\t\tlogger,\n\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E,CAAC,YAAY,EAAE,GAAG,EAAE;YAC7C,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;QAEH,OAAO,uBAAuB,CAAC;IAChC,CAAC;CACD;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CACzC,WAAyB,EACzB,0BAAuD,EACvD,aAA6B,EAC7B,QAAgB,EAChB,UAAkB,EAClB,2BAAsE,EACtE,QAAmC,EACnC,oBAAuC,EACvC,MAA6B;IAE7B,OAAO,IAAI,oBAAoB,CAC9B,WAAW,EACX,0BAA0B,EAC1B,aAAa,EACb,QAAQ,EACR,UAAU,EACV,2BAA2B,EAC3B,QAAQ,EACR,oBAAoB,EACpB,MAAM,CACN,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport type { IClient } from \"@fluidframework/driver-definitions\";\nimport type {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIDocumentServiceEvents,\n\tIDocumentServicePolicies,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type { ITokenProvider } from \"@fluidframework/routerlicious-driver\";\nimport type { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport { GitManager } from \"@fluidframework/server-services-client\";\nimport { TestHistorian } from \"@fluidframework/server-test-utils\";\n\nimport { LocalDeltaStorageService } from \"./localDeltaStorageService.js\";\nimport { LocalDocumentDeltaConnection } from \"./localDocumentDeltaConnection.js\";\nimport { LocalDocumentStorageService } from \"./localDocumentStorageService.js\";\n\n/**\n * Basic implementation of a document service for local use.\n * @internal\n */\nexport class LocalDocumentService\n\textends TypedEventEmitter<IDocumentServiceEvents>\n\timplements IDocumentService\n{\n\t/**\n\t * @param localDeltaConnectionServer - delta connection server for ops\n\t * @param tokenProvider - token provider\n\t * @param tenantId - ID of tenant\n\t * @param documentId - ID of document\n\t */\n\tconstructor(\n\t\tpublic readonly resolvedUrl: IResolvedUrl,\n\t\tprivate readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,\n\t\tprivate readonly tokenProvider: ITokenProvider,\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly documentId: string,\n\t\tprivate readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>,\n\t\tpublic readonly policies: IDocumentServicePolicies = { supportGetSnapshotApi: true },\n\t\tprivate readonly innerDocumentService?: IDocumentService,\n\t\tprivate readonly logger?: ITelemetryBaseLogger,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic dispose(): void {}\n\n\t/**\n\t * Creates and returns a document storage service for local use.\n\t */\n\tpublic async connectToStorage(): Promise<IDocumentStorageService> {\n\t\treturn new LocalDocumentStorageService(\n\t\t\tthis.documentId,\n\t\t\tnew GitManager(\n\t\t\t\tnew TestHistorian(this.localDeltaConnectionServer.testDbFactory.testDatabase),\n\t\t\t),\n\t\t\t{\n\t\t\t\tmaximumCacheDurationMs: 432_000_000, // 5 days in ms. Not actually enforced but shouldn't matter for any local driver scenario\n\t\t\t},\n\t\t\tthis.localDeltaConnectionServer,\n\t\t\tthis.resolvedUrl,\n\t\t);\n\t}\n\n\t/**\n\t * Creates and returns a delta storage service for local use.\n\t */\n\tpublic async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n\t\tif (this.innerDocumentService) {\n\t\t\treturn this.innerDocumentService.connectToDeltaStorage();\n\t\t}\n\t\treturn new LocalDeltaStorageService(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t\tthis.localDeltaConnectionServer.databaseManager,\n\t\t);\n\t}\n\n\t/**\n\t * Creates and returns a delta stream for local use.\n\t * @param client - client data\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n\t\tif (this.policies.storageOnly === true) {\n\t\t\tthrow new Error(\"can't connect to delta stream in storage-only mode\");\n\t\t}\n\t\tif (this.innerDocumentService) {\n\t\t\treturn this.innerDocumentService.connectToDeltaStream(client);\n\t\t}\n\t\tconst ordererToken = await this.tokenProvider.fetchOrdererToken(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t);\n\t\tconst documentDeltaConnection = await LocalDocumentDeltaConnection.create(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t\tordererToken.jwt,\n\t\t\tclient,\n\t\t\tthis.localDeltaConnectionServer.webSocketServer,\n\t\t\tundefined,\n\t\t\tthis.logger,\n\t\t);\n\t\tconst clientId = documentDeltaConnection.clientId;\n\n\t\t// Add this document service for the clientId in the document service factory.\n\t\tthis.documentDeltaConnectionsMap.set(clientId, documentDeltaConnection);\n\n\t\t// Add a listener to remove this document service when the client is disconnected.\n\t\tdocumentDeltaConnection.on(\"disconnect\", () => {\n\t\t\tthis.documentDeltaConnectionsMap.delete(clientId);\n\t\t});\n\n\t\treturn documentDeltaConnection;\n\t}\n}\n\n/**\n * Creates and returns a document service for local use.\n * @param localDeltaConnectionServer - delta connection server for ops\n * @param tokenProvider - token provider with a single token\n * @param tenantId - ID of tenant\n * @param documentId - ID of document\n * @internal\n */\nexport function createLocalDocumentService(\n\tresolvedUrl: IResolvedUrl,\n\tlocalDeltaConnectionServer: ILocalDeltaConnectionServer,\n\ttokenProvider: ITokenProvider,\n\ttenantId: string,\n\tdocumentId: string,\n\tdocumentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>,\n\tpolicies?: IDocumentServicePolicies,\n\tinnerDocumentService?: IDocumentService,\n\tlogger?: ITelemetryBaseLogger,\n): IDocumentService {\n\treturn new LocalDocumentService(\n\t\tresolvedUrl,\n\t\tlocalDeltaConnectionServer,\n\t\ttokenProvider,\n\t\ttenantId,\n\t\tdocumentId,\n\t\tdocumentDeltaConnectionsMap,\n\t\tpolicies,\n\t\tinnerDocumentService,\n\t\tlogger,\n\t);\n}\n"]}
|
|
@@ -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 { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
6
|
-
import { ISummaryTree } from "@fluidframework/driver-definitions";
|
|
7
|
-
import { IDocumentService, IDocumentServiceFactory, IDocumentServicePolicies, IResolvedUrl, NackErrorType } from "@fluidframework/driver-definitions/internal";
|
|
8
|
-
import { ILocalDeltaConnectionServer } from "@fluidframework/server-local-server";
|
|
5
|
+
import type { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
6
|
+
import type { ISummaryTree } from "@fluidframework/driver-definitions";
|
|
7
|
+
import type { IDocumentService, IDocumentServiceFactory, IDocumentServicePolicies, IResolvedUrl, NackErrorType } from "@fluidframework/driver-definitions/internal";
|
|
8
|
+
import type { ILocalDeltaConnectionServer } from "@fluidframework/server-local-server";
|
|
9
9
|
/**
|
|
10
10
|
* Implementation of document service factory for local use.
|
|
11
11
|
* @legacy @beta
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/localDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"localDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/localDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,KAAK,EACX,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,YAAY,EACZ,aAAa,EACb,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,EAAE,CAAC,CAAC;QACvD,CAAC;QACD,uBAAuB,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIDocumentServicePolicies,\n\tIResolvedUrl,\n\tNackErrorType,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { DefaultTokenProvider } from \"@fluidframework/routerlicious-driver/internal\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\n\nimport { createDocument } from \"./localCreateDocument.js\";\nimport { LocalDocumentDeltaConnection } from \"./localDocumentDeltaConnection.js\";\nimport { createLocalDocumentService } from \"./localDocumentService.js\";\nimport { localDriverCompatDetailsForLoader } from \"./localLayerCompatState.js\";\n\n/**\n * Implementation of document service factory for local use.\n * @legacy @beta\n */\nexport class LocalDocumentServiceFactory implements IDocumentServiceFactory {\n\t// A map of clientId to LocalDocumentService.\n\tprivate readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection> =\n\t\tnew Map();\n\n\t/**\n\t * @param localDeltaConnectionServer - delta connection server for ops\n\t */\n\tconstructor(\n\t\tprivate readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,\n\t\tprivate readonly policies?: IDocumentServicePolicies,\n\t\tprivate readonly innerDocumentService?: IDocumentService,\n\t) {}\n\n\t/**\n\t * The compatibility details of the Local Driver layer that is exposed to the Loader layer\n\t * for validating Loader-Driver compatibility.\n\t * @remarks This is for internal use only.\n\t * The type of this should be ILayerCompatDetails. However, ILayerCompatDetails is internal and this class\n\t * is currently marked as legacy alpha. So, using unknown here.\n\t */\n\tpublic readonly ILayerCompatDetails?: unknown = localDriverCompatDetailsForLoader;\n\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tif (!this.localDeltaConnectionServer) {\n\t\t\tthrow new Error(\"Provide the localDeltaConnectionServer!!\");\n\t\t}\n\t\tif (createNewSummary !== undefined) {\n\t\t\tawait createDocument(this.localDeltaConnectionServer, resolvedUrl, createNewSummary);\n\t\t}\n\t\treturn this.createDocumentService(resolvedUrl, logger, clientIsSummarizer);\n\t}\n\n\t/**\n\t * Creates and returns a document service for testing using the given resolved\n\t * URL for the tenant ID, document ID, and token.\n\t * @param resolvedUrl - resolved URL of document\n\t */\n\tpublic async createDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tconst parsedUrl = new URL(resolvedUrl.url);\n\t\tconst [, tenantId, documentId] = parsedUrl.pathname ? parsedUrl.pathname.split(\"/\") : [];\n\t\tif (!documentId || !tenantId) {\n\t\t\tthrow new Error(\n\t\t\t\t`Couldn't parse resolved url. [documentId:${documentId}][tenantId:${tenantId}]`,\n\t\t\t);\n\t\t}\n\n\t\tconst fluidResolvedUrl = resolvedUrl;\n\t\tconst jwtToken = fluidResolvedUrl.tokens.jwt;\n\t\tif (!jwtToken) {\n\t\t\tthrow new Error(`Token was not provided.`);\n\t\t}\n\n\t\tconst tokenProvider = new DefaultTokenProvider(jwtToken);\n\n\t\treturn createLocalDocumentService(\n\t\t\tresolvedUrl,\n\t\t\tthis.localDeltaConnectionServer,\n\t\t\ttokenProvider,\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tthis.documentDeltaConnectionsMap,\n\t\t\tthis.policies,\n\t\t\tthis.innerDocumentService,\n\t\t\tlogger,\n\t\t);\n\t}\n\n\t/**\n\t * Gets the document delta connection for the clientId and asks it to disconnect the client.\n\t * @param clientId - The ID of the client to be disconnected.\n\t * @param disconnectReason - The reason of the disconnection.\n\t */\n\tpublic disconnectClient(clientId: string, disconnectReason: string): void {\n\t\tconst documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);\n\t\tif (documentDeltaConnection === undefined) {\n\t\t\tthrow new Error(`No client with the id: ${clientId}`);\n\t\t}\n\t\tdocumentDeltaConnection.disconnectClient(disconnectReason);\n\t}\n\n\t/**\n\t * Gets the document delta connection for the clientId and asks it to nack the client.\n\t * @param clientId - The ID of the client to be Nack'd.\n\t * @param code - An error code number that represents the error. It will be a valid HTTP error code.\n\t * @param type - Type of the Nack.\n\t * @param message - A message about the nack for debugging/logging/telemetry purposes.\n\t */\n\tpublic nackClient(\n\t\tclientId: string,\n\t\tcode?: number,\n\t\ttype?: NackErrorType,\n\t\tmessage?: any,\n\t): void {\n\t\tconst documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);\n\t\tif (documentDeltaConnection === undefined) {\n\t\t\tthrow new Error(`No client with the id: ${clientId}`);\n\t\t}\n\t\tdocumentDeltaConnection.nackClient(code, type, message);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"localDocumentServiceFactory.js","sourceRoot":"","sources":["../src/localDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,OAAO,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AAGrF,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,iCAAiC,EAAE,MAAM,4BAA4B,CAAC;AAE/E;;;GAGG;AACH,MAAM,OAAO,2BAA2B;IAKvC;;OAEG;IACH,YACkB,0BAAuD,EACvD,QAAmC,EACnC,oBAAuC;QAFvC,+BAA0B,GAA1B,0BAA0B,CAA6B;QACvD,aAAQ,GAAR,QAAQ,CAA2B;QACnC,yBAAoB,GAApB,oBAAo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C5C,CAAC;QAED,MAAM,aAAa,GAAG,IAAI,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAEzD,OAAO,0BAA0B,CAChC,WAAW,EACX,IAAI,CAAC,0BAA0B,EAC/B,aAAa,EACb,QAAQ,EACR,UAAU,EACV,IAAI,CAAC,2BAA2B,EAChC,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,oBAAoB,EACzB,MAAM,CACN,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,gBAAgB,CAAC,QAAgB,EAAE,gBAAwB;QACjE,MAAM,uBAAuB,GAAG,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,uBAAuB,KAAK,SAAS,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;QACvD,CAAC;QACD,uBAAuB,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;;OAMG;IACI,UAAU,CAChB,QAAgB,EAChB,IAAa,EACb,IAAoB,EACpB,OAAa;QAEb,MAAM,uBAAuB,GAAG,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,uBAAuB,KAAK,SAAS,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;QACvD,CAAC;QACD,uBAAuB,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport type { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport type {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIDocumentServicePolicies,\n\tIResolvedUrl,\n\tNackErrorType,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { DefaultTokenProvider } from \"@fluidframework/routerlicious-driver/internal\";\nimport type { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\n\nimport { createDocument } from \"./localCreateDocument.js\";\nimport type { LocalDocumentDeltaConnection } from \"./localDocumentDeltaConnection.js\";\nimport { createLocalDocumentService } from \"./localDocumentService.js\";\nimport { localDriverCompatDetailsForLoader } from \"./localLayerCompatState.js\";\n\n/**\n * Implementation of document service factory for local use.\n * @legacy @beta\n */\nexport class LocalDocumentServiceFactory implements IDocumentServiceFactory {\n\t// A map of clientId to LocalDocumentService.\n\tprivate readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection> =\n\t\tnew Map();\n\n\t/**\n\t * @param localDeltaConnectionServer - delta connection server for ops\n\t */\n\tconstructor(\n\t\tprivate readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,\n\t\tprivate readonly policies?: IDocumentServicePolicies,\n\t\tprivate readonly innerDocumentService?: IDocumentService,\n\t) {}\n\n\t/**\n\t * The compatibility details of the Local Driver layer that is exposed to the Loader layer\n\t * for validating Loader-Driver compatibility.\n\t * @remarks This is for internal use only.\n\t * The type of this should be ILayerCompatDetails. However, ILayerCompatDetails is internal and this class\n\t * is currently marked as legacy alpha. So, using unknown here.\n\t */\n\tpublic readonly ILayerCompatDetails?: unknown = localDriverCompatDetailsForLoader;\n\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tif (!this.localDeltaConnectionServer) {\n\t\t\tthrow new Error(\"Provide the localDeltaConnectionServer!!\");\n\t\t}\n\t\tif (createNewSummary !== undefined) {\n\t\t\tawait createDocument(this.localDeltaConnectionServer, resolvedUrl, createNewSummary);\n\t\t}\n\t\treturn this.createDocumentService(resolvedUrl, logger, clientIsSummarizer);\n\t}\n\n\t/**\n\t * Creates and returns a document service for testing using the given resolved\n\t * URL for the tenant ID, document ID, and token.\n\t * @param resolvedUrl - resolved URL of document\n\t */\n\tpublic async createDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tconst parsedUrl = new URL(resolvedUrl.url);\n\t\tconst [, tenantId, documentId] = parsedUrl.pathname ? parsedUrl.pathname.split(\"/\") : [];\n\t\tif (!documentId || !tenantId) {\n\t\t\tthrow new Error(\n\t\t\t\t`Couldn't parse resolved url. [documentId:${documentId}][tenantId:${tenantId}]`,\n\t\t\t);\n\t\t}\n\n\t\tconst fluidResolvedUrl = resolvedUrl;\n\t\tconst jwtToken = fluidResolvedUrl.tokens.jwt;\n\t\tif (!jwtToken) {\n\t\t\tthrow new Error(`Token was not provided.`);\n\t\t}\n\n\t\tconst tokenProvider = new DefaultTokenProvider(jwtToken);\n\n\t\treturn createLocalDocumentService(\n\t\t\tresolvedUrl,\n\t\t\tthis.localDeltaConnectionServer,\n\t\t\ttokenProvider,\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tthis.documentDeltaConnectionsMap,\n\t\t\tthis.policies,\n\t\t\tthis.innerDocumentService,\n\t\t\tlogger,\n\t\t);\n\t}\n\n\t/**\n\t * Gets the document delta connection for the clientId and asks it to disconnect the client.\n\t * @param clientId - The ID of the client to be disconnected.\n\t * @param disconnectReason - The reason of the disconnection.\n\t */\n\tpublic disconnectClient(clientId: string, disconnectReason: string): void {\n\t\tconst documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);\n\t\tif (documentDeltaConnection === undefined) {\n\t\t\tthrow new Error(`No client with the id: ${clientId}`);\n\t\t}\n\t\tdocumentDeltaConnection.disconnectClient(disconnectReason);\n\t}\n\n\t/**\n\t * Gets the document delta connection for the clientId and asks it to nack the client.\n\t * @param clientId - The ID of the client to be Nack'd.\n\t * @param code - An error code number that represents the error. It will be a valid HTTP error code.\n\t * @param type - Type of the Nack.\n\t * @param message - A message about the nack for debugging/logging/telemetry purposes.\n\t */\n\tpublic nackClient(\n\t\tclientId: string,\n\t\tcode?: number,\n\t\ttype?: NackErrorType,\n\t\tmessage?: any,\n\t): void {\n\t\tconst documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);\n\t\tif (documentDeltaConnection === undefined) {\n\t\t\tthrow new Error(`No client with the id: ${clientId}`);\n\t\t}\n\t\tdocumentDeltaConnection.nackClient(code, type, message);\n\t}\n}\n"]}
|