prepare for client/server split

This commit is contained in:
Morten Olsen
2024-12-11 12:32:23 +01:00
parent 02614d216c
commit 99248e98b5
51 changed files with 409 additions and 1500 deletions

2
packages/client/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
/node_modules/
/dist/

View 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"
}
}

View 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 };

View File

View 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 };

View File

@@ -0,0 +1,9 @@
{
"extends": "@plainidx/configs/tsconfig.json",
"compilerOptions": {
"outDir": "dist"
},
"include": [
"src"
]
}