poad 2.65.0 → 2.70.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/package.json +1 -1
- package/project/cli.js +1 -1
- package/project/logs.js +1 -1
- package/project/source.js +175 -24
- package/test/source.test.js +84 -1
- package/utils/help-details.js +5 -4
package/package.json
CHANGED
package/project/cli.js
CHANGED
|
@@ -76,7 +76,7 @@ module.exports = {
|
|
|
76
76
|
function: 'Alias of poad functions',
|
|
77
77
|
flows: 'Flows of the project (automations in poad/flows/<name>.json, engine 0.18.0+, needs Valkey): new, list, run, runs, show, cancel; --env <name> for poad.io',
|
|
78
78
|
flow: 'Alias of poad flows',
|
|
79
|
-
source: 'Sources of the project (tables kept up to date from a URL or an uploaded file, poad/sources/<name>.yaml, engine 0.64.0+): ls, refresh <name> [--force], import <file> [--table <t>], link <table> (linked table of another PostgreSQL database), test <name>, pull <name>; --env <name> for poad.io',
|
|
79
|
+
source: 'Sources of the project (tables kept up to date from a URL or an uploaded file, poad/sources/<name>.yaml, engine 0.64.0+): ls, refresh <name> [--force], import <file> [--table <t>], link <table> (linked table of another PostgreSQL database, or remote table over a CSV, JSON, JSON-L, GeoJSON or Parquet file: --url or --storage, engine 0.67.0+), test <name>, pull <name>; --env <name> for poad.io',
|
|
80
80
|
sources: 'Alias of poad source',
|
|
81
81
|
/* status: `[AI] Vérification du statut de l'environnement`,
|
|
82
82
|
gen: {
|
package/project/logs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// poad logs les 100 dernières lignes, tous services
|
|
3
3
|
// poad logs data auth seulement ces services (gateway, data, auth,
|
|
4
4
|
// storage, meta, functions, flows, postgres,
|
|
5
|
-
// logs, engine, mailpit, keycloak, valkey)
|
|
5
|
+
// files, logs, engine, mailpit, keycloak, valkey)
|
|
6
6
|
// poad logs level=warn warn, error et fatal
|
|
7
7
|
// poad logs since=15m depuis 15 minutes (s, m, h, d)
|
|
8
8
|
// poad logs request=6f1c… tout le chemin d'une requête (début de l'id suffit)
|
package/project/source.js
CHANGED
|
@@ -5,7 +5,12 @@
|
|
|
5
5
|
// poad source link <table> --host h --database d --remote schéma.table --credential c [--sslmode m] [--port p] [--columns a,b]
|
|
6
6
|
// table liée (mode virtual, engine 0.66.0+) : une table d'une autre base PostgreSQL
|
|
7
7
|
// lue à chaque requête, rien n'est copié ; colonnes proposées par l'engine
|
|
8
|
-
// poad source
|
|
8
|
+
// poad source link <table> --url https://… | --storage bucket/chemin [--format f] [--delimiter ;] [--no-header]
|
|
9
|
+
// [--encoding e] [--root a.b] [--columns a,b]
|
|
10
|
+
// table distante sur fichier (mode virtual, engine 0.67.0+) : CSV, JSON, JSON-L,
|
|
11
|
+
// GeoJSON ou Parquet lu par poad-files dans Postgres à chaque requête, rien n'est copié
|
|
12
|
+
// poad source test <nom> table liée ou distante : vérifie l'adresse (garde des adresses internes),
|
|
13
|
+
// rebranche, lit une ligne par Postgres
|
|
9
14
|
// poad source pull <nom> [--force] rapatrie la déclaration d'une source (créée dans la console
|
|
10
15
|
// de poad.io avec --env) dans poad/sources/<nom>.yaml
|
|
11
16
|
//
|
|
@@ -46,9 +51,111 @@ const describeReader = (sample) => {
|
|
|
46
51
|
const POLL_MS = 1000;
|
|
47
52
|
const TIMEOUT_MS = 30000;
|
|
48
53
|
const FINAL = ['completed', 'failed', 'cancelled'];
|
|
49
|
-
const USAGE = 'Usage: poad source ls | refresh <name> [--force] [--detach] | import <file> [--table <table>] [--name <source>] | link <table> --host <host> --database <db> --remote <schema.table> --credential <name> | test <name> | pull <name> [--force] [--stdout], and --env <name> | --project <id> for poad.io';
|
|
50
|
-
const LINK_USAGE = 'Usage: poad source link <table> --host <host> --database <db> --remote <schema.table> --credential <name> [--port <port>] [--sslmode require|verify-full|disable] [--columns <col,…>] [--env <name>]';
|
|
54
|
+
const USAGE = 'Usage: poad source ls | refresh <name> [--force] [--detach] | import <file> [--table <table>] [--name <source>] | link <table> --host <host> --database <db> --remote <schema.table> --credential <name> | link <table> --url <https://…> | --storage <bucket>/<path> | test <name> | pull <name> [--force] [--stdout], and --env <name> | --project <id> for poad.io';
|
|
55
|
+
const LINK_USAGE = 'Usage: poad source link <table> --host <host> --database <db> --remote <schema.table> --credential <name> [--port <port>] [--sslmode require|verify-full|disable] [--columns <col,…>] [--env <name>]\n or: poad source link <table> --url <https://…> | --storage <bucket>/<path> [--format csv|json|jsonl|geojson|parquet] [--delimiter <c>] [--no-header] [--encoding utf-8|latin-1|utf-16] [--root <a.b>] [--columns <col,…>] [--env <name>]';
|
|
51
56
|
const SSLMODES = ['require', 'verify-full', 'disable'];
|
|
57
|
+
/** Formats d'une table distante sur fichier (meta, engine 0.67.0 : lus par DuckDB ; 0.68.0 : par poad-files) */
|
|
58
|
+
const REMOTE_FORMATS = ['csv', 'json', 'jsonl', 'geojson', 'parquet'];
|
|
59
|
+
const REMOTE_ENCODINGS = ['utf-8', 'latin-1', 'iso-8859-1', 'windows-1252', 'utf-16'];
|
|
60
|
+
const BUCKET_RE = /^[a-z0-9][a-z0-9._-]{0,62}$/;
|
|
61
|
+
|
|
62
|
+
/** Emplacement d'un fichier distant, sans query string ni identifiant : https://hôte/chemin ou storage://bucket/chemin. Pure. */
|
|
63
|
+
const remoteLocation = (o) => {
|
|
64
|
+
if (!o) return '';
|
|
65
|
+
if (o.storage && o.storage.bucket) return `storage://${o.storage.bucket}/${o.storage.path || ''}`;
|
|
66
|
+
if (!o.url) return '';
|
|
67
|
+
try {
|
|
68
|
+
const u = new URL(o.url);
|
|
69
|
+
return `${u.protocol}//${u.host}${u.pathname}`;
|
|
70
|
+
} catch {
|
|
71
|
+
return String(o.url).split(/[?#]/)[0];
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/** « bucket/chemin/fichier.csv » → { bucket, path }, ou un message. Pure. */
|
|
76
|
+
const parseStorageRef = (raw) => {
|
|
77
|
+
const v = String(raw || '').replace(/^storage:\/\//, '').replace(/^\/+/, '');
|
|
78
|
+
const i = v.indexOf('/');
|
|
79
|
+
if (i <= 0 || i === v.length - 1) return '--storage takes <bucket>/<path> (an object of the project storage), e.g. donnees/arrets.geojson';
|
|
80
|
+
const bucket = v.slice(0, i);
|
|
81
|
+
const path = v.slice(i + 1);
|
|
82
|
+
if (!BUCKET_RE.test(bucket)) return `"${bucket}" is not a bucket name`;
|
|
83
|
+
if (path.split('/').some((p) => p === '' || p === '.' || p === '..') || /[\u0000-\u001f\\]/.test(path)) return `"${path.slice(0, 80)}" is not an object path`;
|
|
84
|
+
return { bucket, path };
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Options de « poad source link » : table liée (--host…) ou table distante sur fichier (--url / --storage).
|
|
89
|
+
* Rend { ok: false, message } ou { ok: true, kind: 'postgres' | 'file', o }. Pure.
|
|
90
|
+
*/
|
|
91
|
+
const parseLinkArgs = (words) => {
|
|
92
|
+
const o = { table: null, host: null, port: null, database: null, remote: null, credential: null, sslmode: null, columns: null, title: null, url: null, storage: null, format: null, delimiter: null, header: null, encoding: null, root: null };
|
|
93
|
+
const valued = { '--host': 'host', '--port': 'port', '--database': 'database', '--db': 'database', '--remote': 'remote', '--credential': 'credential', '--sslmode': 'sslmode', '--columns': 'columns', '--title': 'title', '--url': 'url', '--storage': 'storage', '--format': 'format', '--delimiter': 'delimiter', '--encoding': 'encoding', '--root': 'root' };
|
|
94
|
+
for (let i = 0; i < words.length; i++) {
|
|
95
|
+
const w = words[i];
|
|
96
|
+
const flag = valued[w];
|
|
97
|
+
if (flag) {
|
|
98
|
+
const v = words[++i];
|
|
99
|
+
if (v === undefined || (v.startsWith('--') && v.length > 2)) return { ok: false, message: `poad source link: ${w} needs a value.` };
|
|
100
|
+
o[flag] = v;
|
|
101
|
+
} else if (w === '--no-header') o.header = false;
|
|
102
|
+
else if (w === '--header') o.header = true;
|
|
103
|
+
else if (w === '--yes' || w === '-y') continue;
|
|
104
|
+
else if (w.startsWith('-')) return { ok: false, message: `poad source link: unknown option ${w}.\n${LINK_USAGE}`, usage: true };
|
|
105
|
+
else if (o.table === null) o.table = w.replace(/^public\./, '');
|
|
106
|
+
else return { ok: false, message: `poad source link: one table at a time ("${w}").` };
|
|
107
|
+
}
|
|
108
|
+
const file = o.url !== null || o.storage !== null;
|
|
109
|
+
if (!o.table) return { ok: false, message: LINK_USAGE, usage: true };
|
|
110
|
+
if (!/^[a-z_][a-z0-9_]{0,62}$/.test(o.table)) return { ok: false, message: `"${o.table}" is not a table name (a-z, 0-9 and "_", a letter or "_" first).` };
|
|
111
|
+
if (!file) {
|
|
112
|
+
for (const k of ['format', 'delimiter', 'encoding', 'root']) if (o[k] !== null) return { ok: false, message: `--${k} is for a file (--url or --storage).` };
|
|
113
|
+
if (o.header !== null) return { ok: false, message: '--header / --no-header are for a CSV file (--url or --storage).' };
|
|
114
|
+
if (!o.host || !o.database || !o.remote || !o.credential) return { ok: false, message: LINK_USAGE, usage: true };
|
|
115
|
+
o.sslmode = o.sslmode || 'require';
|
|
116
|
+
if (!SSLMODES.includes(o.sslmode)) return { ok: false, message: `--sslmode: ${SSLMODES.join(', ')}.` };
|
|
117
|
+
if (o.port !== null && !(Number.isInteger(Number(o.port)) && Number(o.port) >= 1 && Number(o.port) <= 65535)) return { ok: false, message: '--port: 1 to 65535.' };
|
|
118
|
+
return { ok: true, kind: 'postgres', o };
|
|
119
|
+
}
|
|
120
|
+
if (o.url !== null && o.storage !== null) return { ok: false, message: 'poad source link: --url or --storage, not both.' };
|
|
121
|
+
for (const k of ['host', 'port', 'database', 'remote', 'credential', 'sslmode']) if (o[k] !== null) return { ok: false, message: `--${k} is for a linked PostgreSQL table, not a file (--url or --storage).` };
|
|
122
|
+
if (o.url !== null) {
|
|
123
|
+
let u;
|
|
124
|
+
try {
|
|
125
|
+
u = new URL(o.url);
|
|
126
|
+
} catch {
|
|
127
|
+
return { ok: false, message: `--url: "${o.url.slice(0, 80)}" is not an address.` };
|
|
128
|
+
}
|
|
129
|
+
if (u.protocol !== 'https:' && u.protocol !== 'http:') return { ok: false, message: '--url: an http:// or https:// address.' };
|
|
130
|
+
if (u.username || u.password) return { ok: false, message: '--url: no user or password in the address.' };
|
|
131
|
+
} else {
|
|
132
|
+
const ref = parseStorageRef(o.storage);
|
|
133
|
+
if (typeof ref === 'string') return { ok: false, message: ref };
|
|
134
|
+
o.storage = ref;
|
|
135
|
+
}
|
|
136
|
+
if (o.format !== null && !REMOTE_FORMATS.includes(o.format)) return { ok: false, message: `--format: ${REMOTE_FORMATS.join(', ')} (got "${o.format}").` };
|
|
137
|
+
const csvOpt = o.delimiter !== null || o.header !== null || o.encoding !== null;
|
|
138
|
+
if (csvOpt && o.format !== null && o.format !== 'csv') return { ok: false, message: '--delimiter, --no-header and --encoding are for a CSV file.' };
|
|
139
|
+
if (o.delimiter !== null && !(o.delimiter.length === 1 || ['\\t', 'tab'].includes(o.delimiter))) return { ok: false, message: '--delimiter: one character (or tab).' };
|
|
140
|
+
if (o.encoding !== null && !REMOTE_ENCODINGS.includes(o.encoding.toLowerCase())) return { ok: false, message: `--encoding: ${REMOTE_ENCODINGS.join(', ')}.` };
|
|
141
|
+
if (o.root !== null && o.format !== null && o.format !== 'json') return { ok: false, message: '--root is for a JSON file.' };
|
|
142
|
+
return { ok: true, kind: 'file', o };
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/** Brouillon d'une table distante sur fichier (POST /sources) : jamais de credential ni d'en-tête. Pure. */
|
|
146
|
+
const remoteDraft = (o, inspected, columns, key) => {
|
|
147
|
+
const format = o.format || inspected.format;
|
|
148
|
+
const csv = format === 'csv' ? { ...(inspected.csv || {}), ...(o.delimiter !== null ? { delimiter: o.delimiter === 'tab' ? '\\t' : o.delimiter } : {}), ...(o.header !== null ? { header: o.header } : {}), ...(o.encoding !== null ? { encoding: o.encoding.toLowerCase() } : {}) } : null;
|
|
149
|
+
const root = format === 'json' ? (o.root || inspected.root || null) : null;
|
|
150
|
+
return {
|
|
151
|
+
table: `public.${o.table}`,
|
|
152
|
+
...(o.title ? { title: o.title } : {}),
|
|
153
|
+
mode: 'virtual',
|
|
154
|
+
origin: { kind: 'file', ...(o.storage ? { storage: o.storage } : { url: o.url }), format, ...(root ? { root } : {}), ...(csv && Object.keys(csv).length ? { csv } : {}) },
|
|
155
|
+
columns: columns.map((c) => ({ name: c.name, from: c.from, type: c.type, ...(c.transform ? { transform: c.transform } : {}) })),
|
|
156
|
+
...(key && key.length ? { key } : {}),
|
|
157
|
+
};
|
|
158
|
+
};
|
|
52
159
|
|
|
53
160
|
/** Origine d'une table liée : hôte[:port]/base · schéma.table (jamais d'identifiant). Pure. */
|
|
54
161
|
const linkedOrigin = (o) => (o && o.host ? `${o.host}${o.port && o.port !== 5432 ? `:${o.port}` : ''}/${o.database || ''} · ${o.schema || 'public'}.${o.table || ''}` : '');
|
|
@@ -84,6 +191,19 @@ const sourceLines = (s, width = 0) => {
|
|
|
84
191
|
const more = (s.problems || []).length > 1 ? ` (+${s.problems.length - 1} more)` : '';
|
|
85
192
|
return [chalk.redBright(` ✖ ${name} ${s.file}`), chalk.redBright(` ${first.line ? `line ${first.line}: ` : first.path ? `${first.path}: ` : ''}${first.message || 'invalid declaration'}${more}`)];
|
|
86
193
|
}
|
|
194
|
+
if (s.mode === 'virtual' && (s.remote || (s.origin && s.origin.kind === 'file'))) {
|
|
195
|
+
// Table distante sur fichier : poad-files relit le fichier à chaque requête ; branchée ou non (adresse refusée)
|
|
196
|
+
const attached = Boolean(s.remote && s.remote.attached) && s.table_exists !== false;
|
|
197
|
+
const where = (s.remote && s.remote.location) || remoteLocation(s.origin);
|
|
198
|
+
const format = (s.remote && s.remote.format) || (s.origin && s.origin.format) || '';
|
|
199
|
+
const facts = ['remote table (file)', s.table, [format, where].filter(Boolean).join(' '), attached ? 'attached' : 'not attached'].filter(Boolean).join(' ');
|
|
200
|
+
const out = [` ${attached && !(s.problems && s.problems.length) ? chalk.greenBright('✔') : chalk.yellowBright('!')} ${chalk.bold(name)} ${chalk.grey(facts)}`];
|
|
201
|
+
if (s.title && s.title !== s.name) out[0] += ` ${s.title}`;
|
|
202
|
+
for (const p of s.problems || []) out.push(chalk.yellowBright(` ${p.path ? `${p.path}: ` : ''}${p.message}`));
|
|
203
|
+
if (s.drift && s.drift.issues) for (const issue of s.drift.issues.slice(0, 5)) out.push(chalk.yellowBright(` table: ${typeof issue === 'string' ? issue : issue.message || JSON.stringify(issue)}`));
|
|
204
|
+
if (!attached) out.push(chalk.grey(` poad source test ${s.name} tells why`));
|
|
205
|
+
return out;
|
|
206
|
+
}
|
|
87
207
|
if (s.mode === 'virtual') {
|
|
88
208
|
// Table liée : rien n'est copié, pas d'exécution ; branchée (adresse vérifiée et user mapping posés) ou non
|
|
89
209
|
const attached = Boolean(s.linked && s.linked.attached) && s.table_exists !== false;
|
|
@@ -218,8 +338,9 @@ const main = async (args = {}, raw, deps = {}) => {
|
|
|
218
338
|
const error = data && typeof data === 'object' && data.error && typeof data.error === 'object' ? data.error : null;
|
|
219
339
|
if (error && error.message) throw new SourceError(`${error.message}${error.hint ? ` (${error.hint})` : ''}`);
|
|
220
340
|
// Fichier envoyé, échantillon, rapprochement : engine 0.65.0 ; le reste : 0.64.0
|
|
221
|
-
|
|
222
|
-
|
|
341
|
+
// Table distante sur fichier : engine 0.67.0 ; table liée : 0.66.0
|
|
342
|
+
const needs = /\/sources\/remote\b/.test(route) ? '0.67.0' : /\/sources\/linked\b/.test(route) ? '0.66.0' : /\/sources\/(uploads|sample|propose|preview|tables)\b/.test(route) ? '0.65.0' : '0.64.0';
|
|
343
|
+
if (res.status === 404) throw new SourceError(`${t.cloud ? t.label : 'The engine'} has no ${needs === '0.64.0' ? 'sources API' : 'such sources API'} (HTTP 404): engine ${needs} or later is needed.`);
|
|
223
344
|
if (res.status === 401 || res.status === 403) throw new SourceError(t.cloud ? `${t.label} refused the access (HTTP ${res.status}): "poad login" again, or check that you own the project.` : `the engine refused the service_role key (HTTP ${res.status})`);
|
|
224
345
|
throw new SourceError(`HTTP ${res.status}`);
|
|
225
346
|
};
|
|
@@ -477,14 +598,21 @@ const main = async (args = {}, raw, deps = {}) => {
|
|
|
477
598
|
// Table liée : meta refait la garde des adresses, rebranche (adresse vérifiée, user mapping depuis le coffre) et lit une ligne
|
|
478
599
|
if (command === 'test') {
|
|
479
600
|
const name = words[1];
|
|
480
|
-
if (!name || words.length > 2) return fail('Usage: poad source test <name> [--env <name>] (a linked table: "poad source ls" lists them).', 2);
|
|
601
|
+
if (!name || words.length > 2) return fail('Usage: poad source test <name> [--env <name>] (a linked or remote table: "poad source ls" lists them).', 2);
|
|
481
602
|
if (!NAME_RE.test(name)) return fail(`"${name}" is not a source name.`, 2);
|
|
482
603
|
const t = await ready();
|
|
483
604
|
if (!t) return;
|
|
484
605
|
const r = await guard(() => call(t, 'POST', `/meta/v1/sources/${encodeURIComponent(name)}/test`, {}));
|
|
485
606
|
if (!r) return;
|
|
486
607
|
if (json) return console.log(JSON.stringify(r, null, 2));
|
|
487
|
-
|
|
608
|
+
const ms = typeof r.duration_ms === 'number' ? ` (${Math.round(r.duration_ms)} ms)` : '';
|
|
609
|
+
if (r.location) {
|
|
610
|
+
// Table distante sur fichier : lue par Postgres (poad-files), à l'emplacement rendu sans query string
|
|
611
|
+
console.log(`${chalk.greenBright('✔')} ${chalk.bold(name)} ${chalk.grey(`the remote file is readable${ms}, ${remoteLocation({ url: /^https?:/.test(r.location) ? r.location : null, storage: null }) || r.location}`)}`);
|
|
612
|
+
if (r.table) console.log(chalk.grey(` ${r.table}: read by Postgres, nothing copied${typeof r.sample_rows === 'number' ? `, ${r.sample_rows ? 'rows found' : 'no row'}` : ''}`));
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
console.log(`${chalk.greenBright('✔')} ${chalk.bold(name)} ${chalk.grey(`the remote table answers${ms}${r.address ? `, checked address ${r.address}` : ''}`)}`);
|
|
488
616
|
return;
|
|
489
617
|
}
|
|
490
618
|
|
|
@@ -492,23 +620,46 @@ const main = async (args = {}, raw, deps = {}) => {
|
|
|
492
620
|
// Table liée : l'engine se connecte en lecture seule (garde des adresses internes), propose les colonnes de la table
|
|
493
621
|
// distante, puis écrit la déclaration (poad/sources/<table>.yaml) et la migration de la table étrangère. Le credential
|
|
494
622
|
// (utilisateur et mot de passe) est déjà dans le coffre : poad credential, ou l'écran Credentials ; jamais ici.
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
623
|
+
// Table distante sur fichier (engine 0.67.0) : l'engine vérifie l'adresse (garde des adresses internes) ou l'objet du
|
|
624
|
+
// Stockage, lit un échantillon et propose les colonnes ; puis la déclaration (poad/sources/<table>.yaml) et la
|
|
625
|
+
// migration de la table étrangère (file_fdw) sont écrites. Rien n'est copié : chaque requête relit le fichier.
|
|
626
|
+
const linkFile = async (o) => {
|
|
627
|
+
const t = await ready();
|
|
628
|
+
if (!t) return;
|
|
629
|
+
const where = o.storage ? { storage: o.storage } : { url: o.url };
|
|
630
|
+
const csv = { ...(o.delimiter !== null ? { delimiter: o.delimiter === 'tab' ? '\\t' : o.delimiter } : {}), ...(o.header !== null ? { header: o.header } : {}), ...(o.encoding !== null ? { encoding: o.encoding.toLowerCase() } : {}) };
|
|
631
|
+
const seen = await guard(() => call(t, 'POST', '/meta/v1/sources/remote/inspect', { ...where, ...(o.format ? { format: o.format } : {}), ...(o.root ? { root: o.root } : {}), ...(Object.keys(csv).length ? { csv } : {}), name: o.table }));
|
|
632
|
+
if (!seen) return;
|
|
633
|
+
let columns = Array.isArray(seen.columns) ? seen.columns : [];
|
|
634
|
+
if (o.columns) {
|
|
635
|
+
const wanted = o.columns.split(',').map((x) => x.trim()).filter(Boolean);
|
|
636
|
+
const unknown = wanted.filter((w) => !columns.some((c) => c.from === w || c.name === w));
|
|
637
|
+
if (unknown.length) return fail(`The file has no field ${unknown.map((u) => `"${u}"`).join(', ')} (it has: ${columns.map((c) => c.from).join(', ')}).`);
|
|
638
|
+
columns = columns.filter((c) => wanted.includes(c.from) || wanted.includes(c.name));
|
|
639
|
+
}
|
|
640
|
+
if (!columns.length) return fail(`${remoteLocation(where)}: no column to read.`);
|
|
641
|
+
if (!o.format && !seen.format) return fail('The engine could not tell the format of the file: --format csv|json|jsonl|geojson|parquet.', 2);
|
|
642
|
+
const key = (seen.key || []).filter((k) => columns.some((c) => c.name === k));
|
|
643
|
+
const draft = remoteDraft(o, seen, columns, key);
|
|
644
|
+
if (!json) {
|
|
645
|
+
console.log(`${chalk.bold(o.table)} ${chalk.grey(`${draft.origin.format} ${remoteLocation(draft.origin)}${typeof seen.duration_ms === 'number' ? `, read in ${Math.round(seen.duration_ms)} ms` : ''}`)}`);
|
|
646
|
+
const w = Math.max(...columns.map((c) => c.name.length));
|
|
647
|
+
for (const c of columns) console.log(chalk.grey(` ${c.name.padEnd(w)} ${c.type}${c.from !== c.name ? ` ← ${c.from}` : ''}${c.transform ? ` (${c.transform})` : ''}`));
|
|
508
648
|
}
|
|
509
|
-
|
|
510
|
-
if (
|
|
511
|
-
if (
|
|
649
|
+
const saved = await guard(() => call(t, 'POST', '/meta/v1/sources', { draft }));
|
|
650
|
+
if (!saved) return;
|
|
651
|
+
if (json) return console.log(JSON.stringify(saved, null, 2));
|
|
652
|
+
console.log(`${chalk.greenBright('✔')} ${chalk.bold(saved.name || o.table)} ${chalk.grey(`public.${o.table} → ${remoteLocation(draft.origin)}, ${columns.length} column${columns.length > 1 ? 's' : ''}, nothing copied`)}`);
|
|
653
|
+
if (saved.file) console.log(chalk.grey(` ${saved.file}${saved.report && saved.report.created && saved.report.created.migration ? `, ${saved.report.created.migration}` : ''}`));
|
|
654
|
+
for (const p of saved.problems || []) console.log(chalk.yellowBright(` ${p.path ? `${p.path}: ` : ''}${p.message}`));
|
|
655
|
+
console.log(chalk.grey(` Every query reads the file again. Private: never served by the API; read it in SQL, through a security_invoker view or a function. "poad source test ${saved.name || o.table}" checks it.`));
|
|
656
|
+
};
|
|
657
|
+
|
|
658
|
+
if (command === 'link') {
|
|
659
|
+
const parsed = parseLinkArgs(words.slice(1));
|
|
660
|
+
if (!parsed.ok) return fail(parsed.message, 2);
|
|
661
|
+
const o = parsed.o;
|
|
662
|
+
if (parsed.kind === 'file') return linkFile(o);
|
|
512
663
|
const port = o.port === null ? undefined : Number(o.port);
|
|
513
664
|
if (port !== undefined && !(Number.isInteger(port) && port >= 1 && port <= 65535)) return fail('--port: 1 to 65535.', 2);
|
|
514
665
|
const dot = o.remote.indexOf('.');
|
|
@@ -582,4 +733,4 @@ const main = async (args = {}, raw, deps = {}) => {
|
|
|
582
733
|
};
|
|
583
734
|
|
|
584
735
|
module.exports = (args, raw) => main(args, raw);
|
|
585
|
-
Object.assign(module.exports, { main, supportsSources, sourceLines, reportOf, reportLines, guardRefused, age, linkedOrigin, NAME_RE, FORMATS, describeReader });
|
|
736
|
+
Object.assign(module.exports, { main, supportsSources, sourceLines, reportOf, reportLines, guardRefused, age, linkedOrigin, remoteLocation, parseStorageRef, parseLinkArgs, remoteDraft, REMOTE_FORMATS, NAME_RE, FORMATS, describeReader });
|
package/test/source.test.js
CHANGED
|
@@ -61,7 +61,13 @@ function fakeCloud(t, behaviour = {}) {
|
|
|
61
61
|
if (body.host === '10.0.0.5') return send(res, 400, { error: { code: 'internal_address', message: 'adresse interne refusée (10.0.0.5) : une table liée lit une base sur internet' } });
|
|
62
62
|
return send(res, 200, { ok: true, schema: body.schema, table: body.table, key: ['id'], columns: [{ name: 'id', from: 'id', type: 'integer' }, { name: 'nom_client', from: 'Nom Client', type: 'text' }, { name: 'ville', from: 'ville', type: 'character varying(60)' }] });
|
|
63
63
|
}
|
|
64
|
-
if (req.method === 'POST' && url.pathname === '/meta/v1/sources
|
|
64
|
+
if (req.method === 'POST' && url.pathname === '/meta/v1/sources/remote/inspect') {
|
|
65
|
+
if (body.url && body.url.includes('127.0.0.1')) return send(res, 400, { error: { code: 'internal_address', message: 'adresse interne refusée (127.0.0.1) : une table distante lit un fichier sur internet' } });
|
|
66
|
+
const csv = body.storage || (body.format === 'csv');
|
|
67
|
+
return send(res, 200, { ok: true, location: body.storage ? `storage://${body.storage.bucket}/${body.storage.path}` : 'https://data.example.org/arrets.geojson', format: csv ? 'csv' : 'geojson', ...(csv ? { csv: { delimiter: ';', header: true } } : {}), duration_ms: 41, key: [], columns: csv ? [{ name: 'code', from: 'Code', type: 'text' }, { name: 'population', from: 'Population', type: 'integer' }] : [{ name: 'id', from: 'id', type: 'text' }, { name: 'nom', from: 'nom', type: 'text' }, { name: 'geometry', from: 'geometry', type: 'geometry(Point,4326)', transform: 'geojson' }] });
|
|
68
|
+
}
|
|
69
|
+
if (req.method === 'POST' && url.pathname === '/meta/v1/sources/arrets_bus/test') return send(res, 200, { ok: true, source: 'arrets_bus', table: 'public.arrets_bus', readable: true, sample_rows: 1, duration_ms: 87, location: 'https://data.example.org/arrets.geojson?jeton=x' });
|
|
70
|
+
if (req.method === 'POST' && url.pathname === '/meta/v1/sources') return send(res, 201, { name: body.draft.origin.kind === 'file' ? body.draft.table.slice(7) : 'clients', stored: 'file', file: 'poad/sources/clients.yaml', table: 'public.clients', mode: 'virtual', problems: [], report: { created: { migration: 'poad/migrations/20261202000000_source_clients_liee.sql' } } });
|
|
65
71
|
if (req.method === 'POST' && url.pathname === '/meta/v1/sources/clients/test') return send(res, 200, { ok: true, source: 'clients', readable: true, duration_ms: 12 });
|
|
66
72
|
if (req.method === 'POST' && url.pathname === '/meta/v1/sources/inconnue/refresh') return send(res, 404, { error: { code: 'not_found', message: 'source inconnue : inconnue', hint: 'déclarez-la dans poad/sources/inconnue.yaml' } });
|
|
67
73
|
if (req.method === 'GET' && url.pathname === `/flows/v1/runs/${RUN}`) {
|
|
@@ -359,3 +365,80 @@ test('describeReader : feuille, en-tête, enregistrements, répétitions, exécu
|
|
|
359
365
|
assert.strictEqual(source.describeReader({ format: 'csv', csv: { delimiter: ';' } }), null);
|
|
360
366
|
assert.deepStrictEqual(source.FORMATS, ['csv', 'json', 'geojson', 'jsonl', 'ics', 'xlsx', 'ods', 'xml', 'kml', 'kmz', 'gpx']);
|
|
361
367
|
});
|
|
368
|
+
|
|
369
|
+
// --- Tables distantes sur fichier (mode virtual, engine 0.67.0) ---------------------------
|
|
370
|
+
|
|
371
|
+
test('source link --url : colonnes proposées par l’engine, brouillon fichier sans secret, puis source test', async (t) => {
|
|
372
|
+
const cloud = await fakeCloud(t);
|
|
373
|
+
const box = sandbox(t);
|
|
374
|
+
const r = await poad(box, cloud.api, ['source', 'link', 'arrets_bus', '--url', 'https://data.example.org/arrets.geojson?annee=2026', '--columns', 'nom,geometry', '--env', 'dev']);
|
|
375
|
+
noSecret(r);
|
|
376
|
+
assert.strictEqual(r.status, 0, r.all);
|
|
377
|
+
const inspect = cloud.state.requests.find((q) => q.path === '/meta/v1/sources/remote/inspect').body;
|
|
378
|
+
assert.deepStrictEqual(inspect, { url: 'https://data.example.org/arrets.geojson?annee=2026', name: 'arrets_bus' });
|
|
379
|
+
const draft = cloud.state.requests.find((q) => q.path === '/meta/v1/sources' && q.method === 'POST').body.draft;
|
|
380
|
+
assert.deepStrictEqual(draft, {
|
|
381
|
+
table: 'public.arrets_bus',
|
|
382
|
+
mode: 'virtual',
|
|
383
|
+
origin: { kind: 'file', url: 'https://data.example.org/arrets.geojson?annee=2026', format: 'geojson' },
|
|
384
|
+
columns: [{ name: 'nom', from: 'nom', type: 'text' }, { name: 'geometry', from: 'geometry', type: 'geometry(Point,4326)', transform: 'geojson' }],
|
|
385
|
+
});
|
|
386
|
+
assert.match(r.stdout, /geometry {2}geometry\(Point,4326\) {2}\(geojson\)/);
|
|
387
|
+
assert.match(r.stdout, /✔ arrets_bus {2}public\.arrets_bus → https:\/\/data\.example\.org\/arrets\.geojson, 2 columns, nothing copied/);
|
|
388
|
+
assert.ok(!r.stdout.includes('annee=2026 '), 'location printed without its query string');
|
|
389
|
+
const tst = await poad(box, cloud.api, ['source', 'test', 'arrets_bus', '--env', 'dev']);
|
|
390
|
+
assert.strictEqual(tst.status, 0, tst.all);
|
|
391
|
+
assert.match(tst.stdout, /✔ arrets_bus {2}the remote file is readable \(87 ms\), https:\/\/data\.example\.org\/arrets\.geojson\n/);
|
|
392
|
+
assert.ok(!tst.stdout.includes('jeton'), 'no query string');
|
|
393
|
+
});
|
|
394
|
+
|
|
395
|
+
test('source link --storage : objet du Stockage, options CSV, adresse interne refusée, options mêlées', async (t) => {
|
|
396
|
+
const cloud = await fakeCloud(t);
|
|
397
|
+
const box = sandbox(t);
|
|
398
|
+
const r = await poad(box, cloud.api, ['source', 'link', 'communes', '--storage', 'donnees/ref/communes.csv', '--delimiter', ';', '--encoding', 'Latin-1', '--env', 'dev']);
|
|
399
|
+
assert.strictEqual(r.status, 0, r.all);
|
|
400
|
+
const inspect = cloud.state.requests.find((q) => q.path === '/meta/v1/sources/remote/inspect').body;
|
|
401
|
+
assert.deepStrictEqual(inspect, { storage: { bucket: 'donnees', path: 'ref/communes.csv' }, csv: { delimiter: ';', encoding: 'latin-1' }, name: 'communes' });
|
|
402
|
+
const draft = cloud.state.requests.find((q) => q.path === '/meta/v1/sources' && q.method === 'POST').body.draft;
|
|
403
|
+
assert.deepStrictEqual(draft.origin, { kind: 'file', storage: { bucket: 'donnees', path: 'ref/communes.csv' }, format: 'csv', csv: { delimiter: ';', header: true, encoding: 'latin-1' } });
|
|
404
|
+
assert.match(r.stdout, /public\.communes → storage:\/\/donnees\/ref\/communes\.csv, 2 columns/);
|
|
405
|
+
const refused = await poad(box, cloud.api, ['source', 'link', 'interne', '--url', 'http://127.0.0.1:8000/x.csv', '--env', 'dev']);
|
|
406
|
+
assert.strictEqual(refused.status, 1, refused.all);
|
|
407
|
+
assert.match(refused.stdout, /adresse interne refusée \(127\.0\.0\.1\)/);
|
|
408
|
+
assert.strictEqual(cloud.state.requests.filter((q) => q.path === '/meta/v1/sources' && q.method === 'POST').length, 1, 'nothing more declared');
|
|
409
|
+
for (const args of [['source', 'link', 'x', '--url', 'https://a.org/f.csv', '--host', 'h'], ['source', 'link', 'x', '--storage', 'sansChemin'], ['source', 'link', 'x', '--url', 'ftp://a.org/f.csv'], ['source', 'link', 'x', '--url', 'https://a.org/f', '--format', 'xlsx']]) {
|
|
410
|
+
const u = await poad(box, cloud.api, [...args, '--env', 'dev']);
|
|
411
|
+
assert.strictEqual(u.status, 2, `${args.join(' ')}: ${u.all}`);
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
test('parseLinkArgs, parseStorageRef, remoteLocation, remoteDraft : formes et refus', () => {
|
|
416
|
+
const ok = source.parseLinkArgs(['t', '--url', 'https://a.org/f.json', '--format', 'json', '--root', 'data.items']);
|
|
417
|
+
assert.strictEqual(ok.kind, 'file');
|
|
418
|
+
assert.strictEqual(source.parseLinkArgs(['t', '--host', 'h', '--database', 'd', '--remote', 'r', '--credential', 'c']).kind, 'postgres');
|
|
419
|
+
assert.match(source.parseLinkArgs(['t', '--url', 'https://a.org/f.json', '--storage', 'b/p']).message, /not both/);
|
|
420
|
+
assert.match(source.parseLinkArgs(['t', '--url', 'https://u:p@a.org/f.csv']).message, /no user or password/);
|
|
421
|
+
assert.match(source.parseLinkArgs(['t', '--url', 'https://a.org/f.csv', '--format', 'geojson', '--delimiter', ';']).message, /for a CSV file/);
|
|
422
|
+
assert.match(source.parseLinkArgs(['t', '--url', 'https://a.org/f.csv', '--encoding', 'koi8-r']).message, /--encoding/);
|
|
423
|
+
assert.match(source.parseLinkArgs(['t', '--format', 'csv', '--host', 'h']).message, /for a file/);
|
|
424
|
+
assert.deepStrictEqual(source.parseStorageRef('storage://donnees/a/b.csv'), { bucket: 'donnees', path: 'a/b.csv' });
|
|
425
|
+
assert.match(source.parseStorageRef('donnees/../x'), /not an object path/);
|
|
426
|
+
assert.match(source.parseStorageRef('Donnees/x'), /not a bucket name/);
|
|
427
|
+
assert.strictEqual(source.remoteLocation({ url: 'https://a.org/f.csv?token=abc#x' }), 'https://a.org/f.csv');
|
|
428
|
+
assert.strictEqual(source.remoteLocation({ storage: { bucket: 'b', path: 'p/q.json' } }), 'storage://b/p/q.json');
|
|
429
|
+
const d = source.remoteDraft(ok.o, { format: 'json', root: 'ignored' }, [{ name: 'a', from: 'a', type: 'text' }], []);
|
|
430
|
+
assert.deepStrictEqual(d, { table: 'public.t', mode: 'virtual', origin: { kind: 'file', url: 'https://a.org/f.json', format: 'json', root: 'data.items' }, columns: [{ name: 'a', from: 'a', type: 'text' }] });
|
|
431
|
+
const tab = source.parseLinkArgs(['t', '--storage', 'b/f.tsv', '--delimiter', 'tab', '--no-header']);
|
|
432
|
+
assert.deepStrictEqual(source.remoteDraft(tab.o, { format: 'csv' }, [{ name: 'c', from: '#1', type: 'text' }], []).origin.csv, { delimiter: '\\t', header: false });
|
|
433
|
+
assert.deepStrictEqual(source.REMOTE_FORMATS, ['csv', 'json', 'jsonl', 'geojson', 'parquet']);
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
test('sourceLines : table distante sur fichier branchée ou non, emplacement sans query string', () => {
|
|
437
|
+
const s = { name: 'arrets_bus', valid: true, mode: 'virtual', table: 'public.arrets_bus', table_exists: true, origin: { kind: 'file', url: 'https://data.example.org/arrets.geojson?cle=1', storage: null, format: 'geojson' }, remote: { server: 'poad_remote_0123456789ab', attached: true, location: 'https://data.example.org/arrets.geojson', format: 'geojson' }, problems: [] };
|
|
438
|
+
const strip = (lines) => lines.join('\n').replace(/\u001b\[[0-9;]*m/g, '');
|
|
439
|
+
assert.match(strip(source.sourceLines(s)), /✔ arrets_bus {2}remote table \(file\) {2}public\.arrets_bus {2}geojson https:\/\/data\.example\.org\/arrets\.geojson {2}attached/);
|
|
440
|
+
const off = strip(source.sourceLines({ ...s, remote: null, origin: { kind: 'file', url: null, storage: { bucket: 'donnees', path: 'a.csv' }, format: 'csv' }, problems: [{ path: 'origin.url', message: 'adresse interne refusée' }] }));
|
|
441
|
+
assert.match(off, /! arrets_bus {2}remote table \(file\) {2}public\.arrets_bus {2}csv storage:\/\/donnees\/a\.csv {2}not attached/);
|
|
442
|
+
assert.match(off, /poad source test arrets_bus tells why/);
|
|
443
|
+
assert.ok(!off.includes('cle=1'));
|
|
444
|
+
});
|
package/utils/help-details.js
CHANGED
|
@@ -97,7 +97,7 @@ const sheets = {
|
|
|
97
97
|
logs: {
|
|
98
98
|
usage: ['poad logs [service …] [<filter>=<value> …] [-f] [--json]'],
|
|
99
99
|
text: [
|
|
100
|
-
'Unified logs of the project (every service, the project functions and flow steps), the latest 100 lines by default. Services: gateway, data, auth, storage, meta, functions, flows, postgres, logs, engine, mailpit, keycloak, valkey, ai.',
|
|
100
|
+
'Unified logs of the project (every service, the project functions and flow steps), the latest 100 lines by default. Services: gateway, data, auth, storage, meta, functions, flows, postgres, files (remote tables, engine 0.68.0+), logs, engine, mailpit, keycloak, valkey, ai.',
|
|
101
101
|
],
|
|
102
102
|
options: [
|
|
103
103
|
['level=warn', 'warn, error and fatal'],
|
|
@@ -287,7 +287,7 @@ const sheets = {
|
|
|
287
287
|
notes: ['Their logs: poad logs flow=<name>, poad logs run=<id>'],
|
|
288
288
|
},
|
|
289
289
|
source: {
|
|
290
|
-
usage: ['poad source ls [--json]', 'poad source refresh <name> [--force] [--detach]', 'poad source import <file> [--table <table>] [--name <source>] [--key <col,…> | --key-generated uuid|identity|hash] [--existing] [--format …] [--root <path>] [--sheet <name|n>] [--header <row|none>] [--records <path>] [--expand-until <YYYY-MM-DD>] [--kinds wpt,rte,trk] [--detach]', 'poad source link <table> --host <host> --database <db> --remote <schema.table> --credential <name> [--port <port>] [--sslmode require|verify-full|disable] [--columns <col,…>]', 'poad source test <name>', 'poad source pull <name> [--force] [--stdout]', 'poad source ls | refresh | import | link | test | pull … --env <name> [--project <id>]'],
|
|
290
|
+
usage: ['poad source ls [--json]', 'poad source refresh <name> [--force] [--detach]', 'poad source import <file> [--table <table>] [--name <source>] [--key <col,…> | --key-generated uuid|identity|hash] [--existing] [--format …] [--root <path>] [--sheet <name|n>] [--header <row|none>] [--records <path>] [--expand-until <YYYY-MM-DD>] [--kinds wpt,rte,trk] [--detach]', 'poad source link <table> --host <host> --database <db> --remote <schema.table> --credential <name> [--port <port>] [--sslmode require|verify-full|disable] [--columns <col,…>]', 'poad source link <table> --url <https://…> | --storage <bucket>/<path> [--format csv|json|jsonl|geojson|parquet] [--delimiter <c>] [--no-header] [--encoding utf-8|latin-1|utf-16] [--root <a.b>] [--columns <col,…>]', 'poad source test <name>', 'poad source pull <name> [--force] [--stdout]', 'poad source ls | refresh | import | link | test | pull … --env <name> [--project <id>]'],
|
|
291
291
|
text: [
|
|
292
292
|
'Sources of the project: tables kept up to date from a URL (JSON, GeoJSON, CSV, JSONL, ICS calendar, XLSX or ODS spreadsheet, XML such as RSS or Atom, KML, KMZ or GPX), declared in poad/sources/<name>.yaml (engine 0.64.0+; from engine 0.65.0 a source created by poad is named after its table). The engine creates the table with a migration of poad/migrations (read-only for the application, readable through the API with api: true) and a generated flow source-<name> that fills it: download, read, deposit, apply (upsert by key, removals under a guard).',
|
|
293
293
|
'With --env or --project, the commands act on the project hosted on poad.io (session of poad login, owner only) instead of the local engine: poad.io gives an access of 15 minutes, never shown. Locally, the service_role key of the project, never shown.',
|
|
@@ -298,7 +298,8 @@ const sheets = {
|
|
|
298
298
|
['import <file>', 'load a CSV, JSON, GeoJSON, JSONL, ICS, XLSX, ODS, XML, KML, KMZ or GPX file (.gz accepted, no size limit) into a table: the file goes to the system bucket poad-sources (resumable upload when the storage offers it), the engine reads a sample, proposes the columns and a key, declares an imported source (origin kind: upload) and loads it, streamed; a source is named after its table (poad/sources/<table>.yaml); the source already exists: a new version, same path, then the load. --table <name> (default: the file name; cleaned: lowercase, accents removed, spaces → _, leading digit → t_), --name <source> (kept for compatibility: an existing source of that name gets a new version, otherwise ignored), --key <col,…>, --existing (load into an existing table), --format and --root when the guess is wrong. ICS, XLSX, ODS, XML, KML, KMZ and GPX are read by the source-read step itself (engine with meta 1.43.0): --sheet <name or position> and --header <row, or none> for a spreadsheet (default: the first sheet that has rows, first row with two cells or more), --records <path> for XML (channel/item; RSS and Atom are found alone), --expand-until <YYYY-MM-DD> for a calendar (one row per occurrence of repeated events instead of one row per event), --kinds wpt,rte,trk for GPX; what the reader chose is written in the declaration (origin.<format>)'],
|
|
299
299
|
['--key-generated <kind>', 'import, new table without a natural key: poad adds an id column first, key: { generated: <kind> } in the declaration. uuid (gen_random_uuid()) or identity (sequential bigint): each new version replaces the whole table content in one transaction (the API never sees it empty), under the deletion guard on the net row loss; hash: SHA-256 of the row values, an unchanged row keeps its id (a modified row is removed then added)'],
|
|
300
300
|
['link <table>', 'a linked table (mode virtual, engine 0.66.0+): a table of another PostgreSQL database read on every query through a foreign table (postgres_fdw), nothing copied. The engine checks the host (internal addresses refused: private network, localhost, link-local, the engine), connects read-only with the credential (a "Database login" of the vault: user and password, never on the command line), proposes the columns of --remote <schema.table> (--columns keeps some of them, remote names), then writes poad/sources/<table>.yaml and the migration of the foreign table. Private: never served by the API'],
|
|
301
|
-
['
|
|
301
|
+
['link <table> --url | --storage', 'a remote table over a file (mode virtual, engine 0.67.0+): a CSV, JSON (array, --root for where the rows are), JSON-L, GeoJSON (geometry as PostGIS geometry) or Parquet file (.gz accepted) read by poad-files inside Postgres (file_fdw, engine 0.68.0; DuckDB in 0.67.0) on every query, nothing copied: select, where, join with the tables of the project, aggregates; filters are pushed to the file reader. --url <https://…> (internal addresses refused: private network, localhost, link-local, NAT64, the engine, another poad project; no credential, no secret in the address) or --storage <bucket>/<path> (an object of the project storage, local or S3). The engine reads a sample, proposes the columns (--columns keeps some of them, field names), then writes poad/sources/<table>.yaml and the migration of the foreign table. Private: never served by the API Separator, header, encoding, decimal comma and dd/mm/yyyy dates are detected and written to the declaration; --delimiter, --no-header and --encoding only override the detection. A ZIP archive holding one file is read as that file (entry: in the declaration when it holds several).'],
|
|
302
|
+
['test <name>', 'a linked or remote table: check the address again, reattach it and read one row through Postgres (duration, location without its query string); exit code 1 if it cannot be read'],
|
|
302
303
|
['pull <name>', 'write the declaration of a source into poad/sources/<name>.yaml: with --env, a source created in the console of poad.io (kept in the project database); commit it, then poad deploy'],
|
|
303
304
|
['--force', 'refresh: lift the deletion guard (safety.maxDeletePercent) for this run: the source is right even though many rows go away; pull: replace an existing poad/sources/<name>.yaml'],
|
|
304
305
|
['--stdout', 'pull: print the declaration instead of writing the file'],
|
|
@@ -309,7 +310,7 @@ const sheets = {
|
|
|
309
310
|
],
|
|
310
311
|
notes: [
|
|
311
312
|
'A run that would remove more rows than safety.maxDeletePercent allows (or empty a table) is refused and changes nothing: check the source, then poad source refresh <name> --force.',
|
|
312
|
-
'A linked table is not refreshed (poad source refresh refuses it): every query reads the remote database. Read it in SQL, through a security_invoker view or a function.',
|
|
313
|
+
'A linked or remote table is not refreshed (poad source refresh refuses it): every query reads the remote database or file again. Read it in SQL, through a security_invoker view or a function; a query on a large file is bounded by statement_timeout like any other.',
|
|
313
314
|
'Their logs: poad logs source=<name>; the run: poad flows show <run_id>. poad deploy sends poad/sources to poad.io.',
|
|
314
315
|
'Sources can also be created in the console (Sources, New source): locally it writes poad/sources/<name>.yaml; on poad.io it keeps the declaration in the project ("created in the console") until poad source pull <name> --env <name> brings it into the repository.',
|
|
315
316
|
],
|