@learncard/helpers 1.0.19 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/helpers.cjs.development.js +70 -3
- package/dist/helpers.cjs.development.js.map +2 -2
- package/dist/helpers.cjs.production.min.js +1 -1
- package/dist/helpers.cjs.production.min.js.map +3 -3
- package/dist/helpers.d.ts +6 -0
- package/dist/helpers.esm.js +70 -3
- package/dist/helpers.esm.js.map +2 -2
- package/package.json +3 -2
@@ -105,6 +105,7 @@ var require_types_cjs_development = __commonJS({
|
|
105
105
|
LCNNotificationTypeEnumValidator: () => LCNNotificationTypeEnumValidator,
|
106
106
|
LCNNotificationValidator: () => LCNNotificationValidator,
|
107
107
|
LCNProfileConnectionStatusEnum: () => LCNProfileConnectionStatusEnum,
|
108
|
+
LCNProfileQueryValidator: () => LCNProfileQueryValidator,
|
108
109
|
LCNProfileValidator: () => LCNProfileValidator,
|
109
110
|
LCNSigningAuthorityForUserValidator: () => LCNSigningAuthorityForUserValidator,
|
110
111
|
LCNSigningAuthorityValidator: () => LCNSigningAuthorityValidator,
|
@@ -130,7 +131,6 @@ var require_types_cjs_development = __commonJS({
|
|
130
131
|
RubricCriterionValidator: () => RubricCriterionValidator,
|
131
132
|
SentCredentialInfoValidator: () => SentCredentialInfoValidator,
|
132
133
|
ServiceValidator: () => ServiceValidator,
|
133
|
-
StringQuery: () => StringQuery,
|
134
134
|
UnsignedAchievementCredentialValidator: () => UnsignedAchievementCredentialValidator,
|
135
135
|
UnsignedVCValidator: () => UnsignedVCValidator,
|
136
136
|
UnsignedVPValidator: () => UnsignedVPValidator,
|
@@ -3881,6 +3881,35 @@ var require_types_cjs_development = __commonJS({
|
|
3881
3881
|
var PaginatedEncryptedCredentialRecordsValidator = PaginationResponseValidator.extend({
|
3882
3882
|
records: EncryptedCredentialRecordValidator.array()
|
3883
3883
|
});
|
3884
|
+
var parseRegexString = /* @__PURE__ */ __name2((regexStr) => {
|
3885
|
+
const match = regexStr.match(/^\/(.*)\/([gimsuy]*)$/);
|
3886
|
+
if (!match)
|
3887
|
+
throw new Error("Invalid RegExp string format");
|
3888
|
+
return { pattern: match[1], flags: match[2] };
|
3889
|
+
}, "parseRegexString");
|
3890
|
+
var RegExpValidator = mod.instanceof(RegExp).or(
|
3891
|
+
mod.string().refine(
|
3892
|
+
(str) => {
|
3893
|
+
try {
|
3894
|
+
parseRegexString(str);
|
3895
|
+
return true;
|
3896
|
+
} catch (e) {
|
3897
|
+
return false;
|
3898
|
+
}
|
3899
|
+
},
|
3900
|
+
{
|
3901
|
+
message: "Invalid RegExp string format. Must be in format '/pattern/flags'"
|
3902
|
+
}
|
3903
|
+
).transform((str) => {
|
3904
|
+
const { pattern, flags } = parseRegexString(str);
|
3905
|
+
try {
|
3906
|
+
return new RegExp(pattern, flags);
|
3907
|
+
} catch (error) {
|
3908
|
+
throw new Error(`Invalid RegExp: ${error.message}`);
|
3909
|
+
}
|
3910
|
+
})
|
3911
|
+
);
|
3912
|
+
var StringQuery = mod.string().or(mod.object({ $in: mod.string().array() })).or(mod.object({ $regex: RegExpValidator }));
|
3884
3913
|
var LCNProfileValidator = mod.object({
|
3885
3914
|
profileId: mod.string().min(3).max(40),
|
3886
3915
|
displayName: mod.string().default(""),
|
@@ -3895,6 +3924,16 @@ var require_types_cjs_development = __commonJS({
|
|
3895
3924
|
type: mod.string().optional(),
|
3896
3925
|
notificationsWebhook: mod.string().url().startsWith("http").optional()
|
3897
3926
|
});
|
3927
|
+
var LCNProfileQueryValidator = mod.object({
|
3928
|
+
profileId: StringQuery,
|
3929
|
+
displayName: StringQuery,
|
3930
|
+
shortBio: StringQuery,
|
3931
|
+
bio: StringQuery,
|
3932
|
+
email: StringQuery,
|
3933
|
+
websiteLink: StringQuery,
|
3934
|
+
isServiceProfile: mod.boolean(),
|
3935
|
+
type: StringQuery
|
3936
|
+
}).partial();
|
3898
3937
|
var PaginatedLCNProfilesValidator = PaginationResponseValidator.extend({
|
3899
3938
|
records: LCNProfileValidator.array()
|
3900
3939
|
});
|
@@ -3935,7 +3974,6 @@ var require_types_cjs_development = __commonJS({
|
|
3935
3974
|
meta: mod.record(mod.any()).optional(),
|
3936
3975
|
claimPermissions: BoostPermissionsValidator.optional()
|
3937
3976
|
});
|
3938
|
-
var StringQuery = mod.string().or(mod.object({ $in: mod.string().array() })).or(mod.object({ $regex: mod.instanceof(RegExp) }));
|
3939
3977
|
var BoostQueryValidator = mod.object({
|
3940
3978
|
uri: StringQuery,
|
3941
3979
|
name: StringQuery,
|
@@ -3951,7 +3989,8 @@ var require_types_cjs_development = __commonJS({
|
|
3951
3989
|
var BoostRecipientValidator = mod.object({
|
3952
3990
|
to: LCNProfileValidator,
|
3953
3991
|
from: mod.string(),
|
3954
|
-
received: mod.string().optional()
|
3992
|
+
received: mod.string().optional(),
|
3993
|
+
uri: mod.string().optional()
|
3955
3994
|
});
|
3956
3995
|
var PaginatedBoostRecipientsValidator = PaginationResponseValidator.extend({
|
3957
3996
|
records: BoostRecipientValidator.array()
|
@@ -4152,6 +4191,7 @@ var require_dist = __commonJS({
|
|
4152
4191
|
// src/index.ts
|
4153
4192
|
var src_exports = {};
|
4154
4193
|
__export(src_exports, {
|
4194
|
+
RegExpTransformer: () => RegExpTransformer,
|
4155
4195
|
isEncrypted: () => isEncrypted,
|
4156
4196
|
isHex: () => isHex
|
4157
4197
|
});
|
@@ -4161,3 +4201,30 @@ var isHex = /* @__PURE__ */ __name((str) => /^[0-9a-f]+$/i.test(str), "isHex");
|
|
4161
4201
|
var isEncrypted = /* @__PURE__ */ __name((item) => {
|
4162
4202
|
return import_types.JWEValidator.safeParse(item).success;
|
4163
4203
|
}, "isEncrypted");
|
4204
|
+
var RegExpTransformer = {
|
4205
|
+
serialize(object) {
|
4206
|
+
return JSON.stringify(object, (_key, value) => {
|
4207
|
+
if (value instanceof RegExp)
|
4208
|
+
return value.toString();
|
4209
|
+
return value;
|
4210
|
+
});
|
4211
|
+
},
|
4212
|
+
deserialize(object) {
|
4213
|
+
if (typeof object !== "string")
|
4214
|
+
return object;
|
4215
|
+
return JSON.parse(object, (_key, value) => {
|
4216
|
+
if (typeof value === "string") {
|
4217
|
+
const match = value.match(/^\/(.*)\/([gimsuy]*)$/);
|
4218
|
+
if (match) {
|
4219
|
+
try {
|
4220
|
+
return new RegExp(match[1], match[2]);
|
4221
|
+
} catch (error) {
|
4222
|
+
console.warn(`Failed to parse RegExp: ${error}`);
|
4223
|
+
return value;
|
4224
|
+
}
|
4225
|
+
}
|
4226
|
+
}
|
4227
|
+
return value;
|
4228
|
+
});
|
4229
|
+
}
|
4230
|
+
};
|