create-drobek-module 0.5.3 → 0.6.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/dist/index.js +1 -1
- package/package.json +1 -1
- package/template/README.md +1 -1
- package/template/src/index.ts +14 -0
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ export const TEMPLATE_DIR = fileURLToPath(new URL('../template', import.meta.url
|
|
|
23
23
|
const MODULE_NAME_RE = /^[a-z][a-z0-9]{1,30}$/;
|
|
24
24
|
const RESERVED = ['sdk', 'v1', 'drobek', 'internal'];
|
|
25
25
|
/** The modules drobek ships: a new module needs its own name (replacing one is an operator decision, docs/MODULES.md). */
|
|
26
|
-
const BUILT_IN = ['auth', 'email', 'forms', 'data', 'proxy', 'files'];
|
|
26
|
+
const BUILT_IN = ['auth', 'email', 'forms', 'data', 'proxy', 'files', 'sync'];
|
|
27
27
|
const PACKAGE_RE = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/;
|
|
28
28
|
/** Resolve `<name>` (a short name, `drobek-module-<x>` or a scoped package) to package, module and directory names. */
|
|
29
29
|
export function parseTarget(input, moduleOverride) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-drobek-module",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Scaffold a drobek platform module: npm create drobek-module@latest <name> — routes, SDK, a migration, SKILL.md, vitest + PGlite tests and the checkSkill gate.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
package/template/README.md
CHANGED
|
@@ -44,7 +44,7 @@ task selfhost:module:add -- {{package}}@0.1.0 # or the URL of a packed tarba
|
|
|
44
44
|
and add the module to `DROBEK_MODULES` in `.env.production`:
|
|
45
45
|
|
|
46
46
|
```sh
|
|
47
|
-
DROBEK_MODULES=auth,email,forms,data,proxy,files,{{entry}}
|
|
47
|
+
DROBEK_MODULES=auth,email,forms,data,proxy,files,sync,{{entry}}
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
Then restart drobek (see the self-hosting guide). The server refuses a module whose
|
package/template/src/index.ts
CHANGED
|
@@ -78,6 +78,20 @@ export default defineModule<Config>({
|
|
|
78
78
|
fix: 'Tell the user the list is full; the app owner can raise maxItems with configure_module.',
|
|
79
79
|
},
|
|
80
80
|
],
|
|
81
|
+
// Scheduled work (module contract 1.2 — set contract: '^1.2' when you use it): core runs a
|
|
82
|
+
// job on its interval, once across replicas; a throw is retried with backoff and an 'app'
|
|
83
|
+
// job's failure shows in that app's get_logs runtime. Test it with t.runJob('trim').
|
|
84
|
+
// jobs: [
|
|
85
|
+
// {
|
|
86
|
+
// name: 'trim',
|
|
87
|
+
// scope: 'app', // for each app that configured this module; omit for one server-wide run
|
|
88
|
+
// every: '1h', // or (config) => interval | null, read per app
|
|
89
|
+
// async run(ctx) {
|
|
90
|
+
// const extra = (await itemCount(ctx.db, ctx.app.id)) - ctx.config.maxItems;
|
|
91
|
+
// if (extra > 0) ctx.log.info('over maxItems', { extra });
|
|
92
|
+
// },
|
|
93
|
+
// },
|
|
94
|
+
// ],
|
|
81
95
|
routes(r) {
|
|
82
96
|
r.get('/items', { rule: 'public' }, async (_req, ctx) => {
|
|
83
97
|
const rows = await ctx.db.select().from(items).where(eq(items.appId, ctx.app.id)).orderBy(desc(items.id)).limit(100);
|