jazz-tools 0.7.0-alpha.9 → 0.7.1
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/.eslintrc.cjs +3 -10
- package/.prettierrc.js +9 -0
- package/.turbo/turbo-build.log +3 -19
- package/.turbo/turbo-lint.log +4 -0
- package/.turbo/turbo-test.log +140 -0
- package/CHANGELOG.md +298 -0
- package/README.md +10 -2
- package/dist/coValues/account.js +59 -41
- package/dist/coValues/account.js.map +1 -1
- package/dist/coValues/coList.js +49 -46
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.js +143 -44
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coStream.js +144 -35
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/coValues/deepLoading.js +60 -0
- package/dist/coValues/deepLoading.js.map +1 -0
- package/dist/coValues/extensions/imageDef.js +10 -7
- package/dist/coValues/extensions/imageDef.js.map +1 -1
- package/dist/coValues/group.js +49 -13
- package/dist/coValues/group.js.map +1 -1
- package/dist/coValues/interfaces.js +70 -31
- package/dist/coValues/interfaces.js.map +1 -1
- package/dist/implementation/devtoolsFormatters.js +114 -0
- package/dist/implementation/devtoolsFormatters.js.map +1 -0
- package/dist/implementation/refs.js +58 -18
- package/dist/implementation/refs.js.map +1 -1
- package/dist/implementation/schema.js +58 -0
- package/dist/implementation/schema.js.map +1 -0
- package/dist/implementation/subscriptionScope.js +19 -1
- package/dist/implementation/subscriptionScope.js.map +1 -1
- package/dist/implementation/symbols.js +5 -0
- package/dist/implementation/symbols.js.map +1 -0
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/dist/internal.js +5 -2
- package/dist/internal.js.map +1 -1
- package/dist/tests/coList.test.js +51 -48
- package/dist/tests/coList.test.js.map +1 -1
- package/dist/tests/coMap.test.js +131 -74
- package/dist/tests/coMap.test.js.map +1 -1
- package/dist/tests/coStream.test.js +56 -41
- package/dist/tests/coStream.test.js.map +1 -1
- package/dist/tests/deepLoading.test.js +188 -0
- package/dist/tests/deepLoading.test.js.map +1 -0
- package/dist/tests/groupsAndAccounts.test.js +83 -0
- package/dist/tests/groupsAndAccounts.test.js.map +1 -0
- package/package.json +17 -9
- package/src/coValues/account.ts +113 -125
- package/src/coValues/coList.ts +87 -103
- package/src/coValues/coMap.ts +200 -147
- package/src/coValues/coStream.ts +264 -80
- package/src/coValues/deepLoading.ts +229 -0
- package/src/coValues/extensions/imageDef.ts +17 -13
- package/src/coValues/group.ts +92 -58
- package/src/coValues/interfaces.ts +215 -115
- package/src/implementation/devtoolsFormatters.ts +110 -0
- package/src/implementation/inspect.ts +1 -1
- package/src/implementation/refs.ts +80 -28
- package/src/implementation/schema.ts +138 -0
- package/src/implementation/subscriptionScope.ts +48 -12
- package/src/implementation/symbols.ts +11 -0
- package/src/index.ts +12 -8
- package/src/internal.ts +7 -3
- package/src/tests/coList.test.ts +77 -62
- package/src/tests/coMap.test.ts +201 -114
- package/src/tests/coStream.test.ts +113 -84
- package/src/tests/deepLoading.test.ts +301 -0
- package/src/tests/groupsAndAccounts.test.ts +91 -0
- package/dist/implementation/encoding.js +0 -26
- package/dist/implementation/encoding.js.map +0 -1
- package/src/implementation/encoding.ts +0 -105
@@ -1,7 +1,7 @@
|
|
1
|
-
import { Effect, Sink, Stream } from "effect";
|
1
|
+
import { Effect, Option, Sink, Stream } from "effect";
|
2
2
|
import type { CojsonInternalTypes, RawCoValue } from "cojson";
|
3
3
|
import { RawAccount } from "cojson";
|
4
|
-
import type {
|
4
|
+
import type { DeeplyLoaded, DepthsIn, UnavailableError } from "../internal.js";
|
5
5
|
import {
|
6
6
|
Account,
|
7
7
|
AccountCtx,
|
@@ -9,200 +9,290 @@ import {
|
|
9
9
|
SubscriptionScope,
|
10
10
|
Ref,
|
11
11
|
inspect,
|
12
|
+
subscriptionsScopes,
|
12
13
|
} from "../internal.js";
|
14
|
+
import { fulfillsDepth } from "./deepLoading.js";
|
13
15
|
|
14
|
-
export type
|
16
|
+
export type ClassOf<T> = {
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
15
18
|
new (...args: any[]): T;
|
16
19
|
};
|
17
20
|
|
21
|
+
/** @category Abstract interfaces */
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
18
23
|
export interface CoValueClass<Value extends CoValue = CoValue, Init = any> {
|
19
|
-
/** @category Construction and loading */
|
20
24
|
new (init: Init, options: { owner: Account | Group }): Value;
|
21
25
|
|
22
26
|
/** @ignore */
|
23
27
|
fromRaw(raw: Value["_raw"]): Value;
|
24
28
|
|
25
|
-
/** @category
|
26
|
-
load<V extends Value>(
|
27
|
-
this:
|
29
|
+
/** @category Subscription & Loading */
|
30
|
+
load<V extends Value, Depth>(
|
31
|
+
this: ClassOf<V>,
|
28
32
|
id: ID<V>,
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
as: Account,
|
34
|
+
depth: Depth & DepthsIn<V>,
|
35
|
+
): Promise<DeeplyLoaded<V, Depth> | undefined>;
|
36
|
+
/** @category Subscription & Loading */
|
37
|
+
load<V extends Value, Depth>(
|
38
|
+
this: ClassOf<V>,
|
39
|
+
existing: V,
|
40
|
+
depth: Depth & DepthsIn<V>,
|
41
|
+
): Promise<DeeplyLoaded<V, Depth> | undefined>;
|
34
42
|
|
35
|
-
/** @category
|
36
|
-
loadEf<V extends Value>(
|
37
|
-
this:
|
38
|
-
id: ID<V
|
39
|
-
|
43
|
+
/** @category Subscription & Loading */
|
44
|
+
loadEf<V extends Value, Depth>(
|
45
|
+
this: ClassOf<V>,
|
46
|
+
id: ID<V>,
|
47
|
+
depth: Depth & DepthsIn<V>,
|
48
|
+
): Effect.Effect<DeeplyLoaded<V, Depth>, UnavailableError, AccountCtx>;
|
40
49
|
|
41
|
-
/** @category Subscription */
|
42
|
-
subscribe<V extends Value,
|
43
|
-
this:
|
50
|
+
/** @category Subscription & Loading */
|
51
|
+
subscribe<V extends Value, Depth>(
|
52
|
+
this: ClassOf<V>,
|
44
53
|
id: ID<V>,
|
45
|
-
|
46
|
-
|
54
|
+
as: Account,
|
55
|
+
depth: Depth & DepthsIn<V>,
|
56
|
+
listener: (value: DeeplyLoaded<V, Depth>) => void,
|
57
|
+
): () => void;
|
58
|
+
subscribe<V extends Value, Depth>(
|
59
|
+
this: ClassOf<V>,
|
60
|
+
existing: V,
|
61
|
+
depth: Depth & DepthsIn<V>,
|
62
|
+
listener: (value: DeeplyLoaded<V, Depth>) => void,
|
47
63
|
): () => void;
|
48
64
|
|
49
|
-
/** @category Subscription */
|
50
|
-
subscribeEf<V extends Value>(
|
51
|
-
this:
|
52
|
-
id: ID<V
|
53
|
-
|
65
|
+
/** @category Subscription & Loading */
|
66
|
+
subscribeEf<V extends Value, Depth>(
|
67
|
+
this: ClassOf<V>,
|
68
|
+
id: ID<V>,
|
69
|
+
depth: Depth & DepthsIn<V>,
|
70
|
+
): Stream.Stream<DeeplyLoaded<V, Depth>, UnavailableError, AccountCtx>;
|
54
71
|
}
|
55
72
|
|
56
|
-
/** @category
|
73
|
+
/** @category Abstract interfaces */
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
57
75
|
export interface CoValue<Type extends string = string, Raw = any> {
|
58
|
-
/** @category
|
76
|
+
/** @category Content */
|
59
77
|
readonly id: ID<this>;
|
60
|
-
/** @category
|
78
|
+
/** @category Type Helpers */
|
61
79
|
_type: Type;
|
62
80
|
/** @category Collaboration */
|
63
81
|
_owner: Account | Group;
|
64
|
-
/** @category Subscription */
|
65
|
-
subscribe(listener: (update: this) => void): () => void;
|
66
|
-
/** @category Subscription */
|
67
|
-
subscribeEf(): Stream.Stream<this, UnavailableError, never>;
|
68
82
|
/** @category Internals */
|
69
83
|
_raw: Raw;
|
70
|
-
/** @
|
71
|
-
readonly _loadedAs: Account
|
72
|
-
/** @category Stringifying &
|
84
|
+
/** @internal */
|
85
|
+
readonly _loadedAs: Account;
|
86
|
+
/** @category Stringifying & Inspection */
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
73
88
|
toJSON(): any[] | object;
|
74
|
-
/** @category Stringifying &
|
89
|
+
/** @category Stringifying & Inspection */
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
75
91
|
[inspect](): any;
|
76
92
|
}
|
77
93
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
78
95
|
export function isCoValue(value: any): value is CoValue {
|
79
96
|
return value && value._type !== undefined;
|
80
97
|
}
|
81
98
|
|
82
|
-
|
83
|
-
export
|
84
|
-
|
85
|
-
}
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
100
|
+
export function isCoValueClass(value: any): value is CoValueClass {
|
101
|
+
return typeof value === "function" && value.fromRaw !== undefined;
|
102
|
+
}
|
103
|
+
|
104
|
+
/** @category CoValues */
|
105
|
+
export type ID<T> = CojsonInternalTypes.RawCoID & IDMarker<T>;
|
106
|
+
|
107
|
+
type IDMarker<out T> = { __type(_: never): T };
|
86
108
|
|
109
|
+
/** @internal */
|
87
110
|
export class CoValueBase implements CoValue {
|
88
111
|
id!: ID<this>;
|
89
112
|
_type!: string;
|
90
113
|
_raw!: RawCoValue;
|
114
|
+
_instanceID!: string;
|
91
115
|
|
92
116
|
get _owner(): Account | Group {
|
93
|
-
|
94
|
-
|
95
|
-
|
117
|
+
const owner =
|
118
|
+
this._raw.group instanceof RawAccount
|
119
|
+
? Account.fromRaw(this._raw.group)
|
120
|
+
: Group.fromRaw(this._raw.group);
|
121
|
+
|
122
|
+
const subScope = subscriptionsScopes.get(this);
|
123
|
+
if (subScope) {
|
124
|
+
subScope.onRefAccessedOrSet(this.id, owner.id);
|
125
|
+
subscriptionsScopes.set(owner, subScope);
|
126
|
+
}
|
127
|
+
|
128
|
+
return owner;
|
96
129
|
}
|
97
130
|
|
131
|
+
/** @private */
|
98
132
|
get _loadedAs() {
|
99
133
|
return Account.fromNode(this._raw.core.node);
|
100
134
|
}
|
101
135
|
|
102
|
-
|
136
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
137
|
+
constructor(..._args: any) {
|
138
|
+
Object.defineProperty(this, "_instanceID", {
|
139
|
+
value: `instance-${Math.random().toString(36).slice(2)}`,
|
140
|
+
enumerable: false,
|
141
|
+
});
|
142
|
+
}
|
103
143
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
): V {
|
108
|
-
return new this(undefined, { fromRaw: raw });
|
144
|
+
/** @category Internals */
|
145
|
+
static fromRaw<V extends CoValue>(this: ClassOf<V>, raw: RawCoValue): V {
|
146
|
+
return new this({ fromRaw: raw });
|
109
147
|
}
|
110
148
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
149
|
+
/** @category Subscription & Loading */
|
150
|
+
static load<V extends CoValue, Depth>(
|
151
|
+
this: ClassOf<V> & typeof CoValueBase,
|
152
|
+
id: ID<V>,
|
153
|
+
as: Account,
|
154
|
+
depth: Depth & DepthsIn<V>,
|
155
|
+
): Promise<DeeplyLoaded<V, Depth> | undefined>;
|
156
|
+
/** @category Subscription & Loading */
|
157
|
+
static load<V extends CoValue, Depth>(
|
158
|
+
this: ClassOf<V> & typeof CoValueBase,
|
159
|
+
existing: V,
|
160
|
+
depth: Depth & DepthsIn<V>,
|
161
|
+
): Promise<DeeplyLoaded<V, Depth> | undefined>;
|
162
|
+
static load<V extends CoValue, Depth>(
|
163
|
+
this: ClassOf<V> & typeof CoValueBase,
|
164
|
+
|
165
|
+
...args:
|
166
|
+
| [ID<V>, Account, Depth & DepthsIn<V>]
|
167
|
+
| [V, Depth & DepthsIn<V>]
|
168
|
+
): Promise<DeeplyLoaded<V, Depth> | undefined> {
|
169
|
+
const { id, as, depth } =
|
170
|
+
args.length === 3
|
171
|
+
? { id: args[0], as: args[1], depth: args[2] }
|
172
|
+
: { id: args[0].id, as: args[0]._loadedAs, depth: args[1] };
|
173
|
+
return Effect.runPromise(
|
174
|
+
this.loadEf(id, depth).pipe(
|
175
|
+
Effect.mapError(() => undefined),
|
176
|
+
Effect.merge,
|
177
|
+
Effect.provideService(AccountCtx, as),
|
178
|
+
),
|
179
|
+
);
|
123
180
|
}
|
124
181
|
|
125
|
-
|
126
|
-
|
182
|
+
/** @category Subscription & Loading */
|
183
|
+
static loadEf<V extends CoValue, Depth>(
|
184
|
+
this: ClassOf<V> & typeof CoValueBase,
|
127
185
|
id: ID<V>,
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
186
|
+
depth: Depth & DepthsIn<V>,
|
187
|
+
): Effect.Effect<DeeplyLoaded<V, Depth>, UnavailableError, AccountCtx> {
|
188
|
+
return this.subscribeEf(id, depth).pipe(
|
189
|
+
Stream.runHead,
|
190
|
+
Effect.andThen(
|
191
|
+
Effect.mapError((_noSuchElem) => "unavailable" as const),
|
192
|
+
),
|
193
|
+
);
|
136
194
|
}
|
137
195
|
|
138
|
-
|
139
|
-
|
196
|
+
/** @category Subscription & Loading */
|
197
|
+
static subscribe<V extends CoValue, Depth>(
|
198
|
+
this: ClassOf<V> & typeof CoValueBase,
|
140
199
|
id: ID<V>,
|
141
|
-
|
142
|
-
|
200
|
+
as: Account,
|
201
|
+
depth: Depth & DepthsIn<V>,
|
202
|
+
listener: (value: DeeplyLoaded<V, Depth>) => void,
|
203
|
+
): () => void;
|
204
|
+
static subscribe<V extends CoValue, Depth>(
|
205
|
+
this: ClassOf<V> & typeof CoValueBase,
|
206
|
+
existing: V,
|
207
|
+
depth: Depth & DepthsIn<V>,
|
208
|
+
listener: (value: DeeplyLoaded<V, Depth>) => void,
|
209
|
+
): () => void;
|
210
|
+
static subscribe<V extends CoValue, Depth>(
|
211
|
+
this: ClassOf<V> & typeof CoValueBase,
|
212
|
+
...args:
|
213
|
+
| [
|
214
|
+
ID<V>,
|
215
|
+
Account,
|
216
|
+
Depth & DepthsIn<V>,
|
217
|
+
(value: DeeplyLoaded<V, Depth>) => void,
|
218
|
+
]
|
219
|
+
| [V, Depth & DepthsIn<V>, (value: DeeplyLoaded<V, Depth>) => void]
|
143
220
|
): () => void {
|
221
|
+
const { id, as, depth, listener } =
|
222
|
+
args.length === 4
|
223
|
+
? {
|
224
|
+
id: args[0],
|
225
|
+
as: args[1],
|
226
|
+
depth: args[2],
|
227
|
+
listener: args[3],
|
228
|
+
}
|
229
|
+
: {
|
230
|
+
id: args[0].id,
|
231
|
+
as: args[0]._loadedAs,
|
232
|
+
depth: args[1],
|
233
|
+
listener: args[2],
|
234
|
+
};
|
144
235
|
void Effect.runPromise(
|
145
236
|
Effect.provideService(
|
146
|
-
this.subscribeEf(id).pipe(
|
237
|
+
this.subscribeEf(id, depth).pipe(
|
147
238
|
Stream.run(
|
148
239
|
Sink.forEach((update) =>
|
149
|
-
Effect.sync(() =>
|
150
|
-
)
|
151
|
-
)
|
240
|
+
Effect.sync(() => listener(update)),
|
241
|
+
),
|
242
|
+
),
|
152
243
|
),
|
153
244
|
AccountCtx,
|
154
|
-
|
155
|
-
)
|
245
|
+
as,
|
246
|
+
),
|
156
247
|
);
|
157
248
|
|
158
249
|
return function unsubscribe() {};
|
159
250
|
}
|
160
251
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
252
|
+
/** @category Subscription & Loading */
|
253
|
+
static subscribeEf<V extends CoValue, Depth>(
|
254
|
+
this: ClassOf<V> & typeof CoValueBase,
|
255
|
+
id: ID<V>,
|
256
|
+
depth: Depth & DepthsIn<V>,
|
257
|
+
): Stream.Stream<DeeplyLoaded<V, Depth>, UnavailableError, AccountCtx> {
|
258
|
+
return AccountCtx.pipe(
|
259
|
+
Effect.andThen((account) =>
|
260
|
+
new Ref(id, account, {
|
261
|
+
ref: this as CoValueClass<V>,
|
262
|
+
optional: false,
|
263
|
+
}).loadEf(),
|
264
|
+
),
|
265
|
+
Stream.fromEffect,
|
266
|
+
Stream.flatMap((value: V) =>
|
167
267
|
Stream.asyncScoped<V, UnavailableError>((emit) =>
|
168
268
|
Effect.gen(this, function* (_) {
|
169
269
|
const subscription = new SubscriptionScope(
|
170
270
|
value,
|
171
271
|
this,
|
172
|
-
(update) =>
|
173
|
-
void emit.single(update as V);
|
174
|
-
}
|
272
|
+
(update) => void emit.single(update as V),
|
175
273
|
);
|
176
274
|
|
177
275
|
yield* _(
|
178
276
|
Effect.addFinalizer(() =>
|
179
|
-
Effect.sync(() =>
|
180
|
-
|
277
|
+
Effect.sync(() =>
|
278
|
+
subscription.unsubscribeAll(),
|
279
|
+
),
|
280
|
+
),
|
181
281
|
);
|
182
|
-
})
|
183
|
-
)
|
184
|
-
)
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
{ as: this._loadedAs },
|
192
|
-
listener as unknown as (update: CoValue) => void
|
193
|
-
);
|
194
|
-
}
|
195
|
-
|
196
|
-
subscribeEf(): Stream.Stream<this, UnavailableError, never> {
|
197
|
-
return Stream.provideService(
|
198
|
-
(this.constructor as unknown as typeof CoValueBase).subscribeEf(
|
199
|
-
this.id as unknown as ID<CoValue>
|
282
|
+
}),
|
283
|
+
),
|
284
|
+
),
|
285
|
+
Stream.filterMap((update: V) =>
|
286
|
+
Option.fromNullable(
|
287
|
+
fulfillsDepth(depth, update)
|
288
|
+
? (update as DeeplyLoaded<V, Depth>)
|
289
|
+
: undefined,
|
290
|
+
),
|
200
291
|
),
|
201
|
-
|
202
|
-
this._loadedAs
|
203
|
-
) as unknown as Stream.Stream<this, UnavailableError, never>;
|
292
|
+
);
|
204
293
|
}
|
205
294
|
|
295
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
206
296
|
toJSON(): object | any[] {
|
207
297
|
return {
|
208
298
|
id: this.id,
|
@@ -214,4 +304,14 @@ export class CoValueBase implements CoValue {
|
|
214
304
|
[inspect]() {
|
215
305
|
return this.toJSON();
|
216
306
|
}
|
307
|
+
|
308
|
+
/** @category Type Helpers*/
|
309
|
+
as<C extends CoValueClass>(otherSchema: C): InstanceType<C> {
|
310
|
+
const cast = otherSchema.fromRaw(this._raw) as InstanceType<C>;
|
311
|
+
const subScope = subscriptionsScopes.get(this);
|
312
|
+
if (subScope) {
|
313
|
+
subscriptionsScopes.set(cast, subScope);
|
314
|
+
}
|
315
|
+
return cast;
|
316
|
+
}
|
217
317
|
}
|
@@ -0,0 +1,110 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
2
|
+
import { ItemsSym } from "./symbols.js";
|
3
|
+
|
4
|
+
(globalThis as any).devtoolsFormatters = [
|
5
|
+
{
|
6
|
+
header: (object: any) => {
|
7
|
+
if (object._type === "CoMap") {
|
8
|
+
return ["div", {}, ["span", {}, object.constructor.name]];
|
9
|
+
} else if (object._type === "CoList") {
|
10
|
+
return [
|
11
|
+
"div",
|
12
|
+
{},
|
13
|
+
[
|
14
|
+
"span",
|
15
|
+
{},
|
16
|
+
object.constructor.name + "(" + object.length + ") ",
|
17
|
+
],
|
18
|
+
];
|
19
|
+
} else if (object._type === "Account") {
|
20
|
+
return [
|
21
|
+
"div",
|
22
|
+
{},
|
23
|
+
[
|
24
|
+
"span",
|
25
|
+
{},
|
26
|
+
object.constructor.name +
|
27
|
+
"(" +
|
28
|
+
object._refs.profile.value?.name +
|
29
|
+
(object.isMe ? " ME" : "") +
|
30
|
+
")",
|
31
|
+
],
|
32
|
+
];
|
33
|
+
} else {
|
34
|
+
return null;
|
35
|
+
}
|
36
|
+
},
|
37
|
+
hasBody: function () {
|
38
|
+
return true;
|
39
|
+
},
|
40
|
+
body: function (object: any) {
|
41
|
+
if (object._type === "CoMap" || object._type === "Account") {
|
42
|
+
return [
|
43
|
+
"div",
|
44
|
+
{ style: "margin-left: 15px" },
|
45
|
+
["div", "id: ", ["object", { object: object.id }]],
|
46
|
+
...Object.entries(object).map(([k, v]) => [
|
47
|
+
"div",
|
48
|
+
{ style: "white-space: nowrap;" },
|
49
|
+
[
|
50
|
+
"span",
|
51
|
+
{ style: "font-weight: bold; opacity: 0.6" },
|
52
|
+
k,
|
53
|
+
": ",
|
54
|
+
],
|
55
|
+
["object", { object: v }],
|
56
|
+
...(typeof object._schema[k] === "function"
|
57
|
+
? v === null
|
58
|
+
? [
|
59
|
+
[
|
60
|
+
"span",
|
61
|
+
{ style: "opacity: 0.5" },
|
62
|
+
` (pending ${object._schema[k].name} `,
|
63
|
+
[
|
64
|
+
"object",
|
65
|
+
{ object: object._refs[k] },
|
66
|
+
],
|
67
|
+
")",
|
68
|
+
],
|
69
|
+
]
|
70
|
+
: []
|
71
|
+
: []),
|
72
|
+
]),
|
73
|
+
];
|
74
|
+
} else if (object._type === "CoList") {
|
75
|
+
return [
|
76
|
+
"div",
|
77
|
+
{ style: "margin-left: 15px" },
|
78
|
+
["div", "id: ", ["object", { object: object.id }]],
|
79
|
+
...(object as any[]).map((v, i) => [
|
80
|
+
"div",
|
81
|
+
{ style: "white-space: nowrap;" },
|
82
|
+
[
|
83
|
+
"span",
|
84
|
+
{ style: "font-weight: bold; opacity: 0.6" },
|
85
|
+
i,
|
86
|
+
": ",
|
87
|
+
],
|
88
|
+
["object", { object: v }],
|
89
|
+
...(typeof object._schema[ItemsSym] === "function"
|
90
|
+
? v === null
|
91
|
+
? [
|
92
|
+
[
|
93
|
+
"span",
|
94
|
+
{ style: "opacity: 0.5" },
|
95
|
+
` (pending ${object._schema[ItemsSym].name} `,
|
96
|
+
[
|
97
|
+
"object",
|
98
|
+
{ object: object._refs[i] },
|
99
|
+
],
|
100
|
+
")",
|
101
|
+
],
|
102
|
+
]
|
103
|
+
: []
|
104
|
+
: []),
|
105
|
+
]),
|
106
|
+
];
|
107
|
+
}
|
108
|
+
},
|
109
|
+
},
|
110
|
+
];
|
@@ -1,2 +1,2 @@
|
|
1
1
|
export const inspect = Symbol.for("nodejs.util.inspect.custom");
|
2
|
-
export type inspect = typeof inspect;
|
2
|
+
export type inspect = typeof inspect;
|