techne-sdk 0.4.0 → 0.6.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +12 -3
  3. package/dist/auth/app-key.d.ts +5 -0
  4. package/dist/auth/app-key.js +7 -0
  5. package/dist/auth/index.d.ts +19 -11
  6. package/dist/auth/index.js +21 -13
  7. package/dist/catalog/catalog.gen.js +499 -139
  8. package/dist/connect.d.ts +18 -3
  9. package/dist/connect.js +2 -0
  10. package/dist/generated/index.d.ts +3 -0
  11. package/dist/generated/index.js +9 -0
  12. package/dist/generated/lexicons.d.ts +590 -146
  13. package/dist/generated/lexicons.js +332 -71
  14. package/dist/generated/nsid.d.ts +3 -0
  15. package/dist/generated/nsid.js +3 -0
  16. package/dist/generated/nsid.json +3 -0
  17. package/dist/generated/types/pub/techne/draft/identity/attest.d.ts +2 -0
  18. package/dist/generated/types/pub/techne/draft/identity/defs.d.ts +23 -7
  19. package/dist/generated/types/pub/techne/draft/identity/defs.js +7 -0
  20. package/dist/generated/types/pub/techne/draft/identity/finishAddMethod.d.ts +3 -0
  21. package/dist/generated/types/pub/techne/draft/identity/listMethods.d.ts +2 -1
  22. package/dist/generated/types/pub/techne/draft/identity/manageMethods.d.ts +52 -10
  23. package/dist/generated/types/pub/techne/draft/identity/manageMethods.js +56 -0
  24. package/dist/generated/types/pub/techne/draft/identity/writeAsCollective.d.ts +51 -0
  25. package/dist/generated/types/pub/techne/draft/identity/writeAsCollective.js +55 -0
  26. package/dist/generated/types/pub/techne/draft/permissioned/putRecord.d.ts +1 -1
  27. package/dist/generated/types/pub/techne/draft/permissioned/putRecords.d.ts +1 -1
  28. package/dist/generated/types/pub/techne/draft/query/getRecords.d.ts +11 -0
  29. package/dist/generated/types/pub/techne/draft/query/getRecords.js +7 -0
  30. package/dist/query/compose.d.ts +1 -1
  31. package/dist/query/compose.js +1 -1
  32. package/dist/query/index.d.ts +7 -0
  33. package/dist/query/index.js +28 -1
  34. package/dist/versions/react.js +19 -6
  35. package/dist/wasm/techne-wasm.gen.js +1 -1
  36. package/dist/wasm/techne-wasm2js.gen.js +16836 -16838
  37. package/package.json +3 -2
package/dist/connect.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * techne-sdk/connect — the SDK's client over one signed-in session (techne P13.3): two clients, the
3
- * reads (`query`, `get`, `versions` and their options forms, SDK1) and the one write (`put`).
3
+ * reads (`query`, `get`, `versions` and their options forms, SDK1) and the writes (`put`, and
4
+ * `writeAsCollective` for writing as a collective the user may write as).
4
5
  *
5
6
  * Everything goes through the user's own PDS with the user's own session (an atproto OAuth session's
6
7
  * `did` and `fetchHandler`, or anything shaped like it). `pds` calls the PDS itself (the user's repo).
@@ -16,7 +17,7 @@
16
17
  * in to yet uses {@link connectAnonymous}: public reads straight from the platform, no write.
17
18
  */
18
19
  import type { FetchHandler } from '@atproto/xrpc';
19
- import { AtpBaseClient } from './generated/index.js';
20
+ import { AtpBaseClient, type PubTechneDraftIdentityWriteAsCollective } from './generated/index.js';
20
21
  import type { IncludeOf, ItemFor, RecordOfQuery, RecordOfUri } from './item.js';
21
22
  import type { Query } from './query/index.js';
22
23
  import type { PutRecord, PutResult } from './put/index.js';
@@ -57,7 +58,11 @@ export interface ReadOptions<K extends readonly unknown[], R> {
57
58
  queryKey: K;
58
59
  queryFn: () => Promise<R>;
59
60
  }
60
- /** The SDK's client for one signed-in user: its clients, its reads and its one write. */
61
+ /** {@link Techne.writeAsCollective}'s input: com.atproto.repo.applyWrites's, with `repo` the collective's DID. */
62
+ export type WriteAsCollectiveInput = PubTechneDraftIdentityWriteAsCollective.InputSchema;
63
+ /** {@link Techne.writeAsCollective}'s answer: com.atproto.repo.applyWrites's (`commit`, `results`). */
64
+ export type WriteAsCollectiveOutput = PubTechneDraftIdentityWriteAsCollective.OutputSchema;
65
+ /** The SDK's client for one signed-in user: its clients, its reads and its writes. */
61
66
  export interface Techne extends Clients {
62
67
  /** One page of a query document; a list across authors answers curated records. Valid items by default
63
68
  * (`ValidItem<T>`); `{ include: 'all' }` any verdict (`Item<T>`). */
@@ -70,6 +75,16 @@ export interface Techne extends Clients {
70
75
  versions<U extends string>(uri: U): Promise<Versions<RecordOfUri<U>> | null>;
71
76
  /** Write records, and with `deletes` delete some (`techne-sdk/put` says how). */
72
77
  put(records: PutRecord[], options?: PutOptions): Promise<PutResult>;
78
+ /**
79
+ * Write as a collective the user may write as (`pub.techne.draft.identity.writeAsCollective`): the
80
+ * writes are applied atomically to the collective's repo by the platform, with the credential it holds
81
+ * for the collective, after it checks the user's role there (403 `Forbidden` when the user may not).
82
+ * `input` is com.atproto.repo.applyWrites's, `repo` the collective's DID (never the user's own: that is
83
+ * `put`, or the PDS's applyWrites). Under {@link connect} it goes through the user's PDS like every
84
+ * platform call, so the app's OAuth scope needs
85
+ * `rpc:pub.techne.draft.identity.writeAsCollective?aud=<platform DID>%23atproto_appview`.
86
+ */
87
+ writeAsCollective(input: WriteAsCollectiveInput): Promise<WriteAsCollectiveOutput>;
73
88
  /** The options forms (TanStack Query's `{ queryKey, queryFn }`). Each key ends with the viewer's DID, so
74
89
  * one viewer's reads are never another's, and a prefix (`['techne', 'versions']`) still names them all. */
75
90
  queryOptions<Q extends Query, O extends QueryOpts = {}>(q: Q, opts?: O): ReadOptions<readonly ['techne', 'query', Q, QueryOpts, string], Page<RecordOfQuery<Q>, IncludeOf<O>>>;
package/dist/connect.js CHANGED
@@ -16,6 +16,7 @@ export function bind(clients) {
16
16
  get: (uri, opts) => get(techne, uri, opts),
17
17
  versions: (uri) => versions(techne, uri),
18
18
  put: (records, options) => put(techne, records, options),
19
+ writeAsCollective: async (input) => (await clients.platform.pub.techne.draft.identity.writeAsCollective(input)).data,
19
20
  queryOptions: (q, opts) => ({ queryKey: ['techne', 'query', q, opts ?? {}, clients.did], queryFn: () => query(techne, q, opts) }),
20
21
  getOptions: (uri, opts) => ({ queryKey: ['techne', 'record', uri, opts ?? {}, clients.did], queryFn: () => get(techne, uri, opts) }),
21
22
  versionsOptions: (uri) => ({ queryKey: ['techne', 'versions', uri, clients.did], queryFn: () => versions(techne, uri) }),
@@ -78,6 +79,7 @@ export function connectAnonymous(platform = TECHNE_PLATFORM_DID, options = {}) {
78
79
  const nowhere = async () => Promise.reject(new Error(SIGN_IN_TO_WRITE));
79
80
  const techne = bind({ did: '', pds: new AtpBaseClient(nowhere), platform: new AtpBaseClient(direct), claims: options.claims });
80
81
  techne.put = async () => Promise.reject(new Error(SIGN_IN_TO_WRITE));
82
+ techne.writeAsCollective = async () => Promise.reject(new Error(SIGN_IN_TO_WRITE));
81
83
  return techne;
82
84
  }
83
85
  /**
@@ -72,6 +72,7 @@ import * as PubTechneDraftIdentityResolve from './types/pub/techne/draft/identit
72
72
  import * as PubTechneDraftIdentityRevokeLinkToken from './types/pub/techne/draft/identity/revokeLinkToken.js';
73
73
  import * as PubTechneDraftIdentityUnlinkAccount from './types/pub/techne/draft/identity/unlinkAccount.js';
74
74
  import * as PubTechneDraftIdentityUnlinkMethod from './types/pub/techne/draft/identity/unlinkMethod.js';
75
+ import * as PubTechneDraftIdentityWriteAsCollective from './types/pub/techne/draft/identity/writeAsCollective.js';
75
76
  import * as PubTechneDraftInterest from './types/pub/techne/draft/interest.js';
76
77
  import * as PubTechneDraftIntroProposal from './types/pub/techne/draft/introProposal.js';
77
78
  import * as PubTechneDraftInvite from './types/pub/techne/draft/invite.js';
@@ -229,6 +230,7 @@ export * as PubTechneDraftIdentityResolve from './types/pub/techne/draft/identit
229
230
  export * as PubTechneDraftIdentityRevokeLinkToken from './types/pub/techne/draft/identity/revokeLinkToken.js';
230
231
  export * as PubTechneDraftIdentityUnlinkAccount from './types/pub/techne/draft/identity/unlinkAccount.js';
231
232
  export * as PubTechneDraftIdentityUnlinkMethod from './types/pub/techne/draft/identity/unlinkMethod.js';
233
+ export * as PubTechneDraftIdentityWriteAsCollective from './types/pub/techne/draft/identity/writeAsCollective.js';
232
234
  export * as PubTechneDraftInterest from './types/pub/techne/draft/interest.js';
233
235
  export * as PubTechneDraftIntroProposal from './types/pub/techne/draft/introProposal.js';
234
236
  export * as PubTechneDraftInvite from './types/pub/techne/draft/invite.js';
@@ -719,6 +721,7 @@ export declare class PubTechneDraftIdentityNS {
719
721
  revokeLinkToken(data?: PubTechneDraftIdentityRevokeLinkToken.InputSchema, opts?: PubTechneDraftIdentityRevokeLinkToken.CallOptions): Promise<PubTechneDraftIdentityRevokeLinkToken.Response>;
720
722
  unlinkAccount(data?: PubTechneDraftIdentityUnlinkAccount.InputSchema, opts?: PubTechneDraftIdentityUnlinkAccount.CallOptions): Promise<PubTechneDraftIdentityUnlinkAccount.Response>;
721
723
  unlinkMethod(data?: PubTechneDraftIdentityUnlinkMethod.InputSchema, opts?: PubTechneDraftIdentityUnlinkMethod.CallOptions): Promise<PubTechneDraftIdentityUnlinkMethod.Response>;
724
+ writeAsCollective(data?: PubTechneDraftIdentityWriteAsCollective.InputSchema, opts?: PubTechneDraftIdentityWriteAsCollective.CallOptions): Promise<PubTechneDraftIdentityWriteAsCollective.Response>;
722
725
  }
723
726
  export declare class PubTechneDraftIdentityLinkRedemptionRecord {
724
727
  _client: XrpcClient;
@@ -35,6 +35,7 @@ import * as PubTechneDraftIdentityResolve from './types/pub/techne/draft/identit
35
35
  import * as PubTechneDraftIdentityRevokeLinkToken from './types/pub/techne/draft/identity/revokeLinkToken.js';
36
36
  import * as PubTechneDraftIdentityUnlinkAccount from './types/pub/techne/draft/identity/unlinkAccount.js';
37
37
  import * as PubTechneDraftIdentityUnlinkMethod from './types/pub/techne/draft/identity/unlinkMethod.js';
38
+ import * as PubTechneDraftIdentityWriteAsCollective from './types/pub/techne/draft/identity/writeAsCollective.js';
38
39
  import * as PubTechneDraftPermissionedDeleteRecord from './types/pub/techne/draft/permissioned/deleteRecord.js';
39
40
  import * as PubTechneDraftPermissionedGetGrants from './types/pub/techne/draft/permissioned/getGrants.js';
40
41
  import * as PubTechneDraftPermissionedGetRecord from './types/pub/techne/draft/permissioned/getRecord.js';
@@ -152,6 +153,7 @@ export * as PubTechneDraftIdentityResolve from './types/pub/techne/draft/identit
152
153
  export * as PubTechneDraftIdentityRevokeLinkToken from './types/pub/techne/draft/identity/revokeLinkToken.js';
153
154
  export * as PubTechneDraftIdentityUnlinkAccount from './types/pub/techne/draft/identity/unlinkAccount.js';
154
155
  export * as PubTechneDraftIdentityUnlinkMethod from './types/pub/techne/draft/identity/unlinkMethod.js';
156
+ export * as PubTechneDraftIdentityWriteAsCollective from './types/pub/techne/draft/identity/writeAsCollective.js';
155
157
  export * as PubTechneDraftInterest from './types/pub/techne/draft/interest.js';
156
158
  export * as PubTechneDraftIntroProposal from './types/pub/techne/draft/introProposal.js';
157
159
  export * as PubTechneDraftInvite from './types/pub/techne/draft/invite.js';
@@ -1050,6 +1052,13 @@ export class PubTechneDraftIdentityNS {
1050
1052
  throw PubTechneDraftIdentityUnlinkMethod.toKnownErr(e);
1051
1053
  });
1052
1054
  }
1055
+ writeAsCollective(data, opts) {
1056
+ return this._client
1057
+ .call('pub.techne.draft.identity.writeAsCollective', opts?.qp, data, opts)
1058
+ .catch((e) => {
1059
+ throw PubTechneDraftIdentityWriteAsCollective.toKnownErr(e);
1060
+ });
1061
+ }
1053
1062
  }
1054
1063
  export class PubTechneDraftIdentityLinkRedemptionRecord {
1055
1064
  _client;