smoodly 0.0.26 → 0.0.28
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 +70 -6
- package/dist/admin/client-ops.js +1 -0
- package/dist/admin/editor/EditorView.js +5 -2
- package/dist/admin/editor/PageInspector.d.ts +4 -1
- package/dist/admin/editor/PageInspector.js +2 -2
- package/dist/admin/editor/PageSettings.d.ts +4 -1
- package/dist/admin/editor/PageSettings.js +16 -8
- package/dist/admin/ops-impl.js +86 -7
- package/dist/admin/ops.d.ts +40 -1
- package/dist/admin/redirect-path.d.ts +6 -0
- package/dist/admin/redirect-path.js +33 -0
- package/dist/admin/shell/AddRedirectModal.d.ts +11 -0
- package/dist/admin/shell/AddRedirectModal.js +29 -0
- package/dist/admin/shell/AdminApp.js +24 -10
- package/dist/admin/shell/EntryForm.js +14 -6
- package/dist/admin/shell/GlobalForm.js +1 -1
- package/dist/admin/shell/IconRail.d.ts +1 -1
- package/dist/admin/shell/IconRail.js +3 -2
- package/dist/admin/shell/PagesList.js +6 -4
- package/dist/admin/shell/RedirectsPage.d.ts +11 -0
- package/dist/admin/shell/RedirectsPage.js +75 -0
- package/dist/admin/shell/SettingsView.d.ts +4 -2
- package/dist/admin/shell/SettingsView.js +18 -14
- package/dist/admin/shell/live-url.d.ts +10 -2
- package/dist/admin/shell/live-url.js +9 -4
- package/dist/admin/shell/members-list.js +1 -1
- package/dist/admin/shell/presence-realtime.d.ts +1 -1
- package/dist/admin/shell/presence-realtime.js +19 -9
- package/dist/admin/shell/presence.d.ts +18 -0
- package/dist/admin/shell/presence.js +13 -0
- package/dist/admin/shell/redirects-list.d.ts +12 -0
- package/dist/admin/shell/redirects-list.js +15 -0
- package/dist/admin/shell/settings.d.ts +12 -3
- package/dist/admin/shell/settings.js +13 -9
- package/dist/admin/ui/ConfirmDialog.d.ts +1 -1
- package/dist/admin/ui/ConfirmDialog.js +4 -3
- package/dist/admin/ui/confirm.d.ts +13 -2
- package/dist/admin/ui/confirm.js +9 -5
- package/dist/admin/ui/primitives.d.ts +4 -1
- package/dist/admin/ui/primitives.js +4 -2
- package/dist/admin/ui/theme.js +3 -0
- package/dist/entry-store.d.ts +18 -6
- package/dist/entry-store.js +13 -8
- package/dist/next/page-renderer.js +28 -9
- package/dist/path-index.d.ts +28 -4
- package/dist/path-index.js +37 -4
- package/dist/paths.d.ts +16 -0
- package/dist/paths.js +9 -0
- package/dist/schema-version.d.ts +1 -1
- package/dist/schema-version.js +1 -1
- package/dist/site.d.ts +4 -1
- package/dist/site.js +3 -1
- package/dist/sql-space.d.ts +6 -0
- package/dist/sql-space.js +37 -10
- package/dist/sql.js +24 -5
- package/dist/store.d.ts +30 -5
- package/dist/store.js +24 -8
- package/dist/supabase-entry-store.d.ts +7 -2
- package/dist/supabase-entry-store.js +12 -8
- package/dist/supabase-path-index.d.ts +10 -3
- package/dist/supabase-path-index.js +50 -17
- package/dist/supabase-store.d.ts +13 -2
- package/dist/supabase-store.js +15 -8
- package/migrations/20260926140000_smoodly_v3.sql +38 -0
- package/migrations/20260926150000_smoodly_v4.sql +41 -0
- package/package.json +1 -1
package/dist/supabase-store.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SupabaseClient } from "@supabase/supabase-js";
|
|
2
2
|
import { type AddLocaleOptions, type CreatePageInput, type PageRecord, type PageStore, type PageStoreOptions, type PageVersion } from "./store.ts";
|
|
3
3
|
import type { PageTree } from "./render.tsx";
|
|
4
|
+
import type { PathRow } from "./path-index.ts";
|
|
4
5
|
import { type DraftToken } from "./draft-token.ts";
|
|
5
6
|
import { type PathTarget } from "./paths.ts";
|
|
6
7
|
export declare class SupabasePageStore implements PageStore {
|
|
@@ -60,19 +61,29 @@ export declare class SupabasePageStore implements PageStore {
|
|
|
60
61
|
listPages(): Promise<PageRecord[]>;
|
|
61
62
|
/** The site's one warning per process (spec 2026-09-26 §5): fired by the first locate, never blocking. */
|
|
62
63
|
private schemaChecked;
|
|
63
|
-
resolvePath(locale: string, path: string): Promise<
|
|
64
|
+
resolvePath(locale: string, path: string): Promise<import("./path-index.ts").PathHit | null>;
|
|
64
65
|
schemaVersion(): Promise<number | null>;
|
|
65
66
|
pathsOf(id: string): Promise<{}>;
|
|
67
|
+
targetPaths(target: PathTarget): Promise<Record<string, string>>;
|
|
68
|
+
redirectsOf(id: string): Promise<Record<string, string[]>>;
|
|
69
|
+
listLive(locale: string): Promise<PathRow[]>;
|
|
70
|
+
listRedirects(locale: string): Promise<PathRow[]>;
|
|
71
|
+
addRedirect(row: PathRow): Promise<void>;
|
|
72
|
+
removeRedirect(locale: string, path: string): Promise<void>;
|
|
66
73
|
addLocale(id: string, locale: string, options: AddLocaleOptions, by?: string): Promise<PageRecord>;
|
|
67
74
|
removeLocale(id: string, locale: string): Promise<PageRecord>;
|
|
68
75
|
rename(id: string, patch: {
|
|
69
76
|
locale: string;
|
|
70
77
|
slug?: string;
|
|
71
78
|
title?: string;
|
|
72
|
-
}, by?: string
|
|
79
|
+
}, by?: string, options?: {
|
|
80
|
+
redirect?: boolean;
|
|
81
|
+
}): Promise<PageRecord>;
|
|
73
82
|
move(id: string, to: {
|
|
74
83
|
parentId: string | null;
|
|
75
84
|
index?: number;
|
|
85
|
+
}, options?: {
|
|
86
|
+
redirect?: boolean;
|
|
76
87
|
}): Promise<PageRecord>;
|
|
77
88
|
setTemplate(id: string, template: string, by?: string): Promise<PageRecord>;
|
|
78
89
|
saveDraft(id: string, locale: string, tree: PageTree, by?: string, expected?: DraftToken | null): Promise<PageVersion>;
|
package/dist/supabase-store.js
CHANGED
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
import { assertPublishable, assertSupportedLocale, localeRow, pageErrors, pageRefEdges, pathOptions, refSections, } from "./store.js";
|
|
10
10
|
import { SupabasePathIndex } from "./supabase-path-index.js";
|
|
11
11
|
import { SCHEMA_VERSION_KEY, schemaBehind, schemaBehindMessage } from "./schema-version.js";
|
|
12
|
+
import { groupRedirects } from "./store.js";
|
|
12
13
|
import { assertFresh, draftToken, StaleDraftError } from "./draft-token.js";
|
|
13
|
-
import { assertDepth, assertSegment, isHomeNode, pagePathRows } from "./paths.js";
|
|
14
|
+
import { assertDepth, assertSegment, isHomeNode, pagePathRows, rewriteTargets } from "./paths.js";
|
|
14
15
|
const SELECT = "*, page_locales(*, draft:page_versions!page_locales_draft_version_fkey(saved_at))";
|
|
15
16
|
const UNIQUE_VIOLATION = "23505";
|
|
16
17
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
@@ -121,11 +122,11 @@ export class SupabasePageStore {
|
|
|
121
122
|
}
|
|
122
123
|
/** Rewrite path rows for a subtree: ancestors are loaded once so the
|
|
123
124
|
* chain lookup is a map, then ONE RPC replaces every target's rows. */
|
|
124
|
-
async writePaths(top) {
|
|
125
|
+
async writePaths(top, redirect = true) {
|
|
125
126
|
const ancestors = await this.chain(top);
|
|
126
127
|
const nodes = await this.subtree(top);
|
|
127
128
|
const byId = new Map([...ancestors, ...nodes].map((n) => [n.id, n]));
|
|
128
|
-
await this.paths.rewrite(
|
|
129
|
+
await this.paths.rewrite(rewriteTargets("page", nodes, redirect), pagePathRows(nodes, (id) => byId.get(id), this.opts));
|
|
129
130
|
}
|
|
130
131
|
/** `touch` defaults to true (the normal edit path bumps updated_at).
|
|
131
132
|
* A rollback restoring prior column values passes `{ touch: false }`,
|
|
@@ -358,6 +359,12 @@ export class SupabasePageStore {
|
|
|
358
359
|
pathsOf(id) {
|
|
359
360
|
return UUID_RE.test(id) ? this.paths.pathsOf({ kind: "page", id }) : Promise.resolve({});
|
|
360
361
|
}
|
|
362
|
+
targetPaths(target) { return this.paths.pathsOf(target); }
|
|
363
|
+
async redirectsOf(id) { return UUID_RE.test(id) ? groupRedirects(await this.paths.redirectsOf({ kind: "page", id })) : {}; }
|
|
364
|
+
listLive(locale) { return this.paths.listLive(locale); }
|
|
365
|
+
listRedirects(locale) { return this.paths.listRedirects(locale); }
|
|
366
|
+
addRedirect(row) { return this.paths.addRedirect(row); }
|
|
367
|
+
removeRedirect(locale, path) { return this.paths.removeRedirect(locale, path); }
|
|
361
368
|
async addLocale(id, locale, options, by) {
|
|
362
369
|
assertSupportedLocale(locale, this.opts.locales);
|
|
363
370
|
const page = await this.must(id);
|
|
@@ -403,11 +410,11 @@ export class SupabasePageStore {
|
|
|
403
410
|
// content — until the next write of this node fixes it.
|
|
404
411
|
await this.deleteLocale(id, locale);
|
|
405
412
|
const remaining = await this.must(id);
|
|
406
|
-
await this.writePaths(remaining);
|
|
413
|
+
await this.writePaths(remaining, false);
|
|
407
414
|
await this.writeRefs(remaining);
|
|
408
415
|
return remaining;
|
|
409
416
|
}
|
|
410
|
-
async rename(id, patch, by) {
|
|
417
|
+
async rename(id, patch, by, options) {
|
|
411
418
|
const page = await this.must(id);
|
|
412
419
|
const row = localeRow(page, patch.locale);
|
|
413
420
|
if (patch.slug !== undefined)
|
|
@@ -431,7 +438,7 @@ export class SupabasePageStore {
|
|
|
431
438
|
columns.title = patch.title;
|
|
432
439
|
const renamed = await this.updateLocale(id, patch.locale, columns, { by });
|
|
433
440
|
try {
|
|
434
|
-
await this.writePaths(renamed);
|
|
441
|
+
await this.writePaths(renamed, options?.redirect ?? true);
|
|
435
442
|
}
|
|
436
443
|
catch (e) {
|
|
437
444
|
// The audit pair goes back too: a rejected rename is not an edit.
|
|
@@ -440,7 +447,7 @@ export class SupabasePageStore {
|
|
|
440
447
|
}
|
|
441
448
|
return renamed;
|
|
442
449
|
}
|
|
443
|
-
async move(id, to) {
|
|
450
|
+
async move(id, to, options) {
|
|
444
451
|
const page = await this.must(id);
|
|
445
452
|
const subtree = await this.subtree(page);
|
|
446
453
|
if (to.parentId !== null) {
|
|
@@ -485,7 +492,7 @@ export class SupabasePageStore {
|
|
|
485
492
|
ordered.splice(index, 0, id);
|
|
486
493
|
try {
|
|
487
494
|
await this.reorder(ordered);
|
|
488
|
-
await this.writePaths(moved);
|
|
495
|
+
await this.writePaths(moved, options?.redirect ?? true);
|
|
489
496
|
}
|
|
490
497
|
catch (e) {
|
|
491
498
|
await this.updateNode(id, { parent_id: page.parentId, sort: page.sort }, { touch: false });
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
-- Smoodly core schema, version 3 (docs/superpowers/specs/2026-09-26-security-pass-design.md).
|
|
2
|
+
-- Shipped in the smoodly package; `npx smoodly migrate` copies it into supabase/migrations/.
|
|
3
|
+
-- Never edit a published file: the next change is the next file.
|
|
4
|
+
-- The delta over version 2: the presence channel admits a signed-in
|
|
5
|
+
-- member of the topic's space (a definer lookup in members by the session
|
|
6
|
+
-- token's user), the five unpinned functions get a search_path, and the
|
|
7
|
+
-- three mutation RPCs are no longer executable by anon or public.
|
|
8
|
+
|
|
9
|
+
set client_min_messages = warning;
|
|
10
|
+
|
|
11
|
+
create or replace function "smoodly_presence_member"() returns boolean
|
|
12
|
+
language sql stable security definer set search_path = public as $$
|
|
13
|
+
select exists (select 1 from "members" m
|
|
14
|
+
where m."user_id" = auth.uid()
|
|
15
|
+
and realtime.topic() = 'space:' || m."space_id"::text);
|
|
16
|
+
$$;
|
|
17
|
+
|
|
18
|
+
drop policy if exists "smoodly_presence_read" on "realtime"."messages";
|
|
19
|
+
create policy "smoodly_presence_read" on "realtime"."messages" for select
|
|
20
|
+
using ((select public."smoodly_presence_member"()));
|
|
21
|
+
|
|
22
|
+
drop policy if exists "smoodly_presence_write" on "realtime"."messages";
|
|
23
|
+
create policy "smoodly_presence_write" on "realtime"."messages" for insert
|
|
24
|
+
with check ((select public."smoodly_presence_member"()));
|
|
25
|
+
|
|
26
|
+
alter function "smoodly_current_space"() set search_path = '';
|
|
27
|
+
alter function "smoodly_key_kind"() set search_path = '';
|
|
28
|
+
alter function "smoodly_set_space"() set search_path = '';
|
|
29
|
+
alter function "smoodly_reorder"(text, uuid[]) set search_path = public;
|
|
30
|
+
alter function "smoodly_reorder_pages"(uuid[]) set search_path = public;
|
|
31
|
+
alter function "smoodly_rewrite_paths"(jsonb, jsonb) set search_path = public;
|
|
32
|
+
|
|
33
|
+
revoke execute on function "smoodly_reorder"(text, uuid[]) from public, anon;
|
|
34
|
+
revoke execute on function "smoodly_reorder_pages"(uuid[]) from public, anon;
|
|
35
|
+
revoke execute on function "smoodly_rewrite_paths"(jsonb, jsonb) from public, anon;
|
|
36
|
+
|
|
37
|
+
insert into "smoodly_meta" ("key", "value") values ('schema_version', '3')
|
|
38
|
+
on conflict ("key") do update set "value" = excluded."value";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
-- Smoodly core schema, version 4 (docs/superpowers/specs/2026-09-26-redirects-design.md).
|
|
2
|
+
-- Shipped in the smoodly package; `npx smoodly migrate` copies it into supabase/migrations/.
|
|
3
|
+
-- Never edit a published file: the next change is the next file.
|
|
4
|
+
-- The delta over version 3: a `redirect` flag on the paths index — a row
|
|
5
|
+
-- with it set is an old address of its target — and the rewrite function
|
|
6
|
+
-- keeps the published old rows as redirects when a target names their
|
|
7
|
+
-- locales. The read policy is unchanged: a redirect row is visible when
|
|
8
|
+
-- its target is published in that locale.
|
|
9
|
+
|
|
10
|
+
set client_min_messages = warning;
|
|
11
|
+
|
|
12
|
+
alter table "paths" add column if not exists "redirect" boolean not null default false;
|
|
13
|
+
|
|
14
|
+
create or replace function "smoodly_rewrite_paths"(p_targets jsonb, p_rows jsonb) returns void language sql set search_path = public as $$
|
|
15
|
+
delete from "paths" p
|
|
16
|
+
using jsonb_to_recordset(p_rows) as r(locale text, path text, kind text, id uuid)
|
|
17
|
+
where p."redirect" and p."locale" = r.locale and p."path" = r.path
|
|
18
|
+
and p."space_id" = "smoodly_current_space"();
|
|
19
|
+
update "paths" p set "redirect" = true
|
|
20
|
+
from jsonb_to_recordset(p_targets) as t(kind text, id uuid, redirect_locales text[])
|
|
21
|
+
where not p."redirect" and p."kind" = t.kind and p."target_id" = t.id
|
|
22
|
+
and p."locale" = any (coalesce(t.redirect_locales, '{}'::text[]))
|
|
23
|
+
and not exists (select 1 from jsonb_to_recordset(p_rows) as r(locale text, path text, kind text, id uuid)
|
|
24
|
+
where r.locale = p."locale" and r.path = p."path")
|
|
25
|
+
and p."space_id" = "smoodly_current_space"();
|
|
26
|
+
delete from "paths" p
|
|
27
|
+
using jsonb_to_recordset(p_targets) as t(kind text, id uuid, redirect_locales text[])
|
|
28
|
+
where p."kind" = t.kind and p."target_id" = t.id
|
|
29
|
+
and (not p."redirect" or not exists (select 1 from jsonb_to_recordset(p_rows) as r(locale text, path text, kind text, id uuid)
|
|
30
|
+
where r.kind = p."kind" and r.id = p."target_id" and r.locale = p."locale"))
|
|
31
|
+
and p."space_id" = "smoodly_current_space"();
|
|
32
|
+
insert into "paths" ("locale", "path", "kind", "target_id")
|
|
33
|
+
select r.locale, r.path, r.kind, r.id
|
|
34
|
+
from jsonb_to_recordset(p_rows) as r(locale text, path text, kind text, id uuid);
|
|
35
|
+
$$;
|
|
36
|
+
|
|
37
|
+
alter function "smoodly_rewrite_paths"(jsonb, jsonb) set search_path = public;
|
|
38
|
+
revoke execute on function "smoodly_rewrite_paths"(jsonb, jsonb) from public, anon;
|
|
39
|
+
|
|
40
|
+
insert into "smoodly_meta" ("key", "value") values ('schema_version', '4')
|
|
41
|
+
on conflict ("key") do update set "value" = excluded."value";
|
package/package.json
CHANGED