jazz-tools 0.7.0-alpha.12 → 0.7.0-alpha.14
Sign up to get free protection for your applications and to get access to all the features.
- package/.turbo/turbo-build.log +19 -17
- package/CHANGELOG.md +12 -0
- package/dist/coValues/coMap.js +5 -4
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coStream.js +34 -2
- package/dist/coValues/coStream.js.map +1 -1
- package/package.json +1 -1
- package/src/coValues/coMap.ts +17 -25
- package/src/coValues/coStream.ts +79 -14
- package/src/coValues/interfaces.ts +3 -3
- package/src/implementation/refs.ts +2 -0
package/.turbo/turbo-build.log
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
|
2
|
-
> jazz-tools@0.7.0-alpha.
|
2
|
+
> jazz-tools@0.7.0-alpha.13 build /Users/anselm/jazz/jazz/packages/jazz-tools
|
3
3
|
> npm run lint && rm -rf ./dist && tsc --sourceMap --outDir dist
|
4
4
|
|
5
5
|
|
6
|
-
> jazz-tools@0.7.0-alpha.
|
6
|
+
> jazz-tools@0.7.0-alpha.13 lint
|
7
7
|
> eslint src/**/*.ts
|
8
8
|
|
9
9
|
|
@@ -30,22 +30,24 @@
|
|
30
30
|
274:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
31
31
|
|
32
32
|
/Users/anselm/jazz/jazz/packages/jazz-tools/src/coValues/coMap.ts
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
33
|
+
28:50 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
34
|
+
28:68 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
35
|
+
56:20 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
36
|
+
57:18 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
37
|
+
91:21 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
38
|
+
112:14 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
39
|
+
206:44 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
40
|
+
224:56 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
41
|
+
250:38 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
42
|
+
277:42 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
43
43
|
|
44
44
|
/Users/anselm/jazz/jazz/packages/jazz-tools/src/coValues/coStream.ts
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
47:66 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
46
|
+
51:58 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
47
|
+
68:21 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
48
|
+
170:31 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
49
|
+
291:73 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
50
|
+
389:73 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
49
51
|
|
50
52
|
/Users/anselm/jazz/jazz/packages/jazz-tools/src/coValues/group.ts
|
51
53
|
33:21 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
@@ -90,5 +92,5 @@
|
|
90
92
|
/Users/anselm/jazz/jazz/packages/jazz-tools/src/tests/coStream.test.ts
|
91
93
|
0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override
|
92
94
|
|
93
|
-
✖
|
95
|
+
✖ 63 problems (0 errors, 63 warnings)
|
94
96
|
|
package/CHANGELOG.md
CHANGED
package/dist/coValues/coMap.js
CHANGED
@@ -3,8 +3,7 @@ import { Schema as EffectSchema } from "@effect/schema";
|
|
3
3
|
import { Account, CoValueBase, Ref, SchemaInit, inspect, makeRefs, subscriptionsScopes, ItemsSym, InitValues, isRefEncoded, } from "../internal.js";
|
4
4
|
export class CoMap extends CoValueBase {
|
5
5
|
get _schema() {
|
6
|
-
return this.constructor
|
7
|
-
._schema;
|
6
|
+
return this.constructor._schema;
|
8
7
|
}
|
9
8
|
get _refs() {
|
10
9
|
return makeRefs((key) => this._raw.get(key), () => Object.keys(this._schema).filter((key) => {
|
@@ -135,7 +134,8 @@ const CoMapProxyHandler = {
|
|
135
134
|
return Reflect.get(target, key, receiver);
|
136
135
|
}
|
137
136
|
else {
|
138
|
-
const descriptor = (target._schema[key] ||
|
137
|
+
const descriptor = (target._schema[key] ||
|
138
|
+
target._schema[ItemsSym]);
|
139
139
|
if (descriptor && typeof key === "string") {
|
140
140
|
const raw = target._raw.get(key);
|
141
141
|
if (descriptor === "json") {
|
@@ -221,7 +221,8 @@ const CoMapProxyHandler = {
|
|
221
221
|
return Reflect.getOwnPropertyDescriptor(target, key);
|
222
222
|
}
|
223
223
|
else {
|
224
|
-
const descriptor = (target._schema[key] ||
|
224
|
+
const descriptor = (target._schema[key] ||
|
225
|
+
target._schema[ItemsSym]);
|
225
226
|
if (descriptor || key in target._raw.ops) {
|
226
227
|
return {
|
227
228
|
enumerable: true,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"coMap.js","sourceRoot":"","sources":["../../src/coValues/coMap.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
1
|
+
{"version":3,"file":"coMap.js","sourceRoot":"","sources":["../../src/coValues/coMap.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAYxD,OAAO,EACH,OAAO,EACP,WAAW,EACX,GAAG,EACH,UAAU,EACV,OAAO,EACP,QAAQ,EACR,mBAAmB,EACnB,QAAQ,EACR,UAAU,EACV,YAAY,GACf,MAAM,gBAAgB,CAAC;AAsDxB,MAAM,OAAO,KACT,SAAQ,WAAW;IAWnB,IAAI,OAAO;QACP,OAAQ,IAAI,CAAC,WAA4B,CAAC,OAA4B,CAAC;IAC3E,CAAC;IAED,IAAI,KAAK;QAKL,OAAO,Q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BACtB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACnB,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,wBAAwB,CAAC,MAAM,EAAE,GAAG;QAChC,IAAI,GAAG,IAAI,MAAM,EAAE,CAAC;YAChB,OAAO,OAAO,CAAC,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACzD,CAAC;aAAM,CAAC;YACJ,MAAM,UAAU,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAA6B,CAAC;gBAC7D,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAW,CAAC;YACxC,IAAI,UAAU,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;gBACvC,OAAO;oBACH,UAAU,EAAE,IAAI;oBAChB,YAAY,EAAE,IAAI;oBAClB,QAAQ,EAAE,IAAI;iBACjB,CAAC;YACN,CAAC;QACL,CAAC;IACL,CAAC;CACJ,CAAC"}
|
@@ -103,12 +103,18 @@ function entryFromRawEntry(accessFrom, rawEntry, loadedAs, accountID, itemField)
|
|
103
103
|
else if (isRefEncoded(itemField)) {
|
104
104
|
return this.ref?.accessFrom(accessFrom);
|
105
105
|
}
|
106
|
+
else {
|
107
|
+
throw new Error("Invalid item field schema");
|
108
|
+
}
|
106
109
|
},
|
107
110
|
get ref() {
|
108
111
|
if (itemField !== "json" && isRefEncoded(itemField)) {
|
109
112
|
const rawId = rawEntry.value;
|
110
113
|
return new Ref(rawId, loadedAs, itemField);
|
111
114
|
}
|
115
|
+
else {
|
116
|
+
return undefined;
|
117
|
+
}
|
112
118
|
},
|
113
119
|
get by() {
|
114
120
|
return (accountID &&
|
@@ -141,7 +147,19 @@ export const CoStreamProxyHandler = {
|
|
141
147
|
const rawEntry = target._raw.lastItemBy(key);
|
142
148
|
if (!rawEntry)
|
143
149
|
return;
|
144
|
-
|
150
|
+
const entry = entryFromRawEntry(receiver, rawEntry, target._loadedAs, key, target._schema[ItemsSym]);
|
151
|
+
Object.defineProperty(entry, "all", {
|
152
|
+
get: () => {
|
153
|
+
const allRawEntries = target._raw.itemsBy(key);
|
154
|
+
return (function* () {
|
155
|
+
const rawEntry = allRawEntries.next();
|
156
|
+
if (rawEntry.done)
|
157
|
+
return;
|
158
|
+
yield entryFromRawEntry(receiver, rawEntry.value, target._loadedAs, key, target._schema[ItemsSym]);
|
159
|
+
})();
|
160
|
+
},
|
161
|
+
});
|
162
|
+
return entry;
|
145
163
|
}
|
146
164
|
else if (key === "perSession") {
|
147
165
|
return new Proxy(receiver, CoStreamPerSessionProxyHandler);
|
@@ -209,9 +227,23 @@ const CoStreamPerSessionProxyHandler = {
|
|
209
227
|
if (!rawEntry)
|
210
228
|
return;
|
211
229
|
const by = cojsonInternals.accountOrAgentIDfromSessionID(sessionID);
|
212
|
-
|
230
|
+
const entry = entryFromRawEntry(target, rawEntry, target._loadedAs, cojsonInternals.isAccountID(by)
|
213
231
|
? by
|
214
232
|
: undefined, target._schema[ItemsSym]);
|
233
|
+
Object.defineProperty(entry, "all", {
|
234
|
+
get: () => {
|
235
|
+
const allRawEntries = target._raw.itemsIn(sessionID);
|
236
|
+
return (function* () {
|
237
|
+
const rawEntry = allRawEntries.next();
|
238
|
+
if (rawEntry.done)
|
239
|
+
return;
|
240
|
+
yield entryFromRawEntry(receiver, rawEntry.value, target._loadedAs, cojsonInternals.isAccountID(by)
|
241
|
+
? by
|
242
|
+
: undefined, target._schema[ItemsSym]);
|
243
|
+
})();
|
244
|
+
},
|
245
|
+
});
|
246
|
+
return entry;
|
215
247
|
}
|
216
248
|
else {
|
217
249
|
return Reflect.get(target, key, receiver);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"coStream.js","sourceRoot":"","sources":["../../src/coValues/coStream.ts"],"names":[],"mappings":";AAUA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAWzC,OAAO,EACH,QAAQ,EACR,OAAO,EACP,WAAW,E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;QAED,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE;YAC1B,EAAE,EAAE;gBACA,KAAK,EAAE,GAAG,CAAC,EAAE;gBACb,UAAU,EAAE,KAAK;aACpB;YACD,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE;SAC1C,CAAC,CAAC;IACP,CAAC;IAED,SAAS,CAAC,OAET;QAGG,OAAO,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,OAAyB;QAC3B,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,CAAC,IAAgB;QACjB,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,GAAG;QACC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;IAChC,CAAC;IAED,MAAM;QACF,OAAO;YACH,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,GAAG,IAAI,CAAC,SAAS,EAAE;SACtB,CAAC;IACN,CAAC;IAED,CAAC,OAAO,CAAC;QACL,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACzB,CAAC;CACJ"}
|
package/package.json
CHANGED
package/src/coValues/coMap.ts
CHANGED
@@ -10,6 +10,7 @@ import type {
|
|
10
10
|
RefEncoded,
|
11
11
|
EnsureCoValueNullable,
|
12
12
|
IfCo,
|
13
|
+
RefIfCoValue,
|
13
14
|
} from "../internal.js";
|
14
15
|
import {
|
15
16
|
Account,
|
@@ -57,9 +58,7 @@ type DefaultFields = {
|
|
57
58
|
};
|
58
59
|
|
59
60
|
type CoMapSchema<Fields extends object> = {
|
60
|
-
[Key in
|
61
|
-
Fields[Key]
|
62
|
-
>;
|
61
|
+
[Key in CoKeys<Fields> as IfCo<Fields[Key], Key>]: SchemaFor<Fields[Key]>;
|
63
62
|
} & {
|
64
63
|
[ItemsSym]: ItemsSym extends keyof Fields
|
65
64
|
? SchemaFor<Fields[ItemsSym]>
|
@@ -68,7 +67,7 @@ type CoMapSchema<Fields extends object> = {
|
|
68
67
|
|
69
68
|
type CoMapEdit<V> = {
|
70
69
|
value?: V;
|
71
|
-
ref?:
|
70
|
+
ref?: RefIfCoValue<V>;
|
72
71
|
by?: Account;
|
73
72
|
madeAt: Date;
|
74
73
|
};
|
@@ -91,18 +90,15 @@ export class CoMap<Fields extends ValidFields<Fields> = DefaultFields>
|
|
91
90
|
|
92
91
|
static _schema: any;
|
93
92
|
get _schema() {
|
94
|
-
return (this.constructor as typeof CoMap)
|
95
|
-
._schema as CoMapSchema<this>;
|
93
|
+
return (this.constructor as typeof CoMap)._schema as CoMapSchema<this>;
|
96
94
|
}
|
97
95
|
|
98
96
|
get _refs(): {
|
99
|
-
[Key in
|
97
|
+
[Key in CoKeys<this> as NonNullable<this[Key]> extends CoValue
|
100
98
|
? Key
|
101
|
-
: never]:
|
102
|
-
? Ref<NonNullable<this[Key]>>
|
103
|
-
: never;
|
99
|
+
: never]: RefIfCoValue<this[Key]>;
|
104
100
|
} {
|
105
|
-
return makeRefs<
|
101
|
+
return makeRefs<CoKeys<Fields>>(
|
106
102
|
(key) => this._raw.get(key as string) as unknown as ID<CoValue>,
|
107
103
|
() =>
|
108
104
|
Object.keys(this._schema).filter((key) => {
|
@@ -110,7 +106,7 @@ export class CoMap<Fields extends ValidFields<Fields> = DefaultFields>
|
|
110
106
|
key as keyof typeof this._schema
|
111
107
|
] as Schema;
|
112
108
|
schema !== "json" && isRefEncoded(schema);
|
113
|
-
}) as
|
109
|
+
}) as CoKeys<Fields>[],
|
114
110
|
this._loadedAs,
|
115
111
|
(key) => this._schema[key] as RefEncoded<CoValue>
|
116
112
|
) as any;
|
@@ -158,9 +154,7 @@ export class CoMap<Fields extends ValidFields<Fields> = DefaultFields>
|
|
158
154
|
};
|
159
155
|
},
|
160
156
|
}) as {
|
161
|
-
[Key in
|
162
|
-
this[Key]
|
163
|
-
>;
|
157
|
+
[Key in CoKeys<this> as IfCo<this[Key], Key>]: CoMapEdit<this[Key]>;
|
164
158
|
};
|
165
159
|
}
|
166
160
|
|
@@ -203,7 +197,7 @@ export class CoMap<Fields extends ValidFields<Fields> = DefaultFields>
|
|
203
197
|
|
204
198
|
toJSON() {
|
205
199
|
const jsonedFields = this._raw.keys().map((key) => {
|
206
|
-
const tKey = key as
|
200
|
+
const tKey = key as CoKeys<Fields>;
|
207
201
|
const descriptor = this._schema[tKey] as Schema;
|
208
202
|
|
209
203
|
if (descriptor == "json" || "encode" in descriptor) {
|
@@ -262,18 +256,18 @@ export class CoMap<Fields extends ValidFields<Fields> = DefaultFields>
|
|
262
256
|
}
|
263
257
|
}
|
264
258
|
|
265
|
-
export type
|
259
|
+
export type CoKeys<Fields extends object> = Exclude<
|
266
260
|
keyof Fields & string,
|
267
261
|
keyof CoMap<Record<string, never>>
|
268
262
|
>;
|
269
263
|
|
270
264
|
export type CoMapInit<Fields extends object> = {
|
271
|
-
[Key in
|
265
|
+
[Key in CoKeys<Fields> as undefined extends Fields[Key]
|
272
266
|
? never
|
273
267
|
: null extends Fields[Key]
|
274
268
|
? never
|
275
269
|
: IfCo<Fields[Key], Key>]: Fields[Key];
|
276
|
-
} & { [Key in
|
270
|
+
} & { [Key in CoKeys<Fields> as IfCo<Fields[Key], Key>]?: Fields[Key] };
|
277
271
|
|
278
272
|
function tryInit(map: CoMap) {
|
279
273
|
if (
|
@@ -306,9 +300,8 @@ const CoMapProxyHandler: ProxyHandler<CoMap> = {
|
|
306
300
|
} else if (key in target) {
|
307
301
|
return Reflect.get(target, key, receiver);
|
308
302
|
} else {
|
309
|
-
const descriptor = (target._schema[
|
310
|
-
|
311
|
-
] || target._schema[ItemsSym]) as Schema;
|
303
|
+
const descriptor = (target._schema[key as keyof CoMap["_schema"]] ||
|
304
|
+
target._schema[ItemsSym]) as Schema;
|
312
305
|
if (descriptor && typeof key === "string") {
|
313
306
|
const raw = target._raw.get(key);
|
314
307
|
|
@@ -398,9 +391,8 @@ const CoMapProxyHandler: ProxyHandler<CoMap> = {
|
|
398
391
|
if (key in target) {
|
399
392
|
return Reflect.getOwnPropertyDescriptor(target, key);
|
400
393
|
} else {
|
401
|
-
const descriptor = (target._schema[
|
402
|
-
|
403
|
-
] || target._schema[ItemsSym]) as Schema;
|
394
|
+
const descriptor = (target._schema[key as keyof CoMap["_schema"]] ||
|
395
|
+
target._schema[ItemsSym]) as Schema;
|
404
396
|
if (descriptor || key in target._raw.ops) {
|
405
397
|
return {
|
406
398
|
enumerable: true,
|
package/src/coValues/coStream.ts
CHANGED
@@ -32,10 +32,14 @@ import {
|
|
32
32
|
} from "../internal.js";
|
33
33
|
import { Schema as EffectSchema } from "@effect/schema";
|
34
34
|
|
35
|
-
export type CoStreamEntry<Item> = {
|
35
|
+
export type CoStreamEntry<Item> = SingleCoStreamEntry<Item> & {
|
36
|
+
all: IterableIterator<SingleCoStreamEntry<Item>>;
|
37
|
+
};
|
38
|
+
|
39
|
+
export type SingleCoStreamEntry<Item> = {
|
36
40
|
value: NonNullable<Item> extends CoValue ? NonNullable<Item> | null : Item;
|
37
|
-
ref
|
38
|
-
by?: Account;
|
41
|
+
ref: NonNullable<Item> extends CoValue ? Ref<NonNullable<Item>> : never;
|
42
|
+
by?: Account | null;
|
39
43
|
madeAt: Date;
|
40
44
|
tx: CojsonInternalTypes.TransactionID;
|
41
45
|
};
|
@@ -123,7 +127,9 @@ export class CoStream<Item extends ValidItem<Item, "CoStream"> = any>
|
|
123
127
|
if (itemDescriptor === "json") {
|
124
128
|
this._raw.push(item as JsonValue);
|
125
129
|
} else if ("encoded" in itemDescriptor) {
|
126
|
-
this._raw.push(
|
130
|
+
this._raw.push(
|
131
|
+
EffectSchema.encodeSync(itemDescriptor.encoded)(item)
|
132
|
+
);
|
127
133
|
} else if (isRefEncoded(itemDescriptor)) {
|
128
134
|
this._raw.push((item as unknown as CoValue).id);
|
129
135
|
}
|
@@ -180,31 +186,49 @@ function entryFromRawEntry<Item>(
|
|
180
186
|
loadedAs: Account & Me,
|
181
187
|
accountID: ID<Account> | undefined,
|
182
188
|
itemField: Schema
|
183
|
-
) {
|
189
|
+
): Omit<CoStreamEntry<Item>, "all"> {
|
184
190
|
return {
|
185
|
-
get value(): Item
|
191
|
+
get value(): NonNullable<Item> extends CoValue
|
192
|
+
? (CoValue & Item) | null
|
193
|
+
: Item {
|
186
194
|
if (itemField === "json") {
|
187
|
-
return rawEntry.value as Item
|
195
|
+
return rawEntry.value as NonNullable<Item> extends CoValue
|
196
|
+
? (CoValue & Item) | null
|
197
|
+
: Item;
|
188
198
|
} else if ("encoded" in itemField) {
|
189
|
-
return EffectSchema.decodeSync(itemField.encoded)(
|
199
|
+
return EffectSchema.decodeSync(itemField.encoded)(
|
200
|
+
rawEntry.value
|
201
|
+
);
|
190
202
|
} else if (isRefEncoded(itemField)) {
|
191
|
-
return this.ref?.accessFrom(
|
203
|
+
return this.ref?.accessFrom(
|
204
|
+
accessFrom
|
205
|
+
) as NonNullable<Item> extends CoValue
|
206
|
+
? (CoValue & Item) | null
|
207
|
+
: Item;
|
208
|
+
} else {
|
209
|
+
throw new Error("Invalid item field schema");
|
192
210
|
}
|
193
211
|
},
|
194
|
-
get ref()
|
212
|
+
get ref(): NonNullable<Item> extends CoValue
|
213
|
+
? Ref<NonNullable<Item>>
|
214
|
+
: never {
|
195
215
|
if (itemField !== "json" && isRefEncoded(itemField)) {
|
196
216
|
const rawId = rawEntry.value;
|
197
217
|
return new Ref(
|
198
218
|
rawId as unknown as ID<CoValue>,
|
199
219
|
loadedAs,
|
200
220
|
itemField
|
201
|
-
)
|
221
|
+
) as NonNullable<Item> extends CoValue
|
222
|
+
? Ref<NonNullable<Item>>
|
223
|
+
: never;
|
224
|
+
} else {
|
225
|
+
return undefined as never;
|
202
226
|
}
|
203
227
|
},
|
204
228
|
get by() {
|
205
229
|
return (
|
206
230
|
accountID &&
|
207
|
-
new Ref(
|
231
|
+
new Ref<Account>(
|
208
232
|
accountID as unknown as ID<Account>,
|
209
233
|
loadedAs,
|
210
234
|
Account
|
@@ -243,13 +267,32 @@ export const CoStreamProxyHandler: ProxyHandler<CoStream> = {
|
|
243
267
|
const rawEntry = target._raw.lastItemBy(key as AccountID);
|
244
268
|
|
245
269
|
if (!rawEntry) return;
|
246
|
-
|
270
|
+
const entry = entryFromRawEntry(
|
247
271
|
receiver,
|
248
272
|
rawEntry,
|
249
273
|
target._loadedAs,
|
250
274
|
key as unknown as ID<Account>,
|
251
275
|
target._schema[ItemsSym]
|
252
276
|
);
|
277
|
+
|
278
|
+
Object.defineProperty(entry, "all", {
|
279
|
+
get: () => {
|
280
|
+
const allRawEntries = target._raw.itemsBy(key as AccountID);
|
281
|
+
return (function* () {
|
282
|
+
const rawEntry = allRawEntries.next();
|
283
|
+
if (rawEntry.done) return;
|
284
|
+
yield entryFromRawEntry(
|
285
|
+
receiver,
|
286
|
+
rawEntry.value,
|
287
|
+
target._loadedAs,
|
288
|
+
key as unknown as ID<Account>,
|
289
|
+
target._schema[ItemsSym]
|
290
|
+
);
|
291
|
+
})() satisfies IterableIterator<SingleCoStreamEntry<any>>;
|
292
|
+
},
|
293
|
+
});
|
294
|
+
|
295
|
+
return entry;
|
253
296
|
} else if (key === "perSession") {
|
254
297
|
return new Proxy(receiver, CoStreamPerSessionProxyHandler);
|
255
298
|
} else {
|
@@ -317,7 +360,8 @@ const CoStreamPerSessionProxyHandler: ProxyHandler<CoStream> = {
|
|
317
360
|
|
318
361
|
if (!rawEntry) return;
|
319
362
|
const by = cojsonInternals.accountOrAgentIDfromSessionID(sessionID);
|
320
|
-
|
363
|
+
|
364
|
+
const entry = entryFromRawEntry(
|
321
365
|
target,
|
322
366
|
rawEntry,
|
323
367
|
target._loadedAs,
|
@@ -326,6 +370,27 @@ const CoStreamPerSessionProxyHandler: ProxyHandler<CoStream> = {
|
|
326
370
|
: undefined,
|
327
371
|
target._schema[ItemsSym]
|
328
372
|
);
|
373
|
+
|
374
|
+
Object.defineProperty(entry, "all", {
|
375
|
+
get: () => {
|
376
|
+
const allRawEntries = target._raw.itemsIn(sessionID);
|
377
|
+
return (function* () {
|
378
|
+
const rawEntry = allRawEntries.next();
|
379
|
+
if (rawEntry.done) return;
|
380
|
+
yield entryFromRawEntry(
|
381
|
+
receiver,
|
382
|
+
rawEntry.value,
|
383
|
+
target._loadedAs,
|
384
|
+
cojsonInternals.isAccountID(by)
|
385
|
+
? (by as unknown as ID<Account>)
|
386
|
+
: undefined,
|
387
|
+
target._schema[ItemsSym]
|
388
|
+
);
|
389
|
+
})() satisfies IterableIterator<SingleCoStreamEntry<any>>;
|
390
|
+
},
|
391
|
+
});
|
392
|
+
|
393
|
+
return entry;
|
329
394
|
} else {
|
330
395
|
return Reflect.get(target, key, receiver);
|
331
396
|
}
|
@@ -83,9 +83,9 @@ export function isCoValueClass(value: any): value is CoValueClass {
|
|
83
83
|
}
|
84
84
|
|
85
85
|
/** @category Schemas & CoValues - Abstract interfaces */
|
86
|
-
export type ID<T> = CojsonInternalTypes.RawCoID &
|
87
|
-
|
88
|
-
};
|
86
|
+
export type ID<T> = CojsonInternalTypes.RawCoID & IDMarker<T>;
|
87
|
+
|
88
|
+
type IDMarker<out T> = { __type(_: never): T };
|
89
89
|
|
90
90
|
export class CoValueBase implements CoValue {
|
91
91
|
id!: ID<this>;
|