tally-xml-tdl 1.25.2 → 1.27.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.
Files changed (28) hide show
  1. package/package.json +3 -4
  2. package/src/index.js +2 -3
  3. package/src/v25/engine/{execution → dispatchTally/buildXml}/buildXml.js +3 -12
  4. package/src/v25/engine/{execution/dispatchTally.js → dispatchTally/index.js} +4 -8
  5. package/src/v25/engine/{execution → dispatchTally}/transport.js +2 -2
  6. package/src/v25/engine/{execution/index.js → index.js} +6 -8
  7. package/src/v25/index.js +1 -1
  8. package/src/v26/engine/dispatchTally/buildXml/buildXml.js +45 -0
  9. package/src/v26/engine/dispatchTally/buildXml/templates.js +42 -0
  10. package/src/v26/engine/dispatchTally/index.js +25 -0
  11. package/src/v26/engine/dispatchTally/parseResponse.js +13 -0
  12. package/src/v26/engine/dispatchTally/transport.js +16 -0
  13. package/src/v26/engine/getEndpointSpec/index.js +12 -0
  14. package/src/v26/engine/index.js +25 -0
  15. package/src/v26/engine/validateInput/index.js +19 -0
  16. package/src/v26/index.js +10 -0
  17. package/src/v27/engine/dispatchTally/buildXml/buildXml.js +45 -0
  18. package/src/v27/engine/dispatchTally/buildXml/templates.js +42 -0
  19. package/src/v27/engine/dispatchTally/index.js +20 -0
  20. package/src/v27/engine/dispatchTally/transport.js +16 -0
  21. package/src/v27/engine/getEndpointSpec/index.js +12 -0
  22. package/src/v27/engine/index.js +25 -0
  23. package/src/v27/engine/validateInput/index.js +19 -0
  24. package/src/v27/index.js +10 -0
  25. /package/src/v25/engine/{execution → dispatchTally/buildXml}/templates.js +0 -0
  26. /package/src/v25/engine/{execution → dispatchTally}/parseResponse.js +0 -0
  27. /package/src/v25/engine/{execution/getEndpointSpec.js → getEndpointSpec/index.js} +0 -0
  28. /package/src/v25/engine/{execution/validateInput.js → validateInput/index.js} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tally-xml-tdl",
3
- "version": "1.25.2",
3
+ "version": "1.27.1",
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,8 +30,7 @@
30
30
  "url": "https://github.com/keshavsoft/tally-xml-tdl/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@keshavsoft/api-tree": "^6.1.0",
34
- "fast-xml-parser": "^5.11.1",
33
+ "@keshavsoft/api-tree": "^11.1.1",
35
34
  "tally-spec": "^1.0.0"
36
35
  }
37
- }
36
+ }
package/src/index.js CHANGED
@@ -1,3 +1,2 @@
1
- import app from "./v25/index.js";
2
-
3
- export default app;
1
+ export { default } from "./v27/index.js";
2
+ export * from "./v27/index.js";
@@ -1,9 +1,8 @@
1
1
  import { collectionTemplate, dataTemplate } from "./templates.js";
2
2
 
3
- const startFunc = ({ inEndpoint, inParam, inArgs }) => {
3
+ const startFunc = ({ inEndpoint, inParam }) => {
4
4
  const localEndpoint = inEndpoint;
5
5
  const localParam = inParam;
6
- const localArgs = inArgs || [];
7
6
 
8
7
  if (localEndpoint?.reportId) {
9
8
  let staticVars = "";
@@ -16,11 +15,7 @@ const startFunc = ({ inEndpoint, inParam, inArgs }) => {
16
15
 
17
16
  if (localEndpoint.staticVariables) {
18
17
  staticVars += localEndpoint.staticVariables;
19
- }
20
-
21
- if (localArgs[0] && typeof localArgs[0] === "string") {
22
- staticVars += localArgs[0];
23
- }
18
+ };
24
19
 
25
20
  return dataTemplate
26
21
  .replace("{{ID}}", localEndpoint.reportId)
@@ -38,11 +33,7 @@ const startFunc = ({ inEndpoint, inParam, inArgs }) => {
38
33
  if (localParam.fromDate && localParam.toDate) {
39
34
  staticVars += `<SVFROMDATE TYPE="Date">${localParam.fromDate}</SVFROMDATE><SVTODATE TYPE="Date">${localParam.toDate}</SVTODATE>`;
40
35
  }
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
- }
36
+ };
46
37
 
47
38
  const tdlMessage = localEndpoint?.tdl || "";
48
39
 
@@ -1,22 +1,18 @@
1
- import buildXml from "./buildXml.js";
1
+ import buildXml from "./buildXml/buildXml.js";
2
2
  import transport from "./transport.js";
3
3
  import parseResponse from "./parseResponse.js";
4
4
 
5
- const startFunc = async ({ inEndpoint, inParam, inArgs, inUrl }) => {
5
+ const startFunc = async ({ inEndpoint, inParam }) => {
6
6
  const localEndpoint = inEndpoint;
7
7
  const localParam = inParam;
8
- const localArgs = inArgs;
9
- const localUrl = inUrl;
10
8
 
11
9
  const xml = buildXml({
12
10
  inEndpoint: localEndpoint,
13
- inParam: localParam,
14
- inArgs: localArgs
11
+ inParam: localParam
15
12
  });
16
13
 
17
14
  const rawResponse = await transport({
18
- inXml: xml,
19
- inUrl: localUrl
15
+ inXml: xml
20
16
  });
21
17
 
22
18
  const parsedJson = parseResponse({
@@ -1,6 +1,6 @@
1
- const startFunc = async ({ inXml, inUrl }) => {
1
+ const startFunc = async ({ inXml }) => {
2
2
  const localXml = inXml;
3
- const localUrl = inUrl || "http://localhost:9000";
3
+ const localUrl = "http://localhost:9000";
4
4
 
5
5
  const response = await fetch(localUrl, {
6
6
  method: "POST",
@@ -1,11 +1,10 @@
1
- import validateInput from "./validateInput.js";
2
- import getEndpointSpec from "./getEndpointSpec.js";
3
- import dispatchTally from "./dispatchTally.js";
1
+ import validateInput from "./validateInput/index.js";
2
+ import getEndpointSpec from "./getEndpointSpec/index.js";
3
+ import dispatchTally from "./dispatchTally/index.js";
4
4
 
5
- const startFunc = async ({ inRoutePath, inParam, inArgs, inSource }) => {
5
+ const startFunc = async ({ inRoutePath, inParam, inSource }) => {
6
6
  const localRoutePath = inRoutePath;
7
7
  const localParam = inParam;
8
- const localArgs = inArgs;
9
8
  const localSource = inSource;
10
9
 
11
10
  const param = validateInput({
@@ -19,9 +18,8 @@ const startFunc = async ({ inRoutePath, inParam, inArgs, inSource }) => {
19
18
 
20
19
  return await dispatchTally({
21
20
  inEndpoint: endpoint,
22
- inParam: param,
23
- inArgs: localArgs
21
+ inParam: param
24
22
  });
25
23
  };
26
24
 
27
- export default startFunc;
25
+ export default startFunc;
package/src/v25/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import apiTree from "@keshavsoft/api-tree";
2
2
  import { source, apiPaths } from "tally-spec";
3
3
 
4
- import execute from "./engine/execution/index.js";
4
+ import execute from "./engine/index.js";
5
5
 
6
6
  const app = apiTree(source, apiPaths, execute);
7
7
 
@@ -0,0 +1,45 @@
1
+ import { collectionTemplate, dataTemplate } from "./templates.js";
2
+
3
+ const startFunc = ({ inEndpoint, inParam }) => {
4
+ const localEndpoint = inEndpoint;
5
+ const localParam = inParam;
6
+
7
+ if (localEndpoint?.reportId) {
8
+ let staticVars = "";
9
+
10
+ if (typeof localParam === "string" && localParam.length > 0) {
11
+ staticVars += `<SVCURRENTCOMPANY>${localParam}</SVCURRENTCOMPANY>`;
12
+ } else if (typeof localParam === "object" && localParam?.company) {
13
+ staticVars += `<SVCURRENTCOMPANY>${localParam.company}</SVCURRENTCOMPANY>`;
14
+ }
15
+
16
+ if (localEndpoint.staticVariables) {
17
+ staticVars += localEndpoint.staticVariables;
18
+ };
19
+
20
+ return dataTemplate
21
+ .replace("{{ID}}", localEndpoint.reportId)
22
+ .replace("{{STATICVARIABLES}}", staticVars);
23
+ }
24
+
25
+ let staticVars = "";
26
+
27
+ if (typeof localParam === "string" && localParam.length > 0) {
28
+ staticVars += `<SVCURRENTCOMPANY>${localParam}</SVCURRENTCOMPANY>`;
29
+ } else if (typeof localParam === "object" && localParam) {
30
+ if (localParam.company) {
31
+ staticVars += `<SVCURRENTCOMPANY>${localParam.company}</SVCURRENTCOMPANY>`;
32
+ }
33
+ if (localParam.fromDate && localParam.toDate) {
34
+ staticVars += `<SVFROMDATE TYPE="Date">${localParam.fromDate}</SVFROMDATE><SVTODATE TYPE="Date">${localParam.toDate}</SVTODATE>`;
35
+ }
36
+ };
37
+
38
+ const tdlMessage = localEndpoint?.tdl || "";
39
+
40
+ return collectionTemplate
41
+ .replace("{{STATICVARIABLES}}", staticVars)
42
+ .replace("{{TDLMESSAGE}}", tdlMessage);
43
+ };
44
+
45
+ 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,25 @@
1
+ import buildXml from "./buildXml/buildXml.js";
2
+ import transport from "./transport.js";
3
+ import parseResponse from "./parseResponse.js";
4
+
5
+ const startFunc = async ({ inEndpoint, inParam }) => {
6
+ const localEndpoint = inEndpoint;
7
+ const localParam = inParam;
8
+
9
+ const xml = buildXml({
10
+ inEndpoint: localEndpoint,
11
+ inParam: localParam
12
+ });
13
+
14
+ const rawResponse = await transport({
15
+ inXml: xml
16
+ });
17
+
18
+ const parsedJson = parseResponse({
19
+ inXml: rawResponse
20
+ });
21
+
22
+ return parsedJson;
23
+ };
24
+
25
+ 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,16 @@
1
+ const startFunc = async ({ inXml }) => {
2
+ const localXml = inXml;
3
+ const localUrl = "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,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,25 @@
1
+ import validateInput from "./validateInput/index.js";
2
+ import getEndpointSpec from "./getEndpointSpec/index.js";
3
+ import dispatchTally from "./dispatchTally/index.js";
4
+
5
+ const startFunc = async ({ inRoutePath, inParam, inSource }) => {
6
+ const localRoutePath = inRoutePath;
7
+ const localParam = inParam;
8
+ const localSource = inSource;
9
+
10
+ const param = validateInput({
11
+ inParam: localParam
12
+ });
13
+
14
+ const endpoint = getEndpointSpec({
15
+ inSource: localSource,
16
+ inRoutePath: localRoutePath
17
+ });
18
+
19
+ return await dispatchTally({
20
+ inEndpoint: endpoint,
21
+ inParam: param
22
+ });
23
+ };
24
+
25
+ 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,10 @@
1
+ import apiTree, { createCaller } from "@keshavsoft/api-tree";
2
+ import { source, apiPaths } from "tally-spec";
3
+
4
+ import execute from "./engine/index.js";
5
+
6
+ const app = apiTree(source, apiPaths, execute);
7
+ const call = createCaller({ inSource: source, inExecutor: execute });
8
+
9
+ export default app;
10
+ export { app, call };
@@ -0,0 +1,45 @@
1
+ import { collectionTemplate, dataTemplate } from "./templates.js";
2
+
3
+ const startFunc = ({ inEndpoint, inParam }) => {
4
+ const localEndpoint = inEndpoint;
5
+ const localParam = inParam;
6
+
7
+ if (localEndpoint?.reportId) {
8
+ let staticVars = "";
9
+
10
+ if (typeof localParam === "string" && localParam.length > 0) {
11
+ staticVars += `<SVCURRENTCOMPANY>${localParam}</SVCURRENTCOMPANY>`;
12
+ } else if (typeof localParam === "object" && localParam?.company) {
13
+ staticVars += `<SVCURRENTCOMPANY>${localParam.company}</SVCURRENTCOMPANY>`;
14
+ }
15
+
16
+ if (localEndpoint.staticVariables) {
17
+ staticVars += localEndpoint.staticVariables;
18
+ };
19
+
20
+ return dataTemplate
21
+ .replace("{{ID}}", localEndpoint.reportId)
22
+ .replace("{{STATICVARIABLES}}", staticVars);
23
+ }
24
+
25
+ let staticVars = "";
26
+
27
+ if (typeof localParam === "string" && localParam.length > 0) {
28
+ staticVars += `<SVCURRENTCOMPANY>${localParam}</SVCURRENTCOMPANY>`;
29
+ } else if (typeof localParam === "object" && localParam) {
30
+ if (localParam.company) {
31
+ staticVars += `<SVCURRENTCOMPANY>${localParam.company}</SVCURRENTCOMPANY>`;
32
+ }
33
+ if (localParam.fromDate && localParam.toDate) {
34
+ staticVars += `<SVFROMDATE TYPE="Date">${localParam.fromDate}</SVFROMDATE><SVTODATE TYPE="Date">${localParam.toDate}</SVTODATE>`;
35
+ }
36
+ };
37
+
38
+ const tdlMessage = localEndpoint?.tdl || "";
39
+
40
+ return collectionTemplate
41
+ .replace("{{STATICVARIABLES}}", staticVars)
42
+ .replace("{{TDLMESSAGE}}", tdlMessage);
43
+ };
44
+
45
+ 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,20 @@
1
+ import buildXml from "./buildXml/buildXml.js";
2
+ import transport from "./transport.js";
3
+
4
+ const startFunc = async ({ inEndpoint, inParam }) => {
5
+ const localEndpoint = inEndpoint;
6
+ const localParam = inParam;
7
+
8
+ const xml = buildXml({
9
+ inEndpoint: localEndpoint,
10
+ inParam: localParam
11
+ });
12
+
13
+ const rawResponse = await transport({
14
+ inXml: xml
15
+ });
16
+
17
+ return rawResponse;
18
+ };
19
+
20
+ export default startFunc;
@@ -0,0 +1,16 @@
1
+ const startFunc = async ({ inXml }) => {
2
+ const localXml = inXml;
3
+ const localUrl = "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,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,25 @@
1
+ import validateInput from "./validateInput/index.js";
2
+ import getEndpointSpec from "./getEndpointSpec/index.js";
3
+ import dispatchTally from "./dispatchTally/index.js";
4
+
5
+ const startFunc = async ({ inRoutePath, inParam, inSource }) => {
6
+ const localRoutePath = inRoutePath;
7
+ const localParam = inParam;
8
+ const localSource = inSource;
9
+
10
+ const param = validateInput({
11
+ inParam: localParam
12
+ });
13
+
14
+ const endpoint = getEndpointSpec({
15
+ inSource: localSource,
16
+ inRoutePath: localRoutePath
17
+ });
18
+
19
+ return await dispatchTally({
20
+ inEndpoint: endpoint,
21
+ inParam: param
22
+ });
23
+ };
24
+
25
+ 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,10 @@
1
+ import apiTree, { createCaller } from "@keshavsoft/api-tree";
2
+ import { source, apiPaths } from "tally-spec";
3
+
4
+ import execute from "./engine/index.js";
5
+
6
+ const app = apiTree(source, apiPaths, execute);
7
+ const call = createCaller({ inSource: source, inExecutor: execute });
8
+
9
+ export default app;
10
+ export { app, call };