@mono-lit/utility 0.0.0-stage → 0.0.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.
Files changed (54) hide show
  1. package/LICENSE.md +54 -0
  2. package/README.md +156 -2
  3. package/dist/app-roots-BJsIxzjk.d.ts +91 -0
  4. package/dist/app-roots-CvJnmXcs.js +128 -0
  5. package/dist/config-node-UzJrXg0Z.js +76 -0
  6. package/dist/config-node.d.ts +977 -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-D3m6xTaQ.d.ts +733 -0
  11. package/dist/create-config-DdL3Fh6T.js +357 -0
  12. package/dist/fetching.d.ts +239 -0
  13. package/dist/fetching.js +867 -0
  14. package/dist/generate-CJ7MtcDd.js +291 -0
  15. package/dist/index-C2hZeNkq.d.ts +365 -0
  16. package/dist/index-ClrZbU7n.d.ts +518 -0
  17. package/dist/index.d.ts +29 -0
  18. package/dist/index.js +939 -0
  19. package/dist/merge-file-C5nzi_MY.d.ts +122 -0
  20. package/dist/merge-file-CtyKTu5L.js +133 -0
  21. package/dist/mock-db-5mJTObSC.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 +151 -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 +27 -0
  33. package/dist/mono-skills.d.ts +1 -0
  34. package/dist/mono-skills.js +830 -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 +34 -0
  39. package/dist/nuxt-layers.js +3 -0
  40. package/dist/nuxt-runtime.d.ts +18 -0
  41. package/dist/nuxt-runtime.js +102 -0
  42. package/dist/nuxt.d.ts +386 -0
  43. package/dist/nuxt.js +590 -0
  44. package/dist/runtime-C_IWNrAG.js +5817 -0
  45. package/dist/runtime.d.ts +2583 -0
  46. package/dist/runtime.js +4 -0
  47. package/dist/session-Bk985AIM.js +1721 -0
  48. package/dist/types-B6FdB7LJ.d.ts +57 -0
  49. package/dist/universal-B2eD9xho.d.ts +97 -0
  50. package/dist/universal-BNTo_83u.js +599 -0
  51. package/dist/virtual-mono-apps.d.ts +16 -0
  52. package/dist/vite.d.ts +940 -0
  53. package/dist/vite.js +1132 -0
  54. package/package.json +141 -3
@@ -0,0 +1,733 @@
1
+ import { VNode } from "vue";
2
+
3
+ //#region src/composables/create-config.d.ts
4
+ interface Permission {
5
+ permId: number;
6
+ module: string;
7
+ canView: boolean;
8
+ canEdit: boolean;
9
+ canDelete: boolean;
10
+ canCreate: boolean;
11
+ canApprove: boolean;
12
+ canReport: boolean;
13
+ }
14
+ interface DefaultJWTTokenTypes {
15
+ nbf?: number;
16
+ exp?: number;
17
+ iat?: number;
18
+ }
19
+ interface JWTCompleteTokenTypes extends DefaultJWTTokenTypes {
20
+ USER_ID?: string;
21
+ USER_NAME?: string;
22
+ NAME?: string;
23
+ CHANNEL?: string;
24
+ IS_DEPT_HEAD?: '0' | '1';
25
+ ROLE_ID?: string;
26
+ ROLE_NAME?: string;
27
+ ROLE_TYPE?: string;
28
+ ORG_NAME?: string;
29
+ JOBPOS_ID?: string;
30
+ JOBPOS_NAME?: string;
31
+ JOBLVL_ID?: string;
32
+ JOBLVL_NAME?: string;
33
+ COMPANY_DB?: string;
34
+ DEPT_CODE?: string;
35
+ IS_SUPERADMIN?: '0' | '1';
36
+ COMPANY_ID?: string;
37
+ IS_LOCK_BUDGET?: '0' | '1';
38
+ ALL_DEPARTMENT?: '0' | '1';
39
+ ALL_COMPANY?: '0' | '1';
40
+ ALL_BRAND?: '0' | '1';
41
+ ALL_AREA?: '0' | '1';
42
+ IS_APPROVAL_PROGRAM?: '0' | '1';
43
+ USER_BRAND?: string;
44
+ USER_AREA?: string;
45
+ TOKEN_KIND?: 'ACCESS' | 'REFRESH';
46
+ EXPIRED?: string;
47
+ PERMISSIONS?: Permission[] | string;
48
+ }
49
+ /**
50
+ * One JWT the app carries.
51
+ *
52
+ * `name` is either the cookie to decode, or — the dev-mode form — an already-decoded
53
+ * claims object, which is assigned straight into state:
54
+ * `name: import.meta.env.PROD ? 'MONO_token' : { ...decodedAtBoot }`
55
+ */
56
+ interface MonoJwtEntry<T extends object = Record<string, any>> {
57
+ name: string | T;
58
+ split?: boolean;
59
+ }
60
+ /**
61
+ * The `jwt` block. `token` and `refreshToken` are named — so they keep their autocomplete
62
+ * and their own claim types — but ANY key is allowed, for an app that carries a third JWT
63
+ * (a vendor token, an impersonation token, a second identity provider). Each one hydrates
64
+ * into `monoState().jwt.<key>`.
65
+ *
66
+ * The index signature lives in a separate intersection member on purpose: inside a single
67
+ * object type, TS would force `token` and `refreshToken` to be assignable to it, collapsing
68
+ * their specific claim types into the generic entry.
69
+ *
70
+ * One cost worth knowing: an index signature turns OFF excess-property checking for the
71
+ * block, so a mis-cased key (`refreshtoken`) compiles. `initMono` warns about that at
72
+ * runtime, because the type system no longer can.
73
+ */
74
+ type MonoJwtConfig = {
75
+ token?: MonoJwtEntry<JWTCompleteTokenTypes>;
76
+ refreshToken?: MonoJwtEntry<DefaultJWTTokenTypes>;
77
+ } & {
78
+ [key: string]: MonoJwtEntry | undefined;
79
+ };
80
+ interface SidebarMenu {
81
+ title: string;
82
+ subtitle?: string;
83
+ url?: string;
84
+ icon?: string;
85
+ color?: string;
86
+ button?: {
87
+ title?: string;
88
+ icon?: string;
89
+ };
90
+ items?: SidebarMenu[];
91
+ remoteName?: string;
92
+ visible?: boolean;
93
+ order?: number;
94
+ route?: {
95
+ meta: {
96
+ layout: string;
97
+ title: string;
98
+ };
99
+ };
100
+ }
101
+ /**
102
+ * The kind of app, which decides its source-folder convention:
103
+ * - `vue` -> source under `src/` (Vue/Vite apps)
104
+ * - `nuxt` -> source under `app/` (Nuxt apps)
105
+ *
106
+ * Consumed by `monoAlias`/`monoEcosystem` to resolve `@<app>` aliases and remote
107
+ * folder discovery to the right subdir, instead of assuming `src/` everywhere.
108
+ */
109
+ type MonoAppType = 'vue' | 'nuxt';
110
+ /** Source subdir for each app kind. The single place the convention lives. */
111
+ declare const MONO_SRC_DIR: Record<MonoAppType, string>;
112
+ /** Map an app `type` to its source subdir (`vue` -> `src`, `nuxt` -> `app`). */
113
+ declare function srcDirForType(type: MonoAppType): string;
114
+ /**
115
+ * Which side of a federation this app is.
116
+ *
117
+ * Orthogonal to {@link MonoAppType}: `type` says where the source lives (`src/`
118
+ * or `app/`), `template` says whether this app OWNS the shared shell or CONSUMES
119
+ * it. Either kind of app can be either role — read by `mono.vite()` for a Vite
120
+ * app and by the `@mono-lit/utility/nuxt` module for a Nuxt one.
121
+ */
122
+ type MonoTemplate = 'host' | 'remote';
123
+ /**
124
+ * How `mono sync` reaches a remote app's repository.
125
+ *
126
+ * - `auto` (default) probe the machine's own git credentials first — one
127
+ * `git ls-remote`, no token, no GitHub REST rate limit. Falls back to
128
+ * `envToken` + the REST/archive-ZIP path if this machine has no access.
129
+ * - `git` git transport only. Fails the app instead of falling back, so a CI
130
+ * runner with a missing credential errors loudly rather than silently
131
+ * burning the shared PAT.
132
+ * - `token` legacy behaviour: always REST + archive ZIP (needs `unzip` on PATH).
133
+ *
134
+ * Overridable for every app at once with `MONO_SYNC_TRANSPORT`.
135
+ */
136
+ type MonoSyncTransport = 'auto' | 'git' | 'token';
137
+ /**
138
+ * A remote app this host federates — from a clone (`url`, materialised by
139
+ * `mono sync` into `.mono/apps/<name>`) or read in place (`path`, a sibling
140
+ * folder in a mono-lith). Every command reads the same directory; `mono sync`
141
+ * only ever writes and deletes inside `.mono/apps`.
142
+ */
143
+ interface MonoAppConfig {
144
+ name: string;
145
+ /**
146
+ * Where `mono sync` clones this app from (a GitHub URL, optionally with
147
+ * `/tree/<ref>[/<dir>]`).
148
+ *
149
+ * Optional when `path` is set: in a mono-lith the app is read from its
150
+ * sibling folder and there is nothing to clone. Keep it anyway if this app
151
+ * may be lifted out of the lith into a standalone checkout — there the
152
+ * `path` directory is absent, and `mono sync` falls back to the `url`.
153
+ *
154
+ * An entry with neither `url` nor `path` is a config error.
155
+ */
156
+ url?: string;
157
+ /**
158
+ * Read this app from a directory instead of a clone. **Authoritative in
159
+ * every command** — dev, build, `mono prepare`, `mono sync`, `mono env`,
160
+ * the Nuxt module — so a mono-lith (every app a sibling folder of one repo)
161
+ * builds from exactly what dev served:
162
+ *
163
+ * ```ts
164
+ * // apps/esw-host/mono.config.ts
165
+ * apps: [
166
+ * { name: 'esw-project', path: '../esw-project', url: 'https://github.com/org/esw-project/tree/mono', type: 'vue' },
167
+ * ]
168
+ * ```
169
+ *
170
+ * Resolved against the app root, absolute paths kept as-is. Rules:
171
+ *
172
+ * - **The directory wins.** `.mono/apps/<name>` is not read while `path`
173
+ * resolves, and a stale clone there is left alone (never deleted).
174
+ * - **A missing directory falls back to the clone when `url` is set**, with
175
+ * one warning — your machine reads the sibling, a checkout that was lifted
176
+ * out of the lith syncs from GitHub. With no `url` it is an error: there is
177
+ * nothing to fall back to.
178
+ * - **Nothing here is ever written to or deleted.** `mono sync` prunes only
179
+ * inside `.mono/apps`, and `mono prepare` never touches a sibling's
180
+ * `tsconfig.json` — each sibling runs its own prepare.
181
+ * - **Static literal, forward slashes.** `mono.config.ts` is text-parsed
182
+ * before it can be executed, so a computed path yields no alias; and the
183
+ * literal is evaluated as JS, so `'..\esw-x'` loses its backslash.
184
+ *
185
+ * See the Mono-Lith docs.
186
+ */
187
+ path?: string;
188
+ /**
189
+ * Env var holding a GitHub PAT. Only read on the token transport, so it is
190
+ * optional: if every machine that syncs this app is a repo collaborator, the
191
+ * git transport covers it and no token is needed at all.
192
+ */
193
+ envToken?: string;
194
+ /** Sync transport for this app. @default 'auto' */
195
+ transport?: MonoSyncTransport;
196
+ /**
197
+ * App kind / folder convention. `vue` -> `src/`, `nuxt` -> `app/`. Lets the
198
+ * host resolve this remote's `@<name>` alias and synced folders to the
199
+ * correct subdir (a Nuxt remote keeps source under `app/`, not `src/`).
200
+ */
201
+ type: MonoAppType;
202
+ }
203
+ /**
204
+ * The DevExtreme source constructors shared across every OData API in an app.
205
+ * These are the same classes for all OData entries, so they live once at the
206
+ * `fetching.source` level instead of being repeated per entry. The per-API
207
+ * service constructor (`oDataService`) stays on each {@link MonoApiEntry}.
208
+ */
209
+ interface MonoOdataSource {
210
+ /** DevExtreme `DataSource` constructor (shared across all odata APIs) */
211
+ dataSource?: any;
212
+ /** DevExtreme `ODataStore` constructor (shared across all odata APIs) */
213
+ oDataStore?: any;
214
+ /** DevExtreme `CustomStore` constructor (shared across all odata APIs) */
215
+ customStore?: any;
216
+ }
217
+ /**
218
+ * A single named API entry.
219
+ *
220
+ * `url` is always required. `type` is a flag: `'odata'` entries may additionally
221
+ * carry their own `oDataService` constructor (it differs per API). The shared
222
+ * DevExtreme source ctors live on `fetching.source`, not here.
223
+ */
224
+ interface MonoApiEntry {
225
+ type: 'restful' | 'odata';
226
+ url: string;
227
+ /** odata only — the OData service constructor, unique to this API */
228
+ oDataService?: any;
229
+ }
230
+ interface MonoFetchingConfig {
231
+ /**
232
+ * Named map of APIs. Pick one per call with `configBaseUrl: "<entryName>"`.
233
+ *
234
+ * @example
235
+ * api: {
236
+ * Posts: { type: 'restful', url: 'https://jsonplaceholder.typicode.com' },
237
+ * MyApi: { type: 'odata', url: '.../odata', oDataService: DefaultService },
238
+ * }
239
+ */
240
+ api?: {
241
+ [key: string]: MonoApiEntry;
242
+ };
243
+ /**
244
+ * Shared DevExtreme source constructors, reused by every odata API entry.
245
+ *
246
+ * @example
247
+ * source: { dataSource: DataSource, oDataStore: ODataStore, customStore: CustomStore }
248
+ */
249
+ source?: MonoOdataSource;
250
+ auth?: MonoAuthConfig;
251
+ }
252
+ /**
253
+ * The request that swaps an expiring token for a fresh one.
254
+ *
255
+ * Mirrors `MonoFetchCookieOptions` (src/token), which is what the core fetch layer ultimately
256
+ * receives. You supply the endpoint and where to find the new token in its response;
257
+ * the `Authorization` header and the `{ username }` body are filled in for you from
258
+ * the `use.refreshTokenRequest` cookie.
259
+ */
260
+ interface MonoRefreshRequestConfig {
261
+ /**
262
+ * The cookie this re-sets with the new token. Defaults to `use.apiRequest` — i.e.
263
+ * the token the app sends on normal requests, which is the one that has to stay fresh.
264
+ */
265
+ name?: string;
266
+ /**
267
+ * Where to find the pieces in the refresh response body (dot-paths).
268
+ *
269
+ * `value` is the new token. **One of `milis` / `days` is REQUIRED** — it is the
270
+ * cookie's lifetime, and without it the cookie is never written: the refresh appears
271
+ * to succeed and silently changes nothing.
272
+ *
273
+ * @example path: { milis: 'Expired', value: 'RefreshToken' }
274
+ */
275
+ path: {
276
+ milis?: string;
277
+ days?: string;
278
+ value?: string;
279
+ name?: string;
280
+ };
281
+ /** Defaults to whatever `cookie[]` declares for `name`. */
282
+ splitCookie?: boolean;
283
+ fetchParams: {
284
+ url: string; /** 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. */default?: Record<string, string | number | boolean>; /** One block per `NODE_ENV` value, e.g. `development` / `production`. */
531
+ [nodeEnv: string]: Record<string, string | number | boolean> | undefined;
532
+ };
533
+ /**
534
+ * Where `mono skills` stores THIS app's knowledge, decisions and AI session
535
+ * history: a git repository the user owns. Its presence in `mono.config.ts` is
536
+ * the feature switch — no `skill` key, no skills workflow (every remote command
537
+ * reports `skipped: true, reason: 'MONO_SKILLS_NOT_CONFIGURED'`).
538
+ *
539
+ * ```ts
540
+ * skill: { url: 'https://github.com/org/app-knowledge.git', envToken: 'APP_SKILLS_TOKEN' }
541
+ * // push into a subfolder on a specific branch (GitHub deep URL):
542
+ * skill: { url: 'https://github.com/org/monorepo/tree/mono/knowledge' }
543
+ * ```
544
+ *
545
+ * Both values must be static string literals — the skills CLI text-parses this
546
+ * file (like `apps[]`) before it could be executed, so a computed `url` reads as
547
+ * an invalid config rather than a different repo.
548
+ */
549
+ interface MonoSkillConfig {
550
+ /**
551
+ * The repository. Either a plain clone URL — `https://host/org/repo.git` on
552
+ * ANY git host, or `ssh://` / `git@host:org/repo.git` (machine credentials
553
+ * only) — or a GitHub deep URL `https://github.com/org/repo/tree/<ref>/<dir>`
554
+ * meaning "on branch `<ref>`, under folder `<dir>`". A bare
555
+ * `https://github.com/org/repo` targets the remote's default branch at its
556
+ * root.
557
+ */
558
+ url: string;
559
+ /**
560
+ * NAME of the env var holding a personal access token — the same convention
561
+ * as `apps[].envToken`. Only read when this machine's own git credentials
562
+ * cannot reach the repo (not invited / no credential); a collaborator never
563
+ * needs it. HTTPS URLs only: the token rides the fetch/push URL and is never
564
+ * written into the clone's `.git/config` or any log line.
565
+ */
566
+ envToken?: string;
567
+ }
568
+ interface MonoConfig {
569
+ extends?: MonoConfigExtends;
570
+ name: string;
571
+ /**
572
+ * This host's own app kind / folder convention. `vue` -> `src/`, `nuxt` ->
573
+ * `app/`. Drives the `@<own-name>` alias and (Nuxt) ecosystem discovery. When
574
+ * statically parsed (pre-config-load, by `monoAlias`), declare it ABOVE `apps`.
575
+ */
576
+ type: MonoAppType;
577
+ /**
578
+ * Host or remote — which side of the federation this app is.
579
+ *
580
+ * The line the two roles have always disagreed on is **layouts**: a `host`
581
+ * ships the shared shell, so it takes its own `layouts/` and NO federated
582
+ * ones; a `remote` consumes the host's, so it takes both. Both readers agree
583
+ * on that:
584
+ *
585
+ * - `mono.vite()` — `monoLayoutsOptions` builds `layoutsDirs` from it.
586
+ * - `@mono-lit/utility/nuxt` — with two paths, both gated on the same answer:
587
+ *
588
+ * - **A federated app that is itself Nuxt** is registered as a native NUXT
589
+ * LAYER (`registerMonoNuxtLayers`), so Nuxt merges its pages, layouts,
590
+ * middleware, plugins and components with its own cross-layer rules. A
591
+ * `'host'` gets no layers at all: a layer is all-or-nothing, so opting one
592
+ * in would hand the host its remotes' `layouts/` with no way to refuse.
593
+ * - **A Vue remote**, which can never be a Nuxt layer, goes through mono's
594
+ * own merge, where the `layouts` ecosystem entry is enabled unless
595
+ * `'host'` — matching `mono.vite()` exactly, absent `template` included.
596
+ * `middleware` and `plugins` are enabled there on an EXPLICIT `'remote'`
597
+ * only: they have no Vite analogue, so there is no prior behaviour to
598
+ * preserve, and a host silently adopting a remote's global middleware
599
+ * would be a regression rather than a fix.
600
+ *
601
+ * Either way a file the app ships itself wins over the federated one.
602
+ *
603
+ * ```ts
604
+ * defineConfig({ name: 'mono-host', type: 'vue', template: 'host', … })
605
+ * ```
606
+ *
607
+ * Optional. Absent behaves as `'remote'`, which is what `mono.vite()` did
608
+ * before this field existed — so adding it breaks nothing, and the long-hand
609
+ * config (`Layouts({ layoutsDirs: mono.ecosystem('layouts') })`) ignores it
610
+ * entirely and keeps deciding for itself. To override for one call, pass the
611
+ * plugin's own option: `mono.layouts.options({ layoutsDirs: [...] })` replaces
612
+ * the whole list.
613
+ *
614
+ * **Never inherited through `extends`.** Like `name` and `type`, it identifies
615
+ * a config rather than describing shared state — a remote that extends a host
616
+ * declaring `template: 'host'` would otherwise inherit it and silently render
617
+ * with no shell. It is read from THIS file only.
618
+ */
619
+ template?: MonoTemplate;
620
+ /**
621
+ * Optional. The user-owned repository `mono skills` reads knowledge from and
622
+ * saves session history to. See {@link MonoSkillConfig}.
623
+ *
624
+ * **Never inherited through `extends`.** Like `template`, it says something
625
+ * about THIS app — which repo holds its history — so a remote extending a host
626
+ * must not silently start filing its sessions into the host's repo. It is read
627
+ * from THIS file only.
628
+ */
629
+ skill?: MonoSkillConfig;
630
+ menu?: SidebarMenu[];
631
+ apps: MonoAppConfig[];
632
+ fetching?: MonoFetchingConfig;
633
+ /**
634
+ * Environment-specific, non-secret values keyed by `NODE_ENV`. Deep-merges
635
+ * across the `extends` chain (current app wins). See {@link MonoEnvConfig}
636
+ * and read it with `monoEnv()`.
637
+ */
638
+ env?: MonoEnvConfig;
639
+ /** Browser-native mock backend (IndexedDB). See {@link MonoMockDbConfig}. */
640
+ mockIndexedDB?: MonoMockDbConfig;
641
+ renderFn?: () => VNode;
642
+ jwt?: MonoJwtConfig;
643
+ cookie?: {
644
+ name: string;
645
+ split?: boolean;
646
+ }[];
647
+ }
648
+ /**
649
+ * Browser-safe defineConfig.
650
+ *
651
+ * No C12 here.
652
+ * No process here.
653
+ * No filesystem here.
654
+ *
655
+ * NOTE on mutually-extending configs: when two configs extend each other via
656
+ * `extends: [() => other]`, TypeScript hits a circular type reference
657
+ * ("'default' implicitly has type 'any' … referenced … in its own initializer").
658
+ * The fix lives in the config file, not here — annotate the thunk's return type
659
+ * so TS stops inferring through the cycle:
660
+ * `extends: [(): MonoConfig => otherConfig]`
661
+ * (or annotate the export: `const config: MonoConfig = defineConfig({...})`).
662
+ */
663
+ declare function defineConfig<T extends MonoConfig>(config: T): T;
664
+ /** Dedupe a name-keyed list, keeping the FIRST occurrence of each key. */
665
+ declare function dedupeBy<T>(list: T[] | undefined, key: (item: T) => string): T[] | undefined;
666
+ /**
667
+ * Collapse the name-keyed arrays of a single config. The layer merge already
668
+ * dedupes pairwise ({@link mergeKeyedList}), so this is the safety net for a
669
+ * config that repeats a key inside its own array — and the ONE rule the C12 node
670
+ * loader shares, so the two can never disagree about precedence.
671
+ */
672
+ declare function dedupeConfigArrays<T extends Partial<MonoConfig>>(config: T): T;
673
+ /**
674
+ * Resolve a config's `extends` at runtime by merging any object layers.
675
+ *
676
+ * Only object entries are merged here (browser-safe). String/path entries are a
677
+ * C12-loader concern and are ignored (with a warning), since the filesystem
678
+ * isn't available at runtime. The current config takes precedence over its
679
+ * layers — every key, and for `env` every block (see {@link mergeEnvLayer}) —
680
+ * and name-keyed arrays (apps/menu/cookie) are combined and de-duped with the
681
+ * current config's entries winning and leading the list.
682
+ *
683
+ * Circular references are supported: two configs may extend each other (e.g.
684
+ * mono-host ⇄ mono-vue). A layer already on the current resolution path is
685
+ * skipped, so whichever config is loaded as the root wins on conflicts.
686
+ *
687
+ * Called automatically by `createMono`/`initMono`, so apps don't normally
688
+ * need to invoke it directly.
689
+ */
690
+ declare function resolveMonoConfig<T extends MonoConfig>(config: T): T;
691
+ /**
692
+ * Flatten a config's {@link MonoEnvConfig} into the values for the active
693
+ * environment: `env.default` merged first, then the active `env[mode]` block on
694
+ * top (active wins). Returns `{}` when there is no `env` field.
695
+ *
696
+ * `config` MUST be already resolved (post-{@link resolveMonoConfig}) — that is
697
+ * where the layer-beats-block rule is applied. Handed a raw config whose
698
+ * `extends` were never merged, this returns only that one config's values; handed
699
+ * a naively block-merged one, a layer's per-mode value would outrank the root's
700
+ * `default`. Prefer the runtime `monoEnv()` accessor, which always reads the
701
+ * resolved config out of `monoState()`.
702
+ */
703
+ declare function resolveEnv(config: Partial<MonoConfig>, mode?: string | undefined): Record<string, string | number | boolean>;
704
+ /**
705
+ * The `name`s of the apps a config activates through its `extends` array — the
706
+ * authoritative "which remotes are switched on" set.
707
+ *
708
+ * Each `extends` entry (a thunk `() => config` or an already-imported object)
709
+ * is resolved and its `name` collected; string/path entries have no name and
710
+ * are skipped. Only the top-level layer's `name` is read — this never recurses
711
+ * into a layer's own `extends`, so it is safe with the circular host⇄remote
712
+ * import graph.
713
+ *
714
+ * Callers use this to gate rendering (page/route + auto-import discovery, and
715
+ * the sidebar menu) on `extends`, so commenting an `extends` entry fully
716
+ * removes that remote while `apps[]` (the `mono sync` clone source) is left
717
+ * untouched. Returns `[]` when there is no `extends` field.
718
+ */
719
+ declare function resolveExtendsAppNames(config: Partial<MonoConfig>): string[];
720
+ /**
721
+ * The per-app ecosystem allowlists declared in `extends`.
722
+ *
723
+ * Keyed by each layer's own `name`, which is also that remote's name in
724
+ * `apps[]` — the same identity `resolveExtendsAppNames` already gates
725
+ * activation on. An app **absent** from the result is unrestricted; an app
726
+ * mapped to `[]` contributes no directories at all.
727
+ *
728
+ * Read from the RAW config for the same reason as `resolveExtendsAppNames`:
729
+ * `resolveMonoConfig` strips `extends` before any consumer could see it.
730
+ */
731
+ declare function resolveExtendsEcosystems(config: Partial<MonoConfig>): Record<string, string[]>;
732
+ //#endregion
733
+ 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 };