Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sonicjs",
"version": "3.0.0-beta.15",
"version": "3.0.0-beta.14",
"private": true,
"type": "module",
"workspaces": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ describe('admin-content Option B (document-backed blog_post) — integration', (
body: form({ _method: 'PUT', collection_id: COLL, title: 'Post updateme v2', slug: 'updateme', content: '<p>v2</p>', author: 'Ada', difficulty: 'beginner', status: 'published' }),
})
expect([200, 302]).toContain(res.status)
// A new version exists and exactly one published row, now at v2.
expect(db.raw.prepare("SELECT COUNT(*) n FROM documents WHERE root_id=?").get(rootId).n).toBe(2)
// With versioning off (default), publish() deletes the old published row when it is no longer
// the current draft — so only v2 survives. The version_number still advances to 2.
expect(db.raw.prepare("SELECT COUNT(*) n FROM documents WHERE root_id=?").get(rootId).n).toBe(1)
expect(db.raw.prepare("SELECT COUNT(*) n FROM documents WHERE root_id=? AND is_published=1").get(rootId).n).toBe(1)
expect(db.raw.prepare("SELECT version_number v FROM documents WHERE root_id=? AND is_published=1").get(rootId).v).toBe(2)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ describe('api-content-crud → documents (decommission step)', () => {
const created = (await (await app.request('/api/content', json('POST', { collectionId: 'blog_post', title: 'V1', slug: 'v', status: 'published', data: {} }))).json()).data
const res = await app.request(`/api/content/${created.id}`, json('PUT', { data: { body: 'v2' }, status: 'published' }))
expect(res.status).toBe(200)
expect(db.raw.prepare('SELECT COUNT(*) n FROM documents WHERE root_id=?').get(created.id).n).toBe(2)
// With versioning off (default), publish() deletes the old published row — only v2 survives.
expect(db.raw.prepare('SELECT COUNT(*) n FROM documents WHERE root_id=?').get(created.id).n).toBe(1)
expect(db.raw.prepare('SELECT version_number v FROM documents WHERE root_id=? AND is_published=1').get(created.id).v).toBe(2)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ describe('onCronTick — hookFamily filter', () => {
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
const ctx = makeCtx({}) // no credentials, no DB

await onCronTick(ctx, {
await onCronTick({
type: 'cron:tick',
schedule: '*/5 * * * *',
hookFamily: 'some-other-plugin-cron',
triggeredAt: 1700000000000,
})
}, ctx)

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

await onCronTick(ctx, {
await onCronTick({
type: 'cron:tick',
schedule: '*/5 * * * *',
hookFamily: 'email-reconciliation',
triggeredAt: 0,
})
}, ctx)

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

await onCronTick(ctx, {
await onCronTick({
type: 'cron:tick',
schedule: '*/5 * * * *',
hookFamily: 'email-reconciliation',
triggeredAt: 0,
})
}, ctx)

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

await expect(
onCronTick(ctx, {
onCronTick({
type: 'cron:tick',
schedule: '*/5 * * * *',
hookFamily: 'email-reconciliation',
triggeredAt: 0,
}),
}, ctx),
).resolves.toBeUndefined()
})
})
Expand Down Expand Up @@ -120,7 +120,7 @@ describe('onCronTick — happy path (credentials present)', () => {
) as never

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

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

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

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

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

expect(warn).toHaveBeenCalledWith(
expect.stringContaining('GraphQL error'),
Expand All @@ -190,7 +190,7 @@ describe('onCronTick — D1 settings fallback', () => {
})),
} as unknown as D1Database
const ctx = makeCtx({ DB: db, CF_ZONE_ID: 'zone' }) // EMAIL_API_TOKEN absent
await onCronTick(ctx, { type: 'cron:tick', schedule: '*/5 * * * *', hookFamily: 'email-reconciliation', triggeredAt: 0 })
await onCronTick({ type: 'cron:tick', schedule: '*/5 * * * *', hookFamily: 'email-reconciliation', triggeredAt: 0 }, ctx)
expect(debug).toHaveBeenCalledWith(expect.stringContaining('EMAIL_API_TOKEN read from D1'))
})
})
21 changes: 0 additions & 21 deletions packages/core/src/services/document-types-seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,27 +229,6 @@ export async function bootstrapDocumentTypes(db: D1Database): Promise<void> {
],
})

// Media asset: every file upload creates a media_asset document (document-authoritative).
// File bytes stay in R2; this document holds intrinsic metadata (dimensions, mime, r2Key…).
await registry.register({
id: 'media_asset',
name: 'media_asset',
displayName: 'Media Asset',
description: 'Media file metadata (R2 object key + intrinsic properties; URL derived at read time)',
source: 'system',
schema: anyObject,
settings: {
baseGrants: { public: ['read'], admin: ['read', 'create', 'update', 'delete', 'publish', 'manage'], editor: ['read', 'create', 'update'] },
maxVersionsPerRoot: 5,
},
queryableFields: [
{ name: 'mimeType', kind: 'scalar', type: 'text', column: 'q_media_mime' },
{ name: 'folder', kind: 'scalar', type: 'text', column: 'q_media_folder' },
{ name: 'size', kind: 'scalar', type: 'integer', column: 'q_media_size' },
{ name: 'tags', kind: 'facet', type: 'text' },
],
})

// ── RBAC (auth-owned). 3 document types replace 4 relational tables: ──────────
// rbac_role slug = roleId, data.grants[] embedded (replaces role_grants)
// rbac_verb slug = verbId
Expand Down
2 changes: 1 addition & 1 deletion packages/create-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-sonicjs",
"version": "3.0.0-beta.15",
"version": "3.0.0-beta.14",
"description": "Create a new SonicJS application with zero configuration",
"type": "module",
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion packages/create-app/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ async function copyTemplate(templateName, targetDir, options) {

// Add @sonicjs-cms/core dependency
packageJson.dependencies = {
'@sonicjs-cms/core': '^3.0.0-beta.15',
'@sonicjs-cms/core': '^3.0.0-beta.14',
...packageJson.dependencies
}

Expand Down
2 changes: 1 addition & 1 deletion www/src/lib/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// When releasing a new version, run `npm run version:patch` (or minor/major) from the root
// which will update this file via scripts/sync-versions.js

export const VERSION = '3.0.0-beta.15'
export const VERSION = '3.0.0-beta.14'

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