@fluidframework/tool-utils 2.0.0-dev.6.4.0.192049 → 2.0.0-dev.7.2.0.203917
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 +52 -0
- package/api-extractor.json +9 -1
- package/api-report/tool-utils.api.md +95 -0
- package/dist/httpHelpers.d.ts +3 -2
- package/dist/httpHelpers.d.ts.map +1 -1
- package/dist/odspTokenManager.d.ts +1 -1
- package/dist/odspTokenManager.d.ts.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/snapshotNormalizer.js +3 -1
- package/dist/snapshotNormalizer.js.map +1 -1
- package/dist/tool-utils-alpha.d.ts +92 -0
- package/dist/tool-utils-beta.d.ts +92 -0
- package/dist/tool-utils-public.d.ts +92 -0
- package/dist/tool-utils-untrimmed.d.ts +92 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/httpHelpers.d.ts +3 -2
- package/lib/httpHelpers.d.ts.map +1 -1
- package/lib/odspTokenManager.d.ts +1 -1
- package/lib/odspTokenManager.d.ts.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/snapshotNormalizer.js +3 -1
- package/lib/snapshotNormalizer.js.map +1 -1
- package/package.json +18 -19
- package/src/packageVersion.ts +1 -1
- package/src/snapshotNormalizer.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# @fluidframework/tool-utils
|
|
2
2
|
|
|
3
|
+
## 2.0.0-internal.7.1.0
|
|
4
|
+
|
|
5
|
+
Dependency updates only.
|
|
6
|
+
|
|
7
|
+
## 2.0.0-internal.7.0.0
|
|
8
|
+
|
|
9
|
+
### Major Changes
|
|
10
|
+
|
|
11
|
+
- Dependencies on @fluidframework/protocol-definitions package updated to 3.0.0 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
|
|
12
|
+
|
|
13
|
+
This included the following changes from the protocol-definitions release:
|
|
14
|
+
|
|
15
|
+
- Updating signal interfaces for some planned improvements. The intention is split the interface between signals
|
|
16
|
+
submitted by clients to the server and the resulting signals sent from the server to clients.
|
|
17
|
+
- A new optional type member is available on the ISignalMessage interface and a new ISentSignalMessage interface has
|
|
18
|
+
been added, which will be the typing for signals sent from the client to the server. Both extend a new
|
|
19
|
+
ISignalMessageBase interface that contains common members.
|
|
20
|
+
- The @fluidframework/common-definitions package dependency has been updated to version 1.0.0.
|
|
21
|
+
|
|
22
|
+
- Server upgrade: dependencies on Fluid server packages updated to 2.0.1 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
|
|
23
|
+
|
|
24
|
+
Dependencies on the following Fluid server package have been updated to version 2.0.1:
|
|
25
|
+
|
|
26
|
+
- @fluidframework/gitresources: 2.0.1
|
|
27
|
+
- @fluidframework/server-kafka-orderer: 2.0.1
|
|
28
|
+
- @fluidframework/server-lambdas: 2.0.1
|
|
29
|
+
- @fluidframework/server-lambdas-driver: 2.0.1
|
|
30
|
+
- @fluidframework/server-local-server: 2.0.1
|
|
31
|
+
- @fluidframework/server-memory-orderer: 2.0.1
|
|
32
|
+
- @fluidframework/protocol-base: 2.0.1
|
|
33
|
+
- @fluidframework/server-routerlicious: 2.0.1
|
|
34
|
+
- @fluidframework/server-routerlicious-base: 2.0.1
|
|
35
|
+
- @fluidframework/server-services: 2.0.1
|
|
36
|
+
- @fluidframework/server-services-client: 2.0.1
|
|
37
|
+
- @fluidframework/server-services-core: 2.0.1
|
|
38
|
+
- @fluidframework/server-services-ordering-kafkanode: 2.0.1
|
|
39
|
+
- @fluidframework/server-services-ordering-rdkafka: 2.0.1
|
|
40
|
+
- @fluidframework/server-services-ordering-zookeeper: 2.0.1
|
|
41
|
+
- @fluidframework/server-services-shared: 2.0.1
|
|
42
|
+
- @fluidframework/server-services-telemetry: 2.0.1
|
|
43
|
+
- @fluidframework/server-services-utils: 2.0.1
|
|
44
|
+
- @fluidframework/server-test-utils: 2.0.1
|
|
45
|
+
- tinylicious: 2.0.1
|
|
46
|
+
|
|
47
|
+
- Minimum TypeScript version now 5.1.6 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
|
|
48
|
+
|
|
49
|
+
The minimum supported TypeScript version for Fluid 2.0 clients is now 5.1.6.
|
|
50
|
+
|
|
51
|
+
## 2.0.0-internal.6.4.0
|
|
52
|
+
|
|
53
|
+
Dependency updates only.
|
|
54
|
+
|
|
3
55
|
## 2.0.0-internal.6.3.0
|
|
4
56
|
|
|
5
57
|
Dependency updates only.
|
package/api-extractor.json
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
-
"extends": "@fluidframework/build-common/api-extractor-
|
|
3
|
+
"extends": "@fluidframework/build-common/api-extractor-base.json",
|
|
4
|
+
"messages": {
|
|
5
|
+
"extractorMessageReporting": {
|
|
6
|
+
"ae-missing-release-tag": {
|
|
7
|
+
// TODO: Fix violations and remove this rule override
|
|
8
|
+
"logLevel": "none"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
4
12
|
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
## API Report File for "@fluidframework/tool-utils"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
import { IClientConfig } from '@fluidframework/odsp-doclib-utils';
|
|
8
|
+
import { IOdspTokens } from '@fluidframework/odsp-doclib-utils';
|
|
9
|
+
import { ITree } from '@fluidframework/protocol-definitions';
|
|
10
|
+
|
|
11
|
+
// @public
|
|
12
|
+
export const gcBlobPrefix = "__gc";
|
|
13
|
+
|
|
14
|
+
// @public (undocumented)
|
|
15
|
+
export const getMicrosoftConfiguration: () => IClientConfig;
|
|
16
|
+
|
|
17
|
+
// @public
|
|
18
|
+
export function getNormalizedSnapshot(snapshot: ITree, config?: ISnapshotNormalizerConfig): ITree;
|
|
19
|
+
|
|
20
|
+
// @public (undocumented)
|
|
21
|
+
export interface IAsyncCache<TKey, TValue> {
|
|
22
|
+
// (undocumented)
|
|
23
|
+
get(key: TKey): Promise<TValue | undefined>;
|
|
24
|
+
// (undocumented)
|
|
25
|
+
lock<T>(callback: () => Promise<T>): Promise<T>;
|
|
26
|
+
// (undocumented)
|
|
27
|
+
save(key: TKey, value: TValue): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// @public (undocumented)
|
|
31
|
+
export interface IOdspTokenManagerCacheKey {
|
|
32
|
+
// (undocumented)
|
|
33
|
+
readonly isPush: boolean;
|
|
34
|
+
// (undocumented)
|
|
35
|
+
readonly userOrServer: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// @public (undocumented)
|
|
39
|
+
export interface IResources {
|
|
40
|
+
// (undocumented)
|
|
41
|
+
tokens?: {
|
|
42
|
+
version?: number;
|
|
43
|
+
data: {
|
|
44
|
+
[key: string]: {
|
|
45
|
+
storage?: IOdspTokens;
|
|
46
|
+
push?: IOdspTokens;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// @public (undocumented)
|
|
53
|
+
export interface ISnapshotNormalizerConfig {
|
|
54
|
+
// (undocumented)
|
|
55
|
+
blobsToNormalize?: string[];
|
|
56
|
+
excludedChannelContentTypes?: string[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// @public (undocumented)
|
|
60
|
+
export function loadRC(): Promise<IResources>;
|
|
61
|
+
|
|
62
|
+
// @public (undocumented)
|
|
63
|
+
export function lockRC(): Promise<any>;
|
|
64
|
+
|
|
65
|
+
// @public (undocumented)
|
|
66
|
+
export type OdspTokenConfig = {
|
|
67
|
+
type: "password";
|
|
68
|
+
username: string;
|
|
69
|
+
password: string;
|
|
70
|
+
} | {
|
|
71
|
+
type: "browserLogin";
|
|
72
|
+
navigator: (url: string) => void;
|
|
73
|
+
redirectUriCallback?: (tokens: IOdspTokens) => Promise<string>;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// @public (undocumented)
|
|
77
|
+
export class OdspTokenManager {
|
|
78
|
+
constructor(tokenCache?: IAsyncCache<IOdspTokenManagerCacheKey, IOdspTokens> | undefined);
|
|
79
|
+
// (undocumented)
|
|
80
|
+
getOdspTokens(server: string, clientConfig: IClientConfig, tokenConfig: OdspTokenConfig, forceRefresh?: boolean, forceReauth?: boolean): Promise<IOdspTokens>;
|
|
81
|
+
// (undocumented)
|
|
82
|
+
getPushTokens(server: string, clientConfig: IClientConfig, tokenConfig: OdspTokenConfig, forceRefresh?: boolean, forceReauth?: boolean): Promise<IOdspTokens>;
|
|
83
|
+
// (undocumented)
|
|
84
|
+
updateTokensCache(key: IOdspTokenManagerCacheKey, value: IOdspTokens): Promise<void>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// @public (undocumented)
|
|
88
|
+
export const odspTokensCache: IAsyncCache<IOdspTokenManagerCacheKey, IOdspTokens>;
|
|
89
|
+
|
|
90
|
+
// @public (undocumented)
|
|
91
|
+
export function saveRC(rc: IResources): Promise<void>;
|
|
92
|
+
|
|
93
|
+
// (No @packageDocumentation comment for this package)
|
|
94
|
+
|
|
95
|
+
```
|
package/dist/httpHelpers.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
/// <reference types="node" />
|
|
6
|
+
/// <reference types="node" />
|
|
6
7
|
import http from "http";
|
|
7
8
|
import { Socket } from "net";
|
|
8
9
|
export interface ITrackedHttpServer {
|
|
@@ -11,8 +12,8 @@ export interface ITrackedHttpServer {
|
|
|
11
12
|
fullyClose(): void;
|
|
12
13
|
}
|
|
13
14
|
export declare function createTrackedServer(port: number, requestListener: http.RequestListener): ITrackedHttpServer;
|
|
14
|
-
export
|
|
15
|
-
export
|
|
15
|
+
export type OnceListenerHandler<T> = (req: http.IncomingMessage, res: http.ServerResponse) => Promise<T>;
|
|
16
|
+
export type OnceListenerResult<T> = Promise<() => Promise<T>>;
|
|
16
17
|
export declare const serverListenAndHandle: <T>(port: number, handler: OnceListenerHandler<T>) => OnceListenerResult<T>;
|
|
17
18
|
export declare const endResponse: (response: http.ServerResponse) => Promise<void>;
|
|
18
19
|
//# sourceMappingURL=httpHelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpHelpers.d.ts","sourceRoot":"","sources":["../src/httpHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG
|
|
1
|
+
{"version":3,"file":"httpHelpers.d.ts","sourceRoot":"","sources":["../src/httpHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAE7B,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,UAAU,IAAI,IAAI,CAAC;CACnB;AACD,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,MAAM,EACZ,eAAe,EAAE,IAAI,CAAC,eAAe,GACnC,kBAAkB,CAiBpB;AACD,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CACpC,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,GAAG,EAAE,IAAI,CAAC,cAAc,KACpB,OAAO,CAAC,CAAC,CAAC,CAAC;AAChB,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9D,eAAO,MAAM,qBAAqB,YAC3B,MAAM,2DAuBV,CAAC;AAEJ,eAAO,MAAM,WAAW,aAAoB,KAAK,cAAc,KAAG,QAAQ,IAAI,CAO3E,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { IOdspTokens, IClientConfig } from "@fluidframework/odsp-doclib-utils";
|
|
6
6
|
import { IAsyncCache } from "./fluidToolRC";
|
|
7
7
|
export declare const getMicrosoftConfiguration: () => IClientConfig;
|
|
8
|
-
export
|
|
8
|
+
export type OdspTokenConfig = {
|
|
9
9
|
type: "password";
|
|
10
10
|
username: string;
|
|
11
11
|
password: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspTokenManager.d.ts","sourceRoot":"","sources":["../src/odspTokenManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,WAAW,EACX,aAAa,EAOb,MAAM,mCAAmC,CAAC;AAI3C,OAAO,EAAE,WAAW,EAA0B,MAAM,eAAe,CAAC;AAOpE,eAAO,MAAM,yBAAyB,QAAO,aAe3C,CAAC;AAEH,
|
|
1
|
+
{"version":3,"file":"odspTokenManager.d.ts","sourceRoot":"","sources":["../src/odspTokenManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,WAAW,EACX,aAAa,EAOb,MAAM,mCAAmC,CAAC;AAI3C,OAAO,EAAE,WAAW,EAA0B,MAAM,eAAe,CAAC;AAOpE,eAAO,MAAM,yBAAyB,QAAO,aAe3C,CAAC;AAEH,MAAM,MAAM,eAAe,GACxB;IACA,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAChB,GACD;IACA,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;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const pkgName = "@fluidframework/tool-utils";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-dev.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-dev.7.2.0.203917";
|
|
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/tool-utils";
|
|
11
|
-
exports.pkgVersion = "2.0.0-dev.
|
|
11
|
+
exports.pkgVersion = "2.0.0-dev.7.2.0.203917";
|
|
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,4BAA4B,CAAC;AACvC,QAAA,UAAU,GAAG,wBAAwB,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/tool-utils\";\nexport const pkgVersion = \"2.0.0-dev.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,4BAA4B,CAAC;AACvC,QAAA,UAAU,GAAG,wBAAwB,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/tool-utils\";\nexport const pkgVersion = \"2.0.0-dev.7.2.0.203917\";\n"]}
|
|
@@ -170,7 +170,9 @@ function normalizeEntry(entry, config) {
|
|
|
170
170
|
case protocol_definitions_1.TreeEntry.Blob: {
|
|
171
171
|
let contents = entry.value.contents;
|
|
172
172
|
// If this blob has to be normalized or it's a GC blob, parse and sort the blob contents first.
|
|
173
|
-
if (
|
|
173
|
+
if (
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- ?? is not logically equivalent when .includes returns false.
|
|
175
|
+
config?.blobsToNormalize?.includes(entry.path) ||
|
|
174
176
|
entry.path.startsWith(exports.gcBlobPrefix)) {
|
|
175
177
|
contents = getNormalizedBlobContent(contents, entry.path);
|
|
176
178
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshotNormalizer.js","sourceRoot":"","sources":["../src/snapshotNormalizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiG;AACjG,+EAAoF;AAEpF,gFAAgF;AAChF,MAAM,gBAAgB,GAAG,WAAW,CAAC;AACrC,oDAAoD;AACvC,QAAA,YAAY,GAAG,MAAM,CAAC;AAanC;;;GAGG;AACH,SAAS,kBAAkB,CAAC,KAAY;IACvC,MAAM,WAAW,GAAU,EAAE,CAAC;IAC9B,iDAAiD;IACjD,KAAK,MAAM,OAAO,IAAI,KAAK,EAAE;QAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC3B,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;SAC9C;aAAM,IAAI,OAAO,YAAY,MAAM,EAAE;YACrC,WAAW,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;SAC/C;aAAM;YACN,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SAC1B;KACD;IAED,2GAA2G;IAC3G,iCAAiC;IACjC,MAAM,MAAM,GAAG,CAAC,KAAU,EAAE,KAAU,EAAE,EAAE;QACzC,MAAM,eAAe,GAAG,IAAI,CAAC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,EAAE;gBACtD,KAAK,MAAM,eAAe,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE;oBAClD,IACC,eAAe,CAAC,IAAI,KAAK,gCAAS,CAAC,IAAI;wBACvC,eAAe,CAAC,IAAI,KAAK,aAAa,EACrC;wBACD,MAAM,MAAM,GAAsB,IAAI,CAAC,KAAK,CAC3C,eAAe,CAAC,KAAK,CAAC,QAAQ,CAC9B,CAAC;wBACF,IAAI,MAAM,CAAC,IAAI,KAAK,gDAAgD,EAAE;4BACrE,OAAO,IAAI,4BAAa,CACvB,KAAK,CAAC,IAAI,EACV,eAAe,CAAC,qBAAqB,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAC3D,CAAC;yBACF;wBACD,IACC,MAAM,CAAC,IAAI,KAAK,SAAS;4BACzB,MAAM,CAAC,2BAA2B,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EACvD;4BACD,iDAAiD;4BACjD,OAAO,IAAI,4BAAa,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;yBACrE;qBACD;iBACD;aACD;YAED,OAAO,IAAI,4BAAa,CAAC,KAAK,CAAC,IAAI,EAAE,qBAAqB,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;SACjF;QACD,KAAK,gCAAS,CAAC,UAAU,CAAC,CAAC;YAC1B,OAAO,IAAI,kCAAmB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;SAC3D;QAED;YACC,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;KACvC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from \"@fluidframework/driver-utils\";\nimport { ITree, TreeEntry, ITreeEntry } from \"@fluidframework/protocol-definitions\";\n\n/** The name of the metadata blob added to the root of the container runtime. */\nconst metadataBlobName = \".metadata\";\n/** The prefix that all GC blob names start with. */\nexport const gcBlobPrefix = \"__gc\";\n\nexport interface ISnapshotNormalizerConfig {\n\t// The paths of blobs whose contents should be normalized.\n\tblobsToNormalize?: string[];\n\t/**\n\t * channel types who's content (non-attribute) blobs will be excluded.\n\t * this is used to exclude the content of channels who's content cannot be compared\n\t * as the content is non-deterministic between snapshot at the same sequence number.\n\t */\n\texcludedChannelContentTypes?: string[];\n}\n\n/**\n * Function that deep sorts an array. It handles cases where array elements are objects or arrays.\n * @returns the sorted array.\n */\nfunction getDeepSortedArray(array: any[]): any[] {\n\tconst sortedArray: any[] = [];\n\t// Sort arrays and objects, if any, in the array.\n\tfor (const element of array) {\n\t\tif (Array.isArray(element)) {\n\t\t\tsortedArray.push(getDeepSortedArray(element));\n\t\t} else if (element instanceof Object) {\n\t\t\tsortedArray.push(getDeepSortedObject(element));\n\t\t} else {\n\t\t\tsortedArray.push(element);\n\t\t}\n\t}\n\n\t// Now that all the arrays and objects in this array's elements have been sorted, sort it by comparing each\n\t// element's stringified version.\n\tconst sortFn = (elem1: any, elem2: any) => {\n\t\tconst serializedElem1 = JSON.stringify(elem1);\n\t\tconst serializedElem2 = JSON.stringify(elem2);\n\t\treturn serializedElem1.localeCompare(serializedElem2);\n\t};\n\n\treturn sortedArray.sort(sortFn);\n}\n\n/**\n * Function that deep sorts an object. It handles cases where object properties are arrays or objects.\n * @returns the sorted object.\n */\nfunction getDeepSortedObject(obj: any): any {\n\tconst sortedObj: any = {};\n\t// Sort the object keys first. Then sort arrays and objects, if any, in the object.\n\tconst keys = Object.keys(obj).sort();\n\tfor (const key of keys) {\n\t\tconst value = obj[key];\n\t\tif (Array.isArray(value)) {\n\t\t\tsortedObj[key] = getDeepSortedArray(value);\n\t\t} else if (value instanceof Object) {\n\t\t\tsortedObj[key] = getDeepSortedObject(value);\n\t\t} else {\n\t\t\tsortedObj[key] = value;\n\t\t}\n\t}\n\n\treturn sortedObj;\n}\n\n/**\n * Function that normalizes a blob's content. If the content is an object or an array, deep sorts them.\n * Special handling for certain runtime blobs, such as the \"gc\" blob.\n * @returns the normalized blob content.\n */\nfunction getNormalizedBlobContent(blobContent: string, blobName: string): string {\n\tlet content = blobContent;\n\tif (blobName.startsWith(gcBlobPrefix)) {\n\t\t// GC blobs may contain `unreferencedTimestampMs` for node that became unreferenced. This is the timestamp\n\t\t// of the last op processed or current timestamp and can differ between clients depending on when GC was run.\n\t\t// So, remove it for the purposes of comparing snapshots.\n\t\tconst gcState = JSON.parse(content);\n\t\tfor (const [, data] of Object.entries(gcState.gcNodes)) {\n\t\t\tdelete (data as any).unreferencedTimestampMs;\n\t\t}\n\t\tcontent = JSON.stringify(gcState);\n\t}\n\n\t/**\n\t * The metadata blob has \"summaryNumber\" or \"summaryCount\" that tells which summary this is for a container. It can\n\t * be different in summaries of two clients even if they are generated at the same sequence#. For instance, at seq#\n\t * 1000, if one client has summarized 10 times and other has summarizer 15 times, summaryNumber will be different\n\t * for them. So, update \"summaryNumber\" to 0 for purposes of comparing snapshots.\n\t */\n\tif (blobName === metadataBlobName) {\n\t\tconst metadata = JSON.parse(content);\n\t\tif (metadata.summaryNumber !== undefined) {\n\t\t\tmetadata.summaryNumber = 0;\n\t\t}\n\t\tif (metadata.summaryCount !== undefined) {\n\t\t\tmetadata.summaryCount = 0;\n\t\t}\n\t\t// \"telemetryDocumentId\" is not a deterministic property (random guid), so we need to set it to something consistent\n\t\tif (metadata.telemetryDocumentId !== undefined) {\n\t\t\tmetadata.telemetryDocumentId = \"x\";\n\t\t}\n\t\tcontent = JSON.stringify(metadata);\n\t}\n\n\t// Deep sort the content if it's parseable.\n\ttry {\n\t\tlet contentObj = JSON.parse(content);\n\t\tif (Array.isArray(contentObj)) {\n\t\t\tcontentObj = getDeepSortedArray(contentObj);\n\t\t} else if (contentObj instanceof Object) {\n\t\t\tcontentObj = getDeepSortedObject(contentObj);\n\t\t}\n\t\tcontent = JSON.stringify(contentObj);\n\t} catch {}\n\treturn content;\n}\n\n/**\n * Helper function that normalizes the given snapshot tree. It sorts objects and arrays in the snapshot. It also\n * normalizes certain blob contents for which the order of content does not matter. For example, garbage collection\n * blobs contains objects / arrays whose element order do not matter.\n * @param snapshot - The snapshot tree to normalize.\n * @param config - Configs to use when normalizing snapshot. For example, it can contain paths of blobs whose contents\n * should be normalized as well.\n * @returns a copy of the normalized snapshot tree.\n */\nexport function getNormalizedSnapshot(snapshot: ITree, config?: ISnapshotNormalizerConfig): ITree {\n\t// Merge blobs to normalize in the config with runtime blobs to normalize. The contents of these blobs will be\n\t// parsed and deep sorted.\n\tconst normalizedEntries: ITreeEntry[] = [];\n\n\t// The metadata blob in the root of the summary tree needs to be normalized.\n\tconst blobsToNormalize = [metadataBlobName, ...(config?.blobsToNormalize ?? [])];\n\tfor (const entry of snapshot.entries) {\n\t\tnormalizedEntries.push(normalizeEntry(entry, { ...config, blobsToNormalize }));\n\t}\n\n\t// Sort the tree entries based on their path.\n\tnormalizedEntries.sort((a, b) => a.path.localeCompare(b.path));\n\n\treturn {\n\t\tentries: normalizedEntries,\n\t\tid: snapshot.id,\n\t};\n}\n\nfunction normalizeMatrix(value: ITree): ITree {\n\tconst rows = value.entries.find((e) => e.path === \"rows\");\n\n\tif (!rows || !(\"entries\" in rows.value)) {\n\t\treturn value;\n\t}\n\n\tconst segments = rows.value.entries.find((e) => e.path === \"segments\");\n\n\tif (!segments || !(\"entries\" in segments.value)) {\n\t\treturn value;\n\t}\n\n\tconst header = segments.value.entries.find((e) => e.path === \"header\");\n\n\tif (!header || !(\"contents\" in header.value)) {\n\t\treturn value;\n\t}\n\n\tif (!header?.value.contents.includes(\"removedClientId\")) {\n\t\treturn value;\n\t}\n\n\tconst contents = JSON.parse(header?.value.contents);\n\n\tfor (const segment of contents.segments) {\n\t\tif (\"removedClientId\" in segment) {\n\t\t\tsegment.removedClientId = undefined;\n\t\t}\n\n\t\tif (\"removedClientIds\" in segment) {\n\t\t\tsegment.removedClientIds = undefined;\n\t\t}\n\t}\n\n\theader.value.contents = JSON.stringify(contents);\n\n\treturn value;\n}\n\nfunction normalizeEntry(\n\tentry: ITreeEntry,\n\tconfig: ISnapshotNormalizerConfig | undefined,\n): ITreeEntry {\n\tswitch (entry.type) {\n\t\tcase TreeEntry.Blob: {\n\t\t\tlet contents = entry.value.contents;\n\t\t\t// If this blob has to be normalized or it's a GC blob, parse and sort the blob contents first.\n\t\t\tif (\n\t\t\t\tconfig?.blobsToNormalize?.includes(entry.path) ||\n\t\t\t\tentry.path.startsWith(gcBlobPrefix)\n\t\t\t) {\n\t\t\t\tcontents = getNormalizedBlobContent(contents, entry.path);\n\t\t\t}\n\t\t\treturn new BlobTreeEntry(entry.path, contents);\n\t\t}\n\t\tcase TreeEntry.Tree: {\n\t\t\tif (config?.excludedChannelContentTypes !== undefined) {\n\t\t\t\tfor (const maybeAttributes of entry.value.entries) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tmaybeAttributes.type === TreeEntry.Blob &&\n\t\t\t\t\t\tmaybeAttributes.path === \".attributes\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst parsed: { type?: string } = JSON.parse(\n\t\t\t\t\t\t\tmaybeAttributes.value.contents,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (parsed.type === \"https://graph.microsoft.com/types/sharedmatrix\") {\n\t\t\t\t\t\t\treturn new TreeTreeEntry(\n\t\t\t\t\t\t\t\tentry.path,\n\t\t\t\t\t\t\t\tnormalizeMatrix(getNormalizedSnapshot(entry.value, config)),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tparsed.type !== undefined &&\n\t\t\t\t\t\t\tconfig.excludedChannelContentTypes.includes(parsed.type)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// remove everything to match the unknown channel\n\t\t\t\t\t\t\treturn new TreeTreeEntry(entry.path, { entries: [maybeAttributes] });\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn new TreeTreeEntry(entry.path, getNormalizedSnapshot(entry.value, config));\n\t\t}\n\t\tcase TreeEntry.Attachment: {\n\t\t\treturn new AttachmentTreeEntry(entry.path, entry.value.id);\n\t\t}\n\n\t\tdefault:\n\t\t\tthrow new Error(\"Unknown entry type\");\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"snapshotNormalizer.js","sourceRoot":"","sources":["../src/snapshotNormalizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAiG;AACjG,+EAAoF;AAEpF,gFAAgF;AAChF,MAAM,gBAAgB,GAAG,WAAW,CAAC;AACrC,oDAAoD;AACvC,QAAA,YAAY,GAAG,MAAM,CAAC;AAanC;;;GAGG;AACH,SAAS,kBAAkB,CAAC,KAAY;IACvC,MAAM,WAAW,GAAU,EAAE,CAAC;IAC9B,iDAAiD;IACjD,KAAK,MAAM,OAAO,IAAI,KAAK,EAAE;QAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC3B,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;SAC9C;aAAM,IAAI,OAAO,YAAY,MAAM,EAAE;YACrC,WAAW,CAAC,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;SAC/C;aAAM;YACN,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SAC1B;KACD;IAED,2GAA2G;IAC3G,iCAAiC;IACjC,MAAM,MAAM,GAAG,CAAC,KAAU,EAAE,KAAU,EAAE,EAAE;QACzC,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC9C,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC9C,OAAO,eAAe,CAAC,aAAa,CAAC,eAAe,CAA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BACvC,eAAe,CAAC,IAAI,KAAK,aAAa,EACrC;wBACD,MAAM,MAAM,GAAsB,IAAI,CAAC,KAAK,CAC3C,eAAe,CAAC,KAAK,CAAC,QAAQ,CAC9B,CAAC;wBACF,IAAI,MAAM,CAAC,IAAI,KAAK,gDAAgD,EAAE;4BACrE,OAAO,IAAI,4BAAa,CACvB,KAAK,CAAC,IAAI,EACV,eAAe,CAAC,qBAAqB,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAC3D,CAAC;yBACF;wBACD,IACC,MAAM,CAAC,IAAI,KAAK,SAAS;4BACzB,MAAM,CAAC,2BAA2B,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EACvD;4BACD,iDAAiD;4BACjD,OAAO,IAAI,4BAAa,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;yBACrE;qBACD;iBACD;aACD;YAED,OAAO,IAAI,4BAAa,CAAC,KAAK,CAAC,IAAI,EAAE,qBAAqB,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;SACjF;QACD,KAAK,gCAAS,CAAC,UAAU,CAAC,CAAC;YAC1B,OAAO,IAAI,kCAAmB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;SAC3D;QAED;YACC,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;KACvC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from \"@fluidframework/driver-utils\";\nimport { ITree, TreeEntry, ITreeEntry } from \"@fluidframework/protocol-definitions\";\n\n/** The name of the metadata blob added to the root of the container runtime. */\nconst metadataBlobName = \".metadata\";\n/** The prefix that all GC blob names start with. */\nexport const gcBlobPrefix = \"__gc\";\n\nexport interface ISnapshotNormalizerConfig {\n\t// The paths of blobs whose contents should be normalized.\n\tblobsToNormalize?: string[];\n\t/**\n\t * channel types who's content (non-attribute) blobs will be excluded.\n\t * this is used to exclude the content of channels who's content cannot be compared\n\t * as the content is non-deterministic between snapshot at the same sequence number.\n\t */\n\texcludedChannelContentTypes?: string[];\n}\n\n/**\n * Function that deep sorts an array. It handles cases where array elements are objects or arrays.\n * @returns the sorted array.\n */\nfunction getDeepSortedArray(array: any[]): any[] {\n\tconst sortedArray: any[] = [];\n\t// Sort arrays and objects, if any, in the array.\n\tfor (const element of array) {\n\t\tif (Array.isArray(element)) {\n\t\t\tsortedArray.push(getDeepSortedArray(element));\n\t\t} else if (element instanceof Object) {\n\t\t\tsortedArray.push(getDeepSortedObject(element));\n\t\t} else {\n\t\t\tsortedArray.push(element);\n\t\t}\n\t}\n\n\t// Now that all the arrays and objects in this array's elements have been sorted, sort it by comparing each\n\t// element's stringified version.\n\tconst sortFn = (elem1: any, elem2: any) => {\n\t\tconst serializedElem1 = JSON.stringify(elem1);\n\t\tconst serializedElem2 = JSON.stringify(elem2);\n\t\treturn serializedElem1.localeCompare(serializedElem2);\n\t};\n\n\treturn sortedArray.sort(sortFn);\n}\n\n/**\n * Function that deep sorts an object. It handles cases where object properties are arrays or objects.\n * @returns the sorted object.\n */\nfunction getDeepSortedObject(obj: any): any {\n\tconst sortedObj: any = {};\n\t// Sort the object keys first. Then sort arrays and objects, if any, in the object.\n\tconst keys = Object.keys(obj).sort();\n\tfor (const key of keys) {\n\t\tconst value = obj[key];\n\t\tif (Array.isArray(value)) {\n\t\t\tsortedObj[key] = getDeepSortedArray(value);\n\t\t} else if (value instanceof Object) {\n\t\t\tsortedObj[key] = getDeepSortedObject(value);\n\t\t} else {\n\t\t\tsortedObj[key] = value;\n\t\t}\n\t}\n\n\treturn sortedObj;\n}\n\n/**\n * Function that normalizes a blob's content. If the content is an object or an array, deep sorts them.\n * Special handling for certain runtime blobs, such as the \"gc\" blob.\n * @returns the normalized blob content.\n */\nfunction getNormalizedBlobContent(blobContent: string, blobName: string): string {\n\tlet content = blobContent;\n\tif (blobName.startsWith(gcBlobPrefix)) {\n\t\t// GC blobs may contain `unreferencedTimestampMs` for node that became unreferenced. This is the timestamp\n\t\t// of the last op processed or current timestamp and can differ between clients depending on when GC was run.\n\t\t// So, remove it for the purposes of comparing snapshots.\n\t\tconst gcState = JSON.parse(content);\n\t\tfor (const [, data] of Object.entries(gcState.gcNodes)) {\n\t\t\tdelete (data as any).unreferencedTimestampMs;\n\t\t}\n\t\tcontent = JSON.stringify(gcState);\n\t}\n\n\t/**\n\t * The metadata blob has \"summaryNumber\" or \"summaryCount\" that tells which summary this is for a container. It can\n\t * be different in summaries of two clients even if they are generated at the same sequence#. For instance, at seq#\n\t * 1000, if one client has summarized 10 times and other has summarizer 15 times, summaryNumber will be different\n\t * for them. So, update \"summaryNumber\" to 0 for purposes of comparing snapshots.\n\t */\n\tif (blobName === metadataBlobName) {\n\t\tconst metadata = JSON.parse(content);\n\t\tif (metadata.summaryNumber !== undefined) {\n\t\t\tmetadata.summaryNumber = 0;\n\t\t}\n\t\tif (metadata.summaryCount !== undefined) {\n\t\t\tmetadata.summaryCount = 0;\n\t\t}\n\t\t// \"telemetryDocumentId\" is not a deterministic property (random guid), so we need to set it to something consistent\n\t\tif (metadata.telemetryDocumentId !== undefined) {\n\t\t\tmetadata.telemetryDocumentId = \"x\";\n\t\t}\n\t\tcontent = JSON.stringify(metadata);\n\t}\n\n\t// Deep sort the content if it's parseable.\n\ttry {\n\t\tlet contentObj = JSON.parse(content);\n\t\tif (Array.isArray(contentObj)) {\n\t\t\tcontentObj = getDeepSortedArray(contentObj);\n\t\t} else if (contentObj instanceof Object) {\n\t\t\tcontentObj = getDeepSortedObject(contentObj);\n\t\t}\n\t\tcontent = JSON.stringify(contentObj);\n\t} catch {}\n\treturn content;\n}\n\n/**\n * Helper function that normalizes the given snapshot tree. It sorts objects and arrays in the snapshot. It also\n * normalizes certain blob contents for which the order of content does not matter. For example, garbage collection\n * blobs contains objects / arrays whose element order do not matter.\n * @param snapshot - The snapshot tree to normalize.\n * @param config - Configs to use when normalizing snapshot. For example, it can contain paths of blobs whose contents\n * should be normalized as well.\n * @returns a copy of the normalized snapshot tree.\n */\nexport function getNormalizedSnapshot(snapshot: ITree, config?: ISnapshotNormalizerConfig): ITree {\n\t// Merge blobs to normalize in the config with runtime blobs to normalize. The contents of these blobs will be\n\t// parsed and deep sorted.\n\tconst normalizedEntries: ITreeEntry[] = [];\n\n\t// The metadata blob in the root of the summary tree needs to be normalized.\n\tconst blobsToNormalize = [metadataBlobName, ...(config?.blobsToNormalize ?? [])];\n\tfor (const entry of snapshot.entries) {\n\t\tnormalizedEntries.push(normalizeEntry(entry, { ...config, blobsToNormalize }));\n\t}\n\n\t// Sort the tree entries based on their path.\n\tnormalizedEntries.sort((a, b) => a.path.localeCompare(b.path));\n\n\treturn {\n\t\tentries: normalizedEntries,\n\t\tid: snapshot.id,\n\t};\n}\n\nfunction normalizeMatrix(value: ITree): ITree {\n\tconst rows = value.entries.find((e) => e.path === \"rows\");\n\n\tif (!rows || !(\"entries\" in rows.value)) {\n\t\treturn value;\n\t}\n\n\tconst segments = rows.value.entries.find((e) => e.path === \"segments\");\n\n\tif (!segments || !(\"entries\" in segments.value)) {\n\t\treturn value;\n\t}\n\n\tconst header = segments.value.entries.find((e) => e.path === \"header\");\n\n\tif (!header || !(\"contents\" in header.value)) {\n\t\treturn value;\n\t}\n\n\tif (!header?.value.contents.includes(\"removedClientId\")) {\n\t\treturn value;\n\t}\n\n\tconst contents = JSON.parse(header?.value.contents);\n\n\tfor (const segment of contents.segments) {\n\t\tif (\"removedClientId\" in segment) {\n\t\t\tsegment.removedClientId = undefined;\n\t\t}\n\n\t\tif (\"removedClientIds\" in segment) {\n\t\t\tsegment.removedClientIds = undefined;\n\t\t}\n\t}\n\n\theader.value.contents = JSON.stringify(contents);\n\n\treturn value;\n}\n\nfunction normalizeEntry(\n\tentry: ITreeEntry,\n\tconfig: ISnapshotNormalizerConfig | undefined,\n): ITreeEntry {\n\tswitch (entry.type) {\n\t\tcase TreeEntry.Blob: {\n\t\t\tlet contents = entry.value.contents;\n\t\t\t// If this blob has to be normalized or it's a GC blob, parse and sort the blob contents first.\n\t\t\tif (\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- ?? is not logically equivalent when .includes returns false.\n\t\t\t\tconfig?.blobsToNormalize?.includes(entry.path) ||\n\t\t\t\tentry.path.startsWith(gcBlobPrefix)\n\t\t\t) {\n\t\t\t\tcontents = getNormalizedBlobContent(contents, entry.path);\n\t\t\t}\n\t\t\treturn new BlobTreeEntry(entry.path, contents);\n\t\t}\n\t\tcase TreeEntry.Tree: {\n\t\t\tif (config?.excludedChannelContentTypes !== undefined) {\n\t\t\t\tfor (const maybeAttributes of entry.value.entries) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tmaybeAttributes.type === TreeEntry.Blob &&\n\t\t\t\t\t\tmaybeAttributes.path === \".attributes\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst parsed: { type?: string } = JSON.parse(\n\t\t\t\t\t\t\tmaybeAttributes.value.contents,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (parsed.type === \"https://graph.microsoft.com/types/sharedmatrix\") {\n\t\t\t\t\t\t\treturn new TreeTreeEntry(\n\t\t\t\t\t\t\t\tentry.path,\n\t\t\t\t\t\t\t\tnormalizeMatrix(getNormalizedSnapshot(entry.value, config)),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tparsed.type !== undefined &&\n\t\t\t\t\t\t\tconfig.excludedChannelContentTypes.includes(parsed.type)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// remove everything to match the unknown channel\n\t\t\t\t\t\t\treturn new TreeTreeEntry(entry.path, { entries: [maybeAttributes] });\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn new TreeTreeEntry(entry.path, getNormalizedSnapshot(entry.value, config));\n\t\t}\n\t\tcase TreeEntry.Attachment: {\n\t\t\treturn new AttachmentTreeEntry(entry.path, entry.value.id);\n\t\t}\n\n\t\tdefault:\n\t\t\tthrow new Error(\"Unknown entry type\");\n\t}\n}\n"]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { IClientConfig } from '@fluidframework/odsp-doclib-utils';
|
|
2
|
+
import { IOdspTokens } from '@fluidframework/odsp-doclib-utils';
|
|
3
|
+
import { ITree } from '@fluidframework/protocol-definitions';
|
|
4
|
+
|
|
5
|
+
/** The prefix that all GC blob names start with. */
|
|
6
|
+
export declare const gcBlobPrefix = "__gc";
|
|
7
|
+
|
|
8
|
+
export declare const getMicrosoftConfiguration: () => IClientConfig;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Helper function that normalizes the given snapshot tree. It sorts objects and arrays in the snapshot. It also
|
|
12
|
+
* normalizes certain blob contents for which the order of content does not matter. For example, garbage collection
|
|
13
|
+
* blobs contains objects / arrays whose element order do not matter.
|
|
14
|
+
* @param snapshot - The snapshot tree to normalize.
|
|
15
|
+
* @param config - Configs to use when normalizing snapshot. For example, it can contain paths of blobs whose contents
|
|
16
|
+
* should be normalized as well.
|
|
17
|
+
* @returns a copy of the normalized snapshot tree.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getNormalizedSnapshot(snapshot: ITree, config?: ISnapshotNormalizerConfig): ITree;
|
|
20
|
+
|
|
21
|
+
export declare interface IAsyncCache<TKey, TValue> {
|
|
22
|
+
get(key: TKey): Promise<TValue | undefined>;
|
|
23
|
+
save(key: TKey, value: TValue): Promise<void>;
|
|
24
|
+
lock<T>(callback: () => Promise<T>): Promise<T>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export declare interface IOdspTokenManagerCacheKey {
|
|
28
|
+
readonly isPush: boolean;
|
|
29
|
+
readonly userOrServer: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export declare interface IResources {
|
|
33
|
+
tokens?: {
|
|
34
|
+
version?: number;
|
|
35
|
+
data: {
|
|
36
|
+
[key: string]: {
|
|
37
|
+
storage?: IOdspTokens;
|
|
38
|
+
push?: IOdspTokens;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export declare interface ISnapshotNormalizerConfig {
|
|
45
|
+
blobsToNormalize?: string[];
|
|
46
|
+
/**
|
|
47
|
+
* channel types who's content (non-attribute) blobs will be excluded.
|
|
48
|
+
* this is used to exclude the content of channels who's content cannot be compared
|
|
49
|
+
* as the content is non-deterministic between snapshot at the same sequence number.
|
|
50
|
+
*/
|
|
51
|
+
excludedChannelContentTypes?: string[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export declare function loadRC(): Promise<IResources>;
|
|
55
|
+
|
|
56
|
+
export declare function lockRC(): Promise<any>;
|
|
57
|
+
|
|
58
|
+
export declare type OdspTokenConfig = {
|
|
59
|
+
type: "password";
|
|
60
|
+
username: string;
|
|
61
|
+
password: string;
|
|
62
|
+
} | {
|
|
63
|
+
type: "browserLogin";
|
|
64
|
+
navigator: (url: string) => void;
|
|
65
|
+
redirectUriCallback?: (tokens: IOdspTokens) => Promise<string>;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export declare class OdspTokenManager {
|
|
69
|
+
private readonly tokenCache?;
|
|
70
|
+
private readonly storageCache;
|
|
71
|
+
private readonly pushCache;
|
|
72
|
+
private readonly cacheMutex;
|
|
73
|
+
constructor(tokenCache?: IAsyncCache<IOdspTokenManagerCacheKey, IOdspTokens> | undefined);
|
|
74
|
+
updateTokensCache(key: IOdspTokenManagerCacheKey, value: IOdspTokens): Promise<void>;
|
|
75
|
+
private updateTokensCacheWithoutLock;
|
|
76
|
+
getOdspTokens(server: string, clientConfig: IClientConfig, tokenConfig: OdspTokenConfig, forceRefresh?: boolean, forceReauth?: boolean): Promise<IOdspTokens>;
|
|
77
|
+
getPushTokens(server: string, clientConfig: IClientConfig, tokenConfig: OdspTokenConfig, forceRefresh?: boolean, forceReauth?: boolean): Promise<IOdspTokens>;
|
|
78
|
+
private getTokenFromCache;
|
|
79
|
+
private static getCacheKey;
|
|
80
|
+
private getTokens;
|
|
81
|
+
private getTokensCore;
|
|
82
|
+
private acquireTokensWithPassword;
|
|
83
|
+
private acquireTokensViaBrowserLogin;
|
|
84
|
+
private onTokenRetrievalFromCache;
|
|
85
|
+
private extractAuthorizationCode;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export declare const odspTokensCache: IAsyncCache<IOdspTokenManagerCacheKey, IOdspTokens>;
|
|
89
|
+
|
|
90
|
+
export declare function saveRC(rc: IResources): Promise<void>;
|
|
91
|
+
|
|
92
|
+
export { }
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { IClientConfig } from '@fluidframework/odsp-doclib-utils';
|
|
2
|
+
import { IOdspTokens } from '@fluidframework/odsp-doclib-utils';
|
|
3
|
+
import { ITree } from '@fluidframework/protocol-definitions';
|
|
4
|
+
|
|
5
|
+
/** The prefix that all GC blob names start with. */
|
|
6
|
+
export declare const gcBlobPrefix = "__gc";
|
|
7
|
+
|
|
8
|
+
export declare const getMicrosoftConfiguration: () => IClientConfig;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Helper function that normalizes the given snapshot tree. It sorts objects and arrays in the snapshot. It also
|
|
12
|
+
* normalizes certain blob contents for which the order of content does not matter. For example, garbage collection
|
|
13
|
+
* blobs contains objects / arrays whose element order do not matter.
|
|
14
|
+
* @param snapshot - The snapshot tree to normalize.
|
|
15
|
+
* @param config - Configs to use when normalizing snapshot. For example, it can contain paths of blobs whose contents
|
|
16
|
+
* should be normalized as well.
|
|
17
|
+
* @returns a copy of the normalized snapshot tree.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getNormalizedSnapshot(snapshot: ITree, config?: ISnapshotNormalizerConfig): ITree;
|
|
20
|
+
|
|
21
|
+
export declare interface IAsyncCache<TKey, TValue> {
|
|
22
|
+
get(key: TKey): Promise<TValue | undefined>;
|
|
23
|
+
save(key: TKey, value: TValue): Promise<void>;
|
|
24
|
+
lock<T>(callback: () => Promise<T>): Promise<T>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export declare interface IOdspTokenManagerCacheKey {
|
|
28
|
+
readonly isPush: boolean;
|
|
29
|
+
readonly userOrServer: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export declare interface IResources {
|
|
33
|
+
tokens?: {
|
|
34
|
+
version?: number;
|
|
35
|
+
data: {
|
|
36
|
+
[key: string]: {
|
|
37
|
+
storage?: IOdspTokens;
|
|
38
|
+
push?: IOdspTokens;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export declare interface ISnapshotNormalizerConfig {
|
|
45
|
+
blobsToNormalize?: string[];
|
|
46
|
+
/**
|
|
47
|
+
* channel types who's content (non-attribute) blobs will be excluded.
|
|
48
|
+
* this is used to exclude the content of channels who's content cannot be compared
|
|
49
|
+
* as the content is non-deterministic between snapshot at the same sequence number.
|
|
50
|
+
*/
|
|
51
|
+
excludedChannelContentTypes?: string[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export declare function loadRC(): Promise<IResources>;
|
|
55
|
+
|
|
56
|
+
export declare function lockRC(): Promise<any>;
|
|
57
|
+
|
|
58
|
+
export declare type OdspTokenConfig = {
|
|
59
|
+
type: "password";
|
|
60
|
+
username: string;
|
|
61
|
+
password: string;
|
|
62
|
+
} | {
|
|
63
|
+
type: "browserLogin";
|
|
64
|
+
navigator: (url: string) => void;
|
|
65
|
+
redirectUriCallback?: (tokens: IOdspTokens) => Promise<string>;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export declare class OdspTokenManager {
|
|
69
|
+
private readonly tokenCache?;
|
|
70
|
+
private readonly storageCache;
|
|
71
|
+
private readonly pushCache;
|
|
72
|
+
private readonly cacheMutex;
|
|
73
|
+
constructor(tokenCache?: IAsyncCache<IOdspTokenManagerCacheKey, IOdspTokens> | undefined);
|
|
74
|
+
updateTokensCache(key: IOdspTokenManagerCacheKey, value: IOdspTokens): Promise<void>;
|
|
75
|
+
private updateTokensCacheWithoutLock;
|
|
76
|
+
getOdspTokens(server: string, clientConfig: IClientConfig, tokenConfig: OdspTokenConfig, forceRefresh?: boolean, forceReauth?: boolean): Promise<IOdspTokens>;
|
|
77
|
+
getPushTokens(server: string, clientConfig: IClientConfig, tokenConfig: OdspTokenConfig, forceRefresh?: boolean, forceReauth?: boolean): Promise<IOdspTokens>;
|
|
78
|
+
private getTokenFromCache;
|
|
79
|
+
private static getCacheKey;
|
|
80
|
+
private getTokens;
|
|
81
|
+
private getTokensCore;
|
|
82
|
+
private acquireTokensWithPassword;
|
|
83
|
+
private acquireTokensViaBrowserLogin;
|
|
84
|
+
private onTokenRetrievalFromCache;
|
|
85
|
+
private extractAuthorizationCode;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export declare const odspTokensCache: IAsyncCache<IOdspTokenManagerCacheKey, IOdspTokens>;
|
|
89
|
+
|
|
90
|
+
export declare function saveRC(rc: IResources): Promise<void>;
|
|
91
|
+
|
|
92
|
+
export { }
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { IClientConfig } from '@fluidframework/odsp-doclib-utils';
|
|
2
|
+
import { IOdspTokens } from '@fluidframework/odsp-doclib-utils';
|
|
3
|
+
import { ITree } from '@fluidframework/protocol-definitions';
|
|
4
|
+
|
|
5
|
+
/** The prefix that all GC blob names start with. */
|
|
6
|
+
export declare const gcBlobPrefix = "__gc";
|
|
7
|
+
|
|
8
|
+
export declare const getMicrosoftConfiguration: () => IClientConfig;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Helper function that normalizes the given snapshot tree. It sorts objects and arrays in the snapshot. It also
|
|
12
|
+
* normalizes certain blob contents for which the order of content does not matter. For example, garbage collection
|
|
13
|
+
* blobs contains objects / arrays whose element order do not matter.
|
|
14
|
+
* @param snapshot - The snapshot tree to normalize.
|
|
15
|
+
* @param config - Configs to use when normalizing snapshot. For example, it can contain paths of blobs whose contents
|
|
16
|
+
* should be normalized as well.
|
|
17
|
+
* @returns a copy of the normalized snapshot tree.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getNormalizedSnapshot(snapshot: ITree, config?: ISnapshotNormalizerConfig): ITree;
|
|
20
|
+
|
|
21
|
+
export declare interface IAsyncCache<TKey, TValue> {
|
|
22
|
+
get(key: TKey): Promise<TValue | undefined>;
|
|
23
|
+
save(key: TKey, value: TValue): Promise<void>;
|
|
24
|
+
lock<T>(callback: () => Promise<T>): Promise<T>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export declare interface IOdspTokenManagerCacheKey {
|
|
28
|
+
readonly isPush: boolean;
|
|
29
|
+
readonly userOrServer: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export declare interface IResources {
|
|
33
|
+
tokens?: {
|
|
34
|
+
version?: number;
|
|
35
|
+
data: {
|
|
36
|
+
[key: string]: {
|
|
37
|
+
storage?: IOdspTokens;
|
|
38
|
+
push?: IOdspTokens;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export declare interface ISnapshotNormalizerConfig {
|
|
45
|
+
blobsToNormalize?: string[];
|
|
46
|
+
/**
|
|
47
|
+
* channel types who's content (non-attribute) blobs will be excluded.
|
|
48
|
+
* this is used to exclude the content of channels who's content cannot be compared
|
|
49
|
+
* as the content is non-deterministic between snapshot at the same sequence number.
|
|
50
|
+
*/
|
|
51
|
+
excludedChannelContentTypes?: string[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export declare function loadRC(): Promise<IResources>;
|
|
55
|
+
|
|
56
|
+
export declare function lockRC(): Promise<any>;
|
|
57
|
+
|
|
58
|
+
export declare type OdspTokenConfig = {
|
|
59
|
+
type: "password";
|
|
60
|
+
username: string;
|
|
61
|
+
password: string;
|
|
62
|
+
} | {
|
|
63
|
+
type: "browserLogin";
|
|
64
|
+
navigator: (url: string) => void;
|
|
65
|
+
redirectUriCallback?: (tokens: IOdspTokens) => Promise<string>;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export declare class OdspTokenManager {
|
|
69
|
+
private readonly tokenCache?;
|
|
70
|
+
private readonly storageCache;
|
|
71
|
+
private readonly pushCache;
|
|
72
|
+
private readonly cacheMutex;
|
|
73
|
+
constructor(tokenCache?: IAsyncCache<IOdspTokenManagerCacheKey, IOdspTokens> | undefined);
|
|
74
|
+
updateTokensCache(key: IOdspTokenManagerCacheKey, value: IOdspTokens): Promise<void>;
|
|
75
|
+
private updateTokensCacheWithoutLock;
|
|
76
|
+
getOdspTokens(server: string, clientConfig: IClientConfig, tokenConfig: OdspTokenConfig, forceRefresh?: boolean, forceReauth?: boolean): Promise<IOdspTokens>;
|
|
77
|
+
getPushTokens(server: string, clientConfig: IClientConfig, tokenConfig: OdspTokenConfig, forceRefresh?: boolean, forceReauth?: boolean): Promise<IOdspTokens>;
|
|
78
|
+
private getTokenFromCache;
|
|
79
|
+
private static getCacheKey;
|
|
80
|
+
private getTokens;
|
|
81
|
+
private getTokensCore;
|
|
82
|
+
private acquireTokensWithPassword;
|
|
83
|
+
private acquireTokensViaBrowserLogin;
|
|
84
|
+
private onTokenRetrievalFromCache;
|
|
85
|
+
private extractAuthorizationCode;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export declare const odspTokensCache: IAsyncCache<IOdspTokenManagerCacheKey, IOdspTokens>;
|
|
89
|
+
|
|
90
|
+
export declare function saveRC(rc: IResources): Promise<void>;
|
|
91
|
+
|
|
92
|
+
export { }
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { IClientConfig } from '@fluidframework/odsp-doclib-utils';
|
|
2
|
+
import { IOdspTokens } from '@fluidframework/odsp-doclib-utils';
|
|
3
|
+
import { ITree } from '@fluidframework/protocol-definitions';
|
|
4
|
+
|
|
5
|
+
/** The prefix that all GC blob names start with. */
|
|
6
|
+
export declare const gcBlobPrefix = "__gc";
|
|
7
|
+
|
|
8
|
+
export declare const getMicrosoftConfiguration: () => IClientConfig;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Helper function that normalizes the given snapshot tree. It sorts objects and arrays in the snapshot. It also
|
|
12
|
+
* normalizes certain blob contents for which the order of content does not matter. For example, garbage collection
|
|
13
|
+
* blobs contains objects / arrays whose element order do not matter.
|
|
14
|
+
* @param snapshot - The snapshot tree to normalize.
|
|
15
|
+
* @param config - Configs to use when normalizing snapshot. For example, it can contain paths of blobs whose contents
|
|
16
|
+
* should be normalized as well.
|
|
17
|
+
* @returns a copy of the normalized snapshot tree.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getNormalizedSnapshot(snapshot: ITree, config?: ISnapshotNormalizerConfig): ITree;
|
|
20
|
+
|
|
21
|
+
export declare interface IAsyncCache<TKey, TValue> {
|
|
22
|
+
get(key: TKey): Promise<TValue | undefined>;
|
|
23
|
+
save(key: TKey, value: TValue): Promise<void>;
|
|
24
|
+
lock<T>(callback: () => Promise<T>): Promise<T>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export declare interface IOdspTokenManagerCacheKey {
|
|
28
|
+
readonly isPush: boolean;
|
|
29
|
+
readonly userOrServer: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export declare interface IResources {
|
|
33
|
+
tokens?: {
|
|
34
|
+
version?: number;
|
|
35
|
+
data: {
|
|
36
|
+
[key: string]: {
|
|
37
|
+
storage?: IOdspTokens;
|
|
38
|
+
push?: IOdspTokens;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export declare interface ISnapshotNormalizerConfig {
|
|
45
|
+
blobsToNormalize?: string[];
|
|
46
|
+
/**
|
|
47
|
+
* channel types who's content (non-attribute) blobs will be excluded.
|
|
48
|
+
* this is used to exclude the content of channels who's content cannot be compared
|
|
49
|
+
* as the content is non-deterministic between snapshot at the same sequence number.
|
|
50
|
+
*/
|
|
51
|
+
excludedChannelContentTypes?: string[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export declare function loadRC(): Promise<IResources>;
|
|
55
|
+
|
|
56
|
+
export declare function lockRC(): Promise<any>;
|
|
57
|
+
|
|
58
|
+
export declare type OdspTokenConfig = {
|
|
59
|
+
type: "password";
|
|
60
|
+
username: string;
|
|
61
|
+
password: string;
|
|
62
|
+
} | {
|
|
63
|
+
type: "browserLogin";
|
|
64
|
+
navigator: (url: string) => void;
|
|
65
|
+
redirectUriCallback?: (tokens: IOdspTokens) => Promise<string>;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export declare class OdspTokenManager {
|
|
69
|
+
private readonly tokenCache?;
|
|
70
|
+
private readonly storageCache;
|
|
71
|
+
private readonly pushCache;
|
|
72
|
+
private readonly cacheMutex;
|
|
73
|
+
constructor(tokenCache?: IAsyncCache<IOdspTokenManagerCacheKey, IOdspTokens> | undefined);
|
|
74
|
+
updateTokensCache(key: IOdspTokenManagerCacheKey, value: IOdspTokens): Promise<void>;
|
|
75
|
+
private updateTokensCacheWithoutLock;
|
|
76
|
+
getOdspTokens(server: string, clientConfig: IClientConfig, tokenConfig: OdspTokenConfig, forceRefresh?: boolean, forceReauth?: boolean): Promise<IOdspTokens>;
|
|
77
|
+
getPushTokens(server: string, clientConfig: IClientConfig, tokenConfig: OdspTokenConfig, forceRefresh?: boolean, forceReauth?: boolean): Promise<IOdspTokens>;
|
|
78
|
+
private getTokenFromCache;
|
|
79
|
+
private static getCacheKey;
|
|
80
|
+
private getTokens;
|
|
81
|
+
private getTokensCore;
|
|
82
|
+
private acquireTokensWithPassword;
|
|
83
|
+
private acquireTokensViaBrowserLogin;
|
|
84
|
+
private onTokenRetrievalFromCache;
|
|
85
|
+
private extractAuthorizationCode;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export declare const odspTokensCache: IAsyncCache<IOdspTokenManagerCacheKey, IOdspTokens>;
|
|
89
|
+
|
|
90
|
+
export declare function saveRC(rc: IResources): Promise<void>;
|
|
91
|
+
|
|
92
|
+
export { }
|
package/dist/tsdoc-metadata.json
CHANGED
package/lib/httpHelpers.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
/// <reference types="node" />
|
|
6
|
+
/// <reference types="node" />
|
|
6
7
|
import http from "http";
|
|
7
8
|
import { Socket } from "net";
|
|
8
9
|
export interface ITrackedHttpServer {
|
|
@@ -11,8 +12,8 @@ export interface ITrackedHttpServer {
|
|
|
11
12
|
fullyClose(): void;
|
|
12
13
|
}
|
|
13
14
|
export declare function createTrackedServer(port: number, requestListener: http.RequestListener): ITrackedHttpServer;
|
|
14
|
-
export
|
|
15
|
-
export
|
|
15
|
+
export type OnceListenerHandler<T> = (req: http.IncomingMessage, res: http.ServerResponse) => Promise<T>;
|
|
16
|
+
export type OnceListenerResult<T> = Promise<() => Promise<T>>;
|
|
16
17
|
export declare const serverListenAndHandle: <T>(port: number, handler: OnceListenerHandler<T>) => OnceListenerResult<T>;
|
|
17
18
|
export declare const endResponse: (response: http.ServerResponse) => Promise<void>;
|
|
18
19
|
//# sourceMappingURL=httpHelpers.d.ts.map
|
package/lib/httpHelpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpHelpers.d.ts","sourceRoot":"","sources":["../src/httpHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG
|
|
1
|
+
{"version":3,"file":"httpHelpers.d.ts","sourceRoot":"","sources":["../src/httpHelpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;;;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAE7B,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC9B,UAAU,IAAI,IAAI,CAAC;CACnB;AACD,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,MAAM,EACZ,eAAe,EAAE,IAAI,CAAC,eAAe,GACnC,kBAAkB,CAiBpB;AACD,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CACpC,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,GAAG,EAAE,IAAI,CAAC,cAAc,KACpB,OAAO,CAAC,CAAC,CAAC,CAAC;AAChB,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,OAAO,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9D,eAAO,MAAM,qBAAqB,YAC3B,MAAM,2DAuBV,CAAC;AAEJ,eAAO,MAAM,WAAW,aAAoB,KAAK,cAAc,KAAG,QAAQ,IAAI,CAO3E,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { IOdspTokens, IClientConfig } from "@fluidframework/odsp-doclib-utils";
|
|
6
6
|
import { IAsyncCache } from "./fluidToolRC";
|
|
7
7
|
export declare const getMicrosoftConfiguration: () => IClientConfig;
|
|
8
|
-
export
|
|
8
|
+
export type OdspTokenConfig = {
|
|
9
9
|
type: "password";
|
|
10
10
|
username: string;
|
|
11
11
|
password: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspTokenManager.d.ts","sourceRoot":"","sources":["../src/odspTokenManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,WAAW,EACX,aAAa,EAOb,MAAM,mCAAmC,CAAC;AAI3C,OAAO,EAAE,WAAW,EAA0B,MAAM,eAAe,CAAC;AAOpE,eAAO,MAAM,yBAAyB,QAAO,aAe3C,CAAC;AA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,EAC3B,WAAW,EAAE,eAAe,EAC5B,YAAY,UAAQ,EACpB,WAAW,UAAQ,GACjB,OAAO,CAAC,WAAW,CAAC;YAIT,iBAAiB;IAe/B,OAAO,CAAC,MAAM,CAAC,WAAW;YAYZ,SAAS;YA0CT,aAAa;YA+Db,yBAAyB;YAezB,4BAA4B;YAuC5B,yBAAyB;IAMvC,OAAO,CAAC,wBAAwB;CAWhC;AAYD,eAAO,MAAM,eAAe,EAAE,WAAW,CAAC,yBAAyB,EAAE,WAAW,CA6B/E,CAAC"}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/tool-utils";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-dev.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-dev.7.2.0.203917";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export const pkgName = "@fluidframework/tool-utils";
|
|
8
|
-
export const pkgVersion = "2.0.0-dev.
|
|
8
|
+
export const pkgVersion = "2.0.0-dev.7.2.0.203917";
|
|
9
9
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,4BAA4B,CAAC;AACpD,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,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/tool-utils\";\nexport const pkgVersion = \"2.0.0-dev.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,4BAA4B,CAAC;AACpD,MAAM,CAAC,MAAM,UAAU,GAAG,wBAAwB,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/tool-utils\";\nexport const pkgVersion = \"2.0.0-dev.7.2.0.203917\";\n"]}
|
|
@@ -166,7 +166,9 @@ function normalizeEntry(entry, config) {
|
|
|
166
166
|
case TreeEntry.Blob: {
|
|
167
167
|
let contents = entry.value.contents;
|
|
168
168
|
// If this blob has to be normalized or it's a GC blob, parse and sort the blob contents first.
|
|
169
|
-
if (
|
|
169
|
+
if (
|
|
170
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- ?? is not logically equivalent when .includes returns false.
|
|
171
|
+
config?.blobsToNormalize?.includes(entry.path) ||
|
|
170
172
|
entry.path.startsWith(gcBlobPrefix)) {
|
|
171
173
|
contents = getNormalizedBlobContent(contents, entry.path);
|
|
172
174
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshotNormalizer.js","sourceRoot":"","sources":["../src/snapshotNormalizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AACjG,OAAO,EAAS,SAAS,EAAc,MAAM,sCAAsC,CAAC;AAEpF,gFAAgF;AAChF,MAAM,gBAAgB,GAAG,WAAW,CAAC;AACrC,oDAAoD;AACp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AC,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;yBACrE;qBACD;iBACD;aACD;YAED,OAAO,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,qBAAqB,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;SACjF;QACD,KAAK,SAAS,CAAC,UAAU,CAAC,CAAC;YAC1B,OAAO,IAAI,mBAAmB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;SAC3D;QAED;YACC,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;KACvC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from \"@fluidframework/driver-utils\";\nimport { ITree, TreeEntry, ITreeEntry } from \"@fluidframework/protocol-definitions\";\n\n/** The name of the metadata blob added to the root of the container runtime. */\nconst metadataBlobName = \".metadata\";\n/** The prefix that all GC blob names start with. */\nexport const gcBlobPrefix = \"__gc\";\n\nexport interface ISnapshotNormalizerConfig {\n\t// The paths of blobs whose contents should be normalized.\n\tblobsToNormalize?: string[];\n\t/**\n\t * channel types who's content (non-attribute) blobs will be excluded.\n\t * this is used to exclude the content of channels who's content cannot be compared\n\t * as the content is non-deterministic between snapshot at the same sequence number.\n\t */\n\texcludedChannelContentTypes?: string[];\n}\n\n/**\n * Function that deep sorts an array. It handles cases where array elements are objects or arrays.\n * @returns the sorted array.\n */\nfunction getDeepSortedArray(array: any[]): any[] {\n\tconst sortedArray: any[] = [];\n\t// Sort arrays and objects, if any, in the array.\n\tfor (const element of array) {\n\t\tif (Array.isArray(element)) {\n\t\t\tsortedArray.push(getDeepSortedArray(element));\n\t\t} else if (element instanceof Object) {\n\t\t\tsortedArray.push(getDeepSortedObject(element));\n\t\t} else {\n\t\t\tsortedArray.push(element);\n\t\t}\n\t}\n\n\t// Now that all the arrays and objects in this array's elements have been sorted, sort it by comparing each\n\t// element's stringified version.\n\tconst sortFn = (elem1: any, elem2: any) => {\n\t\tconst serializedElem1 = JSON.stringify(elem1);\n\t\tconst serializedElem2 = JSON.stringify(elem2);\n\t\treturn serializedElem1.localeCompare(serializedElem2);\n\t};\n\n\treturn sortedArray.sort(sortFn);\n}\n\n/**\n * Function that deep sorts an object. It handles cases where object properties are arrays or objects.\n * @returns the sorted object.\n */\nfunction getDeepSortedObject(obj: any): any {\n\tconst sortedObj: any = {};\n\t// Sort the object keys first. Then sort arrays and objects, if any, in the object.\n\tconst keys = Object.keys(obj).sort();\n\tfor (const key of keys) {\n\t\tconst value = obj[key];\n\t\tif (Array.isArray(value)) {\n\t\t\tsortedObj[key] = getDeepSortedArray(value);\n\t\t} else if (value instanceof Object) {\n\t\t\tsortedObj[key] = getDeepSortedObject(value);\n\t\t} else {\n\t\t\tsortedObj[key] = value;\n\t\t}\n\t}\n\n\treturn sortedObj;\n}\n\n/**\n * Function that normalizes a blob's content. If the content is an object or an array, deep sorts them.\n * Special handling for certain runtime blobs, such as the \"gc\" blob.\n * @returns the normalized blob content.\n */\nfunction getNormalizedBlobContent(blobContent: string, blobName: string): string {\n\tlet content = blobContent;\n\tif (blobName.startsWith(gcBlobPrefix)) {\n\t\t// GC blobs may contain `unreferencedTimestampMs` for node that became unreferenced. This is the timestamp\n\t\t// of the last op processed or current timestamp and can differ between clients depending on when GC was run.\n\t\t// So, remove it for the purposes of comparing snapshots.\n\t\tconst gcState = JSON.parse(content);\n\t\tfor (const [, data] of Object.entries(gcState.gcNodes)) {\n\t\t\tdelete (data as any).unreferencedTimestampMs;\n\t\t}\n\t\tcontent = JSON.stringify(gcState);\n\t}\n\n\t/**\n\t * The metadata blob has \"summaryNumber\" or \"summaryCount\" that tells which summary this is for a container. It can\n\t * be different in summaries of two clients even if they are generated at the same sequence#. For instance, at seq#\n\t * 1000, if one client has summarized 10 times and other has summarizer 15 times, summaryNumber will be different\n\t * for them. So, update \"summaryNumber\" to 0 for purposes of comparing snapshots.\n\t */\n\tif (blobName === metadataBlobName) {\n\t\tconst metadata = JSON.parse(content);\n\t\tif (metadata.summaryNumber !== undefined) {\n\t\t\tmetadata.summaryNumber = 0;\n\t\t}\n\t\tif (metadata.summaryCount !== undefined) {\n\t\t\tmetadata.summaryCount = 0;\n\t\t}\n\t\t// \"telemetryDocumentId\" is not a deterministic property (random guid), so we need to set it to something consistent\n\t\tif (metadata.telemetryDocumentId !== undefined) {\n\t\t\tmetadata.telemetryDocumentId = \"x\";\n\t\t}\n\t\tcontent = JSON.stringify(metadata);\n\t}\n\n\t// Deep sort the content if it's parseable.\n\ttry {\n\t\tlet contentObj = JSON.parse(content);\n\t\tif (Array.isArray(contentObj)) {\n\t\t\tcontentObj = getDeepSortedArray(contentObj);\n\t\t} else if (contentObj instanceof Object) {\n\t\t\tcontentObj = getDeepSortedObject(contentObj);\n\t\t}\n\t\tcontent = JSON.stringify(contentObj);\n\t} catch {}\n\treturn content;\n}\n\n/**\n * Helper function that normalizes the given snapshot tree. It sorts objects and arrays in the snapshot. It also\n * normalizes certain blob contents for which the order of content does not matter. For example, garbage collection\n * blobs contains objects / arrays whose element order do not matter.\n * @param snapshot - The snapshot tree to normalize.\n * @param config - Configs to use when normalizing snapshot. For example, it can contain paths of blobs whose contents\n * should be normalized as well.\n * @returns a copy of the normalized snapshot tree.\n */\nexport function getNormalizedSnapshot(snapshot: ITree, config?: ISnapshotNormalizerConfig): ITree {\n\t// Merge blobs to normalize in the config with runtime blobs to normalize. The contents of these blobs will be\n\t// parsed and deep sorted.\n\tconst normalizedEntries: ITreeEntry[] = [];\n\n\t// The metadata blob in the root of the summary tree needs to be normalized.\n\tconst blobsToNormalize = [metadataBlobName, ...(config?.blobsToNormalize ?? [])];\n\tfor (const entry of snapshot.entries) {\n\t\tnormalizedEntries.push(normalizeEntry(entry, { ...config, blobsToNormalize }));\n\t}\n\n\t// Sort the tree entries based on their path.\n\tnormalizedEntries.sort((a, b) => a.path.localeCompare(b.path));\n\n\treturn {\n\t\tentries: normalizedEntries,\n\t\tid: snapshot.id,\n\t};\n}\n\nfunction normalizeMatrix(value: ITree): ITree {\n\tconst rows = value.entries.find((e) => e.path === \"rows\");\n\n\tif (!rows || !(\"entries\" in rows.value)) {\n\t\treturn value;\n\t}\n\n\tconst segments = rows.value.entries.find((e) => e.path === \"segments\");\n\n\tif (!segments || !(\"entries\" in segments.value)) {\n\t\treturn value;\n\t}\n\n\tconst header = segments.value.entries.find((e) => e.path === \"header\");\n\n\tif (!header || !(\"contents\" in header.value)) {\n\t\treturn value;\n\t}\n\n\tif (!header?.value.contents.includes(\"removedClientId\")) {\n\t\treturn value;\n\t}\n\n\tconst contents = JSON.parse(header?.value.contents);\n\n\tfor (const segment of contents.segments) {\n\t\tif (\"removedClientId\" in segment) {\n\t\t\tsegment.removedClientId = undefined;\n\t\t}\n\n\t\tif (\"removedClientIds\" in segment) {\n\t\t\tsegment.removedClientIds = undefined;\n\t\t}\n\t}\n\n\theader.value.contents = JSON.stringify(contents);\n\n\treturn value;\n}\n\nfunction normalizeEntry(\n\tentry: ITreeEntry,\n\tconfig: ISnapshotNormalizerConfig | undefined,\n): ITreeEntry {\n\tswitch (entry.type) {\n\t\tcase TreeEntry.Blob: {\n\t\t\tlet contents = entry.value.contents;\n\t\t\t// If this blob has to be normalized or it's a GC blob, parse and sort the blob contents first.\n\t\t\tif (\n\t\t\t\tconfig?.blobsToNormalize?.includes(entry.path) ||\n\t\t\t\tentry.path.startsWith(gcBlobPrefix)\n\t\t\t) {\n\t\t\t\tcontents = getNormalizedBlobContent(contents, entry.path);\n\t\t\t}\n\t\t\treturn new BlobTreeEntry(entry.path, contents);\n\t\t}\n\t\tcase TreeEntry.Tree: {\n\t\t\tif (config?.excludedChannelContentTypes !== undefined) {\n\t\t\t\tfor (const maybeAttributes of entry.value.entries) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tmaybeAttributes.type === TreeEntry.Blob &&\n\t\t\t\t\t\tmaybeAttributes.path === \".attributes\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst parsed: { type?: string } = JSON.parse(\n\t\t\t\t\t\t\tmaybeAttributes.value.contents,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (parsed.type === \"https://graph.microsoft.com/types/sharedmatrix\") {\n\t\t\t\t\t\t\treturn new TreeTreeEntry(\n\t\t\t\t\t\t\t\tentry.path,\n\t\t\t\t\t\t\t\tnormalizeMatrix(getNormalizedSnapshot(entry.value, config)),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tparsed.type !== undefined &&\n\t\t\t\t\t\t\tconfig.excludedChannelContentTypes.includes(parsed.type)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// remove everything to match the unknown channel\n\t\t\t\t\t\t\treturn new TreeTreeEntry(entry.path, { entries: [maybeAttributes] });\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn new TreeTreeEntry(entry.path, getNormalizedSnapshot(entry.value, config));\n\t\t}\n\t\tcase TreeEntry.Attachment: {\n\t\t\treturn new AttachmentTreeEntry(entry.path, entry.value.id);\n\t\t}\n\n\t\tdefault:\n\t\t\tthrow new Error(\"Unknown entry type\");\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"snapshotNormalizer.js","sourceRoot":"","sources":["../src/snapshotNormalizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AACjG,OAAO,EAAS,SAAS,EAAc,MAAM,sCAAsC,CAAC;AAEpF,gFAAgF;AAChF,MAAM,gBAAgB,GAAG,WAAW,CAAC;AACrC,oDAAoD;AACpD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC;AAanC;;;GAGG;A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CAAC,EAAE,CAAC,CAAC;yBACrE;qBACD;iBACD;aACD;YAED,OAAO,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,qBAAqB,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;SACjF;QACD,KAAK,SAAS,CAAC,UAAU,CAAC,CAAC;YAC1B,OAAO,IAAI,mBAAmB,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;SAC3D;QAED;YACC,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;KACvC;AACF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { AttachmentTreeEntry, BlobTreeEntry, TreeTreeEntry } from \"@fluidframework/driver-utils\";\nimport { ITree, TreeEntry, ITreeEntry } from \"@fluidframework/protocol-definitions\";\n\n/** The name of the metadata blob added to the root of the container runtime. */\nconst metadataBlobName = \".metadata\";\n/** The prefix that all GC blob names start with. */\nexport const gcBlobPrefix = \"__gc\";\n\nexport interface ISnapshotNormalizerConfig {\n\t// The paths of blobs whose contents should be normalized.\n\tblobsToNormalize?: string[];\n\t/**\n\t * channel types who's content (non-attribute) blobs will be excluded.\n\t * this is used to exclude the content of channels who's content cannot be compared\n\t * as the content is non-deterministic between snapshot at the same sequence number.\n\t */\n\texcludedChannelContentTypes?: string[];\n}\n\n/**\n * Function that deep sorts an array. It handles cases where array elements are objects or arrays.\n * @returns the sorted array.\n */\nfunction getDeepSortedArray(array: any[]): any[] {\n\tconst sortedArray: any[] = [];\n\t// Sort arrays and objects, if any, in the array.\n\tfor (const element of array) {\n\t\tif (Array.isArray(element)) {\n\t\t\tsortedArray.push(getDeepSortedArray(element));\n\t\t} else if (element instanceof Object) {\n\t\t\tsortedArray.push(getDeepSortedObject(element));\n\t\t} else {\n\t\t\tsortedArray.push(element);\n\t\t}\n\t}\n\n\t// Now that all the arrays and objects in this array's elements have been sorted, sort it by comparing each\n\t// element's stringified version.\n\tconst sortFn = (elem1: any, elem2: any) => {\n\t\tconst serializedElem1 = JSON.stringify(elem1);\n\t\tconst serializedElem2 = JSON.stringify(elem2);\n\t\treturn serializedElem1.localeCompare(serializedElem2);\n\t};\n\n\treturn sortedArray.sort(sortFn);\n}\n\n/**\n * Function that deep sorts an object. It handles cases where object properties are arrays or objects.\n * @returns the sorted object.\n */\nfunction getDeepSortedObject(obj: any): any {\n\tconst sortedObj: any = {};\n\t// Sort the object keys first. Then sort arrays and objects, if any, in the object.\n\tconst keys = Object.keys(obj).sort();\n\tfor (const key of keys) {\n\t\tconst value = obj[key];\n\t\tif (Array.isArray(value)) {\n\t\t\tsortedObj[key] = getDeepSortedArray(value);\n\t\t} else if (value instanceof Object) {\n\t\t\tsortedObj[key] = getDeepSortedObject(value);\n\t\t} else {\n\t\t\tsortedObj[key] = value;\n\t\t}\n\t}\n\n\treturn sortedObj;\n}\n\n/**\n * Function that normalizes a blob's content. If the content is an object or an array, deep sorts them.\n * Special handling for certain runtime blobs, such as the \"gc\" blob.\n * @returns the normalized blob content.\n */\nfunction getNormalizedBlobContent(blobContent: string, blobName: string): string {\n\tlet content = blobContent;\n\tif (blobName.startsWith(gcBlobPrefix)) {\n\t\t// GC blobs may contain `unreferencedTimestampMs` for node that became unreferenced. This is the timestamp\n\t\t// of the last op processed or current timestamp and can differ between clients depending on when GC was run.\n\t\t// So, remove it for the purposes of comparing snapshots.\n\t\tconst gcState = JSON.parse(content);\n\t\tfor (const [, data] of Object.entries(gcState.gcNodes)) {\n\t\t\tdelete (data as any).unreferencedTimestampMs;\n\t\t}\n\t\tcontent = JSON.stringify(gcState);\n\t}\n\n\t/**\n\t * The metadata blob has \"summaryNumber\" or \"summaryCount\" that tells which summary this is for a container. It can\n\t * be different in summaries of two clients even if they are generated at the same sequence#. For instance, at seq#\n\t * 1000, if one client has summarized 10 times and other has summarizer 15 times, summaryNumber will be different\n\t * for them. So, update \"summaryNumber\" to 0 for purposes of comparing snapshots.\n\t */\n\tif (blobName === metadataBlobName) {\n\t\tconst metadata = JSON.parse(content);\n\t\tif (metadata.summaryNumber !== undefined) {\n\t\t\tmetadata.summaryNumber = 0;\n\t\t}\n\t\tif (metadata.summaryCount !== undefined) {\n\t\t\tmetadata.summaryCount = 0;\n\t\t}\n\t\t// \"telemetryDocumentId\" is not a deterministic property (random guid), so we need to set it to something consistent\n\t\tif (metadata.telemetryDocumentId !== undefined) {\n\t\t\tmetadata.telemetryDocumentId = \"x\";\n\t\t}\n\t\tcontent = JSON.stringify(metadata);\n\t}\n\n\t// Deep sort the content if it's parseable.\n\ttry {\n\t\tlet contentObj = JSON.parse(content);\n\t\tif (Array.isArray(contentObj)) {\n\t\t\tcontentObj = getDeepSortedArray(contentObj);\n\t\t} else if (contentObj instanceof Object) {\n\t\t\tcontentObj = getDeepSortedObject(contentObj);\n\t\t}\n\t\tcontent = JSON.stringify(contentObj);\n\t} catch {}\n\treturn content;\n}\n\n/**\n * Helper function that normalizes the given snapshot tree. It sorts objects and arrays in the snapshot. It also\n * normalizes certain blob contents for which the order of content does not matter. For example, garbage collection\n * blobs contains objects / arrays whose element order do not matter.\n * @param snapshot - The snapshot tree to normalize.\n * @param config - Configs to use when normalizing snapshot. For example, it can contain paths of blobs whose contents\n * should be normalized as well.\n * @returns a copy of the normalized snapshot tree.\n */\nexport function getNormalizedSnapshot(snapshot: ITree, config?: ISnapshotNormalizerConfig): ITree {\n\t// Merge blobs to normalize in the config with runtime blobs to normalize. The contents of these blobs will be\n\t// parsed and deep sorted.\n\tconst normalizedEntries: ITreeEntry[] = [];\n\n\t// The metadata blob in the root of the summary tree needs to be normalized.\n\tconst blobsToNormalize = [metadataBlobName, ...(config?.blobsToNormalize ?? [])];\n\tfor (const entry of snapshot.entries) {\n\t\tnormalizedEntries.push(normalizeEntry(entry, { ...config, blobsToNormalize }));\n\t}\n\n\t// Sort the tree entries based on their path.\n\tnormalizedEntries.sort((a, b) => a.path.localeCompare(b.path));\n\n\treturn {\n\t\tentries: normalizedEntries,\n\t\tid: snapshot.id,\n\t};\n}\n\nfunction normalizeMatrix(value: ITree): ITree {\n\tconst rows = value.entries.find((e) => e.path === \"rows\");\n\n\tif (!rows || !(\"entries\" in rows.value)) {\n\t\treturn value;\n\t}\n\n\tconst segments = rows.value.entries.find((e) => e.path === \"segments\");\n\n\tif (!segments || !(\"entries\" in segments.value)) {\n\t\treturn value;\n\t}\n\n\tconst header = segments.value.entries.find((e) => e.path === \"header\");\n\n\tif (!header || !(\"contents\" in header.value)) {\n\t\treturn value;\n\t}\n\n\tif (!header?.value.contents.includes(\"removedClientId\")) {\n\t\treturn value;\n\t}\n\n\tconst contents = JSON.parse(header?.value.contents);\n\n\tfor (const segment of contents.segments) {\n\t\tif (\"removedClientId\" in segment) {\n\t\t\tsegment.removedClientId = undefined;\n\t\t}\n\n\t\tif (\"removedClientIds\" in segment) {\n\t\t\tsegment.removedClientIds = undefined;\n\t\t}\n\t}\n\n\theader.value.contents = JSON.stringify(contents);\n\n\treturn value;\n}\n\nfunction normalizeEntry(\n\tentry: ITreeEntry,\n\tconfig: ISnapshotNormalizerConfig | undefined,\n): ITreeEntry {\n\tswitch (entry.type) {\n\t\tcase TreeEntry.Blob: {\n\t\t\tlet contents = entry.value.contents;\n\t\t\t// If this blob has to be normalized or it's a GC blob, parse and sort the blob contents first.\n\t\t\tif (\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- ?? is not logically equivalent when .includes returns false.\n\t\t\t\tconfig?.blobsToNormalize?.includes(entry.path) ||\n\t\t\t\tentry.path.startsWith(gcBlobPrefix)\n\t\t\t) {\n\t\t\t\tcontents = getNormalizedBlobContent(contents, entry.path);\n\t\t\t}\n\t\t\treturn new BlobTreeEntry(entry.path, contents);\n\t\t}\n\t\tcase TreeEntry.Tree: {\n\t\t\tif (config?.excludedChannelContentTypes !== undefined) {\n\t\t\t\tfor (const maybeAttributes of entry.value.entries) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tmaybeAttributes.type === TreeEntry.Blob &&\n\t\t\t\t\t\tmaybeAttributes.path === \".attributes\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst parsed: { type?: string } = JSON.parse(\n\t\t\t\t\t\t\tmaybeAttributes.value.contents,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (parsed.type === \"https://graph.microsoft.com/types/sharedmatrix\") {\n\t\t\t\t\t\t\treturn new TreeTreeEntry(\n\t\t\t\t\t\t\t\tentry.path,\n\t\t\t\t\t\t\t\tnormalizeMatrix(getNormalizedSnapshot(entry.value, config)),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tparsed.type !== undefined &&\n\t\t\t\t\t\t\tconfig.excludedChannelContentTypes.includes(parsed.type)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// remove everything to match the unknown channel\n\t\t\t\t\t\t\treturn new TreeTreeEntry(entry.path, { entries: [maybeAttributes] });\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn new TreeTreeEntry(entry.path, getNormalizedSnapshot(entry.value, config));\n\t\t}\n\t\tcase TreeEntry.Attachment: {\n\t\t\treturn new AttachmentTreeEntry(entry.path, entry.value.id);\n\t\t}\n\n\t\tdefault:\n\t\t\tthrow new Error(\"Unknown entry type\");\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/tool-utils",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.7.2.0.203917",
|
|
4
4
|
"description": "Common utilities for Fluid tools",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -35,38 +35,37 @@
|
|
|
35
35
|
"temp-directory": "nyc/.nyc_output"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@fluidframework/core-utils": "2.0.0-dev.
|
|
39
|
-
"@fluidframework/driver-utils": "2.0.0-dev.
|
|
40
|
-
"@fluidframework/odsp-doclib-utils": "2.0.0-dev.
|
|
41
|
-
"@fluidframework/protocol-definitions": "^
|
|
38
|
+
"@fluidframework/core-utils": "2.0.0-dev.7.2.0.203917",
|
|
39
|
+
"@fluidframework/driver-utils": "2.0.0-dev.7.2.0.203917",
|
|
40
|
+
"@fluidframework/odsp-doclib-utils": "2.0.0-dev.7.2.0.203917",
|
|
41
|
+
"@fluidframework/protocol-definitions": "^3.0.0",
|
|
42
42
|
"async-mutex": "^0.3.1",
|
|
43
|
-
"debug": "^4.
|
|
43
|
+
"debug": "^4.3.4",
|
|
44
44
|
"jwt-decode": "^2.2.0",
|
|
45
45
|
"proper-lockfile": "^4.1.2"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@fluid-tools/build-cli": "
|
|
49
|
-
"@fluidframework/build-common": "^2.0.
|
|
50
|
-
"@fluidframework/build-tools": "
|
|
51
|
-
"@fluidframework/eslint-config-fluid": "^
|
|
52
|
-
"@fluidframework/mocha-test-setup": "2.0.0-dev.
|
|
53
|
-
"@fluidframework/tool-utils-previous": "npm:@fluidframework/tool-utils@2.0.0-internal.
|
|
54
|
-
"@microsoft/api-extractor": "^7.
|
|
48
|
+
"@fluid-tools/build-cli": "0.26.0-203096",
|
|
49
|
+
"@fluidframework/build-common": "^2.0.2",
|
|
50
|
+
"@fluidframework/build-tools": "0.26.0-203096",
|
|
51
|
+
"@fluidframework/eslint-config-fluid": "^3.0.0",
|
|
52
|
+
"@fluidframework/mocha-test-setup": "2.0.0-dev.7.2.0.203917",
|
|
53
|
+
"@fluidframework/tool-utils-previous": "npm:@fluidframework/tool-utils@2.0.0-internal.7.1.0",
|
|
54
|
+
"@microsoft/api-extractor": "^7.37.0",
|
|
55
55
|
"@types/debug": "^4.1.5",
|
|
56
56
|
"@types/jwt-decode": "^2.2.1",
|
|
57
57
|
"@types/mocha": "^9.1.1",
|
|
58
58
|
"@types/node": "^16.18.38",
|
|
59
59
|
"c8": "^7.7.1",
|
|
60
|
-
"copyfiles": "^2.4.1",
|
|
61
60
|
"cross-env": "^7.0.3",
|
|
62
|
-
"eslint": "~8.
|
|
61
|
+
"eslint": "~8.50.0",
|
|
63
62
|
"mocha": "^10.2.0",
|
|
64
63
|
"mocha-json-output-reporter": "^2.0.1",
|
|
65
64
|
"mocha-multi-reporters": "^1.5.1",
|
|
66
65
|
"moment": "^2.21.0",
|
|
67
|
-
"prettier": "~
|
|
66
|
+
"prettier": "~3.0.3",
|
|
68
67
|
"rimraf": "^4.4.0",
|
|
69
|
-
"typescript": "~
|
|
68
|
+
"typescript": "~5.1.6"
|
|
70
69
|
},
|
|
71
70
|
"typeValidation": {
|
|
72
71
|
"broken": {}
|
|
@@ -75,11 +74,11 @@
|
|
|
75
74
|
"build": "fluid-build . --task build",
|
|
76
75
|
"build:commonjs": "fluid-build . --task commonjs",
|
|
77
76
|
"build:compile": "fluid-build . --task compile",
|
|
78
|
-
"build:docs": "api-extractor run --local
|
|
77
|
+
"build:docs": "api-extractor run --local",
|
|
79
78
|
"build:esnext": "tsc --project ./tsconfig.esnext.json",
|
|
80
79
|
"build:genver": "gen-version",
|
|
81
80
|
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
82
|
-
"ci:build:docs": "api-extractor run
|
|
81
|
+
"ci:build:docs": "api-extractor run",
|
|
83
82
|
"clean": "rimraf --glob 'dist' 'lib' '*.tsbuildinfo' '*.build.log' '_api-extractor-temp' 'nyc'",
|
|
84
83
|
"eslint": "eslint --format stylish src",
|
|
85
84
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
package/src/packageVersion.ts
CHANGED
|
@@ -202,6 +202,7 @@ function normalizeEntry(
|
|
|
202
202
|
let contents = entry.value.contents;
|
|
203
203
|
// If this blob has to be normalized or it's a GC blob, parse and sort the blob contents first.
|
|
204
204
|
if (
|
|
205
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- ?? is not logically equivalent when .includes returns false.
|
|
205
206
|
config?.blobsToNormalize?.includes(entry.path) ||
|
|
206
207
|
entry.path.startsWith(gcBlobPrefix)
|
|
207
208
|
) {
|