@learncard/helpers 1.0.20 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -105,6 +105,7 @@ var require_types_cjs_development = __commonJS({
105
105
  LCNNotificationTypeEnumValidator: () => LCNNotificationTypeEnumValidator,
106
106
  LCNNotificationValidator: () => LCNNotificationValidator,
107
107
  LCNProfileConnectionStatusEnum: () => LCNProfileConnectionStatusEnum,
108
+ LCNProfileDisplayValidator: () => LCNProfileDisplayValidator,
108
109
  LCNProfileQueryValidator: () => LCNProfileQueryValidator,
109
110
  LCNProfileValidator: () => LCNProfileValidator,
110
111
  LCNSigningAuthorityForUserValidator: () => LCNSigningAuthorityForUserValidator,
@@ -3910,6 +3911,19 @@ var require_types_cjs_development = __commonJS({
3910
3911
  })
3911
3912
  );
3912
3913
  var StringQuery = mod.string().or(mod.object({ $in: mod.string().array() })).or(mod.object({ $regex: RegExpValidator }));
3914
+ var LCNProfileDisplayValidator = mod.object({
3915
+ backgroundColor: mod.string().optional(),
3916
+ backgroundImage: mod.string().optional(),
3917
+ fadeBackgroundImage: mod.boolean().optional(),
3918
+ repeatBackgroundImage: mod.boolean().optional(),
3919
+ fontColor: mod.string().optional(),
3920
+ accentColor: mod.string().optional(),
3921
+ accentFontColor: mod.string().optional(),
3922
+ idBackgroundImage: mod.string().optional(),
3923
+ fadeIdBackgroundImage: mod.boolean().optional(),
3924
+ idBackgroundColor: mod.string().optional(),
3925
+ repeatIdBackgroundImage: mod.boolean().optional()
3926
+ });
3913
3927
  var LCNProfileValidator = mod.object({
3914
3928
  profileId: mod.string().min(3).max(40),
3915
3929
  displayName: mod.string().default(""),
@@ -3922,7 +3936,8 @@ var require_types_cjs_development = __commonJS({
3922
3936
  websiteLink: mod.string().optional(),
3923
3937
  isServiceProfile: mod.boolean().default(false).optional(),
3924
3938
  type: mod.string().optional(),
3925
- notificationsWebhook: mod.string().url().startsWith("http").optional()
3939
+ notificationsWebhook: mod.string().url().startsWith("http").optional(),
3940
+ display: LCNProfileDisplayValidator.optional()
3926
3941
  });
3927
3942
  var LCNProfileQueryValidator = mod.object({
3928
3943
  profileId: StringQuery,
@@ -3989,7 +4004,8 @@ var require_types_cjs_development = __commonJS({
3989
4004
  var BoostRecipientValidator = mod.object({
3990
4005
  to: LCNProfileValidator,
3991
4006
  from: mod.string(),
3992
- received: mod.string().optional()
4007
+ received: mod.string().optional(),
4008
+ uri: mod.string().optional()
3993
4009
  });
3994
4010
  var PaginatedBoostRecipientsValidator = PaginationResponseValidator.extend({
3995
4011
  records: BoostRecipientValidator.array()
@@ -4190,6 +4206,7 @@ var require_dist = __commonJS({
4190
4206
  // src/index.ts
4191
4207
  var src_exports = {};
4192
4208
  __export(src_exports, {
4209
+ RegExpTransformer: () => RegExpTransformer,
4193
4210
  isEncrypted: () => isEncrypted,
4194
4211
  isHex: () => isHex
4195
4212
  });
@@ -4199,3 +4216,30 @@ var isHex = /* @__PURE__ */ __name((str) => /^[0-9a-f]+$/i.test(str), "isHex");
4199
4216
  var isEncrypted = /* @__PURE__ */ __name((item) => {
4200
4217
  return import_types.JWEValidator.safeParse(item).success;
4201
4218
  }, "isEncrypted");
4219
+ var RegExpTransformer = {
4220
+ serialize(object) {
4221
+ return JSON.stringify(object, (_key, value) => {
4222
+ if (value instanceof RegExp)
4223
+ return value.toString();
4224
+ return value;
4225
+ });
4226
+ },
4227
+ deserialize(object) {
4228
+ if (typeof object !== "string")
4229
+ return object;
4230
+ return JSON.parse(object, (_key, value) => {
4231
+ if (typeof value === "string") {
4232
+ const match = value.match(/^\/(.*)\/([gimsuy]*)$/);
4233
+ if (match) {
4234
+ try {
4235
+ return new RegExp(match[1], match[2]);
4236
+ } catch (error) {
4237
+ console.warn(`Failed to parse RegExp: ${error}`);
4238
+ return value;
4239
+ }
4240
+ }
4241
+ }
4242
+ return value;
4243
+ });
4244
+ }
4245
+ };