Skip to content

Expand static types#206

Draft
dawsontoth wants to merge 1 commit intomainfrom
typeical
Draft

Expand static types#206
dawsontoth wants to merge 1 commit intomainfrom
typeical

Conversation

@dawsontoth
Copy link
Contributor

@dawsontoth dawsontoth commented Mar 10, 2026

I did a few things here:

  1. I fixed the schema description for shard in the config-root.schema.json
  2. I added interfaces describing the methods and stuff we have on tables and resources, shuffling things around a little bit to facilitate that

Why? Well, it will more easily describe our tables and resources for consumers. I shifted the tables and databases to point people at these interfaces instead of at the return value of makeTable. These are a lot easier for IDEs, agents, and humans to read as a result. It will also let people guard their types when using static methods themselves.

Here's the question, though: what should be described in the interfaces for statics? What shouldn't be described, because its an internal implementation detail?

@dawsontoth dawsontoth changed the title fix: Remove v1+v2, defaulting to v1, and expand table interface Expand static types Mar 10, 2026
@dawsontoth dawsontoth marked this pull request as ready for review March 10, 2026 18:52
@dawsontoth dawsontoth requested a review from a team as a code owner March 10, 2026 18:52
Copy link
Member

@kriszyp kriszyp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of great stuff, thank you for working on this!

import { Context, Id, ResourceInterface, type ResourceStaticInterface } from './ResourceInterface.ts';
import { DBI } from './DatabaseInterface.ts';

export interface Table<Record extends object = any> extends TableInterface<Record> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these all things we are exposing in our public interface, or things that we have declare internally for consistency? We certainly don't document these nor ever want users accessing most of these.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should only put stuff in that we want to expose, IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to backtrack on my prior comment -- these interfaces are actually a mixture of the internal interface, and the external interface. I haven't been able to fully wrap my head around how we'd want to differentiate the two yet. Arguably there are actually three separate interfaces that show up in our code:

  1. The fully internal table interface (aka typeof TableResource) which is used inside of table.ts mostly
  2. The inside-our-harper-codebase interface
  3. The external interface that consumers can call from their applications and extensions

🤔

Copy link
Contributor

@cb1kenobi cb1kenobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Wish we had these types a long time ago! Couple of small nits that you can accept/ignore/punt.

@dawsontoth dawsontoth force-pushed the typeical branch 5 times, most recently from 7d7872b to caebdc4 Compare March 11, 2026 17:56
Copy link
Member

@kriszyp kriszyp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this kinda still in draft? Do you want me to put together a list of desired exposed properties/methods on tables?

@dawsontoth dawsontoth marked this pull request as draft March 12, 2026 15:48
import type { Context, Id, ResourceInterface, ResourceStaticInterface } from './ResourceInterface.ts';
import type { DBI } from './DatabaseInterface.ts';

export interface TableInterface<Record extends object = any> extends ResourceInterface<Record> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think any of these are table instance methods or properties except getExpiresAt() and getUpdatedTime().

remove: (valueToRemove, id: Id, options?: unknown) => void;
}

export interface TableStaticInterface<Record extends object = any> extends ResourceStaticInterface<Record> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we probably want to expose these properties:

  • attributes
  • createdTimeProperty
  • databaseName
  • expirationMS
  • getResidencyById
  • primaryKey
  • replicate
  • schemaDefined
  • sealed
  • tableName
  • updatedTimeProperty

And methods:

  • addAttributes
  • coerceId
  • getRecordCount
  • getSize
  • getNewId
  • getStorageStats
  • removeAttributes
  • setTTLExpiration
  • sourcedFrom

@dawsontoth dawsontoth force-pushed the typeical branch 2 times, most recently from f0a6ad5 to b68e814 Compare March 17, 2026 16:06
@dawsontoth
Copy link
Contributor Author

I'll peel off a few PRs #243 and #244

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants