@ddd-ts-kit/http 0.111.0 → 0.112.0
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/README.fr.md +47 -2
- package/README.md +46 -1
- package/dist/controller/declared-route.d.ts.map +1 -1
- package/dist/controller/declared-route.js +9 -0
- package/dist/controller/declared-route.js.map +1 -1
- package/dist/openapi/request-body.js +11 -1
- package/dist/openapi/request-body.js.map +1 -1
- package/dist/route/define-route.d.ts.map +1 -1
- package/dist/route/define-route.js +9 -0
- package/dist/route/define-route.js.map +1 -1
- package/dist/route/upload-defects.d.ts +7 -0
- package/dist/route/upload-defects.d.ts.map +1 -0
- package/dist/route/upload-defects.js +11 -0
- package/dist/route/upload-defects.js.map +1 -0
- package/dist/route/upload-spec.d.ts +21 -3
- package/dist/route/upload-spec.d.ts.map +1 -1
- package/dist/uploads/read-multipart.js +9 -1
- package/dist/uploads/read-multipart.js.map +1 -1
- package/package.json +4 -4
package/README.fr.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[English](README.md) · **Français**
|
|
2
|
-
<!-- translation-of: README.md sha256:
|
|
2
|
+
<!-- translation-of: README.md sha256:c1e19772dde9e37c -->
|
|
3
3
|
|
|
4
4
|
# @ddd-ts-kit/http
|
|
5
5
|
|
|
@@ -1877,11 +1877,56 @@ lue ; un formulaire sans le fichier, 422. Les champs texte envoyés après le fi
|
|
|
1877
1877
|
lus. `fileName` est montré aux personnes, jamais utilisé comme clé : la clé est générée sur le
|
|
1878
1878
|
serveur.
|
|
1879
1879
|
|
|
1880
|
+
Chaque type de média de `mediaTypes` a une règle de contenu. Le kit en a une pour les formats
|
|
1881
|
+
qu'il reconnaît à leurs premiers octets (PDF, PNG, JPEG, GIF, WebP, zip et les documents
|
|
1882
|
+
bureautiques, gzip) et pour le texte (`text/plain`, `text/csv`, `text/tab-separated-values`,
|
|
1883
|
+
`text/markdown`, `application/json`, `application/csv`). Pour tout autre type, la route
|
|
1884
|
+
l'énonce dans `contentRules` : `text`, le contenu est du texte sous un autre nom, ou
|
|
1885
|
+
`unchecked`, la route prend les octets tels quels. Un type sans règle ne pourrait recevoir aucun
|
|
1886
|
+
fichier, alors la déclaration est refusée quand la route est déclarée (`@Controller`,
|
|
1887
|
+
`defineRoute`, les routes d'un contrôleur Nest), avec le type et les règles qu'elle peut
|
|
1888
|
+
énoncer, et `ddd-ts-kit check` le signale (`files/upload-content-rule`).
|
|
1889
|
+
|
|
1890
|
+
Le texte est de l'UTF-8 valide par défaut. Une route qui reçoit des exports en Windows-1252 ou
|
|
1891
|
+
en ISO-8859-1 dit `text: 'single-byte'` : l'UTF-8 et tout encodage sur un octet passent, un
|
|
1892
|
+
fichier binaire sous le nom d'un CSV est toujours refusé, l'UTF-16 et l'UTF-32 aussi. Le
|
|
1893
|
+
gestionnaire reçoit les octets tels qu'ils sont arrivés et les décode lui-même ; `isUtf8` du
|
|
1894
|
+
kernel dit lequel des deux il tient. Le charset qu'un client peut écrire sur la partie n'est
|
|
1895
|
+
pas transmis : les navigateurs n'en envoient pas, et busboy ne l'expose pas.
|
|
1896
|
+
|
|
1897
|
+
<!-- checked sample -->
|
|
1898
|
+
```ts
|
|
1899
|
+
import type { UploadSpec } from '@ddd-ts-kit/http';
|
|
1900
|
+
import { isUtf8 } from '@ddd-ts-kit/kernel';
|
|
1901
|
+
|
|
1902
|
+
/** The statement of a bank: a CSV under the names browsers give it, in UTF-8 or in a single-byte encoding. */
|
|
1903
|
+
export const statement: UploadSpec = {
|
|
1904
|
+
field: 'statement',
|
|
1905
|
+
maxBytes: 5_000_000,
|
|
1906
|
+
mediaTypes: ['text/csv', 'application/csv', 'application/vnd.ms-excel'],
|
|
1907
|
+
text: 'single-byte',
|
|
1908
|
+
contentRules: { 'application/vnd.ms-excel': 'text' },
|
|
1909
|
+
};
|
|
1910
|
+
|
|
1911
|
+
/** Bytes of any kind, which the route takes as they are and says so. */
|
|
1912
|
+
export const attachment: UploadSpec = {
|
|
1913
|
+
field: 'attachment',
|
|
1914
|
+
maxBytes: 50_000_000,
|
|
1915
|
+
mediaTypes: ['application/pdf', 'application/octet-stream'],
|
|
1916
|
+
contentRules: { 'application/octet-stream': 'unchecked' },
|
|
1917
|
+
};
|
|
1918
|
+
|
|
1919
|
+
export function decoded(bytes: Uint8Array): string {
|
|
1920
|
+
return new TextDecoder(isUtf8(bytes) ? 'utf-8' : 'windows-1252').decode(bytes);
|
|
1921
|
+
}
|
|
1922
|
+
```
|
|
1923
|
+
|
|
1880
1924
|
Pour un gros fichier, le client téléverse plutôt directement vers le stockage : une commande
|
|
1881
1925
|
signe un lien de téléversement (`FileStaging.uploadUrl`) et enregistre sur l'agrégat
|
|
1882
1926
|
l'autorisation qu'il renvoie, le client envoie le fichier au lien, et une deuxième commande
|
|
1883
1927
|
confirme à partir de cette autorisation (`FileStaging.confirm(pending)`, qui contrôle la taille
|
|
1884
|
-
et le type de média de ce qui est
|
|
1928
|
+
et le type de média de ce qui est arrivé, sous la règle `text` et les `contentRules` données à
|
|
1929
|
+
`uploadUrl`). Un client qui coupe la connexion en cours de route
|
|
1885
1930
|
fait échouer le flux du fichier, si bien qu'un gestionnaire qui l'attend est rejeté au lieu
|
|
1886
1931
|
d'attendre sans fin.
|
|
1887
1932
|
|
package/README.md
CHANGED
|
@@ -1802,10 +1802,55 @@ far larger than the file allowed is refused before it is read; a form without th
|
|
|
1802
1802
|
Text fields sent after the file are not read. `fileName` is shown back to people, never used as
|
|
1803
1803
|
a key: the key is generated on the server.
|
|
1804
1804
|
|
|
1805
|
+
Each media type of `mediaTypes` has a content rule. The kit has one for the formats it
|
|
1806
|
+
recognises by their first bytes (PDF, PNG, JPEG, GIF, WebP, zip and the office documents, gzip)
|
|
1807
|
+
and for text (`text/plain`, `text/csv`, `text/tab-separated-values`, `text/markdown`,
|
|
1808
|
+
`application/json`, `application/csv`). For any other type the route states it in
|
|
1809
|
+
`contentRules`: `text`, the content is text under another name, or `unchecked`, the route takes
|
|
1810
|
+
the bytes as they are. A type with no rule could receive no file, so the declaration is refused
|
|
1811
|
+
when the route is declared (`@Controller`, `defineRoute`, the routes of a Nest controller), with
|
|
1812
|
+
the type and the rules it may state, and `ddd-ts-kit check` reports it
|
|
1813
|
+
(`files/upload-content-rule`).
|
|
1814
|
+
|
|
1815
|
+
Text is valid UTF-8 by default. A route that receives exports in Windows-1252 or ISO-8859-1
|
|
1816
|
+
says `text: 'single-byte'`: UTF-8 and any single-byte encoding pass, a binary file under the
|
|
1817
|
+
name of a CSV is still refused, and so are UTF-16 and UTF-32. The handler receives the bytes as
|
|
1818
|
+
they came and decodes them itself; `isUtf8` of the kernel tells which it holds. The charset a
|
|
1819
|
+
client may write on the part is not handed over: browsers send none, and busboy does not expose
|
|
1820
|
+
it.
|
|
1821
|
+
|
|
1822
|
+
<!-- checked sample -->
|
|
1823
|
+
```ts
|
|
1824
|
+
import type { UploadSpec } from '@ddd-ts-kit/http';
|
|
1825
|
+
import { isUtf8 } from '@ddd-ts-kit/kernel';
|
|
1826
|
+
|
|
1827
|
+
/** The statement of a bank: a CSV under the names browsers give it, in UTF-8 or in a single-byte encoding. */
|
|
1828
|
+
export const statement: UploadSpec = {
|
|
1829
|
+
field: 'statement',
|
|
1830
|
+
maxBytes: 5_000_000,
|
|
1831
|
+
mediaTypes: ['text/csv', 'application/csv', 'application/vnd.ms-excel'],
|
|
1832
|
+
text: 'single-byte',
|
|
1833
|
+
contentRules: { 'application/vnd.ms-excel': 'text' },
|
|
1834
|
+
};
|
|
1835
|
+
|
|
1836
|
+
/** Bytes of any kind, which the route takes as they are and says so. */
|
|
1837
|
+
export const attachment: UploadSpec = {
|
|
1838
|
+
field: 'attachment',
|
|
1839
|
+
maxBytes: 50_000_000,
|
|
1840
|
+
mediaTypes: ['application/pdf', 'application/octet-stream'],
|
|
1841
|
+
contentRules: { 'application/octet-stream': 'unchecked' },
|
|
1842
|
+
};
|
|
1843
|
+
|
|
1844
|
+
export function decoded(bytes: Uint8Array): string {
|
|
1845
|
+
return new TextDecoder(isUtf8(bytes) ? 'utf-8' : 'windows-1252').decode(bytes);
|
|
1846
|
+
}
|
|
1847
|
+
```
|
|
1848
|
+
|
|
1805
1849
|
For a large file, the client uploads straight to the storage instead: a command signs an upload
|
|
1806
1850
|
link (`FileStaging.uploadUrl`) and records the grant it answers on the aggregate, the client
|
|
1807
1851
|
sends the file to the link, and a second command confirms from that grant
|
|
1808
|
-
(`FileStaging.confirm(pending)`, which checks the size and the media type on what arrived
|
|
1852
|
+
(`FileStaging.confirm(pending)`, which checks the size and the media type on what arrived, under
|
|
1853
|
+
the `text` rule and the `contentRules` given to `uploadUrl`). A
|
|
1809
1854
|
client that drops the connection part-way fails the file stream, so a handler waiting on it
|
|
1810
1855
|
rejects instead of waiting forever.
|
|
1811
1856
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declared-route.d.ts","sourceRoot":"","sources":["../../src/controller/declared-route.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"declared-route.d.ts","sourceRoot":"","sources":["../../src/controller/declared-route.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAKxD,qEAAqE;AACrE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC;IAC3C,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,qFAAqF;IACrF,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,8FAA8F;IAC9F,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;CAC9B;AAeD,gGAAgG;AAChG,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,aAAa,CAoBpF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DeclarationError } from '@ddd-ts-kit/kernel/declarations';
|
|
2
2
|
import { ROUTE_PATH_PATTERN } from '../route/route-path-pattern.js';
|
|
3
|
+
import { uploadDefects } from '../route/upload-defects.js';
|
|
3
4
|
import { Public } from './guards/public.js';
|
|
4
5
|
import { presentationRegistry } from './presentation-registry.js';
|
|
5
6
|
const NOTHING = { groups: [], prefix: '', tags: [], guards: [], errors: [] };
|
|
@@ -14,6 +15,7 @@ export function declaredRoute(className, spec) {
|
|
|
14
15
|
assertPath(className, spec.path, path);
|
|
15
16
|
assertAccess(className, guards);
|
|
16
17
|
assertRawBody(className, spec);
|
|
18
|
+
assertUpload(className, spec);
|
|
17
19
|
return {
|
|
18
20
|
path,
|
|
19
21
|
operationId: spec.operationId ?? operationIdOf(className),
|
|
@@ -65,6 +67,13 @@ function assertRawBody(className, spec) {
|
|
|
65
67
|
throw new DeclarationError(`Controller ${className} declares rawBody and ${reading.join(', ')}: the body is left unparsed, so nothing reads it. Parse the bytes in handle after checking them, or drop rawBody.`);
|
|
66
68
|
}
|
|
67
69
|
}
|
|
70
|
+
/** An upload whose media types no content could prove receives no file: said when the route is declared, not by a 415 to each client. */
|
|
71
|
+
function assertUpload(className, { upload }) {
|
|
72
|
+
const defects = uploadDefects(upload);
|
|
73
|
+
if (defects.length > 0) {
|
|
74
|
+
throw new DeclarationError(`Controller ${className} declares an upload it cannot receive: ${defects.join(' ')}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
68
77
|
function operationIdOf(className) {
|
|
69
78
|
const name = className.replace(/Controller$/, '');
|
|
70
79
|
return `${name.charAt(0).toLowerCase()}${name.slice(1)}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declared-route.js","sourceRoot":"","sources":["../../src/controller/declared-route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"declared-route.js","sourceRoot":"","sources":["../../src/controller/declared-route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAyB/D,MAAM,OAAO,GAAc,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;AACxF,kGAAkG;AAClG,MAAM,KAAK,GAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAEjD,gGAAgG;AAChG,MAAM,UAAU,aAAa,CAAC,SAAiB,EAAE,IAAoB;IACnE,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5F,MAAM,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC;IAC7D,MAAM,IAAI,GAAG,GAAG,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,I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,SAAS,aAAa,CAAC,SAAiB;IACtC,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;IAElD,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3D,CAAC;AAED,SAAS,QAAQ,CAAC,MAAyB;IACzC,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -36,9 +36,11 @@ function multipartBody(upload, fields) {
|
|
|
36
36
|
[upload.field]: {
|
|
37
37
|
type: 'string',
|
|
38
38
|
contentMediaType: 'application/octet-stream',
|
|
39
|
-
description: `The file: ${types}, at most ${String(upload.maxBytes)} bytes, its type checked on its content
|
|
39
|
+
description: `The file: ${types}, at most ${String(upload.maxBytes)} bytes, its type checked on its content.${textOf(upload)}${uncheckedOf(upload)}`,
|
|
40
40
|
'x-max-bytes': upload.maxBytes,
|
|
41
41
|
'x-media-types': [...upload.mediaTypes],
|
|
42
|
+
...(upload.text === undefined ? {} : { 'x-text': upload.text }),
|
|
43
|
+
...(upload.contentRules === undefined ? {} : { 'x-content-rules': { ...upload.contentRules } }),
|
|
42
44
|
},
|
|
43
45
|
},
|
|
44
46
|
required: [upload.field],
|
|
@@ -54,4 +56,12 @@ function multipartBody(upload, fields) {
|
|
|
54
56
|
},
|
|
55
57
|
};
|
|
56
58
|
}
|
|
59
|
+
/** What a client may send as text, when the route takes more than UTF-8. */
|
|
60
|
+
function textOf({ text }) {
|
|
61
|
+
return text === 'single-byte' ? ' Text is UTF-8 or a single-byte encoding such as Windows-1252.' : '';
|
|
62
|
+
}
|
|
63
|
+
function uncheckedOf({ contentRules = {} }) {
|
|
64
|
+
const unchecked = Object.keys(contentRules).filter((type) => contentRules[type] === 'unchecked');
|
|
65
|
+
return unchecked.length === 0 ? '' : ` Taken as sent, its content not checked: ${unchecked.join(', ')}.`;
|
|
66
|
+
}
|
|
57
67
|
//# sourceMappingURL=request-body.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-body.js","sourceRoot":"","sources":["../../src/openapi/request-body.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAY,EAAE,EAAE,WAAW,EAAE,eAAe,EAAe;IACrF,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC;IACjC,MAAM,MAAM,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAExE,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,aAAa,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAC3B,OAAO,OAAO,EAAE,CAAC;IACnB,CAAC;IAED,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,UAAU,GAAG,CAAC,kBAAkB,EAAE,GAAG,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAE1G,OAAO;QACL,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,SAAS,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;KAC5F,CAAC;AACJ,CAAC;AAED,sFAAsF;AACtF,SAAS,OAAO;IACd,OAAO;QACL,QAAQ,EAAE,IAAI;QACd,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define-route.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"define-route.d.ts","sourceRoot":"","sources":["../../src/route/define-route.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGrC,wBAAgB,WAAW,CAAC,KAAK,CAAC,OAAO,SAAS,cAAc,EAAE,KAAK,CAAC,SAAS,SAAS,aAAa,EACrG,IAAI,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,EACnC,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,GACxC,KAAK,CAYP"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { assertCacheDeclaration } from '../cache/assert-cache-declaration.js';
|
|
2
2
|
import { ROUTE_PATH_PATTERN } from './route-path-pattern.js';
|
|
3
|
+
import { uploadDefects } from './upload-defects.js';
|
|
3
4
|
export function defineRoute(spec, handler) {
|
|
4
5
|
if (!ROUTE_PATH_PATTERN.test(spec.path)) {
|
|
5
6
|
throw new Error(`Route "${spec.operationId}": the path "${spec.path}" must be made of literal segments and ":name" parameters.`);
|
|
6
7
|
}
|
|
7
8
|
assertSecurityDeclared(spec);
|
|
8
9
|
assertCacheDeclaration(spec);
|
|
10
|
+
assertUploadReceivable(spec);
|
|
9
11
|
return { ...spec, handle: handler };
|
|
10
12
|
}
|
|
11
13
|
// Checked at run time too: a JavaScript caller, or a spec built dynamically, gets no compile error.
|
|
@@ -16,4 +18,11 @@ function assertSecurityDeclared(spec) {
|
|
|
16
18
|
}
|
|
17
19
|
throw new Error(`Route "${spec.operationId}": declare "security" with the names of its security schemes, or false for a public route.`);
|
|
18
20
|
}
|
|
21
|
+
/** An upload whose media types no content could prove receives no file: said when the route is defined, not by a 415 to each client. */
|
|
22
|
+
function assertUploadReceivable({ operationId, upload }) {
|
|
23
|
+
const defects = uploadDefects(upload);
|
|
24
|
+
if (defects.length > 0) {
|
|
25
|
+
throw new Error(`Route "${operationId}" declares an upload it cannot receive: ${defects.join(' ')}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
19
28
|
//# sourceMappingURL=define-route.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-route.js","sourceRoot":"","sources":["../../src/route/define-route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAG3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"define-route.js","sourceRoot":"","sources":["../../src/route/define-route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAG3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAI1D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,UAAU,WAAW,CACzB,IAAmC,EACnC,OAAyC;IAEzC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACb,UAAU,IAAI,CAAC,WAAW,gBAAgB,IAAI,CAAC,IAAI,4DAA4D,CAChH,CAAC;IACJ,CAAC;IAED,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAC7B,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAC7B,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAE7B,OAAO,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACtC,CAAC;AAED,oGAAoG;AACpG,SAAS,sBAAsB,CAAC,IAAsE;IACpG,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IAE1B,IAAI,QAAQ,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;QAC3E,OAAO;IACT,CAAC;IAED,MAAM,IAAI,KAAK,CACb,UAAU,IAAI,CAAC,WAAW,4FAA4F,CACvH,CAAC;AACJ,CAAC;AAED,wIAAwI;AACxI,SAAS,sBAAsB,CAAC,EAAE,WAAW,EAAE,MAAM,EAA6C;IAChG,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAEtC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,UAAU,WAAW,2CAA2C,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACvG,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UploadSpec } from './upload-spec.js';
|
|
2
|
+
/**
|
|
3
|
+
* Why a declared upload could receive no file, one sentence per defect: a media type no content
|
|
4
|
+
* could prove, a stated content rule that does nothing. Empty for a route without an upload.
|
|
5
|
+
*/
|
|
6
|
+
export declare function uploadDefects(upload: UploadSpec | undefined): string[];
|
|
7
|
+
//# sourceMappingURL=upload-defects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-defects.d.ts","sourceRoot":"","sources":["../../src/route/upload-defects.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM,EAAE,CAItE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { contentRuleDefects } from '@ddd-ts-kit/kernel';
|
|
2
|
+
/**
|
|
3
|
+
* Why a declared upload could receive no file, one sentence per defect: a media type no content
|
|
4
|
+
* could prove, a stated content rule that does nothing. Empty for a route without an upload.
|
|
5
|
+
*/
|
|
6
|
+
export function uploadDefects(upload) {
|
|
7
|
+
return upload === undefined
|
|
8
|
+
? []
|
|
9
|
+
: contentRuleDefects({ accepted: upload.mediaTypes, contentRules: upload.contentRules ?? {} });
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=upload-defects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-defects.js","sourceRoot":"","sources":["../../src/route/upload-defects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,MAA8B;IAC1D,OAAO,MAAM,KAAK,SAAS;QACzB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,kBAAkB,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,UAAU,EAAE,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,EAAE,EAAE,CAAC,CAAC;AACnG,CAAC"}
|
|
@@ -1,12 +1,30 @@
|
|
|
1
|
+
import type { ContentRules, TextRule } from '@ddd-ts-kit/kernel';
|
|
1
2
|
/**
|
|
2
3
|
* The file a route receives, in a `multipart/form-data` request: the field that carries it, the
|
|
3
|
-
* most it may weigh and the media types it may be. All
|
|
4
|
-
*
|
|
4
|
+
* most it may weigh and the media types it may be. All of it is part of the contract (the OpenAPI
|
|
5
|
+
* document states it) and is enforced while the content streams.
|
|
5
6
|
*/
|
|
6
7
|
export interface UploadSpec {
|
|
7
8
|
readonly field: string;
|
|
8
9
|
readonly maxBytes: number;
|
|
9
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Exact types or families (`image/*`), verified on the first bytes of the content, never on the
|
|
12
|
+
* file name. Each must have a content rule: a signature or the text rule of the kit, or the one
|
|
13
|
+
* `contentRules` states. A type with none could receive no file, and is refused when the route
|
|
14
|
+
* is declared.
|
|
15
|
+
*/
|
|
10
16
|
readonly mediaTypes: readonly string[];
|
|
17
|
+
/**
|
|
18
|
+
* The text a text type may be: `utf-8` (the default) or `single-byte`, which also takes an export
|
|
19
|
+
* in Windows-1252 or ISO-8859-1. The handler receives the bytes as they came and decodes them
|
|
20
|
+
* itself (`isUtf8` of the kernel tells which it holds); a binary file is refused under both.
|
|
21
|
+
*/
|
|
22
|
+
readonly text?: TextRule;
|
|
23
|
+
/**
|
|
24
|
+
* The rule of each accepted type the kit has none for: `{ 'application/vnd.ms-excel': 'text' }`
|
|
25
|
+
* for the CSV a browser on Windows sends, `{ 'application/octet-stream': 'unchecked' }` for bytes
|
|
26
|
+
* the route takes as they are.
|
|
27
|
+
*/
|
|
28
|
+
readonly contentRules?: ContentRules;
|
|
11
29
|
}
|
|
12
30
|
//# sourceMappingURL=upload-spec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload-spec.d.ts","sourceRoot":"","sources":["../../src/route/upload-spec.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B
|
|
1
|
+
{"version":3,"file":"upload-spec.d.ts","sourceRoot":"","sources":["../../src/route/upload-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEjE;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IACzB;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;CACtC"}
|
|
@@ -57,9 +57,17 @@ function inspected(spec, file, info) {
|
|
|
57
57
|
const mediaType = mediaTypeOf(info.mimeType);
|
|
58
58
|
const inspection = new FileInspection({
|
|
59
59
|
maxBytes: spec.maxBytes,
|
|
60
|
-
expected:
|
|
60
|
+
expected: expectationOf(spec, mediaType),
|
|
61
61
|
});
|
|
62
62
|
void pipeline(file, inspection).catch(() => undefined);
|
|
63
63
|
return { fileName: info.filename ?? '', mediaType, stream: inspection };
|
|
64
64
|
}
|
|
65
|
+
function expectationOf({ mediaTypes, text, contentRules }, mediaType) {
|
|
66
|
+
return {
|
|
67
|
+
mediaType,
|
|
68
|
+
accepted: mediaTypes,
|
|
69
|
+
...(text === undefined ? {} : { text }),
|
|
70
|
+
...(contentRules === undefined ? {} : { contentRules }),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
65
73
|
//# sourceMappingURL=read-multipart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-multipart.js","sourceRoot":"","sources":["../../src/uploads/read-multipart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,MAAM,EAAE,EAAiB,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"read-multipart.js","sourceRoot":"","sources":["../../src/uploads/read-multipart.ts"],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AAM,CAAC,UAAU,IAAI,MAAM;KACvC,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,IAAgB,EAAE,IAA2B,EAAE,IAAc;IAC9E,MAAM,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAE7C,MAAM,UAAU,GAAG,IAAI,cAAc,CAAC;QACpC,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,QAAQ,EAAE,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC;KACzC,CAAC,CAAC;IAEH,KAAK,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAEvD,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AAC1E,CAAC;AAED,SAAS,aAAa,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAc,EAAE,SAAiB;IACtF,OAAO;QACL,SAAS;QACT,QAAQ,EAAE,UAAU;QACpB,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC;QACvC,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC;KACxD,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddd-ts-kit/http",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.112.0",
|
|
4
4
|
"description": "Framework-agnostic route definitions with Express, Fastify, Hono and NestJS adapters, oRPC and tRPC procedures and OpenAPI 3.1 generation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ddd",
|
|
@@ -88,8 +88,8 @@
|
|
|
88
88
|
"dist"
|
|
89
89
|
],
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@ddd-ts-kit/kernel": "0.
|
|
92
|
-
"@ddd-ts-kit/validation": "0.
|
|
91
|
+
"@ddd-ts-kit/kernel": "0.112.0",
|
|
92
|
+
"@ddd-ts-kit/validation": "0.112.0"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
95
|
"@nestjs/common": ">=11.0.0",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
}
|
|
129
129
|
},
|
|
130
130
|
"devDependencies": {
|
|
131
|
-
"@ddd-ts-kit/testing": "0.
|
|
131
|
+
"@ddd-ts-kit/testing": "0.112.0",
|
|
132
132
|
"@hono/node-server": "^2.1.6",
|
|
133
133
|
"@nestjs/common": "^12.3.2",
|
|
134
134
|
"@nestjs/core": "^12.3.2",
|