@agentic-kit/db-tools 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -31,6 +31,7 @@ npm install @agentic-kit/db-tools
31
31
  - **Host injection** — credentials, backend endpoints and data-plane tokens come from the host application, not from the package. Call `configureHost()` once at startup; the tools read it lazily per call.
32
32
  - **Project context** — `resolveProjectContext` / `resolveDataToken` resolve the database a tool acts on from the cwd's `.env` plus the host's session, and `deriveSubdomainEndpoint` derives its per-database endpoints.
33
33
  - **Provisioning model** — the pinned `node-type-registry` presets, the provision manifest, and overlay resolution (`resolveProvisionModules`).
34
+ - **`constructiveGateDeps`** — the confirm gate's host capabilities (is the project runnable, is there a data token, what tables would a template copy) answered by these resolvers, so every adapter gates the same tools against the same project state instead of restating it.
34
35
  - **`toolSchema`** — a tool's zod parameters as plain JSON Schema, for adapters whose harness wants JSON Schema rather than zod.
35
36
 
36
37
  ## Usage
package/esm/gate.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import type { ConstructiveGateDeps } from '@agentic-kit/harness';
2
+ import { resolveDataToken as defaultResolveDataToken, resolveProjectContext as defaultResolveProjectContext } from './context';
3
+ import { createTemplatePreviewTables as defaultCreateTemplatePreviewTables } from './tools/templates';
4
+ /** The resolvers the deps are built from, so a test can substitute fakes. */
5
+ export type ConstructiveGateResolvers = {
6
+ resolveProjectContext: typeof defaultResolveProjectContext;
7
+ resolveDataToken: typeof defaultResolveDataToken;
8
+ createTemplatePreviewTables: typeof defaultCreateTemplatePreviewTables;
9
+ };
10
+ /**
11
+ * The Constructive gate's host capabilities, answered by this package's own
12
+ * project/token/template resolvers.
13
+ *
14
+ * Every adapter gates the same tools against the same project state, so the
15
+ * mapping lives here rather than once per harness — an adapter's job is only
16
+ * to hand its harness's confirm surface to the gate.
17
+ */
18
+ export declare function constructiveGateDeps(resolvers?: Partial<ConstructiveGateResolvers>): ConstructiveGateDeps;
package/esm/gate.js ADDED
@@ -0,0 +1,39 @@
1
+ import { resolveDataToken as defaultResolveDataToken, resolveProjectContext as defaultResolveProjectContext, } from './context';
2
+ import { createTemplatePreviewTables as defaultCreateTemplatePreviewTables } from './tools/templates';
3
+ /**
4
+ * The Constructive gate's host capabilities, answered by this package's own
5
+ * project/token/template resolvers.
6
+ *
7
+ * Every adapter gates the same tools against the same project state, so the
8
+ * mapping lives here rather than once per harness — an adapter's job is only
9
+ * to hand its harness's confirm surface to the gate.
10
+ */
11
+ export function constructiveGateDeps(resolvers = {}) {
12
+ const resolveProjectContext = resolvers.resolveProjectContext ?? defaultResolveProjectContext;
13
+ const resolveDataToken = resolvers.resolveDataToken ?? defaultResolveDataToken;
14
+ const createTemplatePreviewTables = resolvers.createTemplatePreviewTables ?? defaultCreateTemplatePreviewTables;
15
+ const context = async (cwd) => (await resolveProjectContext(cwd)).context;
16
+ return {
17
+ isProjectRunnable: async (cwd) => (await context(cwd)) !== null,
18
+ hasDataToken: async (cwd) => {
19
+ const resolved = await context(cwd);
20
+ if (!resolved)
21
+ return false;
22
+ return Boolean((await resolveDataToken(resolved)).token);
23
+ },
24
+ resolveTemplatePreview: async (cwd, blueprintName, displayName) => {
25
+ const resolved = await context(cwd);
26
+ if (!resolved)
27
+ return undefined;
28
+ const result = await createTemplatePreviewTables(resolved, blueprintName);
29
+ if (result.tables.length === 0)
30
+ return undefined;
31
+ return {
32
+ kind: 'template',
33
+ displayName,
34
+ blueprintName: result.blueprintName || undefined,
35
+ tables: result.tables,
36
+ };
37
+ },
38
+ };
39
+ }
package/esm/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export declare const constructiveDbTools: readonly AnyHarnessTool[];
11
11
  /** Configure the host and get the tools in one call. */
12
12
  export declare function createConstructiveDbTools(host: ToolsHost): readonly AnyHarnessTool[];
13
13
  export { CONTEXT_ENV_KEYS, CONTEXT_ENV_PREFIX, type ContextEnvKey, type ContextSource, deriveSubdomainEndpoint, fromEnvFile, fromEnvironment, type ModulesClient, type ProjectContext, type ProjectContextFailureCode, resolveDataToken, resolveProjectContext, } from './context';
14
+ export { constructiveGateDeps, type ConstructiveGateResolvers } from './gate';
14
15
  export { type ActiveDataToken, configureHost, type DataAuthBroker, DEFAULT_DATA_TOKEN_SKEW_MS, getHost, type HostAccount, type HostBackendConfig, type HostProvisionOverlay, type PreviewToken, type SecretDelivery, type StepUpRequest, type ToolsHost, } from './host';
15
16
  export { loadProvisionManifest, parseProvisionManifest, PROVISION_MANIFEST_FILE, type ProvisionManifest, } from './provision-database/manifest';
16
17
  export { allModulePresets, DEFAULT_PROVISION_PRESET, getModulePreset, type ModulePreset, type ProvisionModule, } from './provision-database/presets';
package/esm/index.js CHANGED
@@ -43,6 +43,7 @@ export function createConstructiveDbTools(host) {
43
43
  return constructiveDbTools;
44
44
  }
45
45
  export { CONTEXT_ENV_KEYS, CONTEXT_ENV_PREFIX, deriveSubdomainEndpoint, fromEnvFile, fromEnvironment, resolveDataToken, resolveProjectContext, } from './context';
46
+ export { constructiveGateDeps } from './gate';
46
47
  export { configureHost, DEFAULT_DATA_TOKEN_SKEW_MS, getHost, } from './host';
47
48
  export { loadProvisionManifest, parseProvisionManifest, PROVISION_MANIFEST_FILE, } from './provision-database/manifest';
48
49
  export { allModulePresets, DEFAULT_PROVISION_PRESET, getModulePreset, } from './provision-database/presets';
package/gate.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import type { ConstructiveGateDeps } from '@agentic-kit/harness';
2
+ import { resolveDataToken as defaultResolveDataToken, resolveProjectContext as defaultResolveProjectContext } from './context';
3
+ import { createTemplatePreviewTables as defaultCreateTemplatePreviewTables } from './tools/templates';
4
+ /** The resolvers the deps are built from, so a test can substitute fakes. */
5
+ export type ConstructiveGateResolvers = {
6
+ resolveProjectContext: typeof defaultResolveProjectContext;
7
+ resolveDataToken: typeof defaultResolveDataToken;
8
+ createTemplatePreviewTables: typeof defaultCreateTemplatePreviewTables;
9
+ };
10
+ /**
11
+ * The Constructive gate's host capabilities, answered by this package's own
12
+ * project/token/template resolvers.
13
+ *
14
+ * Every adapter gates the same tools against the same project state, so the
15
+ * mapping lives here rather than once per harness — an adapter's job is only
16
+ * to hand its harness's confirm surface to the gate.
17
+ */
18
+ export declare function constructiveGateDeps(resolvers?: Partial<ConstructiveGateResolvers>): ConstructiveGateDeps;
package/gate.js ADDED
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.constructiveGateDeps = constructiveGateDeps;
4
+ const context_1 = require("./context");
5
+ const templates_1 = require("./tools/templates");
6
+ /**
7
+ * The Constructive gate's host capabilities, answered by this package's own
8
+ * project/token/template resolvers.
9
+ *
10
+ * Every adapter gates the same tools against the same project state, so the
11
+ * mapping lives here rather than once per harness — an adapter's job is only
12
+ * to hand its harness's confirm surface to the gate.
13
+ */
14
+ function constructiveGateDeps(resolvers = {}) {
15
+ const resolveProjectContext = resolvers.resolveProjectContext ?? context_1.resolveProjectContext;
16
+ const resolveDataToken = resolvers.resolveDataToken ?? context_1.resolveDataToken;
17
+ const createTemplatePreviewTables = resolvers.createTemplatePreviewTables ?? templates_1.createTemplatePreviewTables;
18
+ const context = async (cwd) => (await resolveProjectContext(cwd)).context;
19
+ return {
20
+ isProjectRunnable: async (cwd) => (await context(cwd)) !== null,
21
+ hasDataToken: async (cwd) => {
22
+ const resolved = await context(cwd);
23
+ if (!resolved)
24
+ return false;
25
+ return Boolean((await resolveDataToken(resolved)).token);
26
+ },
27
+ resolveTemplatePreview: async (cwd, blueprintName, displayName) => {
28
+ const resolved = await context(cwd);
29
+ if (!resolved)
30
+ return undefined;
31
+ const result = await createTemplatePreviewTables(resolved, blueprintName);
32
+ if (result.tables.length === 0)
33
+ return undefined;
34
+ return {
35
+ kind: 'template',
36
+ displayName,
37
+ blueprintName: result.blueprintName || undefined,
38
+ tables: result.tables,
39
+ };
40
+ },
41
+ };
42
+ }
package/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export declare const constructiveDbTools: readonly AnyHarnessTool[];
11
11
  /** Configure the host and get the tools in one call. */
12
12
  export declare function createConstructiveDbTools(host: ToolsHost): readonly AnyHarnessTool[];
13
13
  export { CONTEXT_ENV_KEYS, CONTEXT_ENV_PREFIX, type ContextEnvKey, type ContextSource, deriveSubdomainEndpoint, fromEnvFile, fromEnvironment, type ModulesClient, type ProjectContext, type ProjectContextFailureCode, resolveDataToken, resolveProjectContext, } from './context';
14
+ export { constructiveGateDeps, type ConstructiveGateResolvers } from './gate';
14
15
  export { type ActiveDataToken, configureHost, type DataAuthBroker, DEFAULT_DATA_TOKEN_SKEW_MS, getHost, type HostAccount, type HostBackendConfig, type HostProvisionOverlay, type PreviewToken, type SecretDelivery, type StepUpRequest, type ToolsHost, } from './host';
15
16
  export { loadProvisionManifest, parseProvisionManifest, PROVISION_MANIFEST_FILE, type ProvisionManifest, } from './provision-database/manifest';
16
17
  export { allModulePresets, DEFAULT_PROVISION_PRESET, getModulePreset, type ModulePreset, type ProvisionModule, } from './provision-database/presets';
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTemplatePreviewTables = exports.toolSchema = exports.resolveProvisionModules = exports.moduleKey = exports.getModulePreset = exports.DEFAULT_PROVISION_PRESET = exports.allModulePresets = exports.PROVISION_MANIFEST_FILE = exports.parseProvisionManifest = exports.loadProvisionManifest = exports.getHost = exports.DEFAULT_DATA_TOKEN_SKEW_MS = exports.configureHost = exports.resolveProjectContext = exports.resolveDataToken = exports.fromEnvironment = exports.fromEnvFile = exports.deriveSubdomainEndpoint = exports.CONTEXT_ENV_PREFIX = exports.CONTEXT_ENV_KEYS = exports.constructiveDbTools = void 0;
3
+ exports.createTemplatePreviewTables = exports.toolSchema = exports.resolveProvisionModules = exports.moduleKey = exports.getModulePreset = exports.DEFAULT_PROVISION_PRESET = exports.allModulePresets = exports.PROVISION_MANIFEST_FILE = exports.parseProvisionManifest = exports.loadProvisionManifest = exports.getHost = exports.DEFAULT_DATA_TOKEN_SKEW_MS = exports.configureHost = exports.constructiveGateDeps = exports.resolveProjectContext = exports.resolveDataToken = exports.fromEnvironment = exports.fromEnvFile = exports.deriveSubdomainEndpoint = exports.CONTEXT_ENV_PREFIX = exports.CONTEXT_ENV_KEYS = exports.constructiveDbTools = void 0;
4
4
  exports.createConstructiveDbTools = createConstructiveDbTools;
5
5
  const host_1 = require("./host");
6
6
  const add_policies_1 = require("./tools/add-policies");
@@ -54,6 +54,8 @@ Object.defineProperty(exports, "fromEnvFile", { enumerable: true, get: function
54
54
  Object.defineProperty(exports, "fromEnvironment", { enumerable: true, get: function () { return context_1.fromEnvironment; } });
55
55
  Object.defineProperty(exports, "resolveDataToken", { enumerable: true, get: function () { return context_1.resolveDataToken; } });
56
56
  Object.defineProperty(exports, "resolveProjectContext", { enumerable: true, get: function () { return context_1.resolveProjectContext; } });
57
+ var gate_1 = require("./gate");
58
+ Object.defineProperty(exports, "constructiveGateDeps", { enumerable: true, get: function () { return gate_1.constructiveGateDeps; } });
57
59
  var host_2 = require("./host");
58
60
  Object.defineProperty(exports, "configureHost", { enumerable: true, get: function () { return host_2.configureHost; } });
59
61
  Object.defineProperty(exports, "DEFAULT_DATA_TOKEN_SKEW_MS", { enumerable: true, get: function () { return host_2.DEFAULT_DATA_TOKEN_SKEW_MS; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentic-kit/db-tools",
3
- "version": "0.2.0",
3
+ "version": "0.3.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",
@@ -31,8 +31,8 @@
31
31
  "dependencies": {
32
32
  "12factor-env": "^1.32.0",
33
33
  "@agentic-kit/harness": "^0.15.0",
34
- "@constructive-io/graphql-query": "^4.14.1",
35
- "@constructive-io/sdk": "^1.14.1",
34
+ "@constructive-io/graphql-query": "^4.15.1",
35
+ "@constructive-io/sdk": "^1.14.3",
36
36
  "node-type-registry": "^1.17.0",
37
37
  "zod": "^4.4.3"
38
38
  },
@@ -45,5 +45,5 @@
45
45
  "database",
46
46
  "constructive"
47
47
  ],
48
- "gitHead": "d4bb5506059e1dfb28f2766e6d18e8d946db632d"
48
+ "gitHead": "e35db12526094b515596ced2dd27a1ec8edd99d5"
49
49
  }