a collection of lightweight TypeScript packages for AT Protocol, the protocol powering Bluesky
atproto bluesky typescript npm
101
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor(mst)!: replace enums with plain objects

Mary 194a382b 4729dea3

+41 -19
+7
.changeset/replace-enums-mst.md
··· 1 + --- 2 + '@atcute/mst': major 3 + --- 4 + 5 + replace enums with plain objects 6 + 7 + `DeltaType` is now an `as const` object with a companion type alias.
+7 -6
packages/utilities/mst/lib/diff.ts
··· 4 4 import { NodeWalker } from './node-walker.ts'; 5 5 6 6 /** 7 - * Type of change to a record 7 + * type of change to a record 8 8 */ 9 - export enum DeltaType { 10 - CREATED = 1, 11 - UPDATED = 2, 12 - DELETED = 3, 13 - } 9 + export const DeltaType = { 10 + CREATED: 1, 11 + UPDATED: 2, 12 + DELETED: 3, 13 + } as const; 14 + export type DeltaType = (typeof DeltaType)[keyof typeof DeltaType]; 14 15 15 16 /** 16 17 * Represents a change to a single record
+10 -5
packages/utilities/mst/lib/errors.ts
··· 2 2 * thrown when an MST key is invalid or malformed 3 3 */ 4 4 export class InvalidMstKeyError extends Error { 5 - constructor(public key: string) { 5 + key: string; 6 + 7 + constructor(key: string) { 6 8 super(`invalid mst key; key=${key}`); 9 + this.key = key; 7 10 } 8 11 } 9 12 ··· 11 14 * thrown when a referenced block cannot be found in the store 12 15 */ 13 16 export class MissingBlockError extends Error { 14 - constructor( 15 - public cid: string, 16 - public def?: string, 17 - ) { 17 + cid: string; 18 + def?: string; 19 + 20 + constructor(cid: string, def?: string) { 18 21 super(`missing block in store; cid=${cid}` + (def ? `; type=${def}` : ``)); 22 + this.cid = cid; 23 + this.def = def; 19 24 } 20 25 }
+15 -7
packages/utilities/mst/lib/node.ts
··· 27 27 */ 28 28 _bytes: Uint8Array<ArrayBuffer> | undefined; 29 29 30 + /** sorted array of keys stored in this node */ 31 + readonly keys: readonly string[]; 32 + /** array of value CIDs corresponding to each key */ 33 + readonly values: readonly CidLink[]; 34 + /** array of subtree CIDs (length is keys.length + 1) */ 35 + readonly subtrees: readonly (CidLink | null)[]; 36 + 30 37 protected constructor( 31 - /** sorted array of keys stored in this node */ 32 - readonly keys: readonly string[], 33 - /** array of value CIDs corresponding to each key */ 34 - readonly values: readonly CidLink[], 35 - /** array of subtree CIDs (length is keys.length + 1) */ 36 - readonly subtrees: readonly (CidLink | null)[], 37 - ) {} 38 + keys: readonly string[], 39 + values: readonly CidLink[], 40 + subtrees: readonly (CidLink | null)[], 41 + ) { 42 + this.keys = keys; 43 + this.values = values; 44 + this.subtrees = subtrees; 45 + } 38 46 39 47 /** 40 48 * creates a new MST node with validation
+2 -1
packages/utilities/mst/tsconfig.json
··· 22 22 "sourceMap": true, 23 23 "declaration": true, 24 24 "declarationMap": true, 25 - "stripInternal": true 25 + "stripInternal": true, 26 + "erasableSyntaxOnly": true 26 27 }, 27 28 "include": ["lib"] 28 29 }