@mono-lit/utility 0.0.0-stage → 0.0.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.
Files changed (54) hide show
  1. package/LICENSE.md +54 -0
  2. package/README.md +157 -3
  3. package/dist/app-roots-CvJnmXcs.js +128 -0
  4. package/dist/app-roots-DK41xMWj.d.ts +90 -0
  5. package/dist/config-node-UzJrXg0Z.js +76 -0
  6. package/dist/config-node.d.ts +923 -0
  7. package/dist/config-node.js +7 -0
  8. package/dist/config.d.ts +2 -0
  9. package/dist/config.js +3 -0
  10. package/dist/create-config-B8IhX4ht.d.ts +735 -0
  11. package/dist/create-config-DdL3Fh6T.js +357 -0
  12. package/dist/fetching.d.ts +244 -0
  13. package/dist/fetching.js +1015 -0
  14. package/dist/generate-CJ7MtcDd.js +291 -0
  15. package/dist/index-BAy6tbOG.d.ts +371 -0
  16. package/dist/index-DYlzhHq7.d.ts +514 -0
  17. package/dist/index.d.ts +25 -0
  18. package/dist/index.js +941 -0
  19. package/dist/merge-file-CLc3wxY4.d.ts +99 -0
  20. package/dist/merge-file-CtyKTu5L.js +133 -0
  21. package/dist/mock-db-4tTWrF-P.js +1282 -0
  22. package/dist/mock-db.d.ts +2 -0
  23. package/dist/mock-db.js +4 -0
  24. package/dist/mono-alias-DNDm-jB_.js +508 -0
  25. package/dist/mono-clone.mjs +958 -0
  26. package/dist/mono-db.d.ts +1 -0
  27. package/dist/mono-db.js +158 -0
  28. package/dist/mono-env.mjs +231 -0
  29. package/dist/mono-git.mjs +798 -0
  30. package/dist/mono-link-YlOQ2PVS.js +488 -0
  31. package/dist/mono-prepare.d.ts +1 -0
  32. package/dist/mono-prepare.js +28 -0
  33. package/dist/mono-skills.d.ts +1 -0
  34. package/dist/mono-skills.js +837 -0
  35. package/dist/mono-tsconfig-D2qRL9_R.js +204 -0
  36. package/dist/mono.mjs +34 -0
  37. package/dist/nuxt-layers-DP1m7f1-.js +176 -0
  38. package/dist/nuxt-layers.d.ts +36 -0
  39. package/dist/nuxt-layers.js +3 -0
  40. package/dist/nuxt-runtime.d.ts +17 -0
  41. package/dist/nuxt-runtime.js +102 -0
  42. package/dist/nuxt.d.ts +390 -0
  43. package/dist/nuxt.js +737 -0
  44. package/dist/runtime-vs7U9Ed4.js +6054 -0
  45. package/dist/runtime.d.ts +2518 -0
  46. package/dist/runtime.js +4 -0
  47. package/dist/session-Bcig-rPi.js +1721 -0
  48. package/dist/types-B6FdB7LJ.d.ts +57 -0
  49. package/dist/universal-BR0O7Qwk.d.ts +59 -0
  50. package/dist/universal-DIVEzCvN.js +600 -0
  51. package/dist/virtual-mono-apps.d.ts +16 -0
  52. package/dist/vite.d.ts +943 -0
  53. package/dist/vite.js +1132 -0
  54. package/package.json +141 -3
@@ -0,0 +1,735 @@
1
+ import { VNode } from "vue";
2
+ //#region src/composables/create-config.d.ts
3
+ interface Permission {
4
+ permId: number;
5
+ module: string;
6
+ canView: boolean;
7
+ canEdit: boolean;
8
+ canDelete: boolean;
9
+ canCreate: boolean;
10
+ canApprove: boolean;
11
+ canReport: boolean;
12
+ }
13
+ interface DefaultJWTTokenTypes {
14
+ nbf?: number;
15
+ exp?: number;
16
+ iat?: number;
17
+ }
18
+ interface JWTCompleteTokenTypes extends DefaultJWTTokenTypes {
19
+ USER_ID?: string;
20
+ USER_NAME?: string;
21
+ NAME?: string;
22
+ CHANNEL?: string;
23
+ IS_DEPT_HEAD?: '0' | '1';
24
+ ROLE_ID?: string;
25
+ ROLE_NAME?: string;
26
+ ROLE_TYPE?: string;
27
+ ORG_NAME?: string;
28
+ JOBPOS_ID?: string;
29
+ JOBPOS_NAME?: string;
30
+ JOBLVL_ID?: string;
31
+ JOBLVL_NAME?: string;
32
+ COMPANY_DB?: string;
33
+ DEPT_CODE?: string;
34
+ IS_SUPERADMIN?: '0' | '1';
35
+ COMPANY_ID?: string;
36
+ IS_LOCK_BUDGET?: '0' | '1';
37
+ ALL_DEPARTMENT?: '0' | '1';
38
+ ALL_COMPANY?: '0' | '1';
39
+ ALL_BRAND?: '0' | '1';
40
+ ALL_AREA?: '0' | '1';
41
+ IS_APPROVAL_PROGRAM?: '0' | '1';
42
+ USER_BRAND?: string;
43
+ USER_AREA?: string;
44
+ TOKEN_KIND?: 'ACCESS' | 'REFRESH';
45
+ EXPIRED?: string;
46
+ PERMISSIONS?: Permission[] | string;
47
+ }
48
+ /**
49
+ * One JWT the app carries.
50
+ *
51
+ * `name` is either the cookie to decode, or — the dev-mode form — an already-decoded
52
+ * claims object, which is assigned straight into state:
53
+ * `name: import.meta.env.PROD ? 'MONO_token' : { ...decodedAtBoot }`
54
+ */
55
+ interface MonoJwtEntry<T extends object = Record<string, any>> {
56
+ name: string | T;
57
+ split?: boolean;
58
+ }
59
+ /**
60
+ * The `jwt` block. `token` and `refreshToken` are named — so they keep their autocomplete
61
+ * and their own claim types — but ANY key is allowed, for an app that carries a third JWT
62
+ * (a vendor token, an impersonation token, a second identity provider). Each one hydrates
63
+ * into `monoState().jwt.<key>`.
64
+ *
65
+ * The index signature lives in a separate intersection member on purpose: inside a single
66
+ * object type, TS would force `token` and `refreshToken` to be assignable to it, collapsing
67
+ * their specific claim types into the generic entry.
68
+ *
69
+ * One cost worth knowing: an index signature turns OFF excess-property checking for the
70
+ * block, so a mis-cased key (`refreshtoken`) compiles. `initMono` warns about that at
71
+ * runtime, because the type system no longer can.
72
+ */
73
+ type MonoJwtConfig = {
74
+ token?: MonoJwtEntry<JWTCompleteTokenTypes>;
75
+ refreshToken?: MonoJwtEntry<DefaultJWTTokenTypes>;
76
+ } & {
77
+ [key: string]: MonoJwtEntry | undefined;
78
+ };
79
+ interface SidebarMenu {
80
+ title: string;
81
+ subtitle?: string;
82
+ url?: string;
83
+ icon?: string;
84
+ color?: string;
85
+ button?: {
86
+ title?: string;
87
+ icon?: string;
88
+ };
89
+ items?: SidebarMenu[];
90
+ remoteName?: string;
91
+ visible?: boolean;
92
+ order?: number;
93
+ route?: {
94
+ meta: {
95
+ layout: string;
96
+ title: string;
97
+ };
98
+ };
99
+ }
100
+ /**
101
+ * The kind of app, which decides its source-folder convention:
102
+ * - `vue` -> source under `src/` (Vue/Vite apps)
103
+ * - `nuxt` -> source under `app/` (Nuxt apps)
104
+ *
105
+ * Consumed by `monoAlias`/`monoEcosystem` to resolve `@<app>` aliases and remote
106
+ * folder discovery to the right subdir, instead of assuming `src/` everywhere.
107
+ */
108
+ type MonoAppType = 'vue' | 'nuxt';
109
+ /** Source subdir for each app kind. The single place the convention lives. */
110
+ declare const MONO_SRC_DIR: Record<MonoAppType, string>;
111
+ /** Map an app `type` to its source subdir (`vue` -> `src`, `nuxt` -> `app`). */
112
+ declare function srcDirForType(type: MonoAppType): string;
113
+ /**
114
+ * Which side of a federation this app is.
115
+ *
116
+ * Orthogonal to {@link MonoAppType}: `type` says where the source lives (`src/`
117
+ * or `app/`), `template` says whether this app OWNS the shared shell or CONSUMES
118
+ * it. Either kind of app can be either role — read by `mono.vite()` for a Vite
119
+ * app and by the `@mono-lit/utility/nuxt` module for a Nuxt one.
120
+ */
121
+ type MonoTemplate = 'host' | 'remote';
122
+ /**
123
+ * How `mono sync` reaches a remote app's repository.
124
+ *
125
+ * - `auto` (default) probe the machine's own git credentials first — one
126
+ * `git ls-remote`, no token, no GitHub REST rate limit. Falls back to
127
+ * `envToken` + the REST/archive-ZIP path if this machine has no access.
128
+ * - `git` git transport only. Fails the app instead of falling back, so a CI
129
+ * runner with a missing credential errors loudly rather than silently
130
+ * burning the shared PAT.
131
+ * - `token` legacy behaviour: always REST + archive ZIP (needs `unzip` on PATH).
132
+ *
133
+ * Overridable for every app at once with `MONO_SYNC_TRANSPORT`.
134
+ */
135
+ type MonoSyncTransport = 'auto' | 'git' | 'token';
136
+ /**
137
+ * A remote app this host federates — from a clone (`url`, materialised by
138
+ * `mono sync` into `.mono/apps/<name>`) or read in place (`path`, a sibling
139
+ * folder in a mono-lith). Every command reads the same directory; `mono sync`
140
+ * only ever writes and deletes inside `.mono/apps`.
141
+ */
142
+ interface MonoAppConfig {
143
+ name: string;
144
+ /**
145
+ * Where `mono sync` clones this app from (a GitHub URL, optionally with
146
+ * `/tree/<ref>[/<dir>]`).
147
+ *
148
+ * Optional when `path` is set: in a mono-lith the app is read from its
149
+ * sibling folder and there is nothing to clone. Keep it anyway if this app
150
+ * may be lifted out of the lith into a standalone checkout — there the
151
+ * `path` directory is absent, and `mono sync` falls back to the `url`.
152
+ *
153
+ * An entry with neither `url` nor `path` is a config error.
154
+ */
155
+ url?: string;
156
+ /**
157
+ * Read this app from a directory instead of a clone. **Authoritative in
158
+ * every command** — dev, build, `mono prepare`, `mono sync`, `mono env`,
159
+ * the Nuxt module — so a mono-lith (every app a sibling folder of one repo)
160
+ * builds from exactly what dev served:
161
+ *
162
+ * ```ts
163
+ * // apps/esw-host/mono.config.ts
164
+ * apps: [
165
+ * { name: 'esw-project', path: '../esw-project', url: 'https://github.com/org/esw-project/tree/mono', type: 'vue' },
166
+ * ]
167
+ * ```
168
+ *
169
+ * Resolved against the app root, absolute paths kept as-is. Rules:
170
+ *
171
+ * - **The directory wins.** `.mono/apps/<name>` is not read while `path`
172
+ * resolves, and a stale clone there is left alone (never deleted).
173
+ * - **A missing directory falls back to the clone when `url` is set**, with
174
+ * one warning — your machine reads the sibling, a checkout that was lifted
175
+ * out of the lith syncs from GitHub. With no `url` it is an error: there is
176
+ * nothing to fall back to.
177
+ * - **Nothing here is ever written to or deleted.** `mono sync` prunes only
178
+ * inside `.mono/apps`, and `mono prepare` never touches a sibling's
179
+ * `tsconfig.json` — each sibling runs its own prepare.
180
+ * - **Static literal, forward slashes.** `mono.config.ts` is text-parsed
181
+ * before it can be executed, so a computed path yields no alias; and the
182
+ * literal is evaluated as JS, so `'..\esw-x'` loses its backslash.
183
+ *
184
+ * See the Mono-Lith docs.
185
+ */
186
+ path?: string;
187
+ /**
188
+ * Env var holding a GitHub PAT. Only read on the token transport, so it is
189
+ * optional: if every machine that syncs this app is a repo collaborator, the
190
+ * git transport covers it and no token is needed at all.
191
+ */
192
+ envToken?: string;
193
+ /** Sync transport for this app. @default 'auto' */
194
+ transport?: MonoSyncTransport;
195
+ /**
196
+ * App kind / folder convention. `vue` -> `src/`, `nuxt` -> `app/`. Lets the
197
+ * host resolve this remote's `@<name>` alias and synced folders to the
198
+ * correct subdir (a Nuxt remote keeps source under `app/`, not `src/`).
199
+ */
200
+ type: MonoAppType;
201
+ }
202
+ /**
203
+ * The DevExtreme source constructors shared across every OData API in an app.
204
+ * These are the same classes for all OData entries, so they live once at the
205
+ * `fetching.source` level instead of being repeated per entry. The per-API
206
+ * service constructor (`oDataService`) stays on each {@link MonoApiEntry}.
207
+ */
208
+ interface MonoOdataSource {
209
+ /** DevExtreme `DataSource` constructor (shared across all odata APIs) */
210
+ dataSource?: any;
211
+ /** DevExtreme `ODataStore` constructor (shared across all odata APIs) */
212
+ oDataStore?: any;
213
+ /** DevExtreme `CustomStore` constructor (shared across all odata APIs) */
214
+ customStore?: any;
215
+ }
216
+ /**
217
+ * A single named API entry.
218
+ *
219
+ * `url` is always required. `type` is a flag: `'odata'` entries may additionally
220
+ * carry their own `oDataService` constructor (it differs per API). The shared
221
+ * DevExtreme source ctors live on `fetching.source`, not here.
222
+ */
223
+ interface MonoApiEntry {
224
+ type: 'restful' | 'odata';
225
+ url: string;
226
+ /** odata only — the OData service constructor, unique to this API */
227
+ oDataService?: any;
228
+ }
229
+ interface MonoFetchingConfig {
230
+ /**
231
+ * Named map of APIs. Pick one per call with `configBaseUrl: "<entryName>"`.
232
+ *
233
+ * @example
234
+ * api: {
235
+ * Posts: { type: 'restful', url: 'https://jsonplaceholder.typicode.com' },
236
+ * MyApi: { type: 'odata', url: '.../odata', oDataService: DefaultService },
237
+ * }
238
+ */
239
+ api?: {
240
+ [key: string]: MonoApiEntry;
241
+ };
242
+ /**
243
+ * Shared DevExtreme source constructors, reused by every odata API entry.
244
+ *
245
+ * @example
246
+ * source: { dataSource: DataSource, oDataStore: ODataStore, customStore: CustomStore }
247
+ */
248
+ source?: MonoOdataSource;
249
+ auth?: MonoAuthConfig;
250
+ }
251
+ /**
252
+ * The request that swaps an expiring token for a fresh one.
253
+ *
254
+ * Mirrors `MonoFetchCookieOptions` (src/token), which is what the core fetch layer ultimately
255
+ * receives. You supply the endpoint and where to find the new token in its response;
256
+ * the `Authorization` header and the `{ username }` body are filled in for you from
257
+ * the `use.refreshTokenRequest` cookie.
258
+ */
259
+ interface MonoRefreshRequestConfig {
260
+ /**
261
+ * The cookie this re-sets with the new token. Defaults to `use.apiRequest` — i.e.
262
+ * the token the app sends on normal requests, which is the one that has to stay fresh.
263
+ */
264
+ name?: string;
265
+ /**
266
+ * Where to find the pieces in the refresh response body (dot-paths).
267
+ *
268
+ * `value` is the new token. **One of `milis` / `days` is REQUIRED** — it is the
269
+ * cookie's lifetime, and without it the cookie is never written: the refresh appears
270
+ * to succeed and silently changes nothing.
271
+ *
272
+ * @example path: { milis: 'Expired', value: 'RefreshToken' }
273
+ */
274
+ path: {
275
+ milis?: string;
276
+ days?: string;
277
+ value?: string;
278
+ name?: string;
279
+ };
280
+ /** Defaults to whatever `cookie[]` declares for `name`. */
281
+ splitCookie?: boolean;
282
+ fetchParams: {
283
+ url: string;
284
+ /** Any `RequestInit` field, plus `baseUrl` (defaults to the resolved REST base url). */
285
+ options?: Record<string, any> & {
286
+ baseUrl?: string;
287
+ };
288
+ };
289
+ }
290
+ interface MonoAuthConfig {
291
+ /** @deprecated Name the cookies in `use` instead. Still honoured. */
292
+ token?: string;
293
+ /** @deprecated Name the cookies in `use` instead. Still honoured. */
294
+ tokenRefresh?: string;
295
+ /**
296
+ * Which cookie goes on which request. The object form names **cookies** — entries of
297
+ * the top-level `cookie[]` array — so each one's `split` flag is inherited from there
298
+ * rather than restated here.
299
+ *
300
+ * @example
301
+ * use: {
302
+ * apiRequest: 'MONO_tokenRefresh', // sent on every API request
303
+ * refreshTokenRequest: 'MONO_token', // sent as the Bearer ON the refresh request
304
+ * }
305
+ *
306
+ * The legacy string form (`'token'` | `'tokenRefresh'`) picks which of the deprecated
307
+ * `token` / `tokenRefresh` names to send on API requests, and is still supported.
308
+ */
309
+ use?: 'token' | 'tokenRefresh' | {
310
+ apiRequest?: string;
311
+ refreshTokenRequest?: string;
312
+ };
313
+ /**
314
+ * Enables **automatic token refresh** — proactively when the token is expiring, and
315
+ * on a 401 (the request is retried once).
316
+ *
317
+ * Omit it and nothing refreshes, which is the behaviour mono had before this existed.
318
+ */
319
+ requestRefreshTokenRequest?: MonoRefreshRequestConfig;
320
+ /**
321
+ * What to do when a request is unauthorized and no refresh could save it.
322
+ * Only consulted when no `unauthCall` is registered via `monoConfigureFetching`.
323
+ */
324
+ expiredBehaviour?: 'refresh';
325
+ }
326
+ /**
327
+ * A single `extends` source.
328
+ *
329
+ * - `string` / `[string, options]` — a local path, npm package, or remote
330
+ * source (e.g. `github:org/repo`). Resolved only by the C12 node loader
331
+ * (`@mono-lit/utility/config/node` → `getMonoConfig`). Ignored at runtime.
332
+ * - object — an already-imported config object. Merged at runtime by
333
+ * `createMono`/`initMono`, so this is the browser-safe form (functions
334
+ * such as DevExtreme source constructors are preserved).
335
+ * - thunk `() => config` — a lazy getter, called at resolve-time. Use this when
336
+ * two configs extend each other (mono-host ⇄ mono-vue): a thunk dodges the
337
+ * ESM circular-import trap where a direct object would still be `undefined`
338
+ * when this module evaluates. e.g. `extends: [() => monoHostConfig]`.
339
+ * - `{ config, merges?, ecosystems? }` — the selective form, taking only part of
340
+ * a layer. See {@link MonoConfigExtendsOptions}.
341
+ */
342
+ type MonoConfigExtendsEntry = MonoConfigExtendsOptions | string | [string, Record<string, any>] | MonoConfigLayer | (() => Partial<MonoConfig> | undefined);
343
+ /**
344
+ * A plain, already-imported config object used as an `extends` layer.
345
+ *
346
+ * The three {@link MonoConfigExtendsOptions} keys are excluded on purpose.
347
+ * `Partial<MonoConfig>` makes every key optional, so *any* object is
348
+ * structurally assignable to it — which meant a selective entry with one bad
349
+ * key (`merges: ['mockIndexedDb']`, `ecosystem` for `ecosystems`) stopped
350
+ * matching `MonoConfigExtendsOptions` and silently landed here instead. That
351
+ * either passed a typo through to a runtime no-op, or produced an error
352
+ * elaborated against whichever other union member TypeScript liked best
353
+ * (`'() => MonoConfig' is not assignable to type 'string'`), naming neither the
354
+ * key nor the type at fault.
355
+ *
356
+ * `config?: never` makes the two members mutually exclusive, so anything
357
+ * carrying a `config` key is checked — and reported — as the selective form.
358
+ */
359
+ type MonoConfigLayer = Partial<MonoConfig> & {
360
+ config?: never;
361
+ merges?: never;
362
+ ecosystems?: never;
363
+ };
364
+ /**
365
+ * Config keys an `extends` layer is allowed to contribute.
366
+ *
367
+ * `name`, `type`, `template` and `skill` identify a config rather than describe
368
+ * shared state, and `extends` is always stripped before merging, so none of the
369
+ * five is ever taken from a layer.
370
+ *
371
+ * `template` matters most here: a remote extends its host, and a host declaring
372
+ * `template: 'host'` leaking down would tell the remote to drop the host's
373
+ * layouts — rendering it with no shell, silently.
374
+ */
375
+ type MonoMergeableKey = keyof Omit<MonoConfig, 'extends' | 'name' | 'type' | 'template' | 'skill'>;
376
+ /**
377
+ * The selective form of an `extends` entry: take only part of a layer.
378
+ *
379
+ * A bare thunk merges everything, which is still the right default. This form is
380
+ * for the case where you want a remote's `menu` and mock data but not its
381
+ * components, or want to ignore a host's directories while developing.
382
+ *
383
+ * ```ts
384
+ * extends: [
385
+ * (): MonoConfig => flowAppConfig, // everything
386
+ * { config: (): MonoConfig => galleryAppConfig,
387
+ * merges: ['menu', 'mockIndexedDB'],
388
+ * ecosystems: ['pages', 'composables', 'stores'] },
389
+ * ]
390
+ * ```
391
+ *
392
+ * Both lists are allowlists, and **omitting one means "no restriction"** — so
393
+ * `{ config }` behaves exactly like the bare thunk. An explicit `[]` means
394
+ * "none", which is how you express config-only or directories-only.
395
+ *
396
+ * `ecosystems` outranks the call site: `mono.ecosystem('components')` in a Vite
397
+ * config, and the Nuxt module's own discovery, both yield nothing for a layer
398
+ * that did not list `components`.
399
+ */
400
+ interface MonoConfigExtendsOptions {
401
+ /**
402
+ * The layer. Thunk form for the same reason as a bare entry — it dodges the
403
+ * ESM circular-import trap between two mutually-extending configs.
404
+ */
405
+ config: (() => Partial<MonoConfig> | undefined) | Partial<MonoConfig>;
406
+ /**
407
+ * Config keys to take from this layer. Omitted = all. `[]` = none.
408
+ *
409
+ * `readonly` so an `as const` list is accepted; it is copied before use.
410
+ */
411
+ merges?: readonly MonoMergeableKey[];
412
+ /**
413
+ * Ecosystem sub-directories this layer may contribute (`'pages'`,
414
+ * `'composables'`, …). Omitted = all. `[]` = none.
415
+ *
416
+ * Matching is segment-wise, so `'composables'` also admits
417
+ * `'composables/shared'`, but `'composables/shared'` admits only itself.
418
+ */
419
+ ecosystems?: readonly string[];
420
+ }
421
+ /**
422
+ * Configs this config extends.
423
+ *
424
+ * The ROOT config — the repo you are working in, the one c12 loads from `cwd` —
425
+ * is the top-priority layer, for every key and (for `env`) in every block. Layers
426
+ * only fill in what the root did not declare. Name-keyed arrays
427
+ * (apps/menu/cookie) are combined and de-duped: a same-key entry from the root
428
+ * replaces the layer's and leads the list, layer-only entries survive.
429
+ */
430
+ type MonoConfigExtends = MonoConfigExtendsEntry[] | Exclude<MonoConfigExtendsEntry, [string, Record<string, any>]>;
431
+ /**
432
+ * One entity (object store) in a mock schema.
433
+ *
434
+ * `fields` uses the mini-DSL `'<type>|<modifier>'`:
435
+ *
436
+ * type number | string | boolean | date | object | array
437
+ * modifier primary | foreign | <localField>-><targetEntity>:<targetKey>
438
+ *
439
+ * A relation modifier reads **`A->B:C` = "rows of B where `B[C] === row[A]`"**;
440
+ * `object` yields the first match, `array` yields all of them. So a one-to-many
441
+ * lives on the PARENT and a many-to-one on the CHILD:
442
+ *
443
+ * @example
444
+ * users: { fields: { id: 'number|primary', name: 'string',
445
+ * cars: 'array|id->cars:userId' } } // parent -> children
446
+ * cars: { fields: { id: 'number|primary', userId: 'number|foreign',
447
+ * user: 'object|userId->users:id' } } // child -> parent
448
+ *
449
+ * Relations are virtual: never stored, materialised only under `$expand`.
450
+ */
451
+ interface MonoMockEntity {
452
+ fields: Record<string, string>;
453
+ /**
454
+ * Explicit fixtures. When present they are used verbatim and the generator is
455
+ * skipped for this entity — the escape hatch for data a generator cannot
456
+ * invent (enum-like columns, serialized graphs, anything an app parses).
457
+ *
458
+ * Must be importable at BUILD time (a literal, or an imported JSON module).
459
+ * Fetching it at runtime would break the offline/no-server guarantee.
460
+ */
461
+ seed?: Record<string, any>[];
462
+ }
463
+ /**
464
+ * Browser-native mock backend. Declaring this makes every `@mono-lit/utility/fetching`
465
+ * call whose url matches one of the `schema` base-urls resolve against
466
+ * IndexedDB instead of the network — the same code path in dev and in a static
467
+ * production build, so there is no server, no port and no CORS.
468
+ *
469
+ * Schemas from several apps merge automatically: `deepMergeLayer` deep-merges
470
+ * plain objects key-by-key, so each app contributes its own base-url. Keep every
471
+ * value here a KEYED OBJECT — arrays are concatenated on merge, never deduped.
472
+ *
473
+ * @example
474
+ * mockIndexedDB: {
475
+ * schema: {
476
+ * 'my-mock': {
477
+ * users: { fields: { id: 'number|primary', name: 'string' } },
478
+ * },
479
+ * },
480
+ * }
481
+ */
482
+ interface MonoMockDbConfig {
483
+ /** IndexedDB database name. Default `mono-mock`. */
484
+ dbName?: string;
485
+ /**
486
+ * Schema version. Bumping it WIPES the store and re-hydrates from the seed —
487
+ * correct for a mock, but it discards whatever the user had saved.
488
+ */
489
+ version?: number;
490
+ /** Rows generated per entity that has no explicit `seed`. Default 10. */
491
+ seedCount?: number;
492
+ /** Fixed RNG seed, so generated rows are identical across reloads. Default 1. */
493
+ seedRandom?: number;
494
+ /** Keyed by base-url: a request url matching one is served from IndexedDB. */
495
+ schema: Record<string, Record<string, MonoMockEntity>>;
496
+ }
497
+ /**
498
+ * Non-secret, environment-specific values, keyed by `NODE_ENV`. Use this for
499
+ * things that aren't really secret (API base URLs, feature flags) so they live
500
+ * in `mono.config.ts` — merged across the host+remote `extends` chain — instead
501
+ * of a `.env` file each dev has to remember to push.
502
+ *
503
+ * The `default` block deep-merges UNDER the active `env[NODE_ENV]` block (the
504
+ * active block wins, key by key). Read the flattened result at runtime with
505
+ * `monoEnv()` / `monoEnv('KEY')`.
506
+ *
507
+ * **Layer beats block.** That mode-wins-over-default rule applies only WITHIN a
508
+ * single config. Across `extends`, the repo you are working in always outranks
509
+ * the layers it extends — so re-declaring a key in your own `default` overrides
510
+ * a host's per-mode value, and you do not have to mirror the host's block layout
511
+ * to override it:
512
+ *
513
+ * ```ts
514
+ * // .mono/apps/mono-host/mono.config.ts
515
+ * env: { development: { MONO_URL: 'https://host.api' } }
516
+ *
517
+ * // your repo's mono.config.ts
518
+ * env: { default: { MONO_URL: 'https://mine.api' } }
519
+ *
520
+ * monoEnv('MONO_URL') // -> 'https://mine.api', in every mode
521
+ * ```
522
+ *
523
+ * Keys you do NOT re-declare keep the host's whole per-environment matrix.
524
+ * See {@link mergeEnvLayer}.
525
+ *
526
+ * Leaves must be scalars: an array value would CONCATENATE across `extends`
527
+ * layers rather than override (see {@link deepMergeLayer}).
528
+ */
529
+ type MonoEnvConfig = {
530
+ /** Shared values merged under every environment. */
531
+ default?: Record<string, string | number | boolean>;
532
+ /** One block per `NODE_ENV` value, e.g. `development` / `production`. */
533
+ [nodeEnv: string]: Record<string, string | number | boolean> | undefined;
534
+ };
535
+ /**
536
+ * Where `mono skills` stores THIS app's knowledge, decisions and AI session
537
+ * history: a git repository the user owns. Its presence in `mono.config.ts` is
538
+ * the feature switch — no `skill` key, no skills workflow (every remote command
539
+ * reports `skipped: true, reason: 'MONO_SKILLS_NOT_CONFIGURED'`).
540
+ *
541
+ * ```ts
542
+ * skill: { url: 'https://github.com/org/app-knowledge.git', envToken: 'APP_SKILLS_TOKEN' }
543
+ * // push into a subfolder on a specific branch (GitHub deep URL):
544
+ * skill: { url: 'https://github.com/org/monorepo/tree/mono/knowledge' }
545
+ * ```
546
+ *
547
+ * Both values must be static string literals — the skills CLI text-parses this
548
+ * file (like `apps[]`) before it could be executed, so a computed `url` reads as
549
+ * an invalid config rather than a different repo.
550
+ */
551
+ interface MonoSkillConfig {
552
+ /**
553
+ * The repository. Either a plain clone URL — `https://host/org/repo.git` on
554
+ * ANY git host, or `ssh://` / `git@host:org/repo.git` (machine credentials
555
+ * only) — or a GitHub deep URL `https://github.com/org/repo/tree/<ref>/<dir>`
556
+ * meaning "on branch `<ref>`, under folder `<dir>`". A bare
557
+ * `https://github.com/org/repo` targets the remote's default branch at its
558
+ * root.
559
+ */
560
+ url: string;
561
+ /**
562
+ * NAME of the env var holding a personal access token — the same convention
563
+ * as `apps[].envToken`. Only read when this machine's own git credentials
564
+ * cannot reach the repo (not invited / no credential); a collaborator never
565
+ * needs it. HTTPS URLs only: the token rides the fetch/push URL and is never
566
+ * written into the clone's `.git/config` or any log line.
567
+ */
568
+ envToken?: string;
569
+ }
570
+ interface MonoConfig {
571
+ extends?: MonoConfigExtends;
572
+ name: string;
573
+ /**
574
+ * This host's own app kind / folder convention. `vue` -> `src/`, `nuxt` ->
575
+ * `app/`. Drives the `@<own-name>` alias and (Nuxt) ecosystem discovery. When
576
+ * statically parsed (pre-config-load, by `monoAlias`), declare it ABOVE `apps`.
577
+ */
578
+ type: MonoAppType;
579
+ /**
580
+ * Host or remote — which side of the federation this app is.
581
+ *
582
+ * The line the two roles have always disagreed on is **layouts**: a `host`
583
+ * ships the shared shell, so it takes its own `layouts/` and NO federated
584
+ * ones; a `remote` consumes the host's, so it takes both. Both readers agree
585
+ * on that:
586
+ *
587
+ * - `mono.vite()` — `monoLayoutsOptions` builds `layoutsDirs` from it.
588
+ * - `@mono-lit/utility/nuxt` — with two paths, both gated on the same answer:
589
+ *
590
+ * - **A federated app that is itself Nuxt** is registered as a native NUXT
591
+ * LAYER (`registerMonoNuxtLayers`), so Nuxt merges its pages, layouts,
592
+ * middleware, plugins and components with its own cross-layer rules. A
593
+ * `'host'` gets no layers at all: a layer is all-or-nothing, so opting one
594
+ * in would hand the host its remotes' `layouts/` with no way to refuse.
595
+ * - **A Vue remote**, which can never be a Nuxt layer, goes through mono's
596
+ * own merge, where the `layouts` ecosystem entry is enabled unless
597
+ * `'host'` — matching `mono.vite()` exactly, absent `template` included.
598
+ * `middleware` and `plugins` are enabled there on an EXPLICIT `'remote'`
599
+ * only: they have no Vite analogue, so there is no prior behaviour to
600
+ * preserve, and a host silently adopting a remote's global middleware
601
+ * would be a regression rather than a fix.
602
+ *
603
+ * Either way a file the app ships itself wins over the federated one.
604
+ *
605
+ * ```ts
606
+ * defineConfig({ name: 'mono-host', type: 'vue', template: 'host', … })
607
+ * ```
608
+ *
609
+ * Optional. Absent behaves as `'remote'`, which is what `mono.vite()` did
610
+ * before this field existed — so adding it breaks nothing, and the long-hand
611
+ * config (`Layouts({ layoutsDirs: mono.ecosystem('layouts') })`) ignores it
612
+ * entirely and keeps deciding for itself. To override for one call, pass the
613
+ * plugin's own option: `mono.layouts.options({ layoutsDirs: [...] })` replaces
614
+ * the whole list.
615
+ *
616
+ * **Never inherited through `extends`.** Like `name` and `type`, it identifies
617
+ * a config rather than describing shared state — a remote that extends a host
618
+ * declaring `template: 'host'` would otherwise inherit it and silently render
619
+ * with no shell. It is read from THIS file only.
620
+ */
621
+ template?: MonoTemplate;
622
+ /**
623
+ * Optional. The user-owned repository `mono skills` reads knowledge from and
624
+ * saves session history to. See {@link MonoSkillConfig}.
625
+ *
626
+ * **Never inherited through `extends`.** Like `template`, it says something
627
+ * about THIS app — which repo holds its history — so a remote extending a host
628
+ * must not silently start filing its sessions into the host's repo. It is read
629
+ * from THIS file only.
630
+ */
631
+ skill?: MonoSkillConfig;
632
+ menu?: SidebarMenu[];
633
+ apps: MonoAppConfig[];
634
+ fetching?: MonoFetchingConfig;
635
+ /**
636
+ * Environment-specific, non-secret values keyed by `NODE_ENV`. Deep-merges
637
+ * across the `extends` chain (current app wins). See {@link MonoEnvConfig}
638
+ * and read it with `monoEnv()`.
639
+ */
640
+ env?: MonoEnvConfig;
641
+ /** Browser-native mock backend (IndexedDB). See {@link MonoMockDbConfig}. */
642
+ mockIndexedDB?: MonoMockDbConfig;
643
+ renderFn?: () => VNode;
644
+ jwt?: MonoJwtConfig;
645
+ cookie?: {
646
+ name: string;
647
+ split?: boolean;
648
+ }[];
649
+ }
650
+ /**
651
+ * Browser-safe defineConfig.
652
+ *
653
+ * No C12 here.
654
+ * No process here.
655
+ * No filesystem here.
656
+ *
657
+ * NOTE on mutually-extending configs: when two configs extend each other via
658
+ * `extends: [() => other]`, TypeScript hits a circular type reference
659
+ * ("'default' implicitly has type 'any' … referenced … in its own initializer").
660
+ * The fix lives in the config file, not here — annotate the thunk's return type
661
+ * so TS stops inferring through the cycle:
662
+ * `extends: [(): MonoConfig => otherConfig]`
663
+ * (or annotate the export: `const config: MonoConfig = defineConfig({...})`).
664
+ */
665
+ declare function defineConfig<T extends MonoConfig>(config: T): T;
666
+ /** Dedupe a name-keyed list, keeping the FIRST occurrence of each key. */
667
+ declare function dedupeBy<T>(list: T[] | undefined, key: (item: T) => string): T[] | undefined;
668
+ /**
669
+ * Collapse the name-keyed arrays of a single config. The layer merge already
670
+ * dedupes pairwise ({@link mergeKeyedList}), so this is the safety net for a
671
+ * config that repeats a key inside its own array — and the ONE rule the C12 node
672
+ * loader shares, so the two can never disagree about precedence.
673
+ */
674
+ declare function dedupeConfigArrays<T extends Partial<MonoConfig>>(config: T): T;
675
+ /**
676
+ * Resolve a config's `extends` at runtime by merging any object layers.
677
+ *
678
+ * Only object entries are merged here (browser-safe). String/path entries are a
679
+ * C12-loader concern and are ignored (with a warning), since the filesystem
680
+ * isn't available at runtime. The current config takes precedence over its
681
+ * layers — every key, and for `env` every block (see {@link mergeEnvLayer}) —
682
+ * and name-keyed arrays (apps/menu/cookie) are combined and de-duped with the
683
+ * current config's entries winning and leading the list.
684
+ *
685
+ * Circular references are supported: two configs may extend each other (e.g.
686
+ * mono-host ⇄ mono-vue). A layer already on the current resolution path is
687
+ * skipped, so whichever config is loaded as the root wins on conflicts.
688
+ *
689
+ * Called automatically by `createMono`/`initMono`, so apps don't normally
690
+ * need to invoke it directly.
691
+ */
692
+ declare function resolveMonoConfig<T extends MonoConfig>(config: T): T;
693
+ /**
694
+ * Flatten a config's {@link MonoEnvConfig} into the values for the active
695
+ * environment: `env.default` merged first, then the active `env[mode]` block on
696
+ * top (active wins). Returns `{}` when there is no `env` field.
697
+ *
698
+ * `config` MUST be already resolved (post-{@link resolveMonoConfig}) — that is
699
+ * where the layer-beats-block rule is applied. Handed a raw config whose
700
+ * `extends` were never merged, this returns only that one config's values; handed
701
+ * a naively block-merged one, a layer's per-mode value would outrank the root's
702
+ * `default`. Prefer the runtime `monoEnv()` accessor, which always reads the
703
+ * resolved config out of `monoState()`.
704
+ */
705
+ declare function resolveEnv(config: Partial<MonoConfig>, mode?: string | undefined): Record<string, string | number | boolean>;
706
+ /**
707
+ * The `name`s of the apps a config activates through its `extends` array — the
708
+ * authoritative "which remotes are switched on" set.
709
+ *
710
+ * Each `extends` entry (a thunk `() => config` or an already-imported object)
711
+ * is resolved and its `name` collected; string/path entries have no name and
712
+ * are skipped. Only the top-level layer's `name` is read — this never recurses
713
+ * into a layer's own `extends`, so it is safe with the circular host⇄remote
714
+ * import graph.
715
+ *
716
+ * Callers use this to gate rendering (page/route + auto-import discovery, and
717
+ * the sidebar menu) on `extends`, so commenting an `extends` entry fully
718
+ * removes that remote while `apps[]` (the `mono sync` clone source) is left
719
+ * untouched. Returns `[]` when there is no `extends` field.
720
+ */
721
+ declare function resolveExtendsAppNames(config: Partial<MonoConfig>): string[];
722
+ /**
723
+ * The per-app ecosystem allowlists declared in `extends`.
724
+ *
725
+ * Keyed by each layer's own `name`, which is also that remote's name in
726
+ * `apps[]` — the same identity `resolveExtendsAppNames` already gates
727
+ * activation on. An app **absent** from the result is unrestricted; an app
728
+ * mapped to `[]` contributes no directories at all.
729
+ *
730
+ * Read from the RAW config for the same reason as `resolveExtendsAppNames`:
731
+ * `resolveMonoConfig` strips `extends` before any consumer could see it.
732
+ */
733
+ declare function resolveExtendsEcosystems(config: Partial<MonoConfig>): Record<string, string[]>;
734
+ //#endregion
735
+ export { resolveEnv as A, MonoSyncTransport as C, dedupeBy as D, SidebarMenu as E, resolveExtendsEcosystems as M, resolveMonoConfig as N, dedupeConfigArrays as O, srcDirForType as P, MonoSkillConfig as S, Permission as T, MonoMergeableKey as _, MonoAppConfig as a, MonoOdataSource as b, MonoConfig as c, MonoConfigExtendsOptions as d, MonoConfigLayer as f, MonoJwtEntry as g, MonoJwtConfig as h, MonoApiEntry as i, resolveExtendsAppNames as j, defineConfig as k, MonoConfigExtends as l, MonoFetchingConfig as m, JWTCompleteTokenTypes as n, MonoAppType as o, MonoEnvConfig as p, MONO_SRC_DIR as r, MonoAuthConfig as s, DefaultJWTTokenTypes as t, MonoConfigExtendsEntry as u, MonoMockDbConfig as v, MonoTemplate as w, MonoRefreshRequestConfig as x, MonoMockEntity as y };