@singi-labs/sifa-sdk 0.4.0 → 0.5.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.
- package/dist/index.cjs +189 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +165 -4
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.cjs +191 -0
- package/dist/schemas/index.cjs.map +1 -0
- package/dist/schemas/index.d.cts +294 -0
- package/dist/schemas/index.d.ts +294 -0
- package/dist/schemas/index.js +165 -0
- package/dist/schemas/index.js.map +1 -0
- package/package.json +14 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
3
5
|
// src/taxonomy/continents.ts
|
|
4
6
|
var CONTINENTS = [
|
|
5
7
|
{ code: "AF", name: "Africa" },
|
|
@@ -780,8 +782,9 @@ function sanitizeHandleInput(raw) {
|
|
|
780
782
|
// src/format/location-utils.ts
|
|
781
783
|
function formatLocation(loc) {
|
|
782
784
|
if (!loc) return "";
|
|
783
|
-
const
|
|
784
|
-
|
|
785
|
+
const locality = loc.locality ?? loc.city;
|
|
786
|
+
const parts = [locality, loc.region, loc.country].filter(Boolean);
|
|
787
|
+
if (loc.postalCode && !locality) {
|
|
785
788
|
return `${loc.postalCode}, ${loc.country}`;
|
|
786
789
|
}
|
|
787
790
|
return parts.join(", ");
|
|
@@ -925,25 +928,203 @@ function contrastRatio(color1, color2) {
|
|
|
925
928
|
function meetsContrastAA(foreground, background) {
|
|
926
929
|
return contrastRatio(foreground, background) >= 4.5;
|
|
927
930
|
}
|
|
931
|
+
function maxGraphemes(max) {
|
|
932
|
+
return (value) => {
|
|
933
|
+
const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
934
|
+
let count = 0;
|
|
935
|
+
for (const _ of segmenter.segment(value)) {
|
|
936
|
+
count++;
|
|
937
|
+
if (count > max) return false;
|
|
938
|
+
}
|
|
939
|
+
return true;
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
var didSchema = zod.z.string().regex(/^did:[a-z]+:[a-zA-Z0-9._:%-]+$/, "Invalid DID");
|
|
943
|
+
var datetimeSchema = zod.z.string().datetime({ offset: true });
|
|
944
|
+
var atUriSchema = zod.z.string().regex(/^at:\/\/[^\s]+$/, "Invalid AT-URI");
|
|
945
|
+
var cidSchema = zod.z.string().regex(/^(Qm[1-9A-HJ-NP-Za-km-z]{44}|b[A-Za-z0-9+/=]+)$/, "Invalid CID");
|
|
946
|
+
var languageTagSchema = zod.z.string().regex(/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/, "Invalid BCP 47 language tag");
|
|
947
|
+
var uriSchema = zod.z.string().url();
|
|
948
|
+
var strongRefSchema = zod.z.object({
|
|
949
|
+
uri: atUriSchema,
|
|
950
|
+
cid: cidSchema
|
|
951
|
+
});
|
|
952
|
+
var selfLabelsSchema = zod.z.object({
|
|
953
|
+
$type: zod.z.literal("com.atproto.label.defs#selfLabels").optional(),
|
|
954
|
+
values: zod.z.array(zod.z.object({ val: zod.z.string() }))
|
|
955
|
+
});
|
|
956
|
+
|
|
957
|
+
// src/schemas/endorsement-confirmation.ts
|
|
958
|
+
var EndorsementConfirmationRecordSchema = zod.z.object({
|
|
959
|
+
endorsement: strongRefSchema,
|
|
960
|
+
createdAt: datetimeSchema
|
|
961
|
+
});
|
|
962
|
+
var EndorsementRecordSchema = zod.z.object({
|
|
963
|
+
subject: didSchema,
|
|
964
|
+
skill: strongRefSchema,
|
|
965
|
+
skillName: zod.z.string().min(1).refine(maxGraphemes(64)).max(640),
|
|
966
|
+
comment: zod.z.string().refine(maxGraphemes(300)).max(3e3).optional(),
|
|
967
|
+
createdAt: datetimeSchema
|
|
968
|
+
});
|
|
969
|
+
var GraphFollowRecordSchema = zod.z.object({
|
|
970
|
+
subject: didSchema,
|
|
971
|
+
createdAt: datetimeSchema
|
|
972
|
+
});
|
|
973
|
+
var ProfileCertificationRecordSchema = zod.z.object({
|
|
974
|
+
name: zod.z.string().min(1).refine(maxGraphemes(100)).max(1e3),
|
|
975
|
+
authority: zod.z.string().refine(maxGraphemes(100)).max(1e3).optional(),
|
|
976
|
+
authorityDid: didSchema.optional(),
|
|
977
|
+
credentialId: zod.z.string().refine(maxGraphemes(100)).max(1e3).optional(),
|
|
978
|
+
credentialUrl: uriSchema.optional(),
|
|
979
|
+
issuedAt: datetimeSchema.optional(),
|
|
980
|
+
expiresAt: datetimeSchema.optional(),
|
|
981
|
+
labels: selfLabelsSchema.optional(),
|
|
982
|
+
createdAt: datetimeSchema
|
|
983
|
+
});
|
|
984
|
+
var ProfileCourseRecordSchema = zod.z.object({
|
|
985
|
+
name: zod.z.string().min(1).refine(maxGraphemes(200)).max(2e3),
|
|
986
|
+
number: zod.z.string().refine(maxGraphemes(50)).max(500).optional(),
|
|
987
|
+
institution: zod.z.string().refine(maxGraphemes(100)).max(1e3).optional(),
|
|
988
|
+
education: strongRefSchema.optional(),
|
|
989
|
+
createdAt: datetimeSchema
|
|
990
|
+
});
|
|
991
|
+
var ProfileEducationRecordSchema = zod.z.object({
|
|
992
|
+
institution: zod.z.string().min(1).refine(maxGraphemes(100)).max(1e3),
|
|
993
|
+
institutionDid: didSchema.optional(),
|
|
994
|
+
degree: zod.z.string().refine(maxGraphemes(100)).max(1e3).optional(),
|
|
995
|
+
fieldOfStudy: zod.z.string().refine(maxGraphemes(100)).max(1e3).optional(),
|
|
996
|
+
grade: zod.z.string().refine(maxGraphemes(50)).max(500).optional(),
|
|
997
|
+
activities: zod.z.string().refine(maxGraphemes(1e3)).max(1e4).optional(),
|
|
998
|
+
description: zod.z.string().refine(maxGraphemes(5e3)).max(5e4).optional(),
|
|
999
|
+
location: zod.z.unknown().optional(),
|
|
1000
|
+
startedAt: datetimeSchema.optional(),
|
|
1001
|
+
endedAt: datetimeSchema.optional(),
|
|
1002
|
+
labels: selfLabelsSchema.optional(),
|
|
1003
|
+
createdAt: datetimeSchema
|
|
1004
|
+
});
|
|
1005
|
+
var ProfileExternalAccountRecordSchema = zod.z.object({
|
|
1006
|
+
platform: zod.z.string(),
|
|
1007
|
+
url: uriSchema,
|
|
1008
|
+
label: zod.z.string().refine(maxGraphemes(64)).max(640).optional(),
|
|
1009
|
+
feedUrl: uriSchema.optional(),
|
|
1010
|
+
isPrimary: zod.z.boolean().optional(),
|
|
1011
|
+
createdAt: datetimeSchema
|
|
1012
|
+
});
|
|
1013
|
+
var ProfileHonorRecordSchema = zod.z.object({
|
|
1014
|
+
title: zod.z.string().min(1).refine(maxGraphemes(200)).max(2e3),
|
|
1015
|
+
issuer: zod.z.string().refine(maxGraphemes(100)).max(1e3).optional(),
|
|
1016
|
+
issuerDid: didSchema.optional(),
|
|
1017
|
+
description: zod.z.string().refine(maxGraphemes(5e3)).max(5e4).optional(),
|
|
1018
|
+
awardedAt: datetimeSchema.optional(),
|
|
1019
|
+
createdAt: datetimeSchema
|
|
1020
|
+
});
|
|
1021
|
+
var ProfileLanguageRecordSchema = zod.z.object({
|
|
1022
|
+
name: zod.z.string().min(1).refine(maxGraphemes(64)).max(640),
|
|
1023
|
+
proficiency: zod.z.string().optional(),
|
|
1024
|
+
createdAt: datetimeSchema
|
|
1025
|
+
});
|
|
1026
|
+
var ProfilePositionRecordSchema = zod.z.object({
|
|
1027
|
+
company: zod.z.string().min(1).refine(maxGraphemes(100)).max(1e3),
|
|
1028
|
+
companyDid: didSchema.optional(),
|
|
1029
|
+
title: zod.z.string().min(1).refine(maxGraphemes(100)).max(1e3),
|
|
1030
|
+
description: zod.z.string().refine(maxGraphemes(5e3)).max(5e4).optional(),
|
|
1031
|
+
employmentType: zod.z.string().optional(),
|
|
1032
|
+
workplaceType: zod.z.string().optional(),
|
|
1033
|
+
location: zod.z.unknown().optional(),
|
|
1034
|
+
startedAt: datetimeSchema,
|
|
1035
|
+
endedAt: datetimeSchema.optional(),
|
|
1036
|
+
skills: zod.z.array(strongRefSchema).max(50).optional(),
|
|
1037
|
+
labels: selfLabelsSchema.optional(),
|
|
1038
|
+
createdAt: datetimeSchema
|
|
1039
|
+
});
|
|
1040
|
+
var ProfileProjectRecordSchema = zod.z.object({
|
|
1041
|
+
name: zod.z.string().min(1).refine(maxGraphemes(100)).max(1e3),
|
|
1042
|
+
description: zod.z.string().refine(maxGraphemes(5e3)).max(5e4).optional(),
|
|
1043
|
+
url: uriSchema.optional(),
|
|
1044
|
+
position: strongRefSchema.optional(),
|
|
1045
|
+
startedAt: datetimeSchema.optional(),
|
|
1046
|
+
endedAt: datetimeSchema.optional(),
|
|
1047
|
+
labels: selfLabelsSchema.optional(),
|
|
1048
|
+
createdAt: datetimeSchema
|
|
1049
|
+
});
|
|
1050
|
+
var PublicationAuthorSchema = zod.z.object({
|
|
1051
|
+
name: zod.z.string().min(1).refine(maxGraphemes(100)).max(1e3),
|
|
1052
|
+
did: didSchema.optional()
|
|
1053
|
+
});
|
|
1054
|
+
var ProfilePublicationRecordSchema = zod.z.object({
|
|
1055
|
+
title: zod.z.string().min(1).refine(maxGraphemes(200)).max(2e3),
|
|
1056
|
+
publisher: zod.z.string().refine(maxGraphemes(100)).max(1e3).optional(),
|
|
1057
|
+
url: uriSchema.optional(),
|
|
1058
|
+
description: zod.z.string().refine(maxGraphemes(5e3)).max(5e4).optional(),
|
|
1059
|
+
authors: zod.z.array(PublicationAuthorSchema).max(50).optional(),
|
|
1060
|
+
publishedAt: datetimeSchema.optional(),
|
|
1061
|
+
createdAt: datetimeSchema
|
|
1062
|
+
});
|
|
1063
|
+
var ProfileSelfRecordSchema = zod.z.object({
|
|
1064
|
+
headline: zod.z.string().refine(maxGraphemes(120)).max(1200).optional(),
|
|
1065
|
+
about: zod.z.string().refine(maxGraphemes(5e3)).max(5e4).optional(),
|
|
1066
|
+
industry: zod.z.string().refine(maxGraphemes(100)).max(1e3).optional(),
|
|
1067
|
+
location: zod.z.unknown().optional(),
|
|
1068
|
+
openTo: zod.z.array(zod.z.string()).max(10).optional(),
|
|
1069
|
+
preferredWorkplace: zod.z.array(zod.z.string()).max(3).optional(),
|
|
1070
|
+
langs: zod.z.array(languageTagSchema).max(3).optional(),
|
|
1071
|
+
labels: selfLabelsSchema.optional(),
|
|
1072
|
+
createdAt: datetimeSchema
|
|
1073
|
+
});
|
|
1074
|
+
var ProfileSkillRecordSchema = zod.z.object({
|
|
1075
|
+
name: zod.z.string().min(1).refine(maxGraphemes(64)).max(640),
|
|
1076
|
+
category: zod.z.string().optional(),
|
|
1077
|
+
createdAt: datetimeSchema
|
|
1078
|
+
});
|
|
1079
|
+
var ProfileVolunteeringRecordSchema = zod.z.object({
|
|
1080
|
+
organization: zod.z.string().min(1).refine(maxGraphemes(100)).max(1e3),
|
|
1081
|
+
organizationDid: didSchema.optional(),
|
|
1082
|
+
role: zod.z.string().refine(maxGraphemes(100)).max(1e3).optional(),
|
|
1083
|
+
cause: zod.z.string().refine(maxGraphemes(100)).max(1e3).optional(),
|
|
1084
|
+
description: zod.z.string().refine(maxGraphemes(5e3)).max(5e4).optional(),
|
|
1085
|
+
startedAt: datetimeSchema.optional(),
|
|
1086
|
+
endedAt: datetimeSchema.optional(),
|
|
1087
|
+
createdAt: datetimeSchema
|
|
1088
|
+
});
|
|
928
1089
|
|
|
929
1090
|
// src/index.ts
|
|
930
|
-
var SIFA_SDK_VERSION = "0.
|
|
1091
|
+
var SIFA_SDK_VERSION = "0.5.0";
|
|
931
1092
|
|
|
932
1093
|
exports.CATEGORY_LABELS = CATEGORY_LABELS;
|
|
933
1094
|
exports.CATEGORY_ORDER = CATEGORY_ORDER;
|
|
934
1095
|
exports.CONTINENTS = CONTINENTS;
|
|
935
1096
|
exports.COUNTRIES = COUNTRIES;
|
|
1097
|
+
exports.EndorsementConfirmationRecordSchema = EndorsementConfirmationRecordSchema;
|
|
1098
|
+
exports.EndorsementRecordSchema = EndorsementRecordSchema;
|
|
1099
|
+
exports.GraphFollowRecordSchema = GraphFollowRecordSchema;
|
|
936
1100
|
exports.INDUSTRY_OPTIONS = INDUSTRY_OPTIONS;
|
|
937
1101
|
exports.PLATFORM_LABELS = PLATFORM_LABELS;
|
|
938
1102
|
exports.PLATFORM_OPTIONS = PLATFORM_OPTIONS;
|
|
1103
|
+
exports.ProfileCertificationRecordSchema = ProfileCertificationRecordSchema;
|
|
1104
|
+
exports.ProfileCourseRecordSchema = ProfileCourseRecordSchema;
|
|
1105
|
+
exports.ProfileEducationRecordSchema = ProfileEducationRecordSchema;
|
|
1106
|
+
exports.ProfileExternalAccountRecordSchema = ProfileExternalAccountRecordSchema;
|
|
1107
|
+
exports.ProfileHonorRecordSchema = ProfileHonorRecordSchema;
|
|
1108
|
+
exports.ProfileLanguageRecordSchema = ProfileLanguageRecordSchema;
|
|
1109
|
+
exports.ProfilePositionRecordSchema = ProfilePositionRecordSchema;
|
|
1110
|
+
exports.ProfileProjectRecordSchema = ProfileProjectRecordSchema;
|
|
1111
|
+
exports.ProfilePublicationRecordSchema = ProfilePublicationRecordSchema;
|
|
1112
|
+
exports.ProfileSelfRecordSchema = ProfileSelfRecordSchema;
|
|
1113
|
+
exports.ProfileSkillRecordSchema = ProfileSkillRecordSchema;
|
|
1114
|
+
exports.ProfileVolunteeringRecordSchema = ProfileVolunteeringRecordSchema;
|
|
1115
|
+
exports.PublicationAuthorSchema = PublicationAuthorSchema;
|
|
939
1116
|
exports.SIFA_SDK_VERSION = SIFA_SDK_VERSION;
|
|
940
1117
|
exports.SKILL_CATEGORIES = SKILL_CATEGORIES;
|
|
1118
|
+
exports.atUriSchema = atUriSchema;
|
|
941
1119
|
exports.certDateExtractor = certDateExtractor;
|
|
1120
|
+
exports.cidSchema = cidSchema;
|
|
942
1121
|
exports.contrastRatio = contrastRatio;
|
|
943
1122
|
exports.countryCodeToFlag = countryCodeToFlag;
|
|
944
1123
|
exports.dateRangeExtractor = dateRangeExtractor;
|
|
1124
|
+
exports.datetimeSchema = datetimeSchema;
|
|
945
1125
|
exports.dedupeSkills = dedupeSkills;
|
|
946
1126
|
exports.detectPdsProvider = detectPdsProvider;
|
|
1127
|
+
exports.didSchema = didSchema;
|
|
947
1128
|
exports.findIndustry = findIndustry;
|
|
948
1129
|
exports.formatDistanceToNow = formatDistanceToNow;
|
|
949
1130
|
exports.formatLocation = formatLocation;
|
|
@@ -958,15 +1139,20 @@ exports.getPlatformLabel = getPlatformLabel;
|
|
|
958
1139
|
exports.groupSkillsByCategory = groupSkillsByCategory;
|
|
959
1140
|
exports.isKnownPlatform = isKnownPlatform;
|
|
960
1141
|
exports.isValidRgbColor = isValidRgbColor;
|
|
1142
|
+
exports.languageTagSchema = languageTagSchema;
|
|
961
1143
|
exports.lexiconDateExtractor = lexiconDateExtractor;
|
|
1144
|
+
exports.maxGraphemes = maxGraphemes;
|
|
962
1145
|
exports.meetsContrastAA = meetsContrastAA;
|
|
963
1146
|
exports.parseLocationString = parseLocationString;
|
|
964
1147
|
exports.pdsProviderFromApi = pdsProviderFromApi;
|
|
965
1148
|
exports.relativeLuminance = relativeLuminance;
|
|
966
1149
|
exports.rgbToString = rgbToString;
|
|
967
1150
|
exports.sanitizeHandleInput = sanitizeHandleInput;
|
|
1151
|
+
exports.selfLabelsSchema = selfLabelsSchema;
|
|
968
1152
|
exports.singleDateExtractor = singleDateExtractor;
|
|
969
1153
|
exports.sortByDateDesc = sortByDateDesc;
|
|
1154
|
+
exports.strongRefSchema = strongRefSchema;
|
|
970
1155
|
exports.truncateGraphemes = truncateGraphemes;
|
|
1156
|
+
exports.uriSchema = uriSchema;
|
|
971
1157
|
//# sourceMappingURL=index.cjs.map
|
|
972
1158
|
//# sourceMappingURL=index.cjs.map
|