poad 2.63.0 → 2.65.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/global/start.js +7 -0
- package/package.json +2 -2
- package/poad.js +4 -3
- package/project/auth/import.js +68 -0
- package/project/auth/index.js +7 -0
- package/project/cli.js +7 -2
- package/project/db/import.js +138 -0
- package/project/db/index.js +1 -0
- package/project/deploy.js +22 -0
- package/project/gen/types.js +10 -2
- package/project/logs.js +2 -0
- package/project/source.js +341 -42
- package/project/storage/cp.js +4 -2
- package/project/upgrade.js +10 -0
- package/test/api-exposure.test.js +60 -0
- package/test/auth-import.test.js +113 -0
- package/test/cloud.test.js +1 -0
- package/test/data.test.js +24 -0
- package/test/deps.test.js +108 -0
- package/test/import.test.js +226 -0
- package/test/logs.test.js +12 -0
- package/test/naming.test.js +18 -0
- package/test/source.test.js +116 -0
- package/test/storage-tus.test.js +169 -0
- package/test/storage.test.js +7 -0
- package/utils/api-exposure/api-exposure.sql +42 -0
- package/utils/api-exposure/index.js +97 -0
- package/utils/auth-import.js +204 -0
- package/utils/cloud/bundle.js +16 -2
- package/utils/cloud/deps.js +297 -0
- package/utils/data.js +41 -0
- package/utils/help-details.js +57 -4
- package/utils/import-upload.js +112 -0
- package/utils/logline.js +2 -2
- package/utils/logs.js +8 -1
- package/utils/naming.js +41 -0
- package/utils/runner.js +1 -1
- package/utils/storage-copy.js +31 -3
- package/utils/storage-tus.js +201 -0
- package/utils/storage.js +37 -1
package/utils/storage.js
CHANGED
|
@@ -172,7 +172,24 @@ function client({ base, key, apikey, renew, fetch: doFetch = fetch, timeout = TI
|
|
|
172
172
|
return text ? JSON.parse(text) : null;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
/** Réponse fetch brute, quel que soit son code (envois en morceaux, utils/storage-tus.js) */
|
|
176
|
+
async function raw(method, route, { headers: extra = {}, body } = {}) {
|
|
177
|
+
await fresh();
|
|
178
|
+
const ctl = new AbortController();
|
|
179
|
+
const timer = setTimeout(() => ctl.abort(), timeout * 4);
|
|
180
|
+
try {
|
|
181
|
+
return await doFetch(`${base}/storage/v1${route}`, { method, headers: headers({ ...(body ? { 'content-length': String(body.length) } : {}), ...extra }), body, signal: ctl.signal });
|
|
182
|
+
} catch (err) {
|
|
183
|
+
const cause = (err && err.cause && err.cause.message) || (err && err.message) || String(err);
|
|
184
|
+
throw new CloudError(ctl.signal.aborted ? `The storage did not answer within ${(timeout * 4) / 1000} s (${base}).` : `The storage does not answer on ${base}: ${cause}`);
|
|
185
|
+
} finally {
|
|
186
|
+
clearTimeout(timer);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
175
190
|
return {
|
|
191
|
+
base,
|
|
192
|
+
raw,
|
|
176
193
|
buckets: () => request('GET', '/bucket'),
|
|
177
194
|
bucket: (id) => request('GET', `/bucket/${encodeURIComponent(id)}`),
|
|
178
195
|
/** Tous les objets dont le nom commence par prefix (pages de 1000) */
|
|
@@ -354,13 +371,32 @@ async function cloudTarget(opts = {}) {
|
|
|
354
371
|
const ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
355
372
|
function engineEnv(config = {}) {
|
|
356
373
|
const env = [];
|
|
374
|
+
// [storage] file_size_limit : taille maximale d'un fichier du projet, plafond des buckets (storage 0.6.0+)
|
|
375
|
+
const limit = fileSizeLimit(config);
|
|
376
|
+
if (limit.value) env.push(`POAD_STORAGE_FILE_SIZE_LIMIT=${limit.value}`);
|
|
357
377
|
if (ID_RE.test(String(config.project_uuid || ''))) env.push(`POAD_PROJECT_UUID=${config.project_uuid}`);
|
|
358
378
|
const linked = config.cloud && config.cloud.project;
|
|
359
379
|
if (ID_RE.test(String(linked || ''))) env.push(`POAD_CLOUD_PROJECT=${linked}`);
|
|
360
380
|
return env;
|
|
361
381
|
}
|
|
362
382
|
|
|
383
|
+
/**
|
|
384
|
+
* [storage] file_size_limit de poad/config.toml → octets ({ value }), ou { warning } si la valeur est
|
|
385
|
+
* illisible (elle n'est alors pas transmise : la limite de l'engine, 50 MiB, reste). Octets ou texte :
|
|
386
|
+
* « 200MB », « 1GB » (décimal, comme Supabase), « 500MiB » (binaire). Pure.
|
|
387
|
+
*/
|
|
388
|
+
function fileSizeLimit(config = {}) {
|
|
389
|
+
const raw = config.storage && config.storage.file_size_limit;
|
|
390
|
+
if (raw === undefined || raw === null || raw === '') return { value: null };
|
|
391
|
+
const units = { b: 1, kb: 1e3, mb: 1e6, gb: 1e9, tb: 1e12, kib: 1024, mib: 1024 ** 2, gib: 1024 ** 3, tib: 1024 ** 4 };
|
|
392
|
+
const m = typeof raw === 'number' ? [null, String(raw), 'b'] : /^(\d+(?:\.\d+)?)\s*([kmgt]i?b|b)?$/i.exec(String(raw).trim());
|
|
393
|
+
const n = m ? Math.round(Number(m[1]) * units[(m[2] || 'b').toLowerCase()]) : NaN;
|
|
394
|
+
if (!Number.isSafeInteger(n) || n <= 0)
|
|
395
|
+
return { value: null, warning: `[storage] file_size_limit = "${String(raw).slice(0, 32)}" in poad/config.toml is not a size (examples: "200MB", "1GB", 52428800): the engine default (50 MiB) is used.` };
|
|
396
|
+
return { value: n };
|
|
397
|
+
}
|
|
398
|
+
|
|
363
399
|
/** Cible : poad.io avec --env/--project, sinon l'engine local */
|
|
364
400
|
const target = (opts = {}, deps) => (opts.env || opts.project ? cloudTarget(opts) : localTarget(deps));
|
|
365
401
|
|
|
366
|
-
module.exports = { EXIT, PARALLEL, MAX_PARALLEL, concurrency, reason, md5File, engineEnv, target, cloudTarget, when, parseRemote, isRemote, size, entries, viewEntries, joinKey, client, each, resolve, walk, mimeOf, show, localTarget };
|
|
402
|
+
module.exports = { fileSizeLimit, EXIT, PARALLEL, MAX_PARALLEL, concurrency, reason, md5File, engineEnv, target, cloudTarget, when, parseRemote, isRemote, size, entries, viewEntries, joinKey, client, each, resolve, walk, mimeOf, show, localTarget };
|