@atproto/lex-client 0.0.4 → 0.0.6
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.
- package/CHANGELOG.md +42 -0
- package/dist/agent.d.ts +10 -9
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +3 -0
- package/dist/agent.js.map +1 -1
- package/dist/client.d.ts +51 -113
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +38 -42
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +82 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +132 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lexicons/com/atproto/repo/createRecord.defs.d.ts +7 -7
- package/dist/lexicons/com/atproto/repo/createRecord.defs.d.ts.map +1 -1
- package/dist/lexicons/com/atproto/repo/createRecord.defs.js +8 -12
- package/dist/lexicons/com/atproto/repo/createRecord.defs.js.map +1 -1
- package/dist/lexicons/com/atproto/repo/deleteRecord.defs.d.ts +7 -7
- package/dist/lexicons/com/atproto/repo/deleteRecord.defs.d.ts.map +1 -1
- package/dist/lexicons/com/atproto/repo/deleteRecord.defs.js +8 -12
- package/dist/lexicons/com/atproto/repo/deleteRecord.defs.js.map +1 -1
- package/dist/lexicons/com/atproto/repo/getRecord.defs.d.ts +5 -6
- package/dist/lexicons/com/atproto/repo/getRecord.defs.d.ts.map +1 -1
- package/dist/lexicons/com/atproto/repo/getRecord.defs.js +6 -10
- package/dist/lexicons/com/atproto/repo/getRecord.defs.js.map +1 -1
- package/dist/lexicons/com/atproto/repo/listRecords.defs.d.ts +5 -6
- package/dist/lexicons/com/atproto/repo/listRecords.defs.d.ts.map +1 -1
- package/dist/lexicons/com/atproto/repo/listRecords.defs.js +5 -8
- package/dist/lexicons/com/atproto/repo/listRecords.defs.js.map +1 -1
- package/dist/lexicons/com/atproto/repo/putRecord.defs.d.ts +7 -7
- package/dist/lexicons/com/atproto/repo/putRecord.defs.d.ts.map +1 -1
- package/dist/lexicons/com/atproto/repo/putRecord.defs.js +8 -12
- package/dist/lexicons/com/atproto/repo/putRecord.defs.js.map +1 -1
- package/dist/lexicons/com/atproto/repo/uploadBlob.defs.d.ts +7 -7
- package/dist/lexicons/com/atproto/repo/uploadBlob.defs.d.ts.map +1 -1
- package/dist/lexicons/com/atproto/repo/uploadBlob.defs.js +6 -9
- package/dist/lexicons/com/atproto/repo/uploadBlob.defs.js.map +1 -1
- package/dist/lexicons/com/atproto/sync/getBlob.d.ts +3 -0
- package/dist/lexicons/com/atproto/sync/getBlob.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/sync/getBlob.defs.d.ts +25 -0
- package/dist/lexicons/com/atproto/sync/getBlob.defs.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/sync/getBlob.defs.js +27 -0
- package/dist/lexicons/com/atproto/sync/getBlob.defs.js.map +1 -0
- package/dist/lexicons/com/atproto/sync/getBlob.js +10 -0
- package/dist/lexicons/com/atproto/sync/getBlob.js.map +1 -0
- package/dist/lexicons/com/atproto/sync.d.ts +2 -0
- package/dist/lexicons/com/atproto/sync.d.ts.map +1 -0
- package/dist/lexicons/com/atproto/sync.js +9 -0
- package/dist/lexicons/com/atproto/sync.js.map +1 -0
- package/dist/lexicons/com/atproto.d.ts +1 -0
- package/dist/lexicons/com/atproto.d.ts.map +1 -1
- package/dist/lexicons/com/atproto.js +2 -1
- package/dist/lexicons/com/atproto.js.map +1 -1
- package/dist/lexicons.d.ts +2 -0
- package/dist/lexicons.d.ts.map +1 -0
- package/dist/lexicons.js +6 -0
- package/dist/lexicons.js.map +1 -0
- package/dist/response.d.ts +25 -8
- package/dist/response.d.ts.map +1 -1
- package/dist/response.js +123 -10
- package/dist/response.js.map +1 -1
- package/dist/types.d.ts +18 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -4
- package/dist/types.js.map +1 -1
- package/dist/util.d.ts +14 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +65 -0
- package/dist/util.js.map +1 -0
- package/dist/xrpc.d.ts +35 -32
- package/dist/xrpc.d.ts.map +1 -1
- package/dist/xrpc.js +116 -124
- package/dist/xrpc.js.map +1 -1
- package/package.json +10 -10
- package/src/agent.ts +18 -14
- package/src/client.ts +135 -114
- package/src/errors.ts +206 -0
- package/src/index.ts +1 -1
- package/src/lexicons/com/atproto/repo/createRecord.defs.ts +31 -36
- package/src/lexicons/com/atproto/repo/deleteRecord.defs.ts +27 -32
- package/src/lexicons/com/atproto/repo/getRecord.defs.ts +12 -17
- package/src/lexicons/com/atproto/repo/listRecords.defs.ts +13 -15
- package/src/lexicons/com/atproto/repo/putRecord.defs.ts +32 -37
- package/src/lexicons/com/atproto/repo/uploadBlob.defs.ts +13 -15
- package/src/lexicons/com/atproto/sync/getBlob.defs.ts +37 -0
- package/src/lexicons/com/atproto/sync/getBlob.ts +6 -0
- package/src/lexicons/com/atproto/sync.ts +5 -0
- package/src/lexicons/com/atproto.ts +1 -0
- package/src/lexicons.ts +1 -0
- package/src/response.ts +201 -15
- package/src/types.ts +26 -5
- package/src/util.ts +84 -0
- package/src/xrpc.ts +220 -232
- package/tsconfig.tests.json +4 -7
- package/dist/error.d.ts +0 -66
- package/dist/error.d.ts.map +0 -1
- package/dist/error.js +0 -100
- package/dist/error.js.map +0 -1
- package/src/error.ts +0 -145
package/dist/client.js.map
CHANGED
|
@@ -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,GAAyB,EAAE,CAAA;IAE7C;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,IAA2C;QAC1D,IAAI,IAAI,CA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,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"]}
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,gDAA8D;AAC9D,oDAmB4B;AAC5B,yCAA4D;AAC5D,+CAAmC;AAGnC,uCAA+C;AAC/C,uCAAwE;AAqHxE,MAAa,MAAM;IACjB,MAAM,CAAC,WAAW,GAAyB,EAAE,CAAA;IAE7C;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,IAA2C;QAC1D,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,CAAgB;IAExC,YAAY,KAA2B,EAAE,UAAyB,EAAE;QAClE,IAAI,CAAC,KAAK,GAAG,IAAA,qBAAU,EAAC,KAAK,CAAC,CAAA;QAC9B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,OAAO,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ACnE,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;;AAjXH,wBAkXC;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 { LexError, LexMap, LexValue } from '@atproto/lex-data'\nimport {\n AtIdentifierString,\n CidString,\n DidString,\n Infer,\n InferMethodInputBody,\n InferMethodOutputBody,\n InferMethodParams,\n InferRecordKey,\n LexiconRecordKey,\n Main,\n NsidString,\n Params,\n Procedure,\n Query,\n RecordSchema,\n Restricted,\n Schema,\n getMain,\n} from '@atproto/lex-schema'\nimport { Agent, AgentOptions, buildAgent } from './agent.js'\nimport { com } from './lexicons.js'\nimport { LexRpcResponse, LexRpcResponseBody } from './response.js'\nimport { BinaryBodyInit, CallOptions, Service } from './types.js'\nimport { buildAtprotoHeaders } from './util.js'\nimport { LexRpcFailure, LexRpcOptions, xrpc, xrpcSafe } from './xrpc.js'\n\nexport type {\n AtIdentifierString,\n CidString,\n DidString,\n InferMethodInputBody,\n InferMethodOutputBody,\n InferMethodParams,\n InferRecordKey,\n LexMap,\n LexValue,\n LexiconRecordKey,\n NsidString,\n Params,\n Procedure,\n Query,\n RecordSchema,\n Restricted,\n Schema,\n}\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 = InferMethodOutputBody<\n typeof com.atproto.repo.createRecord.main,\n Uint8Array\n>\n\nexport type DeleteOptions<T extends RecordSchema> = DeleteRecordOptions &\n RecordKeyOptions<T>\nexport type DeleteOutput = InferMethodOutputBody<\n typeof com.atproto.repo.deleteRecord.main,\n Uint8Array\n>\nexport type GetOptions<T extends RecordSchema> = GetRecordOptions &\n RecordKeyOptions<T>\nexport type GetOutput<T extends RecordSchema> = Omit<\n InferMethodOutputBody<typeof com.atproto.repo.getRecord.main, Uint8Array>,\n 'value'\n> & { value: Infer<T> }\n\nexport type PutOptions<T extends RecordSchema> = PutRecordOptions &\n RecordKeyOptions<T>\nexport type PutOutput = InferMethodOutputBody<\n typeof com.atproto.repo.putRecord.main,\n Uint8Array\n>\n\nexport type ListOptions = ListRecordsOptions\nexport type ListOutput<T extends RecordSchema> = InferMethodOutputBody<\n typeof com.atproto.repo.listRecords.main,\n Uint8Array\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 = 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 LexError('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 = buildAtprotoHeaders({\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 // @NOTE The agent here could be another Client instance.\n return this.agent.fetchHandler(path, { ...init, headers })\n }\n\n /**\n * @throws {LexRpcFailure<M>} when the request fails or the response is an error\n */\n async xrpc<const M extends Query | Procedure>(\n ns: NonNullable<unknown> extends LexRpcOptions<M>\n ? Main<M>\n : Restricted<'This XRPC method requires an \"options\" argument'>,\n ): Promise<LexRpcResponse<M>>\n async xrpc<const M extends Query | Procedure>(\n ns: Main<M>,\n options: LexRpcOptions<M>,\n ): Promise<LexRpcResponse<M>>\n async xrpc<const M extends Query | Procedure>(\n ns: Main<M>,\n options: LexRpcOptions<M> = {} as LexRpcOptions<M>,\n ): Promise<LexRpcResponse<M>> {\n return xrpc(this, ns, options)\n }\n\n async xrpcSafe<const M extends Query | Procedure>(\n ns: NonNullable<unknown> extends LexRpcOptions<M>\n ? Main<M>\n : Restricted<'This XRPC method requires an \"options\" argument'>,\n ): Promise<LexRpcResponse<M> | LexRpcFailure<M>>\n async xrpcSafe<const M extends Query | Procedure>(\n ns: Main<M>,\n options: LexRpcOptions<M>,\n ): Promise<LexRpcResponse<M> | LexRpcFailure<M>>\n async xrpcSafe<const M extends Query | Procedure>(\n ns: Main<M>,\n options: LexRpcOptions<M> = {} as LexRpcOptions<M>,\n ): Promise<LexRpcResponse<M> | LexRpcFailure<M>> {\n return xrpcSafe(this, ns, options)\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 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 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 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 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 async uploadBlob(\n body: BinaryBodyInit,\n options?: CallOptions & { encoding?: `${string}/${string}` },\n ) {\n return this.xrpc(com.atproto.repo.uploadBlob.main, {\n ...options,\n body,\n })\n }\n\n async getBlob(did: DidString, cid: CidString, options?: CallOptions) {\n return this.xrpc(com.atproto.sync.getBlob.main, {\n ...options,\n params: { did, cid },\n })\n }\n\n public async call<const T extends Query>(\n ns: NonNullable<unknown> extends InferMethodParams<T>\n ? Main<T>\n : Restricted<'This query type requires a \"params\" argument'>,\n ): Promise<LexRpcResponseBody<T>>\n public async call<const T extends Action>(\n ns: void extends InferActionInput<T>\n ? Main<T>\n : Restricted<'This action type requires an \"input\" argument'>,\n ): Promise<InferActionOutput<T>>\n public async call<const T extends Action | Procedure | Query>(\n ns: Main<T>,\n arg: T extends Action\n ? InferActionInput<T>\n : T extends Procedure\n ? InferMethodInputBody<T, Uint8Array>\n : T extends Query\n ? InferMethodParams<T>\n : never,\n options?: CallOptions,\n ): Promise<\n T extends Action\n ? InferActionOutput<T>\n : T extends Procedure\n ? LexRpcResponseBody<T>\n : T extends Query\n ? LexRpcResponseBody<T>\n : never\n >\n public async call(\n ns: Main<Action> | Main<Procedure> | Main<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 result = await this.xrpc(method, { ...options, body: arg as any })\n return result.body\n } else if (method instanceof Query) {\n const result = await this.xrpc(method, { ...options, params: arg as any })\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 ? Main<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: Main<T>,\n input: Omit<Infer<T>, '$type'>,\n options: CreateOptions<T>,\n ): Promise<CreateOutput>\n public async create<const T extends RecordSchema>(\n ns: Main<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 = schema.build(input)\n if (options.validateRequest) schema.assert(record)\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 ? Main<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n ): Promise<DeleteOutput>\n public async delete<const T extends RecordSchema>(\n ns: Main<T>,\n options?: DeleteOptions<T>,\n ): Promise<DeleteOutput>\n public async delete<const T extends RecordSchema>(\n ns: Main<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 ? Main<T>\n : Restricted<'This record type requires an \"options\" argument'>,\n ): Promise<GetOutput<T>>\n public async get<const T extends RecordSchema>(\n ns: Main<T>,\n options?: GetOptions<T>,\n ): Promise<GetOutput<T>>\n public async get<const T extends RecordSchema>(\n ns: Main<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 ? Main<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: Main<T>,\n input: Omit<Infer<T>, '$type'>,\n options: PutOptions<T>,\n ): Promise<PutOutput>\n public async put<const T extends RecordSchema>(\n ns: Main<T>,\n input: Omit<Infer<T>, '$type'>,\n options: PutOptions<T> = {} as PutOptions<T>,\n ): Promise<PutOutput> {\n const schema: T = getMain(ns)\n const record = schema.build(input)\n if (options.validateRequest) schema.assert(record)\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: Main<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/errors.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { LexError, LexErrorCode, LexErrorData } from '@atproto/lex-data';
|
|
2
|
+
import { l } from '@atproto/lex-schema';
|
|
3
|
+
import { Payload } from './util.js';
|
|
4
|
+
export type LexRpcErrorPayload<N extends LexErrorCode = LexErrorCode> = Payload<LexErrorData<N>, 'application/json'>;
|
|
5
|
+
export declare class LexRpcError<N extends LexErrorCode = LexErrorCode> extends LexError<N> {
|
|
6
|
+
name: string;
|
|
7
|
+
constructor(error: N, message?: string, options?: ErrorOptions);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* All unsuccessful responses should follow a standard error response
|
|
11
|
+
* schema. The Content-Type should be application/json, and the payload
|
|
12
|
+
* should be a JSON object with the following fields:
|
|
13
|
+
*
|
|
14
|
+
* - `error` (string, required): type name of the error (generic ASCII
|
|
15
|
+
* constant, no whitespace)
|
|
16
|
+
* - `message` (string, optional): description of the error, appropriate for
|
|
17
|
+
* display to humans
|
|
18
|
+
*
|
|
19
|
+
* This function checks whether a given payload matches this schema.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isLexRpcErrorPayload(payload: Payload | null): payload is LexRpcErrorPayload;
|
|
22
|
+
/**
|
|
23
|
+
* Interface representing a failed XRPC request result.
|
|
24
|
+
*/
|
|
25
|
+
type LexRpcFailureResult<N extends LexErrorCode, E> = l.ResultFailure<E> & {
|
|
26
|
+
readonly error: N;
|
|
27
|
+
shouldRetry(): boolean;
|
|
28
|
+
matchesSchema(): boolean;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Class used to represent an HTTP request that resulted in an XRPC method error
|
|
32
|
+
* That is, a non-2xx response with a valid XRPC error payload.
|
|
33
|
+
*/
|
|
34
|
+
export declare class LexRpcResponseError<M extends l.Procedure | l.Query = l.Procedure | l.Query, N extends LexErrorCode = LexErrorCode> extends LexRpcError<N> implements LexRpcFailureResult<N, LexRpcResponseError<M, N>> {
|
|
35
|
+
readonly method: M;
|
|
36
|
+
readonly status: number;
|
|
37
|
+
readonly headers: Headers;
|
|
38
|
+
readonly payload: LexRpcErrorPayload<N>;
|
|
39
|
+
name: string;
|
|
40
|
+
constructor(method: M, status: number, headers: Headers, payload: LexRpcErrorPayload<N>, options?: ErrorOptions);
|
|
41
|
+
readonly success = false;
|
|
42
|
+
get reason(): this;
|
|
43
|
+
get body(): LexErrorData;
|
|
44
|
+
matchesSchema(): this is M extends {
|
|
45
|
+
errors: readonly (infer E extends string)[];
|
|
46
|
+
} ? LexRpcResponseError<M, E> : never;
|
|
47
|
+
shouldRetry(): boolean;
|
|
48
|
+
toJSON(): LexErrorData<N>;
|
|
49
|
+
toResponse(): Response;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* This class represents an invalid XRPC response from the server.
|
|
53
|
+
*/
|
|
54
|
+
export declare class LexRpcUpstreamError<N extends 'InvalidResponse' | 'UpstreamFailure' = 'InvalidResponse' | 'UpstreamFailure'> extends LexRpcError<N> implements LexRpcFailureResult<N, LexRpcUpstreamError<N>> {
|
|
55
|
+
name: "LexRpcUpstreamError";
|
|
56
|
+
readonly response: {
|
|
57
|
+
status: number;
|
|
58
|
+
headers: Headers;
|
|
59
|
+
payload: Payload | null;
|
|
60
|
+
};
|
|
61
|
+
constructor(error: N, message: string, response: {
|
|
62
|
+
status: number;
|
|
63
|
+
headers: Headers;
|
|
64
|
+
}, payload: Payload | null, options?: ErrorOptions);
|
|
65
|
+
readonly success: false;
|
|
66
|
+
get reason(): this;
|
|
67
|
+
matchesSchema(): false;
|
|
68
|
+
shouldRetry(): boolean;
|
|
69
|
+
toResponse(): Response;
|
|
70
|
+
}
|
|
71
|
+
export declare class LexRpcUnexpectedError extends LexRpcError<'InternalServerError'> implements LexRpcFailureResult<'InternalServerError', unknown> {
|
|
72
|
+
name: "LexRpcUnexpectedError";
|
|
73
|
+
protected constructor(message: string, options: Required<ErrorOptions>);
|
|
74
|
+
readonly success = false;
|
|
75
|
+
get reason(): unknown;
|
|
76
|
+
matchesSchema(): false;
|
|
77
|
+
shouldRetry(): boolean;
|
|
78
|
+
toResponse(): Response;
|
|
79
|
+
static from(cause: unknown, message?: string): LexRpcUnexpectedError;
|
|
80
|
+
}
|
|
81
|
+
export {};
|
|
82
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,IAAI,OAAO,CAC7E,YAAY,CAAC,CAAC,CAAC,EACf,kBAAkB,CACnB,CAAA;AAED,qBAAa,WAAW,CACtB,CAAC,SAAS,YA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AAQ,CAAC,OAAO,SAAQ;IAExB,IAAI,MAAM,YAET;IAED,aAAa,IAAI,KAAK;IAItB,WAAW,IAAI,OAAO;IAItB,UAAU,IAAI,QAAQ;IAItB,MAAM,CAAC,IAAI,CACT,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,MAEgB,GACxB,qBAAqB;CAIzB"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LexRpcUnexpectedError = exports.LexRpcUpstreamError = exports.LexRpcResponseError = exports.LexRpcError = void 0;
|
|
4
|
+
exports.isLexRpcErrorPayload = isLexRpcErrorPayload;
|
|
5
|
+
const lex_data_1 = require("@atproto/lex-data");
|
|
6
|
+
const lex_schema_1 = require("@atproto/lex-schema");
|
|
7
|
+
class LexRpcError extends lex_data_1.LexError {
|
|
8
|
+
name = 'LexRpcError';
|
|
9
|
+
constructor(error, message = `${error} Lexicon RPC error`, options) {
|
|
10
|
+
super(error, message, options);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.LexRpcError = LexRpcError;
|
|
14
|
+
/**
|
|
15
|
+
* All unsuccessful responses should follow a standard error response
|
|
16
|
+
* schema. The Content-Type should be application/json, and the payload
|
|
17
|
+
* should be a JSON object with the following fields:
|
|
18
|
+
*
|
|
19
|
+
* - `error` (string, required): type name of the error (generic ASCII
|
|
20
|
+
* constant, no whitespace)
|
|
21
|
+
* - `message` (string, optional): description of the error, appropriate for
|
|
22
|
+
* display to humans
|
|
23
|
+
*
|
|
24
|
+
* This function checks whether a given payload matches this schema.
|
|
25
|
+
*/
|
|
26
|
+
function isLexRpcErrorPayload(payload) {
|
|
27
|
+
return (payload !== null &&
|
|
28
|
+
payload.encoding === 'application/json' &&
|
|
29
|
+
lex_schema_1.l.lexErrorData.matches(payload.body));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Class used to represent an HTTP request that resulted in an XRPC method error
|
|
33
|
+
* That is, a non-2xx response with a valid XRPC error payload.
|
|
34
|
+
*/
|
|
35
|
+
class LexRpcResponseError extends LexRpcError {
|
|
36
|
+
method;
|
|
37
|
+
status;
|
|
38
|
+
headers;
|
|
39
|
+
payload;
|
|
40
|
+
name = 'LexRpcResponseError';
|
|
41
|
+
constructor(method, status, headers, payload, options) {
|
|
42
|
+
const { error, message } = payload.body;
|
|
43
|
+
super(error, message, options);
|
|
44
|
+
this.method = method;
|
|
45
|
+
this.status = status;
|
|
46
|
+
this.headers = headers;
|
|
47
|
+
this.payload = payload;
|
|
48
|
+
}
|
|
49
|
+
success = false;
|
|
50
|
+
get reason() {
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
get body() {
|
|
54
|
+
return this.payload.body;
|
|
55
|
+
}
|
|
56
|
+
matchesSchema() {
|
|
57
|
+
return this.method.errors?.includes(this.error) ?? false;
|
|
58
|
+
}
|
|
59
|
+
shouldRetry() {
|
|
60
|
+
// Do not retry client errors
|
|
61
|
+
if (this.status < 500)
|
|
62
|
+
return false;
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
toJSON() {
|
|
66
|
+
return this.payload.body;
|
|
67
|
+
}
|
|
68
|
+
toResponse() {
|
|
69
|
+
const { status, headers } = this;
|
|
70
|
+
return Response.json(this.toJSON(), { status, headers });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.LexRpcResponseError = LexRpcResponseError;
|
|
74
|
+
/**
|
|
75
|
+
* This class represents an invalid XRPC response from the server.
|
|
76
|
+
*/
|
|
77
|
+
class LexRpcUpstreamError extends LexRpcError {
|
|
78
|
+
name = 'LexRpcUpstreamError';
|
|
79
|
+
// For debugging purposes, we keep the response details here
|
|
80
|
+
response;
|
|
81
|
+
constructor(error, message, response, payload, options) {
|
|
82
|
+
super(error, message, { cause: options?.cause });
|
|
83
|
+
this.response = {
|
|
84
|
+
status: response.status,
|
|
85
|
+
headers: response.headers,
|
|
86
|
+
payload,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
success = false;
|
|
90
|
+
get reason() {
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
matchesSchema() {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
shouldRetry() {
|
|
97
|
+
// Do not retry client errors
|
|
98
|
+
return this.response.status >= 500;
|
|
99
|
+
}
|
|
100
|
+
toResponse() {
|
|
101
|
+
return Response.json(this.toJSON(), { status: 502 });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.LexRpcUpstreamError = LexRpcUpstreamError;
|
|
105
|
+
class LexRpcUnexpectedError extends LexRpcError {
|
|
106
|
+
name = 'LexRpcUnexpectedError';
|
|
107
|
+
constructor(message, options) {
|
|
108
|
+
super('InternalServerError', message, options);
|
|
109
|
+
}
|
|
110
|
+
success = false;
|
|
111
|
+
get reason() {
|
|
112
|
+
return this.cause;
|
|
113
|
+
}
|
|
114
|
+
matchesSchema() {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
shouldRetry() {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
toResponse() {
|
|
121
|
+
return Response.json(this.toJSON(), { status: 500 });
|
|
122
|
+
}
|
|
123
|
+
static from(cause, message = cause instanceof lex_data_1.LexError
|
|
124
|
+
? cause.message
|
|
125
|
+
: 'XRPC request failed') {
|
|
126
|
+
if (cause instanceof LexRpcUnexpectedError)
|
|
127
|
+
return cause;
|
|
128
|
+
return new LexRpcUnexpectedError(message, { cause });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.LexRpcUnexpectedError = LexRpcUnexpectedError;
|
|
132
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAmCA,oDAQC;AA3CD,gDAAwE;AACxE,oDAAuC;AAQvC,MA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,KAAK,CAAC,qBAAqB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IAChD,CAAC;IAEQ,OAAO,GAAG,KAAK,CAAA;IAExB,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED,aAAa;QACX,OAAO,KAAK,CAAA;IACd,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAA;IACb,CAAC;IAED,UAAU;QACR,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;IACtD,CAAC;IAED,MAAM,CAAC,IAAI,CACT,KAAc,EACd,UAAkB,KAAK,YAAY,mBAAQ;QACzC,CAAC,CAAC,KAAK,CAAC,OAAO;QACf,CAAC,CAAC,qBAAqB;QAEzB,IAAI,KAAK,YAAY,qBAAqB;YAAE,OAAO,KAAK,CAAA;QACxD,OAAO,IAAI,qBAAqB,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;IACtD,CAAC;CACF;AArCD,sDAqCC","sourcesContent":["import { LexError, LexErrorCode, LexErrorData } from '@atproto/lex-data'\nimport { l } from '@atproto/lex-schema'\nimport { Payload } from './util.js'\n\nexport type LexRpcErrorPayload<N extends LexErrorCode = LexErrorCode> = Payload<\n LexErrorData<N>,\n 'application/json'\n>\n\nexport class LexRpcError<\n N extends LexErrorCode = LexErrorCode,\n> extends LexError<N> {\n name = 'LexRpcError'\n\n constructor(\n error: N,\n message: string = `${error} Lexicon RPC error`,\n options?: ErrorOptions,\n ) {\n super(error, message, options)\n }\n}\n\n/**\n * All unsuccessful responses should follow a standard error response\n * schema. The Content-Type should be application/json, and the payload\n * should be a JSON object with the following fields:\n *\n * - `error` (string, required): type name of the error (generic ASCII\n * constant, no whitespace)\n * - `message` (string, optional): description of the error, appropriate for\n * display to humans\n *\n * This function checks whether a given payload matches this schema.\n */\nexport function isLexRpcErrorPayload(\n payload: Payload | null,\n): payload is LexRpcErrorPayload {\n return (\n payload !== null &&\n payload.encoding === 'application/json' &&\n l.lexErrorData.matches(payload.body)\n )\n}\n\n/**\n * Interface representing a failed XRPC request result.\n */\ntype LexRpcFailureResult<N extends LexErrorCode, E> = l.ResultFailure<E> & {\n readonly error: N\n shouldRetry(): boolean\n matchesSchema(): boolean\n}\n\n/**\n * Class used to represent an HTTP request that resulted in an XRPC method error\n * That is, a non-2xx response with a valid XRPC error payload.\n */\nexport class LexRpcResponseError<\n M extends l.Procedure | l.Query = l.Procedure | l.Query,\n N extends LexErrorCode = LexErrorCode,\n >\n extends LexRpcError<N>\n implements LexRpcFailureResult<N, LexRpcResponseError<M, N>>\n{\n name = 'LexRpcResponseError'\n\n constructor(\n readonly method: M,\n readonly status: number,\n readonly headers: Headers,\n readonly payload: LexRpcErrorPayload<N>,\n options?: ErrorOptions,\n ) {\n const { error, message } = payload.body\n super(error, message, options)\n }\n\n readonly success = false\n\n get reason(): this {\n return this as this\n }\n\n get body(): LexErrorData {\n return this.payload.body\n }\n\n matchesSchema(): this is M extends {\n errors: readonly (infer E extends string)[]\n }\n ? LexRpcResponseError<M, E>\n : never {\n return this.method.errors?.includes(this.error) ?? false\n }\n\n shouldRetry(): boolean {\n // Do not retry client errors\n if (this.status < 500) return false\n\n return true\n }\n\n toJSON() {\n return this.payload.body\n }\n\n toResponse(): Response {\n const { status, headers } = this\n return Response.json(this.toJSON(), { status, headers })\n }\n}\n\n/**\n * This class represents an invalid XRPC response from the server.\n */\nexport class LexRpcUpstreamError<\n N extends 'InvalidResponse' | 'UpstreamFailure' =\n | 'InvalidResponse'\n | 'UpstreamFailure',\n >\n extends LexRpcError<N>\n implements LexRpcFailureResult<N, LexRpcUpstreamError<N>>\n{\n name = 'LexRpcUpstreamError' as const\n\n // For debugging purposes, we keep the response details here\n readonly response: {\n status: number\n headers: Headers\n payload: Payload | null\n }\n\n constructor(\n error: N,\n message: string,\n response: { status: number; headers: Headers },\n payload: Payload | null,\n options?: ErrorOptions,\n ) {\n super(error, message, { cause: options?.cause })\n this.response = {\n status: response.status,\n headers: response.headers,\n payload,\n }\n }\n\n readonly success = false as const\n\n get reason(): this {\n return this\n }\n\n matchesSchema(): false {\n return false\n }\n\n shouldRetry(): boolean {\n // Do not retry client errors\n return this.response.status >= 500\n }\n\n toResponse(): Response {\n return Response.json(this.toJSON(), { status: 502 })\n }\n}\n\nexport class LexRpcUnexpectedError\n extends LexRpcError<'InternalServerError'>\n implements LexRpcFailureResult<'InternalServerError', unknown>\n{\n name = 'LexRpcUnexpectedError' as const\n\n protected constructor(message: string, options: Required<ErrorOptions>) {\n super('InternalServerError', message, options)\n }\n\n readonly success = false\n\n get reason() {\n return this.cause\n }\n\n matchesSchema(): false {\n return false\n }\n\n shouldRetry(): boolean {\n return true\n }\n\n toResponse(): Response {\n return Response.json(this.toJSON(), { status: 500 })\n }\n\n static from(\n cause: unknown,\n message: string = cause instanceof LexError\n ? cause.message\n : 'XRPC request failed',\n ): LexRpcUnexpectedError {\n if (cause instanceof LexRpcUnexpectedError) return cause\n return new LexRpcUnexpectedError(message, { cause })\n }\n}\n"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./agent.js"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./client.js"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./
|
|
6
|
+
tslib_1.__exportStar(require("./errors.js"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./response.js"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./types.js"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./xrpc.js"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAA0B;AAC1B,sDAA2B;AAC3B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAA0B;AAC1B,sDAA2B;AAC3B,sDAA2B;AAC3B,wDAA6B;AAC7B,qDAA0B;AAC1B,oDAAyB","sourcesContent":["export * from './agent.js'\nexport * from './client.js'\nexport * from './errors.js'\nexport * from './response.js'\nexport * from './types.js'\nexport * from './xrpc.js'\n"]}
|
|
@@ -2,9 +2,7 @@ import { l } from '@atproto/lex-schema';
|
|
|
2
2
|
import * as RepoDefs from './defs.defs.js';
|
|
3
3
|
declare const $nsid = "com.atproto.repo.createRecord";
|
|
4
4
|
export { $nsid };
|
|
5
|
-
/**
|
|
6
|
-
* Create a single new repository record. Requires auth, implemented by PDS.
|
|
7
|
-
*/
|
|
5
|
+
/** Create a single new repository record. Requires auth, implemented by PDS. */
|
|
8
6
|
declare const main: l.Procedure<"com.atproto.repo.createRecord", l.ParamsSchema<{}>, l.Payload<"application/json", l.ObjectSchema<{
|
|
9
7
|
readonly repo: l.StringSchema<{
|
|
10
8
|
readonly format: "at-identifier";
|
|
@@ -27,7 +25,12 @@ declare const main: l.Procedure<"com.atproto.repo.createRecord", l.ParamsSchema<
|
|
|
27
25
|
readonly validationStatus: l.OptionalSchema<string>;
|
|
28
26
|
}>>, readonly ["InvalidSwap"]>;
|
|
29
27
|
export { main };
|
|
30
|
-
export
|
|
28
|
+
export type Params = l.InferMethodParams<typeof main>;
|
|
29
|
+
export type Input = l.InferMethodInput<typeof main>;
|
|
30
|
+
export type InputBody = l.InferMethodInputBody<typeof main>;
|
|
31
|
+
export type Output = l.InferMethodOutput<typeof main>;
|
|
32
|
+
export type OutputBody = l.InferMethodOutputBody<typeof main>;
|
|
33
|
+
export declare const $lxm: "com.atproto.repo.createRecord", $params: l.ParamsSchema<{}>, $input: l.Payload<"application/json", l.ObjectSchema<{
|
|
31
34
|
readonly repo: l.StringSchema<{
|
|
32
35
|
readonly format: "at-identifier";
|
|
33
36
|
}>;
|
|
@@ -48,7 +51,4 @@ export declare const $params: l.ParamsSchema<{}>, $input: l.Payload<"application
|
|
|
48
51
|
readonly commit: l.OptionalSchema<RepoDefs.CommitMeta>;
|
|
49
52
|
readonly validationStatus: l.OptionalSchema<string>;
|
|
50
53
|
}>>;
|
|
51
|
-
export type Params = l.InferProcedureParameters<typeof main>;
|
|
52
|
-
export type Input = l.InferProcedureInputBody<typeof main>;
|
|
53
|
-
export type Output = l.InferProcedureOutputBody<typeof main>;
|
|
54
54
|
//# sourceMappingURL=createRecord.defs.d.ts.map
|
|
@@ -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
|
|
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,gFAAgF;AAChF,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;8BA4BP,CAAA;AACH,OAAO,EAAE,IAAI,EAAE,CAAA;AAEf,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,IAAI,CAAC,CAAA;AACrD,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,gBAAgB,CAAC,OAAO,IAAI,CAAC,CAAA;AACnD,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,oBAAoB,CAAC,OAAO,IAAI,CAAC,CAAA;AAC3D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,IAAI,CAAC,CAAA;AACrD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,qBAAqB,CAAC,OAAO,IAAI,CAAC,CAAA;AAE7D,eAAO,MAAM,IAAI,iCAA0B,EACzC,OAAO,oBAAgC,EACvC,MAAM;;;;;;;;;;;GAA2B,EACjC,OAAO;;;;;;;;;GAA4B,CAAA"}
|
|
@@ -3,21 +3,18 @@
|
|
|
3
3
|
* THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.$output = exports.$input = exports.$params = exports.main = exports.$nsid = void 0;
|
|
6
|
+
exports.$output = exports.$input = exports.$params = exports.$lxm = exports.main = exports.$nsid = void 0;
|
|
7
7
|
const tslib_1 = require("tslib");
|
|
8
8
|
const lex_schema_1 = require("@atproto/lex-schema");
|
|
9
9
|
const RepoDefs = tslib_1.__importStar(require("./defs.defs.js"));
|
|
10
10
|
const $nsid = 'com.atproto.repo.createRecord';
|
|
11
11
|
exports.$nsid = $nsid;
|
|
12
|
-
/**
|
|
13
|
-
* Create a single new repository record. Requires auth, implemented by PDS.
|
|
14
|
-
*/
|
|
12
|
+
/** Create a single new repository record. Requires auth, implemented by PDS. */
|
|
15
13
|
const main =
|
|
16
14
|
/*#__PURE__*/
|
|
17
15
|
lex_schema_1.l.procedure($nsid,
|
|
18
|
-
/*#__PURE__*/ lex_schema_1.l.params(
|
|
19
|
-
/*#__PURE__*/ lex_schema_1.l.
|
|
20
|
-
/*#__PURE__*/ lex_schema_1.l.object({
|
|
16
|
+
/*#__PURE__*/ lex_schema_1.l.params(),
|
|
17
|
+
/*#__PURE__*/ lex_schema_1.l.jsonPayload({
|
|
21
18
|
repo: /*#__PURE__*/ lex_schema_1.l.string({ format: 'at-identifier' }),
|
|
22
19
|
collection: /*#__PURE__*/ lex_schema_1.l.string({ format: 'nsid' }),
|
|
23
20
|
rkey: /*#__PURE__*/ lex_schema_1.l.optional(
|
|
@@ -26,15 +23,14 @@ lex_schema_1.l.procedure($nsid,
|
|
|
26
23
|
record: /*#__PURE__*/ lex_schema_1.l.unknownObject(),
|
|
27
24
|
swapCommit: /*#__PURE__*/ lex_schema_1.l.optional(
|
|
28
25
|
/*#__PURE__*/ lex_schema_1.l.string({ format: 'cid' })),
|
|
29
|
-
})
|
|
30
|
-
/*#__PURE__*/ lex_schema_1.l.
|
|
31
|
-
/*#__PURE__*/ lex_schema_1.l.object({
|
|
26
|
+
}),
|
|
27
|
+
/*#__PURE__*/ lex_schema_1.l.jsonPayload({
|
|
32
28
|
uri: /*#__PURE__*/ lex_schema_1.l.string({ format: 'at-uri' }),
|
|
33
29
|
cid: /*#__PURE__*/ lex_schema_1.l.string({ format: 'cid' }),
|
|
34
30
|
commit: /*#__PURE__*/ lex_schema_1.l.optional(
|
|
35
31
|
/*#__PURE__*/ lex_schema_1.l.ref((() => RepoDefs.commitMeta))),
|
|
36
32
|
validationStatus: /*#__PURE__*/ lex_schema_1.l.optional(/*#__PURE__*/ lex_schema_1.l.string()),
|
|
37
|
-
})
|
|
33
|
+
}), ['InvalidSwap']);
|
|
38
34
|
exports.main = main;
|
|
39
|
-
exports.$params = main.parameters, exports.$input = main.input, exports.$output = main.output;
|
|
35
|
+
exports.$lxm = main.nsid, exports.$params = main.parameters, exports.$input = main.input, exports.$output = main.output;
|
|
40
36
|
//# 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
|
|
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,gFAAgF;AAChF,MAAM,IAAI;AACR,aAAa;AACb,cAAC,CAAC,SAAS,CACT,KAAK;AACL,aAAa,CAAC,cAAC,CAAC,MAAM,EAAE;AACxB,aAAa,CAAC,cAAC,CAAC,WAAW,CAAC;IAC1B,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,QAAQ;IAC5B,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CACjE;IACD,QAAQ,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAC,CAAC,OAAO,EAAE,CAAC;IAC7D,MAAM,EAAE,aAAa,CAAC,cAAC,CAAC,aAAa,EAAE;IACvC,UAAU,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ;IAClC,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAC1C;CACF,CAAC;AACF,aAAa,CAAC,cAAC,CAAC,WAAW,CAAC;IAC1B,GAAG,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IACjD,GAAG,EAAE,aAAa,CAAC,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC9C,MAAM,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ;IAC9B,aAAa,CAAC,cAAC,CAAC,GAAG,CACjB,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAQ,CACnC,CACF;IACD,gBAAgB,EAAE,aAAa,CAAC,cAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,cAAC,CAAC,MAAM,EAAE,CAAC;CACrE,CAAC,EACF,CAAC,aAAa,CAAC,CAChB,CAAA;AACM,oBAAI;AAQA,QAAA,IAAI,GAAiB,IAAI,CAAC,IAAI,EACzC,QAAA,OAAO,GAAiB,IAAI,CAAC,UAAU,EACvC,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/** Create a single new repository record. Requires auth, implemented by PDS. */\nconst main =\n /*#__PURE__*/\n l.procedure(\n $nsid,\n /*#__PURE__*/ l.params(),\n /*#__PURE__*/ l.jsonPayload({\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 /*#__PURE__*/ l.jsonPayload({\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 ['InvalidSwap'],\n )\nexport { main }\n\nexport type Params = l.InferMethodParams<typeof main>\nexport type Input = l.InferMethodInput<typeof main>\nexport type InputBody = l.InferMethodInputBody<typeof main>\nexport type Output = l.InferMethodOutput<typeof main>\nexport type OutputBody = l.InferMethodOutputBody<typeof main>\n\nexport const $lxm = /*#__PURE__*/ main.nsid,\n $params = /*#__PURE__*/ main.parameters,\n $input = /*#__PURE__*/ main.input,\n $output = /*#__PURE__*/ main.output\n"]}
|
|
@@ -2,9 +2,7 @@ import { l } from '@atproto/lex-schema';
|
|
|
2
2
|
import * as RepoDefs from './defs.defs.js';
|
|
3
3
|
declare const $nsid = "com.atproto.repo.deleteRecord";
|
|
4
4
|
export { $nsid };
|
|
5
|
-
/**
|
|
6
|
-
* Delete a repository record, or ensure it doesn't exist. Requires auth, implemented by PDS.
|
|
7
|
-
*/
|
|
5
|
+
/** Delete a repository record, or ensure it doesn't exist. Requires auth, implemented by PDS. */
|
|
8
6
|
declare const main: l.Procedure<"com.atproto.repo.deleteRecord", l.ParamsSchema<{}>, l.Payload<"application/json", l.ObjectSchema<{
|
|
9
7
|
readonly repo: l.StringSchema<{
|
|
10
8
|
readonly format: "at-identifier";
|
|
@@ -21,7 +19,12 @@ declare const main: l.Procedure<"com.atproto.repo.deleteRecord", l.ParamsSchema<
|
|
|
21
19
|
readonly commit: l.OptionalSchema<RepoDefs.CommitMeta>;
|
|
22
20
|
}>>, readonly ["InvalidSwap"]>;
|
|
23
21
|
export { main };
|
|
24
|
-
export
|
|
22
|
+
export type Params = l.InferMethodParams<typeof main>;
|
|
23
|
+
export type Input = l.InferMethodInput<typeof main>;
|
|
24
|
+
export type InputBody = l.InferMethodInputBody<typeof main>;
|
|
25
|
+
export type Output = l.InferMethodOutput<typeof main>;
|
|
26
|
+
export type OutputBody = l.InferMethodOutputBody<typeof main>;
|
|
27
|
+
export declare const $lxm: "com.atproto.repo.deleteRecord", $params: l.ParamsSchema<{}>, $input: l.Payload<"application/json", l.ObjectSchema<{
|
|
25
28
|
readonly repo: l.StringSchema<{
|
|
26
29
|
readonly format: "at-identifier";
|
|
27
30
|
}>;
|
|
@@ -36,7 +39,4 @@ export declare const $params: l.ParamsSchema<{}>, $input: l.Payload<"application
|
|
|
36
39
|
}>>, $output: l.Payload<"application/json", l.ObjectSchema<{
|
|
37
40
|
readonly commit: l.OptionalSchema<RepoDefs.CommitMeta>;
|
|
38
41
|
}>>;
|
|
39
|
-
export type Params = l.InferProcedureParameters<typeof main>;
|
|
40
|
-
export type Input = l.InferProcedureInputBody<typeof main>;
|
|
41
|
-
export type Output = l.InferProcedureOutputBody<typeof main>;
|
|
42
42
|
//# sourceMappingURL=deleteRecord.defs.d.ts.map
|
|
@@ -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
|
|
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,iGAAiG;AACjG,QAAA,MAAM,IAAI;;;;;;;;;;;;;;8BAwBP,CAAA;AACH,OAAO,EAAE,IAAI,EAAE,CAAA;AAEf,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,IAAI,CAAC,CAAA;AACrD,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,gBAAgB,CAAC,OAAO,IAAI,CAAC,CAAA;AACnD,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,oBAAoB,CAAC,OAAO,IAAI,CAAC,CAAA;AAC3D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,IAAI,CAAC,CAAA;AACrD,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,qBAAqB,CAAC,OAAO,IAAI,CAAC,CAAA;AAE7D,eAAO,MAAM,IAAI,iCAA0B,EACzC,OAAO,oBAAgC,EACvC,MAAM;;;;;;;;;;;;GAA2B,EACjC,OAAO;;GAA4B,CAAA"}
|
|
@@ -3,21 +3,18 @@
|
|
|
3
3
|
* THIS FILE WAS GENERATED BY "@atproto/lex". DO NOT EDIT.
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.$output = exports.$input = exports.$params = exports.main = exports.$nsid = void 0;
|
|
6
|
+
exports.$output = exports.$input = exports.$params = exports.$lxm = exports.main = exports.$nsid = void 0;
|
|
7
7
|
const tslib_1 = require("tslib");
|
|
8
8
|
const lex_schema_1 = require("@atproto/lex-schema");
|
|
9
9
|
const RepoDefs = tslib_1.__importStar(require("./defs.defs.js"));
|
|
10
10
|
const $nsid = 'com.atproto.repo.deleteRecord';
|
|
11
11
|
exports.$nsid = $nsid;
|
|
12
|
-
/**
|
|
13
|
-
* Delete a repository record, or ensure it doesn't exist. Requires auth, implemented by PDS.
|
|
14
|
-
*/
|
|
12
|
+
/** Delete a repository record, or ensure it doesn't exist. Requires auth, implemented by PDS. */
|
|
15
13
|
const main =
|
|
16
14
|
/*#__PURE__*/
|
|
17
15
|
lex_schema_1.l.procedure($nsid,
|
|
18
|
-
/*#__PURE__*/ lex_schema_1.l.params(
|
|
19
|
-
/*#__PURE__*/ lex_schema_1.l.
|
|
20
|
-
/*#__PURE__*/ lex_schema_1.l.object({
|
|
16
|
+
/*#__PURE__*/ lex_schema_1.l.params(),
|
|
17
|
+
/*#__PURE__*/ lex_schema_1.l.jsonPayload({
|
|
21
18
|
repo: /*#__PURE__*/ lex_schema_1.l.string({ format: 'at-identifier' }),
|
|
22
19
|
collection: /*#__PURE__*/ lex_schema_1.l.string({ format: 'nsid' }),
|
|
23
20
|
rkey: /*#__PURE__*/ lex_schema_1.l.string({ format: 'record-key' }),
|
|
@@ -25,12 +22,11 @@ lex_schema_1.l.procedure($nsid,
|
|
|
25
22
|
/*#__PURE__*/ lex_schema_1.l.string({ format: 'cid' })),
|
|
26
23
|
swapCommit: /*#__PURE__*/ lex_schema_1.l.optional(
|
|
27
24
|
/*#__PURE__*/ lex_schema_1.l.string({ format: 'cid' })),
|
|
28
|
-
})
|
|
29
|
-
/*#__PURE__*/ lex_schema_1.l.
|
|
30
|
-
/*#__PURE__*/ lex_schema_1.l.object({
|
|
25
|
+
}),
|
|
26
|
+
/*#__PURE__*/ lex_schema_1.l.jsonPayload({
|
|
31
27
|
commit: /*#__PURE__*/ lex_schema_1.l.optional(
|
|
32
28
|
/*#__PURE__*/ lex_schema_1.l.ref((() => RepoDefs.commitMeta))),
|
|
33
|
-
})
|
|
29
|
+
}), ['InvalidSwap']);
|
|
34
30
|
exports.main = main;
|
|
35
|
-
exports.$params = main.parameters, exports.$input = main.input, exports.$output = main.output;
|
|
31
|
+
exports.$lxm = main.nsid, exports.$params = main.parameters, exports.$input = main.input, exports.$output = main.output;
|
|
36
32
|
//# sourceMappingURL=deleteRecord.defs.js.map
|
|
@@ -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
|
|
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,iGAAiG;AACjG,MAAM,IAAI;AACR,aAAa;AACb,cAAC,CAAC,SAAS,CACT,KAAK;AACL,aAAa,CAAC,cAAC,CAAC,MAAM,EAAE;AACxB,aAAa,CAAC,cAAC,CAAC,WAAW,CAAC;IAC1B,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;AACF,aAAa,CAAC,cAAC,CAAC,WAAW,CAAC;IAC1B,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,EACF,CAAC,aAAa,CAAC,CAChB,CAAA;AACM,oBAAI;AAQA,QAAA,IAAI,GAAiB,IAAI,CAAC,IAAI,EACzC,QAAA,OAAO,GAAiB,IAAI,CAAC,UAAU,EACvC,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/** Delete a repository record, or ensure it doesn't exist. Requires auth, implemented by PDS. */\nconst main =\n /*#__PURE__*/\n l.procedure(\n $nsid,\n /*#__PURE__*/ l.params(),\n /*#__PURE__*/ l.jsonPayload({\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 /*#__PURE__*/ l.jsonPayload({\n commit: /*#__PURE__*/ l.optional(\n /*#__PURE__*/ l.ref<RepoDefs.CommitMeta>(\n (() => RepoDefs.commitMeta) as any,\n ),\n ),\n }),\n ['InvalidSwap'],\n )\nexport { main }\n\nexport type Params = l.InferMethodParams<typeof main>\nexport type Input = l.InferMethodInput<typeof main>\nexport type InputBody = l.InferMethodInputBody<typeof main>\nexport type Output = l.InferMethodOutput<typeof main>\nexport type OutputBody = l.InferMethodOutputBody<typeof main>\n\nexport const $lxm = /*#__PURE__*/ main.nsid,\n $params = /*#__PURE__*/ main.parameters,\n $input = /*#__PURE__*/ main.input,\n $output = /*#__PURE__*/ main.output\n"]}
|