Skip to content

Commit

Permalink
Call markdownToBlocks syncronously
Browse files Browse the repository at this point in the history
  • Loading branch information
bdb-dd committed May 22, 2024
1 parent a87d3b3 commit ee9b9c5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/slack-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"dependencies": {
"@azure/openai": "^1.0.0-beta.11",
"@babel/runtime": "^7.24.5",
"@bdb-dd/mack": "https://github.com/bdb-dd/mack.git#819389d8446960f8a12ba82344e53993b499144b",
"@bdb-dd/mack": "https://github.com/bdb-dd/mack.git#f26f12cef2650a1121ed6d5d2ad2b089226656cc",
"@digdir/assistant-lib": "*",
"@instructor-ai/instructor": "^0.0.7",
"@slack/bolt": "^3.18.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/slack-app/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ function updateSlackMsgCallback(

contentChunks.push(partialResponse);

const blocks = await markdownToBlocks(stripCodeBlockLang(contentChunks.join('')));
const blocks = markdownToBlocks(stripCodeBlockLang(contentChunks.join('')));

if (envVar('LOG_LEVEL') == 'debug') {
console.log(
Expand Down
4 changes: 1 addition & 3 deletions apps/slack-app/src/utils/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,4 @@ export function parseSlackTs(ts: string): { date: number; time: number } {
const testMarkdown =
'In the context of Altinn Authorization, the term "org" refers to an organization. It is used to specify the entity that owns or is associated with an application or instance within the Altinn platform. For example, in the authorization rules, `[ORG]` is a placeholder that should be replaced with the actual organization identifier.\n\nHere are some relevant source code examples:\n\n1. **Instantiation Rule:**\n ```xml\n <xacml:Rule RuleId="urn:altinn:example:ruleid:[RULE_ID]" Effect="Permit">\n <xacml:Description>[ORG_2] can instantiate an instance of [ORG_1]/[APP]</xacml:Description>\n <xacml:Target>\n <xacml:AnyOf>\n <xacml:AllOf>\n <xacml:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">\n <xacml:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">[ORG_2]</xacml:AttributeValue>\n <xacml:AttributeDesignator AttributeId="urn:altinn:org" Category="urn:oasis:names:tc:xacml:1.0:subject-category:access-subject" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>\n </xacml:Match>\n </xacml:AllOf>\n </xacml:AnyOf>\n <xacml:AnyOf>\n <xacml:AllOf>\n <xacml:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">\n <xacml:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">[ORG_1]</xacml:AttributeValue>\n <xacml:AttributeDesignator AttributeId="urn:altinn:org" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>\n </xacml:Match>\n <xacml:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">\n <xacml:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">[APP]</xacml:AttributeValue>\n <xacml:AttributeDesignator AttributeId="urn:altinn:app" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>\n </xacml:Match>\n </xacml:AllOf>\n </xacml:AnyOf>\n <xacml:AnyOf>\n <xacml:AllOf>\n <xacml:Match MatchId="urn:oasis:names:tc:xacml:1.0:function:string-equal">\n <xacml:AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">instantiate</xacml:AttributeValue>\n <xacml:AttributeDesignator AttributeId="urn:oasis:names:tc:xacml:1.0:action:action-id" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:action" DataType="http://www.w3.org/2001/XMLSchema#string" MustBePresent="false"/>\n </xacml:Match>\n </xacml:AllOf>\n </xacml:AnyOf>\n </xacml:Target>\n </xacml:Rule>\n ```\n\n2. **JSON Example:**\n ```json\n {\n "$schema": "https://altinncdn.no/schemas/json/policy/policy.schema.v1.json",\n "Policy": {\n "Rules": [\n {\n "Effect": "Permit",\n "Description": "[ORG_2] can instantiate an instance of [ORG_1]/[APP]",\n "Subjects": [\n "org:[ORG_2]"\n ],\n "Resources": [\n "app:[ORG_1]/[APP]"\n ],\n "Actions": [\n "instantiate"\n ]\n }\n ]\n }\n }\n ```\n\nIn these examples, `[ORG_1]` and `[ORG_2]` are placeholders for the organization identifiers.';

(async () => {
console.log(await markdownToBlocks(testMarkdown));
})();
// console.log(markdownToBlocks(testMarkdown));
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,9 @@
"@babel/helper-validator-identifier" "^7.22.20"
to-fast-properties "^2.0.0"

"@bdb-dd/mack@https://github.com/bdb-dd/mack.git#819389d8446960f8a12ba82344e53993b499144b":
"@bdb-dd/mack@https://github.com/bdb-dd/mack.git#f26f12cef2650a1121ed6d5d2ad2b089226656cc":
version "1.2.1"
resolved "https://github.com/bdb-dd/mack.git#819389d8446960f8a12ba82344e53993b499144b"
resolved "https://github.com/bdb-dd/mack.git#f26f12cef2650a1121ed6d5d2ad2b089226656cc"
dependencies:
"@slack/types" "^2.11.0"
fast-xml-parser "^4.4.0"
Expand Down

0 comments on commit ee9b9c5

Please sign in to comment.