@singi-labs/sifa-sdk 0.19.43 → 0.19.45
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.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 +100 -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 +29 -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 +8 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +675 -7080
- 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 +31 -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.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.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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/query/hooks/use-education-mutations.ts"],"sourcesContent":["'use client';\n\nimport { useMutation, useQueryClient, type UseMutationOptions } from '@tanstack/react-query';\n\nimport { type CreateResult, type WriteResult } from '../client.js';\nimport { useSifaConfig } from '../config.js';\nimport { createEducation, deleteEducation, updateEducation } from '../fetchers/education.js';\nimport { sifaQueryKeys } from '../keys.js';\n\nasync function invalidateProfile(\n queryClient: ReturnType<typeof useQueryClient>,\n ownerHandleOrDid: string,\n): Promise<void> {\n await queryClient.invalidateQueries({\n queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid),\n });\n}\n\n/** React hook for creating an education record. */\nexport function useCreateEducation(\n ownerHandleOrDid: string,\n options?: Omit<UseMutationOptions<CreateResult, Error, Record<string, unknown>>, 'mutationFn'>,\n) {\n const config = useSifaConfig();\n const queryClient = useQueryClient();\n return useMutation({\n // Spread first: a consumer-supplied onSuccess would otherwise replace the\n // handler below and silently drop cache invalidation (#453).\n ...options,\n mutationFn: (data: Record<string, unknown>) => createEducation(config, data),\n onSuccess: async (result, variables, onMutateResult, context) => {\n if (result.success) {\n await invalidateProfile(queryClient, ownerHandleOrDid);\n }\n await options?.onSuccess?.(result, variables, onMutateResult, context);\n },\n });\n}\n\n/** Variables for {@link useUpdateEducation}. */\nexport interface UpdateEducationVariables {\n rkey: string;\n data: Record<string, unknown>;\n}\n\n/** React hook for updating an education record. */\nexport function useUpdateEducation(\n ownerHandleOrDid: string,\n options?: Omit<UseMutationOptions<WriteResult, Error, UpdateEducationVariables>, 'mutationFn'>,\n) {\n const config = useSifaConfig();\n const queryClient = useQueryClient();\n return useMutation({\n // Spread first: a consumer-supplied onSuccess would otherwise replace the\n // handler below and silently drop cache invalidation (#453).\n ...options,\n mutationFn: ({ rkey, data }: UpdateEducationVariables) => updateEducation(config, rkey, data),\n onSuccess: async (result, variables, onMutateResult, context) => {\n if (result.success) {\n await invalidateProfile(queryClient, ownerHandleOrDid);\n }\n await options?.onSuccess?.(result, variables, onMutateResult, context);\n },\n });\n}\n\n/** React hook for deleting an education record. Variable: the `rkey` string. */\nexport function useDeleteEducation(\n ownerHandleOrDid: string,\n options?: Omit<UseMutationOptions<WriteResult, Error, string>, 'mutationFn'>,\n) {\n const config = useSifaConfig();\n const queryClient = useQueryClient();\n return useMutation({\n // Spread first: a consumer-supplied onSuccess would otherwise replace the\n // handler below and silently drop cache invalidation (#453).\n ...options,\n mutationFn: (rkey: string) => deleteEducation(config, rkey),\n onSuccess: async (result, variables, onMutateResult, context) => {\n if (result.success) {\n await invalidateProfile(queryClient, ownerHandleOrDid);\n }\n await options?.onSuccess?.(result, variables, onMutateResult, context);\n },\n });\n}\n"],"mappings":";;;AAEA,SAAS,aAAa,sBAA+C;AAErE,OAAoD;AACpD,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB,iBAAiB,uBAAuB;AAClE,SAAS,qBAAqB;AAE9B,eAAe,kBACb,aACA,kBACe;AACf,QAAM,YAAY,kBAAkB;AAAA,IAClC,UAAU,cAAc,QAAQ,SAAS,gBAAgB;AAAA,EAC3D,CAAC;AACH;AAGO,SAAS,mBACd,kBACA,SACA;AACA,QAAM,SAAS,cAAc;AAC7B,QAAM,cAAc,eAAe;AACnC,SAAO,YAAY;AAAA;AAAA;AAAA,IAGjB,GAAG;AAAA,IACH,YAAY,CAAC,SAAkC,gBAAgB,QAAQ,IAAI;AAAA,IAC3E,WAAW,OAAO,QAAQ,WAAW,gBAAgB,YAAY;AAC/D,UAAI,OAAO,SAAS;AAClB,cAAM,kBAAkB,aAAa,gBAAgB;AAAA,MACvD;AACA,YAAM,SAAS,YAAY,QAAQ,WAAW,gBAAgB,OAAO;AAAA,IACvE;AAAA,EACF,CAAC;AACH;AASO,SAAS,mBACd,kBACA,SACA;AACA,QAAM,SAAS,cAAc;AAC7B,QAAM,cAAc,eAAe;AACnC,SAAO,YAAY;AAAA;AAAA;AAAA,IAGjB,GAAG;AAAA,IACH,YAAY,CAAC,EAAE,MAAM,KAAK,MAAgC,gBAAgB,QAAQ,MAAM,IAAI;AAAA,IAC5F,WAAW,OAAO,QAAQ,WAAW,gBAAgB,YAAY;AAC/D,UAAI,OAAO,SAAS;AAClB,cAAM,kBAAkB,aAAa,gBAAgB;AAAA,MACvD;AACA,YAAM,SAAS,YAAY,QAAQ,WAAW,gBAAgB,OAAO;AAAA,IACvE;AAAA,EACF,CAAC;AACH;AAGO,SAAS,mBACd,kBACA,SACA;AACA,QAAM,SAAS,cAAc;AAC7B,QAAM,cAAc,eAAe;AACnC,SAAO,YAAY;AAAA;AAAA;AAAA,IAGjB,GAAG;AAAA,IACH,YAAY,CAAC,SAAiB,gBAAgB,QAAQ,IAAI;AAAA,IAC1D,WAAW,OAAO,QAAQ,WAAW,gBAAgB,YAAY;AAC/D,UAAI,OAAO,SAAS;AAClB,cAAM,kBAAkB,aAAa,gBAAgB;AAAA,MACvD;AACA,YAAM,SAAS,YAAY,QAAQ,WAAW,gBAAgB,OAAO;AAAA,IACvE;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/query/hooks/use-endorsement-inbox.ts
|
|
4
|
+
import {
|
|
5
|
+
useMutation,
|
|
6
|
+
useQuery,
|
|
7
|
+
useQueryClient
|
|
8
|
+
} from "@tanstack/react-query";
|
|
9
|
+
import "../client.js";
|
|
10
|
+
import { useSifaConfig } from "../config.js";
|
|
11
|
+
import { confirmEndorsement } from "../fetchers/endorsements.js";
|
|
12
|
+
import {
|
|
13
|
+
dismissEndorsement,
|
|
14
|
+
fetchPendingEndorsements
|
|
15
|
+
} from "../fetchers/endorsement-inbox.js";
|
|
16
|
+
import { sifaQueryKeys } from "../keys.js";
|
|
17
|
+
function usePendingEndorsements(options) {
|
|
18
|
+
const config = useSifaConfig();
|
|
19
|
+
return useQuery({
|
|
20
|
+
queryKey: sifaQueryKeys.endorsement.pending(),
|
|
21
|
+
queryFn: () => fetchPendingEndorsements(config),
|
|
22
|
+
...options
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function useConfirmEndorsement(subjectHandleOrDid, options) {
|
|
26
|
+
const config = useSifaConfig();
|
|
27
|
+
const queryClient = useQueryClient();
|
|
28
|
+
return useMutation({
|
|
29
|
+
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
30
|
+
// one below and silently drop cache invalidation (#453).
|
|
31
|
+
...options,
|
|
32
|
+
mutationFn: (data) => confirmEndorsement(config, data),
|
|
33
|
+
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
34
|
+
if (result.success) {
|
|
35
|
+
await queryClient.invalidateQueries({
|
|
36
|
+
queryKey: sifaQueryKeys.endorsement.pending()
|
|
37
|
+
});
|
|
38
|
+
await queryClient.invalidateQueries({
|
|
39
|
+
queryKey: sifaQueryKeys.inbox.counts()
|
|
40
|
+
});
|
|
41
|
+
if (subjectHandleOrDid) {
|
|
42
|
+
await queryClient.invalidateQueries({
|
|
43
|
+
queryKey: sifaQueryKeys.profile.byHandle(subjectHandleOrDid)
|
|
44
|
+
});
|
|
45
|
+
await queryClient.invalidateQueries({
|
|
46
|
+
queryKey: sifaQueryKeys.endorsement.count(subjectHandleOrDid)
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function useDismissEndorsement(options) {
|
|
55
|
+
const config = useSifaConfig();
|
|
56
|
+
const queryClient = useQueryClient();
|
|
57
|
+
return useMutation({
|
|
58
|
+
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
59
|
+
// one below and silently drop cache invalidation (#453).
|
|
60
|
+
...options,
|
|
61
|
+
mutationFn: (data) => dismissEndorsement(config, data),
|
|
62
|
+
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
63
|
+
if (result.success) {
|
|
64
|
+
await queryClient.invalidateQueries({
|
|
65
|
+
queryKey: sifaQueryKeys.endorsement.pending()
|
|
66
|
+
});
|
|
67
|
+
await queryClient.invalidateQueries({
|
|
68
|
+
queryKey: sifaQueryKeys.inbox.counts()
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
useConfirmEndorsement,
|
|
77
|
+
useDismissEndorsement,
|
|
78
|
+
usePendingEndorsements
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=use-endorsement-inbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/query/hooks/use-endorsement-inbox.ts"],"sourcesContent":["'use client';\n\nimport {\n useMutation,\n useQuery,\n useQueryClient,\n type UseMutationOptions,\n type UseQueryOptions,\n} from '@tanstack/react-query';\n\nimport { type CreateResult, type WriteResult } from '../client.js';\nimport { useSifaConfig } from '../config.js';\nimport { confirmEndorsement, type ConfirmEndorsementInput } from '../fetchers/endorsements.js';\nimport {\n dismissEndorsement,\n fetchPendingEndorsements,\n type DismissEndorsementInput,\n type PendingEndorsementsPage,\n} from '../fetchers/endorsement-inbox.js';\nimport { sifaQueryKeys } from '../keys.js';\n\n/**\n * Endorsements awaiting the signed-in user's decision. Returns an empty page\n * when signed out or on error, so callers can render \"nothing pending\" without\n * special-casing either.\n */\nexport function usePendingEndorsements(\n options?: Omit<\n UseQueryOptions<\n PendingEndorsementsPage,\n Error,\n PendingEndorsementsPage,\n ReturnType<typeof sifaQueryKeys.endorsement.pending>\n >,\n 'queryKey' | 'queryFn'\n >,\n) {\n const config = useSifaConfig();\n return useQuery({\n queryKey: sifaQueryKeys.endorsement.pending(),\n queryFn: () => fetchPendingEndorsements(config),\n ...options,\n });\n}\n\n/**\n * Confirm a received endorsement. On success the endorsement leaves the inbox\n * and starts displaying, so both the inbox and the subject's own profile and\n * count caches are invalidated.\n *\n * `subjectHandleOrDid` is the confirming user (the endorsement's subject);\n * pass `null` to skip profile invalidation.\n */\nexport function useConfirmEndorsement(\n subjectHandleOrDid: string | null,\n options?: Omit<UseMutationOptions<CreateResult, Error, ConfirmEndorsementInput>, 'mutationFn'>,\n) {\n const config = useSifaConfig();\n const queryClient = useQueryClient();\n return useMutation({\n // Spread first: a consumer-supplied handler would otherwise replace the\n // one below and silently drop cache invalidation (#453).\n ...options,\n mutationFn: (data: ConfirmEndorsementInput) => confirmEndorsement(config, data),\n onSuccess: async (result, variables, onMutateResult, context) => {\n if (result.success) {\n await queryClient.invalidateQueries({\n queryKey: sifaQueryKeys.endorsement.pending(),\n });\n // Keep the header bell badge in step with the resolved task.\n await queryClient.invalidateQueries({\n queryKey: sifaQueryKeys.inbox.counts(),\n });\n if (subjectHandleOrDid) {\n await queryClient.invalidateQueries({\n queryKey: sifaQueryKeys.profile.byHandle(subjectHandleOrDid),\n });\n await queryClient.invalidateQueries({\n queryKey: sifaQueryKeys.endorsement.count(subjectHandleOrDid),\n });\n }\n }\n await options?.onSuccess?.(result, variables, onMutateResult, context);\n },\n });\n}\n\n/**\n * Dismiss a received endorsement. Only the inbox is invalidated -- a dismissal\n * changes nothing that displays anywhere, so no profile cache is affected.\n */\nexport function useDismissEndorsement(\n options?: Omit<UseMutationOptions<WriteResult, Error, DismissEndorsementInput>, 'mutationFn'>,\n) {\n const config = useSifaConfig();\n const queryClient = useQueryClient();\n return useMutation({\n // Spread first: a consumer-supplied handler would otherwise replace the\n // one below and silently drop cache invalidation (#453).\n ...options,\n mutationFn: (data: DismissEndorsementInput) => dismissEndorsement(config, data),\n onSuccess: async (result, variables, onMutateResult, context) => {\n if (result.success) {\n await queryClient.invalidateQueries({\n queryKey: sifaQueryKeys.endorsement.pending(),\n });\n // Keep the header bell badge in step with the resolved task.\n await queryClient.invalidateQueries({\n queryKey: sifaQueryKeys.inbox.counts(),\n });\n }\n await options?.onSuccess?.(result, variables, onMutateResult, context);\n },\n });\n}\n"],"mappings":";;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP,OAAoD;AACpD,SAAS,qBAAqB;AAC9B,SAAS,0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cAAM,YAAY,kBAAkB;AAAA,UAClC,UAAU,cAAc,YAAY,QAAQ;AAAA,QAC9C,CAAC;AAED,cAAM,YAAY,kBAAkB;AAAA,UAClC,UAAU,cAAc,MAAM,OAAO;AAAA,QACvC,CAAC;AAAA,MACH;AACA,YAAM,SAAS,YAAY,QAAQ,WAAW,gBAAgB,OAAO;AAAA,IACvE;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/query/hooks/use-endorsement-mutations.ts
|
|
4
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
5
|
+
import "../client.js";
|
|
6
|
+
import { useSifaConfig } from "../config.js";
|
|
7
|
+
import { createEndorsement } from "../fetchers/endorsements.js";
|
|
8
|
+
import { sifaQueryKeys } from "../keys.js";
|
|
9
|
+
function useCreateEndorsement(endorsedHandleOrDid, options) {
|
|
10
|
+
const config = useSifaConfig();
|
|
11
|
+
const queryClient = useQueryClient();
|
|
12
|
+
return useMutation({
|
|
13
|
+
// Spread first: a consumer-supplied onSuccess would otherwise replace the
|
|
14
|
+
// handler below and silently drop cache invalidation (#453).
|
|
15
|
+
...options,
|
|
16
|
+
mutationFn: (data) => createEndorsement(config, data),
|
|
17
|
+
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
18
|
+
if (result.success && endorsedHandleOrDid) {
|
|
19
|
+
await queryClient.invalidateQueries({
|
|
20
|
+
queryKey: sifaQueryKeys.profile.byHandle(endorsedHandleOrDid)
|
|
21
|
+
});
|
|
22
|
+
await queryClient.invalidateQueries({
|
|
23
|
+
queryKey: sifaQueryKeys.endorsement.count(endorsedHandleOrDid)
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
useCreateEndorsement
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=use-endorsement-mutations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/query/hooks/use-endorsement-mutations.ts"],"sourcesContent":["'use client';\n\nimport { useMutation, useQueryClient, type UseMutationOptions } from '@tanstack/react-query';\n\nimport { type CreateResult } from '../client.js';\nimport { useSifaConfig } from '../config.js';\nimport { createEndorsement, type EndorsementInput } from '../fetchers/endorsements.js';\nimport { sifaQueryKeys } from '../keys.js';\n\n/**\n * React hook for creating an endorsement of another user's skill. The\n * mutation needs the endorsed user's handle/DID (not the endorser's)\n * so the endorsed profile + their endorsement count caches get\n * invalidated; pass `null` to skip endorsed-profile invalidation\n * (e.g., if you only know the skill URI).\n */\nexport function useCreateEndorsement(\n endorsedHandleOrDid: string | null,\n options?: Omit<UseMutationOptions<CreateResult, Error, EndorsementInput>, 'mutationFn'>,\n) {\n const config = useSifaConfig();\n const queryClient = useQueryClient();\n return useMutation({\n // Spread first: a consumer-supplied onSuccess would otherwise replace the\n // handler below and silently drop cache invalidation (#453).\n ...options,\n mutationFn: (data: EndorsementInput) => createEndorsement(config, data),\n onSuccess: async (result, variables, onMutateResult, context) => {\n if (result.success && endorsedHandleOrDid) {\n await queryClient.invalidateQueries({\n queryKey: sifaQueryKeys.profile.byHandle(endorsedHandleOrDid),\n });\n await queryClient.invalidateQueries({\n queryKey: sifaQueryKeys.endorsement.count(endorsedHandleOrDid),\n });\n }\n await options?.onSuccess?.(result, variables, onMutateResult, context);\n },\n });\n}\n"],"mappings":";;;AAEA,SAAS,aAAa,sBAA+C;AAErE,OAAkC;AAClC,SAAS,qBAAqB;AAC9B,SAAS,yBAAgD;AACzD,SAAS,qBAAqB;AASvB,SAAS,qBACd,qBACA,SACA;AACA,QAAM,SAAS,cAAc;AAC7B,QAAM,cAAc,eAAe;AACnC,SAAO,YAAY;AAAA;AAAA;AAAA,IAGjB,GAAG;AAAA,IACH,YAAY,CAAC,SAA2B,kBAAkB,QAAQ,IAAI;AAAA,IACtE,WAAW,OAAO,QAAQ,WAAW,gBAAgB,YAAY;AAC/D,UAAI,OAAO,WAAW,qBAAqB;AACzC,cAAM,YAAY,kBAAkB;AAAA,UAClC,UAAU,cAAc,QAAQ,SAAS,mBAAmB;AAAA,QAC9D,CAAC;AACD,cAAM,YAAY,kBAAkB;AAAA,UAClC,UAAU,cAAc,YAAY,MAAM,mBAAmB;AAAA,QAC/D,CAAC;AAAA,MACH;AACA,YAAM,SAAS,YAAY,QAAQ,WAAW,gBAAgB,OAAO;AAAA,IACvE;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/query/hooks/use-endorsement.ts
|
|
4
|
+
import { useQuery } from "@tanstack/react-query";
|
|
5
|
+
import { useSifaConfig } from "../config.js";
|
|
6
|
+
import { fetchEndorsementCount } from "../fetchers/endorsement.js";
|
|
7
|
+
import { sifaQueryKeys } from "../keys.js";
|
|
8
|
+
function useEndorsementCount(did, options) {
|
|
9
|
+
const config = useSifaConfig();
|
|
10
|
+
return useQuery({
|
|
11
|
+
queryKey: sifaQueryKeys.endorsement.count(did ?? ""),
|
|
12
|
+
queryFn: () => fetchEndorsementCount(config, did ?? ""),
|
|
13
|
+
enabled: Boolean(did) && (options?.enabled ?? true),
|
|
14
|
+
...options
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
useEndorsementCount
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=use-endorsement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/query/hooks/use-endorsement.ts"],"sourcesContent":["'use client';\n\nimport { useQuery, type UseQueryOptions } from '@tanstack/react-query';\n\nimport { useSifaConfig } from '../config.js';\nimport { fetchEndorsementCount } from '../fetchers/endorsement.js';\nimport { sifaQueryKeys } from '../keys.js';\n\n/** Count of confirmed endorsements for a DID. Returns 0 on error. */\nexport function useEndorsementCount(\n did: string | undefined | null,\n options?: Omit<\n UseQueryOptions<number, Error, number, ReturnType<typeof sifaQueryKeys.endorsement.count>>,\n 'queryKey' | 'queryFn'\n >,\n) {\n const config = useSifaConfig();\n return useQuery({\n queryKey: sifaQueryKeys.endorsement.count(did ?? ''),\n queryFn: () => fetchEndorsementCount(config, did ?? ''),\n enabled: Boolean(did) && (options?.enabled ?? true),\n ...options,\n });\n}\n"],"mappings":";;;AAEA,SAAS,gBAAsC;AAE/C,SAAS,qBAAqB;AAC9B,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;AAGvB,SAAS,oBACd,KACA,SAIA;AACA,QAAM,SAAS,cAAc;AAC7B,SAAO,SAAS;AAAA,IACd,UAAU,cAAc,YAAY,MAAM,OAAO,EAAE;AAAA,IACnD,SAAS,MAAM,sBAAsB,QAAQ,OAAO,EAAE;AAAA,IACtD,SAAS,QAAQ,GAAG,MAAM,SAAS,WAAW;AAAA,IAC9C,GAAG;AAAA,EACL,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/query/hooks/use-entity-search.ts
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import {
|
|
6
|
+
useMutation,
|
|
7
|
+
useQuery
|
|
8
|
+
} from "@tanstack/react-query";
|
|
9
|
+
import { useSifaConfig } from "../config.js";
|
|
10
|
+
import {
|
|
11
|
+
fetchEntitySearch,
|
|
12
|
+
importSearchEntities,
|
|
13
|
+
mintEntityDomain,
|
|
14
|
+
resolveEntityDomain,
|
|
15
|
+
selectEntity
|
|
16
|
+
} from "../fetchers/entities.js";
|
|
17
|
+
import { sifaQueryKeys } from "../keys.js";
|
|
18
|
+
function useDebouncedValue(value, delayMs = 250) {
|
|
19
|
+
const [debounced, setDebounced] = useState(value);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const timer = setTimeout(() => setDebounced(value), delayMs);
|
|
22
|
+
return () => clearTimeout(timer);
|
|
23
|
+
}, [value, delayMs]);
|
|
24
|
+
return debounced;
|
|
25
|
+
}
|
|
26
|
+
function useEntitySearch(query, opts = {}, queryOptions) {
|
|
27
|
+
const config = useSifaConfig();
|
|
28
|
+
const { limit = 5, debounceMs = 250, enabled = true } = opts;
|
|
29
|
+
const debounced = useDebouncedValue(query.trim(), debounceMs);
|
|
30
|
+
return useQuery({
|
|
31
|
+
queryKey: sifaQueryKeys.entity.search(debounced, limit),
|
|
32
|
+
queryFn: () => fetchEntitySearch(config, debounced, limit),
|
|
33
|
+
enabled: enabled && debounced.length > 0,
|
|
34
|
+
...queryOptions
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function useSelectEntity(options) {
|
|
38
|
+
const config = useSifaConfig();
|
|
39
|
+
return useMutation({
|
|
40
|
+
mutationFn: (body) => selectEntity(config, body),
|
|
41
|
+
...options
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function useImportSearchEntities(options) {
|
|
45
|
+
const config = useSifaConfig();
|
|
46
|
+
return useMutation({
|
|
47
|
+
mutationFn: (query) => importSearchEntities(config, query),
|
|
48
|
+
...options
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function useResolveEntityDomain(options) {
|
|
52
|
+
const config = useSifaConfig();
|
|
53
|
+
return useMutation({
|
|
54
|
+
mutationFn: (domain) => resolveEntityDomain(config, domain),
|
|
55
|
+
...options
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function useMintEntityDomain(options) {
|
|
59
|
+
const config = useSifaConfig();
|
|
60
|
+
return useMutation({
|
|
61
|
+
mutationFn: (domain) => mintEntityDomain(config, domain),
|
|
62
|
+
...options
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
useDebouncedValue,
|
|
67
|
+
useEntitySearch,
|
|
68
|
+
useImportSearchEntities,
|
|
69
|
+
useMintEntityDomain,
|
|
70
|
+
useResolveEntityDomain,
|
|
71
|
+
useSelectEntity
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=use-entity-search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/query/hooks/use-entity-search.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\nimport {\n useMutation,\n useQuery,\n type UseMutationOptions,\n type UseQueryOptions,\n} from '@tanstack/react-query';\n\nimport { useSifaConfig } from '../config.js';\nimport {\n fetchEntitySearch,\n importSearchEntities,\n mintEntityDomain,\n resolveEntityDomain,\n selectEntity,\n} from '../fetchers/entities.js';\nimport { sifaQueryKeys } from '../keys.js';\nimport type {\n EntityMintDomainResponse,\n EntityResolveDomainResponse,\n EntitySearchResponse,\n EntitySearchResult,\n EntitySelectRequest,\n EntitySelectResponse,\n} from '../../schemas/entity.js';\n\n/** Debounce a rapidly-changing value (e.g. a typeahead input). */\nexport function useDebouncedValue<T>(value: T, delayMs = 250): T {\n const [debounced, setDebounced] = useState(value);\n useEffect(() => {\n const timer = setTimeout(() => setDebounced(value), delayMs);\n return () => clearTimeout(timer);\n }, [value, delayMs]);\n return debounced;\n}\n\nexport interface UseEntitySearchOptions {\n /** Max rows to request (default 5). */\n limit?: number;\n /** Debounce delay in ms (default 250). */\n debounceMs?: number;\n enabled?: boolean;\n}\n\n/**\n * Debounced organization typeahead. The query is debounced internally, so\n * consumers can pass the raw input value on every keystroke. Skips the network\n * call while the (trimmed, debounced) query is empty.\n */\nexport function useEntitySearch(\n query: string,\n opts: UseEntitySearchOptions = {},\n queryOptions?: Omit<\n UseQueryOptions<\n EntitySearchResponse,\n Error,\n EntitySearchResponse,\n ReturnType<typeof sifaQueryKeys.entity.search>\n >,\n 'queryKey' | 'queryFn' | 'enabled'\n >,\n) {\n const config = useSifaConfig();\n const { limit = 5, debounceMs = 250, enabled = true } = opts;\n const debounced = useDebouncedValue(query.trim(), debounceMs);\n return useQuery({\n queryKey: sifaQueryKeys.entity.search(debounced, limit),\n queryFn: () => fetchEntitySearch(config, debounced, limit),\n enabled: enabled && debounced.length > 0,\n ...queryOptions,\n });\n}\n\n/** Mutation: record a selection (promote a PDL row or bump an entity). */\nexport function useSelectEntity(\n options?: Omit<\n UseMutationOptions<EntitySelectResponse, Error, EntitySelectRequest>,\n 'mutationFn'\n >,\n) {\n const config = useSifaConfig();\n return useMutation({\n mutationFn: (body: EntitySelectRequest) => selectEntity(config, body),\n ...options,\n });\n}\n\n/** Mutation: grow-on-demand Wikidata import for a typeahead miss. */\nexport function useImportSearchEntities(\n options?: Omit<UseMutationOptions<EntitySearchResult[], Error, string>, 'mutationFn'>,\n) {\n const config = useSifaConfig();\n return useMutation({\n mutationFn: (query: string) => importSearchEntities(config, query),\n ...options,\n });\n}\n\n/**\n * Mutation: grow-on-demand by domain, Branch 1. Resolve a domain-shaped\n * typeahead miss to any notable company (Wikidata reverse P856). The response's\n * `canMint` flag drives the \"Add <domain>\" affordance.\n */\nexport function useResolveEntityDomain(\n options?: Omit<UseMutationOptions<EntityResolveDomainResponse, Error, string>, 'mutationFn'>,\n) {\n const config = useSifaConfig();\n return useMutation({\n mutationFn: (domain: string) => resolveEntityDomain(config, domain),\n ...options,\n });\n}\n\n/**\n * Mutation: grow-on-demand by domain, Branch 2 (user-initiated). Mint a\n * crawled-tier entity from the domain's homepage. Rejects when the domain is not\n * mintable or the site yields nothing usable.\n */\nexport function useMintEntityDomain(\n options?: Omit<UseMutationOptions<EntityMintDomainResponse, Error, string>, 'mutationFn'>,\n) {\n const config = useSifaConfig();\n return useMutation({\n mutationFn: (domain: string) => mintEntityDomain(config, domain),\n ...options,\n });\n}\n"],"mappings":";;;AAEA,SAAS,WAAW,gBAAgB;AACpC;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAEP,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAWvB,SAAS,kBAAqB,OAAU,UAAU,KAAQ;AAC/D,QAAM,C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 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/query/hooks/use-external-accounts.ts
|
|
4
|
+
import {
|
|
5
|
+
useMutation,
|
|
6
|
+
useQuery,
|
|
7
|
+
useQueryClient
|
|
8
|
+
} from "@tanstack/react-query";
|
|
9
|
+
import "../client.js";
|
|
10
|
+
import { useSifaConfig } from "../config.js";
|
|
11
|
+
import {
|
|
12
|
+
createExternalAccount,
|
|
13
|
+
deleteExternalAccount,
|
|
14
|
+
fetchExternalAccounts,
|
|
15
|
+
setExternalAccountPrimary,
|
|
16
|
+
unsetExternalAccountPrimary,
|
|
17
|
+
updateExternalAccount,
|
|
18
|
+
verifyExternalAccount
|
|
19
|
+
} from "../fetchers/external-accounts.js";
|
|
20
|
+
import { sifaQueryKeys } from "../keys.js";
|
|
21
|
+
async function invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid) {
|
|
22
|
+
await queryClient.invalidateQueries({
|
|
23
|
+
queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid)
|
|
24
|
+
});
|
|
25
|
+
await queryClient.invalidateQueries({
|
|
26
|
+
queryKey: sifaQueryKeys.profile.externalAccounts(ownerHandleOrDid)
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function useExternalAccounts(handleOrDid, options) {
|
|
30
|
+
const config = useSifaConfig();
|
|
31
|
+
return useQuery({
|
|
32
|
+
queryKey: sifaQueryKeys.profile.externalAccounts(handleOrDid ?? ""),
|
|
33
|
+
queryFn: () => fetchExternalAccounts(config, handleOrDid ?? ""),
|
|
34
|
+
enabled: Boolean(handleOrDid) && (options?.enabled ?? true),
|
|
35
|
+
...options
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function useCreateExternalAccount(ownerHandleOrDid, options) {
|
|
39
|
+
const config = useSifaConfig();
|
|
40
|
+
const queryClient = useQueryClient();
|
|
41
|
+
return useMutation({
|
|
42
|
+
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
43
|
+
// one below and silently drop cache invalidation (#453).
|
|
44
|
+
...options,
|
|
45
|
+
mutationFn: (data) => createExternalAccount(config, data),
|
|
46
|
+
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
47
|
+
if (result.success) {
|
|
48
|
+
await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);
|
|
49
|
+
}
|
|
50
|
+
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function useUpdateExternalAccount(ownerHandleOrDid, options) {
|
|
55
|
+
const config = useSifaConfig();
|
|
56
|
+
const queryClient = useQueryClient();
|
|
57
|
+
return useMutation({
|
|
58
|
+
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
59
|
+
// one below and silently drop cache invalidation (#453).
|
|
60
|
+
...options,
|
|
61
|
+
mutationFn: ({ rkey, data }) => updateExternalAccount(config, rkey, data),
|
|
62
|
+
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
63
|
+
if (result.success) {
|
|
64
|
+
await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);
|
|
65
|
+
}
|
|
66
|
+
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function useDeleteExternalAccount(ownerHandleOrDid, options) {
|
|
71
|
+
const config = useSifaConfig();
|
|
72
|
+
const queryClient = useQueryClient();
|
|
73
|
+
return useMutation({
|
|
74
|
+
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
75
|
+
// one below and silently drop cache invalidation (#453).
|
|
76
|
+
...options,
|
|
77
|
+
mutationFn: (rkey) => deleteExternalAccount(config, rkey),
|
|
78
|
+
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
79
|
+
if (result.success) {
|
|
80
|
+
await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);
|
|
81
|
+
}
|
|
82
|
+
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function useSetExternalAccountPrimary(ownerHandleOrDid, options) {
|
|
87
|
+
const config = useSifaConfig();
|
|
88
|
+
const queryClient = useQueryClient();
|
|
89
|
+
return useMutation({
|
|
90
|
+
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
91
|
+
// one below and silently drop cache invalidation (#453).
|
|
92
|
+
...options,
|
|
93
|
+
mutationFn: (rkey) => setExternalAccountPrimary(config, rkey),
|
|
94
|
+
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
95
|
+
if (result.success) {
|
|
96
|
+
await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);
|
|
97
|
+
}
|
|
98
|
+
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function useUnsetExternalAccountPrimary(ownerHandleOrDid, options) {
|
|
103
|
+
const config = useSifaConfig();
|
|
104
|
+
const queryClient = useQueryClient();
|
|
105
|
+
return useMutation({
|
|
106
|
+
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
107
|
+
// one below and silently drop cache invalidation (#453).
|
|
108
|
+
...options,
|
|
109
|
+
mutationFn: (rkey) => unsetExternalAccountPrimary(config, rkey),
|
|
110
|
+
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
111
|
+
if (result.success) {
|
|
112
|
+
await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);
|
|
113
|
+
}
|
|
114
|
+
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function useVerifyExternalAccount(ownerHandleOrDid, options) {
|
|
119
|
+
const config = useSifaConfig();
|
|
120
|
+
const queryClient = useQueryClient();
|
|
121
|
+
return useMutation({
|
|
122
|
+
// Spread first: a consumer-supplied handler would otherwise replace the
|
|
123
|
+
// one below and silently drop cache invalidation (#453).
|
|
124
|
+
...options,
|
|
125
|
+
mutationFn: (rkey) => verifyExternalAccount(config, rkey),
|
|
126
|
+
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
127
|
+
if (result.success) {
|
|
128
|
+
await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);
|
|
129
|
+
}
|
|
130
|
+
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
export {
|
|
135
|
+
useCreateExternalAccount,
|
|
136
|
+
useDeleteExternalAccount,
|
|
137
|
+
useExternalAccounts,
|
|
138
|
+
useSetExternalAccountPrimary,
|
|
139
|
+
useUnsetExternalAccountPrimary,
|
|
140
|
+
useUpdateExternalAccount,
|
|
141
|
+
useVerifyExternalAccount
|
|
142
|
+
};
|
|
143
|
+
//# sourceMappingURL=use-external-accounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/query/hooks/use-external-accounts.ts"],"sourcesContent":["'use client';\n\nimport {\n useMutation,\n useQuery,\n useQueryClient,\n type UseMutationOptions,\n type UseQueryOptions,\n} from '@tanstack/react-query';\n\nimport type { ExternalAccount } from '../../types/index.js';\nimport { type WriteResult } from '../client.js';\nimport { useSifaConfig } from '../config.js';\nimport {\n createExternalAccount,\n deleteExternalAccount,\n fetchExternalAccounts,\n setExternalAccountPrimary,\n unsetExternalAccountPrimary,\n updateExternalAccount,\n verifyExternalAccount,\n type CreateExternalAccountResult,\n type ExternalAccountInput,\n type VerifyExternalAccountResult,\n} from '../fetchers/external-accounts.js';\nimport { sifaQueryKeys } from '../keys.js';\n\nasync function invalidateProfileAndExternalAccounts(\n queryClient: ReturnType<typeof useQueryClient>,\n ownerHandleOrDid: string,\n): Promise<void> {\n await queryClient.invalidateQueries({\n queryKey: sifaQueryKeys.profile.byHandle(ownerHandleOrDid),\n });\n await queryClient.invalidateQueries({\n queryKey: sifaQueryKeys.profile.externalAccounts(ownerHandleOrDid),\n });\n}\n\n/** React hook for reading the external-accounts list. Returns `[]` data on error. */\nexport function useExternalAccounts(\n handleOrDid: string | undefined | null,\n options?: Omit<\n UseQueryOptions<\n ExternalAccount[],\n Error,\n ExternalAccount[],\n ReturnType<typeof sifaQueryKeys.profile.externalAccounts>\n >,\n 'queryKey' | 'queryFn'\n >,\n) {\n const config = useSifaConfig();\n return useQuery({\n queryKey: sifaQueryKeys.profile.externalAccounts(handleOrDid ?? ''),\n queryFn: () => fetchExternalAccounts(config, handleOrDid ?? ''),\n enabled: Boolean(handleOrDid) && (options?.enabled ?? true),\n ...options,\n });\n}\n\n/** React hook for creating an external account. */\nexport function useCreateExternalAccount(\n ownerHandleOrDid: string,\n options?: Omit<\n UseMutationOptions<CreateExternalAccountResult, Error, ExternalAccountInput>,\n 'mutationFn'\n >,\n) {\n const config = useSifaConfig();\n const queryClient = useQueryClient();\n return useMutation({\n // Spread first: a consumer-supplied handler would otherwise replace the\n // one below and silently drop cache invalidation (#453).\n ...options,\n mutationFn: (data: ExternalAccountInput) => createExternalAccount(config, data),\n onSuccess: async (result, variables, onMutateResult, context) => {\n if (result.success) {\n await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);\n }\n await options?.onSuccess?.(result, variables, onMutateResult, context);\n },\n });\n}\n\n/** Variables for {@link useUpdateExternalAccount}. */\nexport interface UpdateExternalAccountVariables {\n rkey: string;\n data: ExternalAccountInput;\n}\n\n/** React hook for updating an external account. */\nexport function useUpdateExternalAccount(\n ownerHandleOrDid: string,\n options?: Omit<\n UseMutationOptions<WriteResult, Error, UpdateExternalAccountVariables>,\n 'mutationFn'\n >,\n) {\n const config = useSifaConfig();\n const queryClient = useQueryClient();\n return useMutation({\n // Spread first: a consumer-supplied handler would otherwise replace the\n // one below and silently drop cache invalidation (#453).\n ...options,\n mutationFn: ({ rkey, data }: UpdateExternalAccountVariables) =>\n updateExternalAccount(config, rkey, data),\n onSuccess: async (result, variables, onMutateResult, context) => {\n if (result.success) {\n await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);\n }\n await options?.onSuccess?.(result, variables, onMutateResult, context);\n },\n });\n}\n\n/** React hook for deleting an external account. Variable: the `rkey` string. */\nexport function useDeleteExternalAccount(\n ownerHandleOrDid: string,\n options?: Omit<UseMutationOptions<WriteResult, Error, string>, 'mutationFn'>,\n) {\n const config = useSifaConfig();\n const queryClient = useQueryClient();\n return useMutation({\n // Spread first: a consumer-supplied handler would otherwise replace the\n // one below and silently drop cache invalidation (#453).\n ...options,\n mutationFn: (rkey: string) => deleteExternalAccount(config, rkey),\n onSuccess: async (result, variables, onMutateResult, context) => {\n if (result.success) {\n await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);\n }\n await options?.onSuccess?.(result, variables, onMutateResult, context);\n },\n });\n}\n\n/** React hook for marking an external account primary. */\nexport function useSetExternalAccountPrimary(\n ownerHandleOrDid: string,\n options?: Omit<UseMutationOptions<WriteResult, Error, string>, 'mutationFn'>,\n) {\n const config = useSifaConfig();\n const queryClient = useQueryClient();\n return useMutation({\n // Spread first: a consumer-supplied handler would otherwise replace the\n // one below and silently drop cache invalidation (#453).\n ...options,\n mutationFn: (rkey: string) => setExternalAccountPrimary(config, rkey),\n onSuccess: async (result, variables, onMutateResult, context) => {\n if (result.success) {\n await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);\n }\n await options?.onSuccess?.(result, variables, onMutateResult, context);\n },\n });\n}\n\n/** React hook for clearing the primary flag on an external account. */\nexport function useUnsetExternalAccountPrimary(\n ownerHandleOrDid: string,\n options?: Omit<UseMutationOptions<WriteResult, Error, string>, 'mutationFn'>,\n) {\n const config = useSifaConfig();\n const queryClient = useQueryClient();\n return useMutation({\n // Spread first: a consumer-supplied handler would otherwise replace the\n // one below and silently drop cache invalidation (#453).\n ...options,\n mutationFn: (rkey: string) => unsetExternalAccountPrimary(config, rkey),\n onSuccess: async (result, variables, onMutateResult, context) => {\n if (result.success) {\n await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);\n }\n await options?.onSuccess?.(result, variables, onMutateResult, context);\n },\n });\n}\n\n/** React hook for running server-side verification of an external account. */\nexport function useVerifyExternalAccount(\n ownerHandleOrDid: string,\n options?: Omit<UseMutationOptions<VerifyExternalAccountResult, Error, string>, 'mutationFn'>,\n) {\n const config = useSifaConfig();\n const queryClient = useQueryClient();\n return useMutation({\n // Spread first: a consumer-supplied handler would otherwise replace the\n // one below and silently drop cache invalidation (#453).\n ...options,\n mutationFn: (rkey: string) => verifyExternalAccount(config, rkey),\n onSuccess: async (result, variables, onMutateResult, context) => {\n if (result.success) {\n await invalidateProfileAndExternalAccounts(queryClient, ownerHandleOrDid);\n }\n await options?.onSuccess?.(result, variables, onMutateResult, context);\n },\n });\n}\n"],"mappings":";;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAGP,OAAiC;AACjC,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,qBAAqB;AAE9B,eAAe,qCACb,aACA,kBACe;AACf,QAAM,YAAY,kBAAkB;AAAA,IAClC,UAAU,cAAc,QAAQ,SAAS,gBAAgB;AAAA,EAC3D,CAAC;AACD,QAAM,YAAY,kBAAkB;AAAA,IAClC,UAAU,cAAc,QAAQ,iBAAiB,gBAAgB;AAAA,EACnE,CAAC;AACH;AAGO,SAAS,oBACd,aACA,SASA;AACA,QAAM,SAAS,cAAc;AAC7B,SAAO,SAAS;AAAA,IACd,UAAU,cAAc,QAAQ,iBAAiB,eAAe,EAAE;AAAA,IAClE,SAAS,MAAM,sBAAsB,QAAQ,eAAe,EAAE;AAAA,IAC9D,SAAS,QAAQ,WAAW,MAAM,SAAS,WAAW;AAAA,IACtD,GAAG;AAAA,EACL,CAAC;AACH;AAGO,SAAS,yBACd,kBACA,SAIA;AACA,QAAM,SAAS,cAAc;AAC7B,QAAM,cAAc,eAAe;AACnC,S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ack/react-query";
|
|
9
|
+
import "../client.js";
|
|
10
|
+
import { useSifaConfig } from "../config.js";
|
|
11
|
+
import {
|
|
12
|
+
addFeatureAllowlist,
|
|
13
|
+
listFeatureAllowlist,
|
|
14
|
+
removeFeatureAllowlist
|
|
15
|
+
} from "../fetchers/admin-feature-allowlists.js";
|
|
16
|
+
import { sifaQueryKeys } from "../keys.js";
|
|
17
|
+
function useFeatureAllowlist(flag, options) {
|
|
18
|
+
const config = useSifaConfig();
|
|
19
|
+
return useQuery({
|
|
20
|
+
queryKey: sifaQueryKeys.admin.featureAllowlist(flag),
|
|
21
|
+
queryFn: () => listFeatureAllowlist(config, flag),
|
|
22
|
+
...options
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function useAddFeatureAllowlist(flag, options) {
|
|
26
|
+
const config = useSifaConfig();
|
|
27
|
+
const queryClient = useQueryClient();
|
|
28
|
+
const key = sifaQueryKeys.admin.featureAllowlist(flag);
|
|
29
|
+
return useMutation({
|
|
30
|
+
mutationFn: ({ did, note }) => addFeatureAllowlist(config, flag, did, { note }),
|
|
31
|
+
onMutate: async ({ did, note }) => {
|
|
32
|
+
await queryClient.cancelQueries({ queryKey: key });
|
|
33
|
+
const previous = queryClient.getQueryData(key);
|
|
34
|
+
const optimisticEntry = {
|
|
35
|
+
did,
|
|
36
|
+
addedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
37
|
+
note: note ?? null
|
|
38
|
+
};
|
|
39
|
+
const next = previous ? { items: [optimisticEntry, ...previous.items.filter((e) => e.did !== did)] } : { items: [optimisticEntry] };
|
|
40
|
+
queryClient.setQueryData(key, next);
|
|
41
|
+
return { previous };
|
|
42
|
+
},
|
|
43
|
+
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
44
|
+
if (!result.success && onMutateResult?.previous) {
|
|
45
|
+
queryClient.setQueryData(key, onMutateResult.previous);
|
|
46
|
+
}
|
|
47
|
+
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
48
|
+
},
|
|
49
|
+
onError: async (error, variables, onMutateResult, context) => {
|
|
50
|
+
if (onMutateResult?.previous) {
|
|
51
|
+
queryClient.setQueryData(key, onMutateResult.previous);
|
|
52
|
+
}
|
|
53
|
+
await options?.onError?.(error, variables, onMutateResult, context);
|
|
54
|
+
},
|
|
55
|
+
onSettled: async (result, error, variables, onMutateResult, context) => {
|
|
56
|
+
await queryClient.invalidateQueries({ queryKey: key });
|
|
57
|
+
await options?.onSettled?.(result, error, variables, onMutateResult, context);
|
|
58
|
+
},
|
|
59
|
+
...options
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function useRemoveFeatureAllowlist(flag, options) {
|
|
63
|
+
const config = useSifaConfig();
|
|
64
|
+
const queryClient = useQueryClient();
|
|
65
|
+
const key = sifaQueryKeys.admin.featureAllowlist(flag);
|
|
66
|
+
return useMutation(
|
|
67
|
+
{
|
|
68
|
+
mutationFn: ({ did }) => removeFeatureAllowlist(config, flag, did),
|
|
69
|
+
onMutate: async ({ did }) => {
|
|
70
|
+
await queryClient.cancelQueries({ queryKey: key });
|
|
71
|
+
const previous = queryClient.getQueryData(key);
|
|
72
|
+
if (previous) {
|
|
73
|
+
queryClient.setQueryData(key, {
|
|
74
|
+
items: previous.items.filter((e) => e.did !== did)
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return { previous };
|
|
78
|
+
},
|
|
79
|
+
onSuccess: async (result, variables, onMutateResult, context) => {
|
|
80
|
+
if (!result.success && onMutateResult?.previous) {
|
|
81
|
+
queryClient.setQueryData(key, onMutateResult.previous);
|
|
82
|
+
}
|
|
83
|
+
await options?.onSuccess?.(result, variables, onMutateResult, context);
|
|
84
|
+
},
|
|
85
|
+
onError: async (error, variables, onMutateResult, context) => {
|
|
86
|
+
if (onMutateResult?.previous) {
|
|
87
|
+
queryClient.setQueryData(key, onMutateResult.previous);
|
|
88
|
+
}
|
|
89
|
+
await options?.onError?.(error, variables, onMutateResult, context);
|
|
90
|
+
},
|
|
91
|
+
onSettled: async (result, error, variables, onMutateResult, context) => {
|
|
92
|
+
await queryClient.invalidateQueries({ queryKey: key });
|
|
93
|
+
await options?.onSettled?.(result, error, variables, onMutateResult, context);
|
|
94
|
+
},
|
|
95
|
+
...options
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
export {
|
|
100
|
+
useAddFeatureAllowlist,
|
|
101
|
+
useFeatureAllowlist,
|
|
102
|
+
useRemoveFeatureAllowlist
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=use-feature-allowlist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/query/hooks/use-feature-allowlist.ts"],"sourcesContent":["'use client';\n\nimport {\n useMutation,\n useQuery,\n useQueryClient,\n type UseMutationOptions,\n type UseQueryOptions,\n} from '@tanstack/react-query';\n\nimport { type WriteResult } from '../client.js';\nimport { useSifaConfig } from '../config.js';\nimport {\n addFeatureAllowlist,\n listFeatureAllowlist,\n removeFeatureAllowlist,\n type FeatureAllowlistResponse,\n} from '../fetchers/admin-feature-allowlists.js';\nimport type { FeatureAllowlistEntry, FeatureFlag } from '../../schemas/follow-profile.js';\nimport { sifaQueryKeys } from '../keys.js';\n\n/**\n * Read hook for the admin allowlist of a given feature flag. Admin-gated on\n * the server; non-admins get an empty list (the fetcher swallows 403).\n */\nexport function useFeatureAllowlist(\n flag: FeatureFlag,\n options?: Omit<\n UseQueryOptions<\n FeatureAllowlistResponse,\n Error,\n FeatureAllowlistResponse,\n ReturnType<typeof sifaQueryKeys.admin.featureAllowlist>\n >,\n 'queryKey' | 'queryFn'\n >,\n) {\n const config = useSifaConfig();\n return useQuery({\n queryKey: sifaQueryKeys.admin.featureAllowlist(flag),\n queryFn: () => listFeatureAllowlist(config, flag),\n ...options,\n });\n}\n\n/** Snapshot of the previous cache entry; returned from `onMutate` for rollback. */\ninterface AllowlistMutationContext {\n previous: FeatureAllowlistResponse | undefined;\n}\n\n/** Variables for {@link useAddFeatureAllowlist}. */\nexport interface AddFeatureAllowlistVariables {\n did: string;\n note?: string;\n}\n\n/**\n * Mutation hook to add (or upsert) a DID on the given flag's allowlist.\n * Optimistically prepends a synthesized entry to the cache so admin UIs feel\n * instant; rolls back if the server reports failure.\n */\nexport function useAddFeatureAllowlist(\n flag: FeatureFlag,\n options?: Omit<\n UseMutationOptions<WriteResult, Error, AddFeatureAllowlistVariables, AllowlistMutationContext>,\n 'mutationFn'\n >,\n) {\n const config = useSifaConfig();\n const queryClient = useQueryClient();\n const key = sifaQueryKeys.admin.featureAllowlist(flag);\n\n return useMutation<WriteResult, Error, AddFeatureAllowlistVariables, AllowlistMutationContext>({\n mutationFn: ({ did, note }) => addFeatureAllowlist(config, flag, did, { note }),\n onMutate: async ({ did, note }) => {\n await queryClient.cancelQueries({ queryKey: key });\n const previous = queryClient.getQueryData<FeatureAllowlistResponse>(key);\n const optimisticEntry: FeatureAllowlistEntry = {\n did,\n addedAt: new Date().toISOString(),\n note: note ?? null,\n };\n const next: FeatureAllowlistResponse = previous\n ? { items: [optimisticEntry, ...previous.items.filter((e) => e.did !== did)] }\n : { items: [optimisticEntry] };\n queryClient.setQueryData<FeatureAllowlistResponse>(key, next);\n return { previous };\n },\n onSuccess: async (result, variables, onMutateResult, context) => {\n // The fetcher's never-throws contract (see {@link apiWrite}) means a\n // server-side failure surfaces here as `result.success === false`, not\n // as an `onError`. Roll back the optimistic insert in that case.\n if (!result.success && onMutateResult?.previous) {\n queryClient.setQueryData(key, onMutateResult.previous);\n }\n await options?.onSuccess?.(result, variables, onMutateResult, context);\n },\n onError: async (error, variables, onMutateResult, context) => {\n if (onMutateResult?.previous) {\n queryClient.setQueryData(key, onMutateResult.previous);\n }\n await options?.onError?.(error, variables, onMutateResult, context);\n },\n onSettled: async (result, error, variables, onMutateResult, context) => {\n await queryClient.invalidateQueries({ queryKey: key });\n await options?.onSettled?.(result, error, variables, onMutateResult, context);\n },\n ...options,\n });\n}\n\n/** Variables for {@link useRemoveFeatureAllowlist}. */\nexport interface RemoveFeatureAllowlistVariables {\n did: string;\n}\n\n/**\n * Mutation hook to remove a DID from the given flag's allowlist.\n * Optimistically removes the row from the cache; rolls back if the server\n * reports failure.\n */\nexport function useRemoveFeatureAllowlist(\n flag: FeatureFlag,\n options?: Omit<\n UseMutationOptions<\n WriteResult,\n Error,\n RemoveFeatureAllowlistVariables,\n AllowlistMutationContext\n >,\n 'mutationFn'\n >,\n) {\n const config = useSifaConfig();\n const queryClient = useQueryClient();\n const key = sifaQueryKeys.admin.featureAllowlist(flag);\n\n return useMutation<WriteResult, Error, RemoveFeatureAllowlistVariables, AllowlistMutationContext>(\n {\n mutationFn: ({ did }) => removeFeatureAllowlist(config, flag, did),\n onMutate: async ({ did }) => {\n await queryClient.cancelQueries({ queryKey: key });\n const previous = queryClient.getQueryData<FeatureAllowlistResponse>(key);\n if (previous) {\n queryClient.setQueryData<FeatureAllowlistResponse>(key, {\n items: previous.items.filter((e) => e.did !== did),\n });\n }\n return { previous };\n },\n onSuccess: async (result, variables, onMutateResult, context) => {\n if (!result.success && onMutateResult?.previous) {\n queryClient.setQueryData(key, onMutateResult.previous);\n }\n await options?.onSuccess?.(result, variables, onMutateResult, context);\n },\n onError: async (error, variables, onMutateResult, context) => {\n if (onMutateResult?.previous) {\n queryClient.setQueryData(key, onMutateResult.previous);\n }\n await options?.onError?.(error, variables, onMutateResult, context);\n },\n onSettled: async (result, error, variables, onMutateResult, context) => {\n await queryClient.invalidateQueries({ queryKey: key });\n await options?.onSettled?.(result, error, variables, onMutateResult, context);\n },\n ...options,\n },\n );\n}\n"],"mappings":";;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AAEP,OAAiC;AACjC,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,qBAAqB;AAMvB,SAAS,oBACd,MACA,SASA;AACA,QAAM,SAAS,cAAc;AAC7B,SAAO,SAAS;AAAA,IACd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,CAAC;AACrD,cAAM,SAAS,YAAY,QAAQ,OAAO,WAAW,gBAAgB,OAAO;AAAA,MAC9E;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/query/hooks/use-follow-extras.ts
|
|
4
|
+
import {
|
|
5
|
+
useInfiniteQuery
|
|
6
|
+
} from "@tanstack/react-query";
|
|
7
|
+
import { useSifaConfig } from "../config.js";
|
|
8
|
+
import {
|
|
9
|
+
getBlueskySuggestions,
|
|
10
|
+
getMutuals
|
|
11
|
+
} from "../fetchers/follow-extras.js";
|
|
12
|
+
import { sifaQueryKeys } from "../keys.js";
|
|
13
|
+
function useMutuals(handleOrDid, opts = {}, options) {
|
|
14
|
+
const config = useSifaConfig();
|
|
15
|
+
return useInfiniteQuery({
|
|
16
|
+
queryKey: sifaQueryKeys.follow.mutuals(handleOrDid),
|
|
17
|
+
queryFn: ({ pageParam }) => getMutuals(config, handleOrDid, { ...opts, cursor: pageParam }),
|
|
18
|
+
initialPageParam: void 0,
|
|
19
|
+
getNextPageParam: (lastPage) => lastPage.cursor ?? void 0,
|
|
20
|
+
enabled: handleOrDid.length > 0,
|
|
21
|
+
...options
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function useBlueskySuggestions(opts = {}, options) {
|
|
25
|
+
const config = useSifaConfig();
|
|
26
|
+
return useInfiniteQuery({
|
|
27
|
+
queryKey: sifaQueryKeys.follow.blueskySuggestions(),
|
|
28
|
+
queryFn: ({ pageParam }) => getBlueskySuggestions(config, { ...opts, cursor: pageParam }),
|
|
29
|
+
initialPageParam: void 0,
|
|
30
|
+
getNextPageParam: (lastPage) => lastPage.cursor ?? void 0,
|
|
31
|
+
...options
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
useBlueskySuggestions,
|
|
36
|
+
useMutuals
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=use-follow-extras.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/query/hooks/use-follow-extras.ts"],"sourcesContent":["'use client';\n\nimport {\n useInfiniteQuery,\n type InfiniteData,\n type UseInfiniteQueryOptions,\n} from '@tanstack/react-query';\n\nimport { useSifaConfig } from '../config.js';\nimport {\n getBlueskySuggestions,\n getMutuals,\n type FetchFollowProfilePageOptions,\n type FollowProfilePageResponse,\n} from '../fetchers/follow-extras.js';\nimport { sifaQueryKeys } from '../keys.js';\n\n/**\n * Infinite-query hook for the mutuals list of `handleOrDid`. Backed by\n * {@link getMutuals} (`GET /api/profile/{handleOrDid}/mutuals`). Disabled\n * when `handleOrDid` is empty so component-mount with a lazy handle doesn't\n * fire a wasted request.\n */\nexport function useMutuals(\n handleOrDid: string,\n opts: Omit<FetchFollowProfilePageOptions, 'cursor'> = {},\n options?: Omit<\n UseInfiniteQueryOptions<\n FollowProfilePageResponse,\n Error,\n InfiniteData<FollowProfilePageResponse>,\n ReturnType<typeof sifaQueryKeys.follow.mutuals>,\n string | undefined\n >,\n 'queryKey' | 'queryFn' | 'initialPageParam' | 'getNextPageParam'\n >,\n) {\n const config = useSifaConfig();\n return useInfiniteQuery({\n queryKey: sifaQueryKeys.follow.mutuals(handleOrDid),\n queryFn: ({ pageParam }) => getMutuals(config, handleOrDid, { ...opts, cursor: pageParam }),\n initialPageParam: undefined as string | undefined,\n getNextPageParam: (lastPage: FollowProfilePageResponse) => lastPage.cursor ?? undefined,\n enabled: handleOrDid.length > 0,\n ...options,\n });\n}\n\n/**\n * Infinite-query hook for the authenticated viewer's Bluesky-follow\n * suggestions (people the viewer follows on Bluesky but not Sifa).\n * Backed by {@link getBlueskySuggestions}.\n */\nexport function useBlueskySuggestions(\n opts: Omit<FetchFollowProfilePageOptions, 'cursor'> = {},\n options?: Omit<\n UseInfiniteQueryOptions<\n FollowProfilePageResponse,\n Error,\n InfiniteData<FollowProfilePageResponse>,\n ReturnType<typeof sifaQueryKeys.follow.blueskySuggestions>,\n string | undefined\n >,\n 'queryKey' | 'queryFn' | 'initialPageParam' | 'getNextPageParam'\n >,\n) {\n const config = useSifaConfig();\n return useInfiniteQuery({\n queryKey: sifaQueryKeys.follow.blueskySuggestions(),\n queryFn: ({ pageParam }) => getBlueskySuggestions(config, { ...opts, cursor: pageParam }),\n initialPageParam: undefined as string | undefined,\n getNextPageParam: (lastPage: FollowProfilePageResponse) => lastPage.cursor ?? undefined,\n ...options,\n });\n}\n"],"mappings":";;;AAEA;AAAA,EACE;AAAA,OAGK;AAEP,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP,SAAS,qBAAqB;AAQvB,SAAS,WACd,aACA,OAAsD,CAAC,GACvD,SAUA;AACA,QAAM,SAAS,cAAc;AAC7B,SAAO,iBAAiB;AAAA,IACtB,UAAU,cAAc,OAAO,QAAQ,WAAW;AAAA,IAClD,SAAS,CAAC,EAAE,UAAU,MAAM,WAAW,QAAQ,aAAa,EAAE,GAAG,MAAM,QAAQ,UAAU,CAAC;AAAA,IAC1F,kBAAkB;AAAA,IAClB,kBAAkB,CAAC,aAAwC,SAAS,UAAU;AAAA,IAC9E,SAAS,YAAY,SAAS;AAAA,IAC9B,GAAG;AAAA,EACL,CAAC;AACH;AAOO,SAAS,sBACd,OAAsD,CAAC,GACvD,SAUA;AACA,QAAM,SAAS,cAAc;AAC7B,SAAO,iBAAiB;AAAA,IACtB,UAAU,cAAc,OAAO,mBAAmB;AAAA,IAClD,SAAS,CAAC,EAAE,UAAU,MAAM,sBAAsB,QAAQ,EAAE,GAAG,MAAM,QAAQ,UAAU,CAAC;AAAA,IACxF,kBAAkB;AAAA,IAClB,kBAAkB,CAAC,aAAwC,SAAS,UAAU;AAAA,IAC9E,GAAG;AAAA,EACL,CAAC;AACH;","names":[]}
|