@objectstack/platform-objects 6.8.1 → 7.0.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 +994 -37
  4. package/dist/apps/index.js.map +1 -1
  5. package/dist/apps/index.mjs +994 -38
  6. package/dist/apps/index.mjs.map +1 -1
  7. package/dist/audit/index.d.mts +320 -16
  8. package/dist/audit/index.d.ts +320 -16
  9. package/dist/identity/index.d.mts +1000 -22
  10. package/dist/identity/index.d.ts +1000 -22
  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 +5 -2
  16. package/dist/index.d.ts +5 -2
  17. package/dist/index.js +7060 -154
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +7054 -155
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/integration/index.d.mts +20 -1
  22. package/dist/integration/index.d.ts +20 -1
  23. package/dist/metadata/index.d.mts +40 -2
  24. package/dist/metadata/index.d.ts +40 -2
  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 +68 -0
  32. package/dist/pages/index.d.ts +68 -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 +17566 -0
  40. package/dist/plugin.js.map +1 -0
  41. package/dist/plugin.mjs +17563 -0
  42. package/dist/plugin.mjs.map +1 -0
  43. package/dist/security/index.d.mts +6376 -2094
  44. package/dist/security/index.d.ts +6376 -2094
  45. package/dist/security/index.js +383 -1
  46. package/dist/security/index.js.map +1 -1
  47. package/dist/security/index.mjs +383 -2
  48. package/dist/security/index.mjs.map +1 -1
  49. package/dist/system/index.d.mts +60 -3
  50. package/dist/system/index.d.ts +60 -3
  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",
@@ -827,6 +845,200 @@ var SysSharingRule = data.ObjectSchema.create({
827
845
  { fields: ["organization_id"] }
828
846
  ]
829
847
  });
848
+ var SysShareLink = data.ObjectSchema.create({
849
+ name: "sys_share_link",
850
+ label: "Share Link",
851
+ pluralLabel: "Share Links",
852
+ icon: "link-2",
853
+ isSystem: true,
854
+ managedBy: "system",
855
+ description: "Opaque capability token granting access to a single record. Notion/Figma-style public link sharing.",
856
+ titleFormat: "{object_name}/{record_id} ({permission})",
857
+ compactLayout: ["object_name", "record_id", "permission", "audience", "expires_at", "revoked_at"],
858
+ listViews: {
859
+ active_links: {
860
+ type: "grid",
861
+ name: "active_links",
862
+ label: "Active",
863
+ data: { provider: "object", object: "sys_share_link" },
864
+ columns: ["object_name", "record_id", "permission", "audience", "expires_at", "use_count", "last_used_at"],
865
+ filter: [{ field: "revoked_at", operator: "isNull" }],
866
+ sort: [{ field: "created_at", order: "desc" }],
867
+ pagination: { pageSize: 100 }
868
+ },
869
+ by_me: {
870
+ type: "grid",
871
+ name: "by_me",
872
+ label: "Created by Me",
873
+ data: { provider: "object", object: "sys_share_link" },
874
+ columns: ["object_name", "record_id", "permission", "audience", "expires_at", "revoked_at"],
875
+ filter: [{ field: "created_by", operator: "equals", value: "{current_user_id}" }],
876
+ sort: [{ field: "created_at", order: "desc" }],
877
+ pagination: { pageSize: 100 }
878
+ },
879
+ revoked: {
880
+ type: "grid",
881
+ name: "revoked",
882
+ label: "Revoked",
883
+ data: { provider: "object", object: "sys_share_link" },
884
+ columns: ["object_name", "record_id", "revoked_at", "created_by"],
885
+ filter: [{ field: "revoked_at", operator: "isNotNull" }],
886
+ sort: [{ field: "revoked_at", order: "desc" }],
887
+ pagination: { pageSize: 50 }
888
+ },
889
+ all_links: {
890
+ type: "grid",
891
+ name: "all_links",
892
+ label: "All",
893
+ data: { provider: "object", object: "sys_share_link" },
894
+ columns: ["object_name", "record_id", "permission", "audience", "expires_at", "revoked_at", "created_at"],
895
+ sort: [{ field: "created_at", order: "desc" }],
896
+ pagination: { pageSize: 200 }
897
+ }
898
+ },
899
+ fields: {
900
+ id: data.Field.text({
901
+ label: "Link ID",
902
+ required: true,
903
+ readonly: true,
904
+ group: "System"
905
+ }),
906
+ // ── Token (the secret) ───────────────────────────────────────
907
+ token: data.Field.text({
908
+ label: "Token",
909
+ required: true,
910
+ maxLength: 64,
911
+ description: "Opaque URL-safe random token (\u2265 22 chars). The only secret in this row.",
912
+ group: "Token"
913
+ }),
914
+ // ── Target ───────────────────────────────────────────────────
915
+ object_name: data.Field.text({
916
+ label: "Object",
917
+ required: true,
918
+ maxLength: 100,
919
+ description: "Short object name of the shared record (e.g. ai_conversation, contracts_contract)",
920
+ group: "Target"
921
+ }),
922
+ record_id: data.Field.text({
923
+ label: "Record",
924
+ required: true,
925
+ maxLength: 100,
926
+ description: "Primary key of the shared record within object_name",
927
+ group: "Target"
928
+ }),
929
+ // ── Access Policy ────────────────────────────────────────────
930
+ permission: data.Field.select(
931
+ [
932
+ { label: "View", value: "view" },
933
+ { label: "Comment", value: "comment" },
934
+ { label: "Edit", value: "edit" }
935
+ ],
936
+ {
937
+ label: "Permission",
938
+ required: true,
939
+ defaultValue: "view",
940
+ description: "What the link holder can do with the record",
941
+ group: "Access Policy"
942
+ }
943
+ ),
944
+ audience: data.Field.select(
945
+ [
946
+ { label: "Public (indexable)", value: "public" },
947
+ { label: "Anyone with the link", value: "link_only" },
948
+ { label: "Signed-in users", value: "signed_in" },
949
+ { label: "Specific emails", value: "email" }
950
+ ],
951
+ {
952
+ label: "Audience",
953
+ required: true,
954
+ defaultValue: "link_only",
955
+ description: "Gating layer applied on top of the token check",
956
+ group: "Access Policy"
957
+ }
958
+ ),
959
+ expires_at: data.Field.datetime({
960
+ label: "Expires At",
961
+ description: "When set, resolveToken returns null after this timestamp",
962
+ group: "Access Policy"
963
+ }),
964
+ email_allowlist: data.Field.json({
965
+ label: "Email Allowlist",
966
+ description: "Lowercased addresses checked when audience=email",
967
+ group: "Access Policy"
968
+ }),
969
+ password_hash: data.Field.text({
970
+ label: "Password Hash",
971
+ maxLength: 256,
972
+ description: "Argon2/bcrypt hash. When set, the UI prompts for a password before rendering.",
973
+ group: "Access Policy"
974
+ }),
975
+ redact_fields: data.Field.json({
976
+ label: "Per-Link Redactions",
977
+ description: "Extra fields stripped from the response, on top of the object-default set",
978
+ group: "Access Policy"
979
+ }),
980
+ label: data.Field.text({
981
+ label: "Label",
982
+ maxLength: 200,
983
+ description: 'Free-text shown in the share dialog (e.g. "ACME Q3 contract")',
984
+ group: "Metadata"
985
+ }),
986
+ // ── Lifecycle ────────────────────────────────────────────────
987
+ revoked_at: data.Field.datetime({
988
+ label: "Revoked At",
989
+ readonly: true,
990
+ description: "When set, the link is permanently disabled",
991
+ group: "Lifecycle"
992
+ }),
993
+ created_by: data.Field.lookup("sys_user", {
994
+ label: "Created By",
995
+ readonly: true,
996
+ description: "Issuer of the link",
997
+ group: "Lifecycle"
998
+ }),
999
+ created_at: data.Field.datetime({
1000
+ label: "Created At",
1001
+ required: true,
1002
+ defaultValue: "NOW()",
1003
+ readonly: true,
1004
+ group: "Lifecycle"
1005
+ }),
1006
+ last_used_at: data.Field.datetime({
1007
+ label: "Last Used At",
1008
+ readonly: true,
1009
+ description: "Stamped by resolveToken; used by the dashboard to highlight active links",
1010
+ group: "Lifecycle"
1011
+ }),
1012
+ use_count: data.Field.number({
1013
+ label: "Use Count",
1014
+ defaultValue: 0,
1015
+ readonly: true,
1016
+ description: "Incremented by resolveToken on every successful resolution",
1017
+ group: "Lifecycle"
1018
+ })
1019
+ },
1020
+ indexes: [
1021
+ // Hot path: resolveToken — one row lookup per public request.
1022
+ { fields: ["token"], unique: true },
1023
+ // Management UI: "all links for this record".
1024
+ { fields: ["object_name", "record_id"] },
1025
+ // "Active links I issued".
1026
+ { fields: ["created_by", "revoked_at"] },
1027
+ // Reaper for expired rows (background sweep).
1028
+ { fields: ["expires_at"] }
1029
+ ],
1030
+ enable: {
1031
+ trackHistory: false,
1032
+ searchable: false,
1033
+ apiEnabled: true,
1034
+ // The /api/v1/share-links endpoints are the authoritative surface;
1035
+ // the generic data API is exposed read-only for the admin grid.
1036
+ apiMethods: ["get", "list"],
1037
+ trash: false,
1038
+ mru: false,
1039
+ clone: false
1040
+ }
1041
+ });
830
1042
  var BETTER_AUTH_MANAGED_OBJECTS = [
831
1043
  "sys_user",
832
1044
  "sys_account",
@@ -867,7 +1079,176 @@ var defaultPermissionSets = [
867
1079
  modifyAllRecords: true
868
1080
  }
869
1081
  },
870
- 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
+ // Org-scoped visibility for organization-owned identity-adjacent
1231
+ // tables. Org admins may inspect their own org's invitations and
1232
+ // memberships (read; writes still flow through better-auth).
1233
+ {
1234
+ name: "sys_member_org",
1235
+ object: "sys_member",
1236
+ operation: "select",
1237
+ using: "organization_id = current_user.organization_id"
1238
+ },
1239
+ {
1240
+ name: "sys_invitation_org",
1241
+ object: "sys_invitation",
1242
+ operation: "select",
1243
+ using: "organization_id = current_user.organization_id"
1244
+ },
1245
+ {
1246
+ name: "sys_team_org",
1247
+ object: "sys_team",
1248
+ operation: "select",
1249
+ using: "organization_id = current_user.organization_id"
1250
+ }
1251
+ ]
871
1252
  }),
872
1253
  security.PermissionSetSchema.parse({
873
1254
  name: "member_default",
@@ -1112,6 +1493,7 @@ exports.SysPermissionSet = SysPermissionSet;
1112
1493
  exports.SysRecordShare = SysRecordShare;
1113
1494
  exports.SysRole = SysRole;
1114
1495
  exports.SysRolePermissionSet = SysRolePermissionSet;
1496
+ exports.SysShareLink = SysShareLink;
1115
1497
  exports.SysSharingRule = SysSharingRule;
1116
1498
  exports.SysUserPermissionSet = SysUserPermissionSet;
1117
1499
  exports.defaultPermissionSets = defaultPermissionSets;