@dxos/functions-testing 0.8.4-main.9be5663bfe → 0.8.4-main.abd8ff62ef

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/functions-testing",
3
- "version": "0.8.4-main.9be5663bfe",
3
+ "version": "0.8.4-main.abd8ff62ef",
4
4
  "description": "Functions tests",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -25,31 +25,25 @@
25
25
  }
26
26
  },
27
27
  "types": "dist/types/src/index.d.ts",
28
- "typesVersions": {
29
- "*": {
30
- "testing": [
31
- "dist/types/src/testing/index.d.ts"
32
- ]
33
- }
34
- },
35
28
  "files": [
36
29
  "dist",
37
30
  "src"
38
31
  ],
39
32
  "dependencies": {
40
33
  "@effect/platform": "0.94.4",
41
- "@dxos/async": "0.8.4-main.9be5663bfe",
42
- "@dxos/context": "0.8.4-main.9be5663bfe",
43
- "@dxos/client": "0.8.4-main.9be5663bfe",
44
- "@dxos/config": "0.8.4-main.9be5663bfe",
45
- "@dxos/echo": "0.8.4-main.9be5663bfe",
46
- "@dxos/functions": "0.8.4-main.9be5663bfe",
47
- "@dxos/functions-runtime-cloudflare": "0.8.4-main.9be5663bfe",
48
- "@dxos/functions-runtime": "0.8.4-main.9be5663bfe",
49
- "@dxos/invariant": "0.8.4-main.9be5663bfe",
50
- "@dxos/operation": "0.8.4-main.9be5663bfe",
51
- "@dxos/protocols": "0.8.4-main.9be5663bfe",
52
- "@dxos/log": "0.8.4-main.9be5663bfe"
34
+ "@dxos/async": "0.8.4-main.abd8ff62ef",
35
+ "@dxos/client": "0.8.4-main.abd8ff62ef",
36
+ "@dxos/compute": "0.8.4-main.abd8ff62ef",
37
+ "@dxos/context": "0.8.4-main.abd8ff62ef",
38
+ "@dxos/config": "0.8.4-main.abd8ff62ef",
39
+ "@dxos/echo": "0.8.4-main.abd8ff62ef",
40
+ "@dxos/functions": "0.8.4-main.abd8ff62ef",
41
+ "@dxos/functions-runtime-cloudflare": "0.8.4-main.abd8ff62ef",
42
+ "@dxos/invariant": "0.8.4-main.abd8ff62ef",
43
+ "@dxos/log": "0.8.4-main.abd8ff62ef",
44
+ "@dxos/functions-runtime": "0.8.4-main.abd8ff62ef",
45
+ "@dxos/protocols": "0.8.4-main.abd8ff62ef",
46
+ "@dxos/operation": "0.8.4-main.abd8ff62ef"
53
47
  },
54
48
  "publishConfig": {
55
49
  "access": "public"
@@ -4,18 +4,18 @@
4
4
 
5
5
  import { describe, test } from 'vitest';
6
6
 
7
+ import { Trigger } from '@dxos/compute';
7
8
  import { configPreset } from '@dxos/config';
8
9
  import { Context } from '@dxos/context';
9
10
  import { Obj, Ref } from '@dxos/echo';
10
- import { Trigger } from '@dxos/functions';
11
11
  import { FunctionRuntimeKind } from '@dxos/protocols';
12
12
 
13
13
  import { deployFunction, observeInvocations, setup, sync } from './testing';
14
14
 
15
15
  const FIB_FUNCTION_PATH = new URL('./functions/fib.ts', import.meta.url).pathname;
16
16
 
17
- // Test suite to explore who CPU time limits influence function execution
18
- describe.runIf(process.env.DX_TEST_TAGS?.includes('functions-e2e'))('CPU limit', () => {
17
+ // Test suite to explore who CPU time limits influence function execution.
18
+ describe('CPU limit', { tags: ['functions-e2e'] }, () => {
19
19
  const config = configPreset({ edge: 'dev' });
20
20
 
21
21
  test('invoke directly', { timeout: 120_000 }, async ({ expect }) => {
@@ -51,7 +51,7 @@ describe.runIf(process.env.DX_TEST_TAGS?.includes('functions-e2e'))('CPU limit',
51
51
  Obj.make(Trigger.Trigger, {
52
52
  enabled: true,
53
53
  function: Ref.make(func),
54
- spec: { kind: 'timer', cron: '* */30 * * * *' },
54
+ spec: Trigger.specTimer('* */30 * * * *'),
55
55
  input: { iterations: 100 },
56
56
  }),
57
57
  );
@@ -72,7 +72,7 @@ describe.runIf(process.env.DX_TEST_TAGS?.includes('functions-e2e'))('CPU limit',
72
72
  Obj.make(Trigger.Trigger, {
73
73
  enabled: true,
74
74
  function: Ref.make(func),
75
- spec: { kind: 'timer', cron: '* */30 * * * *' },
75
+ spec: Trigger.specTimer('* */30 * * * *'),
76
76
  input: { iterations: 1_000_000_000 },
77
77
  }),
78
78
  );
@@ -88,7 +88,7 @@ describe.runIf(process.env.DX_TEST_TAGS?.includes('functions-e2e'))('CPU limit',
88
88
  }
89
89
 
90
90
  {
91
- Obj.change(trigger, (trigger) => {
91
+ Obj.update(trigger, (trigger) => {
92
92
  trigger.input!.iterations = 100;
93
93
  });
94
94
  await sync(space);
@@ -109,7 +109,7 @@ describe.runIf(process.env.DX_TEST_TAGS?.includes('functions-e2e'))('CPU limit',
109
109
  Obj.make(Trigger.Trigger, {
110
110
  enabled: true,
111
111
  function: Ref.make(func),
112
- spec: { kind: 'timer', cron: '* * * * * *' },
112
+ spec: Trigger.specTimer('* * * * * *'),
113
113
  input: { iterations: 1_000_000 },
114
114
  }),
115
115
  );
@@ -129,20 +129,20 @@ describe.runIf(process.env.DX_TEST_TAGS?.includes('functions-e2e'))('CPU limit',
129
129
  Obj.make(Trigger.Trigger, {
130
130
  enabled: true,
131
131
  function: Ref.make(func),
132
- spec: { kind: 'timer', cron: '* * * * * *' },
132
+ spec: Trigger.specTimer('* * * * * *'),
133
133
  input: { iterations: 100 },
134
134
  }),
135
135
  );
136
136
  await sync(space);
137
137
  await observeInvocations(space, 5);
138
138
 
139
- Obj.change(trigger, (trigger) => {
139
+ Obj.update(trigger, (trigger) => {
140
140
  trigger.input!.iterations = 1_000_000_000;
141
141
  });
142
142
  await sync(space);
143
143
  await observeInvocations(space, 10);
144
144
 
145
- Obj.change(trigger, (trigger) => {
145
+ Obj.update(trigger, (trigger) => {
146
146
  trigger.input!.iterations = 100;
147
147
  });
148
148
  await sync(space);
@@ -4,12 +4,12 @@
4
4
 
5
5
  import * as Schema from 'effect/Schema';
6
6
 
7
+ import { Operation } from '@dxos/compute';
7
8
  import { Database } from '@dxos/echo';
8
- import { Operation } from '@dxos/operation';
9
9
 
10
10
  export const Fibonacci = Operation.make({
11
11
  meta: {
12
- key: 'example.org/function/fib',
12
+ key: 'org.example.function.fib',
13
13
  name: 'Fibonacci',
14
14
  description: 'Function that calculates a Fibonacci number',
15
15
  },
@@ -26,7 +26,7 @@ export const Fibonacci = Operation.make({
26
26
 
27
27
  export const Reply = Operation.make({
28
28
  meta: {
29
- key: 'example.org/function/reply',
29
+ key: 'org.example.function.reply',
30
30
  name: 'Reply',
31
31
  description: 'Function that echoes the input',
32
32
  },
@@ -36,7 +36,7 @@ export const Reply = Operation.make({
36
36
 
37
37
  export const Sleep = Operation.make({
38
38
  meta: {
39
- key: 'example.org/function/sleep',
39
+ key: 'org.example.function.sleep',
40
40
  name: 'Sleep',
41
41
  description: 'Function that sleeps for a given amount of time',
42
42
  },
@@ -51,7 +51,7 @@ export const Sleep = Operation.make({
51
51
 
52
52
  export const QueryDb = Operation.make({
53
53
  meta: {
54
- key: 'example.org/function/query',
54
+ key: 'org.example.function.query',
55
55
  name: 'Query',
56
56
  description: 'Queries the database',
57
57
  },
@@ -4,7 +4,7 @@
4
4
 
5
5
  import * as Effect from 'effect/Effect';
6
6
 
7
- import { Operation } from '@dxos/operation';
7
+ import { Operation } from '@dxos/compute';
8
8
 
9
9
  import { Fibonacci } from './definitions';
10
10
 
@@ -10,7 +10,7 @@ import * as Effect from 'effect/Effect';
10
10
  import * as Schedule from 'effect/Schedule';
11
11
  import * as Schema from 'effect/Schema';
12
12
 
13
- import { Operation } from '@dxos/operation';
13
+ import { Operation } from '@dxos/compute';
14
14
 
15
15
  const ForexEffect = Operation.make({
16
16
  meta: {
@@ -4,8 +4,8 @@
4
4
 
5
5
  import * as Effect from 'effect/Effect';
6
6
 
7
+ import { Operation } from '@dxos/compute';
7
8
  import { Database, Filter, Query as EchoQuery } from '@dxos/echo';
8
- import { Operation } from '@dxos/operation';
9
9
 
10
10
  import { QueryDb } from './definitions';
11
11
 
@@ -5,7 +5,7 @@
5
5
  import * as Console from 'effect/Console';
6
6
  import * as Effect from 'effect/Effect';
7
7
 
8
- import { Operation } from '@dxos/operation';
8
+ import { Operation } from '@dxos/compute';
9
9
 
10
10
  import { Reply } from './definitions';
11
11
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  import * as Effect from 'effect/Effect';
6
6
 
7
- import { Operation } from '@dxos/operation';
7
+ import { Operation } from '@dxos/compute';
8
8
 
9
9
  import { Sleep } from './definitions';
10
10
 
@@ -7,14 +7,13 @@ import fs from 'node:fs';
7
7
  import { sleep } from '@dxos/async';
8
8
  import { Client, type Config } from '@dxos/client';
9
9
  import { type Space } from '@dxos/client/echo';
10
+ import { Operation, Trigger } from '@dxos/compute';
10
11
  import { Context } from '@dxos/context';
11
- import { Filter, Obj, Query } from '@dxos/echo';
12
- import { Trigger } from '@dxos/functions';
12
+ import { Feed, Obj } from '@dxos/echo';
13
13
  import { InvocationTraceEndEvent, InvocationTraceStartEvent } from '@dxos/functions-runtime';
14
14
  import { FunctionsServiceClient } from '@dxos/functions-runtime/edge';
15
15
  import { bundleFunction } from '@dxos/functions-runtime/native';
16
16
  import type { BundleResult } from '@dxos/functions-runtime/native';
17
- import { Operation } from '@dxos/operation';
18
17
  import { ErrorCodec, type FunctionRuntimeKind } from '@dxos/protocols';
19
18
  import { EdgeReplicationSetting } from '@dxos/protocols/proto/dxos/echo/metadata';
20
19
 
@@ -84,8 +83,9 @@ export const observeInvocations = async (space: Space, maxCount: number | null)
84
83
  let count = 0;
85
84
  while (true) {
86
85
  try {
87
- const invocations =
88
- (await space.properties.invocationTraceQueue?.target!.query(Query.select(Filter.everything())).run()) ?? [];
86
+ const traceFeed = space.properties.invocationTraceFeed?.target;
87
+ const traceQueueDxn = traceFeed ? Feed.getQueueDxn(traceFeed) : undefined;
88
+ const invocations = traceQueueDxn ? ((await space.queues.get(traceQueueDxn).queryObjects()) ?? []) : [];
89
89
 
90
90
  for (const invocation of invocations) {
91
91
  if (Obj.instanceOf(InvocationTraceStartEvent, invocation)) {