@antelopejs/dms 0.20.4 → 0.20.5

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 (65) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/implementations/dms-builder/engine/database-access.d.ts +1 -16
  4. package/dist/implementations/dms-builder/engine/database-access.js +13 -44
  5. package/dist/implementations/dms-builder/engine/database-access.js.map +1 -1
  6. package/dist/implementations/dms-builder/engine/database-check.d.ts +1 -2
  7. package/dist/implementations/dms-builder/engine/database-check.js +28 -15
  8. package/dist/implementations/dms-builder/engine/database-check.js.map +1 -1
  9. package/dist/implementations/dms-builder/engine/driver-packages.d.ts +1 -0
  10. package/dist/implementations/dms-builder/engine/driver-packages.js +4 -0
  11. package/dist/implementations/dms-builder/engine/driver-packages.js.map +1 -1
  12. package/dist/implementations/dms-builder/engine/driver-probe.d.ts +27 -0
  13. package/dist/implementations/dms-builder/engine/driver-probe.js +53 -0
  14. package/dist/implementations/dms-builder/engine/driver-probe.js.map +1 -0
  15. package/dist/implementations/dms-builder/engine/index.d.ts +2 -6
  16. package/dist/implementations/dms-builder/engine/index.js +2 -6
  17. package/dist/implementations/dms-builder/engine/index.js.map +1 -1
  18. package/dist/implementations/dms-builder/engine/probe-answer.d.ts +4 -0
  19. package/dist/implementations/dms-builder/engine/probe-answer.js +90 -0
  20. package/dist/implementations/dms-builder/engine/probe-answer.js.map +1 -0
  21. package/dist/implementations/dms-builder/engine/probe-child.d.ts +1 -0
  22. package/dist/implementations/dms-builder/engine/probe-child.js +70 -0
  23. package/dist/implementations/dms-builder/engine/probe-child.js.map +1 -0
  24. package/dist/implementations/dms-builder/engine/probe-process.d.ts +2 -0
  25. package/dist/implementations/dms-builder/engine/probe-process.js +132 -0
  26. package/dist/implementations/dms-builder/engine/probe-process.js.map +1 -0
  27. package/dist/implementations/dms-builder/engine/probe-protocol.d.ts +46 -0
  28. package/dist/implementations/dms-builder/engine/probe-protocol.js +18 -0
  29. package/dist/implementations/dms-builder/engine/probe-protocol.js.map +1 -0
  30. package/dist/mockup/fixtures.d.ts +1 -1
  31. package/dist/routes/system-state.d.ts +1 -1
  32. package/package.json +5 -19
  33. package/dist/implementations/dms-builder/engine/access-mongodb.d.ts +0 -20
  34. package/dist/implementations/dms-builder/engine/access-mongodb.js +0 -30
  35. package/dist/implementations/dms-builder/engine/access-mongodb.js.map +0 -1
  36. package/dist/implementations/dms-builder/engine/access-mysql.d.ts +0 -8
  37. package/dist/implementations/dms-builder/engine/access-mysql.js +0 -11
  38. package/dist/implementations/dms-builder/engine/access-mysql.js.map +0 -1
  39. package/dist/implementations/dms-builder/engine/access-postgres.d.ts +0 -8
  40. package/dist/implementations/dms-builder/engine/access-postgres.js +0 -11
  41. package/dist/implementations/dms-builder/engine/access-postgres.js.map +0 -1
  42. package/dist/implementations/dms-builder/engine/probe-client.d.ts +0 -19
  43. package/dist/implementations/dms-builder/engine/probe-client.js +0 -50
  44. package/dist/implementations/dms-builder/engine/probe-client.js.map +0 -1
  45. package/dist/implementations/dms-builder/engine/probe-connections.d.ts +0 -10
  46. package/dist/implementations/dms-builder/engine/probe-connections.js +0 -43
  47. package/dist/implementations/dms-builder/engine/probe-connections.js.map +0 -1
  48. package/dist/implementations/dms-builder/engine/probe-mongodb.d.ts +0 -2
  49. package/dist/implementations/dms-builder/engine/probe-mongodb.js +0 -148
  50. package/dist/implementations/dms-builder/engine/probe-mongodb.js.map +0 -1
  51. package/dist/implementations/dms-builder/engine/probe-mysql.d.ts +0 -2
  52. package/dist/implementations/dms-builder/engine/probe-mysql.js +0 -189
  53. package/dist/implementations/dms-builder/engine/probe-mysql.js.map +0 -1
  54. package/dist/implementations/dms-builder/engine/probe-postgres.d.ts +0 -2
  55. package/dist/implementations/dms-builder/engine/probe-postgres.js +0 -164
  56. package/dist/implementations/dms-builder/engine/probe-postgres.js.map +0 -1
  57. package/dist/implementations/dms-builder/engine/probe-rethinkdb.d.ts +0 -2
  58. package/dist/implementations/dms-builder/engine/probe-rethinkdb.js +0 -92
  59. package/dist/implementations/dms-builder/engine/probe-rethinkdb.js.map +0 -1
  60. package/dist/implementations/dms-builder/engine/rethinkdb-client.d.ts +0 -34
  61. package/dist/implementations/dms-builder/engine/rethinkdb-client.js +0 -3
  62. package/dist/implementations/dms-builder/engine/rethinkdb-client.js.map +0 -1
  63. package/dist/implementations/dms-builder/engine/scram-bound.d.ts +0 -5
  64. package/dist/implementations/dms-builder/engine/scram-bound.js +0 -60
  65. package/dist/implementations/dms-builder/engine/scram-bound.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.20.5
4
+
5
+ [compare changes](https://github.com/AntelopeJS/dms/compare/v0.20.4...v0.20.5)
6
+
7
+ ### 💅 Refactors
8
+
9
+ - **dms:** Check a database connection with the probe its driver exports ([#1055](https://github.com/AntelopeJS/dms/pull/1055))
10
+
11
+ ### ❤️ Contributors
12
+
13
+ - Antony Rizzitelli ([@Upd4ting](http://github.com/Upd4ting))
14
+
3
15
  ## v0.20.4
4
16
 
5
17
  [compare changes](https://github.com/AntelopeJS/dms/compare/v0.20.3...v0.20.4)
package/README.md CHANGED
@@ -84,7 +84,7 @@ export class SalesPage extends PageController("sales", {
84
84
  | `@antelopejs/interface-api-util` | `>=0.3.0 <0.4.0` | `0.3.0` |
85
85
  | `@antelopejs/interface-core` | `>=0.5.1 <0.6.0` | `0.5.1` |
86
86
  | `@antelopejs/interface-data-api` | `>=0.8.0 <0.9.0` | `0.8.0` |
87
- | `@antelopejs/interface-database` | `>=0.4.0 <0.5.0` | `0.4.0` |
87
+ | `@antelopejs/interface-database` | `>=0.4.0 <0.5.0` | `0.4.1` |
88
88
  | `@antelopejs/interface-database-catalog` | `>=0.1.0 <0.2.0` | `0.1.0` |
89
89
  | `@antelopejs/interface-database-decorators` | `>=0.5.2 <0.6.0` | `0.5.2` |
90
90
  | `@antelopejs/interface-dms` | `>=0.14.0 <0.15.0` | `0.14.2` |
@@ -1,22 +1,7 @@
1
1
  import type { DatabaseAccess } from "@antelopejs/interface-dms-builder";
2
- import type { ProbeConnections } from "./probe-connections";
3
2
  export declare const DATABASE_ENGINES: readonly ["postgres", "mysql", "mongodb", "rethinkdb"];
4
- export interface Privileges {
5
- canRead: boolean;
6
- canWrite: boolean;
7
- }
8
- export interface RelationAccess {
9
- readable: boolean;
10
- writable: boolean;
11
- }
12
- export type Probe = (url: string, timeoutMs: number, connections: ProbeConnections) => Promise<DatabaseAccess>;
13
- export declare function summarizeRelations(relations: readonly RelationAccess[]): Privileges;
14
3
  export declare function unanswered(reason: string): DatabaseAccess;
15
- export declare function refusedBy(reason: string): DatabaseAccess;
16
- export declare function signedIn(latencyMs: number, user: string | undefined, privileges: Privileges, unreadable?: string): DatabaseAccess;
17
- export declare function missingClient(packageName: string, engineLabel: string): DatabaseAccess;
18
- export declare function hasControlCharacter(url: string): boolean;
19
4
  export declare function redact(message: string, url: string): string;
20
5
  export declare function failureMessage(error: unknown): string;
21
6
  export declare function noAnswerReason(message: string, url: string): string;
22
- export declare function serverRefusal(message: string, url: string): string;
7
+ export declare function signInRefusal(message: string, url: string): string;
@@ -1,16 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DATABASE_ENGINES = void 0;
4
- exports.summarizeRelations = summarizeRelations;
5
4
  exports.unanswered = unanswered;
6
- exports.refusedBy = refusedBy;
7
- exports.signedIn = signedIn;
8
- exports.missingClient = missingClient;
9
- exports.hasControlCharacter = hasControlCharacter;
10
5
  exports.redact = redact;
11
6
  exports.failureMessage = failureMessage;
12
7
  exports.noAnswerReason = noAnswerReason;
13
- exports.serverRefusal = serverRefusal;
8
+ exports.signInRefusal = signInRefusal;
14
9
  const zod_1 = require("zod");
15
10
  exports.DATABASE_ENGINES = [
16
11
  "postgres",
@@ -18,52 +13,22 @@ exports.DATABASE_ENGINES = [
18
13
  "mongodb",
19
14
  "rethinkdb",
20
15
  ];
21
- const NO_READ = "This account cannot read this database.";
22
16
  const NOT_CHECKED = "Could not check the database";
17
+ const NO_MESSAGE = "The database could not be reached at this host and port.";
23
18
  const REDACTED = "[hidden]";
24
19
  const USERINFO = /^[a-z][a-z0-9+.-]*:\/\/([^/?#]*)@/i;
25
20
  const CONNECTION_STRING = /(?<![a-z0-9+.-])[a-z0-9+.-]+:\/\/[^\s"']+/gi;
26
21
  const NO_ANSWER_REASONS = [
27
22
  [/ECONNREFUSED/, "Nothing is listening at this host and port."],
28
23
  [/ENOTFOUND|EAI_AGAIN/, "This host name could not be found."],
29
- [/time(?:d)? ?out|in less than/i, "The database did not answer in time."],
24
+ [
25
+ /time(?:d)? ?out|in less than|did not answer/i,
26
+ "The database did not answer in time.",
27
+ ],
30
28
  ];
31
- function summarizeRelations(relations) {
32
- return {
33
- canRead: relations.length === 0 || relations.some(({ readable }) => readable),
34
- canWrite: relations.some(({ writable }) => writable),
35
- };
36
- }
37
29
  function unanswered(reason) {
38
30
  return { reachable: false, canRead: false, canWrite: false, reason };
39
31
  }
40
- function refusedBy(reason) {
41
- return { reachable: true, canRead: false, canWrite: false, reason };
42
- }
43
- function signedIn(latencyMs, user, privileges, unreadable = NO_READ) {
44
- const access = { reachable: true, latencyMs, ...privileges };
45
- if (user !== undefined) {
46
- access.user = user;
47
- }
48
- if (!privileges.canRead) {
49
- access.reason = unreadable;
50
- }
51
- return access;
52
- }
53
- function missingClient(packageName, engineLabel) {
54
- return unanswered(`Install ${packageName} to connect a ${engineLabel} database.`);
55
- }
56
- const LAST_CONTROL_CHARACTER = 0x1f;
57
- const DELETE_CHARACTER = 0x7f;
58
- function hasControlCharacter(url) {
59
- for (let index = 0; index < url.length; index += 1) {
60
- const code = url.charCodeAt(index);
61
- if (code <= LAST_CONTROL_CHARACTER || code === DELETE_CHARACTER) {
62
- return true;
63
- }
64
- }
65
- return false;
66
- }
67
32
  function decoded(text) {
68
33
  try {
69
34
  return decodeURIComponent(text);
@@ -87,6 +52,7 @@ function redact(message, url) {
87
52
  }
88
53
  const ThrownMessage = zod_1.z
89
54
  .instanceof(Error)
55
+ .pipe(zod_1.z.object({ message: zod_1.z.string() }))
90
56
  .transform(({ message }) => message)
91
57
  .catch("The check ended with an error that carries no message.");
92
58
  function failureMessage(error) {
@@ -100,11 +66,14 @@ function withoutQuery(message) {
100
66
  return QUERY_ECHOES.reduce((text, echo) => text.replace(echo, ""), message);
101
67
  }
102
68
  function noAnswerReason(message, url) {
103
- const text = withoutQuery(message);
69
+ const text = withoutQuery(message).trim();
70
+ if (text === "") {
71
+ return NO_MESSAGE;
72
+ }
104
73
  const known = NO_ANSWER_REASONS.find(([pattern]) => pattern.test(text));
105
74
  return known ? known[1] : `${NOT_CHECKED}: ${redact(text, url)}`;
106
75
  }
107
- function serverRefusal(message, url) {
108
- return `The server refused the request: ${redact(withoutQuery(message), url)}`;
76
+ function signInRefusal(message, url) {
77
+ return `Could not sign in: ${redact(withoutQuery(message), url)}`;
109
78
  }
110
79
  //# sourceMappingURL=database-access.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"database-access.js","sourceRoot":"","sources":["../../../../src/implementations/dms-builder/engine/database-access.ts"],"names":[],"mappings":";;;AAuDA,gDAQC;AAGD,gCAEC;AAGD,8BAEC;AAMD,4BAcC;AAGD,sCAOC;AASD,kDAQC;AAqBD,wBAKC;AAQD,wCAEC;AAiBD,wCAIC;AAGD,sCAEC;AAlLD,6BAAwB;AAMX,QAAA,gBAAgB,GAAG;IAC9B,UAAU;IACV,OAAO;IACP,SAAS;IACT,WAAW;CACiC,CAAC;AAuB/C,MAAM,OAAO,GAAG,yCAAyC,CAAC;AAC1D,MAAM,WAAW,GAAG,8BAA8B,CAAC;AACnD,MAAM,QAAQ,GAAG,UAAU,CAAC;AAC5B,MAAM,QAAQ,GAAG,oCAAoC,CAAC;AACtD,MAAM,iBAAiB,GAAG,6CAA6C,CAAC;AAExE,MAAM,iBAAiB,GAA2C;IAChE,CAAC,c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AC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;AACnE,CAAC;AAGD,SAAgB,aAAa,CAAC,OAAe,EAAE,GAAW;IACxD,OAAO,mCAAmC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AACjF,CAAC"}
1
+ {"version":3,"file":"database-access.js","sourceRoot":"","sources":["../../../../src/implementations/dms-builder/engine/database-access.ts"],"names":[],"mappings":";;;AAiCA,gCAEC;AAqBD,wBAKC;AASD,wCAEC;AAiBD,wCAOC;AAOD,sCAEC;AArGD,6BAAwB;AAKX,QAAA,gBAAgB,GAAG;IAC9B,UAAU;IACV,OAAO;IACP,SAAS;IACT,WAAW;CACiC,CAAC;AAE/C,MAAM,WAAW,GAAG,8BAA8B,CAAC;AAEnD,MAAM,UAAU,GAAG,0DAA0D,CAAC;AAC9E,MAAM,QAAQ,GAAG,UAAU,CAAC;AAC5B,MAAM,QAAQ,GAAG,oCAAoC,CAAC;AACtD,MAAM,iBAAiB,GAAG,6CAA6C,CAAC;AAExE,MAAM,iBAAiB,GAA2C;IAChE,CAAC,cAAc,EAAE,6CAA6C,CAAC;IAC/D,CAAC,qBAAqB,EAAE,oCAAoC,CAAC;IAC7D;QACE,8CAA8C;QAC9C,sCAAsC;KACvC;CACF,CAAC;AAGF,SAAgB,UAAU,CAAC,MAAc;IACvC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACvE,CAAC;AAED,SAAS,OAAO,CAAC,IAAY;IAC3B,IAAI,CAAC;QACH,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,GAAW;IAC5B,MAAM,QAAQ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GnE,SAAgB,cAAc,CAAC,KAAc;IAC3C,OAAO,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC;AAMD,MAAM,YAAY,GAAsB;IACtC,4BAA4B;IAC5B,2BAA2B;CAC5B,CAAC;AAGF,SAAS,YAAY,CAAC,OAAe;IACnC,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC;AAC9E,CAAC;AAGD,SAAgB,cAAc,CAAC,OAAe,EAAE,GAAW;IACzD,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1C,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QAChB,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACxE,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;AACnE,CAAC;AAOD,SAAgB,aAAa,CAAC,OAAe,EAAE,GAAW;IACxD,OAAO,sBAAsB,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AACpE,CAAC"}
@@ -1,4 +1,3 @@
1
1
  import type { DatabaseAccess, DatabaseEngine } from "@antelopejs/interface-dms-builder";
2
- import { type Probe } from "./database-access";
3
2
  export declare const CONNECT_TIMEOUT_MS = 5000;
4
- export declare function checkDatabase(engine: DatabaseEngine, url: string, timeoutMs?: number, probes?: Readonly<Record<DatabaseEngine, Probe>>): Promise<DatabaseAccess>;
3
+ export declare function checkDatabase(engine: DatabaseEngine, url: string, timeoutMs?: number): Promise<DatabaseAccess>;
@@ -3,35 +3,48 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CONNECT_TIMEOUT_MS = void 0;
4
4
  exports.checkDatabase = checkDatabase;
5
5
  const database_access_1 = require("./database-access");
6
- const probe_connections_1 = require("./probe-connections");
7
- const probe_mongodb_1 = require("./probe-mongodb");
8
- const probe_mysql_1 = require("./probe-mysql");
9
- const probe_postgres_1 = require("./probe-postgres");
10
- const probe_rethinkdb_1 = require("./probe-rethinkdb");
6
+ const driver_probe_1 = require("./driver-probe");
7
+ const probe_process_1 = require("./probe-process");
8
+ const probe_answer_1 = require("./probe-answer");
11
9
  exports.CONNECT_TIMEOUT_MS = 5000;
12
10
  const DEADLINE_IN_TIMEOUTS = 3;
13
11
  const TOO_SLOW = "The database did not answer in time.";
14
- const PROBES = {
15
- postgres: probe_postgres_1.probePostgres,
16
- mysql: probe_mysql_1.probeMysql,
17
- mongodb: probe_mongodb_1.probeMongodb,
18
- rethinkdb: probe_rethinkdb_1.probeRethinkdb,
19
- };
20
- async function checkDatabase(engine, url, timeoutMs = exports.CONNECT_TIMEOUT_MS, probes = PROBES) {
21
- const connections = new probe_connections_1.ProbeConnections();
12
+ const UNREADABLE_FAILURE = "The check ended with an error it could not read.";
13
+ async function probeWithDriver(engine, url, timeoutMs, signal) {
14
+ const loader = (0, driver_probe_1.testProbeLoader)();
15
+ if (loader) {
16
+ const probe = loader(engine);
17
+ return probe
18
+ ? (0, probe_answer_1.accessOf)((0, probe_answer_1.readProbeAnswer)(await probe({ url, timeoutMs, signal })), url)
19
+ : (0, database_access_1.unanswered)((0, driver_probe_1.missingDriver)(engine));
20
+ }
21
+ const outcome = await (0, probe_process_1.probeInChild)({ ...(0, driver_probe_1.probeTarget)(engine), url, timeoutMs }, signal);
22
+ switch (outcome.kind) {
23
+ case "missing":
24
+ return (0, database_access_1.unanswered)((0, driver_probe_1.missingDriver)(engine));
25
+ case "failed":
26
+ return (0, database_access_1.unanswered)((0, database_access_1.noAnswerReason)(outcome.message, url));
27
+ case "answer":
28
+ return (0, probe_answer_1.accessOf)((0, probe_answer_1.readProbeAnswer)(outcome.answer), url);
29
+ }
30
+ }
31
+ async function checkDatabase(engine, url, timeoutMs = exports.CONNECT_TIMEOUT_MS) {
32
+ const controller = new AbortController();
22
33
  let timer;
23
34
  const deadline = new Promise((resolve) => {
24
35
  timer = setTimeout(() => resolve((0, database_access_1.unanswered)(TOO_SLOW)), timeoutMs * DEADLINE_IN_TIMEOUTS);
25
36
  });
26
37
  try {
27
38
  return await Promise.race([
28
- probes[engine](url, timeoutMs, connections).catch((error) => (0, database_access_1.unanswered)((0, database_access_1.noAnswerReason)((0, database_access_1.failureMessage)(error), url))),
39
+ probeWithDriver(engine, url, timeoutMs, controller.signal)
40
+ .catch((error) => (0, database_access_1.unanswered)((0, database_access_1.noAnswerReason)((0, database_access_1.failureMessage)(error), url)))
41
+ .catch(() => (0, database_access_1.unanswered)(UNREADABLE_FAILURE)),
29
42
  deadline,
30
43
  ]);
31
44
  }
32
45
  finally {
33
46
  clearTimeout(timer);
34
- connections.closeAll();
47
+ controller.abort();
35
48
  }
36
49
  }
37
50
  //# sourceMappingURL=database-check.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"database-check.js","sourceRoot":"","sources":["../../../../src/implementations/dms-builder/engine/database-check.ts"],"names":[],"mappings":";;;AAuCA,sCAyBC;AA5DD,uDAK2B;AAC3B,2DAAuD;AACvD,mDAA+C;AAC/C,+CAA2C;AAC3C,qDAAiD;AACjD,uDAAmD;AAGtC,QAAA,kBAAkB,GAAG,IAAI,CAAC;AAGvC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B,MAAM,QAAQ,GAAG,sCAAsC,CAAC;AAExD,MAAM,MAAM,GAAkC;IAC5C,QAAQ,EAAE,8BAAa;IACvB,KAAK,EAAE,wBAAU;IACjB,OAAO,EAAE,4BAAY;IACrB,SAAS,EAAE,gCAAc;CAC1B,CAAC;AAWK,KAAK,UAAU,aAAa,CACjC,MAAsB,EACtB,GAAW,EACX,YAAoB,0BAAkB,EACtC,SAAkD,MAAM;IAExD,MAAM,WAAW,GAAG,IAAI,oCAAgB,EAAE,CAAC;IAC3C,IAAI,KAAiC,CAAC;IACtC,MAAM,QAAQ,GAAG,IAAI,OAAO,CAAiB,CAAC,OAAO,EAAE,EAAE;QACvD,KAAK,GAAG,UAAU,CAChB,GAAG,EAAE,CAAC,OAAO,CAAC,IAAA,4BAAU,EAAC,QAAQ,CAAC,CAAC,EACnC,SAAS,GAAG,oBAAoB,CACjC,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC;YACxB,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE,CACnE,IAAA,4BAAU,EAAC,IAAA,gCAAc,EAAC,IAAA,gCAAc,EAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CACvD;YACD,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,WAAW,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"database-check.js","sourceRoot":"","sources":["../../../../src/implementations/dms-builder/engine/database-check.ts"],"names":[],"mappings":";;;AAsDA,sCA0BC;AA5ED,uDAA+E;AAC/E,iDAA6E;AAC7E,mDAA+C;AAC/C,iDAA2D;AAG9C,QAAA,kBAAkB,GAAG,IAAI,CAAC;AAGvC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B,MAAM,QAAQ,GAAG,sCAAsC,CAAC;AACxD,MAAM,kBAAkB,GAAG,kDAAkD,CAAC;AAE9E,KAAK,UAAU,eAAe,CAC5B,MAAsB,EACtB,GAAW,EACX,SAAi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AU,EAAC,QAAQ,CAAC,CAAC,EACnC,SAAS,GAAG,oBAAoB,CACjC,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC;YACxB,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC;iBACvD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE,CACxB,IAAA,4BAAU,EAAC,IAAA,gCAAc,EAAC,IAAA,gCAAc,EAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CACvD;iBACA,KAAK,CAAC,GAAG,EAAE,CAAC,IAAA,4BAAU,EAAC,kBAAkB,CAAC,CAAC;YAC9C,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,YAAY,CAAC,KAAK,CAAC,CAAC;QACpB,UAAU,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;AACH,CAAC"}
@@ -1,3 +1,4 @@
1
1
  import type { DatabaseEngine, DriverPackage } from "@antelopejs/interface-dms-builder";
2
+ export declare function driverPackageName(engine: DatabaseEngine): string;
2
3
  export declare function resolvedInterfaceDatabase(): string | undefined;
3
4
  export declare function driverPackages(interfaceDatabase: string | undefined): Partial<Record<DatabaseEngine, DriverPackage>>;
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.driverPackageName = driverPackageName;
6
7
  exports.resolvedInterfaceDatabase = resolvedInterfaceDatabase;
7
8
  exports.driverPackages = driverPackages;
8
9
  const node_path_1 = __importDefault(require("node:path"));
@@ -41,6 +42,9 @@ const DRIVERS = {
41
42
  ],
42
43
  },
43
44
  };
45
+ function driverPackageName(engine) {
46
+ return DRIVERS[engine].package;
47
+ }
44
48
  const Manifest = zod_1.z.object({ version: zod_1.z.string() });
45
49
  function resolvedInterfaceDatabase() {
46
50
  const bases = [node_path_1.default.join((0, project_1.resolveProjectRoot)(), "package.json"), __filename];
@@ -1 +1 @@
1
- {"version":3,"file":"driver-packages.js","sourceRoot":"","sources":["../../../../src/implementations/dms-builder/engine/driver-packages.ts"],"names":[],"mappings":";;;;;AAuEA,8DAYC;AAwBD,wCAcC;AAzHD,0DAA6B;AAK7B,oDAA4B;AAC5B,6BAAwB;AACxB,uDAAqD;AACrD,mDAAiD;AACjD,uCAA+C;AAuB/C,MAAM,OAAO,GAAmC;IAC9C,QAAQ,EAAE;QACR,OAAO,EAAE,sBAAsB;QAC/B,QAAQ,EAAE;YACR,EAAE,IAAI,EAAE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE;YACtD,EAAE,IAAI,EAAE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE;SACvD;KACF;IACD,KAAK,EAAE;QACL,OAAO,EAAE,mBAAmB;QAC5B,QAAQ,EAAE;YACR,EAAE,IAAI,EAAE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE;YACtD,EAAE,IAAI,EAAE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE;SACvD;KACF;IACD,OAAO,EAAE;QACP,OAAO,EAAE,qBAAqB;QAC9B,QAAQ,EAAE;YACR,EAAE,IAAI,EAAE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE;YACtD,EAAE,IAAI,EAAE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE;SACvD;KACF;IACD,SAAS,EAAE;QACT,OAAO,EAAE,uBAAuB;QAChC,QAAQ,EAAE;YACR,EAAE,IAAI,EAAE,QAAQ,EAAE,iBAAiB,EAAE,gBAAgB,EAAE;YACvD,EAAE,IAAI,EAAE,QAAQ,EAAE,iBAAiB,EAAE,gBAAgB,EAAE;SACxD;KACF;CACF,CAAC;AAEF,MAAM,QAAQ,GAAG,OAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,OAAC,CAA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gB,cAAc,CAC5B,iBAAqC;IAErC,IAAI,CAAC,iBAAiB,IAAI,CAAC,gBAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC3D,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,OAAO,GAAmD,EAAE,CAAC;IACnE,KAAK,MAAM,MAAM,IAAI,kCAAgB,EAAE,CAAC;QACtC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,iBAAiB,CAAC,CAAC;QAC7D,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QAClE,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
1
+ {"version":3,"file":"driver-packages.js","sourceRoot":"","sources":["../../../../src/implementations/dms-builder/engine/driver-packages.ts"],"names":[],"mappings":";;;;;AAgEA,8CAEC;AAUD,8DAYC;AAwBD,wCAcC;AA9HD,0DAA6B;AAK7B,oDAA4B;AAC5B,6BAAwB;AACxB,uDAAqD;AACrD,mDAAiD;AACjD,uCAA+C;AAuB/C,MAAM,OAAO,GAAmC;IAC9C,QAAQ,EAAE;QACR,OAAO,EAAE,sBAAsB;QAC/B,QAAQ,EAAE;YACR,EAAE,IAAI,EAAE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE;YACtD,EAAE,IAAI,EAAE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE;SACvD;KACF;IACD,KAAK,EAAE;QACL,OAAO,EAAE,mBAAmB;QAC5B,QAAQ,EAAE;YACR,EAAE,IAAI,EAAE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE;YACtD,EAAE,IAAI,EAAE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE;SACvD;KACF;IACD,OAAO,EAAE;QACP,OAAO,EAAE,qB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odString;
5
+ timeoutMs: z.ZodNumber;
6
+ signal: z.ZodType<AbortSignal, z.ZodTypeDef, AbortSignal>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ url: string;
9
+ timeoutMs: number;
10
+ signal: AbortSignal;
11
+ }, {
12
+ url: string;
13
+ timeoutMs: number;
14
+ signal: AbortSignal;
15
+ }>], z.ZodUnknown>, z.ZodPromise<z.ZodUnknown>>;
16
+ export type LoadedProbe = z.infer<typeof ProbeExport>;
17
+ export interface ProbeTarget {
18
+ specifier: string;
19
+ bases: string[];
20
+ }
21
+ export declare function probeTarget(engine: DatabaseEngine): ProbeTarget;
22
+ export declare function setProbeBasesForTests(bases?: string[]): void;
23
+ type ProbeLoader = (engine: DatabaseEngine) => LoadedProbe | undefined;
24
+ export declare function testProbeLoader(): ProbeLoader | undefined;
25
+ export declare function setProbeLoaderForTests(loader?: ProbeLoader): void;
26
+ export declare function missingDriver(engine: DatabaseEngine): string;
27
+ export {};
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.probeTarget = probeTarget;
7
+ exports.setProbeBasesForTests = setProbeBasesForTests;
8
+ exports.testProbeLoader = testProbeLoader;
9
+ exports.setProbeLoaderForTests = setProbeLoaderForTests;
10
+ exports.missingDriver = missingDriver;
11
+ const node_path_1 = __importDefault(require("node:path"));
12
+ const zod_1 = require("zod");
13
+ const driver_packages_1 = require("./driver-packages");
14
+ const project_1 = require("./project");
15
+ const ProbeConfigSchema = zod_1.z.object({
16
+ url: zod_1.z.string(),
17
+ timeoutMs: zod_1.z.number(),
18
+ signal: zod_1.z.instanceof(AbortSignal),
19
+ });
20
+ const ProbeExport = zod_1.z
21
+ .function()
22
+ .args(ProbeConfigSchema)
23
+ .returns(zod_1.z.promise(zod_1.z.unknown()));
24
+ const ENGINE_LABELS = {
25
+ postgres: "PostgreSQL",
26
+ mysql: "MySQL or MariaDB",
27
+ mongodb: "MongoDB",
28
+ rethinkdb: "RethinkDB",
29
+ };
30
+ let basesForTests;
31
+ function probeTarget(engine) {
32
+ return {
33
+ specifier: `${(0, driver_packages_1.driverPackageName)(engine)}/dist/probe`,
34
+ bases: basesForTests ?? [
35
+ __filename,
36
+ node_path_1.default.join((0, project_1.resolveProjectRoot)(), "package.json"),
37
+ ],
38
+ };
39
+ }
40
+ function setProbeBasesForTests(bases) {
41
+ basesForTests = bases;
42
+ }
43
+ let probeLoader;
44
+ function testProbeLoader() {
45
+ return probeLoader;
46
+ }
47
+ function setProbeLoaderForTests(loader) {
48
+ probeLoader = loader;
49
+ }
50
+ function missingDriver(engine) {
51
+ return `Install ${(0, driver_packages_1.driverPackageName)(engine)} to connect a ${ENGINE_LABELS[engine]} database.`;
52
+ }
53
+ //# sourceMappingURL=driver-probe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"driver-probe.js","sourceRoot":"","sources":["../../../../src/implementations/dms-builder/engine/driver-probe.ts"],"names":[],"mappings":";;;;;AA2CA,kCAQC;AAGD,sDAEC;AAOD,0CAEC;AAGD,wDAEC;AAGD,sCAEC;AA3ED,0DAA6B;AAG7B,6BAAwB;AACxB,uDAAsD;AACtD,uCAA+C;AAE/C,MAAM,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IACjC,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;IACf,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;IACrB,MAAM,EAAE,OAAC,CAAC,UAAU,CAAC,WAAW,CAAC;CAClC,CAAkC,CAAC;AAEpC,MAAM,WAAW,GAAG,OAAC;KAClB,QAAQ,EAAE;KACV,IAAI,CAAC,iBAAiB,CAAC;KACvB,OAAO,CAAC,OAAC,CAAC,OAAO,CAAC,OAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAQnC,MAAM,aAAa,GAAmC;IACpD,QAAQ,EAAE,YAAY;IACtB,KAAK,EAAE,kBAAkB;IACzB,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,WAAW;CACvB,CAAC;AAQF,IAAI,aAAmC,CAAC;AAMxC,SAAgB,WAAW,CAAC,MAAsB;IAChD,OAAO;QACL,SAAS,EAAE,GAAG,IAAA,mCAAiB,EAAC,MAAM,CAAC,aAAa;QACpD,KAAK,EAAE,aAAa,IAAI;YACtB,UAAU;YACV,mBAAI,CAAC,IAAI,CAAC,IAAA,4BAAkB,GAAE,EAAE,cAAc,CAAC;SAChD;KACF,CAAC;AACJ,CAAC;AAGD,SAAgB,qBAAqB,CAAC,KAAgB;IACpD,aAAa,GAAG,KAAK,CAAC;AACxB,CAAC;AAID,IAAI,WAAoC,CAAC;AAGzC,SAAgB,eAAe;IAC7B,OAAO,WAAW,CAAC;AACrB,CAAC;AAGD,SAAgB,sBAAsB,CAAC,MAAoB;IACzD,WAAW,GAAG,MAAM,CAAC;AACvB,CAAC;AAGD,SAAgB,aAAa,CAAC,MAAsB;IAClD,OAAO,WAAW,IAAA,mCAAiB,EAAC,MAAM,CAAC,iBAAiB,aAAa,CAAC,MAAM,CAAC,YAAY,CAAC;AAChG,CAAC"}
@@ -1,7 +1,4 @@
1
1
  export * from "./access-grant";
2
- export * from "./access-mongodb";
3
- export * from "./access-mysql";
4
- export * from "./access-postgres";
5
2
  export * from "./analysis";
6
3
  export * from "./analysis-input";
7
4
  export * from "./analysis-job";
@@ -20,6 +17,7 @@ export * from "./database-pin";
20
17
  export * from "./database-repair";
21
18
  export * from "./dms-database";
22
19
  export * from "./driver-packages";
20
+ export * from "./driver-probe";
23
21
  export * from "./emit";
24
22
  export * from "./entry-connections";
25
23
  export * from "./env-lines";
@@ -37,8 +35,7 @@ export * from "./options-patch";
37
35
  export * from "./own-connections";
38
36
  export * from "./page-access";
39
37
  export * from "./page-structure";
40
- export * from "./probe-client";
41
- export * from "./probe-connections";
38
+ export * from "./probe-answer";
42
39
  export * from "./project";
43
40
  export { StepRefusal } from "./project-config";
44
41
  export * from "./project-env";
@@ -53,7 +50,6 @@ export * from "./query-template-emit";
53
50
  export * from "./resource-emit";
54
51
  export * from "./resource-index";
55
52
  export * from "./scan";
56
- export * from "./scram-bound";
57
53
  export * from "./source-index";
58
54
  export * from "./table-readers";
59
55
  export * from "./theme-font-catalog";
@@ -16,9 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.StepRefusal = void 0;
18
18
  __exportStar(require("./access-grant"), exports);
19
- __exportStar(require("./access-mongodb"), exports);
20
- __exportStar(require("./access-mysql"), exports);
21
- __exportStar(require("./access-postgres"), exports);
22
19
  __exportStar(require("./analysis"), exports);
23
20
  __exportStar(require("./analysis-input"), exports);
24
21
  __exportStar(require("./analysis-job"), exports);
@@ -37,6 +34,7 @@ __exportStar(require("./database-pin"), exports);
37
34
  __exportStar(require("./database-repair"), exports);
38
35
  __exportStar(require("./dms-database"), exports);
39
36
  __exportStar(require("./driver-packages"), exports);
37
+ __exportStar(require("./driver-probe"), exports);
40
38
  __exportStar(require("./emit"), exports);
41
39
  __exportStar(require("./entry-connections"), exports);
42
40
  __exportStar(require("./env-lines"), exports);
@@ -54,8 +52,7 @@ __exportStar(require("./options-patch"), exports);
54
52
  __exportStar(require("./own-connections"), exports);
55
53
  __exportStar(require("./page-access"), exports);
56
54
  __exportStar(require("./page-structure"), exports);
57
- __exportStar(require("./probe-client"), exports);
58
- __exportStar(require("./probe-connections"), exports);
55
+ __exportStar(require("./probe-answer"), exports);
59
56
  __exportStar(require("./project"), exports);
60
57
  var project_config_1 = require("./project-config");
61
58
  Object.defineProperty(exports, "StepRefusal", { enumerable: true, get: function () { return project_config_1.StepRefusal; } });
@@ -71,7 +68,6 @@ __exportStar(require("./query-template-emit"), exports);
71
68
  __exportStar(require("./resource-emit"), exports);
72
69
  __exportStar(require("./resource-index"), exports);
73
70
  __exportStar(require("./scan"), exports);
74
- __exportStar(require("./scram-bound"), exports);
75
71
  __exportStar(require("./source-index"), exports);
76
72
  __exportStar(require("./table-readers"), exports);
77
73
  __exportStar(require("./theme-font-catalog"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/implementations/dms-builder/engine/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,mDAAiC;AACjC,iDAA+B;AAC/B,oDAAkC;AAClC,6CAA2B;AAC3B,mDAAiC;AACjC,iDAA+B;AAC/B,4CAA0B;AAC1B,uDAAqC;AACrC,sDAAoC;AACpC,iDAA+B;AAC/B,6DAA2C;AAC3C,uDAAqC;AACrC,oDAAkC;AAClC,mDAAiC;AACjC,yDAAuC;AACvC,wDAAsC;AACtC,+DAA6C;AAC7C,iDAA+B;AAC/B,oDAAkC;AAClC,iDAA+B;AAC/B,oDAAkC;AAClC,yCAAuB;AACvB,sDAAoC;AACpC,8CAA4B;AAC5B,+CAA6B;AAC7B,+CAA6B;AAC7B,2CAAyB;AACzB,wDAAsC;AACtC,2DAAyC;AACzC,kDAAgC;AAChC,kDAAgC;AAChC,4CAA0B;AAC1B,gDAA8B;AAC9B,wCAAsB;AACtB,kDAAgC;AAChC,oDAAkC;AAClC,gDAA8B;AAC9B,mDAAiC;AACjC,iDAA+B;AAC/B,sDAAoC;AACpC,4CAA0B;AAC1B,mDAA+C;AAAtC,6GAAA,WAAW,OAAA;AACpB,gDAA8B;AAC9B,qDAAmC;AACnC,gDAA8B;AAC9B,+CAA6B;AAC7B,+CAA6B;AAC7B,uDAAqC;AACrC,kDAAgC;AAChC,oDAAkC;AAClC,wDAAsC;AACtC,kDAAgC;AAChC,mDAAiC;AACjC,yCAAuB;AACvB,gDAA8B;AAC9B,iDAA+B;AAC/B,kDAAgC;AAChC,uDAAqC;AACrC,gDAA8B;AAC9B,gDAA8B;AAC9B,mDAAiC;AACjC,qDAAmC;AACnC,8CAA4B;AAC5B,0CAAwB;AACxB,mDAAiC;AACjC,6CAA2B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/implementations/dms-builder/engine/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,6CAA2B;AAC3B,mDAAiC;AACjC,iDAA+B;AAC/B,4CAA0B;AAC1B,uDAAqC;AACrC,sDAAoC;AACpC,iDAA+B;AAC/B,6DAA2C;AAC3C,uDAAqC;AACrC,oDAAkC;AAClC,mDAAiC;AACjC,yDAAuC;AACvC,wDAAsC;AACtC,+DAA6C;AAC7C,iDAA+B;AAC/B,oDAAkC;AAClC,iDAA+B;AAC/B,oDAAkC;AAClC,iDAA+B;AAC/B,yCAAuB;AACvB,sDAAoC;AACpC,8CAA4B;AAC5B,+CAA6B;AAC7B,+CAA6B;AAC7B,2CAAyB;AACzB,wDAAsC;AACtC,2DAAyC;AACzC,kDAAgC;AAChC,kDAAgC;AAChC,4CAA0B;AAC1B,gDAA8B;AAC9B,wCAAsB;AACtB,kDAAgC;AAChC,oDAAkC;AAClC,gDAA8B;AAC9B,mDAAiC;AACjC,iDAA+B;AAC/B,4CAA0B;AAC1B,mDAA+C;AAAtC,6GAAA,WAAW,OAAA;AACpB,gDAA8B;AAC9B,qDAAmC;AACnC,gDAA8B;AAC9B,+CAA6B;AAC7B,+CAA6B;AAC7B,uDAAqC;AACrC,kDAAgC;AAChC,oDAAkC;AAClC,wDAAsC;AACtC,kDAAgC;AAChC,mDAAiC;AACjC,yCAAuB;AACvB,iDAA+B;AAC/B,kDAAgC;AAChC,uDAAqC;AACrC,gDAA8B;AAC9B,gDAA8B;AAC9B,mDAAiC;AACjC,qDAAmC;AACnC,8CAA4B;AAC5B,0CAAwB;AACxB,mDAAiC;AACjC,6CAA2B"}
@@ -0,0 +1,4 @@
1
+ import type { ProbeAnswer } from "@antelopejs/interface-database-catalog";
2
+ import type { DatabaseAccess } from "@antelopejs/interface-dms-builder";
3
+ export declare function readProbeAnswer(answer: unknown): ProbeAnswer | undefined;
4
+ export declare function accessOf(probed: ProbeAnswer | undefined, url: string): DatabaseAccess;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readProbeAnswer = readProbeAnswer;
4
+ exports.accessOf = accessOf;
5
+ const zod_1 = require("zod");
6
+ const database_access_1 = require("./database-access");
7
+ const NO_READ = "This account cannot read this database.";
8
+ const NO_DATABASE = "The server has no database with this name.";
9
+ const NOT_UNDERSTOOD = "The database driver answered in a way this check does not understand.";
10
+ const Refusal = zod_1.z.enum([
11
+ "credentials",
12
+ "host",
13
+ "database",
14
+ "database-denied",
15
+ "sign-in-required",
16
+ "other",
17
+ ]);
18
+ const Unreadable = zod_1.z.enum([
19
+ "no-database-named",
20
+ "no-database",
21
+ "cannot-list",
22
+ ]);
23
+ const REFUSALS = {
24
+ credentials: "The database refused this user name or password.",
25
+ host: "The database does not let this account connect from here.",
26
+ database: NO_DATABASE,
27
+ "database-denied": "This account may not use this database.",
28
+ "sign-in-required": "This server asks for a user name and a password.",
29
+ };
30
+ const UNREADABLE = {
31
+ "no-database-named": "The URL names no database: add its name after the host and port.",
32
+ "no-database": NO_DATABASE,
33
+ "cannot-list": "This account cannot list the tables or collections of this database.",
34
+ };
35
+ const ProbeAnswerSchema = zod_1.z.discriminatedUnion("outcome", [
36
+ zod_1.z.object({ outcome: zod_1.z.literal("unreachable"), message: zod_1.z.string() }),
37
+ zod_1.z.object({
38
+ outcome: zod_1.z.literal("refused"),
39
+ refusal: Refusal,
40
+ message: zod_1.z.string(),
41
+ }),
42
+ zod_1.z.object({
43
+ outcome: zod_1.z.literal("signed-in"),
44
+ latencyMs: zod_1.z.number().nonnegative().finite(),
45
+ user: zod_1.z.string().optional(),
46
+ canRead: zod_1.z.boolean(),
47
+ canWrite: zod_1.z.boolean(),
48
+ unreadable: Unreadable.optional(),
49
+ }),
50
+ ]);
51
+ const ReadProbeAnswer = ProbeAnswerSchema.optional().catch(undefined);
52
+ function signedIn({ latencyMs, user, canRead, canWrite, unreadable, }) {
53
+ const access = {
54
+ reachable: true,
55
+ latencyMs: Math.ceil(latencyMs),
56
+ canRead,
57
+ canWrite,
58
+ };
59
+ if (user !== undefined) {
60
+ access.user = user;
61
+ }
62
+ if (!canRead) {
63
+ access.reason = unreadable === undefined ? NO_READ : UNREADABLE[unreadable];
64
+ }
65
+ return access;
66
+ }
67
+ function readProbeAnswer(answer) {
68
+ return ReadProbeAnswer.parse(answer);
69
+ }
70
+ function accessOf(probed, url) {
71
+ if (probed === undefined) {
72
+ return (0, database_access_1.unanswered)(NOT_UNDERSTOOD);
73
+ }
74
+ switch (probed.outcome) {
75
+ case "unreachable":
76
+ return (0, database_access_1.unanswered)((0, database_access_1.noAnswerReason)(probed.message, url));
77
+ case "refused":
78
+ return {
79
+ reachable: true,
80
+ canRead: false,
81
+ canWrite: false,
82
+ reason: probed.refusal === "other"
83
+ ? (0, database_access_1.signInRefusal)(probed.message, url)
84
+ : REFUSALS[probed.refusal],
85
+ };
86
+ case "signed-in":
87
+ return signedIn(probed);
88
+ }
89
+ }
90
+ //# sourceMappingURL=probe-answer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probe-answer.js","sourceRoot":"","sources":["../../../../src/implementations/dms-builder/engine/probe-answer.ts"],"names":[],"mappings":";;AA4FA,0CAEC;AAOD,4BAuBC;AAtHD,6BAAwB;AACxB,uDAA8E;AAE9E,MAAM,OAAO,GAAG,yCAAyC,CAAC;AAC1D,MAAM,WAAW,GAAG,4CAA4C,CAAC;AACjE,MAAM,cAAc,GAClB,uEAAuE,CAAC;AAE1E,MAAM,OAAO,GAAG,OAAC,CAAC,IAAI,CAAC;IACrB,aAAa;IACb,MAAM;IACN,UAAU;IACV,iBAAiB;IACjB,kBAAkB;IAClB,OAAO;CACR,CAAmC,CAAC;AAErC,MAAM,UAAU,GAAG,OAAC,CAAC,IAAI,CAAC;IACxB,mBAAmB;IACnB,aAAa;IACb,aAAa;CACd,CAAsC,CAAC;AAGxC,MAAM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ict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const zod_1 = require("zod");
4
+ const module_loader_1 = require("./module-loader");
5
+ const probe_protocol_1 = require("./probe-protocol");
6
+ const NotInstalled = zod_1.z.object({
7
+ code: zod_1.z.literal("MODULE_NOT_FOUND"),
8
+ message: zod_1.z.string(),
9
+ });
10
+ const ProbeModule = zod_1.z.object({
11
+ probe: zod_1.z
12
+ .function()
13
+ .args(zod_1.z.object({
14
+ url: zod_1.z.string(),
15
+ timeoutMs: zod_1.z.number(),
16
+ signal: zod_1.z.instanceof(AbortSignal),
17
+ }))
18
+ .returns(zod_1.z.promise(zod_1.z.unknown())),
19
+ });
20
+ const ThrownMessage = zod_1.z
21
+ .instanceof(Error)
22
+ .pipe(zod_1.z.object({ message: zod_1.z.string() }))
23
+ .transform(({ message }) => message)
24
+ .catch("The driver's probe ended with an error that carries no message.");
25
+ function installedProbe(specifier, bases) {
26
+ for (const base of bases) {
27
+ try {
28
+ const loaded = ProbeModule.safeParse((0, module_loader_1.loadModuleFrom)(base, specifier));
29
+ return loaded.success ? loaded.data.probe : undefined;
30
+ }
31
+ catch (error) {
32
+ const failure = NotInstalled.safeParse(error);
33
+ if (!failure.success ||
34
+ !failure.data.message.includes(`'${specifier}'`)) {
35
+ throw error;
36
+ }
37
+ }
38
+ }
39
+ return undefined;
40
+ }
41
+ function reply(outcome) {
42
+ process.stdout.write(`\n${probe_protocol_1.OUTCOME_MARK}${JSON.stringify(outcome)}\n`);
43
+ }
44
+ async function answer() {
45
+ const request = probe_protocol_1.ProbeRequest.safeParse(JSON.parse(process.env[probe_protocol_1.PROBE_REQUEST] ?? "null"));
46
+ delete process.env[probe_protocol_1.PROBE_REQUEST];
47
+ if (!request.success) {
48
+ reply({
49
+ kind: "failed",
50
+ message: "The check sent the probe a request it could not read.",
51
+ });
52
+ return;
53
+ }
54
+ const { specifier, bases, url, timeoutMs } = request.data;
55
+ const probe = installedProbe(specifier, bases);
56
+ if (!probe) {
57
+ reply({ kind: "missing" });
58
+ return;
59
+ }
60
+ const answered = await probe({
61
+ url,
62
+ timeoutMs,
63
+ signal: new AbortController().signal,
64
+ });
65
+ reply({ kind: "answer", answer: answered });
66
+ }
67
+ answer().catch((error) => {
68
+ reply({ kind: "failed", message: ThrownMessage.parse(error) });
69
+ });
70
+ //# sourceMappingURL=probe-child.js.map