@extrahorizon/javascript-sdk 8.9.0-dev-122-b59ec47 → 8.9.0-feat-134-c0f5b9d

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/build/index.cjs.js +198 -62
  3. package/build/index.mjs +197 -63
  4. package/build/types/client.d.ts +6 -0
  5. package/build/types/constants.d.ts +1 -0
  6. package/build/types/errors.d.ts +11 -0
  7. package/build/types/mockType.d.ts +60 -0
  8. package/build/types/services/auth/applications/types.d.ts +3 -3
  9. package/build/types/services/auth/oauth1/types.d.ts +2 -2
  10. package/build/types/services/auth/oauth2/types.d.ts +2 -2
  11. package/build/types/services/auth/oidc/loginAttempts/types.d.ts +1 -1
  12. package/build/types/services/auth/oidc/providers/types.d.ts +1 -1
  13. package/build/types/services/data/types.d.ts +5 -5
  14. package/build/types/services/dispatchers/dispatchers/types.d.ts +1 -1
  15. package/build/types/services/events/types.d.ts +4 -4
  16. package/build/types/services/files/types.d.ts +2 -2
  17. package/build/types/services/localizations/types.d.ts +2 -2
  18. package/build/types/services/logs/access/types.d.ts +2 -2
  19. package/build/types/services/mails/types.d.ts +22 -14
  20. package/build/types/services/notifications/types.d.ts +4 -4
  21. package/build/types/services/payments/types.d.ts +4 -4
  22. package/build/types/services/profiles/types.d.ts +2 -2
  23. package/build/types/services/tasks/apiRequests/logs/types.d.ts +1 -1
  24. package/build/types/services/tasks/apiRequests/types.d.ts +1 -1
  25. package/build/types/services/tasks/functions/types.d.ts +145 -1
  26. package/build/types/services/tasks/logs/types.d.ts +1 -1
  27. package/build/types/services/tasks/schedules/types.d.ts +1 -1
  28. package/build/types/services/tasks/types.d.ts +2 -2
  29. package/build/types/services/templatesV2/health.d.ts +9 -0
  30. package/build/types/services/templatesV2/index.d.ts +4 -0
  31. package/build/types/services/templatesV2/templatesV2.d.ts +5 -0
  32. package/build/types/services/templatesV2/types.d.ts +145 -0
  33. package/build/types/services/types.d.ts +4 -1
  34. package/build/types/services/users/activationRequests/types.d.ts +3 -3
  35. package/build/types/services/users/forgotPasswordRequests/types.d.ts +3 -3
  36. package/build/types/services/users/types.d.ts +27 -9
  37. package/build/types/version.d.ts +1 -1
  38. package/package.json +2 -2
package/build/index.mjs CHANGED
@@ -587,6 +587,18 @@ class LocalizationKeyMissingError extends BadRequestError {
587
587
  }
588
588
  class TemplateFillingError extends BadRequestError {
589
589
  }
590
+ class TemplateSyntaxError extends BadRequestError {
591
+ constructor(apiError) {
592
+ super(apiError);
593
+ this.syntaxError = apiError.response.syntaxError;
594
+ }
595
+ }
596
+ class TemplateResolvingError extends BadRequestError {
597
+ constructor(apiError) {
598
+ super(apiError);
599
+ this.resolveError = apiError.response.resolveError;
600
+ }
601
+ }
590
602
  class MissingRequiredFieldsError extends BadRequestError {
591
603
  }
592
604
  class InvalidCurrencyForProductPrice extends BadRequestError {
@@ -887,6 +899,8 @@ const ErrorClassMap = {
887
899
  801: DefaultLocalizationMissingError,
888
900
  1002: LocalizationKeyMissingError,
889
901
  1003: TemplateFillingError,
902
+ 1004: TemplateSyntaxError,
903
+ 1005: TemplateResolvingError,
890
904
  2605: InvalidTokenError,
891
905
  2606: UnauthorizedTokenError,
892
906
  2607: TokenNotDeleteableError,
@@ -955,6 +969,16 @@ var ApiRequestErrorType;
955
969
  ApiRequestErrorType["RESPONSE"] = "response";
956
970
  })(ApiRequestErrorType || (ApiRequestErrorType = {}));
957
971
 
972
+ var FunctionPermissionMode;
973
+ (function (FunctionPermissionMode) {
974
+ /** To execute this function directly the user needs the EXECUTE_TASK_FUNCTION permission */
975
+ FunctionPermissionMode["PERMISSION_REQUIRED"] = "permissionRequired";
976
+ /** Every logged in user can execute this function directly */
977
+ FunctionPermissionMode["ALL_USERS"] = "allUsers";
978
+ /** The function can be executed even by unauthenticated requests */
979
+ FunctionPermissionMode["PUBLIC"] = "public";
980
+ })(FunctionPermissionMode || (FunctionPermissionMode = {}));
981
+
958
982
  var TaskStatus;
959
983
  (function (TaskStatus) {
960
984
  TaskStatus["NEW"] = "new";
@@ -1053,6 +1077,7 @@ var GlobalPermissionName;
1053
1077
  GlobalPermissionName["REMOVE_ROLE_PERMISSION"] = "REMOVE_ROLE_PERMISSION";
1054
1078
  GlobalPermissionName["REMOVE_STAFF"] = "REMOVE_STAFF";
1055
1079
  GlobalPermissionName["RESET_FAILED_LOGIN_ATTEMPTS"] = "RESET_FAILED_LOGIN_ATTEMPTS";
1080
+ GlobalPermissionName["RESOLVE_TEMPLATES"] = "RESOLVE_TEMPLATES";
1056
1081
  GlobalPermissionName["SEND_MAILS"] = "SEND_MAILS";
1057
1082
  GlobalPermissionName["SYNC_PROFILE_GROUPS"] = "SYNC_PROFILE_GROUPS";
1058
1083
  GlobalPermissionName["TRANSFER_PERIOD"] = "TRANSFER_PERIOD";
@@ -1617,6 +1642,7 @@ const FILES_BASE = '/files/v1';
1617
1642
  const TASKS_BASE = '/tasks/v1';
1618
1643
  const CONFIGURATION_BASE = '/configurations/v2';
1619
1644
  const TEMPLATE_BASE = '/templates/v1';
1645
+ const TEMPLATES_V2_BASE = '/templates/v2';
1620
1646
  const MAIL_BASE = '/mail/v1';
1621
1647
  const DISPATCHERS_BASE = '/dispatchers/v1';
1622
1648
  const PAYMENTS_BASE = '/payments/v1';
@@ -3513,11 +3539,7 @@ var comments = (client, httpAuth) => ({
3513
3539
  },
3514
3540
  async findById(id, schemaIdOrName, documentId, options) {
3515
3541
  const rqlWithId = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('id', id).build();
3516
- const res = await this.find(schemaIdOrName, documentId, {
3517
- ...options,
3518
- rql: rqlWithId,
3519
- });
3520
- return res.data[0];
3542
+ return await this.findFirst(schemaIdOrName, documentId, { ...options, rql: rqlWithId });
3521
3543
  },
3522
3544
  async findFirst(schemaIdOrName, documentId, options) {
3523
3545
  const res = await this.find(schemaIdOrName, documentId, options);
@@ -3570,8 +3592,7 @@ var documents = (client, httpAuth) => {
3570
3592
  },
3571
3593
  async findById(schemaIdOrName, documentId, options) {
3572
3594
  const rqlWithId = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('id', documentId).build();
3573
- const res = await this.find(schemaIdOrName, { ...options, rql: rqlWithId });
3574
- return res.data[0];
3595
+ return await this.findFirst(schemaIdOrName, { ...options, rql: rqlWithId });
3575
3596
  },
3576
3597
  async findFirst(schemaIdOrName, options) {
3577
3598
  const res = await this.find(schemaIdOrName, options);
@@ -3698,13 +3719,11 @@ var schemas = (client, httpAuth) => {
3698
3719
  },
3699
3720
  async findById(id, options) {
3700
3721
  const rqlWithId = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('id', id).build();
3701
- const res = await find({ ...options, rql: rqlWithId });
3702
- return res.data[0];
3722
+ return await this.findFirst({ ...options, rql: rqlWithId });
3703
3723
  },
3704
3724
  async findByName(name, options) {
3705
3725
  const rqlWithName = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('name', name).build();
3706
- const res = await find({ ...options, rql: rqlWithName });
3707
- return res.data[0];
3726
+ return await this.findFirst({ ...options, rql: rqlWithName });
3708
3727
  },
3709
3728
  async findFirst(options) {
3710
3729
  const res = await find(options);
@@ -3796,8 +3815,7 @@ var files = (client, httpAuth) => ({
3796
3815
  },
3797
3816
  async findByName(name, options) {
3798
3817
  const rqlWithName = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('name', name).build();
3799
- const res = await this.find({ ...options, rql: rqlWithName });
3800
- return res.data[0];
3818
+ return await this.findFirst({ ...options, rql: rqlWithName });
3801
3819
  },
3802
3820
  async findFirst(options) {
3803
3821
  const res = await this.find(options);
@@ -3982,8 +4000,48 @@ var apiRequests = (client, httpAuth) => {
3982
4000
  };
3983
4001
 
3984
4002
  var functions = (client, httpAuth) => ({
4003
+ async find(options) {
4004
+ const response = await client.get(httpAuth, '/functions/', options);
4005
+ return response.data;
4006
+ },
4007
+ async create(body, options) {
4008
+ const response = await client.post(httpAuth, '/functions/', body, {
4009
+ ...options,
4010
+ customKeys: ['environmentVariables'],
4011
+ });
4012
+ return response.data;
4013
+ },
4014
+ async getByName(name, options) {
4015
+ const response = await client.get(httpAuth, `/functions/${name}`, {
4016
+ ...options,
4017
+ customResponseKeys: ['environmentVariables'],
4018
+ });
4019
+ return response.data;
4020
+ },
4021
+ async update(name, body, options) {
4022
+ const response = await client.put(httpAuth, `/functions/${name}`, body, {
4023
+ ...options,
4024
+ customRequestKeys: ['environmentVariables'],
4025
+ });
4026
+ return response.data;
4027
+ },
4028
+ async delete(name, options) {
4029
+ const response = await client.delete(httpAuth, `/functions/${name}`, options);
4030
+ return response.data;
4031
+ },
4032
+ async enable(name, options) {
4033
+ const response = await client.post(httpAuth, `/functions/${name}/enable`, {}, options);
4034
+ return response.data;
4035
+ },
4036
+ async disable(name, options) {
4037
+ const response = await client.post(httpAuth, `/functions/${name}/disable`, {}, options);
4038
+ return response.data;
4039
+ },
3985
4040
  async execute(functionName, data, options) {
3986
- const response = await client.post(httpAuth, `/functions/${functionName}/execute`, { data }, { ...options, customKeys: ['data', 'result'] });
4041
+ const response = await client.post(httpAuth, `/functions/${functionName}/execute`, { data }, {
4042
+ ...options,
4043
+ customKeys: ['data', 'result'],
4044
+ });
3987
4045
  return response.data;
3988
4046
  },
3989
4047
  });
@@ -4054,8 +4112,7 @@ var tasks = (client, httpAuth) => ({
4054
4112
  },
4055
4113
  async findById(id, options) {
4056
4114
  const rqlWithId = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('id', id).build();
4057
- const res = await this.find({ ...options, rql: rqlWithId });
4058
- return res.data[0];
4115
+ return await this.findFirst({ ...options, rql: rqlWithId });
4059
4116
  },
4060
4117
  async findFirst(options) {
4061
4118
  const res = await this.find(options);
@@ -4230,7 +4287,7 @@ var groupRoles = (client, httpWithAuth) => ({
4230
4287
  },
4231
4288
  });
4232
4289
 
4233
- var health$6 = (userClient, http) => ({
4290
+ var health$7 = (userClient, http) => ({
4234
4291
  /**
4235
4292
  * Perform a health check
4236
4293
  * @returns {boolean} success
@@ -4280,6 +4337,10 @@ var users$1 = (userClient, httpWithAuth, http) => {
4280
4337
  const res = await find(options);
4281
4338
  return res.data[0];
4282
4339
  },
4340
+ async findByEmail(email, options) {
4341
+ const rqlWithEmail = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('email', email).build();
4342
+ return await this.findFirst({ ...options, rql: rqlWithEmail });
4343
+ },
4283
4344
  async removeUsers(rql, options) {
4284
4345
  return (await userClient.delete(httpWithAuth, `/${rql}`, options)).data;
4285
4346
  },
@@ -4427,7 +4488,7 @@ const usersService = (httpWithAuth, http) => {
4427
4488
  basePath: USER_BASE,
4428
4489
  transformRequestData: decamelizeRequestData,
4429
4490
  });
4430
- const healthMethods = health$6(userClient, httpWithAuth);
4491
+ const healthMethods = health$7(userClient, httpWithAuth);
4431
4492
  const usersMethods = users$1(userClient, httpWithAuth, http);
4432
4493
  const groupRolesMethods = groupRoles(userClient, httpWithAuth);
4433
4494
  const globalRolesMethods = globalRoles(userClient, httpWithAuth);
@@ -4557,13 +4618,11 @@ var templates = (client, httpAuth) => ({
4557
4618
  },
4558
4619
  async findById(id, options) {
4559
4620
  const rqlWithId = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('id', id).build();
4560
- const res = await this.find({ ...options, rql: rqlWithId });
4561
- return res.data[0];
4621
+ return await this.findFirst({ ...options, rql: rqlWithId });
4562
4622
  },
4563
4623
  async findByName(name, options) {
4564
4624
  const rqlWithName = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('name', name).build();
4565
- const res = await this.find({ ...options, rql: rqlWithName });
4566
- return res.data[0];
4625
+ return await this.findFirst({ ...options, rql: rqlWithName });
4567
4626
  },
4568
4627
  async findFirst(options) {
4569
4628
  const res = await this.find(options);
@@ -4631,34 +4690,37 @@ var mails = (client, httpAuth) => ({
4631
4690
  return result.status === Results.Success;
4632
4691
  },
4633
4692
  async find(options) {
4634
- return (await client.get(httpAuth, `/${(options === null || options === void 0 ? void 0 : options.rql) || ''}`, {
4693
+ const result = await client.get(httpAuth, `/${(options === null || options === void 0 ? void 0 : options.rql) || ''}`, {
4635
4694
  ...options,
4636
4695
  customResponseKeys: ['data.content'],
4637
- })).data;
4696
+ });
4697
+ return result.data;
4638
4698
  },
4639
4699
  async findById(id, options) {
4640
4700
  const rqlWithId = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('id', id).build();
4641
- const res = await this.find({ ...options, rql: rqlWithId });
4642
- return res.data[0];
4701
+ return await this.findFirst({ ...options, rql: rqlWithId });
4643
4702
  },
4644
4703
  async findFirst(options) {
4645
4704
  const res = await this.find(options);
4646
4705
  return res.data[0];
4647
4706
  },
4648
4707
  async send(requestBody, options) {
4649
- return (await client.post(httpAuth, '/', requestBody, {
4708
+ const result = await client.post(httpAuth, '/', requestBody, {
4650
4709
  ...options,
4651
4710
  customKeys: ['content'],
4652
- })).data;
4711
+ });
4712
+ return result.data;
4653
4713
  },
4654
4714
  async track(trackingHash, options) {
4655
- return (await client.get(httpAuth, `/${trackingHash}/open`, options)).data;
4715
+ const result = await client.get(httpAuth, `/${trackingHash}/open`, options);
4716
+ return result.data;
4656
4717
  },
4657
4718
  async findOutbound(options) {
4658
- return (await client.get(httpAuth, `/queued${(options === null || options === void 0 ? void 0 : options.rql) || ''}`, {
4719
+ const result = await client.get(httpAuth, `/queued${(options === null || options === void 0 ? void 0 : options.rql) || ''}`, {
4659
4720
  ...options,
4660
4721
  customResponseKeys: ['data.templateData.content'],
4661
- })).data;
4722
+ });
4723
+ return result.data;
4662
4724
  },
4663
4725
  });
4664
4726
 
@@ -4808,7 +4870,7 @@ var appStoreSubscriptions = (client, httpAuth) => ({
4808
4870
  },
4809
4871
  });
4810
4872
 
4811
- var health$5 = (client, httpAuth) => ({
4873
+ var health$6 = (client, httpAuth) => ({
4812
4874
  /**
4813
4875
  * Check if the service is available
4814
4876
  * @returns true if service is up and running
@@ -4834,8 +4896,7 @@ var orders = (client, httpAuth) => ({
4834
4896
  },
4835
4897
  async findById(id, options) {
4836
4898
  const rqlWithId = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('id', id).build();
4837
- const res = await this.find({ ...options, rql: rqlWithId });
4838
- return res.data[0];
4899
+ return await this.findFirst({ ...options, rql: rqlWithId });
4839
4900
  },
4840
4901
  async findFirst(options) {
4841
4902
  const res = await this.find(options);
@@ -4934,8 +4995,7 @@ var products = (client, httpAuth) => ({
4934
4995
  },
4935
4996
  async findById(id, options) {
4936
4997
  const rqlWithId = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('id', id).build();
4937
- const res = await this.find({ ...options, rql: rqlWithId });
4938
- return res.data[0];
4998
+ return await this.findFirst({ ...options, rql: rqlWithId });
4939
4999
  },
4940
5000
  async findFirst(options) {
4941
5001
  const res = await this.find(options);
@@ -5014,7 +5074,7 @@ const paymentsService = (httpWithAuth) => {
5014
5074
  basePath: PAYMENTS_BASE,
5015
5075
  });
5016
5076
  return {
5017
- ...health$5(client, httpWithAuth),
5077
+ ...health$6(client, httpWithAuth),
5018
5078
  products: products(client, httpWithAuth),
5019
5079
  orders: orders(client, httpWithAuth),
5020
5080
  subscriptions: subscriptions$1(client, httpWithAuth),
@@ -5036,7 +5096,7 @@ var countries = (client, httpAuth) => ({
5036
5096
  },
5037
5097
  });
5038
5098
 
5039
- var health$4 = (client, http) => ({
5099
+ var health$5 = (client, http) => ({
5040
5100
  /**
5041
5101
  * Perform a health check
5042
5102
  * @returns {boolean} success
@@ -5059,8 +5119,7 @@ var localizations = (client, httpAuth) => ({
5059
5119
  },
5060
5120
  async findByKey(key, options) {
5061
5121
  const rqlWithKey = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('key', key).build();
5062
- const res = await this.find({ ...options, rql: rqlWithKey });
5063
- return res.data[0];
5122
+ return await this.findFirst({ ...options, rql: rqlWithKey });
5064
5123
  },
5065
5124
  async findFirst(options) {
5066
5125
  const res = await this.find(options);
@@ -5089,7 +5148,7 @@ const localizationsService = (httpWithAuth) => {
5089
5148
  basePath: LOCALIZATIONS_BASE,
5090
5149
  });
5091
5150
  return {
5092
- ...health$4(client, httpWithAuth),
5151
+ ...health$5(client, httpWithAuth),
5093
5152
  ...localizations(client, httpWithAuth),
5094
5153
  ...countries(client, httpWithAuth),
5095
5154
  ...languages(client, httpWithAuth),
@@ -5114,7 +5173,7 @@ var groups = (client, httpAuth) => ({
5114
5173
  },
5115
5174
  });
5116
5175
 
5117
- var health$3 = (client, httpAuth) => ({
5176
+ var health$4 = (client, httpAuth) => ({
5118
5177
  /**
5119
5178
  * Perform a health check for profiles service
5120
5179
  * @returns {boolean} success
@@ -5168,8 +5227,7 @@ var profiles = (client, httpAuth) => ({
5168
5227
  },
5169
5228
  async findById(id, options) {
5170
5229
  const rqlWithId = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('id', id).build();
5171
- const res = await this.find({ ...options, rql: rqlWithId });
5172
- return res.data[0];
5230
+ return await this.findFirst({ ...options, rql: rqlWithId });
5173
5231
  },
5174
5232
  async findFirst(options) {
5175
5233
  const res = await this.find(options);
@@ -5204,14 +5262,14 @@ const profilesService = (httpWithAuth) => {
5204
5262
  basePath: PROFILES_BASE,
5205
5263
  });
5206
5264
  return {
5207
- ...health$3(client, httpWithAuth),
5265
+ ...health$4(client, httpWithAuth),
5208
5266
  ...profiles(client, httpWithAuth),
5209
5267
  groups: groups(client, httpWithAuth),
5210
5268
  logs: logs(client, httpWithAuth),
5211
5269
  };
5212
5270
  };
5213
5271
 
5214
- var health$2 = (client, http) => ({
5272
+ var health$3 = (client, http) => ({
5215
5273
  /**
5216
5274
  * Perform a health check
5217
5275
  * @returns {boolean} success
@@ -5252,8 +5310,7 @@ var notifications = (client, httpAuth) => {
5252
5310
  },
5253
5311
  async findById(id, options) {
5254
5312
  const rqlWithId = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('id', id).build();
5255
- const res = await this.find({ ...options, rql: rqlWithId });
5256
- return res.data[0];
5313
+ return await this.findFirst({ ...options, rql: rqlWithId });
5257
5314
  },
5258
5315
  async findFirst(options) {
5259
5316
  const res = await this.find(options);
@@ -5277,8 +5334,7 @@ var settings = (client, httpAuth) => ({
5277
5334
  },
5278
5335
  async findById(id, options) {
5279
5336
  const rqlWithId = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('id', id).build();
5280
- const res = await this.find({ ...options, rql: rqlWithId });
5281
- return res.data[0];
5337
+ return await this.findFirst({ ...options, rql: rqlWithId });
5282
5338
  },
5283
5339
  async findFirst(options) {
5284
5340
  const res = await this.find(options);
@@ -5298,13 +5354,13 @@ const notificationsService = (httpWithAuth) => {
5298
5354
  transformRequestData: decamelizeRequestData,
5299
5355
  });
5300
5356
  return {
5301
- ...health$2(client, httpWithAuth),
5357
+ ...health$3(client, httpWithAuth),
5302
5358
  ...notifications(client, httpWithAuth),
5303
5359
  settings: settings(client, httpWithAuth),
5304
5360
  };
5305
5361
  };
5306
5362
 
5307
- var health$1 = (client, http) => ({
5363
+ var health$2 = (client, http) => ({
5308
5364
  /**
5309
5365
  * Perform a health check
5310
5366
  * @returns {boolean} success
@@ -5349,8 +5405,7 @@ var notificationsV2 = (client, httpWithAuth) => {
5349
5405
  },
5350
5406
  async findById(notificationId, options) {
5351
5407
  const rqlWithNotificationId = rqlBuilder().eq('id', notificationId).build();
5352
- const result = await find({ ...options, rql: rqlWithNotificationId });
5353
- return result.data[0];
5408
+ return await this.findFirst({ ...options, rql: rqlWithNotificationId });
5354
5409
  },
5355
5410
  };
5356
5411
  };
@@ -5400,7 +5455,7 @@ const notificationsV2Service = (httpWithAuth) => {
5400
5455
  basePath: NOTIFICATIONS_V2_BASE,
5401
5456
  });
5402
5457
  return {
5403
- ...health$1(client, httpWithAuth),
5458
+ ...health$2(client, httpWithAuth),
5404
5459
  ...notificationsV2(client, httpWithAuth),
5405
5460
  userSettings: notificationV2UserSettings(client, httpWithAuth),
5406
5461
  };
@@ -5412,8 +5467,7 @@ var events = (client, httpAuth) => ({
5412
5467
  },
5413
5468
  async findById(id, options) {
5414
5469
  const rqlWithId = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('id', id).build();
5415
- const res = await this.find({ ...options, rql: rqlWithId });
5416
- return res.data[0];
5470
+ return await this.findFirst({ ...options, rql: rqlWithId });
5417
5471
  },
5418
5472
  async findFirst(options) {
5419
5473
  const res = await this.find(options);
@@ -5429,7 +5483,7 @@ var events = (client, httpAuth) => ({
5429
5483
  },
5430
5484
  });
5431
5485
 
5432
- var health = (client, http) => ({
5486
+ var health$1 = (client, http) => ({
5433
5487
  /**
5434
5488
  * Perform a health check
5435
5489
  * @returns {boolean} success
@@ -5447,8 +5501,7 @@ var subscriptions = (client, httpAuth) => ({
5447
5501
  },
5448
5502
  async findById(id, options) {
5449
5503
  const rqlWithId = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('id', id).build();
5450
- const res = await this.find({ ...options, rql: rqlWithId });
5451
- return res.data[0];
5504
+ return await this.findFirst({ ...options, rql: rqlWithId });
5452
5505
  },
5453
5506
  async findFirst(options) {
5454
5507
  const res = await this.find(options);
@@ -5466,7 +5519,7 @@ const eventsService = (httpWithAuth) => {
5466
5519
  transformRequestData: decamelizeRequestData,
5467
5520
  });
5468
5521
  return {
5469
- ...health(client, httpWithAuth),
5522
+ ...health$1(client, httpWithAuth),
5470
5523
  ...events(client, httpWithAuth),
5471
5524
  subscriptions: subscriptions(client, httpWithAuth),
5472
5525
  };
@@ -5498,7 +5551,87 @@ const logsService = (httpWithAuth) => {
5498
5551
  };
5499
5552
  };
5500
5553
 
5501
- const version = '8.9.0-dev-122-b59ec47';
5554
+ var health = (client, http) => ({
5555
+ /**
5556
+ * Perform a health check
5557
+ * @returns {boolean} success
5558
+ */
5559
+ async health() {
5560
+ const result = await client.get(http, '/health');
5561
+ return result.status === Results.Success;
5562
+ },
5563
+ });
5564
+
5565
+ var templatesV2 = (client, httpWithAuth) => {
5566
+ async function find(options) {
5567
+ const result = await client.get(httpWithAuth, `/${(options === null || options === void 0 ? void 0 : options.rql) || ''}`, {
5568
+ ...options,
5569
+ customResponseKeys: ['data.properties', 'data.outputs'],
5570
+ });
5571
+ return result.data;
5572
+ }
5573
+ return {
5574
+ async create(requestBody, options) {
5575
+ const result = (await client.post(httpWithAuth, '/', requestBody, {
5576
+ ...options,
5577
+ customKeys: ['properties', 'outputs'],
5578
+ }));
5579
+ return result.data;
5580
+ },
5581
+ async update(templateId, requestBody, options) {
5582
+ const result = (await client.put(httpWithAuth, `/${templateId}`, requestBody, {
5583
+ ...options,
5584
+ customKeys: ['properties', 'outputs'],
5585
+ }));
5586
+ return result.data;
5587
+ },
5588
+ async remove(templateId, options) {
5589
+ const result = (await client.delete(httpWithAuth, `/${templateId}`, options));
5590
+ return result.data;
5591
+ },
5592
+ async resolve(templateId, requestBody, options) {
5593
+ const result = (await client.post(httpWithAuth, `/${templateId}/resolve`, requestBody, {
5594
+ ...options,
5595
+ customRequestKeys: ['data'],
5596
+ customResponseKeys: ['*'],
5597
+ }));
5598
+ return result.data;
5599
+ },
5600
+ async find(options) {
5601
+ const result = await find(options);
5602
+ return addPagersFn(find, options, result);
5603
+ },
5604
+ async findAll(options) {
5605
+ return findAllGeneric(find, options);
5606
+ },
5607
+ async findById(templateId, options) {
5608
+ const rqlWithId = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('id', templateId).build();
5609
+ const result = await find({ ...options, rql: rqlWithId });
5610
+ return result.data[0];
5611
+ },
5612
+ async findByName(name, options) {
5613
+ const rqlWithName = rqlBuilder(options === null || options === void 0 ? void 0 : options.rql).eq('name', name).build();
5614
+ const result = await find({ ...options, rql: rqlWithName });
5615
+ return result.data[0];
5616
+ },
5617
+ async findFirst(options) {
5618
+ const result = await find(options);
5619
+ return result.data[0];
5620
+ },
5621
+ };
5622
+ };
5623
+
5624
+ const templatesV2Service = (httpWithAuth) => {
5625
+ const client = httpClient({
5626
+ basePath: TEMPLATES_V2_BASE,
5627
+ });
5628
+ return {
5629
+ ...health(client, httpWithAuth),
5630
+ ...templatesV2(client, httpWithAuth),
5631
+ };
5632
+ };
5633
+
5634
+ const version = '8.9.0-feat-134-c0f5b9d';
5502
5635
 
5503
5636
  /**
5504
5637
  * Create ExtraHorizon client.
@@ -5531,6 +5664,7 @@ function createClient(rawConfig) {
5531
5664
  files: filesService(httpWithAuth),
5532
5665
  tasks: tasksService(httpWithAuth),
5533
5666
  templates: templatesService(httpWithAuth),
5667
+ templatesV2: templatesV2Service(httpWithAuth),
5534
5668
  mails: mailsService(httpWithAuth),
5535
5669
  configurations: configurationsService(httpWithAuth),
5536
5670
  dispatchers: dispatchersService(httpWithAuth),
@@ -5677,4 +5811,4 @@ const parseStoredCredentials = (fileContent) => exhCredentialsDecoder(fileConten
5677
5811
  .filter(line => line.length === 2)
5678
5812
  .reduce((memo, [key, value]) => ({ ...memo, [key]: value }), {}));
5679
5813
 
5680
- export { AccessTokenExpiredError, AccessTokenUnknownError, ActionType, ActivationRequestLimitError, ActivationRequestTimeoutError, ActivationUnknownError, AlreadyActivatedError, ApiError, ApiFunctionRequestMethod, ApiRequestErrorType, AppStoreTransactionAlreadyLinked, ApplicationNotAuthenticatedError, ApplicationType, ApplicationUnknownError, AuthenticationError, AuthorizationCodeExpiredError, AuthorizationUnknownError, BadGatewayServerError, BadRequestError, BodyFormatError, CallbackNotValidError, Comorbidities, DefaultLocalizationMissingError, DisabledForOidcUsersError, DuplicateRequestError, EmailUnknownError, EmailUsedError, EmptyBodyError, ErrorClassMap, FieldFormatError, FieldType, FileTooLargeError, FirebaseConnectionError, FirebaseInvalidPlatformDataError, ForbiddenError, ForgotPasswordRequestLimitError, ForgotPasswordRequestTimeoutError, Gender, GlobalPermissionName, IDFormatError, IllegalArgumentError, IllegalStateError, Impediments, IncorrectPinCodeError, InvalidClientError, InvalidCurrencyForProductPrice, InvalidGrantError, InvalidMfaCodeError, InvalidMfaTokenError, InvalidNonceError, InvalidPKCEError, InvalidPresenceTokenError, InvalidReceiptDataError, InvalidRequestError, InvalidTokenError, JSONSchemaType, LocalizationKeyMissingError, LockedDocumentError, LoginAttemptStatus, LoginFreezeError, LoginTimeoutError, MedicationFrequency, MedicationUnit, MfaReattemptDelayError, MfaRequiredError, MissingPKCEVerifierError, MissingRequiredFieldsError, NewMFARequiredError, NewPasswordHashUnknownError, NewPasswordPinCodeUnknownError, NoConfiguredAppStoreProduct, NoConfiguredPlayStoreProduct, NoMatchingPlayStoreLinkedSubscription, NoPermissionError, NotActivatedError, NotEnoughMfaMethodsError, NotFoundError, OAuth2ClientIdError, OAuth2ClientSecretError, OAuth2ErrorClassMap, OAuth2LoginError, OAuth2MissingClientCredentialsError, OauthKeyError, OauthSignatureError, OauthTokenError, ObjectMaxBytesOptionType, ObjectMinBytesOptionType, OidcIdTokenError, OidcInvalidAuthorizationCodeError, OidcProviderResponseError, OrderSchemaStatus, PasswordError, PaymentIntentCreationSchemaPaymentMethodType, PaymentIntentCreationSchemaSetupPaymentMethodReuse, PinCodesNotEnabledError, PlayStoreTransactionAlreadyLinked, ProfileActivity, ProfileAlreadyExistsError, QueuedMailStatus, RefreshTokenExpiredError, RefreshTokenUnknownError, RemoveFieldError, RequestAbortedError, ResourceAlreadyExistsError, ResourceUnknownError, Results, ServerError, ServiceUnavailableError, StatusInUseError, StripePaymentMethodError, StripeRequestError, SubscriptionEntitlementSource, SubscriptionEntitlementStatus, SubscriptionEntitlementStatusCategory, SubscriptionEventSource, SubscriptionEventType, SupportedLanguageCodes, TaskStatus, TemplateFillingError, TokenNotDeleteableError, TokenPermission, TooManyFailedAttemptsError, UnauthorizedClientError, UnauthorizedError, UnauthorizedTokenError, UnknownReceiptTransactionError, UnsupportedGrantError, UnsupportedGrantTypeError, UnsupportedResponseTypeError, UserNotAuthenticatedError, createClient, createOAuth1Client, createOAuth2Client, createProxyClient, findAllGeneric, findAllIterator, getMockSdkOAuth2 as getMockSdk, getMockSdkOAuth1, getMockSdkOAuth2, getMockSdkProxy, parseGlobalPermissions, parseStoredCredentials, recursiveMap, rqlBuilder, rqlParser };
5814
+ export { AccessTokenExpiredError, AccessTokenUnknownError, ActionType, ActivationRequestLimitError, ActivationRequestTimeoutError, ActivationUnknownError, AlreadyActivatedError, ApiError, ApiFunctionRequestMethod, ApiRequestErrorType, AppStoreTransactionAlreadyLinked, ApplicationNotAuthenticatedError, ApplicationType, ApplicationUnknownError, AuthenticationError, AuthorizationCodeExpiredError, AuthorizationUnknownError, BadGatewayServerError, BadRequestError, BodyFormatError, CallbackNotValidError, Comorbidities, DefaultLocalizationMissingError, DisabledForOidcUsersError, DuplicateRequestError, EmailUnknownError, EmailUsedError, EmptyBodyError, ErrorClassMap, FieldFormatError, FieldType, FileTooLargeError, FirebaseConnectionError, FirebaseInvalidPlatformDataError, ForbiddenError, ForgotPasswordRequestLimitError, ForgotPasswordRequestTimeoutError, FunctionPermissionMode, Gender, GlobalPermissionName, IDFormatError, IllegalArgumentError, IllegalStateError, Impediments, IncorrectPinCodeError, InvalidClientError, InvalidCurrencyForProductPrice, InvalidGrantError, InvalidMfaCodeError, InvalidMfaTokenError, InvalidNonceError, InvalidPKCEError, InvalidPresenceTokenError, InvalidReceiptDataError, InvalidRequestError, InvalidTokenError, JSONSchemaType, LocalizationKeyMissingError, LockedDocumentError, LoginAttemptStatus, LoginFreezeError, LoginTimeoutError, MedicationFrequency, MedicationUnit, MfaReattemptDelayError, MfaRequiredError, MissingPKCEVerifierError, MissingRequiredFieldsError, NewMFARequiredError, NewPasswordHashUnknownError, NewPasswordPinCodeUnknownError, NoConfiguredAppStoreProduct, NoConfiguredPlayStoreProduct, NoMatchingPlayStoreLinkedSubscription, NoPermissionError, NotActivatedError, NotEnoughMfaMethodsError, NotFoundError, OAuth2ClientIdError, OAuth2ClientSecretError, OAuth2ErrorClassMap, OAuth2LoginError, OAuth2MissingClientCredentialsError, OauthKeyError, OauthSignatureError, OauthTokenError, ObjectMaxBytesOptionType, ObjectMinBytesOptionType, OidcIdTokenError, OidcInvalidAuthorizationCodeError, OidcProviderResponseError, OrderSchemaStatus, PasswordError, PaymentIntentCreationSchemaPaymentMethodType, PaymentIntentCreationSchemaSetupPaymentMethodReuse, PinCodesNotEnabledError, PlayStoreTransactionAlreadyLinked, ProfileActivity, ProfileAlreadyExistsError, QueuedMailStatus, RefreshTokenExpiredError, RefreshTokenUnknownError, RemoveFieldError, RequestAbortedError, ResourceAlreadyExistsError, ResourceUnknownError, Results, ServerError, ServiceUnavailableError, StatusInUseError, StripePaymentMethodError, StripeRequestError, SubscriptionEntitlementSource, SubscriptionEntitlementStatus, SubscriptionEntitlementStatusCategory, SubscriptionEventSource, SubscriptionEventType, SupportedLanguageCodes, TaskStatus, TemplateFillingError, TemplateResolvingError, TemplateSyntaxError, TokenNotDeleteableError, TokenPermission, TooManyFailedAttemptsError, UnauthorizedClientError, UnauthorizedError, UnauthorizedTokenError, UnknownReceiptTransactionError, UnsupportedGrantError, UnsupportedGrantTypeError, UnsupportedResponseTypeError, UserNotAuthenticatedError, createClient, createOAuth1Client, createOAuth2Client, createProxyClient, findAllGeneric, findAllIterator, getMockSdkOAuth2 as getMockSdk, getMockSdkOAuth1, getMockSdkOAuth2, getMockSdkProxy, parseGlobalPermissions, parseStoredCredentials, recursiveMap, rqlBuilder, rqlParser };
@@ -1,5 +1,6 @@
1
1
  import { AuthHttpClient, OAuth1HttpClient, OAuth2HttpClient, ProxyInstance } from './http/types';
2
2
  import { authService, configurationsService, dataService, dispatchersService, eventsService, filesService, localizationsService, logsService, mailsService, notificationsService, notificationsV2Service, paymentsService, profilesService, tasksService, templatesService, usersService } from './services';
3
+ import { templatesV2Service } from './services/templatesV2';
3
4
  import { ClientParams, ParamsOauth1, ParamsOauth2, ParamsProxy } from './types';
4
5
  export interface Client<T extends ClientParams> {
5
6
  raw: AuthHttpClient;
@@ -8,6 +9,11 @@ export interface Client<T extends ClientParams> {
8
9
  * @see https://swagger.extrahorizon.com/listing/?service=templates-service&redirectToVersion=1
9
10
  */
10
11
  templates: ReturnType<typeof templatesService>;
12
+ /**
13
+ * The template service manages templates used to build emails. It can be used to retrieve, create, update or delete templates as well as resolving them.
14
+ * @see https://swagger.extrahorizon.com/listing/?service=templates-service&redirectToVersion=2
15
+ */
16
+ templatesV2: ReturnType<typeof templatesV2Service>;
11
17
  /**
12
18
  * Provides mail functionality for other services.
13
19
  * @see https://swagger.extrahorizon.com/listing/?service=mail-service&redirectToVersion=1
@@ -5,6 +5,7 @@ export declare const FILES_BASE = "/files/v1";
5
5
  export declare const TASKS_BASE = "/tasks/v1";
6
6
  export declare const CONFIGURATION_BASE = "/configurations/v2";
7
7
  export declare const TEMPLATE_BASE = "/templates/v1";
8
+ export declare const TEMPLATES_V2_BASE = "/templates/v2";
8
9
  export declare const MAIL_BASE = "/mail/v1";
9
10
  export declare const DISPATCHERS_BASE = "/dispatchers/v1";
10
11
  export declare const PAYMENTS_BASE = "/payments/v1";
@@ -1,3 +1,4 @@
1
+ import { TemplatesV2ErrorInfo } from './services/templatesV2/types';
1
2
  import { MfaMethod, NotificationV2Error } from './types';
2
3
  declare type Method = 'get' | 'GET' | 'delete' | 'DELETE' | 'head' | 'HEAD' | 'options' | 'OPTIONS' | 'post' | 'POST' | 'put' | 'PUT' | 'patch' | 'PATCH';
3
4
  interface RequestConfig {
@@ -101,6 +102,14 @@ export declare class LocalizationKeyMissingError extends BadRequestError {
101
102
  }
102
103
  export declare class TemplateFillingError extends BadRequestError {
103
104
  }
105
+ export declare class TemplateSyntaxError extends BadRequestError {
106
+ syntaxError: TemplatesV2ErrorInfo;
107
+ constructor(apiError: ApiError);
108
+ }
109
+ export declare class TemplateResolvingError extends BadRequestError {
110
+ resolveError: TemplatesV2ErrorInfo;
111
+ constructor(apiError: ApiError);
112
+ }
104
113
  export declare class MissingRequiredFieldsError extends BadRequestError {
105
114
  }
106
115
  export declare class InvalidCurrencyForProductPrice extends BadRequestError {
@@ -324,6 +333,8 @@ export declare const ErrorClassMap: {
324
333
  801: typeof DefaultLocalizationMissingError;
325
334
  1002: typeof LocalizationKeyMissingError;
326
335
  1003: typeof TemplateFillingError;
336
+ 1004: typeof TemplateSyntaxError;
337
+ 1005: typeof TemplateResolvingError;
327
338
  2605: typeof InvalidTokenError;
328
339
  2606: typeof UnauthorizedTokenError;
329
340
  2607: typeof TokenNotDeleteableError;