shutro-erp 0.2.0 → 0.3.0

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 (232) hide show
  1. package/README.md +17 -10
  2. package/dist/account_portal/.kosh/bindings.d.ts +22 -0
  3. package/dist/account_portal/.kosh/bindings.js +15 -0
  4. package/dist/account_portal/.kosh/schema.d.ts +1350 -0
  5. package/dist/account_portal/index.d.ts +3 -0
  6. package/dist/account_portal/index.js +73 -0
  7. package/dist/account_portal/module.d.ts +5983 -0
  8. package/dist/account_portal/module.js +18 -0
  9. package/dist/accounting/.kosh/bindings.js +1 -1
  10. package/dist/accounting/.kosh/schema.d.ts +142 -9
  11. package/dist/accounting/chart.d.ts +40 -8
  12. package/dist/accounting/chart.js +124 -30
  13. package/dist/accounting/closing.d.ts +6 -1
  14. package/dist/accounting/closing.js +5 -1
  15. package/dist/accounting/demo.js +6 -5
  16. package/dist/accounting/index.d.ts +3 -3
  17. package/dist/accounting/index.js +200 -23
  18. package/dist/accounting/module.d.ts +3326 -1086
  19. package/dist/accounting/module.js +408 -66
  20. package/dist/accounting/payments.d.ts +25 -0
  21. package/dist/accounting/payments.js +96 -4
  22. package/dist/accounting/web/RegisterPayment.d.ts +3 -2
  23. package/dist/accounting/web/RegisterPayment.js +39 -6
  24. package/dist/accounting/web/SettingsPage.js +5 -1
  25. package/dist/accounting/web/messages.js +10 -0
  26. package/dist/cli/index.d.ts +1 -1
  27. package/dist/cli/index.js +1 -1
  28. package/dist/cli/init.d.ts +5 -0
  29. package/dist/cli/init.js +195 -53
  30. package/dist/cli/launch.d.ts +16 -0
  31. package/dist/cli/launch.js +138 -0
  32. package/dist/cli/prompt.d.ts +35 -0
  33. package/dist/cli/prompt.js +46 -0
  34. package/dist/cli/templates.d.ts +11 -3
  35. package/dist/cli/templates.js +32 -7
  36. package/dist/cli/tui.d.ts +7 -0
  37. package/dist/cli/tui.js +254 -0
  38. package/dist/cli/ui.d.ts +25 -5
  39. package/dist/cli/ui.js +49 -9
  40. package/dist/contacts/.kosh/bindings.js +1 -1
  41. package/dist/contacts/.kosh/schema.d.ts +3 -1
  42. package/dist/contacts/index.js +24 -1
  43. package/dist/contacts/module.d.ts +42 -0
  44. package/dist/contacts/module.js +3 -1
  45. package/dist/import/convert.d.ts +55 -0
  46. package/dist/import/convert.js +224 -0
  47. package/dist/import/csv.d.ts +28 -0
  48. package/dist/import/csv.js +115 -0
  49. package/dist/import/index.d.ts +33 -0
  50. package/dist/import/index.js +60 -0
  51. package/dist/import/mapping.d.ts +15 -0
  52. package/dist/import/mapping.js +33 -0
  53. package/dist/import/match.d.ts +24 -0
  54. package/dist/import/match.js +60 -0
  55. package/dist/import/models.d.ts +2 -0
  56. package/dist/import/models.js +102 -0
  57. package/dist/import/routes.d.ts +13 -0
  58. package/dist/import/routes.js +392 -0
  59. package/dist/import/run.d.ts +131 -0
  60. package/dist/import/run.js +568 -0
  61. package/dist/import/service.d.ts +153 -0
  62. package/dist/import/service.js +367 -0
  63. package/dist/import/web/ImportButton.d.ts +7 -0
  64. package/dist/import/web/ImportButton.js +31 -0
  65. package/dist/import/web/ImportWizard.d.ts +75 -0
  66. package/dist/import/web/ImportWizard.js +217 -0
  67. package/dist/import/web/index.d.ts +13 -0
  68. package/dist/import/web/index.js +18 -0
  69. package/dist/import/web/messages.d.ts +2 -0
  70. package/dist/import/web/messages.js +139 -0
  71. package/dist/import/worker.d.ts +3 -0
  72. package/dist/import/worker.js +52 -0
  73. package/dist/import/xlsx.d.ts +20 -0
  74. package/dist/import/xlsx.js +192 -0
  75. package/dist/l10n_bd/.kosh/bindings.d.ts +22 -0
  76. package/dist/l10n_bd/.kosh/bindings.js +15 -0
  77. package/dist/l10n_bd/.kosh/schema.d.ts +1281 -0
  78. package/dist/l10n_bd/documents.d.ts +8 -0
  79. package/dist/l10n_bd/documents.js +183 -0
  80. package/dist/l10n_bd/index.d.ts +8 -0
  81. package/dist/l10n_bd/index.js +156 -0
  82. package/dist/l10n_bd/module.d.ts +5705 -0
  83. package/dist/l10n_bd/module.js +163 -0
  84. package/dist/l10n_bd/mushak.d.ts +67 -0
  85. package/dist/l10n_bd/mushak.js +139 -0
  86. package/dist/l10n_bd/routes.d.ts +3 -0
  87. package/dist/l10n_bd/routes.js +205 -0
  88. package/dist/l10n_bd/web/MushakPage.d.ts +7 -0
  89. package/dist/l10n_bd/web/MushakPage.js +53 -0
  90. package/dist/l10n_bd/web/index.d.ts +13 -0
  91. package/dist/l10n_bd/web/index.js +18 -0
  92. package/dist/l10n_bd/web/messages.d.ts +2 -0
  93. package/dist/l10n_bd/web/messages.js +101 -0
  94. package/dist/l10n_in/.kosh/bindings.d.ts +22 -0
  95. package/dist/l10n_in/.kosh/bindings.js +15 -0
  96. package/dist/l10n_in/.kosh/schema.d.ts +1343 -0
  97. package/dist/l10n_in/documents.d.ts +8 -0
  98. package/dist/l10n_in/documents.js +114 -0
  99. package/dist/l10n_in/einvoice.d.ts +253 -0
  100. package/dist/l10n_in/einvoice.js +485 -0
  101. package/dist/l10n_in/gstr.d.ts +109 -0
  102. package/dist/l10n_in/gstr.js +430 -0
  103. package/dist/l10n_in/index.d.ts +20 -0
  104. package/dist/l10n_in/index.js +232 -0
  105. package/dist/l10n_in/module.d.ts +7823 -0
  106. package/dist/l10n_in/module.js +427 -0
  107. package/dist/l10n_in/routes-einvoice.d.ts +15 -0
  108. package/dist/l10n_in/routes-einvoice.js +124 -0
  109. package/dist/l10n_in/routes.d.ts +17 -0
  110. package/dist/l10n_in/routes.js +282 -0
  111. package/dist/l10n_in/web/EInvoicePanel.d.ts +8 -0
  112. package/dist/l10n_in/web/EInvoicePanel.js +63 -0
  113. package/dist/l10n_in/web/GstPage.d.ts +7 -0
  114. package/dist/l10n_in/web/GstPage.js +57 -0
  115. package/dist/l10n_in/web/GstSettings.d.ts +10 -0
  116. package/dist/l10n_in/web/GstSettings.js +36 -0
  117. package/dist/l10n_in/web/index.d.ts +15 -0
  118. package/dist/l10n_in/web/index.js +22 -0
  119. package/dist/l10n_in/web/messages.d.ts +2 -0
  120. package/dist/l10n_in/web/messages.js +166 -0
  121. package/dist/modules-sdk/demo.d.ts +2 -0
  122. package/dist/modules-sdk/demo.js +7 -3
  123. package/dist/modules-sdk/index.d.ts +2 -2
  124. package/dist/modules-sdk/index.js +1 -1
  125. package/dist/modules-sdk/manifest.d.ts +132 -0
  126. package/dist/modules-sdk/manifest.js +22 -0
  127. package/dist/notify/inbox.js +21 -0
  128. package/dist/notify/messages.js +4 -0
  129. package/dist/notify/models.d.ts +1 -1
  130. package/dist/notify/models.js +2 -0
  131. package/dist/notify/web/messages.js +4 -0
  132. package/dist/portal/.kosh/bindings.d.ts +22 -0
  133. package/dist/portal/.kosh/bindings.js +15 -0
  134. package/dist/portal/.kosh/schema.d.ts +346 -0
  135. package/dist/portal/announce.d.ts +16 -0
  136. package/dist/portal/announce.js +117 -0
  137. package/dist/portal/documents.d.ts +17 -0
  138. package/dist/portal/documents.js +61 -0
  139. package/dist/portal/index.d.ts +20 -0
  140. package/dist/portal/index.js +65 -0
  141. package/dist/portal/module.d.ts +1405 -0
  142. package/dist/portal/module.js +84 -0
  143. package/dist/portal/routes-documents.d.ts +2 -0
  144. package/dist/portal/routes-documents.js +391 -0
  145. package/dist/portal/routes.d.ts +13 -0
  146. package/dist/portal/routes.js +313 -0
  147. package/dist/portal/rules.d.ts +11 -0
  148. package/dist/portal/rules.js +25 -0
  149. package/dist/portal/web/PortalAccess.d.ts +8 -0
  150. package/dist/portal/web/PortalAccess.js +66 -0
  151. package/dist/portal/web/index.d.ts +12 -0
  152. package/dist/portal/web/index.js +17 -0
  153. package/dist/portal/web/messages.d.ts +2 -0
  154. package/dist/portal/web/messages.js +33 -0
  155. package/dist/product/.kosh/bindings.js +1 -1
  156. package/dist/product/.kosh/schema.d.ts +12 -3
  157. package/dist/product/demo.js +6 -5
  158. package/dist/product/index.d.ts +1 -0
  159. package/dist/product/index.js +17 -4
  160. package/dist/product/module.d.ts +346 -14
  161. package/dist/product/module.js +48 -18
  162. package/dist/product/taxes.d.ts +59 -0
  163. package/dist/product/taxes.js +61 -0
  164. package/dist/project/.kosh/bindings.js +1 -1
  165. package/dist/project/.kosh/schema.d.ts +3 -1
  166. package/dist/project/module.d.ts +20 -0
  167. package/dist/project_portal/.kosh/bindings.d.ts +22 -0
  168. package/dist/project_portal/.kosh/bindings.js +15 -0
  169. package/dist/project_portal/.kosh/schema.d.ts +671 -0
  170. package/dist/project_portal/index.d.ts +9 -0
  171. package/dist/project_portal/index.js +42 -0
  172. package/dist/project_portal/module.d.ts +2142 -0
  173. package/dist/project_portal/module.js +22 -0
  174. package/dist/purchase/.kosh/bindings.js +1 -1
  175. package/dist/purchase/.kosh/schema.d.ts +15 -4
  176. package/dist/purchase/demo.js +3 -3
  177. package/dist/purchase/index.js +1 -1
  178. package/dist/purchase/module.d.ts +232 -8
  179. package/dist/purchase/module.js +51 -9
  180. package/dist/purchase_account/.kosh/bindings.js +1 -1
  181. package/dist/purchase_account/.kosh/schema.d.ts +144 -10
  182. package/dist/purchase_account/module.d.ts +2008 -641
  183. package/dist/purchase_account/module.js +2 -2
  184. package/dist/purchase_portal/.kosh/bindings.d.ts +22 -0
  185. package/dist/purchase_portal/.kosh/bindings.js +15 -0
  186. package/dist/purchase_portal/.kosh/schema.d.ts +822 -0
  187. package/dist/purchase_portal/index.d.ts +9 -0
  188. package/dist/purchase_portal/index.js +53 -0
  189. package/dist/purchase_portal/module.d.ts +2758 -0
  190. package/dist/purchase_portal/module.js +18 -0
  191. package/dist/reporting/documents.js +20 -3
  192. package/dist/reporting/index.d.ts +1 -0
  193. package/dist/reporting/index.js +1 -0
  194. package/dist/reporting/routes-documents.js +9 -2
  195. package/dist/reporting/words.d.ts +11 -0
  196. package/dist/reporting/words.js +229 -0
  197. package/dist/sale_account/.kosh/bindings.js +1 -1
  198. package/dist/sale_account/.kosh/schema.d.ts +144 -10
  199. package/dist/sale_account/module.d.ts +2008 -641
  200. package/dist/sale_account/module.js +3 -3
  201. package/dist/sale_portal/.kosh/bindings.d.ts +22 -0
  202. package/dist/sale_portal/.kosh/bindings.js +15 -0
  203. package/dist/sale_portal/.kosh/schema.d.ts +736 -0
  204. package/dist/sale_portal/index.d.ts +9 -0
  205. package/dist/sale_portal/index.js +71 -0
  206. package/dist/sale_portal/module.d.ts +2718 -0
  207. package/dist/sale_portal/module.js +19 -0
  208. package/dist/sale_project/.kosh/bindings.js +1 -1
  209. package/dist/sale_project/.kosh/schema.d.ts +15 -4
  210. package/dist/sale_project/module.d.ts +390 -10
  211. package/dist/sales/.kosh/bindings.js +1 -1
  212. package/dist/sales/.kosh/schema.d.ts +15 -4
  213. package/dist/sales/demo.js +3 -3
  214. package/dist/sales/index.js +67 -1
  215. package/dist/sales/module.d.ts +232 -8
  216. package/dist/sales/module.js +51 -12
  217. package/dist/server/auth/base.js +2 -0
  218. package/dist/server/auth/service.d.ts +2 -0
  219. package/dist/server/auth/service.js +7 -1
  220. package/dist/server/index.d.ts +1 -1
  221. package/dist/server/index.js +1 -1
  222. package/dist/server/server.js +26 -1
  223. package/dist/ui/api.d.ts +2 -0
  224. package/dist/ui/app.js +1 -1
  225. package/dist/ui/context.d.ts +3 -1
  226. package/dist/ui/context.js +2 -2
  227. package/dist/ui/index.d.ts +1 -1
  228. package/dist/ui/index.js +1 -1
  229. package/dist/ui/lib/format.d.ts +2 -0
  230. package/dist/ui/lib/format.js +3 -1
  231. package/dist/ui/views/FormView.js +19 -6
  232. package/package.json +50 -2
@@ -0,0 +1,131 @@
1
+ /**
2
+ * The import itself (RFC 0014 §5.1–§5.5): rows of cells become records of a model through the ORM, as the user.
3
+ *
4
+ * - Records are created, updated or both (`mode`), matched on a key column: the record id, an external id, or a
5
+ * field the model keeps unique (a code, an email).
6
+ * - A row whose own columns are empty continues the record above: its `lines.*` cells add a line (§5.2). Lines of an
7
+ * updated record replace its lines, so a file exported with its lines re-imports to the same records.
8
+ * - A dry run does all of it — conversions, relation matches, creates and writes, computes, sequences, constraints,
9
+ * record rules — in a savepoint that is rolled back. A commit is all-or-nothing, or with `onError: 'skip'` keeps
10
+ * the records without errors.
11
+ * - A commit returns what undo needs (§5.5): the created ids, the previous values of updated records and their lines,
12
+ * and each record's `updatedAt` after the import, to tell records changed since.
13
+ *
14
+ * Errors name their row (as numbered in the file), column and cell.
15
+ */
16
+ import { type ApiModel } from '../server/index.js';
17
+ import { type Env } from '../server/orm.js';
18
+ import { type Cell, type CellError, type ConvertOptions } from './convert.js';
19
+ import type { ColumnMapping } from './mapping.js';
20
+ import { type Match, type MatchTarget } from './match.js';
21
+ /** The record id as a key column (`#42` or `42`, as an export writes it). */
22
+ export declare const ID_KEY = "id";
23
+ /** An external id as a key column (`legacy.partner_42`; a bare `partner_42` is `__import__.partner_42`). */
24
+ export declare const EXTERNAL_ID_KEY = "externalId";
25
+ /** The module part of external ids an import gives (Shutro `env.setExternalId`). */
26
+ export declare const IMPORT_MODULE = "__import__";
27
+ export interface ImportOptions extends ConvertOptions {
28
+ /** `create` (default), `update` existing records only, or `upsert`. */
29
+ readonly mode?: 'create' | 'update' | 'upsert';
30
+ /** The key column's field: `id`, `externalId`, or a unique field. Needed to update. */
31
+ readonly key?: string;
32
+ /** `stop` (default): any error keeps nothing. `skip`: records with errors are left out, the others kept. */
33
+ readonly onError?: 'stop' | 'skip';
34
+ /** The file's first row holds the headers (default true). */
35
+ readonly headerRow?: boolean;
36
+ }
37
+ export type RowErrorCode = CellError['code'] | 'not-found' | 'ambiguous' | 'missing-required' | 'missing-key' | 'no-match' | 'exists' | 'duplicate-key' | 'rejected';
38
+ /** One error, where the user can find it: the row of the file (1-based) and the column, when known. */
39
+ export interface RowError {
40
+ readonly row: number;
41
+ readonly column: number | null;
42
+ readonly field: string | null;
43
+ readonly code: RowErrorCode;
44
+ readonly message: string;
45
+ }
46
+ /** What undo needs (RFC 0014 §5.5). JSON: stored with the session. */
47
+ export interface UndoData {
48
+ readonly created: readonly number[];
49
+ readonly updated: readonly {
50
+ readonly id: number;
51
+ /** The previous values of the fields the import wrote (as `read()` gives them). */
52
+ readonly before: Readonly<Record<string, unknown>>;
53
+ /** The previous lines of the one2many fields the import replaced. */
54
+ readonly lines: Readonly<Record<string, readonly Readonly<Record<string, unknown>>[]>>;
55
+ }[];
56
+ /** `updatedAt` of each touched record after the import (ISO). */
57
+ readonly stamps: Readonly<Record<string, string>>;
58
+ }
59
+ export interface ImportResult {
60
+ /** Records read (a record and its continuation rows count once). */
61
+ readonly rows: number;
62
+ /** Records created and updated; empty after a dry run or a commit that stopped on errors. */
63
+ readonly created: readonly number[];
64
+ readonly updated: readonly number[];
65
+ /** What a dry run would create and update. */
66
+ readonly wouldCreate: number;
67
+ readonly wouldUpdate: number;
68
+ /** Records left out for their errors (`onError: 'skip'`). */
69
+ readonly skipped: number;
70
+ /** The file rows of the records left out (their continuation rows included). */
71
+ readonly rejectedRows: readonly number[];
72
+ readonly errors: readonly RowError[];
73
+ /** How each relation text was matched (by external id, key, name), by field path, for the user to check. */
74
+ readonly matches: Readonly<Record<string, Readonly<Record<string, Match>>>>;
75
+ /** Set when the import was kept. */
76
+ readonly undo: UndoData | null;
77
+ }
78
+ /** A field the user can fill by import: of the model, a line field (`lines.product`), or a key column. */
79
+ export interface ImportField {
80
+ /** The path: `name`, `lines.product`, `id`, `externalId`. */
81
+ readonly key: string;
82
+ readonly kind: string;
83
+ readonly label: string;
84
+ readonly required: boolean;
85
+ readonly options: readonly (readonly [string, string])[] | null;
86
+ readonly target: MatchTarget | null;
87
+ /** The one2many field a line field belongs to, else null. */
88
+ readonly line: string | null;
89
+ /** The field key in its own model (`product` for `lines.product`). */
90
+ readonly sub: string;
91
+ /** Usable as the key column: the id, an external id, or a field the model keeps unique. */
92
+ readonly keyable: boolean;
93
+ }
94
+ /** Records written per savepoint (and per progress report). */
95
+ export declare const WRITE_BATCH = 1000;
96
+ /** The full external id of a key cell. */
97
+ export declare const externalIdOf: (text: string) => string;
98
+ /**
99
+ * Imports `table` (cells by row) into `model` with `columns`. With `dryRun`, nothing is kept. Runs in the caller's
100
+ * transaction, in savepoints of its own.
101
+ */
102
+ export declare function runImport(env: Env, model: ApiModel, fields: ReadonlyMap<string, ImportField>, table: readonly (readonly Cell[])[], columns: readonly ColumnMapping[], options: ImportOptions & {
103
+ readonly dryRun: boolean;
104
+ /** Called before the writes and after each batch: records written so far, of how many. */
105
+ readonly onProgress?: (done: number, total: number) => Promise<void>;
106
+ }): Promise<ImportResult>;
107
+ export interface UndoResult {
108
+ readonly deleted: number;
109
+ readonly restored: number;
110
+ /** Records changed since the import: left as they are. */
111
+ readonly changed: readonly number[];
112
+ }
113
+ /**
114
+ * Undoes an import (RFC 0014 §5.5), as the user: deletes the records it created and restores the values it changed,
115
+ * for the records nobody changed since (their `updatedAt` is still the import's). The others are listed.
116
+ */
117
+ export declare function undoImport(env: Env, model: ApiModel, fields: ReadonlyMap<string, ImportField>, undo: UndoData): Promise<UndoResult>;
118
+ /** What `importFields` needs to know about the models. */
119
+ export interface ImportModels {
120
+ readonly models: ReadonlyMap<string, ApiModel>;
121
+ /** How records of a model are found from text (its name field, its unique char fields). */
122
+ targets(model: string): MatchTarget | null;
123
+ /** The many2one a one2many's lines point back with. */
124
+ inverseOf(model: string, field: string): string | null;
125
+ }
126
+ /**
127
+ * The fields of `model` the user may fill by import, by path: its own, the key columns (`id`, `externalId`), and
128
+ * the fields of the lines of each one2many the user may write and whose lines they may create (without the link
129
+ * back to the record).
130
+ */
131
+ export declare function importFields(env: Env, model: ApiModel, catalog: ImportModels): Map<string, ImportField>;