@cfast/core 0.1.4 → 0.2.0
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/dist/index.d.ts +16 -6
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -88,25 +88,35 @@ declare function createApp<TSchema extends Schema, TPermissions extends Permissi
|
|
|
88
88
|
* return { client: createDb({}) };
|
|
89
89
|
* },
|
|
90
90
|
* });
|
|
91
|
+
*
|
|
92
|
+
* // Env-typed plugin — pass the env type as the single explicit generic
|
|
93
|
+
* // to type ctx.env precisely (no casts needed):
|
|
94
|
+
* const storagePlugin = definePlugin<Cloudflare.Env>({
|
|
95
|
+
* name: 'storage',
|
|
96
|
+
* setup(ctx) {
|
|
97
|
+
* ctx.env.BUCKET; // typed as R2Bucket, not unknown
|
|
98
|
+
* return { upload: (file: File) => ctx.env.BUCKET.put(file.name, file) };
|
|
99
|
+
* },
|
|
100
|
+
* });
|
|
91
101
|
* ```
|
|
92
102
|
*/
|
|
93
|
-
declare function definePlugin<TName extends string, TProvides, const TRequires extends readonly CfastPlugin<string, unknown, any, unknown, any>[] = [], TClient = unknown>(config: {
|
|
103
|
+
declare function definePlugin<TEnv = Record<string, unknown>, TName extends string = string, TProvides = unknown, const TRequires extends readonly CfastPlugin<string, unknown, any, unknown, any>[] = [], TClient = unknown>(config: {
|
|
94
104
|
name: TName;
|
|
95
105
|
requires?: TRequires;
|
|
96
|
-
setup: (ctx: PluginSetupContext<RequiresFromPlugins<TRequires
|
|
106
|
+
setup: (ctx: PluginSetupContext<RequiresFromPlugins<TRequires>, TEnv>) => TProvides | Promise<TProvides>;
|
|
97
107
|
Provider?: ComponentType<{
|
|
98
108
|
children: ReactNode;
|
|
99
109
|
}>;
|
|
100
110
|
client?: TClient;
|
|
101
|
-
}): CfastPlugin<TName, Awaited<TProvides>, RequiresFromPlugins<TRequires>, TClient>;
|
|
102
|
-
declare function definePlugin<TRequires
|
|
111
|
+
}): CfastPlugin<TName, Awaited<TProvides>, RequiresFromPlugins<TRequires>, TClient, TEnv>;
|
|
112
|
+
declare function definePlugin<TRequires, TEnv = Record<string, unknown>>(): <TName extends string, TProvides, TClient = unknown>(config: {
|
|
103
113
|
name: TName;
|
|
104
|
-
setup: (ctx: PluginSetupContext<TRequires>) => TProvides | Promise<TProvides>;
|
|
114
|
+
setup: (ctx: PluginSetupContext<TRequires, TEnv>) => TProvides | Promise<TProvides>;
|
|
105
115
|
Provider?: ComponentType<{
|
|
106
116
|
children: ReactNode;
|
|
107
117
|
}>;
|
|
108
118
|
client?: TClient;
|
|
109
|
-
}) => CfastPlugin<TName, Awaited<TProvides>, TRequires, TClient>;
|
|
119
|
+
}) => CfastPlugin<TName, Awaited<TProvides>, TRequires, TClient, TEnv>;
|
|
110
120
|
/**
|
|
111
121
|
* Returns an env-typed `definePlugin` factory.
|
|
112
122
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cfast/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "App composition layer with plugin system for @cfast/* packages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cfast",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"tsup": "^8",
|
|
61
61
|
"typescript": "^5.7",
|
|
62
62
|
"vitest": "^4.1.0",
|
|
63
|
-
"@cfast/
|
|
64
|
-
"@cfast/
|
|
63
|
+
"@cfast/env": "0.2.1",
|
|
64
|
+
"@cfast/permissions": "0.5.1"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
67
67
|
"build": "tsup src/index.ts src/client/index.ts --format esm --dts",
|