@umijs/preset-umi 4.0.0-beta.10

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 (113) hide show
  1. package/README.md +3 -0
  2. package/assets/umi.png +0 -0
  3. package/compiled/body-parser/LICENSE +23 -0
  4. package/compiled/body-parser/connect/index.d.ts +93 -0
  5. package/compiled/body-parser/index.d.ts +107 -0
  6. package/compiled/body-parser/index.js +129 -0
  7. package/compiled/body-parser/package.json +1 -0
  8. package/compiled/multer/LICENSE +17 -0
  9. package/compiled/multer/body-parser/index.d.ts +104 -0
  10. package/compiled/multer/connect/index.d.ts +93 -0
  11. package/compiled/multer/express/index.d.ts +133 -0
  12. package/compiled/multer/express-serve-static-core/index.d.ts +1252 -0
  13. package/compiled/multer/index.d.ts +321 -0
  14. package/compiled/multer/index.js +41 -0
  15. package/compiled/multer/mime/index.d.ts +35 -0
  16. package/compiled/multer/package.json +1 -0
  17. package/compiled/multer/qs/index.d.ts +62 -0
  18. package/compiled/multer/range-parser/index.d.ts +35 -0
  19. package/compiled/multer/serve-static/index.d.ts +108 -0
  20. package/dist/commands/build.d.ts +3 -0
  21. package/dist/commands/build.js +120 -0
  22. package/dist/commands/config/config.d.ts +3 -0
  23. package/dist/commands/config/config.js +61 -0
  24. package/dist/commands/config/list.d.ts +2 -0
  25. package/dist/commands/config/list.js +34 -0
  26. package/dist/commands/config/remove.d.ts +1 -0
  27. package/dist/commands/config/remove.js +21 -0
  28. package/dist/commands/config/set.d.ts +1 -0
  29. package/dist/commands/config/set.js +21 -0
  30. package/dist/commands/dev/createRouteMiddleware.d.ts +5 -0
  31. package/dist/commands/dev/createRouteMiddleware.js +35 -0
  32. package/dist/commands/dev/dev.d.ts +3 -0
  33. package/dist/commands/dev/dev.js +269 -0
  34. package/dist/commands/dev/faviconMiddleware.d.ts +2 -0
  35. package/dist/commands/dev/faviconMiddleware.js +13 -0
  36. package/dist/commands/dev/getBabelOpts.d.ts +20 -0
  37. package/dist/commands/dev/getBabelOpts.js +57 -0
  38. package/dist/commands/dev/getMarkupArgs.d.ts +13 -0
  39. package/dist/commands/dev/getMarkupArgs.js +73 -0
  40. package/dist/commands/dev/watch.d.ts +19 -0
  41. package/dist/commands/dev/watch.js +55 -0
  42. package/dist/commands/generate/page.d.ts +3 -0
  43. package/dist/commands/generate/page.js +44 -0
  44. package/dist/commands/generate/prettier.d.ts +3 -0
  45. package/dist/commands/generate/prettier.js +31 -0
  46. package/dist/commands/help.d.ts +3 -0
  47. package/dist/commands/help.js +61 -0
  48. package/dist/commands/plugin.d.ts +3 -0
  49. package/dist/commands/plugin.js +38 -0
  50. package/dist/commands/setup.d.ts +3 -0
  51. package/dist/commands/setup.js +20 -0
  52. package/dist/commands/version.d.ts +3 -0
  53. package/dist/commands/version.js +16 -0
  54. package/dist/constants.d.ts +4 -0
  55. package/dist/constants.js +8 -0
  56. package/dist/features/__sample.d.ts +3 -0
  57. package/dist/features/__sample.js +5 -0
  58. package/dist/features/appData/appData.d.ts +3 -0
  59. package/dist/features/appData/appData.js +30 -0
  60. package/dist/features/check/check.d.ts +3 -0
  61. package/dist/features/check/check.js +34 -0
  62. package/dist/features/configPlugins/configPlugins.d.ts +3 -0
  63. package/dist/features/configPlugins/configPlugins.js +61 -0
  64. package/dist/features/configPlugins/schema.d.ts +2 -0
  65. package/dist/features/configPlugins/schema.js +16 -0
  66. package/dist/features/esmi/esmi.d.ts +3 -0
  67. package/dist/features/esmi/esmi.js +44 -0
  68. package/dist/features/favicon/favicon.d.ts +3 -0
  69. package/dist/features/favicon/favicon.js +58 -0
  70. package/dist/features/lowImport/babelPlugin.d.ts +17 -0
  71. package/dist/features/lowImport/babelPlugin.js +68 -0
  72. package/dist/features/lowImport/lowImport.d.ts +9 -0
  73. package/dist/features/lowImport/lowImport.js +108 -0
  74. package/dist/features/mock/constants.d.ts +3 -0
  75. package/dist/features/mock/constants.js +14 -0
  76. package/dist/features/mock/createMockMiddleware.d.ts +7 -0
  77. package/dist/features/mock/createMockMiddleware.js +82 -0
  78. package/dist/features/mock/getMockData.d.ts +9 -0
  79. package/dist/features/mock/getMockData.js +61 -0
  80. package/dist/features/mock/mock.d.ts +2 -0
  81. package/dist/features/mock/mock.js +50 -0
  82. package/dist/features/polyfill/polyfill.d.ts +3 -0
  83. package/dist/features/polyfill/polyfill.js +14 -0
  84. package/dist/features/tmpFiles/importsToStr.d.ts +4 -0
  85. package/dist/features/tmpFiles/importsToStr.js +16 -0
  86. package/dist/features/tmpFiles/routes.d.ts +8 -0
  87. package/dist/features/tmpFiles/routes.js +74 -0
  88. package/dist/features/tmpFiles/tmpFiles.d.ts +3 -0
  89. package/dist/features/tmpFiles/tmpFiles.js +124 -0
  90. package/dist/features/transform/babelPlugin.d.ts +11 -0
  91. package/dist/features/transform/babelPlugin.js +118 -0
  92. package/dist/features/transform/transform.d.ts +3 -0
  93. package/dist/features/transform/transform.js +29 -0
  94. package/dist/index.d.ts +5 -0
  95. package/dist/index.js +30 -0
  96. package/dist/libs/moduleGraph.d.ts +2 -0
  97. package/dist/libs/moduleGraph.js +6 -0
  98. package/dist/libs/scan.d.ts +28 -0
  99. package/dist/libs/scan.js +110 -0
  100. package/dist/registerMethods.d.ts +3 -0
  101. package/dist/registerMethods.js +89 -0
  102. package/dist/types.d.ts +147 -0
  103. package/dist/types.js +2 -0
  104. package/dist/utils/clearTmp.d.ts +1 -0
  105. package/dist/utils/clearTmp.js +17 -0
  106. package/dist/utils/isTypeScriptFile.d.ts +1 -0
  107. package/dist/utils/isTypeScriptFile.js +7 -0
  108. package/package.json +62 -0
  109. package/templates/generate/page/index.less.tpl +4 -0
  110. package/templates/generate/page/index.tsx.tpl +10 -0
  111. package/templates/plugin.tpl +18 -0
  112. package/templates/route.tpl +7 -0
  113. package/templates/umi.tpl +22 -0
@@ -0,0 +1,321 @@
1
+ // Type definitions for multer 1.4
2
+ // Project: https://github.com/expressjs/multer
3
+ // Definitions by: jt000 <https://github.com/jt000>
4
+ // vilicvane <https://github.com/vilic>
5
+ // David Broder-Rodgers <https://github.com/DavidBR-SW>
6
+ // Michael Ledin <https://github.com/mxl>
7
+ // HyunSeob Lee <https://github.com/hyunseob>
8
+ // Pierre Tchuente <https://github.com/PierreTchuente>
9
+ // Oliver Emery <https://github.com/thrymgjol>
10
+ // Piotr Błażejewicz <https://github.com/peterblazejewicz>
11
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
12
+ import { Request, RequestHandler } from './express';
13
+ import { Readable } from 'stream';
14
+
15
+ declare global {
16
+ namespace Express {
17
+ namespace Multer {
18
+ /** Object containing file metadata and access information. */
19
+ interface File {
20
+ /** Name of the form field associated with this file. */
21
+ fieldname: string;
22
+ /** Name of the file on the uploader's computer. */
23
+ originalname: string;
24
+ /**
25
+ * Value of the `Content-Transfer-Encoding` header for this file.
26
+ * @deprecated since July 2015
27
+ * @see RFC 7578, Section 4.7
28
+ */
29
+ encoding: string;
30
+ /** Value of the `Content-Type` header for this file. */
31
+ mimetype: string;
32
+ /** Size of the file in bytes. */
33
+ size: number;
34
+ /**
35
+ * A readable stream of this file. Only available to the `_handleFile`
36
+ * callback for custom `StorageEngine`s.
37
+ */
38
+ stream: Readable;
39
+ /** `DiskStorage` only: Directory to which this file has been uploaded. */
40
+ destination: string;
41
+ /** `DiskStorage` only: Name of this file within `destination`. */
42
+ filename: string;
43
+ /** `DiskStorage` only: Full path to the uploaded file. */
44
+ path: string;
45
+ /** `MemoryStorage` only: A Buffer containing the entire file. */
46
+ buffer: Buffer;
47
+ }
48
+ }
49
+
50
+ interface Request {
51
+ /** `Multer.File` object populated by `single()` middleware. */
52
+ file?: Multer.File | undefined;
53
+ /**
54
+ * Array or dictionary of `Multer.File` object populated by `array()`,
55
+ * `fields()`, and `any()` middleware.
56
+ */
57
+ files?: {
58
+ [fieldname: string]: Multer.File[];
59
+ } | Multer.File[] | undefined;
60
+ }
61
+ }
62
+ }
63
+
64
+ /**
65
+ * Returns a Multer instance that provides several methods for generating
66
+ * middleware that process files uploaded in `multipart/form-data` format.
67
+ *
68
+ * The `StorageEngine` specified in `storage` will be used to store files. If
69
+ * `storage` is not set and `dest` is, files will be stored in `dest` on the
70
+ * local file system with random names. If neither are set, files will be stored
71
+ * in memory.
72
+ *
73
+ * In addition to files, all generated middleware process all text fields in
74
+ * the request. For each non-file field, the `Request.body` object will be
75
+ * populated with an entry mapping the field name to its string value, or array
76
+ * of string values if multiple fields share the same name.
77
+ */
78
+ declare function multer(options?: multer.Options): multer.Multer;
79
+
80
+ declare namespace multer {
81
+ /**
82
+ * @see {@link https://github.com/expressjs/multer#api}
83
+ */
84
+ interface Multer {
85
+ /**
86
+ * Returns middleware that processes a single file associated with the
87
+ * given form field.
88
+ *
89
+ * The `Request` object will be populated with a `file` object containing
90
+ * information about the processed file.
91
+ *
92
+ * @param fieldName Name of the multipart form field to process.
93
+ */
94
+ single(fieldName: string): RequestHandler;
95
+ /**
96
+ * Returns middleware that processes multiple files sharing the same field
97
+ * name.
98
+ *
99
+ * The `Request` object will be populated with a `files` array containing
100
+ * an information object for each processed file.
101
+ *
102
+ * @param fieldName Shared name of the multipart form fields to process.
103
+ * @param maxCount Optional. Maximum number of files to process. (default: Infinity)
104
+ * @throws `MulterError('LIMIT_UNEXPECTED_FILE')` if more than `maxCount` files are associated with `fieldName`
105
+ */
106
+ array(fieldName: string, maxCount?: number): RequestHandler;
107
+ /**
108
+ * Returns middleware that processes multiple files associated with the
109
+ * given form fields.
110
+ *
111
+ * The `Request` object will be populated with a `files` object which
112
+ * maps each field name to an array of the associated file information
113
+ * objects.
114
+ *
115
+ * @param fields Array of `Field` objects describing multipart form fields to process.
116
+ * @throws `MulterError('LIMIT_UNEXPECTED_FILE')` if more than `maxCount` files are associated with `fieldName` for any field.
117
+ */
118
+ fields(fields: ReadonlyArray<Field>): RequestHandler;
119
+ /**
120
+ * Returns middleware that processes all files contained in the multipart
121
+ * request.
122
+ *
123
+ * The `Request` object will be populated with a `files` array containing
124
+ * an information object for each processed file.
125
+ */
126
+ any(): RequestHandler;
127
+ /**
128
+ * Returns middleware that accepts only non-file multipart form fields.
129
+ *
130
+ * @throws `MulterError('LIMIT_UNEXPECTED_FILE')` if any file is encountered.
131
+ */
132
+ none(): RequestHandler;
133
+ }
134
+
135
+ /**
136
+ * Returns a `StorageEngine` implementation configured to store files on
137
+ * the local file system.
138
+ *
139
+ * A string or function may be specified to determine the destination
140
+ * directory, and a function to determine filenames. If no options are set,
141
+ * files will be stored in the system's temporary directory with random 32
142
+ * character filenames.
143
+ */
144
+ function diskStorage(options: DiskStorageOptions): StorageEngine;
145
+
146
+ /**
147
+ * Returns a `StorageEngine` implementation configured to store files in
148
+ * memory as `Buffer` objects.
149
+ */
150
+ function memoryStorage(): StorageEngine;
151
+
152
+ type ErrorCode =
153
+ | 'LIMIT_PART_COUNT'
154
+ | 'LIMIT_FILE_SIZE'
155
+ | 'LIMIT_FILE_COUNT'
156
+ | 'LIMIT_FIELD_KEY'
157
+ | 'LIMIT_FIELD_VALUE'
158
+ | 'LIMIT_FIELD_COUNT'
159
+ | 'LIMIT_UNEXPECTED_FILE';
160
+
161
+ class MulterError extends Error {
162
+ constructor(code: ErrorCode, field?: string);
163
+ /** Name of the MulterError constructor. */
164
+ name: string;
165
+ /** Identifying error code. */
166
+ code: ErrorCode;
167
+ /** Descriptive error message. */
168
+ message: string;
169
+ /** Name of the multipart form field associated with this error. */
170
+ field?: string | undefined;
171
+ }
172
+
173
+ /**
174
+ * a function to control which files should be uploaded and which should be skipped
175
+ * pass a boolean to indicate if the file should be accepted
176
+ * pass an error if something goes wrong
177
+ */
178
+ interface FileFilterCallback {
179
+ (error: Error): void;
180
+ (error: null, acceptFile: boolean): void;
181
+ }
182
+
183
+ /** Options for initializing a Multer instance. */
184
+ interface Options {
185
+ /**
186
+ * A `StorageEngine` responsible for processing files uploaded via Multer.
187
+ * Takes precedence over `dest`.
188
+ */
189
+ storage?: StorageEngine | undefined;
190
+ /**
191
+ * The destination directory for uploaded files. If `storage` is not set
192
+ * and `dest` is, Multer will create a `DiskStorage` instance configured
193
+ * to store files at `dest` with random filenames.
194
+ *
195
+ * Ignored if `storage` is set.
196
+ */
197
+ dest?: string | undefined;
198
+ /**
199
+ * An object specifying various limits on incoming data. This object is
200
+ * passed to Busboy directly, and the details of properties can be found
201
+ * at https://github.com/mscdex/busboy#busboy-methods.
202
+ */
203
+ limits?: {
204
+ /** Maximum size of each form field name in bytes. (Default: 100) */
205
+ fieldNameSize?: number | undefined;
206
+ /** Maximum size of each form field value in bytes. (Default: 1048576) */
207
+ fieldSize?: number | undefined;
208
+ /** Maximum number of non-file form fields. (Default: Infinity) */
209
+ fields?: number | undefined;
210
+ /** Maximum size of each file in bytes. (Default: Infinity) */
211
+ fileSize?: number | undefined;
212
+ /** Maximum number of file fields. (Default: Infinity) */
213
+ files?: number | undefined;
214
+ /** Maximum number of parts (non-file fields + files). (Default: Infinity) */
215
+ parts?: number | undefined;
216
+ /** Maximum number of headers. (Default: 2000) */
217
+ headerPairs?: number | undefined;
218
+ } | undefined;
219
+ /** Preserve the full path of the original filename rather than the basename. (Default: false) */
220
+ preservePath?: boolean | undefined;
221
+ /**
222
+ * Optional function to control which files are uploaded. This is called
223
+ * for every file that is processed.
224
+ *
225
+ * @param req The Express `Request` object.
226
+ * @param file Object containing information about the processed file.
227
+ * @param callback a function to control which files should be uploaded and which should be skipped.
228
+ */
229
+ fileFilter?(
230
+ req: Request,
231
+ file: Express.Multer.File,
232
+ callback: FileFilterCallback,
233
+ ): void;
234
+ }
235
+
236
+ /**
237
+ * Implementations of this interface are responsible for storing files
238
+ * encountered by Multer and returning information on how to access them
239
+ * once stored. Implementations must also provide a method for removing
240
+ * files in the event that an error occurs.
241
+ */
242
+ interface StorageEngine {
243
+ /**
244
+ * Store the file described by `file`, then invoke the callback with
245
+ * information about the stored file.
246
+ *
247
+ * File contents are available as a stream via `file.stream`. Information
248
+ * passed to the callback will be merged with `file` for subsequent
249
+ * middleware.
250
+ *
251
+ * @param req The Express `Request` object.
252
+ * @param file Object with `stream`, `fieldname`, `originalname`, `encoding`, and `mimetype` defined.
253
+ * @param callback Callback to specify file information.
254
+ */
255
+ _handleFile(
256
+ req: Request,
257
+ file: Express.Multer.File,
258
+ callback: (error?: any, info?: Partial<Express.Multer.File>) => void
259
+ ): void;
260
+ /**
261
+ * Remove the file described by `file`, then invoke the callback with.
262
+ *
263
+ * `file` contains all the properties available to `_handleFile`, as
264
+ * well as those returned by `_handleFile`.
265
+ *
266
+ * @param req The Express `Request` object.
267
+ * @param file Object containing information about the processed file.
268
+ * @param callback Callback to indicate completion.
269
+ */
270
+ _removeFile(
271
+ req: Request,
272
+ file: Express.Multer.File,
273
+ callback: (error: Error | null) => void
274
+ ): void;
275
+ }
276
+
277
+ interface DiskStorageOptions {
278
+ /**
279
+ * A string or function that determines the destination path for uploaded
280
+ * files. If a string is passed and the directory does not exist, Multer
281
+ * attempts to create it recursively. If neither a string or a function
282
+ * is passed, the destination defaults to `os.tmpdir()`.
283
+ *
284
+ * @param req The Express `Request` object.
285
+ * @param file Object containing information about the processed file.
286
+ * @param callback Callback to determine the destination path.
287
+ */
288
+ destination?: string | ((
289
+ req: Request,
290
+ file: Express.Multer.File,
291
+ callback: (error: Error | null, destination: string) => void
292
+ ) => void) | undefined;
293
+ /**
294
+ * A function that determines the name of the uploaded file. If nothing
295
+ * is passed, Multer will generate a 32 character pseudorandom hex string
296
+ * with no extension.
297
+ *
298
+ * @param req The Express `Request` object.
299
+ * @param file Object containing information about the processed file.
300
+ * @param callback Callback to determine the name of the uploaded file.
301
+ */
302
+ filename?(
303
+ req: Request,
304
+ file: Express.Multer.File,
305
+ callback: (error: Error | null, filename: string) => void
306
+ ): void;
307
+ }
308
+
309
+ /**
310
+ * An object describing a field name and the maximum number of files with
311
+ * that field name to accept.
312
+ */
313
+ interface Field {
314
+ /** The field name. */
315
+ name: string;
316
+ /** Optional maximum number of files per field to accept. (Default: Infinity) */
317
+ maxCount?: number | undefined;
318
+ }
319
+ }
320
+
321
+ export = multer;