vome-core 0.3.47 → 0.3.49

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 (77) hide show
  1. package/dist/admin/components/ui/avatar/index.js +1 -1
  2. package/dist/admin/components/ui/checkbox/index.js +1 -1
  3. package/dist/admin/components/ui/dialog/index.js +1 -1
  4. package/dist/admin/components/ui/dropdown-menu/index.js +1 -1
  5. package/dist/admin/components/ui/input/index.js +1 -1
  6. package/dist/admin/components/ui/label/index.js +1 -1
  7. package/dist/admin/components/ui/scroll-area/index.js +1 -1
  8. package/dist/admin/components/ui/select/index.js +1 -1
  9. package/dist/admin/components/ui/separator/index.js +1 -1
  10. package/dist/admin/components/ui/sheet/index.js +1 -1
  11. package/dist/admin/components/ui/sonner/index.js +1 -1
  12. package/dist/admin/components/ui/table/index.js +1 -1
  13. package/dist/admin/components/ui/tabs/index.js +1 -1
  14. package/dist/admin/components/ui/tooltip/index.js +1 -1
  15. package/dist/admin/crud/auto-fields.js +1 -1
  16. package/dist/admin/crud/config.js +1 -1
  17. package/dist/admin/crud/confirm.js +1 -1
  18. package/dist/admin/crud/crud-page-request.js +1 -1
  19. package/dist/admin/crud/data-i18n.js +1 -1
  20. package/dist/admin/crud/dict.js +1 -1
  21. package/dist/admin/crud/export-fetch.js +1 -1
  22. package/dist/admin/crud/key.js +1 -1
  23. package/dist/admin/crud/plugins.js +1 -1
  24. package/dist/admin/crud/span.js +1 -1
  25. package/dist/admin/crud/style.js +1 -1
  26. package/dist/admin/crud/validate.js +1 -1
  27. package/dist/admin/directives/perm.js +1 -1
  28. package/dist/admin/hooks/useUpload.js +1 -1
  29. package/dist/admin/lib/browser.js +1 -1
  30. package/dist/admin/lib/cn.js +1 -1
  31. package/dist/admin/lib/dialog-float.js +1 -1
  32. package/dist/admin/lib/export-excel.js +1 -1
  33. package/dist/admin/lib/import-excel.js +1 -1
  34. package/dist/admin/lib/json.js +1 -1
  35. package/dist/admin/lib/menu.js +1 -1
  36. package/dist/admin/lib/micro-locale.js +1 -1
  37. package/dist/admin/lib/micro-theme.js +1 -1
  38. package/dist/admin/lib/shell.js +1 -1
  39. package/dist/admin/lib/theme-color-options.js +1 -1
  40. package/dist/admin/lib/tree.js +1 -1
  41. package/dist/admin/lib/upload.js +1 -1
  42. package/dist/admin/lib/video-frame.js +1 -1
  43. package/dist/admin/router/create.js +1 -1
  44. package/dist/admin/router/guards.js +1 -1
  45. package/dist/ai/index.js +1 -1
  46. package/dist/client/ai-model-registry.js +1 -1
  47. package/dist/client/base.js +1 -1
  48. package/dist/client/configure.js +1 -1
  49. package/dist/client/dict.js +1 -1
  50. package/dist/client/eps-payload.js +1 -1
  51. package/dist/client/eps.js +1 -1
  52. package/dist/client/index.js +1 -1
  53. package/dist/client/locale-change.js +1 -1
  54. package/dist/client/locale-store.js +1 -1
  55. package/dist/client/service.js +1 -1
  56. package/dist/client/vite-admin.js +1 -1
  57. package/dist/client/vite-auto-import.js +1 -1
  58. package/dist/client/vite-micro-proxy.js +1 -1
  59. package/dist/client/vite-plugin-eps.js +1 -1
  60. package/dist/client/vite-resolve.js +1 -1
  61. package/dist/config/index.js +1 -1
  62. package/dist/index.js +1 -1
  63. package/dist/orm/import-excel.d.ts +5 -6
  64. package/dist/orm/index.d.ts +1 -1
  65. package/dist/orm/repository.d.ts +35 -1
  66. package/dist/orm/service.d.ts +2 -1
  67. package/dist/orm/unique-keys.d.ts +7 -0
  68. package/dist/server/index.js +1 -1
  69. package/dist/shared/datetime-picker.js +1 -1
  70. package/dist/shared/decimal.js +1 -1
  71. package/dist/shared/excel.js +1 -1
  72. package/dist/shared/index.js +1 -1
  73. package/dist/shared/locale-json.js +1 -1
  74. package/dist/shared/tree.js +1 -1
  75. package/dist/typings/comm/crud.d.ts +2 -0
  76. package/package.json +1 -1
  77. package/typings/comm/crud.ts +2 -0
@@ -10,13 +10,12 @@ type ImportRowResult = {
10
10
  }>;
11
11
  };
12
12
  /**
13
- * 按唯一键 upsert 导入行(含软删恢复,走 Repository.upsert):
14
- * 1. id 且存在 更新(软删先 restore)
15
- * 2. 否则按 unique 索引匹配 更新(软删先 restore)
16
- * 3. 否则新增(唯一键撞软删亦 restore)
13
+ * 清洗后整批 `svc.add`(与声明式 CRUD add 同源):
14
+ * - 开 softDelete:`Repository.upsert`(有 id / 唯一键撞软删恢复 / 撞活行覆盖 / 纯新增)
15
+ * - 否则按 `vome.crud.upsert`:`save` id 则更新否则插;`insert` 只插
16
+ * `uniqueKeys`(Controller `importUniqueKeys`)在 softDelete→upsert 时覆盖表 unique。
17
17
  */
18
- export declare function importEntityRows(svc: BaseService, table: PgTable, rows: Record<string, unknown>[], options?: {
19
- /** 覆盖表唯一索引;不传则读表 unique */
18
+ export declare function importEntityRows(svc: BaseService, _table: PgTable, rows: Record<string, unknown>[], options?: {
20
19
  uniqueKeys?: string[];
21
20
  ignoreProperty?: string[];
22
21
  }): Promise<ImportRowResult>;
@@ -14,7 +14,7 @@ export { readCrudConfig, resolveSoftDelete, resolveUpsert, } from './crud-config
14
14
  export { Repository, getRepository, InjectRepository, } from './repository';
15
15
  export { registerOnForceDelete, clearForceDeleteHooks, runOnForceDelete, } from './force-delete-hooks';
16
16
  export type { ForceDeleteHook, ForceDeleteHookEvent, } from './force-delete-hooks';
17
- export { listUniqueKeySets, buildUniqueWhere } from './unique-keys';
17
+ export { listUniqueKeySets, buildUniqueWhere, buildUniqueWhereForRows, uniqueFingerprint, } from './unique-keys';
18
18
  export { BaseService } from './service';
19
19
  export { q, compactWhere, needsAdvancedQuery, buildQueryOp } from './query-op';
20
20
  export { queryWithOp } from './query-builder';
@@ -41,23 +41,57 @@ export declare class Repository<T extends PgTable> {
41
41
  private findSoftDeletedByUnique;
42
42
  /** 按唯一键找行(含软删);`uniqueKeys` 覆盖表上 unique 索引 */
43
43
  private findByUniqueIncludingTrashed;
44
+ /**
45
+ * 批量按唯一键组查询;返回每组 fingerprint → 行。
46
+ * `onlyTrashed` 时只查软删行(create 撞软删恢复用)。
47
+ */
48
+ private lookupUniqueMaps;
49
+ private matchUniqueMaps;
44
50
  private rowId;
45
51
  private rowDeleteTime;
46
52
  private restoreThenUpdate;
53
+ /** 批量恢复软删 id(一次 UPDATE) */
54
+ private restoreSoftIds;
55
+ /** 纯批量 INSERT(不再走 softDelete 逐条逻辑) */
56
+ private insertManyRaw;
57
+ /** 行在各唯一键组上的指纹(`setIdx:fp`);无完整键则空 */
58
+ private uniqueFpKeys;
59
+ /**
60
+ * 同批待插入行按唯一键折叠:先到者 insert,后者挂到同一 root 插入行,插完再 update(对齐逐条 upsert)。
61
+ */
62
+ private foldInsertsByUnique;
63
+ /**
64
+ * 批量:restore → update → insert → 同批折叠的 deferred update。
65
+ * 返回与入参等长、按下标对齐;缺结果则抛错。
66
+ */
67
+ private applyBatchWrite;
47
68
  private createOne;
69
+ /**
70
+ * softDelete 下 create(数组):批量查软删唯一键 → 恢复更新 / 纯插入。
71
+ * 同批重复唯一键折叠(先插后更);撞活行唯一仍由 DB 报错。
72
+ */
73
+ private createManySoft;
48
74
  /**
49
75
  * 插入;若唯一键命中软删行则 restore + update(不再抛唯一冲突)。
50
- * 数组:开启软删时逐条处理(可能混插/恢复);否则仍一条批量 INSERT。
76
+ * 数组:
77
+ * - 开 softDelete:批量查软删唯一 → 批量恢复更新 / 批量插入
78
+ * - 否则:一条批量 INSERT,`ON CONFLICT DO NOTHING`
51
79
  */
52
80
  create(data: readonly unknown[]): Promise<InferSelectModel<T>[]>;
53
81
  create(data: unknown): Promise<InferSelectModel<T>>;
54
82
  /**
55
83
  * 按 id 或唯一键写入:命中则 update(软删先 restore;活行则覆盖),未命中则 create。
84
+ * 数组:先批量查 id / 唯一键,再批量更新 + 批量新增。
56
85
  * `options.uniqueKeys` 覆盖表 unique(如 Excel importUniqueKeys)。
57
86
  */
87
+ upsert(data: readonly unknown[], options?: {
88
+ uniqueKeys?: string[];
89
+ }): Promise<InferSelectModel<T>[]>;
58
90
  upsert(data: unknown, options?: {
59
91
  uniqueKeys?: string[];
60
92
  }): Promise<InferSelectModel<T>>;
93
+ /** 批量 upsert:查 id → 查唯一键 → 分类 → 批量 restore/update/insert */
94
+ private upsertMany;
61
95
  /**
62
96
  * 有 id 且存在(含软删)则更新(软删先 restore),否则插入。
63
97
  * 对象 / 数组均可;数组时一次查出已存在 id,再批量 update + insert。
@@ -34,9 +34,10 @@ export declare abstract class BaseService {
34
34
  modifyAfter(_data: any, _type: CrudModifyType): Promise<void>;
35
35
  /**
36
36
  * 新增(单条 / 数组)。
37
- * - 表支持软删且 `vome.crud.softDelete`:统一 `Repository.upsert`
37
+ * - 表支持软删且 `vome.crud.softDelete`:统一 `Repository.upsert`(单条 / 数组均批量分类写入)
38
38
  * (有 id / 唯一键撞软删恢复 / 撞活行覆盖 / 纯新增;与配置 save|insert 无关)
39
39
  * - 否则:按 `vome.crud.upsert` → `save`(有 id 则更新)或 `create`(只插)
40
+ * - `options.uniqueKeys`:仅 softDelete→upsert 时覆盖表 unique(Excel import 用)
40
41
  */
41
42
  add(data: unknown, options?: CrudWriteOptions): Promise<unknown>;
42
43
  /**
@@ -2,5 +2,12 @@ import { type SQL } from 'drizzle-orm';
2
2
  import { type PgTable } from 'drizzle-orm/pg-core';
3
3
  /** 从表唯一索引 / unique 约束提取键集合 */
4
4
  export declare function listUniqueKeySets(table: PgTable): string[][];
5
+ /** 唯一键指纹;任一键为空则 undefined */
6
+ export declare function uniqueFingerprint(keys: string[], row: Record<string, unknown>): string | undefined;
5
7
  /** 按唯一键拼 where;任一键为空则返回 undefined */
6
8
  export declare function buildUniqueWhere(table: PgTable, keys: string[], row: Record<string, unknown>): SQL | undefined;
9
+ /**
10
+ * 多行同一唯一键组:单列用 inArray,多列用 OR(AND…)。
11
+ * 无有效行时返回 undefined。
12
+ */
13
+ export declare function buildUniqueWhereForRows(table: PgTable, keys: string[], rows: Record<string, unknown>[]): SQL | undefined;