@dxos/compute 0.8.4-main.fcfe5033a5 → 0.8.4-staging.60fe92afc8

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 (176) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +36 -1
  3. package/dist/lib/neutral/StorageService.mjs +22 -0
  4. package/dist/lib/neutral/StorageService.mjs.map +7 -0
  5. package/dist/lib/neutral/chunk-2B2KSJT6.mjs +17 -0
  6. package/dist/lib/neutral/chunk-2B2KSJT6.mjs.map +7 -0
  7. package/dist/lib/neutral/chunk-AFBNVFAY.mjs +25 -0
  8. package/dist/lib/neutral/chunk-AFBNVFAY.mjs.map +7 -0
  9. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  10. package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
  11. package/dist/lib/neutral/chunk-JAU4E4EK.mjs +53 -0
  12. package/dist/lib/neutral/chunk-JAU4E4EK.mjs.map +7 -0
  13. package/dist/lib/neutral/chunk-MEPE4HHX.mjs +21 -0
  14. package/dist/lib/neutral/chunk-MEPE4HHX.mjs.map +7 -0
  15. package/dist/lib/neutral/chunk-QZS4G6PE.mjs +240 -0
  16. package/dist/lib/neutral/chunk-QZS4G6PE.mjs.map +7 -0
  17. package/dist/lib/neutral/chunk-XEVFBI6S.mjs +62 -0
  18. package/dist/lib/neutral/chunk-XEVFBI6S.mjs.map +7 -0
  19. package/dist/lib/neutral/chunk-Z3Y7FQGN.mjs +174 -0
  20. package/dist/lib/neutral/chunk-Z3Y7FQGN.mjs.map +7 -0
  21. package/dist/lib/neutral/fib-HBDUGQW7.mjs +10 -0
  22. package/dist/lib/neutral/fib-HBDUGQW7.mjs.map +7 -0
  23. package/dist/lib/neutral/index.mjs +1179 -51
  24. package/dist/lib/neutral/index.mjs.map +4 -4
  25. package/dist/lib/neutral/meta.json +1 -1
  26. package/dist/lib/neutral/reply-RJIAJ6FV.mjs +10 -0
  27. package/dist/lib/neutral/reply-RJIAJ6FV.mjs.map +7 -0
  28. package/dist/lib/neutral/sleep-3T2CZ7RE.mjs +10 -0
  29. package/dist/lib/neutral/sleep-3T2CZ7RE.mjs.map +7 -0
  30. package/dist/lib/neutral/testing/index.mjs +27 -214
  31. package/dist/lib/neutral/testing/index.mjs.map +4 -4
  32. package/dist/types/src/Blueprint.d.ts +182 -0
  33. package/dist/types/src/Blueprint.d.ts.map +1 -0
  34. package/dist/types/src/Credential.d.ts +27 -0
  35. package/dist/types/src/Credential.d.ts.map +1 -0
  36. package/dist/types/src/Header.d.ts +9 -0
  37. package/dist/types/src/Header.d.ts.map +1 -0
  38. package/dist/types/src/Header.test.d.ts +2 -0
  39. package/dist/types/src/Header.test.d.ts.map +1 -0
  40. package/dist/types/src/LayerSpec.d.ts +56 -0
  41. package/dist/types/src/LayerSpec.d.ts.map +1 -0
  42. package/dist/types/src/McpServer.d.ts +26 -0
  43. package/dist/types/src/McpServer.d.ts.map +1 -0
  44. package/dist/types/src/Operation.d.ts +385 -0
  45. package/dist/types/src/Operation.d.ts.map +1 -0
  46. package/dist/types/src/OperationHandlerSet.d.ts +69 -0
  47. package/dist/types/src/OperationHandlerSet.d.ts.map +1 -0
  48. package/dist/types/src/OperationHandlerSet.test.d.ts +2 -0
  49. package/dist/types/src/OperationHandlerSet.test.d.ts.map +1 -0
  50. package/dist/types/src/OperationRegistry.d.ts +23 -0
  51. package/dist/types/src/OperationRegistry.d.ts.map +1 -0
  52. package/dist/types/src/Process.d.ts +255 -0
  53. package/dist/types/src/Process.d.ts.map +1 -0
  54. package/dist/types/src/Routine.d.ts +54 -0
  55. package/dist/types/src/Routine.d.ts.map +1 -0
  56. package/dist/types/src/Script.d.ts +21 -0
  57. package/dist/types/src/Script.d.ts.map +1 -0
  58. package/dist/types/src/ServiceResolver.d.ts +92 -0
  59. package/dist/types/src/ServiceResolver.d.ts.map +1 -0
  60. package/dist/types/src/StorageService.d.ts +58 -0
  61. package/dist/types/src/StorageService.d.ts.map +1 -0
  62. package/dist/types/src/Template.d.ts +61 -0
  63. package/dist/types/src/Template.d.ts.map +1 -0
  64. package/dist/types/src/Template.test.d.ts +2 -0
  65. package/dist/types/src/Template.test.d.ts.map +1 -0
  66. package/dist/types/src/Trace.d.ts +266 -0
  67. package/dist/types/src/Trace.d.ts.map +1 -0
  68. package/dist/types/src/Trigger.d.ts +192 -0
  69. package/dist/types/src/Trigger.d.ts.map +1 -0
  70. package/dist/types/src/TriggerEvent.d.ts +83 -0
  71. package/dist/types/src/TriggerEvent.d.ts.map +1 -0
  72. package/dist/types/src/errors.d.ts +308 -0
  73. package/dist/types/src/errors.d.ts.map +1 -0
  74. package/dist/types/src/index.d.ts +18 -5
  75. package/dist/types/src/index.d.ts.map +1 -1
  76. package/dist/types/src/testing/definitions.d.ts +11 -0
  77. package/dist/types/src/testing/definitions.d.ts.map +1 -0
  78. package/dist/types/src/testing/fib.d.ts +8 -0
  79. package/dist/types/src/testing/fib.d.ts.map +1 -0
  80. package/dist/types/src/testing/index.d.ts +6 -4
  81. package/dist/types/src/testing/index.d.ts.map +1 -1
  82. package/dist/types/src/testing/reply.d.ts +4 -0
  83. package/dist/types/src/testing/reply.d.ts.map +1 -0
  84. package/dist/types/src/testing/sleep.d.ts +6 -0
  85. package/dist/types/src/testing/sleep.d.ts.map +1 -0
  86. package/dist/types/src/umbrella.test.d.ts +2 -0
  87. package/dist/types/src/umbrella.test.d.ts.map +1 -0
  88. package/dist/types/tsconfig.tsbuildinfo +1 -1
  89. package/package.json +25 -36
  90. package/src/Blueprint.ts +224 -0
  91. package/src/Credential.ts +53 -0
  92. package/src/Header.test.ts +132 -0
  93. package/src/Header.ts +38 -0
  94. package/src/LayerSpec.ts +91 -0
  95. package/src/McpServer.ts +44 -0
  96. package/src/Operation.ts +646 -0
  97. package/src/OperationHandlerSet.test.ts +97 -0
  98. package/src/OperationHandlerSet.ts +181 -0
  99. package/src/OperationRegistry.ts +50 -0
  100. package/src/Process.ts +541 -0
  101. package/src/Routine.ts +68 -0
  102. package/src/Script.ts +33 -0
  103. package/src/ServiceResolver.ts +200 -0
  104. package/src/StorageService.ts +101 -0
  105. package/src/Template.test.ts +164 -0
  106. package/src/Template.ts +125 -0
  107. package/src/Trace.ts +363 -0
  108. package/src/Trigger.ts +196 -0
  109. package/src/TriggerEvent.ts +64 -0
  110. package/src/errors.ts +71 -0
  111. package/src/index.ts +20 -6
  112. package/src/testing/definitions.ts +51 -0
  113. package/src/testing/fib.ts +22 -0
  114. package/src/testing/index.ts +13 -5
  115. package/src/testing/reply.ts +18 -0
  116. package/src/testing/sleep.ts +16 -0
  117. package/src/umbrella.test.ts +51 -0
  118. package/dist/lib/neutral/chunk-JRV42MW3.mjs +0 -3101
  119. package/dist/lib/neutral/chunk-JRV42MW3.mjs.map +0 -7
  120. package/dist/types/src/compute-graph-registry.d.ts +0 -37
  121. package/dist/types/src/compute-graph-registry.d.ts.map +0 -1
  122. package/dist/types/src/compute-graph-registry.test.d.ts +0 -2
  123. package/dist/types/src/compute-graph-registry.test.d.ts.map +0 -1
  124. package/dist/types/src/compute-graph.d.ts +0 -67
  125. package/dist/types/src/compute-graph.d.ts.map +0 -1
  126. package/dist/types/src/compute-graph.test.d.ts +0 -2
  127. package/dist/types/src/compute-graph.test.d.ts.map +0 -1
  128. package/dist/types/src/compute-node.d.ts +0 -24
  129. package/dist/types/src/compute-node.d.ts.map +0 -1
  130. package/dist/types/src/functions/async-function.d.ts +0 -68
  131. package/dist/types/src/functions/async-function.d.ts.map +0 -1
  132. package/dist/types/src/functions/edge-function.d.ts +0 -20
  133. package/dist/types/src/functions/edge-function.d.ts.map +0 -1
  134. package/dist/types/src/functions/function-defs.d.ts +0 -11
  135. package/dist/types/src/functions/function-defs.d.ts.map +0 -1
  136. package/dist/types/src/functions/index.d.ts +0 -4
  137. package/dist/types/src/functions/index.d.ts.map +0 -1
  138. package/dist/types/src/hyperformula.test.d.ts +0 -2
  139. package/dist/types/src/hyperformula.test.d.ts.map +0 -1
  140. package/dist/types/src/testing/test-builder.d.ts +0 -15
  141. package/dist/types/src/testing/test-builder.d.ts.map +0 -1
  142. package/dist/types/src/testing/test-plugin.d.ts +0 -35
  143. package/dist/types/src/testing/test-plugin.d.ts.map +0 -1
  144. package/dist/types/src/testing/test-runtime.d.ts +0 -10
  145. package/dist/types/src/testing/test-runtime.d.ts.map +0 -1
  146. package/dist/types/src/testing/util.d.ts +0 -2
  147. package/dist/types/src/testing/util.d.ts.map +0 -1
  148. package/dist/types/src/types/hyperformula.d.ts +0 -8
  149. package/dist/types/src/types/hyperformula.d.ts.map +0 -1
  150. package/dist/types/src/types/index.d.ts +0 -3
  151. package/dist/types/src/types/index.d.ts.map +0 -1
  152. package/dist/types/src/types/types.d.ts +0 -20
  153. package/dist/types/src/types/types.d.ts.map +0 -1
  154. package/dist/types/src/types/types.test.d.ts +0 -2
  155. package/dist/types/src/types/types.test.d.ts.map +0 -1
  156. package/dist/types/src/util.d.ts +0 -2
  157. package/dist/types/src/util.d.ts.map +0 -1
  158. package/src/compute-graph-registry.test.ts +0 -167
  159. package/src/compute-graph-registry.ts +0 -97
  160. package/src/compute-graph.test.ts +0 -139
  161. package/src/compute-graph.ts +0 -265
  162. package/src/compute-node.ts +0 -59
  163. package/src/functions/async-function.ts +0 -184
  164. package/src/functions/edge-function.ts +0 -108
  165. package/src/functions/function-defs.ts +0 -2427
  166. package/src/functions/index.ts +0 -7
  167. package/src/hyperformula.test.ts +0 -14
  168. package/src/testing/test-builder.ts +0 -59
  169. package/src/testing/test-plugin.ts +0 -98
  170. package/src/testing/test-runtime.ts +0 -53
  171. package/src/testing/util.ts +0 -9
  172. package/src/types/hyperformula.ts +0 -19
  173. package/src/types/index.ts +0 -6
  174. package/src/types/types.test.ts +0 -91
  175. package/src/types/types.ts +0 -80
  176. package/src/util.ts +0 -8
@@ -1,20 +0,0 @@
1
- import { type ProcedureAst } from '@dxos/vendor-hyperformula';
2
- import { type InterpreterState } from '@dxos/vendor-hyperformula';
3
- import { AsyncFunctionPlugin } from './async-function';
4
- export declare const EDGE_FUNCTION_NAME = "DX";
5
- /**
6
- * A hyperformula function plugin for calling remote (EDGE) functions.
7
- * https://hyperformula.handsontable.com/guide/custom-functions.html#add-a-simple-custom-function
8
- */
9
- export declare class EdgeFunctionPlugin extends AsyncFunctionPlugin {
10
- dx(ast: ProcedureAst, state: InterpreterState): import("@dxos/vendor-hyperformula").RawInterpreterValue;
11
- }
12
- export declare const EdgeFunctionPluginTranslations: {
13
- enGB: {
14
- DX: string;
15
- };
16
- enUS: {
17
- DX: string;
18
- };
19
- };
20
- //# sourceMappingURL=edge-function.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"edge-function.d.ts","sourceRoot":"","sources":["../../../../src/functions/edge-function.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAsB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE3E,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAIvC;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,mBAAmB;IACzD,EAAE,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;CAkD9C;AAuBD,eAAO,MAAM,8BAA8B;;;;;;;CAO1C,CAAC"}
@@ -1,11 +0,0 @@
1
- export type FunctionDefinition = {
2
- name: string;
3
- description?: string;
4
- syntax?: string;
5
- section?: string;
6
- };
7
- /**
8
- * nullDate {year: 1899, month: 12, day: 30}
9
- */
10
- export declare const defaultFunctions: FunctionDefinition[];
11
- //# sourceMappingURL=function-defs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"function-defs.d.ts","sourceRoot":"","sources":["../../../../src/functions/function-defs.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,kBAAkB,EA42EhD,CAAC"}
@@ -1,4 +0,0 @@
1
- export * from './async-function';
2
- export * from './edge-function';
3
- export * from './function-defs';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/functions/index.ts"],"names":[],"mappings":"AAIA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=hyperformula.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hyperformula.test.d.ts","sourceRoot":"","sources":["../../../src/hyperformula.test.ts"],"names":[],"mappings":""}
@@ -1,15 +0,0 @@
1
- import { Client, type ClientOptions } from '@dxos/client';
2
- import { type Context, Resource } from '@dxos/context';
3
- import { type ComputeGraphOptions, ComputeGraphRegistry } from '../compute-graph-registry';
4
- export type TestBuilderOptions = ClientOptions & Partial<ComputeGraphOptions>;
5
- export declare class TestBuilder extends Resource {
6
- private readonly _options;
7
- private _client?;
8
- private _registry?;
9
- constructor(_options?: TestBuilderOptions);
10
- get ctx(): Context;
11
- get client(): Client;
12
- get registry(): ComputeGraphRegistry;
13
- _open(): Promise<void>;
14
- }
15
- //# sourceMappingURL=test-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-builder.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-builder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,KAAK,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGvD,OAAO,EAAE,KAAK,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAG3F,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAG9E,qBAAa,WAAY,SAAQ,QAAQ;IAI3B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAHrC,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,SAAS,CAAC,CAAuB;gBAEZ,QAAQ,GAAE,kBAAuB;IAI9D,IAAI,GAAG,IAAI,OAAO,CAEjB;IAED,IAAI,MAAM,IAAI,MAAM,CAGnB;IAED,IAAI,QAAQ,IAAI,oBAAoB,CAGnC;IAEc,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAsBtC"}
@@ -1,35 +0,0 @@
1
- import { type InterpreterState, type ProcedureAst } from '@dxos/vendor-hyperformula';
2
- import { type ComputeGraphPlugin } from '../compute-graph-registry';
3
- import { AsyncFunctionPlugin } from '../functions';
4
- /**
5
- * Testing functions run locally (not run via EDGE).
6
- * https://hyperformula.handsontable.com/guide/custom-functions.html#add-a-simple-custom-function
7
- */
8
- export declare class TestPlugin extends AsyncFunctionPlugin {
9
- /**
10
- * Simple local function returns input value.
11
- */
12
- test(ast: ProcedureAst, state: InterpreterState): import("@dxos/vendor-hyperformula").RawInterpreterValue;
13
- /**
14
- * Simple local function returns random number.
15
- */
16
- random(ast: ProcedureAst, state: InterpreterState): import("@dxos/vendor-hyperformula").RawInterpreterValue;
17
- /**
18
- * Async HTTP function.
19
- */
20
- crypto(ast: ProcedureAst, state: InterpreterState): import("@dxos/vendor-hyperformula").RawInterpreterValue;
21
- }
22
- export declare const TestPluginTranslations: {
23
- enGB: {
24
- TEST: string;
25
- RANDOM: string;
26
- CRYPTO: string;
27
- };
28
- enUS: {
29
- TEST: string;
30
- RANDOM: string;
31
- CRYPTO: string;
32
- };
33
- };
34
- export declare const testFunctionPlugins: ComputeGraphPlugin[];
35
- //# sourceMappingURL=test-plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-plugin.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-plugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGrF,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAsB,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGvE;;;GAGG;AACH,qBAAa,UAAW,SAAQ,mBAAmB;IACjD;;OAEG;IACH,IAAI,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;IAQ/C;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;IAQjD;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;CAelD;AAsBD,eAAO,MAAM,sBAAsB;;;;;;;;;;;CAWlC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,kBAAkB,EAKnD,CAAC"}
@@ -1,10 +0,0 @@
1
- import { OperationHandlerSet } from '@dxos/operation';
2
- import { type FunctionsRuntimeProvider } from '../compute-graph-registry';
3
- /**
4
- * Minimal compute runtime provider for tests and Storybook.
5
- * Will cause errors if used for actual runtime.
6
- */
7
- export declare const createMockedComputeRuntimeProvider: ({ functions, }?: {
8
- functions?: OperationHandlerSet.OperationHandlerSet;
9
- }) => FunctionsRuntimeProvider;
10
- //# sourceMappingURL=test-runtime.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-runtime.d.ts","sourceRoot":"","sources":["../../../../src/testing/test-runtime.ts"],"names":[],"mappings":"AASA,OAAO,EAAa,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEjE,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAE1E;;;GAGG;AACH,eAAO,MAAM,kCAAkC,GAAI,iBAEhD;IAAE,SAAS,CAAC,EAAE,mBAAmB,CAAC,mBAAmB,CAAA;CAAO,KAAG,wBAiCjE,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const getRegisteredFunctionNames: () => string[];
2
- //# sourceMappingURL=util.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../src/testing/util.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,0BAA0B,gBAEtC,CAAC"}
@@ -1,8 +0,0 @@
1
- import { type SimpleCellAddress, type SimpleCellRange, type SimpleDate, type SimpleDateTime } from '@dxos/vendor-hyperformula';
2
- import { DetailedCellError, ExportedCellChange } from '@dxos/vendor-hyperformula';
3
- /**
4
- * Re-exported from vendored hyperformula package.
5
- */
6
- export { DetailedCellError, ExportedCellChange };
7
- export type { SimpleCellRange, SimpleCellAddress, SimpleDate, SimpleDateTime };
8
- //# sourceMappingURL=hyperformula.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hyperformula.d.ts","sourceRoot":"","sources":["../../../../src/types/hyperformula.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAElF;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,CAAC;AAEjD,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from './hyperformula';
2
- export * from './types';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC"}
@@ -1,20 +0,0 @@
1
- export type CellAddress = Record<'row' | 'col', number>;
2
- export type CellRange = {
3
- from: CellAddress;
4
- to?: CellAddress;
5
- };
6
- export type CompleteCellRange = {
7
- from: CellAddress;
8
- to: CellAddress;
9
- };
10
- export type CellScalarValue = number | string | boolean | null;
11
- export declare const RANGE_NOTATION: RegExp;
12
- export declare const isFormula: (value: any) => value is string;
13
- export declare const cellEquals: (a: CellAddress | undefined, b: CellAddress | undefined) => boolean;
14
- export declare const columnLetter: (col: number) => string;
15
- export declare const addressToA1Notation: ({ col, row }: CellAddress) => string;
16
- export declare const addressFromA1Notation: (ref: string) => CellAddress;
17
- export declare const rangeToA1Notation: (range: CellRange) => string;
18
- export declare const rangeFromA1Notation: (ref: string) => CellRange;
19
- export declare const inRange: (range: CellRange | undefined, cell: CellAddress) => boolean;
20
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types/types.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,GAAG,KAAK,EAAE,MAAM,CAAC,CAAC;AAExD,MAAM,MAAM,SAAS,GAAG;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,EAAE,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAChE,MAAM,MAAM,iBAAiB,GAAG;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,EAAE,EAAE,WAAW,CAAA;CAAE,CAAC;AAEvE,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAE/D,eAAO,MAAM,cAAc,QAAmC,CAAC;AAE/D,eAAO,MAAM,SAAS,GAAI,OAAO,GAAG,KAAG,KAAK,IAAI,MAA8D,CAAC;AAE/G,eAAO,MAAM,UAAU,GAAI,GAAG,WAAW,GAAG,SAAS,EAAE,GAAG,WAAW,GAAG,SAAS,YAEhF,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,KAAK,MAAM,KAAG,MAM1C,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,cAAc,WAAW,KAAG,MAE/D,CAAC;AAGF,eAAO,MAAM,qBAAqB,GAAI,KAAK,MAAM,KAAG,WAOnD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,OAAO,SAAS,WAIjD,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,KAAK,MAAM,KAAG,SAGjD,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,OAAO,SAAS,GAAG,SAAS,EAAE,MAAM,WAAW,KAAG,OAwBzE,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.test.d.ts","sourceRoot":"","sources":["../../../../src/types/types.test.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export declare const parseNumberString: (str: string) => number;
2
- //# sourceMappingURL=util.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/util.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,KAAG,MAE/C,CAAC"}
@@ -1,167 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import * as Effect from 'effect/Effect';
6
- import * as Schema from 'effect/Schema';
7
- import { describe, expect, onTestFinished, test } from 'vitest';
8
-
9
- import { Trigger } from '@dxos/async';
10
- import { Obj } from '@dxos/echo';
11
- import { Operation, OperationHandlerSet } from '@dxos/operation';
12
-
13
- import { ComputeGraphRegistry, defaultPlugins } from './compute-graph-registry';
14
- import { TestBuilder, createMockedComputeRuntimeProvider } from './testing';
15
-
16
- const AddDefinition = Operation.make({
17
- meta: {
18
- key: 'add',
19
- name: 'add',
20
- description: 'Adds two numbers',
21
- },
22
- input: Schema.Struct({ a: Schema.Number, b: Schema.Number }),
23
- output: Schema.Number,
24
- services: [],
25
- });
26
-
27
- const add = AddDefinition.pipe(
28
- Operation.withHandler(
29
- Effect.fn(function* ({ a, b }) {
30
- return a + b;
31
- }),
32
- ),
33
- );
34
-
35
- describe('ComputeGraphRegistry', () => {
36
- test('invokes user function through compute graph', async () => {
37
- const computeRuntime = createMockedComputeRuntimeProvider({
38
- functions: OperationHandlerSet.make(add),
39
- });
40
- const testBuilder = new TestBuilder({
41
- types: [Operation.PersistentOperation],
42
- computeRuntime,
43
- });
44
- await testBuilder.open();
45
- onTestFinished(async () => {
46
- await testBuilder.close();
47
- });
48
-
49
- const space = await testBuilder.client.spaces.create();
50
-
51
- // Register Edge function plugin and runtime in the registry.
52
- const registry = new ComputeGraphRegistry({
53
- plugins: defaultPlugins,
54
- computeRuntime,
55
- });
56
- await registry.open();
57
- onTestFinished(async () => {
58
- await registry.close();
59
- });
60
-
61
- const graph = registry.createGraph(space);
62
- await graph.open();
63
- onTestFinished(async () => {
64
- await graph.close();
65
- });
66
-
67
- const functionObj = Operation.serialize(add);
68
- Obj.change(functionObj, (functionObj) => {
69
- functionObj.binding = 'ADD';
70
- });
71
- space.db.add(functionObj);
72
-
73
- const node = await graph.getOrCreateNode('sheet').open();
74
-
75
- // Wait for value update after async invocation completes.
76
- const trigger = new Trigger<number>();
77
- node.update.on(() => {
78
- const value = node.getValue({ row: 0, col: 0 });
79
- if (typeof value === 'number') {
80
- trigger.wake(value);
81
- }
82
- });
83
-
84
- // Set formula using binding; graph will map to DX("ADD", ...)
85
- node.setValue({ row: 0, col: 0 }, '=ADD(2, 3)');
86
-
87
- const result = await trigger.wait();
88
- expect(result).to.equal(5);
89
-
90
- // Sanity check: mapping to fully qualified id works as well.
91
- const bindingId = graph.mapFunctionBindingToId('ADD(2, 3)');
92
- expect(bindingId.startsWith(`${Obj.getDXN(functionObj).toString()}`)).to.be.true;
93
- });
94
-
95
- test('adding a function binding updates autocomplete and enables execution', async () => {
96
- const computeRuntime = createMockedComputeRuntimeProvider({
97
- functions: OperationHandlerSet.make(add),
98
- });
99
- const testBuilder = new TestBuilder({
100
- types: [Operation.PersistentOperation],
101
- computeRuntime,
102
- });
103
- await testBuilder.open();
104
- onTestFinished(async () => {
105
- await testBuilder.close();
106
- });
107
-
108
- const space = await testBuilder.client.spaces.create();
109
-
110
- const registry = new ComputeGraphRegistry({
111
- plugins: defaultPlugins,
112
- computeRuntime,
113
- });
114
- await registry.open();
115
- onTestFinished(async () => {
116
- await registry.close();
117
- });
118
-
119
- const graph = registry.createGraph(space);
120
- await graph.open();
121
- onTestFinished(async () => {
122
- await graph.close();
123
- });
124
-
125
- // Initially there should be no echo functions.
126
- expect(graph.getFunctions({ standard: false, echo: true }).length).to.equal(0);
127
-
128
- // Subscribe for function updates.
129
- const functionsUpdated = new Trigger<void>();
130
- const unsubscribe = graph.update.on((e) => {
131
- if (e.type === 'functionsUpdated') {
132
- functionsUpdated.wake();
133
- }
134
- });
135
- onTestFinished(unsubscribe);
136
-
137
- const functionObj = Operation.serialize(add);
138
- Obj.change(functionObj, (functionObj) => {
139
- functionObj.binding = 'ADD';
140
- });
141
- space.db.add(functionObj);
142
-
143
- await functionsUpdated.wait();
144
-
145
- // Autocomplete should now include the binding.
146
- const echoFunctions = graph.getFunctions({ standard: false, echo: true }).map((fn) => fn.name);
147
- expect(echoFunctions).toContain('ADD');
148
-
149
- // And the binding should execute when used in a formula.
150
- const node = await graph.getOrCreateNode('sheet').open();
151
- onTestFinished(async () => {
152
- await node.close();
153
- });
154
-
155
- const valueSettled = new Trigger<number>();
156
- node.update.on(() => {
157
- const value = node.getValue({ row: 0, col: 0 });
158
- if (typeof value === 'number') {
159
- valueSettled.wake(value);
160
- }
161
- });
162
-
163
- node.setValue({ row: 0, col: 0 }, '=ADD(2, 3)');
164
- const result = await valueSettled.wait();
165
- expect(result).to.equal(5);
166
- });
167
- });
@@ -1,97 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import type * as ManagedRuntime from 'effect/ManagedRuntime';
6
- import defaultsDeep from 'lodash.defaultsdeep';
7
-
8
- import { type Space, type SpaceId } from '@dxos/client/echo';
9
- import { Resource } from '@dxos/context';
10
- import { invariant } from '@dxos/invariant';
11
- import { log } from '@dxos/log';
12
- import type { Operation } from '@dxos/operation';
13
- import type { ConfigParams, FunctionPluginDefinition, FunctionTranslationsPackage } from '@dxos/vendor-hyperformula';
14
- import { HyperFormula } from '@dxos/vendor-hyperformula';
15
-
16
- import { ComputeGraph } from './compute-graph';
17
- import { EdgeFunctionPlugin, EdgeFunctionPluginTranslations, type FunctionContextOptions } from './functions';
18
-
19
- export type ComputeGraphPlugin = {
20
- plugin: FunctionPluginDefinition;
21
- translations: FunctionTranslationsPackage;
22
- };
23
-
24
- export type FunctionsRuntimeProvider = {
25
- getRuntime(spaceId: SpaceId): ManagedRuntime.ManagedRuntime<Operation.Service, never>;
26
- };
27
-
28
- export type ComputeGraphOptions = {
29
- plugins?: ComputeGraphPlugin[];
30
- computeRuntime: FunctionsRuntimeProvider;
31
- } & Partial<FunctionContextOptions> &
32
- Partial<ConfigParams>;
33
-
34
- export const defaultPlugins: ComputeGraphPlugin[] = [
35
- {
36
- plugin: EdgeFunctionPlugin,
37
- translations: EdgeFunctionPluginTranslations,
38
- },
39
- ];
40
-
41
- export const defaultOptions: Partial<ComputeGraphOptions> = {
42
- licenseKey: 'gpl-v3',
43
- };
44
-
45
- /**
46
- * Manages a collection of ComputeGraph instances for each space.
47
- *
48
- * [ComputePlugin] => [ComputeGraphRegistry] => [ComputeGraph(Space)] => [ComputeNode(Object)]
49
- *
50
- * NOTE: The ComputeGraphRegistry manages the hierarchy of resources via its root Context.
51
- */
52
- // TODO(burdon): Move graph into separate plugin; isolate HF deps.
53
- export class ComputeGraphRegistry extends Resource {
54
- private readonly _graphs = new Map<SpaceId, ComputeGraph>();
55
- private readonly _options: ComputeGraphOptions;
56
-
57
- constructor(options: ComputeGraphOptions) {
58
- super();
59
- this._options = defaultsDeep({}, options, defaultOptions);
60
- this._options.plugins = this._options.plugins ?? defaultPlugins;
61
- this._options.plugins?.forEach(({ plugin, translations }) => {
62
- HyperFormula.registerFunctionPlugin(plugin, translations);
63
- });
64
- }
65
-
66
- getGraph(spaceId: SpaceId): ComputeGraph | undefined {
67
- return this._graphs.get(spaceId);
68
- }
69
-
70
- getOrCreateGraph(space: Space): ComputeGraph {
71
- let graph = this._graphs.get(space.id);
72
- if (!graph) {
73
- log('create graph', { space: space.id });
74
- graph = this.createGraph(space);
75
- }
76
-
77
- return graph;
78
- }
79
-
80
- createGraph(space: Space): ComputeGraph {
81
- invariant(!this._graphs.has(space.id), `ComputeGraph already exists for space: ${space.id}`);
82
- const hf = HyperFormula.buildEmpty(this._options);
83
- invariant(this._options.computeRuntime, 'ComputeRuntime is required');
84
- const runtime = this._options.computeRuntime.getRuntime(space.id);
85
-
86
- const graph = new ComputeGraph(hf, runtime, space, this._options);
87
- this._graphs.set(space.id, graph);
88
- return graph;
89
- }
90
-
91
- protected override async _close(): Promise<void> {
92
- for (const graph of this._graphs.values()) {
93
- await graph.close();
94
- }
95
- this._graphs.clear();
96
- }
97
- }
@@ -1,139 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { afterEach, beforeEach, describe, expect, test } from 'vitest';
6
-
7
- import { Trigger } from '@dxos/async';
8
- import { Obj } from '@dxos/echo';
9
- import { Operation } from '@dxos/operation';
10
- import { type CellValue } from '@dxos/vendor-hyperformula';
11
- import { DetailedCellError } from '@dxos/vendor-hyperformula';
12
-
13
- import { TestBuilder } from './testing';
14
-
15
- describe('ComputeGraph', () => {
16
- let testBuilder: TestBuilder;
17
- beforeEach(async () => {
18
- testBuilder = new TestBuilder({ types: [Operation.PersistentOperation] });
19
- await testBuilder.open();
20
- });
21
- afterEach(async () => {
22
- await testBuilder.close();
23
- });
24
-
25
- test('map functions', async () => {
26
- const space = await testBuilder.client.spaces.create();
27
- const graph = testBuilder.registry.createGraph(space);
28
- await graph.open();
29
-
30
- // Create script.
31
- const trigger = new Trigger();
32
- graph.update.once(() => trigger.wake());
33
- const functionObject = space.db.add(
34
- Obj.make(Operation.PersistentOperation, { name: 'test', version: '0.0.1', binding: 'TEST' }),
35
- );
36
- await trigger.wait();
37
- const functions = graph.getFunctions({ echo: true });
38
- expect(functions).to.toHaveLength(1);
39
-
40
- const id = graph.mapFunctionBindingToId('TEST()');
41
- expect(id).to.eq(`${Obj.getDXN(functionObject).toString()}()`);
42
-
43
- const restored = graph.mapFunctionBindingFromId(id);
44
- expect(restored).to.eq('TEST()');
45
- });
46
-
47
- test('map functions roundtrip with args', async () => {
48
- const space = await testBuilder.client.spaces.create();
49
- const graph = testBuilder.registry.createGraph(space);
50
- await graph.open();
51
-
52
- const trigger = new Trigger();
53
- graph.update.once(() => trigger.wake());
54
- space.db.add(Obj.make(Operation.PersistentOperation, { name: 'forex', version: '0.0.1', binding: 'FOREX' }));
55
- await trigger.wait();
56
-
57
- const stored = graph.mapFunctionBindingToId('=FOREX(C6,C7)');
58
- expect(stored).to.include('dxn:echo:');
59
- expect(stored).not.to.include('FOREX');
60
-
61
- const restored = graph.mapFunctionBindingFromId(stored);
62
- expect(restored).to.eq('=FOREX(C6,C7)');
63
- });
64
-
65
- test('map functions unknown binding returns undefined', async () => {
66
- const space = await testBuilder.client.spaces.create();
67
- const graph = testBuilder.registry.createGraph(space);
68
- await graph.open();
69
-
70
- const result = graph.mapFunctionBindingFromId('=dxn:echo:@:01ABCDEF01ABCDEF01ABCDEF01(A1,B1)');
71
- expect(result).to.be.undefined;
72
- });
73
-
74
- test('cross-node references', async () => {
75
- const space = await testBuilder.client.spaces.create();
76
- const graph = testBuilder.registry.createGraph(space);
77
-
78
- // Create nodes.
79
- const node1 = await graph.getOrCreateNode('node-1').open();
80
- const node2 = await graph.getOrCreateNode('node-2').open();
81
- expect(graph.hf.getSheetNames()).to.toHaveLength(2);
82
-
83
- {
84
- node1.graph.hf.setCellContents({ sheet: node1.sheetId, row: 0, col: 0 }, [[100, 200, 300, '=SUM(A1:C1)']]);
85
- node2.graph.hf.setCellContents({ sheet: node2.sheetId, row: 0, col: 0 }, "='node-1'!D1");
86
- const value1 = node1.graph.hf.getCellValue({
87
- sheet: node1.sheetId,
88
- col: 3,
89
- row: 0,
90
- });
91
- const value2 = node2.graph.hf.getCellValue({
92
- sheet: node2.sheetId,
93
- col: 0,
94
- row: 0,
95
- });
96
- expect(value1).to.eq(value2);
97
- }
98
-
99
- // Get updated event.
100
- const trigger = new Trigger<CellValue>();
101
- node2.update.on(({ change }) => {
102
- const value = node2.graph.hf.getCellValue({
103
- sheet: node2.sheetId,
104
- col: 0,
105
- row: 0,
106
- });
107
- expect(value).to.eq(change?.newValue);
108
- trigger.wake(value);
109
- });
110
-
111
- {
112
- node1.graph.hf.setCellContents({ sheet: node1.sheetId, row: 0, col: 0 }, 400);
113
- const value1 = node1.graph.hf.getCellValue({
114
- sheet: node1.sheetId,
115
- col: 3,
116
- row: 0,
117
- });
118
- const value2 = await trigger.wait();
119
- expect(value1).to.eq(value2);
120
- }
121
- });
122
-
123
- // TODO(burdon): Dynamically load node/model based on dependencies.
124
- // - Create dependency then close model.
125
- test('dynamic loading', async () => {
126
- const space = await testBuilder.client.spaces.create();
127
- const graph = testBuilder.registry.createGraph(space);
128
-
129
- const node1 = await graph.getOrCreateNode('node-1').open();
130
- node1.graph.hf.setCellContents({ sheet: node1.sheetId, row: 0, col: 0 }, "='node-2'!A1");
131
- const value1 = node1.graph.hf.getCellValue({
132
- sheet: node1.sheetId,
133
- col: 0,
134
- row: 0,
135
- });
136
- expect(value1).to.be.instanceof(DetailedCellError);
137
- expect((value1 as DetailedCellError).type).to.eq('REF');
138
- });
139
- });