@wener/common 1.0.4 → 2.0.1

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 (151) hide show
  1. package/lib/cn/DivisionCode.js +55 -32
  2. package/lib/cn/DivisionCode.test.js +140 -0
  3. package/lib/cn/Mod11Checksum.js +80 -37
  4. package/lib/cn/Mod31Checksum.js +89 -40
  5. package/lib/cn/ResidentIdentityCardNumber.js +16 -16
  6. package/lib/cn/ResidentIdentityCardNumber.test.js +21 -0
  7. package/lib/cn/UnifiedSocialCreditCode.js +32 -26
  8. package/lib/cn/UnifiedSocialCreditCode.test.js +16 -0
  9. package/lib/cn/formatDate.js +5 -7
  10. package/lib/cn/index.js +0 -1
  11. package/lib/cn/parseSex.js +0 -2
  12. package/lib/cn/types.d.js +0 -2
  13. package/lib/consola/createStandardConsolaReporter.js +18 -0
  14. package/lib/consola/formatLogObject.js +226 -0
  15. package/lib/consola/index.js +2 -0
  16. package/lib/data/formatSort.js +5 -6
  17. package/lib/data/formatSort.test.js +34 -0
  18. package/lib/data/index.js +0 -1
  19. package/lib/data/maybeNumber.js +11 -5
  20. package/lib/data/parseSort.js +28 -22
  21. package/lib/data/parseSort.test.js +188 -0
  22. package/lib/data/resolvePagination.js +27 -16
  23. package/lib/data/resolvePagination.test.js +232 -0
  24. package/lib/data/types.d.js +0 -2
  25. package/lib/index.js +0 -1
  26. package/lib/jsonschema/JsonSchema.js +80 -54
  27. package/lib/jsonschema/JsonSchema.test.js +137 -0
  28. package/lib/jsonschema/index.js +0 -1
  29. package/lib/jsonschema/types.d.js +5 -3
  30. package/lib/meta/defineFileType.js +103 -20
  31. package/lib/meta/defineInit.js +250 -31
  32. package/lib/meta/defineMetadata.js +140 -24
  33. package/lib/meta/defineMetadata.test.js +13 -0
  34. package/lib/meta/index.js +0 -1
  35. package/lib/password/PHC.js +87 -63
  36. package/lib/password/PHC.test.js +539 -0
  37. package/lib/password/Password.js +291 -29
  38. package/lib/password/Password.test.js +362 -0
  39. package/lib/password/createArgon2PasswordAlgorithm.js +191 -35
  40. package/lib/password/createBase64PasswordAlgorithm.js +141 -8
  41. package/lib/password/createBcryptPasswordAlgorithm.js +168 -13
  42. package/lib/password/createPBKDF2PasswordAlgorithm.js +228 -46
  43. package/lib/password/createScryptPasswordAlgorithm.js +211 -55
  44. package/lib/password/index.js +0 -1
  45. package/lib/password/server/index.js +0 -1
  46. package/lib/resource/Identifiable.js +1 -0
  47. package/lib/resource/getTitleOfResource.js +10 -0
  48. package/lib/resource/index.js +1 -0
  49. package/lib/resource/schema/AnyResourceSchema.js +89 -0
  50. package/lib/resource/schema/BaseResourceSchema.js +29 -0
  51. package/lib/resource/schema/ResourceActionType.js +118 -0
  52. package/lib/resource/schema/ResourceStatus.js +93 -0
  53. package/lib/resource/schema/ResourceType.js +24 -0
  54. package/lib/resource/schema/SchemaRegistry.js +38 -0
  55. package/lib/resource/schema/SexType.js +10 -0
  56. package/lib/resource/schema/types.js +89 -0
  57. package/lib/resource/schema/types.test.js +14 -0
  58. package/lib/schema/TypeSchema.d.js +1 -0
  59. package/lib/schema/createSchemaData.js +173 -0
  60. package/lib/schema/findJsonSchemaByPath.js +49 -0
  61. package/lib/schema/getSchemaCache.js +11 -0
  62. package/lib/schema/getSchemaOptions.js +24 -0
  63. package/lib/schema/index.js +5 -0
  64. package/lib/schema/toJsonSchema.js +441 -0
  65. package/lib/schema/toJsonSchema.test.js +27 -0
  66. package/lib/schema/validate.js +124 -0
  67. package/lib/search/AdvanceSearch.js +0 -1
  68. package/lib/search/AdvanceSearch.test.js +435 -0
  69. package/lib/search/formatAdvanceSearch.js +41 -27
  70. package/lib/search/index.js +0 -1
  71. package/lib/search/optimizeAdvanceSearch.js +79 -25
  72. package/lib/search/parseAdvanceSearch.js +5 -5
  73. package/lib/search/parser.d.js +0 -2
  74. package/lib/search/parser.js +97 -74
  75. package/lib/search/types.d.js +0 -2
  76. package/lib/tools/generateSchema.js +201 -0
  77. package/lib/tools/renderJsonSchemaToMarkdownDoc.js +143 -55
  78. package/package.json +30 -9
  79. package/src/consola/createStandardConsolaReporter.ts +31 -0
  80. package/src/consola/formatLogObject.ts +171 -0
  81. package/src/consola/index.ts +2 -0
  82. package/src/data/maybeNumber.ts +5 -1
  83. package/src/data/resolvePagination.test.ts +1 -1
  84. package/src/data/resolvePagination.ts +18 -7
  85. package/src/data/types.d.ts +12 -0
  86. package/src/jsonschema/JsonSchema.test.ts +17 -0
  87. package/src/jsonschema/JsonSchema.ts +4 -4
  88. package/src/jsonschema/types.d.ts +63 -12
  89. package/src/resource/Identifiable.ts +3 -0
  90. package/src/resource/getTitleOfResource.tsx +6 -0
  91. package/src/resource/index.ts +3 -0
  92. package/src/resource/schema/AnyResourceSchema.ts +113 -0
  93. package/src/resource/schema/BaseResourceSchema.ts +32 -0
  94. package/src/resource/schema/ResourceActionType.ts +123 -0
  95. package/src/resource/schema/ResourceStatus.ts +94 -0
  96. package/src/resource/schema/ResourceType.ts +25 -0
  97. package/src/resource/schema/SchemaRegistry.ts +42 -0
  98. package/src/resource/schema/SexType.ts +13 -0
  99. package/src/resource/schema/types.test.ts +18 -0
  100. package/src/resource/schema/types.ts +105 -0
  101. package/src/schema/TypeSchema.d.ts +32 -0
  102. package/src/schema/createSchemaData.ts +81 -0
  103. package/src/schema/findJsonSchemaByPath.ts +37 -0
  104. package/src/schema/getSchemaCache.ts +21 -0
  105. package/src/schema/getSchemaOptions.ts +24 -0
  106. package/src/schema/index.ts +6 -0
  107. package/src/schema/toJsonSchema.test.ts +37 -0
  108. package/src/schema/toJsonSchema.ts +200 -0
  109. package/src/schema/validate.ts +135 -0
  110. package/src/tools/generateSchema.ts +39 -0
  111. package/lib/cn/DivisionCode.js.map +0 -1
  112. package/lib/cn/Mod11Checksum.js.map +0 -1
  113. package/lib/cn/Mod31Checksum.js.map +0 -1
  114. package/lib/cn/ResidentIdentityCardNumber.js.map +0 -1
  115. package/lib/cn/UnifiedSocialCreditCode.js.map +0 -1
  116. package/lib/cn/formatDate.js.map +0 -1
  117. package/lib/cn/index.js.map +0 -1
  118. package/lib/cn/parseSex.js.map +0 -1
  119. package/lib/cn/types.d.js.map +0 -1
  120. package/lib/data/formatSort.js.map +0 -1
  121. package/lib/data/index.js.map +0 -1
  122. package/lib/data/maybeNumber.js.map +0 -1
  123. package/lib/data/parseSort.js.map +0 -1
  124. package/lib/data/resolvePagination.js.map +0 -1
  125. package/lib/data/types.d.js.map +0 -1
  126. package/lib/index.js.map +0 -1
  127. package/lib/jsonschema/JsonSchema.js.map +0 -1
  128. package/lib/jsonschema/index.js.map +0 -1
  129. package/lib/jsonschema/types.d.js.map +0 -1
  130. package/lib/meta/defineFileType.js.map +0 -1
  131. package/lib/meta/defineInit.js.map +0 -1
  132. package/lib/meta/defineMetadata.js.map +0 -1
  133. package/lib/meta/index.js.map +0 -1
  134. package/lib/password/PHC.js.map +0 -1
  135. package/lib/password/Password.js.map +0 -1
  136. package/lib/password/createArgon2PasswordAlgorithm.js.map +0 -1
  137. package/lib/password/createBase64PasswordAlgorithm.js.map +0 -1
  138. package/lib/password/createBcryptPasswordAlgorithm.js.map +0 -1
  139. package/lib/password/createPBKDF2PasswordAlgorithm.js.map +0 -1
  140. package/lib/password/createScryptPasswordAlgorithm.js.map +0 -1
  141. package/lib/password/index.js.map +0 -1
  142. package/lib/password/server/index.js.map +0 -1
  143. package/lib/search/AdvanceSearch.js.map +0 -1
  144. package/lib/search/formatAdvanceSearch.js.map +0 -1
  145. package/lib/search/index.js.map +0 -1
  146. package/lib/search/optimizeAdvanceSearch.js.map +0 -1
  147. package/lib/search/parseAdvanceSearch.js.map +0 -1
  148. package/lib/search/parser.d.js.map +0 -1
  149. package/lib/search/parser.js.map +0 -1
  150. package/lib/search/types.d.js.map +0 -1
  151. package/lib/tools/renderJsonSchemaToMarkdownDoc.js.map +0 -1
@@ -0,0 +1,201 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
+ try {
3
+ var info = gen[key](arg);
4
+ var value = info.value;
5
+ } catch (error) {
6
+ reject(error);
7
+ return;
8
+ }
9
+ if (info.done) {
10
+ resolve(value);
11
+ } else {
12
+ Promise.resolve(value).then(_next, _throw);
13
+ }
14
+ }
15
+ function _async_to_generator(fn) {
16
+ return function() {
17
+ var self = this, args = arguments;
18
+ return new Promise(function(resolve, reject) {
19
+ var gen = fn.apply(self, args);
20
+ function _next(value) {
21
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
+ }
23
+ function _throw(err) {
24
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
+ }
26
+ _next(undefined);
27
+ });
28
+ };
29
+ }
30
+ function _ts_generator(thisArg, body) {
31
+ var f, y, t, _ = {
32
+ label: 0,
33
+ sent: function() {
34
+ if (t[0] & 1) throw t[1];
35
+ return t[1];
36
+ },
37
+ trys: [],
38
+ ops: []
39
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
40
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
41
+ return this;
42
+ }), g;
43
+ function verb(n) {
44
+ return function(v) {
45
+ return step([
46
+ n,
47
+ v
48
+ ]);
49
+ };
50
+ }
51
+ function step(op) {
52
+ if (f) throw new TypeError("Generator is already executing.");
53
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
54
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
55
+ if (y = 0, t) op = [
56
+ op[0] & 2,
57
+ t.value
58
+ ];
59
+ switch(op[0]){
60
+ case 0:
61
+ case 1:
62
+ t = op;
63
+ break;
64
+ case 4:
65
+ _.label++;
66
+ return {
67
+ value: op[1],
68
+ done: false
69
+ };
70
+ case 5:
71
+ _.label++;
72
+ y = op[1];
73
+ op = [
74
+ 0
75
+ ];
76
+ continue;
77
+ case 7:
78
+ op = _.ops.pop();
79
+ _.trys.pop();
80
+ continue;
81
+ default:
82
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
83
+ _ = 0;
84
+ continue;
85
+ }
86
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
87
+ _.label = op[1];
88
+ break;
89
+ }
90
+ if (op[0] === 6 && _.label < t[1]) {
91
+ _.label = t[1];
92
+ t = op;
93
+ break;
94
+ }
95
+ if (t && _.label < t[2]) {
96
+ _.label = t[2];
97
+ _.ops.push(op);
98
+ break;
99
+ }
100
+ if (t[2]) _.ops.pop();
101
+ _.trys.pop();
102
+ continue;
103
+ }
104
+ op = body.call(thisArg, _);
105
+ } catch (e) {
106
+ op = [
107
+ 6,
108
+ e
109
+ ];
110
+ y = 0;
111
+ } finally{
112
+ f = t = 0;
113
+ }
114
+ if (op[0] & 5) throw op[1];
115
+ return {
116
+ value: op[0] ? op[1] : void 0,
117
+ done: true
118
+ };
119
+ }
120
+ }
121
+ import { exec } from 'node:child_process';
122
+ import fs from 'node:fs/promises';
123
+ import path from 'node:path';
124
+ import * as Codegen from '@sinclair/typebox-codegen';
125
+ export function generateSchema(_0) {
126
+ return _async_to_generator(function(param) {
127
+ var file, _param_dir, dir, fn, types, typeboxDir, zodDir, typeBoxFile, zodFile, out, model;
128
+ return _ts_generator(this, function(_state) {
129
+ switch(_state.label){
130
+ case 0:
131
+ file = param.file, _param_dir = param.dir, dir = _param_dir === void 0 ? path.dirname(file) : _param_dir;
132
+ fn = path.basename(file).replace(/\.d\.ts$/, '.ts');
133
+ return [
134
+ 4,
135
+ fs.readFile(file, 'utf-8')
136
+ ];
137
+ case 1:
138
+ types = _state.sent();
139
+ typeboxDir = path.join(dir, 'typebox');
140
+ zodDir = path.join(dir, 'zod');
141
+ return [
142
+ 4,
143
+ fs.mkdir(typeboxDir, {
144
+ recursive: true
145
+ })
146
+ ];
147
+ case 2:
148
+ _state.sent();
149
+ return [
150
+ 4,
151
+ fs.mkdir(zodDir, {
152
+ recursive: true
153
+ })
154
+ ];
155
+ case 3:
156
+ _state.sent();
157
+ typeBoxFile = path.join(typeboxDir, fn);
158
+ zodFile = path.join(zodDir, fn);
159
+ // avoid import type error
160
+ out = Codegen.TypeScriptToTypeBox.Generate(types);
161
+ out = out.replace(/^import \{ Type, Static\b/, "import { Type, type Static");
162
+ return [
163
+ 4,
164
+ fs.writeFile(typeBoxFile, out)
165
+ ];
166
+ case 4:
167
+ _state.sent();
168
+ model = Codegen.TypeScriptToModel.Generate(types);
169
+ return [
170
+ 4,
171
+ fs.writeFile(zodFile, Codegen.ModelToZod.Generate(model))
172
+ ];
173
+ case 5:
174
+ _state.sent();
175
+ return [
176
+ 4,
177
+ new Promise(function(resolve, reject) {
178
+ exec('pnpm prettier --write "'.concat(dir, '/{typebox,zod}/*.ts"'), function(error, stdout, stderr) {
179
+ if (error) {
180
+ console.error("exec error: ".concat(error));
181
+ reject(error);
182
+ return;
183
+ }
184
+ resolve({
185
+ stderr: stderr,
186
+ stdout: stdout
187
+ });
188
+ stdout && console.log("prettier:stdout: ".concat(stdout));
189
+ stderr && console.error("prettier:stderr: ".concat(stderr));
190
+ });
191
+ })
192
+ ];
193
+ case 6:
194
+ _state.sent();
195
+ return [
196
+ 2
197
+ ];
198
+ }
199
+ });
200
+ }).apply(this, arguments);
201
+ }
@@ -1,85 +1,173 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_with_holes(arr) {
7
+ if (Array.isArray(arr)) return arr;
8
+ }
9
+ function _iterable_to_array_limit(arr, i) {
10
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
11
+ if (_i == null) return;
12
+ var _arr = [];
13
+ var _n = true;
14
+ var _d = false;
15
+ var _s, _e;
16
+ try {
17
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
18
+ _arr.push(_s.value);
19
+ if (i && _arr.length === i) break;
20
+ }
21
+ } catch (err) {
22
+ _d = true;
23
+ _e = err;
24
+ } finally{
25
+ try {
26
+ if (!_n && _i["return"] != null) _i["return"]();
27
+ } finally{
28
+ if (_d) throw _e;
29
+ }
30
+ }
31
+ return _arr;
32
+ }
33
+ function _non_iterable_rest() {
34
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
35
+ }
36
+ function _sliced_to_array(arr, i) {
37
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
38
+ }
39
+ function _unsupported_iterable_to_array(o, minLen) {
40
+ if (!o) return;
41
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
42
+ var n = Object.prototype.toString.call(o).slice(8, -1);
43
+ if (n === "Object" && o.constructor) n = o.constructor.name;
44
+ if (n === "Map" || n === "Set") return Array.from(n);
45
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
46
+ }
1
47
  export function renderJsonSchemaToMarkdownDoc(rootSchema) {
2
48
  // markdown
3
- const out = [];
4
- const all = new Set();
5
- const pending = [];
6
- const addObject = (o)=>{
49
+ var out = [];
50
+ var all = new Set();
51
+ var pending = [];
52
+ var addObject = function(o) {
7
53
  if (all.has(o.$id)) {
8
54
  return;
9
55
  }
10
56
  all.add(o.$id);
11
57
  pending.push(o);
12
58
  };
13
- const writeObjectProps = (T, { prefix = '' } = {})=>{
14
- if (!T?.properties) {
59
+ var writeObjectProps = function(T) {
60
+ var _ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, _ref_prefix = _ref.prefix, prefix = _ref_prefix === void 0 ? '' : _ref_prefix;
61
+ if (!(T === null || T === void 0 ? void 0 : T.properties)) {
15
62
  return;
16
63
  }
17
- for (const [name, schema] of Object.entries(T.properties)){
18
- let typ = schema.$id || schema.type;
19
- if (typ === 'array') {
20
- typ = `${schema.items.$id || schema.items.type}[]`;
21
- if (schema.items.$id) {
22
- addObject(schema.items);
64
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
65
+ try {
66
+ for(var _iterator = Object.entries(T.properties)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
67
+ var _step_value = _sliced_to_array(_step.value, 2), name = _step_value[0], schema = _step_value[1];
68
+ var typ = schema.$id || schema.type;
69
+ if (typ === 'array') {
70
+ typ = "".concat(schema.items.$id || schema.items.type, "[]");
71
+ if (schema.items.$id) {
72
+ addObject(schema.items);
73
+ }
74
+ } else if (schema.$id) {
75
+ addObject(schema);
23
76
  }
24
- } else if (schema.$id) {
25
- addObject(schema);
26
- }
27
- if (!typ) {
28
- if ('anyOf' in schema) {
29
- typ = 'enum';
77
+ if (!typ) {
78
+ if ('anyOf' in schema) {
79
+ typ = 'enum';
80
+ }
30
81
  }
31
- }
32
- out.push(`| ${prefix}${name} | ${typ} | ${schema.title || schema.description || ''} |`);
33
- if (typ === 'object') {
34
- writeObjectProps(schema, {
35
- prefix: `${prefix}${name}.`
36
- });
37
- } else if (schema.type === 'array') {
38
- if (schema.items.type === 'object' && !schema.items.$id) {
39
- writeObjectProps(schema.items, {
40
- prefix: `${prefix}${name}[].`
82
+ out.push("| ".concat(prefix).concat(name, " | ").concat(typ, " | ").concat(schema.title || schema.description || '', " |"));
83
+ if (typ === 'object') {
84
+ writeObjectProps(schema, {
85
+ prefix: "".concat(prefix).concat(name, ".")
41
86
  });
87
+ } else if (schema.type === 'array') {
88
+ if (schema.items.type === 'object' && !schema.items.$id) {
89
+ writeObjectProps(schema.items, {
90
+ prefix: "".concat(prefix).concat(name, "[].")
91
+ });
92
+ }
93
+ }
94
+ }
95
+ } catch (err) {
96
+ _didIteratorError = true;
97
+ _iteratorError = err;
98
+ } finally{
99
+ try {
100
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
101
+ _iterator.return();
102
+ }
103
+ } finally{
104
+ if (_didIteratorError) {
105
+ throw _iteratorError;
42
106
  }
43
107
  }
44
108
  }
45
109
  };
46
- const writeObject = (T)=>{
47
- out.push(`### ${T.title || T.$id}`);
48
- out.push(`
49
- | $id | 名字 |
50
- | --- | --- |
51
- | ${T.$id || ''} | ${T.title || ''} |
52
- `);
110
+ var writeObject = function(T) {
111
+ out.push("### ".concat(T.title || T.$id));
112
+ out.push("\n| $id | 名字 |\n| --- | --- |\n| ".concat(T.$id || '', " | ").concat(T.title || '', " | \n "));
53
113
  if (T.description) {
54
114
  out.push('');
55
- out.push(`> ${T.description}`);
115
+ out.push("> ".concat(T.description));
56
116
  out.push('');
57
117
  }
58
- out.push(`| 名字 | 类型 | 说明 |`);
59
- out.push(`| --- | --- | --- |`);
118
+ out.push("| 名字 | 类型 | 说明 |");
119
+ out.push("| --- | --- | --- |");
60
120
  writeObjectProps(T);
61
121
  out.push('');
62
122
  };
63
123
  writeObject(rootSchema);
64
- for (const schema of pending){
65
- if (schema.type === 'object') {
66
- writeObject(schema);
67
- } else if ('anyOf' in schema) {
68
- out.push(`### ${schema.$id || schema.title}`);
69
- out.push(`
70
- | $id | 名字 |
71
- | --- | --- |
72
- | ${schema.$id || ''} | ${schema.title || ''} |
73
- `);
74
- out.push(`| | 说明 |`);
75
- out.push(`| --- | --- |`);
76
- for (const item of schema.anyOf){
77
- out.push(`| ${item.const} | ${item.title || item.description || ''} |`);
124
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
125
+ try {
126
+ for(var _iterator = pending[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
127
+ var schema = _step.value;
128
+ if (schema.type === 'object') {
129
+ writeObject(schema);
130
+ } else if ('anyOf' in schema) {
131
+ out.push("### ".concat(schema.$id || schema.title));
132
+ out.push("\n| $id | 名字 |\n| --- | --- |\n| ".concat(schema.$id || '', " | ").concat(schema.title || '', " | \n "));
133
+ out.push("| 值 | 说明 |");
134
+ out.push("| --- | --- |");
135
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
136
+ try {
137
+ for(var _iterator1 = schema.anyOf[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
138
+ var item = _step1.value;
139
+ out.push("| ".concat(item.const, " | ").concat(item.title || item.description || '', " |"));
140
+ }
141
+ } catch (err) {
142
+ _didIteratorError1 = true;
143
+ _iteratorError1 = err;
144
+ } finally{
145
+ try {
146
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
147
+ _iterator1.return();
148
+ }
149
+ } finally{
150
+ if (_didIteratorError1) {
151
+ throw _iteratorError1;
152
+ }
153
+ }
154
+ }
155
+ out.push('');
156
+ }
157
+ }
158
+ } catch (err) {
159
+ _didIteratorError = true;
160
+ _iteratorError = err;
161
+ } finally{
162
+ try {
163
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
164
+ _iterator.return();
165
+ }
166
+ } finally{
167
+ if (_didIteratorError) {
168
+ throw _iteratorError;
78
169
  }
79
- out.push('');
80
170
  }
81
171
  }
82
172
  return out.join('\n');
83
173
  }
84
-
85
- //# sourceMappingURL=renderJsonSchemaToMarkdownDoc.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wener/common",
3
- "version": "1.0.4",
3
+ "version": "2.0.1",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "author": "",
@@ -14,6 +14,10 @@
14
14
  "types": "./src/cn/index.ts",
15
15
  "default": "./lib/cn/index.js"
16
16
  },
17
+ "./consola": {
18
+ "types": "./src/consola/index.ts",
19
+ "default": "./lib/consola/index.js"
20
+ },
17
21
  "./data": {
18
22
  "types": "./src/data/index.ts",
19
23
  "default": "./lib/data/index.js"
@@ -30,6 +34,14 @@
30
34
  "types": "./src/password/index.ts",
31
35
  "default": "./lib/password/index.js"
32
36
  },
37
+ "./resource": {
38
+ "types": "./src/resource/index.ts",
39
+ "default": "./lib/resource/index.js"
40
+ },
41
+ "./schema": {
42
+ "types": "./src/schema/index.ts",
43
+ "default": "./lib/schema/index.js"
44
+ },
33
45
  "./search": {
34
46
  "types": "./src/search/index.ts",
35
47
  "default": "./lib/search/index.js"
@@ -43,25 +55,34 @@
43
55
  "src"
44
56
  ],
45
57
  "keywords": [],
58
+ "peerDependencies": {
59
+ "zod": "*"
60
+ },
46
61
  "dependencies": {
47
- "es-toolkit": "^1.32.0",
48
- "ts-pattern": "^5.6.2",
49
- "zod": "^3.24.2",
50
- "@wener/utils": "1.1.51"
62
+ "@standard-schema/spec": "^1.0.0",
63
+ "@wener/utils": "^1.1.51",
64
+ "date-fns": "^4.1.0",
65
+ "es-toolkit": "^1.37.2",
66
+ "std-env": "^3.9.0",
67
+ "ts-pattern": "^5.7.0"
51
68
  },
52
69
  "devDependencies": {
53
- "@sinclair/typebox": "^0.34.28",
70
+ "@sinclair/typebox": "^0.34.33",
71
+ "@sinclair/typebox-codegen": "^0.11.1",
54
72
  "@types/argon2-browser": "^1.18.4",
55
73
  "@types/bcrypt": "^5.0.2",
56
- "@types/bcryptjs": "^2.4.6",
57
74
  "ajv": "^8.17.1",
58
75
  "ajv-formats": "^3.0.1",
59
76
  "ajv-i18n": "^4.2.0",
60
77
  "ajv-keywords": "^5.1.0",
61
- "argon2": "^0.41.1",
78
+ "argon2": "^0.43.0",
62
79
  "argon2-browser": "^1.18.0",
63
80
  "bcrypt": "^5.1.1",
64
- "bcryptjs": "^3.0.2"
81
+ "bcryptjs": "^3.0.2",
82
+ "chalk": "^5.4.1",
83
+ "consola": "^3.4.2",
84
+ "dayjs": "^1.11.13",
85
+ "zod": "^3.25.63"
65
86
  },
66
87
  "scripts": {
67
88
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -0,0 +1,31 @@
1
+ import type { ConsolaOptions, ConsolaReporter, LogObject } from 'consola/core';
2
+ import { formatLogObject } from './formatLogObject';
3
+
4
+ type Formatter = (
5
+ o: LogObject,
6
+ ctx: {
7
+ options: ConsolaOptions;
8
+ },
9
+ ) => string;
10
+
11
+ export function createStandardConsolaReporter({
12
+ format = formatLogObject,
13
+ }: {
14
+ format?: Formatter;
15
+ } = {}): ConsolaReporter {
16
+ return {
17
+ log: (o, ctx) => {
18
+ let out = format(o, ctx);
19
+ let fn = console.log;
20
+
21
+ const { level } = o;
22
+ if (level < 1) {
23
+ fn = console.error;
24
+ } else if (level === 1) {
25
+ fn = console.warn;
26
+ }
27
+
28
+ fn(out);
29
+ },
30
+ };
31
+ }