Skip to content

Commit

Permalink
[Components] roamresearch - Added new components (#14482)
Browse files Browse the repository at this point in the history
* [Components] roamresearch - Added new components

* Update components/roamresearch/sources/new-modified-linked-reference/new-modified-linked-reference.mjs

Co-authored-by: michelle0927 <[email protected]>

---------

Co-authored-by: michelle0927 <[email protected]>
  • Loading branch information
jcortes and michelle0927 authored Nov 5, 2024
1 parent 129369a commit 776eed2
Show file tree
Hide file tree
Showing 15 changed files with 563 additions and 20 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 Expand Up @@ -57,7 +57,7 @@ export default {
},
});

$.export("$summary", "Succesfully added content to daily note page.");
$.export("$summary", "Successfully added content to daily note page.");
return response;
},
};
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 Expand Up @@ -55,7 +55,7 @@ export default {
},
});

$.export("$summary", "Succesfully added content to page.");
$.export("$summary", "Successfully added content to page.");
return response;
},
};
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 Expand Up @@ -54,7 +54,7 @@ export default {
},
});

$.export("$summary", "Succesfully added content underneath block.");
$.export("$summary", "Successfully added content underneath block.");
return response;
},
};
41 changes: 41 additions & 0 deletions components/roamresearch/actions/append-blocks/append-blocks.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import utils from "../../common/utils.mjs";
import app from "../../roamresearch.app.mjs";

export default {
key: "roamresearch-append-blocks",
name: "Append Blocks",
description: "Generic append blocks for Roam Research pages. [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/kjnAseQ-K).",
version: "0.0.1",
type: "action",
props: {
app,
location: {
type: "object",
label: "Location",
description: "The location to append the block to. [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/kjnAseQ-K).",
},
appendData: {
type: "string[]",
label: "Append Data",
description: "The data to append to the block. [See the documentation](https://roamresearch.com/#/app/developer-documentation/page/kjnAseQ-K).",
},
},
async run({ $ }) {
const {
app,
location,
appendData,
} = this;

const response = await app.appendBlocks({
$,
data: {
location,
["append-data"]: utils.parseArray(appendData),
},
});

$.export("$summary", "Successfully ran append blocks.");
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 All @@ -47,7 +45,7 @@ export default {
return response;
}

$.export("$summary", `Succesfully got data for ${resourceType}: \`${pageOrBlock}\`.`);
$.export("$summary", `Successfully got data for ${resourceType}: \`${pageOrBlock}\`.`);
return response;
},
};
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 IDs 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", "Successfully 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", "Successfully 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", "Successfully ran query.");
return response;
},
};
4 changes: 2 additions & 2 deletions components/roamresearch/actions/search-title/search-title.mjs
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 Expand Up @@ -35,7 +35,7 @@ export default {
},
});

$.export("$summary", `Succesfully searched for title: \`${title}\`.`);
$.export("$summary", `Successfully searched for title: \`${title}\`.`);
return response;
},
};
Loading

0 comments on commit 776eed2

Please sign in to comment.