@mono-lit/utility 0.0.6 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config-node-Dn0K54kd.js +153 -0
- package/dist/config-node.d.ts +7 -0
- package/dist/config-node.js +1 -1
- package/dist/fetching.d.ts +1 -1
- package/dist/{index-CLXtqgEx.d.ts → index-GhC2ux6U.d.ts} +12 -1
- package/dist/mono-db.js +1 -1
- package/dist/nuxt.js +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/vite.js +1 -1
- package/package.json +13 -14
- package/dist/config-node-UzJrXg0Z.js +0 -76
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { r as dedupeConfigArrays } from "./create-config-DdL3Fh6T.js";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import { loadConfig } from "c12";
|
|
6
|
+
|
|
7
|
+
//#region src/composables/config-node.ts
|
|
8
|
+
/**
|
|
9
|
+
* Runtime-only imports a `mono.config.ts` makes that the Node-side readers never use.
|
|
10
|
+
*
|
|
11
|
+
* App configs import `{ DataSource, ODataStore, CustomStore }` from
|
|
12
|
+
* `@mono-lit/devextreme` and only STORE them (`dataSource: DataSource`), for the
|
|
13
|
+
* browser to use. Nothing that reads the config in Node needs them: the Nuxt/Vite
|
|
14
|
+
* integrations read `name` / `apps` / `menu` / `template`, `sanitizeForExpose` drops
|
|
15
|
+
* functions, and `mono db` reads the mock schemas.
|
|
16
|
+
*
|
|
17
|
+
* Loading the real package is very slow. It pulls in hundreds of DevExtreme
|
|
18
|
+
* `devextreme/data/*` CommonJS files written with directory imports, and jiti
|
|
19
|
+
* resolves every one with synchronous `stat` calls. c12 also creates jiti with
|
|
20
|
+
* `moduleCache: false`, so EVERY `getMonoConfig` call pays the cost again. On
|
|
21
|
+
* Windows that measured ~0.7–1.2 s per config, against ~0.15 s stubbed. A
|
|
22
|
+
* mono-lith host loads one config per app at startup, which made Nuxt report
|
|
23
|
+
* `mono-nuxt` and app modules as slow to set up (7–12 s).
|
|
24
|
+
*/
|
|
25
|
+
const RUNTIME_STUBS = { "@mono-lit/devextreme": {
|
|
26
|
+
file: "devextreme-v1.mjs",
|
|
27
|
+
source: `// Generated by @mono-lit/utility; do not edit.
|
|
28
|
+
//
|
|
29
|
+
// Stands in for @mono-lit/devextreme while a mono.config is loaded in Node
|
|
30
|
+
// (getMonoConfig). The config only stores these classes for the browser; Node-side
|
|
31
|
+
// readers never construct them. See RUNTIME_STUBS in @mono-lit/utility.
|
|
32
|
+
export class DataSource {}
|
|
33
|
+
export class CustomStore {}
|
|
34
|
+
export class ODataStore {}
|
|
35
|
+
export class ArrayStore {}
|
|
36
|
+
export function config() { return {} }
|
|
37
|
+
`
|
|
38
|
+
} };
|
|
39
|
+
let runtimeStubAliasCache;
|
|
40
|
+
/**
|
|
41
|
+
* Write the stub modules once per process into the OS temp dir and return the
|
|
42
|
+
* alias map (specifier → stub file). The temp dir instead of the app's `.mono/`,
|
|
43
|
+
* because sibling apps in a mono-lith are read in place and may have no `.mono/`.
|
|
44
|
+
*/
|
|
45
|
+
function runtimeStubAliases() {
|
|
46
|
+
if (runtimeStubAliasCache) return runtimeStubAliasCache;
|
|
47
|
+
const dir = path.join(os.tmpdir(), "mono-lit-utility", "config-stubs");
|
|
48
|
+
const alias = {};
|
|
49
|
+
for (const [specifier, { file, source }] of Object.entries(RUNTIME_STUBS)) {
|
|
50
|
+
const target = path.join(dir, file);
|
|
51
|
+
let current;
|
|
52
|
+
try {
|
|
53
|
+
current = fs.readFileSync(target, "utf8");
|
|
54
|
+
} catch {
|
|
55
|
+
current = void 0;
|
|
56
|
+
}
|
|
57
|
+
if (current !== source) {
|
|
58
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
59
|
+
const tmp = `${target}.${process.pid}.tmp`;
|
|
60
|
+
fs.writeFileSync(tmp, source);
|
|
61
|
+
try {
|
|
62
|
+
fs.renameSync(tmp, target);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
fs.rmSync(tmp, { force: true });
|
|
65
|
+
if (!fs.existsSync(target)) throw error;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
alias[specifier] = target;
|
|
69
|
+
}
|
|
70
|
+
runtimeStubAliasCache = alias;
|
|
71
|
+
return alias;
|
|
72
|
+
}
|
|
73
|
+
function getCwd() {
|
|
74
|
+
return typeof process !== "undefined" ? process.cwd() : void 0;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Collapse name-keyed arrays that may carry one duplicate per layer, so the
|
|
78
|
+
* loaded config behaves like a single config.
|
|
79
|
+
*
|
|
80
|
+
* Delegates to `dedupeConfigArrays` from `create-config` rather than owning a
|
|
81
|
+
* rule: this used to keep the FIRST occurrence while the runtime resolver keeps
|
|
82
|
+
* the LAST, which are opposite precedence rules for the same data. It is a no-op
|
|
83
|
+
* while `extend: false` (below) leaves c12 with only the root config's own
|
|
84
|
+
* arrays, but the two must never be able to disagree.
|
|
85
|
+
*/
|
|
86
|
+
function normalizeMergedConfig(config) {
|
|
87
|
+
return dedupeConfigArrays(config);
|
|
88
|
+
}
|
|
89
|
+
async function loadMonoConfig(options = {}) {
|
|
90
|
+
const { stubRuntimeDeps = true, ...loadOptions } = options;
|
|
91
|
+
const jitiOptions = stubRuntimeDeps ? {
|
|
92
|
+
...loadOptions.jitiOptions,
|
|
93
|
+
alias: {
|
|
94
|
+
...runtimeStubAliases(),
|
|
95
|
+
...loadOptions.jitiOptions?.alias
|
|
96
|
+
}
|
|
97
|
+
} : loadOptions.jitiOptions;
|
|
98
|
+
const result = await loadConfig({
|
|
99
|
+
name: "mono",
|
|
100
|
+
cwd: options.cwd ?? getCwd(),
|
|
101
|
+
extend: false,
|
|
102
|
+
defaults: {
|
|
103
|
+
apps: [],
|
|
104
|
+
name: "mono-app",
|
|
105
|
+
type: "vue",
|
|
106
|
+
menu: [],
|
|
107
|
+
cookie: [],
|
|
108
|
+
jwt: {}
|
|
109
|
+
},
|
|
110
|
+
...loadOptions,
|
|
111
|
+
...jitiOptions ? { jitiOptions } : {}
|
|
112
|
+
});
|
|
113
|
+
return {
|
|
114
|
+
...result,
|
|
115
|
+
config: normalizeMergedConfig(result.config)
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
async function getMonoConfig(options = {}) {
|
|
119
|
+
try {
|
|
120
|
+
return (await loadMonoConfig(options)).config;
|
|
121
|
+
} catch (error) {
|
|
122
|
+
throw describeConfigLoadError(error);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/** `Cannot find module '@some-app-root/mono.config'` — the shape jiti throws. */
|
|
126
|
+
const MISSING_ALIAS_RE = /Cannot find module ['"](@[^'"]+)['"]/;
|
|
127
|
+
/**
|
|
128
|
+
* Turn an unresolved mono alias into an error that says what to do.
|
|
129
|
+
*
|
|
130
|
+
* `mono.config.ts` reaches other apps through ordinary `import`s resolved by jiti
|
|
131
|
+
* against the alias map, and those aliases come from the `.mono/apps/` directory
|
|
132
|
+
* listing. An app that isn't synced therefore surfaces as a bare `Cannot find
|
|
133
|
+
* module '@x-root/mono.config'` — a specifier nobody typed by hand, thrown from
|
|
134
|
+
* inside c12, naming no file and no fix.
|
|
135
|
+
*
|
|
136
|
+
* Pattern-based on purpose: this module knows nothing about the alias map, and
|
|
137
|
+
* shouldn't. Covers the paths that never call `monoStubAliases` (the `mono db` CLI)
|
|
138
|
+
* and the specifiers a config-only stub can't satisfy (a host config importing a
|
|
139
|
+
* missing app's OData service).
|
|
140
|
+
*/
|
|
141
|
+
function describeConfigLoadError(error) {
|
|
142
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
143
|
+
const specifier = MISSING_ALIAS_RE.exec(message)?.[1];
|
|
144
|
+
if (!specifier) return error;
|
|
145
|
+
return new Error([
|
|
146
|
+
`[@mono-lit/utility] Failed to load mono.config: cannot resolve '${specifier}'.`,
|
|
147
|
+
"That looks like a federated mono app that isn't present in .mono/apps/.",
|
|
148
|
+
"Run `mono sync && mono prepare`. If the repo is private, set its envToken in .env."
|
|
149
|
+
].join("\n"), { cause: error });
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
//#endregion
|
|
153
|
+
export { loadMonoConfig as n, getMonoConfig as t };
|
package/dist/config-node.d.ts
CHANGED
|
@@ -5,6 +5,13 @@ import { TSConfig } from "pkg-types";
|
|
|
5
5
|
//#region src/composables/config-node.d.ts
|
|
6
6
|
export interface LoadMonoConfigOptions extends Partial<LoadConfigOptions<MonoConfig>> {
|
|
7
7
|
cwd?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Swap runtime-only imports of `mono.config.ts` for inert stubs while loading it
|
|
10
|
+
* in Node (default `true`). See `RUNTIME_STUBS`. Set `false` only if a Node-side
|
|
11
|
+
* caller really needs the real classes out of the config. A caller's own
|
|
12
|
+
* `jitiOptions.alias` entry for the same specifier still wins.
|
|
13
|
+
*/
|
|
14
|
+
stubRuntimeDeps?: boolean;
|
|
8
15
|
}
|
|
9
16
|
export declare function loadMonoConfig(options?: LoadMonoConfigOptions): Promise<{
|
|
10
17
|
config: MonoConfig;
|
package/dist/config-node.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as isMissingPathError, c as pathAppRoots, i as isHostedApp, l as resetAppPathWarnings, n as hasUrl, o as linkedAppRoots, r as hostedAppRoots, s as missingPathMessage, t as appRootDirs, u as resolveAppRoots } from "./app-roots-LpDrHF_J.js";
|
|
2
|
-
import { n as loadMonoConfig, t as getMonoConfig } from "./config-node-
|
|
2
|
+
import { n as loadMonoConfig, t as getMonoConfig } from "./config-node-Dn0K54kd.js";
|
|
3
3
|
import { a as extractTemplate, c as monoConfigFileFor, d as resolveFederatedRoots, f as stripCommentsSafe, i as extractSkill, l as monoMissingApps, n as extractConfig, o as formatMissingApps, r as extractConfigName, s as monoAlias, t as assertAppSources, u as monoStubAliases } from "./mono-alias-BU2B0tYL.js";
|
|
4
4
|
import { a as buildMonoTsconfig, i as adoptHostedApps, n as MONO_DIR, o as monoTsconfigPaths, r as MONO_TSCONFIG_REF, s as runMonoPrepare, t as MONO_APPS_DIR } from "./mono-tsconfig-CYOKwy6E.js";
|
|
5
5
|
import { A as BASE_ARGS, B as refPatterns, C as commitAndPush, D as repoDir, E as readRepoFile, F as parseHeadSha, G as SKILLS_DEFAULTS, H as tokenRemote, I as parseLsRemote, J as loadSkillsEnv, K as isGenericAppName, L as parseSymref, M as firstFatal, N as gitEnv, O as resolveRemote, P as isNonFastForward, R as redactUrl, S as SkillsAccessError, T as listRepoFiles, U as ALLOWED_FLAGS, V as runGit, W as GENERIC_APP_NAMES, Y as resolveSkillTarget, _ as stagingRoot, a as applyPlan, b as resolveAppId, c as chunkConversation, d as REQUIRED_FILES, f as cacheDir, g as removeSession, h as moveToFailed, i as runSearch, j as classifyGitFailure, k as skillsRoot, l as redact, m as loadStagedSession, n as runCheck, o as buildSavePlan, p as listSessions, q as loadSkillConfig, r as runRead, s as runSave, t as runSessionShow, u as redactBuffer, v as validateStagedSession, w as ensureRepo, x as detectActor, y as normalizeAppId, z as refDirCandidates } from "./session-CbSl2BMJ.js";
|
package/dist/fetching.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as monoMockDb, n as MonoMockRequest, o as resetMonoMockDb, r as MonoMockResponse, t as MonoMockDb } from "./index-BAy6tbOG.js";
|
|
2
|
-
import { G as OdataFetchTypes, K as TanstackFetchOptions, Q as UseOdataStaticOpts, U as NormalFetchOptions, _ as getPrefetchBridge, a as TryCatchDatasourceParams, d as promiseWrapper, g as MonoPrefetchRequest, h as MonoPrefetchBridge, i as OdataFetchUniqueTypes, n as FetchOverrides, o as createFetcher, r as LoadChunkStoreArgs } from "./index-
|
|
2
|
+
import { G as OdataFetchTypes, K as TanstackFetchOptions, Q as UseOdataStaticOpts, U as NormalFetchOptions, _ as getPrefetchBridge, a as TryCatchDatasourceParams, d as promiseWrapper, g as MonoPrefetchRequest, h as MonoPrefetchBridge, i as OdataFetchUniqueTypes, n as FetchOverrides, o as createFetcher, r as LoadChunkStoreArgs } from "./index-GhC2ux6U.js";
|
|
3
3
|
import DataSource from "devextreme/data/data_source";
|
|
4
4
|
import CustomStore from "devextreme/data/custom_store";
|
|
5
5
|
import ODataStore from "devextreme/data/odata/store";
|
|
@@ -3,7 +3,6 @@ import { NotivueItem, PushOptions } from "notivue";
|
|
|
3
3
|
import { RouteLocationNormalizedLoadedGeneric, Router } from "vue-router";
|
|
4
4
|
import DataSource, { DataSourceOptions } from "devextreme/data/data_source";
|
|
5
5
|
import CustomStore, { CustomStoreOptions } from "devextreme/data/custom_store";
|
|
6
|
-
import { FetchRequestConfig } from "@odata2ts/http-client-fetch";
|
|
7
6
|
import ODataStore, { ODataStoreOptions } from "devextreme/data/odata/store";
|
|
8
7
|
import { DxColumn, DxDataGrid, DxDataGridTypes } from "devextreme-vue/data-grid";
|
|
9
8
|
import * as yup from "yup";
|
|
@@ -44,6 +43,18 @@ type Result<T> = {
|
|
|
44
43
|
};
|
|
45
44
|
declare function createStaticDatasource<T extends AnyObj>(opts: UseOdataStaticOpts<T>): Promise<Result<T>>;
|
|
46
45
|
//#endregion
|
|
46
|
+
//#region ../../node_modules/.pnpm/@odata2ts+http-client-fetch@0.9.0/node_modules/@odata2ts/http-client-fetch/lib/FetchRequestConfig.d.ts
|
|
47
|
+
/**
|
|
48
|
+
* Available config options for end user when making a given request.
|
|
49
|
+
*/
|
|
50
|
+
interface FetchRequestConfig extends Partial<Pick<RequestInit, "credentials" | "cache" | "mode" | "redirect" | "referrerPolicy" | "signal">> {
|
|
51
|
+
headers?: Record<string, string> | Headers;
|
|
52
|
+
/**
|
|
53
|
+
* Add query params.
|
|
54
|
+
*/
|
|
55
|
+
params?: Record<string, string | number | boolean | Array<string | number | boolean>>;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
47
58
|
//#region src/core/types/notif-action.d.ts
|
|
48
59
|
/** Relaxed button descriptor — no Vuetify dependency. */
|
|
49
60
|
interface MonoNotifButton {
|
package/dist/mono-db.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as resolveMonoConfig } from "./create-config-DdL3Fh6T.js";
|
|
2
|
-
import { t as getMonoConfig } from "./config-node-
|
|
2
|
+
import { t as getMonoConfig } from "./config-node-Dn0K54kd.js";
|
|
3
3
|
import { s as monoAlias } from "./mono-alias-BU2B0tYL.js";
|
|
4
4
|
import { n as generateSeed, s as parseMockSchema } from "./generate-CJ7MtcDd.js";
|
|
5
5
|
import { writeFileSync } from "node:fs";
|
package/dist/nuxt.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as pathAppRoots, t as appRootDirs } from "./app-roots-LpDrHF_J.js";
|
|
2
2
|
import { c as resolveMonoConfig, l as srcDirForType, o as resolveExtendsAppNames, s as resolveExtendsEcosystems } from "./create-config-DdL3Fh6T.js";
|
|
3
3
|
import { n as mergeEcosystem, r as monoEcosystem, t as ecosystemSubAllowed } from "./merge-file-DahuGcvr.js";
|
|
4
|
-
import { t as getMonoConfig } from "./config-node-
|
|
4
|
+
import { t as getMonoConfig } from "./config-node-Dn0K54kd.js";
|
|
5
5
|
import { d as resolveFederatedRoots, n as extractConfig, o as formatMissingApps, s as monoAlias, t as assertAppSources, u as monoStubAliases } from "./mono-alias-BU2B0tYL.js";
|
|
6
6
|
import { a as defaultMonoExpose, c as createMonoLithHooks, f as remoteGate, i as monoRouterLinkToNuxtLink, o as sanitizeForExpose, u as parsePageMeta } from "./mono-link-URGX8xsT.js";
|
|
7
7
|
import { r as registerMonoNuxtLayers, t as monoLayerCandidates } from "./nuxt-layers-BO0AGwA5.js";
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { C as MonoSyncTransport, _ as MonoMergeableKey, c as MonoConfig, n as JWTCompleteTokenTypes, o as MonoAppType, t as DefaultJWTTokenTypes, w as MonoTemplate } from "./create-config-B8IhX4ht.js";
|
|
2
2
|
import { a as MonoFetchCookieOptions, i as LocalStorageParams, n as CookieTokenParams, o as NormalFetchOptions$1, r as JWTPayload, s as NormalFetchResult$1, t as CookieParams } from "./types-B6FdB7LJ.js";
|
|
3
3
|
import { a as monoToken, i as monoStorage, n as monoCookie, o as setMonoEventResolver, r as monoJwt, s as CookieApi, t as MonoRequestEvent } from "./universal-BR0O7Qwk.js";
|
|
4
|
-
import { $ as createStaticDatasource, A as ValidateError, B as FetchLoading, C as Format, D as SchemaType, E as SchemaObject, F as ValidationSchemaLike, G as OdataFetchTypes, H as FetchParam, I as Col, J as NotifProps, K as TanstackFetchOptions, L as GroupTemplate, M as ValidateErrorItem, N as ValidateErrorSingle, O as StandardSchemaV1, P as ValidateSchema, Q as UseOdataStaticOpts, R as LoopTemplate, S as FilterExpression, T as Schema, U as NormalFetchOptions, V as FetchOData, W as NormalFetchResult, X as MonoNotifActionTypes, Y as MonoNotifActionProps, Z as MonoNotifButton, _ as getPrefetchBridge, a as TryCatchDatasourceParams, b as CustomSummary, c as extractErrorMessage, d as promiseWrapper, f as tryCatchDatasource, g as MonoPrefetchRequest, h as MonoPrefetchBridge, i as OdataFetchUniqueTypes, j as ValidateErrorComplex, k as StandardSchemaV1Result, l as loadChuckStore, m as useNormalFetch, n as FetchOverrides, o as createFetcher, p as useFetchOData, q as useHelper, r as LoadChunkStoreArgs, s as createUniqueFetcher, t as _default, u as parseDxError, v as setPrefetchBridge, w as HeaderFilter, x as DataGrid, y as OdataMapTypes, z as PathValue } from "./index-
|
|
4
|
+
import { $ as createStaticDatasource, A as ValidateError, B as FetchLoading, C as Format, D as SchemaType, E as SchemaObject, F as ValidationSchemaLike, G as OdataFetchTypes, H as FetchParam, I as Col, J as NotifProps, K as TanstackFetchOptions, L as GroupTemplate, M as ValidateErrorItem, N as ValidateErrorSingle, O as StandardSchemaV1, P as ValidateSchema, Q as UseOdataStaticOpts, R as LoopTemplate, S as FilterExpression, T as Schema, U as NormalFetchOptions, V as FetchOData, W as NormalFetchResult, X as MonoNotifActionTypes, Y as MonoNotifActionProps, Z as MonoNotifButton, _ as getPrefetchBridge, a as TryCatchDatasourceParams, b as CustomSummary, c as extractErrorMessage, d as promiseWrapper, f as tryCatchDatasource, g as MonoPrefetchRequest, h as MonoPrefetchBridge, i as OdataFetchUniqueTypes, j as ValidateErrorComplex, k as StandardSchemaV1Result, l as loadChuckStore, m as useNormalFetch, n as FetchOverrides, o as createFetcher, p as useFetchOData, q as useHelper, r as LoadChunkStoreArgs, s as createUniqueFetcher, t as _default, u as parseDxError, v as setPrefetchBridge, w as HeaderFilter, x as DataGrid, y as OdataMapTypes, z as PathValue } from "./index-GhC2ux6U.js";
|
|
5
5
|
import { InjectionKey, Plugin, Ref } from "vue";
|
|
6
6
|
import { RouteRecordRaw } from "vue-router";
|
|
7
7
|
//#region src/token/client.d.ts
|
package/dist/vite.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as pathAppRoots, t as appRootDirs } from "./app-roots-LpDrHF_J.js";
|
|
2
2
|
import { c as resolveMonoConfig, l as srcDirForType, o as resolveExtendsAppNames, s as resolveExtendsEcosystems } from "./create-config-DdL3Fh6T.js";
|
|
3
3
|
import { r as monoEcosystem } from "./merge-file-DahuGcvr.js";
|
|
4
|
-
import { t as getMonoConfig } from "./config-node-
|
|
4
|
+
import { t as getMonoConfig } from "./config-node-Dn0K54kd.js";
|
|
5
5
|
import { d as resolveFederatedRoots, n as extractConfig, o as formatMissingApps, s as monoAlias, t as assertAppSources, u as monoStubAliases } from "./mono-alias-BU2B0tYL.js";
|
|
6
6
|
import { a as defaultMonoExpose, c as createMonoLithHooks, d as parsePageMetaFromFile, f as remoteGate, i as monoRouterLinkToNuxtLink, l as monoLith, n as monoNuxtLinkToRouterLink, o as sanitizeForExpose, r as monoRouterLink, s as MONO_APPS_VIRTUAL_ID, t as monoNuxtLink, u as parsePageMeta } from "./mono-link-URGX8xsT.js";
|
|
7
7
|
import { existsSync } from "node:fs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mono-lit/utility",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Mono config, fetching, auth/token, Nuxt/Vite integration and shared helpers for the @mono-lit ecosystem.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue",
|
|
@@ -81,20 +81,20 @@
|
|
|
81
81
|
"registry": "https://registry.npmjs.org/"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
|
-
"@
|
|
85
|
-
"
|
|
86
|
-
"dotenv": "^17.4.2",
|
|
84
|
+
"@unhead/vue": "^3.0.0",
|
|
85
|
+
"dotenv": "^17.4.2 || ^18.0.0",
|
|
87
86
|
"dotenv-cli": "^11.0.0",
|
|
88
87
|
"h3": "^1.15.1",
|
|
89
88
|
"jwt-decode": "^4.0.0",
|
|
90
89
|
"notivue": "^2.4.5",
|
|
91
90
|
"valibot": "^1.0.0",
|
|
92
|
-
"vue": "3.5.
|
|
93
|
-
"vue-router": "5.
|
|
91
|
+
"vue": "^3.5.0",
|
|
92
|
+
"vue-router": "^5.0.0",
|
|
94
93
|
"yup": "^1.7.1",
|
|
95
94
|
"@mono-lit/devextreme": "^0.0.2"
|
|
96
95
|
},
|
|
97
96
|
"devDependencies": {
|
|
97
|
+
"@nuxt/schema": "^4.6.2",
|
|
98
98
|
"@odata2ts/http-client-fetch": "0.9.0",
|
|
99
99
|
"@odata2ts/odata-query-objects": "0.28.1",
|
|
100
100
|
"@tsdown/css": "0.23.1",
|
|
@@ -110,22 +110,18 @@
|
|
|
110
110
|
"vite": "8.3.4",
|
|
111
111
|
"vue-tsc": "~3.2.0",
|
|
112
112
|
"yup": "1.7.1",
|
|
113
|
-
"@mono-lit/helper": "0.
|
|
113
|
+
"@mono-lit/helper": "0.1.6"
|
|
114
114
|
},
|
|
115
115
|
"dependencies": {
|
|
116
116
|
"@nuxt/kit": "^4.6.2",
|
|
117
|
-
"@nuxt/schema": "^4.6.2",
|
|
118
117
|
"c12": "4.0.0-beta.5",
|
|
119
|
-
"citty": "0.1.6",
|
|
118
|
+
"citty": "^0.1.6",
|
|
120
119
|
"devextreme": "25.1.6",
|
|
121
120
|
"devextreme-vue": "25.1.6",
|
|
122
|
-
"pkg-types": "2.3.1",
|
|
123
|
-
"unstorage": "1.17.5"
|
|
121
|
+
"pkg-types": "^2.3.1",
|
|
122
|
+
"unstorage": "^1.17.5"
|
|
124
123
|
},
|
|
125
124
|
"peerDependenciesMeta": {
|
|
126
|
-
"@odata2ts/http-client-fetch": {
|
|
127
|
-
"optional": true
|
|
128
|
-
},
|
|
129
125
|
"h3": {
|
|
130
126
|
"optional": true
|
|
131
127
|
},
|
|
@@ -137,6 +133,9 @@
|
|
|
137
133
|
},
|
|
138
134
|
"valibot": {
|
|
139
135
|
"optional": true
|
|
136
|
+
},
|
|
137
|
+
"@unhead/vue": {
|
|
138
|
+
"optional": true
|
|
140
139
|
}
|
|
141
140
|
},
|
|
142
141
|
"scripts": {
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { r as dedupeConfigArrays } from "./create-config-DdL3Fh6T.js";
|
|
2
|
-
import { loadConfig } from "c12";
|
|
3
|
-
|
|
4
|
-
//#region src/composables/config-node.ts
|
|
5
|
-
function getCwd() {
|
|
6
|
-
return typeof process !== "undefined" ? process.cwd() : void 0;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Collapse name-keyed arrays that may carry one duplicate per layer, so the
|
|
10
|
-
* loaded config behaves like a single config.
|
|
11
|
-
*
|
|
12
|
-
* Delegates to `dedupeConfigArrays` from `create-config` rather than owning a
|
|
13
|
-
* rule: this used to keep the FIRST occurrence while the runtime resolver keeps
|
|
14
|
-
* the LAST, which are opposite precedence rules for the same data. It is a no-op
|
|
15
|
-
* while `extend: false` (below) leaves c12 with only the root config's own
|
|
16
|
-
* arrays, but the two must never be able to disagree.
|
|
17
|
-
*/
|
|
18
|
-
function normalizeMergedConfig(config) {
|
|
19
|
-
return dedupeConfigArrays(config);
|
|
20
|
-
}
|
|
21
|
-
async function loadMonoConfig(options = {}) {
|
|
22
|
-
const result = await loadConfig({
|
|
23
|
-
name: "mono",
|
|
24
|
-
cwd: options.cwd ?? getCwd(),
|
|
25
|
-
extend: false,
|
|
26
|
-
defaults: {
|
|
27
|
-
apps: [],
|
|
28
|
-
name: "mono-app",
|
|
29
|
-
type: "vue",
|
|
30
|
-
menu: [],
|
|
31
|
-
cookie: [],
|
|
32
|
-
jwt: {}
|
|
33
|
-
},
|
|
34
|
-
...options
|
|
35
|
-
});
|
|
36
|
-
return {
|
|
37
|
-
...result,
|
|
38
|
-
config: normalizeMergedConfig(result.config)
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
async function getMonoConfig(options = {}) {
|
|
42
|
-
try {
|
|
43
|
-
return (await loadMonoConfig(options)).config;
|
|
44
|
-
} catch (error) {
|
|
45
|
-
throw describeConfigLoadError(error);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/** `Cannot find module '@some-app-root/mono.config'` — the shape jiti throws. */
|
|
49
|
-
const MISSING_ALIAS_RE = /Cannot find module ['"](@[^'"]+)['"]/;
|
|
50
|
-
/**
|
|
51
|
-
* Turn an unresolved mono alias into an error that says what to do.
|
|
52
|
-
*
|
|
53
|
-
* `mono.config.ts` reaches other apps through ordinary `import`s resolved by jiti
|
|
54
|
-
* against the alias map, and those aliases come from the `.mono/apps/` directory
|
|
55
|
-
* listing. An app that isn't synced therefore surfaces as a bare `Cannot find
|
|
56
|
-
* module '@x-root/mono.config'` — a specifier nobody typed by hand, thrown from
|
|
57
|
-
* inside c12, naming no file and no fix.
|
|
58
|
-
*
|
|
59
|
-
* Pattern-based on purpose: this module knows nothing about the alias map, and
|
|
60
|
-
* shouldn't. Covers the paths that never call `monoStubAliases` (the `mono db` CLI)
|
|
61
|
-
* and the specifiers a config-only stub can't satisfy (a host config importing a
|
|
62
|
-
* missing app's OData service).
|
|
63
|
-
*/
|
|
64
|
-
function describeConfigLoadError(error) {
|
|
65
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
66
|
-
const specifier = MISSING_ALIAS_RE.exec(message)?.[1];
|
|
67
|
-
if (!specifier) return error;
|
|
68
|
-
return new Error([
|
|
69
|
-
`[@mono-lit/utility] Failed to load mono.config: cannot resolve '${specifier}'.`,
|
|
70
|
-
"That looks like a federated mono app that isn't present in .mono/apps/.",
|
|
71
|
-
"Run `mono sync && mono prepare`. If the repo is private, set its envToken in .env."
|
|
72
|
-
].join("\n"), { cause: error });
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
//#endregion
|
|
76
|
-
export { loadMonoConfig as n, getMonoConfig as t };
|