@kcuf/helper-data 0.0.1 → 0.2.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 ADDED
@@ -0,0 +1,12 @@
1
+ # CHANGELOG
2
+
3
+ ## 0.2.0 2024/11/05 @驳是
4
+
5
+ * BREAK Removed Loading stuff
6
+ * BREAK `timeModified` → `timeUpdated`
7
+ * BREAK `whoCreated` → `creator`
8
+ * BREAK `whoModified` → `updater`
9
+
10
+ ## 0.1.0 2024/11/05 @驳是
11
+
12
+ * Revamped version
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @/pkg/data-normalizer
1
+ # @kcuf/helper-data
2
2
 
3
3
  将千奇百怪、随心所欲、虚头巴脑的后端数据中的字段、类型进行标准化的帮助类型及方法。
4
4
 
@@ -4,12 +4,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- Object.defineProperty(exports, "createDataWithLoading", {
8
- enumerable: true,
9
- get: function get() {
10
- return _createDataWithLoading.default;
11
- }
12
- });
13
7
  Object.defineProperty(exports, "normalizeBoolean", {
14
8
  enumerable: true,
15
9
  get: function get() {
@@ -40,6 +34,12 @@ Object.defineProperty(exports, "normalizePagedList", {
40
34
  return _normalizePagedList.default;
41
35
  }
42
36
  });
37
+ Object.defineProperty(exports, "normalizePagedListUncertain", {
38
+ enumerable: true,
39
+ get: function get() {
40
+ return _normalizePagedListUncertain.default;
41
+ }
42
+ });
43
43
  Object.defineProperty(exports, "normalizeTime", {
44
44
  enumerable: true,
45
45
  get: function get() {
@@ -52,4 +52,4 @@ var _normalizeNumber = _interopRequireDefault(require("./normalize-number"));
52
52
  var _normalizeEnum = _interopRequireDefault(require("./normalize-enum"));
53
53
  var _normalizeTime = _interopRequireDefault(require("./normalize-time"));
54
54
  var _normalizePagedList = _interopRequireDefault(require("./normalize-paged-list"));
55
- var _createDataWithLoading = _interopRequireDefault(require("./create-data-with-loading"));
55
+ var _normalizePagedListUncertain = _interopRequireDefault(require("./normalize-paged-list-uncertain"));
package/dist/cjs/index.js CHANGED
@@ -3,19 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- var _exportNames = {
7
- LoadingStatus: true
8
- };
9
- Object.defineProperty(exports, "LoadingStatus", {
10
- enumerable: true,
11
- get: function get() {
12
- return _enum.ELoadingStatus;
13
- }
14
- });
15
6
  var _helper = require("./helper");
16
7
  Object.keys(_helper).forEach(function (key) {
17
8
  if (key === "default" || key === "__esModule") return;
18
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
19
9
  if (key in exports && exports[key] === _helper[key]) return;
20
10
  Object.defineProperty(exports, key, {
21
11
  enumerable: true,
@@ -23,5 +13,4 @@ Object.keys(_helper).forEach(function (key) {
23
13
  return _helper[key];
24
14
  }
25
15
  });
26
- });
27
- var _enum = require("./enum");
16
+ });
@@ -4,5 +4,5 @@ export { default as normalizeNumber } from './normalize-number';
4
4
  export { default as normalizeEnum } from './normalize-enum';
5
5
  export { default as normalizeTime } from './normalize-time';
6
6
  export { default as normalizePagedList } from './normalize-paged-list';
7
- export { default as createDataWithLoading } from './create-data-with-loading';
7
+ export { default as normalizePagedListUncertain } from './normalize-paged-list-uncertain';
8
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["default","normalizeId","normalizeBoolean","normalizeNumber","normalizeEnum","normalizeTime","normalizePagedList","createDataWithLoading"],"sources":["../../../src/helper/index.ts"],"sourcesContent":["export { default as normalizeId } from './normalize-id';\nexport { default as normalizeBoolean } from './normalize-boolean';\nexport { default as normalizeNumber } from './normalize-number';\nexport { default as normalizeEnum } from './normalize-enum';\nexport { default as normalizeTime } from './normalize-time';\nexport { default as normalizePagedList } from './normalize-paged-list';\n\nexport { default as createDataWithLoading } from './create-data-with-loading';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,WAAW,QAAQ,gBAAgB;AACvD,SAASD,OAAO,IAAIE,gBAAgB,QAAQ,qBAAqB;AACjE,SAASF,OAAO,IAAIG,eAAe,QAAQ,oBAAoB;AAC/D,SAASH,OAAO,IAAII,aAAa,QAAQ,kBAAkB;AAC3D,SAASJ,OAAO,IAAIK,aAAa,QAAQ,kBAAkB;AAC3D,SAASL,OAAO,IAAIM,kBAAkB,QAAQ,wBAAwB;AAEtE,SAASN,OAAO,IAAIO,qBAAqB,QAAQ,4BAA4B","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["default","normalizeId","normalizeBoolean","normalizeNumber","normalizeEnum","normalizeTime","normalizePagedList","normalizePagedListUncertain"],"sources":["../../../src/helper/index.ts"],"sourcesContent":["export { default as normalizeId } from './normalize-id';\nexport { default as normalizeBoolean } from './normalize-boolean';\nexport { default as normalizeNumber } from './normalize-number';\nexport { default as normalizeEnum } from './normalize-enum';\nexport { default as normalizeTime } from './normalize-time';\nexport { default as normalizePagedList } from './normalize-paged-list';\nexport { default as normalizePagedListUncertain } from './normalize-paged-list-uncertain';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,WAAW,QAAQ,gBAAgB;AACvD,SAASD,OAAO,IAAIE,gBAAgB,QAAQ,qBAAqB;AACjE,SAASF,OAAO,IAAIG,eAAe,QAAQ,oBAAoB;AAC/D,SAASH,OAAO,IAAII,aAAa,QAAQ,kBAAkB;AAC3D,SAASJ,OAAO,IAAIK,aAAa,QAAQ,kBAAkB;AAC3D,SAASL,OAAO,IAAIM,kBAAkB,QAAQ,wBAAwB;AACtE,SAASN,OAAO,IAAIO,2BAA2B,QAAQ,kCAAkC","ignoreList":[]}
package/dist/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export * from './helper';
2
- export { ELoadingStatus as LoadingStatus } from './enum';
2
+ export {};
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ELoadingStatus","LoadingStatus"],"sources":["../../src/index.ts"],"sourcesContent":["export * from './helper';\n\nexport {\n ELoadingStatus as LoadingStatus\n} from './enum';\n\nexport type {\n IBaseParamsPage as BaseParamsPage,\n IBaseParamsPageWithQ as BaseParamsPageWithQ,\n \n IBaseDataId as BaseDataId,\n IBaseDataName as BaseDataName,\n IBaseDataIdName as BaseDataIdName,\n IBaseDataTitle as BaseDataTitle,\n IBaseDataContent as BaseDataContent,\n IBaseDataTimeCreated as BaseDataTimeCreated,\n IBaseDataTimeModified as BaseDataTimeModified,\n IBaseDataTimes as BaseDataTimes,\n \n IPagedList as PagedList,\n IPagedListUncertain as PagedListUncertain,\n \n IDataWithLoading as DataWithLoading\n} from './types';\n"],"mappings":"AAAA,cAAc,UAAU;AAExB,SACEA,cAAc,IAAIC,aAAa,QAC1B,QAAQ","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from './helper';\n\nexport type {\n IBaseParamsPage as BaseParamsPage,\n IBaseParamsPageWithQ as BaseParamsPageWithQ,\n \n IBaseDataId as BaseDataId,\n IBaseDataName as BaseDataName,\n IBaseDataIdName as BaseDataIdName,\n IBaseDataTitle as BaseDataTitle,\n IBaseDataDescription as BaseDataDescription,\n IBaseDataContent as BaseDataContent,\n IBaseDataTimeCreated as BaseDataTimeCreated,\n IBaseDataTimeUpdated as BaseDataTimeModified,\n IBaseDataTimes as BaseDataTimes,\n IBaseDataCreator as BaseDataCreator,\n IBaseDataUpdater as BaseDataUpdater,\n \n IPagedList as PagedList,\n IPagedListUncertain as PagedListUncertain\n} from './types';\n"],"mappings":"AAAA,cAAc,UAAU;AAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"base-data.js","names":[],"sources":["../../../src/types/base-data.ts"],"sourcesContent":["// 基础类型 mixin,用于继承,统一前缀 BaseData\n\n/**\n * 「ID」标准化\n */\nexport interface IBaseDataId {\n id: string;\n}\n\n/**\n * 「名称」标准化\n */\nexport interface IBaseDataName {\n name: string;\n}\n\n/**\n * 「标题」标准化\n */\nexport interface IBaseDataTitle {\n title: string;\n}\n\n/**\n * 「内容」标准化\n */\nexport interface IBaseDataContent {\n content: string;\n}\n\n/**\n * id + name\n */\nexport interface IBaseDataIdName extends IBaseDataId, IBaseDataName {}\n\n/**\n * 「创建时间」标准化\n */\nexport interface IBaseDataTimeCreated {\n timeCreated: Date;\n}\n\n/**\n * 「更新时间」标准化\n */\nexport interface IBaseDataTimeModified {\n timeModified: Date;\n}\n\n/**\n * timeCreated + timeModified\n */\nexport interface IBaseDataTimes extends IBaseDataTimeCreated, IBaseDataTimeModified {}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"base-data.js","names":[],"sources":["../../../src/types/base-data.ts"],"sourcesContent":["// 基础类型 mixin,用于继承,统一前缀 BaseData\n\n/**\n * 「ID」标准化\n */\nexport interface IBaseDataId {\n id: string;\n}\n\n/**\n * 「名称」标准化\n */\nexport interface IBaseDataName {\n name: string;\n}\n\n/**\n * 「标题」标准化\n */\nexport interface IBaseDataTitle {\n title: string;\n}\n\n/**\n * 「内容」标准化\n */\nexport interface IBaseDataContent {\n content: string;\n}\n\n/**\n * 「描述」标准化\n */\nexport interface IBaseDataDescription {\n description: string;\n}\n\n/**\n * id + name\n */\nexport interface IBaseDataIdName extends IBaseDataId, IBaseDataName {}\n\n/**\n * 「创建时间」标准化\n */\nexport interface IBaseDataTimeCreated {\n timeCreated: Date;\n}\n\n/**\n * 「更新时间」标准化\n */\nexport interface IBaseDataTimeUpdated {\n timeUpdated: Date;\n}\n\n/**\n * timeCreated + timeUpdated\n */\nexport interface IBaseDataTimes extends IBaseDataTimeCreated, IBaseDataTimeUpdated {}\n\n/**\n * 「创建人」标准化\n */\nexport interface IBaseDataCreator {\n creator: IBaseDataIdName;\n}\n\n/**\n * 「更新人」标准化\n */\nexport interface IBaseDataUpdater {\n updater: IBaseDataIdName;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"generic.js","names":[],"sources":["../../../src/types/generic.ts"],"sourcesContent":["import {\n ELoadingStatus\n} from '../enum';\n\n/**\n * 分页数据标准化\n */\nexport interface IPagedList<T> {\n list: T[];\n total: number;\n page: number;\n pageSize: number;\n}\n\n/**\n * 某些分页接口,后端给的数据只有列表,前端需根据返回转成非确定分页列表数据\n */\nexport interface IPagedListUncertain<T> extends Omit<IPagedList<T>, 'total'> {\n hasMore: boolean;\n}\n\nexport interface IDataWithLoading<T> {\n loading: ELoadingStatus;\n data: T | null | undefined;\n error: Error | null | undefined;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"generic.js","names":[],"sources":["../../../src/types/generic.ts"],"sourcesContent":["/**\n * 分页数据标准化\n */\nexport interface IPagedList<T> {\n list: T[];\n total: number;\n page: number;\n pageSize: number;\n}\n\n/**\n * 某些分页接口,后端给的数据只有列表,前端需根据返回转成非确定分页列表数据\n */\nexport interface IPagedListUncertain<T> extends Omit<IPagedList<T>, 'total'> {\n hasMore: boolean;\n}\n"],"mappings":"","ignoreList":[]}
@@ -4,4 +4,4 @@ export { default as normalizeNumber } from './normalize-number';
4
4
  export { default as normalizeEnum } from './normalize-enum';
5
5
  export { default as normalizeTime } from './normalize-time';
6
6
  export { default as normalizePagedList } from './normalize-paged-list';
7
- export { default as createDataWithLoading } from './create-data-with-loading';
7
+ export { default as normalizePagedListUncertain } from './normalize-paged-list-uncertain';
@@ -1,3 +1,2 @@
1
1
  export * from './helper';
2
- export { ELoadingStatus as LoadingStatus } from './enum';
3
- export type { IBaseParamsPage as BaseParamsPage, IBaseParamsPageWithQ as BaseParamsPageWithQ, IBaseDataId as BaseDataId, IBaseDataName as BaseDataName, IBaseDataIdName as BaseDataIdName, IBaseDataTitle as BaseDataTitle, IBaseDataContent as BaseDataContent, IBaseDataTimeCreated as BaseDataTimeCreated, IBaseDataTimeModified as BaseDataTimeModified, IBaseDataTimes as BaseDataTimes, IPagedList as PagedList, IPagedListUncertain as PagedListUncertain, IDataWithLoading as DataWithLoading } from './types';
2
+ export type { IBaseParamsPage as BaseParamsPage, IBaseParamsPageWithQ as BaseParamsPageWithQ, IBaseDataId as BaseDataId, IBaseDataName as BaseDataName, IBaseDataIdName as BaseDataIdName, IBaseDataTitle as BaseDataTitle, IBaseDataDescription as BaseDataDescription, IBaseDataContent as BaseDataContent, IBaseDataTimeCreated as BaseDataTimeCreated, IBaseDataTimeUpdated as BaseDataTimeModified, IBaseDataTimes as BaseDataTimes, IBaseDataCreator as BaseDataCreator, IBaseDataUpdater as BaseDataUpdater, IPagedList as PagedList, IPagedListUncertain as PagedListUncertain } from './types';
@@ -22,6 +22,12 @@ export interface IBaseDataTitle {
22
22
  export interface IBaseDataContent {
23
23
  content: string;
24
24
  }
25
+ /**
26
+ * 「描述」标准化
27
+ */
28
+ export interface IBaseDataDescription {
29
+ description: string;
30
+ }
25
31
  /**
26
32
  * id + name
27
33
  */
@@ -36,11 +42,23 @@ export interface IBaseDataTimeCreated {
36
42
  /**
37
43
  * 「更新时间」标准化
38
44
  */
39
- export interface IBaseDataTimeModified {
40
- timeModified: Date;
45
+ export interface IBaseDataTimeUpdated {
46
+ timeUpdated: Date;
47
+ }
48
+ /**
49
+ * timeCreated + timeUpdated
50
+ */
51
+ export interface IBaseDataTimes extends IBaseDataTimeCreated, IBaseDataTimeUpdated {
52
+ }
53
+ /**
54
+ * 「创建人」标准化
55
+ */
56
+ export interface IBaseDataCreator {
57
+ creator: IBaseDataIdName;
41
58
  }
42
59
  /**
43
- * timeCreated + timeModified
60
+ * 「更新人」标准化
44
61
  */
45
- export interface IBaseDataTimes extends IBaseDataTimeCreated, IBaseDataTimeModified {
62
+ export interface IBaseDataUpdater {
63
+ updater: IBaseDataIdName;
46
64
  }
@@ -1,4 +1,3 @@
1
- import { ELoadingStatus } from '../enum';
2
1
  /**
3
2
  * 分页数据标准化
4
3
  */
@@ -14,8 +13,3 @@ export interface IPagedList<T> {
14
13
  export interface IPagedListUncertain<T> extends Omit<IPagedList<T>, 'total'> {
15
14
  hasMore: boolean;
16
15
  }
17
- export interface IDataWithLoading<T> {
18
- loading: ELoadingStatus;
19
- data: T | null | undefined;
20
- error: Error | null | undefined;
21
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kcuf/helper-data",
3
- "version": "0.0.1",
3
+ "version": "0.2.0",
4
4
  "description": "Data normalizer helpers and loading stuff to make all frontend data processing sane.",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -22,17 +22,17 @@
22
22
  "access": "public"
23
23
  },
24
24
  "devDependencies": {
25
- "@babel/cli": "^7.25.9",
26
- "@babel/core": "^7.26.0",
27
- "@babel/plugin-transform-runtime": "^7.25.9",
28
- "@babel/preset-env": "^7.26.0",
29
- "@babel/preset-typescript": "^7.26.0",
25
+ "@babel/cli": "^7.28.3",
26
+ "@babel/core": "^7.28.3",
27
+ "@babel/plugin-transform-runtime": "^7.28.3",
28
+ "@babel/preset-env": "^7.28.3",
29
+ "@babel/preset-typescript": "^7.27.1",
30
30
  "rimraf": "^6.0.1",
31
- "typescript": "^5.6.3",
31
+ "typescript": "^5.9.2",
32
32
  "@kcuf/ts-config": "^0.0.1"
33
33
  },
34
34
  "peerDependencies": {
35
- "@babel/runtime": "^7.24.8"
35
+ "@babel/runtime": "^7.x"
36
36
  },
37
37
  "scripts": {
38
38
  "build:clean": "rimraf dist",
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ELoadingStatus = void 0;
7
- /**
8
- * 数据加载状态
9
- */
10
- var ELoadingStatus = exports.ELoadingStatus = /*#__PURE__*/function (ELoadingStatus) {
11
- ELoadingStatus[ELoadingStatus["IDLE"] = 0] = "IDLE";
12
- ELoadingStatus[ELoadingStatus["LOADING"] = 1] = "LOADING";
13
- ELoadingStatus[ELoadingStatus["SUCCESS"] = 2] = "SUCCESS";
14
- ELoadingStatus[ELoadingStatus["ERROR"] = 3] = "ERROR";
15
- return ELoadingStatus;
16
- }({});
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = createDataWithLoading;
7
- var _enum = require("../enum");
8
- function createDataWithLoading(data) {
9
- var loading = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _enum.ELoadingStatus.IDLE;
10
- var error = arguments.length > 2 ? arguments[2] : undefined;
11
- return {
12
- loading: loading,
13
- data: data,
14
- error: error
15
- };
16
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * 数据加载状态
3
- */
4
- export var ELoadingStatus = /*#__PURE__*/function (ELoadingStatus) {
5
- ELoadingStatus[ELoadingStatus["IDLE"] = 0] = "IDLE";
6
- ELoadingStatus[ELoadingStatus["LOADING"] = 1] = "LOADING";
7
- ELoadingStatus[ELoadingStatus["SUCCESS"] = 2] = "SUCCESS";
8
- ELoadingStatus[ELoadingStatus["ERROR"] = 3] = "ERROR";
9
- return ELoadingStatus;
10
- }({});
11
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["ELoadingStatus"],"sources":["../../../src/enum/index.ts"],"sourcesContent":["/**\n * 数据加载状态\n */\nexport enum ELoadingStatus {\n IDLE,\n LOADING,\n SUCCESS,\n ERROR\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,WAAYA,cAAc,0BAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAdA,cAAc,CAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA","ignoreList":[]}
@@ -1,11 +0,0 @@
1
- import { ELoadingStatus } from '../enum';
2
- export default function createDataWithLoading(data) {
3
- var loading = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ELoadingStatus.IDLE;
4
- var error = arguments.length > 2 ? arguments[2] : undefined;
5
- return {
6
- loading: loading,
7
- data: data,
8
- error: error
9
- };
10
- }
11
- //# sourceMappingURL=create-data-with-loading.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create-data-with-loading.js","names":["ELoadingStatus","createDataWithLoading","data","loading","arguments","length","undefined","IDLE","error"],"sources":["../../../src/helper/create-data-with-loading.ts"],"sourcesContent":["import {\n ELoadingStatus\n} from '../enum';\nimport {\n IDataWithLoading\n} from '../types';\n\nexport default function createDataWithLoading<T>(data?: T | null, loading = ELoadingStatus.IDLE, error?: Error | null): IDataWithLoading<T> {\n return {\n loading,\n data,\n error\n };\n}\n"],"mappings":"AAAA,SACEA,cAAc,QACT,SAAS;AAKhB,eAAe,SAASC,qBAAqBA,CAAIC,IAAe,EAA4E;EAAA,IAA1EC,OAAO,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGJ,cAAc,CAACO,IAAI;EAAA,IAAEC,KAAoB,GAAAJ,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EACnH,OAAO;IACLH,OAAO,EAAPA,OAAO;IACPD,IAAI,EAAJA,IAAI;IACJM,KAAK,EAALA;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,9 +0,0 @@
1
- /**
2
- * 数据加载状态
3
- */
4
- export declare enum ELoadingStatus {
5
- IDLE = 0,
6
- LOADING = 1,
7
- SUCCESS = 2,
8
- ERROR = 3
9
- }
@@ -1,3 +0,0 @@
1
- import { ELoadingStatus } from '../enum';
2
- import { IDataWithLoading } from '../types';
3
- export default function createDataWithLoading<T>(data?: T | null, loading?: ELoadingStatus, error?: Error | null): IDataWithLoading<T>;