@wener/common 2.0.3 → 2.0.5

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 (168) hide show
  1. package/lib/ai/qwen3vl/utils.js.map +1 -1
  2. package/lib/cn/ChineseResidentIdNo.js +1 -1
  3. package/lib/cn/ChineseResidentIdNo.js.map +1 -1
  4. package/lib/cn/Mod11.js +1 -1
  5. package/lib/cn/Mod11.js.map +1 -1
  6. package/lib/consola/formatLogObject.js +5 -5
  7. package/lib/consola/formatLogObject.js.map +1 -1
  8. package/lib/data/maybeNumber.js +1 -1
  9. package/lib/data/maybeNumber.js.map +1 -1
  10. package/lib/data/types.d.js.map +1 -1
  11. package/lib/dayjs/formatDuration.js.map +1 -1
  12. package/lib/dayjs/resolveRelativeTime.js +9 -80
  13. package/lib/dayjs/resolveRelativeTime.js.map +1 -1
  14. package/lib/drain3/Drain.js +356 -0
  15. package/lib/drain3/Drain.js.map +1 -0
  16. package/lib/drain3/LogCluster.js +38 -0
  17. package/lib/drain3/LogCluster.js.map +1 -0
  18. package/lib/drain3/Node.js +39 -0
  19. package/lib/drain3/Node.js.map +1 -0
  20. package/lib/drain3/TemplateMiner.js +204 -0
  21. package/lib/drain3/TemplateMiner.js.map +1 -0
  22. package/lib/drain3/index.js +31 -0
  23. package/lib/drain3/index.js.map +1 -0
  24. package/lib/drain3/persistence/FilePersistence.js +24 -0
  25. package/lib/drain3/persistence/FilePersistence.js.map +1 -0
  26. package/lib/drain3/persistence/MemoryPersistence.js +18 -0
  27. package/lib/drain3/persistence/MemoryPersistence.js.map +1 -0
  28. package/lib/drain3/persistence/PersistenceHandler.js +5 -0
  29. package/lib/drain3/persistence/PersistenceHandler.js.map +1 -0
  30. package/lib/drain3/types.js +7 -0
  31. package/lib/drain3/types.js.map +1 -0
  32. package/lib/fs/IFileSystem.d.js.map +1 -1
  33. package/lib/fs/createBrowserFileSystem.js +4 -2
  34. package/lib/fs/createBrowserFileSystem.js.map +1 -1
  35. package/lib/fs/createMemoryFileSystem.js +7 -6
  36. package/lib/fs/createMemoryFileSystem.js.map +1 -1
  37. package/lib/fs/createSandboxFileSystem.js.map +1 -1
  38. package/lib/fs/createWebDavFileSystem.js +22 -5
  39. package/lib/fs/createWebDavFileSystem.js.map +1 -1
  40. package/lib/fs/createWebFileSystem.js +225 -0
  41. package/lib/fs/createWebFileSystem.js.map +1 -0
  42. package/lib/fs/findMimeType.js +1 -1
  43. package/lib/fs/findMimeType.js.map +1 -1
  44. package/lib/fs/index.js +1 -1
  45. package/lib/fs/index.js.map +1 -1
  46. package/lib/fs/minio/createMinioFileSystem.js +974 -0
  47. package/lib/fs/minio/createMinioFileSystem.js.map +1 -0
  48. package/lib/fs/minio/index.js +2 -0
  49. package/lib/fs/minio/index.js.map +1 -0
  50. package/lib/fs/orpc/createContractClientFileSystem.js +3 -3
  51. package/lib/fs/orpc/createContractClientFileSystem.js.map +1 -1
  52. package/lib/fs/orpc/server/createFileSystemContractImpl.js.map +1 -1
  53. package/lib/fs/s3/createS3MiniFileSystem.js +116 -68
  54. package/lib/fs/s3/createS3MiniFileSystem.js.map +1 -1
  55. package/lib/fs/server/createDatabaseFileSystem.js +7 -7
  56. package/lib/fs/server/createDatabaseFileSystem.js.map +1 -1
  57. package/lib/fs/server/createNodeFileSystem.js +30 -5
  58. package/lib/fs/server/createNodeFileSystem.js.map +1 -1
  59. package/lib/fs/tests/runFileSystemTest.js +27 -26
  60. package/lib/fs/tests/runFileSystemTest.js.map +1 -1
  61. package/lib/fs/utils.js.map +1 -1
  62. package/lib/fs/webdav/index.js +2 -0
  63. package/lib/fs/webdav/index.js.map +1 -0
  64. package/lib/jsonschema/JsonSchema.js +5 -5
  65. package/lib/jsonschema/JsonSchema.js.map +1 -1
  66. package/lib/jsonschema/forEachJsonSchema.js +1 -1
  67. package/lib/jsonschema/forEachJsonSchema.js.map +1 -1
  68. package/lib/jsonschema/types.d.js.map +1 -1
  69. package/lib/meta/defineMetadata.js.map +1 -1
  70. package/lib/orpc/createOpenApiContractClient.js.map +1 -1
  71. package/lib/password/PHC.js +2 -2
  72. package/lib/password/PHC.js.map +1 -1
  73. package/lib/password/createArgon2PasswordAlgorithm.js.map +1 -1
  74. package/lib/password/createBase64PasswordAlgorithm.js +1 -1
  75. package/lib/password/createBase64PasswordAlgorithm.js.map +1 -1
  76. package/lib/password/createBcryptPasswordAlgorithm.js.map +1 -1
  77. package/lib/password/createPBKDF2PasswordAlgorithm.js +1 -1
  78. package/lib/password/createPBKDF2PasswordAlgorithm.js.map +1 -1
  79. package/lib/password/createScryptPasswordAlgorithm.js +3 -3
  80. package/lib/password/createScryptPasswordAlgorithm.js.map +1 -1
  81. package/lib/resource/ListQuery.js.map +1 -1
  82. package/lib/resource/index.js.map +1 -1
  83. package/lib/s3/formatS3Url.js +2 -2
  84. package/lib/s3/formatS3Url.js.map +1 -1
  85. package/lib/s3/parseS3Url.js +1 -1
  86. package/lib/s3/parseS3Url.js.map +1 -1
  87. package/lib/schema/SchemaRegistry.js.map +1 -1
  88. package/lib/schema/TypeSchema.d.js.map +1 -1
  89. package/lib/schema/createSchemaData.js +4 -4
  90. package/lib/schema/createSchemaData.js.map +1 -1
  91. package/lib/schema/findJsonSchemaByPath.js.map +1 -1
  92. package/lib/schema/formatZodError.js +42 -44
  93. package/lib/schema/formatZodError.js.map +1 -1
  94. package/lib/schema/toJsonSchema.js +4 -4
  95. package/lib/schema/toJsonSchema.js.map +1 -1
  96. package/lib/schema/validate.js +1 -1
  97. package/lib/schema/validate.js.map +1 -1
  98. package/lib/utils/buildRedactorFormSchema.js +1 -1
  99. package/lib/utils/buildRedactorFormSchema.js.map +1 -1
  100. package/package.json +32 -13
  101. package/src/ai/qwen3vl/utils.ts +1 -1
  102. package/src/cn/ChineseResidentIdNo.ts +1 -1
  103. package/src/cn/Mod11.ts +1 -1
  104. package/src/cn/__snapshots__/ChineseResidentIdNo.test.ts.snap +1 -1
  105. package/src/cn/__snapshots__/UnifiedSocialCreditCode.test.ts.snap +0 -23
  106. package/src/cn/parseChineseNumber.test.ts +4 -4
  107. package/src/consola/formatLogObject.ts +6 -6
  108. package/src/data/maybeNumber.ts +1 -1
  109. package/src/data/parseSort.test.ts +0 -1
  110. package/src/data/types.d.ts +2 -2
  111. package/src/dayjs/formatDuration.ts +2 -2
  112. package/src/dayjs/resolveRelativeTime.ts +11 -14
  113. package/src/drain3/Drain.test.ts +378 -0
  114. package/src/drain3/Drain.ts +394 -0
  115. package/src/drain3/LogCluster.ts +46 -0
  116. package/src/drain3/Node.ts +53 -0
  117. package/src/drain3/TemplateMiner.ts +246 -0
  118. package/src/drain3/index.ts +36 -0
  119. package/src/drain3/persistence/FilePersistence.ts +24 -0
  120. package/src/drain3/persistence/MemoryPersistence.ts +23 -0
  121. package/src/drain3/persistence/PersistenceHandler.ts +19 -0
  122. package/src/drain3/types.ts +75 -0
  123. package/src/fs/IFileSystem.d.ts +1 -2
  124. package/src/fs/createBrowserFileSystem.ts +7 -5
  125. package/src/fs/createMemoryFileSystem.ts +9 -13
  126. package/src/fs/createSandboxFileSystem.ts +1 -1
  127. package/src/fs/createWebDavFileSystem.ts +28 -10
  128. package/src/fs/createWebFileSystem.ts +242 -0
  129. package/src/fs/findMimeType.ts +1 -4
  130. package/src/fs/index.ts +1 -1
  131. package/src/fs/minio/createMinioFileSystem.ts +1148 -0
  132. package/src/fs/minio/index.ts +1 -0
  133. package/src/fs/orpc/createContractClientFileSystem.ts +5 -5
  134. package/src/fs/orpc/server/createFileSystemContractImpl.ts +1 -1
  135. package/src/fs/s3/createS3MiniFileSystem.ts +119 -78
  136. package/src/fs/s3/s3fs.test.ts +441 -0
  137. package/src/fs/s3/s3mini.test.ts +2 -2
  138. package/src/fs/server/createDatabaseFileSystem.ts +7 -7
  139. package/src/fs/server/createNodeFileSystem.ts +32 -13
  140. package/src/fs/server/dbfs.test.ts +2 -1
  141. package/src/fs/tests/runFileSystemTest.ts +29 -28
  142. package/src/fs/utils.ts +1 -1
  143. package/src/fs/webdav/index.ts +1 -0
  144. package/src/jsonschema/JsonSchema.ts +5 -5
  145. package/src/jsonschema/forEachJsonSchema.ts +1 -1
  146. package/src/jsonschema/types.d.ts +1 -1
  147. package/src/meta/defineMetadata.ts +1 -1
  148. package/src/orpc/createOpenApiContractClient.ts +2 -2
  149. package/src/password/PHC.ts +3 -3
  150. package/src/password/createArgon2PasswordAlgorithm.ts +1 -1
  151. package/src/password/createBase64PasswordAlgorithm.ts +2 -2
  152. package/src/password/createBcryptPasswordAlgorithm.ts +4 -2
  153. package/src/password/createPBKDF2PasswordAlgorithm.ts +2 -2
  154. package/src/password/createScryptPasswordAlgorithm.ts +4 -4
  155. package/src/resource/ListQuery.ts +4 -1
  156. package/src/resource/index.ts +2 -2
  157. package/src/s3/formatS3Url.test.ts +1 -1
  158. package/src/s3/formatS3Url.ts +2 -2
  159. package/src/s3/parseS3Url.ts +1 -1
  160. package/src/schema/SchemaRegistry.ts +1 -1
  161. package/src/schema/TypeSchema.d.ts +6 -6
  162. package/src/schema/createSchemaData.ts +4 -4
  163. package/src/schema/findJsonSchemaByPath.ts +4 -4
  164. package/src/schema/formatZodError.test.ts +2 -1
  165. package/src/schema/formatZodError.ts +50 -62
  166. package/src/schema/toJsonSchema.ts +6 -6
  167. package/src/schema/validate.ts +1 -1
  168. package/src/utils/buildRedactorFormSchema.ts +3 -3
@@ -1,6 +1,6 @@
1
1
  import { expect } from 'vitest';
2
2
  import { FileSystemError, FileSystemErrorCode } from '../FileSystemError';
3
- import type { IFileSystem } from '../IFileSystem';
3
+ import type { IFileSystem, IServerFileSystem } from '../IFileSystem';
4
4
 
5
5
  export type RunFileSystemTestOptions = {
6
6
  writableStream?: boolean;
@@ -10,7 +10,7 @@ export type RunFileSystemTestOptions = {
10
10
  abort?: boolean;
11
11
  };
12
12
 
13
- export async function runFileSystemTest(fs: IFileSystem, options: RunFileSystemTestOptions = {}) {
13
+ export async function runFileSystemTest(fs: IFileSystem | IServerFileSystem, options: RunFileSystemTestOptions = {}) {
14
14
  const { writableStream = true, readableStream = true, readStream = true, writeStream = true, abort = true } = options;
15
15
  // should be implemented
16
16
  const stat = await fs.stat('/README.txt');
@@ -65,21 +65,22 @@ export async function runFileSystemTest(fs: IFileSystem, options: RunFileSystemT
65
65
  await expect(fs.writeFile('/', 'test')).rejects.toMatchObject({ code: FileSystemErrorCode.EINVAL });
66
66
 
67
67
  // should support streaming operations
68
- if (readStream && fs.createReadStream) {
68
+ const serverFs = fs as IServerFileSystem;
69
+ if (readStream && 'createReadStream' in fs) {
69
70
  await fs.writeFile('/stream.txt', 'Hello, World!');
70
71
 
71
72
  // Test createReadStream
72
- const readStream = fs.createReadStream('/stream.txt');
73
- expect(readStream).toBeDefined();
73
+ const readStreamObj = serverFs.createReadStream('/stream.txt');
74
+ expect(readStreamObj).toBeDefined();
74
75
 
75
76
  const chunks: Buffer[] = [];
76
- for await (const chunk of readStream) {
77
+ for await (const chunk of readStreamObj) {
77
78
  chunks.push(chunk);
78
79
  }
79
80
  expect(Buffer.concat(chunks).toString()).toBe('Hello, World!');
80
81
 
81
82
  // Test createReadStream with range
82
- const rangeStream = fs.createReadStream('/stream.txt', { range: { start: 0, end: 4 } });
83
+ const rangeStream = serverFs.createReadStream('/stream.txt', { range: { start: 0, end: 4 } });
83
84
  const rangeChunks: Buffer[] = [];
84
85
  for await (const chunk of rangeStream) {
85
86
  rangeChunks.push(chunk);
@@ -87,37 +88,37 @@ export async function runFileSystemTest(fs: IFileSystem, options: RunFileSystemT
87
88
  expect(Buffer.concat(rangeChunks).toString()).toBe('Hello');
88
89
  }
89
90
 
90
- if (writeStream && fs.createWriteStream) {
91
+ if (writeStream && 'createWriteStream' in fs) {
91
92
  // Test createWriteStream
92
- const writeStream = fs.createWriteStream('/write-test.txt');
93
- expect(writeStream).toBeDefined();
93
+ const writeStreamObj = serverFs.createWriteStream('/write-test.txt');
94
+ expect(writeStreamObj).toBeDefined();
94
95
 
95
- writeStream.write('Test content');
96
- writeStream.end();
96
+ writeStreamObj.write('Test content');
97
+ writeStreamObj.end();
97
98
 
98
- await new Promise((resolve) => writeStream.on('finish', resolve));
99
+ await new Promise((resolve) => writeStreamObj.on('finish', resolve));
99
100
  expect(await fs.readFile('/write-test.txt', { encoding: 'text' })).toBe('Test content');
100
101
  }
101
102
 
102
103
  // should support Web Streams API
103
- if (readableStream) {
104
+ if (readableStream && fs.createReadableStream) {
104
105
  await fs.writeFile('/webstream.txt', 'Web Stream Test');
105
106
 
106
107
  // Test createReadableStream
107
- const readableStream = fs.createReadableStream('/webstream.txt');
108
- expect(readableStream).toBeDefined();
108
+ const readableStreamObj = fs.createReadableStream('/webstream.txt');
109
+ expect(readableStreamObj).toBeDefined();
109
110
 
110
- const reader = readableStream.getReader();
111
+ const reader = readableStreamObj.getReader();
111
112
  const { value } = await reader.read();
112
113
  expect(value?.toString()).toBe('Web Stream Test');
113
114
  }
114
115
 
115
- if (writableStream) {
116
+ if (writableStream && fs.createWritableStream) {
116
117
  // Test createWritableStream
117
- const writableStream = fs.createWritableStream('/web-write-test.txt');
118
- expect(writableStream).toBeDefined();
118
+ const writableStreamObj = fs.createWritableStream('/web-write-test.txt');
119
+ expect(writableStreamObj).toBeDefined();
119
120
 
120
- const writer = writableStream.getWriter();
121
+ const writer = writableStreamObj.getWriter();
121
122
  await writer.write(Buffer.from('Web Stream Write Test'));
122
123
  await writer.close();
123
124
 
@@ -125,30 +126,30 @@ export async function runFileSystemTest(fs: IFileSystem, options: RunFileSystemT
125
126
  }
126
127
 
127
128
  // should handle streaming errors
128
- if (abort && readStream && fs.createReadStream) {
129
+ if (abort && readStream && 'createReadStream' in fs) {
129
130
  const controller2 = new AbortController();
130
131
 
131
132
  // Test read stream with abort
132
- const readStream = fs.createReadStream('/README.txt', { signal: controller2.signal });
133
+ const readStreamObj = serverFs.createReadStream('/README.txt', { signal: controller2.signal });
133
134
  controller2.abort();
134
135
 
135
136
  await expect(
136
137
  new Promise((_, reject) => {
137
- readStream.on('error', reject);
138
+ readStreamObj.on('error', reject);
138
139
  }),
139
140
  ).rejects.toThrow(Error);
140
141
  }
141
142
 
142
- if (abort && writeStream && fs.createWriteStream) {
143
+ if (abort && writeStream && 'createWriteStream' in fs) {
143
144
  // Test write stream with abort
144
145
  const controller3 = new AbortController();
145
- const writeStream = fs.createWriteStream('/abort-test.txt', { signal: controller3.signal });
146
+ const writeStreamObj = serverFs.createWriteStream('/abort-test.txt', { signal: controller3.signal });
146
147
  controller3.abort();
147
148
 
148
149
  await expect(
149
150
  new Promise((_, reject) => {
150
- writeStream.on('error', reject);
151
- writeStream.write('test');
151
+ writeStreamObj.on('error', reject);
152
+ writeStreamObj.write('test');
152
153
  }),
153
154
  ).rejects.toThrow(Error);
154
155
  }
package/src/fs/utils.ts CHANGED
@@ -4,7 +4,7 @@ import type { IFileStat, WritableData } from './IFileSystem';
4
4
  export function resolveData(data: WritableData) {
5
5
  let buf: Uint8Array;
6
6
  if (typeof data === 'string') {
7
- buf = ArrayBuffers.toUint8Array(ArrayBuffers.from(data, 'utf8'));
7
+ buf = ArrayBuffers.toUint8Array(ArrayBuffers.from(data, 'utf8') as BufferSource);
8
8
  } else if (data instanceof ArrayBuffer) {
9
9
  buf = new Uint8Array(data);
10
10
  } else if (data instanceof Uint8Array) {
@@ -0,0 +1 @@
1
+ export { createWebDavFileSystem } from '../createWebDavFileSystem';
@@ -72,7 +72,7 @@ function addSchema(
72
72
  onConflict = (_, neo) => neo;
73
73
  break;
74
74
  case 'throw':
75
- onConflict = (old, neo) => {
75
+ onConflict = (_old, neo) => {
76
76
  throw new Error(`Schema ${neo.$id} already exists`);
77
77
  };
78
78
  break;
@@ -119,8 +119,8 @@ function create<S>(schema: S, data?: any): TypeOfSchema<S> {
119
119
  .with({ oneOf: P.nonNullable }, (schema) => {
120
120
  return create(schema.oneOf[0]);
121
121
  })
122
- .with({ type: 'string' }, (schema) => '')
123
- .with({ type: P.union('number', 'integer') }, (schema) => 0)
122
+ .with({ type: 'string' }, (_schema) => '')
123
+ .with({ type: P.union('number', 'integer') }, (_schema) => 0)
124
124
  .with({ type: 'object' }, (schema: JsonSchemaDef) => {
125
125
  let out = validate({ schema, data: data ?? {}, mutate: true });
126
126
  if (!out.success) {
@@ -141,8 +141,8 @@ function create<S>(schema: S, data?: any): TypeOfSchema<S> {
141
141
  return out.data;
142
142
  })
143
143
  .with({ type: 'null' }, () => null)
144
- .with({ type: 'boolean' }, (schema) => false)
145
- .with({ type: 'array' }, (schema) => [])
144
+ .with({ type: 'boolean' }, (_schema) => false)
145
+ .with({ type: 'array' }, (_schema) => [])
146
146
  .otherwise(() => {
147
147
  return undefined;
148
148
  });
@@ -9,7 +9,7 @@ export function forEachJsonSchema(js: JsonSchemaDef, cb: (js: JsonSchemaDef, ctx
9
9
  _f: (js: JsonSchemaDef, ctx: VisitJsonSchemaContext) => void,
10
10
  parent: JsonSchemaDef | undefined,
11
11
  path: string[],
12
- k?: string,
12
+ _k?: string,
13
13
  ) => {
14
14
  if (!js) {
15
15
  return;
@@ -59,7 +59,7 @@ type JsonSchemaFormatName =
59
59
  *
60
60
  * @see https://json-schema.org/specification-links.html
61
61
  */
62
- export type JsonSchemaDef<I = any, O = I> = {
62
+ export type JsonSchemaDef<I = any, _O = I> = {
63
63
  $id?: string;
64
64
  $ref?: string;
65
65
  /**
@@ -30,7 +30,7 @@ export function createMetadataKey<T = never>(a: any, b?: any): MetadataKey<T> {
30
30
 
31
31
  export function defineMetadata<T>(res: HasMetadata, key: MetadataKey<T>, opts: T): void;
32
32
  export function defineMetadata<T>(key: MetadataKey<T>, items: Array<[HasMetadata, T]>): void;
33
- export function defineMetadata<T>(a: any, b: any, c?: any) {
33
+ export function defineMetadata<_T>(a: any, b: any, c?: any) {
34
34
  if (Array.isArray(b)) {
35
35
  const key = a;
36
36
  const items = b;
@@ -43,8 +43,8 @@ export type CreateContractClientOptions = {
43
43
  baseUrl?: string;
44
44
  apiKey?: string;
45
45
  headers?: Record<string, string> | Headers;
46
- getApiKey?: () => string | void;
47
- getHeaders?: (headers: Headers) => Headers | void;
46
+ getApiKey?: () => string | undefined;
47
+ getHeaders?: (headers: Headers) => Headers | undefined;
48
48
  plugins?: StandardLinkPlugin<any>[];
49
49
  fetch?: LinkFetchClientOptions<any>['fetch'];
50
50
  batch?: BatchLinkPluginOptions<any> | boolean;
@@ -99,7 +99,7 @@ export namespace PHC {
99
99
 
100
100
  // Convert Numbers into Numeric Strings and Buffers into B64 encoded strings.
101
101
  pk.forEach((k) => {
102
- const value = opts.params![k];
102
+ const value = opts.params?.[k];
103
103
  if (typeof value === 'number') {
104
104
  opts.params![k] = value.toString();
105
105
  } else if (value instanceof Uint8Array) {
@@ -143,7 +143,7 @@ export namespace PHC {
143
143
  return phcstr;
144
144
  }
145
145
 
146
- interface DeserializeResult {
146
+ export interface DeserializeResult {
147
147
  id: string;
148
148
  version?: number;
149
149
  params?: Record<string, string | number>;
@@ -223,7 +223,7 @@ export namespace PHC {
223
223
 
224
224
  // Convert Decimal Strings into Numbers
225
225
  Object.keys(params).forEach((k) => {
226
- const value = params![k];
226
+ const value = params?.[k];
227
227
  if (typeof value === 'string' && decimalRegex.test(value)) {
228
228
  params![k] = parseInt(value, 10);
229
229
  }
@@ -1,5 +1,5 @@
1
1
  import { maybeFunction, type MaybeFunction, type MaybePromise } from '@wener/utils';
2
- import { Password } from './Password';
2
+ import type { Password } from './Password';
3
3
 
4
4
  type Provide = {
5
5
  hash: (password: string, options: { salt?: Buffer; raw?: boolean; type?: 0 | 1 | 2 }) => Promise<string>;
@@ -1,5 +1,5 @@
1
1
  import { ArrayBuffers } from '@wener/utils';
2
- import { Password } from './Password';
2
+ import type { Password } from './Password';
3
3
 
4
4
  export function createBase64PasswordAlgorithm({ id = 'base64' }: { id?: string } = {}): Password.PasswordAlgorithm {
5
5
  return {
@@ -7,7 +7,7 @@ export function createBase64PasswordAlgorithm({ id = 'base64' }: { id?: string }
7
7
  async hash(password: string) {
8
8
  return `$${id}$$${ArrayBuffers.toBase64(password).replace(/=/g, '')}`;
9
9
  },
10
- async verify(password: string, hash: string, opts) {
10
+ async verify(password: string, _hash: string, opts) {
11
11
  return Boolean(opts.hash) && ArrayBuffers.toString(opts.hash!) === password;
12
12
  },
13
13
  };
@@ -1,5 +1,5 @@
1
1
  import type { MaybePromise } from '@wener/utils';
2
- import { Password } from './Password';
2
+ import type { Password } from './Password';
3
3
 
4
4
  type ProviderType = () => MaybePromise<{
5
5
  hash: (password: string, rounds: number | string) => Promise<string>;
@@ -9,7 +9,9 @@ type ProviderType = () => MaybePromise<{
9
9
  export function createBcryptPasswordAlgorithm({
10
10
  // provider = () => import('bcrypt').then((v) => v.default),
11
11
  provider = () => import('bcryptjs').then((v) => v.default),
12
- }: { provider?: ProviderType } = {}): Password.PasswordAlgorithm {
12
+ }: {
13
+ provider?: ProviderType;
14
+ } = {}): Password.PasswordAlgorithm {
13
15
  // bcrypt or bcryptjs
14
16
  return {
15
17
  name: 'bcrypt',
@@ -1,5 +1,5 @@
1
1
  import { Errors } from '@wener/utils';
2
- import { Password } from './Password';
2
+ import type { Password } from './Password';
3
3
  import { PHC } from './PHC';
4
4
 
5
5
  export function createPBKDF2PasswordAlgorithm({
@@ -55,7 +55,7 @@ export function createPBKDF2PasswordAlgorithm({
55
55
  key,
56
56
  storedHash.length * 8,
57
57
  );
58
- return new Uint8Array(hash).every((v, i) => v === storedHash![i]);
58
+ return new Uint8Array(hash).every((v, i) => v === storedHash?.[i]);
59
59
  },
60
60
  };
61
61
  }
@@ -1,6 +1,6 @@
1
1
  import { randomBytes, scrypt, timingSafeEqual } from 'node:crypto';
2
2
  import { Errors } from '@wener/utils';
3
- import { Password } from './Password';
3
+ import type { Password } from './Password';
4
4
  import { PHC } from './PHC';
5
5
 
6
6
  export function createScryptPasswordAlgorithm(
@@ -14,7 +14,7 @@ export function createScryptPasswordAlgorithm(
14
14
  } = {},
15
15
  ): Password.PasswordAlgorithm {
16
16
  let id = options.id || 'scrypt';
17
- options.cost ||= Math.pow(2, 14);
17
+ options.cost ||= 2 ** 14;
18
18
  options.blocksize ||= 8;
19
19
  options.parallelism ||= 1;
20
20
  options.saltlen ||= 16;
@@ -35,7 +35,7 @@ export function createScryptPasswordAlgorithm(
35
35
  });
36
36
  },
37
37
 
38
- async verify(password: string, hash: string, opts): Promise<boolean> {
38
+ async verify(password: string, _hash: string, opts): Promise<boolean> {
39
39
  try {
40
40
  const salt = Errors.BadRequest.require(opts.salt);
41
41
  const storedHash = Errors.BadRequest.require(opts.hash);
@@ -53,7 +53,7 @@ export function createScryptPasswordAlgorithm(
53
53
  resolve(isMatch);
54
54
  });
55
55
  });
56
- } catch (error) {
56
+ } catch (_error) {
57
57
  return Promise.resolve(false);
58
58
  }
59
59
  },
@@ -25,7 +25,10 @@ export const ListQuerySchema = z.object({
25
25
  deleted: z.coerce.boolean().optional(),
26
26
  });
27
27
 
28
- type ListQueryOverride = ListQueryInput | undefined | ((input: ListQueryInput) => ListQueryInput | undefined | void);
28
+ type ListQueryOverride =
29
+ | ListQueryInput
30
+ | undefined
31
+ | ((input: ListQueryInput) => ListQueryInput | undefined | undefined);
29
32
 
30
33
  export function resolveListQuery(target: ListQueryInput | undefined, ...args: ListQueryOverride[]): ListQuery {
31
34
  let out = args.reduce((a: ListQueryInput, source) => {
@@ -1,4 +1,4 @@
1
- export { type AnyResource } from './schema/AnyResourceSchema';
2
- export { type Identifiable } from './Identifiable';
1
+ export type { AnyResource } from './schema/AnyResourceSchema';
2
+ export type { Identifiable } from './Identifiable';
3
3
  export { getTitleOfResource } from './getTitleOfResource';
4
4
  export { type ListQueryInput, type ListQuery, resolveListQuery, ListQuerySchema } from './ListQuery';
@@ -216,7 +216,7 @@ describe('formatS3Url', () => {
216
216
  endpoint: 's3.amazonaws.com',
217
217
  bucket: 'a'.repeat(64),
218
218
  };
219
- expect(() => formatS3Url(options)).toThrow('Invalid bucket name: ' + 'a'.repeat(64));
219
+ expect(() => formatS3Url(options)).toThrow(`Invalid bucket name: ${'a'.repeat(64)}`);
220
220
  });
221
221
 
222
222
  it('should handle valid bucket names with various formats', () => {
@@ -31,7 +31,7 @@ export function formatS3Url(
31
31
  } else {
32
32
  url = new URL(`https://${ep}`);
33
33
  }
34
- } catch (error) {
34
+ } catch (_error) {
35
35
  throw new Error(`Invalid endpoint: ${ep}`);
36
36
  }
37
37
 
@@ -58,7 +58,7 @@ export function formatS3Url(
58
58
 
59
59
  if (port) {
60
60
  const portNum = Number(port);
61
- if (isNaN(portNum) || portNum < 1 || portNum > 65535) {
61
+ if (Number.isNaN(portNum) || portNum < 1 || portNum > 65535) {
62
62
  throw new Error('Port must be a valid number between 1 and 65535');
63
63
  }
64
64
  url.port = String(portNum);
@@ -27,7 +27,7 @@ export function parseS3Url({ url = process.env.S3_URL, ...rest }: ParseS3UrlOpti
27
27
  let parsed: URL;
28
28
  try {
29
29
  parsed = new URL(normalizedUrl);
30
- } catch (error) {
30
+ } catch (_error) {
31
31
  throw new Error(`Invalid S3 URL: ${url}`);
32
32
  }
33
33
 
@@ -21,7 +21,7 @@ export namespace SchemaRegistry {
21
21
  }
22
22
 
23
23
  function getKey(s: TypeSchema | string) {
24
- let key;
24
+ let key: string | undefined;
25
25
  if (typeof s === 'string') {
26
26
  key = s;
27
27
  } else {
@@ -10,23 +10,23 @@ import type { JsonSchemaDef } from '../jsonschema';
10
10
  export type TypeSchema<I = unknown, O = I> = TSchema | z.ZodSchema<O, I> | JsonSchemaDef | StandardSchemaV1<I, O>;
11
11
 
12
12
  export type SchemaOutput<S extends TypeSchema> =
13
- S extends StandardSchemaV1<infer I, infer O>
13
+ S extends StandardSchemaV1<infer _I, infer O>
14
14
  ? O
15
- : S extends z.ZodSchema<infer O, infer I>
15
+ : S extends z.ZodSchema<infer O, infer _I>
16
16
  ? O
17
17
  : S extends TSchema
18
18
  ? TypeBoxStaticEncode<S>
19
- : S extends JsonSchemaDef<infer I, infer O>
19
+ : S extends JsonSchemaDef<infer _I, infer O>
20
20
  ? O
21
21
  : never;
22
22
 
23
23
  export type SchemaInput<S extends TypeSchema> =
24
- S extends StandardSchemaV1<infer I, infer O>
24
+ S extends StandardSchemaV1<infer I, infer _O>
25
25
  ? I
26
- : S extends z.ZodSchema<infer O, infer I>
26
+ : S extends z.ZodSchema<infer _O, infer I>
27
27
  ? I
28
28
  : S extends TSchema
29
29
  ? TypeBoxStaticDecode<S>
30
- : S extends JsonSchemaDef<infer I, infer O>
30
+ : S extends JsonSchemaDef<infer I, infer _O>
31
31
  ? I
32
32
  : never;
@@ -54,8 +54,8 @@ function _create(schema: JsonSchemaDef, options: CreateOptions, ctx: { required:
54
54
  .with({ oneOf: P.nonNullable }, (schema) => {
55
55
  return _create(schema.oneOf[0], options, { required: false });
56
56
  })
57
- .with({ type: 'string' }, (schema) => '')
58
- .with({ type: P.union('number', 'integer') }, (schema) => 0)
57
+ .with({ type: 'string' }, (_schema) => '')
58
+ .with({ type: P.union('number', 'integer') }, (_schema) => 0)
59
59
  .with({ type: 'object' }, () => {
60
60
  const out: Record<string, any> = {};
61
61
 
@@ -73,8 +73,8 @@ function _create(schema: JsonSchemaDef, options: CreateOptions, ctx: { required:
73
73
  return out;
74
74
  })
75
75
  .with({ type: 'null' }, () => null)
76
- .with({ type: 'boolean' }, (schema) => false)
77
- .with({ type: 'array' }, (schema) => [])
76
+ .with({ type: 'boolean' }, (_schema) => false)
77
+ .with({ type: 'array' }, (_schema) => [])
78
78
  .otherwise(() => {
79
79
  return undefined;
80
80
  });
@@ -14,10 +14,10 @@ export function findJsonSchemaByPath(schema: TypeSchema, objectPath: string) {
14
14
  for (const segment of segments) {
15
15
  // 检查当前 schema 是否是对象类型且有 properties
16
16
  if (
17
- currentSchema
18
- && typeof currentSchema === 'object'
19
- && currentSchema.properties
20
- && currentSchema.properties[segment]
17
+ currentSchema &&
18
+ typeof currentSchema === 'object' &&
19
+ currentSchema.properties &&
20
+ currentSchema.properties[segment]
21
21
  ) {
22
22
  currentSchema = currentSchema.properties[segment];
23
23
  continue;
@@ -181,10 +181,11 @@ describe('formatZodError', () => {
181
181
 
182
182
  it('should use schema description when available', () => {
183
183
  const schema = z.object({
184
- name: z.string().describe('姓名'),
184
+ name: z.string().min(1).describe('姓名'),
185
185
  email: z.string().email().describe('邮箱地址'),
186
186
  });
187
187
 
188
+ // Use empty string for name (triggers min(1) error) and invalid email
188
189
  const result = schema.safeParse({ name: '', email: 'invalid' });
189
190
  expect(result.success).toBe(false);
190
191
  if (!result.success) {