feat(templates): create schemas for categories, brands, products, customers, orders, order_items, reviews

This commit is contained in:
GitApp 2025-12-19 16:03:14 +00:00
parent 59b2b57b5a
commit d49ccca880
21 changed files with 375 additions and 0 deletions

0
.gitapp/.gitkeep Normal file
View File

61
.gitapp/manifest.json Normal file
View File

@ -0,0 +1,61 @@
{
"name": "pocketbase-lite",
"version": "0.1.0",
"paths": {
"data": "collections/",
"media": "media/",
"indexes": ".gitapp/indexes/"
},
"schemas": [
{
"id": "categories",
"file": "schemas/categories.json",
"glob": "collections/categories/*.json"
},
{
"id": "brands",
"file": "schemas/brands.json",
"glob": "collections/brands/*.json"
},
{
"id": "products",
"file": "schemas/products.json",
"glob": "collections/products/*.json"
},
{
"id": "customers",
"file": "schemas/customers.json",
"glob": "collections/customers/*.json"
},
{
"id": "orders",
"file": "schemas/orders.json",
"glob": "collections/orders/*.json"
},
{
"id": "order_items",
"file": "schemas/order_items.json",
"glob": "collections/order_items/*.json"
},
{
"id": "reviews",
"file": "schemas/reviews.json",
"glob": "collections/reviews/*.json"
}
],
"operations": [
"create-record",
"update-record",
"delete-record"
],
"policies": {
"roles": [
"viewer",
"editor"
],
"acl": null
},
"lfs": {
"enabled": false
}
}

View File

View File

@ -0,0 +1,20 @@
name: create-record
version: 1
scope:
subtree: "collections/"
input:
$schema: zod
schema: |
z.object({
collection: z.string().min(1),
id: z.string().min(1),
data: z.record(z.unknown())
})
preconditions: []
mutations:
- type: create_file
path: "collections/${input.collection}/${input.id}.json"
content: "${JSON.stringify(input.data, null, 2)}"
commit:
message: "feat(data): create ${input.collection} record ${input.id}"
updateRef: "refs/heads/main"

View File

@ -0,0 +1,20 @@
name: delete-record
version: 1
scope:
subtree: "collections/"
input:
$schema: zod
schema: |
z.object({
collection: z.string().min(1),
id: z.string().min(1)
})
preconditions:
- type: path_exists
path: "collections/${input.collection}/${input.id}.json"
mutations:
- type: delete_file
path: "collections/${input.collection}/${input.id}.json"
commit:
message: "feat(data): delete ${input.collection} record ${input.id}"
updateRef: "refs/heads/main"

View File

@ -0,0 +1,22 @@
name: update-record
version: 1
scope:
subtree: "collections/"
input:
$schema: zod
schema: |
z.object({
collection: z.string().min(1),
id: z.string().min(1),
data: z.record(z.unknown())
})
preconditions:
- type: path_exists
path: "collections/${input.collection}/${input.id}.json"
mutations:
- type: create_file
path: "collections/${input.collection}/${input.id}.json"
content: "${JSON.stringify(input.data, null, 2)}"
commit:
message: "feat(data): update ${input.collection} record ${input.id}"
updateRef: "refs/heads/main"

0
.gitapp/schemas/.gitkeep Normal file
View File

View File

@ -0,0 +1,24 @@
{
"$id": "brands",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string",
"minLength": 1
},
"logo": {
"type": "string"
},
"description": {
"type": "string"
},
"website": {
"type": "string",
"format": "uri"
}
}
}

View File

@ -0,0 +1,31 @@
{
"$id": "categories",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": [
"name",
"slug"
],
"properties": {
"name": {
"type": "string",
"minLength": 1
},
"slug": {
"type": "string"
},
"description": {
"type": "string"
},
"image": {
"type": "string"
},
"parent": {
"type": "string",
"x-relation": {
"collection": "categories",
"type": "single"
}
}
}
}

View File

@ -0,0 +1,28 @@
{
"$id": "customers",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": [
"name",
"email"
],
"properties": {
"name": {
"type": "string",
"minLength": 1
},
"email": {
"type": "string",
"format": "email"
},
"phone": {
"type": "string"
},
"address": {
"type": "string"
},
"avatar": {
"type": "string"
}
}
}

View File

@ -0,0 +1,33 @@
{
"$id": "order_items",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": [
"quantity",
"price"
],
"properties": {
"quantity": {
"type": "integer",
"minimum": 1
},
"price": {
"type": "number",
"minimum": 0
},
"order": {
"type": "string",
"x-relation": {
"collection": "orders",
"type": "single"
}
},
"product": {
"type": "string",
"x-relation": {
"collection": "products",
"type": "single"
}
}
}
}

View File

@ -0,0 +1,43 @@
{
"$id": "orders",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": [
"orderNumber",
"status",
"total"
],
"properties": {
"orderNumber": {
"type": "string"
},
"status": {
"type": "string",
"enum": [
"pending",
"processing",
"shipped",
"delivered",
"cancelled"
]
},
"total": {
"type": "number",
"minimum": 0
},
"date": {
"type": "string",
"format": "date-time"
},
"shippingAddress": {
"type": "string"
},
"customer": {
"type": "string",
"x-relation": {
"collection": "customers",
"type": "single"
}
}
}
}

View File

@ -0,0 +1,50 @@
{
"$id": "products",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": [
"name",
"price",
"sku"
],
"properties": {
"name": {
"type": "string",
"minLength": 1
},
"description": {
"type": "string"
},
"price": {
"type": "number",
"minimum": 0
},
"sku": {
"type": "string"
},
"stock": {
"type": "integer",
"minimum": 0
},
"image": {
"type": "string"
},
"featured": {
"type": "boolean"
},
"category": {
"type": "string",
"x-relation": {
"collection": "categories",
"type": "single"
}
},
"brand": {
"type": "string",
"x-relation": {
"collection": "brands",
"type": "single"
}
}
}
}

View File

@ -0,0 +1,43 @@
{
"$id": "reviews",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"required": [
"rating",
"title"
],
"properties": {
"rating": {
"type": "integer",
"minimum": 1,
"maximum": 5
},
"title": {
"type": "string"
},
"content": {
"type": "string"
},
"date": {
"type": "string",
"format": "date-time"
},
"verified": {
"type": "boolean"
},
"product": {
"type": "string",
"x-relation": {
"collection": "products",
"type": "single"
}
},
"customer": {
"type": "string",
"x-relation": {
"collection": "customers",
"type": "single"
}
}
}
}

View File

View File

View File

View File

View File

View File

View File