···11+---
22+'@atcute/mst': major
33+---
44+55+replace enums with plain objects
66+77+`DeltaType` is now an `as const` object with a companion type alias.
+7-6
packages/utilities/mst/lib/diff.ts
···44import { NodeWalker } from './node-walker.ts';
5566/**
77- * Type of change to a record
77+ * type of change to a record
88 */
99-export enum DeltaType {
1010- CREATED = 1,
1111- UPDATED = 2,
1212- DELETED = 3,
1313-}
99+export const DeltaType = {
1010+ CREATED: 1,
1111+ UPDATED: 2,
1212+ DELETED: 3,
1313+} as const;
1414+export type DeltaType = (typeof DeltaType)[keyof typeof DeltaType];
14151516/**
1617 * Represents a change to a single record
+10-5
packages/utilities/mst/lib/errors.ts
···22 * thrown when an MST key is invalid or malformed
33 */
44export class InvalidMstKeyError extends Error {
55- constructor(public key: string) {
55+ key: string;
66+77+ constructor(key: string) {
68 super(`invalid mst key; key=${key}`);
99+ this.key = key;
710 }
811}
912···1114 * thrown when a referenced block cannot be found in the store
1215 */
1316export class MissingBlockError extends Error {
1414- constructor(
1515- public cid: string,
1616- public def?: string,
1717- ) {
1717+ cid: string;
1818+ def?: string;
1919+2020+ constructor(cid: string, def?: string) {
1821 super(`missing block in store; cid=${cid}` + (def ? `; type=${def}` : ``));
2222+ this.cid = cid;
2323+ this.def = def;
1924 }
2025}
+15-7
packages/utilities/mst/lib/node.ts
···2727 */
2828 _bytes: Uint8Array<ArrayBuffer> | undefined;
29293030+ /** sorted array of keys stored in this node */
3131+ readonly keys: readonly string[];
3232+ /** array of value CIDs corresponding to each key */
3333+ readonly values: readonly CidLink[];
3434+ /** array of subtree CIDs (length is keys.length + 1) */
3535+ readonly subtrees: readonly (CidLink | null)[];
3636+3037 protected constructor(
3131- /** sorted array of keys stored in this node */
3232- readonly keys: readonly string[],
3333- /** array of value CIDs corresponding to each key */
3434- readonly values: readonly CidLink[],
3535- /** array of subtree CIDs (length is keys.length + 1) */
3636- readonly subtrees: readonly (CidLink | null)[],
3737- ) {}
3838+ keys: readonly string[],
3939+ values: readonly CidLink[],
4040+ subtrees: readonly (CidLink | null)[],
4141+ ) {
4242+ this.keys = keys;
4343+ this.values = values;
4444+ this.subtrees = subtrees;
4545+ }
38463947 /**
4048 * creates a new MST node with validation