@objectstack/platform-objects 6.9.0 → 7.1.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 (51) hide show
  1. package/dist/apps/index.d.mts +30 -1
  2. package/dist/apps/index.d.ts +30 -1
  3. package/dist/apps/index.js +987 -37
  4. package/dist/apps/index.js.map +1 -1
  5. package/dist/apps/index.mjs +987 -38
  6. package/dist/apps/index.mjs.map +1 -1
  7. package/dist/audit/index.d.mts +240 -64
  8. package/dist/audit/index.d.ts +240 -64
  9. package/dist/identity/index.d.mts +900 -82
  10. package/dist/identity/index.d.ts +900 -82
  11. package/dist/identity/index.js +384 -8
  12. package/dist/identity/index.js.map +1 -1
  13. package/dist/identity/index.mjs +384 -8
  14. package/dist/identity/index.mjs.map +1 -1
  15. package/dist/index.d.mts +4 -1
  16. package/dist/index.d.ts +4 -1
  17. package/dist/index.js +6823 -99
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +6818 -100
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/integration/index.d.mts +15 -4
  22. package/dist/integration/index.d.ts +15 -4
  23. package/dist/metadata/index.d.mts +30 -8
  24. package/dist/metadata/index.d.ts +30 -8
  25. package/dist/metadata-translations/index.d.mts +20 -0
  26. package/dist/metadata-translations/index.d.ts +20 -0
  27. package/dist/metadata-translations/index.js +4777 -0
  28. package/dist/metadata-translations/index.js.map +1 -0
  29. package/dist/metadata-translations/index.mjs +4775 -0
  30. package/dist/metadata-translations/index.mjs.map +1 -0
  31. package/dist/pages/index.d.mts +73 -0
  32. package/dist/pages/index.d.ts +73 -0
  33. package/dist/pages/index.js +371 -0
  34. package/dist/pages/index.js.map +1 -0
  35. package/dist/pages/index.mjs +368 -0
  36. package/dist/pages/index.mjs.map +1 -0
  37. package/dist/plugin.d.mts +35 -0
  38. package/dist/plugin.d.ts +35 -0
  39. package/dist/plugin.js +17562 -0
  40. package/dist/plugin.js.map +1 -0
  41. package/dist/plugin.mjs +17559 -0
  42. package/dist/plugin.mjs.map +1 -0
  43. package/dist/security/index.d.mts +806 -204
  44. package/dist/security/index.d.ts +806 -204
  45. package/dist/security/index.js +208 -1
  46. package/dist/security/index.js.map +1 -1
  47. package/dist/security/index.mjs +208 -1
  48. package/dist/security/index.mjs.map +1 -1
  49. package/dist/system/index.d.mts +45 -12
  50. package/dist/system/index.d.ts +45 -12
  51. package/package.json +17 -2
@@ -342,6 +342,24 @@ var SysPermissionSet = data.ObjectSchema.create({
342
342
  description: "JSON-serialized field-level read/write permissions",
343
343
  group: "Permissions"
344
344
  }),
345
+ system_permissions: data.Field.textarea({
346
+ label: "System Permissions",
347
+ required: false,
348
+ description: 'JSON-serialized array of system capability names (e.g. ["setup.access","studio.access","manage_users"])',
349
+ group: "Permissions"
350
+ }),
351
+ row_level_security: data.Field.textarea({
352
+ label: "Row-Level Security",
353
+ required: false,
354
+ description: "JSON-serialized array of row-level security policies (USING/CHECK clauses)",
355
+ group: "Permissions"
356
+ }),
357
+ tab_permissions: data.Field.textarea({
358
+ label: "Tab Permissions",
359
+ required: false,
360
+ description: "JSON-serialized map of app tab visibility (visible | hidden | default_on | default_off)",
361
+ group: "Permissions"
362
+ }),
345
363
  // ── Status ───────────────────────────────────────────────────
346
364
  active: data.Field.boolean({
347
365
  label: "Active",
@@ -1061,7 +1079,186 @@ var defaultPermissionSets = [
1061
1079
  modifyAllRecords: true
1062
1080
  }
1063
1081
  },
1064
- systemPermissions: ["manage_users", "manage_metadata", "setup.access", "studio.access"]
1082
+ systemPermissions: [
1083
+ "manage_users",
1084
+ "manage_metadata",
1085
+ "manage_platform_settings",
1086
+ "setup.access",
1087
+ "studio.access"
1088
+ ]
1089
+ }),
1090
+ // ── Organization Administrator ──────────────────────────────────────
1091
+ //
1092
+ // Third tier between platform admin (`admin_full_access`) and rank-and-file
1093
+ // member. Lives at the *organization* scope: full CRUD on business
1094
+ // objects within their org (governed by `tenant_isolation` RLS), plus
1095
+ // `setup.access` so the Setup app shell is reachable.
1096
+ //
1097
+ // **Deliberately withheld** vs `admin_full_access`:
1098
+ // - `studio.access` — schema-design surfaces are platform-level (a
1099
+ // tenant cannot mutate the shared metadata) and Studio is hidden.
1100
+ // - `manage_metadata` — same reasoning.
1101
+ // - `manage_platform_settings` — global settings manifests
1102
+ // (mail / storage / AI / knowledge) and platform-only Setup pages
1103
+ // (sharing rules, audit logs, OAuth apps, JWKS, …) require this
1104
+ // and are hidden / 403'd for org admins. Tenant-scoped manifests
1105
+ // (`branding`, `feature_flags`) keep using `setup.access` so org
1106
+ // admins CAN configure their own org's branding.
1107
+ //
1108
+ // **Anti-escalation**: writes to the global RBAC tables
1109
+ // (`sys_role`, `sys_permission_set`, `sys_role_permission_set`,
1110
+ // `sys_user_permission_set`, `sys_user_role`) are denied. Allowing
1111
+ // them would let an org admin bind `admin_full_access` (which has no
1112
+ // RLS) to themselves and break out of tenant isolation. Reads are
1113
+ // permitted so the Roles / Permission Sets nav entries still render.
1114
+ //
1115
+ // Auto-granted to every `sys_member` whose role contains `owner` or
1116
+ // `admin` by `plugin-security/src/auto-org-admin-grant.ts`.
1117
+ security.PermissionSetSchema.parse({
1118
+ name: "organization_admin",
1119
+ label: "Organization Administrator",
1120
+ isProfile: true,
1121
+ objects: {
1122
+ "*": {
1123
+ allowRead: true,
1124
+ allowCreate: true,
1125
+ allowEdit: true,
1126
+ allowDelete: true,
1127
+ viewAllRecords: true,
1128
+ modifyAllRecords: true
1129
+ },
1130
+ // Identity tables — go through better-auth endpoints (invite,
1131
+ // accept, remove-member, transfer, …) rather than raw CRUD.
1132
+ ...denyWritesOnManagedObjects(),
1133
+ // RBAC tables — read-only to prevent privilege escalation.
1134
+ sys_role: { allowRead: true, allowCreate: false, allowEdit: false, allowDelete: false },
1135
+ sys_permission_set: { allowRead: true, allowCreate: false, allowEdit: false, allowDelete: false },
1136
+ sys_role_permission_set: { allowRead: true, allowCreate: false, allowEdit: false, allowDelete: false },
1137
+ sys_user_permission_set: { allowRead: true, allowCreate: false, allowEdit: false, allowDelete: false },
1138
+ sys_user_role: { allowRead: true, allowCreate: false, allowEdit: false, allowDelete: false }
1139
+ },
1140
+ systemPermissions: ["manage_org_users", "setup.access"],
1141
+ rowLevelSecurity: [
1142
+ {
1143
+ name: "tenant_isolation",
1144
+ object: "*",
1145
+ operation: "all",
1146
+ using: "organization_id = current_user.organization_id"
1147
+ },
1148
+ // ── better-auth system tables that lack `organization_id` and would
1149
+ // otherwise be denied by the wildcard policy. Same self-only
1150
+ // carve-outs as `member_default` — an org admin does not get to
1151
+ // inspect cross-tenant identity rows.
1152
+ {
1153
+ name: "sys_organization_self",
1154
+ object: "sys_organization",
1155
+ operation: "all",
1156
+ using: "id = current_user.organization_id"
1157
+ },
1158
+ {
1159
+ name: "sys_user_self",
1160
+ object: "sys_user",
1161
+ operation: "select",
1162
+ using: "id = current_user.id"
1163
+ },
1164
+ {
1165
+ name: "sys_user_org_members",
1166
+ object: "sys_user",
1167
+ operation: "select",
1168
+ using: "id IN (current_user.org_user_ids)"
1169
+ },
1170
+ {
1171
+ name: "sys_session_self",
1172
+ object: "sys_session",
1173
+ operation: "all",
1174
+ using: "user_id = current_user.id"
1175
+ },
1176
+ {
1177
+ name: "sys_account_self",
1178
+ object: "sys_account",
1179
+ operation: "select",
1180
+ using: "user_id = current_user.id"
1181
+ },
1182
+ {
1183
+ name: "sys_team_member_self",
1184
+ object: "sys_team_member",
1185
+ operation: "select",
1186
+ using: "user_id = current_user.id"
1187
+ },
1188
+ {
1189
+ name: "sys_two_factor_self",
1190
+ object: "sys_two_factor",
1191
+ operation: "all",
1192
+ using: "user_id = current_user.id"
1193
+ },
1194
+ {
1195
+ name: "sys_user_preference_self",
1196
+ object: "sys_user_preference",
1197
+ operation: "all",
1198
+ using: "user_id = current_user.id"
1199
+ },
1200
+ {
1201
+ name: "sys_api_key_self",
1202
+ object: "sys_api_key",
1203
+ operation: "all",
1204
+ using: "user_id = current_user.id"
1205
+ },
1206
+ {
1207
+ name: "sys_device_code_self",
1208
+ object: "sys_device_code",
1209
+ operation: "all",
1210
+ using: "user_id = current_user.id"
1211
+ },
1212
+ {
1213
+ name: "sys_oauth_access_token_self",
1214
+ object: "sys_oauth_access_token",
1215
+ operation: "select",
1216
+ using: "user_id = current_user.id"
1217
+ },
1218
+ {
1219
+ name: "sys_oauth_refresh_token_self",
1220
+ object: "sys_oauth_refresh_token",
1221
+ operation: "select",
1222
+ using: "user_id = current_user.id"
1223
+ },
1224
+ {
1225
+ name: "sys_oauth_consent_self",
1226
+ object: "sys_oauth_consent",
1227
+ operation: "all",
1228
+ using: "user_id = current_user.id"
1229
+ },
1230
+ // OAuth applications a user has registered themselves (self-service
1231
+ // developer flow exposed in the Account app's Developer section).
1232
+ // `sys_oauth_application` has no `organization_id` so the wildcard
1233
+ // `tenant_isolation` policy would otherwise deny every row.
1234
+ {
1235
+ name: "sys_oauth_application_self",
1236
+ object: "sys_oauth_application",
1237
+ operation: "all",
1238
+ using: "user_id = current_user.id"
1239
+ },
1240
+ // Org-scoped visibility for organization-owned identity-adjacent
1241
+ // tables. Org admins may inspect their own org's invitations and
1242
+ // memberships (read; writes still flow through better-auth).
1243
+ {
1244
+ name: "sys_member_org",
1245
+ object: "sys_member",
1246
+ operation: "select",
1247
+ using: "organization_id = current_user.organization_id"
1248
+ },
1249
+ {
1250
+ name: "sys_invitation_org",
1251
+ object: "sys_invitation",
1252
+ operation: "select",
1253
+ using: "organization_id = current_user.organization_id"
1254
+ },
1255
+ {
1256
+ name: "sys_team_org",
1257
+ object: "sys_team",
1258
+ operation: "select",
1259
+ using: "organization_id = current_user.organization_id"
1260
+ }
1261
+ ]
1065
1262
  }),
1066
1263
  security.PermissionSetSchema.parse({
1067
1264
  name: "member_default",
@@ -1192,6 +1389,16 @@ var defaultPermissionSets = [
1192
1389
  object: "sys_oauth_consent",
1193
1390
  operation: "all",
1194
1391
  using: "user_id = current_user.id"
1392
+ },
1393
+ // OAuth applications a user has registered themselves (Account →
1394
+ // Developer → OAuth Applications). `sys_oauth_application` has no
1395
+ // `organization_id`, so without this carve-out the wildcard
1396
+ // `tenant_isolation` policy returns zero rows even for the owner.
1397
+ {
1398
+ name: "sys_oauth_application_self",
1399
+ object: "sys_oauth_application",
1400
+ operation: "all",
1401
+ using: "user_id = current_user.id"
1195
1402
  }
1196
1403
  ]
1197
1404
  }),