@rocapine/community 0.13.0 → 0.14.0
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
CHANGED
|
@@ -13,7 +13,7 @@ version. The binary is named `community`.
|
|
|
13
13
|
## `init`
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
npx @rocapine/community init [--modules core,push,polls,reaction,inbox,translation,images] [--project-url <url>] [--anon-key <key>] [--dir supabase]
|
|
16
|
+
npx @rocapine/community init [--modules core,push,polls,reaction,inbox,translation,images,streaks] [--project-url <url>] [--anon-key <key>] [--dir supabase]
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
Copies the migrations and Edge Functions for the requested modules into
|
|
@@ -21,10 +21,10 @@ Copies the migrations and Edge Functions for the requested modules into
|
|
|
21
21
|
relative to the current directory), and writes a `community-sdk.json`
|
|
22
22
|
manifest at the repo root recording what was installed.
|
|
23
23
|
|
|
24
|
-
- `--modules` — comma-separated (`core,push,polls,reaction,inbox,translation,images`). `core`
|
|
24
|
+
- `--modules` — comma-separated (`core,push,polls,reaction,inbox,translation,images,streaks`). `core`
|
|
25
25
|
is always implied even if omitted. Omit the flag entirely to install every
|
|
26
26
|
module. Regardless of the order you type them, modules are installed
|
|
27
|
-
`core → push → polls → reaction → inbox → translation → images` — this order is load-bearing:
|
|
27
|
+
`core → push → polls → reaction → inbox → translation → images → streaks` — this order is load-bearing:
|
|
28
28
|
the inbox module's reaction trigger is guarded at install time and must
|
|
29
29
|
find the reaction module's table already present, so reaction has to land
|
|
30
30
|
first. Requesting `inbox` without `reaction`, or `translation` without `polls`, prints a (non-fatal) warning (reactions missing from the inbox; poll labels left untranslated).
|
package/lib/index.js
CHANGED
|
@@ -60,7 +60,7 @@ program
|
|
|
60
60
|
program
|
|
61
61
|
.command("init")
|
|
62
62
|
.description("Copy the community backend into a Supabase project: migrations, Edge Functions, and a community-sdk.json manifest")
|
|
63
|
-
.option("--modules <modules>", "comma-separated module list (core,push,polls,reaction,inbox,translation,images) — core is always implied; defaults to all modules")
|
|
63
|
+
.option("--modules <modules>", "comma-separated module list (core,push,polls,reaction,inbox,translation,images,streaks) — core is always implied; defaults to all modules")
|
|
64
64
|
.option("--project-url <url>", "Supabase project URL, e.g. https://<ref>.supabase.co — optional, only fills in the printed settings seed statement")
|
|
65
65
|
.option("--anon-key <key>", "Supabase anon key — optional, only fills in the printed settings seed statement")
|
|
66
66
|
.option("--dir <dir>", "target Supabase directory, relative to the current directory", "supabase")
|
|
@@ -103,7 +103,7 @@ program
|
|
|
103
103
|
.command("adopt")
|
|
104
104
|
.description("Register an already-live community backend (e.g. an app that hand-rolled its own before this SDK existed) with community-sdk.json, without copying any files")
|
|
105
105
|
.requiredOption("--schema-version <n>", "the community-sdk schema version this app's live backend corresponds to")
|
|
106
|
-
.requiredOption("--modules <modules>", "comma-separated module list (core,push,polls,reaction,inbox,translation,images) — core is always implied")
|
|
106
|
+
.requiredOption("--modules <modules>", "comma-separated module list (core,push,polls,reaction,inbox,translation,images,streaks) — core is always implied")
|
|
107
107
|
.option("--dir <dir>", "Supabase directory this app would use, relative to the current directory", "supabase")
|
|
108
108
|
.action(async (opts) => {
|
|
109
109
|
try {
|
package/lib/install-shared.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Ruled install order (controller ruling, task 18): core -> push -> polls ->
|
|
3
|
-
* reaction -> inbox -> translation -> images. Reaction MUST land before inbox —
|
|
3
|
+
* reaction -> inbox -> translation -> images -> streaks. Reaction MUST land before inbox —
|
|
4
4
|
* inbox/001's reaction trigger is guarded with
|
|
5
5
|
* `to_regclass('public.post_reactions')` at install time and is never
|
|
6
6
|
* retroactively wired if the reaction module shows up later, so `reaction`
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* single source of truth for module names, order, and the function sets
|
|
11
11
|
* each module pulls in.
|
|
12
12
|
*/
|
|
13
|
-
export declare const MODULE_ORDER: readonly ["core", "push", "polls", "reaction", "inbox", "translation", "images"];
|
|
13
|
+
export declare const MODULE_ORDER: readonly ["core", "push", "polls", "reaction", "inbox", "translation", "images", "streaks"];
|
|
14
14
|
export type Module = (typeof MODULE_ORDER)[number];
|
|
15
15
|
export declare function functionsForModules(modules: readonly Module[]): string[];
|
|
16
16
|
/**
|
package/lib/install-shared.js
CHANGED
|
@@ -55,7 +55,7 @@ const fs = __importStar(require("node:fs"));
|
|
|
55
55
|
const path = __importStar(require("node:path"));
|
|
56
56
|
/**
|
|
57
57
|
* Ruled install order (controller ruling, task 18): core -> push -> polls ->
|
|
58
|
-
* reaction -> inbox -> translation -> images. Reaction MUST land before inbox —
|
|
58
|
+
* reaction -> inbox -> translation -> images -> streaks. Reaction MUST land before inbox —
|
|
59
59
|
* inbox/001's reaction trigger is guarded with
|
|
60
60
|
* `to_regclass('public.post_reactions')` at install time and is never
|
|
61
61
|
* retroactively wired if the reaction module shows up later, so `reaction`
|
|
@@ -73,6 +73,7 @@ exports.MODULE_ORDER = [
|
|
|
73
73
|
"inbox",
|
|
74
74
|
"translation",
|
|
75
75
|
"images",
|
|
76
|
+
"streaks",
|
|
76
77
|
];
|
|
77
78
|
const ALWAYS_FUNCTIONS = [
|
|
78
79
|
"moderate-one",
|
package/package.json
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
-- community-sdk streaks/001_streaks.sql (schema v1)
|
|
2
|
+
-- Streaks module: the host app's streak on each profile (a sobriety, habit or
|
|
3
|
+
-- practice streak), shown as a pill on posts and on the profile.
|
|
4
|
+
-- The client writes the raw values (when the current streak started, the best
|
|
5
|
+
-- streak in days) and two visibility toggles. Readers only ever see the
|
|
6
|
+
-- generated `visible_*` columns, null while the owner hides that value, so a
|
|
7
|
+
-- hidden streak never leaves the database. Fully idempotent.
|
|
8
|
+
|
|
9
|
+
alter table public.profiles
|
|
10
|
+
add column if not exists streak_started_at timestamptz,
|
|
11
|
+
add column if not exists best_streak_days int check (best_streak_days >= 0),
|
|
12
|
+
add column if not exists show_streak boolean not null default true,
|
|
13
|
+
add column if not exists show_best_streak boolean not null default true;
|
|
14
|
+
|
|
15
|
+
alter table public.profiles
|
|
16
|
+
add column if not exists visible_streak_started_at timestamptz
|
|
17
|
+
generated always as (case when show_streak then streak_started_at end) stored,
|
|
18
|
+
add column if not exists visible_best_streak_days int
|
|
19
|
+
generated always as (case when show_best_streak then best_streak_days end) stored;
|
|
20
|
+
|
|
21
|
+
-- Owners write their own row (RLS "update own profile"); the raw values stay
|
|
22
|
+
-- unreadable, everyone reads the visible ones and the toggles.
|
|
23
|
+
grant update (streak_started_at, best_streak_days, show_streak, show_best_streak)
|
|
24
|
+
on table public.profiles to authenticated;
|
|
25
|
+
grant select (visible_streak_started_at, visible_best_streak_days, show_streak, show_best_streak)
|
|
26
|
+
on public.profiles to anon, authenticated;
|