|
1 | 1 | // Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license. |
2 | 2 |
|
3 | | -import { ObjectSchema, Field } from '@objectstack/spec/data'; |
4 | | - |
5 | 3 | /** |
6 | | - * Auth Account Object |
7 | | - * |
8 | | - * Uses better-auth's native schema for seamless migration: |
9 | | - * - id: string |
10 | | - * - created_at: Date |
11 | | - * - updated_at: Date |
12 | | - * - provider_id: string (e.g., 'google', 'github') |
13 | | - * - account_id: string (provider's user ID) |
14 | | - * - user_id: string (link to user table) |
15 | | - * - access_token: string | null |
16 | | - * - refresh_token: string | null |
17 | | - * - id_token: string | null |
18 | | - * - access_token_expires_at: Date | null |
19 | | - * - refresh_token_expires_at: Date | null |
20 | | - * - scope: string | null |
21 | | - * - password: string | null (for email/password provider) |
| 4 | + * @deprecated Use `SysAccount` from `./sys-account.object` instead. |
| 5 | + * This re-export is kept for backward compatibility. |
22 | 6 | */ |
23 | | -export const AuthAccount = ObjectSchema.create({ |
24 | | - name: 'sys_account', |
25 | | - label: 'Account', |
26 | | - pluralLabel: 'Accounts', |
27 | | - icon: 'link', |
28 | | - description: 'OAuth and authentication provider accounts', |
29 | | - titleFormat: '{provider_id} - {account_id}', |
30 | | - compactLayout: ['provider_id', 'user_id', 'account_id'], |
31 | | - |
32 | | - fields: { |
33 | | - id: Field.text({ |
34 | | - label: 'Account ID', |
35 | | - required: true, |
36 | | - readonly: true, |
37 | | - }), |
38 | | - |
39 | | - created_at: Field.datetime({ |
40 | | - label: 'Created At', |
41 | | - defaultValue: 'NOW()', |
42 | | - readonly: true, |
43 | | - }), |
44 | | - |
45 | | - updated_at: Field.datetime({ |
46 | | - label: 'Updated At', |
47 | | - defaultValue: 'NOW()', |
48 | | - readonly: true, |
49 | | - }), |
50 | | - |
51 | | - provider_id: Field.text({ |
52 | | - label: 'Provider ID', |
53 | | - required: true, |
54 | | - description: 'OAuth provider identifier (google, github, etc.)', |
55 | | - }), |
56 | | - |
57 | | - account_id: Field.text({ |
58 | | - label: 'Provider Account ID', |
59 | | - required: true, |
60 | | - description: "User's ID in the provider's system", |
61 | | - }), |
62 | | - |
63 | | - user_id: Field.text({ |
64 | | - label: 'User ID', |
65 | | - required: true, |
66 | | - description: 'Link to user table', |
67 | | - }), |
68 | | - |
69 | | - access_token: Field.textarea({ |
70 | | - label: 'Access Token', |
71 | | - required: false, |
72 | | - }), |
73 | | - |
74 | | - refresh_token: Field.textarea({ |
75 | | - label: 'Refresh Token', |
76 | | - required: false, |
77 | | - }), |
78 | | - |
79 | | - id_token: Field.textarea({ |
80 | | - label: 'ID Token', |
81 | | - required: false, |
82 | | - }), |
83 | | - |
84 | | - access_token_expires_at: Field.datetime({ |
85 | | - label: 'Access Token Expires At', |
86 | | - required: false, |
87 | | - }), |
88 | | - |
89 | | - refresh_token_expires_at: Field.datetime({ |
90 | | - label: 'Refresh Token Expires At', |
91 | | - required: false, |
92 | | - }), |
93 | | - |
94 | | - scope: Field.text({ |
95 | | - label: 'OAuth Scope', |
96 | | - required: false, |
97 | | - }), |
98 | | - |
99 | | - password: Field.text({ |
100 | | - label: 'Password Hash', |
101 | | - required: false, |
102 | | - description: 'Hashed password for email/password provider', |
103 | | - }), |
104 | | - }, |
105 | | - |
106 | | - // Database indexes for performance |
107 | | - indexes: [ |
108 | | - { fields: ['user_id'], unique: false }, |
109 | | - { fields: ['provider_id', 'account_id'], unique: true }, |
110 | | - ], |
111 | | - |
112 | | - // Enable features |
113 | | - enable: { |
114 | | - trackHistory: false, |
115 | | - searchable: false, |
116 | | - apiEnabled: true, |
117 | | - apiMethods: ['get', 'list', 'create', 'update', 'delete'], |
118 | | - trash: true, |
119 | | - mru: false, |
120 | | - }, |
121 | | -}); |
| 7 | +export { SysAccount as AuthAccount } from './sys-account.object.js'; |
0 commit comments