@mono-lit/utility 0.0.5 → 0.0.6

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/README.md CHANGED
@@ -1,157 +1,157 @@
1
- # Mono Utils
2
-
3
- A comprehensive utility library for Vue.js applications built around DevExtreme UI components, providing powerful data management, validation, and export capabilities.
4
-
5
- ## Features
6
-
7
- - 🔧 **OData Integration** - Sophisticated OData client with batch operations, caching, and error handling
8
- - 🎛️ **DevExtreme Helpers** - Utilities for data grids, lookups, and form components
9
- - ✅ **Schema Validation** - Yup or Valibot (any Standard Schema) validation with nested object support
10
- - 📊 **Excel Export** - Advanced Excel export capabilities with custom formatting and formulas
11
- - 🔔 **Notification System** - Notivue-based notification management
12
- - 🚨 **Error Handling** - Comprehensive HTTP and OData error handling
13
- - 🔄 **Data Manipulation** - Powerful utilities for data transformation and operations
14
-
15
- ## Installation
16
-
17
- **From npmjs (public):**
18
-
19
- ```bash
20
- pnpm add @mono-lit/utility
21
- ```
22
-
23
- **From the Netlify registry:** add this to your project's `.npmrc`, then run the same `pnpm add`:
24
-
25
- ```ini
26
- @mono-lit:registry=https://mono-libs.netlify.app/npm/
27
- //mono-libs.netlify.app/npm/:_authToken=<REGISTRY_DOWNLOAD_TOKEN>
28
- ```
29
-
30
- See the [repository README](https://github.com/mono-lit/core#install-in-your-project) for details.
31
-
32
- ## Dependencies
33
-
34
- ### Core Dependencies
35
-
36
- These are the essential dependencies required for core functionality:
37
-
38
- ```bash
39
- npm install notivue valibot exceljs file-saver-es @odata2ts/http-client-fetch json-server change-case chokidar
40
- ```
41
-
42
- **Note:** The additional dependencies (`json-server`, `change-case`, `chokidar`) are recommended for development and should be installed as devDependencies:
43
-
44
- ```bash
45
- npm install --save-dev json-server change-case chokidar
46
- ```
47
-
48
- ### Optional DevExtreme Dependencies
49
-
50
- **For DevExtreme UI Components:**
51
- If you're using DevExtreme components, you'll also need:
52
-
53
- ```bash
54
- npm install devextreme devextreme-vue
55
- ```
56
-
57
- **Note:** The core data fetching, validation, and Excel export utilities work independently of any UI framework. You can use this library with Vue, React, Angular, or vanilla JavaScript.
58
-
59
- ## Quick Start
60
-
61
- ### Basic Setup
62
-
63
- ```vue
64
- <script setup>
65
- import { useUtils } from '@mono-lit/utility/runtime'
66
-
67
- const utils = useUtils()
68
-
69
- // Destructure the utilities you need
70
- const {
71
- notif,
72
- validateAllSchema,
73
- validateSchema,
74
- replacerData,
75
- exportExcel,
76
- useFetchOData,
77
- createFetcher,
78
- advanceExportExcel
79
- } = utils
80
- </script>
81
- ```
82
-
83
- ### Usage Without DevExtreme
84
-
85
- For users working with other UI frameworks (React, Angular, or vanilla JavaScript), you can still use the core data fetching, validation, and export utilities:
86
-
87
- ```javascript
88
- import { useUtils } from '@mono-lit/utility/runtime'
89
-
90
- const { useFetchOData, notif, advanceExportExcel } = useUtils()
91
-
92
- // Fetch data
93
- const { data, error } = await useFetchOData({
94
- url: '/Users',
95
- baseUrl: 'https://your-api.com/odata',
96
- type: 'data'
97
- })
98
-
99
- if (error) {
100
- notif({
101
- message: error.message,
102
- type: 'error'
103
- })
104
- }
105
-
106
- // Export to Excel
107
- await advanceExportExcel({
108
- title: 'User Report',
109
- items: data,
110
- config: {
111
- columns: [
112
- { key: 'Id', title: 'ID', width: 10 },
113
- { key: 'Name', title: 'Name', width: 30 },
114
- { key: 'Email', title: 'Email', width: 40 }
115
- ]
116
- }
117
- })
118
- ```
119
-
120
- ## Documentation
121
-
122
- - **[Data Fetching](./docs/data-fetching.md)** - OData integration, HTTP client, data manipulation
123
- - **[Excel Export](./docs/excel-export.md)** - Advanced Excel export with formatting and formulas
124
- - **[Validation](./docs/validation.md)** - Schema validation with Yup or Valibot
125
- - **[Notifications](./docs/notifications.md)** - Notivue-based notification system
126
- - **[DevExtreme Integration](./docs/devextreme-integration.md)** - DevExtreme UI helpers and components
127
-
128
- ## API Reference
129
-
130
- ### useUtils Return Object
131
-
132
- The main `useUtils()` function returns an object with the following utilities:
133
-
134
- #### Core Utilities
135
- - `notif` - Notification system
136
- - `validateAllSchema` - Validate entire form (Yup or Valibot)
137
- - `validateSchema` - Validate single field (Yup or Valibot)
138
- - `validateAllSchemaCheck` - Check if any validation errors exist
139
- - `clearSchemaValidation` - Clear all validation errors
140
-
141
- #### Data Utilities
142
- - `replacerData` - Add/update/remove items from arrays or DataSources
143
- - `filterOrIn` - Create OData filter expressions
144
-
145
- #### UI Components
146
- - `exportExcel` - Basic Excel export
147
- - `advanceExportExcel` - Advanced Excel export with formulas
148
-
149
- #### OData & HTTP
150
- - `useFetchOData` - Main OData fetching utility
151
- - `createFetcher` - Create reusable fetchers
152
- - `useNormalFetch` - Simple HTTP fetch utility
153
- - `createUniqueFetcher` - Fetch unique records
154
-
155
- ## License
156
-
1
+ # Mono Utils
2
+
3
+ A comprehensive utility library for Vue.js applications built around DevExtreme UI components, providing powerful data management, validation, and export capabilities.
4
+
5
+ ## Features
6
+
7
+ - 🔧 **OData Integration** - Sophisticated OData client with batch operations, caching, and error handling
8
+ - 🎛️ **DevExtreme Helpers** - Utilities for data grids, lookups, and form components
9
+ - ✅ **Schema Validation** - Yup or Valibot (any Standard Schema) validation with nested object support
10
+ - 📊 **Excel Export** - Advanced Excel export capabilities with custom formatting and formulas
11
+ - 🔔 **Notification System** - Notivue-based notification management
12
+ - 🚨 **Error Handling** - Comprehensive HTTP and OData error handling
13
+ - 🔄 **Data Manipulation** - Powerful utilities for data transformation and operations
14
+
15
+ ## Installation
16
+
17
+ **From npmjs (public):**
18
+
19
+ ```bash
20
+ pnpm add @mono-lit/utility
21
+ ```
22
+
23
+ **From the Netlify registry:** add this to your project's `.npmrc`, then run the same `pnpm add`:
24
+
25
+ ```ini
26
+ @mono-lit:registry=https://mono-libs.netlify.app/npm/
27
+ //mono-libs.netlify.app/npm/:_authToken=<REGISTRY_DOWNLOAD_TOKEN>
28
+ ```
29
+
30
+ See the [repository README](https://github.com/mono-lit/core#install-in-your-project) for details.
31
+
32
+ ## Dependencies
33
+
34
+ ### Core Dependencies
35
+
36
+ These are the essential dependencies required for core functionality:
37
+
38
+ ```bash
39
+ npm install notivue valibot exceljs file-saver-es @odata2ts/http-client-fetch json-server change-case chokidar
40
+ ```
41
+
42
+ **Note:** The additional dependencies (`json-server`, `change-case`, `chokidar`) are recommended for development and should be installed as devDependencies:
43
+
44
+ ```bash
45
+ npm install --save-dev json-server change-case chokidar
46
+ ```
47
+
48
+ ### Optional DevExtreme Dependencies
49
+
50
+ **For DevExtreme UI Components:**
51
+ If you're using DevExtreme components, you'll also need:
52
+
53
+ ```bash
54
+ npm install devextreme devextreme-vue
55
+ ```
56
+
57
+ **Note:** The core data fetching, validation, and Excel export utilities work independently of any UI framework. You can use this library with Vue, React, Angular, or vanilla JavaScript.
58
+
59
+ ## Quick Start
60
+
61
+ ### Basic Setup
62
+
63
+ ```vue
64
+ <script setup>
65
+ import { useUtils } from '@mono-lit/utility/runtime'
66
+
67
+ const utils = useUtils()
68
+
69
+ // Destructure the utilities you need
70
+ const {
71
+ notif,
72
+ validateAllSchema,
73
+ validateSchema,
74
+ replacerData,
75
+ exportExcel,
76
+ useFetchOData,
77
+ createFetcher,
78
+ advanceExportExcel
79
+ } = utils
80
+ </script>
81
+ ```
82
+
83
+ ### Usage Without DevExtreme
84
+
85
+ For users working with other UI frameworks (React, Angular, or vanilla JavaScript), you can still use the core data fetching, validation, and export utilities:
86
+
87
+ ```javascript
88
+ import { useUtils } from '@mono-lit/utility/runtime'
89
+
90
+ const { useFetchOData, notif, advanceExportExcel } = useUtils()
91
+
92
+ // Fetch data
93
+ const { data, error } = await useFetchOData({
94
+ url: '/Users',
95
+ baseUrl: 'https://your-api.com/odata',
96
+ type: 'data'
97
+ })
98
+
99
+ if (error) {
100
+ notif({
101
+ message: error.message,
102
+ type: 'error'
103
+ })
104
+ }
105
+
106
+ // Export to Excel
107
+ await advanceExportExcel({
108
+ title: 'User Report',
109
+ items: data,
110
+ config: {
111
+ columns: [
112
+ { key: 'Id', title: 'ID', width: 10 },
113
+ { key: 'Name', title: 'Name', width: 30 },
114
+ { key: 'Email', title: 'Email', width: 40 }
115
+ ]
116
+ }
117
+ })
118
+ ```
119
+
120
+ ## Documentation
121
+
122
+ - **[Data Fetching](./docs/data-fetching.md)** - OData integration, HTTP client, data manipulation
123
+ - **[Excel Export](./docs/excel-export.md)** - Advanced Excel export with formatting and formulas
124
+ - **[Validation](./docs/validation.md)** - Schema validation with Yup or Valibot
125
+ - **[Notifications](./docs/notifications.md)** - Notivue-based notification system
126
+ - **[DevExtreme Integration](./docs/devextreme-integration.md)** - DevExtreme UI helpers and components
127
+
128
+ ## API Reference
129
+
130
+ ### useUtils Return Object
131
+
132
+ The main `useUtils()` function returns an object with the following utilities:
133
+
134
+ #### Core Utilities
135
+ - `notif` - Notification system
136
+ - `validateAllSchema` - Validate entire form (Yup or Valibot)
137
+ - `validateSchema` - Validate single field (Yup or Valibot)
138
+ - `validateAllSchemaCheck` - Check if any validation errors exist
139
+ - `clearSchemaValidation` - Clear all validation errors
140
+
141
+ #### Data Utilities
142
+ - `replacerData` - Add/update/remove items from arrays or DataSources
143
+ - `filterOrIn` - Create OData filter expressions
144
+
145
+ #### UI Components
146
+ - `exportExcel` - Basic Excel export
147
+ - `advanceExportExcel` - Advanced Excel export with formulas
148
+
149
+ #### OData & HTTP
150
+ - `useFetchOData` - Main OData fetching utility
151
+ - `createFetcher` - Create reusable fetchers
152
+ - `useNormalFetch` - Simple HTTP fetch utility
153
+ - `createUniqueFetcher` - Fetch unique records
154
+
155
+ ## License
156
+
157
157
  This project is licensed under the MIT License.
@@ -330,6 +330,11 @@ export interface HostedAppPrepared {
330
330
  * host's side — the mini has no `package.json`, so it can never run a
331
331
  * `mono prepare` (or an install) of its own.
332
332
  *
333
+ * Only a mini that names THIS host in its own `apps[]` (by name — typically a
334
+ * `url` entry — or by a `path` landing here) is prepared: the wiring is declared
335
+ * on both sides, never inferred. Any other hosted app is skipped with a warning
336
+ * that spells out the entry to add.
337
+ *
333
338
  * 1. `<mini>/node_modules` becomes a link (a junction on Windows — no admin
334
339
  * rights needed) to the host's `node_modules`. A sibling outside the host
335
340
  * has no `node_modules` above it, so every bare import in its files —
@@ -1,7 +1,7 @@
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
2
  import { n as loadMonoConfig, t as getMonoConfig } from "./config-node-UzJrXg0Z.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
- 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-4R-pfXV3.js";
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";
6
6
 
7
7
  export { ALLOWED_FLAGS, BASE_ARGS, GENERIC_APP_NAMES, MONO_APPS_DIR, MONO_DIR, MONO_TSCONFIG_REF, REQUIRED_FILES, SKILLS_DEFAULTS, SkillsAccessError, adoptHostedApps, appRootDirs, applyPlan, assertAppSources, buildMonoTsconfig, buildSavePlan, cacheDir, chunkConversation, classifyGitFailure, commitAndPush, detectActor, ensureRepo, extractConfig, extractConfigName, extractSkill, extractTemplate, firstFatal, formatMissingApps, getMonoConfig, gitEnv, hasUrl, hostedAppRoots, isGenericAppName, isHostedApp, isMissingPathError, isNonFastForward, linkedAppRoots, listRepoFiles, listSessions, loadMonoConfig, loadSkillConfig, loadSkillsEnv, loadStagedSession, missingPathMessage, monoAlias, monoConfigFileFor, monoMissingApps, monoStubAliases, monoTsconfigPaths, moveToFailed, normalizeAppId, parseHeadSha, parseLsRemote, parseSymref, pathAppRoots, readRepoFile, redact, redactBuffer, redactUrl, refDirCandidates, refPatterns, removeSession, repoDir, resetAppPathWarnings, resolveAppId, resolveAppRoots, resolveFederatedRoots, resolveRemote, resolveSkillTarget, runCheck, runGit, runMonoPrepare, runRead, runSave, runSearch, runSessionShow, skillsRoot, stagingRoot, stripCommentsSafe, tokenRemote, validateStagedSession };
@@ -1,4 +1,4 @@
1
- import { s as runMonoPrepare } from "./mono-tsconfig-4R-pfXV3.js";
1
+ import { s as runMonoPrepare } from "./mono-tsconfig-CYOKwy6E.js";
2
2
  import path from "node:path";
3
3
  import { defineCommand, runMain } from "citty";
4
4
 
@@ -169,6 +169,11 @@ async function runMonoPrepare(opts) {
169
169
  * host's side — the mini has no `package.json`, so it can never run a
170
170
  * `mono prepare` (or an install) of its own.
171
171
  *
172
+ * Only a mini that names THIS host in its own `apps[]` (by name — typically a
173
+ * `url` entry — or by a `path` landing here) is prepared: the wiring is declared
174
+ * on both sides, never inferred. Any other hosted app is skipped with a warning
175
+ * that spells out the entry to add.
176
+ *
172
177
  * 1. `<mini>/node_modules` becomes a link (a junction on Windows — no admin
173
178
  * rights needed) to the host's `node_modules`. A sibling outside the host
174
179
  * has no `node_modules` above it, so every bare import in its files —
@@ -200,6 +205,11 @@ function adoptHostedApps(dirname) {
200
205
  const base = host.type === "nuxt" ? path.join(dirname, ".nuxt", "tsconfig.app.json") : path.join(dirname, "tsconfig.json");
201
206
  const prepared = [];
202
207
  for (const { name, type, root } of hostedAppRoots(roots)) {
208
+ if (!namesHost(root, dirname, host.name)) {
209
+ const hint = `{ name: '${host.name ?? path.basename(dirname)}', url: '<the host repo>', type: '${host.type}' }`;
210
+ console.warn(`[mono] ${name}: not prepared — its mono.config.ts does not name this host. Add ${hint} to its apps[].`);
211
+ continue;
212
+ }
203
213
  const link = linkHostModules(name, root, hostModules);
204
214
  const miniMono = path.join(root, MONO_DIR);
205
215
  if (!fs.existsSync(miniMono)) fs.mkdirSync(miniMono, { recursive: true });
@@ -258,6 +268,14 @@ function linkHostModules(name, root, hostModules) {
258
268
  fs.symlinkSync(hostModules, linkPath, process.platform === "win32" ? "junction" : "dir");
259
269
  return "created";
260
270
  }
271
+ /**
272
+ * Does the app at `root` name this host in its `apps[]`? By the host's `name` (a
273
+ * `url` entry, the usual way), or by a `path` that lands on `hostDir`. Read
274
+ * statically, like every other `apps[]` read before the config can execute.
275
+ */
276
+ function namesHost(root, hostDir, hostName) {
277
+ return extractConfig(root).apps.some((app) => hostName !== null && app.name === hostName || typeof app.path === "string" && samePath(path.resolve(root, app.path), hostDir));
278
+ }
261
279
  function samePath(a, b) {
262
280
  const norm = (p) => {
263
281
  const r = path.resolve(p);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mono-lit/utility",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
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",