@ts-pf/astro 0.1.1 → 0.2.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/LICENSE +21 -0
- package/README.md +12 -1
- package/dist/client.d.ts +11 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +13 -24
- package/dist/client.js.map +1 -1
- package/dist/server.d.ts +10 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +8 -0
- package/dist/server.js.map +1 -1
- package/package.json +11 -6
- package/skills/ts-pf-astro/SKILL.md +4 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ts-pf contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ const planet = await caller.planet.find({ id: 1 })
|
|
|
36
36
|
|
|
37
37
|
Import the contract with `import type`. Do not import `@ts-pf/astro/server` or the implementer from a client island or `<script>`. `@ts-pf/swr` works on this client for React islands.
|
|
38
38
|
|
|
39
|
-
```ts
|
|
39
|
+
```ts bundler
|
|
40
40
|
import { createAstroClient, withBase } from '@ts-pf/astro/client'
|
|
41
41
|
import type { contract } from './contract'
|
|
42
42
|
|
|
@@ -44,3 +44,14 @@ export const client = createAstroClient<typeof contract>({
|
|
|
44
44
|
prefix: withBase(import.meta.env.BASE_URL, '/rpc'),
|
|
45
45
|
})
|
|
46
46
|
```
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
- `createAstroHandler`
|
|
51
|
+
- `createAstroLocalClient`
|
|
52
|
+
- `createAstroClient`
|
|
53
|
+
- `withBase`
|
|
54
|
+
- `AstroHandlerOptions`
|
|
55
|
+
- `AstroLocalClientOptions`
|
|
56
|
+
|
|
57
|
+
`createAstroHandler`, `createAstroLocalClient`, `AstroHandlerOptions`, and `AstroLocalClientOptions` are `@ts-pf/astro/server`. `createAstroClient` and `withBase` are `@ts-pf/astro` and `@ts-pf/astro/client`.
|
package/dist/client.d.ts
CHANGED
|
@@ -2,13 +2,22 @@ import { type CallInterceptor, type CallPlugin } from '@ts-pf/client';
|
|
|
2
2
|
import { FetchLink } from '@ts-pf/client-http';
|
|
3
3
|
import type { ContractClient } from '@ts-pf/contract';
|
|
4
4
|
type FetchLinkOptions = ConstructorParameters<typeof FetchLink>[0];
|
|
5
|
-
|
|
5
|
+
type AstroClientOptions = {
|
|
6
6
|
prefix: string;
|
|
7
7
|
headers?: NonNullable<FetchLinkOptions['headers']>;
|
|
8
8
|
fetch?: NonNullable<FetchLinkOptions['fetch']>;
|
|
9
9
|
codec?: NonNullable<FetchLinkOptions['codec']>;
|
|
10
10
|
plugins?: readonly CallPlugin[];
|
|
11
11
|
interceptors?: readonly CallInterceptor[];
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Browser / island client. Pass the contract type:
|
|
15
|
+
* `createAstroClient<typeof contract>({ prefix })`. Without it `T` is `never`
|
|
16
|
+
* and the result is a single `~error` member naming the fix (same rule as
|
|
17
|
+
* `createClient`).
|
|
18
|
+
*/
|
|
19
|
+
export declare function createAstroClient<T = never>(opts: AstroClientOptions): [T] extends [never] ? {
|
|
20
|
+
readonly '~error': 'Pass createAstroClient<typeof contract>({ prefix })';
|
|
21
|
+
} : ContractClient<T>;
|
|
13
22
|
export { withBase } from './with-base.js';
|
|
14
23
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,UAAU,EAEhB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,UAAU,EAEhB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAGrD,KAAK,gBAAgB,GAAG,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;AAElE,KAAK,kBAAkB,GAAG;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAA;IAClD,KAAK,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAA;IAC9C,KAAK,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAA;IAC9C,OAAO,CAAC,EAAE,SAAS,UAAU,EAAE,CAAA;IAC/B,YAAY,CAAC,EAAE,SAAS,eAAe,EAAE,CAAA;CAC1C,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,KAAK,EACzC,IAAI,EAAE,kBAAkB,GACvB,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAClB;IAAE,QAAQ,CAAC,QAAQ,EAAE,qDAAqD,CAAA;CAAE,GAC5E,cAAc,CAAC,CAAC,CAAC,CAAA;AAqCrB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/client.js
CHANGED
|
@@ -1,36 +1,25 @@
|
|
|
1
1
|
import { createClient, } from '@ts-pf/client';
|
|
2
2
|
import { FetchLink } from '@ts-pf/client-http';
|
|
3
|
+
import { defined } from '@ts-pf/protocol';
|
|
3
4
|
export function createAstroClient(opts) {
|
|
4
5
|
const link = new FetchLink(fetchLinkOptions(opts));
|
|
5
6
|
const clientOpts = clientOptions(opts);
|
|
6
|
-
return clientOpts
|
|
7
|
+
return clientOpts
|
|
8
|
+
? createClient(link, clientOpts)
|
|
9
|
+
: createClient(link);
|
|
7
10
|
}
|
|
8
11
|
function fetchLinkOptions(opts) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
if (opts.fetch !== undefined) {
|
|
14
|
-
linkOpts.fetch = opts.fetch;
|
|
15
|
-
}
|
|
16
|
-
if (opts.codec !== undefined) {
|
|
17
|
-
linkOpts.codec = opts.codec;
|
|
18
|
-
}
|
|
19
|
-
return linkOpts;
|
|
12
|
+
return {
|
|
13
|
+
url: opts.prefix,
|
|
14
|
+
...defined({ headers: opts.headers, fetch: opts.fetch, codec: opts.codec }),
|
|
15
|
+
};
|
|
20
16
|
}
|
|
21
17
|
function clientOptions(opts) {
|
|
22
|
-
const clientOpts = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
clientOpts.interceptors = opts.interceptors;
|
|
28
|
-
}
|
|
29
|
-
if (clientOpts.plugins === undefined &&
|
|
30
|
-
clientOpts.interceptors === undefined) {
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
return clientOpts;
|
|
18
|
+
const clientOpts = defined({
|
|
19
|
+
plugins: opts.plugins,
|
|
20
|
+
interceptors: opts.interceptors,
|
|
21
|
+
});
|
|
22
|
+
return Object.keys(clientOpts).length === 0 ? undefined : clientOpts;
|
|
34
23
|
}
|
|
35
24
|
export { withBase } from './with-base.js';
|
|
36
25
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,GACb,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,GACb,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAwBzC,MAAM,UAAU,iBAAiB,CAAC,IAAwB;IACxD,MAAM,IAAI,GAAG,IAAI,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAA;IAClD,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,CAAA;IACtC,OAAO,UAAU;QACf,CAAC,CAAC,YAAY,CAAU,IAAI,EAAE,UAAU,CAAC;QACzC,CAAC,CAAC,YAAY,CAAU,IAAI,CAAC,CAAA;AACjC,CAAC;AAED,SAAS,gBAAgB,CAAC,IAKzB;IACC,OAAO;QACL,GAAG,EAAE,IAAI,CAAC,MAAM;QAChB,GAAG,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;KAC5E,CAAA;AACH,CAAC;AAED,SAAS,aAAa,CAAC,IAGtB;IAMC,MAAM,UAAU,GAAG,OAAO,CAAC;QACzB,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,YAAY,EAAE,IAAI,CAAC,YAAY;KAChC,CAAC,CAAA;IACF,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAA;AACtE,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/server.d.ts
CHANGED
|
@@ -11,9 +11,17 @@ export type AstroLocalClientOptions = {
|
|
|
11
11
|
plugins?: readonly CallPlugin[];
|
|
12
12
|
validation?: ProcedureValidation;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* `TCtx` comes from the `FetchHandler` (which inferred it from the router), so
|
|
16
|
+
* `options.context` is checked against the app's `$context<C>()` type.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createAstroHandler<TCtx>(handler: FetchHandler<TCtx>, options: AstroHandlerOptions<NoInfer<TCtx>>): (context: APIContext) => Promise<Response>;
|
|
19
|
+
/**
|
|
20
|
+
* `TCtx` is inferred from the router's context brand, so `context` is checked
|
|
21
|
+
* against the app's `$context<C>()` type.
|
|
22
|
+
*/
|
|
15
23
|
export declare function createAstroLocalClient<TApp, TAstro extends {
|
|
16
24
|
request: Request;
|
|
17
|
-
}, TCtx>(app: ImplementedRouter<TApp>, astro: TAstro, context: TCtx | ((astro: TAstro) => TCtx | Promise<TCtx
|
|
25
|
+
}, TCtx>(app: ImplementedRouter<TApp, TCtx>, astro: TAstro, context: NoInfer<TCtx> | ((astro: TAstro) => NoInfer<TCtx> | Promise<NoInfer<TCtx>>), options?: AstroLocalClientOptions): Promise<ContractClient<TApp>>;
|
|
18
26
|
export { withBase } from './with-base.js';
|
|
19
27
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,UAAU,EAEf,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACzB,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAEvC,MAAM,MAAM,mBAAmB,CAAC,IAAI,IAAI;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;CAC9D,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,YAAY,CAAC,EAAE,SAAS,eAAe,EAAE,CAAA;IACzC,OAAO,CAAC,EAAE,SAAS,UAAU,EAAE,CAAA;IAC/B,UAAU,CAAC,EAAE,mBAAmB,CAAA;CACjC,CAAA;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EACrC,OAAO,EAAE,YAAY,CAAC,IAAI,CAAC,EAC3B,OAAO,EAAE,mBAAmB,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../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AAC,IAAI,CAAC,CAAC,CAAC,EAC/D,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAG/B;AA4CD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/server.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { createLocalClient, } from '@ts-pf/server';
|
|
2
|
+
/**
|
|
3
|
+
* `TCtx` comes from the `FetchHandler` (which inferred it from the router), so
|
|
4
|
+
* `options.context` is checked against the app's `$context<C>()` type.
|
|
5
|
+
*/
|
|
2
6
|
export function createAstroHandler(handler, options) {
|
|
3
7
|
return async (astro) => {
|
|
4
8
|
const context = await resolveContext(options.context, astro);
|
|
@@ -12,6 +16,10 @@ export function createAstroHandler(handler, options) {
|
|
|
12
16
|
return result.response;
|
|
13
17
|
};
|
|
14
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* `TCtx` is inferred from the router's context brand, so `context` is checked
|
|
21
|
+
* against the app's `$context<C>()` type.
|
|
22
|
+
*/
|
|
15
23
|
export async function createAstroLocalClient(app, astro, context, options) {
|
|
16
24
|
const resolved = await resolveContext(context, astro);
|
|
17
25
|
return createLocalClient(app, localClientOptions(resolved, options));
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,iBAAiB,GAGlB,MAAM,eAAe,CAAA;AAetB,MAAM,UAAU,kBAAkB,CAChC,OAA2B,EAC3B,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,iBAAiB,GAGlB,MAAM,eAAe,CAAA;AAetB;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAA2B,EAC3B,OAA2C;IAE3C,OAAO,KAAK,EAAE,KAAK,EAAE,EAAE;QACrB,MA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D,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;IAChC,CAAC;IACD,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAA;IACtC,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-pf/astro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Opt-in Astro endpoint and in-process page caller for ts-pf",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ts-pf",
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
"astro"
|
|
14
14
|
],
|
|
15
15
|
"license": "MIT",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=22"
|
|
18
|
+
},
|
|
16
19
|
"repository": {
|
|
17
20
|
"type": "git",
|
|
18
21
|
"url": "git+https://github.com/crobinson42/ts-pf.git",
|
|
@@ -52,16 +55,18 @@
|
|
|
52
55
|
"lint": "biome check src tests"
|
|
53
56
|
},
|
|
54
57
|
"dependencies": {
|
|
55
|
-
"@ts-pf/client": "0.1
|
|
56
|
-
"@ts-pf/client-http": "0.1
|
|
57
|
-
"@ts-pf/
|
|
58
|
-
"@ts-pf/
|
|
58
|
+
"@ts-pf/client": "0.2.1",
|
|
59
|
+
"@ts-pf/client-http": "0.2.1",
|
|
60
|
+
"@ts-pf/contract": "0.2.1",
|
|
61
|
+
"@ts-pf/protocol": "0.2.0",
|
|
62
|
+
"@ts-pf/server": "0.4.1",
|
|
63
|
+
"@ts-pf/server-http": "0.3.1"
|
|
59
64
|
},
|
|
60
65
|
"peerDependencies": {
|
|
61
66
|
"astro": ">=4.9.0"
|
|
62
67
|
},
|
|
63
68
|
"devDependencies": {
|
|
64
|
-
"astro": "^
|
|
69
|
+
"astro": "^7.4.1",
|
|
65
70
|
"zod": "^4.0.0"
|
|
66
71
|
}
|
|
67
72
|
}
|
|
@@ -7,7 +7,7 @@ description: Use when serving a ts-pf API from an Astro endpoint or calling it i
|
|
|
7
7
|
|
|
8
8
|
Opt-in Astro endpoint and in-process page caller. Thin shell around `FetchHandler` and `createClient`. Not an integration, middleware mount, or Astro Actions adapter.
|
|
9
9
|
|
|
10
|
-
Install: `npm i @ts-pf/astro` (peer **astro >= 4.9.0**). The app already has `@ts-pf/server`, `@ts-pf/server-http`, `@ts-pf/client`, and `@ts-pf/client-http`.
|
|
10
|
+
Install: `npm i @ts-pf/astro` (peer **astro >= 4.9.0**). The app already has `@ts-pf/contract`, `@ts-pf/server`, `@ts-pf/server-http`, `@ts-pf/client`, and `@ts-pf/client-http`.
|
|
11
11
|
|
|
12
12
|
Link for agents: `npx skills experimental_sync -y`
|
|
13
13
|
|
|
@@ -37,7 +37,7 @@ const planet = await caller.planet.find({ id: 1 })
|
|
|
37
37
|
|
|
38
38
|
Browser or island module. Import the contract with `import type`. Do not import the implementer.
|
|
39
39
|
|
|
40
|
-
```ts
|
|
40
|
+
```ts bundler
|
|
41
41
|
import { createAstroClient, withBase } from '@ts-pf/astro/client'
|
|
42
42
|
import type { contract } from './contract'
|
|
43
43
|
|
|
@@ -48,6 +48,8 @@ export const client = createAstroClient<typeof contract>({
|
|
|
48
48
|
|
|
49
49
|
`@ts-pf/astro` (root) exports the same client helpers. `@ts-pf/swr` works on that client for React islands.
|
|
50
50
|
|
|
51
|
+
`createAstroHandler(handler, { context })` checks `context` against the context type `FetchHandler` inferred from `app`; `createAstroLocalClient(app, Astro, context)` checks it against `app`'s `$context<C>()`. `createAstroClient` needs the contract type: `createAstroClient<typeof contract>({ prefix })`, or a `ContractClient<typeof contract>` annotation on the variable or return type. Without either the result is `{ readonly '~error': 'Pass createAstroClient<typeof contract>({ prefix })' }`, not an empty client.
|
|
52
|
+
|
|
51
53
|
## API
|
|
52
54
|
|
|
53
55
|
- `createAstroHandler`
|