tally-simple 1.3.1 → 1.8.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/README.md +132 -83
- package/bin/tally-simple.js +2 -7
- package/docs/.nojekyll +1 -0
- package/docs/architecture.html +67 -68
- package/docs/architecture.md +74 -57
- package/docs/execution-pipeline.html +71 -0
- package/docs/execution-pipeline.md +158 -0
- package/docs/index.html +288 -26
- package/docs/queries.html +107 -0
- package/docs/queries.md +122 -0
- package/docs/route-engine.html +57 -0
- package/docs/route-engine.md +141 -0
- package/docs/style.css +137 -0
- package/docs/usage.html +82 -0
- package/docs/usage.md +117 -0
- package/package.json +14 -8
- package/src/index.js +2 -8
- package/src/v5/external-api/api.js +21 -0
- package/src/{v3 → v5}/external-api/api.json +1 -1
- package/src/v5/index.js +1 -0
- package/src/v5/internal-working/execution/buildXmlBody.js +41 -0
- package/src/v5/internal-working/execution/getTdl.js +12 -0
- package/src/v5/internal-working/execution/index.js +30 -0
- package/src/v5/internal-working/execution/postHttp.js +26 -0
- package/src/v5/internal-working/execution/validateCompany.js +11 -0
- package/src/v5/internal-working/route/attachPath.js +25 -0
- package/src/v5/internal-working/route/createLeafHandler.js +17 -0
- package/src/v5/internal-working/route/index.js +24 -0
- package/src/{v3 → v5}/source.json +1 -11
- package/src/v6/external-api/api.js +21 -0
- package/src/v6/external-api/api.json +6 -0
- package/src/v6/index.js +1 -0
- package/src/v6/internal-working/execution/buildXmlBody.js +41 -0
- package/src/v6/internal-working/execution/getTdl.js +12 -0
- package/src/v6/internal-working/execution/index.js +30 -0
- package/src/v6/internal-working/execution/postHttp.js +26 -0
- package/src/v6/internal-working/execution/validateCompany.js +11 -0
- package/src/v6/internal-working/route/attachPath.js +25 -0
- package/src/v6/internal-working/route/createLeafHandler.js +17 -0
- package/src/v6/internal-working/route/index.js +24 -0
- package/src/{v2 → v6}/source.json +8 -10
- package/src/v7/api.json +6 -0
- package/src/v7/index.js +14 -0
- package/src/v7/internal-working/execution/buildXmlBody.js +41 -0
- package/src/v7/internal-working/execution/getTdl.js +12 -0
- package/src/v7/internal-working/execution/index.js +30 -0
- package/src/v7/internal-working/execution/postHttp.js +26 -0
- package/src/v7/internal-working/execution/validateCompany.js +11 -0
- package/src/v7/internal-working/route/attachPath.js +25 -0
- package/src/v7/internal-working/route/createLeafHandler.js +17 -0
- package/src/v7/internal-working/route/index.js +24 -0
- package/src/{v1 → v7}/source.json +8 -10
- package/src/v8/engine/index.js +18 -0
- package/src/v8/engine/parseXml.js +11 -0
- package/src/v8/index.js +21 -0
- package/docs/api.html +0 -41
- package/docs/api.md +0 -20
- package/docs/developer.html +0 -57
- package/docs/developer.md +0 -41
- package/docs/end-user.html +0 -49
- package/docs/end-user.md +0 -34
- package/docs/repo-developer.html +0 -91
- package/docs/repo-developer.md +0 -107
- package/src/index.d.ts +0 -54
- package/src/v1/external-api/api.js +0 -67
- package/src/v1/external-api/api.json +0 -5
- package/src/v1/external-api/index.js +0 -1
- package/src/v1/index.js +0 -1
- package/src/v1/traverse.js +0 -103
- package/src/v1/traverseObject/index.js +0 -39
- package/src/v2/external-api/api.js +0 -67
- package/src/v2/external-api/api.json +0 -5
- package/src/v2/external-api/index.js +0 -1
- package/src/v2/index.js +0 -1
- package/src/v2/traverse.js +0 -103
- package/src/v2/traverseObject/index.js +0 -39
- package/src/v3/external-api/api.js +0 -67
- package/src/v3/external-api/index.js +0 -1
- package/src/v3/index.js +0 -1
- package/src/v3/traverse.js +0 -103
- package/src/v3/traverseObject/index.js +0 -39
|
@@ -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,17 @@
|
|
|
1
|
+
const startFunc = ({ inPath, inSource, inExecutor }) => {
|
|
2
|
+
const localPath = inPath;
|
|
3
|
+
const localSource = inSource;
|
|
4
|
+
const localExecutor = inExecutor;
|
|
5
|
+
|
|
6
|
+
return async (inCompany) => {
|
|
7
|
+
const localCompany = inCompany;
|
|
8
|
+
|
|
9
|
+
return await localExecutor({
|
|
10
|
+
inRoutePath: localPath,
|
|
11
|
+
inCompany: localCompany,
|
|
12
|
+
inSource: localSource
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
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;
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"tally": {
|
|
3
|
-
"connection": {
|
|
4
|
-
"url": "http://localhost:9000",
|
|
5
|
-
"method": "POST",
|
|
6
|
-
"headers": {
|
|
7
|
-
"Content-Type": "text/xml"
|
|
8
|
-
}
|
|
9
|
-
},
|
|
10
|
-
"request": {
|
|
11
|
-
"body": "<ENVELOPE>\n<HEADER>\n<VERSION>1</VERSION>\n<TALLYREQUEST>Export</TALLYREQUEST>\n<TYPE>Collection</TYPE>\n<ID>TDLID</ID>\n</HEADER>\n<BODY>\n<DESC>\n<STATICVARIABLES>\n<SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>\n<SVCURRENTCOMPANY>{company}</SVCURRENTCOMPANY>\n</STATICVARIABLES>\n<TDL>\n<TDLMESSAGE>\n<COLLECTION NAME=\"TDLID\">\n{collectionBody}</COLLECTION>\n</TDLMESSAGE>\n</TDL>\n</DESC>\n</BODY>\n</ENVELOPE>"
|
|
12
|
-
},
|
|
13
3
|
"masters": {
|
|
14
4
|
"units": {
|
|
15
5
|
"fetch": {
|
|
@@ -34,6 +24,14 @@
|
|
|
34
24
|
},
|
|
35
25
|
"action": "fetch"
|
|
36
26
|
}
|
|
27
|
+
},
|
|
28
|
+
"stockGroup": {
|
|
29
|
+
"withParent": {
|
|
30
|
+
"tdl": {
|
|
31
|
+
"collection": "<TYPE>StockGroup</TYPE><FETCH>$$Alias:Name</FETCH><FETCH>Parent</FETCH>"
|
|
32
|
+
},
|
|
33
|
+
"action": "fetch"
|
|
34
|
+
}
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { call } from "tally-simple-json";
|
|
2
|
+
import transform from "@keshavsoft/json-transformer";
|
|
3
|
+
|
|
4
|
+
const startFunc = async ({ inRoutePath, inParam, inSource, inLeafSpec }) => {
|
|
5
|
+
const localRoutePath = inRoutePath;
|
|
6
|
+
const localParam = inParam;
|
|
7
|
+
const localSource = inSource;
|
|
8
|
+
const localLeafSpec = inLeafSpec;
|
|
9
|
+
|
|
10
|
+
const rawResponse = await call(localRoutePath,
|
|
11
|
+
localParam);
|
|
12
|
+
const jsonNeeded = rawResponse?.ENVELOPE?.BODY?.DATA?.COLLECTION;
|
|
13
|
+
const transformedResponse = transform(jsonNeeded, localLeafSpec?.transform?.instructions);
|
|
14
|
+
// console.log("localSource: ", jsonNeeded, localLeafSpec?.transform?.instructions, transformedResponse);
|
|
15
|
+
return transformedResponse;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default startFunc;
|
package/src/v8/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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 tree = apiTree(source, apiPaths, execute);
|
|
7
|
+
const app = tree.tally ?? tree;
|
|
8
|
+
|
|
9
|
+
// Keep the package's historical root API while retaining the explicit
|
|
10
|
+
// `app.tally` form exposed by @keshavsoft/api-tree.
|
|
11
|
+
if (!app.tally) {
|
|
12
|
+
Object.defineProperty(app, "tally", {
|
|
13
|
+
value: app,
|
|
14
|
+
enumerable: false
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const call = createCaller({ inSource: source, inExecutor: execute });
|
|
19
|
+
|
|
20
|
+
export default app;
|
|
21
|
+
export { app, call };
|
package/docs/api.html
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
-
<title>Api</title>
|
|
7
|
-
<style>
|
|
8
|
-
body{font-family:system-ui,-apple-system,Segoe UI,Arial,sans-serif;max-width:900px;margin:40px auto;padding:0 24px;line-height:1.65;color:#202124}
|
|
9
|
-
nav{padding:12px 16px;margin-bottom:28px;background:#f5f5f5;border-radius:8px}
|
|
10
|
-
nav a{margin-right:16px;text-decoration:none}
|
|
11
|
-
h1{font-size:30px;margin-top:0}
|
|
12
|
-
h2{font-size:22px;margin-top:32px}
|
|
13
|
-
h3{font-size:18px;margin-top:24px}
|
|
14
|
-
pre{background:#f6f8fa;padding:16px;border-radius:8px;overflow:auto}
|
|
15
|
-
code{background:#f1f3f4;padding:2px 5px;border-radius:4px}
|
|
16
|
-
pre code{background:none;padding:0}
|
|
17
|
-
table{border-collapse:collapse;width:100%;margin:16px 0}
|
|
18
|
-
th,td{border:1px solid #ddd;padding:8px;text-align:left}
|
|
19
|
-
th{background:#f6f6f6}
|
|
20
|
-
a{color:#0969da}
|
|
21
|
-
</style>
|
|
22
|
-
</head>
|
|
23
|
-
<body>
|
|
24
|
-
<nav>
|
|
25
|
-
<a href="../README.html">README</a>
|
|
26
|
-
<a href="end-user.html">End User</a>
|
|
27
|
-
<a href="developer.html">Application Developer</a>
|
|
28
|
-
<a href="repo-developer.html">Repository Developer</a>
|
|
29
|
-
<a href="api.html">API</a>
|
|
30
|
-
<a href="architecture.html">Architecture</a>
|
|
31
|
-
</nav>
|
|
32
|
-
<h1>API Reference</h1>
|
|
33
|
-
<p>The public API is generated from <code>src/v1/external-api/api.json</code>.</p>
|
|
34
|
-
<p>Current public paths:</p>
|
|
35
|
-
<pre><code>tally.masters.units.fetch
|
|
36
|
-
tally.masters.stockItems.withBatches</code></pre>
|
|
37
|
-
<p>Example:</p>
|
|
38
|
-
<pre><code>await tally.masters.units.fetch("Mani9");</code></pre>
|
|
39
|
-
<p>The exact public surface should be changed through <code>external-api/api.json</code>, followed by declaration generation.</p>
|
|
40
|
-
</body>
|
|
41
|
-
</html>
|
package/docs/api.md
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
[**View this document as HTML**](./api.html)
|
|
2
|
-
|
|
3
|
-
# API Reference
|
|
4
|
-
|
|
5
|
-
The public API is generated from `src/v1/external-api/api.json`.
|
|
6
|
-
|
|
7
|
-
Current public paths:
|
|
8
|
-
|
|
9
|
-
```text
|
|
10
|
-
tally.masters.units.fetch
|
|
11
|
-
tally.masters.stockItems.withBatches
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
Example:
|
|
15
|
-
|
|
16
|
-
```js
|
|
17
|
-
await tally.masters.units.fetch("Mani9");
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
The exact public surface should be changed through `external-api/api.json`, followed by declaration generation.
|
package/docs/developer.html
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
-
<title>Developer</title>
|
|
7
|
-
<style>
|
|
8
|
-
body{font-family:system-ui,-apple-system,Segoe UI,Arial,sans-serif;max-width:900px;margin:40px auto;padding:0 24px;line-height:1.65;color:#202124}
|
|
9
|
-
nav{padding:12px 16px;margin-bottom:28px;background:#f5f5f5;border-radius:8px}
|
|
10
|
-
nav a{margin-right:16px;text-decoration:none}
|
|
11
|
-
h1{font-size:30px;margin-top:0}
|
|
12
|
-
h2{font-size:22px;margin-top:32px}
|
|
13
|
-
h3{font-size:18px;margin-top:24px}
|
|
14
|
-
pre{background:#f6f8fa;padding:16px;border-radius:8px;overflow:auto}
|
|
15
|
-
code{background:#f1f3f4;padding:2px 5px;border-radius:4px}
|
|
16
|
-
pre code{background:none;padding:0}
|
|
17
|
-
table{border-collapse:collapse;width:100%;margin:16px 0}
|
|
18
|
-
th,td{border:1px solid #ddd;padding:8px;text-align:left}
|
|
19
|
-
th{background:#f6f6f6}
|
|
20
|
-
a{color:#0969da}
|
|
21
|
-
</style>
|
|
22
|
-
</head>
|
|
23
|
-
<body>
|
|
24
|
-
<nav>
|
|
25
|
-
<a href="../README.html">README</a>
|
|
26
|
-
<a href="end-user.html">End User</a>
|
|
27
|
-
<a href="developer.html">Application Developer</a>
|
|
28
|
-
<a href="repo-developer.html">Repository Developer</a>
|
|
29
|
-
<a href="api.html">API</a>
|
|
30
|
-
<a href="architecture.html">Architecture</a>
|
|
31
|
-
</nav>
|
|
32
|
-
<h1>Application Developer Guide</h1>
|
|
33
|
-
<p>This guide is for developers consuming Tally Public API from another application.</p>
|
|
34
|
-
<h2>Public boundary</h2>
|
|
35
|
-
<p>The consumer sees a tree-shaped JavaScript API:</p>
|
|
36
|
-
<pre><code>const result = await tally.masters.units.fetch("Mani9");</code></pre>
|
|
37
|
-
<p>The consumer does not need to know:</p>
|
|
38
|
-
<ul>
|
|
39
|
-
<li>the internal source JSON structure;</li>
|
|
40
|
-
<ul>
|
|
41
|
-
<li>the TDL request template;</li>
|
|
42
|
-
<ul>
|
|
43
|
-
<li>how traversal finds the definition;</li>
|
|
44
|
-
<ul>
|
|
45
|
-
<li>how the HTTP request is constructed.</li>
|
|
46
|
-
<h2>Company name</h2>
|
|
47
|
-
<p>The company is runtime input.</p>
|
|
48
|
-
<pre><code>await tally.masters.units.fetch("Mani9");
|
|
49
|
-
await tally.masters.units.fetch("Another Company");</code></pre>
|
|
50
|
-
<p>The company should therefore not be permanently embedded in the source definition.</p>
|
|
51
|
-
<h2>CLI / scripting</h2>
|
|
52
|
-
<p>The same public operation can be exposed through a CLI layer without duplicating the Tally definition.</p>
|
|
53
|
-
<h2>Response</h2>
|
|
54
|
-
<p>The package returns the Tally response body. XML parsing and application-specific normalization remain outside this package.</p>
|
|
55
|
-
<p>For the internal architecture, see <a href="repo-developer.md">Repository Developer Guide</a>.</p>
|
|
56
|
-
</body>
|
|
57
|
-
</html>
|
package/docs/developer.md
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
[**View this document as HTML**](./developer.html)
|
|
2
|
-
|
|
3
|
-
# Application Developer Guide
|
|
4
|
-
|
|
5
|
-
This guide is for developers consuming Tally Public API from another application.
|
|
6
|
-
|
|
7
|
-
## Public boundary
|
|
8
|
-
|
|
9
|
-
The consumer sees a tree-shaped JavaScript API:
|
|
10
|
-
|
|
11
|
-
```js
|
|
12
|
-
const result = await tally.masters.units.fetch("Mani9");
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
The consumer does not need to know:
|
|
16
|
-
|
|
17
|
-
- the internal source JSON structure;
|
|
18
|
-
- the TDL request template;
|
|
19
|
-
- how traversal finds the definition;
|
|
20
|
-
- how the HTTP request is constructed.
|
|
21
|
-
|
|
22
|
-
## Company name
|
|
23
|
-
|
|
24
|
-
The company is runtime input.
|
|
25
|
-
|
|
26
|
-
```js
|
|
27
|
-
await tally.masters.units.fetch("Mani9");
|
|
28
|
-
await tally.masters.units.fetch("Another Company");
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
The company should therefore not be permanently embedded in the source definition.
|
|
32
|
-
|
|
33
|
-
## CLI / scripting
|
|
34
|
-
|
|
35
|
-
The same public operation can be exposed through a CLI layer without duplicating the Tally definition.
|
|
36
|
-
|
|
37
|
-
## Response
|
|
38
|
-
|
|
39
|
-
The package returns the Tally response body. XML parsing and application-specific normalization remain outside this package.
|
|
40
|
-
|
|
41
|
-
For the internal architecture, see [Repository Developer Guide](repo-developer.md).
|
package/docs/end-user.html
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
-
<title>End User</title>
|
|
7
|
-
<style>
|
|
8
|
-
body{font-family:system-ui,-apple-system,Segoe UI,Arial,sans-serif;max-width:900px;margin:40px auto;padding:0 24px;line-height:1.65;color:#202124}
|
|
9
|
-
nav{padding:12px 16px;margin-bottom:28px;background:#f5f5f5;border-radius:8px}
|
|
10
|
-
nav a{margin-right:16px;text-decoration:none}
|
|
11
|
-
h1{font-size:30px;margin-top:0}
|
|
12
|
-
h2{font-size:22px;margin-top:32px}
|
|
13
|
-
h3{font-size:18px;margin-top:24px}
|
|
14
|
-
pre{background:#f6f8fa;padding:16px;border-radius:8px;overflow:auto}
|
|
15
|
-
code{background:#f1f3f4;padding:2px 5px;border-radius:4px}
|
|
16
|
-
pre code{background:none;padding:0}
|
|
17
|
-
table{border-collapse:collapse;width:100%;margin:16px 0}
|
|
18
|
-
th,td{border:1px solid #ddd;padding:8px;text-align:left}
|
|
19
|
-
th{background:#f6f6f6}
|
|
20
|
-
a{color:#0969da}
|
|
21
|
-
</style>
|
|
22
|
-
</head>
|
|
23
|
-
<body>
|
|
24
|
-
<nav>
|
|
25
|
-
<a href="../README.html">README</a>
|
|
26
|
-
<a href="end-user.html">End User</a>
|
|
27
|
-
<a href="developer.html">Application Developer</a>
|
|
28
|
-
<a href="repo-developer.html">Repository Developer</a>
|
|
29
|
-
<a href="api.html">API</a>
|
|
30
|
-
<a href="architecture.html">Architecture</a>
|
|
31
|
-
</nav>
|
|
32
|
-
<h1>End User Guide</h1>
|
|
33
|
-
<p>This guide is for someone who wants to use the Tally package, not modify it.</p>
|
|
34
|
-
<h2>JavaScript</h2>
|
|
35
|
-
<pre><code>import tally from "./src/index.js";
|
|
36
|
-
|
|
37
|
-
const units = await tally.masters.units.fetch("Mani9");
|
|
38
|
-
console.log(units);</code></pre>
|
|
39
|
-
<p>The company name is supplied by the caller:</p>
|
|
40
|
-
<pre><code>tally.masters.units.fetch("My Company");</code></pre>
|
|
41
|
-
<p>The package builds the Tally request internally.</p>
|
|
42
|
-
<h2>What you receive</h2>
|
|
43
|
-
<p>The Tally response is returned as XML text. This package does not force an XML-to-JSON format on the consumer.</p>
|
|
44
|
-
<p>You can parse or transform the response with the tool you prefer.</p>
|
|
45
|
-
<h2>Public API</h2>
|
|
46
|
-
<p>See <a href="api.md">API Reference</a> for the currently exposed operations.</p>
|
|
47
|
-
<p>If you are integrating this package into a larger application, continue with the <a href="developer.md">Application Developer Guide</a>.</p>
|
|
48
|
-
</body>
|
|
49
|
-
</html>
|
package/docs/end-user.md
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
[**View this document as HTML**](./end-user.html)
|
|
2
|
-
|
|
3
|
-
# End User Guide
|
|
4
|
-
|
|
5
|
-
This guide is for someone who wants to use the Tally package, not modify it.
|
|
6
|
-
|
|
7
|
-
## JavaScript
|
|
8
|
-
|
|
9
|
-
```js
|
|
10
|
-
import tally from "./src/index.js";
|
|
11
|
-
|
|
12
|
-
const units = await tally.masters.units.fetch("Mani9");
|
|
13
|
-
console.log(units);
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
The company name is supplied by the caller:
|
|
17
|
-
|
|
18
|
-
```js
|
|
19
|
-
tally.masters.units.fetch("My Company");
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
The package builds the Tally request internally.
|
|
23
|
-
|
|
24
|
-
## What you receive
|
|
25
|
-
|
|
26
|
-
The Tally response is returned as XML text. This package does not force an XML-to-JSON format on the consumer.
|
|
27
|
-
|
|
28
|
-
You can parse or transform the response with the tool you prefer.
|
|
29
|
-
|
|
30
|
-
## Public API
|
|
31
|
-
|
|
32
|
-
See [API Reference](api.md) for the currently exposed operations.
|
|
33
|
-
|
|
34
|
-
If you are integrating this package into a larger application, continue with the [Application Developer Guide](developer.md).
|
package/docs/repo-developer.html
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
-
<title>Repo Developer</title>
|
|
7
|
-
<style>
|
|
8
|
-
body{font-family:system-ui,-apple-system,Segoe UI,Arial,sans-serif;max-width:900px;margin:40px auto;padding:0 24px;line-height:1.65;color:#202124}
|
|
9
|
-
nav{padding:12px 16px;margin-bottom:28px;background:#f5f5f5;border-radius:8px}
|
|
10
|
-
nav a{margin-right:16px;text-decoration:none}
|
|
11
|
-
h1{font-size:30px;margin-top:0}
|
|
12
|
-
h2{font-size:22px;margin-top:32px}
|
|
13
|
-
h3{font-size:18px;margin-top:24px}
|
|
14
|
-
pre{background:#f6f8fa;padding:16px;border-radius:8px;overflow:auto}
|
|
15
|
-
code{background:#f1f3f4;padding:2px 5px;border-radius:4px}
|
|
16
|
-
pre code{background:none;padding:0}
|
|
17
|
-
table{border-collapse:collapse;width:100%;margin:16px 0}
|
|
18
|
-
th,td{border:1px solid #ddd;padding:8px;text-align:left}
|
|
19
|
-
th{background:#f6f6f6}
|
|
20
|
-
a{color:#0969da}
|
|
21
|
-
</style>
|
|
22
|
-
</head>
|
|
23
|
-
<body>
|
|
24
|
-
<nav>
|
|
25
|
-
<a href="../README.html">README</a>
|
|
26
|
-
<a href="end-user.html">End User</a>
|
|
27
|
-
<a href="developer.html">Application Developer</a>
|
|
28
|
-
<a href="repo-developer.html">Repository Developer</a>
|
|
29
|
-
<a href="api.html">API</a>
|
|
30
|
-
<a href="architecture.html">Architecture</a>
|
|
31
|
-
</nav>
|
|
32
|
-
<h1>Repository Developer Guide</h1>
|
|
33
|
-
<p>This guide is for developers who change the repository itself.</p>
|
|
34
|
-
<h2>Source of truth</h2>
|
|
35
|
-
<p>The active version contains the Tally definitions:</p>
|
|
36
|
-
<pre><code>src/
|
|
37
|
-
└── v1/
|
|
38
|
-
├── source.json
|
|
39
|
-
├── traverse.js
|
|
40
|
-
├── traverseObject/
|
|
41
|
-
├── external-api/
|
|
42
|
-
│ ├── api.json
|
|
43
|
-
│ ├── api.js
|
|
44
|
-
│ └── index.js
|
|
45
|
-
└── index.js</code></pre>
|
|
46
|
-
<p><code>source.json</code> contains the internal request definitions.</p>
|
|
47
|
-
<p><code>external-api/api.json</code> contains only the public paths.</p>
|
|
48
|
-
<p>That separation is intentional.</p>
|
|
49
|
-
<h2>Adding a public operation</h2>
|
|
50
|
-
<p>1. Add or change the internal TDL definition in <code>source.json</code>.</p>
|
|
51
|
-
<p>2. Add its public path to <code>external-api/api.json</code>.</p>
|
|
52
|
-
<p>3. Regenerate <code>src/index.d.ts</code>.</p>
|
|
53
|
-
<p>4. Test the public call.</p>
|
|
54
|
-
<p>5. Leave older source versions untouched.</p>
|
|
55
|
-
<h2>Company input</h2>
|
|
56
|
-
<p>Do not hardcode a real company name into the public definition.</p>
|
|
57
|
-
<p>The caller supplies the company:</p>
|
|
58
|
-
<pre><code>tally.masters.units.fetch("Mani9");</code></pre>
|
|
59
|
-
<p>The runtime passes that value into the request builder.</p>
|
|
60
|
-
<h2>Traversal</h2>
|
|
61
|
-
<p>Traversal should remain generic.</p>
|
|
62
|
-
<p>Its job is to locate the requested definition.</p>
|
|
63
|
-
<p>The action/request layer interprets the terminal definition and performs the Tally HTTP request.</p>
|
|
64
|
-
<p>Avoid putting endpoint-specific paths directly into the traversal engine.</p>
|
|
65
|
-
<h2>Versioning</h2>
|
|
66
|
-
<p>When a new implementation is required:</p>
|
|
67
|
-
<pre><code>src/v1
|
|
68
|
-
src/v2
|
|
69
|
-
src/v3</code></pre>
|
|
70
|
-
<p>Create the next version and make the root <code>src/index.js</code> point to the highest active version.</p>
|
|
71
|
-
<p>Do not rewrite old versions merely to keep them visually consistent.</p>
|
|
72
|
-
<h2>Declaration generation</h2>
|
|
73
|
-
<p>The generated declaration file represents the public API tree.</p>
|
|
74
|
-
<p>It should be generated from the public API definition rather than manually maintained.</p>
|
|
75
|
-
<pre><code>node generate-dts.js</code></pre>
|
|
76
|
-
<h2>Testing</h2>
|
|
77
|
-
<p>Test both:</p>
|
|
78
|
-
<p>1. the public JavaScript API;</p>
|
|
79
|
-
<p>2. the generated request sent to Tally.</p>
|
|
80
|
-
<p>Keep Tally-specific request definitions in JSON where possible so adding another operation is primarily a data change rather than a new JavaScript module.</p>
|
|
81
|
-
<h2>Design boundary</h2>
|
|
82
|
-
<p>The repository deliberately has three layers:</p>
|
|
83
|
-
<pre><code>public API
|
|
84
|
-
↓
|
|
85
|
-
traversal / execution
|
|
86
|
-
↓
|
|
87
|
-
source JSON</code></pre>
|
|
88
|
-
<p>The public consumer sees the first layer.</p>
|
|
89
|
-
<p>The repository developer maintains all three.</p>
|
|
90
|
-
</body>
|
|
91
|
-
</html>
|
package/docs/repo-developer.md
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
[**View this document as HTML**](./repo-developer.html)
|
|
2
|
-
|
|
3
|
-
# Repository Developer Guide
|
|
4
|
-
|
|
5
|
-
This guide is for developers who change the repository itself.
|
|
6
|
-
|
|
7
|
-
## Source of truth
|
|
8
|
-
|
|
9
|
-
The active version contains the Tally definitions:
|
|
10
|
-
|
|
11
|
-
```text
|
|
12
|
-
src/
|
|
13
|
-
└── v1/
|
|
14
|
-
├── source.json
|
|
15
|
-
├── traverse.js
|
|
16
|
-
├── traverseObject/
|
|
17
|
-
├── external-api/
|
|
18
|
-
│ ├── api.json
|
|
19
|
-
│ ├── api.js
|
|
20
|
-
│ └── index.js
|
|
21
|
-
└── index.js
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
`source.json` contains the internal request definitions.
|
|
25
|
-
|
|
26
|
-
`external-api/api.json` contains only the public paths.
|
|
27
|
-
|
|
28
|
-
That separation is intentional.
|
|
29
|
-
|
|
30
|
-
## Adding a public operation
|
|
31
|
-
|
|
32
|
-
1. Add or change the internal TDL definition in `source.json`.
|
|
33
|
-
2. Add its public path to `external-api/api.json`.
|
|
34
|
-
3. Regenerate `src/index.d.ts`.
|
|
35
|
-
4. Test the public call.
|
|
36
|
-
5. Leave older source versions untouched.
|
|
37
|
-
|
|
38
|
-
## Company input
|
|
39
|
-
|
|
40
|
-
Do not hardcode a real company name into the public definition.
|
|
41
|
-
|
|
42
|
-
The caller supplies the company:
|
|
43
|
-
|
|
44
|
-
```js
|
|
45
|
-
tally.masters.units.fetch("Mani9");
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
The runtime passes that value into the request builder.
|
|
49
|
-
|
|
50
|
-
## Traversal
|
|
51
|
-
|
|
52
|
-
Traversal should remain generic.
|
|
53
|
-
|
|
54
|
-
Its job is to locate the requested definition.
|
|
55
|
-
|
|
56
|
-
The action/request layer interprets the terminal definition and performs the Tally HTTP request.
|
|
57
|
-
|
|
58
|
-
Avoid putting endpoint-specific paths directly into the traversal engine.
|
|
59
|
-
|
|
60
|
-
## Versioning
|
|
61
|
-
|
|
62
|
-
When a new implementation is required:
|
|
63
|
-
|
|
64
|
-
```text
|
|
65
|
-
src/v1
|
|
66
|
-
src/v2
|
|
67
|
-
src/v3
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Create the next version and make the root `src/index.js` point to the highest active version.
|
|
71
|
-
|
|
72
|
-
Do not rewrite old versions merely to keep them visually consistent.
|
|
73
|
-
|
|
74
|
-
## Declaration generation
|
|
75
|
-
|
|
76
|
-
The generated declaration file represents the public API tree.
|
|
77
|
-
|
|
78
|
-
It should be generated from the public API definition rather than manually maintained.
|
|
79
|
-
|
|
80
|
-
```bash
|
|
81
|
-
node generate-dts.js
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## Testing
|
|
85
|
-
|
|
86
|
-
Test both:
|
|
87
|
-
|
|
88
|
-
1. the public JavaScript API;
|
|
89
|
-
2. the generated request sent to Tally.
|
|
90
|
-
|
|
91
|
-
Keep Tally-specific request definitions in JSON where possible so adding another operation is primarily a data change rather than a new JavaScript module.
|
|
92
|
-
|
|
93
|
-
## Design boundary
|
|
94
|
-
|
|
95
|
-
The repository deliberately has three layers:
|
|
96
|
-
|
|
97
|
-
```text
|
|
98
|
-
public API
|
|
99
|
-
↓
|
|
100
|
-
traversal / execution
|
|
101
|
-
↓
|
|
102
|
-
source JSON
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
The public consumer sees the first layer.
|
|
106
|
-
|
|
107
|
-
The repository developer maintains all three.
|
package/src/index.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generated from src/v3/external-api/api.json and src/v3/source.json.
|
|
3
|
-
* Do not edit this file directly. Run npm run generate:dts instead.
|
|
4
|
-
*/
|
|
5
|
-
export interface TallyClientOptions {
|
|
6
|
-
/** Tally HTTP endpoint. Defaults to http://localhost:9000. */
|
|
7
|
-
url?: string;
|
|
8
|
-
/** HTTP method used for the Tally request. Defaults to POST. */
|
|
9
|
-
method?: string;
|
|
10
|
-
/** Additional request headers. */
|
|
11
|
-
headers?: Record<string, string>;
|
|
12
|
-
/** Abort the request after this many milliseconds. */
|
|
13
|
-
timeout?: number;
|
|
14
|
-
/** Optional fetch-compatible implementation for tests or adapters. */
|
|
15
|
-
fetch?: (url: string, options: {
|
|
16
|
-
method: string;
|
|
17
|
-
headers: Record<string, string>;
|
|
18
|
-
body: string;
|
|
19
|
-
signal?: unknown;
|
|
20
|
-
}) => Promise<{
|
|
21
|
-
ok: boolean;
|
|
22
|
-
status: number;
|
|
23
|
-
text: () => Promise<string>;
|
|
24
|
-
}>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export type TallyApi = {
|
|
28
|
-
masters: {
|
|
29
|
-
units: {
|
|
30
|
-
/** Runs tally.masters.units.fetch and returns Tally's raw XML response. */
|
|
31
|
-
fetch: (company: string) => Promise<string>;
|
|
32
|
-
};
|
|
33
|
-
stockItems: {
|
|
34
|
-
/** Runs tally.masters.stockItems.withBatches and returns Tally's raw XML response. */
|
|
35
|
-
withBatches: (company: string) => Promise<string>;
|
|
36
|
-
};
|
|
37
|
-
ledgers: {
|
|
38
|
-
/** Runs tally.masters.ledgers.withGstDetails and returns Tally's raw XML response. */
|
|
39
|
-
withGstDetails: (company: string) => Promise<string>;
|
|
40
|
-
};
|
|
41
|
-
stockGroup: {
|
|
42
|
-
/** Runs tally.masters.stockGroup.withParent and returns Tally's raw XML response. */
|
|
43
|
-
withParent: (company: string) => Promise<string>;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/** Create an independently configured Tally client. */
|
|
49
|
-
export declare const createTallyClient: (options?: TallyClientOptions) => TallyApi;
|
|
50
|
-
|
|
51
|
-
/** Default Tally client using the package connection defaults. */
|
|
52
|
-
export declare const tally: TallyApi;
|
|
53
|
-
|
|
54
|
-
export default tally;
|