@singi-labs/sifa-sdk 0.19.44 → 0.19.46
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/atproto/index.js +9 -3
- package/dist/atproto/index.js.map +1 -1
- package/dist/badge/index.cjs.map +1 -1
- package/dist/badge/index.js +5 -141
- package/dist/badge/index.js.map +1 -1
- package/dist/cards/adult-content.js +14 -0
- package/dist/cards/adult-content.js.map +1 -0
- package/dist/cards/app-url-patterns.js +369 -0
- package/dist/cards/app-url-patterns.js.map +1 -0
- package/dist/cards/index.js +24 -0
- package/dist/cards/index.js.map +1 -0
- package/dist/cards/resolve-card-url.js +198 -0
- package/dist/cards/resolve-card-url.js.map +1 -0
- package/dist/cards/visibility.js +45 -0
- package/dist/cards/visibility.js.map +1 -0
- package/dist/flags/index.js +4 -3
- package/dist/flags/index.js.map +1 -1
- package/dist/format/collapse-contributors.js +19 -0
- package/dist/format/collapse-contributors.js.map +1 -0
- package/dist/format/company-name.js +61 -0
- package/dist/format/company-name.js.map +1 -0
- package/dist/format/compare-text.js +9 -0
- package/dist/format/compare-text.js.map +1 -0
- package/dist/format/doi.js +8 -0
- package/dist/format/doi.js.map +1 -0
- package/dist/format/embed.js +131 -0
- package/dist/format/embed.js.map +1 -0
- package/dist/format/endorsement-context.js +35 -0
- package/dist/format/endorsement-context.js.map +1 -0
- package/dist/format/format-display-url.js +42 -0
- package/dist/format/format-display-url.js.map +1 -0
- package/dist/format/format-duration.js +13 -0
- package/dist/format/format-duration.js.map +1 -0
- package/dist/format/format-time.js +30 -0
- package/dist/format/format-time.js.map +1 -0
- package/dist/format/handle-utils.js +19 -0
- package/dist/format/handle-utils.js.map +1 -0
- package/dist/format/index.js +106 -0
- package/dist/format/index.js.map +1 -0
- package/dist/format/location-segments.js +29 -0
- package/dist/format/location-segments.js.map +1 -0
- package/dist/format/location-utils.js +42 -0
- package/dist/format/location-utils.js.map +1 -0
- package/dist/format/meta-description.js +35 -0
- package/dist/format/meta-description.js.map +1 -0
- package/dist/format/normalize-company-key.js +12 -0
- package/dist/format/normalize-company-key.js.map +1 -0
- package/dist/format/normalize-legal-form.js +71 -0
- package/dist/format/normalize-legal-form.js.map +1 -0
- package/dist/format/pds-utils.js +73 -0
- package/dist/format/pds-utils.js.map +1 -0
- package/dist/format/sort-by-date.js +39 -0
- package/dist/format/sort-by-date.js.map +1 -0
- package/dist/format/summarize-deliveries.js +37 -0
- package/dist/format/summarize-deliveries.js.map +1 -0
- package/dist/format/talk-slug.js +21 -0
- package/dist/format/talk-slug.js.map +1 -0
- package/dist/format/text-sanitize.js +29 -0
- package/dist/format/text-sanitize.js.map +1 -0
- package/dist/format/text-truncate.js +14 -0
- package/dist/format/text-truncate.js.map +1 -0
- package/dist/format/time-utils.js +19 -0
- package/dist/format/time-utils.js.map +1 -0
- package/dist/format/timeline.js +33 -0
- package/dist/format/timeline.js.map +1 -0
- package/dist/format/wcag-contrast.js +34 -0
- package/dist/format/wcag-contrast.js.map +1 -0
- package/dist/import/index.js +22 -0
- package/dist/import/index.js.map +1 -0
- package/dist/import/presentation-csv.js +116 -0
- package/dist/import/presentation-csv.js.map +1 -0
- package/dist/index.cjs +7 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +677 -7086
- package/dist/index.js.map +1 -1
- package/dist/jev/index.js +18 -5
- package/dist/jev/index.js.map +1 -1
- package/dist/jsonld/index.cjs.map +1 -1
- package/dist/jsonld/index.js +30 -987
- package/dist/jsonld/index.js.map +1 -1
- package/dist/jsonld/profile.js +222 -0
- package/dist/jsonld/profile.js.map +1 -0
- package/dist/jsonld/terms.js +496 -0
- package/dist/jsonld/terms.js.map +1 -0
- package/dist/jsonld/url.js +17 -0
- package/dist/jsonld/url.js.map +1 -0
- package/dist/jsonld/works-graph.js +41 -0
- package/dist/jsonld/works-graph.js.map +1 -0
- package/dist/jsonld/works.js +178 -0
- package/dist/jsonld/works.js.map +1 -0
- package/dist/logic/actor-identity.js +8 -0
- package/dist/logic/actor-identity.js.map +1 -0
- package/dist/logic/agent-ref.js +24 -0
- package/dist/logic/agent-ref.js.map +1 -0
- package/dist/logic/company-page-indexable.js +23 -0
- package/dist/logic/company-page-indexable.js.map +1 -0
- package/dist/logic/date-lookahead.js +33 -0
- package/dist/logic/date-lookahead.js.map +1 -0
- package/dist/logic/domain-detect.js +43 -0
- package/dist/logic/domain-detect.js.map +1 -0
- package/dist/logic/entity-disambiguation.js +24 -0
- package/dist/logic/entity-disambiguation.js.map +1 -0
- package/dist/logic/entity-ref-anchor.js +33 -0
- package/dist/logic/entity-ref-anchor.js.map +1 -0
- package/dist/logic/index.js +91 -0
- package/dist/logic/index.js.map +1 -0
- package/dist/logic/org-floor.js +66 -0
- package/dist/logic/org-floor.js.map +1 -0
- package/dist/logic/primary-item.js +9 -0
- package/dist/logic/primary-item.js.map +1 -0
- package/dist/logic/primary-position.js +16 -0
- package/dist/logic/primary-position.js.map +1 -0
- package/dist/logic/profile-completeness.js +21 -0
- package/dist/logic/profile-completeness.js.map +1 -0
- package/dist/logic/profile-dimensions.js +50 -0
- package/dist/logic/profile-dimensions.js.map +1 -0
- package/dist/logic/profile-summary.js +23 -0
- package/dist/logic/profile-summary.js.map +1 -0
- package/dist/logic/pseudo-employer.js +34 -0
- package/dist/logic/pseudo-employer.js.map +1 -0
- package/dist/logic/recent-activity.js +10 -0
- package/dist/logic/recent-activity.js.map +1 -0
- package/dist/logic/self-app.js +10 -0
- package/dist/logic/self-app.js.map +1 -0
- package/dist/{org-BCrvebcf.d.ts → org-CxTEjjrm.d.ts} +1 -1
- package/dist/{org-settings-C73Sin5E.d.ts → org-settings-BShvhyFp.d.ts} +1 -1
- package/dist/profile/headline-role-dedupe.js +12 -0
- package/dist/profile/headline-role-dedupe.js.map +1 -0
- package/dist/profile/highlights.js +200 -0
- package/dist/profile/highlights.js.map +1 -0
- package/dist/profile/index.js +66 -0
- package/dist/profile/index.js.map +1 -0
- package/dist/profile/involvement-grouping.js +31 -0
- package/dist/profile/involvement-grouping.js.map +1 -0
- package/dist/profile/language-sort.js +24 -0
- package/dist/profile/language-sort.js.map +1 -0
- package/dist/profile/publication-versions.js +98 -0
- package/dist/profile/publication-versions.js.map +1 -0
- package/dist/profile/range-sort.js +14 -0
- package/dist/profile/range-sort.js.map +1 -0
- package/dist/profile/section-model.js +122 -0
- package/dist/profile/section-model.js.map +1 -0
- package/dist/profile/section-sorts.js +33 -0
- package/dist/profile/section-sorts.js.map +1 -0
- package/dist/publishers/index.js +16 -0
- package/dist/publishers/index.js.map +1 -0
- package/dist/publishers/registry.js +87 -0
- package/dist/publishers/registry.js.map +1 -0
- package/dist/publishing/index.js +46 -184
- package/dist/publishing/index.js.map +1 -1
- package/dist/publishing/linkblog.js +42 -0
- package/dist/publishing/linkblog.js.map +1 -0
- package/dist/publishing/registry.js +32 -0
- package/dist/publishing/registry.js.map +1 -0
- package/dist/publishing/schemas.js +74 -0
- package/dist/publishing/schemas.js.map +1 -0
- package/dist/publishing/types.js +32 -0
- package/dist/publishing/types.js.map +1 -0
- package/dist/query/client.js +119 -0
- package/dist/query/client.js.map +1 -0
- package/dist/query/config.js +23 -0
- package/dist/query/config.js.map +1 -0
- package/dist/query/fetchers/accounts.js +29 -0
- package/dist/query/fetchers/accounts.js.map +1 -0
- package/dist/query/fetchers/activity-items-hide.js +31 -0
- package/dist/query/fetchers/activity-items-hide.js.map +1 -0
- package/dist/query/fetchers/activity.js +61 -0
- package/dist/query/fetchers/activity.js.map +1 -0
- package/dist/query/fetchers/actor.js +30 -0
- package/dist/query/fetchers/actor.js.map +1 -0
- package/dist/query/fetchers/admin-feature-allowlists.js +41 -0
- package/dist/query/fetchers/admin-feature-allowlists.js.map +1 -0
- package/dist/query/fetchers/admin-review-queues.js +30 -0
- package/dist/query/fetchers/admin-review-queues.js.map +1 -0
- package/dist/query/fetchers/apps.js +31 -0
- package/dist/query/fetchers/apps.js.map +1 -0
- package/dist/query/fetchers/bsky-preferences.js +55 -0
- package/dist/query/fetchers/bsky-preferences.js.map +1 -0
- package/dist/query/fetchers/confirmations.js +55 -0
- package/dist/query/fetchers/confirmations.js.map +1 -0
- package/dist/query/fetchers/destructive.js +34 -0
- package/dist/query/fetchers/destructive.js.map +1 -0
- package/dist/query/fetchers/discovery.js +67 -0
- package/dist/query/fetchers/discovery.js.map +1 -0
- package/dist/query/fetchers/education.js +23 -0
- package/dist/query/fetchers/education.js.map +1 -0
- package/dist/query/fetchers/endorsement-inbox.js +36 -0
- package/dist/query/fetchers/endorsement-inbox.js.map +1 -0
- package/dist/query/fetchers/endorsement.js +23 -0
- package/dist/query/fetchers/endorsement.js.map +1 -0
- package/dist/query/fetchers/endorsements.js +20 -0
- package/dist/query/fetchers/endorsements.js.map +1 -0
- package/dist/query/fetchers/entities.js +65 -0
- package/dist/query/fetchers/entities.js.map +1 -0
- package/dist/query/fetchers/external-accounts.js +74 -0
- package/dist/query/fetchers/external-accounts.js.map +1 -0
- package/dist/query/fetchers/follow-extras.js +38 -0
- package/dist/query/fetchers/follow-extras.js.map +1 -0
- package/dist/query/fetchers/follow.js +105 -0
- package/dist/query/fetchers/follow.js.map +1 -0
- package/dist/query/fetchers/get-profile-view.js +21 -0
- package/dist/query/fetchers/get-profile-view.js.map +1 -0
- package/dist/query/fetchers/github-prs.js +45 -0
- package/dist/query/fetchers/github-prs.js.map +1 -0
- package/dist/query/fetchers/inbox.js +29 -0
- package/dist/query/fetchers/inbox.js.map +1 -0
- package/dist/query/fetchers/index.cjs.map +1 -1
- package/dist/query/fetchers/index.d.ts +2 -2
- package/dist/query/fetchers/index.js +360 -2045
- package/dist/query/fetchers/index.js.map +1 -1
- package/dist/query/fetchers/investments.js +18 -0
- package/dist/query/fetchers/investments.js.map +1 -0
- package/dist/query/fetchers/keytrace-claims.js +23 -0
- package/dist/query/fetchers/keytrace-claims.js.map +1 -0
- package/dist/query/fetchers/marque-domains.js +23 -0
- package/dist/query/fetchers/marque-domains.js.map +1 -0
- package/dist/query/fetchers/network-map.js +36 -0
- package/dist/query/fetchers/network-map.js.map +1 -0
- package/dist/query/fetchers/org.js +48 -0
- package/dist/query/fetchers/org.js.map +1 -0
- package/dist/query/fetchers/positions.js +77 -0
- package/dist/query/fetchers/positions.js.map +1 -0
- package/dist/query/fetchers/profile-completeness.js +45 -0
- package/dist/query/fetchers/profile-completeness.js.map +1 -0
- package/dist/query/fetchers/profile-items-hide.js +36 -0
- package/dist/query/fetchers/profile-items-hide.js.map +1 -0
- package/dist/query/fetchers/profile-locations.js +23 -0
- package/dist/query/fetchers/profile-locations.js.map +1 -0
- package/dist/query/fetchers/profile-mutations.js +82 -0
- package/dist/query/fetchers/profile-mutations.js.map +1 -0
- package/dist/query/fetchers/profile-summary.js +14 -0
- package/dist/query/fetchers/profile-summary.js.map +1 -0
- package/dist/query/fetchers/profile.js +31 -0
- package/dist/query/fetchers/profile.js.map +1 -0
- package/dist/query/fetchers/publications.js +66 -0
- package/dist/query/fetchers/publications.js.map +1 -0
- package/dist/query/fetchers/quoted-posts.js +40 -0
- package/dist/query/fetchers/quoted-posts.js.map +1 -0
- package/dist/query/fetchers/reactions.js +85 -0
- package/dist/query/fetchers/reactions.js.map +1 -0
- package/dist/query/fetchers/received-endorsements.js +20 -0
- package/dist/query/fetchers/received-endorsements.js.map +1 -0
- package/dist/query/fetchers/reciprocity.js +23 -0
- package/dist/query/fetchers/reciprocity.js.map +1 -0
- package/dist/query/fetchers/records.js +27 -0
- package/dist/query/fetchers/records.js.map +1 -0
- package/dist/query/fetchers/repo-inventory.js +23 -0
- package/dist/query/fetchers/repo-inventory.js.map +1 -0
- package/dist/query/fetchers/roadmap.js +73 -0
- package/dist/query/fetchers/roadmap.js.map +1 -0
- package/dist/query/fetchers/rpg.js +36 -0
- package/dist/query/fetchers/rpg.js.map +1 -0
- package/dist/query/fetchers/search.js +78 -0
- package/dist/query/fetchers/search.js.map +1 -0
- package/dist/query/fetchers/section-primary.js +23 -0
- package/dist/query/fetchers/section-primary.js.map +1 -0
- package/dist/query/fetchers/skills.js +30 -0
- package/dist/query/fetchers/skills.js.map +1 -0
- package/dist/query/fetchers/speakers.js +42 -0
- package/dist/query/fetchers/speakers.js.map +1 -0
- package/dist/query/fetchers/stats.js +16 -0
- package/dist/query/fetchers/stats.js.map +1 -0
- package/dist/query/fetchers/stream.js +30 -0
- package/dist/query/fetchers/stream.js.map +1 -0
- package/dist/query/fetchers/unlinked-positions.js +30 -0
- package/dist/query/fetchers/unlinked-positions.js.map +1 -0
- package/dist/query/hooks/index.d.ts +3 -3
- package/dist/query/hooks/index.js +283 -3555
- package/dist/query/hooks/index.js.map +1 -1
- package/dist/query/hooks/use-accounts.js +19 -0
- package/dist/query/hooks/use-accounts.js.map +1 -0
- package/dist/query/hooks/use-activity-items-hide.js +52 -0
- package/dist/query/hooks/use-activity-items-hide.js.map +1 -0
- package/dist/query/hooks/use-activity.js +44 -0
- package/dist/query/hooks/use-activity.js.map +1 -0
- package/dist/query/hooks/use-admin-review-queues.js +21 -0
- package/dist/query/hooks/use-admin-review-queues.js.map +1 -0
- package/dist/query/hooks/use-apps.js +31 -0
- package/dist/query/hooks/use-apps.js.map +1 -0
- package/dist/query/hooks/use-bsky-content-prefs.js +45 -0
- package/dist/query/hooks/use-bsky-content-prefs.js.map +1 -0
- package/dist/query/hooks/use-confirmations.js +121 -0
- package/dist/query/hooks/use-confirmations.js.map +1 -0
- package/dist/query/hooks/use-create-position.js +28 -0
- package/dist/query/hooks/use-create-position.js.map +1 -0
- package/dist/query/hooks/use-destructive.js +63 -0
- package/dist/query/hooks/use-destructive.js.map +1 -0
- package/dist/query/hooks/use-discovery.js +53 -0
- package/dist/query/hooks/use-discovery.js.map +1 -0
- package/dist/query/hooks/use-education-mutations.js +67 -0
- package/dist/query/hooks/use-education-mutations.js.map +1 -0
- package/dist/query/hooks/use-endorsement-inbox.js +80 -0
- package/dist/query/hooks/use-endorsement-inbox.js.map +1 -0
- package/dist/query/hooks/use-endorsement-mutations.js +33 -0
- package/dist/query/hooks/use-endorsement-mutations.js.map +1 -0
- package/dist/query/hooks/use-endorsement.js +20 -0
- package/dist/query/hooks/use-endorsement.js.map +1 -0
- package/dist/query/hooks/use-entity-search.js +73 -0
- package/dist/query/hooks/use-entity-search.js.map +1 -0
- package/dist/query/hooks/use-external-accounts.js +143 -0
- package/dist/query/hooks/use-external-accounts.js.map +1 -0
- package/dist/query/hooks/use-feature-allowlist.js +104 -0
- package/dist/query/hooks/use-feature-allowlist.js.map +1 -0
- package/dist/query/hooks/use-follow-extras.js +38 -0
- package/dist/query/hooks/use-follow-extras.js.map +1 -0
- package/dist/query/hooks/use-follow.js +113 -0
- package/dist/query/hooks/use-follow.js.map +1 -0
- package/dist/query/hooks/use-get-profile-view.js +20 -0
- package/dist/query/hooks/use-get-profile-view.js.map +1 -0
- package/dist/query/hooks/use-github-prs.js +21 -0
- package/dist/query/hooks/use-github-prs.js.map +1 -0
- package/dist/query/hooks/use-inbox.js +19 -0
- package/dist/query/hooks/use-inbox.js.map +1 -0
- package/dist/query/hooks/use-investment-mutations.js +65 -0
- package/dist/query/hooks/use-investment-mutations.js.map +1 -0
- package/dist/query/hooks/use-keytrace-claims.js +50 -0
- package/dist/query/hooks/use-keytrace-claims.js.map +1 -0
- package/dist/query/hooks/use-location-mutations.js +71 -0
- package/dist/query/hooks/use-location-mutations.js.map +1 -0
- package/dist/query/hooks/use-marque-domains.js +50 -0
- package/dist/query/hooks/use-marque-domains.js.map +1 -0
- package/dist/query/hooks/use-org-claim.js +29 -0
- package/dist/query/hooks/use-org-claim.js.map +1 -0
- package/dist/query/hooks/use-org-domains.js +28 -0
- package/dist/query/hooks/use-org-domains.js.map +1 -0
- package/dist/query/hooks/use-org-notification-emails.js +28 -0
- package/dist/query/hooks/use-org-notification-emails.js.map +1 -0
- package/dist/query/hooks/use-org-profile-settings.js +29 -0
- package/dist/query/hooks/use-org-profile-settings.js.map +1 -0
- package/dist/query/hooks/use-org-profile.js +21 -0
- package/dist/query/hooks/use-org-profile.js.map +1 -0
- package/dist/query/hooks/use-position-mutations.js +128 -0
- package/dist/query/hooks/use-position-mutations.js.map +1 -0
- package/dist/query/hooks/use-profile-completeness.js +21 -0
- package/dist/query/hooks/use-profile-completeness.js.map +1 -0
- package/dist/query/hooks/use-profile-items-hide.js +53 -0
- package/dist/query/hooks/use-profile-items-hide.js.map +1 -0
- package/dist/query/hooks/use-profile-mutations.js +143 -0
- package/dist/query/hooks/use-profile-mutations.js.map +1 -0
- package/dist/query/hooks/use-profile.js +30 -0
- package/dist/query/hooks/use-profile.js.map +1 -0
- package/dist/query/hooks/use-publication-mutations.js +90 -0
- package/dist/query/hooks/use-publication-mutations.js.map +1 -0
- package/dist/query/hooks/use-reaction-mutations.js +48 -0
- package/dist/query/hooks/use-reaction-mutations.js.map +1 -0
- package/dist/query/hooks/use-reactions.js +32 -0
- package/dist/query/hooks/use-reactions.js.map +1 -0
- package/dist/query/hooks/use-received-endorsements.js +23 -0
- package/dist/query/hooks/use-received-endorsements.js.map +1 -0
- package/dist/query/hooks/use-reciprocity.js +19 -0
- package/dist/query/hooks/use-reciprocity.js.map +1 -0
- package/dist/query/hooks/use-record-mutations.js +67 -0
- package/dist/query/hooks/use-record-mutations.js.map +1 -0
- package/dist/query/hooks/use-repo-inventory.js +43 -0
- package/dist/query/hooks/use-repo-inventory.js.map +1 -0
- package/dist/query/hooks/use-roadmap-mutations.js +51 -0
- package/dist/query/hooks/use-roadmap-mutations.js.map +1 -0
- package/dist/query/hooks/use-roadmap.js +31 -0
- package/dist/query/hooks/use-roadmap.js.map +1 -0
- package/dist/query/hooks/use-search.js +63 -0
- package/dist/query/hooks/use-search.js.map +1 -0
- package/dist/query/hooks/use-section-primary-mutations.js +53 -0
- package/dist/query/hooks/use-section-primary-mutations.js.map +1 -0
- package/dist/query/hooks/use-skill-mutations.js +91 -0
- package/dist/query/hooks/use-skill-mutations.js.map +1 -0
- package/dist/query/hooks/use-stats.js +19 -0
- package/dist/query/hooks/use-stats.js.map +1 -0
- package/dist/query/hooks/use-stream.js +20 -0
- package/dist/query/hooks/use-stream.js.map +1 -0
- package/dist/query/hooks/use-unlinked-positions.js +45 -0
- package/dist/query/hooks/use-unlinked-positions.js.map +1 -0
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.d.ts +4 -4
- package/dist/query/index.js +685 -3744
- package/dist/query/index.js.map +1 -1
- package/dist/query/keys.js +138 -0
- package/dist/query/keys.js.map +1 -0
- package/dist/repo/groups.js +81 -0
- package/dist/repo/groups.js.map +1 -0
- package/dist/repo/index.js +9 -0
- package/dist/repo/index.js.map +1 -0
- package/dist/repo/labels.js +121 -0
- package/dist/repo/labels.js.map +1 -0
- package/dist/repo/types.js +1 -0
- package/dist/repo/types.js.map +1 -0
- package/dist/resume/index.js +5 -179
- package/dist/resume/index.js.map +1 -1
- package/dist/resume/json-resume.js +153 -0
- package/dist/resume/json-resume.js.map +1 -0
- package/dist/roadmap/index.js +101 -0
- package/dist/roadmap/index.js.map +1 -0
- package/dist/rpg/catalog.js +101 -0
- package/dist/rpg/catalog.js.map +1 -0
- package/dist/rpg/index.js +13 -116
- package/dist/rpg/index.js.map +1 -1
- package/dist/rpg/unlocks.js +21 -0
- package/dist/rpg/unlocks.js.map +1 -0
- package/dist/schemas/blob-ref.js +12 -0
- package/dist/schemas/blob-ref.js.map +1 -0
- package/dist/schemas/confirmation.js +23 -0
- package/dist/schemas/confirmation.js.map +1 -0
- package/dist/schemas/endorsement-confirmation.js +18 -0
- package/dist/schemas/endorsement-confirmation.js.map +1 -0
- package/dist/schemas/endorsement.js +19 -0
- package/dist/schemas/endorsement.js.map +1 -0
- package/dist/schemas/entity.js +74 -0
- package/dist/schemas/entity.js.map +1 -0
- package/dist/schemas/feed.js +73 -0
- package/dist/schemas/feed.js.map +1 -0
- package/dist/schemas/follow-profile.js +32 -0
- package/dist/schemas/follow-profile.js.map +1 -0
- package/dist/schemas/graph-follow.js +19 -0
- package/dist/schemas/graph-follow.js.map +1 -0
- package/dist/schemas/index.js +164 -629
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/org-employment-attestation.js +28 -0
- package/dist/schemas/org-employment-attestation.js.map +1 -0
- package/dist/schemas/org-profile.js +64 -0
- package/dist/schemas/org-profile.js.map +1 -0
- package/dist/schemas/profile-certification.js +28 -0
- package/dist/schemas/profile-certification.js.map +1 -0
- package/dist/schemas/profile-course.js +32 -0
- package/dist/schemas/profile-course.js.map +1 -0
- package/dist/schemas/profile-education.js +33 -0
- package/dist/schemas/profile-education.js.map +1 -0
- package/dist/schemas/profile-external-account.js +15 -0
- package/dist/schemas/profile-external-account.js.map +1 -0
- package/dist/schemas/profile-honor.js +18 -0
- package/dist/schemas/profile-honor.js.map +1 -0
- package/dist/schemas/profile-investment.js +48 -0
- package/dist/schemas/profile-investment.js.map +1 -0
- package/dist/schemas/profile-involvement.js +47 -0
- package/dist/schemas/profile-involvement.js.map +1 -0
- package/dist/schemas/profile-language.js +12 -0
- package/dist/schemas/profile-language.js.map +1 -0
- package/dist/schemas/profile-position.js +42 -0
- package/dist/schemas/profile-position.js.map +1 -0
- package/dist/schemas/profile-presentation-delivery.js +38 -0
- package/dist/schemas/profile-presentation-delivery.js.map +1 -0
- package/dist/schemas/profile-presentation.js +36 -0
- package/dist/schemas/profile-presentation.js.map +1 -0
- package/dist/schemas/profile-project.js +48 -0
- package/dist/schemas/profile-project.js.map +1 -0
- package/dist/schemas/profile-publication.js +30 -0
- package/dist/schemas/profile-publication.js.map +1 -0
- package/dist/schemas/profile-self.js +22 -0
- package/dist/schemas/profile-self.js.map +1 -0
- package/dist/schemas/profile-skill.js +13 -0
- package/dist/schemas/profile-skill.js.map +1 -0
- package/dist/schemas/profile-volunteering.js +20 -0
- package/dist/schemas/profile-volunteering.js.map +1 -0
- package/dist/schemas/shared.js +56 -0
- package/dist/schemas/shared.js.map +1 -0
- package/dist/schemas/write/certification.js +16 -0
- package/dist/schemas/write/certification.js.map +1 -0
- package/dist/schemas/write/course.js +36 -0
- package/dist/schemas/write/course.js.map +1 -0
- package/dist/schemas/write/education.js +18 -0
- package/dist/schemas/write/education.js.map +1 -0
- package/dist/schemas/write/external-account.js +13 -0
- package/dist/schemas/write/external-account.js.map +1 -0
- package/dist/schemas/write/honor.js +14 -0
- package/dist/schemas/write/honor.js.map +1 -0
- package/dist/schemas/write/index.d.ts +1 -1
- package/dist/schemas/write/index.js +89 -593
- package/dist/schemas/write/index.js.map +1 -1
- package/dist/schemas/write/investment.js +32 -0
- package/dist/schemas/write/investment.js.map +1 -0
- package/dist/schemas/write/involvement.js +34 -0
- package/dist/schemas/write/involvement.js.map +1 -0
- package/dist/schemas/write/language.js +10 -0
- package/dist/schemas/write/language.js.map +1 -0
- package/dist/schemas/write/org-claim.js +56 -0
- package/dist/schemas/write/org-claim.js.map +1 -0
- package/dist/schemas/write/org-employment-attestation.js +19 -0
- package/dist/schemas/write/org-employment-attestation.js.map +1 -0
- package/dist/schemas/write/org-profile.js +54 -0
- package/dist/schemas/write/org-profile.js.map +1 -0
- package/dist/schemas/write/org-settings.js +81 -0
- package/dist/schemas/write/org-settings.js.map +1 -0
- package/dist/schemas/write/position.js +24 -0
- package/dist/schemas/write/position.js.map +1 -0
- package/dist/schemas/write/presentation-delivery.js +34 -0
- package/dist/schemas/write/presentation-delivery.js.map +1 -0
- package/dist/schemas/write/presentation.js +23 -0
- package/dist/schemas/write/presentation.js.map +1 -0
- package/dist/schemas/write/profile-location.js +21 -0
- package/dist/schemas/write/profile-location.js.map +1 -0
- package/dist/schemas/write/profile-self.js +27 -0
- package/dist/schemas/write/profile-self.js.map +1 -0
- package/dist/schemas/write/project.js +27 -0
- package/dist/schemas/write/project.js.map +1 -0
- package/dist/schemas/write/publication.js +41 -0
- package/dist/schemas/write/publication.js.map +1 -0
- package/dist/schemas/write/shared.js +96 -0
- package/dist/schemas/write/shared.js.map +1 -0
- package/dist/schemas/write/skill.js +18 -0
- package/dist/schemas/write/skill.js.map +1 -0
- package/dist/schemas/write/volunteering.js +16 -0
- package/dist/schemas/write/volunteering.js.map +1 -0
- package/dist/stream/activity-item.js +1 -0
- package/dist/stream/activity-item.js.map +1 -0
- package/dist/stream/index.js +49 -0
- package/dist/stream/index.js.map +1 -0
- package/dist/stream/stream-card-vm-schema.js +265 -0
- package/dist/stream/stream-card-vm-schema.js.map +1 -0
- package/dist/stream/stream-card-vm.js +1 -0
- package/dist/stream/stream-card-vm.js.map +1 -0
- package/dist/stream/to-stream-card-vm.js +793 -0
- package/dist/stream/to-stream-card-vm.js.map +1 -0
- package/dist/stream/two-tier.js +30 -0
- package/dist/stream/two-tier.js.map +1 -0
- package/dist/stream/verbs.js +120 -0
- package/dist/stream/verbs.js.map +1 -0
- package/dist/taxonomy/activity-tiers.js +956 -0
- package/dist/taxonomy/activity-tiers.js.map +1 -0
- package/dist/taxonomy/app-categories.js +42 -0
- package/dist/taxonomy/app-categories.js.map +1 -0
- package/dist/taxonomy/app-category-map.js +166 -0
- package/dist/taxonomy/app-category-map.js.map +1 -0
- package/dist/taxonomy/artifact-link-kind.js +29 -0
- package/dist/taxonomy/artifact-link-kind.js.map +1 -0
- package/dist/taxonomy/calendar-event.js +28 -0
- package/dist/taxonomy/calendar-event.js.map +1 -0
- package/dist/taxonomy/continents.js +215 -0
- package/dist/taxonomy/continents.js.map +1 -0
- package/dist/taxonomy/countries.js +203 -0
- package/dist/taxonomy/countries.js.map +1 -0
- package/dist/taxonomy/course-role.js +37 -0
- package/dist/taxonomy/course-role.js.map +1 -0
- package/dist/taxonomy/employment-type.js +82 -0
- package/dist/taxonomy/employment-type.js.map +1 -0
- package/dist/taxonomy/eqf-level.js +59 -0
- package/dist/taxonomy/eqf-level.js.map +1 -0
- package/dist/taxonomy/index.js +263 -0
- package/dist/taxonomy/index.js.map +1 -0
- package/dist/taxonomy/industry-taxonomy.js +281 -0
- package/dist/taxonomy/industry-taxonomy.js.map +1 -0
- package/dist/taxonomy/investment.js +54 -0
- package/dist/taxonomy/investment.js.map +1 -0
- package/dist/taxonomy/involvement-kind.js +30 -0
- package/dist/taxonomy/involvement-kind.js.map +1 -0
- package/dist/taxonomy/open-to.js +128 -0
- package/dist/taxonomy/open-to.js.map +1 -0
- package/dist/taxonomy/platforms.js +56 -0
- package/dist/taxonomy/platforms.js.map +1 -0
- package/dist/taxonomy/presentation-link-type.js +22 -0
- package/dist/taxonomy/presentation-link-type.js.map +1 -0
- package/dist/taxonomy/presentation-role.js +21 -0
- package/dist/taxonomy/presentation-role.js.map +1 -0
- package/dist/taxonomy/publication-type.js +54 -0
- package/dist/taxonomy/publication-type.js.map +1 -0
- package/dist/taxonomy/relational.js +25 -0
- package/dist/taxonomy/relational.js.map +1 -0
- package/dist/taxonomy/search-filter-defs.js +66 -0
- package/dist/taxonomy/search-filter-defs.js.map +1 -0
- package/dist/taxonomy/skill-categories.js +28 -0
- package/dist/taxonomy/skill-categories.js.map +1 -0
- package/dist/taxonomy/skill-display-groups.js +12 -0
- package/dist/taxonomy/skill-display-groups.js.map +1 -0
- package/dist/taxonomy/skill-grouping.js +90 -0
- package/dist/taxonomy/skill-grouping.js.map +1 -0
- package/dist/taxonomy/verification-providers.js +69 -0
- package/dist/taxonomy/verification-providers.js.map +1 -0
- package/dist/taxonomy/workplace-type.js +38 -0
- package/dist/taxonomy/workplace-type.js.map +1 -0
- package/dist/tokens/colors.js +11 -0
- package/dist/tokens/colors.js.map +1 -0
- package/dist/tokens/icons.js +15 -0
- package/dist/tokens/icons.js.map +1 -0
- package/dist/tokens/index.js +10 -39
- package/dist/tokens/index.js.map +1 -1
- package/dist/tokens/typography.js +23 -0
- package/dist/tokens/typography.js.map +1 -0
- package/dist/types/index.js +10 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/profile-view.js +1 -0
- package/dist/types/profile-view.js.map +1 -0
- package/dist/{use-org-notification-emails-0hjt-dEw.d.ts → use-org-notification-emails-CWWi1D8t.d.ts} +2 -2
- package/package.json +4 -3
|
@@ -1,3557 +1,285 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
// src/query/hooks/index.ts
|
|
2
|
+
import { SifaProvider, useSifaConfig } from "../config.js";
|
|
3
|
+
import { useAtFundLink, useProfile } from "./use-profile.js";
|
|
4
|
+
import { useGetProfileView } from "./use-get-profile-view.js";
|
|
5
|
+
import {
|
|
6
|
+
useDeleteAvatarOverride,
|
|
7
|
+
useDeleteNamePronunciationAudio,
|
|
8
|
+
useRefreshPds,
|
|
9
|
+
useUpdateProfileOverride,
|
|
10
|
+
useUpdateProfileSelf,
|
|
11
|
+
useUploadAvatar,
|
|
12
|
+
useUploadNamePronunciationAudio
|
|
13
|
+
} from "./use-profile-mutations.js";
|
|
14
|
+
import { useCreatePosition } from "./use-create-position.js";
|
|
15
|
+
import {
|
|
16
|
+
useDeletePosition,
|
|
17
|
+
useLinkSkillToPosition,
|
|
18
|
+
useSetPositionPrimary,
|
|
19
|
+
useUnlinkSkillFromPosition,
|
|
20
|
+
useUnsetPositionPrimary,
|
|
21
|
+
useUpdatePosition
|
|
22
|
+
} from "./use-position-mutations.js";
|
|
23
|
+
import {
|
|
24
|
+
useCreateEducation,
|
|
25
|
+
useDeleteEducation,
|
|
26
|
+
useUpdateEducation
|
|
27
|
+
} from "./use-education-mutations.js";
|
|
28
|
+
import { useSetSectionPrimary, useUnsetSectionPrimary } from "./use-section-primary-mutations.js";
|
|
29
|
+
import {
|
|
30
|
+
useCreateSkill,
|
|
31
|
+
useDeleteSkill,
|
|
32
|
+
useUpdateSkill,
|
|
33
|
+
useUpdateSkillSubCategories
|
|
34
|
+
} from "./use-skill-mutations.js";
|
|
35
|
+
import {
|
|
36
|
+
useCreateRecord,
|
|
37
|
+
useDeleteRecord,
|
|
38
|
+
useUpdateRecord
|
|
39
|
+
} from "./use-record-mutations.js";
|
|
40
|
+
import {
|
|
41
|
+
useCreateProfileLocation,
|
|
42
|
+
useDeleteProfileLocation,
|
|
43
|
+
useUpdateProfileLocation
|
|
44
|
+
} from "./use-location-mutations.js";
|
|
45
|
+
import {
|
|
46
|
+
useCreateExternalAccount,
|
|
47
|
+
useDeleteExternalAccount,
|
|
48
|
+
useExternalAccounts,
|
|
49
|
+
useSetExternalAccountPrimary,
|
|
50
|
+
useUnsetExternalAccountPrimary,
|
|
51
|
+
useUpdateExternalAccount,
|
|
52
|
+
useVerifyExternalAccount
|
|
53
|
+
} from "./use-external-accounts.js";
|
|
54
|
+
import { useCreateEndorsement } from "./use-endorsement-mutations.js";
|
|
55
|
+
import {
|
|
56
|
+
usePendingConfirmations,
|
|
57
|
+
useGivenConfirmations,
|
|
58
|
+
useCreateConfirmation,
|
|
59
|
+
useDismissConfirmation,
|
|
60
|
+
useRevokeConfirmation
|
|
61
|
+
} from "./use-confirmations.js";
|
|
62
|
+
import { useInboxCounts } from "./use-inbox.js";
|
|
63
|
+
import { useUnlinkedPositions, useDismissUnlinkedPosition } from "./use-unlinked-positions.js";
|
|
64
|
+
import { useProfileCompleteness } from "./use-profile-completeness.js";
|
|
65
|
+
import { useHideKeytraceClaim, useUnhideKeytraceClaim } from "./use-keytrace-claims.js";
|
|
66
|
+
import { useRevealMarqueDomain, useUnrevealMarqueDomain } from "./use-marque-domains.js";
|
|
67
|
+
import {
|
|
68
|
+
useBulkHideStandardPublications,
|
|
69
|
+
useBulkUnhideStandardPublications,
|
|
70
|
+
useHideOrcidPublication,
|
|
71
|
+
useHideSifaPublication,
|
|
72
|
+
useHideStandardPublication,
|
|
73
|
+
useRefreshOrcidPublications,
|
|
74
|
+
useUnhideOrcidPublication,
|
|
75
|
+
useUnhideSifaPublication,
|
|
76
|
+
useUnhideStandardPublication
|
|
77
|
+
} from "./use-publication-mutations.js";
|
|
78
|
+
import {
|
|
79
|
+
useBulkHideProfileItems,
|
|
80
|
+
useBulkUnhideProfileItems,
|
|
81
|
+
useHideProfileItem,
|
|
82
|
+
useUnhideProfileItem
|
|
83
|
+
} from "./use-profile-items-hide.js";
|
|
84
|
+
import {
|
|
85
|
+
useHiddenActivityItems,
|
|
86
|
+
useHideActivityItem,
|
|
87
|
+
useUnhideActivityItem
|
|
88
|
+
} from "./use-activity-items-hide.js";
|
|
89
|
+
import { useStats } from "./use-stats.js";
|
|
90
|
+
import { useAppsRegistry, useHiddenApps } from "./use-apps.js";
|
|
91
|
+
import { useAccounts } from "./use-accounts.js";
|
|
92
|
+
import {
|
|
93
|
+
useCanonicalSkillSearch,
|
|
94
|
+
useSearchCompanies,
|
|
95
|
+
useSearchFilters,
|
|
96
|
+
useSearchProfiles,
|
|
97
|
+
useSkillSuggestions
|
|
98
|
+
} from "./use-search.js";
|
|
99
|
+
import {
|
|
100
|
+
useFeaturedProfile,
|
|
101
|
+
useSimilarProfiles,
|
|
102
|
+
useSuggestionCount,
|
|
103
|
+
useSuggestions
|
|
104
|
+
} from "./use-discovery.js";
|
|
105
|
+
import {
|
|
106
|
+
useFollow,
|
|
107
|
+
useFollowers,
|
|
108
|
+
useFollowing,
|
|
109
|
+
useFollowingFeed,
|
|
110
|
+
useFollowingList,
|
|
111
|
+
useUnfollow
|
|
112
|
+
} from "./use-follow.js";
|
|
113
|
+
import { useBlueskySuggestions, useMutuals } from "./use-follow-extras.js";
|
|
114
|
+
import {
|
|
115
|
+
useAddFeatureAllowlist,
|
|
116
|
+
useFeatureAllowlist,
|
|
117
|
+
useRemoveFeatureAllowlist
|
|
118
|
+
} from "./use-feature-allowlist.js";
|
|
119
|
+
import { useAdminReviewQueues } from "./use-admin-review-queues.js";
|
|
120
|
+
import { useActivityFeed, useActivityTeaser, useHeatmapData } from "./use-activity.js";
|
|
121
|
+
import { useMyGithubPullRequests } from "./use-github-prs.js";
|
|
122
|
+
import { useEndorsementCount } from "./use-endorsement.js";
|
|
123
|
+
import { useNetworkStreamCount } from "./use-stream.js";
|
|
124
|
+
import { useAppAccountCheck, useReactionStatus } from "./use-reactions.js";
|
|
125
|
+
import {
|
|
126
|
+
useCreateReaction,
|
|
127
|
+
useDeleteReaction
|
|
128
|
+
} from "./use-reaction-mutations.js";
|
|
129
|
+
import { useMyRoadmapVotes, useRoadmapVotes } from "./use-roadmap.js";
|
|
130
|
+
import { useCastRoadmapVote, useRetractRoadmapVote } from "./use-roadmap-mutations.js";
|
|
131
|
+
import { useDeleteAccount, useResetProfile, useWipePreview } from "./use-destructive.js";
|
|
132
|
+
import { useDeleteRepoRecords, useRepoInventory } from "./use-repo-inventory.js";
|
|
133
|
+
import {
|
|
134
|
+
useEntitySearch,
|
|
135
|
+
useSelectEntity,
|
|
136
|
+
useImportSearchEntities,
|
|
137
|
+
useDebouncedValue
|
|
138
|
+
} from "./use-entity-search.js";
|
|
139
|
+
import { useOrgProfile } from "./use-org-profile.js";
|
|
140
|
+
import { useOrgClaim } from "./use-org-claim.js";
|
|
141
|
+
import { useUpdateOrgProfile } from "./use-org-profile-settings.js";
|
|
142
|
+
import { useOrgDomainChallenge, useOrgDomainVerify } from "./use-org-domains.js";
|
|
143
|
+
import {
|
|
144
|
+
useAddOrgNotificationEmail,
|
|
145
|
+
useRemoveOrgNotificationEmail
|
|
146
|
+
} from "./use-org-notification-emails.js";
|
|
147
|
+
import { sifaQueryKeys } from "../keys.js";
|
|
148
|
+
import {
|
|
149
|
+
useCreateInvestment,
|
|
150
|
+
useUpdateInvestment,
|
|
151
|
+
useDeleteInvestment
|
|
152
|
+
} from "./use-investment-mutations.js";
|
|
153
|
+
export {
|
|
154
|
+
SifaProvider,
|
|
155
|
+
sifaQueryKeys,
|
|
156
|
+
useAccounts,
|
|
157
|
+
useActivityFeed,
|
|
158
|
+
useActivityTeaser,
|
|
159
|
+
useAddFeatureAllowlist,
|
|
160
|
+
useAddOrgNotificationEmail,
|
|
161
|
+
useAdminReviewQueues,
|
|
162
|
+
useAppAccountCheck,
|
|
163
|
+
useAppsRegistry,
|
|
164
|
+
useAtFundLink,
|
|
165
|
+
useBlueskySuggestions,
|
|
166
|
+
useBulkHideProfileItems,
|
|
167
|
+
useBulkHideStandardPublications,
|
|
168
|
+
useBulkUnhideProfileItems,
|
|
169
|
+
useBulkUnhideStandardPublications,
|
|
170
|
+
useCanonicalSkillSearch,
|
|
171
|
+
useCastRoadmapVote,
|
|
172
|
+
useCreateConfirmation,
|
|
173
|
+
useCreateEducation,
|
|
174
|
+
useCreateEndorsement,
|
|
175
|
+
useCreateExternalAccount,
|
|
176
|
+
useCreateInvestment,
|
|
177
|
+
useCreatePosition,
|
|
178
|
+
useCreateProfileLocation,
|
|
179
|
+
useCreateReaction,
|
|
180
|
+
useCreateRecord,
|
|
181
|
+
useCreateSkill,
|
|
182
|
+
useDebouncedValue,
|
|
183
|
+
useDeleteAccount,
|
|
184
|
+
useDeleteAvatarOverride,
|
|
185
|
+
useDeleteEducation,
|
|
186
|
+
useDeleteExternalAccount,
|
|
187
|
+
useDeleteInvestment,
|
|
188
|
+
useDeleteNamePronunciationAudio,
|
|
189
|
+
useDeletePosition,
|
|
190
|
+
useDeleteProfileLocation,
|
|
191
|
+
useDeleteReaction,
|
|
192
|
+
useDeleteRecord,
|
|
193
|
+
useDeleteRepoRecords,
|
|
194
|
+
useDeleteSkill,
|
|
195
|
+
useDismissConfirmation,
|
|
196
|
+
useDismissUnlinkedPosition,
|
|
197
|
+
useEndorsementCount,
|
|
198
|
+
useEntitySearch,
|
|
199
|
+
useExternalAccounts,
|
|
200
|
+
useFeatureAllowlist,
|
|
201
|
+
useFeaturedProfile,
|
|
202
|
+
useFollow,
|
|
203
|
+
useFollowers,
|
|
204
|
+
useFollowing,
|
|
205
|
+
useFollowingFeed,
|
|
206
|
+
useFollowingList,
|
|
207
|
+
useGetProfileView,
|
|
208
|
+
useGivenConfirmations,
|
|
209
|
+
useHeatmapData,
|
|
210
|
+
useHiddenActivityItems,
|
|
211
|
+
useHiddenApps,
|
|
212
|
+
useHideActivityItem,
|
|
213
|
+
useHideKeytraceClaim,
|
|
214
|
+
useHideOrcidPublication,
|
|
215
|
+
useHideProfileItem,
|
|
216
|
+
useHideSifaPublication,
|
|
217
|
+
useHideStandardPublication,
|
|
218
|
+
useImportSearchEntities,
|
|
219
|
+
useInboxCounts,
|
|
220
|
+
useLinkSkillToPosition,
|
|
221
|
+
useMutuals,
|
|
222
|
+
useMyGithubPullRequests,
|
|
223
|
+
useMyRoadmapVotes,
|
|
224
|
+
useNetworkStreamCount,
|
|
225
|
+
useOrgClaim,
|
|
226
|
+
useOrgDomainChallenge,
|
|
227
|
+
useOrgDomainVerify,
|
|
228
|
+
useOrgProfile,
|
|
229
|
+
usePendingConfirmations,
|
|
230
|
+
useProfile,
|
|
231
|
+
useProfileCompleteness,
|
|
232
|
+
useReactionStatus,
|
|
233
|
+
useRefreshOrcidPublications,
|
|
234
|
+
useRefreshPds,
|
|
235
|
+
useRemoveFeatureAllowlist,
|
|
236
|
+
useRemoveOrgNotificationEmail,
|
|
237
|
+
useRepoInventory,
|
|
238
|
+
useResetProfile,
|
|
239
|
+
useRetractRoadmapVote,
|
|
240
|
+
useRevealMarqueDomain,
|
|
241
|
+
useRevokeConfirmation,
|
|
242
|
+
useRoadmapVotes,
|
|
243
|
+
useSearchCompanies,
|
|
244
|
+
useSearchFilters,
|
|
245
|
+
useSearchProfiles,
|
|
246
|
+
useSelectEntity,
|
|
247
|
+
useSetExternalAccountPrimary,
|
|
248
|
+
useSetPositionPrimary,
|
|
249
|
+
useSetSectionPrimary,
|
|
250
|
+
useSifaConfig,
|
|
251
|
+
useSimilarProfiles,
|
|
252
|
+
useSkillSuggestions,
|
|
253
|
+
useStats,
|
|
254
|
+
useSuggestionCount,
|
|
255
|
+
useSuggestions,
|
|
256
|
+
useUnfollow,
|
|
257
|
+
useUnhideActivityItem,
|
|
258
|
+
useUnhideKeytraceClaim,
|
|
259
|
+
useUnhideOrcidPublication,
|
|
260
|
+
useUnhideProfileItem,
|
|
261
|
+
useUnhideSifaPublication,
|
|
262
|
+
useUnhideStandardPublication,
|
|
263
|
+
useUnlinkSkillFromPosition,
|
|
264
|
+
useUnlinkedPositions,
|
|
265
|
+
useUnrevealMarqueDomain,
|
|
266
|
+
useUnsetExternalAccountPrimary,
|
|
267
|
+
useUnsetPositionPrimary,
|
|
268
|
+
useUnsetSectionPrimary,
|
|
269
|
+
useUpdateEducation,
|
|
270
|
+
useUpdateExternalAccount,
|
|
271
|
+
useUpdateInvestment,
|
|
272
|
+
useUpdateOrgProfile,
|
|
273
|
+
useUpdatePosition,
|
|
274
|
+
useUpdateProfileLocation,
|
|
275
|
+
useUpdateProfileOverride,
|
|
276
|
+
useUpdateProfileSelf,
|
|
277
|
+
useUpdateRecord,
|
|
278
|
+
useUpdateSkill,
|
|
279
|
+
useUpdateSkillSubCategories,
|
|
280
|
+
useUploadAvatar,
|
|
281
|
+
useUploadNamePronunciationAudio,
|
|
282
|
+
useVerifyExternalAccount,
|
|
283
|
+
useWipePreview
|
|
31
284
|
};
|
|
32
|
-
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
33
|
-
var MAX_RATE_LIMIT_RETRIES = 3;
|
|
34
|
-
var RATE_LIMIT_RETRY_CAP_SECONDS = 3;
|
|
35
|
-
function encodeIdentifier(value) {
|
|
36
|
-
let decoded = value;
|
|
37
|
-
try {
|
|
38
|
-
decoded = decodeURIComponent(value);
|
|
39
|
-
} catch {
|
|
40
|
-
}
|
|
41
|
-
return encodeURIComponent(decoded);
|
|
42
|
-
}
|
|
43
|
-
async function apiFetch(config, path, options = {}) {
|
|
44
|
-
const fetchFn = config.fetch ?? globalThis.fetch;
|
|
45
|
-
const url = `${config.baseUrl}${path}`;
|
|
46
|
-
const maxRetries = options.retryOn429 ? MAX_RATE_LIMIT_RETRIES : 0;
|
|
47
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
48
|
-
const signal = options.signal ?? AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
49
|
-
const headers = { ...options.headers ?? {} };
|
|
50
|
-
let body;
|
|
51
|
-
if (options.body !== void 0) {
|
|
52
|
-
headers["Content-Type"] ??= "application/json";
|
|
53
|
-
body = JSON.stringify(options.body);
|
|
54
|
-
}
|
|
55
|
-
const init = {
|
|
56
|
-
method: options.method ?? "GET",
|
|
57
|
-
headers,
|
|
58
|
-
body,
|
|
59
|
-
signal,
|
|
60
|
-
credentials: options.credentials,
|
|
61
|
-
cache: options.cache,
|
|
62
|
-
...options.next ? { next: options.next } : {}
|
|
63
|
-
};
|
|
64
|
-
const res = await fetchFn(url, init);
|
|
65
|
-
if (res.status === 429 && attempt < maxRetries) {
|
|
66
|
-
const retryAfterRaw = res.headers.get("retry-after");
|
|
67
|
-
const retryAfter = retryAfterRaw ? Number.parseInt(retryAfterRaw, 10) : 2;
|
|
68
|
-
const waitSeconds = Math.min(
|
|
69
|
-
Number.isFinite(retryAfter) ? retryAfter : 2,
|
|
70
|
-
RATE_LIMIT_RETRY_CAP_SECONDS
|
|
71
|
-
);
|
|
72
|
-
await new Promise((r) => setTimeout(r, waitSeconds * 1e3));
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
if (!res.ok) {
|
|
76
|
-
let errBody;
|
|
77
|
-
try {
|
|
78
|
-
errBody = await res.json();
|
|
79
|
-
} catch {
|
|
80
|
-
try {
|
|
81
|
-
errBody = await res.text();
|
|
82
|
-
} catch {
|
|
83
|
-
errBody = void 0;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
throw new ApiError(`Sifa API ${res.status} on ${path}`, res.status, errBody);
|
|
87
|
-
}
|
|
88
|
-
if (res.status === 204 || res.status === 205) {
|
|
89
|
-
return void 0;
|
|
90
|
-
}
|
|
91
|
-
return await res.json();
|
|
92
|
-
}
|
|
93
|
-
throw new ApiError(`Sifa API exhausted retries on ${path}`, 429);
|
|
94
|
-
}
|
|
95
|
-
async function apiFetchOrNull(config, path, options = {}) {
|
|
96
|
-
try {
|
|
97
|
-
return await apiFetch(config, path, options);
|
|
98
|
-
} catch (e) {
|
|
99
|
-
if (e instanceof ApiError && e.status === 404) return null;
|
|
100
|
-
throw e;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function extractWriteError(data, status) {
|
|
104
|
-
const body = data ?? {};
|
|
105
|
-
return {
|
|
106
|
-
error: body.message ?? `Request failed (${status})`,
|
|
107
|
-
...body.pdsHost ? { pdsHost: body.pdsHost } : {}
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
async function apiWrite(config, path, method, options = {}) {
|
|
111
|
-
try {
|
|
112
|
-
const data = await apiFetch(config, path, {
|
|
113
|
-
method,
|
|
114
|
-
credentials: "include",
|
|
115
|
-
...options
|
|
116
|
-
});
|
|
117
|
-
return { success: true, ...data ?? {} };
|
|
118
|
-
} catch (e) {
|
|
119
|
-
if (e instanceof ApiError) {
|
|
120
|
-
return { success: false, ...extractWriteError(e.body, e.status) };
|
|
121
|
-
}
|
|
122
|
-
return { success: false, error: "Network error" };
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
function apiWriteCreate(config, path, body, options = {}) {
|
|
126
|
-
return apiWrite(config, path, "POST", {
|
|
127
|
-
body,
|
|
128
|
-
...options
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// src/query/fetchers/profile.ts
|
|
133
|
-
function fetchProfile(config, handleOrDid, options = {}) {
|
|
134
|
-
const path = `/api/profile/${encodeIdentifier(handleOrDid)}`;
|
|
135
|
-
return apiFetchOrNull(config, path, {
|
|
136
|
-
retryOn429: true,
|
|
137
|
-
...options
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
async function fetchAtFundLink(config, did, options = {}) {
|
|
141
|
-
const path = `/api/profiles/${encodeIdentifier(did)}/at-fund-link`;
|
|
142
|
-
try {
|
|
143
|
-
const data = await apiFetch(config, path, {
|
|
144
|
-
next: { revalidate: 3600 },
|
|
145
|
-
timeoutMs: 5e3,
|
|
146
|
-
...options
|
|
147
|
-
});
|
|
148
|
-
return typeof data.url === "string" ? data.url : null;
|
|
149
|
-
} catch {
|
|
150
|
-
return null;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// src/query/keys.ts
|
|
155
|
-
var sifaQueryKeys = {
|
|
156
|
-
all: () => ["sifa"],
|
|
157
|
-
profile: {
|
|
158
|
-
all: () => ["sifa", "profile"],
|
|
159
|
-
byHandle: (handleOrDid) => ["sifa", "profile", handleOrDid],
|
|
160
|
-
atFundLink: (did) => ["sifa", "profile", "at-fund-link", did],
|
|
161
|
-
view: (actor) => ["sifa", "profile", "view", actor],
|
|
162
|
-
externalAccounts: (handleOrDid) => ["sifa", "profile", "external-accounts", handleOrDid],
|
|
163
|
-
// Session-scoped: the AppView reads the owner from the session cookie, so
|
|
164
|
-
// there is only ever one completeness result per client.
|
|
165
|
-
completeness: () => ["sifa", "profile", "completeness"]
|
|
166
|
-
},
|
|
167
|
-
position: {
|
|
168
|
-
all: () => ["sifa", "position"],
|
|
169
|
-
byOwner: (did) => ["sifa", "position", "by-owner", did],
|
|
170
|
-
// Session-scoped: the AppView reads the owner from the session cookie.
|
|
171
|
-
unlinked: () => ["sifa", "position", "unlinked"]
|
|
172
|
-
},
|
|
173
|
-
// Aggregate inbox counts for the header bell badge (session-scoped). The first
|
|
174
|
-
// aggregate namespace: it fans in across confirmations, endorsements, drift,
|
|
175
|
-
// unlinked positions and profile completeness on the server.
|
|
176
|
-
inbox: {
|
|
177
|
-
all: () => ["sifa", "inbox"],
|
|
178
|
-
counts: () => ["sifa", "inbox", "counts"]
|
|
179
|
-
},
|
|
180
|
-
search: {
|
|
181
|
-
all: () => ["sifa", "search"],
|
|
182
|
-
profiles: (filters) => ["sifa", "search", "profiles", filters],
|
|
183
|
-
companies: (filters) => ["sifa", "search", "companies", filters],
|
|
184
|
-
skills: (query) => ["sifa", "search", "skills", query],
|
|
185
|
-
canonicalSkills: (query, limit) => ["sifa", "search", "canonical-skills", query, limit],
|
|
186
|
-
filters: () => ["sifa", "search", "filters"]
|
|
187
|
-
},
|
|
188
|
-
entity: {
|
|
189
|
-
all: () => ["sifa", "entity"],
|
|
190
|
-
search: (query, limit) => ["sifa", "entity", "search", query, limit]
|
|
191
|
-
},
|
|
192
|
-
discovery: {
|
|
193
|
-
all: () => ["sifa", "discovery"],
|
|
194
|
-
similar: (did, limit) => ["sifa", "discovery", "similar", did, limit],
|
|
195
|
-
suggestions: (opts) => ["sifa", "discovery", "suggestions", opts],
|
|
196
|
-
suggestionCount: (since) => ["sifa", "discovery", "suggestion-count", since ?? null],
|
|
197
|
-
featured: () => ["sifa", "discovery", "featured"]
|
|
198
|
-
},
|
|
199
|
-
follow: {
|
|
200
|
-
all: () => ["sifa", "follow"],
|
|
201
|
-
following: (opts) => ["sifa", "follow", "following", opts],
|
|
202
|
-
followers: (handle) => ["sifa", "follow", "followers", handle],
|
|
203
|
-
followingOf: (handle) => ["sifa", "follow", "following-of", handle],
|
|
204
|
-
feed: (opts) => ["sifa", "follow", "feed", opts],
|
|
205
|
-
mutuals: (handle) => ["sifa", "follow", "mutuals", handle],
|
|
206
|
-
blueskySuggestions: () => ["sifa", "follow", "bluesky-suggestions"]
|
|
207
|
-
},
|
|
208
|
-
admin: {
|
|
209
|
-
all: () => ["sifa", "admin"],
|
|
210
|
-
featureAllowlist: (flag) => ["sifa", "admin", "feature-allowlist", flag],
|
|
211
|
-
reviewQueues: () => ["sifa", "admin", "review-queues"]
|
|
212
|
-
},
|
|
213
|
-
stats: {
|
|
214
|
-
all: () => ["sifa", "stats"],
|
|
215
|
-
homepage: () => ["sifa", "stats", "homepage"]
|
|
216
|
-
},
|
|
217
|
-
apps: {
|
|
218
|
-
all: () => ["sifa", "apps"],
|
|
219
|
-
registry: () => ["sifa", "apps", "registry"],
|
|
220
|
-
hidden: () => ["sifa", "apps", "hidden"]
|
|
221
|
-
},
|
|
222
|
-
auth: {
|
|
223
|
-
all: () => ["sifa", "auth"],
|
|
224
|
-
// Session-scoped: the AppView reads the account list from the browser's
|
|
225
|
-
// cookies, so there is only ever one list per client.
|
|
226
|
-
accounts: () => ["sifa", "auth", "accounts"]
|
|
227
|
-
},
|
|
228
|
-
activity: {
|
|
229
|
-
all: () => ["sifa", "activity"],
|
|
230
|
-
heatmap: (handleOrDid, days) => ["sifa", "activity", "heatmap", handleOrDid, days],
|
|
231
|
-
teaser: (handleOrDid) => ["sifa", "activity", "teaser", handleOrDid],
|
|
232
|
-
feed: (handleOrDid, opts) => ["sifa", "activity", "feed", handleOrDid, opts],
|
|
233
|
-
// Session-scoped: the AppView reads the caller's own hides from their
|
|
234
|
-
// cookie, so there is only ever one list per client.
|
|
235
|
-
hiddenItems: () => ["sifa", "activity", "hidden-items"]
|
|
236
|
-
},
|
|
237
|
-
github: {
|
|
238
|
-
all: () => ["sifa", "github"],
|
|
239
|
-
myPullRequests: (opts) => ["sifa", "github", "my-pull-requests", opts]
|
|
240
|
-
},
|
|
241
|
-
endorsement: {
|
|
242
|
-
all: () => ["sifa", "endorsement"],
|
|
243
|
-
count: (did) => ["sifa", "endorsement", "count", did],
|
|
244
|
-
// Scoped to the session rather than a DID -- the AppView reads the subject
|
|
245
|
-
// from the session cookie, so there is only ever one inbox per client.
|
|
246
|
-
pending: () => ["sifa", "endorsement", "pending"],
|
|
247
|
-
// Also session-scoped: the AppView picks the candidate from the viewer's
|
|
248
|
-
// own follows, dismissals and blocks.
|
|
249
|
-
reciprocity: () => ["sifa", "endorsement", "reciprocity"],
|
|
250
|
-
received: (did) => ["sifa", "endorsement", "received", did]
|
|
251
|
-
},
|
|
252
|
-
confirmation: {
|
|
253
|
-
all: () => ["sifa", "confirmation"],
|
|
254
|
-
// Scoped to the session for the same reason as the endorsement inbox: the
|
|
255
|
-
// AppView reads the subject from the session cookie, so there is only ever
|
|
256
|
-
// one inbox per client.
|
|
257
|
-
pending: () => ["sifa", "confirmation", "pending"],
|
|
258
|
-
/** Confirmations this session has given, for the withdraw surface. */
|
|
259
|
-
given: () => ["sifa", "confirmation", "given"]
|
|
260
|
-
},
|
|
261
|
-
stream: {
|
|
262
|
-
all: () => ["sifa", "stream"],
|
|
263
|
-
networkCount: (did) => ["sifa", "stream", "network-count", did]
|
|
264
|
-
},
|
|
265
|
-
reactions: {
|
|
266
|
-
all: () => ["sifa", "reactions"],
|
|
267
|
-
status: (uris) => ["sifa", "reactions", "status", uris],
|
|
268
|
-
accountCheck: (appId) => ["sifa", "reactions", "account-check", appId]
|
|
269
|
-
},
|
|
270
|
-
roadmap: {
|
|
271
|
-
all: () => ["sifa", "roadmap"],
|
|
272
|
-
votes: () => ["sifa", "roadmap", "votes"],
|
|
273
|
-
myVotes: () => ["sifa", "roadmap", "my-votes"]
|
|
274
|
-
},
|
|
275
|
-
bskyPreferences: {
|
|
276
|
-
all: () => ["sifa", "bsky-preferences"],
|
|
277
|
-
contentLabels: () => ["sifa", "bsky-preferences", "content-labels"]
|
|
278
|
-
},
|
|
279
|
-
repoInventory: {
|
|
280
|
-
all: () => ["sifa", "repo-inventory"],
|
|
281
|
-
list: () => ["sifa", "repo-inventory", "list"]
|
|
282
|
-
},
|
|
283
|
-
destructive: {
|
|
284
|
-
all: () => ["sifa", "destructive"],
|
|
285
|
-
wipePreview: () => ["sifa", "destructive", "wipe-preview"]
|
|
286
|
-
}
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
// src/query/hooks/use-profile.ts
|
|
290
|
-
function useProfile(handleOrDid, options) {
|
|
291
|
-
const config = useSifaConfig();
|
|
292
|
-
return useQuery({
|
|
293
|
-
queryKey: sifaQueryKeys.profile.byHandle(handleOrDid ?? ""),
|
|
294
|
-
queryFn: () => fetchProfile(config, handleOrDid ?? ""),
|
|
295
|
-
enabled: Boolean(handleOrDid) && (options?.enabled ?? true),
|
|
296
|
-
...options
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
function useAtFundLink(did, options) {
|
|
300
|
-
const config = useSifaConfig();
|
|
301
|
-
return useQuery({
|
|
302
|
-
queryKey: sifaQueryKeys.profile.atFundLink(did ?? ""),
|
|
303
|
-
queryFn: () => fetchAtFundLink(config, did ?? ""),
|
|
304
|
-
enabled: Boolean(did) && (options?.enabled ?? true),
|
|
305
|
-
...options
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// src/query/fetchers/get-profile-view.ts
|
|
310
|
-
async function fetchGetProfileView(config, actor, options = {}) {
|
|
311
|
-
const path = `/xrpc/id.sifa.getProfileView?actor=${encodeIdentifier(actor)}`;
|
|
312
|
-
try {
|
|
313
|
-
return await apiFetch(config, path, { retryOn429: true, ...options });
|
|
314
|
-
} catch (e) {
|
|
315
|
-
if (e instanceof ApiError && e.status === 400 && typeof e.body === "object" && e.body !== null && e.body.error === "ProfileNotFound") {
|
|
316
|
-
return null;
|
|
317
|
-
}
|
|
318
|
-
throw e;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
// src/query/hooks/use-get-profile-view.ts
|
|
323
|
-
function useGetProfileView(actor, options) {
|
|
324
|
-
const config = useSifaConfig();
|
|
325
|
-
return useQuery({
|
|
326
|
-
queryKey: sifaQueryKeys.profile.view(actor ?? ""),
|
|
327
|
-
queryFn: () => fetchGetProfileView(config, actor ?? ""),
|
|
328
|
-
enabled: Boolean(actor) && (options?.enabled ?? true),
|
|
329
|
-
...options
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// src/query/fetchers/profile-mutations.ts
|
|
334
|
-
function updateProfileSelf(config, data, options = {}) {
|
|
335
|
-
return apiWrite(config, "/api/profile/self", "PUT", { body: data, ...options });
|
|
336
|
-
}
|
|
337
|
-
function updateProfileOverride(config, data, options = {}) {
|
|
338
|
-
return apiWrite(config, "/api/profile/override", "PUT", { body: data, ...options });
|
|
339
|
-
}
|
|
340
|
-
function refreshPds(config, options = {}) {
|
|
341
|
-
return apiWrite(
|
|
342
|
-
config,
|
|
343
|
-
"/api/profile/refresh-pds",
|
|
344
|
-
"POST",
|
|
345
|
-
options
|
|
346
|
-
);
|
|
347
|
-
}
|
|
348
|
-
async function uploadAvatar(config, file, options = {}) {
|
|
349
|
-
const fetchFn = config.fetch ?? globalThis.fetch;
|
|
350
|
-
const url = `${config.baseUrl}/api/profile/avatar`;
|
|
351
|
-
const formData = new FormData();
|
|
352
|
-
formData.append("file", file);
|
|
353
|
-
try {
|
|
354
|
-
const res = await fetchFn(url, {
|
|
355
|
-
method: "POST",
|
|
356
|
-
credentials: options.credentials ?? "include",
|
|
357
|
-
body: formData,
|
|
358
|
-
signal: options.signal ?? AbortSignal.timeout(options.timeoutMs ?? 3e4),
|
|
359
|
-
headers: options.headers
|
|
360
|
-
});
|
|
361
|
-
if (!res.ok) {
|
|
362
|
-
const errBody = await res.json().catch(() => ({}));
|
|
363
|
-
const msg = errBody.message ?? `Request failed (${res.status})`;
|
|
364
|
-
const pdsHost = errBody.pdsHost;
|
|
365
|
-
return { success: false, error: msg, ...pdsHost ? { pdsHost } : {} };
|
|
366
|
-
}
|
|
367
|
-
const data = await res.json();
|
|
368
|
-
return { success: true, url: data.url };
|
|
369
|
-
} catch {
|
|
370
|
-
return { success: false, error: "Network error" };
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
function deleteAvatarOverride(config, options = {}) {
|
|
374
|
-
return apiWrite(config, "/api/profile/avatar", "DELETE", options);
|
|
375
|
-
}
|
|
376
|
-
async function uploadNamePronunciationAudio(config, file, options = {}) {
|
|
377
|
-
const fetchFn = config.fetch ?? globalThis.fetch;
|
|
378
|
-
const url = `${config.baseUrl}/api/profile/pronunciation-audio`;
|
|
379
|
-
const formData = new FormData();
|
|
380
|
-
formData.append("file", file);
|
|
381
|
-
try {
|
|
382
|
-
const res = await fetchFn(url, {
|
|
383
|
-
method: "POST",
|
|
384
|
-
credentials: options.credentials ?? "include",
|
|
385
|
-
body: formData,
|
|
386
|
-
signal: options.signal ?? AbortSignal.timeout(options.timeoutMs ?? 3e4),
|
|
387
|
-
headers: options.headers
|
|
388
|
-
});
|
|
389
|
-
if (!res.ok) {
|
|
390
|
-
const errBody = await res.json().catch(() => ({}));
|
|
391
|
-
const msg = errBody.message ?? `Request failed (${res.status})`;
|
|
392
|
-
const pdsHost = errBody.pdsHost;
|
|
393
|
-
return { success: false, error: msg, ...pdsHost ? { pdsHost } : {} };
|
|
394
|
-
}
|
|
395
|
-
const data = await res.json();
|
|
396
|
-
return { success: true, url: data.url };
|
|
397
|
-
} catch {
|
|
398
|
-
return { success: false, error: "Network error" };
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
function deleteNamePronunciationAudio(config, options = {}) {
|
|
402
|
-
return apiWrite(config, "/api/profile/pronunciation-audio", "DELETE", options);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// src/query/hooks/use-profile-mutations.ts
|
|
406
|
-
async function invalidateProfile(queryClient, ownerHandleOrDid) {
|
|
407
|
-
await queryClient.invalidateQueries({
|
|
408
|
-
queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
function useUpdateProfileSelf(ownerHandleOrDid, options) {
|
|
412
|
-
const config = useSifaConfig();
|
|
413
|
-
const queryClient = useQueryClient();
|
|
414
|
-
return useMutation({
|
|
415
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
416
|
-
// handler below and silently drop cache invalidation (#453).
|
|
417
|
-
...options,
|
|
418
|
-
mutationFn: (data) => updateProfileSelf(config, data),
|
|
419
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
420
|
-
if (result.success) {
|
|
421
|
-
await invalidateProfile(queryClient, ownerHandleOrDid);
|
|
422
|
-
}
|
|
423
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
424
|
-
}
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
function useUpdateProfileOverride(ownerHandleOrDid, options) {
|
|
428
|
-
const config = useSifaConfig();
|
|
429
|
-
const queryClient = useQueryClient();
|
|
430
|
-
return useMutation({
|
|
431
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
432
|
-
// handler below and silently drop cache invalidation (#453).
|
|
433
|
-
...options,
|
|
434
|
-
mutationFn: (data) => updateProfileOverride(config, data),
|
|
435
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
436
|
-
if (result.success) {
|
|
437
|
-
await invalidateProfile(queryClient, ownerHandleOrDid);
|
|
438
|
-
}
|
|
439
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
440
|
-
}
|
|
441
|
-
});
|
|
442
|
-
}
|
|
443
|
-
function useRefreshPds(ownerHandleOrDid, options) {
|
|
444
|
-
const config = useSifaConfig();
|
|
445
|
-
const queryClient = useQueryClient();
|
|
446
|
-
return useMutation({
|
|
447
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
448
|
-
// handler below and silently drop cache invalidation (#453).
|
|
449
|
-
...options,
|
|
450
|
-
mutationFn: () => refreshPds(config),
|
|
451
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
452
|
-
if (result.success) {
|
|
453
|
-
await invalidateProfile(queryClient, ownerHandleOrDid);
|
|
454
|
-
}
|
|
455
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
456
|
-
}
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
function useUploadAvatar(ownerHandleOrDid, options) {
|
|
460
|
-
const config = useSifaConfig();
|
|
461
|
-
const queryClient = useQueryClient();
|
|
462
|
-
return useMutation({
|
|
463
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
464
|
-
// handler below and silently drop cache invalidation (#453).
|
|
465
|
-
...options,
|
|
466
|
-
mutationFn: (file) => uploadAvatar(config, file),
|
|
467
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
468
|
-
if (result.success) {
|
|
469
|
-
await invalidateProfile(queryClient, ownerHandleOrDid);
|
|
470
|
-
}
|
|
471
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
472
|
-
}
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
function useDeleteAvatarOverride(ownerHandleOrDid, options) {
|
|
476
|
-
const config = useSifaConfig();
|
|
477
|
-
const queryClient = useQueryClient();
|
|
478
|
-
return useMutation({
|
|
479
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
480
|
-
// handler below and silently drop cache invalidation (#453).
|
|
481
|
-
...options,
|
|
482
|
-
mutationFn: () => deleteAvatarOverride(config),
|
|
483
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
484
|
-
if (result.success) {
|
|
485
|
-
await invalidateProfile(queryClient, ownerHandleOrDid);
|
|
486
|
-
}
|
|
487
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
function useUploadNamePronunciationAudio(ownerHandleOrDid, options) {
|
|
492
|
-
const config = useSifaConfig();
|
|
493
|
-
const queryClient = useQueryClient();
|
|
494
|
-
return useMutation({
|
|
495
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
496
|
-
// handler below and silently drop cache invalidation (#453).
|
|
497
|
-
...options,
|
|
498
|
-
mutationFn: (file) => uploadNamePronunciationAudio(config, file),
|
|
499
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
500
|
-
if (result.success) {
|
|
501
|
-
await invalidateProfile(queryClient, ownerHandleOrDid);
|
|
502
|
-
}
|
|
503
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
504
|
-
}
|
|
505
|
-
});
|
|
506
|
-
}
|
|
507
|
-
function useDeleteNamePronunciationAudio(ownerHandleOrDid, options) {
|
|
508
|
-
const config = useSifaConfig();
|
|
509
|
-
const queryClient = useQueryClient();
|
|
510
|
-
return useMutation({
|
|
511
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
512
|
-
// handler below and silently drop cache invalidation (#453).
|
|
513
|
-
...options,
|
|
514
|
-
mutationFn: () => deleteNamePronunciationAudio(config),
|
|
515
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
516
|
-
if (result.success) {
|
|
517
|
-
await invalidateProfile(queryClient, ownerHandleOrDid);
|
|
518
|
-
}
|
|
519
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
520
|
-
}
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
// src/query/fetchers/positions.ts
|
|
525
|
-
function createPosition(config, data, options = {}) {
|
|
526
|
-
return apiWriteCreate(config, "/api/profile/position", data, options);
|
|
527
|
-
}
|
|
528
|
-
function updatePosition(config, rkey, data, options = {}) {
|
|
529
|
-
return apiWrite(config, `/api/profile/position/${encodeURIComponent(rkey)}`, "PUT", {
|
|
530
|
-
body: data,
|
|
531
|
-
...options
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
function deletePosition(config, rkey, options = {}) {
|
|
535
|
-
return apiWrite(config, `/api/profile/position/${encodeURIComponent(rkey)}`, "DELETE", options);
|
|
536
|
-
}
|
|
537
|
-
function setPositionPrimary(config, rkey, options = {}) {
|
|
538
|
-
return apiWrite(
|
|
539
|
-
config,
|
|
540
|
-
`/api/profile/position/${encodeURIComponent(rkey)}/primary`,
|
|
541
|
-
"PUT",
|
|
542
|
-
options
|
|
543
|
-
);
|
|
544
|
-
}
|
|
545
|
-
function unsetPositionPrimary(config, rkey, options = {}) {
|
|
546
|
-
return apiWrite(
|
|
547
|
-
config,
|
|
548
|
-
`/api/profile/position/${encodeURIComponent(rkey)}/primary`,
|
|
549
|
-
"DELETE",
|
|
550
|
-
options
|
|
551
|
-
);
|
|
552
|
-
}
|
|
553
|
-
function buildPositionPayload(position, skills) {
|
|
554
|
-
return {
|
|
555
|
-
company: position.company,
|
|
556
|
-
title: position.title,
|
|
557
|
-
description: position.description,
|
|
558
|
-
startedAt: position.startedAt,
|
|
559
|
-
endedAt: position.endedAt,
|
|
560
|
-
location: position.location ?? void 0,
|
|
561
|
-
// Carry the form-controlled optional fields the AppView merge would
|
|
562
|
-
// otherwise clear when absent from the PUT body. Omitting them here made
|
|
563
|
-
// every link/unlink strip employmentType, workplaceType, and entityRef
|
|
564
|
-
// off the position (id.sifa.profile.position#skills round-trip).
|
|
565
|
-
employmentType: position.employmentType,
|
|
566
|
-
workplaceType: position.workplaceType,
|
|
567
|
-
entityRef: position.entityRef,
|
|
568
|
-
skills
|
|
569
|
-
};
|
|
570
|
-
}
|
|
571
|
-
function linkSkillToPosition(config, position, skillRef, options = {}) {
|
|
572
|
-
const currentSkills = position.skills ?? [];
|
|
573
|
-
if (currentSkills.some((s) => s.uri === skillRef.uri)) {
|
|
574
|
-
return Promise.resolve({ success: true });
|
|
575
|
-
}
|
|
576
|
-
return updatePosition(
|
|
577
|
-
config,
|
|
578
|
-
position.rkey,
|
|
579
|
-
buildPositionPayload(position, [...currentSkills, skillRef]),
|
|
580
|
-
options
|
|
581
|
-
);
|
|
582
|
-
}
|
|
583
|
-
function unlinkSkillFromPosition(config, position, skillRef, options = {}) {
|
|
584
|
-
const remaining = (position.skills ?? []).filter((s) => s.uri !== skillRef.uri);
|
|
585
|
-
return updatePosition(config, position.rkey, buildPositionPayload(position, remaining), options);
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
// src/query/hooks/use-create-position.ts
|
|
589
|
-
function useCreatePosition(ownerDid, options) {
|
|
590
|
-
const config = useSifaConfig();
|
|
591
|
-
const queryClient = useQueryClient();
|
|
592
|
-
return useMutation({
|
|
593
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
594
|
-
// handler below and silently drop cache invalidation (#453).
|
|
595
|
-
...options,
|
|
596
|
-
mutationFn: (data) => createPosition(config, data),
|
|
597
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
598
|
-
if (result.success) {
|
|
599
|
-
await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.profile.byHandle(ownerDid) });
|
|
600
|
-
await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.position.byOwner(ownerDid) });
|
|
601
|
-
}
|
|
602
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
async function invalidatePositionCaches(queryClient, ownerHandleOrDid) {
|
|
607
|
-
await queryClient.invalidateQueries({
|
|
608
|
-
queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
|
|
609
|
-
});
|
|
610
|
-
await queryClient.invalidateQueries({
|
|
611
|
-
queryKey: sifaQueryKeys.position.byOwner(ownerHandleOrDid)
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
function useUpdatePosition(ownerHandleOrDid, options) {
|
|
615
|
-
const config = useSifaConfig();
|
|
616
|
-
const queryClient = useQueryClient();
|
|
617
|
-
return useMutation({
|
|
618
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
619
|
-
// handler below and silently drop cache invalidation (#453).
|
|
620
|
-
...options,
|
|
621
|
-
mutationFn: ({ rkey, data }) => updatePosition(config, rkey, data),
|
|
622
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
623
|
-
if (result.success) {
|
|
624
|
-
await invalidatePositionCaches(queryClient, ownerHandleOrDid);
|
|
625
|
-
}
|
|
626
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
627
|
-
}
|
|
628
|
-
});
|
|
629
|
-
}
|
|
630
|
-
function useDeletePosition(ownerHandleOrDid, options) {
|
|
631
|
-
const config = useSifaConfig();
|
|
632
|
-
const queryClient = useQueryClient();
|
|
633
|
-
return useMutation({
|
|
634
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
635
|
-
// handler below and silently drop cache invalidation (#453).
|
|
636
|
-
...options,
|
|
637
|
-
mutationFn: (rkey) => deletePosition(config, rkey),
|
|
638
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
639
|
-
if (result.success) {
|
|
640
|
-
await invalidatePositionCaches(queryClient, ownerHandleOrDid);
|
|
641
|
-
}
|
|
642
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
643
|
-
}
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
function useSetPositionPrimary(ownerHandleOrDid, options) {
|
|
647
|
-
const config = useSifaConfig();
|
|
648
|
-
const queryClient = useQueryClient();
|
|
649
|
-
return useMutation({
|
|
650
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
651
|
-
// handler below and silently drop cache invalidation (#453).
|
|
652
|
-
...options,
|
|
653
|
-
mutationFn: (rkey) => setPositionPrimary(config, rkey),
|
|
654
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
655
|
-
if (result.success) {
|
|
656
|
-
await invalidatePositionCaches(queryClient, ownerHandleOrDid);
|
|
657
|
-
}
|
|
658
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
659
|
-
}
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
function useUnsetPositionPrimary(ownerHandleOrDid, options) {
|
|
663
|
-
const config = useSifaConfig();
|
|
664
|
-
const queryClient = useQueryClient();
|
|
665
|
-
return useMutation({
|
|
666
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
667
|
-
// handler below and silently drop cache invalidation (#453).
|
|
668
|
-
...options,
|
|
669
|
-
mutationFn: (rkey) => unsetPositionPrimary(config, rkey),
|
|
670
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
671
|
-
if (result.success) {
|
|
672
|
-
await invalidatePositionCaches(queryClient, ownerHandleOrDid);
|
|
673
|
-
}
|
|
674
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
675
|
-
}
|
|
676
|
-
});
|
|
677
|
-
}
|
|
678
|
-
function useLinkSkillToPosition(ownerHandleOrDid, options) {
|
|
679
|
-
const config = useSifaConfig();
|
|
680
|
-
const queryClient = useQueryClient();
|
|
681
|
-
return useMutation({
|
|
682
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
683
|
-
// handler below and silently drop cache invalidation (#453).
|
|
684
|
-
...options,
|
|
685
|
-
mutationFn: ({ position, skillRef }) => linkSkillToPosition(config, position, skillRef),
|
|
686
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
687
|
-
if (result.success) {
|
|
688
|
-
await invalidatePositionCaches(queryClient, ownerHandleOrDid);
|
|
689
|
-
}
|
|
690
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
function useUnlinkSkillFromPosition(ownerHandleOrDid, options) {
|
|
695
|
-
const config = useSifaConfig();
|
|
696
|
-
const queryClient = useQueryClient();
|
|
697
|
-
return useMutation({
|
|
698
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
699
|
-
// handler below and silently drop cache invalidation (#453).
|
|
700
|
-
...options,
|
|
701
|
-
mutationFn: ({ position, skillRef }) => unlinkSkillFromPosition(config, position, skillRef),
|
|
702
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
703
|
-
if (result.success) {
|
|
704
|
-
await invalidatePositionCaches(queryClient, ownerHandleOrDid);
|
|
705
|
-
}
|
|
706
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
707
|
-
}
|
|
708
|
-
});
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
// src/query/fetchers/education.ts
|
|
712
|
-
function createEducation(config, data, options = {}) {
|
|
713
|
-
return apiWriteCreate(config, "/api/profile/education", data, options);
|
|
714
|
-
}
|
|
715
|
-
function updateEducation(config, rkey, data, options = {}) {
|
|
716
|
-
return apiWrite(config, `/api/profile/education/${encodeURIComponent(rkey)}`, "PUT", {
|
|
717
|
-
body: data,
|
|
718
|
-
...options
|
|
719
|
-
});
|
|
720
|
-
}
|
|
721
|
-
function deleteEducation(config, rkey, options = {}) {
|
|
722
|
-
return apiWrite(config, `/api/profile/education/${encodeURIComponent(rkey)}`, "DELETE", options);
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
// src/query/hooks/use-education-mutations.ts
|
|
726
|
-
async function invalidateProfile2(queryClient, ownerHandleOrDid) {
|
|
727
|
-
await queryClient.invalidateQueries({
|
|
728
|
-
queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
function useCreateEducation(ownerHandleOrDid, options) {
|
|
732
|
-
const config = useSifaConfig();
|
|
733
|
-
const queryClient = useQueryClient();
|
|
734
|
-
return useMutation({
|
|
735
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
736
|
-
// handler below and silently drop cache invalidation (#453).
|
|
737
|
-
...options,
|
|
738
|
-
mutationFn: (data) => createEducation(config, data),
|
|
739
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
740
|
-
if (result.success) {
|
|
741
|
-
await invalidateProfile2(queryClient, ownerHandleOrDid);
|
|
742
|
-
}
|
|
743
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
744
|
-
}
|
|
745
|
-
});
|
|
746
|
-
}
|
|
747
|
-
function useUpdateEducation(ownerHandleOrDid, options) {
|
|
748
|
-
const config = useSifaConfig();
|
|
749
|
-
const queryClient = useQueryClient();
|
|
750
|
-
return useMutation({
|
|
751
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
752
|
-
// handler below and silently drop cache invalidation (#453).
|
|
753
|
-
...options,
|
|
754
|
-
mutationFn: ({ rkey, data }) => updateEducation(config, rkey, data),
|
|
755
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
756
|
-
if (result.success) {
|
|
757
|
-
await invalidateProfile2(queryClient, ownerHandleOrDid);
|
|
758
|
-
}
|
|
759
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
760
|
-
}
|
|
761
|
-
});
|
|
762
|
-
}
|
|
763
|
-
function useDeleteEducation(ownerHandleOrDid, options) {
|
|
764
|
-
const config = useSifaConfig();
|
|
765
|
-
const queryClient = useQueryClient();
|
|
766
|
-
return useMutation({
|
|
767
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
768
|
-
// handler below and silently drop cache invalidation (#453).
|
|
769
|
-
...options,
|
|
770
|
-
mutationFn: (rkey) => deleteEducation(config, rkey),
|
|
771
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
772
|
-
if (result.success) {
|
|
773
|
-
await invalidateProfile2(queryClient, ownerHandleOrDid);
|
|
774
|
-
}
|
|
775
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
776
|
-
}
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
// src/query/fetchers/section-primary.ts
|
|
781
|
-
function setSectionPrimary(config, section, rkey, options = {}) {
|
|
782
|
-
return apiWrite(
|
|
783
|
-
config,
|
|
784
|
-
`/api/profile/${section}/${encodeURIComponent(rkey)}/primary`,
|
|
785
|
-
"PUT",
|
|
786
|
-
options
|
|
787
|
-
);
|
|
788
|
-
}
|
|
789
|
-
function unsetSectionPrimary(config, section, rkey, options = {}) {
|
|
790
|
-
return apiWrite(
|
|
791
|
-
config,
|
|
792
|
-
`/api/profile/${section}/${encodeURIComponent(rkey)}/primary`,
|
|
793
|
-
"DELETE",
|
|
794
|
-
options
|
|
795
|
-
);
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
// src/query/hooks/use-section-primary-mutations.ts
|
|
799
|
-
async function invalidateProfile3(queryClient, ownerHandleOrDid) {
|
|
800
|
-
await queryClient.invalidateQueries({
|
|
801
|
-
queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
|
|
802
|
-
});
|
|
803
|
-
}
|
|
804
|
-
function useSetSectionPrimary(section, ownerHandleOrDid, options) {
|
|
805
|
-
const config = useSifaConfig();
|
|
806
|
-
const queryClient = useQueryClient();
|
|
807
|
-
return useMutation({
|
|
808
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
809
|
-
// handler below and silently drop cache invalidation (#453).
|
|
810
|
-
...options,
|
|
811
|
-
mutationFn: (rkey) => setSectionPrimary(config, section, rkey),
|
|
812
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
813
|
-
if (result.success) {
|
|
814
|
-
await invalidateProfile3(queryClient, ownerHandleOrDid);
|
|
815
|
-
}
|
|
816
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
817
|
-
}
|
|
818
|
-
});
|
|
819
|
-
}
|
|
820
|
-
function useUnsetSectionPrimary(section, ownerHandleOrDid, options) {
|
|
821
|
-
const config = useSifaConfig();
|
|
822
|
-
const queryClient = useQueryClient();
|
|
823
|
-
return useMutation({
|
|
824
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
825
|
-
// handler below and silently drop cache invalidation (#453).
|
|
826
|
-
...options,
|
|
827
|
-
mutationFn: (rkey) => unsetSectionPrimary(config, section, rkey),
|
|
828
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
829
|
-
if (result.success) {
|
|
830
|
-
await invalidateProfile3(queryClient, ownerHandleOrDid);
|
|
831
|
-
}
|
|
832
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
833
|
-
}
|
|
834
|
-
});
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
// src/query/fetchers/skills.ts
|
|
838
|
-
function createSkill(config, data, options = {}) {
|
|
839
|
-
return apiWriteCreate(config, "/api/profile/skill", data, options);
|
|
840
|
-
}
|
|
841
|
-
function updateSkill(config, rkey, data, options = {}) {
|
|
842
|
-
return apiWrite(config, `/api/profile/skill/${encodeURIComponent(rkey)}`, "PUT", {
|
|
843
|
-
body: data,
|
|
844
|
-
...options
|
|
845
|
-
});
|
|
846
|
-
}
|
|
847
|
-
function updateSkillSubCategories(config, rkeys, subCategory, options = {}) {
|
|
848
|
-
return apiWrite(config, "/api/profile/skills/subcategory", "POST", {
|
|
849
|
-
body: { rkeys, subCategory },
|
|
850
|
-
...options
|
|
851
|
-
});
|
|
852
|
-
}
|
|
853
|
-
function deleteSkill(config, rkey, options = {}) {
|
|
854
|
-
return apiWrite(config, `/api/profile/skill/${encodeURIComponent(rkey)}`, "DELETE", options);
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
// src/query/hooks/use-skill-mutations.ts
|
|
858
|
-
async function invalidateProfile4(queryClient, ownerHandleOrDid) {
|
|
859
|
-
await queryClient.invalidateQueries({
|
|
860
|
-
queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
|
|
861
|
-
});
|
|
862
|
-
}
|
|
863
|
-
function useCreateSkill(ownerHandleOrDid, options) {
|
|
864
|
-
const config = useSifaConfig();
|
|
865
|
-
const queryClient = useQueryClient();
|
|
866
|
-
return useMutation({
|
|
867
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
868
|
-
// handler below and silently drop cache invalidation (#453).
|
|
869
|
-
...options,
|
|
870
|
-
mutationFn: (data) => createSkill(config, data),
|
|
871
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
872
|
-
if (result.success) {
|
|
873
|
-
await invalidateProfile4(queryClient, ownerHandleOrDid);
|
|
874
|
-
}
|
|
875
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
876
|
-
}
|
|
877
|
-
});
|
|
878
|
-
}
|
|
879
|
-
function useUpdateSkill(ownerHandleOrDid, options) {
|
|
880
|
-
const config = useSifaConfig();
|
|
881
|
-
const queryClient = useQueryClient();
|
|
882
|
-
return useMutation({
|
|
883
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
884
|
-
// handler below and silently drop cache invalidation (#453).
|
|
885
|
-
...options,
|
|
886
|
-
mutationFn: ({ rkey, data }) => updateSkill(config, rkey, data),
|
|
887
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
888
|
-
if (result.success) {
|
|
889
|
-
await invalidateProfile4(queryClient, ownerHandleOrDid);
|
|
890
|
-
}
|
|
891
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
892
|
-
}
|
|
893
|
-
});
|
|
894
|
-
}
|
|
895
|
-
function useUpdateSkillSubCategories(ownerHandleOrDid, options) {
|
|
896
|
-
const config = useSifaConfig();
|
|
897
|
-
const queryClient = useQueryClient();
|
|
898
|
-
return useMutation({
|
|
899
|
-
mutationFn: ({ rkeys, subCategory }) => updateSkillSubCategories(config, rkeys, subCategory),
|
|
900
|
-
// `...options` comes first so a caller-supplied onSuccess cannot replace the
|
|
901
|
-
// wrapper below and silently skip profile invalidation; the wrapper calls it
|
|
902
|
-
// instead. The older skill hooks in this file spread options last and still
|
|
903
|
-
// carry that bug.
|
|
904
|
-
...options,
|
|
905
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
906
|
-
if (result.success) {
|
|
907
|
-
await invalidateProfile4(queryClient, ownerHandleOrDid);
|
|
908
|
-
}
|
|
909
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
910
|
-
}
|
|
911
|
-
});
|
|
912
|
-
}
|
|
913
|
-
function useDeleteSkill(ownerHandleOrDid, options) {
|
|
914
|
-
const config = useSifaConfig();
|
|
915
|
-
const queryClient = useQueryClient();
|
|
916
|
-
return useMutation({
|
|
917
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
918
|
-
// handler below and silently drop cache invalidation (#453).
|
|
919
|
-
...options,
|
|
920
|
-
mutationFn: (rkey) => deleteSkill(config, rkey),
|
|
921
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
922
|
-
if (result.success) {
|
|
923
|
-
await invalidateProfile4(queryClient, ownerHandleOrDid);
|
|
924
|
-
}
|
|
925
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
926
|
-
}
|
|
927
|
-
});
|
|
928
|
-
}
|
|
929
|
-
|
|
930
|
-
// src/query/fetchers/records.ts
|
|
931
|
-
function createRecord(config, collection, data, options = {}) {
|
|
932
|
-
return apiWriteCreate(
|
|
933
|
-
config,
|
|
934
|
-
`/api/profile/records/${encodeURIComponent(collection)}`,
|
|
935
|
-
data,
|
|
936
|
-
options
|
|
937
|
-
);
|
|
938
|
-
}
|
|
939
|
-
function updateRecord(config, collection, rkey, data, options = {}) {
|
|
940
|
-
const path = `/api/profile/records/${encodeURIComponent(collection)}/${encodeURIComponent(rkey)}`;
|
|
941
|
-
return apiWrite(config, path, "PUT", { body: data, ...options });
|
|
942
|
-
}
|
|
943
|
-
function deleteRecord(config, collection, rkey, options = {}) {
|
|
944
|
-
const path = `/api/profile/records/${encodeURIComponent(collection)}/${encodeURIComponent(rkey)}`;
|
|
945
|
-
return apiWrite(config, path, "DELETE", options);
|
|
946
|
-
}
|
|
947
|
-
|
|
948
|
-
// src/query/hooks/use-record-mutations.ts
|
|
949
|
-
async function invalidateProfile5(queryClient, ownerHandleOrDid) {
|
|
950
|
-
await queryClient.invalidateQueries({
|
|
951
|
-
queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
|
|
952
|
-
});
|
|
953
|
-
}
|
|
954
|
-
function useCreateRecord(ownerHandleOrDid, options) {
|
|
955
|
-
const config = useSifaConfig();
|
|
956
|
-
const queryClient = useQueryClient();
|
|
957
|
-
return useMutation({
|
|
958
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
959
|
-
// handler below and silently drop cache invalidation (#453).
|
|
960
|
-
...options,
|
|
961
|
-
mutationFn: ({ collection, data }) => createRecord(config, collection, data),
|
|
962
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
963
|
-
if (result.success) {
|
|
964
|
-
await invalidateProfile5(queryClient, ownerHandleOrDid);
|
|
965
|
-
}
|
|
966
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
967
|
-
}
|
|
968
|
-
});
|
|
969
|
-
}
|
|
970
|
-
function useUpdateRecord(ownerHandleOrDid, options) {
|
|
971
|
-
const config = useSifaConfig();
|
|
972
|
-
const queryClient = useQueryClient();
|
|
973
|
-
return useMutation({
|
|
974
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
975
|
-
// handler below and silently drop cache invalidation (#453).
|
|
976
|
-
...options,
|
|
977
|
-
mutationFn: ({ collection, rkey, data }) => updateRecord(config, collection, rkey, data),
|
|
978
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
979
|
-
if (result.success) {
|
|
980
|
-
await invalidateProfile5(queryClient, ownerHandleOrDid);
|
|
981
|
-
}
|
|
982
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
983
|
-
}
|
|
984
|
-
});
|
|
985
|
-
}
|
|
986
|
-
function useDeleteRecord(ownerHandleOrDid, options) {
|
|
987
|
-
const config = useSifaConfig();
|
|
988
|
-
const queryClient = useQueryClient();
|
|
989
|
-
return useMutation({
|
|
990
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
991
|
-
// handler below and silently drop cache invalidation (#453).
|
|
992
|
-
...options,
|
|
993
|
-
mutationFn: ({ collection, rkey }) => deleteRecord(config, collection, rkey),
|
|
994
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
995
|
-
if (result.success) {
|
|
996
|
-
await invalidateProfile5(queryClient, ownerHandleOrDid);
|
|
997
|
-
}
|
|
998
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
999
|
-
}
|
|
1000
|
-
});
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
// src/query/fetchers/profile-locations.ts
|
|
1004
|
-
function createProfileLocation(config, data, options = {}) {
|
|
1005
|
-
return apiWriteCreate(config, "/api/profile/location", data, options);
|
|
1006
|
-
}
|
|
1007
|
-
function updateProfileLocation(config, rkey, data, options = {}) {
|
|
1008
|
-
return apiWrite(config, `/api/profile/location/${encodeURIComponent(rkey)}`, "PUT", {
|
|
1009
|
-
body: data,
|
|
1010
|
-
...options
|
|
1011
|
-
});
|
|
1012
|
-
}
|
|
1013
|
-
function deleteProfileLocation(config, rkey, options = {}) {
|
|
1014
|
-
return apiWrite(config, `/api/profile/location/${encodeURIComponent(rkey)}`, "DELETE", options);
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
// src/query/hooks/use-location-mutations.ts
|
|
1018
|
-
async function invalidateProfile6(queryClient, ownerHandleOrDid) {
|
|
1019
|
-
await queryClient.invalidateQueries({
|
|
1020
|
-
queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
|
|
1021
|
-
});
|
|
1022
|
-
}
|
|
1023
|
-
function useCreateProfileLocation(ownerHandleOrDid, options) {
|
|
1024
|
-
const config = useSifaConfig();
|
|
1025
|
-
const queryClient = useQueryClient();
|
|
1026
|
-
return useMutation({
|
|
1027
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
1028
|
-
// handler below and silently drop cache invalidation (#453).
|
|
1029
|
-
...options,
|
|
1030
|
-
mutationFn: (data) => createProfileLocation(config, data),
|
|
1031
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1032
|
-
if (result.success) {
|
|
1033
|
-
await invalidateProfile6(queryClient, ownerHandleOrDid);
|
|
1034
|
-
}
|
|
1035
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1036
|
-
}
|
|
1037
|
-
});
|
|
1038
|
-
}
|
|
1039
|
-
function useUpdateProfileLocation(ownerHandleOrDid, options) {
|
|
1040
|
-
const config = useSifaConfig();
|
|
1041
|
-
const queryClient = useQueryClient();
|
|
1042
|
-
return useMutation({
|
|
1043
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
1044
|
-
// handler below and silently drop cache invalidation (#453).
|
|
1045
|
-
...options,
|
|
1046
|
-
mutationFn: ({ rkey, data }) => updateProfileLocation(config, rkey, data),
|
|
1047
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1048
|
-
if (result.success) {
|
|
1049
|
-
await invalidateProfile6(queryClient, ownerHandleOrDid);
|
|
1050
|
-
}
|
|
1051
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1052
|
-
}
|
|
1053
|
-
});
|
|
1054
|
-
}
|
|
1055
|
-
function useDeleteProfileLocation(ownerHandleOrDid, options) {
|
|
1056
|
-
const config = useSifaConfig();
|
|
1057
|
-
const queryClient = useQueryClient();
|
|
1058
|
-
return useMutation({
|
|
1059
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
1060
|
-
// handler below and silently drop cache invalidation (#453).
|
|
1061
|
-
...options,
|
|
1062
|
-
mutationFn: (rkey) => deleteProfileLocation(config, rkey),
|
|
1063
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1064
|
-
if (result.success) {
|
|
1065
|
-
await invalidateProfile6(queryClient, ownerHandleOrDid);
|
|
1066
|
-
}
|
|
1067
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1068
|
-
}
|
|
1069
|
-
});
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
// src/query/fetchers/external-accounts.ts
|
|
1073
|
-
async function fetchExternalAccounts(config, handleOrDid, options = {}) {
|
|
1074
|
-
const path = `/api/profile/${encodeIdentifier(handleOrDid)}/external-accounts`;
|
|
1075
|
-
try {
|
|
1076
|
-
const data = await apiFetch(config, path, {
|
|
1077
|
-
credentials: "include",
|
|
1078
|
-
...options
|
|
1079
|
-
});
|
|
1080
|
-
return data.accounts ?? [];
|
|
1081
|
-
} catch {
|
|
1082
|
-
return [];
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
function createExternalAccount(config, data, options = {}) {
|
|
1086
|
-
return apiWrite(
|
|
1087
|
-
config,
|
|
1088
|
-
"/api/profile/external-accounts",
|
|
1089
|
-
"POST",
|
|
1090
|
-
{ body: data, ...options }
|
|
1091
|
-
);
|
|
1092
|
-
}
|
|
1093
|
-
function updateExternalAccount(config, rkey, data, options = {}) {
|
|
1094
|
-
return apiWrite(config, `/api/profile/external-accounts/${encodeURIComponent(rkey)}`, "PUT", {
|
|
1095
|
-
body: data,
|
|
1096
|
-
...options
|
|
1097
|
-
});
|
|
1098
|
-
}
|
|
1099
|
-
function deleteExternalAccount(config, rkey, options = {}) {
|
|
1100
|
-
return apiWrite(
|
|
1101
|
-
config,
|
|
1102
|
-
`/api/profile/external-accounts/${encodeURIComponent(rkey)}`,
|
|
1103
|
-
"DELETE",
|
|
1104
|
-
options
|
|
1105
|
-
);
|
|
1106
|
-
}
|
|
1107
|
-
function setExternalAccountPrimary(config, rkey, options = {}) {
|
|
1108
|
-
return apiWrite(
|
|
1109
|
-
config,
|
|
1110
|
-
`/api/profile/external-accounts/${encodeURIComponent(rkey)}/primary`,
|
|
1111
|
-
"PUT",
|
|
1112
|
-
options
|
|
1113
|
-
);
|
|
1114
|
-
}
|
|
1115
|
-
function unsetExternalAccountPrimary(config, rkey, options = {}) {
|
|
1116
|
-
return apiWrite(
|
|
1117
|
-
config,
|
|
1118
|
-
`/api/profile/external-accounts/${encodeURIComponent(rkey)}/primary`,
|
|
1119
|
-
"DELETE",
|
|
1120
|
-
options
|
|
1121
|
-
);
|
|
1122
|
-
}
|
|
1123
|
-
function verifyExternalAccount(config, rkey, options = {}) {
|
|
1124
|
-
return apiWrite(
|
|
1125
|
-
config,
|
|
1126
|
-
`/api/profile/external-accounts/${encodeURIComponent(rkey)}/verify`,
|
|
1127
|
-
"POST",
|
|
1128
|
-
{ body: {}, ...options }
|
|
1129
|
-
);
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
// src/query/hooks/use-external-accounts.ts
|
|
1133
|
-
async function invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid) {
|
|
1134
|
-
await queryClient.invalidateQueries({
|
|
1135
|
-
queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
|
|
1136
|
-
});
|
|
1137
|
-
await queryClient.invalidateQueries({
|
|
1138
|
-
queryKey: sifaQueryKeys.profile.externalAccounts(ownerHandleOrDid)
|
|
1139
|
-
});
|
|
1140
|
-
}
|
|
1141
|
-
function useExternalAccounts(handleOrDid, options) {
|
|
1142
|
-
const config = useSifaConfig();
|
|
1143
|
-
return useQuery({
|
|
1144
|
-
queryKey: sifaQueryKeys.profile.externalAccounts(handleOrDid ?? ""),
|
|
1145
|
-
queryFn: () => fetchExternalAccounts(config, handleOrDid ?? ""),
|
|
1146
|
-
enabled: Boolean(handleOrDid) && (options?.enabled ?? true),
|
|
1147
|
-
...options
|
|
1148
|
-
});
|
|
1149
|
-
}
|
|
1150
|
-
function useCreateExternalAccount(ownerHandleOrDid, options) {
|
|
1151
|
-
const config = useSifaConfig();
|
|
1152
|
-
const queryClient = useQueryClient();
|
|
1153
|
-
return useMutation({
|
|
1154
|
-
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
1155
|
-
// one below and silently drop cache invalidation (#453).
|
|
1156
|
-
...options,
|
|
1157
|
-
mutationFn: (data) => createExternalAccount(config, data),
|
|
1158
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1159
|
-
if (result.success) {
|
|
1160
|
-
await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);
|
|
1161
|
-
}
|
|
1162
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1163
|
-
}
|
|
1164
|
-
});
|
|
1165
|
-
}
|
|
1166
|
-
function useUpdateExternalAccount(ownerHandleOrDid, options) {
|
|
1167
|
-
const config = useSifaConfig();
|
|
1168
|
-
const queryClient = useQueryClient();
|
|
1169
|
-
return useMutation({
|
|
1170
|
-
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
1171
|
-
// one below and silently drop cache invalidation (#453).
|
|
1172
|
-
...options,
|
|
1173
|
-
mutationFn: ({ rkey, data }) => updateExternalAccount(config, rkey, data),
|
|
1174
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1175
|
-
if (result.success) {
|
|
1176
|
-
await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);
|
|
1177
|
-
}
|
|
1178
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1179
|
-
}
|
|
1180
|
-
});
|
|
1181
|
-
}
|
|
1182
|
-
function useDeleteExternalAccount(ownerHandleOrDid, options) {
|
|
1183
|
-
const config = useSifaConfig();
|
|
1184
|
-
const queryClient = useQueryClient();
|
|
1185
|
-
return useMutation({
|
|
1186
|
-
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
1187
|
-
// one below and silently drop cache invalidation (#453).
|
|
1188
|
-
...options,
|
|
1189
|
-
mutationFn: (rkey) => deleteExternalAccount(config, rkey),
|
|
1190
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1191
|
-
if (result.success) {
|
|
1192
|
-
await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);
|
|
1193
|
-
}
|
|
1194
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1195
|
-
}
|
|
1196
|
-
});
|
|
1197
|
-
}
|
|
1198
|
-
function useSetExternalAccountPrimary(ownerHandleOrDid, options) {
|
|
1199
|
-
const config = useSifaConfig();
|
|
1200
|
-
const queryClient = useQueryClient();
|
|
1201
|
-
return useMutation({
|
|
1202
|
-
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
1203
|
-
// one below and silently drop cache invalidation (#453).
|
|
1204
|
-
...options,
|
|
1205
|
-
mutationFn: (rkey) => setExternalAccountPrimary(config, rkey),
|
|
1206
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1207
|
-
if (result.success) {
|
|
1208
|
-
await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);
|
|
1209
|
-
}
|
|
1210
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1211
|
-
}
|
|
1212
|
-
});
|
|
1213
|
-
}
|
|
1214
|
-
function useUnsetExternalAccountPrimary(ownerHandleOrDid, options) {
|
|
1215
|
-
const config = useSifaConfig();
|
|
1216
|
-
const queryClient = useQueryClient();
|
|
1217
|
-
return useMutation({
|
|
1218
|
-
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
1219
|
-
// one below and silently drop cache invalidation (#453).
|
|
1220
|
-
...options,
|
|
1221
|
-
mutationFn: (rkey) => unsetExternalAccountPrimary(config, rkey),
|
|
1222
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1223
|
-
if (result.success) {
|
|
1224
|
-
await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);
|
|
1225
|
-
}
|
|
1226
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1227
|
-
}
|
|
1228
|
-
});
|
|
1229
|
-
}
|
|
1230
|
-
function useVerifyExternalAccount(ownerHandleOrDid, options) {
|
|
1231
|
-
const config = useSifaConfig();
|
|
1232
|
-
const queryClient = useQueryClient();
|
|
1233
|
-
return useMutation({
|
|
1234
|
-
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
1235
|
-
// one below and silently drop cache invalidation (#453).
|
|
1236
|
-
...options,
|
|
1237
|
-
mutationFn: (rkey) => verifyExternalAccount(config, rkey),
|
|
1238
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1239
|
-
if (result.success) {
|
|
1240
|
-
await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);
|
|
1241
|
-
}
|
|
1242
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1243
|
-
}
|
|
1244
|
-
});
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
// src/query/fetchers/endorsements.ts
|
|
1248
|
-
function createEndorsement(config, data, options = {}) {
|
|
1249
|
-
return apiWriteCreate(config, "/api/endorsement", data, options);
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
// src/query/hooks/use-endorsement-mutations.ts
|
|
1253
|
-
function useCreateEndorsement(endorsedHandleOrDid, options) {
|
|
1254
|
-
const config = useSifaConfig();
|
|
1255
|
-
const queryClient = useQueryClient();
|
|
1256
|
-
return useMutation({
|
|
1257
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
1258
|
-
// handler below and silently drop cache invalidation (#453).
|
|
1259
|
-
...options,
|
|
1260
|
-
mutationFn: (data) => createEndorsement(config, data),
|
|
1261
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1262
|
-
if (result.success && endorsedHandleOrDid) {
|
|
1263
|
-
await queryClient.invalidateQueries({
|
|
1264
|
-
queryKey: sifaQueryKeys.profile.byHandle(endorsedHandleOrDid)
|
|
1265
|
-
});
|
|
1266
|
-
await queryClient.invalidateQueries({
|
|
1267
|
-
queryKey: sifaQueryKeys.endorsement.count(endorsedHandleOrDid)
|
|
1268
|
-
});
|
|
1269
|
-
}
|
|
1270
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1271
|
-
}
|
|
1272
|
-
});
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
// src/query/fetchers/confirmations.ts
|
|
1276
|
-
async function fetchPendingConfirmations(config, options = {}) {
|
|
1277
|
-
const { cookieHeader, ...rest } = options;
|
|
1278
|
-
const headers = { ...rest.headers ?? {} };
|
|
1279
|
-
if (cookieHeader) headers.cookie = cookieHeader;
|
|
1280
|
-
try {
|
|
1281
|
-
const data = await apiFetch(config, "/api/confirmations/pending", {
|
|
1282
|
-
cache: "no-store",
|
|
1283
|
-
credentials: "include",
|
|
1284
|
-
timeoutMs: 5e3,
|
|
1285
|
-
...rest,
|
|
1286
|
-
headers
|
|
1287
|
-
});
|
|
1288
|
-
return { confirmations: data?.confirmations ?? [], cursor: data?.cursor };
|
|
1289
|
-
} catch {
|
|
1290
|
-
return { confirmations: [] };
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
async function fetchGivenConfirmations(config, options = {}) {
|
|
1294
|
-
const { cookieHeader, ...rest } = options;
|
|
1295
|
-
const headers = { ...rest.headers ?? {} };
|
|
1296
|
-
if (cookieHeader) headers.cookie = cookieHeader;
|
|
1297
|
-
try {
|
|
1298
|
-
const data = await apiFetch(
|
|
1299
|
-
config,
|
|
1300
|
-
"/api/confirmations/mine",
|
|
1301
|
-
{ cache: "no-store", credentials: "include", timeoutMs: 5e3, ...rest, headers }
|
|
1302
|
-
);
|
|
1303
|
-
return { confirmations: data?.confirmations ?? [] };
|
|
1304
|
-
} catch {
|
|
1305
|
-
return { confirmations: [] };
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
function createConfirmation(config, data, options = {}) {
|
|
1309
|
-
return apiWriteCreate(config, "/api/confirmation", data, options);
|
|
1310
|
-
}
|
|
1311
|
-
function dismissConfirmation(config, data, options = {}) {
|
|
1312
|
-
return apiWrite(config, "/api/confirmation/dismiss", "POST", { body: data, ...options });
|
|
1313
|
-
}
|
|
1314
|
-
function revokeConfirmation(config, data, options = {}) {
|
|
1315
|
-
return apiWrite(config, "/api/confirmation/revoke", "POST", { body: data, ...options });
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
// src/query/hooks/use-confirmations.ts
|
|
1319
|
-
function usePendingConfirmations(options) {
|
|
1320
|
-
const config = useSifaConfig();
|
|
1321
|
-
return useQuery({
|
|
1322
|
-
queryKey: sifaQueryKeys.confirmation.pending(),
|
|
1323
|
-
queryFn: () => fetchPendingConfirmations(config),
|
|
1324
|
-
...options
|
|
1325
|
-
});
|
|
1326
|
-
}
|
|
1327
|
-
function useGivenConfirmations(options) {
|
|
1328
|
-
const config = useSifaConfig();
|
|
1329
|
-
return useQuery({
|
|
1330
|
-
queryKey: sifaQueryKeys.confirmation.given(),
|
|
1331
|
-
queryFn: () => fetchGivenConfirmations(config),
|
|
1332
|
-
...options
|
|
1333
|
-
});
|
|
1334
|
-
}
|
|
1335
|
-
function useCreateConfirmation(claimerHandleOrDid, options) {
|
|
1336
|
-
const config = useSifaConfig();
|
|
1337
|
-
const queryClient = useQueryClient();
|
|
1338
|
-
return useMutation({
|
|
1339
|
-
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
1340
|
-
// one below and silently drop cache invalidation (#453).
|
|
1341
|
-
...options,
|
|
1342
|
-
mutationFn: (data) => createConfirmation(config, data),
|
|
1343
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1344
|
-
if (result.success) {
|
|
1345
|
-
await queryClient.invalidateQueries({
|
|
1346
|
-
queryKey: sifaQueryKeys.confirmation.pending()
|
|
1347
|
-
});
|
|
1348
|
-
await queryClient.invalidateQueries({
|
|
1349
|
-
queryKey: sifaQueryKeys.confirmation.given()
|
|
1350
|
-
});
|
|
1351
|
-
await queryClient.invalidateQueries({
|
|
1352
|
-
queryKey: sifaQueryKeys.inbox.counts()
|
|
1353
|
-
});
|
|
1354
|
-
if (claimerHandleOrDid) {
|
|
1355
|
-
await queryClient.invalidateQueries({
|
|
1356
|
-
queryKey: sifaQueryKeys.profile.byHandle(claimerHandleOrDid)
|
|
1357
|
-
});
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1361
|
-
}
|
|
1362
|
-
});
|
|
1363
|
-
}
|
|
1364
|
-
function useDismissConfirmation(options) {
|
|
1365
|
-
const config = useSifaConfig();
|
|
1366
|
-
const queryClient = useQueryClient();
|
|
1367
|
-
return useMutation({
|
|
1368
|
-
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
1369
|
-
// one below and silently drop cache invalidation (#453).
|
|
1370
|
-
...options,
|
|
1371
|
-
mutationFn: (data) => dismissConfirmation(config, data),
|
|
1372
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1373
|
-
if (result.success) {
|
|
1374
|
-
await queryClient.invalidateQueries({
|
|
1375
|
-
queryKey: sifaQueryKeys.confirmation.pending()
|
|
1376
|
-
});
|
|
1377
|
-
await queryClient.invalidateQueries({
|
|
1378
|
-
queryKey: sifaQueryKeys.inbox.counts()
|
|
1379
|
-
});
|
|
1380
|
-
}
|
|
1381
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1382
|
-
}
|
|
1383
|
-
});
|
|
1384
|
-
}
|
|
1385
|
-
function useRevokeConfirmation(claimerHandleOrDid, options) {
|
|
1386
|
-
const config = useSifaConfig();
|
|
1387
|
-
const queryClient = useQueryClient();
|
|
1388
|
-
return useMutation({
|
|
1389
|
-
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
1390
|
-
// one below and silently drop cache invalidation (#453).
|
|
1391
|
-
...options,
|
|
1392
|
-
mutationFn: (data) => revokeConfirmation(config, data),
|
|
1393
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1394
|
-
if (result.success) {
|
|
1395
|
-
await queryClient.invalidateQueries({
|
|
1396
|
-
queryKey: sifaQueryKeys.confirmation.pending()
|
|
1397
|
-
});
|
|
1398
|
-
await queryClient.invalidateQueries({
|
|
1399
|
-
queryKey: sifaQueryKeys.confirmation.given()
|
|
1400
|
-
});
|
|
1401
|
-
await queryClient.invalidateQueries({
|
|
1402
|
-
queryKey: sifaQueryKeys.inbox.counts()
|
|
1403
|
-
});
|
|
1404
|
-
if (claimerHandleOrDid) {
|
|
1405
|
-
await queryClient.invalidateQueries({
|
|
1406
|
-
queryKey: sifaQueryKeys.profile.byHandle(claimerHandleOrDid)
|
|
1407
|
-
});
|
|
1408
|
-
}
|
|
1409
|
-
}
|
|
1410
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1411
|
-
}
|
|
1412
|
-
});
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
// src/query/fetchers/inbox.ts
|
|
1416
|
-
function toCount(value) {
|
|
1417
|
-
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.trunc(value) : 0;
|
|
1418
|
-
}
|
|
1419
|
-
async function fetchInboxCounts(config, options = {}) {
|
|
1420
|
-
const { cookieHeader, ...rest } = options;
|
|
1421
|
-
const headers = { ...rest.headers ?? {} };
|
|
1422
|
-
if (cookieHeader) headers.cookie = cookieHeader;
|
|
1423
|
-
try {
|
|
1424
|
-
const data = await apiFetch(config, "/api/inbox/counts", {
|
|
1425
|
-
cache: "no-store",
|
|
1426
|
-
credentials: "include",
|
|
1427
|
-
timeoutMs: 5e3,
|
|
1428
|
-
...rest,
|
|
1429
|
-
headers
|
|
1430
|
-
});
|
|
1431
|
-
return {
|
|
1432
|
-
tasks: toCount(data?.tasks),
|
|
1433
|
-
unreadNotifications: toCount(data?.unreadNotifications)
|
|
1434
|
-
};
|
|
1435
|
-
} catch {
|
|
1436
|
-
return { tasks: 0, unreadNotifications: 0 };
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1439
|
-
|
|
1440
|
-
// src/query/hooks/use-inbox.ts
|
|
1441
|
-
function useInboxCounts(options) {
|
|
1442
|
-
const config = useSifaConfig();
|
|
1443
|
-
return useQuery({
|
|
1444
|
-
queryKey: sifaQueryKeys.inbox.counts(),
|
|
1445
|
-
queryFn: () => fetchInboxCounts(config),
|
|
1446
|
-
...options
|
|
1447
|
-
});
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
// src/query/fetchers/unlinked-positions.ts
|
|
1451
|
-
async function fetchUnlinkedPositions(config, options = {}) {
|
|
1452
|
-
const { cookieHeader, ...rest } = options;
|
|
1453
|
-
const headers = { ...rest.headers ?? {} };
|
|
1454
|
-
if (cookieHeader) headers.cookie = cookieHeader;
|
|
1455
|
-
try {
|
|
1456
|
-
const data = await apiFetch(config, "/api/positions/unlinked", {
|
|
1457
|
-
cache: "no-store",
|
|
1458
|
-
credentials: "include",
|
|
1459
|
-
timeoutMs: 5e3,
|
|
1460
|
-
...rest,
|
|
1461
|
-
headers
|
|
1462
|
-
});
|
|
1463
|
-
return { positions: Array.isArray(data?.positions) ? data.positions : [] };
|
|
1464
|
-
} catch {
|
|
1465
|
-
return { positions: [] };
|
|
1466
|
-
}
|
|
1467
|
-
}
|
|
1468
|
-
function dismissUnlinkedPosition(config, data, options = {}) {
|
|
1469
|
-
return apiWrite(config, "/api/positions/unlinked/dismiss", "POST", { body: data, ...options });
|
|
1470
|
-
}
|
|
1471
|
-
|
|
1472
|
-
// src/query/hooks/use-unlinked-positions.ts
|
|
1473
|
-
function useUnlinkedPositions(options) {
|
|
1474
|
-
const config = useSifaConfig();
|
|
1475
|
-
return useQuery({
|
|
1476
|
-
queryKey: sifaQueryKeys.position.unlinked(),
|
|
1477
|
-
queryFn: () => fetchUnlinkedPositions(config),
|
|
1478
|
-
...options
|
|
1479
|
-
});
|
|
1480
|
-
}
|
|
1481
|
-
function useDismissUnlinkedPosition(options) {
|
|
1482
|
-
const config = useSifaConfig();
|
|
1483
|
-
const queryClient = useQueryClient();
|
|
1484
|
-
return useMutation({
|
|
1485
|
-
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
1486
|
-
// one below and silently drop cache invalidation (#453).
|
|
1487
|
-
...options,
|
|
1488
|
-
mutationFn: (data) => dismissUnlinkedPosition(config, data),
|
|
1489
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1490
|
-
if (result.success) {
|
|
1491
|
-
await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.position.unlinked() });
|
|
1492
|
-
await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.inbox.counts() });
|
|
1493
|
-
}
|
|
1494
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1495
|
-
}
|
|
1496
|
-
});
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
// src/query/fetchers/profile-completeness.ts
|
|
1500
|
-
var PROFILE_COMPLETENESS_SIGNALS = [
|
|
1501
|
-
"headline",
|
|
1502
|
-
"about",
|
|
1503
|
-
"position",
|
|
1504
|
-
"education",
|
|
1505
|
-
"skill",
|
|
1506
|
-
"certification"
|
|
1507
|
-
];
|
|
1508
|
-
async function fetchProfileCompleteness(config, options = {}) {
|
|
1509
|
-
const { cookieHeader, ...rest } = options;
|
|
1510
|
-
const headers = { ...rest.headers ?? {} };
|
|
1511
|
-
if (cookieHeader) headers.cookie = cookieHeader;
|
|
1512
|
-
const empty = {
|
|
1513
|
-
complete: true,
|
|
1514
|
-
score: PROFILE_COMPLETENESS_SIGNALS.length,
|
|
1515
|
-
total: PROFILE_COMPLETENESS_SIGNALS.length,
|
|
1516
|
-
missing: []
|
|
1517
|
-
};
|
|
1518
|
-
try {
|
|
1519
|
-
const data = await apiFetch(config, "/api/profile/completeness", {
|
|
1520
|
-
cache: "no-store",
|
|
1521
|
-
credentials: "include",
|
|
1522
|
-
timeoutMs: 5e3,
|
|
1523
|
-
...rest,
|
|
1524
|
-
headers
|
|
1525
|
-
});
|
|
1526
|
-
if (!data) return empty;
|
|
1527
|
-
const missing = Array.isArray(data.missing) ? data.missing : [];
|
|
1528
|
-
return {
|
|
1529
|
-
complete: data.complete ?? missing.length === 0,
|
|
1530
|
-
score: data.score ?? PROFILE_COMPLETENESS_SIGNALS.length - missing.length,
|
|
1531
|
-
total: data.total ?? PROFILE_COMPLETENESS_SIGNALS.length,
|
|
1532
|
-
missing
|
|
1533
|
-
};
|
|
1534
|
-
} catch {
|
|
1535
|
-
return empty;
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
|
|
1539
|
-
// src/query/hooks/use-profile-completeness.ts
|
|
1540
|
-
function useProfileCompleteness(options) {
|
|
1541
|
-
const config = useSifaConfig();
|
|
1542
|
-
return useQuery({
|
|
1543
|
-
queryKey: sifaQueryKeys.profile.completeness(),
|
|
1544
|
-
queryFn: () => fetchProfileCompleteness(config),
|
|
1545
|
-
...options
|
|
1546
|
-
});
|
|
1547
|
-
}
|
|
1548
|
-
|
|
1549
|
-
// src/query/fetchers/keytrace-claims.ts
|
|
1550
|
-
function hideKeytraceClaim(config, rkey, options = {}) {
|
|
1551
|
-
return apiWrite(
|
|
1552
|
-
config,
|
|
1553
|
-
`/api/profile/keytrace-claims/${encodeURIComponent(rkey)}/hide`,
|
|
1554
|
-
"POST",
|
|
1555
|
-
options
|
|
1556
|
-
);
|
|
1557
|
-
}
|
|
1558
|
-
function unhideKeytraceClaim(config, rkey, options = {}) {
|
|
1559
|
-
return apiWrite(
|
|
1560
|
-
config,
|
|
1561
|
-
`/api/profile/keytrace-claims/${encodeURIComponent(rkey)}/hide`,
|
|
1562
|
-
"DELETE",
|
|
1563
|
-
options
|
|
1564
|
-
);
|
|
1565
|
-
}
|
|
1566
|
-
|
|
1567
|
-
// src/query/hooks/use-keytrace-claims.ts
|
|
1568
|
-
async function invalidateProfile7(queryClient, ownerHandleOrDid) {
|
|
1569
|
-
await queryClient.invalidateQueries({
|
|
1570
|
-
queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
|
|
1571
|
-
});
|
|
1572
|
-
}
|
|
1573
|
-
function useHideKeytraceClaim(ownerHandleOrDid, options) {
|
|
1574
|
-
const config = useSifaConfig();
|
|
1575
|
-
const queryClient = useQueryClient();
|
|
1576
|
-
return useMutation({
|
|
1577
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
1578
|
-
// handler below and silently drop cache invalidation (#453).
|
|
1579
|
-
...options,
|
|
1580
|
-
mutationFn: (rkey) => hideKeytraceClaim(config, rkey),
|
|
1581
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1582
|
-
if (result.success) {
|
|
1583
|
-
await invalidateProfile7(queryClient, ownerHandleOrDid);
|
|
1584
|
-
}
|
|
1585
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1586
|
-
}
|
|
1587
|
-
});
|
|
1588
|
-
}
|
|
1589
|
-
function useUnhideKeytraceClaim(ownerHandleOrDid, options) {
|
|
1590
|
-
const config = useSifaConfig();
|
|
1591
|
-
const queryClient = useQueryClient();
|
|
1592
|
-
return useMutation({
|
|
1593
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
1594
|
-
// handler below and silently drop cache invalidation (#453).
|
|
1595
|
-
...options,
|
|
1596
|
-
mutationFn: (rkey) => unhideKeytraceClaim(config, rkey),
|
|
1597
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1598
|
-
if (result.success) {
|
|
1599
|
-
await invalidateProfile7(queryClient, ownerHandleOrDid);
|
|
1600
|
-
}
|
|
1601
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1602
|
-
}
|
|
1603
|
-
});
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
// src/query/fetchers/marque-domains.ts
|
|
1607
|
-
function revealMarqueDomain(config, domain, options = {}) {
|
|
1608
|
-
return apiWrite(
|
|
1609
|
-
config,
|
|
1610
|
-
`/api/profile/marque-domains/${encodeURIComponent(domain)}/reveal`,
|
|
1611
|
-
"POST",
|
|
1612
|
-
options
|
|
1613
|
-
);
|
|
1614
|
-
}
|
|
1615
|
-
function unrevealMarqueDomain(config, domain, options = {}) {
|
|
1616
|
-
return apiWrite(
|
|
1617
|
-
config,
|
|
1618
|
-
`/api/profile/marque-domains/${encodeURIComponent(domain)}/reveal`,
|
|
1619
|
-
"DELETE",
|
|
1620
|
-
options
|
|
1621
|
-
);
|
|
1622
|
-
}
|
|
1623
|
-
|
|
1624
|
-
// src/query/hooks/use-marque-domains.ts
|
|
1625
|
-
async function invalidateProfile8(queryClient, ownerHandleOrDid) {
|
|
1626
|
-
await queryClient.invalidateQueries({
|
|
1627
|
-
queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
|
|
1628
|
-
});
|
|
1629
|
-
}
|
|
1630
|
-
function useRevealMarqueDomain(ownerHandleOrDid, options) {
|
|
1631
|
-
const config = useSifaConfig();
|
|
1632
|
-
const queryClient = useQueryClient();
|
|
1633
|
-
return useMutation({
|
|
1634
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
1635
|
-
// handler below and silently drop cache invalidation (#453).
|
|
1636
|
-
...options,
|
|
1637
|
-
mutationFn: (domain) => revealMarqueDomain(config, domain),
|
|
1638
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1639
|
-
if (result.success) {
|
|
1640
|
-
await invalidateProfile8(queryClient, ownerHandleOrDid);
|
|
1641
|
-
}
|
|
1642
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1643
|
-
}
|
|
1644
|
-
});
|
|
1645
|
-
}
|
|
1646
|
-
function useUnrevealMarqueDomain(ownerHandleOrDid, options) {
|
|
1647
|
-
const config = useSifaConfig();
|
|
1648
|
-
const queryClient = useQueryClient();
|
|
1649
|
-
return useMutation({
|
|
1650
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
1651
|
-
// handler below and silently drop cache invalidation (#453).
|
|
1652
|
-
...options,
|
|
1653
|
-
mutationFn: (domain) => unrevealMarqueDomain(config, domain),
|
|
1654
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1655
|
-
if (result.success) {
|
|
1656
|
-
await invalidateProfile8(queryClient, ownerHandleOrDid);
|
|
1657
|
-
}
|
|
1658
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1659
|
-
}
|
|
1660
|
-
});
|
|
1661
|
-
}
|
|
1662
|
-
|
|
1663
|
-
// src/query/fetchers/publications.ts
|
|
1664
|
-
function hideOrcidPublication(config, putCode, options = {}) {
|
|
1665
|
-
return apiWrite(config, `/api/profile/orcid-publications/${putCode}/hide`, "POST", options);
|
|
1666
|
-
}
|
|
1667
|
-
function unhideOrcidPublication(config, putCode, options = {}) {
|
|
1668
|
-
return apiWrite(config, `/api/profile/orcid-publications/${putCode}/hide`, "DELETE", options);
|
|
1669
|
-
}
|
|
1670
|
-
function hideStandardPublication(config, uri, options = {}) {
|
|
1671
|
-
return apiWrite(
|
|
1672
|
-
config,
|
|
1673
|
-
`/api/profile/standard-publications/${encodeURIComponent(uri)}/hide`,
|
|
1674
|
-
"POST",
|
|
1675
|
-
options
|
|
1676
|
-
);
|
|
1677
|
-
}
|
|
1678
|
-
function unhideStandardPublication(config, uri, options = {}) {
|
|
1679
|
-
return apiWrite(
|
|
1680
|
-
config,
|
|
1681
|
-
`/api/profile/standard-publications/${encodeURIComponent(uri)}/hide`,
|
|
1682
|
-
"DELETE",
|
|
1683
|
-
options
|
|
1684
|
-
);
|
|
1685
|
-
}
|
|
1686
|
-
function bulkHideStandardPublications(config, uris, options = {}) {
|
|
1687
|
-
return apiWrite(config, "/api/profile/standard-publications/bulk-hide", "POST", {
|
|
1688
|
-
body: { uris },
|
|
1689
|
-
...options
|
|
1690
|
-
});
|
|
1691
|
-
}
|
|
1692
|
-
function bulkUnhideStandardPublications(config, uris, options = {}) {
|
|
1693
|
-
return apiWrite(config, "/api/profile/standard-publications/bulk-hide", "DELETE", {
|
|
1694
|
-
body: { uris },
|
|
1695
|
-
...options
|
|
1696
|
-
});
|
|
1697
|
-
}
|
|
1698
|
-
function hideSifaPublication(config, rkey, options = {}) {
|
|
1699
|
-
return apiWrite(config, `/api/profile/publications/${rkey}/hide`, "POST", options);
|
|
1700
|
-
}
|
|
1701
|
-
function unhideSifaPublication(config, rkey, options = {}) {
|
|
1702
|
-
return apiWrite(config, `/api/profile/publications/${rkey}/hide`, "DELETE", options);
|
|
1703
|
-
}
|
|
1704
|
-
async function refreshOrcidPublications(config, options = {}) {
|
|
1705
|
-
const result = await apiWrite(
|
|
1706
|
-
config,
|
|
1707
|
-
"/api/profile/orcid-publications/refresh",
|
|
1708
|
-
"POST",
|
|
1709
|
-
{ body: {}, ...options }
|
|
1710
|
-
);
|
|
1711
|
-
if (result.success && result.error) {
|
|
1712
|
-
return { success: false, error: result.error };
|
|
1713
|
-
}
|
|
1714
|
-
return result;
|
|
1715
|
-
}
|
|
1716
|
-
|
|
1717
|
-
// src/query/hooks/use-publication-mutations.ts
|
|
1718
|
-
async function invalidateProfile9(queryClient, ownerHandleOrDid) {
|
|
1719
|
-
await queryClient.invalidateQueries({
|
|
1720
|
-
queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
|
|
1721
|
-
});
|
|
1722
|
-
}
|
|
1723
|
-
function makeWriteHook(fetcher) {
|
|
1724
|
-
return function useHook(ownerHandleOrDid, options) {
|
|
1725
|
-
const config = useSifaConfig();
|
|
1726
|
-
const queryClient = useQueryClient();
|
|
1727
|
-
return useMutation({
|
|
1728
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
1729
|
-
// handler below and silently drop cache invalidation (#453).
|
|
1730
|
-
...options,
|
|
1731
|
-
mutationFn: (v) => fetcher(config, v),
|
|
1732
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1733
|
-
if (result.success) {
|
|
1734
|
-
await invalidateProfile9(queryClient, ownerHandleOrDid);
|
|
1735
|
-
}
|
|
1736
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1737
|
-
}
|
|
1738
|
-
});
|
|
1739
|
-
};
|
|
1740
|
-
}
|
|
1741
|
-
var useHideOrcidPublication = makeWriteHook(
|
|
1742
|
-
(config, putCode) => hideOrcidPublication(config, putCode)
|
|
1743
|
-
);
|
|
1744
|
-
var useUnhideOrcidPublication = makeWriteHook(
|
|
1745
|
-
(config, putCode) => unhideOrcidPublication(config, putCode)
|
|
1746
|
-
);
|
|
1747
|
-
var useHideStandardPublication = makeWriteHook(
|
|
1748
|
-
(config, uri) => hideStandardPublication(config, uri)
|
|
1749
|
-
);
|
|
1750
|
-
var useUnhideStandardPublication = makeWriteHook(
|
|
1751
|
-
(config, uri) => unhideStandardPublication(config, uri)
|
|
1752
|
-
);
|
|
1753
|
-
var useBulkHideStandardPublications = makeWriteHook(
|
|
1754
|
-
(config, uris) => bulkHideStandardPublications(config, uris)
|
|
1755
|
-
);
|
|
1756
|
-
var useBulkUnhideStandardPublications = makeWriteHook(
|
|
1757
|
-
(config, uris) => bulkUnhideStandardPublications(config, uris)
|
|
1758
|
-
);
|
|
1759
|
-
var useHideSifaPublication = makeWriteHook(
|
|
1760
|
-
(config, rkey) => hideSifaPublication(config, rkey)
|
|
1761
|
-
);
|
|
1762
|
-
var useUnhideSifaPublication = makeWriteHook(
|
|
1763
|
-
(config, rkey) => unhideSifaPublication(config, rkey)
|
|
1764
|
-
);
|
|
1765
|
-
function useRefreshOrcidPublications(ownerHandleOrDid, options) {
|
|
1766
|
-
const config = useSifaConfig();
|
|
1767
|
-
const queryClient = useQueryClient();
|
|
1768
|
-
return useMutation({
|
|
1769
|
-
mutationFn: () => refreshOrcidPublications(config),
|
|
1770
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1771
|
-
if (result.success) {
|
|
1772
|
-
await invalidateProfile9(queryClient, ownerHandleOrDid);
|
|
1773
|
-
}
|
|
1774
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1775
|
-
}
|
|
1776
|
-
});
|
|
1777
|
-
}
|
|
1778
|
-
|
|
1779
|
-
// src/query/fetchers/profile-items-hide.ts
|
|
1780
|
-
function hideProfileItem(config, input, options = {}) {
|
|
1781
|
-
return apiWrite(config, "/api/profile/items/hide", "POST", { ...options, body: input });
|
|
1782
|
-
}
|
|
1783
|
-
function unhideProfileItem(config, input, options = {}) {
|
|
1784
|
-
return apiWrite(config, "/api/profile/items/hide", "DELETE", { ...options, body: input });
|
|
1785
|
-
}
|
|
1786
|
-
function bulkHideProfileItems(config, input, options = {}) {
|
|
1787
|
-
return apiWrite(config, "/api/profile/items/bulk-hide", "POST", { ...options, body: input });
|
|
1788
|
-
}
|
|
1789
|
-
function bulkUnhideProfileItems(config, input, options = {}) {
|
|
1790
|
-
return apiWrite(config, "/api/profile/items/bulk-hide", "DELETE", { ...options, body: input });
|
|
1791
|
-
}
|
|
1792
|
-
|
|
1793
|
-
// src/query/hooks/use-profile-items-hide.ts
|
|
1794
|
-
async function invalidateProfile10(queryClient, ownerHandleOrDid) {
|
|
1795
|
-
await queryClient.invalidateQueries({
|
|
1796
|
-
queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
|
|
1797
|
-
});
|
|
1798
|
-
}
|
|
1799
|
-
function makeWriteHook2(fetcher) {
|
|
1800
|
-
return function useHook(ownerHandleOrDid, options) {
|
|
1801
|
-
const config = useSifaConfig();
|
|
1802
|
-
const queryClient = useQueryClient();
|
|
1803
|
-
return useMutation({
|
|
1804
|
-
mutationFn: (v) => fetcher(config, v),
|
|
1805
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1806
|
-
if (result.success) {
|
|
1807
|
-
await invalidateProfile10(queryClient, ownerHandleOrDid);
|
|
1808
|
-
}
|
|
1809
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1810
|
-
},
|
|
1811
|
-
...options
|
|
1812
|
-
});
|
|
1813
|
-
};
|
|
1814
|
-
}
|
|
1815
|
-
var useHideProfileItem = makeWriteHook2(
|
|
1816
|
-
(config, input) => hideProfileItem(config, input)
|
|
1817
|
-
);
|
|
1818
|
-
var useUnhideProfileItem = makeWriteHook2(
|
|
1819
|
-
(config, input) => unhideProfileItem(config, input)
|
|
1820
|
-
);
|
|
1821
|
-
var useBulkHideProfileItems = makeWriteHook2(
|
|
1822
|
-
(config, input) => bulkHideProfileItems(config, input)
|
|
1823
|
-
);
|
|
1824
|
-
var useBulkUnhideProfileItems = makeWriteHook2(
|
|
1825
|
-
(config, input) => bulkUnhideProfileItems(config, input)
|
|
1826
|
-
);
|
|
1827
|
-
|
|
1828
|
-
// src/query/fetchers/activity-items-hide.ts
|
|
1829
|
-
function hideActivityItem(config, input, options = {}) {
|
|
1830
|
-
return apiWrite(config, "/api/activity/items/hide", "POST", { ...options, body: input });
|
|
1831
|
-
}
|
|
1832
|
-
function unhideActivityItem(config, input, options = {}) {
|
|
1833
|
-
return apiWrite(config, "/api/activity/items/hide", "DELETE", { ...options, body: input });
|
|
1834
|
-
}
|
|
1835
|
-
async function fetchHiddenActivityItems(config, options = {}) {
|
|
1836
|
-
const headers = { ...options.headers ?? {} };
|
|
1837
|
-
if (options.cookieHeader) headers.cookie = options.cookieHeader;
|
|
1838
|
-
try {
|
|
1839
|
-
const data = await apiFetch(
|
|
1840
|
-
config,
|
|
1841
|
-
"/api/activity/hidden-items",
|
|
1842
|
-
{ credentials: "include", ...options, headers }
|
|
1843
|
-
);
|
|
1844
|
-
return data.items;
|
|
1845
|
-
} catch {
|
|
1846
|
-
return [];
|
|
1847
|
-
}
|
|
1848
|
-
}
|
|
1849
|
-
|
|
1850
|
-
// src/query/hooks/use-activity-items-hide.ts
|
|
1851
|
-
function useHiddenActivityItems(options) {
|
|
1852
|
-
const config = useSifaConfig();
|
|
1853
|
-
return useQuery({
|
|
1854
|
-
queryKey: sifaQueryKeys.activity.hiddenItems(),
|
|
1855
|
-
queryFn: () => fetchHiddenActivityItems(config),
|
|
1856
|
-
...options
|
|
1857
|
-
});
|
|
1858
|
-
}
|
|
1859
|
-
function makeHideHook(fetcher) {
|
|
1860
|
-
return function useHook(options) {
|
|
1861
|
-
const config = useSifaConfig();
|
|
1862
|
-
const queryClient = useQueryClient();
|
|
1863
|
-
return useMutation({
|
|
1864
|
-
mutationFn: (v) => fetcher(config, v),
|
|
1865
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
1866
|
-
if (result.success) {
|
|
1867
|
-
await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.activity.all() });
|
|
1868
|
-
}
|
|
1869
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
1870
|
-
},
|
|
1871
|
-
...options
|
|
1872
|
-
});
|
|
1873
|
-
};
|
|
1874
|
-
}
|
|
1875
|
-
var useHideActivityItem = makeHideHook(
|
|
1876
|
-
(config, input) => hideActivityItem(config, input)
|
|
1877
|
-
);
|
|
1878
|
-
var useUnhideActivityItem = makeHideHook(
|
|
1879
|
-
(config, input) => unhideActivityItem(config, input)
|
|
1880
|
-
);
|
|
1881
|
-
|
|
1882
|
-
// src/query/fetchers/stats.ts
|
|
1883
|
-
async function fetchStats(config, options = {}) {
|
|
1884
|
-
try {
|
|
1885
|
-
return await apiFetch(config, "/api/stats", {
|
|
1886
|
-
next: { revalidate: 900 },
|
|
1887
|
-
...options
|
|
1888
|
-
});
|
|
1889
|
-
} catch {
|
|
1890
|
-
return null;
|
|
1891
|
-
}
|
|
1892
|
-
}
|
|
1893
|
-
|
|
1894
|
-
// src/query/hooks/use-stats.ts
|
|
1895
|
-
function useStats(options) {
|
|
1896
|
-
const config = useSifaConfig();
|
|
1897
|
-
return useQuery({
|
|
1898
|
-
queryKey: sifaQueryKeys.stats.homepage(),
|
|
1899
|
-
queryFn: () => fetchStats(config),
|
|
1900
|
-
...options
|
|
1901
|
-
});
|
|
1902
|
-
}
|
|
1903
|
-
|
|
1904
|
-
// src/query/fetchers/apps.ts
|
|
1905
|
-
async function fetchAppsRegistry(config, options = {}) {
|
|
1906
|
-
try {
|
|
1907
|
-
return await apiFetch(config, "/api/apps/registry", {
|
|
1908
|
-
next: { revalidate: 86400 },
|
|
1909
|
-
...options
|
|
1910
|
-
});
|
|
1911
|
-
} catch {
|
|
1912
|
-
return [];
|
|
1913
|
-
}
|
|
1914
|
-
}
|
|
1915
|
-
async function fetchHiddenApps(config, options = {}) {
|
|
1916
|
-
const headers = { ...options.headers ?? {} };
|
|
1917
|
-
if (options.cookieHeader) headers.cookie = options.cookieHeader;
|
|
1918
|
-
try {
|
|
1919
|
-
const data = await apiFetch(config, "/api/profile/hidden-apps", {
|
|
1920
|
-
credentials: "include",
|
|
1921
|
-
...options,
|
|
1922
|
-
headers
|
|
1923
|
-
});
|
|
1924
|
-
return data.apps;
|
|
1925
|
-
} catch {
|
|
1926
|
-
return [];
|
|
1927
|
-
}
|
|
1928
|
-
}
|
|
1929
|
-
|
|
1930
|
-
// src/query/hooks/use-apps.ts
|
|
1931
|
-
function useAppsRegistry(options) {
|
|
1932
|
-
const config = useSifaConfig();
|
|
1933
|
-
return useQuery({
|
|
1934
|
-
queryKey: sifaQueryKeys.apps.registry(),
|
|
1935
|
-
queryFn: () => fetchAppsRegistry(config),
|
|
1936
|
-
...options
|
|
1937
|
-
});
|
|
1938
|
-
}
|
|
1939
|
-
function useHiddenApps(options) {
|
|
1940
|
-
const config = useSifaConfig();
|
|
1941
|
-
return useQuery({
|
|
1942
|
-
queryKey: sifaQueryKeys.apps.hidden(),
|
|
1943
|
-
queryFn: () => fetchHiddenApps(config),
|
|
1944
|
-
...options
|
|
1945
|
-
});
|
|
1946
|
-
}
|
|
1947
|
-
|
|
1948
|
-
// src/query/fetchers/accounts.ts
|
|
1949
|
-
async function fetchAccounts(config, options = {}) {
|
|
1950
|
-
const headers = { ...options.headers ?? {} };
|
|
1951
|
-
if (options.cookieHeader) headers.cookie = options.cookieHeader;
|
|
1952
|
-
try {
|
|
1953
|
-
const data = await apiFetch(config, "/api/auth/accounts", {
|
|
1954
|
-
credentials: "include",
|
|
1955
|
-
...options,
|
|
1956
|
-
headers
|
|
1957
|
-
});
|
|
1958
|
-
return data.accounts;
|
|
1959
|
-
} catch {
|
|
1960
|
-
return [];
|
|
1961
|
-
}
|
|
1962
|
-
}
|
|
1963
|
-
|
|
1964
|
-
// src/query/hooks/use-accounts.ts
|
|
1965
|
-
function useAccounts(options) {
|
|
1966
|
-
const config = useSifaConfig();
|
|
1967
|
-
return useQuery({
|
|
1968
|
-
queryKey: sifaQueryKeys.auth.accounts(),
|
|
1969
|
-
queryFn: () => fetchAccounts(config),
|
|
1970
|
-
...options
|
|
1971
|
-
});
|
|
1972
|
-
}
|
|
1973
|
-
|
|
1974
|
-
// src/query/fetchers/search.ts
|
|
1975
|
-
var EMPTY_SEARCH = { profiles: [], total: 0, limit: 20, offset: 0 };
|
|
1976
|
-
var EMPTY_FILTERS = { countries: [], industries: [], apps: [], openTo: [] };
|
|
1977
|
-
var EMPTY_COMPANY_SEARCH = { results: [], hasMore: false };
|
|
1978
|
-
async function fetchSearchProfiles(config, filters, options = {}) {
|
|
1979
|
-
const params = new URLSearchParams();
|
|
1980
|
-
if (filters.q) params.set("q", filters.q);
|
|
1981
|
-
if (filters.skill) params.set("skill", filters.skill);
|
|
1982
|
-
if (filters.country) params.set("country", filters.country);
|
|
1983
|
-
if (filters.industry) params.set("industry", filters.industry);
|
|
1984
|
-
if (filters.domain) params.set("domain", filters.domain);
|
|
1985
|
-
if (filters.workplace) params.set("workplace", filters.workplace);
|
|
1986
|
-
if (filters.app) params.set("app", filters.app);
|
|
1987
|
-
if (filters.openTo && filters.openTo.length > 0) {
|
|
1988
|
-
for (const token of filters.openTo) {
|
|
1989
|
-
if (token) params.append("openTo", token);
|
|
1990
|
-
}
|
|
1991
|
-
}
|
|
1992
|
-
if (filters.limit !== void 0) params.set("limit", String(filters.limit));
|
|
1993
|
-
if (params.size === 0) return EMPTY_SEARCH;
|
|
1994
|
-
return apiFetch(config, `/api/search/profiles?${params.toString()}`, {
|
|
1995
|
-
cache: "no-store",
|
|
1996
|
-
...options
|
|
1997
|
-
});
|
|
1998
|
-
}
|
|
1999
|
-
async function fetchSearchCompanies(config, filters, options = {}) {
|
|
2000
|
-
const q = filters.q?.trim();
|
|
2001
|
-
if (!q) return EMPTY_COMPANY_SEARCH;
|
|
2002
|
-
const params = new URLSearchParams({ q });
|
|
2003
|
-
if (filters.country) params.set("country", filters.country);
|
|
2004
|
-
if (filters.industry) params.set("industry", filters.industry);
|
|
2005
|
-
if (filters.limit !== void 0) params.set("limit", String(filters.limit));
|
|
2006
|
-
return apiFetch(config, `/api/search/companies?${params.toString()}`, {
|
|
2007
|
-
cache: "no-store",
|
|
2008
|
-
...options
|
|
2009
|
-
});
|
|
2010
|
-
}
|
|
2011
|
-
async function fetchSkillSuggestions(config, query, options = {}) {
|
|
2012
|
-
if (!query.trim()) return [];
|
|
2013
|
-
const path = `/api/search/skills?q=${encodeURIComponent(query)}&limit=8`;
|
|
2014
|
-
const data = await apiFetch(config, path, {
|
|
2015
|
-
cache: "no-store",
|
|
2016
|
-
...options
|
|
2017
|
-
});
|
|
2018
|
-
return data.skills ?? [];
|
|
2019
|
-
}
|
|
2020
|
-
async function fetchSearchFilters(config, options = {}) {
|
|
2021
|
-
try {
|
|
2022
|
-
return await apiFetch(config, "/api/search/filters", {
|
|
2023
|
-
next: { revalidate: 300 },
|
|
2024
|
-
...options
|
|
2025
|
-
});
|
|
2026
|
-
} catch {
|
|
2027
|
-
return EMPTY_FILTERS;
|
|
2028
|
-
}
|
|
2029
|
-
}
|
|
2030
|
-
async function searchSkills(config, query, limit = 10, options = {}) {
|
|
2031
|
-
if (!query.trim()) return [];
|
|
2032
|
-
const path = `/api/skills/search?q=${encodeURIComponent(query)}&limit=${limit}`;
|
|
2033
|
-
try {
|
|
2034
|
-
const data = await apiFetch(config, path, {
|
|
2035
|
-
cache: "no-store",
|
|
2036
|
-
...options
|
|
2037
|
-
});
|
|
2038
|
-
return data.skills ?? [];
|
|
2039
|
-
} catch {
|
|
2040
|
-
return [];
|
|
2041
|
-
}
|
|
2042
|
-
}
|
|
2043
|
-
|
|
2044
|
-
// src/query/hooks/use-search.ts
|
|
2045
|
-
function useSearchProfiles(filters, options) {
|
|
2046
|
-
const config = useSifaConfig();
|
|
2047
|
-
return useQuery({
|
|
2048
|
-
queryKey: sifaQueryKeys.search.profiles(filters),
|
|
2049
|
-
queryFn: () => fetchSearchProfiles(config, filters),
|
|
2050
|
-
...options
|
|
2051
|
-
});
|
|
2052
|
-
}
|
|
2053
|
-
function useSkillSuggestions(query, options) {
|
|
2054
|
-
const config = useSifaConfig();
|
|
2055
|
-
return useQuery({
|
|
2056
|
-
queryKey: sifaQueryKeys.search.skills(query),
|
|
2057
|
-
queryFn: () => fetchSkillSuggestions(config, query),
|
|
2058
|
-
enabled: query.trim().length > 0 && (options?.enabled ?? true),
|
|
2059
|
-
...options
|
|
2060
|
-
});
|
|
2061
|
-
}
|
|
2062
|
-
function useCanonicalSkillSearch(query, limit = 10, options) {
|
|
2063
|
-
const config = useSifaConfig();
|
|
2064
|
-
return useQuery({
|
|
2065
|
-
queryKey: sifaQueryKeys.search.canonicalSkills(query, limit),
|
|
2066
|
-
queryFn: () => searchSkills(config, query, limit),
|
|
2067
|
-
enabled: query.trim().length > 0 && (options?.enabled ?? true),
|
|
2068
|
-
...options
|
|
2069
|
-
});
|
|
2070
|
-
}
|
|
2071
|
-
function useSearchFilters(options) {
|
|
2072
|
-
const config = useSifaConfig();
|
|
2073
|
-
return useQuery({
|
|
2074
|
-
queryKey: sifaQueryKeys.search.filters(),
|
|
2075
|
-
queryFn: () => fetchSearchFilters(config),
|
|
2076
|
-
...options
|
|
2077
|
-
});
|
|
2078
|
-
}
|
|
2079
|
-
function useSearchCompanies(filters, options) {
|
|
2080
|
-
const config = useSifaConfig();
|
|
2081
|
-
return useQuery({
|
|
2082
|
-
queryKey: sifaQueryKeys.search.companies(filters),
|
|
2083
|
-
queryFn: () => fetchSearchCompanies(config, filters),
|
|
2084
|
-
...options
|
|
2085
|
-
});
|
|
2086
|
-
}
|
|
2087
|
-
|
|
2088
|
-
// src/query/fetchers/discovery.ts
|
|
2089
|
-
async function fetchSimilarProfiles(config, did, opts = {}) {
|
|
2090
|
-
const limit = opts.limit ?? 5;
|
|
2091
|
-
const path = `/api/discover/similar/${encodeIdentifier(did)}?limit=${limit}`;
|
|
2092
|
-
try {
|
|
2093
|
-
const data = await apiFetch(config, path, {
|
|
2094
|
-
next: { revalidate: 300 },
|
|
2095
|
-
timeoutMs: 5e3,
|
|
2096
|
-
...opts
|
|
2097
|
-
});
|
|
2098
|
-
return data.profiles ?? [];
|
|
2099
|
-
} catch {
|
|
2100
|
-
return [];
|
|
2101
|
-
}
|
|
2102
|
-
}
|
|
2103
|
-
async function fetchSuggestions(config, opts = {}) {
|
|
2104
|
-
const params = new URLSearchParams();
|
|
2105
|
-
if (opts.source) params.set("source", opts.source);
|
|
2106
|
-
if (opts.includeDismissed) params.set("include_dismissed", "true");
|
|
2107
|
-
if (opts.cursor) params.set("cursor", opts.cursor);
|
|
2108
|
-
if (opts.limit) params.set("limit", String(opts.limit));
|
|
2109
|
-
const qs = params.toString();
|
|
2110
|
-
const headers = { ...opts.headers ?? {} };
|
|
2111
|
-
if (opts.cookieHeader) headers.cookie = opts.cookieHeader;
|
|
2112
|
-
try {
|
|
2113
|
-
return await apiFetch(config, `/api/suggestions${qs ? `?${qs}` : ""}`, {
|
|
2114
|
-
credentials: "include",
|
|
2115
|
-
cache: "no-store",
|
|
2116
|
-
timeoutMs: 8e3,
|
|
2117
|
-
...opts,
|
|
2118
|
-
headers
|
|
2119
|
-
});
|
|
2120
|
-
} catch {
|
|
2121
|
-
return { onSifa: [], notOnSifa: [] };
|
|
2122
|
-
}
|
|
2123
|
-
}
|
|
2124
|
-
async function fetchSuggestionCount(config, since, options = {}) {
|
|
2125
|
-
const params = since ? `?since=${encodeURIComponent(since)}` : "";
|
|
2126
|
-
try {
|
|
2127
|
-
const data = await apiFetch(config, `/api/suggestions/count${params}`, {
|
|
2128
|
-
credentials: "include",
|
|
2129
|
-
cache: "no-store",
|
|
2130
|
-
...options
|
|
2131
|
-
});
|
|
2132
|
-
return data.count ?? 0;
|
|
2133
|
-
} catch {
|
|
2134
|
-
return 0;
|
|
2135
|
-
}
|
|
2136
|
-
}
|
|
2137
|
-
async function fetchFeaturedProfile(config, options = {}) {
|
|
2138
|
-
try {
|
|
2139
|
-
return await apiFetch(config, "/api/featured-profile", {
|
|
2140
|
-
next: { revalidate: 900 },
|
|
2141
|
-
...options
|
|
2142
|
-
});
|
|
2143
|
-
} catch {
|
|
2144
|
-
return null;
|
|
2145
|
-
}
|
|
2146
|
-
}
|
|
2147
|
-
|
|
2148
|
-
// src/query/hooks/use-discovery.ts
|
|
2149
|
-
function useSimilarProfiles(did, opts = {}, options) {
|
|
2150
|
-
const config = useSifaConfig();
|
|
2151
|
-
const limit = opts.limit ?? 5;
|
|
2152
|
-
return useQuery({
|
|
2153
|
-
queryKey: sifaQueryKeys.discovery.similar(did ?? "", limit),
|
|
2154
|
-
queryFn: () => fetchSimilarProfiles(config, did ?? "", { limit }),
|
|
2155
|
-
enabled: Boolean(did) && (options?.enabled ?? true),
|
|
2156
|
-
...options
|
|
2157
|
-
});
|
|
2158
|
-
}
|
|
2159
|
-
function useSuggestions(opts = {}, options) {
|
|
2160
|
-
const config = useSifaConfig();
|
|
2161
|
-
return useQuery({
|
|
2162
|
-
queryKey: sifaQueryKeys.discovery.suggestions(opts),
|
|
2163
|
-
queryFn: () => fetchSuggestions(config, opts),
|
|
2164
|
-
...options
|
|
2165
|
-
});
|
|
2166
|
-
}
|
|
2167
|
-
function useSuggestionCount(since, options) {
|
|
2168
|
-
const config = useSifaConfig();
|
|
2169
|
-
return useQuery({
|
|
2170
|
-
queryKey: sifaQueryKeys.discovery.suggestionCount(since),
|
|
2171
|
-
queryFn: () => fetchSuggestionCount(config, since),
|
|
2172
|
-
...options
|
|
2173
|
-
});
|
|
2174
|
-
}
|
|
2175
|
-
function useFeaturedProfile(options) {
|
|
2176
|
-
const config = useSifaConfig();
|
|
2177
|
-
return useQuery({
|
|
2178
|
-
queryKey: sifaQueryKeys.discovery.featured(),
|
|
2179
|
-
queryFn: () => fetchFeaturedProfile(config),
|
|
2180
|
-
...options
|
|
2181
|
-
});
|
|
2182
|
-
}
|
|
2183
|
-
|
|
2184
|
-
// src/query/fetchers/follow.ts
|
|
2185
|
-
async function fetchFollowing(config, opts = {}) {
|
|
2186
|
-
const params = new URLSearchParams();
|
|
2187
|
-
if (opts.source) params.set("source", opts.source);
|
|
2188
|
-
if (opts.cursor) params.set("cursor", opts.cursor);
|
|
2189
|
-
if (opts.limit) params.set("limit", String(opts.limit));
|
|
2190
|
-
const qs = params.toString();
|
|
2191
|
-
try {
|
|
2192
|
-
return await apiFetch(config, `/api/following${qs ? `?${qs}` : ""}`, {
|
|
2193
|
-
credentials: "include",
|
|
2194
|
-
cache: "no-store",
|
|
2195
|
-
...opts
|
|
2196
|
-
});
|
|
2197
|
-
} catch {
|
|
2198
|
-
return { follows: [] };
|
|
2199
|
-
}
|
|
2200
|
-
}
|
|
2201
|
-
function followUser(config, handle, opts = {}) {
|
|
2202
|
-
const { note, ...rest } = opts;
|
|
2203
|
-
return apiWrite(
|
|
2204
|
-
config,
|
|
2205
|
-
`/api/follow/${encodeIdentifier(handle)}`,
|
|
2206
|
-
"POST",
|
|
2207
|
-
{
|
|
2208
|
-
body: note !== void 0 ? { note } : void 0,
|
|
2209
|
-
...rest
|
|
2210
|
-
}
|
|
2211
|
-
);
|
|
2212
|
-
}
|
|
2213
|
-
function unfollowUser(config, handle, opts = {}) {
|
|
2214
|
-
return apiWrite(config, `/api/follow/${encodeIdentifier(handle)}`, "DELETE", opts);
|
|
2215
|
-
}
|
|
2216
|
-
function buildListPath(prefix, opts) {
|
|
2217
|
-
const params = new URLSearchParams();
|
|
2218
|
-
if (opts.cursor) params.set("cursor", opts.cursor);
|
|
2219
|
-
if (opts.limit) params.set("limit", String(opts.limit));
|
|
2220
|
-
const qs = params.toString();
|
|
2221
|
-
return `${prefix}${qs ? `?${qs}` : ""}`;
|
|
2222
|
-
}
|
|
2223
|
-
async function getFollowers(config, handle, opts = {}) {
|
|
2224
|
-
const headers = { ...opts.headers ?? {} };
|
|
2225
|
-
if (opts.cookieHeader) headers.cookie = opts.cookieHeader;
|
|
2226
|
-
try {
|
|
2227
|
-
const res = await apiFetch(
|
|
2228
|
-
config,
|
|
2229
|
-
buildListPath(`/api/profile/${encodeIdentifier(handle)}/followers`, opts),
|
|
2230
|
-
{ credentials: "include", cache: "no-store", ...opts, headers }
|
|
2231
|
-
);
|
|
2232
|
-
return { follows: res.follows, cursor: res.cursor ?? null };
|
|
2233
|
-
} catch {
|
|
2234
|
-
return { follows: [], cursor: null };
|
|
2235
|
-
}
|
|
2236
|
-
}
|
|
2237
|
-
async function getFollowing(config, handle, opts = {}) {
|
|
2238
|
-
const headers = { ...opts.headers ?? {} };
|
|
2239
|
-
if (opts.cookieHeader) headers.cookie = opts.cookieHeader;
|
|
2240
|
-
try {
|
|
2241
|
-
const res = await apiFetch(
|
|
2242
|
-
config,
|
|
2243
|
-
buildListPath(`/api/profile/${encodeIdentifier(handle)}/following`, opts),
|
|
2244
|
-
{ credentials: "include", cache: "no-store", ...opts, headers }
|
|
2245
|
-
);
|
|
2246
|
-
return { follows: res.follows, cursor: res.cursor ?? null };
|
|
2247
|
-
} catch {
|
|
2248
|
-
return { follows: [], cursor: null };
|
|
2249
|
-
}
|
|
2250
|
-
}
|
|
2251
|
-
var FOLLOWING_FEED_LXM = "id.sifa.feed.getFollowingFeed";
|
|
2252
|
-
async function fetchFollowingFeed(config, opts = {}) {
|
|
2253
|
-
const params = new URLSearchParams();
|
|
2254
|
-
if (opts.limit) params.set("limit", String(opts.limit));
|
|
2255
|
-
if (opts.app) params.set("app", opts.app);
|
|
2256
|
-
else if (opts.includeBluesky) params.set("includeBluesky", "true");
|
|
2257
|
-
const qs = params.toString();
|
|
2258
|
-
const headers = { ...opts.headers ?? {} };
|
|
2259
|
-
if (opts.cookieHeader) headers.cookie = opts.cookieHeader;
|
|
2260
|
-
if (config.getAuthToken) {
|
|
2261
|
-
const token = await config.getAuthToken(FOLLOWING_FEED_LXM);
|
|
2262
|
-
if (token) headers.Authorization = `Bearer ${token}`;
|
|
2263
|
-
}
|
|
2264
|
-
try {
|
|
2265
|
-
return await apiFetch(
|
|
2266
|
-
config,
|
|
2267
|
-
`/api/following/feed${qs ? `?${qs}` : ""}`,
|
|
2268
|
-
{ credentials: "include", cache: "no-store", ...opts, headers }
|
|
2269
|
-
);
|
|
2270
|
-
} catch {
|
|
2271
|
-
return null;
|
|
2272
|
-
}
|
|
2273
|
-
}
|
|
2274
|
-
|
|
2275
|
-
// src/query/hooks/use-follow.ts
|
|
2276
|
-
function useFollowing(opts = {}, options) {
|
|
2277
|
-
const config = useSifaConfig();
|
|
2278
|
-
return useQuery({
|
|
2279
|
-
queryKey: sifaQueryKeys.follow.following(opts),
|
|
2280
|
-
queryFn: () => fetchFollowing(config, opts),
|
|
2281
|
-
...options
|
|
2282
|
-
});
|
|
2283
|
-
}
|
|
2284
|
-
function useFollow(options) {
|
|
2285
|
-
const config = useSifaConfig();
|
|
2286
|
-
const queryClient = useQueryClient();
|
|
2287
|
-
return useMutation({
|
|
2288
|
-
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
2289
|
-
// one below and silently drop cache invalidation (#453).
|
|
2290
|
-
...options,
|
|
2291
|
-
mutationFn: ({ handle, note }) => followUser(config, handle, { note }),
|
|
2292
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
2293
|
-
if (result.success) {
|
|
2294
|
-
await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.follow.all() });
|
|
2295
|
-
}
|
|
2296
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
2297
|
-
},
|
|
2298
|
-
onError: async (error, variables, onMutateResult, context) => {
|
|
2299
|
-
await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.follow.all() });
|
|
2300
|
-
await options?.onError?.(error, variables, onMutateResult, context);
|
|
2301
|
-
}
|
|
2302
|
-
});
|
|
2303
|
-
}
|
|
2304
|
-
function useUnfollow(options) {
|
|
2305
|
-
const config = useSifaConfig();
|
|
2306
|
-
const queryClient = useQueryClient();
|
|
2307
|
-
return useMutation({
|
|
2308
|
-
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
2309
|
-
// one below and silently drop cache invalidation (#453).
|
|
2310
|
-
...options,
|
|
2311
|
-
mutationFn: ({ handle }) => unfollowUser(config, handle),
|
|
2312
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
2313
|
-
if (result.success) {
|
|
2314
|
-
await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.follow.all() });
|
|
2315
|
-
}
|
|
2316
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
2317
|
-
},
|
|
2318
|
-
onError: async (error, variables, onMutateResult, context) => {
|
|
2319
|
-
await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.follow.all() });
|
|
2320
|
-
await options?.onError?.(error, variables, onMutateResult, context);
|
|
2321
|
-
}
|
|
2322
|
-
});
|
|
2323
|
-
}
|
|
2324
|
-
function useFollowers(handle, opts = {}, options) {
|
|
2325
|
-
const config = useSifaConfig();
|
|
2326
|
-
return useInfiniteQuery({
|
|
2327
|
-
queryKey: sifaQueryKeys.follow.followers(handle),
|
|
2328
|
-
queryFn: ({ pageParam }) => getFollowers(config, handle, { ...opts, cursor: pageParam }),
|
|
2329
|
-
initialPageParam: void 0,
|
|
2330
|
-
getNextPageParam: (lastPage) => lastPage.cursor ?? void 0,
|
|
2331
|
-
enabled: handle.length > 0,
|
|
2332
|
-
...options
|
|
2333
|
-
});
|
|
2334
|
-
}
|
|
2335
|
-
function useFollowingList(handle, opts = {}, options) {
|
|
2336
|
-
const config = useSifaConfig();
|
|
2337
|
-
return useInfiniteQuery({
|
|
2338
|
-
queryKey: sifaQueryKeys.follow.followingOf(handle),
|
|
2339
|
-
queryFn: ({ pageParam }) => getFollowing(config, handle, { ...opts, cursor: pageParam }),
|
|
2340
|
-
initialPageParam: void 0,
|
|
2341
|
-
getNextPageParam: (lastPage) => lastPage.cursor ?? void 0,
|
|
2342
|
-
enabled: handle.length > 0,
|
|
2343
|
-
...options
|
|
2344
|
-
});
|
|
2345
|
-
}
|
|
2346
|
-
function useFollowingFeed(opts = {}, options) {
|
|
2347
|
-
const config = useSifaConfig();
|
|
2348
|
-
return useQuery({
|
|
2349
|
-
// `app` is part of the key: each source tab is its own cache entry, so
|
|
2350
|
-
// switching tabs does not serve the previous tab's items.
|
|
2351
|
-
queryKey: sifaQueryKeys.follow.feed({
|
|
2352
|
-
limit: opts.limit,
|
|
2353
|
-
includeBluesky: opts.includeBluesky,
|
|
2354
|
-
app: opts.app
|
|
2355
|
-
}),
|
|
2356
|
-
queryFn: () => fetchFollowingFeed(config, opts),
|
|
2357
|
-
...options
|
|
2358
|
-
});
|
|
2359
|
-
}
|
|
2360
|
-
|
|
2361
|
-
// src/query/fetchers/follow-extras.ts
|
|
2362
|
-
function buildListPath2(prefix, opts) {
|
|
2363
|
-
const params = new URLSearchParams();
|
|
2364
|
-
if (opts.cursor) params.set("cursor", opts.cursor);
|
|
2365
|
-
if (opts.limit) params.set("limit", String(opts.limit));
|
|
2366
|
-
const qs = params.toString();
|
|
2367
|
-
return `${prefix}${qs ? `?${qs}` : ""}`;
|
|
2368
|
-
}
|
|
2369
|
-
async function fetchFollowProfilePage(config, path, opts) {
|
|
2370
|
-
const headers = { ...opts.headers ?? {} };
|
|
2371
|
-
if (opts.cookieHeader) headers.cookie = opts.cookieHeader;
|
|
2372
|
-
try {
|
|
2373
|
-
const res = await apiFetch(
|
|
2374
|
-
config,
|
|
2375
|
-
path,
|
|
2376
|
-
{ credentials: "include", cache: "no-store", ...opts, headers }
|
|
2377
|
-
);
|
|
2378
|
-
return { items: res.items ?? [], cursor: res.cursor ?? null };
|
|
2379
|
-
} catch {
|
|
2380
|
-
return { items: [], cursor: null };
|
|
2381
|
-
}
|
|
2382
|
-
}
|
|
2383
|
-
async function getMutuals(config, handleOrDid, opts = {}) {
|
|
2384
|
-
return fetchFollowProfilePage(
|
|
2385
|
-
config,
|
|
2386
|
-
buildListPath2(`/api/profile/${encodeIdentifier(handleOrDid)}/mutuals`, opts),
|
|
2387
|
-
opts
|
|
2388
|
-
);
|
|
2389
|
-
}
|
|
2390
|
-
async function getBlueskySuggestions(config, opts = {}) {
|
|
2391
|
-
return fetchFollowProfilePage(config, buildListPath2("/api/me/bluesky-suggestions", opts), opts);
|
|
2392
|
-
}
|
|
2393
|
-
|
|
2394
|
-
// src/query/hooks/use-follow-extras.ts
|
|
2395
|
-
function useMutuals(handleOrDid, opts = {}, options) {
|
|
2396
|
-
const config = useSifaConfig();
|
|
2397
|
-
return useInfiniteQuery({
|
|
2398
|
-
queryKey: sifaQueryKeys.follow.mutuals(handleOrDid),
|
|
2399
|
-
queryFn: ({ pageParam }) => getMutuals(config, handleOrDid, { ...opts, cursor: pageParam }),
|
|
2400
|
-
initialPageParam: void 0,
|
|
2401
|
-
getNextPageParam: (lastPage) => lastPage.cursor ?? void 0,
|
|
2402
|
-
enabled: handleOrDid.length > 0,
|
|
2403
|
-
...options
|
|
2404
|
-
});
|
|
2405
|
-
}
|
|
2406
|
-
function useBlueskySuggestions(opts = {}, options) {
|
|
2407
|
-
const config = useSifaConfig();
|
|
2408
|
-
return useInfiniteQuery({
|
|
2409
|
-
queryKey: sifaQueryKeys.follow.blueskySuggestions(),
|
|
2410
|
-
queryFn: ({ pageParam }) => getBlueskySuggestions(config, { ...opts, cursor: pageParam }),
|
|
2411
|
-
initialPageParam: void 0,
|
|
2412
|
-
getNextPageParam: (lastPage) => lastPage.cursor ?? void 0,
|
|
2413
|
-
...options
|
|
2414
|
-
});
|
|
2415
|
-
}
|
|
2416
|
-
|
|
2417
|
-
// src/query/fetchers/admin-feature-allowlists.ts
|
|
2418
|
-
async function listFeatureAllowlist(config, flag, opts = {}) {
|
|
2419
|
-
const headers = { ...opts.headers ?? {} };
|
|
2420
|
-
if (opts.cookieHeader) headers.cookie = opts.cookieHeader;
|
|
2421
|
-
try {
|
|
2422
|
-
const res = await apiFetch(
|
|
2423
|
-
config,
|
|
2424
|
-
`/api/admin/feature-allowlists/${encodeURIComponent(flag)}`,
|
|
2425
|
-
{ credentials: "include", cache: "no-store", ...opts, headers }
|
|
2426
|
-
);
|
|
2427
|
-
return { items: res.items ?? [] };
|
|
2428
|
-
} catch {
|
|
2429
|
-
return { items: [] };
|
|
2430
|
-
}
|
|
2431
|
-
}
|
|
2432
|
-
function addFeatureAllowlist(config, flag, did, opts = {}) {
|
|
2433
|
-
const { note, ...rest } = opts;
|
|
2434
|
-
return apiWrite(config, `/api/admin/feature-allowlists/${encodeURIComponent(flag)}`, "POST", {
|
|
2435
|
-
body: note !== void 0 ? { did, note } : { did },
|
|
2436
|
-
...rest
|
|
2437
|
-
});
|
|
2438
|
-
}
|
|
2439
|
-
function removeFeatureAllowlist(config, flag, did, opts = {}) {
|
|
2440
|
-
return apiWrite(
|
|
2441
|
-
config,
|
|
2442
|
-
`/api/admin/feature-allowlists/${encodeURIComponent(flag)}/${encodeIdentifier(did)}`,
|
|
2443
|
-
"DELETE",
|
|
2444
|
-
opts
|
|
2445
|
-
);
|
|
2446
|
-
}
|
|
2447
|
-
|
|
2448
|
-
// src/query/hooks/use-feature-allowlist.ts
|
|
2449
|
-
function useFeatureAllowlist(flag, options) {
|
|
2450
|
-
const config = useSifaConfig();
|
|
2451
|
-
return useQuery({
|
|
2452
|
-
queryKey: sifaQueryKeys.admin.featureAllowlist(flag),
|
|
2453
|
-
queryFn: () => listFeatureAllowlist(config, flag),
|
|
2454
|
-
...options
|
|
2455
|
-
});
|
|
2456
|
-
}
|
|
2457
|
-
function useAddFeatureAllowlist(flag, options) {
|
|
2458
|
-
const config = useSifaConfig();
|
|
2459
|
-
const queryClient = useQueryClient();
|
|
2460
|
-
const key = sifaQueryKeys.admin.featureAllowlist(flag);
|
|
2461
|
-
return useMutation({
|
|
2462
|
-
mutationFn: ({ did, note }) => addFeatureAllowlist(config, flag, did, { note }),
|
|
2463
|
-
onMutate: async ({ did, note }) => {
|
|
2464
|
-
await queryClient.cancelQueries({ queryKey: key });
|
|
2465
|
-
const previous = queryClient.getQueryData(key);
|
|
2466
|
-
const optimisticEntry = {
|
|
2467
|
-
did,
|
|
2468
|
-
addedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2469
|
-
note: note ?? null
|
|
2470
|
-
};
|
|
2471
|
-
const next = previous ? { items: [optimisticEntry, ...previous.items.filter((e) => e.did !== did)] } : { items: [optimisticEntry] };
|
|
2472
|
-
queryClient.setQueryData(key, next);
|
|
2473
|
-
return { previous };
|
|
2474
|
-
},
|
|
2475
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
2476
|
-
if (!result.success && onMutateResult?.previous) {
|
|
2477
|
-
queryClient.setQueryData(key, onMutateResult.previous);
|
|
2478
|
-
}
|
|
2479
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
2480
|
-
},
|
|
2481
|
-
onError: async (error, variables, onMutateResult, context) => {
|
|
2482
|
-
if (onMutateResult?.previous) {
|
|
2483
|
-
queryClient.setQueryData(key, onMutateResult.previous);
|
|
2484
|
-
}
|
|
2485
|
-
await options?.onError?.(error, variables, onMutateResult, context);
|
|
2486
|
-
},
|
|
2487
|
-
onSettled: async (result, error, variables, onMutateResult, context) => {
|
|
2488
|
-
await queryClient.invalidateQueries({ queryKey: key });
|
|
2489
|
-
await options?.onSettled?.(result, error, variables, onMutateResult, context);
|
|
2490
|
-
},
|
|
2491
|
-
...options
|
|
2492
|
-
});
|
|
2493
|
-
}
|
|
2494
|
-
function useRemoveFeatureAllowlist(flag, options) {
|
|
2495
|
-
const config = useSifaConfig();
|
|
2496
|
-
const queryClient = useQueryClient();
|
|
2497
|
-
const key = sifaQueryKeys.admin.featureAllowlist(flag);
|
|
2498
|
-
return useMutation(
|
|
2499
|
-
{
|
|
2500
|
-
mutationFn: ({ did }) => removeFeatureAllowlist(config, flag, did),
|
|
2501
|
-
onMutate: async ({ did }) => {
|
|
2502
|
-
await queryClient.cancelQueries({ queryKey: key });
|
|
2503
|
-
const previous = queryClient.getQueryData(key);
|
|
2504
|
-
if (previous) {
|
|
2505
|
-
queryClient.setQueryData(key, {
|
|
2506
|
-
items: previous.items.filter((e) => e.did !== did)
|
|
2507
|
-
});
|
|
2508
|
-
}
|
|
2509
|
-
return { previous };
|
|
2510
|
-
},
|
|
2511
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
2512
|
-
if (!result.success && onMutateResult?.previous) {
|
|
2513
|
-
queryClient.setQueryData(key, onMutateResult.previous);
|
|
2514
|
-
}
|
|
2515
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
2516
|
-
},
|
|
2517
|
-
onError: async (error, variables, onMutateResult, context) => {
|
|
2518
|
-
if (onMutateResult?.previous) {
|
|
2519
|
-
queryClient.setQueryData(key, onMutateResult.previous);
|
|
2520
|
-
}
|
|
2521
|
-
await options?.onError?.(error, variables, onMutateResult, context);
|
|
2522
|
-
},
|
|
2523
|
-
onSettled: async (result, error, variables, onMutateResult, context) => {
|
|
2524
|
-
await queryClient.invalidateQueries({ queryKey: key });
|
|
2525
|
-
await options?.onSettled?.(result, error, variables, onMutateResult, context);
|
|
2526
|
-
},
|
|
2527
|
-
...options
|
|
2528
|
-
}
|
|
2529
|
-
);
|
|
2530
|
-
}
|
|
2531
|
-
|
|
2532
|
-
// src/query/fetchers/admin-review-queues.ts
|
|
2533
|
-
async function getAdminReviewQueues(config, opts = {}) {
|
|
2534
|
-
const headers = { ...opts.headers ?? {} };
|
|
2535
|
-
if (opts.cookieHeader) headers.cookie = opts.cookieHeader;
|
|
2536
|
-
const res = await apiFetch(config, "/api/admin/stats/review-queues", {
|
|
2537
|
-
credentials: "include",
|
|
2538
|
-
cache: "no-store",
|
|
2539
|
-
...opts,
|
|
2540
|
-
headers
|
|
2541
|
-
});
|
|
2542
|
-
const ideas = res.ideas ?? 0;
|
|
2543
|
-
const nameCorrections = res.nameCorrections ?? 0;
|
|
2544
|
-
const pendingCompanies = res.pendingCompanies ?? 0;
|
|
2545
|
-
const duplicateOrgs = res.duplicateOrgs ?? 0;
|
|
2546
|
-
return {
|
|
2547
|
-
ideas,
|
|
2548
|
-
nameCorrections,
|
|
2549
|
-
pendingCompanies,
|
|
2550
|
-
duplicateOrgs,
|
|
2551
|
-
// Derived rather than trusted so an API that predates the field still
|
|
2552
|
-
// yields a usable pill count.
|
|
2553
|
-
total: res.total ?? ideas + nameCorrections + pendingCompanies + duplicateOrgs,
|
|
2554
|
-
generatedAt: res.generatedAt ?? ""
|
|
2555
|
-
};
|
|
2556
|
-
}
|
|
2557
|
-
|
|
2558
|
-
// src/query/hooks/use-admin-review-queues.ts
|
|
2559
|
-
var REVIEW_QUEUES_STALE_TIME_MS = 6e4;
|
|
2560
|
-
function useAdminReviewQueues(options) {
|
|
2561
|
-
const config = useSifaConfig();
|
|
2562
|
-
return useQuery({
|
|
2563
|
-
queryKey: sifaQueryKeys.admin.reviewQueues(),
|
|
2564
|
-
queryFn: () => getAdminReviewQueues(config),
|
|
2565
|
-
staleTime: REVIEW_QUEUES_STALE_TIME_MS,
|
|
2566
|
-
...options
|
|
2567
|
-
});
|
|
2568
|
-
}
|
|
2569
|
-
|
|
2570
|
-
// src/query/fetchers/activity.ts
|
|
2571
|
-
async function fetchHeatmapData(config, handleOrDid, days, options = {}) {
|
|
2572
|
-
const path = `/api/activity/${encodeIdentifier(handleOrDid)}/heatmap?days=${days}`;
|
|
2573
|
-
try {
|
|
2574
|
-
return await apiFetch(config, path, {
|
|
2575
|
-
next: { revalidate: 900, tags: [`heatmap-${handleOrDid}`] },
|
|
2576
|
-
...options
|
|
2577
|
-
});
|
|
2578
|
-
} catch {
|
|
2579
|
-
return null;
|
|
2580
|
-
}
|
|
2581
|
-
}
|
|
2582
|
-
async function fetchActivityTeaser(config, handleOrDid, options = {}) {
|
|
2583
|
-
const headers = { ...options.headers ?? {} };
|
|
2584
|
-
if (options.cookieHeader) headers.cookie = options.cookieHeader;
|
|
2585
|
-
try {
|
|
2586
|
-
return await apiFetch(
|
|
2587
|
-
config,
|
|
2588
|
-
`/api/activity/${encodeIdentifier(handleOrDid)}/teaser`,
|
|
2589
|
-
{
|
|
2590
|
-
credentials: "include",
|
|
2591
|
-
timeoutMs: 8e3,
|
|
2592
|
-
next: { revalidate: 300, tags: [`activity-teaser-${handleOrDid}`] },
|
|
2593
|
-
...options,
|
|
2594
|
-
headers
|
|
2595
|
-
}
|
|
2596
|
-
);
|
|
2597
|
-
} catch {
|
|
2598
|
-
return null;
|
|
2599
|
-
}
|
|
2600
|
-
}
|
|
2601
|
-
async function fetchActivityFeed(config, handleOrDid, options = {}) {
|
|
2602
|
-
const params = new URLSearchParams();
|
|
2603
|
-
if (options.category) params.set("category", options.category);
|
|
2604
|
-
if (options.limit) params.set("limit", String(options.limit));
|
|
2605
|
-
if (options.cursor) params.set("cursor", options.cursor);
|
|
2606
|
-
const qs = params.toString();
|
|
2607
|
-
const headers = { ...options.headers ?? {} };
|
|
2608
|
-
if (options.cookieHeader) headers.cookie = options.cookieHeader;
|
|
2609
|
-
try {
|
|
2610
|
-
return await apiFetch(
|
|
2611
|
-
config,
|
|
2612
|
-
`/api/activity/${encodeIdentifier(handleOrDid)}${qs ? `?${qs}` : ""}`,
|
|
2613
|
-
{
|
|
2614
|
-
credentials: "include",
|
|
2615
|
-
cache: "no-store",
|
|
2616
|
-
...options,
|
|
2617
|
-
headers
|
|
2618
|
-
}
|
|
2619
|
-
);
|
|
2620
|
-
} catch {
|
|
2621
|
-
return null;
|
|
2622
|
-
}
|
|
2623
|
-
}
|
|
2624
|
-
|
|
2625
|
-
// src/query/hooks/use-activity.ts
|
|
2626
|
-
function useHeatmapData(handleOrDid, days, options) {
|
|
2627
|
-
const config = useSifaConfig();
|
|
2628
|
-
return useQuery({
|
|
2629
|
-
queryKey: sifaQueryKeys.activity.heatmap(handleOrDid ?? "", days),
|
|
2630
|
-
queryFn: () => fetchHeatmapData(config, handleOrDid ?? "", days),
|
|
2631
|
-
enabled: Boolean(handleOrDid) && (options?.enabled ?? true),
|
|
2632
|
-
...options
|
|
2633
|
-
});
|
|
2634
|
-
}
|
|
2635
|
-
function useActivityTeaser(handleOrDid, options) {
|
|
2636
|
-
const config = useSifaConfig();
|
|
2637
|
-
return useQuery({
|
|
2638
|
-
queryKey: sifaQueryKeys.activity.teaser(handleOrDid ?? ""),
|
|
2639
|
-
queryFn: () => fetchActivityTeaser(config, handleOrDid ?? ""),
|
|
2640
|
-
enabled: Boolean(handleOrDid) && (options?.enabled ?? true),
|
|
2641
|
-
...options
|
|
2642
|
-
});
|
|
2643
|
-
}
|
|
2644
|
-
function useActivityFeed(handleOrDid, opts = {}, options) {
|
|
2645
|
-
const config = useSifaConfig();
|
|
2646
|
-
return useQuery({
|
|
2647
|
-
queryKey: sifaQueryKeys.activity.feed(handleOrDid ?? "", opts),
|
|
2648
|
-
queryFn: () => fetchActivityFeed(config, handleOrDid ?? "", opts),
|
|
2649
|
-
enabled: Boolean(handleOrDid) && (options?.enabled ?? true),
|
|
2650
|
-
...options
|
|
2651
|
-
});
|
|
2652
|
-
}
|
|
2653
|
-
var GithubPullRequestSchema = z.object({
|
|
2654
|
-
prNumber: z.number(),
|
|
2655
|
-
repoOwner: z.string(),
|
|
2656
|
-
repoName: z.string(),
|
|
2657
|
-
title: z.string(),
|
|
2658
|
-
url: z.string(),
|
|
2659
|
-
language: z.string().nullable(),
|
|
2660
|
-
additions: z.number(),
|
|
2661
|
-
deletions: z.number(),
|
|
2662
|
-
/** ISO 8601 merge timestamp. */
|
|
2663
|
-
mergedAt: z.string()
|
|
2664
|
-
});
|
|
2665
|
-
var MyGithubPullRequestsResponseSchema = z.object({
|
|
2666
|
-
items: z.array(GithubPullRequestSchema),
|
|
2667
|
-
hasMore: z.boolean()
|
|
2668
|
-
});
|
|
2669
|
-
async function fetchMyGithubPullRequests(config, options = {}) {
|
|
2670
|
-
const { limit, offset, cookieHeader, ...fetchOptions } = options;
|
|
2671
|
-
const params = new URLSearchParams();
|
|
2672
|
-
if (limit !== void 0) params.set("limit", String(limit));
|
|
2673
|
-
if (offset !== void 0) params.set("offset", String(offset));
|
|
2674
|
-
const qs = params.toString();
|
|
2675
|
-
const headers = { ...options.headers ?? {} };
|
|
2676
|
-
if (cookieHeader) headers.cookie = cookieHeader;
|
|
2677
|
-
const data = await apiFetch(
|
|
2678
|
-
config,
|
|
2679
|
-
`/api/me/github/pull-requests${qs ? `?${qs}` : ""}`,
|
|
2680
|
-
{
|
|
2681
|
-
credentials: "include",
|
|
2682
|
-
cache: "no-store",
|
|
2683
|
-
...fetchOptions,
|
|
2684
|
-
headers
|
|
2685
|
-
}
|
|
2686
|
-
);
|
|
2687
|
-
return MyGithubPullRequestsResponseSchema.parse(data);
|
|
2688
|
-
}
|
|
2689
|
-
|
|
2690
|
-
// src/query/hooks/use-github-prs.ts
|
|
2691
|
-
function useMyGithubPullRequests(params = {}, options) {
|
|
2692
|
-
const config = useSifaConfig();
|
|
2693
|
-
return useQuery({
|
|
2694
|
-
queryKey: sifaQueryKeys.github.myPullRequests(params),
|
|
2695
|
-
queryFn: () => fetchMyGithubPullRequests(config, params),
|
|
2696
|
-
...options
|
|
2697
|
-
});
|
|
2698
|
-
}
|
|
2699
|
-
|
|
2700
|
-
// src/query/fetchers/endorsement.ts
|
|
2701
|
-
async function fetchEndorsementCount(config, did, options = {}) {
|
|
2702
|
-
const path = `/api/endorsement/${encodeIdentifier(did)}`;
|
|
2703
|
-
try {
|
|
2704
|
-
const data = await apiFetch(config, path, {
|
|
2705
|
-
cache: "no-store",
|
|
2706
|
-
timeoutMs: 5e3,
|
|
2707
|
-
...options
|
|
2708
|
-
});
|
|
2709
|
-
if (typeof data !== "object" || data === null || !("endorsements" in data)) {
|
|
2710
|
-
return 0;
|
|
2711
|
-
}
|
|
2712
|
-
const endorsements = data.endorsements;
|
|
2713
|
-
return Array.isArray(endorsements) ? endorsements.length : 0;
|
|
2714
|
-
} catch {
|
|
2715
|
-
return 0;
|
|
2716
|
-
}
|
|
2717
|
-
}
|
|
2718
|
-
|
|
2719
|
-
// src/query/hooks/use-endorsement.ts
|
|
2720
|
-
function useEndorsementCount(did, options) {
|
|
2721
|
-
const config = useSifaConfig();
|
|
2722
|
-
return useQuery({
|
|
2723
|
-
queryKey: sifaQueryKeys.endorsement.count(did ?? ""),
|
|
2724
|
-
queryFn: () => fetchEndorsementCount(config, did ?? ""),
|
|
2725
|
-
enabled: Boolean(did) && (options?.enabled ?? true),
|
|
2726
|
-
...options
|
|
2727
|
-
});
|
|
2728
|
-
}
|
|
2729
|
-
|
|
2730
|
-
// src/query/fetchers/stream.ts
|
|
2731
|
-
async function fetchNetworkStreamCount(config, did, options = {}) {
|
|
2732
|
-
const headers = { ...options.headers ?? {} };
|
|
2733
|
-
if (options.cookieHeader) headers.cookie = options.cookieHeader;
|
|
2734
|
-
try {
|
|
2735
|
-
const data = await apiFetch(
|
|
2736
|
-
config,
|
|
2737
|
-
`/api/stream/network?did=${encodeIdentifier(did)}`,
|
|
2738
|
-
{
|
|
2739
|
-
cache: "no-store",
|
|
2740
|
-
timeoutMs: 5e3,
|
|
2741
|
-
...options.cookieHeader ? {} : { credentials: "include" },
|
|
2742
|
-
...options,
|
|
2743
|
-
headers
|
|
2744
|
-
}
|
|
2745
|
-
);
|
|
2746
|
-
if (typeof data !== "object" || data === null || !("items" in data)) {
|
|
2747
|
-
return 0;
|
|
2748
|
-
}
|
|
2749
|
-
const items = data.items;
|
|
2750
|
-
return Array.isArray(items) ? items.length : 0;
|
|
2751
|
-
} catch {
|
|
2752
|
-
return 0;
|
|
2753
|
-
}
|
|
2754
|
-
}
|
|
2755
|
-
|
|
2756
|
-
// src/query/hooks/use-stream.ts
|
|
2757
|
-
function useNetworkStreamCount(did, options) {
|
|
2758
|
-
const config = useSifaConfig();
|
|
2759
|
-
return useQuery({
|
|
2760
|
-
queryKey: sifaQueryKeys.stream.networkCount(did ?? ""),
|
|
2761
|
-
queryFn: () => fetchNetworkStreamCount(config, did ?? ""),
|
|
2762
|
-
enabled: Boolean(did) && (options?.enabled ?? true),
|
|
2763
|
-
...options
|
|
2764
|
-
});
|
|
2765
|
-
}
|
|
2766
|
-
|
|
2767
|
-
// src/query/fetchers/reactions.ts
|
|
2768
|
-
async function fetchReactionStatus(config, uris, options = {}) {
|
|
2769
|
-
if (uris.length === 0) return {};
|
|
2770
|
-
const headers = { ...options.headers ?? {} };
|
|
2771
|
-
if (options.cookieHeader) headers.cookie = options.cookieHeader;
|
|
2772
|
-
try {
|
|
2773
|
-
return await apiFetch(
|
|
2774
|
-
config,
|
|
2775
|
-
`/api/reactions/status?uris=${encodeURIComponent(uris.join(","))}`,
|
|
2776
|
-
{
|
|
2777
|
-
credentials: "include",
|
|
2778
|
-
...options,
|
|
2779
|
-
headers
|
|
2780
|
-
}
|
|
2781
|
-
);
|
|
2782
|
-
} catch {
|
|
2783
|
-
return null;
|
|
2784
|
-
}
|
|
2785
|
-
}
|
|
2786
|
-
async function checkAppAccount(config, appId, options = {}) {
|
|
2787
|
-
const headers = { ...options.headers ?? {} };
|
|
2788
|
-
if (options.cookieHeader) headers.cookie = options.cookieHeader;
|
|
2789
|
-
try {
|
|
2790
|
-
return await apiFetch(
|
|
2791
|
-
config,
|
|
2792
|
-
`/api/reactions/account-check/${encodeURIComponent(appId)}`,
|
|
2793
|
-
{
|
|
2794
|
-
credentials: "include",
|
|
2795
|
-
...options,
|
|
2796
|
-
headers
|
|
2797
|
-
}
|
|
2798
|
-
);
|
|
2799
|
-
} catch {
|
|
2800
|
-
return null;
|
|
2801
|
-
}
|
|
2802
|
-
}
|
|
2803
|
-
async function createReaction(config, targetUri, appId, targetCid, options = {}) {
|
|
2804
|
-
const fetchFn = config.fetch ?? globalThis.fetch;
|
|
2805
|
-
const url = `${config.baseUrl}/api/reactions`;
|
|
2806
|
-
try {
|
|
2807
|
-
const res = await fetchFn(url, {
|
|
2808
|
-
method: "POST",
|
|
2809
|
-
headers: { "Content-Type": "application/json", ...options.headers ?? {} },
|
|
2810
|
-
credentials: options.credentials ?? "include",
|
|
2811
|
-
body: JSON.stringify({ targetUri, appId, targetCid }),
|
|
2812
|
-
signal: options.signal ?? AbortSignal.timeout(options.timeoutMs ?? 1e4)
|
|
2813
|
-
});
|
|
2814
|
-
if (!res.ok) {
|
|
2815
|
-
if (res.status === 403) {
|
|
2816
|
-
try {
|
|
2817
|
-
const body = await res.json();
|
|
2818
|
-
if (body.error === "ScopeInsufficient") {
|
|
2819
|
-
return {
|
|
2820
|
-
ok: false,
|
|
2821
|
-
error: { type: "scope_insufficient", requiredScope: body.requiredScope }
|
|
2822
|
-
};
|
|
2823
|
-
}
|
|
2824
|
-
} catch {
|
|
2825
|
-
}
|
|
2826
|
-
}
|
|
2827
|
-
return { ok: false, error: { type: "error" } };
|
|
2828
|
-
}
|
|
2829
|
-
const data = await res.json();
|
|
2830
|
-
return { ok: true, data };
|
|
2831
|
-
} catch {
|
|
2832
|
-
return { ok: false, error: { type: "error" } };
|
|
2833
|
-
}
|
|
2834
|
-
}
|
|
2835
|
-
function deleteReaction(config, targetUri, appId, options = {}) {
|
|
2836
|
-
return apiWrite(config, "/api/reactions", "DELETE", {
|
|
2837
|
-
body: { targetUri, appId },
|
|
2838
|
-
...options
|
|
2839
|
-
});
|
|
2840
|
-
}
|
|
2841
|
-
|
|
2842
|
-
// src/query/hooks/use-reactions.ts
|
|
2843
|
-
function useReactionStatus(uris, options) {
|
|
2844
|
-
const config = useSifaConfig();
|
|
2845
|
-
return useQuery({
|
|
2846
|
-
queryKey: sifaQueryKeys.reactions.status(uris),
|
|
2847
|
-
queryFn: () => fetchReactionStatus(config, uris),
|
|
2848
|
-
...options
|
|
2849
|
-
});
|
|
2850
|
-
}
|
|
2851
|
-
function useAppAccountCheck(appId, options) {
|
|
2852
|
-
const config = useSifaConfig();
|
|
2853
|
-
return useQuery({
|
|
2854
|
-
queryKey: sifaQueryKeys.reactions.accountCheck(appId ?? ""),
|
|
2855
|
-
queryFn: () => checkAppAccount(config, appId ?? ""),
|
|
2856
|
-
enabled: Boolean(appId) && (options?.enabled ?? true),
|
|
2857
|
-
...options
|
|
2858
|
-
});
|
|
2859
|
-
}
|
|
2860
|
-
function useCreateReaction(options) {
|
|
2861
|
-
const config = useSifaConfig();
|
|
2862
|
-
const queryClient = useQueryClient();
|
|
2863
|
-
return useMutation({
|
|
2864
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
2865
|
-
// handler below and silently drop cache invalidation (#453).
|
|
2866
|
-
...options,
|
|
2867
|
-
mutationFn: ({ targetUri, appId, targetCid }) => createReaction(config, targetUri, appId, targetCid),
|
|
2868
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
2869
|
-
if (result.ok) {
|
|
2870
|
-
await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.reactions.all() });
|
|
2871
|
-
}
|
|
2872
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
2873
|
-
}
|
|
2874
|
-
});
|
|
2875
|
-
}
|
|
2876
|
-
function useDeleteReaction(options) {
|
|
2877
|
-
const config = useSifaConfig();
|
|
2878
|
-
const queryClient = useQueryClient();
|
|
2879
|
-
return useMutation({
|
|
2880
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
2881
|
-
// handler below and silently drop cache invalidation (#453).
|
|
2882
|
-
...options,
|
|
2883
|
-
mutationFn: ({ targetUri, appId }) => deleteReaction(config, targetUri, appId),
|
|
2884
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
2885
|
-
if (result.success) {
|
|
2886
|
-
await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.reactions.all() });
|
|
2887
|
-
}
|
|
2888
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
2889
|
-
}
|
|
2890
|
-
});
|
|
2891
|
-
}
|
|
2892
|
-
|
|
2893
|
-
// src/query/fetchers/roadmap.ts
|
|
2894
|
-
async function fetchRoadmapVotes(config, options = {}) {
|
|
2895
|
-
try {
|
|
2896
|
-
return await apiFetch(config, "/api/roadmap/votes", {
|
|
2897
|
-
cache: "no-store",
|
|
2898
|
-
...options
|
|
2899
|
-
});
|
|
2900
|
-
} catch {
|
|
2901
|
-
return {};
|
|
2902
|
-
}
|
|
2903
|
-
}
|
|
2904
|
-
async function fetchMyRoadmapVotes(config, options = {}) {
|
|
2905
|
-
const headers = { ...options.headers ?? {} };
|
|
2906
|
-
if (options.cookieHeader) headers.cookie = options.cookieHeader;
|
|
2907
|
-
try {
|
|
2908
|
-
const data = await apiFetch(config, "/api/roadmap/votes/me", {
|
|
2909
|
-
credentials: "include",
|
|
2910
|
-
...options,
|
|
2911
|
-
headers
|
|
2912
|
-
});
|
|
2913
|
-
return data.voted ?? [];
|
|
2914
|
-
} catch {
|
|
2915
|
-
return [];
|
|
2916
|
-
}
|
|
2917
|
-
}
|
|
2918
|
-
async function castRoadmapVote(config, key, options = {}) {
|
|
2919
|
-
const fetchFn = config.fetch ?? globalThis.fetch;
|
|
2920
|
-
const url = `${config.baseUrl}/api/roadmap/votes/${encodeURIComponent(key)}`;
|
|
2921
|
-
try {
|
|
2922
|
-
const res = await fetchFn(url, {
|
|
2923
|
-
method: "POST",
|
|
2924
|
-
// No body: the item key is in the URL. Do NOT declare a JSON content-type
|
|
2925
|
-
// for an empty body — Fastify rejects that with a 400 before the handler
|
|
2926
|
-
// runs. Only forward caller-provided headers.
|
|
2927
|
-
...options.headers ? { headers: options.headers } : {},
|
|
2928
|
-
credentials: options.credentials ?? "include",
|
|
2929
|
-
signal: options.signal ?? AbortSignal.timeout(options.timeoutMs ?? 1e4)
|
|
2930
|
-
});
|
|
2931
|
-
if (!res.ok) {
|
|
2932
|
-
if (res.status === 403) {
|
|
2933
|
-
try {
|
|
2934
|
-
const body = await res.json();
|
|
2935
|
-
if (body.error === "ScopeInsufficient") {
|
|
2936
|
-
return {
|
|
2937
|
-
ok: false,
|
|
2938
|
-
error: { type: "scope_insufficient", requiredScope: body.requiredScope }
|
|
2939
|
-
};
|
|
2940
|
-
}
|
|
2941
|
-
} catch {
|
|
2942
|
-
}
|
|
2943
|
-
}
|
|
2944
|
-
return { ok: false, error: { type: "error" } };
|
|
2945
|
-
}
|
|
2946
|
-
const data = await res.json();
|
|
2947
|
-
return { ok: true, data };
|
|
2948
|
-
} catch {
|
|
2949
|
-
return { ok: false, error: { type: "error" } };
|
|
2950
|
-
}
|
|
2951
|
-
}
|
|
2952
|
-
function retractRoadmapVote(config, key, options = {}) {
|
|
2953
|
-
return apiWrite(config, `/api/roadmap/votes/${encodeURIComponent(key)}`, "DELETE", options);
|
|
2954
|
-
}
|
|
2955
|
-
|
|
2956
|
-
// src/query/hooks/use-roadmap.ts
|
|
2957
|
-
function useRoadmapVotes(options) {
|
|
2958
|
-
const config = useSifaConfig();
|
|
2959
|
-
return useQuery({
|
|
2960
|
-
queryKey: sifaQueryKeys.roadmap.votes(),
|
|
2961
|
-
queryFn: () => fetchRoadmapVotes(config),
|
|
2962
|
-
...options
|
|
2963
|
-
});
|
|
2964
|
-
}
|
|
2965
|
-
function useMyRoadmapVotes(options) {
|
|
2966
|
-
const config = useSifaConfig();
|
|
2967
|
-
return useQuery({
|
|
2968
|
-
queryKey: sifaQueryKeys.roadmap.myVotes(),
|
|
2969
|
-
queryFn: () => fetchMyRoadmapVotes(config),
|
|
2970
|
-
...options
|
|
2971
|
-
});
|
|
2972
|
-
}
|
|
2973
|
-
async function invalidateRoadmap(queryClient) {
|
|
2974
|
-
await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.roadmap.all() });
|
|
2975
|
-
}
|
|
2976
|
-
function useCastRoadmapVote(options) {
|
|
2977
|
-
const config = useSifaConfig();
|
|
2978
|
-
const queryClient = useQueryClient();
|
|
2979
|
-
return useMutation({
|
|
2980
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
2981
|
-
// handler below and silently drop cache invalidation (#453).
|
|
2982
|
-
...options,
|
|
2983
|
-
mutationFn: (key) => castRoadmapVote(config, key),
|
|
2984
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
2985
|
-
if (result.ok) {
|
|
2986
|
-
await invalidateRoadmap(queryClient);
|
|
2987
|
-
}
|
|
2988
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
2989
|
-
}
|
|
2990
|
-
});
|
|
2991
|
-
}
|
|
2992
|
-
function useRetractRoadmapVote(options) {
|
|
2993
|
-
const config = useSifaConfig();
|
|
2994
|
-
const queryClient = useQueryClient();
|
|
2995
|
-
return useMutation({
|
|
2996
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
2997
|
-
// handler below and silently drop cache invalidation (#453).
|
|
2998
|
-
...options,
|
|
2999
|
-
mutationFn: (key) => retractRoadmapVote(config, key),
|
|
3000
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
3001
|
-
if (result.success) {
|
|
3002
|
-
await invalidateRoadmap(queryClient);
|
|
3003
|
-
}
|
|
3004
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
3005
|
-
}
|
|
3006
|
-
});
|
|
3007
|
-
}
|
|
3008
|
-
|
|
3009
|
-
// src/query/fetchers/destructive.ts
|
|
3010
|
-
function fetchWipePreview(config, options = {}) {
|
|
3011
|
-
return apiFetch(config, "/api/profile/wipe-preview", {
|
|
3012
|
-
credentials: "include",
|
|
3013
|
-
...options
|
|
3014
|
-
});
|
|
3015
|
-
}
|
|
3016
|
-
function resetProfile(config, deletePdsData, options = {}) {
|
|
3017
|
-
return apiWrite(config, "/api/profile/reset", "DELETE", {
|
|
3018
|
-
body: { deletePdsData },
|
|
3019
|
-
...options
|
|
3020
|
-
});
|
|
3021
|
-
}
|
|
3022
|
-
function deleteAccount(config, deletePdsData, options = {}) {
|
|
3023
|
-
return apiWrite(
|
|
3024
|
-
config,
|
|
3025
|
-
"/api/profile/account",
|
|
3026
|
-
"DELETE",
|
|
3027
|
-
{
|
|
3028
|
-
body: { deletePdsData },
|
|
3029
|
-
...options
|
|
3030
|
-
}
|
|
3031
|
-
);
|
|
3032
|
-
}
|
|
3033
|
-
|
|
3034
|
-
// src/query/hooks/use-destructive.ts
|
|
3035
|
-
function useWipePreview(options) {
|
|
3036
|
-
const config = useSifaConfig();
|
|
3037
|
-
return useQuery({
|
|
3038
|
-
queryKey: sifaQueryKeys.destructive.wipePreview(),
|
|
3039
|
-
queryFn: () => fetchWipePreview(config),
|
|
3040
|
-
staleTime: 0,
|
|
3041
|
-
gcTime: 0,
|
|
3042
|
-
...options
|
|
3043
|
-
});
|
|
3044
|
-
}
|
|
3045
|
-
function useResetProfile(options) {
|
|
3046
|
-
const config = useSifaConfig();
|
|
3047
|
-
const queryClient = useQueryClient();
|
|
3048
|
-
return useMutation({
|
|
3049
|
-
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
3050
|
-
// one below and silently drop cache invalidation (#453).
|
|
3051
|
-
...options,
|
|
3052
|
-
mutationFn: (deletePdsData) => resetProfile(config, deletePdsData),
|
|
3053
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
3054
|
-
if (result.success) {
|
|
3055
|
-
await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.all() });
|
|
3056
|
-
}
|
|
3057
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
3058
|
-
}
|
|
3059
|
-
});
|
|
3060
|
-
}
|
|
3061
|
-
function useDeleteAccount(options) {
|
|
3062
|
-
const config = useSifaConfig();
|
|
3063
|
-
const queryClient = useQueryClient();
|
|
3064
|
-
return useMutation({
|
|
3065
|
-
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
3066
|
-
// one below and silently drop cache invalidation (#453).
|
|
3067
|
-
...options,
|
|
3068
|
-
mutationFn: (deletePdsData) => deleteAccount(config, deletePdsData),
|
|
3069
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
3070
|
-
if (result.success) {
|
|
3071
|
-
queryClient.clear();
|
|
3072
|
-
}
|
|
3073
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
3074
|
-
}
|
|
3075
|
-
});
|
|
3076
|
-
}
|
|
3077
|
-
|
|
3078
|
-
// src/query/fetchers/repo-inventory.ts
|
|
3079
|
-
function fetchRepoInventory(config, options = {}) {
|
|
3080
|
-
return apiFetch(config, "/api/me/repo-inventory", {
|
|
3081
|
-
credentials: "include",
|
|
3082
|
-
...options
|
|
3083
|
-
});
|
|
3084
|
-
}
|
|
3085
|
-
function deleteRepoRecords(config, input, options = {}) {
|
|
3086
|
-
return apiWrite(config, "/api/me/repo-delete", "POST", {
|
|
3087
|
-
body: input,
|
|
3088
|
-
...options
|
|
3089
|
-
});
|
|
3090
|
-
}
|
|
3091
|
-
|
|
3092
|
-
// src/query/hooks/use-repo-inventory.ts
|
|
3093
|
-
function useRepoInventory(options) {
|
|
3094
|
-
const config = useSifaConfig();
|
|
3095
|
-
return useQuery({
|
|
3096
|
-
queryKey: sifaQueryKeys.repoInventory.list(),
|
|
3097
|
-
queryFn: () => fetchRepoInventory(config),
|
|
3098
|
-
staleTime: 0,
|
|
3099
|
-
gcTime: 0,
|
|
3100
|
-
...options
|
|
3101
|
-
});
|
|
3102
|
-
}
|
|
3103
|
-
function useDeleteRepoRecords(options) {
|
|
3104
|
-
const config = useSifaConfig();
|
|
3105
|
-
const queryClient = useQueryClient();
|
|
3106
|
-
return useMutation({
|
|
3107
|
-
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
3108
|
-
// one below and silently drop cache invalidation (#453).
|
|
3109
|
-
...options,
|
|
3110
|
-
mutationFn: (input) => deleteRepoRecords(config, input),
|
|
3111
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
3112
|
-
await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.all() });
|
|
3113
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
3114
|
-
}
|
|
3115
|
-
});
|
|
3116
|
-
}
|
|
3117
|
-
var httpUrlNullable = z.string().refine((s) => /^https?:\/\//i.test(s), { message: "must be an http(s) URL" }).nullable();
|
|
3118
|
-
var searchResultCommon = {
|
|
3119
|
-
kind: z.string(),
|
|
3120
|
-
name: z.string(),
|
|
3121
|
-
domain: z.string().nullable(),
|
|
3122
|
-
country: z.string().nullable(),
|
|
3123
|
-
logoUrl: httpUrlNullable,
|
|
3124
|
-
parentName: z.string().nullable()
|
|
3125
|
-
};
|
|
3126
|
-
var EntitySearchResultSchema = z.discriminatedUnion("source", [
|
|
3127
|
-
z.object({
|
|
3128
|
-
source: z.literal("entity"),
|
|
3129
|
-
entityId: z.number().int().positive(),
|
|
3130
|
-
...searchResultCommon
|
|
3131
|
-
}),
|
|
3132
|
-
z.object({
|
|
3133
|
-
source: z.literal("pdl"),
|
|
3134
|
-
pdlId: z.string().min(1),
|
|
3135
|
-
...searchResultCommon
|
|
3136
|
-
})
|
|
3137
|
-
]);
|
|
3138
|
-
var EntitySearchResponseSchema = z.object({
|
|
3139
|
-
results: z.array(EntitySearchResultSchema),
|
|
3140
|
-
hasMore: z.boolean()
|
|
3141
|
-
});
|
|
3142
|
-
z.object({
|
|
3143
|
-
entityId: z.number().int().positive().optional(),
|
|
3144
|
-
pdlId: z.string().min(1).optional()
|
|
3145
|
-
}).refine((v) => v.entityId != null !== (v.pdlId != null), {
|
|
3146
|
-
message: "exactly one of entityId or pdlId is required"
|
|
3147
|
-
});
|
|
3148
|
-
var EntitySelectResponseSchema = z.object({
|
|
3149
|
-
entityId: z.number().int().positive(),
|
|
3150
|
-
slug: z.string(),
|
|
3151
|
-
kind: z.string(),
|
|
3152
|
-
canonicalName: z.string(),
|
|
3153
|
-
domain: z.string().nullable(),
|
|
3154
|
-
/**
|
|
3155
|
-
* The entity's website, gated to sources trustworthy enough to prefill into a
|
|
3156
|
-
* record the user signs. Narrower than `domain`, which is a display value and
|
|
3157
|
-
* may come from a crawl. Null when the entity has no such source.
|
|
3158
|
-
*/
|
|
3159
|
-
website: httpUrlNullable.default(null),
|
|
3160
|
-
/** Which tier `website` came from. Crawled is never an accepted source. */
|
|
3161
|
-
websiteTier: z.enum(["org", "curated"]).nullable().default(null),
|
|
3162
|
-
entityRef: httpUrlNullable
|
|
3163
|
-
});
|
|
3164
|
-
var EntityImportSearchResponseSchema = z.object({
|
|
3165
|
-
results: z.array(EntitySearchResultSchema)
|
|
3166
|
-
});
|
|
3167
|
-
z.object({
|
|
3168
|
-
domain: z.string().min(1).max(253)
|
|
3169
|
-
});
|
|
3170
|
-
z.object({
|
|
3171
|
-
results: z.array(EntitySearchResultSchema),
|
|
3172
|
-
canMint: z.boolean()
|
|
3173
|
-
});
|
|
3174
|
-
z.object({
|
|
3175
|
-
result: EntitySearchResultSchema,
|
|
3176
|
-
pending: z.boolean()
|
|
3177
|
-
});
|
|
3178
|
-
|
|
3179
|
-
// src/query/fetchers/entities.ts
|
|
3180
|
-
var EMPTY_SEARCH2 = { results: [], hasMore: false };
|
|
3181
|
-
async function fetchEntitySearch(config, query, limit, options = {}) {
|
|
3182
|
-
if (!query.trim()) return EMPTY_SEARCH2;
|
|
3183
|
-
const params = new URLSearchParams({ q: query });
|
|
3184
|
-
if (limit !== void 0) params.set("limit", String(limit));
|
|
3185
|
-
const data = await apiFetch(config, `/api/entities/search?${params.toString()}`, {
|
|
3186
|
-
cache: "no-store",
|
|
3187
|
-
...options
|
|
3188
|
-
});
|
|
3189
|
-
return EntitySearchResponseSchema.parse(data);
|
|
3190
|
-
}
|
|
3191
|
-
async function selectEntity(config, body, options = {}) {
|
|
3192
|
-
const data = await apiFetch(config, "/api/entities/select", {
|
|
3193
|
-
method: "POST",
|
|
3194
|
-
body,
|
|
3195
|
-
credentials: "include",
|
|
3196
|
-
...options
|
|
3197
|
-
});
|
|
3198
|
-
return EntitySelectResponseSchema.parse(data);
|
|
3199
|
-
}
|
|
3200
|
-
async function importSearchEntities(config, query, options = {}) {
|
|
3201
|
-
if (!query.trim()) return [];
|
|
3202
|
-
const data = await apiFetch(config, "/api/entities/import-search", {
|
|
3203
|
-
method: "POST",
|
|
3204
|
-
body: { q: query },
|
|
3205
|
-
credentials: "include",
|
|
3206
|
-
...options
|
|
3207
|
-
});
|
|
3208
|
-
return EntityImportSearchResponseSchema.parse(data).results;
|
|
3209
|
-
}
|
|
3210
|
-
|
|
3211
|
-
// src/query/hooks/use-entity-search.ts
|
|
3212
|
-
function useDebouncedValue(value, delayMs = 250) {
|
|
3213
|
-
const [debounced, setDebounced] = useState(value);
|
|
3214
|
-
useEffect(() => {
|
|
3215
|
-
const timer = setTimeout(() => setDebounced(value), delayMs);
|
|
3216
|
-
return () => clearTimeout(timer);
|
|
3217
|
-
}, [value, delayMs]);
|
|
3218
|
-
return debounced;
|
|
3219
|
-
}
|
|
3220
|
-
function useEntitySearch(query, opts = {}, queryOptions) {
|
|
3221
|
-
const config = useSifaConfig();
|
|
3222
|
-
const { limit = 5, debounceMs = 250, enabled = true } = opts;
|
|
3223
|
-
const debounced = useDebouncedValue(query.trim(), debounceMs);
|
|
3224
|
-
return useQuery({
|
|
3225
|
-
queryKey: sifaQueryKeys.entity.search(debounced, limit),
|
|
3226
|
-
queryFn: () => fetchEntitySearch(config, debounced, limit),
|
|
3227
|
-
enabled: enabled && debounced.length > 0,
|
|
3228
|
-
...queryOptions
|
|
3229
|
-
});
|
|
3230
|
-
}
|
|
3231
|
-
function useSelectEntity(options) {
|
|
3232
|
-
const config = useSifaConfig();
|
|
3233
|
-
return useMutation({
|
|
3234
|
-
mutationFn: (body) => selectEntity(config, body),
|
|
3235
|
-
...options
|
|
3236
|
-
});
|
|
3237
|
-
}
|
|
3238
|
-
function useImportSearchEntities(options) {
|
|
3239
|
-
const config = useSifaConfig();
|
|
3240
|
-
return useMutation({
|
|
3241
|
-
mutationFn: (query) => importSearchEntities(config, query),
|
|
3242
|
-
...options
|
|
3243
|
-
});
|
|
3244
|
-
}
|
|
3245
|
-
function useOrgProfile(handleOrDid, options) {
|
|
3246
|
-
const config = useSifaConfig();
|
|
3247
|
-
return useQuery({
|
|
3248
|
-
queryKey: sifaQueryKeys.profile.byHandle(handleOrDid ?? ""),
|
|
3249
|
-
queryFn: () => fetchProfile(config, handleOrDid ?? ""),
|
|
3250
|
-
enabled: Boolean(handleOrDid) && (options?.enabled ?? true),
|
|
3251
|
-
select: (profile) => profile?.org ?? null,
|
|
3252
|
-
...options
|
|
3253
|
-
});
|
|
3254
|
-
}
|
|
3255
|
-
|
|
3256
|
-
// src/query/fetchers/org.ts
|
|
3257
|
-
function submitOrgClaim(config, body, options = {}) {
|
|
3258
|
-
return apiWrite(config, "/api/org/claim", "POST", { body, ...options });
|
|
3259
|
-
}
|
|
3260
|
-
function updateOrgProfile(config, body, options = {}) {
|
|
3261
|
-
return apiWrite(config, "/api/org/profile", "PUT", {
|
|
3262
|
-
body,
|
|
3263
|
-
...options
|
|
3264
|
-
});
|
|
3265
|
-
}
|
|
3266
|
-
function requestOrgDomainChallenge(config, body, options = {}) {
|
|
3267
|
-
return apiWrite(config, "/api/org/domains/challenge", "POST", {
|
|
3268
|
-
body,
|
|
3269
|
-
...options
|
|
3270
|
-
});
|
|
3271
|
-
}
|
|
3272
|
-
function verifyOrgDomain(config, body, options = {}) {
|
|
3273
|
-
return apiWrite(config, "/api/org/domains/verify", "POST", {
|
|
3274
|
-
body,
|
|
3275
|
-
...options
|
|
3276
|
-
});
|
|
3277
|
-
}
|
|
3278
|
-
function addOrgNotificationEmail(config, body, options = {}) {
|
|
3279
|
-
return apiWrite(
|
|
3280
|
-
config,
|
|
3281
|
-
"/api/org/notification-emails",
|
|
3282
|
-
"POST",
|
|
3283
|
-
{ body, ...options }
|
|
3284
|
-
);
|
|
3285
|
-
}
|
|
3286
|
-
function removeOrgNotificationEmail(config, body, options = {}) {
|
|
3287
|
-
return apiWrite(
|
|
3288
|
-
config,
|
|
3289
|
-
"/api/org/notification-emails",
|
|
3290
|
-
"DELETE",
|
|
3291
|
-
{ body, ...options }
|
|
3292
|
-
);
|
|
3293
|
-
}
|
|
3294
|
-
|
|
3295
|
-
// src/query/hooks/use-org-claim.ts
|
|
3296
|
-
function useOrgClaim(handleOrDid, options) {
|
|
3297
|
-
const config = useSifaConfig();
|
|
3298
|
-
const queryClient = useQueryClient();
|
|
3299
|
-
return useMutation({
|
|
3300
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
3301
|
-
// handler below and silently drop cache invalidation (#453).
|
|
3302
|
-
...options,
|
|
3303
|
-
mutationFn: (body) => submitOrgClaim(config, body),
|
|
3304
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
3305
|
-
if (result.success && handleOrDid) {
|
|
3306
|
-
await queryClient.invalidateQueries({
|
|
3307
|
-
queryKey: sifaQueryKeys.profile.byHandle(handleOrDid)
|
|
3308
|
-
});
|
|
3309
|
-
}
|
|
3310
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
3311
|
-
}
|
|
3312
|
-
});
|
|
3313
|
-
}
|
|
3314
|
-
function useUpdateOrgProfile(handleOrDid, options) {
|
|
3315
|
-
const config = useSifaConfig();
|
|
3316
|
-
const queryClient = useQueryClient();
|
|
3317
|
-
return useMutation({
|
|
3318
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
3319
|
-
// handler below and silently drop cache invalidation (#453).
|
|
3320
|
-
...options,
|
|
3321
|
-
mutationFn: (body) => updateOrgProfile(config, body),
|
|
3322
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
3323
|
-
if (result.success && handleOrDid) {
|
|
3324
|
-
await queryClient.invalidateQueries({
|
|
3325
|
-
queryKey: sifaQueryKeys.profile.byHandle(handleOrDid)
|
|
3326
|
-
});
|
|
3327
|
-
}
|
|
3328
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
3329
|
-
}
|
|
3330
|
-
});
|
|
3331
|
-
}
|
|
3332
|
-
function useOrgDomainChallenge(options) {
|
|
3333
|
-
const config = useSifaConfig();
|
|
3334
|
-
return useMutation({
|
|
3335
|
-
mutationFn: (body) => requestOrgDomainChallenge(config, body),
|
|
3336
|
-
...options
|
|
3337
|
-
});
|
|
3338
|
-
}
|
|
3339
|
-
function useOrgDomainVerify(options) {
|
|
3340
|
-
const config = useSifaConfig();
|
|
3341
|
-
return useMutation({
|
|
3342
|
-
mutationFn: (body) => verifyOrgDomain(config, body),
|
|
3343
|
-
...options
|
|
3344
|
-
});
|
|
3345
|
-
}
|
|
3346
|
-
function useAddOrgNotificationEmail(options) {
|
|
3347
|
-
const config = useSifaConfig();
|
|
3348
|
-
return useMutation({
|
|
3349
|
-
mutationFn: (body) => addOrgNotificationEmail(config, body),
|
|
3350
|
-
...options
|
|
3351
|
-
});
|
|
3352
|
-
}
|
|
3353
|
-
function useRemoveOrgNotificationEmail(options) {
|
|
3354
|
-
const config = useSifaConfig();
|
|
3355
|
-
return useMutation({
|
|
3356
|
-
mutationFn: (body) => removeOrgNotificationEmail(config, body),
|
|
3357
|
-
...options
|
|
3358
|
-
});
|
|
3359
|
-
}
|
|
3360
|
-
function maxGraphemes(max) {
|
|
3361
|
-
return (value) => {
|
|
3362
|
-
const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
3363
|
-
let count = 0;
|
|
3364
|
-
for (const _ of segmenter.segment(value)) {
|
|
3365
|
-
count++;
|
|
3366
|
-
if (count > max) return false;
|
|
3367
|
-
}
|
|
3368
|
-
return true;
|
|
3369
|
-
};
|
|
3370
|
-
}
|
|
3371
|
-
var didSchema = z.string().regex(/^did:[a-z]+:[a-zA-Z0-9._:%-]+$/, "Invalid DID");
|
|
3372
|
-
var datetimeSchema = z.string().datetime({ offset: true });
|
|
3373
|
-
var partialDateSchema = z.string().regex(/^\d{4}(-\d{2}(-\d{2}(T.+)?)?)?$/, "Expected YYYY, YYYY-MM, YYYY-MM-DD, or a datetime");
|
|
3374
|
-
var atUriSchema = z.string().regex(/^at:\/\/[^\s]+$/, "Invalid AT-URI");
|
|
3375
|
-
var cidSchema = z.string().regex(/^(Qm[1-9A-HJ-NP-Za-km-z]{44}|b[A-Za-z0-9+/=]+)$/, "Invalid CID");
|
|
3376
|
-
z.string().regex(/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/, "Invalid BCP 47 language tag");
|
|
3377
|
-
var uriSchema = z.string().url();
|
|
3378
|
-
var strongRefSchema = z.object({
|
|
3379
|
-
uri: atUriSchema,
|
|
3380
|
-
cid: cidSchema
|
|
3381
|
-
});
|
|
3382
|
-
z.object({
|
|
3383
|
-
uri: atUriSchema
|
|
3384
|
-
});
|
|
3385
|
-
var externalRecordRefSchema = z.object({
|
|
3386
|
-
uri: atUriSchema,
|
|
3387
|
-
cid: cidSchema.optional()
|
|
3388
|
-
});
|
|
3389
|
-
z.object({
|
|
3390
|
-
name: z.string().min(1).refine(maxGraphemes(256)).max(2560),
|
|
3391
|
-
did: didSchema.optional(),
|
|
3392
|
-
entityRef: uriSchema.optional()
|
|
3393
|
-
}).passthrough();
|
|
3394
|
-
var selfLabelsSchema = z.object({
|
|
3395
|
-
$type: z.literal("com.atproto.label.defs#selfLabels").optional(),
|
|
3396
|
-
values: z.array(z.object({ val: z.string() }))
|
|
3397
|
-
});
|
|
3398
|
-
var projectMemberRefSchema = z.object({
|
|
3399
|
-
did: didSchema,
|
|
3400
|
-
role: z.string().optional(),
|
|
3401
|
-
title: z.string().refine(maxGraphemes(128)).max(1280).optional()
|
|
3402
|
-
});
|
|
3403
|
-
z.object({
|
|
3404
|
-
name: z.string().min(1).refine(maxGraphemes(256)).max(2560),
|
|
3405
|
-
// The user's own role on the project (#596), e.g. Maintainer.
|
|
3406
|
-
role: z.string().refine(maxGraphemes(256)).max(2560).optional(),
|
|
3407
|
-
description: z.string().refine(maxGraphemes(5e3)).max(5e4).optional(),
|
|
3408
|
-
url: uriSchema.optional(),
|
|
3409
|
-
members: z.array(projectMemberRefSchema).max(50).optional(),
|
|
3410
|
-
/**
|
|
3411
|
-
* The canonical `id.sifa.project.self` this personal entry corresponds to.
|
|
3412
|
-
* A composition link. For the same project recorded on someone else's
|
|
3413
|
-
* profile, see `sameAs`.
|
|
3414
|
-
*/
|
|
3415
|
-
projectRef: strongRefSchema.optional(),
|
|
3416
|
-
/**
|
|
3417
|
-
* The same project as recorded on another person's profile. Each side stays
|
|
3418
|
-
* its own record; this only says the two describe one thing. Resolves by
|
|
3419
|
-
* AT-URI, since they will keep editing their copy.
|
|
3420
|
-
*/
|
|
3421
|
-
sameAs: externalRecordRefSchema.optional(),
|
|
3422
|
-
position: strongRefSchema.optional(),
|
|
3423
|
-
startedAt: partialDateSchema.optional(),
|
|
3424
|
-
endedAt: partialDateSchema.optional(),
|
|
3425
|
-
labels: selfLabelsSchema.optional(),
|
|
3426
|
-
isPrimary: z.boolean().optional(),
|
|
3427
|
-
createdAt: datetimeSchema
|
|
3428
|
-
});
|
|
3429
|
-
|
|
3430
|
-
// src/schemas/profile-involvement.ts
|
|
3431
|
-
var ArtifactLinkSchema = z.object({
|
|
3432
|
-
url: uriSchema,
|
|
3433
|
-
kind: z.string().optional(),
|
|
3434
|
-
label: z.string().refine(maxGraphemes(200)).max(2e3).optional()
|
|
3435
|
-
}).passthrough();
|
|
3436
|
-
z.object({
|
|
3437
|
-
kind: z.string(),
|
|
3438
|
-
upstream: z.string().refine(maxGraphemes(256)).max(2560).optional(),
|
|
3439
|
-
upstreamDid: didSchema.optional(),
|
|
3440
|
-
upstreamUrl: uriSchema.optional(),
|
|
3441
|
-
role: z.string().refine(maxGraphemes(256)).max(2560).optional(),
|
|
3442
|
-
description: z.string().refine(maxGraphemes(5e3)).max(5e4).optional(),
|
|
3443
|
-
startedAt: partialDateSchema.optional(),
|
|
3444
|
-
endedAt: partialDateSchema.optional(),
|
|
3445
|
-
links: z.array(ArtifactLinkSchema).max(50).optional(),
|
|
3446
|
-
// Portable org entity identifier (Wikidata/ROR/LEI URI) from the resolver
|
|
3447
|
-
// typeahead, constrained to http(s) so a script scheme is never a valid ref.
|
|
3448
|
-
entityRef: z.string().url().refine((s) => /^https?:\/\//i.test(s), { message: "entityRef must be an http(s) URL" }).max(2048).optional(),
|
|
3449
|
-
// community.lexicon.location.address — validated at the app layer.
|
|
3450
|
-
location: z.unknown().optional(),
|
|
3451
|
-
// id.sifa.defs#skillRef references (at-uri to a skill record in the same repo).
|
|
3452
|
-
skills: z.array(z.object({ uri: z.string() })).max(50).optional(),
|
|
3453
|
-
labels: selfLabelsSchema.optional(),
|
|
3454
|
-
collaborators: z.array(projectMemberRefSchema).max(50).optional(),
|
|
3455
|
-
sameAs: externalRecordRefSchema.optional(),
|
|
3456
|
-
isPrimary: z.boolean().optional(),
|
|
3457
|
-
createdAt: datetimeSchema
|
|
3458
|
-
}).passthrough();
|
|
3459
|
-
|
|
3460
|
-
// src/schemas/profile-investment.ts
|
|
3461
|
-
var entityRefField = z.string().url().refine((s) => /^https?:\/\//i.test(s), { message: "entityRef must be an http(s) URL" }).max(2048).optional();
|
|
3462
|
-
var InvestmentAmountSchema = z.object({
|
|
3463
|
-
/** Whole major currency units (euros, not cents). Cheque sizes are round numbers. */
|
|
3464
|
-
value: z.number().int().min(0),
|
|
3465
|
-
/** ISO 4217 three-letter code, uppercase. */
|
|
3466
|
-
currency: z.string().length(3)
|
|
3467
|
-
});
|
|
3468
|
-
var PROFILE_INVESTMENT_NSID = "id.sifa.profile.investment";
|
|
3469
|
-
z.object({
|
|
3470
|
-
/** For a limited-partner entry this names the fund, not a portfolio company. */
|
|
3471
|
-
company: z.string().min(1).refine(maxGraphemes(256)).max(2560),
|
|
3472
|
-
companyDid: didSchema.optional(),
|
|
3473
|
-
entityRef: entityRefField,
|
|
3474
|
-
role: z.string().optional(),
|
|
3475
|
-
stage: z.string().optional(),
|
|
3476
|
-
status: z.string().optional(),
|
|
3477
|
-
/** The vehicle the capital went through. Absent for a cheque in the person's own name. */
|
|
3478
|
-
via: z.string().refine(maxGraphemes(256)).max(2560).optional(),
|
|
3479
|
-
viaDid: didSchema.optional(),
|
|
3480
|
-
viaEntityRef: entityRefField,
|
|
3481
|
-
/**
|
|
3482
|
-
* Optional and empty by default. Cheque size is a personal financial disclosure,
|
|
3483
|
-
* and clients must not prompt for it.
|
|
3484
|
-
*/
|
|
3485
|
-
amount: InvestmentAmountSchema.optional(),
|
|
3486
|
-
startedAt: partialDateSchema.optional(),
|
|
3487
|
-
endedAt: partialDateSchema.optional(),
|
|
3488
|
-
description: z.string().refine(maxGraphemes(5e3)).max(5e4).optional(),
|
|
3489
|
-
links: z.array(ArtifactLinkSchema).max(50).optional(),
|
|
3490
|
-
labels: selfLabelsSchema.optional(),
|
|
3491
|
-
createdAt: datetimeSchema
|
|
3492
|
-
}).passthrough();
|
|
3493
|
-
|
|
3494
|
-
// src/query/fetchers/investments.ts
|
|
3495
|
-
function createInvestment(config, data, options = {}) {
|
|
3496
|
-
return createRecord(config, PROFILE_INVESTMENT_NSID, data, options);
|
|
3497
|
-
}
|
|
3498
|
-
function updateInvestment(config, rkey, data, options = {}) {
|
|
3499
|
-
return updateRecord(config, PROFILE_INVESTMENT_NSID, rkey, data, options);
|
|
3500
|
-
}
|
|
3501
|
-
function deleteInvestment(config, rkey, options = {}) {
|
|
3502
|
-
return deleteRecord(config, PROFILE_INVESTMENT_NSID, rkey, options);
|
|
3503
|
-
}
|
|
3504
|
-
|
|
3505
|
-
// src/query/hooks/use-investment-mutations.ts
|
|
3506
|
-
function useCreateInvestment(ownerDid, options) {
|
|
3507
|
-
const config = useSifaConfig();
|
|
3508
|
-
const queryClient = useQueryClient();
|
|
3509
|
-
return useMutation({
|
|
3510
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the handler
|
|
3511
|
-
// below and silently drop cache invalidation. The handler forwards to it instead.
|
|
3512
|
-
...options,
|
|
3513
|
-
mutationFn: (data) => createInvestment(config, data),
|
|
3514
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
3515
|
-
if (result.success) {
|
|
3516
|
-
await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.profile.byHandle(ownerDid) });
|
|
3517
|
-
}
|
|
3518
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
3519
|
-
}
|
|
3520
|
-
});
|
|
3521
|
-
}
|
|
3522
|
-
function useUpdateInvestment(ownerDid, options) {
|
|
3523
|
-
const config = useSifaConfig();
|
|
3524
|
-
const queryClient = useQueryClient();
|
|
3525
|
-
return useMutation({
|
|
3526
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the handler
|
|
3527
|
-
// below and silently drop cache invalidation. The handler forwards to it instead.
|
|
3528
|
-
...options,
|
|
3529
|
-
mutationFn: ({ rkey, data }) => updateInvestment(config, rkey, data),
|
|
3530
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
3531
|
-
if (result.success) {
|
|
3532
|
-
await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.profile.byHandle(ownerDid) });
|
|
3533
|
-
}
|
|
3534
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
3535
|
-
}
|
|
3536
|
-
});
|
|
3537
|
-
}
|
|
3538
|
-
function useDeleteInvestment(ownerDid, options) {
|
|
3539
|
-
const config = useSifaConfig();
|
|
3540
|
-
const queryClient = useQueryClient();
|
|
3541
|
-
return useMutation({
|
|
3542
|
-
// Spread first: a consumer-supplied onSuccess would otherwise replace the handler
|
|
3543
|
-
// below and silently drop cache invalidation. The handler forwards to it instead.
|
|
3544
|
-
...options,
|
|
3545
|
-
mutationFn: (rkey) => deleteInvestment(config, rkey),
|
|
3546
|
-
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
3547
|
-
if (result.success) {
|
|
3548
|
-
await queryClient.invalidateQueries({ queryKey: sifaQueryKeys.profile.byHandle(ownerDid) });
|
|
3549
|
-
}
|
|
3550
|
-
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
3551
|
-
}
|
|
3552
|
-
});
|
|
3553
|
-
}
|
|
3554
|
-
|
|
3555
|
-
export { SifaProvider, sifaQueryKeys, useAccounts, useActivityFeed, useActivityTeaser, useAddFeatureAllowlist, useAddOrgNotificationEmail, useAdminReviewQueues, useAppAccountCheck, useAppsRegistry, useAtFundLink, useBlueskySuggestions, useBulkHideProfileItems, useBulkHideStandardPublications, useBulkUnhideProfileItems, useBulkUnhideStandardPublications, useCanonicalSkillSearch, useCastRoadmapVote, useCreateConfirmation, useCreateEducation, useCreateEndorsement, useCreateExternalAccount, useCreateInvestment, useCreatePosition, useCreateProfileLocation, useCreateReaction, useCreateRecord, useCreateSkill, useDebouncedValue, useDeleteAccount, useDeleteAvatarOverride, useDeleteEducation, useDeleteExternalAccount, useDeleteInvestment, useDeleteNamePronunciationAudio, useDeletePosition, useDeleteProfileLocation, useDeleteReaction, useDeleteRecord, useDeleteRepoRecords, useDeleteSkill, useDismissConfirmation, useDismissUnlinkedPosition, useEndorsementCount, useEntitySearch, useExternalAccounts, useFeatureAllowlist, useFeaturedProfile, useFollow, useFollowers, useFollowing, useFollowingFeed, useFollowingList, useGetProfileView, useGivenConfirmations, useHeatmapData, useHiddenActivityItems, useHiddenApps, useHideActivityItem, useHideKeytraceClaim, useHideOrcidPublication, useHideProfileItem, useHideSifaPublication, useHideStandardPublication, useImportSearchEntities, useInboxCounts, useLinkSkillToPosition, useMutuals, useMyGithubPullRequests, useMyRoadmapVotes, useNetworkStreamCount, useOrgClaim, useOrgDomainChallenge, useOrgDomainVerify, useOrgProfile, usePendingConfirmations, useProfile, useProfileCompleteness, useReactionStatus, useRefreshOrcidPublications, useRefreshPds, useRemoveFeatureAllowlist, useRemoveOrgNotificationEmail, useRepoInventory, useResetProfile, useRetractRoadmapVote, useRevealMarqueDomain, useRevokeConfirmation, useRoadmapVotes, useSearchCompanies, useSearchFilters, useSearchProfiles, useSelectEntity, useSetExternalAccountPrimary, useSetPositionPrimary, useSetSectionPrimary, useSifaConfig, useSimilarProfiles, useSkillSuggestions, useStats, useSuggestionCount, useSuggestions, useUnfollow, useUnhideActivityItem, useUnhideKeytraceClaim, useUnhideOrcidPublication, useUnhideProfileItem, useUnhideSifaPublication, useUnhideStandardPublication, useUnlinkSkillFromPosition, useUnlinkedPositions, useUnrevealMarqueDomain, useUnsetExternalAccountPrimary, useUnsetPositionPrimary, useUnsetSectionPrimary, useUpdateEducation, useUpdateExternalAccount, useUpdateInvestment, useUpdateOrgProfile, useUpdatePosition, useUpdateProfileLocation, useUpdateProfileOverride, useUpdateProfileSelf, useUpdateRecord, useUpdateSkill, useUpdateSkillSubCategories, useUploadAvatar, useUploadNamePronunciationAudio, useVerifyExternalAccount, useWipePreview };
|
|
3556
|
-
//# sourceMappingURL=index.js.map
|
|
3557
285
|
//# sourceMappingURL=index.js.map
|