@objectstack/plugin-auth 4.0.2 → 4.0.3
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 +7 -0
- package/dist/index.d.mts +1383 -91
- package/dist/index.d.ts +1383 -91
- package/dist/index.js +63 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/auth-plugin.test.ts +6 -2
- package/src/auth-plugin.ts +2 -2
- package/src/objects/index.ts +1 -0
- package/src/objects/sys-user-preference.object.ts +82 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectstack/plugin-auth",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Authentication & Identity Plugin for ObjectStack",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"better-auth": "^1.
|
|
18
|
-
"@objectstack/core": "4.0.
|
|
19
|
-
"@objectstack/spec": "4.0.
|
|
17
|
+
"better-auth": "^1.6.2",
|
|
18
|
+
"@objectstack/core": "4.0.3",
|
|
19
|
+
"@objectstack/spec": "4.0.3"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@types/node": "^25.
|
|
22
|
+
"@types/node": "^25.6.0",
|
|
23
23
|
"typescript": "^6.0.2",
|
|
24
|
-
"vitest": "^4.1.
|
|
25
|
-
"@objectstack/cli": "4.0.
|
|
24
|
+
"vitest": "^4.1.4",
|
|
25
|
+
"@objectstack/cli": "4.0.3"
|
|
26
26
|
},
|
|
27
27
|
"scripts": {
|
|
28
28
|
"build": "tsup --config ../../../tsup.config.ts",
|
package/src/auth-plugin.test.ts
CHANGED
|
@@ -24,7 +24,11 @@ describe('AuthPlugin', () => {
|
|
|
24
24
|
beforeEach(() => {
|
|
25
25
|
mockContext = {
|
|
26
26
|
registerService: vi.fn(),
|
|
27
|
-
getService: vi.fn()
|
|
27
|
+
getService: vi.fn((name: string) => {
|
|
28
|
+
if (name === 'manifest') return { register: vi.fn() };
|
|
29
|
+
if (name === 'data') return undefined;
|
|
30
|
+
return undefined;
|
|
31
|
+
}),
|
|
28
32
|
getServices: vi.fn(() => new Map()),
|
|
29
33
|
hook: vi.fn(),
|
|
30
34
|
trigger: vi.fn(),
|
|
@@ -47,7 +51,7 @@ describe('AuthPlugin', () => {
|
|
|
47
51
|
expect(authPlugin.name).toBe('com.objectstack.auth');
|
|
48
52
|
expect(authPlugin.type).toBe('standard');
|
|
49
53
|
expect(authPlugin.version).toBe('1.0.0');
|
|
50
|
-
expect(authPlugin.dependencies).toEqual([]);
|
|
54
|
+
expect(authPlugin.dependencies).toEqual(['com.objectstack.engine.objectql']);
|
|
51
55
|
});
|
|
52
56
|
});
|
|
53
57
|
|
package/src/auth-plugin.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
SysUser, SysSession, SysAccount, SysVerification,
|
|
8
8
|
SysOrganization, SysMember, SysInvitation,
|
|
9
9
|
SysTeam, SysTeamMember,
|
|
10
|
-
SysApiKey, SysTwoFactor,
|
|
10
|
+
SysApiKey, SysTwoFactor, SysUserPreference,
|
|
11
11
|
} from './objects/index.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -107,7 +107,7 @@ export class AuthPlugin implements Plugin {
|
|
|
107
107
|
SysUser, SysSession, SysAccount, SysVerification,
|
|
108
108
|
SysOrganization, SysMember, SysInvitation,
|
|
109
109
|
SysTeam, SysTeamMember,
|
|
110
|
-
SysApiKey, SysTwoFactor,
|
|
110
|
+
SysApiKey, SysTwoFactor, SysUserPreference,
|
|
111
111
|
],
|
|
112
112
|
});
|
|
113
113
|
|
package/src/objects/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ export { SysTeamMember } from './sys-team-member.object.js';
|
|
|
27
27
|
// ── Additional Auth Objects ────────────────────────────────────────────────
|
|
28
28
|
export { SysApiKey } from './sys-api-key.object.js';
|
|
29
29
|
export { SysTwoFactor } from './sys-two-factor.object.js';
|
|
30
|
+
export { SysUserPreference } from './sys-user-preference.object.js';
|
|
30
31
|
|
|
31
32
|
// ── Backward Compatibility (deprecated) ────────────────────────────────────
|
|
32
33
|
/** @deprecated Use `SysUser` instead */
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
|
|
2
|
+
|
|
3
|
+
import { ObjectSchema, Field } from '@objectstack/spec/data';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* sys_user_preference — System User Preference Object
|
|
7
|
+
*
|
|
8
|
+
* Per-user key-value preferences for storing UI state, settings, and personalization.
|
|
9
|
+
* Supports the User Preferences layer in the Config Resolution hierarchy
|
|
10
|
+
* (Runtime > User Preferences > Tenant > Env).
|
|
11
|
+
*
|
|
12
|
+
* Common use cases:
|
|
13
|
+
* - UI preferences: theme, locale, timezone, sidebar state
|
|
14
|
+
* - Feature flags: plugin.ai.auto_save, plugin.dev.debug_mode
|
|
15
|
+
* - User-specific settings: default_view, notifications_enabled
|
|
16
|
+
*
|
|
17
|
+
* @namespace sys
|
|
18
|
+
*/
|
|
19
|
+
export const SysUserPreference = ObjectSchema.create({
|
|
20
|
+
namespace: 'sys',
|
|
21
|
+
name: 'user_preference',
|
|
22
|
+
label: 'User Preference',
|
|
23
|
+
pluralLabel: 'User Preferences',
|
|
24
|
+
icon: 'settings',
|
|
25
|
+
isSystem: true,
|
|
26
|
+
description: 'Per-user key-value preferences (theme, locale, etc.)',
|
|
27
|
+
titleFormat: '{key}',
|
|
28
|
+
compactLayout: ['user_id', 'key'],
|
|
29
|
+
|
|
30
|
+
fields: {
|
|
31
|
+
id: Field.text({
|
|
32
|
+
label: 'Preference ID',
|
|
33
|
+
required: true,
|
|
34
|
+
readonly: true,
|
|
35
|
+
}),
|
|
36
|
+
|
|
37
|
+
created_at: Field.datetime({
|
|
38
|
+
label: 'Created At',
|
|
39
|
+
defaultValue: 'NOW()',
|
|
40
|
+
readonly: true,
|
|
41
|
+
}),
|
|
42
|
+
|
|
43
|
+
updated_at: Field.datetime({
|
|
44
|
+
label: 'Updated At',
|
|
45
|
+
defaultValue: 'NOW()',
|
|
46
|
+
readonly: true,
|
|
47
|
+
}),
|
|
48
|
+
|
|
49
|
+
user_id: Field.text({
|
|
50
|
+
label: 'User ID',
|
|
51
|
+
required: true,
|
|
52
|
+
maxLength: 255,
|
|
53
|
+
description: 'Owner user of this preference',
|
|
54
|
+
}),
|
|
55
|
+
|
|
56
|
+
key: Field.text({
|
|
57
|
+
label: 'Key',
|
|
58
|
+
required: true,
|
|
59
|
+
maxLength: 255,
|
|
60
|
+
description: 'Preference key (e.g., theme, locale, plugin.ai.auto_save)',
|
|
61
|
+
}),
|
|
62
|
+
|
|
63
|
+
value: Field.json({
|
|
64
|
+
label: 'Value',
|
|
65
|
+
description: 'Preference value (any JSON-serializable type)',
|
|
66
|
+
}),
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
indexes: [
|
|
70
|
+
{ fields: ['user_id', 'key'], unique: true },
|
|
71
|
+
{ fields: ['user_id'], unique: false },
|
|
72
|
+
],
|
|
73
|
+
|
|
74
|
+
enable: {
|
|
75
|
+
trackHistory: false,
|
|
76
|
+
searchable: false,
|
|
77
|
+
apiEnabled: true,
|
|
78
|
+
apiMethods: ['get', 'list', 'create', 'update', 'delete'],
|
|
79
|
+
trash: false,
|
|
80
|
+
mru: false,
|
|
81
|
+
},
|
|
82
|
+
});
|