@wipzent/github-sync 1.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 (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -0
  3. package/dist/cli/index.js +185 -0
  4. package/dist/cli/prompts.js +16 -0
  5. package/dist/config/defaults.js +5 -0
  6. package/dist/config/env.js +23 -0
  7. package/dist/config/octokit.js +14 -0
  8. package/dist/git/clone.js +15 -0
  9. package/dist/git/rewriteAuthor.js +37 -0
  10. package/dist/git/sync.js +141 -0
  11. package/dist/mcp/resources/github.js +13 -0
  12. package/dist/mcp/server.js +92 -0
  13. package/dist/mcp/tools/autoSync.js +130 -0
  14. package/dist/mcp/tools/createRepo.js +120 -0
  15. package/dist/mcp/tools/resolveConflict.js +4 -0
  16. package/dist/mcp/tools/syncRepo.js +21 -0
  17. package/dist/temp/Terred-Mujtaba-/apps/app/src/components/Toaster/toast.js +17 -0
  18. package/dist/temp/Terred-Mujtaba-/apps/app/src/config/fetch.js +76 -0
  19. package/dist/temp/Terred-Mujtaba-/apps/app/src/config/index.js +65 -0
  20. package/dist/temp/Terred-Mujtaba-/apps/app/src/data/data.js +574 -0
  21. package/dist/temp/Terred-Mujtaba-/apps/app/src/lib/utils.js +8 -0
  22. package/dist/temp/Terred-Mujtaba-/apps/app/src/redux/config.js +7 -0
  23. package/dist/temp/Terred-Mujtaba-/apps/app/src/redux/slices/AdminsSlice.js +20 -0
  24. package/dist/temp/Terred-Mujtaba-/apps/app/src/redux/slices/userSlice.js +19 -0
  25. package/dist/temp/Terred-Mujtaba-/apps/app/src/redux/store.js +15 -0
  26. package/dist/temp/Terred-Mujtaba-/apps/app/src/types/interfaces.js +3 -0
  27. package/dist/temp/Terred-Mujtaba-/apps/app/src/types/types.js +2 -0
  28. package/dist/temp/Terred-Mujtaba-/apps/app/src/utils/helperFunctions.js +150 -0
  29. package/dist/temp/Terred-Mujtaba-/apps/app/tailwind.config.js +85 -0
  30. package/dist/temp/Terred-Mujtaba-/apps/backend/src/admin/admin.controller.js +113 -0
  31. package/dist/temp/Terred-Mujtaba-/apps/backend/src/admin/admin.controller.spec.js +18 -0
  32. package/dist/temp/Terred-Mujtaba-/apps/backend/src/admin/admin.module.js +64 -0
  33. package/dist/temp/Terred-Mujtaba-/apps/backend/src/admin/admin.service.js +327 -0
  34. package/dist/temp/Terred-Mujtaba-/apps/backend/src/admin/admin.service.spec.js +16 -0
  35. package/dist/temp/Terred-Mujtaba-/apps/backend/src/admin/dto/admin.dto.js +214 -0
  36. package/dist/temp/Terred-Mujtaba-/apps/backend/src/app.controller.js +67 -0
  37. package/dist/temp/Terred-Mujtaba-/apps/backend/src/app.controller.spec.js +20 -0
  38. package/dist/temp/Terred-Mujtaba-/apps/backend/src/app.module.js +67 -0
  39. package/dist/temp/Terred-Mujtaba-/apps/backend/src/app.service.js +60 -0
  40. package/dist/temp/Terred-Mujtaba-/apps/backend/src/categories/categories.controller.js +89 -0
  41. package/dist/temp/Terred-Mujtaba-/apps/backend/src/categories/categories.controller.spec.js +18 -0
  42. package/dist/temp/Terred-Mujtaba-/apps/backend/src/categories/categories.module.js +64 -0
  43. package/dist/temp/Terred-Mujtaba-/apps/backend/src/categories/categories.service.js +173 -0
  44. package/dist/temp/Terred-Mujtaba-/apps/backend/src/categories/categories.service.spec.js +16 -0
  45. package/dist/temp/Terred-Mujtaba-/apps/backend/src/categories/dto/category.dto.js +128 -0
  46. package/dist/temp/Terred-Mujtaba-/apps/backend/src/cloudinary/cloudinary.controller.js +86 -0
  47. package/dist/temp/Terred-Mujtaba-/apps/backend/src/cloudinary/cloudinary.controller.spec.js +18 -0
  48. package/dist/temp/Terred-Mujtaba-/apps/backend/src/cloudinary/cloudinary.module.js +63 -0
  49. package/dist/temp/Terred-Mujtaba-/apps/backend/src/cloudinary/cloudinary.service.js +132 -0
  50. package/dist/temp/Terred-Mujtaba-/apps/backend/src/cloudinary/cloudinary.service.spec.js +16 -0
  51. package/dist/temp/Terred-Mujtaba-/apps/backend/src/config/index.js +2 -0
  52. package/dist/temp/Terred-Mujtaba-/apps/backend/src/main.js +30 -0
  53. package/dist/temp/Terred-Mujtaba-/apps/backend/src/prisma/prisma.module.js +60 -0
  54. package/dist/temp/Terred-Mujtaba-/apps/backend/src/prisma/prisma.service.js +58 -0
  55. package/dist/temp/Terred-Mujtaba-/apps/backend/src/prisma/prisma.service.spec.js +16 -0
  56. package/dist/temp/Terred-Mujtaba-/apps/backend/src/products/dto/product.dto.js +124 -0
  57. package/dist/temp/Terred-Mujtaba-/apps/backend/src/products/products.controller.js +89 -0
  58. package/dist/temp/Terred-Mujtaba-/apps/backend/src/products/products.controller.spec.js +18 -0
  59. package/dist/temp/Terred-Mujtaba-/apps/backend/src/products/products.module.js +64 -0
  60. package/dist/temp/Terred-Mujtaba-/apps/backend/src/products/products.service.js +170 -0
  61. package/dist/temp/Terred-Mujtaba-/apps/backend/src/products/products.service.spec.js +16 -0
  62. package/dist/temp/Terred-Mujtaba-/apps/backend/src/types/index.js +2 -0
  63. package/dist/temp/Terred-Mujtaba-/apps/backend/src/utils/func.js +79 -0
  64. package/dist/temp/Terred-Mujtaba-/apps/backend/src/utils/helper.js +31 -0
  65. package/dist/temp/Terred-Mujtaba-/apps/backend/test/app.e2e-spec.js +54 -0
  66. package/dist/temp/Terred-Mujtaba-/packages/ui/turbo/generators/config.js +30 -0
  67. package/package.json +47 -0
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.AppModule = void 0;
38
+ const common_1 = require("@nestjs/common");
39
+ const app_controller_1 = require("./app.controller");
40
+ const app_service_1 = require("./app.service");
41
+ const prisma_module_1 = require("./prisma/prisma.module");
42
+ const products_module_1 = require("./products/products.module");
43
+ const categories_module_1 = require("./categories/categories.module");
44
+ const admin_module_1 = require("./admin/admin.module");
45
+ const cloudinary_module_1 = require("./cloudinary/cloudinary.module");
46
+ let AppModule = (() => {
47
+ let _classDecorators = [(0, common_1.Module)({
48
+ imports: [prisma_module_1.PrismaModule, products_module_1.ProductsModule, categories_module_1.CategoriesModule, admin_module_1.AdminModule, cloudinary_module_1.CloudinaryModule],
49
+ controllers: [app_controller_1.AppController],
50
+ providers: [app_service_1.AppService],
51
+ })];
52
+ let _classDescriptor;
53
+ let _classExtraInitializers = [];
54
+ let _classThis;
55
+ var AppModule = class {
56
+ static { _classThis = this; }
57
+ static {
58
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
59
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
60
+ AppModule = _classThis = _classDescriptor.value;
61
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
62
+ __runInitializers(_classThis, _classExtraInitializers);
63
+ }
64
+ };
65
+ return AppModule = _classThis;
66
+ })();
67
+ exports.AppModule = AppModule;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.AppService = void 0;
38
+ const common_1 = require("@nestjs/common");
39
+ let AppService = (() => {
40
+ let _classDecorators = [(0, common_1.Injectable)()];
41
+ let _classDescriptor;
42
+ let _classExtraInitializers = [];
43
+ let _classThis;
44
+ var AppService = class {
45
+ static { _classThis = this; }
46
+ static {
47
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
48
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
49
+ AppService = _classThis = _classDescriptor.value;
50
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
51
+ __runInitializers(_classThis, _classExtraInitializers);
52
+ }
53
+ getHello() {
54
+ console.log('Runnning...');
55
+ return 'Hello World!';
56
+ }
57
+ };
58
+ return AppService = _classThis;
59
+ })();
60
+ exports.AppService = AppService;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
3
+ var useValue = arguments.length > 2;
4
+ for (var i = 0; i < initializers.length; i++) {
5
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
6
+ }
7
+ return useValue ? value : void 0;
8
+ };
9
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
10
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
11
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
12
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
13
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
14
+ var _, done = false;
15
+ for (var i = decorators.length - 1; i >= 0; i--) {
16
+ var context = {};
17
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
18
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
19
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
20
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
21
+ if (kind === "accessor") {
22
+ if (result === void 0) continue;
23
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
24
+ if (_ = accept(result.get)) descriptor.get = _;
25
+ if (_ = accept(result.set)) descriptor.set = _;
26
+ if (_ = accept(result.init)) initializers.unshift(_);
27
+ }
28
+ else if (_ = accept(result)) {
29
+ if (kind === "field") initializers.unshift(_);
30
+ else descriptor[key] = _;
31
+ }
32
+ }
33
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
34
+ done = true;
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.CategoriesController = void 0;
38
+ const common_1 = require("@nestjs/common");
39
+ let CategoriesController = (() => {
40
+ let _classDecorators = [(0, common_1.Controller)('category')];
41
+ let _classDescriptor;
42
+ let _classExtraInitializers = [];
43
+ let _classThis;
44
+ let _instanceExtraInitializers = [];
45
+ let _getCategories_decorators;
46
+ let _addCategory_decorators;
47
+ let _updateCategory_decorators;
48
+ let _removeCategory_decorators;
49
+ var CategoriesController = class {
50
+ static { _classThis = this; }
51
+ static {
52
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
53
+ _getCategories_decorators = [(0, common_1.Get)('/get-all')];
54
+ _addCategory_decorators = [(0, common_1.Post)('add-category')];
55
+ _updateCategory_decorators = [(0, common_1.Post)('update-category')];
56
+ _removeCategory_decorators = [(0, common_1.Delete)('delete-category')];
57
+ __esDecorate(this, null, _getCategories_decorators, { kind: "method", name: "getCategories", static: false, private: false, access: { has: obj => "getCategories" in obj, get: obj => obj.getCategories }, metadata: _metadata }, null, _instanceExtraInitializers);
58
+ __esDecorate(this, null, _addCategory_decorators, { kind: "method", name: "addCategory", static: false, private: false, access: { has: obj => "addCategory" in obj, get: obj => obj.addCategory }, metadata: _metadata }, null, _instanceExtraInitializers);
59
+ __esDecorate(this, null, _updateCategory_decorators, { kind: "method", name: "updateCategory", static: false, private: false, access: { has: obj => "updateCategory" in obj, get: obj => obj.updateCategory }, metadata: _metadata }, null, _instanceExtraInitializers);
60
+ __esDecorate(this, null, _removeCategory_decorators, { kind: "method", name: "removeCategory", static: false, private: false, access: { has: obj => "removeCategory" in obj, get: obj => obj.removeCategory }, metadata: _metadata }, null, _instanceExtraInitializers);
61
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
62
+ CategoriesController = _classThis = _classDescriptor.value;
63
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
64
+ __runInitializers(_classThis, _classExtraInitializers);
65
+ }
66
+ categoriesService = __runInitializers(this, _instanceExtraInitializers);
67
+ constructor(categoriesService) {
68
+ this.categoriesService = categoriesService;
69
+ }
70
+ getCategories() {
71
+ return this.categoriesService.getCategories();
72
+ }
73
+ addCategory(addCategoryData) {
74
+ return this.categoriesService.addCategory(addCategoryData);
75
+ }
76
+ updateCategory(addCategoryData) {
77
+ return this.categoriesService.updateCategory(addCategoryData);
78
+ }
79
+ async removeCategory(categoryId) {
80
+ const id = parseInt(categoryId, 10);
81
+ if (isNaN(id)) {
82
+ return { message: 'Invalid product ID', status: common_1.HttpStatus.BAD_REQUEST };
83
+ }
84
+ return this.categoriesService.removeCategory(id);
85
+ }
86
+ };
87
+ return CategoriesController = _classThis;
88
+ })();
89
+ exports.CategoriesController = CategoriesController;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const testing_1 = require("@nestjs/testing");
4
+ const categories_controller_1 = require("./categories.controller");
5
+ const categories_service_1 = require("./categories.service");
6
+ describe('CategoriesController', () => {
7
+ let controller;
8
+ beforeEach(async () => {
9
+ const module = await testing_1.Test.createTestingModule({
10
+ controllers: [categories_controller_1.CategoriesController],
11
+ providers: [categories_service_1.CategoriesService],
12
+ }).compile();
13
+ controller = module.get(categories_controller_1.CategoriesController);
14
+ });
15
+ it('should be defined', () => {
16
+ expect(controller).toBeDefined();
17
+ });
18
+ });
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.CategoriesModule = void 0;
38
+ const common_1 = require("@nestjs/common");
39
+ const categories_service_1 = require("./categories.service");
40
+ const categories_controller_1 = require("./categories.controller");
41
+ const config_1 = require("@nestjs/config");
42
+ const prisma_module_1 = require("../prisma/prisma.module");
43
+ let CategoriesModule = (() => {
44
+ let _classDecorators = [(0, common_1.Module)({
45
+ controllers: [categories_controller_1.CategoriesController],
46
+ providers: [categories_service_1.CategoriesService],
47
+ imports: [prisma_module_1.PrismaModule, config_1.ConfigModule],
48
+ })];
49
+ let _classDescriptor;
50
+ let _classExtraInitializers = [];
51
+ let _classThis;
52
+ var CategoriesModule = class {
53
+ static { _classThis = this; }
54
+ static {
55
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
56
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
57
+ CategoriesModule = _classThis = _classDescriptor.value;
58
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
59
+ __runInitializers(_classThis, _classExtraInitializers);
60
+ }
61
+ };
62
+ return CategoriesModule = _classThis;
63
+ })();
64
+ exports.CategoriesModule = CategoriesModule;
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.CategoriesService = void 0;
38
+ const common_1 = require("@nestjs/common");
39
+ const helper_1 = require("../utils/helper");
40
+ let CategoriesService = (() => {
41
+ let _classDecorators = [(0, common_1.Injectable)()];
42
+ let _classDescriptor;
43
+ let _classExtraInitializers = [];
44
+ let _classThis;
45
+ var CategoriesService = class {
46
+ static { _classThis = this; }
47
+ static {
48
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
49
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
50
+ CategoriesService = _classThis = _classDescriptor.value;
51
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
52
+ __runInitializers(_classThis, _classExtraInitializers);
53
+ }
54
+ prisma;
55
+ constructor(prisma) {
56
+ this.prisma = prisma;
57
+ }
58
+ getCategories() {
59
+ try {
60
+ return this.prisma.categories.findMany({});
61
+ }
62
+ catch (error) {
63
+ throw new common_1.HttpException(error.message, common_1.HttpStatus.NOT_FOUND);
64
+ }
65
+ }
66
+ async addCategory(categoryData) {
67
+ console.log('Update category triggered');
68
+ console.log(categoryData);
69
+ try {
70
+ const { name } = categoryData;
71
+ const existingCategory = await this.prisma.categories.findFirst({
72
+ where: { name },
73
+ });
74
+ if (existingCategory) {
75
+ return {
76
+ message: 'Already exist!',
77
+ status: common_1.HttpStatus.FORBIDDEN,
78
+ };
79
+ }
80
+ await this.prisma.categories.create({
81
+ data: {
82
+ ...categoryData,
83
+ posterImageUrl: categoryData.posterImageUrl.imageUrl ?? null,
84
+ posterImagePublicId: categoryData.posterImageUrl.public_id ?? null,
85
+ },
86
+ });
87
+ return {
88
+ message: 'Category Created successfully🎉',
89
+ status: common_1.HttpStatus.OK,
90
+ };
91
+ }
92
+ catch (error) {
93
+ (0, helper_1.customHttpException)(error.message, 'BAD_REQUEST');
94
+ }
95
+ }
96
+ async updateCategory(categoryData) {
97
+ console.log('Update category triggered');
98
+ console.log(categoryData);
99
+ try {
100
+ const { id, name } = categoryData;
101
+ // Find the existing category by id
102
+ const existingCategory = await this.prisma.categories.findFirst({
103
+ where: { id },
104
+ });
105
+ if (!existingCategory) {
106
+ return {
107
+ message: 'Category not found!',
108
+ status: common_1.HttpStatus.NOT_FOUND,
109
+ };
110
+ }
111
+ // Check if the name already exists and is not the current category
112
+ const existingCategoryByName = await this.prisma.categories.findFirst({
113
+ where: {
114
+ name,
115
+ id: { not: id },
116
+ },
117
+ });
118
+ if (existingCategoryByName) {
119
+ return {
120
+ message: 'Category name already exists!',
121
+ status: common_1.HttpStatus.CONFLICT,
122
+ };
123
+ }
124
+ // Update category with new data or fallback to existing data
125
+ await this.prisma.categories.update({
126
+ where: { id },
127
+ data: {
128
+ name: name ?? existingCategory.name,
129
+ description: categoryData.description ?? existingCategory.description,
130
+ posterImageUrl: categoryData.posterImageUrl?.imageUrl ??
131
+ existingCategory.posterImageUrl ??
132
+ null,
133
+ posterImagePublicId: categoryData.posterImageUrl?.public_id ??
134
+ existingCategory.posterImagePublicId ??
135
+ null,
136
+ },
137
+ });
138
+ return {
139
+ message: 'Category updated successfully 🎉',
140
+ status: common_1.HttpStatus.OK,
141
+ };
142
+ }
143
+ catch (error) {
144
+ (0, helper_1.customHttpException)(error.message, 'BAD_REQUEST');
145
+ }
146
+ }
147
+ async removeCategory(id) {
148
+ try {
149
+ const cateoryExist = await this.prisma.categories.findUnique({
150
+ where: { id },
151
+ });
152
+ if (!cateoryExist) {
153
+ return {
154
+ message: 'Category does not exist ☹',
155
+ status: common_1.HttpStatus.NOT_FOUND,
156
+ };
157
+ }
158
+ await this.prisma.categories.delete({
159
+ where: { id },
160
+ });
161
+ return {
162
+ message: 'Category removed successfully 😊',
163
+ status: common_1.HttpStatus.OK,
164
+ };
165
+ }
166
+ catch (error) {
167
+ (0, helper_1.customHttpException)(error.message, 'BAD_REQUEST');
168
+ }
169
+ }
170
+ };
171
+ return CategoriesService = _classThis;
172
+ })();
173
+ exports.CategoriesService = CategoriesService;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const testing_1 = require("@nestjs/testing");
4
+ const categories_service_1 = require("./categories.service");
5
+ describe('CategoriesService', () => {
6
+ let service;
7
+ beforeEach(async () => {
8
+ const module = await testing_1.Test.createTestingModule({
9
+ providers: [categories_service_1.CategoriesService],
10
+ }).compile();
11
+ service = module.get(categories_service_1.CategoriesService);
12
+ });
13
+ it('should be defined', () => {
14
+ expect(service).toBeDefined();
15
+ });
16
+ });
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.UpdateCategoryDto = exports.AddCategoryDto = void 0;
38
+ const class_transformer_1 = require("class-transformer");
39
+ const class_validator_1 = require("class-validator");
40
+ let ImageDto = (() => {
41
+ let _imageUrl_decorators;
42
+ let _imageUrl_initializers = [];
43
+ let _imageUrl_extraInitializers = [];
44
+ let _public_id_decorators;
45
+ let _public_id_initializers = [];
46
+ let _public_id_extraInitializers = [];
47
+ return class ImageDto {
48
+ static {
49
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
50
+ _imageUrl_decorators = [(0, class_validator_1.IsOptional)(), (0, class_validator_1.IsString)()];
51
+ _public_id_decorators = [(0, class_validator_1.IsOptional)(), (0, class_validator_1.IsString)()];
52
+ __esDecorate(null, null, _imageUrl_decorators, { kind: "field", name: "imageUrl", static: false, private: false, access: { has: obj => "imageUrl" in obj, get: obj => obj.imageUrl, set: (obj, value) => { obj.imageUrl = value; } }, metadata: _metadata }, _imageUrl_initializers, _imageUrl_extraInitializers);
53
+ __esDecorate(null, null, _public_id_decorators, { kind: "field", name: "public_id", static: false, private: false, access: { has: obj => "public_id" in obj, get: obj => obj.public_id, set: (obj, value) => { obj.public_id = value; } }, metadata: _metadata }, _public_id_initializers, _public_id_extraInitializers);
54
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
55
+ }
56
+ imageUrl = __runInitializers(this, _imageUrl_initializers, void 0);
57
+ public_id = (__runInitializers(this, _imageUrl_extraInitializers), __runInitializers(this, _public_id_initializers, void 0));
58
+ constructor() {
59
+ __runInitializers(this, _public_id_extraInitializers);
60
+ }
61
+ };
62
+ })();
63
+ let AddCategoryDto = (() => {
64
+ let _name_decorators;
65
+ let _name_initializers = [];
66
+ let _name_extraInitializers = [];
67
+ let _description_decorators;
68
+ let _description_initializers = [];
69
+ let _description_extraInitializers = [];
70
+ let _posterImageUrl_decorators;
71
+ let _posterImageUrl_initializers = [];
72
+ let _posterImageUrl_extraInitializers = [];
73
+ return class AddCategoryDto {
74
+ static {
75
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
76
+ _name_decorators = [(0, class_validator_1.IsNotEmpty)(), (0, class_validator_1.IsString)()];
77
+ _description_decorators = [(0, class_validator_1.IsNotEmpty)(), (0, class_validator_1.IsString)()];
78
+ _posterImageUrl_decorators = [(0, class_validator_1.IsOptional)(), (0, class_validator_1.ValidateNested)(), (0, class_transformer_1.Type)(() => ImageDto)];
79
+ __esDecorate(null, null, _name_decorators, { kind: "field", name: "name", static: false, private: false, access: { has: obj => "name" in obj, get: obj => obj.name, set: (obj, value) => { obj.name = value; } }, metadata: _metadata }, _name_initializers, _name_extraInitializers);
80
+ __esDecorate(null, null, _description_decorators, { kind: "field", name: "description", static: false, private: false, access: { has: obj => "description" in obj, get: obj => obj.description, set: (obj, value) => { obj.description = value; } }, metadata: _metadata }, _description_initializers, _description_extraInitializers);
81
+ __esDecorate(null, null, _posterImageUrl_decorators, { kind: "field", name: "posterImageUrl", static: false, private: false, access: { has: obj => "posterImageUrl" in obj, get: obj => obj.posterImageUrl, set: (obj, value) => { obj.posterImageUrl = value; } }, metadata: _metadata }, _posterImageUrl_initializers, _posterImageUrl_extraInitializers);
82
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
83
+ }
84
+ name = __runInitializers(this, _name_initializers, void 0);
85
+ description = (__runInitializers(this, _name_extraInitializers), __runInitializers(this, _description_initializers, void 0));
86
+ posterImageUrl = (__runInitializers(this, _description_extraInitializers), __runInitializers(this, _posterImageUrl_initializers, void 0));
87
+ constructor() {
88
+ __runInitializers(this, _posterImageUrl_extraInitializers);
89
+ }
90
+ };
91
+ })();
92
+ exports.AddCategoryDto = AddCategoryDto;
93
+ let UpdateCategoryDto = (() => {
94
+ let _id_decorators;
95
+ let _id_initializers = [];
96
+ let _id_extraInitializers = [];
97
+ let _name_decorators;
98
+ let _name_initializers = [];
99
+ let _name_extraInitializers = [];
100
+ let _description_decorators;
101
+ let _description_initializers = [];
102
+ let _description_extraInitializers = [];
103
+ let _posterImageUrl_decorators;
104
+ let _posterImageUrl_initializers = [];
105
+ let _posterImageUrl_extraInitializers = [];
106
+ return class UpdateCategoryDto {
107
+ static {
108
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
109
+ _id_decorators = [(0, class_validator_1.IsNotEmpty)(), (0, class_validator_1.IsNumber)()];
110
+ _name_decorators = [(0, class_validator_1.IsNotEmpty)(), (0, class_validator_1.IsString)()];
111
+ _description_decorators = [(0, class_validator_1.IsNotEmpty)(), (0, class_validator_1.IsString)()];
112
+ _posterImageUrl_decorators = [(0, class_validator_1.IsOptional)()];
113
+ __esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
114
+ __esDecorate(null, null, _name_decorators, { kind: "field", name: "name", static: false, private: false, access: { has: obj => "name" in obj, get: obj => obj.name, set: (obj, value) => { obj.name = value; } }, metadata: _metadata }, _name_initializers, _name_extraInitializers);
115
+ __esDecorate(null, null, _description_decorators, { kind: "field", name: "description", static: false, private: false, access: { has: obj => "description" in obj, get: obj => obj.description, set: (obj, value) => { obj.description = value; } }, metadata: _metadata }, _description_initializers, _description_extraInitializers);
116
+ __esDecorate(null, null, _posterImageUrl_decorators, { kind: "field", name: "posterImageUrl", static: false, private: false, access: { has: obj => "posterImageUrl" in obj, get: obj => obj.posterImageUrl, set: (obj, value) => { obj.posterImageUrl = value; } }, metadata: _metadata }, _posterImageUrl_initializers, _posterImageUrl_extraInitializers);
117
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
118
+ }
119
+ id = __runInitializers(this, _id_initializers, void 0);
120
+ name = (__runInitializers(this, _id_extraInitializers), __runInitializers(this, _name_initializers, void 0));
121
+ description = (__runInitializers(this, _name_extraInitializers), __runInitializers(this, _description_initializers, void 0));
122
+ posterImageUrl = (__runInitializers(this, _description_extraInitializers), __runInitializers(this, _posterImageUrl_initializers, void 0));
123
+ constructor() {
124
+ __runInitializers(this, _posterImageUrl_extraInitializers);
125
+ }
126
+ };
127
+ })();
128
+ exports.UpdateCategoryDto = UpdateCategoryDto;