@atproto/xrpc 0.8.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atproto/xrpc
2
2
 
3
+ ## 0.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#4967](https://github.com/bluesky-social/atproto/pull/4967) [`9fc720c`](https://github.com/bluesky-social/atproto/commit/9fc720ce75f3ee88a5e48a9be919b07c7647f6f5) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Use TypeScript 7 to build package
8
+
9
+ - Updated dependencies [[`9fc720c`](https://github.com/bluesky-social/atproto/commit/9fc720ce75f3ee88a5e48a9be919b07c7647f6f5)]:
10
+ - @atproto/lexicon@0.7.2
11
+
3
12
  ## 0.8.0
4
13
 
5
14
  ### Minor Changes
package/README.md CHANGED
@@ -5,6 +5,10 @@ TypeScript client library for talking to [atproto](https://atproto.com) services
5
5
  [![NPM](https://img.shields.io/npm/v/@atproto/xrpc)](https://www.npmjs.com/package/@atproto/xrpc)
6
6
  [![Github CI Status](https://github.com/bluesky-social/atproto/actions/workflows/repo.yaml/badge.svg)](https://github.com/bluesky-social/atproto/actions/workflows/repo.yaml)
7
7
 
8
+ > [!NOTE]
9
+ >
10
+ > We recommend using [lex](https://github.com/bluesky-social/atproto/tree/main/packages/lex/lex), our type-safe SDK with Lexicon code generation, for all new projects.
11
+
8
12
  ## Usage
9
13
 
10
14
  ```typescript
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,iDAAiD;AACjD,qBAAa,MAAM;IACjB,kB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AA;IAC5C,CAAC;IAED,UAAU;IACV,IAAI;IAEJ,UAAU,CAAC,GAAe;QACxB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACnB,CAAC;IAED,WAAW,CAAC,IAAkB;QAC5B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;QACtB,CAAC;IACH,CAAC;IAED,aAAa,CAAC,GAAW;QACvB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IACtB,CAAC;CACF;AAED,iDAAiD;AACjD,MAAM,OAAO,aAAc,SAAQ,UAAU;IAG3C,YACS,UAAkB,EACzB,UAAwB;QAExB,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YAC1B,MAAM,OAAO,GAAG,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;YAC1E,OAAO,KAAK,CAAC,IAAI,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;QAC9D,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,CAAA;QANX,eAAU,GAAV,UAAU,CAAQ;QAOzB,IAAI,CAAC,GAAG,GAAG,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAA;IAC9E,CAAC;CACF","sourcesContent":["import { LexiconDoc, Lexicons } from '@atproto/lexicon'\nimport { CallOptions, QueryParams } from './types.js'\nimport { combineHeaders } from './util.js'\nimport { XrpcClient } from './xrpc-client.js'\n\n/** @deprecated Use {@link XrpcClient} instead */\nexport class Client {\n /** @deprecated */\n get fetch(): never {\n throw new Error(\n 'Client.fetch is no longer supported. Use an XrpcClient instead.',\n )\n }\n\n /** @deprecated */\n set fetch(_: never) {\n throw new Error(\n 'Client.fetch is no longer supported. Use an XrpcClient instead.',\n )\n }\n\n lex = new Lexicons()\n\n // method calls\n //\n\n async call(\n serviceUri: string | URL,\n methodNsid: string,\n params?: QueryParams,\n data?: BodyInit | null,\n opts?: CallOptions,\n ) {\n return this.service(serviceUri).call(methodNsid, params, data, opts)\n }\n\n service(serviceUri: string | URL) {\n return new ServiceClient(this, serviceUri)\n }\n\n // schemas\n // =\n\n addLexicon(doc: LexiconDoc) {\n this.lex.add(doc)\n }\n\n addLexicons(docs: LexiconDoc[]) {\n for (const doc of docs) {\n this.addLexicon(doc)\n }\n }\n\n removeLexicon(uri: string) {\n this.lex.remove(uri)\n }\n}\n\n/** @deprecated Use {@link XrpcClient} instead */\nexport class ServiceClient extends XrpcClient {\n uri: URL\n\n constructor(\n public baseClient: Client,\n serviceUri: string | URL,\n ) {\n super(async (input, init) => {\n const headers = combineHeaders(init.headers, Object.entries(this.headers))\n return fetch(new URL(input, this.uri), { ...init, headers })\n }, baseClient.lex)\n this.uri = typeof serviceUri === 'string' ? new URL(serviceUri) : serviceUri\n }\n}\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,iDAAiD;AACjD,MAAM,OAAO,MAAM;IAAnB;QAeE,QAAG,GAAG,IAAI,QAAQ,EAAE,CAAA;IAmCtB,CAAC;IAjDC,kBAAkB;IAClB,IAAI,KAAK;QACP,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAA;IACH,CAAC;IAED,kBAAkB;IAClB,IAAI,KAAK,CAAC,CAAQ;QAChB,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,C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AQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAA;IAC9E,CAAC;CACF","sourcesContent":["import { LexiconDoc, Lexicons } from '@atproto/lexicon'\nimport { CallOptions, QueryParams } from './types.js'\nimport { combineHeaders } from './util.js'\nimport { XrpcClient } from './xrpc-client.js'\n\n/** @deprecated Use {@link XrpcClient} instead */\nexport class Client {\n /** @deprecated */\n get fetch(): never {\n throw new Error(\n 'Client.fetch is no longer supported. Use an XrpcClient instead.',\n )\n }\n\n /** @deprecated */\n set fetch(_: never) {\n throw new Error(\n 'Client.fetch is no longer supported. Use an XrpcClient instead.',\n )\n }\n\n lex = new Lexicons()\n\n // method calls\n //\n\n async call(\n serviceUri: string | URL,\n methodNsid: string,\n params?: QueryParams,\n data?: BodyInit | null,\n opts?: CallOptions,\n ) {\n return this.service(serviceUri).call(methodNsid, params, data, opts)\n }\n\n service(serviceUri: string | URL) {\n return new ServiceClient(this, serviceUri)\n }\n\n // schemas\n // =\n\n addLexicon(doc: LexiconDoc) {\n this.lex.add(doc)\n }\n\n addLexicons(docs: LexiconDoc[]) {\n for (const doc of docs) {\n this.addLexicon(doc)\n }\n }\n\n removeLexicon(uri: string) {\n this.lex.remove(uri)\n }\n}\n\n/** @deprecated Use {@link XrpcClient} instead */\nexport class ServiceClient extends XrpcClient {\n uri: URL\n\n constructor(\n public baseClient: Client,\n serviceUri: string | URL,\n ) {\n super(async (input, init) => {\n const headers = combineHeaders(init.headers, Object.entries(this.headers))\n return fetch(new URL(input, this.uri), { ...init, headers })\n }, baseClient.lex)\n this.uri = typeof serviceUri === 'string' ? new URL(serviceUri) : serviceUri\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,qEAAqE;AACrE,QAAA,MAAM,WAAW,QAAe,CAAA;AAChC,eAAe,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAEhC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,qEAAqE;AACrE,QAAA,MAAM,WAAW,QAAe,CAAA;eACjB,WAAW"}
package/dist/types.d.ts CHANGED
@@ -49,22 +49,22 @@ export declare enum ResponseType {
49
49
  export declare function httpResponseCodeToEnum(status: number): ResponseType;
50
50
  export declare function httpResponseCodeToName(status: number): string;
51
51
  export declare const ResponseTypeStrings: {
52
- readonly 1: "Unknown";
53
- readonly 2: "Invalid Response";
54
- readonly 200: "Success";
55
- readonly 400: "Invalid Request";
56
- readonly 401: "Authentication Required";
57
- readonly 403: "Forbidden";
58
- readonly 404: "XRPC Not Supported";
59
- readonly 406: "Not Acceptable";
60
- readonly 413: "Payload Too Large";
61
- readonly 415: "Unsupported Media Type";
62
- readonly 429: "Rate Limit Exceeded";
63
- readonly 500: "Internal Server Error";
64
- readonly 501: "Method Not Implemented";
65
- readonly 502: "Upstream Failure";
66
- readonly 503: "Not Enough Resources";
67
- readonly 504: "Upstream Timeout";
52
+ readonly 1: 'Unknown';
53
+ readonly 2: 'Invalid Response';
54
+ readonly 200: 'Success';
55
+ readonly 400: 'Invalid Request';
56
+ readonly 401: 'Authentication Required';
57
+ readonly 403: 'Forbidden';
58
+ readonly 404: 'XRPC Not Supported';
59
+ readonly 406: 'Not Acceptable';
60
+ readonly 413: 'Payload Too Large';
61
+ readonly 415: 'Unsupported Media Type';
62
+ readonly 429: 'Rate Limit Exceeded';
63
+ readonly 500: 'Internal Server Error';
64
+ readonly 501: 'Method Not Implemented';
65
+ readonly 502: 'Upstream Failure';
66
+ readonly 503: 'Not Enough Resources';
67
+ readonly 504: 'Upstream Timeout';
68
68
  };
69
69
  export declare function httpResponseCodeToString(status: number): string;
70
70
  export declare class XRPCResponse {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAElD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAC7C,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;AAE3D,YAAY;AACV,yEAAyE;AACzE,UAAU,IAAI,OAAO,GACtB,CAAA;AAED,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;AAEvC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,OAAO,CAAC,EAAE,UAAU,CAAA;CACrB;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;EAG5B,CAAA;AACF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEjE,oBAAY,YAAY;IACtB;;OAEG;IACH,OAAO,IAAI;IACX;;OAEG;IACH,eAAe,IAAI;IACnB,OAAO,MAAM;IACb,cAAc,MAAM;IACpB,sBAAsB,MAAM;IAC5B,SAAS,MAAM;IACf,gBAAgB,MAAM;IACtB,aAAa,MAAM;IACnB,eAAe,MAAM;IACrB,oBAAoB,MAAM;IAC1B,iBAAiB,MAAM;IACvB,mBAAmB,MAA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,CAAC,CAAC,cAAc,IAAI,YAAY,CAAC,OAAO,CAAA;QAE5C,MAAM,OAAO,GAAG,QAAQ,EAAE,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAA;QAElD,MAAM,OAAO,GAAG,aAAa;YAC3B,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACrD,CAAC,CAAC,SAAS,CAAA;QAEb,OAAO,IAAI,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;IACtE,CAAC;CACF;AAED,MAAM,OAAO,wBAAyB,SAAQ,SAAS;IACrD,YACS,WAAmB,EACnB,eAAgC,EAChC,YAAqB;QAE5B,KAAK,CACH,YAAY,CAAC,eAAe;QAC5B,0EAA0E;QAC1E,uCAAuC;QACvC,mBAAmB,CAAC,YAAY,CAAC,eAAe,CAAC,EACjD,6DAA6D,EAC7D,SAAS,EACT,EAAE,KAAK,EAAE,eAAe,EAAE,CAC3B,CAAA;QAZM,gBAAW,GAAX,WAAW,CAAQ;QACnB,oBAAe,GAAf,eAAe,CAAiB;QAChC,iBAAY,GAAZ,YAAY,CAAS;IAW9B,CAAC;CACF","sourcesContent":["import { z } from 'zod'\nimport { ValidationError } from '@atproto/lexicon'\n\nexport type QueryParams = Record<string, any>\nexport type HeadersMap = Record<string, string | undefined>\n\nexport type {\n /** @deprecated not to be confused with the WHATWG Headers constructor */\n HeadersMap as Headers,\n}\n\nexport type Gettable<T> = T | (() => T)\n\nexport interface CallOptions {\n encoding?: string\n signal?: AbortSignal\n headers?: HeadersMap\n}\n\nexport const errorResponseBody = z.object({\n error: z.string().optional(),\n message: z.string().optional(),\n})\nexport type ErrorResponseBody = z.infer<typeof errorResponseBody>\n\nexport enum ResponseType {\n /**\n * Network issue, unable to get response from the server.\n */\n Unknown = 1,\n /**\n * Response failed lexicon validation.\n */\n InvalidResponse = 2,\n Success = 200,\n InvalidRequest = 400,\n AuthenticationRequired = 401,\n Forbidden = 403,\n XRPCNotSupported = 404,\n NotAcceptable = 406,\n PayloadTooLarge = 413,\n UnsupportedMediaType = 415,\n RateLimitExceeded = 429,\n InternalServerError = 500,\n MethodNotImplemented = 501,\n UpstreamFailure = 502,\n NotEnoughResources = 503,\n UpstreamTimeout = 504,\n}\n\nexport function httpResponseCodeToEnum(status: number): ResponseType {\n if (status in ResponseType) {\n return status\n } else if (status >= 100 && status < 200) {\n return ResponseType.XRPCNotSupported\n } else if (status >= 200 && status < 300) {\n return ResponseType.Success\n } else if (status >= 300 && status < 400) {\n return ResponseType.XRPCNotSupported\n } else if (status >= 400 && status < 500) {\n return ResponseType.InvalidRequest\n } else {\n return ResponseType.InternalServerError\n }\n}\n\nexport function httpResponseCodeToName(status: number): string {\n return ResponseType[httpResponseCodeToEnum(status)]\n}\n\nexport const ResponseTypeStrings = {\n [ResponseType.Unknown]: 'Unknown',\n [ResponseType.InvalidResponse]: 'Invalid Response',\n [ResponseType.Success]: 'Success',\n [ResponseType.InvalidRequest]: 'Invalid Request',\n [ResponseType.AuthenticationRequired]: 'Authentication Required',\n [ResponseType.Forbidden]: 'Forbidden',\n [ResponseType.XRPCNotSupported]: 'XRPC Not Supported',\n [ResponseType.NotAcceptable]: 'Not Acceptable',\n [ResponseType.PayloadTooLarge]: 'Payload Too Large',\n [ResponseType.UnsupportedMediaType]: 'Unsupported Media Type',\n [ResponseType.RateLimitExceeded]: 'Rate Limit Exceeded',\n [ResponseType.InternalServerError]: 'Internal Server Error',\n [ResponseType.MethodNotImplemented]: 'Method Not Implemented',\n [ResponseType.UpstreamFailure]: 'Upstream Failure',\n [ResponseType.NotEnoughResources]: 'Not Enough Resources',\n [ResponseType.UpstreamTimeout]: 'Upstream Timeout',\n} as const satisfies Record<ResponseType, string>\n\nexport function httpResponseCodeToString(status: number): string {\n return ResponseTypeStrings[httpResponseCodeToEnum(status)]\n}\n\nexport class XRPCResponse {\n success = true\n\n constructor(\n public data: any,\n public headers: HeadersMap,\n ) {}\n}\n\nexport class XRPCError extends Error {\n success = false\n\n public status: ResponseType\n\n constructor(\n statusCode: number,\n public error: string = httpResponseCodeToName(statusCode),\n message?: string,\n public headers?: HeadersMap,\n options?: ErrorOptions,\n ) {\n super(message || error || httpResponseCodeToString(statusCode), options)\n\n this.status = httpResponseCodeToEnum(statusCode)\n\n // Pre 2022 runtimes won't handle the \"options\" constructor argument\n const cause = options?.cause\n if (this.cause === undefined && cause !== undefined) {\n this.cause = cause\n }\n }\n\n static from(cause: unknown, fallbackStatus?: ResponseType): XRPCError {\n if (cause instanceof XRPCError) {\n return cause\n }\n\n // Type cast the cause to an Error if it is one\n const causeErr = cause instanceof Error ? cause : undefined\n\n // Try and find a Response object in the cause\n const causeResponse: Response | undefined =\n cause instanceof Response\n ? cause\n : cause?.['response'] instanceof Response\n ? cause['response']\n : undefined\n\n const statusCode: unknown =\n // Extract status code from \"http-errors\" like errors\n causeErr?.['statusCode'] ??\n causeErr?.['status'] ??\n // Use the status code from the response object as fallback\n causeResponse?.status\n\n // Convert the status code to a ResponseType\n const status: ResponseType =\n typeof statusCode === 'number'\n ? httpResponseCodeToEnum(statusCode)\n : fallbackStatus ?? ResponseType.Unknown\n\n const message = causeErr?.message ?? String(cause)\n\n const headers = causeResponse\n ? Object.fromEntries(causeResponse.headers.entries())\n : undefined\n\n return new XRPCError(status, undefined, message, headers, { cause })\n }\n}\n\nexport class XRPCInvalidResponseError extends XRPCError {\n constructor(\n public lexiconNsid: string,\n public validationError: ValidationError,\n public responseBody: unknown,\n ) {\n super(\n ResponseType.InvalidResponse,\n // @NOTE: This is probably wrong and should use ResponseTypeNames instead.\n // But it would mean a breaking change.\n ResponseTypeStrings[ResponseType.InvalidResponse],\n `The server gave an invalid response and may be out of date.`,\n undefined,\n { cause: validationError },\n )\n }\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,E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Q,EAAE,CAAC,YAAY,CAAC;YACxB,QAAQ,EAAE,CAAC,QAAQ,CAAC;YACpB,2DAA2D;YAC3D,aAAa,EAAE,MAAM,CAAA;QAEvB,4CAA4C;QAC5C,MAAM,MAAM,GACV,OAAO,UAAU,KAAK,QAAQ;YAC5B,CAAC,CAAC,sBAAsB,CAAC,UAAU,CAAC;YACpC,CAAC,CAAC,cAAc,IAAI,YAAY,CAAC,OAAO,CAAA;QAE5C,MAAM,OAAO,GAAG,QAAQ,EAAE,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAA;QAElD,MAAM,OAAO,GAAG,aAAa;YAC3B,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACrD,CAAC,CAAC,SAAS,CAAA;QAEb,OAAO,IAAI,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;IACtE,CAAC;CACF;AAED,MAAM,OAAO,wBAAyB,SAAQ,SAAS;IACrD,YACS,WAAmB,EACnB,eAAgC,EAChC,YAAqB;QAE5B,KAAK,CACH,YAAY,CAAC,eAAe;QAC5B,0EAA0E;QAC1E,uCAAuC;QACvC,mBAAmB,CAAC,YAAY,CAAC,eAAe,CAAC,EACjD,6DAA6D,EAC7D,SAAS,EACT,EAAE,KAAK,EAAE,eAAe,EAAE,CAC3B,CAAA;2BAZM,WAAW;+BACX,eAAe;4BACf,YAAY;IAWrB,CAAC;CACF","sourcesContent":["import { z } from 'zod'\nimport { ValidationError } from '@atproto/lexicon'\n\nexport type QueryParams = Record<string, any>\nexport type HeadersMap = Record<string, string | undefined>\n\nexport type {\n /** @deprecated not to be confused with the WHATWG Headers constructor */\n HeadersMap as Headers,\n}\n\nexport type Gettable<T> = T | (() => T)\n\nexport interface CallOptions {\n encoding?: string\n signal?: AbortSignal\n headers?: HeadersMap\n}\n\nexport const errorResponseBody = z.object({\n error: z.string().optional(),\n message: z.string().optional(),\n})\nexport type ErrorResponseBody = z.infer<typeof errorResponseBody>\n\nexport enum ResponseType {\n /**\n * Network issue, unable to get response from the server.\n */\n Unknown = 1,\n /**\n * Response failed lexicon validation.\n */\n InvalidResponse = 2,\n Success = 200,\n InvalidRequest = 400,\n AuthenticationRequired = 401,\n Forbidden = 403,\n XRPCNotSupported = 404,\n NotAcceptable = 406,\n PayloadTooLarge = 413,\n UnsupportedMediaType = 415,\n RateLimitExceeded = 429,\n InternalServerError = 500,\n MethodNotImplemented = 501,\n UpstreamFailure = 502,\n NotEnoughResources = 503,\n UpstreamTimeout = 504,\n}\n\nexport function httpResponseCodeToEnum(status: number): ResponseType {\n if (status in ResponseType) {\n return status\n } else if (status >= 100 && status < 200) {\n return ResponseType.XRPCNotSupported\n } else if (status >= 200 && status < 300) {\n return ResponseType.Success\n } else if (status >= 300 && status < 400) {\n return ResponseType.XRPCNotSupported\n } else if (status >= 400 && status < 500) {\n return ResponseType.InvalidRequest\n } else {\n return ResponseType.InternalServerError\n }\n}\n\nexport function httpResponseCodeToName(status: number): string {\n return ResponseType[httpResponseCodeToEnum(status)]\n}\n\nexport const ResponseTypeStrings = {\n [ResponseType.Unknown]: 'Unknown',\n [ResponseType.InvalidResponse]: 'Invalid Response',\n [ResponseType.Success]: 'Success',\n [ResponseType.InvalidRequest]: 'Invalid Request',\n [ResponseType.AuthenticationRequired]: 'Authentication Required',\n [ResponseType.Forbidden]: 'Forbidden',\n [ResponseType.XRPCNotSupported]: 'XRPC Not Supported',\n [ResponseType.NotAcceptable]: 'Not Acceptable',\n [ResponseType.PayloadTooLarge]: 'Payload Too Large',\n [ResponseType.UnsupportedMediaType]: 'Unsupported Media Type',\n [ResponseType.RateLimitExceeded]: 'Rate Limit Exceeded',\n [ResponseType.InternalServerError]: 'Internal Server Error',\n [ResponseType.MethodNotImplemented]: 'Method Not Implemented',\n [ResponseType.UpstreamFailure]: 'Upstream Failure',\n [ResponseType.NotEnoughResources]: 'Not Enough Resources',\n [ResponseType.UpstreamTimeout]: 'Upstream Timeout',\n} as const satisfies Record<ResponseType, string>\n\nexport function httpResponseCodeToString(status: number): string {\n return ResponseTypeStrings[httpResponseCodeToEnum(status)]\n}\n\nexport class XRPCResponse {\n success = true\n\n constructor(\n public data: any,\n public headers: HeadersMap,\n ) {}\n}\n\nexport class XRPCError extends Error {\n success = false\n\n public status: ResponseType\n\n constructor(\n statusCode: number,\n public error: string = httpResponseCodeToName(statusCode),\n message?: string,\n public headers?: HeadersMap,\n options?: ErrorOptions,\n ) {\n super(message || error || httpResponseCodeToString(statusCode), options)\n\n this.status = httpResponseCodeToEnum(statusCode)\n\n // Pre 2022 runtimes won't handle the \"options\" constructor argument\n const cause = options?.cause\n if (this.cause === undefined && cause !== undefined) {\n this.cause = cause\n }\n }\n\n static from(cause: unknown, fallbackStatus?: ResponseType): XRPCError {\n if (cause instanceof XRPCError) {\n return cause\n }\n\n // Type cast the cause to an Error if it is one\n const causeErr = cause instanceof Error ? cause : undefined\n\n // Try and find a Response object in the cause\n const causeResponse: Response | undefined =\n cause instanceof Response\n ? cause\n : cause?.['response'] instanceof Response\n ? cause['response']\n : undefined\n\n const statusCode: unknown =\n // Extract status code from \"http-errors\" like errors\n causeErr?.['statusCode'] ??\n causeErr?.['status'] ??\n // Use the status code from the response object as fallback\n causeResponse?.status\n\n // Convert the status code to a ResponseType\n const status: ResponseType =\n typeof statusCode === 'number'\n ? httpResponseCodeToEnum(statusCode)\n : fallbackStatus ?? ResponseType.Unknown\n\n const message = causeErr?.message ?? String(cause)\n\n const headers = causeResponse\n ? Object.fromEntries(causeResponse.headers.entries())\n : undefined\n\n return new XRPCError(status, undefined, message, headers, { cause })\n }\n}\n\nexport class XRPCInvalidResponseError extends XRPCError {\n constructor(\n public lexiconNsid: string,\n public validationError: ValidationError,\n public responseBody: unknown,\n ) {\n super(\n ResponseType.InvalidResponse,\n // @NOTE: This is probably wrong and should use ResponseTypeNames instead.\n // But it would mean a breaking change.\n ResponseTypeStrings[ResponseType.InvalidResponse],\n `The server gave an invalid response and may be out of date.`,\n undefined,\n { cause: validationError },\n )\n }\n}\n"]}
package/dist/util.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { LexXrpcProcedure, LexXrpcQuery } from '@atproto/lexicon';
2
2
  import { CallOptions, ErrorResponseBody, Gettable, QueryParams } from './types.js';
3
3
  export declare function isErrorResponseBody(v: unknown): v is ErrorResponseBody;
4
- export declare function getMethodSchemaHTTPMethod(schema: LexXrpcProcedure | LexXrpcQuery): "post" | "get";
4
+ export declare function getMethodSchemaHTTPMethod(schema: LexXrpcProcedure | LexXrpcQuery): "get" | "post";
5
5
  export declare function constructMethodCallUri(nsid: string, schema: LexXrpcProcedure | LexXrpcQuery, serviceUri: URL, params?: QueryParams): string;
6
6
  export declare function constructMethodCallUrl(nsid: string, schema: LexXrpcProcedure | LexXrpcQuery, params?: QueryParams): string;
7
7
  export declare function encodeQueryParam(type: 'string' | 'float' | 'integer' | 'boolean' | 'datetime' | 'array' | 'unknown', value: any): string;
@@ -1 +1 @@
1
- {"version":3,"file":"xrpc-client.d.ts","sourceRoot":"","sources":["../src/xrpc-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAmB,MAAM,kBAAkB,CAAA;AACxE,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EAEpB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,WAAW,EACX,QAAQ,EACR,WAAW,EAIX,YAAY,EAEb,MAAM,YAAY,CAAA;AAWnB,qBAAa,UAAU;IACrB,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAA;IACnC,QAAQ,CAAC,OAAO,uCAA6C;IAC7D,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAA;gBAGpB,gBAAgB,EAAE,YAAY,GAAG,kBAAkB,GAAG,mBAAmB,EAGzE,GAAG,EAAE,QAAQ,GAAG,QAAQ,CAAC,UAAU,CAAC;IAOt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jB,OAAO,CAAC,YAAY,CAAC,CA8DvB;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/xrpc",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },
@@ -18,11 +18,9 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "zod": "^3.23.8",
21
- "@atproto/lexicon": "^0.7.0"
22
- },
23
- "devDependencies": {
24
- "typescript": "^6.0.3"
21
+ "@atproto/lexicon": "^0.7.2"
25
22
  },
23
+ "devDependencies": {},
26
24
  "type": "module",
27
25
  "exports": {
28
26
  ".": {
@@ -31,6 +29,6 @@
31
29
  }
32
30
  },
33
31
  "scripts": {
34
- "build": "tsc --build tsconfig.build.json"
32
+ "build": "tsgo --build tsconfig.build.json"
35
33
  }
36
34
  }
@@ -2,7 +2,7 @@
2
2
  "extends": "../../tsconfig/isomorphic.json",
3
3
  "compilerOptions": {
4
4
  "rootDir": "./src",
5
- "outDir": "./dist"
5
+ "outDir": "./dist",
6
6
  },
7
- "include": ["./src"]
7
+ "include": ["./src"],
8
8
  }
@@ -1 +1 @@
1
- {"root":["./src/client.ts","./src/fetch-handler.ts","./src/index.ts","./src/types.ts","./src/util.ts","./src/xrpc-client.ts"],"version":"6.0.3"}
1
+ {"version":"7.0.0-dev.20260614.1","root":["./src/client.ts","./src/fetch-handler.ts","./src/index.ts","./src/types.ts","./src/util.ts","./src/xrpc-client.ts"]}
package/tsconfig.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "include": [],
3
- "references": [{ "path": "./tsconfig.build.json" }]
3
+ "references": [{ "path": "./tsconfig.build.json" }],
4
4
  }