@wener/common 1.0.2 → 1.0.4
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/lib/cn/DivisionCode.js +311 -0
- package/lib/cn/DivisionCode.js.map +1 -0
- package/lib/cn/Mod11Checksum.js +42 -0
- package/lib/cn/Mod11Checksum.js.map +1 -0
- package/lib/cn/Mod31Checksum.js +48 -0
- package/lib/cn/Mod31Checksum.js.map +1 -0
- package/lib/cn/ResidentIdentityCardNumber.js +50 -0
- package/lib/cn/ResidentIdentityCardNumber.js.map +1 -0
- package/lib/cn/UnifiedSocialCreditCode.js +118 -0
- package/lib/cn/UnifiedSocialCreditCode.js.map +1 -0
- package/lib/cn/formatDate.js +15 -0
- package/lib/cn/formatDate.js.map +1 -0
- package/lib/cn/index.js +4 -0
- package/lib/cn/index.js.map +1 -0
- package/lib/cn/parseSex.js +22 -0
- package/lib/cn/parseSex.js.map +1 -0
- package/lib/cn/types.d.js +8 -0
- package/lib/cn/types.d.js.map +1 -0
- package/lib/data/formatSort.js +15 -0
- package/lib/data/formatSort.js.map +1 -0
- package/lib/data/index.js +4 -0
- package/lib/data/index.js.map +1 -0
- package/lib/data/maybeNumber.js +22 -0
- package/lib/data/maybeNumber.js.map +1 -0
- package/lib/data/parseSort.js +95 -0
- package/lib/data/parseSort.js.map +1 -0
- package/lib/data/resolvePagination.js +36 -0
- package/lib/data/resolvePagination.js.map +1 -0
- package/lib/data/types.d.js +3 -0
- package/lib/data/types.d.js.map +1 -0
- package/lib/index.js +6 -2
- package/lib/index.js.map +1 -1
- package/lib/jsonschema/JsonSchema.js +4 -4
- package/lib/jsonschema/JsonSchema.js.map +1 -1
- package/lib/jsonschema/types.d.js.map +1 -1
- package/lib/meta/defineFileType.js +44 -0
- package/lib/meta/defineFileType.js.map +1 -0
- package/lib/meta/defineInit.js.map +1 -1
- package/lib/meta/defineMetadata.js +14 -3
- package/lib/meta/defineMetadata.js.map +1 -1
- package/lib/meta/index.js +1 -0
- package/lib/meta/index.js.map +1 -1
- package/lib/password/PHC.js +8 -8
- package/lib/password/PHC.js.map +1 -1
- package/lib/password/Password.js.map +1 -1
- package/lib/password/createArgon2PasswordAlgorithm.js.map +1 -1
- package/lib/password/createBase64PasswordAlgorithm.js.map +1 -1
- package/lib/password/createBcryptPasswordAlgorithm.js.map +1 -1
- package/lib/password/createPBKDF2PasswordAlgorithm.js.map +1 -1
- package/lib/password/createScryptPasswordAlgorithm.js.map +1 -1
- package/lib/search/AdvanceSearch.js.map +1 -1
- package/lib/search/formatAdvanceSearch.js +1 -1
- package/lib/search/formatAdvanceSearch.js.map +1 -1
- package/lib/search/optimizeAdvanceSearch.js.map +1 -1
- package/lib/search/parseAdvanceSearch.js.map +1 -1
- package/lib/search/parser.d.js.map +1 -1
- package/lib/search/parser.js +380 -76
- package/lib/search/parser.js.map +1 -1
- package/lib/search/types.d.js.map +1 -1
- package/lib/tools/renderJsonSchemaToMarkdownDoc.js.map +1 -1
- package/package.json +14 -5
- package/src/cn/DivisionCode.test.ts +43 -0
- package/src/cn/DivisionCode.ts +209 -0
- package/src/cn/Mod11Checksum.ts +24 -0
- package/src/cn/Mod31Checksum.ts +36 -0
- package/src/cn/ResidentIdentityCardNumber.test.ts +17 -0
- package/src/cn/ResidentIdentityCardNumber.ts +96 -0
- package/src/cn/UnifiedSocialCreditCode.test.ts +16 -0
- package/src/cn/UnifiedSocialCreditCode.ts +143 -0
- package/src/cn/__snapshots__/ResidentIdentityCardNumber.test.ts.snap +15 -0
- package/src/cn/__snapshots__/UnifiedSocialCreditCode.test.ts.snap +41 -0
- package/src/cn/formatDate.ts +12 -0
- package/src/cn/index.ts +3 -0
- package/src/cn/parseSex.ts +13 -0
- package/src/cn/types.d.ts +51 -0
- package/src/data/formatSort.test.ts +13 -0
- package/src/data/formatSort.ts +18 -0
- package/src/data/index.ts +5 -0
- package/src/data/maybeNumber.ts +23 -0
- package/src/data/parseSort.test.ts +67 -0
- package/src/data/parseSort.ts +108 -0
- package/src/data/resolvePagination.test.ts +58 -0
- package/src/data/resolvePagination.ts +60 -0
- package/src/data/types.d.ts +33 -0
- package/src/index.ts +8 -2
- package/src/jsonschema/JsonSchema.test.ts +13 -22
- package/src/jsonschema/JsonSchema.ts +145 -177
- package/src/jsonschema/types.d.ts +151 -161
- package/src/meta/defineFileType.tsx +68 -0
- package/src/meta/defineInit.ts +32 -53
- package/src/meta/defineMetadata.test.ts +5 -7
- package/src/meta/defineMetadata.ts +35 -40
- package/src/meta/index.ts +2 -0
- package/src/password/PHC.test.ts +186 -277
- package/src/password/PHC.ts +243 -243
- package/src/password/Password.test.ts +38 -50
- package/src/password/Password.ts +73 -95
- package/src/password/createArgon2PasswordAlgorithm.ts +65 -69
- package/src/password/createBase64PasswordAlgorithm.ts +9 -9
- package/src/password/createBcryptPasswordAlgorithm.ts +20 -22
- package/src/password/createPBKDF2PasswordAlgorithm.ts +49 -61
- package/src/password/createScryptPasswordAlgorithm.ts +48 -59
- package/src/search/AdvanceSearch.test.ts +136 -143
- package/src/search/AdvanceSearch.ts +6 -6
- package/src/search/__snapshots__/AdvanceSearch.test.ts.snap +3 -3
- package/src/search/formatAdvanceSearch.ts +44 -53
- package/src/search/optimizeAdvanceSearch.ts +70 -83
- package/src/search/parseAdvanceSearch.ts +16 -19
- package/src/search/parser.d.ts +3 -3
- package/src/search/parser.js +325 -73
- package/src/search/parser.peggy +42 -9
- package/src/search/types.d.ts +28 -54
- package/src/tools/renderJsonSchemaToMarkdownDoc.ts +69 -69
- package/lib/normalizePagination.js +0 -14
- package/lib/normalizePagination.js.map +0 -1
- package/lib/parseSort.js +0 -91
- package/lib/parseSort.js.map +0 -1
- package/src/normalizePagination.ts +0 -25
- package/src/parseSort.test.ts +0 -42
- package/src/parseSort.ts +0 -115
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
const DivisionCodeLevels = [
|
|
2
|
+
{
|
|
3
|
+
level: 1,
|
|
4
|
+
code: 'Province',
|
|
5
|
+
length: 2,
|
|
6
|
+
size: 2,
|
|
7
|
+
label: '省'
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
level: 2,
|
|
11
|
+
code: 'City',
|
|
12
|
+
length: 4,
|
|
13
|
+
size: 2,
|
|
14
|
+
label: '市'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
level: 3,
|
|
18
|
+
code: 'County',
|
|
19
|
+
length: 6,
|
|
20
|
+
size: 2,
|
|
21
|
+
label: '区县'
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
level: 4,
|
|
25
|
+
code: 'Town',
|
|
26
|
+
length: 9,
|
|
27
|
+
size: 3,
|
|
28
|
+
label: '乡镇'
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
level: 5,
|
|
32
|
+
code: 'Village',
|
|
33
|
+
length: 12,
|
|
34
|
+
size: 3,
|
|
35
|
+
label: '村'
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
(function(DivisionCode) {
|
|
39
|
+
let DivisionCodeLevel = /*#__PURE__*/ function(DivisionCodeLevel) {
|
|
40
|
+
DivisionCodeLevel[DivisionCodeLevel["Province"] = 1] = "Province";
|
|
41
|
+
DivisionCodeLevel[DivisionCodeLevel["City"] = 2] = "City";
|
|
42
|
+
DivisionCodeLevel[DivisionCodeLevel["County"] = 3] = "County";
|
|
43
|
+
DivisionCodeLevel[DivisionCodeLevel["Town"] = 4] = "Town";
|
|
44
|
+
DivisionCodeLevel[DivisionCodeLevel["Village"] = 5] = "Village";
|
|
45
|
+
return DivisionCodeLevel;
|
|
46
|
+
}({});
|
|
47
|
+
DivisionCode.levels = DivisionCodeLevels;
|
|
48
|
+
DivisionCode.regex = /^(?<province>\d{2})(?<city>\d{2})?(?<county>\d{2})?(?<town>\d{3})?(?<village>\d{3})?$/;
|
|
49
|
+
const root = [
|
|
50
|
+
{
|
|
51
|
+
value: '11',
|
|
52
|
+
label: '北京市'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
value: '12',
|
|
56
|
+
label: '天津市'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
value: '13',
|
|
60
|
+
label: '河北省'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
value: '14',
|
|
64
|
+
label: '山西省'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
value: '15',
|
|
68
|
+
label: '内蒙古自治区'
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
value: '21',
|
|
72
|
+
label: '辽宁省'
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
value: '22',
|
|
76
|
+
label: '吉林省'
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
value: '23',
|
|
80
|
+
label: '黑龙江省'
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
value: '31',
|
|
84
|
+
label: '上海市'
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
value: '32',
|
|
88
|
+
label: '江苏省'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
value: '33',
|
|
92
|
+
label: '浙江省'
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
value: '34',
|
|
96
|
+
label: '安徽省'
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
value: '35',
|
|
100
|
+
label: '福建省'
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
value: '36',
|
|
104
|
+
label: '江西省'
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
value: '37',
|
|
108
|
+
label: '山东省'
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
value: '41',
|
|
112
|
+
label: '河南省'
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
value: '42',
|
|
116
|
+
label: '湖北省'
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
value: '43',
|
|
120
|
+
label: '湖南省'
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
value: '44',
|
|
124
|
+
label: '广东省'
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
value: '45',
|
|
128
|
+
label: '广西壮族自治区'
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
value: '46',
|
|
132
|
+
label: '海南省'
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
value: '50',
|
|
136
|
+
label: '重庆市'
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
value: '51',
|
|
140
|
+
label: '四川省'
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
value: '52',
|
|
144
|
+
label: '贵州省'
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
value: '53',
|
|
148
|
+
label: '云南省'
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
value: '54',
|
|
152
|
+
label: '西藏自治区'
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
value: '61',
|
|
156
|
+
label: '陕西省'
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
value: '62',
|
|
160
|
+
label: '甘肃省'
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
value: '63',
|
|
164
|
+
label: '青海省'
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
value: '64',
|
|
168
|
+
label: '宁夏回族自治区'
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
value: '65',
|
|
172
|
+
label: '新疆维吾尔自治区'
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
value: '71',
|
|
176
|
+
label: '台湾省'
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
value: '81',
|
|
180
|
+
label: '香港特别行政区'
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
value: '82',
|
|
184
|
+
label: '澳门特别行政区'
|
|
185
|
+
}
|
|
186
|
+
];
|
|
187
|
+
function parse(code) {
|
|
188
|
+
if (!code) return;
|
|
189
|
+
code = String(code);
|
|
190
|
+
const match = DivisionCode.regex.exec(code);
|
|
191
|
+
if (!match) return;
|
|
192
|
+
const { province, city, county, town, village } = match.groups ?? {};
|
|
193
|
+
if (!province) return;
|
|
194
|
+
let codes = [
|
|
195
|
+
province,
|
|
196
|
+
city,
|
|
197
|
+
county,
|
|
198
|
+
town,
|
|
199
|
+
village
|
|
200
|
+
].filter(Boolean);
|
|
201
|
+
return {
|
|
202
|
+
province,
|
|
203
|
+
city,
|
|
204
|
+
county,
|
|
205
|
+
town,
|
|
206
|
+
village,
|
|
207
|
+
codes: codes,
|
|
208
|
+
level: codes.length
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
DivisionCode.parse = parse;
|
|
212
|
+
function format({ province, city, county, town, village }) {
|
|
213
|
+
const codes = [];
|
|
214
|
+
for(let i = 0; i < [
|
|
215
|
+
province,
|
|
216
|
+
city,
|
|
217
|
+
county,
|
|
218
|
+
town,
|
|
219
|
+
village
|
|
220
|
+
].length; i++){
|
|
221
|
+
let x = [
|
|
222
|
+
province,
|
|
223
|
+
city,
|
|
224
|
+
county,
|
|
225
|
+
town,
|
|
226
|
+
village
|
|
227
|
+
][i];
|
|
228
|
+
if (x === undefined || x === null || x === '') {
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
let len = DivisionCode.levels[i].size;
|
|
232
|
+
codes.push(String(x).padStart(len, '0').slice(0, len));
|
|
233
|
+
}
|
|
234
|
+
return codes.join('');
|
|
235
|
+
}
|
|
236
|
+
DivisionCode.format = format;
|
|
237
|
+
// export function random(level: DivisionCodeLevel = 'County'): string {
|
|
238
|
+
// const l = DivisionCodeLevels.find((v) => v.code === level) || DivisionCodeLevels[2];
|
|
239
|
+
// const l1 = randomPick(provinces);
|
|
240
|
+
// if (l.level === 1) {
|
|
241
|
+
// return String(l1[0]);
|
|
242
|
+
// }
|
|
243
|
+
// return l1 + String(Math.floor(Math.random() * parseFloat(`1e${l.length - 2}`) - 1));
|
|
244
|
+
// }
|
|
245
|
+
})(DivisionCode || (DivisionCode = {}));
|
|
246
|
+
// export type DivisionCodeLevel = 'Village' | 'Town' | 'County' | 'City' | 'Province';
|
|
247
|
+
// export interface ParsedDivisionCode {
|
|
248
|
+
// level: DivisionCodeLevel;
|
|
249
|
+
// code: string;
|
|
250
|
+
// name?: string;
|
|
251
|
+
// fullName?: string;
|
|
252
|
+
// names: string[];
|
|
253
|
+
// // 村级(村委会、居委会)
|
|
254
|
+
// // 12 位
|
|
255
|
+
// village?: CodeName;
|
|
256
|
+
// // 乡级(乡镇、街道)
|
|
257
|
+
// // 9 位
|
|
258
|
+
// town?: CodeName;
|
|
259
|
+
// // 县级(区县)
|
|
260
|
+
// // 6 位 - 常用 - 2985 个
|
|
261
|
+
// county?: CodeName;
|
|
262
|
+
// // 地级(城市)
|
|
263
|
+
// // 4 位 - 343 个
|
|
264
|
+
// city?: CodeName;
|
|
265
|
+
// // 省级(省份、直辖市、自治区)
|
|
266
|
+
// // 2 位 - 32 个
|
|
267
|
+
// province: CodeName;
|
|
268
|
+
//
|
|
269
|
+
// children?: Array<{ code: string; name?: string }>;
|
|
270
|
+
// }
|
|
271
|
+
// export interface CodeName {
|
|
272
|
+
// code: string;
|
|
273
|
+
// name: string;
|
|
274
|
+
// }
|
|
275
|
+
// export function getSimpleProvinceLabel(value: string) {
|
|
276
|
+
// if (!value) {
|
|
277
|
+
// return;
|
|
278
|
+
// }
|
|
279
|
+
// let label = value;
|
|
280
|
+
// if (/[0-9]/.test(label)) {
|
|
281
|
+
// label = label.slice(0, 2);
|
|
282
|
+
// label = options.find((v) => v.value === label)?.label || label;
|
|
283
|
+
// }
|
|
284
|
+
// return label.replace(/省|市|(回族|维吾尔|壮族)?自治区|特别行政区$/, '');
|
|
285
|
+
// }
|
|
286
|
+
export function randomPick(s) {
|
|
287
|
+
return s[Math.floor(Math.random() * s.length)];
|
|
288
|
+
}
|
|
289
|
+
function lookup(opts) {
|
|
290
|
+
const { values, root } = opts;
|
|
291
|
+
const found = [];
|
|
292
|
+
let currentLevel = root;
|
|
293
|
+
for (const v of values){
|
|
294
|
+
const node = currentLevel.find((n)=>n.value === v);
|
|
295
|
+
if (!node) {
|
|
296
|
+
break;
|
|
297
|
+
}
|
|
298
|
+
found.push(node);
|
|
299
|
+
if (node.children) {
|
|
300
|
+
currentLevel = node.children;
|
|
301
|
+
} else {
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return {
|
|
306
|
+
found
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
export var DivisionCode;
|
|
310
|
+
|
|
311
|
+
//# sourceMappingURL=DivisionCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cn/DivisionCode.ts"],"sourcesContent":["const DivisionCodeLevels: Array<{ level: number; code: string; length: number; size: number; label: string }> = [\n\t{ level: 1, code: 'Province', length: 2, size: 2, label: '省' },\n\t{ level: 2, code: 'City', length: 4, size: 2, label: '市' },\n\t{ level: 3, code: 'County', length: 6, size: 2, label: '区县' },\n\t{ level: 4, code: 'Town', length: 9, size: 3, label: '乡镇' },\n\t{ level: 5, code: 'Village', length: 12, size: 3, label: '村' },\n] as const;\n\n// String(Number.MAX_SAFE_INTEGER).length=16\n// 12 is safe int\n\n/**\n * Codes for the administrative divisions of the People's Republic of China\n *\n * @see https://zh.wikipedia.org/wiki/GB/T_2260 中华人民共和国行政区划代码\n */\nexport namespace DivisionCode {\n\tenum DivisionCodeLevel {\n\t\tProvince = 1,\n\t\tCity = 2,\n\t\tCounty = 3,\n\t\tTown = 4,\n\t\tVillage = 5,\n\t}\n\n\texport const levels = DivisionCodeLevels;\n\n\texport const regex = /^(?<province>\\d{2})(?<city>\\d{2})?(?<county>\\d{2})?(?<town>\\d{3})?(?<village>\\d{3})?$/;\n\n\tconst root: CodeValue[] = [\n\t\t{ value: '11', label: '北京市' },\n\t\t{ value: '12', label: '天津市' },\n\t\t{ value: '13', label: '河北省' },\n\t\t{ value: '14', label: '山西省' },\n\t\t{ value: '15', label: '内蒙古自治区' },\n\t\t{ value: '21', label: '辽宁省' },\n\t\t{ value: '22', label: '吉林省' },\n\t\t{ value: '23', label: '黑龙江省' },\n\t\t{ value: '31', label: '上海市' },\n\t\t{ value: '32', label: '江苏省' },\n\t\t{ value: '33', label: '浙江省' },\n\t\t{ value: '34', label: '安徽省' },\n\t\t{ value: '35', label: '福建省' },\n\t\t{ value: '36', label: '江西省' },\n\t\t{ value: '37', label: '山东省' },\n\t\t{ value: '41', label: '河南省' },\n\t\t{ value: '42', label: '湖北省' },\n\t\t{ value: '43', label: '湖南省' },\n\t\t{ value: '44', label: '广东省' },\n\t\t{ value: '45', label: '广西壮族自治区' },\n\t\t{ value: '46', label: '海南省' },\n\t\t{ value: '50', label: '重庆市' },\n\t\t{ value: '51', label: '四川省' },\n\t\t{ value: '52', label: '贵州省' },\n\t\t{ value: '53', label: '云南省' },\n\t\t{ value: '54', label: '西藏自治区' },\n\t\t{ value: '61', label: '陕西省' },\n\t\t{ value: '62', label: '甘肃省' },\n\t\t{ value: '63', label: '青海省' },\n\t\t{ value: '64', label: '宁夏回族自治区' },\n\t\t{ value: '65', label: '新疆维吾尔自治区' },\n\t\t{ value: '71', label: '台湾省' },\n\t\t{ value: '81', label: '香港特别行政区' },\n\t\t{ value: '82', label: '澳门特别行政区' },\n\t\t// 9 国外\n\t];\n\n\texport type ParsedCode = {\n\t\tprovince: string;\n\t\tcity?: string;\n\t\tcounty?: string;\n\t\ttown?: string;\n\t\tvillage?: string;\n\t\tcodes: string[];\n\t\tlevel: DivisionCodeLevel;\n\t\tlabels: string[];\n\t};\n\n\texport function parse(code: string | undefined | null | number): ParsedCode | undefined {\n\t\tif (!code) return;\n\t\tcode = String(code);\n\t\tconst match = regex.exec(code);\n\t\tif (!match) return;\n\t\tconst { province, city, county, town, village } = match.groups ?? {};\n\t\tif (!province) return;\n\n\t\tlet codes = [province, city, county, town, village].filter(Boolean);\n\t\treturn { province, city, county, town, village, codes: codes, level: codes.length as DivisionCodeLevel };\n\t}\n\n\texport function format({\n\t\tprovince,\n\t\tcity,\n\t\tcounty,\n\t\ttown,\n\t\tvillage,\n\t}: {\n\t\tprovince: string | number;\n\t\tcity?: string | number;\n\t\tcounty?: string | number;\n\t\ttown?: string | number;\n\t\tvillage?: string | number;\n\t}): string {\n\t\tconst codes: string[] = [];\n\t\tfor (let i = 0; i < [province, city, county, town, village].length; i++) {\n\t\t\tlet x = [province, city, county, town, village][i];\n\t\t\tif (x === undefined || x === null || x === '') {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tlet len = levels[i].size;\n\t\t\tcodes.push(String(x).padStart(len, '0').slice(0, len));\n\t\t}\n\t\treturn codes.join('');\n\t}\n\n\t// export function random(level: DivisionCodeLevel = 'County'): string {\n\t// const l = DivisionCodeLevels.find((v) => v.code === level) || DivisionCodeLevels[2];\n\t// const l1 = randomPick(provinces);\n\t// if (l.level === 1) {\n\t// return String(l1[0]);\n\t// }\n\t// return l1 + String(Math.floor(Math.random() * parseFloat(`1e${l.length - 2}`) - 1));\n\t// }\n}\n\ninterface DivisionTreeNode {\n\tsub: string; // sub code\n\tchildren?: Record<string, DivisionTreeNode>;\n\n\tcode: string; // full code\n\tname?: string; // name of division\n}\n\n// export type DivisionCodeLevel = 'Village' | 'Town' | 'County' | 'City' | 'Province';\n\n// export interface ParsedDivisionCode {\n// level: DivisionCodeLevel;\n// code: string;\n// name?: string;\n// fullName?: string;\n// names: string[];\n// // 村级(村委会、居委会)\n// // 12 位\n// village?: CodeName;\n// // 乡级(乡镇、街道)\n// // 9 位\n// town?: CodeName;\n// // 县级(区县)\n// // 6 位 - 常用 - 2985 个\n// county?: CodeName;\n// // 地级(城市)\n// // 4 位 - 343 个\n// city?: CodeName;\n// // 省级(省份、直辖市、自治区)\n// // 2 位 - 32 个\n// province: CodeName;\n//\n// children?: Array<{ code: string; name?: string }>;\n// }\n\n// export interface CodeName {\n// code: string;\n// name: string;\n// }\n\n// export function getSimpleProvinceLabel(value: string) {\n// if (!value) {\n// return;\n// }\n// let label = value;\n// if (/[0-9]/.test(label)) {\n// label = label.slice(0, 2);\n// label = options.find((v) => v.value === label)?.label || label;\n// }\n// return label.replace(/省|市|(回族|维吾尔|壮族)?自治区|特别行政区$/, '');\n// }\n\nexport function randomPick<T>(s: T[]) {\n\treturn s[Math.floor(Math.random() * s.length)];\n}\n\nfunction lookup(opts: { values: string[]; root: CodeValue[] }): { found: CodeValue[] } {\n\tconst { values, root } = opts;\n\tconst found: CodeValue[] = [];\n\tlet currentLevel = root;\n\n\tfor (const v of values) {\n\t\tconst node = currentLevel.find((n) => n.value === v);\n\t\tif (!node) {\n\t\t\tbreak;\n\t\t}\n\n\t\tfound.push(node);\n\n\t\tif (node.children) {\n\t\t\tcurrentLevel = node.children;\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn { found };\n}\n\ninterface CodeValue {\n\tvalue: string;\n\tlabel: string;\n\tchildren?: Array<CodeValue>;\n}\n"],"names":["DivisionCodeLevels","level","code","length","size","label","DivisionCode","DivisionCodeLevel","levels","regex","root","value","parse","String","match","exec","province","city","county","town","village","groups","codes","filter","Boolean","format","i","x","undefined","len","push","padStart","slice","join","randomPick","s","Math","floor","random","lookup","opts","values","found","currentLevel","v","node","find","n","children"],"mappings":"AAAA,MAAMA,qBAA0G;IAC/G;QAAEC,OAAO;QAAGC,MAAM;QAAYC,QAAQ;QAAGC,MAAM;QAAGC,OAAO;IAAI;IAC7D;QAAEJ,OAAO;QAAGC,MAAM;QAAQC,QAAQ;QAAGC,MAAM;QAAGC,OAAO;IAAI;IACzD;QAAEJ,OAAO;QAAGC,MAAM;QAAUC,QAAQ;QAAGC,MAAM;QAAGC,OAAO;IAAK;IAC5D;QAAEJ,OAAO;QAAGC,MAAM;QAAQC,QAAQ;QAAGC,MAAM;QAAGC,OAAO;IAAK;IAC1D;QAAEJ,OAAO;QAAGC,MAAM;QAAWC,QAAQ;QAAIC,MAAM;QAAGC,OAAO;IAAI;CAC7D;UAUgBC;IAChB,IAAA,AAAKC,2CAAAA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EA,OAAO;QAAEN;IAAM;AAChB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ISO 7064:1983, MOD 11-2.
|
|
3
|
+
*/ export class Mod11Checksum {
|
|
4
|
+
weights = [
|
|
5
|
+
7,
|
|
6
|
+
9,
|
|
7
|
+
10,
|
|
8
|
+
5,
|
|
9
|
+
8,
|
|
10
|
+
4,
|
|
11
|
+
2,
|
|
12
|
+
1,
|
|
13
|
+
6,
|
|
14
|
+
3,
|
|
15
|
+
7,
|
|
16
|
+
9,
|
|
17
|
+
10,
|
|
18
|
+
5,
|
|
19
|
+
8,
|
|
20
|
+
4,
|
|
21
|
+
2,
|
|
22
|
+
1
|
|
23
|
+
];
|
|
24
|
+
validate(s) {
|
|
25
|
+
return s.at(-1) === this.compute(s.slice(0, s.length - 1));
|
|
26
|
+
}
|
|
27
|
+
compute(s) {
|
|
28
|
+
const { weights } = this;
|
|
29
|
+
let sum = 0;
|
|
30
|
+
for(let i = 0; i < s.length; i++){
|
|
31
|
+
sum += parseInt(s[i]) * weights[i];
|
|
32
|
+
}
|
|
33
|
+
const num = (12 - sum % 11) % 11;
|
|
34
|
+
if (num < 10) {
|
|
35
|
+
return num.toString();
|
|
36
|
+
} else {
|
|
37
|
+
return 'X';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=Mod11Checksum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cn/Mod11Checksum.ts"],"sourcesContent":["/**\n * ISO 7064:1983, MOD 11-2.\n */\nexport class Mod11Checksum {\n\tweights = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1];\n\n\tvalidate(s: string) {\n\t\treturn s.at(-1) === this.compute(s.slice(0, s.length - 1));\n\t}\n\n\tcompute(s: string) {\n\t\tconst { weights } = this;\n\t\tlet sum = 0;\n\t\tfor (let i = 0; i < s.length; i++) {\n\t\t\tsum += parseInt(s[i]) * weights[i];\n\t\t}\n\t\tconst num = (12 - (sum % 11)) % 11;\n\t\tif (num < 10) {\n\t\t\treturn num.toString();\n\t\t} else {\n\t\t\treturn 'X';\n\t\t}\n\t}\n}\n"],"names":["Mod11Checksum","weights","validate","s","at","compute","slice","length","sum","i","parseInt","num","toString"],"mappings":"AAAA;;CAEC,GACD,OAAO,MAAMA;IACZC,UAAU;QAAC;QAAG;QAAG;QAAI;QAAG;QAAG;QAAG;QAAG;QAAG;QAAG;QAAG;QAAG;QAAG;QAAI;QAAG;QAAG;QAAG;QAAG;KAAE,CAAC;IAEnEC,SAASC,CAAS,EAAE;QACnB,OAAOA,EAAEC,EAAE,CAAC,CAAC,OAAO,IAAI,CAACC,OAAO,CAACF,EAAEG,KAAK,CAAC,GAAGH,EAAEI,MAAM,GAAG;IACxD;IAEAF,QAAQF,CAAS,EAAE;QAClB,MAAM,EAAEF,OAAO,EAAE,GAAG,IAAI;QACxB,IAAIO,MAAM;QACV,IAAK,IAAIC,IAAI,GAAGA,IAAIN,EAAEI,MAAM,EAAEE,IAAK;YAClCD,OAAOE,SAASP,CAAC,CAACM,EAAE,IAAIR,OAAO,CAACQ,EAAE;QACnC;QACA,MAAME,MAAM,AAAC,CAAA,KAAMH,MAAM,EAAE,IAAK;QAChC,IAAIG,MAAM,IAAI;YACb,OAAOA,IAAIC,QAAQ;QACpB,OAAO;YACN,OAAO;QACR;IACD;AACD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GB/T 17710(采ISO 7064)的模31校验码
|
|
3
|
+
*
|
|
4
|
+
* Mod31-3
|
|
5
|
+
*/ export class Mod31Checksum {
|
|
6
|
+
weights = [
|
|
7
|
+
1,
|
|
8
|
+
3,
|
|
9
|
+
9,
|
|
10
|
+
27,
|
|
11
|
+
19,
|
|
12
|
+
26,
|
|
13
|
+
16,
|
|
14
|
+
17,
|
|
15
|
+
20,
|
|
16
|
+
29,
|
|
17
|
+
25,
|
|
18
|
+
13,
|
|
19
|
+
8,
|
|
20
|
+
24,
|
|
21
|
+
10,
|
|
22
|
+
30,
|
|
23
|
+
28
|
|
24
|
+
];
|
|
25
|
+
chars = '0123456789ABCDEFGHJKLMNPQRTUWXY';
|
|
26
|
+
numbers = this.chars.split('').reduce((acc, cur, i)=>{
|
|
27
|
+
acc[cur] = i;
|
|
28
|
+
return acc;
|
|
29
|
+
}, {});
|
|
30
|
+
toChar(n) {
|
|
31
|
+
return this.chars[n];
|
|
32
|
+
}
|
|
33
|
+
toNumber(c) {
|
|
34
|
+
return this.numbers[c];
|
|
35
|
+
}
|
|
36
|
+
validate(s) {
|
|
37
|
+
return s.at(-1) === this.compute(s.slice(0, s.length - 1));
|
|
38
|
+
}
|
|
39
|
+
compute(s) {
|
|
40
|
+
let sum = 0;
|
|
41
|
+
for(let i = 0; i < s.length; i++){
|
|
42
|
+
sum += this.numbers[s[i]] * this.weights[i];
|
|
43
|
+
}
|
|
44
|
+
return this.toChar(31 - sum % 31);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=Mod31Checksum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cn/Mod31Checksum.ts"],"sourcesContent":["/**\n * GB/T 17710(采ISO 7064)的模31校验码\n *\n * Mod31-3\n */\nexport class Mod31Checksum {\n\tweights = [1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28];\n\tchars = '0123456789ABCDEFGHJKLMNPQRTUWXY';\n\tnumbers: Record<string, number> = this.chars.split('').reduce(\n\t\t(acc, cur, i) => {\n\t\t\tacc[cur] = i;\n\t\t\treturn acc;\n\t\t},\n\t\t{} as Record<string, number>,\n\t);\n\n\ttoChar(n: number) {\n\t\treturn this.chars[n];\n\t}\n\n\ttoNumber(c: string) {\n\t\treturn this.numbers[c];\n\t}\n\n\tvalidate(s: string) {\n\t\treturn s.at(-1) === this.compute(s.slice(0, s.length - 1));\n\t}\n\n\tcompute(s: string) {\n\t\tlet sum = 0;\n\t\tfor (let i = 0; i < s.length; i++) {\n\t\t\tsum += this.numbers[s[i]] * this.weights[i];\n\t\t}\n\t\treturn this.toChar(31 - (sum % 31));\n\t}\n}\n"],"names":["Mod31Checksum","weights","chars","numbers","split","reduce","acc","cur","i","toChar","n","toNumber","c","validate","s","at","compute","slice","length","sum"],"mappings":"AAAA;;;;CAIC,GACD,OAAO,MAAMA;IACZC,UAAU;QAAC;QAAG;QAAG;QAAG;QAAI;QAAI;QAAI;QAAI;QAAI;QAAI;QAAI;QAAI;QAAI;QAAG;QAAI;QAAI;QAAI;KAAG,CAAC;IAC3EC,QAAQ,kCAAkC;IAC1CC,UAAkC,IAAI,CAACD,KAAK,CAACE,KAAK,CAAC,IAAIC,MAAM,CAC5D,CAACC,KAAKC,KAAKC;QACVF,GAAG,CAACC,IAAI,GAAGC;QACX,OAAOF;IACR,GACA,CAAC,GACA;IAEFG,OAAOC,CAAS,EAAE;QACjB,OAAO,IAAI,CAACR,KAAK,CAACQ,EAAE;IACrB;IAEAC,SAASC,CAAS,EAAE;QACnB,OAAO,IAAI,CAACT,OAAO,CAACS,EAAE;IACvB;IAEAC,SAASC,CAAS,EAAE;QACnB,OAAOA,EAAEC,EAAE,CAAC,CAAC,OAAO,IAAI,CAACC,OAAO,CAACF,EAAEG,KAAK,CAAC,GAAGH,EAAEI,MAAM,GAAG;IACxD;IAEAF,QAAQF,CAAS,EAAE;QAClB,IAAIK,MAAM;QACV,IAAK,IAAIX,IAAI,GAAGA,IAAIM,EAAEI,MAAM,EAAEV,IAAK;YAClCW,OAAO,IAAI,CAAChB,OAAO,CAACW,CAAC,CAACN,EAAE,CAAC,GAAG,IAAI,CAACP,OAAO,CAACO,EAAE;QAC5C;QACA,OAAO,IAAI,CAACC,MAAM,CAAC,KAAMU,MAAM;IAChC;AACD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { formatDate } from "./formatDate.js";
|
|
2
|
+
import { Mod11Checksum } from "./Mod11Checksum.js";
|
|
3
|
+
(function (ResidentIdentityCardNumber) {
|
|
4
|
+
ResidentIdentityCardNumber.Checksum = new Mod11Checksum();
|
|
5
|
+
function parse(s) {
|
|
6
|
+
const division = s.slice(0, 6);
|
|
7
|
+
const birthDate = s.slice(6, 14);
|
|
8
|
+
const sequence = parseInt(s.slice(14, 17), 10);
|
|
9
|
+
const checksum = s.slice(17, 18);
|
|
10
|
+
const valid = ResidentIdentityCardNumber.Checksum.validate(s);
|
|
11
|
+
const sex = sequence % 2 === 1 ? "Male" : "Female";
|
|
12
|
+
return {
|
|
13
|
+
division,
|
|
14
|
+
birthDate,
|
|
15
|
+
sequence,
|
|
16
|
+
checksum,
|
|
17
|
+
valid,
|
|
18
|
+
sex,
|
|
19
|
+
male: sex === "Male",
|
|
20
|
+
female: sex === "Female",
|
|
21
|
+
age: new Date().getFullYear() - parseInt(birthDate.slice(0, 4), 10)
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/*
|
|
25
|
+
export const length = 18;
|
|
26
|
+
export const pattern = /^\d{6}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[0-9Xx]$/;
|
|
27
|
+
*/ ResidentIdentityCardNumber.parse = parse;
|
|
28
|
+
function format({ division, birthDate, sequence, checksum }) {
|
|
29
|
+
if (typeof birthDate !== "string") {
|
|
30
|
+
birthDate = formatDate(birthDate, "yyyyMMDD");
|
|
31
|
+
}
|
|
32
|
+
if (birthDate.includes("-")) {
|
|
33
|
+
birthDate = birthDate.replace(/-/g, "");
|
|
34
|
+
}
|
|
35
|
+
typeof sequence === "number" && (sequence = sequence.toString());
|
|
36
|
+
sequence = sequence.padStart(3, "0");
|
|
37
|
+
const base = [
|
|
38
|
+
division,
|
|
39
|
+
birthDate,
|
|
40
|
+
sequence
|
|
41
|
+
].join("");
|
|
42
|
+
if (base.length !== 17)
|
|
43
|
+
throw new Error("Invalid params");
|
|
44
|
+
checksum ||= ResidentIdentityCardNumber.Checksum.compute(base);
|
|
45
|
+
return base + checksum;
|
|
46
|
+
}
|
|
47
|
+
ResidentIdentityCardNumber.format = format;
|
|
48
|
+
})(ResidentIdentityCardNumber || (ResidentIdentityCardNumber = {}));
|
|
49
|
+
export var ResidentIdentityCardNumber;
|
|
50
|
+
//# sourceMappingURL=ResidentIdentityCardNumber.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cn/ResidentIdentityCardNumber.ts"],"sourcesContent":["import { formatDate } from './formatDate';\nimport { Mod11Checksum } from './Mod11Checksum';\n\nexport namespace ResidentIdentityCardNumber {\n\texport const Checksum = new Mod11Checksum();\n\n\t/*\n export const length = 18;\n export const pattern = /^\\d{6}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}[0-9Xx]$/;\n */\n\n\texport function parse(s: string): ParsedResidentIdentityCardNumber {\n\t\tconst division = s.slice(0, 6);\n\t\tconst birthDate = s.slice(6, 14);\n\t\tconst sequence = parseInt(s.slice(14, 17), 10);\n\t\tconst checksum = s.slice(17, 18);\n\t\tconst valid = Checksum.validate(s);\n\t\tconst sex = sequence % 2 === 1 ? 'Male' : 'Female';\n\t\treturn {\n\t\t\tdivision,\n\t\t\tbirthDate,\n\t\t\tsequence,\n\t\t\tchecksum,\n\t\t\tvalid,\n\t\t\tsex,\n\t\t\tmale: sex === 'Male',\n\t\t\tfemale: sex === 'Female',\n\t\t\tage: new Date().getFullYear() - parseInt(birthDate.slice(0, 4), 10),\n\t\t};\n\t}\n\n\texport function format({\n\t\tdivision,\n\t\tbirthDate,\n\t\tsequence,\n\t\tchecksum,\n\t}: {\n\t\tdivision: string;\n\t\tbirthDate: string | Date;\n\t\tsequence: number | string;\n\t\tchecksum?: string;\n\t}) {\n\t\tif (typeof birthDate !== 'string') {\n\t\t\tbirthDate = formatDate(birthDate, 'yyyyMMDD');\n\t\t}\n\t\tif (birthDate.includes('-')) {\n\t\t\tbirthDate = birthDate.replace(/-/g, '');\n\t\t}\n\t\ttypeof sequence === 'number' && (sequence = sequence.toString());\n\t\tsequence = sequence.padStart(3, '0');\n\t\tconst base = [division, birthDate, sequence].join('');\n\t\tif (base.length !== 17) throw new Error('Invalid params');\n\t\tchecksum ||= Checksum.compute(base);\n\t\treturn base + checksum;\n\t}\n}\nexport interface ParsedResidentIdentityCardNumber {\n\t/**\n\t * @title 行政区划代码\n\t */\n\tdivision: string;\n\t/**\n\t * @title 出生日期\n\t * 格式 yyyyMMDD\n\t */\n\tbirthDate: string;\n\t/**\n\t * @title 顺序码\n\t */\n\tsequence: number;\n\t/**\n\t * @title 校验位\n\t */\n\tchecksum: string;\n\n\t/**\n\t * @title 是否有效\n\t */\n\tvalid: boolean;\n\t/**\n\t * @title 是否男性\n\t */\n\tmale: boolean;\n\t/**\n\t * @title 是否女性\n\t */\n\tfemale: boolean;\n\t/**\n\t * @title 性别\n\t */\n\tsex: 'Male' | 'Female';\n\t/**\n\t * @title 年龄\n\t */\n\tage: number;\n}\n"],"names":["formatDate","Mod11Checksum","ResidentIdentityCardNumber","Checksum","parse","s","division","slice","birthDate","sequence","parseInt","checksum","valid","validate","sex","male","female","age","Date","getFullYear","format","includes","replace","toString","padStart","base","join","length","Error","compute"],"mappings":"AAAA,SAASA,UAAU,QAAQ,eAAe;AAC1C,SAASC,aAAa,QAAQ,kBAAkB;UAE/BC;+BACHC,WAAW,IAAIF;IAOrB,SAASG,MAAMC,CAAS;QAC9B,MAAMC,WAAWD,EAAEE,KAAK,CAAC,GAAG;QAC5B,MAAMC,YAAYH,EAAEE,KAAK,CAAC,GAAG;QAC7B,MAAME,WAAWC,SAASL,EAAEE,KAAK,CAAC,IAAI,KAAK;QAC3C,MAAMI,WAAWN,EAAEE,KAAK,CAAC,IAAI;QAC7B,MAAMK,QAAQT,2BAAAA,SAASU,QAAQ,CAACR;QAChC,MAAMS,MAAML,WAAW,MAAM,IAAI,SAAS;QAC1C,OAAO;YACNH;YACAE;YACAC;YACAE;YACAC;YACAE;YACAC,MAAMD,QAAQ;YACdE,QAAQF,QAAQ;YAChBG,KAAK,IAAIC,OAAOC,WAAW,KAAKT,SAASF,UAAUD,KAAK,CAAC,GAAG,IAAI;QACjE;IACD;IAvBA;;;GAGE,8BAEcH,QAAAA;IAoBT,SAASgB,OAAO,EACtBd,QAAQ,EACRE,SAAS,EACTC,QAAQ,EACRE,QAAQ,EAMR;QACA,IAAI,OAAOH,cAAc,UAAU;YAClCA,YAAYR,WAAWQ,WAAW;QACnC;QACA,IAAIA,UAAUa,QAAQ,CAAC,MAAM;YAC5Bb,YAAYA,UAAUc,OAAO,CAAC,MAAM;QACrC;QACA,OAAOb,aAAa,YAAaA,CAAAA,WAAWA,SAASc,QAAQ,EAAC;QAC9Dd,WAAWA,SAASe,QAAQ,CAAC,GAAG;QAChC,MAAMC,OAAO;YAACnB;YAAUE;YAAWC;SAAS,CAACiB,IAAI,CAAC;QAClD,IAAID,KAAKE,MAAM,KAAK,IAAI,MAAM,IAAIC,MAAM;QACxCjB,aAAaR,2BAAAA,SAAS0B,OAAO,CAACJ;QAC9B,OAAOA,OAAOd;IACf;+BAvBgBS,SAAAA;AAwBjB,GApDiBlB,+BAAAA"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Mod31Checksum } from "./Mod31Checksum.js";
|
|
2
|
+
(function (UnifiedSocialCreditCode) {
|
|
3
|
+
const CodeLabels = {
|
|
4
|
+
1: {
|
|
5
|
+
label: "\u673A\u6784\u7F16\u5236",
|
|
6
|
+
children: {
|
|
7
|
+
1: {
|
|
8
|
+
label: "\u673A\u5173"
|
|
9
|
+
},
|
|
10
|
+
2: {
|
|
11
|
+
label: "\u4E8B\u4E1A\u5355\u4F4D"
|
|
12
|
+
},
|
|
13
|
+
3: {
|
|
14
|
+
label: "\u4E2D\u592E\u7F16\u529E\u76F4\u63A5\u7BA1\u7406\u673A\u6784\u7F16\u5236\u7684\u7FA4\u4F17\u56E2\u4F53"
|
|
15
|
+
},
|
|
16
|
+
9: {
|
|
17
|
+
label: "\u5176\u4ED6"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
5: {
|
|
22
|
+
label: "\u6C11\u653F",
|
|
23
|
+
children: {
|
|
24
|
+
1: {
|
|
25
|
+
label: "\u793E\u4F1A\u56E2\u4F53"
|
|
26
|
+
},
|
|
27
|
+
2: {
|
|
28
|
+
label: "\u6C11\u529E\u975E\u4F01\u4E1A\u5355\u4F4D"
|
|
29
|
+
},
|
|
30
|
+
3: {
|
|
31
|
+
label: "\u57FA\u91D1\u4F1A"
|
|
32
|
+
},
|
|
33
|
+
9: {
|
|
34
|
+
label: "\u5176\u4ED6"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
9: {
|
|
39
|
+
label: "\u5DE5\u5546",
|
|
40
|
+
children: {
|
|
41
|
+
1: {
|
|
42
|
+
label: "\u4F01\u4E1A"
|
|
43
|
+
},
|
|
44
|
+
2: {
|
|
45
|
+
label: "\u4E2A\u4F53\u5DE5\u5546\u6237"
|
|
46
|
+
},
|
|
47
|
+
3: {
|
|
48
|
+
label: "\u519C\u6C11\u4E13\u4E1A\u5408\u4F5C\u793E"
|
|
49
|
+
},
|
|
50
|
+
9: {
|
|
51
|
+
label: "\u5176\u4ED6"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
Y: {
|
|
56
|
+
label: "\u5176\u4ED6",
|
|
57
|
+
children: {
|
|
58
|
+
1: {
|
|
59
|
+
label: "\u5176\u4ED6"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
UnifiedSocialCreditCode.pattern = /^([159][1239]|Y1)[0-9]{6}[0-9A-HJ-NP-RTUWXY]{10}$/; // 无 I O Z S V
|
|
65
|
+
UnifiedSocialCreditCode.Checksum = new Mod31Checksum();
|
|
66
|
+
function parse(s) {
|
|
67
|
+
let bureau = s[0];
|
|
68
|
+
let subjectType = s[1];
|
|
69
|
+
let division = s.slice(2, 8); // 第3~8位,共6位,正确
|
|
70
|
+
let subject = s.slice(8, 17); // 第9~17位,共9位
|
|
71
|
+
let checksum = s.slice(17, 18); // 第18位,校验码
|
|
72
|
+
const labels = [];
|
|
73
|
+
let l1 = CodeLabels[bureau];
|
|
74
|
+
l1 && labels.push(l1?.label);
|
|
75
|
+
let l2 = l1?.children?.[subjectType];
|
|
76
|
+
l2 && labels.push(l2?.label);
|
|
77
|
+
return {
|
|
78
|
+
bureau,
|
|
79
|
+
subjectType,
|
|
80
|
+
division,
|
|
81
|
+
subject,
|
|
82
|
+
checksum,
|
|
83
|
+
codes: [
|
|
84
|
+
bureau,
|
|
85
|
+
subjectType,
|
|
86
|
+
division,
|
|
87
|
+
subject
|
|
88
|
+
],
|
|
89
|
+
labels
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
UnifiedSocialCreditCode.parse = parse;
|
|
93
|
+
function format({ bureau, subjectType, division, subject, checksum }) {
|
|
94
|
+
const base = `${bureau}${subjectType}${division}${subject}`;
|
|
95
|
+
checksum ||= UnifiedSocialCreditCode.Checksum.compute(base);
|
|
96
|
+
return `${base}${checksum}`;
|
|
97
|
+
}
|
|
98
|
+
UnifiedSocialCreditCode.format = format;
|
|
99
|
+
function next(s, delta = 1) {
|
|
100
|
+
const sp = s.split("").map((v) => UnifiedSocialCreditCode.Checksum.numbers[v]);
|
|
101
|
+
for (let i = sp.length - 1; i >= 0; i--) {
|
|
102
|
+
if (delta > 0 && sp[i] < 30 || delta < 0 && sp[i] > 0) {
|
|
103
|
+
sp[i] += delta;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
else if (delta > 0 && sp[i] === 30) {
|
|
107
|
+
sp[i] = 0;
|
|
108
|
+
}
|
|
109
|
+
else if (delta < 0 && sp[i] === 0) {
|
|
110
|
+
sp[i] = 30;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return sp.map((v) => UnifiedSocialCreditCode.Checksum.chars[v]).join("");
|
|
114
|
+
}
|
|
115
|
+
UnifiedSocialCreditCode.next = next;
|
|
116
|
+
})(UnifiedSocialCreditCode || (UnifiedSocialCreditCode = {}));
|
|
117
|
+
export var UnifiedSocialCreditCode;
|
|
118
|
+
//# sourceMappingURL=UnifiedSocialCreditCode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cn/UnifiedSocialCreditCode.ts"],"sourcesContent":["import { Mod31Checksum } from './Mod31Checksum';\n\n/**\n * 统一社会信用代码\n *\n * - GB 11714-1997 全国组织机构代码编制规则\n */\nexport namespace UnifiedSocialCreditCode {\n\tinterface CodeValue {\n\t\tlabel: string;\n\t\tchildren?: Record<string, CodeValue>;\n\t}\n\n\tconst CodeLabels: Record<string, CodeValue> = {\n\t\t1: {\n\t\t\tlabel: '机构编制',\n\t\t\tchildren: {\n\t\t\t\t1: { label: '机关' },\n\t\t\t\t2: { label: '事业单位' },\n\t\t\t\t3: { label: '中央编办直接管理机构编制的群众团体' },\n\t\t\t\t9: { label: '其他' },\n\t\t\t},\n\t\t},\n\t\t5: {\n\t\t\tlabel: '民政',\n\t\t\tchildren: {\n\t\t\t\t1: { label: '社会团体' },\n\t\t\t\t2: { label: '民办非企业单位' },\n\t\t\t\t3: { label: '基金会' },\n\t\t\t\t9: { label: '其他' },\n\t\t\t},\n\t\t},\n\t\t9: {\n\t\t\tlabel: '工商',\n\t\t\tchildren: {\n\t\t\t\t1: { label: '企业' },\n\t\t\t\t2: { label: '个体工商户' },\n\t\t\t\t3: { label: '农民专业合作社' },\n\t\t\t\t9: { label: '其他' },\n\t\t\t},\n\t\t},\n\t\tY: { label: '其他', children: { 1: { label: '其他' } } },\n\t};\n\n\texport const pattern = /^([159][1239]|Y1)[0-9]{6}[0-9A-HJ-NP-RTUWXY]{10}$/; // 无 I O Z S V\n\n\texport const Checksum = new Mod31Checksum();\n\n\texport function parse(s: string): ParsedUnifiedSocialCreditCode {\n\t\tlet bureau = s[0];\n\t\tlet subjectType = s[1];\n\t\tlet division = s.slice(2, 8); // 第3~8位,共6位,正确\n\t\tlet subject = s.slice(8, 17); // 第9~17位,共9位\n\t\tlet checksum = s.slice(17, 18); // 第18位,校验码\n\n\t\tconst labels: string[] = [];\n\t\tlet l1 = CodeLabels[bureau];\n\t\tl1 && labels.push(l1?.label);\n\t\tlet l2 = l1?.children?.[subjectType];\n\t\tl2 && labels.push(l2?.label);\n\n\t\treturn {\n\t\t\tbureau,\n\t\t\tsubjectType,\n\t\t\tdivision,\n\t\t\tsubject,\n\t\t\tchecksum,\n\t\t\tcodes: [bureau, subjectType, division, subject],\n\t\t\tlabels,\n\t\t};\n\t}\n\n\texport function format({\n\t\tbureau,\n\t\tsubjectType,\n\t\tdivision,\n\t\tsubject,\n\t\tchecksum,\n\t}: {\n\t\tbureau: string;\n\t\tsubjectType: string;\n\t\tdivision: string;\n\t\tsubject: string;\n\t\tchecksum?: string;\n\t}): string {\n\t\tconst base = `${bureau}${subjectType}${division}${subject}`;\n\t\tchecksum ||= Checksum.compute(base);\n\t\treturn `${base}${checksum}`;\n\t}\n\n\texport function next(s: string, delta: number = 1) {\n\t\tconst sp = s.split('').map((v) => Checksum.numbers[v]);\n\t\tfor (let i = sp.length - 1; i >= 0; i--) {\n\t\t\tif ((delta > 0 && sp[i] < 30) || (delta < 0 && sp[i] > 0)) {\n\t\t\t\tsp[i] += delta;\n\t\t\t\tbreak;\n\t\t\t} else if (delta > 0 && sp[i] === 30) {\n\t\t\t\tsp[i] = 0;\n\t\t\t} else if (delta < 0 && sp[i] === 0) {\n\t\t\t\tsp[i] = 30;\n\t\t\t}\n\t\t}\n\t\treturn sp.map((v) => Checksum.chars[v]).join('');\n\t}\n}\n\n/**\n * 解析后的统一社会信用代码信息\n */\ninterface ParsedUnifiedSocialCreditCode {\n\t/**\n\t * @title 登记管理部门代码\n\t * 对应统一社会信用代码的第1位字符,用于标识发证机构类别(登记管理部门)。\n\t */\n\tbureau: string;\n\n\t/**\n\t * @title 机构类别代码\n\t * 对应统一社会信用代码的第2位字符,用于标识被赋码主体的类型(如企业、事业单位、社会组织等)。\n\t */\n\tsubjectType: string;\n\n\t/**\n\t * @title 登记管理机关行政区划代码\n\t * 对应统一社会信用代码的第3至第8位字符,用于标识该主体登记机关所在的行政区划。\n\t */\n\tdivision: string;\n\n\t/**\n\t * @title 主体标识码\n\t * 对应统一社会信用代码的第9至第17位字符,用于标识特定的市场主体或法人单位。\n\t */\n\tsubject: string;\n\n\t/**\n\t * @title 校验码\n\t * 对应统一社会信用代码的最后一位字符,用特定算法计算,用于校验代码有效性。\n\t */\n\tchecksum: string;\n\n\tcodes: string[];\n\tlabels: string[];\n}\n"],"names":["Mod31Checksum","UnifiedSocialCreditCode","CodeLabels","label","children","Y","pattern","Checksum","parse","s","bureau","subjectType","division","slice","subject","checksum","labels","l1","push","l2","codes","format","base","compute","next","delta","sp","split","map","v","numbers","i","length","chars","join"],"mappings":"AAAA,SAASA,aAAa,QAAQ,kBAAkB;UAO/BC;IAMhB,MAAMC,aAAwC;QAC7C,GAAG;YACFC,OAAO;YACPC,UAAU;gBACT,GAAG;oBAAED,OAAO;gBAAK;gBACjB,GAAG;oBAAEA,OAAO;gBAAO;gBACnB,GAAG;oBAAEA,OAAO;gBAAoB;gBAChC,GAAG;oBAAEA,OAAO;gBAAK;YAClB;QACD;QACA,GAAG;YACFA,OAAO;YACPC,UAAU;gBACT,GAAG;oBAAED,OAAO;gBAAO;gBACnB,GAAG;oBAAEA,OAAO;gBAAU;gBACtB,GAAG;oBAAEA,OAAO;gBAAM;gBAClB,GAAG;oBAAEA,OAAO;gBAAK;YAClB;QACD;QACA,GAAG;YACFA,OAAO;YACPC,UAAU;gBACT,GAAG;oBAAED,OAAO;gBAAK;gBACjB,GAAG;oBAAEA,OAAO;gBAAQ;gBACpB,GAAG;oBAAEA,OAAO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L,GAAGM,MAAM,GAAG,GAAGD,KAAK,GAAGA,IAAK;YACxC,IAAI,AAACN,QAAQ,KAAKC,EAAE,CAACK,EAAE,GAAG,MAAQN,QAAQ,KAAKC,EAAE,CAACK,EAAE,GAAG,GAAI;gBAC1DL,EAAE,CAACK,EAAE,IAAIN;gBACT;YACD,OAAO,IAAIA,QAAQ,KAAKC,EAAE,CAACK,EAAE,KAAK,IAAI;gBACrCL,EAAE,CAACK,EAAE,GAAG;YACT,OAAO,IAAIN,QAAQ,KAAKC,EAAE,CAACK,EAAE,KAAK,GAAG;gBACpCL,EAAE,CAACK,EAAE,GAAG;YACT;QACD;QACA,OAAOL,GAAGE,GAAG,CAAC,CAACC,IAAMtB,wBAAAA,SAAS0B,KAAK,CAACJ,EAAE,EAAEK,IAAI,CAAC;IAC9C;4BAbgBV,OAAAA;AAcjB,GAjGiBvB,4BAAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function formatDate(date, format) {
|
|
2
|
+
switch(format){
|
|
3
|
+
case 'yyyyMMDD':
|
|
4
|
+
{
|
|
5
|
+
const year = date.getFullYear();
|
|
6
|
+
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
|
7
|
+
const day = date.getDate().toString().padStart(2, '0');
|
|
8
|
+
return `${year}${month}${day}`;
|
|
9
|
+
}
|
|
10
|
+
default:
|
|
11
|
+
throw new Error(`Invalid format`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=formatDate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cn/formatDate.ts"],"sourcesContent":["export function formatDate(date: Date, format: 'yyyyMMDD') {\n\tswitch (format) {\n\t\tcase 'yyyyMMDD': {\n\t\t\tconst year = date.getFullYear();\n\t\t\tconst month = (date.getMonth() + 1).toString().padStart(2, '0');\n\t\t\tconst day = date.getDate().toString().padStart(2, '0');\n\t\t\treturn `${year}${month}${day}`;\n\t\t}\n\t\tdefault:\n\t\t\tthrow new Error(`Invalid format`);\n\t}\n}\n"],"names":["formatDate","date","format","year","getFullYear","month","getMonth","toString","padStart","day","getDate","Error"],"mappings":"AAAA,OAAO,SAASA,WAAWC,IAAU,EAAEC,MAAkB;IACxD,OAAQA;QACP,KAAK;YAAY;gBAChB,MAAMC,OAAOF,KAAKG,WAAW;gBAC7B,MAAMC,QAAQ,AAACJ,CAAAA,KAAKK,QAAQ,KAAK,CAAA,EAAGC,QAAQ,GAAGC,QAAQ,CAAC,GAAG;gBAC3D,MAAMC,MAAMR,KAAKS,OAAO,GAAGH,QAAQ,GAAGC,QAAQ,CAAC,GAAG;gBAClD,OAAO,GAAGL,OAAOE,QAAQI,KAAK;YAC/B;QACA;YACC,MAAM,IAAIE,MAAM,CAAC,cAAc,CAAC;IAClC;AACD"}
|
package/lib/cn/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cn/index.ts"],"sourcesContent":["export { ResidentIdentityCardNumber } from './ResidentIdentityCardNumber';\nexport { DivisionCode } from './DivisionCode';\nexport { UnifiedSocialCreditCode } from './UnifiedSocialCreditCode';\n"],"names":["ResidentIdentityCardNumber","DivisionCode","UnifiedSocialCreditCode"],"mappings":"AAAA,SAASA,0BAA0B,QAAQ,+BAA+B;AAC1E,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,uBAAuB,QAAQ,4BAA4B"}
|