@objectstack/plugin-auth 3.2.2 → 3.2.4
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +16 -0
- package/README.md +56 -19
- package/dist/index.d.mts +346 -12
- package/dist/index.d.ts +346 -12
- package/dist/index.js +304 -65
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +289 -65
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/auth-manager.test.ts +196 -15
- package/src/auth-manager.ts +90 -28
- package/src/auth-schema-config.ts +339 -0
- package/src/index.ts +1 -0
- package/src/objectql-adapter.test.ts +169 -1
- package/src/objectql-adapter.ts +195 -119
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @objectstack/plugin-auth@3.2.
|
|
2
|
+
> @objectstack/plugin-auth@3.2.4 build /home/runner/work/spec/spec/packages/plugins/plugin-auth
|
|
3
3
|
> tsup --config ../../../tsup.config.ts
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mESM[39m Build start
|
|
12
12
|
[34mCJS[39m Build start
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m30.08 KB[39m
|
|
14
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m67.20 KB[39m
|
|
15
|
+
[32mCJS[39m ⚡️ Build success in 67ms
|
|
16
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m27.37 KB[39m
|
|
17
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m66.55 KB[39m
|
|
18
|
+
[32mESM[39m ⚡️ Build success in 68ms
|
|
19
19
|
[34mDTS[39m Build start
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.mts [22m[
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 7993ms
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.mts [22m[32m421.74 KB[39m
|
|
22
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m421.74 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.2.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f490991: fix better-auth
|
|
8
|
+
- @objectstack/spec@3.2.4
|
|
9
|
+
- @objectstack/core@3.2.4
|
|
10
|
+
|
|
11
|
+
## 3.2.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 0b1d7c9: fix auth
|
|
16
|
+
- @objectstack/spec@3.2.3
|
|
17
|
+
- @objectstack/core@3.2.3
|
|
18
|
+
|
|
3
19
|
## 3.2.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -215,38 +215,75 @@ export const AuthUser = ObjectSchema.create({
|
|
|
215
215
|
**Database Objects:**
|
|
216
216
|
Uses ObjectStack `sys_` prefixed protocol names with snake_case field naming.
|
|
217
217
|
The adapter automatically maps better-auth model names to protocol names:
|
|
218
|
+
|
|
219
|
+
*Core models:*
|
|
218
220
|
- `sys_user` (← better-auth `user`) - User accounts (id, email, name, email_verified, created_at, etc.)
|
|
219
221
|
- `sys_session` (← better-auth `session`) - Active sessions (id, token, user_id, expires_at, ip_address, etc.)
|
|
220
222
|
- `sys_account` (← better-auth `account`) - OAuth provider accounts (id, provider_id, account_id, user_id, tokens, etc.)
|
|
221
223
|
- `sys_verification` (← better-auth `verification`) - Verification tokens (id, value, identifier, expires_at, etc.)
|
|
222
224
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
+
*Organization plugin (when `plugins.organization: true`):*
|
|
226
|
+
- `sys_organization` (← `organization`) - Organizations (id, name, slug, logo, created_at, etc.)
|
|
227
|
+
- `sys_member` (← `member`) - Organization members (id, organization_id, user_id, role, created_at)
|
|
228
|
+
- `sys_invitation` (← `invitation`) - Invitations (id, organization_id, inviter_id, email, role, expires_at, etc.)
|
|
229
|
+
- `sys_team` (← `team`) - Teams (id, name, organization_id, created_at, etc.)
|
|
230
|
+
- `sys_team_member` (← `teamMember`) - Team members (id, team_id, user_id, created_at)
|
|
225
231
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
232
|
+
*Two-Factor plugin (when `plugins.twoFactor: true`):*
|
|
233
|
+
- `sys_two_factor` (← `twoFactor`) - 2FA secrets (id, secret, backup_codes, user_id)
|
|
234
|
+
|
|
235
|
+
**Schema Mapping (modelName + fields):**
|
|
229
236
|
|
|
230
|
-
|
|
237
|
+
better-auth uses camelCase field names internally (`emailVerified`, `userId`, `createdAt`, etc.)
|
|
238
|
+
while ObjectStack's protocol layer uses snake_case (`email_verified`, `user_id`, `created_at`).
|
|
231
239
|
|
|
232
|
-
|
|
233
|
-
|
|
240
|
+
The plugin leverages better-auth's official `modelName` / `fields` schema customisation API
|
|
241
|
+
to declare the mapping at configuration time. The `createAdapterFactory` wrapper then
|
|
242
|
+
transforms data and where-clauses automatically — no runtime camelCase ↔ snake_case
|
|
243
|
+
conversion is needed in the adapter itself.
|
|
234
244
|
|
|
235
|
-
|
|
236
|
-
//
|
|
237
|
-
|
|
245
|
+
```typescript
|
|
246
|
+
// Schema mapping constants (auth-schema-config.ts)
|
|
247
|
+
import {
|
|
248
|
+
AUTH_USER_CONFIG,
|
|
249
|
+
AUTH_SESSION_CONFIG,
|
|
250
|
+
AUTH_ACCOUNT_CONFIG,
|
|
251
|
+
AUTH_VERIFICATION_CONFIG,
|
|
252
|
+
buildOrganizationPluginSchema,
|
|
253
|
+
buildTwoFactorPluginSchema,
|
|
254
|
+
} from '@objectstack/plugin-auth';
|
|
255
|
+
|
|
256
|
+
// Applied to the betterAuth() config:
|
|
238
257
|
const auth = betterAuth({
|
|
239
|
-
database: (
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
|
|
258
|
+
database: createObjectQLAdapterFactory(dataEngine),
|
|
259
|
+
user: { ...AUTH_USER_CONFIG },
|
|
260
|
+
session: { ...AUTH_SESSION_CONFIG, expiresIn: 604800 },
|
|
261
|
+
account: { ...AUTH_ACCOUNT_CONFIG },
|
|
262
|
+
verification: { ...AUTH_VERIFICATION_CONFIG },
|
|
263
|
+
plugins: [
|
|
264
|
+
organization({ schema: buildOrganizationPluginSchema() }),
|
|
265
|
+
twoFactor({ schema: buildTwoFactorPluginSchema() }),
|
|
266
|
+
],
|
|
245
267
|
});
|
|
246
268
|
```
|
|
247
269
|
|
|
248
|
-
|
|
249
|
-
|
|
270
|
+
**Adapter Factory:**
|
|
271
|
+
The `createObjectQLAdapterFactory()` function uses better-auth's `createAdapterFactory` to
|
|
272
|
+
bridge ObjectQL's IDataEngine with better-auth. Model-name and field-name transformations
|
|
273
|
+
are applied by the factory wrapper so the adapter code stays simple:
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
import { createObjectQLAdapterFactory } from '@objectstack/plugin-auth';
|
|
277
|
+
|
|
278
|
+
const adapterFactory = createObjectQLAdapterFactory(dataEngine);
|
|
279
|
+
// adapterFactory is (options: BetterAuthOptions) => DBAdapter
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
> **Note:** `AuthManager` handles all of this automatically when you provide a `dataEngine`.
|
|
283
|
+
> You only need the factory/config above when using the adapter directly.
|
|
284
|
+
|
|
285
|
+
A legacy `createObjectQLAdapter()` function (with manual model-name mapping via
|
|
286
|
+
`AUTH_MODEL_TO_PROTOCOL`) is still exported for backward compatibility.
|
|
250
287
|
|
|
251
288
|
## Development
|
|
252
289
|
|
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import { AuthConfig } from '@objectstack/spec/system';
|
|
|
3
3
|
export { AuthConfig, AuthPluginConfig, AuthProviderConfig } from '@objectstack/spec/system';
|
|
4
4
|
import * as better_auth from 'better-auth';
|
|
5
5
|
import { Auth } from 'better-auth';
|
|
6
|
+
import * as better_auth_adapters from 'better-auth/adapters';
|
|
6
7
|
import { CleanedWhere } from 'better-auth/adapters';
|
|
7
8
|
import { z } from 'zod';
|
|
8
9
|
import * as _objectstack_spec_data from '@objectstack/spec/data';
|
|
@@ -115,6 +116,14 @@ declare class AuthManager {
|
|
|
115
116
|
* Create a better-auth instance from configuration
|
|
116
117
|
*/
|
|
117
118
|
private createAuthInstance;
|
|
119
|
+
/**
|
|
120
|
+
* Build the list of better-auth plugins based on AuthPluginConfig flags.
|
|
121
|
+
*
|
|
122
|
+
* Each plugin that introduces its own database tables is configured with
|
|
123
|
+
* a `schema` option containing the appropriate snake_case field mappings,
|
|
124
|
+
* so that `createAdapterFactory` transforms them automatically.
|
|
125
|
+
*/
|
|
126
|
+
private buildPluginList;
|
|
118
127
|
/**
|
|
119
128
|
* Create database configuration using ObjectQL adapter
|
|
120
129
|
*
|
|
@@ -2257,17 +2266,35 @@ declare const AUTH_MODEL_TO_PROTOCOL: Record<string, string>;
|
|
|
2257
2266
|
*/
|
|
2258
2267
|
declare function resolveProtocolName(model: string): string;
|
|
2259
2268
|
/**
|
|
2260
|
-
* ObjectQL
|
|
2269
|
+
* Create an ObjectQL adapter **factory** for better-auth.
|
|
2270
|
+
*
|
|
2271
|
+
* Uses better-auth's official `createAdapterFactory` so that model-name and
|
|
2272
|
+
* field-name transformations (declared via `modelName` / `fields` in the
|
|
2273
|
+
* betterAuth config) are applied **automatically** before any data reaches
|
|
2274
|
+
* ObjectQL. This eliminates the need for manual camelCase ↔ snake_case
|
|
2275
|
+
* conversion inside the adapter.
|
|
2276
|
+
*
|
|
2277
|
+
* The returned value is an `AdapterFactory` – a function of type
|
|
2278
|
+
* `(options: BetterAuthOptions) => DBAdapter` – which is the shape expected
|
|
2279
|
+
* by `betterAuth({ database: … })`.
|
|
2280
|
+
*
|
|
2281
|
+
* @param dataEngine - ObjectQL data engine instance
|
|
2282
|
+
* @returns better-auth AdapterFactory
|
|
2283
|
+
*/
|
|
2284
|
+
declare function createObjectQLAdapterFactory(dataEngine: IDataEngine): better_auth_adapters.AdapterFactory<better_auth.BetterAuthOptions>;
|
|
2285
|
+
/**
|
|
2286
|
+
* Create a raw ObjectQL adapter for better-auth (without factory wrapping).
|
|
2261
2287
|
*
|
|
2262
|
-
*
|
|
2263
|
-
*
|
|
2264
|
-
*
|
|
2288
|
+
* > **Prefer {@link createObjectQLAdapterFactory}** for production use.
|
|
2289
|
+
* > The factory version leverages `createAdapterFactory` and automatically
|
|
2290
|
+
* > handles model-name + field-name transformations declared in the
|
|
2291
|
+
* > better-auth config.
|
|
2265
2292
|
*
|
|
2266
|
-
*
|
|
2267
|
-
*
|
|
2293
|
+
* This function is retained for direct / low-level usage where callers
|
|
2294
|
+
* manage field-name conversion themselves.
|
|
2268
2295
|
*
|
|
2269
2296
|
* @param dataEngine - ObjectQL data engine instance
|
|
2270
|
-
* @returns better-auth CustomAdapter
|
|
2297
|
+
* @returns better-auth CustomAdapter (raw, without factory wrapping)
|
|
2271
2298
|
*/
|
|
2272
2299
|
declare function createObjectQLAdapter(dataEngine: IDataEngine): {
|
|
2273
2300
|
create: <T extends Record<string, any>>({ model, data, select: _select }: {
|
|
@@ -2316,6 +2343,313 @@ declare function createObjectQLAdapter(dataEngine: IDataEngine): {
|
|
|
2316
2343
|
}) => Promise<number>;
|
|
2317
2344
|
};
|
|
2318
2345
|
|
|
2346
|
+
/**
|
|
2347
|
+
* better-auth ↔ ObjectStack Schema Mapping
|
|
2348
|
+
*
|
|
2349
|
+
* better-auth uses camelCase field names internally (e.g. `emailVerified`, `userId`)
|
|
2350
|
+
* while ObjectStack's protocol layer uses snake_case (e.g. `email_verified`, `user_id`).
|
|
2351
|
+
*
|
|
2352
|
+
* These constants declare the `modelName` and `fields` mappings for each core auth
|
|
2353
|
+
* model, following better-auth's official schema customisation API
|
|
2354
|
+
* ({@link https://www.better-auth.com/docs/concepts/database}).
|
|
2355
|
+
*
|
|
2356
|
+
* The mappings serve two purposes:
|
|
2357
|
+
* 1. `modelName` — maps the default model name to the ObjectStack protocol name
|
|
2358
|
+
* (e.g. `user` → `sys_user`).
|
|
2359
|
+
* 2. `fields` — maps camelCase field names to their snake_case database column
|
|
2360
|
+
* equivalents. Only fields whose names differ need to be listed; fields that
|
|
2361
|
+
* are already identical (e.g. `email`, `name`, `token`) are omitted.
|
|
2362
|
+
*
|
|
2363
|
+
* These mappings are consumed by:
|
|
2364
|
+
* - The `betterAuth()` configuration in {@link AuthManager} so that
|
|
2365
|
+
* `getAuthTables()` builds the correct schema.
|
|
2366
|
+
* - The ObjectQL adapter factory (via `createAdapterFactory`) which uses the
|
|
2367
|
+
* schema to transform data and where-clauses automatically.
|
|
2368
|
+
*/
|
|
2369
|
+
/**
|
|
2370
|
+
* better-auth `user` model mapping.
|
|
2371
|
+
*
|
|
2372
|
+
* | camelCase (better-auth) | snake_case (ObjectStack) |
|
|
2373
|
+
* |:------------------------|:-------------------------|
|
|
2374
|
+
* | emailVerified | email_verified |
|
|
2375
|
+
* | createdAt | created_at |
|
|
2376
|
+
* | updatedAt | updated_at |
|
|
2377
|
+
*/
|
|
2378
|
+
declare const AUTH_USER_CONFIG: {
|
|
2379
|
+
readonly modelName: "sys_user";
|
|
2380
|
+
readonly fields: {
|
|
2381
|
+
readonly emailVerified: "email_verified";
|
|
2382
|
+
readonly createdAt: "created_at";
|
|
2383
|
+
readonly updatedAt: "updated_at";
|
|
2384
|
+
};
|
|
2385
|
+
};
|
|
2386
|
+
/**
|
|
2387
|
+
* better-auth `session` model mapping.
|
|
2388
|
+
*
|
|
2389
|
+
* | camelCase (better-auth) | snake_case (ObjectStack) |
|
|
2390
|
+
* |:------------------------|:-------------------------|
|
|
2391
|
+
* | userId | user_id |
|
|
2392
|
+
* | expiresAt | expires_at |
|
|
2393
|
+
* | createdAt | created_at |
|
|
2394
|
+
* | updatedAt | updated_at |
|
|
2395
|
+
* | ipAddress | ip_address |
|
|
2396
|
+
* | userAgent | user_agent |
|
|
2397
|
+
*/
|
|
2398
|
+
declare const AUTH_SESSION_CONFIG: {
|
|
2399
|
+
readonly modelName: "sys_session";
|
|
2400
|
+
readonly fields: {
|
|
2401
|
+
readonly userId: "user_id";
|
|
2402
|
+
readonly expiresAt: "expires_at";
|
|
2403
|
+
readonly createdAt: "created_at";
|
|
2404
|
+
readonly updatedAt: "updated_at";
|
|
2405
|
+
readonly ipAddress: "ip_address";
|
|
2406
|
+
readonly userAgent: "user_agent";
|
|
2407
|
+
};
|
|
2408
|
+
};
|
|
2409
|
+
/**
|
|
2410
|
+
* better-auth `account` model mapping.
|
|
2411
|
+
*
|
|
2412
|
+
* | camelCase (better-auth) | snake_case (ObjectStack) |
|
|
2413
|
+
* |:--------------------------|:-------------------------------|
|
|
2414
|
+
* | userId | user_id |
|
|
2415
|
+
* | providerId | provider_id |
|
|
2416
|
+
* | accountId | account_id |
|
|
2417
|
+
* | accessToken | access_token |
|
|
2418
|
+
* | refreshToken | refresh_token |
|
|
2419
|
+
* | idToken | id_token |
|
|
2420
|
+
* | accessTokenExpiresAt | access_token_expires_at |
|
|
2421
|
+
* | refreshTokenExpiresAt | refresh_token_expires_at |
|
|
2422
|
+
* | createdAt | created_at |
|
|
2423
|
+
* | updatedAt | updated_at |
|
|
2424
|
+
*/
|
|
2425
|
+
declare const AUTH_ACCOUNT_CONFIG: {
|
|
2426
|
+
readonly modelName: "sys_account";
|
|
2427
|
+
readonly fields: {
|
|
2428
|
+
readonly userId: "user_id";
|
|
2429
|
+
readonly providerId: "provider_id";
|
|
2430
|
+
readonly accountId: "account_id";
|
|
2431
|
+
readonly accessToken: "access_token";
|
|
2432
|
+
readonly refreshToken: "refresh_token";
|
|
2433
|
+
readonly idToken: "id_token";
|
|
2434
|
+
readonly accessTokenExpiresAt: "access_token_expires_at";
|
|
2435
|
+
readonly refreshTokenExpiresAt: "refresh_token_expires_at";
|
|
2436
|
+
readonly createdAt: "created_at";
|
|
2437
|
+
readonly updatedAt: "updated_at";
|
|
2438
|
+
};
|
|
2439
|
+
};
|
|
2440
|
+
/**
|
|
2441
|
+
* better-auth `verification` model mapping.
|
|
2442
|
+
*
|
|
2443
|
+
* | camelCase (better-auth) | snake_case (ObjectStack) |
|
|
2444
|
+
* |:------------------------|:-------------------------|
|
|
2445
|
+
* | expiresAt | expires_at |
|
|
2446
|
+
* | createdAt | created_at |
|
|
2447
|
+
* | updatedAt | updated_at |
|
|
2448
|
+
*/
|
|
2449
|
+
declare const AUTH_VERIFICATION_CONFIG: {
|
|
2450
|
+
readonly modelName: "sys_verification";
|
|
2451
|
+
readonly fields: {
|
|
2452
|
+
readonly expiresAt: "expires_at";
|
|
2453
|
+
readonly createdAt: "created_at";
|
|
2454
|
+
readonly updatedAt: "updated_at";
|
|
2455
|
+
};
|
|
2456
|
+
};
|
|
2457
|
+
/**
|
|
2458
|
+
* better-auth Organization plugin `organization` model mapping.
|
|
2459
|
+
*
|
|
2460
|
+
* | camelCase (better-auth) | snake_case (ObjectStack) |
|
|
2461
|
+
* |:------------------------|:-------------------------|
|
|
2462
|
+
* | createdAt | created_at |
|
|
2463
|
+
* | updatedAt | updated_at |
|
|
2464
|
+
*/
|
|
2465
|
+
declare const AUTH_ORGANIZATION_SCHEMA: {
|
|
2466
|
+
readonly modelName: "sys_organization";
|
|
2467
|
+
readonly fields: {
|
|
2468
|
+
readonly createdAt: "created_at";
|
|
2469
|
+
readonly updatedAt: "updated_at";
|
|
2470
|
+
};
|
|
2471
|
+
};
|
|
2472
|
+
/**
|
|
2473
|
+
* better-auth Organization plugin `member` model mapping.
|
|
2474
|
+
*
|
|
2475
|
+
* | camelCase (better-auth) | snake_case (ObjectStack) |
|
|
2476
|
+
* |:------------------------|:-------------------------|
|
|
2477
|
+
* | organizationId | organization_id |
|
|
2478
|
+
* | userId | user_id |
|
|
2479
|
+
* | createdAt | created_at |
|
|
2480
|
+
*/
|
|
2481
|
+
declare const AUTH_MEMBER_SCHEMA: {
|
|
2482
|
+
readonly modelName: "sys_member";
|
|
2483
|
+
readonly fields: {
|
|
2484
|
+
readonly organizationId: "organization_id";
|
|
2485
|
+
readonly userId: "user_id";
|
|
2486
|
+
readonly createdAt: "created_at";
|
|
2487
|
+
};
|
|
2488
|
+
};
|
|
2489
|
+
/**
|
|
2490
|
+
* better-auth Organization plugin `invitation` model mapping.
|
|
2491
|
+
*
|
|
2492
|
+
* | camelCase (better-auth) | snake_case (ObjectStack) |
|
|
2493
|
+
* |:------------------------|:-------------------------|
|
|
2494
|
+
* | organizationId | organization_id |
|
|
2495
|
+
* | inviterId | inviter_id |
|
|
2496
|
+
* | expiresAt | expires_at |
|
|
2497
|
+
* | createdAt | created_at |
|
|
2498
|
+
* | teamId | team_id |
|
|
2499
|
+
*/
|
|
2500
|
+
declare const AUTH_INVITATION_SCHEMA: {
|
|
2501
|
+
readonly modelName: "sys_invitation";
|
|
2502
|
+
readonly fields: {
|
|
2503
|
+
readonly organizationId: "organization_id";
|
|
2504
|
+
readonly inviterId: "inviter_id";
|
|
2505
|
+
readonly expiresAt: "expires_at";
|
|
2506
|
+
readonly createdAt: "created_at";
|
|
2507
|
+
readonly teamId: "team_id";
|
|
2508
|
+
};
|
|
2509
|
+
};
|
|
2510
|
+
/**
|
|
2511
|
+
* Organization plugin adds `activeOrganizationId` (and optionally
|
|
2512
|
+
* `activeTeamId`) to the session model. These field mappings are
|
|
2513
|
+
* injected via the organization plugin's `schema.session.fields`.
|
|
2514
|
+
*/
|
|
2515
|
+
declare const AUTH_ORG_SESSION_FIELDS: {
|
|
2516
|
+
readonly activeOrganizationId: "active_organization_id";
|
|
2517
|
+
readonly activeTeamId: "active_team_id";
|
|
2518
|
+
};
|
|
2519
|
+
/**
|
|
2520
|
+
* better-auth Organization plugin `team` model mapping.
|
|
2521
|
+
*
|
|
2522
|
+
* | camelCase (better-auth) | snake_case (ObjectStack) |
|
|
2523
|
+
* |:------------------------|:-------------------------|
|
|
2524
|
+
* | organizationId | organization_id |
|
|
2525
|
+
* | createdAt | created_at |
|
|
2526
|
+
* | updatedAt | updated_at |
|
|
2527
|
+
*/
|
|
2528
|
+
declare const AUTH_TEAM_SCHEMA: {
|
|
2529
|
+
readonly modelName: "sys_team";
|
|
2530
|
+
readonly fields: {
|
|
2531
|
+
readonly organizationId: "organization_id";
|
|
2532
|
+
readonly createdAt: "created_at";
|
|
2533
|
+
readonly updatedAt: "updated_at";
|
|
2534
|
+
};
|
|
2535
|
+
};
|
|
2536
|
+
/**
|
|
2537
|
+
* better-auth Organization plugin `teamMember` model mapping.
|
|
2538
|
+
*
|
|
2539
|
+
* | camelCase (better-auth) | snake_case (ObjectStack) |
|
|
2540
|
+
* |:------------------------|:-------------------------|
|
|
2541
|
+
* | teamId | team_id |
|
|
2542
|
+
* | userId | user_id |
|
|
2543
|
+
* | createdAt | created_at |
|
|
2544
|
+
*/
|
|
2545
|
+
declare const AUTH_TEAM_MEMBER_SCHEMA: {
|
|
2546
|
+
readonly modelName: "sys_team_member";
|
|
2547
|
+
readonly fields: {
|
|
2548
|
+
readonly teamId: "team_id";
|
|
2549
|
+
readonly userId: "user_id";
|
|
2550
|
+
readonly createdAt: "created_at";
|
|
2551
|
+
};
|
|
2552
|
+
};
|
|
2553
|
+
/**
|
|
2554
|
+
* better-auth Two-Factor plugin `twoFactor` model mapping.
|
|
2555
|
+
*
|
|
2556
|
+
* | camelCase (better-auth) | snake_case (ObjectStack) |
|
|
2557
|
+
* |:------------------------|:-------------------------|
|
|
2558
|
+
* | backupCodes | backup_codes |
|
|
2559
|
+
* | userId | user_id |
|
|
2560
|
+
*/
|
|
2561
|
+
declare const AUTH_TWO_FACTOR_SCHEMA: {
|
|
2562
|
+
readonly modelName: "sys_two_factor";
|
|
2563
|
+
readonly fields: {
|
|
2564
|
+
readonly backupCodes: "backup_codes";
|
|
2565
|
+
readonly userId: "user_id";
|
|
2566
|
+
};
|
|
2567
|
+
};
|
|
2568
|
+
/**
|
|
2569
|
+
* Two-Factor plugin adds a `twoFactorEnabled` field to the user model.
|
|
2570
|
+
*/
|
|
2571
|
+
declare const AUTH_TWO_FACTOR_USER_FIELDS: {
|
|
2572
|
+
readonly twoFactorEnabled: "two_factor_enabled";
|
|
2573
|
+
};
|
|
2574
|
+
/**
|
|
2575
|
+
* Builds the `schema` option for better-auth's `twoFactor()` plugin.
|
|
2576
|
+
*
|
|
2577
|
+
* @returns An object suitable for `twoFactor({ schema: … })`
|
|
2578
|
+
*/
|
|
2579
|
+
declare function buildTwoFactorPluginSchema(): {
|
|
2580
|
+
twoFactor: {
|
|
2581
|
+
readonly modelName: "sys_two_factor";
|
|
2582
|
+
readonly fields: {
|
|
2583
|
+
readonly backupCodes: "backup_codes";
|
|
2584
|
+
readonly userId: "user_id";
|
|
2585
|
+
};
|
|
2586
|
+
};
|
|
2587
|
+
user: {
|
|
2588
|
+
fields: {
|
|
2589
|
+
readonly twoFactorEnabled: "two_factor_enabled";
|
|
2590
|
+
};
|
|
2591
|
+
};
|
|
2592
|
+
};
|
|
2593
|
+
/**
|
|
2594
|
+
* Builds the `schema` option for better-auth's `organization()` plugin.
|
|
2595
|
+
*
|
|
2596
|
+
* The organization plugin accepts a `schema` sub-option that allows
|
|
2597
|
+
* customising model names and field names for each table it manages.
|
|
2598
|
+
* This helper assembles the correct snake_case mappings from the
|
|
2599
|
+
* individual `AUTH_*_SCHEMA` constants above.
|
|
2600
|
+
*
|
|
2601
|
+
* @returns An object suitable for `organization({ schema: … })`
|
|
2602
|
+
*/
|
|
2603
|
+
declare function buildOrganizationPluginSchema(): {
|
|
2604
|
+
organization: {
|
|
2605
|
+
readonly modelName: "sys_organization";
|
|
2606
|
+
readonly fields: {
|
|
2607
|
+
readonly createdAt: "created_at";
|
|
2608
|
+
readonly updatedAt: "updated_at";
|
|
2609
|
+
};
|
|
2610
|
+
};
|
|
2611
|
+
member: {
|
|
2612
|
+
readonly modelName: "sys_member";
|
|
2613
|
+
readonly fields: {
|
|
2614
|
+
readonly organizationId: "organization_id";
|
|
2615
|
+
readonly userId: "user_id";
|
|
2616
|
+
readonly createdAt: "created_at";
|
|
2617
|
+
};
|
|
2618
|
+
};
|
|
2619
|
+
invitation: {
|
|
2620
|
+
readonly modelName: "sys_invitation";
|
|
2621
|
+
readonly fields: {
|
|
2622
|
+
readonly organizationId: "organization_id";
|
|
2623
|
+
readonly inviterId: "inviter_id";
|
|
2624
|
+
readonly expiresAt: "expires_at";
|
|
2625
|
+
readonly createdAt: "created_at";
|
|
2626
|
+
readonly teamId: "team_id";
|
|
2627
|
+
};
|
|
2628
|
+
};
|
|
2629
|
+
team: {
|
|
2630
|
+
readonly modelName: "sys_team";
|
|
2631
|
+
readonly fields: {
|
|
2632
|
+
readonly organizationId: "organization_id";
|
|
2633
|
+
readonly createdAt: "created_at";
|
|
2634
|
+
readonly updatedAt: "updated_at";
|
|
2635
|
+
};
|
|
2636
|
+
};
|
|
2637
|
+
teamMember: {
|
|
2638
|
+
readonly modelName: "sys_team_member";
|
|
2639
|
+
readonly fields: {
|
|
2640
|
+
readonly teamId: "team_id";
|
|
2641
|
+
readonly userId: "user_id";
|
|
2642
|
+
readonly createdAt: "created_at";
|
|
2643
|
+
};
|
|
2644
|
+
};
|
|
2645
|
+
session: {
|
|
2646
|
+
fields: {
|
|
2647
|
+
readonly activeOrganizationId: "active_organization_id";
|
|
2648
|
+
readonly activeTeamId: "active_team_id";
|
|
2649
|
+
};
|
|
2650
|
+
};
|
|
2651
|
+
};
|
|
2652
|
+
|
|
2319
2653
|
/**
|
|
2320
2654
|
* XState-inspired State Machine Protocol
|
|
2321
2655
|
* Used to define strict business logic constraints and lifecycle management.
|
|
@@ -2382,7 +2716,7 @@ declare const AuthUser: Omit<{
|
|
|
2382
2716
|
abstract: boolean;
|
|
2383
2717
|
datasource: string;
|
|
2384
2718
|
fields: Record<string, {
|
|
2385
|
-
type: "number" | "boolean" | "select" | "date" | "file" | "email" | "url" | "
|
|
2719
|
+
type: "number" | "boolean" | "select" | "date" | "file" | "email" | "url" | "image" | "password" | "time" | "code" | "json" | "location" | "tags" | "lookup" | "text" | "textarea" | "phone" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "toggle" | "multiselect" | "radio" | "checkboxes" | "master_detail" | "tree" | "avatar" | "video" | "audio" | "formula" | "summary" | "autonumber" | "address" | "color" | "rating" | "slider" | "signature" | "qrcode" | "progress" | "vector";
|
|
2386
2720
|
required: boolean;
|
|
2387
2721
|
searchable: boolean;
|
|
2388
2722
|
multiple: boolean;
|
|
@@ -3859,7 +4193,7 @@ declare const AuthSession: Omit<{
|
|
|
3859
4193
|
abstract: boolean;
|
|
3860
4194
|
datasource: string;
|
|
3861
4195
|
fields: Record<string, {
|
|
3862
|
-
type: "number" | "boolean" | "select" | "date" | "file" | "email" | "url" | "
|
|
4196
|
+
type: "number" | "boolean" | "select" | "date" | "file" | "email" | "url" | "image" | "password" | "time" | "code" | "json" | "location" | "tags" | "lookup" | "text" | "textarea" | "phone" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "toggle" | "multiselect" | "radio" | "checkboxes" | "master_detail" | "tree" | "avatar" | "video" | "audio" | "formula" | "summary" | "autonumber" | "address" | "color" | "rating" | "slider" | "signature" | "qrcode" | "progress" | "vector";
|
|
3863
4197
|
required: boolean;
|
|
3864
4198
|
searchable: boolean;
|
|
3865
4199
|
multiple: boolean;
|
|
@@ -5494,7 +5828,7 @@ declare const AuthAccount: Omit<{
|
|
|
5494
5828
|
abstract: boolean;
|
|
5495
5829
|
datasource: string;
|
|
5496
5830
|
fields: Record<string, {
|
|
5497
|
-
type: "number" | "boolean" | "select" | "date" | "file" | "email" | "url" | "
|
|
5831
|
+
type: "number" | "boolean" | "select" | "date" | "file" | "email" | "url" | "image" | "password" | "time" | "code" | "json" | "location" | "tags" | "lookup" | "text" | "textarea" | "phone" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "toggle" | "multiselect" | "radio" | "checkboxes" | "master_detail" | "tree" | "avatar" | "video" | "audio" | "formula" | "summary" | "autonumber" | "address" | "color" | "rating" | "slider" | "signature" | "qrcode" | "progress" | "vector";
|
|
5498
5832
|
required: boolean;
|
|
5499
5833
|
searchable: boolean;
|
|
5500
5834
|
multiple: boolean;
|
|
@@ -7909,7 +8243,7 @@ declare const AuthVerification: Omit<{
|
|
|
7909
8243
|
abstract: boolean;
|
|
7910
8244
|
datasource: string;
|
|
7911
8245
|
fields: Record<string, {
|
|
7912
|
-
type: "number" | "boolean" | "select" | "date" | "file" | "email" | "url" | "
|
|
8246
|
+
type: "number" | "boolean" | "select" | "date" | "file" | "email" | "url" | "image" | "password" | "time" | "code" | "json" | "location" | "tags" | "lookup" | "text" | "textarea" | "phone" | "markdown" | "html" | "richtext" | "currency" | "percent" | "datetime" | "toggle" | "multiselect" | "radio" | "checkboxes" | "master_detail" | "tree" | "avatar" | "video" | "audio" | "formula" | "summary" | "autonumber" | "address" | "color" | "rating" | "slider" | "signature" | "qrcode" | "progress" | "vector";
|
|
7913
8247
|
required: boolean;
|
|
7914
8248
|
searchable: boolean;
|
|
7915
8249
|
multiple: boolean;
|
|
@@ -9203,4 +9537,4 @@ declare const AuthVerification: Omit<{
|
|
|
9203
9537
|
};
|
|
9204
9538
|
}, "fields">;
|
|
9205
9539
|
|
|
9206
|
-
export { AUTH_MODEL_TO_PROTOCOL, AuthAccount, AuthManager, type AuthManagerOptions, AuthPlugin, type AuthPluginOptions, AuthSession, AuthUser, AuthVerification, createObjectQLAdapter, resolveProtocolName };
|
|
9540
|
+
export { AUTH_ACCOUNT_CONFIG, AUTH_INVITATION_SCHEMA, AUTH_MEMBER_SCHEMA, AUTH_MODEL_TO_PROTOCOL, AUTH_ORGANIZATION_SCHEMA, AUTH_ORG_SESSION_FIELDS, AUTH_SESSION_CONFIG, AUTH_TEAM_MEMBER_SCHEMA, AUTH_TEAM_SCHEMA, AUTH_TWO_FACTOR_SCHEMA, AUTH_TWO_FACTOR_USER_FIELDS, AUTH_USER_CONFIG, AUTH_VERIFICATION_CONFIG, AuthAccount, AuthManager, type AuthManagerOptions, AuthPlugin, type AuthPluginOptions, AuthSession, AuthUser, AuthVerification, buildOrganizationPluginSchema, buildTwoFactorPluginSchema, createObjectQLAdapter, createObjectQLAdapterFactory, resolveProtocolName };
|