@antelopejs/dms-frontend 0.0.1 → 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/README.md CHANGED
@@ -6,7 +6,44 @@
6
6
  <a href="https://antelopejs.com"><img src="https://img.shields.io/badge/Docs-18181B?style=for-the-badge&color=000000" alt="Documentation"></a>
7
7
  </div>
8
8
 
9
- Official Vue 3, Vite, Inertia, and SSR frontend loader for AntelopeJS DMS. The `ajs dms` CLI generates a Vue workspace and runs its Node frontend server.
9
+ Frontend-agnostic loader for AntelopeJS DMS. The backend serves a frontend
10
+ manifest and the matching frontend-module archives; the `ajs dms` CLI
11
+ materializes them into a generated workspace for one renderer, builds it, and
12
+ runs its Node frontend server. The `vue` renderer — Vue 3, Vite, Inertia, and
13
+ SSR — is the one shipped today.
14
+
15
+ ## Renderers
16
+
17
+ A renderer is the target framework a generated workspace is built for. The
18
+ loader's contract with a renderer has three parts:
19
+
20
+ - **Manifest negotiation.** `prepare`, `dev`, and `build` request the versioned
21
+ `/dms/frontend` manifest with `renderer=vue&rendererVersion=3`
22
+ (`src/manifest.ts`) and reject every module whose `renderer` does not match.
23
+ The backend side is renderer-keyed too: `AddFrontendModule` takes a
24
+ `renderer: { name, version }`, and each manifest module carries it back
25
+ (`ManifestModule.renderer` in `src/workspace.ts`).
26
+ - **Workspace templates.** Every file of the generated workspace comes from
27
+ `templates/<renderer>/` — `templates/vue/` today. `TEMPLATE_FILES` in
28
+ `src/config.ts` lists what is copied verbatim, and `src/materialize.ts`
29
+ resolves the template root, copies it, materializes the frontend modules
30
+ under `frontend-modules/`, and writes `generated-frontend-modules.json` in
31
+ manifest-priority order.
32
+ - **Generated server.** `templates/vue/server.mjs` and `templates/vue/server/`
33
+ become the Node server that `ajs dms start` runs from the built workspace:
34
+ Inertia visits, backend proxying, sessions, and email rendering.
35
+
36
+ `vue` (version `3`) is the only renderer this package ships, and the loader
37
+ rejects a manifest that declares any other. Renderers for other frameworks —
38
+ React, Svelte, Solid — are a direction, not a promise: nothing in the package
39
+ implements them yet. Adding one means a new `templates/<renderer>/` tree, plus
40
+ making the template root (`src/materialize.ts`) and the manifest query
41
+ (`src/manifest.ts`) renderer-aware instead of hardcoding `vue`. There is no
42
+ `--renderer` flag and no renderer registry; the single-renderer assumption is
43
+ deliberate until a second renderer exists. Whatever a renderer names its module
44
+ entry is its own convention: `dms.frontend.ts` and the
45
+ `#dms-inertia/frontend-module` alias belong to the Vue renderer, not to the
46
+ loader.
10
47
 
11
48
  ## Application ownership
12
49
 
@@ -56,13 +93,13 @@ throttle stamp lives at `~/.antelopejs/dms-frontend/update-check.json`. Set
56
93
  `NO_UPDATE_NOTIFIER=1`, pass `--no-update-check`, or run under `CI` to turn the
57
94
  check off.
58
95
 
59
- The loader renders Vue 3 only: a manifest that declares any other renderer is rejected. `prepare`, `dev`, and `build` request the versioned `/dms/frontend` manifest with `renderer=vue&rendererVersion=3`. Modules are materialized under `frontend-modules/` and registered in deterministic manifest-priority order in `generated-frontend-modules.json`.
96
+ Manifest negotiation and module materialization are the renderer contract described in [Renderers](#renderers).
60
97
 
61
- The generated application uses `@inertiajs/vue3`, `@nuxt/ui/vite` with `{ router: "inertia" }`, and `@nuxt/ui/vue-plugin`. The Node server resolves each Inertia visit through `/dms/page?path=…`, including fresh shared data so account, tenant, and permission changes update navigation state. It proxies backend routes and manages authentication through server-side sessions. `DMS_BOOTSTRAP_SECRET` is used only by the CLI's server-to-server frontend manifest and module archive requests and is never sent by, or exposed to, browser traffic.
98
+ The generated Vue application uses `@inertiajs/vue3`, `@nuxt/ui/vite` with `{ router: "inertia" }`, and `@nuxt/ui/vue-plugin`. The Node server resolves each Inertia visit through `/dms/page?path=…`, including fresh shared data so account, tenant, and permission changes update navigation state. It proxies backend routes and manages authentication through server-side sessions. `DMS_BOOTSTRAP_SECRET` is used only by the CLI's server-to-server frontend manifest and module archive requests and is never sent by, or exposed to, browser traffic.
62
99
 
63
100
  Vue modules use `dms.frontend.ts` and the `#dms-inertia/frontend-module` SDK alias, which replaces the former `#cms-inertia` alias and is the import path every DMS frontend module now uses. Email templates register separately through `dms.email.ts`.
64
101
 
65
- An email entry exports `serverEmailTemplates` and may export a plain `appConfig` object, such as shared branding defaults. Email rendering merges these configurations in manifest-priority order and provides them to `useDmsAppConfig` per render. Public runtime options come from the module manifest; `DMS_CLIENT_URL` overrides `public.dms.clientBaseUrl`. Email entries must not import the browser frontend module.
102
+ An email entry exports `serverEmailTemplates` and may export a plain `appConfig` object, such as shared branding defaults. Email rendering merges these configurations in manifest-priority order and provides them to `useDmsAppConfig` per render. Public runtime options come from the module manifest; `DMS_CLIENT_BASE_URL` overrides `public.dms.clientBaseUrl`. Email entries must not import the browser frontend module.
66
103
 
67
104
  Email builds ship complete merged translation catalogs as JSON under `dist/server/locales/`, separate from executable JavaScript. Deploy the entire `dist/server` directory. Each render loads only its requested language and the English fallback; arbitrary translation keys and module overrides remain available. Unknown languages fall back to English, while missing or corrupt files for a supported language fail rendering rather than silently dropping translations. The source harness keeps the 256 KiB JavaScript ceiling and reports locale-data bytes separately.
68
105
 
@@ -89,7 +126,7 @@ The SDK also exposes `use` for Vue plugins. Entries execute by descending manife
89
126
 
90
127
  ## Discovery, caching, and security
91
128
 
92
- In development, `ajs dms` discovers the backend from the nearest live `.antelope/dev.json`. It reads the local bootstrap credential from `.antelope/dms-dev.json` only when that discovered backend matches the destination URL. For production and CI, set `DMS_BACKEND_URL` and `DMS_BOOTSTRAP_SECRET` in the environment rather than passing credentials on the command line.
129
+ In development, `ajs dms` discovers the backend from the nearest live `.antelope/dev.json`. It reads the local bootstrap credential from `.antelope/dms-dev.json` only when that discovered backend matches the destination URL. For production and CI, set `DMS_API_BASE_URL` and `DMS_BOOTSTRAP_SECRET` in the environment rather than passing credentials on the command line.
93
130
 
94
131
  Each canonical backend URL gets an owner-only workspace under `~/.antelopejs/dms-frontend`. Manifest caches, private module configuration, and extracted archives retain restrictive permissions. `--offline` reuses the last successful manifest and archive; an authorization failure never falls back to privileged cached data.
95
132
 
@@ -105,7 +142,7 @@ frontend-module registry drives server and client entries.
105
142
 
106
143
  | Option | Environment | Purpose |
107
144
  | --- | --- | --- |
108
- | `-b, --backend-url` | `DMS_BACKEND_URL` | DMS backend URL |
145
+ | `-b, --backend-url` | `DMS_API_BASE_URL` | DMS backend URL |
109
146
  | `-p, --port` | `PORT` | Frontend port, default `3001` |
110
147
  | `-f, --force` | | Reinstall workspace dependencies |
111
148
  | `--offline` | `DMS_OFFLINE` | Reuse cached manifest and archives |
@@ -18,7 +18,7 @@ function cmdBuild() {
18
18
  .addOption(common_1.Options.bootstrapSecret)
19
19
  .action(async (options) => {
20
20
  if (!options.backendUrl) {
21
- (0, cli_ui_1.error)("Backend URL is required. Use -b <url> or set DMS_BACKEND_URL.");
21
+ (0, cli_ui_1.error)("Backend URL is required. Use -b <url> or set DMS_API_BASE_URL.");
22
22
  process.exit(1);
23
23
  }
24
24
  const spinner = new cli_ui_1.Spinner("Setting up workspace...");
@@ -99,7 +99,7 @@ function cmdDev() {
99
99
  PORT: String(port),
100
100
  DMS_DEV: "true",
101
101
  DMS_COOKIE_SECURE: process.env.DMS_COOKIE_SECURE ?? "false",
102
- DMS_BACKEND_URL: backendUrl,
102
+ DMS_API_BASE_URL: backendUrl,
103
103
  DMS_BOOTSTRAP_SECRET: bootstrapSecret,
104
104
  NODE_OPTIONS: "--max-old-space-size=4096",
105
105
  NODE_PATH: nodeModulesDir,
@@ -17,7 +17,7 @@ function cmdPrepare() {
17
17
  .addOption(common_1.Options.bootstrapSecret)
18
18
  .action(async (options) => {
19
19
  if (!options.backendUrl) {
20
- (0, cli_ui_1.warning)("Backend URL not set; skipping prepare. Pass -b <url> or set DMS_BACKEND_URL to generate types.");
20
+ (0, cli_ui_1.warning)("Backend URL not set; skipping prepare. Pass -b <url> or set DMS_API_BASE_URL to generate types.");
21
21
  process.exit(0);
22
22
  }
23
23
  const spinner = new cli_ui_1.Spinner("Setting up workspace...");
@@ -17,7 +17,7 @@ function cmdStart() {
17
17
  .addOption(common_1.Options.port)
18
18
  .action(async (options) => {
19
19
  if (!options.backendUrl) {
20
- (0, cli_ui_1.error)("Backend URL is required. Use -b <url> or set DMS_BACKEND_URL.");
20
+ (0, cli_ui_1.error)("Backend URL is required. Use -b <url> or set DMS_API_BASE_URL.");
21
21
  process.exit(1);
22
22
  }
23
23
  const workspaceDir = (0, common_1.getWorkspaceDir)(options.backendUrl);
@@ -40,7 +40,7 @@ function cmdStart() {
40
40
  env: {
41
41
  ...process.env,
42
42
  PORT: options.port,
43
- DMS_BACKEND_URL: options.backendUrl,
43
+ DMS_API_BASE_URL: options.backendUrl,
44
44
  DMS_COOKIE_SECURE: process.env.DMS_COOKIE_SECURE ?? "true",
45
45
  },
46
46
  });
package/dist/config.js CHANGED
@@ -83,7 +83,7 @@ function booleanFromEnv(name) {
83
83
  return !["", "0", "false", "no", "off"].includes(value.trim().toLowerCase());
84
84
  }
85
85
  exports.Options = {
86
- backendUrl: new commander_1.Option("-b, --backend-url <url>", "Backend DMS URL (when omitted, dev mode discovers it from the enclosing antelope project's .antelope/dev.json)").env("DMS_BACKEND_URL"),
86
+ backendUrl: new commander_1.Option("-b, --backend-url <url>", "Backend DMS URL (when omitted, dev mode discovers it from the enclosing antelope project's .antelope/dev.json)").env("DMS_API_BASE_URL"),
87
87
  port: new commander_1.Option("-p, --port <port>", "Port to run on")
88
88
  .default("3001")
89
89
  .env("PORT"),
package/dist/discovery.js CHANGED
@@ -82,7 +82,7 @@ function describeDiscoveryFailure(result) {
82
82
  return ("No backend URL provided and no running antelope project found.\n" +
83
83
  ` Searched for ${exports.DEV_REGISTRY_RELATIVE_PATH} from the current directory upward.\n` +
84
84
  " Either run this command inside an antelope project started with 'ajs project dev',\n" +
85
- " or pass the backend explicitly with -b <url> (env: DMS_BACKEND_URL).");
85
+ " or pass the backend explicitly with -b <url> (env: DMS_API_BASE_URL).");
86
86
  case "stale":
87
87
  return (`Found ${(0, node_path_1.join)(result.projectDir, exports.DEV_REGISTRY_RELATIVE_PATH)} but its process (pid ${result.pid}) is no longer running.\n` +
88
88
  " Start the backend with 'ajs project dev', or pass -b <url> explicitly.");
package/dist/index.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antelopejs/dms-frontend",
3
- "version": "0.0.1",
4
- "description": "Vue 3, Vite, and Inertia frontend loader for AntelopeJS DMS",
3
+ "version": "0.1.1",
4
+ "description": "Frontend-agnostic loader for AntelopeJS DMS, shipping the Vue 3 renderer (Vite, Inertia, SSR)",
5
5
  "keywords": [
6
6
  "antelope",
7
7
  "antelopejs",
@@ -10,6 +10,7 @@
10
10
  "frontend-modules",
11
11
  "inertia",
12
12
  "loader",
13
+ "renderer",
13
14
  "ui",
14
15
  "vite",
15
16
  "vue"
@@ -31,6 +32,19 @@
31
32
  "provenance": true,
32
33
  "registry": "https://registry.npmjs.org/"
33
34
  },
35
+ "scripts": {
36
+ "build": "rimraf dist && tsc -p tsconfig.build.json",
37
+ "prepack": "pnpm run build",
38
+ "release": "pnpm run lint && pnpm run test && pnpm run prepack && release-it",
39
+ "test": "node --import tsx --test tests/*.test.ts tests/*.test.mts",
40
+ "test:real-source": "pnpm run build && node dist/verify-source-runner.js",
41
+ "format": "oxfmt .",
42
+ "lint": "oxlint && oxfmt --check .",
43
+ "typecheck": "tsc -p tsconfig.json",
44
+ "lint:fix": "oxlint --fix --max-warnings=1000000 && oxfmt .",
45
+ "knip": "knip --dependencies",
46
+ "knip:all": "knip"
47
+ },
34
48
  "dependencies": {
35
49
  "boxen": "^5.1.2",
36
50
  "chalk": "^4.1.2",
@@ -68,7 +82,7 @@
68
82
  "vue-i18n": "^11.1.12"
69
83
  },
70
84
  "peerDependencies": {
71
- "@antelopejs/core": ">=1.5.0 <2"
85
+ "@antelopejs/core": ">=1.6.0 <2"
72
86
  },
73
87
  "peerDependenciesMeta": {
74
88
  "@antelopejs/core": {
@@ -82,16 +96,5 @@
82
96
  "@oxc-parser/binding-linux-x64-gnu": "^0.95.0",
83
97
  "@oxc-parser/binding-win32-x64-msvc": "^0.95.0"
84
98
  },
85
- "scripts": {
86
- "build": "rimraf dist && tsc -p tsconfig.build.json",
87
- "release": "pnpm run lint && pnpm run test && pnpm run prepack && release-it",
88
- "test": "node --import tsx --test tests/*.test.ts tests/*.test.mts",
89
- "test:real-source": "pnpm run build && node dist/verify-source-runner.js",
90
- "format": "oxfmt .",
91
- "lint": "oxlint && oxfmt --check .",
92
- "typecheck": "tsc -p tsconfig.json",
93
- "lint:fix": "oxlint --fix --max-warnings=1000000 && oxfmt .",
94
- "knip": "knip --dependencies",
95
- "knip:all": "knip"
96
- }
97
- }
99
+ "packageManager": "pnpm@10.6.5"
100
+ }
@@ -147,8 +147,8 @@ export async function renderEmail(
147
147
  );
148
148
  app.provide("dmsEmailRuntimeConfig", {
149
149
  public: defu(
150
- process.env.DMS_CLIENT_URL
151
- ? { dms: { clientBaseUrl: process.env.DMS_CLIENT_URL } }
150
+ process.env.DMS_CLIENT_BASE_URL
151
+ ? { dms: { clientBaseUrl: process.env.DMS_CLIENT_BASE_URL } }
152
152
  : {},
153
153
  publicConfig,
154
154
  { dms: { clientBaseUrl: "" } },
@@ -12,7 +12,7 @@ export function useDmsAppConfig(): Record<string, unknown> {
12
12
 
13
13
  export function useDmsRuntimeConfig(): EmailRuntimeConfig {
14
14
  return inject<EmailRuntimeConfig>("dmsEmailRuntimeConfig", {
15
- public: { dms: { clientBaseUrl: process.env.DMS_CLIENT_URL ?? "" } },
15
+ public: { dms: { clientBaseUrl: process.env.DMS_CLIENT_BASE_URL ?? "" } },
16
16
  });
17
17
  }
18
18
 
@@ -34,7 +34,7 @@ export async function backend(path, request, options = {}) {
34
34
  if (options.relay)
35
35
  headers["x-dms-oauth-relay"] = process.env.DMS_OAUTH_RELAY_SECRET ?? "";
36
36
  if (options.body !== undefined) headers["content-type"] = "application/json";
37
- const response = await fetch(new URL(path, process.env.DMS_BACKEND_URL), {
37
+ const response = await fetch(new URL(path, process.env.DMS_API_BASE_URL), {
38
38
  method: options.method ?? "GET",
39
39
  headers,
40
40
  body: options.body === undefined ? undefined : JSON.stringify(options.body),
@@ -71,7 +71,7 @@ function targetUrl(path) {
71
71
  )
72
72
  return invalidInput();
73
73
  path.split("?", 1)[0].split("/").forEach(validatePathSegment);
74
- const base = new URL(process.env.DMS_BACKEND_URL);
74
+ const base = new URL(process.env.DMS_API_BASE_URL);
75
75
  if (
76
76
  !["http:", "https:"].includes(base.protocol) ||
77
77
  base.username ||
@@ -142,14 +142,14 @@ function serverComponentFetch(request) {
142
142
  });
143
143
  return ofetch(path, {
144
144
  ...options,
145
- baseURL: process.env.DMS_BACKEND_URL,
145
+ baseURL: process.env.DMS_API_BASE_URL,
146
146
  headers,
147
147
  });
148
148
  };
149
149
  }
150
150
 
151
151
  async function backendJson(path, request) {
152
- const response = await fetch(new URL(path, process.env.DMS_BACKEND_URL), {
152
+ const response = await fetch(new URL(path, process.env.DMS_API_BASE_URL), {
153
153
  headers: backendHeaders(request),
154
154
  });
155
155
  if (!response.ok) {
@@ -245,7 +245,7 @@ async function proxy(request, response, fallbackOnNotFound = false) {
245
245
  response.end(JSON.stringify({ error: "Forbidden" }));
246
246
  return true;
247
247
  }
248
- const target = new URL(request.url, process.env.DMS_BACKEND_URL);
248
+ const target = new URL(request.url, process.env.DMS_API_BASE_URL);
249
249
  const upstream = await fetch(target, {
250
250
  method: request.method,
251
251
  headers: backendHeaders(request),