techne-sdk 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -0
- package/LICENSE +21 -0
- package/README.md +115 -2
- package/dist/auth/index.d.ts +151 -0
- package/dist/auth/index.js +167 -0
- package/dist/auth/placement.gen.d.ts +1 -0
- package/dist/auth/placement.gen.js +49 -0
- package/dist/catalog/catalog.gen.d.ts +841 -0
- package/dist/catalog/catalog.gen.js +29696 -0
- package/dist/catalog/index.d.ts +11 -0
- package/dist/catalog/index.js +11 -0
- package/dist/connect.d.ts +38 -0
- package/dist/connect.js +19 -0
- package/dist/generated/index.d.ts +2296 -0
- package/dist/generated/index.js +3320 -0
- package/dist/generated/lexicons.d.ts +17254 -0
- package/dist/generated/lexicons.js +9225 -0
- package/dist/generated/nsid.d.ts +529 -0
- package/dist/generated/nsid.js +1094 -0
- package/dist/generated/nsid.json +1082 -0
- package/dist/generated/records.d.ts +143 -0
- package/dist/generated/records.js +1 -0
- package/dist/generated/types/app/bsky/richtext/facet.d.ts +44 -0
- package/dist/generated/types/app/bsky/richtext/facet.js +39 -0
- package/dist/generated/types/com/atproto/admin/defs.d.ts +10 -0
- package/dist/generated/types/com/atproto/admin/defs.js +11 -0
- package/dist/generated/types/com/atproto/label/defs.d.ts +73 -0
- package/dist/generated/types/com/atproto/label/defs.js +39 -0
- package/dist/generated/types/com/atproto/moderation/createReport.d.ts +39 -0
- package/dist/generated/types/com/atproto/moderation/createReport.js +7 -0
- package/dist/generated/types/com/atproto/moderation/defs.d.ts +15 -0
- package/dist/generated/types/com/atproto/moderation/defs.js +18 -0
- package/dist/generated/types/com/atproto/repo/applyWrites.d.ts +88 -0
- package/dist/generated/types/com/atproto/repo/applyWrites.js +62 -0
- package/dist/generated/types/com/atproto/repo/createRecord.d.ts +43 -0
- package/dist/generated/types/com/atproto/repo/createRecord.js +20 -0
- package/dist/generated/types/com/atproto/repo/defs.d.ts +11 -0
- package/dist/generated/types/com/atproto/repo/defs.js +11 -0
- package/dist/generated/types/com/atproto/repo/deleteRecord.d.ts +36 -0
- package/dist/generated/types/com/atproto/repo/deleteRecord.js +20 -0
- package/dist/generated/types/com/atproto/repo/getRecord.d.ts +35 -0
- package/dist/generated/types/com/atproto/repo/getRecord.js +20 -0
- package/dist/generated/types/com/atproto/repo/listRecords.d.ts +41 -0
- package/dist/generated/types/com/atproto/repo/listRecords.js +14 -0
- package/dist/generated/types/com/atproto/repo/putRecord.d.ts +45 -0
- package/dist/generated/types/com/atproto/repo/putRecord.js +20 -0
- package/dist/generated/types/com/atproto/repo/strongRef.d.ts +11 -0
- package/dist/generated/types/com/atproto/repo/strongRef.js +11 -0
- package/dist/generated/types/com/atproto/server/getServiceAuth.d.ts +29 -0
- package/dist/generated/types/com/atproto/server/getServiceAuth.js +20 -0
- package/dist/generated/types/community/lexicon/calendar/event.d.ts +65 -0
- package/dist/generated/types/community/lexicon/calendar/event.js +35 -0
- package/dist/generated/types/community/lexicon/calendar/rsvp.d.ts +20 -0
- package/dist/generated/types/community/lexicon/calendar/rsvp.js +18 -0
- package/dist/generated/types/community/lexicon/location/address.d.ts +22 -0
- package/dist/generated/types/community/lexicon/location/address.js +11 -0
- package/dist/generated/types/community/lexicon/location/fsq.d.ts +16 -0
- package/dist/generated/types/community/lexicon/location/fsq.js +11 -0
- package/dist/generated/types/community/lexicon/location/geo.d.ts +15 -0
- package/dist/generated/types/community/lexicon/location/geo.js +11 -0
- package/dist/generated/types/community/lexicon/location/hthree.d.ts +14 -0
- package/dist/generated/types/community/lexicon/location/hthree.js +11 -0
- package/dist/generated/types/pub/techne/draft/accessRule.d.ts +36 -0
- package/dist/generated/types/pub/techne/draft/accessRule.js +33 -0
- package/dist/generated/types/pub/techne/draft/accountLink.d.ts +16 -0
- package/dist/generated/types/pub/techne/draft/accountLink.js +12 -0
- package/dist/generated/types/pub/techne/draft/actor/profile.d.ts +20 -0
- package/dist/generated/types/pub/techne/draft/actor/profile.js +12 -0
- package/dist/generated/types/pub/techne/draft/appAccess.d.ts +25 -0
- package/dist/generated/types/pub/techne/draft/appAccess.js +19 -0
- package/dist/generated/types/pub/techne/draft/appAccessRequest.d.ts +16 -0
- package/dist/generated/types/pub/techne/draft/appAccessRequest.js +12 -0
- package/dist/generated/types/pub/techne/draft/appConfig.d.ts +24 -0
- package/dist/generated/types/pub/techne/draft/appConfig.js +19 -0
- package/dist/generated/types/pub/techne/draft/approval.d.ts +18 -0
- package/dist/generated/types/pub/techne/draft/approval.js +12 -0
- package/dist/generated/types/pub/techne/draft/assessment.d.ts +36 -0
- package/dist/generated/types/pub/techne/draft/assessment.js +26 -0
- package/dist/generated/types/pub/techne/draft/attentionPrefs.d.ts +14 -0
- package/dist/generated/types/pub/techne/draft/attentionPrefs.js +12 -0
- package/dist/generated/types/pub/techne/draft/beacon.d.ts +17 -0
- package/dist/generated/types/pub/techne/draft/beacon.js +12 -0
- package/dist/generated/types/pub/techne/draft/beaconLists.d.ts +13 -0
- package/dist/generated/types/pub/techne/draft/beaconLists.js +12 -0
- package/dist/generated/types/pub/techne/draft/beaconSpot.d.ts +17 -0
- package/dist/generated/types/pub/techne/draft/beaconSpot.js +12 -0
- package/dist/generated/types/pub/techne/draft/block.d.ts +14 -0
- package/dist/generated/types/pub/techne/draft/block.js +12 -0
- package/dist/generated/types/pub/techne/draft/channelVerification.d.ts +15 -0
- package/dist/generated/types/pub/techne/draft/channelVerification.js +12 -0
- package/dist/generated/types/pub/techne/draft/circleBeacon.d.ts +14 -0
- package/dist/generated/types/pub/techne/draft/circleBeacon.js +12 -0
- package/dist/generated/types/pub/techne/draft/collective.d.ts +29 -0
- package/dist/generated/types/pub/techne/draft/collective.js +12 -0
- package/dist/generated/types/pub/techne/draft/commons/createServiceAccount.d.ts +47 -0
- package/dist/generated/types/pub/techne/draft/commons/createServiceAccount.js +55 -0
- package/dist/generated/types/pub/techne/draft/commons/getVersions.d.ts +78 -0
- package/dist/generated/types/pub/techne/draft/commons/getVersions.js +41 -0
- package/dist/generated/types/pub/techne/draft/commons/moveAccountHandle.d.ts +45 -0
- package/dist/generated/types/pub/techne/draft/commons/moveAccountHandle.js +48 -0
- package/dist/generated/types/pub/techne/draft/commons/runChain.d.ts +53 -0
- package/dist/generated/types/pub/techne/draft/commons/runChain.js +34 -0
- package/dist/generated/types/pub/techne/draft/connection.d.ts +16 -0
- package/dist/generated/types/pub/techne/draft/connection.js +12 -0
- package/dist/generated/types/pub/techne/draft/contact.d.ts +20 -0
- package/dist/generated/types/pub/techne/draft/contact.js +12 -0
- package/dist/generated/types/pub/techne/draft/contactChannel.d.ts +18 -0
- package/dist/generated/types/pub/techne/draft/contactChannel.js +12 -0
- package/dist/generated/types/pub/techne/draft/contactList.d.ts +14 -0
- package/dist/generated/types/pub/techne/draft/contactList.js +12 -0
- package/dist/generated/types/pub/techne/draft/containedIn.d.ts +17 -0
- package/dist/generated/types/pub/techne/draft/containedIn.js +12 -0
- package/dist/generated/types/pub/techne/draft/credential.d.ts +39 -0
- package/dist/generated/types/pub/techne/draft/credential.js +19 -0
- package/dist/generated/types/pub/techne/draft/credentialRevocation.d.ts +14 -0
- package/dist/generated/types/pub/techne/draft/credentialRevocation.js +12 -0
- package/dist/generated/types/pub/techne/draft/derivation.d.ts +50 -0
- package/dist/generated/types/pub/techne/draft/derivation.js +26 -0
- package/dist/generated/types/pub/techne/draft/description.d.ts +17 -0
- package/dist/generated/types/pub/techne/draft/description.js +12 -0
- package/dist/generated/types/pub/techne/draft/distinctFrom.d.ts +15 -0
- package/dist/generated/types/pub/techne/draft/distinctFrom.js +12 -0
- package/dist/generated/types/pub/techne/draft/evaluation.d.ts +18 -0
- package/dist/generated/types/pub/techne/draft/evaluation.js +12 -0
- package/dist/generated/types/pub/techne/draft/event/config.d.ts +22 -0
- package/dist/generated/types/pub/techne/draft/event/config.js +12 -0
- package/dist/generated/types/pub/techne/draft/event/detail.d.ts +25 -0
- package/dist/generated/types/pub/techne/draft/event/detail.js +12 -0
- package/dist/generated/types/pub/techne/draft/event/listing.d.ts +14 -0
- package/dist/generated/types/pub/techne/draft/event/listing.js +12 -0
- package/dist/generated/types/pub/techne/draft/feed/recipe.d.ts +50 -0
- package/dist/generated/types/pub/techne/draft/feed/recipe.js +26 -0
- package/dist/generated/types/pub/techne/draft/geo.d.ts +19 -0
- package/dist/generated/types/pub/techne/draft/geo.js +12 -0
- package/dist/generated/types/pub/techne/draft/heldAt.d.ts +17 -0
- package/dist/generated/types/pub/techne/draft/heldAt.js +12 -0
- package/dist/generated/types/pub/techne/draft/identity/accountsForPhones.d.ts +43 -0
- package/dist/generated/types/pub/techne/draft/identity/accountsForPhones.js +41 -0
- package/dist/generated/types/pub/techne/draft/identity/attest.d.ts +48 -0
- package/dist/generated/types/pub/techne/draft/identity/attest.js +48 -0
- package/dist/generated/types/pub/techne/draft/identity/beginAddMethod.d.ts +35 -0
- package/dist/generated/types/pub/techne/draft/identity/beginAddMethod.js +34 -0
- package/dist/generated/types/pub/techne/draft/identity/checkLinkToken.d.ts +41 -0
- package/dist/generated/types/pub/techne/draft/identity/checkLinkToken.js +41 -0
- package/dist/generated/types/pub/techne/draft/identity/createCollective.d.ts +28 -0
- package/dist/generated/types/pub/techne/draft/identity/createCollective.js +20 -0
- package/dist/generated/types/pub/techne/draft/identity/createLinkToken.d.ts +47 -0
- package/dist/generated/types/pub/techne/draft/identity/createLinkToken.js +48 -0
- package/dist/generated/types/pub/techne/draft/identity/defs.d.ts +75 -0
- package/dist/generated/types/pub/techne/draft/identity/defs.js +53 -0
- package/dist/generated/types/pub/techne/draft/identity/finishAddMethod.d.ts +46 -0
- package/dist/generated/types/pub/techne/draft/identity/finishAddMethod.js +34 -0
- package/dist/generated/types/pub/techne/draft/identity/fold.d.ts +37 -0
- package/dist/generated/types/pub/techne/draft/identity/fold.js +34 -0
- package/dist/generated/types/pub/techne/draft/identity/holdForPhone.d.ts +54 -0
- package/dist/generated/types/pub/techne/draft/identity/holdForPhone.js +41 -0
- package/dist/generated/types/pub/techne/draft/identity/link.d.ts +35 -0
- package/dist/generated/types/pub/techne/draft/identity/link.js +34 -0
- package/dist/generated/types/pub/techne/draft/identity/linkRedeemed.d.ts +46 -0
- package/dist/generated/types/pub/techne/draft/identity/linkRedeemed.js +48 -0
- package/dist/generated/types/pub/techne/draft/identity/linkRedemption.d.ts +18 -0
- package/dist/generated/types/pub/techne/draft/identity/linkRedemption.js +12 -0
- package/dist/generated/types/pub/techne/draft/identity/listLinkRedemptions.d.ts +36 -0
- package/dist/generated/types/pub/techne/draft/identity/listLinkRedemptions.js +41 -0
- package/dist/generated/types/pub/techne/draft/identity/listLinkTokens.d.ts +39 -0
- package/dist/generated/types/pub/techne/draft/identity/listLinkTokens.js +41 -0
- package/dist/generated/types/pub/techne/draft/identity/listMethods.d.ts +24 -0
- package/dist/generated/types/pub/techne/draft/identity/listMethods.js +20 -0
- package/dist/generated/types/pub/techne/draft/identity/listPhoneHolds.d.ts +49 -0
- package/dist/generated/types/pub/techne/draft/identity/listPhoneHolds.js +34 -0
- package/dist/generated/types/pub/techne/draft/identity/redeemLinkToken.d.ts +47 -0
- package/dist/generated/types/pub/techne/draft/identity/redeemLinkToken.js +55 -0
- package/dist/generated/types/pub/techne/draft/identity/releasePhoneHold.d.ts +32 -0
- package/dist/generated/types/pub/techne/draft/identity/releasePhoneHold.js +34 -0
- package/dist/generated/types/pub/techne/draft/identity/resetLinkToken.d.ts +45 -0
- package/dist/generated/types/pub/techne/draft/identity/resetLinkToken.js +48 -0
- package/dist/generated/types/pub/techne/draft/identity/resolve.d.ts +39 -0
- package/dist/generated/types/pub/techne/draft/identity/resolve.js +34 -0
- package/dist/generated/types/pub/techne/draft/identity/revokeLinkToken.d.ts +36 -0
- package/dist/generated/types/pub/techne/draft/identity/revokeLinkToken.js +41 -0
- package/dist/generated/types/pub/techne/draft/identity/unlinkAccount.d.ts +29 -0
- package/dist/generated/types/pub/techne/draft/identity/unlinkAccount.js +27 -0
- package/dist/generated/types/pub/techne/draft/identity/unlinkMethod.d.ts +32 -0
- package/dist/generated/types/pub/techne/draft/identity/unlinkMethod.js +34 -0
- package/dist/generated/types/pub/techne/draft/interest.d.ts +14 -0
- package/dist/generated/types/pub/techne/draft/interest.js +12 -0
- package/dist/generated/types/pub/techne/draft/introProposal.d.ts +28 -0
- package/dist/generated/types/pub/techne/draft/introProposal.js +19 -0
- package/dist/generated/types/pub/techne/draft/invite.d.ts +16 -0
- package/dist/generated/types/pub/techne/draft/invite.js +12 -0
- package/dist/generated/types/pub/techne/draft/market/ask.d.ts +18 -0
- package/dist/generated/types/pub/techne/draft/market/ask.js +12 -0
- package/dist/generated/types/pub/techne/draft/market/offer.d.ts +14 -0
- package/dist/generated/types/pub/techne/draft/market/offer.js +12 -0
- package/dist/generated/types/pub/techne/draft/membership.d.ts +22 -0
- package/dist/generated/types/pub/techne/draft/membership.js +12 -0
- package/dist/generated/types/pub/techne/draft/notificationState.d.ts +18 -0
- package/dist/generated/types/pub/techne/draft/notificationState.js +12 -0
- package/dist/generated/types/pub/techne/draft/operator.d.ts +20 -0
- package/dist/generated/types/pub/techne/draft/operator.js +12 -0
- package/dist/generated/types/pub/techne/draft/org.d.ts +42 -0
- package/dist/generated/types/pub/techne/draft/org.js +19 -0
- package/dist/generated/types/pub/techne/draft/passage.d.ts +18 -0
- package/dist/generated/types/pub/techne/draft/passage.js +12 -0
- package/dist/generated/types/pub/techne/draft/pendingBeaconSpot.d.ts +19 -0
- package/dist/generated/types/pub/techne/draft/pendingBeaconSpot.js +12 -0
- package/dist/generated/types/pub/techne/draft/permissioned/deleteRecord.d.ts +47 -0
- package/dist/generated/types/pub/techne/draft/permissioned/deleteRecord.js +55 -0
- package/dist/generated/types/pub/techne/draft/permissioned/getGrants.d.ts +32 -0
- package/dist/generated/types/pub/techne/draft/permissioned/getGrants.js +34 -0
- package/dist/generated/types/pub/techne/draft/permissioned/getRecord.d.ts +36 -0
- package/dist/generated/types/pub/techne/draft/permissioned/getRecord.js +34 -0
- package/dist/generated/types/pub/techne/draft/permissioned/listChanges.d.ts +71 -0
- package/dist/generated/types/pub/techne/draft/permissioned/listChanges.js +41 -0
- package/dist/generated/types/pub/techne/draft/permissioned/listRecords.d.ts +53 -0
- package/dist/generated/types/pub/techne/draft/permissioned/listRecords.js +34 -0
- package/dist/generated/types/pub/techne/draft/permissioned/putRecord.d.ts +70 -0
- package/dist/generated/types/pub/techne/draft/permissioned/putRecord.js +76 -0
- package/dist/generated/types/pub/techne/draft/permissioned/putRecords.d.ts +84 -0
- package/dist/generated/types/pub/techne/draft/permissioned/putRecords.js +69 -0
- package/dist/generated/types/pub/techne/draft/place.d.ts +36 -0
- package/dist/generated/types/pub/techne/draft/place.js +19 -0
- package/dist/generated/types/pub/techne/draft/post.d.ts +30 -0
- package/dist/generated/types/pub/techne/draft/post.js +19 -0
- package/dist/generated/types/pub/techne/draft/presence.d.ts +16 -0
- package/dist/generated/types/pub/techne/draft/presence.js +12 -0
- package/dist/generated/types/pub/techne/draft/profile.d.ts +53 -0
- package/dist/generated/types/pub/techne/draft/profile.js +33 -0
- package/dist/generated/types/pub/techne/draft/provenance.d.ts +52 -0
- package/dist/generated/types/pub/techne/draft/provenance.js +33 -0
- package/dist/generated/types/pub/techne/draft/publisher.d.ts +43 -0
- package/dist/generated/types/pub/techne/draft/publisher.js +19 -0
- package/dist/generated/types/pub/techne/draft/query/countRecords.d.ts +47 -0
- package/dist/generated/types/pub/techne/draft/query/countRecords.js +34 -0
- package/dist/generated/types/pub/techne/draft/query/getRecords.d.ts +86 -0
- package/dist/generated/types/pub/techne/draft/query/getRecords.js +48 -0
- package/dist/generated/types/pub/techne/draft/query/listRecords.d.ts +83 -0
- package/dist/generated/types/pub/techne/draft/query/listRecords.js +34 -0
- package/dist/generated/types/pub/techne/draft/query/listRejections.d.ts +50 -0
- package/dist/generated/types/pub/techne/draft/query/listRejections.js +27 -0
- package/dist/generated/types/pub/techne/draft/questionSet.d.ts +31 -0
- package/dist/generated/types/pub/techne/draft/questionSet.js +19 -0
- package/dist/generated/types/pub/techne/draft/receipt.d.ts +16 -0
- package/dist/generated/types/pub/techne/draft/receipt.js +12 -0
- package/dist/generated/types/pub/techne/draft/reflection.d.ts +20 -0
- package/dist/generated/types/pub/techne/draft/reflection.js +12 -0
- package/dist/generated/types/pub/techne/draft/retirement.d.ts +16 -0
- package/dist/generated/types/pub/techne/draft/retirement.js +12 -0
- package/dist/generated/types/pub/techne/draft/rsvpNote.d.ts +16 -0
- package/dist/generated/types/pub/techne/draft/rsvpNote.js +12 -0
- package/dist/generated/types/pub/techne/draft/sameAs.d.ts +15 -0
- package/dist/generated/types/pub/techne/draft/sameAs.js +12 -0
- package/dist/generated/types/pub/techne/draft/scraper/cursor.d.ts +17 -0
- package/dist/generated/types/pub/techne/draft/scraper/cursor.js +12 -0
- package/dist/generated/types/pub/techne/draft/scraper/raw.d.ts +31 -0
- package/dist/generated/types/pub/techne/draft/scraper/raw.js +12 -0
- package/dist/generated/types/pub/techne/draft/share.d.ts +14 -0
- package/dist/generated/types/pub/techne/draft/share.js +12 -0
- package/dist/generated/types/pub/techne/draft/source.d.ts +23 -0
- package/dist/generated/types/pub/techne/draft/source.js +12 -0
- package/dist/generated/types/pub/techne/draft/sourceAttribution.d.ts +25 -0
- package/dist/generated/types/pub/techne/draft/sourceAttribution.js +12 -0
- package/dist/generated/types/pub/techne/draft/sourceRef.d.ts +23 -0
- package/dist/generated/types/pub/techne/draft/sourceRef.js +12 -0
- package/dist/generated/types/pub/techne/draft/subjectPrefs.d.ts +18 -0
- package/dist/generated/types/pub/techne/draft/subjectPrefs.js +12 -0
- package/dist/generated/types/pub/techne/draft/sync/indexRecord.d.ts +48 -0
- package/dist/generated/types/pub/techne/draft/sync/indexRecord.js +55 -0
- package/dist/generated/types/pub/techne/draft/verdict.d.ts +16 -0
- package/dist/generated/types/pub/techne/draft/verdict.js +12 -0
- package/dist/generated/types/pub/techne/draft/verification.d.ts +14 -0
- package/dist/generated/types/pub/techne/draft/verification.js +12 -0
- package/dist/generated/types/pub/techne/draft/weeklyCheckIn.d.ts +21 -0
- package/dist/generated/types/pub/techne/draft/weeklyCheckIn.js +12 -0
- package/dist/generated/types/social/scenius/approveAppAccess.d.ts +36 -0
- package/dist/generated/types/social/scenius/approveAppAccess.js +27 -0
- package/dist/generated/types/social/scenius/createCirclePost.d.ts +39 -0
- package/dist/generated/types/social/scenius/createCirclePost.js +41 -0
- package/dist/generated/types/social/scenius/createContactInvite.d.ts +41 -0
- package/dist/generated/types/social/scenius/createContactInvite.js +34 -0
- package/dist/generated/types/social/scenius/deleteCirclePost.d.ts +34 -0
- package/dist/generated/types/social/scenius/deleteCirclePost.js +34 -0
- package/dist/generated/types/social/scenius/deleteCircleProfile.d.ts +33 -0
- package/dist/generated/types/social/scenius/deleteCircleProfile.js +34 -0
- package/dist/generated/types/social/scenius/getAppAccess.d.ts +30 -0
- package/dist/generated/types/social/scenius/getAppAccess.js +27 -0
- package/dist/generated/types/social/scenius/getAppConfig.d.ts +26 -0
- package/dist/generated/types/social/scenius/getAppConfig.js +7 -0
- package/dist/generated/types/social/scenius/getCircleThread.d.ts +48 -0
- package/dist/generated/types/social/scenius/getCircleThread.js +41 -0
- package/dist/generated/types/social/scenius/getContactInvite.d.ts +37 -0
- package/dist/generated/types/social/scenius/getContactInvite.js +27 -0
- package/dist/generated/types/social/scenius/listAppAccess.d.ts +35 -0
- package/dist/generated/types/social/scenius/listAppAccess.js +27 -0
- package/dist/generated/types/social/scenius/listCirclePosts.d.ts +47 -0
- package/dist/generated/types/social/scenius/listCirclePosts.js +34 -0
- package/dist/generated/types/social/scenius/listCircleProfiles.d.ts +50 -0
- package/dist/generated/types/social/scenius/listCircleProfiles.js +41 -0
- package/dist/generated/types/social/scenius/previewContactInvite.d.ts +37 -0
- package/dist/generated/types/social/scenius/previewContactInvite.js +34 -0
- package/dist/generated/types/social/scenius/putCircleProfile.d.ts +39 -0
- package/dist/generated/types/social/scenius/putCircleProfile.js +41 -0
- package/dist/generated/types/social/scenius/redeemContactInvite.d.ts +43 -0
- package/dist/generated/types/social/scenius/redeemContactInvite.js +48 -0
- package/dist/generated/types/social/scenius/revokeContactInvite.d.ts +33 -0
- package/dist/generated/types/social/scenius/revokeContactInvite.js +20 -0
- package/dist/generated/util.d.ts +36 -0
- package/dist/generated/util.js +32 -0
- package/dist/links/index.d.ts +65 -0
- package/dist/links/index.js +119 -0
- package/dist/platform.d.ts +14 -0
- package/dist/platform.js +16 -0
- package/dist/put/contacts.d.ts +29 -0
- package/dist/put/contacts.js +109 -0
- package/dist/put/index.d.ts +148 -0
- package/dist/put/index.js +252 -0
- package/dist/query/hosts.d.ts +77 -0
- package/dist/query/hosts.js +227 -0
- package/dist/query/index.d.ts +201 -0
- package/dist/query/index.js +167 -0
- package/dist/versions/index.d.ts +121 -0
- package/dist/versions/index.js +90 -0
- package/dist/versions/react.d.ts +53 -0
- package/dist/versions/react.js +81 -0
- package/dist/wasm/index.d.ts +85 -0
- package/dist/wasm/index.js +51 -0
- package/dist/wasm/load.d.ts +2 -0
- package/dist/wasm/load.js +16 -0
- package/dist/wasm/load.native.d.ts +11 -0
- package/dist/wasm/load.native.js +3 -0
- package/dist/wasm/techne-wasm.gen.d.ts +2 -0
- package/dist/wasm/techne-wasm.gen.js +3 -0
- package/dist/wasm/techne-wasm2js.gen.d.ts +6 -0
- package/dist/wasm/techne-wasm2js.gen.js +90467 -0
- package/package.json +136 -4
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who posted a record ("Hosted by"), from generic reads: the commons rule `Commons::host_did_expr` /
|
|
3
|
+
* `posted_by_join` applies on the server (`crates/regenos-appview/src/commons/listing.rs`, B7, §24 VT8),
|
|
4
|
+
* answered here from the records a query hands back.
|
|
5
|
+
*
|
|
6
|
+
* - A **curated** record (`curated: true`: a curator the commons root trusts merged it) is the curator's,
|
|
7
|
+
* never the host's. Its host is its provenance's byline (the version that speaks first) when that is a
|
|
8
|
+
* person's or a collective's own record, and nobody when a mirror's copy wins. With no composition, the
|
|
9
|
+
* host is the first source that is a person's or a collective's own record. A source counts only while it
|
|
10
|
+
* is still there, is not the commons collective's (those stay anonymous), and is not a mirror's (its author
|
|
11
|
+
* also wrote a `pub.techne.draft.source` or `sourceRef` sidecar about it). Only the curated record's own
|
|
12
|
+
* provenance (same author, subject this record) counts: a provenance on any other record names nobody.
|
|
13
|
+
* - Any other **public** record is its author's, unless the author is the commons collective or a mirror of it.
|
|
14
|
+
* - A **permissioned** record is its author's.
|
|
15
|
+
*
|
|
16
|
+
* Only public records count as provenances, mirror sidecars and live sources, as on the server
|
|
17
|
+
* (`posted_by_join` / `host_did_expr` read `public_records` only): a permissioned record never names a host.
|
|
18
|
+
*
|
|
19
|
+
* `null` is anonymous. The commons collective's DID comes from the app's config: `undefined` when the
|
|
20
|
+
* deployment names none (no DID is it), `null` when it is not known (the config read failed). Unknown, any
|
|
21
|
+
* public record might be the commons collective's or name it, so every public record is anonymous then:
|
|
22
|
+
* "Hosted by" never names the commons collective for want of its DID.
|
|
23
|
+
*/
|
|
24
|
+
import { NSID } from '../generated/nsid.js';
|
|
25
|
+
import { getRecords, listAllRecordsFor } from './index.js';
|
|
26
|
+
/** The provenance records written about `$uris` (as written: a read scoped to subjects). */
|
|
27
|
+
export const PROVENANCE_OF_QUERY = {
|
|
28
|
+
where: { all: [{ type: { is: NSID.PROVENANCE } }, { subject: { in: ['$uris'] } }] },
|
|
29
|
+
};
|
|
30
|
+
/** The mirror sidecars written about `$uris` (`source`, and the frozen old-Almanac `sourceRef`). */
|
|
31
|
+
export const MIRROR_SIDECARS_QUERY = {
|
|
32
|
+
where: { all: [{ type: { in: [NSID.SOURCE, NSID.SOURCE_REF] } }, { subject: { in: ['$uris'] } }] },
|
|
33
|
+
};
|
|
34
|
+
const authority = (uri) => uri.split('/')[2] ?? '';
|
|
35
|
+
/** The public records `query` answers about `uris` (the only ones the commons rule counts). */
|
|
36
|
+
async function publicFor(read, query, uris) {
|
|
37
|
+
return (await listAllRecordsFor(read, query, 'uris', uris)).filter((r) => r.source === 'public');
|
|
38
|
+
}
|
|
39
|
+
/** The mirror sidecars about `uris`, by the URI they describe: only the record's own author's count (a
|
|
40
|
+
* mirror describes its own copy), a `source` before the frozen old-Almanac `sourceRef`s. */
|
|
41
|
+
async function sidecarsOf(read, uris) {
|
|
42
|
+
const out = new Map();
|
|
43
|
+
if (uris.length === 0)
|
|
44
|
+
return out;
|
|
45
|
+
for (const s of await publicFor(read, MIRROR_SIDECARS_QUERY, uris)) {
|
|
46
|
+
const subject = s.value.subject;
|
|
47
|
+
const uri = typeof subject === 'string' ? subject : typeof subject?.uri === 'string' ? subject.uri : undefined;
|
|
48
|
+
if (!uri || authority(uri) !== s.author)
|
|
49
|
+
continue;
|
|
50
|
+
out.set(uri, [...(out.get(uri) ?? []), s]);
|
|
51
|
+
}
|
|
52
|
+
for (const list of out.values())
|
|
53
|
+
list.sort((a, b) => Number(b.collection === NSID.SOURCE) - Number(a.collection === NSID.SOURCE) || a.uri.localeCompare(b.uri));
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
/** Each curated record's own provenance (same author, subject that record), by the curated record's URI. */
|
|
57
|
+
async function provenancesOf(read, curated) {
|
|
58
|
+
const out = new Map();
|
|
59
|
+
if (curated.length === 0)
|
|
60
|
+
return out;
|
|
61
|
+
const found = await publicFor(read, PROVENANCE_OF_QUERY, curated.map((r) => r.uri));
|
|
62
|
+
for (const r of curated) {
|
|
63
|
+
const p = found.find((p) => p.author === r.author && p.value.subject?.uri === r.uri);
|
|
64
|
+
if (p)
|
|
65
|
+
out.set(r.uri, p.value);
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
const sourceUris = (v) => (Array.isArray(v?.sources) ? v.sources : []).map((s) => s?.uri).filter((u) => typeof u === 'string');
|
|
70
|
+
/** The sources each curated record's own provenance lists (same author, subject that record, public), in
|
|
71
|
+
* provenance order, by the curated record's URI. A record that is not curated, or has no such provenance,
|
|
72
|
+
* is absent. */
|
|
73
|
+
export async function provenanceSourcesOf(read, records) {
|
|
74
|
+
const provenances = await provenancesOf(read, records.filter((r) => r.source === 'public' && r.curated));
|
|
75
|
+
return new Map([...provenances].map(([uri, v]) => [uri, sourceUris(v)]));
|
|
76
|
+
}
|
|
77
|
+
/** The host DID of each record (by URI), `null` when it is anonymous. */
|
|
78
|
+
export async function hostsOf(read, records, commonsDid) {
|
|
79
|
+
const out = new Map();
|
|
80
|
+
for (const r of records)
|
|
81
|
+
out.set(r.uri, r.source === 'public' ? null : r.author);
|
|
82
|
+
// The commons collective unknown: every public record stays anonymous (see the module doc).
|
|
83
|
+
if (commonsDid === null)
|
|
84
|
+
return out;
|
|
85
|
+
const commons = commonsDid?.trim() || undefined;
|
|
86
|
+
const curated = records.filter((r) => r.source === 'public' && r.curated);
|
|
87
|
+
const plain = records.filter((r) => r.source === 'public' && !r.curated);
|
|
88
|
+
// Each curated record's candidate sources, in provenance order.
|
|
89
|
+
const provenances = await provenancesOf(read, curated);
|
|
90
|
+
const candidates = new Map();
|
|
91
|
+
for (const r of curated) {
|
|
92
|
+
const v = provenances.get(r.uri);
|
|
93
|
+
const byline = typeof v?.composition?.byline === 'string' ? v.composition.byline : undefined;
|
|
94
|
+
candidates.set(r.uri, sourceUris(v).filter((u) => authority(u) !== commons && (byline === undefined || u === byline)));
|
|
95
|
+
}
|
|
96
|
+
const sources = [...new Set([...candidates.values()].flat())];
|
|
97
|
+
const [live, mirrors] = await Promise.all([
|
|
98
|
+
sources.length ? getRecords(read, sources) : Promise.resolve(new Map()),
|
|
99
|
+
sidecarsOf(read, [...sources, ...plain.filter((r) => r.author !== commons).map((r) => r.uri)]),
|
|
100
|
+
]);
|
|
101
|
+
for (const r of curated) {
|
|
102
|
+
const host = candidates.get(r.uri)?.find((u) => live.get(u)?.source === 'public' && !mirrors.has(u));
|
|
103
|
+
out.set(r.uri, host ? authority(host) : null);
|
|
104
|
+
}
|
|
105
|
+
for (const r of plain)
|
|
106
|
+
out.set(r.uri, r.author === commons || mirrors.has(r.uri) ? null : r.author);
|
|
107
|
+
return out;
|
|
108
|
+
}
|
|
109
|
+
/** `http(s)` with a host and no credentials: the server's `public_links::public_web_url`. */
|
|
110
|
+
export function publicWebUrl(value) {
|
|
111
|
+
if (typeof value !== 'string' || value.length > 2048 || /[\u0000-\u001f\u007f-\u009f]/.test(value))
|
|
112
|
+
return false;
|
|
113
|
+
try {
|
|
114
|
+
const url = new URL(value);
|
|
115
|
+
return (url.protocol === 'http:' || url.protocol === 'https:') && Boolean(url.hostname) && !url.username && !url.password;
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
class Unresolved extends Error {
|
|
122
|
+
}
|
|
123
|
+
function refsOf(body) {
|
|
124
|
+
const v = body.attributions;
|
|
125
|
+
if (v === undefined)
|
|
126
|
+
return [];
|
|
127
|
+
if (!Array.isArray(v) || v.length > 16)
|
|
128
|
+
throw new Unresolved();
|
|
129
|
+
return v.map((r) => {
|
|
130
|
+
const { uri, cid } = (r ?? {});
|
|
131
|
+
if (typeof uri !== 'string' || !uri || uri.length > 2048 || typeof cid !== 'string' || !cid || cid.length > 256)
|
|
132
|
+
throw new Unresolved();
|
|
133
|
+
return { uri, cid };
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function creditOf(record, ref, issuer) {
|
|
137
|
+
if (!record || record.cid !== ref.cid || record.author !== issuer || record.collection !== NSID.SOURCE_ATTRIBUTION)
|
|
138
|
+
throw new Unresolved();
|
|
139
|
+
const v = record.value;
|
|
140
|
+
const text = (k, max) => {
|
|
141
|
+
const s = v[k];
|
|
142
|
+
if (typeof s !== 'string' || !s.trim() || s.length > max)
|
|
143
|
+
throw new Unresolved();
|
|
144
|
+
return s;
|
|
145
|
+
};
|
|
146
|
+
const credit = {
|
|
147
|
+
uri: ref.uri,
|
|
148
|
+
cid: ref.cid,
|
|
149
|
+
source: text('source', 128),
|
|
150
|
+
credit: text('credit', 2048),
|
|
151
|
+
license: text('license', 128),
|
|
152
|
+
licenseUrl: typeof v.licenseUrl === 'string' ? v.licenseUrl : '',
|
|
153
|
+
licenseText: text('licenseText', 65536),
|
|
154
|
+
obligationDigest: typeof v.obligationDigest === 'string' ? v.obligationDigest : '',
|
|
155
|
+
};
|
|
156
|
+
if (!publicWebUrl(credit.licenseUrl) || !/^[0-9a-f]{64}$/.test(credit.obligationDigest))
|
|
157
|
+
throw new Unresolved();
|
|
158
|
+
return credit;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The mirrors that also list a public record, with their credits (the server's `source_attribution::listed_on`,
|
|
162
|
+
* PG4): the curated record's provenance sources (a record nobody curated is its own source), each that its
|
|
163
|
+
* own author also wrote a mirror sidecar about. A credit is a `sourceAttribution` by that same author at the
|
|
164
|
+
* exact CID the sidecar names. A declared credit that does not resolve fails closed for the whole answer
|
|
165
|
+
* (`unresolved`, no credits), never a partial licence list.
|
|
166
|
+
*/
|
|
167
|
+
export async function listedOnOf(read, record) {
|
|
168
|
+
if (record.source !== 'public')
|
|
169
|
+
return { listedOn: [], unresolved: false };
|
|
170
|
+
const provenance = record.curated ? (await provenancesOf(read, [record])).get(record.uri) : undefined;
|
|
171
|
+
const sources = sourceUris(provenance);
|
|
172
|
+
if (sources.length === 0)
|
|
173
|
+
sources.push(record.uri);
|
|
174
|
+
const sidecars = await sidecarsOf(read, sources);
|
|
175
|
+
try {
|
|
176
|
+
const mirrors = sources.flatMap((uri) => {
|
|
177
|
+
const found = sidecars.get(uri) ?? [];
|
|
178
|
+
const source = found.find((s) => s.collection === NSID.SOURCE);
|
|
179
|
+
const pick = source ? [source] : found.filter((s) => s.collection === NSID.SOURCE_REF);
|
|
180
|
+
if (pick.length === 0)
|
|
181
|
+
return [];
|
|
182
|
+
const url = source && publicWebUrl(source.value.url) ? (source.value.url) : undefined;
|
|
183
|
+
const refs = pick.flatMap((s) => refsOf(s.value));
|
|
184
|
+
return [{ uri, url, refs: [...new Map(refs.map((r) => [`${r.uri}\n${r.cid}`, r])).values()].sort((a, b) => a.uri.localeCompare(b.uri) || a.cid.localeCompare(b.cid)) }];
|
|
185
|
+
});
|
|
186
|
+
const bodies = await getRecords(read, mirrors.flatMap((m) => m.refs.map((r) => r.uri)));
|
|
187
|
+
const listedOn = mirrors.map(({ uri, url, refs }) => ({ uri, ...(url ? { url } : {}), credits: refs.map((r) => creditOf(bodies.get(r.uri), r, authority(uri))) }));
|
|
188
|
+
return { listedOn, unresolved: false };
|
|
189
|
+
}
|
|
190
|
+
catch (e) {
|
|
191
|
+
if (e instanceof Unresolved)
|
|
192
|
+
return { listedOn: [], unresolved: true };
|
|
193
|
+
throw e;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
/** The provenances naming any of `$uris` among their sources (the `references` role): a source copy finds
|
|
197
|
+
* the curated record made from it. As written, so a provenance is found whatever lists. */
|
|
198
|
+
export const CURATED_FROM_QUERY = {
|
|
199
|
+
where: { all: [{ type: { is: NSID.PROVENANCE } }, { references: { in: ['$uris'] } }] },
|
|
200
|
+
curated: false,
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* The live curated record that stands for `uri` now, when `uri` itself is not one a reader is shown (the
|
|
204
|
+
* server's RS5 pointer resolution, by provenance): a source copy resolves to the curated record whose
|
|
205
|
+
* provenance lists it; a curated record merged away (superseded, so no read answers it) resolves through its
|
|
206
|
+
* own provenance's sources to the record that lists them now. Only a public provenance its curated record's own
|
|
207
|
+
* author wrote counts, and only a record the platform marks curated. `undefined`: nothing stands for it.
|
|
208
|
+
*/
|
|
209
|
+
export async function curatedFor(read, uri) {
|
|
210
|
+
const viaSources = async (sources) => {
|
|
211
|
+
if (sources.length === 0)
|
|
212
|
+
return undefined;
|
|
213
|
+
const provenances = (await publicFor(read, CURATED_FROM_QUERY, sources)).filter((p) => {
|
|
214
|
+
const v = p.value;
|
|
215
|
+
return v.readiness !== 'superseded' && typeof v.subject?.uri === 'string' && authority(v.subject.uri) === p.author;
|
|
216
|
+
});
|
|
217
|
+
const subjects = provenances.map((p) => p.value.subject.uri).filter((u) => u !== uri);
|
|
218
|
+
const found = await getRecords(read, subjects);
|
|
219
|
+
return subjects.map((u) => found.get(u)).find((r) => r?.curated);
|
|
220
|
+
};
|
|
221
|
+
const asSource = await viaSources([uri]);
|
|
222
|
+
if (asSource)
|
|
223
|
+
return asSource;
|
|
224
|
+
// A merged-away curated record: its own provenance (same author) still names its sources.
|
|
225
|
+
const own = (await publicFor(read, PROVENANCE_OF_QUERY, [uri])).find((p) => p.author === authority(uri) && p.value.subject?.uri === uri);
|
|
226
|
+
return viaSources(sourceUris(own?.value));
|
|
227
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* techne-sdk/query — the platform's generic queries (techne P16.1, `docs/techne-write-path/QUERY_DESIGN.md`).
|
|
3
|
+
*
|
|
4
|
+
* A read is a `pub.techne.draft.query`: a `where` tree over shared roles (`type`, `author`, `subject`,
|
|
5
|
+
* `space`, `uri`, `written`, and what each type's query document declares: `start`, `end`, `location`,
|
|
6
|
+
* `text`, `references`), one `order`, `include` and `signals`. The platform scopes every query to what the
|
|
7
|
+
* viewer may read and proves it bounded; this module only carries it: `listRecords` (one page),
|
|
8
|
+
* `listAllRecords` (every page), `countRecords`, and `getRecords` (by URI, in batches the platform takes; `getRecordsAnswer` also says which
|
|
9
|
+
* asked URIs moderation withheld).
|
|
10
|
+
*
|
|
11
|
+
* An app holds its query definitions (data, like any record) and calls these with its own reader: a
|
|
12
|
+
* `get(nsid, params)` over whatever session it has. What a record means stays the app's.
|
|
13
|
+
*/
|
|
14
|
+
import type * as GetRecords from '../generated/types/pub/techne/draft/query/getRecords.js';
|
|
15
|
+
/** A `$param` value: a string, or a list of strings where the query says `in`. */
|
|
16
|
+
export type Param = string | readonly string[];
|
|
17
|
+
/** The one call this module makes: a GET of a platform method. A list value is sent repeated. */
|
|
18
|
+
export type QueryReader = <T>(nsid: string, params: Record<string, string | number | readonly string[] | undefined>) => Promise<T>;
|
|
19
|
+
/** One condition on a role (`{ "is": … }`, `{ "near": { point, within }, "as": … }`, …). */
|
|
20
|
+
export type Condition = Readonly<Record<string, unknown>>;
|
|
21
|
+
/** A node of a query's `where`: `all` / `any` / `not`, or one role's condition. */
|
|
22
|
+
export type QueryNode = {
|
|
23
|
+
readonly all: readonly QueryNode[];
|
|
24
|
+
} | {
|
|
25
|
+
readonly any: readonly QueryNode[];
|
|
26
|
+
} | {
|
|
27
|
+
readonly not: readonly [QueryNode];
|
|
28
|
+
} | {
|
|
29
|
+
readonly [role: string]: Condition | readonly QueryNode[];
|
|
30
|
+
};
|
|
31
|
+
/** A `pub.techne.draft.query`, as data (the platform validates it). */
|
|
32
|
+
export interface Query {
|
|
33
|
+
readonly where: QueryNode;
|
|
34
|
+
readonly order?: string;
|
|
35
|
+
readonly limit?: number;
|
|
36
|
+
readonly include?: {
|
|
37
|
+
readonly author?: 'profile';
|
|
38
|
+
readonly subject?: 'record';
|
|
39
|
+
};
|
|
40
|
+
readonly signals?: readonly Readonly<Record<string, unknown>>[];
|
|
41
|
+
readonly curated?: boolean;
|
|
42
|
+
/** The seed of `order: 'shuffle'`, a literal or a parameter (`$seed`); required with it. */
|
|
43
|
+
readonly seed?: string;
|
|
44
|
+
/** Only the signed-in caller's own records the reach limit holds back (each answered `held`). */
|
|
45
|
+
readonly held?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** One record a query answered (`pub.techne.draft.query.listRecords#record`). */
|
|
48
|
+
export interface QueryRecord<V = Record<string, unknown>> {
|
|
49
|
+
uri: string;
|
|
50
|
+
cid: string;
|
|
51
|
+
author: string;
|
|
52
|
+
collection: string;
|
|
53
|
+
value: V;
|
|
54
|
+
/** The record's indexed time (the `written` role). */
|
|
55
|
+
time: string;
|
|
56
|
+
/** The space a permissioned record counts in. */
|
|
57
|
+
space?: string;
|
|
58
|
+
source: 'public' | 'permissioned';
|
|
59
|
+
/** A public record that is a live curated record (a curator the commons root trusts merged it); its
|
|
60
|
+
* provenance names who it is from ({@link hostsOf}). Absent otherwise. */
|
|
61
|
+
curated?: boolean;
|
|
62
|
+
/** The caller's own permissioned record the reach limit holds back from the people it would reach,
|
|
63
|
+
* answered to its author alone until the limit admits it. Absent otherwise. */
|
|
64
|
+
held?: boolean;
|
|
65
|
+
/** The numbers the query's operators produced, by name (a `near` distance in metres). */
|
|
66
|
+
measures?: Record<string, number>;
|
|
67
|
+
signals?: Record<string, number>;
|
|
68
|
+
/** The records `include` attached: the author's profile, the subject's record. */
|
|
69
|
+
included?: {
|
|
70
|
+
author?: QueryRecord;
|
|
71
|
+
subject?: QueryRecord;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export interface ListPage<V = Record<string, unknown>> {
|
|
75
|
+
records: QueryRecord<V>[];
|
|
76
|
+
cursor?: string;
|
|
77
|
+
/** Asked with `count: true`: how many records the query answers this caller ({@link countRecords}'s). */
|
|
78
|
+
count?: number;
|
|
79
|
+
/** Asked with `count: true`: there are more than `count`. */
|
|
80
|
+
capped?: boolean;
|
|
81
|
+
}
|
|
82
|
+
/** The most records one page (and one `getRecords` call) carries. */
|
|
83
|
+
export declare const MAX_PAGE = 100;
|
|
84
|
+
export interface ListCall {
|
|
85
|
+
params?: Readonly<Record<string, Param>>;
|
|
86
|
+
limit?: number;
|
|
87
|
+
cursor?: string;
|
|
88
|
+
/** Also count what the query answers (the page gains `count` and `capped`). */
|
|
89
|
+
count?: boolean;
|
|
90
|
+
}
|
|
91
|
+
/** One page of `query`. */
|
|
92
|
+
export declare function listRecords<V = Record<string, unknown>>(read: QueryReader, query: Query, call?: ListCall): Promise<ListPage<V>>;
|
|
93
|
+
/** A page whose cursor came back again: paging would never end. */
|
|
94
|
+
export declare class QueryNoProgressError extends Error {
|
|
95
|
+
constructor();
|
|
96
|
+
}
|
|
97
|
+
/** How many pages `listAllRecords` reads before it stops: a guard, the query is the bound. */
|
|
98
|
+
export declare const MAX_PAGES = 100;
|
|
99
|
+
/**
|
|
100
|
+
* The most characters one GET's query string may carry. Every read here is a GET (an XRPC query, and it
|
|
101
|
+
* must pass a PDS's atproto-proxy as one), and proxies refuse a long request line: one in front of a test
|
|
102
|
+
* PDS answered 414 past about 8 KB (nginx's default line buffer), and 100 AT-URIs in one `getRecords` or
|
|
103
|
+
* one `in` list are ~11 KB. So a list is sent in runs that fit this as well as {@link MAX_PAGE}.
|
|
104
|
+
*/
|
|
105
|
+
export declare const MAX_QUERY_CHARS = 6000;
|
|
106
|
+
/** The query-string characters a list call spends besides its list: the query JSON and its other params. */
|
|
107
|
+
export declare function fixedChars(query?: Query, params?: Readonly<Record<string, Param>>): number;
|
|
108
|
+
/**
|
|
109
|
+
* `list` in runs of at most {@link MAX_PAGE} (what one `getRecords` call or one `in` takes) that also fit
|
|
110
|
+
* one GET ({@link MAX_QUERY_CHARS}) beside `fixed` characters of query and other params ({@link fixedChars}).
|
|
111
|
+
* An item too long to fit with anything else goes alone.
|
|
112
|
+
*/
|
|
113
|
+
export declare function batches<T>(list: readonly T[], fixed?: number): T[][];
|
|
114
|
+
/**
|
|
115
|
+
* Every page of `query`, in its order. The query is the bound (the platform proves each branch
|
|
116
|
+
* index-driven); {@link MAX_PAGES} is only a guard. A page can hold fewer records than its limit and still carry
|
|
117
|
+
* a cursor (the platform's read rule drops some after reading), so paging stops only when none comes back.
|
|
118
|
+
*/
|
|
119
|
+
export declare function listAllRecords<V = Record<string, unknown>>(read: QueryReader, query: Query, call?: Omit<ListCall, 'cursor'>): Promise<QueryRecord<V>[]>;
|
|
120
|
+
/**
|
|
121
|
+
* Every page of `query` for all of `uris`, passed as the list parameter `$key` in runs that one `in` and
|
|
122
|
+
* one GET take ({@link batches}), the batches read together. Duplicate URIs are asked once; no URIs
|
|
123
|
+
* read nothing. `params` are the query's other parameters, the same for every batch.
|
|
124
|
+
*/
|
|
125
|
+
export declare function listAllRecordsFor<V = Record<string, unknown>>(read: QueryReader, query: Query, key: string, uris: Iterable<string>, params?: Readonly<Record<string, Param>>): Promise<QueryRecord<V>[]>;
|
|
126
|
+
export interface CountAnswer {
|
|
127
|
+
count: number;
|
|
128
|
+
/** Counting stopped at the platform's cap. */
|
|
129
|
+
capped: boolean;
|
|
130
|
+
groups?: {
|
|
131
|
+
key: string;
|
|
132
|
+
count: number;
|
|
133
|
+
}[];
|
|
134
|
+
}
|
|
135
|
+
/** How many records `listRecords` would answer for `query`, optionally per type or author. */
|
|
136
|
+
export declare function countRecords(read: QueryReader, query: Query, call?: {
|
|
137
|
+
params?: ListCall['params'];
|
|
138
|
+
groupBy?: 'type' | 'author';
|
|
139
|
+
}): Promise<CountAnswer>;
|
|
140
|
+
/** One `pub.techne.draft.query.getRecords` answer. */
|
|
141
|
+
export interface GetRecordsPage<V = Record<string, unknown>> {
|
|
142
|
+
records: QueryRecord<V>[];
|
|
143
|
+
/** The asked URIs of indexed public records that moderation holds back from this caller. Such a record
|
|
144
|
+
* answers not-found, and nothing may stand in for it (no curated record found by provenance). */
|
|
145
|
+
withheld?: string[];
|
|
146
|
+
/** Asked with `handles`: the public handle of each repo the asked URIs name, found or not (never an
|
|
147
|
+
* inactive account's). */
|
|
148
|
+
handles?: GetRecords.Handle[];
|
|
149
|
+
/** Asked with `curation`, signed in: the curation status of each asked URI that is the caller's own. */
|
|
150
|
+
curation?: GetRecords.Curation[];
|
|
151
|
+
/** Asked with `defaults`, signed in: each asked URI naming a missing record of the caller's own that
|
|
152
|
+
* the platform reads a starting value for, and that value. */
|
|
153
|
+
defaults?: GetRecords.Default[];
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* One of the caller's own records, as far as being listed for others goes (`getRecords#curation`, the
|
|
157
|
+
* answer `put` gives a write): `pending` until the curator and moderation answer, `curated` with the
|
|
158
|
+
* curated record listed for it, or `notCurated` with why (moderation declined it, the index refused
|
|
159
|
+
* the version, a type with no lexicon or no curator).
|
|
160
|
+
*/
|
|
161
|
+
export type Curation = {
|
|
162
|
+
uri: string;
|
|
163
|
+
status: 'pending';
|
|
164
|
+
} | {
|
|
165
|
+
uri: string;
|
|
166
|
+
status: 'curated';
|
|
167
|
+
curated: string;
|
|
168
|
+
} | {
|
|
169
|
+
uri: string;
|
|
170
|
+
status: 'notCurated';
|
|
171
|
+
reason: string;
|
|
172
|
+
};
|
|
173
|
+
/** {@link getRecords}'s records, and the asked URIs moderation withheld from this caller. */
|
|
174
|
+
export interface RecordsAnswer<V = Record<string, unknown>> {
|
|
175
|
+
records: Map<string, QueryRecord<V>>;
|
|
176
|
+
withheld: Set<string>;
|
|
177
|
+
/** Asked with `{ handles: true }`: each named repo's public handle, by DID (empty otherwise). */
|
|
178
|
+
handles: Map<string, string>;
|
|
179
|
+
/** Asked with `{ curation: true }`, signed in: the curation status of each asked URI that is the
|
|
180
|
+
* caller's own, by URI (empty otherwise, and for anyone else's record or a private one). */
|
|
181
|
+
curation: Map<string, Curation>;
|
|
182
|
+
/** Asked with `{ defaults: true }`, signed in: the starting value the platform reads for each asked URI
|
|
183
|
+
* naming a missing record of the caller's own, by URI (empty otherwise). Show it until the caller
|
|
184
|
+
* writes the record. */
|
|
185
|
+
defaults: Map<string, unknown>;
|
|
186
|
+
}
|
|
187
|
+
/** The records at `uris` the viewer may read, by URI, and which of the asked URIs were withheld. With
|
|
188
|
+
* `handles`, also the public handle of each repo the URIs name; with `curation`, the curation status
|
|
189
|
+
* of each asked URI that is the signed-in caller's own; with `defaults`, the starting value of each
|
|
190
|
+
* missing record of the caller's own the platform has one for (no extra read: the same call answers
|
|
191
|
+
* them). `includeBlockedByMe` lifts the caller's own blocks for this read (to name the people they
|
|
192
|
+
* blocked). */
|
|
193
|
+
export declare function getRecordsAnswer<V = Record<string, unknown>>(read: QueryReader, uris: Iterable<string>, opts?: {
|
|
194
|
+
handles?: boolean;
|
|
195
|
+
curation?: boolean;
|
|
196
|
+
defaults?: boolean;
|
|
197
|
+
includeBlockedByMe?: boolean;
|
|
198
|
+
}): Promise<RecordsAnswer<V>>;
|
|
199
|
+
/** The records at `uris` the viewer may read, by URI (absent: no such record, not readable, or withheld). */
|
|
200
|
+
export declare function getRecords<V = Record<string, unknown>>(read: QueryReader, uris: Iterable<string>): Promise<Map<string, QueryRecord<V>>>;
|
|
201
|
+
export { CURATED_FROM_QUERY, curatedFor, hostsOf, listedOnOf, MIRROR_SIDECARS_QUERY, PROVENANCE_OF_QUERY, provenanceSourcesOf, publicWebUrl, type ListedOn, type SourceCredit, } from './hosts.js';
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* techne-sdk/query — the platform's generic queries (techne P16.1, `docs/techne-write-path/QUERY_DESIGN.md`).
|
|
3
|
+
*
|
|
4
|
+
* A read is a `pub.techne.draft.query`: a `where` tree over shared roles (`type`, `author`, `subject`,
|
|
5
|
+
* `space`, `uri`, `written`, and what each type's query document declares: `start`, `end`, `location`,
|
|
6
|
+
* `text`, `references`), one `order`, `include` and `signals`. The platform scopes every query to what the
|
|
7
|
+
* viewer may read and proves it bounded; this module only carries it: `listRecords` (one page),
|
|
8
|
+
* `listAllRecords` (every page), `countRecords`, and `getRecords` (by URI, in batches the platform takes; `getRecordsAnswer` also says which
|
|
9
|
+
* asked URIs moderation withheld).
|
|
10
|
+
*
|
|
11
|
+
* An app holds its query definitions (data, like any record) and calls these with its own reader: a
|
|
12
|
+
* `get(nsid, params)` over whatever session it has. What a record means stays the app's.
|
|
13
|
+
*/
|
|
14
|
+
import { NSID } from '../generated/nsid.js';
|
|
15
|
+
/** The most records one page (and one `getRecords` call) carries. */
|
|
16
|
+
export const MAX_PAGE = 100;
|
|
17
|
+
const paramsOf = (params) => (params && Object.keys(params).length ? JSON.stringify(params) : undefined);
|
|
18
|
+
/** One page of `query`. */
|
|
19
|
+
export function listRecords(read, query, call = {}) {
|
|
20
|
+
return read(NSID.QUERY_LIST_RECORDS, {
|
|
21
|
+
query: JSON.stringify(query),
|
|
22
|
+
params: paramsOf(call.params),
|
|
23
|
+
limit: call.limit,
|
|
24
|
+
cursor: call.cursor,
|
|
25
|
+
count: call.count ? 'true' : undefined,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** A page whose cursor came back again: paging would never end. */
|
|
29
|
+
export class QueryNoProgressError extends Error {
|
|
30
|
+
constructor() {
|
|
31
|
+
super('listRecords handed back a cursor it already gave');
|
|
32
|
+
this.name = 'QueryNoProgressError';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/** How many pages `listAllRecords` reads before it stops: a guard, the query is the bound. */
|
|
36
|
+
export const MAX_PAGES = 100;
|
|
37
|
+
/**
|
|
38
|
+
* The most characters one GET's query string may carry. Every read here is a GET (an XRPC query, and it
|
|
39
|
+
* must pass a PDS's atproto-proxy as one), and proxies refuse a long request line: one in front of a test
|
|
40
|
+
* PDS answered 414 past about 8 KB (nginx's default line buffer), and 100 AT-URIs in one `getRecords` or
|
|
41
|
+
* one `in` list are ~11 KB. So a list is sent in runs that fit this as well as {@link MAX_PAGE}.
|
|
42
|
+
*/
|
|
43
|
+
export const MAX_QUERY_CHARS = 6000;
|
|
44
|
+
/** What the path, `limit`, `handles` and a cursor may take beside the list. A cursor is `<sort key>~<uri>`
|
|
45
|
+
* (~150 characters encoded); this assumes a short sort key (a time), as every order today has. */
|
|
46
|
+
const HEAD_ROOM = 400;
|
|
47
|
+
/** Characters `s` takes form-encoded (`URLSearchParams`, what a reader sends). */
|
|
48
|
+
const formChars = (s) => new URLSearchParams({ v: s }).toString().length - 2;
|
|
49
|
+
/** What one list item adds to a query string, sent repeated (`&uris=…`) or inside a JSON list (`"…",`):
|
|
50
|
+
* the larger of the two. */
|
|
51
|
+
const itemChars = (item) => formChars(JSON.stringify(String(item))) + 6;
|
|
52
|
+
/** The query-string characters a list call spends besides its list: the query JSON and its other params. */
|
|
53
|
+
export function fixedChars(query, params = {}) {
|
|
54
|
+
return (query ? formChars(JSON.stringify(query)) : 0) + formChars(JSON.stringify(params));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* `list` in runs of at most {@link MAX_PAGE} (what one `getRecords` call or one `in` takes) that also fit
|
|
58
|
+
* one GET ({@link MAX_QUERY_CHARS}) beside `fixed` characters of query and other params ({@link fixedChars}).
|
|
59
|
+
* An item too long to fit with anything else goes alone.
|
|
60
|
+
*/
|
|
61
|
+
export function batches(list, fixed = 0) {
|
|
62
|
+
const budget = MAX_QUERY_CHARS - HEAD_ROOM - fixed;
|
|
63
|
+
const out = [];
|
|
64
|
+
let run = [];
|
|
65
|
+
let used = 0;
|
|
66
|
+
for (const item of list) {
|
|
67
|
+
const cost = itemChars(item);
|
|
68
|
+
if (run.length > 0 && (run.length === MAX_PAGE || used + cost > budget)) {
|
|
69
|
+
out.push(run);
|
|
70
|
+
run = [];
|
|
71
|
+
used = 0;
|
|
72
|
+
}
|
|
73
|
+
run.push(item);
|
|
74
|
+
used += cost;
|
|
75
|
+
}
|
|
76
|
+
if (run.length > 0)
|
|
77
|
+
out.push(run);
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Every page of `query`, in its order. The query is the bound (the platform proves each branch
|
|
82
|
+
* index-driven); {@link MAX_PAGES} is only a guard. A page can hold fewer records than its limit and still carry
|
|
83
|
+
* a cursor (the platform's read rule drops some after reading), so paging stops only when none comes back.
|
|
84
|
+
*/
|
|
85
|
+
export async function listAllRecords(read, query, call = {}) {
|
|
86
|
+
const out = [];
|
|
87
|
+
const seen = new Set();
|
|
88
|
+
let cursor;
|
|
89
|
+
for (let page = 0; page < MAX_PAGES; page++) {
|
|
90
|
+
const got = await listRecords(read, query, { params: call.params, limit: call.limit ?? MAX_PAGE, cursor });
|
|
91
|
+
out.push(...got.records);
|
|
92
|
+
if (!got.cursor)
|
|
93
|
+
return out;
|
|
94
|
+
if (seen.has(got.cursor))
|
|
95
|
+
throw new QueryNoProgressError();
|
|
96
|
+
seen.add(got.cursor);
|
|
97
|
+
cursor = got.cursor;
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Every page of `query` for all of `uris`, passed as the list parameter `$key` in runs that one `in` and
|
|
103
|
+
* one GET take ({@link batches}), the batches read together. Duplicate URIs are asked once; no URIs
|
|
104
|
+
* read nothing. `params` are the query's other parameters, the same for every batch.
|
|
105
|
+
*/
|
|
106
|
+
export async function listAllRecordsFor(read, query, key, uris, params = {}) {
|
|
107
|
+
const unique = [...new Set(uris)];
|
|
108
|
+
if (unique.length === 0)
|
|
109
|
+
return [];
|
|
110
|
+
const pages = await Promise.all(batches(unique, fixedChars(query, params)).map((chunk) => listAllRecords(read, query, { params: { ...params, [key]: chunk } })));
|
|
111
|
+
return pages.flat();
|
|
112
|
+
}
|
|
113
|
+
/** How many records `listRecords` would answer for `query`, optionally per type or author. */
|
|
114
|
+
export function countRecords(read, query, call = {}) {
|
|
115
|
+
return read(NSID.QUERY_COUNT_RECORDS, { query: JSON.stringify(query), params: paramsOf(call.params), groupBy: call.groupBy });
|
|
116
|
+
}
|
|
117
|
+
/** `c` as a {@link Curation}, or `undefined` for a malformed one or a status this SDK does not know (the
|
|
118
|
+
* guards are for the wire: a platform's answer is not held to the generated type). */
|
|
119
|
+
function curationOf(c) {
|
|
120
|
+
if (!c || typeof c !== 'object')
|
|
121
|
+
return undefined;
|
|
122
|
+
const { uri, status, curated, reason } = c;
|
|
123
|
+
if (typeof uri !== 'string')
|
|
124
|
+
return undefined;
|
|
125
|
+
if (status === 'pending')
|
|
126
|
+
return { uri, status: 'pending' };
|
|
127
|
+
if (status === 'curated' && typeof curated === 'string')
|
|
128
|
+
return { uri, status: 'curated', curated };
|
|
129
|
+
if (status === 'notCurated')
|
|
130
|
+
return { uri, status: 'notCurated', reason: typeof reason === 'string' ? reason : 'not curated' };
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
/** The records at `uris` the viewer may read, by URI, and which of the asked URIs were withheld. With
|
|
134
|
+
* `handles`, also the public handle of each repo the URIs name; with `curation`, the curation status
|
|
135
|
+
* of each asked URI that is the signed-in caller's own; with `defaults`, the starting value of each
|
|
136
|
+
* missing record of the caller's own the platform has one for (no extra read: the same call answers
|
|
137
|
+
* them). `includeBlockedByMe` lifts the caller's own blocks for this read (to name the people they
|
|
138
|
+
* blocked). */
|
|
139
|
+
export async function getRecordsAnswer(read, uris, opts = {}) {
|
|
140
|
+
const flags = ['handles', 'curation', 'defaults', 'includeBlockedByMe'];
|
|
141
|
+
const extra = Object.fromEntries(flags.filter((f) => opts[f]).map((f) => [f, 'true']));
|
|
142
|
+
const pages = await Promise.all(batches([...new Set(uris)]).map((uris) => read(NSID.QUERY_GET_RECORDS, { uris, ...extra })));
|
|
143
|
+
const handles = new Map();
|
|
144
|
+
for (const h of pages.flatMap((p) => (Array.isArray(p.handles) ? p.handles : []))) {
|
|
145
|
+
if (typeof h?.did === 'string' && typeof h.handle === 'string')
|
|
146
|
+
handles.set(h.did, h.handle);
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
records: new Map(pages.flatMap((p) => p.records).map((r) => [r.uri, r])),
|
|
150
|
+
withheld: new Set(pages.flatMap((p) => (Array.isArray(p.withheld) ? p.withheld : []))),
|
|
151
|
+
handles,
|
|
152
|
+
curation: new Map(pages
|
|
153
|
+
.flatMap((p) => (Array.isArray(p.curation) ? p.curation : []))
|
|
154
|
+
.map(curationOf)
|
|
155
|
+
.filter((c) => c !== undefined)
|
|
156
|
+
.map((c) => [c.uri, c])),
|
|
157
|
+
defaults: new Map(pages
|
|
158
|
+
.flatMap((p) => (Array.isArray(p.defaults) ? p.defaults : []))
|
|
159
|
+
.filter((d) => typeof d?.uri === 'string')
|
|
160
|
+
.map((d) => [d.uri, d.value])),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/** The records at `uris` the viewer may read, by URI (absent: no such record, not readable, or withheld). */
|
|
164
|
+
export async function getRecords(read, uris) {
|
|
165
|
+
return (await getRecordsAnswer(read, uris)).records;
|
|
166
|
+
}
|
|
167
|
+
export { CURATED_FROM_QUERY, curatedFor, hostsOf, listedOnOf, MIRROR_SIDECARS_QUERY, PROVENANCE_OF_QUERY, provenanceSourcesOf, publicWebUrl, } from './hosts.js';
|