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
20 changes: 10 additions & 10 deletions packages/functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2386,9 +2386,9 @@ References:

#### :gear: HttpRequestArgsSchema

| Constant | Type |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `HttpRequestArgsSchema` | `ZodObject<{ url: ZodString; method: ZodEnum<{ GET: "GET"; POST: "POST"; HEAD: "HEAD"; }>; headers: ZodArray<ZodObject<{ name: ZodString; value: ZodString; }, $strip>>; body: ZodOptional<...>; maxResponseBytes: ZodOptional<...>; transform: ZodOptional<...>; isReplicated: ZodOptional<...>; }, $strip>` |
| Constant | Type |
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `HttpRequestArgsSchema` | `ZodObject<{ url: ZodURL; method: ZodEnum<{ GET: "GET"; POST: "POST"; HEAD: "HEAD"; }>; headers: ZodArray<ZodObject<{ name: ZodString; value: ZodString; }, $strip>>; body: ZodOptional<...>; maxResponseBytes: ZodOptional<...>; transform: ZodOptional<...>; isReplicated: ZodOptional<...>; }, $strip>` |

References:

Expand All @@ -2406,7 +2406,7 @@ References:

- HttpRequestResult

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/http-request.ts#L33)
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/http-request.ts#L32)

#### :gear: TransformArgsSchema

Expand All @@ -2418,7 +2418,7 @@ References:

- TransformArgs

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/http-request.ts#L42)
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/http-request.ts#L41)

### :factory: CallResponseLengthError

Expand Down Expand Up @@ -2842,7 +2842,7 @@ An HTTP header consisting of a name and value.
| `name` | `string` | The header name. |
| `value` | `string` | The header value. |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/http-request.ts#L50)
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/http-request.ts#L49)

#### :gear: HttpRequestArgs

Expand All @@ -2858,7 +2858,7 @@ The arguments for an HTTP request.
| `transform` | `string or undefined` | The name of a query function used to transform the response before consensus - for example, to trim headers. If provided, a corresponding query must be declared using {@link defineQuery }. |
| `isReplicated` | `boolean or undefined` | Whether all nodes should perform the request and agree on the response, or just one node. Using a single node is cheaper but the response is not verified by others - suitable when you trust the data source or consistency is not critical. Defaults to all nodes if not specified. |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/http-request.ts#L70)
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/http-request.ts#L69)

#### :gear: HttpRequestResult

Expand All @@ -2870,7 +2870,7 @@ The result of an HTTP request.
| `headers` | `HttpHeader[]` | List of HTTP response headers and their corresponding values. |
| `body` | `Uint8Array<ArrayBuffer>` | The response's body. |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/http-request.ts#L113)
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/http-request.ts#L112)

#### :gear: TransformArgs

Expand All @@ -2881,7 +2881,7 @@ The arguments passed to an HTTP response transform function.
| `response` | `HttpRequestResult` | The raw HTTP response to be transformed. |
| `context` | `Uint8Array<ArrayBuffer>` | Context for response transformation |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/http-request.ts#L133)
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/http-request.ts#L132)

### :cocktail: Types

Expand Down Expand Up @@ -4066,7 +4066,7 @@ The HTTP method for the request.
| ------------ | --------------------------- |
| `HttpMethod` | `'GET' or 'POST' or 'HEAD'` |

[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/http-request.ts#L65)
[:link: Source](https://github.com/junobuild/juno-js/tree/main/packages/functions/src/ic-cdk/schemas/http-request.ts#L64)

<!-- TSDOC_END -->

Expand Down
3 changes: 1 addition & 2 deletions packages/functions/src/ic-cdk/schemas/http-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ export const HttpMethodSchema = j.enum(['GET', 'POST', 'HEAD']);
* @see HttpRequestArgs
*/
export const HttpRequestArgsSchema = j.object({
// TODO exclude url in j and expose custom
url: j.string(),
url: j.url(),
method: HttpMethodSchema,
headers: j.array(HttpHeaderSchema),
body: j.uint8Array().optional(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('ic-cdk > http-request', () => {
expect(result).toEqual(mockResult);
});

it.todo('should throw if args do not match the schema', async () => {
it('should throw if args do not match the schema', async () => {
await expect(httpRequest({...validArgs, url: 'not-a-url'})).rejects.toThrow();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('ic-cdk > schemas > http-request', () => {
expect(() => HttpRequestArgsSchema.parse(validArgs)).not.toThrow();
});

it.todo('should reject an invalid URL', () => {
it('should reject an invalid URL', () => {
expect(() => HttpRequestArgsSchema.parse({...validArgs, url: 'not-a-url'})).toThrow();
});

Expand Down