@lightdash/common 0.2038.0 → 0.2039.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/dist/cjs/ee/AiAgent/schemas/tools/toolProposeChange.d.ts +17 -0
- package/dist/cjs/ee/AiAgent/schemas/tools/toolProposeChange.d.ts.map +1 -1
- package/dist/cjs/ee/AiAgent/schemas/tools/toolProposeChange.js +26 -11
- package/dist/cjs/ee/AiAgent/schemas/tools/toolProposeChange.js.map +1 -1
- package/dist/esm/ee/AiAgent/schemas/tools/toolProposeChange.d.ts +17 -0
- package/dist/esm/ee/AiAgent/schemas/tools/toolProposeChange.d.ts.map +1 -1
- package/dist/esm/ee/AiAgent/schemas/tools/toolProposeChange.js +26 -11
- package/dist/esm/ee/AiAgent/schemas/tools/toolProposeChange.js.map +1 -1
- package/dist/tsconfig.types.tsbuildinfo +1 -1
- package/dist/types/ee/AiAgent/schemas/tools/toolProposeChange.d.ts +17 -0
- package/dist/types/ee/AiAgent/schemas/tools/toolProposeChange.d.ts.map +1 -1
- package/package.json +1 -1
@@ -1,6 +1,18 @@
|
|
1
1
|
import { z } from 'zod';
|
2
|
+
import type { Dimension, Metric, Table } from '../../../..';
|
2
3
|
import { AiResultType } from '../../types';
|
3
4
|
export declare const TOOL_PROPOSE_CHANGE_DESCRIPTION = "\nUse this tool to propose changes to a table's metadata in the semantic layer. This tool creates a change proposal that can be reviewed and approved before being applied.\n\n- When updating descriptions, ensure to preserve as much original content as possible. Remember that descriptions are enclosed in \"description\" tags and you should take the whole value into account as well as its format.\n- If modifying tables, _always_ use the findExplores tool to check existing descriptions before proposing changes to ensure no important content is removed.\n- If modifying metrics or dimensions, _always_ use the findFields tool to check existing descriptions before proposing changes to ensure no important content is removed.\n\n- **When to use the Propose Change Tool:**\n - User requests to update a table description: \"Update the description of the customers table\"\n - User wants to improve a dimension description: \"Add a better description for the customer_name field\"\n - User asks to clarify a metric description: \"Update the total_revenue metric description to explain it's net revenue\"\n - User wants to document business logic in descriptions: \"Add a note that active_users excludes test accounts\"\n\n- **What this tool does:**\n - Creates a change proposal in the system\n - The change is NOT applied immediately - it requires review and approval\n - Supports updating descriptions for tables, dimensions, and metrics\n - Tracks who proposed the change and when\n - Change proposals can be reviewed, approved, or rejected by authorized users\n\n- **Examples:**\n\n User: \"Update the customers table description to mention it includes both B2B and B2C customers\"\n User: \"The revenue_net field should explain it's after taxes and discounts\"\n";
|
5
|
+
type ChangePatch<T> = Partial<Record<keyof T, z.ZodType>>;
|
6
|
+
declare const stringOpSchema: z.ZodDiscriminatedUnion<"op", [z.ZodObject<{
|
7
|
+
op: z.ZodLiteral<"replace">;
|
8
|
+
value: z.ZodString;
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
10
|
+
value: string;
|
11
|
+
op: "replace";
|
12
|
+
}, {
|
13
|
+
value: string;
|
14
|
+
op: "replace";
|
15
|
+
}>]>;
|
4
16
|
export declare const toolProposeChangeArgsSchema: z.ZodObject<{
|
5
17
|
type: z.ZodLiteral<AiResultType.PROPOSE_CHANGE>;
|
6
18
|
} & {
|
@@ -416,4 +428,9 @@ export declare const toolProposeChangeArgsSchema: z.ZodObject<{
|
|
416
428
|
};
|
417
429
|
}>;
|
418
430
|
export type ToolProposeChangeArgs = z.infer<typeof toolProposeChangeArgsSchema>;
|
431
|
+
export type ToolProposeChangeReplaceStringOp = z.infer<typeof stringOpSchema>;
|
432
|
+
export type UpdateDimensionPatch = ChangePatch<Dimension>;
|
433
|
+
export type UpdateMetricPatch = ChangePatch<Metric>;
|
434
|
+
export type UpdateTablePatch = ChangePatch<Table>;
|
435
|
+
export {};
|
419
436
|
//# sourceMappingURL=toolProposeChange.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"toolProposeChange.d.ts","sourceRoot":"","sources":["../../../../../../src/ee/AiAgent/schemas/tools/toolProposeChange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|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,CAAC,SAAS,CAAC,CAAC;AAC1D,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;AACpD,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC"}
|
@@ -5,6 +5,9 @@ const zod_1 = require("zod");
|
|
5
5
|
const types_1 = require("../../types");
|
6
6
|
const fieldId_1 = require("../fieldId");
|
7
7
|
const toolSchemaBuilder_1 = require("../toolSchemaBuilder");
|
8
|
+
// ============================================================================
|
9
|
+
// Tool Description
|
10
|
+
// ============================================================================
|
8
11
|
exports.TOOL_PROPOSE_CHANGE_DESCRIPTION = `
|
9
12
|
Use this tool to propose changes to a table's metadata in the semantic layer. This tool creates a change proposal that can be reviewed and approved before being applied.
|
10
13
|
|
@@ -31,6 +34,9 @@ Use this tool to propose changes to a table's metadata in the semantic layer. Th
|
|
31
34
|
User: "The revenue_net field should explain it's after taxes and discounts"
|
32
35
|
`;
|
33
36
|
const getPatchDescription = (type) => `Patch to apply to the ${type}. You can omit/set-to-null any fields you don't want to change.`;
|
37
|
+
// ============================================================================
|
38
|
+
// Operation Schemas
|
39
|
+
// ============================================================================
|
34
40
|
/**
|
35
41
|
* Op schema can be configured on per-field basis to have a appropriate type and allow applicable operations
|
36
42
|
*/
|
@@ -50,6 +56,20 @@ const getOpSchema = (type) => zod_1.z.discriminatedUnion('op', [
|
|
50
56
|
// z.object({ op: z.literal("remove") }),
|
51
57
|
]);
|
52
58
|
const stringOpSchema = getOpSchema(zod_1.z.string());
|
59
|
+
// ============================================================================
|
60
|
+
// Entity Change Schemas
|
61
|
+
// ============================================================================
|
62
|
+
const TableChangeSchema = zod_1.z.discriminatedUnion('type', [
|
63
|
+
zod_1.z.object({
|
64
|
+
type: zod_1.z.literal('update'),
|
65
|
+
patch: zod_1.z
|
66
|
+
.object({
|
67
|
+
description: stringOpSchema.nullable(),
|
68
|
+
label: stringOpSchema.nullable(),
|
69
|
+
})
|
70
|
+
.describe(getPatchDescription('table')),
|
71
|
+
}),
|
72
|
+
]);
|
53
73
|
const DimensionChangeSchema = zod_1.z.discriminatedUnion('type', [
|
54
74
|
// z.object({
|
55
75
|
// type: z.literal('create'),
|
@@ -80,17 +100,9 @@ const MetricChangeSchema = zod_1.z.discriminatedUnion('type', [
|
|
80
100
|
.describe(getPatchDescription('metric')),
|
81
101
|
}),
|
82
102
|
]);
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
patch: zod_1.z
|
87
|
-
.object({
|
88
|
-
description: stringOpSchema.nullable(),
|
89
|
-
label: stringOpSchema.nullable(),
|
90
|
-
})
|
91
|
-
.describe(getPatchDescription('table')),
|
92
|
-
}),
|
93
|
-
]);
|
103
|
+
// ============================================================================
|
104
|
+
// Main Change Schema
|
105
|
+
// ============================================================================
|
94
106
|
const changeSchema = zod_1.z.discriminatedUnion('entityType', [
|
95
107
|
zod_1.z.object({
|
96
108
|
entityType: zod_1.z.literal('table'),
|
@@ -107,6 +119,9 @@ const changeSchema = zod_1.z.discriminatedUnion('entityType', [
|
|
107
119
|
value: MetricChangeSchema,
|
108
120
|
}),
|
109
121
|
]);
|
122
|
+
// ============================================================================
|
123
|
+
// Tool Schema Export
|
124
|
+
// ============================================================================
|
110
125
|
exports.toolProposeChangeArgsSchema = (0, toolSchemaBuilder_1.createToolSchema)(types_1.AiResultType.PROPOSE_CHANGE, exports.TOOL_PROPOSE_CHANGE_DESCRIPTION)
|
111
126
|
.extend({
|
112
127
|
entityTableName: zod_1.z
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"toolProposeChange.js","sourceRoot":"","sources":["../../../../../../src/ee/AiAgent/schemas/tools/toolProposeChange.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,uCAA2C;AAC3C,wCAA8C;AAC9C,4DAAwD;
|
1
|
+
{"version":3,"file":"toolProposeChange.js","sourceRoot":"","sources":["../../../../../../src/ee/AiAgent/schemas/tools/toolProposeChange.ts"],"names":[],"mappings":";;;AAAA,6BAAwB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qBAAqB;KAC/B,CAAC;IACF,OAAC,CAAC,MAAM,CAAC;QACL,UAAU,EAAE,OAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;QAC/B,OAAO,EAAE,IAAA,0BAAgB,EAAC,EAAE,qBAAqB,EAAE,EAAE,EAAE,CAAC;QACxD,KAAK,EAAE,kBAAkB;KAC5B,CAAC;CACL,CAAC,CAAC;AAEH,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAElE,QAAA,2BAA2B,GAAG,IAAA,oCAAgB,EACvD,oBAAY,CAAC,cAAc,EAC3B,uCAA+B,CAClC;KACI,MAAM,CAAC;IACJ,eAAe,EAAE,OAAC;SACb,MAAM,EAAE;SACR,QAAQ,CAAC,8CAA8C,CAAC;IAC7D,SAAS,EAAE,OAAC;SACP,MAAM,EAAE;SACR,QAAQ,CACL,6EAA6E,CAChF;IACL,MAAM,EAAE,YAAY;CACvB,CAAC;KACD,KAAK,EAAE,CAAC"}
|
@@ -1,6 +1,18 @@
|
|
1
1
|
import { z } from 'zod';
|
2
|
+
import type { Dimension, Metric, Table } from '../../../..';
|
2
3
|
import { AiResultType } from '../../types';
|
3
4
|
export declare const TOOL_PROPOSE_CHANGE_DESCRIPTION = "\nUse this tool to propose changes to a table's metadata in the semantic layer. This tool creates a change proposal that can be reviewed and approved before being applied.\n\n- When updating descriptions, ensure to preserve as much original content as possible. Remember that descriptions are enclosed in \"description\" tags and you should take the whole value into account as well as its format.\n- If modifying tables, _always_ use the findExplores tool to check existing descriptions before proposing changes to ensure no important content is removed.\n- If modifying metrics or dimensions, _always_ use the findFields tool to check existing descriptions before proposing changes to ensure no important content is removed.\n\n- **When to use the Propose Change Tool:**\n - User requests to update a table description: \"Update the description of the customers table\"\n - User wants to improve a dimension description: \"Add a better description for the customer_name field\"\n - User asks to clarify a metric description: \"Update the total_revenue metric description to explain it's net revenue\"\n - User wants to document business logic in descriptions: \"Add a note that active_users excludes test accounts\"\n\n- **What this tool does:**\n - Creates a change proposal in the system\n - The change is NOT applied immediately - it requires review and approval\n - Supports updating descriptions for tables, dimensions, and metrics\n - Tracks who proposed the change and when\n - Change proposals can be reviewed, approved, or rejected by authorized users\n\n- **Examples:**\n\n User: \"Update the customers table description to mention it includes both B2B and B2C customers\"\n User: \"The revenue_net field should explain it's after taxes and discounts\"\n";
|
5
|
+
type ChangePatch<T> = Partial<Record<keyof T, z.ZodType>>;
|
6
|
+
declare const stringOpSchema: z.ZodDiscriminatedUnion<"op", [z.ZodObject<{
|
7
|
+
op: z.ZodLiteral<"replace">;
|
8
|
+
value: z.ZodString;
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
10
|
+
value: string;
|
11
|
+
op: "replace";
|
12
|
+
}, {
|
13
|
+
value: string;
|
14
|
+
op: "replace";
|
15
|
+
}>]>;
|
4
16
|
export declare const toolProposeChangeArgsSchema: z.ZodObject<{
|
5
17
|
type: z.ZodLiteral<AiResultType.PROPOSE_CHANGE>;
|
6
18
|
} & {
|
@@ -416,4 +428,9 @@ export declare const toolProposeChangeArgsSchema: z.ZodObject<{
|
|
416
428
|
};
|
417
429
|
}>;
|
418
430
|
export type ToolProposeChangeArgs = z.infer<typeof toolProposeChangeArgsSchema>;
|
431
|
+
export type ToolProposeChangeReplaceStringOp = z.infer<typeof stringOpSchema>;
|
432
|
+
export type UpdateDimensionPatch = ChangePatch<Dimension>;
|
433
|
+
export type UpdateMetricPatch = ChangePatch<Metric>;
|
434
|
+
export type UpdateTablePatch = ChangePatch<Table>;
|
435
|
+
export {};
|
419
436
|
//# sourceMappingURL=toolProposeChange.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"toolProposeChange.d.ts","sourceRoot":"","sources":["../../../../../../src/ee/AiAgent/schemas/tools/toolProposeChange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
1
|
+
{"version":3,"file":"toolProposeChange.d.ts","sourceRoot":"","sources":["../../../../../../src/ee/AiAgent/schemas/tools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AC,CAAC;AACpD,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC"}
|
@@ -2,6 +2,9 @@ import { z } from 'zod';
|
|
2
2
|
import { AiResultType } from '../../types';
|
3
3
|
import { getFieldIdSchema } from '../fieldId';
|
4
4
|
import { createToolSchema } from '../toolSchemaBuilder';
|
5
|
+
// ============================================================================
|
6
|
+
// Tool Description
|
7
|
+
// ============================================================================
|
5
8
|
export const TOOL_PROPOSE_CHANGE_DESCRIPTION = `
|
6
9
|
Use this tool to propose changes to a table's metadata in the semantic layer. This tool creates a change proposal that can be reviewed and approved before being applied.
|
7
10
|
|
@@ -28,6 +31,9 @@ Use this tool to propose changes to a table's metadata in the semantic layer. Th
|
|
28
31
|
User: "The revenue_net field should explain it's after taxes and discounts"
|
29
32
|
`;
|
30
33
|
const getPatchDescription = (type) => `Patch to apply to the ${type}. You can omit/set-to-null any fields you don't want to change.`;
|
34
|
+
// ============================================================================
|
35
|
+
// Operation Schemas
|
36
|
+
// ============================================================================
|
31
37
|
/**
|
32
38
|
* Op schema can be configured on per-field basis to have a appropriate type and allow applicable operations
|
33
39
|
*/
|
@@ -47,6 +53,20 @@ const getOpSchema = (type) => z.discriminatedUnion('op', [
|
|
47
53
|
// z.object({ op: z.literal("remove") }),
|
48
54
|
]);
|
49
55
|
const stringOpSchema = getOpSchema(z.string());
|
56
|
+
// ============================================================================
|
57
|
+
// Entity Change Schemas
|
58
|
+
// ============================================================================
|
59
|
+
const TableChangeSchema = z.discriminatedUnion('type', [
|
60
|
+
z.object({
|
61
|
+
type: z.literal('update'),
|
62
|
+
patch: z
|
63
|
+
.object({
|
64
|
+
description: stringOpSchema.nullable(),
|
65
|
+
label: stringOpSchema.nullable(),
|
66
|
+
})
|
67
|
+
.describe(getPatchDescription('table')),
|
68
|
+
}),
|
69
|
+
]);
|
50
70
|
const DimensionChangeSchema = z.discriminatedUnion('type', [
|
51
71
|
// z.object({
|
52
72
|
// type: z.literal('create'),
|
@@ -77,17 +97,9 @@ const MetricChangeSchema = z.discriminatedUnion('type', [
|
|
77
97
|
.describe(getPatchDescription('metric')),
|
78
98
|
}),
|
79
99
|
]);
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
patch: z
|
84
|
-
.object({
|
85
|
-
description: stringOpSchema.nullable(),
|
86
|
-
label: stringOpSchema.nullable(),
|
87
|
-
})
|
88
|
-
.describe(getPatchDescription('table')),
|
89
|
-
}),
|
90
|
-
]);
|
100
|
+
// ============================================================================
|
101
|
+
// Main Change Schema
|
102
|
+
// ============================================================================
|
91
103
|
const changeSchema = z.discriminatedUnion('entityType', [
|
92
104
|
z.object({
|
93
105
|
entityType: z.literal('table'),
|
@@ -104,6 +116,9 @@ const changeSchema = z.discriminatedUnion('entityType', [
|
|
104
116
|
value: MetricChangeSchema,
|
105
117
|
}),
|
106
118
|
]);
|
119
|
+
// ============================================================================
|
120
|
+
// Tool Schema Export
|
121
|
+
// ============================================================================
|
107
122
|
export const toolProposeChangeArgsSchema = createToolSchema(AiResultType.PROPOSE_CHANGE, TOOL_PROPOSE_CHANGE_DESCRIPTION)
|
108
123
|
.extend({
|
109
124
|
entityTableName: z
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"toolProposeChange.js","sourceRoot":"","sources":["../../../../../../src/ee/AiAgent/schemas/tools/toolProposeChange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,CAAC,MAAM,+BAA+B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;CAwB9C,CAAC;
|
1
|
+
{"version":3,"file":"toolProposeChange.js","sourceRoot":"","sources":["../../../../../../src/ee/AiAgent/schemas/tools/toolProposeChange.ts"],"names":[],"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