@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.
- package/.env +0 -0
- package/.env.development +4 -0
- package/.turbo/turbo-build.log +14 -0
- package/CHANGELOG.md +15 -0
- package/build.ts +45 -0
- package/bun-env.d.ts +34 -0
- package/bunfig.toml +8 -0
- package/catalog-version-stamp.json +8 -0
- package/dist/main.js +4 -0
- package/dist/main.js.map +11 -0
- package/dist/src/config.d.ts +20 -0
- package/dist/src/create-logger.d.ts +1 -0
- package/dist/src/errors.d.ts +43 -0
- package/dist/src/main.d.ts +1 -0
- package/dist/src/preview/api.d.ts +264 -0
- package/dist/src/preview/client/app.d.ts +2 -0
- package/dist/src/preview/client/invoice/invoice-display.d.ts +5 -0
- package/dist/src/preview/client/invoice/invoice-setup.d.ts +8 -0
- package/dist/src/preview/client/preview-targets.d.ts +12 -0
- package/dist/src/preview/client/preview.d.ts +6 -0
- package/dist/src/preview/client/sidebar.d.ts +7 -0
- package/dist/src/preview/client/treaty.d.ts +200 -0
- package/dist/src/preview/client/use-target.d.ts +1 -0
- package/dist/src/preview/fonts/register-fonts.d.ts +1 -0
- package/dist/src/preview/frontend.d.ts +1 -0
- package/dist/src/preview/server.d.ts +1 -0
- package/dist/src/repository.d.ts +171 -0
- package/dist/src/templates/invoice/colors.d.ts +6 -0
- package/dist/src/templates/invoice/company-details.d.ts +10 -0
- package/dist/src/templates/invoice/flux-invoice.d.ts +6 -0
- package/dist/src/templates/invoice/footer.d.ts +2 -0
- package/dist/src/templates/invoice/host-invoice.d.ts +9 -0
- package/dist/src/templates/invoice/invoice-details.d.ts +13 -0
- package/dist/src/templates/invoice/invoice-notes.d.ts +1 -0
- package/dist/src/templates/invoice/invoice-summary.d.ts +7 -0
- package/dist/src/templates/invoice/letter-head.d.ts +10 -0
- package/dist/src/templates/invoice/li.d.ts +10 -0
- package/dist/src/templates/invoice/platform-and-host-details.d.ts +11 -0
- package/dist/src/templates/invoice/spacer.d.ts +3 -0
- package/dist/src/templates/invoice/split-container-items.d.ts +10 -0
- package/dist/src/templates/invoice/split-container.d.ts +7 -0
- package/dist/src/templates/invoice/standard-page.d.ts +7 -0
- package/dist/src/templates/invoice/types.d.ts +3 -0
- package/dist/src/templates/invoice/ul.d.ts +8 -0
- package/dist/src/templates/invoice/utils.d.ts +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +34 -40
- package/src/config.ts +42 -0
- package/src/create-logger.ts +4 -0
- package/src/errors.ts +35 -0
- package/src/main.ts +7 -0
- package/src/preview/api.ts +33 -0
- package/src/preview/client/app.tsx +30 -0
- package/src/preview/client/invoice/invoice-display.tsx +27 -0
- package/src/preview/client/invoice/invoice-setup.tsx +95 -0
- package/src/preview/client/preview-targets.ts +30 -0
- package/src/preview/client/preview.tsx +37 -0
- package/src/preview/client/sidebar.tsx +39 -0
- package/src/preview/client/treaty.ts +8 -0
- package/src/preview/client/use-target.ts +11 -0
- package/src/preview/fonts/GOTHAM-BLACK.TTF +0 -0
- package/src/preview/fonts/GOTHAM-BLACKITALIC.TTF +0 -0
- package/src/preview/fonts/GOTHAM-BOLD.TTF +0 -0
- package/src/preview/fonts/GOTHAM-BOLDITALIC.TTF +0 -0
- package/src/preview/fonts/GOTHAM-LIGHT.TTF +0 -0
- package/src/preview/fonts/GOTHAM-LIGHTITALIC.TTF +0 -0
- package/src/preview/fonts/GOTHAM-MEDIUM.TTF +0 -0
- package/src/preview/fonts/GOTHAM-MEDIUMITALIC.TTF +0 -0
- package/src/preview/fonts/GOTHAM-THIN.TTF +0 -0
- package/src/preview/fonts/GOTHAM-THINITALIC.TTF +0 -0
- package/src/preview/fonts/GOTHAM-ULTRA.TTF +0 -0
- package/src/preview/fonts/GOTHAM-ULTRAITALIC.TTF +0 -0
- package/src/preview/fonts/GOTHAM-XLIGHT.TTF +0 -0
- package/src/preview/fonts/GOTHAM-XLIGHTITALIC.TTF +0 -0
- package/src/preview/fonts/Gotham Book Italic.otf +0 -0
- package/src/preview/fonts/Gotham-BoldItalic.otf +0 -0
- package/src/preview/fonts/Gotham-Book.otf +0 -0
- package/src/preview/fonts/Gotham-BookItalic.otf +0 -0
- package/src/preview/fonts/Gotham-ExtraLight.otf +0 -0
- package/src/preview/fonts/Gotham-ExtraLightItalic.otf +0 -0
- package/src/preview/fonts/Gotham-Light.otf +0 -0
- package/src/preview/fonts/Gotham-LightItalic.otf +0 -0
- package/src/preview/fonts/Gotham-Medium.otf +0 -0
- package/src/preview/fonts/Gotham-MediumItalic.otf +0 -0
- package/src/preview/fonts/Gotham-Thin.otf +0 -0
- package/src/preview/fonts/Gotham-ThinItalic.otf +0 -0
- package/src/preview/fonts/Gotham-Ultra.otf +0 -0
- package/src/preview/fonts/Gotham-UltraItalic.otf +0 -0
- package/src/preview/fonts/GothamNarrow-Black.otf +0 -0
- package/src/preview/fonts/GothamNarrow-BlackItalic.otf +0 -0
- package/src/preview/fonts/GothamNarrow-Book.otf +0 -0
- package/src/preview/fonts/GothamNarrow-BookItalic.otf +0 -0
- package/src/preview/fonts/GothamNarrow-Light.otf +0 -0
- package/src/preview/fonts/GothamNarrow-LightItalic.otf +0 -0
- package/src/preview/fonts/GothamNarrow-Medium.otf +0 -0
- package/src/preview/fonts/GothamNarrow-MediumItalic.otf +0 -0
- package/src/preview/fonts/GothamNarrow-Thin.otf +0 -0
- package/src/preview/fonts/GothamNarrow-ThinItalic.otf +0 -0
- package/src/preview/fonts/GothamNarrow-Ultra.otf +0 -0
- package/src/preview/fonts/GothamNarrow-UltraItalic.otf +0 -0
- package/src/preview/fonts/GothamNarrow-XLight.otf +0 -0
- package/src/preview/fonts/GothamNarrow-XLightItalic.otf +0 -0
- package/src/preview/fonts/gotham-extra-narrow-bold-italic.otf +0 -0
- package/src/preview/fonts/gotham-extra-narrow-bold.otf +0 -0
- package/src/preview/fonts/gotham-extra-narrow-book-italic.otf +0 -0
- package/src/preview/fonts/gotham-extra-narrow-book.otf +0 -0
- package/src/preview/fonts/gotham-extra-narrow-light-italic.otf +0 -0
- package/src/preview/fonts/gotham-extra-narrow-light.otf +0 -0
- package/src/preview/fonts/gotham-extra-narrow-medium-italic.otf +0 -0
- package/src/preview/fonts/gotham-extra-narrow-medium.otf +0 -0
- package/src/preview/fonts/gotham-rounded-bold-italic.otf +0 -0
- package/src/preview/fonts/gotham-rounded-bold.otf +0 -0
- package/src/preview/fonts/gotham-rounded-book-italic.otf +0 -0
- package/src/preview/fonts/gotham-rounded-book.otf +0 -0
- package/src/preview/fonts/gotham-rounded-light-italic.otf +0 -0
- package/src/preview/fonts/gotham-rounded-light.otf +0 -0
- package/src/preview/fonts/gotham-rounded-medium-italic.otf +0 -0
- package/src/preview/fonts/gotham-rounded-medium.otf +0 -0
- package/src/preview/fonts/register-fonts.ts +395 -0
- package/src/preview/frontend.tsx +23 -0
- package/src/preview/global.css +39 -0
- package/src/preview/preview.html +12 -0
- package/src/preview/server.ts +28 -0
- package/src/repository.ts +39 -0
- package/src/templates/invoice/E Invoice Format.pdf +0 -0
- package/src/templates/invoice/colors.ts +6 -0
- package/src/templates/invoice/company-details.tsx +124 -0
- package/src/templates/invoice/flux-invoice.tsx +134 -0
- package/src/templates/invoice/footer.tsx +46 -0
- package/src/templates/invoice/host-invoice.tsx +134 -0
- package/src/templates/invoice/images/logo.png +0 -0
- package/src/templates/invoice/images/logo.svg +41 -0
- package/src/templates/invoice/invoice-details.tsx +231 -0
- package/src/templates/invoice/invoice-notes.tsx +74 -0
- package/src/templates/invoice/invoice-summary.tsx +135 -0
- package/src/templates/invoice/letter-head.tsx +132 -0
- package/src/templates/invoice/li.tsx +48 -0
- package/src/templates/invoice/platform-and-host-details.tsx +56 -0
- package/src/templates/invoice/spacer.tsx +5 -0
- package/src/templates/invoice/split-container-items.tsx +80 -0
- package/src/templates/invoice/split-container.tsx +35 -0
- package/src/templates/invoice/standard-page.tsx +45 -0
- package/src/templates/invoice/types.ts +6 -0
- package/src/templates/invoice/ul.tsx +19 -0
- package/src/templates/invoice/utils.ts +5 -0
- package/tsconfig.json +21 -0
- package/dist/components/FluxLogo.d.ts +0 -3
- package/dist/components/FluxLogo.d.ts.map +0 -1
- package/dist/components/FluxLogo.js +0 -66
- package/dist/components/FluxLogo.js.map +0 -1
- package/dist/components/StandardPage.d.ts +0 -7
- package/dist/components/StandardPage.d.ts.map +0 -1
- package/dist/components/StandardPage.js +0 -132
- package/dist/components/StandardPage.js.map +0 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -1
- package/dist/templates/QuotationPdf/CustomerSubscriptionSection.d.ts +0 -10
- package/dist/templates/QuotationPdf/CustomerSubscriptionSection.d.ts.map +0 -1
- package/dist/templates/QuotationPdf/CustomerSubscriptionSection.js +0 -165
- package/dist/templates/QuotationPdf/CustomerSubscriptionSection.js.map +0 -1
- package/dist/templates/QuotationPdf/GFV.d.ts +0 -10
- package/dist/templates/QuotationPdf/GFV.d.ts.map +0 -1
- package/dist/templates/QuotationPdf/GFV.js +0 -61
- package/dist/templates/QuotationPdf/GFV.js.map +0 -1
- package/dist/templates/QuotationPdf/Header.d.ts +0 -9
- package/dist/templates/QuotationPdf/Header.d.ts.map +0 -1
- package/dist/templates/QuotationPdf/Header.js +0 -71
- package/dist/templates/QuotationPdf/Header.js.map +0 -1
- package/dist/templates/QuotationPdf/Pricing.d.ts +0 -10
- package/dist/templates/QuotationPdf/Pricing.d.ts.map +0 -1
- package/dist/templates/QuotationPdf/Pricing.js +0 -723
- package/dist/templates/QuotationPdf/Pricing.js.map +0 -1
- package/dist/templates/QuotationPdf/QuotationPdfPage.d.ts +0 -8
- package/dist/templates/QuotationPdf/QuotationPdfPage.d.ts.map +0 -1
- package/dist/templates/QuotationPdf/QuotationPdfPage.js +0 -30
- package/dist/templates/QuotationPdf/QuotationPdfPage.js.map +0 -1
- package/dist/templates/QuotationPdf/SectionBoxNew.d.ts +0 -9
- package/dist/templates/QuotationPdf/SectionBoxNew.d.ts.map +0 -1
- package/dist/templates/QuotationPdf/SectionBoxNew.js +0 -38
- package/dist/templates/QuotationPdf/SectionBoxNew.js.map +0 -1
- package/dist/templates/QuotationPdf/TermsSection.d.ts +0 -8
- package/dist/templates/QuotationPdf/TermsSection.d.ts.map +0 -1
- package/dist/templates/QuotationPdf/TermsSection.js +0 -50
- package/dist/templates/QuotationPdf/TermsSection.js.map +0 -1
- package/dist/templates/QuotationPdf/VehiclePhotos.d.ts +0 -10
- package/dist/templates/QuotationPdf/VehiclePhotos.d.ts.map +0 -1
- package/dist/templates/QuotationPdf/VehiclePhotos.js +0 -66
- package/dist/templates/QuotationPdf/VehiclePhotos.js.map +0 -1
- package/dist/templates/QuotationPdf/index.d.ts +0 -12
- package/dist/templates/QuotationPdf/index.d.ts.map +0 -1
- package/dist/templates/QuotationPdf/index.js +0 -214
- package/dist/templates/QuotationPdf/index.js.map +0 -1
- package/dist/templates/QuotationPdf/translations.d.ts +0 -68
- package/dist/templates/QuotationPdf/translations.d.ts.map +0 -1
- package/dist/templates/QuotationPdf/translations.js +0 -101
- package/dist/templates/QuotationPdf/translations.js.map +0 -1
- package/dist/templates/QuotationPdf/utils.d.ts +0 -14
- package/dist/templates/QuotationPdf/utils.d.ts.map +0 -1
- package/dist/templates/QuotationPdf/utils.js +0 -152
- package/dist/templates/QuotationPdf/utils.js.map +0 -1
- package/dist/templates/SubscriptionAgreement/Confirmation.d.ts +0 -12
- package/dist/templates/SubscriptionAgreement/Confirmation.d.ts.map +0 -1
- package/dist/templates/SubscriptionAgreement/Confirmation.js +0 -80
- package/dist/templates/SubscriptionAgreement/Confirmation.js.map +0 -1
- package/dist/templates/SubscriptionAgreement/CoverPage.d.ts +0 -14
- package/dist/templates/SubscriptionAgreement/CoverPage.d.ts.map +0 -1
- package/dist/templates/SubscriptionAgreement/CoverPage.js +0 -111
- package/dist/templates/SubscriptionAgreement/CoverPage.js.map +0 -1
- package/dist/templates/SubscriptionAgreement/CoverPageSection.d.ts +0 -7
- package/dist/templates/SubscriptionAgreement/CoverPageSection.d.ts.map +0 -1
- package/dist/templates/SubscriptionAgreement/CoverPageSection.js +0 -25
- package/dist/templates/SubscriptionAgreement/CoverPageSection.js.map +0 -1
- package/dist/templates/SubscriptionAgreement/Details.d.ts +0 -10
- package/dist/templates/SubscriptionAgreement/Details.d.ts.map +0 -1
- package/dist/templates/SubscriptionAgreement/Details.js +0 -223
- package/dist/templates/SubscriptionAgreement/Details.js.map +0 -1
- package/dist/templates/SubscriptionAgreement/Footer.d.ts +0 -10
- package/dist/templates/SubscriptionAgreement/Footer.d.ts.map +0 -1
- package/dist/templates/SubscriptionAgreement/Footer.js +0 -58
- package/dist/templates/SubscriptionAgreement/Footer.js.map +0 -1
- package/dist/templates/SubscriptionAgreement/Header.d.ts +0 -10
- package/dist/templates/SubscriptionAgreement/Header.d.ts.map +0 -1
- package/dist/templates/SubscriptionAgreement/Header.js +0 -46
- package/dist/templates/SubscriptionAgreement/Header.js.map +0 -1
- package/dist/templates/SubscriptionAgreement/LabelValue.d.ts +0 -8
- package/dist/templates/SubscriptionAgreement/LabelValue.d.ts.map +0 -1
- package/dist/templates/SubscriptionAgreement/LabelValue.js +0 -29
- package/dist/templates/SubscriptionAgreement/LabelValue.js.map +0 -1
- package/dist/templates/SubscriptionAgreement/SubscriptionAgreementPage.d.ts +0 -10
- package/dist/templates/SubscriptionAgreement/SubscriptionAgreementPage.d.ts.map +0 -1
- package/dist/templates/SubscriptionAgreement/SubscriptionAgreementPage.js +0 -33
- package/dist/templates/SubscriptionAgreement/SubscriptionAgreementPage.js.map +0 -1
- package/dist/templates/SubscriptionAgreement/TermsOfUse.d.ts +0 -8
- package/dist/templates/SubscriptionAgreement/TermsOfUse.d.ts.map +0 -1
- package/dist/templates/SubscriptionAgreement/TermsOfUse.js +0 -101
- package/dist/templates/SubscriptionAgreement/TermsOfUse.js.map +0 -1
- package/dist/templates/SubscriptionAgreement/TermsOfUseSubSection.d.ts +0 -12
- package/dist/templates/SubscriptionAgreement/TermsOfUseSubSection.d.ts.map +0 -1
- package/dist/templates/SubscriptionAgreement/TermsOfUseSubSection.js +0 -103
- package/dist/templates/SubscriptionAgreement/TermsOfUseSubSection.js.map +0 -1
- package/dist/templates/SubscriptionAgreement/index.d.ts +0 -13
- package/dist/templates/SubscriptionAgreement/index.d.ts.map +0 -1
- package/dist/templates/SubscriptionAgreement/index.js +0 -271
- package/dist/templates/SubscriptionAgreement/index.js.map +0 -1
- package/dist/templates/SubscriptionAgreement/translations.d.ts +0 -78
- package/dist/templates/SubscriptionAgreement/translations.d.ts.map +0 -1
- package/dist/templates/SubscriptionAgreement/translations.js +0 -662
- package/dist/templates/SubscriptionAgreement/translations.js.map +0 -1
- package/dist/templates/SubscriptionAgreement/types.d.ts +0 -7
- package/dist/templates/SubscriptionAgreement/types.d.ts.map +0 -1
- package/dist/templates/SubscriptionAgreement/types.js +0 -1
- package/dist/templates/SubscriptionAgreement/types.js.map +0 -1
- package/dist/templates/SubscriptionAgreement/utils.d.ts +0 -6
- package/dist/templates/SubscriptionAgreement/utils.d.ts.map +0 -1
- package/dist/templates/SubscriptionAgreement/utils.js +0 -37
- package/dist/templates/SubscriptionAgreement/utils.js.map +0 -1
- package/dist/templates/index.d.ts +0 -3
- package/dist/templates/index.d.ts.map +0 -1
- package/dist/templates/index.js +0 -2
- package/dist/templates/index.js.map +0 -1
- package/dist/theme/colors.d.ts +0 -148
- package/dist/theme/colors.d.ts.map +0 -1
- package/dist/theme/colors.js +0 -137
- package/dist/theme/colors.js.map +0 -1
- package/dist/theme/index.d.ts +0 -2
- package/dist/theme/index.d.ts.map +0 -1
- package/dist/theme/index.js +0 -1
- package/dist/theme/index.js.map +0 -1
- package/dist/types.d.ts +0 -2
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -1
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -10
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -175
- package/dist/utils.js.map +0 -1
- package/dist/watch.d.ts +0 -2
- package/dist/watch.d.ts.map +0 -1
- package/dist/watch.js +0 -11
- package/dist/watch.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,52 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driveflux/pdf",
|
|
3
|
-
"version": "
|
|
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
|
-
"
|
|
8
|
-
"
|
|
12
|
+
"import": "./dist/main.js",
|
|
13
|
+
"types": "./dist/main.d.ts"
|
|
9
14
|
}
|
|
10
15
|
},
|
|
11
|
-
"
|
|
12
|
-
"
|
|
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/
|
|
16
|
-
"@driveflux/
|
|
17
|
-
"@driveflux/
|
|
18
|
-
"@driveflux/
|
|
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
|
-
"
|
|
22
|
-
"
|
|
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
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"@
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"
|
|
31
|
-
"@
|
|
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
|
+
}
|
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,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,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
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|