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