@tailorkit/app 0.1.0-beta.9 → 1.0.0-beta.44
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.md +74 -0
- package/README.md +123 -0
- package/dist/chunk-7ZQPXG7O.js +34 -0
- package/dist/chunk-MYK3WL3S.js +428 -0
- package/dist/chunk-QDZXHVTU.js +277 -0
- package/dist/chunk-YFKW5FBP.js +623 -0
- package/dist/client/connection.d.ts +31 -0
- package/dist/client/query-store.d.ts +23 -0
- package/dist/client/reference.d.ts +20 -0
- package/dist/client/session.d.ts +20 -0
- package/dist/client/tools.d.ts +16 -0
- package/dist/client-connection.js +16 -0
- package/dist/client.d.ts +11 -0
- package/dist/client.js +40 -0
- package/dist/database/definition.d.ts +8 -0
- package/dist/database/schema.d.ts +78 -0
- package/dist/database/types.d.ts +8 -0
- package/dist/errors.d.ts +6 -0
- package/dist/index.d.ts +2 -87
- package/dist/index.js +91 -70
- package/dist/preact.d.ts +52 -0
- package/dist/protocol.d.ts +74 -0
- package/dist/protocol.js +39 -0
- package/dist/routing.d.ts +35 -0
- package/dist/server/builder.d.ts +46 -0
- package/dist/server/bundle.d.ts +12 -0
- package/dist/server/functions.d.ts +113 -0
- package/dist/server/instances.d.ts +17 -0
- package/dist/server.d.ts +11 -0
- package/dist/server.js +60 -0
- package/dist/validation.d.ts +5 -0
- package/dist/views.d.ts +126 -0
- package/package.json +59 -22
- package/LICENSE +0 -674
- package/dist/builder/index.d.ts +0 -10
- package/dist/builder/upload-manifest.d.ts +0 -13
- package/dist/builder.js +0 -224
- package/dist/chunk-EKCUETAV.js +0 -26
- package/dist/chunk-ZFYKVXDO.js +0 -27
- package/dist/config/config.d.ts +0 -20
- package/dist/config/index.d.ts +0 -1
- package/dist/config/loader.d.ts +0 -7
- package/dist/config-loader.js +0 -7
- package/dist/config.js +0 -8
- package/dist/preact-version.d.ts +0 -7
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import type { Identity } from "#server/functions";
|
|
3
|
+
export declare const parseSession: (value: Parameters<typeof v.parse>[1]) => Session;
|
|
4
|
+
export interface Session {
|
|
5
|
+
toolUrl?: string;
|
|
6
|
+
identity?: Identity;
|
|
7
|
+
subjectId?: string;
|
|
8
|
+
token: string;
|
|
9
|
+
expiresAt: number;
|
|
10
|
+
url: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const sessionRenewalDelay: (session: Session) => number;
|
|
13
|
+
/** Host-owned provider: project credentials never cross into the sandbox. */
|
|
14
|
+
export declare const createSessionProvider: (options: {
|
|
15
|
+
baseUrl: string | URL;
|
|
16
|
+
appId: string;
|
|
17
|
+
fetch?: typeof fetch;
|
|
18
|
+
}) => (input: {
|
|
19
|
+
refresh: boolean;
|
|
20
|
+
}) => Promise<Session>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Session } from "./session";
|
|
2
|
+
export interface ToolBridge<TInput = unknown, TOutput = unknown> {
|
|
3
|
+
client: (path: string, input: TInput) => Promise<TOutput>;
|
|
4
|
+
session: (path: string) => Promise<Session>;
|
|
5
|
+
}
|
|
6
|
+
declare global {
|
|
7
|
+
var __tailorkitTools: ToolBridge | undefined;
|
|
8
|
+
var __tailorkitBackendSession: ((options: {
|
|
9
|
+
refresh: boolean;
|
|
10
|
+
}) => Promise<Session>) | undefined;
|
|
11
|
+
}
|
|
12
|
+
export interface TailorKitServerTools {
|
|
13
|
+
}
|
|
14
|
+
export declare const executeServerTool: (session: Session, path: string, input: unknown, request?: typeof fetch, signal?: AbortSignal) => Promise<unknown>;
|
|
15
|
+
/** Generated callers delegate only transport; host/server declarations validate both directions. */
|
|
16
|
+
export declare const callTool: (kind: "client" | "server", path: string, input?: Parameters<ToolBridge["client"]>[1]) => ReturnType<ToolBridge["client"]>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createClient,
|
|
3
|
+
createSessionProvider,
|
|
4
|
+
parseSession,
|
|
5
|
+
reference
|
|
6
|
+
} from "./chunk-MYK3WL3S.js";
|
|
7
|
+
import {
|
|
8
|
+
AppError
|
|
9
|
+
} from "./chunk-7ZQPXG7O.js";
|
|
10
|
+
export {
|
|
11
|
+
AppError,
|
|
12
|
+
createClient,
|
|
13
|
+
createSessionProvider,
|
|
14
|
+
parseSession,
|
|
15
|
+
reference
|
|
16
|
+
};
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./views";
|
|
2
|
+
export * from "./preact";
|
|
3
|
+
export { defineRoute, Route, createFileClient } from "./routing";
|
|
4
|
+
export type { RouteDefinition, ShellProps } from "./routing";
|
|
5
|
+
export { createClient, createSessionProvider, reference, } from "./client/connection";
|
|
6
|
+
export { createApi } from "./client/reference";
|
|
7
|
+
export type { Client, Session, Reference, References, } from "./client/connection";
|
|
8
|
+
export { AppError, appError } from "./errors";
|
|
9
|
+
export type { ErrorCode } from "./errors";
|
|
10
|
+
export { callTool } from "./client/tools";
|
|
11
|
+
export type { TailorKitServerTools, ToolBridge } from "./client/tools";
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ClientProvider,
|
|
3
|
+
Route,
|
|
4
|
+
callTool,
|
|
5
|
+
createFileClient,
|
|
6
|
+
createRemoteComponent,
|
|
7
|
+
defineRoute,
|
|
8
|
+
defineView,
|
|
9
|
+
useAction,
|
|
10
|
+
useMutation,
|
|
11
|
+
useQuery
|
|
12
|
+
} from "./chunk-YFKW5FBP.js";
|
|
13
|
+
import {
|
|
14
|
+
createApi,
|
|
15
|
+
createClient,
|
|
16
|
+
createSessionProvider,
|
|
17
|
+
reference
|
|
18
|
+
} from "./chunk-MYK3WL3S.js";
|
|
19
|
+
import {
|
|
20
|
+
AppError,
|
|
21
|
+
appError
|
|
22
|
+
} from "./chunk-7ZQPXG7O.js";
|
|
23
|
+
export {
|
|
24
|
+
AppError,
|
|
25
|
+
ClientProvider,
|
|
26
|
+
Route,
|
|
27
|
+
appError,
|
|
28
|
+
callTool,
|
|
29
|
+
createApi,
|
|
30
|
+
createClient,
|
|
31
|
+
createFileClient,
|
|
32
|
+
createRemoteComponent,
|
|
33
|
+
createSessionProvider,
|
|
34
|
+
defineRoute,
|
|
35
|
+
defineView,
|
|
36
|
+
reference,
|
|
37
|
+
useAction,
|
|
38
|
+
useMutation,
|
|
39
|
+
useQuery
|
|
40
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AnyRelations } from "drizzle-orm/relations";
|
|
2
|
+
export interface DatabaseDefinition<R extends AnyRelations = AnyRelations> {
|
|
3
|
+
readonly relations: R;
|
|
4
|
+
}
|
|
5
|
+
/** Configure the installation database with Drizzle relations, which also contain its tables. */
|
|
6
|
+
export declare const defineDatabase: <const R extends AnyRelations>(definition: DatabaseDefinition<R>) => Readonly<{
|
|
7
|
+
relations: R;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ColumnBuilderBase } from "drizzle-orm";
|
|
2
|
+
export declare const table: <N extends string, C extends Record<string, ColumnBuilderBase>>(name: N, columns: C) => import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
|
|
3
|
+
name: N;
|
|
4
|
+
schema: undefined;
|
|
5
|
+
columns: { [Key in keyof C]: import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
6
|
+
name: string;
|
|
7
|
+
tableName: N;
|
|
8
|
+
dataType: C[Key]["_"]["dataType"];
|
|
9
|
+
data: C[Key]["_"] extends infer T ? T extends C[Key]["_"] ? T extends {
|
|
10
|
+
$type: infer U;
|
|
11
|
+
} ? U : T["data"] : never : never;
|
|
12
|
+
driverParam: C[Key]["_"]["driverParam"];
|
|
13
|
+
notNull: C[Key]["_"]["notNull"] extends true ? true : false;
|
|
14
|
+
hasDefault: C[Key]["_"]["hasDefault"] extends true ? true : false;
|
|
15
|
+
isPrimaryKey: C[Key]["_"] extends infer T_1 ? T_1 extends C[Key]["_"] ? T_1 extends {
|
|
16
|
+
isPrimaryKey: true;
|
|
17
|
+
} ? true : false : never : never;
|
|
18
|
+
isAutoincrement: C[Key]["_"] extends infer T_2 ? T_2 extends C[Key]["_"] ? T_2 extends {
|
|
19
|
+
isAutoincrement: true;
|
|
20
|
+
} ? true : false : never : never;
|
|
21
|
+
hasRuntimeDefault: C[Key]["_"] extends infer T_3 ? T_3 extends C[Key]["_"] ? T_3 extends {
|
|
22
|
+
hasRuntimeDefault: true;
|
|
23
|
+
} ? true : false : never : never;
|
|
24
|
+
enumValues: C[Key]["_"] extends infer T_4 ? T_4 extends C[Key]["_"] ? T_4 extends {
|
|
25
|
+
enumValues: [string, ...string[]];
|
|
26
|
+
} ? T_4["enumValues"] : undefined : never : never;
|
|
27
|
+
baseColumn: C[Key]["_"] extends infer T_5 ? T_5 extends C[Key]["_"] ? T_5 extends {
|
|
28
|
+
baseBuilder: infer U_1 extends ColumnBuilderBase;
|
|
29
|
+
} ? import("drizzle-orm/sqlite-core").SQLiteColumn<{
|
|
30
|
+
name: string;
|
|
31
|
+
tableName: N;
|
|
32
|
+
dataType: U_1["_"]["dataType"];
|
|
33
|
+
data: U_1["_"] extends infer T_6 ? T_6 extends U_1["_"] ? T_6 extends {
|
|
34
|
+
$type: infer U;
|
|
35
|
+
} ? U : T_6["data"] : never : never;
|
|
36
|
+
driverParam: U_1["_"]["driverParam"];
|
|
37
|
+
notNull: U_1["_"]["notNull"] extends true ? true : false;
|
|
38
|
+
hasDefault: U_1["_"]["hasDefault"] extends true ? true : false;
|
|
39
|
+
isPrimaryKey: U_1["_"] extends infer T_7 ? T_7 extends U_1["_"] ? T_7 extends {
|
|
40
|
+
isPrimaryKey: true;
|
|
41
|
+
} ? true : false : never : never;
|
|
42
|
+
isAutoincrement: U_1["_"] extends infer T_8 ? T_8 extends U_1["_"] ? T_8 extends {
|
|
43
|
+
isAutoincrement: true;
|
|
44
|
+
} ? true : false : never : never;
|
|
45
|
+
hasRuntimeDefault: U_1["_"] extends infer T_9 ? T_9 extends U_1["_"] ? T_9 extends {
|
|
46
|
+
hasRuntimeDefault: true;
|
|
47
|
+
} ? true : false : never : never;
|
|
48
|
+
enumValues: U_1["_"] extends infer T_10 ? T_10 extends U_1["_"] ? T_10 extends {
|
|
49
|
+
enumValues: [string, ...string[]];
|
|
50
|
+
} ? T_10["enumValues"] : undefined : never : never;
|
|
51
|
+
baseColumn: U_1["_"] extends infer T_11 ? T_11 extends U_1["_"] ? T_11 extends {
|
|
52
|
+
baseBuilder: infer U_1 extends ColumnBuilderBase;
|
|
53
|
+
} ? import("drizzle-orm/sqlite-core").SQLiteColumn</*elided*/ any, {}> : never : never : never;
|
|
54
|
+
identity: U_1["_"] extends infer T_12 ? T_12 extends U_1["_"] ? T_12 extends {
|
|
55
|
+
identity: 'always';
|
|
56
|
+
} ? "always" : T_12 extends {
|
|
57
|
+
identity: 'byDefault';
|
|
58
|
+
} ? "byDefault" : undefined : never : never;
|
|
59
|
+
generated: U_1["_"] extends infer T_13 ? T_13 extends U_1["_"] ? T_13 extends {
|
|
60
|
+
generated: infer G;
|
|
61
|
+
} ? unknown extends G ? undefined : G extends undefined ? undefined : G : undefined : never : never;
|
|
62
|
+
}, {}> : never : never : never;
|
|
63
|
+
identity: C[Key]["_"] extends infer T_14 ? T_14 extends C[Key]["_"] ? T_14 extends {
|
|
64
|
+
identity: 'always';
|
|
65
|
+
} ? "always" : T_14 extends {
|
|
66
|
+
identity: 'byDefault';
|
|
67
|
+
} ? "byDefault" : undefined : never : never;
|
|
68
|
+
generated: C[Key]["_"] extends infer T_15 ? T_15 extends C[Key]["_"] ? T_15 extends {
|
|
69
|
+
generated: infer G;
|
|
70
|
+
} ? unknown extends G ? undefined : G extends undefined ? undefined : G : undefined : never : never;
|
|
71
|
+
}, {}>; };
|
|
72
|
+
dialect: 'sqlite';
|
|
73
|
+
}>;
|
|
74
|
+
export declare const text: (name?: string) => import("drizzle-orm/sqlite-core").SQLiteTextBuilder<[string, ...string[]]>;
|
|
75
|
+
export declare const integer: (name?: string) => import("drizzle-orm/sqlite-core").SQLiteIntegerBuilder;
|
|
76
|
+
export declare const real: (name?: string) => import("drizzle-orm/sqlite-core").SQLiteRealBuilder;
|
|
77
|
+
export declare const boolean: (name?: string) => import("drizzle-orm/sqlite-core").SQLiteBooleanBuilder;
|
|
78
|
+
export { eq, ne, gt, gte, lt, lte, and, or, asc, desc, count, isNull, isNotNull, inArray, } from "drizzle-orm";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AnyRelations, EmptyRelations } from "drizzle-orm/relations";
|
|
2
|
+
import type { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core";
|
|
3
|
+
type Database<R extends AnyRelations> = BaseSQLiteDatabase<"sync", {
|
|
4
|
+
changes: number;
|
|
5
|
+
}, Record<string, never>, R>;
|
|
6
|
+
export type QueryDatabase<R extends AnyRelations = EmptyRelations> = Pick<Database<R>, "select" | "selectDistinct" | "query">;
|
|
7
|
+
export type MutationDatabase<R extends AnyRelations = EmptyRelations> = QueryDatabase<R> & Pick<Database<R>, "insert" | "update" | "delete">;
|
|
8
|
+
export {};
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type ErrorCode = "BAD_REQUEST" | "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "CONFLICT" | "INCOMPATIBLE_VERSION" | "UNAVAILABLE" | "INTERNAL_SERVER_ERROR";
|
|
2
|
+
export declare class AppError extends Error {
|
|
3
|
+
readonly code: ErrorCode;
|
|
4
|
+
constructor(code: ErrorCode, message?: string);
|
|
5
|
+
}
|
|
6
|
+
export declare const appError: (cause: unknown) => AppError;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,87 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export interface TailorKitViews {
|
|
4
|
-
}
|
|
5
|
-
export interface TailorKitSlots {
|
|
6
|
-
}
|
|
7
|
-
export type SlotName = keyof TailorKitSlots & string;
|
|
8
|
-
export type ViewPath = Extract<keyof TailorKitViews & string, `/${string}`>;
|
|
9
|
-
export type AppViewPath = ViewPath;
|
|
10
|
-
export type ViewProps<TPath extends ViewPath> = TailorKitViews[TPath] extends object ? TailorKitViews[TPath] : Record<string, never>;
|
|
11
|
-
export type ViewPropsForPath<TPath extends AppViewPath> = TPath extends ViewPath ? ViewProps<TPath> : never;
|
|
12
|
-
export type ViewContext<TPath extends AppViewPath> = ViewPropsForPath<TPath> extends {
|
|
13
|
-
context: infer TContext;
|
|
14
|
-
} ? TContext : Record<string, never>;
|
|
15
|
-
export type View<TProps extends object = Record<string, never>> = (props: TProps) => ComponentChild;
|
|
16
|
-
export type ViewRuntimeProps<TPath extends AppViewPath> = {
|
|
17
|
-
context: ViewContext<TPath>;
|
|
18
|
-
view: TPath;
|
|
19
|
-
status: "ready";
|
|
20
|
-
} | {
|
|
21
|
-
context?: never;
|
|
22
|
-
view: TPath;
|
|
23
|
-
status: "loading";
|
|
24
|
-
} | {
|
|
25
|
-
context?: never;
|
|
26
|
-
view: TPath;
|
|
27
|
-
status: "error";
|
|
28
|
-
};
|
|
29
|
-
export interface ViewDefinition<TPath extends AppViewPath = AppViewPath> {
|
|
30
|
-
component: View<ViewRuntimeProps<TPath>>;
|
|
31
|
-
path: TPath;
|
|
32
|
-
useContext: () => ViewContext<TPath>;
|
|
33
|
-
}
|
|
34
|
-
type RegisteredViews = {
|
|
35
|
-
[TPath in AppViewPath]: ViewDefinition<TPath>;
|
|
36
|
-
};
|
|
37
|
-
type ViewDefinitions = Partial<{
|
|
38
|
-
[P in AppViewPath]: RegisteredViews[P] | false;
|
|
39
|
-
}>;
|
|
40
|
-
type InvalidViewPath<TViews> = Exclude<keyof TViews & string, AppViewPath>;
|
|
41
|
-
type RequireViewPaths<TViews> = InvalidViewPath<TViews> extends never ? unknown : {
|
|
42
|
-
readonly __tailorkit_error__: `View paths must be declared by the host. Invalid view: ${InvalidViewPath<TViews>}`;
|
|
43
|
-
};
|
|
44
|
-
type ViewKeyPathMismatch<TViews> = {
|
|
45
|
-
[TPath in keyof TViews & string]: TViews[TPath] extends false ? never : TViews[TPath] extends ViewDefinition<infer TViewPath> ? TViewPath extends TPath ? never : TPath : TPath;
|
|
46
|
-
}[keyof TViews & string];
|
|
47
|
-
type RequireMatchingViewKeys<TViews> = ViewKeyPathMismatch<TViews> extends never ? unknown : {
|
|
48
|
-
readonly __tailorkit_error__: `View key must match createView path. Invalid view: ${ViewKeyPathMismatch<TViews>}`;
|
|
49
|
-
};
|
|
50
|
-
export type SlotView<TSlot extends SlotName> = Extract<TailorKitSlots[TSlot], AppViewPath>;
|
|
51
|
-
type SlotDefinitions = {
|
|
52
|
-
[V in SlotName]?: Pick<ViewDefinitions, SlotView<V>>;
|
|
53
|
-
};
|
|
54
|
-
type RequireSlotViews<V, S> = V extends SlotName ? Exclude<keyof S, SlotView<V>> extends never ? unknown : {
|
|
55
|
-
readonly __tailorkit_error__: "View is not supported by this slot";
|
|
56
|
-
} : never;
|
|
57
|
-
export interface TailorKitClient<TSlots extends SlotDefinitions = SlotDefinitions> {
|
|
58
|
-
slots: TSlots;
|
|
59
|
-
}
|
|
60
|
-
export interface TailorKitClientMeta {
|
|
61
|
-
preactVersion: string;
|
|
62
|
-
}
|
|
63
|
-
export interface TailorKitClientRuntime {
|
|
64
|
-
h: typeof h;
|
|
65
|
-
render: (vnode: VNode | null, parent: Element | Document | ShadowRoot | DocumentFragment) => void;
|
|
66
|
-
}
|
|
67
|
-
export type TailorKitClientWithMeta<TViews extends SlotDefinitions = SlotDefinitions> = TailorKitClient<TViews> & {
|
|
68
|
-
$meta: TailorKitClientMeta;
|
|
69
|
-
$runtime: TailorKitClientRuntime;
|
|
70
|
-
};
|
|
71
|
-
export declare const createView: <const TPath extends AppViewPath>(path: TPath, options: {
|
|
72
|
-
component: View<Record<string, never>>;
|
|
73
|
-
error?: View<Record<string, never>>;
|
|
74
|
-
loading?: View<Record<string, never>>;
|
|
75
|
-
}) => ViewDefinition<TPath>;
|
|
76
|
-
export declare const defineClient: <const TSlots extends SlotDefinitions>(client: TailorKitClient<TSlots> & {
|
|
77
|
-
slots: { [V in keyof TSlots]: TSlots[V] & RequireViewPaths<TSlots[V]> & RequireMatchingViewKeys<TSlots[V]> & RequireSlotViews<V, TSlots[V]>; };
|
|
78
|
-
} & (Exclude<keyof TSlots, SlotName> extends never ? unknown : {
|
|
79
|
-
__tailorkit_error__: "Unknown slot";
|
|
80
|
-
})) => TailorKitClientWithMeta<TSlots>;
|
|
81
|
-
export declare const createRemoteComponent: <TProps extends object, TChildren extends boolean = false>(name: string, options?: {
|
|
82
|
-
callbacks?: Record<string, number>;
|
|
83
|
-
children?: TChildren;
|
|
84
|
-
}) => View<TProps & {
|
|
85
|
-
children?: TChildren extends true ? ComponentChildren : never;
|
|
86
|
-
}>;
|
|
87
|
-
export {};
|
|
1
|
+
export * from "./client";
|
|
2
|
+
export * from "./server";
|
package/dist/index.js
CHANGED
|
@@ -1,73 +1,94 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
const eventName = toCallbackEventName(key);
|
|
54
|
-
callbackMap[eventName] = { callback: key, inputCount };
|
|
55
|
-
nextProps[toEventProp(eventName)] = (event) => {
|
|
56
|
-
callback(...(event.detail ?? []).slice(0, inputCount));
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
const serializedProps = Object.fromEntries(
|
|
60
|
-
Object.entries(nextProps).filter(([, value]) => typeof value !== "function")
|
|
61
|
-
);
|
|
62
|
-
nextProps["data-tailorkit-props"] = JSON.stringify(serializedProps);
|
|
63
|
-
if (Object.keys(callbackMap).length > 0) {
|
|
64
|
-
nextProps["data-tailorkit-callbacks"] = JSON.stringify(callbackMap);
|
|
65
|
-
}
|
|
66
|
-
return h(tagName, nextProps, options.children ? children : void 0);
|
|
67
|
-
};
|
|
68
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
ClientProvider,
|
|
3
|
+
Route,
|
|
4
|
+
callTool,
|
|
5
|
+
createFileClient,
|
|
6
|
+
createRemoteComponent,
|
|
7
|
+
defineRoute,
|
|
8
|
+
defineView,
|
|
9
|
+
useAction,
|
|
10
|
+
useMutation,
|
|
11
|
+
useQuery
|
|
12
|
+
} from "./chunk-YFKW5FBP.js";
|
|
13
|
+
import {
|
|
14
|
+
createApi,
|
|
15
|
+
createClient,
|
|
16
|
+
createSessionProvider,
|
|
17
|
+
reference
|
|
18
|
+
} from "./chunk-MYK3WL3S.js";
|
|
19
|
+
import {
|
|
20
|
+
action,
|
|
21
|
+
and,
|
|
22
|
+
asc,
|
|
23
|
+
boolean,
|
|
24
|
+
count,
|
|
25
|
+
defineDatabase,
|
|
26
|
+
defineServer,
|
|
27
|
+
desc,
|
|
28
|
+
eq,
|
|
29
|
+
fn,
|
|
30
|
+
gt,
|
|
31
|
+
gte,
|
|
32
|
+
inArray,
|
|
33
|
+
integer,
|
|
34
|
+
isNotNull,
|
|
35
|
+
isNull,
|
|
36
|
+
lt,
|
|
37
|
+
lte,
|
|
38
|
+
mutation,
|
|
39
|
+
ne,
|
|
40
|
+
or,
|
|
41
|
+
query,
|
|
42
|
+
real,
|
|
43
|
+
table,
|
|
44
|
+
text,
|
|
45
|
+
withInstanceResolvers
|
|
46
|
+
} from "./chunk-QDZXHVTU.js";
|
|
47
|
+
import {
|
|
48
|
+
AppError,
|
|
49
|
+
appError
|
|
50
|
+
} from "./chunk-7ZQPXG7O.js";
|
|
69
51
|
export {
|
|
52
|
+
AppError,
|
|
53
|
+
ClientProvider,
|
|
54
|
+
Route,
|
|
55
|
+
action,
|
|
56
|
+
and,
|
|
57
|
+
appError,
|
|
58
|
+
asc,
|
|
59
|
+
boolean,
|
|
60
|
+
callTool,
|
|
61
|
+
count,
|
|
62
|
+
createApi,
|
|
63
|
+
createClient,
|
|
64
|
+
createFileClient,
|
|
70
65
|
createRemoteComponent,
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
createSessionProvider,
|
|
67
|
+
defineDatabase,
|
|
68
|
+
defineRoute,
|
|
69
|
+
defineServer,
|
|
70
|
+
defineView,
|
|
71
|
+
desc,
|
|
72
|
+
eq,
|
|
73
|
+
fn,
|
|
74
|
+
gt,
|
|
75
|
+
gte,
|
|
76
|
+
inArray,
|
|
77
|
+
integer,
|
|
78
|
+
isNotNull,
|
|
79
|
+
isNull,
|
|
80
|
+
lt,
|
|
81
|
+
lte,
|
|
82
|
+
mutation,
|
|
83
|
+
ne,
|
|
84
|
+
or,
|
|
85
|
+
query,
|
|
86
|
+
real,
|
|
87
|
+
reference,
|
|
88
|
+
table,
|
|
89
|
+
text,
|
|
90
|
+
useAction,
|
|
91
|
+
useMutation,
|
|
92
|
+
useQuery,
|
|
93
|
+
withInstanceResolvers
|
|
73
94
|
};
|
package/dist/preact.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ComponentChildren } from "preact";
|
|
2
|
+
import type { Client } from "./client/connection";
|
|
3
|
+
import { QueryStore } from "./client/query-store";
|
|
4
|
+
import type { QueryState } from "./client/query-store";
|
|
5
|
+
import type { Reference } from "./client/reference";
|
|
6
|
+
import type { AppError } from "./errors";
|
|
7
|
+
export interface ClientProviderProps {
|
|
8
|
+
children?: ComponentChildren;
|
|
9
|
+
/** Supply a client for custom transport configuration. Caller-owned clients are not closed. */
|
|
10
|
+
client?: Client;
|
|
11
|
+
onError?: (error: AppError) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const ClientProvider: ({ children, client, onError, }: ClientProviderProps) => import("preact").VNode<import("preact").Attributes & {
|
|
14
|
+
value: QueryStore | null;
|
|
15
|
+
children?: ComponentChildren;
|
|
16
|
+
}>;
|
|
17
|
+
export interface QueryOptions {
|
|
18
|
+
enabled?: boolean;
|
|
19
|
+
}
|
|
20
|
+
type InputArguments<I> = undefined extends I ? [input?: I] : [input: I];
|
|
21
|
+
type QueryArguments<I> = undefined extends I ? [input?: I, options?: QueryOptions] : [input: I, options?: QueryOptions];
|
|
22
|
+
export interface QueryResult<T> extends QueryState<T> {
|
|
23
|
+
isPending: boolean;
|
|
24
|
+
isLoading: boolean;
|
|
25
|
+
isSuccess: boolean;
|
|
26
|
+
isError: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare const useQuery: <I, O>(ref: Reference<"query", I, O>, ...[input, options]: QueryArguments<NoInfer<I>>) => QueryResult<O>;
|
|
29
|
+
export interface CallOptions<I, O> {
|
|
30
|
+
onSuccess?: (data: O, input: I) => void;
|
|
31
|
+
onError?: (error: AppError, input: I) => void;
|
|
32
|
+
}
|
|
33
|
+
export interface CallState<T> {
|
|
34
|
+
data: T | undefined;
|
|
35
|
+
error: AppError | null;
|
|
36
|
+
status: "idle" | "pending" | "success" | "error";
|
|
37
|
+
isPending: boolean;
|
|
38
|
+
isSuccess: boolean;
|
|
39
|
+
isError: boolean;
|
|
40
|
+
reset: () => void;
|
|
41
|
+
}
|
|
42
|
+
export interface MutationResult<I, O> extends CallState<O> {
|
|
43
|
+
mutate: (...args: InputArguments<I>) => void;
|
|
44
|
+
mutateAsync: (...args: InputArguments<I>) => Promise<O>;
|
|
45
|
+
}
|
|
46
|
+
export declare const useMutation: <I, O>(ref: Reference<"mutation", I, O>, options?: CallOptions<I, O>) => MutationResult<I, O>;
|
|
47
|
+
export interface ActionResult<I, O> extends CallState<O> {
|
|
48
|
+
execute: (...args: InputArguments<I>) => void;
|
|
49
|
+
executeAsync: (...args: InputArguments<I>) => Promise<O>;
|
|
50
|
+
}
|
|
51
|
+
export declare const useAction: <I, O>(ref: Reference<"action", I, O>, options?: CallOptions<I, O>) => ActionResult<I, O>;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { ContractRouterClient } from "@orpc/contract";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
export declare const invocationSchema: v.StrictObjectSchema<{
|
|
4
|
+
readonly args: v.OptionalSchema<v.UnknownSchema, undefined>;
|
|
5
|
+
readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 512, undefined>, v.RegexAction<string, undefined>]>;
|
|
6
|
+
}, undefined>;
|
|
7
|
+
export type Invocation = v.InferOutput<typeof invocationSchema>;
|
|
8
|
+
export type MutationInvocation = Invocation & {
|
|
9
|
+
requestId: string;
|
|
10
|
+
};
|
|
11
|
+
/** Public wire contract; implementations and clients both depend on this definition. */
|
|
12
|
+
export declare const appContract: {
|
|
13
|
+
actions: import("@orpc/contract").ProcedureContractBuilderWithInputOutput<v.StrictObjectSchema<{
|
|
14
|
+
readonly args: v.OptionalSchema<v.UnknownSchema, undefined>;
|
|
15
|
+
readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 512, undefined>, v.RegexAction<string, undefined>]>;
|
|
16
|
+
}, undefined>, import("@orpc/contract").Schema<unknown, unknown>, {
|
|
17
|
+
BAD_REQUEST: {};
|
|
18
|
+
CONFLICT: {};
|
|
19
|
+
FORBIDDEN: {};
|
|
20
|
+
INCOMPATIBLE_VERSION: {};
|
|
21
|
+
INTERNAL_SERVER_ERROR: {};
|
|
22
|
+
NOT_FOUND: {};
|
|
23
|
+
UNAUTHORIZED: {};
|
|
24
|
+
UNAVAILABLE: {};
|
|
25
|
+
}>;
|
|
26
|
+
mutations: import("@orpc/contract").ProcedureContractBuilderWithInputOutput<v.StrictObjectSchema<{
|
|
27
|
+
readonly args: v.OptionalSchema<v.UnknownSchema, undefined>;
|
|
28
|
+
readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 512, undefined>, v.RegexAction<string, undefined>]>;
|
|
29
|
+
readonly requestId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UuidAction<string, undefined>]>;
|
|
30
|
+
}, undefined>, import("@orpc/contract").Schema<unknown, unknown>, {
|
|
31
|
+
BAD_REQUEST: {};
|
|
32
|
+
CONFLICT: {};
|
|
33
|
+
FORBIDDEN: {};
|
|
34
|
+
INCOMPATIBLE_VERSION: {};
|
|
35
|
+
INTERNAL_SERVER_ERROR: {};
|
|
36
|
+
NOT_FOUND: {};
|
|
37
|
+
UNAUTHORIZED: {};
|
|
38
|
+
UNAVAILABLE: {};
|
|
39
|
+
}>;
|
|
40
|
+
queries: import("@orpc/contract").ProcedureContractBuilderWithInputOutput<v.StrictObjectSchema<{
|
|
41
|
+
readonly args: v.OptionalSchema<v.UnknownSchema, undefined>;
|
|
42
|
+
readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 512, undefined>, v.RegexAction<string, undefined>]>;
|
|
43
|
+
}, undefined>, import("@orpc/contract").Schema<unknown, unknown>, {
|
|
44
|
+
BAD_REQUEST: {};
|
|
45
|
+
CONFLICT: {};
|
|
46
|
+
FORBIDDEN: {};
|
|
47
|
+
INCOMPATIBLE_VERSION: {};
|
|
48
|
+
INTERNAL_SERVER_ERROR: {};
|
|
49
|
+
NOT_FOUND: {};
|
|
50
|
+
UNAUTHORIZED: {};
|
|
51
|
+
UNAVAILABLE: {};
|
|
52
|
+
}>;
|
|
53
|
+
subscribe: import("@orpc/contract").ProcedureContractBuilderWithInputOutput<v.StrictObjectSchema<{
|
|
54
|
+
readonly args: v.OptionalSchema<v.UnknownSchema, undefined>;
|
|
55
|
+
readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 512, undefined>, v.RegexAction<string, undefined>]>;
|
|
56
|
+
}, undefined>, import("@orpc/contract").Schema<AsyncIterableIterator<unknown>, AsyncIterableIterator<unknown>>, {
|
|
57
|
+
BAD_REQUEST: {};
|
|
58
|
+
CONFLICT: {};
|
|
59
|
+
FORBIDDEN: {};
|
|
60
|
+
INCOMPATIBLE_VERSION: {};
|
|
61
|
+
INTERNAL_SERVER_ERROR: {};
|
|
62
|
+
NOT_FOUND: {};
|
|
63
|
+
UNAUTHORIZED: {};
|
|
64
|
+
UNAVAILABLE: {};
|
|
65
|
+
}>;
|
|
66
|
+
};
|
|
67
|
+
export type PlatformClient = ContractRouterClient<typeof appContract>;
|
|
68
|
+
export type SubscriptionClient = Pick<PlatformClient, "subscribe">;
|
|
69
|
+
/** Drizzle-generated SQL exported by application bundles. */
|
|
70
|
+
export interface AppMigration {
|
|
71
|
+
id: string;
|
|
72
|
+
hash: string;
|
|
73
|
+
statements: string[];
|
|
74
|
+
}
|
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/protocol.ts
|
|
2
|
+
import { oc, type } from "@orpc/contract";
|
|
3
|
+
import * as v from "valibot";
|
|
4
|
+
var invocationSchema = v.strictObject({
|
|
5
|
+
args: v.optional(v.unknown()),
|
|
6
|
+
name: v.pipe(
|
|
7
|
+
v.string(),
|
|
8
|
+
v.maxLength(512),
|
|
9
|
+
v.regex(
|
|
10
|
+
/^(?:[a-zA-Z][a-zA-Z0-9_]{0,63}|_tailorkit)(?:\.[a-zA-Z][a-zA-Z0-9_]{0,63})*$/u
|
|
11
|
+
)
|
|
12
|
+
)
|
|
13
|
+
});
|
|
14
|
+
var procedure = oc.errors({
|
|
15
|
+
BAD_REQUEST: {},
|
|
16
|
+
CONFLICT: {},
|
|
17
|
+
FORBIDDEN: {},
|
|
18
|
+
INCOMPATIBLE_VERSION: {},
|
|
19
|
+
INTERNAL_SERVER_ERROR: {},
|
|
20
|
+
NOT_FOUND: {},
|
|
21
|
+
UNAUTHORIZED: {},
|
|
22
|
+
UNAVAILABLE: {}
|
|
23
|
+
});
|
|
24
|
+
var appContract = {
|
|
25
|
+
actions: procedure.input(invocationSchema).output(type()),
|
|
26
|
+
mutations: procedure.input(
|
|
27
|
+
v.strictObject({
|
|
28
|
+
...invocationSchema.entries,
|
|
29
|
+
requestId: v.pipe(v.string(), v.uuid())
|
|
30
|
+
})
|
|
31
|
+
).output(type()),
|
|
32
|
+
queries: procedure.input(invocationSchema).output(type()),
|
|
33
|
+
// A pass-through type schema preserves the private hibernation iterator instance.
|
|
34
|
+
subscribe: procedure.input(invocationSchema).output(type())
|
|
35
|
+
};
|
|
36
|
+
export {
|
|
37
|
+
appContract,
|
|
38
|
+
invocationSchema
|
|
39
|
+
};
|