@merkaly/api 0.2.4-7 → 0.2.4-9

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 (273) hide show
  1. package/.output/abstract/abstract.entity.d.ts +1 -1
  2. package/.output/abstract/abstract.exception.d.ts +11 -0
  3. package/.output/abstract/abstract.exception.js +53 -0
  4. package/.output/exceptions/missing-identity.exception.d.ts +5 -0
  5. package/.output/{modules/setting/organization/organization.entity.js → exceptions/missing-identity.exception.js} +12 -10
  6. package/.output/exceptions/store-not-implemented.exception.d.ts +5 -0
  7. package/.output/exceptions/store-not-implemented.exception.js +31 -0
  8. package/.output/exceptions/store-not-recognized.exception.d.ts +5 -0
  9. package/.output/exceptions/store-not-recognized.exception.js +30 -0
  10. package/.output/modules/inventory/brands/brand.exception.d.ts +5 -0
  11. package/.output/modules/{setting/theme/theme.entity.js → inventory/brands/brand.exception.js} +15 -21
  12. package/.output/modules/inventory/categories/category.exception.d.ts +5 -0
  13. package/.output/modules/{setting/layout/layout.entity.js → inventory/categories/category.exception.js} +15 -21
  14. package/.output/modules/inventory/products/product.entity.d.ts +1 -0
  15. package/.output/modules/inventory/products/product.exception.d.ts +5 -0
  16. package/.output/modules/inventory/products/{entities/price.entity.js → product.exception.js} +15 -24
  17. package/.output/modules/inventory/products/product.validator.d.ts +2 -1
  18. package/.output/modules/inventory/products/product.validator.js +7 -0
  19. package/.output/modules/inventory/properties/property.exception.d.ts +5 -0
  20. package/.output/modules/inventory/{brands/brand.entity.js → properties/property.exception.js} +15 -25
  21. package/.output/modules/sales/clients/client.exception.d.ts +5 -0
  22. package/.output/modules/sales/clients/client.exception.js +40 -0
  23. package/.output/modules/sales/orders/order.exception.d.ts +13 -0
  24. package/.output/modules/sales/orders/order.exception.js +46 -0
  25. package/.output/services/logger.service.d.ts +11 -0
  26. package/.output/services/logger.service.js +54 -0
  27. package/.output/types.d.ts +4 -1
  28. package/package.json +2 -3
  29. package/.DS_Store +0 -0
  30. package/.bin/deploy.sh +0 -9
  31. package/.bin/package.sh +0 -7
  32. package/.docker/Dockerfile +0 -21
  33. package/.dockerignore +0 -12
  34. package/.env +0 -21
  35. package/.eslintignore +0 -8
  36. package/.eslintrc.js +0 -35
  37. package/.github/dependabot.yml +0 -17
  38. package/.github/semantic.yml +0 -5
  39. package/.github/workflows/pull_request.yml +0 -35
  40. package/.gitignore +0 -42
  41. package/.husky/.gitignore +0 -1
  42. package/.husky/commit-msg +0 -5
  43. package/.husky/common.sh +0 -8
  44. package/.husky/pre-commit +0 -5
  45. package/.husky/pre-push +0 -4
  46. package/.idea/.gitignore +0 -5
  47. package/.idea/api.iml +0 -13
  48. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  49. package/.idea/inspectionProfiles/Project_Default.xml +0 -11
  50. package/.idea/modules.xml +0 -8
  51. package/.idea/vcs.xml +0 -12
  52. package/.idea/workspace.xml +0 -2320
  53. package/.output/abstract/abstract.entity.js +0 -53
  54. package/.output/modules/assets/asset.entity.js +0 -69
  55. package/.output/modules/content/banners/banner.entity.js +0 -54
  56. package/.output/modules/content/pages/page.entity.js +0 -69
  57. package/.output/modules/inventory/categories/category.entity.js +0 -61
  58. package/.output/modules/inventory/products/entities/code.entity.js +0 -53
  59. package/.output/modules/inventory/products/entities/dimension.entity.js +0 -57
  60. package/.output/modules/inventory/products/entities/seo.entity.js +0 -53
  61. package/.output/modules/inventory/products/product.entity.js +0 -101
  62. package/.output/modules/inventory/properties/property.entity.js +0 -55
  63. package/.output/modules/sales/clients/client.entity.js +0 -64
  64. package/.output/modules/sales/orders/billing/billing.entity.js +0 -64
  65. package/.output/modules/sales/orders/billing/entities/address.entity.js +0 -68
  66. package/.output/modules/sales/orders/billing/entities/customer.entity.js +0 -52
  67. package/.output/modules/sales/orders/billing/entities/status.entity.js +0 -37
  68. package/.output/modules/sales/orders/customer/customer.entity.js +0 -52
  69. package/.output/modules/sales/orders/item/item.entity.js +0 -58
  70. package/.output/modules/sales/orders/order.entity.js +0 -89
  71. package/.output/modules/sales/orders/shipping/entities/address.entity.js +0 -68
  72. package/.output/modules/sales/orders/shipping/entities/customer.entity.js +0 -52
  73. package/.output/modules/sales/orders/shipping/entities/status.entity.js +0 -37
  74. package/.output/modules/sales/orders/shipping/shipping.entity.js +0 -68
  75. package/.output/modules/sales/orders/status/status.entity.js +0 -37
  76. package/authCertificate.pem +0 -19
  77. package/cloudbuild.yaml +0 -20
  78. package/commitlint.config.js +0 -3
  79. package/jest.config.js +0 -14
  80. package/merkaly-api-0.2.4-6.tgz +0 -0
  81. package/nest-cli.json +0 -9
  82. package/serviceAccount.json +0 -7
  83. package/src/abstract/absctract.listener.ts +0 -2
  84. package/src/abstract/abstract.controller.ts +0 -27
  85. package/src/abstract/abstract.entity.ts +0 -19
  86. package/src/abstract/abstract.exception.ts +0 -56
  87. package/src/abstract/abstract.fixture.ts +0 -7
  88. package/src/abstract/abstract.migration.ts +0 -13
  89. package/src/abstract/abstract.repository.ts +0 -79
  90. package/src/abstract/abstract.router.ts +0 -7
  91. package/src/abstract/abstract.validator.ts +0 -62
  92. package/src/app.config.ts +0 -57
  93. package/src/app.console.ts +0 -30
  94. package/src/app.controller.ts +0 -48
  95. package/src/app.migration.ts +0 -7
  96. package/src/app.module.ts +0 -92
  97. package/src/app.strategy.ts +0 -25
  98. package/src/commands/assets.command.ts +0 -38
  99. package/src/commands/deploy.command.ts +0 -6
  100. package/src/commands/fixture.command.ts +0 -11
  101. package/src/commands/generate.command.ts +0 -286
  102. package/src/decorators/public.decorator.ts +0 -5
  103. package/src/decorators/user.decorator.ts +0 -21
  104. package/src/exceptions/missing-identity.exception.ts +0 -11
  105. package/src/exceptions/store-not-implemented.exception.ts +0 -13
  106. package/src/exceptions/store-not-recognized.exception.ts +0 -11
  107. package/src/guards/auth.guard.ts +0 -43
  108. package/src/guards/organization.guard.ts +0 -39
  109. package/src/interceptors/mongo.interceptor.ts +0 -16
  110. package/src/main.ts +0 -37
  111. package/src/middlewares/logger.middleware.ts +0 -15
  112. package/src/middlewares/organization.middleware.ts +0 -76
  113. package/src/migrations/1667226478717-product_price_enhance.ts +0 -29
  114. package/src/migrations/1667329249561-product_add_seo_code_dimension.ts +0 -37
  115. package/src/migrations/1667601099139-product_activve_and_hashtag.ts +0 -35
  116. package/src/migrations/1668136428972-content_banners-use-as-image.ts +0 -56
  117. package/src/migrations/1680483744321-order-billing-shipping-status.ts +0 -32
  118. package/src/modules/assets/asset.controller.ts +0 -33
  119. package/src/modules/assets/asset.entity.ts +0 -26
  120. package/src/modules/assets/asset.module.ts +0 -21
  121. package/src/modules/assets/asset.repository.ts +0 -51
  122. package/src/modules/assets/asset.schema.ts +0 -4
  123. package/src/modules/assets/asset.service.ts +0 -41
  124. package/src/modules/auth/auth.controller.ts +0 -42
  125. package/src/modules/auth/auth.module.ts +0 -18
  126. package/src/modules/auth/logout.ts +0 -0
  127. package/src/modules/command.module.ts +0 -19
  128. package/src/modules/content/banners/banner.controller.ts +0 -56
  129. package/src/modules/content/banners/banner.entity.ts +0 -17
  130. package/src/modules/content/banners/banner.fixture.ts +0 -19
  131. package/src/modules/content/banners/banner.listener.ts +0 -6
  132. package/src/modules/content/banners/banner.module.ts +0 -21
  133. package/src/modules/content/banners/banner.repository.ts +0 -38
  134. package/src/modules/content/banners/banner.schema.ts +0 -4
  135. package/src/modules/content/banners/banner.types.ts +0 -7
  136. package/src/modules/content/banners/banner.validator.ts +0 -19
  137. package/src/modules/content/content.module.ts +0 -20
  138. package/src/modules/content/pages/page.controller.ts +0 -53
  139. package/src/modules/content/pages/page.entity.ts +0 -27
  140. package/src/modules/content/pages/page.fixture.ts +0 -19
  141. package/src/modules/content/pages/page.listener.ts +0 -6
  142. package/src/modules/content/pages/page.module.ts +0 -21
  143. package/src/modules/content/pages/page.repository.ts +0 -44
  144. package/src/modules/content/pages/page.schema.ts +0 -4
  145. package/src/modules/content/pages/page.types.ts +0 -9
  146. package/src/modules/content/pages/page.validator.ts +0 -29
  147. package/src/modules/global.module.ts +0 -70
  148. package/src/modules/insight/controllers/address.controller.ts +0 -29
  149. package/src/modules/insight/controllers/order.controller.ts +0 -70
  150. package/src/modules/insight/controllers/products.controller.ts +0 -18
  151. package/src/modules/insight/insight.module.ts +0 -24
  152. package/src/modules/insight/validators/order.validator.ts +0 -10
  153. package/src/modules/inventory/brands/brand.controller.ts +0 -59
  154. package/src/modules/inventory/brands/brand.entity.ts +0 -14
  155. package/src/modules/inventory/brands/brand.exception.ts +0 -9
  156. package/src/modules/inventory/brands/brand.listener.ts +0 -18
  157. package/src/modules/inventory/brands/brand.module.ts +0 -19
  158. package/src/modules/inventory/brands/brand.repository.ts +0 -39
  159. package/src/modules/inventory/brands/brand.schema.ts +0 -4
  160. package/src/modules/inventory/brands/brand.validator.ts +0 -23
  161. package/src/modules/inventory/categories/category.controller.ts +0 -59
  162. package/src/modules/inventory/categories/category.entity.ts +0 -21
  163. package/src/modules/inventory/categories/category.exception.ts +0 -9
  164. package/src/modules/inventory/categories/category.fixture.ts +0 -18
  165. package/src/modules/inventory/categories/category.listener.ts +0 -17
  166. package/src/modules/inventory/categories/category.module.ts +0 -19
  167. package/src/modules/inventory/categories/category.repository.ts +0 -40
  168. package/src/modules/inventory/categories/category.schema.ts +0 -4
  169. package/src/modules/inventory/categories/category.validator.ts +0 -30
  170. package/src/modules/inventory/inventory.module.ts +0 -22
  171. package/src/modules/inventory/products/entities/code.entity.ts +0 -15
  172. package/src/modules/inventory/products/entities/dimension.entity.ts +0 -18
  173. package/src/modules/inventory/products/entities/price.entity.ts +0 -12
  174. package/src/modules/inventory/products/entities/seo.entity.ts +0 -15
  175. package/src/modules/inventory/products/product.controller.ts +0 -59
  176. package/src/modules/inventory/products/product.entity.ts +0 -53
  177. package/src/modules/inventory/products/product.exception.ts +0 -9
  178. package/src/modules/inventory/products/product.fixture.ts +0 -19
  179. package/src/modules/inventory/products/product.listener.ts +0 -27
  180. package/src/modules/inventory/products/product.module.ts +0 -20
  181. package/src/modules/inventory/products/product.repository.ts +0 -108
  182. package/src/modules/inventory/products/product.schema.ts +0 -15
  183. package/src/modules/inventory/products/product.validator.ts +0 -71
  184. package/src/modules/inventory/products/validators/code.validator.ts +0 -15
  185. package/src/modules/inventory/products/validators/dimension.validator.ts +0 -19
  186. package/src/modules/inventory/products/validators/price.validator.ts +0 -10
  187. package/src/modules/inventory/products/validators/seo.validator.ts +0 -15
  188. package/src/modules/inventory/properties/property.controller.ts +0 -56
  189. package/src/modules/inventory/properties/property.entity.ts +0 -18
  190. package/src/modules/inventory/properties/property.exception.ts +0 -9
  191. package/src/modules/inventory/properties/property.listener.ts +0 -20
  192. package/src/modules/inventory/properties/property.module.ts +0 -21
  193. package/src/modules/inventory/properties/property.repository.ts +0 -23
  194. package/src/modules/inventory/properties/property.schema.ts +0 -4
  195. package/src/modules/inventory/properties/property.validator.ts +0 -27
  196. package/src/modules/sales/clients/client.controller.ts +0 -60
  197. package/src/modules/sales/clients/client.entity.ts +0 -25
  198. package/src/modules/sales/clients/client.exception.ts +0 -9
  199. package/src/modules/sales/clients/client.listener.ts +0 -20
  200. package/src/modules/sales/clients/client.module.ts +0 -19
  201. package/src/modules/sales/clients/client.repository.ts +0 -37
  202. package/src/modules/sales/clients/client.schema.ts +0 -4
  203. package/src/modules/sales/clients/client.validator.ts +0 -43
  204. package/src/modules/sales/orders/billing/billing.entity.ts +0 -22
  205. package/src/modules/sales/orders/billing/billing.types.ts +0 -10
  206. package/src/modules/sales/orders/billing/billing.validator.ts +0 -21
  207. package/src/modules/sales/orders/billing/entities/address.entity.ts +0 -27
  208. package/src/modules/sales/orders/billing/entities/customer.entity.ts +0 -14
  209. package/src/modules/sales/orders/billing/entities/status.entity.ts +0 -16
  210. package/src/modules/sales/orders/billing/validators/address.validator.ts +0 -28
  211. package/src/modules/sales/orders/billing/validators/customer.validator.ts +0 -14
  212. package/src/modules/sales/orders/customer/customer.entity.ts +0 -14
  213. package/src/modules/sales/orders/customer/customer.validator.ts +0 -14
  214. package/src/modules/sales/orders/item/item.entity.ts +0 -21
  215. package/src/modules/sales/orders/item/item.schema.ts +0 -8
  216. package/src/modules/sales/orders/item/item.validator.ts +0 -10
  217. package/src/modules/sales/orders/order.controller.ts +0 -93
  218. package/src/modules/sales/orders/order.entity.ts +0 -47
  219. package/src/modules/sales/orders/order.listener.ts +0 -20
  220. package/src/modules/sales/orders/order.module.ts +0 -19
  221. package/src/modules/sales/orders/order.repository.ts +0 -189
  222. package/src/modules/sales/orders/order.schema.ts +0 -35
  223. package/src/modules/sales/orders/order.validator.ts +0 -72
  224. package/src/modules/sales/orders/shipping/entities/address.entity.ts +0 -27
  225. package/src/modules/sales/orders/shipping/entities/customer.entity.ts +0 -14
  226. package/src/modules/sales/orders/shipping/entities/status.entity.ts +0 -16
  227. package/src/modules/sales/orders/shipping/shipping.entity.ts +0 -25
  228. package/src/modules/sales/orders/shipping/shipping.types.ts +0 -12
  229. package/src/modules/sales/orders/shipping/shipping.validator.ts +0 -25
  230. package/src/modules/sales/orders/shipping/validators/address.validator.ts +0 -28
  231. package/src/modules/sales/orders/shipping/validators/customer.validator.ts +0 -14
  232. package/src/modules/sales/orders/status/status.entity.ts +0 -16
  233. package/src/modules/sales/orders/status/status.validator.ts +0 -8
  234. package/src/modules/sales/sales.module.ts +0 -20
  235. package/src/modules/setting/connections/connection.controller.ts +0 -27
  236. package/src/modules/setting/connections/connection.module.ts +0 -17
  237. package/src/modules/setting/connections/connection.validator.ts +0 -15
  238. package/src/modules/setting/layout/layout.controller.ts +0 -34
  239. package/src/modules/setting/layout/layout.entity.ts +0 -13
  240. package/src/modules/setting/layout/layout.listener.ts +0 -7
  241. package/src/modules/setting/layout/layout.module.ts +0 -21
  242. package/src/modules/setting/layout/layout.repository.ts +0 -29
  243. package/src/modules/setting/layout/layout.schema.ts +0 -4
  244. package/src/modules/setting/members/member.controller.ts +0 -22
  245. package/src/modules/setting/members/member.module.ts +0 -17
  246. package/src/modules/setting/members/member.validator.ts +0 -3
  247. package/src/modules/setting/organization/organization.controller.ts +0 -33
  248. package/src/modules/setting/organization/organization.entity.ts +0 -27
  249. package/src/modules/setting/organization/organization.listener.ts +0 -46
  250. package/src/modules/setting/organization/organization.module.ts +0 -21
  251. package/src/modules/setting/organization/organization.repository.ts +0 -55
  252. package/src/modules/setting/organization/organization.types.ts +0 -65
  253. package/src/modules/setting/organization/organization.validator.ts +0 -56
  254. package/src/modules/setting/setting.module.ts +0 -23
  255. package/src/modules/setting/theme/theme.controller.ts +0 -34
  256. package/src/modules/setting/theme/theme.entity.ts +0 -13
  257. package/src/modules/setting/theme/theme.listener.ts +0 -6
  258. package/src/modules/setting/theme/theme.module.ts +0 -21
  259. package/src/modules/setting/theme/theme.repository.ts +0 -23
  260. package/src/modules/setting/theme/theme.schema.ts +0 -4
  261. package/src/modules/users/user.controller.ts +0 -75
  262. package/src/modules/users/user.module.ts +0 -20
  263. package/src/modules/users/user.validator.ts +0 -28
  264. package/src/providers/auth0.provider.ts +0 -36
  265. package/src/providers/storage.provider.ts +0 -22
  266. package/src/services/auth0.service.ts +0 -7
  267. package/src/services/logger.service.ts +0 -33
  268. package/src/services/mongo.service.ts +0 -44
  269. package/src/services/storage.service.ts +0 -39
  270. package/src/types.ts +0 -19
  271. package/tsconfig.json +0 -40
  272. package/tsconfig.package.json +0 -20
  273. package/yarn.lock +0 -8782
@@ -1,15 +0,0 @@
1
- import { Inject, Injectable, NestMiddleware } from '@nestjs/common';
2
- import { NextFunction, Request, Response } from 'express';
3
- import { LoggerService } from '../services/logger.service';
4
-
5
- @Injectable()
6
- export class LoggerMiddleware implements NestMiddleware {
7
- @Inject()
8
- protected readonly $logger: LoggerService;
9
-
10
- public use(req: Request, res: Response, next: NextFunction) {
11
- this.$logger.debug(req.originalUrl, req.method);
12
-
13
- return next();
14
- }
15
- }
@@ -1,76 +0,0 @@
1
- import { Inject, Injectable, NestMiddleware, OnModuleInit } from '@nestjs/common';
2
- import { Organization } from 'auth0';
3
- import { NextFunction, Request } from 'express';
4
- import { MissingIdentityException } from '../exceptions/missing-identity.exception';
5
- import { StoreNotImplementedException } from '../exceptions/store-not-implemented.exception';
6
- import { Auth0Service } from '../services/auth0.service';
7
- import { OrganizationListener } from "../modules/setting/organization/organization.listener";
8
-
9
- declare module 'http' {
10
- interface IncomingHttpHeaders {
11
- identity?: string;
12
- }
13
- }
14
-
15
- declare module 'express-session' {
16
- interface SessionData {
17
- organization?: Organization;
18
- }
19
- }
20
-
21
- @Injectable()
22
- export class OrganizationMiddleware implements NestMiddleware, OnModuleInit {
23
- public readonly organizations = [];
24
- @Inject()
25
- protected readonly $auth0: Auth0Service;
26
- protected readonly $event = new OrganizationListener();
27
- protected readonly allowedDomains = ['.store.merkaly.local', '.store.merkaly.io'];
28
-
29
- public async onModuleInit() {
30
- const organizations = await this.$auth0.organizations.getAll()
31
-
32
- for await (const organization of organizations) {
33
- this.organizations.push(this.$event.parseMetadata(organization))
34
- }
35
-
36
- return this.organizations
37
- }
38
-
39
- public async use(req: Request, res: Response, next: NextFunction) {
40
- const identity = String(req.headers.identity || req.query.identity);
41
-
42
- !identity && MissingIdentityException.throw();
43
-
44
- let org: Organization | undefined
45
-
46
- if (this.allowedDomains.some(dns => identity.endsWith(dns))) {
47
- const [name] = identity.split('.');
48
-
49
- org = this.organizations.find(org => org.name === name)
50
- }
51
-
52
- if (!org) {
53
- org = this.organizations.find((org) => {
54
- if (org.id === identity) {
55
- return org
56
- }
57
-
58
- if (org.name === identity) {
59
- return org
60
- }
61
-
62
- if (org.metadata?.domains?.includes(identity)) {
63
- return org
64
- }
65
- })
66
- }
67
-
68
- if (org) {
69
- req.session.organization = org
70
-
71
- return next()
72
- }
73
-
74
- return StoreNotImplementedException.throw(identity)
75
- }
76
- }
@@ -1,29 +0,0 @@
1
- import { UpdateQuery } from "mongoose";
2
- import { connect } from '../abstract/abstract.migration';
3
- import { ProductEntity } from "../modules/inventory/products/product.entity";
4
-
5
- /**
6
- * Make any changes you need to make to the database here
7
- */
8
- export const up = () => connect(async (connection) => {
9
- const productRepository = await connection.collection('inventory_products');
10
-
11
- const updateSentence: UpdateQuery<ProductEntity>[] = [
12
- { $set: { price: { sale: '$price', purchase: '$price' } } },
13
- ];
14
-
15
- return productRepository.updateMany({}, updateSentence);
16
- });
17
-
18
- /**
19
- * Make any changes that UNDO the up function side effects here (if possible)
20
- */
21
- export const down = () => connect(async (connection) => {
22
- const productRepository = await connection.collection('inventory_products');
23
-
24
- const updateSentence: UpdateQuery<ProductEntity>[] = [
25
- { $set: { price: '$price.sale' } },
26
- ];
27
-
28
- return productRepository.updateMany({}, updateSentence);
29
- });
@@ -1,37 +0,0 @@
1
- import { connect } from '../abstract/abstract.migration';
2
- import { UpdateQuery } from "mongoose";
3
- import { ProductEntity } from "../modules/inventory/products/product.entity";
4
-
5
- /**
6
- * Make any changes you need to make to the database here
7
- */
8
- export const up = () => connect(async (connection) => {
9
- const productRepository = await connection.collection('inventory_products');
10
-
11
- const updateSentence: UpdateQuery<ProductEntity>[] = [{
12
- $set: {
13
- seo: { slug: null, title: '$name', description: '$description' },
14
- code: { sku: undefined, gtin: undefined, mpn: undefined },
15
- dimension: { weight: undefined, height: undefined, width: undefined, depth: undefined },
16
- },
17
- }];
18
-
19
- return productRepository.updateMany({}, updateSentence);
20
- });
21
-
22
- /**
23
- * Make any changes that UNDO the up function side effects here (if possible)
24
- */
25
- export const down = () => connect(async (connection) => {
26
- const productRepository = await connection.collection('inventory_products');
27
-
28
- const updateSentence: UpdateQuery<ProductEntity>[] = [{
29
- $unset: {
30
- seo: undefined,
31
- code: undefined,
32
- dimension: undefined,
33
- },
34
- }];
35
-
36
- return productRepository.updateMany({}, updateSentence);
37
- });
@@ -1,35 +0,0 @@
1
- import { connect } from '../abstract/abstract.migration';
2
- import { UpdateQuery } from "mongoose";
3
- import { ProductEntity } from "../modules/inventory/products/product.entity";
4
-
5
- /**
6
- * Make any changes you need to make to the database here
7
- */
8
- export const up = () => connect(async (connection) => {
9
- const productRepository = await connection.collection('inventory_products');
10
-
11
- const updateSentence: UpdateQuery<ProductEntity>[] = [{
12
- $set: {
13
- hashtags: [],
14
- active: true,
15
- },
16
- }];
17
-
18
- return productRepository.updateMany({}, updateSentence);
19
- });
20
-
21
- /**
22
- * Make any changes that UNDO the up function side effects here (if possible)
23
- */
24
- export const down = () => connect(async (connection) => {
25
- const productRepository = await connection.collection('inventory_products');
26
-
27
- const updateSentence: UpdateQuery<ProductEntity>[] = [{
28
- $unset: {
29
- hashtags: undefined,
30
- active: undefined,
31
- },
32
- }];
33
-
34
- return productRepository.updateMany({}, updateSentence);
35
- });
@@ -1,56 +0,0 @@
1
- import { connect } from '../abstract/abstract.migration';
2
-
3
- /**
4
- * Make any changes you need to make to the database here
5
- */
6
- export const up = () => connect(async (connection) => {
7
- const productRepository = await connection.collection('content_banners');
8
-
9
- await productRepository.updateMany({}, {
10
- $set: {
11
- name: '$title',
12
- href: '#',
13
- },
14
- });
15
-
16
- await productRepository.updateMany({}, {
17
- $unset: {
18
- title: undefined,
19
- description: undefined,
20
- size: undefined,
21
- cta: undefined,
22
- tip: undefined,
23
- },
24
- });
25
- });
26
-
27
- /**
28
- * Make any changes that UNDO the up function side effects here (if possible)
29
- */
30
- export const down = () => connect(async (connection) => {
31
- const productRepository = await connection.collection('content_banners');
32
-
33
- await productRepository.updateMany({}, {
34
- $set: {
35
- title: '$name',
36
- description: '',
37
- size: 220,
38
- cta: {
39
- variant: '',
40
- text: '',
41
- to: '',
42
- },
43
- tip: {
44
- variant: '',
45
- text: '',
46
- },
47
- },
48
- });
49
-
50
- await productRepository.updateMany({}, {
51
- $unset: {
52
- name: '$title',
53
- href: '#',
54
- },
55
- });
56
- });
@@ -1,32 +0,0 @@
1
- import { connect } from '../abstract/abstract.migration';
2
- import { BillingStatus } from "../modules/sales/orders/billing/billing.types";
3
- import * as process from "process";
4
-
5
- /**
6
- * Make any changes you need to make to the database here
7
- */
8
- export const up = () => connect(async (connection) => {
9
- const orderRepository = await connection.collection('store_orders');
10
-
11
- await orderRepository.updateMany({}, { $rename: { 'billing.type': 'billing.method' } });
12
-
13
- await orderRepository.updateMany({}, {
14
- $set: {
15
- 'billing.status': [{
16
- user: process.env.USER_ID,
17
- name: BillingStatus.UNPAID,
18
- date: new Date()
19
- }]
20
- },
21
- });
22
- });
23
-
24
- /**
25
- * Make any changes that UNDO the up function side effects here (if possible)
26
- */
27
- export const down = () => connect(async (connection) => {
28
- const orderRepository = await connection.collection('store_orders');
29
-
30
- await orderRepository.updateMany({}, { $rename: { 'billing.method': 'billing.type' } });
31
- await orderRepository.updateMany({}, { $unset: { 'billing.method': undefined, 'billing.status': undefined } });
32
- });
@@ -1,33 +0,0 @@
1
- import { Controller, Delete, Inject, Param, Post, UploadedFiles, UseInterceptors } from '@nestjs/common';
2
- import { AnyFilesInterceptor } from '@nestjs/platform-express';
3
- import { ApiTags } from '@nestjs/swagger';
4
- import { AssetEntity } from './asset.entity';
5
- import { AssetRepository } from './asset.repository';
6
- import MFiles = Express.Multer.File;
7
-
8
- @Controller()
9
- @ApiTags('assets')
10
- export class AssetController {
11
- @Inject()
12
- protected readonly $repository: AssetRepository;
13
-
14
- @Post('/files')
15
- @UseInterceptors(AnyFilesInterceptor())
16
- public async files(@UploadedFiles() images: MFiles[] = []): Promise<AssetEntity[]> {
17
- return this.$repository.uploadFiles(images);
18
- }
19
-
20
- @Post('/file')
21
- @UseInterceptors(AnyFilesInterceptor())
22
- public async file(@UploadedFiles() images: MFiles[] = []): Promise<AssetEntity> {
23
- const [asset] = await this.files(images);
24
-
25
- return asset;
26
- }
27
-
28
- @Delete('/file/:id')
29
- public async delete(@Param('id') id: string): Promise<void> {
30
- return this.$repository.delete(id);
31
- }
32
-
33
- }
@@ -1,26 +0,0 @@
1
- import { Prop, Schema } from '@nestjs/mongoose';
2
- import { Schema as MongoSchema } from 'mongoose';
3
- import { AbstractEntity } from '../../abstract/abstract.entity';
4
-
5
- @Schema({ timestamps: true })
6
- export class AssetEntity extends AbstractEntity {
7
- public static readonly $index = 'assets';
8
-
9
- @Prop({ type: MongoSchema.Types.String, required: true, unique: true })
10
- public name: string;
11
-
12
- @Prop({ type: MongoSchema.Types.String, required: true })
13
- public url: string;
14
-
15
- @Prop({ type: MongoSchema.Types.Boolean, default: true })
16
- public weak = true;
17
-
18
- @Prop({ type: MongoSchema.Types.String, nullable: true })
19
- public description: string;
20
-
21
- @Prop({ type: MongoSchema.Types.String })
22
- public type: string;
23
-
24
- @Prop({ type: MongoSchema.Types.Number, required: true, default: 0 })
25
- public size = 0;
26
- }
@@ -1,21 +0,0 @@
1
- import { Module, ModuleMetadata } from '@nestjs/common';
2
- import { AbstractRouter } from '../../abstract/abstract.router';
3
- import { AssetController } from './asset.controller';
4
- import { AssetRepository } from './asset.repository';
5
- import { AssetService } from './asset.service';
6
-
7
- export const metadata: ModuleMetadata = {
8
- imports: [],
9
- controllers: [AssetController],
10
- providers: [AssetRepository, AssetService],
11
- exports: [AssetRepository],
12
- };
13
-
14
- @Module(metadata)
15
- export class AssetModule extends AbstractRouter {
16
- public static readonly path = '/assets';
17
-
18
- public static readonly module = AssetModule;
19
-
20
- public static readonly children = metadata.imports;
21
- }
@@ -1,51 +0,0 @@
1
- import { Inject, Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
- import { AbstractRepository } from '../../abstract/abstract.repository';
5
- import { StorageService } from '../../services/storage.service';
6
- import { AssetEntity } from './asset.entity';
7
- import MFiles = Express.Multer.File;
8
-
9
- @Injectable()
10
- export class AssetRepository extends AbstractRepository<AssetEntity> {
11
- @InjectModel(AssetEntity.$index)
12
- public readonly $model: Model<AssetEntity>;
13
-
14
- @Inject() protected readonly $storage: StorageService;
15
-
16
- public async uploadFiles(files: MFiles[] = []): Promise<AssetEntity[]> {
17
- const assets: AssetEntity[] = [];
18
- const { name } = this.$model.db;
19
-
20
- const uploadedFiles = await this.$storage.uploadBuffers(files, {
21
- dest: `${name}/uploads`,
22
- public: true,
23
- });
24
-
25
- for await (const file of uploadedFiles) {
26
- const asset: AssetEntity = new this.$model();
27
-
28
- asset.id = file.id;
29
- asset.url = file.publicUrl();
30
- asset.name = file.metadata.name;
31
- asset.size = file.metadata.size;
32
- asset.type = file.metadata.contentType;
33
-
34
- assets.push(await this.$model.create(asset));
35
- }
36
-
37
- return Promise.all(assets);
38
- }
39
-
40
- public create(partial: Partial<AssetEntity>): Promise<AssetEntity> {
41
- return this.$model.create(partial);
42
- }
43
-
44
- public async delete(id: string): Promise<void> {
45
- await this.$model.findByIdAndDelete(id);
46
- }
47
-
48
- public update(id: string, params: unknown): Promise<AssetEntity> {
49
- return Promise.resolve(undefined);
50
- }
51
- }
@@ -1,4 +0,0 @@
1
- import { SchemaFactory } from '@nestjs/mongoose';
2
- import { AssetEntity } from './asset.entity';
3
-
4
- export const AssetSchema = SchemaFactory.createForClass(AssetEntity);
@@ -1,41 +0,0 @@
1
- import { Inject, Injectable } from '@nestjs/common';
2
- import { join } from 'path';
3
- import { StorageService } from '../../services/storage.service';
4
- import { AssetEntity } from './asset.entity';
5
-
6
- @Injectable()
7
- export class AssetService {
8
- @Inject()
9
- protected readonly $storage: StorageService;
10
-
11
- public async removeAssetsWeakness(assets: AssetEntity[], path: string) {
12
- const promises = [];
13
- const weakAssets = assets.filter(asset => asset.weak);
14
-
15
- for (const asset of weakAssets) {
16
- promises.push(this.removeAssetWeakness(asset, path));
17
- }
18
-
19
- return Promise.all(promises);
20
- }
21
-
22
- public async removeAssetWeakness(asset: AssetEntity, path: string) {
23
- const finalName = asset.name.split('/').pop();
24
- const file = await this.$storage.file(asset.name);
25
-
26
- return file.move(join(path, finalName))
27
- .then(async ([metadata]) => {
28
- const newFile = await this.$storage.file(metadata.name);
29
- await newFile.makePublic();
30
- await newFile.setMetadata({ temporaryHold: true });
31
-
32
- asset.weak = false;
33
- asset.name = metadata.name;
34
- asset.url = newFile.publicUrl();
35
-
36
- await asset.save();
37
-
38
- return newFile;
39
- });
40
- }
41
- }
@@ -1,42 +0,0 @@
1
- import { Body, Controller, Get, Inject, Post } from '@nestjs/common';
2
- import { ApiTags } from '@nestjs/swagger';
3
- import { GetUser } from '../../decorators/user.decorator';
4
- import { Public } from '../../decorators/public.decorator';
5
- import { Auth0Service } from '../../services/auth0.service';
6
-
7
- @Controller()
8
- @ApiTags('auth')
9
- export class AuthController {
10
- @Inject()
11
- public readonly $auth: Auth0Service;
12
-
13
- @Public()
14
- @Get('/login')
15
- public async login() {
16
- return 'login';
17
- }
18
-
19
- @Get('/logout')
20
- public async logout(@GetUser('sub') id: string) {
21
- return 'logout';
22
- }
23
-
24
- @Post('/link')
25
- public linkAccounts(@GetUser('sub') id: string, @Body() config: Record<any, any>) {
26
- const params = {
27
- user_id: config.id,
28
- provider: config.provider,
29
- };
30
- return this.$auth.linkUsers(id, params);
31
- }
32
-
33
- @Post('/unlink')
34
- public unlinkACcount(@GetUser('sub') id: string, @Body() config: any) {
35
- const params: any = {
36
- id: id,
37
- provider: config.provider,
38
- user_id: config.secondary_user_id,
39
- };
40
- return this.$auth.unlinkUsers(params);
41
- }
42
- }
@@ -1,18 +0,0 @@
1
- import { Module, ModuleMetadata } from '@nestjs/common';
2
- import { AbstractRouter } from '../../abstract/abstract.router';
3
- import { AuthController } from "./auth.controller";
4
-
5
- export const metadata: ModuleMetadata = {
6
- controllers: [AuthController],
7
- imports: [],
8
- providers: [],
9
- };
10
-
11
- @Module(metadata)
12
- export class AuthModule extends AbstractRouter {
13
- public static readonly path = '/auth';
14
-
15
- public static readonly module = AuthModule;
16
-
17
- public static readonly children = [];
18
- }
File without changes
@@ -1,19 +0,0 @@
1
- import { DynamicModule } from '@nestjs/common';
2
- import { ConsoleModule } from 'nestjs-console';
3
- import { router } from '../app.module';
4
- import { AssetsCommand } from '../commands/assets.command';
5
- import { DeployCommand } from '../commands/deploy.command';
6
- import { FixtureCommand } from '../commands/fixture.command';
7
- import { GenerateCommand } from '../commands/generate.command';
8
-
9
- export class CommandsModule {
10
-
11
- public static register(): DynamicModule {
12
- return {
13
- global: true,
14
- module: CommandsModule,
15
- imports: [ConsoleModule, ...router],
16
- providers: [GenerateCommand, FixtureCommand, AssetsCommand, DeployCommand],
17
- };
18
- }
19
- }
@@ -1,56 +0,0 @@
1
- import {
2
- Body,
3
- Controller,
4
- Delete,
5
- Get,
6
- HttpCode,
7
- HttpStatus,
8
- Inject,
9
- Param,
10
- Patch,
11
- Post,
12
- Query,
13
- } from '@nestjs/common';
14
- import { ApiTags } from '@nestjs/swagger';
15
- import { AbstractController } from '../../../abstract/abstract.controller';
16
- import { FindValidator } from '../../../abstract/abstract.validator';
17
- import { Public } from '../../../decorators/public.decorator';
18
- import { BannerEntity } from './banner.entity';
19
- import { BannerRepository } from './banner.repository';
20
- import { CreateBannerValidator, UpdateBannerValidator } from './banner.validator';
21
-
22
- @Controller()
23
- @ApiTags('content')
24
- export class BannerController extends AbstractController<BannerEntity> {
25
- @Inject()
26
- protected readonly $repository: BannerRepository;
27
-
28
- @Get('/')
29
- @Public()
30
- public async find(@Query() validator: FindValidator<BannerEntity>) {
31
- return this.$repository.find(validator);
32
- }
33
-
34
- @Get('/:id')
35
- @Public()
36
- public async read(@Param('id') id: string) {
37
- return this.$repository.read(id);
38
- }
39
-
40
- @Post('/')
41
- @HttpCode(HttpStatus.CREATED)
42
- public async create(@Body() validator: CreateBannerValidator) {
43
- return this.$repository.create(validator);
44
- }
45
-
46
- @Patch('/:id')
47
- public async update(@Param('id') id: string, @Body() validator: UpdateBannerValidator) {
48
- return this.$repository.update(id, validator);
49
- }
50
-
51
- @Delete('/:id')
52
- @HttpCode(HttpStatus.NO_CONTENT)
53
- public async delete(@Param('id') id: string) {
54
- return this.$repository.delete(id);
55
- }
56
- }
@@ -1,17 +0,0 @@
1
- import { Prop, Schema as Collection } from '@nestjs/mongoose';
2
- import { Schema } from 'mongoose';
3
- import { AbstractEntity } from '../../../abstract/abstract.entity';
4
-
5
- @Collection({ timestamps: true })
6
- export class BannerEntity extends AbstractEntity {
7
- public static readonly $index = 'content_banners';
8
-
9
- @Prop({ type: Schema.Types.String, required: true })
10
- public name: string;
11
-
12
- @Prop({ type: Schema.Types.String, required: true })
13
- public image: string;
14
-
15
- @Prop({ type: Schema.Types.String, default: '#' })
16
- public href: string;
17
- }
@@ -1,19 +0,0 @@
1
- import { faker } from '@faker-js/faker';
2
- import { AbstractFixture } from '../../../abstract/abstract.fixture';
3
- import { BannerEntity } from "./banner.entity";
4
-
5
- export class BannerFixture extends AbstractFixture {
6
-
7
- public normal() {
8
- const banner = new BannerEntity({
9
- _id: this.$faker.datatype.uuid(),
10
- createdAt: this.$faker.date.past(1),
11
- updatedAt: this.$faker.date.past(1),
12
- });
13
-
14
- banner.name = faker.random.words(6);
15
- banner.image = faker.image.placeholder.imageUrl(850, 400, 'webp');
16
-
17
- return banner;
18
- }
19
- }
@@ -1,6 +0,0 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { AbsctractListener } from '../../../abstract/absctract.listener';
3
-
4
- @Injectable()
5
- export class BannerListener extends AbsctractListener {
6
- }
@@ -1,21 +0,0 @@
1
- import { Module, ModuleMetadata } from '@nestjs/common';
2
- import { AbstractRouter } from '../../../abstract/abstract.router';
3
- import { BannerController } from './banner.controller';
4
- import { BannerListener } from './banner.listener';
5
- import { BannerRepository } from './banner.repository';
6
-
7
- export const metadata: ModuleMetadata = {
8
- imports: [],
9
- controllers: [BannerController],
10
- providers: [BannerRepository, BannerListener],
11
- exports: [BannerRepository],
12
- };
13
-
14
- @Module(metadata)
15
- export class BannerModule extends AbstractRouter {
16
- public static readonly path = '/banners';
17
-
18
- public static readonly module = BannerModule;
19
-
20
- public static readonly children = metadata.imports;
21
- }