@atproto/xrpc
Advanced tools
Comparing version 0.0.4 to 0.1.0
@@ -5,3 +5,3 @@ import { LexXrpcProcedure, LexXrpcQuery } from '@atproto/lexicon'; | ||
export declare function constructMethodCallUri(nsid: string, schema: LexXrpcProcedure | LexXrpcQuery, serviceUri: URL, params?: QueryParams): string; | ||
export declare function encodeQueryParam(type: 'string' | 'number' | 'integer' | 'boolean' | 'datetime' | 'array' | 'unknown', value: any): string; | ||
export declare function encodeQueryParam(type: 'string' | 'float' | 'integer' | 'boolean' | 'datetime' | 'array' | 'unknown', value: any): string; | ||
export declare function constructMethodCallHeaders(schema: LexXrpcProcedure | LexXrpcQuery, data?: any, opts?: CallOptions): Headers; | ||
@@ -8,0 +8,0 @@ export declare function encodeMethodCallBody(headers: Headers, data?: any): ArrayBuffer | undefined; |
{ | ||
"name": "@atproto/xrpc", | ||
"version": "0.0.4", | ||
"version": "0.1.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -1,3 +0,8 @@ | ||
import { LexXrpcProcedure, LexXrpcQuery } from '@atproto/lexicon' | ||
import { | ||
jsonStringToLex, | ||
LexXrpcProcedure, | ||
LexXrpcQuery, | ||
stringifyLex, | ||
} from '@atproto/lexicon' | ||
import { | ||
CallOptions, | ||
@@ -57,3 +62,3 @@ Headers, | ||
| 'string' | ||
| 'number' | ||
| 'float' | ||
| 'integer' | ||
@@ -69,3 +74,3 @@ | 'boolean' | ||
} | ||
if (type === 'number') { | ||
if (type === 'float') { | ||
return String(Number(value)) | ||
@@ -118,3 +123,3 @@ } else if (type === 'integer') { | ||
if (headers['Content-Type'].startsWith('application/json')) { | ||
return new TextEncoder().encode(JSON.stringify(data)) | ||
return new TextEncoder().encode(stringifyLex(data)) | ||
} | ||
@@ -150,3 +155,3 @@ return data | ||
const str = new TextDecoder().decode(data) | ||
return JSON.parse(str) | ||
return jsonStringToLex(str) | ||
} catch (e) { | ||
@@ -170,3 +175,6 @@ throw new XRPCError( | ||
} | ||
if (data instanceof ArrayBuffer) { | ||
return new Uint8Array(data) | ||
} | ||
return data | ||
} |
@@ -10,4 +10,5 @@ { | ||
"references": [ | ||
{ "path": "../common/tsconfig.build.json" }, | ||
{ "path": "../lexicon/tsconfig.build.json" } | ||
] | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
611463
7426