@agentic-kit/db-tools 0.15.1 → 0.16.1
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/README.md +4 -4
- package/blueprint/blueprint-schema.js +3 -1
- package/context.d.ts +9 -9
- package/context.js +92 -54
- package/db-probe.js +2 -2
- package/esm/blueprint/blueprint-schema.js +3 -1
- package/esm/context.d.ts +9 -9
- package/esm/context.js +91 -54
- package/esm/db-probe.js +2 -2
- package/esm/failure.d.ts +1 -1
- package/esm/failure.js +2 -2
- package/esm/gate.js +1 -1
- package/esm/graphql-http.d.ts +3 -2
- package/esm/graphql-http.js +26 -7
- package/esm/host.d.ts +20 -7
- package/esm/host.js +7 -2
- package/esm/index.d.ts +175 -14
- package/esm/index.js +5 -15
- package/esm/project-file.d.ts +72 -0
- package/esm/project-file.js +161 -0
- package/esm/provision-database/provision.d.ts +8 -3
- package/esm/provision-database/provision.js +63 -94
- package/esm/ready.d.ts +7 -3
- package/esm/ready.js +3 -3
- package/esm/records/rows.d.ts +1 -0
- package/esm/records/rows.js +9 -6
- package/esm/tools/access.js +1 -1
- package/esm/tools/create-api-key.js +2 -2
- package/esm/tools/delete-records.d.ts +1 -1
- package/esm/tools/delete-records.js +7 -7
- package/esm/tools/index.d.ts +195 -2
- package/esm/tools/index.js +25 -15
- package/esm/tools/mutations.js +7 -6
- package/esm/tools/provision-database.js +4 -4
- package/esm/tools/run-codegen.d.ts +2 -2
- package/esm/tools/run-codegen.js +10 -11
- package/esm/tools/update-records.js +1 -1
- package/failure.d.ts +1 -1
- package/failure.js +2 -2
- package/gate.js +1 -1
- package/graphql-http.d.ts +3 -2
- package/graphql-http.js +26 -7
- package/host.d.ts +20 -7
- package/host.js +7 -2
- package/index.d.ts +175 -14
- package/index.js +9 -45
- package/package.json +7 -6
- package/project-file.d.ts +72 -0
- package/project-file.js +178 -0
- package/provision-database/provision.d.ts +8 -3
- package/provision-database/provision.js +66 -96
- package/ready.d.ts +7 -3
- package/ready.js +3 -3
- package/records/rows.d.ts +1 -0
- package/records/rows.js +8 -5
- package/tools/access.js +1 -1
- package/tools/create-api-key.js +2 -2
- package/tools/delete-records.d.ts +1 -1
- package/tools/delete-records.js +8 -8
- package/tools/index.d.ts +195 -2
- package/tools/index.js +53 -43
- package/tools/mutations.js +6 -5
- package/tools/provision-database.js +5 -5
- package/tools/run-codegen.d.ts +2 -2
- package/tools/run-codegen.js +8 -9
- package/tools/update-records.js +1 -1
- package/esm/provision-database/env-file.d.ts +0 -62
- package/esm/provision-database/env-file.js +0 -170
- package/esm/provision-database/pending-ticket.d.ts +0 -33
- package/esm/provision-database/pending-ticket.js +0 -63
- package/provision-database/env-file.d.ts +0 -62
- package/provision-database/env-file.js +0 -179
- package/provision-database/pending-ticket.d.ts +0 -33
- package/provision-database/pending-ticket.js +0 -72
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// The provision request provision_database stopped waiting on, as recorded in
|
|
3
|
-
// a project's .env. requestDatabase never resumes by name, so the ticket is
|
|
4
|
-
// the only way back to a provision that is still running.
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ABANDONED_TICKETS_KEY = exports.MAX_PENDING_ATTEMPTS = void 0;
|
|
7
|
-
exports.recordedTicket = recordedTicket;
|
|
8
|
-
exports.recordPendingTicket = recordPendingTicket;
|
|
9
|
-
exports.clearPendingTicket = clearPendingTicket;
|
|
10
|
-
exports.archivePendingTicket = archivePendingTicket;
|
|
11
|
-
exports.abandonedTickets = abandonedTickets;
|
|
12
|
-
exports.recordAbandoned = recordAbandoned;
|
|
13
|
-
const env_file_1 = require("./env-file");
|
|
14
|
-
/**
|
|
15
|
-
* Pending results recorded for one ticket before provision_database stops
|
|
16
|
-
* following it. At the default 240 s deadline that is about 20 minutes.
|
|
17
|
-
*/
|
|
18
|
-
exports.MAX_PENDING_ATTEMPTS = 5;
|
|
19
|
-
const KEYS = Object.values(env_file_1.PENDING_PROVISION_KEYS);
|
|
20
|
-
/**
|
|
21
|
-
* Tickets the host told provisioning to stop following (`abandonPending`),
|
|
22
|
-
* comma-separated. A lookup by name skips them, so an abandoned provision is
|
|
23
|
-
* never resumed.
|
|
24
|
-
*/
|
|
25
|
-
exports.ABANDONED_TICKETS_KEY = 'PROVISION_TICKET_ABANDONED';
|
|
26
|
-
/** The newest abandoned ids kept; older ones are long finished or failed. */
|
|
27
|
-
const MAX_ABANDONED = 10;
|
|
28
|
-
/**
|
|
29
|
-
* The recorded ticket, with the name, backend and account it was requested
|
|
30
|
-
* for. Only a ticket from this backend and account is ours to poll, and one
|
|
31
|
-
* for another name is a different database.
|
|
32
|
-
*/
|
|
33
|
-
function recordedTicket(env) {
|
|
34
|
-
const ticketId = env[env_file_1.PENDING_PROVISION_KEYS.ticketId];
|
|
35
|
-
if (!ticketId)
|
|
36
|
-
return undefined;
|
|
37
|
-
const attempts = Number.parseInt(env[env_file_1.PENDING_PROVISION_KEYS.attempts] ?? '', 10);
|
|
38
|
-
return {
|
|
39
|
-
ticketId,
|
|
40
|
-
databaseName: env[env_file_1.PENDING_PROVISION_KEYS.databaseName] ?? '',
|
|
41
|
-
apiEndpoint: env[env_file_1.PENDING_PROVISION_KEYS.apiEndpoint] ?? '',
|
|
42
|
-
userId: env[env_file_1.PENDING_PROVISION_KEYS.userId] ?? '',
|
|
43
|
-
attempts: Number.isFinite(attempts) && attempts > 0 ? attempts : 0,
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function recordPendingTicket(content, ticket) {
|
|
47
|
-
return (0, env_file_1.mergeEnv)(content, {
|
|
48
|
-
[env_file_1.PENDING_PROVISION_KEYS.ticketId]: ticket.ticketId,
|
|
49
|
-
[env_file_1.PENDING_PROVISION_KEYS.databaseName]: ticket.databaseName,
|
|
50
|
-
[env_file_1.PENDING_PROVISION_KEYS.apiEndpoint]: ticket.apiEndpoint,
|
|
51
|
-
[env_file_1.PENDING_PROVISION_KEYS.userId]: ticket.userId,
|
|
52
|
-
[env_file_1.PENDING_PROVISION_KEYS.attempts]: String(ticket.attempts),
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
function clearPendingTicket(content) {
|
|
56
|
-
return (0, env_file_1.removeEnvKeys)(content, KEYS);
|
|
57
|
-
}
|
|
58
|
-
/** Comment the record out (`# archived <date>: …`), keeping it readable. */
|
|
59
|
-
function archivePendingTicket(content, archivedOn) {
|
|
60
|
-
return (0, env_file_1.archiveBindingKeys)(content, KEYS, archivedOn);
|
|
61
|
-
}
|
|
62
|
-
function abandonedTickets(env) {
|
|
63
|
-
return new Set((env[exports.ABANDONED_TICKETS_KEY] ?? '')
|
|
64
|
-
.split(',')
|
|
65
|
-
.map((id) => id.trim())
|
|
66
|
-
.filter(Boolean));
|
|
67
|
-
}
|
|
68
|
-
/** Add ticket ids to the abandoned list. */
|
|
69
|
-
function recordAbandoned(content, ticketIds) {
|
|
70
|
-
const ids = [...new Set([...abandonedTickets((0, env_file_1.readEnv)(content)), ...ticketIds])].slice(-MAX_ABANDONED);
|
|
71
|
-
return (0, env_file_1.mergeEnv)(content, { [exports.ABANDONED_TICKETS_KEY]: ids.join(',') });
|
|
72
|
-
}
|