#38 Phase 1: Define CasStore, VarStore, TagStore, Store types in core/src/types.ts #39

Closed
opened 2026-06-02 05:30:40 +00:00 by xiaoju · 0 comments
Owner

Parent

Part of #38 — unified Store type refactor.

What

Define the new type definitions in core/src/types.ts. Use type not interface.

type CasStore = {
  get(hash: Hash): CasNode | null
  put(type: Hash, payload: unknown): Hash
  has(hash: Hash): boolean
  delete(hash: Hash): boolean
  listByType(type: Hash, options?: ListOptions): ListEntry[]
  listMeta(options?: ListOptions): ListEntry[]
  listSchemas(options?: ListOptions): ListEntry[]
}

type VarStore = {
  set(name: string, hash: Hash, options?: VarSetOptions): Variable
  get(name: string, schema?: Hash): Variable | null
  remove(name: string, schema?: Hash): Variable[]
  update(name: string, hash: Hash, options?: VarSetOptions): Variable
  list(options?: VarListOptions): Variable[]
  history(name: string, schema?: Hash): HistoryEntry[]
  close(): void
}

type TagStore = {
  tag(target: Hash, operations: TagOp[]): Tag[]
  untag(target: Hash, keys: string[]): void
  tags(target: Hash): Tag[]
  listByTag(tag: string, options?: ListOptions): Hash[]
}

type Store = {
  cas: CasStore
  var: VarStore
  tag: TagStore
}

Acceptance

  • Types exported from @ocas/core
  • Existing code unchanged (no consumers yet)
  • bun test passes, bun run check passes

小橘 🍊(NEKO Team)

## Parent Part of #38 — unified Store type refactor. ## What Define the new type definitions in `core/src/types.ts`. Use `type` not `interface`. ```ts type CasStore = { get(hash: Hash): CasNode | null put(type: Hash, payload: unknown): Hash has(hash: Hash): boolean delete(hash: Hash): boolean listByType(type: Hash, options?: ListOptions): ListEntry[] listMeta(options?: ListOptions): ListEntry[] listSchemas(options?: ListOptions): ListEntry[] } type VarStore = { set(name: string, hash: Hash, options?: VarSetOptions): Variable get(name: string, schema?: Hash): Variable | null remove(name: string, schema?: Hash): Variable[] update(name: string, hash: Hash, options?: VarSetOptions): Variable list(options?: VarListOptions): Variable[] history(name: string, schema?: Hash): HistoryEntry[] close(): void } type TagStore = { tag(target: Hash, operations: TagOp[]): Tag[] untag(target: Hash, keys: string[]): void tags(target: Hash): Tag[] listByTag(tag: string, options?: ListOptions): Hash[] } type Store = { cas: CasStore var: VarStore tag: TagStore } ``` ## Acceptance - Types exported from `@ocas/core` - Existing code unchanged (no consumers yet) - `bun test` passes, `bun run check` passes --- 小橘 🍊(NEKO Team)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shazhou/ocas#39