@objectstack/metadata-core 10.2.0 → 11.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.
package/dist/index.js CHANGED
@@ -986,9 +986,127 @@ var SysMetadataHistoryObject = ObjectSchema2.create({
986
986
  }
987
987
  });
988
988
 
989
- // src/objects/sys-metadata-audit.object.ts
989
+ // src/objects/sys-metadata-commit.object.ts
990
990
  import { ObjectSchema as ObjectSchema3, Field as Field3 } from "@objectstack/spec/data";
991
- var SysMetadataAuditObject = ObjectSchema3.create({
991
+ var SysMetadataCommitObject = ObjectSchema3.create({
992
+ name: "sys_metadata_commit",
993
+ label: "Metadata Commit",
994
+ pluralLabel: "Metadata Commits",
995
+ icon: "git-commit",
996
+ isSystem: true,
997
+ managedBy: "system",
998
+ description: "Package-scoped commit log grouping a turn\u2019s metadata changes (ADR-0067).",
999
+ fields: {
1000
+ /** Primary Key — the commit id. */
1001
+ id: Field3.text({
1002
+ label: "ID",
1003
+ required: true,
1004
+ readonly: true,
1005
+ maxLength: 64
1006
+ }),
1007
+ /** The app/package this commit belongs to (the unit a user reverts). */
1008
+ package_id: Field3.text({
1009
+ label: "Package",
1010
+ required: false,
1011
+ searchable: true,
1012
+ readonly: true,
1013
+ maxLength: 255
1014
+ }),
1015
+ /** apply = a turn promoted changes; revert = this commit undid another. */
1016
+ operation: Field3.select(["apply", "revert"], {
1017
+ label: "Operation",
1018
+ required: true,
1019
+ readonly: true
1020
+ }),
1021
+ /** Human-readable summary — for AI turns, the user's prompt. */
1022
+ message: Field3.textarea({
1023
+ label: "Message",
1024
+ required: false,
1025
+ readonly: true,
1026
+ description: "Change summary; for AI turns, the user instruction that produced it."
1027
+ }),
1028
+ /** Producing actor (user id, or an AI principal like "ai:claude"). */
1029
+ actor: Field3.text({
1030
+ label: "Actor",
1031
+ required: false,
1032
+ readonly: true,
1033
+ maxLength: 255
1034
+ }),
1035
+ /** AI model that authored the turn (absent for human/CLI commits). */
1036
+ ai_model: Field3.text({
1037
+ label: "AI Model",
1038
+ required: false,
1039
+ readonly: true,
1040
+ maxLength: 100
1041
+ }),
1042
+ /** For a revert commit, the id of the commit it reverted. */
1043
+ parent_commit_id: Field3.text({
1044
+ label: "Parent Commit",
1045
+ required: false,
1046
+ readonly: true,
1047
+ maxLength: 64
1048
+ }),
1049
+ /** First `sys_metadata_history.event_seq` covered by this commit. */
1050
+ event_seq_start: Field3.number({
1051
+ label: "Event Seq Start",
1052
+ required: false,
1053
+ readonly: true
1054
+ }),
1055
+ /** Last `sys_metadata_history.event_seq` covered by this commit. */
1056
+ event_seq_end: Field3.number({
1057
+ label: "Event Seq End",
1058
+ required: false,
1059
+ readonly: true
1060
+ }),
1061
+ /**
1062
+ * JSON array of the artifacts this commit touched, with the data
1063
+ * `revertCommit` needs: [{ type, name, existedBefore, prevVersion }].
1064
+ */
1065
+ items: Field3.textarea({
1066
+ label: "Items",
1067
+ required: false,
1068
+ readonly: true,
1069
+ description: "JSON: [{ type, name, existedBefore, prevVersion }] \u2014 the revert plan."
1070
+ }),
1071
+ /** Number of artifacts in `items` (denormalized for list views). */
1072
+ item_count: Field3.number({
1073
+ label: "Item Count",
1074
+ required: false,
1075
+ readonly: true
1076
+ }),
1077
+ /** Organization ID for multi-tenant isolation. */
1078
+ organization_id: Field3.lookup("sys_organization", {
1079
+ label: "Organization",
1080
+ required: false,
1081
+ readonly: true,
1082
+ description: "Organization for multi-tenant isolation."
1083
+ }),
1084
+ /** When the commit was recorded. */
1085
+ created_at: Field3.datetime({
1086
+ label: "Created At",
1087
+ required: true,
1088
+ readonly: true
1089
+ })
1090
+ },
1091
+ indexes: [
1092
+ // List a package's history newest-first (the timeline read pattern).
1093
+ { fields: ["organization_id", "package_id", "created_at"] },
1094
+ // Org-wide commit replay / audit.
1095
+ { fields: ["organization_id", "created_at"] },
1096
+ { fields: ["parent_commit_id"] }
1097
+ ],
1098
+ enable: {
1099
+ trackHistory: false,
1100
+ searchable: false,
1101
+ apiEnabled: true,
1102
+ apiMethods: ["get", "list"],
1103
+ trash: false
1104
+ }
1105
+ });
1106
+
1107
+ // src/objects/sys-metadata-audit.object.ts
1108
+ import { ObjectSchema as ObjectSchema4, Field as Field4 } from "@objectstack/spec/data";
1109
+ var SysMetadataAuditObject = ObjectSchema4.create({
992
1110
  name: "sys_metadata_audit",
993
1111
  label: "Metadata Audit",
994
1112
  pluralLabel: "Metadata Audit",
@@ -998,19 +1116,19 @@ var SysMetadataAuditObject = ObjectSchema3.create({
998
1116
  description: "Append-only audit trail of metadata write decisions (ADR-0010).",
999
1117
  fields: {
1000
1118
  /** Primary Key (UUID) */
1001
- id: Field3.text({
1119
+ id: Field4.text({
1002
1120
  label: "ID",
1003
1121
  required: true,
1004
1122
  readonly: true
1005
1123
  }),
1006
1124
  /** When the decision was made (ISO-8601 UTC). */
1007
- occurred_at: Field3.datetime({
1125
+ occurred_at: Field4.datetime({
1008
1126
  label: "Occurred At",
1009
1127
  required: true,
1010
1128
  readonly: true
1011
1129
  }),
1012
1130
  /** Acting principal (user id, system id, or 'system'). */
1013
- actor: Field3.text({
1131
+ actor: Field4.text({
1014
1132
  label: "Actor",
1015
1133
  required: true,
1016
1134
  readonly: true,
@@ -1018,14 +1136,14 @@ var SysMetadataAuditObject = ObjectSchema3.create({
1018
1136
  description: 'Acting principal \u2014 user id, system id, or "system".'
1019
1137
  }),
1020
1138
  /** Code path that produced the decision (e.g. `protocol.saveMetaItem`). */
1021
- source: Field3.text({
1139
+ source: Field4.text({
1022
1140
  label: "Source",
1023
1141
  required: false,
1024
1142
  readonly: true,
1025
1143
  maxLength: 128
1026
1144
  }),
1027
1145
  /** Metadata type (singular, e.g. `app`, `object`, `view`). */
1028
- type: Field3.text({
1146
+ type: Field4.text({
1029
1147
  label: "Metadata Type",
1030
1148
  required: true,
1031
1149
  readonly: true,
@@ -1033,7 +1151,7 @@ var SysMetadataAuditObject = ObjectSchema3.create({
1033
1151
  maxLength: 100
1034
1152
  }),
1035
1153
  /** Item machine name. */
1036
- name: Field3.text({
1154
+ name: Field4.text({
1037
1155
  label: "Name",
1038
1156
  required: true,
1039
1157
  readonly: true,
@@ -1041,19 +1159,19 @@ var SysMetadataAuditObject = ObjectSchema3.create({
1041
1159
  maxLength: 255
1042
1160
  }),
1043
1161
  /** Organization for multi-tenant filtering. NULL for env-wide writes. */
1044
- organization_id: Field3.lookup("sys_organization", {
1162
+ organization_id: Field4.lookup("sys_organization", {
1045
1163
  label: "Organization",
1046
1164
  required: false,
1047
1165
  readonly: true
1048
1166
  }),
1049
1167
  /** Operation kind. */
1050
- operation: Field3.select(["save", "publish", "rollback", "delete", "reset"], {
1168
+ operation: Field4.select(["save", "publish", "rollback", "delete", "reset"], {
1051
1169
  label: "Operation",
1052
1170
  required: true,
1053
1171
  readonly: true
1054
1172
  }),
1055
1173
  /** Decision outcome — allowed, denied (refused), or forced (bypassed via override). */
1056
- outcome: Field3.select(["allowed", "denied", "forced"], {
1174
+ outcome: Field4.select(["allowed", "denied", "forced"], {
1057
1175
  label: "Outcome",
1058
1176
  required: true,
1059
1177
  readonly: true
@@ -1066,7 +1184,7 @@ var SysMetadataAuditObject = ObjectSchema3.create({
1066
1184
  * `'metadata_conflict'`
1067
1185
  * - on `forced`: `'lock_override'` (Phase 3)
1068
1186
  */
1069
- code: Field3.text({
1187
+ code: Field4.text({
1070
1188
  label: "Code",
1071
1189
  required: true,
1072
1190
  readonly: true,
@@ -1078,26 +1196,26 @@ var SysMetadataAuditObject = ObjectSchema3.create({
1078
1196
  * later compliance queries can see "what was the lock state when
1079
1197
  * this write succeeded".
1080
1198
  */
1081
- lock_state: Field3.select(["none", "no-overlay", "no-delete", "full"], {
1199
+ lock_state: Field4.select(["none", "no-overlay", "no-delete", "full"], {
1082
1200
  label: "Lock State",
1083
1201
  required: false,
1084
1202
  readonly: true
1085
1203
  }),
1086
1204
  /** True when the write succeeded by bypassing a lock (Phase 3). */
1087
- lock_overridden: Field3.boolean({
1205
+ lock_overridden: Field4.boolean({
1088
1206
  label: "Lock Overridden",
1089
1207
  required: false,
1090
1208
  readonly: true
1091
1209
  }),
1092
1210
  /** Optional request correlation id for tracing. */
1093
- request_id: Field3.text({
1211
+ request_id: Field4.text({
1094
1212
  label: "Request ID",
1095
1213
  required: false,
1096
1214
  readonly: true,
1097
1215
  maxLength: 128
1098
1216
  }),
1099
1217
  /** Optional free-form context (e.g. brief diff summary). */
1100
- note: Field3.textarea({
1218
+ note: Field4.textarea({
1101
1219
  label: "Note",
1102
1220
  required: false,
1103
1221
  readonly: true
@@ -1119,8 +1237,8 @@ var SysMetadataAuditObject = ObjectSchema3.create({
1119
1237
  });
1120
1238
 
1121
1239
  // src/objects/sys-view-definition.object.ts
1122
- import { ObjectSchema as ObjectSchema4, Field as Field4 } from "@objectstack/spec/data";
1123
- var SysViewDefinitionObject = ObjectSchema4.create({
1240
+ import { ObjectSchema as ObjectSchema5, Field as Field5 } from "@objectstack/spec/data";
1241
+ var SysViewDefinitionObject = ObjectSchema5.create({
1124
1242
  name: "sys_view_definition",
1125
1243
  label: "View Definition",
1126
1244
  pluralLabel: "View Definitions",
@@ -1129,73 +1247,73 @@ var SysViewDefinitionObject = ObjectSchema4.create({
1129
1247
  description: "Runtime-authored view definitions (shared / personal layers). The package layer ships from source.",
1130
1248
  fields: {
1131
1249
  /** Primary Key (UUID) */
1132
- id: Field4.text({ label: "ID", required: true, readonly: true }),
1250
+ id: Field5.text({ label: "ID", required: true, readonly: true }),
1133
1251
  /**
1134
1252
  * Globally-unique qualified view id, `<object>.<viewKey>`, matching the
1135
1253
  * spec `ViewItemSchema.name`. For personal views the runtime may suffix
1136
1254
  * to keep it unique per owner.
1137
1255
  */
1138
- name: Field4.text({
1256
+ name: Field5.text({
1139
1257
  label: "Name",
1140
1258
  required: true,
1141
1259
  searchable: true,
1142
1260
  maxLength: 255
1143
1261
  }),
1144
1262
  /** Bound object — the foreign key used to aggregate views for the switcher. */
1145
- object: Field4.text({
1263
+ object: Field5.text({
1146
1264
  label: "Object",
1147
1265
  required: true,
1148
1266
  searchable: true,
1149
1267
  maxLength: 255
1150
1268
  }),
1151
1269
  /** Whether `config` is a ListView (list family) or a FormView. */
1152
- view_kind: Field4.select(["list", "form"], {
1270
+ view_kind: Field5.select(["list", "form"], {
1153
1271
  label: "View Kind",
1154
1272
  required: true,
1155
1273
  defaultValue: "list"
1156
1274
  }),
1157
1275
  /** Display label (plain string; i18n keys also accepted). */
1158
- label: Field4.text({ label: "Label", required: false, maxLength: 255 }),
1276
+ label: Field5.text({ label: "Label", required: false, maxLength: 255 }),
1159
1277
  /** Whether this is the object's default view in the switcher. */
1160
- is_default: Field4.boolean({ label: "Is Default", required: false, defaultValue: false }),
1278
+ is_default: Field5.boolean({ label: "Is Default", required: false, defaultValue: false }),
1161
1279
  /** Sort order within the object's switcher / left rail. */
1162
- view_order: Field4.number({ label: "Order", required: false, defaultValue: 0 }),
1280
+ view_order: Field5.number({ label: "Order", required: false, defaultValue: 0 }),
1163
1281
  /**
1164
1282
  * Identity layer. Only `shared` and `personal` are stored at runtime;
1165
1283
  * `package` views come from source.
1166
1284
  */
1167
- scope: Field4.select(["shared", "personal"], {
1285
+ scope: Field5.select(["shared", "personal"], {
1168
1286
  label: "Scope",
1169
1287
  required: true,
1170
1288
  defaultValue: "personal"
1171
1289
  }),
1172
1290
  /** Owner user id — set when scope = personal; null for shared. */
1173
- owner: Field4.text({ label: "Owner", required: false, maxLength: 255 }),
1291
+ owner: Field5.text({ label: "Owner", required: false, maxLength: 255 }),
1174
1292
  /** Hidden from the switcher (per-user / per-org declutter). */
1175
- hidden: Field4.boolean({ label: "Hidden", required: false, defaultValue: false }),
1293
+ hidden: Field5.boolean({ label: "Hidden", required: false, defaultValue: false }),
1176
1294
  /** The ListView / FormView configuration payload. */
1177
- config: Field4.json({
1295
+ config: Field5.json({
1178
1296
  label: "Config",
1179
1297
  required: true,
1180
1298
  description: "ListView or FormView configuration (matches spec ViewItem.config)."
1181
1299
  }),
1182
1300
  /** Organization for multi-tenant isolation. */
1183
- organization_id: Field4.lookup("sys_organization", {
1301
+ organization_id: Field5.lookup("sys_organization", {
1184
1302
  label: "Organization",
1185
1303
  required: false,
1186
1304
  description: "Organization for multi-tenant isolation."
1187
1305
  }),
1188
1306
  /** Lifecycle state. */
1189
- state: Field4.select(["draft", "active", "archived"], {
1307
+ state: Field5.select(["draft", "active", "archived"], {
1190
1308
  label: "State",
1191
1309
  required: false,
1192
1310
  defaultValue: "active"
1193
1311
  }),
1194
1312
  /** Audit fields. */
1195
- created_by: Field4.lookup("sys_user", { label: "Created By", required: false, readonly: true }),
1196
- created_at: Field4.datetime({ label: "Created At", required: false, readonly: true }),
1197
- updated_by: Field4.lookup("sys_user", { label: "Updated By", required: false }),
1198
- updated_at: Field4.datetime({ label: "Updated At", required: false })
1313
+ created_by: Field5.lookup("sys_user", { label: "Created By", required: false, readonly: true }),
1314
+ created_at: Field5.datetime({ label: "Created At", required: false, readonly: true }),
1315
+ updated_by: Field5.lookup("sys_user", { label: "Updated By", required: false }),
1316
+ updated_at: Field5.datetime({ label: "Updated At", required: false })
1199
1317
  },
1200
1318
  indexes: [
1201
1319
  // A given view name is unique per (organization, owner) among active rows —
@@ -1237,6 +1355,7 @@ export {
1237
1355
  SchemaValidationError,
1238
1356
  SysMetadataObject as SysMetadata,
1239
1357
  SysMetadataAuditObject,
1358
+ SysMetadataCommitObject,
1240
1359
  SysMetadataHistoryObject,
1241
1360
  SysMetadataObject,
1242
1361
  SysViewDefinitionObject,