@agentic-kit/db-tools 0.15.0 → 0.16.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 (74) hide show
  1. package/README.md +4 -4
  2. package/blueprint/blueprint-schema.js +3 -1
  3. package/context.d.ts +9 -9
  4. package/context.js +92 -54
  5. package/db-probe.js +2 -2
  6. package/esm/blueprint/blueprint-schema.js +3 -1
  7. package/esm/context.d.ts +9 -9
  8. package/esm/context.js +91 -54
  9. package/esm/db-probe.js +2 -2
  10. package/esm/failure.d.ts +1 -1
  11. package/esm/failure.js +2 -2
  12. package/esm/gate.js +1 -1
  13. package/esm/graphql-http.d.ts +3 -2
  14. package/esm/graphql-http.js +26 -7
  15. package/esm/host.d.ts +20 -7
  16. package/esm/host.js +7 -2
  17. package/esm/index.d.ts +175 -14
  18. package/esm/index.js +5 -15
  19. package/esm/project-file.d.ts +72 -0
  20. package/esm/project-file.js +161 -0
  21. package/esm/provision-database/provision.d.ts +8 -3
  22. package/esm/provision-database/provision.js +63 -94
  23. package/esm/ready.d.ts +7 -3
  24. package/esm/ready.js +3 -3
  25. package/esm/records/rows.d.ts +1 -0
  26. package/esm/records/rows.js +9 -6
  27. package/esm/tools/access.js +1 -1
  28. package/esm/tools/create-api-key.js +2 -2
  29. package/esm/tools/delete-records.d.ts +1 -1
  30. package/esm/tools/delete-records.js +7 -7
  31. package/esm/tools/index.d.ts +195 -2
  32. package/esm/tools/index.js +25 -15
  33. package/esm/tools/mutations.js +7 -6
  34. package/esm/tools/provision-database.js +4 -4
  35. package/esm/tools/run-codegen.d.ts +2 -2
  36. package/esm/tools/run-codegen.js +10 -11
  37. package/esm/tools/update-records.js +1 -1
  38. package/failure.d.ts +1 -1
  39. package/failure.js +2 -2
  40. package/gate.js +1 -1
  41. package/graphql-http.d.ts +3 -2
  42. package/graphql-http.js +26 -7
  43. package/host.d.ts +20 -7
  44. package/host.js +7 -2
  45. package/index.d.ts +175 -14
  46. package/index.js +9 -45
  47. package/package.json +19 -16
  48. package/project-file.d.ts +72 -0
  49. package/project-file.js +178 -0
  50. package/provision-database/provision.d.ts +8 -3
  51. package/provision-database/provision.js +66 -96
  52. package/ready.d.ts +7 -3
  53. package/ready.js +3 -3
  54. package/records/rows.d.ts +1 -0
  55. package/records/rows.js +8 -5
  56. package/tools/access.js +1 -1
  57. package/tools/create-api-key.js +2 -2
  58. package/tools/delete-records.d.ts +1 -1
  59. package/tools/delete-records.js +8 -8
  60. package/tools/index.d.ts +195 -2
  61. package/tools/index.js +53 -43
  62. package/tools/mutations.js +6 -5
  63. package/tools/provision-database.js +5 -5
  64. package/tools/run-codegen.d.ts +2 -2
  65. package/tools/run-codegen.js +8 -9
  66. package/tools/update-records.js +1 -1
  67. package/esm/provision-database/env-file.d.ts +0 -62
  68. package/esm/provision-database/env-file.js +0 -170
  69. package/esm/provision-database/pending-ticket.d.ts +0 -33
  70. package/esm/provision-database/pending-ticket.js +0 -63
  71. package/provision-database/env-file.d.ts +0 -62
  72. package/provision-database/env-file.js +0 -179
  73. package/provision-database/pending-ticket.d.ts +0 -33
  74. package/provision-database/pending-ticket.js +0 -72
package/host.d.ts CHANGED
@@ -20,9 +20,12 @@ export type HostAccount = {
20
20
  agent?: PlanAgent;
21
21
  accessToken: string;
22
22
  apiKey?: string;
23
+ backend?: HostBackendConfig;
23
24
  };
24
25
  export type HostBackendConfig = {
25
26
  apiEndpoint?: string;
27
+ /** The auth plane, when the host knows it; without it, it is derived only from an `api.` host. */
28
+ authEndpoint?: string;
26
29
  modulesEndpoint?: string;
27
30
  agentEndpoint?: string;
28
31
  computeEndpoint?: string;
@@ -35,6 +38,7 @@ export declare function noBackendReason(hint?: string): string;
35
38
  export type ActiveDataToken = {
36
39
  token: string;
37
40
  userId?: string;
41
+ email?: string;
38
42
  expiresAt: number;
39
43
  origin?: string;
40
44
  };
@@ -53,6 +57,7 @@ export type PreviewToken = {
53
57
  accessToken: string;
54
58
  accessTokenExpiresAt?: string;
55
59
  userId?: string;
60
+ email?: string;
56
61
  };
57
62
  /**
58
63
  * Overlay layered over the pinned base preset when provisioning a database.
@@ -89,8 +94,8 @@ export type StepUpRequest = {
89
94
  };
90
95
  /**
91
96
  * The database a project is bound to, handed to the host before provisioning
92
- * writes it to the project's `.env`, so a host that keeps its own record of
93
- * the binding never ends up with a `.env` it doesn't know about.
97
+ * writes it to the project's `.constructive/project.json`, so a host that keeps
98
+ * its own record of the binding never ends up with a binding it doesn't know about.
94
99
  */
95
100
  export type ProjectBinding = {
96
101
  cwd: string;
@@ -120,8 +125,16 @@ export interface ToolsHost {
120
125
  * the desktop wording.
121
126
  */
122
127
  signInHint?: string;
123
- /** Harvest an end-user token from the host's app preview, if it has one. */
124
- previewToken?(): Promise<PreviewToken | null>;
128
+ /**
129
+ * The token of a user of the app of `database`, signed in to the app's own auth plane: harvested from the host's
130
+ * app preview, or one the host keeps for that database. Null when no one is signed in to that app.
131
+ */
132
+ previewToken?(database: {
133
+ databaseId: string;
134
+ databaseName: string;
135
+ }): Promise<PreviewToken | null>;
136
+ /** Host-specific instruction for signing in to the app, in place of the desktop wording, when a record tool finds no one. */
137
+ appSignInHint?: string;
125
138
  /** Treat tokens expiring within this window as already expired. Default 30s. */
126
139
  dataTokenSkewMs?: number;
127
140
  /**
@@ -172,8 +185,8 @@ export interface ToolsHost {
172
185
  prewarmApp?: boolean;
173
186
  /**
174
187
  * Save a binding in the host's own store. Provisioning calls it before
175
- * writing `.env`, on a new binding and on a kept one (`skipped`). If it
176
- * throws, `.env` is left alone, the provision ticket stays recorded, and
188
+ * writing the project file, on a new binding and on a kept one (`skipped`). If it
189
+ * throws, the binding is left alone, the provision ticket stays recorded, and
177
190
  * the call fails with `binding-not-saved`.
178
191
  */
179
192
  persistBinding?(binding: ProjectBinding): Promise<void>;
@@ -196,5 +209,5 @@ export declare function configureHost(host: ToolsHost): void;
196
209
  /** The host's backend config, or `no-backend` when the host could not give it. */
197
210
  export declare function readBackendConfig(host: ToolsHost): Result<HostBackendConfig | null | undefined>;
198
211
  /** The signed-in account, or `signed-out` when the host could not give it (it threw, or its promise rejected). */
199
- export declare function readAccount(host: ToolsHost): Promise<Result<HostAccount | null | undefined>>;
212
+ export declare function readAccount(host: ToolsHost, backend?: HostBackendConfig | null): Promise<Result<HostAccount | null | undefined>>;
200
213
  export declare function getHost(): ToolsHost;
package/host.js CHANGED
@@ -66,9 +66,14 @@ function readBackendConfig(host) {
66
66
  }
67
67
  }
68
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) {
69
+ async function readAccount(host, backend) {
70
70
  try {
71
- return { kind: 'ok', value: await host.account() };
71
+ const account = await host.account();
72
+ if (account?.backend && (!backend || Object.keys(account.backend)
73
+ .some((plane) => account.backend[plane] !== backend[plane]))) {
74
+ return { kind: 'failed', failure: { code: 'signed-out', message: 'The account and backend no longer match. Retry the command.' } };
75
+ }
76
+ return { kind: 'ok', value: account };
72
77
  }
73
78
  catch (err) {
74
79
  return {
package/index.d.ts CHANGED
@@ -10,14 +10,14 @@ export { type AccessPolicy, AccessPolicyZod, AuthzTypeZod, type Blueprint, bluep
10
10
  export { fieldTypeToTypeName, toFieldDefault, toFieldType } from './blueprint/field-type';
11
11
  export { isInternalPolicy } from './blueprint/internal-policies';
12
12
  export { BlueprintBuildError, buildBlueprint, CONSTRUCTION_DEADLINE_MS, type ConstructionTableMap, readConstructionFailure, waitForConstruction, type WaitForConstructionOptions, } from './blueprint-construction';
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';
13
+ export { CONTEXT_ENV_KEYS, CONTEXT_ENV_PREFIX, type ContextEnvKey, type ContextSource, deriveSubdomainEndpoint, fromEnvFile, fromEnvironment, type ModulesClient, type ProjectContext, type ProjectContextFailureCode, readEnv, resolveDataToken, resolveProjectContext, type ResolveResult, } from './context';
14
14
  export { type DatabaseProbe, probeBoundDatabase, probeDatabase, type UnreachableCause, } from './db-probe';
15
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
18
  export { type PostGraphQLArgs } from './graphql-http';
19
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';
20
- export { archiveBindingKeys, ARCHIVED_BINDING_KEYS, type EnvVars, mergeEnv, provisionEnvVars, readEnv, } from './provision-database/env-file';
20
+ export { type ArchivedEntry, type BoundDatabase, type PendingTicket, PROJECT_FILE, type ProjectFile, readProjectFile, updateProjectFile, } from './project-file';
21
21
  export { loadProvisionManifest, parseProvisionManifest, PROVISION_MANIFEST_FILE, type ProvisionManifest, } from './provision-database/manifest';
22
22
  export { allModulePresets, DEFAULT_PROVISION_PRESET, getModulePreset, type ModulePreset, type ProvisionModule, } from './provision-database/presets';
23
23
  export { provisionDatabase, type ProvisionDatabaseDetails, type ProvisionFailureCode, type ProvisionInput, } from './provision-database/provision';
@@ -26,16 +26,177 @@ export { type RecordsDetails } from './records/rows';
26
26
  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';
27
27
  export { accessState, asWritten, grantWords, planRule, ruleWords, type WrittenRule } from './table-access';
28
28
  export { toolSchema } from './tool-schema';
29
- export { describePolicyTypeTool, explainAccessTool, type ExplainedRule, type ExplainedTable, setAccessTool } from './tools/access';
30
- export { type AddPoliciesDetails, addPoliciesTool } from './tools/add-policies';
31
- export { addRecordsTool } from './tools/add-records';
32
- export { type AddRelationDetails, addRelationTool } from './tools/add-relation';
33
- export { type CreateApiKeyDetails, createApiKeyTool } from './tools/create-api-key';
34
- export { type DescribeSchemaDetails, describeSchemaTool } from './tools/describe-schema';
35
- export { createEntityTypeTool, deleteEntityTypeTool, type EntityTypesDetails, type EntityTypeSummary, listEntityTypesTool } from './tools/entity-types';
36
- export { createFieldTool, deleteFieldTool, deleteTableTool, type MutationDetails, retypeFieldTool, updateFieldTool, } from './tools/mutations';
37
- export { type ProvisionBlueprintDetails, provisionBlueprintTool } from './tools/provision-blueprint';
38
- export { provisionDatabaseTool, replaceDatabaseTool } from './tools/provision-database';
39
- export { type RunCodegenDetails, type RunCodegenTimings, runCodegenTool } from './tools/run-codegen';
40
- export { applyTemplateTool, type CreateTemplateDetails, createTemplatePreviewTables, createTemplateTool, deleteTemplateTool, type ListTemplatesDetails, listTemplatesTool, type TemplateDetails, updateTemplateTool, } from './tools/templates';
29
+ export { type ExplainedRule, type ExplainedTable } from './tools/access';
30
+ export { type AddPoliciesDetails } from './tools/add-policies';
31
+ export { type AddRelationDetails } from './tools/add-relation';
32
+ export { type CreateApiKeyDetails } from './tools/create-api-key';
33
+ export { type DescribeSchemaDetails } from './tools/describe-schema';
34
+ export { type EntityTypesDetails, type EntityTypeSummary } from './tools/entity-types';
35
+ export { type MutationDetails } from './tools/mutations';
36
+ export { type ProvisionBlueprintDetails } from './tools/provision-blueprint';
37
+ export { type RunCodegenDetails, type RunCodegenTimings } from './tools/run-codegen';
38
+ export { type CreateTemplateDetails, createTemplatePreviewTables, type ListTemplatesDetails, type TemplateDetails } from './tools/templates';
39
+ export declare const addPoliciesTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
40
+ table_name: import("zod").ZodString;
41
+ policies: import("zod").ZodArray<import("zod").ZodObject<{
42
+ $type: import("zod").ZodString;
43
+ privileges: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
44
+ permissive: import("zod").ZodOptional<import("zod").ZodBoolean>;
45
+ policy_role: import("zod").ZodOptional<import("zod").ZodString>;
46
+ policy_name: import("zod").ZodOptional<import("zod").ZodString>;
47
+ data: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
48
+ }, import("zod/v4/core").$loose>>;
49
+ }, import("zod/v4/core").$strict>, import("./tools/add-policies").AddPoliciesDetails>, addRecordsTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
50
+ table_name: import("zod").ZodString;
51
+ records: import("zod").ZodArray<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
52
+ }, import("zod/v4/core").$strict>, import("./records/rows").RecordsDetails>, addRelationTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
53
+ relation_type: import("zod").ZodOptional<import("zod").ZodEnum<{
54
+ belongs_to: "belongs_to";
55
+ many_to_many: "many_to_many";
56
+ }>>;
57
+ source_table: import("zod").ZodString;
58
+ target_table: import("zod").ZodString;
59
+ field_name: import("zod").ZodOptional<import("zod").ZodString>;
60
+ junction_table_name: import("zod").ZodOptional<import("zod").ZodString>;
61
+ delete_action: import("zod").ZodOptional<import("zod").ZodEnum<{
62
+ c: "c";
63
+ n: "n";
64
+ r: "r";
65
+ a: "a";
66
+ d: "d";
67
+ }>>;
68
+ is_required: import("zod").ZodOptional<import("zod").ZodBoolean>;
69
+ }, import("zod/v4/core").$strict>, import("./tools/add-relation").AddRelationDetails>, applyTemplateTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
70
+ templateName: import("zod").ZodString;
71
+ nameOverride: import("zod").ZodOptional<import("zod").ZodString>;
72
+ }, import("zod/v4/core").$strict>, import("./tools/templates").TemplateDetails>, createApiKeyTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
73
+ key_name: import("zod").ZodString;
74
+ principal_name: import("zod").ZodOptional<import("zod").ZodString>;
75
+ entity_ids: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodGUID>>;
76
+ read_only: import("zod").ZodOptional<import("zod").ZodBoolean>;
77
+ expires_in_days: import("zod").ZodOptional<import("zod").ZodNumber>;
78
+ }, import("zod/v4/core").$strict>, import("./tools/create-api-key").CreateApiKeyDetails>, createEntityTypeTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
79
+ name: import("zod").ZodString;
80
+ description: import("zod").ZodOptional<import("zod").ZodString>;
81
+ prefix: import("zod").ZodOptional<import("zod").ZodString>;
82
+ parent_entity: import("zod").ZodOptional<import("zod").ZodString>;
83
+ is_visible: import("zod").ZodOptional<import("zod").ZodBoolean>;
84
+ has_invites: import("zod").ZodOptional<import("zod").ZodBoolean>;
85
+ has_profiles: import("zod").ZodOptional<import("zod").ZodBoolean>;
86
+ has_limits: import("zod").ZodOptional<import("zod").ZodBoolean>;
87
+ has_levels: import("zod").ZodOptional<import("zod").ZodBoolean>;
88
+ has_storage: import("zod").ZodOptional<import("zod").ZodBoolean>;
89
+ }, import("zod/v4/core").$strict>, import("./tools/entity-types").EntityTypesDetails>, createFieldTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
90
+ table_name: import("zod").ZodString;
91
+ field_name: import("zod").ZodString;
92
+ type: import("zod").ZodString;
93
+ is_required: import("zod").ZodOptional<import("zod").ZodBoolean>;
94
+ default_value: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber, import("zod").ZodBoolean, import("zod").ZodNull]>>;
95
+ is_unique: import("zod").ZodOptional<import("zod").ZodBoolean>;
96
+ }, import("zod/v4/core").$strict>, import("./tools/mutations").MutationDetails>, createTemplateTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
97
+ displayName: import("zod").ZodString;
98
+ blueprintName: import("zod").ZodOptional<import("zod").ZodString>;
99
+ description: import("zod").ZodOptional<import("zod").ZodString>;
100
+ categories: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
101
+ }, import("zod/v4/core").$strict>, import("./tools/templates").CreateTemplateDetails>, deleteEntityTypeTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
102
+ entity_type_id: import("zod").ZodGUID;
103
+ }, import("zod/v4/core").$strict>, import("./tools/entity-types").EntityTypesDetails>, deleteFieldTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
104
+ table_name: import("zod").ZodString;
105
+ field_name: import("zod").ZodString;
106
+ }, import("zod/v4/core").$strict>, import("./tools/mutations").MutationDetails>, deleteRecordsTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
107
+ tables: import("zod").ZodArray<import("zod").ZodObject<{
108
+ table_name: import("zod").ZodString;
109
+ rows: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber]>>>;
110
+ where: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
111
+ sample: import("zod").ZodOptional<import("zod").ZodLiteral<true>>;
112
+ all: import("zod").ZodOptional<import("zod").ZodLiteral<true>>;
113
+ }, import("zod/v4/core").$strict>>;
114
+ }, import("zod/v4/core").$strict>, import("./tools/delete-records").DeleteRecordsDetails>, deleteTableTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
115
+ table_name: import("zod").ZodString;
116
+ }, import("zod/v4/core").$strict>, import("./tools/mutations").MutationDetails>, deleteTemplateTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
117
+ templateName: import("zod").ZodString;
118
+ }, import("zod/v4/core").$strict>, import("./tools/templates").TemplateDetails>, describePolicyTypeTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
119
+ type: import("zod").ZodOptional<import("zod").ZodEnum<{
120
+ [x: string]: string;
121
+ }>>;
122
+ }, import("zod/v4/core").$strict>, {
123
+ types?: {
124
+ name: string;
125
+ summary?: string;
126
+ tableKind?: string;
127
+ }[];
128
+ type?: {
129
+ name: string;
130
+ summary?: string;
131
+ tableKind?: string;
132
+ } & {
133
+ parameterSchema: unknown;
134
+ useWhen: string[];
135
+ avoidWhen: string[];
136
+ risks: string[];
137
+ dataNode?: unknown;
138
+ };
139
+ }>, describeSchemaTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{}, import("zod/v4/core").$strict>, import("./tools/describe-schema").DescribeSchemaDetails>, explainAccessTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
140
+ table_name: import("zod").ZodOptional<import("zod").ZodString>;
141
+ }, import("zod/v4/core").$strict>, {
142
+ tables: import("./tools/access").ExplainedTable[];
143
+ }>, listEntityTypesTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{}, import("zod/v4/core").$strict>, import("./tools/entity-types").EntityTypesDetails>, listTemplatesTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{}, import("zod/v4/core").$strict>, import("./tools/templates").ListTemplatesDetails>, provisionBlueprintTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
144
+ name: import("zod").ZodString;
145
+ description: import("zod").ZodString;
146
+ definition: import("zod").ZodObject<{
147
+ tables: import("zod").ZodArray<import("zod").ZodObject<{
148
+ table_name: import("zod").ZodOptional<import("zod").ZodString>;
149
+ fields: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
150
+ name: import("zod").ZodString;
151
+ }, import("zod/v4/core").$loose>>>;
152
+ }, import("zod/v4/core").$loose>>;
153
+ }, import("zod/v4/core").$loose>;
154
+ categories: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
155
+ tags: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
156
+ }, import("zod/v4/core").$strict>, import("./tools/provision-blueprint").ProvisionBlueprintDetails>, provisionDatabaseTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
157
+ database_name: import("zod").ZodString;
158
+ }, import("zod/v4/core").$strict>, import("./provision-database/provision").ProvisionDatabaseDetails>, replaceDatabaseTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
159
+ database_name: import("zod").ZodString;
160
+ }, import("zod/v4/core").$strict>, import("./provision-database/provision").ProvisionDatabaseDetails>, retypeFieldTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
161
+ table_name: import("zod").ZodString;
162
+ field_name: import("zod").ZodString;
163
+ type: import("zod").ZodString;
164
+ }, import("zod/v4/core").$strict>, import("./tools/mutations").MutationDetails>, runCodegenTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{}, import("zod/v4/core").$strict>, import("./tools/run-codegen").RunCodegenDetails>, setAccessTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
165
+ table_name: import("zod").ZodString;
166
+ policies: import("zod").ZodArray<import("zod").ZodObject<{
167
+ $type: import("zod").ZodString;
168
+ privileges: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
169
+ permissive: import("zod").ZodOptional<import("zod").ZodBoolean>;
170
+ policy_role: import("zod").ZodOptional<import("zod").ZodString>;
171
+ policy_name: import("zod").ZodOptional<import("zod").ZodString>;
172
+ data: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
173
+ }, import("zod/v4/core").$loose>>;
174
+ }, import("zod/v4/core").$strict>, {
175
+ success: boolean;
176
+ message: string;
177
+ table?: string;
178
+ access?: import("./tools/access").ExplainedTable;
179
+ }>, updateFieldTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
180
+ table_name: import("zod").ZodString;
181
+ field_name: import("zod").ZodString;
182
+ new_name: import("zod").ZodOptional<import("zod").ZodString>;
183
+ is_required: import("zod").ZodOptional<import("zod").ZodBoolean>;
184
+ default_value: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodNumber, import("zod").ZodBoolean, import("zod").ZodNull]>>;
185
+ is_unique: import("zod").ZodOptional<import("zod").ZodBoolean>;
186
+ }, import("zod/v4/core").$strict>, import("./tools/mutations").MutationDetails>, updateRecordsTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
187
+ table_name: import("zod").ZodString;
188
+ records: import("zod").ZodArray<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
189
+ }, import("zod/v4/core").$strict>, import("./records/rows").RecordsDetails>, updateTemplateTool: import("@agentic-kit/harness").HarnessTool<import("zod").ZodObject<{
190
+ templateName: import("zod").ZodString;
191
+ patch: import("zod").ZodObject<{
192
+ displayName: import("zod").ZodOptional<import("zod").ZodString>;
193
+ description: import("zod").ZodOptional<import("zod").ZodString>;
194
+ categories: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
195
+ tags: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
196
+ visibility: import("zod").ZodOptional<import("zod").ZodEnum<{
197
+ public: "public";
198
+ private: "private";
199
+ }>>;
200
+ }, import("zod/v4/core").$strict>;
201
+ }, import("zod/v4/core").$strict>, import("./tools/templates").TemplateDetails>;
41
202
  export default constructiveDbTools;
package/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
3
+ exports.configureHost = exports.statusAdapter = exports.postGraphQL = exports.classifyBackendErrors = exports.constructiveGateDeps = exports.failureFromErrors = exports.probeDatabase = exports.probeBoundDatabase = exports.resolveProjectContext = exports.resolveDataToken = exports.readEnv = 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.updateFieldTool = exports.setAccessTool = exports.runCodegenTool = exports.retypeFieldTool = exports.replaceDatabaseTool = exports.provisionDatabaseTool = exports.provisionBlueprintTool = exports.listTemplatesTool = exports.listEntityTypesTool = exports.explainAccessTool = exports.describeSchemaTool = exports.describePolicyTypeTool = exports.deleteTemplateTool = exports.deleteTableTool = exports.deleteRecordsTool = exports.deleteFieldTool = exports.deleteEntityTypeTool = exports.createTemplateTool = exports.createFieldTool = exports.createEntityTypeTool = exports.createApiKeyTool = exports.applyTemplateTool = exports.addRelationTool = exports.addRecordsTool = exports.addPoliciesTool = exports.createTemplatePreviewTables = 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.updateProjectFile = exports.readProjectFile = exports.PROJECT_FILE = exports.noBackendReason = exports.getHost = exports.DEFAULT_DATA_TOKEN_SKEW_MS = void 0;
5
+ exports.updateTemplateTool = exports.updateRecordsTool = void 0;
6
6
  exports.createConstructiveDbTools = createConstructiveDbTools;
7
7
  const host_1 = require("./host");
8
8
  const tools_1 = require("./tools");
@@ -57,6 +57,7 @@ Object.defineProperty(exports, "CONTEXT_ENV_PREFIX", { enumerable: true, get: fu
57
57
  Object.defineProperty(exports, "deriveSubdomainEndpoint", { enumerable: true, get: function () { return context_1.deriveSubdomainEndpoint; } });
58
58
  Object.defineProperty(exports, "fromEnvFile", { enumerable: true, get: function () { return context_1.fromEnvFile; } });
59
59
  Object.defineProperty(exports, "fromEnvironment", { enumerable: true, get: function () { return context_1.fromEnvironment; } });
60
+ Object.defineProperty(exports, "readEnv", { enumerable: true, get: function () { return context_1.readEnv; } });
60
61
  Object.defineProperty(exports, "resolveDataToken", { enumerable: true, get: function () { return context_1.resolveDataToken; } });
61
62
  Object.defineProperty(exports, "resolveProjectContext", { enumerable: true, get: function () { return context_1.resolveProjectContext; } });
62
63
  var db_probe_1 = require("./db-probe");
@@ -75,12 +76,10 @@ Object.defineProperty(exports, "configureHost", { enumerable: true, get: functio
75
76
  Object.defineProperty(exports, "DEFAULT_DATA_TOKEN_SKEW_MS", { enumerable: true, get: function () { return host_2.DEFAULT_DATA_TOKEN_SKEW_MS; } });
76
77
  Object.defineProperty(exports, "getHost", { enumerable: true, get: function () { return host_2.getHost; } });
77
78
  Object.defineProperty(exports, "noBackendReason", { enumerable: true, get: function () { return host_2.noBackendReason; } });
78
- var env_file_1 = require("./provision-database/env-file");
79
- Object.defineProperty(exports, "archiveBindingKeys", { enumerable: true, get: function () { return env_file_1.archiveBindingKeys; } });
80
- Object.defineProperty(exports, "ARCHIVED_BINDING_KEYS", { enumerable: true, get: function () { return env_file_1.ARCHIVED_BINDING_KEYS; } });
81
- Object.defineProperty(exports, "mergeEnv", { enumerable: true, get: function () { return env_file_1.mergeEnv; } });
82
- Object.defineProperty(exports, "provisionEnvVars", { enumerable: true, get: function () { return env_file_1.provisionEnvVars; } });
83
- Object.defineProperty(exports, "readEnv", { enumerable: true, get: function () { return env_file_1.readEnv; } });
79
+ var project_file_1 = require("./project-file");
80
+ Object.defineProperty(exports, "PROJECT_FILE", { enumerable: true, get: function () { return project_file_1.PROJECT_FILE; } });
81
+ Object.defineProperty(exports, "readProjectFile", { enumerable: true, get: function () { return project_file_1.readProjectFile; } });
82
+ Object.defineProperty(exports, "updateProjectFile", { enumerable: true, get: function () { return project_file_1.updateProjectFile; } });
84
83
  var manifest_1 = require("./provision-database/manifest");
85
84
  Object.defineProperty(exports, "loadProvisionManifest", { enumerable: true, get: function () { return manifest_1.loadProvisionManifest; } });
86
85
  Object.defineProperty(exports, "parseProvisionManifest", { enumerable: true, get: function () { return manifest_1.parseProvisionManifest; } });
@@ -106,42 +105,7 @@ Object.defineProperty(exports, "planRule", { enumerable: true, get: function ()
106
105
  Object.defineProperty(exports, "ruleWords", { enumerable: true, get: function () { return table_access_1.ruleWords; } });
107
106
  var tool_schema_1 = require("./tool-schema");
108
107
  Object.defineProperty(exports, "toolSchema", { enumerable: true, get: function () { return tool_schema_1.toolSchema; } });
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
108
  var templates_1 = require("./tools/templates");
141
- Object.defineProperty(exports, "applyTemplateTool", { enumerable: true, get: function () { return templates_1.applyTemplateTool; } });
142
109
  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; } });
110
+ exports.addPoliciesTool = tools_1.servedTools.addPoliciesTool, exports.addRecordsTool = tools_1.servedTools.addRecordsTool, exports.addRelationTool = tools_1.servedTools.addRelationTool, exports.applyTemplateTool = tools_1.servedTools.applyTemplateTool, exports.createApiKeyTool = tools_1.servedTools.createApiKeyTool, exports.createEntityTypeTool = tools_1.servedTools.createEntityTypeTool, exports.createFieldTool = tools_1.servedTools.createFieldTool, exports.createTemplateTool = tools_1.servedTools.createTemplateTool, exports.deleteEntityTypeTool = tools_1.servedTools.deleteEntityTypeTool, exports.deleteFieldTool = tools_1.servedTools.deleteFieldTool, exports.deleteRecordsTool = tools_1.servedTools.deleteRecordsTool, exports.deleteTableTool = tools_1.servedTools.deleteTableTool, exports.deleteTemplateTool = tools_1.servedTools.deleteTemplateTool, exports.describePolicyTypeTool = tools_1.servedTools.describePolicyTypeTool, exports.describeSchemaTool = tools_1.servedTools.describeSchemaTool, exports.explainAccessTool = tools_1.servedTools.explainAccessTool, exports.listEntityTypesTool = tools_1.servedTools.listEntityTypesTool, exports.listTemplatesTool = tools_1.servedTools.listTemplatesTool, exports.provisionBlueprintTool = tools_1.servedTools.provisionBlueprintTool, exports.provisionDatabaseTool = tools_1.servedTools.provisionDatabaseTool, exports.replaceDatabaseTool = tools_1.servedTools.replaceDatabaseTool, exports.retypeFieldTool = tools_1.servedTools.retypeFieldTool, exports.runCodegenTool = tools_1.servedTools.runCodegenTool, exports.setAccessTool = tools_1.servedTools.setAccessTool, exports.updateFieldTool = tools_1.servedTools.updateFieldTool, exports.updateRecordsTool = tools_1.servedTools.updateRecordsTool, exports.updateTemplateTool = tools_1.servedTools.updateTemplateTool;
147
111
  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.15.0",
3
+ "version": "0.16.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",
@@ -19,14 +19,24 @@
19
19
  "bugs": {
20
20
  "url": "https://github.com/constructive-io/constructive/issues"
21
21
  },
22
+ "scripts": {
23
+ "clean": "makage clean",
24
+ "prepack": "npm run build",
25
+ "build": "makage build",
26
+ "build:dev": "makage build --dev",
27
+ "lint": "eslint . --fix",
28
+ "test": "jest",
29
+ "test:watch": "jest --watch"
30
+ },
22
31
  "dependencies": {
23
- "ajv": "^8.20.0",
24
- "zod": "^4.4.3",
25
32
  "12factor-env": "^1.34.1",
26
- "@agentic-kit/harness": "^0.21.0",
27
- "@constructive-io/graphql-query": "^4.26.0",
28
- "@constructive-io/sdk": "^1.22.2",
29
- "node-type-registry": "^1.24.0"
33
+ "@agentic-kit/harness": "^0.22.0",
34
+ "@constructive-io/errors": "^0.27.1",
35
+ "@constructive-io/graphql-query": "^4.26.1",
36
+ "@constructive-io/sdk": "^1.22.3",
37
+ "ajv": "^8.20.0",
38
+ "node-type-registry": "^2.0.0",
39
+ "zod": "^4.4.3"
30
40
  },
31
41
  "devDependencies": {
32
42
  "typebox": "^1.0.0"
@@ -37,12 +47,5 @@
37
47
  "database",
38
48
  "constructive"
39
49
  ],
40
- "scripts": {
41
- "clean": "makage clean",
42
- "build": "makage build",
43
- "build:dev": "makage build --dev",
44
- "lint": "eslint . --fix",
45
- "test": "jest",
46
- "test:watch": "jest --watch"
47
- }
48
- }
50
+ "gitHead": "c1f8c703f57f99d27bc82757283c95e700127761"
51
+ }
@@ -0,0 +1,72 @@
1
+ import type { Result } from './failure';
2
+ /** The binding's file, relative to the project directory. */
3
+ export declare const PROJECT_FILE: string;
4
+ /** The bound database. A host that binds a work directory of its own may know only its id. */
5
+ export type BoundDatabase = {
6
+ id: string;
7
+ name?: string;
8
+ ownerId?: string;
9
+ };
10
+ /**
11
+ * The provision request provision_database stopped waiting on: the next call with the same name resumes it. Only a
12
+ * ticket of this backend and account is followed.
13
+ */
14
+ export type PendingTicket = {
15
+ ticketId: string;
16
+ databaseName: string;
17
+ apiEndpoint: string;
18
+ userId: string;
19
+ /** Pending results recorded for this ticket so far. */
20
+ attempts: number;
21
+ };
22
+ /** An earlier binding or request, kept readable when a new one replaced it. */
23
+ export type ArchivedEntry = {
24
+ archivedOn: string;
25
+ backend?: string;
26
+ database?: BoundDatabase;
27
+ pending?: PendingTicket;
28
+ };
29
+ export type ProjectFile = {
30
+ /** The api endpoint of the backend the database is on. It is compared with the session's backend, never sent to. */
31
+ backend?: string;
32
+ database?: BoundDatabase;
33
+ /** The agent `setup agent` set this project up for. A command still acts as the person unless it says which agent. */
34
+ agent?: string;
35
+ pending?: PendingTicket;
36
+ /** Tickets the host told provisioning to stop following: a lookup by name skips them. */
37
+ abandoned?: string[];
38
+ archived?: ArchivedEntry[];
39
+ };
40
+ /** The backend's own check on a database name, which is 3 to 63 characters long. */
41
+ export declare const DATABASE_NAME_PATTERN: RegExp;
42
+ export declare const isDatabaseName: (value: unknown) => value is string;
43
+ export declare const isUuid: (value: unknown) => value is string;
44
+ export declare const isEndpoint: (value: unknown) => value is string;
45
+ /**
46
+ * The binding of `cwd`: null when the directory has none, a failure when the file is not JSON or a value is not of its
47
+ * form. A cloned project's file is not the person's text, so a value that fails its check is never used, sent or shown.
48
+ */
49
+ export declare function readProjectFile(cwd: string): Promise<Result<ProjectFile | null>>;
50
+ /**
51
+ * Change the binding of `cwd` from its current content, read right before the write, so a change another tool or the
52
+ * person made while this call waited on the backend is kept. The write replaces the file in one step. The first write
53
+ * also tells git to leave the file out. A file that can't be read is left as it is, and the edit throws, as it does
54
+ * when .constructive links outside the project.
55
+ */
56
+ export declare function updateProjectFile(cwd: string, edit: (file: ProjectFile) => ProjectFile): Promise<void>;
57
+ export declare const recordPendingTicket: (file: ProjectFile, ticket: PendingTicket) => ProjectFile;
58
+ export declare const clearPendingTicket: (file: ProjectFile) => ProjectFile;
59
+ /** Keep the recorded request readable in the archive, and record no request. */
60
+ export declare const archivePendingTicket: (file: ProjectFile, archivedOn: string) => ProjectFile;
61
+ export declare const abandonedTickets: (file: ProjectFile) => Set<string>;
62
+ /** Add ticket ids to the abandoned list. */
63
+ export declare const recordAbandoned: (file: ProjectFile, ticketIds: readonly string[]) => ProjectFile;
64
+ /**
65
+ * Bind the directory to `database` on `backend`, with no recorded request. A binding it replaces is kept readable in
66
+ * the archive.
67
+ */
68
+ export declare function bindProject(file: ProjectFile, binding: {
69
+ database: BoundDatabase;
70
+ backend: string;
71
+ archivedOn: string;
72
+ }): ProjectFile;