techne-sdk 0.14.0 → 0.15.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.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * GENERATED CODE - DO NOT MODIFY
3
3
  */
4
- import { type ValidationResult } from '@atproto/lexicon';
4
+ import { type ValidationResult, BlobRef } from '@atproto/lexicon';
5
5
  import type * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef.js';
6
6
  export interface Main {
7
7
  $type: 'pub.techne.draft.evaluation';
@@ -10,6 +10,8 @@ export interface Main {
10
10
  direction: 'positive' | 'negative' | (string & {});
11
11
  /** Optional free-form note. */
12
12
  note?: string;
13
+ /** Optional photo of the subject, set by the evaluator: a blob in the evaluator's own repo. Apps show it only when the subject has no picture of its own. */
14
+ image?: BlobRef;
13
15
  createdAt: string;
14
16
  [k: string]: unknown;
15
17
  }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { type ValidationResult } from '@atproto/lexicon';
5
+ export interface Main {
6
+ $type: 'pub.techne.draft.follow';
7
+ /** The person followed. */
8
+ subject: string;
9
+ createdAt: string;
10
+ [k: string]: unknown;
11
+ }
12
+ export declare function isMain<V>(v: V): v is import("../../../../util.js").$TypedObject<V, "pub.techne.draft.follow", "main">;
13
+ export declare function validateMain<V>(v: V): ValidationResult<Main & V>;
14
+ export { type Main as Record, isMain as isRecord, validateMain as validateRecord, };
@@ -0,0 +1,12 @@
1
+ import { validate as _validate } from '../../../../lexicons.js';
2
+ import { is$typed as _is$typed, } from '../../../../util.js';
3
+ const is$typed = _is$typed, validate = _validate;
4
+ const id = 'pub.techne.draft.follow';
5
+ const hashMain = 'main';
6
+ export function isMain(v) {
7
+ return is$typed(v, id, hashMain);
8
+ }
9
+ export function validateMain(v) {
10
+ return validate(v, id, hashMain, true);
11
+ }
12
+ export { isMain as isRecord, validateMain as validateRecord, };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { type ValidationResult } from '@atproto/lexicon';
5
+ export interface Main {
6
+ $type: 'pub.techne.draft.notificationPref';
7
+ /** The kind of notice. An unknown kind is kept and ignored. */
8
+ kind: 'curator.new' | 'curator.picks' | (string & {});
9
+ /** Send this kind of notice (push and the other interrupting channels). The in-app inbox is not switched. */
10
+ enabled: boolean;
11
+ createdAt: string;
12
+ [k: string]: unknown;
13
+ }
14
+ export declare function isMain<V>(v: V): v is import("../../../../util.js").$TypedObject<V, "pub.techne.draft.notificationPref", "main">;
15
+ export declare function validateMain<V>(v: V): ValidationResult<Main & V>;
16
+ export { type Main as Record, isMain as isRecord, validateMain as validateRecord, };
@@ -0,0 +1,12 @@
1
+ import { validate as _validate } from '../../../../lexicons.js';
2
+ import { is$typed as _is$typed, } from '../../../../util.js';
3
+ const is$typed = _is$typed, validate = _validate;
4
+ const id = 'pub.techne.draft.notificationPref';
5
+ const hashMain = 'main';
6
+ export function isMain(v) {
7
+ return is$typed(v, id, hashMain);
8
+ }
9
+ export function validateMain(v) {
10
+ return validate(v, id, hashMain, true);
11
+ }
12
+ export { isMain as isRecord, validateMain as validateRecord, };
@@ -26,7 +26,7 @@ export interface Main {
26
26
  url?: string;
27
27
  /** Public phone number, E.164. */
28
28
  phone?: string;
29
- /** Where the organization is: a point, an H3 cell, an address or a place record, each bare entry a site of the org (its office, its storefront, a place it runs). A `pub.techne.draft.locationEntry` says something other than "is at": `serves` for a service area, `registered` for where a registry lists it (a nonprofit's filing city or ZIP area, never the street address). Never a mailing address: a registry's address is often an organizer's home, so it is not published. Its query document reads the entries as `sites`: each is its own location. This replaces `pub.techne.draft.orgAtPlace`. */
29
+ /** Where the organization is: a point, an H3 cell, an address or a place record, each bare entry a site of the org (its office, its storefront, a place it runs). A `pub.techne.draft.locationEntry` says something other than "is at": `serves` for a service area, `registered` for where a registry lists it (a nonprofit's filing city or ZIP area, never the street address). Never a mailing address: a registry's address is often an organizer's home, so it is not published. Its query document reads the entries as `sites`: each is its own location. With a `pub.techne.draft.statement` about the org carrying `locations` (a site the org's author did not state), this replaces `pub.techne.draft.orgAtPlace`. */
30
30
  locations?: ($Typed<CommunityLexiconLocationGeo.Main> | $Typed<CommunityLexiconLocationHthree.Main> | $Typed<CommunityLexiconLocationAddress.Main> | $Typed<ComAtprotoRepoStrongRef.Main> | $Typed<PubTechneDraftLocationEntry.Main> | {
31
31
  $type: string;
32
32
  })[];
@@ -55,7 +55,7 @@ export interface Fields {
55
55
  url?: string;
56
56
  /** Public phone number, E.164. */
57
57
  phone?: string;
58
- /** Where the organization is: a point, an H3 cell, an address or a place record, each bare entry a site of the org (its office, its storefront, a place it runs). A `pub.techne.draft.locationEntry` says something other than "is at": `serves` for a service area, `registered` for where a registry lists it (a nonprofit's filing city or ZIP area, never the street address). Never a mailing address: a registry's address is often an organizer's home, so it is not published. Its query document reads the entries as `sites`: each is its own location. This replaces `pub.techne.draft.orgAtPlace`. */
58
+ /** Where the organization is: a point, an H3 cell, an address or a place record, each bare entry a site of the org (its office, its storefront, a place it runs). A `pub.techne.draft.locationEntry` says something other than "is at": `serves` for a service area, `registered` for where a registry lists it (a nonprofit's filing city or ZIP area, never the street address). Never a mailing address: a registry's address is often an organizer's home, so it is not published. Its query document reads the entries as `sites`: each is its own location. With a `pub.techne.draft.statement` about the org carrying `locations` (a site the org's author did not state), this replaces `pub.techne.draft.orgAtPlace`. */
59
59
  locations?: ($Typed<CommunityLexiconLocationGeo.Main> | $Typed<CommunityLexiconLocationHthree.Main> | $Typed<CommunityLexiconLocationAddress.Main> | $Typed<ComAtprotoRepoStrongRef.Main> | $Typed<PubTechneDraftLocationEntry.Main> | {
60
60
  $type: string;
61
61
  })[];
@@ -21,7 +21,7 @@ export interface Main {
21
21
  export declare function isMain<V>(v: V): v is import("../../../../util.js").$TypedObject<V, "pub.techne.draft.statement", "main">;
22
22
  export declare function validateMain<V>(v: V): ValidationResult<Main & V>;
23
23
  export { type Main as Record, isMain as isRecord, validateMain as validateRecord, };
24
- /** Where the subject is, as the writer of the statement says, for a subject of any type. It counts only as the view decides: the subject's own locations win, and a statement fills in only where the subject states no location of that kind, or (with `basis`) gives a position to a subject's entry that has none. A statement the subject's own author writes counts as the subject's own locations. A `basis` equal to the subject record's CID (a legacy claim) counts for any own entry of that kind with no position, while the subject is still that version. When several claims compete for one slot (the same kind, and the same `basis` or none), one counts: the finest grain wins, then the newest, then the lowest source URI; the others are conflicts. On a type whose query document reads its entries as sites (`entries: sites`, as on an org), a claim entry that names no own entry (no `basis`, or a legacy `basis` while the subject states no location of that kind) is its own site: it counts beside every other such entry and competes with none. A claim that names an own entry still competes for that entry, and a subject that states a location of that kind still bars a claim with no `basis`. Read as written, every writer's claim is weighed; curated, only the subject's author's and those of writers the commons root endorses. */
24
+ /** Where the subject is, as the writer of the statement says, for a subject of any type. It counts only as the view decides: the subject's own locations win, and a statement fills in only where the subject states no location of that kind, or (with `basis`) gives a position to a subject's entry that has none. A statement the subject's own author writes counts as the subject's own locations. A `basis` equal to the subject record's CID (a legacy claim) counts for any own entry of that kind with no position, while the subject is still that version. When several claims compete for one slot (the same kind, and the same `basis` or none), one counts: the finest grain wins, then the newest, then the lowest source URI; the others are conflicts. On a type whose query document reads its entries as sites (`entries: sites`, as on an org), a claim entry that names no own entry (no `basis`, or a legacy `basis` while the subject states no location of that kind) is its own site: it counts beside every other such entry and competes with none. A claim that names an own entry still competes for that entry, and a subject that states a location of that kind still bars a claim with no `basis`. Read as written, every writer's claim is weighed; curated, only the subject's author's and those of writers the commons root endorses. The commons curator makes a curated copy of a statement carrying `locations` only when its subject's type reads its entries as sites (an org; never an event or a place) and the statement's author is one the root endorses for statements: the copy is about the curated org and written by the org's curator, so it counts as the org's own locations. */
25
25
  export interface Locations {
26
26
  $type?: 'pub.techne.draft.statement#locations';
27
27
  /** Entries as in the subject's own `locations` field (lexicon naming register). */
@@ -43,7 +43,7 @@ export type QueryNode = {
43
43
  readonly [role: string]: Condition | readonly QueryNode[];
44
44
  };
45
45
  /**
46
- * Which public records a branch reads; every list names one, there is no default (the `view` property of `pub.techne.draft.query` and its `#branch`):
46
+ * Which public records a branch reads; every list names one, and the types require it (the `view` property of `pub.techne.draft.query` and its `#branch`):
47
47
  * - `curated`: the commons' listed records, one curated record per thing (merged from its sources by a curator
48
48
  * the commons root trusts), moderated, not hidden; an event only inside the supported areas. A type no curator
49
49
  * covers is refused with `NotCurated`, naming the type, never answered as an empty list.
@@ -71,7 +71,8 @@ export interface QueryOptions {
71
71
  /** A `pub.techne.draft.query`, as data (the platform validates it). Every branch names its {@link View}: `view`
72
72
  * beside `where` names it for every branch of the `where` (each child of a top-level `any` too), and the `any`
73
73
  * form, `{ any: [{ view, where }, …] }`, one per branch (an app's feed: curated events and its own records as
74
- * written, in one list). A query naming no view is refused with `ViewRequired`. */
74
+ * written, in one list). The platform answers a query naming no view the way it did before views through
75
+ * 2027-03-01 (UTC) and refuses it with `ViewRequired` from 2027-03-02. */
75
76
  export type Query = QueryOptions & ({
76
77
  readonly view: View;
77
78
  readonly where: QueryNode;
@@ -39,8 +39,8 @@ export interface FinishPhoneSignInOptions extends PhoneSignInOptions {
39
39
  /**
40
40
  * Step 1: ask the door for its endpoints, make the DPoP key and the PKCE pair, and start the sign-in (the
41
41
  * platform texts the code). Rejects with the platform's refusal as an {@link OwnSessionError}:
42
- * `OwnSessionUnavailable` (sign in the old way: the door is off, or a review number), `RateLimitExceeded`
43
- * (`retryAfter`), `InvalidRequest`.
42
+ * `Unavailable` (no code could be sent: try again; an older platform says `OwnSessionUnavailable`),
43
+ * `RateLimitExceeded` (`retryAfter`), `InvalidRequest`.
44
44
  */
45
45
  export declare function startPhoneSignIn(o: PhoneSignInOptions & {
46
46
  phone: string;
@@ -50,10 +50,11 @@ export declare function startPhoneSignIn(o: PhoneSignInOptions & {
50
50
  * platform uses only if a check refuses the sign-in) are signed with the latest nonce; a `UseDpopNonce`
51
51
  * answer with a new nonce is signed again and sent with the same code (the platform has not spent it), up to
52
52
  * twice (the code step and the token step may each ask). `pending.dpopNonce` keeps the latest nonce, so a
53
- * retry by the app signs with it. Answers the session to save ({@link OwnSession.signedIn}) and whether the
54
- * number's account was just made. Rejects with the platform's refusal: `InvalidRequest` (wrong code: try
55
- * again), `CodeExpired` (start again), `NewCodeSent`, `MethodFrozen`, `OwnSessionUnavailable`,
56
- * `RateLimitExceeded`, `Unavailable`.
53
+ * retry by the app signs with it. Answers the session to save ({@link OwnSession.signedIn}) and `created`: the
54
+ * platform records the account for the first time (normally a new number; the app asks for a name next).
55
+ * Rejects with the platform's refusal: `InvalidRequest` (wrong code: try again), `CodeExpired` (start again),
56
+ * `MethodFrozen`, `AccountUnavailable` (the number can't sign in here), `NumberRemoved` (sign in with the
57
+ * current number), `RateLimitExceeded`, `Unavailable`.
57
58
  */
58
59
  export declare function finishPhoneSignIn(pending: PendingPhoneSignIn, code: string, o: FinishPhoneSignInOptions): Promise<{
59
60
  session: OwnSessionData;
@@ -27,8 +27,8 @@ function ownAnswer(nsid, own) {
27
27
  /**
28
28
  * Step 1: ask the door for its endpoints, make the DPoP key and the PKCE pair, and start the sign-in (the
29
29
  * platform texts the code). Rejects with the platform's refusal as an {@link OwnSessionError}:
30
- * `OwnSessionUnavailable` (sign in the old way: the door is off, or a review number), `RateLimitExceeded`
31
- * (`retryAfter`), `InvalidRequest`.
30
+ * `Unavailable` (no code could be sent: try again; an older platform says `OwnSessionUnavailable`),
31
+ * `RateLimitExceeded` (`retryAfter`), `InvalidRequest`.
32
32
  */
33
33
  export async function startPhoneSignIn(o) {
34
34
  const fetch = fetchOr(o.fetch);
@@ -54,10 +54,11 @@ export async function startPhoneSignIn(o) {
54
54
  * platform uses only if a check refuses the sign-in) are signed with the latest nonce; a `UseDpopNonce`
55
55
  * answer with a new nonce is signed again and sent with the same code (the platform has not spent it), up to
56
56
  * twice (the code step and the token step may each ask). `pending.dpopNonce` keeps the latest nonce, so a
57
- * retry by the app signs with it. Answers the session to save ({@link OwnSession.signedIn}) and whether the
58
- * number's account was just made. Rejects with the platform's refusal: `InvalidRequest` (wrong code: try
59
- * again), `CodeExpired` (start again), `NewCodeSent`, `MethodFrozen`, `OwnSessionUnavailable`,
60
- * `RateLimitExceeded`, `Unavailable`.
57
+ * retry by the app signs with it. Answers the session to save ({@link OwnSession.signedIn}) and `created`: the
58
+ * platform records the account for the first time (normally a new number; the app asks for a name next).
59
+ * Rejects with the platform's refusal: `InvalidRequest` (wrong code: try again), `CodeExpired` (start again),
60
+ * `MethodFrozen`, `AccountUnavailable` (the number can't sign in here), `NumberRemoved` (sign in with the
61
+ * current number), `RateLimitExceeded`, `Unavailable`.
61
62
  */
62
63
  export async function finishPhoneSignIn(pending, code, o) {
63
64
  const fetch = fetchOr(o.fetch);
@@ -7,7 +7,7 @@
7
7
  * `SessionEnded` (sign in again), `NetworkError` (no answer), `WrongAccount` (the tokens name another DID),
8
8
  * `InvalidResponse` (an answer without what the lexicon promises). */
9
9
  export declare class OwnSessionError extends Error {
10
- /** The XRPC error name (`UseDpopNonce`, `InvalidGrant`, `OwnSessionUnavailable`, `RateLimitExceeded`, ...) or the SDK's. */
10
+ /** The XRPC error name (`UseDpopNonce`, `InvalidGrant`, `Unavailable`, `RateLimitExceeded`, ...) or the SDK's. */
11
11
  readonly code: string;
12
12
  /** The HTTP status, when there was an answer. */
13
13
  readonly status?: number;
@@ -7,7 +7,7 @@
7
7
  * `SessionEnded` (sign in again), `NetworkError` (no answer), `WrongAccount` (the tokens name another DID),
8
8
  * `InvalidResponse` (an answer without what the lexicon promises). */
9
9
  export class OwnSessionError extends Error {
10
- /** The XRPC error name (`UseDpopNonce`, `InvalidGrant`, `OwnSessionUnavailable`, `RateLimitExceeded`, ...) or the SDK's. */
10
+ /** The XRPC error name (`UseDpopNonce`, `InvalidGrant`, `Unavailable`, `RateLimitExceeded`, ...) or the SDK's. */
11
11
  code;
12
12
  /** The HTTP status, when there was an answer. */
13
13
  status;
@@ -110,7 +110,7 @@ function countryList(languages) {
110
110
  names = new Intl.DisplayNames(languages, { type: 'region' });
111
111
  }
112
112
  catch {
113
- names = null;
113
+ /* no region names: the codes stand in */
114
114
  }
115
115
  const out = getCountries().map((region) => {
116
116
  let name = region;
@@ -118,7 +118,7 @@ function countryList(languages) {
118
118
  name = names?.of(region) || region;
119
119
  }
120
120
  catch {
121
- name = region;
121
+ /* keep the code */
122
122
  }
123
123
  return { region, dial: getCountryCallingCode(region), name, key: fold(name) };
124
124
  });
@@ -133,7 +133,7 @@ function defaultRegion(languages, known) {
133
133
  region = new Intl.Locale(l).maximize().region || '';
134
134
  }
135
135
  catch {
136
- region = '';
136
+ /* not a locale */
137
137
  }
138
138
  if (known.has(region))
139
139
  return region;
@@ -161,14 +161,10 @@ function flagsDrawn(doc) {
161
161
  }
162
162
  return false;
163
163
  }
164
- /** A typed number read under `region` (a number with its own `+` code wins); undefined when it reads as none. */
164
+ /** A typed number read under `region` (a number with its own `+` code wins); undefined when it reads as none.
165
+ * libphonenumber answers undefined for text it cannot parse; it throws only for a non-string or broken metadata. */
165
166
  function parsePhone(typed, region) {
166
- try {
167
- return parsePhoneNumberFromString(typed || '', region);
168
- }
169
- catch {
170
- return undefined;
171
- }
167
+ return parsePhoneNumberFromString(typed, region);
172
168
  }
173
169
  /** A typed number as E.164 under `region`, or null when it cannot be one. */
174
170
  function phoneE164(typed, region) {
@@ -257,7 +253,7 @@ export function mountSignIn(target, options) {
257
253
  stored = doc.defaultView?.localStorage?.getItem(COUNTRY_STORAGE_KEY) ?? null;
258
254
  }
259
255
  catch {
260
- stored = null;
256
+ /* storage blocked */
261
257
  }
262
258
  let current = byRegion.get(stored ?? '') ?? byRegion.get(defaultRegion(languages, new Set(byRegion.keys()))) ?? countries[0];
263
259
  let shown = [];