@objectstack/platform-objects 7.0.0 → 7.2.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.
Files changed (43) hide show
  1. package/dist/apps/index.js +25 -29
  2. package/dist/apps/index.js.map +1 -1
  3. package/dist/apps/index.mjs +25 -29
  4. package/dist/apps/index.mjs.map +1 -1
  5. package/dist/audit/index.d.mts +192 -96
  6. package/dist/audit/index.d.ts +192 -96
  7. package/dist/identity/index.d.mts +244 -122
  8. package/dist/identity/index.d.ts +244 -122
  9. package/dist/identity/index.js +5 -2
  10. package/dist/identity/index.js.map +1 -1
  11. package/dist/identity/index.mjs +5 -2
  12. package/dist/identity/index.mjs.map +1 -1
  13. package/dist/index.d.mts +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +180 -31
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +180 -32
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/integration/index.d.mts +12 -6
  20. package/dist/integration/index.d.ts +12 -6
  21. package/dist/metadata/index.d.mts +3252 -13
  22. package/dist/metadata/index.d.ts +3252 -13
  23. package/dist/metadata/index.js +130 -0
  24. package/dist/metadata/index.js.map +1 -1
  25. package/dist/metadata/index.mjs +130 -1
  26. package/dist/metadata/index.mjs.map +1 -1
  27. package/dist/pages/index.d.mts +8 -3
  28. package/dist/pages/index.d.ts +8 -3
  29. package/dist/pages/index.js.map +1 -1
  30. package/dist/pages/index.mjs.map +1 -1
  31. package/dist/plugin.js +4 -8
  32. package/dist/plugin.js.map +1 -1
  33. package/dist/plugin.mjs +4 -8
  34. package/dist/plugin.mjs.map +1 -1
  35. package/dist/security/index.d.mts +84 -42
  36. package/dist/security/index.d.ts +84 -42
  37. package/dist/security/index.js +20 -0
  38. package/dist/security/index.js.map +1 -1
  39. package/dist/security/index.mjs +20 -0
  40. package/dist/security/index.mjs.map +1 -1
  41. package/dist/system/index.d.mts +36 -18
  42. package/dist/system/index.d.ts +36 -18
  43. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -10,6 +10,9 @@ var SysUser = ObjectSchema.create({
10
10
  icon: "user",
11
11
  isSystem: true,
12
12
  managedBy: "better-auth",
13
+ // ADR-0010 — identity table is managed by better-auth, schema must not drift.
14
+ _lock: "full",
15
+ _lockReason: "Identity table managed by better-auth \u2014 see ADR-0010.",
13
16
  description: "User accounts for authentication",
14
17
  displayNameField: "name",
15
18
  titleFormat: "{name}",
@@ -601,7 +604,7 @@ var SysAccount = ObjectSchema.create({
601
604
  mode: "create",
602
605
  locations: ["list_toolbar"],
603
606
  type: "url",
604
- target: "/api/v1/auth/sign-in/social?provider=${param.provider}&callbackURL=${ctx.origin}/apps/account/sys_account",
607
+ target: "/api/v1/auth/sign-in/social?provider=${param.provider}&callbackURL=${ctx.origin}/_console/apps/account/sys_account",
605
608
  params: [
606
609
  {
607
610
  name: "provider",
@@ -2395,7 +2398,7 @@ var SysOauthApplication = ObjectSchema.create({
2395
2398
  locations: ["list_toolbar"],
2396
2399
  type: "api",
2397
2400
  method: "POST",
2398
- target: "/api/v1/auth/oauth2/register",
2401
+ target: "/api/v1/auth/sys-oauth-application/register",
2399
2402
  refreshAfter: true,
2400
2403
  params: [
2401
2404
  { name: "name", label: "Application Name", type: "text", required: true },
@@ -4204,6 +4207,16 @@ var defaultPermissionSets = [
4204
4207
  operation: "all",
4205
4208
  using: "user_id = current_user.id"
4206
4209
  },
4210
+ // OAuth applications a user has registered themselves (self-service
4211
+ // developer flow exposed in the Account app's Developer section).
4212
+ // `sys_oauth_application` has no `organization_id` so the wildcard
4213
+ // `tenant_isolation` policy would otherwise deny every row.
4214
+ {
4215
+ name: "sys_oauth_application_self",
4216
+ object: "sys_oauth_application",
4217
+ operation: "all",
4218
+ using: "user_id = current_user.id"
4219
+ },
4207
4220
  // Org-scoped visibility for organization-owned identity-adjacent
4208
4221
  // tables. Org admins may inspect their own org's invitations and
4209
4222
  // memberships (read; writes still flow through better-auth).
@@ -4356,6 +4369,16 @@ var defaultPermissionSets = [
4356
4369
  object: "sys_oauth_consent",
4357
4370
  operation: "all",
4358
4371
  using: "user_id = current_user.id"
4372
+ },
4373
+ // OAuth applications a user has registered themselves (Account →
4374
+ // Developer → OAuth Applications). `sys_oauth_application` has no
4375
+ // `organization_id`, so without this carve-out the wildcard
4376
+ // `tenant_isolation` policy returns zero rows even for the owner.
4377
+ {
4378
+ name: "sys_oauth_application_self",
4379
+ object: "sys_oauth_application",
4380
+ operation: "all",
4381
+ using: "user_id = current_user.id"
4359
4382
  }
4360
4383
  ]
4361
4384
  }),
@@ -6902,6 +6925,135 @@ var SysMetadataHistoryObject = ObjectSchema.create({
6902
6925
  trash: false
6903
6926
  }
6904
6927
  });
6928
+ var SysMetadataAuditObject = ObjectSchema.create({
6929
+ name: "sys_metadata_audit",
6930
+ label: "Metadata Audit",
6931
+ pluralLabel: "Metadata Audit",
6932
+ icon: "shield-check",
6933
+ isSystem: true,
6934
+ managedBy: "append-only",
6935
+ description: "Append-only audit trail of metadata write decisions (ADR-0010).",
6936
+ fields: {
6937
+ /** Primary Key (UUID) */
6938
+ id: Field.text({
6939
+ label: "ID",
6940
+ required: true,
6941
+ readonly: true
6942
+ }),
6943
+ /** When the decision was made (ISO-8601 UTC). */
6944
+ occurred_at: Field.datetime({
6945
+ label: "Occurred At",
6946
+ required: true,
6947
+ readonly: true
6948
+ }),
6949
+ /** Acting principal (user id, system id, or 'system'). */
6950
+ actor: Field.text({
6951
+ label: "Actor",
6952
+ required: true,
6953
+ readonly: true,
6954
+ maxLength: 255,
6955
+ description: 'Acting principal \u2014 user id, system id, or "system".'
6956
+ }),
6957
+ /** Code path that produced the decision (e.g. `protocol.saveMetaItem`). */
6958
+ source: Field.text({
6959
+ label: "Source",
6960
+ required: false,
6961
+ readonly: true,
6962
+ maxLength: 128
6963
+ }),
6964
+ /** Metadata type (singular, e.g. `app`, `object`, `view`). */
6965
+ type: Field.text({
6966
+ label: "Metadata Type",
6967
+ required: true,
6968
+ readonly: true,
6969
+ searchable: true,
6970
+ maxLength: 100
6971
+ }),
6972
+ /** Item machine name. */
6973
+ name: Field.text({
6974
+ label: "Name",
6975
+ required: true,
6976
+ readonly: true,
6977
+ searchable: true,
6978
+ maxLength: 255
6979
+ }),
6980
+ /** Organization for multi-tenant filtering. NULL for env-wide writes. */
6981
+ organization_id: Field.lookup("sys_organization", {
6982
+ label: "Organization",
6983
+ required: false,
6984
+ readonly: true
6985
+ }),
6986
+ /** Operation kind. */
6987
+ operation: Field.select(["save", "publish", "rollback", "delete", "reset"], {
6988
+ label: "Operation",
6989
+ required: true,
6990
+ readonly: true
6991
+ }),
6992
+ /** Decision outcome — allowed, denied (refused), or forced (bypassed via override). */
6993
+ outcome: Field.select(["allowed", "denied", "forced"], {
6994
+ label: "Outcome",
6995
+ required: true,
6996
+ readonly: true
6997
+ }),
6998
+ /**
6999
+ * Machine-readable code for the decision:
7000
+ * - on `allowed`: `'ok'`
7001
+ * - on `denied`: `'not_overridable'` | `'not_creatable'` |
7002
+ * `'item_locked'` | `'invalid_metadata'` | `'destructive_change'` |
7003
+ * `'metadata_conflict'`
7004
+ * - on `forced`: `'lock_override'` (Phase 3)
7005
+ */
7006
+ code: Field.text({
7007
+ label: "Code",
7008
+ required: true,
7009
+ readonly: true,
7010
+ maxLength: 64
7011
+ }),
7012
+ /**
7013
+ * Lock state observed at the time of the decision (`none` if the
7014
+ * item carried no `_lock`). Captured even on `allowed` rows so
7015
+ * later compliance queries can see "what was the lock state when
7016
+ * this write succeeded".
7017
+ */
7018
+ lock_state: Field.select(["none", "no-overlay", "no-delete", "full"], {
7019
+ label: "Lock State",
7020
+ required: false,
7021
+ readonly: true
7022
+ }),
7023
+ /** True when the write succeeded by bypassing a lock (Phase 3). */
7024
+ lock_overridden: Field.boolean({
7025
+ label: "Lock Overridden",
7026
+ required: false,
7027
+ readonly: true
7028
+ }),
7029
+ /** Optional request correlation id for tracing. */
7030
+ request_id: Field.text({
7031
+ label: "Request ID",
7032
+ required: false,
7033
+ readonly: true,
7034
+ maxLength: 128
7035
+ }),
7036
+ /** Optional free-form context (e.g. brief diff summary). */
7037
+ note: Field.textarea({
7038
+ label: "Note",
7039
+ required: false,
7040
+ readonly: true
7041
+ })
7042
+ },
7043
+ indexes: [
7044
+ { fields: ["organization_id", "occurred_at"] },
7045
+ { fields: ["type", "name", "occurred_at"] },
7046
+ { fields: ["actor", "occurred_at"] },
7047
+ { fields: ["outcome"] }
7048
+ ],
7049
+ enable: {
7050
+ trackHistory: false,
7051
+ searchable: false,
7052
+ apiEnabled: true,
7053
+ apiMethods: ["get", "list"],
7054
+ trash: false
7055
+ }
7056
+ });
6905
7057
  var SysSetting = ObjectSchema.create({
6906
7058
  name: "sys_setting",
6907
7059
  label: "Setting",
@@ -7295,6 +7447,9 @@ var SETUP_APP = {
7295
7447
  icon: "settings",
7296
7448
  active: true,
7297
7449
  isDefault: false,
7450
+ // ADR-0010 — core admin UI must not be overlay-edited or deleted.
7451
+ _lock: "full",
7452
+ _lockReason: "Core admin UI shipped by @objectstack/platform-objects \u2014 see ADR-0010.",
7298
7453
  branding: {
7299
7454
  primaryColor: "#475569"
7300
7455
  // Slate-600 — neutral admin palette
@@ -7785,21 +7940,20 @@ var ACCOUNT_APP = {
7785
7940
  // manage their own 2FA / linked accounts / personal OAuth apps. RLS on
7786
7941
  // each object scopes rows to the caller.
7787
7942
  navigation: [
7788
- // Profile is the canonical landing — name, email, avatar, verification
7789
- // status. Uses `type: 'object' + recordId: '{current_user_id}'` so it
7790
- // resolves to the sys_user record page; the slotted SysUserDetailPage
7791
- // (kind: 'slotted', isDefault: true) tailors that page into a proper
7792
- // self-service profile (highlight chips, grouped detail sections, no
7793
- // Discussion thread) without losing the record-context features
7794
- // (related lists, header actions, RLS-aware edit).
7943
+ // Profile is the canonical landing — a hand-written React settings card
7944
+ // (Vercel/Linear style) registered in the Console SPA as
7945
+ // `account:profile_card`. The renderer reads the current user via
7946
+ // `useAuth()` and writes via `client.auth.updateUser`, so there is no
7947
+ // sys_user record context here this is intentional. The admin-facing
7948
+ // sys_user record page (see `pages/sys-user.page.ts`) stays focused on
7949
+ // record browsing (Identity/Audit fields, related lists, admin actions)
7950
+ // and is reached through Setup, never from the Account App.
7795
7951
  {
7796
7952
  id: "nav_account_profile",
7797
- type: "object",
7953
+ type: "component",
7798
7954
  label: "Profile",
7799
- objectName: "sys_user",
7800
- recordId: "{current_user_id}",
7801
- icon: "user-circle",
7802
- requiresObject: "sys_user"
7955
+ componentRef: "account:profile_card",
7956
+ icon: "user-circle"
7803
7957
  },
7804
7958
  // --- Inbox & work assigned to me -----------------------------------
7805
7959
  // Notifications, approvals waiting on me, and the orgs I belong to.
@@ -7903,16 +8057,14 @@ var ACCOUNT_APP = {
7903
8057
  requiresObject: "sys_oauth_application"
7904
8058
  }
7905
8059
  ]
7906
- },
7907
- {
7908
- id: "nav_account_preferences",
7909
- type: "object",
7910
- label: "Preferences",
7911
- objectName: "sys_user_preference",
7912
- viewName: "mine",
7913
- icon: "sliders-horizontal",
7914
- requiresObject: "sys_user_preference"
7915
8060
  }
8061
+ // Note: `sys_user_preference` is intentionally NOT exposed in the
8062
+ // Account App. It's an internal key-value store the UI uses for state
8063
+ // like `ui.recent`, `ui.favorites`, theme, sidebar collapse — not
8064
+ // a user-curatable settings surface. A future
8065
+ // `account:preferences_card` React component should provide the
8066
+ // curated theme / locale / timezone / notifications toggles when we
8067
+ // need them; until then there is no nav entry.
7916
8068
  ]
7917
8069
  };
7918
8070
  var SystemOverviewDashboard = Dashboard.create({
@@ -11131,8 +11283,7 @@ var en = {
11131
11283
  nav_account_linked: { label: "Linked Accounts" },
11132
11284
  nav_account_sessions: { label: "Active Sessions" },
11133
11285
  nav_account_api_keys: { label: "API Keys" },
11134
- nav_account_oauth_apps: { label: "OAuth Applications" },
11135
- nav_account_preferences: { label: "Preferences" }
11286
+ nav_account_oauth_apps: { label: "OAuth Applications" }
11136
11287
  }
11137
11288
  },
11138
11289
  setup: {
@@ -14343,8 +14494,7 @@ var zhCN = {
14343
14494
  nav_account_linked: { label: "\u5DF2\u5173\u8054\u8D26\u6237" },
14344
14495
  nav_account_sessions: { label: "\u6D3B\u52A8\u4F1A\u8BDD" },
14345
14496
  nav_account_api_keys: { label: "API \u5BC6\u94A5" },
14346
- nav_account_oauth_apps: { label: "OAuth \u5E94\u7528" },
14347
- nav_account_preferences: { label: "\u504F\u597D\u8BBE\u7F6E" }
14497
+ nav_account_oauth_apps: { label: "OAuth \u5E94\u7528" }
14348
14498
  }
14349
14499
  },
14350
14500
  setup: {
@@ -17516,8 +17666,7 @@ var jaJP = {
17516
17666
  nav_account_linked: { label: "\u9023\u643A\u30A2\u30AB\u30A6\u30F3\u30C8" },
17517
17667
  nav_account_sessions: { label: "\u30A2\u30AF\u30C6\u30A3\u30D6\u30BB\u30C3\u30B7\u30E7\u30F3" },
17518
17668
  nav_account_api_keys: { label: "API \u30AD\u30FC" },
17519
- nav_account_oauth_apps: { label: "OAuth \u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3" },
17520
- nav_account_preferences: { label: "\u74B0\u5883\u8A2D\u5B9A" }
17669
+ nav_account_oauth_apps: { label: "OAuth \u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3" }
17521
17670
  }
17522
17671
  },
17523
17672
  setup: {
@@ -20689,8 +20838,7 @@ var esES = {
20689
20838
  nav_account_linked: { label: "Cuentas vinculadas" },
20690
20839
  nav_account_sessions: { label: "Sesiones activas" },
20691
20840
  nav_account_api_keys: { label: "Claves API" },
20692
- nav_account_oauth_apps: { label: "Aplicaciones OAuth" },
20693
- nav_account_preferences: { label: "Preferencias" }
20841
+ nav_account_oauth_apps: { label: "Aplicaciones OAuth" }
20694
20842
  }
20695
20843
  },
20696
20844
  setup: {
@@ -25987,6 +26135,6 @@ function createPlatformObjectsPlugin() {
25987
26135
  return new PlatformObjectsPlugin();
25988
26136
  }
25989
26137
 
25990
- export { ACCOUNT_APP, MetadataFormsTranslations, PlatformObjectsPlugin, SETUP_APP, STUDIO_APP, SetupAppTranslations, SysAccount, SysActivity, SysApiKey, SysApprovalAction, SysApprovalProcess, SysApprovalRequest, SysAttachment, SysAuditLog, SysComment, SysDepartment, SysDepartmentMember, SysDeviceCode, SysEmail, SysEmailTemplate, SysInvitation, SysJob, SysJobQueue, SysJobRun, SysJwks, SysMember, SysMetadataObject as SysMetadata, SysMetadataHistoryObject, SysMetadataObject, SysNotification, SysOauthAccessToken, SysOauthApplication, SysOauthConsent, SysOauthRefreshToken, SysOrganization, SysOrganizationDetailPage, SysPermissionSet, SysPresence, SysRecordShare, SysReportSchedule, SysRole, SysRolePermissionSet, SysSavedReport, SysSecret, SysSession, SysSetting, SysSettingAudit, SysShareLink, SysSharingRule, SysTeam, SysTeamMember, SysTwoFactor, SysUser, SysUserDetailPage, SysUserPermissionSet, SysUserPreference, SysVerification, SysWebhook, SystemOverviewDashboard, createPlatformObjectsPlugin, defaultPermissionSets, en, esES, jaJP, zhCN };
26138
+ export { ACCOUNT_APP, MetadataFormsTranslations, PlatformObjectsPlugin, SETUP_APP, STUDIO_APP, SetupAppTranslations, SysAccount, SysActivity, SysApiKey, SysApprovalAction, SysApprovalProcess, SysApprovalRequest, SysAttachment, SysAuditLog, SysComment, SysDepartment, SysDepartmentMember, SysDeviceCode, SysEmail, SysEmailTemplate, SysInvitation, SysJob, SysJobQueue, SysJobRun, SysJwks, SysMember, SysMetadataObject as SysMetadata, SysMetadataAuditObject, SysMetadataHistoryObject, SysMetadataObject, SysNotification, SysOauthAccessToken, SysOauthApplication, SysOauthConsent, SysOauthRefreshToken, SysOrganization, SysOrganizationDetailPage, SysPermissionSet, SysPresence, SysRecordShare, SysReportSchedule, SysRole, SysRolePermissionSet, SysSavedReport, SysSecret, SysSession, SysSetting, SysSettingAudit, SysShareLink, SysSharingRule, SysTeam, SysTeamMember, SysTwoFactor, SysUser, SysUserDetailPage, SysUserPermissionSet, SysUserPreference, SysVerification, SysWebhook, SystemOverviewDashboard, createPlatformObjectsPlugin, defaultPermissionSets, en, esES, jaJP, zhCN };
25991
26139
  //# sourceMappingURL=index.mjs.map
25992
26140
  //# sourceMappingURL=index.mjs.map