@postgres.ai/shared 4.0.2-pr-1148 → 4.0.2-pr-1149

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.
Files changed (35) hide show
  1. package/package.json +1 -1
  2. package/pages/Instance/Configuration/configOptions.d.ts +0 -6
  3. package/pages/Instance/Configuration/configOptions.js +0 -48
  4. package/pages/Instance/Configuration/index.d.ts +2 -1
  5. package/pages/Instance/Configuration/index.js +86 -115
  6. package/pages/Instance/Configuration/useForm.d.ts +0 -20
  7. package/pages/Instance/Configuration/useForm.js +5 -126
  8. package/pages/Instance/Configuration/utils/index.js +17 -1
  9. package/pages/Instance/index.js +3 -1
  10. package/pages/Instance/stores/Main.d.ts +0 -20
  11. package/pages/Instance/stores/Main.js +0 -9
  12. package/types/api/entities/config.d.ts +0 -32
  13. package/types/api/entities/config.js +18 -45
  14. package/pages/Instance/Configuration/PhysicalMode/EnvsEditor/index.d.ts +0 -11
  15. package/pages/Instance/Configuration/PhysicalMode/EnvsEditor/index.js +0 -24
  16. package/pages/Instance/Configuration/PhysicalMode/PgBackRest/index.d.ts +0 -10
  17. package/pages/Instance/Configuration/PhysicalMode/PgBackRest/index.js +0 -29
  18. package/pages/Instance/Configuration/PhysicalMode/Sync/index.d.ts +0 -9
  19. package/pages/Instance/Configuration/PhysicalMode/Sync/index.js +0 -14
  20. package/pages/Instance/Configuration/PhysicalMode/Walg/index.d.ts +0 -10
  21. package/pages/Instance/Configuration/PhysicalMode/Walg/index.js +0 -21
  22. package/pages/Instance/Configuration/PhysicalMode/index.d.ts +0 -10
  23. package/pages/Instance/Configuration/PhysicalMode/index.js +0 -17
  24. package/pages/Instance/Configuration/SimpleMode/PreviewCard.d.ts +0 -11
  25. package/pages/Instance/Configuration/SimpleMode/PreviewCard.js +0 -14
  26. package/pages/Instance/Configuration/SimpleMode/index.d.ts +0 -14
  27. package/pages/Instance/Configuration/SimpleMode/index.js +0 -107
  28. package/pages/Instance/Configuration/configMode.d.ts +0 -2
  29. package/pages/Instance/Configuration/configMode.js +0 -7
  30. package/pages/Instance/Configuration/connectionString.d.ts +0 -20
  31. package/pages/Instance/Configuration/connectionString.js +0 -129
  32. package/pages/Instance/Configuration/dockerCatalog.d.ts +0 -2
  33. package/pages/Instance/Configuration/dockerCatalog.js +0 -19
  34. package/types/api/endpoints/probeSource.d.ts +0 -32
  35. package/types/api/endpoints/probeSource.js +0 -1
@@ -1,20 +0,0 @@
1
- export declare type ConnectionFields = {
2
- host: string;
3
- port: string;
4
- username: string;
5
- dbname: string;
6
- };
7
- export declare type ParseResult = {
8
- fields: ConnectionFields;
9
- portWasExplicit: boolean;
10
- };
11
- export declare class ConnectionStringError extends Error {
12
- }
13
- export declare const ErrPasswordInConnectionString = "Password must be entered in the Password field, not the connection string.";
14
- export declare const ErrMultiHost = "Multi-host connection strings are not supported.";
15
- export declare const ErrInvalidConnectionString = "Could not parse the connection string.";
16
- export declare const connectionStringToFields: (s: string) => ParseResult;
17
- export declare type SerializeOptions = {
18
- omitDefaultPort?: boolean;
19
- };
20
- export declare const connectionStringFromFields: (fields: ConnectionFields, opts?: SerializeOptions) => string;
@@ -1,129 +0,0 @@
1
- // connectionString.ts — Expert-mode helper that converts between the
2
- // (host, port, username, dbname) shape stored in `server.yml` and the
3
- // single URL field the form exposes. The engine remains the source of
4
- // truth for actual probing (see engine/internal/retrieval/probe/parser.go);
5
- // this parser only powers the form's load/save round-trip.
6
- //
7
- // Accepts both URI form (postgres://user@host:5432/dbname) and DSN form
8
- // (host=db port=5432 user=app dbname=shop). Rejects any input that carries
9
- // a password — passwords belong in the masked field, never the URL field.
10
- export class ConnectionStringError extends Error {
11
- }
12
- export const ErrPasswordInConnectionString = 'Password must be entered in the Password field, not the connection string.';
13
- export const ErrMultiHost = 'Multi-host connection strings are not supported.';
14
- export const ErrInvalidConnectionString = 'Could not parse the connection string.';
15
- const URI_SCHEMES = ['postgres:', 'postgresql:'];
16
- const isUri = (s) => URI_SCHEMES.some((p) => s.toLowerCase().startsWith(p));
17
- const stripBrackets = (h) => (h.startsWith('[') && h.endsWith(']') ? h.slice(1, -1) : h);
18
- const parseUri = (s) => {
19
- let url;
20
- try {
21
- url = new URL(s);
22
- }
23
- catch {
24
- throw new ConnectionStringError(ErrInvalidConnectionString);
25
- }
26
- if (url.password)
27
- throw new ConnectionStringError(ErrPasswordInConnectionString);
28
- if (!url.hostname)
29
- throw new ConnectionStringError(ErrInvalidConnectionString);
30
- if (url.hostname.includes(','))
31
- throw new ConnectionStringError(ErrMultiHost);
32
- const portWasExplicit = url.port !== '';
33
- const path = url.pathname.startsWith('/') ? url.pathname.slice(1) : url.pathname;
34
- const dbname = path.includes(',') ? '' : decodeURIComponent(path);
35
- return {
36
- fields: {
37
- host: stripBrackets(url.hostname),
38
- port: portWasExplicit ? url.port : '5432',
39
- username: url.username ? decodeURIComponent(url.username) : '',
40
- dbname,
41
- },
42
- portWasExplicit,
43
- };
44
- };
45
- // Tokenizer for libpq DSN form: key=value pairs, values may be single-quoted
46
- // when they contain spaces (libpq spec). Throws on malformed input.
47
- const tokenizeDsn = (s) => {
48
- const out = {};
49
- let i = 0;
50
- while (i < s.length) {
51
- // skip leading whitespace
52
- while (i < s.length && /\s/.test(s[i]))
53
- i++;
54
- if (i >= s.length)
55
- break;
56
- // read key
57
- const keyStart = i;
58
- while (i < s.length && s[i] !== '=' && !/\s/.test(s[i]))
59
- i++;
60
- if (i >= s.length || s[i] !== '=')
61
- throw new ConnectionStringError(ErrInvalidConnectionString);
62
- const key = s.slice(keyStart, i);
63
- i++; // skip '='
64
- // read value (possibly quoted)
65
- let value = '';
66
- if (s[i] === "'") {
67
- i++;
68
- while (i < s.length && s[i] !== "'") {
69
- if (s[i] === '\\' && i + 1 < s.length) {
70
- value += s[i + 1];
71
- i += 2;
72
- continue;
73
- }
74
- value += s[i];
75
- i++;
76
- }
77
- if (i >= s.length)
78
- throw new ConnectionStringError(ErrInvalidConnectionString);
79
- i++; // skip closing quote
80
- }
81
- else {
82
- while (i < s.length && !/\s/.test(s[i])) {
83
- value += s[i];
84
- i++;
85
- }
86
- }
87
- out[key.toLowerCase()] = value;
88
- }
89
- return out;
90
- };
91
- const parseDsn = (s) => {
92
- var _a, _b, _c, _d, _e, _f, _g;
93
- const tokens = tokenizeDsn(s);
94
- if (tokens.password)
95
- throw new ConnectionStringError(ErrPasswordInConnectionString);
96
- const host = (_b = (_a = tokens.host) !== null && _a !== void 0 ? _a : tokens.hostaddr) !== null && _b !== void 0 ? _b : '';
97
- if (host.includes(','))
98
- throw new ConnectionStringError(ErrMultiHost);
99
- const portRaw = (_c = tokens.port) !== null && _c !== void 0 ? _c : '';
100
- const portWasExplicit = portRaw !== '';
101
- return {
102
- fields: {
103
- host,
104
- port: portWasExplicit ? portRaw : '5432',
105
- username: (_e = (_d = tokens.user) !== null && _d !== void 0 ? _d : tokens.username) !== null && _e !== void 0 ? _e : '',
106
- dbname: (_g = (_f = tokens.dbname) !== null && _f !== void 0 ? _f : tokens.database) !== null && _g !== void 0 ? _g : '',
107
- },
108
- portWasExplicit,
109
- };
110
- };
111
- export const connectionStringToFields = (s) => {
112
- const trimmed = s.trim();
113
- if (!trimmed)
114
- throw new ConnectionStringError(ErrInvalidConnectionString);
115
- if (isUri(trimmed))
116
- return parseUri(trimmed);
117
- if (trimmed.includes('='))
118
- return parseDsn(trimmed);
119
- throw new ConnectionStringError(ErrInvalidConnectionString);
120
- };
121
- // formatHost wraps IPv6 literals in brackets so the resulting URI parses cleanly.
122
- const formatHost = (host) => (host.includes(':') ? `[${host}]` : host);
123
- export const connectionStringFromFields = (fields, opts = {}) => {
124
- const userPart = fields.username ? `${encodeURIComponent(fields.username)}@` : '';
125
- const showPort = fields.port && !(opts.omitDefaultPort && fields.port === '5432');
126
- const portPart = showPort ? `:${fields.port}` : '';
127
- const dbPart = fields.dbname ? `/${encodeURIComponent(fields.dbname)}` : '';
128
- return `postgres://${userPart}${formatHost(fields.host)}${portPart}${dbPart}`;
129
- };
@@ -1,2 +0,0 @@
1
- export declare const genericImagePrefix = "postgresai/extended-postgres";
2
- export declare const dockerImagesConfig: Record<string, string[]>;
@@ -1,19 +0,0 @@
1
- // Shared image-catalog constants. Kept in its own module so both
2
- // `configOptions.ts` and `utils/index.ts` can read them without creating
3
- // an import cycle (utils → configOptions today).
4
- export const genericImagePrefix = 'postgresai/extended-postgres';
5
- // Predefined Docker image catalog for the Generic Postgres image. If a
6
- // user's config references a tag not listed here, createEnhancedDockerImages
7
- // in utils/index.ts appends it at runtime.
8
- export const dockerImagesConfig = {
9
- '9.6': ['0.5.3', '0.5.2', '0.5.1'],
10
- '10': ['0.5.3', '0.5.2', '0.5.1'],
11
- '11': ['0.5.3', '0.5.2', '0.5.1'],
12
- '12': ['0.5.3', '0.5.2', '0.5.1'],
13
- '13': ['0.5.3', '0.5.2', '0.5.1'],
14
- '14': ['0.5.3', '0.5.2', '0.5.1'],
15
- '15': ['0.5.3', '0.5.2', '0.5.1'],
16
- '16': ['0.5.3', '0.5.2', '0.5.1'],
17
- '17': ['0.5.3', '0.5.2', '0.5.1'],
18
- '18': ['0.6.1'],
19
- };
@@ -1,32 +0,0 @@
1
- export declare type ProbeSourceRequest = {
2
- url: string;
3
- password: string;
4
- };
5
- export declare type SourceConnection = {
6
- host: string;
7
- port: number;
8
- username: string;
9
- dbname: string;
10
- };
11
- export declare type ProposedConfig = {
12
- source: SourceConnection;
13
- detectedProvider: string;
14
- dockerImage: string;
15
- dockerTag: string;
16
- pgMajorVersion: number;
17
- databases: string[];
18
- sharedBuffers: string;
19
- memoryProbed: boolean;
20
- sharedPreloadLibraries: string;
21
- queryTuning: {
22
- [key: string]: string;
23
- };
24
- };
25
- export declare type ProbeSourceError = {
26
- status: number;
27
- message: string;
28
- };
29
- export declare type ProbeSource = (req: ProbeSourceRequest) => Promise<{
30
- response: ProposedConfig | null;
31
- error: ProbeSourceError | null;
32
- }>;
@@ -1 +0,0 @@
1
- export {};