@driveflux/pdf 4.0.77 → 5.0.0-feature-e-invoicing.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 (282) hide show
  1. package/.env +0 -0
  2. package/.env.development +4 -0
  3. package/.turbo/turbo-build.log +14 -0
  4. package/CHANGELOG.md +15 -0
  5. package/build.ts +45 -0
  6. package/bun-env.d.ts +34 -0
  7. package/bunfig.toml +8 -0
  8. package/catalog-version-stamp.json +8 -0
  9. package/dist/main.js +4 -0
  10. package/dist/main.js.map +11 -0
  11. package/dist/src/config.d.ts +20 -0
  12. package/dist/src/create-logger.d.ts +1 -0
  13. package/dist/src/errors.d.ts +43 -0
  14. package/dist/src/main.d.ts +1 -0
  15. package/dist/src/preview/api.d.ts +264 -0
  16. package/dist/src/preview/client/app.d.ts +2 -0
  17. package/dist/src/preview/client/invoice/invoice-display.d.ts +5 -0
  18. package/dist/src/preview/client/invoice/invoice-setup.d.ts +8 -0
  19. package/dist/src/preview/client/preview-targets.d.ts +12 -0
  20. package/dist/src/preview/client/preview.d.ts +6 -0
  21. package/dist/src/preview/client/sidebar.d.ts +7 -0
  22. package/dist/src/preview/client/treaty.d.ts +200 -0
  23. package/dist/src/preview/client/use-target.d.ts +1 -0
  24. package/dist/src/preview/fonts/register-fonts.d.ts +1 -0
  25. package/dist/src/preview/frontend.d.ts +1 -0
  26. package/dist/src/preview/server.d.ts +1 -0
  27. package/dist/src/repository.d.ts +171 -0
  28. package/dist/src/templates/invoice/colors.d.ts +6 -0
  29. package/dist/src/templates/invoice/company-details.d.ts +10 -0
  30. package/dist/src/templates/invoice/flux-invoice.d.ts +6 -0
  31. package/dist/src/templates/invoice/footer.d.ts +2 -0
  32. package/dist/src/templates/invoice/host-invoice.d.ts +9 -0
  33. package/dist/src/templates/invoice/invoice-details.d.ts +13 -0
  34. package/dist/src/templates/invoice/invoice-notes.d.ts +1 -0
  35. package/dist/src/templates/invoice/invoice-summary.d.ts +7 -0
  36. package/dist/src/templates/invoice/letter-head.d.ts +10 -0
  37. package/dist/src/templates/invoice/li.d.ts +10 -0
  38. package/dist/src/templates/invoice/platform-and-host-details.d.ts +11 -0
  39. package/dist/src/templates/invoice/spacer.d.ts +3 -0
  40. package/dist/src/templates/invoice/split-container-items.d.ts +10 -0
  41. package/dist/src/templates/invoice/split-container.d.ts +7 -0
  42. package/dist/src/templates/invoice/standard-page.d.ts +7 -0
  43. package/dist/src/templates/invoice/types.d.ts +3 -0
  44. package/dist/src/templates/invoice/ul.d.ts +8 -0
  45. package/dist/src/templates/invoice/utils.d.ts +2 -0
  46. package/dist/tsconfig.tsbuildinfo +1 -0
  47. package/package.json +34 -40
  48. package/src/config.ts +42 -0
  49. package/src/create-logger.ts +4 -0
  50. package/src/errors.ts +35 -0
  51. package/src/main.ts +7 -0
  52. package/src/preview/api.ts +33 -0
  53. package/src/preview/client/app.tsx +30 -0
  54. package/src/preview/client/invoice/invoice-display.tsx +27 -0
  55. package/src/preview/client/invoice/invoice-setup.tsx +95 -0
  56. package/src/preview/client/preview-targets.ts +30 -0
  57. package/src/preview/client/preview.tsx +37 -0
  58. package/src/preview/client/sidebar.tsx +39 -0
  59. package/src/preview/client/treaty.ts +8 -0
  60. package/src/preview/client/use-target.ts +11 -0
  61. package/src/preview/fonts/GOTHAM-BLACK.TTF +0 -0
  62. package/src/preview/fonts/GOTHAM-BLACKITALIC.TTF +0 -0
  63. package/src/preview/fonts/GOTHAM-BOLD.TTF +0 -0
  64. package/src/preview/fonts/GOTHAM-BOLDITALIC.TTF +0 -0
  65. package/src/preview/fonts/GOTHAM-LIGHT.TTF +0 -0
  66. package/src/preview/fonts/GOTHAM-LIGHTITALIC.TTF +0 -0
  67. package/src/preview/fonts/GOTHAM-MEDIUM.TTF +0 -0
  68. package/src/preview/fonts/GOTHAM-MEDIUMITALIC.TTF +0 -0
  69. package/src/preview/fonts/GOTHAM-THIN.TTF +0 -0
  70. package/src/preview/fonts/GOTHAM-THINITALIC.TTF +0 -0
  71. package/src/preview/fonts/GOTHAM-ULTRA.TTF +0 -0
  72. package/src/preview/fonts/GOTHAM-ULTRAITALIC.TTF +0 -0
  73. package/src/preview/fonts/GOTHAM-XLIGHT.TTF +0 -0
  74. package/src/preview/fonts/GOTHAM-XLIGHTITALIC.TTF +0 -0
  75. package/src/preview/fonts/Gotham Book Italic.otf +0 -0
  76. package/src/preview/fonts/Gotham-BoldItalic.otf +0 -0
  77. package/src/preview/fonts/Gotham-Book.otf +0 -0
  78. package/src/preview/fonts/Gotham-BookItalic.otf +0 -0
  79. package/src/preview/fonts/Gotham-ExtraLight.otf +0 -0
  80. package/src/preview/fonts/Gotham-ExtraLightItalic.otf +0 -0
  81. package/src/preview/fonts/Gotham-Light.otf +0 -0
  82. package/src/preview/fonts/Gotham-LightItalic.otf +0 -0
  83. package/src/preview/fonts/Gotham-Medium.otf +0 -0
  84. package/src/preview/fonts/Gotham-MediumItalic.otf +0 -0
  85. package/src/preview/fonts/Gotham-Thin.otf +0 -0
  86. package/src/preview/fonts/Gotham-ThinItalic.otf +0 -0
  87. package/src/preview/fonts/Gotham-Ultra.otf +0 -0
  88. package/src/preview/fonts/Gotham-UltraItalic.otf +0 -0
  89. package/src/preview/fonts/GothamNarrow-Black.otf +0 -0
  90. package/src/preview/fonts/GothamNarrow-BlackItalic.otf +0 -0
  91. package/src/preview/fonts/GothamNarrow-Book.otf +0 -0
  92. package/src/preview/fonts/GothamNarrow-BookItalic.otf +0 -0
  93. package/src/preview/fonts/GothamNarrow-Light.otf +0 -0
  94. package/src/preview/fonts/GothamNarrow-LightItalic.otf +0 -0
  95. package/src/preview/fonts/GothamNarrow-Medium.otf +0 -0
  96. package/src/preview/fonts/GothamNarrow-MediumItalic.otf +0 -0
  97. package/src/preview/fonts/GothamNarrow-Thin.otf +0 -0
  98. package/src/preview/fonts/GothamNarrow-ThinItalic.otf +0 -0
  99. package/src/preview/fonts/GothamNarrow-Ultra.otf +0 -0
  100. package/src/preview/fonts/GothamNarrow-UltraItalic.otf +0 -0
  101. package/src/preview/fonts/GothamNarrow-XLight.otf +0 -0
  102. package/src/preview/fonts/GothamNarrow-XLightItalic.otf +0 -0
  103. package/src/preview/fonts/gotham-extra-narrow-bold-italic.otf +0 -0
  104. package/src/preview/fonts/gotham-extra-narrow-bold.otf +0 -0
  105. package/src/preview/fonts/gotham-extra-narrow-book-italic.otf +0 -0
  106. package/src/preview/fonts/gotham-extra-narrow-book.otf +0 -0
  107. package/src/preview/fonts/gotham-extra-narrow-light-italic.otf +0 -0
  108. package/src/preview/fonts/gotham-extra-narrow-light.otf +0 -0
  109. package/src/preview/fonts/gotham-extra-narrow-medium-italic.otf +0 -0
  110. package/src/preview/fonts/gotham-extra-narrow-medium.otf +0 -0
  111. package/src/preview/fonts/gotham-rounded-bold-italic.otf +0 -0
  112. package/src/preview/fonts/gotham-rounded-bold.otf +0 -0
  113. package/src/preview/fonts/gotham-rounded-book-italic.otf +0 -0
  114. package/src/preview/fonts/gotham-rounded-book.otf +0 -0
  115. package/src/preview/fonts/gotham-rounded-light-italic.otf +0 -0
  116. package/src/preview/fonts/gotham-rounded-light.otf +0 -0
  117. package/src/preview/fonts/gotham-rounded-medium-italic.otf +0 -0
  118. package/src/preview/fonts/gotham-rounded-medium.otf +0 -0
  119. package/src/preview/fonts/register-fonts.ts +395 -0
  120. package/src/preview/frontend.tsx +23 -0
  121. package/src/preview/global.css +39 -0
  122. package/src/preview/preview.html +12 -0
  123. package/src/preview/server.ts +28 -0
  124. package/src/repository.ts +39 -0
  125. package/src/templates/invoice/E Invoice Format.pdf +0 -0
  126. package/src/templates/invoice/colors.ts +6 -0
  127. package/src/templates/invoice/company-details.tsx +124 -0
  128. package/src/templates/invoice/flux-invoice.tsx +134 -0
  129. package/src/templates/invoice/footer.tsx +46 -0
  130. package/src/templates/invoice/host-invoice.tsx +134 -0
  131. package/src/templates/invoice/images/logo.png +0 -0
  132. package/src/templates/invoice/images/logo.svg +41 -0
  133. package/src/templates/invoice/invoice-details.tsx +231 -0
  134. package/src/templates/invoice/invoice-notes.tsx +74 -0
  135. package/src/templates/invoice/invoice-summary.tsx +135 -0
  136. package/src/templates/invoice/letter-head.tsx +132 -0
  137. package/src/templates/invoice/li.tsx +48 -0
  138. package/src/templates/invoice/platform-and-host-details.tsx +56 -0
  139. package/src/templates/invoice/spacer.tsx +5 -0
  140. package/src/templates/invoice/split-container-items.tsx +80 -0
  141. package/src/templates/invoice/split-container.tsx +35 -0
  142. package/src/templates/invoice/standard-page.tsx +45 -0
  143. package/src/templates/invoice/types.ts +6 -0
  144. package/src/templates/invoice/ul.tsx +19 -0
  145. package/src/templates/invoice/utils.ts +5 -0
  146. package/tsconfig.json +21 -0
  147. package/dist/components/FluxLogo.d.ts +0 -3
  148. package/dist/components/FluxLogo.d.ts.map +0 -1
  149. package/dist/components/FluxLogo.js +0 -66
  150. package/dist/components/FluxLogo.js.map +0 -1
  151. package/dist/components/StandardPage.d.ts +0 -7
  152. package/dist/components/StandardPage.d.ts.map +0 -1
  153. package/dist/components/StandardPage.js +0 -132
  154. package/dist/components/StandardPage.js.map +0 -1
  155. package/dist/index.d.ts +0 -4
  156. package/dist/index.d.ts.map +0 -1
  157. package/dist/index.js +0 -3
  158. package/dist/index.js.map +0 -1
  159. package/dist/templates/QuotationPdf/CustomerSubscriptionSection.d.ts +0 -10
  160. package/dist/templates/QuotationPdf/CustomerSubscriptionSection.d.ts.map +0 -1
  161. package/dist/templates/QuotationPdf/CustomerSubscriptionSection.js +0 -165
  162. package/dist/templates/QuotationPdf/CustomerSubscriptionSection.js.map +0 -1
  163. package/dist/templates/QuotationPdf/GFV.d.ts +0 -10
  164. package/dist/templates/QuotationPdf/GFV.d.ts.map +0 -1
  165. package/dist/templates/QuotationPdf/GFV.js +0 -61
  166. package/dist/templates/QuotationPdf/GFV.js.map +0 -1
  167. package/dist/templates/QuotationPdf/Header.d.ts +0 -9
  168. package/dist/templates/QuotationPdf/Header.d.ts.map +0 -1
  169. package/dist/templates/QuotationPdf/Header.js +0 -71
  170. package/dist/templates/QuotationPdf/Header.js.map +0 -1
  171. package/dist/templates/QuotationPdf/Pricing.d.ts +0 -10
  172. package/dist/templates/QuotationPdf/Pricing.d.ts.map +0 -1
  173. package/dist/templates/QuotationPdf/Pricing.js +0 -723
  174. package/dist/templates/QuotationPdf/Pricing.js.map +0 -1
  175. package/dist/templates/QuotationPdf/QuotationPdfPage.d.ts +0 -8
  176. package/dist/templates/QuotationPdf/QuotationPdfPage.d.ts.map +0 -1
  177. package/dist/templates/QuotationPdf/QuotationPdfPage.js +0 -30
  178. package/dist/templates/QuotationPdf/QuotationPdfPage.js.map +0 -1
  179. package/dist/templates/QuotationPdf/SectionBoxNew.d.ts +0 -9
  180. package/dist/templates/QuotationPdf/SectionBoxNew.d.ts.map +0 -1
  181. package/dist/templates/QuotationPdf/SectionBoxNew.js +0 -38
  182. package/dist/templates/QuotationPdf/SectionBoxNew.js.map +0 -1
  183. package/dist/templates/QuotationPdf/TermsSection.d.ts +0 -8
  184. package/dist/templates/QuotationPdf/TermsSection.d.ts.map +0 -1
  185. package/dist/templates/QuotationPdf/TermsSection.js +0 -50
  186. package/dist/templates/QuotationPdf/TermsSection.js.map +0 -1
  187. package/dist/templates/QuotationPdf/VehiclePhotos.d.ts +0 -10
  188. package/dist/templates/QuotationPdf/VehiclePhotos.d.ts.map +0 -1
  189. package/dist/templates/QuotationPdf/VehiclePhotos.js +0 -66
  190. package/dist/templates/QuotationPdf/VehiclePhotos.js.map +0 -1
  191. package/dist/templates/QuotationPdf/index.d.ts +0 -12
  192. package/dist/templates/QuotationPdf/index.d.ts.map +0 -1
  193. package/dist/templates/QuotationPdf/index.js +0 -214
  194. package/dist/templates/QuotationPdf/index.js.map +0 -1
  195. package/dist/templates/QuotationPdf/translations.d.ts +0 -68
  196. package/dist/templates/QuotationPdf/translations.d.ts.map +0 -1
  197. package/dist/templates/QuotationPdf/translations.js +0 -101
  198. package/dist/templates/QuotationPdf/translations.js.map +0 -1
  199. package/dist/templates/QuotationPdf/utils.d.ts +0 -14
  200. package/dist/templates/QuotationPdf/utils.d.ts.map +0 -1
  201. package/dist/templates/QuotationPdf/utils.js +0 -152
  202. package/dist/templates/QuotationPdf/utils.js.map +0 -1
  203. package/dist/templates/SubscriptionAgreement/Confirmation.d.ts +0 -12
  204. package/dist/templates/SubscriptionAgreement/Confirmation.d.ts.map +0 -1
  205. package/dist/templates/SubscriptionAgreement/Confirmation.js +0 -80
  206. package/dist/templates/SubscriptionAgreement/Confirmation.js.map +0 -1
  207. package/dist/templates/SubscriptionAgreement/CoverPage.d.ts +0 -14
  208. package/dist/templates/SubscriptionAgreement/CoverPage.d.ts.map +0 -1
  209. package/dist/templates/SubscriptionAgreement/CoverPage.js +0 -111
  210. package/dist/templates/SubscriptionAgreement/CoverPage.js.map +0 -1
  211. package/dist/templates/SubscriptionAgreement/CoverPageSection.d.ts +0 -7
  212. package/dist/templates/SubscriptionAgreement/CoverPageSection.d.ts.map +0 -1
  213. package/dist/templates/SubscriptionAgreement/CoverPageSection.js +0 -25
  214. package/dist/templates/SubscriptionAgreement/CoverPageSection.js.map +0 -1
  215. package/dist/templates/SubscriptionAgreement/Details.d.ts +0 -10
  216. package/dist/templates/SubscriptionAgreement/Details.d.ts.map +0 -1
  217. package/dist/templates/SubscriptionAgreement/Details.js +0 -223
  218. package/dist/templates/SubscriptionAgreement/Details.js.map +0 -1
  219. package/dist/templates/SubscriptionAgreement/Footer.d.ts +0 -10
  220. package/dist/templates/SubscriptionAgreement/Footer.d.ts.map +0 -1
  221. package/dist/templates/SubscriptionAgreement/Footer.js +0 -58
  222. package/dist/templates/SubscriptionAgreement/Footer.js.map +0 -1
  223. package/dist/templates/SubscriptionAgreement/Header.d.ts +0 -10
  224. package/dist/templates/SubscriptionAgreement/Header.d.ts.map +0 -1
  225. package/dist/templates/SubscriptionAgreement/Header.js +0 -46
  226. package/dist/templates/SubscriptionAgreement/Header.js.map +0 -1
  227. package/dist/templates/SubscriptionAgreement/LabelValue.d.ts +0 -8
  228. package/dist/templates/SubscriptionAgreement/LabelValue.d.ts.map +0 -1
  229. package/dist/templates/SubscriptionAgreement/LabelValue.js +0 -29
  230. package/dist/templates/SubscriptionAgreement/LabelValue.js.map +0 -1
  231. package/dist/templates/SubscriptionAgreement/SubscriptionAgreementPage.d.ts +0 -10
  232. package/dist/templates/SubscriptionAgreement/SubscriptionAgreementPage.d.ts.map +0 -1
  233. package/dist/templates/SubscriptionAgreement/SubscriptionAgreementPage.js +0 -33
  234. package/dist/templates/SubscriptionAgreement/SubscriptionAgreementPage.js.map +0 -1
  235. package/dist/templates/SubscriptionAgreement/TermsOfUse.d.ts +0 -8
  236. package/dist/templates/SubscriptionAgreement/TermsOfUse.d.ts.map +0 -1
  237. package/dist/templates/SubscriptionAgreement/TermsOfUse.js +0 -101
  238. package/dist/templates/SubscriptionAgreement/TermsOfUse.js.map +0 -1
  239. package/dist/templates/SubscriptionAgreement/TermsOfUseSubSection.d.ts +0 -12
  240. package/dist/templates/SubscriptionAgreement/TermsOfUseSubSection.d.ts.map +0 -1
  241. package/dist/templates/SubscriptionAgreement/TermsOfUseSubSection.js +0 -103
  242. package/dist/templates/SubscriptionAgreement/TermsOfUseSubSection.js.map +0 -1
  243. package/dist/templates/SubscriptionAgreement/index.d.ts +0 -13
  244. package/dist/templates/SubscriptionAgreement/index.d.ts.map +0 -1
  245. package/dist/templates/SubscriptionAgreement/index.js +0 -271
  246. package/dist/templates/SubscriptionAgreement/index.js.map +0 -1
  247. package/dist/templates/SubscriptionAgreement/translations.d.ts +0 -78
  248. package/dist/templates/SubscriptionAgreement/translations.d.ts.map +0 -1
  249. package/dist/templates/SubscriptionAgreement/translations.js +0 -662
  250. package/dist/templates/SubscriptionAgreement/translations.js.map +0 -1
  251. package/dist/templates/SubscriptionAgreement/types.d.ts +0 -7
  252. package/dist/templates/SubscriptionAgreement/types.d.ts.map +0 -1
  253. package/dist/templates/SubscriptionAgreement/types.js +0 -1
  254. package/dist/templates/SubscriptionAgreement/types.js.map +0 -1
  255. package/dist/templates/SubscriptionAgreement/utils.d.ts +0 -6
  256. package/dist/templates/SubscriptionAgreement/utils.d.ts.map +0 -1
  257. package/dist/templates/SubscriptionAgreement/utils.js +0 -37
  258. package/dist/templates/SubscriptionAgreement/utils.js.map +0 -1
  259. package/dist/templates/index.d.ts +0 -3
  260. package/dist/templates/index.d.ts.map +0 -1
  261. package/dist/templates/index.js +0 -2
  262. package/dist/templates/index.js.map +0 -1
  263. package/dist/theme/colors.d.ts +0 -148
  264. package/dist/theme/colors.d.ts.map +0 -1
  265. package/dist/theme/colors.js +0 -137
  266. package/dist/theme/colors.js.map +0 -1
  267. package/dist/theme/index.d.ts +0 -2
  268. package/dist/theme/index.d.ts.map +0 -1
  269. package/dist/theme/index.js +0 -1
  270. package/dist/theme/index.js.map +0 -1
  271. package/dist/types.d.ts +0 -2
  272. package/dist/types.d.ts.map +0 -1
  273. package/dist/types.js +0 -1
  274. package/dist/types.js.map +0 -1
  275. package/dist/utils.d.ts +0 -10
  276. package/dist/utils.d.ts.map +0 -1
  277. package/dist/utils.js +0 -175
  278. package/dist/utils.js.map +0 -1
  279. package/dist/watch.d.ts +0 -2
  280. package/dist/watch.d.ts.map +0 -1
  281. package/dist/watch.js +0 -11
  282. package/dist/watch.js.map +0 -1
package/package.json CHANGED
@@ -1,52 +1,46 @@
1
1
  {
2
2
  "name": "@driveflux/pdf",
3
- "version": "4.0.77",
3
+ "version": "5.0.0-feature-e-invoicing.0",
4
4
  "type": "module",
5
+ "author": {
6
+ "name": "Aladdin Bouzerd",
7
+ "email": "aladin@driveflux.com",
8
+ "url": "https://driveflux.com"
9
+ },
5
10
  "exports": {
6
11
  ".": {
7
- "types": "./dist/index.d.ts",
8
- "import": "./dist/index.js"
12
+ "import": "./dist/main.js",
13
+ "types": "./dist/main.d.ts"
9
14
  }
10
15
  },
11
- "files": [
12
- "dist"
13
- ],
16
+ "scripts": {
17
+ "build": "bun run ./build.ts",
18
+ "build:all": "bun tsc --emitDeclarationOnly && bun run ./build.ts",
19
+ "typecheck": "tsc -b --noEmit",
20
+ "dev": "bun --watch src/preview/server.ts"
21
+ },
14
22
  "dependencies": {
15
- "@driveflux/db": "4.1.19",
16
- "@driveflux/env": "3.0.1",
17
- "@driveflux/format-money": "7.0.1",
18
- "@driveflux/time": "6.0.3",
19
- "@react-pdf/renderer": "^4.5.1",
23
+ "@driveflux/beam": "^3.0.0",
24
+ "@driveflux/db": "4.0.24-feature-e-invoicing.0",
25
+ "@driveflux/logger": "1.0.1",
26
+ "@driveflux/singleton": "3.0.0",
20
27
  "date-fns": "^4.1.0",
21
- "nodemon": "^3.1.14",
22
- "react": "19.2.6"
28
+ "@date-fns/tz": "^1.4.1",
29
+ "@elysiajs/eden": "^1.4.6",
30
+ "elysia": "^1.4.19",
31
+ "@react-pdf/renderer": "^4.3.1",
32
+ "arktype": "^2.1.22",
33
+ "bun-plugin-tailwind": "^0.1.2",
34
+ "nuqs": "^2.8.5",
35
+ "tailwindcss": "^4.1.17"
23
36
  },
24
37
  "devDependencies": {
25
- "@babel/preset-env": "^7.29.5",
26
- "@driveflux/fab": "4.0.1",
27
- "@driveflux/tsconfig": "3.0.1",
28
- "@swc/cli": "^0.8.1",
29
- "@swc/core": "^1.15.33",
30
- "@types/node": "^25.7.0",
31
- "@types/react": "19.2.14",
32
- "del-cli": "^7.0.0",
33
- "react": "19.2.6",
34
- "typescript": "^6.0.3"
35
- },
36
- "peerDependencies": {
37
- "react": "19.2.6"
38
- },
39
- "scripts": {
40
- "build": "fab",
41
- "debug": "pnpm build && node dist/debug.js",
42
- "dev": "pnpm debug && node dist/watch.js",
43
- "clean": "fab clean",
44
- "build:js": "fab -t esm",
45
- "build:types": "fab -t types",
46
- "type-check": "tsc --noEmit",
47
- "check": "biome check --write ./src",
48
- "lint:errors": "pnpm lint --diagnostic-level error",
49
- "format": "biome format --write ./src",
50
- "lint": "biome lint --write --unsafe ./src"
38
+ "react": "^19.2.3",
39
+ "react-dom": "^19.2.3",
40
+ "@types/react": "^19.2.5",
41
+ "@types/react-dom": "^19.2.3",
42
+ "@types/bun": "^1.3",
43
+ "typescript": "5.9.3",
44
+ "@driveflux/fix-builds": "1.0.0"
51
45
  }
52
- }
46
+ }
package/src/config.ts ADDED
@@ -0,0 +1,42 @@
1
+ import { type } from 'arktype'
2
+
3
+ declare global {
4
+ var __pdfConfig: Config
5
+ }
6
+
7
+ if (typeof globalThis.__pdfConfig === 'undefined') {
8
+ globalThis.__pdfConfig = undefined as any
9
+ }
10
+
11
+ export type Config = (typeof Config)['infer']
12
+
13
+ export const Config = type({
14
+ appUrl: 'string.url',
15
+ timezone: 'string',
16
+ })
17
+
18
+ const parseEnvConfig = () => ({
19
+ appUrl: 'http://localhost:3000',
20
+ timezone: 'Asia/Kuala_Lumpur',
21
+ })
22
+
23
+ const loadConfigInternal = () => {
24
+ return Object.freeze(Config.assert(parseEnvConfig()))
25
+ }
26
+
27
+ export let config = globalThis.__pdfConfig ?? loadConfigInternal()
28
+
29
+ export const loadConfig = () => {
30
+ globalThis.__pdfConfig = loadConfigInternal()
31
+ config = globalThis.__pdfConfig
32
+ return config
33
+ }
34
+
35
+ export const setConfig = <K extends keyof Config>(key: K, value: Config[K]) => {
36
+ globalThis.__pdfConfig = {
37
+ ...globalThis.__pdfConfig,
38
+ [key]: value,
39
+ }
40
+ config = globalThis.__pdfConfig
41
+ return config
42
+ }
@@ -0,0 +1,4 @@
1
+ import { createLogger } from '@driveflux/logger'
2
+
3
+ export const createScopedLogger = (name: string) =>
4
+ createLogger(`flux:pdf:${name}`)
package/src/errors.ts ADDED
@@ -0,0 +1,35 @@
1
+ export abstract class PDFError extends Error {
2
+ abstract readonly code: string
3
+ abstract readonly status: number
4
+
5
+ toResponse() {
6
+ return Response.json(
7
+ {
8
+ error: this.message,
9
+ code: this.code,
10
+ },
11
+ {
12
+ status: this.status,
13
+ },
14
+ )
15
+ }
16
+ }
17
+
18
+ export const PDFErrors = {
19
+ InvoiceNotEInvoice: class InvoiceNotEInvoice extends PDFError {
20
+ readonly code = 'invoice_not_einvoice'
21
+ readonly status = 400
22
+
23
+ constructor(readonly invoiceId: string) {
24
+ super(`Invoice ${invoiceId} is not an e-invoice`)
25
+ }
26
+ },
27
+ InvoiceNotFound: class InvoiceNotFound extends PDFError {
28
+ readonly code = 'invoice_not_found'
29
+ readonly status = 404
30
+
31
+ constructor(readonly invoiceId: string) {
32
+ super(`Invoice ${invoiceId} not found`)
33
+ }
34
+ },
35
+ } as const
package/src/main.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { createScopedLogger } from './create-logger'
2
+
3
+ const _log = createScopedLogger('main')
4
+
5
+ export const main = () => {
6
+ console.info('Hello, world!')
7
+ }
@@ -0,0 +1,33 @@
1
+ import { isId } from '@driveflux/db/id'
2
+ import { type } from 'arktype'
3
+ import Elysia, { status } from 'elysia'
4
+ import { PDFError, PDFErrors } from '../errors'
5
+ import { repository } from '../repository'
6
+
7
+ export const api = new Elysia()
8
+ .error(PDFErrors)
9
+ .onError(({ error }) => {
10
+ if (error instanceof PDFError) {
11
+ return status(
12
+ error.status as (typeof PDFErrors)[keyof typeof PDFErrors]['prototype']['status'],
13
+ {
14
+ code: error.code as (typeof PDFErrors)[keyof typeof PDFErrors]['prototype']['code'],
15
+ context: 'PDFError',
16
+ message: error.message,
17
+ },
18
+ )
19
+ }
20
+ })
21
+ .get(
22
+ '/api/invoice-for-pdf/:invoiceId',
23
+ async ({ params }) => {
24
+ return await repository.getInvoiceForPDF(params.invoiceId)
25
+ },
26
+ {
27
+ params: type({
28
+ invoiceId: type('string')
29
+ .narrow((id) => isId(id, true, ['Invoice']))
30
+ .describe('Invoice ID must be a valid FLUX invoice ID'),
31
+ }),
32
+ },
33
+ )
@@ -0,0 +1,30 @@
1
+ import Box from '@driveflux/beam/box'
2
+ import Text from '@driveflux/beam/text'
3
+ import { Toaster } from '@driveflux/beam/toast'
4
+ import { cn } from '@driveflux/beam/utils'
5
+ import '../global.css'
6
+ import { Preview } from './preview'
7
+ import { Sidebar } from './sidebar'
8
+ import { useTarget } from './use-target'
9
+
10
+ export const App = () => {
11
+ const [target, setTarget] = useTarget()
12
+ return (
13
+ <Box className="flex h-screen overflow-hidden">
14
+ <Box className="flex-shrink-0 overflow-y-auto">
15
+ <Sidebar onSelect={setTarget} selectedTarget={target} />
16
+ </Box>
17
+ <Box className="flex-1 overflow-hidden">
18
+ <main className={cn('flex flex-col items-center w-full h-full')}>
19
+ {target && <Preview target={target} />}
20
+ {!target && (
21
+ <Box className="w-full h-full flex flex-col flex-grow-1 items-center justify-center">
22
+ <Text>Select a target to preview</Text>
23
+ </Box>
24
+ )}
25
+ </main>
26
+ </Box>
27
+ <Toaster />
28
+ </Box>
29
+ )
30
+ }
@@ -0,0 +1,27 @@
1
+ import { Document } from '@react-pdf/renderer'
2
+ import { FLUXInvoice } from '../../../templates/invoice/flux-invoice'
3
+ import {
4
+ HostInvoice,
5
+ type HostInvoiceProps,
6
+ } from '../../../templates/invoice/host-invoice'
7
+ import { InvoiceSummary } from '../../../templates/invoice/invoice-summary'
8
+ import type { InvoiceForPDF } from '../../../templates/invoice/types'
9
+ import { registerFonts } from '../../fonts/register-fonts'
10
+
11
+ export type InvoiceDisplayProps = {
12
+ invoice: InvoiceForPDF
13
+ }
14
+
15
+ registerFonts()
16
+
17
+ export const InvoiceDisplay = ({ invoice }: InvoiceDisplayProps) => {
18
+ return (
19
+ <Document>
20
+ <InvoiceSummary data={invoice} />
21
+ <FLUXInvoice data={invoice} />
22
+ {invoice.eInvoice?.hostDetails && (
23
+ <HostInvoice data={invoice as HostInvoiceProps['data']} />
24
+ )}
25
+ </Document>
26
+ )
27
+ }
@@ -0,0 +1,95 @@
1
+ import Box from '@driveflux/beam/box'
2
+ import Button from '@driveflux/beam/button'
3
+ import HStack from '@driveflux/beam/hstack'
4
+ import Input from '@driveflux/beam/input'
5
+ import { toast } from '@driveflux/beam/toast'
6
+ import { useCallback, useEffect, useState } from 'react'
7
+ import { appTreaty } from '../treaty'
8
+ import type { InvoiceDisplayProps } from './invoice-display'
9
+
10
+ type Props = {
11
+ onPropsUpdated: (props: InvoiceDisplayProps | { error: string }) => void
12
+ }
13
+
14
+ let submitted = false
15
+ export const InvoiceSetup = ({ onPropsUpdated }: Props) => {
16
+ const [invoiceId, setInvoiceId] = useState<string>('')
17
+
18
+ const fetchInvoice = useCallback(
19
+ async (invoiceId: string) => {
20
+ const result = await appTreaty.api['invoice-for-pdf']({
21
+ invoiceId,
22
+ }).get()
23
+
24
+ if (result.status === 404) {
25
+ toast({
26
+ title: 'Invoice not found',
27
+ description: 'The invoice you are looking for does not exist.',
28
+ status: 'error',
29
+ })
30
+ return
31
+ }
32
+
33
+ if (result.error) {
34
+ const error =
35
+ typeof result.error === 'string'
36
+ ? (result as any).error
37
+ : (result as any).error.value.summary ||
38
+ result.error.value.message ||
39
+ 'An unknown error occurred'
40
+ toast({
41
+ title: 'Error',
42
+ description: error,
43
+
44
+ status: 'error',
45
+ })
46
+ onPropsUpdated({ error })
47
+ return
48
+ }
49
+
50
+ onPropsUpdated({ invoice: result.data })
51
+ return result
52
+ },
53
+ [onPropsUpdated],
54
+ )
55
+
56
+ const handleSubmit = useCallback(
57
+ async (e: React.FormEvent<HTMLFormElement>) => {
58
+ e.preventDefault()
59
+ await fetchInvoice(invoiceId)
60
+ },
61
+ [fetchInvoice, invoiceId],
62
+ )
63
+
64
+ useEffect(() => {
65
+ if (!invoiceId) {
66
+ setInvoiceId('I_JLJXH4JL')
67
+ }
68
+ }, [invoiceId])
69
+ useEffect(() => {
70
+ if (invoiceId === 'I_JLJXH4JL' && !submitted) {
71
+ submitted = true
72
+ handleSubmit(
73
+ new Event('submit') as unknown as React.FormEvent<HTMLFormElement>,
74
+ )
75
+ }
76
+ }, [invoiceId, handleSubmit])
77
+
78
+ return (
79
+ <Box>
80
+ <form onSubmit={handleSubmit}>
81
+ <HStack className="items-end">
82
+ <Input
83
+ htmlFor="invoiceId"
84
+ id="invoiceId"
85
+ label="Invoice ID"
86
+ type="text"
87
+ value={invoiceId}
88
+ onChange={(e) => setInvoiceId(e.target.value)}
89
+ />
90
+ <Button type="submit">Ok</Button>
91
+ </HStack>
92
+ </form>
93
+ </Box>
94
+ )
95
+ }
@@ -0,0 +1,30 @@
1
+ import type { FunctionComponent, LazyExoticComponent } from 'react'
2
+ import { InvoiceDisplay } from './invoice/invoice-display'
3
+ import { InvoiceSetup } from './invoice/invoice-setup'
4
+
5
+ type PreviewTargetSetup =
6
+ | LazyExoticComponent<
7
+ FunctionComponent<{ onPropsUpdated: (props: any) => void }>
8
+ >
9
+ | FunctionComponent<{ onPropsUpdated: (props: any) => void }>
10
+
11
+ type PreviewTargetDisplay =
12
+ | LazyExoticComponent<FunctionComponent<any>>
13
+ | FunctionComponent<any>
14
+
15
+ export const PREVIEW_TARGETS = {
16
+ invoice: {
17
+ title: 'Invoice',
18
+ Setup: InvoiceSetup,
19
+ Display: InvoiceDisplay,
20
+ },
21
+ } as const satisfies Record<
22
+ string,
23
+ {
24
+ title: string
25
+ Setup: PreviewTargetSetup
26
+ Display: PreviewTargetDisplay
27
+ }
28
+ >
29
+
30
+ export type PreviewTarget = keyof typeof PREVIEW_TARGETS
@@ -0,0 +1,37 @@
1
+ import Box from '@driveflux/beam/box'
2
+ import Divider from '@driveflux/beam/divider'
3
+ import Text from '@driveflux/beam/text'
4
+ import VStack from '@driveflux/beam/vstack'
5
+ import { PDFViewer } from '@react-pdf/renderer'
6
+ import { useState } from 'react'
7
+ import { PREVIEW_TARGETS, type PreviewTarget } from './preview-targets'
8
+
9
+ type Props = {
10
+ target: PreviewTarget
11
+ }
12
+
13
+ export const Preview = ({ target }: Props) => {
14
+ const { Setup, Display } = PREVIEW_TARGETS[target]
15
+ const [props, setProps] = useState<any>(null)
16
+
17
+ const error =
18
+ typeof props === 'object' &&
19
+ props !== null &&
20
+ 'error' in props &&
21
+ props.error
22
+ const displayResult = props && !error ? <Display {...(props ?? {})} /> : null
23
+ return (
24
+ <VStack className="w-full h-full">
25
+ {Setup && (
26
+ <Box className="w-full p-4 flex-shrink-0">
27
+ <Setup onPropsUpdated={setProps} />
28
+ </Box>
29
+ )}
30
+ <Divider />
31
+ {displayResult && (
32
+ <PDFViewer className="w-full h-svh">{displayResult}</PDFViewer>
33
+ )}
34
+ {error ? <Text>{error}</Text> : null}
35
+ </VStack>
36
+ )
37
+ }
@@ -0,0 +1,39 @@
1
+ import Box from '@driveflux/beam/box'
2
+ import Button from '@driveflux/beam/button'
3
+ import Text from '@driveflux/beam/text'
4
+ import { cn } from '@driveflux/beam/utils'
5
+ import { PREVIEW_TARGETS, type PreviewTarget } from './preview-targets'
6
+
7
+ type Props = {
8
+ onSelect: (target: PreviewTarget) => void
9
+ selectedTarget?: PreviewTarget | null
10
+ }
11
+
12
+ export const Sidebar = ({ onSelect, selectedTarget }: Props) => {
13
+ return (
14
+ <Box className="w-64 bg-gray-50 border-r border-gray-200 min-h-screen p-4">
15
+ <Text className="text-lg font-semibold mb-4 text-gray-800">
16
+ Preview Targets
17
+ </Text>
18
+ <Box className="space-y-2">
19
+ {Object.entries(PREVIEW_TARGETS).map(([key, target]) => (
20
+ <Button
21
+ key={key}
22
+ variant={selectedTarget === key ? 'outline' : undefined}
23
+ disabled={selectedTarget === key}
24
+ className={cn(
25
+ 'w-full',
26
+ // 'p-3 rounded-lg cursor-pointer transition-all duration-200 border',
27
+ // selectedTarget === key
28
+ // ? 'bg-blue-500 text-white border-blue-500 shadow-md'
29
+ // : 'bg-white text-gray-700 border-gray-200 hover:bg-gray-100 hover:border-gray-300 hover:shadow-sm',
30
+ )}
31
+ onClick={() => onSelect(key as PreviewTarget)}
32
+ >
33
+ <Text className="font-medium">{target.title}</Text>
34
+ </Button>
35
+ ))}
36
+ </Box>
37
+ </Box>
38
+ )
39
+ }
@@ -0,0 +1,8 @@
1
+ import { treaty } from '@elysiajs/eden'
2
+ import type { api } from '../api'
3
+
4
+ export const appTreaty = treaty<typeof api>(
5
+ process.env.FLUX_PUBLIC_APP_URL
6
+ ? `${process.env.FLUX_PUBLIC_APP_URL}`
7
+ : 'http://localhost:3000',
8
+ )
@@ -0,0 +1,11 @@
1
+ import { parseAsStringLiteral, useQueryState } from 'nuqs'
2
+ import { PREVIEW_TARGETS, type PreviewTarget } from './preview-targets'
3
+
4
+ const parser = parseAsStringLiteral(
5
+ Object.keys(PREVIEW_TARGETS) as PreviewTarget[],
6
+ )
7
+
8
+ export const useTarget = () => {
9
+ const state = useQueryState('target', parser)
10
+ return state
11
+ }