smoodly 0.0.51 → 0.0.53
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/README.md +14 -13
- package/dist/admin/auth.d.ts +3 -11
- package/dist/admin/auth.js +1 -30
- package/dist/admin/client-ops.d.ts +5 -4
- package/dist/admin/client-ops.js +15 -12
- package/dist/admin/delivery-mode.d.ts +1 -1
- package/dist/admin/delivery-mode.js +2 -2
- package/dist/admin/drift.d.ts +0 -2
- package/dist/admin/drift.js +1 -1
- package/dist/admin/editor/EditorView.d.ts +0 -3
- package/dist/admin/editor/EditorView.js +11 -16
- package/dist/admin/editor/FloatingToolbar.d.ts +0 -1
- package/dist/admin/editor/FloatingToolbar.js +1 -1
- package/dist/admin/editor/SeoSettings.d.ts +0 -2
- package/dist/admin/editor/SeoSettings.js +2 -2
- package/dist/admin/editor/canvas-address.d.ts +8 -0
- package/dist/admin/editor/canvas-address.js +18 -2
- package/dist/admin/editor/canvas-diagnosis.d.ts +2 -0
- package/dist/admin/editor/canvas-diagnosis.js +3 -0
- package/dist/admin/editor/inline-dom.d.ts +0 -4
- package/dist/admin/editor/inline-dom.js +1 -1
- package/dist/admin/editor/preview-grant.d.ts +6 -0
- package/dist/admin/editor/preview-grant.js +25 -0
- package/dist/admin/editor/useCanvasDiagnosis.js +2 -2
- package/dist/admin/files.generated.js +1 -1
- package/dist/admin/fixed-nodes.d.ts +0 -6
- package/dist/admin/fixed-nodes.js +1 -81
- package/dist/admin/forms/CropEditor.d.ts +4 -2
- package/dist/admin/forms/CropEditor.js +58 -5
- package/dist/admin/forms/ImagePreview.d.ts +3 -1
- package/dist/admin/forms/ImagePreview.js +9 -3
- package/dist/admin/forms/MediaGrid.js +2 -1
- package/dist/admin/forms/MediaPicker.js +9 -6
- package/dist/admin/forms/MediaWidget.js +11 -9
- package/dist/admin/forms/assets-context.d.ts +7 -3
- package/dist/admin/forms/assets-context.js +5 -3
- package/dist/admin/forms/crop-editor.d.ts +24 -2
- package/dist/admin/forms/crop-editor.js +36 -2
- package/dist/admin/forms/date-picker.d.ts +0 -1
- package/dist/admin/forms/date-picker.js +1 -1
- package/dist/admin/forms/tabs.d.ts +0 -1
- package/dist/admin/forms/tabs.js +1 -1
- package/dist/admin/forms/upload.d.ts +18 -11
- package/dist/admin/forms/upload.js +62 -24
- package/dist/admin/global-items.d.ts +0 -3
- package/dist/admin/global-items.js +0 -54
- package/dist/admin/handler.d.ts +22 -28
- package/dist/admin/handler.js +146 -47
- package/dist/admin/health.d.ts +0 -4
- package/dist/admin/index.d.ts +6 -9
- package/dist/admin/index.js +3 -6
- package/dist/admin/ops.d.ts +40 -32
- package/dist/admin/page-data.d.ts +14 -6
- package/dist/admin/page-data.js +1 -1
- package/dist/admin/session-flow.d.ts +65 -0
- package/dist/admin/session-flow.js +121 -0
- package/dist/admin/shell/AdminApp.d.ts +8 -3
- package/dist/admin/shell/AdminApp.js +37 -58
- package/dist/admin/shell/ContentHealthPage.js +1 -3
- package/dist/admin/shell/GlobalFields.d.ts +0 -3
- package/dist/admin/shell/GlobalFields.js +1 -1
- package/dist/admin/shell/IconRail.js +10 -8
- package/dist/admin/shell/MediaScreen.js +9 -6
- package/dist/admin/shell/MembersPage.d.ts +1 -2
- package/dist/admin/shell/MembersPage.js +19 -90
- package/dist/admin/shell/SettingsView.d.ts +1 -2
- package/dist/admin/shell/SettingsView.js +2 -2
- package/dist/admin/shell/SignedOutView.d.ts +5 -0
- package/dist/admin/shell/SignedOutView.js +9 -0
- package/dist/admin/shell/console-links.d.ts +5 -0
- package/dist/admin/shell/console-links.js +11 -0
- package/dist/admin/shell/members-list.d.ts +1 -14
- package/dist/admin/shell/members-list.js +2 -23
- package/dist/admin/shell/pages-tree.d.ts +0 -2
- package/dist/admin/shell/pages-tree.js +1 -1
- package/dist/admin/shell/presence-socket.d.ts +10 -0
- package/dist/admin/shell/presence-socket.js +191 -0
- package/dist/admin/shell/presence.d.ts +6 -18
- package/dist/admin/shell/presence.js +4 -11
- package/dist/admin/shell/session.d.ts +19 -12
- package/dist/admin/shell/session.js +114 -47
- package/dist/admin/ui/LocaleSwitcher.d.ts +0 -4
- package/dist/admin/ui/LocaleSwitcher.js +2 -2
- package/dist/admin/ui/primitives.d.ts +4 -14
- package/dist/admin/ui/primitives.js +7 -9
- package/dist/admin/ui/theme.js +13 -2
- package/dist/admin/validate.js +10 -1
- package/dist/api-client.d.ts +26 -0
- package/dist/api-client.js +107 -0
- package/dist/assemble.d.ts +4 -41
- package/dist/assemble.js +5 -303
- package/dist/asset-store.d.ts +28 -30
- package/dist/asset-store.js +26 -121
- package/dist/astro/cache.d.ts +1 -1
- package/dist/astro/components/Head.astro +4 -1
- package/dist/astro/components/Image.astro +12 -17
- package/dist/astro/components/Video.astro +5 -2
- package/dist/astro/head.d.ts +3 -0
- package/dist/astro/head.js +24 -0
- package/dist/astro/index.js +61 -27
- package/dist/astro/locale-paths.d.ts +5 -2
- package/dist/astro/locale-paths.js +10 -2
- package/dist/astro/routes/admin.js +9 -7
- package/dist/astro/runtime.d.ts +3 -2
- package/dist/astro/runtime.js +5 -4
- package/dist/astro/server.d.ts +7 -11
- package/dist/astro/server.js +22 -28
- package/dist/astro/shell.d.ts +3 -3
- package/dist/astro/shell.js +1 -1
- package/dist/astro/static-media-node.d.ts +4 -0
- package/dist/astro/static-media-node.js +25 -0
- package/dist/astro/static-media.d.ts +17 -0
- package/dist/astro/static-media.js +55 -0
- package/dist/astro/static.d.ts +5 -10
- package/dist/astro/static.js +13 -29
- package/dist/canvas-marker.d.ts +14 -0
- package/dist/canvas-marker.js +36 -0
- package/dist/cli/api.d.ts +14 -0
- package/dist/cli/api.js +48 -0
- package/dist/cli/app-env.d.ts +2 -0
- package/dist/cli/app-env.js +20 -0
- package/dist/cli/export.d.ts +16 -2
- package/dist/cli/export.js +52 -35
- package/dist/cli/import.d.ts +7 -11
- package/dist/cli/import.js +50 -54
- package/dist/cli/load-config.d.ts +0 -1
- package/dist/cli/load-config.js +1 -1
- package/dist/cli/main.d.ts +4 -12
- package/dist/cli/main.js +26 -72
- package/dist/cli/push.d.ts +6 -0
- package/dist/cli/push.js +31 -0
- package/dist/collections.d.ts +0 -1
- package/dist/collections.js +1 -1
- package/dist/config.d.ts +20 -5
- package/dist/config.js +18 -1
- package/dist/content/content-api.d.ts +23 -23
- package/dist/content/content-api.js +48 -56
- package/dist/content/mime.d.ts +1 -0
- package/dist/content/mime.js +6 -0
- package/dist/css.js +1 -1
- package/dist/deploy-store.d.ts +19 -0
- package/dist/entry-store.d.ts +8 -94
- package/dist/entry-store.js +9 -557
- package/dist/env.d.ts +27 -20
- package/dist/env.js +38 -50
- package/dist/fields.d.ts +11 -3
- package/dist/fields.js +33 -2
- package/dist/global-id.d.ts +2 -0
- package/dist/global-id.js +4 -2
- package/dist/image/SmoodlyImage.d.ts +9 -5
- package/dist/image/SmoodlyImage.js +29 -15
- package/dist/image/SmoodlyVideo.d.ts +1 -1
- package/dist/image/SmoodlyVideo.js +3 -2
- package/dist/image/index.d.ts +2 -3
- package/dist/image/index.js +0 -2
- package/dist/image/markup.d.ts +53 -0
- package/dist/image/markup.js +111 -0
- package/dist/index.d.ts +13 -23
- package/dist/index.js +7 -20
- package/dist/media-cut.d.ts +44 -0
- package/dist/media-cut.js +70 -0
- package/dist/media.d.ts +58 -4
- package/dist/media.js +126 -16
- package/dist/member-store.d.ts +2 -50
- package/dist/member-store.js +0 -56
- package/dist/next/admin-route.d.ts +1 -1
- package/dist/next/admin-route.js +5 -3
- package/dist/next/meta.js +2 -3
- package/dist/next/page-renderer.d.ts +2 -2
- package/dist/next/page-renderer.js +22 -11
- package/dist/next/queries.d.ts +2 -2
- package/dist/path-index.d.ts +0 -24
- package/dist/path-index.js +0 -98
- package/dist/paths.d.ts +1 -1
- package/dist/paths.js +1 -1
- package/dist/push.d.ts +30 -0
- package/dist/push.js +52 -0
- package/dist/read-counter.d.ts +2 -0
- package/dist/read-counter.js +6 -0
- package/dist/reads.d.ts +7 -7
- package/dist/reads.js +3 -0
- package/dist/registry-json.d.ts +11 -0
- package/dist/registry-json.js +81 -0
- package/dist/render.d.ts +0 -1
- package/dist/render.js +1 -1
- package/dist/resolve.d.ts +12 -6
- package/dist/resolve.js +11 -8
- package/dist/revalidate.d.ts +8 -1
- package/dist/revalidate.js +8 -1
- package/dist/richtext/index.d.ts +1 -1
- package/dist/section-wrapper.d.ts +1 -1
- package/dist/section-wrapper.js +0 -9
- package/dist/signed-message.d.ts +26 -0
- package/dist/signed-message.js +103 -0
- package/dist/site.d.ts +59 -18
- package/dist/site.js +21 -252
- package/dist/space-transfer.d.ts +6 -3
- package/dist/space-transfer.js +18 -6
- package/dist/store.d.ts +2 -80
- package/dist/store.js +3 -489
- package/dist/toolset.d.ts +2 -1
- package/dist/toolset.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -15
- package/dist/admin/auth-config.d.ts +0 -6
- package/dist/admin/browser/fetch-op.d.ts +0 -10
- package/dist/admin/browser/fetch-op.js +0 -44
- package/dist/admin/browser/main.d.ts +0 -1
- package/dist/admin/browser/main.js +0 -23
- package/dist/admin/ops-impl.d.ts +0 -51
- package/dist/admin/ops-impl.js +0 -1403
- package/dist/admin/shell/InviteModal.d.ts +0 -6
- package/dist/admin/shell/InviteModal.js +0 -28
- package/dist/admin/shell/LoginView.d.ts +0 -5
- package/dist/admin/shell/LoginView.js +0 -80
- package/dist/admin/shell/SchemaNotice.d.ts +0 -4
- package/dist/admin/shell/SchemaNotice.js +0 -4
- package/dist/admin/shell/SetPasswordView.d.ts +0 -7
- package/dist/admin/shell/SetPasswordView.js +0 -41
- package/dist/admin/shell/presence-realtime.d.ts +0 -3
- package/dist/admin/shell/presence-realtime.js +0 -32
- package/dist/admin/supabase-auth.d.ts +0 -7
- package/dist/admin/supabase-auth.js +0 -30
- package/dist/astro/deploy-deps.d.ts +0 -10
- package/dist/astro/deploy-deps.js +0 -8
- package/dist/astro/image.d.ts +0 -27
- package/dist/astro/image.js +0 -29
- package/dist/bind.d.ts +0 -19
- package/dist/bind.js +0 -34
- package/dist/cli/add-admin.d.ts +0 -11
- package/dist/cli/add-admin.js +0 -25
- package/dist/cli/load-collections.d.ts +0 -2
- package/dist/cli/load-collections.js +0 -27
- package/dist/cli/migrate.d.ts +0 -43
- package/dist/cli/migrate.js +0 -138
- package/dist/cli/rebuild.d.ts +0 -23
- package/dist/cli/rebuild.js +0 -22
- package/dist/cli/space-io.d.ts +0 -41
- package/dist/cli/space-io.js +0 -84
- package/dist/client.d.ts +0 -11
- package/dist/client.js +0 -54
- package/dist/current-space.d.ts +0 -4
- package/dist/current-space.js +0 -9
- package/dist/document-stamp.d.ts +0 -7
- package/dist/document-stamp.js +0 -48
- package/dist/image/loaders.d.ts +0 -15
- package/dist/image/loaders.js +0 -5
- package/dist/image/next-config.d.ts +0 -18
- package/dist/image/next-config.js +0 -32
- package/dist/image/remote-pattern.d.ts +0 -1
- package/dist/image/remote-pattern.js +0 -5
- package/dist/migrations.d.ts +0 -37
- package/dist/migrations.js +0 -73
- package/dist/project.d.ts +0 -88
- package/dist/project.js +0 -231
- package/dist/published.d.ts +0 -142
- package/dist/published.js +0 -164
- package/dist/ref-index.d.ts +0 -19
- package/dist/ref-index.js +0 -0
- package/dist/schema-read.d.ts +0 -23
- package/dist/schema-read.js +0 -50
- package/dist/schema-version.d.ts +0 -19
- package/dist/schema-version.js +0 -34
- package/dist/sql-space.d.ts +0 -44
- package/dist/sql-space.js +0 -289
- package/dist/sql.d.ts +0 -15
- package/dist/sql.js +0 -556
- package/dist/supabase-asset-store.d.ts +0 -21
- package/dist/supabase-asset-store.js +0 -170
- package/dist/supabase-entry-store.d.ts +0 -92
- package/dist/supabase-entry-store.js +0 -824
- package/dist/supabase-member-store.d.ts +0 -21
- package/dist/supabase-member-store.js +0 -96
- package/dist/supabase-path-index.d.ts +0 -30
- package/dist/supabase-path-index.js +0 -138
- package/dist/supabase-published-store.d.ts +0 -56
- package/dist/supabase-published-store.js +0 -314
- package/dist/supabase-store.d.ts +0 -103
- package/dist/supabase-store.js +0 -678
- package/migrations/20260926120000_smoodly_v1.sql +0 -535
- package/migrations/20260926130000_smoodly_v2.sql +0 -26
- package/migrations/20260926140000_smoodly_v3.sql +0 -38
- package/migrations/20260926150000_smoodly_v4.sql +0 -41
- package/migrations/20260929120000_smoodly_v5.sql +0 -56
- package/migrations/20260929135523_smoodly_v6.sql +0 -200
- package/migrations/20260930040956_smoodly_v7.sql +0 -84
- package/migrations/20261007120000_smoodly_v8.sql +0 -154
- package/migrations/20261007200000_smoodly_v9.sql +0 -30
- package/migrations/20261008120000_smoodly_v10.sql +0 -47
- package/migrations/20261009120000_smoodly_v11.sql +0 -49
- /package/dist/{admin/auth-config.js → deploy-store.js} +0 -0
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { assetErrors, kindOf, objectPath, withDownload, PAGE_SIZE, } from "./asset-store.js";
|
|
2
|
-
import { ASSET_COLLECTION, MEDIA_CACHE_SECONDS } from "./media.js";
|
|
3
|
-
const BUCKET = "media";
|
|
4
|
-
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
5
|
-
const SELECT = "id, kind, status, path, mime, size, width, height, duration, poster_id, filename, title, alt, caption, credit, created_at, updated_at";
|
|
6
|
-
export class SupabaseAssetStore {
|
|
7
|
-
constructor(db) {
|
|
8
|
-
this.db = db;
|
|
9
|
-
}
|
|
10
|
-
fail(message) {
|
|
11
|
-
throw new Error(`smoodly: ${message}`);
|
|
12
|
-
}
|
|
13
|
-
bucket() {
|
|
14
|
-
return this.db.storage.from(BUCKET);
|
|
15
|
-
}
|
|
16
|
-
toRecord(row) {
|
|
17
|
-
return {
|
|
18
|
-
id: row.id, kind: row.kind, status: row.status, path: row.path, mime: row.mime, size: Number(row.size),
|
|
19
|
-
width: row.width, height: row.height, duration: row.duration === null ? null : Number(row.duration),
|
|
20
|
-
posterId: row.poster_id, filename: row.filename, title: row.title, alt: row.alt, caption: row.caption, credit: row.credit,
|
|
21
|
-
url: withDownload(this.bucket().getPublicUrl(row.path).data.publicUrl, row.mime),
|
|
22
|
-
createdAt: Date.parse(row.created_at), updatedAt: Date.parse(row.updated_at),
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
/** The space this client writes into — the claim, or the default. */
|
|
26
|
-
async space() {
|
|
27
|
-
const res = await this.db.rpc("smoodly_current_space");
|
|
28
|
-
if (res.error)
|
|
29
|
-
this.fail(res.error.message);
|
|
30
|
-
return String(res.data);
|
|
31
|
-
}
|
|
32
|
-
async insert(input, status, extra = {}) {
|
|
33
|
-
const id = crypto.randomUUID();
|
|
34
|
-
const path = objectPath(await this.space(), id, input.filename, input.mime);
|
|
35
|
-
const res = await this.db
|
|
36
|
-
.from("assets")
|
|
37
|
-
.insert({
|
|
38
|
-
id, kind: kindOf(input.mime), status, path, mime: input.mime, size: input.size, filename: input.filename,
|
|
39
|
-
...(input.createdBy ? { created_by: input.createdBy } : {}), ...extra,
|
|
40
|
-
})
|
|
41
|
-
.select(SELECT)
|
|
42
|
-
.single();
|
|
43
|
-
if (res.error)
|
|
44
|
-
this.fail(res.error.message);
|
|
45
|
-
return this.toRecord(res.data);
|
|
46
|
-
}
|
|
47
|
-
async beginUpload(input) {
|
|
48
|
-
const row = await this.insert(input, "pending");
|
|
49
|
-
const signed = await this.bucket().createSignedUploadUrl(row.path);
|
|
50
|
-
if (signed.error)
|
|
51
|
-
this.fail(signed.error.message);
|
|
52
|
-
return { id: row.id, uploadUrl: signed.data.signedUrl, token: signed.data.token };
|
|
53
|
-
}
|
|
54
|
-
async finishUpload(id, dims) {
|
|
55
|
-
const current = await this.get(id);
|
|
56
|
-
if (!current)
|
|
57
|
-
throw assetErrors.notFound(id);
|
|
58
|
-
if (current.status !== "pending")
|
|
59
|
-
throw assetErrors.notPending(id);
|
|
60
|
-
const res = await this.db
|
|
61
|
-
.from("assets")
|
|
62
|
-
.update({
|
|
63
|
-
status: "ready", width: dims.width ?? null, height: dims.height ?? null, duration: dims.duration ?? null,
|
|
64
|
-
poster_id: dims.posterId ?? null, updated_at: new Date().toISOString(),
|
|
65
|
-
})
|
|
66
|
-
.eq("id", id)
|
|
67
|
-
.select(SELECT)
|
|
68
|
-
.single();
|
|
69
|
-
if (res.error)
|
|
70
|
-
this.fail(res.error.message);
|
|
71
|
-
return this.toRecord(res.data);
|
|
72
|
-
}
|
|
73
|
-
async create(input) {
|
|
74
|
-
const row = await this.insert(input, "ready", {
|
|
75
|
-
width: input.width ?? null, height: input.height ?? null, duration: input.duration ?? null,
|
|
76
|
-
poster_id: input.posterId ?? null, title: input.title ?? null, alt: input.alt ?? null,
|
|
77
|
-
caption: input.caption ?? null, credit: input.credit ?? null,
|
|
78
|
-
});
|
|
79
|
-
const up = await this.bucket().upload(row.path, input.bytes, { contentType: input.mime, upsert: false, cacheControl: String(MEDIA_CACHE_SECONDS) });
|
|
80
|
-
if (up.error) {
|
|
81
|
-
await this.db.from("assets").delete().eq("id", row.id);
|
|
82
|
-
this.fail(up.error.message);
|
|
83
|
-
}
|
|
84
|
-
return row;
|
|
85
|
-
}
|
|
86
|
-
async get(id) {
|
|
87
|
-
if (!UUID_RE.test(id))
|
|
88
|
-
return null;
|
|
89
|
-
const res = await this.db.from("assets").select(SELECT).eq("id", id).maybeSingle();
|
|
90
|
-
if (res.error)
|
|
91
|
-
this.fail(res.error.message);
|
|
92
|
-
return res.data ? this.toRecord(res.data) : null;
|
|
93
|
-
}
|
|
94
|
-
async getMany(ids) {
|
|
95
|
-
const wanted = ids.filter((id) => UUID_RE.test(id));
|
|
96
|
-
if (wanted.length === 0)
|
|
97
|
-
return {};
|
|
98
|
-
const res = await this.db.from("assets").select(SELECT).in("id", wanted).eq("status", "ready");
|
|
99
|
-
if (res.error)
|
|
100
|
-
this.fail(res.error.message);
|
|
101
|
-
const out = {};
|
|
102
|
-
for (const row of res.data)
|
|
103
|
-
out[row.id] = this.toRecord(row);
|
|
104
|
-
return out;
|
|
105
|
-
}
|
|
106
|
-
async list(query = {}) {
|
|
107
|
-
const limit = query.limit ?? PAGE_SIZE;
|
|
108
|
-
let q = this.db.from("assets").select(SELECT).eq("status", "ready").order("created_at", { ascending: false }).limit(limit + 1);
|
|
109
|
-
if (query.kind)
|
|
110
|
-
q = q.eq("kind", query.kind);
|
|
111
|
-
if (query.cursor)
|
|
112
|
-
q = q.lt("created_at", query.cursor);
|
|
113
|
-
if (query.search) {
|
|
114
|
-
// PostgREST's or() splits on commas; the pattern must not carry one.
|
|
115
|
-
const term = `%${query.search.replace(/[,%]/g, " ").trim()}%`;
|
|
116
|
-
q = q.or(`title.ilike.${term},filename.ilike.${term},alt.ilike.${term}`);
|
|
117
|
-
}
|
|
118
|
-
const res = await q;
|
|
119
|
-
if (res.error)
|
|
120
|
-
this.fail(res.error.message);
|
|
121
|
-
const rows = res.data;
|
|
122
|
-
const page = rows.slice(0, limit);
|
|
123
|
-
return {
|
|
124
|
-
items: page.map((r) => this.toRecord(r)),
|
|
125
|
-
nextCursor: rows.length > limit ? page[page.length - 1].created_at : null,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
async update(id, meta) {
|
|
129
|
-
if (!UUID_RE.test(id))
|
|
130
|
-
throw assetErrors.notFound(id);
|
|
131
|
-
const patch = { updated_at: new Date().toISOString() };
|
|
132
|
-
for (const key of ["title", "alt", "caption", "credit"])
|
|
133
|
-
if (meta[key] !== undefined)
|
|
134
|
-
patch[key] = meta[key];
|
|
135
|
-
const res = await this.db.from("assets").update(patch).eq("id", id).select(SELECT).maybeSingle();
|
|
136
|
-
if (res.error)
|
|
137
|
-
this.fail(res.error.message);
|
|
138
|
-
if (!res.data)
|
|
139
|
-
throw assetErrors.notFound(id);
|
|
140
|
-
return this.toRecord(res.data);
|
|
141
|
-
}
|
|
142
|
-
async delete(id) {
|
|
143
|
-
const row = await this.get(id);
|
|
144
|
-
if (!row)
|
|
145
|
-
return;
|
|
146
|
-
const usage = await this.db.from("refs").select("source_id").eq("target_collection", ASSET_COLLECTION).eq("target_id", id);
|
|
147
|
-
if (usage.error)
|
|
148
|
-
this.fail(usage.error.message);
|
|
149
|
-
if (usage.data.length > 0)
|
|
150
|
-
throw assetErrors.referenced(id, usage.data.length);
|
|
151
|
-
const paths = [row.path];
|
|
152
|
-
if (row.posterId) {
|
|
153
|
-
const poster = await this.get(row.posterId);
|
|
154
|
-
if (poster)
|
|
155
|
-
paths.push(poster.path);
|
|
156
|
-
}
|
|
157
|
-
// The row first (its poster_id reference goes with it), then the poster row, then the objects.
|
|
158
|
-
const gone = await this.db.from("assets").delete().eq("id", id);
|
|
159
|
-
if (gone.error)
|
|
160
|
-
this.fail(gone.error.message);
|
|
161
|
-
if (row.posterId) {
|
|
162
|
-
const posterGone = await this.db.from("assets").delete().eq("id", row.posterId);
|
|
163
|
-
if (posterGone.error)
|
|
164
|
-
this.fail(posterGone.error.message);
|
|
165
|
-
}
|
|
166
|
-
const removed = await this.bucket().remove(paths);
|
|
167
|
-
if (removed.error)
|
|
168
|
-
this.fail(removed.error.message);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import type { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
-
import type { CollectionSchema } from "./collections.ts";
|
|
3
|
-
import type { AddEntryLocaleOptions, CreateEntryOptions, EntryRecord, EntryStore, EntryStoreOptions, EntryScan, EntryUsage, EntryVersion, ListOptions, SnapshotQuery, SnapshotRow } from "./entry-store.ts";
|
|
4
|
-
import { type DraftToken } from "./draft-token.ts";
|
|
5
|
-
export declare class SupabaseEntryStore implements EntryStore {
|
|
6
|
-
private db;
|
|
7
|
-
private paths;
|
|
8
|
-
private locales;
|
|
9
|
-
private schemas;
|
|
10
|
-
private elements;
|
|
11
|
-
private spaceId?;
|
|
12
|
-
constructor(db: SupabaseClient, collections: CollectionSchema<any>[], options?: EntryStoreOptions);
|
|
13
|
-
private fail;
|
|
14
|
-
private schema;
|
|
15
|
-
/** The space this client acts in — the ONE function the policies and
|
|
16
|
-
* the insert trigger read (src/sql-space.ts): a key's claim in the
|
|
17
|
-
* cloud, the default space under the service role. Constant for the
|
|
18
|
-
* life of the client, so the PROMISE is cached and concurrent creates
|
|
19
|
-
* share one round trip; a failed lookup is not cached. */
|
|
20
|
-
private space;
|
|
21
|
-
private fetch;
|
|
22
|
-
private must;
|
|
23
|
-
private siblings;
|
|
24
|
-
private byIdMap;
|
|
25
|
-
private chain;
|
|
26
|
-
private subtree;
|
|
27
|
-
private versionFields;
|
|
28
|
-
private writePaths;
|
|
29
|
-
/** Every field set the site can render: each locale's live view, plus a
|
|
30
|
-
* published snapshot the draft has moved past (see entryRefEdges). */
|
|
31
|
-
private liveFieldSets;
|
|
32
|
-
private writeRefs;
|
|
33
|
-
/** The friendly pre-check per locale (spec 2026-09-06 §11); the paths
|
|
34
|
-
* primary key is the invariant. */
|
|
35
|
-
private assertSiblingSlug;
|
|
36
|
-
private assertParent;
|
|
37
|
-
private assertParentHasLocale;
|
|
38
|
-
private updateNode;
|
|
39
|
-
private insertLocale;
|
|
40
|
-
/** A touch writes the audit pair — `updated_at` and `updated_by` (spec 2026-09-13 history §2). */
|
|
41
|
-
private updateLocale;
|
|
42
|
-
/** The row's stale error, built from a fresh read: what a reload would get, and who wrote last. */
|
|
43
|
-
private stale;
|
|
44
|
-
/** `updateLocale` with the pointer as a filter (spec 2026-09-26 concurrency §3): the row is
|
|
45
|
-
* written only while `draft_version_id` still equals `guard` (null = still no pointer).
|
|
46
|
-
* `undefined` guard = unconditional. Resolves false when no row matched. */
|
|
47
|
-
private guardedUpdateLocale;
|
|
48
|
-
/** The row goes first (it is what makes the entry exist in the locale), then its versions. */
|
|
49
|
-
private deleteLocale;
|
|
50
|
-
/** The draft rule for every collection (spec 2026-09-14 §1), see MemoryEntryStore.recordVersion —
|
|
51
|
-
* guarded (spec 2026-09-26 concurrency §3) when the caller verified `row` against the token:
|
|
52
|
-
* the rewrite filters on saved_at, the first draft on the pointer. Returns the version row it
|
|
53
|
-
* created, or null when it rewrote in place, so a failed later step can undo it. */
|
|
54
|
-
private recordVersion;
|
|
55
|
-
/** See MemoryEntryStore.ensureLiveSnapshot: the snapshot of what is live, both pointers on it. */
|
|
56
|
-
private ensureLiveSnapshot;
|
|
57
|
-
create(collection: string, fields: Record<string, unknown>, options: CreateEntryOptions, by?: string): Promise<EntryRecord>;
|
|
58
|
-
get(collection: string, id: string): Promise<EntryRecord | null>;
|
|
59
|
-
list(collection: string, options?: ListOptions): Promise<EntryRecord[]>;
|
|
60
|
-
query(collection: string, q: SnapshotQuery): Promise<SnapshotRow[]>;
|
|
61
|
-
getMany(collection: string, ids: string[], locale: string, options?: {
|
|
62
|
-
status?: "published";
|
|
63
|
-
}): Promise<Record<string, Record<string, unknown>>>;
|
|
64
|
-
update(collection: string, id: string, locale: string, fields: Record<string, unknown>, by?: string, expected?: DraftToken | null, options?: {
|
|
65
|
-
redirect?: boolean;
|
|
66
|
-
}): Promise<EntryRecord>;
|
|
67
|
-
setStatus(collection: string, id: string, locale: string, status: "draft" | "published", by?: string, expected?: DraftToken | null): Promise<EntryRecord>;
|
|
68
|
-
discardDraft(collection: string, id: string, locale: string, by?: string, expected?: DraftToken | null): Promise<EntryRecord>;
|
|
69
|
-
addLocale(collection: string, id: string, locale: string, options: AddEntryLocaleOptions, by?: string): Promise<EntryRecord>;
|
|
70
|
-
removeLocale(collection: string, id: string, locale: string): Promise<EntryRecord>;
|
|
71
|
-
scanEntries(): Promise<EntryScan[]>;
|
|
72
|
-
listVersions(collection: string, id: string, locale: string): Promise<EntryVersion[]>;
|
|
73
|
-
restore(collection: string, id: string, locale: string, versionId: string, by?: string, expected?: DraftToken | null): Promise<EntryRecord>;
|
|
74
|
-
getVersion(collection: string, versionId: string): Promise<EntryVersion | null>;
|
|
75
|
-
move(collection: string, id: string, to: {
|
|
76
|
-
parentId: string | null;
|
|
77
|
-
index?: number;
|
|
78
|
-
}, options?: {
|
|
79
|
-
redirect?: boolean;
|
|
80
|
-
}): Promise<EntryRecord>;
|
|
81
|
-
delete(collection: string, id: string): Promise<void>;
|
|
82
|
-
resolvePath(locale: string, path: string): Promise<import("./path-index.ts").PathHit | null>;
|
|
83
|
-
pathsIn(collection: string, ids: string[], locale: string): Promise<Record<string, string>>;
|
|
84
|
-
pathsOf(collection: string, id: string): Promise<Record<string, string>>;
|
|
85
|
-
redirectsOf(collection: string, id: string): Promise<Record<string, string[]>>;
|
|
86
|
-
reorder(collection: string, orderedIds: string[]): Promise<void>;
|
|
87
|
-
incoming(targetId: string): Promise<{
|
|
88
|
-
sourceKind: string;
|
|
89
|
-
sourceId: string;
|
|
90
|
-
}[]>;
|
|
91
|
-
referencesTo(collection: string, id: string): Promise<EntryUsage[]>;
|
|
92
|
-
}
|