@fiap-tech-challenge/shared-ftc 1.0.0
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/dist/jest.config.d.ts +3 -0
- package/dist/jest.config.js +19 -0
- package/dist/jest.config.js.map +1 -0
- package/dist/src/application/entities/cart-item.d.ts +25 -0
- package/dist/src/application/entities/cart-item.js +37 -0
- package/dist/src/application/entities/cart-item.js.map +1 -0
- package/dist/src/application/entities/cart.d.ts +23 -0
- package/dist/src/application/entities/cart.js +34 -0
- package/dist/src/application/entities/cart.js.map +1 -0
- package/dist/src/application/entities/common-cart-item.d.ts +25 -0
- package/dist/src/application/entities/common-cart-item.js +37 -0
- package/dist/src/application/entities/common-cart-item.js.map +1 -0
- package/dist/src/application/entities/common-cart.d.ts +20 -0
- package/dist/src/application/entities/common-cart.js +19 -0
- package/dist/src/application/entities/common-cart.js.map +1 -0
- package/dist/src/application/entities/item.d.ts +33 -0
- package/dist/src/application/entities/item.js +44 -0
- package/dist/src/application/entities/item.js.map +1 -0
- package/dist/src/application/entities/item.spec.d.ts +1 -0
- package/dist/src/application/entities/item.spec.js +36 -0
- package/dist/src/application/entities/item.spec.js.map +1 -0
- package/dist/src/application/services/cart-service/cart-service.d.ts +4 -0
- package/dist/src/application/services/cart-service/cart-service.js +7 -0
- package/dist/src/application/services/cart-service/cart-service.js.map +1 -0
- package/dist/src/application/services/item-service/item-service.d.ts +4 -0
- package/dist/src/application/services/item-service/item-service.js +7 -0
- package/dist/src/application/services/item-service/item-service.js.map +1 -0
- package/dist/src/helpers/Replace.d.ts +1 -0
- package/dist/src/helpers/Replace.js +3 -0
- package/dist/src/helpers/Replace.js.map +1 -0
- package/dist/src/index.d.ts +13 -0
- package/dist/src/index.js +30 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/infra/services/cart-service/cart-dtos.d.ts +32 -0
- package/dist/src/infra/services/cart-service/cart-dtos.js +109 -0
- package/dist/src/infra/services/cart-service/cart-dtos.js.map +1 -0
- package/dist/src/infra/services/cart-service/cart-service.module.d.ts +4 -0
- package/dist/src/infra/services/cart-service/cart-service.module.js +42 -0
- package/dist/src/infra/services/cart-service/cart-service.module.js.map +1 -0
- package/dist/src/infra/services/cart-service/http-client/http-client-cart-service.d.ts +8 -0
- package/dist/src/infra/services/cart-service/http-client/http-client-cart-service.js +61 -0
- package/dist/src/infra/services/cart-service/http-client/http-client-cart-service.js.map +1 -0
- package/dist/src/infra/services/cart-service/mock/mock-cart-service.d.ts +8 -0
- package/dist/src/infra/services/cart-service/mock/mock-cart-service.js +77 -0
- package/dist/src/infra/services/cart-service/mock/mock-cart-service.js.map +1 -0
- package/dist/src/infra/services/item-service/http-client/http-client.service.d.ts +5 -0
- package/dist/src/infra/services/item-service/http-client/http-client.service.js +40 -0
- package/dist/src/infra/services/item-service/http-client/http-client.service.js.map +1 -0
- package/dist/src/infra/services/item-service/http-client/http-service-mapper.d.ts +5 -0
- package/dist/src/infra/services/item-service/http-client/http-service-mapper.js +16 -0
- package/dist/src/infra/services/item-service/http-client/http-service-mapper.js.map +1 -0
- package/dist/src/infra/services/item-service/http-client/openapi-http-client.d.ts +1 -0
- package/dist/src/infra/services/item-service/http-client/openapi-http-client.js +8 -0
- package/dist/src/infra/services/item-service/http-client/openapi-http-client.js.map +1 -0
- package/dist/src/infra/services/item-service/item-dtos.d.ts +20 -0
- package/dist/src/infra/services/item-service/item-dtos.js +92 -0
- package/dist/src/infra/services/item-service/item-dtos.js.map +1 -0
- package/dist/src/infra/services/item-service/item-service.module.d.ts +4 -0
- package/dist/src/infra/services/item-service/item-service.module.js +42 -0
- package/dist/src/infra/services/item-service/item-service.module.js.map +1 -0
- package/dist/src/infra/services/item-service/mock/mock-item-service.d.ts +8 -0
- package/dist/src/infra/services/item-service/mock/mock-item-service.js +81 -0
- package/dist/src/infra/services/item-service/mock/mock-item-service.js.map +1 -0
- package/dist/src/infra/services/item-service/mock/mock-item-service.module.d.ts +2 -0
- package/dist/src/infra/services/item-service/mock/mock-item-service.module.js +27 -0
- package/dist/src/infra/services/item-service/mock/mock-item-service.module.js.map +1 -0
- package/dist/src/infra/services/item-service/mock/mock-item.service.d.ts +7 -0
- package/dist/src/infra/services/item-service/mock/mock-item.service.js +50 -0
- package/dist/src/infra/services/item-service/mock/mock-item.service.js.map +1 -0
- package/dist/src/utils/is-cpf-valid.d.ts +5 -0
- package/dist/src/utils/is-cpf-valid.js +27 -0
- package/dist/src/utils/is-cpf-valid.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +35 -0
- package/readme.md +49 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cart-dtos.js","sourceRoot":"","sources":["../../../../../src/infra/services/cart-service/cart-dtos.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAmE;AACnE,qDAAuG;AACvG,sDAAiD;AAKjD,MAAa,cAAc;CAO1B;AAPD,wCAOC;AADC;IALC,IAAA,qBAAW,EAAC,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACxD,IAAA,6BAAmB,GAAE;IACrB,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,EAAC,yBAAU,EAAE,EAAE,OAAO,EAAE,qBAAqB,EAAE,CAAC;;2CAC5C;AAGf,MAAa,eAAe;CAW3B;AAXD,0CAWC;AANC;IAJC,IAAA,qBAAW,EAAC,EAAE,OAAO,EAAE,sCAAsC,EAAE,CAAC;IAChE,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAM,GAAE;IACR,IAAA,wBAAM,EAAC,EAAE,EAAE,EAAE,CAAC;;+CACA;AAKf;IAHC,IAAA,qBAAW,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC3B,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;iDACM;AAGnB,MAAa,iBAAiB;CAW7B;AAXD,8CAWC;AANC;IAJC,I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{
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.MockCartServiceModule = exports.HttpCartServiceModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const cart_service_1 = require("../../../application/services/cart-service/cart-service");
|
|
12
|
+
const http_client_cart_service_1 = require("../../services/cart-service/http-client/http-client-cart-service");
|
|
13
|
+
const mock_cart_service_1 = require("../../services/cart-service/mock/mock-cart-service");
|
|
14
|
+
let HttpCartServiceModule = class HttpCartServiceModule {
|
|
15
|
+
};
|
|
16
|
+
exports.HttpCartServiceModule = HttpCartServiceModule;
|
|
17
|
+
exports.HttpCartServiceModule = HttpCartServiceModule = __decorate([
|
|
18
|
+
(0, common_1.Module)({
|
|
19
|
+
providers: [
|
|
20
|
+
{
|
|
21
|
+
provide: cart_service_1.CartService,
|
|
22
|
+
useClass: http_client_cart_service_1.HttpClientCartService,
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
exports: [cart_service_1.CartService],
|
|
26
|
+
})
|
|
27
|
+
], HttpCartServiceModule);
|
|
28
|
+
let MockCartServiceModule = class MockCartServiceModule {
|
|
29
|
+
};
|
|
30
|
+
exports.MockCartServiceModule = MockCartServiceModule;
|
|
31
|
+
exports.MockCartServiceModule = MockCartServiceModule = __decorate([
|
|
32
|
+
(0, common_1.Module)({
|
|
33
|
+
providers: [
|
|
34
|
+
{
|
|
35
|
+
provide: cart_service_1.CartService,
|
|
36
|
+
useClass: mock_cart_service_1.MockCartService,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
exports: [cart_service_1.CartService],
|
|
40
|
+
})
|
|
41
|
+
], MockCartServiceModule);
|
|
42
|
+
//# sourceMappingURL=cart-service.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cart-service.module.js","sourceRoot":"","sources":["../../../../../src/infra/services/cart-service/cart-service.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,kFAA8E;AAC9E,gHAA0G;AAC1G,2FAAsF;AAW/E,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;CAAG,CAAA;AAAxB,sDAAqB;gCAArB,qBAAqB;IATjC,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,0BAAW;gBACpB,QAAQ,EAAE,gDAAqB;aAChC;SACF;QACD,OAAO,EAAE,CAAC,0BAAW,CAAC;KACvB,CAAC;GACW,qBAAqB,CAAG;AAW9B,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;CAAG,CAAA;AAAxB,sDAAqB;gCAArB,qBAAqB;IATjC,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,0BAAW;gBACpB,QAAQ,EAAE,mCAAe;aAC1B;SACF;QACD,OAAO,EAAE,CAAC,0BAAW,CAAC;KACvB,CAAC;GACW,qBAAqB,CAAG"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CommonCart } from "../../../../application/entities/common-cart";
|
|
2
|
+
import { CartService } from "../../../../application/services/cart-service/cart-service";
|
|
3
|
+
export declare class HttpClientCartService extends CartService {
|
|
4
|
+
private baseUrl;
|
|
5
|
+
constructor();
|
|
6
|
+
findById(cartId: string): Promise<CommonCart | null>;
|
|
7
|
+
private mapToDomain;
|
|
8
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.HttpClientCartService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const common_cart_1 = require("../../../../application/entities/common-cart");
|
|
15
|
+
const common_cart_item_1 = require("../../../../application/entities/common-cart-item");
|
|
16
|
+
const cart_service_1 = require("../../../../application/services/cart-service/cart-service");
|
|
17
|
+
let HttpClientCartService = class HttpClientCartService extends cart_service_1.CartService {
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
this.baseUrl = process.env.CART_SERVICE_URL || "http://localhost:3001";
|
|
21
|
+
}
|
|
22
|
+
async findById(cartId) {
|
|
23
|
+
try {
|
|
24
|
+
const response = await fetch(`${this.baseUrl}/carts/${cartId}`);
|
|
25
|
+
if (response.status === 404) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
if (!response.ok) {
|
|
29
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
30
|
+
}
|
|
31
|
+
const data = await response.json();
|
|
32
|
+
return this.mapToDomain(data);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (error instanceof Error && error.message.includes("404")) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
mapToDomain(cartResponse) {
|
|
42
|
+
const CommonCartItems = cartResponse.items.map((item) => new common_cart_item_1.CommonCartItem({
|
|
43
|
+
itemId: item.id,
|
|
44
|
+
price: item.price,
|
|
45
|
+
quantity: item.quantity,
|
|
46
|
+
createdAt: new Date(item.createdAt),
|
|
47
|
+
}, item.id));
|
|
48
|
+
return new common_cart_1.CommonCart({
|
|
49
|
+
customerId: cartResponse.customerId,
|
|
50
|
+
items: CommonCartItems,
|
|
51
|
+
createdAt: new Date(cartResponse.createdAt),
|
|
52
|
+
updatedAt: new Date(cartResponse.updatedAt),
|
|
53
|
+
}, cartResponse.id);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
exports.HttpClientCartService = HttpClientCartService;
|
|
57
|
+
exports.HttpClientCartService = HttpClientCartService = __decorate([
|
|
58
|
+
(0, common_1.Injectable)(),
|
|
59
|
+
__metadata("design:paramtypes", [])
|
|
60
|
+
], HttpClientCartService);
|
|
61
|
+
//# sourceMappingURL=http-client-cart-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client-cart-service.js","sourceRoot":"","sources":["../../../../../../src/infra/services/cart-service/http-client/http-client-cart-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,mEAA+D;AAC/D,6EAAwE;AACxE,kFAA8E;AAIvE,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,0BAAW;IAGpD;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,uBAAuB,CAAC;IACzE,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAc;QAC3B,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,UAAU,MAAM,EAAE,CAAC,CAAC;YA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AA,mBAAU,GAAE;;GACA,qBAAqB,CAsDjC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CommonCart } from "../../../../application/entities/common-cart";
|
|
2
|
+
import { CartService } from "../../../../application/services/cart-service/cart-service";
|
|
3
|
+
export declare class MockCartService extends CartService {
|
|
4
|
+
private carts;
|
|
5
|
+
constructor();
|
|
6
|
+
private seedMockData;
|
|
7
|
+
findById(cartId: string): Promise<CommonCart | null>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MockCartService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const common_cart_1 = require("../../../../application/entities/common-cart");
|
|
15
|
+
const common_cart_item_1 = require("../../../../application/entities/common-cart-item");
|
|
16
|
+
const cart_service_1 = require("../../../../application/services/cart-service/cart-service");
|
|
17
|
+
let MockCartService = class MockCartService extends cart_service_1.CartService {
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
this.carts = new Map();
|
|
21
|
+
this.seedMockData();
|
|
22
|
+
}
|
|
23
|
+
seedMockData() {
|
|
24
|
+
const cart1 = new common_cart_1.CommonCart({
|
|
25
|
+
customerId: "12345678901",
|
|
26
|
+
items: [
|
|
27
|
+
new common_cart_item_1.CommonCartItem({
|
|
28
|
+
itemId: "123e4567-e89b-12d3-a456-426614174000",
|
|
29
|
+
price: 25,
|
|
30
|
+
quantity: 2,
|
|
31
|
+
}, "cart-item-1"),
|
|
32
|
+
new common_cart_item_1.CommonCartItem({
|
|
33
|
+
itemId: "123e4567-e89b-12d3-a456-426614174002",
|
|
34
|
+
price: 12,
|
|
35
|
+
quantity: 1,
|
|
36
|
+
}, "cart-item-2"),
|
|
37
|
+
new common_cart_item_1.CommonCartItem({
|
|
38
|
+
itemId: "123e4567-e89b-12d3-a456-426614174004",
|
|
39
|
+
price: 8,
|
|
40
|
+
quantity: 2,
|
|
41
|
+
}, "cart-item-3"),
|
|
42
|
+
],
|
|
43
|
+
}, "cart-1");
|
|
44
|
+
const cart2 = new common_cart_1.CommonCart({
|
|
45
|
+
customerId: null,
|
|
46
|
+
items: [
|
|
47
|
+
new common_cart_item_1.CommonCartItem({
|
|
48
|
+
itemId: "123e4567-e89b-12d3-a456-426614174001",
|
|
49
|
+
price: 29,
|
|
50
|
+
quantity: 1,
|
|
51
|
+
}, "cart-item-4"),
|
|
52
|
+
new common_cart_item_1.CommonCartItem({
|
|
53
|
+
itemId: "123e4567-e89b-12d3-a456-426614174006",
|
|
54
|
+
price: 15,
|
|
55
|
+
quantity: 1,
|
|
56
|
+
}, "cart-item-5"),
|
|
57
|
+
],
|
|
58
|
+
}, "cart-2");
|
|
59
|
+
const cart3 = new common_cart_1.CommonCart({
|
|
60
|
+
customerId: "98765432109",
|
|
61
|
+
items: [],
|
|
62
|
+
}, "cart-3");
|
|
63
|
+
[cart1, cart2, cart3].forEach((cart) => {
|
|
64
|
+
this.carts.set(cart.id, cart);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
async findById(cartId) {
|
|
68
|
+
const cart = this.carts.get(cartId);
|
|
69
|
+
return cart !== null && cart !== void 0 ? cart : null;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
exports.MockCartService = MockCartService;
|
|
73
|
+
exports.MockCartService = MockCartService = __decorate([
|
|
74
|
+
(0, common_1.Injectable)(),
|
|
75
|
+
__metadata("design:paramtypes", [])
|
|
76
|
+
], MockCartService);
|
|
77
|
+
//# sourceMappingURL=mock-cart-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-cart-service.js","sourceRoot":"","sources":["../../../../../../src/infra/services/cart-service/mock/mock-cart-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,mEAA+D;AAC/D,6EAAwE;AACxE,kFAA8E;AAIvE,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,0BAAW;IAG9C;QACE,KAAK,EAAE,CAAC;QAHF,UAAK,GAA4B,IAAI,GAAG,EAAE,CAAC;QAIjD,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAEO,YAAY;QAClB,MAAM,KAAK,GAAG,IAAI,wBAAU,CAC1B;YACE,UAAU,EAAE,aAAa;YACzB,KAAK,EAAE;gBACL,IAAI,iCAAc,CAChB;oBACE,MAAM,EAAE,sCAAsC;oBAC9C,KAAK,EAAE,EAAE;oBACT,QAAQ,EAAE,CAAC;iBACZ,EACD,aAAa,CACd;gBACD,IAAI,iCAAc,CAChB;oBACE,MAAM,EAAE,sCAAsC;oBAC9C,KAAK,EAAE,EAAE;oBACT,QAAQ,EAAE,CAAC;iBACZ,EACD,aAAa,CACd;gBACD,IAAI,iCAAc,CAChB;oBACE,MAAM,EAAE,sCAAsC;oBAC9C,KAAK,EAAE,CAAC;oBACR,QAAQ,EAAE,CAAC;iBACZ,EACD,aAAa,CACd;aACF;SACF,EACD,QAAQ,CACT,CAAC;QAEF,MAAM,KAAK,GAAG,IAAI,wBAAU,CAC1B;YACE,UAAU,EAAE,IAAI;YAChB,KAAK,EAAE;gBACL,IAAI,iCAAc,CAChB;oBACE,MAAM,EAAE,sCAAsC;oBAC9C,KAAK,EAAE,EAAE;oBACT,QAAQ,EAAE,CAAC;iBACZ,EACD,aAAa,CACd;gBACD,IAAI,iCAAc,CAChB;oBACE,MAAM,EAAE,sCAAsC;oBAC9C,KAAK,EAAE,EAAE;oBACT,QAAQ,EAAE,CAAC;iBACZ,EACD,aAAa,CACd;aACF;SACF,EACD,QAAQ,CACT,CAAC;QAEF,MAAM,KAAK,GAAG,IAAI,wBAAU,CAC1B;YACE,UAAU,EAAE,aAAa;YACzB,KAAK,EAAE,EAAE;SACV,EACD,QAAQ,CACT,CAAC;QAEF,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAc;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACpC,OAAO,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,IAAI,CAAC;IACtB,CAAC;CACF,CAAA;AApFY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;;GACA,eAAe,CAoF3B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.HttpClientItemService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const http_service_mapper_1 = require("./http-service-mapper");
|
|
15
|
+
let HttpClientItemService = class HttpClientItemService {
|
|
16
|
+
constructor() {
|
|
17
|
+
}
|
|
18
|
+
async findById(itemId) {
|
|
19
|
+
if (!process.env.ITEM_SERVICE_URL) {
|
|
20
|
+
throw new Error("ITEM_SERVICE_URL is not defined");
|
|
21
|
+
}
|
|
22
|
+
const url = `${process.env.ITEM_SERVICE_URL}/items/${itemId}`;
|
|
23
|
+
const response = await fetch(url, {
|
|
24
|
+
method: 'GET',
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
const data = await response.json();
|
|
30
|
+
if (!data)
|
|
31
|
+
return null;
|
|
32
|
+
return http_service_mapper_1.HttpServiceMapper.toDomainItem(data);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.HttpClientItemService = HttpClientItemService;
|
|
36
|
+
exports.HttpClientItemService = HttpClientItemService = __decorate([
|
|
37
|
+
(0, common_1.Injectable)(),
|
|
38
|
+
__metadata("design:paramtypes", [])
|
|
39
|
+
], HttpClientItemService);
|
|
40
|
+
//# sourceMappingURL=http-client.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client.service.js","sourceRoot":"","sources":["../../../../../../src/infra/services/item-service/http-client/http-client.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAE5C,+DAA0D;AAInD,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC;IACA,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAc;QAC3B,IAAG,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QAED,MAAM,GAAG,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,UAAU,MAAM,EAAE,CAAC;QAE9D,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAChC,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAkB,CAAA;QAElD,IAAG,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QAEtB,OAAO,uCAAiB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;CACF,CAAA;AAxBY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;;GACA,qBAAqB,CAwBjC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpServiceMapper = void 0;
|
|
4
|
+
const item_1 = require("../../../../application/entities/item");
|
|
5
|
+
class HttpServiceMapper {
|
|
6
|
+
static toDomainItem(raw) {
|
|
7
|
+
return new item_1.CommonItem({
|
|
8
|
+
name: raw.name,
|
|
9
|
+
price: raw.price,
|
|
10
|
+
category: item_1.ItemCategory[raw.category],
|
|
11
|
+
createdAt: new Date(raw.createdAt),
|
|
12
|
+
}, raw.id);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.HttpServiceMapper = HttpServiceMapper;
|
|
16
|
+
//# sourceMappingURL=http-service-mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-service-mapper.js","sourceRoot":"","sources":["../../../../../../src/infra/services/item-service/http-client/http-service-mapper.ts"],"names":[],"mappings":";;;AAAA,qDAAsE;AAGtE,MAAa,iBAAiB;IAC1B,MAAM,CAAC,YAAY,CAAC,GAAiB;QACjC,OAAO,IAAI,iBAAU,CAAC;YAClB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,QAAQ,EAAE,mBAAY,CAAC,GAAG,CAAC,QAAQ,CAAC;YACpC,SAAS,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;SACrC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IACf,CAAC;CACJ;AATD,8CASC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createItemServiceHttpClient(baseUrl: string): import("openapi-fetch").Client<paths, `${string}/${string}`>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createItemServiceHttpClient = createItemServiceHttpClient;
|
|
4
|
+
const openapi_fetch_1 = require("openapi-fetch");
|
|
5
|
+
function createItemServiceHttpClient(baseUrl) {
|
|
6
|
+
return (0, openapi_fetch_1.default)({ baseUrl });
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=openapi-http-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-http-client.js","sourceRoot":"","sources":["../../../../../../src/infra/services/item-service/http-client/openapi-http-client.ts"],"names":[],"mappings":";;AAGA,kEAEC;AALD,iDAAyC;AAGzC,SAAgB,2BAA2B,CAAC,OAAe;IACzD,OAAO,IAAA,uBAAY,EAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ItemCategory } from '../../../application/entities/item';
|
|
2
|
+
export declare class CreateItemBody {
|
|
3
|
+
name: string;
|
|
4
|
+
category: ItemCategory;
|
|
5
|
+
price: number;
|
|
6
|
+
imageId?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class PatchItemBody {
|
|
9
|
+
name: string;
|
|
10
|
+
category: ItemCategory;
|
|
11
|
+
price: number;
|
|
12
|
+
imageId?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class ItemResponse {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
category: ItemCategory;
|
|
18
|
+
price: number;
|
|
19
|
+
createdAt: Date;
|
|
20
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ItemResponse = exports.PatchItemBody = exports.CreateItemBody = void 0;
|
|
13
|
+
const class_validator_1 = require("class-validator");
|
|
14
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
15
|
+
const item_1 = require("../../../application/entities/item");
|
|
16
|
+
class CreateItemBody {
|
|
17
|
+
}
|
|
18
|
+
exports.CreateItemBody = CreateItemBody;
|
|
19
|
+
__decorate([
|
|
20
|
+
(0, swagger_1.ApiProperty)({ example: 'Item 1' }),
|
|
21
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
22
|
+
(0, class_validator_1.Length)(5, 255),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], CreateItemBody.prototype, "name", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, swagger_1.ApiProperty)({ enum: item_1.ItemCategory }),
|
|
27
|
+
(0, class_validator_1.IsEnum)(item_1.ItemCategory),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], CreateItemBody.prototype, "category", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, swagger_1.ApiProperty)({ example: 10.0 }),
|
|
32
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
33
|
+
(0, class_validator_1.Min)(0.1),
|
|
34
|
+
(0, class_validator_1.IsPositive)(),
|
|
35
|
+
__metadata("design:type", Number)
|
|
36
|
+
], CreateItemBody.prototype, "price", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
39
|
+
(0, class_validator_1.IsOptional)(),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], CreateItemBody.prototype, "imageId", void 0);
|
|
42
|
+
class PatchItemBody {
|
|
43
|
+
}
|
|
44
|
+
exports.PatchItemBody = PatchItemBody;
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, swagger_1.ApiProperty)(),
|
|
47
|
+
(0, class_validator_1.IsOptional)(),
|
|
48
|
+
(0, class_validator_1.Length)(5, 255),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], PatchItemBody.prototype, "name", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, swagger_1.ApiProperty)({ enum: item_1.ItemCategory }),
|
|
53
|
+
(0, class_validator_1.IsEnum)(item_1.ItemCategory),
|
|
54
|
+
(0, class_validator_1.IsOptional)(),
|
|
55
|
+
__metadata("design:type", String)
|
|
56
|
+
], PatchItemBody.prototype, "category", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, swagger_1.ApiProperty)(),
|
|
59
|
+
(0, class_validator_1.IsOptional)(),
|
|
60
|
+
(0, class_validator_1.Min)(0.1),
|
|
61
|
+
(0, class_validator_1.IsPositive)(),
|
|
62
|
+
__metadata("design:type", Number)
|
|
63
|
+
], PatchItemBody.prototype, "price", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
66
|
+
(0, class_validator_1.IsOptional)(),
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], PatchItemBody.prototype, "imageId", void 0);
|
|
69
|
+
class ItemResponse {
|
|
70
|
+
}
|
|
71
|
+
exports.ItemResponse = ItemResponse;
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, swagger_1.ApiProperty)(),
|
|
74
|
+
__metadata("design:type", String)
|
|
75
|
+
], ItemResponse.prototype, "id", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
(0, swagger_1.ApiProperty)(),
|
|
78
|
+
__metadata("design:type", String)
|
|
79
|
+
], ItemResponse.prototype, "name", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
(0, swagger_1.ApiProperty)({ enum: item_1.ItemCategory }),
|
|
82
|
+
__metadata("design:type", String)
|
|
83
|
+
], ItemResponse.prototype, "category", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
(0, swagger_1.ApiProperty)(),
|
|
86
|
+
__metadata("design:type", Number)
|
|
87
|
+
], ItemResponse.prototype, "price", void 0);
|
|
88
|
+
__decorate([
|
|
89
|
+
(0, swagger_1.ApiProperty)(),
|
|
90
|
+
__metadata("design:type", Date)
|
|
91
|
+
], ItemResponse.prototype, "createdAt", void 0);
|
|
92
|
+
//# sourceMappingURL=item-dtos.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item-dtos.js","sourceRoot":"","sources":["../../../../../src/infra/services/item-service/item-dtos.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA2F;AAC3F,6C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ADC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,mBAAY,EAAE,CAAC;;8CACb;AAGvB;IADC,IAAA,qBAAW,GAAE;;2CACA;AAGd;IADC,IAAA,qBAAW,GAAE;8BACH,IAAI;+CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.MockItemServiceModule = exports.HttpItemServiceModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const item_service_1 = require("../../../application/services/item-service/item-service");
|
|
12
|
+
const http_client_service_1 = require("../../services/item-service/http-client/http-client.service");
|
|
13
|
+
const mock_item_service_1 = require("../../services/item-service/mock/mock-item-service");
|
|
14
|
+
let HttpItemServiceModule = class HttpItemServiceModule {
|
|
15
|
+
};
|
|
16
|
+
exports.HttpItemServiceModule = HttpItemServiceModule;
|
|
17
|
+
exports.HttpItemServiceModule = HttpItemServiceModule = __decorate([
|
|
18
|
+
(0, common_1.Module)({
|
|
19
|
+
providers: [
|
|
20
|
+
{
|
|
21
|
+
provide: item_service_1.ItemService,
|
|
22
|
+
useClass: http_client_service_1.HttpClientItemService
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
exports: [item_service_1.ItemService],
|
|
26
|
+
})
|
|
27
|
+
], HttpItemServiceModule);
|
|
28
|
+
let MockItemServiceModule = class MockItemServiceModule {
|
|
29
|
+
};
|
|
30
|
+
exports.MockItemServiceModule = MockItemServiceModule;
|
|
31
|
+
exports.MockItemServiceModule = MockItemServiceModule = __decorate([
|
|
32
|
+
(0, common_1.Module)({
|
|
33
|
+
providers: [
|
|
34
|
+
{
|
|
35
|
+
provide: item_service_1.ItemService,
|
|
36
|
+
useClass: mock_item_service_1.MockItemService
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
exports: [item_service_1.ItemService],
|
|
40
|
+
})
|
|
41
|
+
], MockItemServiceModule);
|
|
42
|
+
//# sourceMappingURL=item-service.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item-service.module.js","sourceRoot":"","sources":["../../../../../src/infra/services/item-service/item-service.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,kFAA8E;AAC9E,sGAAqG;AACrG,2FAAsF;AAW/E,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;CAAI,CAAA;AAAzB,sDAAqB;gCAArB,qBAAqB;IATjC,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,0BAAW;gBACpB,QAAQ,EAAE,2CAAqB;aAChC;SACF;QACD,OAAO,EAAE,CAAC,0BAAW,CAAC;KACvB,CAAC;GACW,qBAAqB,CAAI;AAW/B,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;CAAI,CAAA;AAAzB,sDAAqB;gCAArB,qBAAqB;IATjC,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,0BAAW;gBACpB,QAAQ,EAAE,mCAAe;aAC1B;SACF;QACD,OAAO,EAAE,CAAC,0BAAW,CAAC;KACvB,CAAC;GACW,qBAAqB,CAAI"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CommonItem } from "../../../../application/entities/item";
|
|
2
|
+
import { ItemService } from "../../../../application/services/item-service/item-service";
|
|
3
|
+
export declare class MockItemService extends ItemService {
|
|
4
|
+
private items;
|
|
5
|
+
constructor();
|
|
6
|
+
private seedMockData;
|
|
7
|
+
findById(itemId: string): Promise<CommonItem | null>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MockItemService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const item_1 = require("../../../../application/entities/item");
|
|
15
|
+
const item_service_1 = require("../../../../application/services/item-service/item-service");
|
|
16
|
+
let MockItemService = class MockItemService extends item_service_1.ItemService {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.items = new Map();
|
|
20
|
+
this.seedMockData();
|
|
21
|
+
}
|
|
22
|
+
seedMockData() {
|
|
23
|
+
const mockItems = [
|
|
24
|
+
new item_1.CommonItem({
|
|
25
|
+
name: "Classic Burger",
|
|
26
|
+
category: item_1.ItemCategory.BURGER,
|
|
27
|
+
price: 25,
|
|
28
|
+
imageId: "burger-1",
|
|
29
|
+
}, "123e4567-e89b-12d3-a456-426614174000"),
|
|
30
|
+
new item_1.CommonItem({
|
|
31
|
+
name: "Cheese Burger",
|
|
32
|
+
category: item_1.ItemCategory.BURGER,
|
|
33
|
+
price: 29,
|
|
34
|
+
imageId: "burger-2",
|
|
35
|
+
}, "123e4567-e89b-12d3-a456-426614174001"),
|
|
36
|
+
new item_1.CommonItem({
|
|
37
|
+
name: "French Fries",
|
|
38
|
+
category: item_1.ItemCategory.SIDE,
|
|
39
|
+
price: 12,
|
|
40
|
+
imageId: "side-1",
|
|
41
|
+
}, "123e4567-e89b-12d3-a456-426614174002"),
|
|
42
|
+
new item_1.CommonItem({
|
|
43
|
+
name: "Onion Rings",
|
|
44
|
+
category: item_1.ItemCategory.SIDE,
|
|
45
|
+
price: 14,
|
|
46
|
+
imageId: "side-2",
|
|
47
|
+
}, "123e4567-e89b-12d3-a456-426614174003"),
|
|
48
|
+
new item_1.CommonItem({
|
|
49
|
+
name: "Coca-Cola",
|
|
50
|
+
category: item_1.ItemCategory.BEVERAGE,
|
|
51
|
+
price: 8,
|
|
52
|
+
imageId: "beverage-1",
|
|
53
|
+
}, "123e4567-e89b-12d3-a456-426614174004"),
|
|
54
|
+
new item_1.CommonItem({
|
|
55
|
+
name: "Orange Juice",
|
|
56
|
+
category: item_1.ItemCategory.BEVERAGE,
|
|
57
|
+
price: 10,
|
|
58
|
+
imageId: "beverage-2",
|
|
59
|
+
}, "123e4567-e89b-12d3-a456-426614174005"),
|
|
60
|
+
new item_1.CommonItem({
|
|
61
|
+
name: "Chocolate Sundae",
|
|
62
|
+
category: item_1.ItemCategory.SWEAT,
|
|
63
|
+
price: 15,
|
|
64
|
+
imageId: "sweet-1",
|
|
65
|
+
}, "123e4567-e89b-12d3-a456-426614174006"),
|
|
66
|
+
];
|
|
67
|
+
mockItems.forEach((item) => {
|
|
68
|
+
this.items.set(item.id, item);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
async findById(itemId) {
|
|
72
|
+
const item = this.items.get(itemId);
|
|
73
|
+
return item !== null && item !== void 0 ? item : null;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
exports.MockItemService = MockItemService;
|
|
77
|
+
exports.MockItemService = MockItemService = __decorate([
|
|
78
|
+
(0, common_1.Injectable)(),
|
|
79
|
+
__metadata("design:paramtypes", [])
|
|
80
|
+
], MockItemService);
|
|
81
|
+
//# sourceMappingURL=mock-item-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-item-service.js","sourceRoot":"","sources":["../../../../../../src/infra/services/item-service/mock/mock-item-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,qDAAsE;AACtE,kFAA8E;AAGvE,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,0BAAW;IAG9C;QACE,KAAK,EAAE,CAAC;QAHF,UAAK,GAA4B,IAAI,GAAG,EAAE,CAAC;QAIjD,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAEO,YAAY;QAClB,MAAM,SAAS,GAAG;YAChB,IAAI,iBAAU,CACZ;gBACE,IAAI,EAAE,gBAAgB;gBACtB,QAAQ,EAAE,mBAAY,CAAC,MAAM;gBAC7B,KAAK,EAAE,EAAE;gBACT,OAAO,EAAE,UAAU;aACpB,EACD,sCAAsC,CACvC;YACD,IAAI,iBAAU,CACZ;gBACE,IAAI,EAAE,eAAe;gBACrB,QAAQ,EAAE,mBAAY,CAAC,MAAM;gBAC7B,KAAK,EAAE,EAAE;gBACT,OAAO,EAAE,UAAU;aACpB,EACD,sCAAsC,CACvC;YACD,IAAI,iBAAU,CACZ;gBACE,IAAI,EAAE,cAAc;gBACpB,QAAQ,EAAE,mBAAY,CAAC,IAAI;gBAC3B,KAAK,EAAE,EAAE;gBACT,OAAO,EAAE,QAAQ;aAClB,EACD,sCAAsC,CACvC;YACD,IAAI,iBAAU,CACZ;gBACE,IAAI,EAAE,aAAa;gBACnB,QAAQ,EAAE,mBAAY,CAAC,IAAI;gBAC3B,KAAK,EAAE,EAAE;gBACT,OAAO,EAAE,QAAQ;aAClB,EACD,sCAAsC,CACvC;YACD,IAAI,iBAAU,CACZ;gBACE,IAAI,EAAE,WAAW;gBACjB,QAAQ,EAAE,mBAAY,CAAC,QAAQ;gBAC/B,KAAK,EAAE,CAAC;gBACR,OAAO,EAAE,YAAY;aACtB,EACD,sCAAsC,CACvC;YACD,IAAI,iBAAU,CACZ;gBACE,IAAI,EAAE,cAAc;gBACpB,QAAQ,EAAE,mBAAY,CAAC,QAAQ;gBAC/B,KAAK,EAAE,EAAE;gBACT,OAAO,EAAE,YAAY;aACtB,EACD,sCAAsC,CACvC;YACD,IAAI,iBAAU,CACZ;gBACE,IAAI,EAAE,kBAAkB;gBACxB,QAAQ,EAAE,mBAAY,CAAC,KAAK;gBAC5B,KAAK,EAAE,EAAE;gBACT,OAAO,EAAE,SAAS;aACnB,EACD,sCAAsC,CACvC;SACF,CAAC;QAEF,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACzB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAc;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACpC,OAAO,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,IAAI,CAAC;IACtB,CAAC;CACF,CAAA;AApFY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,mBAAU,GAAE;;GACA,eAAe,CAoF3B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.MockItemServiceModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const item_service_1 = require("../../../../application/services/item-service/item-service");
|
|
12
|
+
const mock_item_service_1 = require("./mock-item.service");
|
|
13
|
+
let MockItemServiceModule = class MockItemServiceModule {
|
|
14
|
+
};
|
|
15
|
+
exports.MockItemServiceModule = MockItemServiceModule;
|
|
16
|
+
exports.MockItemServiceModule = MockItemServiceModule = __decorate([
|
|
17
|
+
(0, common_1.Module)({
|
|
18
|
+
providers: [
|
|
19
|
+
{
|
|
20
|
+
provide: item_service_1.ItemService,
|
|
21
|
+
useClass: mock_item_service_1.MockItemService,
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
exports: [mock_item_service_1.MockItemService],
|
|
25
|
+
})
|
|
26
|
+
], MockItemServiceModule);
|
|
27
|
+
//# sourceMappingURL=mock-item-service.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-item-service.module.js","sourceRoot":"","sources":["../../../../../../src/infra/services/item-service/mock/mock-item-service.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,kFAA8E;AAC9E,2DAAsD;AAW/C,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;CAAG,CAAA;AAAxB,sDAAqB;gCAArB,qBAAqB;IATjC,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,0BAAW;gBACpB,QAAQ,EAAE,mCAAe;aAC1B;SACF;QACD,OAAO,EAAE,CAAC,mCAAe,CAAC;KAC3B,CAAC;GACW,qBAAqB,CAAG"}
|