@singi-labs/sifa-sdk 0.12.69 → 0.12.71

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.
@@ -9,15 +9,13 @@ import '../../org-settings-CZ_tmAYl.cjs';
9
9
  import '../../profile-summary-BTZAwG1z.cjs';
10
10
 
11
11
  /**
12
- * Create a new `id.sifa.profile.investment` record on the authenticated user's PDS.
13
- * The AppView signs and writes via the user's OAuth session.
12
+ * Typed wrappers over the generic record routes for
13
+ * `id.sifa.profile.investment`. sifa-api serves every collection without a
14
+ * bespoke handler through `POST|PUT|DELETE /api/profile/records/<collection>`,
15
+ * so these exist for call-site readability, not for a different endpoint.
14
16
  *
15
- * `data` should be a lexicon-shaped investment record (without `createdAt` or
16
- * `rkey`; the AppView fills both). Validate with `InvestmentWriteSchema` first if
17
- * you want client-side guarantees.
18
- *
19
- * Never throws -- inspect `result.success` and use `result.error` / `result.pdsHost`
20
- * for UI messaging.
17
+ * Never throw -- inspect `result.success` and use `result.error` /
18
+ * `result.pdsHost` for UI messaging.
21
19
  */
22
20
  declare function createInvestment(config: SifaApiConfig, data: Record<string, unknown>, options?: ApiFetchOptions): Promise<CreateResult>;
23
21
  /** Update an existing investment by `rkey`. */
@@ -9,15 +9,13 @@ import '../../org-settings-CZ_tmAYl.js';
9
9
  import '../../profile-summary-Do5FY7Q0.js';
10
10
 
11
11
  /**
12
- * Create a new `id.sifa.profile.investment` record on the authenticated user's PDS.
13
- * The AppView signs and writes via the user's OAuth session.
12
+ * Typed wrappers over the generic record routes for
13
+ * `id.sifa.profile.investment`. sifa-api serves every collection without a
14
+ * bespoke handler through `POST|PUT|DELETE /api/profile/records/<collection>`,
15
+ * so these exist for call-site readability, not for a different endpoint.
14
16
  *
15
- * `data` should be a lexicon-shaped investment record (without `createdAt` or
16
- * `rkey`; the AppView fills both). Validate with `InvestmentWriteSchema` first if
17
- * you want client-side guarantees.
18
- *
19
- * Never throws -- inspect `result.success` and use `result.error` / `result.pdsHost`
20
- * for UI messaging.
17
+ * Never throw -- inspect `result.success` and use `result.error` /
18
+ * `result.pdsHost` for UI messaging.
21
19
  */
22
20
  declare function createInvestment(config: SifaApiConfig, data: Record<string, unknown>, options?: ApiFetchOptions): Promise<CreateResult>;
23
21
  /** Update an existing investment by `rkey`. */
@@ -1546,19 +1546,140 @@ var sifaQueryKeys = {
1546
1546
  wipePreview: () => ["sifa", "destructive", "wipe-preview"]
1547
1547
  }
1548
1548
  };
1549
+ function maxGraphemes(max) {
1550
+ return (value) => {
1551
+ const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
1552
+ let count = 0;
1553
+ for (const _ of segmenter.segment(value)) {
1554
+ count++;
1555
+ if (count > max) return false;
1556
+ }
1557
+ return true;
1558
+ };
1559
+ }
1560
+ var didSchema = z.string().regex(/^did:[a-z]+:[a-zA-Z0-9._:%-]+$/, "Invalid DID");
1561
+ var datetimeSchema = z.string().datetime({ offset: true });
1562
+ var partialDateSchema = z.string().regex(/^\d{4}(-\d{2}(-\d{2}(T.+)?)?)?$/, "Expected YYYY, YYYY-MM, YYYY-MM-DD, or a datetime");
1563
+ var atUriSchema = z.string().regex(/^at:\/\/[^\s]+$/, "Invalid AT-URI");
1564
+ var cidSchema = z.string().regex(/^(Qm[1-9A-HJ-NP-Za-km-z]{44}|b[A-Za-z0-9+/=]+)$/, "Invalid CID");
1565
+ z.string().regex(/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/, "Invalid BCP 47 language tag");
1566
+ var uriSchema = z.string().url();
1567
+ var strongRefSchema = z.object({
1568
+ uri: atUriSchema,
1569
+ cid: cidSchema
1570
+ });
1571
+ z.object({
1572
+ uri: atUriSchema
1573
+ });
1574
+ var externalRecordRefSchema = z.object({
1575
+ uri: atUriSchema,
1576
+ cid: cidSchema.optional()
1577
+ });
1578
+ var selfLabelsSchema = z.object({
1579
+ $type: z.literal("com.atproto.label.defs#selfLabels").optional(),
1580
+ values: z.array(z.object({ val: z.string() }))
1581
+ });
1582
+ var projectMemberRefSchema = z.object({
1583
+ did: didSchema,
1584
+ role: z.string().optional(),
1585
+ title: z.string().refine(maxGraphemes(128)).max(1280).optional()
1586
+ });
1587
+ z.object({
1588
+ name: z.string().min(1).refine(maxGraphemes(256)).max(2560),
1589
+ description: z.string().refine(maxGraphemes(5e3)).max(5e4).optional(),
1590
+ url: uriSchema.optional(),
1591
+ members: z.array(projectMemberRefSchema).max(50).optional(),
1592
+ /**
1593
+ * The canonical `id.sifa.project.self` this personal entry corresponds to.
1594
+ * A composition link. For the same project recorded on someone else's
1595
+ * profile, see `sameAs`.
1596
+ */
1597
+ projectRef: strongRefSchema.optional(),
1598
+ /**
1599
+ * The same project as recorded on another person's profile. Each side stays
1600
+ * its own record; this only says the two describe one thing. Resolves by
1601
+ * AT-URI, since they will keep editing their copy.
1602
+ */
1603
+ sameAs: externalRecordRefSchema.optional(),
1604
+ position: strongRefSchema.optional(),
1605
+ startedAt: partialDateSchema.optional(),
1606
+ endedAt: partialDateSchema.optional(),
1607
+ labels: selfLabelsSchema.optional(),
1608
+ createdAt: datetimeSchema
1609
+ });
1610
+
1611
+ // src/schemas/profile-involvement.ts
1612
+ var ArtifactLinkSchema = z.object({
1613
+ url: uriSchema,
1614
+ kind: z.string().optional(),
1615
+ label: z.string().refine(maxGraphemes(200)).max(2e3).optional()
1616
+ }).passthrough();
1617
+ z.object({
1618
+ kind: z.string(),
1619
+ upstream: z.string().refine(maxGraphemes(256)).max(2560).optional(),
1620
+ upstreamDid: didSchema.optional(),
1621
+ upstreamUrl: uriSchema.optional(),
1622
+ role: z.string().refine(maxGraphemes(256)).max(2560).optional(),
1623
+ description: z.string().refine(maxGraphemes(5e3)).max(5e4).optional(),
1624
+ startedAt: partialDateSchema.optional(),
1625
+ endedAt: partialDateSchema.optional(),
1626
+ links: z.array(ArtifactLinkSchema).max(50).optional(),
1627
+ // Portable org entity identifier (Wikidata/ROR/LEI URI) from the resolver
1628
+ // typeahead, constrained to http(s) so a script scheme is never a valid ref.
1629
+ entityRef: z.string().url().refine((s) => /^https?:\/\//i.test(s), { message: "entityRef must be an http(s) URL" }).max(2048).optional(),
1630
+ // community.lexicon.location.address — validated at the app layer.
1631
+ location: z.unknown().optional(),
1632
+ // id.sifa.defs#skillRef references (at-uri to a skill record in the same repo).
1633
+ skills: z.array(z.object({ uri: z.string() })).max(50).optional(),
1634
+ labels: selfLabelsSchema.optional(),
1635
+ collaborators: z.array(projectMemberRefSchema).max(50).optional(),
1636
+ sameAs: externalRecordRefSchema.optional(),
1637
+ createdAt: datetimeSchema
1638
+ }).passthrough();
1639
+
1640
+ // src/schemas/profile-investment.ts
1641
+ var entityRefField = z.string().url().refine((s) => /^https?:\/\//i.test(s), { message: "entityRef must be an http(s) URL" }).max(2048).optional();
1642
+ var InvestmentAmountSchema = z.object({
1643
+ /** Whole major currency units (euros, not cents). Cheque sizes are round numbers. */
1644
+ value: z.number().int().min(0),
1645
+ /** ISO 4217 three-letter code, uppercase. */
1646
+ currency: z.string().length(3)
1647
+ });
1648
+ var PROFILE_INVESTMENT_NSID = "id.sifa.profile.investment";
1649
+ z.object({
1650
+ /** For a limited-partner entry this names the fund, not a portfolio company. */
1651
+ company: z.string().min(1).refine(maxGraphemes(256)).max(2560),
1652
+ companyDid: didSchema.optional(),
1653
+ entityRef: entityRefField,
1654
+ role: z.string().optional(),
1655
+ stage: z.string().optional(),
1656
+ status: z.string().optional(),
1657
+ /** The vehicle the capital went through. Absent for a cheque in the person's own name. */
1658
+ via: z.string().refine(maxGraphemes(256)).max(2560).optional(),
1659
+ viaDid: didSchema.optional(),
1660
+ viaEntityRef: entityRefField,
1661
+ /**
1662
+ * Optional and empty by default. Cheque size is a personal financial disclosure,
1663
+ * and clients must not prompt for it.
1664
+ */
1665
+ amount: InvestmentAmountSchema.optional(),
1666
+ startedAt: partialDateSchema.optional(),
1667
+ endedAt: partialDateSchema.optional(),
1668
+ description: z.string().refine(maxGraphemes(5e3)).max(5e4).optional(),
1669
+ links: z.array(ArtifactLinkSchema).max(50).optional(),
1670
+ labels: selfLabelsSchema.optional(),
1671
+ createdAt: datetimeSchema
1672
+ }).passthrough();
1549
1673
 
1550
1674
  // src/query/fetchers/investments.ts
1551
1675
  function createInvestment(config, data, options = {}) {
1552
- return apiWriteCreate(config, "/api/profile/investment", data, options);
1676
+ return createRecord(config, PROFILE_INVESTMENT_NSID, data, options);
1553
1677
  }
1554
1678
  function updateInvestment(config, rkey, data, options = {}) {
1555
- return apiWrite(config, `/api/profile/investment/${encodeURIComponent(rkey)}`, "PUT", {
1556
- body: data,
1557
- ...options
1558
- });
1679
+ return updateRecord(config, PROFILE_INVESTMENT_NSID, rkey, data, options);
1559
1680
  }
1560
1681
  function deleteInvestment(config, rkey, options = {}) {
1561
- return apiWrite(config, `/api/profile/investment/${encodeURIComponent(rkey)}`, "DELETE", options);
1682
+ return deleteRecord(config, PROFILE_INVESTMENT_NSID, rkey, options);
1562
1683
  }
1563
1684
 
1564
1685
  export { ApiError, HIDDEN_ITEM_SOURCES, HIDDEN_ITEM_TYPES, QUOTED_POSTS_BATCH_MAX, addFeatureAllowlist, addOrgNotificationEmail, apiFetch, apiFetchOrNull, apiWrite, apiWriteCreate, bulkHideProfileItems, bulkHideStandardPublications, bulkUnhideProfileItems, bulkUnhideStandardPublications, castRoadmapVote, checkAppAccount, checkNetworkMapJobStatus, confirmEndorsement, createConfirmation, createEducation, createEndorsement, createExternalAccount, createInvestment, createPosition, createProfileLocation, createReaction, createRecord, createSkill, deleteAccount, deleteAvatarOverride, deleteEducation, deleteExternalAccount, deleteInvestment, deletePosition, deleteProfileLocation, deleteReaction, deleteRecord, deleteRepoRecords, deleteSkill, dismissConfirmation, dismissEndorsement, fetchActivityFeed, fetchActivityTeaser, fetchAppsRegistry, fetchAtFundLink, fetchEndorsementCount, fetchEntitySearch, fetchExternalAccounts, fetchFeaturedProfile, fetchFollowing, fetchGetProfileView, fetchGivenConfirmations, fetchHeatmapData, fetchHiddenApps, fetchMyGithubPullRequests, fetchMyRoadmapVotes, fetchNetworkMap, fetchNetworkStreamCount, fetchPendingConfirmations, fetchPendingEndorsements, fetchProfile, fetchProfileSummary, fetchReactionStatus, fetchRepoInventory, fetchRoadmapVotes, fetchSearchFilters, fetchSearchProfiles, fetchSimilarProfiles, fetchSkillSuggestions, fetchStats, fetchSuggestionCount, fetchSuggestions, fetchWipePreview, followUser, getAdminReviewQueues, getBlueskySuggestions, getFollowers, getFollowing, getFollowingFeed, getMutuals, hideKeytraceClaim, hideOrcidPublication, hideProfileItem, hideSifaPublication, hideStandardPublication, importSearchEntities, initiateNetworkMapGeneration, isNetworkMapResponse, linkSkillToPosition, listFeatureAllowlist, refreshOrcidPublications, refreshPds, removeFeatureAllowlist, removeOrgNotificationEmail, repoExportUrl, requestOrgDomainChallenge, resetProfile, resolveQuotedPosts, retractRoadmapVote, revealMarqueDomain, revokeConfirmation, searchSkills, selectEntity, setExternalAccountPrimary, setPositionPrimary, sifaQueryKeys, submitOrgClaim, unfollowUser, unhideKeytraceClaim, unhideOrcidPublication, unhideProfileItem, unhideSifaPublication, unhideStandardPublication, unlinkSkillFromPosition, unrevealMarqueDomain, unsetExternalAccountPrimary, unsetPositionPrimary, updateEducation, updateExternalAccount, updateInvestment, updateOrgProfile, updatePosition, updateProfileLocation, updateProfileOverride, updateProfileSelf, updateRecord, updateSkill, uploadAvatar, verifyExternalAccount, verifyOrgDomain };