@inkeep/agents-core 0.59.2 → 0.59.4
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/dist/auth/auth-schema.d.ts +86 -86
- package/dist/auth/auth-validation-schemas.d.ts +137 -137
- package/dist/auth/auth.js +2 -2
- package/dist/auth/permissions.d.ts +9 -9
- package/dist/client-exports.d.ts +2 -2
- package/dist/client-exports.js +2 -2
- package/dist/constants/signoz-queries.d.ts +30 -106
- package/dist/constants/signoz-queries.js +55 -108
- package/dist/data-access/manage/credentialReferences.js +1 -1
- package/dist/data-access/manage/dataComponents.js +1 -1
- package/dist/data-access/manage/skills.d.ts +1 -1
- package/dist/data-access/manage/subAgentRelations.d.ts +6 -6
- package/dist/data-access/manage/triggers.d.ts +2 -2
- package/dist/data-access/runtime/apiKeys.d.ts +4 -4
- package/dist/data-access/runtime/apps.d.ts +4 -4
- package/dist/data-access/runtime/conversations.d.ts +11 -11
- package/dist/data-access/runtime/scheduledTriggerInvocations.d.ts +3 -3
- package/dist/data-access/runtime/tasks.d.ts +4 -4
- package/dist/data-access/runtime/triggerInvocations.d.ts +1 -1
- package/dist/db/manage/manage-schema.d.ts +361 -361
- package/dist/db/runtime/runtime-schema.d.ts +14 -14
- package/dist/db/runtime/test-runtime-client.js +1 -1
- package/dist/dolt/advisory-lock.d.ts +7 -0
- package/dist/dolt/advisory-lock.js +18 -0
- package/dist/dolt/branches-api.d.ts +19 -9
- package/dist/dolt/branches-api.js +58 -29
- package/dist/dolt/index.d.ts +7 -4
- package/dist/dolt/index.js +7 -4
- package/dist/dolt/merge.d.ts +41 -5
- package/dist/dolt/merge.js +161 -24
- package/dist/dolt/pk-map.d.ts +6 -0
- package/dist/dolt/pk-map.js +27 -0
- package/dist/dolt/ref-middleware.d.ts +2 -1
- package/dist/dolt/ref-middleware.js +18 -4
- package/dist/dolt/resolve-conflicts.d.ts +10 -0
- package/dist/dolt/resolve-conflicts.js +100 -0
- package/dist/dolt/schema-sync.js +17 -17
- package/dist/index.d.ts +10 -7
- package/dist/index.js +11 -8
- package/dist/utils/error.d.ts +51 -51
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +3 -3
- package/dist/utils/schema-conversion.d.ts +27 -1
- package/dist/utils/schema-conversion.js +68 -1
- package/dist/utils/work-app-mcp.js +4 -3
- package/dist/validation/dolt-schemas.d.ts +96 -3
- package/dist/validation/dolt-schemas.js +54 -2
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +2 -2
- package/dist/validation/schemas.d.ts +1425 -1425
- package/package.json +2 -2
|
@@ -216,7 +216,7 @@ declare const conversations: drizzle_orm_pg_core1816.PgTableWithColumns<{
|
|
|
216
216
|
dataType: "json";
|
|
217
217
|
columnType: "PgJsonb";
|
|
218
218
|
data: {
|
|
219
|
-
type: "
|
|
219
|
+
type: "commit" | "tag" | "branch";
|
|
220
220
|
name: string;
|
|
221
221
|
hash: string;
|
|
222
222
|
};
|
|
@@ -232,7 +232,7 @@ declare const conversations: drizzle_orm_pg_core1816.PgTableWithColumns<{
|
|
|
232
232
|
generated: undefined;
|
|
233
233
|
}, {}, {
|
|
234
234
|
$type: {
|
|
235
|
-
type: "
|
|
235
|
+
type: "commit" | "tag" | "branch";
|
|
236
236
|
name: string;
|
|
237
237
|
hash: string;
|
|
238
238
|
};
|
|
@@ -413,7 +413,7 @@ declare const tasks: drizzle_orm_pg_core1816.PgTableWithColumns<{
|
|
|
413
413
|
dataType: "json";
|
|
414
414
|
columnType: "PgJsonb";
|
|
415
415
|
data: {
|
|
416
|
-
type: "
|
|
416
|
+
type: "commit" | "tag" | "branch";
|
|
417
417
|
name: string;
|
|
418
418
|
hash: string;
|
|
419
419
|
};
|
|
@@ -429,7 +429,7 @@ declare const tasks: drizzle_orm_pg_core1816.PgTableWithColumns<{
|
|
|
429
429
|
generated: undefined;
|
|
430
430
|
}, {}, {
|
|
431
431
|
$type: {
|
|
432
|
-
type: "
|
|
432
|
+
type: "commit" | "tag" | "branch";
|
|
433
433
|
name: string;
|
|
434
434
|
hash: string;
|
|
435
435
|
};
|
|
@@ -1113,7 +1113,7 @@ declare const triggerInvocations: drizzle_orm_pg_core1816.PgTableWithColumns<{
|
|
|
1113
1113
|
dataType: "json";
|
|
1114
1114
|
columnType: "PgJsonb";
|
|
1115
1115
|
data: {
|
|
1116
|
-
type: "
|
|
1116
|
+
type: "commit" | "tag" | "branch";
|
|
1117
1117
|
name: string;
|
|
1118
1118
|
hash: string;
|
|
1119
1119
|
};
|
|
@@ -1129,7 +1129,7 @@ declare const triggerInvocations: drizzle_orm_pg_core1816.PgTableWithColumns<{
|
|
|
1129
1129
|
generated: undefined;
|
|
1130
1130
|
}, {}, {
|
|
1131
1131
|
$type: {
|
|
1132
|
-
type: "
|
|
1132
|
+
type: "commit" | "tag" | "branch";
|
|
1133
1133
|
name: string;
|
|
1134
1134
|
hash: string;
|
|
1135
1135
|
};
|
|
@@ -2137,7 +2137,7 @@ declare const scheduledTriggerInvocations: drizzle_orm_pg_core1816.PgTableWithCo
|
|
|
2137
2137
|
dataType: "json";
|
|
2138
2138
|
columnType: "PgJsonb";
|
|
2139
2139
|
data: {
|
|
2140
|
-
type: "
|
|
2140
|
+
type: "commit" | "tag" | "branch";
|
|
2141
2141
|
name: string;
|
|
2142
2142
|
hash: string;
|
|
2143
2143
|
};
|
|
@@ -2153,7 +2153,7 @@ declare const scheduledTriggerInvocations: drizzle_orm_pg_core1816.PgTableWithCo
|
|
|
2153
2153
|
generated: undefined;
|
|
2154
2154
|
}, {}, {
|
|
2155
2155
|
$type: {
|
|
2156
|
-
type: "
|
|
2156
|
+
type: "commit" | "tag" | "branch";
|
|
2157
2157
|
name: string;
|
|
2158
2158
|
hash: string;
|
|
2159
2159
|
};
|
|
@@ -3398,7 +3398,7 @@ declare const contextCache: drizzle_orm_pg_core1816.PgTableWithColumns<{
|
|
|
3398
3398
|
dataType: "json";
|
|
3399
3399
|
columnType: "PgJsonb";
|
|
3400
3400
|
data: {
|
|
3401
|
-
type: "
|
|
3401
|
+
type: "commit" | "tag" | "branch";
|
|
3402
3402
|
name: string;
|
|
3403
3403
|
hash: string;
|
|
3404
3404
|
};
|
|
@@ -3414,7 +3414,7 @@ declare const contextCache: drizzle_orm_pg_core1816.PgTableWithColumns<{
|
|
|
3414
3414
|
generated: undefined;
|
|
3415
3415
|
}, {}, {
|
|
3416
3416
|
$type: {
|
|
3417
|
-
type: "
|
|
3417
|
+
type: "commit" | "tag" | "branch";
|
|
3418
3418
|
name: string;
|
|
3419
3419
|
hash: string;
|
|
3420
3420
|
};
|
|
@@ -3661,7 +3661,7 @@ declare const datasetRun: drizzle_orm_pg_core1816.PgTableWithColumns<{
|
|
|
3661
3661
|
dataType: "json";
|
|
3662
3662
|
columnType: "PgJsonb";
|
|
3663
3663
|
data: {
|
|
3664
|
-
type: "
|
|
3664
|
+
type: "commit" | "tag" | "branch";
|
|
3665
3665
|
name: string;
|
|
3666
3666
|
hash: string;
|
|
3667
3667
|
};
|
|
@@ -3677,7 +3677,7 @@ declare const datasetRun: drizzle_orm_pg_core1816.PgTableWithColumns<{
|
|
|
3677
3677
|
generated: undefined;
|
|
3678
3678
|
}, {}, {
|
|
3679
3679
|
$type: {
|
|
3680
|
-
type: "
|
|
3680
|
+
type: "commit" | "tag" | "branch";
|
|
3681
3681
|
name: string;
|
|
3682
3682
|
hash: string;
|
|
3683
3683
|
};
|
|
@@ -3991,7 +3991,7 @@ declare const evaluationRun: drizzle_orm_pg_core1816.PgTableWithColumns<{
|
|
|
3991
3991
|
dataType: "json";
|
|
3992
3992
|
columnType: "PgJsonb";
|
|
3993
3993
|
data: {
|
|
3994
|
-
type: "
|
|
3994
|
+
type: "commit" | "tag" | "branch";
|
|
3995
3995
|
name: string;
|
|
3996
3996
|
hash: string;
|
|
3997
3997
|
};
|
|
@@ -4007,7 +4007,7 @@ declare const evaluationRun: drizzle_orm_pg_core1816.PgTableWithColumns<{
|
|
|
4007
4007
|
generated: undefined;
|
|
4008
4008
|
}, {}, {
|
|
4009
4009
|
$type: {
|
|
4010
|
-
type: "
|
|
4010
|
+
type: "commit" | "tag" | "branch";
|
|
4011
4011
|
name: string;
|
|
4012
4012
|
hash: string;
|
|
4013
4013
|
};
|
|
@@ -57,7 +57,7 @@ async function closeTestRuntimeDatabase(db) {
|
|
|
57
57
|
* This is a helper for tests that need organization records before creating projects/agents
|
|
58
58
|
*/
|
|
59
59
|
async function createTestOrganization(db, tenantId) {
|
|
60
|
-
const slug = tenantId.replace(/^test-tenant-/, "")
|
|
60
|
+
const slug = tenantId.replace(/^test-tenant-/, "");
|
|
61
61
|
await db.insert(organization).values({
|
|
62
62
|
id: tenantId,
|
|
63
63
|
name: `Test Organization ${tenantId}`,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AgentsManageDatabaseClient } from "../db/manage/manage-client.js";
|
|
2
|
+
|
|
3
|
+
//#region src/dolt/advisory-lock.d.ts
|
|
4
|
+
declare const tryAdvisoryLock: (db: AgentsManageDatabaseClient) => (prefix: string, identifier: string) => Promise<boolean>;
|
|
5
|
+
declare const releaseAdvisoryLock: (db: AgentsManageDatabaseClient) => (prefix: string, identifier: string) => Promise<void>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { releaseAdvisoryLock, tryAdvisoryLock };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { sql } from "drizzle-orm";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
|
|
4
|
+
//#region src/dolt/advisory-lock.ts
|
|
5
|
+
function computeLockKey(prefix, identifier) {
|
|
6
|
+
return createHash("sha256").update(`${prefix}${identifier}`).digest().readBigInt64BE(0);
|
|
7
|
+
}
|
|
8
|
+
const tryAdvisoryLock = (db) => async (prefix, identifier) => {
|
|
9
|
+
const key = computeLockKey(prefix, identifier);
|
|
10
|
+
return (await db.execute(sql`SELECT pg_try_advisory_lock(CAST(${key} AS bigint)) as acquired`)).rows[0]?.acquired === true;
|
|
11
|
+
};
|
|
12
|
+
const releaseAdvisoryLock = (db) => async (prefix, identifier) => {
|
|
13
|
+
const key = computeLockKey(prefix, identifier);
|
|
14
|
+
await db.execute(sql`SELECT pg_advisory_unlock(CAST(${key} AS bigint))`);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { releaseAdvisoryLock, tryAdvisoryLock };
|
|
@@ -5,6 +5,9 @@ import { AgentsManageDatabaseClient } from "../db/manage/manage-client.js";
|
|
|
5
5
|
|
|
6
6
|
//#region src/dolt/branches-api.d.ts
|
|
7
7
|
declare const MAIN_BRANCH_SUFFIX = "main";
|
|
8
|
+
declare class invalidBranchParamsError extends Error {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
8
11
|
/**
|
|
9
12
|
* Get the tenant-scoped main branch name
|
|
10
13
|
*/
|
|
@@ -13,24 +16,23 @@ declare const getTenantMainBranch: (tenantId: string) => string;
|
|
|
13
16
|
* Check if a branch name (without tenant/project prefix) is a protected branch
|
|
14
17
|
*/
|
|
15
18
|
declare const isProtectedBranchName: (branchName: string) => boolean;
|
|
19
|
+
declare const getTempBranchSuffix: (prefix: string) => string;
|
|
20
|
+
declare const isTempBranchName: (fullName: string) => boolean;
|
|
16
21
|
type CreateBranchParams = {
|
|
17
22
|
tenantId: string;
|
|
18
23
|
projectId: string;
|
|
19
24
|
name: string;
|
|
20
|
-
/** Branch to create from. Defaults to tenant main branch. */
|
|
21
|
-
|
|
25
|
+
/** Branch name to create from. Defaults to tenant main branch. */
|
|
26
|
+
fromBranch?: string;
|
|
27
|
+
/** Commit hash to create from. Mutually exclusive with fromBranch. */
|
|
28
|
+
fromCommit?: string;
|
|
22
29
|
/**
|
|
23
30
|
* Whether to sync schema on the source branch before creating.
|
|
24
31
|
* This ensures the new branch starts with the latest schema from main.
|
|
25
|
-
* Default: true
|
|
32
|
+
* Default: true. Ignored when fromCommit is set.
|
|
26
33
|
*/
|
|
27
34
|
syncSchemaOnSource?: boolean;
|
|
28
35
|
};
|
|
29
|
-
type DeleteBranchParams = {
|
|
30
|
-
tenantId: string;
|
|
31
|
-
projectId: string;
|
|
32
|
-
name: string;
|
|
33
|
-
};
|
|
34
36
|
type GetBranchParams = {
|
|
35
37
|
tenantId: string;
|
|
36
38
|
projectId: string;
|
|
@@ -79,6 +81,7 @@ type CheckoutBranchResult = {
|
|
|
79
81
|
* @returns Function that takes checkout params and returns checkout result
|
|
80
82
|
*/
|
|
81
83
|
declare const checkoutBranch: (db: AgentsManageDatabaseClient) => (params: CheckoutBranchParams) => Promise<CheckoutBranchResult>;
|
|
84
|
+
declare const syncSchemaOnBranch: (db: AgentsManageDatabaseClient) => (branchName: string) => Promise<void>;
|
|
82
85
|
/**
|
|
83
86
|
* Create a new branch with optional schema synchronization.
|
|
84
87
|
*
|
|
@@ -88,8 +91,15 @@ declare const checkoutBranch: (db: AgentsManageDatabaseClient) => (params: Check
|
|
|
88
91
|
*
|
|
89
92
|
* By syncing schema on the source branch first, we ensure the new branch
|
|
90
93
|
* starts with the latest schema, avoiding schema conflicts later.
|
|
94
|
+
* If you want to create a branch from a commit hash, use the fromCommit parameter.
|
|
91
95
|
*/
|
|
92
96
|
declare const createBranch: (db: AgentsManageDatabaseClient) => (params: CreateBranchParams) => Promise<BranchInfo>;
|
|
97
|
+
type DeleteBranchParams = {
|
|
98
|
+
tenantId: string;
|
|
99
|
+
projectId: string;
|
|
100
|
+
branchName: string;
|
|
101
|
+
force?: boolean;
|
|
102
|
+
};
|
|
93
103
|
/**
|
|
94
104
|
* Delete a branch
|
|
95
105
|
*/
|
|
@@ -106,4 +116,4 @@ declare const getBranch: (db: AgentsManageDatabaseClient) => (params: GetBranchP
|
|
|
106
116
|
declare const listBranches: (db: AgentsManageDatabaseClient) => (params: ProjectScopeConfig) => Promise<BranchInfo[]>;
|
|
107
117
|
declare const listBranchesForAgent: (db: AgentsManageDatabaseClient) => (params: AgentScopeConfig) => Promise<BranchInfo[]>;
|
|
108
118
|
//#endregion
|
|
109
|
-
export { CheckoutBranchParams, CheckoutBranchResult, CreateBranchParams, DeleteBranchParams, GetBranchParams, MAIN_BRANCH_SUFFIX, checkoutBranch, createBranch, deleteBranch, getBranch, getTenantMainBranch, isProtectedBranchName, listBranches, listBranchesForAgent };
|
|
119
|
+
export { CheckoutBranchParams, CheckoutBranchResult, CreateBranchParams, DeleteBranchParams, GetBranchParams, MAIN_BRANCH_SUFFIX, checkoutBranch, createBranch, deleteBranch, getBranch, getTempBranchSuffix, getTenantMainBranch, invalidBranchParamsError, isProtectedBranchName, isTempBranchName, listBranches, listBranchesForAgent, syncSchemaOnBranch };
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import { doltHashOf } from "./commit.js";
|
|
1
2
|
import { SCHEMA_SOURCE_BRANCH, ensureSchemaSync, getSchemaDiff, syncSchemaFromMain } from "./schema-sync.js";
|
|
2
3
|
import { doltBranch, doltCheckout, doltDeleteBranch, doltGetBranchNamespace, doltListBranches } from "./branch.js";
|
|
3
4
|
import { sql } from "drizzle-orm";
|
|
4
5
|
|
|
5
6
|
//#region src/dolt/branches-api.ts
|
|
6
7
|
const MAIN_BRANCH_SUFFIX = "main";
|
|
8
|
+
var invalidBranchParamsError = class extends Error {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "invalidBranchParamsError";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
7
14
|
/**
|
|
8
15
|
* Get the tenant-scoped main branch name
|
|
9
16
|
*/
|
|
@@ -14,6 +21,12 @@ const getTenantMainBranch = (tenantId) => `${tenantId}_${MAIN_BRANCH_SUFFIX}`;
|
|
|
14
21
|
const isProtectedBranchName = (branchName) => {
|
|
15
22
|
return branchName === MAIN_BRANCH_SUFFIX;
|
|
16
23
|
};
|
|
24
|
+
const getTempBranchSuffix = (prefix) => {
|
|
25
|
+
return `temp-${prefix}_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`;
|
|
26
|
+
};
|
|
27
|
+
const isTempBranchName = (fullName) => {
|
|
28
|
+
return /temp-[a-z-]+_\d+_[a-z0-9]+$/.test(fullName);
|
|
29
|
+
};
|
|
17
30
|
/**
|
|
18
31
|
* Checkout a branch with optional schema synchronization from main.
|
|
19
32
|
*
|
|
@@ -49,6 +62,13 @@ const checkoutBranch = (db) => async (params) => {
|
|
|
49
62
|
}
|
|
50
63
|
};
|
|
51
64
|
};
|
|
65
|
+
const syncSchemaOnBranch = (db) => async (branchName) => {
|
|
66
|
+
if ((await getSchemaDiff(db)(branchName)).length > 0) {
|
|
67
|
+
await doltCheckout(db)({ branch: branchName });
|
|
68
|
+
const syncResult = await syncSchemaFromMain(db)({ autoCommitPending: true });
|
|
69
|
+
if (syncResult.error && !syncResult.synced) throw new Error(`Failed to sync schema on source branch '${branchName}': ${syncResult.error}`);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
52
72
|
/**
|
|
53
73
|
* Create a new branch with optional schema synchronization.
|
|
54
74
|
*
|
|
@@ -58,55 +78,64 @@ const checkoutBranch = (db) => async (params) => {
|
|
|
58
78
|
*
|
|
59
79
|
* By syncing schema on the source branch first, we ensure the new branch
|
|
60
80
|
* starts with the latest schema, avoiding schema conflicts later.
|
|
81
|
+
* If you want to create a branch from a commit hash, use the fromCommit parameter.
|
|
61
82
|
*/
|
|
62
83
|
const createBranch = (db) => async (params) => {
|
|
63
|
-
const { tenantId, projectId, name,
|
|
64
|
-
if (
|
|
84
|
+
const { tenantId, projectId, name, fromBranch, fromCommit, syncSchemaOnSource = true } = params;
|
|
85
|
+
if (fromBranch && fromCommit) throw new invalidBranchParamsError("Cannot specify both fromBranch and fromCommit");
|
|
86
|
+
if (!name || name.trim() === "") throw new invalidBranchParamsError("Branch name cannot be empty");
|
|
65
87
|
const fullName = doltGetBranchNamespace({
|
|
66
88
|
tenantId,
|
|
67
89
|
projectId,
|
|
68
90
|
branchName: name
|
|
69
91
|
})();
|
|
70
|
-
if ((await doltListBranches(db)()).some((b) => b.name === fullName)) throw new
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
else
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
92
|
+
if ((await doltListBranches(db)()).some((b) => b.name === fullName)) throw new invalidBranchParamsError(`Branch '${name}' already exists`);
|
|
93
|
+
if (fromCommit) {
|
|
94
|
+
await doltBranch(db)({
|
|
95
|
+
name: fullName,
|
|
96
|
+
startPoint: fromCommit
|
|
97
|
+
});
|
|
98
|
+
if (syncSchemaOnSource) await syncSchemaOnBranch(db)(fullName);
|
|
99
|
+
} else {
|
|
100
|
+
let fromFullBranchName;
|
|
101
|
+
if (fromBranch) fromFullBranchName = doltGetBranchNamespace({
|
|
102
|
+
tenantId,
|
|
103
|
+
projectId,
|
|
104
|
+
branchName: fromBranch
|
|
105
|
+
})();
|
|
106
|
+
else fromFullBranchName = doltGetBranchNamespace({
|
|
107
|
+
tenantId,
|
|
108
|
+
projectId,
|
|
109
|
+
branchName: MAIN_BRANCH_SUFFIX
|
|
110
|
+
})();
|
|
111
|
+
if (syncSchemaOnSource && fromFullBranchName !== SCHEMA_SOURCE_BRANCH) await syncSchemaOnBranch(db)(fromFullBranchName);
|
|
112
|
+
await doltBranch(db)({
|
|
113
|
+
name: fullName,
|
|
114
|
+
startPoint: fromFullBranchName
|
|
115
|
+
});
|
|
84
116
|
}
|
|
85
|
-
await doltBranch(db)({
|
|
86
|
-
name: fullName,
|
|
87
|
-
startPoint: fromFullBranchName
|
|
88
|
-
});
|
|
89
|
-
const newBranch = (await doltListBranches(db)()).find((b) => b.name === fullName);
|
|
90
|
-
if (!newBranch) throw new Error("Failed to create branch");
|
|
91
117
|
return {
|
|
92
118
|
baseName: name,
|
|
93
119
|
fullName,
|
|
94
|
-
hash:
|
|
120
|
+
hash: await doltHashOf(db)({ revision: fullName })
|
|
95
121
|
};
|
|
96
122
|
};
|
|
97
123
|
/**
|
|
98
124
|
* Delete a branch
|
|
99
125
|
*/
|
|
100
126
|
const deleteBranch = (db) => async (params) => {
|
|
101
|
-
const { tenantId, projectId,
|
|
102
|
-
if (isProtectedBranchName(
|
|
127
|
+
const { tenantId, projectId, branchName, force } = params;
|
|
128
|
+
if (isProtectedBranchName(branchName)) throw new invalidBranchParamsError(`Cannot delete protected branch '${branchName}'`);
|
|
103
129
|
const fullName = doltGetBranchNamespace({
|
|
104
130
|
tenantId,
|
|
105
131
|
projectId,
|
|
106
|
-
branchName
|
|
132
|
+
branchName
|
|
107
133
|
})();
|
|
108
|
-
if (!(await doltListBranches(db)()).some((b) => b.name === fullName)) throw new
|
|
109
|
-
await doltDeleteBranch(db)({
|
|
134
|
+
if (!(await doltListBranches(db)()).some((b) => b.name === fullName)) throw new invalidBranchParamsError(`Branch '${branchName}' not found`);
|
|
135
|
+
await doltDeleteBranch(db)({
|
|
136
|
+
name: fullName,
|
|
137
|
+
force
|
|
138
|
+
});
|
|
110
139
|
};
|
|
111
140
|
/**
|
|
112
141
|
* Get a single branch
|
|
@@ -159,4 +188,4 @@ const listBranchesForAgent = (db) => async (params) => {
|
|
|
159
188
|
};
|
|
160
189
|
|
|
161
190
|
//#endregion
|
|
162
|
-
export { MAIN_BRANCH_SUFFIX, checkoutBranch, createBranch, deleteBranch, getBranch, getTenantMainBranch, isProtectedBranchName, listBranches, listBranchesForAgent };
|
|
191
|
+
export { MAIN_BRANCH_SUFFIX, checkoutBranch, createBranch, deleteBranch, getBranch, getTempBranchSuffix, getTenantMainBranch, invalidBranchParamsError, isProtectedBranchName, isTempBranchName, listBranches, listBranchesForAgent, syncSchemaOnBranch };
|
package/dist/dolt/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { releaseAdvisoryLock, tryAdvisoryLock } from "./advisory-lock.js";
|
|
1
2
|
import { branchScopes, doltActiveBranch, doltBranch, doltBranchExists, doltCheckout, doltDeleteBranch, doltGetBranchNamespace, doltListBranches, doltRenameBranch, ensureBranchExists } from "./branch.js";
|
|
2
|
-
import { CheckoutBranchParams, CheckoutBranchResult, CreateBranchParams, DeleteBranchParams, GetBranchParams, MAIN_BRANCH_SUFFIX, checkoutBranch, createBranch, deleteBranch, getBranch, getTenantMainBranch, isProtectedBranchName, listBranches, listBranchesForAgent } from "./branches-api.js";
|
|
3
|
+
import { CheckoutBranchParams, CheckoutBranchResult, CreateBranchParams, DeleteBranchParams, GetBranchParams, MAIN_BRANCH_SUFFIX, checkoutBranch, createBranch, deleteBranch, getBranch, getTempBranchSuffix, getTenantMainBranch, invalidBranchParamsError, isProtectedBranchName, isTempBranchName, listBranches, listBranchesForAgent, syncSchemaOnBranch } from "./branches-api.js";
|
|
3
4
|
import { doltAdd, doltAddAndCommit, doltCommit, doltDeleteTag, doltHashOf, doltListTags, doltLog, doltReset, doltStatus, doltTag } from "./commit.js";
|
|
4
5
|
import { doltDiff, doltDiffSummary } from "./diff.js";
|
|
5
|
-
import { doltAbortMerge, doltConflicts, doltMerge, doltMergeStatus, doltResolveConflicts, doltSchemaConflicts, doltTableConflicts } from "./merge.js";
|
|
6
|
+
import { MergeConflictError, doltAbortMerge, doltConflicts, doltMerge, doltMergeStatus, doltPreviewMergeConflicts, doltPreviewMergeConflictsSummary, doltResolveConflicts, doltSchemaConflicts, doltTableConflicts } from "./merge.js";
|
|
7
|
+
import { PkMap, isValidManageTable, managePkMap } from "./pk-map.js";
|
|
6
8
|
import { RefType, checkoutRef, getCurrentBranchOrCommit, getProjectMainResolvedRef, getProjectScopedRef, getTenantScopedRef, isRefWritable, isValidCommitHash, resolveProjectMainRefs, resolveRef } from "./ref-helpers.js";
|
|
7
|
-
import { RefContext, RefMiddlewareOptions, createRefMiddleware, createWriteProtectionMiddleware, refMiddlewareFactory, writeProtectionMiddlewareFactory } from "./ref-middleware.js";
|
|
9
|
+
import { RefContext, RefMiddlewareOptions, createRefMiddleware, createWriteProtectionMiddleware, isMergeRoute, refMiddlewareFactory, writeProtectionMiddlewareFactory } from "./ref-middleware.js";
|
|
8
10
|
import { NestedRefScopeError, WithRefOptions, getCurrentRefScope, getRefScopedDb, isInRefScope, withRef } from "./ref-scope.js";
|
|
11
|
+
import { ResolutionValidationError, applyResolutions } from "./resolve-conflicts.js";
|
|
9
12
|
import { EnsureSchemaSyncOptions, SCHEMA_SOURCE_BRANCH, SchemaDiff, SchemaSyncOptions, SchemaSyncResult, areBranchesSchemaCompatible, ensureSchemaSync, formatSchemaDiffSummary, getActiveBranch, getSchemaDiff, hasSchemaDifferences, hasUncommittedChanges, isLocalhostUrl, syncSchemaFromMain } from "./schema-sync.js";
|
|
10
|
-
export { CheckoutBranchParams, CheckoutBranchResult, CreateBranchParams, DeleteBranchParams, EnsureSchemaSyncOptions, GetBranchParams, MAIN_BRANCH_SUFFIX, NestedRefScopeError, RefContext, RefMiddlewareOptions, RefType, SCHEMA_SOURCE_BRANCH, SchemaDiff, SchemaSyncOptions, SchemaSyncResult, WithRefOptions, areBranchesSchemaCompatible, branchScopes, checkoutBranch, checkoutRef, createBranch, createRefMiddleware, createWriteProtectionMiddleware, deleteBranch, doltAbortMerge, doltActiveBranch, doltAdd, doltAddAndCommit, doltBranch, doltBranchExists, doltCheckout, doltCommit, doltConflicts, doltDeleteBranch, doltDeleteTag, doltDiff, doltDiffSummary, doltGetBranchNamespace, doltHashOf, doltListBranches, doltListTags, doltLog, doltMerge, doltMergeStatus, doltRenameBranch, doltReset, doltResolveConflicts, doltSchemaConflicts, doltStatus, doltTableConflicts, doltTag, ensureBranchExists, ensureSchemaSync, formatSchemaDiffSummary, getActiveBranch, getBranch, getCurrentBranchOrCommit, getCurrentRefScope, getProjectMainResolvedRef, getProjectScopedRef, getRefScopedDb, getSchemaDiff, getTenantMainBranch, getTenantScopedRef, hasSchemaDifferences, hasUncommittedChanges, isInRefScope, isLocalhostUrl, isProtectedBranchName, isRefWritable, isValidCommitHash, listBranches, listBranchesForAgent, refMiddlewareFactory, resolveProjectMainRefs, resolveRef, syncSchemaFromMain, withRef, writeProtectionMiddlewareFactory };
|
|
13
|
+
export { CheckoutBranchParams, CheckoutBranchResult, CreateBranchParams, DeleteBranchParams, EnsureSchemaSyncOptions, GetBranchParams, MAIN_BRANCH_SUFFIX, MergeConflictError, NestedRefScopeError, PkMap, RefContext, RefMiddlewareOptions, RefType, ResolutionValidationError, SCHEMA_SOURCE_BRANCH, SchemaDiff, SchemaSyncOptions, SchemaSyncResult, WithRefOptions, applyResolutions, areBranchesSchemaCompatible, branchScopes, checkoutBranch, checkoutRef, createBranch, createRefMiddleware, createWriteProtectionMiddleware, deleteBranch, doltAbortMerge, doltActiveBranch, doltAdd, doltAddAndCommit, doltBranch, doltBranchExists, doltCheckout, doltCommit, doltConflicts, doltDeleteBranch, doltDeleteTag, doltDiff, doltDiffSummary, doltGetBranchNamespace, doltHashOf, doltListBranches, doltListTags, doltLog, doltMerge, doltMergeStatus, doltPreviewMergeConflicts, doltPreviewMergeConflictsSummary, doltRenameBranch, doltReset, doltResolveConflicts, doltSchemaConflicts, doltStatus, doltTableConflicts, doltTag, ensureBranchExists, ensureSchemaSync, formatSchemaDiffSummary, getActiveBranch, getBranch, getCurrentBranchOrCommit, getCurrentRefScope, getProjectMainResolvedRef, getProjectScopedRef, getRefScopedDb, getSchemaDiff, getTempBranchSuffix, getTenantMainBranch, getTenantScopedRef, hasSchemaDifferences, hasUncommittedChanges, invalidBranchParamsError, isInRefScope, isLocalhostUrl, isMergeRoute, isProtectedBranchName, isRefWritable, isTempBranchName, isValidCommitHash, isValidManageTable, listBranches, listBranchesForAgent, managePkMap, refMiddlewareFactory, releaseAdvisoryLock, resolveProjectMainRefs, resolveRef, syncSchemaFromMain, syncSchemaOnBranch, tryAdvisoryLock, withRef, writeProtectionMiddlewareFactory };
|
package/dist/dolt/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { doltAdd, doltAddAndCommit, doltCommit, doltDeleteTag, doltHashOf, doltListTags, doltLog, doltReset, doltStatus, doltTag } from "./commit.js";
|
|
2
|
-
import {
|
|
2
|
+
import { isValidManageTable, managePkMap } from "./pk-map.js";
|
|
3
|
+
import { ResolutionValidationError, applyResolutions } from "./resolve-conflicts.js";
|
|
4
|
+
import { MergeConflictError, doltAbortMerge, doltConflicts, doltMerge, doltMergeStatus, doltPreviewMergeConflicts, doltPreviewMergeConflictsSummary, doltResolveConflicts, doltSchemaConflicts, doltTableConflicts } from "./merge.js";
|
|
3
5
|
import { SCHEMA_SOURCE_BRANCH, areBranchesSchemaCompatible, ensureSchemaSync, formatSchemaDiffSummary, getActiveBranch, getSchemaDiff, hasSchemaDifferences, hasUncommittedChanges, isLocalhostUrl, syncSchemaFromMain } from "./schema-sync.js";
|
|
4
|
-
import { MAIN_BRANCH_SUFFIX, checkoutBranch, createBranch, deleteBranch, getBranch, getTenantMainBranch, isProtectedBranchName, listBranches, listBranchesForAgent } from "./branches-api.js";
|
|
6
|
+
import { MAIN_BRANCH_SUFFIX, checkoutBranch, createBranch, deleteBranch, getBranch, getTempBranchSuffix, getTenantMainBranch, invalidBranchParamsError, isProtectedBranchName, isTempBranchName, listBranches, listBranchesForAgent, syncSchemaOnBranch } from "./branches-api.js";
|
|
5
7
|
import { checkoutRef, getCurrentBranchOrCommit, getProjectMainResolvedRef, getProjectScopedRef, getTenantScopedRef, isRefWritable, isValidCommitHash, resolveProjectMainRefs, resolveRef } from "./ref-helpers.js";
|
|
6
8
|
import { doltActiveBranch, doltBranch, doltBranchExists, doltCheckout, doltDeleteBranch, doltGetBranchNamespace, doltListBranches, doltRenameBranch, ensureBranchExists } from "./branch.js";
|
|
9
|
+
import { releaseAdvisoryLock, tryAdvisoryLock } from "./advisory-lock.js";
|
|
7
10
|
import { doltDiff, doltDiffSummary } from "./diff.js";
|
|
8
|
-
import { createRefMiddleware, createWriteProtectionMiddleware, refMiddlewareFactory, writeProtectionMiddlewareFactory } from "./ref-middleware.js";
|
|
11
|
+
import { createRefMiddleware, createWriteProtectionMiddleware, isMergeRoute, refMiddlewareFactory, writeProtectionMiddlewareFactory } from "./ref-middleware.js";
|
|
9
12
|
import { NestedRefScopeError, getCurrentRefScope, getRefScopedDb, isInRefScope, withRef } from "./ref-scope.js";
|
|
10
13
|
|
|
11
|
-
export { MAIN_BRANCH_SUFFIX, NestedRefScopeError, SCHEMA_SOURCE_BRANCH, areBranchesSchemaCompatible, checkoutBranch, checkoutRef, createBranch, createRefMiddleware, createWriteProtectionMiddleware, deleteBranch, doltAbortMerge, doltActiveBranch, doltAdd, doltAddAndCommit, doltBranch, doltBranchExists, doltCheckout, doltCommit, doltConflicts, doltDeleteBranch, doltDeleteTag, doltDiff, doltDiffSummary, doltGetBranchNamespace, doltHashOf, doltListBranches, doltListTags, doltLog, doltMerge, doltMergeStatus, doltRenameBranch, doltReset, doltResolveConflicts, doltSchemaConflicts, doltStatus, doltTableConflicts, doltTag, ensureBranchExists, ensureSchemaSync, formatSchemaDiffSummary, getActiveBranch, getBranch, getCurrentBranchOrCommit, getCurrentRefScope, getProjectMainResolvedRef, getProjectScopedRef, getRefScopedDb, getSchemaDiff, getTenantMainBranch, getTenantScopedRef, hasSchemaDifferences, hasUncommittedChanges, isInRefScope, isLocalhostUrl, isProtectedBranchName, isRefWritable, isValidCommitHash, listBranches, listBranchesForAgent, refMiddlewareFactory, resolveProjectMainRefs, resolveRef, syncSchemaFromMain, withRef, writeProtectionMiddlewareFactory };
|
|
14
|
+
export { MAIN_BRANCH_SUFFIX, MergeConflictError, NestedRefScopeError, ResolutionValidationError, SCHEMA_SOURCE_BRANCH, applyResolutions, areBranchesSchemaCompatible, checkoutBranch, checkoutRef, createBranch, createRefMiddleware, createWriteProtectionMiddleware, deleteBranch, doltAbortMerge, doltActiveBranch, doltAdd, doltAddAndCommit, doltBranch, doltBranchExists, doltCheckout, doltCommit, doltConflicts, doltDeleteBranch, doltDeleteTag, doltDiff, doltDiffSummary, doltGetBranchNamespace, doltHashOf, doltListBranches, doltListTags, doltLog, doltMerge, doltMergeStatus, doltPreviewMergeConflicts, doltPreviewMergeConflictsSummary, doltRenameBranch, doltReset, doltResolveConflicts, doltSchemaConflicts, doltStatus, doltTableConflicts, doltTag, ensureBranchExists, ensureSchemaSync, formatSchemaDiffSummary, getActiveBranch, getBranch, getCurrentBranchOrCommit, getCurrentRefScope, getProjectMainResolvedRef, getProjectScopedRef, getRefScopedDb, getSchemaDiff, getTempBranchSuffix, getTenantMainBranch, getTenantScopedRef, hasSchemaDifferences, hasUncommittedChanges, invalidBranchParamsError, isInRefScope, isLocalhostUrl, isMergeRoute, isProtectedBranchName, isRefWritable, isTempBranchName, isValidCommitHash, isValidManageTable, listBranches, listBranchesForAgent, managePkMap, refMiddlewareFactory, releaseAdvisoryLock, resolveProjectMainRefs, resolveRef, syncSchemaFromMain, syncSchemaOnBranch, tryAdvisoryLock, withRef, writeProtectionMiddlewareFactory };
|
package/dist/dolt/merge.d.ts
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
+
import { ConflictResolution } from "../validation/dolt-schemas.js";
|
|
1
2
|
import { AgentsManageDatabaseClient } from "../db/manage/manage-client.js";
|
|
2
3
|
|
|
3
4
|
//#region src/dolt/merge.d.ts
|
|
4
|
-
|
|
5
|
+
declare class MergeConflictError extends Error {
|
|
6
|
+
readonly conflictCount: number;
|
|
7
|
+
readonly fromBranch: string;
|
|
8
|
+
readonly toBranch: string;
|
|
9
|
+
constructor(message: string, conflictCount: number, fromBranch: string, toBranch: string);
|
|
10
|
+
}
|
|
5
11
|
/**
|
|
6
|
-
* Merge
|
|
7
|
-
*
|
|
12
|
+
* Merge a branch into the currently checked out branch.
|
|
13
|
+
*
|
|
14
|
+
* Runs inside an explicit transaction so that conflicts and
|
|
15
|
+
* constraint-violations are surfaced to the caller instead of being
|
|
16
|
+
* auto-rolled-back by Dolt's AUTOCOMMIT mode.
|
|
17
|
+
*
|
|
18
|
+
* If conflicts arise and `resolutions` are provided, they are applied
|
|
19
|
+
* and the merge is committed. If conflicts arise without resolutions
|
|
20
|
+
* (or with insufficient resolutions), the transaction is rolled back
|
|
21
|
+
* and a `MergeConflictError` is thrown.
|
|
8
22
|
*/
|
|
9
23
|
declare const doltMerge: (db: AgentsManageDatabaseClient) => (params: {
|
|
10
24
|
fromBranch: string;
|
|
@@ -15,8 +29,9 @@ declare const doltMerge: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
15
29
|
name: string;
|
|
16
30
|
email: string;
|
|
17
31
|
};
|
|
32
|
+
resolutions?: ConflictResolution[];
|
|
18
33
|
}) => Promise<{
|
|
19
|
-
status: "success"
|
|
34
|
+
status: "success";
|
|
20
35
|
from: string;
|
|
21
36
|
to: string;
|
|
22
37
|
toHead?: string;
|
|
@@ -52,6 +67,27 @@ declare const doltTableConflicts: (db: AgentsManageDatabaseClient) => (params: {
|
|
|
52
67
|
* Get schema conflicts
|
|
53
68
|
*/
|
|
54
69
|
declare const doltSchemaConflicts: (db: AgentsManageDatabaseClient) => () => Promise<any[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Preview merge conflicts without modifying the database (dry-run).
|
|
72
|
+
* Returns a summary of which tables have conflicts.
|
|
73
|
+
*/
|
|
74
|
+
declare const doltPreviewMergeConflictsSummary: (db: AgentsManageDatabaseClient) => (params: {
|
|
75
|
+
baseBranch: string;
|
|
76
|
+
mergeBranch: string;
|
|
77
|
+
}) => Promise<{
|
|
78
|
+
table: string;
|
|
79
|
+
numDataConflicts: number;
|
|
80
|
+
numSchemaConflicts: number;
|
|
81
|
+
}[]>;
|
|
82
|
+
/**
|
|
83
|
+
* Preview detailed merge conflicts for a specific table without modifying the database (dry-run).
|
|
84
|
+
* Returns the same column shape as dolt_conflicts_$table.
|
|
85
|
+
*/
|
|
86
|
+
declare const doltPreviewMergeConflicts: (db: AgentsManageDatabaseClient) => (params: {
|
|
87
|
+
baseBranch: string;
|
|
88
|
+
mergeBranch: string;
|
|
89
|
+
tableName: string;
|
|
90
|
+
}) => Promise<Record<string, unknown>[]>;
|
|
55
91
|
/**
|
|
56
92
|
* Resolve conflicts for a table using a strategy
|
|
57
93
|
*/
|
|
@@ -60,4 +96,4 @@ declare const doltResolveConflicts: (db: AgentsManageDatabaseClient) => (params:
|
|
|
60
96
|
strategy: "ours" | "theirs";
|
|
61
97
|
}) => Promise<void>;
|
|
62
98
|
//#endregion
|
|
63
|
-
export { doltAbortMerge, doltConflicts, doltMerge, doltMergeStatus, doltResolveConflicts, doltSchemaConflicts, doltTableConflicts };
|
|
99
|
+
export { MergeConflictError, doltAbortMerge, doltConflicts, doltMerge, doltMergeStatus, doltPreviewMergeConflicts, doltPreviewMergeConflictsSummary, doltResolveConflicts, doltSchemaConflicts, doltTableConflicts };
|