@credal/actions 0.2.216 → 0.2.217
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/actions/autogen/templates.js +12 -20
- package/dist/actions/autogen/types.d.ts +9 -26
- package/dist/actions/autogen/types.js +269 -245
- package/dist/actions/parse.js +10 -2
- package/dist/actions/providers/google-oauth/appendRowsToSpreadsheet.js +8 -7
- package/dist/actions/providers/google-oauth/updateRowsInSpreadsheet.js +18 -12
- package/package.json +1 -1
package/dist/actions/parse.js
CHANGED
|
@@ -125,8 +125,16 @@ async function addActionTypes({ file, prefix, action }) {
|
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
async function addTypesToFile({ file, obj, fallback, name, }) {
|
|
128
|
-
// Tool calling framework currently having trouble filling in records as opposed to objects
|
|
129
|
-
|
|
128
|
+
// Tool calling framework currently having trouble filling in records as opposed to objects.
|
|
129
|
+
// Also coerce numeric types from strings: LLMs often emit numbers as JSON strings (e.g. "2"
|
|
130
|
+
// instead of 2) even when the schema specifies integer/number, causing Zod validation failures.
|
|
131
|
+
// z.coerce.number() is a no-op for actual numbers, so this is fully backward-compatible.
|
|
132
|
+
const zodSchema = obj
|
|
133
|
+
? convert(obj)
|
|
134
|
+
.replace(/z\.record\(z\.any\(\)\)/g, "z.object({}).catchall(z.any())")
|
|
135
|
+
.replace(/z\.number\(\)\.int\(\)/g, "z.coerce.number().int()")
|
|
136
|
+
.replace(/z\.number\(\)/g, "z.coerce.number()")
|
|
137
|
+
: fallback;
|
|
130
138
|
const zodName = `${name}Schema`;
|
|
131
139
|
file.addVariableStatement({
|
|
132
140
|
declarationKind: VariableDeclarationKind.Const,
|
|
@@ -9,16 +9,17 @@ const appendRowsToSpreadsheet = async ({ params, authParams, }) => {
|
|
|
9
9
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
10
10
|
}
|
|
11
11
|
const { spreadsheetId, sheetName, rows } = params;
|
|
12
|
-
// Transform rows from schema format to Google Sheets API format
|
|
13
|
-
// Schema: [[{ stringValue: "cell1" }, { stringValue: "cell2" }], ...]
|
|
14
|
-
// API expects: [["cell1", "cell2"], ...]
|
|
15
|
-
const values = rows.map(row => row.map(cell => cell.stringValue));
|
|
16
|
-
const appendUrl = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/'${sheetName ?? "Sheet1"}':append`;
|
|
17
12
|
try {
|
|
13
|
+
if (rows.length === 0) {
|
|
14
|
+
throw new Error("rows array cannot be empty");
|
|
15
|
+
}
|
|
16
|
+
const sheet = sheetName ?? "Sheet1";
|
|
17
|
+
const quotedSheet = /[\s'!]/.test(sheet) ? `'${sheet.replace(/'/g, "''")}'` : sheet;
|
|
18
|
+
const appendUrl = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/${encodeURIComponent(quotedSheet)}:append`;
|
|
18
19
|
const response = await axiosClient.post(appendUrl, {
|
|
19
|
-
values,
|
|
20
|
+
values: rows,
|
|
20
21
|
majorDimension: "ROWS",
|
|
21
|
-
range:
|
|
22
|
+
range: quotedSheet,
|
|
22
23
|
}, {
|
|
23
24
|
headers: {
|
|
24
25
|
Authorization: `Bearer ${authParams.authToken}`,
|
|
@@ -8,20 +8,26 @@ const updateRowsInSpreadsheet = async ({ params, authParams, }) => {
|
|
|
8
8
|
if (!authParams.authToken) {
|
|
9
9
|
throw new Error(MISSING_AUTH_TOKEN);
|
|
10
10
|
}
|
|
11
|
-
const { spreadsheetId, sheetName, startRow, rows } = params;
|
|
12
|
-
if (rows.length === 0) {
|
|
13
|
-
throw new Error("rows array cannot be empty");
|
|
14
|
-
}
|
|
15
|
-
const values = rows.map(row => row.map(cell => cell.stringValue));
|
|
16
|
-
if (startRow < 1) {
|
|
17
|
-
throw new Error("startRow must be >= 1");
|
|
18
|
-
}
|
|
19
|
-
const endRow = startRow + rows.length - 1;
|
|
20
|
-
const range = `'${sheetName ?? "Sheet1"}'!A${startRow}:ZZ${endRow}`;
|
|
21
|
-
const updateUrl = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/${encodeURIComponent(range)}`;
|
|
11
|
+
const { spreadsheetId, sheetName, startRow, startColumn, rows } = params;
|
|
22
12
|
try {
|
|
13
|
+
if (rows.length === 0) {
|
|
14
|
+
throw new Error("rows array cannot be empty");
|
|
15
|
+
}
|
|
16
|
+
if (startRow < 1) {
|
|
17
|
+
throw new Error("startRow must be >= 1");
|
|
18
|
+
}
|
|
19
|
+
const col = startColumn ?? "A";
|
|
20
|
+
if (!/^[A-Za-z]+$/.test(col)) {
|
|
21
|
+
throw new Error(`startColumn must be a column letter (e.g. "A", "BE"), got: "${col}"`);
|
|
22
|
+
}
|
|
23
|
+
const endRow = startRow + rows.length - 1;
|
|
24
|
+
const sheet = sheetName ?? "Sheet1";
|
|
25
|
+
// Only quote sheet names that contain spaces or special characters
|
|
26
|
+
const quotedSheet = /[\s'!]/.test(sheet) ? `'${sheet.replace(/'/g, "''")}'` : sheet;
|
|
27
|
+
const range = `${quotedSheet}!${col}${startRow}:ZZ${endRow}`;
|
|
28
|
+
const updateUrl = `https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/${encodeURIComponent(range)}`;
|
|
23
29
|
const response = await axiosClient.put(updateUrl, {
|
|
24
|
-
values,
|
|
30
|
+
values: rows,
|
|
25
31
|
majorDimension: "ROWS",
|
|
26
32
|
range,
|
|
27
33
|
}, {
|