@snugdesk/core 0.2.3 → 0.2.5
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/fesm2022/snugdesk-core-src-lib-models-dynamodb.mjs +25 -0
- package/fesm2022/snugdesk-core-src-lib-models-dynamodb.mjs.map +1 -0
- package/fesm2022/snugdesk-core.mjs +262 -108
- package/fesm2022/snugdesk-core.mjs.map +1 -1
- package/index.d.ts +79 -31
- package/package.json +5 -1
- package/src/lib/models/dynamodb/index.d.ts +176 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var ModelAttributeTypes;
|
|
2
|
+
(function (ModelAttributeTypes) {
|
|
3
|
+
ModelAttributeTypes["binary"] = "binary";
|
|
4
|
+
ModelAttributeTypes["binarySet"] = "binarySet";
|
|
5
|
+
ModelAttributeTypes["bool"] = "bool";
|
|
6
|
+
ModelAttributeTypes["list"] = "list";
|
|
7
|
+
ModelAttributeTypes["map"] = "map";
|
|
8
|
+
ModelAttributeTypes["number"] = "number";
|
|
9
|
+
ModelAttributeTypes["numberSet"] = "numberSet";
|
|
10
|
+
ModelAttributeTypes["string"] = "string";
|
|
11
|
+
ModelAttributeTypes["stringSet"] = "stringSet";
|
|
12
|
+
ModelAttributeTypes["_null"] = "_null";
|
|
13
|
+
})(ModelAttributeTypes || (ModelAttributeTypes = {}));
|
|
14
|
+
var ModelSortDirection;
|
|
15
|
+
(function (ModelSortDirection) {
|
|
16
|
+
ModelSortDirection["ASC"] = "ASC";
|
|
17
|
+
ModelSortDirection["DESC"] = "DESC";
|
|
18
|
+
})(ModelSortDirection || (ModelSortDirection = {}));
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Generated bundle index. Do not edit.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
export { ModelAttributeTypes, ModelSortDirection };
|
|
25
|
+
//# sourceMappingURL=snugdesk-core-src-lib-models-dynamodb.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snugdesk-core-src-lib-models-dynamodb.mjs","sources":["../../../projects/snugdesk-core/src/lib/models/dynamodb/common.model.ts","../../../projects/snugdesk-core/src/lib/models/dynamodb/snugdesk-core-src-lib-models-dynamodb.ts"],"sourcesContent":["import { GraphQLResult } from '@aws-amplify/api-graphql';\n\nexport enum ModelAttributeTypes {\n binary = 'binary',\n binarySet = 'binarySet',\n bool = 'bool',\n list = 'list',\n map = 'map',\n number = 'number',\n numberSet = 'numberSet',\n string = 'string',\n stringSet = 'stringSet',\n _null = '_null',\n}\n\nexport enum ModelSortDirection {\n ASC = 'ASC',\n DESC = 'DESC',\n}\n\nexport type ModelSizeInput = {\n ne?: number | null;\n eq?: number | null;\n le?: number | null;\n lt?: number | null;\n ge?: number | null;\n gt?: number | null;\n between?: Array<number | null> | null;\n};\n\nexport type ModelBooleanInput = {\n ne?: boolean | null;\n eq?: boolean | null;\n attributeExists?: boolean | null;\n attributeType?: ModelAttributeTypes | null;\n};\n\nexport type ModelIDInput = {\n ne?: string | null;\n eq?: string | null;\n le?: string | null;\n lt?: string | null;\n ge?: string | null;\n gt?: string | null;\n contains?: string | null;\n notContains?: string | null;\n between?: Array<string | null> | null;\n beginsWith?: string | null;\n attributeExists?: boolean | null;\n attributeType?: ModelAttributeTypes | null;\n size?: ModelSizeInput | null;\n};\n\nexport type ModelIntInput = {\n ne?: number | null;\n eq?: number | null;\n le?: number | null;\n lt?: number | null;\n ge?: number | null;\n gt?: number | null;\n between?: Array<number | null> | null;\n attributeExists?: boolean | null;\n attributeType?: ModelAttributeTypes | null;\n};\n\nexport type ModelStringInput = {\n ne?: string | null;\n eq?: string | null;\n le?: string | null;\n lt?: string | null;\n ge?: string | null;\n gt?: string | null;\n contains?: string | null;\n notContains?: string | null;\n between?: Array<string | null> | null;\n beginsWith?: string | null;\n attributeExists?: boolean | null;\n attributeType?: ModelAttributeTypes | null;\n size?: ModelSizeInput | null;\n};\n\nexport type ModelIDKeyConditionInput = {\n eq?: string | null;\n le?: string | null;\n lt?: string | null;\n ge?: string | null;\n gt?: string | null;\n between?: Array<string | null> | null;\n beginsWith?: string | null;\n};\n\nexport type ModelIntKeyConditionInput = {\n eq?: number | null;\n le?: number | null;\n lt?: number | null;\n ge?: number | null;\n gt?: number | null;\n between?: Array<number | null> | null;\n};\n\nexport type ModelStringKeyConditionInput = {\n eq?: string | null;\n le?: string | null;\n lt?: string | null;\n ge?: string | null;\n gt?: string | null;\n between?: Array<string | null> | null;\n beginsWith?: string | null;\n};\n\nexport type List<T> = {\n items: Array<T | null>;\n nextToken?: string | null;\n};\n\nexport interface SubscriptionResponse<T> {\n value: GraphQLResult<T>;\n}\n\nexport type Country = {\n code: string;\n nameEn: string;\n nameLocal?: string | null;\n currency?: CountryCurrency | null;\n officialLanguage?: Language | null;\n callingCode?: string | null;\n region?: string | null;\n flag?: string | null;\n};\n\nexport type CountryCurrency = {\n code: string;\n nameEn: string;\n};\n\nexport type Language = {\n code: string;\n nameEn: string;\n nameLocal?: string | null;\n};\n\nexport type PhoneNumber = {\n countryCode?: string | null;\n dialCode?: string | null;\n e164Number?: string | null;\n internationalNumber?: string | null;\n nationalNumber?: string | null;\n number?: string | null;\n};\n\nexport type S3Object = {\n key: string;\n bucket: string;\n location: string;\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"IAEY;AAAZ,CAAA,UAAY,mBAAmB,EAAA;AAC7B,IAAA,mBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,mBAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACvB,IAAA,mBAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,mBAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,mBAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,mBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,mBAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACvB,IAAA,mBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,mBAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACvB,IAAA,mBAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACjB,CAAC,EAXW,mBAAmB,KAAnB,mBAAmB,GAAA,EAAA,CAAA,CAAA;IAanB;AAAZ,CAAA,UAAY,kBAAkB,EAAA;AAC5B,IAAA,kBAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,kBAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACf,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,GAAA,EAAA,CAAA,CAAA;;ACf9B;;AAEG;;;;"}
|
|
@@ -950,6 +950,54 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
950
950
|
args: [AMPLIFY_CONFIG]
|
|
951
951
|
}] }, { type: SnugdeskAuthenticationService }] });
|
|
952
952
|
|
|
953
|
+
class OpenSearchHelperService {
|
|
954
|
+
httpClient;
|
|
955
|
+
jsonHeaders = new HttpHeaders({
|
|
956
|
+
'Content-Type': 'application/json',
|
|
957
|
+
});
|
|
958
|
+
constructor(httpClient) {
|
|
959
|
+
this.httpClient = httpClient;
|
|
960
|
+
}
|
|
961
|
+
buildOpenSearchProxyEndpoint(index) {
|
|
962
|
+
return `${SnugdeskAPIConfig.endpoint}/opensearch/${index}`;
|
|
963
|
+
}
|
|
964
|
+
searchIndex(index, body) {
|
|
965
|
+
return lastValueFrom(this.httpClient.post(this.buildOpenSearchProxyEndpoint(index), body, {
|
|
966
|
+
headers: this.jsonHeaders,
|
|
967
|
+
}));
|
|
968
|
+
}
|
|
969
|
+
parseSearchResults(response) {
|
|
970
|
+
const hits = response?.hits?.hits ?? [];
|
|
971
|
+
return hits.map(this.mapHitToSource);
|
|
972
|
+
}
|
|
973
|
+
parseTotalCount(response) {
|
|
974
|
+
const total = response?.hits?.total;
|
|
975
|
+
if (typeof total === 'number') {
|
|
976
|
+
return total;
|
|
977
|
+
}
|
|
978
|
+
if (total && typeof total.value === 'number') {
|
|
979
|
+
return total.value;
|
|
980
|
+
}
|
|
981
|
+
return 0;
|
|
982
|
+
}
|
|
983
|
+
mapHitToSource(hit) {
|
|
984
|
+
const source = hit?.fields ?? hit?._source ?? {};
|
|
985
|
+
const id = hit?.id ?? source?.id ?? hit?._id;
|
|
986
|
+
return {
|
|
987
|
+
...source,
|
|
988
|
+
id,
|
|
989
|
+
};
|
|
990
|
+
}
|
|
991
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: OpenSearchHelperService, deps: [{ token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
992
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: OpenSearchHelperService, providedIn: 'root' });
|
|
993
|
+
}
|
|
994
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: OpenSearchHelperService, decorators: [{
|
|
995
|
+
type: Injectable,
|
|
996
|
+
args: [{
|
|
997
|
+
providedIn: 'root',
|
|
998
|
+
}]
|
|
999
|
+
}], ctorParameters: () => [{ type: i1$2.HttpClient }] });
|
|
1000
|
+
|
|
953
1001
|
class S3HelperService {
|
|
954
1002
|
http;
|
|
955
1003
|
API_BASE = 'https://api.snugdesk.com/s3';
|
|
@@ -1752,10 +1800,13 @@ var InteractionStatus;
|
|
|
1752
1800
|
var InteractionProvider;
|
|
1753
1801
|
(function (InteractionProvider) {
|
|
1754
1802
|
InteractionProvider["AVAYA_IPO"] = "AVAYA_IPO";
|
|
1803
|
+
InteractionProvider["FACEBOOK"] = "FACEBOOK";
|
|
1804
|
+
InteractionProvider["INSTAGRAM"] = "INSTAGRAM";
|
|
1805
|
+
InteractionProvider["OZONETEL"] = "OZONETEL";
|
|
1806
|
+
InteractionProvider["SNUGDESK"] = "SNUGDESK";
|
|
1807
|
+
InteractionProvider["TELEGRAM"] = "TELEGRAM";
|
|
1755
1808
|
InteractionProvider["TELNYX"] = "TELNYX";
|
|
1756
1809
|
InteractionProvider["WHATSAPP"] = "WHATSAPP";
|
|
1757
|
-
InteractionProvider["TELEGRAM"] = "TELEGRAM";
|
|
1758
|
-
InteractionProvider["SNUGDESK"] = "SNUGDESK";
|
|
1759
1810
|
})(InteractionProvider || (InteractionProvider = {}));
|
|
1760
1811
|
var InteractionRouteLogic;
|
|
1761
1812
|
(function (InteractionRouteLogic) {
|
|
@@ -2589,6 +2640,214 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
2589
2640
|
}]
|
|
2590
2641
|
}], ctorParameters: () => [{ type: AppSyncHelperService }] });
|
|
2591
2642
|
|
|
2643
|
+
const FIELDS_USER = `
|
|
2644
|
+
id
|
|
2645
|
+
externalId
|
|
2646
|
+
tenantId
|
|
2647
|
+
email
|
|
2648
|
+
name
|
|
2649
|
+
image {
|
|
2650
|
+
key
|
|
2651
|
+
bucket
|
|
2652
|
+
location
|
|
2653
|
+
}
|
|
2654
|
+
phoneNumber {
|
|
2655
|
+
countryCode
|
|
2656
|
+
dialCode
|
|
2657
|
+
e164Number
|
|
2658
|
+
internationalNumber
|
|
2659
|
+
nationalNumber
|
|
2660
|
+
number
|
|
2661
|
+
}
|
|
2662
|
+
preferences {
|
|
2663
|
+
timezoneName
|
|
2664
|
+
language {
|
|
2665
|
+
code
|
|
2666
|
+
nameEn
|
|
2667
|
+
nameLocal
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
notificationSettings {
|
|
2671
|
+
allowPush
|
|
2672
|
+
allowEmail
|
|
2673
|
+
allowSMS
|
|
2674
|
+
allowWhatsApp
|
|
2675
|
+
}
|
|
2676
|
+
type
|
|
2677
|
+
activatedAt
|
|
2678
|
+
blockedAt
|
|
2679
|
+
createdAt
|
|
2680
|
+
updatedAt
|
|
2681
|
+
deletedAt
|
|
2682
|
+
`;
|
|
2683
|
+
var UserStatus;
|
|
2684
|
+
(function (UserStatus) {
|
|
2685
|
+
UserStatus["READY"] = "READY";
|
|
2686
|
+
UserStatus["NOT_READY"] = "NOT_READY";
|
|
2687
|
+
UserStatus["INVITED"] = "INVITED";
|
|
2688
|
+
UserStatus["BUSY"] = "BUSY";
|
|
2689
|
+
UserStatus["AFTER_CALL_WORK"] = "AFTER_CALL_WORK";
|
|
2690
|
+
})(UserStatus || (UserStatus = {}));
|
|
2691
|
+
var UserType;
|
|
2692
|
+
(function (UserType) {
|
|
2693
|
+
UserType["AGENT"] = "AGENT";
|
|
2694
|
+
UserType["SUPERVISOR"] = "SUPERVISOR";
|
|
2695
|
+
UserType["ADMINISTRATOR"] = "ADMINISTRATOR";
|
|
2696
|
+
})(UserType || (UserType = {}));
|
|
2697
|
+
class UserService {
|
|
2698
|
+
appSyncService;
|
|
2699
|
+
constructor(appSyncService) {
|
|
2700
|
+
this.appSyncService = appSyncService;
|
|
2701
|
+
}
|
|
2702
|
+
async getUserById(id) {
|
|
2703
|
+
if (!id || !uuid.validate(id)) {
|
|
2704
|
+
throw { code: 400, message: `Invalid id: ${id}` };
|
|
2705
|
+
}
|
|
2706
|
+
const user = await this.GetUser(id);
|
|
2707
|
+
if (!user || !!user.deletedAt) {
|
|
2708
|
+
throw { code: 400, message: `User not found` };
|
|
2709
|
+
}
|
|
2710
|
+
if (!user.activatedAt) {
|
|
2711
|
+
throw { code: 403, message: `User not activated.` };
|
|
2712
|
+
}
|
|
2713
|
+
if (!!user.blockedAt) {
|
|
2714
|
+
throw { code: 403, message: `User has been blocked.` };
|
|
2715
|
+
}
|
|
2716
|
+
return user;
|
|
2717
|
+
}
|
|
2718
|
+
async GetUser(id) {
|
|
2719
|
+
const statement = `query GetUser($id: ID!) {
|
|
2720
|
+
getUser(id: $id) {
|
|
2721
|
+
${FIELDS_USER}
|
|
2722
|
+
}
|
|
2723
|
+
}`;
|
|
2724
|
+
const gqlAPIServiceArguments = { id };
|
|
2725
|
+
const response = await this.appSyncService.query(statement, gqlAPIServiceArguments);
|
|
2726
|
+
return response.data.getUser;
|
|
2727
|
+
}
|
|
2728
|
+
OnUserByIdListener(id) {
|
|
2729
|
+
const statement = `subscription OnUserById($id: ID!) {
|
|
2730
|
+
OnUserById(id: $id) {
|
|
2731
|
+
${FIELDS_USER}
|
|
2732
|
+
}
|
|
2733
|
+
}`;
|
|
2734
|
+
const gqlAPIServiceArguments = { id };
|
|
2735
|
+
return this.appSyncService.subscribe(statement, gqlAPIServiceArguments);
|
|
2736
|
+
/* as Observable<SubscriptionResponse<Pick<__SubscriptionContainer, "OnUserById">>>; */
|
|
2737
|
+
}
|
|
2738
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: UserService, deps: [{ token: AppSyncHelperService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2739
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: UserService, providedIn: 'root' });
|
|
2740
|
+
}
|
|
2741
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: UserService, decorators: [{
|
|
2742
|
+
type: Injectable,
|
|
2743
|
+
args: [{
|
|
2744
|
+
providedIn: 'root',
|
|
2745
|
+
}]
|
|
2746
|
+
}], ctorParameters: () => [{ type: AppSyncHelperService }] });
|
|
2747
|
+
|
|
2748
|
+
const FIELDS_TEAM = `
|
|
2749
|
+
id
|
|
2750
|
+
tenantId
|
|
2751
|
+
name
|
|
2752
|
+
description
|
|
2753
|
+
image {
|
|
2754
|
+
key
|
|
2755
|
+
bucket
|
|
2756
|
+
location
|
|
2757
|
+
}
|
|
2758
|
+
ticketFields
|
|
2759
|
+
createdAt
|
|
2760
|
+
updatedAt
|
|
2761
|
+
deletedAt
|
|
2762
|
+
`;
|
|
2763
|
+
const FIELDS_TEAM_MEMBER = `
|
|
2764
|
+
id
|
|
2765
|
+
teamId
|
|
2766
|
+
team {
|
|
2767
|
+
${FIELDS_TEAM}
|
|
2768
|
+
}
|
|
2769
|
+
userId
|
|
2770
|
+
user {
|
|
2771
|
+
${FIELDS_USER}
|
|
2772
|
+
}
|
|
2773
|
+
isManager
|
|
2774
|
+
createdAt
|
|
2775
|
+
updatedAt
|
|
2776
|
+
deletedAt
|
|
2777
|
+
`;
|
|
2778
|
+
class TeamService {
|
|
2779
|
+
appSyncService;
|
|
2780
|
+
constructor(appSyncService) {
|
|
2781
|
+
this.appSyncService = appSyncService;
|
|
2782
|
+
}
|
|
2783
|
+
async GetTeam(id) {
|
|
2784
|
+
const statement = `query GetTeam($id: ID!) {
|
|
2785
|
+
getTeam(id: $id) {
|
|
2786
|
+
${FIELDS_TEAM}
|
|
2787
|
+
}
|
|
2788
|
+
}`;
|
|
2789
|
+
const gqlAPIServiceArguments = {
|
|
2790
|
+
id,
|
|
2791
|
+
};
|
|
2792
|
+
const response = await this.appSyncService.query(statement, gqlAPIServiceArguments);
|
|
2793
|
+
return response.data.getTeam;
|
|
2794
|
+
}
|
|
2795
|
+
async ListTeamMembershipsByUserId(userId, createdAt, sortDirection, filter, limit, nextToken) {
|
|
2796
|
+
const statement = `query ListTeamMembershipsByUserId($userId: ID!, $createdAt: ModelIntKeyConditionInput, $sortDirection: ModelSortDirection, $filter: ModelTeamMemberFilterInput, $limit: Int, $nextToken: String) {
|
|
2797
|
+
listTeamMembershipsByUserId(
|
|
2798
|
+
userId: $userId
|
|
2799
|
+
createdAt: $createdAt
|
|
2800
|
+
sortDirection: $sortDirection
|
|
2801
|
+
filter: $filter
|
|
2802
|
+
limit: $limit
|
|
2803
|
+
nextToken: $nextToken
|
|
2804
|
+
) {
|
|
2805
|
+
items {
|
|
2806
|
+
id
|
|
2807
|
+
teamId
|
|
2808
|
+
team {
|
|
2809
|
+
${FIELDS_TEAM}
|
|
2810
|
+
}
|
|
2811
|
+
userId
|
|
2812
|
+
isManager
|
|
2813
|
+
createdAt
|
|
2814
|
+
updatedAt
|
|
2815
|
+
deletedAt
|
|
2816
|
+
}
|
|
2817
|
+
nextToken
|
|
2818
|
+
}
|
|
2819
|
+
}`;
|
|
2820
|
+
const gqlAPIServiceArguments = {
|
|
2821
|
+
userId,
|
|
2822
|
+
};
|
|
2823
|
+
if (createdAt) {
|
|
2824
|
+
gqlAPIServiceArguments.createdAt = createdAt;
|
|
2825
|
+
}
|
|
2826
|
+
if (sortDirection) {
|
|
2827
|
+
gqlAPIServiceArguments.sortDirection = sortDirection;
|
|
2828
|
+
}
|
|
2829
|
+
if (filter) {
|
|
2830
|
+
gqlAPIServiceArguments.filter = filter;
|
|
2831
|
+
}
|
|
2832
|
+
if (limit) {
|
|
2833
|
+
gqlAPIServiceArguments.limit = limit;
|
|
2834
|
+
}
|
|
2835
|
+
if (nextToken) {
|
|
2836
|
+
gqlAPIServiceArguments.nextToken = nextToken;
|
|
2837
|
+
}
|
|
2838
|
+
const response = await this.appSyncService.query(statement, gqlAPIServiceArguments);
|
|
2839
|
+
return response.data.listTeamMembershipsByUserId;
|
|
2840
|
+
}
|
|
2841
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: TeamService, deps: [{ token: AppSyncHelperService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2842
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: TeamService, providedIn: 'root' });
|
|
2843
|
+
}
|
|
2844
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: TeamService, decorators: [{
|
|
2845
|
+
type: Injectable,
|
|
2846
|
+
args: [{
|
|
2847
|
+
providedIn: 'root',
|
|
2848
|
+
}]
|
|
2849
|
+
}], ctorParameters: () => [{ type: AppSyncHelperService }] });
|
|
2850
|
+
|
|
2592
2851
|
const FIELDS_TENANT_EXPANDED = `
|
|
2593
2852
|
id
|
|
2594
2853
|
externalId
|
|
@@ -2771,111 +3030,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
2771
3030
|
}]
|
|
2772
3031
|
}], ctorParameters: () => [{ type: AppSyncHelperService }] });
|
|
2773
3032
|
|
|
2774
|
-
const FIELDS_USER_EXPANDED = `
|
|
2775
|
-
id
|
|
2776
|
-
externalId
|
|
2777
|
-
tenantId
|
|
2778
|
-
email
|
|
2779
|
-
name
|
|
2780
|
-
image {
|
|
2781
|
-
key
|
|
2782
|
-
bucket
|
|
2783
|
-
location
|
|
2784
|
-
}
|
|
2785
|
-
phoneNumber {
|
|
2786
|
-
countryCode
|
|
2787
|
-
dialCode
|
|
2788
|
-
e164Number
|
|
2789
|
-
internationalNumber
|
|
2790
|
-
nationalNumber
|
|
2791
|
-
number
|
|
2792
|
-
}
|
|
2793
|
-
preferences {
|
|
2794
|
-
timezoneName
|
|
2795
|
-
language {
|
|
2796
|
-
code
|
|
2797
|
-
nameEn
|
|
2798
|
-
nameLocal
|
|
2799
|
-
}
|
|
2800
|
-
}
|
|
2801
|
-
notificationSettings {
|
|
2802
|
-
allowPush
|
|
2803
|
-
allowEmail
|
|
2804
|
-
allowSMS
|
|
2805
|
-
allowWhatsApp
|
|
2806
|
-
}
|
|
2807
|
-
type
|
|
2808
|
-
activatedAt
|
|
2809
|
-
blockedAt
|
|
2810
|
-
createdAt
|
|
2811
|
-
updatedAt
|
|
2812
|
-
deletedAt
|
|
2813
|
-
`;
|
|
2814
|
-
var UserStatus;
|
|
2815
|
-
(function (UserStatus) {
|
|
2816
|
-
UserStatus["READY"] = "READY";
|
|
2817
|
-
UserStatus["NOT_READY"] = "NOT_READY";
|
|
2818
|
-
UserStatus["INVITED"] = "INVITED";
|
|
2819
|
-
UserStatus["BUSY"] = "BUSY";
|
|
2820
|
-
UserStatus["AFTER_CALL_WORK"] = "AFTER_CALL_WORK";
|
|
2821
|
-
})(UserStatus || (UserStatus = {}));
|
|
2822
|
-
var UserType;
|
|
2823
|
-
(function (UserType) {
|
|
2824
|
-
UserType["AGENT"] = "AGENT";
|
|
2825
|
-
UserType["SUPERVISOR"] = "SUPERVISOR";
|
|
2826
|
-
UserType["ADMINISTRATOR"] = "ADMINISTRATOR";
|
|
2827
|
-
})(UserType || (UserType = {}));
|
|
2828
|
-
class UserService {
|
|
2829
|
-
appSyncService;
|
|
2830
|
-
constructor(appSyncService) {
|
|
2831
|
-
this.appSyncService = appSyncService;
|
|
2832
|
-
}
|
|
2833
|
-
async getUserById(id) {
|
|
2834
|
-
if (!id || !uuid.validate(id)) {
|
|
2835
|
-
throw { code: 400, message: `Invalid id: ${id}` };
|
|
2836
|
-
}
|
|
2837
|
-
const user = await this.GetUser(id);
|
|
2838
|
-
if (!user || !!user.deletedAt) {
|
|
2839
|
-
throw { code: 400, message: `User not found` };
|
|
2840
|
-
}
|
|
2841
|
-
if (!user.activatedAt) {
|
|
2842
|
-
throw { code: 403, message: `User not activated.` };
|
|
2843
|
-
}
|
|
2844
|
-
if (!!user.blockedAt) {
|
|
2845
|
-
throw { code: 403, message: `User has been blocked.` };
|
|
2846
|
-
}
|
|
2847
|
-
return user;
|
|
2848
|
-
}
|
|
2849
|
-
async GetUser(id) {
|
|
2850
|
-
const statement = `query GetUser($id: ID!) {
|
|
2851
|
-
getUser(id: $id) {
|
|
2852
|
-
${FIELDS_USER_EXPANDED}
|
|
2853
|
-
}
|
|
2854
|
-
}`;
|
|
2855
|
-
const gqlAPIServiceArguments = { id };
|
|
2856
|
-
const response = await this.appSyncService.query(statement, gqlAPIServiceArguments);
|
|
2857
|
-
return response.data.getUser;
|
|
2858
|
-
}
|
|
2859
|
-
OnUserByIdListener(id) {
|
|
2860
|
-
const statement = `subscription OnUserById($id: ID!) {
|
|
2861
|
-
OnUserById(id: $id) {
|
|
2862
|
-
${FIELDS_USER_EXPANDED}
|
|
2863
|
-
}
|
|
2864
|
-
}`;
|
|
2865
|
-
const gqlAPIServiceArguments = { id };
|
|
2866
|
-
return this.appSyncService.subscribe(statement, gqlAPIServiceArguments);
|
|
2867
|
-
/* as Observable<SubscriptionResponse<Pick<__SubscriptionContainer, "OnUserById">>>; */
|
|
2868
|
-
}
|
|
2869
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: UserService, deps: [{ token: AppSyncHelperService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2870
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: UserService, providedIn: 'root' });
|
|
2871
|
-
}
|
|
2872
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: UserService, decorators: [{
|
|
2873
|
-
type: Injectable,
|
|
2874
|
-
args: [{
|
|
2875
|
-
providedIn: 'root',
|
|
2876
|
-
}]
|
|
2877
|
-
}], ctorParameters: () => [{ type: AppSyncHelperService }] });
|
|
2878
|
-
|
|
2879
3033
|
class CustomValidators {
|
|
2880
3034
|
/**
|
|
2881
3035
|
* Validator that checks for whitespace-only input.
|
|
@@ -2979,5 +3133,5 @@ class CleanDeep {
|
|
|
2979
3133
|
* Generated bundle index. Do not edit.
|
|
2980
3134
|
*/
|
|
2981
3135
|
|
|
2982
|
-
export { AMPLIFY_CONFIG, AppSyncHelperService, CleanDeep, CustomPipesModule, CustomValidators, DomainNamePipe, EntityConversationService, EntityService, ErrorComponent, FIELDS_ENTITY_CONVERSATION, FIELDS_ENTITY_CONVERSATION_EXPANDED, FIELDS_INTERACTION_WIDGET, FooterComponent, FormatEpochTimestampPipe, InteractionChannel, InteractionContext, InteractionDirection, InteractionEndpointService, InteractionProvider, InteractionRouteLogic, InteractionService, InteractionStatus, InteractionWidgetService, LoaderComponent,
|
|
3136
|
+
export { AMPLIFY_CONFIG, AppSyncHelperService, CleanDeep, CustomPipesModule, CustomValidators, DomainNamePipe, EntityConversationService, EntityService, ErrorComponent, FIELDS_ENTITY_CONVERSATION, FIELDS_ENTITY_CONVERSATION_EXPANDED, FIELDS_INTERACTION_WIDGET, FIELDS_USER, FooterComponent, FormatEpochTimestampPipe, InteractionChannel, InteractionContext, InteractionDirection, InteractionEndpointService, InteractionProvider, InteractionRouteLogic, InteractionService, InteractionStatus, InteractionWidgetService, LoaderComponent, OpenSearchHelperService, S3HelperService, SafeHtmlPipe, SearchInnerFieldPipe, SearchPipe, SingularizePipe, SnugdeskAuthenticationService, SnugdeskCoreModule, SnugdeskIPRegistryService, TeamService, TenantService, UserService, UserSessionService, UserStatus, UserType, provideAmplifyConfig };
|
|
2983
3137
|
//# sourceMappingURL=snugdesk-core.mjs.map
|