@silverbulletmd/silverbullet 2.9.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -23
- package/client/plugos/hooks/syscall.ts +24 -10
- package/client/plugos/syscalls/asset.ts +61 -23
- package/client/plugos/syscalls/clientStore.ts +32 -6
- package/client/plugos/syscalls/client_code_widget.ts +9 -4
- package/client/plugos/syscalls/code_widget.ts +26 -11
- package/client/plugos/syscalls/config.ts +146 -30
- package/client/plugos/syscalls/datastore.ts +146 -40
- package/client/plugos/syscalls/editor.ts +1432 -711
- package/client/plugos/syscalls/event.ts +46 -13
- package/client/plugos/syscalls/fetch.ts +123 -82
- package/client/plugos/syscalls/index.ts +242 -116
- package/client/plugos/syscalls/jsonschema.ts +107 -8
- package/client/plugos/syscalls/language.ts +38 -12
- package/client/plugos/syscalls/markdown.ts +166 -50
- package/client/plugos/syscalls/mq.ts +93 -20
- package/client/plugos/syscalls/schema_introspection.ts +33 -0
- package/client/plugos/syscalls/service_registry.ts +74 -20
- package/client/plugos/syscalls/shell.ts +51 -20
- package/client/plugos/syscalls/space.ts +169 -113
- package/client/plugos/syscalls/sync.ts +50 -19
- package/client/plugos/syscalls/system.ts +236 -139
- package/client/plugos/system.ts +21 -5
- package/client/space_lua/api_documentation.ts +107 -0
- package/client/space_lua/ast.ts +13 -0
- package/client/space_lua/eval.ts +12 -4
- package/client/space_lua/parse.ts +243 -108
- package/client/space_lua/pretty_print.ts +128 -54
- package/client/space_lua/query_collection.ts +4 -4
- package/client/space_lua/render_widget.ts +156 -0
- package/client/space_lua/runtime.ts +83 -22
- package/client/space_lua/stdlib/crypto.ts +8 -3
- package/client/space_lua/stdlib/encoding.ts +27 -9
- package/client/space_lua/stdlib/js.ts +137 -22
- package/client/space_lua/stdlib/load.ts +24 -15
- package/client/space_lua/stdlib/math.ts +323 -118
- package/client/space_lua/stdlib/net.ts +57 -9
- package/client/space_lua/stdlib/os.ts +111 -44
- package/client/space_lua/stdlib/space_lua.ts +344 -20
- package/client/space_lua/stdlib/string.ts +282 -104
- package/client/space_lua/stdlib/string_pack.ts +58 -19
- package/client/space_lua/stdlib/table.ts +195 -40
- package/client/space_lua/stdlib.ts +335 -93
- package/client/space_lua/syscalls.ts +270 -0
- package/dist/plug-compile.js +1 -1
- package/package.json +3 -3
- package/plug-api/lib/ref.ts +96 -0
- package/plug-api/lib/shortcut.ts +2 -1
- package/plug-api/syscalls/config.ts +5 -3
- package/plug-api/syscalls/editor.ts +16 -0
- package/plug-api/syscalls/index.ts +17 -1
- package/plug-api/syscalls/jsonschema.ts +9 -0
- package/plug-api/syscalls/lua.ts +7 -0
- package/plug-api/syscalls/shell.ts +0 -1
- package/plug-api/syscalls/system.ts +7 -0
- package/plug-api/system_mock.ts +2 -2
- package/plug-api/types/index.ts +52 -1
- package/plug-api/types/manifest.ts +22 -4
- package/plug-api/ui/cx.ts +1 -3
- package/plug-api/ui/index.ts +3 -0
- package/plug-api/ui/panel_styles.ts +4 -3
- package/plug-api/ui/slugify.ts +44 -0
- package/client/plugos/syscalls/lua.ts +0 -81
|
@@ -25,65 +25,171 @@ export function dataStoreReadSyscalls(
|
|
|
25
25
|
clientSystem: ClientSystem,
|
|
26
26
|
): SysCallMapping {
|
|
27
27
|
return {
|
|
28
|
-
"datastore.batchGet":
|
|
29
|
-
_ctx,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
"datastore.batchGet": {
|
|
29
|
+
callback: (_ctx, keys: KvKey[]): Promise<(any | undefined)[]> => {
|
|
30
|
+
return ds.batchGet(keys);
|
|
31
|
+
},
|
|
32
|
+
description: "Gets multiple values from the key-value store.",
|
|
33
|
+
parameters: [
|
|
34
|
+
{ name: "keys", type: "table", description: "List of keys to read." },
|
|
35
|
+
],
|
|
36
|
+
returns: [
|
|
37
|
+
{
|
|
38
|
+
type: "table",
|
|
39
|
+
description: "Values in key order, with nil for missing keys.",
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
examples: [
|
|
43
|
+
{
|
|
44
|
+
code: 'local values = datastore.batchGet({{"user", "1"}, {"user", "2"}})',
|
|
45
|
+
},
|
|
46
|
+
],
|
|
33
47
|
},
|
|
34
48
|
|
|
35
|
-
"datastore.get":
|
|
36
|
-
|
|
49
|
+
"datastore.get": {
|
|
50
|
+
callback: (_ctx, key: KvKey): Promise<any | null> => {
|
|
51
|
+
return ds.get(key);
|
|
52
|
+
},
|
|
53
|
+
description: "Gets a value from the key-value store.",
|
|
54
|
+
parameters: [
|
|
55
|
+
{ name: "key", type: "table", description: "Key segments." },
|
|
56
|
+
],
|
|
57
|
+
returns: [{ description: "Stored value, or nil when absent." }],
|
|
58
|
+
examples: [{ code: 'local user = datastore.get({"user", "123"})' }],
|
|
37
59
|
},
|
|
38
60
|
|
|
39
|
-
"datastore.query":
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
61
|
+
"datastore.query": {
|
|
62
|
+
callback: async (_ctx, options: KvQueryOptions): Promise<KV[]> => {
|
|
63
|
+
const results: KV[] = [];
|
|
64
|
+
for await (const item of ds.query(options)) {
|
|
65
|
+
results.push(item);
|
|
66
|
+
}
|
|
67
|
+
return results;
|
|
68
|
+
},
|
|
69
|
+
description:
|
|
70
|
+
"Queries key-value entries, optionally restricted to a key prefix.",
|
|
71
|
+
parameters: [
|
|
72
|
+
{
|
|
73
|
+
name: "options",
|
|
74
|
+
type: "table",
|
|
75
|
+
description: "Query options, including an optional prefix.",
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
returns: [{ type: "table", description: "Matching key-value entries." }],
|
|
45
79
|
},
|
|
46
80
|
|
|
47
|
-
"datastore.queryLua":
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
81
|
+
"datastore.queryLua": {
|
|
82
|
+
callback: async (
|
|
83
|
+
_ctx,
|
|
84
|
+
prefix: string[],
|
|
85
|
+
query: LuaCollectionQuery,
|
|
86
|
+
scopeVariables?: Record<string, any>,
|
|
87
|
+
): Promise<any[]> => {
|
|
88
|
+
const sf = LuaStackFrame.createWithGlobalEnv(
|
|
89
|
+
clientSystem.spaceLuaEnv.env,
|
|
90
|
+
);
|
|
91
|
+
let env = clientSystem.spaceLuaEnv.env;
|
|
92
|
+
if (scopeVariables) {
|
|
93
|
+
env = new LuaEnv(clientSystem.spaceLuaEnv.env);
|
|
94
|
+
for (const [key, value] of Object.entries(scopeVariables)) {
|
|
95
|
+
env.setLocal(key, jsToLuaValue(value));
|
|
96
|
+
}
|
|
61
97
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
98
|
+
return (await queryLua<any>(ds.kv, prefix, query, env, sf)).map(
|
|
99
|
+
(item) => luaValueToJS(item, sf),
|
|
100
|
+
);
|
|
101
|
+
},
|
|
102
|
+
description: "Runs a Space Lua collection query over a key prefix.",
|
|
103
|
+
parameters: [
|
|
104
|
+
{
|
|
105
|
+
name: "prefix",
|
|
106
|
+
type: "table",
|
|
107
|
+
description: "Key prefix to query.",
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "query",
|
|
111
|
+
type: "table",
|
|
112
|
+
description: "Parsed collection query.",
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: "scopeVariables",
|
|
116
|
+
type: "table",
|
|
117
|
+
description: "Additional variables available to the query.",
|
|
118
|
+
optional: true,
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
returns: [
|
|
122
|
+
{
|
|
123
|
+
type: "table",
|
|
124
|
+
description: "Query results converted to Lua values.",
|
|
125
|
+
},
|
|
126
|
+
],
|
|
66
127
|
},
|
|
67
128
|
};
|
|
68
129
|
}
|
|
69
130
|
|
|
70
131
|
export function dataStoreWriteSyscalls(ds: DataStore): SysCallMapping {
|
|
71
132
|
return {
|
|
72
|
-
"datastore.delete":
|
|
73
|
-
|
|
74
|
-
|
|
133
|
+
"datastore.delete": {
|
|
134
|
+
callback: (_ctx, key: KvKey) => {
|
|
135
|
+
console.log("Deleting key", key);
|
|
136
|
+
return ds.delete(key);
|
|
137
|
+
},
|
|
138
|
+
description: "Deletes a value from the key-value store.",
|
|
139
|
+
parameters: [
|
|
140
|
+
{ name: "key", type: "table", description: "Key segments." },
|
|
141
|
+
],
|
|
142
|
+
examples: [{ code: 'datastore.delete({"user", "123"})' }],
|
|
75
143
|
},
|
|
76
144
|
|
|
77
|
-
"datastore.set":
|
|
78
|
-
|
|
145
|
+
"datastore.set": {
|
|
146
|
+
callback: (_ctx, key: KvKey, value: any) => {
|
|
147
|
+
return ds.set(key, value);
|
|
148
|
+
},
|
|
149
|
+
description: "Sets a value in the key-value store.",
|
|
150
|
+
parameters: [
|
|
151
|
+
{ name: "key", type: "table", description: "Key segments." },
|
|
152
|
+
{ name: "value", description: "Value to store." },
|
|
153
|
+
],
|
|
154
|
+
examples: [{ code: 'datastore.set({"user", "123"}, {name = "John"})' }],
|
|
79
155
|
},
|
|
80
156
|
|
|
81
|
-
"datastore.batchSet":
|
|
82
|
-
|
|
157
|
+
"datastore.batchSet": {
|
|
158
|
+
callback: (_ctx, kvs: KV[]) => {
|
|
159
|
+
return ds.batchSet(kvs);
|
|
160
|
+
},
|
|
161
|
+
description: "Sets multiple key-value entries in one operation.",
|
|
162
|
+
parameters: [
|
|
163
|
+
{
|
|
164
|
+
name: "entries",
|
|
165
|
+
type: "table",
|
|
166
|
+
description: "Entries with key and value fields.",
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
examples: [
|
|
170
|
+
{
|
|
171
|
+
code: 'datastore.batchSet({\n {key = {"user", "1"}, value = {name = "Alice"}},\n {key = {"user", "2"}, value = {name = "Bob"}},\n})',
|
|
172
|
+
},
|
|
173
|
+
],
|
|
83
174
|
},
|
|
84
175
|
|
|
85
|
-
"datastore.batchDelete":
|
|
86
|
-
|
|
176
|
+
"datastore.batchDelete": {
|
|
177
|
+
callback: (_ctx, keys: KvKey[]) => {
|
|
178
|
+
return ds.batchDelete(keys);
|
|
179
|
+
},
|
|
180
|
+
description: "Deletes multiple values from the key-value store.",
|
|
181
|
+
parameters: [
|
|
182
|
+
{
|
|
183
|
+
name: "keys",
|
|
184
|
+
type: "table",
|
|
185
|
+
description: "List of keys to delete.",
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
examples: [
|
|
189
|
+
{
|
|
190
|
+
code: 'datastore.batchDelete({{"user", "1"}, {"user", "2"}})',
|
|
191
|
+
},
|
|
192
|
+
],
|
|
87
193
|
},
|
|
88
194
|
};
|
|
89
195
|
}
|