Skip to content

Commit 9598f0e

Browse files
Copilotpelikhan
andcommitted
Create separate xlsx runtime package and update imports
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent a5dbd92 commit 9598f0e

File tree

12 files changed

+132
-17
lines changed

12 files changed

+132
-17
lines changed

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"turndown": "^7.2.0",
101101
"turndown-plugin-gfm": "^1.0.2",
102102
"typescript": "5.8.3",
103-
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz",
103+
"genaiscript-xlsx": "workspace:*",
104104
"zod": "^3.25.30",
105105
"zod-to-json-schema": "^3.24.5"
106106
},

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"ts-dedent": "^2.2.0",
100100
"tsx": "^4.19.4",
101101
"typescript": "5.8.3",
102-
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz",
102+
"genaiscript-xlsx": "workspace:*",
103103
"yaml": "^2.8.0"
104104
},
105105
"scripts": {

packages/core/src/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { splitMarkdown } from "./frontmatter"
1515
import { INITryParse } from "./ini"
1616
import { JSON5TryParse } from "./json5"
1717
import { TOMLTryParse } from "./toml"
18-
import { XLSXParse } from "./xlsx"
18+
import { XLSXParse } from "genaiscript-xlsx"
1919
import { XMLTryParse } from "./xml"
2020
import { YAMLTryParse } from "./yaml"
2121
import { resolveFileContent } from "./file"

packages/core/src/file.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { fromBase64, toBase64 } from "./base64"
1313
import { host } from "./host"
1414
import { TraceOptions } from "./trace"
1515
import { parsePdf } from "./pdf"
16-
import { XLSXParse } from "./xlsx"
16+
import { XLSXParse, WorkbookSheet } from "genaiscript-xlsx"
1717
import { dataToMarkdownTable, CSVTryParse } from "./csv"
1818
import {
1919
CSV_REGEX,

packages/core/src/parsers.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { describe, beforeEach, test } from "node:test"
22
import assert from "node:assert/strict"
33
import { createParsers } from "./parsers"
44
import { MarkdownTrace } from "./trace"
5-
import { XLSXParse } from "./xlsx"
5+
import { XLSXParse } from "genaiscript-xlsx"
66
import { readFile } from "fs/promises"
77
import { resolve } from "path"
88
import { TestHost } from "./testhost"

packages/core/src/parsers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { parsePdf } from "./pdf"
2121
import { HTMLToMarkdown, HTMLToText } from "./html"
2222
import { MathTryEvaluate } from "./math"
2323
import { tryValidateJSONWithSchema, validateJSONWithSchema } from "./schema"
24-
import { XLSXTryParse } from "./xlsx"
24+
import { XLSXTryParse } from "genaiscript-xlsx"
2525
import { host } from "./host"
2626
import { unzip } from "./zip"
2727
import { JSONLTryParse } from "./jsonl"

packages/core/src/types/prompt_template.d.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,6 +2179,8 @@ interface RunPromptResult {
21792179
usage?: RunPromptUsage
21802180
}
21812181

2182+
import type { ParseXLSXOptions, WorkbookSheet } from "genaiscript-xlsx"
2183+
21822184
/**
21832185
* Path manipulation functions.
21842186
*/
@@ -2322,17 +2324,6 @@ interface HTMLToTextOptions {
23222324
wordwrap?: number | false | null | undefined
23232325
}
23242326

2325-
interface ParseXLSXOptions {
2326-
// specific worksheet name
2327-
sheet?: string
2328-
// Use specified range (A1-style bounded range string)
2329-
range?: string
2330-
}
2331-
2332-
interface WorkbookSheet {
2333-
name: string
2334-
rows: object[]
2335-
}
23362327

23372328
interface ParseZipOptions {
23382329
glob?: string

packages/xlsx/package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "genaiscript-xlsx",
3+
"version": "1.140.0",
4+
"main": "src/index.ts",
5+
"license": "MIT",
6+
"private": true,
7+
"npm": {
8+
"publish": false
9+
},
10+
"repository": {
11+
"directory": "packages/xlsx",
12+
"url": "https://github.com/microsoft/genaiscript"
13+
},
14+
"dependencies": {
15+
"xlsx": "^0.18.5"
16+
},
17+
"devDependencies": {
18+
"@types/node": "^22.15.2",
19+
"typescript": "5.8.3"
20+
},
21+
"scripts": {
22+
"typecheck": "tsc -p src",
23+
"test": "node --import tsx --test src/**.test.*ts"
24+
}
25+
}

packages/xlsx/src/index.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { describe, test } from "node:test"
2+
import assert from "node:assert/strict"
3+
import { XLSXParse } from "./index"
4+
import { readFile } from "fs/promises"
5+
import { resolve } from "path"
6+
7+
describe("xlsx package", async () => {
8+
test("XLSX parsing", async () => {
9+
const result = await XLSXParse(
10+
await readFile(resolve("../../core/src/parsers.test.xlsx"))
11+
)
12+
assert.deepStrictEqual(result, [
13+
{ name: "Sheet1", rows: [{ key: 1, value: 2 }] },
14+
])
15+
})
16+
})

0 commit comments

Comments
 (0)