Skip to content

Commit

Permalink
[Components] roamresearch - Added new components
Browse files Browse the repository at this point in the history
  • Loading branch information
jcortes committed Oct 31, 2024
1 parent 0ded330 commit 58f8097
Show file tree
Hide file tree
Showing 15 changed files with 599 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "roamresearch-add-content-to-daily-note-page",
name: "Add Content To Daily Note Page",
description: "Adds content as a child block to a daily note page in Roam Research (access to encrypted and non encrypted graphs). [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/eb8OVhaFC).",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "roamresearch-add-content-to-page",
name: "Add Content To Page",
description: "Add content as a child block to an existing or new page in Roam Research (access to encrypted and non encrypted graphs). [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/eb8OVhaFC).",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "roamresearch-add-content-underneath-block",
name: "Add Content Underneath Block",
description: "Add content underneath an existing block in your Roam Research graph (access to encrypted and non encrypted graphs). [See the documentation](https://roamresearch.com/)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
Expand Down
81 changes: 81 additions & 0 deletions components/roamresearch/actions/append-block/append-block.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import utils from "../../common/utils.mjs";
import app from "../../roamresearch.app.mjs";

export default {
key: "roamresearch-append-block",
name: "Append Block",
description: "Generic append block for Roam Research pages. [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/jzuu4ODbF).",
version: "0.0.1",
type: "action",
props: {
app,
string: {
type: "string",
label: "Content",
description: "The string to append.",
},
children: {
type: "string[]",
label: "Children",
description: "The children to append. This is an array of possibly further nested child blocks.",
optional: true,
},
heading: {
type: "string",
label: "Heading",
description: "The heading to append.",
optional: true,
},
open: {
type: "boolean",
label: "Open",
description: "Whether the block should be collapsed or expanded. Defaults to `true`.",
optional: true,
},
childrenViewType: {
type: "string",
label: "Children View Type",
description: "Block view type of children blocks.",
optional: true,
options: [
"bullet",
"document",
"numbered",
],
},
uid: {
type: "string",
label: "UID",
description: "The UID of the block to append.",
optional: true,
},
},
async run({ $ }) {
const {
app,
string,
children,
heading,
open,
childrenViewType,
uid,
} = this;

const response = await app.appendBlocks({
$,
data: {
"append-data": {
string,
children: utils.parseArray(children),
heading,
open,
["children-view-type"]: childrenViewType,
uid,
},
},
});

$.export("$summary", "Succesfully ran append block.");
return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,21 @@ export default {
key: "roamresearch-get-page-or-block-data",
name: "Get Page Or Block Data",
description: "Get the data for a page or block in Roam Research (access only to non ecrypted graphs). [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/eb8OVhaFC).",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
resourceType: {
type: "string",
label: "Resource Type",
description: "The type of resource to get data for.",
options: [
"page",
"block",
propDefinition: [
app,
"resourceType",
],
},
pageOrBlock: {
type: "string",
label: "Page Title Or Block UID",
description: "The page title of the block uid to get data for. Page title example: `My Page` and Block UID example: `ideWWvTgI`.",
propDefinition: [
app,
"pageOrBlock",
],
},
},
async run({ $ }) {
Expand Down
45 changes: 45 additions & 0 deletions components/roamresearch/actions/pull-many/pull-many.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import app from "../../roamresearch.app.mjs";

export default {
key: "roamresearch-pull-many",
name: "Pull Many",
description: "Generic pull many for Roam Research pages. [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/mdnjFsqoA).",
version: "0.0.1",
type: "action",
props: {
app,
eids: {
type: "string",
label: "Entity IDs",
description: "The entity ID to pull. Eg. `[[:block/uid \"08-30-2022\"] [:block/uid \"08-31-2022\"]]`.",
},
selector: {
type: "string",
label: "Selector",
description: "The selector to pull. Eg. `[:block/uid :node/title :block/string {:block/children [:block/uid :block/string]} {:block/refs [:node/title :block/string :block/uid]}]`.",
},
},
async run({ $ }) {
const {
app,
eids,
selector,
} = this;

const response = await app.pullMany({
$,
data: {
eids,
selector,
},
});

if (!response.result) {
$.export("$summary", `Failed to pull many data for entity IDs: \`${eids}\`.`);
return response;
}

$.export("$summary", "Succesfully ran pull many.");
return response;
},
};
45 changes: 45 additions & 0 deletions components/roamresearch/actions/pull/pull.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import app from "../../roamresearch.app.mjs";

export default {
key: "roamresearch-pull",
name: "Pull",
description: "Generic pull for Roam Research pages. [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/mdnjFsqoA).",
version: "0.0.1",
type: "action",
props: {
app,
eid: {
type: "string",
label: "Entity ID",
description: "The entity ID to pull. Eg. `[:block/uid \"08-30-2022\"]`.",
},
selector: {
type: "string",
label: "Selector",
description: "The selector to pull. Eg. `[:block/uid :node/title :block/string {:block/children [:block/uid :block/string]} {:block/refs [:node/title :block/string :block/uid]}]`.",
},
},
async run({ $ }) {
const {
app,
eid,
selector,
} = this;

const response = await app.pull({
$,
data: {
eid,
selector,
},
});

if (!response.result) {
$.export("$summary", `Failed to pull data for entity ID: \`${eid}\`.`);
return response;
}

$.export("$summary", "Succesfully ran pull.");
return response;
},
};
40 changes: 40 additions & 0 deletions components/roamresearch/actions/query/query.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import app from "../../roamresearch.app.mjs";

export default {
key: "roamresearch-query",
name: "Query",
description: "Generic query for Roam Research pages. [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/mdnjFsqoA).",
version: "0.0.1",
type: "action",
props: {
app,
query: {
type: "string",
label: "Query",
description: "The query to run in Datalog language. Eg. `[:find ?block-uid ?block-str :in $ ?search-string :where [?b :block/uid ?block-uid] [?b :block/string ?block-str] [(clojure.string/includes? ?block-str ?search-string)]]`.",
},
args: {
type: "string[]",
label: "Arguments",
description: "The arguments to pass to the query. Eg. `apple` as the firs argument.",
},
},
async run({ $ }) {
const {
app,
query,
args,
} = this;

const response = await app.query({
$,
data: {
query,
args,
},
});

$.export("$summary", "Succesfully ran query.");
return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "roamresearch-search-title",
name: "Search Title",
description: "Search for a title in Roam Research pages (access only to non ecrypted graphs). [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/eb8OVhaFC).",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
Expand Down
Loading

0 comments on commit 58f8097

Please sign in to comment.