@quanxiaoxiao/datav 0.3.0 → 0.3.2

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": "@quanxiaoxiao/datav",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test"
@@ -22,7 +22,7 @@
22
22
  "node": ">= 20.0.0"
23
23
  },
24
24
  "dependencies": {
25
- "@quanxiaoxiao/utils": "^0.9.0",
25
+ "@quanxiaoxiao/utils": "^0.11.0",
26
26
  "ajv": "^8.12.0",
27
27
  "lodash": "^4.17.21"
28
28
  }
@@ -860,7 +860,7 @@ test('select > index, resolve pathList', () => {
860
860
  });
861
861
  });
862
862
 
863
- test('select > index, resolve pathList 2', { only: true }, () => {
863
+ test('select > index, resolve pathList 2', () => {
864
864
  const ret = select(
865
865
  {
866
866
  type: 'object',
@@ -1018,13 +1018,103 @@ test('select 666', () => {
1018
1018
  const ret = select({
1019
1019
  type: 'object',
1020
1020
  properties: {
1021
- chl: ['.', {
1021
+ chl: {
1022
1022
  type: 'array',
1023
1023
  properties: ['$channel', { type: 'string' }],
1024
- }],
1024
+ },
1025
1025
  },
1026
1026
  })({
1027
1027
  channel: '1',
1028
1028
  });
1029
1029
  assert.deepEqual(ret, { chl: ['1'] });
1030
1030
  });
1031
+
1032
+ test('select 777', () => {
1033
+ const ret = select({
1034
+ type: 'object',
1035
+ properties: {
1036
+ key: {
1037
+ type: 'string',
1038
+ },
1039
+ params: {
1040
+ type: 'array',
1041
+ properties: {
1042
+ task: ['$taskId', { type: 'number' }],
1043
+ date: ['$dateName', { type: 'string' }],
1044
+ },
1045
+ },
1046
+ },
1047
+ })({
1048
+ key: '123',
1049
+ taskId: '999',
1050
+ dateName: '2024-06-06',
1051
+ });
1052
+ assert.deepEqual(ret, {
1053
+ key: '123',
1054
+ params: [
1055
+ {
1056
+ task: '999',
1057
+ date: '2024-06-06',
1058
+ },
1059
+ ],
1060
+ });
1061
+ });
1062
+
1063
+ test('select 888', () => {
1064
+ const ret = select({
1065
+ type: 'object',
1066
+ properties: {
1067
+ dir: ['.data.0.dir', { type: 'string' }],
1068
+ name: ['.data.0.name', { type: 'string' }],
1069
+ },
1070
+ })({
1071
+ data: [
1072
+ {
1073
+ dir: 'QzpcVmlkZW9ccXExMjM0XDIwMTctMDYtMTlccmVjb3JkXDE=',
1074
+ name: 'qq1234-170619-000000-002000-01p401000000.264'
1075
+ },
1076
+ {
1077
+ dir: 'QzpcVmlkZW9ccXExMjM0XDIwMTctMDYtMTlccmVjb3JkXDE=',
1078
+ name: 'qq1234-170619-000000-002000-01p401000000.mp4'
1079
+ }
1080
+ ],
1081
+ errorcode: 200
1082
+ });
1083
+ assert.deepEqual(ret, {
1084
+ dir: 'QzpcVmlkZW9ccXExMjM0XDIwMTctMDYtMTlccmVjb3JkXDE=',
1085
+ name: 'qq1234-170619-000000-002000-01p401000000.264'
1086
+ });
1087
+ });
1088
+
1089
+ test('select object empty properties', () => {
1090
+ const data = {
1091
+ code: 0,
1092
+ data: {
1093
+ 'name': 'data111',
1094
+ '/aaa': {
1095
+ name: '123',
1096
+ '/ccc': {
1097
+ name: 'ccc',
1098
+ },
1099
+ },
1100
+ '/sss': {
1101
+ name: '999',
1102
+ },
1103
+ },
1104
+ };
1105
+ const ret = select({
1106
+ type: 'object',
1107
+ properties: {
1108
+ route: ['.data', {
1109
+ type: 'object',
1110
+ properties: {},
1111
+ }],
1112
+ },
1113
+ })(data);
1114
+ assert.deepEqual(
1115
+ {
1116
+ route: data.data,
1117
+ },
1118
+ ret,
1119
+ );
1120
+ });