Skip to content

Commit 2f28790

Browse files
Merge branch 'main' into fix/rui
2 parents df38c6d + e53a248 commit 2f28790

File tree

33 files changed

+292
-57
lines changed

33 files changed

+292
-57
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,6 @@ pkg/oauth/test/didroom_microservices/
9191
!/pkg/oauth/test/authz_server.keys.json
9292
!/pkg/oauth/test/credential_issuer.keys.json
9393
!/pkg/oauth/test/relying_party.keys.json
94+
95+
# mise stuff
96+
!/mise.toml

README.md

Lines changed: 218 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,240 @@
11
<!--
2-
SPDX-FileCopyrightText: 2023 Dyne.org foundation
2+
SPDX-FileCopyrightText: 2023-2025 Dyne.org foundation
33
SPDX-License-Identifier: AGPL-3.0-or-later
44
-->
55

66
[![REUSE status](https://api.reuse.software/badge/github.com/dyne/slangroom)](https://api.reuse.software/info/github.com/dyne/slangroom)
77

8-
<h1 align="center">
9-
Slangroom</br>
10-
<sub>Plugins for Zencode!</sub>
11-
</h1>
8+
<div align="center">
129

10+
# Slangroom <!-- omit in toc -->
11+
12+
### Zencode plugins? Slangroom!</br>Enhance zencode smart–contracts with your slang <!-- omit in toc -->
13+
14+
</div>
15+
16+
<p align="center">
17+
<a href="https://dyne.org">
18+
<img src="https://files.dyne.org/software_by_dyne.png" width="170">
19+
</a>
20+
</p>
1321

14-
<br><br>
1522

16-
<h4 align="center">
17-
<a href="#-quick-start">🎮 Quick start</a>
18-
<span> • </span>
19-
<a href="#-customize">🔧 Customize</a>
20-
<span> • </span>
21-
<a href="#-acknowledgements">😍 Acknowledgements</a>
22-
<span> • </span>
23-
<a href="#-contributing">👤 Contributing</a>
24-
<span> • </span>
25-
<a href="#-license">💼 License</a>
26-
</h4>
23+
---
24+
<br><br>
2725

26+
## ✨ Slangroom features <!-- omit in toc -->
2827

29-
Slangroom is a plugin system to enhance the domain-specific Zencode language, allowing to define custom operations to new sentences and making it easy to execute fast cryptographic operations on any data structure.
28+
Slangroom is a plugin system to enhance the domain-specific [Zencode language](hhttps://dev.zenroom.org/#/), allowing to define custom operations to new sentences and making it easy to execute fast cryptographic operations on any data structure.
3029

3130
Zencode has a **no-code** approach. It is a domain-specific language (DSL) **similar to human language**. One can process large data structures through complex cryptographic and logical transformations.
3231

3332
Zencode helps developers to **empower people** who know what to do with data: one can write and review business logic and data-sensitive operations **without learning to code**.
3433

35-
### To use it head your browser to [https://apiroom.net/](https://apiroom.net)
34+
Start by reading the [full documentation](https://dyne.org/slangroom/).
35+
36+
***
37+
38+
<div id="toc">
3639

37-
<details id="toc">
38-
<summary><strong>🚩 Table of Contents</strong> (click to expand)</summary>
40+
### 🚩 Table of Contents <!-- omit in toc -->
3941

42+
- [💾 Install](#-install)
4043
- [🎮 Quick start](#-quick-start)
44+
- [🌐 Usage in the browser](#-usage-in-the-browser)
45+
- [⚡ Build](#-build)
46+
- [📋 Testing](#-testing)
4147
- [🔧 Customize](#-customize)
48+
- [🐛 Troubleshooting \& debugging](#-troubleshooting--debugging)
4249
- [😍 Acknowledgements](#-acknowledgements)
4350
- [👤 Contributing](#-contributing)
4451
- [💼 License](#-license)
45-
</details>
52+
</div>
53+
54+
***
55+
## 💾 Install
56+
57+
To use slangroom in your project you must install the `@slangroom/core` package and then all the plugins that you like:
58+
59+
```sh
60+
pnpm add @slangroom/core
61+
# and then install the plugin that you need, here we install all of them
62+
pnpm add @slangroom/db @slangroom/ethereum @slangroom/fs @slangroom/git @slangroom/helpers @slangroom/http @slangroom/json-schema @slangroom/oauth @slangroom/pocketbase @slangroom/qrcode @slangroom/rdf @slangroom/redis @slangroom/shell @slangroom/timestamp @slangroom/wallet @slangroom/zencode
63+
```
64+
65+
66+
**[🔝 back to top](#toc)**
4667

4768
***
4869
## 🎮 Quick start
4970

50-
To start using it online in a browser just head your browser to [https://apiroom.net/](https://apiroom.net)
71+
After having installed the core plugin along with the other plugins that you need (here wew continuer with all the plugins) you can
72+
use it in your code in the following way:
73+
74+
```ts
75+
import { Slangroom } from '@slangroom/core';
76+
import { db } from '@slangroom/db';
77+
import { ethereum } from '@slangroom/ethereum';
78+
import { fs } from '@slangroom/fs';
79+
import { git } from '@slangroom/git';
80+
import { helpers } from '@slangroom/helpers';
81+
import { http } from '@slangroom/http';
82+
import { JSONSchema } from '@slangroom/json-schema';
83+
import { oauth } from '@slangroom/oauth';
84+
import { pocketbase } from '@slangroom/pocketbase';
85+
import { qrcode } from '@slangroom/qrcode';
86+
import { rdf } from '@slangroom/rdf';
87+
import { redis } from '@slangroom/redis';
88+
import { shell } from '@slangroom/shell';
89+
import { timestamp } from '@slangroom/timestamp';
90+
import { wallet } from '@slangroom/wallet';
91+
import { zencode } from '@slangroom/zencode';
92+
93+
const SLANGROOM_PLUGINS = [
94+
db,
95+
ethereum,
96+
fs,
97+
git,
98+
helpers,
99+
http,
100+
JSONSchema,
101+
oauth,
102+
pocketbase,
103+
qrcode,
104+
rdf,
105+
redis,
106+
shell,
107+
timestamp,
108+
wallet,
109+
zencode
110+
];
111+
112+
const slang = new Slangroom(SLANGROOM_PLUGINS);
113+
114+
// slangroom contract that you want to run
115+
// here we simply take the timestamp in seconds
116+
const script = `Rule unknown ignore
117+
Given I fetch the local timestamp in seconds and output into 'timestamp'
118+
Given I have a 'time' named 'timestamp'
119+
Then print the 'timestamp'
120+
`;
121+
const data = {};
122+
const keys = {};
123+
124+
const res = await slangroom.execute(script, { data, keys })
125+
```
126+
127+
If you do not wwant to integrate slangroom in your code but wwant to use it, you can simply use:
128+
* [ncr](https://github.com/forkbombEu/ncr): No code REST API server based on slangroom
129+
* [slangroom-exec](https://github.com/dyne/slangroom-exec): CLI tool to run slangroom contracts (offers also go bindings)
130+
* [twinroom](https://github.com/forkbombEu/twinroom): Create your own CLI tool that under the hoods run slangroom contracts.
131+
132+
### 🌐 Usage in the browser
133+
134+
Slangroom can also be directly used in the browser thorugh the plugin @slangroom/browser. This plugin at the moment contains only a subsets of plugin that are:
135+
* [@slangroom/helpers](https://dyne.org/slangroom/examples/#helpers-plugin-examples)
136+
* [@slangroom/http](https://dyne.org/slangroom/examples/#http-plugin-examples)
137+
* [@slangroom/json-schema](https://dyne.org/slangroom/examples/#json-schema-plugin-examples)
138+
* [@slangroom/location](https://dyne.org/slangroom/examples/#location-plugin-examples)
139+
* [@slangroom/pocketbase](https://dyne.org/slangroom/examples/#pocketbase-plugin-examples)
140+
* [@slangroom/qrcode](https://dyne.org/slangroom/examples/#qrcode-plugin-examples)
141+
* [@slangroom/timestamp](https://dyne.org/slangroom/examples/#timestamp-plugin-examples)
142+
143+
A minimal example is:
144+
145+
```html
146+
<html>
147+
<head>
148+
<script type="module" id="slangroom-loader" src="https://cdn.jsdelivr.net/npm/@slangroom/browser"></script>
149+
</head>
150+
<body>
151+
<div id="res"></div>
152+
<script>
153+
document.getElementById('slangroom-loader').addEventListener('load', () => {
154+
const script = `
155+
Rule unknown ignore
156+
Given I fetch the local timestamp in seconds and output into 'timestamp'
157+
Given I have a 'time' named 'timestamp'
158+
Then print the 'timestamp'
159+
`;
160+
const res = document.getElementById('res');
161+
slangroom.execute(script, {
162+
data: {
163+
foo: 'bar',
164+
did_url: 'https://did.dyne.org/dids/did:dyne:sandbox.test:pEn78CGNEKvMR7DJQ1yvUVUpAHKzsBz45mQw3zD2js9',
165+
},
166+
})
167+
.then((r) => {
168+
res.innerText = JSON.stringify(r.result);
169+
});
170+
});
171+
</script>
172+
</body>
173+
</html>
174+
```
175+
176+
**[🔝 back to top](#toc)**
177+
178+
***
179+
## ⚡ Build
180+
181+
To build slangroom locally you need:
182+
* `pnpm@9`
183+
* `node@^20.10.0` or `node@22`
184+
185+
both of this dependencies can be install with [mise](https://mise.jdx.dev/) by simply running `mise install` in the root of this repository. So the steps to build slangroom are:
186+
187+
```sh
188+
# clone it
189+
git clone https://github.com/dyne/slangroom
190+
cd slangroom
191+
192+
# if you want to handle node and pnpm deps with mise now run: mise install
193+
194+
# install slangroom dependencies
195+
pnpm i
196+
# build slangroom
197+
pnpm build
198+
```
51199

200+
**[🔝 back to top](#toc)**
201+
202+
***
203+
## 📋 Testing
204+
205+
In order to test slangroom you will need to:
206+
* have a redis server running on your machine, it usually can be started with:
207+
```sh
208+
sudo systemctl start redis.service
209+
```
210+
This is needed to test the redis plugin.
211+
* start a local pocketbase instance:
212+
```sh
213+
./slangroom/pkg/pocketbase/test/pocketbase serve
214+
```
215+
This is needed to test the pocketbase plugin.
216+
* start oauth microservices:
217+
```sh
218+
./slangroom/pkg/oauth/test/start_microservices.sh setup
219+
```
220+
This is needed to test the oauth plugin.
221+
222+
After that the above services are started the tests can be launched with
223+
```sh
224+
# install dependencies
225+
pnpm i
226+
# build and run tests
227+
pnpm t
228+
```
229+
If you want to test only a particular plugin you can do it with
230+
```sh
231+
# install dependencies
232+
pnpm i
233+
# build
234+
pnpm build
235+
# test (subistitute timestamp with the plugin you want to test)
236+
pnpm -F @slangroom/timestamp exec ava --verbose build/esm/test
237+
```
52238

53239
**[🔝 back to top](#toc)**
54240

@@ -59,14 +245,21 @@ To write new plugins and other technical documentation head your browser to
59245
[https://dyne.org/slangroom/](https://dyne.org/slangroom/)
60246

61247

248+
**[🔝 back to top](#toc)**
249+
250+
***
251+
## 🐛 Troubleshooting & debugging
252+
253+
Availabe bugs are reported via [GitHub issues](https://github.com/dyne/slangroom/issues).
254+
62255
**[🔝 back to top](#toc)**
63256

64257
***
65258
## 😍 Acknowledgements
66259

67260
<img alt="software by Dyne.org" src="https://files.dyne.org/software_by_dyne.png" width="150" />
68261

69-
Copyleft 🄯 2023—2024 by [Dyne.org](https://www.dyne.org) foundation, Amsterdam.
262+
Copyleft 🄯 2023—2025 by [Dyne.org](https://www.dyne.org) foundation, Amsterdam.
70263

71264
The grammar package has been created starting from [CodeMirror 6 language package template](https://github.com/codemirror/lang-example).
72265

@@ -90,7 +283,7 @@ Please first take a look at the [Dyne.org - Contributor License Agreement](CONTR
90283
***
91284
## 💼 License
92285
Slangroom - the missing plugin system for Zencode
93-
Copyleft 🄯 2021-2024 Dyne.org foundation, Amsterdam
286+
Copyleft 🄯 2023-2025 Dyne.org foundation, Amsterdam
94287

95288
This program is free software: you can redistribute it and/or modify
96289
it under the terms of the GNU Affero General Public License as
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Rule unknown ignore
22

3-
Given I connect to 'database' and send statement 'statement' and send parameters 'parameters' and execute sql statement with parameters and output into 'result'
3+
Given I connect to 'database' and send statement 'statement' and send parameters 'parameters' and execute parametrized sql statement and output into 'result'
44

55
Given I have a 'string dictionary' named 'result'
66
Then print the 'result'

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "node_modules/@lerna-lite/cli/schemas/lerna-schema.json",
3-
"version": "1.45.1",
3+
"version": "1.45.2",
44
"command": {
55
"publish": {
66
"conventionalCommits": true

mise.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-FileCopyrightText: 2023 Dyne.org foundation
2+
#
3+
# SPDX-License-Identifier: AGPL-3.0-or-later
4+
5+
[tools]
6+
node = "22"
7+
pnpm = "9"

pkg/browser/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
"@slangroom/json-schema": "workspace:*",
99
"@slangroom/location": "workspace:*",
1010
"@slangroom/pocketbase": "workspace:*",
11-
"@slangroom/qrcode": "workspace:*"
11+
"@slangroom/qrcode": "workspace:*",
12+
"@slangroom/timestamp": "workspace:*"
1213
},
13-
"version": "1.45.1",
14+
"version": "1.45.2",
1415
"repository": "https://github.com/dyne/slangroom",
1516
"license": "AGPL-3.0-only",
1617
"type": "module",

pkg/browser/public/index.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ <h1>Test http</h1>
1515
<div id="test-pocketbase"></div>
1616
<div id="test-pocketbase-2"></div>
1717
<div id="test-pocketbase-3"></div>
18+
<div id="test-timestamp"></div>
1819
<script>
1920
const script = `
2021
Rule unknown ignore
@@ -148,6 +149,24 @@ <h1>Test http</h1>
148149
.then((r) => {
149150
Pocketbase3ResDiv.innerText = JSON.stringify(r.result);
150151
})}, 2000);
152+
153+
//
154+
155+
const scriptTimestamp = `
156+
Rule unknown ignore
157+
Given I fetch the local timestamp in seconds and output into 'timestamp'
158+
Given I have a 'time' named 'timestamp'
159+
Then print the 'timestamp'
160+
`
161+
162+
const TimestampResDiv = document.getElementById('test-timestamp');
163+
164+
slangroom.execute(scriptTimestamp, {
165+
data: {}
166+
})
167+
.then((r) => {
168+
TimestampResDiv.innerText = JSON.stringify(r.result);
169+
});
151170
</script>
152171
</body>
153172
</html>

pkg/browser/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { pocketbase, version as pocketbaseVersion } from '@slangroom/pocketbase'
99
import { helpers, version as helpersVersion } from '@slangroom/helpers';
1010
import { JSONSchema, version as jsonSchemaVersion } from '@slangroom/json-schema';
1111
import { location, version as locationVersion } from '@slangroom/location';
12+
import { timestamp, version as timestampVersion } from '@slangroom/timestamp';
1213
import { zenroomVersion } from '@slangroom/deps/zenroom';
1314
import packageJson from '@slangroom/browser/package.json' with { type: 'json' };
1415

@@ -38,6 +39,10 @@ const plugins_dict = {
3839
location: {
3940
plugin: location,
4041
version: locationVersion
42+
},
43+
timestamp: {
44+
plugin: timestamp,
45+
version: timestampVersion
4146
}
4247
};
4348

0 commit comments

Comments
 (0)