Skip to content

Commit

Permalink
feat: Add datastore count API
Browse files Browse the repository at this point in the history
  • Loading branch information
cyungslack committed Feb 27, 2024
1 parent fcb40ae commit 3162134
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/typed-method-types/apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
"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,
> =
Expand Down Expand Up @@ -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>,
Expand Down Expand Up @@ -368,6 +402,7 @@ export type TypedAppsMethodTypes = {
bulkPut: AppsDatastoreBulkPut;
update: AppsDatastoreUpdate;
query: AppsDatastoreQuery;
count: AppsDatastoreCount;
delete: AppsDatastoreDelete;
bulkDelete: AppsDatastoreBulkDelete;
};
Expand Down
1 change: 1 addition & 0 deletions src/typed-method-types/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const methodsWithCustomTypes = [
"apps.datastore.bulkPut",
"apps.datastore.update",
"apps.datastore.query",
"apps.datastore.count",
"apps.auth.external.get",
"apps.auth.external.delete",
"chat.postMessage",
Expand Down
1 change: 1 addition & 0 deletions src/typed-method-types/typed-method-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Deno.test("Custom Type Methods are valid functions", () => {
assertEquals(typeof client.apps.datastore.bulkPut, "function");
assertEquals(typeof client.apps.datastore.update, "function");
assertEquals(typeof client.apps.datastore.query, "function");
assertEquals(typeof client.apps.datastore.count, "function");
assertEquals(typeof client.apps.auth.external.get, "function");
assertEquals(typeof client.apps.auth.external.delete, "function");
assertEquals(typeof client.workflows.triggers.create, "function");
Expand Down

0 comments on commit 3162134

Please sign in to comment.