@snugdesk/core 0.2.25 → 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.
@@ -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
- countryCode
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
- code
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(
@@ -3140,79 +3349,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImpo
3140
3349
  }]
3141
3350
  }], ctorParameters: () => [{ type: AppSyncHelperService }] });
3142
3351
 
3143
- const FIELDS_LANGUAGE = `
3144
- code
3145
- nameEn
3146
- nameLocal
3147
- `;
3148
- const FIELDS_COUNTRY = `
3149
- code
3150
- nameEn
3151
- nameLocal
3152
- currency {
3153
- code
3154
- nameEn
3155
- }
3156
- officialLanguage {
3157
- ${FIELDS_LANGUAGE}
3158
- }
3159
- callingCode
3160
- region
3161
- flag
3162
- `;
3163
- const FIELDS_PHONE_NUMBER = `
3164
- countryCode
3165
- dialCode
3166
- e164Number
3167
- internationalNumber
3168
- nationalNumber
3169
- number
3170
- `;
3171
- class CommonService {
3172
- httpClient;
3173
- countriesData;
3174
- languagesData;
3175
- // private static readonly COUNTRY_ENDPOINT = `https://assets.snugdesk.com/metadata/countries.json`;
3176
- static COUNTRY_ENDPOINT = `https://snugdesk-assets.s3.amazonaws.com/metadata/countries.json`;
3177
- // private static readonly LANGUAGE_ENDPOINT = `https://assets.snugdesk.com/metadata/languages.json`;
3178
- static LANGUAGE_ENDPOINT = `https://snugdesk-assets.s3.amazonaws.com/metadata/languages.json`;
3179
- constructor(httpClient) {
3180
- this.httpClient = httpClient;
3181
- }
3182
- async getAllCountries() {
3183
- if (!this.countriesData) {
3184
- this.countriesData = await lastValueFrom(this.httpClient.get(CommonService.COUNTRY_ENDPOINT));
3185
- }
3186
- return this.countriesData;
3187
- }
3188
- async getCountryFromCallingCode(countryCallingCode) {
3189
- const countries = await this.getAllCountries();
3190
- return countries.find((country) => country.callingCode === countryCallingCode);
3191
- }
3192
- async getCountryFromCountryCode(countryCode) {
3193
- const countries = await this.getAllCountries();
3194
- return countries.find((country) => country.code === countryCode);
3195
- }
3196
- async getAllLanguages() {
3197
- if (!this.languagesData) {
3198
- this.languagesData = await lastValueFrom(this.httpClient.get(CommonService.LANGUAGE_ENDPOINT));
3199
- }
3200
- return this.languagesData;
3201
- }
3202
- async getLanguageFromLanguageCode(languageCode) {
3203
- const languages = await this.getAllLanguages();
3204
- return languages?.find((language) => language.code === languageCode);
3205
- }
3206
- 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 });
3207
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: CommonService, providedIn: 'root' });
3208
- }
3209
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: CommonService, decorators: [{
3210
- type: Injectable,
3211
- args: [{
3212
- providedIn: 'root',
3213
- }]
3214
- }], ctorParameters: () => [{ type: i1$2.HttpClient }] });
3215
-
3216
3352
  const FIELDS_TENANT = `
3217
3353
  id
3218
3354
  externalId
@@ -3225,9 +3361,7 @@ const FIELDS_TENANT = `
3225
3361
  preferences {
3226
3362
  timezoneName
3227
3363
  language {
3228
- code
3229
- nameEn
3230
- nameLocal
3364
+ ${FIELDS_LANGUAGE}
3231
3365
  }
3232
3366
  allowUserToChangePreferences
3233
3367
  }
@@ -3258,9 +3392,7 @@ const FIELDS_TENANT_MINIMAL = `
3258
3392
  preferences {
3259
3393
  timezoneName
3260
3394
  language {
3261
- code
3262
- nameEn
3263
- nameLocal
3395
+ ${FIELDS_LANGUAGE}
3264
3396
  }
3265
3397
  allowUserToChangePreferences
3266
3398
  }
@@ -3310,9 +3442,7 @@ const FIELDS_TENANT_EXPANDED = `
3310
3442
  preferences {
3311
3443
  timezoneName
3312
3444
  language {
3313
- code
3314
- nameEn
3315
- nameLocal
3445
+ ${FIELDS_LANGUAGE}
3316
3446
  }
3317
3447
  allowUserToChangePreferences
3318
3448
  }
@@ -3373,7 +3503,7 @@ class TenantService {
3373
3503
  }`;
3374
3504
  const gqlAPIServiceArguments = { id };
3375
3505
  const response = await this.appSyncService.query(statement, gqlAPIServiceArguments);
3376
- return response.data?.getTenant;
3506
+ return response.data.getTenant;
3377
3507
  }
3378
3508
  async GetTenantExpanded(id) {
3379
3509
  const statement = `query GetTenant($id: ID!) {
@@ -3383,7 +3513,7 @@ class TenantService {
3383
3513
  }`;
3384
3514
  const gqlAPIServiceArguments = { id };
3385
3515
  const response = await this.appSyncService.query(statement, gqlAPIServiceArguments);
3386
- return response.data?.getTenant;
3516
+ return response.data.getTenant;
3387
3517
  }
3388
3518
  async CreateTenant(input, condition) {
3389
3519
  const statement = `mutation CreateTenant($input: CreateTenantInput!, $condition: ModelTenantConditionInput) {