create-prenta 1.7.1 → 1.7.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # create-actuate-cms
2
2
 
3
+ ## 1.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 69b9667: Appearance → Menus opens the menu editor again, and sidebar groups open when you're on one of their pages. Settings tabs show the save bar only after a change.
8
+
9
+ A form's open and close dates, entry limit, and closed message now save and are enforced on submit.
10
+
11
+ Cancelling a job while a slice is running now sticks: the job stops after that slice. Migration 0025 ships a `down.sql` for manual rollback.
12
+
13
+ - 69b9667: The jobs API gains detail, activity log, retry, run now and worker status endpoints: `GET /jobs/:id`, `GET /jobs/:id/events`, `POST /jobs/:id/retry`, `POST /jobs/run` and `GET /jobs/worker`. `GET /jobs` lists newest first and filters by `type` and `status`.
14
+
15
+ Jobs now record who queued them, an activity log of every slice, retry and cancel, and the AI tokens each batch used. A batch AI job that hits the monthly or daily AI limit waits for the limit to reset instead of failing.
16
+
17
+ Cancelling, retrying and running a job now need a role that can write, so viewers and read-only API keys get 403. Only an admin, or the person who queued it, can retry a batch AI job. A job's `lastError` keeps the stack (up to 4 KB), and lists show its one-line cause.
18
+
19
+ Job responses follow the October 2026 contract (progress unit and cursor, `createdBy`, `cancelledBy`, `finishedAt`, `usage`), and the job types are exported from `@prenta/core`.
20
+
21
+ Migration 0026 adds `prenta_jobs.createdById` and a `prenta_system_settings` table. It ships a `down.sql` for manual rollback.
22
+
23
+ - 69b9667: Sites declare what editors can change in their header and footer with `defineRegion(name, { component, variants, fields })` and `field.brand`, `menu`, `link`, `text`, `textarea`, `select`, `boolean` and `social`, from `@prenta/core/config`. Saved values are typed per region: `RegionValues<typeof header>` for what the CMS stores, `ChromeFieldsOf<typeof header>` for what the site receives. The earlier array-of-fields `defineRegion` and `DEFAULT_CHROME_SCHEMA` are gone, and the `@prenta/core/chrome/schema` entry with them.
24
+
25
+ `prenta push chrome` sends the regions `prenta.config.ts` exports to the CMS, with the repo, branch and commit; run it on every deploy, with an admin API key. The CMS stores each region's schema and fits the saved values to it. A value whose field was removed is kept as an orphan for 30 days, or until someone removes it. A field with `renamedFrom` keeps the old key's value. `prenta pull chrome` writes the CMS's schema to `.prenta/chrome.json`, and `prenta types` generates `ChromeFields` from it.
26
+
27
+ Migration 0027 adds the `prenta_chrome_regions` table. It ships a `down.sql` for manual rollback.
28
+
3
29
  ## 1.7.1
4
30
 
5
31
  ### Patch Changes
@@ -0,0 +1,60 @@
1
+ -- Down-migration for 0025_job_cancel_review. Prisma Migrate has no down
2
+ -- migrations, so run this by hand, with the job worker stopped and the
3
+ -- pre-0025 code deployed:
4
+ --
5
+ -- prisma db execute --file prisma/migrations/0025_job_cancel_review/down.sql
6
+ --
7
+ -- Then remove 0025 from the history so `migrate deploy` can apply it again:
8
+ --
9
+ -- DELETE FROM "_prisma_migrations" WHERE "migration_name" = '0025_job_cancel_review';
10
+ --
11
+ -- (If 0025 failed part-way, use `prisma migrate resolve --rolled-back
12
+ -- 0025_job_cancel_review` instead of the DELETE.)
13
+ --
14
+ -- `status` is plain TEXT, so `cancelled` has no enum value to drop. Code before
15
+ -- 0025 reads any unknown status as `queued`, so cancelled rows move to `dead`,
16
+ -- the dead-letter that is never claimed again. The cancel columns go away, so
17
+ -- the reason is kept in `lastError` when that is empty. A pending cancel on a
18
+ -- running job is lost.
19
+ --
20
+ -- Job events and review items are dropped with their tables. Every statement
21
+ -- uses IF EXISTS so a part-applied 0025 rolls back too.
22
+
23
+ BEGIN;
24
+
25
+ -- RemapStatus
26
+ UPDATE "prenta_jobs"
27
+ SET "status" = 'dead', "lastError" = COALESCE("lastError", 'Cancelled')
28
+ WHERE "status" = 'cancelled';
29
+
30
+ -- DropForeignKey
31
+ ALTER TABLE IF EXISTS "prenta_job_review_items" DROP CONSTRAINT IF EXISTS "prenta_job_review_items_jobId_fkey";
32
+
33
+ -- DropForeignKey
34
+ ALTER TABLE IF EXISTS "prenta_job_events" DROP CONSTRAINT IF EXISTS "prenta_job_events_jobId_fkey";
35
+
36
+ -- DropIndex
37
+ DROP INDEX IF EXISTS "prenta_job_review_items_jobId_status_idx";
38
+
39
+ -- DropIndex
40
+ DROP INDEX IF EXISTS "prenta_job_events_jobId_at_idx";
41
+
42
+ -- DropTable
43
+ DROP TABLE IF EXISTS "prenta_job_review_items";
44
+
45
+ -- DropTable
46
+ DROP TABLE IF EXISTS "prenta_job_events";
47
+
48
+ -- AlterTable
49
+ ALTER TABLE "prenta_jobs" DROP COLUMN IF EXISTS "finishedAt",
50
+ DROP COLUMN IF EXISTS "results",
51
+ DROP COLUMN IF EXISTS "summary",
52
+ DROP COLUMN IF EXISTS "explain",
53
+ DROP COLUMN IF EXISTS "tokensOut",
54
+ DROP COLUMN IF EXISTS "tokensIn",
55
+ DROP COLUMN IF EXISTS "scope",
56
+ DROP COLUMN IF EXISTS "title",
57
+ DROP COLUMN IF EXISTS "cancelledById",
58
+ DROP COLUMN IF EXISTS "cancelRequestedAt";
59
+
60
+ COMMIT;
@@ -0,0 +1,56 @@
1
+ -- AlterTable
2
+ ALTER TABLE "prenta_jobs" ADD COLUMN "cancelRequestedAt" TIMESTAMP(3),
3
+ ADD COLUMN "cancelledById" TEXT,
4
+ ADD COLUMN "title" TEXT,
5
+ ADD COLUMN "scope" TEXT,
6
+ ADD COLUMN "tokensIn" INTEGER NOT NULL DEFAULT 0,
7
+ ADD COLUMN "tokensOut" INTEGER NOT NULL DEFAULT 0,
8
+ ADD COLUMN "explain" TEXT,
9
+ ADD COLUMN "summary" TEXT,
10
+ ADD COLUMN "results" JSONB,
11
+ ADD COLUMN "finishedAt" TIMESTAMP(3);
12
+
13
+ -- CreateTable
14
+ CREATE TABLE "prenta_job_events" (
15
+ "id" TEXT NOT NULL,
16
+ "jobId" TEXT NOT NULL,
17
+ "at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
18
+ "kind" TEXT NOT NULL,
19
+ "message" TEXT NOT NULL,
20
+ "detail" TEXT,
21
+ "durationMs" INTEGER,
22
+ "tokens" INTEGER,
23
+
24
+ CONSTRAINT "prenta_job_events_pkey" PRIMARY KEY ("id")
25
+ );
26
+
27
+ -- CreateTable
28
+ CREATE TABLE "prenta_job_review_items" (
29
+ "id" TEXT NOT NULL,
30
+ "jobId" TEXT NOT NULL,
31
+ "documentId" TEXT NOT NULL,
32
+ "documentTitle" TEXT NOT NULL,
33
+ "url" TEXT NOT NULL DEFAULT '',
34
+ "field" TEXT NOT NULL,
35
+ "before" TEXT NOT NULL,
36
+ "after" TEXT NOT NULL,
37
+ "editedAfter" TEXT,
38
+ "status" TEXT NOT NULL DEFAULT 'pending',
39
+ "decidedById" TEXT,
40
+ "decidedAt" TIMESTAMP(3),
41
+ "appliedRevisionId" TEXT,
42
+
43
+ CONSTRAINT "prenta_job_review_items_pkey" PRIMARY KEY ("id")
44
+ );
45
+
46
+ -- CreateIndex
47
+ CREATE INDEX "prenta_job_events_jobId_at_idx" ON "prenta_job_events"("jobId", "at");
48
+
49
+ -- CreateIndex
50
+ CREATE INDEX "prenta_job_review_items_jobId_status_idx" ON "prenta_job_review_items"("jobId", "status");
51
+
52
+ -- AddForeignKey
53
+ ALTER TABLE "prenta_job_events" ADD CONSTRAINT "prenta_job_events_jobId_fkey" FOREIGN KEY ("jobId") REFERENCES "prenta_jobs"("id") ON DELETE CASCADE ON UPDATE CASCADE;
54
+
55
+ -- AddForeignKey
56
+ ALTER TABLE "prenta_job_review_items" ADD CONSTRAINT "prenta_job_review_items_jobId_fkey" FOREIGN KEY ("jobId") REFERENCES "prenta_jobs"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,30 @@
1
+ -- Down-migration for 0026_job_creator_system_settings. Prisma Migrate has no
2
+ -- down migrations, so run this by hand, with the job worker stopped and the
3
+ -- pre-0026 code deployed:
4
+ --
5
+ -- prisma db execute --file prisma/migrations/0026_job_creator_system_settings/down.sql
6
+ --
7
+ -- Then remove 0026 from the history so `migrate deploy` can apply it again:
8
+ --
9
+ -- DELETE FROM "_prisma_migrations" WHERE "migration_name" = '0026_job_creator_system_settings';
10
+ --
11
+ -- (If 0026 failed part-way, use `prisma migrate resolve --rolled-back
12
+ -- 0026_job_creator_system_settings` instead of the DELETE.)
13
+ --
14
+ -- Who queued each job is lost, so the Jobs screen shows those rows as cron
15
+ -- jobs again. The worker's last-tick time is lost with its table and comes
16
+ -- back on the next tick. Every statement uses IF EXISTS so a part-applied
17
+ -- 0026 rolls back too.
18
+
19
+ BEGIN;
20
+
21
+ -- DropIndex
22
+ DROP INDEX IF EXISTS "prenta_jobs_createdAt_idx";
23
+
24
+ -- DropTable
25
+ DROP TABLE IF EXISTS "prenta_system_settings";
26
+
27
+ -- AlterTable
28
+ ALTER TABLE "prenta_jobs" DROP COLUMN IF EXISTS "createdById";
29
+
30
+ COMMIT;
@@ -0,0 +1,14 @@
1
+ -- AlterTable
2
+ ALTER TABLE "prenta_jobs" ADD COLUMN "createdById" TEXT;
3
+
4
+ -- CreateTable
5
+ CREATE TABLE "prenta_system_settings" (
6
+ "key" TEXT NOT NULL,
7
+ "value" JSONB NOT NULL,
8
+ "updatedAt" TIMESTAMP(3) NOT NULL,
9
+
10
+ CONSTRAINT "prenta_system_settings_pkey" PRIMARY KEY ("key")
11
+ );
12
+
13
+ -- CreateIndex
14
+ CREATE INDEX "prenta_jobs_createdAt_idx" ON "prenta_jobs"("createdAt");
@@ -0,0 +1,24 @@
1
+ -- Down-migration for 0027_chrome_regions. Prisma Migrate has no down
2
+ -- migrations, so run this by hand, with the pre-0027 code deployed:
3
+ --
4
+ -- prisma db execute --file prisma/migrations/0027_chrome_regions/down.sql
5
+ --
6
+ -- Then remove 0027 from the history so `migrate deploy` can apply it again:
7
+ --
8
+ -- DELETE FROM "_prisma_migrations" WHERE "migration_name" = '0027_chrome_regions';
9
+ --
10
+ -- (If 0027 failed part-way, use `prisma migrate resolve --rolled-back
11
+ -- 0027_chrome_regions` instead of the DELETE.)
12
+ --
13
+ -- The header and footer schemas, their saved values and orphans, and the
14
+ -- announcement bar are lost with the table. The next `prenta push chrome`
15
+ -- after 0027 is applied again reads the schema back; the values have to be
16
+ -- entered again. Page overrides live on the pages (`_layout`) and are kept.
17
+ -- The statement uses IF EXISTS so it is safe to run twice.
18
+
19
+ BEGIN;
20
+
21
+ -- DropTable
22
+ DROP TABLE IF EXISTS "prenta_chrome_regions";
23
+
24
+ COMMIT;
@@ -0,0 +1,16 @@
1
+ -- CreateTable
2
+ CREATE TABLE "prenta_chrome_regions" (
3
+ "region" TEXT NOT NULL,
4
+ "schema" JSONB,
5
+ "schemaHash" TEXT,
6
+ "variant" TEXT,
7
+ "values" JSONB NOT NULL DEFAULT '{}',
8
+ "orphans" JSONB NOT NULL DEFAULT '[]',
9
+ "state" JSONB,
10
+ "version" INTEGER NOT NULL DEFAULT 0,
11
+ "updatedById" TEXT,
12
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
13
+ "updatedAt" TIMESTAMP(3) NOT NULL,
14
+
15
+ CONSTRAINT "prenta_chrome_regions_pkey" PRIMARY KEY ("region")
16
+ );
@@ -1113,27 +1113,117 @@ model DocumentNotification {
1113
1113
  }
1114
1114
 
1115
1115
  /// Background work for SEO audit, content health, and batch AI.
1116
- /// `status` is queued | running | succeeded | dead. A dead row is the
1117
- /// dead-letter: it is not claimed again. Ids are minted by the queue so a
1118
- /// stub database that ignores `create` still returns a job id.
1116
+ /// `status` is queued | running | succeeded | dead | cancelled. Only queued
1117
+ /// rows are claimed: a dead row is the dead-letter and a cancelled row is
1118
+ /// final, so neither runs again. Ids are minted by the queue so a stub
1119
+ /// database that ignores `create` still returns a job id.
1119
1120
  model Job {
1120
- id String @id
1121
- type String
1122
- payload Json
1123
- status String
1124
- attempts Int @default(0)
1125
- maxAttempts Int @default(3)
1126
- runAt DateTime
1127
- lockedAt DateTime?
1128
- lastError String?
1129
- progress Json
1130
- createdAt DateTime @default(now())
1131
- updatedAt DateTime @updatedAt
1121
+ id String @id
1122
+ type String
1123
+ payload Json
1124
+ status String
1125
+ attempts Int @default(0)
1126
+ maxAttempts Int @default(3)
1127
+ runAt DateTime
1128
+ lockedAt DateTime?
1129
+ lastError String?
1130
+ progress Json
1131
+ cancelRequestedAt DateTime?
1132
+ cancelledById String?
1133
+ /// Who queued it. Null for cron jobs and rows queued before 0026.
1134
+ createdById String?
1135
+ title String?
1136
+ scope String?
1137
+ tokensIn Int @default(0)
1138
+ tokensOut Int @default(0)
1139
+ explain String?
1140
+ summary String?
1141
+ results Json?
1142
+ finishedAt DateTime?
1143
+ createdAt DateTime @default(now())
1144
+ updatedAt DateTime @updatedAt
1145
+ events JobEvent[]
1146
+ reviewItems JobReviewItem[]
1132
1147
 
1133
1148
  @@index([status, runAt])
1149
+ @@index([createdAt])
1134
1150
  @@map("prenta_jobs")
1135
1151
  }
1136
1152
 
1153
+ /// Worker log for a job. The admin shows the newest 50; a job that ends keeps its newest 100.
1154
+ model JobEvent {
1155
+ id String @id @default(cuid())
1156
+ jobId String
1157
+ job Job @relation(fields: [jobId], references: [id], onDelete: Cascade)
1158
+ at DateTime @default(now())
1159
+ kind String
1160
+ message String
1161
+ detail String?
1162
+ durationMs Int?
1163
+ tokens Int?
1164
+
1165
+ @@index([jobId, at])
1166
+ @@map("prenta_job_events")
1167
+ }
1168
+
1169
+ /// One proposed document change from a review-first batch AI job.
1170
+ model JobReviewItem {
1171
+ id String @id @default(cuid())
1172
+ jobId String
1173
+ job Job @relation(fields: [jobId], references: [id], onDelete: Cascade)
1174
+ documentId String
1175
+ documentTitle String
1176
+ url String @default("")
1177
+ field String
1178
+ before String
1179
+ after String
1180
+ editedAfter String?
1181
+ status String @default("pending")
1182
+ decidedById String?
1183
+ decidedAt DateTime?
1184
+ appliedRevisionId String?
1185
+
1186
+ @@index([jobId, status])
1187
+ @@map("prenta_job_review_items")
1188
+ }
1189
+
1190
+ /// Machine-written state keyed by name, such as the job worker's last tick
1191
+ /// (`jobs.worker`). Separate from the `settings` global so a background write
1192
+ /// can never overwrite an admin's save, and no user id is needed.
1193
+ model SystemSetting {
1194
+ key String @id
1195
+ value Json
1196
+ updatedAt DateTime @updatedAt
1197
+
1198
+ @@map("prenta_system_settings")
1199
+ }
1200
+
1201
+ /// Site chrome for Appearance > Header & Footer, one row per region.
1202
+ /// `header` and `footer` hold the code-first schema the site sends on deploy
1203
+ /// (`schema`, with `source.commit`; variants and fields are ordered pairs
1204
+ /// because JSONB doesn't keep key order), the site-default `variant`, the saved
1205
+ /// field `values`, and the values a schema change dropped (`orphans`, each with
1206
+ /// `orphanedAt`, kept 30 days). `announcement` holds the announcement bar in
1207
+ /// `values`, and in `state` the schedule boundaries that already revalidated
1208
+ /// the site. Every write is conditional on `version`, so a save and a schema
1209
+ /// read can't overwrite each other. `updatedAt` is set by the code, not
1210
+ /// `@updatedAt`'s default: it moves only when the saved values change.
1211
+ model ChromeRegion {
1212
+ region String @id
1213
+ schema Json?
1214
+ schemaHash String?
1215
+ variant String?
1216
+ values Json @default("{}")
1217
+ orphans Json @default("[]")
1218
+ state Json?
1219
+ version Int @default(0)
1220
+ updatedById String?
1221
+ createdAt DateTime @default(now())
1222
+ updatedAt DateTime @updatedAt
1223
+
1224
+ @@map("prenta_chrome_regions")
1225
+ }
1226
+
1137
1227
  /// One MCP OAuth grant. The authorization code and the current refresh token
1138
1228
  /// are stored only as SHA-256 hashes. `familyId` groups rotations; replaying a
1139
1229
  /// replaced refresh token revokes every row in the family.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prenta",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "Scaffold a new Prenta CMS project",
5
5
  "repository": {
6
6
  "type": "git",