Skip to content

Commit afa2f9b

Browse files
committed
Refactor field types in various objects to use lookup fields for user and organization references
- Changed `Field.text` to `Field.lookup` for user and organization IDs in multiple objects, enhancing data integrity and relationships. - Updated labels for clarity, ensuring they reflect the new field types. - Adjusted descriptions to align with the new field implementations.
1 parent be252ae commit afa2f9b

37 files changed

Lines changed: 147 additions & 162 deletions

packages/platform-objects/src/audit/sys-activity.object.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ export const SysActivity = ObjectSchema.create({
7777
}),
7878

7979
// ── Actor ───────────────────────────────────────────────────
80-
actor_id: Field.text({
81-
label: 'Actor ID',
80+
actor_id: Field.lookup('sys_user', {
81+
label: 'Actor',
8282
required: false,
8383
readonly: true,
8484
searchable: true,
@@ -136,7 +136,7 @@ export const SysActivity = ObjectSchema.create({
136136
}),
137137

138138
// ── Context ──────────────────────────────────────────────────
139-
project_id: Field.text({
139+
project_id: Field.lookup('sys_project', {
140140
label: 'Project',
141141
required: false,
142142
readonly: true,

packages/platform-objects/src/audit/sys-audit-log.object.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const SysAuditLog = ObjectSchema.create({
4646
},
4747
),
4848

49-
user_id: Field.text({
49+
user_id: Field.lookup('sys_user', {
5050
label: 'Actor',
5151
required: false,
5252
readonly: true,
@@ -109,7 +109,7 @@ export const SysAuditLog = ObjectSchema.create({
109109
}),
110110

111111
// ── Context ──────────────────────────────────────────────────
112-
tenant_id: Field.text({
112+
tenant_id: Field.lookup('sys_organization', {
113113
label: 'Tenant',
114114
required: false,
115115
readonly: true,

packages/platform-objects/src/audit/sys-comment.object.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const SysComment = ObjectSchema.create({
4747
group: 'Thread',
4848
}),
4949

50-
parent_id: Field.text({
50+
parent_id: Field.lookup('sys_comment', {
5151
label: 'Parent Comment',
5252
required: false,
5353
description: 'Optional parent comment for nested replies',
@@ -62,8 +62,8 @@ export const SysComment = ObjectSchema.create({
6262
}),
6363

6464
// ── Author ───────────────────────────────────────────────────
65-
author_id: Field.text({
66-
label: 'Author ID',
65+
author_id: Field.lookup('sys_user', {
66+
label: 'Author',
6767
required: true,
6868
searchable: true,
6969
group: 'Author',

packages/platform-objects/src/audit/sys-presence.object.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ export const SysPresence = ObjectSchema.create({
4343
readonly: true,
4444
}),
4545

46-
user_id: Field.text({
47-
label: 'User ID',
46+
user_id: Field.lookup('sys_user', {
47+
label: 'User',
4848
required: true,
4949
searchable: true,
5050
}),
5151

52-
session_id: Field.text({
53-
label: 'Session ID',
52+
session_id: Field.lookup('sys_session', {
53+
label: 'Session',
5454
required: true,
5555
}),
5656

packages/platform-objects/src/identity/sys-account.object.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ export const SysAccount = ObjectSchema.create({
5151
description: "User's ID in the provider's system",
5252
}),
5353

54-
user_id: Field.text({
55-
label: 'User ID',
54+
user_id: Field.lookup('sys_user', {
55+
label: 'User',
5656
required: true,
5757
description: 'Link to user table',
5858
}),

packages/platform-objects/src/identity/sys-api-key.object.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const SysApiKey = ObjectSchema.create({
4343
group: 'Identity',
4444
}),
4545

46-
user_id: Field.text({
46+
user_id: Field.lookup('sys_user', {
4747
label: 'Owner',
4848
required: true,
4949
description: 'User who owns this API key',

packages/platform-objects/src/identity/sys-device-code.object.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export const SysDeviceCode = ObjectSchema.create({
6363
}),
6464

6565
/** Owning user — populated when the request is approved. */
66-
user_id: Field.text({
67-
label: 'User ID',
66+
user_id: Field.lookup('sys_user', {
67+
label: 'User',
6868
required: false,
6969
description: 'User who approved the device authorization',
7070
}),

packages/platform-objects/src/identity/sys-invitation.object.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ export const SysInvitation = ObjectSchema.create({
3333
readonly: true,
3434
}),
3535

36-
organization_id: Field.text({
37-
label: 'Organization ID',
36+
organization_id: Field.lookup('sys_organization', {
37+
label: 'Organization',
3838
required: true,
3939
}),
4040

@@ -57,19 +57,19 @@ export const SysInvitation = ObjectSchema.create({
5757
defaultValue: 'pending',
5858
}),
5959

60-
inviter_id: Field.text({
61-
label: 'Inviter ID',
60+
inviter_id: Field.lookup('sys_user', {
61+
label: 'Inviter',
6262
required: true,
63-
description: 'User ID of the person who sent the invitation',
63+
description: 'User who sent the invitation',
6464
}),
6565

6666
expires_at: Field.datetime({
6767
label: 'Expires At',
6868
required: true,
6969
}),
7070

71-
team_id: Field.text({
72-
label: 'Team ID',
71+
team_id: Field.lookup('sys_team', {
72+
label: 'Team',
7373
required: false,
7474
description: 'Optional team to assign upon acceptance',
7575
}),

packages/platform-objects/src/identity/sys-member.object.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ export const SysMember = ObjectSchema.create({
3333
readonly: true,
3434
}),
3535

36-
organization_id: Field.text({
37-
label: 'Organization ID',
36+
organization_id: Field.lookup('sys_organization', {
37+
label: 'Organization',
3838
required: true,
3939
}),
4040

41-
user_id: Field.text({
42-
label: 'User ID',
41+
user_id: Field.lookup('sys_user', {
42+
label: 'User',
4343
required: true,
4444
}),
4545

packages/platform-objects/src/identity/sys-oauth-access-token.object.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,20 @@ export const SysOauthAccessToken = ObjectSchema.create({
4444
description: 'Foreign key to sys_oauth_application.client_id',
4545
}),
4646

47-
session_id: Field.text({
48-
label: 'Session ID',
47+
session_id: Field.lookup('sys_session', {
48+
label: 'Session',
4949
required: false,
5050
description: 'Foreign key to sys_session.id',
5151
}),
5252

53-
user_id: Field.text({
54-
label: 'User ID',
53+
user_id: Field.lookup('sys_user', {
54+
label: 'User',
5555
required: false,
5656
description: 'Foreign key to sys_user.id',
5757
}),
5858

59-
refresh_id: Field.text({
60-
label: 'Refresh Token ID',
59+
refresh_id: Field.lookup('sys_oauth_refresh_token', {
60+
label: 'Refresh Token',
6161
required: false,
6262
description: 'Foreign key to sys_oauth_refresh_token.id',
6363
}),

0 commit comments

Comments
 (0)