@dxos/plugin-space 0.8.4-main.72ec0f3 → 0.8.4-main.7ace549
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/dist/lib/browser/{ObjectDetailsPanel-2BRUBHP6.mjs → ObjectDetailsPanel-ACGHWPDX.mjs} +2 -2
- package/dist/lib/browser/{ObjectDetailsPanel-2BRUBHP6.mjs.map → ObjectDetailsPanel-ACGHWPDX.mjs.map} +3 -3
- package/dist/lib/browser/{ObjectSettings-5LLWCVEK.mjs → ObjectSettings-U3IH7BMV.mjs} +2 -2
- package/dist/lib/browser/{ObjectSettings-5LLWCVEK.mjs.map → ObjectSettings-U3IH7BMV.mjs.map} +3 -3
- package/dist/lib/browser/{RecordArticle-SXDRWTTU.mjs → RecordArticle-2PFEBPXY.mjs} +1 -1
- package/dist/lib/browser/RecordArticle-2PFEBPXY.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-VQAB3GCQ.mjs → app-graph-builder-HABMCWAI.mjs} +140 -151
- package/dist/lib/browser/app-graph-builder-HABMCWAI.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-serializer-KSLKMEPP.mjs → app-graph-serializer-G3VFEGTN.mjs} +4 -4
- package/dist/lib/browser/chunk-6A3NWBB6.mjs +392 -0
- package/dist/lib/browser/chunk-6A3NWBB6.mjs.map +7 -0
- package/dist/lib/browser/{chunk-K5J7ZB5P.mjs → chunk-C6DAPIFF.mjs} +3 -3
- package/dist/lib/browser/chunk-C6DAPIFF.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ERQMHU7L.mjs → chunk-GJOZILGC.mjs} +163 -105
- package/dist/lib/browser/chunk-GJOZILGC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-J2BUK5E6.mjs → chunk-KCZ527AM.mjs} +169 -101
- package/dist/lib/browser/chunk-KCZ527AM.mjs.map +7 -0
- package/dist/lib/browser/{chunk-PU5IOFMG.mjs → chunk-P25R3AOK.mjs} +4 -47
- package/dist/lib/browser/{chunk-PU5IOFMG.mjs.map → chunk-P25R3AOK.mjs.map} +4 -4
- package/dist/lib/browser/{chunk-OLBBSOVI.mjs → chunk-POFUXISV.mjs} +53 -59
- package/dist/lib/browser/chunk-POFUXISV.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +47 -94
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-Q2XWHAVA.mjs → intent-resolver-RZEWNJ2K.mjs} +51 -40
- package/dist/lib/browser/intent-resolver-RZEWNJ2K.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-root-MM4HADPE.mjs → react-root-JCRD74GI.mjs} +6 -6
- package/dist/lib/browser/{react-surface-SGZC3Y4U.mjs → react-surface-VOETEAG3.mjs} +28 -14
- package/dist/lib/browser/react-surface-VOETEAG3.mjs.map +7 -0
- package/dist/lib/browser/repair-CNLE35NF.mjs +44 -0
- package/dist/lib/browser/repair-CNLE35NF.mjs.map +7 -0
- package/dist/lib/browser/{settings-WKLGKUHQ.mjs → settings-TRLI52I5.mjs} +2 -2
- package/dist/lib/browser/{spaces-ready-C5QC2UFL.mjs → spaces-ready-OHGCWZHQ.mjs} +13 -7
- package/dist/lib/browser/{spaces-ready-C5QC2UFL.mjs.map → spaces-ready-OHGCWZHQ.mjs.map} +2 -2
- package/dist/lib/browser/{state-Q7YRE5KG.mjs → state-C7N6EDDZ.mjs} +2 -2
- package/dist/lib/browser/types/index.mjs +9 -3
- package/dist/lib/node-esm/{ObjectDetailsPanel-6PZQIQG3.mjs → ObjectDetailsPanel-6OFTT3GG.mjs} +2 -2
- package/dist/lib/node-esm/{ObjectDetailsPanel-6PZQIQG3.mjs.map → ObjectDetailsPanel-6OFTT3GG.mjs.map} +3 -3
- package/dist/lib/node-esm/{ObjectSettings-OQSBOH7K.mjs → ObjectSettings-YXPJQMJ5.mjs} +2 -2
- package/dist/lib/node-esm/{ObjectSettings-OQSBOH7K.mjs.map → ObjectSettings-YXPJQMJ5.mjs.map} +3 -3
- package/dist/lib/node-esm/{RecordArticle-NACBH42P.mjs → RecordArticle-SSJ7PULS.mjs} +1 -1
- package/dist/lib/node-esm/RecordArticle-SSJ7PULS.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-24JCLJPX.mjs → app-graph-builder-T6VJKIOA.mjs} +140 -151
- package/dist/lib/node-esm/app-graph-builder-T6VJKIOA.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-serializer-R723K764.mjs → app-graph-serializer-2NLWWFUB.mjs} +4 -4
- package/dist/lib/node-esm/{chunk-TJPQDQNI.mjs → chunk-7EV4SN47.mjs} +4 -47
- package/dist/lib/node-esm/{chunk-TJPQDQNI.mjs.map → chunk-7EV4SN47.mjs.map} +4 -4
- package/dist/lib/node-esm/{chunk-WC4VBFMA.mjs → chunk-AX3UGL5D.mjs} +53 -59
- package/dist/lib/node-esm/chunk-AX3UGL5D.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-VH2EBZEV.mjs → chunk-I6FZP42D.mjs} +163 -105
- package/dist/lib/node-esm/chunk-I6FZP42D.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ITQFSFQ3.mjs → chunk-JAMGJUFU.mjs} +169 -101
- package/dist/lib/node-esm/chunk-JAMGJUFU.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-Z7BB6HC2.mjs → chunk-WWGV5FJM.mjs} +3 -3
- package/dist/lib/node-esm/chunk-WWGV5FJM.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-X34VDVMY.mjs +393 -0
- package/dist/lib/node-esm/chunk-X34VDVMY.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +47 -94
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-YK4ESSET.mjs → intent-resolver-4PHJWDXW.mjs} +51 -40
- package/dist/lib/node-esm/intent-resolver-4PHJWDXW.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-root-5ANDLQMX.mjs → react-root-O5I5CDJ7.mjs} +6 -6
- package/dist/lib/node-esm/{react-surface-V7J2QB44.mjs → react-surface-J3XDMU2D.mjs} +28 -14
- package/dist/lib/node-esm/react-surface-J3XDMU2D.mjs.map +7 -0
- package/dist/lib/node-esm/repair-EHZS6MFY.mjs +45 -0
- package/dist/lib/node-esm/repair-EHZS6MFY.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-RBB5633M.mjs → settings-MNQTKHL7.mjs} +2 -2
- package/dist/lib/node-esm/{spaces-ready-SJCXV6YH.mjs → spaces-ready-ZPU24DA2.mjs} +13 -7
- package/dist/lib/node-esm/{spaces-ready-SJCXV6YH.mjs.map → spaces-ready-ZPU24DA2.mjs.map} +2 -2
- package/dist/lib/node-esm/{state-362I5BMK.mjs → state-45TXZQJ6.mjs} +2 -2
- package/dist/lib/node-esm/types/index.mjs +9 -3
- package/dist/types/src/SpacePlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +9 -4
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/repair.d.ts +4 -0
- package/dist/types/src/capabilities/repair.d.ts.map +1 -0
- package/dist/types/src/capabilities/spaces-ready.d.ts.map +1 -1
- package/dist/types/src/components/CreateDialog/CreateObjectDialog.d.ts.map +1 -1
- package/dist/types/src/components/CreateDialog/CreateObjectDialog.stories.d.ts +147 -253
- package/dist/types/src/components/CreateDialog/CreateObjectDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/CreateDialog/CreateObjectPanel.d.ts +14 -7
- package/dist/types/src/components/CreateDialog/CreateObjectPanel.d.ts.map +1 -1
- package/dist/types/src/components/MembersContainer/MembersContainer.stories.d.ts +147 -253
- package/dist/types/src/components/MembersContainer/MembersContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/ObjectSettings/AdvancedObjectSettings.d.ts.map +1 -1
- package/dist/types/src/components/ObjectSettings/BaseObjectSettings.stories.d.ts +147 -253
- package/dist/types/src/components/ObjectSettings/BaseObjectSettings.stories.d.ts.map +1 -1
- package/dist/types/src/components/ObjectSettings/ForeignKeys.d.ts +3 -3
- package/dist/types/src/components/ObjectSettings/ForeignKeys.d.ts.map +1 -1
- package/dist/types/src/components/RecordArticle.stories.d.ts +147 -253
- package/dist/types/src/components/RecordArticle.stories.d.ts.map +1 -1
- package/dist/types/src/components/SchemaContainer.d.ts +1 -1
- package/dist/types/src/components/SchemaContainer.d.ts.map +1 -1
- package/dist/types/src/components/SpacePresence/SpacePresence.d.ts +2 -2
- package/dist/types/src/components/SpacePresence/SpacePresence.d.ts.map +1 -1
- package/dist/types/src/components/SpacePresence/SpacePresence.stories.d.ts +147 -253
- package/dist/types/src/components/SpacePresence/SpacePresence.stories.d.ts.map +1 -1
- package/dist/types/src/components/SpaceSettings/SpaceSettingsContainer.d.ts.map +1 -1
- package/dist/types/src/components/SpaceSettings/SpaceSettingsContainer.stories.d.ts +147 -253
- package/dist/types/src/components/SpaceSettings/SpaceSettingsContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/SyncStatus/SyncStatus.stories.d.ts +147 -253
- package/dist/types/src/components/SyncStatus/SyncStatus.stories.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/helpers/query.d.ts +1 -1
- package/dist/types/src/helpers/query.d.ts.map +1 -1
- package/dist/types/src/hooks/useTypeOptions.d.ts +2 -2
- package/dist/types/src/hooks/useTypeOptions.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +147 -253
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/form.d.ts +24 -0
- package/dist/types/src/types/form.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +29 -72
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +16 -32
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +54 -50
- package/src/SpacePlugin.ts +34 -84
- package/src/capabilities/app-graph-builder.ts +130 -227
- package/src/capabilities/capabilities.ts +10 -5
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/intent-resolver.ts +31 -35
- package/src/capabilities/react-surface.tsx +34 -8
- package/src/capabilities/repair.ts +57 -0
- package/src/capabilities/spaces-ready.ts +7 -1
- package/src/components/CreateDialog/CreateObjectDialog.tsx +33 -23
- package/src/components/CreateDialog/CreateObjectPanel.tsx +32 -25
- package/src/components/ObjectDetailsPanel/ObjectForm.tsx +1 -1
- package/src/components/ObjectSettings/AdvancedObjectSettings.tsx +4 -5
- package/src/components/ObjectSettings/BaseObjectSettings.tsx +1 -1
- package/src/components/ObjectSettings/ForeignKeys.tsx +5 -5
- package/src/components/RecordArticle.tsx +6 -6
- package/src/components/SchemaContainer.tsx +2 -2
- package/src/components/SpacePresence/SpacePresence.tsx +2 -2
- package/src/components/SpaceSettings/SpaceSettingsContainer.tsx +25 -6
- package/src/components/ViewEditor.tsx +9 -3
- package/src/helpers/query.ts +1 -1
- package/src/hooks/useTypeOptions.ts +3 -35
- package/src/translations.ts +52 -57
- package/src/types/form.ts +75 -0
- package/src/types/index.ts +1 -0
- package/src/types/types.ts +26 -36
- package/src/util.tsx +165 -107
- package/dist/lib/browser/RecordArticle-SXDRWTTU.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-VQAB3GCQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-ERQMHU7L.mjs.map +0 -7
- package/dist/lib/browser/chunk-J2BUK5E6.mjs.map +0 -7
- package/dist/lib/browser/chunk-K5J7ZB5P.mjs.map +0 -7
- package/dist/lib/browser/chunk-M2Z6D4ZI.mjs +0 -349
- package/dist/lib/browser/chunk-M2Z6D4ZI.mjs.map +0 -7
- package/dist/lib/browser/chunk-OLBBSOVI.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-Q2XWHAVA.mjs.map +0 -7
- package/dist/lib/browser/react-surface-SGZC3Y4U.mjs.map +0 -7
- package/dist/lib/browser/schema-defs-QPI2JU3X.mjs +0 -26
- package/dist/lib/browser/schema-defs-QPI2JU3X.mjs.map +0 -7
- package/dist/lib/node-esm/RecordArticle-NACBH42P.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-24JCLJPX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2PN7QNGV.mjs +0 -350
- package/dist/lib/node-esm/chunk-2PN7QNGV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ITQFSFQ3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VH2EBZEV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WC4VBFMA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Z7BB6HC2.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-YK4ESSET.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-V7J2QB44.mjs.map +0 -7
- package/dist/lib/node-esm/schema-defs-ZS2D47XW.mjs +0 -27
- package/dist/lib/node-esm/schema-defs-ZS2D47XW.mjs.map +0 -7
- package/dist/types/src/capabilities/schema-defs.d.ts +0 -4
- package/dist/types/src/capabilities/schema-defs.d.ts.map +0 -1
- package/src/capabilities/schema-defs.ts +0 -31
- /package/dist/lib/browser/{app-graph-serializer-KSLKMEPP.mjs.map → app-graph-serializer-G3VFEGTN.mjs.map} +0 -0
- /package/dist/lib/browser/{react-root-MM4HADPE.mjs.map → react-root-JCRD74GI.mjs.map} +0 -0
- /package/dist/lib/browser/{settings-WKLGKUHQ.mjs.map → settings-TRLI52I5.mjs.map} +0 -0
- /package/dist/lib/browser/{state-Q7YRE5KG.mjs.map → state-C7N6EDDZ.mjs.map} +0 -0
- /package/dist/lib/node-esm/{app-graph-serializer-R723K764.mjs.map → app-graph-serializer-2NLWWFUB.mjs.map} +0 -0
- /package/dist/lib/node-esm/{react-root-5ANDLQMX.mjs.map → react-root-O5I5CDJ7.mjs.map} +0 -0
- /package/dist/lib/node-esm/{settings-RBB5633M.mjs.map → settings-MNQTKHL7.mjs.map} +0 -0
- /package/dist/lib/node-esm/{state-362I5BMK.mjs.map → state-45TXZQJ6.mjs.map} +0 -0
|
@@ -9,13 +9,13 @@ import * as Option from 'effect/Option';
|
|
|
9
9
|
import * as Schema from 'effect/Schema';
|
|
10
10
|
|
|
11
11
|
import { Capabilities, type PluginContext, contributes, createIntent } from '@dxos/app-framework';
|
|
12
|
-
import { type
|
|
13
|
-
import { DXN, Filter, Obj,
|
|
12
|
+
import { type Space, SpaceState, getSpace, isSpace } from '@dxos/client/echo';
|
|
13
|
+
import { DXN, type Database, type Entity, Filter, Obj, Type } from '@dxos/echo';
|
|
14
14
|
import { log } from '@dxos/log';
|
|
15
15
|
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
16
16
|
import { ATTENDABLE_PATH_SEPARATOR, PLANK_COMPANION_TYPE } from '@dxos/plugin-deck/types';
|
|
17
17
|
import { ROOT_ID, atomFromObservable, atomFromSignal, createExtension } from '@dxos/plugin-graph';
|
|
18
|
-
import { Collection,
|
|
18
|
+
import { Collection, View, ViewAnnotation, getTypenameFromQuery } from '@dxos/schema';
|
|
19
19
|
import { isNonNullable } from '@dxos/util';
|
|
20
20
|
|
|
21
21
|
import { getActiveSpace } from '../hooks';
|
|
@@ -168,14 +168,14 @@ export default (context: PluginContext) => {
|
|
|
168
168
|
Option.getOrElse(() => []),
|
|
169
169
|
),
|
|
170
170
|
),
|
|
171
|
-
// resolver: ({ id }) => (id === SPACES ? spacesNode : undefined),
|
|
172
171
|
}),
|
|
173
172
|
|
|
174
173
|
// Create space nodes.
|
|
175
174
|
createExtension({
|
|
176
175
|
id: SPACES,
|
|
177
176
|
connector: (node) => {
|
|
178
|
-
|
|
177
|
+
// TODO(wittjosiah): Find a simpler way to define this type.
|
|
178
|
+
let query: Database.QueryResult<Schema.Schema.Type<typeof Type.Expando>> | undefined;
|
|
179
179
|
return Atom.make((get) =>
|
|
180
180
|
Function.pipe(
|
|
181
181
|
get(node),
|
|
@@ -235,46 +235,6 @@ export default (context: PluginContext) => {
|
|
|
235
235
|
),
|
|
236
236
|
);
|
|
237
237
|
},
|
|
238
|
-
// resolver: ({ id }) => {
|
|
239
|
-
// if (id.length !== SPACE_ID_LENGTH) {
|
|
240
|
-
// return;
|
|
241
|
-
// }
|
|
242
|
-
|
|
243
|
-
// const client = context.requestCapability(ClientCapabilities.Client);
|
|
244
|
-
// const spaces = toSignal(
|
|
245
|
-
// (onChange) => client.spaces.subscribe(() => onChange()).unsubscribe,
|
|
246
|
-
// () => client.spaces.get(),
|
|
247
|
-
// );
|
|
248
|
-
|
|
249
|
-
// const isReady = toSignal(
|
|
250
|
-
// (onChange) => client.spaces.isReady.subscribe(() => onChange()).unsubscribe,
|
|
251
|
-
// () => client.spaces.isReady.get(),
|
|
252
|
-
// );
|
|
253
|
-
|
|
254
|
-
// if (!spaces || !isReady) {
|
|
255
|
-
// return;
|
|
256
|
-
// }
|
|
257
|
-
|
|
258
|
-
// const space = spaces.find((space) => space.id === id);
|
|
259
|
-
// if (!space) {
|
|
260
|
-
// return;
|
|
261
|
-
// }
|
|
262
|
-
|
|
263
|
-
// if (space.state.get() === SpaceState.SPACE_INACTIVE) {
|
|
264
|
-
// return false;
|
|
265
|
-
// } else if (space.state.get() !== SpaceState.SPACE_READY) {
|
|
266
|
-
// return undefined;
|
|
267
|
-
// } else {
|
|
268
|
-
// const state = context.requestCapability(SpaceCapabilities.State);
|
|
269
|
-
// return constructSpaceNode({
|
|
270
|
-
// space,
|
|
271
|
-
// navigable: state.navigableCollections,
|
|
272
|
-
// personal: space === client.spaces.default,
|
|
273
|
-
// namesCache: state.spaceNames,
|
|
274
|
-
// resolve,
|
|
275
|
-
// });
|
|
276
|
-
// }
|
|
277
|
-
// },
|
|
278
238
|
}),
|
|
279
239
|
|
|
280
240
|
// Create space actions.
|
|
@@ -359,7 +319,7 @@ export default (context: PluginContext) => {
|
|
|
359
319
|
),
|
|
360
320
|
}),
|
|
361
321
|
|
|
362
|
-
// Create nodes for objects in a collection or by its
|
|
322
|
+
// Create nodes for objects in a collection or by its DXN.
|
|
363
323
|
createExtension({
|
|
364
324
|
id: `${meta.id}/objects`,
|
|
365
325
|
connector: (node) =>
|
|
@@ -397,95 +357,68 @@ export default (context: PluginContext) => {
|
|
|
397
357
|
Option.getOrElse(() => []),
|
|
398
358
|
),
|
|
399
359
|
),
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
// if (!object) {
|
|
427
|
-
// return;
|
|
428
|
-
// }
|
|
429
|
-
|
|
430
|
-
// if (isDeleted(object)) {
|
|
431
|
-
// return false;
|
|
432
|
-
// } else {
|
|
433
|
-
// const state = context.requestCapability(SpaceCapabilities.State);
|
|
434
|
-
// return createObjectNode({ object, space, resolve, navigable: state.navigableCollections });
|
|
435
|
-
// }
|
|
436
|
-
// },
|
|
360
|
+
resolver: (id) => {
|
|
361
|
+
let query: Database.QueryResult<Entity.Unknown> | undefined;
|
|
362
|
+
return Atom.make((get) => {
|
|
363
|
+
const client = context.getCapability(ClientCapabilities.Client);
|
|
364
|
+
const dxn = DXN.tryParse(id)?.asEchoDXN();
|
|
365
|
+
if (!dxn || !dxn.spaceId) {
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const space = client.spaces.get(dxn.spaceId);
|
|
370
|
+
if (!space) {
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (!query) {
|
|
375
|
+
query = space.db.query(Filter.ids(dxn.echoId));
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const object = get(atomFromQuery(query)).at(0);
|
|
379
|
+
if (!Obj.isObject(object)) {
|
|
380
|
+
return null;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
return createObjectNode({ object, space, resolve: resolve(get), disposition: 'hidden' });
|
|
384
|
+
});
|
|
385
|
+
},
|
|
437
386
|
}),
|
|
438
387
|
|
|
439
|
-
// Create nodes for
|
|
388
|
+
// Create object nodes for schema-based system collections.
|
|
440
389
|
createExtension({
|
|
441
|
-
id: `${meta.id}/
|
|
390
|
+
id: `${meta.id}/system-collections`,
|
|
442
391
|
connector: (node) => {
|
|
443
|
-
|
|
392
|
+
const client = context.getCapability(ClientCapabilities.Client);
|
|
393
|
+
// TODO(wittjosiah): Find a simpler way to define this type.
|
|
394
|
+
let query: Database.QueryResult<Schema.Schema.Type<typeof Type.Expando>> | undefined;
|
|
444
395
|
return Atom.make((get) =>
|
|
445
396
|
Function.pipe(
|
|
446
397
|
get(node),
|
|
447
398
|
Option.flatMap((node) =>
|
|
448
|
-
Obj.instanceOf(Collection.
|
|
399
|
+
Obj.instanceOf(Collection.Managed, node.data) ? Option.some(node.data) : Option.none(),
|
|
449
400
|
),
|
|
450
401
|
Option.flatMap((collection) => {
|
|
451
402
|
const space = getSpace(collection);
|
|
452
|
-
const
|
|
453
|
-
|
|
403
|
+
const schema = client.graph.schemaRegistry.schemas.find(
|
|
404
|
+
(schema) => Type.getTypename(schema) === collection.key,
|
|
405
|
+
);
|
|
406
|
+
return space && schema ? Option.some({ space, schema }) : Option.none();
|
|
454
407
|
}),
|
|
455
|
-
Option.map(({
|
|
456
|
-
const state = context.getCapability(SpaceCapabilities.State);
|
|
408
|
+
Option.map(({ space, schema }) => {
|
|
457
409
|
if (!query) {
|
|
458
|
-
query = space.db.query(
|
|
459
|
-
Query.without(
|
|
460
|
-
Query.select(Filter.typename(typename)),
|
|
461
|
-
// TODO(wittjosiah): This query is broader than it should be.
|
|
462
|
-
// It will return all objects in the collection, not just the ones of the given type.
|
|
463
|
-
// However this works fine for now because this query is only used for exclusions.
|
|
464
|
-
Query.select(Filter.typename(typename))
|
|
465
|
-
.referencedBy(Collection.Collection, 'objects')
|
|
466
|
-
.reference('objects'),
|
|
467
|
-
),
|
|
468
|
-
);
|
|
410
|
+
query = space.db.query(Filter.type(schema));
|
|
469
411
|
}
|
|
470
|
-
return (
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
resolve: resolve(get),
|
|
481
|
-
droppable: false, // Cannot rearrange query collections.
|
|
482
|
-
navigable: state.navigableCollections,
|
|
483
|
-
}),
|
|
484
|
-
),
|
|
485
|
-
),
|
|
486
|
-
)
|
|
487
|
-
.filter(isNonNullable)
|
|
488
|
-
);
|
|
412
|
+
return get(atomFromQuery(query))
|
|
413
|
+
.map((object) =>
|
|
414
|
+
createObjectNode({
|
|
415
|
+
object,
|
|
416
|
+
space,
|
|
417
|
+
managedCollectionChild: true,
|
|
418
|
+
resolve: resolve(get),
|
|
419
|
+
}),
|
|
420
|
+
)
|
|
421
|
+
.filter(isNonNullable);
|
|
489
422
|
}),
|
|
490
423
|
Option.getOrElse(() => []),
|
|
491
424
|
),
|
|
@@ -493,7 +426,7 @@ export default (context: PluginContext) => {
|
|
|
493
426
|
},
|
|
494
427
|
}),
|
|
495
428
|
|
|
496
|
-
//
|
|
429
|
+
// Create branch nodes for static schema record types.
|
|
497
430
|
createExtension({
|
|
498
431
|
id: `${meta.id}/static-schemas`,
|
|
499
432
|
connector: (node) => {
|
|
@@ -502,8 +435,7 @@ export default (context: PluginContext) => {
|
|
|
502
435
|
Function.pipe(
|
|
503
436
|
get(node),
|
|
504
437
|
Option.flatMap((node) =>
|
|
505
|
-
Obj.instanceOf(Collection.
|
|
506
|
-
getTypenameFromQuery(node.data.query) === StoredSchema.typename
|
|
438
|
+
Obj.instanceOf(Collection.Managed, node.data) && node.data.key === Type.getTypename(Type.PersistentType)
|
|
507
439
|
? Option.some(node.data)
|
|
508
440
|
: Option.none(),
|
|
509
441
|
),
|
|
@@ -525,13 +457,19 @@ export default (context: PluginContext) => {
|
|
|
525
457
|
},
|
|
526
458
|
}),
|
|
527
459
|
|
|
528
|
-
// Create static schema
|
|
460
|
+
// Create actions for static schema record types.
|
|
529
461
|
createExtension({
|
|
530
462
|
id: `${meta.id}/static-schema-actions`,
|
|
531
463
|
actions: (node) => {
|
|
532
|
-
let query: QueryResult<
|
|
533
|
-
return Atom.make((get) =>
|
|
534
|
-
|
|
464
|
+
let query: Database.QueryResult<Obj.Any> | undefined;
|
|
465
|
+
return Atom.make((get) => {
|
|
466
|
+
// TODO(wittjosiah): Use schemaRegistry query once it support atom reactivity.
|
|
467
|
+
const schemas = get(context.capabilities(ClientCapabilities.Schema))
|
|
468
|
+
.flat()
|
|
469
|
+
.filter((schema) => ViewAnnotation.get(schema).pipe(Option.getOrElse(() => false)));
|
|
470
|
+
const filter = Filter.or(...schemas.map((schema) => Filter.type(schema)));
|
|
471
|
+
|
|
472
|
+
return Function.pipe(
|
|
535
473
|
get(node),
|
|
536
474
|
Option.flatMap((node) => {
|
|
537
475
|
const space = isSpace(node.properties.space) ? node.properties.space : undefined;
|
|
@@ -539,16 +477,18 @@ export default (context: PluginContext) => {
|
|
|
539
477
|
}),
|
|
540
478
|
Option.map(({ space, schema }) => {
|
|
541
479
|
if (!query) {
|
|
542
|
-
// TODO(wittjosiah):
|
|
543
|
-
|
|
480
|
+
// TODO(wittjosiah): Ideally this query would traverse the view reference & filter by the query ast.
|
|
481
|
+
// TODO(wittjosiah): Remove cast.
|
|
482
|
+
query = space.db.query(filter) as unknown as Database.QueryResult<Obj.Any>;
|
|
544
483
|
}
|
|
545
484
|
|
|
546
|
-
const
|
|
485
|
+
const objects = get(atomFromQuery(query));
|
|
547
486
|
const filteredViews = get(
|
|
548
487
|
atomFromSignal(() =>
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
488
|
+
objects.filter(
|
|
489
|
+
(viewObject) =>
|
|
490
|
+
getTypenameFromQuery((viewObject as any).view.target?.query.ast) ===
|
|
491
|
+
Type.getTypename(schema as Type.Obj.Any),
|
|
552
492
|
),
|
|
553
493
|
),
|
|
554
494
|
);
|
|
@@ -568,103 +508,60 @@ export default (context: PluginContext) => {
|
|
|
568
508
|
});
|
|
569
509
|
}),
|
|
570
510
|
Option.getOrElse(() => []),
|
|
571
|
-
)
|
|
572
|
-
);
|
|
511
|
+
);
|
|
512
|
+
});
|
|
573
513
|
},
|
|
574
514
|
}),
|
|
575
515
|
|
|
576
|
-
// Create nodes for
|
|
516
|
+
// Create nodes for views of record types.
|
|
577
517
|
createExtension({
|
|
578
518
|
id: `${meta.id}/schema-views`,
|
|
579
519
|
connector: (node) => {
|
|
580
|
-
let query: QueryResult<
|
|
581
|
-
return Atom.make((get) =>
|
|
582
|
-
|
|
520
|
+
let query: Database.QueryResult<Obj.Any> | undefined;
|
|
521
|
+
return Atom.make((get) => {
|
|
522
|
+
// TODO(wittjosiah): Use schemaRegistry query once it support atom reactivity.
|
|
523
|
+
const schemas = get(context.capabilities(ClientCapabilities.Schema))
|
|
524
|
+
.flat()
|
|
525
|
+
.filter((schema) => ViewAnnotation.get(schema).pipe(Option.getOrElse(() => false)));
|
|
526
|
+
const filter = Filter.or(...schemas.map((schema) => Filter.type(schema)));
|
|
527
|
+
|
|
528
|
+
return Function.pipe(
|
|
583
529
|
get(node),
|
|
584
530
|
Option.flatMap((node) => {
|
|
585
531
|
const space = getSpace(node.data) ?? (isSpace(node.properties.space) ? node.properties.space : undefined);
|
|
586
|
-
return space && (Obj.instanceOf(
|
|
532
|
+
return space && (Obj.instanceOf(Type.PersistentType, node.data) || Schema.isSchema(node.data))
|
|
587
533
|
? Option.some({ space, schema: node.data })
|
|
588
534
|
: Option.none();
|
|
589
535
|
}),
|
|
590
536
|
Option.map(({ space, schema }) => {
|
|
591
537
|
if (!query) {
|
|
592
|
-
// TODO(wittjosiah):
|
|
593
|
-
|
|
538
|
+
// TODO(wittjosiah): Ideally this query would traverse the view reference & filter by the query ast.
|
|
539
|
+
// TODO(wittjosiah): Remove cast.
|
|
540
|
+
query = space.db.query(filter) as unknown as Database.QueryResult<Obj.Any>;
|
|
594
541
|
}
|
|
595
542
|
|
|
596
|
-
// TODO(wittjosiah): Remove
|
|
543
|
+
// TODO(wittjosiah): Remove casts.
|
|
597
544
|
const typename = Schema.isSchema(schema) ? Type.getTypename(schema as Type.Obj.Any) : schema.typename;
|
|
598
|
-
return (
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
return false;
|
|
611
|
-
}
|
|
545
|
+
return get(atomFromQuery(query))
|
|
546
|
+
.filter((object) =>
|
|
547
|
+
get(atomFromSignal(() => getTypenameFromQuery((object as any).view.target?.query.ast) === typename)),
|
|
548
|
+
)
|
|
549
|
+
.map((object) =>
|
|
550
|
+
get(
|
|
551
|
+
atomFromSignal(() =>
|
|
552
|
+
createObjectNode({
|
|
553
|
+
object,
|
|
554
|
+
space,
|
|
555
|
+
resolve: resolve(get),
|
|
556
|
+
droppable: false,
|
|
612
557
|
}),
|
|
613
558
|
),
|
|
614
|
-
)
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
atomFromSignal(() =>
|
|
618
|
-
createObjectNode({
|
|
619
|
-
object: view,
|
|
620
|
-
space,
|
|
621
|
-
resolve: resolve(get),
|
|
622
|
-
droppable: false,
|
|
623
|
-
}),
|
|
624
|
-
),
|
|
625
|
-
),
|
|
626
|
-
)
|
|
627
|
-
.filter(isNonNullable)
|
|
628
|
-
);
|
|
559
|
+
),
|
|
560
|
+
)
|
|
561
|
+
.filter(isNonNullable);
|
|
629
562
|
}),
|
|
630
563
|
Option.getOrElse(() => []),
|
|
631
|
-
)
|
|
632
|
-
);
|
|
633
|
-
},
|
|
634
|
-
}),
|
|
635
|
-
|
|
636
|
-
// Create record nodes.
|
|
637
|
-
createExtension({
|
|
638
|
-
id: `${meta.id}/records`,
|
|
639
|
-
resolver: (id) => {
|
|
640
|
-
let query: QueryResult<Type.Expando> | undefined;
|
|
641
|
-
return Atom.make((get) => {
|
|
642
|
-
const client = context.getCapability(ClientCapabilities.Client);
|
|
643
|
-
const dxn = DXN.tryParse(id)?.asEchoDXN();
|
|
644
|
-
if (!dxn || !dxn.spaceId) {
|
|
645
|
-
return null;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
const space = client.spaces.get(dxn.spaceId);
|
|
649
|
-
if (!space) {
|
|
650
|
-
return null;
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
if (!query) {
|
|
654
|
-
query = space.db.query(Filter.ids(dxn.echoId));
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
const object = get(atomFromQuery(query)).at(0);
|
|
658
|
-
if (!object) {
|
|
659
|
-
return null;
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
return createObjectNode({
|
|
663
|
-
object,
|
|
664
|
-
space,
|
|
665
|
-
resolve: resolve(get),
|
|
666
|
-
disposition: 'hidden',
|
|
667
|
-
});
|
|
564
|
+
);
|
|
668
565
|
});
|
|
669
566
|
},
|
|
670
567
|
}),
|
|
@@ -673,9 +570,15 @@ export default (context: PluginContext) => {
|
|
|
673
570
|
createExtension({
|
|
674
571
|
id: `${meta.id}/object-actions`,
|
|
675
572
|
actions: (node) => {
|
|
676
|
-
let query: QueryResult<
|
|
677
|
-
return Atom.make((get) =>
|
|
678
|
-
|
|
573
|
+
let query: Database.QueryResult<Obj.Any> | undefined;
|
|
574
|
+
return Atom.make((get) => {
|
|
575
|
+
// TODO(wittjosiah): Use schemaRegistry query once it support atom reactivity.
|
|
576
|
+
const schemas = get(context.capabilities(ClientCapabilities.Schema))
|
|
577
|
+
.flat()
|
|
578
|
+
.filter((schema) => ViewAnnotation.get(schema).pipe(Option.getOrElse(() => false)));
|
|
579
|
+
const filter = Filter.or(...schemas.map((schema) => Filter.type(schema)));
|
|
580
|
+
|
|
581
|
+
return Function.pipe(
|
|
679
582
|
get(node),
|
|
680
583
|
Option.flatMap((node) => {
|
|
681
584
|
const space = getSpace(node.data);
|
|
@@ -684,24 +587,25 @@ export default (context: PluginContext) => {
|
|
|
684
587
|
: Option.none();
|
|
685
588
|
}),
|
|
686
589
|
Option.flatMap(({ space, object }) => {
|
|
687
|
-
const isSchema = Obj.instanceOf(
|
|
590
|
+
const isSchema = Obj.instanceOf(Type.PersistentType, object);
|
|
688
591
|
if (!query && isSchema) {
|
|
689
|
-
// TODO(wittjosiah):
|
|
690
|
-
|
|
592
|
+
// TODO(wittjosiah): Ideally this query would traverse the view reference & filter by the query ast.
|
|
593
|
+
// TODO(wittjosiah): Remove cast.
|
|
594
|
+
query = space.db.query(filter) as unknown as Database.QueryResult<Obj.Any>;
|
|
691
595
|
}
|
|
692
596
|
|
|
693
597
|
let deletable =
|
|
694
598
|
!isSchema &&
|
|
695
|
-
// Don't allow
|
|
696
|
-
!(
|
|
697
|
-
Obj.instanceOf(Collection.QueryCollection, object) &&
|
|
698
|
-
getTypenameFromQuery(object.query) === StoredSchema.typename
|
|
699
|
-
);
|
|
599
|
+
// Don't allow system collections to be deleted.
|
|
600
|
+
!Obj.instanceOf(Collection.Managed, object);
|
|
700
601
|
if (isSchema && query) {
|
|
701
|
-
const
|
|
602
|
+
const objects = get(atomFromQuery(query));
|
|
702
603
|
const filteredViews = get(
|
|
703
604
|
atomFromSignal(() =>
|
|
704
|
-
|
|
605
|
+
objects.filter(
|
|
606
|
+
(viewObject) =>
|
|
607
|
+
getTypenameFromQuery((viewObject as any).view.target?.query.ast) === object.typename,
|
|
608
|
+
),
|
|
705
609
|
),
|
|
706
610
|
);
|
|
707
611
|
deletable = filteredViews.length === 0;
|
|
@@ -710,7 +614,6 @@ export default (context: PluginContext) => {
|
|
|
710
614
|
const [dispatcher] = get(context.capabilities(Capabilities.IntentDispatcher));
|
|
711
615
|
const [appGraph] = get(context.capabilities(Capabilities.AppGraph));
|
|
712
616
|
const [state] = get(context.capabilities(SpaceCapabilities.State));
|
|
713
|
-
const objectForms = get(context.capabilities(SpaceCapabilities.ObjectForm));
|
|
714
617
|
|
|
715
618
|
if (!dispatcher || !appGraph || !state) {
|
|
716
619
|
return Option.none();
|
|
@@ -719,7 +622,7 @@ export default (context: PluginContext) => {
|
|
|
719
622
|
object,
|
|
720
623
|
graph: appGraph.graph,
|
|
721
624
|
dispatch: dispatcher.dispatchPromise,
|
|
722
|
-
|
|
625
|
+
resolve: resolve(get),
|
|
723
626
|
deletable,
|
|
724
627
|
navigable: get(atomFromSignal(() => state.navigableCollections)),
|
|
725
628
|
});
|
|
@@ -727,8 +630,8 @@ export default (context: PluginContext) => {
|
|
|
727
630
|
}),
|
|
728
631
|
Option.map((params) => constructObjectActions(params)),
|
|
729
632
|
Option.getOrElse(() => []),
|
|
730
|
-
)
|
|
731
|
-
);
|
|
633
|
+
);
|
|
634
|
+
});
|
|
732
635
|
},
|
|
733
636
|
}),
|
|
734
637
|
|
|
@@ -10,7 +10,7 @@ import { type Collection } from '@dxos/schema';
|
|
|
10
10
|
import { type DeepReadonly, type Position } from '@dxos/util';
|
|
11
11
|
|
|
12
12
|
import { meta } from '../meta';
|
|
13
|
-
import { type
|
|
13
|
+
import { type PluginState } from '../types';
|
|
14
14
|
|
|
15
15
|
export namespace SpaceCapabilities {
|
|
16
16
|
export const State = defineCapability<DeepReadonly<PluginState>>(`${meta.id}/capability/state`);
|
|
@@ -19,8 +19,12 @@ export namespace SpaceCapabilities {
|
|
|
19
19
|
export type SettingsSection = { id: string; label: Label; position?: Position };
|
|
20
20
|
export const SettingsSection = defineCapability<SettingsSection>(`${meta.id}/capability/settings-section`);
|
|
21
21
|
|
|
22
|
-
export type
|
|
23
|
-
|
|
22
|
+
export type OnCreateSpace = (params: {
|
|
23
|
+
space: Space;
|
|
24
|
+
isDefault: boolean;
|
|
25
|
+
rootCollection: Collection.Collection;
|
|
26
|
+
}) => AnyIntentChain;
|
|
27
|
+
export const OnCreateSpace = defineCapability<OnCreateSpace>(`${meta.id}/capability/on-space-created`);
|
|
24
28
|
|
|
25
29
|
export type OnSchemaAdded = (params: {
|
|
26
30
|
space: Space;
|
|
@@ -30,6 +34,7 @@ export namespace SpaceCapabilities {
|
|
|
30
34
|
}) => AnyIntentChain;
|
|
31
35
|
export const OnSchemaAdded = defineCapability<OnSchemaAdded>(`${meta.id}/capability/on-schema-added`);
|
|
32
36
|
|
|
33
|
-
// TODO(
|
|
34
|
-
export
|
|
37
|
+
// TODO(wittjosiah): Replace with migrations, this is not a sustainable solution.
|
|
38
|
+
export type HandleRepair = (params: { space: Space; isDefault: boolean }) => Promise<void>;
|
|
39
|
+
export const Repair = defineCapability<HandleRepair>(`${meta.id}/capability/repair`);
|
|
35
40
|
}
|
|
@@ -10,7 +10,7 @@ export const IdentityCreated = lazy(() => import('./identity-created'));
|
|
|
10
10
|
export const IntentResolver = lazy(() => import('./intent-resolver'));
|
|
11
11
|
export const ReactRoot = lazy(() => import('./react-root'));
|
|
12
12
|
export const ReactSurface = lazy(() => import('./react-surface'));
|
|
13
|
-
export const
|
|
13
|
+
export const Repair = lazy(() => import('./repair'));
|
|
14
14
|
export const SpaceSettings = lazy(() => import('./settings'));
|
|
15
15
|
export const SpaceState = lazy(() => import('./state'));
|
|
16
16
|
export const SpacesReady = lazy(() => import('./spaces-ready'));
|