Compare commits

..

4 Commits

Author SHA1 Message Date
ahasani fc27b9d616 feat(pos): add favorite functionality for goods
- Implemented PosGoodFavoriteController to handle attaching and detaching favorites for goods.
- Created PosGoodFavoriteService to manage the business logic for favorites, including database operations and cache invalidation.
- Added PosGoodFavoriteModule to encapsulate the controller and service.
2026-05-20 11:42:59 +03:30
ahasani 98099e97e7 feat: add field validators for username and password, and integrate them into DTOs 2026-05-19 20:34:05 +03:30
ahasani d526f6ed2c feat: enhance consumer selection to include partner details for individual and legal types 2026-05-19 16:11:59 +03:30
ahasani 62b659246f feat: implement Redis caching for business activities and consumers
- Added Redis caching to BusinessActivitiesService for findAll and findOne methods.
- Integrated Redis caching in BusinessActivityComplexesService for findAll and findOne methods.
- Enhanced ConsumersService with Redis caching for findAll and findOne methods.
- Introduced cache invalidation for partner consumers and business activities.
- Created RedisKeyMaker utility for generating cache keys for consumers, partners, and POS.
- Implemented cache invalidation services for partners and POS.
- Added Redis service methods for JSON handling and key deletion by patterns.
- Updated goods service to include caching and invalidation for goods list.
- Introduced DTO for updating goods.
2026-05-19 15:40:45 +03:30
66 changed files with 3290 additions and 136 deletions
+27
View File
@@ -102,3 +102,30 @@ Operational guide for AI/coding agents working in `consumer_api`.
- Duplicate FK error seen in this repo: `sales_invoices_ref_id_fkey` (MySQL 1826). Recheck migration SQL for repeated `ADD CONSTRAINT` statements before rerun.
- Drift that repeatedly showed in this project: missing FK/unique on `sale_invoice_tsp_attempts.invoice_id`. Validate both schema and migration SQL produce the same final state.
- `prisma migrate status` may show up-to-date while `migrate dev` still detects drift (shadow DB/application history issue); treat `migrate dev` output as source of truth for fixing local history.
## Redis Cache Conventions (May 2026)
- Use `RedisKeyMaker` in `src/common/utils/redis-key-maker.util.ts` for all cache keys and wildcard patterns; do not inline key strings in services.
- Keep invalidation domain-based (for example `src/modules/admin/guilds/cache/*`, `src/modules/admin/partners/cache/*`, `src/modules/pos/cache/*`) and avoid duplicating delete logic across modules.
- For list APIs that are expensive or frequently read, prefer read-through cache with TTL and invalidation on every related write path.
- For entity endpoints, use list + detail split:
- list key(s): invalidated broadly on writes,
- detail key(s): invalidated per entity id.
- Partner domain rules:
- Shared partner cache namespace is `partners:*` (not admin-prefixed) because writes occur in both `admin/partners` and `partners` modules.
- Use shared invalidation service `src/modules/partners/cache/partners-cache-invalidation.service.ts` from both admin and partner write paths.
- Invalidate `partners:list` and `partners:{id}:detail` on partner create/update/delete and license-affecting writes.
- Invalidate partner license caches (activated-licenses list, charge-transactions list/detail) via the shared invalidation service.
- POS goods rules:
- Cache key shape is BA + guild scoped (`pos:ba:{businessActivityId}:guild:{guildId}:goods:list`) because results combine guild-default and BA-owned goods.
- Invalidate POS goods cache by guild when admin guild goods/category/sku changes.
- Invalidate POS goods cache by business activity when consumer BA goods create/update/delete.
- Consumer/Partner hierarchy rules:
- Consumer profile cache key: `consumers:{consumerId}:info`.
- Partner-consumer profile cache key: `partners:{partnerId}:consumers:{consumerId}:info`.
- On partner-consumer single read, write both keys when practical to share warm cache across modules.
- On consumer info update or partner-consumer update, invalidate both consumer and partner-consumer profile keys.
- For business activities, invalidate both list and detail layers; child updates may invalidate parent single cache when parent aggregates depend on child state.
- Wildcard invalidation implementation:
- Use `RedisService.deleteByPattern` / `RedisService.deleteByPatterns` for all pattern deletes.
- Do not implement ad-hoc scan/delete loops inside domain services.
- Pattern deletion uses `SCAN` + pipelined `DEL`; multi-pattern deletes run in parallel.
@@ -0,0 +1,16 @@
-- CreateTable
CREATE TABLE `consumer_account_goods_favorites` (
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`consumer_account_id` VARCHAR(191) NOT NULL,
`goods_id` VARCHAR(191) NOT NULL,
INDEX `consumer_account_goods_favorites_goods_id_idx`(`goods_id`),
INDEX `consumer_account_goods_favorites_consumer_account_id_idx`(`consumer_account_id`),
PRIMARY KEY (`consumer_account_id`, `goods_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- AddForeignKey
ALTER TABLE `consumer_account_goods_favorites` ADD CONSTRAINT `consumer_account_goods_favorites_consumer_account_id_fkey` FOREIGN KEY (`consumer_account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `consumer_account_goods_favorites` ADD CONSTRAINT `consumer_account_goods_favorites_goods_id_fkey` FOREIGN KEY (`goods_id`) REFERENCES `goods`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,31 @@
/*
Warnings:
- You are about to drop the `consumer_account_goods_favorites` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE `consumer_account_goods_favorites` DROP FOREIGN KEY `consumer_account_goods_favorites_consumer_account_id_fkey`;
-- DropForeignKey
ALTER TABLE `consumer_account_goods_favorites` DROP FOREIGN KEY `consumer_account_goods_favorites_goods_id_fkey`;
-- DropTable
DROP TABLE `consumer_account_goods_favorites`;
-- CreateTable
CREATE TABLE `consumer_account_good_favorites` (
`created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`consumer_account_id` VARCHAR(191) NOT NULL,
`good_id` VARCHAR(191) NOT NULL,
INDEX `consumer_account_good_favorites_good_id_idx`(`good_id`),
INDEX `consumer_account_good_favorites_consumer_account_id_idx`(`consumer_account_id`),
PRIMARY KEY (`consumer_account_id`, `good_id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- AddForeignKey
ALTER TABLE `consumer_account_good_favorites` ADD CONSTRAINT `consumer_account_good_favorites_consumer_account_id_fkey` FOREIGN KEY (`consumer_account_id`) REFERENCES `consumer_accounts`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `consumer_account_good_favorites` ADD CONSTRAINT `consumer_account_good_favorites_good_id_fkey` FOREIGN KEY (`good_id`) REFERENCES `goods`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
+17 -1
View File
@@ -14,8 +14,9 @@ model ConsumerAccount {
pos Pos?
permission PermissionConsumer?
account_allocation LicenseAccountAllocation?
sales_invoices SalesInvoice[]
account_device ConsumerAccountDevice?
sales_invoices SalesInvoice[]
consumer_account_good_favorites ConsumerAccountGoodFavorite[]
@@map("consumer_accounts")
}
@@ -150,3 +151,18 @@ model Pos {
@@map("poses")
}
model ConsumerAccountGoodFavorite {
created_at DateTime @default(now())
consumer_account_id String
consumer_account ConsumerAccount @relation(fields: [consumer_account_id], references: [id], onDelete: Cascade)
good_id String
good Good @relation(fields: [good_id], references: [id], onDelete: Cascade)
@@id([consumer_account_id, good_id]) // unique pair
@@index([good_id])
@@index([consumer_account_id])
@@map("consumer_account_good_favorites")
}
+1
View File
@@ -26,6 +26,7 @@ model Good {
business_activity BusinessActivity? @relation(fields: [business_activity_id], references: [id])
sales_invoice_items SalesInvoiceItem[]
consumer_account_good_favorites ConsumerAccountGoodFavorite[]
@@index([category_id])
@@map("goods")
@@ -0,0 +1,14 @@
import { Matches, MinLength } from 'class-validator'
const MIN_LENGTH = 6
const REGEX = /^[a-zA-Z0-9]*$/
export const FiscalIdFieldValidator = () =>
function (target: object, propertyKey: string) {
MinLength(MIN_LENGTH, {
message: `شناسه یکتا باید حداقل ${MIN_LENGTH} کاراکتر باشد`,
})(target, propertyKey)
Matches(REGEX, {
message: 'شناسه یکتا فقط می‌تواند شامل حروف و اعداد باشد',
})(target, propertyKey)
}
@@ -0,0 +1,3 @@
export { FiscalIdFieldValidator } from './fiscalId-validator'
export { PasswordFieldValidator, PASSWORD_MIN_LENGTH } from './password'
export { UsernameFieldValidator } from './username'
@@ -0,0 +1,10 @@
import { MinLength } from 'class-validator'
export const PASSWORD_MIN_LENGTH = 6
export const PasswordFieldValidator = () =>
function (target: object, propertyKey: string) {
MinLength(PASSWORD_MIN_LENGTH, {
message: `رمز عبور باید حداقل ${PASSWORD_MIN_LENGTH} کاراکتر باشد`,
})(target, propertyKey)
}
@@ -0,0 +1,14 @@
import { Matches, MinLength } from 'class-validator'
const USERNAME_REGEX = /^[a-zA-Z0-9_-]*$/
const USERNAME_MIN_LENGTH = 6
export const UsernameFieldValidator = () =>
function (target: object, propertyKey: string) {
MinLength(USERNAME_MIN_LENGTH, {
message: `نام کاربری باید حداقل ${USERNAME_MIN_LENGTH} کاراکتر باشد`,
})(target, propertyKey)
Matches(USERNAME_REGEX, {
message: 'نام کاربری فقط می‌تواند شامل حروف، اعداد، زیرخط و خط تیره باشد',
})(target, propertyKey)
}
+4 -2
View File
@@ -1,6 +1,8 @@
export * from './jwt-user.util'
export * from './enum-translator.util'
export * from './field-validator.util'
export * from './http-client.util'
export * from './jwt-user.util'
export * from './mappers/consumer_mappers.util'
export * from './password.util'
export * from './redisKeyMaker'
export * from './tracking-code-generator.util'
export * from './http-client.util'
@@ -0,0 +1,16 @@
export class ConsumerKeyMaker {
static consumerInfo(consumerId: string): string {
return `consumers:${consumerId}:info`
}
static consumerBusinessActivitiesList(consumerId: string): string {
return `consumers:${consumerId}:business-activities:list`
}
static consumerBusinessActivityInfo(
consumerId: string,
businessActivityId: string,
): string {
return `consumers:${consumerId}:business-activities:${businessActivityId}:info`
}
}
+9
View File
@@ -0,0 +1,9 @@
export class EnumKeyMaker {
static enumsAll(buildVersion: string): string {
return `enums:${buildVersion}:all`
}
static enumsValues(buildVersion: string, enumName: string): string {
return `enums:${buildVersion}:values:${enumName}`
}
}
+9
View File
@@ -0,0 +1,9 @@
export class GuildKeyMaker {
static guildStockKeepingUnitsList(guildId: string): string {
return `guilds:${guildId}:stock-keeping-units:list`
}
static guildGoodsList(guildId: string): string {
return `guilds:${guildId}:goods:list`
}
}
+30
View File
@@ -0,0 +1,30 @@
import { ConsumerKeyMaker } from './consumer'
import { EnumKeyMaker } from './enum'
import { GuildKeyMaker } from './guild'
import { PartnerKeyMaker } from './partner'
import { PosKeyMaker } from './pos'
// Keep backward-compatible static methods while separating key builders by domain.
export class RedisKeyMaker extends PartnerKeyMaker {
static consumer = ConsumerKeyMaker
static enums = EnumKeyMaker
static guild = GuildKeyMaker
static partner = PartnerKeyMaker
static pos = PosKeyMaker
static consumerInfo = ConsumerKeyMaker.consumerInfo
static consumerBusinessActivitiesList = ConsumerKeyMaker.consumerBusinessActivitiesList
static consumerBusinessActivityInfo = ConsumerKeyMaker.consumerBusinessActivityInfo
static guildStockKeepingUnitsList = GuildKeyMaker.guildStockKeepingUnitsList
static guildGoodsList = GuildKeyMaker.guildGoodsList
static posInfo = PosKeyMaker.posInfo
static posMe = PosKeyMaker.posMe
static posGoodsList = PosKeyMaker.posGoodsList
static enumsAll = EnumKeyMaker.enumsAll
static enumsValues = EnumKeyMaker.enumsValues
}
export { ConsumerKeyMaker, EnumKeyMaker, GuildKeyMaker, PartnerKeyMaker, PosKeyMaker }
+135
View File
@@ -0,0 +1,135 @@
export class PartnerKeyMaker {
static partnersList(): string {
return 'partners:list'
}
static partnerDetail(partnerId: string): string {
return `partners:${partnerId}:detail`
}
static partnerActivatedLicensesList(
partnerId: string,
page: number,
perPage: number,
): string {
return `partners:${partnerId}:activated-licenses:list:${page}:${perPage}`
}
static partnerActivatedLicensesListPattern(partnerId: string): string {
return `partners:${partnerId}:activated-licenses:list:*`
}
static partnerLicenseChargeTransactionsList(
partnerId: string,
page: number,
perPage: number,
): string {
return `partners:${partnerId}:license-charge-transactions:list:${page}:${perPage}`
}
static partnerLicenseChargeTransactionsListPattern(partnerId: string): string {
return `partners:${partnerId}:license-charge-transactions:list:*`
}
static partnerLicenseChargeTransactionDetail(
partnerId: string,
transactionId: string,
): string {
return `partners:${partnerId}:license-charge-transactions:${transactionId}:detail`
}
static partnerLicenseChargeTransactionDetailPattern(partnerId: string): string {
return `partners:${partnerId}:license-charge-transactions:*:detail`
}
//////////////////// consumers ////////////////////
static partnerConsumersPattern(partnerId: string): string {
return `partners:${partnerId}:consumers:*`
}
static partnerConsumerPattern(partnerId: string): string {
return this.partnerConsumersPattern(partnerId)
}
static partnerConsumersListPattern(partnerId: string): string {
return `partners:${partnerId}:consumers:list:*`
}
static partnerConsumersList(partnerId: string, page: number, perPage: number): string {
return `partners:${partnerId}:consumers:list:${page}:${perPage}`
}
static partnerConsumerInfo(partnerId: string, consumerId: string): string {
return `partners:${partnerId}:consumers:${consumerId}:info`
}
static partnerConsumerBusinessActivitiesList(
partnerId: string,
consumerId: string,
page: number,
perPage: number,
): string {
return `partners:${partnerId}:consumers:${consumerId}:business-activities:list:${page}:${perPage}`
}
static partnerConsumerBusinessActivitiesPattern(
partnerId: string,
consumerId: string,
): string {
return `partners:${partnerId}:consumers:${consumerId}:business-activities:*`
}
static partnerConsumerBusinessActivityInfo(
partnerId: string,
consumerId: string,
businessActivityId: string,
): string {
return `partners:${partnerId}:consumers:${consumerId}:business-activities:${businessActivityId}:info`
}
static partnerConsumerBusinessActivityComplexesList(
partnerId: string,
consumerId: string,
businessActivityId: string,
page: number,
perPage: number,
): string {
return `partners:${partnerId}:consumers:${consumerId}:business-activities:${businessActivityId}:complexes:list:${page}:${perPage}`
}
static partnerConsumerBusinessActivityComplexesPattern(
partnerId: string,
consumerId: string,
businessActivityId: string,
): string {
return `partners:${partnerId}:consumers:${consumerId}:business-activities:${businessActivityId}:complexes:*`
}
static partnerConsumerBusinessActivityComplexInfo(
partnerId: string,
consumerId: string,
businessActivityId: string,
complexId: string,
): string {
return `partners:${partnerId}:consumers:${consumerId}:business-activities:${businessActivityId}:complexes:${complexId}`
}
static partnerConsumerBusinessActivityComplexPosesPattern(
partnerId: string,
consumerId: string,
businessActivityId: string,
complexId: string,
): string {
return `partners:${partnerId}:consumers:${consumerId}:business-activities:${businessActivityId}:complexes:${complexId}:poses:*`
}
static partnerConsumerBusinessActivityComplexPosInfo(
partnerId: string,
consumerId: string,
businessActivityId: string,
complexId: string,
posId: string,
): string {
return `partners:${partnerId}:consumers:${consumerId}:business-activities:${businessActivityId}:complexes:${complexId}:poses:${posId}`
}
}
+13
View File
@@ -0,0 +1,13 @@
export class PosKeyMaker {
static posInfo(posId: string): string {
return `pos:${posId}:info`
}
static posMe(accountId: string, posId: string): string {
return `pos:${posId}:me:${accountId}`
}
static posGoodsList(businessActivityId: string, guildId: string): string {
return `pos:ba:${businessActivityId}:guild:${guildId}:goods:list`
}
}
+5
View File
@@ -167,6 +167,11 @@ export type Complex = Prisma.ComplexModel
*
*/
export type Pos = Prisma.PosModel
/**
* Model ConsumerAccountGoodFavorite
*
*/
export type ConsumerAccountGoodFavorite = Prisma.ConsumerAccountGoodFavoriteModel
/**
* Model Good
*
+5
View File
@@ -189,6 +189,11 @@ export type Complex = Prisma.ComplexModel
*
*/
export type Pos = Prisma.PosModel
/**
* Model ConsumerAccountGoodFavorite
*
*/
export type ConsumerAccountGoodFavorite = Prisma.ConsumerAccountGoodFavoriteModel
/**
* Model Good
*
File diff suppressed because one or more lines are too long
@@ -414,6 +414,7 @@ export const ModelName = {
BusinessActivity: 'BusinessActivity',
Complex: 'Complex',
Pos: 'Pos',
ConsumerAccountGoodFavorite: 'ConsumerAccountGoodFavorite',
Good: 'Good',
GoodCategory: 'GoodCategory',
Guild: 'Guild',
@@ -445,7 +446,7 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
omit: GlobalOmitOptions
}
meta: {
modelProps: "adminAccount" | "admin" | "account" | "deviceBrand" | "device" | "licenseChargeTransaction" | "license" | "licenseActivation" | "licenseRenewChargeTransaction" | "licenseRenew" | "partnerAccountQuotaChargeTransaction" | "partnerAccountQuotaCredit" | "licenseAccountAllocation" | "partnerAccount" | "partner" | "permissionConsumer" | "permissionPos" | "permissionComplex" | "permissionBusiness" | "providerAccount" | "provider" | "consumerAccountDevice" | "applicationReleasedInfo" | "consumerAccount" | "consumer" | "consumerIndividual" | "consumerLegal" | "businessActivity" | "complex" | "pos" | "good" | "goodCategory" | "guild" | "measureUnits" | "stockKeepingUnits" | "triggerLog" | "customer" | "customerIndividual" | "customerLegal" | "salesInvoice" | "salesInvoiceItem" | "saleInvoiceTspAttempts" | "salesInvoicePayment" | "salesInvoicePaymentTerminalInfo" | "service" | "serviceCategory"
modelProps: "adminAccount" | "admin" | "account" | "deviceBrand" | "device" | "licenseChargeTransaction" | "license" | "licenseActivation" | "licenseRenewChargeTransaction" | "licenseRenew" | "partnerAccountQuotaChargeTransaction" | "partnerAccountQuotaCredit" | "licenseAccountAllocation" | "partnerAccount" | "partner" | "permissionConsumer" | "permissionPos" | "permissionComplex" | "permissionBusiness" | "providerAccount" | "provider" | "consumerAccountDevice" | "applicationReleasedInfo" | "consumerAccount" | "consumer" | "consumerIndividual" | "consumerLegal" | "businessActivity" | "complex" | "pos" | "consumerAccountGoodFavorite" | "good" | "goodCategory" | "guild" | "measureUnits" | "stockKeepingUnits" | "triggerLog" | "customer" | "customerIndividual" | "customerLegal" | "salesInvoice" | "salesInvoiceItem" | "saleInvoiceTspAttempts" | "salesInvoicePayment" | "salesInvoicePaymentTerminalInfo" | "service" | "serviceCategory"
txIsolationLevel: TransactionIsolationLevel
}
model: {
@@ -2429,6 +2430,72 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
}
}
}
ConsumerAccountGoodFavorite: {
payload: Prisma.$ConsumerAccountGoodFavoritePayload<ExtArgs>
fields: Prisma.ConsumerAccountGoodFavoriteFieldRefs
operations: {
findUnique: {
args: Prisma.ConsumerAccountGoodFavoriteFindUniqueArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$ConsumerAccountGoodFavoritePayload> | null
}
findUniqueOrThrow: {
args: Prisma.ConsumerAccountGoodFavoriteFindUniqueOrThrowArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$ConsumerAccountGoodFavoritePayload>
}
findFirst: {
args: Prisma.ConsumerAccountGoodFavoriteFindFirstArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$ConsumerAccountGoodFavoritePayload> | null
}
findFirstOrThrow: {
args: Prisma.ConsumerAccountGoodFavoriteFindFirstOrThrowArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$ConsumerAccountGoodFavoritePayload>
}
findMany: {
args: Prisma.ConsumerAccountGoodFavoriteFindManyArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$ConsumerAccountGoodFavoritePayload>[]
}
create: {
args: Prisma.ConsumerAccountGoodFavoriteCreateArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$ConsumerAccountGoodFavoritePayload>
}
createMany: {
args: Prisma.ConsumerAccountGoodFavoriteCreateManyArgs<ExtArgs>
result: BatchPayload
}
delete: {
args: Prisma.ConsumerAccountGoodFavoriteDeleteArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$ConsumerAccountGoodFavoritePayload>
}
update: {
args: Prisma.ConsumerAccountGoodFavoriteUpdateArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$ConsumerAccountGoodFavoritePayload>
}
deleteMany: {
args: Prisma.ConsumerAccountGoodFavoriteDeleteManyArgs<ExtArgs>
result: BatchPayload
}
updateMany: {
args: Prisma.ConsumerAccountGoodFavoriteUpdateManyArgs<ExtArgs>
result: BatchPayload
}
upsert: {
args: Prisma.ConsumerAccountGoodFavoriteUpsertArgs<ExtArgs>
result: runtime.Types.Utils.PayloadToResult<Prisma.$ConsumerAccountGoodFavoritePayload>
}
aggregate: {
args: Prisma.ConsumerAccountGoodFavoriteAggregateArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.AggregateConsumerAccountGoodFavorite>
}
groupBy: {
args: Prisma.ConsumerAccountGoodFavoriteGroupByArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.ConsumerAccountGoodFavoriteGroupByOutputType>[]
}
count: {
args: Prisma.ConsumerAccountGoodFavoriteCountArgs<ExtArgs>
result: runtime.Types.Utils.Optional<Prisma.ConsumerAccountGoodFavoriteCountAggregateOutputType> | number
}
}
}
Good: {
payload: Prisma.$GoodPayload<ExtArgs>
fields: Prisma.GoodFieldRefs
@@ -3890,6 +3957,15 @@ export const PosScalarFieldEnum = {
export type PosScalarFieldEnum = (typeof PosScalarFieldEnum)[keyof typeof PosScalarFieldEnum]
export const ConsumerAccountGoodFavoriteScalarFieldEnum = {
created_at: 'created_at',
consumer_account_id: 'consumer_account_id',
good_id: 'good_id'
} as const
export type ConsumerAccountGoodFavoriteScalarFieldEnum = (typeof ConsumerAccountGoodFavoriteScalarFieldEnum)[keyof typeof ConsumerAccountGoodFavoriteScalarFieldEnum]
export const GoodScalarFieldEnum = {
id: 'id',
name: 'name',
@@ -4469,6 +4545,14 @@ export const PosOrderByRelevanceFieldEnum = {
export type PosOrderByRelevanceFieldEnum = (typeof PosOrderByRelevanceFieldEnum)[keyof typeof PosOrderByRelevanceFieldEnum]
export const ConsumerAccountGoodFavoriteOrderByRelevanceFieldEnum = {
consumer_account_id: 'consumer_account_id',
good_id: 'good_id'
} as const
export type ConsumerAccountGoodFavoriteOrderByRelevanceFieldEnum = (typeof ConsumerAccountGoodFavoriteOrderByRelevanceFieldEnum)[keyof typeof ConsumerAccountGoodFavoriteOrderByRelevanceFieldEnum]
export const GoodOrderByRelevanceFieldEnum = {
id: 'id',
name: 'name',
@@ -4992,6 +5076,7 @@ export type GlobalOmitConfig = {
businessActivity?: Prisma.BusinessActivityOmit
complex?: Prisma.ComplexOmit
pos?: Prisma.PosOmit
consumerAccountGoodFavorite?: Prisma.ConsumerAccountGoodFavoriteOmit
good?: Prisma.GoodOmit
goodCategory?: Prisma.GoodCategoryOmit
guild?: Prisma.GuildOmit
@@ -81,6 +81,7 @@ export const ModelName = {
BusinessActivity: 'BusinessActivity',
Complex: 'Complex',
Pos: 'Pos',
ConsumerAccountGoodFavorite: 'ConsumerAccountGoodFavorite',
Good: 'Good',
GoodCategory: 'GoodCategory',
Guild: 'Guild',
@@ -481,6 +482,15 @@ export const PosScalarFieldEnum = {
export type PosScalarFieldEnum = (typeof PosScalarFieldEnum)[keyof typeof PosScalarFieldEnum]
export const ConsumerAccountGoodFavoriteScalarFieldEnum = {
created_at: 'created_at',
consumer_account_id: 'consumer_account_id',
good_id: 'good_id'
} as const
export type ConsumerAccountGoodFavoriteScalarFieldEnum = (typeof ConsumerAccountGoodFavoriteScalarFieldEnum)[keyof typeof ConsumerAccountGoodFavoriteScalarFieldEnum]
export const GoodScalarFieldEnum = {
id: 'id',
name: 'name',
@@ -1060,6 +1070,14 @@ export const PosOrderByRelevanceFieldEnum = {
export type PosOrderByRelevanceFieldEnum = (typeof PosOrderByRelevanceFieldEnum)[keyof typeof PosOrderByRelevanceFieldEnum]
export const ConsumerAccountGoodFavoriteOrderByRelevanceFieldEnum = {
consumer_account_id: 'consumer_account_id',
good_id: 'good_id'
} as const
export type ConsumerAccountGoodFavoriteOrderByRelevanceFieldEnum = (typeof ConsumerAccountGoodFavoriteOrderByRelevanceFieldEnum)[keyof typeof ConsumerAccountGoodFavoriteOrderByRelevanceFieldEnum]
export const GoodOrderByRelevanceFieldEnum = {
id: 'id',
name: 'name',
+1
View File
@@ -38,6 +38,7 @@ export type * from './models/ConsumerLegal.js'
export type * from './models/BusinessActivity.js'
export type * from './models/Complex.js'
export type * from './models/Pos.js'
export type * from './models/ConsumerAccountGoodFavorite.js'
export type * from './models/Good.js'
export type * from './models/GoodCategory.js'
export type * from './models/Guild.js'
+197 -39
View File
@@ -195,8 +195,9 @@ export type ConsumerAccountWhereInput = {
pos?: Prisma.XOR<Prisma.PosNullableScalarRelationFilter, Prisma.PosWhereInput> | null
permission?: Prisma.XOR<Prisma.PermissionConsumerNullableScalarRelationFilter, Prisma.PermissionConsumerWhereInput> | null
account_allocation?: Prisma.XOR<Prisma.LicenseAccountAllocationNullableScalarRelationFilter, Prisma.LicenseAccountAllocationWhereInput> | null
sales_invoices?: Prisma.SalesInvoiceListRelationFilter
account_device?: Prisma.XOR<Prisma.ConsumerAccountDeviceNullableScalarRelationFilter, Prisma.ConsumerAccountDeviceWhereInput> | null
sales_invoices?: Prisma.SalesInvoiceListRelationFilter
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteListRelationFilter
}
export type ConsumerAccountOrderByWithRelationInput = {
@@ -211,8 +212,9 @@ export type ConsumerAccountOrderByWithRelationInput = {
pos?: Prisma.PosOrderByWithRelationInput
permission?: Prisma.PermissionConsumerOrderByWithRelationInput
account_allocation?: Prisma.LicenseAccountAllocationOrderByWithRelationInput
sales_invoices?: Prisma.SalesInvoiceOrderByRelationAggregateInput
account_device?: Prisma.ConsumerAccountDeviceOrderByWithRelationInput
sales_invoices?: Prisma.SalesInvoiceOrderByRelationAggregateInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteOrderByRelationAggregateInput
_relevance?: Prisma.ConsumerAccountOrderByRelevanceInput
}
@@ -231,8 +233,9 @@ export type ConsumerAccountWhereUniqueInput = Prisma.AtLeast<{
pos?: Prisma.XOR<Prisma.PosNullableScalarRelationFilter, Prisma.PosWhereInput> | null
permission?: Prisma.XOR<Prisma.PermissionConsumerNullableScalarRelationFilter, Prisma.PermissionConsumerWhereInput> | null
account_allocation?: Prisma.XOR<Prisma.LicenseAccountAllocationNullableScalarRelationFilter, Prisma.LicenseAccountAllocationWhereInput> | null
sales_invoices?: Prisma.SalesInvoiceListRelationFilter
account_device?: Prisma.XOR<Prisma.ConsumerAccountDeviceNullableScalarRelationFilter, Prisma.ConsumerAccountDeviceWhereInput> | null
sales_invoices?: Prisma.SalesInvoiceListRelationFilter
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteListRelationFilter
}, "id" | "account_id">
export type ConsumerAccountOrderByWithAggregationInput = {
@@ -269,8 +272,9 @@ export type ConsumerAccountCreateInput = {
pos?: Prisma.PosCreateNestedOneWithoutAccountInput
permission?: Prisma.PermissionConsumerCreateNestedOneWithoutConsumer_accountInput
account_allocation?: Prisma.LicenseAccountAllocationCreateNestedOneWithoutAccountInput
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutConsumer_accountInput
account_device?: Prisma.ConsumerAccountDeviceCreateNestedOneWithoutConsumer_accountInput
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutConsumer_accountInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteCreateNestedManyWithoutConsumer_accountInput
}
export type ConsumerAccountUncheckedCreateInput = {
@@ -283,8 +287,9 @@ export type ConsumerAccountUncheckedCreateInput = {
pos?: Prisma.PosUncheckedCreateNestedOneWithoutAccountInput
permission?: Prisma.PermissionConsumerUncheckedCreateNestedOneWithoutConsumer_accountInput
account_allocation?: Prisma.LicenseAccountAllocationUncheckedCreateNestedOneWithoutAccountInput
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput
account_device?: Prisma.ConsumerAccountDeviceUncheckedCreateNestedOneWithoutConsumer_accountInput
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedCreateNestedManyWithoutConsumer_accountInput
}
export type ConsumerAccountUpdateInput = {
@@ -297,8 +302,9 @@ export type ConsumerAccountUpdateInput = {
pos?: Prisma.PosUpdateOneWithoutAccountNestedInput
permission?: Prisma.PermissionConsumerUpdateOneWithoutConsumer_accountNestedInput
account_allocation?: Prisma.LicenseAccountAllocationUpdateOneWithoutAccountNestedInput
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput
account_device?: Prisma.ConsumerAccountDeviceUpdateOneWithoutConsumer_accountNestedInput
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUpdateManyWithoutConsumer_accountNestedInput
}
export type ConsumerAccountUncheckedUpdateInput = {
@@ -311,8 +317,9 @@ export type ConsumerAccountUncheckedUpdateInput = {
pos?: Prisma.PosUncheckedUpdateOneWithoutAccountNestedInput
permission?: Prisma.PermissionConsumerUncheckedUpdateOneWithoutConsumer_accountNestedInput
account_allocation?: Prisma.LicenseAccountAllocationUncheckedUpdateOneWithoutAccountNestedInput
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput
account_device?: Prisma.ConsumerAccountDeviceUncheckedUpdateOneWithoutConsumer_accountNestedInput
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedUpdateManyWithoutConsumer_accountNestedInput
}
export type ConsumerAccountCreateManyInput = {
@@ -529,6 +536,20 @@ export type ConsumerAccountUpdateOneRequiredWithoutPosNestedInput = {
update?: Prisma.XOR<Prisma.XOR<Prisma.ConsumerAccountUpdateToOneWithWhereWithoutPosInput, Prisma.ConsumerAccountUpdateWithoutPosInput>, Prisma.ConsumerAccountUncheckedUpdateWithoutPosInput>
}
export type ConsumerAccountCreateNestedOneWithoutConsumer_account_good_favoritesInput = {
create?: Prisma.XOR<Prisma.ConsumerAccountCreateWithoutConsumer_account_good_favoritesInput, Prisma.ConsumerAccountUncheckedCreateWithoutConsumer_account_good_favoritesInput>
connectOrCreate?: Prisma.ConsumerAccountCreateOrConnectWithoutConsumer_account_good_favoritesInput
connect?: Prisma.ConsumerAccountWhereUniqueInput
}
export type ConsumerAccountUpdateOneRequiredWithoutConsumer_account_good_favoritesNestedInput = {
create?: Prisma.XOR<Prisma.ConsumerAccountCreateWithoutConsumer_account_good_favoritesInput, Prisma.ConsumerAccountUncheckedCreateWithoutConsumer_account_good_favoritesInput>
connectOrCreate?: Prisma.ConsumerAccountCreateOrConnectWithoutConsumer_account_good_favoritesInput
upsert?: Prisma.ConsumerAccountUpsertWithoutConsumer_account_good_favoritesInput
connect?: Prisma.ConsumerAccountWhereUniqueInput
update?: Prisma.XOR<Prisma.XOR<Prisma.ConsumerAccountUpdateToOneWithWhereWithoutConsumer_account_good_favoritesInput, Prisma.ConsumerAccountUpdateWithoutConsumer_account_good_favoritesInput>, Prisma.ConsumerAccountUncheckedUpdateWithoutConsumer_account_good_favoritesInput>
}
export type ConsumerAccountCreateNestedOneWithoutSales_invoicesInput = {
create?: Prisma.XOR<Prisma.ConsumerAccountCreateWithoutSales_invoicesInput, Prisma.ConsumerAccountUncheckedCreateWithoutSales_invoicesInput>
connectOrCreate?: Prisma.ConsumerAccountCreateOrConnectWithoutSales_invoicesInput
@@ -552,8 +573,9 @@ export type ConsumerAccountCreateWithoutAccountInput = {
pos?: Prisma.PosCreateNestedOneWithoutAccountInput
permission?: Prisma.PermissionConsumerCreateNestedOneWithoutConsumer_accountInput
account_allocation?: Prisma.LicenseAccountAllocationCreateNestedOneWithoutAccountInput
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutConsumer_accountInput
account_device?: Prisma.ConsumerAccountDeviceCreateNestedOneWithoutConsumer_accountInput
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutConsumer_accountInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteCreateNestedManyWithoutConsumer_accountInput
}
export type ConsumerAccountUncheckedCreateWithoutAccountInput = {
@@ -565,8 +587,9 @@ export type ConsumerAccountUncheckedCreateWithoutAccountInput = {
pos?: Prisma.PosUncheckedCreateNestedOneWithoutAccountInput
permission?: Prisma.PermissionConsumerUncheckedCreateNestedOneWithoutConsumer_accountInput
account_allocation?: Prisma.LicenseAccountAllocationUncheckedCreateNestedOneWithoutAccountInput
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput
account_device?: Prisma.ConsumerAccountDeviceUncheckedCreateNestedOneWithoutConsumer_accountInput
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedCreateNestedManyWithoutConsumer_accountInput
}
export type ConsumerAccountCreateOrConnectWithoutAccountInput = {
@@ -594,8 +617,9 @@ export type ConsumerAccountUpdateWithoutAccountInput = {
pos?: Prisma.PosUpdateOneWithoutAccountNestedInput
permission?: Prisma.PermissionConsumerUpdateOneWithoutConsumer_accountNestedInput
account_allocation?: Prisma.LicenseAccountAllocationUpdateOneWithoutAccountNestedInput
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput
account_device?: Prisma.ConsumerAccountDeviceUpdateOneWithoutConsumer_accountNestedInput
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUpdateManyWithoutConsumer_accountNestedInput
}
export type ConsumerAccountUncheckedUpdateWithoutAccountInput = {
@@ -607,8 +631,9 @@ export type ConsumerAccountUncheckedUpdateWithoutAccountInput = {
pos?: Prisma.PosUncheckedUpdateOneWithoutAccountNestedInput
permission?: Prisma.PermissionConsumerUncheckedUpdateOneWithoutConsumer_accountNestedInput
account_allocation?: Prisma.LicenseAccountAllocationUncheckedUpdateOneWithoutAccountNestedInput
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput
account_device?: Prisma.ConsumerAccountDeviceUncheckedUpdateOneWithoutConsumer_accountNestedInput
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedUpdateManyWithoutConsumer_accountNestedInput
}
export type ConsumerAccountCreateWithoutAccount_allocationInput = {
@@ -620,8 +645,9 @@ export type ConsumerAccountCreateWithoutAccount_allocationInput = {
account: Prisma.AccountCreateNestedOneWithoutConsumer_accountInput
pos?: Prisma.PosCreateNestedOneWithoutAccountInput
permission?: Prisma.PermissionConsumerCreateNestedOneWithoutConsumer_accountInput
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutConsumer_accountInput
account_device?: Prisma.ConsumerAccountDeviceCreateNestedOneWithoutConsumer_accountInput
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutConsumer_accountInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteCreateNestedManyWithoutConsumer_accountInput
}
export type ConsumerAccountUncheckedCreateWithoutAccount_allocationInput = {
@@ -633,8 +659,9 @@ export type ConsumerAccountUncheckedCreateWithoutAccount_allocationInput = {
account_id: string
pos?: Prisma.PosUncheckedCreateNestedOneWithoutAccountInput
permission?: Prisma.PermissionConsumerUncheckedCreateNestedOneWithoutConsumer_accountInput
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput
account_device?: Prisma.ConsumerAccountDeviceUncheckedCreateNestedOneWithoutConsumer_accountInput
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedCreateNestedManyWithoutConsumer_accountInput
}
export type ConsumerAccountCreateOrConnectWithoutAccount_allocationInput = {
@@ -662,8 +689,9 @@ export type ConsumerAccountUpdateWithoutAccount_allocationInput = {
account?: Prisma.AccountUpdateOneRequiredWithoutConsumer_accountNestedInput
pos?: Prisma.PosUpdateOneWithoutAccountNestedInput
permission?: Prisma.PermissionConsumerUpdateOneWithoutConsumer_accountNestedInput
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput
account_device?: Prisma.ConsumerAccountDeviceUpdateOneWithoutConsumer_accountNestedInput
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUpdateManyWithoutConsumer_accountNestedInput
}
export type ConsumerAccountUncheckedUpdateWithoutAccount_allocationInput = {
@@ -675,8 +703,9 @@ export type ConsumerAccountUncheckedUpdateWithoutAccount_allocationInput = {
account_id?: Prisma.StringFieldUpdateOperationsInput | string
pos?: Prisma.PosUncheckedUpdateOneWithoutAccountNestedInput
permission?: Prisma.PermissionConsumerUncheckedUpdateOneWithoutConsumer_accountNestedInput
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput
account_device?: Prisma.ConsumerAccountDeviceUncheckedUpdateOneWithoutConsumer_accountNestedInput
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedUpdateManyWithoutConsumer_accountNestedInput
}
export type ConsumerAccountCreateWithoutPermissionInput = {
@@ -688,8 +717,9 @@ export type ConsumerAccountCreateWithoutPermissionInput = {
account: Prisma.AccountCreateNestedOneWithoutConsumer_accountInput
pos?: Prisma.PosCreateNestedOneWithoutAccountInput
account_allocation?: Prisma.LicenseAccountAllocationCreateNestedOneWithoutAccountInput
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutConsumer_accountInput
account_device?: Prisma.ConsumerAccountDeviceCreateNestedOneWithoutConsumer_accountInput
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutConsumer_accountInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteCreateNestedManyWithoutConsumer_accountInput
}
export type ConsumerAccountUncheckedCreateWithoutPermissionInput = {
@@ -701,8 +731,9 @@ export type ConsumerAccountUncheckedCreateWithoutPermissionInput = {
account_id: string
pos?: Prisma.PosUncheckedCreateNestedOneWithoutAccountInput
account_allocation?: Prisma.LicenseAccountAllocationUncheckedCreateNestedOneWithoutAccountInput
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput
account_device?: Prisma.ConsumerAccountDeviceUncheckedCreateNestedOneWithoutConsumer_accountInput
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedCreateNestedManyWithoutConsumer_accountInput
}
export type ConsumerAccountCreateOrConnectWithoutPermissionInput = {
@@ -730,8 +761,9 @@ export type ConsumerAccountUpdateWithoutPermissionInput = {
account?: Prisma.AccountUpdateOneRequiredWithoutConsumer_accountNestedInput
pos?: Prisma.PosUpdateOneWithoutAccountNestedInput
account_allocation?: Prisma.LicenseAccountAllocationUpdateOneWithoutAccountNestedInput
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput
account_device?: Prisma.ConsumerAccountDeviceUpdateOneWithoutConsumer_accountNestedInput
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUpdateManyWithoutConsumer_accountNestedInput
}
export type ConsumerAccountUncheckedUpdateWithoutPermissionInput = {
@@ -743,8 +775,9 @@ export type ConsumerAccountUncheckedUpdateWithoutPermissionInput = {
account_id?: Prisma.StringFieldUpdateOperationsInput | string
pos?: Prisma.PosUncheckedUpdateOneWithoutAccountNestedInput
account_allocation?: Prisma.LicenseAccountAllocationUncheckedUpdateOneWithoutAccountNestedInput
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput
account_device?: Prisma.ConsumerAccountDeviceUncheckedUpdateOneWithoutConsumer_accountNestedInput
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedUpdateManyWithoutConsumer_accountNestedInput
}
export type ConsumerAccountCreateWithoutAccount_deviceInput = {
@@ -758,6 +791,7 @@ export type ConsumerAccountCreateWithoutAccount_deviceInput = {
permission?: Prisma.PermissionConsumerCreateNestedOneWithoutConsumer_accountInput
account_allocation?: Prisma.LicenseAccountAllocationCreateNestedOneWithoutAccountInput
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutConsumer_accountInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteCreateNestedManyWithoutConsumer_accountInput
}
export type ConsumerAccountUncheckedCreateWithoutAccount_deviceInput = {
@@ -771,6 +805,7 @@ export type ConsumerAccountUncheckedCreateWithoutAccount_deviceInput = {
permission?: Prisma.PermissionConsumerUncheckedCreateNestedOneWithoutConsumer_accountInput
account_allocation?: Prisma.LicenseAccountAllocationUncheckedCreateNestedOneWithoutAccountInput
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedCreateNestedManyWithoutConsumer_accountInput
}
export type ConsumerAccountCreateOrConnectWithoutAccount_deviceInput = {
@@ -800,6 +835,7 @@ export type ConsumerAccountUpdateWithoutAccount_deviceInput = {
permission?: Prisma.PermissionConsumerUpdateOneWithoutConsumer_accountNestedInput
account_allocation?: Prisma.LicenseAccountAllocationUpdateOneWithoutAccountNestedInput
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUpdateManyWithoutConsumer_accountNestedInput
}
export type ConsumerAccountUncheckedUpdateWithoutAccount_deviceInput = {
@@ -813,6 +849,7 @@ export type ConsumerAccountUncheckedUpdateWithoutAccount_deviceInput = {
permission?: Prisma.PermissionConsumerUncheckedUpdateOneWithoutConsumer_accountNestedInput
account_allocation?: Prisma.LicenseAccountAllocationUncheckedUpdateOneWithoutAccountNestedInput
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedUpdateManyWithoutConsumer_accountNestedInput
}
export type ConsumerAccountCreateWithoutConsumerInput = {
@@ -824,8 +861,9 @@ export type ConsumerAccountCreateWithoutConsumerInput = {
pos?: Prisma.PosCreateNestedOneWithoutAccountInput
permission?: Prisma.PermissionConsumerCreateNestedOneWithoutConsumer_accountInput
account_allocation?: Prisma.LicenseAccountAllocationCreateNestedOneWithoutAccountInput
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutConsumer_accountInput
account_device?: Prisma.ConsumerAccountDeviceCreateNestedOneWithoutConsumer_accountInput
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutConsumer_accountInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteCreateNestedManyWithoutConsumer_accountInput
}
export type ConsumerAccountUncheckedCreateWithoutConsumerInput = {
@@ -837,8 +875,9 @@ export type ConsumerAccountUncheckedCreateWithoutConsumerInput = {
pos?: Prisma.PosUncheckedCreateNestedOneWithoutAccountInput
permission?: Prisma.PermissionConsumerUncheckedCreateNestedOneWithoutConsumer_accountInput
account_allocation?: Prisma.LicenseAccountAllocationUncheckedCreateNestedOneWithoutAccountInput
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput
account_device?: Prisma.ConsumerAccountDeviceUncheckedCreateNestedOneWithoutConsumer_accountInput
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedCreateNestedManyWithoutConsumer_accountInput
}
export type ConsumerAccountCreateOrConnectWithoutConsumerInput = {
@@ -888,8 +927,9 @@ export type ConsumerAccountCreateWithoutPosInput = {
account: Prisma.AccountCreateNestedOneWithoutConsumer_accountInput
permission?: Prisma.PermissionConsumerCreateNestedOneWithoutConsumer_accountInput
account_allocation?: Prisma.LicenseAccountAllocationCreateNestedOneWithoutAccountInput
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutConsumer_accountInput
account_device?: Prisma.ConsumerAccountDeviceCreateNestedOneWithoutConsumer_accountInput
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutConsumer_accountInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteCreateNestedManyWithoutConsumer_accountInput
}
export type ConsumerAccountUncheckedCreateWithoutPosInput = {
@@ -901,8 +941,9 @@ export type ConsumerAccountUncheckedCreateWithoutPosInput = {
account_id: string
permission?: Prisma.PermissionConsumerUncheckedCreateNestedOneWithoutConsumer_accountInput
account_allocation?: Prisma.LicenseAccountAllocationUncheckedCreateNestedOneWithoutAccountInput
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput
account_device?: Prisma.ConsumerAccountDeviceUncheckedCreateNestedOneWithoutConsumer_accountInput
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedCreateNestedManyWithoutConsumer_accountInput
}
export type ConsumerAccountCreateOrConnectWithoutPosInput = {
@@ -930,8 +971,9 @@ export type ConsumerAccountUpdateWithoutPosInput = {
account?: Prisma.AccountUpdateOneRequiredWithoutConsumer_accountNestedInput
permission?: Prisma.PermissionConsumerUpdateOneWithoutConsumer_accountNestedInput
account_allocation?: Prisma.LicenseAccountAllocationUpdateOneWithoutAccountNestedInput
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput
account_device?: Prisma.ConsumerAccountDeviceUpdateOneWithoutConsumer_accountNestedInput
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUpdateManyWithoutConsumer_accountNestedInput
}
export type ConsumerAccountUncheckedUpdateWithoutPosInput = {
@@ -943,8 +985,81 @@ export type ConsumerAccountUncheckedUpdateWithoutPosInput = {
account_id?: Prisma.StringFieldUpdateOperationsInput | string
permission?: Prisma.PermissionConsumerUncheckedUpdateOneWithoutConsumer_accountNestedInput
account_allocation?: Prisma.LicenseAccountAllocationUncheckedUpdateOneWithoutAccountNestedInput
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput
account_device?: Prisma.ConsumerAccountDeviceUncheckedUpdateOneWithoutConsumer_accountNestedInput
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedUpdateManyWithoutConsumer_accountNestedInput
}
export type ConsumerAccountCreateWithoutConsumer_account_good_favoritesInput = {
id?: string
role: $Enums.ConsumerRole
created_at?: Date | string
updated_at?: Date | string
consumer: Prisma.ConsumerCreateNestedOneWithoutAccountsInput
account: Prisma.AccountCreateNestedOneWithoutConsumer_accountInput
pos?: Prisma.PosCreateNestedOneWithoutAccountInput
permission?: Prisma.PermissionConsumerCreateNestedOneWithoutConsumer_accountInput
account_allocation?: Prisma.LicenseAccountAllocationCreateNestedOneWithoutAccountInput
account_device?: Prisma.ConsumerAccountDeviceCreateNestedOneWithoutConsumer_accountInput
sales_invoices?: Prisma.SalesInvoiceCreateNestedManyWithoutConsumer_accountInput
}
export type ConsumerAccountUncheckedCreateWithoutConsumer_account_good_favoritesInput = {
id?: string
role: $Enums.ConsumerRole
created_at?: Date | string
updated_at?: Date | string
consumer_id: string
account_id: string
pos?: Prisma.PosUncheckedCreateNestedOneWithoutAccountInput
permission?: Prisma.PermissionConsumerUncheckedCreateNestedOneWithoutConsumer_accountInput
account_allocation?: Prisma.LicenseAccountAllocationUncheckedCreateNestedOneWithoutAccountInput
account_device?: Prisma.ConsumerAccountDeviceUncheckedCreateNestedOneWithoutConsumer_accountInput
sales_invoices?: Prisma.SalesInvoiceUncheckedCreateNestedManyWithoutConsumer_accountInput
}
export type ConsumerAccountCreateOrConnectWithoutConsumer_account_good_favoritesInput = {
where: Prisma.ConsumerAccountWhereUniqueInput
create: Prisma.XOR<Prisma.ConsumerAccountCreateWithoutConsumer_account_good_favoritesInput, Prisma.ConsumerAccountUncheckedCreateWithoutConsumer_account_good_favoritesInput>
}
export type ConsumerAccountUpsertWithoutConsumer_account_good_favoritesInput = {
update: Prisma.XOR<Prisma.ConsumerAccountUpdateWithoutConsumer_account_good_favoritesInput, Prisma.ConsumerAccountUncheckedUpdateWithoutConsumer_account_good_favoritesInput>
create: Prisma.XOR<Prisma.ConsumerAccountCreateWithoutConsumer_account_good_favoritesInput, Prisma.ConsumerAccountUncheckedCreateWithoutConsumer_account_good_favoritesInput>
where?: Prisma.ConsumerAccountWhereInput
}
export type ConsumerAccountUpdateToOneWithWhereWithoutConsumer_account_good_favoritesInput = {
where?: Prisma.ConsumerAccountWhereInput
data: Prisma.XOR<Prisma.ConsumerAccountUpdateWithoutConsumer_account_good_favoritesInput, Prisma.ConsumerAccountUncheckedUpdateWithoutConsumer_account_good_favoritesInput>
}
export type ConsumerAccountUpdateWithoutConsumer_account_good_favoritesInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
role?: Prisma.EnumConsumerRoleFieldUpdateOperationsInput | $Enums.ConsumerRole
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
consumer?: Prisma.ConsumerUpdateOneRequiredWithoutAccountsNestedInput
account?: Prisma.AccountUpdateOneRequiredWithoutConsumer_accountNestedInput
pos?: Prisma.PosUpdateOneWithoutAccountNestedInput
permission?: Prisma.PermissionConsumerUpdateOneWithoutConsumer_accountNestedInput
account_allocation?: Prisma.LicenseAccountAllocationUpdateOneWithoutAccountNestedInput
account_device?: Prisma.ConsumerAccountDeviceUpdateOneWithoutConsumer_accountNestedInput
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput
}
export type ConsumerAccountUncheckedUpdateWithoutConsumer_account_good_favoritesInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
role?: Prisma.EnumConsumerRoleFieldUpdateOperationsInput | $Enums.ConsumerRole
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
consumer_id?: Prisma.StringFieldUpdateOperationsInput | string
account_id?: Prisma.StringFieldUpdateOperationsInput | string
pos?: Prisma.PosUncheckedUpdateOneWithoutAccountNestedInput
permission?: Prisma.PermissionConsumerUncheckedUpdateOneWithoutConsumer_accountNestedInput
account_allocation?: Prisma.LicenseAccountAllocationUncheckedUpdateOneWithoutAccountNestedInput
account_device?: Prisma.ConsumerAccountDeviceUncheckedUpdateOneWithoutConsumer_accountNestedInput
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput
}
export type ConsumerAccountCreateWithoutSales_invoicesInput = {
@@ -958,6 +1073,7 @@ export type ConsumerAccountCreateWithoutSales_invoicesInput = {
permission?: Prisma.PermissionConsumerCreateNestedOneWithoutConsumer_accountInput
account_allocation?: Prisma.LicenseAccountAllocationCreateNestedOneWithoutAccountInput
account_device?: Prisma.ConsumerAccountDeviceCreateNestedOneWithoutConsumer_accountInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteCreateNestedManyWithoutConsumer_accountInput
}
export type ConsumerAccountUncheckedCreateWithoutSales_invoicesInput = {
@@ -971,6 +1087,7 @@ export type ConsumerAccountUncheckedCreateWithoutSales_invoicesInput = {
permission?: Prisma.PermissionConsumerUncheckedCreateNestedOneWithoutConsumer_accountInput
account_allocation?: Prisma.LicenseAccountAllocationUncheckedCreateNestedOneWithoutAccountInput
account_device?: Prisma.ConsumerAccountDeviceUncheckedCreateNestedOneWithoutConsumer_accountInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedCreateNestedManyWithoutConsumer_accountInput
}
export type ConsumerAccountCreateOrConnectWithoutSales_invoicesInput = {
@@ -1000,6 +1117,7 @@ export type ConsumerAccountUpdateWithoutSales_invoicesInput = {
permission?: Prisma.PermissionConsumerUpdateOneWithoutConsumer_accountNestedInput
account_allocation?: Prisma.LicenseAccountAllocationUpdateOneWithoutAccountNestedInput
account_device?: Prisma.ConsumerAccountDeviceUpdateOneWithoutConsumer_accountNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUpdateManyWithoutConsumer_accountNestedInput
}
export type ConsumerAccountUncheckedUpdateWithoutSales_invoicesInput = {
@@ -1013,6 +1131,7 @@ export type ConsumerAccountUncheckedUpdateWithoutSales_invoicesInput = {
permission?: Prisma.PermissionConsumerUncheckedUpdateOneWithoutConsumer_accountNestedInput
account_allocation?: Prisma.LicenseAccountAllocationUncheckedUpdateOneWithoutAccountNestedInput
account_device?: Prisma.ConsumerAccountDeviceUncheckedUpdateOneWithoutConsumer_accountNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedUpdateManyWithoutConsumer_accountNestedInput
}
export type ConsumerAccountCreateManyConsumerInput = {
@@ -1032,8 +1151,9 @@ export type ConsumerAccountUpdateWithoutConsumerInput = {
pos?: Prisma.PosUpdateOneWithoutAccountNestedInput
permission?: Prisma.PermissionConsumerUpdateOneWithoutConsumer_accountNestedInput
account_allocation?: Prisma.LicenseAccountAllocationUpdateOneWithoutAccountNestedInput
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput
account_device?: Prisma.ConsumerAccountDeviceUpdateOneWithoutConsumer_accountNestedInput
sales_invoices?: Prisma.SalesInvoiceUpdateManyWithoutConsumer_accountNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUpdateManyWithoutConsumer_accountNestedInput
}
export type ConsumerAccountUncheckedUpdateWithoutConsumerInput = {
@@ -1045,8 +1165,9 @@ export type ConsumerAccountUncheckedUpdateWithoutConsumerInput = {
pos?: Prisma.PosUncheckedUpdateOneWithoutAccountNestedInput
permission?: Prisma.PermissionConsumerUncheckedUpdateOneWithoutConsumer_accountNestedInput
account_allocation?: Prisma.LicenseAccountAllocationUncheckedUpdateOneWithoutAccountNestedInput
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput
account_device?: Prisma.ConsumerAccountDeviceUncheckedUpdateOneWithoutConsumer_accountNestedInput
sales_invoices?: Prisma.SalesInvoiceUncheckedUpdateManyWithoutConsumer_accountNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedUpdateManyWithoutConsumer_accountNestedInput
}
export type ConsumerAccountUncheckedUpdateManyWithoutConsumerInput = {
@@ -1064,10 +1185,12 @@ export type ConsumerAccountUncheckedUpdateManyWithoutConsumerInput = {
export type ConsumerAccountCountOutputType = {
sales_invoices: number
consumer_account_good_favorites: number
}
export type ConsumerAccountCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
sales_invoices?: boolean | ConsumerAccountCountOutputTypeCountSales_invoicesArgs
consumer_account_good_favorites?: boolean | ConsumerAccountCountOutputTypeCountConsumer_account_good_favoritesArgs
}
/**
@@ -1087,6 +1210,13 @@ export type ConsumerAccountCountOutputTypeCountSales_invoicesArgs<ExtArgs extend
where?: Prisma.SalesInvoiceWhereInput
}
/**
* ConsumerAccountCountOutputType without action
*/
export type ConsumerAccountCountOutputTypeCountConsumer_account_good_favoritesArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
where?: Prisma.ConsumerAccountGoodFavoriteWhereInput
}
export type ConsumerAccountSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean
@@ -1100,8 +1230,9 @@ export type ConsumerAccountSelect<ExtArgs extends runtime.Types.Extensions.Inter
pos?: boolean | Prisma.ConsumerAccount$posArgs<ExtArgs>
permission?: boolean | Prisma.ConsumerAccount$permissionArgs<ExtArgs>
account_allocation?: boolean | Prisma.ConsumerAccount$account_allocationArgs<ExtArgs>
sales_invoices?: boolean | Prisma.ConsumerAccount$sales_invoicesArgs<ExtArgs>
account_device?: boolean | Prisma.ConsumerAccount$account_deviceArgs<ExtArgs>
sales_invoices?: boolean | Prisma.ConsumerAccount$sales_invoicesArgs<ExtArgs>
consumer_account_good_favorites?: boolean | Prisma.ConsumerAccount$consumer_account_good_favoritesArgs<ExtArgs>
_count?: boolean | Prisma.ConsumerAccountCountOutputTypeDefaultArgs<ExtArgs>
}, ExtArgs["result"]["consumerAccount"]>
@@ -1123,8 +1254,9 @@ export type ConsumerAccountInclude<ExtArgs extends runtime.Types.Extensions.Inte
pos?: boolean | Prisma.ConsumerAccount$posArgs<ExtArgs>
permission?: boolean | Prisma.ConsumerAccount$permissionArgs<ExtArgs>
account_allocation?: boolean | Prisma.ConsumerAccount$account_allocationArgs<ExtArgs>
sales_invoices?: boolean | Prisma.ConsumerAccount$sales_invoicesArgs<ExtArgs>
account_device?: boolean | Prisma.ConsumerAccount$account_deviceArgs<ExtArgs>
sales_invoices?: boolean | Prisma.ConsumerAccount$sales_invoicesArgs<ExtArgs>
consumer_account_good_favorites?: boolean | Prisma.ConsumerAccount$consumer_account_good_favoritesArgs<ExtArgs>
_count?: boolean | Prisma.ConsumerAccountCountOutputTypeDefaultArgs<ExtArgs>
}
@@ -1136,8 +1268,9 @@ export type $ConsumerAccountPayload<ExtArgs extends runtime.Types.Extensions.Int
pos: Prisma.$PosPayload<ExtArgs> | null
permission: Prisma.$PermissionConsumerPayload<ExtArgs> | null
account_allocation: Prisma.$LicenseAccountAllocationPayload<ExtArgs> | null
sales_invoices: Prisma.$SalesInvoicePayload<ExtArgs>[]
account_device: Prisma.$ConsumerAccountDevicePayload<ExtArgs> | null
sales_invoices: Prisma.$SalesInvoicePayload<ExtArgs>[]
consumer_account_good_favorites: Prisma.$ConsumerAccountGoodFavoritePayload<ExtArgs>[]
}
scalars: runtime.Types.Extensions.GetPayloadResult<{
id: string
@@ -1491,8 +1624,9 @@ export interface Prisma__ConsumerAccountClient<T, Null = never, ExtArgs extends
pos<T extends Prisma.ConsumerAccount$posArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.ConsumerAccount$posArgs<ExtArgs>>): Prisma.Prisma__PosClient<runtime.Types.Result.GetResult<Prisma.$PosPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
permission<T extends Prisma.ConsumerAccount$permissionArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.ConsumerAccount$permissionArgs<ExtArgs>>): Prisma.Prisma__PermissionConsumerClient<runtime.Types.Result.GetResult<Prisma.$PermissionConsumerPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
account_allocation<T extends Prisma.ConsumerAccount$account_allocationArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.ConsumerAccount$account_allocationArgs<ExtArgs>>): Prisma.Prisma__LicenseAccountAllocationClient<runtime.Types.Result.GetResult<Prisma.$LicenseAccountAllocationPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
sales_invoices<T extends Prisma.ConsumerAccount$sales_invoicesArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.ConsumerAccount$sales_invoicesArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$SalesInvoicePayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
account_device<T extends Prisma.ConsumerAccount$account_deviceArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.ConsumerAccount$account_deviceArgs<ExtArgs>>): Prisma.Prisma__ConsumerAccountDeviceClient<runtime.Types.Result.GetResult<Prisma.$ConsumerAccountDevicePayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
sales_invoices<T extends Prisma.ConsumerAccount$sales_invoicesArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.ConsumerAccount$sales_invoicesArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$SalesInvoicePayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
consumer_account_good_favorites<T extends Prisma.ConsumerAccount$consumer_account_good_favoritesArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.ConsumerAccount$consumer_account_good_favoritesArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$ConsumerAccountGoodFavoritePayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
@@ -1932,6 +2066,25 @@ export type ConsumerAccount$account_allocationArgs<ExtArgs extends runtime.Types
where?: Prisma.LicenseAccountAllocationWhereInput
}
/**
* ConsumerAccount.account_device
*/
export type ConsumerAccount$account_deviceArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
/**
* Select specific fields to fetch from the ConsumerAccountDevice
*/
select?: Prisma.ConsumerAccountDeviceSelect<ExtArgs> | null
/**
* Omit specific fields from the ConsumerAccountDevice
*/
omit?: Prisma.ConsumerAccountDeviceOmit<ExtArgs> | null
/**
* Choose, which related nodes to fetch as well
*/
include?: Prisma.ConsumerAccountDeviceInclude<ExtArgs> | null
where?: Prisma.ConsumerAccountDeviceWhereInput
}
/**
* ConsumerAccount.sales_invoices
*/
@@ -1957,22 +2110,27 @@ export type ConsumerAccount$sales_invoicesArgs<ExtArgs extends runtime.Types.Ext
}
/**
* ConsumerAccount.account_device
* ConsumerAccount.consumer_account_good_favorites
*/
export type ConsumerAccount$account_deviceArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
export type ConsumerAccount$consumer_account_good_favoritesArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
/**
* Select specific fields to fetch from the ConsumerAccountDevice
* Select specific fields to fetch from the ConsumerAccountGoodFavorite
*/
select?: Prisma.ConsumerAccountDeviceSelect<ExtArgs> | null
select?: Prisma.ConsumerAccountGoodFavoriteSelect<ExtArgs> | null
/**
* Omit specific fields from the ConsumerAccountDevice
* Omit specific fields from the ConsumerAccountGoodFavorite
*/
omit?: Prisma.ConsumerAccountDeviceOmit<ExtArgs> | null
omit?: Prisma.ConsumerAccountGoodFavoriteOmit<ExtArgs> | null
/**
* Choose, which related nodes to fetch as well
*/
include?: Prisma.ConsumerAccountDeviceInclude<ExtArgs> | null
where?: Prisma.ConsumerAccountDeviceWhereInput
include?: Prisma.ConsumerAccountGoodFavoriteInclude<ExtArgs> | null
where?: Prisma.ConsumerAccountGoodFavoriteWhereInput
orderBy?: Prisma.ConsumerAccountGoodFavoriteOrderByWithRelationInput | Prisma.ConsumerAccountGoodFavoriteOrderByWithRelationInput[]
cursor?: Prisma.ConsumerAccountGoodFavoriteWhereUniqueInput
take?: number
skip?: number
distinct?: Prisma.ConsumerAccountGoodFavoriteScalarFieldEnum | Prisma.ConsumerAccountGoodFavoriteScalarFieldEnum[]
}
/**
File diff suppressed because it is too large Load Diff
+179 -5
View File
@@ -309,6 +309,7 @@ export type GoodWhereInput = {
category?: Prisma.XOR<Prisma.GoodCategoryNullableScalarRelationFilter, Prisma.GoodCategoryWhereInput> | null
business_activity?: Prisma.XOR<Prisma.BusinessActivityNullableScalarRelationFilter, Prisma.BusinessActivityWhereInput> | null
sales_invoice_items?: Prisma.SalesInvoiceItemListRelationFilter
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteListRelationFilter
}
export type GoodOrderByWithRelationInput = {
@@ -333,6 +334,7 @@ export type GoodOrderByWithRelationInput = {
category?: Prisma.GoodCategoryOrderByWithRelationInput
business_activity?: Prisma.BusinessActivityOrderByWithRelationInput
sales_invoice_items?: Prisma.SalesInvoiceItemOrderByRelationAggregateInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteOrderByRelationAggregateInput
_relevance?: Prisma.GoodOrderByRelevanceInput
}
@@ -361,6 +363,7 @@ export type GoodWhereUniqueInput = Prisma.AtLeast<{
category?: Prisma.XOR<Prisma.GoodCategoryNullableScalarRelationFilter, Prisma.GoodCategoryWhereInput> | null
business_activity?: Prisma.XOR<Prisma.BusinessActivityNullableScalarRelationFilter, Prisma.BusinessActivityWhereInput> | null
sales_invoice_items?: Prisma.SalesInvoiceItemListRelationFilter
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteListRelationFilter
}, "id" | "local_sku" | "barcode">
export type GoodOrderByWithAggregationInput = {
@@ -427,6 +430,7 @@ export type GoodCreateInput = {
category?: Prisma.GoodCategoryCreateNestedOneWithoutGoodsInput
business_activity?: Prisma.BusinessActivityCreateNestedOneWithoutGoodsInput
sales_invoice_items?: Prisma.SalesInvoiceItemCreateNestedManyWithoutGoodInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteCreateNestedManyWithoutGoodInput
}
export type GoodUncheckedCreateInput = {
@@ -447,6 +451,7 @@ export type GoodUncheckedCreateInput = {
category_id?: string | null
business_activity_id?: string | null
sales_invoice_items?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutGoodInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedCreateNestedManyWithoutGoodInput
}
export type GoodUpdateInput = {
@@ -467,6 +472,7 @@ export type GoodUpdateInput = {
category?: Prisma.GoodCategoryUpdateOneWithoutGoodsNestedInput
business_activity?: Prisma.BusinessActivityUpdateOneWithoutGoodsNestedInput
sales_invoice_items?: Prisma.SalesInvoiceItemUpdateManyWithoutGoodNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUpdateManyWithoutGoodNestedInput
}
export type GoodUncheckedUpdateInput = {
@@ -487,6 +493,7 @@ export type GoodUncheckedUpdateInput = {
category_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
business_activity_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
sales_invoice_items?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutGoodNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedUpdateManyWithoutGoodNestedInput
}
export type GoodCreateManyInput = {
@@ -552,6 +559,11 @@ export type GoodOrderByRelationAggregateInput = {
_count?: Prisma.SortOrder
}
export type GoodScalarRelationFilter = {
is?: Prisma.GoodWhereInput
isNot?: Prisma.GoodWhereInput
}
export type GoodOrderByRelevanceInput = {
fields: Prisma.GoodOrderByRelevanceFieldEnum | Prisma.GoodOrderByRelevanceFieldEnum[]
sort: Prisma.SortOrder
@@ -623,11 +635,6 @@ export type GoodSumOrderByAggregateInput = {
base_sale_price?: Prisma.SortOrder
}
export type GoodScalarRelationFilter = {
is?: Prisma.GoodWhereInput
isNot?: Prisma.GoodWhereInput
}
export type GoodCreateNestedManyWithoutBusiness_activityInput = {
create?: Prisma.XOR<Prisma.GoodCreateWithoutBusiness_activityInput, Prisma.GoodUncheckedCreateWithoutBusiness_activityInput> | Prisma.GoodCreateWithoutBusiness_activityInput[] | Prisma.GoodUncheckedCreateWithoutBusiness_activityInput[]
connectOrCreate?: Prisma.GoodCreateOrConnectWithoutBusiness_activityInput | Prisma.GoodCreateOrConnectWithoutBusiness_activityInput[]
@@ -670,6 +677,20 @@ export type GoodUncheckedUpdateManyWithoutBusiness_activityNestedInput = {
deleteMany?: Prisma.GoodScalarWhereInput | Prisma.GoodScalarWhereInput[]
}
export type GoodCreateNestedOneWithoutConsumer_account_good_favoritesInput = {
create?: Prisma.XOR<Prisma.GoodCreateWithoutConsumer_account_good_favoritesInput, Prisma.GoodUncheckedCreateWithoutConsumer_account_good_favoritesInput>
connectOrCreate?: Prisma.GoodCreateOrConnectWithoutConsumer_account_good_favoritesInput
connect?: Prisma.GoodWhereUniqueInput
}
export type GoodUpdateOneRequiredWithoutConsumer_account_good_favoritesNestedInput = {
create?: Prisma.XOR<Prisma.GoodCreateWithoutConsumer_account_good_favoritesInput, Prisma.GoodUncheckedCreateWithoutConsumer_account_good_favoritesInput>
connectOrCreate?: Prisma.GoodCreateOrConnectWithoutConsumer_account_good_favoritesInput
upsert?: Prisma.GoodUpsertWithoutConsumer_account_good_favoritesInput
connect?: Prisma.GoodWhereUniqueInput
update?: Prisma.XOR<Prisma.XOR<Prisma.GoodUpdateToOneWithWhereWithoutConsumer_account_good_favoritesInput, Prisma.GoodUpdateWithoutConsumer_account_good_favoritesInput>, Prisma.GoodUncheckedUpdateWithoutConsumer_account_good_favoritesInput>
}
export type EnumGoodPricingModelFieldUpdateOperationsInput = {
set?: $Enums.GoodPricingModel
}
@@ -843,6 +864,7 @@ export type GoodCreateWithoutBusiness_activityInput = {
measure_unit: Prisma.MeasureUnitsCreateNestedOneWithoutGoodsInput
category?: Prisma.GoodCategoryCreateNestedOneWithoutGoodsInput
sales_invoice_items?: Prisma.SalesInvoiceItemCreateNestedManyWithoutGoodInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteCreateNestedManyWithoutGoodInput
}
export type GoodUncheckedCreateWithoutBusiness_activityInput = {
@@ -862,6 +884,7 @@ export type GoodUncheckedCreateWithoutBusiness_activityInput = {
measure_unit_id: string
category_id?: string | null
sales_invoice_items?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutGoodInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedCreateNestedManyWithoutGoodInput
}
export type GoodCreateOrConnectWithoutBusiness_activityInput = {
@@ -912,6 +935,102 @@ export type GoodScalarWhereInput = {
business_activity_id?: Prisma.StringNullableFilter<"Good"> | string | null
}
export type GoodCreateWithoutConsumer_account_good_favoritesInput = {
id?: string
name: string
is_default_guild_good?: boolean
pricing_model: $Enums.GoodPricingModel
description?: string | null
local_sku?: string | null
barcode?: string | null
base_sale_price?: runtime.Decimal | runtime.DecimalJsLike | number | string | null
image_url?: string | null
created_at?: Date | string
updated_at?: Date | string
deleted_at?: Date | string | null
sku: Prisma.StockKeepingUnitsCreateNestedOneWithoutGoodsInput
measure_unit: Prisma.MeasureUnitsCreateNestedOneWithoutGoodsInput
category?: Prisma.GoodCategoryCreateNestedOneWithoutGoodsInput
business_activity?: Prisma.BusinessActivityCreateNestedOneWithoutGoodsInput
sales_invoice_items?: Prisma.SalesInvoiceItemCreateNestedManyWithoutGoodInput
}
export type GoodUncheckedCreateWithoutConsumer_account_good_favoritesInput = {
id?: string
name: string
is_default_guild_good?: boolean
pricing_model: $Enums.GoodPricingModel
description?: string | null
local_sku?: string | null
barcode?: string | null
base_sale_price?: runtime.Decimal | runtime.DecimalJsLike | number | string | null
image_url?: string | null
created_at?: Date | string
updated_at?: Date | string
deleted_at?: Date | string | null
sku_id: string
measure_unit_id: string
category_id?: string | null
business_activity_id?: string | null
sales_invoice_items?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutGoodInput
}
export type GoodCreateOrConnectWithoutConsumer_account_good_favoritesInput = {
where: Prisma.GoodWhereUniqueInput
create: Prisma.XOR<Prisma.GoodCreateWithoutConsumer_account_good_favoritesInput, Prisma.GoodUncheckedCreateWithoutConsumer_account_good_favoritesInput>
}
export type GoodUpsertWithoutConsumer_account_good_favoritesInput = {
update: Prisma.XOR<Prisma.GoodUpdateWithoutConsumer_account_good_favoritesInput, Prisma.GoodUncheckedUpdateWithoutConsumer_account_good_favoritesInput>
create: Prisma.XOR<Prisma.GoodCreateWithoutConsumer_account_good_favoritesInput, Prisma.GoodUncheckedCreateWithoutConsumer_account_good_favoritesInput>
where?: Prisma.GoodWhereInput
}
export type GoodUpdateToOneWithWhereWithoutConsumer_account_good_favoritesInput = {
where?: Prisma.GoodWhereInput
data: Prisma.XOR<Prisma.GoodUpdateWithoutConsumer_account_good_favoritesInput, Prisma.GoodUncheckedUpdateWithoutConsumer_account_good_favoritesInput>
}
export type GoodUpdateWithoutConsumer_account_good_favoritesInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
name?: Prisma.StringFieldUpdateOperationsInput | string
is_default_guild_good?: Prisma.BoolFieldUpdateOperationsInput | boolean
pricing_model?: Prisma.EnumGoodPricingModelFieldUpdateOperationsInput | $Enums.GoodPricingModel
description?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
local_sku?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
barcode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
base_sale_price?: Prisma.NullableDecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string | null
image_url?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
deleted_at?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
sku?: Prisma.StockKeepingUnitsUpdateOneRequiredWithoutGoodsNestedInput
measure_unit?: Prisma.MeasureUnitsUpdateOneRequiredWithoutGoodsNestedInput
category?: Prisma.GoodCategoryUpdateOneWithoutGoodsNestedInput
business_activity?: Prisma.BusinessActivityUpdateOneWithoutGoodsNestedInput
sales_invoice_items?: Prisma.SalesInvoiceItemUpdateManyWithoutGoodNestedInput
}
export type GoodUncheckedUpdateWithoutConsumer_account_good_favoritesInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string
name?: Prisma.StringFieldUpdateOperationsInput | string
is_default_guild_good?: Prisma.BoolFieldUpdateOperationsInput | boolean
pricing_model?: Prisma.EnumGoodPricingModelFieldUpdateOperationsInput | $Enums.GoodPricingModel
description?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
local_sku?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
barcode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
base_sale_price?: Prisma.NullableDecimalFieldUpdateOperationsInput | runtime.Decimal | runtime.DecimalJsLike | number | string | null
image_url?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
created_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
updated_at?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
deleted_at?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
sku_id?: Prisma.StringFieldUpdateOperationsInput | string
measure_unit_id?: Prisma.StringFieldUpdateOperationsInput | string
category_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
business_activity_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
sales_invoice_items?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutGoodNestedInput
}
export type GoodCreateWithoutCategoryInput = {
id?: string
name: string
@@ -929,6 +1048,7 @@ export type GoodCreateWithoutCategoryInput = {
measure_unit: Prisma.MeasureUnitsCreateNestedOneWithoutGoodsInput
business_activity?: Prisma.BusinessActivityCreateNestedOneWithoutGoodsInput
sales_invoice_items?: Prisma.SalesInvoiceItemCreateNestedManyWithoutGoodInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteCreateNestedManyWithoutGoodInput
}
export type GoodUncheckedCreateWithoutCategoryInput = {
@@ -948,6 +1068,7 @@ export type GoodUncheckedCreateWithoutCategoryInput = {
measure_unit_id: string
business_activity_id?: string | null
sales_invoice_items?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutGoodInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedCreateNestedManyWithoutGoodInput
}
export type GoodCreateOrConnectWithoutCategoryInput = {
@@ -993,6 +1114,7 @@ export type GoodCreateWithoutMeasure_unitInput = {
category?: Prisma.GoodCategoryCreateNestedOneWithoutGoodsInput
business_activity?: Prisma.BusinessActivityCreateNestedOneWithoutGoodsInput
sales_invoice_items?: Prisma.SalesInvoiceItemCreateNestedManyWithoutGoodInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteCreateNestedManyWithoutGoodInput
}
export type GoodUncheckedCreateWithoutMeasure_unitInput = {
@@ -1012,6 +1134,7 @@ export type GoodUncheckedCreateWithoutMeasure_unitInput = {
category_id?: string | null
business_activity_id?: string | null
sales_invoice_items?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutGoodInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedCreateNestedManyWithoutGoodInput
}
export type GoodCreateOrConnectWithoutMeasure_unitInput = {
@@ -1057,6 +1180,7 @@ export type GoodCreateWithoutSkuInput = {
category?: Prisma.GoodCategoryCreateNestedOneWithoutGoodsInput
business_activity?: Prisma.BusinessActivityCreateNestedOneWithoutGoodsInput
sales_invoice_items?: Prisma.SalesInvoiceItemCreateNestedManyWithoutGoodInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteCreateNestedManyWithoutGoodInput
}
export type GoodUncheckedCreateWithoutSkuInput = {
@@ -1076,6 +1200,7 @@ export type GoodUncheckedCreateWithoutSkuInput = {
category_id?: string | null
business_activity_id?: string | null
sales_invoice_items?: Prisma.SalesInvoiceItemUncheckedCreateNestedManyWithoutGoodInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedCreateNestedManyWithoutGoodInput
}
export type GoodCreateOrConnectWithoutSkuInput = {
@@ -1121,6 +1246,7 @@ export type GoodCreateWithoutSales_invoice_itemsInput = {
measure_unit: Prisma.MeasureUnitsCreateNestedOneWithoutGoodsInput
category?: Prisma.GoodCategoryCreateNestedOneWithoutGoodsInput
business_activity?: Prisma.BusinessActivityCreateNestedOneWithoutGoodsInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteCreateNestedManyWithoutGoodInput
}
export type GoodUncheckedCreateWithoutSales_invoice_itemsInput = {
@@ -1140,6 +1266,7 @@ export type GoodUncheckedCreateWithoutSales_invoice_itemsInput = {
measure_unit_id: string
category_id?: string | null
business_activity_id?: string | null
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedCreateNestedManyWithoutGoodInput
}
export type GoodCreateOrConnectWithoutSales_invoice_itemsInput = {
@@ -1175,6 +1302,7 @@ export type GoodUpdateWithoutSales_invoice_itemsInput = {
measure_unit?: Prisma.MeasureUnitsUpdateOneRequiredWithoutGoodsNestedInput
category?: Prisma.GoodCategoryUpdateOneWithoutGoodsNestedInput
business_activity?: Prisma.BusinessActivityUpdateOneWithoutGoodsNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUpdateManyWithoutGoodNestedInput
}
export type GoodUncheckedUpdateWithoutSales_invoice_itemsInput = {
@@ -1194,6 +1322,7 @@ export type GoodUncheckedUpdateWithoutSales_invoice_itemsInput = {
measure_unit_id?: Prisma.StringFieldUpdateOperationsInput | string
category_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
business_activity_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedUpdateManyWithoutGoodNestedInput
}
export type GoodCreateManyBusiness_activityInput = {
@@ -1231,6 +1360,7 @@ export type GoodUpdateWithoutBusiness_activityInput = {
measure_unit?: Prisma.MeasureUnitsUpdateOneRequiredWithoutGoodsNestedInput
category?: Prisma.GoodCategoryUpdateOneWithoutGoodsNestedInput
sales_invoice_items?: Prisma.SalesInvoiceItemUpdateManyWithoutGoodNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUpdateManyWithoutGoodNestedInput
}
export type GoodUncheckedUpdateWithoutBusiness_activityInput = {
@@ -1250,6 +1380,7 @@ export type GoodUncheckedUpdateWithoutBusiness_activityInput = {
measure_unit_id?: Prisma.StringFieldUpdateOperationsInput | string
category_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
sales_invoice_items?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutGoodNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedUpdateManyWithoutGoodNestedInput
}
export type GoodUncheckedUpdateManyWithoutBusiness_activityInput = {
@@ -1305,6 +1436,7 @@ export type GoodUpdateWithoutCategoryInput = {
measure_unit?: Prisma.MeasureUnitsUpdateOneRequiredWithoutGoodsNestedInput
business_activity?: Prisma.BusinessActivityUpdateOneWithoutGoodsNestedInput
sales_invoice_items?: Prisma.SalesInvoiceItemUpdateManyWithoutGoodNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUpdateManyWithoutGoodNestedInput
}
export type GoodUncheckedUpdateWithoutCategoryInput = {
@@ -1324,6 +1456,7 @@ export type GoodUncheckedUpdateWithoutCategoryInput = {
measure_unit_id?: Prisma.StringFieldUpdateOperationsInput | string
business_activity_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
sales_invoice_items?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutGoodNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedUpdateManyWithoutGoodNestedInput
}
export type GoodUncheckedUpdateManyWithoutCategoryInput = {
@@ -1379,6 +1512,7 @@ export type GoodUpdateWithoutMeasure_unitInput = {
category?: Prisma.GoodCategoryUpdateOneWithoutGoodsNestedInput
business_activity?: Prisma.BusinessActivityUpdateOneWithoutGoodsNestedInput
sales_invoice_items?: Prisma.SalesInvoiceItemUpdateManyWithoutGoodNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUpdateManyWithoutGoodNestedInput
}
export type GoodUncheckedUpdateWithoutMeasure_unitInput = {
@@ -1398,6 +1532,7 @@ export type GoodUncheckedUpdateWithoutMeasure_unitInput = {
category_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
business_activity_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
sales_invoice_items?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutGoodNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedUpdateManyWithoutGoodNestedInput
}
export type GoodUncheckedUpdateManyWithoutMeasure_unitInput = {
@@ -1453,6 +1588,7 @@ export type GoodUpdateWithoutSkuInput = {
category?: Prisma.GoodCategoryUpdateOneWithoutGoodsNestedInput
business_activity?: Prisma.BusinessActivityUpdateOneWithoutGoodsNestedInput
sales_invoice_items?: Prisma.SalesInvoiceItemUpdateManyWithoutGoodNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUpdateManyWithoutGoodNestedInput
}
export type GoodUncheckedUpdateWithoutSkuInput = {
@@ -1472,6 +1608,7 @@ export type GoodUncheckedUpdateWithoutSkuInput = {
category_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
business_activity_id?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
sales_invoice_items?: Prisma.SalesInvoiceItemUncheckedUpdateManyWithoutGoodNestedInput
consumer_account_good_favorites?: Prisma.ConsumerAccountGoodFavoriteUncheckedUpdateManyWithoutGoodNestedInput
}
export type GoodUncheckedUpdateManyWithoutSkuInput = {
@@ -1499,10 +1636,12 @@ export type GoodUncheckedUpdateManyWithoutSkuInput = {
export type GoodCountOutputType = {
sales_invoice_items: number
consumer_account_good_favorites: number
}
export type GoodCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
sales_invoice_items?: boolean | GoodCountOutputTypeCountSales_invoice_itemsArgs
consumer_account_good_favorites?: boolean | GoodCountOutputTypeCountConsumer_account_good_favoritesArgs
}
/**
@@ -1522,6 +1661,13 @@ export type GoodCountOutputTypeCountSales_invoice_itemsArgs<ExtArgs extends runt
where?: Prisma.SalesInvoiceItemWhereInput
}
/**
* GoodCountOutputType without action
*/
export type GoodCountOutputTypeCountConsumer_account_good_favoritesArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
where?: Prisma.ConsumerAccountGoodFavoriteWhereInput
}
export type GoodSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean
@@ -1545,6 +1691,7 @@ export type GoodSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = r
category?: boolean | Prisma.Good$categoryArgs<ExtArgs>
business_activity?: boolean | Prisma.Good$business_activityArgs<ExtArgs>
sales_invoice_items?: boolean | Prisma.Good$sales_invoice_itemsArgs<ExtArgs>
consumer_account_good_favorites?: boolean | Prisma.Good$consumer_account_good_favoritesArgs<ExtArgs>
_count?: boolean | Prisma.GoodCountOutputTypeDefaultArgs<ExtArgs>
}, ExtArgs["result"]["good"]>
@@ -1576,6 +1723,7 @@ export type GoodInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs =
category?: boolean | Prisma.Good$categoryArgs<ExtArgs>
business_activity?: boolean | Prisma.Good$business_activityArgs<ExtArgs>
sales_invoice_items?: boolean | Prisma.Good$sales_invoice_itemsArgs<ExtArgs>
consumer_account_good_favorites?: boolean | Prisma.Good$consumer_account_good_favoritesArgs<ExtArgs>
_count?: boolean | Prisma.GoodCountOutputTypeDefaultArgs<ExtArgs>
}
@@ -1587,6 +1735,7 @@ export type $GoodPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs =
category: Prisma.$GoodCategoryPayload<ExtArgs> | null
business_activity: Prisma.$BusinessActivityPayload<ExtArgs> | null
sales_invoice_items: Prisma.$SalesInvoiceItemPayload<ExtArgs>[]
consumer_account_good_favorites: Prisma.$ConsumerAccountGoodFavoritePayload<ExtArgs>[]
}
scalars: runtime.Types.Extensions.GetPayloadResult<{
id: string
@@ -1950,6 +2099,7 @@ export interface Prisma__GoodClient<T, Null = never, ExtArgs extends runtime.Typ
category<T extends Prisma.Good$categoryArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Good$categoryArgs<ExtArgs>>): Prisma.Prisma__GoodCategoryClient<runtime.Types.Result.GetResult<Prisma.$GoodCategoryPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
business_activity<T extends Prisma.Good$business_activityArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Good$business_activityArgs<ExtArgs>>): Prisma.Prisma__BusinessActivityClient<runtime.Types.Result.GetResult<Prisma.$BusinessActivityPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
sales_invoice_items<T extends Prisma.Good$sales_invoice_itemsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Good$sales_invoice_itemsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$SalesInvoiceItemPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
consumer_account_good_favorites<T extends Prisma.Good$consumer_account_good_favoritesArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Good$consumer_account_good_favoritesArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$ConsumerAccountGoodFavoritePayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
@@ -2404,6 +2554,30 @@ export type Good$sales_invoice_itemsArgs<ExtArgs extends runtime.Types.Extension
distinct?: Prisma.SalesInvoiceItemScalarFieldEnum | Prisma.SalesInvoiceItemScalarFieldEnum[]
}
/**
* Good.consumer_account_good_favorites
*/
export type Good$consumer_account_good_favoritesArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
/**
* Select specific fields to fetch from the ConsumerAccountGoodFavorite
*/
select?: Prisma.ConsumerAccountGoodFavoriteSelect<ExtArgs> | null
/**
* Omit specific fields from the ConsumerAccountGoodFavorite
*/
omit?: Prisma.ConsumerAccountGoodFavoriteOmit<ExtArgs> | null
/**
* Choose, which related nodes to fetch as well
*/
include?: Prisma.ConsumerAccountGoodFavoriteInclude<ExtArgs> | null
where?: Prisma.ConsumerAccountGoodFavoriteWhereInput
orderBy?: Prisma.ConsumerAccountGoodFavoriteOrderByWithRelationInput | Prisma.ConsumerAccountGoodFavoriteOrderByWithRelationInput[]
cursor?: Prisma.ConsumerAccountGoodFavoriteWhereUniqueInput
take?: number
skip?: number
distinct?: Prisma.ConsumerAccountGoodFavoriteScalarFieldEnum | Prisma.ConsumerAccountGoodFavoriteScalarFieldEnum[]
}
/**
* Good without action
*/
@@ -1,13 +1,16 @@
import { PasswordFieldValidator, UsernameFieldValidator } from '@/common/utils'
import { ApiProperty, PartialType } from '@nestjs/swagger'
import { IsEnum, IsOptional, IsString } from 'class-validator'
import { AccountStatus, ConsumerRole } from 'generated/prisma/enums'
export class CreateConsumerAccountDto {
@IsString()
@UsernameFieldValidator()
@ApiProperty({ required: true })
username: string
@IsString()
@PasswordFieldValidator()
@ApiProperty({ required: true })
password: string
@@ -14,6 +14,26 @@ export class AdminConsumersService {
type: true,
...QUERY_CONSTANTS.CONSUMER.infoSelect,
...QUERY_CONSTANTS.CONSUMER.activeBusinessCount,
individual: {
select: {
partner: {
select: {
id: true,
name: true,
},
},
},
},
legal: {
select: {
partner: {
select: {
id: true,
name: true,
},
},
},
},
status: true,
created_at: true,
}
@@ -1,3 +1,4 @@
import { PasswordFieldValidator, UsernameFieldValidator } from '@/common/utils'
import { ConsumerStatus } from '@/generated/prisma/enums'
import { ApiProperty, OmitType, PartialType } from '@nestjs/swagger'
import { IsEnum, IsOptional, IsString } from 'class-validator'
@@ -16,10 +17,12 @@ export class CreateConsumerDto {
last_name: string
@IsString()
@UsernameFieldValidator()
@ApiProperty({ required: true })
username: string
@IsString()
@PasswordFieldValidator()
@ApiProperty({ required: true })
password: string
@@ -0,0 +1,17 @@
import { RedisKeyMaker } from '@/common/utils/redisKeyMaker'
import { PosCacheInvalidationService } from '@/modules/pos/cache/pos-cache-invalidation.service'
import { RedisService } from '@/redis/redis.service'
import { Injectable } from '@nestjs/common'
@Injectable()
export class AdminGuildCacheInvalidationService {
constructor(
private readonly redisService: RedisService,
private readonly posCacheInvalidationService: PosCacheInvalidationService,
) {}
async invalidateGoodsList(guildId: string): Promise<void> {
await this.redisService.delete(RedisKeyMaker.guildGoodsList(guildId))
await this.posCacheInvalidationService.invalidateGoodsListByGuild(guildId)
}
}
@@ -1,5 +1,6 @@
import { GoodCategoryOmit } from '@/generated/prisma/models'
import { PrismaService } from '@/prisma/prisma.service'
import { AdminGuildCacheInvalidationService } from '@/modules/admin/guilds/cache/admin-guild-cache-invalidation.service'
import { Injectable } from '@nestjs/common'
import { ResponseMapper } from 'common/response/response-mapper'
import {
@@ -9,7 +10,10 @@ import {
@Injectable()
export class GoodCategoriesService {
constructor(private prisma: PrismaService) {}
constructor(
private prisma: PrismaService,
private readonly cacheInvalidationService: AdminGuildCacheInvalidationService,
) {}
private readonly goodCategoriesOmit = {
complex_id: true,
@@ -67,8 +71,8 @@ export class GoodCategoriesService {
})
}
create(guild_id: string, data: CreateGoodCategoryDto) {
const category = this.prisma.goodCategory.create({
async create(guild_id: string, data: CreateGoodCategoryDto) {
const category = await this.prisma.goodCategory.create({
data: {
guild: {
connect: {
@@ -83,6 +87,8 @@ export class GoodCategoriesService {
omit: this.goodCategoriesOmit,
})
await this.cacheInvalidationService.invalidateGoodsList(guild_id)
return ResponseMapper.create({ ...category, goods_count: 0 })
}
@@ -113,6 +119,8 @@ export class GoodCategoriesService {
omit: this.goodCategoriesOmit,
})
await this.cacheInvalidationService.invalidateGoodsList(guild_id)
return ResponseMapper.update({
...category,
goods_count: Number(category?._count.goods),
@@ -1,7 +1,10 @@
import { UploadedFileTypes } from '@/common/enums/enums'
import { RedisKeyMaker } from '@/common/utils/redisKeyMaker'
import { GoodSelect, GoodWhereInput } from '@/generated/prisma/models'
import { AdminGuildCacheInvalidationService } from '@/modules/admin/guilds/cache/admin-guild-cache-invalidation.service'
import { UploaderService } from '@/modules/uploader/uploader.service'
import { PrismaService } from '@/prisma/prisma.service'
import { RedisService } from '@/redis/redis.service'
import { Injectable } from '@nestjs/common'
import { ResponseMapper } from 'common/response/response-mapper'
import { CreateGuildGoodDto, UpdateGuildGoodDto } from './dto/create-good.dto'
@@ -11,8 +14,12 @@ export class GoodsService {
constructor(
private prisma: PrismaService,
private readonly uploaderService: UploaderService,
private readonly redisService: RedisService,
private readonly cacheInvalidationService: AdminGuildCacheInvalidationService,
) {}
private readonly listCacheTtlSeconds = 300
private readonly defaultSelect: GoodSelect = {
id: true,
name: true,
@@ -49,6 +56,14 @@ export class GoodsService {
})
async findAll(guildId: string) {
const cacheKey = RedisKeyMaker.guildGoodsList(guildId)
const cached = await this.redisService.getJson<{ goods: unknown[]; total: number }>(
cacheKey,
)
if (cached) {
return ResponseMapper.paginate(cached.goods, { total: cached.total })
}
const [goods, total] = await this.prisma.$transaction([
this.prisma.good.findMany({
where: this.defaultWhere(guildId),
@@ -56,6 +71,9 @@ export class GoodsService {
}),
this.prisma.good.count(),
])
await this.redisService.setJson(cacheKey, { goods, total }, this.listCacheTtlSeconds)
return ResponseMapper.paginate(goods, {
total,
})
@@ -75,6 +93,10 @@ export class GoodsService {
async create(data: CreateGuildGoodDto, file: Express.Multer.File) {
const { category_id, measure_unit_id, sku_id, ...rest } = data
const category = await this.prisma.goodCategory.findUnique({
where: { id: category_id },
select: { guild_id: true },
})
const good = await this.prisma.$transaction(async tx => {
let image_url = ''
@@ -111,11 +133,25 @@ export class GoodsService {
})
})
if (category?.guild_id) {
await this.cacheInvalidationService.invalidateGoodsList(category.guild_id)
}
return ResponseMapper.create(good)
}
async update(id: string, data: UpdateGuildGoodDto, file: Express.Multer.File) {
const { category_id, measure_unit_id, sku_id, ...rest } = data
const prevGood = await this.prisma.good.findUnique({
where: { id },
select: { category: { select: { guild_id: true } } },
})
const nextCategory = category_id
? await this.prisma.goodCategory.findUnique({
where: { id: category_id },
select: { guild_id: true },
})
: null
const good = await this.prisma.$transaction(async tx => {
let image_url = ''
@@ -162,6 +198,18 @@ export class GoodsService {
})
})
const cacheGuildIds = new Set<string>()
if (prevGood?.category?.guild_id) {
cacheGuildIds.add(prevGood.category.guild_id)
}
if (nextCategory?.guild_id) {
cacheGuildIds.add(nextCategory.guild_id)
}
for (const guildId of cacheGuildIds) {
await this.cacheInvalidationService.invalidateGoodsList(guildId)
}
return ResponseMapper.create(good)
}
}
@@ -1,4 +1,7 @@
import { RedisKeyMaker } from '@/common/utils/redisKeyMaker'
import { AdminGuildCacheInvalidationService } from '@/modules/admin/guilds/cache/admin-guild-cache-invalidation.service'
import { PrismaService } from '@/prisma/prisma.service'
import { RedisService } from '@/redis/redis.service'
import { Injectable } from '@nestjs/common'
import { ResponseMapper } from 'common/response/response-mapper'
import { CreateStockKeepingUnitDto } from './dto/create-stock-keeping-unit.dto'
@@ -6,7 +9,17 @@ import { UpdateStockKeepingUnitDto } from './dto/update-stock-keeping-unit.dto'
@Injectable()
export class StockKeepingUnitsService {
constructor(private readonly prisma: PrismaService) {}
constructor(
private readonly prisma: PrismaService,
private readonly redisService: RedisService,
private readonly cacheInvalidationService: AdminGuildCacheInvalidationService,
) {}
private readonly listCacheTtlSeconds = 300
private getListCacheKey(guild_id: string): string {
return RedisKeyMaker.guildStockKeepingUnitsList(guild_id)
}
private mapData(data: any) {
const { name, is_foreign, is_domestic, ...rest } = data
@@ -17,12 +30,19 @@ export class StockKeepingUnitsService {
}
async findAll(guild_id: string) {
const cacheKey = this.getListCacheKey(guild_id)
const cached = await this.redisService.getJson<unknown[]>(cacheKey)
if (cached) {
return ResponseMapper.list(cached)
}
const items = await this.prisma.stockKeepingUnits.findMany({
where: { guild_id },
orderBy: { created_at: 'desc' },
})
const mappedData = items.map(this.mapData)
await this.redisService.setJson(cacheKey, mappedData, this.listCacheTtlSeconds)
return ResponseMapper.list(mappedData)
}
@@ -39,6 +59,9 @@ export class StockKeepingUnitsService {
},
})
await this.redisService.delete(this.getListCacheKey(guild_id))
await this.cacheInvalidationService.invalidateGoodsList(guild_id)
const mappedData = this.mapData(item)
return ResponseMapper.create(mappedData)
}
@@ -48,6 +71,10 @@ export class StockKeepingUnitsService {
where: { guild_id, id },
data,
})
await this.redisService.delete(this.getListCacheKey(guild_id))
await this.cacheInvalidationService.invalidateGoodsList(guild_id)
return ResponseMapper.update(item)
}
}
@@ -1,15 +1,30 @@
import { QUERY_CONSTANTS } from '@/common/queryConstants'
import consumer_mappersUtil from '@/common/utils/mappers/consumer_mappers.util'
import { RedisKeyMaker } from '@/common/utils/redisKeyMaker'
import { LicenseActivationWhereInput } from '@/generated/prisma/models'
import { PartnersCacheInvalidationService } from '@/modules/partners/cache/partners-cache-invalidation.service'
import { PrismaService } from '@/prisma/prisma.service'
import { RedisService } from '@/redis/redis.service'
import { Injectable } from '@nestjs/common'
import { ResponseMapper } from 'common/response/response-mapper'
@Injectable()
export class PartnerActivatedLicensesService {
constructor(private readonly prisma: PrismaService) {}
constructor(
private readonly prisma: PrismaService,
private readonly redisService: RedisService,
private readonly cacheInvalidationService: PartnersCacheInvalidationService,
) {}
async findAll(partner_id: string, page = 1, perPage = 10) {
const cacheKey = RedisKeyMaker.partnerActivatedLicensesList(partner_id, page, perPage)
const cached = await this.redisService.getJson<{ data: unknown[]; total: number }>(
cacheKey,
)
if (cached) {
return ResponseMapper.paginate(cached.data, { page, perPage, total: cached.total })
}
const defaultWhere: LicenseActivationWhereInput = {
license: {
charge_transaction: {
@@ -73,6 +88,8 @@ export class PartnerActivatedLicensesService {
}
})
await this.redisService.setJson(cacheKey, { data: mappedLicenses, total }, 300)
return ResponseMapper.paginate(mappedLicenses, {
page,
perPage,
@@ -90,6 +107,7 @@ export class PartnerActivatedLicensesService {
async delete(partnerId: string, id: string) {
await this.prisma.license.delete({ where: { id } })
await this.cacheInvalidationService.invalidatePartnerLicenses(partnerId)
return ResponseMapper.delete()
}
}
@@ -1,3 +1,4 @@
import { RedisKeyMaker } from '@/common/utils/redisKeyMaker'
import {
generateTrackingCode,
isTrackingCodeUniqueViolation,
@@ -6,14 +7,20 @@ import {
LicenseChargeTransactionSelect,
LicenseChargeTransactionWhereInput,
} from '@/generated/prisma/models'
import { PartnersCacheInvalidationService } from '@/modules/partners/cache/partners-cache-invalidation.service'
import { PrismaService } from '@/prisma/prisma.service'
import { RedisService } from '@/redis/redis.service'
import { BadRequestException, Injectable } from '@nestjs/common'
import { ResponseMapper } from 'common/response/response-mapper'
import { ChargeLicenseDto } from './dto/chargedLicenseTransactions.dto'
@Injectable()
export class PartnerLicenseChargeTransactionService {
constructor(private readonly prisma: PrismaService) {}
constructor(
private readonly prisma: PrismaService,
private readonly redisService: RedisService,
private readonly cacheInvalidationService: PartnersCacheInvalidationService,
) {}
private readonly TRACKING_CODE_LENGTH = 8
private readonly TRACKING_CODE_MAX_ATTEMPTS = 5
@@ -53,6 +60,18 @@ export class PartnerLicenseChargeTransactionService {
}
async findAll(partner_id: string, page = 1, perPage = 10) {
const cacheKey = RedisKeyMaker.partnerLicenseChargeTransactionsList(
partner_id,
page,
perPage,
)
const cached = await this.redisService.getJson<{ data: unknown[]; total: number }>(
cacheKey,
)
if (cached) {
return ResponseMapper.paginate(cached.data, { page, perPage, total: cached.total })
}
const defaultWhere: LicenseChargeTransactionWhereInput = {
partner_id,
}
@@ -70,6 +89,7 @@ export class PartnerLicenseChargeTransactionService {
])
const mappedTransactions = transactions.map(this.mappedTransaction)
await this.redisService.setJson(cacheKey, { data: mappedTransactions, total }, 300)
return ResponseMapper.paginate(mappedTransactions, {
page,
@@ -79,6 +99,12 @@ export class PartnerLicenseChargeTransactionService {
}
async findOne(partner_id: string, id: string) {
const cacheKey = RedisKeyMaker.partnerLicenseChargeTransactionDetail(partner_id, id)
const cached = await this.redisService.getJson<unknown>(cacheKey)
if (cached) {
return ResponseMapper.single(cached)
}
const transaction = await this.prisma.licenseChargeTransaction.findUniqueOrThrow({
where: {
id,
@@ -86,7 +112,9 @@ export class PartnerLicenseChargeTransactionService {
},
select: this.defaultSelect,
})
return ResponseMapper.single(this.mappedTransaction(transaction))
const mappedTransaction = this.mappedTransaction(transaction)
await this.redisService.setJson(cacheKey, mappedTransaction, 300)
return ResponseMapper.single(mappedTransaction)
}
async create(partner_id: string, data: ChargeLicenseDto) {
@@ -134,6 +162,8 @@ export class PartnerLicenseChargeTransactionService {
})
this.scheduleLicenseProvisioning(transaction.id, transaction.purchased_count)
await this.cacheInvalidationService.invalidatePartnersList()
await this.cacheInvalidationService.invalidatePartnerLicenses(partner_id)
return ResponseMapper.create({
transaction_id: transaction.id,
charged_license_count: transaction.purchased_count,
@@ -1,3 +1,4 @@
import { PasswordFieldValidator, UsernameFieldValidator } from '@/common/utils'
import { PartnerStatus, TspProviderType } from '@/generated/prisma/enums'
import { ApiProperty, PartialType } from '@nestjs/swagger'
import { IsEnum, IsNumber, IsOptional, IsString } from 'class-validator'
@@ -21,10 +22,12 @@ export class CreatePartnerDto {
// license_quota?: number
@IsString()
@UsernameFieldValidator()
@ApiProperty({ required: true })
username: string
@IsString()
@PasswordFieldValidator()
@ApiProperty({ required: true })
password: string
@@ -1,3 +1,4 @@
import { PasswordFieldValidator, UsernameFieldValidator } from '@/common/utils'
import { ApiProperty, PartialType } from '@nestjs/swagger'
import { IsEnum, IsOptional, IsString } from 'class-validator'
import { PartnerRole } from 'generated/prisma/enums'
@@ -5,9 +6,11 @@ import { PartnerRole } from 'generated/prisma/enums'
export class CreatePartnerAccountDto {
@IsString()
@ApiProperty({})
@UsernameFieldValidator()
username: string
@IsString()
@PasswordFieldValidator()
@ApiProperty({})
password: string
}
+32 -1
View File
@@ -1,6 +1,7 @@
import { UploadedFileTypes } from '@/common/enums/enums'
import { translateEnumValue } from '@/common/utils'
import { PasswordUtil } from '@/common/utils/password.util'
import { RedisKeyMaker } from '@/common/utils/redisKeyMaker'
import {
AccountStatus,
AccountType,
@@ -8,8 +9,10 @@ import {
PartnerStatus,
} from '@/generated/prisma/enums'
import { PartnerSelect } from '@/generated/prisma/models'
import { PartnersCacheInvalidationService } from '@/modules/partners/cache/partners-cache-invalidation.service'
import { UploaderService } from '@/modules/uploader/uploader.service'
import { PrismaService } from '@/prisma/prisma.service'
import { RedisService } from '@/redis/redis.service'
import { Injectable } from '@nestjs/common'
import { ResponseMapper } from 'common/response/response-mapper'
import { CreatePartnerDto, UpdatePartnerDto } from './dto/partner.dto'
@@ -20,6 +23,8 @@ export class PartnersService {
constructor(
private readonly prisma: PrismaService,
private readonly uploaderService: UploaderService,
private readonly redisService: RedisService,
private readonly cacheInvalidationService: PartnersCacheInvalidationService,
) {}
private readonly defaultSelect: PartnerSelect = {
@@ -137,22 +142,40 @@ export class PartnersService {
}
async findAll() {
const cacheKey = RedisKeyMaker.partnersList()
const cached = await this.redisService.getJson<unknown[]>(cacheKey)
if (cached) {
console.log('cached', cached)
return ResponseMapper.list(cached)
}
const partners = await this.prisma.partner.findMany({
select: this.defaultSelect,
})
const mappedPartners = partners.map(this.mapPartner)
await this.redisService.setJson(cacheKey, mappedPartners, 300)
return ResponseMapper.list(mappedPartners)
}
async findOne(id: string) {
const cacheKey = RedisKeyMaker.partnerDetail(id)
const cached = await this.redisService.getJson<unknown>(cacheKey)
if (cached) {
return ResponseMapper.single(cached)
}
const partner = await this.prisma.partner.findUniqueOrThrow({
where: { id },
select: this.defaultSelect,
})
return ResponseMapper.single(this.mapPartner(partner))
const mappedPartner = this.mapPartner(partner)
await this.redisService.setJson(cacheKey, mappedPartner, 300)
return ResponseMapper.single(mappedPartner)
}
async create(data: CreatePartnerDto, logo?: any) {
@@ -184,6 +207,8 @@ export class PartnersService {
},
select: this.defaultSelect,
})
await this.cacheInvalidationService.invalidatePartnersList()
await this.cacheInvalidationService.invalidatePartnerDetail(partner.id)
return ResponseMapper.create(partner)
}
@@ -220,11 +245,17 @@ export class PartnersService {
})
})
await this.cacheInvalidationService.invalidatePartnersList()
await this.cacheInvalidationService.invalidatePartnerDetail(id)
return ResponseMapper.update(partner)
}
async delete(id: string) {
await this.prisma.partner.delete({ where: { id } })
await this.cacheInvalidationService.invalidatePartnersList()
await this.cacheInvalidationService.invalidatePartnerDetail(id)
await this.cacheInvalidationService.invalidatePartnerLicenses(id)
return ResponseMapper.delete()
}
}
@@ -1,13 +1,16 @@
import { PasswordFieldValidator, UsernameFieldValidator } from '@/common/utils'
import { ApiProperty, PartialType } from '@nestjs/swagger'
import { IsEnum, IsOptional, IsString } from 'class-validator'
import { AccountStatus, AccountType } from 'generated/prisma/enums'
export class CreateAccountDto {
@IsString()
@UsernameFieldValidator()
@ApiProperty()
username: string
@IsString()
@PasswordFieldValidator()
@ApiProperty()
password: string
+5 -2
View File
@@ -2,11 +2,14 @@ import { ApiProperty } from '@nestjs/swagger'
import { IsBoolean, IsOptional, IsString } from 'class-validator'
export class LoginDto {
@ApiProperty({ description: 'Mobile number used as username', example: '09120258156' })
@ApiProperty({
description: 'you can use your mobile number as username',
example: '09120258156',
})
@IsString()
username: string
@ApiProperty({ description: 'OTP password (one-time password)', example: '11111' })
@ApiProperty({ example: '11111' })
@IsString()
password: string
+6 -12
View File
@@ -52,20 +52,14 @@ export class CatalogsService {
async getSKU(search: string) {
const items = await this.prisma.stockKeepingUnits.findMany({
// where: {
// OR: [{ code: { contains: search } }, { name: { contains: search } }],
// },
select: {
id: true,
code: true,
name: true,
is_domestic: true,
is_public: true,
VAT: true,
},
take: 100,
})
return ResponseMapper.list(items)
const mappedItems = items.map(item => ({
...item,
fullname: `${item.code} - ${item.name}`,
}))
return ResponseMapper.list(mappedItems)
}
async getGuildGoodCategories(guild_id: string) {
@@ -1,13 +1,16 @@
import { PasswordFieldValidator, UsernameFieldValidator } from '@/common/utils'
import { ApiProperty, PartialType } from '@nestjs/swagger'
import { IsEnum, IsOptional, IsString } from 'class-validator'
import { AccountStatus } from 'generated/prisma/enums'
export class CreateConsumerAccountDto {
@IsString()
@UsernameFieldValidator()
@ApiProperty({ required: true })
username: string
@IsString()
@PasswordFieldValidator()
@ApiProperty({ required: true })
password: string
@@ -1,6 +1,8 @@
import { BusinessActivitiesQueryService } from '@/common/services/businessActivities/business-activities-query.service'
import { RedisKeyMaker } from '@/common/utils/redisKeyMaker'
import { BusinessActivitySelect } from '@/generated/prisma/models'
import { PrismaService } from '@/prisma/prisma.service'
import { RedisService } from '@/redis/redis.service'
import { Injectable } from '@nestjs/common'
import { ResponseMapper } from 'common/response/response-mapper'
@@ -10,6 +12,7 @@ export class BusinessActivitiesService {
constructor(
private readonly prisma: PrismaService,
private readonly businessActivitiesQueryService: BusinessActivitiesQueryService,
private readonly redisService: RedisService,
) {
this.defaultSelect = {
...this.businessActivitiesQueryService.baseSelect,
@@ -37,6 +40,7 @@ export class BusinessActivitiesService {
},
}
}
private readonly cacheTtlSeconds = 300
private readonly prepareBusinessActivityResponse = (businessActivity: any) => {
const { license_activation, complexes, ...rest } = businessActivity
@@ -56,20 +60,34 @@ export class BusinessActivitiesService {
}
async findAll(consumer_id: string) {
const cacheKey = RedisKeyMaker.consumerBusinessActivitiesList(consumer_id)
const cached = await this.redisService.getJson<unknown[]>(cacheKey)
if (cached) {
return ResponseMapper.list(cached)
}
const businessActivities =
await this.businessActivitiesQueryService.findAllByConsumer(
consumer_id,
this.defaultSelect,
)
await this.redisService.setJson(cacheKey, businessActivities, this.cacheTtlSeconds)
return ResponseMapper.list(businessActivities)
}
async findOne(consumer_id: string, id: string) {
const cacheKey = RedisKeyMaker.consumerBusinessActivityInfo(consumer_id, id)
const cached = await this.redisService.getJson<unknown>(cacheKey)
if (cached) {
return ResponseMapper.single(cached)
}
const businessActivity = await this.businessActivitiesQueryService.findOneByConsumer(
consumer_id,
id,
this.defaultSelect,
)
await this.redisService.setJson(cacheKey, businessActivity, this.cacheTtlSeconds)
return ResponseMapper.single(businessActivity)
}
@@ -79,6 +97,13 @@ export class BusinessActivitiesService {
data,
select: this.defaultSelect,
})
await this.redisService.delete(
RedisKeyMaker.consumerBusinessActivityInfo(consumer_id, id),
)
await this.redisService.delete(
RedisKeyMaker.consumerBusinessActivitiesList(consumer_id),
)
return ResponseMapper.update(this.prepareBusinessActivityResponse(businessActivity))
}
}
@@ -1,5 +1,6 @@
import { UploadedFileTypes } from '@/common/enums/enums'
import { GoodSelect } from '@/generated/prisma/models'
import { PosCacheInvalidationService } from '@/modules/pos/cache/pos-cache-invalidation.service'
import { UploaderService } from '@/modules/uploader/uploader.service'
import { PrismaService } from '@/prisma/prisma.service'
import { Injectable } from '@nestjs/common'
@@ -11,6 +12,7 @@ export class ConsumerBusinessActivityGoodsService {
constructor(
private readonly prisma: PrismaService,
private readonly uploaderService: UploaderService,
private readonly posCacheInvalidationService: PosCacheInvalidationService,
) {}
defaultSelect: GoodSelect = {
@@ -110,6 +112,9 @@ export class ConsumerBusinessActivityGoodsService {
},
},
})
await this.posCacheInvalidationService.invalidateGoodsListByBusinessActivity(
business_activity_id,
)
return ResponseMapper.create(good)
}
@@ -174,6 +179,9 @@ export class ConsumerBusinessActivityGoodsService {
},
})
})
await this.posCacheInvalidationService.invalidateGoodsListByBusinessActivity(
business_activity_id,
)
return ResponseMapper.update(good)
}
+33 -2
View File
@@ -1,8 +1,10 @@
import { QUERY_CONSTANTS } from '@/common/queryConstants'
import { ResponseMapper } from '@/common/response/response-mapper'
import { PasswordUtil } from '@/common/utils'
import { RedisKeyMaker } from '@/common/utils/redisKeyMaker'
import { ConsumerUpdateInput } from '@/generated/prisma/models'
import { PrismaService } from '@/prisma/prisma.service'
import { RedisService } from '@/redis/redis.service'
import { Injectable } from '@nestjs/common'
import consumer_mappersUtil from '../../common/utils/mappers/consumer_mappers.util'
import { UpdateConsumerInfoDto } from './dto/update-info-request.dto'
@@ -10,9 +12,20 @@ import { UpdateConsumerPasswordDto } from './dto/update-password-request.dto'
@Injectable()
export class ConsumerService {
constructor(private readonly prisma: PrismaService) {}
constructor(
private readonly prisma: PrismaService,
private readonly redisService: RedisService,
) {}
private readonly infoCacheTtlSeconds = 300
async getInfo(consumer_id: string) {
const cacheKey = RedisKeyMaker.consumerInfo(consumer_id)
const cached = await this.redisService.getJson<unknown>(cacheKey)
if (cached) {
return ResponseMapper.single(cached)
}
const consumer = await this.prisma.consumer.findUniqueOrThrow({
where: {
id: consumer_id,
@@ -24,7 +37,9 @@ export class ConsumerService {
},
})
return ResponseMapper.single(consumer_mappersUtil(consumer))
const mappedConsumer = consumer_mappersUtil(consumer)
await this.redisService.setJson(cacheKey, mappedConsumer, this.infoCacheTtlSeconds)
return ResponseMapper.single(mappedConsumer)
}
async updateInfo(consumer_id: string, data: UpdateConsumerInfoDto) {
@@ -69,6 +84,22 @@ export class ConsumerService {
},
})
await this.redisService.delete(RedisKeyMaker.consumerInfo(consumer_id))
const partnerOwner = await this.prisma.consumer.findUnique({
where: { id: consumer_id },
select: {
legal: { select: { partner_id: true } },
individual: { select: { partner_id: true } },
},
})
const partnerId =
partnerOwner?.legal?.partner_id || partnerOwner?.individual?.partner_id || null
if (partnerId) {
await this.redisService.delete(
RedisKeyMaker.partnerConsumerInfo(partnerId, consumer_id),
)
}
return ResponseMapper.update(consumer)
}
+35 -4
View File
@@ -1,5 +1,6 @@
import translates from '@/common/constants/translates/translates'
import { translateEnumValue } from '@/common/utils/enum-translator.util'
import { RedisKeyMaker } from '@/common/utils/redisKeyMaker'
import {
AccountStatus,
AccountType,
@@ -26,12 +27,22 @@ import {
TspProviderResponseStatus,
TspProviderType,
} from '@/generated/prisma/enums'
import { RedisService } from '@/redis/redis.service'
import { Injectable } from '@nestjs/common'
import { GoldKarat, TspProviderCustomerType } from 'common/enums/enums'
import { ResponseMapper } from 'common/response/response-mapper'
@Injectable()
export class EnumsService {
constructor(private readonly redisService: RedisService) {}
private readonly cacheTtlSeconds = 24 * 60 * 60
private readonly cacheBuildVersion =
process.env.CACHE_BUILD_VERSION ||
process.env.APP_BUILD_ID ||
process.env.npm_package_version ||
'local'
private prepareData(
items: Record<string, string>,
enumName: keyof typeof translates.enums,
@@ -45,7 +56,7 @@ export class EnumsService {
})
}
getAllEnums() {
private buildAllEnums() {
return {
PaymentMethodType: this.prepareData(PaymentMethodType, 'PaymentMethodType'),
GoldKarat: this.prepareData(GoldKarat, 'GoldKarat'),
@@ -91,8 +102,28 @@ export class EnumsService {
}
}
getEnumValues(enumName: keyof typeof translates.enums) {
const enums = this.getAllEnums()
return ResponseMapper.list(enums[enumName] || [])
async getAllEnums() {
const cacheKey = RedisKeyMaker.enumsAll(this.cacheBuildVersion)
const cached = await this.redisService.getJson<Record<string, unknown[]>>(cacheKey)
if (cached) {
return cached
}
const enums = this.buildAllEnums()
await this.redisService.setJson(cacheKey, enums, this.cacheTtlSeconds)
return enums
}
async getEnumValues(enumName: keyof typeof translates.enums) {
const cacheKey = RedisKeyMaker.enumsValues(this.cacheBuildVersion, enumName)
const cached = await this.redisService.getJson<unknown[]>(cacheKey)
if (cached) {
return ResponseMapper.list(cached)
}
const enums = await this.getAllEnums()
const items = enums[enumName] || []
await this.redisService.setJson(cacheKey, items, this.cacheTtlSeconds)
return ResponseMapper.list(items)
}
}
@@ -0,0 +1,167 @@
import { RedisKeyMaker } from '@/common/utils'
import { RedisService } from '@/redis/redis.service'
import { Injectable } from '@nestjs/common'
@Injectable()
export class PartnersCacheInvalidationService {
constructor(private readonly redisService: RedisService) {}
async invalidatePartnerSummary(partnerId: string): Promise<void> {
await this.invalidatePartnersList()
await this.redisService.delete(RedisKeyMaker.partnerDetail(partnerId))
}
async invalidatePartnersList(): Promise<void> {
await this.redisService.delete(RedisKeyMaker.partnersList())
}
async invalidatePartnerDetail(partnerId: string): Promise<void> {
await this.invalidatePartnerSummary(partnerId)
}
async invalidatePartnerLicenseReadModels(partnerId: string): Promise<void> {
await this.redisService.deleteByPatterns([
RedisKeyMaker.partnerActivatedLicensesListPattern(partnerId),
RedisKeyMaker.partnerLicenseChargeTransactionsListPattern(partnerId),
RedisKeyMaker.partnerLicenseChargeTransactionDetailPattern(partnerId),
])
}
async invalidatePartnerLicenses(partnerId: string): Promise<void> {
await this.invalidatePartnerSummary(partnerId)
await this.invalidatePartnerLicenseReadModels(partnerId)
}
// consumers //
async invalidatePartnerConsumers(
partnerId: string,
page: number,
perPage: number,
): Promise<void> {
await this.redisService.delete(
RedisKeyMaker.partnerConsumersList(partnerId, page, perPage),
)
}
async invalidatePartnerConsumerReadModels(
partnerId: string,
consumerId: string,
): Promise<void> {
await this.redisService.deleteByPatterns([
RedisKeyMaker.partnerConsumersListPattern(partnerId),
RedisKeyMaker.partnerConsumerInfo(partnerId, consumerId),
])
}
async invalidatePartnerConsumerBusinessActivitiesReadModels(
partnerId: string,
consumerId: string,
): Promise<void> {
await this.invalidatePartnerConsumerReadModels(partnerId, consumerId)
await this.redisService.deleteByPattern(
RedisKeyMaker.partnerConsumerBusinessActivitiesPattern(partnerId, consumerId),
)
}
async invalidatePartnerConsumerBusinessActivityReadModels(
partnerId: string,
consumerId: string,
businessActivityId: string,
): Promise<void> {
await this.invalidatePartnerConsumerBusinessActivitiesReadModels(
partnerId,
consumerId,
)
await this.redisService.delete(
RedisKeyMaker.partnerConsumerBusinessActivityInfo(
partnerId,
consumerId,
businessActivityId,
),
)
}
async invalidatePartnerConsumerBusinessActivityComplexesReadModels(
partnerId: string,
consumerId: string,
businessActivityId: string,
): Promise<void> {
await this.invalidatePartnerConsumerBusinessActivitiesReadModels(
partnerId,
consumerId,
)
await this.redisService.deleteByPattern(
RedisKeyMaker.partnerConsumerBusinessActivityComplexesPattern(
partnerId,
consumerId,
businessActivityId,
),
)
}
async invalidatePartnerConsumerBusinessActivityComplexReadModels(
partnerId: string,
consumerId: string,
businessActivityId: string,
complexId: string,
): Promise<void> {
await this.invalidatePartnerConsumerBusinessActivityComplexesReadModels(
partnerId,
consumerId,
businessActivityId,
)
await this.redisService.delete(
RedisKeyMaker.partnerConsumerBusinessActivityComplexInfo(
partnerId,
consumerId,
businessActivityId,
complexId,
),
)
}
async invalidatePartnerConsumerBusinessActivityComplexPosesReadModels(
partnerId: string,
consumerId: string,
businessActivityId: string,
complexId: string,
): Promise<void> {
await this.invalidatePartnerConsumerBusinessActivitiesReadModels(
partnerId,
consumerId,
)
await this.redisService.deleteByPattern(
RedisKeyMaker.partnerConsumerBusinessActivityComplexPosesPattern(
partnerId,
consumerId,
businessActivityId,
complexId,
),
)
}
async invalidatePartnerConsumerBusinessActivityComplexPosReadModels(
partnerId: string,
consumerId: string,
businessActivityId: string,
complexId: string,
posId: string,
): Promise<void> {
await this.invalidatePartnerConsumerBusinessActivityComplexPosesReadModels(
partnerId,
consumerId,
businessActivityId,
complexId,
)
await this.redisService.delete(
RedisKeyMaker.partnerConsumerBusinessActivityComplexPosInfo(
partnerId,
consumerId,
businessActivityId,
complexId,
posId,
),
)
}
}
@@ -1,13 +1,16 @@
import { PasswordFieldValidator, UsernameFieldValidator } from '@/common/utils'
import { ApiProperty, PartialType } from '@nestjs/swagger'
import { IsEnum, IsOptional, IsString } from 'class-validator'
import { AccountStatus, ConsumerRole } from 'generated/prisma/enums'
export class CreateConsumerAccountDto {
@IsString()
@UsernameFieldValidator()
@ApiProperty({ required: true })
username: string
@IsString()
@PasswordFieldValidator()
@ApiProperty({ required: true })
password: string
@@ -1,13 +1,25 @@
import { BusinessActivitySelect } from '@/generated/prisma/models'
import { RedisKeyMaker } from '@/common/utils'
import {
BusinessActivityCreateInput,
BusinessActivitySelect,
} from '@/generated/prisma/models'
import { getPartnerFirstRemainingLicense } from '@/modules/partners/utils/getPartnerRemainingLicenses.util'
import { PrismaService } from '@/prisma/prisma.service'
import { BadRequestException, Injectable } from '@nestjs/common'
import { RedisService } from '@/redis/redis.service'
import { Injectable } from '@nestjs/common'
import { ResponseMapper } from 'common/response/response-mapper'
import { PartnersCacheInvalidationService } from '../../cache/partners-cache-invalidation.service'
import { CreateBusinessActivitiesDto } from './dto/create-business-activities.dto'
@Injectable()
export class BusinessActivitiesService {
constructor(private readonly prisma: PrismaService) {}
constructor(
private readonly prisma: PrismaService,
private readonly redisService: RedisService,
private readonly partnersCacheInvalidationService: PartnersCacheInvalidationService,
) {}
private readonly cacheTtlSeconds = 300
private readonly setExpireDate = (starts_at: Date) => {
return new Date(
@@ -85,6 +97,19 @@ export class BusinessActivitiesService {
}
async findAll(partner_id: string, consumer_id: string, page = 1, perPage = 10) {
const cacheKey = RedisKeyMaker.partnerConsumerBusinessActivitiesList(
partner_id,
consumer_id,
page,
perPage,
)
const cached = await this.redisService.getJson<{ items: unknown[]; total: number }>(
cacheKey,
)
if (cached) {
return ResponseMapper.paginate(cached.items, { total: cached.total, page, perPage })
}
const where = this.defaultWhere(partner_id, consumer_id)
const [businessActivities, total] = await this.prisma.$transaction(async tx => [
await tx.businessActivity.findMany({
@@ -95,13 +120,26 @@ export class BusinessActivitiesService {
}),
await tx.businessActivity.count({ where }),
])
return ResponseMapper.paginate(
businessActivities.map(this.prepareBusinessActivityResponse),
{ total, page, perPage },
const mappedItems = businessActivities.map(this.prepareBusinessActivityResponse)
await this.redisService.setJson(
cacheKey,
{ items: mappedItems, total },
this.cacheTtlSeconds,
)
return ResponseMapper.paginate(mappedItems, { total, page, perPage })
}
async findOne(partner_id: string, consumer_id: string, id: string) {
const cacheKey = RedisKeyMaker.partnerConsumerBusinessActivityInfo(
partner_id,
consumer_id,
id,
)
const cached = await this.redisService.getJson<unknown>(cacheKey)
if (cached) {
return ResponseMapper.single(cached)
}
const businessActivity = await this.prisma.businessActivity.findUnique({
where: {
...this.defaultWhere(partner_id, consumer_id),
@@ -109,7 +147,9 @@ export class BusinessActivitiesService {
},
select: this.defaultSelect,
})
return ResponseMapper.single(this.prepareBusinessActivityResponse(businessActivity))
const mappedItem = this.prepareBusinessActivityResponse(businessActivity)
await this.redisService.setJson(cacheKey, mappedItem, this.cacheTtlSeconds)
return ResponseMapper.single(mappedItem)
}
async create(
@@ -121,6 +161,37 @@ export class BusinessActivitiesService {
const license = await getPartnerFirstRemainingLicense(tx, { partner_id })
const { guild_id, license_starts_at, expires_at, ...rest } = data
const dataToCreate: BusinessActivityCreateInput = {
...rest,
economic_code: String(data.economic_code),
guild: {
connect: {
id: guild_id,
},
},
consumer: {
connect: {
id: consumer_id,
},
},
}
if (license_starts_at) {
dataToCreate.license_activation = {
create: {
starts_at: license_starts_at ?? new Date(),
expires_at:
expires_at ?? this.setExpireDate(new Date(license_starts_at || '')),
license: {
connect: {
id: license.id,
},
},
},
}
}
const createdBusinessActivity = await tx.businessActivity.create({
data: {
...rest,
@@ -159,10 +230,7 @@ export class BusinessActivitiesService {
})
const activationId = createdBusinessActivity.license_activation?.id
if (!activationId) {
throw new BadRequestException('لایسنس برای این فعالیت تجاری ایجاد نشد.')
}
if (activationId) {
const licenseAllocationCreation = Array.from({
length: license.accounts_limit,
}).map(() =>
@@ -178,6 +246,7 @@ export class BusinessActivitiesService {
)
await Promise.all(licenseAllocationCreation)
}
return tx.businessActivity.findUniqueOrThrow({
where: {
@@ -187,6 +256,10 @@ export class BusinessActivitiesService {
})
})
await this.partnersCacheInvalidationService.invalidatePartnerConsumerBusinessActivitiesReadModels(
partner_id,
consumer_id,
)
return ResponseMapper.create(businessActivity)
}
@@ -196,6 +269,13 @@ export class BusinessActivitiesService {
data,
select: this.defaultSelect,
})
await this.partnersCacheInvalidationService.invalidatePartnerConsumerBusinessActivityReadModels(
partner_id,
consumer_id,
id,
)
return ResponseMapper.update(businessActivity)
}
@@ -3,7 +3,12 @@ import { Body, Controller, Get, Param, Patch, Post } from '@nestjs/common'
import { ApiTags } from '@nestjs/swagger'
import { BusinessActivityComplexesService } from './complexes.service'
import { CreateComplexDto, UpdateComplexDto } from './dto/complex.dto'
import type { BusinessActivityComplexesServiceCreateResponseDto, BusinessActivityComplexesServiceFindAllResponseDto, BusinessActivityComplexesServiceFindOneResponseDto, BusinessActivityComplexesServiceUpdateResponseDto } from './dto/complexes-response.dto'
import type {
BusinessActivityComplexesServiceCreateResponseDto,
BusinessActivityComplexesServiceFindAllResponseDto,
BusinessActivityComplexesServiceFindOneResponseDto,
BusinessActivityComplexesServiceUpdateResponseDto,
} from './dto/complexes-response.dto'
@ApiTags('PartnerBusinessActivityComplexes')
@Controller(
@@ -34,10 +39,11 @@ export class BusinessActivityComplexesController {
@Post()
async create(
@PartnerInfo('id') partnerId: string,
@Param('consumerId') consumerId: string,
@Param('businessActivityId') businessActivityId: string,
@Body() data: CreateComplexDto,
): Promise<BusinessActivityComplexesServiceCreateResponseDto> {
return this.service.create(partnerId, businessActivityId, data)
return this.service.create(partnerId, consumerId, businessActivityId, data)
}
@Patch(':id')
@@ -1,13 +1,22 @@
import { QUERY_CONSTANTS } from '@/common/queryConstants'
import { RedisKeyMaker } from '@/common/utils'
import { ComplexSelect, ComplexWhereInput } from '@/generated/prisma/models'
import { PartnersCacheInvalidationService } from '@/modules/partners/cache/partners-cache-invalidation.service'
import { PrismaService } from '@/prisma/prisma.service'
import { RedisService } from '@/redis/redis.service'
import { BadRequestException, Injectable } from '@nestjs/common'
import { ResponseMapper } from 'common/response/response-mapper'
import { CreateComplexDto, UpdateComplexDto } from './dto/complex.dto'
@Injectable()
export class BusinessActivityComplexesService {
constructor(private readonly prisma: PrismaService) {}
constructor(
private readonly prisma: PrismaService,
private readonly redisService: RedisService,
private readonly partnersCacheInvalidationService: PartnersCacheInvalidationService,
) {}
private readonly cacheTtlSeconds = 300
private readonly defaultSelect: ComplexSelect = {
id: true,
@@ -49,6 +58,20 @@ export class BusinessActivityComplexesService {
page = 1,
perPage = 10,
) {
const cacheKey = RedisKeyMaker.partnerConsumerBusinessActivityComplexesList(
partner_id,
consumer_id,
business_activity_id,
page,
perPage,
)
const cached = await this.redisService.getJson<{ items: unknown[]; total: number }>(
cacheKey,
)
if (cached) {
return ResponseMapper.paginate(cached.items, { total: cached.total, page, perPage })
}
const where = this.defaultWhere(partner_id, consumer_id, business_activity_id)
const [complexes, total] = await this.prisma.$transaction(async tx => [
await tx.complex.findMany({
@@ -74,6 +97,11 @@ export class BusinessActivityComplexesService {
pos_count: _count.pos_list,
}
})
await this.redisService.setJson(
cacheKey,
{ items: mappedComplexes, total },
this.cacheTtlSeconds,
)
return ResponseMapper.paginate(mappedComplexes, { total, page, perPage })
}
@@ -83,18 +111,40 @@ export class BusinessActivityComplexesService {
business_activity_id: string,
id: string,
) {
const complex = await this.prisma.complex.findUnique({
const cacheKey = RedisKeyMaker.partnerConsumerBusinessActivityComplexInfo(
partner_id,
consumer_id,
business_activity_id,
id,
)
const cached = await this.redisService.getJson<unknown>(cacheKey)
if (cached) {
return ResponseMapper.single(cached)
}
const complex = await this.prisma.complex.findFirst({
where: {
...this.defaultWhere(partner_id, consumer_id, business_activity_id),
id,
},
select: this.defaultSelect,
})
if (!complex) {
throw new BadRequestException('شعبه مورد نظر یافت نشد.')
}
await this.redisService.setJson(cacheKey, complex, this.cacheTtlSeconds)
return ResponseMapper.single(complex)
}
async create(partner_id: string, business_id: string, data: CreateComplexDto) {
const complex = this.prisma.$transaction(async tx => {
async create(
partner_id: string,
business_id: string,
consumer_id: string,
data: CreateComplexDto,
) {
const complex = await this.prisma.$transaction(async tx => {
const relatedLicense = await tx.licenseAccountAllocation.findFirst({
where: {
license_activation: {
@@ -121,7 +171,7 @@ export class BusinessActivityComplexesService {
)
}
return await this.prisma.complex.create({
return await tx.complex.create({
data: {
...data,
business_activity: {
@@ -133,6 +183,12 @@ export class BusinessActivityComplexesService {
})
})
await this.partnersCacheInvalidationService.invalidatePartnerConsumerBusinessActivityComplexesReadModels(
partner_id,
consumer_id,
business_id,
)
return ResponseMapper.create(complex)
}
@@ -147,6 +203,13 @@ export class BusinessActivityComplexesService {
where: { ...this.defaultWhere(partner_id, consumer_id, business_activity_id), id },
data,
})
await this.partnersCacheInvalidationService.invalidatePartnerConsumerBusinessActivityComplexReadModels(
partner_id,
consumer_id,
business_activity_id,
id,
)
return ResponseMapper.update(complex)
}
@@ -1,7 +1,7 @@
import { QUERY_CONSTANTS } from '@/common/queryConstants'
import { consumerRelatedPartner } from '@/common/queryConstants/consumer'
import { PrismaErrorUtil } from '@/common/utils/prisma-error.util'
import { PasswordUtil } from '@/common/utils/password.util'
import { PrismaErrorUtil } from '@/common/utils/prisma-error.util'
import {
AccountStatus,
AccountType,
@@ -9,14 +9,22 @@ import {
POSStatus,
} from '@/generated/prisma/enums'
import { PosSelect } from '@/generated/prisma/models'
import { PartnersCacheInvalidationService } from '@/modules/partners/cache/partners-cache-invalidation.service'
import { PrismaService } from '@/prisma/prisma.service'
import { RedisService } from '@/redis/redis.service'
import { BadRequestException, Injectable } from '@nestjs/common'
import { ResponseMapper } from 'common/response/response-mapper'
import { CreatePosDto, UpdatePosDto } from './dto/pos.dto'
@Injectable()
export class ComplexPosesService {
constructor(private readonly prisma: PrismaService) {}
constructor(
private readonly prisma: PrismaService,
private readonly redisService: RedisService,
private readonly partnersCacheInvalidationService: PartnersCacheInvalidationService,
) {}
private readonly cacheTtlSeconds = 300
private readonly defaultSelect: PosSelect = {
id: true,
@@ -1,5 +1,6 @@
import { FiscalIdFieldValidator } from '@/common/utils'
import { ApiProperty, PartialType } from '@nestjs/swagger'
import { IsDateString, IsOptional, IsString } from 'class-validator'
import { IsDateString, IsNumber, IsOptional, IsString, Max, Min } from 'class-validator'
export class CreateBusinessActivitiesDto {
@IsString()
@@ -11,6 +12,7 @@ export class CreateBusinessActivitiesDto {
economic_code: string
@IsString()
@FiscalIdFieldValidator()
@ApiProperty({ required: true })
fiscal_id: string
@@ -22,6 +24,12 @@ export class CreateBusinessActivitiesDto {
@ApiProperty({ required: true })
guild_id: string
@ApiProperty({ required: false, default: '1' })
@IsNumber()
@Min(0)
@Max(1_000_000_000)
invoice_number_sequence: number
@IsDateString()
@IsOptional()
@ApiProperty({ required: false })
@@ -1,6 +1,7 @@
import { QUERY_CONSTANTS } from '@/common/queryConstants'
import mapConsumerWithLicenseUtil from '@/common/utils/mappers/consumer_mappers.util'
import { PasswordUtil } from '@/common/utils/password.util'
import { RedisKeyMaker } from '@/common/utils/redisKeyMaker'
import {
AccountStatus,
AccountType,
@@ -15,13 +16,21 @@ import {
ConsumerWhereInput,
} from '@/generated/prisma/models'
import { PrismaService } from '@/prisma/prisma.service'
import { RedisService } from '@/redis/redis.service'
import { BadRequestException, Injectable } from '@nestjs/common'
import { ResponseMapper } from 'common/response/response-mapper'
import { PartnersCacheInvalidationService } from '../cache/partners-cache-invalidation.service'
import { CreateConsumerDto, UpdateConsumerDto } from './dto/create-consumers.dto'
@Injectable()
export class PartnerConsumersService {
constructor(private readonly prisma: PrismaService) {}
constructor(
private readonly prisma: PrismaService,
private readonly redisService: RedisService,
private readonly partnersCacheInvalidationService: PartnersCacheInvalidationService,
) {}
private readonly infoCacheTtlSeconds = 300
private readonly setExpireDate = (starts_at: Date) => {
return new Date(
@@ -54,6 +63,14 @@ export class PartnerConsumersService {
})
async findAll(partner_id: string, page = 1, perPage = 10) {
const cacheKey = RedisKeyMaker.partnerConsumersList(partner_id, page, perPage)
const cached = await this.redisService.getJson<{ items: unknown[]; total: number }>(
cacheKey,
)
if (cached) {
return ResponseMapper.paginate(cached.items, { total: cached.total, page, perPage })
}
const [consumers, total] = await this.prisma.$transaction(async tx => [
await tx.consumer.findMany({
where: this.defaultWhere(partner_id),
@@ -65,7 +82,13 @@ export class PartnerConsumersService {
where: this.defaultWhere(partner_id),
}),
])
return ResponseMapper.paginate(consumers.map(mapConsumerWithLicenseUtil), {
const mappedItems = consumers.map(mapConsumerWithLicenseUtil)
await this.redisService.setJson(
cacheKey,
{ items: mappedItems, total },
this.infoCacheTtlSeconds,
)
return ResponseMapper.paginate(mappedItems, {
total,
page,
perPage,
@@ -73,6 +96,12 @@ export class PartnerConsumersService {
}
async findOne(partner_id: string, consumer_id: string) {
const cacheKey = RedisKeyMaker.partnerConsumerInfo(partner_id, consumer_id)
const cached = await this.redisService.getJson<unknown>(cacheKey)
if (cached) {
return ResponseMapper.single(cached)
}
const consumer = await this.prisma.consumer.findUniqueOrThrow({
where: {
...(this.defaultWhere(partner_id) as any),
@@ -81,7 +110,14 @@ export class PartnerConsumersService {
select: this.defaultSelect,
})
return ResponseMapper.single(mapConsumerWithLicenseUtil(consumer))
const mappedConsumer = mapConsumerWithLicenseUtil(consumer)
await this.redisService.setJson(
RedisKeyMaker.consumerInfo(consumer_id),
mappedConsumer,
this.infoCacheTtlSeconds,
)
await this.redisService.setJson(cacheKey, mappedConsumer, this.infoCacheTtlSeconds)
return ResponseMapper.single(mappedConsumer)
}
async create(partner_id: string, data: CreateConsumerDto) {
@@ -224,11 +260,16 @@ export class PartnerConsumersService {
})
})
await this.partnersCacheInvalidationService.invalidatePartnerConsumerReadModels(
partner_id,
consumer.id,
)
return ResponseMapper.single(mapConsumerWithLicenseUtil(consumer))
}
async update(id: string, partner_id: string, data: UpdateConsumerDto) {
return this.prisma.consumer.update({
const updatedConsumer = await this.prisma.consumer.update({
where: {
...(this.defaultWhere(partner_id) as any),
id,
@@ -243,5 +284,13 @@ export class PartnerConsumersService {
},
},
})
await this.partnersCacheInvalidationService.invalidatePartnerConsumerReadModels(
partner_id,
id,
)
await this.redisService.delete(RedisKeyMaker.consumerInfo(id))
return updatedConsumer
}
}
@@ -1,3 +1,4 @@
import { PasswordFieldValidator, UsernameFieldValidator } from '@/common/utils'
import { ConsumerIndividual, ConsumerLegal } from '@/generated/prisma/client'
import { ConsumerStatus, ConsumerType } from '@/generated/prisma/enums'
import { ApiProperty, OmitType, PartialType } from '@nestjs/swagger'
@@ -9,10 +10,12 @@ export class CreateConsumerDto {
type: ConsumerType
@IsString()
@UsernameFieldValidator()
@ApiProperty({ required: true })
username: string
@IsString()
@PasswordFieldValidator()
@ApiProperty({ required: true })
password: string
+5
View File
@@ -1,6 +1,7 @@
import { UploadedFileTypes } from '@/common/enums/enums'
import { ResponseMapper } from '@/common/response/response-mapper'
import { PasswordUtil } from '@/common/utils'
import { PartnersCacheInvalidationService } from '@/modules/partners/cache/partners-cache-invalidation.service'
import { UploaderService } from '@/modules/uploader/uploader.service'
import { PrismaService } from '@/prisma/prisma.service'
import { Injectable } from '@nestjs/common'
@@ -12,6 +13,7 @@ export class PartnerService {
constructor(
private readonly prisma: PrismaService,
private readonly uploaderService: UploaderService,
private readonly cacheInvalidationService: PartnersCacheInvalidationService,
) {}
async me(partner_id: string, account_id: string) {
@@ -245,6 +247,9 @@ export class PartnerService {
})
})
await this.cacheInvalidationService.invalidatePartnersList()
await this.cacheInvalidationService.invalidatePartnerDetail(partner_id)
return ResponseMapper.single(updatedPartner)
}
+25
View File
@@ -0,0 +1,25 @@
import { Injectable } from '@nestjs/common'
import { RedisService } from '@/redis/redis.service'
@Injectable()
export class PosCacheInvalidationService {
constructor(private readonly redisService: RedisService) {}
async invalidateGoodsListByGuild(guildId: string): Promise<void> {
const client = await this.redisService.getClient()
const keys = await client.keys(`pos:ba:*:guild:${guildId}:goods:list`)
if (keys.length > 0) {
await client.del(keys)
}
}
async invalidateGoodsListByBusinessActivity(
businessActivityId: string,
): Promise<void> {
const client = await this.redisService.getClient()
const keys = await client.keys(`pos:ba:${businessActivityId}:guild:*:goods:list`)
if (keys.length > 0) {
await client.del(keys)
}
}
}
@@ -0,0 +1,25 @@
import { PosInfo } from '@/common/decorators/posInfo.decorator'
import type { IPosPayload } from '@/common/models/posPayload.model'
import { Controller, Delete, Param, Post } from '@nestjs/common'
import { PosGoodFavoriteService } from './favorite.service'
@Controller('pos/goods/:good_id/favorite')
export class PosGoodFavoriteController {
constructor(private readonly service: PosGoodFavoriteService) {}
@Post()
attach(
@Param('good_id') good_id: string,
@PosInfo() { business_id, guild_id, consumer_account_id }: IPosPayload,
) {
return this.service.attach(good_id, business_id, guild_id, consumer_account_id)
}
@Delete()
detach(
@Param('good_id') good_id: string,
@PosInfo() { business_id, guild_id, consumer_account_id }: IPosPayload,
) {
return this.service.detach(good_id, business_id, guild_id, consumer_account_id)
}
}
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common'
import { PosGoodFavoriteController } from './favorite.controller'
import { PosGoodFavoriteService } from './favorite.service'
@Module({
controllers: [PosGoodFavoriteController],
providers: [PosGoodFavoriteService],
})
export class PosGoodFavoriteModule {}
@@ -0,0 +1,88 @@
import { RedisService } from '@/redis/redis.service'
import { Injectable } from '@nestjs/common'
import { ResponseMapper } from '../../../common/response/response-mapper'
import { PrismaService } from '../../../prisma/prisma.service'
import { PosCacheInvalidationService } from '../cache/pos-cache-invalidation.service'
@Injectable()
export class PosGoodFavoriteService {
constructor(
private prisma: PrismaService,
private readonly redisService: RedisService,
private readonly posCacheInvalidationService: PosCacheInvalidationService,
) {}
async attach(
good_id: string,
business_id: string,
guild_id: string,
consumer_account_id: string,
) {
const favorite = await this.prisma.consumerAccountGoodFavorite.upsert({
where: {
consumer_account_id_good_id: {
consumer_account_id,
good_id,
},
good: {
OR: [
{
business_activity_id: business_id,
},
{
sku: {
guild_id,
},
},
],
},
},
update: {},
create: {
consumer_account_id,
good_id,
},
})
await this.posCacheInvalidationService.invalidateGoodsListByBusinessActivity(
business_id,
)
return ResponseMapper.create(favorite)
}
async detach(
good_id: string,
business_id: string,
guild_id: string,
consumer_account_id: string,
) {
const favorite = await this.prisma.consumerAccountGoodFavorite.delete({
where: {
consumer_account_id_good_id: {
consumer_account_id,
good_id,
},
good: {
OR: [
{
business_activity_id: business_id,
},
{
sku: {
guild_id,
},
},
],
},
},
})
await this.posCacheInvalidationService.invalidateGoodsListByBusinessActivity(
business_id,
)
return ResponseMapper.delete()
}
}
@@ -0,0 +1,4 @@
import { PartialType } from '@nestjs/swagger'
import { CreateGoodDto } from './create-good.dto'
export class UpdateGoodDto extends PartialType(CreateGoodDto) {}
+3 -3
View File
@@ -1,15 +1,15 @@
import { PosInfo } from '@/common/decorators/posInfo.decorator'
import type { IPosPayload } from '@/common/models/posPayload.model'
import { Controller, Get, Param } from '@nestjs/common'
import { GoodsService } from './goods.service'
import type { IPosPayload } from '@/common/models/posPayload.model'
@Controller('pos/goods')
export class GoodsController {
constructor(private readonly goodsService: GoodsService) {}
@Get()
findAll(@PosInfo() { business_id, guild_id }: IPosPayload) {
return this.goodsService.findAll(business_id, guild_id)
findAll(@PosInfo() { business_id, guild_id, consumer_account_id }: IPosPayload) {
return this.goodsService.findAll(business_id, guild_id, consumer_account_id)
}
@Get(':id')
+2
View File
@@ -1,8 +1,10 @@
import { Module } from '@nestjs/common'
import { PosGoodFavoriteModule } from '../favorite/favorite.module'
import { GoodsController } from './goods.controller'
import { GoodsService } from './goods.service'
@Module({
imports: [PosGoodFavoriteModule],
controllers: [GoodsController],
providers: [GoodsService],
})
+105 -4
View File
@@ -1,12 +1,22 @@
import { RedisKeyMaker } from '@/common/utils/redisKeyMaker'
import { GoodSelect } from '@/generated/prisma/models'
import { PosCacheInvalidationService } from '@/modules/pos/cache/pos-cache-invalidation.service'
import { RedisService } from '@/redis/redis.service'
import { Injectable } from '@nestjs/common'
import { ResponseMapper } from '../../../common/response/response-mapper'
import { PrismaService } from '../../../prisma/prisma.service'
import { CreateGoodDto } from './dto/create-good.dto'
import { UpdateGoodDto } from './dto/update-good.dto'
@Injectable()
export class GoodsService {
constructor(private prisma: PrismaService) {}
constructor(
private prisma: PrismaService,
private readonly redisService: RedisService,
private readonly posCacheInvalidationService: PosCacheInvalidationService,
) {}
private readonly listCacheTtlSeconds = 300
private readonly defaultSelect: GoodSelect = {
id: true,
@@ -41,7 +51,17 @@ export class GoodsService {
},
}
async findAll(business_activity_id: string, guild_id: string) {
async findAll(
business_activity_id: string,
guild_id: string,
consumer_account_id: string,
) {
const cacheKey = RedisKeyMaker.posGoodsList(business_activity_id, guild_id)
const cached = await this.redisService.getJson<unknown[]>(cacheKey)
if (cached) {
return ResponseMapper.list(cached)
}
const goods = await this.prisma.good.findMany({
where: {
OR: [
@@ -56,10 +76,24 @@ export class GoodsService {
},
],
},
select: this.defaultSelect,
select: {
...this.defaultSelect,
consumer_account_good_favorites: {
where: {
consumer_account_id,
},
},
},
})
return ResponseMapper.list(goods)
const mappedGoods = goods.map(good => ({
...good,
is_favorite: good.consumer_account_good_favorites.length > 0,
}))
await this.redisService.setJson(cacheKey, mappedGoods, this.listCacheTtlSeconds)
return ResponseMapper.list(mappedGoods)
}
async findOne(good_id: string, business_activity_id: string, guild_id: string) {
@@ -117,6 +151,73 @@ export class GoodsService {
select: this.defaultSelect,
})
await this.posCacheInvalidationService.invalidateGoodsListByBusinessActivity(
business_activity_id,
)
return ResponseMapper.create(good)
}
async update(id: string, data: UpdateGoodDto, business_activity_id: string) {
const { category_id, sku_id, measure_unit_id, ...rest } = data
const good = await this.prisma.good.update({
where: {
id,
business_activity_id,
},
data: {
...rest,
...(measure_unit_id
? {
measure_unit: {
connect: {
id: measure_unit_id,
},
},
}
: {}),
...(sku_id
? {
sku: {
connect: {
id: sku_id,
},
},
}
: {}),
...(category_id
? {
category: {
connect: {
id: category_id,
},
},
}
: {}),
},
select: this.defaultSelect,
})
await this.posCacheInvalidationService.invalidateGoodsListByBusinessActivity(
business_activity_id,
)
return ResponseMapper.update(good)
}
async delete(id: string, business_activity_id: string) {
await this.prisma.good.delete({
where: {
id,
business_activity_id,
},
})
await this.posCacheInvalidationService.invalidateGoodsListByBusinessActivity(
business_activity_id,
)
return ResponseMapper.delete()
}
}
+29 -5
View File
@@ -1,15 +1,29 @@
import { QUERY_CONSTANTS } from '@/common/queryConstants'
import consumer_mappersUtil from '@/common/utils/mappers/consumer_mappers.util'
import { RedisKeyMaker } from '@/common/utils/redisKeyMaker'
import { ConsumerStatus } from '@/generated/prisma/enums'
import { PrismaService } from '@/prisma/prisma.service'
import { RedisService } from '@/redis/redis.service'
import { Injectable } from '@nestjs/common'
import { ResponseMapper } from 'common/response/response-mapper'
@Injectable()
export class PosService {
constructor(private readonly prisma: PrismaService) {}
constructor(
private readonly prisma: PrismaService,
private readonly redisService: RedisService,
) {}
private readonly infoCacheTtlSeconds = 300
private readonly meCacheTtlSeconds = 120
async getInfo(pos_id: string) {
const cacheKey = RedisKeyMaker.posInfo(pos_id)
const cached = await this.redisService.getJson<unknown>(cacheKey)
if (cached) {
return ResponseMapper.single(cached)
}
const pos = await this.prisma.pos.findUniqueOrThrow({
where: {
id: pos_id,
@@ -71,7 +85,7 @@ export class PosService {
license_activation,
} = business_activity
return ResponseMapper.single({
const payload = {
name,
complex: {
id: complexId,
@@ -89,7 +103,9 @@ export class PosService {
license_id: license_activation?.license.id,
},
partner: license_activation?.license.charge_transaction.partner,
})
}
await this.redisService.setJson(cacheKey, payload, this.infoCacheTtlSeconds)
return ResponseMapper.single(payload)
}
async getAccessible(account_id: string) {
@@ -136,6 +152,12 @@ export class PosService {
}
async getMe(account_id: string, pos_id: string) {
const cacheKey = RedisKeyMaker.posMe(account_id, pos_id)
const cached = await this.redisService.getJson<unknown>(cacheKey)
if (cached) {
return ResponseMapper.single(cached)
}
const pos = await this.prisma.consumerAccount.findUniqueOrThrow({
where: {
id: account_id,
@@ -177,9 +199,11 @@ export class PosService {
const { consumer, ...rest } = pos
return ResponseMapper.single({
const payload = {
...rest,
consumer: consumer_mappersUtil(consumer),
})
}
await this.redisService.setJson(cacheKey, payload, this.meCacheTtlSeconds)
return ResponseMapper.single(payload)
}
}
+15 -2
View File
@@ -1,9 +1,22 @@
import { Global, Module } from '@nestjs/common'
import { AdminGuildCacheInvalidationService } from '@/modules/admin/guilds/cache/admin-guild-cache-invalidation.service'
import { PartnersCacheInvalidationService } from '@/modules/partners/cache/partners-cache-invalidation.service'
import { PosCacheInvalidationService } from '@/modules/pos/cache/pos-cache-invalidation.service'
import { RedisService } from './redis.service'
@Global()
@Module({
providers: [RedisService],
exports: [RedisService],
providers: [
RedisService,
AdminGuildCacheInvalidationService,
PartnersCacheInvalidationService,
PosCacheInvalidationService,
],
exports: [
RedisService,
AdminGuildCacheInvalidationService,
PartnersCacheInvalidationService,
PosCacheInvalidationService,
],
})
export class RedisModule {}
+93
View File
@@ -34,6 +34,99 @@ export class RedisService implements OnModuleDestroy {
return this.client
}
async get(key: string): Promise<string | null> {
const client = await this.getClient()
return client.get(key)
}
async getJson<T>(key: string): Promise<T | null> {
const value = await this.get(key)
if (!value) {
return null
}
try {
return JSON.parse(value) as T
} catch {
this.logger.warn(`Invalid JSON for key "${key}"`)
return null
}
}
async set(
key: string,
value: string,
ttlSeconds?: number,
): Promise<'OK' | null> {
const client = await this.getClient()
if (ttlSeconds && ttlSeconds > 0) {
return client.set(key, value, 'EX', ttlSeconds)
}
return client.set(key, value)
}
async setJson(
key: string,
value: unknown,
ttlSeconds?: number,
): Promise<'OK' | null> {
return this.set(key, JSON.stringify(value), ttlSeconds)
}
async delete(key: string): Promise<number> {
const client = await this.getClient()
return client.del(key)
}
async exists(key: string): Promise<boolean> {
const client = await this.getClient()
const result = await client.exists(key)
return result === 1
}
async expire(key: string, ttlSeconds: number): Promise<boolean> {
const client = await this.getClient()
const result = await client.expire(key, ttlSeconds)
return result === 1
}
async deleteByPattern(pattern: string): Promise<number> {
const client = await this.getClient()
let deletedCount = 0
let cursor = '0'
do {
const [nextCursor, keys] = await client.scan(
cursor,
'MATCH',
pattern,
'COUNT',
100,
)
cursor = nextCursor
if (keys.length > 0) {
const pipeline = client.pipeline()
keys.forEach(k => pipeline.del(k))
const results = await pipeline.exec()
if (results) {
deletedCount += results.reduce((sum, [, value]) => {
return sum + (typeof value === 'number' ? value : 0)
}, 0)
}
}
} while (cursor !== '0')
return deletedCount
}
async deleteByPatterns(patterns: string[]): Promise<number> {
const deletedCounts = await Promise.all(
patterns.map(pattern => this.deleteByPattern(pattern)),
)
return deletedCounts.reduce((sum, count) => sum + count, 0)
}
async onModuleDestroy() {
await this.client.quit()
}