@dereekb/zoho 13.32.0 → 13.33.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.
@@ -1,5 +1,5 @@
1
1
  import { Injectable, Inject, Logger, Post, Req, Controller, Module } from '@nestjs/common';
2
- import { zohoAccountsFactory, zohoAccountsAccessToken, zohoCrmFactory, zohoCrmInsertRecord, zohoCrmUpsertRecord, zohoCrmUpdateRecord, zohoCrmDeleteRecord, zohoCrmGetRecordById, zohoCrmGetRecords, zohoCrmSearchRecords, zohoCrmSearchRecordsPageFactory, zohoCrmGetRelatedRecordsFunctionFactory, zohoCrmGetEmailsForRecord, zohoCrmGetEmailsForRecordPageFactory, zohoCrmGetAttachmentsForRecord, zohoCrmGetAttachmentsForRecordPageFactory, zohoCrmUploadAttachmentForRecord, zohoCrmDownloadAttachmentForRecord, zohoCrmDeleteAttachmentFromRecord, zohoCrmCreateNotes, zohoCrmDeleteNotes, zohoCrmCreateNotesForRecord, zohoCrmGetNotesForRecord, zohoCrmGetNotesForRecordPageFactory, zohoCrmExecuteRestApiFunction, zohoCrmCreateTagsForModule, zohoCrmDeleteTag, zohoCrmGetTagsForModule, zohoCrmAddTagsToRecords, zohoCrmRemoveTagsFromRecords, ZOHO_CRM_SERVICE_NAME, zohoRecruitFactory, zohoRecruitInsertRecord, zohoRecruitUpsertRecord, zohoRecruitUpdateRecord, zohoRecruitDeleteRecord, zohoRecruitGetRecordById, zohoRecruitGetRecords, zohoRecruitSearchRecords, zohoRecruitSearchRecordsPageFactory, zohoRecruitGetRelatedRecordsFunctionFactory, zohoRecruitGetEmailsForRecord, zohoRecruitGetEmailsForRecordPageFactory, zohoRecruitGetAttachmentsForRecord, zohoRecruitGetAttachmentsForRecordPageFactory, zohoRecruitUploadAttachmentForRecord, zohoRecruitDownloadAttachmentForRecord, zohoRecruitDeleteAttachmentFromRecord, zohoRecruitCreateNotes, zohoRecruitDeleteNotes, zohoRecruitCreateNotesForRecord, zohoRecruitGetNotesForRecord, zohoRecruitGetNotesForRecordPageFactory, zohoRecruitExecuteRestApiFunction, zohoRecruitAssociateCandidateRecordsWithJobOpenings, zohoRecruitSearchCandidateAssociatedJobOpeningRecords, zohoRecruitSearchCandidateAssociatedJobOpeningRecordsPageFactory, zohoRecruitSearchJobOpeningAssociatedCandidateRecords, zohoRecruitSearchJobOpeningAssociatedCandidateRecordsPageFactory, zohoRecruitCreateTagsForModule, zohoRecruitGetTagsForModule, zohoRecruitAddTagsToRecords, zohoRecruitRemoveTagsFromRecords, ZOHO_RECRUIT_SERVICE_NAME, zohoSignFactory, zohoSignGetDocument, zohoSignGetDocuments, zohoSignGetDocumentsPageFactory, zohoSignGetDocumentFormData, zohoSignRetrieveFieldTypes, zohoSignDownloadPdf, zohoSignDownloadCompletionCertificate, zohoSignCreateDocument, zohoSignCreateDocumentFromTemplate, zohoSignGetTemplate, zohoSignGetTemplates, zohoSignUpdateDocument, zohoSignSendDocumentForSignature, zohoSignExtendDocument, zohoSignDeleteDocument, zohoSignGetEmbeddedSigningUrl, ZOHO_SIGN_SERVICE_NAME, zohoDeskFactory, zohoDeskGetTickets, zohoDeskGetTicketById, zohoDeskSearchTickets, zohoDeskGetTicketsForContact, zohoDeskGetTicketsForProduct, zohoDeskGetTicketMetrics, zohoDeskGetAgentsTicketsCount, zohoDeskGetTicketsPageFactory, zohoDeskSearchTicketsPageFactory, zohoDeskGetDepartments, zohoDeskGetDepartmentById, zohoDeskGetContacts, zohoDeskGetContactById, zohoDeskGetContactsByIds, zohoDeskGetContactsPageFactory, zohoDeskGetTicketTags, zohoDeskAssociateTicketTags, zohoDeskDissociateTicketTag, zohoDeskSearchTags, zohoDeskGetAllTags, zohoDeskGetTicketFollowers, zohoDeskAddTicketFollowers, zohoDeskRemoveTicketFollowers, zohoDeskGetTicketAttachments, zohoDeskDeleteTicketAttachment, zohoDeskGetTicketComments, zohoDeskGetTicketCommentById, zohoDeskCreateTicketComment, zohoDeskDeleteTicketComment, zohoDeskGetTicketTimer, zohoDeskPerformTicketTimerAction, zohoDeskGetTicketTimeEntries, zohoDeskGetTicketTimeEntryById, zohoDeskGetTicketTimeEntrySummation, zohoDeskGetTicketThreads, zohoDeskGetTicketThreadById, zohoDeskGetTicketThreadsPageFactory, zohoDeskGetTicketActivities, zohoDeskGetTicketActivitiesPageFactory, zohoDeskGetAgents, zohoDeskGetAgentById, zohoDeskGetAgentsByIds, zohoDeskGetMyInfo, zohoDeskGetAgentsPageFactory, ZOHO_DESK_SERVICE_NAME } from '@dereekb/zoho';
2
+ import { zohoAccountsFactory, zohoAccountsAccessToken, zohoAccountsConfigApiUrl, zohoAccountsOAuthClientFactory, zohoAccountsRefreshTokenFromAuthorizationCode, zohoAccountsUserAccessToken, zohoAccountsUserInfo, zohoCrmFactory, zohoCrmInsertRecord, zohoCrmUpsertRecord, zohoCrmUpdateRecord, zohoCrmDeleteRecord, zohoCrmGetRecordById, zohoCrmGetRecords, zohoCrmSearchRecords, zohoCrmSearchRecordsPageFactory, zohoCrmGetRelatedRecordsFunctionFactory, zohoCrmGetEmailsForRecord, zohoCrmGetEmailsForRecordPageFactory, zohoCrmGetAttachmentsForRecord, zohoCrmGetAttachmentsForRecordPageFactory, zohoCrmUploadAttachmentForRecord, zohoCrmDownloadAttachmentForRecord, zohoCrmDeleteAttachmentFromRecord, zohoCrmCreateNotes, zohoCrmDeleteNotes, zohoCrmCreateNotesForRecord, zohoCrmGetNotesForRecord, zohoCrmGetNotesForRecordPageFactory, zohoCrmExecuteRestApiFunction, zohoCrmCreateTagsForModule, zohoCrmDeleteTag, zohoCrmGetTagsForModule, zohoCrmAddTagsToRecords, zohoCrmRemoveTagsFromRecords, ZOHO_CRM_SERVICE_NAME, zohoRecruitFactory, zohoRecruitInsertRecord, zohoRecruitUpsertRecord, zohoRecruitUpdateRecord, zohoRecruitDeleteRecord, zohoRecruitGetRecordById, zohoRecruitGetRecords, zohoRecruitSearchRecords, zohoRecruitSearchRecordsPageFactory, zohoRecruitGetRelatedRecordsFunctionFactory, zohoRecruitGetEmailsForRecord, zohoRecruitGetEmailsForRecordPageFactory, zohoRecruitGetAttachmentsForRecord, zohoRecruitGetAttachmentsForRecordPageFactory, zohoRecruitUploadAttachmentForRecord, zohoRecruitDownloadAttachmentForRecord, zohoRecruitDeleteAttachmentFromRecord, zohoRecruitCreateNotes, zohoRecruitDeleteNotes, zohoRecruitCreateNotesForRecord, zohoRecruitGetNotesForRecord, zohoRecruitGetNotesForRecordPageFactory, zohoRecruitExecuteRestApiFunction, zohoRecruitAssociateCandidateRecordsWithJobOpenings, zohoRecruitSearchCandidateAssociatedJobOpeningRecords, zohoRecruitSearchCandidateAssociatedJobOpeningRecordsPageFactory, zohoRecruitSearchJobOpeningAssociatedCandidateRecords, zohoRecruitSearchJobOpeningAssociatedCandidateRecordsPageFactory, zohoRecruitCreateTagsForModule, zohoRecruitGetTagsForModule, zohoRecruitAddTagsToRecords, zohoRecruitRemoveTagsFromRecords, ZOHO_RECRUIT_SERVICE_NAME, zohoSignFactory, zohoSignGetDocument, zohoSignGetDocuments, zohoSignGetDocumentsPageFactory, zohoSignGetDocumentFormData, zohoSignRetrieveFieldTypes, zohoSignDownloadPdf, zohoSignDownloadCompletionCertificate, zohoSignCreateDocument, zohoSignCreateDocumentFromTemplate, zohoSignGetTemplate, zohoSignGetTemplates, zohoSignUpdateDocument, zohoSignSendDocumentForSignature, zohoSignExtendDocument, zohoSignDeleteDocument, zohoSignGetEmbeddedSigningUrl, ZOHO_SIGN_SERVICE_NAME, zohoDeskFactory, zohoDeskGetTickets, zohoDeskGetTicketById, zohoDeskSearchTickets, zohoDeskGetTicketsForContact, zohoDeskGetTicketsForProduct, zohoDeskGetTicketMetrics, zohoDeskGetAgentsTicketsCount, zohoDeskGetTicketsPageFactory, zohoDeskSearchTicketsPageFactory, zohoDeskGetDepartments, zohoDeskGetDepartmentById, zohoDeskGetContacts, zohoDeskGetContactById, zohoDeskGetContactsByIds, zohoDeskGetContactsPageFactory, zohoDeskGetTicketTags, zohoDeskAssociateTicketTags, zohoDeskDissociateTicketTag, zohoDeskSearchTags, zohoDeskGetAllTags, zohoDeskGetTicketFollowers, zohoDeskAddTicketFollowers, zohoDeskRemoveTicketFollowers, zohoDeskGetTicketAttachments, zohoDeskDeleteTicketAttachment, zohoDeskGetTicketComments, zohoDeskGetTicketCommentById, zohoDeskCreateTicketComment, zohoDeskDeleteTicketComment, zohoDeskGetTicketTimer, zohoDeskPerformTicketTimerAction, zohoDeskGetTicketTimeEntries, zohoDeskGetTicketTimeEntryById, zohoDeskGetTicketTimeEntrySummation, zohoDeskGetTicketThreads, zohoDeskGetTicketThreadById, zohoDeskGetTicketThreadsPageFactory, zohoDeskGetTicketActivities, zohoDeskGetTicketActivitiesPageFactory, zohoDeskGetAgents, zohoDeskGetAgentById, zohoDeskGetAgentsByIds, zohoDeskGetMyInfo, zohoDeskGetAgentsPageFactory, ZOHO_DESK_SERVICE_NAME } from '@dereekb/zoho';
3
3
  import { memoizeAsyncKeyedValueCache, inMemoryAsyncKeyedValueCache, mergeAsyncValueCaches, isExpired, filterMaybeArrayValues, handlerFactory, handlerConfigurerFactory, handlerMappedSetFunctionFactory } from '@dereekb/util';
4
4
  import { createJsonFileAsyncKeyedValueCache, readJsonFile, RawBody } from '@dereekb/nestjs';
5
5
  import { ConfigService, ConfigModule } from '@nestjs/config';
@@ -79,12 +79,12 @@ function readZohoConfigFromConfigService(configOrService, servicePrefix) {
79
79
  }
80
80
  }
81
81
 
82
- function _class_call_check$e(instance, Constructor) {
82
+ function _class_call_check$g(instance, Constructor) {
83
83
  if (!(instance instanceof Constructor)) {
84
84
  throw new TypeError("Cannot call a class as a function");
85
85
  }
86
86
  }
87
- function _defineProperties$c(target, props) {
87
+ function _defineProperties$e(target, props) {
88
88
  for(var i = 0; i < props.length; i++){
89
89
  var descriptor = props[i];
90
90
  descriptor.enumerable = descriptor.enumerable || false;
@@ -93,11 +93,11 @@ function _defineProperties$c(target, props) {
93
93
  Object.defineProperty(target, descriptor.key, descriptor);
94
94
  }
95
95
  }
96
- function _create_class$c(Constructor, protoProps, staticProps) {
97
- if (staticProps) _defineProperties$c(Constructor, staticProps);
96
+ function _create_class$e(Constructor, protoProps, staticProps) {
97
+ if (staticProps) _defineProperties$e(Constructor, staticProps);
98
98
  return Constructor;
99
99
  }
100
- function _define_property$e(obj, key, value) {
100
+ function _define_property$g(obj, key, value) {
101
101
  if (key in obj) {
102
102
  Object.defineProperty(obj, key, {
103
103
  value: value,
@@ -114,11 +114,11 @@ function _define_property$e(obj, key, value) {
114
114
  * Configuration for ZohoService
115
115
  */ var ZohoAccountsServiceConfig = /*#__PURE__*/ function() {
116
116
  function ZohoAccountsServiceConfig() {
117
- _class_call_check$e(this, ZohoAccountsServiceConfig);
118
- _define_property$e(this, "zohoAccounts", void 0);
119
- _define_property$e(this, "factoryConfig", void 0);
117
+ _class_call_check$g(this, ZohoAccountsServiceConfig);
118
+ _define_property$g(this, "zohoAccounts", void 0);
119
+ _define_property$g(this, "factoryConfig", void 0);
120
120
  }
121
- _create_class$c(ZohoAccountsServiceConfig, null, [
121
+ _create_class$e(ZohoAccountsServiceConfig, null, [
122
122
  {
123
123
  key: "assertValidConfig",
124
124
  value: function assertValidConfig(config) {
@@ -182,7 +182,7 @@ function _define_property$e(obj, key, value) {
182
182
  return config;
183
183
  }
184
184
 
185
- function _array_like_to_array$4(arr, len) {
185
+ function _array_like_to_array$5(arr, len) {
186
186
  if (len == null || len > arr.length) len = arr.length;
187
187
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
188
188
  return arr2;
@@ -190,8 +190,8 @@ function _array_like_to_array$4(arr, len) {
190
190
  function _array_with_holes(arr) {
191
191
  if (Array.isArray(arr)) return arr;
192
192
  }
193
- function _array_without_holes$4(arr) {
194
- if (Array.isArray(arr)) return _array_like_to_array$4(arr);
193
+ function _array_without_holes$5(arr) {
194
+ if (Array.isArray(arr)) return _array_like_to_array$5(arr);
195
195
  }
196
196
  function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
197
197
  try {
@@ -222,12 +222,12 @@ function _async_to_generator$3(fn) {
222
222
  });
223
223
  };
224
224
  }
225
- function _class_call_check$d(instance, Constructor) {
225
+ function _class_call_check$f(instance, Constructor) {
226
226
  if (!(instance instanceof Constructor)) {
227
227
  throw new TypeError("Cannot call a class as a function");
228
228
  }
229
229
  }
230
- function _define_property$d(obj, key, value) {
230
+ function _define_property$f(obj, key, value) {
231
231
  if (key in obj) {
232
232
  Object.defineProperty(obj, key, {
233
233
  value: value,
@@ -248,7 +248,7 @@ function _instanceof(left, right) {
248
248
  return left instanceof right;
249
249
  }
250
250
  }
251
- function _iterable_to_array$4(iter) {
251
+ function _iterable_to_array$5(iter) {
252
252
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
253
253
  }
254
254
  function _iterable_to_array_limit(arr, i) {
@@ -278,7 +278,7 @@ function _iterable_to_array_limit(arr, i) {
278
278
  function _non_iterable_rest() {
279
279
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
280
280
  }
281
- function _non_iterable_spread$4() {
281
+ function _non_iterable_spread$5() {
282
282
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
283
283
  }
284
284
  function _object_spread$6(target) {
@@ -291,7 +291,7 @@ function _object_spread$6(target) {
291
291
  }));
292
292
  }
293
293
  ownKeys.forEach(function(key) {
294
- _define_property$d(target, key, source[key]);
294
+ _define_property$f(target, key, source[key]);
295
295
  });
296
296
  }
297
297
  return target;
@@ -316,22 +316,22 @@ function _object_spread_props$5(target, source) {
316
316
  return target;
317
317
  }
318
318
  function _sliced_to_array(arr, i) {
319
- return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array$4(arr, i) || _non_iterable_rest();
319
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array$5(arr, i) || _non_iterable_rest();
320
320
  }
321
- function _to_consumable_array$4(arr) {
322
- return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$4(arr) || _non_iterable_spread$4();
321
+ function _to_consumable_array$5(arr) {
322
+ return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$5(arr) || _non_iterable_spread$5();
323
323
  }
324
324
  function _type_of(obj) {
325
325
  "@swc/helpers - typeof";
326
326
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
327
327
  }
328
- function _unsupported_iterable_to_array$4(o, minLen) {
328
+ function _unsupported_iterable_to_array$5(o, minLen) {
329
329
  if (!o) return;
330
- if (typeof o === "string") return _array_like_to_array$4(o, minLen);
330
+ if (typeof o === "string") return _array_like_to_array$5(o, minLen);
331
331
  var n = Object.prototype.toString.call(o).slice(8, -1);
332
332
  if (n === "Object" && o.constructor) n = o.constructor.name;
333
333
  if (n === "Map" || n === "Set") return Array.from(n);
334
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
334
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$5(o, minLen);
335
335
  }
336
336
  function _ts_generator$3(thisArg, body) {
337
337
  var f, y, t, _ = {
@@ -435,7 +435,7 @@ function _ts_generator$3(thisArg, body) {
435
435
  /**
436
436
  * Service used for retrieving ZohoAccessTokenCache for Zoho services.
437
437
  */ var ZohoAccountsAccessTokenCacheService = function ZohoAccountsAccessTokenCacheService() {
438
- _class_call_check$d(this, ZohoAccountsAccessTokenCacheService);
438
+ _class_call_check$f(this, ZohoAccountsAccessTokenCacheService);
439
439
  };
440
440
  ZohoAccountsAccessTokenCacheService = __decorate([
441
441
  Injectable()
@@ -510,7 +510,7 @@ function updateZohoCacheCapturingError(cache, accessToken) {
510
510
  * @returns A merged ZohoAccountsAccessTokenCacheService that delegates across all inputs.
511
511
  * @throws {Error} When `inputServicesToMerge` is empty.
512
512
  */ function mergeZohoAccountsAccessTokenCacheServices(inputServicesToMerge, logError) {
513
- var services = _to_consumable_array$4(inputServicesToMerge);
513
+ var services = _to_consumable_array$5(inputServicesToMerge);
514
514
  var logErrorFunction = typeof logError === 'function' ? logError : logError === false ? undefined : logMergeZohoAccountsAccessTokenCacheServiceErrorFunction;
515
515
  if (services.length === 0) {
516
516
  throw new Error('mergeZohoAccountsAccessTokenCacheServices() input cannot be empty.');
@@ -978,12 +978,12 @@ var DEFAULT_FILE_ZOHO_ACCOUNTS_ACCESS_TOKEN_CACHE_SERVICE_PATH = '.tmp/zoho-acce
978
978
  };
979
979
  }
980
980
 
981
- function _class_call_check$c(instance, Constructor) {
981
+ function _class_call_check$e(instance, Constructor) {
982
982
  if (!(instance instanceof Constructor)) {
983
983
  throw new TypeError("Cannot call a class as a function");
984
984
  }
985
985
  }
986
- function _defineProperties$b(target, props) {
986
+ function _defineProperties$d(target, props) {
987
987
  for(var i = 0; i < props.length; i++){
988
988
  var descriptor = props[i];
989
989
  descriptor.enumerable = descriptor.enumerable || false;
@@ -992,11 +992,11 @@ function _defineProperties$b(target, props) {
992
992
  Object.defineProperty(target, descriptor.key, descriptor);
993
993
  }
994
994
  }
995
- function _create_class$b(Constructor, protoProps, staticProps) {
996
- if (protoProps) _defineProperties$b(Constructor.prototype, protoProps);
995
+ function _create_class$d(Constructor, protoProps, staticProps) {
996
+ if (protoProps) _defineProperties$d(Constructor.prototype, protoProps);
997
997
  return Constructor;
998
998
  }
999
- function _define_property$c(obj, key, value) {
999
+ function _define_property$e(obj, key, value) {
1000
1000
  if (key in obj) {
1001
1001
  Object.defineProperty(obj, key, {
1002
1002
  value: value,
@@ -1019,18 +1019,18 @@ function _object_spread$5(target) {
1019
1019
  }));
1020
1020
  }
1021
1021
  ownKeys.forEach(function(key) {
1022
- _define_property$c(target, key, source[key]);
1022
+ _define_property$e(target, key, source[key]);
1023
1023
  });
1024
1024
  }
1025
1025
  return target;
1026
1026
  }
1027
1027
  var ZohoAccountsApi = /*#__PURE__*/ function() {
1028
1028
  function ZohoAccountsApi(config, cacheService) {
1029
- _class_call_check$c(this, ZohoAccountsApi);
1029
+ _class_call_check$e(this, ZohoAccountsApi);
1030
1030
  var _config_zohoAccounts_accessTokenCache, _config_factoryConfig;
1031
- _define_property$c(this, "config", void 0);
1032
- _define_property$c(this, "cacheService", void 0);
1033
- _define_property$c(this, "zohoAccounts", void 0);
1031
+ _define_property$e(this, "config", void 0);
1032
+ _define_property$e(this, "cacheService", void 0);
1033
+ _define_property$e(this, "zohoAccounts", void 0);
1034
1034
  this.config = config;
1035
1035
  this.cacheService = cacheService;
1036
1036
  var accessTokenCache = (_config_zohoAccounts_accessTokenCache = config.zohoAccounts.accessTokenCache) !== null && _config_zohoAccounts_accessTokenCache !== void 0 ? _config_zohoAccounts_accessTokenCache : cacheService.loadZohoAccessTokenCache(config.zohoAccounts.serviceAccessTokenKey);
@@ -1038,7 +1038,7 @@ var ZohoAccountsApi = /*#__PURE__*/ function() {
1038
1038
  accessTokenCache: accessTokenCache
1039
1039
  }, config.zohoAccounts));
1040
1040
  }
1041
- _create_class$b(ZohoAccountsApi, [
1041
+ _create_class$d(ZohoAccountsApi, [
1042
1042
  {
1043
1043
  key: "accountsContext",
1044
1044
  get: function get() {
@@ -1061,6 +1061,314 @@ ZohoAccountsApi = __decorate([
1061
1061
  __param(1, Inject(ZohoAccountsAccessTokenCacheService))
1062
1062
  ], ZohoAccountsApi);
1063
1063
 
1064
+ function _class_call_check$d(instance, Constructor) {
1065
+ if (!(instance instanceof Constructor)) {
1066
+ throw new TypeError("Cannot call a class as a function");
1067
+ }
1068
+ }
1069
+ function _defineProperties$c(target, props) {
1070
+ for(var i = 0; i < props.length; i++){
1071
+ var descriptor = props[i];
1072
+ descriptor.enumerable = descriptor.enumerable || false;
1073
+ descriptor.configurable = true;
1074
+ if ("value" in descriptor) descriptor.writable = true;
1075
+ Object.defineProperty(target, descriptor.key, descriptor);
1076
+ }
1077
+ }
1078
+ function _create_class$c(Constructor, protoProps, staticProps) {
1079
+ if (staticProps) _defineProperties$c(Constructor, staticProps);
1080
+ return Constructor;
1081
+ }
1082
+ function _define_property$d(obj, key, value) {
1083
+ if (key in obj) {
1084
+ Object.defineProperty(obj, key, {
1085
+ value: value,
1086
+ enumerable: true,
1087
+ configurable: true,
1088
+ writable: true
1089
+ });
1090
+ } else {
1091
+ obj[key] = value;
1092
+ }
1093
+ return obj;
1094
+ }
1095
+ /**
1096
+ * Environment key naming the Zoho Accounts datacenter (or a full accounts URL) to authorize against.
1097
+ */ var ZOHO_ACCOUNTS_URL_CONFIG_KEY = 'ZOHO_ACCOUNTS_URL';
1098
+ /**
1099
+ * Environment key holding the Zoho OAuth client id.
1100
+ */ var ZOHO_ACCOUNTS_CLIENT_ID_CONFIG_KEY = 'ZOHO_ACCOUNTS_CLIENT_ID';
1101
+ /**
1102
+ * Environment key holding the Zoho OAuth client secret.
1103
+ */ var ZOHO_ACCOUNTS_CLIENT_SECRET_CONFIG_KEY = 'ZOHO_ACCOUNTS_CLIENT_SECRET';
1104
+ /**
1105
+ * Configuration for {@link ZohoAccountsOAuthApi}.
1106
+ *
1107
+ * Read from the three existing flat `ZOHO_ACCOUNTS_*` keys rather than composed through
1108
+ * `zohoConfigServiceReaderFunction`, which requires a `serviceAccessTokenKey` a per-user OAuth
1109
+ * client does not have. Notably absent: `ZOHO_ACCOUNTS_REFRESH_TOKEN` (a per-user flow has no
1110
+ * server refresh token) and any scope variable (scopes are declared in code).
1111
+ */ var ZohoAccountsOAuthServiceConfig = /*#__PURE__*/ function() {
1112
+ function ZohoAccountsOAuthServiceConfig() {
1113
+ _class_call_check$d(this, ZohoAccountsOAuthServiceConfig);
1114
+ _define_property$d(this, "zohoAccountsOAuth", void 0);
1115
+ _define_property$d(this, "factoryConfig", void 0);
1116
+ }
1117
+ _create_class$c(ZohoAccountsOAuthServiceConfig, null, [
1118
+ {
1119
+ key: "assertValidConfig",
1120
+ value: function assertValidConfig(config) {
1121
+ var zohoAccountsOAuth = config.zohoAccountsOAuth;
1122
+ if (!zohoAccountsOAuth) {
1123
+ throw new Error('ZohoAccountsOAuthServiceConfig.zohoAccountsOAuth is required');
1124
+ }
1125
+ if (!zohoAccountsOAuth.clientId) {
1126
+ throw new Error("ZohoAccountsOAuthServiceConfig requires a clientId (".concat(ZOHO_ACCOUNTS_CLIENT_ID_CONFIG_KEY, ")."));
1127
+ }
1128
+ if (!zohoAccountsOAuth.clientSecret) {
1129
+ throw new Error("ZohoAccountsOAuthServiceConfig requires a clientSecret (".concat(ZOHO_ACCOUNTS_CLIENT_SECRET_CONFIG_KEY, ")."));
1130
+ }
1131
+ }
1132
+ }
1133
+ ]);
1134
+ return ZohoAccountsOAuthServiceConfig;
1135
+ }();
1136
+ /**
1137
+ * Factory function that creates a {@link ZohoAccountsOAuthServiceConfig} from NestJS ConfigService
1138
+ * environment variables.
1139
+ *
1140
+ * @param configService - The NestJS ConfigService instance.
1141
+ * @returns A validated ZohoAccountsOAuthServiceConfig.
1142
+ * @throws {Error} When the client id or client secret is not configured.
1143
+ */ function zohoAccountsOAuthServiceConfigFactory(configService) {
1144
+ var clientId = configService.get(ZOHO_ACCOUNTS_CLIENT_ID_CONFIG_KEY);
1145
+ var clientSecret = configService.get(ZOHO_ACCOUNTS_CLIENT_SECRET_CONFIG_KEY);
1146
+ var apiUrl = configService.get(ZOHO_ACCOUNTS_URL_CONFIG_KEY);
1147
+ var config = {
1148
+ zohoAccountsOAuth: {
1149
+ clientId: clientId || undefined,
1150
+ clientSecret: clientSecret || undefined,
1151
+ apiUrl: apiUrl || undefined
1152
+ }
1153
+ };
1154
+ ZohoAccountsOAuthServiceConfig.assertValidConfig(config);
1155
+ return config;
1156
+ }
1157
+
1158
+ function _class_call_check$c(instance, Constructor) {
1159
+ if (!(instance instanceof Constructor)) {
1160
+ throw new TypeError("Cannot call a class as a function");
1161
+ }
1162
+ }
1163
+ function _defineProperties$b(target, props) {
1164
+ for(var i = 0; i < props.length; i++){
1165
+ var descriptor = props[i];
1166
+ descriptor.enumerable = descriptor.enumerable || false;
1167
+ descriptor.configurable = true;
1168
+ if ("value" in descriptor) descriptor.writable = true;
1169
+ Object.defineProperty(target, descriptor.key, descriptor);
1170
+ }
1171
+ }
1172
+ function _create_class$b(Constructor, protoProps, staticProps) {
1173
+ if (protoProps) _defineProperties$b(Constructor.prototype, protoProps);
1174
+ return Constructor;
1175
+ }
1176
+ function _define_property$c(obj, key, value) {
1177
+ if (key in obj) {
1178
+ Object.defineProperty(obj, key, {
1179
+ value: value,
1180
+ enumerable: true,
1181
+ configurable: true,
1182
+ writable: true
1183
+ });
1184
+ } else {
1185
+ obj[key] = value;
1186
+ }
1187
+ return obj;
1188
+ }
1189
+ /**
1190
+ * The Zoho Accounts endpoints a per-user connect flow needs: the authorization-code exchange, the
1191
+ * per-user token refresh, and the identity lookup that labels the connection.
1192
+ *
1193
+ * Deliberately separate from {@link ZohoAccountsApi}, which requires a server refresh token and a
1194
+ * token cache. A per-user handoff has neither — the handoff is how a refresh token is obtained.
1195
+ */ var ZohoAccountsOAuthApi = /*#__PURE__*/ function() {
1196
+ function ZohoAccountsOAuthApi(config) {
1197
+ _class_call_check$c(this, ZohoAccountsOAuthApi);
1198
+ var _config_factoryConfig;
1199
+ _define_property$c(this, "config", void 0);
1200
+ _define_property$c(this, "_clientFactory", void 0);
1201
+ /**
1202
+ * Per-host clients, memoized so a repeated datacenter reuses one client rather than rebuilding
1203
+ * its fetch stack per callback.
1204
+ */ _define_property$c(this, "_clients", new Map());
1205
+ /**
1206
+ * The accounts host configured for this app.
1207
+ */ _define_property$c(this, "apiUrl", void 0);
1208
+ /**
1209
+ * The OAuth client id the authorize request is composed with.
1210
+ */ _define_property$c(this, "clientId", void 0);
1211
+ _define_property$c(this, "_clientSecret", void 0);
1212
+ this.config = config;
1213
+ // asserted here rather than trusted, so a config assembled in code (not through the env factory,
1214
+ // which already asserts) cannot reach the consent screen with an undefined client id
1215
+ ZohoAccountsOAuthServiceConfig.assertValidConfig(config);
1216
+ var _config_zohoAccountsOAuth = config.zohoAccountsOAuth, apiUrl = _config_zohoAccountsOAuth.apiUrl, clientId = _config_zohoAccountsOAuth.clientId, clientSecret = _config_zohoAccountsOAuth.clientSecret;
1217
+ this.apiUrl = zohoAccountsConfigApiUrl(apiUrl !== null && apiUrl !== void 0 ? apiUrl : 'us');
1218
+ this.clientId = clientId;
1219
+ this._clientSecret = clientSecret;
1220
+ this._clientFactory = zohoAccountsOAuthClientFactory((_config_factoryConfig = config.factoryConfig) !== null && _config_factoryConfig !== void 0 ? _config_factoryConfig : {});
1221
+ }
1222
+ _create_class$b(ZohoAccountsOAuthApi, [
1223
+ {
1224
+ key: "oauthClientContext",
1225
+ get: /**
1226
+ * The client for the configured datacenter.
1227
+ */ function get() {
1228
+ return this.oauthClientContextForApiUrl(this.apiUrl);
1229
+ }
1230
+ },
1231
+ {
1232
+ /**
1233
+ * The client for a specific accounts host, memoized per host.
1234
+ *
1235
+ * Zoho echoes the issuing datacenter back as `accounts-server` on the callback, and a code issued
1236
+ * by one datacenter cannot be exchanged at another. Callers MUST have checked the host against
1237
+ * `isKnownZohoAccountsApiUrl` first — this method will happily build a client for any URL, and the
1238
+ * client secret travels to whatever host it is given.
1239
+ *
1240
+ * @param apiUrl - The datacenter key or full accounts URL to build a client for.
1241
+ * @returns The memoized client context for that host.
1242
+ */ key: "oauthClientContextForApiUrl",
1243
+ value: function oauthClientContextForApiUrl(apiUrl) {
1244
+ var resolvedApiUrl = zohoAccountsConfigApiUrl(apiUrl);
1245
+ var context = this._clients.get(resolvedApiUrl);
1246
+ if (context == null) {
1247
+ context = this._clientFactory({
1248
+ clientId: this.clientId,
1249
+ clientSecret: this._clientSecret,
1250
+ apiUrl: resolvedApiUrl
1251
+ }).oauthClientContext;
1252
+ this._clients.set(resolvedApiUrl, context);
1253
+ }
1254
+ return context;
1255
+ }
1256
+ },
1257
+ {
1258
+ // MARK: Accessors
1259
+ /**
1260
+ * Exchanges a single-use authorization code for tokens.
1261
+ *
1262
+ * @param input - The code, the redirect URI it was issued against, and the optional accounts host.
1263
+ * @returns The Zoho token response. `refresh_token` may be absent on a re-consent.
1264
+ */ key: "exchangeAuthorizationCode",
1265
+ value: function exchangeAuthorizationCode(input) {
1266
+ var code = input.code, redirectUri = input.redirectUri, accountsApiUrl = input.accountsApiUrl;
1267
+ var context = this.oauthClientContextForApiUrl(accountsApiUrl !== null && accountsApiUrl !== void 0 ? accountsApiUrl : this.apiUrl);
1268
+ return zohoAccountsRefreshTokenFromAuthorizationCode(context)({
1269
+ code: code,
1270
+ redirectUri: redirectUri
1271
+ });
1272
+ }
1273
+ },
1274
+ {
1275
+ /**
1276
+ * Exchanges a user's refresh token for a new access token.
1277
+ *
1278
+ * Zoho does not rotate refresh tokens, so the token passed in stays valid and the response carries
1279
+ * no replacement — the caller keeps the one it already has. The response DOES carry `api_domain`,
1280
+ * which is the host the new access token is usable against, so persist it.
1281
+ *
1282
+ * @param input - The user's refresh token and the optional accounts host.
1283
+ * @returns The Zoho access token response.
1284
+ */ key: "refreshUserAccessToken",
1285
+ value: function refreshUserAccessToken(input) {
1286
+ var refreshToken = input.refreshToken, accountsApiUrl = input.accountsApiUrl;
1287
+ var context = this.oauthClientContextForApiUrl(accountsApiUrl !== null && accountsApiUrl !== void 0 ? accountsApiUrl : this.apiUrl);
1288
+ return zohoAccountsUserAccessToken(context)({
1289
+ refreshToken: refreshToken
1290
+ });
1291
+ }
1292
+ },
1293
+ {
1294
+ /**
1295
+ * Reads the Zoho identity an access token was issued to.
1296
+ *
1297
+ * @param input - The access token and the optional accounts host.
1298
+ * @returns The user info response.
1299
+ */ key: "userInfo",
1300
+ value: function userInfo(input) {
1301
+ var accessToken = input.accessToken, accountsApiUrl = input.accountsApiUrl;
1302
+ var context = this.oauthClientContextForApiUrl(accountsApiUrl !== null && accountsApiUrl !== void 0 ? accountsApiUrl : this.apiUrl);
1303
+ return zohoAccountsUserInfo(context)({
1304
+ accessToken: accessToken
1305
+ });
1306
+ }
1307
+ }
1308
+ ]);
1309
+ return ZohoAccountsOAuthApi;
1310
+ }();
1311
+ ZohoAccountsOAuthApi = __decorate([
1312
+ Injectable(),
1313
+ __param(0, Inject(ZohoAccountsOAuthServiceConfig))
1314
+ ], ZohoAccountsOAuthApi);
1315
+
1316
+ function _array_like_to_array$4(arr, len) {
1317
+ if (len == null || len > arr.length) len = arr.length;
1318
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1319
+ return arr2;
1320
+ }
1321
+ function _array_without_holes$4(arr) {
1322
+ if (Array.isArray(arr)) return _array_like_to_array$4(arr);
1323
+ }
1324
+ function _iterable_to_array$4(iter) {
1325
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
1326
+ }
1327
+ function _non_iterable_spread$4() {
1328
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1329
+ }
1330
+ function _to_consumable_array$4(arr) {
1331
+ return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$4(arr) || _non_iterable_spread$4();
1332
+ }
1333
+ function _unsupported_iterable_to_array$4(o, minLen) {
1334
+ if (!o) return;
1335
+ if (typeof o === "string") return _array_like_to_array$4(o, minLen);
1336
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1337
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1338
+ if (n === "Map" || n === "Set") return Array.from(n);
1339
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$4(o, minLen);
1340
+ }
1341
+ /**
1342
+ * Convenience function used to generate ModuleMetadata for an app's ZohoAccountsOAuthModule.
1343
+ *
1344
+ * Unlike `appZohoCrmModuleMetadata`, this needs no `ZohoAccountsAccessTokenCacheService` and
1345
+ * therefore no dependency module: a per-user connect flow has no server token to cache.
1346
+ *
1347
+ * @param config - The module metadata configuration including an optional config factory.
1348
+ * @returns NestJS ModuleMetadata for registering the ZohoAccountsOAuthApi.
1349
+ */ function appZohoAccountsOAuthModuleMetadata(config) {
1350
+ var _config_zohoAccountsOAuthServiceConfigFactory;
1351
+ var imports = config.imports, exports = config.exports, providers = config.providers;
1352
+ return {
1353
+ imports: [
1354
+ ConfigModule
1355
+ ].concat(_to_consumable_array$4(imports !== null && imports !== void 0 ? imports : [])),
1356
+ exports: [
1357
+ ZohoAccountsOAuthApi
1358
+ ].concat(_to_consumable_array$4(exports !== null && exports !== void 0 ? exports : [])),
1359
+ providers: [
1360
+ {
1361
+ provide: ZohoAccountsOAuthServiceConfig,
1362
+ inject: [
1363
+ ConfigService
1364
+ ],
1365
+ useFactory: (_config_zohoAccountsOAuthServiceConfigFactory = config.zohoAccountsOAuthServiceConfigFactory) !== null && _config_zohoAccountsOAuthServiceConfigFactory !== void 0 ? _config_zohoAccountsOAuthServiceConfigFactory : zohoAccountsOAuthServiceConfigFactory
1366
+ },
1367
+ ZohoAccountsOAuthApi
1368
+ ].concat(_to_consumable_array$4(providers !== null && providers !== void 0 ? providers : []))
1369
+ };
1370
+ }
1371
+
1064
1372
  function _class_call_check$b(instance, Constructor) {
1065
1373
  if (!(instance instanceof Constructor)) {
1066
1374
  throw new TypeError("Cannot call a class as a function");
@@ -4325,4 +4633,4 @@ function _unsupported_iterable_to_array(o, minLen) {
4325
4633
  };
4326
4634
  }
4327
4635
 
4328
- export { DEFAULT_FILE_ZOHO_ACCOUNTS_ACCESS_TOKEN_CACHE_SERVICE_PATH, ZOHO_API_URL_CONFIG_KEY, ZOHO_ORG_ID_CONFIG_KEY, ZOHO_SIGN_WEBHOOK_SECRET_TOKEN_ENV_VAR, ZOHO_SIGN_WEBHOOK_SIGNATURE_HEADER, ZohoAccountsAccessTokenCacheService, ZohoAccountsApi, ZohoAccountsServiceConfig, ZohoCrmApi, ZohoCrmServiceConfig, ZohoDeskApi, ZohoDeskServiceConfig, ZohoRecruitApi, ZohoRecruitServiceConfig, ZohoSignApi, ZohoSignServiceConfig, ZohoSignWebhookController, ZohoSignWebhookModule, ZohoSignWebhookService, ZohoSignWebhookServiceConfig, appZohoCrmModuleMetadata, appZohoDeskModuleMetadata, appZohoRecruitModuleMetadata, appZohoSignModuleMetadata, assertValidZohoConfig, fileZohoAccountsAccessTokenCacheService, logMergeZohoAccountsAccessTokenCacheServiceErrorFunction, memoryZohoAccountsAccessTokenCacheService, mergeZohoAccountsAccessTokenCacheServices, readZohoConfigFromConfigService, zohoAccountsServiceConfigFromConfigService, zohoConfigServiceReaderFunction, zohoCrmAccountServiceConfigFactory, zohoCrmServiceConfigFactory, zohoDeskAccountServiceConfigFactory, zohoDeskServiceConfigFactory, zohoRecruitAccountServiceConfigFactory, zohoRecruitServiceConfigFactory, zohoSignAccountServiceConfigFactory, zohoSignEventHandlerConfigurerFactory, zohoSignEventHandlerFactory, zohoSignServiceConfigFactory, zohoSignWebhookEvent, zohoSignWebhookEventVerifier, zohoSignWebhookServiceConfigFactory };
4636
+ export { DEFAULT_FILE_ZOHO_ACCOUNTS_ACCESS_TOKEN_CACHE_SERVICE_PATH, ZOHO_ACCOUNTS_CLIENT_ID_CONFIG_KEY, ZOHO_ACCOUNTS_CLIENT_SECRET_CONFIG_KEY, ZOHO_ACCOUNTS_URL_CONFIG_KEY, ZOHO_API_URL_CONFIG_KEY, ZOHO_ORG_ID_CONFIG_KEY, ZOHO_SIGN_WEBHOOK_SECRET_TOKEN_ENV_VAR, ZOHO_SIGN_WEBHOOK_SIGNATURE_HEADER, ZohoAccountsAccessTokenCacheService, ZohoAccountsApi, ZohoAccountsOAuthApi, ZohoAccountsOAuthServiceConfig, ZohoAccountsServiceConfig, ZohoCrmApi, ZohoCrmServiceConfig, ZohoDeskApi, ZohoDeskServiceConfig, ZohoRecruitApi, ZohoRecruitServiceConfig, ZohoSignApi, ZohoSignServiceConfig, ZohoSignWebhookController, ZohoSignWebhookModule, ZohoSignWebhookService, ZohoSignWebhookServiceConfig, appZohoAccountsOAuthModuleMetadata, appZohoCrmModuleMetadata, appZohoDeskModuleMetadata, appZohoRecruitModuleMetadata, appZohoSignModuleMetadata, assertValidZohoConfig, fileZohoAccountsAccessTokenCacheService, logMergeZohoAccountsAccessTokenCacheServiceErrorFunction, memoryZohoAccountsAccessTokenCacheService, mergeZohoAccountsAccessTokenCacheServices, readZohoConfigFromConfigService, zohoAccountsOAuthServiceConfigFactory, zohoAccountsServiceConfigFromConfigService, zohoConfigServiceReaderFunction, zohoCrmAccountServiceConfigFactory, zohoCrmServiceConfigFactory, zohoDeskAccountServiceConfigFactory, zohoDeskServiceConfigFactory, zohoRecruitAccountServiceConfigFactory, zohoRecruitServiceConfigFactory, zohoSignAccountServiceConfigFactory, zohoSignEventHandlerConfigurerFactory, zohoSignEventHandlerFactory, zohoSignServiceConfigFactory, zohoSignWebhookEvent, zohoSignWebhookEventVerifier, zohoSignWebhookServiceConfigFactory };
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@dereekb/zoho/nestjs",
3
- "version": "13.32.0",
3
+ "version": "13.33.0",
4
4
  "peerDependencies": {
5
- "@dereekb/nestjs": "13.32.0",
6
- "@dereekb/rxjs": "13.32.0",
7
- "@dereekb/util": "13.32.0",
8
- "@dereekb/zoho": "13.32.0",
5
+ "@dereekb/nestjs": "13.33.0",
6
+ "@dereekb/rxjs": "13.33.0",
7
+ "@dereekb/util": "13.33.0",
8
+ "@dereekb/zoho": "13.33.0",
9
9
  "@nestjs/common": "^11.1.19",
10
10
  "@nestjs/config": "^4.0.4",
11
11
  "express": "^5.2.1"