poad 2.22.0 → 2.23.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 +2 -2
- package/utils/compact.js +16 -2
package/package.json
CHANGED
package/utils/compact.js
CHANGED
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
// Même code dans le CLI (utils/compact.js) : poad db diff regroupe pareil.
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
28
|
exports.compact = exports.classify = void 0;
|
|
29
|
+
// Interrupteurs API et Temps réel de la console : leurs formes exactes seulement
|
|
30
|
+
// (un GRANT partiel écrit à la main reste tel quel)
|
|
31
|
+
const API_ON_RE = /^\s*grant\s+select,\s*insert,\s*update,\s*delete\s+on\s+table\s+(.+?)\s+to\s+anon,\s*authenticated\s*;?\s*$/is;
|
|
32
|
+
const API_OFF_RE = /^\s*revoke\s+all\s+on\s+table\s+(.+?)\s+from\s+anon,\s*authenticated\s*;?\s*$/is;
|
|
29
33
|
const RLS_RE = /^\s*alter\s+table\s+(?:if\s+exists\s+)?(?:only\s+)?(.+?)\s+(enable|disable)\s+row\s+level\s+security\s*;?\s*$/is;
|
|
30
34
|
/** Objet unique et opération d'une entrée, ou null si elle n'est pas regroupable */
|
|
31
35
|
const classify = (e) => {
|
|
@@ -45,6 +49,14 @@ const classify = (e) => {
|
|
|
45
49
|
};
|
|
46
50
|
if (by[cmd])
|
|
47
51
|
return { kind: by[cmd][0], target, op: by[cmd][1] };
|
|
52
|
+
if (cmd === 'ALTER PUBLICATION')
|
|
53
|
+
return { kind: 'realtime', target, op: 'on' };
|
|
54
|
+
if (cmd === 'DROP PUBLICATION RELATION')
|
|
55
|
+
return { kind: 'realtime', target, op: 'off' };
|
|
56
|
+
if (cmd === 'GRANT' && API_ON_RE.test(e.statement))
|
|
57
|
+
return { kind: 'api', target, op: 'on' };
|
|
58
|
+
if (cmd === 'REVOKE' && API_OFF_RE.test(e.statement))
|
|
59
|
+
return { kind: 'api', target, op: 'off' };
|
|
48
60
|
if (cmd === 'ALTER TABLE') {
|
|
49
61
|
const m = RLS_RE.exec(e.statement);
|
|
50
62
|
if (m)
|
|
@@ -56,6 +68,8 @@ exports.classify = classify;
|
|
|
56
68
|
const RESULT = {
|
|
57
69
|
extension: ['activée', 'désactivée'],
|
|
58
70
|
rls: ['RLS activé', 'RLS désactivé'],
|
|
71
|
+
api: ['publiée dans l’API', 'retirée de l’API'],
|
|
72
|
+
realtime: ['temps réel activé', 'temps réel désactivé'],
|
|
59
73
|
policy: ['créée', 'supprimée'],
|
|
60
74
|
index: ['créé', 'supprimé'],
|
|
61
75
|
};
|
|
@@ -66,7 +80,7 @@ const net = (kind, items) => {
|
|
|
66
80
|
const after = ops.at(-1) === 'off' ? 'off' : 'on';
|
|
67
81
|
const lastOff = ops.lastIndexOf('off');
|
|
68
82
|
const lastOn = ops.lastIndexOf('on');
|
|
69
|
-
const stateOnly = kind === 'extension' || kind === 'rls';
|
|
83
|
+
const stateOnly = kind === 'extension' || kind === 'rls' || kind === 'api' || kind === 'realtime';
|
|
70
84
|
let keep;
|
|
71
85
|
if (before === 'off' && after === 'off')
|
|
72
86
|
keep = [];
|
|
@@ -103,7 +117,7 @@ const compact = (entries) => {
|
|
|
103
117
|
const ids = g.items.map((i) => i.id);
|
|
104
118
|
const mine = new Set(ids);
|
|
105
119
|
const between = entries.filter((e) => e.id > ids[0] && e.id < ids.at(-1) && !mine.has(e.id));
|
|
106
|
-
const free = between.every((e) =>
|
|
120
|
+
const free = between.every((e) => ['policy', 'rls', 'api', 'realtime'].includes(kindOf.get(e.id) ?? ''));
|
|
107
121
|
if (!free) {
|
|
108
122
|
// Des changements dépendent peut-être des états intermédiaires : tout est gardé
|
|
109
123
|
for (const id of ids)
|