@singi-labs/sifa-sdk 0.9.4 → 0.9.5
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/README.md +12 -1
- package/dist/index.cjs +549 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +115 -1
- package/dist/index.d.ts +115 -1
- package/dist/index.js +541 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -170,6 +170,47 @@ declare function dedupeSkills(skills: ProfileSkill[]): MergedProfileSkill[];
|
|
|
170
170
|
*/
|
|
171
171
|
declare function groupSkillsByCategory<T extends ProfileSkill>(skills: T[]): [string, T[]][];
|
|
172
172
|
|
|
173
|
+
type ActivityTier = 'creation' | 'action' | 'filtered';
|
|
174
|
+
interface TierMeta {
|
|
175
|
+
label: string | null;
|
|
176
|
+
description: string;
|
|
177
|
+
shownOnPublicProfile: boolean;
|
|
178
|
+
}
|
|
179
|
+
interface LexiconEntry {
|
|
180
|
+
tier: ActivityTier;
|
|
181
|
+
app?: string;
|
|
182
|
+
notes?: string;
|
|
183
|
+
}
|
|
184
|
+
interface ActivityTaxonomy {
|
|
185
|
+
version: string;
|
|
186
|
+
updated: string;
|
|
187
|
+
tiers: Record<ActivityTier, TierMeta>;
|
|
188
|
+
lexicons: Record<string, LexiconEntry>;
|
|
189
|
+
}
|
|
190
|
+
declare const ACTIVITY_TIERS: Readonly<ActivityTaxonomy>;
|
|
191
|
+
/**
|
|
192
|
+
* Returns the activity tier for a given AT Protocol NSID.
|
|
193
|
+
* Returns 'filtered' for unknown/unclassified NSIDs (safe default — won't
|
|
194
|
+
* leak unknown records to public profile surfaces).
|
|
195
|
+
*/
|
|
196
|
+
declare function getActivityTier(nsid: string): ActivityTier;
|
|
197
|
+
/**
|
|
198
|
+
* Returns the full lexicon entry (tier + app + notes), or null if unknown.
|
|
199
|
+
*/
|
|
200
|
+
declare function getLexiconEntry(nsid: string): LexiconEntry | null;
|
|
201
|
+
/**
|
|
202
|
+
* Returns tier metadata (label, description, public visibility).
|
|
203
|
+
*/
|
|
204
|
+
declare function getTierMeta(tier: ActivityTier): TierMeta;
|
|
205
|
+
/**
|
|
206
|
+
* Returns the taxonomy version + updated date for diagnostics and
|
|
207
|
+
* version-skew detection between SDK consumers and the canonical taxonomy.
|
|
208
|
+
*/
|
|
209
|
+
declare function getActivityTaxonomyVersion(): {
|
|
210
|
+
version: string;
|
|
211
|
+
updated: string;
|
|
212
|
+
};
|
|
213
|
+
|
|
173
214
|
/**
|
|
174
215
|
* Format a date string as a relative time (e.g. "5m ago", "3d ago").
|
|
175
216
|
* Returns an empty string for invalid or future dates.
|
|
@@ -331,6 +372,79 @@ declare function contrastRatio(color1: RgbColor, color2: RgbColor): number;
|
|
|
331
372
|
*/
|
|
332
373
|
declare function meetsContrastAA(foreground: RgbColor, background: RgbColor): boolean;
|
|
333
374
|
|
|
375
|
+
/**
|
|
376
|
+
* URL patterns per app, mirroring the sifa-web registry.
|
|
377
|
+
*
|
|
378
|
+
* These describe how to build a clickable URL for an activity card given
|
|
379
|
+
* the author's handle/did and the record rkey. The patterns are templates
|
|
380
|
+
* with `{handle}`, `{did}`, and `{rkey}` placeholders; each variable is
|
|
381
|
+
* URI-encoded when interpolated.
|
|
382
|
+
*
|
|
383
|
+
* Tier semantics:
|
|
384
|
+
* - `urlPattern`: per-item URL (a specific post/event/repo). Preferred.
|
|
385
|
+
* - `profileUrlPattern`: per-user profile URL on the app. Fallback.
|
|
386
|
+
*
|
|
387
|
+
* Apps without either pattern are not clickable.
|
|
388
|
+
*/
|
|
389
|
+
interface AppUrlPatterns {
|
|
390
|
+
urlPattern?: string;
|
|
391
|
+
profileUrlPattern?: string;
|
|
392
|
+
}
|
|
393
|
+
declare const APP_URL_PATTERNS: Readonly<Record<string, AppUrlPatterns>>;
|
|
394
|
+
/**
|
|
395
|
+
* Map collection NSID prefixes to app ids. Order matters: longer / more
|
|
396
|
+
* specific prefixes must come before broader ones.
|
|
397
|
+
*/
|
|
398
|
+
declare const COLLECTION_TO_APP: ReadonlyArray<readonly [prefix: string, appId: string]>;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* An activity item as consumed by the Sifa activity-card components and
|
|
402
|
+
* the sifa-api external-URL health scanner. The shape mirrors the props
|
|
403
|
+
* the cards already use, so the resolver returns the same URL the UI
|
|
404
|
+
* renders.
|
|
405
|
+
*/
|
|
406
|
+
interface ActivityItemForUrl {
|
|
407
|
+
/** Collection NSID, e.g. "sh.tangled.graph.repo". */
|
|
408
|
+
collection: string;
|
|
409
|
+
/** The raw record from the PDS / API. */
|
|
410
|
+
record: Record<string, unknown>;
|
|
411
|
+
/** Full at-uri of the record (used by collections that derive URL from uri). */
|
|
412
|
+
uri: string;
|
|
413
|
+
/** Record key. */
|
|
414
|
+
rkey: string;
|
|
415
|
+
/** DID of the author of the record. */
|
|
416
|
+
authorDid: string;
|
|
417
|
+
/** Optional handle (cards prefer handle in URL paths when available). */
|
|
418
|
+
authorHandle?: string;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Map a collection NSID to its app id, mirroring the sifa-web prefix map.
|
|
422
|
+
*
|
|
423
|
+
* Falls back to the first two NSID segments (e.g. "org.hyperboards") when
|
|
424
|
+
* the prefix is not registered, matching the existing card behaviour.
|
|
425
|
+
*/
|
|
426
|
+
declare function getAppIdForCollection(collection: string): string;
|
|
427
|
+
/**
|
|
428
|
+
* Resolve the canonical clickable URL for an activity item — the same URL
|
|
429
|
+
* the activity-card UI in sifa-web renders.
|
|
430
|
+
*
|
|
431
|
+
* Returns `null` when no link is appropriate (the card would render
|
|
432
|
+
* non-clickable, or hide itself entirely).
|
|
433
|
+
*
|
|
434
|
+
* Used by:
|
|
435
|
+
* - sifa-web activity cards (single source of truth for href)
|
|
436
|
+
* - sifa-api external-URL health scanner (must match what the UI links to,
|
|
437
|
+
* so broken-link detection lines up with what users actually click)
|
|
438
|
+
*
|
|
439
|
+
* Resolution order:
|
|
440
|
+
* 1. Per-collection bespoke logic (tangled, kipclip, margin, smokesignal
|
|
441
|
+
* rsvp, standard documents). These mirror the inline logic in the
|
|
442
|
+
* individual card components.
|
|
443
|
+
* 2. Generic `record.url` field (used by hyperboards and similar).
|
|
444
|
+
* 3. Pattern-based per-item / profile URL from the registry.
|
|
445
|
+
*/
|
|
446
|
+
declare function resolveCardUrl(item: ActivityItemForUrl): string | null;
|
|
447
|
+
|
|
334
448
|
/**
|
|
335
449
|
* Profile completeness scoring.
|
|
336
450
|
*
|
|
@@ -418,4 +532,4 @@ declare function countFilledDimensions(input: ProfileDimensionInputs | Profile):
|
|
|
418
532
|
*/
|
|
419
533
|
declare const SIFA_SDK_VERSION: string;
|
|
420
534
|
|
|
421
|
-
export { CATEGORY_LABELS, CATEGORY_ORDER, COMPLETENESS_MAX_SCORE, CONTINENTS, COUNTRIES, type ContinentCode, DIMENSIONS_MAX_SCORE, type DimensionKey, type DimensionMap, EMPLOYMENT_TYPE_GROUPS, EMPLOYMENT_TYPE_LABELS, type EmploymentTypeGroup, type EmploymentTypeOption, INDUSTRY_OPTIONS, type IndustryOption, LocationValue, MIN_SKILLS, type MergedProfileSkill, OPEN_TO_OPTIONS, type OpenToOption, PLATFORM_LABELS, PLATFORM_OPTIONS, type PdsProvider, PdsProviderInfo, type PlatformId, Profile, type ProfileCompletion, type ProfileDimensionInputs, ProfileSkill, type RgbColor, SIFA_SDK_VERSION, SKILL_CATEGORIES, type SkillCategory, WORKPLACE_TYPE_LABELS, WORKPLACE_TYPE_OPTIONS, type WorkplaceTypeOption, certDateExtractor, completenessPercent, completenessScore, contrastRatio, countFilledDimensions, countryCodeToFlag, dateRangeExtractor, dedupeSkills, detectPdsProvider, dimensionsFromInputs, findIndustry, formatDistanceToNow, formatLocation, formatRelativeTime, getContinent, getDisplayLabel, getEmploymentTypeLabel, getFaviconUrl, getFilledDimensionsMap, getHandleStem, getIndustryLabelKey, getOpenToLabelKey, getPdsDisplayName, getPlatformLabel, getWorkplaceTypeLabel, groupSkillsByCategory, isKnownPlatform, isValidRgbColor, lexiconDateExtractor, limitCombiningMarks, meetsContrastAA, parseLocationString, pdsProviderFromApi, profileToDimensionInputs, relativeLuminance, rgbToString, sanitizeDisplayText, sanitizeHandleInput, singleDateExtractor, sortByDateDesc, truncateGraphemes };
|
|
535
|
+
export { ACTIVITY_TIERS, APP_URL_PATTERNS, type ActivityItemForUrl, type ActivityTaxonomy, type ActivityTier, type AppUrlPatterns, CATEGORY_LABELS, CATEGORY_ORDER, COLLECTION_TO_APP, COMPLETENESS_MAX_SCORE, CONTINENTS, COUNTRIES, type ContinentCode, DIMENSIONS_MAX_SCORE, type DimensionKey, type DimensionMap, EMPLOYMENT_TYPE_GROUPS, EMPLOYMENT_TYPE_LABELS, type EmploymentTypeGroup, type EmploymentTypeOption, INDUSTRY_OPTIONS, type IndustryOption, type LexiconEntry, LocationValue, MIN_SKILLS, type MergedProfileSkill, OPEN_TO_OPTIONS, type OpenToOption, PLATFORM_LABELS, PLATFORM_OPTIONS, type PdsProvider, PdsProviderInfo, type PlatformId, Profile, type ProfileCompletion, type ProfileDimensionInputs, ProfileSkill, type RgbColor, SIFA_SDK_VERSION, SKILL_CATEGORIES, type SkillCategory, type TierMeta, WORKPLACE_TYPE_LABELS, WORKPLACE_TYPE_OPTIONS, type WorkplaceTypeOption, certDateExtractor, completenessPercent, completenessScore, contrastRatio, countFilledDimensions, countryCodeToFlag, dateRangeExtractor, dedupeSkills, detectPdsProvider, dimensionsFromInputs, findIndustry, formatDistanceToNow, formatLocation, formatRelativeTime, getActivityTaxonomyVersion, getActivityTier, getAppIdForCollection, getContinent, getDisplayLabel, getEmploymentTypeLabel, getFaviconUrl, getFilledDimensionsMap, getHandleStem, getIndustryLabelKey, getLexiconEntry, getOpenToLabelKey, getPdsDisplayName, getPlatformLabel, getTierMeta, getWorkplaceTypeLabel, groupSkillsByCategory, isKnownPlatform, isValidRgbColor, lexiconDateExtractor, limitCombiningMarks, meetsContrastAA, parseLocationString, pdsProviderFromApi, profileToDimensionInputs, relativeLuminance, resolveCardUrl, rgbToString, sanitizeDisplayText, sanitizeHandleInput, singleDateExtractor, sortByDateDesc, truncateGraphemes };
|
package/dist/index.d.ts
CHANGED
|
@@ -170,6 +170,47 @@ declare function dedupeSkills(skills: ProfileSkill[]): MergedProfileSkill[];
|
|
|
170
170
|
*/
|
|
171
171
|
declare function groupSkillsByCategory<T extends ProfileSkill>(skills: T[]): [string, T[]][];
|
|
172
172
|
|
|
173
|
+
type ActivityTier = 'creation' | 'action' | 'filtered';
|
|
174
|
+
interface TierMeta {
|
|
175
|
+
label: string | null;
|
|
176
|
+
description: string;
|
|
177
|
+
shownOnPublicProfile: boolean;
|
|
178
|
+
}
|
|
179
|
+
interface LexiconEntry {
|
|
180
|
+
tier: ActivityTier;
|
|
181
|
+
app?: string;
|
|
182
|
+
notes?: string;
|
|
183
|
+
}
|
|
184
|
+
interface ActivityTaxonomy {
|
|
185
|
+
version: string;
|
|
186
|
+
updated: string;
|
|
187
|
+
tiers: Record<ActivityTier, TierMeta>;
|
|
188
|
+
lexicons: Record<string, LexiconEntry>;
|
|
189
|
+
}
|
|
190
|
+
declare const ACTIVITY_TIERS: Readonly<ActivityTaxonomy>;
|
|
191
|
+
/**
|
|
192
|
+
* Returns the activity tier for a given AT Protocol NSID.
|
|
193
|
+
* Returns 'filtered' for unknown/unclassified NSIDs (safe default — won't
|
|
194
|
+
* leak unknown records to public profile surfaces).
|
|
195
|
+
*/
|
|
196
|
+
declare function getActivityTier(nsid: string): ActivityTier;
|
|
197
|
+
/**
|
|
198
|
+
* Returns the full lexicon entry (tier + app + notes), or null if unknown.
|
|
199
|
+
*/
|
|
200
|
+
declare function getLexiconEntry(nsid: string): LexiconEntry | null;
|
|
201
|
+
/**
|
|
202
|
+
* Returns tier metadata (label, description, public visibility).
|
|
203
|
+
*/
|
|
204
|
+
declare function getTierMeta(tier: ActivityTier): TierMeta;
|
|
205
|
+
/**
|
|
206
|
+
* Returns the taxonomy version + updated date for diagnostics and
|
|
207
|
+
* version-skew detection between SDK consumers and the canonical taxonomy.
|
|
208
|
+
*/
|
|
209
|
+
declare function getActivityTaxonomyVersion(): {
|
|
210
|
+
version: string;
|
|
211
|
+
updated: string;
|
|
212
|
+
};
|
|
213
|
+
|
|
173
214
|
/**
|
|
174
215
|
* Format a date string as a relative time (e.g. "5m ago", "3d ago").
|
|
175
216
|
* Returns an empty string for invalid or future dates.
|
|
@@ -331,6 +372,79 @@ declare function contrastRatio(color1: RgbColor, color2: RgbColor): number;
|
|
|
331
372
|
*/
|
|
332
373
|
declare function meetsContrastAA(foreground: RgbColor, background: RgbColor): boolean;
|
|
333
374
|
|
|
375
|
+
/**
|
|
376
|
+
* URL patterns per app, mirroring the sifa-web registry.
|
|
377
|
+
*
|
|
378
|
+
* These describe how to build a clickable URL for an activity card given
|
|
379
|
+
* the author's handle/did and the record rkey. The patterns are templates
|
|
380
|
+
* with `{handle}`, `{did}`, and `{rkey}` placeholders; each variable is
|
|
381
|
+
* URI-encoded when interpolated.
|
|
382
|
+
*
|
|
383
|
+
* Tier semantics:
|
|
384
|
+
* - `urlPattern`: per-item URL (a specific post/event/repo). Preferred.
|
|
385
|
+
* - `profileUrlPattern`: per-user profile URL on the app. Fallback.
|
|
386
|
+
*
|
|
387
|
+
* Apps without either pattern are not clickable.
|
|
388
|
+
*/
|
|
389
|
+
interface AppUrlPatterns {
|
|
390
|
+
urlPattern?: string;
|
|
391
|
+
profileUrlPattern?: string;
|
|
392
|
+
}
|
|
393
|
+
declare const APP_URL_PATTERNS: Readonly<Record<string, AppUrlPatterns>>;
|
|
394
|
+
/**
|
|
395
|
+
* Map collection NSID prefixes to app ids. Order matters: longer / more
|
|
396
|
+
* specific prefixes must come before broader ones.
|
|
397
|
+
*/
|
|
398
|
+
declare const COLLECTION_TO_APP: ReadonlyArray<readonly [prefix: string, appId: string]>;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* An activity item as consumed by the Sifa activity-card components and
|
|
402
|
+
* the sifa-api external-URL health scanner. The shape mirrors the props
|
|
403
|
+
* the cards already use, so the resolver returns the same URL the UI
|
|
404
|
+
* renders.
|
|
405
|
+
*/
|
|
406
|
+
interface ActivityItemForUrl {
|
|
407
|
+
/** Collection NSID, e.g. "sh.tangled.graph.repo". */
|
|
408
|
+
collection: string;
|
|
409
|
+
/** The raw record from the PDS / API. */
|
|
410
|
+
record: Record<string, unknown>;
|
|
411
|
+
/** Full at-uri of the record (used by collections that derive URL from uri). */
|
|
412
|
+
uri: string;
|
|
413
|
+
/** Record key. */
|
|
414
|
+
rkey: string;
|
|
415
|
+
/** DID of the author of the record. */
|
|
416
|
+
authorDid: string;
|
|
417
|
+
/** Optional handle (cards prefer handle in URL paths when available). */
|
|
418
|
+
authorHandle?: string;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Map a collection NSID to its app id, mirroring the sifa-web prefix map.
|
|
422
|
+
*
|
|
423
|
+
* Falls back to the first two NSID segments (e.g. "org.hyperboards") when
|
|
424
|
+
* the prefix is not registered, matching the existing card behaviour.
|
|
425
|
+
*/
|
|
426
|
+
declare function getAppIdForCollection(collection: string): string;
|
|
427
|
+
/**
|
|
428
|
+
* Resolve the canonical clickable URL for an activity item — the same URL
|
|
429
|
+
* the activity-card UI in sifa-web renders.
|
|
430
|
+
*
|
|
431
|
+
* Returns `null` when no link is appropriate (the card would render
|
|
432
|
+
* non-clickable, or hide itself entirely).
|
|
433
|
+
*
|
|
434
|
+
* Used by:
|
|
435
|
+
* - sifa-web activity cards (single source of truth for href)
|
|
436
|
+
* - sifa-api external-URL health scanner (must match what the UI links to,
|
|
437
|
+
* so broken-link detection lines up with what users actually click)
|
|
438
|
+
*
|
|
439
|
+
* Resolution order:
|
|
440
|
+
* 1. Per-collection bespoke logic (tangled, kipclip, margin, smokesignal
|
|
441
|
+
* rsvp, standard documents). These mirror the inline logic in the
|
|
442
|
+
* individual card components.
|
|
443
|
+
* 2. Generic `record.url` field (used by hyperboards and similar).
|
|
444
|
+
* 3. Pattern-based per-item / profile URL from the registry.
|
|
445
|
+
*/
|
|
446
|
+
declare function resolveCardUrl(item: ActivityItemForUrl): string | null;
|
|
447
|
+
|
|
334
448
|
/**
|
|
335
449
|
* Profile completeness scoring.
|
|
336
450
|
*
|
|
@@ -418,4 +532,4 @@ declare function countFilledDimensions(input: ProfileDimensionInputs | Profile):
|
|
|
418
532
|
*/
|
|
419
533
|
declare const SIFA_SDK_VERSION: string;
|
|
420
534
|
|
|
421
|
-
export { CATEGORY_LABELS, CATEGORY_ORDER, COMPLETENESS_MAX_SCORE, CONTINENTS, COUNTRIES, type ContinentCode, DIMENSIONS_MAX_SCORE, type DimensionKey, type DimensionMap, EMPLOYMENT_TYPE_GROUPS, EMPLOYMENT_TYPE_LABELS, type EmploymentTypeGroup, type EmploymentTypeOption, INDUSTRY_OPTIONS, type IndustryOption, LocationValue, MIN_SKILLS, type MergedProfileSkill, OPEN_TO_OPTIONS, type OpenToOption, PLATFORM_LABELS, PLATFORM_OPTIONS, type PdsProvider, PdsProviderInfo, type PlatformId, Profile, type ProfileCompletion, type ProfileDimensionInputs, ProfileSkill, type RgbColor, SIFA_SDK_VERSION, SKILL_CATEGORIES, type SkillCategory, WORKPLACE_TYPE_LABELS, WORKPLACE_TYPE_OPTIONS, type WorkplaceTypeOption, certDateExtractor, completenessPercent, completenessScore, contrastRatio, countFilledDimensions, countryCodeToFlag, dateRangeExtractor, dedupeSkills, detectPdsProvider, dimensionsFromInputs, findIndustry, formatDistanceToNow, formatLocation, formatRelativeTime, getContinent, getDisplayLabel, getEmploymentTypeLabel, getFaviconUrl, getFilledDimensionsMap, getHandleStem, getIndustryLabelKey, getOpenToLabelKey, getPdsDisplayName, getPlatformLabel, getWorkplaceTypeLabel, groupSkillsByCategory, isKnownPlatform, isValidRgbColor, lexiconDateExtractor, limitCombiningMarks, meetsContrastAA, parseLocationString, pdsProviderFromApi, profileToDimensionInputs, relativeLuminance, rgbToString, sanitizeDisplayText, sanitizeHandleInput, singleDateExtractor, sortByDateDesc, truncateGraphemes };
|
|
535
|
+
export { ACTIVITY_TIERS, APP_URL_PATTERNS, type ActivityItemForUrl, type ActivityTaxonomy, type ActivityTier, type AppUrlPatterns, CATEGORY_LABELS, CATEGORY_ORDER, COLLECTION_TO_APP, COMPLETENESS_MAX_SCORE, CONTINENTS, COUNTRIES, type ContinentCode, DIMENSIONS_MAX_SCORE, type DimensionKey, type DimensionMap, EMPLOYMENT_TYPE_GROUPS, EMPLOYMENT_TYPE_LABELS, type EmploymentTypeGroup, type EmploymentTypeOption, INDUSTRY_OPTIONS, type IndustryOption, type LexiconEntry, LocationValue, MIN_SKILLS, type MergedProfileSkill, OPEN_TO_OPTIONS, type OpenToOption, PLATFORM_LABELS, PLATFORM_OPTIONS, type PdsProvider, PdsProviderInfo, type PlatformId, Profile, type ProfileCompletion, type ProfileDimensionInputs, ProfileSkill, type RgbColor, SIFA_SDK_VERSION, SKILL_CATEGORIES, type SkillCategory, type TierMeta, WORKPLACE_TYPE_LABELS, WORKPLACE_TYPE_OPTIONS, type WorkplaceTypeOption, certDateExtractor, completenessPercent, completenessScore, contrastRatio, countFilledDimensions, countryCodeToFlag, dateRangeExtractor, dedupeSkills, detectPdsProvider, dimensionsFromInputs, findIndustry, formatDistanceToNow, formatLocation, formatRelativeTime, getActivityTaxonomyVersion, getActivityTier, getAppIdForCollection, getContinent, getDisplayLabel, getEmploymentTypeLabel, getFaviconUrl, getFilledDimensionsMap, getHandleStem, getIndustryLabelKey, getLexiconEntry, getOpenToLabelKey, getPdsDisplayName, getPlatformLabel, getTierMeta, getWorkplaceTypeLabel, groupSkillsByCategory, isKnownPlatform, isValidRgbColor, lexiconDateExtractor, limitCombiningMarks, meetsContrastAA, parseLocationString, pdsProviderFromApi, profileToDimensionInputs, relativeLuminance, resolveCardUrl, rgbToString, sanitizeDisplayText, sanitizeHandleInput, singleDateExtractor, sortByDateDesc, truncateGraphemes };
|