@atproto/lex-client 0.0.2 → 0.0.3

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 (75) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/agent.d.ts +3 -3
  3. package/dist/agent.d.ts.map +1 -1
  4. package/dist/agent.js.map +1 -1
  5. package/dist/client.d.ts +62 -234
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +1 -1
  8. package/dist/client.js.map +1 -1
  9. package/dist/error.d.ts +12 -16
  10. package/dist/error.d.ts.map +1 -1
  11. package/dist/error.js +7 -5
  12. package/dist/error.js.map +1 -1
  13. package/dist/lexicons/com/atproto/repo/createRecord.defs.d.ts +12 -58
  14. package/dist/lexicons/com/atproto/repo/createRecord.defs.d.ts.map +1 -1
  15. package/dist/lexicons/com/atproto/repo/createRecord.defs.js +10 -12
  16. package/dist/lexicons/com/atproto/repo/createRecord.defs.js.map +1 -1
  17. package/dist/lexicons/com/atproto/repo/defs.defs.d.ts +3 -3
  18. package/dist/lexicons/com/atproto/repo/defs.defs.d.ts.map +1 -1
  19. package/dist/lexicons/com/atproto/repo/defs.defs.js +1 -1
  20. package/dist/lexicons/com/atproto/repo/defs.defs.js.map +1 -1
  21. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.d.ts +8 -36
  22. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.d.ts.map +1 -1
  23. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.js +7 -4
  24. package/dist/lexicons/com/atproto/repo/deleteRecord.defs.js.map +1 -1
  25. package/dist/lexicons/com/atproto/repo/getRecord.defs.d.ts +4 -40
  26. package/dist/lexicons/com/atproto/repo/getRecord.defs.d.ts.map +1 -1
  27. package/dist/lexicons/com/atproto/repo/getRecord.defs.js +5 -4
  28. package/dist/lexicons/com/atproto/repo/getRecord.defs.js.map +1 -1
  29. package/dist/lexicons/com/atproto/repo/listRecords.defs.d.ts +13 -41
  30. package/dist/lexicons/com/atproto/repo/listRecords.defs.d.ts.map +1 -1
  31. package/dist/lexicons/com/atproto/repo/listRecords.defs.js +8 -11
  32. package/dist/lexicons/com/atproto/repo/listRecords.defs.js.map +1 -1
  33. package/dist/lexicons/com/atproto/repo/putRecord.defs.d.ts +12 -60
  34. package/dist/lexicons/com/atproto/repo/putRecord.defs.d.ts.map +1 -1
  35. package/dist/lexicons/com/atproto/repo/putRecord.defs.js +10 -15
  36. package/dist/lexicons/com/atproto/repo/putRecord.defs.js.map +1 -1
  37. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.d.ts +8 -12
  38. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.d.ts.map +1 -1
  39. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.js +3 -1
  40. package/dist/lexicons/com/atproto/repo/uploadBlob.defs.js.map +1 -1
  41. package/dist/types.d.ts +4 -4
  42. package/dist/types.d.ts.map +1 -1
  43. package/dist/types.js.map +1 -1
  44. package/dist/xrpc.d.ts +2 -2
  45. package/dist/xrpc.d.ts.map +1 -1
  46. package/dist/xrpc.js +1 -1
  47. package/dist/xrpc.js.map +1 -1
  48. package/package.json +20 -12
  49. package/src/agent.ts +3 -3
  50. package/src/client.ts +29 -27
  51. package/src/error.ts +13 -22
  52. package/src/lexicons/com/atproto/repo/createRecord.defs.ts +58 -0
  53. package/src/lexicons/com/atproto/repo/createRecord.ts +6 -0
  54. package/src/lexicons/com/atproto/repo/defs.defs.ts +28 -0
  55. package/src/lexicons/com/atproto/repo/defs.ts +6 -0
  56. package/src/lexicons/com/atproto/repo/deleteRecord.defs.ts +54 -0
  57. package/src/lexicons/com/atproto/repo/deleteRecord.ts +6 -0
  58. package/src/lexicons/com/atproto/repo/getRecord.defs.ts +42 -0
  59. package/src/lexicons/com/atproto/repo/getRecord.ts +6 -0
  60. package/src/lexicons/com/atproto/repo/listRecords.defs.ts +63 -0
  61. package/src/lexicons/com/atproto/repo/listRecords.ts +6 -0
  62. package/src/lexicons/com/atproto/repo/putRecord.defs.ts +59 -0
  63. package/src/lexicons/com/atproto/repo/putRecord.ts +6 -0
  64. package/src/lexicons/com/atproto/repo/uploadBlob.defs.ts +35 -0
  65. package/src/lexicons/com/atproto/repo/uploadBlob.ts +6 -0
  66. package/src/lexicons/com/atproto/repo.ts +11 -0
  67. package/src/lexicons/com/atproto.ts +5 -0
  68. package/src/lexicons/com.ts +5 -0
  69. package/src/types.ts +4 -4
  70. package/src/xrpc.ts +3 -3
  71. package/jest.config.js +0 -5
  72. package/scripts/lex-build.mjs +0 -40
  73. package/tests/client.test.ts +0 -370
  74. package/tsconfig.build.tsbuildinfo +0 -1
  75. package/tsconfig.tests.tsbuildinfo +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;;AACA,oDAiB4B;AAC5B,yCAA4D;AAC5D,yCAKmB;AACnB,+DAAwC;AAExC,yCAAqE;AACrE,uCAAiE;AA2FjE,MAAa,MAAM;IACjB,MAAM,CAAC,WAAW,GAAmB,EAAE,CAAA;IAEvC;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,IAAqC;QACpD,IAAI,IAAI,CAAC,WAAW;YAAE,IAAI,CAAC,WAAW,GAAG,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAA;IAChE,CAAC;IAEe,KAAK,CAAO;IACZ,OAAO,CAAS;IAChB,OAAO,CAAU;IACjB,QAAQ,CAAU;IAElC,YAAY,KAA2B,EAAE,UAAyB,EAAE;QAClE,IAAI,CAAC,KAAK;YACR,OAAO,KAAK,KAAK,QAAQ,IAAI,cAAc,IAAI,KAAK;gBAClD,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,IAAA,qBAAU,EAAC,KAAK,CAAC,CAAA;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;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S;IAET,IAAI,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACtC,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC5B,CAAC;IAED,MAAM,IAAI,SAAS,CACjB,mDAAmD,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,KAAK,GAAG,CACnF,CAAA;AACH,CAAC","sourcesContent":["import { LexMap, LexValue } from '@atproto/lex-data'\nimport {\n AtIdentifier,\n Did,\n Infer,\n InferProcedureInputBody,\n InferProcedureOutputBody,\n InferQueryOutputBody,\n InferQueryParameters,\n InferRecordKey,\n Nsid,\n Params,\n Procedure,\n Query,\n RecordKey,\n RecordSchema,\n Restricted,\n ValidationResult,\n} from '@atproto/lex-schema'\nimport { Agent, AgentOptions, buildAgent } from './agent.js'\nimport {\n KnownError,\n XrpcError,\n XrpcRequestFailure,\n asXrpcRequestFailureFor,\n} from './error.js'\nimport * as com from './lexicons/com.js'\nimport { XrpcResponse, XrpcResponseBody } from './response.js'\nimport { CallOptions, Namespace, Service, getMain } from './types.js'\nimport { XrpcOptions, xrpc, xrpcRequestHeaders } from './xrpc.js'\n\nexport type ClientOptions = {\n labelers?: Iterable<Did>\n headers?: HeadersInit\n service?: Service\n}\n\nexport type Action<I = any, O = any> = (\n client: Client,\n input: I,\n options: CallOptions,\n) => O | Promise<O>\nexport type InferActionInput<A extends Action> =\n A extends Action<infer I, any> ? I : never\nexport type InferActionOutput<A extends Action> =\n A extends Action<any, infer O> ? O : never\n\nexport type CreateRecordOptions = CallOptions & {\n repo?: AtIdentifier\n swapCommit?: string\n validate?: boolean\n}\n\nexport type DeleteRecordOptions = CallOptions & {\n repo?: AtIdentifier\n swapCommit?: string\n swapRecord?: string\n}\n\nexport type GetRecordOptions = CallOptions & {\n repo?: AtIdentifier\n}\n\nexport type PutRecordOptions = CallOptions & {\n repo?: AtIdentifier\n swapCommit?: string\n swapRecord?: string\n validate?: boolean\n}\n\nexport type ListRecordsOptions = CallOptions & {\n repo?: AtIdentifier\n limit?: number\n cursor?: string\n reverse?: boolean\n}\n\nexport type RecordKeyOptions<\n T extends RecordSchema,\n AlsoOptionalWhenRecordKeyIs extends RecordKey = never,\n> = T['key'] extends `literal:${string}` | AlsoOptionalWhenRecordKeyIs\n ? { rkey?: InferRecordKey<T> }\n : { rkey: InferRecordKey<T> }\n\nexport type CreateOptions<T extends RecordSchema> = CreateRecordOptions &\n RecordKeyOptions<T, 'tid'>\nexport type CreateOutput = XrpcResponseBody<\n typeof com.atproto.repo.createRecord.main\n>\n\nexport type DeleteOptions<T extends RecordSchema> = DeleteRecordOptions &\n RecordKeyOptions<T>\nexport type DeleteOutput = XrpcResponseBody<\n typeof com.atproto.repo.deleteRecord.main\n>\nexport type GetOptions<T extends RecordSchema> = GetRecordOptions &\n RecordKeyOptions<T>\nexport type GetOutput<T extends RecordSchema> = Omit<\n XrpcResponseBody<typeof com.atproto.repo.getRecord.main>,\n 'value'\n> & { value: Infer<T> }\n\nexport type PutOptions<T extends RecordSchema> = PutRecordOptions &\n RecordKeyOptions<T>\nexport type PutOutput = XrpcResponseBody<typeof com.atproto.repo.putRecord.main>\n\nexport type ListOptions = ListRecordsOptions\nexport type ListOutput<T extends RecordSchema> = XrpcResponseBody<\n typeof com.atproto.repo.listRecords.main\n> & {\n records: ListRecord<T>[]\n // @NOTE Because the schema uses \"type\": \"unknown\" instead of an open union,\n // we have to use LexMap instead of TypedObject here.\n invalid: LexMap[]\n}\nexport type ListRecord<T extends RecordSchema> =\n com.atproto.repo.listRecords.DefRecord & {\n value: Infer<T>\n }\n\nexport class Client implements Agent {\n static appLabelers: readonly Did[] = []\n\n /**\n * Configures the Client (or its sub classes) globally.\n */\n static configure(opts: { appLabelers?: Iterable<Did> }) {\n if (opts.appLabelers) this.appLabelers = [...opts.appLabelers]\n }\n\n public readonly agent: Agent\n public readonly headers: Headers\n public readonly service?: Service\n public readonly labelers: Set<Did>\n\n constructor(agent: Agent | AgentOptions, options: ClientOptions = {}) {\n this.agent =\n typeof agent === 'object' && 'fetchHandler' in agent\n ? agent\n : buildAgent(agent)\n this.service = options.service\n this.labelers = new Set(options.labelers)\n this.headers = new Headers(options.headers)\n }\n\n get did(): Did | undefined {\n return this.agent.did\n }\n\n get assertDid(): Did {\n this.assertAuthenticated()\n return this.did\n }\n\n public assertAuthenticated(): asserts this is { did: Did } {\n if (!this.did) throw new XrpcError(KnownError.AuthenticationRequired)\n }\n\n public setLabelers(labelers: Iterable<Did> = []) {\n this.clearLabelers()\n this.addLabelers(labelers)\n }\n\n public addLabelers(labelers: Iterable<Did>) {\n for (const labeler of labelers) this.labelers.add(labeler)\n }\n\n public clearLabelers() {\n this.labelers.clear()\n }\n\n public fetchHandler(path: string, init: RequestInit): Promise<Response> {\n const headers = xrpcRequestHeaders({\n headers: init.headers,\n service: this.service,\n labelers: [\n ...(this.constructor as typeof Client).appLabelers.map(\n (l) => `${l};redact` as const,\n ),\n ...this.labelers,\n ],\n })\n\n // Incoming headers take precedence\n for (const [key, value] of this.headers) {\n if (!headers.has(key)) headers.set(key, value)\n }\n\n return this.agent.fetchHandler(path, { ...init, headers })\n }\n\n async xrpc<const M extends Query | Procedure>(\n ns: NonNullable<unknown> extends XrpcOptions<M>\n ? Namespace<M>\n : Restricted<'This XRPC method requires an \"options\" argument'>,\n ): Promise<XrpcResponse<M>>\n async xrpc<const M extends Query | Procedure>(\n ns: Namespace<M>,\n options: XrpcOptions<M>,\n ): Promise<XrpcResponse<M>>\n async xrpc<const M extends Query | Procedure>(\n ns: Namespace<M>,\n options: XrpcOptions<M> = {} as XrpcOptions<M>,\n ): Promise<XrpcResponse<M>> {\n return xrpc(this, ns, options)\n }\n\n async xrpcSafe<const M extends Query | Procedure>(\n ns: NonNullable<unknown> extends XrpcOptions<M>\n ? Namespace<M>\n : Restricted<'This XRPC method requires an \"options\" argument'>,\n ): Promise<XrpcResponse<M> | XrpcRequestFailure<M>>\n async xrpcSafe<const M extends Query | Procedure>(\n ns: Namespace<M>,\n options: XrpcOptions<M>,\n ): Promise<XrpcResponse<M> | XrpcRequestFailure<M>>\n async xrpcSafe<const M extends Query | Procedure>(\n ns: Namespace<M>,\n options: XrpcOptions<M> = {} as XrpcOptions<M>,\n ): Promise<unknown> {\n const schema = getMain(ns)\n return this.xrpc(schema, options).catch(asXrpcRequestFailureFor(schema))\n }\n\n /**\n * @param rkey Leave `undefined` to have the server generate a TID.\n */\n public async createRecord(\n record: { $type: Nsid } & LexMap,\n rkey?: string,\n options?: CreateRecordOptions,\n ) {\n return this.xrpc(com.atproto.repo.createRecord.main, {\n ...options,\n body: {\n repo: options?.repo ?? this.assertDid,\n collection: record.$type,\n record,\n rkey,\n validate: options?.validate,\n swapCommit: options?.swapCommit,\n },\n })\n }\n\n async createRecordsSafe(...args: Parameters<Client['createRecord']>) {\n return this.createRecord(...args).catch(\n asXrpcRequestFailureFor(com.atproto.repo.createRecord.main),\n )\n }\n\n async deleteRecord(\n collection: Nsid,\n rkey: string,\n options?: DeleteRecordOptions,\n ) {\n return this.xrpc(com.atproto.repo.deleteRecord.main, {\n ...options,\n body: {\n repo: options?.repo ?? this.assertDid,\n collection,\n rkey,\n swapCommit: options?.swapCommit,\n swapRecord: options?.swapRecord,\n },\n })\n }\n\n async deleteRecordsSafe(...args: Parameters<Client['deleteRecord']>) {\n return this.deleteRecord(...args).catch(\n asXrpcRequestFailureFor(com.atproto.repo.deleteRecord.main),\n )\n }\n\n public async getRecord(\n collection: Nsid,\n rkey: string,\n options?: GetRecordOptions,\n ) {\n return this.xrpc(com.atproto.repo.getRecord.main, {\n ...options,\n params: {\n repo: options?.repo ?? this.assertDid,\n collection,\n rkey,\n },\n })\n }\n\n async getRecordsSafe(...args: Parameters<Client['getRecord']>) {\n return this.getRecord(...args).catch(\n asXrpcRequestFailureFor(com.atproto.repo.getRecord.main),\n )\n }\n\n async putRecord(\n record: { $type: Nsid } & LexMap,\n rkey: string,\n options?: PutRecordOptions,\n ) {\n return this.xrpc(com.atproto.repo.putRecord.main, {\n ...options,\n body: {\n repo: options?.repo ?? this.assertDid,\n collection: record.$type,\n rkey,\n record,\n validate: options?.validate,\n swapCommit: options?.swapCommit,\n swapRecord: options?.swapRecord,\n },\n })\n }\n\n async putRecordsSafe(...args: Parameters<Client['putRecord']>) {\n return this.putRecord(...args).catch(\n asXrpcRequestFailureFor(com.atproto.repo.putRecord.main),\n )\n }\n\n async listRecords(nsid: Nsid, options?: ListRecordsOptions) {\n return this.xrpc(com.atproto.repo.listRecords.main, {\n ...options,\n params: {\n repo: options?.repo ?? this.assertDid,\n collection: nsid,\n cursor: options?.cursor,\n limit: options?.limit,\n reverse: options?.reverse,\n },\n })\n }\n\n public async call<const T extends Action>(\n ns: Namespace<T>,\n input: InferActionInput<T>,\n options?: CallOptions,\n ): Promise<InferActionOutput<T>>\n public async call<const T extends Procedure>(\n ns: Namespace<T>,\n body: InferProcedureInputBody<T>,\n options?: CallOptions,\n ): Promise<InferProcedureOutputBody<T>>\n public async call<const T extends Query>(\n ns: NonNullable<unknown> extends InferQueryParameters<T>\n ? Namespace<T>\n : Restricted<'This query type requires a \"params\" argument'>,\n ): Promise<InferQueryOutputBody<T>>\n public async call<const T extends Query>(\n ns: Namespace<T>,\n params: InferQueryParameters<T>,\n options?: CallOptions,\n ): Promise<InferQueryOutputBody<T>>\n public async call(\n ns: Namespace<Action> | Namespace<Procedure> | Namespace<Query>,\n arg?: LexValue | Params,\n options: CallOptions = {},\n ): Promise<unknown> {\n const method = getMain(ns)\n\n if (typeof method === 'function') {\n return method(this, arg, options)\n }\n\n if (method instanceof Procedure) {\n const body = arg as LexValue | undefined\n const result = await this.xrpc(method, { ...options, body })\n return result.body\n } else if (method instanceof Query) {\n const params = arg as Params | undefined\n const result = await this.xrpc(method, { ...options, params })\n return result.body\n } else {\n throw new TypeError('Invalid lexicon')\n }\n }\n\n public async create<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends CreateOptions<T>\n ? Namespace<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n input: Omit<Infer<T>, '$type'>,\n ): Promise<CreateOutput>\n public async create<const T extends RecordSchema>(\n ns: Namespace<T>,\n input: Omit<Infer<T>, '$type'>,\n options: CreateOptions<T>,\n ): Promise<CreateOutput>\n public async create<const T extends RecordSchema>(\n ns: Namespace<T>,\n input: Omit<Infer<T>, '$type'>,\n options: CreateOptions<T> = {} as CreateOptions<T>,\n ): Promise<CreateOutput> {\n const schema: T = getMain(ns)\n const record = options.validate\n ? schema.parse(schema.build(input))\n : schema.build(input)\n const rkey = options.rkey ?? getDefaultRecordKey(schema)\n if (rkey !== undefined) schema.keySchema.assert(rkey)\n const response = await this.createRecord(record, rkey, options)\n return response.body\n }\n\n public async delete<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends DeleteOptions<T>\n ? Namespace<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n ): Promise<DeleteOutput>\n public async delete<const T extends RecordSchema>(\n ns: Namespace<T>,\n options?: DeleteOptions<T>,\n ): Promise<DeleteOutput>\n public async delete<const T extends RecordSchema>(\n ns: Namespace<T>,\n options: DeleteOptions<T> = {} as DeleteOptions<T>,\n ): Promise<DeleteOutput> {\n const schema = getMain(ns)\n const rkey = schema.keySchema.parse(\n options.rkey ?? getLiteralRecordKey(schema),\n )\n const response = await this.deleteRecord(schema.$type, rkey, options)\n return response.body\n }\n\n public async get<const T extends RecordSchema>(\n ns: T['key'] extends `literal:${string}`\n ? Namespace<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n ): Promise<GetOutput<T>>\n public async get<const T extends RecordSchema>(\n ns: Namespace<T>,\n options?: GetOptions<T>,\n ): Promise<GetOutput<T>>\n public async get<const T extends RecordSchema>(\n ns: Namespace<T>,\n options: GetOptions<T> = {} as GetOptions<T>,\n ): Promise<GetOutput<T>> {\n const schema = getMain(ns)\n const rkey = schema.keySchema.parse(\n options.rkey ?? getLiteralRecordKey(schema),\n )\n const response = await this.getRecord(schema.$type, rkey, options)\n const value = schema.parse(response.body.value) as Infer<T>\n return { ...response.body, value }\n }\n\n public async put<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends PutOptions<T>\n ? Namespace<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n input: Omit<Infer<T>, '$type'>,\n ): Promise<PutOutput>\n public async put<const T extends RecordSchema>(\n ns: Namespace<T>,\n input: Omit<Infer<T>, '$type'>,\n options: PutOptions<T>,\n ): Promise<PutOutput>\n public async put<const T extends RecordSchema>(\n ns: Namespace<T>,\n input: Omit<Infer<T>, '$type'>,\n options: PutOptions<T> = {} as PutOptions<T>,\n ): Promise<PutOutput> {\n const schema = getMain(ns)\n const record = schema.build(input)\n const rkey = options.rkey ?? getLiteralRecordKey(schema)\n const response = await this.putRecord(record, rkey, options)\n return response.body\n }\n\n async list<const T extends RecordSchema>(\n ns: Namespace<T>,\n options?: ListOptions,\n ): Promise<ListOutput<T>> {\n const schema = getMain(ns)\n const { body } = await this.listRecords(schema.$type, options)\n\n const records: ListRecord<T>[] = []\n const invalid: LexMap[] = []\n\n for (const record of body.records) {\n const parsed = schema.validate(record.value) as ValidationResult<Infer<T>>\n if (parsed.success) {\n records.push({ ...record, value: parsed.value })\n } else {\n invalid.push(record.value)\n }\n }\n\n return { ...body, records, invalid }\n }\n}\n\nfunction getDefaultRecordKey<const T extends RecordSchema>(\n schema: T,\n): undefined | InferRecordKey<T> {\n // Let the server generate the TID\n if (schema.key === 'tid') return undefined\n if (schema.key === 'any') return undefined\n\n return getLiteralRecordKey(schema)\n}\n\nfunction getLiteralRecordKey<const T extends RecordSchema>(\n schema: T,\n): InferRecordKey<T> {\n if (schema.key.startsWith('literal:')) {\n return schema.key.slice(8)\n }\n\n throw new TypeError(\n `An \"rkey\" must be provided for record key type \"${schema.key}\" (${schema.$type})`,\n )\n}\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;;AACA,oDAiB4B;AAC5B,yCAA4D;AAC5D,yCAKmB;AACnB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AAI,MAA2B,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACnE,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA;YAClD,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YAC5B,CAAC;QACH,CAAC;QAED,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;IACtC,CAAC;;AAnXH,wBAoXC;AAED,SAAS,mBAAmB,CAC1B,MAAS;IAET,kCAAkC;IAClC,IAAI,MAAM,CAAC,GAAG,KAAK,KAAK;QAAE,OAAO,SAAS,CAAA;IAC1C,IAAI,MAAM,CAAC,GAAG,KAAK,KAAK;QAAE,OAAO,SAAS,CAAA;IAE1C,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAA;AACpC,CAAC;AAED,SAAS,mBAAmB,CAC1B,MAAS;IAET,IAAI,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACtC,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IAC5B,CAAC;IAED,MAAM,IAAI,SAAS,CACjB,mDAAmD,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,KAAK,GAAG,CACnF,CAAA;AACH,CAAC","sourcesContent":["import { LexMap, LexValue } from '@atproto/lex-data'\nimport {\n AtIdentifierString,\n DidString,\n Infer,\n InferProcedureInputBody,\n InferProcedureOutputBody,\n InferQueryOutputBody,\n InferQueryParameters,\n InferRecordKey,\n LexiconRecordKey,\n NsidString,\n Params,\n Procedure,\n Query,\n RecordSchema,\n Restricted,\n Schema,\n} from '@atproto/lex-schema'\nimport { Agent, AgentOptions, buildAgent } from './agent.js'\nimport {\n KnownError,\n XrpcError,\n XrpcRequestFailure,\n asXrpcRequestFailureFor,\n} from './error.js'\nimport * as com from './lexicons/com.js'\nimport { XrpcResponse, XrpcResponseBody } from './response.js'\nimport { CallOptions, Namespace, Service, getMain } from './types.js'\nimport { XrpcOptions, xrpc, xrpcRequestHeaders } from './xrpc.js'\n\nexport type ClientOptions = {\n labelers?: Iterable<DidString>\n headers?: HeadersInit\n service?: Service\n}\n\nexport type Action<I = any, O = any> = (\n client: Client,\n input: I,\n options: CallOptions,\n) => O | Promise<O>\nexport type InferActionInput<A extends Action> =\n A extends Action<infer I, any> ? I : never\nexport type InferActionOutput<A extends Action> =\n A extends Action<any, infer O> ? O : never\n\nexport type CreateRecordOptions = CallOptions & {\n repo?: AtIdentifierString\n swapCommit?: string\n validate?: boolean\n}\n\nexport type DeleteRecordOptions = CallOptions & {\n repo?: AtIdentifierString\n swapCommit?: string\n swapRecord?: string\n}\n\nexport type GetRecordOptions = CallOptions & {\n repo?: AtIdentifierString\n}\n\nexport type PutRecordOptions = CallOptions & {\n repo?: AtIdentifierString\n swapCommit?: string\n swapRecord?: string\n validate?: boolean\n}\n\nexport type ListRecordsOptions = CallOptions & {\n repo?: AtIdentifierString\n limit?: number\n cursor?: string\n reverse?: boolean\n}\n\nexport type RecordKeyOptions<\n T extends RecordSchema,\n AlsoOptionalWhenRecordKeyIs extends LexiconRecordKey = never,\n> = T['key'] extends `literal:${string}` | AlsoOptionalWhenRecordKeyIs\n ? { rkey?: InferRecordKey<T> }\n : { rkey: InferRecordKey<T> }\n\nexport type CreateOptions<T extends RecordSchema> = CreateRecordOptions &\n RecordKeyOptions<T, 'tid'>\nexport type CreateOutput = XrpcResponseBody<\n typeof com.atproto.repo.createRecord.main\n>\n\nexport type DeleteOptions<T extends RecordSchema> = DeleteRecordOptions &\n RecordKeyOptions<T>\nexport type DeleteOutput = XrpcResponseBody<\n typeof com.atproto.repo.deleteRecord.main\n>\nexport type GetOptions<T extends RecordSchema> = GetRecordOptions &\n RecordKeyOptions<T>\nexport type GetOutput<T extends RecordSchema> = Omit<\n XrpcResponseBody<typeof com.atproto.repo.getRecord.main>,\n 'value'\n> & { value: Infer<T> }\n\nexport type PutOptions<T extends RecordSchema> = PutRecordOptions &\n RecordKeyOptions<T>\nexport type PutOutput = XrpcResponseBody<typeof com.atproto.repo.putRecord.main>\n\nexport type ListOptions = ListRecordsOptions\nexport type ListOutput<T extends RecordSchema> = XrpcResponseBody<\n typeof com.atproto.repo.listRecords.main\n> & {\n records: ListRecord<T>[]\n // @NOTE Because the schema uses \"type\": \"unknown\" instead of an open union,\n // we have to use LexMap instead of TypedObject here.\n invalid: LexMap[]\n}\nexport type ListRecord<T extends RecordSchema> =\n com.atproto.repo.listRecords.DefRecord & {\n value: Infer<T>\n }\n\nexport class Client implements Agent {\n static appLabelers: readonly DidString[] = []\n\n /**\n * Configures the Client (or its sub classes) globally.\n */\n static configure(opts: { appLabelers?: Iterable<DidString> }) {\n if (opts.appLabelers) this.appLabelers = [...opts.appLabelers]\n }\n\n public readonly agent: Agent\n public readonly headers: Headers\n public readonly service?: Service\n public readonly labelers: Set<DidString>\n\n constructor(agent: Agent | AgentOptions, options: ClientOptions = {}) {\n this.agent =\n typeof agent === 'object' && 'fetchHandler' in agent\n ? agent\n : buildAgent(agent)\n this.service = options.service\n this.labelers = new Set(options.labelers)\n this.headers = new Headers(options.headers)\n }\n\n get did(): DidString | undefined {\n return this.agent.did\n }\n\n get assertDid(): DidString {\n this.assertAuthenticated()\n return this.did\n }\n\n public assertAuthenticated(): asserts this is { did: DidString } {\n if (!this.did) throw new XrpcError(KnownError.AuthenticationRequired)\n }\n\n public setLabelers(labelers: Iterable<DidString> = []) {\n this.clearLabelers()\n this.addLabelers(labelers)\n }\n\n public addLabelers(labelers: Iterable<DidString>) {\n for (const labeler of labelers) this.labelers.add(labeler)\n }\n\n public clearLabelers() {\n this.labelers.clear()\n }\n\n public fetchHandler(path: string, init: RequestInit): Promise<Response> {\n const headers = xrpcRequestHeaders({\n headers: init.headers,\n service: this.service,\n labelers: [\n ...(this.constructor as typeof Client).appLabelers.map(\n (l) => `${l};redact` as const,\n ),\n ...this.labelers,\n ],\n })\n\n // Incoming headers take precedence\n for (const [key, value] of this.headers) {\n if (!headers.has(key)) headers.set(key, value)\n }\n\n return this.agent.fetchHandler(path, { ...init, headers })\n }\n\n async xrpc<const M extends Query | Procedure>(\n ns: NonNullable<unknown> extends XrpcOptions<M>\n ? Namespace<M>\n : Restricted<'This XRPC method requires an \"options\" argument'>,\n ): Promise<XrpcResponse<M>>\n async xrpc<const M extends Query | Procedure>(\n ns: Namespace<M>,\n options: XrpcOptions<M>,\n ): Promise<XrpcResponse<M>>\n async xrpc<const M extends Query | Procedure>(\n ns: Namespace<M>,\n options: XrpcOptions<M> = {} as XrpcOptions<M>,\n ): Promise<XrpcResponse<M>> {\n return xrpc(this, ns, options)\n }\n\n async xrpcSafe<const M extends Query | Procedure>(\n ns: NonNullable<unknown> extends XrpcOptions<M>\n ? Namespace<M>\n : Restricted<'This XRPC method requires an \"options\" argument'>,\n ): Promise<XrpcResponse<M> | XrpcRequestFailure<M>>\n async xrpcSafe<const M extends Query | Procedure>(\n ns: Namespace<M>,\n options: XrpcOptions<M>,\n ): Promise<XrpcResponse<M> | XrpcRequestFailure<M>>\n async xrpcSafe<const M extends Query | Procedure>(\n ns: Namespace<M>,\n options: XrpcOptions<M> = {} as XrpcOptions<M>,\n ): Promise<unknown> {\n const schema = getMain(ns)\n return this.xrpc(schema, options).catch(asXrpcRequestFailureFor(schema))\n }\n\n /**\n * @param rkey Leave `undefined` to have the server generate a TID.\n */\n public async createRecord(\n record: { $type: NsidString } & LexMap,\n rkey?: string,\n options?: CreateRecordOptions,\n ) {\n return this.xrpc(com.atproto.repo.createRecord.main, {\n ...options,\n body: {\n repo: options?.repo ?? this.assertDid,\n collection: record.$type,\n record,\n rkey,\n validate: options?.validate,\n swapCommit: options?.swapCommit,\n },\n })\n }\n\n async createRecordsSafe(...args: Parameters<Client['createRecord']>) {\n return this.createRecord(...args).catch(\n asXrpcRequestFailureFor(com.atproto.repo.createRecord.main),\n )\n }\n\n async deleteRecord(\n collection: NsidString,\n rkey: string,\n options?: DeleteRecordOptions,\n ) {\n return this.xrpc(com.atproto.repo.deleteRecord.main, {\n ...options,\n body: {\n repo: options?.repo ?? this.assertDid,\n collection,\n rkey,\n swapCommit: options?.swapCommit,\n swapRecord: options?.swapRecord,\n },\n })\n }\n\n async deleteRecordsSafe(...args: Parameters<Client['deleteRecord']>) {\n return this.deleteRecord(...args).catch(\n asXrpcRequestFailureFor(com.atproto.repo.deleteRecord.main),\n )\n }\n\n public async getRecord(\n collection: NsidString,\n rkey: string,\n options?: GetRecordOptions,\n ) {\n return this.xrpc(com.atproto.repo.getRecord.main, {\n ...options,\n params: {\n repo: options?.repo ?? this.assertDid,\n collection,\n rkey,\n },\n })\n }\n\n async getRecordsSafe(...args: Parameters<Client['getRecord']>) {\n return this.getRecord(...args).catch(\n asXrpcRequestFailureFor(com.atproto.repo.getRecord.main),\n )\n }\n\n async putRecord(\n record: { $type: NsidString } & LexMap,\n rkey: string,\n options?: PutRecordOptions,\n ) {\n return this.xrpc(com.atproto.repo.putRecord.main, {\n ...options,\n body: {\n repo: options?.repo ?? this.assertDid,\n collection: record.$type,\n rkey,\n record,\n validate: options?.validate,\n swapCommit: options?.swapCommit,\n swapRecord: options?.swapRecord,\n },\n })\n }\n\n async putRecordsSafe(...args: Parameters<Client['putRecord']>) {\n return this.putRecord(...args).catch(\n asXrpcRequestFailureFor(com.atproto.repo.putRecord.main),\n )\n }\n\n async listRecords(nsid: NsidString, options?: ListRecordsOptions) {\n return this.xrpc(com.atproto.repo.listRecords.main, {\n ...options,\n params: {\n repo: options?.repo ?? this.assertDid,\n collection: nsid,\n cursor: options?.cursor,\n limit: options?.limit,\n reverse: options?.reverse,\n },\n })\n }\n\n public async call<const T extends Action>(\n ns: Namespace<T>,\n input: InferActionInput<T>,\n options?: CallOptions,\n ): Promise<InferActionOutput<T>>\n public async call<const T extends Procedure>(\n ns: Namespace<T>,\n body: InferProcedureInputBody<T>,\n options?: CallOptions,\n ): Promise<InferProcedureOutputBody<T>>\n public async call<const T extends Query>(\n ns: NonNullable<unknown> extends InferQueryParameters<T>\n ? Namespace<T>\n : Restricted<'This query type requires a \"params\" argument'>,\n ): Promise<InferQueryOutputBody<T>>\n public async call<const T extends Query>(\n ns: Namespace<T>,\n params: NonNullable<unknown> extends InferQueryParameters<T>\n ? InferQueryParameters<T> | undefined\n : InferQueryParameters<T>,\n options?: CallOptions,\n ): Promise<InferQueryOutputBody<T>>\n public async call(\n ns: Namespace<Action> | Namespace<Procedure> | Namespace<Query>,\n arg?: LexValue | Params,\n options: CallOptions = {},\n ): Promise<unknown> {\n const method = getMain(ns)\n\n if (typeof method === 'function') {\n return method(this, arg, options)\n }\n\n if (method instanceof Procedure) {\n const body = arg as LexValue | undefined\n const result = await this.xrpc(method, { ...options, body })\n return result.body\n } else if (method instanceof Query) {\n const params = arg as Params | undefined\n const result = await this.xrpc(method, { ...options, params })\n return result.body\n } else {\n throw new TypeError('Invalid lexicon')\n }\n }\n\n public async create<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends CreateOptions<T>\n ? Namespace<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n input: Omit<Infer<T>, '$type'>,\n ): Promise<CreateOutput>\n public async create<const T extends RecordSchema>(\n ns: Namespace<T>,\n input: Omit<Infer<T>, '$type'>,\n options: CreateOptions<T>,\n ): Promise<CreateOutput>\n public async create<const T extends RecordSchema>(\n ns: Namespace<T>,\n input: Omit<Infer<T>, '$type'>,\n options: CreateOptions<T> = {} as CreateOptions<T>,\n ): Promise<CreateOutput> {\n const schema: T = getMain(ns)\n const record = options.validate\n ? schema.parse(schema.build(input))\n : schema.build(input)\n const rkey = options.rkey ?? getDefaultRecordKey(schema)\n if (rkey !== undefined) schema.keySchema.assert(rkey)\n const response = await this.createRecord(record, rkey, options)\n return response.body\n }\n\n public async delete<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends DeleteOptions<T>\n ? Namespace<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n ): Promise<DeleteOutput>\n public async delete<const T extends RecordSchema>(\n ns: Namespace<T>,\n options?: DeleteOptions<T>,\n ): Promise<DeleteOutput>\n public async delete<const T extends RecordSchema>(\n ns: Namespace<T>,\n options: DeleteOptions<T> = {} as DeleteOptions<T>,\n ): Promise<DeleteOutput> {\n const schema = getMain(ns)\n const rkey = schema.keySchema.parse(\n options.rkey ?? getLiteralRecordKey(schema),\n )\n const response = await this.deleteRecord(schema.$type, rkey, options)\n return response.body\n }\n\n public async get<const T extends RecordSchema>(\n ns: T['key'] extends `literal:${string}`\n ? Namespace<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n ): Promise<GetOutput<T>>\n public async get<const T extends RecordSchema>(\n ns: Namespace<T>,\n options?: GetOptions<T>,\n ): Promise<GetOutput<T>>\n public async get<const T extends RecordSchema>(\n ns: Namespace<T>,\n options: GetOptions<T> = {} as GetOptions<T>,\n ): Promise<GetOutput<T>> {\n const schema = getMain(ns)\n const rkey = schema.keySchema.parse(\n options.rkey ?? getLiteralRecordKey(schema),\n )\n const response = await this.getRecord(schema.$type, rkey, options)\n const value = schema.parse(response.body.value) as Infer<T>\n return { ...response.body, value }\n }\n\n public async put<const T extends RecordSchema>(\n ns: NonNullable<unknown> extends PutOptions<T>\n ? Namespace<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n input: Omit<Infer<T>, '$type'>,\n ): Promise<PutOutput>\n public async put<const T extends RecordSchema>(\n ns: Namespace<T>,\n input: Omit<Infer<T>, '$type'>,\n options: PutOptions<T>,\n ): Promise<PutOutput>\n public async put<const T extends RecordSchema>(\n ns: Namespace<T>,\n input: Omit<Infer<T>, '$type'>,\n options: PutOptions<T> = {} as PutOptions<T>,\n ): Promise<PutOutput> {\n const schema = getMain(ns)\n const record = schema.build(input)\n const rkey = options.rkey ?? getLiteralRecordKey(schema)\n const response = await this.putRecord(record, rkey, options)\n return response.body\n }\n\n async list<const T extends RecordSchema>(\n ns: Namespace<T>,\n options?: ListOptions,\n ): Promise<ListOutput<T>> {\n const schema = getMain(ns)\n const { body } = await this.listRecords(schema.$type, options)\n\n const records: ListRecord<T>[] = []\n const invalid: LexMap[] = []\n\n for (const record of body.records) {\n const parsed = (schema as Schema<Infer<T>>).safeParse(record.value)\n if (parsed.success) {\n records.push({ ...record, value: parsed.value })\n } else {\n invalid.push(record.value)\n }\n }\n\n return { ...body, records, invalid }\n }\n}\n\nfunction getDefaultRecordKey<const T extends RecordSchema>(\n schema: T,\n): undefined | InferRecordKey<T> {\n // Let the server generate the TID\n if (schema.key === 'tid') return undefined\n if (schema.key === 'any') return undefined\n\n return getLiteralRecordKey(schema)\n}\n\nfunction getLiteralRecordKey<const T extends RecordSchema>(\n schema: T,\n): InferRecordKey<T> {\n if (schema.key.startsWith('literal:')) {\n return schema.key.slice(8)\n }\n\n throw new TypeError(\n `An \"rkey\" must be provided for record key type \"${schema.key}\" (${schema.$type})`,\n )\n}\n"]}
package/dist/error.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { LexValue } from '@atproto/lex-data';
2
- import { Infer, ObjectSchema, Procedure, Query, ResultFailure, StringSchema } from '@atproto/lex-schema';
2
+ import { l } from '@atproto/lex-schema';
3
3
  export declare enum KnownError {
4
4
  Unknown = "Unknown",
5
5
  AuthenticationRequired = "AuthenticationRequired",
@@ -17,36 +17,32 @@ export declare enum KnownError {
17
17
  UpstreamTimeout = "UpstreamTimeout",
18
18
  XRPCNotSupported = "XRPCNotSupported"
19
19
  }
20
- export type XrpcFailure<N extends string, E> = ResultFailure<E> & {
20
+ export type XrpcFailure<N extends string, E> = l.ResultFailure<E> & {
21
21
  name: N;
22
22
  };
23
- export type XrpcErrorName = Infer<typeof xrpcErrorNameSchema>;
24
- export declare const xrpcErrorNameSchema: StringSchema<{
23
+ export type XrpcErrorName = l.UnknownString | KnownError;
24
+ export declare const xrpcErrorNameSchema: l.StringSchema<{
25
25
  readonly minLength: 1;
26
- readonly knownValues: KnownError[];
27
26
  }>;
28
27
  export type XrpcErrorBody<N extends XrpcErrorName = XrpcErrorName> = {
29
28
  error: N;
30
29
  message?: string;
31
30
  };
32
- export declare const xrpcErrorBodySchema: ObjectSchema<{
33
- readonly error: StringSchema<{
31
+ export declare const xrpcErrorBodySchema: l.ObjectSchema<{
32
+ readonly error: l.StringSchema<{
34
33
  readonly minLength: 1;
35
- readonly knownValues: KnownError[];
36
34
  }>;
37
- readonly message: StringSchema<{}>;
38
- }, {
39
- readonly required: readonly ["error"];
40
- }, XrpcErrorBody<KnownError | import("@atproto/lex-schema").UnknownString>>;
35
+ readonly message: l.OptionalSchema<string>;
36
+ }>;
41
37
  /**
42
38
  * @implements {XrpcFailure<N, XrpcError<N>>} for convenience in result handling contexts.
43
39
  */
44
40
  export declare class XrpcError<N extends XrpcErrorName = XrpcErrorName> extends Error implements XrpcFailure<N, XrpcError<N>> {
45
41
  readonly name: N;
46
42
  constructor(name: N, message?: string, options?: ErrorOptions);
47
- /** @see {@link ResultFailure.success} */
43
+ /** @see {@link l.ResultFailure.success} */
48
44
  readonly success: false;
49
- /** @see {@link ResultFailure.error} */
45
+ /** @see {@link l.ResultFailure.error} */
50
46
  get error(): this;
51
47
  static from(cause: unknown, message?: string): XrpcError;
52
48
  }
@@ -63,8 +59,8 @@ export declare class XrpcResponseError<N extends XrpcErrorName = XrpcErrorName,
63
59
  readonly body: B;
64
60
  constructor(status: number, headers: Headers, encoding: undefined | string, body: B, options?: ErrorOptions);
65
61
  }
66
- export type XrpcRequestFailure<M extends Procedure | Query> = (M extends {
62
+ export type XrpcRequestFailure<M extends l.Procedure | l.Query> = (M extends {
67
63
  errors: readonly (infer N extends string)[];
68
64
  } ? XrpcResponseError<N> : never) | XrpcFailure<'Unknown', XrpcResponseError<string>> | XrpcFailure<'UnexpectedError', unknown>;
69
- export declare function asXrpcRequestFailureFor<M extends Procedure | Query>(schema: M): (error: unknown) => XrpcRequestFailure<M>;
65
+ export declare function asXrpcRequestFailureFor<M extends l.Procedure | l.Query>(schema: M): (error: unknown) => XrpcRequestFailure<M>;
70
66
  //# sourceMappingURL=error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EACL,KAAK,EACL,YAAY,EACZ,SAAS,EACT,KAAK,EACL,aAAa,EACb,YAAY,EAEb,MAAM,qBAAqB,CAAA;AAE5B,oBAAY,UAAU;IACpB,OAAO,YAAY;IACnB,sBAAsB,2BAA2B;IACjD,SAAS,cAAc;IACvB,mBAAmB,wBAAwB;IAC3C,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;IACnC,oBAAoB,yBAAyB;IAC7C,aAAa,kBAAkB;IAC/B,kBAAkB,uBAAuB;IACzC,eAAe,oBAAoB;IACnC,iBAAiB,sBAAsB;IACvC,oBAAoB,yBAAyB;IAC7C,eAAe,oBAAoB;IACnC,eAAe,oBAAoB;IACnC,gBAAgB,qBAAqB;CACtC;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,GAAG;IAChE,IAAI,EAAE,CAAC,CAAA;CACR,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAC7D,eAAO,MAAM,mBAAmB;;0BAEU,UAAU,EAAE;EACpD,CAAA;AAEF,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,IAAI;IACnE,KAAK,EAAE,CAAC,CAAA;IACR,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AACD,eAAO,MAAM,mBAAmB;;;8BAPU,UAAU,EAAE;;;;;2EAUlB,CAAA;AAEpC;;GAEG;AACH,qBAAa,SAAS,CAAC,CAAC,SAAS,aAAa,GAAG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G,MAAM;aAC5B,IAAI,EAAE,CAAC;gBAHP,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,SAAS,GAAG,MAAM,EAC5B,IAAI,EAAE,CAAC,EACvB,OAAO,CAAC,EAAE,YAAY;CAIzB;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,KAAK,IAE1D,CAAC,CAAC,SAAS;IAAE,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,SAAS,MAAM,CAAC,EAAE,CAAA;CAAE,GACtD,iBAAiB,CAAC,CAAC,CAAC,GACpB,KAAK,CAAC,GAGV,WAAW,CAAC,SAAS,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAEjD,WAAW,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAA;AAE3C,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,KAAK,EACrE,MAAM,EAAE,CAAC,GAGmC,CAC1C,KAAK,EAAE,OAAO,KACX,kBAAkB,CAAC,CAAC,CAAC,CAC3B"}
package/dist/error.js CHANGED
@@ -21,11 +21,13 @@ var KnownError;
21
21
  KnownError["UpstreamTimeout"] = "UpstreamTimeout";
22
22
  KnownError["XRPCNotSupported"] = "XRPCNotSupported";
23
23
  })(KnownError || (exports.KnownError = KnownError = {}));
24
- exports.xrpcErrorNameSchema = new lex_schema_1.StringSchema({
24
+ exports.xrpcErrorNameSchema = lex_schema_1.l.string({
25
25
  minLength: 1,
26
- knownValues: Object.keys(KnownError),
27
26
  });
28
- exports.xrpcErrorBodySchema = new lex_schema_1.ObjectSchema({ error: exports.xrpcErrorNameSchema, message: new lex_schema_1.StringSchema({}) }, { required: ['error'] });
27
+ exports.xrpcErrorBodySchema = lex_schema_1.l.object({
28
+ error: exports.xrpcErrorNameSchema,
29
+ message: lex_schema_1.l.optional(lex_schema_1.l.string()),
30
+ });
29
31
  /**
30
32
  * @implements {XrpcFailure<N, XrpcError<N>>} for convenience in result handling contexts.
31
33
  */
@@ -42,9 +44,9 @@ class XrpcError extends Error {
42
44
  super(message, options);
43
45
  this.name = name;
44
46
  }
45
- /** @see {@link ResultFailure.success} */
47
+ /** @see {@link l.ResultFailure.success} */
46
48
  success = false;
47
- /** @see {@link ResultFailure.error} */
49
+ /** @see {@link l.ResultFailure.error} */
48
50
  get error() {
49
51
  return this;
50
52
  }
package/dist/error.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;;AAmIA,0DAOC;AAzID,oDAQ4B;AAE5B,IAAY,UAgBX;AAhBD,WAAY,UAAU;IACpB,iCAAmB,CAAA;IACnB,+DAAiD,CAAA;IACjD,qCAAuB,CAAA;IACvB,yDAA2C,CAAA;IAC3C,+CAAiC,CAAA;IACjC,iDAAmC,CAAA;IACnC,2DAA6C,CAAA;IAC7C,6CAA+B,CAAA;IAC/B,uDAAyC,CAAA;IACzC,iDAAmC,CAAA;IACnC,qDAAuC,CAAA;IACvC,2DAA6C,CAAA;IAC7C,iDAAmC,CAAA;IACnC,iDAAmC,CAAA;IACnC,mDAAqC,CAAA;AACvC,CAAC,EAhBW,UAAU,0BAAV,UAAU,QAgBrB;AAOY,QAAA,mBAAmB,GAAG,IAAI,yBAAY,CAAC;IAClD,SAAS,EAAE,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAiB;CACrD,CAAC,CAAA;AAMW,QAAA,mBAAmB,GAAG,IAAI,yBAAY,CACjD,EAAE,KAAK,EAAE,2BAAmB,EAAE,OAAO,EAAE,IAAI,yBAAY,CAAC,EAAE,CAAC,EAAE,EAC7D,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CACW,CAAA;AAEpC;;GAEG;AACH,MAAa,SACX,SAAQ,KAAK;IAIK;IADlB,YACkB,IAAO,EACvB,UAAkB,IAAI,K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,EAChB,QAA4B,EAC5B,IAAO,EACvB,OAAsB;QAEtB,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QANxB,WAAM,GAAN,MAAM,CAAQ;QACd,YAAO,GAAP,OAAO,CAAS;QAChB,aAAQ,GAAR,QAAQ,CAAoB;QAC5B,SAAI,GAAJ,IAAI,CAAG;IAIzB,CAAC;CACF;AAbD,8CAaC;AAaD,SAAgB,uBAAuB,CACrC,MAAS;IAET,iFAAiF;IACjF,OAAO,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAEb,CAAA;AAC5B,CAAC;AAED,SAAS,oBAAoB,CAE3B,KAAc;IAEd,IAAI,CAAC,CAAC,KAAK,YAAY,iBAAiB,CAAC,EAAE,CAAC;QAC1C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAA;IAC3D,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAA;IACnD,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import { LexValue } from '@atproto/lex-data'\nimport {\n Infer,\n ObjectSchema,\n Procedure,\n Query,\n ResultFailure,\n StringSchema,\n Validator,\n} from '@atproto/lex-schema'\n\nexport enum KnownError {\n Unknown = 'Unknown',\n AuthenticationRequired = 'AuthenticationRequired',\n Forbidden = 'Forbidden',\n InternalServerError = 'InternalServerError',\n InvalidRequest = 'InvalidRequest',\n InvalidResponse = 'InvalidResponse',\n MethodNotImplemented = 'MethodNotImplemented',\n NotAcceptable = 'NotAcceptable',\n NotEnoughResources = 'NotEnoughResources',\n PayloadTooLarge = 'PayloadTooLarge',\n RateLimitExceeded = 'RateLimitExceeded',\n UnsupportedMediaType = 'UnsupportedMediaType',\n UpstreamFailure = 'UpstreamFailure',\n UpstreamTimeout = 'UpstreamTimeout',\n XRPCNotSupported = 'XRPCNotSupported',\n}\n\nexport type XrpcFailure<N extends string, E> = ResultFailure<E> & {\n name: N\n}\n\nexport type XrpcErrorName = Infer<typeof xrpcErrorNameSchema>\nexport const xrpcErrorNameSchema = new StringSchema({\n minLength: 1,\n knownValues: Object.keys(KnownError) as KnownError[],\n})\n\nexport type XrpcErrorBody<N extends XrpcErrorName = XrpcErrorName> = {\n error: N\n message?: string\n}\nexport const xrpcErrorBodySchema = new ObjectSchema(\n { error: xrpcErrorNameSchema, message: new StringSchema({}) },\n { required: ['error'] },\n) satisfies Validator<XrpcErrorBody>\n\n/**\n * @implements {XrpcFailure<N, XrpcError<N>>} for convenience in result handling contexts.\n */\nexport class XrpcError<N extends XrpcErrorName = XrpcErrorName>\n extends Error\n implements XrpcFailure<N, XrpcError<N>>\n{\n constructor(\n public readonly name: N,\n message: string = name === KnownError.InvalidResponse\n ? `XRPC service returned an invalid response`\n : name === KnownError.InternalServerError\n ? `XRPC service encountered an internal error`\n : name === KnownError.UpstreamFailure ||\n name === KnownError.UpstreamTimeout\n ? `XRPC service upstream error`\n : `XRPC ${name} error`,\n options?: ErrorOptions,\n ) {\n super(message, options)\n }\n\n /** @see {@link ResultFailure.success} */\n readonly success = false as const\n\n /** @see {@link ResultFailure.error} */\n get error(): this {\n return this\n }\n\n static from(cause: unknown, message?: string): XrpcError {\n if (cause instanceof XrpcError) {\n return cause\n }\n return new XrpcError(\n 'Unknown',\n message ?? (cause instanceof Error ? cause.message : undefined),\n { cause },\n )\n }\n}\n\nexport class XrpcServiceError<\n N extends XrpcErrorName = XrpcErrorName,\n> extends XrpcError<N> {\n constructor(\n name: N,\n public readonly status: number,\n public readonly headers: Headers,\n public readonly body: undefined | LexValue,\n message?: string,\n options?: ErrorOptions,\n ) {\n super(name, message, options)\n }\n}\n\nexport class XrpcResponseError<\n N extends XrpcErrorName = XrpcErrorName,\n B extends XrpcErrorBody<N> = XrpcErrorBody<N>,\n> extends XrpcError<N> {\n constructor(\n public readonly status: number,\n public readonly headers: Headers,\n public readonly encoding: undefined | string,\n public readonly body: B,\n options?: ErrorOptions,\n ) {\n super(body.error, body.message, options)\n }\n}\n\nexport type XrpcRequestFailure<M extends Procedure | Query> =\n // The server responded with a declared error.\n | (M extends { errors: readonly (infer N extends string)[] }\n ? XrpcResponseError<N> // implements XrpcRequestFailure<N, XrpcResponseError<N>>\n : never)\n // The server responded with an error that is not declared in the method's\n // `errors` list.\n | XrpcFailure<'Unknown', XrpcResponseError<string>>\n // An unexpected error occurred (e.g., network error, invalid response, etc.)\n | XrpcFailure<'UnexpectedError', unknown>\n\nexport function asXrpcRequestFailureFor<M extends Procedure | Query>(\n schema: M,\n) {\n // Performance: Using .bind instead of arrow function to avoid creating a closure\n return asXrpcRequestFailure.bind(schema) as (\n error: unknown,\n ) => XrpcRequestFailure<M>\n}\n\nfunction asXrpcRequestFailure<M extends Procedure | Query>(\n this: M,\n error: unknown,\n): XrpcRequestFailure<M> {\n if (!(error instanceof XrpcResponseError)) {\n return { success: false, error, name: 'UnexpectedError' }\n }\n\n if (!this.errors.includes(error.name)) {\n return { success: false, error, name: 'Unknown' }\n }\n\n return error\n}\n"]}
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;;AA0HA,0DAOC;AAhID,oDAAuC;AAEvC,IAAY,UAgBX;AAhBD,WAAY,UAAU;IACpB,iCAAmB,CAAA;IACnB,+DAAiD,CAAA;IACjD,qCAAuB,CAAA;IACvB,yDAA2C,CAAA;IAC3C,+CAAiC,CAAA;IACjC,iDAAmC,CAAA;IACnC,2DAA6C,CAAA;IAC7C,6CAA+B,CAAA;IAC/B,uDAAyC,CAAA;IACzC,iDAAmC,CAAA;IACnC,qDAAuC,CAAA;IACvC,2DAA6C,CAAA;IAC7C,iDAAmC,CAAA;IACnC,iDAAmC,CAAA;IACnC,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esContent":["import { LexValue } from '@atproto/lex-data'\nimport { l } from '@atproto/lex-schema'\n\nexport enum KnownError {\n Unknown = 'Unknown',\n AuthenticationRequired = 'AuthenticationRequired',\n Forbidden = 'Forbidden',\n InternalServerError = 'InternalServerError',\n InvalidRequest = 'InvalidRequest',\n InvalidResponse = 'InvalidResponse',\n MethodNotImplemented = 'MethodNotImplemented',\n NotAcceptable = 'NotAcceptable',\n NotEnoughResources = 'NotEnoughResources',\n PayloadTooLarge = 'PayloadTooLarge',\n RateLimitExceeded = 'RateLimitExceeded',\n UnsupportedMediaType = 'UnsupportedMediaType',\n UpstreamFailure = 'UpstreamFailure',\n UpstreamTimeout = 'UpstreamTimeout',\n XRPCNotSupported = 'XRPCNotSupported',\n}\n\nexport type XrpcFailure<N extends string, E> = l.ResultFailure<E> & {\n name: N\n}\n\nexport type XrpcErrorName = l.UnknownString | KnownError\nexport const xrpcErrorNameSchema = l.string({\n minLength: 1,\n})\n\nexport type XrpcErrorBody<N extends XrpcErrorName = XrpcErrorName> = {\n error: N\n message?: string\n}\nexport const xrpcErrorBodySchema = l.object({\n error: xrpcErrorNameSchema,\n message: l.optional(l.string()),\n})\n\n/**\n * @implements {XrpcFailure<N, XrpcError<N>>} for convenience in result handling contexts.\n */\nexport class XrpcError<N extends XrpcErrorName = XrpcErrorName>\n extends Error\n implements XrpcFailure<N, XrpcError<N>>\n{\n constructor(\n public readonly name: N,\n message: string = name === KnownError.InvalidResponse\n ? `XRPC service returned an invalid response`\n : name === KnownError.InternalServerError\n ? `XRPC service encountered an internal error`\n : name === KnownError.UpstreamFailure ||\n name === KnownError.UpstreamTimeout\n ? `XRPC service upstream error`\n : `XRPC ${name} error`,\n options?: ErrorOptions,\n ) {\n super(message, options)\n }\n\n /** @see {@link l.ResultFailure.success} */\n readonly success = false as const\n\n /** @see {@link l.ResultFailure.error} */\n get error(): this {\n return this\n }\n\n static from(cause: unknown, message?: string): XrpcError {\n if (cause instanceof XrpcError) {\n return cause\n }\n return new XrpcError(\n 'Unknown',\n message ?? (cause instanceof Error ? cause.message : undefined),\n { cause },\n )\n }\n}\n\nexport class XrpcServiceError<\n N extends XrpcErrorName = XrpcErrorName,\n> extends XrpcError<N> {\n constructor(\n name: N,\n public readonly status: number,\n public readonly headers: Headers,\n public readonly body: undefined | LexValue,\n message?: string,\n options?: ErrorOptions,\n ) {\n super(name, message, options)\n }\n}\n\nexport class XrpcResponseError<\n N extends XrpcErrorName = XrpcErrorName,\n B extends XrpcErrorBody<N> = XrpcErrorBody<N>,\n> extends XrpcError<N> {\n constructor(\n public readonly status: number,\n public readonly headers: Headers,\n public readonly encoding: undefined | string,\n public readonly body: B,\n options?: ErrorOptions,\n ) {\n super(body.error, body.message, options)\n }\n}\n\nexport type XrpcRequestFailure<M extends l.Procedure | l.Query> =\n // The server responded with a declared error.\n | (M extends { errors: readonly (infer N extends string)[] }\n ? XrpcResponseError<N> // implements XrpcRequestFailure<N, XrpcResponseError<N>>\n : never)\n // The server responded with an error that is not declared in the method's\n // `errors` list.\n | XrpcFailure<'Unknown', XrpcResponseError<string>>\n // An unexpected error occurred (e.g., network error, invalid response, etc.)\n | XrpcFailure<'UnexpectedError', unknown>\n\nexport function asXrpcRequestFailureFor<M extends l.Procedure | l.Query>(\n schema: M,\n) {\n // Performance: Using .bind instead of arrow function to avoid creating a closure\n return asXrpcRequestFailure.bind(schema) as (\n error: unknown,\n ) => XrpcRequestFailure<M>\n}\n\nfunction asXrpcRequestFailure<M extends l.Procedure | l.Query>(\n this: M,\n error: unknown,\n): XrpcRequestFailure<M> {\n if (!(error instanceof XrpcResponseError)) {\n return { success: false, error, name: 'UnexpectedError' }\n }\n\n if (!this.errors.includes(error.name)) {\n return { success: false, error, name: 'Unknown' }\n }\n\n return error\n}\n"]}
@@ -5,31 +5,17 @@ export { $nsid };
5
5
  /**
6
6
  * Create a single new repository record. Requires auth, implemented by PDS.
7
7
  */
8
- declare const main: l.Procedure<"com.atproto.repo.createRecord", l.ParamsSchema<{}, l.ParamsSchemaOptions, {}>, l.Payload<"application/json", l.ObjectSchema<{
8
+ declare const main: l.Procedure<"com.atproto.repo.createRecord", l.ParamsSchema<{}>, l.Payload<"application/json", l.ObjectSchema<{
9
9
  readonly repo: l.StringSchema<{
10
10
  readonly format: "at-identifier";
11
11
  }>;
12
12
  readonly collection: l.StringSchema<{
13
13
  readonly format: "nsid";
14
14
  }>;
15
- readonly rkey: l.StringSchema<{
16
- readonly format: "record-key";
17
- readonly maxLength: 512;
18
- }>;
19
- readonly validate: l.BooleanSchema;
15
+ readonly rkey: l.OptionalSchema<string>;
16
+ readonly validate: l.OptionalSchema<boolean>;
20
17
  readonly record: l.UnknownObjectSchema;
21
- readonly swapCommit: l.StringSchema<{
22
- readonly format: "cid";
23
- }>;
24
- }, {
25
- readonly required: readonly ["repo", "collection", "record"];
26
- }, {
27
- repo: l.AtIdentifier;
28
- collection: `${string}.${string}.${string}`;
29
- record: l.LexMap;
30
- rkey?: string | undefined;
31
- swapCommit?: string | undefined;
32
- validate?: boolean | undefined;
18
+ readonly swapCommit: l.OptionalSchema<string>;
33
19
  }>>, l.Payload<"application/json", l.ObjectSchema<{
34
20
  readonly uri: l.StringSchema<{
35
21
  readonly format: "at-uri";
@@ -37,44 +23,21 @@ declare const main: l.Procedure<"com.atproto.repo.createRecord", l.ParamsSchema<
37
23
  readonly cid: l.StringSchema<{
38
24
  readonly format: "cid";
39
25
  }>;
40
- readonly commit: l.RefSchema<RepoDefs.CommitMeta>;
41
- readonly validationStatus: l.StringSchema<{
42
- readonly knownValues: readonly ["valid", "unknown"];
43
- }>;
44
- }, {
45
- readonly required: readonly ["uri", "cid"];
46
- }, {
47
- uri: `at://did:${string}:${string}/${string}.${string}.${string}/${string}` | `at://${string}.${string}/${string}.${string}.${string}/${string}`;
48
- cid: string;
49
- validationStatus?: l.UnknownString | "unknown" | "valid" | undefined;
50
- commit?: RepoDefs.CommitMeta | undefined;
26
+ readonly commit: l.OptionalSchema<RepoDefs.CommitMeta>;
27
+ readonly validationStatus: l.OptionalSchema<string>;
51
28
  }>>, readonly ["InvalidSwap"]>;
52
29
  export { main };
53
- export declare const $params: l.ParamsSchema<{}, l.ParamsSchemaOptions, {}>, $input: l.Payload<"application/json", l.ObjectSchema<{
30
+ export declare const $params: l.ParamsSchema<{}>, $input: l.Payload<"application/json", l.ObjectSchema<{
54
31
  readonly repo: l.StringSchema<{
55
32
  readonly format: "at-identifier";
56
33
  }>;
57
34
  readonly collection: l.StringSchema<{
58
35
  readonly format: "nsid";
59
36
  }>;
60
- readonly rkey: l.StringSchema<{
61
- readonly format: "record-key";
62
- readonly maxLength: 512;
63
- }>;
64
- readonly validate: l.BooleanSchema;
37
+ readonly rkey: l.OptionalSchema<string>;
38
+ readonly validate: l.OptionalSchema<boolean>;
65
39
  readonly record: l.UnknownObjectSchema;
66
- readonly swapCommit: l.StringSchema<{
67
- readonly format: "cid";
68
- }>;
69
- }, {
70
- readonly required: readonly ["repo", "collection", "record"];
71
- }, {
72
- repo: l.AtIdentifier;
73
- collection: `${string}.${string}.${string}`;
74
- record: l.LexMap;
75
- rkey?: string | undefined;
76
- swapCommit?: string | undefined;
77
- validate?: boolean | undefined;
40
+ readonly swapCommit: l.OptionalSchema<string>;
78
41
  }>>, $output: l.Payload<"application/json", l.ObjectSchema<{
79
42
  readonly uri: l.StringSchema<{
80
43
  readonly format: "at-uri";
@@ -82,17 +45,8 @@ export declare const $params: l.ParamsSchema<{}, l.ParamsSchemaOptions, {}>, $in
82
45
  readonly cid: l.StringSchema<{
83
46
  readonly format: "cid";
84
47
  }>;
85
- readonly commit: l.RefSchema<RepoDefs.CommitMeta>;
86
- readonly validationStatus: l.StringSchema<{
87
- readonly knownValues: readonly ["valid", "unknown"];
88
- }>;
89
- }, {
90
- readonly required: readonly ["uri", "cid"];
91
- }, {
92
- uri: `at://did:${string}:${string}/${string}.${string}.${string}/${string}` | `at://${string}.${string}/${string}.${string}.${string}/${string}`;
93
- cid: string;
94
- validationStatus?: l.UnknownString | "unknown" | "valid" | undefined;
95
- commit?: RepoDefs.CommitMeta | undefined;
48
+ readonly commit: l.OptionalSchema<RepoDefs.CommitMeta>;
49
+ readonly validationStatus: l.OptionalSchema<string>;
96
50
  }>>;
97
51
  export type Params = l.InferProcedureParameters<typeof main>;
98
52
  export type Input = l.InferProcedureInputBody<typeof main>;
@@ -1 +1 @@
1
- {"version":3,"file":"createRecord.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/createRecord.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAE1C,QAAA,MAAM,KAAK,kCAAkC,CAAA;AAE7C,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB;;GAEG;AACH,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAuCP,CAAA;AACH,OAAO,EAAE,IAAI,EAAE,CAAA;AAEf,eAAO,MAAM,OAAO,+CAAgC,EAClD,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;GAA2B,EACjC,OAAO;;;;;;;;;;;;;;;;;;GAA4B,CAAA;AAErC,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,wBAAwB,CAAC,OAAO,IAAI,CAAC,CAAA;AAC5D,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,uBAAuB,CAAC,OAAO,IAAI,CAAC,CAAA;AAC1D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,wBAAwB,CAAC,OAAO,IAAI,CAAC,CAAA"}
1
+ {"version":3,"file":"createRecord.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/createRecord.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAE1C,QAAA,MAAM,KAAK,kCAAkC,CAAA;AAE7C,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB;;GAEG;AACH,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;8BAkCP,CAAA;AACH,OAAO,EAAE,IAAI,EAAE,CAAA;AAEf,eAAO,MAAM,OAAO,oBAAgC,EAClD,MAAM;;;;;;;;;;;GAA2B,EACjC,OAAO;;;;;;;;;GAA4B,CAAA;AAErC,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,wBAAwB,CAAC,OAAO,IAAI,CAAC,CAAA;AAC5D,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,uBAAuB,CAAC,OAAO,IAAI,CAAC,CAAA;AAC1D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,wBAAwB,CAAC,OAAO,IAAI,CAAC,CAAA"}
@@ -20,23 +20,21 @@ lex_schema_1.l.procedure($nsid,
20
20
  /*#__PURE__*/ lex_schema_1.l.object({
21
21
  repo: /*#__PURE__*/ lex_schema_1.l.string({ format: 'at-identifier' }),
22
22
  collection: /*#__PURE__*/ lex_schema_1.l.string({ format: 'nsid' }),
23
- rkey: /*#__PURE__*/ lex_schema_1.l.string({
24
- format: 'record-key',
25
- maxLength: 512,
26
- }),
27
- validate: /*#__PURE__*/ lex_schema_1.l.boolean(),
23
+ rkey: /*#__PURE__*/ lex_schema_1.l.optional(
24
+ /*#__PURE__*/ lex_schema_1.l.string({ format: 'record-key', maxLength: 512 })),
25
+ validate: /*#__PURE__*/ lex_schema_1.l.optional(/*#__PURE__*/ lex_schema_1.l.boolean()),
28
26
  record: /*#__PURE__*/ lex_schema_1.l.unknownObject(),
29
- swapCommit: /*#__PURE__*/ lex_schema_1.l.string({ format: 'cid' }),
30
- }, { required: ['repo', 'collection', 'record'] })),
27
+ swapCommit: /*#__PURE__*/ lex_schema_1.l.optional(
28
+ /*#__PURE__*/ lex_schema_1.l.string({ format: 'cid' })),
29
+ })),
31
30
  /*#__PURE__*/ lex_schema_1.l.payload('application/json',
32
31
  /*#__PURE__*/ lex_schema_1.l.object({
33
32
  uri: /*#__PURE__*/ lex_schema_1.l.string({ format: 'at-uri' }),
34
33
  cid: /*#__PURE__*/ lex_schema_1.l.string({ format: 'cid' }),
35
- commit: /*#__PURE__*/ lex_schema_1.l.ref((() => RepoDefs.commitMeta)),
36
- validationStatus: /*#__PURE__*/ lex_schema_1.l.string({
37
- knownValues: ['valid', 'unknown'],
38
- }),
39
- }, { required: ['uri', 'cid'] })), ['InvalidSwap']);
34
+ commit: /*#__PURE__*/ lex_schema_1.l.optional(
35
+ /*#__PURE__*/ lex_schema_1.l.ref((() => RepoDefs.commitMeta))),
36
+ validationStatus: /*#__PURE__*/ lex_schema_1.l.optional(/*#__PURE__*/ lex_schema_1.l.string()),
37
+ })), ['InvalidSwap']);
40
38
  exports.main = main;
41
39
  exports.$params = main.parameters, exports.$input = main.input, exports.$output = main.output;
42
40
  //# sourceMappingURL=createRecord.defs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createRecord.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/createRecord.defs.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,oDAAuC;AACvC,iEAA0C;AAE1C,MAAM,KAAK,GAAG,+BAA+B,CAAA;AAEpC,sBAAK;AAEd;;GAEG;AACH,MAAM,IAAI;AACR,aAAa;AACb,cAAC,CAAC,SAAS,CACT,KAAK;AACL,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,CAAC;AAC1B,aAAa,CAAC,cAAC,CAAC,OAAO,CACrB,kBAAkB;AAClB,aAAa,CAAC,cAAC,CAAC,MAAM,CACpB;IACE,IAAI,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;IACzD,UAAU,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACtD,IAAI,EAAE,aAAa,CAAC,cAAC,CAAC,M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s.js'\n\nconst $nsid = 'com.atproto.repo.createRecord'\n\nexport { $nsid }\n\n/**\n * Create a single new repository record. Requires auth, implemented by PDS.\n */\nconst main =\n /*#__PURE__*/\n l.procedure(\n $nsid,\n /*#__PURE__*/ l.params({}),\n /*#__PURE__*/ l.payload(\n 'application/json',\n /*#__PURE__*/ l.object(\n {\n repo: /*#__PURE__*/ l.string({ format: 'at-identifier' }),\n collection: /*#__PURE__*/ l.string({ format: 'nsid' }),\n rkey: /*#__PURE__*/ l.string({\n format: 'record-key',\n maxLength: 512,\n }),\n validate: /*#__PURE__*/ l.boolean(),\n record: /*#__PURE__*/ l.unknownObject(),\n swapCommit: /*#__PURE__*/ l.string({ format: 'cid' }),\n },\n { required: ['repo', 'collection', 'record'] },\n ),\n ),\n /*#__PURE__*/ l.payload(\n 'application/json',\n /*#__PURE__*/ l.object(\n {\n uri: /*#__PURE__*/ l.string({ format: 'at-uri' }),\n cid: /*#__PURE__*/ l.string({ format: 'cid' }),\n commit: /*#__PURE__*/ l.ref<RepoDefs.CommitMeta>(\n (() => RepoDefs.commitMeta) as any,\n ),\n validationStatus: /*#__PURE__*/ l.string({\n knownValues: ['valid', 'unknown'],\n }),\n },\n { required: ['uri', 'cid'] },\n ),\n ),\n ['InvalidSwap'],\n )\nexport { main }\n\nexport const $params = /*#__PURE__*/ main.parameters,\n $input = /*#__PURE__*/ main.input,\n $output = /*#__PURE__*/ main.output\n\nexport type Params = l.InferProcedureParameters<typeof main>\nexport type Input = l.InferProcedureInputBody<typeof main>\nexport type Output = l.InferProcedureOutputBody<typeof main>\n"]}
1
+ {"version":3,"file":"createRecord.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/createRecord.defs.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,oDAAuC;AACvC,iEAA0C;AAE1C,MAAM,KAAK,GAAG,+BAA+B,CAAA;AAEpC,sBAAK;AAEd;;GAEG;AACH,MAAM,IAAI;AACR,aAAa;AACb,cAAC,CA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,CACF;IACD,gBAAgB,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAC,CAAC,MAAM,EAAE,CAAC;CACrE,CAAC,CACH,EACD,CAAC,aAAa,CAAC,CAChB,CAAA;AACM,oBAAI;AAEA,QAAA,OAAO,GAAiB,IAAI,CAAC,UAAU,EAClD,QAAA,MAAM,GAAiB,IAAI,CAAC,KAAK,EACjC,QAAA,OAAO,GAAiB,IAAI,CAAC,MAAM,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex-schema'\nimport * as RepoDefs from './defs.defs.js'\n\nconst $nsid = 'com.atproto.repo.createRecord'\n\nexport { $nsid }\n\n/**\n * Create a single new repository record. Requires auth, implemented by PDS.\n */\nconst main =\n /*#__PURE__*/\n l.procedure(\n $nsid,\n /*#__PURE__*/ l.params({}),\n /*#__PURE__*/ l.payload(\n 'application/json',\n /*#__PURE__*/ l.object({\n repo: /*#__PURE__*/ l.string({ format: 'at-identifier' }),\n collection: /*#__PURE__*/ l.string({ format: 'nsid' }),\n rkey: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.string({ format: 'record-key', maxLength: 512 }),\n ),\n validate: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.boolean()),\n record: /*#__PURE__*/ l.unknownObject(),\n swapCommit: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.string({ format: 'cid' }),\n ),\n }),\n ),\n /*#__PURE__*/ l.payload(\n 'application/json',\n /*#__PURE__*/ l.object({\n uri: /*#__PURE__*/ l.string({ format: 'at-uri' }),\n cid: /*#__PURE__*/ l.string({ format: 'cid' }),\n commit: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.ref<RepoDefs.CommitMeta>(\n (() => RepoDefs.commitMeta) as any,\n ),\n ),\n validationStatus: /*#__PURE__*/ l.optional(/*#__PURE__*/ l.string()),\n }),\n ),\n ['InvalidSwap'],\n )\nexport { main }\n\nexport const $params = /*#__PURE__*/ main.parameters,\n $input = /*#__PURE__*/ main.input,\n $output = /*#__PURE__*/ main.output\n\nexport type Params = l.InferProcedureParameters<typeof main>\nexport type Input = l.InferProcedureInputBody<typeof main>\nexport type Output = l.InferProcedureOutputBody<typeof main>\n"]}
@@ -3,10 +3,10 @@ declare const $nsid = "com.atproto.repo.defs";
3
3
  export { $nsid };
4
4
  type CommitMeta = {
5
5
  $type?: 'com.atproto.repo.defs#commitMeta';
6
- cid: string;
7
- rev: string;
6
+ cid: l.CidString;
7
+ rev: l.TidString;
8
8
  };
9
9
  export type { CommitMeta };
10
- declare const commitMeta: l.TypedObjectSchema<"com.atproto.repo.defs#commitMeta", l.Validator<Omit<CommitMeta, "$type">>, CommitMeta>;
10
+ declare const commitMeta: l.TypedObjectSchema<"com.atproto.repo.defs#commitMeta", l.Validator<Omit<CommitMeta, "$type">>>;
11
11
  export { commitMeta };
12
12
  //# sourceMappingURL=defs.defs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"defs.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/defs.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AAEvC,QAAA,MAAM,KAAK,0BAA0B,CAAA;AAErC,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,KAAK,UAAU,GAAG;IAChB,KAAK,CAAC,EAAE,kCAAkC,CAAA;IAC1C,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,YAAY,EAAE,UAAU,EAAE,CAAA;AAE1B,QAAA,MAAM,UAAU,6GAUf,CAAA;AAED,OAAO,EAAE,UAAU,EAAE,CAAA"}
1
+ {"version":3,"file":"defs.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/defs.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AAEvC,QAAA,MAAM,KAAK,0BAA0B,CAAA;AAErC,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB,KAAK,UAAU,GAAG;IAChB,KAAK,CAAC,EAAE,kCAAkC,CAAA;IAC1C,GAAG,EAAE,CAAC,CAAC,SAAS,CAAA;IAChB,GAAG,EAAE,CAAC,CAAC,SAAS,CAAA;CACjB,CAAA;AAED,YAAY,EAAE,UAAU,EAAE,CAAA;AAE1B,QAAA,MAAM,UAAU,iGAOf,CAAA;AAED,OAAO,EAAE,UAAU,EAAE,CAAA"}
@@ -11,6 +11,6 @@ const commitMeta = /*#__PURE__*/ lex_schema_1.l.typedObject($nsid, 'commitMeta',
11
11
  /*#__PURE__*/ lex_schema_1.l.object({
12
12
  cid: /*#__PURE__*/ lex_schema_1.l.string({ format: 'cid' }),
13
13
  rev: /*#__PURE__*/ lex_schema_1.l.string({ format: 'tid' }),
14
- }, { required: ['cid', 'rev'] }));
14
+ }));
15
15
  exports.commitMeta = commitMeta;
16
16
  //# sourceMappingURL=defs.defs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defs.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/defs.defs.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,oDAAuC;AAEvC,MAAM,KAAK,GAAG,uBAAuB,CAAA;AAE5B,sBAAK;AAUd,MAAM,UAAU,GAAG,aAAa,CAAC,cAAC,CAAC,WAAW,CAC5C,KAAK,EACL,YAAY;AACZ,aAAa,CAAC,cAAC,CAAC,MAAM,CACpB;IACE,GAAG,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC9C,GAAG,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;CAC/C,EACD,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAC7B,CACF,CAAA;AAEQ,gCAAU","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex-schema'\n\nconst $nsid = 'com.atproto.repo.defs'\n\nexport { $nsid }\n\ntype CommitMeta = {\n $type?: 'com.atproto.repo.defs#commitMeta'\n cid: string\n rev: string\n}\n\nexport type { CommitMeta }\n\nconst commitMeta = /*#__PURE__*/ l.typedObject<CommitMeta>(\n $nsid,\n 'commitMeta',\n /*#__PURE__*/ l.object(\n {\n cid: /*#__PURE__*/ l.string({ format: 'cid' }),\n rev: /*#__PURE__*/ l.string({ format: 'tid' }),\n },\n { required: ['cid', 'rev'] },\n ),\n)\n\nexport { commitMeta }\n"]}
1
+ {"version":3,"file":"defs.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/defs.defs.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,oDAAuC;AAEvC,MAAM,KAAK,GAAG,uBAAuB,CAAA;AAE5B,sBAAK;AAUd,MAAM,UAAU,GAAG,aAAa,CAAC,cAAC,CAAC,WAAW,CAC5C,KAAK,EACL,YAAY;AACZ,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC;IACrB,GAAG,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC9C,GAAG,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;CAC/C,CAAC,CACH,CAAA;AAEQ,gCAAU","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex-schema'\n\nconst $nsid = 'com.atproto.repo.defs'\n\nexport { $nsid }\n\ntype CommitMeta = {\n $type?: 'com.atproto.repo.defs#commitMeta'\n cid: l.CidString\n rev: l.TidString\n}\n\nexport type { CommitMeta }\n\nconst commitMeta = /*#__PURE__*/ l.typedObject<CommitMeta>(\n $nsid,\n 'commitMeta',\n /*#__PURE__*/ l.object({\n cid: /*#__PURE__*/ l.string({ format: 'cid' }),\n rev: /*#__PURE__*/ l.string({ format: 'tid' }),\n }),\n)\n\nexport { commitMeta }\n"]}
@@ -5,7 +5,7 @@ export { $nsid };
5
5
  /**
6
6
  * Delete a repository record, or ensure it doesn't exist. Requires auth, implemented by PDS.
7
7
  */
8
- declare const main: l.Procedure<"com.atproto.repo.deleteRecord", l.ParamsSchema<{}, l.ParamsSchemaOptions, {}>, l.Payload<"application/json", l.ObjectSchema<{
8
+ declare const main: l.Procedure<"com.atproto.repo.deleteRecord", l.ParamsSchema<{}>, l.Payload<"application/json", l.ObjectSchema<{
9
9
  readonly repo: l.StringSchema<{
10
10
  readonly format: "at-identifier";
11
11
  }>;
@@ -15,27 +15,13 @@ declare const main: l.Procedure<"com.atproto.repo.deleteRecord", l.ParamsSchema<
15
15
  readonly rkey: l.StringSchema<{
16
16
  readonly format: "record-key";
17
17
  }>;
18
- readonly swapRecord: l.StringSchema<{
19
- readonly format: "cid";
20
- }>;
21
- readonly swapCommit: l.StringSchema<{
22
- readonly format: "cid";
23
- }>;
24
- }, {
25
- readonly required: readonly ["repo", "collection", "rkey"];
26
- }, {
27
- repo: l.AtIdentifier;
28
- collection: `${string}.${string}.${string}`;
29
- rkey: string;
30
- swapCommit?: string | undefined;
31
- swapRecord?: string | undefined;
18
+ readonly swapRecord: l.OptionalSchema<string>;
19
+ readonly swapCommit: l.OptionalSchema<string>;
32
20
  }>>, l.Payload<"application/json", l.ObjectSchema<{
33
- readonly commit: l.RefSchema<RepoDefs.CommitMeta>;
34
- }, {}, {
35
- commit?: RepoDefs.CommitMeta | undefined;
21
+ readonly commit: l.OptionalSchema<RepoDefs.CommitMeta>;
36
22
  }>>, readonly ["InvalidSwap"]>;
37
23
  export { main };
38
- export declare const $params: l.ParamsSchema<{}, l.ParamsSchemaOptions, {}>, $input: l.Payload<"application/json", l.ObjectSchema<{
24
+ export declare const $params: l.ParamsSchema<{}>, $input: l.Payload<"application/json", l.ObjectSchema<{
39
25
  readonly repo: l.StringSchema<{
40
26
  readonly format: "at-identifier";
41
27
  }>;
@@ -45,24 +31,10 @@ export declare const $params: l.ParamsSchema<{}, l.ParamsSchemaOptions, {}>, $in
45
31
  readonly rkey: l.StringSchema<{
46
32
  readonly format: "record-key";
47
33
  }>;
48
- readonly swapRecord: l.StringSchema<{
49
- readonly format: "cid";
50
- }>;
51
- readonly swapCommit: l.StringSchema<{
52
- readonly format: "cid";
53
- }>;
54
- }, {
55
- readonly required: readonly ["repo", "collection", "rkey"];
56
- }, {
57
- repo: l.AtIdentifier;
58
- collection: `${string}.${string}.${string}`;
59
- rkey: string;
60
- swapCommit?: string | undefined;
61
- swapRecord?: string | undefined;
34
+ readonly swapRecord: l.OptionalSchema<string>;
35
+ readonly swapCommit: l.OptionalSchema<string>;
62
36
  }>>, $output: l.Payload<"application/json", l.ObjectSchema<{
63
- readonly commit: l.RefSchema<RepoDefs.CommitMeta>;
64
- }, {}, {
65
- commit?: RepoDefs.CommitMeta | undefined;
37
+ readonly commit: l.OptionalSchema<RepoDefs.CommitMeta>;
66
38
  }>>;
67
39
  export type Params = l.InferProcedureParameters<typeof main>;
68
40
  export type Input = l.InferProcedureInputBody<typeof main>;
@@ -1 +1 @@
1
- {"version":3,"file":"deleteRecord.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/deleteRecord.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAE1C,QAAA,MAAM,KAAK,kCAAkC,CAAA;AAE7C,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB;;GAEG;AACH,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BA2BP,CAAA;AACH,OAAO,EAAE,IAAI,EAAE,CAAA;AAEf,eAAO,MAAM,OAAO,+CAAgC,EAClD,MAAM;;;;;;;;;;;;;;;;;;;;;;;;GAA2B,EACjC,OAAO;;;;GAA4B,CAAA;AAErC,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,wBAAwB,CAAC,OAAO,IAAI,CAAC,CAAA;AAC5D,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,uBAAuB,CAAC,OAAO,IAAI,CAAC,CAAA;AAC1D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,wBAAwB,CAAC,OAAO,IAAI,CAAC,CAAA"}
1
+ {"version":3,"file":"deleteRecord.defs.d.ts","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/deleteRecord.defs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAE1C,QAAA,MAAM,KAAK,kCAAkC,CAAA;AAE7C,OAAO,EAAE,KAAK,EAAE,CAAA;AAEhB;;GAEG;AACH,QAAA,MAAM,IAAI;;;;;;;;;;;;;;8BA8BP,CAAA;AACH,OAAO,EAAE,IAAI,EAAE,CAAA;AAEf,eAAO,MAAM,OAAO,oBAAgC,EAClD,MAAM;;;;;;;;;;;;GAA2B,EACjC,OAAO;;GAA4B,CAAA;AAErC,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,wBAAwB,CAAC,OAAO,IAAI,CAAC,CAAA;AAC5D,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,uBAAuB,CAAC,OAAO,IAAI,CAAC,CAAA;AAC1D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,wBAAwB,CAAC,OAAO,IAAI,CAAC,CAAA"}
@@ -21,12 +21,15 @@ lex_schema_1.l.procedure($nsid,
21
21
  repo: /*#__PURE__*/ lex_schema_1.l.string({ format: 'at-identifier' }),
22
22
  collection: /*#__PURE__*/ lex_schema_1.l.string({ format: 'nsid' }),
23
23
  rkey: /*#__PURE__*/ lex_schema_1.l.string({ format: 'record-key' }),
24
- swapRecord: /*#__PURE__*/ lex_schema_1.l.string({ format: 'cid' }),
25
- swapCommit: /*#__PURE__*/ lex_schema_1.l.string({ format: 'cid' }),
26
- }, { required: ['repo', 'collection', 'rkey'] })),
24
+ swapRecord: /*#__PURE__*/ lex_schema_1.l.optional(
25
+ /*#__PURE__*/ lex_schema_1.l.string({ format: 'cid' })),
26
+ swapCommit: /*#__PURE__*/ lex_schema_1.l.optional(
27
+ /*#__PURE__*/ lex_schema_1.l.string({ format: 'cid' })),
28
+ })),
27
29
  /*#__PURE__*/ lex_schema_1.l.payload('application/json',
28
30
  /*#__PURE__*/ lex_schema_1.l.object({
29
- commit: /*#__PURE__*/ lex_schema_1.l.ref((() => RepoDefs.commitMeta)),
31
+ commit: /*#__PURE__*/ lex_schema_1.l.optional(
32
+ /*#__PURE__*/ lex_schema_1.l.ref((() => RepoDefs.commitMeta))),
30
33
  })), ['InvalidSwap']);
31
34
  exports.main = main;
32
35
  exports.$params = main.parameters, exports.$input = main.input, exports.$output = main.output;
@@ -1 +1 @@
1
- {"version":3,"file":"deleteRecord.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/deleteRecord.defs.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,oDAAuC;AACvC,iEAA0C;AAE1C,MAAM,KAAK,GAAG,+BAA+B,CAAA;AAEpC,sBAAK;AAEd;;GAEG;AACH,MAAM,IAAI;AACR,aAAa;AACb,cAAC,CAAC,SAAS,CACT,KAAK;AACL,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,CAAC;AAC1B,aAAa,CAAC,cAAC,CAAC,OAAO,CACrB,kBAAkB;AAClB,aAAa,CAAC,cAAC,CAAC,MAAM,CACpB;IACE,IAAI,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;IACzD,UAAU,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACtD,IAAI,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IACtD,UAAU,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACrD,UAAU,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;CACtD,EACD,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,CAC7C,CACF;AACD,aAAa,CAAC,cAAC,CAAC,OAAO,CACrB,kBAAkB;AAClB,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC;IACrB,MAAM,EAAE,aAAa,CAAC,cAAC,CAAC,GAAG,CACzB,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAQ,CACnC;CACF,CAAC,CACH,EACD,CAAC,aAAa,CAAC,CAChB,CAAA;AACM,oBAAI;AAEA,QAAA,OAAO,GAAiB,IAAI,CAAC,UAAU,EAClD,QAAA,MAAM,GAAiB,IAAI,CAAC,KAAK,EACjC,QAAA,OAAO,GAAiB,IAAI,CAAC,MAAM,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex-schema'\nimport * as RepoDefs from './defs.defs.js'\n\nconst $nsid = 'com.atproto.repo.deleteRecord'\n\nexport { $nsid }\n\n/**\n * Delete a repository record, or ensure it doesn't exist. Requires auth, implemented by PDS.\n */\nconst main =\n /*#__PURE__*/\n l.procedure(\n $nsid,\n /*#__PURE__*/ l.params({}),\n /*#__PURE__*/ l.payload(\n 'application/json',\n /*#__PURE__*/ l.object(\n {\n repo: /*#__PURE__*/ l.string({ format: 'at-identifier' }),\n collection: /*#__PURE__*/ l.string({ format: 'nsid' }),\n rkey: /*#__PURE__*/ l.string({ format: 'record-key' }),\n swapRecord: /*#__PURE__*/ l.string({ format: 'cid' }),\n swapCommit: /*#__PURE__*/ l.string({ format: 'cid' }),\n },\n { required: ['repo', 'collection', 'rkey'] },\n ),\n ),\n /*#__PURE__*/ l.payload(\n 'application/json',\n /*#__PURE__*/ l.object({\n commit: /*#__PURE__*/ l.ref<RepoDefs.CommitMeta>(\n (() => RepoDefs.commitMeta) as any,\n ),\n }),\n ),\n ['InvalidSwap'],\n )\nexport { main }\n\nexport const $params = /*#__PURE__*/ main.parameters,\n $input = /*#__PURE__*/ main.input,\n $output = /*#__PURE__*/ main.output\n\nexport type Params = l.InferProcedureParameters<typeof main>\nexport type Input = l.InferProcedureInputBody<typeof main>\nexport type Output = l.InferProcedureOutputBody<typeof main>\n"]}
1
+ {"version":3,"file":"deleteRecord.defs.js","sourceRoot":"","sources":["../../../../../src/lexicons/com/atproto/repo/deleteRecord.defs.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,oDAAuC;AACvC,iEAA0C;AAE1C,MAAM,KAAK,GAAG,+BAA+B,CAAA;AAEpC,sBAAK;AAEd;;GAEG;AACH,MAAM,IAAI;AACR,aAAa;AACb,cAAC,CAAC,SAAS,CACT,KAAK;AACL,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,CAAC;AAC1B,aAAa,CAAC,cAAC,CAAC,OAAO,CACrB,kBAAkB;AAClB,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC;IACrB,IAAI,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;IACzD,UAAU,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IACtD,IAAI,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IACtD,UAAU,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ;IAClC,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAC1C;IACD,UAAU,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ;IAClC,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAC1C;CACF,CAAC,CACH;AACD,aAAa,CAAC,cAAC,CAAC,OAAO,CACrB,kBAAkB;AAClB,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC;IACrB,MAAM,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ;IAC9B,aAAa,CAAC,cAAC,CAAC,GAAG,CACjB,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAQ,CACnC,CACF;CACF,CAAC,CACH,EACD,CAAC,aAAa,CAAC,CAChB,CAAA;AACM,oBAAI;AAEA,QAAA,OAAO,GAAiB,IAAI,CAAC,UAAU,EAClD,QAAA,MAAM,GAAiB,IAAI,CAAC,KAAK,EACjC,QAAA,OAAO,GAAiB,IAAI,CAAC,MAAM,CAAA","sourcesContent":["/*\n * THIS FILE WAS GENERATED BY \"@atproto/lex\". DO NOT EDIT.\n */\n\nimport { l } from '@atproto/lex-schema'\nimport * as RepoDefs from './defs.defs.js'\n\nconst $nsid = 'com.atproto.repo.deleteRecord'\n\nexport { $nsid }\n\n/**\n * Delete a repository record, or ensure it doesn't exist. Requires auth, implemented by PDS.\n */\nconst main =\n /*#__PURE__*/\n l.procedure(\n $nsid,\n /*#__PURE__*/ l.params({}),\n /*#__PURE__*/ l.payload(\n 'application/json',\n /*#__PURE__*/ l.object({\n repo: /*#__PURE__*/ l.string({ format: 'at-identifier' }),\n collection: /*#__PURE__*/ l.string({ format: 'nsid' }),\n rkey: /*#__PURE__*/ l.string({ format: 'record-key' }),\n swapRecord: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.string({ format: 'cid' }),\n ),\n swapCommit: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.string({ format: 'cid' }),\n ),\n }),\n ),\n /*#__PURE__*/ l.payload(\n 'application/json',\n /*#__PURE__*/ l.object({\n commit: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.ref<RepoDefs.CommitMeta>(\n (() => RepoDefs.commitMeta) as any,\n ),\n ),\n }),\n ),\n ['InvalidSwap'],\n )\nexport { main }\n\nexport const $params = /*#__PURE__*/ main.parameters,\n $input = /*#__PURE__*/ main.input,\n $output = /*#__PURE__*/ main.output\n\nexport type Params = l.InferProcedureParameters<typeof main>\nexport type Input = l.InferProcedureInputBody<typeof main>\nexport type Output = l.InferProcedureOutputBody<typeof main>\n"]}