@rocapine/community 0.3.2 → 0.4.1
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 +4 -4
- package/lib/index.js +2 -2
- package/package.json +1 -1
- package/templates/functions/_shared/translation.ts +9 -1
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] [--project-url <url>] [--anon-key <key>] [--dir supabase]
|
|
16
|
+
npx @rocapine/community init [--modules core,push,polls,reaction,inbox,translation] [--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,13 +21,13 @@ 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`). `core`
|
|
24
|
+
- `--modules` — comma-separated (`core,push,polls,reaction,inbox,translation`). `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` — this order is load-bearing:
|
|
27
|
+
`core → push → polls → reaction → inbox → translation` — 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
|
-
first. Requesting `inbox` without `reaction` prints a (non-fatal) warning.
|
|
30
|
+
first. Requesting `inbox` without `reaction`, or `translation` without `polls`, prints a (non-fatal) warning (reactions missing from the inbox; poll labels left untranslated).
|
|
31
31
|
- `--project-url` / `--anon-key` — needed only if a migration in the
|
|
32
32
|
selected modules carries a placeholder (see "Placeholder guard" below).
|
|
33
33
|
If omitted, the CLI tries to read the project URL from
|
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) — core is always implied; defaults to all modules")
|
|
63
|
+
.option("--modules <modules>", "comma-separated module list (core,push,polls,reaction,inbox,translation) — core is always implied; defaults to all modules")
|
|
64
64
|
.option("--project-url <url>", "Supabase project URL, e.g. https://<ref>.supabase.co")
|
|
65
65
|
.option("--anon-key <key>", "Supabase anon key")
|
|
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) — core is always implied")
|
|
106
|
+
.requiredOption("--modules <modules>", "comma-separated module list (core,push,polls,reaction,inbox,translation) — 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/package.json
CHANGED
|
@@ -88,6 +88,14 @@ export function parseTranslationResponse(
|
|
|
88
88
|
return { sourceLocale, translations: out };
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
/** OpenAI request timeout: output grows with text length × target count, so a
|
|
92
|
+
* flat limit fails every long post (measured on Eve's Rhythm: 7 locales of a
|
|
93
|
+
* ~1,500-character post take over 20 s). 20 s base plus 5 ms per character per
|
|
94
|
+
* target, capped at 90 s (inside the edge-function wall clock). */
|
|
95
|
+
export function translationTimeoutMs(contentLength: number, targetCount: number): number {
|
|
96
|
+
return Math.min(90_000, 20_000 + 5 * contentLength * Math.max(1, targetCount));
|
|
97
|
+
}
|
|
98
|
+
|
|
91
99
|
/** One OpenAI call. Returns null on any failure (caller writes nothing). */
|
|
92
100
|
export async function translateItem(input: {
|
|
93
101
|
content: string;
|
|
@@ -155,7 +163,7 @@ export async function translateItem(input: {
|
|
|
155
163
|
// effort=minimal shows up as sweep failures in Slack.
|
|
156
164
|
...(/^gpt-5/.test(TRANSLATION_MODEL) ? { reasoning: { effort: "minimal" } } : {}),
|
|
157
165
|
}),
|
|
158
|
-
signal: AbortSignal.timeout(
|
|
166
|
+
signal: AbortSignal.timeout(translationTimeoutMs(input.content.length, input.targets.length)),
|
|
159
167
|
});
|
|
160
168
|
if (!res.ok) {
|
|
161
169
|
console.error("translation api error", res.status, (await res.text()).slice(0, 300));
|