@simplysm/core-common 13.0.0-beta.22 → 13.0.0-beta.23

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 (2) hide show
  1. package/README.md +17 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -654,9 +654,12 @@ TypeScript utility types.
654
654
  | `Type<T>` | Constructor type (for dependency injection, factory patterns) |
655
655
  | `ObjUndefToOptional<T>` | Convert properties with `undefined` to optional |
656
656
  | `ObjOptionalToUndef<T>` | Convert optional properties to `required + undefined` union |
657
+ | `ArrayDiffsResult<T, P>` | Result of `Array.diffs()` — insert / delete / update entries |
658
+ | `ArrayDiffs2Result<T>` | Result of `Array.oneWayDiffs()` — create / update / same entries |
659
+ | `TreeArray<T>` | Result of `Array.toTree()` — `T & { children: TreeArray<T>[] }` |
657
660
 
658
661
  ```typescript
659
- import type { DeepPartial, Type, Bytes } from "@simplysm/core-common";
662
+ import type { DeepPartial, Type, Bytes, ArrayDiffsResult, TreeArray } from "@simplysm/core-common";
660
663
 
661
664
  // DeepPartial: deep Partial
662
665
  interface Config {
@@ -671,6 +674,19 @@ function create<T>(ctor: Type<T>): T {
671
674
 
672
675
  // Bytes: Buffer replacement
673
676
  const data: Bytes = new Uint8Array([1, 2, 3]);
677
+
678
+ // ArrayDiffsResult: diff comparison result type
679
+ const diffs: ArrayDiffsResult<User, User>[] = oldUsers.diffs(newUsers, { keys: ["id"] });
680
+ for (const diff of diffs) {
681
+ if (diff.source === undefined) { /* INSERT */ }
682
+ else if (diff.target === undefined) { /* DELETE */ }
683
+ else { /* UPDATE */ }
684
+ }
685
+
686
+ // TreeArray: tree structure result type
687
+ interface Category { id: number; parentId: number | undefined; name: string }
688
+ const tree: TreeArray<Category>[] = categories.toTree("id", "parentId");
689
+ // Each node has a `children` array of the same type
674
690
  ```
675
691
 
676
692
  ### Extensions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/core-common",
3
- "version": "13.0.0-beta.22",
3
+ "version": "13.0.0-beta.23",
4
4
  "description": "심플리즘 패키지 - 코어 모듈 (common)",
5
5
  "author": "김석래",
6
6
  "repository": {