@simplysm/core-common 14.0.23 → 14.0.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/core-common",
3
- "version": "14.0.23",
3
+ "version": "14.0.25",
4
4
  "description": "심플리즘 패키지 - 코어 (common)",
5
5
  "author": "심플리즘",
6
6
  "license": "Apache-2.0",
@@ -14,8 +14,7 @@
14
14
  "types": "./dist/index.d.ts",
15
15
  "files": [
16
16
  "dist",
17
- "src",
18
- "docs"
17
+ "src"
19
18
  ],
20
19
  "sideEffects": [
21
20
  "./src/extensions/arr-ext.ts",
package/README.md DELETED
@@ -1,218 +0,0 @@
1
- # @simplysm/core-common
2
-
3
- Platform-neutral utility library for the Simplysm framework. Provides type-safe primitives, collection extensions, error hierarchy, async utilities, and serialization helpers that work in both browser and Node.js environments.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install @simplysm/core-common
9
- ```
10
-
11
- ## API Overview
12
-
13
- ### Environment
14
-
15
- | API | Type | Description |
16
- |-----|------|-------------|
17
- | `env` | `const` | Unified environment variables from `import.meta.env` and `process.env`. `DEV` is parsed as boolean, `VER` as optional string. |
18
- | `parseBoolEnv(value)` | `function` | Parse a value to boolean (`"true"`, `"1"`, `"yes"`, `"on"` case-insensitive -> `true`, otherwise `false`) |
19
-
20
- -> See [docs/env.md](./docs/env.md) for details.
21
-
22
- ### Errors
23
-
24
- | API | Type | Description |
25
- |-----|------|-------------|
26
- | `SdError` | `class` | Tree-structured error with chained messages via ES2024 `cause` |
27
- | `ArgumentError` | `class` | Invalid argument error with YAML-formatted argument dump |
28
- | `NotImplementedError` | `class` | Unimplemented feature error |
29
- | `TimeoutError` | `class` | Timeout exceeded error with retry count |
30
-
31
- -> See [docs/errors.md](./docs/errors.md) for details.
32
-
33
- ### Types
34
-
35
- | API | Type | Description |
36
- |-----|------|-------------|
37
- | `Uuid` | `class` | UUID v4 generation and parsing using `crypto.getRandomValues` |
38
- | `LazyGcMap<K,V>` | `class` | Auto-expiring Map with LRU access tracking and GC timer |
39
- | `DateTime` | `class` | Immutable date-time wrapper around `Date` with millisecond precision |
40
- | `DateOnly` | `class` | Immutable date-only class (no time component) with week-sequence support |
41
- | `Time` | `class` | Immutable time-only class with 24-hour wrapping |
42
-
43
- -> See [docs/types.md](./docs/types.md) for details.
44
-
45
- ### Features
46
-
47
- | API | Type | Description |
48
- |-----|------|-------------|
49
- | `DebounceQueue` | `class` | Async debounce queue -- only the last enqueued function runs after delay |
50
- | `SerialQueue` | `class` | Async serial queue -- functions execute one at a time in order |
51
- | `EventEmitter<TEvents>` | `class` | Type-safe event emitter built on `EventTarget` |
52
-
53
- -> See [docs/features.md](./docs/features.md) for details.
54
-
55
- ### Array Extensions
56
-
57
- | API | Type | Description |
58
- |-----|------|-------------|
59
- | `Array.prototype.single` | extension | Return single matching element or throw if multiple |
60
- | `Array.prototype.first` | extension | Return first element or first matching |
61
- | `Array.prototype.last` | extension | Return last element or last matching |
62
- | `Array.prototype.filterExists` | extension | Remove null/undefined elements |
63
- | `Array.prototype.ofType` | extension | Filter by primitive type string or constructor |
64
- | `Array.prototype.filterAsync` | extension | Async sequential filter |
65
- | `Array.prototype.mapAsync` | extension | Async sequential map |
66
- | `Array.prototype.mapMany` | extension | Flatten or map-then-flatten |
67
- | `Array.prototype.mapManyAsync` | extension | Async map then flatten |
68
- | `Array.prototype.parallelAsync` | extension | Parallel async map via `Promise.all` |
69
- | `Array.prototype.groupBy` | extension | Group by key selector |
70
- | `Array.prototype.toMap` | extension | Convert to `Map` with key/value selectors |
71
- | `Array.prototype.toMapAsync` | extension | Async version of `toMap` |
72
- | `Array.prototype.toArrayMap` | extension | Convert to `Map<K, V[]>` |
73
- | `Array.prototype.toSetMap` | extension | Convert to `Map<K, Set<V>>` |
74
- | `Array.prototype.toMapValues` | extension | Group then aggregate values |
75
- | `Array.prototype.toObject` | extension | Convert to `Record<string, V>` |
76
- | `Array.prototype.toTree` | extension | Convert flat array to tree structure |
77
- | `Array.prototype.distinct` | extension | Remove duplicates (new array) |
78
- | `Array.prototype.orderBy` | extension | Sort ascending (new array) |
79
- | `Array.prototype.orderByDesc` | extension | Sort descending (new array) |
80
- | `Array.prototype.diffs` | extension | Compare two arrays (insert/delete/update) |
81
- | `Array.prototype.oneWayDiffs` | extension | One-way diff (create/update/same) |
82
- | `Array.prototype.merge` | extension | Merge two arrays by key |
83
- | `Array.prototype.sum` | extension | Sum of elements |
84
- | `Array.prototype.min` | extension | Minimum element |
85
- | `Array.prototype.max` | extension | Maximum element |
86
- | `Array.prototype.shuffle` | extension | Random shuffle (new array) |
87
- | `Array.prototype.distinctThis` | extension | Remove duplicates in-place |
88
- | `Array.prototype.orderByThis` | extension | Sort ascending in-place |
89
- | `Array.prototype.orderByDescThis` | extension | Sort descending in-place |
90
- | `Array.prototype.insert` | extension | Insert items at index in-place |
91
- | `Array.prototype.remove` | extension | Remove items in-place |
92
- | `Array.prototype.toggle` | extension | Toggle item in-place |
93
- | `Array.prototype.clear` | extension | Remove all items in-place |
94
- | `ArrayDiffsResult<T,P>` | `type` | Diff result: insert / delete / update |
95
- | `ArrayOneWayDiffResult<T>` | `type` | One-way diff result: create / update / same |
96
- | `TreeArray<T>` | `type` | Tree node type with `children` array |
97
- | `ComparableType` | `type` | Union of sortable types |
98
-
99
- -> See [docs/array-extensions.md](./docs/array-extensions.md) for details.
100
-
101
- ### Map Extensions
102
-
103
- | API | Type | Description |
104
- |-----|------|-------------|
105
- | `Map.prototype.getOrCreate` | extension | Get value or create with default/factory |
106
- | `Map.prototype.update` | extension | Update a value using a transform function |
107
-
108
- -> See [docs/map-extensions.md](./docs/map-extensions.md) for details.
109
-
110
- ### Set Extensions
111
-
112
- | API | Type | Description |
113
- |-----|------|-------------|
114
- | `Set.prototype.adds` | extension | Add multiple values at once |
115
- | `Set.prototype.toggle` | extension | Toggle a value with optional force add/delete |
116
-
117
- -> See [docs/set-extensions.md](./docs/set-extensions.md) for details.
118
-
119
- ### Utility Namespaces
120
-
121
- All utility namespaces are exported as `export * as name` and accessed as `obj.clone(...)`, `str.toPascalCase(...)`, etc.
122
-
123
- | Namespace | Description |
124
- |-----------|-------------|
125
- | `obj` | Deep clone, deep equal, deep merge, 3-way merge, omit, pick, chain value access, type-safe keys/entries/fromEntries/map |
126
- | `str` | Korean suffix, full-width conversion, case conversion (pascal/camel/kebab/snake), isNullOrEmpty, insert |
127
- | `num` | parseInt, parseFloat, parseRoundedInt, isNullOrEmpty, format with thousand separators |
128
- | `bytes` | Uint8Array concat, hex, base64 conversion |
129
- | `path` | POSIX path join, basename, extname (browser-compatible, no backslash support) |
130
- | `json` | Custom JSON stringify/parse with DateTime, Uuid, Set, Map, Error, Uint8Array support |
131
- | `xml` | XML parse/stringify via fast-xml-parser |
132
- | `wait` | Async `until` (poll condition) and `time` (delay) |
133
- | `transfer` | Worker-safe encode/decode for custom types with transferable list extraction |
134
- | `err` | Extract error message from unknown catch value |
135
- | `dt` | Date/time formatting with C#-style format strings, normalizeMonth, convert12To24 |
136
- | `primitive` | Get PrimitiveTypeStr from runtime value |
137
-
138
- -> See [docs/utilities.md](./docs/utilities.md) for details.
139
-
140
- ### Template Strings and Zip
141
-
142
- | API | Type | Description |
143
- |-----|------|-------------|
144
- | `js` | tag function | JavaScript template tag with indent normalization |
145
- | `ts` | tag function | TypeScript template tag with indent normalization |
146
- | `html` | tag function | HTML template tag with indent normalization |
147
- | `tsql` | tag function | MSSQL T-SQL template tag with indent normalization |
148
- | `mysql` | tag function | MySQL template tag with indent normalization |
149
- | `pgsql` | tag function | PostgreSQL template tag with indent normalization |
150
- | `ZipArchive` | `class` | ZIP read/write/compress/extract with caching |
151
- | `ZipArchiveProgress` | `interface` | Progress callback data for extraction |
152
-
153
- -> See [docs/template-strings-and-zip.md](./docs/template-strings-and-zip.md) for details.
154
-
155
- ### Type Utilities
156
-
157
- | API | Type | Description |
158
- |-----|------|-------------|
159
- | `Bytes` | `type` | Alias for `Uint8Array` (replaces `Buffer`) |
160
- | `PrimitiveTypeMap` | `type` | Maps type-string keys to their TypeScript types |
161
- | `PrimitiveTypeStr` | `type` | `keyof PrimitiveTypeMap` |
162
- | `PrimitiveType` | `type` | Union of all primitive type values plus `undefined` |
163
- | `DeepPartial<T>` | `type` | Recursively makes all properties optional |
164
- | `Type<T>` | `interface` | Constructor type (`new (...args: unknown[]) => T`) |
165
-
166
- -> See [docs/type-utilities.md](./docs/type-utilities.md) for details.
167
-
168
- ## Usage Examples
169
-
170
- ### Deep Cloning and Comparing
171
-
172
- ```typescript
173
- import { obj } from "@simplysm/core-common";
174
-
175
- const original = { a: 1, b: { c: [2, 3] } };
176
- const cloned = obj.clone(original);
177
- obj.equal(original, cloned); // true
178
-
179
- const merged = obj.merge(original, { b: { d: 4 } });
180
- // { a: 1, b: { c: [2, 3], d: 4 } }
181
- ```
182
-
183
- ### Array Extensions
184
-
185
- ```typescript
186
- import "@simplysm/core-common";
187
-
188
- const users = [
189
- { id: 1, role: "admin", name: "Alice" },
190
- { id: 2, role: "user", name: "Bob" },
191
- { id: 3, role: "user", name: "Carol" },
192
- ];
193
-
194
- users.groupBy((u) => u.role);
195
- // [{ key: "admin", values: [Alice] }, { key: "user", values: [Bob, Carol] }]
196
-
197
- users.toMap((u) => u.id);
198
- // Map { 1 => Alice, 2 => Bob, 3 => Carol }
199
-
200
- [3, 1, 2].orderBy(); // [1, 2, 3]
201
- [1, 2, 2, 3].distinct(); // [1, 2, 3]
202
- ```
203
-
204
- ### JSON Serialization with Custom Types
205
-
206
- ```typescript
207
- import { json, DateTime, Uuid } from "@simplysm/core-common";
208
-
209
- const data = {
210
- id: Uuid.generate(),
211
- createdAt: new DateTime(2025, 6, 15, 10, 30, 0),
212
- tags: new Set(["a", "b"]),
213
- };
214
-
215
- const serialized = json.stringify(data);
216
- const restored = json.parse(serialized);
217
- // restored.id is Uuid, restored.createdAt is DateTime, restored.tags is Set
218
- ```
@@ -1,399 +0,0 @@
1
- # Array Extensions
2
-
3
- Prototype extensions added to both `Array` and `ReadonlyArray`. Available after importing `@simplysm/core-common`.
4
-
5
- Also exports helper functions and result types.
6
-
7
- ## ReadonlyArray Extensions
8
-
9
- These methods do not mutate the original array.
10
-
11
- ### `single`
12
-
13
- Return the single element matching the predicate. Returns `undefined` if no match. Throws `ArgumentError` if more than one element matches.
14
-
15
- ```typescript
16
- single(predicate?: (item: T, index: number) => boolean): T | undefined;
17
- ```
18
-
19
- ### `first`
20
-
21
- Return the first element, or the first element matching the predicate.
22
-
23
- ```typescript
24
- first(predicate?: (item: T, index: number) => boolean): T | undefined;
25
- ```
26
-
27
- ### `last`
28
-
29
- Return the last element, or the last element matching the predicate.
30
-
31
- ```typescript
32
- last(predicate?: (item: T, index: number) => boolean): T | undefined;
33
- ```
34
-
35
- ### `filterExists`
36
-
37
- Remove all `null` and `undefined` elements.
38
-
39
- ```typescript
40
- filterExists(): NonNullable<T>[];
41
- ```
42
-
43
- ### `ofType`
44
-
45
- Filter elements by type. Accepts a `PrimitiveTypeStr` (e.g., `"string"`, `"DateTime"`) or a constructor function.
46
-
47
- ```typescript
48
- ofType<TKey extends PrimitiveTypeStr>(type: TKey): Extract<T, PrimitiveTypeMap[TKey]>[];
49
- ofType<TNarrow extends T>(type: Type<TNarrow>): TNarrow[];
50
- ```
51
-
52
- ### `filterAsync`
53
-
54
- Async sequential filter. Evaluates the predicate for each element in order.
55
-
56
- ```typescript
57
- filterAsync(predicate: (item: T, index: number) => Promise<boolean>): Promise<T[]>;
58
- ```
59
-
60
- ### `mapAsync`
61
-
62
- Async sequential map. Evaluates the selector for each element in order.
63
-
64
- ```typescript
65
- mapAsync<R>(selector: (item: T, index: number) => Promise<R>): Promise<R[]>;
66
- ```
67
-
68
- ### `mapMany`
69
-
70
- Flatten a nested array, or map then flatten. Filters out null/undefined from the result.
71
-
72
- ```typescript
73
- mapMany(): T extends readonly (infer U)[] ? U[] : T;
74
- mapMany<R>(selector: (item: T, index: number) => R[]): R[];
75
- ```
76
-
77
- ### `mapManyAsync`
78
-
79
- Async map then flatten.
80
-
81
- ```typescript
82
- mapManyAsync<R>(selector: (item: T, index: number) => Promise<R[]>): Promise<R[]>;
83
- ```
84
-
85
- ### `parallelAsync`
86
-
87
- Parallel async map using `Promise.all`. All promises run concurrently.
88
-
89
- ```typescript
90
- parallelAsync<R>(fn: (item: T, index: number) => Promise<R>): Promise<R[]>;
91
- ```
92
-
93
- ### `groupBy`
94
-
95
- Group elements by a key selector. Supports object keys via deep comparison (O(n^2)). Primitive keys use Map-based O(n) lookup.
96
-
97
- ```typescript
98
- groupBy<K>(keySelector: (item: T, index: number) => K): { key: K; values: T[] }[];
99
- groupBy<K, V>(
100
- keySelector: (item: T, index: number) => K,
101
- valueSelector: (item: T, index: number) => V,
102
- ): { key: K; values: V[] }[];
103
- ```
104
-
105
- ### `toMap`
106
-
107
- Convert to a `Map`. Throws `ArgumentError` on duplicate keys.
108
-
109
- ```typescript
110
- toMap<K>(keySelector: (item: T, index: number) => K): Map<K, T>;
111
- toMap<K, V>(
112
- keySelector: (item: T, index: number) => K,
113
- valueSelector: (item: T, index: number) => V,
114
- ): Map<K, V>;
115
- ```
116
-
117
- ### `toMapAsync`
118
-
119
- Async version of `toMap`.
120
-
121
- ```typescript
122
- toMapAsync<K>(keySelector: (item: T, index: number) => Promise<K>): Promise<Map<K, T>>;
123
- toMapAsync<K, V>(
124
- keySelector: (item: T, index: number) => Promise<K> | K,
125
- valueSelector: (item: T, index: number) => Promise<V> | V,
126
- ): Promise<Map<K, V>>;
127
- ```
128
-
129
- ### `toArrayMap`
130
-
131
- Convert to a `Map<K, V[]>`. Multiple items with the same key are grouped into an array.
132
-
133
- ```typescript
134
- toArrayMap<K>(keySelector: (item: T, index: number) => K): Map<K, T[]>;
135
- toArrayMap<K, V>(
136
- keySelector: (item: T, index: number) => K,
137
- valueSelector: (item: T, index: number) => V,
138
- ): Map<K, V[]>;
139
- ```
140
-
141
- ### `toSetMap`
142
-
143
- Convert to a `Map<K, Set<V>>`.
144
-
145
- ```typescript
146
- toSetMap<K>(keySelector: (item: T, index: number) => K): Map<K, Set<T>>;
147
- toSetMap<K, V>(
148
- keySelector: (item: T, index: number) => K,
149
- valueSelector: (item: T, index: number) => V,
150
- ): Map<K, Set<V>>;
151
- ```
152
-
153
- ### `toMapValues`
154
-
155
- Group by key, then aggregate each group's items using a value selector.
156
-
157
- ```typescript
158
- toMapValues<K, V>(
159
- keySelector: (item: T, index: number) => K,
160
- valueSelector: (items: T[]) => V,
161
- ): Map<K, V>;
162
- ```
163
-
164
- ### `toObject`
165
-
166
- Convert to a plain object `Record<string, V>`. Throws `ArgumentError` on duplicate keys.
167
-
168
- ```typescript
169
- toObject(keySelector: (item: T, index: number) => string): Record<string, T>;
170
- toObject<V>(
171
- keySelector: (item: T, index: number) => string,
172
- valueSelector: (item: T, index: number) => V,
173
- ): Record<string, V>;
174
- ```
175
-
176
- ### `toTree`
177
-
178
- Convert a flat array to a tree structure. Items where `parentKey` is null/undefined become root nodes. Uses O(n) Map-based indexing internally.
179
-
180
- ```typescript
181
- toTree<K extends keyof T, P extends keyof T>(keyProp: K, parentKey: P): TreeArray<T>[];
182
- ```
183
-
184
- ### `distinct`
185
-
186
- Remove duplicates (returns a new array).
187
-
188
- ```typescript
189
- distinct(
190
- options?: boolean | { matchAddress?: boolean; keyFn?: (item: T) => string | number },
191
- ): T[];
192
- ```
193
-
194
- | Option | Description |
195
- |--------|-------------|
196
- | `true` or `{ matchAddress: true }` | Reference equality (Set-based, O(n)) |
197
- | `{ keyFn }` | Custom key function (O(n)) |
198
- | Default (no options) | Deep equality for objects (O(n^2)), type-based for primitives (O(n)) |
199
-
200
- ### `orderBy`
201
-
202
- Sort ascending (returns a new array). Supports `string`, `number`, `DateTime`, `DateOnly`, `Time`.
203
-
204
- ```typescript
205
- orderBy(selector?: (item: T) => string | number | DateTime | DateOnly | Time | undefined): T[];
206
- ```
207
-
208
- ### `orderByDesc`
209
-
210
- Sort descending (returns a new array).
211
-
212
- ```typescript
213
- orderByDesc(selector?: (item: T) => string | number | DateTime | DateOnly | Time | undefined): T[];
214
- ```
215
-
216
- ### `diffs`
217
-
218
- Compare this array (source) with a target array. Returns a list of insert/delete/update operations.
219
-
220
- ```typescript
221
- diffs<P>(target: P[]): ArrayDiffsResult<T, P>[];
222
- diffs<P extends Record<string, unknown>>(
223
- target: P[],
224
- options: { keys: string[]; excludes?: string[] },
225
- ): ArrayDiffsResult<T, P>[];
226
- diffs<P extends Record<string, unknown>>(
227
- target: P[],
228
- options: { excludes: string[] },
229
- ): ArrayDiffsResult<T, P>[];
230
- ```
231
-
232
- | Option | Description |
233
- |--------|-------------|
234
- | `keys` | Properties to use for matching source to target items |
235
- | `excludes` | Properties to ignore in equality comparison |
236
-
237
- ### `oneWayDiffs`
238
-
239
- One-way diff: compare this array against original items. Returns create/update/same results.
240
-
241
- ```typescript
242
- oneWayDiffs<K extends keyof T>(
243
- orgItems: T[] | Map<T[K], T>,
244
- keyPropNameOrGetValFn: K | ((item: T) => string | number | undefined),
245
- options?: { includeSame?: boolean; excludes?: string[]; includes?: string[] },
246
- ): ArrayOneWayDiffResult<T>[];
247
- ```
248
-
249
- ### `merge`
250
-
251
- Merge this array with a target array. Matched items are deep-merged; unmatched target items are appended.
252
-
253
- ```typescript
254
- merge<P>(target: P[]): (T | P | (T & P))[];
255
- merge<P extends Record<string, unknown>>(
256
- target: P[],
257
- options: { keys: string[]; excludes?: string[] },
258
- ): (T | P | (T & P))[];
259
- merge<P extends Record<string, unknown>>(
260
- target: P[],
261
- options: { excludes: string[] },
262
- ): (T | P | (T & P))[];
263
- ```
264
-
265
- ### `sum`
266
-
267
- Sum of elements. If no selector is provided, elements must be numbers.
268
-
269
- ```typescript
270
- sum(selector?: (item: T, index: number) => number): number;
271
- ```
272
-
273
- Returns `0` for empty arrays.
274
-
275
- ### `min`
276
-
277
- Minimum element or minimum selected value.
278
-
279
- ```typescript
280
- min(): T extends number | string ? T | undefined : never;
281
- min<P extends number | string>(selector?: (item: T, index: number) => P): P | undefined;
282
- ```
283
-
284
- ### `max`
285
-
286
- Maximum element or maximum selected value.
287
-
288
- ```typescript
289
- max(): T extends number | string ? T | undefined : never;
290
- max<P extends number | string>(selector?: (item: T, index: number) => P): P | undefined;
291
- ```
292
-
293
- ### `shuffle`
294
-
295
- Return a new array with elements in random order (Fisher-Yates algorithm).
296
-
297
- ```typescript
298
- shuffle(): T[];
299
- ```
300
-
301
- ---
302
-
303
- ## Mutable Array Extensions
304
-
305
- These methods mutate the original array in-place.
306
-
307
- ### `distinctThis`
308
-
309
- Remove duplicates in-place. Same options as `distinct`.
310
-
311
- ```typescript
312
- distinctThis(
313
- options?: boolean | { matchAddress?: boolean; keyFn?: (item: T) => string | number },
314
- ): T[];
315
- ```
316
-
317
- ### `orderByThis`
318
-
319
- Sort ascending in-place.
320
-
321
- ```typescript
322
- orderByThis(selector?: (item: T) => string | number | DateTime | DateOnly | Time | undefined): T[];
323
- ```
324
-
325
- ### `orderByDescThis`
326
-
327
- Sort descending in-place.
328
-
329
- ```typescript
330
- orderByDescThis(selector?: (item: T) => string | number | DateTime | DateOnly | Time | undefined): T[];
331
- ```
332
-
333
- ### `insert`
334
-
335
- Insert items at a given index. Mutates the array.
336
-
337
- ```typescript
338
- insert(index: number, ...items: T[]): this;
339
- ```
340
-
341
- ### `remove`
342
-
343
- Remove items by value or predicate. Mutates the array.
344
-
345
- ```typescript
346
- remove(item: T): this;
347
- remove(selector: (item: T, index: number) => boolean): this;
348
- ```
349
-
350
- ### `toggle`
351
-
352
- Toggle an item: remove if present, add (push) if absent.
353
-
354
- ```typescript
355
- toggle(item: T): this;
356
- ```
357
-
358
- ### `clear`
359
-
360
- Remove all items from the array.
361
-
362
- ```typescript
363
- clear(): this;
364
- ```
365
-
366
- ---
367
-
368
- ## Exported Types
369
-
370
- ### `ArrayDiffsResult<TOriginal, TOther>`
371
-
372
- ```typescript
373
- type ArrayDiffsResult<TOriginal, TOther> =
374
- | { source: undefined; target: TOther } // INSERT
375
- | { source: TOriginal; target: undefined } // DELETE
376
- | { source: TOriginal; target: TOther }; // UPDATE
377
- ```
378
-
379
- ### `ArrayOneWayDiffResult<TItem>`
380
-
381
- ```typescript
382
- type ArrayOneWayDiffResult<TItem> =
383
- | { type: "create"; item: TItem; orgItem: undefined }
384
- | { type: "update"; item: TItem; orgItem: TItem }
385
- | { type: "same"; item: TItem; orgItem: TItem };
386
- ```
387
-
388
- ### `TreeArray<TNode>`
389
-
390
- ```typescript
391
- type TreeArray<TNode> = TNode & { children: TreeArray<TNode>[] };
392
- ```
393
-
394
- ### `ComparableType`
395
-
396
- ```typescript
397
- type ComparableType = string | number | boolean | DateTime | DateOnly | Time | undefined;
398
- ```
399
-
package/docs/env.md DELETED
@@ -1,33 +0,0 @@
1
- # Environment
2
-
3
- ## `parseBoolEnv`
4
-
5
- Parse a value to boolean. Recognizes `"true"`, `"1"`, `"yes"`, `"on"` (case-insensitive) as `true`; everything else is `false`.
6
-
7
- ```typescript
8
- function parseBoolEnv(value: unknown): boolean;
9
- ```
10
-
11
- | Parameter | Type | Description |
12
- |-----------|------|-------------|
13
- | `value` | `unknown` | The value to parse. Converted to string internally. |
14
-
15
- **Returns:** `boolean`
16
-
17
- ## `env`
18
-
19
- Unified environment variable object. Merges `import.meta.env` and `process.env` (process.env takes precedence). `DEV` is auto-parsed as boolean, `VER` is typed as optional string.
20
-
21
- ```typescript
22
- const env: {
23
- DEV: boolean;
24
- VER?: string;
25
- [key: string]: unknown;
26
- };
27
- ```
28
-
29
- | Field | Type | Description |
30
- |-------|------|-------------|
31
- | `DEV` | `boolean` | Whether the app is running in development mode. Parsed from raw `DEV` env var via `parseBoolEnv`. |
32
- | `VER` | `string \| undefined` | Application version string, if set. |
33
- | `[key: string]` | `unknown` | Any other environment variable. |