@mulmoclaude/accounting-plugin 0.1.0 → 0.2.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 (50) hide show
  1. package/dist/server/atomic.d.ts +5 -3
  2. package/dist/server/atomic.d.ts.map +1 -1
  3. package/dist/server/context.d.ts +0 -7
  4. package/dist/server/context.d.ts.map +1 -1
  5. package/dist/server/http.d.ts +2 -2
  6. package/dist/server/http.d.ts.map +1 -1
  7. package/dist/server/io.d.ts.map +1 -1
  8. package/dist/server.cjs +35 -15
  9. package/dist/server.cjs.map +1 -1
  10. package/dist/server.js +34 -14
  11. package/dist/server.js.map +1 -1
  12. package/dist/shared/api.d.ts +7 -0
  13. package/dist/shared/api.d.ts.map +1 -0
  14. package/dist/shared/index.d.ts +2 -0
  15. package/dist/shared/index.d.ts.map +1 -1
  16. package/dist/shared/paths.d.ts +7 -0
  17. package/dist/shared/paths.d.ts.map +1 -0
  18. package/dist/shared.cjs +16 -0
  19. package/dist/shared.cjs.map +1 -1
  20. package/dist/shared.js +15 -1
  21. package/dist/shared.js.map +1 -1
  22. package/dist/style.css +10 -10
  23. package/dist/vue/api.d.ts.map +1 -1
  24. package/dist/vue/hostContext.d.ts +8 -0
  25. package/dist/vue/hostContext.d.ts.map +1 -1
  26. package/dist/vue/index.d.ts +1 -1
  27. package/dist/vue/index.d.ts.map +1 -1
  28. package/dist/vue/lang/de.d.ts +4 -0
  29. package/dist/vue/lang/de.d.ts.map +1 -0
  30. package/dist/vue/lang/en.d.ts +220 -0
  31. package/dist/vue/lang/en.d.ts.map +1 -0
  32. package/dist/vue/lang/es.d.ts +4 -0
  33. package/dist/vue/lang/es.d.ts.map +1 -0
  34. package/dist/vue/lang/fr.d.ts +4 -0
  35. package/dist/vue/lang/fr.d.ts.map +1 -0
  36. package/dist/vue/lang/index.d.ts +233 -0
  37. package/dist/vue/lang/index.d.ts.map +1 -0
  38. package/dist/vue/lang/ja.d.ts +4 -0
  39. package/dist/vue/lang/ja.d.ts.map +1 -0
  40. package/dist/vue/lang/ko.d.ts +4 -0
  41. package/dist/vue/lang/ko.d.ts.map +1 -0
  42. package/dist/vue/lang/ptBR.d.ts +4 -0
  43. package/dist/vue/lang/ptBR.d.ts.map +1 -0
  44. package/dist/vue/lang/zh.d.ts +4 -0
  45. package/dist/vue/lang/zh.d.ts.map +1 -0
  46. package/dist/vue.cjs +1781 -21
  47. package/dist/vue.cjs.map +1 -1
  48. package/dist/vue.js +1784 -24
  49. package/dist/vue.js.map +1 -1
  50. package/package.json +1 -1
package/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ACCOUNTING_ACTIONS, ACCOUNTING_BOOKS_CHANNEL, BOOK_EVENT_KINDS, FISCAL_YEAR_ENDS, SUPPORTED_COUNTRY_CODES, TIME_SERIES_GRANULARITIES, TIME_SERIES_METRICS, bookChannel, errorMessage, fiscalYearEndMonth, isFiscalYearEnd, isSupportedCountryCode } from "./shared.js";
1
+ import { ACCOUNTING_ACTIONS, ACCOUNTING_API, ACCOUNTING_BOOKS_CHANNEL, ACCOUNTING_DIRS, BOOK_EVENT_KINDS, FISCAL_YEAR_ENDS, SUPPORTED_COUNTRY_CODES, TIME_SERIES_GRANULARITIES, TIME_SERIES_METRICS, bookChannel, errorMessage, fiscalYearEndMonth, isFiscalYearEnd, isSupportedCountryCode } from "./shared.js";
2
2
  import { Router } from "express";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { promises } from "node:fs";
@@ -30,26 +30,42 @@ var log = {
30
30
  info: (namespace, msg, data) => (deps?.logger ?? consoleLogger).info(namespace, msg, data),
31
31
  debug: (namespace, msg, data) => (deps?.logger ?? consoleLogger).debug(namespace, msg, data)
32
32
  };
33
- /** Workspace-relative directories this plugin owns. Mirrors the host
34
- * META's `workspaceDirs` (kept in sync by value; the host META stays
35
- * the codegen-discoverable source for the aggregator merge). */
36
- var ACCOUNTING_DIRS = {
37
- accounting: "data/accounting",
38
- accountingBooks: "data/accounting/books"
39
- };
40
33
  //#endregion
41
34
  //#region src/server/atomic.ts
42
35
  /** True for a `not found` filesystem error. */
43
36
  function isEnoent(err) {
44
37
  return typeof err === "object" && err !== null && "code" in err && err.code === "ENOENT";
45
38
  }
46
- /** Atomic write: tmp alongside destination, then rename. */
39
+ var IS_WINDOWS = process.platform === "win32";
40
+ var RENAME_RETRY_DELAYS_MS = [
41
+ 30,
42
+ 100,
43
+ 300
44
+ ];
45
+ function hasErrnoCode(err) {
46
+ return typeof err === "object" && err !== null && "code" in err && typeof err.code === "string";
47
+ }
48
+ function isTransientRenameError(err) {
49
+ if (!IS_WINDOWS || !hasErrnoCode(err)) return false;
50
+ return err.code === "EPERM" || err.code === "EBUSY" || err.code === "EACCES";
51
+ }
52
+ async function renameWithWindowsRetry(fromPath, toPath) {
53
+ for (const delayMs of RENAME_RETRY_DELAYS_MS) try {
54
+ await promises.rename(fromPath, toPath);
55
+ return;
56
+ } catch (err) {
57
+ if (!isTransientRenameError(err)) throw err;
58
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
59
+ }
60
+ await promises.rename(fromPath, toPath);
61
+ }
62
+ /** Atomic write: unique tmp alongside destination, then rename. */
47
63
  async function writeFileAtomic(filePath, content, opts = {}) {
48
- const tmp = opts.uniqueTmp ? `${filePath}.${randomUUID()}.tmp` : `${filePath}.tmp`;
64
+ const tmp = opts.uniqueTmp ?? true ? `${filePath}.${randomUUID()}.tmp` : `${filePath}.tmp`;
49
65
  await promises.mkdir(path.dirname(filePath), { recursive: true });
50
66
  try {
51
67
  await promises.writeFile(tmp, content, { encoding: "utf-8" });
52
- await promises.rename(tmp, filePath);
68
+ await renameWithWindowsRetry(tmp, filePath);
53
69
  } catch (err) {
54
70
  await promises.unlink(tmp).catch(() => {});
55
71
  throw err;
@@ -1827,7 +1843,7 @@ async function rebuildSnapshots(input, workspaceRoot) {
1827
1843
  //#endregion
1828
1844
  //#region src/server/http.ts
1829
1845
  function asyncHandler(namespace, fallbackMessage, handler) {
1830
- return async (req, res) => {
1846
+ return async (req, res, next) => {
1831
1847
  try {
1832
1848
  await handler(req, res);
1833
1849
  } catch (err) {
@@ -1837,7 +1853,11 @@ function asyncHandler(namespace, fallbackMessage, handler) {
1837
1853
  route: expressReq.path,
1838
1854
  error: errorMessage(err)
1839
1855
  });
1840
- if (!expressRes.headersSent) expressRes.status(500).json({ error: fallbackMessage });
1856
+ if (expressRes.headersSent) {
1857
+ next(err);
1858
+ return;
1859
+ }
1860
+ expressRes.status(500).json({ error: fallbackMessage });
1841
1861
  }
1842
1862
  };
1843
1863
  }
@@ -2037,7 +2057,7 @@ async function dispatch(body) {
2037
2057
  * with `app.use(...)`. */
2038
2058
  function createAccountingRouter() {
2039
2059
  const router = Router();
2040
- router.post("/api/accounting", asyncHandler("accounting", "accounting dispatch failed", async (req, res) => {
2060
+ router.post(ACCOUNTING_API.dispatch.path, asyncHandler("accounting", "accounting dispatch failed", async (req, res) => {
2041
2061
  const { body } = req;
2042
2062
  if (!body || typeof body !== "object" || typeof body.action !== "string") {
2043
2063
  log.warn("accounting", "POST dispatch: invalid body");