@keshavsoft/tallyextract 1.1.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.
Files changed (70) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +95 -0
  3. package/index.d.ts +7 -0
  4. package/index.js +1 -0
  5. package/package.json +30 -0
  6. package/src/core/configStore.js +10 -0
  7. package/src/helpers/getLatestVersion.js +15 -0
  8. package/src/scripts/generateSamples.js +57 -0
  9. package/src/scripts/samples/aggregate_count.js +5 -0
  10. package/src/scripts/samples/mutate_deleteWithChecks.js +5 -0
  11. package/src/scripts/samples/mutate_insertAsIs.js +5 -0
  12. package/src/scripts/samples/mutate_insertFlat.js +5 -0
  13. package/src/scripts/samples/mutate_insertGenPk.js +5 -0
  14. package/src/scripts/samples/mutate_insertWithChecks.js +5 -0
  15. package/src/scripts/samples/mutate_updateWithChecks.js +5 -0
  16. package/src/scripts/samples/query_filterByColumns.js +5 -0
  17. package/src/scripts/samples/query_filterByPk.js +5 -0
  18. package/src/scripts/samples/query_findAll.js +5 -0
  19. package/src/scripts/samples/query_findByPk.js +5 -0
  20. package/src/scripts/updateIndex.js +16 -0
  21. package/src/utils/pathBuilder.js +3 -0
  22. package/src/v1/Import/Templates/inventory.json +121 -0
  23. package/src/v1/Import/Templates/ledgers.json +28 -0
  24. package/src/v1/Import/Templates/main.json +224 -0
  25. package/src/v1/Import/Templates/template.json +224 -0
  26. package/src/v1/Import/ledgers.json +8 -0
  27. package/src/v1/Import/staticVariables.json +12 -0
  28. package/src/v1/api/index.js +3 -0
  29. package/src/v1/api/ledger.js +6 -0
  30. package/src/v1/api/stockItems.js +6 -0
  31. package/src/v1/cli.js +11 -0
  32. package/src/v1/config/getSchema.js +20 -0
  33. package/src/v1/core/sendToTally.js +21 -0
  34. package/src/v1/engine/index.js +5 -0
  35. package/src/v1/engine/mutate/delete/deleteBase.js +26 -0
  36. package/src/v1/engine/mutate/delete/deleteWithChecks.js +14 -0
  37. package/src/v1/engine/mutate/index.js +7 -0
  38. package/src/v1/engine/mutate/insert/insertAsIs.js +7 -0
  39. package/src/v1/engine/mutate/insert/insertBase.js +19 -0
  40. package/src/v1/engine/mutate/insert/insertFlat.js +24 -0
  41. package/src/v1/engine/mutate/insert/insertGenPk copy.js +39 -0
  42. package/src/v1/engine/mutate/insert/insertGenPk.js +41 -0
  43. package/src/v1/engine/mutate/insert/insertWithChecks.js +52 -0
  44. package/src/v1/engine/mutate/update/updateBase.js +26 -0
  45. package/src/v1/engine/mutate/update/updateWithChecks.js +18 -0
  46. package/src/v1/engine/query/aggregate/count.js +13 -0
  47. package/src/v1/engine/query/aggregate/index.js +1 -0
  48. package/src/v1/engine/query/filterByColumns.js +18 -0
  49. package/src/v1/engine/query/filterByPk.js +18 -0
  50. package/src/v1/engine/query/findAll.js +14 -0
  51. package/src/v1/engine/query/findByPk.js +18 -0
  52. package/src/v1/engine/query/index.js +8 -0
  53. package/src/v1/helpers/buildMutate.js +28 -0
  54. package/src/v1/helpers/buildQuery.js +27 -0
  55. package/src/v1/helpers/file/read.js +7 -0
  56. package/src/v1/helpers/file/write.js +5 -0
  57. package/src/v1/helpers/pkHelper.js +19 -0
  58. package/src/v1/helpers/validate.js +27 -0
  59. package/src/v1/helpers/validateHelper.js +27 -0
  60. package/src/v1/helpers/validators/default.js +5 -0
  61. package/src/v1/helpers/validators/enum.js +7 -0
  62. package/src/v1/helpers/validators/length.js +11 -0
  63. package/src/v1/helpers/validators/minMax.js +11 -0
  64. package/src/v1/helpers/validators/pattern.js +8 -0
  65. package/src/v1/helpers/validators/required.js +5 -0
  66. package/src/v1/helpers/validators/type.js +15 -0
  67. package/src/v1/helpers/validators/unique.js +8 -0
  68. package/src/v1/index.js +1 -0
  69. package/src/v1/schema/schema.json +133 -0
  70. package/src/v1/utils/readJson.js +6 -0
@@ -0,0 +1,224 @@
1
+ {
2
+ "static_variables": [
3
+ {
4
+ "name": "svVchImportFormat",
5
+ "value": "json"
6
+ },
7
+ {
8
+ "name": "svCurrentCompany",
9
+ "value": "Mani9"
10
+ }
11
+ ],
12
+ "tallymessage": [
13
+ {
14
+ "metadata": {
15
+ "type": "Voucher",
16
+ "vchtype": "Gst Sales E",
17
+ "action": "Create",
18
+ "objview": "Invoice Voucher View"
19
+ },
20
+ "address": [
21
+ {
22
+ "metadata": true,
23
+ "type": "String"
24
+ },
25
+ "Tallarevu"
26
+ ],
27
+ "basicbuyeraddress": [
28
+ {
29
+ "metadata": true,
30
+ "type": "String"
31
+ },
32
+ "Tallarevu"
33
+ ],
34
+ "oldauditentryids": [
35
+ {
36
+ "metadata": true,
37
+ "type": "Number"
38
+ },
39
+ "-1"
40
+ ],
41
+ "date": "20260320",
42
+ "vchstatusdate": "20260320",
43
+ "gstregistrationtype": "Unregistered/Consumer",
44
+ "vatdealertype": "Regular",
45
+ "statename": "Andhra Pradesh",
46
+ "countryofresidence": "India",
47
+ "placeofsupply": "Andhra Pradesh",
48
+ "vouchertypename": "Gst Sales E",
49
+ "classname": "GST",
50
+ "partyname": "{KeshavSoft}",
51
+ "gstregistration": {
52
+ "value": "Andhra Pradesh Registration",
53
+ "taxtype": "GST",
54
+ "taxregistration": "37ABPPN4785P1ZH"
55
+ },
56
+ "cmpgstin": "37ABPPN4785P1ZH",
57
+ "partyledgername": "{KeshavSoft}",
58
+ "basicbuyername": "{KeshavSoft}",
59
+ "cmpgstregistrationtype": "Regular",
60
+ "partymailingname": "{KeshavSoft}",
61
+ "partypincode": "533001",
62
+ "consigneemailingname": "{KeshavSoft}",
63
+ "consigneepincode": "533001",
64
+ "consigneestatename": "Andhra Pradesh",
65
+ "cmpgststate": "Andhra Pradesh",
66
+ "consigneecountryname": "India",
67
+ "basicbasepartyname": "{KeshavSoft}",
68
+ "numberingstyle": "Auto Retain",
69
+ "cstformissuetype": "\u0004 Not Applicable",
70
+ "cstformrecvtype": "\u0004 Not Applicable",
71
+ "fbtpaymenttype": "Default",
72
+ "persistedview": "Invoice Voucher View",
73
+ "vchstatustaxadjustment": "Default",
74
+ "vchstatusvouchertype": "Gst Sales E",
75
+ "vchstatustaxunit": "Andhra Pradesh Registration",
76
+ "vchgstclass": "\u0004 Not Applicable",
77
+ "vchentrymode": "Item Invoice",
78
+ "diffactualqty": false,
79
+ "ismstfromsync": false,
80
+ "isdeleted": false,
81
+ "issecurityonwhenentered": false,
82
+ "asoriginal": false,
83
+ "audited": false,
84
+ "iscommonparty": false,
85
+ "forjobcosting": false,
86
+ "isoptional": false,
87
+ "effectivedate": "20260320",
88
+ "useforexcise": false,
89
+ "isforjobworkin": false,
90
+ "allowconsumption": false,
91
+ "useforinterest": false,
92
+ "useforgainloss": false,
93
+ "useforgodowntransfer": false,
94
+ "useforcompound": false,
95
+ "useforservicetax": false,
96
+ "isreversechargeapplicable": false,
97
+ "issystem": false,
98
+ "isfetchedonly": false,
99
+ "isgstoverridden": false,
100
+ "iscancelled": false,
101
+ "isonhold": false,
102
+ "issummary": false,
103
+ "isecommercesupply": false,
104
+ "isboenotapplicable": false,
105
+ "isgstsecsevenapplicable": false,
106
+ "ignoreeinvvalidation": false,
107
+ "cmpgstisothterritoryassessee": false,
108
+ "partygstisothterritoryassessee": false,
109
+ "irnjsonexported": false,
110
+ "irncancelled": false,
111
+ "ignoregstconflictinmig": false,
112
+ "isopbaltransaction": false,
113
+ "ignoregstformatvalidation": false,
114
+ "iseligibleforitc": true,
115
+ "ignoregstoptionaluncertain": false,
116
+ "updatesummaryvalues": false,
117
+ "isewaybillapplicable": false,
118
+ "isdeletedretained": false,
119
+ "isnull": false,
120
+ "isexcisevoucher": false,
121
+ "excisetaxoverride": false,
122
+ "usefortaxunittransfer": false,
123
+ "isexer1nopoverwrite": false,
124
+ "isexf2nopoverwrite": false,
125
+ "isexer3nopoverwrite": false,
126
+ "ignoreposvalidation": false,
127
+ "exciseopening": false,
128
+ "useforfinalproduction": false,
129
+ "istdsoverridden": false,
130
+ "istcsoverridden": false,
131
+ "istdstcscashvch": false,
132
+ "includeadvpymtvch": false,
133
+ "issubworkscontract": false,
134
+ "isvatoverridden": false,
135
+ "ignoreorigvchdate": false,
136
+ "isvatpaidatcustoms": false,
137
+ "isdeclaredtocustoms": false,
138
+ "vatadvancepayment": false,
139
+ "vatadvpay": false,
140
+ "iscstdelcaredgoodssales": false,
141
+ "isvatrestaxinv": false,
142
+ "isservicetaxoverridden": false,
143
+ "isisdvoucher": false,
144
+ "isexciseoverridden": false,
145
+ "isexcisesupplyvch": false,
146
+ "gstnotexported": false,
147
+ "ignoregstinvalidation": false,
148
+ "isgstrefund": false,
149
+ "ovrdnewaybillapplicability": false,
150
+ "isvatprincipalaccount": false,
151
+ "vchstatusisvchnumused": false,
152
+ "vchgststatusisincluded": true,
153
+ "vchgststatusisuncertain": false,
154
+ "vchgststatusisexcluded": false,
155
+ "vchgststatusisapplicable": true,
156
+ "vchgststatusisgstr2breconciled": false,
157
+ "vchgststatusisgstr2bonlyinportal": false,
158
+ "vchgststatusisgstr2bonlyinbooks": false,
159
+ "vchgststatusisgstr2bmismatch": false,
160
+ "vchgststatusisgstr2bindiffperiod": false,
161
+ "vchgststatusisreteffdateoverrdn": false,
162
+ "vchgststatusisoverrdn": false,
163
+ "vchgststatusisstatindiffdate": false,
164
+ "vchgststatusisretindiffdate": false,
165
+ "vchgststatusmainsectionexcluded": false,
166
+ "vchgststatusisbranchtransferout": false,
167
+ "vchgststatusissystemsummary": false,
168
+ "vchstatusisunregisteredrcm": false,
169
+ "vchstatusisoptional": false,
170
+ "vchstatusiscancelled": false,
171
+ "vchstatusisdeleted": false,
172
+ "vchstatusisopeningbalance": false,
173
+ "vchstatusisfetchedonly": false,
174
+ "vchgststatusisoptionaluncertain": false,
175
+ "vchstatusisreacceptforhsndone": false,
176
+ "vchstatusisreaccephsnsixonedone": true,
177
+ "paymentlinkhasmultiref": false,
178
+ "isshippingwithinstate": false,
179
+ "isoverseastouristtrans": false,
180
+ "isdesignatedzoneparty": false,
181
+ "hascashflow": false,
182
+ "ispostdated": false,
183
+ "usetrackingnumber": false,
184
+ "isinvoice": true,
185
+ "mfgjournal": false,
186
+ "hasdiscounts": false,
187
+ "aspayslip": false,
188
+ "iscostcentre": false,
189
+ "isstxnonrealizedvch": false,
190
+ "isexcisemanufactureron": false,
191
+ "isblankcheque": false,
192
+ "isvoid": false,
193
+ "orderlinestatus": false,
194
+ "vatisagnstcancsales": false,
195
+ "vatispurcexempted": false,
196
+ "isvatrestaxinvoice": false,
197
+ "vatisassesablecalcvch": false,
198
+ "isvatdutypaid": true,
199
+ "isdeliverysameasconsignee": false,
200
+ "isdispatchsameasconsignor": false,
201
+ "isdeletedvchretained": false,
202
+ "vchonlyaddlinfoupdated": false,
203
+ "changevchmode": false,
204
+ "resetirnqrcode": false,
205
+ "vouchernumberseries": "Default",
206
+ "allinventoryentries": [],
207
+ "ledgerentries": [],
208
+ "gst": [
209
+ {
210
+ "purposetype": "GST",
211
+ "stat": [
212
+ {
213
+ "purposetype": "GST",
214
+ "statkey": "\u0004 Auto Stat Number",
215
+ "isfetchedonly": false,
216
+ "isdeleted": false,
217
+ "tallycontentuser": []
218
+ }
219
+ ]
220
+ }
221
+ ]
222
+ }
223
+ ]
224
+ }
@@ -0,0 +1,224 @@
1
+ {
2
+ "static_variables": [
3
+ {
4
+ "name": "svVchImportFormat",
5
+ "value": "json"
6
+ },
7
+ {
8
+ "name": "svCurrentCompany",
9
+ "value": "Mani9"
10
+ }
11
+ ],
12
+ "tallymessage": [
13
+ {
14
+ "metadata": {
15
+ "type": "Voucher",
16
+ "vchtype": "Gst Sales E",
17
+ "action": "Create",
18
+ "objview": "Invoice Voucher View"
19
+ },
20
+ "address": [
21
+ {
22
+ "metadata": true,
23
+ "type": "String"
24
+ },
25
+ "Tallarevu"
26
+ ],
27
+ "basicbuyeraddress": [
28
+ {
29
+ "metadata": true,
30
+ "type": "String"
31
+ },
32
+ "Tallarevu"
33
+ ],
34
+ "oldauditentryids": [
35
+ {
36
+ "metadata": true,
37
+ "type": "Number"
38
+ },
39
+ "-1"
40
+ ],
41
+ "date": "20260320",
42
+ "vchstatusdate": "20260320",
43
+ "gstregistrationtype": "Unregistered/Consumer",
44
+ "vatdealertype": "Regular",
45
+ "statename": "Andhra Pradesh",
46
+ "countryofresidence": "India",
47
+ "placeofsupply": "Andhra Pradesh",
48
+ "vouchertypename": "Gst Sales E",
49
+ "classname": "GST",
50
+ "partyname": "{KeshavSoft}",
51
+ "gstregistration": {
52
+ "value": "Andhra Pradesh Registration",
53
+ "taxtype": "GST",
54
+ "taxregistration": "37ABPPN4785P1ZH"
55
+ },
56
+ "cmpgstin": "37ABPPN4785P1ZH",
57
+ "partyledgername": "{KeshavSoft}",
58
+ "basicbuyername": "{KeshavSoft}",
59
+ "cmpgstregistrationtype": "Regular",
60
+ "partymailingname": "{KeshavSoft}",
61
+ "partypincode": "533001",
62
+ "consigneemailingname": "{KeshavSoft}",
63
+ "consigneepincode": "533001",
64
+ "consigneestatename": "Andhra Pradesh",
65
+ "cmpgststate": "Andhra Pradesh",
66
+ "consigneecountryname": "India",
67
+ "basicbasepartyname": "{KeshavSoft}",
68
+ "numberingstyle": "Auto Retain",
69
+ "cstformissuetype": "\u0004 Not Applicable",
70
+ "cstformrecvtype": "\u0004 Not Applicable",
71
+ "fbtpaymenttype": "Default",
72
+ "persistedview": "Invoice Voucher View",
73
+ "vchstatustaxadjustment": "Default",
74
+ "vchstatusvouchertype": "Gst Sales E",
75
+ "vchstatustaxunit": "Andhra Pradesh Registration",
76
+ "vchgstclass": "\u0004 Not Applicable",
77
+ "vchentrymode": "Item Invoice",
78
+ "diffactualqty": false,
79
+ "ismstfromsync": false,
80
+ "isdeleted": false,
81
+ "issecurityonwhenentered": false,
82
+ "asoriginal": false,
83
+ "audited": false,
84
+ "iscommonparty": false,
85
+ "forjobcosting": false,
86
+ "isoptional": false,
87
+ "effectivedate": "20260320",
88
+ "useforexcise": false,
89
+ "isforjobworkin": false,
90
+ "allowconsumption": false,
91
+ "useforinterest": false,
92
+ "useforgainloss": false,
93
+ "useforgodowntransfer": false,
94
+ "useforcompound": false,
95
+ "useforservicetax": false,
96
+ "isreversechargeapplicable": false,
97
+ "issystem": false,
98
+ "isfetchedonly": false,
99
+ "isgstoverridden": false,
100
+ "iscancelled": false,
101
+ "isonhold": false,
102
+ "issummary": false,
103
+ "isecommercesupply": false,
104
+ "isboenotapplicable": false,
105
+ "isgstsecsevenapplicable": false,
106
+ "ignoreeinvvalidation": false,
107
+ "cmpgstisothterritoryassessee": false,
108
+ "partygstisothterritoryassessee": false,
109
+ "irnjsonexported": false,
110
+ "irncancelled": false,
111
+ "ignoregstconflictinmig": false,
112
+ "isopbaltransaction": false,
113
+ "ignoregstformatvalidation": false,
114
+ "iseligibleforitc": true,
115
+ "ignoregstoptionaluncertain": false,
116
+ "updatesummaryvalues": false,
117
+ "isewaybillapplicable": false,
118
+ "isdeletedretained": false,
119
+ "isnull": false,
120
+ "isexcisevoucher": false,
121
+ "excisetaxoverride": false,
122
+ "usefortaxunittransfer": false,
123
+ "isexer1nopoverwrite": false,
124
+ "isexf2nopoverwrite": false,
125
+ "isexer3nopoverwrite": false,
126
+ "ignoreposvalidation": false,
127
+ "exciseopening": false,
128
+ "useforfinalproduction": false,
129
+ "istdsoverridden": false,
130
+ "istcsoverridden": false,
131
+ "istdstcscashvch": false,
132
+ "includeadvpymtvch": false,
133
+ "issubworkscontract": false,
134
+ "isvatoverridden": false,
135
+ "ignoreorigvchdate": false,
136
+ "isvatpaidatcustoms": false,
137
+ "isdeclaredtocustoms": false,
138
+ "vatadvancepayment": false,
139
+ "vatadvpay": false,
140
+ "iscstdelcaredgoodssales": false,
141
+ "isvatrestaxinv": false,
142
+ "isservicetaxoverridden": false,
143
+ "isisdvoucher": false,
144
+ "isexciseoverridden": false,
145
+ "isexcisesupplyvch": false,
146
+ "gstnotexported": false,
147
+ "ignoregstinvalidation": false,
148
+ "isgstrefund": false,
149
+ "ovrdnewaybillapplicability": false,
150
+ "isvatprincipalaccount": false,
151
+ "vchstatusisvchnumused": false,
152
+ "vchgststatusisincluded": true,
153
+ "vchgststatusisuncertain": false,
154
+ "vchgststatusisexcluded": false,
155
+ "vchgststatusisapplicable": true,
156
+ "vchgststatusisgstr2breconciled": false,
157
+ "vchgststatusisgstr2bonlyinportal": false,
158
+ "vchgststatusisgstr2bonlyinbooks": false,
159
+ "vchgststatusisgstr2bmismatch": false,
160
+ "vchgststatusisgstr2bindiffperiod": false,
161
+ "vchgststatusisreteffdateoverrdn": false,
162
+ "vchgststatusisoverrdn": false,
163
+ "vchgststatusisstatindiffdate": false,
164
+ "vchgststatusisretindiffdate": false,
165
+ "vchgststatusmainsectionexcluded": false,
166
+ "vchgststatusisbranchtransferout": false,
167
+ "vchgststatusissystemsummary": false,
168
+ "vchstatusisunregisteredrcm": false,
169
+ "vchstatusisoptional": false,
170
+ "vchstatusiscancelled": false,
171
+ "vchstatusisdeleted": false,
172
+ "vchstatusisopeningbalance": false,
173
+ "vchstatusisfetchedonly": false,
174
+ "vchgststatusisoptionaluncertain": false,
175
+ "vchstatusisreacceptforhsndone": false,
176
+ "vchstatusisreaccephsnsixonedone": true,
177
+ "paymentlinkhasmultiref": false,
178
+ "isshippingwithinstate": false,
179
+ "isoverseastouristtrans": false,
180
+ "isdesignatedzoneparty": false,
181
+ "hascashflow": false,
182
+ "ispostdated": false,
183
+ "usetrackingnumber": false,
184
+ "isinvoice": true,
185
+ "mfgjournal": false,
186
+ "hasdiscounts": false,
187
+ "aspayslip": false,
188
+ "iscostcentre": false,
189
+ "isstxnonrealizedvch": false,
190
+ "isexcisemanufactureron": false,
191
+ "isblankcheque": false,
192
+ "isvoid": false,
193
+ "orderlinestatus": false,
194
+ "vatisagnstcancsales": false,
195
+ "vatispurcexempted": false,
196
+ "isvatrestaxinvoice": false,
197
+ "vatisassesablecalcvch": false,
198
+ "isvatdutypaid": true,
199
+ "isdeliverysameasconsignee": false,
200
+ "isdispatchsameasconsignor": false,
201
+ "isdeletedvchretained": false,
202
+ "vchonlyaddlinfoupdated": false,
203
+ "changevchmode": false,
204
+ "resetirnqrcode": false,
205
+ "vouchernumberseries": "Default",
206
+ "allinventoryentries": [],
207
+ "ledgerentries": [],
208
+ "gst": [
209
+ {
210
+ "purposetype": "GST",
211
+ "stat": [
212
+ {
213
+ "purposetype": "GST",
214
+ "statkey": "\u0004 Auto Stat Number",
215
+ "isfetchedonly": false,
216
+ "isdeleted": false,
217
+ "tallycontentuser": []
218
+ }
219
+ ]
220
+ }
221
+ ]
222
+ }
223
+ ]
224
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "static_variables": [
3
+ {
4
+ "name": "svExportFormat",
5
+ "value": "jsonex"
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "static_variables": [
3
+ {
4
+ "name": "svExportFormat",
5
+ "value": "jsonex"
6
+ },
7
+ {
8
+ "name": "svCurrentCompany",
9
+ "value": "Mani"
10
+ }
11
+ ]
12
+ }
@@ -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("KeshavStockItems");
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/v1/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,20 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { getConfig } from "../../core/configStore.js";
4
+
5
+ export const getSchema = (table) => {
6
+ const config = getConfig();
7
+
8
+ const schemaPath = path.join(config.SchemaPath, `${table}.json`);
9
+
10
+ if (!fs.existsSync(schemaPath)) {
11
+ throw new Error(`Schema not found for table "${table}" at ${schemaPath}`);
12
+ }
13
+
14
+ try {
15
+ const schema = fs.readFileSync(schemaPath, "utf-8");
16
+ return JSON.parse(schema);
17
+ } catch (err) {
18
+ throw new Error(`Invalid schema JSON for "${table}": ${err.message}`);
19
+ };
20
+ };
@@ -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,5 @@
1
+ export * as query from "./query/index.js";
2
+ export * as mutate from "./mutate/index.js";
3
+ export * as remove from "./remove/index.js";
4
+ export * as filter from "./filter/index.js";
5
+ export * as aggregate from "./aggregate/index.js";
@@ -0,0 +1,26 @@
1
+ import { getConfig } from "../../../../core/configStore.js";
2
+ import { buildDataPath } from "../../../../utils/pathBuilder.js";
3
+ import { readData } from "../../../helpers/file/read.js";
4
+ import { writeData } from "../../../helpers/file/write.js";
5
+
6
+ const deleteBase = ({ table, pk }) => {
7
+ const config = getConfig();
8
+ const path = buildDataPath(config, table);
9
+
10
+ const data = readData(path);
11
+
12
+ const index = data.findIndex(r => r.pk === pk);
13
+
14
+ if (index === -1) {
15
+ throw new Error(`Record with pk ${pk} not found`);
16
+ }
17
+
18
+ const deleted = data[index];
19
+ data.splice(index, 1);
20
+
21
+ writeData(path, data);
22
+
23
+ return deleted;
24
+ };
25
+
26
+ export default deleteBase;
@@ -0,0 +1,14 @@
1
+ import deleteBase from "./deleteBase.js";
2
+ import { getSchema } from "../../../config/getSchema.js";
3
+
4
+ const deleteWithChecks = ({ table, pk }) => {
5
+ const schema = getSchema(table);
6
+
7
+ if (!pk) {
8
+ throw new Error("pk is required");
9
+ }
10
+
11
+ return deleteBase({ table, pk });
12
+ };
13
+
14
+ export default deleteWithChecks;
@@ -0,0 +1,7 @@
1
+ export { default as insertAsIs } from "./insert/insertAsIs.js";
2
+ export { default as insertFlat } from "./insert/insertFlat.js";
3
+ export { default as insertGenPk } from "./insert/insertGenPk.js";
4
+ export { default as insertWithChecks } from "./insert/insertWithChecks.js";
5
+
6
+ export { default as deleteWithChecks } from "./delete/deleteWithChecks.js";
7
+ export { default as updateWithChecks } from "./update/updateWithChecks.js";
@@ -0,0 +1,7 @@
1
+ import insertBase from "./insertBase.js";
2
+
3
+ const insertAsIs = ({ table, record }) => {
4
+ return insertBase({ table, record });
5
+ };
6
+
7
+ export default insertAsIs;
@@ -0,0 +1,19 @@
1
+ import { getConfig } from "../../../../core/configStore.js";
2
+ import { buildDataPath } from "../../../../utils/pathBuilder.js";
3
+ import { readData } from "../../../helpers/file/read.js";
4
+ import { writeData } from "../../../helpers/file/write.js";
5
+
6
+ const insertBase = ({ table, record }) => {
7
+ const config = getConfig();
8
+ const path = buildDataPath(config, table);
9
+
10
+ const data = readData(path);
11
+
12
+ data.push(record);
13
+
14
+ writeData(path, data);
15
+
16
+ return record;
17
+ };
18
+
19
+ export default insertBase;
@@ -0,0 +1,24 @@
1
+ import insertBase from "./insertBase.js";
2
+
3
+ const isPlainObject = (val) =>
4
+ typeof val === "object" && val !== null && !Array.isArray(val);
5
+
6
+ const isPrimitive = (val) =>
7
+ val === null ||
8
+ ["string", "number", "boolean"].includes(typeof val);
9
+
10
+ const insertFlat = ({ table, record }) => {
11
+ if (!isPlainObject(record)) {
12
+ throw new Error("must be object");
13
+ }
14
+
15
+ for (const key in record) {
16
+ if (!isPrimitive(record[key])) {
17
+ throw new Error(`invalid value for ${key}`);
18
+ }
19
+ }
20
+
21
+ return insertBase({ table, record }); // 🔥 reuse
22
+ };
23
+
24
+ export default insertFlat;