@base44/app-plugin-commerce 0.1.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/LICENSE +21 -0
- package/README.md +117 -0
- package/base44/agents/commerce/StoreAdmin.jsonc +64 -0
- package/base44/entities/commerce.Cart.jsonc +73 -0
- package/base44/entities/commerce.Coupon.jsonc +113 -0
- package/base44/entities/commerce.Customer.jsonc +96 -0
- package/base44/entities/commerce.DownloadPermission.jsonc +54 -0
- package/base44/entities/commerce.EmailLog.jsonc +43 -0
- package/base44/entities/commerce.Order.jsonc +287 -0
- package/base44/entities/commerce.OrderNote.jsonc +31 -0
- package/base44/entities/commerce.OrderRefund.jsonc +64 -0
- package/base44/entities/commerce.PaymentGateway.jsonc +48 -0
- package/base44/entities/commerce.Product.jsonc +291 -0
- package/base44/entities/commerce.ProductAttribute.jsonc +39 -0
- package/base44/entities/commerce.ProductAttributeTerm.jsonc +38 -0
- package/base44/entities/commerce.ProductCategory.jsonc +51 -0
- package/base44/entities/commerce.ProductReview.jsonc +48 -0
- package/base44/entities/commerce.ProductTag.jsonc +30 -0
- package/base44/entities/commerce.ProductVariation.jsonc +167 -0
- package/base44/entities/commerce.ShippingClass.jsonc +30 -0
- package/base44/entities/commerce.ShippingZone.jsonc +41 -0
- package/base44/entities/commerce.ShippingZoneMethod.jsonc +84 -0
- package/base44/entities/commerce.StoreSettings.jsonc +23 -0
- package/base44/entities/commerce.TaxClass.jsonc +23 -0
- package/base44/entities/commerce.TaxRate.jsonc +68 -0
- package/base44/entities/commerce.Webhook.jsonc +57 -0
- package/base44/entities/commerce.WebhookDelivery.jsonc +45 -0
- package/base44/functions/commerce/admin-coupons/entry.ts +100 -0
- package/base44/functions/commerce/admin-customers/entry.ts +141 -0
- package/base44/functions/commerce/admin-orders/entry.ts +396 -0
- package/base44/functions/commerce/admin-orders/helpers.ts +246 -0
- package/base44/functions/commerce/admin-products/entry.ts +506 -0
- package/base44/functions/commerce/admin-refunds/entry.ts +158 -0
- package/base44/functions/commerce/admin-reports/entry.ts +283 -0
- package/base44/functions/commerce/admin-reviews/entry.ts +66 -0
- package/base44/functions/commerce/admin-tools/entry.ts +261 -0
- package/base44/functions/commerce/admin-webhooks/entry.ts +52 -0
- package/base44/functions/commerce/payment-webhook/entry.ts +135 -0
- package/base44/functions/commerce/payments/entry.ts +238 -0
- package/base44/functions/commerce/seed-store/defaults.ts +162 -0
- package/base44/functions/commerce/seed-store/entry.ts +310 -0
- package/base44/functions/commerce/seed-store/sample-data.ts +349 -0
- package/base44/functions/commerce/storefront-account/entry.ts +207 -0
- package/base44/functions/commerce/storefront-cart/cart-pricing.ts +258 -0
- package/base44/functions/commerce/storefront-cart/entry.ts +283 -0
- package/base44/functions/commerce/storefront-catalog/entry.ts +459 -0
- package/base44/functions/commerce/storefront-checkout/cart-pricing.ts +258 -0
- package/base44/functions/commerce/storefront-checkout/entry.ts +485 -0
- package/base44/shared/commerce/auth.ts +60 -0
- package/base44/shared/commerce/coupons.ts +257 -0
- package/base44/shared/commerce/data/continents.ts +75 -0
- package/base44/shared/commerce/data/countries.ts +307 -0
- package/base44/shared/commerce/data/currencies.ts +46 -0
- package/base44/shared/commerce/email-templates.ts +240 -0
- package/base44/shared/commerce/emails.ts +225 -0
- package/base44/shared/commerce/money.ts +66 -0
- package/base44/shared/commerce/orders.ts +251 -0
- package/base44/shared/commerce/payments.ts +495 -0
- package/base44/shared/commerce/reviews.ts +36 -0
- package/base44/shared/commerce/scan.ts +57 -0
- package/base44/shared/commerce/sequence.ts +35 -0
- package/base44/shared/commerce/settings.ts +57 -0
- package/base44/shared/commerce/shipping.ts +215 -0
- package/base44/shared/commerce/stock.ts +227 -0
- package/base44/shared/commerce/stripe.ts +463 -0
- package/base44/shared/commerce/tax.ts +136 -0
- package/base44/shared/commerce/totals.ts +314 -0
- package/base44/shared/commerce/webhooks.ts +116 -0
- package/package.json +37 -0
- package/scripts/install.js +156 -0
- package/skills/commerce/SKILL.md +62 -0
- package/skills/commerce/docs/api-admin.md +186 -0
- package/skills/commerce/docs/api-storefront.md +408 -0
- package/skills/commerce/installation-guidelines.md +91 -0
- package/skills/commerce/post-installation.md +157 -0
- package/skills/commerce/references/emails.md +13 -0
- package/skills/commerce/references/guest-access-security.md +18 -0
- package/skills/commerce/references/limits-and-performance.md +16 -0
- package/skills/commerce/references/media-and-downloads.md +4 -0
- package/skills/commerce/references/online-payments.md +201 -0
- package/skills/commerce/references/product-render.md +87 -0
- package/skills/commerce/references/scheduled-work.md +19 -0
- package/skills/commerce/references/storefront-product-page.md +83 -0
- package/skills/commerce/references/webhooks.md +8 -0
- package/src/commerce/admin/README.md +107 -0
- package/src/commerce/admin/bot/Markdown.jsx +138 -0
- package/src/commerce/admin/bot/StoreAdminBot.jsx +249 -0
- package/src/commerce/admin/bot/pipe-tables.js +116 -0
- package/src/commerce/admin/components/AddressForm.jsx +78 -0
- package/src/commerce/admin/components/ConfirmDialog.jsx +52 -0
- package/src/commerce/admin/components/CountrySelect.jsx +81 -0
- package/src/commerce/admin/components/DataTable.jsx +192 -0
- package/src/commerce/admin/components/DateRangePicker.jsx +91 -0
- package/src/commerce/admin/components/EmptyState.jsx +17 -0
- package/src/commerce/admin/components/MediaUploader.jsx +116 -0
- package/src/commerce/admin/components/MetaDataEditor.jsx +45 -0
- package/src/commerce/admin/components/MoneyInput.jsx +50 -0
- package/src/commerce/admin/components/PageHeader.jsx +29 -0
- package/src/commerce/admin/components/RichTextarea.jsx +21 -0
- package/src/commerce/admin/components/SearchSelect.jsx +142 -0
- package/src/commerce/admin/components/StatusBadge.jsx +17 -0
- package/src/commerce/admin/context/BasePathContext.jsx +26 -0
- package/src/commerce/admin/context/SettingsContext.jsx +207 -0
- package/src/commerce/admin/hooks/useAsync.js +46 -0
- package/src/commerce/admin/hooks/useDebounce.js +11 -0
- package/src/commerce/admin/hooks/useMoney.js +52 -0
- package/src/commerce/admin/hooks/usePagedList.js +83 -0
- package/src/commerce/admin/hooks/usePaymentProvider.js +27 -0
- package/src/commerce/admin/hooks/useRealtime.js +129 -0
- package/src/commerce/admin/index.jsx +34 -0
- package/src/commerce/admin/layout/AccessDenied.jsx +54 -0
- package/src/commerce/admin/layout/AdminLayout.jsx +33 -0
- package/src/commerce/admin/layout/AuthGuard.jsx +84 -0
- package/src/commerce/admin/layout/Sidebar.jsx +130 -0
- package/src/commerce/admin/layout/Topbar.jsx +94 -0
- package/src/commerce/admin/lib/api.js +55 -0
- package/src/commerce/admin/lib/constants.js +157 -0
- package/src/commerce/admin/lib/format.js +27 -0
- package/src/commerce/admin/lib/geo-data.js +125 -0
- package/src/commerce/admin/lib/order-utils.js +147 -0
- package/src/commerce/admin/lib/paths.js +35 -0
- package/src/commerce/admin/lib/product-utils.js +55 -0
- package/src/commerce/admin/pages/Dashboard.jsx +245 -0
- package/src/commerce/admin/pages/coupons/CouponEditor.jsx +565 -0
- package/src/commerce/admin/pages/coupons/CouponsList.jsx +172 -0
- package/src/commerce/admin/pages/customers/CustomerEditor.jsx +318 -0
- package/src/commerce/admin/pages/customers/CustomersList.jsx +169 -0
- package/src/commerce/admin/pages/orders/OrderEditor.jsx +952 -0
- package/src/commerce/admin/pages/orders/OrdersList.jsx +227 -0
- package/src/commerce/admin/pages/orders/components/AddProductDialog.jsx +149 -0
- package/src/commerce/admin/pages/orders/components/DownloadPermissionsPanel.jsx +119 -0
- package/src/commerce/admin/pages/orders/components/LineItemsTable.jsx +208 -0
- package/src/commerce/admin/pages/orders/components/OrderNotesPanel.jsx +123 -0
- package/src/commerce/admin/pages/orders/components/PaymentPanel.jsx +199 -0
- package/src/commerce/admin/pages/orders/components/RefundPanel.jsx +239 -0
- package/src/commerce/admin/pages/orders/components/TotalsBox.jsx +52 -0
- package/src/commerce/admin/pages/products/AttributeTerms.jsx +180 -0
- package/src/commerce/admin/pages/products/Attributes.jsx +183 -0
- package/src/commerce/admin/pages/products/Categories.jsx +236 -0
- package/src/commerce/admin/pages/products/ProductEditor.jsx +267 -0
- package/src/commerce/admin/pages/products/ProductsList.jsx +391 -0
- package/src/commerce/admin/pages/products/Reviews.jsx +255 -0
- package/src/commerce/admin/pages/products/Tags.jsx +150 -0
- package/src/commerce/admin/pages/products/components/ProductDataPanel.jsx +132 -0
- package/src/commerce/admin/pages/products/components/PublishBox.jsx +101 -0
- package/src/commerce/admin/pages/products/components/TaxonomyPanel.jsx +243 -0
- package/src/commerce/admin/pages/products/components/tabs/AdvancedTab.jsx +48 -0
- package/src/commerce/admin/pages/products/components/tabs/AttributesTab.jsx +208 -0
- package/src/commerce/admin/pages/products/components/tabs/DownloadsTab.jsx +91 -0
- package/src/commerce/admin/pages/products/components/tabs/ExternalTab.jsx +41 -0
- package/src/commerce/admin/pages/products/components/tabs/GeneralTab.jsx +103 -0
- package/src/commerce/admin/pages/products/components/tabs/InventoryTab.jsx +93 -0
- package/src/commerce/admin/pages/products/components/tabs/LinkedTab.jsx +102 -0
- package/src/commerce/admin/pages/products/components/tabs/ShippingTab.jsx +86 -0
- package/src/commerce/admin/pages/products/components/tabs/VariationsTab.jsx +377 -0
- package/src/commerce/admin/pages/reports/Reports.jsx +416 -0
- package/src/commerce/admin/pages/settings/EmailsSettings.jsx +240 -0
- package/src/commerce/admin/pages/settings/GeneralSettings.jsx +232 -0
- package/src/commerce/admin/pages/settings/InventorySettings.jsx +146 -0
- package/src/commerce/admin/pages/settings/PaymentsSettings.jsx +260 -0
- package/src/commerce/admin/pages/settings/ProductsSettings.jsx +118 -0
- package/src/commerce/admin/pages/settings/SettingsLayout.jsx +53 -0
- package/src/commerce/admin/pages/settings/ShippingSettings.jsx +304 -0
- package/src/commerce/admin/pages/settings/ShippingZoneEditor.jsx +514 -0
- package/src/commerce/admin/pages/settings/TaxRatesTable.jsx +231 -0
- package/src/commerce/admin/pages/settings/TaxSettings.jsx +281 -0
- package/src/commerce/admin/pages/settings/useGroupForm.jsx +76 -0
- package/src/commerce/admin/pages/status/WebhookEditor.jsx +296 -0
- package/src/commerce/admin/pages/status/Webhooks.jsx +53 -0
- package/src/commerce/admin/routes.jsx +151 -0
- package/src/commerce/utils/index.js +19 -0
- package/src/commerce/utils/shipping-promos.js +99 -0
- package/src/commerce/utils/variants.js +411 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 base44
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Base44 Commerce Template
|
|
2
|
+
|
|
3
|
+
A **Commerce backend + admin UI** for [Base44](https://base44.com) apps, delivered as a copyable file set. Drop `base44/` and `src/commerce/` into an existing Base44 app to add a full store: catalog, orders, coupons, customers, reviews, tax, shipping, webhooks, reports and transactional emails — plus a public storefront API for building your own shopfront.
|
|
4
|
+
|
|
5
|
+
It provides a full-featured **commerce data model and behavior** (product types, order lifecycle, coupon rules, tax priority/compound math, shipping zones) using Base44-idiomatic primitives (entity JSON schemas, Deno functions, the Base44 SDK).
|
|
6
|
+
|
|
7
|
+
## What's included
|
|
8
|
+
|
|
9
|
+
- **24 entities** — Products (simple/grouped/external/variable), variations, categories, tags, attributes + terms, reviews, orders (embedded line/shipping/tax/fee/coupon lines), order notes, refunds, coupons, customers, tax classes/rates, shipping zones/methods, payment gateways, store settings, webhooks + deliveries, carts, download permissions, email log.
|
|
10
|
+
- **16 backend functions** — 9 admin (`commerce/admin-products`, `commerce/admin-orders`, `commerce/admin-refunds`, `commerce/admin-coupons`, `commerce/admin-customers`, `commerce/admin-reviews`, `commerce/admin-webhooks`, `commerce/admin-reports`, `commerce/admin-tools`), 4 storefront (`commerce/storefront-catalog`, `commerce/storefront-cart`, `commerce/storefront-checkout`, `commerce/storefront-account`), 2 payment (`commerce/payments`, `commerce/payment-webhook`), and an idempotent `commerce/seed-store`.
|
|
11
|
+
- **Online card payments, implemented** — hosted payment page, payment links for unpaid orders, two idempotent confirmation paths (customer return + signed webhook) and refunds through the provider. Wired to **Stripe** out of the box behind a provider-neutral payment utility, so the store takes cards as soon as the connector is connected — no charge flow to write — and moving to another provider means implementing one adapter. See [`skills/commerce/references/online-payments.md`](./skills/commerce/references/online-payments.md).
|
|
12
|
+
- **Shared commerce engine** (`base44/shared/commerce/`) — totals, tax, shipping, coupons, stock, order lifecycle, webhook dispatch (HMAC-signed), emails, payments utility + Stripe adapter, plus static country/currency/continent data.
|
|
13
|
+
- **Admin UI** (`src/commerce/admin/`) — a React/Tailwind/shadcn admin with a familiar store back-office information architecture: dashboard, orders, products, coupons, customers, reports, full settings, webhooks. Admin-role gated.
|
|
14
|
+
- **Storefront helpers** (`src/commerce/utils/`) — framework-free, dependency-free functions for the shopfront you build: `variants.js` maps an attribute selection (Size, Color) onto a `ProductVariation` and back, plus per-option availability and variable-product price ranges; `shipping-promos.js` reads the store's real free-shipping configuration so "Free shipping over €150" copy states a configured rule rather than an invented number. See [`skills/commerce/references/storefront-product-page.md`](./skills/commerce/references/storefront-product-page.md).
|
|
15
|
+
- **StoreAdmin agent + bot** — an AI copilot (`base44/agents/commerce/StoreAdmin.jsonc`, registered as `commerce/StoreAdmin`) with the `commerce/*` functions attached directly as tools (calls run as the chatting user → `requireAdmin()` still applies), variant-aware order editing, plus a chat panel in the admin sidebar with GFM markdown-table rendering.
|
|
16
|
+
- **Docs** — this README plus the commerce skill folder [`skills/commerce/`](./skills/commerce/), which holds [`SKILL.md`](./skills/commerce/SKILL.md) (the short map agents start from), [`installation-guidelines.md`](./skills/commerce/installation-guidelines.md), [`post-installation.md`](./skills/commerce/post-installation.md), per-topic guides in [`references/`](./skills/commerce/references/) and the API references in [`docs/`](./skills/commerce/docs/) — the whole folder is installed into the app so agents pick it up natively.
|
|
17
|
+
|
|
18
|
+
## Repo map
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
base44-commerce-template/
|
|
22
|
+
├── base44/
|
|
23
|
+
│ ├── entities/ 24 .jsonc entity schemas (commerce.*.jsonc)
|
|
24
|
+
│ ├── functions/
|
|
25
|
+
│ │ └── commerce/ 16 Deno functions (entry.ts each), invoked as "commerce/<name>"
|
|
26
|
+
│ ├── agents/
|
|
27
|
+
│ │ └── commerce/ StoreAdmin.jsonc — AI admin copilot ("commerce/StoreAdmin")
|
|
28
|
+
│ └── shared/
|
|
29
|
+
│ └── commerce/ commerce engine + static data (bundled into every function)
|
|
30
|
+
├── src/
|
|
31
|
+
│ └── commerce/
|
|
32
|
+
│ ├── admin/ React admin UI (copy into your app's src/commerce/)
|
|
33
|
+
│ └── utils/ storefront helpers — variant selection, shipping promos
|
|
34
|
+
├── scripts/
|
|
35
|
+
│ └── install.js static installer (run from <app>/examples/commerce/scripts/)
|
|
36
|
+
├── skills/
|
|
37
|
+
│ └── commerce/ commerce skill — copied into the app's skills/ so agents
|
|
38
|
+
│ │ know the store natively
|
|
39
|
+
│ ├── SKILL.md the map: short overview + links to everything below
|
|
40
|
+
│ ├── installation-guidelines.md installing into an app (scripted or manual)
|
|
41
|
+
│ ├── post-installation.md embedding the admin pages + AGENTS.md registration
|
|
42
|
+
│ ├── references/ per-topic guides (product rendering, product page & variants,
|
|
43
|
+
│ │ Stripe, scheduled work, emails, webhooks, media & downloads,
|
|
44
|
+
│ │ limits, security)
|
|
45
|
+
│ └── docs/
|
|
46
|
+
│ ├── api-admin.md admin function/entity reference
|
|
47
|
+
│ └── api-storefront.md storefront function reference (build your own shopfront)
|
|
48
|
+
└── README.md
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Get it from npm
|
|
52
|
+
|
|
53
|
+
The template is published as **`@base44/app-plugin-commerce`** — a source-only package whose tarball is exactly the `base44/`, `scripts/`, `skills/` and `src/` folders of this repo, with no build or bundling step. Unpack it into your app at `examples/commerce/` and the install flow below works unchanged:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm pack @base44/app-plugin-commerce # → base44-app-plugin-commerce-<version>.tgz
|
|
57
|
+
mkdir -p examples/commerce
|
|
58
|
+
tar -xzf base44-app-plugin-commerce-*.tgz --strip-components=1 -C examples/commerce
|
|
59
|
+
node examples/commerce/scripts/install.js
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`scripts/install.js` resolves the app root relative to its own location (`<app>/examples/commerce/scripts/`), so run it from the unpacked copy rather than from inside `node_modules/`.
|
|
63
|
+
|
|
64
|
+
## Quick start (Base44 CLI)
|
|
65
|
+
|
|
66
|
+
From your existing Base44 app:
|
|
67
|
+
|
|
68
|
+
1. **Copy the files** — either copy this whole repo into your app at `examples/commerce/` and run `node examples/commerce/scripts/install.js`, or merge `entities/`, `functions/`, `shared/` into your app's `base44/` directory by hand (see [`skills/commerce/installation-guidelines.md`](./skills/commerce/installation-guidelines.md)). Confirm your `base44/config.jsonc` `entitiesDir`/`functionsDir` point at these folders.
|
|
69
|
+
2. **Push the schema, functions and agent:**
|
|
70
|
+
```bash
|
|
71
|
+
npx base44 entities push
|
|
72
|
+
npx base44 functions deploy
|
|
73
|
+
npx base44 agents push
|
|
74
|
+
```
|
|
75
|
+
3. **Copy the UI files:** `src/commerce/admin/` → `src/commerce/admin/` and `src/commerce/utils/` → `src/commerce/utils/`.
|
|
76
|
+
4. **Confirm UI deps** — `sonner`, `recharts` and `react-markdown` all ship with the default Base44 template and are the only ones the admin needs; install any that are missing:
|
|
77
|
+
```bash
|
|
78
|
+
npm i sonner recharts
|
|
79
|
+
```
|
|
80
|
+
See [`src/commerce/admin/README.md`](./src/commerce/admin/README.md) for the exact shadcn component list.
|
|
81
|
+
5. **Mount the admin router** in your app:
|
|
82
|
+
```jsx
|
|
83
|
+
import AdminApp from "@/commerce/admin";
|
|
84
|
+
// inside your <Routes>:
|
|
85
|
+
<Route path="/admin/*" element={<AdminApp />} />
|
|
86
|
+
```
|
|
87
|
+
6. **Grant yourself the `admin` role** (Base44 dashboard → users, or `users.inviteUser(email, "admin")`). The admin UI refuses non-admins.
|
|
88
|
+
7. **Seed the store.** Either open `/admin` and click **Initialize store defaults** on the first-run setup screen, or call `commerce/seed-store` directly — it creates the settings groups, gateways, tax classes and a fallback shipping zone, plus a sample catalog when `with_sample_data: true` and the store is empty. Once the `general` settings group exists the store counts as ready and the first-run screen stops appearing. If an agent is installing this, it should **ask which data the user wants** first — a generated catalog for their actual business, the generic demo data, or nothing: see [`skills/commerce/post-installation.md`](./skills/commerce/post-installation.md) §2.
|
|
89
|
+
|
|
90
|
+
## Quick start (Base44 MCP / hosted apps)
|
|
91
|
+
|
|
92
|
+
If you build on Base44's hosted platform, use the Base44 agent/MCP to write the files instead of the CLI:
|
|
93
|
+
|
|
94
|
+
1. Copy this whole repo into the target app at `examples/commerce/` (e.g. download + extract a tarball with `run_command`), then run `node examples/commerce/scripts/install.js` via `run_command` — or use `write_file` to copy every file under `base44/` and `src/commerce/` individually (use `list_directory`/`read_file` to adapt to the app's actual layout — e.g. the `@/api/base44Client` path and your router file).
|
|
95
|
+
2. Wait for the app to build (`get_app_status`), then confirm entities exist (`list_entity_schemas`).
|
|
96
|
+
3. Grant your user the `admin` role, then settle the store's data with the user — generate a real starter catalog via `commerce/seed-store` + `commerce/admin-products`, seed the demo catalog, or leave it to the admin's first-run **Initialize store defaults** screen ([`skills/commerce/post-installation.md`](./skills/commerce/post-installation.md) §2).
|
|
97
|
+
|
|
98
|
+
## What's NOT included
|
|
99
|
+
|
|
100
|
+
- **No visitor/storefront UI.** The storefront **API** is complete (`commerce/storefront-*` functions); building the shopfront is up to you — see [`skills/commerce/docs/api-storefront.md`](./skills/commerce/docs/api-storefront.md). What *does* ship for the storefront is **helper logic**: [`src/commerce/utils/`](./src/commerce/utils/) — framework-free variant-selection functions (map a Size/Color selection to a `ProductVariation` and back, per-option availability, variable-product price ranges) — plus [`skills/commerce/references/product-render.md`](./skills/commerce/references/product-render.md) (what to render in a grid vs. a product page, and which fields each call returns) and [`skills/commerce/references/storefront-product-page.md`](./skills/commerce/references/storefront-product-page.md), the variant rules that go with the helpers.
|
|
101
|
+
- **No payment credentials** — the card integration itself *is* included (see above), but a store can only charge once someone connects a payment provider's connector for the app. Until then the card option stays hidden from customers and the manual gateways (bank transfer / cheque / COD) carry checkout.
|
|
102
|
+
- **No scheduled workflows shipped.** Base44 *does* have a scheduler, but this template ships no workflow files — time-based jobs (stock-hold release, cart expiry, webhook-log pruning) run **opportunistically** where possible, and for the rest you (or the Base44 agent) create scheduled workflows that call `commerce/admin-tools`/`commerce/admin-orders` actions — see *Scheduled work* in [`skills/commerce/SKILL.md`](./skills/commerce/SKILL.md).
|
|
103
|
+
|
|
104
|
+
## Next steps
|
|
105
|
+
|
|
106
|
+
- **Install into your app:** [`skills/commerce/installation-guidelines.md`](./skills/commerce/installation-guidelines.md)
|
|
107
|
+
- **Operate & extend:** the commerce skill — [`skills/commerce/SKILL.md`](./skills/commerce/SKILL.md)
|
|
108
|
+
- **Build a storefront:** [`skills/commerce/docs/api-storefront.md`](./skills/commerce/docs/api-storefront.md)
|
|
109
|
+
- **Admin automation / alternative admin:** [`skills/commerce/docs/api-admin.md`](./skills/commerce/docs/api-admin.md)
|
|
110
|
+
|
|
111
|
+
## Releasing (maintainers)
|
|
112
|
+
|
|
113
|
+
Publishing is manual: **Actions → Manual Package Publish → Run workflow** ([`.github/workflows/manual-publish.yml`](./.github/workflows/manual-publish.yml)).
|
|
114
|
+
|
|
115
|
+
Inputs: `version` (`patch`/`minor`/`major` or an explicit `0.1.0`), `npm_tag` (`latest`, `beta`, …) and `dry_run`. The workflow bumps `package.json`, prints the tarball contents, runs `npm publish`, then commits the bump, tags `v<version>` and cuts a GitHub release. A dry run publishes nothing and leaves no tag or commit.
|
|
116
|
+
|
|
117
|
+
The first release needs an explicit version (the repo sits at `0.0.0`). Requirements: the repo secret/org secret **`NPM_TOKEN`** (an npm automation token with publish rights on the `@base44` scope), plus the org's `BASE44_GITHUB_ACTIONS_APP_ID` variable and `BASE44_GITHUB_ACTIONS_APP_PRIVATE_KEY` secret used to push the release commit.
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// StoreAdmin — AI copilot for the Base44 Commerce Template admin.
|
|
2
|
+
// Referenced as "commerce/StoreAdmin" (the folder namespaces the agent, like functions).
|
|
3
|
+
//
|
|
4
|
+
// The commerce/* backend functions are attached directly as tools. Tool calls
|
|
5
|
+
// run with the chatting user's credentials, so requireAdmin() in every admin
|
|
6
|
+
// function still applies — the agent has no entity tools and no service-role
|
|
7
|
+
// shortcut. NOTE: no "model" field on purpose — the platform default model
|
|
8
|
+
// path handles slash-namespaced tool names; explicitly setting a model
|
|
9
|
+
// currently rejects them (tool name pattern ^[a-zA-Z0-9_-]{1,128}$).
|
|
10
|
+
{
|
|
11
|
+
"name": "StoreAdmin",
|
|
12
|
+
"description": "Store administration copilot for the commerce template: manage products, orders, refunds, coupons, customers, reviews, reports and maintenance.",
|
|
13
|
+
"instructions": "You are StoreAdmin, the store administration copilot for this shop's back office. You help store operators inspect and manage the store: products, orders, refunds, coupons, customers, reviews, webhooks, reports, and maintenance.\n\n## How you access the store\nEvery tool takes a JSON body of the form {\"action\": \"<action>\", ...payload} (exception: commerce/seed-store takes {with_sample_data?} with no action key) and responds {success, data} or {success:false, error, code}. Search/list actions return {rows, has_next} using limit+skip pagination (there are no total counts). Use search actions for free-text lookups (product name, customer email, coupon code, order number).\n\nStore configuration (settings, tax rates, shipping zones, payment gateways, webhook definitions) is not editable through your tools — see \"Sending the operator to a screen\" below.\n\n## Sending the operator to a screen\nSome configuration is only editable in the admin UI. When one of those is asked for, say plainly that you cannot change it from chat, name the screen, and give a link the operator can click — never just \"do it manually\", and never imply you tried and failed. Do not blame permissions or a security error: the reason is simply that the UI is the only place that configuration is edited.\n\nLinks use the `admin:` scheme with a path from the table below — `[Settings → Tax](admin:settings/tax)`. The chat resolves that to wherever the admin is mounted, so never write `/admin/...` yourself.\n\n| Ask | Screen | Link |\n|---|---|---|\n| Currency, store name/address, coupon & tax toggles | Settings → General | admin:settings/general |\n| Catalog defaults, review settings | Settings → Products | admin:settings/products |\n| Stock thresholds, hold minutes, inventory recipient | Settings → Inventory | admin:settings/inventory |\n| Tax classes, tax rates, price display | Settings → Tax | admin:settings/tax |\n| Shipping zones, methods, shipping classes | Settings → Shipping | admin:settings/shipping |\n| Enabling a gateway, bank/BACS details | Settings → Payments | admin:settings/payments |\n| From-name, admin notification recipients, per-email overrides | Settings → Emails | admin:settings/emails |\n| Creating or deleting a webhook (you CAN test and redeliver) | Webhooks | admin:webhooks |\n\nExample: \"Tax rates aren't something I can change from here — they live in the store's tax settings. Open [Settings → Tax](admin:settings/tax) to add the rate, then tell me and I'll re-check the order's totals.\"\n\nCatalog taxonomy is the opposite: you CAN create categories, tags, attributes and attribute terms yourself with commerce/admin-products save-term. Never send the operator to a screen to create one — only link to admin:products/categories, admin:products/tags or admin:products/attributes if they want to review or reorder them by hand.\n\n## Product variants — be careful\nProducts of type \"variable\" are sold as variations, and every variation can differ in attributes (e.g. size/color), SKU, price and stock.\n- NEVER pick a variation automatically. When an order line, stock change, or download grant involves a variable product, first fetch its variations with commerce/storefront-catalog {\"action\":\"get-product\",\"id\":...} (returns {product, variations}), present them in a table (attributes, SKU, price, stock status), and ask the operator which variation to use — then include that variation_id in the item spec.\n- If the operator already named an exact variation (by SKU or full attribute combination), match it against the fetched variations and confirm the match in your reply; if the description is partial or matches more than one variation, ask.\n- Order item specs for commerce/admin-orders create/update are {product_id, variation_id?, quantity, price_override?} — variation_id is REQUIRED for variable products; the backend rejects a bare product_id for them.\n- The same applies to commerce/admin-products set-stock (pass variation_id to change a variation's stock, not the parent's).\n\n## Behavior\n- Be concise and operational. Confirm before destructive or irreversible operations (delete, refund, bulk-status, prune, clear-abandoned-carts) by restating what will happen and asking the user to confirm — unless the user's message already explicitly confirms it.\n- When showing lists or reports, format them as GitHub-flavored markdown tables (| col | col | with a |---| separator row). Keep tables ≤ 8 columns; prefer the most decision-relevant fields (name/number, status, total, date). Format money with the store currency.\n- After a mutation, report exactly what changed (ids, statuses, totals) and surface any error/code verbatim.\n- If a request is ambiguous (which order? which product?), search first and present the candidates in a table, then ask.\n- For store health questions, start with commerce/admin-tools {\"action\":\"status\"} and commerce/admin-reports {\"action\":\"summary\"}.\n- Payments: for an unpaid order paid online, commerce/payments create-link {order_id} gives a payment page link to send the customer, and verify {order_id} re-checks whether the money arrived. If no payment provider is connected, say \"no payment provider is connected\" and that connecting one enables card payments — don't name or troubleshoot a specific provider. Never invent a payment link or claim an order is paid without verifying.\n- You act with store-operator privileges; do not attempt to weaken or bypass access controls, and never expose secrets (webhook secrets, tokens).",
|
|
14
|
+
"tool_configs": [
|
|
15
|
+
{
|
|
16
|
+
"function_name": "commerce/admin-products",
|
|
17
|
+
"description": "Product & variation management, plus category/tag terms. Actions: save {product, variations?} (upsert + derived price/stock, SKU/slug uniqueness), delete {id}, batch {create?,update?,delete?}, duplicate {id}, set-stock {id, variation_id?, quantity}, search {q?, category_id?, type?, stock_status?, status?, sort?, limit?, skip?} → {rows, has_next}, list-terms {taxonomy, q?, attribute_id?, limit?, skip?} → {rows, has_next}, save-term {taxonomy, term: {...}} (upsert; slug auto-derived and made unique), delete-term {taxonomy, id, detach?}. taxonomy is \"category\" | \"tag\" | \"attribute\" | \"attribute-term\"; term fields per taxonomy: category {id?, name, slug?, description?, parent_id?, image?, menu_order?}, tag {id?, name, slug?, description?}, attribute {id?, name, slug?, type?, order_by?, has_archives?}, attribute-term {id?, attribute_id (required), name, slug?, description?, menu_order?}. Create these yourself with save-term — do NOT tell the operator to create them by hand. list-terms first and reuse a match before creating a duplicate. Deleting an attribute deletes its terms. A variable product needs a ProductAttribute (+ its terms) to exist before product.attributes[].options can reference it, so create the attribute and terms first, then save the product."
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"function_name": "commerce/admin-orders",
|
|
21
|
+
"description": "Order lifecycle. Actions: create-draft, create {items, ...}, update {order_id, patch}, update-status {order_id, status, note?}, bulk-status {ids, status}, status-counts, search {q?, status?, date_min?, date_max?, sort?, limit?, skip?}, recalculate {order_id}, apply-coupon/remove-coupon {order_id, code}, add-note {order_id, note, is_customer_note?}, delete-note {note_id}, send-email {order_id, type}, grant-download {order_id, product_id}, revoke-download {permission_id}, delete {order_id}, release-expired-holds. Item specs: {product_id, variation_id?, quantity, price_override?} — variation_id REQUIRED for variable products (ask the operator which variation; never auto-pick). Statuses: pending, processing, on-hold, completed, cancelled, refunded, failed."
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"function_name": "commerce/admin-refunds",
|
|
25
|
+
"description": "Refunds. Actions: create {order_id, amount, reason?, line_items? [{line_id, quantity, refund_total, refund_tax?}], restock_items?, refund_payment?} (validates against remaining refundable; full refund transitions order to refunded), delete {refund_id}."
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"function_name": "commerce/admin-coupons",
|
|
29
|
+
"description": "Coupons. Actions: save {coupon} (unique lowercased code), delete {id}, batch {create?,update?,delete?}, search {q?, limit?, skip?} → {rows, has_next}."
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"function_name": "commerce/admin-customers",
|
|
33
|
+
"description": "Customers. Actions: save {customer} (unique email), delete {id, reassign_orders_to_guest?}, search {q?, limit?, skip?} → {rows, has_next}, invite {email}, recalculate-stats {id}."
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"function_name": "commerce/admin-reviews",
|
|
37
|
+
"description": "Product reviews moderation. Actions: set-status {id, status: approved|hold|spam|trash}, update {id, rating?, review?}, delete {id}. Each recomputes the product's average_rating/rating_count."
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"function_name": "commerce/admin-webhooks",
|
|
41
|
+
"description": "Webhook diagnostics. Actions: test {webhook_id} (sends sample payload, returns {delivery_id, response_code, success, duration_ms}), redeliver {delivery_id}."
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"function_name": "commerce/admin-reports",
|
|
45
|
+
"description": "Reports (computed from orders on demand). Actions: summary, sales {date_min?, date_max?, interval?: day|week|month}, top-sellers {date_min?, date_max?, limit?}, stock, orders-totals, products-totals, customers-totals, coupons-totals, reviews-totals, categories-totals, tags-totals, attributes-totals."
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"function_name": "commerce/admin-tools",
|
|
49
|
+
"description": "System status & maintenance. Actions: status (template_version, seeded, entity counts, health checks), recount-terms, recount-coupon-usage, recalculate-customer-stats-all, prune-webhook-deliveries {keep_days}, clear-abandoned-carts {older_than_days}, regenerate-download-permissions {order_id}."
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"function_name": "commerce/seed-store",
|
|
53
|
+
"description": "Initialize store defaults (idempotent; canary schema check first). Body: {with_sample_data?: boolean} — no action key. Sample catalog only created when the store has zero products."
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"function_name": "commerce/payments",
|
|
57
|
+
"description": "Online payment for an order. Actions: status {} → {provider, connected, gateway_slug} (is a payment provider connected?), create-link {order_id} → {url} (provider-hosted payment page for an UNPAID online order — the link to send a customer; 409 already_paid, 400 not_an_online_payment, 503 payment_provider_unavailable), verify {order_id} → {paid, status} (re-ask the provider and move the order on if paid; idempotent)."
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"function_name": "commerce/storefront-catalog",
|
|
61
|
+
"description": "Read-only public catalog browsing — use get-product BEFORE putting a variable product on an order, to list its variations and ask the operator which one. Actions: get-store-info, list-products {q?, category_id?, tag_id?, featured?, on_sale?, min_price?, max_price?, sort?, page?, per_page?}, get-product {id | slug} → {product, variations, ...}, list-categories, list-tags, list-reviews {product_id, page?, per_page?}."
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "commerce.Cart",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"description": "Storefront cart session (a self-contained cart + checkout-draft). Access is exclusively via commerce/storefront-cart using the cart_token bearer credential; items store no prices — pricing is resolved at read time.",
|
|
5
|
+
"properties": {
|
|
6
|
+
"cart_token": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"description": "Random uuid; the guest bearer credential. Treat as a secret."
|
|
9
|
+
},
|
|
10
|
+
"customer_email": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "Set when the caller is known (login or checkout); used for cart merge"
|
|
13
|
+
},
|
|
14
|
+
"items": {
|
|
15
|
+
"type": "array",
|
|
16
|
+
"items": {
|
|
17
|
+
"type": "object",
|
|
18
|
+
"properties": {
|
|
19
|
+
"item_key": { "type": "string", "description": "Stable key within the cart" },
|
|
20
|
+
"product_id": { "type": "string" },
|
|
21
|
+
"variation_id": { "type": "string" },
|
|
22
|
+
"quantity": { "type": "integer" },
|
|
23
|
+
"attributes": {
|
|
24
|
+
"type": "array",
|
|
25
|
+
"description": "Chosen variation attributes for display",
|
|
26
|
+
"items": {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"properties": {
|
|
29
|
+
"name": { "type": "string" },
|
|
30
|
+
"option": { "type": "string" }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"coupon_codes": {
|
|
38
|
+
"type": "array",
|
|
39
|
+
"items": { "type": "string" }
|
|
40
|
+
},
|
|
41
|
+
"shipping_address": {
|
|
42
|
+
"type": "object",
|
|
43
|
+
"description": "Destination used for zone matching and tax preview",
|
|
44
|
+
"properties": {
|
|
45
|
+
"country": { "type": "string" },
|
|
46
|
+
"state": { "type": "string" },
|
|
47
|
+
"postcode": { "type": "string" },
|
|
48
|
+
"city": { "type": "string" }
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"chosen_shipping_method": {
|
|
52
|
+
"type": "string",
|
|
53
|
+
"description": "ShippingZoneMethod id"
|
|
54
|
+
},
|
|
55
|
+
"status": {
|
|
56
|
+
"type": "string",
|
|
57
|
+
"enum": ["active", "converted", "abandoned"],
|
|
58
|
+
"default": "active"
|
|
59
|
+
},
|
|
60
|
+
"expires_at": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"format": "date-time",
|
|
63
|
+
"description": "now + 48h, refreshed on touch; expired carts cleared via commerce/admin-tools clear-abandoned-carts"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"required": ["cart_token"],
|
|
67
|
+
"rls": {
|
|
68
|
+
"read": { "user_condition": { "role": "admin" } },
|
|
69
|
+
"create": { "user_condition": { "role": "admin" } },
|
|
70
|
+
"update": { "user_condition": { "role": "admin" } },
|
|
71
|
+
"delete": { "user_condition": { "role": "admin" } }
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "commerce.Coupon",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"description": "Discount coupon with full-featured restrictions and usage limits. Validation happens server-side in shared/coupons.",
|
|
5
|
+
"properties": {
|
|
6
|
+
"code": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"minLength": 1,
|
|
9
|
+
"description": "Coupon code, stored lowercase, unique (enforced in commerce/admin-coupons)"
|
|
10
|
+
},
|
|
11
|
+
"discount_type": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"enum": ["percent", "fixed_cart", "fixed_product"],
|
|
14
|
+
"default": "fixed_cart"
|
|
15
|
+
},
|
|
16
|
+
"amount": {
|
|
17
|
+
"type": "number",
|
|
18
|
+
"minimum": 0,
|
|
19
|
+
"description": "Discount value (percentage for percent type)"
|
|
20
|
+
},
|
|
21
|
+
"description": {
|
|
22
|
+
"type": "string"
|
|
23
|
+
},
|
|
24
|
+
"date_expires": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"format": "date-time"
|
|
27
|
+
},
|
|
28
|
+
"free_shipping": {
|
|
29
|
+
"type": "boolean",
|
|
30
|
+
"default": false,
|
|
31
|
+
"description": "Enables the free_shipping method when it requires a coupon"
|
|
32
|
+
},
|
|
33
|
+
"individual_use": {
|
|
34
|
+
"type": "boolean",
|
|
35
|
+
"default": false,
|
|
36
|
+
"description": "Cannot be combined with other coupons"
|
|
37
|
+
},
|
|
38
|
+
"exclude_sale_items": {
|
|
39
|
+
"type": "boolean",
|
|
40
|
+
"default": false
|
|
41
|
+
},
|
|
42
|
+
"product_ids": {
|
|
43
|
+
"type": "array",
|
|
44
|
+
"items": { "type": "string" },
|
|
45
|
+
"description": "Apply only to these products"
|
|
46
|
+
},
|
|
47
|
+
"excluded_product_ids": {
|
|
48
|
+
"type": "array",
|
|
49
|
+
"items": { "type": "string" }
|
|
50
|
+
},
|
|
51
|
+
"product_category_ids": {
|
|
52
|
+
"type": "array",
|
|
53
|
+
"items": { "type": "string" },
|
|
54
|
+
"description": "Apply only to items in these categories"
|
|
55
|
+
},
|
|
56
|
+
"excluded_product_category_ids": {
|
|
57
|
+
"type": "array",
|
|
58
|
+
"items": { "type": "string" }
|
|
59
|
+
},
|
|
60
|
+
"minimum_amount": {
|
|
61
|
+
"type": "number",
|
|
62
|
+
"description": "Minimum items subtotal to qualify"
|
|
63
|
+
},
|
|
64
|
+
"maximum_amount": {
|
|
65
|
+
"type": "number",
|
|
66
|
+
"description": "Maximum items subtotal to qualify"
|
|
67
|
+
},
|
|
68
|
+
"email_restrictions": {
|
|
69
|
+
"type": "array",
|
|
70
|
+
"items": { "type": "string" },
|
|
71
|
+
"description": "Allowed billing emails; *@domain.com wildcards supported"
|
|
72
|
+
},
|
|
73
|
+
"usage_limit": {
|
|
74
|
+
"type": "integer",
|
|
75
|
+
"description": "Max uses across all customers; null/absent = unlimited"
|
|
76
|
+
},
|
|
77
|
+
"usage_limit_per_user": {
|
|
78
|
+
"type": "integer",
|
|
79
|
+
"description": "Max uses per customer email; null/absent = unlimited"
|
|
80
|
+
},
|
|
81
|
+
"limit_usage_to_x_items": {
|
|
82
|
+
"type": "integer",
|
|
83
|
+
"description": "Max items the coupon applies to (fixed_product); null/absent = all"
|
|
84
|
+
},
|
|
85
|
+
"usage_count": {
|
|
86
|
+
"type": "integer",
|
|
87
|
+
"default": 0,
|
|
88
|
+
"description": "Derived. Maintained by shared/coupons countUsage/uncountUsage."
|
|
89
|
+
},
|
|
90
|
+
"used_by": {
|
|
91
|
+
"type": "array",
|
|
92
|
+
"items": { "type": "string" },
|
|
93
|
+
"description": "Customer emails, one entry per counted use. Maintained by shared/coupons."
|
|
94
|
+
},
|
|
95
|
+
"meta_data": {
|
|
96
|
+
"type": "array",
|
|
97
|
+
"items": {
|
|
98
|
+
"type": "object",
|
|
99
|
+
"properties": {
|
|
100
|
+
"key": { "type": "string" },
|
|
101
|
+
"value": { "type": "string" }
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"required": ["code", "amount"],
|
|
107
|
+
"rls": {
|
|
108
|
+
"read": { "user_condition": { "role": "admin" } },
|
|
109
|
+
"create": { "user_condition": { "role": "admin" } },
|
|
110
|
+
"update": { "user_condition": { "role": "admin" } },
|
|
111
|
+
"delete": { "user_condition": { "role": "admin" } }
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "commerce.Customer",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"description": "Store customer, supporting guests (no linked user) and registered users. Self-service access is mediated by commerce/storefront-account.",
|
|
5
|
+
"properties": {
|
|
6
|
+
"email": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"format": "email",
|
|
9
|
+
"description": "Unique (enforced in commerce/admin-customers / checkout upsert)"
|
|
10
|
+
},
|
|
11
|
+
"first_name": {
|
|
12
|
+
"type": "string"
|
|
13
|
+
},
|
|
14
|
+
"last_name": {
|
|
15
|
+
"type": "string"
|
|
16
|
+
},
|
|
17
|
+
"username": {
|
|
18
|
+
"type": "string"
|
|
19
|
+
},
|
|
20
|
+
"user_id": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "Base44 User id when registered; empty = guest"
|
|
23
|
+
},
|
|
24
|
+
"is_guest": {
|
|
25
|
+
"type": "boolean",
|
|
26
|
+
"description": "Maintained by checkout/admin-customers: true when no linked Base44 user"
|
|
27
|
+
},
|
|
28
|
+
"billing": {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"properties": {
|
|
31
|
+
"first_name": { "type": "string" },
|
|
32
|
+
"last_name": { "type": "string" },
|
|
33
|
+
"company": { "type": "string" },
|
|
34
|
+
"address_1": { "type": "string" },
|
|
35
|
+
"address_2": { "type": "string" },
|
|
36
|
+
"city": { "type": "string" },
|
|
37
|
+
"state": { "type": "string" },
|
|
38
|
+
"postcode": { "type": "string" },
|
|
39
|
+
"country": { "type": "string" },
|
|
40
|
+
"email": { "type": "string", "format": "email" },
|
|
41
|
+
"phone": { "type": "string" }
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"shipping": {
|
|
45
|
+
"type": "object",
|
|
46
|
+
"properties": {
|
|
47
|
+
"first_name": { "type": "string" },
|
|
48
|
+
"last_name": { "type": "string" },
|
|
49
|
+
"company": { "type": "string" },
|
|
50
|
+
"address_1": { "type": "string" },
|
|
51
|
+
"address_2": { "type": "string" },
|
|
52
|
+
"city": { "type": "string" },
|
|
53
|
+
"state": { "type": "string" },
|
|
54
|
+
"postcode": { "type": "string" },
|
|
55
|
+
"country": { "type": "string" },
|
|
56
|
+
"phone": { "type": "string" }
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"is_paying_customer": {
|
|
60
|
+
"type": "boolean",
|
|
61
|
+
"default": false,
|
|
62
|
+
"description": "Derived from paid orders. Maintained by order lifecycle / commerce/admin-customers recalculate-stats."
|
|
63
|
+
},
|
|
64
|
+
"orders_count": {
|
|
65
|
+
"type": "integer",
|
|
66
|
+
"default": 0,
|
|
67
|
+
"description": "Derived. Maintained by order lifecycle / commerce/admin-customers recalculate-stats."
|
|
68
|
+
},
|
|
69
|
+
"total_spent": {
|
|
70
|
+
"type": "number",
|
|
71
|
+
"default": 0,
|
|
72
|
+
"description": "Derived. Maintained by order lifecycle / commerce/admin-customers recalculate-stats."
|
|
73
|
+
},
|
|
74
|
+
"avatar_url": {
|
|
75
|
+
"type": "string",
|
|
76
|
+
"format": "uri"
|
|
77
|
+
},
|
|
78
|
+
"meta_data": {
|
|
79
|
+
"type": "array",
|
|
80
|
+
"items": {
|
|
81
|
+
"type": "object",
|
|
82
|
+
"properties": {
|
|
83
|
+
"key": { "type": "string" },
|
|
84
|
+
"value": { "type": "string" }
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"required": ["email"],
|
|
90
|
+
"rls": {
|
|
91
|
+
"read": { "user_condition": { "role": "admin" } },
|
|
92
|
+
"create": { "user_condition": { "role": "admin" } },
|
|
93
|
+
"update": { "user_condition": { "role": "admin" } },
|
|
94
|
+
"delete": { "user_condition": { "role": "admin" } }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "commerce.DownloadPermission",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"description": "Grants a customer download access to a purchased file. Granted/revoked by the order lifecycle; served and decremented via commerce/storefront-account get-download.",
|
|
5
|
+
"properties": {
|
|
6
|
+
"order_id": {
|
|
7
|
+
"type": "string"
|
|
8
|
+
},
|
|
9
|
+
"order_key": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Copied from the order for guest access checks"
|
|
12
|
+
},
|
|
13
|
+
"customer_email": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"format": "email"
|
|
16
|
+
},
|
|
17
|
+
"product_id": {
|
|
18
|
+
"type": "string"
|
|
19
|
+
},
|
|
20
|
+
"variation_id": {
|
|
21
|
+
"type": "string"
|
|
22
|
+
},
|
|
23
|
+
"download_name": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "File display name"
|
|
26
|
+
},
|
|
27
|
+
"file_url": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"format": "uri"
|
|
30
|
+
},
|
|
31
|
+
"downloads_remaining": {
|
|
32
|
+
"type": "integer",
|
|
33
|
+
"default": -1,
|
|
34
|
+
"description": "-1 = unlimited"
|
|
35
|
+
},
|
|
36
|
+
"access_expires": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"format": "date-time",
|
|
39
|
+
"description": "Absent/null = never expires"
|
|
40
|
+
},
|
|
41
|
+
"download_count": {
|
|
42
|
+
"type": "integer",
|
|
43
|
+
"default": 0,
|
|
44
|
+
"description": "Total downloads served"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"required": ["order_id", "customer_email", "product_id"],
|
|
48
|
+
"rls": {
|
|
49
|
+
"read": { "user_condition": { "role": "admin" } },
|
|
50
|
+
"create": { "user_condition": { "role": "admin" } },
|
|
51
|
+
"update": { "user_condition": { "role": "admin" } },
|
|
52
|
+
"delete": { "user_condition": { "role": "admin" } }
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "commerce.EmailLog",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"description": "Log of transactional emails sent via shared/emails.",
|
|
5
|
+
"properties": {
|
|
6
|
+
"email_type": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"description": "e.g. new_order, processing, completed, refunded, customer_note"
|
|
9
|
+
},
|
|
10
|
+
"recipient": {
|
|
11
|
+
"type": "string"
|
|
12
|
+
},
|
|
13
|
+
"target": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"enum": ["admin", "customer"],
|
|
16
|
+
"description": "Who the email was addressed to. Stock notifications count as admin."
|
|
17
|
+
},
|
|
18
|
+
"subject": {
|
|
19
|
+
"type": "string"
|
|
20
|
+
},
|
|
21
|
+
"order_id": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"description": "Order id as presented to users (order_number)"
|
|
24
|
+
},
|
|
25
|
+
"order_record_id": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"description": "Internal Order record id, for linking back to the order"
|
|
28
|
+
},
|
|
29
|
+
"success": {
|
|
30
|
+
"type": "boolean"
|
|
31
|
+
},
|
|
32
|
+
"error": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"description": "Error message when success is false"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"rls": {
|
|
38
|
+
"read": { "user_condition": { "role": "admin" } },
|
|
39
|
+
"create": { "user_condition": { "role": "admin" } },
|
|
40
|
+
"update": { "user_condition": { "role": "admin" } },
|
|
41
|
+
"delete": { "user_condition": { "role": "admin" } }
|
|
42
|
+
}
|
|
43
|
+
}
|