@sagebox-be/prisma-product 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -6,21 +6,15 @@
6
6
  "sagebox",
7
7
  "product"
8
8
  ],
9
- "version": "0.0.1",
9
+ "version": "0.0.2",
10
10
  "type": "commonjs",
11
+ "main": "prisma/client/index.js",
12
+ "types": "prisma/client/index.d.ts",
13
+ "files": [
14
+ "prisma/client/**"
15
+ ],
11
16
  "publishConfig": {
12
- "access": "public",
13
- "main": "prisma/client/index.js",
14
- "types": "prisma/client/index.d.ts",
15
- "exports": {
16
- ".": {
17
- "types": "./prisma/client/index.d.ts",
18
- "default": "./prisma/client/index.js"
19
- }
20
- },
21
- "files": [
22
- "prisma/client/**"
23
- ]
17
+ "access": "public"
24
18
  },
25
19
  "dependencies": {
26
20
  "@prisma/client": "^6.17.1",
package/eslint.config.mjs DELETED
@@ -1,19 +0,0 @@
1
- import baseConfig from '../../eslint.config.mjs';
2
-
3
- export default [
4
- ...baseConfig,
5
- {
6
- files: ['**/*.json'],
7
- rules: {
8
- '@nx/dependency-checks': [
9
- 'error',
10
- {
11
- ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs,ts,cts,mts}'],
12
- },
13
- ],
14
- },
15
- languageOptions: {
16
- parser: await import('jsonc-eslint-parser'),
17
- },
18
- },
19
- ];
package/jest.config.ts DELETED
@@ -1,10 +0,0 @@
1
- export default {
2
- displayName: 'prisma-product',
3
- preset: '../../jest.preset.js',
4
- testEnvironment: 'node',
5
- transform: {
6
- '^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
7
- },
8
- moduleFileExtensions: ['ts', 'js', 'html'],
9
- coverageDirectory: '../../coverage/libs/prisma-product',
10
- };
@@ -1,128 +0,0 @@
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;
@@ -1,3 +0,0 @@
1
- # Please do not edit this file manually
2
- # It should be added in your version-control system (e.g., Git)
3
- provider = "postgresql"
@@ -1,110 +0,0 @@
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 DELETED
@@ -1,50 +0,0 @@
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 DELETED
@@ -1,2 +0,0 @@
1
- export * from './lib/prisma-product.module';
2
- export * from './lib/prisma-product.service';
@@ -1,10 +0,0 @@
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 {}
@@ -1,9 +0,0 @@
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 DELETED
@@ -1,23 +0,0 @@
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
- }
package/tsconfig.lib.json DELETED
@@ -1,18 +0,0 @@
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
- }
@@ -1,15 +0,0 @@
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
- }