@sagebox-be/prisma-product 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +11 -0
  2. package/eslint.config.mjs +19 -0
  3. package/jest.config.ts +10 -0
  4. package/package.json +30 -0
  5. package/prisma/client/client.d.ts +1 -0
  6. package/prisma/client/client.js +4 -0
  7. package/prisma/client/default.d.ts +1 -0
  8. package/prisma/client/default.js +4 -0
  9. package/prisma/client/edge.d.ts +1 -0
  10. package/prisma/client/edge.js +272 -0
  11. package/prisma/client/index-browser.js +255 -0
  12. package/prisma/client/index.d.ts +11995 -0
  13. package/prisma/client/index.js +297 -0
  14. package/prisma/client/libquery_engine-darwin-arm64.dylib.node +0 -0
  15. package/prisma/client/libquery_engine-linux-musl-openssl-3.0.x.so.node +0 -0
  16. package/prisma/client/package.json +183 -0
  17. package/prisma/client/query_engine_bg.js +2 -0
  18. package/prisma/client/query_engine_bg.wasm +0 -0
  19. package/prisma/client/runtime/edge-esm.js +34 -0
  20. package/prisma/client/runtime/edge.js +34 -0
  21. package/prisma/client/runtime/index-browser.d.ts +370 -0
  22. package/prisma/client/runtime/index-browser.js +16 -0
  23. package/prisma/client/runtime/library.d.ts +3977 -0
  24. package/prisma/client/runtime/library.js +146 -0
  25. package/prisma/client/runtime/react-native.js +83 -0
  26. package/prisma/client/runtime/wasm-compiler-edge.js +84 -0
  27. package/prisma/client/runtime/wasm-engine-edge.js +36 -0
  28. package/prisma/client/schema.prisma +110 -0
  29. package/prisma/client/wasm-edge-light-loader.mjs +4 -0
  30. package/prisma/client/wasm-worker-loader.mjs +4 -0
  31. package/prisma/client/wasm.d.ts +1 -0
  32. package/prisma/client/wasm.js +279 -0
  33. package/prisma/migrations/20251016164201_init/migration.sql +128 -0
  34. package/prisma/migrations/migration_lock.toml +3 -0
  35. package/prisma/schema.prisma +110 -0
  36. package/project.json +50 -0
  37. package/src/index.ts +2 -0
  38. package/src/lib/prisma-product.module.ts +10 -0
  39. package/src/lib/prisma-product.service.ts +9 -0
  40. package/tsconfig.json +23 -0
  41. package/tsconfig.lib.json +18 -0
  42. package/tsconfig.spec.json +15 -0
@@ -0,0 +1,279 @@
1
+
2
+ /* !!! This is code generated by Prisma. Do not edit directly. !!!
3
+ /* eslint-disable */
4
+
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+
7
+ const {
8
+ PrismaClientKnownRequestError,
9
+ PrismaClientUnknownRequestError,
10
+ PrismaClientRustPanicError,
11
+ PrismaClientInitializationError,
12
+ PrismaClientValidationError,
13
+ getPrismaClient,
14
+ sqltag,
15
+ empty,
16
+ join,
17
+ raw,
18
+ skip,
19
+ Decimal,
20
+ Debug,
21
+ objectEnumValues,
22
+ makeStrictEnum,
23
+ Extensions,
24
+ warnOnce,
25
+ defineDmmfProperty,
26
+ Public,
27
+ getRuntime,
28
+ createParam,
29
+ } = require('./runtime/wasm-engine-edge.js')
30
+
31
+
32
+ const Prisma = {}
33
+
34
+ exports.Prisma = Prisma
35
+ exports.$Enums = {}
36
+
37
+ /**
38
+ * Prisma Client JS version: 6.17.1
39
+ * Query Engine version: 272a37d34178c2894197e17273bf937f25acdeac
40
+ */
41
+ Prisma.prismaVersion = {
42
+ client: "6.17.1",
43
+ engine: "272a37d34178c2894197e17273bf937f25acdeac"
44
+ }
45
+
46
+ Prisma.PrismaClientKnownRequestError = PrismaClientKnownRequestError;
47
+ Prisma.PrismaClientUnknownRequestError = PrismaClientUnknownRequestError
48
+ Prisma.PrismaClientRustPanicError = PrismaClientRustPanicError
49
+ Prisma.PrismaClientInitializationError = PrismaClientInitializationError
50
+ Prisma.PrismaClientValidationError = PrismaClientValidationError
51
+ Prisma.Decimal = Decimal
52
+
53
+ /**
54
+ * Re-export of sql-template-tag
55
+ */
56
+ Prisma.sql = sqltag
57
+ Prisma.empty = empty
58
+ Prisma.join = join
59
+ Prisma.raw = raw
60
+ Prisma.validator = Public.validator
61
+
62
+ /**
63
+ * Extensions
64
+ */
65
+ Prisma.getExtensionContext = Extensions.getExtensionContext
66
+ Prisma.defineExtension = Extensions.defineExtension
67
+
68
+ /**
69
+ * Shorthand utilities for JSON filtering
70
+ */
71
+ Prisma.DbNull = objectEnumValues.instances.DbNull
72
+ Prisma.JsonNull = objectEnumValues.instances.JsonNull
73
+ Prisma.AnyNull = objectEnumValues.instances.AnyNull
74
+
75
+ Prisma.NullTypes = {
76
+ DbNull: objectEnumValues.classes.DbNull,
77
+ JsonNull: objectEnumValues.classes.JsonNull,
78
+ AnyNull: objectEnumValues.classes.AnyNull
79
+ }
80
+
81
+
82
+
83
+
84
+
85
+ /**
86
+ * Enums
87
+ */
88
+ exports.Prisma.TransactionIsolationLevel = makeStrictEnum({
89
+ ReadUncommitted: 'ReadUncommitted',
90
+ ReadCommitted: 'ReadCommitted',
91
+ RepeatableRead: 'RepeatableRead',
92
+ Serializable: 'Serializable'
93
+ });
94
+
95
+ exports.Prisma.AttributeScalarFieldEnum = {
96
+ id: 'id',
97
+ name: 'name',
98
+ createdAt: 'createdAt',
99
+ updatedAt: 'updatedAt'
100
+ };
101
+
102
+ exports.Prisma.CategoryScalarFieldEnum = {
103
+ id: 'id',
104
+ key: 'key',
105
+ name: 'name',
106
+ priority: 'priority',
107
+ parentId: 'parentId',
108
+ primary: 'primary',
109
+ createdAt: 'createdAt',
110
+ updatedAt: 'updatedAt'
111
+ };
112
+
113
+ exports.Prisma.CategoriesAttributeScalarFieldEnum = {
114
+ categoryId: 'categoryId',
115
+ attributeId: 'attributeId',
116
+ priority: 'priority',
117
+ createdAt: 'createdAt',
118
+ updatedAt: 'updatedAt'
119
+ };
120
+
121
+ exports.Prisma.ProductScalarFieldEnum = {
122
+ id: 'id',
123
+ name: 'name',
124
+ title: 'title',
125
+ description: 'description',
126
+ keywords: 'keywords',
127
+ categoryId: 'categoryId',
128
+ storeId: 'storeId',
129
+ viewedCount: 'viewedCount',
130
+ status: 'status',
131
+ media: 'media',
132
+ createdAt: 'createdAt',
133
+ updatedAt: 'updatedAt'
134
+ };
135
+
136
+ exports.Prisma.AttributeValueScalarFieldEnum = {
137
+ id: 'id',
138
+ skuId: 'skuId',
139
+ attrId: 'attrId',
140
+ value: 'value',
141
+ createdAt: 'createdAt',
142
+ updatedAt: 'updatedAt'
143
+ };
144
+
145
+ exports.Prisma.SkuScalarFieldEnum = {
146
+ id: 'id',
147
+ skuNo: 'skuNo',
148
+ productId: 'productId',
149
+ price: 'price',
150
+ quantity: 'quantity',
151
+ brand: 'brand',
152
+ media: 'media',
153
+ inactive: 'inactive',
154
+ createdAt: 'createdAt',
155
+ updatedAt: 'updatedAt'
156
+ };
157
+
158
+ exports.Prisma.SortOrder = {
159
+ asc: 'asc',
160
+ desc: 'desc'
161
+ };
162
+
163
+ exports.Prisma.JsonNullValueInput = {
164
+ JsonNull: Prisma.JsonNull
165
+ };
166
+
167
+ exports.Prisma.NullableJsonNullValueInput = {
168
+ DbNull: Prisma.DbNull,
169
+ JsonNull: Prisma.JsonNull
170
+ };
171
+
172
+ exports.Prisma.QueryMode = {
173
+ default: 'default',
174
+ insensitive: 'insensitive'
175
+ };
176
+
177
+ exports.Prisma.NullsOrder = {
178
+ first: 'first',
179
+ last: 'last'
180
+ };
181
+
182
+ exports.Prisma.JsonNullValueFilter = {
183
+ DbNull: Prisma.DbNull,
184
+ JsonNull: Prisma.JsonNull,
185
+ AnyNull: Prisma.AnyNull
186
+ };
187
+
188
+
189
+ exports.Prisma.ModelName = {
190
+ Attribute: 'Attribute',
191
+ Category: 'Category',
192
+ CategoriesAttribute: 'CategoriesAttribute',
193
+ Product: 'Product',
194
+ AttributeValue: 'AttributeValue',
195
+ Sku: 'Sku'
196
+ };
197
+ /**
198
+ * Create the Client
199
+ */
200
+ const config = {
201
+ "generator": {
202
+ "name": "client",
203
+ "provider": {
204
+ "fromEnvVar": null,
205
+ "value": "prisma-client-js"
206
+ },
207
+ "output": {
208
+ "value": "/Users/oreka/Downloads/sagebox/sagebox-be/libs/prisma-product/prisma/client",
209
+ "fromEnvVar": null
210
+ },
211
+ "config": {
212
+ "engineType": "library"
213
+ },
214
+ "binaryTargets": [
215
+ {
216
+ "fromEnvVar": null,
217
+ "value": "darwin-arm64",
218
+ "native": true
219
+ },
220
+ {
221
+ "fromEnvVar": null,
222
+ "value": "linux-musl-openssl-3.0.x"
223
+ }
224
+ ],
225
+ "previewFeatures": [],
226
+ "sourceFilePath": "/Users/oreka/Downloads/sagebox/sagebox-be/libs/prisma-product/prisma/schema.prisma",
227
+ "isCustomOutput": true
228
+ },
229
+ "relativeEnvPaths": {
230
+ "rootEnvPath": null
231
+ },
232
+ "relativePath": "..",
233
+ "clientVersion": "6.17.1",
234
+ "engineVersion": "272a37d34178c2894197e17273bf937f25acdeac",
235
+ "datasourceNames": [
236
+ "db"
237
+ ],
238
+ "activeProvider": "postgresql",
239
+ "postinstall": false,
240
+ "inlineDatasources": {
241
+ "db": {
242
+ "url": {
243
+ "fromEnvVar": "DATABASE_PRODUCT_URL",
244
+ "value": null
245
+ }
246
+ }
247
+ },
248
+ "inlineSchema": "generator client {\n provider = \"prisma-client-js\"\n output = env(\"PRISMA_CLIENT_PRODUCT_OUTPUT\")\n binaryTargets = [\"native\", \"linux-musl-openssl-3.0.x\"]\n}\n\ngenerator json {\n provider = \"prisma-json-types-generator\"\n}\n\ndatasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_PRODUCT_URL\")\n}\n\nmodel Attribute {\n id String @id @default(uuid()) @db.Uuid\n name String @unique(map: \"attribute_name\") @db.VarChar(255)\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n skuAttributesValues AttributeValue[]\n\n @@map(\"attributes\")\n}\n\nmodel Category {\n id String @id @default(uuid()) @db.Uuid\n key String @unique(map: \"category_key\") @db.VarChar(255)\n name String @db.VarChar(255)\n priority Int @default(0)\n parentId String? @db.Uuid\n primary Boolean @default(false)\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n parent Category? @relation(\"categoriesTocategories\", fields: [parentId], references: [id])\n children Category[] @relation(\"categoriesTocategories\")\n categoriesAttributes CategoriesAttribute?\n products Product[]\n\n @@map(\"categories\")\n}\n\nmodel CategoriesAttribute {\n categoryId String @id @default(uuid()) @db.Uuid\n attributeId String? @db.Uuid\n priority Int? @default(0)\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n categories Category @relation(fields: [categoryId], references: [id], onDelete: Cascade)\n\n @@map(\"categories_attributes\")\n}\n\nmodel Product {\n id String @id @default(uuid()) @db.Uuid\n name String @db.VarChar(255)\n title String @db.VarChar(255)\n description String\n keywords String\n categoryId String @db.Uuid\n storeId String @db.Uuid\n viewedCount Int @default(0)\n status String @db.VarChar(255)\n /// [MediaEntity]\n media Json\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n category Category @relation(fields: [categoryId], references: [id], onDelete: NoAction)\n skus Sku[]\n\n @@index([categoryId], map: \"products_category_id\")\n @@index([createdAt], map: \"products_created_at\")\n @@index([status], map: \"products_status\")\n @@index([storeId], map: \"products_store_id\")\n @@index([updatedAt], map: \"products_updated_at\")\n @@map(\"products\")\n}\n\nmodel AttributeValue {\n id String @id @default(uuid()) @db.Uuid\n skuId String @db.Uuid\n attrId String @db.Uuid\n value String @db.VarChar(255)\n attr Attribute? @relation(fields: [attrId], references: [id], onDelete: NoAction)\n skus Sku? @relation(fields: [skuId], references: [id], onDelete: Cascade)\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n\n @@unique([skuId, attrId], map: \"sku-attr-unique-index\")\n @@map(\"sku_attributes_values\")\n}\n\nmodel Sku {\n id String @id @default(uuid()) @db.Uuid\n skuNo String @unique(map: \"skus_sku_no\") @db.VarChar(255)\n productId String @db.Uuid\n price BigInt\n quantity Int\n brand String? @db.VarChar(255)\n /// [MediaEntity]\n media Json?\n inactive Boolean? @default(false)\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n attributeValues AttributeValue[]\n product Product? @relation(fields: [productId], references: [id], onDelete: Cascade)\n\n @@index([productId], map: \"skus_product_id\")\n @@map(\"skus\")\n}\n",
249
+ "inlineSchemaHash": "bde2c687de07fea9d4b208336a511e0dc1d342965d1586f6b7ec7b296550eb88",
250
+ "copyEngine": true
251
+ }
252
+ config.dirname = '/'
253
+
254
+ config.runtimeDataModel = JSON.parse("{\"models\":{\"Attribute\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"skuAttributesValues\",\"kind\":\"object\",\"type\":\"AttributeValue\",\"relationName\":\"AttributeToAttributeValue\"}],\"dbName\":\"attributes\"},\"Category\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"key\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"priority\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"parentId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"primary\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"parent\",\"kind\":\"object\",\"type\":\"Category\",\"relationName\":\"categoriesTocategories\"},{\"name\":\"children\",\"kind\":\"object\",\"type\":\"Category\",\"relationName\":\"categoriesTocategories\"},{\"name\":\"categoriesAttributes\",\"kind\":\"object\",\"type\":\"CategoriesAttribute\",\"relationName\":\"CategoriesAttributeToCategory\"},{\"name\":\"products\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"CategoryToProduct\"}],\"dbName\":\"categories\"},\"CategoriesAttribute\":{\"fields\":[{\"name\":\"categoryId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"attributeId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"priority\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"categories\",\"kind\":\"object\",\"type\":\"Category\",\"relationName\":\"CategoriesAttributeToCategory\"}],\"dbName\":\"categories_attributes\"},\"Product\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"title\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"description\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"keywords\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"categoryId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"storeId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"viewedCount\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"status\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"media\",\"kind\":\"scalar\",\"type\":\"Json\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"category\",\"kind\":\"object\",\"type\":\"Category\",\"relationName\":\"CategoryToProduct\"},{\"name\":\"skus\",\"kind\":\"object\",\"type\":\"Sku\",\"relationName\":\"ProductToSku\"}],\"dbName\":\"products\"},\"AttributeValue\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"skuId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"attrId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"value\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"attr\",\"kind\":\"object\",\"type\":\"Attribute\",\"relationName\":\"AttributeToAttributeValue\"},{\"name\":\"skus\",\"kind\":\"object\",\"type\":\"Sku\",\"relationName\":\"AttributeValueToSku\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":\"sku_attributes_values\"},\"Sku\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"skuNo\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"productId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"price\",\"kind\":\"scalar\",\"type\":\"BigInt\"},{\"name\":\"quantity\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"brand\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"media\",\"kind\":\"scalar\",\"type\":\"Json\"},{\"name\":\"inactive\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"attributeValues\",\"kind\":\"object\",\"type\":\"AttributeValue\",\"relationName\":\"AttributeValueToSku\"},{\"name\":\"product\",\"kind\":\"object\",\"type\":\"Product\",\"relationName\":\"ProductToSku\"}],\"dbName\":\"skus\"}},\"enums\":{},\"types\":{}}")
255
+ defineDmmfProperty(exports.Prisma, config.runtimeDataModel)
256
+ config.engineWasm = {
257
+ getRuntime: async () => require('./query_engine_bg.js'),
258
+ getQueryEngineWasmModule: async () => {
259
+ const loader = (await import('#wasm-engine-loader')).default
260
+ const engine = (await loader).default
261
+ return engine
262
+ }
263
+ }
264
+ config.compilerWasm = undefined
265
+
266
+ config.injectableEdgeEnv = () => ({
267
+ parsed: {
268
+ DATABASE_PRODUCT_URL: typeof globalThis !== 'undefined' && globalThis['DATABASE_PRODUCT_URL'] || typeof process !== 'undefined' && process.env && process.env.DATABASE_PRODUCT_URL || undefined
269
+ }
270
+ })
271
+
272
+ if (typeof globalThis !== 'undefined' && globalThis['DEBUG'] || typeof process !== 'undefined' && process.env && process.env.DEBUG || undefined) {
273
+ Debug.enable(typeof globalThis !== 'undefined' && globalThis['DEBUG'] || typeof process !== 'undefined' && process.env && process.env.DEBUG || undefined)
274
+ }
275
+
276
+ const PrismaClient = getPrismaClient(config)
277
+ exports.PrismaClient = PrismaClient
278
+ Object.assign(exports, Prisma)
279
+
@@ -0,0 +1,128 @@
1
+ -- CreateTable
2
+ CREATE TABLE "attributes" (
3
+ "id" UUID NOT NULL,
4
+ "name" VARCHAR(255) NOT NULL,
5
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
6
+ "updatedAt" TIMESTAMP(3) NOT NULL,
7
+
8
+ CONSTRAINT "attributes_pkey" PRIMARY KEY ("id")
9
+ );
10
+
11
+ -- CreateTable
12
+ CREATE TABLE "categories" (
13
+ "id" UUID NOT NULL,
14
+ "key" VARCHAR(255),
15
+ "name" VARCHAR(255),
16
+ "priority" INTEGER NOT NULL DEFAULT 0,
17
+ "parentId" UUID,
18
+ "primary" BOOLEAN NOT NULL DEFAULT false,
19
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
20
+ "updatedAt" TIMESTAMP(3) NOT NULL,
21
+
22
+ CONSTRAINT "categories_pkey" PRIMARY KEY ("id")
23
+ );
24
+
25
+ -- CreateTable
26
+ CREATE TABLE "categories_attributes" (
27
+ "categoryId" UUID NOT NULL,
28
+ "attributeId" UUID,
29
+ "priority" INTEGER DEFAULT 0,
30
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
31
+ "updatedAt" TIMESTAMP(3) NOT NULL,
32
+
33
+ CONSTRAINT "categories_attributes_pkey" PRIMARY KEY ("categoryId")
34
+ );
35
+
36
+ -- CreateTable
37
+ CREATE TABLE "products" (
38
+ "id" UUID NOT NULL,
39
+ "name" VARCHAR(255) NOT NULL,
40
+ "title" VARCHAR(255) NOT NULL,
41
+ "description" TEXT NOT NULL,
42
+ "keywords" TEXT NOT NULL,
43
+ "categoryId" UUID NOT NULL,
44
+ "storeId" UUID NOT NULL,
45
+ "viewedCount" INTEGER NOT NULL DEFAULT 0,
46
+ "status" VARCHAR(255) NOT NULL,
47
+ "media" JSONB NOT NULL,
48
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
49
+ "updatedAt" TIMESTAMP(3) NOT NULL,
50
+
51
+ CONSTRAINT "products_pkey" PRIMARY KEY ("id")
52
+ );
53
+
54
+ -- CreateTable
55
+ CREATE TABLE "sku_attributes_values" (
56
+ "id" UUID NOT NULL,
57
+ "skuId" UUID NOT NULL,
58
+ "attrId" UUID NOT NULL,
59
+ "value" VARCHAR(255) NOT NULL,
60
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
61
+ "updatedAt" TIMESTAMP(3) NOT NULL,
62
+
63
+ CONSTRAINT "sku_attributes_values_pkey" PRIMARY KEY ("id")
64
+ );
65
+
66
+ -- CreateTable
67
+ CREATE TABLE "skus" (
68
+ "id" UUID NOT NULL,
69
+ "skuNo" VARCHAR(255) NOT NULL,
70
+ "productId" UUID NOT NULL,
71
+ "price" BIGINT NOT NULL,
72
+ "quantity" INTEGER NOT NULL,
73
+ "brand" VARCHAR(255),
74
+ "media" JSONB,
75
+ "inactive" BOOLEAN DEFAULT false,
76
+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
77
+ "updatedAt" TIMESTAMP(3) NOT NULL,
78
+
79
+ CONSTRAINT "skus_pkey" PRIMARY KEY ("id")
80
+ );
81
+
82
+ -- CreateIndex
83
+ CREATE UNIQUE INDEX "attribute_name" ON "attributes"("name");
84
+
85
+ -- CreateIndex
86
+ CREATE UNIQUE INDEX "category_key" ON "categories"("key");
87
+
88
+ -- CreateIndex
89
+ CREATE INDEX "products_category_id" ON "products"("categoryId");
90
+
91
+ -- CreateIndex
92
+ CREATE INDEX "products_created_at" ON "products"("createdAt");
93
+
94
+ -- CreateIndex
95
+ CREATE INDEX "products_status" ON "products"("status");
96
+
97
+ -- CreateIndex
98
+ CREATE INDEX "products_store_id" ON "products"("storeId");
99
+
100
+ -- CreateIndex
101
+ CREATE INDEX "products_updated_at" ON "products"("updatedAt");
102
+
103
+ -- CreateIndex
104
+ CREATE UNIQUE INDEX "sku-attr-unique-index" ON "sku_attributes_values"("skuId", "attrId");
105
+
106
+ -- CreateIndex
107
+ CREATE UNIQUE INDEX "skus_sku_no" ON "skus"("skuNo");
108
+
109
+ -- CreateIndex
110
+ CREATE INDEX "skus_product_id" ON "skus"("productId");
111
+
112
+ -- AddForeignKey
113
+ ALTER TABLE "categories" ADD CONSTRAINT "categories_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "categories"("id") ON DELETE SET NULL ON UPDATE CASCADE;
114
+
115
+ -- AddForeignKey
116
+ ALTER TABLE "categories_attributes" ADD CONSTRAINT "categories_attributes_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "categories"("id") ON DELETE CASCADE ON UPDATE CASCADE;
117
+
118
+ -- AddForeignKey
119
+ ALTER TABLE "products" ADD CONSTRAINT "products_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "categories"("id") ON DELETE NO ACTION ON UPDATE CASCADE;
120
+
121
+ -- AddForeignKey
122
+ ALTER TABLE "sku_attributes_values" ADD CONSTRAINT "sku_attributes_values_attrId_fkey" FOREIGN KEY ("attrId") REFERENCES "attributes"("id") ON DELETE NO ACTION ON UPDATE CASCADE;
123
+
124
+ -- AddForeignKey
125
+ ALTER TABLE "sku_attributes_values" ADD CONSTRAINT "sku_attributes_values_skuId_fkey" FOREIGN KEY ("skuId") REFERENCES "skus"("id") ON DELETE CASCADE ON UPDATE CASCADE;
126
+
127
+ -- AddForeignKey
128
+ ALTER TABLE "skus" ADD CONSTRAINT "skus_productId_fkey" FOREIGN KEY ("productId") REFERENCES "products"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,3 @@
1
+ # Please do not edit this file manually
2
+ # It should be added in your version-control system (e.g., Git)
3
+ provider = "postgresql"
@@ -0,0 +1,110 @@
1
+ generator client {
2
+ provider = "prisma-client-js"
3
+ output = env("PRISMA_CLIENT_PRODUCT_OUTPUT")
4
+ binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
5
+ }
6
+
7
+ generator json {
8
+ provider = "prisma-json-types-generator"
9
+ }
10
+
11
+ datasource db {
12
+ provider = "postgresql"
13
+ url = env("DATABASE_PRODUCT_URL")
14
+ }
15
+
16
+ model Attribute {
17
+ id String @id @default(uuid()) @db.Uuid
18
+ name String @unique(map: "attribute_name") @db.VarChar(255)
19
+ createdAt DateTime @default(now())
20
+ updatedAt DateTime @updatedAt
21
+ skuAttributesValues AttributeValue[]
22
+
23
+ @@map("attributes")
24
+ }
25
+
26
+ model Category {
27
+ id String @id @default(uuid()) @db.Uuid
28
+ key String @unique(map: "category_key") @db.VarChar(255)
29
+ name String @db.VarChar(255)
30
+ priority Int @default(0)
31
+ parentId String? @db.Uuid
32
+ primary Boolean @default(false)
33
+ createdAt DateTime @default(now())
34
+ updatedAt DateTime @updatedAt
35
+ parent Category? @relation("categoriesTocategories", fields: [parentId], references: [id])
36
+ children Category[] @relation("categoriesTocategories")
37
+ categoriesAttributes CategoriesAttribute?
38
+ products Product[]
39
+
40
+ @@map("categories")
41
+ }
42
+
43
+ model CategoriesAttribute {
44
+ categoryId String @id @default(uuid()) @db.Uuid
45
+ attributeId String? @db.Uuid
46
+ priority Int? @default(0)
47
+ createdAt DateTime @default(now())
48
+ updatedAt DateTime @updatedAt
49
+ categories Category @relation(fields: [categoryId], references: [id], onDelete: Cascade)
50
+
51
+ @@map("categories_attributes")
52
+ }
53
+
54
+ model Product {
55
+ id String @id @default(uuid()) @db.Uuid
56
+ name String @db.VarChar(255)
57
+ title String @db.VarChar(255)
58
+ description String
59
+ keywords String
60
+ categoryId String @db.Uuid
61
+ storeId String @db.Uuid
62
+ viewedCount Int @default(0)
63
+ status String @db.VarChar(255)
64
+ /// [MediaEntity]
65
+ media Json
66
+ createdAt DateTime @default(now())
67
+ updatedAt DateTime @updatedAt
68
+ category Category @relation(fields: [categoryId], references: [id], onDelete: NoAction)
69
+ skus Sku[]
70
+
71
+ @@index([categoryId], map: "products_category_id")
72
+ @@index([createdAt], map: "products_created_at")
73
+ @@index([status], map: "products_status")
74
+ @@index([storeId], map: "products_store_id")
75
+ @@index([updatedAt], map: "products_updated_at")
76
+ @@map("products")
77
+ }
78
+
79
+ model AttributeValue {
80
+ id String @id @default(uuid()) @db.Uuid
81
+ skuId String @db.Uuid
82
+ attrId String @db.Uuid
83
+ value String @db.VarChar(255)
84
+ attr Attribute? @relation(fields: [attrId], references: [id], onDelete: NoAction)
85
+ skus Sku? @relation(fields: [skuId], references: [id], onDelete: Cascade)
86
+ createdAt DateTime @default(now())
87
+ updatedAt DateTime @updatedAt
88
+
89
+ @@unique([skuId, attrId], map: "sku-attr-unique-index")
90
+ @@map("sku_attributes_values")
91
+ }
92
+
93
+ model Sku {
94
+ id String @id @default(uuid()) @db.Uuid
95
+ skuNo String @unique(map: "skus_sku_no") @db.VarChar(255)
96
+ productId String @db.Uuid
97
+ price BigInt
98
+ quantity Int
99
+ brand String? @db.VarChar(255)
100
+ /// [MediaEntity]
101
+ media Json?
102
+ inactive Boolean? @default(false)
103
+ createdAt DateTime @default(now())
104
+ updatedAt DateTime @updatedAt
105
+ attributeValues AttributeValue[]
106
+ product Product? @relation(fields: [productId], references: [id], onDelete: Cascade)
107
+
108
+ @@index([productId], map: "skus_product_id")
109
+ @@map("skus")
110
+ }
package/project.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "prisma-product",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "libs/prisma-product/src",
5
+ "projectType": "library",
6
+ "release": {
7
+ "version": {
8
+ "manifestRootsToUpdate": ["dist/{projectRoot}"],
9
+ "currentVersionResolver": "git-tag",
10
+ "fallbackCurrentVersionResolver": "disk"
11
+ }
12
+ },
13
+ "tags": [],
14
+ "targets": {
15
+ "build": {
16
+ "executor": "@nx/js:tsc",
17
+ "outputs": ["{options.outputPath}"],
18
+ "options": {
19
+ "outputPath": "dist/libs/prisma-product",
20
+ "tsConfig": "libs/prisma-product/tsconfig.lib.json",
21
+ "packageJson": "libs/prisma-product/package.json",
22
+ "main": "libs/prisma-product/src/index.ts",
23
+ "assets": ["libs/prisma-product/*.md"]
24
+ }
25
+ },
26
+ "prisma-generate": {
27
+ "command": "PRISMA_CLIENT_PRODUCT_OUTPUT=../../../node_modules/@sagebox-prisma/client/products prisma generate",
28
+ "options": {
29
+ "cwd": "libs/prisma-product"
30
+ }
31
+ },
32
+ "prisma-format": {
33
+ "command": "prisma format",
34
+ "options": {
35
+ "cwd": "libs/prisma-product"
36
+ }
37
+ },
38
+ "nx-release-npm": {
39
+ "command": "PRISMA_CLIENT_PRODUCT_OUTPUT=./client prisma generate",
40
+ "options": {
41
+ "cwd": "libs/prisma-product"
42
+ }
43
+ },
44
+ "nx-release-publish": {
45
+ "options": {
46
+ "packageRoot": "dist/{projectRoot}"
47
+ }
48
+ }
49
+ }
50
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './lib/prisma-product.module';
2
+ export * from './lib/prisma-product.service';
@@ -0,0 +1,10 @@
1
+ import { Module } from '@nestjs/common';
2
+
3
+ import { PrismaProductService } from './prisma-product.service';
4
+
5
+ @Module({
6
+ controllers: [],
7
+ providers: [PrismaProductService],
8
+ exports: [PrismaProductService],
9
+ })
10
+ export class PrismaProductModule {}
@@ -0,0 +1,9 @@
1
+ import { Injectable, OnModuleInit } from '@nestjs/common';
2
+ import { PrismaClient } from '@sagebox-prisma/client/products';
3
+
4
+ @Injectable()
5
+ export class PrismaProductService extends PrismaClient implements OnModuleInit {
6
+ async onModuleInit() {
7
+ await this.$connect();
8
+ }
9
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "module": "nodenext",
5
+ "forceConsistentCasingInFileNames": true,
6
+ "strict": true,
7
+ "importHelpers": true,
8
+ "noImplicitOverride": true,
9
+ "noImplicitReturns": true,
10
+ "noFallthroughCasesInSwitch": true,
11
+ "noPropertyAccessFromIndexSignature": true
12
+ },
13
+ "files": [],
14
+ "include": [],
15
+ "references": [
16
+ {
17
+ "path": "./tsconfig.lib.json"
18
+ },
19
+ {
20
+ "path": "./tsconfig.spec.json"
21
+ }
22
+ ]
23
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "declaration": true,
6
+ "types": ["node"],
7
+ "target": "es2021",
8
+ "experimentalDecorators": true,
9
+ "emitDecoratorMetadata": true,
10
+ "strictNullChecks": true,
11
+ "noImplicitAny": true,
12
+ "strictBindCallApply": true,
13
+ "forceConsistentCasingInFileNames": true,
14
+ "noFallthroughCasesInSwitch": true
15
+ },
16
+ "include": ["src/**/*.ts"],
17
+ "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
18
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc",
5
+ "module": "nodenext",
6
+ "moduleResolution": "nodenext",
7
+ "types": ["jest", "node"]
8
+ },
9
+ "include": [
10
+ "jest.config.ts",
11
+ "src/**/*.test.ts",
12
+ "src/**/*.spec.ts",
13
+ "src/**/*.d.ts"
14
+ ]
15
+ }