@lobb-js/studio 0.21.0 → 0.22.0

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.
@@ -15,53 +15,36 @@
15
15
 
16
16
  let { collectionName, entry = $bindable(), values = {} }: LocalProp = $props();
17
17
 
18
- const childrenRelations = ctx.meta.relations.filter(
19
- (relation) => relation.to.collection === collectionName,
20
- );
18
+ const fkChildren = (ctx.meta.collections[collectionName]?.children ?? [])
19
+ .filter((c) => c.type === "fk") as { type: "fk"; collection: string; field: string }[];
21
20
 
22
- // filling the children properties
23
- for (let index = 0; index < childrenRelations.length; index++) {
24
- const relation = childrenRelations[index];
25
- const childCollection = relation.from.collection;
26
- entry[childCollection] = [];
27
- if (values[childCollection]) {
28
- entry[childCollection] = [
29
- ...entry[childCollection],
30
- ...values[childCollection],
31
- ];
32
- }
21
+ for (const child of fkChildren) {
22
+ entry[child.collection] = values[child.collection] ? [...values[child.collection]] : [];
33
23
  }
34
24
  </script>
35
25
 
36
- {#if childrenRelations.length}
26
+ {#if fkChildren.length}
37
27
  <div class="flex flex-col gap-4 border-t p-4">
38
28
  <div class="flex items-center gap-2">
39
29
  <Link size="17.5" />
40
30
  <div>Sub Records</div>
41
31
  </div>
42
32
  <div class="flex flex-col gap-4">
43
- {#each childrenRelations as relation}
44
- {@const childCollection = relation.from.collection}
33
+ {#each fkChildren as child}
45
34
  <ExtensionsComponents
46
- name="detailView.create.subRecords.{childCollection}"
35
+ name="detailView.create.subRecords.{child.collection}"
47
36
  utils={getExtensionUtils(lobb, ctx)}
48
37
  parentCollectionName={collectionName}
49
- collectionName={childCollection}
50
- parentRecord={{
51
- id: entry.id,
52
- collectionName: collectionName,
53
- }}
38
+ collectionName={child.collection}
39
+ parentRecord={{ id: entry.id, collectionName }}
54
40
  class="bg-muted/30 border rounded-md overflow-hidden"
55
- bind:value={entry[childCollection]}
41
+ bind:value={entry[child.collection]}
56
42
  >
57
43
  <CreateManyView
58
44
  parentCollectionName={collectionName}
59
- collectionName={childCollection}
60
- parentRecord={{
61
- id: entry.id,
62
- collectionName: collectionName,
63
- }}
64
- bind:entries={entry[childCollection]}
45
+ collectionName={child.collection}
46
+ parentRecord={{ id: entry.id, collectionName }}
47
+ bind:entries={entry[child.collection]}
65
48
  />
66
49
  </ExtensionsComponents>
67
50
  {/each}
@@ -1,10 +1,14 @@
1
1
  <script lang="ts">
2
2
  import DataTable from "../../../components/dataTable/dataTable.svelte";
3
3
  import { getStudioContext } from "../../../context";
4
- import { Link, Plus, TableIcon } from "lucide-svelte";
4
+ import { Link, Plus, TableIcon, Unlink } from "lucide-svelte";
5
5
  import CreateDetailViewButton from "../create/createDetailViewButton.svelte";
6
6
  import ExtensionsComponents from "../../../components/extensionsComponents.svelte";
7
7
  import { getExtensionUtils } from "../../../extensions/extensionUtils";
8
+ import SelectRecord from "../../../components/selectRecord.svelte";
9
+ import { getCollectionColumns } from "../../dataTable/utils";
10
+ import Table from "../../../components/dataTable/table.svelte";
11
+ import Button from "../../../components/ui/button/button.svelte";
8
12
 
9
13
  const { ctx, lobb } = getStudioContext();
10
14
 
@@ -15,67 +19,92 @@
15
19
 
16
20
  let { collectionName, entry }: LocalProp = $props();
17
21
 
18
- const childrenRelations = ctx.meta.relations.filter(
19
- (relation) => relation.to.collection === collectionName,
20
- );
21
- const refresh: boolean[] = $state(
22
- new Array(childrenRelations.length).fill(true),
23
- );
22
+ const allChildren = ctx.meta.collections[collectionName]?.children ?? [];
23
+ const fkChildren = allChildren.filter((c) => c.type === "fk") as { type: "fk"; collection: string; field: string }[];
24
+ const relationalChildren = allChildren.filter((c) => c.type === "m2m" || c.type === "polymorphic") as { type: string; collection: string }[];
25
+
26
+ const fkRefresh: boolean[] = $state(new Array(fkChildren.length).fill(true));
27
+
28
+ let relationalRecords: Record<string, any[]> = $state({});
29
+ let relationalLoading = $state(false);
30
+
31
+ async function fetchRelational() {
32
+ if (!relationalChildren.length || !entry?.id) return;
33
+ relationalLoading = true;
34
+ const childrenParam: Record<string, any> = {};
35
+ for (const child of relationalChildren) {
36
+ childrenParam[child.collection] = { fields: ["*"] };
37
+ }
38
+ const response = await lobb.findAll(collectionName, {
39
+ filter: { id: entry.id },
40
+ limit: 1,
41
+ children: childrenParam,
42
+ });
43
+ const result = await response.json();
44
+ const record = result.data?.[0];
45
+ if (record) {
46
+ for (const child of relationalChildren) {
47
+ relationalRecords[child.collection] = record[child.collection] ?? [];
48
+ }
49
+ }
50
+ relationalLoading = false;
51
+ }
52
+
53
+ async function linkRecord(childCollection: string, selected: any) {
54
+ await lobb.updateOne(collectionName, entry.id, {}, { [childCollection]: { link: [selected.id] } });
55
+ await fetchRelational();
56
+ }
57
+
58
+ async function unlinkRecord(childCollection: string, id: any) {
59
+ await lobb.updateOne(collectionName, entry.id, {}, { [childCollection]: { unlink: [id] } });
60
+ await fetchRelational();
61
+ }
62
+
63
+ $effect(() => {
64
+ fetchRelational();
65
+ });
24
66
  </script>
25
67
 
26
- {#if childrenRelations.length}
68
+ {#if allChildren.length}
27
69
  <div class="flex flex-col gap-4 border-t p-4">
28
70
  <div class="flex items-center gap-2">
29
71
  <Link size="17.5" />
30
72
  <div>Sub Records</div>
31
73
  </div>
32
74
  <div class="flex flex-col gap-4">
33
- {#each childrenRelations as relation, index}
34
- {@const childCollection = relation.from.collection}
35
- {@const childField = relation.from.field}
75
+
76
+ <!-- FK children -->
77
+ {#each fkChildren as child, index}
36
78
  <ExtensionsComponents
37
- name="detailView.update.subRecords.{childCollection}"
79
+ name="detailView.update.subRecords.{child.collection}"
38
80
  utils={getExtensionUtils(lobb, ctx)}
39
- collectionName={childCollection}
40
- filter={{
41
- [childField]: entry.id,
42
- }}
81
+ collectionName={child.collection}
82
+ filter={{ [child.field]: entry.id }}
43
83
  class="bg-muted/30 border rounded-md overflow-hidden"
44
84
  >
45
85
  <div class="border rounded-md overflow-clip">
46
- <div
47
- class="flex items-center justify-between px-2 h-10 bg-muted/30 border-b"
48
- >
86
+ <div class="flex items-center justify-between px-2 h-10 bg-muted/30 border-b">
49
87
  <div class="flex-1 flex h-full items-center gap-2">
50
- <TableIcon
51
- class="text-muted-foreground"
52
- size="17.5"
53
- />
54
- <div class="text-sm text-muted-foreground">
55
- {childCollection}
56
- </div>
88
+ <TableIcon class="text-muted-foreground" size="17.5" />
89
+ <div class="text-sm text-muted-foreground">{child.collection}</div>
57
90
  </div>
58
91
  <div class="flex gap-2">
59
92
  <CreateDetailViewButton
60
93
  variant="ghost"
61
94
  class="h-7 px-2 font-normal text-xs"
62
95
  Icon={Plus}
63
- collectionName={childCollection}
64
- onSuccessfullSave={async () => {
65
- refresh[index] = !refresh[index];
66
- }}
96
+ collectionName={child.collection}
97
+ onSuccessfullSave={async () => { fkRefresh[index] = !fkRefresh[index]; }}
67
98
  >
68
99
  Create
69
100
  </CreateDetailViewButton>
70
101
  </div>
71
102
  </div>
72
103
  <div class="max-h-72 overflow-auto rounded-md">
73
- {#key refresh[index]}
104
+ {#key fkRefresh[index]}
74
105
  <DataTable
75
- collectionName={childCollection}
76
- filter={{
77
- [childField]: entry.id,
78
- }}
106
+ collectionName={child.collection}
107
+ filter={{ [child.field]: entry.id }}
79
108
  unifiedBgColor="bg-muted/30"
80
109
  showHeader={false}
81
110
  showFooter={false}
@@ -91,6 +120,64 @@
91
120
  </div>
92
121
  </ExtensionsComponents>
93
122
  {/each}
123
+
124
+ <!-- M2M and polymorphic children -->
125
+ {#each relationalChildren as child}
126
+ {@const columns = getCollectionColumns(ctx, child.collection)}
127
+ {@const linkedIds = new Set((relationalRecords[child.collection] ?? []).map((r: any) => String(r.id)))}
128
+ <div class="border rounded-md overflow-clip">
129
+ <div class="flex items-center justify-between px-2 h-10 bg-muted/30 border-b">
130
+ <div class="flex-1 flex h-full items-center gap-2">
131
+ <TableIcon class="text-muted-foreground" size="17.5" />
132
+ <div class="text-sm text-muted-foreground">{child.collection}</div>
133
+ </div>
134
+ <div class="flex gap-2">
135
+ <CreateDetailViewButton
136
+ variant="ghost"
137
+ class="h-7 px-2 font-normal text-xs"
138
+ Icon={Plus}
139
+ collectionName={child.collection}
140
+ onSuccessfullSave={async (newEntry) => { await linkRecord(child.collection, newEntry); }}
141
+ >
142
+ Create & link
143
+ </CreateDetailViewButton>
144
+ <SelectRecord
145
+ collectionName={child.collection}
146
+ text="Link existing"
147
+ onSelect={(selected) => linkRecord(child.collection, selected)}
148
+ filter={{ id: { $nin: [...linkedIds] } }}
149
+ variant="ghost"
150
+ class="h-7 px-2 font-normal text-xs"
151
+ />
152
+ </div>
153
+ </div>
154
+ <div class="max-h-72 overflow-auto bg-muted/30">
155
+ {#if relationalLoading}
156
+ <div class="p-4 text-sm text-muted-foreground">Loading...</div>
157
+ {:else}
158
+ <Table
159
+ data={relationalRecords[child.collection] ?? []}
160
+ {columns}
161
+ unifiedBgColor="bg-muted/30"
162
+ showLastRowBorder={false}
163
+ showLastColumnBorder={false}
164
+ showCheckboxes={false}
165
+ >
166
+ {#snippet tools(record, _index)}
167
+ <Button
168
+ class="h-6 w-6 text-muted-foreground hover:bg-transparent"
169
+ variant="ghost"
170
+ size="icon"
171
+ onclick={() => unlinkRecord(child.collection, record.id)}
172
+ Icon={Unlink}
173
+ />
174
+ {/snippet}
175
+ </Table>
176
+ {/if}
177
+ </div>
178
+ </div>
179
+ {/each}
180
+
94
181
  </div>
95
182
  </div>
96
183
  {/if}
@@ -5,12 +5,25 @@ interface CollectionTab {
5
5
  filter?: Record<string, any>;
6
6
  default?: boolean;
7
7
  }
8
+ type CollectionChild = {
9
+ type: "fk";
10
+ collection: string;
11
+ field: string;
12
+ } | {
13
+ type: "m2m";
14
+ collection: string;
15
+ } | {
16
+ type: "polymorphic";
17
+ collection: string;
18
+ };
8
19
  interface Collection {
9
20
  category: string;
10
21
  owner: string;
11
22
  fields: Record<string, any>;
12
23
  singleton: boolean;
13
24
  virtual?: boolean;
25
+ junction?: boolean;
26
+ children?: CollectionChild[];
14
27
  ui?: {
15
28
  icon?: string;
16
29
  tabs?: CollectionTab[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lobb-js/studio",
3
3
  "license": "UNLICENSED",
4
- "version": "0.21.0",
4
+ "version": "0.22.0",
5
5
  "type": "module",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -42,7 +42,7 @@
42
42
  "postpublish": "./scripts/postpublish.sh"
43
43
  },
44
44
  "devDependencies": {
45
- "@lobb-js/core": "^0.25.0",
45
+ "@lobb-js/core": "^0.26.0",
46
46
  "@chromatic-com/storybook": "^4.1.2",
47
47
  "@storybook/addon-a11y": "^10.0.1",
48
48
  "@storybook/addon-docs": "^10.0.1",
@@ -15,53 +15,36 @@
15
15
 
16
16
  let { collectionName, entry = $bindable(), values = {} }: LocalProp = $props();
17
17
 
18
- const childrenRelations = ctx.meta.relations.filter(
19
- (relation) => relation.to.collection === collectionName,
20
- );
18
+ const fkChildren = (ctx.meta.collections[collectionName]?.children ?? [])
19
+ .filter((c) => c.type === "fk") as { type: "fk"; collection: string; field: string }[];
21
20
 
22
- // filling the children properties
23
- for (let index = 0; index < childrenRelations.length; index++) {
24
- const relation = childrenRelations[index];
25
- const childCollection = relation.from.collection;
26
- entry[childCollection] = [];
27
- if (values[childCollection]) {
28
- entry[childCollection] = [
29
- ...entry[childCollection],
30
- ...values[childCollection],
31
- ];
32
- }
21
+ for (const child of fkChildren) {
22
+ entry[child.collection] = values[child.collection] ? [...values[child.collection]] : [];
33
23
  }
34
24
  </script>
35
25
 
36
- {#if childrenRelations.length}
26
+ {#if fkChildren.length}
37
27
  <div class="flex flex-col gap-4 border-t p-4">
38
28
  <div class="flex items-center gap-2">
39
29
  <Link size="17.5" />
40
30
  <div>Sub Records</div>
41
31
  </div>
42
32
  <div class="flex flex-col gap-4">
43
- {#each childrenRelations as relation}
44
- {@const childCollection = relation.from.collection}
33
+ {#each fkChildren as child}
45
34
  <ExtensionsComponents
46
- name="detailView.create.subRecords.{childCollection}"
35
+ name="detailView.create.subRecords.{child.collection}"
47
36
  utils={getExtensionUtils(lobb, ctx)}
48
37
  parentCollectionName={collectionName}
49
- collectionName={childCollection}
50
- parentRecord={{
51
- id: entry.id,
52
- collectionName: collectionName,
53
- }}
38
+ collectionName={child.collection}
39
+ parentRecord={{ id: entry.id, collectionName }}
54
40
  class="bg-muted/30 border rounded-md overflow-hidden"
55
- bind:value={entry[childCollection]}
41
+ bind:value={entry[child.collection]}
56
42
  >
57
43
  <CreateManyView
58
44
  parentCollectionName={collectionName}
59
- collectionName={childCollection}
60
- parentRecord={{
61
- id: entry.id,
62
- collectionName: collectionName,
63
- }}
64
- bind:entries={entry[childCollection]}
45
+ collectionName={child.collection}
46
+ parentRecord={{ id: entry.id, collectionName }}
47
+ bind:entries={entry[child.collection]}
65
48
  />
66
49
  </ExtensionsComponents>
67
50
  {/each}
@@ -1,10 +1,14 @@
1
1
  <script lang="ts">
2
2
  import DataTable from "../../../components/dataTable/dataTable.svelte";
3
3
  import { getStudioContext } from "../../../context";
4
- import { Link, Plus, TableIcon } from "lucide-svelte";
4
+ import { Link, Plus, TableIcon, Unlink } from "lucide-svelte";
5
5
  import CreateDetailViewButton from "../create/createDetailViewButton.svelte";
6
6
  import ExtensionsComponents from "../../../components/extensionsComponents.svelte";
7
7
  import { getExtensionUtils } from "../../../extensions/extensionUtils";
8
+ import SelectRecord from "../../../components/selectRecord.svelte";
9
+ import { getCollectionColumns } from "../../dataTable/utils";
10
+ import Table from "../../../components/dataTable/table.svelte";
11
+ import Button from "../../../components/ui/button/button.svelte";
8
12
 
9
13
  const { ctx, lobb } = getStudioContext();
10
14
 
@@ -15,67 +19,92 @@
15
19
 
16
20
  let { collectionName, entry }: LocalProp = $props();
17
21
 
18
- const childrenRelations = ctx.meta.relations.filter(
19
- (relation) => relation.to.collection === collectionName,
20
- );
21
- const refresh: boolean[] = $state(
22
- new Array(childrenRelations.length).fill(true),
23
- );
22
+ const allChildren = ctx.meta.collections[collectionName]?.children ?? [];
23
+ const fkChildren = allChildren.filter((c) => c.type === "fk") as { type: "fk"; collection: string; field: string }[];
24
+ const relationalChildren = allChildren.filter((c) => c.type === "m2m" || c.type === "polymorphic") as { type: string; collection: string }[];
25
+
26
+ const fkRefresh: boolean[] = $state(new Array(fkChildren.length).fill(true));
27
+
28
+ let relationalRecords: Record<string, any[]> = $state({});
29
+ let relationalLoading = $state(false);
30
+
31
+ async function fetchRelational() {
32
+ if (!relationalChildren.length || !entry?.id) return;
33
+ relationalLoading = true;
34
+ const childrenParam: Record<string, any> = {};
35
+ for (const child of relationalChildren) {
36
+ childrenParam[child.collection] = { fields: ["*"] };
37
+ }
38
+ const response = await lobb.findAll(collectionName, {
39
+ filter: { id: entry.id },
40
+ limit: 1,
41
+ children: childrenParam,
42
+ });
43
+ const result = await response.json();
44
+ const record = result.data?.[0];
45
+ if (record) {
46
+ for (const child of relationalChildren) {
47
+ relationalRecords[child.collection] = record[child.collection] ?? [];
48
+ }
49
+ }
50
+ relationalLoading = false;
51
+ }
52
+
53
+ async function linkRecord(childCollection: string, selected: any) {
54
+ await lobb.updateOne(collectionName, entry.id, {}, { [childCollection]: { link: [selected.id] } });
55
+ await fetchRelational();
56
+ }
57
+
58
+ async function unlinkRecord(childCollection: string, id: any) {
59
+ await lobb.updateOne(collectionName, entry.id, {}, { [childCollection]: { unlink: [id] } });
60
+ await fetchRelational();
61
+ }
62
+
63
+ $effect(() => {
64
+ fetchRelational();
65
+ });
24
66
  </script>
25
67
 
26
- {#if childrenRelations.length}
68
+ {#if allChildren.length}
27
69
  <div class="flex flex-col gap-4 border-t p-4">
28
70
  <div class="flex items-center gap-2">
29
71
  <Link size="17.5" />
30
72
  <div>Sub Records</div>
31
73
  </div>
32
74
  <div class="flex flex-col gap-4">
33
- {#each childrenRelations as relation, index}
34
- {@const childCollection = relation.from.collection}
35
- {@const childField = relation.from.field}
75
+
76
+ <!-- FK children -->
77
+ {#each fkChildren as child, index}
36
78
  <ExtensionsComponents
37
- name="detailView.update.subRecords.{childCollection}"
79
+ name="detailView.update.subRecords.{child.collection}"
38
80
  utils={getExtensionUtils(lobb, ctx)}
39
- collectionName={childCollection}
40
- filter={{
41
- [childField]: entry.id,
42
- }}
81
+ collectionName={child.collection}
82
+ filter={{ [child.field]: entry.id }}
43
83
  class="bg-muted/30 border rounded-md overflow-hidden"
44
84
  >
45
85
  <div class="border rounded-md overflow-clip">
46
- <div
47
- class="flex items-center justify-between px-2 h-10 bg-muted/30 border-b"
48
- >
86
+ <div class="flex items-center justify-between px-2 h-10 bg-muted/30 border-b">
49
87
  <div class="flex-1 flex h-full items-center gap-2">
50
- <TableIcon
51
- class="text-muted-foreground"
52
- size="17.5"
53
- />
54
- <div class="text-sm text-muted-foreground">
55
- {childCollection}
56
- </div>
88
+ <TableIcon class="text-muted-foreground" size="17.5" />
89
+ <div class="text-sm text-muted-foreground">{child.collection}</div>
57
90
  </div>
58
91
  <div class="flex gap-2">
59
92
  <CreateDetailViewButton
60
93
  variant="ghost"
61
94
  class="h-7 px-2 font-normal text-xs"
62
95
  Icon={Plus}
63
- collectionName={childCollection}
64
- onSuccessfullSave={async () => {
65
- refresh[index] = !refresh[index];
66
- }}
96
+ collectionName={child.collection}
97
+ onSuccessfullSave={async () => { fkRefresh[index] = !fkRefresh[index]; }}
67
98
  >
68
99
  Create
69
100
  </CreateDetailViewButton>
70
101
  </div>
71
102
  </div>
72
103
  <div class="max-h-72 overflow-auto rounded-md">
73
- {#key refresh[index]}
104
+ {#key fkRefresh[index]}
74
105
  <DataTable
75
- collectionName={childCollection}
76
- filter={{
77
- [childField]: entry.id,
78
- }}
106
+ collectionName={child.collection}
107
+ filter={{ [child.field]: entry.id }}
79
108
  unifiedBgColor="bg-muted/30"
80
109
  showHeader={false}
81
110
  showFooter={false}
@@ -91,6 +120,64 @@
91
120
  </div>
92
121
  </ExtensionsComponents>
93
122
  {/each}
123
+
124
+ <!-- M2M and polymorphic children -->
125
+ {#each relationalChildren as child}
126
+ {@const columns = getCollectionColumns(ctx, child.collection)}
127
+ {@const linkedIds = new Set((relationalRecords[child.collection] ?? []).map((r: any) => String(r.id)))}
128
+ <div class="border rounded-md overflow-clip">
129
+ <div class="flex items-center justify-between px-2 h-10 bg-muted/30 border-b">
130
+ <div class="flex-1 flex h-full items-center gap-2">
131
+ <TableIcon class="text-muted-foreground" size="17.5" />
132
+ <div class="text-sm text-muted-foreground">{child.collection}</div>
133
+ </div>
134
+ <div class="flex gap-2">
135
+ <CreateDetailViewButton
136
+ variant="ghost"
137
+ class="h-7 px-2 font-normal text-xs"
138
+ Icon={Plus}
139
+ collectionName={child.collection}
140
+ onSuccessfullSave={async (newEntry) => { await linkRecord(child.collection, newEntry); }}
141
+ >
142
+ Create & link
143
+ </CreateDetailViewButton>
144
+ <SelectRecord
145
+ collectionName={child.collection}
146
+ text="Link existing"
147
+ onSelect={(selected) => linkRecord(child.collection, selected)}
148
+ filter={{ id: { $nin: [...linkedIds] } }}
149
+ variant="ghost"
150
+ class="h-7 px-2 font-normal text-xs"
151
+ />
152
+ </div>
153
+ </div>
154
+ <div class="max-h-72 overflow-auto bg-muted/30">
155
+ {#if relationalLoading}
156
+ <div class="p-4 text-sm text-muted-foreground">Loading...</div>
157
+ {:else}
158
+ <Table
159
+ data={relationalRecords[child.collection] ?? []}
160
+ {columns}
161
+ unifiedBgColor="bg-muted/30"
162
+ showLastRowBorder={false}
163
+ showLastColumnBorder={false}
164
+ showCheckboxes={false}
165
+ >
166
+ {#snippet tools(record, _index)}
167
+ <Button
168
+ class="h-6 w-6 text-muted-foreground hover:bg-transparent"
169
+ variant="ghost"
170
+ size="icon"
171
+ onclick={() => unlinkRecord(child.collection, record.id)}
172
+ Icon={Unlink}
173
+ />
174
+ {/snippet}
175
+ </Table>
176
+ {/if}
177
+ </div>
178
+ </div>
179
+ {/each}
180
+
94
181
  </div>
95
182
  </div>
96
183
  {/if}
@@ -7,12 +7,19 @@ interface CollectionTab {
7
7
  default?: boolean;
8
8
  }
9
9
 
10
+ type CollectionChild =
11
+ | { type: "fk"; collection: string; field: string }
12
+ | { type: "m2m"; collection: string }
13
+ | { type: "polymorphic"; collection: string };
14
+
10
15
  interface Collection {
11
16
  category: string;
12
17
  owner: string;
13
18
  fields: Record<string, any>;
14
19
  singleton: boolean;
15
20
  virtual?: boolean;
21
+ junction?: boolean;
22
+ children?: CollectionChild[];
16
23
  ui?: {
17
24
  icon?: string;
18
25
  tabs?: CollectionTab[];