alinea 2.0.0-preview.7 → 2.0.0-preview.9
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/.init/content/pages/welcome.json +1 -1
- package/dist/LICENSES.md +103 -103
- package/dist/adapter/next/cms.d.ts +18 -4
- package/dist/adapter/next/cms.js +141 -36
- package/dist/adapter/next/handler.d.ts +5 -1
- package/dist/adapter/next/handler.js +77 -17
- package/dist/adapter/next/node.d.ts +5 -0
- package/dist/adapter/next/node.js +16 -0
- package/dist/adapter/next/previews.d.ts +4 -1
- package/dist/adapter/next/previews.js +13 -1
- package/dist/adapter/next/renderStats.d.ts +45 -0
- package/dist/adapter/next/renderStats.js +142 -0
- package/dist/adapter/next/syncCheck.d.ts +8 -2
- package/dist/adapter/next/syncCheck.js +5 -11
- package/dist/adapter/next/with-alinea.js +6 -20
- package/dist/backend/HandleAction.d.ts +1 -1
- package/dist/backend/HandleAction.js +1 -1
- package/dist/backend/Handler.d.ts +2 -2
- package/dist/backend/Handler.js +45 -47
- package/dist/backend/api/CreateBackend.js +15 -3
- package/dist/backend/api/DatabaseApi.js +22 -135
- package/dist/backend/api/ProxyMedia.d.ts +2 -3
- package/dist/backend/api/ProxyMedia.js +7 -22
- package/dist/backend/api/database.js +15 -3
- package/dist/backend/resolver/ParsePreview.d.ts +2 -2
- package/dist/backend/router/NodeHandler.js +2 -0
- package/dist/backend/store/GeneratedDatabase.d.ts +8 -0
- package/dist/backend/store/GeneratedDatabase.js +33 -0
- package/dist/backend/store/GeneratedDatabaseNode.d.ts +4 -0
- package/dist/backend/store/GeneratedDatabaseNode.js +35 -0
- package/dist/backend/util/ORM.js +4 -2
- package/dist/bundled.d.ts +1565 -468
- package/dist/chunks/bun-sqlite-5SHXN3AT.js +18 -0
- package/dist/chunks/chunk-2BJ2IFQM.js +1085 -0
- package/dist/chunks/chunk-2PIFHEYR.js +364 -0
- package/dist/chunks/chunk-66YZ47TY.js +94 -0
- package/dist/chunks/chunk-76VMZTLN.js +55 -0
- package/dist/chunks/chunk-AIU6CMVT.js +495 -0
- package/dist/chunks/chunk-ASYKC6IE.js +103 -0
- package/dist/chunks/chunk-ATF42T2B.js +35 -0
- package/dist/chunks/{chunk-6P4UVRPH.js → chunk-DWR5A5KL.js} +6 -1
- package/dist/chunks/{chunk-NWQXN4SB.js → chunk-ETBQTP2S.js} +40 -29
- package/dist/chunks/chunk-ETWOY4AL.js +100 -0
- package/dist/chunks/chunk-K62JP6HR.js +22 -0
- package/dist/chunks/chunk-MOWR65LM.js +610 -0
- package/dist/chunks/chunk-N47Y62CI.js +396 -0
- package/dist/chunks/chunk-QBPYWU6C.js +24 -0
- package/dist/chunks/{chunk-X47OVDF3.js → chunk-QJGGYF6E.js} +356 -1000
- package/dist/chunks/chunk-QSN6RH6X.js +94 -0
- package/dist/chunks/{chunk-I4GC3E65.js → chunk-UPY2RUZF.js} +0 -1
- package/dist/chunks/chunk-XCZXR3C2.js +112 -0
- package/dist/chunks/chunk-XTWYBWP2.js +81 -0
- package/dist/chunks/node-sqlite-XVNTNMCY.js +18 -0
- package/dist/cli/Generate.js +74 -64
- package/dist/cli/Serve.js +1 -1
- package/dist/cli/bin.js +6 -1
- package/dist/cli/generate/CopyStaticFiles.js +17 -14
- package/dist/cli/generate/DevDB.d.ts +22 -5
- package/dist/cli/generate/DevDB.js +138 -24
- package/dist/cli/serve/CreateLocalServer.js +22 -4
- package/dist/cli/serve/DevServer.d.ts +2 -0
- package/dist/cli/serve/DevServer.js +7 -2
- package/dist/cli/serve/LiveReload.d.ts +1 -1
- package/dist/cli/serve/LiveReload.js +3 -0
- package/dist/cloud/CloudRemote.js +2 -1
- package/dist/components/Breadcrumbs.js +2 -2
- package/dist/components/Calendar.js +7 -7
- package/dist/components/Checkbox.js +1 -1
- package/dist/components/ColorSwatchPicker.js +2 -2
- package/dist/components/ComboBox.js +14 -14
- package/dist/components/DateField.js +1 -1
- package/dist/components/DatePicker.js +6 -6
- package/dist/components/DateRangePicker.js +4 -4
- package/dist/components/Disclosure.js +8 -8
- package/dist/components/Label.js +6 -6
- package/dist/components/List.js +33 -33
- package/dist/components/Menu.js +2 -2
- package/dist/components/Modal.js +2 -2
- package/dist/components/MultipleSelect.js +23 -23
- package/dist/components/NumberField.js +6 -6
- package/dist/components/ProgressCircle.js +3 -3
- package/dist/components/SearchField.js +8 -8
- package/dist/components/Select.js +8 -8
- package/dist/components/Surface.js +3 -3
- package/dist/components/Switch.js +2 -2
- package/dist/components/Table.js +7 -7
- package/dist/components/Tabs.js +2 -2
- package/dist/components/TagGroup.js +2 -2
- package/dist/components/TextField.js +2 -2
- package/dist/components/TimeField.js +3 -3
- package/dist/components/Toolbar.js +2 -2
- package/dist/components/Tooltip.js +4 -4
- package/dist/components/Tree.d.ts +2 -1
- package/dist/components/Tree.js +6 -6
- package/dist/core/Client.d.ts +1 -4
- package/dist/core/Client.js +5 -7
- package/dist/core/Connection.d.ts +4 -1
- package/dist/core/Connection.js +3 -1
- package/dist/core/Document.js +15 -3
- package/dist/core/Entry.d.ts +3 -0
- package/dist/core/Entry.js +4 -0
- package/dist/core/EntrySeed.d.ts +19 -0
- package/dist/core/EntrySeed.js +136 -0
- package/dist/core/Field.d.ts +7 -0
- package/dist/core/Field.js +4 -0
- package/dist/core/Filter.d.ts +40 -2
- package/dist/core/Filter.js +145 -0
- package/dist/core/Graph.d.ts +9 -0
- package/dist/core/ListRow.d.ts +1 -0
- package/dist/core/ListRow.js +1 -0
- package/dist/core/Reference.d.ts +1 -0
- package/dist/core/Root.js +1 -1
- package/dist/core/Scope.d.ts +2 -0
- package/dist/core/Scope.js +16 -1
- package/dist/core/Type.d.ts +2 -1
- package/dist/core/Type.js +13 -1
- package/dist/core/db/EntryAliases.js +1 -11
- package/dist/core/db/EntryReference.d.ts +0 -6
- package/dist/core/db/IndexEvent.d.ts +2 -1
- package/dist/core/db/IndexEvent.js +11 -3
- package/dist/core/db/LinkResolver.d.ts +6 -6
- package/dist/core/db/LinkResolver.js +0 -52
- package/dist/core/db/LocalStore.d.ts +27 -0
- package/dist/core/field/ListField.js +19 -0
- package/dist/core/field/RecordField.js +8 -0
- package/dist/core/field/RichTextField.js +42 -0
- package/dist/core/field/UnionField.js +8 -0
- package/dist/core/source/FSSource.d.ts +14 -2
- package/dist/core/source/FSSource.js +58 -13
- package/dist/core/source/GitUtils.d.ts +4 -0
- package/dist/core/source/GitUtils.js +9 -10
- package/dist/core/source/GithubSource.js +60 -21
- package/dist/core/source/IndexedDBSource.d.ts +2 -1
- package/dist/core/source/IndexedDBSource.js +67 -53
- package/dist/core/source/MemorySource.js +5 -3
- package/dist/core/source/OverlaySource.d.ts +5 -2
- package/dist/core/source/OverlaySource.js +31 -3
- package/dist/core/source/Source.d.ts +3 -0
- package/dist/core/source/Source.js +15 -2
- package/dist/core/source/Tree.d.ts +10 -7
- package/dist/core/source/Tree.js +118 -70
- package/dist/core/source/Utils.js +6 -3
- package/dist/core/util/Arrays.d.ts +1 -0
- package/dist/core/util/Arrays.js +10 -0
- package/dist/core/util/Async.d.ts +7 -0
- package/dist/core/util/Async.js +15 -0
- package/dist/core/util/Checks.js +1 -1
- package/dist/core/util/EntryFilenames.d.ts +22 -1
- package/dist/core/util/EntryFilenames.js +56 -2
- package/dist/core/util/IndexedDB.d.ts +4 -0
- package/dist/core/util/IndexedDB.js +20 -0
- package/dist/core/util/Paths.js +5 -1
- package/dist/dashboard/App.js +3 -3
- package/dist/dashboard/ViewKeys.d.ts +1 -0
- package/dist/dashboard/ViewKeys.js +1 -0
- package/dist/dashboard/app/AccessDenied.js +2 -2
- package/dist/dashboard/app/ActivityStatus.js +14 -14
- package/dist/dashboard/app/AppShell.js +2 -2
- package/dist/dashboard/app/AuthView.js +12 -12
- package/dist/dashboard/app/CompactField.js +11 -11
- package/dist/dashboard/app/DashboardErrorBoundary.js +6 -6
- package/dist/dashboard/app/DashboardLayout.js +3 -3
- package/dist/dashboard/app/EntryHeader.js +8 -8
- package/dist/dashboard/app/EntryReferences.js +8 -8
- package/dist/dashboard/app/EntrySidebar.js +15 -15
- package/dist/dashboard/app/EntrySidebarPreview.js +7 -7
- package/dist/dashboard/app/EntryTranslationBanner.js +5 -5
- package/dist/dashboard/app/Explorer.js +39 -39
- package/dist/dashboard/app/ExplorerCards.js +31 -31
- package/dist/dashboard/app/ExplorerFileCard.js +19 -19
- package/dist/dashboard/app/ExplorerList.js +10 -10
- package/dist/dashboard/app/ExplorerModal.js +5 -5
- package/dist/dashboard/app/ExplorerTable.js +47 -47
- package/dist/dashboard/app/LinkPicker.js +5 -5
- package/dist/dashboard/app/LocaleMenu.js +4 -4
- package/dist/dashboard/app/SidebarTree.js +76 -40
- package/dist/dashboard/app/WorkspaceMenu.js +9 -9
- package/dist/dashboard/app/WorkspaceRoots.js +22 -22
- package/dist/dashboard/app/editor/FileEditor.js +28 -28
- package/dist/dashboard/app/editor/FilePreview.js +6 -6
- package/dist/dashboard/app/modals/CreateEntry.js +3 -3
- package/dist/dashboard/app/pages/EntryPage.js +18 -18
- package/dist/dashboard/app/pages/RootPage.js +3 -3
- package/dist/dashboard/app/pages/SplashPage.js +45 -45
- package/dist/dashboard/app/pages/UsersPage.js +34 -34
- package/dist/dashboard/app/ui/DashboardModal.js +18 -18
- package/dist/dashboard/app/ui/Rail.js +5 -5
- package/dist/dashboard/app/ui/Sidebar.js +2 -2
- package/dist/dashboard/atoms/config.d.ts +4 -4
- package/dist/dashboard/atoms/entry.d.ts +8 -9
- package/dist/dashboard/atoms/entry.js +34 -4
- package/dist/dashboard/atoms/explorer.d.ts +2 -0
- package/dist/dashboard/atoms/explorer.js +7 -2
- package/dist/dashboard/boot/Boot.js +2 -3
- package/dist/dashboard/boot/DashboardWorker.d.ts +3 -3
- package/dist/dashboard/boot/DashboardWorker.js +82 -27
- package/dist/dashboard/boot/LoadWorker.js +2 -3
- package/dist/dashboard/boot/WorkerDB.d.ts +2 -2
- package/dist/dashboard/icons.d.ts +2 -0
- package/dist/dashboard/icons.js +40 -0
- package/dist/dashboard/plugins/alineaFixturePlugin.js +14 -3
- package/dist/database/BrowserEntryStore.d.ts +42 -0
- package/dist/database/BrowserEntryStore.js +182 -0
- package/dist/database/DatabaseSource.d.ts +13 -0
- package/dist/database/DatabaseSource.js +25 -0
- package/dist/database/DatabaseTables.d.ts +38 -0
- package/dist/database/DatabaseTables.js +53 -0
- package/dist/database/EntryDatabase.d.ts +97 -0
- package/dist/database/EntryDatabase.js +528 -0
- package/dist/database/EntryStore.d.ts +58 -0
- package/dist/database/EntryStore.js +230 -0
- package/dist/database/EntryTransaction.d.ts +33 -0
- package/dist/database/EntryTransaction.js +907 -0
- package/dist/database/EntryUrlAliases.d.ts +2 -0
- package/dist/database/EntryUrlAliases.js +69 -0
- package/dist/database/LocalDB.d.ts +39 -0
- package/dist/database/LocalDB.js +79 -0
- package/dist/database/Version.d.ts +9 -0
- package/dist/database/Version.js +13 -0
- package/dist/database/driver/DatabaseHandle.d.ts +17 -0
- package/dist/database/driver/DatabaseHandle.js +0 -0
- package/dist/database/driver/OverlayExtension.browser.d.ts +2 -0
- package/dist/database/driver/OverlayExtension.browser.js +9 -0
- package/dist/database/driver/OverlayExtension.d.ts +1 -0
- package/dist/database/driver/OverlayExtension.js +7 -0
- package/dist/database/driver/RuntimeDatabase.d.ts +13 -0
- package/dist/database/driver/RuntimeDatabase.js +77 -0
- package/dist/database/driver/WasmDatabase.d.ts +29 -0
- package/dist/database/driver/WasmDatabase.js +46 -0
- package/dist/database/entry/EntryData.d.ts +13 -0
- package/dist/database/entry/EntryData.js +51 -0
- package/dist/database/entry/EntryTable.d.ts +189 -0
- package/dist/database/entry/EntryTable.js +186 -0
- package/dist/database/query/Condition.d.ts +8 -0
- package/dist/database/query/Condition.js +117 -0
- package/dist/database/query/EntryQuery.d.ts +44 -0
- package/dist/database/query/EntryQuery.js +412 -0
- package/dist/database/query/EntryReferences.d.ts +5 -0
- package/dist/database/query/EntryReferences.js +70 -0
- package/dist/database/query/Relation.d.ts +11 -0
- package/dist/database/query/Relation.js +113 -0
- package/dist/database/query/ResolveQuery.d.ts +12 -0
- package/dist/database/query/ResolveQuery.js +189 -0
- package/dist/database/query/Search.d.ts +38 -0
- package/dist/database/query/Search.js +149 -0
- package/dist/database/sync/Derive.d.ts +8 -0
- package/dist/database/sync/Derive.js +270 -0
- package/dist/database/sync/EntryParser.d.ts +8 -0
- package/dist/database/sync/EntryParser.js +90 -0
- package/dist/database/sync/EntrySyncer.d.ts +25 -0
- package/dist/database/sync/EntrySyncer.js +89 -0
- package/dist/database/sync/Ingest.d.ts +21 -0
- package/dist/database/sync/Ingest.js +145 -0
- package/dist/database/sync/SyncQueries.d.ts +160 -0
- package/dist/database/sync/SyncQueries.js +216 -0
- package/dist/field/check/CheckField.view.js +2 -2
- package/dist/field/code/CodeField.view.js +10 -10
- package/dist/field/link/LinkField.js +23 -0
- package/dist/field/link/LinkField.view.js +42 -41
- package/dist/field/list/ListField.view.js +172 -150
- package/dist/field/metadata/MetadataField.d.ts +28 -3
- package/dist/field/metadata/MetadataField.js +44 -7
- package/dist/field/metadata/MetadataField.view.d.ts +5 -0
- package/dist/field/metadata/MetadataField.view.js +31 -16
- package/dist/field/richtext/RichTextDocument.js +4 -3
- package/dist/field/richtext/RichTextExtensions.d.ts +1 -1
- package/dist/field/richtext/RichTextExtensions.js +33 -29
- package/dist/field/richtext/RichTextField.view.js +17 -8
- package/dist/field/richtext/RichTextInsertMenu.js +2 -2
- package/dist/field/views.js +2 -0
- package/dist/next.cjs +6 -20
- package/dist/next.d.ts +4 -3
- package/dist/next.edge.d.ts +1 -1
- package/dist/next.js +1 -2
- package/dist/picker/entry/EntryPicker.js +2 -1
- package/dist/picker/url/UrlPicker.js +1 -0
- package/dist/preview/widget.d.ts +45 -0
- package/dist/preview/widget.js +96 -1
- package/dist/query.d.ts +28 -0
- package/package.json +6 -1
- package/dist/adapter/next/DevRemote.d.ts +0 -3
- package/dist/adapter/next/DevRemote.js +0 -45
- package/dist/backend/store/GeneratedSource.d.ts +0 -2
- package/dist/backend/store/GeneratedSource.js +0 -21
- package/dist/chunks/chunk-G6E35DMJ.js +0 -1997
- package/dist/core/db/EntryDB.d.ts +0 -19
- package/dist/core/db/EntryDB.js +0 -48
- package/dist/core/db/EntryIndex.d.ts +0 -143
- package/dist/core/db/EntryIndex.js +0 -2773
- package/dist/core/db/EntryReferenceIndex.d.ts +0 -21
- package/dist/core/db/EntryReferenceIndex.js +0 -131
- package/dist/core/db/EntryResolver.d.ts +0 -56
- package/dist/core/db/EntryResolver.js +0 -699
- package/dist/core/db/EntryTarget.d.ts +0 -5
- package/dist/core/db/EntryTransaction.d.ts +0 -31
- package/dist/core/db/EntryTransaction.js +0 -956
- package/dist/core/db/LocalDB.d.ts +0 -42
- package/dist/core/db/LocalDB.js +0 -127
- package/dist/core/db/TestDB.d.ts +0 -19
- package/dist/core/db/TestDB.js +0 -50
- /package/dist/core/db/{EntryTarget.js → LocalStore.js} +0 -0
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cached,
|
|
3
|
+
getData,
|
|
4
|
+
getField,
|
|
5
|
+
getSelection,
|
|
6
|
+
getSql,
|
|
7
|
+
getTable,
|
|
8
|
+
hasField,
|
|
9
|
+
hasSelection,
|
|
10
|
+
hasSql,
|
|
11
|
+
hasTable,
|
|
12
|
+
internalData,
|
|
13
|
+
internalField,
|
|
14
|
+
internalSql,
|
|
15
|
+
internalTarget,
|
|
16
|
+
sql
|
|
17
|
+
} from "./chunk-ETBQTP2S.js";
|
|
18
|
+
|
|
19
|
+
// node_modules/rado/dist/core/Index.js
|
|
20
|
+
var IndexData = class {
|
|
21
|
+
name;
|
|
22
|
+
fields;
|
|
23
|
+
concurrently;
|
|
24
|
+
unique;
|
|
25
|
+
only;
|
|
26
|
+
using;
|
|
27
|
+
order;
|
|
28
|
+
nulls;
|
|
29
|
+
where;
|
|
30
|
+
};
|
|
31
|
+
var IndexApi = class extends IndexData {
|
|
32
|
+
toSql(tableName, indexName, ifNotExists) {
|
|
33
|
+
const fields = this.fields.map(
|
|
34
|
+
(field) => sql.join([
|
|
35
|
+
field,
|
|
36
|
+
this.order && sql.unsafe(this.order),
|
|
37
|
+
this.nulls && sql`nulls ${sql.unsafe(this.nulls)}`
|
|
38
|
+
])
|
|
39
|
+
);
|
|
40
|
+
return sql.join([
|
|
41
|
+
sql`create`,
|
|
42
|
+
this.unique && sql`unique`,
|
|
43
|
+
sql`index`,
|
|
44
|
+
this.concurrently && sql`concurrently`,
|
|
45
|
+
ifNotExists && sql`if not exists`,
|
|
46
|
+
sql.identifier(indexName),
|
|
47
|
+
sql`on`,
|
|
48
|
+
this.only && sql`only`,
|
|
49
|
+
sql.identifier(tableName),
|
|
50
|
+
this.using && sql`using ${this.using}`,
|
|
51
|
+
sql`(${sql.join(fields, sql`, `)})`,
|
|
52
|
+
this.where && sql`where ${this.where}`
|
|
53
|
+
]).inlineFields(false);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
var Index = class _Index {
|
|
57
|
+
[internalData];
|
|
58
|
+
constructor(data) {
|
|
59
|
+
this[internalData] = Object.assign(new IndexApi(), data);
|
|
60
|
+
}
|
|
61
|
+
on(...fields) {
|
|
62
|
+
return new _Index({ ...getData(this), fields });
|
|
63
|
+
}
|
|
64
|
+
concurrently() {
|
|
65
|
+
return new _Index({ ...getData(this), concurrently: true });
|
|
66
|
+
}
|
|
67
|
+
only() {
|
|
68
|
+
return new _Index({ ...getData(this), only: true });
|
|
69
|
+
}
|
|
70
|
+
using(using) {
|
|
71
|
+
return new _Index({ ...getData(this), using });
|
|
72
|
+
}
|
|
73
|
+
asc() {
|
|
74
|
+
return new _Index({ ...getData(this), order: "asc" });
|
|
75
|
+
}
|
|
76
|
+
desc() {
|
|
77
|
+
return new _Index({ ...getData(this), order: "desc" });
|
|
78
|
+
}
|
|
79
|
+
nullsFirst() {
|
|
80
|
+
return new _Index({ ...getData(this), nulls: "first" });
|
|
81
|
+
}
|
|
82
|
+
nullsLast() {
|
|
83
|
+
return new _Index({ ...getData(this), nulls: "last" });
|
|
84
|
+
}
|
|
85
|
+
where(where) {
|
|
86
|
+
return new _Index({ ...getData(this), where });
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
function index(name) {
|
|
90
|
+
return new Index({ name, fields: [] });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// node_modules/rado/dist/core/expr/Field.js
|
|
94
|
+
var Field = class {
|
|
95
|
+
[internalField];
|
|
96
|
+
[internalSql];
|
|
97
|
+
constructor(targetName, fieldName, source = {}) {
|
|
98
|
+
const field = { targetName, fieldName, source };
|
|
99
|
+
this[internalField] = field;
|
|
100
|
+
const expr = sql.field(field).as(fieldName).mapWith(source);
|
|
101
|
+
this[internalSql] = expr;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// node_modules/rado/dist/core/Virtual.js
|
|
106
|
+
function virtualFields(alias, source) {
|
|
107
|
+
return Object.fromEntries(
|
|
108
|
+
Object.entries(source).map(([key, value]) => {
|
|
109
|
+
if (value && typeof value === "object" && !hasSql(value))
|
|
110
|
+
return [key, virtualFields(alias, value)];
|
|
111
|
+
return [key, new Field(alias, key, getSql(value))];
|
|
112
|
+
})
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
function virtualTarget(alias, source) {
|
|
116
|
+
const target = {
|
|
117
|
+
[internalTarget]: sql.identifier(alias)
|
|
118
|
+
};
|
|
119
|
+
if (!source || typeof source !== "object")
|
|
120
|
+
throw new Error("Cannot alias a non-object");
|
|
121
|
+
if (hasSql(source)) {
|
|
122
|
+
const expr = getSql(source);
|
|
123
|
+
const name = expr.alias;
|
|
124
|
+
if (!name) throw new Error("Cannot alias a virtual field without a name");
|
|
125
|
+
return Object.assign(new Field(alias, name, expr), target);
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
...target,
|
|
129
|
+
...virtualFields(alias, source)
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// node_modules/rado/dist/core/Selection.js
|
|
134
|
+
var SqlColumn = class {
|
|
135
|
+
constructor(sql2, targetName) {
|
|
136
|
+
this.sql = sql2;
|
|
137
|
+
this.targetName = targetName;
|
|
138
|
+
}
|
|
139
|
+
sql;
|
|
140
|
+
targetName;
|
|
141
|
+
result(ctx) {
|
|
142
|
+
const value = ctx.values[ctx.index++];
|
|
143
|
+
if (!this.sql.mapFromDriverValue) return value;
|
|
144
|
+
return this.sql.mapFromDriverValue(value, ctx.specs);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
var ObjectColumn = class {
|
|
148
|
+
constructor(nullable, entries) {
|
|
149
|
+
this.nullable = nullable;
|
|
150
|
+
this.entries = entries;
|
|
151
|
+
}
|
|
152
|
+
nullable;
|
|
153
|
+
entries;
|
|
154
|
+
result(ctx) {
|
|
155
|
+
const result = {};
|
|
156
|
+
let isNullable = this.nullable.size > 0;
|
|
157
|
+
for (const entry of this.entries) {
|
|
158
|
+
const name = entry[0];
|
|
159
|
+
const col = entry[1];
|
|
160
|
+
const value = col.result(ctx);
|
|
161
|
+
result[name] = value;
|
|
162
|
+
if (isNullable) {
|
|
163
|
+
if (value === null) {
|
|
164
|
+
if (col.targetName && !this.nullable.has(col.targetName))
|
|
165
|
+
isNullable = false;
|
|
166
|
+
} else {
|
|
167
|
+
isNullable = false;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (isNullable) return null;
|
|
172
|
+
return result;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
function firstTargetName(input) {
|
|
176
|
+
const expr = getSql(input);
|
|
177
|
+
if (expr) return hasField(input) ? getField(input).targetName : void 0;
|
|
178
|
+
if (!input || typeof input !== "object") return;
|
|
179
|
+
for (const value of Object.values(input)) {
|
|
180
|
+
const name = firstTargetName(value);
|
|
181
|
+
if (name) return name;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
var Selection = class _Selection {
|
|
185
|
+
constructor(input, nullable = /* @__PURE__ */ new Set()) {
|
|
186
|
+
this.input = input;
|
|
187
|
+
this.nullable = nullable;
|
|
188
|
+
const root = this.#defineColumn(nullable, input);
|
|
189
|
+
this.mapRow = root.result.bind(root);
|
|
190
|
+
}
|
|
191
|
+
input;
|
|
192
|
+
nullable;
|
|
193
|
+
mapRow;
|
|
194
|
+
makeVirtual(name) {
|
|
195
|
+
return virtualTarget(name, this.input);
|
|
196
|
+
}
|
|
197
|
+
#defineColumn(nullable, input) {
|
|
198
|
+
const expr = getSql(input);
|
|
199
|
+
if (expr) return new SqlColumn(expr, getField(input)?.targetName);
|
|
200
|
+
return new ObjectColumn(
|
|
201
|
+
nullable,
|
|
202
|
+
Object.entries(input).map(([name, value]) => [
|
|
203
|
+
name,
|
|
204
|
+
this.#defineColumn(nullable, value)
|
|
205
|
+
])
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
#columns;
|
|
209
|
+
#aliases;
|
|
210
|
+
// Flattened selected expressions with their deduplicated output names
|
|
211
|
+
#selected() {
|
|
212
|
+
if (this.#columns) return this.#columns;
|
|
213
|
+
const columns = [];
|
|
214
|
+
const names = /* @__PURE__ */ new Set();
|
|
215
|
+
const collect = (input, name) => {
|
|
216
|
+
const expr = getSql(input);
|
|
217
|
+
if (expr) {
|
|
218
|
+
let exprName = name ?? expr.alias;
|
|
219
|
+
if (exprName) {
|
|
220
|
+
while (names.has(exprName)) exprName = `${exprName}_`;
|
|
221
|
+
names.add(exprName);
|
|
222
|
+
}
|
|
223
|
+
columns.push({ input, expr, name: exprName });
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
for (const [name2, value] of Object.entries(input)) collect(value, name2);
|
|
227
|
+
};
|
|
228
|
+
collect(this.input);
|
|
229
|
+
return this.#columns = columns;
|
|
230
|
+
}
|
|
231
|
+
fieldNames() {
|
|
232
|
+
return this.#selected().map((column) => {
|
|
233
|
+
if (!column.name) throw new Error("Missing field name");
|
|
234
|
+
return column.name;
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
aliasOf(input) {
|
|
238
|
+
if (!this.#aliases) {
|
|
239
|
+
this.#aliases = /* @__PURE__ */ new Map();
|
|
240
|
+
for (const { expr, name } of this.#selected())
|
|
241
|
+
if (name && !this.#aliases.has(expr)) this.#aliases.set(expr, name);
|
|
242
|
+
}
|
|
243
|
+
return this.#aliases.get(getSql(input));
|
|
244
|
+
}
|
|
245
|
+
get [internalSql]() {
|
|
246
|
+
return cached(this, internalSql, () => {
|
|
247
|
+
const parts = this.#selected().map(({ input, expr, name }) => {
|
|
248
|
+
if (!name) return expr;
|
|
249
|
+
if (hasField(input) && getField(input).fieldName === name) return expr;
|
|
250
|
+
return sql`${expr.forSelection()} as ${sql.identifier(name)}`;
|
|
251
|
+
});
|
|
252
|
+
return sql.join(parts, sql`, `);
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
#collectTargetNames(input, names) {
|
|
256
|
+
const expr = getSql(input);
|
|
257
|
+
if (expr) {
|
|
258
|
+
if (hasField(input)) names.add(getField(input).targetName);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
for (const value of Object.values(input))
|
|
262
|
+
this.#collectTargetNames(value, names);
|
|
263
|
+
}
|
|
264
|
+
#targetNames() {
|
|
265
|
+
const names = /* @__PURE__ */ new Set();
|
|
266
|
+
this.#collectTargetNames(this.input, names);
|
|
267
|
+
return names;
|
|
268
|
+
}
|
|
269
|
+
join(right, operator) {
|
|
270
|
+
if (hasSelection(right)) {
|
|
271
|
+
const selected2 = getSelection(right);
|
|
272
|
+
const alias = firstTargetName(selected2.input);
|
|
273
|
+
if (!alias) return this;
|
|
274
|
+
const nullable2 = new Set(this.nullable);
|
|
275
|
+
if (operator === "leftJoin" || operator === "fullJoin")
|
|
276
|
+
nullable2.add(alias);
|
|
277
|
+
if (operator === "rightJoin" || operator === "fullJoin")
|
|
278
|
+
for (const name of this.#targetNames()) nullable2.add(name);
|
|
279
|
+
return new _Selection(this.input, nullable2);
|
|
280
|
+
}
|
|
281
|
+
if (!hasTable(right)) return this;
|
|
282
|
+
const rightTable = getTable(right);
|
|
283
|
+
const nullable = new Set(this.nullable);
|
|
284
|
+
if (operator === "leftJoin" || operator === "fullJoin")
|
|
285
|
+
nullable.add(rightTable.aliased);
|
|
286
|
+
if (operator === "rightJoin" || operator === "fullJoin")
|
|
287
|
+
for (const name of this.#targetNames()) nullable.add(name);
|
|
288
|
+
return new _Selection(this.input, nullable);
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
var TableSelection = class extends Selection {
|
|
292
|
+
constructor(table) {
|
|
293
|
+
super(table, /* @__PURE__ */ new Set());
|
|
294
|
+
this.table = table;
|
|
295
|
+
}
|
|
296
|
+
table;
|
|
297
|
+
join(right, operator) {
|
|
298
|
+
const leftTable = getTable(this.table);
|
|
299
|
+
if (hasSelection(right)) {
|
|
300
|
+
const selected2 = getSelection(right);
|
|
301
|
+
const alias = firstTargetName(selected2.input);
|
|
302
|
+
if (!alias) return this;
|
|
303
|
+
const nullable2 = new Set(this.nullable);
|
|
304
|
+
if (operator === "rightJoin" || operator === "fullJoin")
|
|
305
|
+
nullable2.add(leftTable.aliased);
|
|
306
|
+
if (operator === "leftJoin" || operator === "fullJoin")
|
|
307
|
+
nullable2.add(alias);
|
|
308
|
+
return new Selection(
|
|
309
|
+
{ [leftTable.aliased]: this.table, [alias]: selected2.input },
|
|
310
|
+
nullable2
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
if (!hasTable(right)) return this;
|
|
314
|
+
const rightTable = getTable(right);
|
|
315
|
+
const nullable = new Set(this.nullable);
|
|
316
|
+
if (operator === "rightJoin" || operator === "fullJoin")
|
|
317
|
+
nullable.add(leftTable.aliased);
|
|
318
|
+
if (operator === "leftJoin" || operator === "fullJoin")
|
|
319
|
+
nullable.add(rightTable.aliased);
|
|
320
|
+
return new JoinSelection([this.table, right], nullable);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
var JoinSelection = class _JoinSelection extends Selection {
|
|
324
|
+
constructor(tables, nullable) {
|
|
325
|
+
super(
|
|
326
|
+
Object.fromEntries(tables.map((table) => [getTable(table).aliased, table])),
|
|
327
|
+
nullable
|
|
328
|
+
);
|
|
329
|
+
this.tables = tables;
|
|
330
|
+
}
|
|
331
|
+
tables;
|
|
332
|
+
join(right, operator) {
|
|
333
|
+
if (!hasTable(right)) return this;
|
|
334
|
+
const rightTable = getTable(right);
|
|
335
|
+
const nullable = new Set(this.nullable);
|
|
336
|
+
if (operator === "rightJoin" || operator === "fullJoin")
|
|
337
|
+
for (const table of this.tables) nullable.add(getTable(table).aliased);
|
|
338
|
+
if (operator === "leftJoin" || operator === "fullJoin")
|
|
339
|
+
nullable.add(rightTable.aliased);
|
|
340
|
+
return new _JoinSelection([...this.tables, right], nullable);
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
var StarSelection = class extends Selection {
|
|
344
|
+
get [internalSql]() {
|
|
345
|
+
return sql`*`;
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
var selected = /* @__PURE__ */ new WeakMap();
|
|
349
|
+
function selection(input) {
|
|
350
|
+
if (input instanceof Selection) return input;
|
|
351
|
+
if (selected.has(input)) return selected.get(input);
|
|
352
|
+
const selection2 = hasTable(input) ? new TableSelection(input) : new Selection(input);
|
|
353
|
+
selected.set(input, selection2);
|
|
354
|
+
return selection2;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export {
|
|
358
|
+
Field,
|
|
359
|
+
virtualTarget,
|
|
360
|
+
StarSelection,
|
|
361
|
+
selection,
|
|
362
|
+
Index,
|
|
363
|
+
index
|
|
364
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ReusedStatement,
|
|
3
|
+
StatementCache,
|
|
4
|
+
execTransaction,
|
|
5
|
+
sqliteDialect,
|
|
6
|
+
sqliteDiff
|
|
7
|
+
} from "./chunk-AIU6CMVT.js";
|
|
8
|
+
import {
|
|
9
|
+
Batch,
|
|
10
|
+
SyncDatabase
|
|
11
|
+
} from "./chunk-N47Y62CI.js";
|
|
12
|
+
|
|
13
|
+
// node_modules/rado/dist/driver/sql.js.js
|
|
14
|
+
var PreparedStatement = class extends ReusedStatement {
|
|
15
|
+
constructor(client, statements, sql) {
|
|
16
|
+
super(statements, sql);
|
|
17
|
+
this.client = client;
|
|
18
|
+
}
|
|
19
|
+
client;
|
|
20
|
+
*iterate(params) {
|
|
21
|
+
this.stmt.bind(params);
|
|
22
|
+
while (this.stmt.step()) yield this.stmt.getAsObject();
|
|
23
|
+
this.stmt.reset();
|
|
24
|
+
}
|
|
25
|
+
*iterateValues(params) {
|
|
26
|
+
this.stmt.bind(params);
|
|
27
|
+
while (this.stmt.step()) yield this.stmt.get();
|
|
28
|
+
this.stmt.reset();
|
|
29
|
+
}
|
|
30
|
+
all(params) {
|
|
31
|
+
return Array.from(this.iterate(params));
|
|
32
|
+
}
|
|
33
|
+
run(params) {
|
|
34
|
+
this.stmt.run(params);
|
|
35
|
+
this.stmt.reset();
|
|
36
|
+
return { affectedRows: this.client.getRowsModified() };
|
|
37
|
+
}
|
|
38
|
+
get(params) {
|
|
39
|
+
return this.all(params)[0] ?? null;
|
|
40
|
+
}
|
|
41
|
+
values(params) {
|
|
42
|
+
return Array.from(this.iterateValues(params));
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var SqlJsDriver = class _SqlJsDriver {
|
|
46
|
+
constructor(client, depth = 0, statements = new StatementCache(
|
|
47
|
+
(sql) => client.prepare(sql),
|
|
48
|
+
(stmt) => stmt.free()
|
|
49
|
+
)) {
|
|
50
|
+
this.client = client;
|
|
51
|
+
this.depth = depth;
|
|
52
|
+
this.statements = statements;
|
|
53
|
+
}
|
|
54
|
+
client;
|
|
55
|
+
depth;
|
|
56
|
+
statements;
|
|
57
|
+
parsesJson = false;
|
|
58
|
+
supportsTransactions = true;
|
|
59
|
+
exec(query) {
|
|
60
|
+
this.statements.invalidate(query);
|
|
61
|
+
this.client.exec(query);
|
|
62
|
+
}
|
|
63
|
+
close() {
|
|
64
|
+
this.statements.clear();
|
|
65
|
+
this.client.close();
|
|
66
|
+
}
|
|
67
|
+
prepare(sql) {
|
|
68
|
+
return new PreparedStatement(this.client, this.statements, sql);
|
|
69
|
+
}
|
|
70
|
+
batch(queries) {
|
|
71
|
+
return this.transaction((tx) => Batch.run(tx, queries), {});
|
|
72
|
+
}
|
|
73
|
+
transaction(run, options) {
|
|
74
|
+
return execTransaction(
|
|
75
|
+
this,
|
|
76
|
+
this.depth,
|
|
77
|
+
(depth) => new _SqlJsDriver(this.client, depth, this.statements),
|
|
78
|
+
run,
|
|
79
|
+
options
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
function connect(db, options) {
|
|
84
|
+
return new SyncDatabase(
|
|
85
|
+
new SqlJsDriver(db),
|
|
86
|
+
sqliteDialect,
|
|
87
|
+
sqliteDiff,
|
|
88
|
+
options
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export {
|
|
93
|
+
connect
|
|
94
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
callFunction
|
|
3
|
+
} from "./chunk-K62JP6HR.js";
|
|
4
|
+
import {
|
|
5
|
+
getSql,
|
|
6
|
+
sql
|
|
7
|
+
} from "./chunk-ETBQTP2S.js";
|
|
8
|
+
|
|
9
|
+
// node_modules/rado/dist/core/expr/Json.js
|
|
10
|
+
var INDEX_PROPERTY = /^\d+$/;
|
|
11
|
+
function jsonExpr(e) {
|
|
12
|
+
return new Proxy(e, {
|
|
13
|
+
get(target, prop) {
|
|
14
|
+
if (typeof prop !== "string") return Reflect.get(target, prop);
|
|
15
|
+
const isNumber = INDEX_PROPERTY.test(prop);
|
|
16
|
+
return jsonExpr(
|
|
17
|
+
sql.jsonPath({
|
|
18
|
+
target: getSql(target),
|
|
19
|
+
segments: [isNumber ? Number(prop) : prop],
|
|
20
|
+
asSql: true
|
|
21
|
+
}).mapWith({
|
|
22
|
+
mapFromDriverValue(value, specs) {
|
|
23
|
+
return specs.parsesJson ? value : JSON.parse(value);
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function jsonAggregateArray(...args) {
|
|
31
|
+
return callFunction(
|
|
32
|
+
sql.universal({
|
|
33
|
+
// Once sqlite 3.45+ is more commonplace we can use jsonb_group_array
|
|
34
|
+
sqlite: sql`json_group_array`,
|
|
35
|
+
postgres: sql`jsonb_agg`,
|
|
36
|
+
mysql: sql`json_arrayagg`
|
|
37
|
+
}),
|
|
38
|
+
args
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
function jsonArray(...args) {
|
|
42
|
+
return callFunction(
|
|
43
|
+
sql.universal({
|
|
44
|
+
postgres: sql`jsonb_build_array`,
|
|
45
|
+
default: sql`json_array`
|
|
46
|
+
}),
|
|
47
|
+
args
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
jsonExpr,
|
|
53
|
+
jsonAggregateArray,
|
|
54
|
+
jsonArray
|
|
55
|
+
};
|