Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion crates/bindings-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@
"dependencies": {
"base64-js": "^1.5.1",
"fast-text-encoding": "^1.0.0",
"prettier": "^3.3.3"
"headers-polyfill": "^4.0.3",
"prettier": "^3.3.3",
"statuses": "^2.0.2",
"url-polyfill": "^1.1.14"
},
"peerDependencies": {
"react": "^18.0.0 || ^19.0.0-0 || ^19.0.0",
Expand All @@ -177,6 +180,7 @@
"@size-limit/file": "^11.2.0",
"@types/fast-text-encoding": "^1.0.3",
"@types/react": "^19.1.13",
"@types/statuses": "^2.0.6",
"@typescript-eslint/eslint-plugin": "^8.18.2",
"@typescript-eslint/parser": "^8.18.2",
"@vitest/coverage-v8": "^3.2.4",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions crates/bindings-typescript/src/lib/autogen/http_headers_type.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions crates/bindings-typescript/src/lib/autogen/http_method_type.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions crates/bindings-typescript/src/lib/autogen/http_request_type.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions crates/bindings-typescript/src/lib/autogen/http_response_type.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions crates/bindings-typescript/src/lib/autogen/http_version_type.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions crates/bindings-typescript/src/lib/http_types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export { default as HttpHeaderPair } from './autogen/http_header_pair_type';
export { default as HttpHeaders } from './autogen/http_headers_type';
export { default as HttpMethod } from './autogen/http_method_type';
export { default as HttpRequest } from './autogen/http_request_type';
export { default as HttpResponse } from './autogen/http_response_type';
export { default as HttpVersion } from './autogen/http_version_type';
2 changes: 2 additions & 0 deletions crates/bindings-typescript/src/lib/procedures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AlgebraicType, ProductType } from '../lib/algebraic_type';
import type { ConnectionId } from '../lib/connection_id';
import type { Identity } from '../lib/identity';
import type { Timestamp } from '../lib/timestamp';
import type { HttpClient } from '../server/http_internal';
import type { ParamsObj } from './reducers';
import {
MODULE_DEF,
Expand All @@ -23,6 +24,7 @@ export interface ProcedureCtx<S extends UntypedSchemaDef> {
readonly identity: Identity;
readonly timestamp: Timestamp;
readonly connectionId: ConnectionId | null;
readonly http: HttpClient;
}

export function procedure<
Expand Down
6 changes: 4 additions & 2 deletions crates/bindings-typescript/src/server/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
export class SpacetimeHostError extends Error {
public readonly code: number;
public readonly message: string;
constructor(code: number) {
constructor(code: number, message?: string) {
super();
const proto = Object.getPrototypeOf(this);
let cls;
Expand All @@ -24,7 +24,7 @@ export class SpacetimeHostError extends Error {
}
Object.setPrototypeOf(this, cls.prototype);
this.code = cls.CODE;
this.message = cls.MESSAGE;
this.message = message ?? cls.MESSAGE;
}
get name(): string {
return errnoToClass.get(this.code)?.name ?? 'SpacetimeHostError';
Expand Down Expand Up @@ -151,6 +151,8 @@ const errorData = {
20,
'ABI call can only be made while within a read-only transaction',
],

HttpError: [21, 'The HTTP request failed'],
} as const;

function mapEntries<const T extends Record<string, any>, U>(
Expand Down
2 changes: 2 additions & 0 deletions crates/bindings-typescript/src/server/http.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { Headers, SyncResponse } from './http_internal';
export type { BodyInit, HeadersInit, ResponseInit } from './http_internal';
Loading
Loading