@snugdesk/core 0.2.24 → 0.2.26
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.mjs +236 -30
- package/fesm2022/snugdesk-core.mjs.map +1 -1
- package/index.d.ts +101 -12
- package/package.json +1 -1
|
@@ -1874,6 +1874,79 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
|
|
|
1874
1874
|
}]
|
|
1875
1875
|
}], ctorParameters: () => [{ type: AppSyncHelperService }] });
|
|
1876
1876
|
|
|
1877
|
+
const FIELDS_LANGUAGE = `
|
|
1878
|
+
code
|
|
1879
|
+
nameEn
|
|
1880
|
+
nameLocal
|
|
1881
|
+
`;
|
|
1882
|
+
const FIELDS_COUNTRY = `
|
|
1883
|
+
code
|
|
1884
|
+
nameEn
|
|
1885
|
+
nameLocal
|
|
1886
|
+
currency {
|
|
1887
|
+
code
|
|
1888
|
+
nameEn
|
|
1889
|
+
}
|
|
1890
|
+
officialLanguage {
|
|
1891
|
+
${FIELDS_LANGUAGE}
|
|
1892
|
+
}
|
|
1893
|
+
callingCode
|
|
1894
|
+
region
|
|
1895
|
+
flag
|
|
1896
|
+
`;
|
|
1897
|
+
const FIELDS_PHONE_NUMBER = `
|
|
1898
|
+
countryCode
|
|
1899
|
+
dialCode
|
|
1900
|
+
e164Number
|
|
1901
|
+
internationalNumber
|
|
1902
|
+
nationalNumber
|
|
1903
|
+
number
|
|
1904
|
+
`;
|
|
1905
|
+
class CommonService {
|
|
1906
|
+
httpClient;
|
|
1907
|
+
countriesData;
|
|
1908
|
+
languagesData;
|
|
1909
|
+
// private static readonly COUNTRY_ENDPOINT = `https://assets.snugdesk.com/metadata/countries.json`;
|
|
1910
|
+
static COUNTRY_ENDPOINT = `https://snugdesk-assets.s3.amazonaws.com/metadata/countries.json`;
|
|
1911
|
+
// private static readonly LANGUAGE_ENDPOINT = `https://assets.snugdesk.com/metadata/languages.json`;
|
|
1912
|
+
static LANGUAGE_ENDPOINT = `https://snugdesk-assets.s3.amazonaws.com/metadata/languages.json`;
|
|
1913
|
+
constructor(httpClient) {
|
|
1914
|
+
this.httpClient = httpClient;
|
|
1915
|
+
}
|
|
1916
|
+
async getAllCountries() {
|
|
1917
|
+
if (!this.countriesData) {
|
|
1918
|
+
this.countriesData = await lastValueFrom(this.httpClient.get(CommonService.COUNTRY_ENDPOINT));
|
|
1919
|
+
}
|
|
1920
|
+
return this.countriesData;
|
|
1921
|
+
}
|
|
1922
|
+
async getCountryFromCallingCode(countryCallingCode) {
|
|
1923
|
+
const countries = await this.getAllCountries();
|
|
1924
|
+
return countries.find((country) => country.callingCode === countryCallingCode);
|
|
1925
|
+
}
|
|
1926
|
+
async getCountryFromCountryCode(countryCode) {
|
|
1927
|
+
const countries = await this.getAllCountries();
|
|
1928
|
+
return countries.find((country) => country.code === countryCode);
|
|
1929
|
+
}
|
|
1930
|
+
async getAllLanguages() {
|
|
1931
|
+
if (!this.languagesData) {
|
|
1932
|
+
this.languagesData = await lastValueFrom(this.httpClient.get(CommonService.LANGUAGE_ENDPOINT));
|
|
1933
|
+
}
|
|
1934
|
+
return this.languagesData;
|
|
1935
|
+
}
|
|
1936
|
+
async getLanguageFromLanguageCode(languageCode) {
|
|
1937
|
+
const languages = await this.getAllLanguages();
|
|
1938
|
+
return languages?.find((language) => language.code === languageCode);
|
|
1939
|
+
}
|
|
1940
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: CommonService, deps: [{ token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1941
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: CommonService, providedIn: 'root' });
|
|
1942
|
+
}
|
|
1943
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: CommonService, decorators: [{
|
|
1944
|
+
type: Injectable,
|
|
1945
|
+
args: [{
|
|
1946
|
+
providedIn: 'root',
|
|
1947
|
+
}]
|
|
1948
|
+
}], ctorParameters: () => [{ type: i1$2.HttpClient }] });
|
|
1949
|
+
|
|
1877
1950
|
const FIELDS_USER = `
|
|
1878
1951
|
id
|
|
1879
1952
|
externalId
|
|
@@ -1881,24 +1954,15 @@ const FIELDS_USER = `
|
|
|
1881
1954
|
email
|
|
1882
1955
|
name
|
|
1883
1956
|
image {
|
|
1884
|
-
key
|
|
1885
|
-
bucket
|
|
1886
1957
|
location
|
|
1887
1958
|
}
|
|
1888
1959
|
phoneNumber {
|
|
1889
|
-
|
|
1890
|
-
dialCode
|
|
1891
|
-
e164Number
|
|
1892
|
-
internationalNumber
|
|
1893
|
-
nationalNumber
|
|
1894
|
-
number
|
|
1960
|
+
${FIELDS_PHONE_NUMBER}
|
|
1895
1961
|
}
|
|
1896
1962
|
preferences {
|
|
1897
1963
|
timezoneName
|
|
1898
1964
|
language {
|
|
1899
|
-
|
|
1900
|
-
nameEn
|
|
1901
|
-
nameLocal
|
|
1965
|
+
${FIELDS_LANGUAGE}
|
|
1902
1966
|
}
|
|
1903
1967
|
}
|
|
1904
1968
|
notificationSettings {
|
|
@@ -1913,6 +1977,8 @@ const FIELDS_USER = `
|
|
|
1913
1977
|
createdAt
|
|
1914
1978
|
updatedAt
|
|
1915
1979
|
deletedAt
|
|
1980
|
+
updatedByUserId
|
|
1981
|
+
updatedByUserSessionId
|
|
1916
1982
|
`;
|
|
1917
1983
|
class UserService {
|
|
1918
1984
|
appSyncService;
|
|
@@ -1929,6 +1995,136 @@ class UserService {
|
|
|
1929
1995
|
const response = await this.appSyncService.query(statement, gqlAPIServiceArguments);
|
|
1930
1996
|
return response.data.getUser;
|
|
1931
1997
|
}
|
|
1998
|
+
async CreateUser(input, condition) {
|
|
1999
|
+
const statement = `mutation CreateUser($input: CreateUserInput!, $condition: ModelUserConditionInput) {
|
|
2000
|
+
createUser(input: $input, condition: $condition) {
|
|
2001
|
+
${FIELDS_USER}
|
|
2002
|
+
}
|
|
2003
|
+
}`;
|
|
2004
|
+
const gqlAPIServiceArguments = { input };
|
|
2005
|
+
if (condition) {
|
|
2006
|
+
gqlAPIServiceArguments.condition = condition;
|
|
2007
|
+
}
|
|
2008
|
+
const response = await this.appSyncService.query(statement, gqlAPIServiceArguments);
|
|
2009
|
+
return response.data.createUser;
|
|
2010
|
+
}
|
|
2011
|
+
async UpdateUser(input, condition) {
|
|
2012
|
+
const statement = `mutation UpdateUser($input: UpdateUserInput!, $condition: ModelUserConditionInput) {
|
|
2013
|
+
updateUser(input: $input, condition: $condition) {
|
|
2014
|
+
${FIELDS_USER}
|
|
2015
|
+
}
|
|
2016
|
+
}`;
|
|
2017
|
+
const gqlAPIServiceArguments = { input };
|
|
2018
|
+
if (condition) {
|
|
2019
|
+
gqlAPIServiceArguments.condition = condition;
|
|
2020
|
+
}
|
|
2021
|
+
const response = await this.appSyncService.query(statement, gqlAPIServiceArguments);
|
|
2022
|
+
return response.data.updateUser;
|
|
2023
|
+
}
|
|
2024
|
+
async ListUsersByTenantIdAndEmail(tenantId, email, sortDirection, filter, limit, nextToken) {
|
|
2025
|
+
const statement = `query ListUsersByTenantIdAndEmail($tenantId: ID!, $email: ModelStringKeyConditionInput, $sortDirection: ModelSortDirection, $filter: ModelUserFilterInput, $limit: Int, $nextToken: String) {
|
|
2026
|
+
listUsersByTenantIdAndEmail(
|
|
2027
|
+
tenantId: $tenantId
|
|
2028
|
+
email: $email
|
|
2029
|
+
sortDirection: $sortDirection
|
|
2030
|
+
filter: $filter
|
|
2031
|
+
limit: $limit
|
|
2032
|
+
nextToken: $nextToken
|
|
2033
|
+
) {
|
|
2034
|
+
items {
|
|
2035
|
+
${FIELDS_USER}
|
|
2036
|
+
}
|
|
2037
|
+
nextToken
|
|
2038
|
+
}
|
|
2039
|
+
}`;
|
|
2040
|
+
const gqlAPIServiceArguments = {
|
|
2041
|
+
tenantId,
|
|
2042
|
+
};
|
|
2043
|
+
if (email) {
|
|
2044
|
+
gqlAPIServiceArguments.email = email;
|
|
2045
|
+
}
|
|
2046
|
+
if (sortDirection) {
|
|
2047
|
+
gqlAPIServiceArguments.sortDirection = sortDirection;
|
|
2048
|
+
}
|
|
2049
|
+
if (filter) {
|
|
2050
|
+
gqlAPIServiceArguments.filter = filter;
|
|
2051
|
+
}
|
|
2052
|
+
if (limit) {
|
|
2053
|
+
gqlAPIServiceArguments.limit = limit;
|
|
2054
|
+
}
|
|
2055
|
+
if (nextToken) {
|
|
2056
|
+
gqlAPIServiceArguments.nextToken = nextToken;
|
|
2057
|
+
}
|
|
2058
|
+
const response = await this.appSyncService.query(statement, gqlAPIServiceArguments);
|
|
2059
|
+
return response.data.listUsersByTenantIdAndEmail;
|
|
2060
|
+
}
|
|
2061
|
+
async ListUsersByTenantIdAndExternalId(tenantId, externalId, sortDirection, filter, limit, nextToken) {
|
|
2062
|
+
const statement = `query ListUsersByTenantIdAndExternalId($tenantId: ID!, $externalId: ModelStringKeyConditionInput, $sortDirection: ModelSortDirection, $filter: ModelUserFilterInput, $limit: Int, $nextToken: String) {
|
|
2063
|
+
listUsersByTenantIdAndExternalId(
|
|
2064
|
+
tenantId: $tenantId
|
|
2065
|
+
externalId: $externalId
|
|
2066
|
+
sortDirection: $sortDirection
|
|
2067
|
+
filter: $filter
|
|
2068
|
+
limit: $limit
|
|
2069
|
+
nextToken: $nextToken
|
|
2070
|
+
) {
|
|
2071
|
+
items {
|
|
2072
|
+
${FIELDS_USER}
|
|
2073
|
+
}
|
|
2074
|
+
nextToken
|
|
2075
|
+
}
|
|
2076
|
+
}`;
|
|
2077
|
+
const gqlAPIServiceArguments = {
|
|
2078
|
+
tenantId,
|
|
2079
|
+
};
|
|
2080
|
+
if (externalId) {
|
|
2081
|
+
gqlAPIServiceArguments.externalId = externalId;
|
|
2082
|
+
}
|
|
2083
|
+
if (sortDirection) {
|
|
2084
|
+
gqlAPIServiceArguments.sortDirection = sortDirection;
|
|
2085
|
+
}
|
|
2086
|
+
if (filter) {
|
|
2087
|
+
gqlAPIServiceArguments.filter = filter;
|
|
2088
|
+
}
|
|
2089
|
+
if (limit) {
|
|
2090
|
+
gqlAPIServiceArguments.limit = limit;
|
|
2091
|
+
}
|
|
2092
|
+
if (nextToken) {
|
|
2093
|
+
gqlAPIServiceArguments.nextToken = nextToken;
|
|
2094
|
+
}
|
|
2095
|
+
const response = await this.appSyncService.query(statement, gqlAPIServiceArguments);
|
|
2096
|
+
return response.data.listUsersByTenantIdAndExternalId;
|
|
2097
|
+
}
|
|
2098
|
+
async ListUsersByTenantIdAndName(tenantId, name, sortDirection, filter, limit, nextToken) {
|
|
2099
|
+
const statement = `query ListUsersByTenantIdAndName($tenantId: ID!, $name: ModelStringKeyConditionInput, $sortDirection: ModelSortDirection, $filter: ModelUserFilterInput, $limit: Int, $nextToken: String) {
|
|
2100
|
+
listUsersByTenantIdAndName(tenantId: $tenantId, name: $name, sortDirection: $sortDirection, filter: $filter, limit: $limit, nextToken: $nextToken) {
|
|
2101
|
+
items {
|
|
2102
|
+
${FIELDS_USER}
|
|
2103
|
+
}
|
|
2104
|
+
nextToken
|
|
2105
|
+
}
|
|
2106
|
+
}`;
|
|
2107
|
+
const gqlAPIServiceArguments = {
|
|
2108
|
+
tenantId,
|
|
2109
|
+
};
|
|
2110
|
+
if (name) {
|
|
2111
|
+
gqlAPIServiceArguments.name = name;
|
|
2112
|
+
}
|
|
2113
|
+
if (sortDirection) {
|
|
2114
|
+
gqlAPIServiceArguments.sortDirection = sortDirection;
|
|
2115
|
+
}
|
|
2116
|
+
if (filter) {
|
|
2117
|
+
gqlAPIServiceArguments.filter = filter;
|
|
2118
|
+
}
|
|
2119
|
+
if (limit) {
|
|
2120
|
+
gqlAPIServiceArguments.limit = limit;
|
|
2121
|
+
}
|
|
2122
|
+
if (nextToken) {
|
|
2123
|
+
gqlAPIServiceArguments.nextToken = nextToken;
|
|
2124
|
+
}
|
|
2125
|
+
const response = await this.appSyncService.query(statement, gqlAPIServiceArguments);
|
|
2126
|
+
return response.data.listUsersByTenantIdAndName;
|
|
2127
|
+
}
|
|
1932
2128
|
OnUserByIdListener(id) {
|
|
1933
2129
|
const statement = `subscription OnUserById($id: ID!) {
|
|
1934
2130
|
OnUserById(id: $id) {
|
|
@@ -1955,8 +2151,6 @@ const FIELDS_TEAM = `
|
|
|
1955
2151
|
name
|
|
1956
2152
|
description
|
|
1957
2153
|
image {
|
|
1958
|
-
key
|
|
1959
|
-
bucket
|
|
1960
2154
|
location
|
|
1961
2155
|
}
|
|
1962
2156
|
ticketFields
|
|
@@ -1996,6 +2190,21 @@ class TeamService {
|
|
|
1996
2190
|
const response = await this.appSyncService.query(statement, gqlAPIServiceArguments);
|
|
1997
2191
|
return response.data.getTeam;
|
|
1998
2192
|
}
|
|
2193
|
+
async CreateTeamMember(input, condition) {
|
|
2194
|
+
const statement = `mutation CreateTeamMember($input: CreateTeamMemberInput!, $condition: ModelTeamMemberConditionInput) {
|
|
2195
|
+
createTeamMember(input: $input, condition: $condition) {
|
|
2196
|
+
${FIELDS_TEAM_MEMBER}
|
|
2197
|
+
}
|
|
2198
|
+
}`;
|
|
2199
|
+
const gqlAPIServiceArguments = {
|
|
2200
|
+
input,
|
|
2201
|
+
};
|
|
2202
|
+
if (condition) {
|
|
2203
|
+
gqlAPIServiceArguments.condition = condition;
|
|
2204
|
+
}
|
|
2205
|
+
const response = await this.appSyncService.query(statement, gqlAPIServiceArguments);
|
|
2206
|
+
return response.data.createTeamMember;
|
|
2207
|
+
}
|
|
1999
2208
|
async ListTeamMembershipsByUserId(userId, createdAt, sortDirection, filter, limit, nextToken) {
|
|
2000
2209
|
const statement = `query ListTeamMembershipsByUserId($userId: ID!, $createdAt: ModelIntKeyConditionInput, $sortDirection: ModelSortDirection, $filter: ModelTeamMemberFilterInput, $limit: Int, $nextToken: String) {
|
|
2001
2210
|
listTeamMembershipsByUserId(
|
|
@@ -3147,16 +3356,12 @@ const FIELDS_TENANT = `
|
|
|
3147
3356
|
organizationName
|
|
3148
3357
|
websiteURL
|
|
3149
3358
|
image {
|
|
3150
|
-
key
|
|
3151
|
-
bucket
|
|
3152
3359
|
location
|
|
3153
3360
|
}
|
|
3154
3361
|
preferences {
|
|
3155
3362
|
timezoneName
|
|
3156
3363
|
language {
|
|
3157
|
-
|
|
3158
|
-
nameEn
|
|
3159
|
-
nameLocal
|
|
3364
|
+
${FIELDS_LANGUAGE}
|
|
3160
3365
|
}
|
|
3161
3366
|
allowUserToChangePreferences
|
|
3162
3367
|
}
|
|
@@ -3187,9 +3392,7 @@ const FIELDS_TENANT_MINIMAL = `
|
|
|
3187
3392
|
preferences {
|
|
3188
3393
|
timezoneName
|
|
3189
3394
|
language {
|
|
3190
|
-
|
|
3191
|
-
nameEn
|
|
3192
|
-
nameLocal
|
|
3395
|
+
${FIELDS_LANGUAGE}
|
|
3193
3396
|
}
|
|
3194
3397
|
allowUserToChangePreferences
|
|
3195
3398
|
}
|
|
@@ -3208,8 +3411,6 @@ const FIELDS_TENANT_EXPANDED = `
|
|
|
3208
3411
|
organizationName
|
|
3209
3412
|
websiteURL
|
|
3210
3413
|
image {
|
|
3211
|
-
key
|
|
3212
|
-
bucket
|
|
3213
3414
|
location
|
|
3214
3415
|
}
|
|
3215
3416
|
billingInformation {
|
|
@@ -3218,23 +3419,30 @@ const FIELDS_TENANT_EXPANDED = `
|
|
|
3218
3419
|
state
|
|
3219
3420
|
city
|
|
3220
3421
|
postalCode
|
|
3422
|
+
country {
|
|
3423
|
+
${FIELDS_COUNTRY}
|
|
3424
|
+
}
|
|
3221
3425
|
companyIdentificationNumber
|
|
3222
3426
|
taxIdentificationNumber
|
|
3223
3427
|
}
|
|
3224
3428
|
contactInformation {
|
|
3225
3429
|
name
|
|
3226
3430
|
email
|
|
3431
|
+
phoneNumber {
|
|
3432
|
+
${FIELDS_PHONE_NUMBER}
|
|
3433
|
+
}
|
|
3227
3434
|
address
|
|
3228
3435
|
state
|
|
3229
3436
|
city
|
|
3230
3437
|
postalCode
|
|
3438
|
+
country {
|
|
3439
|
+
${FIELDS_COUNTRY}
|
|
3440
|
+
}
|
|
3231
3441
|
}
|
|
3232
3442
|
preferences {
|
|
3233
3443
|
timezoneName
|
|
3234
3444
|
language {
|
|
3235
|
-
|
|
3236
|
-
nameEn
|
|
3237
|
-
nameLocal
|
|
3445
|
+
${FIELDS_LANGUAGE}
|
|
3238
3446
|
}
|
|
3239
3447
|
allowUserToChangePreferences
|
|
3240
3448
|
}
|
|
@@ -3274,8 +3482,6 @@ const FIELDS_TENANT_COMPLIANCE_DOCUMENT = `
|
|
|
3274
3482
|
status
|
|
3275
3483
|
notes
|
|
3276
3484
|
file {
|
|
3277
|
-
key
|
|
3278
|
-
bucket
|
|
3279
3485
|
location
|
|
3280
3486
|
}
|
|
3281
3487
|
createdAt
|
|
@@ -3297,7 +3503,7 @@ class TenantService {
|
|
|
3297
3503
|
}`;
|
|
3298
3504
|
const gqlAPIServiceArguments = { id };
|
|
3299
3505
|
const response = await this.appSyncService.query(statement, gqlAPIServiceArguments);
|
|
3300
|
-
return response.data
|
|
3506
|
+
return response.data.getTenant;
|
|
3301
3507
|
}
|
|
3302
3508
|
async GetTenantExpanded(id) {
|
|
3303
3509
|
const statement = `query GetTenant($id: ID!) {
|
|
@@ -3307,7 +3513,7 @@ class TenantService {
|
|
|
3307
3513
|
}`;
|
|
3308
3514
|
const gqlAPIServiceArguments = { id };
|
|
3309
3515
|
const response = await this.appSyncService.query(statement, gqlAPIServiceArguments);
|
|
3310
|
-
return response.data
|
|
3516
|
+
return response.data.getTenant;
|
|
3311
3517
|
}
|
|
3312
3518
|
async CreateTenant(input, condition) {
|
|
3313
3519
|
const statement = `mutation CreateTenant($input: CreateTenantInput!, $condition: ModelTenantConditionInput) {
|