jazz-tools 0.7.0-alpha.0 → 0.7.0-alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. package/.eslintrc.cjs +8 -1
  2. package/CHANGELOG.md +8 -0
  3. package/dist/coValues/account.js +138 -0
  4. package/dist/coValues/account.js.map +1 -0
  5. package/dist/coValues/coList.js +196 -0
  6. package/dist/coValues/coList.js.map +1 -0
  7. package/dist/coValues/coMap.js +249 -0
  8. package/dist/coValues/coMap.js.map +1 -0
  9. package/dist/coValues/coStream.js +189 -0
  10. package/dist/coValues/coStream.js.map +1 -0
  11. package/dist/coValues/extensions/imageDef.js +17 -12
  12. package/dist/coValues/extensions/imageDef.js.map +1 -1
  13. package/dist/coValues/group.js +96 -0
  14. package/dist/coValues/group.js.map +1 -0
  15. package/dist/coValues/interfaces.js +58 -0
  16. package/dist/coValues/interfaces.js.map +1 -0
  17. package/dist/implementation/errors.js.map +1 -0
  18. package/dist/implementation/inspect.js +2 -0
  19. package/dist/implementation/inspect.js.map +1 -0
  20. package/dist/{refs.js → implementation/refs.js} +11 -13
  21. package/dist/implementation/refs.js.map +1 -0
  22. package/dist/implementation/schema.js +6 -0
  23. package/dist/implementation/schema.js.map +1 -0
  24. package/dist/{subscriptionScope.js → implementation/subscriptionScope.js} +1 -1
  25. package/dist/implementation/subscriptionScope.js.map +1 -0
  26. package/dist/index.js +23 -27
  27. package/dist/index.js.map +1 -1
  28. package/dist/internal.js +13 -0
  29. package/dist/internal.js.map +1 -0
  30. package/dist/tests/coList.test.js +26 -22
  31. package/dist/tests/coList.test.js.map +1 -1
  32. package/dist/tests/coMap.test.js +91 -43
  33. package/dist/tests/coMap.test.js.map +1 -1
  34. package/dist/tests/coStream.test.js +35 -24
  35. package/dist/tests/coStream.test.js.map +1 -1
  36. package/package.json +11 -4
  37. package/src/coValues/account.ts +297 -0
  38. package/src/coValues/coList.ts +320 -0
  39. package/src/coValues/coMap.ts +447 -0
  40. package/src/coValues/coStream.ts +325 -0
  41. package/src/coValues/extensions/imageDef.ts +24 -16
  42. package/src/coValues/group.ts +187 -0
  43. package/src/coValues/interfaces.ts +216 -0
  44. package/src/implementation/inspect.ts +2 -0
  45. package/src/{refs.ts → implementation/refs.ts} +21 -32
  46. package/src/implementation/schema.ts +69 -0
  47. package/src/{subscriptionScope.ts → implementation/subscriptionScope.ts} +11 -13
  48. package/src/index.ts +22 -50
  49. package/src/internal.ts +15 -0
  50. package/src/tests/coList.test.ts +27 -25
  51. package/src/tests/coMap.test.ts +125 -50
  52. package/src/tests/coStream.test.ts +51 -38
  53. package/dist/coValueInterfaces.js +0 -8
  54. package/dist/coValueInterfaces.js.map +0 -1
  55. package/dist/coValues/account/account.js +0 -11
  56. package/dist/coValues/account/account.js.map +0 -1
  57. package/dist/coValues/account/accountOf.js +0 -150
  58. package/dist/coValues/account/accountOf.js.map +0 -1
  59. package/dist/coValues/account/migration.js +0 -4
  60. package/dist/coValues/account/migration.js.map +0 -1
  61. package/dist/coValues/coList/coList.js +0 -2
  62. package/dist/coValues/coList/coList.js.map +0 -1
  63. package/dist/coValues/coList/coListOf.js +0 -235
  64. package/dist/coValues/coList/coListOf.js.map +0 -1
  65. package/dist/coValues/coList/internalDocs.js +0 -2
  66. package/dist/coValues/coList/internalDocs.js.map +0 -1
  67. package/dist/coValues/coMap/coMap.js +0 -2
  68. package/dist/coValues/coMap/coMap.js.map +0 -1
  69. package/dist/coValues/coMap/coMapOf.js +0 -262
  70. package/dist/coValues/coMap/coMapOf.js.map +0 -1
  71. package/dist/coValues/coMap/internalDocs.js +0 -2
  72. package/dist/coValues/coMap/internalDocs.js.map +0 -1
  73. package/dist/coValues/coStream/coStream.js +0 -2
  74. package/dist/coValues/coStream/coStream.js.map +0 -1
  75. package/dist/coValues/coStream/coStreamOf.js +0 -244
  76. package/dist/coValues/coStream/coStreamOf.js.map +0 -1
  77. package/dist/coValues/construction.js +0 -34
  78. package/dist/coValues/construction.js.map +0 -1
  79. package/dist/coValues/group/group.js +0 -2
  80. package/dist/coValues/group/group.js.map +0 -1
  81. package/dist/coValues/group/groupOf.js +0 -109
  82. package/dist/coValues/group/groupOf.js.map +0 -1
  83. package/dist/coValues/resolution.js +0 -66
  84. package/dist/coValues/resolution.js.map +0 -1
  85. package/dist/errors.js.map +0 -1
  86. package/dist/refs.js.map +0 -1
  87. package/dist/schemaHelpers.js +0 -14
  88. package/dist/schemaHelpers.js.map +0 -1
  89. package/dist/subscriptionScope.js.map +0 -1
  90. package/dist/tests/types.test.js +0 -33
  91. package/dist/tests/types.test.js.map +0 -1
  92. package/src/coValueInterfaces.ts +0 -105
  93. package/src/coValues/account/account.ts +0 -106
  94. package/src/coValues/account/accountOf.ts +0 -284
  95. package/src/coValues/account/migration.ts +0 -12
  96. package/src/coValues/coList/coList.ts +0 -57
  97. package/src/coValues/coList/coListOf.ts +0 -377
  98. package/src/coValues/coList/internalDocs.ts +0 -1
  99. package/src/coValues/coMap/coMap.ts +0 -110
  100. package/src/coValues/coMap/coMapOf.ts +0 -451
  101. package/src/coValues/coMap/internalDocs.ts +0 -1
  102. package/src/coValues/coStream/coStream.ts +0 -63
  103. package/src/coValues/coStream/coStreamOf.ts +0 -404
  104. package/src/coValues/construction.ts +0 -110
  105. package/src/coValues/group/group.ts +0 -27
  106. package/src/coValues/group/groupOf.ts +0 -183
  107. package/src/coValues/resolution.ts +0 -111
  108. package/src/schemaHelpers.ts +0 -72
  109. package/src/tests/types.test.ts +0 -37
  110. /package/dist/{errors.js → implementation/errors.js} +0 -0
  111. /package/src/{errors.ts → implementation/errors.ts} +0 -0
@@ -0,0 +1,325 @@
1
+ import type {
2
+ AccountID,
3
+ AgentID,
4
+ BinaryStreamInfo,
5
+ CojsonInternalTypes,
6
+ JsonValue,
7
+ RawBinaryCoStream,
8
+ RawCoStream,
9
+ SessionID,
10
+ } from "cojson";
11
+ import { cojsonInternals } from "cojson";
12
+ import type {
13
+ CoValue,
14
+ EnsureItemNullable,
15
+ FieldDescriptor,
16
+ FieldDescriptorFor,
17
+ Group,
18
+ ID,
19
+ Me,
20
+ } from "../internal.js";
21
+ import { Account, CoValueBase, ValueRef, inspect } from "../internal.js";
22
+ import { Schema } from "@effect/schema";
23
+
24
+ export type CoStreamEntry<Item> = {
25
+ value: NonNullable<Item> extends CoValue ? NonNullable<Item> | null : Item;
26
+ ref?: NonNullable<Item> extends CoValue
27
+ ? ValueRef<NonNullable<Item>>
28
+ : never;
29
+ by?: Account;
30
+ madeAt: Date;
31
+ tx: CojsonInternalTypes.TransactionID;
32
+ };
33
+
34
+ export class CoStream<Item extends EnsureItemNullable<Item, "Co.Stream"> = any>
35
+ extends CoValueBase
36
+ implements CoValue<"CoStream", RawCoStream>
37
+ {
38
+ id!: ID<this>;
39
+ _type!: "CoStream";
40
+ static {
41
+ this.prototype._type = "CoStream";
42
+ }
43
+ _raw!: RawCoStream;
44
+
45
+ /** @internal This is only a marker type and doesn't exist at runtime */
46
+ _item!: Item;
47
+ static _schema: any;
48
+ get _schema(): {
49
+ _item: FieldDescriptorFor<Item>;
50
+ } {
51
+ return (this.constructor as typeof CoStream)._schema;
52
+ }
53
+
54
+ by: {
55
+ [key: ID<Account>]: CoStreamEntry<Item>;
56
+ } = {};
57
+ get byMe(): CoStreamEntry<Item> | undefined {
58
+ return this.by[this._loadedAs.id];
59
+ }
60
+ in: {
61
+ [key: SessionID]: CoStreamEntry<Item>;
62
+ } = {};
63
+ get inCurrentSession(): CoStreamEntry<Item> | undefined {
64
+ return this.in[this._loadedAs.sessionID];
65
+ }
66
+
67
+ constructor(_init: undefined, options: { fromRaw: RawCoStream });
68
+ constructor(init: Item[], options: { owner: Account | Group });
69
+ constructor(
70
+ init: Item[] | undefined,
71
+ options: { owner: Account | Group } | { fromRaw: RawCoStream }
72
+ ) {
73
+ super();
74
+
75
+ let raw: RawCoStream;
76
+
77
+ if ("fromRaw" in options) {
78
+ raw = options.fromRaw;
79
+ } else {
80
+ const rawOwner = options.owner._raw;
81
+
82
+ raw = rawOwner.createStream();
83
+ }
84
+
85
+ Object.defineProperties(this, {
86
+ id: {
87
+ value: raw.id,
88
+ enumerable: false,
89
+ },
90
+ _raw: { value: raw, enumerable: false },
91
+ });
92
+
93
+ if (init !== undefined) {
94
+ for (const item of init) {
95
+ this.pushItem(item);
96
+ }
97
+ }
98
+
99
+ this.updateEntries();
100
+ }
101
+
102
+ private updateEntries() {
103
+ for (const accountID of this._raw.accounts()) {
104
+ Object.defineProperty(this.by, accountID, {
105
+ get: () => {
106
+ const rawEntry = this._raw.lastItemBy(accountID);
107
+
108
+ if (!rawEntry) return;
109
+ return entryFromRawEntry(
110
+ this,
111
+ rawEntry,
112
+ this._loadedAs,
113
+ accountID as unknown as ID<Account>,
114
+ this._schema._item
115
+ );
116
+ },
117
+ configurable: true,
118
+ enumerable: true,
119
+ });
120
+ }
121
+
122
+ for (const sessionID of this._raw.sessions()) {
123
+ Object.defineProperty(this.in, sessionID, {
124
+ get: () => {
125
+ const rawEntry = this._raw.lastItemIn(
126
+ sessionID as unknown as SessionID
127
+ );
128
+
129
+ if (!rawEntry) return;
130
+ const by =
131
+ cojsonInternals.accountOrAgentIDfromSessionID(
132
+ sessionID
133
+ );
134
+ return entryFromRawEntry(
135
+ this,
136
+ rawEntry,
137
+ this._loadedAs,
138
+ cojsonInternals.isAccountID(by)
139
+ ? (by as unknown as ID<Account>)
140
+ : undefined,
141
+ this._schema._item
142
+ );
143
+ },
144
+ configurable: true,
145
+ enumerable: true,
146
+ });
147
+ }
148
+ }
149
+
150
+ push(...items: Item[]) {
151
+ for (const item of items) {
152
+ this.pushItem(item);
153
+ }
154
+ this.updateEntries();
155
+ }
156
+
157
+ private pushItem(item: Item) {
158
+ const itemDescriptor = this._schema._item as FieldDescriptor;
159
+
160
+ if (itemDescriptor === "json") {
161
+ this._raw.push(item as JsonValue);
162
+ } else if ("encoded" in itemDescriptor) {
163
+ this._raw.push(Schema.encodeSync(itemDescriptor.encoded)(item));
164
+ } else if ("ref" in itemDescriptor) {
165
+ this._raw.push((item as unknown as CoValue).id);
166
+ }
167
+ }
168
+
169
+ toJSON() {
170
+ const itemDescriptor = this._schema._item as FieldDescriptor;
171
+ const mapper =
172
+ itemDescriptor === "json"
173
+ ? (v: unknown) => v
174
+ : "encoded" in itemDescriptor
175
+ ? Schema.encodeSync(itemDescriptor.encoded)
176
+ : (v: unknown) => v && (v as CoValue).id;
177
+
178
+ return {
179
+ id: this.id,
180
+ _type: this._type,
181
+ by: Object.fromEntries(
182
+ Object.entries(this.by).map(([account, entry]) => [
183
+ account,
184
+ mapper(entry.value),
185
+ ])
186
+ ),
187
+ in: Object.fromEntries(
188
+ Object.entries(this.in).map(([session, entry]) => [
189
+ session,
190
+ mapper(entry.value),
191
+ ])
192
+ ),
193
+ };
194
+ }
195
+
196
+ [inspect]() {
197
+ return this.toJSON();
198
+ }
199
+
200
+ static encoding<V extends CoStream>(
201
+ this: { new (...args: any): V } & typeof CoStream,
202
+ def: { _item: V["_schema"]["_item"] }
203
+ ) {
204
+ this._schema ||= {};
205
+ Object.assign(this._schema, def);
206
+ }
207
+ }
208
+
209
+ function entryFromRawEntry<Item>(
210
+ accessFrom: CoValue,
211
+ rawEntry: {
212
+ by: AccountID | AgentID;
213
+ tx: CojsonInternalTypes.TransactionID;
214
+ at: Date;
215
+ value: JsonValue;
216
+ },
217
+ loadedAs: Account & Me,
218
+ accountID: ID<Account> | undefined,
219
+ itemField: FieldDescriptor
220
+ ) {
221
+ return {
222
+ get value(): Item | undefined {
223
+ if (itemField === "json") {
224
+ return rawEntry.value as Item;
225
+ } else if ("encoded" in itemField) {
226
+ return Schema.decodeSync(itemField.encoded)(rawEntry.value);
227
+ } else if ("ref" in itemField) {
228
+ return this.ref?.accessFrom(accessFrom) as Item;
229
+ }
230
+ },
231
+ get ref() {
232
+ if (itemField !== "json" && "ref" in itemField) {
233
+ const rawId = rawEntry.value;
234
+ return new ValueRef(
235
+ rawId as unknown as ID<CoValue>,
236
+ loadedAs,
237
+ itemField.ref()
238
+ );
239
+ }
240
+ },
241
+ get by() {
242
+ return (
243
+ accountID &&
244
+ new ValueRef(
245
+ accountID as unknown as ID<Account>,
246
+ loadedAs,
247
+ Account
248
+ )?.accessFrom(accessFrom)
249
+ );
250
+ },
251
+ madeAt: rawEntry.at,
252
+ tx: rawEntry.tx,
253
+ };
254
+ }
255
+
256
+ export class BinaryCoStream
257
+ extends CoValueBase
258
+ implements CoValue<"BinaryCoStream", RawBinaryCoStream>
259
+ {
260
+ id!: ID<this>;
261
+ _type!: "BinaryCoStream";
262
+ _raw!: RawBinaryCoStream;
263
+
264
+ constructor(
265
+ init: [] | undefined,
266
+ options:
267
+ | {
268
+ owner: Account | Group;
269
+ }
270
+ | {
271
+ fromRaw: RawBinaryCoStream;
272
+ }
273
+ ) {
274
+ super();
275
+
276
+ let raw: RawBinaryCoStream;
277
+
278
+ if ("fromRaw" in options) {
279
+ raw = options.fromRaw;
280
+ } else {
281
+ const rawOwner = options.owner._raw;
282
+ raw = rawOwner.createBinaryStream();
283
+ }
284
+
285
+ Object.defineProperties(this, {
286
+ id: {
287
+ value: raw.id,
288
+ enumerable: false,
289
+ },
290
+ _raw: { value: raw, enumerable: false },
291
+ });
292
+ }
293
+
294
+ getChunks(options?: {
295
+ allowUnfinished?: boolean;
296
+ }):
297
+ | (BinaryStreamInfo & { chunks: Uint8Array[]; finished: boolean })
298
+ | undefined {
299
+ return this._raw.getBinaryChunks(options?.allowUnfinished);
300
+ }
301
+
302
+ start(options: BinaryStreamInfo): void {
303
+ this._raw.startBinaryStream(options);
304
+ }
305
+
306
+ push(data: Uint8Array): void {
307
+ this._raw.pushBinaryStreamChunk(data);
308
+ }
309
+
310
+ end(): void {
311
+ this._raw.endBinaryStream();
312
+ }
313
+
314
+ toJSON() {
315
+ return {
316
+ id: this.id,
317
+ _type: this._type,
318
+ ...this.getChunks(),
319
+ };
320
+ }
321
+
322
+ [inspect]() {
323
+ return this.toJSON();
324
+ }
325
+ }
@@ -1,20 +1,22 @@
1
- import * as S from "@effect/schema/Schema";
2
- import { CoMapOf } from "../coMap/coMapOf.js";
3
- import { BinaryCoStreamImpl } from "../coStream/coStreamOf.js";
4
- import { BinaryCoStream } from "../coStream/coStream.js";
5
- import { subscriptionsScopes } from "../../subscriptionScope.js";
6
-
7
- export class ImageDefinition extends CoMapOf(
8
- {
9
- originalSize: S.tuple(S.number, S.number),
10
- placeholderDataURL: S.optional(S.string),
11
- },
12
- {
13
- key: S.templateLiteral(S.string, S.literal("x"), S.string),
14
- value: BinaryCoStreamImpl,
1
+ import { BinaryCoStream, CoMap, indexSignature, subscriptionsScopes } from '../../internal.js'
2
+
3
+ export class ImageDefinition extends CoMap<ImageDefinition> {
4
+ declare originalSize: [number, number]
5
+ declare placeholderDataURL?: string
6
+
7
+ [res: `${number}x${number}`]: BinaryCoStream | null;
8
+ declare [indexSignature]: BinaryCoStream | null
9
+
10
+ static {
11
+ this.prototype._schema
12
+ this.encoding({
13
+ originalSize: "json",
14
+ placeholderDataURL: "json",
15
+ [indexSignature]: {ref: () => BinaryCoStream},
16
+ })
15
17
  }
16
- ).as<ImageDefinition>() {
17
- get highestResAvailable():
18
+
19
+ get _highestResAvailable():
18
20
  | { res: `${number}x${number}`; stream: BinaryCoStream }
19
21
  | undefined {
20
22
  if (!subscriptionsScopes.get(this)) {
@@ -47,5 +49,11 @@ export class ImageDefinition extends CoMapOf(
47
49
  );
48
50
  }
49
51
  }
52
+ return (
53
+ highestAvailableResolution && {
54
+ res: highestAvailableResolution,
55
+ stream: this[highestAvailableResolution]!,
56
+ }
57
+ );
50
58
  }
51
59
  }
@@ -0,0 +1,187 @@
1
+ import type { CoID, Everyone, RawCoMap, RawGroup, Role } from "cojson";
2
+ import type {
3
+ CoValue,
4
+ CoValueClass,
5
+ ID,
6
+ PrimitiveField,
7
+ RefField,
8
+ } from "../internal.js";
9
+ import {
10
+ Account,
11
+ CoMap,
12
+ CoValueBase,
13
+ ValueRef,
14
+ isControlledAccount,
15
+ } from "../internal.js";
16
+
17
+ export class Profile extends CoMap<{ name: string }> {
18
+ declare name: string;
19
+
20
+ static {
21
+ this.encoding({ name: "json" } as any);
22
+ }
23
+ }
24
+
25
+ export class Group<
26
+ Def extends { profile: Profile | null; root: CoMap | null } = {
27
+ profile: Profile | null;
28
+ root: CoMap | null;
29
+ },
30
+ >
31
+ extends CoValueBase
32
+ implements CoValue<"Group", RawGroup>
33
+ {
34
+ id!: ID<this>;
35
+ _type!: "Group";
36
+ static {
37
+ this.prototype._type = "Group";
38
+ }
39
+ _raw!: RawGroup;
40
+
41
+ static _schema: any;
42
+ get _schema(): {
43
+ profile: Def["profile"] extends CoValue
44
+ ? RefField<Def["profile"]>
45
+ : PrimitiveField;
46
+ root: Def["root"] extends CoValue
47
+ ? RefField<Def["root"]>
48
+ : PrimitiveField;
49
+ } {
50
+ return (this.constructor as typeof Group)._schema;
51
+ }
52
+ static {
53
+ this._schema = {
54
+ profile: { json: true },
55
+ root: { json: true },
56
+ } as any;
57
+ Object.defineProperty(this.prototype, "_schema", {
58
+ get: () => this._schema,
59
+ });
60
+ }
61
+
62
+ profile!: Def["profile"] extends Profile
63
+ ? Def["profile"] | null
64
+ : undefined;
65
+
66
+ root!: Def["root"] extends CoMap ? Def["root"] | null : undefined;
67
+
68
+ get _refs(): {
69
+ profile: Def["profile"] extends Profile
70
+ ? ValueRef<Def["profile"]>
71
+ : never;
72
+ root: Def["root"] extends CoMap ? ValueRef<Def["root"]> : never;
73
+ } {
74
+ const profileID = this._raw.get("profile") as unknown as
75
+ | ID<NonNullable<Def["profile"]>>
76
+ | undefined;
77
+ const rootID = this._raw.get("root") as unknown as
78
+ | ID<NonNullable<Def["root"]>>
79
+ | undefined;
80
+ return {
81
+ profile:
82
+ profileID &&
83
+ (new ValueRef(
84
+ profileID,
85
+ this._loadedAs,
86
+ (
87
+ this._schema.profile as RefField<
88
+ NonNullable<Def["profile"]>
89
+ >
90
+ ).ref()
91
+ ) as any),
92
+ root:
93
+ rootID &&
94
+ (new ValueRef(
95
+ rootID,
96
+ this._loadedAs,
97
+ (
98
+ this._schema.root as RefField<NonNullable<Def["root"]>>
99
+ ).ref()
100
+ ) as any),
101
+ };
102
+ }
103
+
104
+ constructor(options: { owner: Account | Group });
105
+ constructor(init: any, options: { fromRaw: RawGroup });
106
+ constructor(init: undefined, options: { owner: Account | Group });
107
+ constructor(
108
+ init: undefined | { owner: Account | Group },
109
+ options?: { fromRaw: RawGroup } | { owner: Account | Group }
110
+ ) {
111
+ super();
112
+ let raw: RawGroup;
113
+
114
+ if (options && "fromRaw" in options) {
115
+ raw = options.fromRaw;
116
+ } else {
117
+ const initOwner = options?.owner || init?.owner;
118
+ if (!initOwner) throw new Error("No owner provided");
119
+ if (
120
+ initOwner instanceof Account &&
121
+ isControlledAccount(initOwner)
122
+ ) {
123
+ const rawOwner = initOwner._raw;
124
+ raw = rawOwner.createGroup();
125
+ } else {
126
+ throw new Error(
127
+ "Can only construct group as a controlled account"
128
+ );
129
+ }
130
+ }
131
+
132
+ Object.defineProperties(this, {
133
+ id: {
134
+ value: raw.id,
135
+ enumerable: false,
136
+ },
137
+ _raw: { value: raw, enumerable: false },
138
+ profile: {
139
+ get: () => {
140
+ const ref = this._refs.profile;
141
+ return ref ? ref.accessFrom(this) : (undefined as any);
142
+ },
143
+ set: (value: Def["profile"] | null) => {
144
+ if (value) {
145
+ this._raw.set(
146
+ "profile",
147
+ value.id as unknown as CoID<RawCoMap>
148
+ );
149
+ }
150
+ },
151
+ },
152
+ root: {
153
+ get: () => {
154
+ const ref = this._refs.root;
155
+ return ref ? ref.accessFrom(this) : (undefined as any);
156
+ },
157
+ set: (value: Def["root"] | null) => {
158
+ if (value) {
159
+ this._raw.set(
160
+ "root",
161
+ value.id as unknown as CoID<RawCoMap>
162
+ );
163
+ }
164
+ },
165
+ },
166
+ });
167
+ }
168
+
169
+ myRole(): Role | undefined {
170
+ return this._raw.myRole();
171
+ }
172
+
173
+ addMember(member: Everyone | Account, role: Role) {
174
+ this._raw.addMember(member === "everyone" ? member : member._raw, role);
175
+ }
176
+
177
+ static define<V extends Account>(
178
+ this: CoValueClass<V> & typeof Account,
179
+ fields: {
180
+ profile: V["_schema"]["profile"];
181
+ root: V["_schema"]["root"];
182
+ }
183
+ ) {
184
+ this._schema ||= {};
185
+ Object.assign(this._schema, fields);
186
+ }
187
+ }