@elytracms/studio 0.0.13 → 0.0.15
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/convex/cms.ts +8 -22
- package/convex/content.ts +3 -44
- package/convex/delivery.ts +8 -42
- package/convex/functions.ts +17 -2
- package/convex/members.ts +2 -2
- package/convex/referenceMaintenance.ts +4 -73
- package/convex/references.ts +4 -2
- package/convex/revalidate.ts +42 -0
- package/convex/schema.ts +17 -37
- package/convex/sync.ts +10 -42
- package/convex/triggers.ts +57 -0
- package/convex/webhooks.ts +3 -2
- package/dist/components/builder/builder-store.d.ts +85 -39
- package/dist/components/builder/builder-store.js +29 -125
- package/dist/components/builder/builder-store.js.map +1 -1
- package/dist/components/builder/canvas.js +23 -55
- package/dist/components/builder/canvas.js.map +1 -1
- package/dist/components/builder/clipboard-actions.js +3 -3
- package/dist/components/builder/clipboard-actions.js.map +1 -1
- package/dist/components/builder/composition-field-editor.js +13 -23
- package/dist/components/builder/composition-field-editor.js.map +1 -1
- package/dist/components/builder/insert-context.js +1 -1
- package/dist/components/builder/insert-context.js.map +1 -1
- package/dist/components/builder/page-tree.js +3 -4
- package/dist/components/builder/page-tree.js.map +1 -1
- package/dist/components/builder/property-inspector.js +4 -64
- package/dist/components/builder/property-inspector.js.map +1 -1
- package/dist/components/cms/cell.d.ts +0 -4
- package/dist/components/cms/cell.js +1 -5
- package/dist/components/cms/cell.js.map +1 -1
- package/dist/components/cms/cms-store.d.ts +1 -1
- package/dist/components/cms/cms-store.js +4 -9
- package/dist/components/cms/cms-store.js.map +1 -1
- package/dist/components/cms/collection-table.js +1 -1
- package/dist/components/cms/collection-table.js.map +1 -1
- package/dist/components/cms/detail-editor.js +2 -2
- package/dist/components/cms/detail-editor.js.map +1 -1
- package/dist/components/cms/doc-state.d.ts +0 -5
- package/dist/components/cms/doc-state.js +1 -7
- package/dist/components/cms/doc-state.js.map +1 -1
- package/dist/components/cms/editable-cell.js +1 -1
- package/dist/components/cms/editable-cell.js.map +1 -1
- package/dist/components/collab/collab-context.d.ts +6 -14
- package/dist/components/collab/collab-context.js +3 -12
- package/dist/components/collab/collab-context.js.map +1 -1
- package/dist/components/collab/collab-seed.d.ts +7 -19
- package/dist/components/collab/collab-seed.js +9 -31
- package/dist/components/collab/collab-seed.js.map +1 -1
- package/dist/components/components/registry-browser.js +6 -12
- package/dist/components/components/registry-browser.js.map +1 -1
- package/dist/components/guards.d.ts +0 -9
- package/dist/components/guards.js +0 -12
- package/dist/components/guards.js.map +1 -1
- package/dist/components/section-state.d.ts +0 -2
- package/dist/components/section-state.js +0 -9
- package/dist/components/section-state.js.map +1 -1
- package/dist/components/section-surface.d.ts +3 -7
- package/dist/components/section-surface.js +5 -12
- package/dist/components/section-surface.js.map +1 -1
- package/dist/components/sections.d.ts +0 -1
- package/dist/components/sections.js +0 -10
- package/dist/components/sections.js.map +1 -1
- package/dist/components/studio-project-screen.js +13 -14
- package/dist/components/studio-project-screen.js.map +1 -1
- package/dist/components/studio-shell.d.ts +0 -4
- package/dist/components/studio-shell.js +1 -5
- package/dist/components/studio-shell.js.map +1 -1
- package/dist/lib/operations/graph-commands.d.ts +2 -6
- package/dist/lib/operations/graph-commands.js +1 -2
- package/dist/lib/operations/graph-commands.js.map +1 -1
- package/dist/lib/operations/index.d.ts +0 -2
- package/dist/lib/operations/index.js +0 -2
- package/dist/lib/operations/index.js.map +1 -1
- package/dist/lib/operations/session-hydration.d.ts +14 -24
- package/dist/lib/operations/session-hydration.js +15 -34
- package/dist/lib/operations/session-hydration.js.map +1 -1
- package/dist/lib/persistence/convex-adapter.d.ts +1 -3
- package/dist/lib/persistence/convex-adapter.js +1 -154
- package/dist/lib/persistence/convex-adapter.js.map +1 -1
- package/dist/lib/persona/labels.js +0 -2
- package/dist/lib/persona/labels.js.map +1 -1
- package/dist/lib/references/reference-model.d.ts +0 -16
- package/dist/lib/references/reference-model.js +2 -54
- package/dist/lib/references/reference-model.js.map +1 -1
- package/dist/lib/references/references-store.js +3 -4
- package/dist/lib/references/references-store.js.map +1 -1
- package/dist/lib/registry/index.d.ts +0 -16
- package/dist/lib/registry/index.js +0 -15
- package/dist/lib/registry/index.js.map +1 -1
- package/dist/lib/webhooks/tags.js +2 -16
- package/dist/lib/webhooks/tags.js.map +1 -1
- package/package.json +3 -2
- package/convex/graphs.ts +0 -55
- package/convex/publishing.ts +0 -108
package/convex/publishing.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { makeFunctionReference } from 'convex/server'
|
|
2
|
-
import { v } from 'convex/values'
|
|
3
|
-
import { mutation, query } from './functions'
|
|
4
|
-
import type { MutationCtx } from './functions'
|
|
5
|
-
import { requireRole } from './guard'
|
|
6
|
-
import { maintainGraphPublishedReferences } from './referenceMaintenance'
|
|
7
|
-
|
|
8
|
-
// EC-223: the studio's convex functions are package-shipped and deployment-agnostic
|
|
9
|
-
// — they address each other by STRING ref (resolved against the consumer's deployment),
|
|
10
|
-
// never the per-deployment `_generated/api`. Mirrors the lib's `queryRef`/`actionRef`.
|
|
11
|
-
const webhooksDeliver = makeFunctionReference<'action'>('webhooks:deliver')
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Publishing state (EC-045). Single-environment (EC-179, vision AD-8): a
|
|
15
|
-
* deployment IS one environment, so there is exactly ONE publishingState row —
|
|
16
|
-
* see `env-is-deployment-boundary`.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* EC-180 / EC-146 — fire the host revalidation webhook on a publish-state change.
|
|
21
|
-
*
|
|
22
|
-
* A mutation cannot `fetch`, so we hand off to the `webhooks.deliver` internal
|
|
23
|
-
* action (it signs + POSTs server-side; the secret never leaves Convex). A graph
|
|
24
|
-
* publish/unpublish can affect any page, so the honest v1 invalidation is the
|
|
25
|
-
* whole-project sweep tag `p:<scope>:project` — a mirror of
|
|
26
|
-
* `projectSweepWebhookTag` (`src/lib/webhooks/tags.ts`) / `@elytracms/next`'s
|
|
27
|
-
* `projectSweepTag`; the tests on those two sides pin the literal.
|
|
28
|
-
*
|
|
29
|
-
* `scope` must equal the host's `cache.scope` (its `ELYTRA_PROJECT_ID`) for the
|
|
30
|
-
* tag to match what the host stamped on its cached fetches; it comes from the
|
|
31
|
-
* `CANVAS_PROJECT_SCOPE` Convex env var. Unconfigured deployments (local dev,
|
|
32
|
-
* no env) are a silent no-op — publishing must never depend on a reachable host.
|
|
33
|
-
*/
|
|
34
|
-
async function scheduleRevalidate(
|
|
35
|
-
ctx: MutationCtx,
|
|
36
|
-
event: 'publishing.publish' | 'publishing.unpublish',
|
|
37
|
-
): Promise<void> {
|
|
38
|
-
const env =
|
|
39
|
-
(globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env ?? {}
|
|
40
|
-
const scope = env['CANVAS_PROJECT_SCOPE']
|
|
41
|
-
if (!scope) return
|
|
42
|
-
await ctx.scheduler.runAfter(0, webhooksDeliver, {
|
|
43
|
-
projectId: scope,
|
|
44
|
-
event,
|
|
45
|
-
tags: [`p:${scope}:project`],
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const publish = mutation({
|
|
50
|
-
args: {
|
|
51
|
-
revisionId: v.string(),
|
|
52
|
-
revision: v.number(),
|
|
53
|
-
publishedAt: v.string(),
|
|
54
|
-
},
|
|
55
|
-
handler: async (ctx, args) => {
|
|
56
|
-
await requireRole(ctx, 'editor') // EC-150
|
|
57
|
-
const existing = await ctx.db.query('publishingState').first()
|
|
58
|
-
const record = {
|
|
59
|
-
status: 'published' as const,
|
|
60
|
-
publishedRevisionId: args.revisionId,
|
|
61
|
-
publishedRevision: args.revision,
|
|
62
|
-
publishedAt: args.publishedAt,
|
|
63
|
-
createdAt: existing?.createdAt ?? args.publishedAt,
|
|
64
|
-
updatedAt: args.publishedAt,
|
|
65
|
-
}
|
|
66
|
-
// EC-153 parity: republish preserves `createdAt`; return the stored record.
|
|
67
|
-
const id = existing ? existing._id : await ctx.db.insert('publishingState', record)
|
|
68
|
-
if (existing) await ctx.db.patch(existing._id, record)
|
|
69
|
-
// EC-277: the newly pinned revision becomes the published graph — reindex its
|
|
70
|
-
// published reference rows in-transaction (AD-6 "at the source").
|
|
71
|
-
await maintainGraphPublishedReferences(ctx)
|
|
72
|
-
// EC-180: drop the host's cached pages for this project (fire-and-forget).
|
|
73
|
-
await scheduleRevalidate(ctx, 'publishing.publish')
|
|
74
|
-
return ctx.db.get(id)
|
|
75
|
-
},
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
export const unpublish = mutation({
|
|
79
|
-
args: { updatedAt: v.string() },
|
|
80
|
-
handler: async (ctx, args) => {
|
|
81
|
-
await requireRole(ctx, 'editor') // EC-150
|
|
82
|
-
const existing = await ctx.db.query('publishingState').first()
|
|
83
|
-
if (!existing || existing.status !== 'published') {
|
|
84
|
-
throw new Error('invalid-transition: nothing is currently published')
|
|
85
|
-
}
|
|
86
|
-
await ctx.db.patch(existing._id, {
|
|
87
|
-
status: 'draft',
|
|
88
|
-
publishedRevisionId: undefined,
|
|
89
|
-
publishedRevision: undefined,
|
|
90
|
-
publishedAt: undefined,
|
|
91
|
-
updatedAt: args.updatedAt,
|
|
92
|
-
})
|
|
93
|
-
// EC-277: a graph going dark drops every published graph reference row.
|
|
94
|
-
await maintainGraphPublishedReferences(ctx)
|
|
95
|
-
// EC-180: a graph going dark must also drop the host's cached pages.
|
|
96
|
-
await scheduleRevalidate(ctx, 'publishing.unpublish')
|
|
97
|
-
// EC-153 parity: return the stored record (createdAt preserved).
|
|
98
|
-
return ctx.db.get(existing._id)
|
|
99
|
-
},
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
export const getState = query({
|
|
103
|
-
args: {},
|
|
104
|
-
handler: async (ctx) => {
|
|
105
|
-
await requireRole(ctx, 'viewer') // EC-150
|
|
106
|
-
return ctx.db.query('publishingState').first()
|
|
107
|
-
},
|
|
108
|
-
})
|