@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
@@ -340,6 +340,24 @@ var SysPermissionSet = ObjectSchema.create({
340
340
  description: "JSON-serialized field-level read/write permissions",
341
341
  group: "Permissions"
342
342
  }),
343
+ system_permissions: Field.textarea({
344
+ label: "System Permissions",
345
+ required: false,
346
+ description: 'JSON-serialized array of system capability names (e.g. ["setup.access","studio.access","manage_users"])',
347
+ group: "Permissions"
348
+ }),
349
+ row_level_security: Field.textarea({
350
+ label: "Row-Level Security",
351
+ required: false,
352
+ description: "JSON-serialized array of row-level security policies (USING/CHECK clauses)",
353
+ group: "Permissions"
354
+ }),
355
+ tab_permissions: Field.textarea({
356
+ label: "Tab Permissions",
357
+ required: false,
358
+ description: "JSON-serialized map of app tab visibility (visible | hidden | default_on | default_off)",
359
+ group: "Permissions"
360
+ }),
343
361
  // ── Status ───────────────────────────────────────────────────
344
362
  active: Field.boolean({
345
363
  label: "Active",
@@ -825,6 +843,200 @@ var SysSharingRule = ObjectSchema.create({
825
843
  { fields: ["organization_id"] }
826
844
  ]
827
845
  });
846
+ var SysShareLink = ObjectSchema.create({
847
+ name: "sys_share_link",
848
+ label: "Share Link",
849
+ pluralLabel: "Share Links",
850
+ icon: "link-2",
851
+ isSystem: true,
852
+ managedBy: "system",
853
+ description: "Opaque capability token granting access to a single record. Notion/Figma-style public link sharing.",
854
+ titleFormat: "{object_name}/{record_id} ({permission})",
855
+ compactLayout: ["object_name", "record_id", "permission", "audience", "expires_at", "revoked_at"],
856
+ listViews: {
857
+ active_links: {
858
+ type: "grid",
859
+ name: "active_links",
860
+ label: "Active",
861
+ data: { provider: "object", object: "sys_share_link" },
862
+ columns: ["object_name", "record_id", "permission", "audience", "expires_at", "use_count", "last_used_at"],
863
+ filter: [{ field: "revoked_at", operator: "isNull" }],
864
+ sort: [{ field: "created_at", order: "desc" }],
865
+ pagination: { pageSize: 100 }
866
+ },
867
+ by_me: {
868
+ type: "grid",
869
+ name: "by_me",
870
+ label: "Created by Me",
871
+ data: { provider: "object", object: "sys_share_link" },
872
+ columns: ["object_name", "record_id", "permission", "audience", "expires_at", "revoked_at"],
873
+ filter: [{ field: "created_by", operator: "equals", value: "{current_user_id}" }],
874
+ sort: [{ field: "created_at", order: "desc" }],
875
+ pagination: { pageSize: 100 }
876
+ },
877
+ revoked: {
878
+ type: "grid",
879
+ name: "revoked",
880
+ label: "Revoked",
881
+ data: { provider: "object", object: "sys_share_link" },
882
+ columns: ["object_name", "record_id", "revoked_at", "created_by"],
883
+ filter: [{ field: "revoked_at", operator: "isNotNull" }],
884
+ sort: [{ field: "revoked_at", order: "desc" }],
885
+ pagination: { pageSize: 50 }
886
+ },
887
+ all_links: {
888
+ type: "grid",
889
+ name: "all_links",
890
+ label: "All",
891
+ data: { provider: "object", object: "sys_share_link" },
892
+ columns: ["object_name", "record_id", "permission", "audience", "expires_at", "revoked_at", "created_at"],
893
+ sort: [{ field: "created_at", order: "desc" }],
894
+ pagination: { pageSize: 200 }
895
+ }
896
+ },
897
+ fields: {
898
+ id: Field.text({
899
+ label: "Link ID",
900
+ required: true,
901
+ readonly: true,
902
+ group: "System"
903
+ }),
904
+ // ── Token (the secret) ───────────────────────────────────────
905
+ token: Field.text({
906
+ label: "Token",
907
+ required: true,
908
+ maxLength: 64,
909
+ description: "Opaque URL-safe random token (\u2265 22 chars). The only secret in this row.",
910
+ group: "Token"
911
+ }),
912
+ // ── Target ───────────────────────────────────────────────────
913
+ object_name: Field.text({
914
+ label: "Object",
915
+ required: true,
916
+ maxLength: 100,
917
+ description: "Short object name of the shared record (e.g. ai_conversation, contracts_contract)",
918
+ group: "Target"
919
+ }),
920
+ record_id: Field.text({
921
+ label: "Record",
922
+ required: true,
923
+ maxLength: 100,
924
+ description: "Primary key of the shared record within object_name",
925
+ group: "Target"
926
+ }),
927
+ // ── Access Policy ────────────────────────────────────────────
928
+ permission: Field.select(
929
+ [
930
+ { label: "View", value: "view" },
931
+ { label: "Comment", value: "comment" },
932
+ { label: "Edit", value: "edit" }
933
+ ],
934
+ {
935
+ label: "Permission",
936
+ required: true,
937
+ defaultValue: "view",
938
+ description: "What the link holder can do with the record",
939
+ group: "Access Policy"
940
+ }
941
+ ),
942
+ audience: Field.select(
943
+ [
944
+ { label: "Public (indexable)", value: "public" },
945
+ { label: "Anyone with the link", value: "link_only" },
946
+ { label: "Signed-in users", value: "signed_in" },
947
+ { label: "Specific emails", value: "email" }
948
+ ],
949
+ {
950
+ label: "Audience",
951
+ required: true,
952
+ defaultValue: "link_only",
953
+ description: "Gating layer applied on top of the token check",
954
+ group: "Access Policy"
955
+ }
956
+ ),
957
+ expires_at: Field.datetime({
958
+ label: "Expires At",
959
+ description: "When set, resolveToken returns null after this timestamp",
960
+ group: "Access Policy"
961
+ }),
962
+ email_allowlist: Field.json({
963
+ label: "Email Allowlist",
964
+ description: "Lowercased addresses checked when audience=email",
965
+ group: "Access Policy"
966
+ }),
967
+ password_hash: Field.text({
968
+ label: "Password Hash",
969
+ maxLength: 256,
970
+ description: "Argon2/bcrypt hash. When set, the UI prompts for a password before rendering.",
971
+ group: "Access Policy"
972
+ }),
973
+ redact_fields: Field.json({
974
+ label: "Per-Link Redactions",
975
+ description: "Extra fields stripped from the response, on top of the object-default set",
976
+ group: "Access Policy"
977
+ }),
978
+ label: Field.text({
979
+ label: "Label",
980
+ maxLength: 200,
981
+ description: 'Free-text shown in the share dialog (e.g. "ACME Q3 contract")',
982
+ group: "Metadata"
983
+ }),
984
+ // ── Lifecycle ────────────────────────────────────────────────
985
+ revoked_at: Field.datetime({
986
+ label: "Revoked At",
987
+ readonly: true,
988
+ description: "When set, the link is permanently disabled",
989
+ group: "Lifecycle"
990
+ }),
991
+ created_by: Field.lookup("sys_user", {
992
+ label: "Created By",
993
+ readonly: true,
994
+ description: "Issuer of the link",
995
+ group: "Lifecycle"
996
+ }),
997
+ created_at: Field.datetime({
998
+ label: "Created At",
999
+ required: true,
1000
+ defaultValue: "NOW()",
1001
+ readonly: true,
1002
+ group: "Lifecycle"
1003
+ }),
1004
+ last_used_at: Field.datetime({
1005
+ label: "Last Used At",
1006
+ readonly: true,
1007
+ description: "Stamped by resolveToken; used by the dashboard to highlight active links",
1008
+ group: "Lifecycle"
1009
+ }),
1010
+ use_count: Field.number({
1011
+ label: "Use Count",
1012
+ defaultValue: 0,
1013
+ readonly: true,
1014
+ description: "Incremented by resolveToken on every successful resolution",
1015
+ group: "Lifecycle"
1016
+ })
1017
+ },
1018
+ indexes: [
1019
+ // Hot path: resolveToken — one row lookup per public request.
1020
+ { fields: ["token"], unique: true },
1021
+ // Management UI: "all links for this record".
1022
+ { fields: ["object_name", "record_id"] },
1023
+ // "Active links I issued".
1024
+ { fields: ["created_by", "revoked_at"] },
1025
+ // Reaper for expired rows (background sweep).
1026
+ { fields: ["expires_at"] }
1027
+ ],
1028
+ enable: {
1029
+ trackHistory: false,
1030
+ searchable: false,
1031
+ apiEnabled: true,
1032
+ // The /api/v1/share-links endpoints are the authoritative surface;
1033
+ // the generic data API is exposed read-only for the admin grid.
1034
+ apiMethods: ["get", "list"],
1035
+ trash: false,
1036
+ mru: false,
1037
+ clone: false
1038
+ }
1039
+ });
828
1040
  var BETTER_AUTH_MANAGED_OBJECTS = [
829
1041
  "sys_user",
830
1042
  "sys_account",
@@ -865,7 +1077,176 @@ var defaultPermissionSets = [
865
1077
  modifyAllRecords: true
866
1078
  }
867
1079
  },
868
- systemPermissions: ["manage_users", "manage_metadata", "setup.access", "studio.access"]
1080
+ systemPermissions: [
1081
+ "manage_users",
1082
+ "manage_metadata",
1083
+ "manage_platform_settings",
1084
+ "setup.access",
1085
+ "studio.access"
1086
+ ]
1087
+ }),
1088
+ // ── Organization Administrator ──────────────────────────────────────
1089
+ //
1090
+ // Third tier between platform admin (`admin_full_access`) and rank-and-file
1091
+ // member. Lives at the *organization* scope: full CRUD on business
1092
+ // objects within their org (governed by `tenant_isolation` RLS), plus
1093
+ // `setup.access` so the Setup app shell is reachable.
1094
+ //
1095
+ // **Deliberately withheld** vs `admin_full_access`:
1096
+ // - `studio.access` — schema-design surfaces are platform-level (a
1097
+ // tenant cannot mutate the shared metadata) and Studio is hidden.
1098
+ // - `manage_metadata` — same reasoning.
1099
+ // - `manage_platform_settings` — global settings manifests
1100
+ // (mail / storage / AI / knowledge) and platform-only Setup pages
1101
+ // (sharing rules, audit logs, OAuth apps, JWKS, …) require this
1102
+ // and are hidden / 403'd for org admins. Tenant-scoped manifests
1103
+ // (`branding`, `feature_flags`) keep using `setup.access` so org
1104
+ // admins CAN configure their own org's branding.
1105
+ //
1106
+ // **Anti-escalation**: writes to the global RBAC tables
1107
+ // (`sys_role`, `sys_permission_set`, `sys_role_permission_set`,
1108
+ // `sys_user_permission_set`, `sys_user_role`) are denied. Allowing
1109
+ // them would let an org admin bind `admin_full_access` (which has no
1110
+ // RLS) to themselves and break out of tenant isolation. Reads are
1111
+ // permitted so the Roles / Permission Sets nav entries still render.
1112
+ //
1113
+ // Auto-granted to every `sys_member` whose role contains `owner` or
1114
+ // `admin` by `plugin-security/src/auto-org-admin-grant.ts`.
1115
+ PermissionSetSchema.parse({
1116
+ name: "organization_admin",
1117
+ label: "Organization Administrator",
1118
+ isProfile: true,
1119
+ objects: {
1120
+ "*": {
1121
+ allowRead: true,
1122
+ allowCreate: true,
1123
+ allowEdit: true,
1124
+ allowDelete: true,
1125
+ viewAllRecords: true,
1126
+ modifyAllRecords: true
1127
+ },
1128
+ // Identity tables — go through better-auth endpoints (invite,
1129
+ // accept, remove-member, transfer, …) rather than raw CRUD.
1130
+ ...denyWritesOnManagedObjects(),
1131
+ // RBAC tables — read-only to prevent privilege escalation.
1132
+ sys_role: { allowRead: true, allowCreate: false, allowEdit: false, allowDelete: false },
1133
+ sys_permission_set: { allowRead: true, allowCreate: false, allowEdit: false, allowDelete: false },
1134
+ sys_role_permission_set: { allowRead: true, allowCreate: false, allowEdit: false, allowDelete: false },
1135
+ sys_user_permission_set: { allowRead: true, allowCreate: false, allowEdit: false, allowDelete: false },
1136
+ sys_user_role: { allowRead: true, allowCreate: false, allowEdit: false, allowDelete: false }
1137
+ },
1138
+ systemPermissions: ["manage_org_users", "setup.access"],
1139
+ rowLevelSecurity: [
1140
+ {
1141
+ name: "tenant_isolation",
1142
+ object: "*",
1143
+ operation: "all",
1144
+ using: "organization_id = current_user.organization_id"
1145
+ },
1146
+ // ── better-auth system tables that lack `organization_id` and would
1147
+ // otherwise be denied by the wildcard policy. Same self-only
1148
+ // carve-outs as `member_default` — an org admin does not get to
1149
+ // inspect cross-tenant identity rows.
1150
+ {
1151
+ name: "sys_organization_self",
1152
+ object: "sys_organization",
1153
+ operation: "all",
1154
+ using: "id = current_user.organization_id"
1155
+ },
1156
+ {
1157
+ name: "sys_user_self",
1158
+ object: "sys_user",
1159
+ operation: "select",
1160
+ using: "id = current_user.id"
1161
+ },
1162
+ {
1163
+ name: "sys_user_org_members",
1164
+ object: "sys_user",
1165
+ operation: "select",
1166
+ using: "id IN (current_user.org_user_ids)"
1167
+ },
1168
+ {
1169
+ name: "sys_session_self",
1170
+ object: "sys_session",
1171
+ operation: "all",
1172
+ using: "user_id = current_user.id"
1173
+ },
1174
+ {
1175
+ name: "sys_account_self",
1176
+ object: "sys_account",
1177
+ operation: "select",
1178
+ using: "user_id = current_user.id"
1179
+ },
1180
+ {
1181
+ name: "sys_team_member_self",
1182
+ object: "sys_team_member",
1183
+ operation: "select",
1184
+ using: "user_id = current_user.id"
1185
+ },
1186
+ {
1187
+ name: "sys_two_factor_self",
1188
+ object: "sys_two_factor",
1189
+ operation: "all",
1190
+ using: "user_id = current_user.id"
1191
+ },
1192
+ {
1193
+ name: "sys_user_preference_self",
1194
+ object: "sys_user_preference",
1195
+ operation: "all",
1196
+ using: "user_id = current_user.id"
1197
+ },
1198
+ {
1199
+ name: "sys_api_key_self",
1200
+ object: "sys_api_key",
1201
+ operation: "all",
1202
+ using: "user_id = current_user.id"
1203
+ },
1204
+ {
1205
+ name: "sys_device_code_self",
1206
+ object: "sys_device_code",
1207
+ operation: "all",
1208
+ using: "user_id = current_user.id"
1209
+ },
1210
+ {
1211
+ name: "sys_oauth_access_token_self",
1212
+ object: "sys_oauth_access_token",
1213
+ operation: "select",
1214
+ using: "user_id = current_user.id"
1215
+ },
1216
+ {
1217
+ name: "sys_oauth_refresh_token_self",
1218
+ object: "sys_oauth_refresh_token",
1219
+ operation: "select",
1220
+ using: "user_id = current_user.id"
1221
+ },
1222
+ {
1223
+ name: "sys_oauth_consent_self",
1224
+ object: "sys_oauth_consent",
1225
+ operation: "all",
1226
+ using: "user_id = current_user.id"
1227
+ },
1228
+ // Org-scoped visibility for organization-owned identity-adjacent
1229
+ // tables. Org admins may inspect their own org's invitations and
1230
+ // memberships (read; writes still flow through better-auth).
1231
+ {
1232
+ name: "sys_member_org",
1233
+ object: "sys_member",
1234
+ operation: "select",
1235
+ using: "organization_id = current_user.organization_id"
1236
+ },
1237
+ {
1238
+ name: "sys_invitation_org",
1239
+ object: "sys_invitation",
1240
+ operation: "select",
1241
+ using: "organization_id = current_user.organization_id"
1242
+ },
1243
+ {
1244
+ name: "sys_team_org",
1245
+ object: "sys_team",
1246
+ operation: "select",
1247
+ using: "organization_id = current_user.organization_id"
1248
+ }
1249
+ ]
869
1250
  }),
870
1251
  PermissionSetSchema.parse({
871
1252
  name: "member_default",
@@ -1106,6 +1487,6 @@ var defaultPermissionSets = [
1106
1487
  })
1107
1488
  ];
1108
1489
 
1109
- export { SysPermissionSet, SysRecordShare, SysRole, SysRolePermissionSet, SysSharingRule, SysUserPermissionSet, defaultPermissionSets };
1490
+ export { SysPermissionSet, SysRecordShare, SysRole, SysRolePermissionSet, SysShareLink, SysSharingRule, SysUserPermissionSet, defaultPermissionSets };
1110
1491
  //# sourceMappingURL=index.mjs.map
1111
1492
  //# sourceMappingURL=index.mjs.map