techne-sdk 0.2.0 → 0.3.1

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 (68) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/README.md +21 -4
  3. package/dist/auth/app-key.d.ts +8 -0
  4. package/dist/auth/app-key.js +95 -0
  5. package/dist/auth/index.d.ts +60 -12
  6. package/dist/auth/index.js +79 -14
  7. package/dist/auth/placement.gen.d.ts +1 -1
  8. package/dist/auth/placement.gen.js +1 -0
  9. package/dist/catalog/catalog.gen.js +2147 -667
  10. package/dist/connect.d.ts +4 -1
  11. package/dist/connect.js +7 -3
  12. package/dist/generated/index.d.ts +61 -0
  13. package/dist/generated/index.js +116 -0
  14. package/dist/generated/lexicons.d.ts +3670 -1430
  15. package/dist/generated/lexicons.js +1228 -33
  16. package/dist/generated/nsid.d.ts +23 -1
  17. package/dist/generated/nsid.js +23 -19
  18. package/dist/generated/nsid.json +23 -19
  19. package/dist/generated/records.d.ts +28 -26
  20. package/dist/generated/types/pub/techne/draft/commons/getVersions.d.ts +3 -3
  21. package/dist/generated/types/pub/techne/draft/commons/runChain.d.ts +1 -1
  22. package/dist/generated/types/pub/techne/draft/permissioned/deleteRecord.d.ts +5 -0
  23. package/dist/generated/types/pub/techne/draft/permissioned/deleteRecord.js +7 -0
  24. package/dist/generated/types/pub/techne/draft/permissioned/getRecord.d.ts +2 -1
  25. package/dist/generated/types/pub/techne/draft/permissioned/listChanges.d.ts +1 -1
  26. package/dist/generated/types/pub/techne/draft/permissioned/putRecord.d.ts +2 -2
  27. package/dist/generated/types/pub/techne/draft/query/composeRecords.d.ts +152 -0
  28. package/dist/generated/types/pub/techne/draft/query/composeRecords.js +55 -0
  29. package/dist/generated/types/pub/techne/draft/query/getRecords.d.ts +1 -1
  30. package/dist/generated/types/pub/techne/draft/query/listRecords.d.ts +0 -4
  31. package/dist/generated/types/pub/techne/draft/query/listRejections.d.ts +2 -2
  32. package/dist/generated/types/pub/techne/draft/registry/blockIndex.d.ts +42 -0
  33. package/dist/generated/types/pub/techne/draft/registry/blockIndex.js +34 -0
  34. package/dist/generated/types/pub/techne/draft/registry/defs.d.ts +112 -0
  35. package/dist/generated/types/pub/techne/draft/registry/defs.js +32 -0
  36. package/dist/generated/types/pub/techne/draft/registry/getType.d.ts +23 -0
  37. package/dist/generated/types/pub/techne/draft/registry/getType.js +20 -0
  38. package/dist/generated/types/pub/techne/draft/registry/getTypeRequest.d.ts +23 -0
  39. package/dist/generated/types/pub/techne/draft/registry/getTypeRequest.js +20 -0
  40. package/dist/generated/types/pub/techne/draft/registry/listTypeRequests.d.ts +27 -0
  41. package/dist/generated/types/pub/techne/draft/registry/listTypeRequests.js +7 -0
  42. package/dist/generated/types/pub/techne/draft/registry/listTypes.d.ts +34 -0
  43. package/dist/generated/types/pub/techne/draft/registry/listTypes.js +7 -0
  44. package/dist/generated/types/pub/techne/draft/registry/publishType.d.ts +77 -0
  45. package/dist/generated/types/pub/techne/draft/registry/publishType.js +83 -0
  46. package/dist/generated/types/pub/techne/draft/registry/purgeType.d.ts +39 -0
  47. package/dist/generated/types/pub/techne/draft/registry/purgeType.js +34 -0
  48. package/dist/generated/types/pub/techne/draft/registry/requestType.d.ts +53 -0
  49. package/dist/generated/types/pub/techne/draft/registry/requestType.js +76 -0
  50. package/dist/generated/types/pub/techne/draft/registry/typeRequest.d.ts +22 -0
  51. package/dist/generated/types/pub/techne/draft/registry/typeRequest.js +12 -0
  52. package/dist/generated/types/pub/techne/draft/sync/indexRecord.d.ts +1 -1
  53. package/dist/generated/types/pub/techne/draft/verdict.d.ts +2 -2
  54. package/dist/put/index.d.ts +5 -1
  55. package/dist/put/index.js +33 -10
  56. package/dist/query/index.d.ts +1 -10
  57. package/dist/query/index.js +1 -1
  58. package/dist/types-cli/emit.d.ts +20 -0
  59. package/dist/types-cli/emit.js +217 -0
  60. package/dist/types-cli/main.d.ts +5 -0
  61. package/dist/types-cli/main.js +63 -0
  62. package/dist/types-cli/resolve.d.ts +26 -0
  63. package/dist/types-cli/resolve.js +99 -0
  64. package/dist/wasm/index.d.ts +6 -1
  65. package/dist/wasm/index.js +6 -1
  66. package/dist/wasm/techne-wasm.gen.js +1 -1
  67. package/dist/wasm/techne-wasm2js.gen.js +19782 -19763
  68. package/package.json +11 -4
@@ -0,0 +1,77 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { HeadersMap, XRPCError } from '@atproto/xrpc';
5
+ import type * as ComAtprotoRepoStrongRef from '../../../../com/atproto/repo/strongRef.js';
6
+ export type QueryParams = {};
7
+ export interface InputSchema {
8
+ /** The type to publish a new version of. Leave it out to create a type. */
9
+ nsid?: string;
10
+ /** For a new type, its name: the NSID's last segment, a letter then letters and digits (`bookClubMeeting`). With `nsid`, a new name under the same id (a second type, or a sidecar, of yours). */
11
+ name?: string;
12
+ /** The lexicon document. Its main def is a record. Its `id` may be left out of a new type (it is filled in); otherwise it must equal the type's NSID. */
13
+ lexicon: {
14
+ [_ in string]: unknown;
15
+ };
16
+ /** The type's `{nsid}.query` document: which fields fill the shared query roles (`start`, `end`, `location`, `text`, `references`, `category`; pub.techne.draft.query#roles). Without it the type's records can only be got and listed. */
17
+ query?: {
18
+ [_ in string]: unknown;
19
+ };
20
+ /** For a new type: the type it extends. Its main record must then have a required `subject` (an at-uri). */
21
+ sidecarOf?: string;
22
+ /** For a new type: the community type it was forked from. */
23
+ forkOf?: string;
24
+ }
25
+ export interface OutputSchema {
26
+ nsid: string;
27
+ version: number;
28
+ schema: ComAtprotoRepoStrongRef.Main;
29
+ /** The type's page on techne.pub. */
30
+ page: string;
31
+ /** Whether this call created the type (false: a new version). */
32
+ created: boolean;
33
+ /** The lexicon and query document equal the current version; nothing was published. */
34
+ unchanged?: boolean;
35
+ }
36
+ export interface CallOptions {
37
+ signal?: AbortSignal;
38
+ headers?: HeadersMap;
39
+ qp?: QueryParams;
40
+ encoding?: 'application/json';
41
+ }
42
+ export interface Response {
43
+ success: boolean;
44
+ headers: HeadersMap;
45
+ data: OutputSchema;
46
+ }
47
+ export declare class AuthenticationRequiredError extends XRPCError {
48
+ constructor(src: XRPCError);
49
+ }
50
+ export declare class InvalidLexiconError extends XRPCError {
51
+ constructor(src: XRPCError);
52
+ }
53
+ export declare class InvalidQueryError extends XRPCError {
54
+ constructor(src: XRPCError);
55
+ }
56
+ export declare class InvalidNameError extends XRPCError {
57
+ constructor(src: XRPCError);
58
+ }
59
+ export declare class NotAdditiveError extends XRPCError {
60
+ constructor(src: XRPCError);
61
+ }
62
+ export declare class NotCreatorError extends XRPCError {
63
+ constructor(src: XRPCError);
64
+ }
65
+ export declare class UnknownTypeError extends XRPCError {
66
+ constructor(src: XRPCError);
67
+ }
68
+ export declare class TooLargeError extends XRPCError {
69
+ constructor(src: XRPCError);
70
+ }
71
+ export declare class NotConfiguredError extends XRPCError {
72
+ constructor(src: XRPCError);
73
+ }
74
+ export declare class RateLimitExceededError extends XRPCError {
75
+ constructor(src: XRPCError);
76
+ }
77
+ export declare function toKnownErr(e: any): any;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { XRPCError } from '@atproto/xrpc';
5
+ import { validate as _validate } from '../../../../../lexicons.js';
6
+ import { is$typed as _is$typed, } from '../../../../../util.js';
7
+ const is$typed = _is$typed, validate = _validate;
8
+ const id = 'pub.techne.draft.registry.publishType';
9
+ export class AuthenticationRequiredError extends XRPCError {
10
+ constructor(src) {
11
+ super(src.status, src.error, src.message, src.headers, { cause: src });
12
+ }
13
+ }
14
+ export class InvalidLexiconError extends XRPCError {
15
+ constructor(src) {
16
+ super(src.status, src.error, src.message, src.headers, { cause: src });
17
+ }
18
+ }
19
+ export class InvalidQueryError extends XRPCError {
20
+ constructor(src) {
21
+ super(src.status, src.error, src.message, src.headers, { cause: src });
22
+ }
23
+ }
24
+ export class InvalidNameError extends XRPCError {
25
+ constructor(src) {
26
+ super(src.status, src.error, src.message, src.headers, { cause: src });
27
+ }
28
+ }
29
+ export class NotAdditiveError extends XRPCError {
30
+ constructor(src) {
31
+ super(src.status, src.error, src.message, src.headers, { cause: src });
32
+ }
33
+ }
34
+ export class NotCreatorError extends XRPCError {
35
+ constructor(src) {
36
+ super(src.status, src.error, src.message, src.headers, { cause: src });
37
+ }
38
+ }
39
+ export class UnknownTypeError extends XRPCError {
40
+ constructor(src) {
41
+ super(src.status, src.error, src.message, src.headers, { cause: src });
42
+ }
43
+ }
44
+ export class TooLargeError extends XRPCError {
45
+ constructor(src) {
46
+ super(src.status, src.error, src.message, src.headers, { cause: src });
47
+ }
48
+ }
49
+ export class NotConfiguredError extends XRPCError {
50
+ constructor(src) {
51
+ super(src.status, src.error, src.message, src.headers, { cause: src });
52
+ }
53
+ }
54
+ export class RateLimitExceededError extends XRPCError {
55
+ constructor(src) {
56
+ super(src.status, src.error, src.message, src.headers, { cause: src });
57
+ }
58
+ }
59
+ export function toKnownErr(e) {
60
+ if (e instanceof XRPCError) {
61
+ if (e.error === 'AuthenticationRequired')
62
+ return new AuthenticationRequiredError(e);
63
+ if (e.error === 'InvalidLexicon')
64
+ return new InvalidLexiconError(e);
65
+ if (e.error === 'InvalidQuery')
66
+ return new InvalidQueryError(e);
67
+ if (e.error === 'InvalidName')
68
+ return new InvalidNameError(e);
69
+ if (e.error === 'NotAdditive')
70
+ return new NotAdditiveError(e);
71
+ if (e.error === 'NotCreator')
72
+ return new NotCreatorError(e);
73
+ if (e.error === 'UnknownType')
74
+ return new UnknownTypeError(e);
75
+ if (e.error === 'TooLarge')
76
+ return new TooLargeError(e);
77
+ if (e.error === 'NotConfigured')
78
+ return new NotConfiguredError(e);
79
+ if (e.error === 'RateLimitExceeded')
80
+ return new RateLimitExceededError(e);
81
+ }
82
+ return e;
83
+ }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { HeadersMap, XRPCError } from '@atproto/xrpc';
5
+ export type QueryParams = {};
6
+ export interface InputSchema {
7
+ /** The runtime type (a community draft or a requested type). */
8
+ nsid: string;
9
+ /** Why, kept with the block. */
10
+ reason: string;
11
+ }
12
+ export interface OutputSchema {
13
+ nsid: string;
14
+ /** How many indexed records were removed. */
15
+ purged: number;
16
+ /** The type's page on techne.pub. */
17
+ page: string;
18
+ }
19
+ export interface CallOptions {
20
+ signal?: AbortSignal;
21
+ headers?: HeadersMap;
22
+ qp?: QueryParams;
23
+ encoding?: 'application/json';
24
+ }
25
+ export interface Response {
26
+ success: boolean;
27
+ headers: HeadersMap;
28
+ data: OutputSchema;
29
+ }
30
+ export declare class AuthenticationRequiredError extends XRPCError {
31
+ constructor(src: XRPCError);
32
+ }
33
+ export declare class ForbiddenError extends XRPCError {
34
+ constructor(src: XRPCError);
35
+ }
36
+ export declare class UnknownTypeError extends XRPCError {
37
+ constructor(src: XRPCError);
38
+ }
39
+ export declare function toKnownErr(e: any): any;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { XRPCError } from '@atproto/xrpc';
5
+ import { validate as _validate } from '../../../../../lexicons.js';
6
+ import { is$typed as _is$typed, } from '../../../../../util.js';
7
+ const is$typed = _is$typed, validate = _validate;
8
+ const id = 'pub.techne.draft.registry.purgeType';
9
+ export class AuthenticationRequiredError extends XRPCError {
10
+ constructor(src) {
11
+ super(src.status, src.error, src.message, src.headers, { cause: src });
12
+ }
13
+ }
14
+ export class ForbiddenError extends XRPCError {
15
+ constructor(src) {
16
+ super(src.status, src.error, src.message, src.headers, { cause: src });
17
+ }
18
+ }
19
+ export class UnknownTypeError extends XRPCError {
20
+ constructor(src) {
21
+ super(src.status, src.error, src.message, src.headers, { cause: src });
22
+ }
23
+ }
24
+ export function toKnownErr(e) {
25
+ if (e instanceof XRPCError) {
26
+ if (e.error === 'AuthenticationRequired')
27
+ return new AuthenticationRequiredError(e);
28
+ if (e.error === 'Forbidden')
29
+ return new ForbiddenError(e);
30
+ if (e.error === 'UnknownType')
31
+ return new UnknownTypeError(e);
32
+ }
33
+ return e;
34
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { HeadersMap, XRPCError } from '@atproto/xrpc';
5
+ import type * as PubTechneDraftRegistryDefs from './defs.js';
6
+ export type QueryParams = {};
7
+ export interface InputSchema {
8
+ nsid: string;
9
+ /** Which of the type's fields fill the shared query roles, as a `{nsid}.query` document (pub.techne.draft.query#roles). Without it the type's records can only be got and listed. */
10
+ query?: {
11
+ [_ in string]: unknown;
12
+ };
13
+ }
14
+ export type OutputSchema = PubTechneDraftRegistryDefs.RequestView;
15
+ export interface CallOptions {
16
+ signal?: AbortSignal;
17
+ headers?: HeadersMap;
18
+ qp?: QueryParams;
19
+ encoding?: 'application/json';
20
+ }
21
+ export interface Response {
22
+ success: boolean;
23
+ headers: HeadersMap;
24
+ data: OutputSchema;
25
+ }
26
+ export declare class AuthenticationRequiredError extends XRPCError {
27
+ constructor(src: XRPCError);
28
+ }
29
+ export declare class NoSchemaError extends XRPCError {
30
+ constructor(src: XRPCError);
31
+ }
32
+ export declare class InvalidLexiconError extends XRPCError {
33
+ constructor(src: XRPCError);
34
+ }
35
+ export declare class InvalidQueryError extends XRPCError {
36
+ constructor(src: XRPCError);
37
+ }
38
+ export declare class AlreadyIndexedError extends XRPCError {
39
+ constructor(src: XRPCError);
40
+ }
41
+ export declare class InvalidRequestError extends XRPCError {
42
+ constructor(src: XRPCError);
43
+ }
44
+ export declare class TooLargeError extends XRPCError {
45
+ constructor(src: XRPCError);
46
+ }
47
+ export declare class NotConfiguredError extends XRPCError {
48
+ constructor(src: XRPCError);
49
+ }
50
+ export declare class RateLimitExceededError extends XRPCError {
51
+ constructor(src: XRPCError);
52
+ }
53
+ export declare function toKnownErr(e: any): any;
@@ -0,0 +1,76 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { XRPCError } from '@atproto/xrpc';
5
+ import { validate as _validate } from '../../../../../lexicons.js';
6
+ import { is$typed as _is$typed, } from '../../../../../util.js';
7
+ const is$typed = _is$typed, validate = _validate;
8
+ const id = 'pub.techne.draft.registry.requestType';
9
+ export class AuthenticationRequiredError extends XRPCError {
10
+ constructor(src) {
11
+ super(src.status, src.error, src.message, src.headers, { cause: src });
12
+ }
13
+ }
14
+ export class NoSchemaError extends XRPCError {
15
+ constructor(src) {
16
+ super(src.status, src.error, src.message, src.headers, { cause: src });
17
+ }
18
+ }
19
+ export class InvalidLexiconError extends XRPCError {
20
+ constructor(src) {
21
+ super(src.status, src.error, src.message, src.headers, { cause: src });
22
+ }
23
+ }
24
+ export class InvalidQueryError extends XRPCError {
25
+ constructor(src) {
26
+ super(src.status, src.error, src.message, src.headers, { cause: src });
27
+ }
28
+ }
29
+ export class AlreadyIndexedError extends XRPCError {
30
+ constructor(src) {
31
+ super(src.status, src.error, src.message, src.headers, { cause: src });
32
+ }
33
+ }
34
+ export class InvalidRequestError extends XRPCError {
35
+ constructor(src) {
36
+ super(src.status, src.error, src.message, src.headers, { cause: src });
37
+ }
38
+ }
39
+ export class TooLargeError extends XRPCError {
40
+ constructor(src) {
41
+ super(src.status, src.error, src.message, src.headers, { cause: src });
42
+ }
43
+ }
44
+ export class NotConfiguredError extends XRPCError {
45
+ constructor(src) {
46
+ super(src.status, src.error, src.message, src.headers, { cause: src });
47
+ }
48
+ }
49
+ export class RateLimitExceededError extends XRPCError {
50
+ constructor(src) {
51
+ super(src.status, src.error, src.message, src.headers, { cause: src });
52
+ }
53
+ }
54
+ export function toKnownErr(e) {
55
+ if (e instanceof XRPCError) {
56
+ if (e.error === 'AuthenticationRequired')
57
+ return new AuthenticationRequiredError(e);
58
+ if (e.error === 'NoSchema')
59
+ return new NoSchemaError(e);
60
+ if (e.error === 'InvalidLexicon')
61
+ return new InvalidLexiconError(e);
62
+ if (e.error === 'InvalidQuery')
63
+ return new InvalidQueryError(e);
64
+ if (e.error === 'AlreadyIndexed')
65
+ return new AlreadyIndexedError(e);
66
+ if (e.error === 'InvalidRequest')
67
+ return new InvalidRequestError(e);
68
+ if (e.error === 'TooLarge')
69
+ return new TooLargeError(e);
70
+ if (e.error === 'NotConfigured')
71
+ return new NotConfiguredError(e);
72
+ if (e.error === 'RateLimitExceeded')
73
+ return new RateLimitExceededError(e);
74
+ }
75
+ return e;
76
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * GENERATED CODE - DO NOT MODIFY
3
+ */
4
+ import { type ValidationResult } from '@atproto/lexicon';
5
+ import type * as ComAtprotoRepoStrongRef from '../../../../com/atproto/repo/strongRef.js';
6
+ export interface Main {
7
+ $type: 'pub.techne.draft.registry.typeRequest';
8
+ /** The requested type; equal to the record key. */
9
+ nsid: string;
10
+ /** Who asked. */
11
+ requester: string;
12
+ schema: ComAtprotoRepoStrongRef.Main;
13
+ /** Which of the type's fields fill the shared query roles, as a `{nsid}.query` document (pub.techne.draft.query#roles). Without it the type's records can only be got and listed. */
14
+ query?: {
15
+ [_ in string]: unknown;
16
+ };
17
+ createdAt: string;
18
+ [k: string]: unknown;
19
+ }
20
+ export declare function isMain<V>(v: V): v is import("../../../../../util.js").$TypedObject<V, "pub.techne.draft.registry.typeRequest", "main">;
21
+ export declare function validateMain<V>(v: V): ValidationResult<Main & V>;
22
+ 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.registry.typeRequest';
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, };
@@ -11,7 +11,7 @@ export interface OutputSchema {
11
11
  uri: string;
12
12
  /** The version the platform fetched and verified: the version the decision is about. */
13
13
  cid: string;
14
- /** Whether this version counts. valid: it does. pending: nothing is wrong, but a claim it needs has not arrived yet (its author's membership, the root's credential for its author); a later read may say valid. invalid: it does not count, for the reason given (it is still in the author's repo; a version the platform refuses to index, such as one that is not valid for its lexicon, is not put on the stream). A curated version of the record, if a rule writes one, is another record. */
14
+ /** Whether this version counts. valid: it does. pending: nothing is wrong, but a claim it needs has not arrived yet (its author's membership, an admin writer's credential for its author: the root's, or an operator's the root names); a later read may say valid. invalid: it does not count, for the reason given (it is still in the author's repo; a version the platform refuses to index, such as one that is not valid for its lexicon, is not put on the stream). A curated version of the record, if a rule writes one, is another record. */
15
15
  decision: 'valid' | 'pending' | 'invalid' | (string & {});
16
16
  /** Why, when decision is invalid: the lexicon problems, no public home, no lexicon for the collection, or the provenance or trust rule it fails. */
17
17
  reason?: string;
@@ -6,8 +6,8 @@ import type * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongR
6
6
  export interface Main {
7
7
  $type: 'pub.techne.draft.verdict';
8
8
  subject: ComAtprotoRepoStrongRef.Main;
9
- /** What the version is. `spam`: advertising, scams, link farms or bulk promotion rather than a real gathering. `obscene`: sexually explicit or gratuitously graphic content. `!takedown`: an operator took the record down; it hides the record at every version. */
10
- values: ('spam' | 'obscene' | '!takedown' | (string & {}))[];
9
+ /** What the version is. `spam`: advertising, scams, link farms or bulk promotion rather than a real gathering. `obscene`: sexually explicit or gratuitously graphic content. `!takedown`: an operator took the record down; it hides the record at every version. `declined`: an operator declined a pub.techne.draft.registry.typeRequest at this version; it hides nothing. */
10
+ values: ('spam' | 'obscene' | '!takedown' | 'declined' | (string & {}))[];
11
11
  createdAt: string;
12
12
  [k: string]: unknown;
13
13
  }
@@ -13,7 +13,11 @@ export interface PutRecord {
13
13
  record: AnyRecord;
14
14
  /** Its record key; derived when absent (see the module doc). */
15
15
  rkey?: string;
16
- /** The space it is placed in (`at://{authority}/{spaceType}/{skey}`); a record with a space is private. */
16
+ /**
17
+ * The space it is placed in (`at://{authority}/{spaceType}/{skey}`); a record with a space is private.
18
+ * Required for a private record (a lexicon type with no public home): a record only you read goes in
19
+ * your own `space.personal`. A public record names none.
20
+ */
17
21
  space?: string;
18
22
  }
19
23
  /** One write, as planned. */
package/dist/put/index.js CHANGED
@@ -8,13 +8,18 @@
8
8
  * order: private records (a `space` named, or a lexicon type with no public home) first, public last;
9
9
  * a type the platform has no lexicon for (another app's own record) is public: it goes to the user's
10
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;
11
+ * the platform's own namespace (a typo after it, an old name, other letter case) stays private instead
12
+ * (a community draft, `pub.techne.draft.c.*`, is not the platform's: public, like another app's type);
12
13
  * 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
+ * through the user's PDS) and stops if any is refused. Every private record names its `space`: one
15
+ * that names none throws {@link PutError} (`InvalidRequest`) with nothing written, as the platform
16
+ * refuses it. A record only the user reads goes in their own `space.personal`
17
+ * (`at://{did}/pub.techne.draft.space.personal/self`);
14
18
  * 3. writes the public ones to the user's PDS in one atomic `com.atproto.repo.applyWrites`;
15
19
  * 4. with `deletes`: deletes the private ones, one `permissioned.deleteRecord` each (below);
16
20
  * 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.
21
+ * indexes it ahead of the relay, and answers what the platform said; and hints each public delete
22
+ * the PDS carried out, so the platform reads the PDS's proof that the record is gone and drops it.
18
23
  *
19
24
  * `put(techne, records, { deletes })` also deletes, in the same plan: a delete is private or public by
20
25
  * the same rule as a write (a `space` named, or a lexicon type with no public home, is private; a type
@@ -22,8 +27,11 @@
22
27
  * public deletes go into the same atomic `applyWrites` as the public writes (step 3); the private ones
23
28
  * go out after it (step 4), so nothing public is left pointing at a private record already gone. A
24
29
  * 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
30
+ * named without it), and each delete answers `deleted`: whether anything was there to delete. Each
31
+ * public delete the PDS carried out is hinted too (`sync.indexRecord` of its URI): the platform asks the
32
+ * PDS, finds the record gone and drops it from the index, even for a type the relay does not bring it
33
+ * (a community or requested type not yet approved). A failed delete hint is ignored: the relay's delete,
34
+ * where it comes, does the same. A key
27
35
  * may not be both written and deleted, or deleted twice, in one put, and only the writer's own records
28
36
  * (by DID) can be deleted. A contact deleted in the same put no longer counts for the contact check.
29
37
  *
@@ -58,6 +66,11 @@ import { call } from '../wasm/index.js';
58
66
  import { contactConflicts, ContactConflictError, storedContacts } from './contacts.js';
59
67
  import { getRecordsAnswer } from '../query/index.js';
60
68
  export { contactConflicts, ContactConflictError } from './contacts.js';
69
+ /** Why a private record with no space is not written (lucian 2026-11-09): the platform's private write
70
+ * needs a space, as `permissioned.putRecords` refuses a write that names none. */
71
+ function noSpace(did, collection) {
72
+ return `names no space. ${collection} is written privately, so name the space it is for: a record only you read goes in your own space.personal (at://${did}/${NSID.SPACE_PERSONAL}/self). Public records are written with com.atproto.repo.putRecord.`;
73
+ }
61
74
  /** A put whose private batch write refused some records: nothing public was written. */
62
75
  export class PutError extends Error {
63
76
  refused;
@@ -87,6 +100,9 @@ export async function put(techne, records, options = {}) {
87
100
  const privates = writes.filter((w) => w.private);
88
101
  const publics = writes.filter((w) => !w.private);
89
102
  const publicDeletes = deletes.filter((d) => !d.private);
103
+ const unplaced = privates.filter((w) => !w.space);
104
+ if (unplaced.length)
105
+ throw new PutError(unplaced.map((w) => ({ uri: w.uri, error: 'InvalidRequest', message: noSpace(did, w.collection) })));
90
106
  const contacts = writes.filter((w) => w.collection === NSID.CONTACT);
91
107
  if (contacts.length) {
92
108
  const gone = new Set(deletes.map((d) => d.uri));
@@ -97,13 +113,16 @@ export async function put(techne, records, options = {}) {
97
113
  if (privates.length) {
98
114
  const { data } = await techne.platform.pub.techne.draft.permissioned.putRecords({
99
115
  repo: did,
100
- writes: privates.map(({ collection, rkey, record, space }) => ({ collection, rkey, record, space })),
116
+ // Every private write names its space (checked above).
117
+ writes: privates.map(({ collection, rkey, record, space }) => ({ collection, rkey, record, space: space })),
101
118
  });
102
119
  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
120
  if (refused.length)
104
121
  throw new PutError(refused);
105
122
  }
106
123
  const done = new Map();
124
+ // The public deletes the PDS carried out in the applyWrites, hinted after (step 5).
125
+ const pdsDeleted = [];
107
126
  if (publics.length || publicDeletes.length) {
108
127
  const current = await Promise.all(publics.map((w) => currentCid(techne, w)));
109
128
  const ops = publics.flatMap((w, i) => current[i] === w.cid
@@ -117,9 +136,12 @@ export async function put(techne, records, options = {}) {
117
136
  }
118
137
  if (ops.length)
119
138
  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);
139
+ for (const [i, d] of publicDeletes.entries()) {
140
+ if (!held[i])
141
+ continue;
142
+ done.set(d.uri, true);
143
+ pdsDeleted.push(d.uri);
144
+ }
123
145
  }
124
146
  // Private deletes after the public leg: nothing public is left pointing at what they remove. A public
125
147
  // delete the PDS did not hold goes here too: a record of that collection kept in a space, named
@@ -131,7 +153,8 @@ export async function put(techne, records, options = {}) {
131
153
  done.set(d.uri, Boolean(data.rev));
132
154
  }
133
155
  const answers = new Map();
134
- await Promise.all(publics.map(async (w) => answers.set(w, await hint(techne, w.uri))));
156
+ // The public deletes are hinted beside the writes; their answer is not kept (a failed hint is ignored).
157
+ await Promise.all([...publics.map(async (w) => answers.set(w, await hint(techne, w.uri))), ...pdsDeleted.map((uri) => hint(techne, uri))]);
135
158
  const curatable = publics.filter((w) => w.lexicon);
136
159
  const counted = (curatable.length ? curatable : publics).map((w) => answers.get(w));
137
160
  const status = counted.find((a) => a.decision === 'invalid') ?? { decision: 'pending' };
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * A read is a `pub.techne.draft.query`: a `where` tree over shared roles (`type`, `author`, `subject`,
5
5
  * `space`, `uri`, `written`, and what each type's query document declares: `start`, `end`, `location`,
6
- * `text`, `references`), one `order`, `include` and `signals`. The platform scopes every query to what the
6
+ * `text`, `references`), one `order` and `signals`. The platform scopes every query to what the
7
7
  * viewer may read and proves it bounded; this module only carries it: `listRecords` (one page),
8
8
  * `listAllRecords` (every page), `countRecords`, and `getRecords` (by URI, in batches the platform takes; `getRecordsAnswer` also says which
9
9
  * asked URIs moderation withheld).
@@ -33,10 +33,6 @@ export interface Query {
33
33
  readonly where: QueryNode;
34
34
  readonly order?: string;
35
35
  readonly limit?: number;
36
- readonly include?: {
37
- readonly author?: 'profile';
38
- readonly subject?: 'record';
39
- };
40
36
  readonly signals?: readonly Readonly<Record<string, unknown>>[];
41
37
  readonly curated?: boolean;
42
38
  /** The seed of `order: 'shuffle'`, a literal or a parameter (`$seed`); required with it. */
@@ -65,11 +61,6 @@ export interface QueryRecord<V = Record<string, unknown>> {
65
61
  /** The numbers the query's operators produced, by name (a `near` distance in metres). */
66
62
  measures?: Record<string, number>;
67
63
  signals?: Record<string, number>;
68
- /** The records `include` attached: the author's profile, the subject's record. */
69
- included?: {
70
- author?: QueryRecord;
71
- subject?: QueryRecord;
72
- };
73
64
  }
74
65
  export interface ListPage<V = Record<string, unknown>> {
75
66
  records: QueryRecord<V>[];
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * A read is a `pub.techne.draft.query`: a `where` tree over shared roles (`type`, `author`, `subject`,
5
5
  * `space`, `uri`, `written`, and what each type's query document declares: `start`, `end`, `location`,
6
- * `text`, `references`), one `order`, `include` and `signals`. The platform scopes every query to what the
6
+ * `text`, `references`), one `order` and `signals`. The platform scopes every query to what the
7
7
  * viewer may read and proves it bounded; this module only carries it: `listRecords` (one page),
8
8
  * `listAllRecords` (every page), `countRecords`, and `getRecords` (by URI, in batches the platform takes; `getRecordsAnswer` also says which
9
9
  * asked URIs moderation withheld).
@@ -0,0 +1,20 @@
1
+ /**
2
+ * A lexicon document, as `registry.getType` or a `com.atproto.lexicon.schema` record carries it: only what
3
+ * {@link isLexiconDoc} checks. Not @atproto/lexicon's LexiconDoc: its parseLexiconDoc refuses documents this
4
+ * emitter reads on purpose (an inline object property, a non-main method def), and each def here is read
5
+ * field by field and checked as it is emitted.
6
+ */
7
+ export interface LexiconDoc {
8
+ lexicon: number;
9
+ id: string;
10
+ description?: string;
11
+ defs: Record<string, unknown>;
12
+ }
13
+ /** Whether `v` has a lexicon document's shape: a numeric `lexicon`, a string `id` and an object `defs`. */
14
+ export declare function isLexiconDoc(v: unknown): v is LexiconDoc;
15
+ /** The exported name of one def of `nsid`. */
16
+ export declare function defName(nsid: string, def: string): string;
17
+ /** TypeScript for every def of `lexicon`, `main` first. `source` goes in the header (where it came from). */
18
+ export declare function emitTypes(lexicon: LexiconDoc, options?: {
19
+ source?: string;
20
+ }): string;