@svgrid/create-studio 0.2.0 → 0.2.1
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/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"type": "commercial",
|
|
5
5
|
"url": "https://svgrid.com/pricing"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.2.
|
|
7
|
+
"version": "0.2.1",
|
|
8
8
|
"description": "Scaffold a runnable SvGrid Studio data app in one command: npm create @svgrid/studio@latest",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"license": "MIT",
|
|
@@ -41,6 +41,6 @@
|
|
|
41
41
|
"node": ">=18"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@svgrid/enterprise": "^2.2.
|
|
44
|
+
"@svgrid/enterprise": "^2.2.1"
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
createRelationLookup,
|
|
11
11
|
type ServerDataSource,
|
|
12
12
|
} from '@svgrid/enterprise'
|
|
13
|
-
import { customerSchema, orderSchema, type Customer, type Order } from './schemas'
|
|
13
|
+
import { customerSchema, orderSchema, productSchema, type Customer, type Order, type Product } from './schemas'
|
|
14
14
|
|
|
15
15
|
const customerSeed: Customer[] = [
|
|
16
16
|
{ id: 'c1', name: 'Ada Lovelace', email: 'ada@analytic.io', tier: 'enterprise', mrr: 1200, active: true },
|
|
@@ -27,8 +27,17 @@ const orderSeed: Order[] = [
|
|
|
27
27
|
{ id: 'o4', ref: 'INV-1004', customerId: 'c3', amount: 980, status: 'refunded' },
|
|
28
28
|
]
|
|
29
29
|
|
|
30
|
+
const productSeed: Product[] = [
|
|
31
|
+
{ id: 'p1', name: 'Analytics Seat', sku: 'SW-ANL-01', category: 'software', price: 49, inStock: true },
|
|
32
|
+
{ id: 'p2', name: 'Edge Gateway', sku: 'HW-EGW-02', category: 'hardware', price: 899, inStock: true },
|
|
33
|
+
{ id: 'p3', name: 'Onboarding', sku: 'SV-ONB-03', category: 'service', price: 1500, inStock: true },
|
|
34
|
+
{ id: 'p4', name: 'Sensor Kit', sku: 'HW-SNS-04', category: 'hardware', price: 249, inStock: false },
|
|
35
|
+
]
|
|
36
|
+
|
|
30
37
|
export const customersSource = createInMemoryDataSource(customerSeed, customerSchema)
|
|
31
38
|
|
|
39
|
+
export const productsSource = createInMemoryDataSource(productSeed, productSchema)
|
|
40
|
+
|
|
32
41
|
// Orders reference a customer. Enrich every method's rows with the customer
|
|
33
42
|
// NAME so the grid shows it (the form stores the id via the lookup below).
|
|
34
43
|
const nameById = () => new Map((customersSource.rows() as Customer[]).map((c) => [c.id, c.name]))
|
|
@@ -23,6 +23,15 @@ export type Order = {
|
|
|
23
23
|
status: string
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
export type Product = {
|
|
27
|
+
id: string
|
|
28
|
+
name: string
|
|
29
|
+
sku: string
|
|
30
|
+
category: string
|
|
31
|
+
price: number
|
|
32
|
+
inStock: boolean
|
|
33
|
+
}
|
|
34
|
+
|
|
26
35
|
export const customerSchema: EntitySchema<Customer> = {
|
|
27
36
|
name: 'customers',
|
|
28
37
|
label: 'Customer',
|
|
@@ -59,3 +68,21 @@ export const orderSchema: EntitySchema<Order> = {
|
|
|
59
68
|
] },
|
|
60
69
|
],
|
|
61
70
|
}
|
|
71
|
+
|
|
72
|
+
export const productSchema: EntitySchema<Product> = {
|
|
73
|
+
name: 'products',
|
|
74
|
+
label: 'Product',
|
|
75
|
+
idField: 'id',
|
|
76
|
+
fields: [
|
|
77
|
+
{ field: 'id', type: 'text', primaryKey: true, readonly: true, hidden: { form: true } },
|
|
78
|
+
{ field: 'name', type: 'text', required: true, minLength: 2 },
|
|
79
|
+
{ field: 'sku', type: 'text', label: 'SKU', required: true },
|
|
80
|
+
{ field: 'category', type: 'enum', options: [
|
|
81
|
+
{ value: 'hardware', label: 'Hardware' },
|
|
82
|
+
{ value: 'software', label: 'Software' },
|
|
83
|
+
{ value: 'service', label: 'Service' },
|
|
84
|
+
] },
|
|
85
|
+
{ field: 'price', type: 'number', label: 'Price ($)', min: 0 },
|
|
86
|
+
{ field: 'inStock', type: 'boolean', label: 'In stock' },
|
|
87
|
+
],
|
|
88
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
const entities = [
|
|
3
3
|
{ href: '/customers', label: 'Customers', desc: 'Tiers, MRR, and status. Sort, filter, edit inline in a modal.' },
|
|
4
4
|
{ href: '/orders', label: 'Orders', desc: 'Linked to a customer via a searchable lookup field.' },
|
|
5
|
+
{ href: '/products', label: 'Products', desc: 'SKU, category, price, and stock. A standalone catalog screen.' },
|
|
5
6
|
]
|
|
6
7
|
</script>
|
|
7
8
|
|