@orhancodestudio/ocsm-core 0.1.0-alpha.2 → 0.1.0-alpha.3
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/CHANGELOG.md +10 -0
- package/package.json +1 -1
- package/src/server/create-ocsm.ts +48 -10
- package/src/server/index.ts +1 -1
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog — @orhancodestudio/ocsm-core
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.3
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `ocsm.public` — a filesystem-only reader (`listDocuments`, `getDocument`,
|
|
8
|
+
`getLayout`, `getTheme`) for the public site. Decouples the production build
|
|
9
|
+
from GitHub: public pages read the committed checkout instead of the API
|
|
10
|
+
(faster, no rate limits, build never depends on GitHub availability). The live
|
|
11
|
+
GitHub backend still powers the editor's reads, writes, and media serving.
|
|
12
|
+
|
|
3
13
|
## 0.1.0-alpha.2
|
|
4
14
|
|
|
5
15
|
### Added
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orhancodestudio/ocsm-core",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.3",
|
|
4
4
|
"description": "OCS Management — the git-based CMS core for Next.js. Built by Orhan Code Studio.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Orhan Code Studio (https://orhancodestudio.com)",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Block } from "../blocks/block.types";
|
|
1
2
|
import type { OcsmConfig, ResolvedOcsmConfig } from "../config/config.types";
|
|
2
3
|
import { resolveOcsmConfig } from "../config/resolve-config";
|
|
3
4
|
import type { ContentStore } from "../content/content-store.interface";
|
|
@@ -6,41 +7,63 @@ import type {
|
|
|
6
7
|
ContentDocumentMeta,
|
|
7
8
|
} from "../content/content.types";
|
|
8
9
|
import { createContentStore } from "../content/create-content-store";
|
|
9
|
-
import { LayoutStore } from "../layout/layout-store";
|
|
10
|
+
import { type LayoutRegion, LayoutStore } from "../layout/layout-store";
|
|
10
11
|
import { MediaStore } from "../media/media-store";
|
|
11
12
|
import { RoleStore } from "../roles/role-store";
|
|
12
13
|
import { createFileBackend } from "../storage/create-file-backend";
|
|
14
|
+
import { FsFileBackend } from "../storage/fs-file-backend";
|
|
13
15
|
import { JsonStore } from "../storage/json-store";
|
|
14
16
|
import { ThemeStore } from "../theme/theme-store";
|
|
17
|
+
import type { OcsmTheme } from "../theme/theme.types";
|
|
15
18
|
import { UserStore } from "../users/user-store";
|
|
16
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Read-only content access that always reads from the **local filesystem** (the
|
|
22
|
+
* repository checkout), regardless of the GitHub env. Use this for the public
|
|
23
|
+
* site so the production build/render never depends on the GitHub API — content
|
|
24
|
+
* is baked from the committed files and refreshed on each rebuild.
|
|
25
|
+
*/
|
|
26
|
+
export interface PublicReader {
|
|
27
|
+
listDocuments(collection: string): Promise<ContentDocumentMeta[]>;
|
|
28
|
+
getDocument(collection: string, slug: string): Promise<ContentDocument | null>;
|
|
29
|
+
getLayout(region: LayoutRegion): Promise<Block[]>;
|
|
30
|
+
getTheme(): Promise<OcsmTheme>;
|
|
31
|
+
}
|
|
32
|
+
|
|
17
33
|
/** A configured OCS Management instance, bound to a config and storage backend. */
|
|
18
34
|
export interface Ocsm {
|
|
19
35
|
/** The fully-resolved configuration. */
|
|
20
36
|
readonly config: ResolvedOcsmConfig;
|
|
21
|
-
/**
|
|
37
|
+
/** Live content access (GitHub in production) — for the editor and writes. */
|
|
22
38
|
readonly store: ContentStore;
|
|
23
39
|
/** User management. */
|
|
24
40
|
readonly users: UserStore;
|
|
25
41
|
/** Role & permission management. */
|
|
26
42
|
readonly roles: RoleStore;
|
|
27
|
-
/** Public-site theme. */
|
|
43
|
+
/** Public-site theme (live backend). */
|
|
28
44
|
readonly theme: ThemeStore;
|
|
29
|
-
/** Global header/footer sections shared across every page. */
|
|
45
|
+
/** Global header/footer sections shared across every page (live backend). */
|
|
30
46
|
readonly layout: LayoutStore;
|
|
31
|
-
/** Uploaded media (images) storage. */
|
|
47
|
+
/** Uploaded media (images) storage (live backend). */
|
|
32
48
|
readonly media: MediaStore;
|
|
33
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Filesystem-only reader for the public site. Decouples the build from GitHub:
|
|
51
|
+
* public pages read the checked-out files, not the API.
|
|
52
|
+
*/
|
|
53
|
+
readonly public: PublicReader;
|
|
54
|
+
/** Lists documents in a collection (live backend). */
|
|
34
55
|
listDocuments(collection: string): Promise<ContentDocumentMeta[]>;
|
|
35
|
-
/** Reads a single document, or `null` if it does not exist. */
|
|
56
|
+
/** Reads a single document, or `null` if it does not exist (live backend). */
|
|
36
57
|
getDocument(collection: string, slug: string): Promise<ContentDocument | null>;
|
|
37
58
|
}
|
|
38
59
|
|
|
39
60
|
/**
|
|
40
61
|
* Creates an {@link Ocsm} instance from an author-supplied config. Call once in a
|
|
41
|
-
* server-only module and reuse the returned instance across the app.
|
|
42
|
-
*
|
|
43
|
-
* GitHub in production)
|
|
62
|
+
* server-only module and reuse the returned instance across the app.
|
|
63
|
+
*
|
|
64
|
+
* The **live backend** (filesystem in dev, GitHub in production) powers the
|
|
65
|
+
* editor's live reads and all writes. A separate **filesystem reader**
|
|
66
|
+
* ({@link Ocsm.public}) serves the public site so the build never calls GitHub.
|
|
44
67
|
*
|
|
45
68
|
* @example
|
|
46
69
|
* ```ts
|
|
@@ -53,10 +76,19 @@ export interface Ocsm {
|
|
|
53
76
|
*/
|
|
54
77
|
export function createOcsm(config: OcsmConfig): Ocsm {
|
|
55
78
|
const resolved = resolveOcsmConfig(config);
|
|
79
|
+
|
|
80
|
+
// Live backend: GitHub in production, filesystem in dev.
|
|
56
81
|
const backend = createFileBackend();
|
|
57
82
|
const store = createContentStore(resolved, backend);
|
|
58
83
|
const json = new JsonStore(backend);
|
|
59
84
|
|
|
85
|
+
// Public reader: always the local filesystem (the repo checkout).
|
|
86
|
+
const fsBackend = new FsFileBackend();
|
|
87
|
+
const publicStore = createContentStore(resolved, fsBackend);
|
|
88
|
+
const publicJson = new JsonStore(fsBackend);
|
|
89
|
+
const publicLayout = new LayoutStore(publicJson);
|
|
90
|
+
const publicTheme = new ThemeStore(publicJson);
|
|
91
|
+
|
|
60
92
|
return {
|
|
61
93
|
config: resolved,
|
|
62
94
|
store,
|
|
@@ -65,6 +97,12 @@ export function createOcsm(config: OcsmConfig): Ocsm {
|
|
|
65
97
|
theme: new ThemeStore(json),
|
|
66
98
|
layout: new LayoutStore(json),
|
|
67
99
|
media: new MediaStore(backend),
|
|
100
|
+
public: {
|
|
101
|
+
listDocuments: (collection) => publicStore.list(collection),
|
|
102
|
+
getDocument: (collection, slug) => publicStore.read(collection, slug),
|
|
103
|
+
getLayout: (region) => publicLayout.get(region),
|
|
104
|
+
getTheme: () => publicTheme.get(),
|
|
105
|
+
},
|
|
68
106
|
listDocuments: (collection) => store.list(collection),
|
|
69
107
|
getDocument: (collection, slug) => store.read(collection, slug),
|
|
70
108
|
};
|
package/src/server/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createOcsm, type Ocsm } from "./create-ocsm";
|
|
1
|
+
export { createOcsm, type Ocsm, type PublicReader } from "./create-ocsm";
|
|
2
2
|
export { deleteDocument, writeDocument } from "./documents";
|
|
3
3
|
export { handleMediaRequest } from "./media-route";
|
|
4
4
|
export { OcsmContent, type OcsmContentProps } from "./render-mdx";
|
package/src/version.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* update checker ({@link ./update/check-for-updates}) and the admin "update available"
|
|
6
6
|
* notice.
|
|
7
7
|
*/
|
|
8
|
-
export const OCSM_VERSION = "0.1.0-alpha.
|
|
8
|
+
export const OCSM_VERSION = "0.1.0-alpha.3";
|
|
9
9
|
|
|
10
10
|
/** The published npm package name for the OCS Management core. */
|
|
11
11
|
export const OCSM_PACKAGE_NAME = "@orhancodestudio/ocsm-core";
|