@milaboratories/pl-tree 1.8.47 → 1.8.49
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/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/accessors.cjs +236 -273
- package/dist/accessors.cjs.map +1 -1
- package/dist/accessors.d.ts +93 -93
- package/dist/accessors.js +235 -271
- package/dist/accessors.js.map +1 -1
- package/dist/dump.cjs +79 -80
- package/dist/dump.cjs.map +1 -1
- package/dist/dump.d.ts +16 -18
- package/dist/dump.js +79 -79
- package/dist/dump.js.map +1 -1
- package/dist/index.cjs +31 -35
- package/dist/index.d.ts +10 -10
- package/dist/index.js +9 -8
- package/dist/snapshot.cjs +50 -71
- package/dist/snapshot.cjs.map +1 -1
- package/dist/snapshot.d.ts +36 -38
- package/dist/snapshot.js +49 -69
- package/dist/snapshot.js.map +1 -1
- package/dist/state.cjs +487 -624
- package/dist/state.cjs.map +1 -1
- package/dist/state.d.ts +117 -116
- package/dist/state.js +486 -622
- package/dist/state.js.map +1 -1
- package/dist/sync.cjs +113 -133
- package/dist/sync.cjs.map +1 -1
- package/dist/sync.d.ts +37 -33
- package/dist/sync.js +111 -131
- package/dist/sync.js.map +1 -1
- package/dist/synchronized_tree.cjs +167 -232
- package/dist/synchronized_tree.cjs.map +1 -1
- package/dist/synchronized_tree.d.ts +66 -68
- package/dist/synchronized_tree.js +165 -211
- package/dist/synchronized_tree.js.map +1 -1
- package/dist/traversal_ops.d.ts +42 -42
- package/dist/value_and_error.cjs +9 -12
- package/dist/value_and_error.cjs.map +1 -1
- package/dist/value_and_error.d.ts +8 -5
- package/dist/value_and_error.js +9 -11
- package/dist/value_and_error.js.map +1 -1
- package/dist/value_or_error.d.ts +8 -5
- package/package.json +9 -9
- package/src/synchronized_tree.ts +10 -5
- package/dist/accessors.d.ts.map +0 -1
- package/dist/dump.d.ts.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/snapshot.d.ts.map +0 -1
- package/dist/state.d.ts.map +0 -1
- package/dist/sync.d.ts.map +0 -1
- package/dist/synchronized_tree.d.ts.map +0 -1
- package/dist/test_utils.d.ts +0 -25
- package/dist/test_utils.d.ts.map +0 -1
- package/dist/traversal_ops.d.ts.map +0 -1
- package/dist/value_and_error.d.ts.map +0 -1
- package/dist/value_or_error.d.ts.map +0 -1
package/dist/dump.cjs
CHANGED
|
@@ -1,86 +1,85 @@
|
|
|
1
|
-
'use strict';
|
|
2
1
|
|
|
2
|
+
//#region src/dump.ts
|
|
3
3
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
4
|
+
* Analyzes a collection of resources and generates statistics grouped by resource type.
|
|
5
|
+
*
|
|
6
|
+
* This function processes an array of ExtendedResourceData and calculates various metrics
|
|
7
|
+
* for each unique resource type, including:
|
|
8
|
+
* - Count of resources
|
|
9
|
+
* - Total bytes in field names
|
|
10
|
+
* - Total number of fields
|
|
11
|
+
* - Total bytes in resource data
|
|
12
|
+
* - Total number of key-value records
|
|
13
|
+
* - Total bytes in key-value records
|
|
14
|
+
*
|
|
15
|
+
* The statistics are organized by resource type using a key in the format "typeName/version".
|
|
16
|
+
*
|
|
17
|
+
* @param dumpStats - Array of ExtendedResourceData objects to analyze
|
|
18
|
+
* @returns A DumpStats object containing statistics for each resource type
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const resources = [...]; // Array of ExtendedResourceData
|
|
22
|
+
* const stats = treeDumpStats(resources);
|
|
23
|
+
* // stats = {
|
|
24
|
+
* // "MyResource/1": {
|
|
25
|
+
* // count: 5,
|
|
26
|
+
* // fieldNameBytes: 150,
|
|
27
|
+
* // fieldsCount: 10,
|
|
28
|
+
* // dataBytes: 1024,
|
|
29
|
+
* // kvCount: 3,
|
|
30
|
+
* // kvBytes: 256
|
|
31
|
+
* // },
|
|
32
|
+
* // ...
|
|
33
|
+
* // }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
36
|
function treeDumpStats(dumpStats) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
return stats;
|
|
37
|
+
const stats = {
|
|
38
|
+
total: {
|
|
39
|
+
count: 0,
|
|
40
|
+
fieldNameBytes: 0,
|
|
41
|
+
fieldsCount: 0,
|
|
42
|
+
dataBytes: 0,
|
|
43
|
+
kvCount: 0,
|
|
44
|
+
kvBytes: 0
|
|
45
|
+
},
|
|
46
|
+
byResourceType: {}
|
|
47
|
+
};
|
|
48
|
+
for (const resource of dumpStats) {
|
|
49
|
+
const typeKey = `${resource.type.name}/${resource.type.version}`;
|
|
50
|
+
if (!stats.byResourceType[typeKey]) stats.byResourceType[typeKey] = {
|
|
51
|
+
count: 0,
|
|
52
|
+
fieldNameBytes: 0,
|
|
53
|
+
fieldsCount: 0,
|
|
54
|
+
dataBytes: 0,
|
|
55
|
+
kvCount: 0,
|
|
56
|
+
kvBytes: 0
|
|
57
|
+
};
|
|
58
|
+
const typeStats = stats.byResourceType[typeKey];
|
|
59
|
+
typeStats.count++;
|
|
60
|
+
stats.total.count++;
|
|
61
|
+
for (const field of resource.fields) {
|
|
62
|
+
typeStats.fieldNameBytes += field.name.length;
|
|
63
|
+
typeStats.fieldsCount++;
|
|
64
|
+
stats.total.fieldNameBytes += field.name.length;
|
|
65
|
+
stats.total.fieldsCount++;
|
|
66
|
+
}
|
|
67
|
+
if (resource.data) {
|
|
68
|
+
const dataLength = resource.data?.length ?? 0;
|
|
69
|
+
typeStats.dataBytes += dataLength;
|
|
70
|
+
stats.total.dataBytes += dataLength;
|
|
71
|
+
}
|
|
72
|
+
typeStats.kvCount += resource.kv.length;
|
|
73
|
+
stats.total.kvCount += resource.kv.length;
|
|
74
|
+
for (const kv of resource.kv) {
|
|
75
|
+
const kvLength = kv.key.length + kv.value.length;
|
|
76
|
+
typeStats.kvBytes += kvLength;
|
|
77
|
+
stats.total.kvBytes += kvLength;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return stats;
|
|
83
81
|
}
|
|
84
82
|
|
|
83
|
+
//#endregion
|
|
85
84
|
exports.treeDumpStats = treeDumpStats;
|
|
86
|
-
//# sourceMappingURL=dump.cjs.map
|
|
85
|
+
//# sourceMappingURL=dump.cjs.map
|
package/dist/dump.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dump.cjs","sources":["../src/dump.ts"],"sourcesContent":["import type { ExtendedResourceData } from \"./state\";\n\nexport type ResourceStats = {\n /** Number of resources of this type */\n count: number;\n /** Total number of bytes in the field names of all resources of this type */\n fieldNameBytes: number;\n /** Total number of fields in all resources of this type */\n fieldsCount: number;\n /** Total number of bytes in the data of all resources of this type */\n dataBytes: number;\n /** Total number of key-value records in all resources of this type */\n kvCount: number;\n /** Total number of bytes in the key-value records of all resources of this type */\n kvBytes: number;\n};\n\n/**\n * A map of resource type statistics, keyed by the resource type name and version.\n *\n * @type {Record<string, ResourceStats>}\n */\nexport type TreeDumpStats = {\n total: ResourceStats;\n byResourceType: Record<`${string}/${string}`, ResourceStats>;\n};\n\n/**\n * Analyzes a collection of resources and generates statistics grouped by resource type.\n *\n * This function processes an array of ExtendedResourceData and calculates various metrics\n * for each unique resource type, including:\n * - Count of resources\n * - Total bytes in field names\n * - Total number of fields\n * - Total bytes in resource data\n * - Total number of key-value records\n * - Total bytes in key-value records\n *\n * The statistics are organized by resource type using a key in the format \"typeName/version\".\n *\n * @param dumpStats - Array of ExtendedResourceData objects to analyze\n * @returns A DumpStats object containing statistics for each resource type\n * @example\n * ```typescript\n * const resources = [...]; // Array of ExtendedResourceData\n * const stats = treeDumpStats(resources);\n * // stats = {\n * // \"MyResource/1\": {\n * // count: 5,\n * // fieldNameBytes: 150,\n * // fieldsCount: 10,\n * // dataBytes: 1024,\n * // kvCount: 3,\n * // kvBytes: 256\n * // },\n * // ...\n * // }\n * ```\n */\nexport function treeDumpStats(dumpStats: ExtendedResourceData[]): TreeDumpStats {\n const stats: TreeDumpStats = {\n total: {\n count: 0,\n fieldNameBytes: 0,\n fieldsCount: 0,\n dataBytes: 0,\n kvCount: 0,\n kvBytes: 0,\n },\n byResourceType: {},\n };\n\n for (const resource of dumpStats) {\n const typeKey = `${resource.type.name}/${resource.type.version}` as const;\n if (!stats.byResourceType[typeKey]) {\n stats.byResourceType[typeKey] = {\n count: 0,\n fieldNameBytes: 0,\n fieldsCount: 0,\n dataBytes: 0,\n kvCount: 0,\n kvBytes: 0,\n };\n }\n\n const typeStats = stats.byResourceType[typeKey];\n typeStats.count++;\n stats.total.count++;\n\n for (const field of resource.fields) {\n typeStats.fieldNameBytes += field.name.length;\n typeStats.fieldsCount++;\n stats.total.fieldNameBytes += field.name.length;\n stats.total.fieldsCount++;\n }\n\n if (resource.data) {\n const dataLength = resource.data?.length ?? 0;\n typeStats.dataBytes += dataLength;\n stats.total.dataBytes += dataLength;\n }\n\n typeStats.kvCount += resource.kv.length;\n stats.total.kvCount += resource.kv.length;\n\n for (const kv of resource.kv) {\n const kvLength = kv.key.length + kv.value.length;\n typeStats.kvBytes += kvLength;\n stats.total.kvBytes += kvLength;\n }\n }\n\n return stats;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"dump.cjs","names":[],"sources":["../src/dump.ts"],"sourcesContent":["import type { ExtendedResourceData } from \"./state\";\n\nexport type ResourceStats = {\n /** Number of resources of this type */\n count: number;\n /** Total number of bytes in the field names of all resources of this type */\n fieldNameBytes: number;\n /** Total number of fields in all resources of this type */\n fieldsCount: number;\n /** Total number of bytes in the data of all resources of this type */\n dataBytes: number;\n /** Total number of key-value records in all resources of this type */\n kvCount: number;\n /** Total number of bytes in the key-value records of all resources of this type */\n kvBytes: number;\n};\n\n/**\n * A map of resource type statistics, keyed by the resource type name and version.\n *\n * @type {Record<string, ResourceStats>}\n */\nexport type TreeDumpStats = {\n total: ResourceStats;\n byResourceType: Record<`${string}/${string}`, ResourceStats>;\n};\n\n/**\n * Analyzes a collection of resources and generates statistics grouped by resource type.\n *\n * This function processes an array of ExtendedResourceData and calculates various metrics\n * for each unique resource type, including:\n * - Count of resources\n * - Total bytes in field names\n * - Total number of fields\n * - Total bytes in resource data\n * - Total number of key-value records\n * - Total bytes in key-value records\n *\n * The statistics are organized by resource type using a key in the format \"typeName/version\".\n *\n * @param dumpStats - Array of ExtendedResourceData objects to analyze\n * @returns A DumpStats object containing statistics for each resource type\n * @example\n * ```typescript\n * const resources = [...]; // Array of ExtendedResourceData\n * const stats = treeDumpStats(resources);\n * // stats = {\n * // \"MyResource/1\": {\n * // count: 5,\n * // fieldNameBytes: 150,\n * // fieldsCount: 10,\n * // dataBytes: 1024,\n * // kvCount: 3,\n * // kvBytes: 256\n * // },\n * // ...\n * // }\n * ```\n */\nexport function treeDumpStats(dumpStats: ExtendedResourceData[]): TreeDumpStats {\n const stats: TreeDumpStats = {\n total: {\n count: 0,\n fieldNameBytes: 0,\n fieldsCount: 0,\n dataBytes: 0,\n kvCount: 0,\n kvBytes: 0,\n },\n byResourceType: {},\n };\n\n for (const resource of dumpStats) {\n const typeKey = `${resource.type.name}/${resource.type.version}` as const;\n if (!stats.byResourceType[typeKey]) {\n stats.byResourceType[typeKey] = {\n count: 0,\n fieldNameBytes: 0,\n fieldsCount: 0,\n dataBytes: 0,\n kvCount: 0,\n kvBytes: 0,\n };\n }\n\n const typeStats = stats.byResourceType[typeKey];\n typeStats.count++;\n stats.total.count++;\n\n for (const field of resource.fields) {\n typeStats.fieldNameBytes += field.name.length;\n typeStats.fieldsCount++;\n stats.total.fieldNameBytes += field.name.length;\n stats.total.fieldsCount++;\n }\n\n if (resource.data) {\n const dataLength = resource.data?.length ?? 0;\n typeStats.dataBytes += dataLength;\n stats.total.dataBytes += dataLength;\n }\n\n typeStats.kvCount += resource.kv.length;\n stats.total.kvCount += resource.kv.length;\n\n for (const kv of resource.kv) {\n const kvLength = kv.key.length + kv.value.length;\n typeStats.kvBytes += kvLength;\n stats.total.kvBytes += kvLength;\n }\n }\n\n return stats;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,SAAgB,cAAc,WAAkD;CAC9E,MAAM,QAAuB;EAC3B,OAAO;GACL,OAAO;GACP,gBAAgB;GAChB,aAAa;GACb,WAAW;GACX,SAAS;GACT,SAAS;GACV;EACD,gBAAgB,EAAE;EACnB;AAED,MAAK,MAAM,YAAY,WAAW;EAChC,MAAM,UAAU,GAAG,SAAS,KAAK,KAAK,GAAG,SAAS,KAAK;AACvD,MAAI,CAAC,MAAM,eAAe,SACxB,OAAM,eAAe,WAAW;GAC9B,OAAO;GACP,gBAAgB;GAChB,aAAa;GACb,WAAW;GACX,SAAS;GACT,SAAS;GACV;EAGH,MAAM,YAAY,MAAM,eAAe;AACvC,YAAU;AACV,QAAM,MAAM;AAEZ,OAAK,MAAM,SAAS,SAAS,QAAQ;AACnC,aAAU,kBAAkB,MAAM,KAAK;AACvC,aAAU;AACV,SAAM,MAAM,kBAAkB,MAAM,KAAK;AACzC,SAAM,MAAM;;AAGd,MAAI,SAAS,MAAM;GACjB,MAAM,aAAa,SAAS,MAAM,UAAU;AAC5C,aAAU,aAAa;AACvB,SAAM,MAAM,aAAa;;AAG3B,YAAU,WAAW,SAAS,GAAG;AACjC,QAAM,MAAM,WAAW,SAAS,GAAG;AAEnC,OAAK,MAAM,MAAM,SAAS,IAAI;GAC5B,MAAM,WAAW,GAAG,IAAI,SAAS,GAAG,MAAM;AAC1C,aAAU,WAAW;AACrB,SAAM,MAAM,WAAW;;;AAI3B,QAAO"}
|
package/dist/dump.d.ts
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/** Total number of key-value records in all resources of this type */
|
|
12
|
-
kvCount: number;
|
|
13
|
-
/** Total number of bytes in the key-value records of all resources of this type */
|
|
14
|
-
kvBytes: number;
|
|
1
|
+
import { ExtendedResourceData } from "./state.js";
|
|
2
|
+
|
|
3
|
+
//#region src/dump.d.ts
|
|
4
|
+
type ResourceStats = {
|
|
5
|
+
/** Number of resources of this type */count: number; /** Total number of bytes in the field names of all resources of this type */
|
|
6
|
+
fieldNameBytes: number; /** Total number of fields in all resources of this type */
|
|
7
|
+
fieldsCount: number; /** Total number of bytes in the data of all resources of this type */
|
|
8
|
+
dataBytes: number; /** Total number of key-value records in all resources of this type */
|
|
9
|
+
kvCount: number; /** Total number of bytes in the key-value records of all resources of this type */
|
|
10
|
+
kvBytes: number;
|
|
15
11
|
};
|
|
16
12
|
/**
|
|
17
13
|
* A map of resource type statistics, keyed by the resource type name and version.
|
|
18
14
|
*
|
|
19
15
|
* @type {Record<string, ResourceStats>}
|
|
20
16
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
type TreeDumpStats = {
|
|
18
|
+
total: ResourceStats;
|
|
19
|
+
byResourceType: Record<`${string}/${string}`, ResourceStats>;
|
|
24
20
|
};
|
|
25
21
|
/**
|
|
26
22
|
* Analyzes a collection of resources and generates statistics grouped by resource type.
|
|
@@ -55,5 +51,7 @@ export type TreeDumpStats = {
|
|
|
55
51
|
* // }
|
|
56
52
|
* ```
|
|
57
53
|
*/
|
|
58
|
-
|
|
54
|
+
declare function treeDumpStats(dumpStats: ExtendedResourceData[]): TreeDumpStats;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { ResourceStats, TreeDumpStats, treeDumpStats };
|
|
59
57
|
//# sourceMappingURL=dump.d.ts.map
|
package/dist/dump.js
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
|
+
//#region src/dump.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
3
|
+
* Analyzes a collection of resources and generates statistics grouped by resource type.
|
|
4
|
+
*
|
|
5
|
+
* This function processes an array of ExtendedResourceData and calculates various metrics
|
|
6
|
+
* for each unique resource type, including:
|
|
7
|
+
* - Count of resources
|
|
8
|
+
* - Total bytes in field names
|
|
9
|
+
* - Total number of fields
|
|
10
|
+
* - Total bytes in resource data
|
|
11
|
+
* - Total number of key-value records
|
|
12
|
+
* - Total bytes in key-value records
|
|
13
|
+
*
|
|
14
|
+
* The statistics are organized by resource type using a key in the format "typeName/version".
|
|
15
|
+
*
|
|
16
|
+
* @param dumpStats - Array of ExtendedResourceData objects to analyze
|
|
17
|
+
* @returns A DumpStats object containing statistics for each resource type
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const resources = [...]; // Array of ExtendedResourceData
|
|
21
|
+
* const stats = treeDumpStats(resources);
|
|
22
|
+
* // stats = {
|
|
23
|
+
* // "MyResource/1": {
|
|
24
|
+
* // count: 5,
|
|
25
|
+
* // fieldNameBytes: 150,
|
|
26
|
+
* // fieldsCount: 10,
|
|
27
|
+
* // dataBytes: 1024,
|
|
28
|
+
* // kvCount: 3,
|
|
29
|
+
* // kvBytes: 256
|
|
30
|
+
* // },
|
|
31
|
+
* // ...
|
|
32
|
+
* // }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
34
35
|
function treeDumpStats(dumpStats) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
return stats;
|
|
36
|
+
const stats = {
|
|
37
|
+
total: {
|
|
38
|
+
count: 0,
|
|
39
|
+
fieldNameBytes: 0,
|
|
40
|
+
fieldsCount: 0,
|
|
41
|
+
dataBytes: 0,
|
|
42
|
+
kvCount: 0,
|
|
43
|
+
kvBytes: 0
|
|
44
|
+
},
|
|
45
|
+
byResourceType: {}
|
|
46
|
+
};
|
|
47
|
+
for (const resource of dumpStats) {
|
|
48
|
+
const typeKey = `${resource.type.name}/${resource.type.version}`;
|
|
49
|
+
if (!stats.byResourceType[typeKey]) stats.byResourceType[typeKey] = {
|
|
50
|
+
count: 0,
|
|
51
|
+
fieldNameBytes: 0,
|
|
52
|
+
fieldsCount: 0,
|
|
53
|
+
dataBytes: 0,
|
|
54
|
+
kvCount: 0,
|
|
55
|
+
kvBytes: 0
|
|
56
|
+
};
|
|
57
|
+
const typeStats = stats.byResourceType[typeKey];
|
|
58
|
+
typeStats.count++;
|
|
59
|
+
stats.total.count++;
|
|
60
|
+
for (const field of resource.fields) {
|
|
61
|
+
typeStats.fieldNameBytes += field.name.length;
|
|
62
|
+
typeStats.fieldsCount++;
|
|
63
|
+
stats.total.fieldNameBytes += field.name.length;
|
|
64
|
+
stats.total.fieldsCount++;
|
|
65
|
+
}
|
|
66
|
+
if (resource.data) {
|
|
67
|
+
const dataLength = resource.data?.length ?? 0;
|
|
68
|
+
typeStats.dataBytes += dataLength;
|
|
69
|
+
stats.total.dataBytes += dataLength;
|
|
70
|
+
}
|
|
71
|
+
typeStats.kvCount += resource.kv.length;
|
|
72
|
+
stats.total.kvCount += resource.kv.length;
|
|
73
|
+
for (const kv of resource.kv) {
|
|
74
|
+
const kvLength = kv.key.length + kv.value.length;
|
|
75
|
+
typeStats.kvBytes += kvLength;
|
|
76
|
+
stats.total.kvBytes += kvLength;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return stats;
|
|
81
80
|
}
|
|
82
81
|
|
|
82
|
+
//#endregion
|
|
83
83
|
export { treeDumpStats };
|
|
84
|
-
//# sourceMappingURL=dump.js.map
|
|
84
|
+
//# sourceMappingURL=dump.js.map
|
package/dist/dump.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dump.js","sources":["../src/dump.ts"],"sourcesContent":["import type { ExtendedResourceData } from \"./state\";\n\nexport type ResourceStats = {\n /** Number of resources of this type */\n count: number;\n /** Total number of bytes in the field names of all resources of this type */\n fieldNameBytes: number;\n /** Total number of fields in all resources of this type */\n fieldsCount: number;\n /** Total number of bytes in the data of all resources of this type */\n dataBytes: number;\n /** Total number of key-value records in all resources of this type */\n kvCount: number;\n /** Total number of bytes in the key-value records of all resources of this type */\n kvBytes: number;\n};\n\n/**\n * A map of resource type statistics, keyed by the resource type name and version.\n *\n * @type {Record<string, ResourceStats>}\n */\nexport type TreeDumpStats = {\n total: ResourceStats;\n byResourceType: Record<`${string}/${string}`, ResourceStats>;\n};\n\n/**\n * Analyzes a collection of resources and generates statistics grouped by resource type.\n *\n * This function processes an array of ExtendedResourceData and calculates various metrics\n * for each unique resource type, including:\n * - Count of resources\n * - Total bytes in field names\n * - Total number of fields\n * - Total bytes in resource data\n * - Total number of key-value records\n * - Total bytes in key-value records\n *\n * The statistics are organized by resource type using a key in the format \"typeName/version\".\n *\n * @param dumpStats - Array of ExtendedResourceData objects to analyze\n * @returns A DumpStats object containing statistics for each resource type\n * @example\n * ```typescript\n * const resources = [...]; // Array of ExtendedResourceData\n * const stats = treeDumpStats(resources);\n * // stats = {\n * // \"MyResource/1\": {\n * // count: 5,\n * // fieldNameBytes: 150,\n * // fieldsCount: 10,\n * // dataBytes: 1024,\n * // kvCount: 3,\n * // kvBytes: 256\n * // },\n * // ...\n * // }\n * ```\n */\nexport function treeDumpStats(dumpStats: ExtendedResourceData[]): TreeDumpStats {\n const stats: TreeDumpStats = {\n total: {\n count: 0,\n fieldNameBytes: 0,\n fieldsCount: 0,\n dataBytes: 0,\n kvCount: 0,\n kvBytes: 0,\n },\n byResourceType: {},\n };\n\n for (const resource of dumpStats) {\n const typeKey = `${resource.type.name}/${resource.type.version}` as const;\n if (!stats.byResourceType[typeKey]) {\n stats.byResourceType[typeKey] = {\n count: 0,\n fieldNameBytes: 0,\n fieldsCount: 0,\n dataBytes: 0,\n kvCount: 0,\n kvBytes: 0,\n };\n }\n\n const typeStats = stats.byResourceType[typeKey];\n typeStats.count++;\n stats.total.count++;\n\n for (const field of resource.fields) {\n typeStats.fieldNameBytes += field.name.length;\n typeStats.fieldsCount++;\n stats.total.fieldNameBytes += field.name.length;\n stats.total.fieldsCount++;\n }\n\n if (resource.data) {\n const dataLength = resource.data?.length ?? 0;\n typeStats.dataBytes += dataLength;\n stats.total.dataBytes += dataLength;\n }\n\n typeStats.kvCount += resource.kv.length;\n stats.total.kvCount += resource.kv.length;\n\n for (const kv of resource.kv) {\n const kvLength = kv.key.length + kv.value.length;\n typeStats.kvBytes += kvLength;\n stats.total.kvBytes += kvLength;\n }\n }\n\n return stats;\n}\n"],"
|
|
1
|
+
{"version":3,"file":"dump.js","names":[],"sources":["../src/dump.ts"],"sourcesContent":["import type { ExtendedResourceData } from \"./state\";\n\nexport type ResourceStats = {\n /** Number of resources of this type */\n count: number;\n /** Total number of bytes in the field names of all resources of this type */\n fieldNameBytes: number;\n /** Total number of fields in all resources of this type */\n fieldsCount: number;\n /** Total number of bytes in the data of all resources of this type */\n dataBytes: number;\n /** Total number of key-value records in all resources of this type */\n kvCount: number;\n /** Total number of bytes in the key-value records of all resources of this type */\n kvBytes: number;\n};\n\n/**\n * A map of resource type statistics, keyed by the resource type name and version.\n *\n * @type {Record<string, ResourceStats>}\n */\nexport type TreeDumpStats = {\n total: ResourceStats;\n byResourceType: Record<`${string}/${string}`, ResourceStats>;\n};\n\n/**\n * Analyzes a collection of resources and generates statistics grouped by resource type.\n *\n * This function processes an array of ExtendedResourceData and calculates various metrics\n * for each unique resource type, including:\n * - Count of resources\n * - Total bytes in field names\n * - Total number of fields\n * - Total bytes in resource data\n * - Total number of key-value records\n * - Total bytes in key-value records\n *\n * The statistics are organized by resource type using a key in the format \"typeName/version\".\n *\n * @param dumpStats - Array of ExtendedResourceData objects to analyze\n * @returns A DumpStats object containing statistics for each resource type\n * @example\n * ```typescript\n * const resources = [...]; // Array of ExtendedResourceData\n * const stats = treeDumpStats(resources);\n * // stats = {\n * // \"MyResource/1\": {\n * // count: 5,\n * // fieldNameBytes: 150,\n * // fieldsCount: 10,\n * // dataBytes: 1024,\n * // kvCount: 3,\n * // kvBytes: 256\n * // },\n * // ...\n * // }\n * ```\n */\nexport function treeDumpStats(dumpStats: ExtendedResourceData[]): TreeDumpStats {\n const stats: TreeDumpStats = {\n total: {\n count: 0,\n fieldNameBytes: 0,\n fieldsCount: 0,\n dataBytes: 0,\n kvCount: 0,\n kvBytes: 0,\n },\n byResourceType: {},\n };\n\n for (const resource of dumpStats) {\n const typeKey = `${resource.type.name}/${resource.type.version}` as const;\n if (!stats.byResourceType[typeKey]) {\n stats.byResourceType[typeKey] = {\n count: 0,\n fieldNameBytes: 0,\n fieldsCount: 0,\n dataBytes: 0,\n kvCount: 0,\n kvBytes: 0,\n };\n }\n\n const typeStats = stats.byResourceType[typeKey];\n typeStats.count++;\n stats.total.count++;\n\n for (const field of resource.fields) {\n typeStats.fieldNameBytes += field.name.length;\n typeStats.fieldsCount++;\n stats.total.fieldNameBytes += field.name.length;\n stats.total.fieldsCount++;\n }\n\n if (resource.data) {\n const dataLength = resource.data?.length ?? 0;\n typeStats.dataBytes += dataLength;\n stats.total.dataBytes += dataLength;\n }\n\n typeStats.kvCount += resource.kv.length;\n stats.total.kvCount += resource.kv.length;\n\n for (const kv of resource.kv) {\n const kvLength = kv.key.length + kv.value.length;\n typeStats.kvBytes += kvLength;\n stats.total.kvBytes += kvLength;\n }\n }\n\n return stats;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,SAAgB,cAAc,WAAkD;CAC9E,MAAM,QAAuB;EAC3B,OAAO;GACL,OAAO;GACP,gBAAgB;GAChB,aAAa;GACb,WAAW;GACX,SAAS;GACT,SAAS;GACV;EACD,gBAAgB,EAAE;EACnB;AAED,MAAK,MAAM,YAAY,WAAW;EAChC,MAAM,UAAU,GAAG,SAAS,KAAK,KAAK,GAAG,SAAS,KAAK;AACvD,MAAI,CAAC,MAAM,eAAe,SACxB,OAAM,eAAe,WAAW;GAC9B,OAAO;GACP,gBAAgB;GAChB,aAAa;GACb,WAAW;GACX,SAAS;GACT,SAAS;GACV;EAGH,MAAM,YAAY,MAAM,eAAe;AACvC,YAAU;AACV,QAAM,MAAM;AAEZ,OAAK,MAAM,SAAS,SAAS,QAAQ;AACnC,aAAU,kBAAkB,MAAM,KAAK;AACvC,aAAU;AACV,SAAM,MAAM,kBAAkB,MAAM,KAAK;AACzC,SAAM,MAAM;;AAGd,MAAI,SAAS,MAAM;GACjB,MAAM,aAAa,SAAS,MAAM,UAAU;AAC5C,aAAU,aAAa;AACvB,SAAM,MAAM,aAAa;;AAG3B,YAAU,WAAW,SAAS,GAAG;AACjC,QAAM,MAAM,WAAW,SAAS,GAAG;AAEnC,OAAK,MAAM,MAAM,SAAS,IAAI;GAC5B,MAAM,WAAW,GAAG,IAAI,SAAS,GAAG,MAAM;AAC1C,aAAU,WAAW;AACrB,SAAM,MAAM,WAAW;;;AAI3B,QAAO"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,36 +1,32 @@
|
|
|
1
|
-
'
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_value_and_error = require('./value_and_error.cjs');
|
|
3
|
+
const require_accessors = require('./accessors.cjs');
|
|
4
|
+
const require_state = require('./state.cjs');
|
|
5
|
+
const require_sync = require('./sync.cjs');
|
|
6
|
+
const require_snapshot = require('./snapshot.cjs');
|
|
7
|
+
const require_synchronized_tree = require('./synchronized_tree.cjs');
|
|
8
|
+
const require_dump = require('./dump.cjs');
|
|
2
9
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
15
|
-
exports.
|
|
16
|
-
exports.
|
|
17
|
-
exports.
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.
|
|
24
|
-
exports.
|
|
25
|
-
exports.
|
|
26
|
-
exports.isPlTreeNodeAccessor = accessors.isPlTreeNodeAccessor;
|
|
27
|
-
exports.treeEntryToResourceInfo = accessors.treeEntryToResourceInfo;
|
|
28
|
-
exports.makeResourceSnapshot = snapshot.makeResourceSnapshot;
|
|
29
|
-
exports.rsSchema = snapshot.rsSchema;
|
|
30
|
-
exports.treeEntryToResourceWithData = snapshot.treeEntryToResourceWithData;
|
|
31
|
-
exports.treeEntryToResourceWithMetadata = snapshot.treeEntryToResourceWithMetadata;
|
|
32
|
-
exports.SynchronizedTreeState = synchronized_tree.SynchronizedTreeState;
|
|
33
|
-
exports.mapValueAndError = value_and_error.mapValueAndError;
|
|
34
|
-
exports.mapValueAndErrorIfDefined = value_and_error.mapValueAndErrorIfDefined;
|
|
35
|
-
exports.treeDumpStats = dump.treeDumpStats;
|
|
36
|
-
//# sourceMappingURL=index.cjs.map
|
|
10
|
+
exports.PlError = require_accessors.PlError;
|
|
11
|
+
exports.PlTreeEntry = require_accessors.PlTreeEntry;
|
|
12
|
+
exports.PlTreeEntryAccessor = require_accessors.PlTreeEntryAccessor;
|
|
13
|
+
exports.PlTreeNodeAccessor = require_accessors.PlTreeNodeAccessor;
|
|
14
|
+
exports.PlTreeResource = require_state.PlTreeResource;
|
|
15
|
+
exports.PlTreeState = require_state.PlTreeState;
|
|
16
|
+
exports.SynchronizedTreeState = require_synchronized_tree.SynchronizedTreeState;
|
|
17
|
+
exports.TreeStateUpdateError = require_state.TreeStateUpdateError;
|
|
18
|
+
exports.constructTreeLoadingRequest = require_sync.constructTreeLoadingRequest;
|
|
19
|
+
exports.formatTreeLoadingStat = require_sync.formatTreeLoadingStat;
|
|
20
|
+
exports.initialTreeLoadingStat = require_sync.initialTreeLoadingStat;
|
|
21
|
+
exports.isPlTreeEntry = require_accessors.isPlTreeEntry;
|
|
22
|
+
exports.isPlTreeEntryAccessor = require_accessors.isPlTreeEntryAccessor;
|
|
23
|
+
exports.isPlTreeNodeAccessor = require_accessors.isPlTreeNodeAccessor;
|
|
24
|
+
exports.loadTreeState = require_sync.loadTreeState;
|
|
25
|
+
exports.makeResourceSnapshot = require_snapshot.makeResourceSnapshot;
|
|
26
|
+
exports.mapValueAndError = require_value_and_error.mapValueAndError;
|
|
27
|
+
exports.mapValueAndErrorIfDefined = require_value_and_error.mapValueAndErrorIfDefined;
|
|
28
|
+
exports.rsSchema = require_snapshot.rsSchema;
|
|
29
|
+
exports.treeDumpStats = require_dump.treeDumpStats;
|
|
30
|
+
exports.treeEntryToResourceInfo = require_accessors.treeEntryToResourceInfo;
|
|
31
|
+
exports.treeEntryToResourceWithData = require_snapshot.treeEntryToResourceWithData;
|
|
32
|
+
exports.treeEntryToResourceWithMetadata = require_snapshot.treeEntryToResourceWithMetadata;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { CommonFieldTraverseOps, CommonTraversalOps, FieldTraversalStep, GetFieldStep, ResourceTraversalOps } from "./traversal_ops.js";
|
|
2
|
+
import { ValueAndError, mapValueAndError, mapValueAndErrorIfDefined } from "./value_and_error.js";
|
|
3
|
+
import { ValueOrError } from "./value_or_error.js";
|
|
4
|
+
import { PlError, PlTreeEntry, PlTreeEntryAccessor, PlTreeNodeAccessor, ResourceInfo, TreeAccessorData, TreeAccessorInstanceData, isPlTreeEntry, isPlTreeEntryAccessor, isPlTreeNodeAccessor, treeEntryToResourceInfo } from "./accessors.js";
|
|
5
|
+
import { ExtendedResourceData, PlTreeResource, PlTreeState, ResourceDataWithFinalState, TreeStateUpdateError } from "./state.js";
|
|
6
|
+
import { PruningFunction, TreeLoadingRequest, TreeLoadingStat, constructTreeLoadingRequest, formatTreeLoadingStat, initialTreeLoadingStat, loadTreeState } from "./sync.js";
|
|
7
|
+
import { InferSnapshot, ResourceSnapshot, ResourceSnapshotSchema, ResourceWithData, ResourceWithMetadata, makeResourceSnapshot, rsSchema, treeEntryToResourceWithData, treeEntryToResourceWithMetadata } from "./snapshot.js";
|
|
8
|
+
import { SynchronizedTreeOps, SynchronizedTreeState } from "./synchronized_tree.js";
|
|
9
|
+
import { ResourceStats, TreeDumpStats, treeDumpStats } from "./dump.js";
|
|
10
|
+
export { CommonFieldTraverseOps, CommonTraversalOps, ExtendedResourceData, FieldTraversalStep, GetFieldStep, InferSnapshot, PlError, PlTreeEntry, PlTreeEntryAccessor, PlTreeNodeAccessor, PlTreeResource, PlTreeState, PruningFunction, ResourceDataWithFinalState, ResourceInfo, ResourceSnapshot, ResourceSnapshotSchema, ResourceStats, ResourceTraversalOps, ResourceWithData, ResourceWithMetadata, SynchronizedTreeOps, SynchronizedTreeState, TreeAccessorData, TreeAccessorInstanceData, TreeDumpStats, TreeLoadingRequest, TreeLoadingStat, TreeStateUpdateError, ValueAndError, ValueOrError, constructTreeLoadingRequest, formatTreeLoadingStat, initialTreeLoadingStat, isPlTreeEntry, isPlTreeEntryAccessor, isPlTreeNodeAccessor, loadTreeState, makeResourceSnapshot, mapValueAndError, mapValueAndErrorIfDefined, rsSchema, treeDumpStats, treeEntryToResourceInfo, treeEntryToResourceWithData, treeEntryToResourceWithMetadata };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { mapValueAndError, mapValueAndErrorIfDefined } from "./value_and_error.js";
|
|
2
|
+
import { PlError, PlTreeEntry, PlTreeEntryAccessor, PlTreeNodeAccessor, isPlTreeEntry, isPlTreeEntryAccessor, isPlTreeNodeAccessor, treeEntryToResourceInfo } from "./accessors.js";
|
|
3
|
+
import { PlTreeResource, PlTreeState, TreeStateUpdateError } from "./state.js";
|
|
4
|
+
import { constructTreeLoadingRequest, formatTreeLoadingStat, initialTreeLoadingStat, loadTreeState } from "./sync.js";
|
|
5
|
+
import { makeResourceSnapshot, rsSchema, treeEntryToResourceWithData, treeEntryToResourceWithMetadata } from "./snapshot.js";
|
|
6
|
+
import { SynchronizedTreeState } from "./synchronized_tree.js";
|
|
7
|
+
import { treeDumpStats } from "./dump.js";
|
|
8
|
+
|
|
9
|
+
export { PlError, PlTreeEntry, PlTreeEntryAccessor, PlTreeNodeAccessor, PlTreeResource, PlTreeState, SynchronizedTreeState, TreeStateUpdateError, constructTreeLoadingRequest, formatTreeLoadingStat, initialTreeLoadingStat, isPlTreeEntry, isPlTreeEntryAccessor, isPlTreeNodeAccessor, loadTreeState, makeResourceSnapshot, mapValueAndError, mapValueAndErrorIfDefined, rsSchema, treeDumpStats, treeEntryToResourceInfo, treeEntryToResourceWithData, treeEntryToResourceWithMetadata };
|