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