@contentrail/astro 0.0.0-stage → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ContentRail contributors
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,51 @@
1
- # Temporary Holding Version
1
+ # `@contentrail/astro`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Build-time helpers for loading ContentRail local JSON content in Astro.
4
+
5
+ **Supported / tested:** Astro **7.3.8** (peer `astro@^7.3.3`) on Node.js **≥ 22.12.0**.
6
+
7
+ Astro 5.x is **not** a supported peer. Official advisories including critical
8
+ [GHSA-26w7-cxv4-gfx2](https://github.com/advisories/GHSA-26w7-cxv4-gfx2)
9
+ (AVIF / Sharp RCE) list affected range `< 7.2.8`. ContentRail does not claim
10
+ Astro 5 is secure. See ADR 024 and `docs/RELEASE_READINESS_8A.md` § Phase 8A.2.
11
+
12
+ Consumers who enable Astro’s default Sharp image service must keep Astro (and
13
+ its Sharp optional dependency) on patched releases. ContentRail’s helper only
14
+ reads local JSON; it does not disable Sharp.
15
+
16
+ ## Install
17
+
18
+ ### Monorepo
19
+
20
+ ```sh
21
+ pnpm install
22
+ pnpm --filter @contentrail/astro build
23
+ ```
24
+
25
+ ### From npm (upcoming `0.2.0` after authorized publish)
26
+
27
+ ```sh
28
+ pnpm add @contentrail/core@0.2.0 @contentrail/reader@0.2.0 @contentrail/astro@0.2.0 zod@^4.6.7
29
+ pnpm add -D astro@^7.3.3
30
+ ```
31
+
32
+ ## Workflow
33
+
34
+ 1. Define a collection with `@contentrail/core`.
35
+ 2. Add JSON files under `{rootDir}/{collection}/`.
36
+ 3. Call `createContentRail` from Astro frontmatter or `getStaticPaths`.
37
+ 4. Build with `astro build`. Invalid content fails the build.
38
+
39
+ ```ts
40
+ import path from "node:path";
41
+ import { createContentRail } from "@contentrail/astro";
42
+ import { articles } from "../content/config";
43
+
44
+ // Prefer process.cwd() for content roots. Astro 7 prerender bundles modules
45
+ // under dist/.prerender/, so import.meta.url-relative paths often break.
46
+ const rootDir = path.join(process.cwd(), "content");
47
+ const rail = await createContentRail({ rootDir });
48
+ const entries = await rail.loadCollection(articles);
49
+ ```
50
+
51
+ This package re-exports the Node reader. Do not import it from client-side scripts.
@@ -0,0 +1,19 @@
1
+ import type { ContentCollection } from "@contentrail/core";
2
+ import { ContentReadError, createLocalJsonSource, loadCollection, loadEntry, type LoadCollectionOptions, type LocalJsonSource } from "@contentrail/reader";
3
+ export interface ContentRailOptions {
4
+ /** Absolute or process-relative path to the content root directory. */
5
+ readonly rootDir: string;
6
+ }
7
+ export interface ContentRail {
8
+ readonly source: LocalJsonSource;
9
+ loadEntry: <TCollection extends ContentCollection>(collection: TCollection, id: string) => ReturnType<typeof loadEntry<TCollection>>;
10
+ loadCollection: <TCollection extends ContentCollection>(collection: TCollection, options?: LoadCollectionOptions) => ReturnType<typeof loadCollection<TCollection>>;
11
+ }
12
+ /**
13
+ * Creates a build-time ContentRail helper for Astro pages and `getStaticPaths`.
14
+ * Uses the local JSON reader. Not for browser bundles.
15
+ */
16
+ export declare function createContentRail(options: ContentRailOptions): Promise<ContentRail>;
17
+ export { ContentReadError, createLocalJsonSource, loadCollection, loadEntry };
18
+ export type { LoadCollectionOptions, LocalJsonSource };
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,SAAS,EACT,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACrB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IACjC,SAAS,EAAE,CAAC,WAAW,SAAS,iBAAiB,EAC/C,UAAU,EAAE,WAAW,EACvB,EAAE,EAAE,MAAM,KACP,UAAU,CAAC,OAAO,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/C,cAAc,EAAE,CAAC,WAAW,SAAS,iBAAiB,EACpD,UAAU,EAAE,WAAW,EACvB,OAAO,CAAC,EAAE,qBAAqB,KAC5B,UAAU,CAAC,OAAO,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC;CACrD;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,WAAW,CAAC,CAQtB;AAED,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC;AAE9E,YAAY,EAAE,qBAAqB,EAAE,eAAe,EAAE,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ import { ContentReadError, createLocalJsonSource, loadCollection, loadEntry, } from "@contentrail/reader";
2
+ /**
3
+ * Creates a build-time ContentRail helper for Astro pages and `getStaticPaths`.
4
+ * Uses the local JSON reader. Not for browser bundles.
5
+ */
6
+ export async function createContentRail(options) {
7
+ const source = await createLocalJsonSource({ rootDir: options.rootDir });
8
+ return {
9
+ source,
10
+ loadEntry: (collection, id) => loadEntry(source, collection, id),
11
+ loadCollection: (collection, loadOptions) => loadCollection(source, collection, loadOptions),
12
+ };
13
+ }
14
+ export { ContentReadError, createLocalJsonSource, loadCollection, loadEntry };
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,SAAS,GAGV,MAAM,qBAAqB,CAAC;AAmB7B;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAA2B;IAE3B,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACzE,OAAO;QACL,MAAM;QACN,SAAS,EAAE,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,CAAC;QAChE,cAAc,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,EAAE,CAC1C,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC;KAClD,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "@contentrail/astro",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0",
4
+ "private": false,
5
+ "type": "module",
6
+ "description": "Astro build-time helpers for ContentRail local JSON content.",
7
+ "license": "MIT",
8
+ "engines": {
9
+ "node": ">=22.12.0"
10
+ },
11
+ "sideEffects": false,
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js",
16
+ "node": "./dist/index.js"
17
+ },
18
+ "./package.json": "./package.json"
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "README.md",
23
+ "LICENSE"
24
+ ],
25
+ "dependencies": {
26
+ "@contentrail/core": "0.2.0",
27
+ "@contentrail/reader": "0.2.0"
28
+ },
29
+ "peerDependencies": {
30
+ "astro": "^7.3.3"
31
+ },
32
+ "peerDependenciesMeta": {
33
+ "astro": {
34
+ "optional": true
35
+ }
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "^22.20.5",
39
+ "astro": "7.3.8",
40
+ "typescript": "5.9.3"
41
+ },
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "https://github.com/Hridhin-k/contentrail.git",
45
+ "directory": "packages/astro"
46
+ },
47
+ "bugs": {
48
+ "url": "https://github.com/Hridhin-k/contentrail/issues"
49
+ },
50
+ "homepage": "https://github.com/Hridhin-k/contentrail#readme",
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "scripts": {
55
+ "build": "tsc -p tsconfig.json",
56
+ "typecheck": "tsc -p tsconfig.json --noEmit",
57
+ "test": "pnpm run build && tsc -p tsconfig.test.json && node --test test-dist/**/*.test.js"
58
+ }
6
59
  }