create-protobase 0.66.3 → 0.66.5
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/dist/templates/erp/documents/invoice.tsx +33 -0
- package/dist/templates/erp/functions/invoice-pdf.ts +18 -0
- package/dist/templates/erp/package.json +6 -6
- package/dist/templates/property-portal/package.json +6 -6
- package/dist/templates/real-estate/package.json +6 -6
- package/dist/templates/scratch/package.json +6 -6
- package/package.json +2 -2
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { definePdf } from '@protobase/server'
|
|
2
|
+
import { Document, Page, StyleSheet, Text, View } from '@protobase/server/pdf'
|
|
3
|
+
|
|
4
|
+
export type InvoiceDocumentData = { number: string; company: string; issuedAt: string; dueAt: string; total: string }
|
|
5
|
+
|
|
6
|
+
const styles = StyleSheet.create({
|
|
7
|
+
page: { padding: 48, fontSize: 11 },
|
|
8
|
+
heading: { fontSize: 20, marginBottom: 16 },
|
|
9
|
+
row: { flexDirection: 'row', justifyContent: 'space-between', marginBottom: 4 },
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
const InvoiceDocument = ({ number, company, issuedAt, dueAt, total }: InvoiceDocumentData) => (
|
|
13
|
+
<Document title={`Invoice ${number}`}>
|
|
14
|
+
<Page size="A4" style={styles.page}>
|
|
15
|
+
<Text style={styles.heading}>Invoice {number}</Text>
|
|
16
|
+
<Text>{company}</Text>
|
|
17
|
+
<View style={styles.row}>
|
|
18
|
+
<Text>Issued</Text>
|
|
19
|
+
<Text>{issuedAt}</Text>
|
|
20
|
+
</View>
|
|
21
|
+
<View style={styles.row}>
|
|
22
|
+
<Text>Due</Text>
|
|
23
|
+
<Text>{dueAt}</Text>
|
|
24
|
+
</View>
|
|
25
|
+
<View style={styles.row}>
|
|
26
|
+
<Text>Total</Text>
|
|
27
|
+
<Text>{total}</Text>
|
|
28
|
+
</View>
|
|
29
|
+
</Page>
|
|
30
|
+
</Document>
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
export const invoiceDocument = definePdf({ name: 'invoice', component: InvoiceDocument })
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineFunction } from '@protobase/server'
|
|
2
|
+
import { invoiceDocument } from '../documents/invoice'
|
|
3
|
+
|
|
4
|
+
// GET /api/functions/invoice-pdf/<id>: the invoice as a PDF file, for anyone who reads invoices.
|
|
5
|
+
export default defineFunction({ capability: 'invoices.read' }, async (request, { records }) => {
|
|
6
|
+
const id = new URL(request.url).pathname.slice(1)
|
|
7
|
+
const { record: invoice } = await records.get('invoices', id)
|
|
8
|
+
const { record: company } = await records.get('companies', invoice.company_id as number)
|
|
9
|
+
const number = invoice.number as string
|
|
10
|
+
const pdf = await invoiceDocument.render({
|
|
11
|
+
number,
|
|
12
|
+
company: company.name as string,
|
|
13
|
+
issuedAt: invoice.issued_at as string,
|
|
14
|
+
dueAt: invoice.due_at as string,
|
|
15
|
+
total: invoice.total as string,
|
|
16
|
+
})
|
|
17
|
+
return new Response(pdf, { headers: { 'content-type': 'application/pdf', 'content-disposition': `inline; filename="invoice-${number}.pdf"` } })
|
|
18
|
+
})
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"zod": "^4.6.5"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@protobase/cli": "^0.66.
|
|
31
|
-
"@protobase/config": "^0.66.
|
|
32
|
-
"@protobase/layout": "^0.66.
|
|
33
|
-
"@protobase/schema": "^0.66.
|
|
34
|
-
"@protobase/server": "^0.66.
|
|
35
|
-
"@protobase/ui": "^0.66.
|
|
30
|
+
"@protobase/cli": "^0.66.5",
|
|
31
|
+
"@protobase/config": "^0.66.5",
|
|
32
|
+
"@protobase/layout": "^0.66.5",
|
|
33
|
+
"@protobase/schema": "^0.66.5",
|
|
34
|
+
"@protobase/server": "^0.66.5",
|
|
35
|
+
"@protobase/ui": "^0.66.5",
|
|
36
36
|
"@types/node": "^22.20.5",
|
|
37
37
|
"@types/pg": "^8.23.1",
|
|
38
38
|
"@types/react": "^19.3.0",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"zod": "^4.6.5"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@protobase/cli": "^0.66.
|
|
31
|
-
"@protobase/config": "^0.66.
|
|
32
|
-
"@protobase/layout": "^0.66.
|
|
33
|
-
"@protobase/schema": "^0.66.
|
|
34
|
-
"@protobase/server": "^0.66.
|
|
35
|
-
"@protobase/ui": "^0.66.
|
|
30
|
+
"@protobase/cli": "^0.66.5",
|
|
31
|
+
"@protobase/config": "^0.66.5",
|
|
32
|
+
"@protobase/layout": "^0.66.5",
|
|
33
|
+
"@protobase/schema": "^0.66.5",
|
|
34
|
+
"@protobase/server": "^0.66.5",
|
|
35
|
+
"@protobase/ui": "^0.66.5",
|
|
36
36
|
"@types/node": "^22.20.5",
|
|
37
37
|
"@types/pg": "^8.23.1",
|
|
38
38
|
"@types/react": "^19.3.0",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"zod": "^4.6.5"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@protobase/cli": "^0.66.
|
|
31
|
-
"@protobase/config": "^0.66.
|
|
32
|
-
"@protobase/layout": "^0.66.
|
|
33
|
-
"@protobase/schema": "^0.66.
|
|
34
|
-
"@protobase/server": "^0.66.
|
|
35
|
-
"@protobase/ui": "^0.66.
|
|
30
|
+
"@protobase/cli": "^0.66.5",
|
|
31
|
+
"@protobase/config": "^0.66.5",
|
|
32
|
+
"@protobase/layout": "^0.66.5",
|
|
33
|
+
"@protobase/schema": "^0.66.5",
|
|
34
|
+
"@protobase/server": "^0.66.5",
|
|
35
|
+
"@protobase/ui": "^0.66.5",
|
|
36
36
|
"@types/node": "^22.20.5",
|
|
37
37
|
"@types/pg": "^8.23.1",
|
|
38
38
|
"@types/react": "^19.3.0",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"zod": "^4.6.5"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@protobase/cli": "^0.66.
|
|
28
|
-
"@protobase/config": "^0.66.
|
|
29
|
-
"@protobase/layout": "^0.66.
|
|
30
|
-
"@protobase/schema": "^0.66.
|
|
31
|
-
"@protobase/server": "^0.66.
|
|
32
|
-
"@protobase/ui": "^0.66.
|
|
27
|
+
"@protobase/cli": "^0.66.5",
|
|
28
|
+
"@protobase/config": "^0.66.5",
|
|
29
|
+
"@protobase/layout": "^0.66.5",
|
|
30
|
+
"@protobase/schema": "^0.66.5",
|
|
31
|
+
"@protobase/server": "^0.66.5",
|
|
32
|
+
"@protobase/ui": "^0.66.5",
|
|
33
33
|
"@types/node": "^22.20.5",
|
|
34
34
|
"@types/pg": "^8.23.1",
|
|
35
35
|
"@types/react": "^19.3.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-protobase",
|
|
3
|
-
"version": "0.66.
|
|
3
|
+
"version": "0.66.5",
|
|
4
4
|
"description": "npm create protobase: starts a new Protobase project from one of its presets, or on an existing Postgres database.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"postgres": "^3.4.9"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@protobase/cli": "0.66.
|
|
31
|
+
"@protobase/cli": "0.66.5"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|