@hzab/data-model 2.0.3-alpha.1 → 2.1.0-alpha.0
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/CHANGELOG.md +9 -150
- package/LICENSE +21 -0
- package/README.md +50 -270
- package/dist/index.cjs +6010 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1305 -0
- package/dist/index.d.ts +1305 -0
- package/dist/index.js +5956 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -49
- package/src/hooks.ts +7 -3
- package/src/index.ts +14 -11
- package/src/ArrayUtils.ts +0 -712
- package/src/RequestCache.ts +0 -202
- package/src/array-data-model.ts +0 -479
- package/src/axios.ts +0 -245
- package/src/data-model.ts +0 -850
- package/src/public-utils.ts +0 -26
- package/src/type.ts +0 -109
- package/src/utils.ts +0 -98
package/package.json
CHANGED
|
@@ -1,62 +1,76 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hzab/data-model",
|
|
3
|
-
"version": "2.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"version:beta": "npm version prerelease --preid=beta",
|
|
12
|
-
"publish:beta": "npm publish --tag beta",
|
|
13
|
-
"version:patch": "npm version patch",
|
|
14
|
-
"version:minior": "npm version minor",
|
|
15
|
-
"version:major": "npm version major",
|
|
16
|
-
"publish:stable": "npm publish --access public",
|
|
17
|
-
"prepare": "husky install",
|
|
18
|
-
"docs": "typedoc"
|
|
3
|
+
"version": "2.1.0-alpha.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "数据模型 2.1:再导出 core + useDataModel;后继 API 与旧写法双轨",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "CaiYansong",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
19
11
|
},
|
|
20
12
|
"files": [
|
|
13
|
+
"dist",
|
|
21
14
|
"src",
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE",
|
|
22
17
|
"CHANGELOG.md"
|
|
23
18
|
],
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
19
|
+
"main": "./dist/index.cjs",
|
|
20
|
+
"module": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.js",
|
|
26
|
+
"require": "./dist/index.cjs"
|
|
27
|
+
},
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"sideEffects": [
|
|
31
|
+
"./dist/index.js",
|
|
32
|
+
"./dist/index.cjs"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"axios": "^1.18.1",
|
|
36
|
+
"nanoid": "^3.3.15"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=24"
|
|
45
40
|
},
|
|
46
41
|
"peerDependencies": {
|
|
47
|
-
"
|
|
48
|
-
"
|
|
42
|
+
"js-cookie": "^3.0.5",
|
|
43
|
+
"react": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
49
44
|
},
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
|
|
45
|
+
"peerDependenciesMeta": {
|
|
46
|
+
"js-cookie": {
|
|
47
|
+
"optional": true
|
|
48
|
+
}
|
|
53
49
|
},
|
|
54
|
-
"
|
|
55
|
-
"
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@testing-library/react": "^16.3.3",
|
|
52
|
+
"@types/lodash-es": "^4.17.12",
|
|
53
|
+
"@types/node": "^24.0.0",
|
|
54
|
+
"@types/react": "^19.0.0",
|
|
55
|
+
"happy-dom": "^20.11.12",
|
|
56
|
+
"lodash-es": "^4.18.1",
|
|
57
|
+
"prettier": "^3.0.0",
|
|
58
|
+
"react": "^19.0.0",
|
|
59
|
+
"react-dom": "^19.2.8",
|
|
60
|
+
"tsup": "^8.5.1",
|
|
61
|
+
"typescript": "^5.9.3",
|
|
62
|
+
"vite": "^8.0.0",
|
|
63
|
+
"vitest": "^4.1.10",
|
|
64
|
+
"@hzab/data-model-core": "^2.1.0-alpha.0",
|
|
65
|
+
"@hzab/eslint-config": "^0.0.0",
|
|
66
|
+
"@hzab/vite-config": "^0.0.2-alpha.0",
|
|
67
|
+
"@hzab/typescript-config": "^0.0.0"
|
|
56
68
|
},
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
69
|
+
"scripts": {
|
|
70
|
+
"build": "tsup",
|
|
71
|
+
"typecheck": "tsc --noEmit -p tsconfig.json --rootDir .",
|
|
72
|
+
"test": "vitest run",
|
|
73
|
+
"lint": "eslint src --max-warnings=0",
|
|
74
|
+
"format:check": "prettier --check src"
|
|
61
75
|
}
|
|
62
|
-
}
|
|
76
|
+
}
|
package/src/hooks.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useMemo, useRef } from "react";
|
|
2
2
|
import { merge } from "lodash-es";
|
|
3
|
-
import DataModel
|
|
3
|
+
import DataModel from "@hzab/data-model-core";
|
|
4
|
+
import type { DataModelOptions } from "@hzab/data-model-core";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* useDataModel 选项接口
|
|
@@ -23,8 +24,11 @@ export interface UseDataModelOptions<T = any> {
|
|
|
23
24
|
* @param {Object} opt.effectQuery 动态的 query 数据
|
|
24
25
|
* @returns DataModel 实例
|
|
25
26
|
*/
|
|
26
|
-
export const useDataModel = function <T = any>(
|
|
27
|
-
|
|
27
|
+
export const useDataModel = function <T = any>(
|
|
28
|
+
initParams: DataModelOptions<T> = {},
|
|
29
|
+
opt: UseDataModelOptions<T> = {},
|
|
30
|
+
) {
|
|
31
|
+
const model = useRef<DataModel<T>>(new DataModel<T>(initParams));
|
|
28
32
|
return useMemo(() => {
|
|
29
33
|
const { effectParams, effectQuery } = opt || {};
|
|
30
34
|
if (effectParams) {
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export
|
|
1
|
+
/**
|
|
2
|
+
* 数据模型 2.1:再导出 `@hzab/data-model-core`(打进 dist,不单独发布),
|
|
3
|
+
* 并提供 `useDataModel`。后继 API 与旧写法双轨。
|
|
4
|
+
*
|
|
5
|
+
* 老页面 `import { useDataModel, DataModel, axios } from "@hzab/data-model"` 仍可用。
|
|
6
|
+
* 不要安装 `@hzab/data-model-core`(private,已被打进本包 dist)。
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
export * from "@hzab/data-model-core";
|
|
12
|
+
export { useDataModel } from "./hooks";
|
|
13
|
+
export type { UseDataModelOptions } from "./hooks";
|
|
14
|
+
export { default } from "@hzab/data-model-core";
|