@aeratic/pagetailor 0.1.0 → 0.1.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/package.json CHANGED
@@ -1,17 +1,42 @@
1
1
  {
2
2
  "name": "@aeratic/pagetailor",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Pages as data: declarative YAML pages, typed data catalog, per-user overrides, validated for AI agents. Renders with json-render.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "bin": { "pagetailor": "bin/cli.js" },
7
+ "bin": {
8
+ "pagetailor": "bin/cli.js"
9
+ },
8
10
  "main": "./src/index.js",
9
- "exports": { ".": "./src/index.js", "./client": "./src/client.jsx" },
10
- "files": ["bin", "src", "templates", "README.md"],
11
- "engines": { "node": ">=20" },
12
- "keywords": ["server-driven-ui", "generative-ui", "declarative-ui", "json-render", "yaml", "personalization", "ai-agent"],
13
- "repository": { "type": "git", "url": "git+https://github.com/aeratic/pagetailor.git" },
14
- "publishConfig": { "access": "public" },
11
+ "exports": {
12
+ ".": "./src/index.js",
13
+ "./client": "./src/client.jsx"
14
+ },
15
+ "files": [
16
+ "bin",
17
+ "src",
18
+ "templates",
19
+ "README.md"
20
+ ],
21
+ "engines": {
22
+ "node": ">=20"
23
+ },
24
+ "keywords": [
25
+ "server-driven-ui",
26
+ "generative-ui",
27
+ "declarative-ui",
28
+ "json-render",
29
+ "yaml",
30
+ "personalization",
31
+ "ai-agent"
32
+ ],
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/aeratic/pagetailor.git"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
15
40
  "dependencies": {
16
41
  "@json-render/core": "0.21.1",
17
42
  "@json-render/react": "0.21.1",
@@ -19,6 +44,15 @@
19
44
  "yaml": "^2.6.0",
20
45
  "zod": "4.3.6"
21
46
  },
22
- "peerDependencies": { "react": ">=19.2.3", "react-dom": ">=19.2.3" },
23
- "devDependencies": { "react": "19.2.3", "react-dom": "19.2.3" }
47
+ "peerDependencies": {
48
+ "react": ">=19.2.3",
49
+ "react-dom": ">=19.2.3"
50
+ },
51
+ "devDependencies": {
52
+ "react": "19.2.3",
53
+ "react-dom": "19.2.3"
54
+ },
55
+ "scripts": {
56
+ "test": "node --no-deprecation --import ./test/jsx-loader.mjs --test test/"
57
+ }
24
58
  }
package/src/dev.js CHANGED
@@ -13,11 +13,13 @@ const here = dirname(fileURLToPath(import.meta.url));
13
13
 
14
14
  export async function dev(cwd, { port = 4747 } = {}) {
15
15
  const root = join(cwd, "pagetailor");
16
- const req = createRequire(join(cwd, "package.json"));
16
+ // Bundle one React only: the project's if installed, otherwise the one shipped with this package.
17
+ const reqProject = createRequire(join(cwd, "package.json")), reqSelf = createRequire(import.meta.url);
17
18
  const alias = {};
18
- for (const m of ["react", "react-dom", "react/jsx-runtime", "react-dom/client", "@json-render/react", "@json-render/core"]) {
19
- try { alias[m] = req.resolve(m); } catch {}
19
+ for (const m of ["react", "react-dom", "react/jsx-runtime", "react-dom/client"]) {
20
+ try { alias[m] = reqProject.resolve(m); } catch { try { alias[m] = reqSelf.resolve(m); } catch {} }
20
21
  }
22
+ const nodePaths = [join(cwd, "node_modules"), join(here, "..", "node_modules")];
21
23
 
22
24
  // one generated entry: imports every component from registry.yaml, mounts <Page>
23
25
  const entry = async () => {
@@ -60,7 +62,7 @@ createRoot(document.getElementById("root")).render(<App />);`;
60
62
 
61
63
  const ctx = await esbuild.context({
62
64
  stdin: { contents: await entry(), resolveDir: join(root, "components"), loader: "jsx", sourcefile: "pagetailor-entry.jsx" },
63
- bundle: true, write: false, format: "esm", jsx: "automatic", alias, outfile: "bundle.js", sourcemap: "inline", logLevel: "silent",
65
+ bundle: true, write: false, format: "esm", jsx: "automatic", alias, nodePaths, outfile: "bundle.js", sourcemap: "inline", logLevel: "silent",
64
66
  define: { "process.env.NODE_ENV": '"development"' },
65
67
  });
66
68
  let bundle = "", buildErrors = [];
package/src/resolver.js CHANGED
@@ -11,7 +11,7 @@ export async function resolve(root, page, { user, role, sources } = {}) {
11
11
  for (const ov of await loadOverrides(root, page, user, role)) {
12
12
  const r = applyOverride(tree, ov); tree = r.tree; errors.push(...r.errors);
13
13
  }
14
- errors.push(...validateTree(tree, project, { role }));
14
+ errors.push(...validateTree(tree, project, { role: role ?? null }));
15
15
  const byPath = new Map(); for (const e of errors) byPath.set(e.path, [...(byPath.get(e.path) ?? []), e.message]);
16
16
 
17
17
  const elements = {}, state = { data: {}, user: { id: user ?? null, role: role ?? null } };
package/src/validator.js CHANGED
@@ -24,7 +24,7 @@ export function validateTree(tree, project, { role } = {}) {
24
24
  const src = project.catalog[node.data.source];
25
25
  if (!src) errors.push({ path, message: `unknown data source "${node.data.source}"` });
26
26
  else {
27
- if (src.roles && !src.roles.includes("*") && !src.roles.includes(role))
27
+ if (role !== undefined && src.roles && !src.roles.includes("*") && !src.roles.includes(role))
28
28
  errors.push({ path, message: `role "${role ?? "none"}" cannot read "${node.data.source}"` });
29
29
  if (comp?.accepts && src.returns && !typeAccepts(comp.accepts, src.returns))
30
30
  errors.push({ path, message: `"${name}" accepts ${comp.accepts} but "${node.data.source}" returns ${src.returns}` });