@usenadia/node 0.1.1 → 0.3.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.md +33 -4
- package/dist/index.d.mts +2191 -325
- package/dist/index.d.ts +2191 -325
- package/dist/index.js +403 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +370 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,6 +46,35 @@ try {
|
|
|
46
46
|
This block is run as is against the real API by the smoke test
|
|
47
47
|
(`test/smoke.test.mjs`): if it stops working, the release stops.
|
|
48
48
|
|
|
49
|
+
## Uploading a file
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
const media = await nadia.upload('./reel.mp4'); // a path, or upload(blob, 'reel.mp4')
|
|
53
|
+
media.path; // what a post takes as image[].path
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
An MP4, JPEG, PNG, WebP or GIF goes in parts of 20 MB straight to the
|
|
57
|
+
storage, four at a time: a part cut by the network is sent again, and so are
|
|
58
|
+
the parts the server says are missing, before it confirms. Up to 500 MB.
|
|
59
|
+
A server without the upload in parts, or another image type (HEIC, which the
|
|
60
|
+
server converts to JPEG; AVIF…), gets the whole file in one request, as
|
|
61
|
+
before. In one request the server takes an image up to 10 MB and an MP4 up to
|
|
62
|
+
25 MB only (`413 FILE_TOO_LARGE` beyond: a recent server takes it in parts).
|
|
63
|
+
A MOV or an M4V is converted on neither path: the server refuses it (`415`),
|
|
64
|
+
convert it to MP4 first (`ffmpeg -i in.mov -c copy -movflags +faststart out.mp4`).
|
|
65
|
+
|
|
66
|
+
A file already online goes in by its URL, downloaded by the server:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
const media = await nadia.uploadFromUrl('https://cdn.example.com/reel.mp4');
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
A long import (not done within 25 seconds) is answered `202` by the server
|
|
73
|
+
and goes on there: `uploadFromUrl` reads it again every 3 seconds until it
|
|
74
|
+
ends (15 minutes at most, `importPoll` in the options), and resolves to the
|
|
75
|
+
media all the same. A failed import throws the `NadiaError` the server would
|
|
76
|
+
have answered at once.
|
|
77
|
+
|
|
49
78
|
## The content board
|
|
50
79
|
|
|
51
80
|
Every card of the board in the app is reachable: create one from anywhere
|
|
@@ -144,7 +173,7 @@ pass `request.headers` and the buffer the same way. With the Fetch API
|
|
|
144
173
|
is the primitive underneath: it returns a boolean and checks the timestamp
|
|
145
174
|
only when `tolerance` (seconds) is given. Both are tested against the
|
|
146
175
|
fixture the server signs with
|
|
147
|
-
(`
|
|
176
|
+
(`apps/server/contract/signed-delivery.json`).
|
|
148
177
|
|
|
149
178
|
## Errors
|
|
150
179
|
|
|
@@ -184,7 +213,7 @@ A tag publishes; nothing is published from a laptop.
|
|
|
184
213
|
```bash
|
|
185
214
|
# 1. bump "version" in apps/sdk/node/package.json, commit, push main
|
|
186
215
|
# 2. tag it — the tag must equal the version
|
|
187
|
-
git tag node-v0.
|
|
216
|
+
git tag node-v0.2.0 && git push origin node-v0.2.0
|
|
188
217
|
```
|
|
189
218
|
|
|
190
219
|
`.github/workflows/publish-npm.yml` refuses a tag that does not match
|
|
@@ -192,5 +221,5 @@ git tag node-v0.1.1 && git push origin node-v0.1.1
|
|
|
192
221
|
the real API**, and publishes only if all are green (npm Trusted Publisher,
|
|
193
222
|
no token).
|
|
194
223
|
|
|
195
|
-
`openapi.public.json` itself is
|
|
196
|
-
|
|
224
|
+
`openapi.public.json` itself is held by hand at the repo root; the server's
|
|
225
|
+
tests hold every public answer to it (`pnpm openapi:check`). Plan: `docs/roadmap/done/19-sdk-public-api.md`.
|