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

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 +14 -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 +12 -12
  12. package/dist/coValues/extensions/imageDef.js.map +1 -1
  13. package/dist/coValues/group.js +93 -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 +8 -28
  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 +74 -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 +25 -16
  42. package/src/coValues/group.ts +186 -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 +9 -54
  49. package/src/internal.ts +15 -0
  50. package/src/tests/coList.test.ts +27 -25
  51. package/src/tests/coMap.test.ts +111 -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 _encoding: any;
48
+ get _encoding(): {
49
+ _item: FieldDescriptorFor<Item>;
50
+ } {
51
+ return (this.constructor as typeof CoStream)._encoding;
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._encoding._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._encoding._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._encoding._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._encoding._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["_encoding"]["_item"] }
203
+ ) {
204
+ this._encoding ||= {};
205
+ Object.assign(this._encoding, 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,18 @@
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";
1
+ import {
2
+ BinaryCoStream,
3
+ CoMap,
4
+ indexSignature,
5
+ subscriptionsScopes,
6
+ } from "../../internal.js";
6
7
 
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,
15
- }
16
- ).as<ImageDefinition>() {
17
- get highestResAvailable():
8
+ export class ImageDefinition extends CoMap<ImageDefinition> {
9
+ declare originalSize: [number, number];
10
+ declare placeholderDataURL?: string;
11
+
12
+ [res: `${number}x${number}`]: BinaryCoStream | null;
13
+ declare [indexSignature]: BinaryCoStream | null;
14
+
15
+ get _highestResAvailable():
18
16
  | { res: `${number}x${number}`; stream: BinaryCoStream }
19
17
  | undefined {
20
18
  if (!subscriptionsScopes.get(this)) {
@@ -47,5 +45,16 @@ export class ImageDefinition extends CoMapOf(
47
45
  );
48
46
  }
49
47
  }
48
+ return (
49
+ highestAvailableResolution && {
50
+ res: highestAvailableResolution,
51
+ stream: this[highestAvailableResolution]!,
52
+ }
53
+ );
50
54
  }
51
55
  }
56
+ ImageDefinition.encoding({
57
+ originalSize: "json",
58
+ placeholderDataURL: "json",
59
+ [indexSignature]: { ref: () => BinaryCoStream },
60
+ });
@@ -0,0 +1,186 @@
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
+ Profile.encoding({ name: "json" });
21
+
22
+ export class Group<
23
+ Def extends { profile: Profile | null; root: CoMap | null } = {
24
+ profile: Profile | null;
25
+ root: CoMap | null;
26
+ },
27
+ >
28
+ extends CoValueBase
29
+ implements CoValue<"Group", RawGroup>
30
+ {
31
+ id!: ID<this>;
32
+ _type!: "Group";
33
+ static {
34
+ this.prototype._type = "Group";
35
+ }
36
+ _raw!: RawGroup;
37
+
38
+ static _encoding: any;
39
+ get _encoding(): {
40
+ profile: Def["profile"] extends CoValue
41
+ ? RefField<Def["profile"]>
42
+ : PrimitiveField;
43
+ root: Def["root"] extends CoValue
44
+ ? RefField<Def["root"]>
45
+ : PrimitiveField;
46
+ } {
47
+ return (this.constructor as typeof Group)._encoding;
48
+ }
49
+ static {
50
+ this._encoding = {
51
+ profile: { json: true },
52
+ root: { json: true },
53
+ } as any;
54
+ Object.defineProperty(this.prototype, "_encoding", {
55
+ get: () => this._encoding,
56
+ });
57
+ }
58
+
59
+ profile!: Def["profile"] extends Profile
60
+ ? Def["profile"] | null
61
+ : undefined;
62
+
63
+ root!: Def["root"] extends CoMap ? Def["root"] | null : undefined;
64
+
65
+ get _refs(): {
66
+ profile: Def["profile"] extends Profile
67
+ ? ValueRef<Def["profile"]>
68
+ : never;
69
+ root: Def["root"] extends CoMap ? ValueRef<Def["root"]> : never;
70
+ } {
71
+ const profileID = this._raw.get("profile") as unknown as
72
+ | ID<NonNullable<Def["profile"]>>
73
+ | undefined;
74
+ const rootID = this._raw.get("root") as unknown as
75
+ | ID<NonNullable<Def["root"]>>
76
+ | undefined;
77
+ return {
78
+ profile:
79
+ profileID &&
80
+ (new ValueRef(
81
+ profileID,
82
+ this._loadedAs,
83
+ (
84
+ this._encoding.profile as RefField<
85
+ NonNullable<Def["profile"]>
86
+ >
87
+ ).ref()
88
+ ) as any),
89
+ root:
90
+ rootID &&
91
+ (new ValueRef(
92
+ rootID,
93
+ this._loadedAs,
94
+ (
95
+ this._encoding.root as RefField<
96
+ NonNullable<Def["root"]>
97
+ >
98
+ ).ref()
99
+ ) as any),
100
+ };
101
+ }
102
+
103
+ constructor(options: { owner: Account | Group });
104
+ constructor(init: any, options: { fromRaw: RawGroup });
105
+ constructor(init: undefined, options: { owner: Account | Group });
106
+ constructor(
107
+ init: undefined | { owner: Account | Group },
108
+ options?: { fromRaw: RawGroup } | { owner: Account | Group }
109
+ ) {
110
+ super();
111
+ let raw: RawGroup;
112
+
113
+ if (options && "fromRaw" in options) {
114
+ raw = options.fromRaw;
115
+ } else {
116
+ const initOwner = options?.owner || init?.owner;
117
+ if (!initOwner) throw new Error("No owner provided");
118
+ if (
119
+ initOwner instanceof Account &&
120
+ isControlledAccount(initOwner)
121
+ ) {
122
+ const rawOwner = initOwner._raw;
123
+ raw = rawOwner.createGroup();
124
+ } else {
125
+ throw new Error(
126
+ "Can only construct group as a controlled account"
127
+ );
128
+ }
129
+ }
130
+
131
+ Object.defineProperties(this, {
132
+ id: {
133
+ value: raw.id,
134
+ enumerable: false,
135
+ },
136
+ _raw: { value: raw, enumerable: false },
137
+ profile: {
138
+ get: () => {
139
+ const ref = this._refs.profile;
140
+ return ref ? ref.accessFrom(this) : (undefined as any);
141
+ },
142
+ set: (value: Def["profile"] | null) => {
143
+ if (value) {
144
+ this._raw.set(
145
+ "profile",
146
+ value.id as unknown as CoID<RawCoMap>
147
+ );
148
+ }
149
+ },
150
+ },
151
+ root: {
152
+ get: () => {
153
+ const ref = this._refs.root;
154
+ return ref ? ref.accessFrom(this) : (undefined as any);
155
+ },
156
+ set: (value: Def["root"] | null) => {
157
+ if (value) {
158
+ this._raw.set(
159
+ "root",
160
+ value.id as unknown as CoID<RawCoMap>
161
+ );
162
+ }
163
+ },
164
+ },
165
+ });
166
+ }
167
+
168
+ myRole(): Role | undefined {
169
+ return this._raw.myRole();
170
+ }
171
+
172
+ addMember(member: Everyone | Account, role: Role) {
173
+ this._raw.addMember(member === "everyone" ? member : member._raw, role);
174
+ }
175
+
176
+ static define<V extends Account>(
177
+ this: CoValueClass<V> & typeof Account,
178
+ fields: {
179
+ profile: V["_encoding"]["profile"];
180
+ root: V["_encoding"]["root"];
181
+ }
182
+ ) {
183
+ this._encoding ||= {};
184
+ Object.assign(this._encoding, fields);
185
+ }
186
+ }