@vite-hub/cms 0.4.1 → 0.5.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/access.js +0 -2
- package/dist/{index-BQk9e5ua.d.ts → index-BCWEbTZ8.d.ts} +0 -13
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -17
- package/dist/vite.d.ts +8 -7
- package/dist/vite.js +13 -22
- package/package.json +10 -10
package/dist/access.js
CHANGED
|
@@ -70,7 +70,6 @@ const cmsAccess = {
|
|
|
70
70
|
function isCmsRoleName(name) {
|
|
71
71
|
return Object.hasOwn(cmsRoles, name);
|
|
72
72
|
}
|
|
73
|
-
/** The known CMS roles of a user. `role` holds one role, or several separated by commas, as Better Auth stores them. */
|
|
74
73
|
function cmsRolesOf(user) {
|
|
75
74
|
const role = user?.role;
|
|
76
75
|
if (String(role) !== role) return [];
|
|
@@ -89,7 +88,6 @@ function cmsCan(user, permissions) {
|
|
|
89
88
|
* Only CMS roles have `content:read`, so `/api/content/**` needs `defineContent({ access: "public" })` to serve visitors.
|
|
90
89
|
*/
|
|
91
90
|
const cmsContentAuthorize = ({ user, action }) => cmsCan(user, { content: [action] });
|
|
92
|
-
/** The `comment` permission of each Comments action. Only `publisher` and `admin` delete. */
|
|
93
91
|
const commentPermissions = {
|
|
94
92
|
read: "read",
|
|
95
93
|
write: "create",
|
|
@@ -35,19 +35,6 @@ interface CmsPresetOptions {
|
|
|
35
35
|
/** GitHub store: how a publish reaches `branch`. `"commit"` (default) commits to it. `"pr"` opens a pull request from a `vitehub/publish/*` branch, which only Console access or a signed link previews. */
|
|
36
36
|
publish?: "commit" | "pr";
|
|
37
37
|
}
|
|
38
|
-
/**
|
|
39
|
-
* Store editable collections without wiring. `vitehub()` turns on Workspace, Database, and Blob when they are unset.
|
|
40
|
-
* At build time `hubCms()` from `@vite-hub/cms/vite` adds a Workspace named `content` on the Blob + Database Store,
|
|
41
|
-
* using the `default` Blob store and the default or only Database, and adds the Workspace history tables to that
|
|
42
|
-
* Database. When the app has no Database Definition, that is the implicit `default` Database. `defineContent({ extends: cms })`
|
|
43
|
-
* then uses that Workspace.
|
|
44
|
-
*
|
|
45
|
-
* With `repo` (or `store: "github"`) the Workspace is a GitHub repository instead: published content on one branch, drafts on
|
|
46
|
-
* another, and no Blob store. The Database keeps editor sessions.
|
|
47
|
-
*
|
|
48
|
-
* With `roles: true` and no `authorize` in `defineContent()`, the CMS roles of the Better Auth `admin` plugin decide
|
|
49
|
-
* who reads drafts, writes, and publishes. See `cmsAccess` from `@vite-hub/cms/access`.
|
|
50
|
-
*/
|
|
51
38
|
declare const cms: ContentPreset<CmsPresetOptions>;
|
|
52
39
|
//#endregion
|
|
53
40
|
export { cms as n, CmsPresetOptions as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as cms, t as CmsPresetOptions } from "./index-
|
|
1
|
+
import { n as cms, t as CmsPresetOptions } from "./index-BCWEbTZ8.js";
|
|
2
2
|
export { CmsPresetOptions, cms, cms as default };
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,11 @@
|
|
|
1
1
|
import { a as cmsRenamedAccessProblem, i as cmsOptionsProblem, n as cmsOptionKeys, o as cmsStoreOf, r as cmsOptionProblem, s as cmsErrorDiagnostics, t as cmsGitHubDefaults } from "./options-BCArcTOP.js";
|
|
2
2
|
import { defineContentPreset } from "@vite-hub/content";
|
|
3
3
|
//#region src/index.ts
|
|
4
|
-
/**
|
|
5
|
-
* The policy for `roles: true` when the app sets no `authorize`. A user without a string role is denied before
|
|
6
|
-
* Better Auth loads. The preset never interprets application roles unless the app explicitly opts in.
|
|
7
|
-
*/
|
|
8
4
|
const cmsDefaultAuthorize = async (context) => {
|
|
9
5
|
if (String(context.user?.role) !== context.user?.role) return false;
|
|
10
6
|
const { cmsContentAuthorize } = await import("./access.js");
|
|
11
7
|
return await cmsContentAuthorize(context);
|
|
12
8
|
};
|
|
13
|
-
/**
|
|
14
|
-
* Store editable collections without wiring. `vitehub()` turns on Workspace, Database, and Blob when they are unset.
|
|
15
|
-
* At build time `hubCms()` from `@vite-hub/cms/vite` adds a Workspace named `content` on the Blob + Database Store,
|
|
16
|
-
* using the `default` Blob store and the default or only Database, and adds the Workspace history tables to that
|
|
17
|
-
* Database. When the app has no Database Definition, that is the implicit `default` Database. `defineContent({ extends: cms })`
|
|
18
|
-
* then uses that Workspace.
|
|
19
|
-
*
|
|
20
|
-
* With `repo` (or `store: "github"`) the Workspace is a GitHub repository instead: published content on one branch, drafts on
|
|
21
|
-
* another, and no Blob store. The Database keeps editor sessions.
|
|
22
|
-
*
|
|
23
|
-
* With `roles: true` and no `authorize` in `defineContent()`, the CMS roles of the Better Auth `admin` plugin decide
|
|
24
|
-
* who reads drafts, writes, and publishes. See `cmsAccess` from `@vite-hub/cms/access`.
|
|
25
|
-
*/
|
|
26
9
|
const cms = defineContentPreset({
|
|
27
10
|
name: "cms",
|
|
28
11
|
options: {
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { t as CmsPresetOptions } from "./index-
|
|
1
|
+
import { t as CmsPresetOptions } from "./index-BCWEbTZ8.js";
|
|
2
2
|
import "nostics";
|
|
3
3
|
import { Plugin } from "vite";
|
|
4
4
|
import { DatabaseContributionFactory } from "@vite-hub/database/vite";
|
|
5
5
|
import { WorkspaceContributionFactory } from "@vite-hub/workspace/vite";
|
|
6
|
-
//#region ../internal/dist/host-credentials-
|
|
6
|
+
//#region ../internal/dist/host-credentials-NQkTpoab.d.ts
|
|
7
7
|
interface HostCliRunResult {
|
|
8
8
|
exitCode: number | null;
|
|
9
9
|
stdout: string;
|
|
10
|
+
stderr?: string;
|
|
10
11
|
}
|
|
11
12
|
/** Runs a host CLI with an argument array and no shell, and returns its stdout. */
|
|
12
13
|
type HostCliRun = (command: string, args: readonly string[], options: {
|
|
@@ -70,7 +71,6 @@ interface ProvisionStep {
|
|
|
70
71
|
}
|
|
71
72
|
//#endregion
|
|
72
73
|
//#region ../internal/dist/cli.d.ts
|
|
73
|
-
//#region src/cli.d.ts
|
|
74
74
|
interface ViteHubCliStreams {
|
|
75
75
|
stderr: {
|
|
76
76
|
write: (chunk: string | Uint8Array, encoding?: BufferEncoding | StdoutWriteCallback, callback?: StdoutWriteCallback) => unknown;
|
|
@@ -217,6 +217,8 @@ interface ViteHubResourceSummary {
|
|
|
217
217
|
owner: string;
|
|
218
218
|
/** Absent when no id is known yet. */
|
|
219
219
|
source?: ViteHubResourceIdSource;
|
|
220
|
+
/** The resource is in the Wrangler config of a standalone Provider Output Worker, not in Nitro's. */
|
|
221
|
+
standalone?: boolean;
|
|
220
222
|
}
|
|
221
223
|
interface ViteHubInspectionContributor {
|
|
222
224
|
definitions?: readonly ViteHubDefinitionInspector[];
|
|
@@ -295,8 +297,6 @@ interface CmsDatabaseChoices {
|
|
|
295
297
|
export declare function resolveCmsPresetPlan(usage: CmsPresetUsage, databases: CmsDatabaseChoices, projectRoot: string): CmsPresetPlan;
|
|
296
298
|
/** Import paths that the generated Workspace module uses. */
|
|
297
299
|
interface CmsWorkspaceImports {
|
|
298
|
-
/** Exports `blob`. */
|
|
299
|
-
blob: string;
|
|
300
300
|
/** Exports `createBlobDatabaseWorkspaceStore` and `workspaceHistorySchema`. */
|
|
301
301
|
blobDatabase: string;
|
|
302
302
|
/** Exports `contentSessionsSchema`, the presence and edit lease table that the preset adds to its Database. */
|
|
@@ -307,8 +307,9 @@ interface CmsWorkspaceImports {
|
|
|
307
307
|
workspace: string;
|
|
308
308
|
}
|
|
309
309
|
/**
|
|
310
|
-
* The generated Workspace Definition module. It
|
|
311
|
-
*
|
|
310
|
+
* The generated Workspace Definition module. It creates a lazy store when it loads, so the build can load it to bundle
|
|
311
|
+
* Workspace assets. The Blob + Database Store looks up its Blob store and Database by name on first use, so durability
|
|
312
|
+
* can read both. The GitHub store reads its token on first use.
|
|
312
313
|
*/
|
|
313
314
|
export declare function renderCmsWorkspaceModule(plan: CmsPresetPlan, imports: CmsWorkspaceImports): string;
|
|
314
315
|
//#endregion
|
package/dist/vite.js
CHANGED
|
@@ -111,7 +111,7 @@ const secretKeyPattern = /secret|token|passw(?:or)?d|credential|api[-_\s]?key|pr
|
|
|
111
111
|
new RegExp(String.raw`\b([\w-]*authorization[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\r\n]+?(?=\s*(?:[,;])?\s*(?:${secretKeyPattern.source})[\w-]*\s*[:=]|\s+rejected\b|$))`, "gi");
|
|
112
112
|
new RegExp(String.raw`\b([\w-]*(?:${secretKeyPattern.source})[\w-]*["']?\s*[:=]\s*)(?!\[redacted\](?=$|[\s,;}&]))(?:"(?:\\[^\r\n]|[^"\\\r\n])*"|'(?:\\[^\r\n]|[^'\\\r\n])*'|[^\s,;&#&]+)`, "gi");
|
|
113
113
|
//#endregion
|
|
114
|
-
//#region ../internal/dist/
|
|
114
|
+
//#region ../internal/dist/vite-DGZFNpcx.js
|
|
115
115
|
const projectRootDirectoryMarkers = [
|
|
116
116
|
["server", "agents"],
|
|
117
117
|
["server", "channels"],
|
|
@@ -161,7 +161,7 @@ function hasProjectRootDirectoryMarker(root) {
|
|
|
161
161
|
for (const marker of projectRootDirectoryMarkers) try {
|
|
162
162
|
if (statSync(resolve(root, ...marker)).isDirectory()) return true;
|
|
163
163
|
} catch (error) {
|
|
164
|
-
if (error
|
|
164
|
+
if (!isMissingProjectMarker(error)) throw error;
|
|
165
165
|
}
|
|
166
166
|
return false;
|
|
167
167
|
}
|
|
@@ -175,11 +175,15 @@ function hasProjectRootFileMarker(root, markers) {
|
|
|
175
175
|
try {
|
|
176
176
|
if (statSync(resolve(root, ...path)).isFile()) return true;
|
|
177
177
|
} catch (error) {
|
|
178
|
-
if (error
|
|
178
|
+
if (!isMissingProjectMarker(error)) throw error;
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
return false;
|
|
182
182
|
}
|
|
183
|
+
function isMissingProjectMarker(error) {
|
|
184
|
+
const code = error.code;
|
|
185
|
+
return code === "ENOENT" || code === "ENOTDIR";
|
|
186
|
+
}
|
|
183
187
|
//#endregion
|
|
184
188
|
//#region ../internal/dist/contributions.js
|
|
185
189
|
function isThenable(value) {
|
|
@@ -236,7 +240,6 @@ const cmsPresetModules = ["vite-hub/cms", "@vite-hub/cms"];
|
|
|
236
240
|
function isNode(value) {
|
|
237
241
|
return value !== null && Object(value) === value && String(Reflect.get(Object(value), "type")) === Reflect.get(Object(value), "type");
|
|
238
242
|
}
|
|
239
|
-
/** Drop type-only and grouping wrappers such as `x satisfies T`, `x as T`, and `(x)`. */
|
|
240
243
|
function unwrap(node) {
|
|
241
244
|
let current = node;
|
|
242
245
|
while (isNode(current) && [
|
|
@@ -255,7 +258,6 @@ function propertyName(node) {
|
|
|
255
258
|
if (key.type === "Identifier") return String(key.name);
|
|
256
259
|
if (key.type === "Literal" && String(key.value) === key.value) return key.value;
|
|
257
260
|
}
|
|
258
|
-
/** A string or `true` literal: the values that the cms preset options take. */
|
|
259
261
|
function literalValue(node) {
|
|
260
262
|
const value = unwrap(node);
|
|
261
263
|
if (isNode(value) && value.type === "Literal" && value.value === true) return true;
|
|
@@ -274,7 +276,6 @@ function stringValue(node) {
|
|
|
274
276
|
function displayPath(file, projectRoot) {
|
|
275
277
|
return JSON.stringify(relative(projectRoot, file).replaceAll("\\", "/"));
|
|
276
278
|
}
|
|
277
|
-
/** The build cannot read how the Definition selects the preset. */
|
|
278
279
|
function presetError(file, projectRoot, message) {
|
|
279
280
|
return cmsErrorDiagnostics.CONTENT_B0001({ message: `[vitehub] ${displayPath(file, projectRoot)}: ${message}` });
|
|
280
281
|
}
|
|
@@ -290,7 +291,6 @@ function cmsRequirementError(file, projectRoot, message) {
|
|
|
290
291
|
function readCmsPresetUsage(source, file, projectRoot, parseAst) {
|
|
291
292
|
return readCmsPresetUsageInternal(source, file, projectRoot, parseAst, /* @__PURE__ */ new Set(), "default");
|
|
292
293
|
}
|
|
293
|
-
/** `exportName` is the export that holds the Content Definition: `default` in `server/content.ts`, or the name that it re-exports. */
|
|
294
294
|
function readCmsPresetUsageInternal(source, file, projectRoot, parseAst, seen, exportName) {
|
|
295
295
|
const resolvedFile = resolve(file);
|
|
296
296
|
if (seen.has(resolvedFile)) return;
|
|
@@ -585,24 +585,21 @@ let lastPresetCheck;
|
|
|
585
585
|
/** Export of the generated module that holds the Workspace Definition. */
|
|
586
586
|
const cmsWorkspaceExport = "contentWorkspace";
|
|
587
587
|
/**
|
|
588
|
-
* The generated Workspace Definition module. It
|
|
589
|
-
*
|
|
588
|
+
* The generated Workspace Definition module. It creates a lazy store when it loads, so the build can load it to bundle
|
|
589
|
+
* Workspace assets. The Blob + Database Store looks up its Blob store and Database by name on first use, so durability
|
|
590
|
+
* can read both. The GitHub store reads its token on first use.
|
|
590
591
|
*/
|
|
591
592
|
function renderCmsWorkspaceModule(plan, imports) {
|
|
592
593
|
if (plan.store === "github" && plan.github) return renderGitHubWorkspaceModule(plan, plan.github, imports);
|
|
593
594
|
return [
|
|
594
595
|
"// Generated by @vite-hub/cms for the cms preset in server/content.ts. Do not edit.",
|
|
595
|
-
`import { blob } from ${JSON.stringify(imports.blob)}`,
|
|
596
|
-
`import { useDatabase } from ${JSON.stringify(imports.database)}`,
|
|
597
596
|
`import { defineWorkspace } from ${JSON.stringify(imports.workspace)}`,
|
|
598
597
|
`import { createBlobDatabaseWorkspaceStore } from ${JSON.stringify(imports.blobDatabase)}`,
|
|
599
598
|
"",
|
|
600
|
-
...renderDatabaseLookup(plan.database),
|
|
601
|
-
"",
|
|
602
599
|
`export const ${cmsWorkspaceExport} = defineWorkspace({`,
|
|
603
600
|
" store: createBlobDatabaseWorkspaceStore({",
|
|
604
|
-
` blob:
|
|
605
|
-
|
|
601
|
+
` blob: ${JSON.stringify(plan.blob ?? "default")},`,
|
|
602
|
+
` database: ${JSON.stringify(plan.database)},`,
|
|
606
603
|
` workspace: ${JSON.stringify(plan.workspace)},`,
|
|
607
604
|
" }),",
|
|
608
605
|
"})",
|
|
@@ -706,7 +703,6 @@ function cmsStore(input) {
|
|
|
706
703
|
return cmsPresetStoreSync(input, parseAst);
|
|
707
704
|
}
|
|
708
705
|
const defaultImports = {
|
|
709
|
-
blob: "@vite-hub/blob",
|
|
710
706
|
blobDatabase: "@vite-hub/workspace/blob-database",
|
|
711
707
|
contentDatabase: "@vite-hub/content/database",
|
|
712
708
|
database: "@vite-hub/database",
|
|
@@ -741,14 +737,9 @@ function databaseDiscoveryRoot(plugins, fallback) {
|
|
|
741
737
|
}
|
|
742
738
|
return fallback;
|
|
743
739
|
}
|
|
744
|
-
/**
|
|
745
|
-
* The other plugins of the app. `vitehub()` nests the CMS plugin in an array, and the Database contributions that
|
|
746
|
-
* the hooks collect would call the hook again through that nested copy, so flatten first.
|
|
747
|
-
*/
|
|
748
740
|
async function pluginsWithoutCms(plugins) {
|
|
749
741
|
return (await flattenPluginOptions(plugins)).filter((plugin) => Reflect.get(plugin, "name") !== CMS_VITE_PLUGIN_NAME);
|
|
750
742
|
}
|
|
751
|
-
/** Store names of the Blob plugin, or false when Blob is off. */
|
|
752
743
|
function blobStoreNames(plugin) {
|
|
753
744
|
if (!plugin) return false;
|
|
754
745
|
const getConfig = Reflect.get(Object(Reflect.get(plugin, "api")), "getConfig");
|
|
@@ -832,7 +823,7 @@ function hubCms(options = {}) {
|
|
|
832
823
|
}] };
|
|
833
824
|
},
|
|
834
825
|
async workspaces(context) {
|
|
835
|
-
const projectRoot = context.projectRoot
|
|
826
|
+
const projectRoot = context.projectRoot;
|
|
836
827
|
const otherPlugins = await pluginsWithoutCms(context.plugins);
|
|
837
828
|
const databaseRoot = databaseDiscoveryRoot(otherPlugins, projectRoot);
|
|
838
829
|
const { collectDatabaseContributions } = await import("@vite-hub/database/vite");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vite-hub/cms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Editable Content collections on a generated ViteHub Workspace, in Blob and Database or in a GitHub repository.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms",
|
|
@@ -46,18 +46,18 @@
|
|
|
46
46
|
"./package.json": "./package.json"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@vite-hub/content": "0.
|
|
50
|
-
"@vite-hub/source": "0.
|
|
49
|
+
"@vite-hub/content": "0.5.0",
|
|
50
|
+
"@vite-hub/source": "0.5.0",
|
|
51
51
|
"nostics": "1.4.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@comark/html": "^0.9.0",
|
|
55
55
|
"@libsql/client": "^0.18.0",
|
|
56
56
|
"@types/node": "^24.19.1",
|
|
57
|
-
"@vite-hub/comments": "0.
|
|
58
|
-
"@vite-hub/database": "0.
|
|
57
|
+
"@vite-hub/comments": "0.5.0",
|
|
58
|
+
"@vite-hub/database": "0.5.0",
|
|
59
59
|
"@vite-hub/internal": "0.0.1",
|
|
60
|
-
"@vite-hub/workspace": "0.
|
|
60
|
+
"@vite-hub/workspace": "0.5.0",
|
|
61
61
|
"better-auth": "^1.7.15",
|
|
62
62
|
"comark": "^0.9.0",
|
|
63
63
|
"comark-ui": "^0.12.0",
|
|
@@ -71,10 +71,10 @@
|
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"@comark/html": "^0.9.0",
|
|
74
|
-
"@vite-hub/blob": "0.
|
|
75
|
-
"@vite-hub/comments": "0.
|
|
76
|
-
"@vite-hub/database": "0.
|
|
77
|
-
"@vite-hub/workspace": "0.
|
|
74
|
+
"@vite-hub/blob": "0.5.0",
|
|
75
|
+
"@vite-hub/comments": "0.5.0",
|
|
76
|
+
"@vite-hub/database": "0.5.0",
|
|
77
|
+
"@vite-hub/workspace": "0.5.0",
|
|
78
78
|
"better-auth": "^1.7.15",
|
|
79
79
|
"comark": "^0.9.0",
|
|
80
80
|
"comark-ui": "^0.12.0",
|