@niyamulahsan/create-deskapp 1.2.5 → 1.2.6
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/package.json +1 -1
- package/template/.env.example +20 -13
- package/template/AGENTS.md +699 -0
- package/template/package.json +3 -0
- package/template/src/config/app.ts +26 -24
- package/template/src/config/winsetup.ts +93 -91
- package/template/src/core/api/binding-error.ts +57 -0
- package/template/src/core/api/bindings.generated.ts +2 -0
- package/template/src/core/api/generate.manifest.ts +84 -80
- package/template/src/core/api/registry.ts +58 -48
- package/template/src/core/config.ts +101 -99
- package/template/src/core/database/aggregate.ts +89 -85
- package/template/src/core/database/config.ts +50 -48
- package/template/src/core/database/connection.ts +116 -114
- package/template/src/core/database/migrate-hooks.ts +86 -84
- package/template/src/core/database/paginate.ts +226 -224
- package/template/src/core/database/reset.ts +21 -19
- package/template/src/core/database/seed.ts +169 -167
- package/template/src/core/database/status.ts +37 -35
- package/template/src/core/env.ts +108 -106
- package/template/src/core/facade.ts +63 -61
- package/template/src/core/maker/db/fresh.ts +10 -8
- package/template/src/core/maker/db/generate.ts +13 -11
- package/template/src/core/maker/db/helpers.ts +92 -96
- package/template/src/core/maker/db/migrate.ts +37 -35
- package/template/src/core/maker/db/mod.ts +93 -91
- package/template/src/core/maker/db/module-migrate.ts +56 -54
- package/template/src/core/maker/db/push.ts +23 -21
- package/template/src/core/maker/db/reset.ts +8 -6
- package/template/src/core/maker/db/seed.ts +9 -7
- package/template/src/core/maker/db/status.ts +8 -6
- package/template/src/core/maker/help.ts +59 -57
- package/template/src/core/maker/make/controller.ts +25 -22
- package/template/src/core/maker/make/helpers.ts +97 -91
- package/template/src/core/maker/make/mod.ts +69 -67
- package/template/src/core/maker/make/model.ts +16 -14
- package/template/src/core/maker/make/module.ts +53 -39
- package/template/src/core/maker/make/seeder.ts +23 -21
- package/template/src/core/maker/make/test.ts +33 -30
- package/template/src/core/maker/mod.ts +85 -83
- package/template/src/core/maker/run/mod.ts +134 -132
- package/template/src/core/maker/stub.ts +26 -24
- package/template/src/core/maker/stubs/controller/controller.controller.stub +57 -55
- package/template/src/core/maker/stubs/controller/controller.schema.stub +18 -13
- package/template/src/core/maker/stubs/facade/facade.stub +21 -0
- package/template/src/core/maker/stubs/model/model.stub +10 -8
- package/template/src/core/maker/stubs/seeder/seeder.stub +18 -16
- package/template/src/core/maker/stubs/test/test.stub +9 -7
- package/template/src/core/maker/sync-config.ts +93 -94
- package/template/src/core/utils/password.ts +29 -27
- package/template/src/core/utils/playwright.ts +123 -121
- package/template/src/core/utils/queue.ts +68 -66
- package/template/src/core/utils/scheduler.ts +62 -60
- package/template/src/core/utils/storage.ts +3 -1
- package/template/src/core/utils/validation.ts +37 -35
- package/template/src/database/schema.ts +2 -0
- package/template/src/main.ts +120 -118
- package/template/src/modules/app/__tests__/demo.controller.test.ts +75 -0
- package/template/src/modules/app/__tests__/net.controller.test.ts +65 -0
- package/template/src/modules/app/__tests__/playwright.controller.test.ts +50 -0
- package/template/src/modules/app/__tests__/storage.controller.test.ts +114 -0
- package/template/src/modules/app/__tests__/window.controller.test.ts +98 -0
- package/template/src/modules/app/controllers/demo.controller.ts +120 -118
- package/template/src/modules/app/controllers/net.controller.ts +50 -48
- package/template/src/modules/app/controllers/playwright.controller.ts +142 -140
- package/template/src/modules/app/controllers/storage.controller.ts +231 -229
- package/template/src/modules/app/controllers/window.controller.ts +2 -0
- package/template/src/modules/app/facade.ts +21 -0
- package/template/src/preload.ts +25 -2
- package/template/src/ui/src/App.vue +4 -2
- package/template/src/ui/src/app.ts +38 -23
- package/template/src/ui/src/bindings.d.ts +18 -16
- package/template/src/ui/src/components/Button.vue +34 -32
- package/template/src/ui/src/components/Checkbox.vue +26 -29
- package/template/src/ui/src/components/Input.vue +221 -227
- package/template/src/ui/src/components/InputGroup.vue +141 -0
- package/template/src/ui/src/components/InputPasswordToggle.vue +204 -0
- package/template/src/ui/src/components/Modal.vue +65 -55
- package/template/src/ui/src/components/Spinner.vue +44 -42
- package/template/src/ui/src/components/Switch.vue +62 -65
- package/template/src/ui/src/components/TextArea.vue +108 -121
- package/template/src/ui/src/components/Toast.vue +55 -56
- package/template/src/ui/src/components/datatable/DataTableSkeleton.vue +100 -98
- package/template/src/ui/src/components/datatable/Pagination.vue +153 -125
- package/template/src/ui/src/components/datatable/SelectOpption.vue +36 -35
- package/template/src/ui/src/components/datatable/index.vue +336 -258
- package/template/src/ui/src/env.d.ts +16 -13
- package/template/src/ui/src/global.d.ts +21 -2
- package/template/src/ui/src/helpers/nformatter.ts +12 -10
- package/template/src/ui/src/pages/dashboard/index.vue +690 -687
- package/template/src/ui/src/plugins/browserDetect.ts +57 -0
- package/template/src/ui/src/plugins/gum.ts +576 -549
- package/template/src/ui/src/plugins/pulse.ts +2 -0
- package/template/src/ui/src/plugins/routeProgress.ts +89 -0
- package/template/src/ui/src/router/index.ts +44 -25
- package/template/src/ui/src/stores/example.ts +2 -0
- package/template/src/ui/vite.config.ts +40 -38
- package/template/src/window/app-menu.ts +89 -87
- package/template/src/window/config.ts +14 -12
- package/template/src/window/context-menu.ts +23 -21
- package/template/src/window/dialogs.ts +92 -90
- package/template/src/window/manager.ts +2 -0
- package/template/src/window/native.ts +47 -45
- package/template/src/window/tray.ts +132 -130
|
@@ -1,224 +1,226 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* await paginate.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
*
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
*
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if (options.
|
|
215
|
-
if (options.
|
|
216
|
-
if (options.
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
1
|
+
// ./src/core/database/paginate.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* database/paginate.ts - nexgen-style pagination, mirroring nexgen's
|
|
5
|
+
* framework/database/paginate.ts but without a request/HTTP context (bindings
|
|
6
|
+
* call handlers directly, so pagination here is callback- or table-based).
|
|
7
|
+
*
|
|
8
|
+
* Core is `paginate.query`: it normalizes page/per_page, clamps with
|
|
9
|
+
* maxPerPage, computes URL meta + links, then runs the caller's
|
|
10
|
+
* `total()` and `data(limit, offset)` callbacks. Import from the facade:
|
|
11
|
+
*
|
|
12
|
+
* import { paginate } from "@/core/facade.ts";
|
|
13
|
+
* await paginate.table(schema.users, { page: 2 });
|
|
14
|
+
* await paginate.query({ total, data });
|
|
15
|
+
* await paginate.model({ table: schema.users, query: db.query.users });
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { count, getTableColumns, type SQL, sql } from "drizzle-orm";
|
|
19
|
+
import type { SQLiteTable } from "drizzle-orm/sqlite-core";
|
|
20
|
+
import { db } from "@/core/facade";
|
|
21
|
+
|
|
22
|
+
export type PaginateInput = {
|
|
23
|
+
page?: number;
|
|
24
|
+
perPage?: number;
|
|
25
|
+
maxPerPage?: number;
|
|
26
|
+
path?: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type PaginatedResult<T> = {
|
|
30
|
+
current_page: number;
|
|
31
|
+
data: T[];
|
|
32
|
+
first_page_url: string | null;
|
|
33
|
+
from: number | null;
|
|
34
|
+
last_page: number;
|
|
35
|
+
last_page_url: string | null;
|
|
36
|
+
next_page_url: string | null;
|
|
37
|
+
path: string;
|
|
38
|
+
per_page: number;
|
|
39
|
+
prev_page_url: string | null;
|
|
40
|
+
to: number | null;
|
|
41
|
+
total: number;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type PaginateQueryOptions<T> = PaginateInput & {
|
|
45
|
+
total: () => Promise<number>;
|
|
46
|
+
data: (limit: number, offset: number) => Promise<T[]>;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type PaginateTableOptions = PaginateInput & {
|
|
50
|
+
where?: SQL<unknown>;
|
|
51
|
+
orderBy?: unknown[];
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type PaginateModelOptions<T = unknown> = PaginateInput & {
|
|
55
|
+
table?: SQLiteTable;
|
|
56
|
+
query?: { findMany: (args: Record<string, unknown>) => Promise<T[]> };
|
|
57
|
+
where?: SQL<unknown>;
|
|
58
|
+
with?: Record<string, unknown>;
|
|
59
|
+
columns?: Record<string, unknown>;
|
|
60
|
+
extras?: Record<string, unknown>;
|
|
61
|
+
orderBy?: unknown;
|
|
62
|
+
total?: () => Promise<number>;
|
|
63
|
+
data?: (params: { limit: number; offset: number }) => Promise<T[]>;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
function toPositiveInt(value: unknown, fallback: number): number {
|
|
67
|
+
const parsed = Number(value);
|
|
68
|
+
if (!Number.isFinite(parsed) || parsed < 1) return fallback;
|
|
69
|
+
return Math.floor(parsed);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function pageUrl(path: string | undefined, page: number, perPage: number): string | null {
|
|
73
|
+
if (!path) return null;
|
|
74
|
+
const delimiter = path.includes("?") ? "&" : "?";
|
|
75
|
+
return `${path}${delimiter}page=${page}&per_page=${perPage}`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Pagination namespace - nexgen-style envelope for Drizzle, surfaced through
|
|
80
|
+
* the facade. Access: `paginate.query`, `paginate.table`, `paginate.model`.
|
|
81
|
+
*/
|
|
82
|
+
export const paginate = {
|
|
83
|
+
/**
|
|
84
|
+
* Generic paginator for custom `total()`/`data(limit, offset)` callbacks.
|
|
85
|
+
* Controllers/services compose any query (joins, filters, aggregates) and
|
|
86
|
+
* get a consistent nexgen-style envelope back.
|
|
87
|
+
*/
|
|
88
|
+
query<T = unknown>(options: PaginateQueryOptions<T>): Promise<PaginatedResult<T>> {
|
|
89
|
+
return paginateQuery<T>(options);
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Paginates a full Drizzle table with optional `where` filter and `orderBy`.
|
|
94
|
+
* Runs a count query plus the paged select. table must be a SCHEMA table
|
|
95
|
+
* object: `import * as schema from "@/database/schema.ts"` then `schema.users`.
|
|
96
|
+
*/
|
|
97
|
+
table<T = unknown>(table: SQLiteTable, options: PaginateTableOptions = {}): Promise<PaginatedResult<T>> {
|
|
98
|
+
return paginateTable<T>(table, options);
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* nexgen-style pagination for Drizzle RELATIONAL queries - mirrors nexgen's
|
|
103
|
+
* paginateModel. Counts via `table` (+ `where`), then pages through
|
|
104
|
+
* `db.query.<table>.findMany({ limit, offset, where, with, columns, extras,
|
|
105
|
+
* orderBy })` for eager-loaded resources.
|
|
106
|
+
*/
|
|
107
|
+
model<T = unknown>(options: PaginateModelOptions<T>): Promise<PaginatedResult<T>> {
|
|
108
|
+
return paginateModel<T>(options);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/** Generic paginator for custom `total()`/`data(limit, offset)` callbacks. */
|
|
113
|
+
async function paginateQuery<T = unknown>(options: PaginateQueryOptions<T>): Promise<PaginatedResult<T>> {
|
|
114
|
+
const maxPerPage = toPositiveInt(options.maxPerPage, 100);
|
|
115
|
+
const perPage = Math.min(toPositiveInt(options.perPage, 15), maxPerPage);
|
|
116
|
+
const page = toPositiveInt(options.page, 1);
|
|
117
|
+
|
|
118
|
+
const total = Number(await options.total());
|
|
119
|
+
const lastPage = Math.max(1, Math.ceil(total / perPage));
|
|
120
|
+
const currentPage = Math.min(page, lastPage);
|
|
121
|
+
const safeOffset = (currentPage - 1) * perPage;
|
|
122
|
+
const data = await options.data(perPage, safeOffset);
|
|
123
|
+
|
|
124
|
+
const from = total === 0 ? null : safeOffset + 1;
|
|
125
|
+
const to = total === 0 ? null : safeOffset + data.length;
|
|
126
|
+
const path = options.path || "";
|
|
127
|
+
const firstPageUrl = pageUrl(path, 1, perPage);
|
|
128
|
+
const lastPageUrl = pageUrl(path, lastPage, perPage);
|
|
129
|
+
const prevPageUrl = currentPage > 1 ? pageUrl(path, currentPage - 1, perPage) : null;
|
|
130
|
+
const nextPageUrl = currentPage < lastPage ? pageUrl(path, currentPage + 1, perPage) : null;
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
current_page: currentPage,
|
|
134
|
+
data,
|
|
135
|
+
first_page_url: firstPageUrl,
|
|
136
|
+
from,
|
|
137
|
+
last_page: lastPage,
|
|
138
|
+
last_page_url: lastPageUrl,
|
|
139
|
+
next_page_url: nextPageUrl,
|
|
140
|
+
path,
|
|
141
|
+
per_page: perPage,
|
|
142
|
+
prev_page_url: prevPageUrl,
|
|
143
|
+
to,
|
|
144
|
+
total
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Paginates a full Drizzle table with optional `where` filter and `orderBy`. */
|
|
149
|
+
function paginateTable<T = unknown>(table: SQLiteTable, options: PaginateTableOptions = {}): Promise<PaginatedResult<T>> {
|
|
150
|
+
return paginateQuery<T>({
|
|
151
|
+
page: options.page,
|
|
152
|
+
perPage: options.perPage,
|
|
153
|
+
maxPerPage: options.maxPerPage,
|
|
154
|
+
path: options.path,
|
|
155
|
+
total: async () => {
|
|
156
|
+
// deno-lint-ignore no-explicit-any
|
|
157
|
+
let totalQuery: any = db.select({ total: count() }).from(table);
|
|
158
|
+
if (options.where) totalQuery = totalQuery.where(options.where);
|
|
159
|
+
const totalRow = await totalQuery;
|
|
160
|
+
return Number(totalRow[0]?.total ?? 0);
|
|
161
|
+
},
|
|
162
|
+
data: (limit, offset) => {
|
|
163
|
+
// deno-lint-ignore no-explicit-any
|
|
164
|
+
let dataQuery: any = db.select(getTableColumns(table)).from(table);
|
|
165
|
+
if (options.where) dataQuery = dataQuery.where(options.where);
|
|
166
|
+
if (options.orderBy?.length) dataQuery = dataQuery.orderBy(...options.orderBy);
|
|
167
|
+
return dataQuery.limit(limit).offset(offset);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* nexgen-style pagination for Drizzle RELATIONAL queries - mirrors nexgen's
|
|
174
|
+
* paginateModel. Counts via `table` (+ `where`), then pages through
|
|
175
|
+
* `db.query.<table>.findMany({ limit, offset, where, with, columns, extras,
|
|
176
|
+
* orderBy })` for eager-loaded resources.
|
|
177
|
+
*
|
|
178
|
+
* Supply either callbacks (`total`/`data`) or the declarative pair
|
|
179
|
+
* (`table` + `query`) - the same fallbacks engine uses:
|
|
180
|
+
*
|
|
181
|
+
* import * as schema from "@/database/schema.ts";
|
|
182
|
+
* const page = await paginate.model({
|
|
183
|
+
* page: 2, perPage: 15,
|
|
184
|
+
* table: schema.users,
|
|
185
|
+
* query: db.query.users,
|
|
186
|
+
* where: sql`active = true`,
|
|
187
|
+
* with: { posts: true },
|
|
188
|
+
* orderBy: (t, { desc }) => desc(t.createdAt),
|
|
189
|
+
* });
|
|
190
|
+
*/
|
|
191
|
+
function paginateModel<T = unknown>(options: PaginateModelOptions<T>): Promise<PaginatedResult<T>> {
|
|
192
|
+
return paginateQuery<T>({
|
|
193
|
+
page: options.page,
|
|
194
|
+
perPage: options.perPage,
|
|
195
|
+
maxPerPage: options.maxPerPage,
|
|
196
|
+
path: options.path,
|
|
197
|
+
total: async () => {
|
|
198
|
+
if (options.total) return Number(await options.total());
|
|
199
|
+
if (!options.table) {
|
|
200
|
+
throw new Error("paginate.model requires either table or total callback");
|
|
201
|
+
}
|
|
202
|
+
// deno-lint-ignore no-explicit-any
|
|
203
|
+
let totalQuery: any = db.select({ total: count() }).from(options.table);
|
|
204
|
+
if (options.where) totalQuery = totalQuery.where(options.where);
|
|
205
|
+
const [row] = await totalQuery;
|
|
206
|
+
return Number(row?.total ?? 0);
|
|
207
|
+
},
|
|
208
|
+
data: (limit, offset) => {
|
|
209
|
+
if (options.data) return options.data({ limit, offset });
|
|
210
|
+
if (!options.query) {
|
|
211
|
+
throw new Error("paginate.model requires either query or data callback");
|
|
212
|
+
}
|
|
213
|
+
const args: Record<string, unknown> = { limit, offset };
|
|
214
|
+
if (options.where) args.where = options.where;
|
|
215
|
+
if (options.with) args.with = options.with;
|
|
216
|
+
if (options.columns) args.columns = options.columns;
|
|
217
|
+
if (options.extras) args.extras = options.extras;
|
|
218
|
+
if (options.orderBy) args.orderBy = options.orderBy;
|
|
219
|
+
return options.query.findMany(args);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// `sql` is re-exported so callers writing `where: sql` filters don't need a
|
|
225
|
+
// second drizzle import: import { paginate, sql } from "@/core/facade.ts".
|
|
226
|
+
export { sql };
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
console.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
// ./src/core/database/reset.ts
|
|
2
|
+
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { sqliteFile } from "@/core/database/config";
|
|
6
|
+
|
|
7
|
+
const raw = sqliteFile();
|
|
8
|
+
const file = path.resolve(process.cwd(), raw);
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
fs.unlinkSync(file);
|
|
12
|
+
console.log(`[db:reset] removed database file: ${file}`);
|
|
13
|
+
} catch (error: any) {
|
|
14
|
+
if (error.code === "ENOENT") {
|
|
15
|
+
console.log(`[db:reset] no database file to remove: ${file}`);
|
|
16
|
+
} else {
|
|
17
|
+
console.error(`[db:reset] failed to remove database file: ${file}`);
|
|
18
|
+
console.error(error);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
}
|