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,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The contact identity check `put` asks before it writes a `pub.techne.draft.contact` (techne P19.1).
|
|
3
|
+
*
|
|
4
|
+
* A contact's number is the key its account is resolved from, and its `did` is the answer: changing
|
|
5
|
+
* either shares the owner's private beacons with a different human, and that exposure does not come
|
|
6
|
+
* back (wiki/architecture/add-people-write-rules.md). The platform refuses such a write itself (409
|
|
7
|
+
* `IdentityConflict` or `DuplicatePhone` from `permissioned.putRecord`/`putRecords`); the SDK also asks
|
|
8
|
+
* first, over the owner's own contacts, and throws {@link ContactConflictError} before anything is
|
|
9
|
+
* written. The rules, for a write that replaces the whole record:
|
|
10
|
+
*
|
|
11
|
+
* - `InvalidPhone`: a `phone` that is not E.164 (it is the bind key, matched exactly).
|
|
12
|
+
* - `IdentityConflict`: the contact has a number and the write gives another or none (a record without
|
|
13
|
+
* its `phone` would clear the bind key); it has a `did` and the write changes or drops it; it is
|
|
14
|
+
* name-only but already bound and the write gives it a first number; the write sets a `did` itself
|
|
15
|
+
* (the platform binds a contact from its number or a redeemed invitation), except on a new contact
|
|
16
|
+
* with no number, which is the owner choosing an account directly; or it binds a `did` another of the
|
|
17
|
+
* owner's active contacts is already bound to. Run Correct person instead.
|
|
18
|
+
* - `Archived`: the contact was corrected away (`archivedAt`); it is history, written again only as it is.
|
|
19
|
+
* - `DuplicatePhone`: a number the write introduces (a new contact's, or a name-only one's first) is
|
|
20
|
+
* already on another of the owner's active contacts, or on another contact in the same put.
|
|
21
|
+
*
|
|
22
|
+
* Renaming is always allowed. Differences from the platform's check: the SDK cannot see accounts, so
|
|
23
|
+
* it counts every contact that is not archived, and it reads and then writes, where the platform checks
|
|
24
|
+
* inside the owner's write transaction; two devices adding one number at the same moment can both pass
|
|
25
|
+
* this check, and the platform then refuses the second.
|
|
26
|
+
*/
|
|
27
|
+
import { NSID } from '../generated/nsid.js';
|
|
28
|
+
/** A put that would change who a contact is: nothing was written. */
|
|
29
|
+
export class ContactConflictError extends Error {
|
|
30
|
+
conflicts;
|
|
31
|
+
name = 'ContactConflictError';
|
|
32
|
+
constructor(conflicts) {
|
|
33
|
+
super(`put: ${conflicts.map((c) => `${c.uri}: ${c.error} ${c.message}`).join('; ')}`);
|
|
34
|
+
this.conflicts = conflicts;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const E164 = /^\+[1-9]\d{1,14}$/;
|
|
38
|
+
const has = (v, key) => Object.prototype.hasOwnProperty.call(v, key) && v[key] !== undefined;
|
|
39
|
+
const phoneOf = (v) => (typeof v.phone === 'string' && v.phone.trim() !== '' ? v.phone.trim() : undefined);
|
|
40
|
+
const active = (v) => typeof v.archivedAt !== 'string';
|
|
41
|
+
/** Equal as JSON, whatever the key order (the platform stores bodies as `jsonb`, which reorders keys). */
|
|
42
|
+
const canonical = (v) => Array.isArray(v) ? v.map(canonical) : v && typeof v === 'object' ? Object.fromEntries(Object.keys(v).sort().map((k) => [k, canonical(v[k])])) : v;
|
|
43
|
+
const same = (a, b) => JSON.stringify(canonical(a)) === JSON.stringify(canonical(b));
|
|
44
|
+
/** What the contact writes in `writes` would do to `stored` (the owner's contacts), refused or not. */
|
|
45
|
+
export function contactConflicts(stored, writes) {
|
|
46
|
+
const before = new Map(stored.map((c) => [c.uri, c.value]));
|
|
47
|
+
const after = new Map(before);
|
|
48
|
+
for (const w of writes)
|
|
49
|
+
after.set(w.uri, w.record);
|
|
50
|
+
const conflicts = [];
|
|
51
|
+
const conflict = (uri, error, message) => conflicts.push({ uri, error, message });
|
|
52
|
+
for (const w of writes) {
|
|
53
|
+
const { uri } = w;
|
|
54
|
+
const record = w.record;
|
|
55
|
+
const current = before.get(uri);
|
|
56
|
+
if (current && !active(current)) {
|
|
57
|
+
if (!same(current, record))
|
|
58
|
+
conflict(uri, 'Archived', 'this contact was corrected away; add the replacement person instead');
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const given = phoneOf(record);
|
|
62
|
+
if (given !== undefined && !E164.test(given)) {
|
|
63
|
+
conflict(uri, 'InvalidPhone', `${given} is not an E.164 number`);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (current) {
|
|
67
|
+
const stored = phoneOf(current);
|
|
68
|
+
if (has(current, 'did') && (!has(record, 'did') || !same(current.did, record.did))) {
|
|
69
|
+
conflict(uri, 'IdentityConflict', 'the account this contact is bound to cannot change; run Correct person');
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (stored !== undefined && given !== stored) {
|
|
73
|
+
conflict(uri, 'IdentityConflict', 'the number that identifies this contact cannot change; run Correct person');
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (stored === undefined && given !== undefined && has(current, 'did')) {
|
|
77
|
+
conflict(uri, 'IdentityConflict', 'this contact is already bound to an account; run Correct person');
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const others = [...after].filter(([other, v]) => other !== uri && active(v));
|
|
82
|
+
const boundNow = has(record, 'did') && !(current && has(current, 'did')) ? record.did : undefined;
|
|
83
|
+
if (boundNow !== undefined && (current || given !== undefined || typeof boundNow !== 'string')) {
|
|
84
|
+
conflict(uri, 'IdentityConflict', 'a contact with a number is bound from its number; leave its did to the platform');
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (boundNow !== undefined && others.some(([, v]) => v.did === boundNow)) {
|
|
88
|
+
conflict(uri, 'IdentityConflict', 'another saved contact is already this person; choose that one');
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const introduced = given !== undefined && given !== (current && phoneOf(current)) ? given : undefined;
|
|
92
|
+
if (introduced !== undefined && others.some(([, v]) => phoneOf(v) === introduced)) {
|
|
93
|
+
conflict(uri, 'DuplicatePhone', `${introduced} is already on another saved contact`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return conflicts;
|
|
97
|
+
}
|
|
98
|
+
/** Every contact the owner has, through the platform's private read (one page after another). */
|
|
99
|
+
export async function storedContacts(techne) {
|
|
100
|
+
const out = [];
|
|
101
|
+
let cursor;
|
|
102
|
+
do {
|
|
103
|
+
const { data } = await techne.platform.pub.techne.draft.permissioned.listRecords({ repo: techne.did, collection: NSID.CONTACT, cursor, limit: 100 });
|
|
104
|
+
for (const r of data.records)
|
|
105
|
+
out.push({ uri: r.uri, value: r.value });
|
|
106
|
+
cursor = data.cursor;
|
|
107
|
+
} while (cursor);
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { Records, AnyRecord } from '../generated/records.js';
|
|
2
|
+
import type * as CalendarEvent from '../generated/types/community/lexicon/calendar/event.js';
|
|
3
|
+
import type * as EventConfig from '../generated/types/pub/techne/draft/event/config.js';
|
|
4
|
+
import type * as EventDetail from '../generated/types/pub/techne/draft/event/detail.js';
|
|
5
|
+
import type { OmitKey } from '../generated/util.js';
|
|
6
|
+
import type { Techne } from '../connect.js';
|
|
7
|
+
import { type Decision } from '../wasm/index.js';
|
|
8
|
+
import { type Curation } from '../query/index.js';
|
|
9
|
+
export { contactConflicts, ContactConflictError, type ContactConflict, type StoredContact } from './contacts.js';
|
|
10
|
+
export type { Records, AnyRecord, Decision, Curation };
|
|
11
|
+
/** One record to put: the body (its `$type` is its collection), and its key or space if it has them. */
|
|
12
|
+
export interface PutRecord {
|
|
13
|
+
record: AnyRecord;
|
|
14
|
+
/** Its record key; derived when absent (see the module doc). */
|
|
15
|
+
rkey?: string;
|
|
16
|
+
/** The space it is placed in (`at://{authority}/{spaceType}/{skey}`); a record with a space is private. */
|
|
17
|
+
space?: string;
|
|
18
|
+
}
|
|
19
|
+
/** One write, as planned. */
|
|
20
|
+
export interface Write {
|
|
21
|
+
uri: string;
|
|
22
|
+
cid: string;
|
|
23
|
+
collection: string;
|
|
24
|
+
rkey: string;
|
|
25
|
+
record: AnyRecord;
|
|
26
|
+
space?: string;
|
|
27
|
+
/** Written with the private batch write rather than to the PDS. */
|
|
28
|
+
private: boolean;
|
|
29
|
+
/** The platform has a lexicon for its type; a record without one is never curated (P18.1). */
|
|
30
|
+
lexicon: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** One write as `put` answers it: a public one with the platform's answer for that record. */
|
|
33
|
+
export interface Written extends Write {
|
|
34
|
+
/**
|
|
35
|
+
* The platform's answer for this record (public records only; a private record is not hinted).
|
|
36
|
+
* `invalid` with "not curated: no lexicon" is no refusal: the record was written, it is just not
|
|
37
|
+
* curated.
|
|
38
|
+
*/
|
|
39
|
+
status?: PutStatus;
|
|
40
|
+
}
|
|
41
|
+
/** One record to delete: its key (`collection` + `rkey`, or its `uri` in the writer's repo), and its
|
|
42
|
+
* space if it was placed in one (that makes the delete private, as it made the write). */
|
|
43
|
+
export type DeleteRecord = {
|
|
44
|
+
uri: string;
|
|
45
|
+
collection?: undefined;
|
|
46
|
+
rkey?: undefined;
|
|
47
|
+
space?: string;
|
|
48
|
+
} | {
|
|
49
|
+
uri?: undefined;
|
|
50
|
+
collection: string;
|
|
51
|
+
rkey: string;
|
|
52
|
+
space?: string;
|
|
53
|
+
}
|
|
54
|
+
/** A planned {@link Write} passed back as it is: its uri, collection and rkey must agree. */
|
|
55
|
+
| {
|
|
56
|
+
uri: string;
|
|
57
|
+
collection: string;
|
|
58
|
+
rkey: string;
|
|
59
|
+
space?: string;
|
|
60
|
+
};
|
|
61
|
+
/** One delete, as planned. */
|
|
62
|
+
export interface Delete {
|
|
63
|
+
uri: string;
|
|
64
|
+
collection: string;
|
|
65
|
+
rkey: string;
|
|
66
|
+
space?: string;
|
|
67
|
+
/** Deleted with the platform's private delete rather than from the PDS. */
|
|
68
|
+
private: boolean;
|
|
69
|
+
}
|
|
70
|
+
/** One delete, as done: `deleted` is false when nothing was there (already gone, or never written). */
|
|
71
|
+
export interface Deleted extends Delete {
|
|
72
|
+
deleted: boolean;
|
|
73
|
+
}
|
|
74
|
+
/** A put's status: never `valid` (see {@link hint}; `wait` brings the curated version). */
|
|
75
|
+
export type PutStatus = Exclude<Decision, {
|
|
76
|
+
decision: 'valid';
|
|
77
|
+
}>;
|
|
78
|
+
/** What `put` answers. */
|
|
79
|
+
export interface PutResult {
|
|
80
|
+
/** Every record written, private ones first; each public one with its own `status`. */
|
|
81
|
+
writes: Written[];
|
|
82
|
+
/** Every delete asked for (with `deletes`), in the order sent (public, then private); empty without. */
|
|
83
|
+
deletes: Deleted[];
|
|
84
|
+
/**
|
|
85
|
+
* The put's status, from the public records with a lexicon: `invalid` (the first reason) when the
|
|
86
|
+
* platform refused one, else `pending`. A record with no lexicon is not curated, which is no refusal
|
|
87
|
+
* of the put, so it counts only when the put has nothing else public: then its answer is the put's
|
|
88
|
+
* ("not curated: no lexicon"). Each record's own answer is on its write.
|
|
89
|
+
*/
|
|
90
|
+
status: PutStatus;
|
|
91
|
+
/** With `wait`: the curated record that names one of them as its source, if it came in time. */
|
|
92
|
+
curated?: {
|
|
93
|
+
uri: string;
|
|
94
|
+
cid: string;
|
|
95
|
+
record: unknown;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* Each public record's curation status, in write order, in the shape `getRecords` answers it read
|
|
99
|
+
* back later (`{ curation: true }`): `pending`, `curated` with the curated record listed for it, or
|
|
100
|
+
* `notCurated` with why. Read once from the platform after the hints (and after `wait`); when that
|
|
101
|
+
* read fails, from the hint (`invalid` is `notCurated`, anything else `pending`), and the failure is
|
|
102
|
+
* {@link PutResult.curationError}.
|
|
103
|
+
*/
|
|
104
|
+
curation: Curation[];
|
|
105
|
+
/** Why the read behind `curation` failed, when it did (the records are written all the same). */
|
|
106
|
+
curationError?: unknown;
|
|
107
|
+
}
|
|
108
|
+
/** A put whose private batch write refused some records: nothing public was written. */
|
|
109
|
+
export declare class PutError extends Error {
|
|
110
|
+
readonly refused: {
|
|
111
|
+
uri: string;
|
|
112
|
+
error: string;
|
|
113
|
+
message: string;
|
|
114
|
+
}[];
|
|
115
|
+
constructor(refused: {
|
|
116
|
+
uri: string;
|
|
117
|
+
error: string;
|
|
118
|
+
message: string;
|
|
119
|
+
}[]);
|
|
120
|
+
}
|
|
121
|
+
/** The plan for `records` into `repo` (Rust, `techne_sdk::put::plan`). */
|
|
122
|
+
export declare function plan(repo: string, records: PutRecord[], now?: Date): Write[];
|
|
123
|
+
/** The plan for `records` and `deletes` into `repo` (Rust, `techne_sdk::put::plan_with_deletes`). */
|
|
124
|
+
export declare function planWithDeletes(repo: string, records: PutRecord[], deletes: DeleteRecord[], now?: Date): {
|
|
125
|
+
writes: Write[];
|
|
126
|
+
deletes: Delete[];
|
|
127
|
+
};
|
|
128
|
+
export declare function put(techne: Techne, records: PutRecord[], options?: {
|
|
129
|
+
wait?: number;
|
|
130
|
+
deletes?: DeleteRecord[];
|
|
131
|
+
}): Promise<PutResult>;
|
|
132
|
+
type EventFields = OmitKey<CalendarEvent.Record, '$type'>;
|
|
133
|
+
type ConfigFields = OmitKey<EventConfig.Record, '$type' | 'event' | 'createdAt'>;
|
|
134
|
+
type DetailFields = OmitKey<EventDetail.Record, '$type' | 'event' | 'createdAt'>;
|
|
135
|
+
/**
|
|
136
|
+
* An event with its config, and its detail when it has gated fields, as the records to `put`
|
|
137
|
+
* (repo = the host's DID). The config and the detail point at the event by URI and CID. The config is
|
|
138
|
+
* keyed `{rkey}-cfg` and the detail `{rkey}-det` (`{rkey}` = the event's key), the only keys the platform
|
|
139
|
+
* reads them at. Spaces: `audience: 'public'` puts the event and its config on the firehose; `'invite'` places
|
|
140
|
+
* both in the event's invite space (`at://{repo}/…space.event.invite/{rkey}`). The detail is always
|
|
141
|
+
* placed in the event's detail space (same skey), so it is read only by those confirmed for the event.
|
|
142
|
+
*/
|
|
143
|
+
export declare function eventRecords(repo: string, input: {
|
|
144
|
+
event: EventFields;
|
|
145
|
+
config: ConfigFields;
|
|
146
|
+
detail?: DetailFields;
|
|
147
|
+
audience: 'public' | 'invite';
|
|
148
|
+
}): PutRecord[];
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* techne-sdk/put — the SDK's one write (techne P13.2): `put(techne, records)`.
|
|
3
|
+
*
|
|
4
|
+
* An app writes records, typed from the lexicons, and nothing refuses a write. `put`:
|
|
5
|
+
*
|
|
6
|
+
* 1. plans them in Rust (`crates/techne-sdk`'s `put`, run as WebAssembly): each record's key (the one
|
|
7
|
+
* given, the lexicon's `literal:` key, or a TID derived from the record), its CID and URI, and the
|
|
8
|
+
* order: private records (a `space` named, or a lexicon type with no public home) first, public last;
|
|
9
|
+
* a type the platform has no lexicon for (another app's own record) is public: it goes to the user's
|
|
10
|
+
* PDS and the platform answers it `invalid`, "not curated: no lexicon" (P18.1). An unknown name in
|
|
11
|
+
* the platform's own namespace (a typo after it, an old name, other letter case) stays private instead;
|
|
12
|
+
* 2. writes the private ones with the platform's private batch write (`permissioned.putRecords`,
|
|
13
|
+
* through the user's PDS) and stops if any is refused;
|
|
14
|
+
* 3. writes the public ones to the user's PDS in one atomic `com.atproto.repo.applyWrites`;
|
|
15
|
+
* 4. with `deletes`: deletes the private ones, one `permissioned.deleteRecord` each (below);
|
|
16
|
+
* 5. hints each public record (`sync.indexRecord`, signed as the user through the PDS) so the platform
|
|
17
|
+
* indexes it ahead of the relay, and answers what the platform said.
|
|
18
|
+
*
|
|
19
|
+
* `put(techne, records, { deletes })` also deletes, in the same plan: a delete is private or public by
|
|
20
|
+
* the same rule as a write (a `space` named, or a lexicon type with no public home, is private; a type
|
|
21
|
+
* with no lexicon is public, P18.1). The
|
|
22
|
+
* public deletes go into the same atomic `applyWrites` as the public writes (step 3); the private ones
|
|
23
|
+
* go out after it (step 4), so nothing public is left pointing at a private record already gone. A
|
|
24
|
+
* public delete the PDS does not hold is sent to the private delete too (a record kept in a space but
|
|
25
|
+
* named without it), and each delete answers `deleted`: whether anything was there to delete. Deletes
|
|
26
|
+
* are not hinted, so the platform drops a deleted public record when the relay brings the delete. A key
|
|
27
|
+
* may not be both written and deleted, or deleted twice, in one put, and only the writer's own records
|
|
28
|
+
* (by DID) can be deleted. A contact deleted in the same put no longer counts for the contact check.
|
|
29
|
+
*
|
|
30
|
+
* Public and private writes cannot share a transaction, so a put that fails part way has written its
|
|
31
|
+
* private records and none of its public ones, or (with deletes) all of those and only some of its
|
|
32
|
+
* private deletes. Send the same records again: the keys are deterministic,
|
|
33
|
+
* a private record written again is a no-op, a public record already at its CID is not rewritten, and a
|
|
34
|
+
* record already gone is not deleted again.
|
|
35
|
+
* Until every record has landed, show the thing as pending.
|
|
36
|
+
*
|
|
37
|
+
* Before writing a `contact`, `put` asks whether the write would change who the contact is (its
|
|
38
|
+
* number, its account; `./contacts`): the platform no longer refuses that, so the SDK does, and throws
|
|
39
|
+
* {@link ContactConflictError} with nothing written.
|
|
40
|
+
*
|
|
41
|
+
* Each public record carries the platform's answer for it (`status` on its write), and the put's
|
|
42
|
+
* `status` sums them up (see {@link PutResult}): a put mixing a curated type with another app's own
|
|
43
|
+
* type answers the one `pending` and the other "not curated: no lexicon".
|
|
44
|
+
*
|
|
45
|
+
* `put(techne, records, { wait: ms })` also waits up to `ms` for a record that names one of the public
|
|
46
|
+
* records as its source (the commons' curated version) and returns it as `curated`. That is generic:
|
|
47
|
+
* `getVersions` of a source answers the curated record that lists it at this CID, whoever wrote it.
|
|
48
|
+
* Only records with a lexicon that the platform did not refuse are waited for: one without a lexicon,
|
|
49
|
+
* or one answered `invalid`, is never curated, so a put of only such records returns at once. That
|
|
50
|
+
* does not promise every other record a curated version: `wait` still ends at its deadline.
|
|
51
|
+
*
|
|
52
|
+
* Builders exist only for writes that compose several records ({@link eventRecords}); any other record
|
|
53
|
+
* is put as it is.
|
|
54
|
+
*/
|
|
55
|
+
import { XRPCError } from '@atproto/xrpc';
|
|
56
|
+
import { NSID } from '../generated/nsid.js';
|
|
57
|
+
import { call } from '../wasm/index.js';
|
|
58
|
+
import { contactConflicts, ContactConflictError, storedContacts } from './contacts.js';
|
|
59
|
+
import { getRecordsAnswer } from '../query/index.js';
|
|
60
|
+
export { contactConflicts, ContactConflictError } from './contacts.js';
|
|
61
|
+
/** A put whose private batch write refused some records: nothing public was written. */
|
|
62
|
+
export class PutError extends Error {
|
|
63
|
+
refused;
|
|
64
|
+
constructor(refused) {
|
|
65
|
+
super(`put: ${refused.map((r) => `${r.uri}: ${r.error} ${r.message}`).join('; ')}`);
|
|
66
|
+
this.refused = refused;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** The plan for `records` into `repo` (Rust, `techne_sdk::put::plan`). */
|
|
70
|
+
export function plan(repo, records, now = new Date()) {
|
|
71
|
+
return call('put', { repo, records, now: unixSeconds(now) });
|
|
72
|
+
}
|
|
73
|
+
/** The clock the plan reads (an old name has a lexicon only while its rename is honoured); the
|
|
74
|
+
* WebAssembly has none of its own. */
|
|
75
|
+
function unixSeconds(now) {
|
|
76
|
+
return Math.floor(now.getTime() / 1000);
|
|
77
|
+
}
|
|
78
|
+
/** The plan for `records` and `deletes` into `repo` (Rust, `techne_sdk::put::plan_with_deletes`). */
|
|
79
|
+
export function planWithDeletes(repo, records, deletes, now = new Date()) {
|
|
80
|
+
return call('putPlan', { repo, records, deletes, now: unixSeconds(now) });
|
|
81
|
+
}
|
|
82
|
+
/** How often `wait` asks for the curated record. */
|
|
83
|
+
const WAIT_POLL_MS = 250;
|
|
84
|
+
export async function put(techne, records, options = {}) {
|
|
85
|
+
const { did } = techne;
|
|
86
|
+
const { writes, deletes } = options.deletes?.length ? planWithDeletes(did, records, options.deletes) : { writes: plan(did, records), deletes: [] };
|
|
87
|
+
const privates = writes.filter((w) => w.private);
|
|
88
|
+
const publics = writes.filter((w) => !w.private);
|
|
89
|
+
const publicDeletes = deletes.filter((d) => !d.private);
|
|
90
|
+
const contacts = writes.filter((w) => w.collection === NSID.CONTACT);
|
|
91
|
+
if (contacts.length) {
|
|
92
|
+
const gone = new Set(deletes.map((d) => d.uri));
|
|
93
|
+
const conflicts = contactConflicts((await storedContacts(techne)).filter((c) => !gone.has(c.uri)), contacts);
|
|
94
|
+
if (conflicts.length)
|
|
95
|
+
throw new ContactConflictError(conflicts);
|
|
96
|
+
}
|
|
97
|
+
if (privates.length) {
|
|
98
|
+
const { data } = await techne.platform.pub.techne.draft.permissioned.putRecords({
|
|
99
|
+
repo: did,
|
|
100
|
+
writes: privates.map(({ collection, rkey, record, space }) => ({ collection, rkey, record, space })),
|
|
101
|
+
});
|
|
102
|
+
const refused = data.results.flatMap((r, i) => r.$type === NSID.PERMISSIONED_PUT_RECORDS_WRITE_ERROR ? [{ uri: privates[i].uri, error: String(r.error), message: String(r.message) }] : []);
|
|
103
|
+
if (refused.length)
|
|
104
|
+
throw new PutError(refused);
|
|
105
|
+
}
|
|
106
|
+
const done = new Map();
|
|
107
|
+
if (publics.length || publicDeletes.length) {
|
|
108
|
+
const current = await Promise.all(publics.map((w) => currentCid(techne, w)));
|
|
109
|
+
const ops = publics.flatMap((w, i) => current[i] === w.cid
|
|
110
|
+
? []
|
|
111
|
+
: [{ $type: current[i] ? 'com.atproto.repo.applyWrites#update' : 'com.atproto.repo.applyWrites#create', collection: w.collection, rkey: w.rkey, value: w.record }]);
|
|
112
|
+
// A record already gone is not deleted again (a PDS refuses deleting what it does not hold).
|
|
113
|
+
const held = await Promise.all(publicDeletes.map((d) => currentCid(techne, d)));
|
|
114
|
+
for (const [i, d] of publicDeletes.entries()) {
|
|
115
|
+
if (held[i])
|
|
116
|
+
ops.push({ $type: 'com.atproto.repo.applyWrites#delete', collection: d.collection, rkey: d.rkey });
|
|
117
|
+
}
|
|
118
|
+
if (ops.length)
|
|
119
|
+
await techne.pds.com.atproto.repo.applyWrites({ repo: did, writes: ops });
|
|
120
|
+
for (const [i, d] of publicDeletes.entries())
|
|
121
|
+
if (held[i])
|
|
122
|
+
done.set(d.uri, true);
|
|
123
|
+
}
|
|
124
|
+
// Private deletes after the public leg: nothing public is left pointing at what they remove. A public
|
|
125
|
+
// delete the PDS did not hold goes here too: a record of that collection kept in a space, named
|
|
126
|
+
// without it. Deleting what is already gone answers without a `rev`, so a retry is a no-op.
|
|
127
|
+
for (const d of deletes) {
|
|
128
|
+
if (done.has(d.uri))
|
|
129
|
+
continue;
|
|
130
|
+
const { data } = await techne.platform.pub.techne.draft.permissioned.deleteRecord({ repo: did, collection: d.collection, rkey: d.rkey });
|
|
131
|
+
done.set(d.uri, Boolean(data.rev));
|
|
132
|
+
}
|
|
133
|
+
const answers = new Map();
|
|
134
|
+
await Promise.all(publics.map(async (w) => answers.set(w, await hint(techne, w.uri))));
|
|
135
|
+
const curatable = publics.filter((w) => w.lexicon);
|
|
136
|
+
const counted = (curatable.length ? curatable : publics).map((w) => answers.get(w));
|
|
137
|
+
const status = counted.find((a) => a.decision === 'invalid') ?? { decision: 'pending' };
|
|
138
|
+
const result = {
|
|
139
|
+
writes: writes.map((w) => (answers.has(w) ? { ...w, status: answers.get(w) } : w)),
|
|
140
|
+
deletes: deletes.map((d) => ({ ...d, deleted: done.get(d.uri) ?? false })),
|
|
141
|
+
status,
|
|
142
|
+
curation: [],
|
|
143
|
+
};
|
|
144
|
+
// Only a record with a lexicon the platform did not refuse can come back curated.
|
|
145
|
+
const waitable = curatable.filter((w) => answers.get(w).decision !== 'invalid');
|
|
146
|
+
if (options.wait && waitable.length) {
|
|
147
|
+
const curated = await curatedOf(techne, waitable, Date.now() + options.wait);
|
|
148
|
+
if (curated)
|
|
149
|
+
result.curated = curated;
|
|
150
|
+
}
|
|
151
|
+
const { read, error } = await curationRead(techne, publics);
|
|
152
|
+
result.curation = curationOfWrites(publics, answers, read);
|
|
153
|
+
if (error !== undefined)
|
|
154
|
+
result.curationError = error;
|
|
155
|
+
return result;
|
|
156
|
+
}
|
|
157
|
+
/** The platform's curation answer for `publics`, by URI, through {@link getRecordsAnswer} (which keeps each
|
|
158
|
+
* GET under the length a proxy takes), and why it failed when it did (then nothing is read). */
|
|
159
|
+
async function curationRead(techne, publics) {
|
|
160
|
+
if (!publics.length)
|
|
161
|
+
return { read: new Map() };
|
|
162
|
+
const reader = async (nsid, params) => (await techne.platform.call(nsid, params)).data;
|
|
163
|
+
try {
|
|
164
|
+
return { read: (await getRecordsAnswer(reader, publics.map((w) => w.uri), { curation: true })).curation };
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
return { read: new Map(), error };
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/** The curation status of each of `publics` (see {@link PutResult.curation}). */
|
|
171
|
+
function curationOfWrites(publics, answers, read) {
|
|
172
|
+
return publics.map((w) => {
|
|
173
|
+
const known = read.get(w.uri);
|
|
174
|
+
const hinted = answers.get(w);
|
|
175
|
+
// A refusal the hint answered stands over a read that has not caught up with it.
|
|
176
|
+
if (hinted?.decision === 'invalid' && (!known || known.status === 'pending'))
|
|
177
|
+
return { uri: w.uri, status: 'notCurated', reason: hinted.reason };
|
|
178
|
+
return known ?? { uri: w.uri, status: 'pending' };
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
/** The CID the user's repo holds at `w`'s key, or `null` when it holds nothing there. */
|
|
182
|
+
async function currentCid(techne, w) {
|
|
183
|
+
try {
|
|
184
|
+
const { data } = await techne.pds.com.atproto.repo.getRecord({ repo: techne.did, collection: w.collection, rkey: w.rkey });
|
|
185
|
+
return data.cid ?? null;
|
|
186
|
+
}
|
|
187
|
+
catch (e) {
|
|
188
|
+
if (e instanceof XRPCError && e.error === 'RecordNotFound')
|
|
189
|
+
return null;
|
|
190
|
+
throw e;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* The hint for one public record. `indexRecord` answers `decide` for the version it indexed (P1.4:
|
|
195
|
+
* `valid`, `pending` or `invalid` with a reason); a version the platform refused answers `invalid`.
|
|
196
|
+
* Anything it did not refuse answers `pending` here: `put` is pending until its curated version lands
|
|
197
|
+
* (`wait`). Any other failure (rate limit, an unreachable PDS) answers `pending`: the relay brings the
|
|
198
|
+
* record anyway.
|
|
199
|
+
*/
|
|
200
|
+
async function hint(techne, uri) {
|
|
201
|
+
try {
|
|
202
|
+
const { data } = await techne.platform.pub.techne.draft.sync.indexRecord({ uri });
|
|
203
|
+
if (data.decision === 'invalid')
|
|
204
|
+
return { decision: 'invalid', reason: data.reason ?? 'invalid' };
|
|
205
|
+
return { decision: 'pending' };
|
|
206
|
+
}
|
|
207
|
+
catch {
|
|
208
|
+
return { decision: 'pending' };
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/** The first curated record that names one of `sources`, at the CID just written, as its source. */
|
|
212
|
+
async function curatedOf(techne, sources, deadline) {
|
|
213
|
+
for (;;) {
|
|
214
|
+
for (const source of sources) {
|
|
215
|
+
const answer = await techne.platform.pub.techne.draft.commons.getVersions({ uri: source.uri }).then((r) => r.data, () => null);
|
|
216
|
+
if (answer && answer.uri !== source.uri && answer.versions.some((v) => v.uri === source.uri && v.cid === source.cid)) {
|
|
217
|
+
return { uri: answer.uri, cid: answer.cid, record: answer.record };
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
const left = deadline - Date.now();
|
|
221
|
+
if (left <= 0)
|
|
222
|
+
return undefined;
|
|
223
|
+
await new Promise((r) => setTimeout(r, Math.min(WAIT_POLL_MS, left)));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* An event with its config, and its detail when it has gated fields, as the records to `put`
|
|
228
|
+
* (repo = the host's DID). The config and the detail point at the event by URI and CID. The config is
|
|
229
|
+
* keyed `{rkey}-cfg` and the detail `{rkey}-det` (`{rkey}` = the event's key), the only keys the platform
|
|
230
|
+
* reads them at. Spaces: `audience: 'public'` puts the event and its config on the firehose; `'invite'` places
|
|
231
|
+
* both in the event's invite space (`at://{repo}/…space.event.invite/{rkey}`). The detail is always
|
|
232
|
+
* placed in the event's detail space (same skey), so it is read only by those confirmed for the event.
|
|
233
|
+
*/
|
|
234
|
+
export function eventRecords(repo, input) {
|
|
235
|
+
const event = { $type: NSID.CALENDAR_EVENT, ...input.event };
|
|
236
|
+
const [{ uri, cid, rkey }] = plan(repo, [{ record: event }]);
|
|
237
|
+
const ref = { uri, cid };
|
|
238
|
+
const createdAt = event.createdAt;
|
|
239
|
+
const invite = input.audience === 'invite' ? `at://${repo}/${NSID.SPACE_EVENT_INVITE}/${rkey}` : undefined;
|
|
240
|
+
const out = [
|
|
241
|
+
{ record: event, rkey, space: invite },
|
|
242
|
+
{ record: { $type: NSID.EVENT_CONFIG, ...input.config, event: ref, createdAt }, rkey: `${rkey}-cfg`, space: invite },
|
|
243
|
+
];
|
|
244
|
+
if (input.detail) {
|
|
245
|
+
out.push({
|
|
246
|
+
record: { $type: NSID.EVENT_DETAIL, ...input.detail, event: ref, createdAt },
|
|
247
|
+
rkey: `${rkey}-det`,
|
|
248
|
+
space: `at://${repo}/${NSID.SPACE_EVENT_DETAIL}/${rkey}`,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
return out;
|
|
252
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
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 { type Query, type QueryReader, type QueryRecord } from './index.js';
|
|
25
|
+
/** The provenance records written about `$uris` (as written: a read scoped to subjects). */
|
|
26
|
+
export declare const PROVENANCE_OF_QUERY: Query;
|
|
27
|
+
/** The mirror sidecars written about `$uris` (`source`, and the frozen old-Almanac `sourceRef`). */
|
|
28
|
+
export declare const MIRROR_SIDECARS_QUERY: Query;
|
|
29
|
+
/** The sources each curated record's own provenance lists (same author, subject that record, public), in
|
|
30
|
+
* provenance order, by the curated record's URI. A record that is not curated, or has no such provenance,
|
|
31
|
+
* is absent. */
|
|
32
|
+
export declare function provenanceSourcesOf(read: QueryReader, records: readonly QueryRecord[]): Promise<Map<string, string[]>>;
|
|
33
|
+
/** The host DID of each record (by URI), `null` when it is anonymous. */
|
|
34
|
+
export declare function hostsOf(read: QueryReader, records: readonly QueryRecord[], commonsDid?: string | null): Promise<Map<string, string | null>>;
|
|
35
|
+
/** One source credit (`pub.techne.draft.sourceAttribution`), pinned to its publisher and exact CID. */
|
|
36
|
+
export interface SourceCredit {
|
|
37
|
+
uri: string;
|
|
38
|
+
cid: string;
|
|
39
|
+
source: string;
|
|
40
|
+
credit: string;
|
|
41
|
+
license: string;
|
|
42
|
+
licenseUrl: string;
|
|
43
|
+
licenseText: string;
|
|
44
|
+
obligationDigest: string;
|
|
45
|
+
}
|
|
46
|
+
/** A mirror that also lists the record: "also listed on". */
|
|
47
|
+
export interface ListedOn {
|
|
48
|
+
/** The mirror's own copy. */
|
|
49
|
+
uri: string;
|
|
50
|
+
/** Its page at the source, when that is a public web URL. */
|
|
51
|
+
url?: string;
|
|
52
|
+
credits: SourceCredit[];
|
|
53
|
+
}
|
|
54
|
+
/** `http(s)` with a host and no credentials: the server's `public_links::public_web_url`. */
|
|
55
|
+
export declare function publicWebUrl(value: unknown): value is string;
|
|
56
|
+
/**
|
|
57
|
+
* The mirrors that also list a public record, with their credits (the server's `source_attribution::listed_on`,
|
|
58
|
+
* PG4): the curated record's provenance sources (a record nobody curated is its own source), each that its
|
|
59
|
+
* own author also wrote a mirror sidecar about. A credit is a `sourceAttribution` by that same author at the
|
|
60
|
+
* exact CID the sidecar names. A declared credit that does not resolve fails closed for the whole answer
|
|
61
|
+
* (`unresolved`, no credits), never a partial licence list.
|
|
62
|
+
*/
|
|
63
|
+
export declare function listedOnOf(read: QueryReader, record: QueryRecord): Promise<{
|
|
64
|
+
listedOn: ListedOn[];
|
|
65
|
+
unresolved: boolean;
|
|
66
|
+
}>;
|
|
67
|
+
/** The provenances naming any of `$uris` among their sources (the `references` role): a source copy finds
|
|
68
|
+
* the curated record made from it. As written, so a provenance is found whatever lists. */
|
|
69
|
+
export declare const CURATED_FROM_QUERY: Query;
|
|
70
|
+
/**
|
|
71
|
+
* The live curated record that stands for `uri` now, when `uri` itself is not one a reader is shown (the
|
|
72
|
+
* server's RS5 pointer resolution, by provenance): a source copy resolves to the curated record whose
|
|
73
|
+
* provenance lists it; a curated record merged away (superseded, so no read answers it) resolves through its
|
|
74
|
+
* own provenance's sources to the record that lists them now. Only a public provenance its curated record's own
|
|
75
|
+
* author wrote counts, and only a record the platform marks curated. `undefined`: nothing stands for it.
|
|
76
|
+
*/
|
|
77
|
+
export declare function curatedFor(read: QueryReader, uri: string): Promise<QueryRecord | undefined>;
|