@agentic-kit/db-tools 0.12.46 → 0.13.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.
Files changed (180) hide show
  1. package/README.md +18 -4
  2. package/access/findings.d.ts +93 -0
  3. package/access/findings.js +434 -0
  4. package/access/index.d.ts +5 -0
  5. package/access/index.js +27 -0
  6. package/access/policies.d.ts +142 -0
  7. package/access/policies.js +338 -0
  8. package/access/provisioning.d.ts +121 -0
  9. package/access/provisioning.js +381 -0
  10. package/access/rule-check.d.ts +52 -0
  11. package/access/rule-check.js +307 -0
  12. package/access/words.d.ts +38 -0
  13. package/access/words.js +530 -0
  14. package/app-workspace.d.ts +1 -0
  15. package/app-workspace.js +7 -9
  16. package/blueprint/blueprint-defaults.d.ts +9 -0
  17. package/blueprint/blueprint-defaults.js +77 -0
  18. package/blueprint/blueprint-schema.d.ts +68 -0
  19. package/blueprint/blueprint-schema.js +139 -0
  20. package/blueprint/field-type.d.ts +4 -0
  21. package/blueprint/field-type.js +100 -0
  22. package/blueprint/internal-policies.d.ts +1 -0
  23. package/blueprint/internal-policies.js +10 -0
  24. package/blueprint-construction.d.ts +10 -6
  25. package/blueprint-construction.js +34 -25
  26. package/context.d.ts +15 -0
  27. package/context.js +132 -69
  28. package/db-probe.d.ts +1 -1
  29. package/db-probe.js +19 -4
  30. package/esm/access/findings.d.ts +93 -0
  31. package/esm/access/findings.js +428 -0
  32. package/esm/access/index.d.ts +5 -0
  33. package/esm/access/index.js +5 -0
  34. package/esm/access/policies.d.ts +142 -0
  35. package/esm/access/policies.js +315 -0
  36. package/esm/access/provisioning.d.ts +121 -0
  37. package/esm/access/provisioning.js +375 -0
  38. package/esm/access/rule-check.d.ts +52 -0
  39. package/esm/access/rule-check.js +297 -0
  40. package/esm/access/words.d.ts +38 -0
  41. package/esm/access/words.js +524 -0
  42. package/esm/app-workspace.d.ts +1 -0
  43. package/esm/app-workspace.js +7 -10
  44. package/esm/blueprint/blueprint-defaults.d.ts +9 -0
  45. package/esm/blueprint/blueprint-defaults.js +74 -0
  46. package/esm/blueprint/blueprint-schema.d.ts +68 -0
  47. package/esm/blueprint/blueprint-schema.js +134 -0
  48. package/esm/blueprint/field-type.d.ts +4 -0
  49. package/esm/blueprint/field-type.js +95 -0
  50. package/esm/blueprint/internal-policies.d.ts +1 -0
  51. package/esm/blueprint/internal-policies.js +7 -0
  52. package/esm/blueprint-construction.d.ts +10 -6
  53. package/esm/blueprint-construction.js +32 -24
  54. package/esm/context.d.ts +15 -0
  55. package/esm/context.js +133 -70
  56. package/esm/db-probe.d.ts +1 -1
  57. package/esm/db-probe.js +21 -6
  58. package/esm/failure.d.ts +89 -0
  59. package/esm/failure.js +362 -0
  60. package/esm/gate.d.ts +6 -4
  61. package/esm/gate.js +42 -14
  62. package/esm/graphql-http.d.ts +27 -6
  63. package/esm/graphql-http.js +96 -24
  64. package/esm/host.d.ts +33 -8
  65. package/esm/host.js +42 -2
  66. package/esm/index.d.ts +22 -12
  67. package/esm/index.js +21 -39
  68. package/esm/provision-database/env-file.d.ts +7 -0
  69. package/esm/provision-database/env-file.js +30 -0
  70. package/esm/provision-database/preset-match.js +1 -2
  71. package/esm/provision-database/provision.d.ts +21 -4
  72. package/esm/provision-database/provision.js +330 -85
  73. package/esm/provision-database/request-database.d.ts +22 -3
  74. package/esm/provision-database/request-database.js +46 -13
  75. package/esm/ready.d.ts +20 -0
  76. package/esm/ready.js +45 -0
  77. package/esm/run-codegen/barrels.js +1 -1
  78. package/esm/run-codegen/endpoints.js +5 -6
  79. package/esm/schema-model/normalize.js +1 -1
  80. package/esm/schema-model.js +4 -5
  81. package/esm/schema-resolve.d.ts +50 -0
  82. package/esm/schema-resolve.js +200 -14
  83. package/esm/table-access.d.ts +116 -0
  84. package/esm/table-access.js +418 -0
  85. package/esm/tools/access.d.ts +218 -0
  86. package/esm/tools/access.js +651 -0
  87. package/esm/tools/add-policies.d.ts +44 -12
  88. package/esm/tools/add-policies.js +84 -84
  89. package/esm/tools/add-records.d.ts +23 -2
  90. package/esm/tools/add-records.js +113 -75
  91. package/esm/tools/add-relation-schema.d.ts +5 -5
  92. package/esm/tools/add-relation-schema.js +13 -14
  93. package/esm/tools/add-relation.d.ts +11 -2
  94. package/esm/tools/add-relation.js +68 -31
  95. package/esm/tools/create-api-key.d.ts +18 -4
  96. package/esm/tools/create-api-key.js +105 -54
  97. package/esm/tools/describe-schema.d.ts +5 -7
  98. package/esm/tools/describe-schema.js +41 -118
  99. package/esm/tools/entity-types.d.ts +54 -0
  100. package/esm/tools/entity-types.js +233 -0
  101. package/esm/tools/index.d.ts +26 -0
  102. package/esm/tools/index.js +151 -0
  103. package/esm/tools/mutations.d.ts +36 -7
  104. package/esm/tools/mutations.js +245 -99
  105. package/esm/tools/provision-blueprint.d.ts +25 -1
  106. package/esm/tools/provision-blueprint.js +184 -42
  107. package/esm/tools/provision-database.d.ts +7 -5
  108. package/esm/tools/provision-database.js +31 -17
  109. package/esm/tools/run-codegen.d.ts +27 -4
  110. package/esm/tools/run-codegen.js +143 -76
  111. package/esm/tools/templates.d.ts +30 -7
  112. package/esm/tools/templates.js +166 -95
  113. package/failure.d.ts +89 -0
  114. package/failure.js +375 -0
  115. package/gate.d.ts +6 -4
  116. package/gate.js +41 -13
  117. package/graphql-http.d.ts +27 -6
  118. package/graphql-http.js +105 -25
  119. package/host.d.ts +33 -8
  120. package/host.js +45 -2
  121. package/index.d.ts +22 -12
  122. package/index.js +86 -43
  123. package/package.json +6 -5
  124. package/provision-database/env-file.d.ts +7 -0
  125. package/provision-database/env-file.js +32 -1
  126. package/provision-database/preset-match.js +1 -2
  127. package/provision-database/provision.d.ts +21 -4
  128. package/provision-database/provision.js +327 -81
  129. package/provision-database/request-database.d.ts +22 -3
  130. package/provision-database/request-database.js +49 -14
  131. package/ready.d.ts +20 -0
  132. package/ready.js +52 -0
  133. package/run-codegen/barrels.js +1 -1
  134. package/run-codegen/endpoints.js +5 -6
  135. package/schema-model/normalize.js +4 -4
  136. package/schema-model.js +4 -5
  137. package/schema-resolve.d.ts +50 -0
  138. package/schema-resolve.js +209 -14
  139. package/table-access.d.ts +116 -0
  140. package/table-access.js +437 -0
  141. package/tools/access.d.ts +218 -0
  142. package/tools/access.js +669 -0
  143. package/tools/add-policies.d.ts +44 -12
  144. package/tools/add-policies.js +86 -84
  145. package/tools/add-records.d.ts +23 -2
  146. package/tools/add-records.js +113 -74
  147. package/tools/add-relation-schema.d.ts +5 -5
  148. package/tools/add-relation-schema.js +13 -14
  149. package/tools/add-relation.d.ts +11 -2
  150. package/tools/add-relation.js +69 -31
  151. package/tools/create-api-key.d.ts +18 -4
  152. package/tools/create-api-key.js +104 -53
  153. package/tools/describe-schema.d.ts +5 -7
  154. package/tools/describe-schema.js +40 -117
  155. package/tools/entity-types.d.ts +54 -0
  156. package/tools/entity-types.js +240 -0
  157. package/tools/index.d.ts +26 -0
  158. package/tools/index.js +154 -0
  159. package/tools/mutations.d.ts +36 -7
  160. package/tools/mutations.js +252 -101
  161. package/tools/provision-blueprint.d.ts +25 -1
  162. package/tools/provision-blueprint.js +186 -43
  163. package/tools/provision-database.d.ts +7 -5
  164. package/tools/provision-database.js +33 -18
  165. package/tools/run-codegen.d.ts +27 -4
  166. package/tools/run-codegen.js +141 -73
  167. package/tools/templates.d.ts +30 -7
  168. package/tools/templates.js +167 -94
  169. package/esm/policy/add-policies-to-table.d.ts +0 -26
  170. package/esm/policy/add-policies-to-table.js +0 -66
  171. package/esm/policy/provision-helpers.d.ts +0 -38
  172. package/esm/policy/provision-helpers.js +0 -50
  173. package/esm/tools/manage-entity-types.d.ts +0 -40
  174. package/esm/tools/manage-entity-types.js +0 -201
  175. package/policy/add-policies-to-table.d.ts +0 -26
  176. package/policy/add-policies-to-table.js +0 -71
  177. package/policy/provision-helpers.d.ts +0 -38
  178. package/policy/provision-helpers.js +0 -58
  179. package/tools/manage-entity-types.d.ts +0 -40
  180. package/tools/manage-entity-types.js +0 -206
package/graphql-http.js CHANGED
@@ -6,10 +6,15 @@
6
6
  // the body's errors keep their `extensions.code`, and every error carries the
7
7
  // HTTP status it arrived with.
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.answersSignedOut = exports.isSignedOut = exports.isSignedOutCode = exports.isRateLimited = void 0;
9
10
  exports.postGraphQL = postGraphQL;
10
11
  exports.statusAdapter = statusAdapter;
12
+ exports.retryAfterOf = retryAfterOf;
13
+ exports.statusOf = statusOf;
11
14
  exports.classifyBackendErrors = classifyBackendErrors;
12
- exports.errorsText = errorsText;
15
+ exports.answerText = answerText;
16
+ exports.thrownText = thrownText;
17
+ const harness_1 = require("@agentic-kit/harness");
13
18
  const runtime_1 = require("@constructive-io/graphql-query/runtime");
14
19
  const errorText = (err) => (err instanceof Error ? err.message : String(err));
15
20
  async function postGraphQL(args) {
@@ -23,7 +28,11 @@ async function postGraphQL(args) {
23
28
  Accept: 'application/json',
24
29
  ...args.headers,
25
30
  },
26
- body: JSON.stringify({ query: args.query, variables: args.variables ?? {} }),
31
+ body: JSON.stringify({
32
+ query: args.query,
33
+ variables: args.variables ?? {},
34
+ ...(args.operationName === undefined ? {} : { operationName: args.operationName }),
35
+ }),
27
36
  });
28
37
  }
29
38
  catch (err) {
@@ -40,6 +49,8 @@ async function postGraphQL(args) {
40
49
  };
41
50
  }
42
51
  const httpStatus = response.status;
52
+ const retryAfter = retryAfterSeconds(response.headers?.get?.('Retry-After') ?? null);
53
+ const waited = retryAfter === undefined ? {} : { retryAfterSeconds: retryAfter };
43
54
  let body = null;
44
55
  try {
45
56
  body = (await response.json());
@@ -55,7 +66,7 @@ async function postGraphQL(args) {
55
66
  errors: bodyErrors.map((error) => ({
56
67
  ...error,
57
68
  message: error?.message ?? '',
58
- extensions: { ...error?.extensions, httpStatus },
69
+ extensions: { ...error?.extensions, httpStatus, ...waited },
59
70
  })),
60
71
  };
61
72
  }
@@ -67,7 +78,7 @@ async function postGraphQL(args) {
67
78
  errors: [
68
79
  {
69
80
  message: response.ok ? `HTTP ${httpStatus}${text} (the body was not JSON)` : `HTTP ${httpStatus}${text}`,
70
- extensions: { code: 'HTTP_ERROR', httpStatus },
81
+ extensions: { code: 'HTTP_ERROR', httpStatus, ...waited },
71
82
  },
72
83
  ],
73
84
  };
@@ -93,26 +104,65 @@ function statusAdapter(endpoint, headers, fetchFn) {
93
104
  getEndpoint: () => endpoint,
94
105
  };
95
106
  }
107
+ // The backend's own codes for a request it limits (admission-control.ts), which it answers with 429.
108
+ const LIMITED = new Set(['RATE_LIMITED', 'CONCURRENCY_LIMIT_REACHED']);
109
+ /** Whether the backend limited the request (a 429, or its code): the step is to wait. */
110
+ const isRateLimited = (error) => LIMITED.has(codeOf(error) ?? '') || statusOf(error) === 429;
111
+ exports.isRateLimited = isRateLimited;
112
+ /** The seconds the backend asked to wait (its Retry-After), when it said. */
113
+ function retryAfterOf(errors) {
114
+ const seconds = (errors ?? []).map((error) => error?.extensions?.retryAfterSeconds).find((value) => typeof value === 'number');
115
+ return seconds;
116
+ }
117
+ // Retry-After is seconds, or an HTTP date.
118
+ function retryAfterSeconds(value) {
119
+ if (!value)
120
+ return undefined;
121
+ if (/^\d+$/.test(value.trim()))
122
+ return Number(value.trim());
123
+ const at = Date.parse(value);
124
+ return Number.isNaN(at) ? undefined : Math.max(0, Math.ceil((at - Date.now()) / 1000));
125
+ }
126
+ // The code of a public error. An internal error may keep a public-looking
127
+ // code (FORBIDDEN) over a masked message, so its code means nothing.
96
128
  const codeOf = (error) => {
97
129
  const code = error?.extensions?.code;
98
- return typeof code === 'string' ? code : undefined;
130
+ return typeof code === 'string' && error?.extensions?.class !== 'internal' ? code : undefined;
99
131
  };
100
- // The status an error arrived with: ours from extensions, or the SDK
101
- // adapter's `HTTP 503: …` message.
102
- const statusOf = (error) => {
103
- const status = error?.extensions?.httpStatus;
104
- if (typeof status === 'number')
105
- return status;
132
+ /**
133
+ * The HTTP status of one error: the one the server put inside it
134
+ * (`extensions.http`, since it answers every GraphQL request with HTTP 200),
135
+ * else the response's own (`extensions.httpStatus`, added by `postGraphQL`),
136
+ * else the one in the SDK FetchAdapter's "HTTP 503: …" message, which drops
137
+ * the body.
138
+ */
139
+ function statusOf(error) {
140
+ for (const status of [error?.extensions?.http, error?.extensions?.httpStatus]) {
141
+ if (typeof status === 'number')
142
+ return status;
143
+ }
106
144
  const match = /^HTTP (\d{3})\b/.exec(error?.message ?? '');
107
145
  return match ? Number(match[1]) : undefined;
108
- };
109
- const AUTH_MESSAGE_RE = /jwt|unauthenticated|invalid token/i;
110
- const FORBIDDEN_MESSAGE_RE = /permission denied/i;
146
+ }
111
147
  /**
112
- * What a failed backend answer says, first match wins: the database is
113
- * suspended or gone (`ACCESS_SUSPENDED`), no response, the backend failing
114
- * (5xx, 429), a rejected credential (401), a refusal (403), or anything else.
148
+ * What a failed backend answer says, by its code and status, first match
149
+ * wins: the database is suspended or gone (`ACCESS_SUSPENDED`), no response,
150
+ * the backend limiting requests (429), the backend failing (5xx), a rejected credential (401,
151
+ * `UNAUTHENTICATED`), a refusal (403, `FORBIDDEN`), or anything else.
115
152
  */
153
+ const SIGNED_OUT_CODES = new Set(['UNAUTHENTICATED', 'NOT_AUTHENTICATED', 'USER_NOT_AUTHENTICATED']);
154
+ /** Whether a public code says the request's sign-in has ended or is missing (packages/errors registry). */
155
+ const isSignedOutCode = (code) => SIGNED_OUT_CODES.has(code ?? '');
156
+ exports.isSignedOutCode = isSignedOutCode;
157
+ /** Whether an error says the backend did not accept the request's credential: one of those codes, or a 401. */
158
+ const isSignedOut = (error) => statusOf(error) === 401 || (0, exports.isSignedOutCode)(codeOf(error));
159
+ exports.isSignedOut = isSignedOut;
160
+ /** Whether a thrown SDK error carries an answer that says so. */
161
+ const answersSignedOut = (err) => {
162
+ const errors = err?.errors;
163
+ return Array.isArray(errors) && errors.some(exports.isSignedOut);
164
+ };
165
+ exports.answersSignedOut = answersSignedOut;
116
166
  function classifyBackendErrors(errors) {
117
167
  const list = errors ?? [];
118
168
  const some = (test) => list.some((error) => test(error));
@@ -120,21 +170,51 @@ function classifyBackendErrors(errors) {
120
170
  return 'suspended';
121
171
  if (some((e) => codeOf(e) === 'NETWORK'))
122
172
  return 'network';
173
+ if (some(exports.isRateLimited))
174
+ return 'rate-limited';
123
175
  if (some((e) => {
124
176
  const status = statusOf(e);
125
- return status !== undefined && (status >= 500 || status === 429);
177
+ return status !== undefined && status >= 500;
126
178
  })) {
127
179
  return 'server';
128
180
  }
129
- if (some((e) => statusOf(e) === 401 || codeOf(e) === 'UNAUTHENTICATED' || AUTH_MESSAGE_RE.test(e?.message ?? ''))) {
181
+ if (some(exports.isSignedOut))
130
182
  return 'auth';
131
- }
132
- if (some((e) => statusOf(e) === 403 || codeOf(e) === 'FORBIDDEN' || FORBIDDEN_MESSAGE_RE.test(e?.message ?? ''))) {
183
+ if (some((e) => statusOf(e) === 403 || codeOf(e) === 'FORBIDDEN'))
133
184
  return 'forbidden';
134
- }
135
185
  return 'graphql';
136
186
  }
137
- /** The messages of a failed answer, joined for a reason string. */
138
- function errorsText(errors) {
139
- return (errors ?? []).map((error) => error?.message || codeOf(error) || 'unknown error').join('; ');
187
+ // A code a server means for its caller is a word in capitals (FORBIDDEN, UNIQUE_VIOLATION). A database error's own
188
+ // code has a digit in its first word, so it is never named.
189
+ const PUBLIC_CODE = /^[A-Z]+(?:_[A-Z0-9]+)*$/;
190
+ // One error in fixed words: a logged error by its id, else its public code, else its HTTP status.
191
+ function errorWords(error) {
192
+ const id = error?.extensions?.errorId;
193
+ if (typeof id === 'string')
194
+ return `an internal error (error id ${id})`;
195
+ const code = codeOf(error);
196
+ if (code && PUBLIC_CODE.test(code))
197
+ return `the code ${code}`;
198
+ const status = statusOf(error);
199
+ return status === undefined || status === 200 ? 'an error without a public code' : `HTTP ${status}`;
200
+ }
201
+ /**
202
+ * What a failed answer was, in fixed words: each error's public code, HTTP status or error id. The text a server writes
203
+ * is never in them, since a server can pass the database's own text through, with internal table names and error
204
+ * codes. Only a request that got no answer keeps its text, which postGraphQL made from the local fetch failure.
205
+ */
206
+ function answerText(errors) {
207
+ const list = errors ?? [];
208
+ const unanswered = list.find((error) => codeOf(error) === 'NETWORK' && error?.extensions?.httpStatus === undefined);
209
+ if (unanswered)
210
+ return `the backend did not answer (${unanswered.message || 'no response'})`;
211
+ const words = [...new Set(list.map(errorWords))];
212
+ return `the backend answered with ${words.length ? (0, harness_1.listed)(words) : 'an error without a public code'}`;
213
+ }
214
+ /** A thrown error in words that hold no server text: an SDK error by its GraphQL errors, any other by its own message. */
215
+ function thrownText(err) {
216
+ const errors = err?.errors;
217
+ if (Array.isArray(errors) && errors.length > 0)
218
+ return answerText(errors);
219
+ return err instanceof Error ? err.message : String(err);
140
220
  }
package/host.d.ts CHANGED
@@ -10,8 +10,14 @@
10
10
  * Nothing here is harness-specific: the host is the *application* a tool acts
11
11
  * on behalf of, so the same contract serves whichever adapter runs the tools.
12
12
  */
13
+ import type { PlanAgent, ToolCallSuggestion } from '@agentic-kit/harness';
14
+ import { type Result } from './failure';
13
15
  export type HostAccount = {
14
16
  userId: string;
17
+ /** Shown beside the user id in a plan, when the host knows it. */
18
+ email?: string;
19
+ /** The agent of the person the session acts as, when it acts as one; a plan names it beside the account. */
20
+ agent?: PlanAgent;
15
21
  accessToken: string;
16
22
  apiKey?: string;
17
23
  };
@@ -99,8 +105,11 @@ export type ProjectBinding = {
99
105
  skipped?: boolean;
100
106
  };
101
107
  export interface ToolsHost {
102
- /** Signed-in platform account, or null/undefined when signed out. */
103
- account(): HostAccount | null | undefined;
108
+ /**
109
+ * Signed-in platform account, or null/undefined when signed out. It may be a promise: a host that mints a
110
+ * short-lived token answers once it has one. A rejection reads as signed out, like a throw.
111
+ */
112
+ account(): HostAccount | null | undefined | Promise<HostAccount | null | undefined>;
104
113
  /** Host-configured backend endpoints (env-aware). */
105
114
  backendConfig(): HostBackendConfig | null | undefined;
106
115
  /** Optional data-plane token broker (see DataAuthBroker). */
@@ -142,17 +151,25 @@ export interface ToolsHost {
142
151
  deliverSecret?(delivery: SecretDelivery): Promise<void>;
143
152
  /**
144
153
  * What to tell the agent to do about a database that is gone or belongs to
145
- * another account, in place of the default advice to call
146
- * provision_database with `reprovision: true`.
154
+ * another account, in place of the default advice to bind the directory to
155
+ * a new database.
147
156
  */
148
157
  reprovisionHint?: string;
149
158
  /**
150
- * Whether the agent may replace a binding through provision_database's
151
- * `reprovision: true`. Default true. A host that replaces databases only
152
- * after the user approves (calling `provisionDatabase` in replace mode
153
- * itself) sets false, and the tool then refuses.
159
+ * Whether the agent may replace a binding through replace_database. Default
160
+ * true. A host that replaces databases only after the user approves (calling
161
+ * `provisionDatabase` in replace mode itself) sets false, and the tool then
162
+ * refuses.
154
163
  */
155
164
  toolReprovision?: boolean;
165
+ /**
166
+ * Whether the tools prepare packages/app: provision_database clones the app
167
+ * template and installs it while the backend provisions, and run_codegen
168
+ * creates or installs the app it generates into. Default true. A host that
169
+ * prepares the app itself, or not at all, sets false: then nothing is cloned
170
+ * or installed, and run_codegen only generates into an app that is there.
171
+ */
172
+ prewarmApp?: boolean;
156
173
  /**
157
174
  * Save a binding in the host's own store. Provisioning calls it before
158
175
  * writing `.env`, on a new binding and on a kept one (`skipped`). If it
@@ -164,5 +181,13 @@ export interface ToolsHost {
164
181
  export declare const DEFAULT_DATA_TOKEN_SKEW_MS = 30000;
165
182
  /** The advice for a database that is gone or under another account. */
166
183
  export declare function reprovisionAdvice(host: ToolsHost): string;
184
+ /** The call that binds the directory to a new database in place of its own, when the agent may make it. */
185
+ export declare function replaceCall(host: ToolsHost): {
186
+ calls?: ToolCallSuggestion[];
187
+ };
167
188
  export declare function configureHost(host: ToolsHost): void;
189
+ /** The host's backend config, or `no-backend` when the host could not give it. */
190
+ export declare function readBackendConfig(host: ToolsHost): Result<HostBackendConfig | null | undefined>;
191
+ /** The signed-in account, or `signed-out` when the host could not give it (it threw, or its promise rejected). */
192
+ export declare function readAccount(host: ToolsHost): Promise<Result<HostAccount | null | undefined>>;
168
193
  export declare function getHost(): ToolsHost;
package/host.js CHANGED
@@ -15,17 +15,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.DEFAULT_DATA_TOKEN_SKEW_MS = void 0;
16
16
  exports.noBackendReason = noBackendReason;
17
17
  exports.reprovisionAdvice = reprovisionAdvice;
18
+ exports.replaceCall = replaceCall;
18
19
  exports.configureHost = configureHost;
20
+ exports.readBackendConfig = readBackendConfig;
21
+ exports.readAccount = readAccount;
19
22
  exports.getHost = getHost;
23
+ const failure_1 = require("./failure");
24
+ const graphql_http_1 = require("./graphql-http");
20
25
  /**
21
26
  * The tools never default to a backend: with no configured endpoint they fail
22
27
  * and say so, rather than sending the account credential to a guessed host.
23
28
  */
24
29
  function noBackendReason(hint) {
25
- return `No Constructive backend is configured. ${hint ?? 'Choose a backend in the app, then retry.'}`;
30
+ return (0, failure_1.failureText)((0, failure_1.noBackendFailure)(hint));
26
31
  }
27
32
  exports.DEFAULT_DATA_TOKEN_SKEW_MS = 30_000;
28
- const DEFAULT_REPROVISION_ADVICE = 'Re-provision with provision_database (reprovision: true): the schema is rebuilt from the project, and records do not carry over.';
33
+ const DEFAULT_REPROVISION_ADVICE = 'Bind the directory to a new database in place of this one: the schema is rebuilt from the project, and records do not carry over.';
29
34
  /** The advice for a database that is gone or under another account. */
30
35
  function reprovisionAdvice(host) {
31
36
  if (host.reprovisionHint)
@@ -34,10 +39,48 @@ function reprovisionAdvice(host) {
34
39
  return 'Ask the user to re-provision it from the app.';
35
40
  return DEFAULT_REPROVISION_ADVICE;
36
41
  }
42
+ /** The call that binds the directory to a new database in place of its own, when the agent may make it. */
43
+ function replaceCall(host) {
44
+ return host.toolReprovision === false ? {} : { calls: [(0, failure_1.suggest)('replace_database', {}, 'Bind the directory to a new, empty database in place of this one', ['database_name'])] };
45
+ }
37
46
  let currentHost = null;
38
47
  function configureHost(host) {
39
48
  currentHost = host;
40
49
  }
50
+ // A host callback may throw (a backend override that is not a URL, a locked
51
+ // keychain); a tool returns a failure instead.
52
+ /** The host's backend config, or `no-backend` when the host could not give it. */
53
+ function readBackendConfig(host) {
54
+ try {
55
+ return { kind: 'ok', value: host.backendConfig() };
56
+ }
57
+ catch (err) {
58
+ return {
59
+ kind: 'failed',
60
+ failure: {
61
+ code: 'no-backend',
62
+ message: `Could not read the backend settings: ${(0, graphql_http_1.thrownText)(err)}`,
63
+ hint: 'Fix the backend settings, then retry.',
64
+ },
65
+ };
66
+ }
67
+ }
68
+ /** The signed-in account, or `signed-out` when the host could not give it (it threw, or its promise rejected). */
69
+ async function readAccount(host) {
70
+ try {
71
+ return { kind: 'ok', value: await host.account() };
72
+ }
73
+ catch (err) {
74
+ return {
75
+ kind: 'failed',
76
+ failure: {
77
+ code: 'signed-out',
78
+ message: `Could not read the signed-in account: ${(0, graphql_http_1.thrownText)(err)}`,
79
+ hint: host.signInHint ?? 'Sign in again, then retry.',
80
+ },
81
+ };
82
+ }
83
+ }
41
84
  function getHost() {
42
85
  if (!currentHost) {
43
86
  throw new Error('@agentic-kit/db-tools host not configured. Call configureHost() (or createDbTools(host)) before using the db tools.');
package/index.d.ts CHANGED
@@ -1,20 +1,21 @@
1
1
  import type { AnyHarnessTool } from '@agentic-kit/harness';
2
2
  import { type ToolsHost } from './host';
3
- /**
4
- * The Constructive database tools, in registration order.
5
- *
6
- * Plain `HarnessTool`s: a harness gets them by mapping them into its own tool
7
- * shape, which is the adapter's job, so this package stays free of any harness
8
- * dependency (see `toPiTool` in `@agentic-kit/pi` for that binding).
9
- */
10
- export declare const constructiveDbTools: readonly AnyHarnessTool[];
3
+ import { constructiveDbTools } from './tools';
4
+ export { constructiveDbTools };
11
5
  /** Configure the host and get the tools in one call. */
12
6
  export declare function createConstructiveDbTools(host: ToolsHost): readonly AnyHarnessTool[];
7
+ export { ACCESS_CHECKS, type AccessCheck, type AccessFinding, accessFindings, type AccessOperation, ADDED_FIELDS, type AddedColumn, type AddedDefault, type AddedField, BUILT_IN_SCOPES, checkRule, type ColumnGap, columnGaps, type ColumnRead, columnsReadByPolicies, type DataNodeNeed, dataNodesForPolicies, defaultFills, DERIVED_KEYS, explainPolicy, fieldsAddedByNodes, type MembershipScope, type NeededDataNode, POLICY_ROLES, POLICY_WORDS, policyDifference, type PolicyWordsTemplate, type ResolvedPolicy, resolveEntityTypes, ROW_ID, type RuleProblem, TABLE_NEEDS, type TableAccessInput, type TableField, type TableKind, type TablePolicy, tablePolicyFromBlueprint, type TablePrivilege, } from './access';
8
+ export { expandBlueprintDefaults } from './blueprint/blueprint-defaults';
9
+ export { type AccessPolicy, AccessPolicyZod, AuthzTypeZod, type Blueprint, blueprintProblems, BlueprintZod, type FieldBlueprint, type TableBlueprint, } from './blueprint/blueprint-schema';
10
+ export { fieldTypeToTypeName, toFieldDefault, toFieldType } from './blueprint/field-type';
11
+ export { isInternalPolicy } from './blueprint/internal-policies';
13
12
  export { BlueprintBuildError, buildBlueprint, CONSTRUCTION_DEADLINE_MS, type ConstructionTableMap, readConstructionFailure, waitForConstruction, type WaitForConstructionOptions, } from './blueprint-construction';
14
13
  export { CONTEXT_ENV_KEYS, CONTEXT_ENV_PREFIX, type ContextEnvKey, type ContextSource, deriveSubdomainEndpoint, fromEnvFile, fromEnvironment, type ModulesClient, type ProjectContext, type ProjectContextFailureCode, resolveDataToken, resolveProjectContext, type ResolveResult, } from './context';
15
14
  export { type DatabaseProbe, probeBoundDatabase, probeDatabase, type UnreachableCause, } from './db-probe';
15
+ export { failureFromErrors, type FailureMeaning } from './failure';
16
16
  export { constructiveGateDeps, type ConstructiveGateResolvers } from './gate';
17
17
  export { type BackendErrorKind, classifyBackendErrors, type HttpGraphQLResponse, postGraphQL, statusAdapter, } from './graphql-http';
18
+ export { type PostGraphQLArgs } from './graphql-http';
18
19
  export { type ActiveDataToken, configureHost, type DataAuthBroker, DEFAULT_DATA_TOKEN_SKEW_MS, getHost, type HostAccount, type HostBackendConfig, type HostProvisionOverlay, noBackendReason, type PreviewToken, type ProjectBinding, type SecretDelivery, type StepUpRequest, type ToolsHost, } from './host';
19
20
  export { archiveBindingKeys, ARCHIVED_BINDING_KEYS, type EnvVars, mergeEnv, provisionEnvVars, readEnv, } from './provision-database/env-file';
20
21
  export { loadProvisionManifest, parseProvisionManifest, PROVISION_MANIFEST_FILE, type ProvisionManifest, } from './provision-database/manifest';
@@ -22,9 +23,18 @@ export { allModulePresets, DEFAULT_PROVISION_PRESET, getModulePreset, type Modul
22
23
  export { provisionDatabase, type ProvisionDatabaseDetails, type ProvisionFailureCode, type ProvisionInput, } from './provision-database/provision';
23
24
  export { moduleKey, type ProvisionOverlay, resolveProvisionModules, } from './provision-database/resolve';
24
25
  export { accessOf, type ColumnDefault, type FkAction, type ModelColumn, type ModelForeignKey, type ModelPolicy, type ModelTable, type ObjectCategory, readSchemaModel, type SchemaModel, SchemaReadError, type TableAccess, } from './schema-model';
26
+ export { accessState, asWritten, grantWords, planRule, ruleWords, type WrittenRule } from './table-access';
25
27
  export { toolSchema } from './tool-schema';
26
- export { type AddRecordsDetails } from './tools/add-records';
27
- export { type CreateApiKeyDetails } from './tools/create-api-key';
28
- export { type RunCodegenDetails, type RunCodegenTimings } from './tools/run-codegen';
29
- export { createTemplatePreviewTables } from './tools/templates';
28
+ export { describePolicyTypeTool, explainAccessTool, type ExplainedRule, type ExplainedTable, setAccessTool } from './tools/access';
29
+ export { type AddPoliciesDetails, addPoliciesTool } from './tools/add-policies';
30
+ export { type AddRecordsDetails, addRecordsTool } from './tools/add-records';
31
+ export { type AddRelationDetails, addRelationTool } from './tools/add-relation';
32
+ export { type CreateApiKeyDetails, createApiKeyTool } from './tools/create-api-key';
33
+ export { type DescribeSchemaDetails, describeSchemaTool } from './tools/describe-schema';
34
+ export { createEntityTypeTool, deleteEntityTypeTool, type EntityTypesDetails, type EntityTypeSummary, listEntityTypesTool } from './tools/entity-types';
35
+ export { createFieldTool, deleteFieldTool, deleteTableTool, type MutationDetails, retypeFieldTool, updateFieldTool, } from './tools/mutations';
36
+ export { type ProvisionBlueprintDetails, provisionBlueprintTool } from './tools/provision-blueprint';
37
+ export { provisionDatabaseTool, replaceDatabaseTool } from './tools/provision-database';
38
+ export { type RunCodegenDetails, type RunCodegenTimings, runCodegenTool } from './tools/run-codegen';
39
+ export { applyTemplateTool, type CreateTemplateDetails, createTemplatePreviewTables, createTemplateTool, deleteTemplateTool, type ListTemplatesDetails, listTemplatesTool, type TemplateDetails, updateTemplateTool, } from './tools/templates';
30
40
  export default constructiveDbTools;
package/index.js CHANGED
@@ -1,51 +1,50 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTemplatePreviewTables = exports.toolSchema = exports.SchemaReadError = exports.readSchemaModel = exports.accessOf = exports.resolveProvisionModules = exports.moduleKey = exports.provisionDatabase = exports.getModulePreset = exports.DEFAULT_PROVISION_PRESET = exports.allModulePresets = exports.PROVISION_MANIFEST_FILE = exports.parseProvisionManifest = exports.loadProvisionManifest = exports.readEnv = exports.provisionEnvVars = exports.mergeEnv = exports.ARCHIVED_BINDING_KEYS = exports.archiveBindingKeys = exports.noBackendReason = exports.getHost = exports.DEFAULT_DATA_TOKEN_SKEW_MS = exports.configureHost = exports.statusAdapter = exports.postGraphQL = exports.classifyBackendErrors = exports.constructiveGateDeps = exports.probeDatabase = exports.probeBoundDatabase = exports.resolveProjectContext = exports.resolveDataToken = exports.fromEnvironment = exports.fromEnvFile = exports.deriveSubdomainEndpoint = exports.CONTEXT_ENV_PREFIX = exports.CONTEXT_ENV_KEYS = exports.waitForConstruction = exports.readConstructionFailure = exports.CONSTRUCTION_DEADLINE_MS = exports.buildBlueprint = exports.BlueprintBuildError = exports.constructiveDbTools = void 0;
3
+ exports.DEFAULT_DATA_TOKEN_SKEW_MS = exports.configureHost = exports.statusAdapter = exports.postGraphQL = exports.classifyBackendErrors = exports.constructiveGateDeps = exports.failureFromErrors = exports.probeDatabase = exports.probeBoundDatabase = exports.resolveProjectContext = exports.resolveDataToken = exports.fromEnvironment = exports.fromEnvFile = exports.deriveSubdomainEndpoint = exports.CONTEXT_ENV_PREFIX = exports.CONTEXT_ENV_KEYS = exports.waitForConstruction = exports.readConstructionFailure = exports.CONSTRUCTION_DEADLINE_MS = exports.buildBlueprint = exports.BlueprintBuildError = exports.isInternalPolicy = exports.toFieldType = exports.toFieldDefault = exports.fieldTypeToTypeName = exports.BlueprintZod = exports.blueprintProblems = exports.AuthzTypeZod = exports.AccessPolicyZod = exports.expandBlueprintDefaults = exports.tablePolicyFromBlueprint = exports.TABLE_NEEDS = exports.ROW_ID = exports.resolveEntityTypes = exports.policyDifference = exports.POLICY_WORDS = exports.POLICY_ROLES = exports.fieldsAddedByNodes = exports.explainPolicy = exports.DERIVED_KEYS = exports.defaultFills = exports.dataNodesForPolicies = exports.columnsReadByPolicies = exports.columnGaps = exports.checkRule = exports.BUILT_IN_SCOPES = exports.ADDED_FIELDS = exports.accessFindings = exports.ACCESS_CHECKS = exports.constructiveDbTools = void 0;
4
+ exports.listTemplatesTool = exports.deleteTemplateTool = exports.createTemplateTool = exports.createTemplatePreviewTables = exports.applyTemplateTool = exports.runCodegenTool = exports.replaceDatabaseTool = exports.provisionDatabaseTool = exports.provisionBlueprintTool = exports.updateFieldTool = exports.retypeFieldTool = exports.deleteTableTool = exports.deleteFieldTool = exports.createFieldTool = exports.listEntityTypesTool = exports.deleteEntityTypeTool = exports.createEntityTypeTool = exports.describeSchemaTool = exports.createApiKeyTool = exports.addRelationTool = exports.addRecordsTool = exports.addPoliciesTool = exports.setAccessTool = exports.explainAccessTool = exports.describePolicyTypeTool = exports.toolSchema = exports.ruleWords = exports.planRule = exports.grantWords = exports.asWritten = exports.accessState = exports.SchemaReadError = exports.readSchemaModel = exports.accessOf = exports.resolveProvisionModules = exports.moduleKey = exports.provisionDatabase = exports.getModulePreset = exports.DEFAULT_PROVISION_PRESET = exports.allModulePresets = exports.PROVISION_MANIFEST_FILE = exports.parseProvisionManifest = exports.loadProvisionManifest = exports.readEnv = exports.provisionEnvVars = exports.mergeEnv = exports.ARCHIVED_BINDING_KEYS = exports.archiveBindingKeys = exports.noBackendReason = exports.getHost = void 0;
5
+ exports.updateTemplateTool = void 0;
4
6
  exports.createConstructiveDbTools = createConstructiveDbTools;
5
7
  const host_1 = require("./host");
6
- const add_policies_1 = require("./tools/add-policies");
7
- const add_records_1 = require("./tools/add-records");
8
- const add_relation_1 = require("./tools/add-relation");
9
- const create_api_key_1 = require("./tools/create-api-key");
10
- const describe_schema_1 = require("./tools/describe-schema");
11
- const manage_entity_types_1 = require("./tools/manage-entity-types");
12
- const mutations_1 = require("./tools/mutations");
13
- const provision_blueprint_1 = require("./tools/provision-blueprint");
14
- const provision_database_1 = require("./tools/provision-database");
15
- const run_codegen_1 = require("./tools/run-codegen");
16
- const templates_1 = require("./tools/templates");
17
- /**
18
- * The Constructive database tools, in registration order.
19
- *
20
- * Plain `HarnessTool`s: a harness gets them by mapping them into its own tool
21
- * shape, which is the adapter's job, so this package stays free of any harness
22
- * dependency (see `toPiTool` in `@agentic-kit/pi` for that binding).
23
- */
24
- exports.constructiveDbTools = [
25
- provision_database_1.provisionDatabaseTool,
26
- describe_schema_1.describeSchemaTool,
27
- templates_1.listTemplatesTool,
28
- provision_blueprint_1.provisionBlueprintTool,
29
- add_relation_1.addRelationTool,
30
- mutations_1.deleteTableTool,
31
- mutations_1.createFieldTool,
32
- mutations_1.updateFieldTool,
33
- mutations_1.deleteFieldTool,
34
- add_policies_1.addPoliciesTool,
35
- templates_1.applyTemplateTool,
36
- templates_1.createTemplateTool,
37
- templates_1.updateTemplateTool,
38
- templates_1.deleteTemplateTool,
39
- add_records_1.addRecordsTool,
40
- manage_entity_types_1.manageEntityTypesTool,
41
- create_api_key_1.createApiKeyTool,
42
- run_codegen_1.runCodegenTool,
43
- ];
8
+ const tools_1 = require("./tools");
9
+ Object.defineProperty(exports, "constructiveDbTools", { enumerable: true, get: function () { return tools_1.constructiveDbTools; } });
44
10
  /** Configure the host and get the tools in one call. */
45
11
  function createConstructiveDbTools(host) {
46
12
  (0, host_1.configureHost)(host);
47
- return exports.constructiveDbTools;
13
+ return tools_1.constructiveDbTools;
48
14
  }
15
+ var access_1 = require("./access");
16
+ Object.defineProperty(exports, "ACCESS_CHECKS", { enumerable: true, get: function () { return access_1.ACCESS_CHECKS; } });
17
+ Object.defineProperty(exports, "accessFindings", { enumerable: true, get: function () { return access_1.accessFindings; } });
18
+ Object.defineProperty(exports, "ADDED_FIELDS", { enumerable: true, get: function () { return access_1.ADDED_FIELDS; } });
19
+ Object.defineProperty(exports, "BUILT_IN_SCOPES", { enumerable: true, get: function () { return access_1.BUILT_IN_SCOPES; } });
20
+ Object.defineProperty(exports, "checkRule", { enumerable: true, get: function () { return access_1.checkRule; } });
21
+ Object.defineProperty(exports, "columnGaps", { enumerable: true, get: function () { return access_1.columnGaps; } });
22
+ Object.defineProperty(exports, "columnsReadByPolicies", { enumerable: true, get: function () { return access_1.columnsReadByPolicies; } });
23
+ Object.defineProperty(exports, "dataNodesForPolicies", { enumerable: true, get: function () { return access_1.dataNodesForPolicies; } });
24
+ Object.defineProperty(exports, "defaultFills", { enumerable: true, get: function () { return access_1.defaultFills; } });
25
+ Object.defineProperty(exports, "DERIVED_KEYS", { enumerable: true, get: function () { return access_1.DERIVED_KEYS; } });
26
+ Object.defineProperty(exports, "explainPolicy", { enumerable: true, get: function () { return access_1.explainPolicy; } });
27
+ Object.defineProperty(exports, "fieldsAddedByNodes", { enumerable: true, get: function () { return access_1.fieldsAddedByNodes; } });
28
+ Object.defineProperty(exports, "POLICY_ROLES", { enumerable: true, get: function () { return access_1.POLICY_ROLES; } });
29
+ Object.defineProperty(exports, "POLICY_WORDS", { enumerable: true, get: function () { return access_1.POLICY_WORDS; } });
30
+ Object.defineProperty(exports, "policyDifference", { enumerable: true, get: function () { return access_1.policyDifference; } });
31
+ Object.defineProperty(exports, "resolveEntityTypes", { enumerable: true, get: function () { return access_1.resolveEntityTypes; } });
32
+ Object.defineProperty(exports, "ROW_ID", { enumerable: true, get: function () { return access_1.ROW_ID; } });
33
+ Object.defineProperty(exports, "TABLE_NEEDS", { enumerable: true, get: function () { return access_1.TABLE_NEEDS; } });
34
+ Object.defineProperty(exports, "tablePolicyFromBlueprint", { enumerable: true, get: function () { return access_1.tablePolicyFromBlueprint; } });
35
+ var blueprint_defaults_1 = require("./blueprint/blueprint-defaults");
36
+ Object.defineProperty(exports, "expandBlueprintDefaults", { enumerable: true, get: function () { return blueprint_defaults_1.expandBlueprintDefaults; } });
37
+ var blueprint_schema_1 = require("./blueprint/blueprint-schema");
38
+ Object.defineProperty(exports, "AccessPolicyZod", { enumerable: true, get: function () { return blueprint_schema_1.AccessPolicyZod; } });
39
+ Object.defineProperty(exports, "AuthzTypeZod", { enumerable: true, get: function () { return blueprint_schema_1.AuthzTypeZod; } });
40
+ Object.defineProperty(exports, "blueprintProblems", { enumerable: true, get: function () { return blueprint_schema_1.blueprintProblems; } });
41
+ Object.defineProperty(exports, "BlueprintZod", { enumerable: true, get: function () { return blueprint_schema_1.BlueprintZod; } });
42
+ var field_type_1 = require("./blueprint/field-type");
43
+ Object.defineProperty(exports, "fieldTypeToTypeName", { enumerable: true, get: function () { return field_type_1.fieldTypeToTypeName; } });
44
+ Object.defineProperty(exports, "toFieldDefault", { enumerable: true, get: function () { return field_type_1.toFieldDefault; } });
45
+ Object.defineProperty(exports, "toFieldType", { enumerable: true, get: function () { return field_type_1.toFieldType; } });
46
+ var internal_policies_1 = require("./blueprint/internal-policies");
47
+ Object.defineProperty(exports, "isInternalPolicy", { enumerable: true, get: function () { return internal_policies_1.isInternalPolicy; } });
49
48
  var blueprint_construction_1 = require("./blueprint-construction");
50
49
  Object.defineProperty(exports, "BlueprintBuildError", { enumerable: true, get: function () { return blueprint_construction_1.BlueprintBuildError; } });
51
50
  Object.defineProperty(exports, "buildBlueprint", { enumerable: true, get: function () { return blueprint_construction_1.buildBlueprint; } });
@@ -63,6 +62,8 @@ Object.defineProperty(exports, "resolveProjectContext", { enumerable: true, get:
63
62
  var db_probe_1 = require("./db-probe");
64
63
  Object.defineProperty(exports, "probeBoundDatabase", { enumerable: true, get: function () { return db_probe_1.probeBoundDatabase; } });
65
64
  Object.defineProperty(exports, "probeDatabase", { enumerable: true, get: function () { return db_probe_1.probeDatabase; } });
65
+ var failure_1 = require("./failure");
66
+ Object.defineProperty(exports, "failureFromErrors", { enumerable: true, get: function () { return failure_1.failureFromErrors; } });
66
67
  var gate_1 = require("./gate");
67
68
  Object.defineProperty(exports, "constructiveGateDeps", { enumerable: true, get: function () { return gate_1.constructiveGateDeps; } });
68
69
  var graphql_http_1 = require("./graphql-http");
@@ -97,8 +98,50 @@ var schema_model_1 = require("./schema-model");
97
98
  Object.defineProperty(exports, "accessOf", { enumerable: true, get: function () { return schema_model_1.accessOf; } });
98
99
  Object.defineProperty(exports, "readSchemaModel", { enumerable: true, get: function () { return schema_model_1.readSchemaModel; } });
99
100
  Object.defineProperty(exports, "SchemaReadError", { enumerable: true, get: function () { return schema_model_1.SchemaReadError; } });
101
+ var table_access_1 = require("./table-access");
102
+ Object.defineProperty(exports, "accessState", { enumerable: true, get: function () { return table_access_1.accessState; } });
103
+ Object.defineProperty(exports, "asWritten", { enumerable: true, get: function () { return table_access_1.asWritten; } });
104
+ Object.defineProperty(exports, "grantWords", { enumerable: true, get: function () { return table_access_1.grantWords; } });
105
+ Object.defineProperty(exports, "planRule", { enumerable: true, get: function () { return table_access_1.planRule; } });
106
+ Object.defineProperty(exports, "ruleWords", { enumerable: true, get: function () { return table_access_1.ruleWords; } });
100
107
  var tool_schema_1 = require("./tool-schema");
101
108
  Object.defineProperty(exports, "toolSchema", { enumerable: true, get: function () { return tool_schema_1.toolSchema; } });
102
- var templates_2 = require("./tools/templates");
103
- Object.defineProperty(exports, "createTemplatePreviewTables", { enumerable: true, get: function () { return templates_2.createTemplatePreviewTables; } });
104
- exports.default = exports.constructiveDbTools;
109
+ var access_2 = require("./tools/access");
110
+ Object.defineProperty(exports, "describePolicyTypeTool", { enumerable: true, get: function () { return access_2.describePolicyTypeTool; } });
111
+ Object.defineProperty(exports, "explainAccessTool", { enumerable: true, get: function () { return access_2.explainAccessTool; } });
112
+ Object.defineProperty(exports, "setAccessTool", { enumerable: true, get: function () { return access_2.setAccessTool; } });
113
+ var add_policies_1 = require("./tools/add-policies");
114
+ Object.defineProperty(exports, "addPoliciesTool", { enumerable: true, get: function () { return add_policies_1.addPoliciesTool; } });
115
+ var add_records_1 = require("./tools/add-records");
116
+ Object.defineProperty(exports, "addRecordsTool", { enumerable: true, get: function () { return add_records_1.addRecordsTool; } });
117
+ var add_relation_1 = require("./tools/add-relation");
118
+ Object.defineProperty(exports, "addRelationTool", { enumerable: true, get: function () { return add_relation_1.addRelationTool; } });
119
+ var create_api_key_1 = require("./tools/create-api-key");
120
+ Object.defineProperty(exports, "createApiKeyTool", { enumerable: true, get: function () { return create_api_key_1.createApiKeyTool; } });
121
+ var describe_schema_1 = require("./tools/describe-schema");
122
+ Object.defineProperty(exports, "describeSchemaTool", { enumerable: true, get: function () { return describe_schema_1.describeSchemaTool; } });
123
+ var entity_types_1 = require("./tools/entity-types");
124
+ Object.defineProperty(exports, "createEntityTypeTool", { enumerable: true, get: function () { return entity_types_1.createEntityTypeTool; } });
125
+ Object.defineProperty(exports, "deleteEntityTypeTool", { enumerable: true, get: function () { return entity_types_1.deleteEntityTypeTool; } });
126
+ Object.defineProperty(exports, "listEntityTypesTool", { enumerable: true, get: function () { return entity_types_1.listEntityTypesTool; } });
127
+ var mutations_1 = require("./tools/mutations");
128
+ Object.defineProperty(exports, "createFieldTool", { enumerable: true, get: function () { return mutations_1.createFieldTool; } });
129
+ Object.defineProperty(exports, "deleteFieldTool", { enumerable: true, get: function () { return mutations_1.deleteFieldTool; } });
130
+ Object.defineProperty(exports, "deleteTableTool", { enumerable: true, get: function () { return mutations_1.deleteTableTool; } });
131
+ Object.defineProperty(exports, "retypeFieldTool", { enumerable: true, get: function () { return mutations_1.retypeFieldTool; } });
132
+ Object.defineProperty(exports, "updateFieldTool", { enumerable: true, get: function () { return mutations_1.updateFieldTool; } });
133
+ var provision_blueprint_1 = require("./tools/provision-blueprint");
134
+ Object.defineProperty(exports, "provisionBlueprintTool", { enumerable: true, get: function () { return provision_blueprint_1.provisionBlueprintTool; } });
135
+ var provision_database_1 = require("./tools/provision-database");
136
+ Object.defineProperty(exports, "provisionDatabaseTool", { enumerable: true, get: function () { return provision_database_1.provisionDatabaseTool; } });
137
+ Object.defineProperty(exports, "replaceDatabaseTool", { enumerable: true, get: function () { return provision_database_1.replaceDatabaseTool; } });
138
+ var run_codegen_1 = require("./tools/run-codegen");
139
+ Object.defineProperty(exports, "runCodegenTool", { enumerable: true, get: function () { return run_codegen_1.runCodegenTool; } });
140
+ var templates_1 = require("./tools/templates");
141
+ Object.defineProperty(exports, "applyTemplateTool", { enumerable: true, get: function () { return templates_1.applyTemplateTool; } });
142
+ Object.defineProperty(exports, "createTemplatePreviewTables", { enumerable: true, get: function () { return templates_1.createTemplatePreviewTables; } });
143
+ Object.defineProperty(exports, "createTemplateTool", { enumerable: true, get: function () { return templates_1.createTemplateTool; } });
144
+ Object.defineProperty(exports, "deleteTemplateTool", { enumerable: true, get: function () { return templates_1.deleteTemplateTool; } });
145
+ Object.defineProperty(exports, "listTemplatesTool", { enumerable: true, get: function () { return templates_1.listTemplatesTool; } });
146
+ Object.defineProperty(exports, "updateTemplateTool", { enumerable: true, get: function () { return templates_1.updateTemplateTool; } });
147
+ exports.default = tools_1.constructiveDbTools;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentic-kit/db-tools",
3
- "version": "0.12.46",
3
+ "version": "0.13.0",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "harness-neutral Constructive database tools — provisioning, schema, policies, records, templates and codegen as HarnessTools any adapter can bind",
6
6
  "main": "index.js",
@@ -20,12 +20,13 @@
20
20
  "url": "https://github.com/constructive-io/constructive/issues"
21
21
  },
22
22
  "dependencies": {
23
+ "ajv": "^8.20.0",
23
24
  "zod": "^4.4.3",
24
25
  "12factor-env": "^1.34.1",
25
- "@agentic-kit/harness": "^0.18.3",
26
- "@constructive-io/sdk": "^1.21.52",
27
- "@constructive-io/graphql-query": "^4.24.26",
28
- "node-type-registry": "^1.22.11"
26
+ "@agentic-kit/harness": "^0.19.0",
27
+ "@constructive-io/sdk": "^1.22.0",
28
+ "@constructive-io/graphql-query": "^4.25.0",
29
+ "node-type-registry": "^1.23.0"
29
30
  },
30
31
  "devDependencies": {
31
32
  "typebox": "^1.0.0"
@@ -26,6 +26,13 @@ export declare const PENDING_PROVISION_KEYS: {
26
26
  readonly userId: "PROVISION_TICKET_USER_ID";
27
27
  readonly attempts: "PROVISION_TICKET_ATTEMPTS";
28
28
  };
29
+ /** The backend's own check on a database name, which is 3 to 63 characters long. */
30
+ export declare const DATABASE_NAME_PATTERN: RegExp;
31
+ /**
32
+ * The binding keys whose value in `env` is not of its form. The .env of a cloned project is not the person's text, so
33
+ * such a value is never used, sent or shown: the caller refuses with the keys alone.
34
+ */
35
+ export declare const invalidBindingKeys: (env: Record<string, string | undefined>) => string[];
29
36
  /** The binding keys provision_database owns in a project's .env. */
30
37
  export declare const PROVISION_ENV_KEYS: readonly ["DATABASE_ID", "DATABASE_NAME", "OWNER_ID", "PGDATABASE", "API_ENDPOINT", "MODULES_ENDPOINT"];
31
38
  /**