@velocity-astro/cms-astro 0.0.0-stage → 0.1.0-beta.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/LICENSE +21 -0
- package/README.md +12 -2
- package/bin/velocity-cms.mjs +6 -0
- package/dist/admin-files.d.ts +21 -0
- package/dist/admin-files.d.ts.map +1 -0
- package/dist/admin-files.js +77 -0
- package/dist/admin-files.js.map +1 -0
- package/dist/cli.d.ts +9 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +75 -0
- package/dist/cli.js.map +1 -0
- package/dist/connection.d.ts +25 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +62 -0
- package/dist/connection.js.map +1 -0
- package/dist/editor.d.ts +65 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +186 -0
- package/dist/editor.js.map +1 -0
- package/dist/entry-page.d.ts +37 -0
- package/dist/entry-page.d.ts.map +1 -0
- package/dist/entry-page.js +56 -0
- package/dist/entry-page.js.map +1 -0
- package/dist/form-post.d.ts +106 -0
- package/dist/form-post.d.ts.map +1 -0
- package/dist/form-post.js +291 -0
- package/dist/form-post.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +33 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +125 -0
- package/dist/init.js.map +1 -0
- package/dist/integration.d.ts +63 -0
- package/dist/integration.d.ts.map +1 -0
- package/dist/integration.js +129 -0
- package/dist/integration.js.map +1 -0
- package/dist/link.d.ts +32 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +76 -0
- package/dist/link.js.map +1 -0
- package/dist/live-loader.d.ts +40 -0
- package/dist/live-loader.d.ts.map +1 -0
- package/dist/live-loader.js +92 -0
- package/dist/live-loader.js.map +1 -0
- package/dist/live-pages.d.ts +69 -0
- package/dist/live-pages.d.ts.map +1 -0
- package/dist/live-pages.js +94 -0
- package/dist/live-pages.js.map +1 -0
- package/dist/loader.d.ts +22 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +62 -0
- package/dist/loader.js.map +1 -0
- package/dist/media-store.d.ts +46 -0
- package/dist/media-store.d.ts.map +1 -0
- package/dist/media-store.js +154 -0
- package/dist/media-store.js.map +1 -0
- package/dist/menu.d.ts +51 -0
- package/dist/menu.d.ts.map +1 -0
- package/dist/menu.js +81 -0
- package/dist/menu.js.map +1 -0
- package/dist/page-head.d.ts +23 -0
- package/dist/page-head.d.ts.map +1 -0
- package/dist/page-head.js +66 -0
- package/dist/page-head.js.map +1 -0
- package/dist/preview.d.ts +60 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +126 -0
- package/dist/preview.js.map +1 -0
- package/dist/resend-mailer.d.ts +46 -0
- package/dist/resend-mailer.d.ts.map +1 -0
- package/dist/resend-mailer.js +95 -0
- package/dist/resend-mailer.js.map +1 -0
- package/dist/secret.d.ts +8 -0
- package/dist/secret.d.ts.map +1 -0
- package/dist/secret.js +16 -0
- package/dist/secret.js.map +1 -0
- package/dist/site-editor.d.ts +41 -0
- package/dist/site-editor.d.ts.map +1 -0
- package/dist/site-editor.js +110 -0
- package/dist/site-editor.js.map +1 -0
- package/dist/site-forms.d.ts +43 -0
- package/dist/site-forms.d.ts.map +1 -0
- package/dist/site-forms.js +82 -0
- package/dist/site-forms.js.map +1 -0
- package/dist/site-images.d.ts +17 -0
- package/dist/site-images.d.ts.map +1 -0
- package/dist/site-images.js +22 -0
- package/dist/site-images.js.map +1 -0
- package/dist/site-media.d.ts +18 -0
- package/dist/site-media.d.ts.map +1 -0
- package/dist/site-media.js +43 -0
- package/dist/site-media.js.map +1 -0
- package/dist/site-plugins.d.ts +10 -0
- package/dist/site-plugins.d.ts.map +1 -0
- package/dist/site-plugins.js +23 -0
- package/dist/site-plugins.js.map +1 -0
- package/dist/site-search.d.ts +12 -0
- package/dist/site-search.d.ts.map +1 -0
- package/dist/site-search.js +79 -0
- package/dist/site-search.js.map +1 -0
- package/package.json +53 -3
- package/routes/admin.ts +10 -0
- package/routes/api.ts +15 -0
- package/routes/auth.ts +10 -0
- package/routes/due.ts +12 -0
- package/routes/editor.ts +48 -0
- package/routes/form-client.js.ts +105 -0
- package/routes/media.ts +10 -0
- package/routes/pages.ts +13 -0
- package/routes/plugins.ts +10 -0
- package/routes/preview-client.js.ts +63 -0
- package/routes/published.ts +29 -0
- package/routes/schedule.ts +20 -0
- package/routes/search-client.js.ts +33 -0
- package/routes/search.json.ts +10 -0
- package/routes/share-image.png.ts +33 -0
- package/routes/sitemap-live.xml.ts +13 -0
- package/routes/submit.ts +22 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Southwell Media
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @velocity-astro/cms-astro
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Astro side of Velocity CMS: a live loader for pages rendered on demand, a Content Layer loader for static builds, and the integration.
|
|
4
|
+
|
|
5
|
+
Part of [Velocity CMS](https://github.com/Velocity-Astro/velocity-cms), a content management system for Astro sites. A site installs `@velocity-astro/cms-astro`, which brings the rest:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npx velocity-cms init
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Docs: https://docs.deployvelocity.com/cms/
|
|
12
|
+
|
|
13
|
+
MIT
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** What the editor needs to know about the site, written into its page. */
|
|
2
|
+
export interface EditorPageConfig {
|
|
3
|
+
readonly siteName: string;
|
|
4
|
+
readonly adminPath: string;
|
|
5
|
+
readonly apiPath: string;
|
|
6
|
+
readonly authPath: string;
|
|
7
|
+
}
|
|
8
|
+
/** Where `@velocity-astro/cms-admin` keeps the editor it built. */
|
|
9
|
+
export declare const builtEditorDirectory: () => string;
|
|
10
|
+
/**
|
|
11
|
+
* Serves the editor: a page and the files it loads, built ahead of time by `cms-admin`. The
|
|
12
|
+
* files are read once. Only a file that was there at the start can ever be sent, whatever
|
|
13
|
+
* address is asked for.
|
|
14
|
+
*/
|
|
15
|
+
export declare class AdminFiles {
|
|
16
|
+
#private;
|
|
17
|
+
constructor(directory: string, config: EditorPageConfig);
|
|
18
|
+
/** Answers a request for anything under the editor's address. */
|
|
19
|
+
respond(request: Request): Response;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=admin-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-files.d.ts","sourceRoot":"","sources":["../src/admin-files.ts"],"names":[],"mappings":"AAIA,2EAA2E;AAC3E,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAkCD,mEAAmE;AACnE,eAAO,MAAM,oBAAoB,QAAO,MAAsB,CAAC;AAE/D;;;;GAIG;AACH,qBAAa,UAAU;;gBAKT,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB;IAkBvD,iEAAiE;IACjE,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ;CAkBpC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { appDirectory } from '@velocity-astro/cms-admin/app-directory';
|
|
4
|
+
const TYPES = {
|
|
5
|
+
'.js': 'text/javascript; charset=utf-8',
|
|
6
|
+
'.css': 'text/css; charset=utf-8',
|
|
7
|
+
'.svg': 'image/svg+xml',
|
|
8
|
+
'.png': 'image/png',
|
|
9
|
+
'.woff2': 'font/woff2',
|
|
10
|
+
'.json': 'application/json; charset=utf-8',
|
|
11
|
+
};
|
|
12
|
+
/** Where the editor's page marks the place for its settings. */
|
|
13
|
+
const MARKER = '<!--velocity-cms-->';
|
|
14
|
+
/**
|
|
15
|
+
* The page may load scripts and styles only from the site itself, and may not be put in a frame.
|
|
16
|
+
* Styles written on elements are allowed because the editor's floating panels place themselves
|
|
17
|
+
* that way; nothing here can run a script.
|
|
18
|
+
*/
|
|
19
|
+
const PAGE_HEADERS = {
|
|
20
|
+
'content-type': 'text/html; charset=utf-8',
|
|
21
|
+
'cache-control': 'no-store',
|
|
22
|
+
'content-security-policy': "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data:; frame-ancestors 'none'; base-uri 'self'; form-action 'self'",
|
|
23
|
+
'x-frame-options': 'DENY',
|
|
24
|
+
'x-content-type-options': 'nosniff',
|
|
25
|
+
'referrer-policy': 'same-origin',
|
|
26
|
+
};
|
|
27
|
+
/** Where `@velocity-astro/cms-admin` keeps the editor it built. */
|
|
28
|
+
export const builtEditorDirectory = () => appDirectory;
|
|
29
|
+
/**
|
|
30
|
+
* Serves the editor: a page and the files it loads, built ahead of time by `cms-admin`. The
|
|
31
|
+
* files are read once. Only a file that was there at the start can ever be sent, whatever
|
|
32
|
+
* address is asked for.
|
|
33
|
+
*/
|
|
34
|
+
export class AdminFiles {
|
|
35
|
+
#files = new Map();
|
|
36
|
+
#page;
|
|
37
|
+
#adminPath;
|
|
38
|
+
constructor(directory, config) {
|
|
39
|
+
const index = path.join(directory, 'index.html');
|
|
40
|
+
if (!fs.existsSync(index)) {
|
|
41
|
+
throw new Error(`The editor has not been built: ${index} is missing. Run \`pnpm --filter @velocity-astro/cms-admin build:app\`.`);
|
|
42
|
+
}
|
|
43
|
+
for (const name of fs.readdirSync(directory, { recursive: true }).map(String)) {
|
|
44
|
+
const file = path.join(directory, name);
|
|
45
|
+
const type = TYPES[path.extname(name)];
|
|
46
|
+
if (type && fs.statSync(file).isFile())
|
|
47
|
+
this.#files.set(name.replaceAll('\\', '/'), { body: fs.readFileSync(file), type });
|
|
48
|
+
}
|
|
49
|
+
this.#adminPath = config.adminPath;
|
|
50
|
+
// `<` is escaped so nothing in a site's name can end the block and start a script.
|
|
51
|
+
const settings = JSON.stringify(config).replaceAll('<', '\\u003c');
|
|
52
|
+
this.#page = fs
|
|
53
|
+
.readFileSync(index, 'utf8')
|
|
54
|
+
.replace(MARKER, `<base href="${config.adminPath}/" />\n <script type="application/json" id="velocity-cms-config">${settings}</script>`);
|
|
55
|
+
}
|
|
56
|
+
/** Answers a request for anything under the editor's address. */
|
|
57
|
+
respond(request) {
|
|
58
|
+
if (request.method !== 'GET' && request.method !== 'HEAD') {
|
|
59
|
+
return new Response(null, { status: 405, headers: { allow: 'GET, HEAD' } });
|
|
60
|
+
}
|
|
61
|
+
const { pathname } = new URL(request.url);
|
|
62
|
+
const inside = pathname === this.#adminPath ? '' : pathname.slice(this.#adminPath.length + 1);
|
|
63
|
+
const file = this.#files.get(inside);
|
|
64
|
+
if (file) {
|
|
65
|
+
// File names carry a hash of their content, so a browser may keep them for good.
|
|
66
|
+
return new Response(new Uint8Array(file.body), {
|
|
67
|
+
headers: { 'content-type': file.type, 'cache-control': 'public, max-age=31536000, immutable', 'x-content-type-options': 'nosniff' },
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
// A missing file must not be answered with the page: a browser would try to run it.
|
|
71
|
+
if (inside.startsWith('assets/'))
|
|
72
|
+
return new Response(null, { status: 404 });
|
|
73
|
+
// Every other address is a screen of the editor, which works out which one in the browser.
|
|
74
|
+
return new Response(this.#page, { headers: PAGE_HEADERS });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=admin-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-files.js","sourceRoot":"","sources":["../src/admin-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAevE,MAAM,KAAK,GAAqC;IAC9C,KAAK,EAAE,gCAAgC;IACvC,MAAM,EAAE,yBAAyB;IACjC,MAAM,EAAE,eAAe;IACvB,MAAM,EAAE,WAAW;IACnB,QAAQ,EAAE,YAAY;IACtB,OAAO,EAAE,iCAAiC;CAC3C,CAAC;AAEF,gEAAgE;AAChE,MAAM,MAAM,GAAG,qBAAqB,CAAC;AAErC;;;;GAIG;AACH,MAAM,YAAY,GAAG;IACnB,cAAc,EAAE,0BAA0B;IAC1C,eAAe,EAAE,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,CAAC;YAAE,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QAC7E,2FAA2F;QAC3F,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface CliEnvironment {
|
|
2
|
+
readonly env: Readonly<Record<string, string | undefined>>;
|
|
3
|
+
readonly print: (line: string) => void;
|
|
4
|
+
/** The folder the command is run in. Defaults to the process's own. */
|
|
5
|
+
readonly dir?: string;
|
|
6
|
+
}
|
|
7
|
+
/** The `velocity-cms` command. Returns the exit code. */
|
|
8
|
+
export declare function runCli(args: readonly string[], environment: CliEnvironment): Promise<number>;
|
|
9
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3D,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,uEAAuE;IACvE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAWD,yDAAyD;AACzD,wBAAsB,MAAM,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,WAAW,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAuDlG"}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { CmsAuth } from '@velocity-astro/cms-auth';
|
|
2
|
+
import { CmsError } from '@velocity-astro/cms-core';
|
|
3
|
+
import { connect } from './connection.js';
|
|
4
|
+
import { LogMailer } from './editor.js';
|
|
5
|
+
import { initSite } from './init.js';
|
|
6
|
+
const USAGE = `Usage:
|
|
7
|
+
velocity-cms init [<email> <name>] Set this site up for the CMS: a secret in .env, the integration in the
|
|
8
|
+
Astro config. With an email and a name, also create the first owner.
|
|
9
|
+
velocity-cms owner <email> <name> Create the site's first owner and print a link that signs them in.
|
|
10
|
+
velocity-cms link <email> Print a new sign-in link for someone who already has access.
|
|
11
|
+
|
|
12
|
+
Reads VELOCITY_CMS_SECRET, VELOCITY_CMS_ORIGIN (the site's address, such as https://example.com)
|
|
13
|
+
and VELOCITY_CMS_DATABASE_URL from the environment or from a .env file in this folder.`;
|
|
14
|
+
/** The `velocity-cms` command. Returns the exit code. */
|
|
15
|
+
export async function runCli(args, environment) {
|
|
16
|
+
const { print } = environment;
|
|
17
|
+
let { env } = environment;
|
|
18
|
+
const [asked, email, ...nameParts] = args;
|
|
19
|
+
const name = nameParts.join(' ');
|
|
20
|
+
let command = asked;
|
|
21
|
+
if (command === 'init') {
|
|
22
|
+
if (email && !name) {
|
|
23
|
+
print(`Give the owner's name after the address, or leave both out.\n\n${USAGE}`);
|
|
24
|
+
return 1;
|
|
25
|
+
}
|
|
26
|
+
const done = initSite({ dir: environment.dir ?? process.cwd(), print });
|
|
27
|
+
if (done.code !== 0)
|
|
28
|
+
return done.code;
|
|
29
|
+
if (!email) {
|
|
30
|
+
print('\nNext, make the first owner:\n\n npx velocity-cms owner <email> <name>\n\nThen start the site (`npm run dev`) and open /admin.');
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
// What init wrote is used at once; what the environment already said still wins.
|
|
34
|
+
env = { ...done.env, ...Object.fromEntries(Object.entries(env).filter(([, value]) => value)) };
|
|
35
|
+
command = 'owner';
|
|
36
|
+
print('');
|
|
37
|
+
}
|
|
38
|
+
const understood = (command === 'owner' && email && name) || (command === 'link' && email && !name);
|
|
39
|
+
if (!understood || !email) {
|
|
40
|
+
print(USAGE);
|
|
41
|
+
return command === undefined || command === 'help' ? 0 : 1;
|
|
42
|
+
}
|
|
43
|
+
const secret = env.VELOCITY_CMS_SECRET;
|
|
44
|
+
const origin = env.VELOCITY_CMS_ORIGIN;
|
|
45
|
+
if (!secret || !origin) {
|
|
46
|
+
print(`${secret ? 'VELOCITY_CMS_ORIGIN' : 'VELOCITY_CMS_SECRET'} is not set.\n\n${USAGE}`);
|
|
47
|
+
return 1;
|
|
48
|
+
}
|
|
49
|
+
const connection = await connect({
|
|
50
|
+
...(env.VELOCITY_CMS_DATABASE_URL && { url: env.VELOCITY_CMS_DATABASE_URL }),
|
|
51
|
+
...(env.VELOCITY_CMS_DATABASE_TOKEN && { authToken: env.VELOCITY_CMS_DATABASE_TOKEN }),
|
|
52
|
+
});
|
|
53
|
+
try {
|
|
54
|
+
const auth = new CmsAuth({ db: connection.db, secret, origin, siteName: 'Velocity CMS', mailer: new LogMailer(print), access: connection.cms.access });
|
|
55
|
+
if (command === 'owner') {
|
|
56
|
+
const { user, link } = await auth.createFirstOwner({ email, name });
|
|
57
|
+
print(`${user.name} <${user.email}> is the site's owner.\n\nOpen this link to sign in. It works once, for 10 minutes:\n\n${link}\n${origin.includes('localhost') ? '\nStart the site first (`npm run dev`), so the link has somewhere to land.\n' : ''}`);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// Whoever holds the link is that person, so it is only ever printed here, for whoever runs the site.
|
|
61
|
+
print(`Open this link to sign in as ${email}. It works once, for 10 minutes:\n\n${await auth.createSignInLink(email)}\n`);
|
|
62
|
+
}
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
if (!(error instanceof CmsError))
|
|
67
|
+
throw error;
|
|
68
|
+
print(error.message);
|
|
69
|
+
return 1;
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
connection.close();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=cli.js.map
|
package/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,CAAC;KACvF,CAAC,CAAC;IACH,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,OAAO,CAAC,EAAE,EAAE,EAAE,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;QACvJ,IAAI,OAAO,KAAK,OAAO,EAAE,CAAC;YACxB,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACpE,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,0FAA0F,IAAI,KAAK,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,8EAA8E,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5P,CAAC;aAAM,CAAC;YACN,qGAAqG;YACrG,KAAK,CAAC,gCAAgC,KAAK,uCAAuC,MAAM,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5H,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,QAAQ,CAAC;YAAE,MAAM,KAAK,CAAC;QAC9C,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,OAAO,CAAC,CAAC;IACX,CAAC;YAAS,CAAC;QACT,UAAU,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Actor, type Cms, type SearchIndex } from '@velocity-astro/cms-core';
|
|
2
|
+
import { type Db } from '@velocity-astro/cms-db';
|
|
3
|
+
export interface ConnectionOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Where the CMS database is. Defaults to the `VELOCITY_CMS_DATABASE_URL` environment variable,
|
|
6
|
+
* then to `file:./cms/data.db`.
|
|
7
|
+
*/
|
|
8
|
+
readonly url?: string;
|
|
9
|
+
/** The access token of a hosted database. Defaults to `VELOCITY_CMS_DATABASE_TOKEN`. */
|
|
10
|
+
readonly authToken?: string;
|
|
11
|
+
}
|
|
12
|
+
/** The site reads content as itself, with read access only. */
|
|
13
|
+
export declare const SITE: Actor;
|
|
14
|
+
export declare const resolveUrl: (options: ConnectionOptions) => string;
|
|
15
|
+
export interface Connection {
|
|
16
|
+
readonly cms: Cms;
|
|
17
|
+
readonly search: SearchIndex;
|
|
18
|
+
/** The database itself, for the packages that keep their own tables in it, such as sign-in. */
|
|
19
|
+
readonly db: Db;
|
|
20
|
+
close(): void;
|
|
21
|
+
}
|
|
22
|
+
export declare function connect(options: ConnectionOptions): Promise<Connection>;
|
|
23
|
+
/** One connection per database for the life of the server, opened on first use. */
|
|
24
|
+
export declare function sharedConnection(options: ConnectionOptions): Promise<Connection>;
|
|
25
|
+
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,KAAK,KAAK,EAAE,KAAK,GAAG,EAAmB,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE9G,OAAO,EAA2Q,KAAK,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAK1T,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,wFAAwF;IACxF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,+DAA+D;AAC/D,eAAO,MAAM,IAAI,EAAE,KAAyD,CAAC;AAE7E,eAAO,MAAM,UAAU,GAAI,SAAS,iBAAiB,KAAG,MACsB,CAAC;AAE/E,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,+FAA+F;IAC/F,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;IAChB,KAAK,IAAI,IAAI,CAAC;CACf;AAKD,wBAAsB,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CA2B7E;AAID,mFAAmF;AACnF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAehF"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { lookup } from 'node:dns/promises';
|
|
2
|
+
import { mkdirSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { createCms } from '@velocity-astro/cms-core';
|
|
5
|
+
import { AuthTeam } from '@velocity-astro/cms-auth/team';
|
|
6
|
+
import { openDatabase, SqliteEntryRepository, SqliteFormRepository, SqliteSubmissionRepository, SqliteContactRepository, SqliteDealRepository, SqlitePipelineStore, SqliteCustomFieldsStore, SqliteMediaRepository, SqlitePluginStore, SqliteSchemaRepository, SqliteSearchIndex } from '@velocity-astro/cms-db';
|
|
7
|
+
import { mediaStoreFromEnv } from './media-store.js';
|
|
8
|
+
import { siteSecret } from './secret.js';
|
|
9
|
+
import { allPlugins } from './site-plugins.js';
|
|
10
|
+
/** The site reads content as itself, with read access only. */
|
|
11
|
+
export const SITE = { kind: 'cli', id: 'astro-site', role: 'author' };
|
|
12
|
+
export const resolveUrl = (options) => options.url ?? process.env.VELOCITY_CMS_DATABASE_URL ?? 'file:./cms/data.db';
|
|
13
|
+
/** Every address a host's name leads to, so a plugin can refuse a name that leads to a private machine. */
|
|
14
|
+
const lookUp = async (host) => (await lookup(host, { all: true })).map((found) => found.address);
|
|
15
|
+
export async function connect(options) {
|
|
16
|
+
const authToken = options.authToken ?? (process.env.VELOCITY_CMS_DATABASE_TOKEN || undefined);
|
|
17
|
+
const url = resolveUrl(options);
|
|
18
|
+
// A database that is a file is made on first use, and so is the folder it sits in.
|
|
19
|
+
const file = /^file:(?!:memory:)([^?]+)/.exec(url)?.[1];
|
|
20
|
+
if (file !== undefined)
|
|
21
|
+
mkdirSync(path.dirname(path.resolve(file.replace(/^\/\/(?=\/)/, ''))), { recursive: true });
|
|
22
|
+
const database = await openDatabase({ url, ...(authToken !== undefined && { authToken }) });
|
|
23
|
+
const store = mediaStoreFromEnv(url);
|
|
24
|
+
const secret = siteSecret();
|
|
25
|
+
const cms = createCms({
|
|
26
|
+
entries: new SqliteEntryRepository(database.db),
|
|
27
|
+
types: new SqliteSchemaRepository(database.db),
|
|
28
|
+
forms: new SqliteFormRepository(database.db),
|
|
29
|
+
submissions: new SqliteSubmissionRepository(database.db),
|
|
30
|
+
contacts: new SqliteContactRepository(database.db),
|
|
31
|
+
pipeline: new SqlitePipelineStore(database.db),
|
|
32
|
+
customFields: new SqliteCustomFieldsStore(database.db),
|
|
33
|
+
deals: new SqliteDealRepository(database.db),
|
|
34
|
+
team: new AuthTeam(database.db),
|
|
35
|
+
// A secret too short to sign with is the editor's to report, not a reason to read no content.
|
|
36
|
+
...(secret !== undefined && secret.length >= 32 && { previews: { secret } }),
|
|
37
|
+
...(store && { media: { storage: { files: new SqliteMediaRepository(database.db), store } } }),
|
|
38
|
+
pluginStore: new SqlitePluginStore(database.db),
|
|
39
|
+
lookup: lookUp,
|
|
40
|
+
onPluginFault: (plugin, error) => console.error(`[velocity-cms] The plugin "${plugin}" failed.`, error),
|
|
41
|
+
});
|
|
42
|
+
return { cms, search: new SqliteSearchIndex(database.db), db: database.db, close: () => database.close() };
|
|
43
|
+
}
|
|
44
|
+
const shared = new Map();
|
|
45
|
+
/** One connection per database for the life of the server, opened on first use. */
|
|
46
|
+
export function sharedConnection(options) {
|
|
47
|
+
const url = resolveUrl(options);
|
|
48
|
+
let connection = shared.get(url);
|
|
49
|
+
if (!connection) {
|
|
50
|
+
// The site's plugins, and the ones that come with the CMS, start with its one connection, so a field type they add is known
|
|
51
|
+
// before the first page or the editor reads content.
|
|
52
|
+
connection = connect(options).then(async (opened) => {
|
|
53
|
+
await opened.cms.plugins.load(allPlugins());
|
|
54
|
+
return opened;
|
|
55
|
+
});
|
|
56
|
+
shared.set(url, connection);
|
|
57
|
+
// A failed connection must not be remembered, or every later request would fail too.
|
|
58
|
+
connection.catch(() => shared.delete(url));
|
|
59
|
+
}
|
|
60
|
+
return connection;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAA2D,MAAM,0BAA0B,CAAC;AAC9G,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,iBAAiB,EAAW,MAAM,wBAAwB,CAAC;AAC1T,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAY/C,+DAA+D;AAC/D,MAAM,CAAC,MAAM,IAAI,GAAU,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAE7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AAQ,CAAC,KAAK,EAAE,EAAE,CAAC;AAC7G,CAAC;AAED,MAAM,MAAM,GAAG,IAAI,GAAG,EAA+B,CAAC;AAEtD,mFAAmF;AACnF,MAAM,UAAU,gBAAgB,CAAC,OAA0B;IACzD,MAAM,GAAG,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAChC,IAAI,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,4HAA4H;QAC5H,qDAAqD;QACrD,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YAClD,MAAM,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;YAC5C,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAC5B,qFAAqF;QACrF,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
package/dist/editor.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { CmsAuth, type InvitationMail, type Mailer, type SignInMail } from '@velocity-astro/cms-auth';
|
|
2
|
+
import { type ImageLibrary } from '@velocity-astro/cms-core';
|
|
3
|
+
import { type Connection } from './connection.js';
|
|
4
|
+
export interface EditorHostOptions {
|
|
5
|
+
readonly connection: Connection;
|
|
6
|
+
/** The site's secret, `VELOCITY_CMS_SECRET`. It signs sessions and sign-in links. */
|
|
7
|
+
readonly secret: string;
|
|
8
|
+
/** The site's own address, such as `https://example.com`. */
|
|
9
|
+
readonly origin: string;
|
|
10
|
+
readonly siteName: string;
|
|
11
|
+
readonly mailer: Mailer;
|
|
12
|
+
/** The site's images, for image fields to choose from. */
|
|
13
|
+
readonly images?: ImageLibrary;
|
|
14
|
+
/** Where the editor is served. Defaults to `/admin`. */
|
|
15
|
+
readonly adminPath?: string;
|
|
16
|
+
/** Where the API is served. Defaults to `/api/cms`; sign-in sits under it at `/auth`. */
|
|
17
|
+
readonly apiPath?: string;
|
|
18
|
+
/** Where the built editor is. Defaults to the one `@velocity-astro/cms-admin` ships. */
|
|
19
|
+
readonly editorDirectory?: string;
|
|
20
|
+
/** Told about every fault in the API, which its responses say nothing about. */
|
|
21
|
+
readonly onFault?: (error: unknown) => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Prints sign-in links to the server's log instead of sending them. This is the mailer a site
|
|
25
|
+
* has until it sets up its own, and it is enough to work locally: copy the link from the log.
|
|
26
|
+
*/
|
|
27
|
+
export declare class LogMailer implements Mailer {
|
|
28
|
+
private readonly log;
|
|
29
|
+
constructor(log?: (line: string) => void);
|
|
30
|
+
sendSignInLink(mail: SignInMail): Promise<void>;
|
|
31
|
+
sendInvitation(mail: InvitationMail): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
export declare class EditorHost {
|
|
34
|
+
#private;
|
|
35
|
+
readonly auth: CmsAuth;
|
|
36
|
+
constructor(options: EditorHostOptions);
|
|
37
|
+
/** Answers a request to the API. */
|
|
38
|
+
api(request: Request): Promise<Response>;
|
|
39
|
+
/** Answers a request to one of the sign-in addresses. */
|
|
40
|
+
signIn(request: Request): Promise<Response>;
|
|
41
|
+
/**
|
|
42
|
+
* Answers a request for the editor's page or one of its files, which include the file of each
|
|
43
|
+
* running plugin that adds to the editor. A plugin's file is code the site's owner installed,
|
|
44
|
+
* like the editor's own, and holds nothing private; it is never kept by a browser, so a plugin
|
|
45
|
+
* that is switched off or updated is gone or new on the next load.
|
|
46
|
+
*/
|
|
47
|
+
admin(request: Request): Promise<Response>;
|
|
48
|
+
/**
|
|
49
|
+
* Publishes the entries whose time has come. A site may have no clock of its own, so this is
|
|
50
|
+
* asked on every request and looks at most every half minute; a scheduled job that calls the
|
|
51
|
+
* site (`/api/cms/schedule`) passes `now` to look whenever it asks. It never throws: a page is
|
|
52
|
+
* not lost over a publish that could not be looked for. `takePublished` says what went out.
|
|
53
|
+
*/
|
|
54
|
+
publishDue(options?: {
|
|
55
|
+
readonly now?: boolean;
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* What was published or taken down since this was last asked, and forgets it: `null` when
|
|
59
|
+
* nothing was, otherwise the addresses of the entries' own pages. The caller clears its page
|
|
60
|
+
* cache, since any page may show the entry, and reads those pages again for search. The list
|
|
61
|
+
* is empty for a type that has no address pattern.
|
|
62
|
+
*/
|
|
63
|
+
takePublished(): string[] | null;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,MAAM,EAAE,KAAK,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtG,OAAO,EAAgD,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE3G,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAOxD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,qFAAqF;IACrF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAC/B,wDAAwD;IACxD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,yFAAyF;IACzF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,wFAAwF;IACxF,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,gFAAgF;IAChF,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC7C;AAED;;;GAGG;AACH,qBAAa,SAAU,YAAW,MAAM;IAC1B,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAmC;IAEjF,cAAc,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/C,cAAc,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAG1D;AAUD,qBAAa,UAAU;;IACrB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;gBAcX,OAAO,EAAE,iBAAiB;IAqEtC,oCAAoC;IACpC,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIxC,yDAAyD;IACzD,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAI3C;;;;;OAKG;IACG,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAUhD;;;;;OAKG;IACG,UAAU,CAAC,OAAO,GAAE;QAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAUzE;;;;;OAKG;IACH,aAAa,IAAI,MAAM,EAAE,GAAG,IAAI;CAOjC"}
|
package/dist/editor.js
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { CmsApi } from '@velocity-astro/cms-api';
|
|
2
|
+
import { CmsAuth } from '@velocity-astro/cms-auth';
|
|
3
|
+
import { pageAddress } from '@velocity-astro/cms-core';
|
|
4
|
+
import { AdminFiles, builtEditorDirectory } from './admin-files.js';
|
|
5
|
+
import { SITE } from './connection.js';
|
|
6
|
+
import { invalidateLiveContent } from './live-loader.js';
|
|
7
|
+
/** The language of the pages at a type's `urlPattern`, as the API and the previews take it. */
|
|
8
|
+
const DEFAULT_LOCALE = 'en';
|
|
9
|
+
const PAGE_SIZE = 500;
|
|
10
|
+
/**
|
|
11
|
+
* Prints sign-in links to the server's log instead of sending them. This is the mailer a site
|
|
12
|
+
* has until it sets up its own, and it is enough to work locally: copy the link from the log.
|
|
13
|
+
*/
|
|
14
|
+
export class LogMailer {
|
|
15
|
+
log;
|
|
16
|
+
constructor(log = (line) => console.info(line)) {
|
|
17
|
+
this.log = log;
|
|
18
|
+
}
|
|
19
|
+
async sendSignInLink(mail) {
|
|
20
|
+
this.log(`[velocity-cms] Sign-in link for ${mail.email} (works once, for ${mail.expiresInMinutes} minutes): ${mail.url}`);
|
|
21
|
+
}
|
|
22
|
+
async sendInvitation(mail) {
|
|
23
|
+
this.log(`[velocity-cms] ${mail.name} (${mail.email}) was invited. No email was sent: tell them to sign in at ${mail.url}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Everything a site needs to host the editor, wired together: the editor's page, the API it
|
|
28
|
+
* calls and the sign-in behind both, over the site's one database connection. The integration's
|
|
29
|
+
* routes each hand their request to one of the three methods and do nothing else.
|
|
30
|
+
*/
|
|
31
|
+
/** How often entries due to be published are looked for. */
|
|
32
|
+
const DUE_EVERY_MS = 30_000;
|
|
33
|
+
export class EditorHost {
|
|
34
|
+
auth;
|
|
35
|
+
#api;
|
|
36
|
+
#files;
|
|
37
|
+
#pluginFile;
|
|
38
|
+
#plugins;
|
|
39
|
+
#content;
|
|
40
|
+
#onFault;
|
|
41
|
+
/** When entries due to be published were last looked for. */
|
|
42
|
+
#lookedAt = 0;
|
|
43
|
+
/** Whether anything was published or taken down since `takePublished` was last called. */
|
|
44
|
+
#published = false;
|
|
45
|
+
/** The addresses of the pages that changed with it, where they are known. */
|
|
46
|
+
#changed = new Set();
|
|
47
|
+
constructor(options) {
|
|
48
|
+
const { cms } = options.connection;
|
|
49
|
+
const adminPath = options.adminPath ?? '/admin';
|
|
50
|
+
const apiPath = options.apiPath ?? '/api/cms';
|
|
51
|
+
const authPath = `${apiPath}/auth`;
|
|
52
|
+
this.auth = new CmsAuth({
|
|
53
|
+
db: options.connection.db,
|
|
54
|
+
secret: options.secret,
|
|
55
|
+
origin: options.origin,
|
|
56
|
+
siteName: options.siteName,
|
|
57
|
+
mailer: options.mailer,
|
|
58
|
+
basePath: authPath,
|
|
59
|
+
adminPath,
|
|
60
|
+
access: cms.access,
|
|
61
|
+
});
|
|
62
|
+
if (options.images)
|
|
63
|
+
cms.media.include(options.images);
|
|
64
|
+
this.#api = new CmsApi({
|
|
65
|
+
cms,
|
|
66
|
+
authenticator: this.auth,
|
|
67
|
+
people: this.auth,
|
|
68
|
+
basePath: apiPath,
|
|
69
|
+
...(options.onFault && { onFault: options.onFault }),
|
|
70
|
+
});
|
|
71
|
+
this.#plugins = cms.plugins;
|
|
72
|
+
this.#content = cms.content;
|
|
73
|
+
this.#onFault = options.onFault;
|
|
74
|
+
// `/admin/plugins/<name>.js`: what a running plugin adds to the editor.
|
|
75
|
+
this.#pluginFile = new RegExp(`^${adminPath.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}/plugins/([a-z][a-z0-9-]{0,39})\\.js$`);
|
|
76
|
+
this.#files = new AdminFiles(options.editorDirectory ?? builtEditorDirectory(), { siteName: options.siteName, adminPath, apiPath, authPath });
|
|
77
|
+
// The site keeps what it read from the CMS for a moment. A publish must be seen at once.
|
|
78
|
+
const published = async ({ entry, before }) => {
|
|
79
|
+
invalidateLiveContent();
|
|
80
|
+
this.#published = true;
|
|
81
|
+
const type = await cms.schema.get(entry.typeId).catch(() => null);
|
|
82
|
+
for (const address of addressesOf(type, [entry, before]))
|
|
83
|
+
this.#changed.add(address);
|
|
84
|
+
};
|
|
85
|
+
cms.events.on('entry.published', published);
|
|
86
|
+
cms.events.on('entry.unpublished', published);
|
|
87
|
+
// Archiving a type takes every page of it off the site, and restoring brings them back.
|
|
88
|
+
const shown = async ({ type }) => {
|
|
89
|
+
invalidateLiveContent();
|
|
90
|
+
this.#published = true;
|
|
91
|
+
for (let offset = 0;; offset += PAGE_SIZE) {
|
|
92
|
+
const page = await cms.content.find(SITE, { typeId: type.id, status: 'published', limit: PAGE_SIZE, offset });
|
|
93
|
+
for (const address of addressesOf(type, page.items))
|
|
94
|
+
this.#changed.add(address);
|
|
95
|
+
if (offset + page.items.length >= page.total || page.items.length === 0)
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
// A plugin changed what pages say about themselves: the copies the site kept are stale.
|
|
100
|
+
cms.events.on('pages.changed', () => {
|
|
101
|
+
invalidateLiveContent();
|
|
102
|
+
this.#published = true;
|
|
103
|
+
});
|
|
104
|
+
// A page that draws a form was kept with the form's fields as they were.
|
|
105
|
+
const formChanged = () => {
|
|
106
|
+
invalidateLiveContent();
|
|
107
|
+
this.#published = true;
|
|
108
|
+
};
|
|
109
|
+
cms.events.on('form.saved', formChanged);
|
|
110
|
+
cms.events.on('form.trashed', formChanged);
|
|
111
|
+
cms.events.on('form.restored', formChanged);
|
|
112
|
+
cms.events.on('form.deleted', formChanged);
|
|
113
|
+
cms.events.on('type.archived', shown);
|
|
114
|
+
cms.events.on('type.restored', shown);
|
|
115
|
+
}
|
|
116
|
+
/** Answers a request to the API. */
|
|
117
|
+
api(request) {
|
|
118
|
+
return this.#api.handle(request);
|
|
119
|
+
}
|
|
120
|
+
/** Answers a request to one of the sign-in addresses. */
|
|
121
|
+
signIn(request) {
|
|
122
|
+
return this.auth.handle(request);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Answers a request for the editor's page or one of its files, which include the file of each
|
|
126
|
+
* running plugin that adds to the editor. A plugin's file is code the site's owner installed,
|
|
127
|
+
* like the editor's own, and holds nothing private; it is never kept by a browser, so a plugin
|
|
128
|
+
* that is switched off or updated is gone or new on the next load.
|
|
129
|
+
*/
|
|
130
|
+
async admin(request) {
|
|
131
|
+
const name = this.#pluginFile.exec(new URL(request.url).pathname)?.[1];
|
|
132
|
+
if (name === undefined)
|
|
133
|
+
return this.#files.respond(request);
|
|
134
|
+
if (request.method !== 'GET' && request.method !== 'HEAD')
|
|
135
|
+
return new Response(null, { status: 405, headers: { allow: 'GET, HEAD' } });
|
|
136
|
+
const file = await this.#plugins.editorFile(name);
|
|
137
|
+
// Not the editor's page: a browser asked for a script, and would try to run it.
|
|
138
|
+
if (file === null)
|
|
139
|
+
return new Response(null, { status: 404, headers: { 'cache-control': 'no-store' } });
|
|
140
|
+
return new Response(file, { headers: { 'content-type': 'text/javascript; charset=utf-8', 'cache-control': 'no-store', 'x-content-type-options': 'nosniff' } });
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Publishes the entries whose time has come. A site may have no clock of its own, so this is
|
|
144
|
+
* asked on every request and looks at most every half minute; a scheduled job that calls the
|
|
145
|
+
* site (`/api/cms/schedule`) passes `now` to look whenever it asks. It never throws: a page is
|
|
146
|
+
* not lost over a publish that could not be looked for. `takePublished` says what went out.
|
|
147
|
+
*/
|
|
148
|
+
async publishDue(options = {}) {
|
|
149
|
+
if (options.now !== true && Date.now() - this.#lookedAt < DUE_EVERY_MS)
|
|
150
|
+
return;
|
|
151
|
+
this.#lookedAt = Date.now();
|
|
152
|
+
try {
|
|
153
|
+
await this.#content.publishDue();
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
this.#onFault?.(error);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* What was published or taken down since this was last asked, and forgets it: `null` when
|
|
161
|
+
* nothing was, otherwise the addresses of the entries' own pages. The caller clears its page
|
|
162
|
+
* cache, since any page may show the entry, and reads those pages again for search. The list
|
|
163
|
+
* is empty for a type that has no address pattern.
|
|
164
|
+
*/
|
|
165
|
+
takePublished() {
|
|
166
|
+
if (!this.#published)
|
|
167
|
+
return null;
|
|
168
|
+
const addresses = [...this.#changed];
|
|
169
|
+
this.#published = false;
|
|
170
|
+
this.#changed.clear();
|
|
171
|
+
return addresses;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Where an entry's own page is, from its type's address pattern: the address visitors find it
|
|
176
|
+
* at now and, if that changed or it was taken down, the one they found it at before. A page in
|
|
177
|
+
* a language the type gives no pattern for is not known here; it is fresh at once all the same,
|
|
178
|
+
* and searched after the next deploy.
|
|
179
|
+
*/
|
|
180
|
+
function addressesOf(type, versions) {
|
|
181
|
+
if (!type)
|
|
182
|
+
return [];
|
|
183
|
+
const at = (entry) => (entry.published ? pageAddress(type, { locale: entry.locale, ...entry.published }, DEFAULT_LOCALE) : null);
|
|
184
|
+
return [...new Set(versions.flatMap((entry) => at(entry) ?? []))];
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor.js","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAqD,MAAM,0BAA0B,CAAC;AACtG,OAAO,EAAE,WAAW,EAAsD,MAAM,0BAA0B,CAAC;AAC3G,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAmB,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,+FAA+F;AAC/F,MAAM,cAAc,GAAG,IAAI,CAAC;AAC5B,MAAM,SAAS,GAAG,GAAG,CAAC;AAsBtB;;;GAGG;AACH,MAAM,OAAO,SAAS;IACS;IAA7B,YAA6B,MAA8B,CAAC,IAAI,EAAE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