inicontent 1.0.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.
- package/.github/pull_request.yml +18 -0
- package/CONTRIBUTING.md +67 -0
- package/LICENSE +21 -0
- package/README.md +142 -0
- package/app/app.vue +106 -0
- package/app/assets/main.css +974 -0
- package/app/components/Api/EndpointCard.vue +169 -0
- package/app/components/Api/SchemaDocsTable.vue +208 -0
- package/app/components/Asset/Card.vue +1363 -0
- package/app/components/Asset/Grid.vue +295 -0
- package/app/components/Asset/Icon.vue +38 -0
- package/app/components/Asset/Preview.vue +486 -0
- package/app/components/Asset/Scanner.vue +700 -0
- package/app/components/Asset/Thumb.vue +708 -0
- package/app/components/Auth/Reset.vue +99 -0
- package/app/components/Auth/index.vue +346 -0
- package/app/components/ChatInterface.vue +2326 -0
- package/app/components/ChatPagePreview.vue +34 -0
- package/app/components/Column/Array.vue +29 -0
- package/app/components/Column/Asset.vue +21 -0
- package/app/components/Column/Boolean.vue +12 -0
- package/app/components/Column/Color.vue +9 -0
- package/app/components/Column/Date.vue +57 -0
- package/app/components/Column/Edit.vue +215 -0
- package/app/components/Column/Email.vue +9 -0
- package/app/components/Column/Html.vue +27 -0
- package/app/components/Column/Id.vue +20 -0
- package/app/components/Column/Locale.vue +32 -0
- package/app/components/Column/Object.vue +18 -0
- package/app/components/Column/Password.vue +7 -0
- package/app/components/Column/Role.vue +15 -0
- package/app/components/Column/S.vue +14 -0
- package/app/components/Column/Table/Single.vue +49 -0
- package/app/components/Column/Table/index.vue +42 -0
- package/app/components/Column/Tags.vue +31 -0
- package/app/components/Column/Text.vue +9 -0
- package/app/components/Column/Url.vue +9 -0
- package/app/components/Column/index.vue +41 -0
- package/app/components/Dashboard/Editor.vue +221 -0
- package/app/components/Dashboard/Grid.vue +270 -0
- package/app/components/Dashboard/View.vue +131 -0
- package/app/components/Dashboard/Widget/BarChart.vue +73 -0
- package/app/components/Dashboard/Widget/Counter.vue +51 -0
- package/app/components/Dashboard/Widget/LineChart.vue +76 -0
- package/app/components/Dashboard/Widget/PieChart.vue +75 -0
- package/app/components/Dashboard/Widget/Table.vue +94 -0
- package/app/components/Dashboard/WidgetEditor.vue +274 -0
- package/app/components/Data/Array.vue +102 -0
- package/app/components/Data/Html.vue +9 -0
- package/app/components/Data/Icon.vue +9 -0
- package/app/components/Data/Object.vue +10 -0
- package/app/components/Data/S.vue +16 -0
- package/app/components/Data/Table.vue +53 -0
- package/app/components/Data/Value.vue +34 -0
- package/app/components/Data/index.vue +14 -0
- package/app/components/Field/Array.vue +324 -0
- package/app/components/Field/Asset/Actions.vue +97 -0
- package/app/components/Field/Asset/index.vue +639 -0
- package/app/components/Field/Boolean.vue +26 -0
- package/app/components/Field/Checkbox.vue +48 -0
- package/app/components/Field/Color.vue +27 -0
- package/app/components/Field/Date.vue +30 -0
- package/app/components/Field/Email.vue +51 -0
- package/app/components/Field/EmailTemplate.vue +420 -0
- package/app/components/Field/Html/ColorPicker.vue +127 -0
- package/app/components/Field/Html/Editor.vue +544 -0
- package/app/components/Field/Html/index.vue +25 -0
- package/app/components/Field/Icon.vue +114 -0
- package/app/components/Field/JSON.vue +113 -0
- package/app/components/Field/Mention.vue +36 -0
- package/app/components/Field/Number.vue +27 -0
- package/app/components/Field/Object.vue +92 -0
- package/app/components/Field/Password.vue +55 -0
- package/app/components/Field/Radio.vue +47 -0
- package/app/components/Field/S.vue +44 -0
- package/app/components/Field/Select.vue +49 -0
- package/app/components/Field/Table.vue +348 -0
- package/app/components/Field/Tags.vue +113 -0
- package/app/components/Field/Text.vue +31 -0
- package/app/components/Field/Textarea.vue +33 -0
- package/app/components/Field/Url.vue +40 -0
- package/app/components/Field/Wrapper.vue +128 -0
- package/app/components/Field/index.vue +68 -0
- package/app/components/FloatingChatbot.vue +73 -0
- package/app/components/Form/Card.vue +151 -0
- package/app/components/Form/Drawer.vue +195 -0
- package/app/components/Form/index.vue +621 -0
- package/app/components/Header.vue +328 -0
- package/app/components/Offline/ConflictModal.vue +200 -0
- package/app/components/Offline/SyncStatus.vue +249 -0
- package/app/components/PlatformFeatureLanding.vue +65 -0
- package/app/components/Table/Backups.vue +638 -0
- package/app/components/Table/Flows.vue +814 -0
- package/app/components/Table/Grid.vue +296 -0
- package/app/components/Table/Icon.vue +36 -0
- package/app/components/Table/Logs.vue +181 -0
- package/app/components/Table/Schedules.vue +722 -0
- package/app/components/Table/Search/Button.vue +256 -0
- package/app/components/Table/Search/Items.vue +286 -0
- package/app/components/Table/Search/index.vue +87 -0
- package/app/components/Table/Settings/Schema.vue +801 -0
- package/app/components/Table/Settings/index.vue +631 -0
- package/app/components/Table/TranslateDrawer.vue +526 -0
- package/app/components/Table/Views/Kanban.vue +289 -0
- package/app/components/Table/Views/Table.vue +1273 -0
- package/app/components/Table/index.vue +890 -0
- package/app/composables/Translation/define.ts +41 -0
- package/app/composables/Translation/fetch.ts +107 -0
- package/app/composables/Translation/languages.ts +1 -0
- package/app/composables/Translation/loadCoreTranslations.ts +38 -0
- package/app/composables/Translation/translate.ts +250 -0
- package/app/composables/databaseCookies.ts +79 -0
- package/app/composables/fieldValidator.ts +72 -0
- package/app/composables/fieldsList.ts +301 -0
- package/app/composables/formatDatabase.ts +101 -0
- package/app/composables/index.ts +444 -0
- package/app/composables/openDrawer.ts +118 -0
- package/app/composables/optimizeFile.ts +287 -0
- package/app/composables/renderLabel.ts +88 -0
- package/app/composables/schemaClipboard.ts +95 -0
- package/app/composables/search.ts +353 -0
- package/app/composables/setThemeConfig.ts +48 -0
- package/app/composables/translationValue.ts +169 -0
- package/app/composables/useAssetPreview.ts +84 -0
- package/app/composables/useAssetUploader.ts +56 -0
- package/app/composables/useDashboardData.ts +310 -0
- package/app/composables/useDocumentThumbnail.ts +351 -0
- package/app/composables/useEcharts.ts +33 -0
- package/app/composables/useLocalDatabaseConfig.ts +51 -0
- package/app/composables/useOcr.ts +300 -0
- package/app/composables/useOfflineFetch.ts +194 -0
- package/app/composables/useOfflineItem.ts +107 -0
- package/app/composables/useOfflineQueue.ts +302 -0
- package/app/composables/useOfflineSync.ts +235 -0
- package/app/composables/usePasskeyAuth.ts +156 -0
- package/app/composables/usePdfCompressor.ts +180 -0
- package/app/composables/usePlatformRedirect.ts +72 -0
- package/app/composables/useRealtimeSync.ts +233 -0
- package/app/composables/useReferencedItems.ts +180 -0
- package/app/composables/useScanner.ts +664 -0
- package/app/composables/useSubscription.ts +650 -0
- package/app/composables/useThumbnailCache.ts +136 -0
- package/app/composables/useVideoCompressor.ts +194 -0
- package/app/error.vue +112 -0
- package/app/layouts/api.vue +188 -0
- package/app/layouts/dashboard.vue +91 -0
- package/app/layouts/default.vue +228 -0
- package/app/layouts/table.vue +471 -0
- package/app/locales/ar.ts +996 -0
- package/app/locales/en.ts +655 -0
- package/app/locales/es.ts +996 -0
- package/app/locales/fr.ts +997 -0
- package/app/middleware/dashboard.ts +33 -0
- package/app/middleware/database.ts +83 -0
- package/app/middleware/global.ts +1 -0
- package/app/middleware/sid-ingest.global.ts +29 -0
- package/app/middleware/table.ts +54 -0
- package/app/middleware/user.ts +26 -0
- package/app/pages/[[database]]/admin/api/auth/index.vue +306 -0
- package/app/pages/[[database]]/admin/api/index.vue +18 -0
- package/app/pages/[[database]]/admin/api/tables/[table]/index.vue +497 -0
- package/app/pages/[[database]]/admin/api/tables/index.vue +87 -0
- package/app/pages/[[database]]/admin/billing/index.vue +16 -0
- package/app/pages/[[database]]/admin/dashboards/[id]/edit.vue +66 -0
- package/app/pages/[[database]]/admin/dashboards/[id]/index.vue +117 -0
- package/app/pages/[[database]]/admin/dashboards/index.vue +20 -0
- package/app/pages/[[database]]/admin/index.vue +28 -0
- package/app/pages/[[database]]/admin/settings.vue +526 -0
- package/app/pages/[[database]]/admin/tables/[table]/[id]/edit.vue +143 -0
- package/app/pages/[[database]]/admin/tables/[table]/[id]/index.vue +146 -0
- package/app/pages/[[database]]/admin/tables/[table]/flows.vue +10 -0
- package/app/pages/[[database]]/admin/tables/[table]/index.vue +10 -0
- package/app/pages/[[database]]/admin/tables/[table]/new.vue +12 -0
- package/app/pages/[[database]]/admin/tables/[table]/schedules.vue +10 -0
- package/app/pages/[[database]]/admin/tables/[table]/settings.vue +30 -0
- package/app/pages/[[database]]/admin/tables/assets/[...path].vue +24 -0
- package/app/pages/[[database]]/admin/tables/assets/flows.vue +10 -0
- package/app/pages/[[database]]/admin/tables/backups/index.vue +10 -0
- package/app/pages/[[database]]/admin/tables/blocks/index.vue +16 -0
- package/app/pages/[[database]]/admin/tables/index.vue +20 -0
- package/app/pages/[[database]]/admin/tables/pages/index.vue +16 -0
- package/app/pages/[[database]]/admin/tables/templates/index.vue +16 -0
- package/app/pages/[[database]]/api/index.vue +120 -0
- package/app/pages/[[database]]/auth/index.vue +12 -0
- package/app/pages/[[database]]/auth/reset.vue +10 -0
- package/app/pages/[[database]]/index.vue +10 -0
- package/app/plugins/offline-warmup.client.ts +53 -0
- package/app/plugins/template-globals.ts +9 -0
- package/app/spa-loading-template.html +93 -0
- package/biome.json +53 -0
- package/index.d.ts +380 -0
- package/modules/naiveui.ts +41 -0
- package/nuxt.config.ts +269 -0
- package/package.json +56 -0
- package/pnpm-workspace.yaml +5 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/pwa-192x192.png +0 -0
- package/public/pwa-512x512.png +0 -0
- package/public/pwa-maskable-192x192.png +0 -0
- package/public/pwa-maskable-512x512.png +0 -0
- package/public/vendor/opencv.js +48 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import type { VNodeChild } from "vue";
|
|
2
|
+
import { Icon, NIcon } from "#components";
|
|
3
|
+
|
|
4
|
+
function renderIcon(iconName: string) {
|
|
5
|
+
return () => h(NIcon, () => h(Icon, { name: `tabler:${iconName}` }));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type fieldListOptionType = {
|
|
9
|
+
type?: string;
|
|
10
|
+
key: string;
|
|
11
|
+
label: string;
|
|
12
|
+
icon: () => VNodeChild;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
children?: fieldListOptionType[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default function fieldsList(): fieldListOptionType[] {
|
|
18
|
+
return [
|
|
19
|
+
{
|
|
20
|
+
label: t("fields.string"),
|
|
21
|
+
key: "text",
|
|
22
|
+
icon: renderIcon("typography"),
|
|
23
|
+
children: [
|
|
24
|
+
{
|
|
25
|
+
label: t("fields.shortText"),
|
|
26
|
+
key: "string",
|
|
27
|
+
icon: renderIcon("letter-case"),
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
label: t("fields.longText"),
|
|
31
|
+
key: "textarea",
|
|
32
|
+
icon: renderIcon("align-justified"),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: t("fields.html"),
|
|
36
|
+
key: "html",
|
|
37
|
+
icon: renderIcon("code"),
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
label: t("fields.password"),
|
|
41
|
+
key: "password",
|
|
42
|
+
icon: renderIcon("key"),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
label: t("fields.email"),
|
|
46
|
+
key: "email",
|
|
47
|
+
icon: renderIcon("at"),
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
label: t("fields.link"),
|
|
51
|
+
key: "url",
|
|
52
|
+
icon: renderIcon("link"),
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: t("fields.color"),
|
|
56
|
+
key: "color",
|
|
57
|
+
icon: renderIcon("palette"),
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
label: t("fields.icon"),
|
|
61
|
+
key: "icon",
|
|
62
|
+
icon: renderIcon("icons"),
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
label: t("fields.role"),
|
|
66
|
+
key: "role",
|
|
67
|
+
icon: renderIcon("shield-lock"),
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
label: t("fields.mention"),
|
|
71
|
+
key: "mention",
|
|
72
|
+
icon: renderIcon("message"),
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
label: t("fields.locale"),
|
|
76
|
+
key: "locale",
|
|
77
|
+
icon: renderIcon("world"),
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
label: t("fields.number"),
|
|
83
|
+
key: "number",
|
|
84
|
+
icon: renderIcon("numbers"),
|
|
85
|
+
children: [
|
|
86
|
+
// https://www.naiveui.com/en-US/dark/components/slider
|
|
87
|
+
{
|
|
88
|
+
label: t("fields.number"),
|
|
89
|
+
key: "number",
|
|
90
|
+
icon: renderIcon("numbers"),
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
label: t("fields.slider"),
|
|
94
|
+
key: "slider",
|
|
95
|
+
icon: renderIcon("timeline-event"),
|
|
96
|
+
disabled: true,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
label: t("fields.ip"),
|
|
100
|
+
key: "ip",
|
|
101
|
+
icon: renderIcon("map-2"),
|
|
102
|
+
disabled: true,
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
label: t("fields.multiple"),
|
|
108
|
+
key: "multiple",
|
|
109
|
+
icon: renderIcon("box-multiple"),
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
label: t("fields.date"),
|
|
113
|
+
key: "date",
|
|
114
|
+
icon: renderIcon("calendar"),
|
|
115
|
+
children: [
|
|
116
|
+
{
|
|
117
|
+
label: t("fields.date"),
|
|
118
|
+
key: "date",
|
|
119
|
+
icon: renderIcon("calendar"),
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
label: t("fields.dateTime"),
|
|
123
|
+
key: "date-datetime",
|
|
124
|
+
icon: renderIcon("calendar-time"),
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
label: t("fields.dateRange"),
|
|
128
|
+
key: "date-daterange",
|
|
129
|
+
icon: renderIcon("calendar-week"),
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
label: t("fields.dateTimeRange"),
|
|
133
|
+
key: "date-datetimerange",
|
|
134
|
+
icon: renderIcon("calendar-stats"),
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
label: t("fields.month"),
|
|
138
|
+
key: "date-month",
|
|
139
|
+
icon: renderIcon("calendar-month"),
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
label: t("fields.monthRange"),
|
|
143
|
+
key: "date-monthrange",
|
|
144
|
+
icon: renderIcon("calendar-due"),
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
label: t("fields.year"),
|
|
148
|
+
key: "date-year",
|
|
149
|
+
icon: renderIcon("calendar-event"),
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
label: t("fields.yearRange"),
|
|
153
|
+
key: "date-yearrange",
|
|
154
|
+
icon: renderIcon("calendar-up"),
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
label: t("fields.quarter"),
|
|
158
|
+
key: "date-quarter",
|
|
159
|
+
icon: renderIcon("calendar-plus"),
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
label: t("fields.quarterRange"),
|
|
163
|
+
key: "date-quarterrange",
|
|
164
|
+
icon: renderIcon("calendar-share"),
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
label: t("fields.week"),
|
|
168
|
+
key: "date-week",
|
|
169
|
+
icon: renderIcon("calendar-time"),
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
label: t("fields.toggle"),
|
|
175
|
+
key: "boolean",
|
|
176
|
+
icon: renderIcon("toggle-left"),
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
label: t("fields.id"),
|
|
180
|
+
key: "id",
|
|
181
|
+
icon: renderIcon("id"),
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
label: t("fields.asset"),
|
|
185
|
+
key: "asset",
|
|
186
|
+
icon: renderIcon("upload"),
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
label: t("fields.radio"),
|
|
190
|
+
key: "radio",
|
|
191
|
+
icon: renderIcon("circle-check"),
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
label: t("fields.select"),
|
|
195
|
+
key: "select",
|
|
196
|
+
icon: renderIcon("list-check"),
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
label: t("fields.array"),
|
|
200
|
+
key: "array",
|
|
201
|
+
icon: renderIcon("brackets"),
|
|
202
|
+
children: [
|
|
203
|
+
{
|
|
204
|
+
label: t("fields.tags"),
|
|
205
|
+
key: "tags",
|
|
206
|
+
icon: renderIcon("tags"),
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
label: t("fields.select"),
|
|
210
|
+
key: "array-select",
|
|
211
|
+
icon: renderIcon("list-check"),
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
label: t("fields.checkbox"),
|
|
215
|
+
key: "checkbox",
|
|
216
|
+
icon: renderIcon("copy-check"),
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
label: t("fields.assets"),
|
|
220
|
+
key: "array-asset",
|
|
221
|
+
icon: renderIcon("upload"),
|
|
222
|
+
},
|
|
223
|
+
// https://www.naiveui.com/en-US/dark/components/slider
|
|
224
|
+
{
|
|
225
|
+
label: t("fields.range"),
|
|
226
|
+
key: "range",
|
|
227
|
+
icon: renderIcon("parentheses"),
|
|
228
|
+
disabled: true,
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
label: t("fields.tableItems"),
|
|
232
|
+
key: "array-table",
|
|
233
|
+
icon: renderIcon("brand-airtable"),
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
label: t("fields.objects"),
|
|
237
|
+
key: "array",
|
|
238
|
+
icon: renderIcon("object-scan"),
|
|
239
|
+
},
|
|
240
|
+
],
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
label: t("fields.object"),
|
|
244
|
+
key: "object",
|
|
245
|
+
icon: renderIcon("braces"),
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
label: t("fields.table"),
|
|
249
|
+
key: "table",
|
|
250
|
+
icon: renderIcon("table"),
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
label: t("fields.json"),
|
|
254
|
+
key: "json",
|
|
255
|
+
icon: renderIcon("code"),
|
|
256
|
+
},
|
|
257
|
+
];
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function defaultField(): fieldListOptionType {
|
|
261
|
+
return {
|
|
262
|
+
key: "custom",
|
|
263
|
+
label: t("fields.custom"),
|
|
264
|
+
icon: renderIcon("question-mark"),
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export function flatFieldsList() {
|
|
269
|
+
return fieldsList().flatMap((field) => field.children || field);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export function getField(field: Field) {
|
|
273
|
+
if (field.type === "date" && field.date) {
|
|
274
|
+
return (
|
|
275
|
+
flatFieldsList().find(({ key }) => key === `date-${field.date}`) ??
|
|
276
|
+
flatFieldsList().find(({ key }) => key === "date") ??
|
|
277
|
+
defaultField()
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
if (field.table === "assets")
|
|
281
|
+
return (
|
|
282
|
+
flatFieldsList().find(
|
|
283
|
+
({ key }) => key === (field.type === "array" ? "array-asset" : "asset"),
|
|
284
|
+
) ?? defaultField()
|
|
285
|
+
);
|
|
286
|
+
if (field.type === "array") {
|
|
287
|
+
if (
|
|
288
|
+
!Array.isArray(field.children) &&
|
|
289
|
+
["table", "object"].includes(field.children as string)
|
|
290
|
+
)
|
|
291
|
+
return (
|
|
292
|
+
flatFieldsList().find(
|
|
293
|
+
({ key }) => key === [field.type, field.children].join("-"),
|
|
294
|
+
) ?? defaultField()
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
let fieldType = field.subType ?? field.type;
|
|
298
|
+
if (Array.isArray(fieldType)) fieldType = "multiple";
|
|
299
|
+
if (!fieldType) return defaultField();
|
|
300
|
+
return flatFieldsList().find(({ key }) => key === fieldType) ?? defaultField();
|
|
301
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { flattenSchema } from "inibase/utils"
|
|
2
|
+
|
|
3
|
+
const hiddenTableSlugs = new Set(["passkey_credentials", "passkey_challenges"])
|
|
4
|
+
|
|
5
|
+
export default function (database?: Database) {
|
|
6
|
+
const databaseState = useState<Database>("database")
|
|
7
|
+
|
|
8
|
+
const tables = database?.tables ?? databaseState.value?.tables
|
|
9
|
+
if (!tables?.length) return
|
|
10
|
+
|
|
11
|
+
const findTable = (slug: string) => tables.find((t) => t.slug === slug)
|
|
12
|
+
|
|
13
|
+
const processField = (field: Field): string | string[] | undefined => {
|
|
14
|
+
const fieldTable = findTable(field.table as string)
|
|
15
|
+
if (!fieldTable?.schema) return
|
|
16
|
+
if (
|
|
17
|
+
!(
|
|
18
|
+
fieldTable.label ||
|
|
19
|
+
fieldTable.customLabel ||
|
|
20
|
+
fieldTable.customLabelColumns
|
|
21
|
+
)
|
|
22
|
+
)
|
|
23
|
+
return
|
|
24
|
+
|
|
25
|
+
if (fieldTable.customLabel && !fieldTable.customLabelColumns)
|
|
26
|
+
return `${field.key}.*`
|
|
27
|
+
|
|
28
|
+
if (fieldTable.customLabelColumns)
|
|
29
|
+
return fieldTable.customLabelColumns.map(
|
|
30
|
+
(label: string) => `${field.key}.${label}`,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
const fieldTableFlatSchema = flattenSchema(fieldTable.schema as any)
|
|
34
|
+
const keyParts = field.key.split(".")
|
|
35
|
+
const lastKeyPart = keyParts[keyParts.length - 1]
|
|
36
|
+
const results: string[] = [field.key]
|
|
37
|
+
|
|
38
|
+
if (typeof fieldTable.label === "string") {
|
|
39
|
+
const tokens = fieldTable.label
|
|
40
|
+
.split(/(@\w+)/g)
|
|
41
|
+
.filter((token) => token.startsWith("@"))
|
|
42
|
+
|
|
43
|
+
for (const token of tokens) {
|
|
44
|
+
const labelId = Number(token.slice(1))
|
|
45
|
+
const labelField = fieldTableFlatSchema.find(
|
|
46
|
+
(f: Field) => f.id === labelId,
|
|
47
|
+
)
|
|
48
|
+
if (!labelField) continue
|
|
49
|
+
|
|
50
|
+
if (labelField.table && labelField.table !== field.table) {
|
|
51
|
+
const labelFieldTable = findTable(labelField.table)
|
|
52
|
+
if (!labelFieldTable) continue
|
|
53
|
+
|
|
54
|
+
if (labelFieldTable.customLabelColumns) {
|
|
55
|
+
for (const column of labelFieldTable.customLabelColumns) {
|
|
56
|
+
results.push(`${lastKeyPart}.${labelField.key}.${column}`)
|
|
57
|
+
}
|
|
58
|
+
continue
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (labelFieldTable.customLabel) {
|
|
62
|
+
results.push(`${lastKeyPart}.${labelField.key}.*`)
|
|
63
|
+
continue
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (labelFieldTable.columns) {
|
|
67
|
+
for (const column of labelFieldTable.columns) {
|
|
68
|
+
results.push(`${lastKeyPart}.${labelField.key}.${column}`)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
results.push(`${lastKeyPart}.${labelField.key ?? "*"}`)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return results
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const formatTable = (table: Table) => {
|
|
80
|
+
if (hiddenTableSlugs.has(table.slug)) table.show = false
|
|
81
|
+
|
|
82
|
+
if (table.columns) return table
|
|
83
|
+
|
|
84
|
+
if (table.schema && (table.label || table.customLabel)) {
|
|
85
|
+
const flatSchema = flattenSchema(table.schema as any)
|
|
86
|
+
const columns = flatSchema
|
|
87
|
+
.filter(
|
|
88
|
+
(field: Field) => Boolean(field.table) && field.table !== "assets",
|
|
89
|
+
)
|
|
90
|
+
.flatMap(processField)
|
|
91
|
+
.filter((col): col is string => col !== undefined)
|
|
92
|
+
|
|
93
|
+
table.columns = columns.length ? ["*", ...columns] : ["*"]
|
|
94
|
+
} else table.columns = []
|
|
95
|
+
|
|
96
|
+
return table
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (database) database.tables = tables.map(formatTable)
|
|
100
|
+
else databaseState.value.tables = tables.map(formatTable)
|
|
101
|
+
}
|