fix: vendor Prisma into release for Docker

This commit is contained in:
mahmood
2026-09-10 12:53:23 +03:30
parent 9e8d4a017d
commit f0f82d20ec
59 changed files with 58842 additions and 12 deletions
+1
View File
@@ -0,0 +1 @@
export * from "./index"
+1
View File
@@ -0,0 +1 @@
module.exports = { ...require('.') }
+9
View File
@@ -0,0 +1,9 @@
class PrismaClient {
constructor() {
throw new Error(
'@prisma/client/deno/edge did not initialize yet. Please run "prisma generate" and try to import it again.',
)
}
}
export { PrismaClient }
+1
View File
@@ -0,0 +1 @@
export * from "./default"
File diff suppressed because one or more lines are too long
+467
View File
@@ -0,0 +1,467 @@
Object.defineProperty(exports, "__esModule", { value: true });
const {
Decimal,
objectEnumValues,
makeStrictEnum,
Public,
getRuntime,
skip
} = require('@prisma/client/runtime/index-browser.js')
const Prisma = {}
exports.Prisma = Prisma
exports.$Enums = {}
/**
* Prisma Client JS version: 5.22.0
* Query Engine version: 605197351a3c8bdd595af2d2a9bc3025bca48ea2
*/
Prisma.prismaVersion = {
client: "5.22.0",
engine: "605197351a3c8bdd595af2d2a9bc3025bca48ea2"
}
Prisma.PrismaClientKnownRequestError = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`PrismaClientKnownRequestError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)};
Prisma.PrismaClientUnknownRequestError = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`PrismaClientUnknownRequestError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.PrismaClientRustPanicError = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`PrismaClientRustPanicError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.PrismaClientInitializationError = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`PrismaClientInitializationError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.PrismaClientValidationError = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`PrismaClientValidationError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.NotFoundError = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`NotFoundError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.Decimal = Decimal
/**
* Re-export of sql-template-tag
*/
Prisma.sql = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`sqltag is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.empty = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`empty is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.join = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`join is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.raw = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`raw is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.validator = Public.validator
/**
* Extensions
*/
Prisma.getExtensionContext = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`Extensions.getExtensionContext is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.defineExtension = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`Extensions.defineExtension is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
/**
* Shorthand utilities for JSON filtering
*/
Prisma.DbNull = objectEnumValues.instances.DbNull
Prisma.JsonNull = objectEnumValues.instances.JsonNull
Prisma.AnyNull = objectEnumValues.instances.AnyNull
Prisma.NullTypes = {
DbNull: objectEnumValues.classes.DbNull,
JsonNull: objectEnumValues.classes.JsonNull,
AnyNull: objectEnumValues.classes.AnyNull
}
/**
* Enums
*/
exports.Prisma.TransactionIsolationLevel = makeStrictEnum({
ReadUncommitted: 'ReadUncommitted',
ReadCommitted: 'ReadCommitted',
RepeatableRead: 'RepeatableRead',
Serializable: 'Serializable'
});
exports.Prisma.CityScalarFieldEnum = {
id: 'id',
name: 'name',
province: 'province'
};
exports.Prisma.AdminUserScalarFieldEnum = {
id: 'id',
fullName: 'fullName',
mobile: 'mobile',
passwordHash: 'passwordHash',
role: 'role',
branchId: 'branchId',
wagePercent: 'wagePercent',
isActive: 'isActive',
createdAt: 'createdAt'
};
exports.Prisma.CustomerScalarFieldEnum = {
id: 'id',
fullName: 'fullName',
mobile: 'mobile',
nationalCode: 'nationalCode',
passwordHash: 'passwordHash',
cityId: 'cityId',
referredByAgentId: 'referredByAgentId',
goldCreditLimitGrams: 'goldCreditLimitGrams',
goldDebtGrams: 'goldDebtGrams',
fiatDebtRial: 'fiatDebtRial',
verificationStep: 'verificationStep',
nationalIdImageUrl: 'nationalIdImageUrl',
businessLicenseUrl: 'businessLicenseUrl',
shopImageUrl: 'shopImageUrl',
isActive: 'isActive',
createdAt: 'createdAt',
updatedAt: 'updatedAt'
};
exports.Prisma.CustomerAddressScalarFieldEnum = {
id: 'id',
customerId: 'customerId',
cityId: 'cityId',
addressLine: 'addressLine',
isDefault: 'isDefault'
};
exports.Prisma.BranchScalarFieldEnum = {
id: 'id',
name: 'name',
cityId: 'cityId'
};
exports.Prisma.WorkshopScalarFieldEnum = {
id: 'id',
name: 'name',
isActive: 'isActive'
};
exports.Prisma.CategoryScalarFieldEnum = {
id: 'id',
title: 'title',
parentId: 'parentId'
};
exports.Prisma.BrandScalarFieldEnum = {
id: 'id',
title: 'title'
};
exports.Prisma.CollectionScalarFieldEnum = {
id: 'id',
title: 'title',
description: 'description',
isActive: 'isActive'
};
exports.Prisma.CollectionProductScalarFieldEnum = {
collectionId: 'collectionId',
productId: 'productId'
};
exports.Prisma.ProductScalarFieldEnum = {
id: 'id',
title: 'title',
description: 'description',
categoryId: 'categoryId',
brandId: 'brandId',
isActive: 'isActive',
createdAt: 'createdAt'
};
exports.Prisma.ProductImageScalarFieldEnum = {
id: 'id',
productId: 'productId',
url: 'url',
sortOrder: 'sortOrder'
};
exports.Prisma.ProductVariantScalarFieldEnum = {
id: 'id',
productId: 'productId',
title: 'title',
sku: 'sku',
rashWeightGrams: 'rashWeightGrams',
defaultWagePercent: 'defaultWagePercent',
isActive: 'isActive'
};
exports.Prisma.OrderScalarFieldEnum = {
id: 'id',
orderNumber: 'orderNumber',
customerId: 'customerId',
branchId: 'branchId',
status: 'status',
totalGoldWeightGrams: 'totalGoldWeightGrams',
wageWeightGrams: 'wageWeightGrams',
flatRialCharge: 'flatRialCharge',
isSuspendedOverCreditLimit: 'isSuspendedOverCreditLimit',
deliveredAt: 'deliveredAt',
createdAt: 'createdAt',
updatedAt: 'updatedAt'
};
exports.Prisma.OrderItemScalarFieldEnum = {
id: 'id',
orderId: 'orderId',
productVariantId: 'productVariantId',
quantity: 'quantity',
rashWeightGramsSnapshot: 'rashWeightGramsSnapshot',
wagePercentSnapshot: 'wagePercentSnapshot',
discountPercentSnapshot: 'discountPercentSnapshot',
computedWeightGrams: 'computedWeightGrams',
flatRialCharge: 'flatRialCharge'
};
exports.Prisma.OrderStatusEventScalarFieldEnum = {
id: 'id',
orderId: 'orderId',
fromStatus: 'fromStatus',
toStatus: 'toStatus',
note: 'note',
actorAdminUserId: 'actorAdminUserId',
createdAt: 'createdAt'
};
exports.Prisma.PreOrderScalarFieldEnum = {
id: 'id',
customerId: 'customerId',
cityId: 'cityId',
workshopId: 'workshopId',
status: 'status',
designImageUrl: 'designImageUrl',
colorName: 'colorName',
sizeSpec: 'sizeSpec',
stoneColor: 'stoneColor',
minaColor: 'minaColor',
estimatedWeightGrams: 'estimatedWeightGrams',
estimatedPriceRial: 'estimatedPriceRial',
description: 'description',
convertedOrderId: 'convertedOrderId',
createdAt: 'createdAt',
updatedAt: 'updatedAt'
};
exports.Prisma.PreOrderStatusEventScalarFieldEnum = {
id: 'id',
preOrderId: 'preOrderId',
changes: 'changes',
actorAdminUserId: 'actorAdminUserId',
ipAddress: 'ipAddress',
createdAt: 'createdAt'
};
exports.Prisma.LedgerEntryScalarFieldEnum = {
id: 'id',
customerId: 'customerId',
currency: 'currency',
direction: 'direction',
sourceType: 'sourceType',
amount: 'amount',
karatPerMille: 'karatPerMille',
pricePerGramRialAtEntry: 'pricePerGramRialAtEntry',
orderId: 'orderId',
confirmed: 'confirmed',
confirmedAt: 'confirmedAt',
postedByAdminUserId: 'postedByAdminUserId',
note: 'note',
createdAt: 'createdAt'
};
exports.Prisma.GoldPriceQuoteScalarFieldEnum = {
id: 'id',
karatPerMille: 'karatPerMille',
pricePerGramRial: 'pricePerGramRial',
source: 'source',
quotedAt: 'quotedAt'
};
exports.Prisma.WalletBonusScalarFieldEnum = {
id: 'id',
customerId: 'customerId',
orderId: 'orderId',
goldGrams: 'goldGrams',
grantedAt: 'grantedAt',
expiresAt: 'expiresAt',
consumedAt: 'consumedAt',
isActive: 'isActive'
};
exports.Prisma.SortOrder = {
asc: 'asc',
desc: 'desc'
};
exports.Prisma.JsonNullValueInput = {
JsonNull: Prisma.JsonNull
};
exports.Prisma.QueryMode = {
default: 'default',
insensitive: 'insensitive'
};
exports.Prisma.NullsOrder = {
first: 'first',
last: 'last'
};
exports.Prisma.JsonNullValueFilter = {
DbNull: Prisma.DbNull,
JsonNull: Prisma.JsonNull,
AnyNull: Prisma.AnyNull
};
exports.AdminRole = exports.$Enums.AdminRole = {
SUPER_ADMIN: 'SUPER_ADMIN',
SYSTEM_APPROVER: 'SYSTEM_APPROVER',
SALES_EXPERT: 'SALES_EXPERT',
WORKSHOP_SUPERVISOR: 'WORKSHOP_SUPERVISOR',
ACCOUNTANT: 'ACCOUNTANT'
};
exports.VerificationStep = exports.$Enums.VerificationStep = {
UNVERIFIED: 'UNVERIFIED',
STEP_ONE_SUBMITTED: 'STEP_ONE_SUBMITTED',
STEP_TWO_SUBMITTED: 'STEP_TWO_SUBMITTED',
VERIFIED: 'VERIFIED'
};
exports.OrderStatus = exports.$Enums.OrderStatus = {
SUSPENDED: 'SUSPENDED',
PLACED: 'PLACED',
ADMIN_APPROVED: 'ADMIN_APPROVED',
SOURCING: 'SOURCING',
PREPARING: 'PREPARING',
DELIVERED_TO_AGENT: 'DELIVERED_TO_AGENT',
DELIVERED_TO_CUSTOMER: 'DELIVERED_TO_CUSTOMER',
CANCELLED: 'CANCELLED'
};
exports.PreOrderStatus = exports.$Enums.PreOrderStatus = {
PLACED: 'PLACED',
ADMIN_APPROVED: 'ADMIN_APPROVED',
WORKSHOP_APPROVED: 'WORKSHOP_APPROVED',
READY_TO_SHIP: 'READY_TO_SHIP',
DELIVERED: 'DELIVERED',
CANCELLED: 'CANCELLED'
};
exports.LedgerCurrency = exports.$Enums.LedgerCurrency = {
GOLD_GRAM: 'GOLD_GRAM',
RIAL: 'RIAL'
};
exports.LedgerDirection = exports.$Enums.LedgerDirection = {
DEBIT: 'DEBIT',
CREDIT: 'CREDIT'
};
exports.LedgerSourceType = exports.$Enums.LedgerSourceType = {
ORDER_STOCK: 'ORDER_STOCK',
ORDER_PRE_ORDER: 'ORDER_PRE_ORDER',
REPAYMENT_MELTED_GOLD: 'REPAYMENT_MELTED_GOLD',
REPAYMENT_TRANSFER: 'REPAYMENT_TRANSFER',
REPAYMENT_CHEQUE: 'REPAYMENT_CHEQUE',
REPAYMENT_CASH: 'REPAYMENT_CASH',
WALLET_BONUS: 'WALLET_BONUS',
ADJUSTMENT: 'ADJUSTMENT'
};
exports.Prisma.ModelName = {
City: 'City',
AdminUser: 'AdminUser',
Customer: 'Customer',
CustomerAddress: 'CustomerAddress',
Branch: 'Branch',
Workshop: 'Workshop',
Category: 'Category',
Brand: 'Brand',
Collection: 'Collection',
CollectionProduct: 'CollectionProduct',
Product: 'Product',
ProductImage: 'ProductImage',
ProductVariant: 'ProductVariant',
Order: 'Order',
OrderItem: 'OrderItem',
OrderStatusEvent: 'OrderStatusEvent',
PreOrder: 'PreOrder',
PreOrderStatusEvent: 'PreOrderStatusEvent',
LedgerEntry: 'LedgerEntry',
GoldPriceQuote: 'GoldPriceQuote',
WalletBonus: 'WalletBonus'
};
/**
* This is a stub Prisma Client that will error at runtime if called.
*/
class PrismaClient {
constructor() {
return new Proxy(this, {
get(target, prop) {
let message
const runtime = getRuntime()
if (runtime.isEdge) {
message = `PrismaClient is not configured to run in ${runtime.prettyName}. In order to run Prisma Client on edge runtime, either:
- Use Prisma Accelerate: https://pris.ly/d/accelerate
- Use Driver Adapters: https://pris.ly/d/driver-adapters
`;
} else {
message = 'PrismaClient is unable to run in this browser environment, or has been bundled for the browser (running in `' + runtime.prettyName + '`).'
}
message += `
If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report`
throw new Error(message)
}
})
}
}
exports.PrismaClient = PrismaClient
Object.assign(exports, Prisma)
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+97
View File
@@ -0,0 +1,97 @@
{
"name": "prisma-client-ba2f6fd6b3d86ffa3c394cb4a096d72809d8f078d1c406de497494345bae5d35",
"main": "index.js",
"types": "index.d.ts",
"browser": "index-browser.js",
"exports": {
"./package.json": "./package.json",
".": {
"require": {
"node": "./index.js",
"edge-light": "./wasm.js",
"workerd": "./wasm.js",
"worker": "./wasm.js",
"browser": "./index-browser.js",
"default": "./index.js"
},
"import": {
"node": "./index.js",
"edge-light": "./wasm.js",
"workerd": "./wasm.js",
"worker": "./wasm.js",
"browser": "./index-browser.js",
"default": "./index.js"
},
"default": "./index.js"
},
"./edge": {
"types": "./edge.d.ts",
"require": "./edge.js",
"import": "./edge.js",
"default": "./edge.js"
},
"./react-native": {
"types": "./react-native.d.ts",
"require": "./react-native.js",
"import": "./react-native.js",
"default": "./react-native.js"
},
"./extension": {
"types": "./extension.d.ts",
"require": "./extension.js",
"import": "./extension.js",
"default": "./extension.js"
},
"./index-browser": {
"types": "./index.d.ts",
"require": "./index-browser.js",
"import": "./index-browser.js",
"default": "./index-browser.js"
},
"./index": {
"types": "./index.d.ts",
"require": "./index.js",
"import": "./index.js",
"default": "./index.js"
},
"./wasm": {
"types": "./wasm.d.ts",
"require": "./wasm.js",
"import": "./wasm.js",
"default": "./wasm.js"
},
"./runtime/library": {
"types": "./runtime/library.d.ts",
"require": "./runtime/library.js",
"import": "./runtime/library.js",
"default": "./runtime/library.js"
},
"./runtime/binary": {
"types": "./runtime/binary.d.ts",
"require": "./runtime/binary.js",
"import": "./runtime/binary.js",
"default": "./runtime/binary.js"
},
"./generator-build": {
"require": "./generator-build/index.js",
"import": "./generator-build/index.js",
"default": "./generator-build/index.js"
},
"./sql": {
"require": {
"types": "./sql.d.ts",
"node": "./sql.js",
"default": "./sql.js"
},
"import": {
"types": "./sql.d.ts",
"node": "./sql.mjs",
"default": "./sql.mjs"
},
"default": "./sql.js"
},
"./*": "./*"
},
"version": "5.22.0",
"sideEffects": false
}
+425
View File
@@ -0,0 +1,425 @@
// Gold Banking System — core schema
// Canonical accounting model: legacy "System A" gram ledger (see migration notes).
// The external "Tahesab" service is retired — LedgerEntry is the sole source of truth.
// All money/weight fields use Decimal, never Float, to avoid rounding drift in debt math.
generator client {
provider = "prisma-client-js"
// native = local Windows/macOS build; linux-musl = Arvan/Alpine Docker runtime
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
// ─────────────────────────────────────────────────────────────────────────
// Enums
// ─────────────────────────────────────────────────────────────────────────
enum AdminRole {
SUPER_ADMIN
SYSTEM_APPROVER // legacy: تایید مدیر سیستم
SALES_EXPERT // legacy Customer.type=1, also acts as a referral "reagent"
WORKSHOP_SUPERVISOR
ACCOUNTANT
}
enum VerificationStep {
UNVERIFIED
STEP_ONE_SUBMITTED
STEP_TWO_SUBMITTED
VERIFIED
}
enum OrderStatus {
SUSPENDED // credit limit (goldCreditLimitGrams) exceeded at placement
PLACED
ADMIN_APPROVED
SOURCING
PREPARING
DELIVERED_TO_AGENT
DELIVERED_TO_CUSTOMER // debt recognition point — mirrors legacy sts>4
CANCELLED
}
enum PreOrderStatus {
PLACED
ADMIN_APPROVED
WORKSHOP_APPROVED
READY_TO_SHIP
DELIVERED
CANCELLED
}
enum LedgerCurrency {
GOLD_GRAM
RIAL
}
enum LedgerDirection {
DEBIT // increases what the customer owes
CREDIT // decreases what the customer owes
}
enum LedgerSourceType {
ORDER_STOCK
ORDER_PRE_ORDER
REPAYMENT_MELTED_GOLD // karat-normalized: amount * karatPerMille / 750
REPAYMENT_TRANSFER
REPAYMENT_CHEQUE
REPAYMENT_CASH // price-per-gram-normalized via pricePerGramRialAtEntry
WALLET_BONUS
ADJUSTMENT
}
// ─────────────────────────────────────────────────────────────────────────
// Identity
// ─────────────────────────────────────────────────────────────────────────
model City {
id String @id @default(cuid())
name String
province String?
customers Customer[]
addresses CustomerAddress[]
branches Branch[]
preOrders PreOrder[]
}
model AdminUser {
id String @id @default(cuid())
fullName String
mobile String @unique
passwordHash String
role AdminRole
branchId String?
branch Branch? @relation(fields: [branchId], references: [id])
wagePercent Decimal? @db.Decimal(6, 3) // legacy Customer.percent, commission on referred orders
isActive Boolean @default(true)
createdAt DateTime @default(now())
referredCustomers Customer[] @relation("ReferralAgent")
postedLedgerEntries LedgerEntry[]
orderStatusEvents OrderStatusEvent[]
preOrderStatusEvents PreOrderStatusEvent[]
@@index([role])
}
model Customer {
id String @id @default(cuid())
fullName String
mobile String @unique
nationalCode String @unique
passwordHash String
cityId String?
city City? @relation(fields: [cityId], references: [id])
referredByAgentId String?
referredByAgent AdminUser? @relation("ReferralAgent", fields: [referredByAgentId], references: [id])
// Credit limit + cached ledger balances (source of truth is LedgerEntry; these
// are denormalized for fast reads and reconciled by a scheduled job).
goldCreditLimitGrams Decimal @default(0) @db.Decimal(14, 4) // legacy gram_level
goldDebtGrams Decimal @default(0) @db.Decimal(14, 4) // legacy remain
fiatDebtRial Decimal @default(0) @db.Decimal(20, 2) // legacy rial_remain
verificationStep VerificationStep @default(UNVERIFIED)
nationalIdImageUrl String?
businessLicenseUrl String?
shopImageUrl String?
isActive Boolean @default(true)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
addresses CustomerAddress[]
orders Order[]
preOrders PreOrder[]
ledgerEntries LedgerEntry[]
walletBonuses WalletBonus[]
@@index([referredByAgentId])
}
model CustomerAddress {
id String @id @default(cuid())
customerId String
customer Customer @relation(fields: [customerId], references: [id])
cityId String?
city City? @relation(fields: [cityId], references: [id])
addressLine String
isDefault Boolean @default(false)
}
model Branch {
id String @id @default(cuid())
name String
cityId String?
city City? @relation(fields: [cityId], references: [id])
adminUsers AdminUser[]
orders Order[]
}
model Workshop {
id String @id @default(cuid())
name String
isActive Boolean @default(true)
preOrders PreOrder[]
}
// ─────────────────────────────────────────────────────────────────────────
// Catalog — item reference catalog
// ─────────────────────────────────────────────────────────────────────────
model Category {
id String @id @default(cuid())
title String
parentId String?
parent Category? @relation("CategoryTree", fields: [parentId], references: [id])
children Category[] @relation("CategoryTree")
products Product[]
}
model Brand {
id String @id @default(cuid())
title String
products Product[]
}
/// Curated product groupings — replaces legacy "Ciny/CinyProduct" (a tagging
/// feature, NOT a gold-price snapshot mechanism, despite the misleading legacy name).
model Collection {
id String @id @default(cuid())
title String
description String?
isActive Boolean @default(true)
products CollectionProduct[]
}
model CollectionProduct {
collectionId String
collection Collection @relation(fields: [collectionId], references: [id])
productId String
product Product @relation(fields: [productId], references: [id])
@@id([collectionId, productId])
}
model Product {
id String @id @default(cuid())
title String
description String?
categoryId String?
category Category? @relation(fields: [categoryId], references: [id])
brandId String?
brand Brand? @relation(fields: [brandId], references: [id])
isActive Boolean @default(true)
createdAt DateTime @default(now())
variants ProductVariant[]
images ProductImage[]
collections CollectionProduct[]
}
model ProductImage {
id String @id @default(cuid())
productId String
product Product @relation(fields: [productId], references: [id])
url String
sortOrder Int @default(0)
}
model ProductVariant {
id String @id @default(cuid())
productId String
product Product @relation(fields: [productId], references: [id])
title String
sku String? @unique
/// Base/raw weight before making charge ("rash weight").
rashWeightGrams Decimal @db.Decimal(14, 4)
/// Default making-charge percentage applied on top of rash weight.
defaultWagePercent Decimal @db.Decimal(6, 3)
isActive Boolean @default(true)
orderItems OrderItem[]
}
// ─────────────────────────────────────────────────────────────────────────
// Orders — stock orders (debt-bearing)
// ─────────────────────────────────────────────────────────────────────────
model Order {
id String @id @default(cuid())
orderNumber String @unique
customerId String
customer Customer @relation(fields: [customerId], references: [id])
branchId String?
branch Branch? @relation(fields: [branchId], references: [id])
status OrderStatus @default(PLACED)
/// Total gold weight incl. wage across all items ("allGram" / order.w).
totalGoldWeightGrams Decimal @db.Decimal(14, 4)
/// Pure making-charge weight component (totalGoldWeightGrams minus raw weight sum).
wageWeightGrams Decimal @db.Decimal(14, 4)
/// Flat Rial charge independent of gold price (e.g. stones) — legacy rial_input.
flatRialCharge Decimal @default(0) @db.Decimal(20, 2)
isSuspendedOverCreditLimit Boolean @default(false)
deliveredAt DateTime? // setting this is what triggers debt recognition
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
items OrderItem[]
statusEvents OrderStatusEvent[]
ledgerEntries LedgerEntry[]
convertedFromPreOrder PreOrder?
@@index([customerId])
@@index([status])
}
model OrderItem {
id String @id @default(cuid())
orderId String
order Order @relation(fields: [orderId], references: [id])
productVariantId String
productVariant ProductVariant @relation(fields: [productVariantId], references: [id])
quantity Int
// Snapshots at order time — never re-read from ProductVariant after placement.
rashWeightGramsSnapshot Decimal @db.Decimal(14, 4)
wagePercentSnapshot Decimal @db.Decimal(6, 3)
discountPercentSnapshot Decimal @default(0) @db.Decimal(6, 3)
/// computed: rash*(1 + (wagePercent-discount)/100)
computedWeightGrams Decimal @db.Decimal(14, 4)
flatRialCharge Decimal @default(0) @db.Decimal(20, 2)
}
model OrderStatusEvent {
id String @id @default(cuid())
orderId String
order Order @relation(fields: [orderId], references: [id])
fromStatus OrderStatus?
toStatus OrderStatus
note String?
actorAdminUserId String?
actorAdminUser AdminUser? @relation(fields: [actorAdminUserId], references: [id])
createdAt DateTime @default(now())
@@index([orderId])
}
// ─────────────────────────────────────────────────────────────────────────
// Pre-orders — custom manufacturing requests (not debt-bearing until converted)
// ─────────────────────────────────────────────────────────────────────────
model PreOrder {
id String @id @default(cuid())
customerId String
customer Customer @relation(fields: [customerId], references: [id])
cityId String?
city City? @relation(fields: [cityId], references: [id])
workshopId String?
workshop Workshop? @relation(fields: [workshopId], references: [id])
status PreOrderStatus @default(PLACED)
designImageUrl String?
colorName String?
sizeSpec String?
stoneColor String?
minaColor String?
estimatedWeightGrams Decimal? @db.Decimal(14, 4)
estimatedPriceRial Decimal? @db.Decimal(20, 2)
description String?
/// Once priced, an admin converts this into a real (debt-bearing) Order.
convertedOrderId String? @unique
convertedOrder Order? @relation(fields: [convertedOrderId], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
statusEvents PreOrderStatusEvent[]
@@index([customerId])
}
model PreOrderStatusEvent {
id String @id @default(cuid())
preOrderId String
preOrder PreOrder @relation(fields: [preOrderId], references: [id])
/// Field-level diff, e.g. {"status": {"old": "PLACED", "new": "ADMIN_APPROVED"}}
changes Json
actorAdminUserId String?
actorAdminUser AdminUser? @relation(fields: [actorAdminUserId], references: [id])
ipAddress String?
createdAt DateTime @default(now())
@@index([preOrderId])
}
// ─────────────────────────────────────────────────────────────────────────
// Accounting — the dual-currency ledger (core of the system)
// ─────────────────────────────────────────────────────────────────────────
model LedgerEntry {
id String @id @default(cuid())
customerId String
customer Customer @relation(fields: [customerId], references: [id])
currency LedgerCurrency
direction LedgerDirection
sourceType LedgerSourceType
/// Always positive; direction determines the sign applied to the customer balance.
amount Decimal @db.Decimal(20, 4)
/// Purity of the physical instrument, for REPAYMENT_MELTED_GOLD (e.g. 750, 916).
karatPerMille Int?
/// Gold price/gram at conversion time, for REPAYMENT_CASH.
pricePerGramRialAtEntry Decimal? @db.Decimal(20, 2)
orderId String?
order Order? @relation(fields: [orderId], references: [id])
/// Pending entries don't count toward the cached customer balance until confirmed.
confirmed Boolean @default(false)
confirmedAt DateTime?
postedByAdminUserId String?
postedByAdminUser AdminUser? @relation(fields: [postedByAdminUserId], references: [id])
note String?
createdAt DateTime @default(now())
@@index([customerId, currency])
@@index([orderId])
}
/// Replaces legacy WebServiceGold / ConfigStatic.gold_price — timestamped price feed.
model GoldPriceQuote {
id String @id @default(cuid())
karatPerMille Int
pricePerGramRial Decimal @db.Decimal(20, 2)
source String
quotedAt DateTime @default(now())
@@index([karatPerMille, quotedAt])
}
/// Time-limited gold cashback bonus — replaces the legacy Rooyesh\Wallet gold credit.
model WalletBonus {
id String @id @default(cuid())
customerId String
customer Customer @relation(fields: [customerId], references: [id])
orderId String?
goldGrams Decimal @db.Decimal(14, 4)
grantedAt DateTime @default(now())
expiresAt DateTime
consumedAt DateTime?
isActive Boolean @default(true)
@@index([customerId, isActive])
}
+1
View File
@@ -0,0 +1 @@
export * from "./index"
+467
View File
@@ -0,0 +1,467 @@
Object.defineProperty(exports, "__esModule", { value: true });
const {
Decimal,
objectEnumValues,
makeStrictEnum,
Public,
getRuntime,
skip
} = require('@prisma/client/runtime/index-browser.js')
const Prisma = {}
exports.Prisma = Prisma
exports.$Enums = {}
/**
* Prisma Client JS version: 5.22.0
* Query Engine version: 605197351a3c8bdd595af2d2a9bc3025bca48ea2
*/
Prisma.prismaVersion = {
client: "5.22.0",
engine: "605197351a3c8bdd595af2d2a9bc3025bca48ea2"
}
Prisma.PrismaClientKnownRequestError = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`PrismaClientKnownRequestError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)};
Prisma.PrismaClientUnknownRequestError = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`PrismaClientUnknownRequestError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.PrismaClientRustPanicError = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`PrismaClientRustPanicError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.PrismaClientInitializationError = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`PrismaClientInitializationError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.PrismaClientValidationError = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`PrismaClientValidationError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.NotFoundError = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`NotFoundError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.Decimal = Decimal
/**
* Re-export of sql-template-tag
*/
Prisma.sql = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`sqltag is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.empty = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`empty is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.join = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`join is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.raw = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`raw is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.validator = Public.validator
/**
* Extensions
*/
Prisma.getExtensionContext = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`Extensions.getExtensionContext is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
Prisma.defineExtension = () => {
const runtimeName = getRuntime().prettyName;
throw new Error(`Extensions.defineExtension is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}).
In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`,
)}
/**
* Shorthand utilities for JSON filtering
*/
Prisma.DbNull = objectEnumValues.instances.DbNull
Prisma.JsonNull = objectEnumValues.instances.JsonNull
Prisma.AnyNull = objectEnumValues.instances.AnyNull
Prisma.NullTypes = {
DbNull: objectEnumValues.classes.DbNull,
JsonNull: objectEnumValues.classes.JsonNull,
AnyNull: objectEnumValues.classes.AnyNull
}
/**
* Enums
*/
exports.Prisma.TransactionIsolationLevel = makeStrictEnum({
ReadUncommitted: 'ReadUncommitted',
ReadCommitted: 'ReadCommitted',
RepeatableRead: 'RepeatableRead',
Serializable: 'Serializable'
});
exports.Prisma.CityScalarFieldEnum = {
id: 'id',
name: 'name',
province: 'province'
};
exports.Prisma.AdminUserScalarFieldEnum = {
id: 'id',
fullName: 'fullName',
mobile: 'mobile',
passwordHash: 'passwordHash',
role: 'role',
branchId: 'branchId',
wagePercent: 'wagePercent',
isActive: 'isActive',
createdAt: 'createdAt'
};
exports.Prisma.CustomerScalarFieldEnum = {
id: 'id',
fullName: 'fullName',
mobile: 'mobile',
nationalCode: 'nationalCode',
passwordHash: 'passwordHash',
cityId: 'cityId',
referredByAgentId: 'referredByAgentId',
goldCreditLimitGrams: 'goldCreditLimitGrams',
goldDebtGrams: 'goldDebtGrams',
fiatDebtRial: 'fiatDebtRial',
verificationStep: 'verificationStep',
nationalIdImageUrl: 'nationalIdImageUrl',
businessLicenseUrl: 'businessLicenseUrl',
shopImageUrl: 'shopImageUrl',
isActive: 'isActive',
createdAt: 'createdAt',
updatedAt: 'updatedAt'
};
exports.Prisma.CustomerAddressScalarFieldEnum = {
id: 'id',
customerId: 'customerId',
cityId: 'cityId',
addressLine: 'addressLine',
isDefault: 'isDefault'
};
exports.Prisma.BranchScalarFieldEnum = {
id: 'id',
name: 'name',
cityId: 'cityId'
};
exports.Prisma.WorkshopScalarFieldEnum = {
id: 'id',
name: 'name',
isActive: 'isActive'
};
exports.Prisma.CategoryScalarFieldEnum = {
id: 'id',
title: 'title',
parentId: 'parentId'
};
exports.Prisma.BrandScalarFieldEnum = {
id: 'id',
title: 'title'
};
exports.Prisma.CollectionScalarFieldEnum = {
id: 'id',
title: 'title',
description: 'description',
isActive: 'isActive'
};
exports.Prisma.CollectionProductScalarFieldEnum = {
collectionId: 'collectionId',
productId: 'productId'
};
exports.Prisma.ProductScalarFieldEnum = {
id: 'id',
title: 'title',
description: 'description',
categoryId: 'categoryId',
brandId: 'brandId',
isActive: 'isActive',
createdAt: 'createdAt'
};
exports.Prisma.ProductImageScalarFieldEnum = {
id: 'id',
productId: 'productId',
url: 'url',
sortOrder: 'sortOrder'
};
exports.Prisma.ProductVariantScalarFieldEnum = {
id: 'id',
productId: 'productId',
title: 'title',
sku: 'sku',
rashWeightGrams: 'rashWeightGrams',
defaultWagePercent: 'defaultWagePercent',
isActive: 'isActive'
};
exports.Prisma.OrderScalarFieldEnum = {
id: 'id',
orderNumber: 'orderNumber',
customerId: 'customerId',
branchId: 'branchId',
status: 'status',
totalGoldWeightGrams: 'totalGoldWeightGrams',
wageWeightGrams: 'wageWeightGrams',
flatRialCharge: 'flatRialCharge',
isSuspendedOverCreditLimit: 'isSuspendedOverCreditLimit',
deliveredAt: 'deliveredAt',
createdAt: 'createdAt',
updatedAt: 'updatedAt'
};
exports.Prisma.OrderItemScalarFieldEnum = {
id: 'id',
orderId: 'orderId',
productVariantId: 'productVariantId',
quantity: 'quantity',
rashWeightGramsSnapshot: 'rashWeightGramsSnapshot',
wagePercentSnapshot: 'wagePercentSnapshot',
discountPercentSnapshot: 'discountPercentSnapshot',
computedWeightGrams: 'computedWeightGrams',
flatRialCharge: 'flatRialCharge'
};
exports.Prisma.OrderStatusEventScalarFieldEnum = {
id: 'id',
orderId: 'orderId',
fromStatus: 'fromStatus',
toStatus: 'toStatus',
note: 'note',
actorAdminUserId: 'actorAdminUserId',
createdAt: 'createdAt'
};
exports.Prisma.PreOrderScalarFieldEnum = {
id: 'id',
customerId: 'customerId',
cityId: 'cityId',
workshopId: 'workshopId',
status: 'status',
designImageUrl: 'designImageUrl',
colorName: 'colorName',
sizeSpec: 'sizeSpec',
stoneColor: 'stoneColor',
minaColor: 'minaColor',
estimatedWeightGrams: 'estimatedWeightGrams',
estimatedPriceRial: 'estimatedPriceRial',
description: 'description',
convertedOrderId: 'convertedOrderId',
createdAt: 'createdAt',
updatedAt: 'updatedAt'
};
exports.Prisma.PreOrderStatusEventScalarFieldEnum = {
id: 'id',
preOrderId: 'preOrderId',
changes: 'changes',
actorAdminUserId: 'actorAdminUserId',
ipAddress: 'ipAddress',
createdAt: 'createdAt'
};
exports.Prisma.LedgerEntryScalarFieldEnum = {
id: 'id',
customerId: 'customerId',
currency: 'currency',
direction: 'direction',
sourceType: 'sourceType',
amount: 'amount',
karatPerMille: 'karatPerMille',
pricePerGramRialAtEntry: 'pricePerGramRialAtEntry',
orderId: 'orderId',
confirmed: 'confirmed',
confirmedAt: 'confirmedAt',
postedByAdminUserId: 'postedByAdminUserId',
note: 'note',
createdAt: 'createdAt'
};
exports.Prisma.GoldPriceQuoteScalarFieldEnum = {
id: 'id',
karatPerMille: 'karatPerMille',
pricePerGramRial: 'pricePerGramRial',
source: 'source',
quotedAt: 'quotedAt'
};
exports.Prisma.WalletBonusScalarFieldEnum = {
id: 'id',
customerId: 'customerId',
orderId: 'orderId',
goldGrams: 'goldGrams',
grantedAt: 'grantedAt',
expiresAt: 'expiresAt',
consumedAt: 'consumedAt',
isActive: 'isActive'
};
exports.Prisma.SortOrder = {
asc: 'asc',
desc: 'desc'
};
exports.Prisma.JsonNullValueInput = {
JsonNull: Prisma.JsonNull
};
exports.Prisma.QueryMode = {
default: 'default',
insensitive: 'insensitive'
};
exports.Prisma.NullsOrder = {
first: 'first',
last: 'last'
};
exports.Prisma.JsonNullValueFilter = {
DbNull: Prisma.DbNull,
JsonNull: Prisma.JsonNull,
AnyNull: Prisma.AnyNull
};
exports.AdminRole = exports.$Enums.AdminRole = {
SUPER_ADMIN: 'SUPER_ADMIN',
SYSTEM_APPROVER: 'SYSTEM_APPROVER',
SALES_EXPERT: 'SALES_EXPERT',
WORKSHOP_SUPERVISOR: 'WORKSHOP_SUPERVISOR',
ACCOUNTANT: 'ACCOUNTANT'
};
exports.VerificationStep = exports.$Enums.VerificationStep = {
UNVERIFIED: 'UNVERIFIED',
STEP_ONE_SUBMITTED: 'STEP_ONE_SUBMITTED',
STEP_TWO_SUBMITTED: 'STEP_TWO_SUBMITTED',
VERIFIED: 'VERIFIED'
};
exports.OrderStatus = exports.$Enums.OrderStatus = {
SUSPENDED: 'SUSPENDED',
PLACED: 'PLACED',
ADMIN_APPROVED: 'ADMIN_APPROVED',
SOURCING: 'SOURCING',
PREPARING: 'PREPARING',
DELIVERED_TO_AGENT: 'DELIVERED_TO_AGENT',
DELIVERED_TO_CUSTOMER: 'DELIVERED_TO_CUSTOMER',
CANCELLED: 'CANCELLED'
};
exports.PreOrderStatus = exports.$Enums.PreOrderStatus = {
PLACED: 'PLACED',
ADMIN_APPROVED: 'ADMIN_APPROVED',
WORKSHOP_APPROVED: 'WORKSHOP_APPROVED',
READY_TO_SHIP: 'READY_TO_SHIP',
DELIVERED: 'DELIVERED',
CANCELLED: 'CANCELLED'
};
exports.LedgerCurrency = exports.$Enums.LedgerCurrency = {
GOLD_GRAM: 'GOLD_GRAM',
RIAL: 'RIAL'
};
exports.LedgerDirection = exports.$Enums.LedgerDirection = {
DEBIT: 'DEBIT',
CREDIT: 'CREDIT'
};
exports.LedgerSourceType = exports.$Enums.LedgerSourceType = {
ORDER_STOCK: 'ORDER_STOCK',
ORDER_PRE_ORDER: 'ORDER_PRE_ORDER',
REPAYMENT_MELTED_GOLD: 'REPAYMENT_MELTED_GOLD',
REPAYMENT_TRANSFER: 'REPAYMENT_TRANSFER',
REPAYMENT_CHEQUE: 'REPAYMENT_CHEQUE',
REPAYMENT_CASH: 'REPAYMENT_CASH',
WALLET_BONUS: 'WALLET_BONUS',
ADJUSTMENT: 'ADJUSTMENT'
};
exports.Prisma.ModelName = {
City: 'City',
AdminUser: 'AdminUser',
Customer: 'Customer',
CustomerAddress: 'CustomerAddress',
Branch: 'Branch',
Workshop: 'Workshop',
Category: 'Category',
Brand: 'Brand',
Collection: 'Collection',
CollectionProduct: 'CollectionProduct',
Product: 'Product',
ProductImage: 'ProductImage',
ProductVariant: 'ProductVariant',
Order: 'Order',
OrderItem: 'OrderItem',
OrderStatusEvent: 'OrderStatusEvent',
PreOrder: 'PreOrder',
PreOrderStatusEvent: 'PreOrderStatusEvent',
LedgerEntry: 'LedgerEntry',
GoldPriceQuote: 'GoldPriceQuote',
WalletBonus: 'WalletBonus'
};
/**
* This is a stub Prisma Client that will error at runtime if called.
*/
class PrismaClient {
constructor() {
return new Proxy(this, {
get(target, prop) {
let message
const runtime = getRuntime()
if (runtime.isEdge) {
message = `PrismaClient is not configured to run in ${runtime.prettyName}. In order to run Prisma Client on edge runtime, either:
- Use Prisma Accelerate: https://pris.ly/d/accelerate
- Use Driver Adapters: https://pris.ly/d/driver-adapters
`;
} else {
message = 'PrismaClient is unable to run in this browser environment, or has been bundled for the browser (running in `' + runtime.prettyName + '`).'
}
message += `
If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report`
throw new Error(message)
}
})
}
}
exports.PrismaClient = PrismaClient
Object.assign(exports, Prisma)