-
Notifications
You must be signed in to change notification settings - Fork 19
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 datastore count API #93
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,6 +208,35 @@ export type DatastoreQueryResponse< | |
items: DatastoreItem<Schema>[]; | ||
}; | ||
|
||
export type DatastoreCountArgs< | ||
Schema extends DatastoreSchema, | ||
> = | ||
& BaseMethodArgs | ||
& { | ||
/** | ||
* @description The name of the datastore | ||
*/ | ||
datastore: Schema["name"]; | ||
expression?: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will the descriptions of these fields be included in the documentation? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are descriptions in the documentation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's do as much as we can to provide at least a basic description to specific fields. If there are relevant links for devs to read up on for more info, let's link them to it. See for example how we do document fields and parameters and link to more information in our Node SDK: https://github.com/slackapi/node-slack-sdk/blob/main/packages/web-api/src/methods.ts#L1229-L1232 |
||
"expression_attributes"?: Record<string, string>; | ||
"expression_values"?: Record<string, string | boolean | number>; | ||
}; | ||
|
||
export type DatastoreCountResponse< | ||
Schema extends DatastoreSchema, | ||
> = | ||
& BaseResponse | ||
& { | ||
/** | ||
* @description The name of the datastore | ||
*/ | ||
datastore: Schema["name"]; | ||
/** | ||
* @description The number of items matching your query | ||
*/ | ||
count: number; | ||
}; | ||
|
||
export type DatastoreDeleteArgs< | ||
Schema extends DatastoreSchema, | ||
> = | ||
|
@@ -293,6 +322,11 @@ export type AppsDatastoreQuery = { | |
args: DatastoreQueryArgs<Schema>, | ||
): Promise<DatastoreQueryResponse<Schema>>; | ||
}; | ||
export type AppsDatastoreCount = { | ||
<Schema extends DatastoreSchema>( | ||
args: DatastoreCountArgs<Schema>, | ||
): Promise<DatastoreCountResponse<Schema>>; | ||
}; | ||
export type AppsDatastoreDelete = { | ||
<Schema extends DatastoreSchema>( | ||
args: DatastoreDeleteArgs<Schema>, | ||
|
@@ -368,6 +402,7 @@ export type TypedAppsMethodTypes = { | |
bulkPut: AppsDatastoreBulkPut; | ||
update: AppsDatastoreUpdate; | ||
query: AppsDatastoreQuery; | ||
count: AppsDatastoreCount; | ||
delete: AppsDatastoreDelete; | ||
bulkDelete: AppsDatastoreBulkDelete; | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the arguments to
datastore.query
anddatastore.count
share a lot of fields, yes? Likedatastore
,expression
, attributes and values.I recommend factoring out these shared fields into its own dedicated
type
(doesn't have to beexport
ed, can just exist in this file), maybe something like atype DynamoQueryArgs
, and have each ofDatastoreQueryArgs
andDatastoreCountArgs
leverage that shared type.This way, you don't duplicate all the work, and especially with JSDocs now being a part, don't have to duplicate the docs either!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For an example of how to do this, see the Node Slack SDK here: https://github.com/slackapi/node-slack-sdk/blob/main/packages/web-api/src/types/request/conversations.ts#L52-L53
There are a bunch of non-exported
interface
s in the above file, and they're mixed and combined together using|
and&
in typescript for different*Arguments
types (likeConversationsAcceptSharedInviteArguments
that I linked to). It is essentially the solution to the same problem we are solving in this PR.