@keshavsoft/tallyextract 1.1.2 → 1.2.1

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/index.js CHANGED
@@ -1 +1 @@
1
- export * from "./src/v1/index.js";
1
+ export * from "./src/v2/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keshavsoft/tallyextract",
3
- "version": "1.1.2",
3
+ "version": "1.2.1",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -0,0 +1,3 @@
1
+ // src/v1/api/index.js
2
+ export { ledger } from "./ledger.js";
3
+ export { stockItems } from "./stockitems.js";
@@ -0,0 +1,6 @@
1
+ // src/v1/api/stockItems.js
2
+ import { sendToTally } from "../core/sendToTally.js";
3
+
4
+ export function ledger() {
5
+ return sendToTally("KeshavLedgers");
6
+ };
@@ -0,0 +1,6 @@
1
+ // src/v1/api/stockItems.js
2
+ import { sendToTally } from "../core/sendToTally.js";
3
+
4
+ export function stockItems() {
5
+ return sendToTally("KeshavStockItems");
6
+ };
package/src/v2/cli.js ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+
3
+ console.log("kschema CLI running 🚀");
4
+
5
+ const args = process.argv.slice(2);
6
+
7
+ console.log("Args:", args);
8
+
9
+ if (args[0] === "init") {
10
+ console.log("Init command triggered");
11
+ };
@@ -0,0 +1,21 @@
1
+ // src/v1/core/sendToTally.js
2
+ const BODY = {
3
+ static_variables: [
4
+ { name: "svExportFormat", value: "jsonex" }
5
+ ]
6
+ };
7
+
8
+ export async function sendToTally(Id, url = "http://localhost:9000") {
9
+ const res = await fetch(url, {
10
+ method: "POST",
11
+ headers: {
12
+ "Content-Type": "application/json",
13
+ "TallyRequest": "Export",
14
+ "Type": "Collection",
15
+ "Id": Id
16
+ },
17
+ body: JSON.stringify(BODY)
18
+ });
19
+
20
+ return res.json();
21
+ };
@@ -0,0 +1 @@
1
+ export * from "./api/index.js";
@@ -0,0 +1,6 @@
1
+ // utils/readJson.js
2
+ import fs from "fs/promises";
3
+
4
+ export async function readJson(filePath) {
5
+ return JSON.parse(await fs.readFile(filePath, "utf8"));
6
+ };