Skip to content
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

[FEAT] - add a public Typescript interface for the minimal required adapter interface #6372

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/store/addon/-private/ts-interfaces/adapter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export interface Adapter {
findRecord(store: any, type: string, id: string | number, snapshot: any): Promise<any>;
findAll(store: any, type: string): Promise<any[]>;
query(store: any, type: string, query: object): Promise<any>;
queryRecord(store: any, type: string, query: object): Promise<any>;
generateIdForRecord(store: any, type: string, inputProperties: object): string | number;
serialize(snapshot: any, options: object): object;
createRecord(store: any, type: string, snapshot: any): Promise<any>;
updateRecord(store: any, type: string, snapshot: any): Promise<any>;
deleteRecord(store: any, type: string, snapshot: any): Promise<any>;
coalesceFindRequests: boolean;
findMany(store: any, type: string, ids: string[] | number[], snapshots: any[]): Promise<any[]>;
groupRecordsForFindMany(store: any, snapshots: any[]): object[][];
shouldReloadRecord(store: any, snapshot: any): boolean;
shouldReloadAll(store: any, snapshots: any[]): boolean;
shouldBackgroundReloadRecord(store: any, snapshot: any): boolean;
shouldBackgroundReloadAll(store: any, snapshots: any[]): boolean;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we more closely define object or any as Record?

Copy link
Contributor

Choose a reason for hiding this comment

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

store should be Store, snapshot should be Snapshot and snapshots should be SnapshotRecordArray, the return values of the promises should probably be unknown although any might be just as fine here.

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 assuming we need to make typescript interfaces for these constructs as well then to consider this PR mergeable?