@atproto/lex-client 0.3.6 → 0.4.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 (135) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +4 -3
  3. package/dist/client.d.ts +4 -11
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +6 -12
  6. package/dist/client.js.map +1 -1
  7. package/dist/index.d.ts +2 -5
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +2 -5
  10. package/dist/index.js.map +1 -1
  11. package/dist/lexicons/com/atproto/repo/applyWrites.d.ts +2 -2
  12. package/dist/lexicons/com/atproto/repo/applyWrites.d.ts.map +1 -1
  13. package/dist/lexicons/com/atproto/repo/applyWrites.defs.d.ts +23 -23
  14. package/dist/lexicons/com/atproto/repo/applyWrites.defs.d.ts.map +1 -1
  15. package/dist/lexicons/com/atproto/repo/applyWrites.defs.js +13 -64
  16. package/dist/lexicons/com/atproto/repo/applyWrites.defs.js.map +1 -1
  17. package/dist/lexicons/com/atproto/repo/applyWrites.js +2 -2
  18. package/dist/lexicons/com/atproto/repo/applyWrites.js.map +1 -1
  19. package/dist/lexicons/com/atproto/repo/createRecord.d.ts +2 -2
  20. package/dist/lexicons/com/atproto/repo/createRecord.d.ts.map +1 -1
  21. package/dist/lexicons/com/atproto/repo/createRecord.defs.d.ts +2 -2
  22. package/dist/lexicons/com/atproto/repo/createRecord.defs.d.ts.map +1 -1
  23. package/dist/lexicons/com/atproto/repo/createRecord.defs.js +6 -24
  24. package/dist/lexicons/com/atproto/repo/createRecord.defs.js.map +1 -1
  25. package/dist/lexicons/com/atproto/repo/createRecord.js +2 -2
  26. package/dist/lexicons/com/atproto/repo/createRecord.js.map +1 -1
  27. package/dist/lexicons/com/atproto/repo/defs.d.ts +1 -1
  28. package/dist/lexicons/com/atproto/repo/defs.d.ts.map +1 -1
  29. package/dist/lexicons/com/atproto/repo/defs.defs.d.ts +4 -4
  30. package/dist/lexicons/com/atproto/repo/defs.defs.d.ts.map +1 -1
  31. package/dist/lexicons/com/atproto/repo/defs.defs.js +3 -7
  32. package/dist/lexicons/com/atproto/repo/defs.defs.js.map +1 -1
  33. package/dist/lexicons/com/atproto/repo/defs.js +1 -1
  34. package/dist/lexicons/com/atproto/repo/defs.js.map +1 -1
  35. package/dist/lexicons/com/atproto/repo/deleteRecord.d.ts +2 -2
  36. package/dist/lexicons/com/atproto/repo/deleteRecord.d.ts.map +1 -1
  37. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.d.ts +2 -2
  38. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.d.ts.map +1 -1
  39. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.js +6 -19
  40. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.js.map +1 -1
  41. package/dist/lexicons/com/atproto/repo/deleteRecord.js +2 -2
  42. package/dist/lexicons/com/atproto/repo/deleteRecord.js.map +1 -1
  43. package/dist/lexicons/com/atproto/repo/getRecord.d.ts +2 -2
  44. package/dist/lexicons/com/atproto/repo/getRecord.d.ts.map +1 -1
  45. package/dist/lexicons/com/atproto/repo/getRecord.defs.d.ts +1 -1
  46. package/dist/lexicons/com/atproto/repo/getRecord.defs.d.ts.map +1 -1
  47. package/dist/lexicons/com/atproto/repo/getRecord.defs.js +5 -14
  48. package/dist/lexicons/com/atproto/repo/getRecord.defs.js.map +1 -1
  49. package/dist/lexicons/com/atproto/repo/getRecord.js +2 -2
  50. package/dist/lexicons/com/atproto/repo/getRecord.js.map +1 -1
  51. package/dist/lexicons/com/atproto/repo/listRecords.d.ts +2 -2
  52. package/dist/lexicons/com/atproto/repo/listRecords.d.ts.map +1 -1
  53. package/dist/lexicons/com/atproto/repo/listRecords.defs.d.ts +5 -5
  54. package/dist/lexicons/com/atproto/repo/listRecords.defs.d.ts.map +1 -1
  55. package/dist/lexicons/com/atproto/repo/listRecords.defs.js +5 -22
  56. package/dist/lexicons/com/atproto/repo/listRecords.defs.js.map +1 -1
  57. package/dist/lexicons/com/atproto/repo/listRecords.js +2 -2
  58. package/dist/lexicons/com/atproto/repo/listRecords.js.map +1 -1
  59. package/dist/lexicons/com/atproto/repo/putRecord.d.ts +2 -2
  60. package/dist/lexicons/com/atproto/repo/putRecord.d.ts.map +1 -1
  61. package/dist/lexicons/com/atproto/repo/putRecord.defs.d.ts +2 -2
  62. package/dist/lexicons/com/atproto/repo/putRecord.defs.d.ts.map +1 -1
  63. package/dist/lexicons/com/atproto/repo/putRecord.defs.js +6 -25
  64. package/dist/lexicons/com/atproto/repo/putRecord.defs.js.map +1 -1
  65. package/dist/lexicons/com/atproto/repo/putRecord.js +2 -2
  66. package/dist/lexicons/com/atproto/repo/putRecord.js.map +1 -1
  67. package/dist/lexicons/com/atproto/repo/uploadBlob.d.ts +2 -2
  68. package/dist/lexicons/com/atproto/repo/uploadBlob.d.ts.map +1 -1
  69. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.d.ts +1 -1
  70. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.d.ts.map +1 -1
  71. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.js +4 -6
  72. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.js.map +1 -1
  73. package/dist/lexicons/com/atproto/repo/uploadBlob.js +2 -2
  74. package/dist/lexicons/com/atproto/repo/uploadBlob.js.map +1 -1
  75. package/dist/lexicons/com/atproto/repo.d.ts +8 -8
  76. package/dist/lexicons/com/atproto/repo.d.ts.map +1 -1
  77. package/dist/lexicons/com/atproto/repo.js +8 -8
  78. package/dist/lexicons/com/atproto/repo.js.map +1 -1
  79. package/dist/lexicons/com/atproto/sync/getBlob.d.ts +2 -2
  80. package/dist/lexicons/com/atproto/sync/getBlob.d.ts.map +1 -1
  81. package/dist/lexicons/com/atproto/sync/getBlob.defs.d.ts +1 -1
  82. package/dist/lexicons/com/atproto/sync/getBlob.defs.d.ts.map +1 -1
  83. package/dist/lexicons/com/atproto/sync/getBlob.defs.js +5 -14
  84. package/dist/lexicons/com/atproto/sync/getBlob.defs.js.map +1 -1
  85. package/dist/lexicons/com/atproto/sync/getBlob.js +2 -2
  86. package/dist/lexicons/com/atproto/sync/getBlob.js.map +1 -1
  87. package/dist/lexicons/com/atproto/sync.d.ts +1 -1
  88. package/dist/lexicons/com/atproto/sync.d.ts.map +1 -1
  89. package/dist/lexicons/com/atproto/sync.js +1 -1
  90. package/dist/lexicons/com/atproto/sync.js.map +1 -1
  91. package/dist/lexicons/com/atproto.d.ts +2 -2
  92. package/dist/lexicons/com/atproto.d.ts.map +1 -1
  93. package/dist/lexicons/com/atproto.js +2 -2
  94. package/dist/lexicons/com/atproto.js.map +1 -1
  95. package/dist/lexicons/com.d.ts +1 -1
  96. package/dist/lexicons/com.d.ts.map +1 -1
  97. package/dist/lexicons/com.js +1 -1
  98. package/dist/lexicons/com.js.map +1 -1
  99. package/dist/lexicons/index.d.ts +1 -1
  100. package/dist/lexicons/index.d.ts.map +1 -1
  101. package/dist/lexicons/index.js +1 -1
  102. package/dist/lexicons/index.js.map +1 -1
  103. package/dist/write-operation-builder.d.ts +1 -1
  104. package/dist/write-operation-builder.d.ts.map +1 -1
  105. package/dist/write-operation-builder.js +4 -4
  106. package/dist/write-operation-builder.js.map +1 -1
  107. package/package.json +14 -7
  108. package/dist/agent.d.ts +0 -127
  109. package/dist/agent.d.ts.map +0 -1
  110. package/dist/agent.js +0 -41
  111. package/dist/agent.js.map +0 -1
  112. package/dist/errors.d.ts +0 -277
  113. package/dist/errors.d.ts.map +0 -1
  114. package/dist/errors.js +0 -388
  115. package/dist/errors.js.map +0 -1
  116. package/dist/response.d.ts +0 -124
  117. package/dist/response.d.ts.map +0 -1
  118. package/dist/response.js +0 -178
  119. package/dist/response.js.map +0 -1
  120. package/dist/types.d.ts +0 -54
  121. package/dist/types.d.ts.map +0 -1
  122. package/dist/types.js +0 -16
  123. package/dist/types.js.map +0 -1
  124. package/dist/util.d.ts +0 -90
  125. package/dist/util.d.ts.map +0 -1
  126. package/dist/util.js +0 -210
  127. package/dist/util.js.map +0 -1
  128. package/dist/www-authenticate.d.ts +0 -35
  129. package/dist/www-authenticate.d.ts.map +0 -1
  130. package/dist/www-authenticate.js +0 -54
  131. package/dist/www-authenticate.js.map +0 -1
  132. package/dist/xrpc.d.ts +0 -194
  133. package/dist/xrpc.d.ts.map +0 -1
  134. package/dist/xrpc.js +0 -235
  135. package/dist/xrpc.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"atproto.js","sourceRoot":"","sources":["../../../src/lexicons/com/atproto.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAA;AACzC,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * as repo from './atproto/repo.js'\nexport * as sync from './atproto/sync.js'\n"]}
1
+ {"version":3,"file":"atproto.js","sourceRoot":"","sources":["../../../src/lexicons/com/atproto.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,mBAAmB,CAAC","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * as repo from \"./atproto/repo.js\";\nexport * as sync from \"./atproto/sync.js\";\n"]}
@@ -1,2 +1,2 @@
1
- export * as atproto from './com/atproto.js';
1
+ export * as atproto from "./com/atproto.js";
2
2
  //# sourceMappingURL=com.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"com.d.ts","sourceRoot":"","sources":["../../src/lexicons/com.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA"}
1
+ {"version":3,"file":"com.d.ts","sourceRoot":"","sources":["../../src/lexicons/com.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /*
2
2
  * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
3
3
  */
4
- export * as atproto from './com/atproto.js';
4
+ export * as atproto from "./com/atproto.js";
5
5
  //# sourceMappingURL=com.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"com.js","sourceRoot":"","sources":["../../src/lexicons/com.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * as atproto from './com/atproto.js'\n"]}
1
+ {"version":3,"file":"com.js","sourceRoot":"","sources":["../../src/lexicons/com.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * as atproto from \"./com/atproto.js\";\n"]}
@@ -1,2 +1,2 @@
1
- export * as com from './com.js';
1
+ export * as com from "./com.js";
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lexicons/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lexicons/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /*
2
2
  * THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
3
3
  */
4
- export * as com from './com.js';
4
+ export * as com from "./com.js";
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lexicons/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * as com from './com.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lexicons/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nexport * as com from \"./com.js\";\n"]}
@@ -1,6 +1,6 @@
1
+ import { type RecordKeyOptions } from '@atproto/lex-rpc';
1
2
  import { type $Typed, type InferInput, type Main, type RecordSchema, type Restricted } from '@atproto/lex-schema';
2
3
  import { com } from './lexicons/index.js';
3
- import type { RecordKeyOptions } from './util.js';
4
4
  export type WriteOperation = $Typed<com.atproto.repo.applyWrites.Create> | $Typed<com.atproto.repo.applyWrites.Update> | $Typed<com.atproto.repo.applyWrites.Delete>;
5
5
  export type WriteOperationCreateOptions<T extends RecordSchema> = RecordKeyOptions<T, 'tid' | 'any'>;
6
6
  export type WriteOperationUpdateOptions<T extends RecordSchema> = RecordKeyOptions<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"write-operation-builder.d.ts","sourceRoot":"","sources":["../src/write-operation-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,KAAK,UAAU,EAEhB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAGjD,MAAM,MAAM,cAAc,GACtB,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAC3C,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAA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9C,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,YAAY,EACjC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,EACX,OAAO,EAAE,2BAA2B,CAAC,CAAC,CAAC,GACtC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IAY9C,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,sBAAsB,GAAG,cAAc,EAAE,CAE9D;CACF"}
@@ -1,6 +1,6 @@
1
+ import { rkeyFor, rkeyForCreate } from '@atproto/lex-rpc';
1
2
  import { getMain, } from '@atproto/lex-schema';
2
3
  import { com } from './lexicons/index.js';
3
- import { getDefaultRecordKey, getLiteralRecordKey } from './util.js';
4
4
  export class WriteOperationHelper {
5
5
  constructor() { }
6
6
  create(ns, input, options = {}) {
@@ -9,7 +9,7 @@ export class WriteOperationHelper {
9
9
  return com.atproto.repo.applyWrites.create.$build({
10
10
  collection: schema.$type,
11
11
  value,
12
- rkey: options?.rkey ?? getDefaultRecordKey(schema),
12
+ rkey: rkeyForCreate(schema, options?.rkey),
13
13
  });
14
14
  }
15
15
  update(ns, input, options = {}) {
@@ -18,14 +18,14 @@ export class WriteOperationHelper {
18
18
  return com.atproto.repo.applyWrites.update.$build({
19
19
  collection: schema.$type,
20
20
  value,
21
- rkey: options?.rkey ?? getLiteralRecordKey(schema),
21
+ rkey: rkeyFor(schema, options?.rkey),
22
22
  });
23
23
  }
24
24
  delete(ns, options = {}) {
25
25
  const schema = getMain(ns);
26
26
  return com.atproto.repo.applyWrites.delete.$build({
27
27
  collection: schema.$type,
28
- rkey: options?.rkey ?? getLiteralRecordKey(schema),
28
+ rkey: rkeyFor(schema, options?.rkey),
29
29
  });
30
30
  }
31
31
  static build(factory) {
@@ -1 +1 @@
1
- {"version":3,"file":"write-operation-builder.js","sourceRoot":"","sources":["../src/write-operation-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,OAAO,GACR,MAAM,qBAAqB,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YACxB,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,mBAAmB,CAAC,MAAM,CAAC;SACnD,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAA+B;QAC1C,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC,CAAA;IACxD,CAAC;CACF","sourcesContent":["import {\n type $Typed,\n type InferInput,\n type Main,\n type RecordSchema,\n type Restricted,\n getMain,\n} from '@atproto/lex-schema'\nimport { com } from './lexicons/index.js'\nimport type { RecordKeyOptions } from './util.js'\nimport { getDefaultRecordKey, getLiteralRecordKey } from './util.js'\n\nexport type WriteOperation =\n | $Typed<com.atproto.repo.applyWrites.Create>\n | $Typed<com.atproto.repo.applyWrites.Update>\n | $Typed<com.atproto.repo.applyWrites.Delete>\n\nexport type WriteOperationCreateOptions<T extends RecordSchema> =\n RecordKeyOptions<T, 'tid' | 'any'>\n\nexport type WriteOperationUpdateOptions<T extends RecordSchema> =\n RecordKeyOptions<T>\n\nexport type WriteOperationDeleteOptions<T extends RecordSchema> =\n RecordKeyOptions<T>\n\nexport type WriteOperationsFactory = (\n helper: WriteOperationHelper,\n) => Iterable<WriteOperation>\n\nexport class WriteOperationHelper {\n private constructor() {}\n\n create<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends WriteOperationCreateOptions<T>\n ? Main<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n input: Omit<InferInput<T>, '$type'>,\n ): $Typed<com.atproto.repo.applyWrites.Create>\n create<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<InferInput<T>, '$type'>,\n options: WriteOperationCreateOptions<T>,\n ): $Typed<com.atproto.repo.applyWrites.Create>\n create<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<InferInput<T>, '$type'>,\n options: WriteOperationCreateOptions<T> = {} as WriteOperationCreateOptions<T>,\n ): $Typed<com.atproto.repo.applyWrites.Create> {\n const schema: T = getMain(ns)\n const value = schema.build(input)\n return com.atproto.repo.applyWrites.create.$build({\n collection: schema.$type,\n value,\n rkey: options?.rkey ?? getDefaultRecordKey(schema),\n })\n }\n\n update<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends WriteOperationUpdateOptions<T>\n ? Main<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n input: Omit<InferInput<T>, '$type'>,\n ): $Typed<com.atproto.repo.applyWrites.Update>\n update<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<InferInput<T>, '$type'>,\n options: WriteOperationUpdateOptions<T>,\n ): $Typed<com.atproto.repo.applyWrites.Update>\n update<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<InferInput<T>, '$type'>,\n options: WriteOperationUpdateOptions<T> = {} as WriteOperationUpdateOptions<T>,\n ): $Typed<com.atproto.repo.applyWrites.Update> {\n const schema: T = getMain(ns)\n const value = schema.build(input)\n return com.atproto.repo.applyWrites.update.$build({\n collection: schema.$type,\n value,\n rkey: options?.rkey ?? getLiteralRecordKey(schema),\n })\n }\n\n delete<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends WriteOperationDeleteOptions<T>\n ? Main<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n ): $Typed<com.atproto.repo.applyWrites.Delete>\n delete<const T extends RecordSchema>(\n ns: Main<T>,\n options: WriteOperationDeleteOptions<T>,\n ): $Typed<com.atproto.repo.applyWrites.Delete>\n delete<const T extends RecordSchema>(\n ns: Main<T>,\n options: WriteOperationDeleteOptions<T> = {} as WriteOperationDeleteOptions<T>,\n ): $Typed<com.atproto.repo.applyWrites.Delete> {\n const schema: T = getMain(ns)\n return com.atproto.repo.applyWrites.delete.$build({\n collection: schema.$type,\n rkey: options?.rkey ?? getLiteralRecordKey(schema),\n })\n }\n\n static build(factory: WriteOperationsFactory): WriteOperation[] {\n return Array.from(factory(new WriteOperationHelper()))\n }\n}\n"]}
1
+ {"version":3,"file":"write-operation-builder.js","sourceRoot":"","sources":["../src/write-operation-builder.ts"],"names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AAM,CAAC;YAChD,UAAU,EAAE,MAAM,CAAC,KAAK;YACxB,IAAI,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;SACrC,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAA+B;QAC1C,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC,CAAA;IACxD,CAAC;CACF","sourcesContent":["import { type RecordKeyOptions, rkeyFor, rkeyForCreate } from '@atproto/lex-rpc'\nimport {\n type $Typed,\n type InferInput,\n type Main,\n type RecordSchema,\n type Restricted,\n getMain,\n} from '@atproto/lex-schema'\nimport { com } from './lexicons/index.js'\n\nexport type WriteOperation =\n | $Typed<com.atproto.repo.applyWrites.Create>\n | $Typed<com.atproto.repo.applyWrites.Update>\n | $Typed<com.atproto.repo.applyWrites.Delete>\n\nexport type WriteOperationCreateOptions<T extends RecordSchema> =\n RecordKeyOptions<T, 'tid' | 'any'>\n\nexport type WriteOperationUpdateOptions<T extends RecordSchema> =\n RecordKeyOptions<T>\n\nexport type WriteOperationDeleteOptions<T extends RecordSchema> =\n RecordKeyOptions<T>\n\nexport type WriteOperationsFactory = (\n helper: WriteOperationHelper,\n) => Iterable<WriteOperation>\n\nexport class WriteOperationHelper {\n private constructor() {}\n\n create<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends WriteOperationCreateOptions<T>\n ? Main<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n input: Omit<InferInput<T>, '$type'>,\n ): $Typed<com.atproto.repo.applyWrites.Create>\n create<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<InferInput<T>, '$type'>,\n options: WriteOperationCreateOptions<T>,\n ): $Typed<com.atproto.repo.applyWrites.Create>\n create<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<InferInput<T>, '$type'>,\n options: WriteOperationCreateOptions<T> = {} as WriteOperationCreateOptions<T>,\n ): $Typed<com.atproto.repo.applyWrites.Create> {\n const schema: T = getMain(ns)\n const value = schema.build(input)\n return com.atproto.repo.applyWrites.create.$build({\n collection: schema.$type,\n value,\n rkey: rkeyForCreate(schema, options?.rkey),\n })\n }\n\n update<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends WriteOperationUpdateOptions<T>\n ? Main<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n input: Omit<InferInput<T>, '$type'>,\n ): $Typed<com.atproto.repo.applyWrites.Update>\n update<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<InferInput<T>, '$type'>,\n options: WriteOperationUpdateOptions<T>,\n ): $Typed<com.atproto.repo.applyWrites.Update>\n update<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<InferInput<T>, '$type'>,\n options: WriteOperationUpdateOptions<T> = {} as WriteOperationUpdateOptions<T>,\n ): $Typed<com.atproto.repo.applyWrites.Update> {\n const schema: T = getMain(ns)\n const value = schema.build(input)\n return com.atproto.repo.applyWrites.update.$build({\n collection: schema.$type,\n value,\n rkey: rkeyFor(schema, options?.rkey),\n })\n }\n\n delete<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends WriteOperationDeleteOptions<T>\n ? Main<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n ): $Typed<com.atproto.repo.applyWrites.Delete>\n delete<const T extends RecordSchema>(\n ns: Main<T>,\n options: WriteOperationDeleteOptions<T>,\n ): $Typed<com.atproto.repo.applyWrites.Delete>\n delete<const T extends RecordSchema>(\n ns: Main<T>,\n options: WriteOperationDeleteOptions<T> = {} as WriteOperationDeleteOptions<T>,\n ): $Typed<com.atproto.repo.applyWrites.Delete> {\n const schema: T = getMain(ns)\n return com.atproto.repo.applyWrites.delete.$build({\n collection: schema.$type,\n rkey: rkeyFor(schema, options?.rkey),\n })\n }\n\n static build(factory: WriteOperationsFactory): WriteOperation[] {\n return Array.from(factory(new WriteOperationHelper()))\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/lex-client",
3
- "version": "0.3.6",
3
+ "version": "0.4.0",
4
4
  "license": "MIT",
5
5
  "description": "HTTP client for interacting with Lexicon based APIs",
6
6
  "keywords": [
@@ -33,17 +33,24 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "tslib": "^2.8.1",
36
- "@atproto/lex-data": "^0.1.7",
37
- "@atproto/lex-json": "^0.1.6",
38
- "@atproto/lex-schema": "^0.2.7"
36
+ "@atproto/lex-data": "^0.1.8",
37
+ "@atproto/lex-schema": "^0.2.9",
38
+ "@atproto/lex-rpc": "^0.0.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "vitest": "^4.1.10",
42
- "@atproto/lex-builder": "^0.1.15",
43
- "@atproto/lex-cbor": "^0.1.6"
42
+ "@atproto/lex-cbor": "^0.1.7",
43
+ "@atproto/lex-builder": "^0.1.18",
44
+ "@atproto/lex-installer": "^0.2.0",
45
+ "@atproto/lex-json": "^0.1.7"
44
46
  },
45
47
  "scripts": {
46
- "codegen:lex": "node ./scripts/lex-build.js",
48
+ "lex:build": "lex-builder build --out ./src/lexicons --clear --lib @atproto/lex-schema --index-file --default-export",
49
+ "lex:install": "lex-installer install",
50
+ "postlex:install": "pnpm run lex:build",
51
+ "lex:update": "lex-installer update",
52
+ "postlex:update": "pnpm run lex:build",
53
+ "codegen:lex": "pnpm run lex:install --ci",
47
54
  "prebuild": "pnpm run '/^(codegen:.+)$/'",
48
55
  "build": "tsc --build tsconfig.build.json",
49
56
  "test": "vitest run"
package/dist/agent.d.ts DELETED
@@ -1,127 +0,0 @@
1
- import type { DidString } from '@atproto/lex-schema';
2
- /**
3
- * A function that performs HTTP requests towards a service endpoint.
4
- *
5
- * The handler is responsible for adding the origin (protocol, hostname, and
6
- * port) to the provided path, typically based on authentication or service
7
- * configuration. The handler can also be responsible for adding any necessary
8
- * headers, such as authorization tokens.
9
- *
10
- * @param path - The URL path (pathname + query parameters) without the origin
11
- * @param init - Standard fetch RequestInit options
12
- * @returns A Promise resolving to the HTTP Response
13
- */
14
- export type FetchHandler = (
15
- /**
16
- * The URL (pathname + query parameters) to make the request to, without the
17
- * origin. The origin (protocol, hostname, and port) must be added by this
18
- * {@link FetchHandler}, typically based on authentication or other factors.
19
- */
20
- path: `/${string}`, init: RequestInit) => Promise<Response>;
21
- /**
22
- * Core interface for making XRPC requests towards a specific service.
23
- *
24
- * An {@link Agent} encapsulates an identity and request handling for AT
25
- * Protocol operations. Agents will typically handle authentication, service URL
26
- * resolution, and other request configuration, allowing client code to make
27
- * requests without needing to manage these details directly. The key component
28
- * of an Agent is the {@link FetchHandler}, which is responsible for
29
- * constructing the full request URL and adding any necessary headers or
30
- * authentication tokens. The Agent's `did` property represents the
31
- * authenticated user's DID, if available, and can be used for operations that
32
- * require knowledge of the user's identity (such as creating AT Protocol
33
- * records).
34
- *
35
- * @see {@link buildAgent} for creating (simple) Agent instances.
36
- *
37
- * @example
38
- * ```typescript
39
- * const agent: Agent = {
40
- * did: 'did:plc:example123',
41
- * fetchHandler: async (path, init) => {
42
- * const url = new URL(path, 'https://bsky.social')
43
- * return fetch(url, init)
44
- * }
45
- * }
46
- * ```
47
- */
48
- export interface Agent {
49
- /** The DID of the authenticated user, or `undefined` if unauthenticated. */
50
- readonly did?: DidString;
51
- /** The fetch handler used to make HTTP requests. */
52
- fetchHandler: FetchHandler;
53
- }
54
- export declare function isAgent(value: unknown): value is Agent;
55
- export type AgentConfig = {
56
- /**
57
- * The identifier (DID) of the user represented by this agent.
58
- */
59
- did?: DidString;
60
- /**
61
- * The service URL to make requests to. This can be a string, URL, or a
62
- * function that returns a string or URL. This is useful for dynamic URLs,
63
- * such as a service URL that changes based on authentication.
64
- */
65
- service: string | URL;
66
- /**
67
- * Optional headers to include with every request made by this agent, unless
68
- * overridden by the request-specific headers provided to the fetch handler.
69
- */
70
- headers?: HeadersInit;
71
- /**
72
- * Bring your own fetch implementation. Typically useful for testing, logging,
73
- * mocking, or adding retries, session management, signatures, proof of
74
- * possession (DPoP), SSRF protection, etc. Defaults to the global `fetch`
75
- * function.
76
- */
77
- fetch?: typeof globalThis.fetch;
78
- fetchHandler?: never;
79
- };
80
- /**
81
- * Options for creating an Agent.
82
- *
83
- * Can be a full {@link AgentConfig} object, or a simple service URL string/{@link URL}.
84
- */
85
- export type AgentOptions = AgentConfig | FetchHandler | string | URL;
86
- /**
87
- * Creates an {@link Agent} from various input types.
88
- *
89
- * This factory function accepts an existing Agent (returned as-is), a service
90
- * URL, or a full configuration object. It handles the common case of creating
91
- * an unauthenticated agent from just a service URL.
92
- *
93
- * @param options - Agent instance, configuration object, or service URL
94
- * @returns A configured Agent ready for making requests
95
- * @throws {TypeError} If fetch() is not available in the environment
96
- *
97
- * @example // From URL string
98
- * ```typescript
99
- * const agent = buildAgent('https://public.api.bsky.app')
100
- * ```
101
- *
102
- * @example // From configuration
103
- * ```typescript
104
- * const agent = buildAgent({
105
- * did: 'did:plc:example',
106
- * service: 'https://bsky.social',
107
- * headers: { 'Authorization': 'Bearer ...' }
108
- * })
109
- * ```
110
- *
111
- * @example // From existing Agent
112
- * ```typescript
113
- * const existingAgent: Agent = { ... }
114
- * const agent = buildAgent(existingAgent)
115
- * ```
116
- *
117
- * @example // From agent like object with fetchHandler
118
- * ```typescript
119
- * const agent = buildAgent({
120
- * did: 'did:plc:example',
121
- * fetchHandler: async (path, init) => { ... }
122
- * // @NOTE "headers" and "service" are not allowed when providing a fetchHandler, because the input will returned "as is" if it matched the "Agent" interface.
123
- * })
124
- * ```
125
- */
126
- export declare function buildAgent<O extends Agent | AgentOptions>(options: O): O extends Agent ? O : Agent;
127
- //# sourceMappingURL=agent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAGpD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,YAAY,GAAG;AACzB;;;;GAIG;AACH,IAAI,EAAE,IAAI,MAAM,EAAE,EAClB,IAAI,EAAE,WAAW,KACd,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEtB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,KAAK;IACpB,4EAA4E;IAC5E,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,CAAA;IACxB,oDAAoD;IACpD,YAAY,EAAE,YAAY,CAAA;CAC3B;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAUtD;AAED,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,GAAG,CAAC,EAAE,SAAS,CAAA;IAEf;;;;OAIG;IACH,OAAO,EAAE,MAAM,GAAG,GAAG,CAAA;IAErB;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAA;IAErB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;IAK/B,YAAY,CAAC,EAAE,KAAK,CAAA;CACrB,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,YAAY,GAAG,MAAM,GAAG,GAAG,CAAA;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,KAAK,GAAG,YAAY,EACvD,OAAO,EAAE,CAAC,GACT,CAAC,SAAS,KAAK,GAAG,CAAC,GAAG,KAAK,CAAA"}
package/dist/agent.js DELETED
@@ -1,41 +0,0 @@
1
- import { mergeHeaders } from './util.js';
2
- export function isAgent(value) {
3
- return (typeof value === 'object' &&
4
- value !== null &&
5
- 'fetchHandler' in value &&
6
- typeof value.fetchHandler === 'function' &&
7
- (!('did' in value) ||
8
- value.did === undefined ||
9
- typeof value.did === 'string'));
10
- }
11
- export function buildAgent(options) {
12
- if (typeof options === 'function') {
13
- return { did: undefined, fetchHandler: options };
14
- }
15
- const config = typeof options === 'string' || options instanceof URL
16
- ? { did: undefined, service: options }
17
- : options;
18
- // Prevent mismatch between `fetchHandler` and `headers` in the config, since
19
- // `headers` would be ignored if `fetchHandler` is provided.
20
- if ('fetchHandler' in config) {
21
- if (isAgent(config))
22
- return config;
23
- throw new TypeError('fetchHandler must not be provided when using AgentConfig');
24
- }
25
- const { did, service, fetch = globalThis.fetch, headers: defaultHeaders, } = config;
26
- if (typeof fetch !== 'function') {
27
- throw new TypeError('fetch() is not available in this environment');
28
- }
29
- return {
30
- get did() {
31
- return did;
32
- },
33
- async fetchHandler(path, init) {
34
- const headers = defaultHeaders != null && init.headers != null
35
- ? mergeHeaders(defaultHeaders, init.headers)
36
- : defaultHeaders || init.headers;
37
- return fetch(new URL(path, service), headers !== init.headers ? { ...init, headers } : init);
38
- },
39
- };
40
- }
41
- //# sourceMappingURL=agent.js.map
package/dist/agent.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AA0DxC,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,cAAc,IAAI,KAAK;QACvB,OAAO,KAAK,CAAC,YAAY,KAAK,UAAU;QACxC,CAAC,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC;YAChB,KAAK,CAAC,GAAG,KAAK,SAAS;YACvB,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC,CACjC,CAAA;AACH,CAAC;AAqFD,MAAM,UAAU,UAAU,CAAC,OAA6B;IACtD,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;QAClC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,EAAE,CAAA;IAClD,CAAC;IAED,MAAM,MAAM,GACV,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,YAAY,GAAG;QACnD,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE;QACtC,CAAC,CAAC,OAAO,CAAA;IAEb,6EAA6E;IAC7E,4DAA4D;IAC5D,IAAI,cAAc,IAAI,MAAM,EAAE,CAAC;QAC7B,IAAI,OAAO,CAAC,MAAM,CAAC;YAAE,OAAO,MAAM,CAAA;QAElC,MAAM,IAAI,SAAS,CACjB,0DAA0D,CAC3D,CAAA;IACH,CAAC;IAED,MAAM,EACJ,GAAG,EACH,OAAO,EACP,KAAK,GAAG,UAAU,CAAC,KAAK,EACxB,OAAO,EAAE,cAAc,GACxB,GAAG,MAAM,CAAA;IAEV,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAChC,MAAM,IAAI,SAAS,CAAC,8CAA8C,CAAC,CAAA;IACrE,CAAC;IAED,OAAO;QACL,IAAI,GAAG;YACL,OAAO,GAAG,CAAA;QACZ,CAAC;QAED,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI;YAC3B,MAAM,OAAO,GACX,cAAc,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI;gBAC5C,CAAC,CAAC,YAAY,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC;gBAC5C,CAAC,CAAC,cAAc,IAAI,IAAI,CAAC,OAAO,CAAA;YAEpC,OAAO,KAAK,CACV,IAAI,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,EACtB,OAAO,KAAK,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CACvD,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import type { DidString } from '@atproto/lex-schema'\nimport { mergeHeaders } from './util.js'\n\n/**\n * A function that performs HTTP requests towards a service endpoint.\n *\n * The handler is responsible for adding the origin (protocol, hostname, and\n * port) to the provided path, typically based on authentication or service\n * configuration. The handler can also be responsible for adding any necessary\n * headers, such as authorization tokens.\n *\n * @param path - The URL path (pathname + query parameters) without the origin\n * @param init - Standard fetch RequestInit options\n * @returns A Promise resolving to the HTTP Response\n */\nexport type FetchHandler = (\n /**\n * The URL (pathname + query parameters) to make the request to, without the\n * origin. The origin (protocol, hostname, and port) must be added by this\n * {@link FetchHandler}, typically based on authentication or other factors.\n */\n path: `/${string}`,\n init: RequestInit,\n) => Promise<Response>\n\n/**\n * Core interface for making XRPC requests towards a specific service.\n *\n * An {@link Agent} encapsulates an identity and request handling for AT\n * Protocol operations. Agents will typically handle authentication, service URL\n * resolution, and other request configuration, allowing client code to make\n * requests without needing to manage these details directly. The key component\n * of an Agent is the {@link FetchHandler}, which is responsible for\n * constructing the full request URL and adding any necessary headers or\n * authentication tokens. The Agent's `did` property represents the\n * authenticated user's DID, if available, and can be used for operations that\n * require knowledge of the user's identity (such as creating AT Protocol\n * records).\n *\n * @see {@link buildAgent} for creating (simple) Agent instances.\n *\n * @example\n * ```typescript\n * const agent: Agent = {\n * did: 'did:plc:example123',\n * fetchHandler: async (path, init) => {\n * const url = new URL(path, 'https://bsky.social')\n * return fetch(url, init)\n * }\n * }\n * ```\n */\nexport interface Agent {\n /** The DID of the authenticated user, or `undefined` if unauthenticated. */\n readonly did?: DidString\n /** The fetch handler used to make HTTP requests. */\n fetchHandler: FetchHandler\n}\n\nexport function isAgent(value: unknown): value is Agent {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'fetchHandler' in value &&\n typeof value.fetchHandler === 'function' &&\n (!('did' in value) ||\n value.did === undefined ||\n typeof value.did === 'string')\n )\n}\n\nexport type AgentConfig = {\n /**\n * The identifier (DID) of the user represented by this agent.\n */\n did?: DidString\n\n /**\n * The service URL to make requests to. This can be a string, URL, or a\n * function that returns a string or URL. This is useful for dynamic URLs,\n * such as a service URL that changes based on authentication.\n */\n service: string | URL\n\n /**\n * Optional headers to include with every request made by this agent, unless\n * overridden by the request-specific headers provided to the fetch handler.\n */\n headers?: HeadersInit\n\n /**\n * Bring your own fetch implementation. Typically useful for testing, logging,\n * mocking, or adding retries, session management, signatures, proof of\n * possession (DPoP), SSRF protection, etc. Defaults to the global `fetch`\n * function.\n */\n fetch?: typeof globalThis.fetch\n\n // Because this type get unioned with `Agent`, we need to prevent TypeScript\n // from accepting `headers` when `fetchHandler` is provided, since `headers`\n // would not be used (while the user might expect it to be).\n fetchHandler?: never\n}\n\n/**\n * Options for creating an Agent.\n *\n * Can be a full {@link AgentConfig} object, or a simple service URL string/{@link URL}.\n */\nexport type AgentOptions = AgentConfig | FetchHandler | string | URL\n\n/**\n * Creates an {@link Agent} from various input types.\n *\n * This factory function accepts an existing Agent (returned as-is), a service\n * URL, or a full configuration object. It handles the common case of creating\n * an unauthenticated agent from just a service URL.\n *\n * @param options - Agent instance, configuration object, or service URL\n * @returns A configured Agent ready for making requests\n * @throws {TypeError} If fetch() is not available in the environment\n *\n * @example // From URL string\n * ```typescript\n * const agent = buildAgent('https://public.api.bsky.app')\n * ```\n *\n * @example // From configuration\n * ```typescript\n * const agent = buildAgent({\n * did: 'did:plc:example',\n * service: 'https://bsky.social',\n * headers: { 'Authorization': 'Bearer ...' }\n * })\n * ```\n *\n * @example // From existing Agent\n * ```typescript\n * const existingAgent: Agent = { ... }\n * const agent = buildAgent(existingAgent)\n * ```\n *\n * @example // From agent like object with fetchHandler\n * ```typescript\n * const agent = buildAgent({\n * did: 'did:plc:example',\n * fetchHandler: async (path, init) => { ... }\n * // @NOTE \"headers\" and \"service\" are not allowed when providing a fetchHandler, because the input will returned \"as is\" if it matched the \"Agent\" interface.\n * })\n * ```\n */\nexport function buildAgent<O extends Agent | AgentOptions>(\n options: O,\n): O extends Agent ? O : Agent\nexport function buildAgent(options: Agent | AgentOptions): Agent {\n if (typeof options === 'function') {\n return { did: undefined, fetchHandler: options }\n }\n\n const config: Agent | AgentConfig =\n typeof options === 'string' || options instanceof URL\n ? { did: undefined, service: options }\n : options\n\n // Prevent mismatch between `fetchHandler` and `headers` in the config, since\n // `headers` would be ignored if `fetchHandler` is provided.\n if ('fetchHandler' in config) {\n if (isAgent(config)) return config\n\n throw new TypeError(\n 'fetchHandler must not be provided when using AgentConfig',\n )\n }\n\n const {\n did,\n service,\n fetch = globalThis.fetch,\n headers: defaultHeaders,\n } = config\n\n if (typeof fetch !== 'function') {\n throw new TypeError('fetch() is not available in this environment')\n }\n\n return {\n get did() {\n return did\n },\n\n async fetchHandler(path, init) {\n const headers =\n defaultHeaders != null && init.headers != null\n ? mergeHeaders(defaultHeaders, init.headers)\n : defaultHeaders || init.headers\n\n return fetch(\n new URL(path, service),\n headers !== init.headers ? { ...init, headers } : init,\n )\n },\n }\n}\n"]}
package/dist/errors.d.ts DELETED
@@ -1,277 +0,0 @@
1
- import type { LexErrorCode, LexErrorData, LexValue } from '@atproto/lex-data';
2
- import { LexError } from '@atproto/lex-data';
3
- import { type InferMethodError, type LexValidationError, type Procedure, type Query, type ResultFailure } from '@atproto/lex-schema';
4
- import type { XrpcUnknownResponsePayload } from './types.js';
5
- import type { WWWAuthenticate } from './www-authenticate.js';
6
- export type { XrpcUnknownResponsePayload };
7
- export type DownstreamError<N extends LexErrorCode = LexErrorCode> = {
8
- status: number;
9
- headers?: Headers;
10
- encoding?: 'application/json';
11
- body: LexErrorData<N>;
12
- };
13
- /**
14
- * HTTP status codes that indicate a transient error that may succeed on retry.
15
- *
16
- * Includes:
17
- * - 408 Request Timeout
18
- * - 425 Too Early
19
- * - 429 Too Many Requests (rate limited)
20
- * - 500 Internal Server Error
21
- * - 502 Bad Gateway
22
- * - 503 Service Unavailable
23
- * - 504 Gateway Timeout
24
- * - 522 Connection Timed Out (Cloudflare)
25
- * - 524 A Timeout Occurred (Cloudflare)
26
- */
27
- export declare const RETRYABLE_HTTP_STATUS_CODES: ReadonlySet<number>;
28
- export { LexError };
29
- export type { LexErrorCode, LexErrorData };
30
- /**
31
- * The payload structure for XRPC error responses.
32
- *
33
- * All XRPC errors return JSON with an `error` code and optional `message`.
34
- *
35
- * @typeParam N - The specific error code type
36
- */
37
- export type XrpcErrorPayload<N extends LexErrorCode = LexErrorCode> = {
38
- body: LexErrorData<N>;
39
- encoding: 'application/json';
40
- };
41
- /**
42
- * All unsuccessful responses should follow a standard error response
43
- * schema. The Content-Type should be application/json, and the payload
44
- * should be a JSON object with the following fields:
45
- *
46
- * - `error` (string, required): type name of the error (generic ASCII
47
- * constant, no whitespace)
48
- * - `message` (string, optional): description of the error, appropriate for
49
- * display to humans
50
- *
51
- * This function checks whether a given payload matches this schema.
52
- */
53
- export declare function isXrpcErrorPayload(payload: XrpcUnknownResponsePayload | null | undefined): payload is XrpcErrorPayload;
54
- /**
55
- * Abstract base class for all XRPC errors.
56
- *
57
- * Extends {@link LexError} and implements {@link ResultFailure} for use with
58
- * safe/result-based error handling patterns.
59
- *
60
- * @typeParam M - The XRPC method type (Procedure or Query)
61
- * @typeParam N - The error code type
62
- * @typeParam TReason - The reason type for ResultFailure
63
- *
64
- * @see {@link XrpcResponseError} - For valid XRPC error responses
65
- * @see {@link XrpcInvalidResponseError} - For invalid/unexpected responses
66
- * @see {@link XrpcInternalError} - For network/internal errors
67
- */
68
- export declare abstract class XrpcError<M extends Procedure | Query = Procedure | Query, N extends LexErrorCode = LexErrorCode, TReason = unknown> extends LexError<N> implements ResultFailure<TReason> {
69
- readonly method: M;
70
- name: string;
71
- constructor(method: M, error: N, message?: string, options?: ErrorOptions);
72
- /**
73
- * @see {@link ResultFailure.success}
74
- */
75
- readonly success: false;
76
- /**
77
- * @see {@link ResultFailure.reason}
78
- */
79
- abstract readonly reason: TReason;
80
- /**
81
- * Indicates whether the error is transient and can be retried.
82
- */
83
- abstract shouldRetry(): boolean;
84
- abstract toDownstreamError(): DownstreamError;
85
- matchesSchemaErrors(): this is XrpcError<M, InferMethodError<M>>;
86
- }
87
- /**
88
- * Error class for valid XRPC error responses from the server.
89
- *
90
- * This represents a properly formatted XRPC error where the server returned
91
- * a non-2xx status with a valid JSON error payload containing `error` and
92
- * optional `message` fields.
93
- *
94
- * Use {@link matchesSchemaErrors} to check if the error matches the method's declared
95
- * error types for type-safe error handling.
96
- *
97
- * @typeParam M - The XRPC method type
98
- * @typeParam N - The error code type (inferred from method or generic)
99
- *
100
- * @example Handling specific errors
101
- * ```typescript
102
- * try {
103
- * await client.xrpc(someMethod, options)
104
- * } catch (err) {
105
- * if (err instanceof XrpcResponseError && err.error === 'RecordNotFound') {
106
- * // Handle not found case
107
- * }
108
- * }
109
- * ```
110
- */
111
- export declare class XrpcResponseError<M extends Procedure | Query = Procedure | Query> extends XrpcError<M, LexErrorCode, XrpcResponseError<M>> {
112
- readonly response: Response;
113
- readonly payload?: XrpcUnknownResponsePayload | undefined;
114
- name: string;
115
- constructor(method: M, response: Response, payload?: XrpcUnknownResponsePayload | undefined, options?: ErrorOptions);
116
- get reason(): this;
117
- shouldRetry(): boolean;
118
- toJSON(): LexErrorData;
119
- toDownstreamError(): DownstreamError;
120
- get status(): number;
121
- get headers(): Headers;
122
- get body(): undefined | Uint8Array | LexValue;
123
- }
124
- export type { WWWAuthenticate };
125
- /**
126
- * Error class for 401 Unauthorized XRPC responses.
127
- *
128
- * Extends {@link XrpcResponseError} with access to parsed WWW-Authenticate header
129
- * information, useful for implementing authentication flows.
130
- *
131
- * Authentication errors are never retryable as they require user intervention
132
- * (e.g., re-authentication, token refresh).
133
- *
134
- * @typeParam M - The XRPC method type
135
- * @typeParam N - The error code type
136
- *
137
- * @example Handling authentication errors
138
- * ```typescript
139
- * try {
140
- * await client.xrpc(someMethod, options)
141
- * } catch (err) {
142
- * if (err instanceof XrpcAuthenticationError) {
143
- * const { DPoP } = err.wwwAuthenticate
144
- * if (DPoP?.error === 'use_dpop_nonce') {
145
- * // Handle DPoP nonce requirement
146
- * }
147
- * }
148
- * }
149
- * ```
150
- */
151
- export declare class XrpcAuthenticationError<M extends Procedure | Query = Procedure | Query> extends XrpcResponseError<M> {
152
- #private;
153
- name: string;
154
- shouldRetry(): boolean;
155
- /**
156
- * Parsed WWW-Authenticate header from the response.
157
- * Contains authentication scheme parameters (e.g., Bearer realm, DPoP nonce).
158
- */
159
- get wwwAuthenticate(): WWWAuthenticate;
160
- }
161
- /**
162
- * Error class for invalid or unprocessable XRPC responses from upstream servers.
163
- *
164
- * This occurs when the server returns a response that doesn't conform to the
165
- * XRPC protocol, such as:
166
- * - Missing or invalid Content-Type header
167
- * - Response body that doesn't match the method's output schema
168
- * - Non-JSON error responses
169
- * - Responses from non-XRPC endpoints
170
- *
171
- * The error code is always 'InvalidResponse' and maps to HTTP 502 Bad Gateway
172
- * when converted to a response. This should allow downstream clients to
173
- * determine at which boundary the error occurred.
174
- *
175
- * @typeParam M - The XRPC method type
176
- */
177
- export declare class XrpcInvalidResponseError<M extends Procedure | Query = Procedure | Query> extends XrpcError<M, 'InvalidResponse', XrpcInvalidResponseError<M>> {
178
- readonly response: Response;
179
- readonly payload?: XrpcUnknownResponsePayload | undefined;
180
- name: string;
181
- constructor(method: M, response: Response, payload?: XrpcUnknownResponsePayload | undefined, message?: string, options?: ErrorOptions);
182
- get reason(): this;
183
- shouldRetry(): boolean;
184
- toDownstreamError(): DownstreamError;
185
- }
186
- /**
187
- * Error class for invalid XRPC responses that fail schema validation.
188
- *
189
- * This is a specific type of {@link XrpcInvalidResponseError} that indicates the
190
- * upstream server returned a response that was structurally valid but did not
191
- * conform to the expected schema for the method. This likely indicates a
192
- * mismatch between client and server versions or an issue with the server's
193
- * XRPC implementation.
194
- *
195
- * @typeParam M - The XRPC method type
196
- */
197
- export declare class XrpcResponseValidationError<M extends Procedure | Query = Procedure | Query> extends XrpcInvalidResponseError<M> {
198
- readonly cause: LexValidationError;
199
- name: string;
200
- constructor(method: M, response: Response, payload: XrpcUnknownResponsePayload, cause: LexValidationError);
201
- }
202
- /**
203
- * Error class for unexpected internal/client-side errors during XRPC requests.
204
- *
205
- * The error code is always 'InternalServerError' and these errors not
206
- * considered retryable as they stem from unforeseen issues in the
207
- * implementation.
208
- *
209
- * @typeParam M - The XRPC method type
210
- */
211
- export declare class XrpcInternalError<M extends Procedure | Query = Procedure | Query> extends XrpcError<M, 'InternalServerError', XrpcInternalError<M>> {
212
- name: string;
213
- constructor(method: M, message?: string, options?: ErrorOptions);
214
- get reason(): this;
215
- shouldRetry(): boolean;
216
- toJSON(): LexErrorData;
217
- toDownstreamError(): DownstreamError;
218
- }
219
- /**
220
- * Special case of XrpcInternalError that specifically represents errors thrown
221
- * by {@link Agent.fetchHandler} during the XRPC request. This includes:
222
- * - Network errors (connection refused, DNS failure)
223
- * - Request timeouts
224
- * - Request aborted via AbortSignal
225
- *
226
- * These errors are optimistically considered retryable, as many fetch errors
227
- * are transient and may succeed on retry.
228
- */
229
- export declare class XrpcFetchError<M extends Procedure | Query = Procedure | Query> extends XrpcInternalError<M> {
230
- name: string;
231
- constructor(method: M, cause: unknown);
232
- shouldRetry(): boolean;
233
- toJSON(): LexErrorData;
234
- toDownstreamError(): DownstreamError;
235
- }
236
- /**
237
- * Union type of all possible XRPC failure types.
238
- *
239
- * Used as the return type for safe/non-throwing XRPC methods. Check the
240
- * `success` property to distinguish between success and failure:
241
- *
242
- * @typeParam M - The XRPC method type
243
- *
244
- * @example
245
- * ```typescript
246
- * const result = await client.xrpcSafe(someMethod, options)
247
- * if (result.success) {
248
- * console.log(result.body) // XrpcResponse
249
- * } else {
250
- * // result is XrpcFailure (XrpcResponseError | XrpcInvalidResponseError | XrpcInternalError)
251
- * console.error(result.error, result.message)
252
- * }
253
- * ```
254
- */
255
- export type XrpcFailure<M extends Procedure | Query = Procedure | Query> = XrpcResponseError<M> | XrpcInvalidResponseError<M> | XrpcInternalError<M>;
256
- /**
257
- * Converts an unknown error into an appropriate {@link XrpcFailure} type.
258
- *
259
- * If the error is already an XrpcFailure for the given method, returns it as-is.
260
- * Otherwise, wraps it in an {@link XrpcInternalError}.
261
- *
262
- * @param method - The XRPC method that was called
263
- * @param cause - The error to convert
264
- * @returns An XrpcFailure instance
265
- *
266
- * @example
267
- * ```typescript
268
- * try {
269
- * const response = await fetch(...)
270
- * // ... process response
271
- * } catch (err) {
272
- * return asXrpcFailure(method, err)
273
- * }
274
- * ```
275
- */
276
- export declare function asXrpcFailure<M extends Procedure | Query>(method: M, cause: unknown): XrpcFailure<M>;
277
- //# sourceMappingURL=errors.d.ts.map