jazz-tools 0.8.14 → 0.8.16
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +281 -268
- package/dist/native/coValues/account.js +3 -6
- package/dist/native/coValues/account.js.map +1 -1
- package/dist/native/coValues/coList.js +3 -7
- package/dist/native/coValues/coList.js.map +1 -1
- package/dist/native/coValues/coMap.js +8 -14
- package/dist/native/coValues/coMap.js.map +1 -1
- package/dist/native/coValues/coStream.js +7 -12
- package/dist/native/coValues/coStream.js.map +1 -1
- package/dist/native/coValues/deepLoading.js +6 -3
- package/dist/native/coValues/deepLoading.js.map +1 -1
- package/dist/native/coValues/extensions/imageDef.js.map +1 -1
- package/dist/native/coValues/group.js +3 -6
- package/dist/native/coValues/group.js.map +1 -1
- package/dist/native/coValues/interfaces.js +4 -3
- package/dist/native/coValues/interfaces.js.map +1 -1
- package/dist/native/exports.js +3 -9
- package/dist/native/exports.js.map +1 -1
- package/dist/native/implementation/createContext.js +7 -0
- package/dist/native/implementation/createContext.js.map +1 -1
- package/dist/native/implementation/devtoolsFormatters.js +5 -25
- package/dist/native/implementation/devtoolsFormatters.js.map +1 -1
- package/dist/native/implementation/refs.js +1 -2
- package/dist/native/implementation/refs.js.map +1 -1
- package/dist/native/implementation/schema.js +1 -1
- package/dist/native/implementation/schema.js.map +1 -1
- package/dist/native/implementation/subscriptionScope.js +2 -4
- package/dist/native/implementation/subscriptionScope.js.map +1 -1
- package/dist/native/index.native.js +1 -1
- package/dist/native/index.native.js.map +1 -1
- package/dist/native/lib/cache.js.map +1 -1
- package/dist/native/lib/cache.test.js +1 -1
- package/dist/native/lib/cache.test.js.map +1 -1
- package/dist/web/coValues/account.js +3 -6
- package/dist/web/coValues/account.js.map +1 -1
- package/dist/web/coValues/coList.js +3 -7
- package/dist/web/coValues/coList.js.map +1 -1
- package/dist/web/coValues/coMap.js +8 -14
- package/dist/web/coValues/coMap.js.map +1 -1
- package/dist/web/coValues/coStream.js +7 -12
- package/dist/web/coValues/coStream.js.map +1 -1
- package/dist/web/coValues/deepLoading.js +6 -3
- package/dist/web/coValues/deepLoading.js.map +1 -1
- package/dist/web/coValues/extensions/imageDef.js.map +1 -1
- package/dist/web/coValues/group.js +3 -6
- package/dist/web/coValues/group.js.map +1 -1
- package/dist/web/coValues/interfaces.js +4 -3
- package/dist/web/coValues/interfaces.js.map +1 -1
- package/dist/web/exports.js +3 -9
- package/dist/web/exports.js.map +1 -1
- package/dist/web/implementation/createContext.js +7 -0
- package/dist/web/implementation/createContext.js.map +1 -1
- package/dist/web/implementation/devtoolsFormatters.js +5 -25
- package/dist/web/implementation/devtoolsFormatters.js.map +1 -1
- package/dist/web/implementation/refs.js +1 -2
- package/dist/web/implementation/refs.js.map +1 -1
- package/dist/web/implementation/schema.js +1 -1
- package/dist/web/implementation/schema.js.map +1 -1
- package/dist/web/implementation/subscriptionScope.js +2 -4
- package/dist/web/implementation/subscriptionScope.js.map +1 -1
- package/dist/web/lib/cache.js.map +1 -1
- package/dist/web/lib/cache.test.js +1 -1
- package/dist/web/lib/cache.test.js.map +1 -1
- package/package.json +5 -9
- package/src/coValues/account.ts +330 -339
- package/src/coValues/coList.ts +474 -495
- package/src/coValues/coMap.ts +584 -604
- package/src/coValues/coStream.ts +624 -650
- package/src/coValues/deepLoading.ts +184 -200
- package/src/coValues/extensions/imageDef.ts +44 -44
- package/src/coValues/group.ts +196 -210
- package/src/coValues/interfaces.ts +197 -199
- package/src/exports.ts +38 -25
- package/src/implementation/createContext.ts +210 -204
- package/src/implementation/devtoolsFormatters.ts +80 -100
- package/src/implementation/refs.ts +127 -139
- package/src/implementation/schema.ts +124 -128
- package/src/implementation/subscriptionScope.ts +111 -121
- package/src/index.native.ts +3 -3
- package/src/lib/cache.test.ts +48 -48
- package/src/lib/cache.ts +9 -9
- package/src/tests/coList.test.ts +264 -283
- package/src/tests/coMap.test.ts +741 -761
- package/src/tests/coStream.test.ts +405 -438
- package/src/tests/deepLoading.test.ts +251 -256
- package/src/tests/groupsAndAccounts.test.ts +70 -74
- package/src/tests/schema.test.ts +198 -198
- package/src/tests/subscribe.test.ts +312 -299
- package/tsconfig.json +2 -4
- package/tsconfig.native.json +4 -10
- package/tsconfig.web.json +4 -10
- package/.eslintrc.cjs +0 -24
- package/.prettierrc.js +0 -9
@@ -1,270 +1,276 @@
|
|
1
1
|
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
2
|
+
AgentSecret,
|
3
|
+
CoID,
|
4
|
+
ControlledAgent,
|
5
|
+
CryptoProvider,
|
6
|
+
LocalNode,
|
7
|
+
Peer,
|
8
|
+
RawAccount,
|
9
|
+
RawAccountID,
|
10
|
+
SessionID,
|
11
11
|
} from "cojson";
|
12
12
|
import { Account, AccountClass, ID } from "../internal.js";
|
13
13
|
|
14
|
+
export type Credentials = {
|
15
|
+
accountID: ID<Account>;
|
16
|
+
secret: AgentSecret;
|
17
|
+
};
|
18
|
+
|
14
19
|
export type AuthResult =
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
logOut: () => void;
|
33
|
-
};
|
20
|
+
| {
|
21
|
+
type: "existing";
|
22
|
+
credentials: Credentials;
|
23
|
+
saveCredentials?: (credentials: Credentials) => Promise<void>;
|
24
|
+
onSuccess: () => void;
|
25
|
+
onError: (error: string | Error) => void;
|
26
|
+
logOut: () => void;
|
27
|
+
}
|
28
|
+
| {
|
29
|
+
type: "new";
|
30
|
+
creationProps: { name: string };
|
31
|
+
initialSecret?: AgentSecret;
|
32
|
+
saveCredentials: (credentials: Credentials) => Promise<void>;
|
33
|
+
onSuccess: () => void;
|
34
|
+
onError: (error: string | Error) => void;
|
35
|
+
logOut: () => void;
|
36
|
+
};
|
34
37
|
|
35
38
|
export interface AuthMethod {
|
36
|
-
|
39
|
+
start(crypto: CryptoProvider): Promise<AuthResult>;
|
37
40
|
}
|
38
41
|
|
39
42
|
export const fixedCredentialsAuth = (credentials: {
|
40
|
-
|
41
|
-
|
43
|
+
accountID: ID<Account>;
|
44
|
+
secret: AgentSecret;
|
42
45
|
}): AuthMethod => {
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
}
|
46
|
+
return {
|
47
|
+
start: async () => ({
|
48
|
+
type: "existing",
|
49
|
+
credentials,
|
50
|
+
saveCredentials: async () => {},
|
51
|
+
onSuccess: () => {},
|
52
|
+
onError: () => {},
|
53
|
+
logOut: () => {},
|
54
|
+
}),
|
55
|
+
};
|
52
56
|
};
|
53
57
|
|
54
58
|
export const ephemeralCredentialsAuth = (): AuthMethod => {
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
59
|
+
return {
|
60
|
+
start: async () => ({
|
61
|
+
type: "new",
|
62
|
+
creationProps: { name: "Ephemeral" },
|
63
|
+
saveCredentials: async () => {},
|
64
|
+
onSuccess: () => {},
|
65
|
+
onError: () => {},
|
66
|
+
logOut: () => {},
|
67
|
+
}),
|
68
|
+
};
|
65
69
|
};
|
66
70
|
|
67
71
|
export async function randomSessionProvider(
|
68
|
-
|
69
|
-
|
72
|
+
accountID: ID<Account>,
|
73
|
+
crypto: CryptoProvider,
|
70
74
|
) {
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
sessionDone: () => {},
|
76
|
-
};
|
75
|
+
return {
|
76
|
+
sessionID: crypto.newRandomSessionID(accountID as unknown as RawAccountID),
|
77
|
+
sessionDone: () => {},
|
78
|
+
};
|
77
79
|
}
|
78
80
|
|
79
81
|
type ContextParamsWithAuth<Acc extends Account> = {
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
82
|
+
AccountSchema?: AccountClass<Acc>;
|
83
|
+
auth: AuthMethod;
|
84
|
+
sessionProvider: (
|
85
|
+
accountID: ID<Account>,
|
86
|
+
crypto: CryptoProvider,
|
87
|
+
) => Promise<{ sessionID: SessionID; sessionDone: () => void }>;
|
86
88
|
} & BaseContextParams;
|
87
89
|
|
88
90
|
type BaseContextParams = {
|
89
|
-
|
90
|
-
|
91
|
+
peersToLoadFrom: Peer[];
|
92
|
+
crypto: CryptoProvider;
|
91
93
|
};
|
92
94
|
|
93
95
|
export type JazzContextWithAccount<Acc extends Account> = {
|
94
|
-
|
95
|
-
|
96
|
-
|
96
|
+
account: Acc;
|
97
|
+
done: () => void;
|
98
|
+
logOut: () => void;
|
97
99
|
};
|
98
100
|
|
99
101
|
export type JazzContextWithAgent = {
|
100
|
-
|
101
|
-
|
102
|
-
|
102
|
+
agent: AnonymousJazzAgent;
|
103
|
+
done: () => void;
|
104
|
+
logOut: () => void;
|
103
105
|
};
|
104
106
|
|
105
107
|
export type JazzContext<Acc extends Account> =
|
106
|
-
|
107
|
-
|
108
|
+
| JazzContextWithAccount<Acc>
|
109
|
+
| JazzContextWithAgent;
|
108
110
|
|
109
111
|
export async function createJazzContext<Acc extends Account>({
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
112
|
+
AccountSchema,
|
113
|
+
auth,
|
114
|
+
sessionProvider,
|
115
|
+
peersToLoadFrom,
|
116
|
+
crypto,
|
115
117
|
}: ContextParamsWithAuth<Acc>): Promise<JazzContextWithAccount<Acc>>;
|
116
118
|
export async function createJazzContext({
|
117
|
-
|
118
|
-
|
119
|
+
peersToLoadFrom,
|
120
|
+
crypto,
|
119
121
|
}: BaseContextParams): Promise<JazzContextWithAgent>;
|
120
122
|
export async function createJazzContext<Acc extends Account>(
|
121
|
-
|
123
|
+
options: ContextParamsWithAuth<Acc> | BaseContextParams,
|
122
124
|
): Promise<JazzContext<Acc>>;
|
123
125
|
export async function createJazzContext<Acc extends Account>(
|
124
|
-
|
126
|
+
options: ContextParamsWithAuth<Acc> | BaseContextParams,
|
125
127
|
): Promise<JazzContext<Acc>> {
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
128
|
+
// eslint-disable-next-line no-constant-condition
|
129
|
+
while (true) {
|
130
|
+
if (!("auth" in options)) {
|
131
|
+
return createAnonymousJazzContext({
|
132
|
+
peersToLoadFrom: options.peersToLoadFrom,
|
133
|
+
crypto: options.crypto,
|
134
|
+
});
|
135
|
+
}
|
136
|
+
|
137
|
+
const { auth, sessionProvider, peersToLoadFrom, crypto } = options;
|
138
|
+
const AccountSchema =
|
139
|
+
options.AccountSchema ?? (Account as unknown as AccountClass<Acc>);
|
140
|
+
let authResult: AuthResult;
|
141
|
+
try {
|
142
|
+
authResult = await auth.start(crypto);
|
143
|
+
} catch (e) {
|
144
|
+
console.error("error", e);
|
145
|
+
throw e;
|
146
|
+
}
|
147
|
+
|
148
|
+
if (authResult.type === "existing") {
|
149
|
+
try {
|
150
|
+
const { sessionID, sessionDone } = await sessionProvider(
|
151
|
+
authResult.credentials.accountID,
|
152
|
+
crypto,
|
153
|
+
);
|
134
154
|
|
135
|
-
const { auth, sessionProvider, peersToLoadFrom, crypto } = options;
|
136
|
-
const AccountSchema =
|
137
|
-
options.AccountSchema ?? (Account as unknown as AccountClass<Acc>);
|
138
|
-
let authResult: AuthResult;
|
139
155
|
try {
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
156
|
+
const node = await LocalNode.withLoadedAccount({
|
157
|
+
accountID: authResult.credentials
|
158
|
+
.accountID as unknown as CoID<RawAccount>,
|
159
|
+
accountSecret: authResult.credentials.secret,
|
160
|
+
sessionID: sessionID,
|
161
|
+
peersToLoadFrom: peersToLoadFrom,
|
162
|
+
crypto: crypto,
|
163
|
+
migration: async (rawAccount, _node, creationProps) => {
|
164
|
+
const account = new AccountSchema({
|
165
|
+
fromRaw: rawAccount,
|
166
|
+
}) as Acc;
|
145
167
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
authResult.credentials.accountID,
|
150
|
-
crypto,
|
151
|
-
);
|
168
|
+
await account.migrate?.(creationProps);
|
169
|
+
},
|
170
|
+
});
|
152
171
|
|
153
|
-
|
154
|
-
const node = await LocalNode.withLoadedAccount({
|
155
|
-
accountID: authResult.credentials
|
156
|
-
.accountID as unknown as CoID<RawAccount>,
|
157
|
-
accountSecret: authResult.credentials.secret,
|
158
|
-
sessionID: sessionID,
|
159
|
-
peersToLoadFrom: peersToLoadFrom,
|
160
|
-
crypto: crypto,
|
161
|
-
migration: async (rawAccount, _node, creationProps) => {
|
162
|
-
const account = new AccountSchema({
|
163
|
-
fromRaw: rawAccount,
|
164
|
-
}) as Acc;
|
172
|
+
const account = AccountSchema.fromNode(node);
|
165
173
|
|
166
|
-
|
167
|
-
|
168
|
-
|
174
|
+
if (authResult.saveCredentials) {
|
175
|
+
await authResult.saveCredentials({
|
176
|
+
accountID: node.account.id as unknown as ID<Account>,
|
177
|
+
secret: node.account.agentSecret,
|
178
|
+
});
|
179
|
+
}
|
169
180
|
|
170
|
-
|
171
|
-
authResult.onSuccess();
|
181
|
+
authResult.onSuccess();
|
172
182
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
fromRaw: rawAccount,
|
207
|
-
}) as Acc;
|
183
|
+
return {
|
184
|
+
account,
|
185
|
+
done: () => {
|
186
|
+
node.gracefulShutdown();
|
187
|
+
sessionDone();
|
188
|
+
},
|
189
|
+
logOut: () => {
|
190
|
+
node.gracefulShutdown();
|
191
|
+
sessionDone();
|
192
|
+
authResult.logOut();
|
193
|
+
},
|
194
|
+
};
|
195
|
+
} catch (e) {
|
196
|
+
authResult.onError(new Error("Error loading account", { cause: e }));
|
197
|
+
sessionDone();
|
198
|
+
}
|
199
|
+
} catch (e) {
|
200
|
+
authResult.onError(
|
201
|
+
new Error("Error acquiring sessionID", { cause: e }),
|
202
|
+
);
|
203
|
+
}
|
204
|
+
} else if (authResult.type === "new") {
|
205
|
+
try {
|
206
|
+
// TODO: figure out a way to not "waste" the first SessionID
|
207
|
+
const { node } = await LocalNode.withNewlyCreatedAccount({
|
208
|
+
creationProps: authResult.creationProps,
|
209
|
+
peersToLoadFrom: peersToLoadFrom,
|
210
|
+
crypto: crypto,
|
211
|
+
initialAgentSecret: authResult.initialSecret,
|
212
|
+
migration: async (rawAccount, _node, creationProps) => {
|
213
|
+
const account = new AccountSchema({
|
214
|
+
fromRaw: rawAccount,
|
215
|
+
}) as Acc;
|
208
216
|
|
209
|
-
|
210
|
-
|
211
|
-
|
217
|
+
await account.migrate?.(creationProps);
|
218
|
+
},
|
219
|
+
});
|
212
220
|
|
213
|
-
|
221
|
+
const account = AccountSchema.fromNode(node);
|
214
222
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
223
|
+
await authResult.saveCredentials({
|
224
|
+
accountID: node.account.id as unknown as ID<Account>,
|
225
|
+
secret: node.account.agentSecret,
|
226
|
+
});
|
219
227
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
);
|
235
|
-
}
|
236
|
-
}
|
228
|
+
authResult.onSuccess();
|
229
|
+
return {
|
230
|
+
account,
|
231
|
+
done: () => {
|
232
|
+
node.gracefulShutdown();
|
233
|
+
},
|
234
|
+
logOut: () => {
|
235
|
+
node.gracefulShutdown();
|
236
|
+
authResult.logOut();
|
237
|
+
},
|
238
|
+
};
|
239
|
+
} catch (e) {
|
240
|
+
authResult.onError(new Error("Error creating account", { cause: e }));
|
241
|
+
}
|
237
242
|
}
|
243
|
+
}
|
238
244
|
}
|
239
245
|
|
240
246
|
export class AnonymousJazzAgent {
|
241
|
-
|
242
|
-
|
247
|
+
_type = "Anonymous" as const;
|
248
|
+
constructor(public node: LocalNode) {}
|
243
249
|
}
|
244
250
|
|
245
251
|
export async function createAnonymousJazzContext({
|
246
|
-
|
247
|
-
|
252
|
+
peersToLoadFrom,
|
253
|
+
crypto,
|
248
254
|
}: {
|
249
|
-
|
250
|
-
|
255
|
+
peersToLoadFrom: Peer[];
|
256
|
+
crypto: CryptoProvider;
|
251
257
|
}): Promise<JazzContextWithAgent> {
|
252
|
-
|
253
|
-
|
258
|
+
const agentSecret = crypto.newRandomAgentSecret();
|
259
|
+
const rawAgent = new ControlledAgent(agentSecret, crypto);
|
254
260
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
261
|
+
const node = new LocalNode(
|
262
|
+
rawAgent,
|
263
|
+
crypto.newRandomSessionID(rawAgent.id),
|
264
|
+
crypto,
|
265
|
+
);
|
260
266
|
|
261
|
-
|
262
|
-
|
263
|
-
|
267
|
+
for (const peer of peersToLoadFrom) {
|
268
|
+
node.syncManager.addPeer(peer);
|
269
|
+
}
|
264
270
|
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
271
|
+
return {
|
272
|
+
agent: new AnonymousJazzAgent(node),
|
273
|
+
done: () => {},
|
274
|
+
logOut: () => {},
|
275
|
+
};
|
270
276
|
}
|
@@ -3,109 +3,89 @@
|
|
3
3
|
import { ItemsSym } from "./symbols.js";
|
4
4
|
|
5
5
|
(globalThis as any).devtoolsFormatters = [
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
{
|
7
|
+
header: (object: any) => {
|
8
|
+
if (object._type === "CoMap") {
|
9
|
+
return ["div", {}, ["span", {}, object.constructor.name]];
|
10
|
+
} else if (object._type === "CoList") {
|
11
|
+
return [
|
12
|
+
"div",
|
13
|
+
{},
|
14
|
+
["span", {}, object.constructor.name + "(" + object.length + ") "],
|
15
|
+
];
|
16
|
+
} else if (object._type === "Account") {
|
17
|
+
return [
|
18
|
+
"div",
|
19
|
+
{},
|
20
|
+
[
|
21
|
+
"span",
|
22
|
+
{},
|
23
|
+
object.constructor.name +
|
24
|
+
"(" +
|
25
|
+
object._refs.profile.value?.name +
|
26
|
+
(object.isMe ? " ME" : "") +
|
27
|
+
")",
|
28
|
+
],
|
29
|
+
];
|
30
|
+
} else {
|
31
|
+
return null;
|
32
|
+
}
|
33
|
+
},
|
34
|
+
hasBody: function () {
|
35
|
+
return true;
|
36
|
+
},
|
37
|
+
body: function (object: any) {
|
38
|
+
if (object._type === "CoMap" || object._type === "Account") {
|
39
|
+
return [
|
40
|
+
"div",
|
41
|
+
{ style: "margin-left: 15px" },
|
42
|
+
["div", "id: ", ["object", { object: object.id }]],
|
43
|
+
...Object.entries(object).map(([k, v]) => [
|
44
|
+
"div",
|
45
|
+
{ style: "white-space: nowrap;" },
|
46
|
+
["span", { style: "font-weight: bold; opacity: 0.6" }, k, ": "],
|
47
|
+
["object", { object: v }],
|
48
|
+
...(typeof object._schema[k] === "function"
|
49
|
+
? v === null
|
50
|
+
? [
|
14
51
|
[
|
15
|
-
|
16
|
-
|
17
|
-
|
52
|
+
"span",
|
53
|
+
{ style: "opacity: 0.5" },
|
54
|
+
` (pending ${object._schema[k].name} `,
|
55
|
+
["object", { object: object._refs[k] }],
|
56
|
+
")",
|
18
57
|
],
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
58
|
+
]
|
59
|
+
: []
|
60
|
+
: []),
|
61
|
+
]),
|
62
|
+
];
|
63
|
+
} else if (object._type === "CoList") {
|
64
|
+
return [
|
65
|
+
"div",
|
66
|
+
{ style: "margin-left: 15px" },
|
67
|
+
["div", "id: ", ["object", { object: object.id }]],
|
68
|
+
...(object as any[]).map((v, i) => [
|
69
|
+
"div",
|
70
|
+
{ style: "white-space: nowrap;" },
|
71
|
+
["span", { style: "font-weight: bold; opacity: 0.6" }, i, ": "],
|
72
|
+
["object", { object: v }],
|
73
|
+
...(typeof object._schema[ItemsSym] === "function"
|
74
|
+
? v === null
|
75
|
+
? [
|
24
76
|
[
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
(object.isMe ? " ME" : "") +
|
31
|
-
")",
|
77
|
+
"span",
|
78
|
+
{ style: "opacity: 0.5" },
|
79
|
+
` (pending ${object._schema[ItemsSym].name} `,
|
80
|
+
["object", { object: object._refs[i] }],
|
81
|
+
")",
|
32
82
|
],
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
return true;
|
40
|
-
},
|
41
|
-
body: function (object: any) {
|
42
|
-
if (object._type === "CoMap" || object._type === "Account") {
|
43
|
-
return [
|
44
|
-
"div",
|
45
|
-
{ style: "margin-left: 15px" },
|
46
|
-
["div", "id: ", ["object", { object: object.id }]],
|
47
|
-
...Object.entries(object).map(([k, v]) => [
|
48
|
-
"div",
|
49
|
-
{ style: "white-space: nowrap;" },
|
50
|
-
[
|
51
|
-
"span",
|
52
|
-
{ style: "font-weight: bold; opacity: 0.6" },
|
53
|
-
k,
|
54
|
-
": ",
|
55
|
-
],
|
56
|
-
["object", { object: v }],
|
57
|
-
...(typeof object._schema[k] === "function"
|
58
|
-
? v === null
|
59
|
-
? [
|
60
|
-
[
|
61
|
-
"span",
|
62
|
-
{ style: "opacity: 0.5" },
|
63
|
-
` (pending ${object._schema[k].name} `,
|
64
|
-
[
|
65
|
-
"object",
|
66
|
-
{ object: object._refs[k] },
|
67
|
-
],
|
68
|
-
")",
|
69
|
-
],
|
70
|
-
]
|
71
|
-
: []
|
72
|
-
: []),
|
73
|
-
]),
|
74
|
-
];
|
75
|
-
} else if (object._type === "CoList") {
|
76
|
-
return [
|
77
|
-
"div",
|
78
|
-
{ style: "margin-left: 15px" },
|
79
|
-
["div", "id: ", ["object", { object: object.id }]],
|
80
|
-
...(object as any[]).map((v, i) => [
|
81
|
-
"div",
|
82
|
-
{ style: "white-space: nowrap;" },
|
83
|
-
[
|
84
|
-
"span",
|
85
|
-
{ style: "font-weight: bold; opacity: 0.6" },
|
86
|
-
i,
|
87
|
-
": ",
|
88
|
-
],
|
89
|
-
["object", { object: v }],
|
90
|
-
...(typeof object._schema[ItemsSym] === "function"
|
91
|
-
? v === null
|
92
|
-
? [
|
93
|
-
[
|
94
|
-
"span",
|
95
|
-
{ style: "opacity: 0.5" },
|
96
|
-
` (pending ${object._schema[ItemsSym].name} `,
|
97
|
-
[
|
98
|
-
"object",
|
99
|
-
{ object: object._refs[i] },
|
100
|
-
],
|
101
|
-
")",
|
102
|
-
],
|
103
|
-
]
|
104
|
-
: []
|
105
|
-
: []),
|
106
|
-
]),
|
107
|
-
];
|
108
|
-
}
|
109
|
-
},
|
83
|
+
]
|
84
|
+
: []
|
85
|
+
: []),
|
86
|
+
]),
|
87
|
+
];
|
88
|
+
}
|
110
89
|
},
|
90
|
+
},
|
111
91
|
];
|