tally-xml-tdl 1.23.3 → 1.25.2

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.d.ts CHANGED
@@ -1,15 +1,65 @@
1
- export function company(showLog?: boolean): Promise<any>;
2
- export default company;
3
-
4
- export interface V6Options {
5
- company: string;
6
- jsonId: string;
7
- url?: string;
8
- }
9
-
10
- export function get<T = any>(options?: V6Options): Promise<T>;
11
- export function clean<T = any>(options?: V6Options): Promise<T>;
12
-
13
- export * as v6 from "./src/v6/index.js";
14
- export * as v13 from "./src/v13/main.js";
15
-
1
+ /**
2
+ * Generated by create-intellisense from src/v24.
3
+ * Do not edit this file directly.
4
+ */
5
+
6
+ export type TallyApi = {
7
+ company: {
8
+ /** Fetches company list from Tally. */
9
+ fetch: (inParam: string, ...inArgs: any[]) => Promise<any>;
10
+ };
11
+ vouchers: {
12
+ purchases: {
13
+ /** Fetches purchase vouchers. */
14
+ fetch: (inParam: string, ...inArgs: any[]) => Promise<any>;
15
+ };
16
+ sales: {
17
+ /** Fetches sales vouchers. */
18
+ fetch: (inParam: string, ...inArgs: any[]) => Promise<any>;
19
+ };
20
+ };
21
+ masters: {
22
+ unit: {
23
+ /** Fetches all units. */
24
+ all: (inParam: string, ...inArgs: any[]) => Promise<any>;
25
+ };
26
+ stockItem: {
27
+ /** Fetches all stock items. */
28
+ all: (inParam: string, ...inArgs: any[]) => Promise<any>;
29
+ /** Fetches stock items with base units. */
30
+ withBaseUnits: (inParam: string, ...inArgs: any[]) => Promise<any>;
31
+ /** Fetches stock items with batches. */
32
+ withBatches: (inParam: string, ...inArgs: any[]) => Promise<any>;
33
+ };
34
+ ledger: {
35
+ /** Fetches all ledgers. */
36
+ all: (inParam: string, ...inArgs: any[]) => Promise<any>;
37
+ /** Fetches ledgers with GSTIN details. */
38
+ withDetails: (inParam: string, ...inArgs: any[]) => Promise<any>;
39
+ /** Fetches ledgers with full GST registration details. */
40
+ withGstDetails: (inParam: string, ...inArgs: any[]) => Promise<any>;
41
+ };
42
+ stockGroup: {
43
+ /** Fetches all stock groups. */
44
+ all: (inParam: string, ...inArgs: any[]) => Promise<any>;
45
+ /** Fetches stock groups with parent hierarchies. */
46
+ withParent: (inParam: string, ...inArgs: any[]) => Promise<any>;
47
+ };
48
+ godown: {
49
+ /** Fetches all godowns. */
50
+ all: (inParam: string, ...inArgs: any[]) => Promise<any>;
51
+ /** Fetches godowns with parent hierarchies. */
52
+ withParent: (inParam: string, ...inArgs: any[]) => Promise<any>;
53
+ };
54
+ };
55
+ reports: {
56
+ stockSummary: {
57
+ /** Fetches the Stock Summary report from Tally. */
58
+ fetch: (inParam: string, ...inArgs: any[]) => Promise<any>;
59
+ };
60
+ };
61
+ };
62
+
63
+ declare const tally: TallyApi;
64
+
65
+ export default tally;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tally-xml-tdl",
3
- "version": "1.23.3",
3
+ "version": "1.25.2",
4
4
  "description": "Simple, clean TDL and XML extraction and manipulation tools for Tally",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -30,6 +30,8 @@
30
30
  "url": "https://github.com/keshavsoft/tally-xml-tdl/issues"
31
31
  },
32
32
  "dependencies": {
33
- "fast-xml-parser": "^5.11.1"
33
+ "@keshavsoft/api-tree": "^6.1.0",
34
+ "fast-xml-parser": "^5.11.1",
35
+ "tally-spec": "^1.0.0"
34
36
  }
35
- }
37
+ }
package/src/index.js CHANGED
@@ -1,2 +1,3 @@
1
- export * from "./v23/index.js";
2
- export { default } from "./v23/index.js";
1
+ import app from "./v25/index.js";
2
+
3
+ export default app;
@@ -0,0 +1,17 @@
1
+ [
2
+ "tally.company.fetch",
3
+ "tally.vouchers.purchases.fetch",
4
+ "tally.vouchers.sales.fetch",
5
+ "tally.masters.unit.all",
6
+ "tally.masters.stockItem.all",
7
+ "tally.masters.stockItem.withBaseUnits",
8
+ "tally.masters.stockItem.withBatches",
9
+ "tally.masters.ledger.all",
10
+ "tally.masters.ledger.withDetails",
11
+ "tally.masters.ledger.withGstDetails",
12
+ "tally.masters.stockGroup.all",
13
+ "tally.masters.stockGroup.withParent",
14
+ "tally.masters.godown.all",
15
+ "tally.masters.godown.withParent",
16
+ "tally.reports.stockSummary.fetch"
17
+ ]
@@ -0,0 +1,54 @@
1
+ import { collectionTemplate, dataTemplate } from "./templates.js";
2
+
3
+ const startFunc = ({ inEndpoint, inParam, inArgs }) => {
4
+ const localEndpoint = inEndpoint;
5
+ const localParam = inParam;
6
+ const localArgs = inArgs || [];
7
+
8
+ if (localEndpoint?.reportId) {
9
+ let staticVars = "";
10
+
11
+ if (typeof localParam === "string" && localParam.length > 0) {
12
+ staticVars += `<SVCURRENTCOMPANY>${localParam}</SVCURRENTCOMPANY>`;
13
+ } else if (typeof localParam === "object" && localParam?.company) {
14
+ staticVars += `<SVCURRENTCOMPANY>${localParam.company}</SVCURRENTCOMPANY>`;
15
+ }
16
+
17
+ if (localEndpoint.staticVariables) {
18
+ staticVars += localEndpoint.staticVariables;
19
+ }
20
+
21
+ if (localArgs[0] && typeof localArgs[0] === "string") {
22
+ staticVars += localArgs[0];
23
+ }
24
+
25
+ return dataTemplate
26
+ .replace("{{ID}}", localEndpoint.reportId)
27
+ .replace("{{STATICVARIABLES}}", staticVars);
28
+ }
29
+
30
+ let staticVars = "";
31
+
32
+ if (typeof localParam === "string" && localParam.length > 0) {
33
+ staticVars += `<SVCURRENTCOMPANY>${localParam}</SVCURRENTCOMPANY>`;
34
+ } else if (typeof localParam === "object" && localParam) {
35
+ if (localParam.company) {
36
+ staticVars += `<SVCURRENTCOMPANY>${localParam.company}</SVCURRENTCOMPANY>`;
37
+ }
38
+ if (localParam.fromDate && localParam.toDate) {
39
+ staticVars += `<SVFROMDATE TYPE="Date">${localParam.fromDate}</SVFROMDATE><SVTODATE TYPE="Date">${localParam.toDate}</SVTODATE>`;
40
+ }
41
+ }
42
+
43
+ if (localArgs.length >= 2 && localArgs[0] && localArgs[1]) {
44
+ staticVars += `<SVFROMDATE TYPE="Date">${localArgs[0]}</SVFROMDATE><SVTODATE TYPE="Date">${localArgs[1]}</SVTODATE>`;
45
+ }
46
+
47
+ const tdlMessage = localEndpoint?.tdl || "";
48
+
49
+ return collectionTemplate
50
+ .replace("{{STATICVARIABLES}}", staticVars)
51
+ .replace("{{TDLMESSAGE}}", tdlMessage);
52
+ };
53
+
54
+ export default startFunc;
@@ -0,0 +1,29 @@
1
+ import buildXml from "./buildXml.js";
2
+ import transport from "./transport.js";
3
+ import parseResponse from "./parseResponse.js";
4
+
5
+ const startFunc = async ({ inEndpoint, inParam, inArgs, inUrl }) => {
6
+ const localEndpoint = inEndpoint;
7
+ const localParam = inParam;
8
+ const localArgs = inArgs;
9
+ const localUrl = inUrl;
10
+
11
+ const xml = buildXml({
12
+ inEndpoint: localEndpoint,
13
+ inParam: localParam,
14
+ inArgs: localArgs
15
+ });
16
+
17
+ const rawResponse = await transport({
18
+ inXml: xml,
19
+ inUrl: localUrl
20
+ });
21
+
22
+ const parsedJson = parseResponse({
23
+ inXml: rawResponse
24
+ });
25
+
26
+ return parsedJson;
27
+ };
28
+
29
+ export default startFunc;
@@ -0,0 +1,12 @@
1
+ const startFunc = ({ inSource, inRoutePath }) => {
2
+ const localSource = inSource;
3
+ const localRoutePath = inRoutePath;
4
+
5
+ const endpoint = localRoutePath
6
+ .split(".")
7
+ .reduce((current, key) => current?.[key], localSource);
8
+
9
+ return endpoint;
10
+ };
11
+
12
+ export default startFunc;
@@ -0,0 +1,27 @@
1
+ import validateInput from "./validateInput.js";
2
+ import getEndpointSpec from "./getEndpointSpec.js";
3
+ import dispatchTally from "./dispatchTally.js";
4
+
5
+ const startFunc = async ({ inRoutePath, inParam, inArgs, inSource }) => {
6
+ const localRoutePath = inRoutePath;
7
+ const localParam = inParam;
8
+ const localArgs = inArgs;
9
+ const localSource = inSource;
10
+
11
+ const param = validateInput({
12
+ inParam: localParam
13
+ });
14
+
15
+ const endpoint = getEndpointSpec({
16
+ inSource: localSource,
17
+ inRoutePath: localRoutePath
18
+ });
19
+
20
+ return await dispatchTally({
21
+ inEndpoint: endpoint,
22
+ inParam: param,
23
+ inArgs: localArgs
24
+ });
25
+ };
26
+
27
+ export default startFunc;
@@ -0,0 +1,13 @@
1
+ import { XMLParser } from "fast-xml-parser";
2
+
3
+ const startFunc = ({ inXml }) => {
4
+ const localXml = inXml;
5
+
6
+ const parser = new XMLParser({
7
+ ignoreAttributes: false
8
+ });
9
+
10
+ return parser.parse(localXml);
11
+ };
12
+
13
+ export default startFunc;
@@ -0,0 +1,42 @@
1
+ const collectionTemplate = `<ENVELOPE>
2
+ <HEADER>
3
+ <VERSION>1</VERSION>
4
+ <TALLYREQUEST>Export</TALLYREQUEST>
5
+ <TYPE>Collection</TYPE>
6
+ <ID>TDLID</ID>
7
+ </HEADER>
8
+ <BODY>
9
+ <DESC>
10
+ <STATICVARIABLES>
11
+ <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
12
+ {{STATICVARIABLES}}
13
+ </STATICVARIABLES>
14
+ <TDL>
15
+ <TDLMESSAGE>
16
+ <COLLECTION NAME="TDLID">
17
+ {{TDLMESSAGE}}
18
+ </COLLECTION>
19
+ </TDLMESSAGE>
20
+ </TDL>
21
+ </DESC>
22
+ </BODY>
23
+ </ENVELOPE>`;
24
+
25
+ const dataTemplate = `<ENVELOPE>
26
+ <HEADER>
27
+ <VERSION>1</VERSION>
28
+ <TALLYREQUEST>Export</TALLYREQUEST>
29
+ <TYPE>Data</TYPE>
30
+ <ID>{{ID}}</ID>
31
+ </HEADER>
32
+ <BODY>
33
+ <DESC>
34
+ <STATICVARIABLES>
35
+ <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
36
+ {{STATICVARIABLES}}
37
+ </STATICVARIABLES>
38
+ </DESC>
39
+ </BODY>
40
+ </ENVELOPE>`;
41
+
42
+ export { collectionTemplate, dataTemplate };
@@ -0,0 +1,16 @@
1
+ const startFunc = async ({ inXml, inUrl }) => {
2
+ const localXml = inXml;
3
+ const localUrl = inUrl || "http://localhost:9000";
4
+
5
+ const response = await fetch(localUrl, {
6
+ method: "POST",
7
+ headers: {
8
+ "Content-Type": "text/xml"
9
+ },
10
+ body: localXml
11
+ });
12
+
13
+ return await response.text();
14
+ };
15
+
16
+ export default startFunc;
@@ -0,0 +1,19 @@
1
+ const startFunc = ({ inParam }) => {
2
+ const localParam = inParam;
3
+
4
+ if (localParam === undefined || localParam === null) {
5
+ return "";
6
+ }
7
+
8
+ if (typeof localParam === "string") {
9
+ return localParam.trim();
10
+ }
11
+
12
+ if (typeof localParam === "object") {
13
+ return localParam;
14
+ }
15
+
16
+ return String(localParam);
17
+ };
18
+
19
+ export default startFunc;
@@ -0,0 +1,25 @@
1
+ import createLeafHandler from "./createLeafHandler.js";
2
+
3
+ const startFunc = ({ inTree, inPath, inSource, inExecutor }) => {
4
+ const localTree = inTree;
5
+ const localPath = inPath;
6
+ const localSource = inSource;
7
+ const localExecutor = inExecutor;
8
+
9
+ const parts = localPath.split(".");
10
+ const leafName = parts.pop();
11
+
12
+ let branch = localTree;
13
+ for (const segment of parts) {
14
+ branch[segment] ??= {};
15
+ branch = branch[segment];
16
+ }
17
+
18
+ branch[leafName] = createLeafHandler({
19
+ inPath: localPath,
20
+ inSource: localSource,
21
+ inExecutor: localExecutor
22
+ });
23
+ };
24
+
25
+ export default startFunc;
@@ -0,0 +1,19 @@
1
+ const startFunc = ({ inPath, inSource, inExecutor }) => {
2
+ const localPath = inPath;
3
+ const localSource = inSource;
4
+ const localExecutor = inExecutor;
5
+
6
+ return async (inParam, ...inArgs) => {
7
+ const localParam = inParam;
8
+ const localArgs = inArgs;
9
+
10
+ return await localExecutor({
11
+ inRoutePath: localPath,
12
+ inParam: localParam,
13
+ inArgs: localArgs,
14
+ inSource: localSource
15
+ });
16
+ };
17
+ };
18
+
19
+ export default startFunc;
@@ -0,0 +1,24 @@
1
+ import attachPath from "./attachPath.js";
2
+
3
+ const startFunc = ({ inApiPaths, inSource, inExecutor }) => {
4
+ const localApiPaths = inApiPaths;
5
+ const localSource = inSource;
6
+ const localExecutor = inExecutor;
7
+
8
+ const tree = {};
9
+
10
+ for (const path of localApiPaths) {
11
+ attachPath({
12
+ inTree: tree,
13
+ inPath: path,
14
+ inSource: localSource,
15
+ inExecutor: localExecutor
16
+ });
17
+ }
18
+
19
+ const rootNamespace = localApiPaths[0]?.split(".")[0];
20
+
21
+ return rootNamespace ? tree[rootNamespace] : tree;
22
+ };
23
+
24
+ export default startFunc;
@@ -0,0 +1,12 @@
1
+ import source from "./source.json" with { type: "json" };
2
+ import apiPaths from "./api.json" with { type: "json" };
3
+
4
+ import createRoute from "./engine/route/index.js";
5
+ import execute from "./engine/execution/index.js";
6
+
7
+ const app = createRoute({
8
+ inApiPaths: apiPaths,
9
+ inSource: source,
10
+ inExecutor: execute
11
+ });
12
+ export default app;
@@ -0,0 +1,119 @@
1
+ {
2
+ "tally": {
3
+ "company": {
4
+ "fetch": {
5
+ "action": "fetch",
6
+ "resource": "Company",
7
+ "tdl": "<TYPE>Company</TYPE><FETCH>$$Alias:Name</FETCH>",
8
+ "description": "Fetches company list from Tally."
9
+ }
10
+ },
11
+ "vouchers": {
12
+ "purchases": {
13
+ "fetch": {
14
+ "action": "fetch",
15
+ "resource": "Purchases",
16
+ "tdl": "<TYPE>Vouchers:VoucherType</TYPE><CHILDOF>$$$$VchTypePurchase</CHILDOF><BELONGSTO>Yes</BELONGSTO><FETCH>Date, VoucherNumber, VoucherTypeName, PartyLedgerName, Amount, AllInventoryEntries, AllLedgerEntries</FETCH>",
17
+ "description": "Fetches purchase vouchers."
18
+ }
19
+ },
20
+ "sales": {
21
+ "fetch": {
22
+ "action": "fetch",
23
+ "resource": "Sales",
24
+ "tdl": "<TYPE>Vouchers:VoucherType</TYPE><CHILDOF>$$$$VchTypeSales</CHILDOF><BELONGSTO>Yes</BELONGSTO><FETCH>Date, VoucherNumber, VoucherTypeName, PartyLedgerName, Amount, AllInventoryEntries, AllLedgerEntries</FETCH>",
25
+ "description": "Fetches sales vouchers."
26
+ }
27
+ }
28
+ },
29
+ "masters": {
30
+ "unit": {
31
+ "all": {
32
+ "action": "fetch",
33
+ "resource": "Unit",
34
+ "tdl": "<TYPE>Unit</TYPE><FETCH>$$Alias:Name</FETCH>",
35
+ "description": "Fetches all units."
36
+ }
37
+ },
38
+ "stockItem": {
39
+ "all": {
40
+ "action": "fetch",
41
+ "resource": "StockItem",
42
+ "tdl": "<TYPE>StockItem</TYPE><FETCH>$$Alias:Name</FETCH>",
43
+ "description": "Fetches all stock items."
44
+ },
45
+ "withBaseUnits": {
46
+ "action": "fetch",
47
+ "resource": "StockItem",
48
+ "tdl": "<TYPE>StockItem</TYPE><FETCH>$$Alias:Name</FETCH><FETCH>BaseUnits</FETCH>",
49
+ "description": "Fetches stock items with base units."
50
+ },
51
+ "withBatches": {
52
+ "action": "fetch",
53
+ "resource": "StockItem",
54
+ "tdl": "<TYPE>StockItem</TYPE><FETCH>$$Alias:Name</FETCH><FETCH>BaseUnits</FETCH><FETCH>BatchAllocations.*</FETCH>",
55
+ "description": "Fetches stock items with batches."
56
+ }
57
+ },
58
+ "ledger": {
59
+ "all": {
60
+ "action": "fetch",
61
+ "resource": "Ledger",
62
+ "tdl": "<TYPE>Ledger</TYPE><FETCH>$$Alias:Name</FETCH>",
63
+ "description": "Fetches all ledgers."
64
+ },
65
+ "withDetails": {
66
+ "action": "fetch",
67
+ "resource": "Ledger",
68
+ "tdl": "<TYPE>Ledger</TYPE><FETCH>$$Alias:Name</FETCH><FETCH>GSTRegistrationType</FETCH><FETCH>GSTIN</FETCH>",
69
+ "description": "Fetches ledgers with GSTIN details."
70
+ },
71
+ "withGstDetails": {
72
+ "action": "fetch",
73
+ "resource": "Ledger",
74
+ "tdl": "<TYPE>Ledger</TYPE><FETCH>$$Alias:Name</FETCH><FETCH>LEDGSTREGDETAILS.LIST</FETCH>",
75
+ "description": "Fetches ledgers with full GST registration details."
76
+ }
77
+ },
78
+ "stockGroup": {
79
+ "all": {
80
+ "action": "fetch",
81
+ "resource": "StockGroup",
82
+ "tdl": "<TYPE>StockGroup</TYPE><FETCH>$$Alias:Name</FETCH>",
83
+ "description": "Fetches all stock groups."
84
+ },
85
+ "withParent": {
86
+ "action": "fetch",
87
+ "resource": "StockGroup",
88
+ "tdl": "<TYPE>StockGroup</TYPE><FETCH>$$Alias:Name</FETCH><FETCH>Parent</FETCH>",
89
+ "description": "Fetches stock groups with parent hierarchies."
90
+ }
91
+ },
92
+ "godown": {
93
+ "all": {
94
+ "action": "fetch",
95
+ "resource": "Godown",
96
+ "tdl": "<TYPE>Godown</TYPE><FETCH>$$Alias:Name</FETCH>",
97
+ "description": "Fetches all godowns."
98
+ },
99
+ "withParent": {
100
+ "action": "fetch",
101
+ "resource": "Godown",
102
+ "tdl": "<TYPE>Godown</TYPE><FETCH>$$Alias:Name</FETCH><FETCH>Parent</FETCH>",
103
+ "description": "Fetches godowns with parent hierarchies."
104
+ }
105
+ }
106
+ },
107
+ "reports": {
108
+ "stockSummary": {
109
+ "fetch": {
110
+ "action": "fetch",
111
+ "resource": "StockSummary",
112
+ "reportId": "Stock Summary",
113
+ "staticVariables": "<EXPLODEFLAG>Yes</EXPLODEFLAG>",
114
+ "description": "Fetches the Stock Summary report from Tally."
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }
@@ -0,0 +1,54 @@
1
+ import { collectionTemplate, dataTemplate } from "./templates.js";
2
+
3
+ const startFunc = ({ inEndpoint, inParam, inArgs }) => {
4
+ const localEndpoint = inEndpoint;
5
+ const localParam = inParam;
6
+ const localArgs = inArgs || [];
7
+
8
+ if (localEndpoint?.reportId) {
9
+ let staticVars = "";
10
+
11
+ if (typeof localParam === "string" && localParam.length > 0) {
12
+ staticVars += `<SVCURRENTCOMPANY>${localParam}</SVCURRENTCOMPANY>`;
13
+ } else if (typeof localParam === "object" && localParam?.company) {
14
+ staticVars += `<SVCURRENTCOMPANY>${localParam.company}</SVCURRENTCOMPANY>`;
15
+ }
16
+
17
+ if (localEndpoint.staticVariables) {
18
+ staticVars += localEndpoint.staticVariables;
19
+ }
20
+
21
+ if (localArgs[0] && typeof localArgs[0] === "string") {
22
+ staticVars += localArgs[0];
23
+ }
24
+
25
+ return dataTemplate
26
+ .replace("{{ID}}", localEndpoint.reportId)
27
+ .replace("{{STATICVARIABLES}}", staticVars);
28
+ }
29
+
30
+ let staticVars = "";
31
+
32
+ if (typeof localParam === "string" && localParam.length > 0) {
33
+ staticVars += `<SVCURRENTCOMPANY>${localParam}</SVCURRENTCOMPANY>`;
34
+ } else if (typeof localParam === "object" && localParam) {
35
+ if (localParam.company) {
36
+ staticVars += `<SVCURRENTCOMPANY>${localParam.company}</SVCURRENTCOMPANY>`;
37
+ }
38
+ if (localParam.fromDate && localParam.toDate) {
39
+ staticVars += `<SVFROMDATE TYPE="Date">${localParam.fromDate}</SVFROMDATE><SVTODATE TYPE="Date">${localParam.toDate}</SVTODATE>`;
40
+ }
41
+ }
42
+
43
+ if (localArgs.length >= 2 && localArgs[0] && localArgs[1]) {
44
+ staticVars += `<SVFROMDATE TYPE="Date">${localArgs[0]}</SVFROMDATE><SVTODATE TYPE="Date">${localArgs[1]}</SVTODATE>`;
45
+ }
46
+
47
+ const tdlMessage = localEndpoint?.tdl || "";
48
+
49
+ return collectionTemplate
50
+ .replace("{{STATICVARIABLES}}", staticVars)
51
+ .replace("{{TDLMESSAGE}}", tdlMessage);
52
+ };
53
+
54
+ export default startFunc;
@@ -0,0 +1,29 @@
1
+ import buildXml from "./buildXml.js";
2
+ import transport from "./transport.js";
3
+ import parseResponse from "./parseResponse.js";
4
+
5
+ const startFunc = async ({ inEndpoint, inParam, inArgs, inUrl }) => {
6
+ const localEndpoint = inEndpoint;
7
+ const localParam = inParam;
8
+ const localArgs = inArgs;
9
+ const localUrl = inUrl;
10
+
11
+ const xml = buildXml({
12
+ inEndpoint: localEndpoint,
13
+ inParam: localParam,
14
+ inArgs: localArgs
15
+ });
16
+
17
+ const rawResponse = await transport({
18
+ inXml: xml,
19
+ inUrl: localUrl
20
+ });
21
+
22
+ const parsedJson = parseResponse({
23
+ inXml: rawResponse
24
+ });
25
+
26
+ return parsedJson;
27
+ };
28
+
29
+ export default startFunc;
@@ -0,0 +1,12 @@
1
+ const startFunc = ({ inSource, inRoutePath }) => {
2
+ const localSource = inSource;
3
+ const localRoutePath = inRoutePath;
4
+
5
+ const endpoint = localRoutePath
6
+ .split(".")
7
+ .reduce((current, key) => current?.[key], localSource);
8
+
9
+ return endpoint;
10
+ };
11
+
12
+ export default startFunc;
@@ -0,0 +1,27 @@
1
+ import validateInput from "./validateInput.js";
2
+ import getEndpointSpec from "./getEndpointSpec.js";
3
+ import dispatchTally from "./dispatchTally.js";
4
+
5
+ const startFunc = async ({ inRoutePath, inParam, inArgs, inSource }) => {
6
+ const localRoutePath = inRoutePath;
7
+ const localParam = inParam;
8
+ const localArgs = inArgs;
9
+ const localSource = inSource;
10
+
11
+ const param = validateInput({
12
+ inParam: localParam
13
+ });
14
+
15
+ const endpoint = getEndpointSpec({
16
+ inSource: localSource,
17
+ inRoutePath: localRoutePath
18
+ });
19
+
20
+ return await dispatchTally({
21
+ inEndpoint: endpoint,
22
+ inParam: param,
23
+ inArgs: localArgs
24
+ });
25
+ };
26
+
27
+ export default startFunc;
@@ -0,0 +1,13 @@
1
+ import { XMLParser } from "fast-xml-parser";
2
+
3
+ const startFunc = ({ inXml }) => {
4
+ const localXml = inXml;
5
+
6
+ const parser = new XMLParser({
7
+ ignoreAttributes: false
8
+ });
9
+
10
+ return parser.parse(localXml);
11
+ };
12
+
13
+ export default startFunc;
@@ -0,0 +1,42 @@
1
+ const collectionTemplate = `<ENVELOPE>
2
+ <HEADER>
3
+ <VERSION>1</VERSION>
4
+ <TALLYREQUEST>Export</TALLYREQUEST>
5
+ <TYPE>Collection</TYPE>
6
+ <ID>TDLID</ID>
7
+ </HEADER>
8
+ <BODY>
9
+ <DESC>
10
+ <STATICVARIABLES>
11
+ <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
12
+ {{STATICVARIABLES}}
13
+ </STATICVARIABLES>
14
+ <TDL>
15
+ <TDLMESSAGE>
16
+ <COLLECTION NAME="TDLID">
17
+ {{TDLMESSAGE}}
18
+ </COLLECTION>
19
+ </TDLMESSAGE>
20
+ </TDL>
21
+ </DESC>
22
+ </BODY>
23
+ </ENVELOPE>`;
24
+
25
+ const dataTemplate = `<ENVELOPE>
26
+ <HEADER>
27
+ <VERSION>1</VERSION>
28
+ <TALLYREQUEST>Export</TALLYREQUEST>
29
+ <TYPE>Data</TYPE>
30
+ <ID>{{ID}}</ID>
31
+ </HEADER>
32
+ <BODY>
33
+ <DESC>
34
+ <STATICVARIABLES>
35
+ <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
36
+ {{STATICVARIABLES}}
37
+ </STATICVARIABLES>
38
+ </DESC>
39
+ </BODY>
40
+ </ENVELOPE>`;
41
+
42
+ export { collectionTemplate, dataTemplate };
@@ -0,0 +1,16 @@
1
+ const startFunc = async ({ inXml, inUrl }) => {
2
+ const localXml = inXml;
3
+ const localUrl = inUrl || "http://localhost:9000";
4
+
5
+ const response = await fetch(localUrl, {
6
+ method: "POST",
7
+ headers: {
8
+ "Content-Type": "text/xml"
9
+ },
10
+ body: localXml
11
+ });
12
+
13
+ return await response.text();
14
+ };
15
+
16
+ export default startFunc;
@@ -0,0 +1,19 @@
1
+ const startFunc = ({ inParam }) => {
2
+ const localParam = inParam;
3
+
4
+ if (localParam === undefined || localParam === null) {
5
+ return "";
6
+ }
7
+
8
+ if (typeof localParam === "string") {
9
+ return localParam.trim();
10
+ }
11
+
12
+ if (typeof localParam === "object") {
13
+ return localParam;
14
+ }
15
+
16
+ return String(localParam);
17
+ };
18
+
19
+ export default startFunc;
@@ -0,0 +1,8 @@
1
+ import apiTree from "@keshavsoft/api-tree";
2
+ import { source, apiPaths } from "tally-spec";
3
+
4
+ import execute from "./engine/execution/index.js";
5
+
6
+ const app = apiTree(source, apiPaths, execute);
7
+
8
+ export default app;