- Node/Express/TypeScript API under /api/v1 with JWT auth (login, refresh, logout, /me) - Prisma schema: vendors, users, roles, products, categories, taxes, transactions - SQLite for local dev; Postgres via docker-compose for production - Full CRUD routes for vendors, users, categories, taxes, products with Zod validation and RBAC - Paginated list endpoints scoped per vendor; refresh token rotation - React/TypeScript admin SPA (Vite): login, protected routing, sidebar layout - Pages: Dashboard, Catalog (tabbed Products/Categories/Taxes), Users, Vendor Settings - Shared UI: Table, Modal, FormField, Btn, PageHeader components - Multi-stage Dockerfile; docker-compose with Postgres healthcheck - Seed script with demo vendor and owner account - INSTRUCTIONS.md, ROADMAP.md, .claude/launch.json for dev server config Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
55 lines
1.5 KiB
JavaScript
55 lines
1.5 KiB
JavaScript
'use strict'
|
|
|
|
let AtRule = require('./at-rule')
|
|
let Comment = require('./comment')
|
|
let Declaration = require('./declaration')
|
|
let Input = require('./input')
|
|
let PreviousMap = require('./previous-map')
|
|
let Root = require('./root')
|
|
let Rule = require('./rule')
|
|
|
|
function fromJSON(json, inputs) {
|
|
if (Array.isArray(json)) return json.map(n => fromJSON(n))
|
|
|
|
let { inputs: ownInputs, ...defaults } = json
|
|
if (ownInputs) {
|
|
inputs = []
|
|
for (let input of ownInputs) {
|
|
let inputHydrated = { ...input, __proto__: Input.prototype }
|
|
if (inputHydrated.map) {
|
|
inputHydrated.map = {
|
|
...inputHydrated.map,
|
|
__proto__: PreviousMap.prototype
|
|
}
|
|
}
|
|
inputs.push(inputHydrated)
|
|
}
|
|
}
|
|
if (defaults.nodes) {
|
|
defaults.nodes = json.nodes.map(n => fromJSON(n, inputs))
|
|
}
|
|
if (defaults.source) {
|
|
let { inputId, ...source } = defaults.source
|
|
defaults.source = source
|
|
if (inputId != null) {
|
|
defaults.source.input = inputs[inputId]
|
|
}
|
|
}
|
|
if (defaults.type === 'root') {
|
|
return new Root(defaults)
|
|
} else if (defaults.type === 'decl') {
|
|
return new Declaration(defaults)
|
|
} else if (defaults.type === 'rule') {
|
|
return new Rule(defaults)
|
|
} else if (defaults.type === 'comment') {
|
|
return new Comment(defaults)
|
|
} else if (defaults.type === 'atrule') {
|
|
return new AtRule(defaults)
|
|
} else {
|
|
throw new Error('Unknown node type: ' + json.type)
|
|
}
|
|
}
|
|
|
|
module.exports = fromJSON
|
|
fromJSON.default = fromJSON
|