@dxos/echo-generator 0.8.4-main.72ec0f3 → 0.8.4-main.7ace549

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/echo-generator",
3
- "version": "0.8.4-main.72ec0f3",
3
+ "version": "0.8.4-main.7ace549",
4
4
  "description": "ECHO data generator for testing.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -27,21 +27,21 @@
27
27
  "dependencies": {
28
28
  "@automerge/automerge": "3.1.2",
29
29
  "effect": "3.18.3",
30
- "@dxos/echo": "0.8.4-main.72ec0f3",
31
- "@dxos/client": "0.8.4-main.72ec0f3",
32
- "@dxos/echo-db": "0.8.4-main.72ec0f3",
33
- "@dxos/live-object": "0.8.4-main.72ec0f3",
34
- "@dxos/invariant": "0.8.4-main.72ec0f3",
35
- "@dxos/log": "0.8.4-main.72ec0f3",
36
- "@dxos/node-std": "0.8.4-main.72ec0f3",
37
- "@dxos/util": "0.8.4-main.72ec0f3"
30
+ "@dxos/client": "0.8.4-main.7ace549",
31
+ "@dxos/echo": "0.8.4-main.7ace549",
32
+ "@dxos/invariant": "0.8.4-main.7ace549",
33
+ "@dxos/live-object": "0.8.4-main.7ace549",
34
+ "@dxos/echo-db": "0.8.4-main.7ace549",
35
+ "@dxos/log": "0.8.4-main.7ace549",
36
+ "@dxos/util": "0.8.4-main.7ace549",
37
+ "@dxos/node-std": "0.8.4-main.7ace549"
38
38
  },
39
39
  "devDependencies": {
40
- "@dxos/random": "0.8.4-main.72ec0f3"
40
+ "@dxos/random": "0.8.4-main.7ace549"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "effect": "^3.13.3",
44
- "@dxos/random": "0.8.4-main.72ec0f3"
44
+ "@dxos/random": "0.8.4-main.7ace549"
45
45
  },
46
46
  "publishConfig": {
47
47
  "access": "public"
package/src/data.ts CHANGED
@@ -5,8 +5,10 @@
5
5
  import { next as A } from '@automerge/automerge';
6
6
  import * as Schema from 'effect/Schema';
7
7
 
8
- import { type Space, createDocAccessor } from '@dxos/client/echo';
9
- import { EchoObject, Ref } from '@dxos/echo/internal';
8
+ import { type Space } from '@dxos/client/echo';
9
+ import { Ref, Type } from '@dxos/echo';
10
+ import { EchoObjectSchema } from '@dxos/echo/internal';
11
+ import { createDocAccessor } from '@dxos/echo-db';
10
12
  import { faker } from '@dxos/random';
11
13
 
12
14
  import { SpaceObjectGenerator, TestObjectGenerator } from './generator';
@@ -37,21 +39,21 @@ const testSchemas = (): TestSchemaMap<TestSchemaType> => {
37
39
  const document = Schema.Struct({
38
40
  title: Schema.String.annotations({ description: 'title of the document' }),
39
41
  content: Schema.String,
40
- }).pipe(EchoObject({ typename: TestSchemaType.document, version: '0.1.0' }));
42
+ }).pipe(EchoObjectSchema({ typename: TestSchemaType.document, version: '0.1.0' }));
41
43
 
42
44
  const organization = Schema.Struct({
43
45
  name: Schema.String.annotations({ description: 'name of the company or organization' }),
44
46
  website: Schema.optional(Schema.String.annotations({ description: 'public website URL' })),
45
47
  description: Schema.String.annotations({ description: 'short summary of the company' }),
46
- }).pipe(EchoObject({ typename: TestSchemaType.organization, version: '0.1.0' }));
48
+ }).pipe(EchoObjectSchema({ typename: TestSchemaType.organization, version: '0.1.0' }));
47
49
 
48
50
  const contact = Schema.Struct({
49
51
  name: Schema.String.annotations({ description: 'name of the person' }),
50
52
  email: Schema.optional(Schema.String),
51
- org: Schema.optional(Ref(organization)),
53
+ org: Schema.optional(Type.Ref(organization)),
52
54
  lat: Schema.optional(Schema.Number),
53
55
  lng: Schema.optional(Schema.Number),
54
- }).pipe(EchoObject({ typename: TestSchemaType.contact, version: '0.1.0' }));
56
+ }).pipe(EchoObjectSchema({ typename: TestSchemaType.contact, version: '0.1.0' }));
55
57
 
56
58
  const project = Schema.Struct({
57
59
  name: Schema.String.annotations({ description: 'name of the project' }),
@@ -61,8 +63,8 @@ const testSchemas = (): TestSchemaMap<TestSchemaType> => {
61
63
  status: Schema.String,
62
64
  priority: Schema.Number,
63
65
  active: Schema.Boolean,
64
- org: Schema.optional(Ref(organization)),
65
- }).pipe(EchoObject({ typename: TestSchemaType.project, version: '0.1.0' }));
66
+ org: Schema.optional(Type.Ref(organization)),
67
+ }).pipe(EchoObjectSchema({ typename: TestSchemaType.project, version: '0.1.0' }));
66
68
 
67
69
  return {
68
70
  [TestSchemaType.document]: document,
@@ -7,7 +7,8 @@ import * as Schema from 'effect/Schema';
7
7
  import { describe, expect, onTestFinished, test } from 'vitest';
8
8
 
9
9
  import { Client } from '@dxos/client';
10
- import { TypedObject, getType } from '@dxos/echo/internal';
10
+ import { Obj } from '@dxos/echo';
11
+ import { TypedObject } from '@dxos/echo/internal';
11
12
  import { getObjectCore } from '@dxos/echo-db';
12
13
  import { faker } from '@dxos/random';
13
14
 
@@ -43,7 +44,7 @@ describe('TestObjectGenerator', () => {
43
44
 
44
45
  // Create org object.
45
46
  const organization = await generator.createObject({ types: [TestSchemaType.organization] });
46
- expect(getType(organization)).to.exist;
47
+ expect(Obj.getTypeDXN(organization)).to.exist;
47
48
 
48
49
  // Expect at least one person object with a linked org reference.
49
50
  const objects = await generator.createObjects({ [TestSchemaType.contact]: 10 });
@@ -59,14 +60,14 @@ describe('TestObjectGenerator', () => {
59
60
  const generator = createSpaceObjectGenerator(space);
60
61
  await generator.addSchemas();
61
62
  const organization = await generator.createObject({ types: [TestSchemaType.organization] });
62
- schemaId.push(getType(organization)!.toString());
63
+ schemaId.push(Obj.getTypeDXN(organization)!.toString());
63
64
  }
64
65
 
65
66
  {
66
67
  const generator = createSpaceObjectGenerator(space);
67
68
  await generator.addSchemas();
68
69
  const organization = await generator.createObject({ types: [TestSchemaType.organization] });
69
- schemaId.push(getType(organization)!.toString());
70
+ schemaId.push(Obj.getTypeDXN(organization)!.toString());
70
71
  }
71
72
 
72
73
  expect(schemaId[0]).not.to.be.undefined;
@@ -78,7 +79,7 @@ describe('TestObjectGenerator', () => {
78
79
  const generator = createSpaceObjectGenerator(space);
79
80
  await generator.addSchemas();
80
81
  const document = await generator.createObject({ types: [TestSchemaType.document] });
81
- expect(getType(document)).to.exist;
82
+ expect(Obj.getTypeDXN(document)).to.exist;
82
83
 
83
84
  const beforeChangesCount = A.getAllChanges(getObjectCore(document).docHandle!.doc()).length;
84
85
 
@@ -106,7 +107,9 @@ describe('TestObjectGenerator', () => {
106
107
  const { space } = await setupTest();
107
108
  const generator = new SpaceObjectGenerator<Types>(
108
109
  space,
109
- { [Types.task]: Task },
110
+ {
111
+ [Types.task]: Task,
112
+ },
110
113
  {
111
114
  [Types.task]: () => ({ name: 'Default' }),
112
115
  },
@@ -121,7 +124,7 @@ describe('TestObjectGenerator', () => {
121
124
  await generator.addSchemas();
122
125
 
123
126
  const todo = await generator.createObject({ types: [Types.task] });
124
- expect(getType(todo)).to.exist;
127
+ expect(Obj.getTypeDXN(todo)).to.exist;
125
128
  });
126
129
 
127
130
  test('references', async () => {
@@ -141,7 +144,7 @@ describe('TestObjectGenerator', () => {
141
144
  test('create project', async () => {
142
145
  const generator = createTestObjectGenerator();
143
146
  const project = await generator.createObject({ types: [TestSchemaType.project] });
144
- expect(getType(project)).to.exist;
147
+ expect(Obj.getTypeDXN(project)).to.exist;
145
148
  });
146
149
 
147
150
  test('create object with not type', async () => {
package/src/generator.ts CHANGED
@@ -6,7 +6,7 @@ import type * as Schema from 'effect/Schema';
6
6
 
7
7
  import { Filter, type Space } from '@dxos/client/echo';
8
8
  import { Obj } from '@dxos/echo';
9
- import { EchoSchema, getSchema, getTypeAnnotation } from '@dxos/echo/internal';
9
+ import { EchoSchema, getTypeAnnotation } from '@dxos/echo/internal';
10
10
  import { type AnyLiveObject } from '@dxos/echo-db';
11
11
  import { invariant } from '@dxos/invariant';
12
12
  import { type Live, isLiveObject, live } from '@dxos/live-object';
@@ -129,7 +129,7 @@ export class SpaceObjectGenerator<T extends string> extends TestObjectGenerator<
129
129
 
130
130
  async mutateObject(object: AnyLiveObject<any>, params: MutationsProviderParams): Promise<void> {
131
131
  invariant(this._mutations, 'Mutations not defined.');
132
- const type = getTypeAnnotation(getSchema(object)!)!.typename as T;
132
+ const type = getTypeAnnotation(Obj.getSchema(object)!)!.typename as T;
133
133
  invariant(type && this._mutations?.[type], 'Invalid object type.');
134
134
 
135
135
  await this._mutations![type](object, params);