@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,357 @@
1
+ //#region src/composables/create-config.ts
2
+ /** Source subdir for each app kind. The single place the convention lives. */
3
+ const MONO_SRC_DIR = {
4
+ vue: "src",
5
+ nuxt: "app"
6
+ };
7
+ /** Map an app `type` to its source subdir (`vue` -> `src`, `nuxt` -> `app`). */
8
+ function srcDirForType(type) {
9
+ return MONO_SRC_DIR[type];
10
+ }
11
+ /**
12
+ * Browser-safe defineConfig.
13
+ *
14
+ * No C12 here.
15
+ * No process here.
16
+ * No filesystem here.
17
+ *
18
+ * NOTE on mutually-extending configs: when two configs extend each other via
19
+ * `extends: [() => other]`, TypeScript hits a circular type reference
20
+ * ("'default' implicitly has type 'any' … referenced … in its own initializer").
21
+ * The fix lives in the config file, not here — annotate the thunk's return type
22
+ * so TS stops inferring through the cycle:
23
+ * `extends: [(): MonoConfig => otherConfig]`
24
+ * (or annotate the export: `const config: MonoConfig = defineConfig({...})`).
25
+ */
26
+ function defineConfig(config) {
27
+ return config;
28
+ }
29
+ function isPlainObject(value) {
30
+ return value != null && typeof value === "object" && !Array.isArray(value);
31
+ }
32
+ /**
33
+ * Deep-merge `override` onto `base`:
34
+ * - plain objects merge recursively,
35
+ * - arrays concatenate (base first, then override),
36
+ * - everything else (scalars, functions, class constructors) is overwritten.
37
+ *
38
+ * The generic rule. Config layers go through {@link mergeConfigLayer} instead,
39
+ * which overrides this for `env` (layer beats block) and for the name-keyed
40
+ * arrays `apps`/`menu`/`cookie` (same-key override, not concatenation). Every
41
+ * OTHER array — e.g. `mockIndexedDB` seed rows — concatenates as described here.
42
+ */
43
+ function deepMergeLayer(base, override) {
44
+ const out = { ...base };
45
+ for (const key of Object.keys(override)) {
46
+ const o = override[key];
47
+ const b = base[key];
48
+ if (o === void 0) continue;
49
+ if (Array.isArray(o) && Array.isArray(b)) out[key] = [...b, ...o];
50
+ else if (isPlainObject(o) && isPlainObject(b)) out[key] = deepMergeLayer(b, o);
51
+ else out[key] = o;
52
+ }
53
+ return out;
54
+ }
55
+ /** Dedupe a name-keyed list, keeping the FIRST occurrence of each key. */
56
+ function dedupeBy(list, key) {
57
+ if (!Array.isArray(list)) return list;
58
+ const seen = /* @__PURE__ */ new Set();
59
+ const out = [];
60
+ for (const item of list) {
61
+ const k = key(item);
62
+ if (seen.has(k)) continue;
63
+ seen.add(k);
64
+ out.push(item);
65
+ }
66
+ return out;
67
+ }
68
+ /** The config arrays that are keyed by a name rather than positional. */
69
+ const NAME_KEYED_ARRAYS = {
70
+ apps: (a) => a.name,
71
+ menu: (m) => m.title,
72
+ cookie: (c) => c.name
73
+ };
74
+ /**
75
+ * Merge one name-keyed config array over another: a same-key entry from the
76
+ * override layer REPLACES the base layer's, and leads the list; entries only the
77
+ * base layer declares survive, in their original relative order.
78
+ *
79
+ * Concatenating override-first and keeping the first occurrence of each key does
80
+ * both in one pass.
81
+ *
82
+ * @example
83
+ * // host: [{title:'A', url:'/host-a'}, {title:'B'}]
84
+ * // local: [{title:'A', url:'/my-a'}]
85
+ * // -> [{title:'A', url:'/my-a'}, {title:'B'}]
86
+ */
87
+ function mergeKeyedList(base, override, key) {
88
+ if (!Array.isArray(base)) return override;
89
+ if (!Array.isArray(override)) return base;
90
+ return dedupeBy([...override, ...base], key);
91
+ }
92
+ /**
93
+ * Collapse the name-keyed arrays of a single config. The layer merge already
94
+ * dedupes pairwise ({@link mergeKeyedList}), so this is the safety net for a
95
+ * config that repeats a key inside its own array — and the ONE rule the C12 node
96
+ * loader shares, so the two can never disagree about precedence.
97
+ */
98
+ function dedupeConfigArrays(config) {
99
+ return {
100
+ ...config,
101
+ apps: dedupeBy(config.apps, NAME_KEYED_ARRAYS.apps) ?? config.apps,
102
+ menu: dedupeBy(config.menu, NAME_KEYED_ARRAYS.menu),
103
+ cookie: dedupeBy(config.cookie, NAME_KEYED_ARRAYS.cookie)
104
+ };
105
+ }
106
+ /**
107
+ * Merge two {@link MonoEnvConfig} blocks so that LAYER precedence outranks BLOCK
108
+ * precedence.
109
+ *
110
+ * `deepMergeLayer` alone merges env block-by-block (`default` with `default`,
111
+ * `development` with `development`). {@link resolveEnv} then spreads the active
112
+ * mode block over `default` — which silently hands a base layer's per-mode value
113
+ * a win over the overriding layer's `default`:
114
+ *
115
+ * host env: { development: { MONO_URL: 'https://host.api' } }
116
+ * local env: { default: { MONO_URL: 'https://mine.api' } }
117
+ * -> resolveEnv(..., 'development') used to return the HOST url.
118
+ *
119
+ * The rule this restores: the repo you are in wins over everything it extends,
120
+ * and mode-beats-default only applies WITHIN one layer. So every key the
121
+ * override layer declares in its own `default` erases that key from the inherited
122
+ * mode blocks — unless the override layer also spoke about it in that same mode
123
+ * block, in which case its more specific value stands.
124
+ *
125
+ * Keys the override layer never mentions keep the base layer's per-mode values,
126
+ * so a remote still inherits the host's whole per-environment matrix.
127
+ *
128
+ * Mode-independent on purpose: the merge must not bake in `detectMode()`, or
129
+ * `resolveEnv(config, someOtherMode)` would read a config resolved for a
130
+ * different environment.
131
+ */
132
+ function mergeEnvLayer(base, override) {
133
+ if (!isPlainObject(base)) return override;
134
+ if (!isPlainObject(override)) return base;
135
+ const merged = deepMergeLayer(base, override);
136
+ const overrideDefault = override.default;
137
+ if (!isPlainObject(overrideDefault)) return merged;
138
+ for (const mode of Object.keys(merged)) {
139
+ if (mode === "default") continue;
140
+ const mergedBlock = merged[mode];
141
+ if (!isPlainObject(mergedBlock)) continue;
142
+ const overrideBlock = override[mode];
143
+ const block = { ...mergedBlock };
144
+ for (const key of Object.keys(overrideDefault)) {
145
+ if (isPlainObject(overrideBlock) && key in overrideBlock) continue;
146
+ delete block[key];
147
+ }
148
+ merged[mode] = block;
149
+ }
150
+ return merged;
151
+ }
152
+ /**
153
+ * Merge one config layer onto another. Everything goes through
154
+ * {@link deepMergeLayer} — which concatenates arrays and lets the override win on
155
+ * every scalar — except two keys that need their own precedence rule:
156
+ *
157
+ * - `env`, which needs layer-over-block precedence ({@link mergeEnvLayer}),
158
+ * - the name-keyed arrays, which override per key rather than by concatenation
159
+ * ({@link mergeKeyedList}).
160
+ */
161
+ function mergeConfigLayer(base, override) {
162
+ const merged = deepMergeLayer(base, override);
163
+ if ("env" in base || "env" in override) {
164
+ const env = mergeEnvLayer(base.env, override.env);
165
+ if (env === void 0) delete merged.env;
166
+ else merged.env = env;
167
+ }
168
+ for (const [key, keyOf] of Object.entries(NAME_KEYED_ARRAYS)) {
169
+ if (!(key in base) && !(key in override)) continue;
170
+ const list = mergeKeyedList(base[key], override[key], keyOf);
171
+ if (list === void 0) delete merged[key];
172
+ else merged[key] = list;
173
+ }
174
+ return merged;
175
+ }
176
+ /** Safety cap for pathological extends chains that don't share object identity. */
177
+ const MAX_EXTENDS_DEPTH = 50;
178
+ /**
179
+ * Resolve a config's `extends` at runtime by merging any object layers.
180
+ *
181
+ * Only object entries are merged here (browser-safe). String/path entries are a
182
+ * C12-loader concern and are ignored (with a warning), since the filesystem
183
+ * isn't available at runtime. The current config takes precedence over its
184
+ * layers — every key, and for `env` every block (see {@link mergeEnvLayer}) —
185
+ * and name-keyed arrays (apps/menu/cookie) are combined and de-duped with the
186
+ * current config's entries winning and leading the list.
187
+ *
188
+ * Circular references are supported: two configs may extend each other (e.g.
189
+ * mono-host ⇄ mono-vue). A layer already on the current resolution path is
190
+ * skipped, so whichever config is loaded as the root wins on conflicts.
191
+ *
192
+ * Called automatically by `createMono`/`initMono`, so apps don't normally
193
+ * need to invoke it directly.
194
+ */
195
+ function resolveMonoConfig(config) {
196
+ return resolveLayer(config, /* @__PURE__ */ new Set(), 0);
197
+ }
198
+ /**
199
+ * The active `NODE_ENV` used to pick a block out of {@link MonoEnvConfig}.
200
+ *
201
+ * `import.meta.env` FIRST, because that is the only one of the two that exists
202
+ * in a browser bundle: `process` is not defined there, so the `NODE_ENV` branch
203
+ * below is dead in every Vite build. `NODE_ENV` is the Node-side fallback —
204
+ * the mono convention is that each `.env.<x>` sets it (e.g. `.env.dev` ->
205
+ * `NODE_ENV=development`) and `mono env` loads that into `process.env` before
206
+ * Vite starts, which covers `vite.config.ts` and bare-node config eval
207
+ * (odata2ts/jiti), where `import.meta.env` does not exist.
208
+ *
209
+ * `import.meta.env` below must survive type-stripping as a VERBATIM token —
210
+ * Vite replaces that whole member expression with an object literal at build
211
+ * time and does NOT expose it as a real runtime object. The cast is on
212
+ * `import.meta` only so the emitted JS is still exactly `import.meta.env`;
213
+ * aliasing `import.meta` itself (`const meta = import.meta; meta.env`) or
214
+ * optional-chaining between the two defeats the replacement and yields
215
+ * `undefined` at runtime, which makes {@link resolveEnv} silently fall back to
216
+ * `env.default` (dev URLs) even in a production build. Same pattern as each
217
+ * app's `mono.env.ts`.
218
+ */
219
+ function detectMode() {
220
+ try {
221
+ const metaEnv = import.meta.env;
222
+ if (metaEnv) {
223
+ if (metaEnv.MODE) return String(metaEnv.MODE);
224
+ if (metaEnv.PROD) return "production";
225
+ if (metaEnv.DEV) return "development";
226
+ }
227
+ } catch {}
228
+ if (typeof process !== "undefined" && process.env?.NODE_ENV) return process.env.NODE_ENV;
229
+ }
230
+ /**
231
+ * Flatten a config's {@link MonoEnvConfig} into the values for the active
232
+ * environment: `env.default` merged first, then the active `env[mode]` block on
233
+ * top (active wins). Returns `{}` when there is no `env` field.
234
+ *
235
+ * `config` MUST be already resolved (post-{@link resolveMonoConfig}) — that is
236
+ * where the layer-beats-block rule is applied. Handed a raw config whose
237
+ * `extends` were never merged, this returns only that one config's values; handed
238
+ * a naively block-merged one, a layer's per-mode value would outrank the root's
239
+ * `default`. Prefer the runtime `monoEnv()` accessor, which always reads the
240
+ * resolved config out of `monoState()`.
241
+ */
242
+ function resolveEnv(config, mode = detectMode()) {
243
+ const env = config?.env;
244
+ if (!env) return {};
245
+ return {
246
+ ...env.default ?? {},
247
+ ...mode && env[mode] || {}
248
+ };
249
+ }
250
+ /**
251
+ * The `name`s of the apps a config activates through its `extends` array — the
252
+ * authoritative "which remotes are switched on" set.
253
+ *
254
+ * Each `extends` entry (a thunk `() => config` or an already-imported object)
255
+ * is resolved and its `name` collected; string/path entries have no name and
256
+ * are skipped. Only the top-level layer's `name` is read — this never recurses
257
+ * into a layer's own `extends`, so it is safe with the circular host⇄remote
258
+ * import graph.
259
+ *
260
+ * Callers use this to gate rendering (page/route + auto-import discovery, and
261
+ * the sidebar menu) on `extends`, so commenting an `extends` entry fully
262
+ * removes that remote while `apps[]` (the `mono sync` clone source) is left
263
+ * untouched. Returns `[]` when there is no `extends` field.
264
+ */
265
+ function resolveExtendsAppNames(config) {
266
+ const names = [];
267
+ for (const entry of normalizeExtendsEntries(config?.extends)) {
268
+ const name = entry.layer?.name;
269
+ if (typeof name === "string") names.push(name);
270
+ }
271
+ return names;
272
+ }
273
+ /**
274
+ * The per-app ecosystem allowlists declared in `extends`.
275
+ *
276
+ * Keyed by each layer's own `name`, which is also that remote's name in
277
+ * `apps[]` — the same identity `resolveExtendsAppNames` already gates
278
+ * activation on. An app **absent** from the result is unrestricted; an app
279
+ * mapped to `[]` contributes no directories at all.
280
+ *
281
+ * Read from the RAW config for the same reason as `resolveExtendsAppNames`:
282
+ * `resolveMonoConfig` strips `extends` before any consumer could see it.
283
+ */
284
+ function resolveExtendsEcosystems(config) {
285
+ const out = {};
286
+ for (const entry of normalizeExtendsEntries(config?.extends)) {
287
+ const name = entry.layer?.name;
288
+ if (typeof name !== "string" || !entry.ecosystems) continue;
289
+ out[name] = entry.ecosystems;
290
+ }
291
+ return out;
292
+ }
293
+ /** The `{ config, … }` selective form, as opposed to a bare config object. */
294
+ function isExtendsOptions(value) {
295
+ if (!isPlainObject(value) || !("config" in value)) return false;
296
+ const inner = value.config;
297
+ return typeof inner === "function" || isPlainObject(inner);
298
+ }
299
+ /** Resolve one layer source. A thunk that throws contributed nothing. */
300
+ function callLayer(value) {
301
+ if (typeof value === "function") try {
302
+ return value();
303
+ } catch {
304
+ return;
305
+ }
306
+ return isPlainObject(value) ? value : void 0;
307
+ }
308
+ /**
309
+ * The single reader for `extends`, in every shape it accepts.
310
+ *
311
+ * `resolveExtendsAppNames` and `resolveLayer` each used to normalize the array
312
+ * and unwrap thunks themselves. They share this now so the two can never drift
313
+ * on which entry forms they understand — the selective form had to be taught to
314
+ * both, and a second copy is how that goes wrong later.
315
+ */
316
+ function normalizeExtendsEntries(ext) {
317
+ if (ext == null) return [];
318
+ return (Array.isArray(ext) ? ext : [ext]).map((entry) => {
319
+ if (typeof entry === "string" || Array.isArray(entry)) return { pathLayer: entry };
320
+ if (isExtendsOptions(entry)) return {
321
+ layer: callLayer(entry.config),
322
+ merges: entry.merges && [...entry.merges],
323
+ ecosystems: entry.ecosystems && [...entry.ecosystems]
324
+ };
325
+ return { layer: callLayer(entry) };
326
+ });
327
+ }
328
+ /** Allowlist copy. An empty list yields `{}` — the layer contributes nothing. */
329
+ function pickKeys(layer, keys) {
330
+ const out = {};
331
+ for (const key of keys) if (key in layer) out[key] = layer[key];
332
+ return out;
333
+ }
334
+ function resolveLayer(config, stack, depth) {
335
+ const { extends: ext, ...current } = config;
336
+ if (!ext || depth > MAX_EXTENDS_DEPTH) return current;
337
+ const entries = normalizeExtendsEntries(ext);
338
+ const objectLayers = entries.filter((e) => e.layer);
339
+ const pathLayers = entries.filter((e) => e.pathLayer).map((e) => e.pathLayer);
340
+ if (pathLayers.length && typeof console !== "undefined") console.warn("[@mono-lit/utility/config] `extends` string/path sources are only resolved by the C12 node loader (getMonoConfig). At runtime, import the config and pass the object in `extends` instead.", pathLayers);
341
+ if (!objectLayers.length) return current;
342
+ stack.add(config);
343
+ let merged = {};
344
+ for (const entry of objectLayers) {
345
+ const layer = entry.layer;
346
+ if (stack.has(layer)) continue;
347
+ const resolved = resolveLayer(layer, stack, depth + 1);
348
+ const { template: _ownRoleOnly, skill: _ownSkillOnly, ...contribution } = entry.merges ? pickKeys(resolved, entry.merges) : resolved;
349
+ merged = mergeConfigLayer(merged, contribution);
350
+ }
351
+ merged = mergeConfigLayer(merged, current);
352
+ stack.delete(config);
353
+ return dedupeConfigArrays(merged);
354
+ }
355
+
356
+ //#endregion
357
+ export { resolveEnv as a, resolveMonoConfig as c, defineConfig as i, srcDirForType as l, dedupeBy as n, resolveExtendsAppNames as o, dedupeConfigArrays as r, resolveExtendsEcosystems as s, MONO_SRC_DIR as t };
@@ -0,0 +1,239 @@
1
+ import { a as monoMockDb, n as MonoMockRequest, o as resetMonoMockDb, r as MonoMockResponse, t as MonoMockDb } from "./index-C2hZeNkq.js";
2
+ import { G as UseOdataStaticOpts, I as NormalFetchOptions, R as OdataFetchTypes, a as TryCatchDatasourceParams, d as promiseWrapper, i as OdataFetchUniqueTypes, o as createFetcher, r as LoadChunkStoreArgs, z as TanstackFetchOptions } from "./index-ClrZbU7n.js";
3
+ import DataSource from "devextreme/data/data_source";
4
+ import CustomStore from "devextreme/data/custom_store";
5
+ import ODataStore from "devextreme/data/odata/store";
6
+
7
+ //#region pkg/wrapper-fetching.d.ts
8
+ type FetchError = {
9
+ message: string;
10
+ stack: string;
11
+ response: any;
12
+ };
13
+ type FetchResult<T> = Promise<{
14
+ data: T | null;
15
+ dataSource: DataSource<T> | null;
16
+ statusCode: number;
17
+ error: FetchError | null;
18
+ }>;
19
+ /**
20
+ * `configBaseUrl` names an entry in `fetching.api`. When set, the call's base
21
+ * url (and, for odata, its source constructors) is resolved from that entry,
22
+ * overriding the call's own `baseUrl`. This prop is mono-only and is stripped
23
+ * before delegating to the core fetch layer fetch functions.
24
+ */
25
+ type MonoOdataFetchParams = Omit<OdataFetchTypes, 'source'> & {
26
+ source?: OdataFetchTypes['source'];
27
+ } & {
28
+ configBaseUrl?: string;
29
+ };
30
+ type MonoOdataUniqueParams<T> = Omit<OdataFetchUniqueTypes<T>, 'source'> & {
31
+ source?: OdataFetchUniqueTypes<T>['source'];
32
+ } & {
33
+ configBaseUrl?: string;
34
+ };
35
+ /** The core's `ConfigType`: the two cookie names its token machinery reads. */
36
+ type MonoTokenConfig = {
37
+ jwtName: string;
38
+ jwtRefreshName: string;
39
+ };
40
+ /**
41
+ * `fetchNormal` takes `config` positionally, so the core's own options type has no room for
42
+ * it. Accept it as a prop here and forward it to the right place — a caller shouldn't
43
+ * have to know about that asymmetry.
44
+ */
45
+ type MonoNormalFetchParams = NormalFetchOptions & {
46
+ configBaseUrl?: string;
47
+ config?: MonoTokenConfig;
48
+ /**
49
+ * Opt-in TanStack Query behaviour (dedupe, cache, retries, offline pause). Applied only when the
50
+ * installed `@mono-lit/devextreme` provides a `tanstackRun` export; otherwise ignored.
51
+ */
52
+ tanstack?: TanstackFetchOptions;
53
+ };
54
+ /** Options for `monoFetch(url, { tanstack })` / `monoOdataFetch({ tanstack })`. */
55
+ type MonoTanstackFetchOptions = TanstackFetchOptions;
56
+ type MonoCreateFetcherParams = Omit<OdataFetchTypes, 'source'> & {
57
+ source?: OdataFetchTypes['source'];
58
+ } & {
59
+ configBaseUrl?: string;
60
+ };
61
+ type MonoFetchingRuntimeOptions = {
62
+ /**
63
+ * Your app notification object/function.
64
+ * Example from your old code:
65
+ * const { notif } = useHelperMonoVue()
66
+ */
67
+ notif?: any;
68
+ /**
69
+ * Override token directly.
70
+ */
71
+ token?: string;
72
+ /**
73
+ * Override REST base URL.
74
+ */
75
+ restBaseUrl?: string;
76
+ /**
77
+ * Override OData base URL.
78
+ */
79
+ odataBaseUrl?: string;
80
+ /**
81
+ * Called when a request is unauthorized and no refresh could save it — typically
82
+ * `() => router.push('/login')`. It lives here rather than in `mono.config.ts`
83
+ * because it needs the router.
84
+ *
85
+ * NOTE: registering it SHORT-CIRCUITS `auth.expiredBehaviour` — the core calls this and
86
+ * returns rather than attempting the reload.
87
+ */
88
+ unauthCall?: () => void;
89
+ };
90
+ declare function configureFetching(options?: MonoFetchingRuntimeOptions): void;
91
+ declare function resetFetchingConfig(): void;
92
+ type ODataServiceCtor = new (...args: any[]) => any;
93
+ /**
94
+ * The capitalized source-ctor shape the core fetch layer expects. A partial source is fine
95
+ * — `mapSharedSource` fills every field from the `@mono-lit/devextreme` defaults — but
96
+ * a fully-absent source must NOT reach the core fetch layer: it `import type`s DevExtreme and
97
+ * calls `new source.ODataStore(...)` with no fallback of its own, so a missing
98
+ * ctor crashes with "ods is not a constructor". `getSharedSource` guarantees the
99
+ * three store ctors are always present; `OdataService` stays per-entry.
100
+ */
101
+ type ResolvedODataSource = {
102
+ DataSource?: typeof DataSource;
103
+ ODataStore?: typeof ODataStore;
104
+ CustomStore?: typeof CustomStore;
105
+ OdataService?: ODataServiceCtor;
106
+ };
107
+ declare function getRestBaseUrl(configBaseUrl?: string, explicitBaseUrl?: string): string;
108
+ declare function getODataBaseUrl(configBaseUrl?: string, explicitBaseUrl?: string): string;
109
+ /**
110
+ * Resolve the OData source ctors. Never throws — when nothing is configured it
111
+ * returns `undefined` and the core fetch layer falls back to its built-in DevExtreme
112
+ * classes.
113
+ *
114
+ * With `configBaseUrl`, the named entry's resolved source wins (already the
115
+ * shared `fetching.source` ctors merged with that entry's `oDataService`).
116
+ * Without it, the shared `fetching.source` is the base, with any inline
117
+ * per-call `source` overriding it per defined field.
118
+ */
119
+ declare function getODataSource(configBaseUrl?: string, inlineSource?: ResolvedODataSource): ResolvedODataSource | undefined;
120
+ /**
121
+ * The token that goes on this call.
122
+ *
123
+ * Hand the core the RAW cookie value, untouched: the core decides whether a passed token is
124
+ * "the cookie" or "the caller's own" by byte-equality with the live cookie, and only a
125
+ * cookie-derived token keeps following the cookie across refreshes for the life of a
126
+ * DataSource. Anything that transforms the value here turns every store into one that
127
+ * sends the token it was built with forever.
128
+ */
129
+ declare function getRequestToken(manualToken?: string): any;
130
+ /**
131
+ * Optional helper if you want to manually refresh state before fetching.
132
+ *
133
+ * Usually unnecessary if createMono(monoConfig) already runs once.
134
+ */
135
+ declare function getFetchingRuntime(configBaseUrl?: string): {
136
+ config: {
137
+ readonly api?: {
138
+ readonly [x: string]: {
139
+ readonly type: "restful" | "odata";
140
+ readonly url: string;
141
+ readonly oDataService?: any;
142
+ };
143
+ } | undefined;
144
+ readonly source?: {
145
+ readonly dataSource?: any;
146
+ readonly oDataStore?: any;
147
+ readonly customStore?: any;
148
+ } | undefined;
149
+ readonly auth?: {
150
+ readonly token?: string | undefined;
151
+ readonly tokenRefresh?: string | undefined;
152
+ readonly use?: "token" | "tokenRefresh" | {
153
+ readonly apiRequest?: string | undefined;
154
+ readonly refreshTokenRequest?: string | undefined;
155
+ } | undefined;
156
+ readonly requestRefreshTokenRequest?: {
157
+ readonly name?: string | undefined;
158
+ readonly path: {
159
+ readonly milis?: string | undefined;
160
+ readonly days?: string | undefined;
161
+ readonly value?: string | undefined;
162
+ readonly name?: string | undefined;
163
+ };
164
+ readonly splitCookie?: boolean | undefined;
165
+ readonly fetchParams: {
166
+ readonly url: string;
167
+ readonly options?: {
168
+ readonly [x: string]: any;
169
+ readonly baseUrl?: string | undefined;
170
+ } | undefined;
171
+ };
172
+ } | undefined;
173
+ readonly expiredBehaviour?: "refresh" | undefined;
174
+ } | undefined;
175
+ };
176
+ restBaseUrl: string | undefined;
177
+ odataBaseUrl: string | undefined;
178
+ source: ResolvedODataSource | undefined;
179
+ token: any;
180
+ };
181
+ declare const useCreateFetcher: <T>(base: MonoCreateFetcherParams) => {
182
+ response(option?: any): FetchResult<T>;
183
+ };
184
+ declare function useTryCatchDatasource<T>(opt: TryCatchDatasourceParams<T>): Promise<T>;
185
+ declare const createStaticDataSource: <T extends Record<string, any>>(opt: UseOdataStaticOpts<T>) => Promise<{
186
+ dataSource: DataSource<T, any>;
187
+ data: T[] | null;
188
+ statusCode: number;
189
+ error: null | {
190
+ message: string;
191
+ stack: string;
192
+ response: any;
193
+ };
194
+ }>;
195
+ declare const useMyFetchOData: <T = any>({
196
+ url,
197
+ options,
198
+ type,
199
+ params,
200
+ notif,
201
+ headers,
202
+ selfProxy,
203
+ method,
204
+ force,
205
+ allowZero,
206
+ cache,
207
+ override,
208
+ baseUrl,
209
+ configBaseUrl,
210
+ source,
211
+ token,
212
+ payload,
213
+ ...rest
214
+ }: MonoOdataFetchParams) => FetchResult<T>;
215
+ declare const useFetchOdataUnique: <T = any>({
216
+ url,
217
+ options,
218
+ type,
219
+ params,
220
+ notif,
221
+ headers,
222
+ selfProxy,
223
+ method,
224
+ force,
225
+ allowZero,
226
+ cache,
227
+ override,
228
+ baseUrl,
229
+ configBaseUrl,
230
+ source,
231
+ token,
232
+ unique,
233
+ payload,
234
+ ...rest
235
+ }: MonoOdataUniqueParams<T>) => FetchResult<T>;
236
+ declare function useMyFetch<T = any>(url: string, opt: MonoNormalFetchParams): Promise<any>;
237
+ declare const loadChuckStores: <T>(opt: LoadChunkStoreArgs<T>) => Promise<T[]>;
238
+ //#endregion
239
+ export { type MonoMockDb, type MonoMockRequest, type MonoMockResponse, MonoTanstackFetchOptions, createFetcher, configureFetching as monoConfigureFetching, useCreateFetcher as monoCreateFetcher, useMyFetch as monoFetch, useMyFetchOData as monoFetchOdata, useMyFetchOData as monoOdataFetch, useFetchOdataUnique as monoFetchOdataUnique, useFetchOdataUnique as monoOdataFetchUnique, getFetchingRuntime as monoFetchingRuntime, loadChuckStores as monoLoadChuckStores, monoMockDb, getODataBaseUrl as monoOdataBaseUrl, getODataSource as monoOdataSource, getRequestToken as monoRequestToken, resetFetchingConfig as monoResetFetchingConfig, getRestBaseUrl as monoRestBaseUrl, createStaticDataSource as monoStaticDataSource, useTryCatchDatasource as monoTryCatchDatasource, promiseWrapper, resetMonoMockDb };