-
Notifications
You must be signed in to change notification settings - Fork 18
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
add datastore bulk apis #92
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #92 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 36 36
Lines 1091 1091
Branches 13 16 +3
=========================================
Hits 1091 1091 ☔ View full report in Codecov by Sentry. |
I was able to test these features out with the following, seems like everything works 💯 // record_datastore.ts
import { DefineDatastore, Schema } from "deno-slack-sdk/mod.ts";
export const RecordSchema = {
id: {
type: Schema.types.string,
description: "Datastore record id of the survey",
},
};
export default DefineDatastore({
name: "data",
primary_key: "id",
attributes: RecordSchema,
}); // in a tests function
import RecordDataStore from "./datastores/data.ts";
const records = [{ id: crypto.randomUUID() }, { id: crypto.randomUUID() }];
const putResp = await client.apps.datastore.bulkPut<
typeof RecordDataStore.definition
>({
datastore: RecordDataStore.name,
items: records,
});
if (!putResp.ok) {
return { error: `Failed to bulk put the record error: ${putResp.error}` };
}
const getResp = await client.apps.datastore.bulkGet<
typeof RecordDataStore.definition
>({
datastore: RecordDataStore.name,
ids: records.map((r) => r.id),
});
if (!getResp.ok) {
return {
error: `Failed to bulk get the record error: ${getResp.error}`,
};
}
const deletedResp = await client.apps.datastore.bulkDelete<
typeof RecordDataStore.definition
>({
datastore: RecordDataStore.name,
ids: records.map((r) => r.id),
});
if (!deletedResp.ok) {
return {
error: `Failed to bulk delete the records error: ${deletedResp.error}`,
};
} // manifest.ts
import { Manifest } from "deno-slack-sdk/mod.ts";
import { PostIssueMessage } from "./functions/post_issue_message.ts";
import SubmitIssueWorkflow from "./workflows/submit_issue.ts";
import RecordDataStore from "./datastores/data.ts";
export default Manifest({
name: "gallant-mole-238",
description: "A basic sample that demonstrates issue submission to channel",
icon: "assets/default_new_app_icon.png",
workflows: [SubmitIssueWorkflow],
functions: [PostIssueMessage],
datastores: [RecordDataStore],
outgoingDomains: ["raw.githubusercontent.com"],
botScopes: [
"commands",
"chat:write",
"chat:write.public",
"datastore:read",
"datastore:write",
],
}); // import_map.json
{
"imports": {
"deno-slack-sdk/": "https://deno.land/x/[email protected]/",
"deno-slack-api/": "https://raw.githubusercontent.com/slackapi/deno-slack-api/anablsi-datastore-bulk-apis/src/"
},
"scopes": {
"https://deno.land/x/[email protected]/": {
"https://deno.land/x/[email protected]/": "https://raw.githubusercontent.com/slackapi/deno-slack-api/anablsi-datastore-bulk-apis/src/"
}
}
} |
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.
LGTM 💯 should be good to merge whenever
DO NOT MERGE YET
Summary
Add support for the experimental bulk APIs
testing
Create an app with a datastore, then use the new bulk APIs to get, put and delete items in bulk
Special notes
Requirements
deno task test
after making the changes.