@tec.pet/tecpet-sdk 0.0.172 → 0.0.174
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/domain/booking/dto/pa.add-services-to-booking.dto.d.ts +2 -0
- package/dist/domain/booking/dto/pa.create-booking.dto.d.ts +3 -1
- package/dist/domain/booking/dto/pa.get-booking-pricing.dto.d.ts +2 -0
- package/dist/domain/booking/dto/pa.get-booking.dto.d.ts +2 -0
- package/dist/domain/booking/dto/pa.reschedule-booking.dto.d.ts +4 -2
- package/dist/domain/chatbot/dto/chatbot-settings.json.d.ts +1 -0
- package/dist/domain/service/dto/pa.get-service-pricing.dto.d.ts +6 -0
- package/dist/domain/serviceCapacity/dto/pa.get-service-capacity.dto.d.ts +17 -0
- package/dist/domain/serviceCapacity/dto/pa.get-service-capacity.dto.js +2 -0
- package/dist/domain/serviceCapacity/enum/capacity-configuration-type.enum.d.ts +5 -0
- package/dist/domain/serviceCapacity/enum/capacity-configuration-type.enum.js +9 -0
- package/dist/domain/serviceCapacity/index.d.ts +2 -0
- package/dist/domain/serviceCapacity/index.js +18 -0
- package/dist/domain/serviceCapacity/serviceCapacity.service.d.ts +7 -0
- package/dist/domain/serviceCapacity/serviceCapacity.service.js +14 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/utils/chatbot/chatbot-trigger.matcher.d.ts +14 -0
- package/dist/utils/chatbot/chatbot-trigger.matcher.js +63 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +6 -2
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { CapacityConfigurationType } from "../../serviceCapacity/enum/capacity-configuration-type.enum";
|
|
1
2
|
export interface PaAddServicesToBookingInput {
|
|
2
3
|
services: number[];
|
|
3
4
|
combos?: number[];
|
|
5
|
+
period?: CapacityConfigurationType;
|
|
4
6
|
}
|
|
5
7
|
export interface PaAddServicesToBookingResponse {
|
|
6
8
|
success: boolean;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { PaEmployeeIndication } from "../../employee";
|
|
2
2
|
import { ShopSegment } from "../../segment/enum/segment.enum";
|
|
3
|
+
import { CapacityConfigurationType } from "../../serviceCapacity/enum/capacity-configuration-type.enum";
|
|
3
4
|
export interface PaCreateBookingInput {
|
|
4
5
|
date?: string;
|
|
5
|
-
timeId
|
|
6
|
+
timeId?: string;
|
|
6
7
|
petId?: number;
|
|
7
8
|
servicesId: Array<number>;
|
|
8
9
|
combosId: Array<number>;
|
|
@@ -10,6 +11,7 @@ export interface PaCreateBookingInput {
|
|
|
10
11
|
comment?: string;
|
|
11
12
|
plan?: PaPlanBookingInput;
|
|
12
13
|
employeeIndication?: Array<PaEmployeeIndication>;
|
|
14
|
+
period?: CapacityConfigurationType;
|
|
13
15
|
}
|
|
14
16
|
export interface PaPlanBookingInput {
|
|
15
17
|
petPlan: number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ShopSegment } from '../../segment/enum/segment.enum';
|
|
2
2
|
import { BillingItemType } from '../../billingMethod/enum/billing-method-type.enum';
|
|
3
|
+
import { CapacityConfigurationType } from '../../serviceCapacity/enum/capacity-configuration-type.enum';
|
|
3
4
|
export interface PaGetBookingPricingBody {
|
|
4
5
|
petId?: number;
|
|
5
6
|
segment: ShopSegment;
|
|
@@ -7,6 +8,7 @@ export interface PaGetBookingPricingBody {
|
|
|
7
8
|
hair?: BillingItemType;
|
|
8
9
|
size?: BillingItemType;
|
|
9
10
|
breed?: number;
|
|
11
|
+
period?: CapacityConfigurationType;
|
|
10
12
|
}
|
|
11
13
|
export interface PaGetBookingPricingResponse {
|
|
12
14
|
totalPrice: number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ShopSegment } from "../../segment/enum/segment.enum";
|
|
2
2
|
import { ServiceCategoryType } from "../../service";
|
|
3
|
+
import { CapacityConfigurationType } from "../../serviceCapacity/enum/capacity-configuration-type.enum";
|
|
3
4
|
export declare enum Status {
|
|
4
5
|
SCHEDULED = "SCHEDULED",
|
|
5
6
|
CONFIRMED = "CONFIRMED",
|
|
@@ -30,6 +31,7 @@ export interface PaGetBookingResponse {
|
|
|
30
31
|
}>;
|
|
31
32
|
petPlanId?: number;
|
|
32
33
|
hasTakeAndBring?: boolean;
|
|
34
|
+
period?: CapacityConfigurationType;
|
|
33
35
|
}
|
|
34
36
|
export interface PaBookingInvoiceResponse {
|
|
35
37
|
id: string;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { CapacityConfigurationType } from "../../serviceCapacity/enum/capacity-configuration-type.enum";
|
|
1
2
|
export interface PaRescheduleBookingInput {
|
|
2
|
-
date
|
|
3
|
-
timeId
|
|
3
|
+
date?: string;
|
|
4
|
+
timeId?: string;
|
|
5
|
+
period?: CapacityConfigurationType;
|
|
4
6
|
}
|
|
5
7
|
export interface PaRescheduleBookingResponse {
|
|
6
8
|
success: boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CapacityConfigurationType } from "../../serviceCapacity/enum/capacity-configuration-type.enum";
|
|
1
2
|
export declare enum ServiceCategoryType {
|
|
2
3
|
BATH = "BATH",
|
|
3
4
|
GROOM = "GROOM",
|
|
@@ -8,6 +9,10 @@ export declare enum ServiceCategoryType {
|
|
|
8
9
|
CUSTOM = "CUSTOM",
|
|
9
10
|
TAKE_AND_BRING = "TAKE_AND_BRING"
|
|
10
11
|
}
|
|
12
|
+
export interface PaServicePriceVariation {
|
|
13
|
+
type: CapacityConfigurationType;
|
|
14
|
+
price: number;
|
|
15
|
+
}
|
|
11
16
|
export interface PaServicePricingResponse {
|
|
12
17
|
id: number;
|
|
13
18
|
name: string;
|
|
@@ -15,6 +20,7 @@ export interface PaServicePricingResponse {
|
|
|
15
20
|
description: string;
|
|
16
21
|
orientation: string;
|
|
17
22
|
serviceCategory: PaServiceCategoryResponse;
|
|
23
|
+
priceVariations?: PaServicePriceVariation[];
|
|
18
24
|
}
|
|
19
25
|
export interface PaServiceCategoryResponse {
|
|
20
26
|
id: number;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ShopSegment } from "../../segment/enum/segment.enum";
|
|
2
|
+
import { CapacityConfigurationType } from "../enum/capacity-configuration-type.enum";
|
|
3
|
+
export interface PaGetServiceCapacityBody {
|
|
4
|
+
date: string;
|
|
5
|
+
segment: ShopSegment;
|
|
6
|
+
serviceId: number;
|
|
7
|
+
petId?: number;
|
|
8
|
+
bookingIdException?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface PaServiceCapacityResponse {
|
|
11
|
+
period: CapacityConfigurationType;
|
|
12
|
+
defaultCheckin: string;
|
|
13
|
+
defaultCheckout: string;
|
|
14
|
+
capacity: number;
|
|
15
|
+
allocated: number;
|
|
16
|
+
available: number;
|
|
17
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CapacityConfigurationType = void 0;
|
|
4
|
+
var CapacityConfigurationType;
|
|
5
|
+
(function (CapacityConfigurationType) {
|
|
6
|
+
CapacityConfigurationType["MORNING"] = "MORNING";
|
|
7
|
+
CapacityConfigurationType["EVENING"] = "EVENING";
|
|
8
|
+
CapacityConfigurationType["ALL_DAY"] = "ALL_DAY";
|
|
9
|
+
})(CapacityConfigurationType || (exports.CapacityConfigurationType = CapacityConfigurationType = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./dto/pa.get-service-capacity.dto"), exports);
|
|
18
|
+
__exportStar(require("./enum/capacity-configuration-type.enum"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HttpClient } from "infra/http/client.http";
|
|
2
|
+
import { PaGetServiceCapacityBody, PaServiceCapacityResponse } from "./dto/pa.get-service-capacity.dto";
|
|
3
|
+
export declare class ServiceCapacityService {
|
|
4
|
+
private readonly api;
|
|
5
|
+
constructor(api: HttpClient);
|
|
6
|
+
getServiceCapacity(body: PaGetServiceCapacityBody, shopId: number): Promise<Array<PaServiceCapacityResponse>>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ServiceCapacityService = void 0;
|
|
4
|
+
class ServiceCapacityService {
|
|
5
|
+
api;
|
|
6
|
+
constructor(api) {
|
|
7
|
+
this.api = api;
|
|
8
|
+
}
|
|
9
|
+
async getServiceCapacity(body, shopId) {
|
|
10
|
+
const response = await this.api.post(`/service-capacity`, body, shopId);
|
|
11
|
+
return response ?? [];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.ServiceCapacityService = ServiceCapacityService;
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ import { InvoiceService } from "./domain/invoice/invoice.service";
|
|
|
22
22
|
import { ServiceRecommendationService } from "./domain/serviceRecommendation/serviceRecommendation.service";
|
|
23
23
|
import { BlockedTimeService } from "./domain/blockedTime/blockedTime.service";
|
|
24
24
|
import { CepService } from "./domain/cep/cep.service";
|
|
25
|
+
import { ServiceCapacityService } from "./domain/serviceCapacity/serviceCapacity.service";
|
|
25
26
|
export declare class TecpetSDK {
|
|
26
27
|
private api;
|
|
27
28
|
client: ClientService;
|
|
@@ -48,6 +49,7 @@ export declare class TecpetSDK {
|
|
|
48
49
|
blockedTime: BlockedTimeService;
|
|
49
50
|
cep: CepService;
|
|
50
51
|
customField: CustomFieldService;
|
|
52
|
+
serviceCapacity: ServiceCapacityService;
|
|
51
53
|
constructor(baseURL: string, apiKey?: string);
|
|
52
54
|
}
|
|
53
55
|
export * from './domain/availableTimes';
|
|
@@ -74,6 +76,7 @@ export * from './domain/serviceRecommendation';
|
|
|
74
76
|
export * from './domain/blockedTime';
|
|
75
77
|
export * from './domain/cep';
|
|
76
78
|
export * from './domain/customField';
|
|
79
|
+
export * from './domain/serviceCapacity';
|
|
77
80
|
export * from './utils/index';
|
|
78
81
|
export * from './domain/petPlan';
|
|
79
82
|
export * from './domain/chain';
|
package/dist/index.js
CHANGED
|
@@ -40,6 +40,7 @@ const invoice_service_1 = require("./domain/invoice/invoice.service");
|
|
|
40
40
|
const serviceRecommendation_service_1 = require("./domain/serviceRecommendation/serviceRecommendation.service");
|
|
41
41
|
const blockedTime_service_1 = require("./domain/blockedTime/blockedTime.service");
|
|
42
42
|
const cep_service_1 = require("./domain/cep/cep.service");
|
|
43
|
+
const serviceCapacity_service_1 = require("./domain/serviceCapacity/serviceCapacity.service");
|
|
43
44
|
class TecpetSDK {
|
|
44
45
|
api;
|
|
45
46
|
client;
|
|
@@ -66,6 +67,7 @@ class TecpetSDK {
|
|
|
66
67
|
blockedTime;
|
|
67
68
|
cep;
|
|
68
69
|
customField;
|
|
70
|
+
serviceCapacity;
|
|
69
71
|
constructor(baseURL, apiKey) {
|
|
70
72
|
this.api = new client_http_1.HttpClient(baseURL, apiKey);
|
|
71
73
|
this.client = new client_service_1.ClientService(this.api);
|
|
@@ -92,6 +94,7 @@ class TecpetSDK {
|
|
|
92
94
|
this.serviceRecommendation = new serviceRecommendation_service_1.ServiceRecommendationService(this.api);
|
|
93
95
|
this.blockedTime = new blockedTime_service_1.BlockedTimeService(this.api);
|
|
94
96
|
this.cep = new cep_service_1.CepService(this.api);
|
|
97
|
+
this.serviceCapacity = new serviceCapacity_service_1.ServiceCapacityService(this.api);
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
exports.TecpetSDK = TecpetSDK;
|
|
@@ -119,6 +122,7 @@ __exportStar(require("./domain/serviceRecommendation"), exports);
|
|
|
119
122
|
__exportStar(require("./domain/blockedTime"), exports);
|
|
120
123
|
__exportStar(require("./domain/cep"), exports);
|
|
121
124
|
__exportStar(require("./domain/customField"), exports);
|
|
125
|
+
__exportStar(require("./domain/serviceCapacity"), exports);
|
|
122
126
|
__exportStar(require("./utils/index"), exports);
|
|
123
127
|
__exportStar(require("./domain/petPlan"), exports);
|
|
124
128
|
__exportStar(require("./domain/chain"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ChatbotActionJson, ChatbotTriggerJson } from '../../domain/chatbot/dto/chatbot-settings.json';
|
|
2
|
+
export interface ChatbotTriggerMatch {
|
|
3
|
+
trigger: ChatbotTriggerJson;
|
|
4
|
+
action: ChatbotActionJson;
|
|
5
|
+
}
|
|
6
|
+
export interface MatchChatbotTriggerInput {
|
|
7
|
+
message: string;
|
|
8
|
+
triggers?: ChatbotTriggerJson[];
|
|
9
|
+
actions?: ChatbotActionJson[];
|
|
10
|
+
now?: Date;
|
|
11
|
+
}
|
|
12
|
+
export declare function normalizeChatbotTriggerText(value?: string): string;
|
|
13
|
+
export declare function isChatbotTriggerExpired(trigger: ChatbotTriggerJson, now?: Date): boolean;
|
|
14
|
+
export declare function matchChatbotTrigger({ message, triggers, actions, now, }: MatchChatbotTriggerInput): ChatbotTriggerMatch | null;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeChatbotTriggerText = normalizeChatbotTriggerText;
|
|
4
|
+
exports.isChatbotTriggerExpired = isChatbotTriggerExpired;
|
|
5
|
+
exports.matchChatbotTrigger = matchChatbotTrigger;
|
|
6
|
+
const chatbot_trigger_pattern_type_enum_1 = require("../../domain/chatbot/enum/chatbotTriggerEnums/chatbot-trigger-pattern-type.enum");
|
|
7
|
+
const DIACRITICS = /\p{Diacritic}/gu;
|
|
8
|
+
const INVISIBLE_CHARACTERS = /[\u00AD\u200B-\u200F\u2060\uFEFF]/gu;
|
|
9
|
+
const NON_ALPHANUMERIC = /[^\p{L}\p{N}\s]/gu;
|
|
10
|
+
const WHITESPACE = /\s+/gu;
|
|
11
|
+
function normalizeChatbotTriggerText(value) {
|
|
12
|
+
if (!value) {
|
|
13
|
+
return '';
|
|
14
|
+
}
|
|
15
|
+
return value
|
|
16
|
+
.normalize('NFD')
|
|
17
|
+
.replace(DIACRITICS, '')
|
|
18
|
+
.replace(INVISIBLE_CHARACTERS, '')
|
|
19
|
+
.replace(NON_ALPHANUMERIC, ' ')
|
|
20
|
+
.replace(WHITESPACE, ' ')
|
|
21
|
+
.trim()
|
|
22
|
+
.toLowerCase();
|
|
23
|
+
}
|
|
24
|
+
function isChatbotTriggerExpired(trigger, now = new Date()) {
|
|
25
|
+
if (!trigger.limit) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const limit = new Date(trigger.limit);
|
|
29
|
+
if (Number.isNaN(limit.getTime())) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const endOfLimitDay = Date.UTC(limit.getUTCFullYear(), limit.getUTCMonth(), limit.getUTCDate(), 23, 59, 59, 999);
|
|
33
|
+
return endOfLimitDay < now.getTime();
|
|
34
|
+
}
|
|
35
|
+
function matchChatbotTrigger({ message, triggers, actions, now = new Date(), }) {
|
|
36
|
+
const normalizedMessage = normalizeChatbotTriggerText(message);
|
|
37
|
+
if (!normalizedMessage || !triggers?.length || !actions?.length) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const enabledActions = actions.filter(action => action.enabled);
|
|
41
|
+
for (const trigger of triggers) {
|
|
42
|
+
if (!trigger.enabled || isChatbotTriggerExpired(trigger, now)) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const normalizedKeyText = normalizeChatbotTriggerText(trigger.keyText);
|
|
46
|
+
if (!normalizedKeyText) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const matched = trigger.patternType === chatbot_trigger_pattern_type_enum_1.ChatbotTriggerPatternTypeEnum.EXACTLY_MATCH
|
|
50
|
+
? normalizedMessage === normalizedKeyText
|
|
51
|
+
: trigger.patternType === chatbot_trigger_pattern_type_enum_1.ChatbotTriggerPatternTypeEnum.CONTAIN_TEXT &&
|
|
52
|
+
normalizedMessage.includes(normalizedKeyText);
|
|
53
|
+
if (!matched) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const action = enabledActions.find(enabledAction => enabledAction.id === trigger.chatbotAction?.id);
|
|
57
|
+
if (!action) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
return { trigger, action };
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./validators/cpf.validator"), exports);
|
|
18
|
+
__exportStar(require("./chatbot/chatbot-trigger.matcher"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tec.pet/tecpet-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.174",
|
|
4
4
|
"description": "TecPet SDK for integration with TecPet services",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "tsc",
|
|
23
|
-
"watch": "tsc-watch"
|
|
23
|
+
"watch": "tsc-watch",
|
|
24
|
+
"test": "jest"
|
|
24
25
|
},
|
|
25
26
|
"engines": {
|
|
26
27
|
"node": ">=23"
|
|
@@ -32,6 +33,9 @@
|
|
|
32
33
|
"date-fns": "^4.1.0"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
36
|
+
"@types/jest": "^29.5.14",
|
|
37
|
+
"jest": "^29.7.0",
|
|
38
|
+
"ts-jest": "^29.3.0",
|
|
35
39
|
"tsc-watch": "^6.2.1",
|
|
36
40
|
"typescript": "^5.8.2"
|
|
37
41
|
}
|