mirror of
https://github.com/morten-olsen/plainidx.git
synced 2026-02-08 01:06:24 +01:00
prepare for client/server split
This commit is contained in:
2
packages/client/.gitignore
vendored
Normal file
2
packages/client/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/node_modules/
|
||||
/dist/
|
||||
20
packages/client/package.json
Normal file
20
packages/client/package.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "@plainidx/client",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"main": "dist/exports.js",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc --build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@plainidx/configs": "workspace:*",
|
||||
"typescript": "^5.7.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@plainidx/base": "workspace:*",
|
||||
"nanoid": "^5.0.9"
|
||||
}
|
||||
}
|
||||
20
packages/client/src/client/client.ts
Normal file
20
packages/client/src/client/client.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Manifest } from '@plainidx/base';
|
||||
import { Plugin } from '../plugin/plugin.js';
|
||||
|
||||
type ClientOptions = {
|
||||
transport: unknown;
|
||||
};
|
||||
|
||||
class Client {
|
||||
#options: ClientOptions;
|
||||
|
||||
constructor(options: ClientOptions) {
|
||||
this.#options = options;
|
||||
}
|
||||
|
||||
public getPlugin = <TManifest extends Manifest>(manifest: TManifest) => {
|
||||
return undefined as unknown as Plugin<TManifest>;
|
||||
};
|
||||
}
|
||||
|
||||
export { Client };
|
||||
0
packages/client/src/exports.ts
Normal file
0
packages/client/src/exports.ts
Normal file
14
packages/client/src/plugin/plugin.ts
Normal file
14
packages/client/src/plugin/plugin.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Manifest, ManifestBackend, z } from '@plainidx/base';
|
||||
|
||||
type Plugin<TManifest extends Manifest> = {
|
||||
manifest: TManifest;
|
||||
actions: TManifest['backend'] extends ManifestBackend
|
||||
? {
|
||||
[TKey in keyof TManifest['backend']['actions']]: (
|
||||
input: z.infer<TManifest['backend']['actions'][TKey]['input']>,
|
||||
) => Promise<z.infer<TManifest['backend']['actions'][TKey]['output']>>;
|
||||
}
|
||||
: Record<string, never>;
|
||||
};
|
||||
|
||||
export { Plugin };
|
||||
9
packages/client/tsconfig.json
Normal file
9
packages/client/tsconfig.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "@plainidx/configs/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user