Skip to content

Typing for .subscribe()/publication API is not defined #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
oOBoomberOo opened this issue Feb 2, 2022 · 4 comments
Closed

Typing for .subscribe()/publication API is not defined #262

oOBoomberOo opened this issue Feb 2, 2022 · 4 comments

Comments

@oOBoomberOo
Copy link

No description provided.

@porsager
Copy link
Owner

porsager commented Feb 2, 2022

If you want to make a PR for this that would be appreciated 😉

cc @Minigugus

@oOBoomberOo
Copy link
Author

I do want to, but I'm afraid I'm not used to the codebase yet; combined with the lack of documentation around the feature, I'm just not sure what its types are supposed to be.
Hopefully, someone who better understands the API can teach me/write the PR themselves.

@Minigugus
Copy link
Contributor

@oOBoomberOo The #257 PR already added publication API types to the rewrite branch, for the v3 version :

postgres/types/index.d.ts

Lines 363 to 385 in 43d78d5

interface ColumnInfo {
key: number;
name: string;
type: number;
parser?(raw: string): unknown;
atttypmod: number;
}
interface RelationInfo {
schema: string;
table: string;
columns: ColumnInfo[];
keys: ColumnInfo[];
}
type ReplicationEvent =
| { command: 'insert', relation: RelationInfo }
| { command: 'delete', relation: RelationInfo, key: boolean }
| { command: 'update', relation: RelationInfo, key: boolean, old: Row | null };
interface SubscriptionHandle {
unsubscribe(): void;
}

subscribe(event: string, cb: (row: Row | null, info: ReplicationEvent) => void): Promise<SubscriptionHandle>;

@porsager Maybe @oOBoomberOo could open another PR for a v2 backport of thoses types? I guess thoses types hasn't changed between the 2 versions, that shouldn't be complicated. What do you think @oOBoomberOo?

@porsager
Copy link
Owner

porsager commented Feb 2, 2022

@Minigugus No I don't think that should be necessary. Better to focus on getting v3 out.

@porsager porsager closed this as completed Feb 2, 2022
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

No branches or pull requests

3 participants