@vite-hub/auth 0.0.4 → 0.3.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/README.md +443 -32
- package/dist/abilities-DfAnFYwG.d.ts +93 -0
- package/dist/abilities.d.ts +2 -0
- package/dist/abilities.js +43 -0
- package/dist/ability-error-CqgBrBfR.js +91 -0
- package/dist/ability-error-DcgChwCN.d.ts +34 -0
- package/dist/admin-claim-code-CDipqeAU.js +22 -0
- package/dist/agent.d.ts +23 -12
- package/dist/agent.js +30 -8
- package/dist/application-path-DuTpfGFj.js +62 -0
- package/dist/auth-instance-CR6b1W80.js +1168 -0
- package/dist/bun-sqlite.d.ts +8 -0
- package/dist/cli-ubYJpAL_.d.ts +163 -0
- package/dist/cli.d.ts +7 -0
- package/dist/cli.js +108 -0
- package/dist/console-runtime-DTopBP-x.d.ts +71 -0
- package/dist/console-runtime-J9_Vx9pT.js +1166 -0
- package/dist/console-runtime.d.ts +3 -0
- package/dist/console-runtime.js +2 -0
- package/dist/console-types-CmmnKGMx.js +38 -0
- package/dist/console.d.ts +219 -0
- package/dist/console.js +15 -0
- package/dist/database-options-BRNef9oy.js +29 -0
- package/dist/database-schema-options-ENuRMduM.js +12 -0
- package/dist/database.d.ts +12 -0
- package/dist/database.js +45 -0
- package/dist/definition-CqQMcDEK.js +280 -0
- package/dist/error-diagnostics-C8XtVz0i.js +138 -0
- package/dist/events-ByzenEVj.js +314 -0
- package/dist/forward.d.ts +50 -0
- package/dist/forward.js +120 -0
- package/dist/host-declarations.d.ts +6 -1
- package/dist/index.d.ts +26 -5
- package/dist/index.js +3 -95
- package/dist/internal/server.d.ts +5 -0
- package/dist/internal/server.js +858 -0
- package/dist/invariant-D8_xBqmZ.js +22 -0
- package/dist/mcp.d.ts +187 -0
- package/dist/mcp.js +353 -0
- package/dist/members-D9lfaEO_.js +533 -0
- package/dist/nuxt-bridge-Cl988STZ.js +44 -0
- package/dist/nuxt.d.ts +36 -7
- package/dist/nuxt.js +116 -7
- package/dist/object-Da1zyPCR.js +11 -0
- package/dist/page-tools-shared-l4eyj53D.js +19 -0
- package/dist/presets-BGZi6Dfu.d.ts +25 -0
- package/dist/presets.d.ts +2 -0
- package/dist/presets.js +32 -0
- package/dist/request-z6DHHmrb.js +47 -0
- package/dist/runtime/console.d.ts +3 -0
- package/dist/runtime/console.js +4 -0
- package/dist/runtime/empty-abilities.d.ts +5 -0
- package/dist/runtime/empty-abilities.js +4 -0
- package/dist/runtime/empty-client.d.ts +6 -0
- package/dist/runtime/empty-client.js +5 -0
- package/dist/runtime/empty-definition.d.ts +1 -2
- package/dist/runtime/nuxt.d.ts +2 -3
- package/dist/runtime/nuxt.js +3 -2
- package/dist/runtime/server.d.ts +2 -0
- package/dist/runtime/server.js +77 -0
- package/dist/runtime/vue-nuxt.d.ts +4 -0
- package/dist/runtime/vue-nuxt.js +160 -0
- package/dist/runtime-state-ojQCzKOc.js +25 -0
- package/dist/schema.d.ts +137 -0
- package/dist/schema.js +147 -0
- package/dist/server-C0qnKN2W.d.ts +143 -0
- package/dist/server-bQGzVQ--.d.ts +41 -0
- package/dist/server.d.ts +3 -22
- package/dist/server.js +3 -2
- package/dist/session-cookies-BbH3UR2m.js +227 -0
- package/dist/set-cookie-C8NOhdRE.js +90 -0
- package/dist/shared-BwcdRGxD.js +12 -0
- package/dist/table-specs-8gq_FCaq.js +771 -0
- package/dist/table-specs-DbXyaXWs.d.ts +842 -0
- package/dist/test.d.ts +26 -0
- package/dist/test.js +25 -0
- package/dist/types-CNaeH2Fd.d.ts +569 -0
- package/dist/vite-CV400XXY.js +1556 -0
- package/dist/vite.d.ts +145 -18
- package/dist/vite.js +2 -2
- package/dist/vue.d.ts +343 -17
- package/dist/vue.js +640 -15
- package/package.json +156 -27
- package/dist/server-BZn8iQrB.js +0 -370
- package/dist/shared-QSYBHaMG.js +0 -12
- package/dist/types-jaRlW3D1.d.ts +0 -117
- package/dist/vite-Cmey8ODS.js +0 -1018
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { $ as AuthConsoleField, G as AuthConsoleActivityQuery, J as AuthConsoleColumn, K as AuthConsoleAgent, Q as AuthConsoleEventUser, St as authConsoleEventGroups, U as AuthConsoleAction, W as AuthConsoleActivity, X as AuthConsoleEvent, Y as AuthConsoleDescription, Z as AuthConsoleEventGroup, _t as AuthConsoleSessionUser, at as AuthConsoleImpersonation, bt as AuthConsoleValue, ct as AuthConsoleOptions, dt as AuthConsoleOverview, et as AuthConsoleFieldPolicy, ft as AuthConsolePage, gt as AuthConsoleSession, ht as AuthConsoleRoles, it as AuthConsoleHostUserInput, lt as AuthConsoleOrganization, mt as AuthConsoleQuery, nt as AuthConsoleHostOptions, ot as AuthConsoleList, pt as AuthConsolePolicy, q as AuthConsoleCapability, rt as AuthConsoleHostSession, st as AuthConsoleMutation, tt as AuthConsoleFieldType, ut as AuthConsoleOrganizationDetail, vt as AuthConsoleUser, xt as authConsoleActionNames, yt as AuthConsoleUserDetail } from "./types-CNaeH2Fd.js";
|
|
2
|
+
import { i as describeAuthConsoleFields, n as AuthConsoleErrorCode, r as createAuthConsole, t as AuthConsole } from "./console-runtime-DTopBP-x.js";
|
|
3
|
+
export { AuthConsole, type AuthConsoleAction, type AuthConsoleActivity, type AuthConsoleActivityQuery, type AuthConsoleAgent, type AuthConsoleCapability, type AuthConsoleColumn, type AuthConsoleDescription, AuthConsoleErrorCode, type AuthConsoleEvent, type AuthConsoleEventGroup, type AuthConsoleEventUser, type AuthConsoleField, type AuthConsoleFieldPolicy, type AuthConsoleFieldType, type AuthConsoleHostOptions, type AuthConsoleHostSession, type AuthConsoleHostUserInput, type AuthConsoleImpersonation, type AuthConsoleList, type AuthConsoleMutation, type AuthConsoleOptions, type AuthConsoleOrganization, type AuthConsoleOrganizationDetail, type AuthConsoleOverview, type AuthConsolePage, type AuthConsolePolicy, type AuthConsoleQuery, type AuthConsoleRoles, type AuthConsoleSession, type AuthConsoleSessionUser, type AuthConsoleUser, type AuthConsoleUserDetail, type AuthConsoleValue, type authConsoleActionNames, type authConsoleEventGroups, createAuthConsole, describeAuthConsoleFields };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region src/console-types.ts
|
|
2
|
+
const authConsoleEventGroups = {
|
|
3
|
+
"sign-in": [
|
|
4
|
+
"user.signed_up",
|
|
5
|
+
"user.signed_in",
|
|
6
|
+
"user.signed_out",
|
|
7
|
+
"sign_in.failed"
|
|
8
|
+
],
|
|
9
|
+
admin: [
|
|
10
|
+
"session.revoked",
|
|
11
|
+
"user.banned",
|
|
12
|
+
"user.unbanned",
|
|
13
|
+
"user.role_changed",
|
|
14
|
+
"user.updated",
|
|
15
|
+
"user.removed",
|
|
16
|
+
"impersonation.started",
|
|
17
|
+
"impersonation.stopped"
|
|
18
|
+
],
|
|
19
|
+
agents: ["oauth.consent_granted", "oauth.consent_revoked"],
|
|
20
|
+
organizations: [
|
|
21
|
+
"organization.member_added",
|
|
22
|
+
"organization.member_removed",
|
|
23
|
+
"organization.member_role_changed"
|
|
24
|
+
]
|
|
25
|
+
};
|
|
26
|
+
const authConsoleActionNames = [
|
|
27
|
+
"ban",
|
|
28
|
+
"unban",
|
|
29
|
+
"remove",
|
|
30
|
+
"revokeSession",
|
|
31
|
+
"revokeSessions",
|
|
32
|
+
"setRole",
|
|
33
|
+
"editField",
|
|
34
|
+
"impersonate",
|
|
35
|
+
"revokeConsent"
|
|
36
|
+
];
|
|
37
|
+
//#endregion
|
|
38
|
+
export { authConsoleEventGroups as n, authConsoleActionNames as t };
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { $ as AuthConsoleField, G as AuthConsoleActivityQuery, J as AuthConsoleColumn, K as AuthConsoleAgent, Q as AuthConsoleEventUser, St as authConsoleEventGroups, U as AuthConsoleAction, W as AuthConsoleActivity, X as AuthConsoleEvent, Y as AuthConsoleDescription, Z as AuthConsoleEventGroup, _t as AuthConsoleSessionUser, at as AuthConsoleImpersonation, bt as AuthConsoleValue, ct as AuthConsoleOptions, dt as AuthConsoleOverview, et as AuthConsoleFieldPolicy, ft as AuthConsolePage, gt as AuthConsoleSession, ht as AuthConsoleRoles, it as AuthConsoleHostUserInput, lt as AuthConsoleOrganization, mt as AuthConsoleQuery, nt as AuthConsoleHostOptions, ot as AuthConsoleList, pt as AuthConsolePolicy, q as AuthConsoleCapability, rt as AuthConsoleHostSession, st as AuthConsoleMutation, tt as AuthConsoleFieldType, ut as AuthConsoleOrganizationDetail, vt as AuthConsoleUser, xt as authConsoleActionNames, yt as AuthConsoleUserDetail } from "./types-CNaeH2Fd.js";
|
|
2
|
+
//#region ../internal/src/console.d.ts
|
|
3
|
+
/** Lists discovered Definitions in a sidebar and shows the selected Definition's fields. */
|
|
4
|
+
interface ViteHubConsoleDefinitionCatalogView {
|
|
5
|
+
kind: "definition-catalog";
|
|
6
|
+
/** States which runtime data this catalog does not include. */
|
|
7
|
+
notice: string;
|
|
8
|
+
}
|
|
9
|
+
/** Lists Workspace Definitions like a catalog, and browses the refs, revisions, and files of the selected one. */
|
|
10
|
+
interface ViteHubConsoleWorkspaceBrowserView {
|
|
11
|
+
kind: "workspace-browser";
|
|
12
|
+
/** States which runtime data the browser does not include. */
|
|
13
|
+
notice: string;
|
|
14
|
+
}
|
|
15
|
+
interface ViteHubConsoleRecordColumn {
|
|
16
|
+
/** Set it for a column with few values, such as a status. The Console then filters the table by its values. */
|
|
17
|
+
filter?: boolean;
|
|
18
|
+
/** Key in `ViteHubConsoleRecord.cells`. */
|
|
19
|
+
key: string;
|
|
20
|
+
label: string;
|
|
21
|
+
}
|
|
22
|
+
/** Shows records in a table and the selected record's fields in a detail panel. */
|
|
23
|
+
interface ViteHubConsoleRecordTableView {
|
|
24
|
+
columns: readonly ViteHubConsoleRecordColumn[];
|
|
25
|
+
kind: "record-table";
|
|
26
|
+
/** States the source and limits of the records. */
|
|
27
|
+
notice: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Lists the collections and documents of an owner runtime and edits them with owner actions: a form generated from each
|
|
31
|
+
* collection's JSON Schema, a Markdown body, save, publish, and revision history.
|
|
32
|
+
*/
|
|
33
|
+
interface ViteHubConsoleDocumentEditorView {
|
|
34
|
+
kind: "document-editor";
|
|
35
|
+
/** States where documents are stored and what the editor does not do. */
|
|
36
|
+
notice: string;
|
|
37
|
+
}
|
|
38
|
+
interface ViteHubConsoleOperationColumn {
|
|
39
|
+
/** Dot path into each item of the result, such as `author.name` or `messages.0.body`. */
|
|
40
|
+
key: string;
|
|
41
|
+
label: string;
|
|
42
|
+
/**
|
|
43
|
+
* `datetime` shows a time in milliseconds since the epoch as a relative date, such as `5m ago`. `excerpt` cuts a long
|
|
44
|
+
* text. `status` shows the value as a status with a colored dot, such as `Open`. `tones` picks the color of each value.
|
|
45
|
+
* `switch` shows a boolean as a switch that calls the `switch` operation.
|
|
46
|
+
*/
|
|
47
|
+
format?: "datetime" | "excerpt" | "status" | "switch";
|
|
48
|
+
/** The color of each value of a `status` column, such as `{ open: "info", resolved: "success" }`. Other values are neutral. */
|
|
49
|
+
tones?: Readonly<Record<string, "error" | "info" | "neutral" | "success" | "warning">>;
|
|
50
|
+
/**
|
|
51
|
+
* What a `switch` column calls when the user flips it: `operation` with an input that maps each key of `input` to a
|
|
52
|
+
* dot path of the item, and the column `key` to the new value. `{ operation: "skills.set", input: { name: "name" } }`
|
|
53
|
+
* on the column `enabled` calls `skills.set` with `{ name, enabled }`, then loads the list again. A user who may only
|
|
54
|
+
* read the section sees the switch disabled.
|
|
55
|
+
*/
|
|
56
|
+
switch?: {
|
|
57
|
+
operation: string;
|
|
58
|
+
input: Readonly<Record<string, string>>;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A button on each row that calls `operation` with the Console user, then loads the list again. `input` maps each input
|
|
63
|
+
* key to a dot path of the item, as a `switch` column does.
|
|
64
|
+
*/
|
|
65
|
+
interface ViteHubConsoleOperationAction {
|
|
66
|
+
label: string;
|
|
67
|
+
operation: string;
|
|
68
|
+
input: Readonly<Record<string, string>>;
|
|
69
|
+
/**
|
|
70
|
+
* The result is `{ url }`, such as a one-time link or a provider sign-in: the Console opens it in a new tab, and loads
|
|
71
|
+
* the list again when the person comes back. The URL must be `https:`, or `http:` on a loopback host.
|
|
72
|
+
*/
|
|
73
|
+
tab?: true;
|
|
74
|
+
/** Show the button only on rows where each dot path holds one of the listed values. */
|
|
75
|
+
when?: Readonly<Record<string, readonly string[]>>;
|
|
76
|
+
/** Ask this question before the call. `{path}` takes a value from the item. */
|
|
77
|
+
confirm?: string;
|
|
78
|
+
}
|
|
79
|
+
/** A chip above the list. Choosing it merges `input` into the operation input. The first chip is the default. */
|
|
80
|
+
interface ViteHubConsoleOperationFilter {
|
|
81
|
+
id: string;
|
|
82
|
+
label: string;
|
|
83
|
+
input: Readonly<Record<string, unknown>>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Lists the items that an operation returns, called over the Console RPC with the signed-in Console user. The operation
|
|
87
|
+
* checks the access of that user for each item, so the view shows only what the user may read. `operation` must return an
|
|
88
|
+
* array of objects with an `id`. A failure of the operation, with its `fix`, shows where the list would be.
|
|
89
|
+
*/
|
|
90
|
+
interface ViteHubConsoleOperationView {
|
|
91
|
+
/** Buttons on each row. A user who may only read the section does not see them. */
|
|
92
|
+
actions?: readonly ViteHubConsoleOperationAction[];
|
|
93
|
+
columns: readonly ViteHubConsoleOperationColumn[];
|
|
94
|
+
/**
|
|
95
|
+
* Opens the item of a row in a side panel. `comment-thread` shows an item of `comments.list` as a comment thread
|
|
96
|
+
* where the user reads, replies, resolves, reopens, and mentions people. The panel calls the `comments.*` operations
|
|
97
|
+
* with the Console user, and `?thread=<id>` in the URL opens it.
|
|
98
|
+
*/
|
|
99
|
+
detail?: {
|
|
100
|
+
kind: "comment-thread";
|
|
101
|
+
};
|
|
102
|
+
filters?: readonly ViteHubConsoleOperationFilter[];
|
|
103
|
+
kind: "operation-view";
|
|
104
|
+
/**
|
|
105
|
+
* Makes each row a link: `{path}` placeholders take values from the item and are URL-encoded, and `{path:path}` takes an
|
|
106
|
+
* app path and encodes each segment (a value that is not an app path, such as `//evil.com/x`, gives no link).
|
|
107
|
+
* `{path:href}` takes an app URL that is already encoded, with its query, as it is. Rows where `when.path` is not
|
|
108
|
+
* `when.equals` get none.
|
|
109
|
+
*/
|
|
110
|
+
link?: {
|
|
111
|
+
label?: string;
|
|
112
|
+
template: string;
|
|
113
|
+
when?: {
|
|
114
|
+
equals: string;
|
|
115
|
+
path: string;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
notice: string;
|
|
119
|
+
/** Operation name, such as `comments.list`. */
|
|
120
|
+
operation: string;
|
|
121
|
+
/** Fetch every page with `limit` and a `before` object whose keys read these dot paths from the last item. */
|
|
122
|
+
pagination?: {
|
|
123
|
+
limit: number;
|
|
124
|
+
cursor: Readonly<Record<string, string>>;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
interface ViteHubConsoleAuthView {
|
|
128
|
+
kind: "auth-management";
|
|
129
|
+
notice: string;
|
|
130
|
+
}
|
|
131
|
+
interface ViteHubConsoleAuthSection extends ViteHubConsoleSectionDescriptor<ViteHubConsoleAuthView> {}
|
|
132
|
+
/**
|
|
133
|
+
* The webhooks of the app, their pending debounce timers, and their delivery log. The Console calls the `webhooks.*`
|
|
134
|
+
* operations of `@vite-hub/webhooks` with the Console user to list them, send a test, send a pending delivery now,
|
|
135
|
+
* cancel it, and redeliver. It has no build-time data.
|
|
136
|
+
*/
|
|
137
|
+
interface ViteHubConsoleWebhooksView {
|
|
138
|
+
kind: "webhooks";
|
|
139
|
+
notice: string;
|
|
140
|
+
}
|
|
141
|
+
type ViteHubConsoleSectionView = ViteHubConsoleOperationView | ViteHubConsoleAuthView | ViteHubConsoleWebhooksView | ViteHubConsoleDefinitionCatalogView | ViteHubConsoleRecordTableView | ViteHubConsoleDocumentEditorView | ViteHubConsoleWorkspaceBrowserView;
|
|
142
|
+
/**
|
|
143
|
+
* The overview of a document editor section: document counts by state, the changes that wait for a publish, recent
|
|
144
|
+
* activity, and a New button per collection. It reads the owner `overview` action.
|
|
145
|
+
*/
|
|
146
|
+
interface ViteHubConsoleDocumentDashboardView {
|
|
147
|
+
kind: "document-dashboard";
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* The media library of a document editor section: folders, uploads, alt text, focal points, and crops of the Blob Store
|
|
151
|
+
* that `blob.serve` serves. The owner decides who may use it with `mediaAccess`, and finds the documents that use a file
|
|
152
|
+
* with `references`. The page needs the Blob section, so declare it with `requires: ["blob"]`.
|
|
153
|
+
*/
|
|
154
|
+
interface ViteHubConsoleMediaLibraryView {
|
|
155
|
+
kind: "media-library";
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* The singletons of a document editor section, such as site settings: one row per singleton that opens it in the
|
|
159
|
+
* editor. Singletons appear here instead of among the collections, and the Console hides the page when the section has
|
|
160
|
+
* none.
|
|
161
|
+
*/
|
|
162
|
+
interface ViteHubConsoleDocumentSettingsView {
|
|
163
|
+
kind: "document-settings";
|
|
164
|
+
}
|
|
165
|
+
/** A view that the Console UI in `vite-hub` renders for a section page. */
|
|
166
|
+
type ViteHubConsoleSectionPageView = ViteHubConsoleDocumentDashboardView | ViteHubConsoleDocumentSettingsView | ViteHubConsoleMediaLibraryView;
|
|
167
|
+
/**
|
|
168
|
+
* A page of a section next to its main view, such as the Content dashboard or media library. The section sidebar lists
|
|
169
|
+
* the pages, and each page has its own URL:
|
|
170
|
+
*
|
|
171
|
+
* - `/_vitehub/<section>` serves the `index` page, or the main view when the section has none.
|
|
172
|
+
* - `/_vitehub/<section>/-/<page>` serves every other page. The `-` segment keeps page URLs apart from the main view's
|
|
173
|
+
* own segments, such as a collection name.
|
|
174
|
+
*
|
|
175
|
+
* Pages share the access of their section: `console.authorize` that allows the section allows every page of it.
|
|
176
|
+
*/
|
|
177
|
+
interface ViteHubConsoleSectionPage {
|
|
178
|
+
/** Lowercase route segment, for example `media`. */
|
|
179
|
+
id: string;
|
|
180
|
+
/** Display name, for example `Media`. */
|
|
181
|
+
label: string;
|
|
182
|
+
/** Iconify class name, for example `i-lucide-image`. */
|
|
183
|
+
icon: string;
|
|
184
|
+
view: ViteHubConsoleSectionPageView;
|
|
185
|
+
/**
|
|
186
|
+
* Serve this page at the section root. At most one page sets it, and `/_vitehub/<section>/-/<id>` then redirects to
|
|
187
|
+
* the root.
|
|
188
|
+
*/
|
|
189
|
+
index?: boolean;
|
|
190
|
+
/**
|
|
191
|
+
* Sidebar heading, for example `Assets`. Pages without a group lead the sidebar, above the main view's navigation.
|
|
192
|
+
* Grouped pages follow it, in the order their group first appears.
|
|
193
|
+
*/
|
|
194
|
+
group?: string;
|
|
195
|
+
/** Section ids that the project must enable, such as `["blob"]`. The Console leaves the page out otherwise. */
|
|
196
|
+
requires?: readonly string[];
|
|
197
|
+
}
|
|
198
|
+
/** Serializable description of a Console section. The Console UI in `vite-hub` renders the view. */
|
|
199
|
+
interface ViteHubConsoleSectionDescriptor<TView extends ViteHubConsoleSectionView = ViteHubConsoleSectionView> {
|
|
200
|
+
description: string;
|
|
201
|
+
/**
|
|
202
|
+
* Iconify class name, for example `i-lucide-inbox`. The Console draws with Lucide; `ph` also resolves. The
|
|
203
|
+
* Console build bundles the icon of every section in the `vite-hub` Console registry and fails if it cannot resolve one.
|
|
204
|
+
*/
|
|
205
|
+
icon: string;
|
|
206
|
+
/** Lowercase route segment, for example `queues`. The Console serves the section at `/_vitehub/<id>`. */
|
|
207
|
+
id: string;
|
|
208
|
+
/** Plural display name, for example `Queues`. */
|
|
209
|
+
label: string;
|
|
210
|
+
view: TView;
|
|
211
|
+
/** Pages next to the main view, in sidebar order. Only document editor sections render pages today. */
|
|
212
|
+
pages?: readonly ViteHubConsoleSectionPage[];
|
|
213
|
+
}
|
|
214
|
+
//#endregion
|
|
215
|
+
//#region src/console.d.ts
|
|
216
|
+
/** The owner descriptor. The host supplies the navigation and renders the Auth views. */
|
|
217
|
+
export declare const authConsoleSection: ViteHubConsoleAuthSection;
|
|
218
|
+
//#endregion
|
|
219
|
+
export { type AuthConsoleAction, type AuthConsoleActivity, type AuthConsoleActivityQuery, type AuthConsoleAgent, type AuthConsoleCapability, type AuthConsoleColumn, type AuthConsoleDescription, type AuthConsoleEvent, type AuthConsoleEventGroup, type AuthConsoleEventUser, type AuthConsoleField, type AuthConsoleFieldPolicy, type AuthConsoleFieldType, type AuthConsoleHostOptions, type AuthConsoleHostSession, type AuthConsoleHostUserInput, type AuthConsoleImpersonation, type AuthConsoleList, type AuthConsoleMutation, type AuthConsoleOptions, type AuthConsoleOrganization, type AuthConsoleOrganizationDetail, type AuthConsoleOverview, type AuthConsolePage, type AuthConsolePolicy, type AuthConsoleQuery, type AuthConsoleRoles, type AuthConsoleSession, type AuthConsoleSessionUser, type AuthConsoleUser, type AuthConsoleUserDetail, type AuthConsoleValue, type authConsoleActionNames, authConsoleEventGroups };
|
package/dist/console.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { n as authConsoleEventGroups } from "./console-types-CmmnKGMx.js";
|
|
2
|
+
//#region src/console.ts
|
|
3
|
+
/** The owner descriptor. The host supplies the navigation and renders the Auth views. */
|
|
4
|
+
const authConsoleSection = {
|
|
5
|
+
id: "auth",
|
|
6
|
+
label: "Auth",
|
|
7
|
+
icon: "i-vitehub-auth",
|
|
8
|
+
description: "Manage users, sessions, organizations, and approved OAuth clients.",
|
|
9
|
+
view: {
|
|
10
|
+
kind: "auth-management",
|
|
11
|
+
notice: "Better Auth owns user data and runs each change through its APIs."
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { authConsoleEventGroups, authConsoleSection };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-C8XtVz0i.js";
|
|
2
|
+
//#region src/database-options.ts
|
|
3
|
+
/** Reads the adapter's target without loading Better Auth or the Database runtime. */
|
|
4
|
+
function authDatabaseName(database) {
|
|
5
|
+
if (typeof database !== "function") return;
|
|
6
|
+
const name = Reflect.get(database, "vitehubDatabase");
|
|
7
|
+
return typeof name === "string" ? name : void 0;
|
|
8
|
+
}
|
|
9
|
+
/** The owned schema has text IDs and references, with no database-generated default. */
|
|
10
|
+
function assertAuthDatabaseIdStrategy(generateId) {
|
|
11
|
+
if (generateId === "serial" || generateId === "uuid" || generateId === false) throw authErrorDiagnostics.AUTH_C0053({ message: "`authDatabase()` owns tables with text IDs. Use Better Auth's default ID generator or a custom function returning strings; `advanced.database.generateId` cannot be `serial`, `uuid`, or `false`. Use another Better Auth adapter to own a different ID schema." });
|
|
12
|
+
}
|
|
13
|
+
/** The Auth Vite plugin reads `additionalFields` from the Definition to add their columns, so they must be static. */
|
|
14
|
+
function authDatabaseAdditionalFieldsError(detail) {
|
|
15
|
+
return authErrorDiagnostics.AUTH_C0055({ message: `\`authDatabase()\` adds a column for each additional field, but ${detail}.` });
|
|
16
|
+
}
|
|
17
|
+
/** The Better Auth options need a table, a column, or a name that the Database of `authDatabase()` does not have. */
|
|
18
|
+
function authDatabaseSchemaError(detail) {
|
|
19
|
+
return authErrorDiagnostics.AUTH_C0056({ message: `\`authDatabase()\` cannot store the Better Auth options: ${detail}.` });
|
|
20
|
+
}
|
|
21
|
+
function authDatabasePlacementError() {
|
|
22
|
+
return authErrorDiagnostics.AUTH_C0054({ message: "`authDatabase()` needs one statically invariant Database: call it inline as `defineAuth()`'s `database`, in an object or a callback's single unconditional returned object. Do not select it in branches." });
|
|
23
|
+
}
|
|
24
|
+
/** Outside a development server, Auth keeps users in memory only when the Definition asks for it. */
|
|
25
|
+
function authMemoryDatabaseError() {
|
|
26
|
+
return authErrorDiagnostics.AUTH_C0063({ message: "`defineAuth()` has no `database` or `preset`. Auth keeps users and sessions in memory only on a development server, because a restart or a second instance loses them." });
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { authDatabaseSchemaError as a, authDatabasePlacementError as i, authDatabaseAdditionalFieldsError as n, authMemoryDatabaseError as o, authDatabaseName as r, assertAuthDatabaseIdStrategy as t };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { a as authDatabaseSchemaError } from "./database-options-BRNef9oy.js";
|
|
2
|
+
import { getAuthTables } from "better-auth/db";
|
|
3
|
+
//#region src/database-schema-options.ts
|
|
4
|
+
/** Better Auth reads each table by its key and each column by its field key, so the options must not rename them. */
|
|
5
|
+
function assertAuthDatabaseNames(options) {
|
|
6
|
+
for (const [model, table] of Object.entries(getAuthTables(options))) {
|
|
7
|
+
if (table.modelName !== model) throw authDatabaseSchemaError(`${model}.modelName cannot be ${JSON.stringify(table.modelName)}, because the table keeps the key \`${model}\``);
|
|
8
|
+
for (const [key, field] of Object.entries(table.fields)) if (field.fieldName && field.fieldName !== key) throw authDatabaseSchemaError(`${model}.${key} cannot map to ${JSON.stringify(field.fieldName)}, because the column keeps the key \`${key}\``);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { assertAuthDatabaseNames as t };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { f as AuthAppDatabase } from "./types-CNaeH2Fd.js";
|
|
2
|
+
//#region src/database.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The Better Auth `database` adapter for the app Database `name` (default `"default"`). Pass it inline as the
|
|
5
|
+
* `database` of `defineAuth()`. Auth then adds the Better Auth tables, with the fields of `admin()`, the
|
|
6
|
+
* Console MCP OAuth tables, the table of Better Auth's limiter, the `additionalFields` of the Definition, and the tables of
|
|
7
|
+
* the plugins that it calls, such as `twoFactor()` and `apiKey()`, to that Database. The adapter uses the Database of each
|
|
8
|
+
* request: SQLite, libSQL, Cloudflare D1, or Postgres.
|
|
9
|
+
*/
|
|
10
|
+
export declare function authDatabase(name?: string): AuthAppDatabase;
|
|
11
|
+
//#endregion
|
|
12
|
+
export type { AuthAppDatabase };
|
package/dist/database.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { t as authErrorDiagnostics } from "./error-diagnostics-C8XtVz0i.js";
|
|
2
|
+
import { a as authDatabaseSchemaError, t as assertAuthDatabaseIdStrategy } from "./database-options-BRNef9oy.js";
|
|
3
|
+
import { t as assertAuthDatabaseNames } from "./database-schema-options-ENuRMduM.js";
|
|
4
|
+
import { getAuthTables } from "better-auth/db";
|
|
5
|
+
import { getTableColumns, is, isTable } from "drizzle-orm";
|
|
6
|
+
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
7
|
+
import { databases } from "@vite-hub/database/runtime/registry";
|
|
8
|
+
import { PgAsyncDatabase } from "drizzle-orm/pg-core";
|
|
9
|
+
//#region src/database.ts
|
|
10
|
+
/**
|
|
11
|
+
* Compares the tables and fields that the options need, with the plugins and additional fields, against the Drizzle
|
|
12
|
+
* tables of the Database, before the adapter opens it.
|
|
13
|
+
*/
|
|
14
|
+
function assertAuthDatabaseSchema(options, schema, database) {
|
|
15
|
+
const fix = "Call the plugin in `server/auth.ts` and write `additionalFields` inline there, so that the Auth Vite plugin adds the columns. Then run `vitehub database generate` and apply the migration";
|
|
16
|
+
for (const [model, table] of Object.entries(getAuthTables(options))) {
|
|
17
|
+
const drizzleTable = Object.hasOwn(schema, model) ? schema[model] : void 0;
|
|
18
|
+
if (!isTable(drizzleTable)) throw authDatabaseSchemaError(`the ${JSON.stringify(database)} Database has no \`${model}\` table. ${fix}`);
|
|
19
|
+
const columns = getTableColumns(drizzleTable);
|
|
20
|
+
for (const key of Object.keys(table.fields)) if (!Object.hasOwn(columns, key)) throw authDatabaseSchemaError(`the \`${model}\` table of the ${JSON.stringify(database)} Database has no \`${key}\` column. ${fix}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The Better Auth `database` adapter for the app Database `name` (default `"default"`). Pass it inline as the
|
|
25
|
+
* `database` of `defineAuth()`. Auth then adds the Better Auth tables, with the fields of `admin()`, the
|
|
26
|
+
* Console MCP OAuth tables, the table of Better Auth's limiter, the `additionalFields` of the Definition, and the tables of
|
|
27
|
+
* the plugins that it calls, such as `twoFactor()` and `apiKey()`, to that Database. The adapter uses the Database of each
|
|
28
|
+
* request: SQLite, libSQL, Cloudflare D1, or Postgres.
|
|
29
|
+
*/
|
|
30
|
+
function authDatabase(name = "default") {
|
|
31
|
+
const adapter = (options) => {
|
|
32
|
+
assertAuthDatabaseIdStrategy(options.advanced?.database?.generateId);
|
|
33
|
+
assertAuthDatabaseNames(options);
|
|
34
|
+
const entry = Object.hasOwn(databases, name) ? databases[name] : void 0;
|
|
35
|
+
if (!entry || !Object.hasOwn(entry.schema, "user")) throw authErrorDiagnostics.AUTH_R0019({ message: `[vitehub] \`authDatabase(${JSON.stringify(name)})\` found no Better Auth tables in the ${JSON.stringify(name)} Database. Pass \`authDatabase()\` inline as the \`database\` of \`defineAuth()\` so that Auth adds them, enable the Database integration, and run \`vitehub database generate\`. \`vitehub inspect definitions --kind database\` lists the tables of each Database.` });
|
|
36
|
+
assertAuthDatabaseSchema(options, entry.schema, name);
|
|
37
|
+
return drizzleAdapter(entry.db, {
|
|
38
|
+
provider: is(entry.db, PgAsyncDatabase) ? "pg" : "sqlite",
|
|
39
|
+
schema: entry.schema
|
|
40
|
+
})(options);
|
|
41
|
+
};
|
|
42
|
+
return Object.assign(adapter, { vitehubDatabase: name });
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { authDatabase };
|