Skip to content

Commit 9c55a4d

Browse files
lane711claude
andcommitted
fix: remove duplicate media_asset seed, fix test regressions; release v3.0.0-beta.14
- document-types-seed: remove duplicate media_asset registration (lines 208–227) that overwrote internal:true, causing media_asset to appear in content dropdowns - admin-content-docbacked + api-content-crud tests: update COUNT assertion from 2→1; versioning-off publish() deletes old published row so only v2 survives - on-cron-tick tests: fix swapped (ctx, event) → (event, ctx) argument order - Bump version to 3.0.0-beta.14 (skip beta.13, published from diverged branch) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent ea2eef8 commit 9c55a4d

8 files changed

Lines changed: 21 additions & 40 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sonicjs",
3-
"version": "3.0.0-beta.15",
3+
"version": "3.0.0-beta.14",
44
"private": true,
55
"type": "module",
66
"workspaces": [

packages/core/src/__tests__/routes/admin-content-docbacked.integration.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@ describe('admin-content Option B (document-backed blog_post) — integration', (
120120
body: form({ _method: 'PUT', collection_id: COLL, title: 'Post updateme v2', slug: 'updateme', content: '<p>v2</p>', author: 'Ada', difficulty: 'beginner', status: 'published' }),
121121
})
122122
expect([200, 302]).toContain(res.status)
123-
// A new version exists and exactly one published row, now at v2.
124-
expect(db.raw.prepare("SELECT COUNT(*) n FROM documents WHERE root_id=?").get(rootId).n).toBe(2)
123+
// With versioning off (default), publish() deletes the old published row when it is no longer
124+
// the current draft — so only v2 survives. The version_number still advances to 2.
125+
expect(db.raw.prepare("SELECT COUNT(*) n FROM documents WHERE root_id=?").get(rootId).n).toBe(1)
125126
expect(db.raw.prepare("SELECT COUNT(*) n FROM documents WHERE root_id=? AND is_published=1").get(rootId).n).toBe(1)
126127
expect(db.raw.prepare("SELECT version_number v FROM documents WHERE root_id=? AND is_published=1").get(rootId).v).toBe(2)
127128
})

packages/core/src/__tests__/routes/api-content-crud-documents.integration.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ describe('api-content-crud → documents (decommission step)', () => {
6767
const created = (await (await app.request('/api/content', json('POST', { collectionId: 'blog_post', title: 'V1', slug: 'v', status: 'published', data: {} }))).json()).data
6868
const res = await app.request(`/api/content/${created.id}`, json('PUT', { data: { body: 'v2' }, status: 'published' }))
6969
expect(res.status).toBe(200)
70-
expect(db.raw.prepare('SELECT COUNT(*) n FROM documents WHERE root_id=?').get(created.id).n).toBe(2)
70+
// With versioning off (default), publish() deletes the old published row — only v2 survives.
71+
expect(db.raw.prepare('SELECT COUNT(*) n FROM documents WHERE root_id=?').get(created.id).n).toBe(1)
7172
expect(db.raw.prepare('SELECT version_number v FROM documents WHERE root_id=? AND is_published=1').get(created.id).v).toBe(2)
7273
})
7374

packages/core/src/plugins/core-plugins/email-plugin/hooks/on-cron-tick.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ describe('onCronTick — hookFamily filter', () => {
3636
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
3737
const ctx = makeCtx({}) // no credentials, no DB
3838

39-
await onCronTick(ctx, {
39+
await onCronTick({
4040
type: 'cron:tick',
4141
schedule: '*/5 * * * *',
4242
hookFamily: 'some-other-plugin-cron',
4343
triggeredAt: 1700000000000,
44-
})
44+
}, ctx)
4545

4646
expect(warn).not.toHaveBeenCalled()
4747
})
@@ -52,12 +52,12 @@ describe('onCronTick — credential check', () => {
5252
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
5353
const ctx = makeCtx({ DB: {}, EMAIL_API_TOKEN: 'tok' })
5454

55-
await onCronTick(ctx, {
55+
await onCronTick({
5656
type: 'cron:tick',
5757
schedule: '*/5 * * * *',
5858
hookFamily: 'email-reconciliation',
5959
triggeredAt: 0,
60-
})
60+
}, ctx)
6161

6262
expect(warn).toHaveBeenCalledWith(
6363
expect.stringContaining('CF GraphQL credentials missing'),
@@ -69,12 +69,12 @@ describe('onCronTick — credential check', () => {
6969
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
7070
const ctx = makeCtx({ DB: {}, CF_ZONE_ID: 'zone' })
7171

72-
await onCronTick(ctx, {
72+
await onCronTick({
7373
type: 'cron:tick',
7474
schedule: '*/5 * * * *',
7575
hookFamily: 'email-reconciliation',
7676
triggeredAt: 0,
77-
})
77+
}, ctx)
7878

7979
expect(warn).toHaveBeenCalledWith(
8080
expect.stringContaining('CF GraphQL credentials missing'),
@@ -87,12 +87,12 @@ describe('onCronTick — credential check', () => {
8787
const ctx = makeCtx({ DB: {} })
8888

8989
await expect(
90-
onCronTick(ctx, {
90+
onCronTick({
9191
type: 'cron:tick',
9292
schedule: '*/5 * * * *',
9393
hookFamily: 'email-reconciliation',
9494
triggeredAt: 0,
95-
}),
95+
}, ctx),
9696
).resolves.toBeUndefined()
9797
})
9898
})
@@ -120,7 +120,7 @@ describe('onCronTick — happy path (credentials present)', () => {
120120
) as never
121121

122122
const ctx = makeCtx({ DB: {} as unknown, CF_ZONE_ID: 'zone', EMAIL_API_TOKEN: 'tok' })
123-
await onCronTick(ctx, { type: 'cron:tick', schedule: '*/5 * * * *', hookFamily: 'email-reconciliation', triggeredAt: 1700000000000 })
123+
await onCronTick({ type: 'cron:tick', schedule: '*/5 * * * *', hookFamily: 'email-reconciliation', triggeredAt: 1700000000000 }, ctx)
124124

125125
// Pre-#701: this outcome was silently swallowed — making "cron working but
126126
// CF returned 0 rows" indistinguishable from "cron never fired" in worker logs.
@@ -147,7 +147,7 @@ describe('onCronTick — happy path (credentials present)', () => {
147147
) as never
148148

149149
const ctx = makeCtx({ DB: makeDb(), CF_ZONE_ID: 'zone', EMAIL_API_TOKEN: 'tok' })
150-
await onCronTick(ctx, { type: 'cron:tick', schedule: '*/5 * * * *', hookFamily: 'email-reconciliation', triggeredAt: 1700000000000 })
150+
await onCronTick({ type: 'cron:tick', schedule: '*/5 * * * *', hookFamily: 'email-reconciliation', triggeredAt: 1700000000000 }, ctx)
151151

152152
expect(log).toHaveBeenCalledWith(
153153
expect.stringContaining('reconciliation cron: ok'),
@@ -163,7 +163,7 @@ describe('onCronTick — happy path (credentials present)', () => {
163163
globalThis.fetch = vi.fn(async () => new Response('Internal Server Error', { status: 500 })) as never
164164

165165
const ctx = makeCtx({ DB: makeDb(), CF_ZONE_ID: 'zone', EMAIL_API_TOKEN: 'tok' })
166-
await onCronTick(ctx, { type: 'cron:tick', schedule: '*/5 * * * *', hookFamily: 'email-reconciliation', triggeredAt: 0 })
166+
await onCronTick({ type: 'cron:tick', schedule: '*/5 * * * *', hookFamily: 'email-reconciliation', triggeredAt: 0 }, ctx)
167167

168168
expect(warn).toHaveBeenCalledWith(
169169
expect.stringContaining('GraphQL error'),
@@ -190,7 +190,7 @@ describe('onCronTick — D1 settings fallback', () => {
190190
})),
191191
} as unknown as D1Database
192192
const ctx = makeCtx({ DB: db, CF_ZONE_ID: 'zone' }) // EMAIL_API_TOKEN absent
193-
await onCronTick(ctx, { type: 'cron:tick', schedule: '*/5 * * * *', hookFamily: 'email-reconciliation', triggeredAt: 0 })
193+
await onCronTick({ type: 'cron:tick', schedule: '*/5 * * * *', hookFamily: 'email-reconciliation', triggeredAt: 0 }, ctx)
194194
expect(debug).toHaveBeenCalledWith(expect.stringContaining('EMAIL_API_TOKEN read from D1'))
195195
})
196196
})

packages/core/src/services/document-types-seed.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -229,27 +229,6 @@ export async function bootstrapDocumentTypes(db: D1Database): Promise<void> {
229229
],
230230
})
231231

232-
// Media asset: every file upload creates a media_asset document (document-authoritative).
233-
// File bytes stay in R2; this document holds intrinsic metadata (dimensions, mime, r2Key…).
234-
await registry.register({
235-
id: 'media_asset',
236-
name: 'media_asset',
237-
displayName: 'Media Asset',
238-
description: 'Media file metadata (R2 object key + intrinsic properties; URL derived at read time)',
239-
source: 'system',
240-
schema: anyObject,
241-
settings: {
242-
baseGrants: { public: ['read'], admin: ['read', 'create', 'update', 'delete', 'publish', 'manage'], editor: ['read', 'create', 'update'] },
243-
maxVersionsPerRoot: 5,
244-
},
245-
queryableFields: [
246-
{ name: 'mimeType', kind: 'scalar', type: 'text', column: 'q_media_mime' },
247-
{ name: 'folder', kind: 'scalar', type: 'text', column: 'q_media_folder' },
248-
{ name: 'size', kind: 'scalar', type: 'integer', column: 'q_media_size' },
249-
{ name: 'tags', kind: 'facet', type: 'text' },
250-
],
251-
})
252-
253232
// ── RBAC (auth-owned). 3 document types replace 4 relational tables: ──────────
254233
// rbac_role slug = roleId, data.grants[] embedded (replaces role_grants)
255234
// rbac_verb slug = verbId

packages/create-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "create-sonicjs",
3-
"version": "3.0.0-beta.15",
3+
"version": "3.0.0-beta.14",
44
"description": "Create a new SonicJS application with zero configuration",
55
"type": "module",
66
"bin": {

packages/create-app/src/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ async function copyTemplate(templateName, targetDir, options) {
409409

410410
// Add @sonicjs-cms/core dependency
411411
packageJson.dependencies = {
412-
'@sonicjs-cms/core': '^3.0.0-beta.15',
412+
'@sonicjs-cms/core': '^3.0.0-beta.14',
413413
...packageJson.dependencies
414414
}
415415

www/src/lib/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// When releasing a new version, run `npm run version:patch` (or minor/major) from the root
66
// which will update this file via scripts/sync-versions.js
77

8-
export const VERSION = '3.0.0-beta.15'
8+
export const VERSION = '3.0.0-beta.14'
99

1010
// Helper function to get the current month/year for "Last updated"
1111
export function getLastUpdatedDate(): string {

0 commit comments

Comments
 (0)