@dokebi/app 0.4.1 → 0.4.2
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/AI.md +5 -4
- package/README.md +3 -2
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +103 -20
- package/package.json +7 -3
package/AI.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# AI guide — @dokebi/app 0.4.
|
|
1
|
+
# AI guide — @dokebi/app 0.4.2
|
|
2
2
|
|
|
3
|
-
A plugin for several apps in one project that **picks the app and template by request domain** (D-0030). One app is one folder `src/apps/<app>/`, defined with `defineApp`. Node >=24.0.0, core ^0.4.0, web ^0.4.
|
|
3
|
+
A plugin for several apps in one project that **picks the app and template by request domain** (D-0030). One app is one folder `src/apps/<app>/`, defined with `defineApp`. Node >=24.0.0, core ^0.4.0, web ^0.4.2; @dokebi/session optional (0.4.1: a refused HTML form goes back to its page, §4). The human-oriented description is the [README](README.md).
|
|
4
4
|
|
|
5
5
|
## 1. Install and what it creates
|
|
6
6
|
|
|
@@ -84,7 +84,7 @@ export default defineApp({
|
|
|
84
84
|
- `view`: the EJS renderer. Lookup order `<app>/<template>` → `<app>/default` → `src/shared/views` (layouts and `$include` too). Every page's data also has `errors`, `old` and `flash` (0.4.1, below), always objects.
|
|
85
85
|
- `inertia`: an Inertia renderer with the app's document settings (when the app has `inertia`). It adds `app` (`{ name, template, domain }`) and `sealed` to the shared props.
|
|
86
86
|
- `sealed`: whether the request host has `seal: true`. EJS data gets it as `sealed` too (the app's `shared` and the page data win).
|
|
87
|
-
- `app` (AppContext): `name`, `logger`, `signal`, `get`, `getDependency`, `getOptionalDependency`, `controller`, `defer`, `realtime(namespace?)` (§4 realtime namespaces). **Reading something not in `requires` is an error** (`NOT_REQUIRED`: `App <app> does not list <plugin> in requires`). Controller factories have the same limit.
|
|
87
|
+
- `app` (AppContext): `name`, `logger`, `signal`, `get`, `getDependency`, `getOptionalDependency`, `controller`, `defer`, `realtime(namespace?)` (§4 realtime namespaces). **Reading something not in `requires` is an error** (`NOT_REQUIRED`: `App <app> does not list <plugin> in requires`). Controller factories have the same limit. When several apps require the same plugin, dokebi-app declares it once to core with every distinct range joined (`^1.0.0 ^1.2.0`, so the provider must satisfy each app), required when any app requires it, with the first factory (`create`) given. Ranges that cannot meet (`^1.0.0` and `^2.0.0`) are refused at `createPlugin` with `DEPENDENCY_CONFLICT` naming both apps.
|
|
88
88
|
- `inertia.ssr: { bundle: 'dist/ssr/<app>/ssr.js' }` renders the first HTML on the server (D-0039, see the template-inertia AI.md).
|
|
89
89
|
- `inertia.errorPage: 'Error'` renders that page component for the error answers of this app's Inertia visits and page loads (D-0074; `false` turns off a plugin-level default). The `app add --inertia` skeleton sets it and creates `views/default/Pages/Error.vue`.
|
|
90
90
|
|
|
@@ -93,7 +93,7 @@ export default defineApp({
|
|
|
93
93
|
Every error answer on an app's host — a thrown error, a refused schema, an unknown route (404) — goes through this app first (a dokebi-web error responder):
|
|
94
94
|
|
|
95
95
|
1. **Inertia** (`inertia` set): the app's scope answers an Inertia validation error with the redirect back (`errors` in the session flash, template-inertia §3.3) and other errors with `inertia.errorPage` when set.
|
|
96
|
-
2. **HTML form back** (0.4.1, D-0074 addendum 1): an HTML form post (body `application/x-www-form-urlencoded` or `multipart/form-data`, answered with HTML — not `fetch`, XHR, Bearer, JSON or Inertia) refused with 422 `VALIDATION_FAILED` (a route schema or `validationError()`) goes **back to its page** when the request has a session (@dokebi/session registered) and a `Referer` of the same host: `errors` (`{ field: message }`) and `old` (the body's top-level values without password-like fields such as `password`, `token`, `secret`, `api_key`, `card`, `cvc`, `otp`, `pin`; nothing when larger than 8 KB) are flashed and the answer is **303 to the Referer** (its path and query). Without a session, or with a missing or foreign Referer, it is the 422 error view below (no redirect, so no loop).
|
|
96
|
+
2. **HTML form back** (0.4.1, D-0074 addendum 1): an HTML form post (body `application/x-www-form-urlencoded` or `multipart/form-data`, answered with HTML — not `fetch`, XHR, Bearer, JSON or Inertia) refused with 422 `VALIDATION_FAILED` (a route schema or `validationError()`) goes **back to its page** when the request has a session (@dokebi/session registered) and a `Referer` of the same host: `errors` (`{ field: message }`) and `old` (the body's top-level values without password-like fields such as `password`, `token`, `secret`, `api_key`, `card`, `cvc`, `otp`, `pin`; nothing when larger than 8 KB) are flashed and the answer is **303 to the Referer** (its path and query). Without a session, or with a missing or foreign Referer (0.4.2: also one whose path reads as another host, such as `//other.host/…`), it is the 422 error view below (no redirect, so no loop).
|
|
97
97
|
3. **EJS error views** (an HTML answer: a browser navigation or an HTML form post): `errors/<status>` (for example `errors/404.ejs`), else `errors/error`, looked up like any page (`<app>/<template>` → `<app>/default` → `src/shared/views`, so a shared `errors/404.ejs` serves every app), with the app's `shared` data and the default layout. Data: `{ status, title ('404 Not Found'), error, message, hint, fields ([{ field, message }], empty unless 422), errors ({ field: message } of a 422), old (the refused form's input, 422 only), fix, stack }` — `fix` and `stack` (5xx) only outside production, otherwise null. An `errors/422.ejs` can therefore show the form again without a session (`<%- await data.$include('posts/form') %>` with the same `data.errors`/`data.old`).
|
|
98
98
|
4. Otherwise dokebi-web's own answer: JSON for scripts (Inertia, `fetch`, XHR, Bearer, JSON bodies), a small HTML page for browser pages.
|
|
99
99
|
|
|
@@ -269,6 +269,7 @@ The API of `createPlugin` is `{ names, resolve(request) }` (`AppGroupApi`). `res
|
|
|
269
269
|
| Code | When |
|
|
270
270
|
|---|---|
|
|
271
271
|
| `INVALID_DEFINITION` | unknown fields or bad values in `defineApp`, a bad module prefix, a module not made with `defineModule`, a bad requires item |
|
|
272
|
+
| `DEPENDENCY_CONFLICT` | at `createPlugin`: two apps (or an app and dokebi-app) require one plugin with version ranges no release satisfies together; the message names both apps and ranges, `details.needs` lists every requirement |
|
|
272
273
|
| `INVALID_ENTRY` | the entry is not `{ apps: { <name>: defineApp(...) } }` (the cause of `INVALID_PLUGIN_INPUT`) |
|
|
273
274
|
| `UNKNOWN_APP` | a domain pointing at an undefined app, or `apps.<app>` naming an undefined app |
|
|
274
275
|
| `SEAL_PROVIDER_MISSING` | a `seal: true` domain exists but the `dokebi-seal` plugin does not (even without sockets) |
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @dokebi/app 0.4.
|
|
1
|
+
# @dokebi/app 0.4.2
|
|
2
2
|
|
|
3
3
|
An optional plugin for several apps in one project that picks the app and template by request domain. An optional package for Node >=24.0.0 and core ^0.4.0 (public on npm). The design is [D-0030](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0030-multi-app-and-domains.md).
|
|
4
4
|
|
|
@@ -86,7 +86,7 @@ export default defineApp({
|
|
|
86
86
|
|
|
87
87
|
- A handler's `page` is `{ app: { name, template, domain }, module, base, view, inertia, sealed }`. In app routes `module` is undefined and `base` is `''`. `view` is an EJS renderer that looks in `<app>/<template>` → `<app>/default` → shared src/shared/views; layouts and `$include` follow the same order. `inertia` uses the app's document settings (Vite entry and so on) and adds `app` to the shared props.
|
|
88
88
|
- **Error pages ([D-0074](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0074-error-responses.md)):** errors on an app's hosts (unknown routes included) go through the app first. An Inertia app answers Inertia validation errors with the redirect back (`errors`) and other errors with `inertia.errorPage` (for example `Error`); for a browser page an EJS app renders `views/<template>/errors/<status>.ejs`, else `errors/error.ejs` (same lookup as pages, with `status`, `title`, `error`, `message`, `hint`, `fields`), else @dokebi/web's small page. JSON clients always get JSON. The `app add` skeletons include `errors/404.ejs` and `errors/error.ejs` (EJS) or `Pages/Error.vue` with `errorPage: 'Error'` (Inertia). Refuse input with `throw validationError({ name: 'Already taken' })` from @dokebi/web.
|
|
89
|
-
- **HTML forms come back (0.4.1, D-0074 addendum 1):** with [@dokebi/session](https://git.nyx-zone.com/dokebi/framework/-/blob/main/plugins/dokebi-session/README.md) registered, an HTML form post refused with 422 `VALIDATION_FAILED` flashes `errors` and `old` (without password-like fields) and answers 303 to the `Referer` of the same host, and every EJS page gets `data.errors`, `data.old` and `data.flash` (always objects, the flash read once per request), so the form shows `<%= data.old.title ?? '' %>` and `data.errors.title`. Without a session, or without a same-host Referer, the refused form gets `errors/422.ejs` (else `errors/error.ejs`) with `fields`, `errors` and `old`. Scripts (`fetch`, XHR, Bearer, JSON, Inertia) keep their JSON. Needs @dokebi/web ^0.4.
|
|
89
|
+
- **HTML forms come back (0.4.1, D-0074 addendum 1):** with [@dokebi/session](https://git.nyx-zone.com/dokebi/framework/-/blob/main/plugins/dokebi-session/README.md) registered, an HTML form post refused with 422 `VALIDATION_FAILED` flashes `errors` and `old` (without password-like fields) and answers 303 to the `Referer` of the same host, and every EJS page gets `data.errors`, `data.old` and `data.flash` (always objects, the flash read once per request), so the form shows `<%= data.old.title ?? '' %>` and `data.errors.title`. Without a session, or without a same-host Referer, the refused form gets `errors/422.ejs` (else `errors/error.ejs`) with `fields`, `errors` and `old`. A Referer whose path reads as another host (`//other.host/…`) is no way back (0.4.2). Scripts (`fetch`, XHR, Bearer, JSON, Inertia) keep their JSON. Needs @dokebi/web ^0.4.2.
|
|
90
90
|
- **Mounting modules ([D-0032](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0032-feature-modules.md)):** `modules: { '/prefix': module }`, where the module was made with `defineModule`.
|
|
91
91
|
- The module's `routes` are registered with this app's route constraint and the prefix; handlers get `page.module` and `page.base`.
|
|
92
92
|
- The module's `sockets` are registered under the prefix. Their tenant is `<namespace>:<tenant>`, as for app sockets.
|
|
@@ -101,6 +101,7 @@ export default defineApp({
|
|
|
101
101
|
6. shared views
|
|
102
102
|
- **`shared(request, { app })`:** merged under the data of every EJS page this app renders (app routes and module routes). On overlapping keys the page data wins. Put app data the layout needs, such as the menu or the user, here. It corresponds to Inertia's shared props.
|
|
103
103
|
- `get` and `getDependency` of the app context (`app`) allow only the plugins listed in `requires`. Controller factories have the same limit.
|
|
104
|
+
- A plugin several apps require is checked against every app's version range (the ranges are joined for core); ranges that cannot meet stop `createPlugin` with `DEPENDENCY_CONFLICT`, naming both apps.
|
|
104
105
|
- App routes are registered with a Fastify route constraint (`dokebiApp`), so several apps can own the same path. Shared routes without the constraint (health checks, module APIs) answer on every domain.
|
|
105
106
|
- The app's WebSocket routes (`sockets`) and SSE routes (`events`, @dokebi/sse) use the same constraint. The hub tenant is `<namespace>:<tenant>` and the default namespace is the app name, so without settings it stays `<app>:<tenant>`, one per app. The session's `identity.tenant` and `stream.tenant` hold this value.
|
|
106
107
|
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DokebiError, type DokebiErrorOptions } from '@dokebi/core';
|
|
2
2
|
/** Codes of the errors this plugin throws (`AppError`, `plugin: 'dokebi-app'`). */
|
|
3
|
-
export type AppErrorCode = 'INVALID_DEFINITION' | 'INVALID_ENTRY' | 'UNKNOWN_APP' | 'SEAL_PROVIDER_MISSING' | 'VIEW_ENGINE_MISSING' | 'VIEWS_MISSING' | 'REALTIME_UNAVAILABLE' | 'NAMESPACE_FORBIDDEN' | 'INVALID_TARGET' | 'NOT_REQUIRED' | 'NOT_READY';
|
|
3
|
+
export type AppErrorCode = 'INVALID_DEFINITION' | 'INVALID_ENTRY' | 'DEPENDENCY_CONFLICT' | 'UNKNOWN_APP' | 'SEAL_PROVIDER_MISSING' | 'VIEW_ENGINE_MISSING' | 'VIEWS_MISSING' | 'REALTIME_UNAVAILABLE' | 'NAMESPACE_FORBIDDEN' | 'INVALID_TARGET' | 'NOT_REQUIRED' | 'NOT_READY';
|
|
4
4
|
/** Errors of @dokebi/app; compare `code`, not the class (another installed copy may throw). */
|
|
5
5
|
export declare class AppError extends DokebiError<AppErrorCode> {
|
|
6
6
|
constructor(code: AppErrorCode, message: string, options?: DokebiErrorOptions);
|
package/dist/errors.js
CHANGED
|
@@ -2,6 +2,7 @@ import { DokebiError } from '@dokebi/core';
|
|
|
2
2
|
const FIX = {
|
|
3
3
|
INVALID_DEFINITION: 'defineApp takes requires, controllers, views (a file: URL), inertia, modules ({ "/prefix": defineModule(...) }), shared, routes, sockets, events, setup, start and drain; hooks are functions.',
|
|
4
4
|
INVALID_ENTRY: 'Pass { apps: { <name>: defineApp(...) } } (src/dokebi.generated.ts does); names match ^[a-z][a-z0-9-]{0,31}$.',
|
|
5
|
+
DEPENDENCY_CONFLICT: 'Two apps (or an app and dokebi-app) require one plugin with version ranges no release satisfies together: align requires of defineApp in src/apps/<app>/app.ts, or update the app that needs the older major.',
|
|
5
6
|
UNKNOWN_APP: 'Every app named in options.dokebi-app.domains.<host>.app and options.dokebi-app.apps must be defined (npx dokebi app add <name>, or remove the entry from dokebi.yaml).',
|
|
6
7
|
SEAL_PROVIDER_MISSING: 'Register the dokebi-seal plugin (npx dokebi add @dokebi/seal), or remove seal: true from options.dokebi-app.domains.',
|
|
7
8
|
VIEW_ENGINE_MISSING: 'Install the view plugin the app uses: npx dokebi add @dokebi/template-ejs (views) or npx dokebi add @dokebi/template-inertia (inertia).',
|
package/dist/index.d.ts
CHANGED
|
@@ -287,3 +287,10 @@ export interface AppGroupApi {
|
|
|
287
287
|
resolve(request: FastifyRequest): AppInfo | undefined;
|
|
288
288
|
}
|
|
289
289
|
export declare const createPlugin: import("@dokebi/core").PluginFactory<AppGroupApi>;
|
|
290
|
+
/**
|
|
291
|
+
* The semver AND of two ranges, `||` included: every pair of alternatives joined with a space,
|
|
292
|
+
* unsatisfiable pairs left out. Joining whole ranges with a space is wrong for `||`
|
|
293
|
+
* (`^1 || ^2` and `^2` would read as `^1 || (^2 ^2)` and accept 1.x; ISSUE-0006 recheck).
|
|
294
|
+
* An empty string: no version satisfies both.
|
|
295
|
+
*/
|
|
296
|
+
export declare function andRanges(a: string, b: string): string;
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,10 @@ import { createControllers, } from '@dokebi/controller';
|
|
|
5
5
|
import { definePlugin, dependencyOf, optionalDependency, providerDependency, } from '@dokebi/core';
|
|
6
6
|
import { formBackTarget, formFieldErrors, formOldInput, isFormSubmission, } from '@dokebi/web';
|
|
7
7
|
import { realtime, viewEngines, } from '@dokebi/web/points';
|
|
8
|
+
import Range from 'semver/classes/range.js';
|
|
9
|
+
import intersects from 'semver/ranges/intersects.js';
|
|
10
|
+
import minVersion from 'semver/ranges/min-version.js';
|
|
11
|
+
import validRange from 'semver/ranges/valid.js';
|
|
8
12
|
import { AppError } from './errors.js';
|
|
9
13
|
import { options as declaration } from './options.js';
|
|
10
14
|
export { AppError } from './errors.js';
|
|
@@ -110,13 +114,13 @@ function parseEntry(input) {
|
|
|
110
114
|
return apps;
|
|
111
115
|
}
|
|
112
116
|
/**
|
|
113
|
-
* dokebi-web 0.4.
|
|
114
|
-
* addendum 1). A local descriptor instead of '@dokebi/web/dependency' (whose range stays ^0.4.0
|
|
117
|
+
* dokebi-web 0.4.2 or later: the HTML form validation redirect uses its form helpers (D-0074
|
|
118
|
+
* addendum 1; 0.4.2 never answers a Referer path that reads as another host, ISSUE-0006 A02). A local descriptor instead of '@dokebi/web/dependency' (whose range stays ^0.4.0
|
|
115
119
|
* for the plugins that need nothing newer).
|
|
116
120
|
*/
|
|
117
121
|
const web = providerDependency({
|
|
118
122
|
name: 'dokebi-web',
|
|
119
|
-
version: '^0.4.
|
|
123
|
+
version: '^0.4.2',
|
|
120
124
|
packageName: '@dokebi/web',
|
|
121
125
|
load: () => import('@dokebi/web'),
|
|
122
126
|
});
|
|
@@ -340,7 +344,7 @@ class AppRuntime {
|
|
|
340
344
|
for (const app of this.options.apps.keys())
|
|
341
345
|
if (!this.apps.has(app))
|
|
342
346
|
throw new AppError('UNKNOWN_APP', `dokebi-app apps.${app} names an app that is not defined (defined: ${[...this.apps.keys()].join(', ') || 'none'})`);
|
|
343
|
-
const http = context.getDependency(web);
|
|
347
|
+
const http = context.getDependency(this.#declaredFor(web.name));
|
|
344
348
|
const logger = context.logger;
|
|
345
349
|
const sessions = context.getOptionalDependency(this.#declaredFor(session.name));
|
|
346
350
|
// D-0074 addendum 1: the flash of a request, taken once (every render of the request shares
|
|
@@ -889,26 +893,105 @@ function missingViews(name) {
|
|
|
889
893
|
}
|
|
890
894
|
export const createPlugin = definePlugin({
|
|
891
895
|
name: 'dokebi-app',
|
|
892
|
-
version: '0.4.
|
|
896
|
+
version: '0.4.2',
|
|
893
897
|
core: '^0.4.0',
|
|
894
898
|
options: declaration,
|
|
895
899
|
entry: parseEntry,
|
|
896
900
|
// Template and realtime plugins are found through these points, not by name (D-0063 §5).
|
|
897
901
|
collects: [viewEngines, realtime],
|
|
898
|
-
dependencies: ({ entry }) =>
|
|
899
|
-
const apps = [...(entry ?? new Map()).values()];
|
|
900
|
-
const list = [web, seal, session];
|
|
901
|
-
for (const app of apps)
|
|
902
|
-
for (const item of [...(app.requires ?? []), ...Object.values(app.modules ?? {})]) {
|
|
903
|
-
const dependency = requirement(item);
|
|
904
|
-
const index = list.findIndex((existing) => existing.name === dependency.name);
|
|
905
|
-
if (index === -1)
|
|
906
|
-
list.push(dependency);
|
|
907
|
-
// An app that requires an optional provider (session, seal) makes it required.
|
|
908
|
-
else if (list[index]?.optional && !dependency.optional)
|
|
909
|
-
list[index] = dependency;
|
|
910
|
-
}
|
|
911
|
-
return list;
|
|
912
|
-
},
|
|
902
|
+
dependencies: ({ entry }) => mergeRequirements(entry ?? new Map()),
|
|
913
903
|
instance: ({ options, entry, dependencies }) => new AppRuntime(settings(options), entry ?? new Map(), dependencies),
|
|
914
904
|
});
|
|
905
|
+
/**
|
|
906
|
+
* Core takes one requirement per plugin name, so the requirements of every app (and dokebi-app's
|
|
907
|
+
* own web, seal and session) are merged per name (ISSUE-0006 A12): the version is every distinct
|
|
908
|
+
* range joined with a space (semver AND, so core checks the provider against each app's range),
|
|
909
|
+
* the result is optional only when every consumer is optional, and the factory (`create`) of the
|
|
910
|
+
* first consumer that has one is kept. Ranges that cannot meet are refused here, before start,
|
|
911
|
+
* with `DEPENDENCY_CONFLICT` naming the apps: no provider version could satisfy both.
|
|
912
|
+
*/
|
|
913
|
+
function mergeRequirements(apps) {
|
|
914
|
+
const needs = new Map();
|
|
915
|
+
const add = (consumer, dependency) => {
|
|
916
|
+
if (!validRange(dependency.version))
|
|
917
|
+
throw new AppError('INVALID_DEFINITION', `${consumer === 'dokebi-app' ? 'dokebi-app' : `App ${consumer}`} requires ${dependency.name} with an invalid version range: ${JSON.stringify(dependency.version)}`);
|
|
918
|
+
const list = needs.get(dependency.name);
|
|
919
|
+
if (list)
|
|
920
|
+
list.push({ consumer, dependency });
|
|
921
|
+
else
|
|
922
|
+
needs.set(dependency.name, [{ consumer, dependency }]);
|
|
923
|
+
};
|
|
924
|
+
for (const dependency of [web, seal, session])
|
|
925
|
+
add('dokebi-app', dependency);
|
|
926
|
+
for (const [name, app] of apps)
|
|
927
|
+
for (const item of [...(app.requires ?? []), ...Object.values(app.modules ?? {})])
|
|
928
|
+
add(name, requirement(item));
|
|
929
|
+
const merged = [];
|
|
930
|
+
for (const [name, list] of needs) {
|
|
931
|
+
const first = list[0];
|
|
932
|
+
const ranges = [];
|
|
933
|
+
// The AND of every distinct range; `||` alternatives are combined pairwise (andRanges).
|
|
934
|
+
let combined = '';
|
|
935
|
+
for (const need of list) {
|
|
936
|
+
if (ranges.includes(need.dependency.version))
|
|
937
|
+
continue;
|
|
938
|
+
const next = ranges.length
|
|
939
|
+
? andRanges(combined, need.dependency.version)
|
|
940
|
+
: need.dependency.version;
|
|
941
|
+
if (!next) {
|
|
942
|
+
// Name the consumer it clashes with; when only the combination fails, name them all.
|
|
943
|
+
const earlier = list.slice(0, list.indexOf(need));
|
|
944
|
+
const clash = earlier.find((other) => !intersects(other.dependency.version, need.dependency.version));
|
|
945
|
+
const others = clash ? [clash] : earlier;
|
|
946
|
+
throw new AppError('DEPENDENCY_CONFLICT', `No version of ${name} satisfies both ${others.map(label).join(' and ')} and ${label(need)}`, {
|
|
947
|
+
details: {
|
|
948
|
+
plugin: name,
|
|
949
|
+
needs: list.map((each) => ({
|
|
950
|
+
consumer: each.consumer,
|
|
951
|
+
version: each.dependency.version,
|
|
952
|
+
optional: each.dependency.optional === true,
|
|
953
|
+
})),
|
|
954
|
+
},
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
ranges.push(need.dependency.version);
|
|
958
|
+
combined = next;
|
|
959
|
+
}
|
|
960
|
+
const optional = list.every((need) => need.dependency.optional);
|
|
961
|
+
const create = list.find((need) => need.dependency.create)?.dependency.create;
|
|
962
|
+
// One consumer, or all the same: keep the descriptor object itself.
|
|
963
|
+
const same = list.every((need) => need.dependency.version === first.dependency.version &&
|
|
964
|
+
Boolean(need.dependency.optional) === optional);
|
|
965
|
+
if (same && (first.dependency.create || !create)) {
|
|
966
|
+
merged.push(first.dependency);
|
|
967
|
+
continue;
|
|
968
|
+
}
|
|
969
|
+
merged.push(Object.freeze({
|
|
970
|
+
name,
|
|
971
|
+
version: combined,
|
|
972
|
+
...(optional ? { optional: true } : {}),
|
|
973
|
+
...(create ? { create } : {}),
|
|
974
|
+
}));
|
|
975
|
+
}
|
|
976
|
+
return merged;
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* The semver AND of two ranges, `||` included: every pair of alternatives joined with a space,
|
|
980
|
+
* unsatisfiable pairs left out. Joining whole ranges with a space is wrong for `||`
|
|
981
|
+
* (`^1 || ^2` and `^2` would read as `^1 || (^2 ^2)` and accept 1.x; ISSUE-0006 recheck).
|
|
982
|
+
* An empty string: no version satisfies both.
|
|
983
|
+
*/
|
|
984
|
+
export function andRanges(a, b) {
|
|
985
|
+
const parts = [];
|
|
986
|
+
for (const left of new Range(a).set)
|
|
987
|
+
for (const right of new Range(b).set) {
|
|
988
|
+
const combo = [...left, ...right]
|
|
989
|
+
.map((comparator) => comparator.value)
|
|
990
|
+
.filter(Boolean)
|
|
991
|
+
.join(' ') || '*';
|
|
992
|
+
if (minVersion(combo) !== null && !parts.includes(combo))
|
|
993
|
+
parts.push(combo);
|
|
994
|
+
}
|
|
995
|
+
return parts.join(' || ');
|
|
996
|
+
}
|
|
997
|
+
const label = (need) => `${need.consumer === 'dokebi-app' ? 'dokebi-app' : `app ${need.consumer}`} (${need.dependency.version})`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dokebi/app",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Multiple apps per project for Dokebi: pick the app and template by request domain, with EJS and Inertia skeletons.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dokebi",
|
|
@@ -37,12 +37,15 @@
|
|
|
37
37
|
"typecheck": "tsc -p tsconfig.test.json --noEmit",
|
|
38
38
|
"test": "node -e \"require('node:fs').rmSync('.tmp/tests',{recursive:true,force:true})\" && tsc -p tsconfig.test.json && node --test .tmp/tests/tests/*.test.js"
|
|
39
39
|
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"semver": "7.8.5"
|
|
42
|
+
},
|
|
40
43
|
"peerDependencies": {
|
|
41
44
|
"@dokebi/controller": "^0.4.0",
|
|
42
45
|
"@dokebi/core": "^0.4.0",
|
|
43
46
|
"@dokebi/module": "^0.4.0",
|
|
44
47
|
"@dokebi/template-ejs": "^0.4.0",
|
|
45
|
-
"@dokebi/web": "^0.4.
|
|
48
|
+
"@dokebi/web": "^0.4.2",
|
|
46
49
|
"fastify": "^5.12.7"
|
|
47
50
|
},
|
|
48
51
|
"peerDependenciesMeta": {
|
|
@@ -58,6 +61,7 @@
|
|
|
58
61
|
"@dokebi/template-inertia": "^0.4.0",
|
|
59
62
|
"@dokebi/websocket": "^0.4.0",
|
|
60
63
|
"@dokebi/websocket-hub": "^0.4.0",
|
|
64
|
+
"@types/semver": "7.8.0",
|
|
61
65
|
"ws": "8.22.0"
|
|
62
66
|
},
|
|
63
67
|
"dokebi": {
|
|
@@ -67,7 +71,7 @@
|
|
|
67
71
|
"dependencies": [
|
|
68
72
|
{
|
|
69
73
|
"name": "dokebi-web",
|
|
70
|
-
"version": "^0.4.
|
|
74
|
+
"version": "^0.4.2",
|
|
71
75
|
"package": "@dokebi/web"
|
|
72
76
|
},
|
|
73
77
|
{
|