@silverbulletmd/silverbullet 2.5.3 → 2.6.1

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.
Files changed (90) hide show
  1. package/README.md +4 -5
  2. package/client/asset_bundle/bundle.ts +3 -9
  3. package/client/data/datastore.ts +4 -5
  4. package/client/markdown_parser/constants.ts +3 -2
  5. package/client/plugos/hooks/code_widget.ts +3 -5
  6. package/client/plugos/hooks/command.ts +8 -8
  7. package/client/plugos/hooks/document_editor.ts +10 -12
  8. package/client/plugos/hooks/event.ts +33 -36
  9. package/client/plugos/hooks/mq.ts +17 -17
  10. package/client/plugos/hooks/plug_namespace.ts +3 -5
  11. package/client/plugos/hooks/slash_command.ts +12 -27
  12. package/client/plugos/hooks/syscall.ts +3 -3
  13. package/client/plugos/manifest_cache.ts +22 -15
  14. package/client/plugos/plug.ts +2 -5
  15. package/client/plugos/plug_compile.ts +67 -65
  16. package/client/plugos/protocol.ts +28 -28
  17. package/client/plugos/proxy_fetch.ts +7 -6
  18. package/client/plugos/sandboxes/worker_sandbox.ts +16 -15
  19. package/client/plugos/syscalls/asset.ts +1 -3
  20. package/client/plugos/syscalls/code_widget.ts +1 -3
  21. package/client/plugos/syscalls/config.ts +1 -5
  22. package/client/plugos/syscalls/datastore.ts +1 -1
  23. package/client/plugos/syscalls/editor.ts +63 -60
  24. package/client/plugos/syscalls/event.ts +9 -12
  25. package/client/plugos/syscalls/fetch.ts +30 -22
  26. package/client/plugos/syscalls/index.ts +10 -1
  27. package/client/plugos/syscalls/jsonschema.ts +72 -32
  28. package/client/plugos/syscalls/language.ts +9 -5
  29. package/client/plugos/syscalls/markdown.ts +29 -7
  30. package/client/plugos/syscalls/mq.ts +3 -11
  31. package/client/plugos/syscalls/service_registry.ts +1 -4
  32. package/client/plugos/syscalls/shell.ts +2 -5
  33. package/client/plugos/syscalls/sync.ts +69 -60
  34. package/client/plugos/syscalls/system.ts +2 -3
  35. package/client/plugos/system.ts +4 -10
  36. package/client/plugos/worker_runtime.ts +4 -3
  37. package/client/space_lua/aggregates.ts +632 -59
  38. package/client/space_lua/ast.ts +21 -9
  39. package/client/space_lua/ast_narrow.ts +4 -2
  40. package/client/space_lua/eval.ts +842 -536
  41. package/client/space_lua/labels.ts +6 -11
  42. package/client/space_lua/liq_null.ts +6 -0
  43. package/client/space_lua/numeric.ts +5 -8
  44. package/client/space_lua/parse.ts +290 -169
  45. package/client/space_lua/query_collection.ts +213 -149
  46. package/client/space_lua/render_lua_markdown.ts +369 -0
  47. package/client/space_lua/rp.ts +5 -4
  48. package/client/space_lua/runtime.ts +245 -142
  49. package/client/space_lua/stdlib/format.ts +34 -20
  50. package/client/space_lua/stdlib/js.ts +3 -7
  51. package/client/space_lua/stdlib/load.ts +1 -3
  52. package/client/space_lua/stdlib/math.ts +15 -14
  53. package/client/space_lua/stdlib/net.ts +25 -15
  54. package/client/space_lua/stdlib/os.ts +76 -85
  55. package/client/space_lua/stdlib/pattern.ts +28 -35
  56. package/client/space_lua/stdlib/prng.ts +15 -12
  57. package/client/space_lua/stdlib/space_lua.ts +16 -17
  58. package/client/space_lua/stdlib/string.ts +7 -17
  59. package/client/space_lua/stdlib/string_pack.ts +23 -19
  60. package/client/space_lua/stdlib/table.ts +5 -9
  61. package/client/space_lua/stdlib.ts +20 -30
  62. package/client/space_lua/tonumber.ts +79 -40
  63. package/client/space_lua/util.ts +14 -10
  64. package/dist/plug-compile.js +44 -41
  65. package/package.json +24 -22
  66. package/plug-api/lib/async.ts +19 -6
  67. package/plug-api/lib/crypto.ts +5 -6
  68. package/plug-api/lib/dates.ts +15 -7
  69. package/plug-api/lib/json.ts +10 -4
  70. package/plug-api/lib/ref.ts +18 -18
  71. package/plug-api/lib/resolve.ts +7 -11
  72. package/plug-api/lib/tags.ts +13 -4
  73. package/plug-api/lib/transclusion.ts +6 -17
  74. package/plug-api/lib/tree.ts +115 -43
  75. package/plug-api/lib/yaml.ts +25 -15
  76. package/plug-api/syscalls/asset.ts +1 -1
  77. package/plug-api/syscalls/config.ts +1 -4
  78. package/plug-api/syscalls/editor.ts +14 -14
  79. package/plug-api/syscalls/jsonschema.ts +1 -3
  80. package/plug-api/syscalls/lua.ts +3 -9
  81. package/plug-api/syscalls/mq.ts +1 -4
  82. package/plug-api/syscalls/shell.ts +4 -1
  83. package/plug-api/syscalls/space.ts +3 -10
  84. package/plug-api/syscalls/system.ts +1 -4
  85. package/plug-api/syscalls/yaml.ts +2 -6
  86. package/plug-api/types/client.ts +16 -1
  87. package/plug-api/types/event.ts +6 -4
  88. package/plug-api/types/manifest.ts +8 -9
  89. package/plugs/builtin_plugs.ts +2 -2
  90. package/dist/worker_runtime_bundle.js +0 -233
@@ -176,7 +176,8 @@ export type LuaExpression =
176
176
  | LuaTableConstructor
177
177
  | LuaFunctionDefinition
178
178
  | LuaQueryExpression
179
- | LuaFilteredCallExpression;
179
+ | LuaFilteredCallExpression
180
+ | LuaAggregateCallExpression;
180
181
 
181
182
  export type LuaNilLiteral = {
182
183
  type: "Nil";
@@ -235,6 +236,7 @@ export type LuaFunctionCallExpression = {
235
236
  prefix: LuaPrefixExpression;
236
237
  name?: string;
237
238
  args: LuaExpression[];
239
+ orderBy?: LuaOrderBy[];
238
240
  } & ASTContext;
239
241
 
240
242
  export type LuaBinaryExpression = {
@@ -255,10 +257,7 @@ export type LuaTableConstructor = {
255
257
  fields: LuaTableField[];
256
258
  } & ASTContext;
257
259
 
258
- export type LuaTableField =
259
- | LuaDynamicField
260
- | LuaPropField
261
- | LuaExpressionField;
260
+ export type LuaTableField = LuaDynamicField | LuaPropField | LuaExpressionField;
262
261
 
263
262
  export type LuaDynamicField = {
264
263
  type: "DynamicField";
@@ -289,6 +288,13 @@ export type LuaFilteredCallExpression = {
289
288
  filter: LuaExpression;
290
289
  } & ASTContext;
291
290
 
291
+ // Aggregate call with intra-aggregate order by
292
+ export type LuaAggregateCallExpression = {
293
+ type: "AggregateCall";
294
+ call: LuaFunctionCallExpression;
295
+ orderBy: LuaOrderBy[];
296
+ } & ASTContext;
297
+
292
298
  // Query stuff
293
299
  export type LuaQueryExpression = {
294
300
  type: "Query";
@@ -299,15 +305,16 @@ export type LuaQueryClause =
299
305
  | LuaFromClause
300
306
  | LuaWhereClause
301
307
  | LuaLimitClause
308
+ | LuaOffsetClause
302
309
  | LuaOrderByClause
303
310
  | LuaSelectClause
304
311
  | LuaGroupByClause
305
312
  | LuaHavingClause;
306
313
 
314
+ // Field list used by `from`, `select` and `group by` clauses
307
315
  export type LuaFromClause = {
308
316
  type: "From";
309
- name?: string;
310
- expression: LuaExpression;
317
+ fields: LuaTableField[];
311
318
  } & ASTContext;
312
319
 
313
320
  export type LuaWhereClause = {
@@ -321,6 +328,11 @@ export type LuaLimitClause = {
321
328
  offset?: LuaExpression;
322
329
  } & ASTContext;
323
330
 
331
+ export type LuaOffsetClause = {
332
+ type: "Offset";
333
+ offset: LuaExpression;
334
+ } & ASTContext;
335
+
324
336
  export type LuaOrderByClause = {
325
337
  type: "OrderBy";
326
338
  orderBy: LuaOrderBy[];
@@ -336,12 +348,12 @@ export type LuaOrderBy = {
336
348
 
337
349
  export type LuaSelectClause = {
338
350
  type: "Select";
339
- expression: LuaExpression;
351
+ fields: LuaTableField[];
340
352
  } & ASTContext;
341
353
 
342
354
  export type LuaGroupByClause = {
343
355
  type: "GroupBy";
344
- expressions: LuaExpression[];
356
+ fields: LuaTableField[];
345
357
  } & ASTContext;
346
358
 
347
359
  export type LuaHavingClause = {
@@ -3,8 +3,10 @@
3
3
  import type { ASTCtx, LuaExpression, LuaLValue, LuaStatement } from "./ast.ts";
4
4
 
5
5
  // Extract by `type` discriminant
6
- type NarrowByType<U, K extends U extends { type: infer T } ? T : never> =
7
- Extract<U, { type: K }>;
6
+ type NarrowByType<
7
+ U,
8
+ K extends U extends { type: infer T } ? T : never,
9
+ > = Extract<U, { type: K }>;
8
10
 
9
11
  // Expressions
10
12
  export const asStringExpr = (e: LuaExpression) =>