@openpolicy/astro 0.0.9 → 0.0.10

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.
Files changed (2) hide show
  1. package/README.md +75 -0
  2. package/package.json +4 -4
package/README.md ADDED
@@ -0,0 +1,75 @@
1
+ # `@openpolicy/astro`
2
+
3
+ > Astro integration for compiling [OpenPolicy](https://openpolicy.sh) policy documents at build time.
4
+
5
+ A first-class Astro integration that compiles `definePrivacyPolicy()` and `defineTermsOfService()` configs to Markdown or HTML — on every build and on save in dev mode. Delegates to `@openpolicy/vite` under the hood.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ # Recommended — auto-updates astro.config.mjs
11
+ npx astro add @openpolicy/astro
12
+
13
+ # Also install the SDK for defining policies
14
+ bun add @openpolicy/sdk
15
+ ```
16
+
17
+ Or manually:
18
+
19
+ ```sh
20
+ bun add -D @openpolicy/astro @openpolicy/vite
21
+ bun add @openpolicy/sdk
22
+ ```
23
+
24
+ ## Setup
25
+
26
+ ```js
27
+ // astro.config.mjs
28
+ import { defineConfig } from "astro/config";
29
+ import { openPolicy } from "@openpolicy/astro";
30
+
31
+ export default defineConfig({
32
+ integrations: [
33
+ openPolicy({
34
+ configs: [
35
+ "privacy.config.ts",
36
+ { config: "terms.config.ts", type: "terms" },
37
+ ],
38
+ formats: ["markdown"],
39
+ outDir: "src/generated/policies",
40
+ }),
41
+ ],
42
+ });
43
+ ```
44
+
45
+ ## Options
46
+
47
+ | Option | Type | Default | Description |
48
+ |---|---|---|---|
49
+ | `configs` | `PolicyConfigEntry[]` | — | Policy configs to compile. Type is auto-detected from filename (`"terms"` → terms of service, otherwise privacy). Each entry is a path string or `{ config: string; type?: "privacy" \| "terms" }`. |
50
+ | `formats` | `OutputFormat[]` | `["markdown"]` | `"markdown"` or `"html"` |
51
+ | `outDir` | `string` | `"public/policies"` | Output directory, relative to the Astro root |
52
+
53
+ ## Using the output
54
+
55
+ Because the generated files land in `src/`, Astro can import them as Markdown components:
56
+
57
+ ```astro
58
+ ---
59
+ // src/pages/privacy.astro
60
+ import { Content } from "../../generated/policies/privacy-policy.md";
61
+ ---
62
+ <div class="prose">
63
+ <Content />
64
+ </div>
65
+ ```
66
+
67
+ ## Documentation
68
+
69
+ [openpolicy.sh/docs/getting-started/astro](https://openpolicy.sh/docs/getting-started/astro)
70
+
71
+ ## Links
72
+
73
+ - [GitHub](https://github.com/jamiedavenport/openpolicy)
74
+ - [openpolicy.sh](https://openpolicy.sh)
75
+ - [npm](https://www.npmjs.com/package/@openpolicy/astro)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpolicy/astro",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "description": "Astro integration for compiling OpenPolicy documents at build time",
6
6
  "license": "MIT",
@@ -32,9 +32,9 @@
32
32
  },
33
33
  "peerDependencies": {
34
34
  "astro": ">=4.0.0",
35
- "@openpolicy/vite": ">=0.0.9",
36
- "@openpolicy/sdk": ">=0.0.9",
37
- "@openpolicy/core": ">=0.0.9"
35
+ "@openpolicy/vite": ">=0.0.10",
36
+ "@openpolicy/sdk": ">=0.0.10",
37
+ "@openpolicy/core": ">=0.0.10"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@openpolicy/tooling": "workspace:*",