@tailorkit/app 0.1.0-beta.2 → 0.1.0-beta.21
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 +201 -0
- package/README.md +3 -0
- package/dist/builder/client-views.d.ts +16 -0
- package/dist/builder/drizzle.d.ts +2 -0
- package/dist/builder/generate-migrations.d.ts +6 -0
- package/dist/builder/index.d.ts +1 -2
- package/dist/builder/instances.d.ts +19 -0
- package/dist/builder/migrations.d.ts +6 -0
- package/dist/builder/schema-check.d.ts +2 -0
- package/dist/builder/server.d.ts +6 -0
- package/dist/builder/upload-manifest.d.ts +13 -3
- package/dist/builder.js +986 -21
- package/dist/chunk-7NOEYJOB.js +197 -0
- package/dist/{chunk-7L6ZZHCK.js → chunk-DEU6RITM.js} +6 -1
- package/dist/chunk-GVB2PAK7.js +28 -0
- package/dist/chunk-IJBQ77AH.js +35 -0
- package/dist/chunk-RHCGWGSG.js +645 -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 +14 -0
- package/dist/client.d.ts +7 -0
- package/dist/client.js +32 -0
- package/dist/config/config.d.ts +88 -4
- package/dist/config/index.d.ts +0 -1
- package/dist/config/loader.d.ts +0 -1
- package/dist/config-loader.js +2 -2
- package/dist/config.js +1 -1
- package/dist/database/schema.d.ts +78 -0
- package/dist/database/types.d.ts +7 -0
- package/dist/errors.d.ts +6 -0
- package/dist/index.d.ts +2 -72
- package/dist/index.js +81 -76
- package/dist/preact-version.d.ts +0 -1
- package/dist/preact.d.ts +52 -0
- package/dist/protocol.d.ts +74 -0
- package/dist/protocol.js +28 -0
- package/dist/server/builder.d.ts +40 -0
- package/dist/server/bundle.d.ts +17 -0
- package/dist/server/functions.d.ts +89 -0
- package/dist/server/instances.d.ts +16 -0
- package/dist/server.d.ts +9 -0
- package/dist/server.js +58 -0
- package/dist/views.d.ts +139 -0
- package/package.json +30 -23
- package/LICENSE +0 -674
- package/dist/builder/index.d.ts.map +0 -1
- package/dist/builder/upload-manifest.d.ts.map +0 -1
- package/dist/chunk-AGGRUUWG.js +0 -22
- package/dist/config/config.d.ts.map +0 -1
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/loader.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/preact-version.d.ts.map +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
import type { FunctionResult, Functions } from "../server/functions";
|
|
3
|
+
export interface Reference<K extends "query" | "mutation" | "action", I, O> {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly $types?: {
|
|
6
|
+
kind: K;
|
|
7
|
+
input: I;
|
|
8
|
+
output: O;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare function reference<K extends "query" | "mutation" | "action", I, O>(name: string, _kind: K): Reference<K, I, O>;
|
|
12
|
+
export type References<F> = {
|
|
13
|
+
readonly [N in keyof F]: F[N] extends {
|
|
14
|
+
kind: infer K extends "query" | "mutation" | "action";
|
|
15
|
+
args: infer A extends z.ZodType;
|
|
16
|
+
handler: (...args: never[]) => unknown;
|
|
17
|
+
} ? Reference<K, z.input<A>, FunctionResult<F[N]>> : F[N] extends Functions ? References<F[N]> : never;
|
|
18
|
+
};
|
|
19
|
+
/** Browser references inferred directly from the server's exported function type. */
|
|
20
|
+
export declare function createApi<F extends Functions>(): References<F>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface Session {
|
|
2
|
+
token: string;
|
|
3
|
+
expiresAt: number;
|
|
4
|
+
url: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function sessionRenewalDelay(session: Session): number;
|
|
7
|
+
/** Host-owned provider: project credentials never cross into the sandbox. */
|
|
8
|
+
export declare function createSessionProvider(options: {
|
|
9
|
+
baseUrl: string | URL;
|
|
10
|
+
appId: string;
|
|
11
|
+
fetch?: typeof fetch;
|
|
12
|
+
}): (input: {
|
|
13
|
+
refresh: boolean;
|
|
14
|
+
}) => Promise<Session>;
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./views";
|
|
2
|
+
export * from "./preact";
|
|
3
|
+
export { createClient, createSessionProvider, reference } from "./client/connection";
|
|
4
|
+
export { createApi } from "./client/reference";
|
|
5
|
+
export type { Client, Session, Reference, References } from "./client/connection";
|
|
6
|
+
export { AppError, appError } from "./errors";
|
|
7
|
+
export type { ErrorCode } from "./errors";
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ClientProvider,
|
|
3
|
+
createApi,
|
|
4
|
+
createClient,
|
|
5
|
+
createRemoteComponent,
|
|
6
|
+
createSessionProvider,
|
|
7
|
+
defineClient,
|
|
8
|
+
defineView,
|
|
9
|
+
reference,
|
|
10
|
+
useAction,
|
|
11
|
+
useMutation,
|
|
12
|
+
useQuery
|
|
13
|
+
} from "./chunk-RHCGWGSG.js";
|
|
14
|
+
import {
|
|
15
|
+
AppError,
|
|
16
|
+
appError
|
|
17
|
+
} from "./chunk-IJBQ77AH.js";
|
|
18
|
+
export {
|
|
19
|
+
AppError,
|
|
20
|
+
ClientProvider,
|
|
21
|
+
appError,
|
|
22
|
+
createApi,
|
|
23
|
+
createClient,
|
|
24
|
+
createRemoteComponent,
|
|
25
|
+
createSessionProvider,
|
|
26
|
+
defineClient,
|
|
27
|
+
defineView,
|
|
28
|
+
reference,
|
|
29
|
+
useAction,
|
|
30
|
+
useMutation,
|
|
31
|
+
useQuery
|
|
32
|
+
};
|
package/dist/config/config.d.ts
CHANGED
|
@@ -6,12 +6,96 @@ declare const tailorkitConfigSchema: z.ZodObject<{
|
|
|
6
6
|
}, z.core.$strip>>;
|
|
7
7
|
client: z.ZodOptional<z.ZodObject<{
|
|
8
8
|
entry: z.ZodDefault<z.ZodString>;
|
|
9
|
-
}, z.core.$
|
|
9
|
+
}, z.core.$strict>>;
|
|
10
10
|
host: z.ZodString;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
logos: z.ZodOptional<z.ZodObject<{
|
|
12
|
+
dark: z.ZodOptional<z.ZodString>;
|
|
13
|
+
light: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>>;
|
|
15
|
+
server: z.ZodOptional<z.ZodObject<{
|
|
16
|
+
entry: z.ZodDefault<z.ZodString>;
|
|
17
|
+
migrations: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, z.core.$strict>>;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
/**
|
|
21
|
+
* App configuration exported from `tailorkit.config.ts`.
|
|
22
|
+
* Relative paths are resolved from the directory containing the config file.
|
|
23
|
+
*/
|
|
24
|
+
export interface TailorKitConfig extends z.input<typeof tailorkitConfigSchema> {
|
|
25
|
+
/**
|
|
26
|
+
* ID of the app on the TailorKit host, used for deployment and remote preview.
|
|
27
|
+
* When omitted, the first deployment creates an app and saves its ID here.
|
|
28
|
+
* The agent command prompts to select or create an app and saves its ID here.
|
|
29
|
+
* Remote preview requires an existing app ID.
|
|
30
|
+
* @default undefined
|
|
31
|
+
*/
|
|
32
|
+
appId?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Build output settings. Omit to use the default output directory.
|
|
35
|
+
* @default undefined
|
|
36
|
+
*/
|
|
37
|
+
build?: {
|
|
38
|
+
/**
|
|
39
|
+
* Directory for generated client bundles, server bundles, and migration assets.
|
|
40
|
+
* A build or CLI `outDir` option overrides this value.
|
|
41
|
+
* @default ".tailorkit"
|
|
42
|
+
*/
|
|
43
|
+
outDir?: string;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Browser client build settings. Omit to use the default client entry point.
|
|
47
|
+
* @default undefined
|
|
48
|
+
*/
|
|
49
|
+
client?: {
|
|
50
|
+
/**
|
|
51
|
+
* Source entry point for the app's browser bundle.
|
|
52
|
+
* @default "src/client.ts"
|
|
53
|
+
*/
|
|
54
|
+
entry?: string;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* URL of the TailorKit host used for authentication, deployment, remote preview,
|
|
58
|
+
* and fetching the host schema for generated types. Required; has no default.
|
|
59
|
+
*/
|
|
60
|
+
host: string;
|
|
61
|
+
/**
|
|
62
|
+
* Optional app logo assets included in the build and uploaded on deployment.
|
|
63
|
+
* Accepts SVG, PNG, or WebP files. Omit to upload no custom logos.
|
|
64
|
+
* @default undefined
|
|
65
|
+
*/
|
|
66
|
+
logos?: {
|
|
67
|
+
/**
|
|
68
|
+
* Path to the app logo for dark mode. Omit to upload no dark-mode logo.
|
|
69
|
+
* @default undefined
|
|
70
|
+
*/
|
|
71
|
+
dark?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Path to the app logo for light mode. Omit to upload no light-mode logo.
|
|
74
|
+
* @default undefined
|
|
75
|
+
*/
|
|
76
|
+
light?: string;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Enables the private app backend and its database migrations when present.
|
|
80
|
+
* Set to `{}` to use the default paths; omit for a client-only app.
|
|
81
|
+
* @default undefined
|
|
82
|
+
*/
|
|
83
|
+
server?: {
|
|
84
|
+
/**
|
|
85
|
+
* Source entry point for the app's private backend bundle.
|
|
86
|
+
* @default "src/server.ts"
|
|
87
|
+
*/
|
|
88
|
+
entry?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Directory containing Drizzle migrations, used for generation and bundling.
|
|
91
|
+
* When omitted, uses `./migrations` and allows that directory to be absent.
|
|
92
|
+
* An explicitly configured directory must exist when building the backend.
|
|
93
|
+
* @default "./migrations"
|
|
94
|
+
*/
|
|
95
|
+
migrations?: string;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
13
98
|
export type ResolvedTailorKitConfig = z.output<typeof tailorkitConfigSchema>;
|
|
14
99
|
export { tailorkitConfigSchema };
|
|
15
100
|
export declare const defineConfig: (config: TailorKitConfig) => TailorKitConfig;
|
|
16
101
|
export declare const defineTailorKitConfig: typeof defineConfig;
|
|
17
|
-
//# sourceMappingURL=config.d.ts.map
|
package/dist/config/index.d.ts
CHANGED
package/dist/config/loader.d.ts
CHANGED
package/dist/config-loader.js
CHANGED
package/dist/config.js
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { ColumnBuilderBase } from "drizzle-orm";
|
|
2
|
+
export declare function 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,7 @@
|
|
|
1
|
+
import type { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core";
|
|
2
|
+
type Database = BaseSQLiteDatabase<"sync", {
|
|
3
|
+
changes: number;
|
|
4
|
+
}>;
|
|
5
|
+
export type QueryDatabase = Pick<Database, "select" | "selectDistinct">;
|
|
6
|
+
export type MutationDatabase = QueryDatabase & Pick<Database, "insert" | "update" | "delete">;
|
|
7
|
+
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 function appError(error: unknown): AppError;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,72 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export interface TailorKitScreens {
|
|
4
|
-
}
|
|
5
|
-
export type ScreenPath = Extract<keyof TailorKitScreens & string, `/${string}`>;
|
|
6
|
-
export type AppScreenPath = ScreenPath;
|
|
7
|
-
export type ScreenProps<TPath extends ScreenPath> = TailorKitScreens[TPath] extends object ? TailorKitScreens[TPath] : Record<string, never>;
|
|
8
|
-
export type ScreenPropsForPath<TPath extends AppScreenPath> = TPath extends ScreenPath ? ScreenProps<TPath> : never;
|
|
9
|
-
export type ScreenContext<TPath extends AppScreenPath> = ScreenPropsForPath<TPath> extends {
|
|
10
|
-
context: infer TContext;
|
|
11
|
-
} ? TContext : Record<string, never>;
|
|
12
|
-
export type View<TProps extends object = Record<string, never>> = (props: TProps) => ComponentChild;
|
|
13
|
-
export type ScreenRuntimeProps<TPath extends AppScreenPath> = {
|
|
14
|
-
context: ScreenContext<TPath>;
|
|
15
|
-
screen: TPath;
|
|
16
|
-
status: "ready";
|
|
17
|
-
} | {
|
|
18
|
-
context?: never;
|
|
19
|
-
screen: TPath;
|
|
20
|
-
status: "loading";
|
|
21
|
-
} | {
|
|
22
|
-
context?: never;
|
|
23
|
-
screen: TPath;
|
|
24
|
-
status: "error";
|
|
25
|
-
};
|
|
26
|
-
export interface ScreenDefinition<TPath extends AppScreenPath = AppScreenPath> {
|
|
27
|
-
component: View<ScreenRuntimeProps<TPath>>;
|
|
28
|
-
path: TPath;
|
|
29
|
-
useContext: () => ScreenContext<TPath>;
|
|
30
|
-
}
|
|
31
|
-
type RegisteredScreens = {
|
|
32
|
-
[TPath in AppScreenPath]: ScreenDefinition<TPath>;
|
|
33
|
-
};
|
|
34
|
-
type ScreenDefinitions = Partial<RegisteredScreens>;
|
|
35
|
-
type InvalidScreenPath<TScreens> = Exclude<keyof TScreens & string, `/${string}`>;
|
|
36
|
-
type RequireScreenPaths<TScreens> = InvalidScreenPath<TScreens> extends never ? unknown : {
|
|
37
|
-
readonly __tailorkit_error__: `Screen paths must start with "/". Invalid screen: ${InvalidScreenPath<TScreens>}`;
|
|
38
|
-
};
|
|
39
|
-
type ScreenKeyPathMismatch<TScreens> = {
|
|
40
|
-
[TPath in keyof TScreens & string]: TScreens[TPath] extends ScreenDefinition<infer TScreenPath> ? TScreenPath extends TPath ? never : TPath : TPath;
|
|
41
|
-
}[keyof TScreens & string];
|
|
42
|
-
type RequireMatchingScreenKeys<TScreens> = ScreenKeyPathMismatch<TScreens> extends never ? unknown : {
|
|
43
|
-
readonly __tailorkit_error__: `Screen key must match createScreen path. Invalid screen: ${ScreenKeyPathMismatch<TScreens>}`;
|
|
44
|
-
};
|
|
45
|
-
export interface TailorKitClient<TScreens extends ScreenDefinitions = ScreenDefinitions> {
|
|
46
|
-
screens: TScreens;
|
|
47
|
-
}
|
|
48
|
-
export interface TailorKitClientMeta {
|
|
49
|
-
preactVersion: string;
|
|
50
|
-
}
|
|
51
|
-
export interface TailorKitClientRuntime {
|
|
52
|
-
h: typeof h;
|
|
53
|
-
render: (vnode: VNode, parent: Element | Document | ShadowRoot | DocumentFragment) => void;
|
|
54
|
-
}
|
|
55
|
-
export type TailorKitClientWithMeta<TScreens extends ScreenDefinitions = ScreenDefinitions> = TailorKitClient<TScreens> & {
|
|
56
|
-
$meta: TailorKitClientMeta;
|
|
57
|
-
$runtime: TailorKitClientRuntime;
|
|
58
|
-
};
|
|
59
|
-
export declare const createScreen: <const TPath extends AppScreenPath>(path: TPath, options: {
|
|
60
|
-
component: View<Record<string, never>>;
|
|
61
|
-
error?: View<Record<string, never>>;
|
|
62
|
-
loading?: View<Record<string, never>>;
|
|
63
|
-
}) => ScreenDefinition<TPath>;
|
|
64
|
-
export declare const defineClient: <const TScreens extends ScreenDefinitions>(client: TailorKitClient<TScreens> & RequireScreenPaths<TScreens> & RequireMatchingScreenKeys<TScreens>) => TailorKitClientWithMeta<TScreens>;
|
|
65
|
-
export declare const createRemoteComponent: <TProps extends object, TSlots extends readonly string[]>(name: string, options: {
|
|
66
|
-
callbacks?: Record<string, number>;
|
|
67
|
-
slots: TSlots;
|
|
68
|
-
}) => View<TProps & {
|
|
69
|
-
children?: ComponentChildren;
|
|
70
|
-
}>;
|
|
71
|
-
export {};
|
|
72
|
-
//# sourceMappingURL=index.d.ts.map
|
|
1
|
+
export * from "./client";
|
|
2
|
+
export * from "./server";
|
package/dist/index.js
CHANGED
|
@@ -1,79 +1,84 @@
|
|
|
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
|
-
var toEventProp = (event) => `on${event}`;
|
|
46
|
-
var createRemoteComponent = (name, options) => {
|
|
47
|
-
const tagName = toComponentTagName(name);
|
|
48
|
-
const callbacks = options.callbacks;
|
|
49
|
-
if (!callbacks || Object.keys(callbacks).length === 0) {
|
|
50
|
-
return function RemoteComponent({ children, ...props }) {
|
|
51
|
-
return h(tagName, props, children);
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
return function RemoteComponent({ children, ...props }) {
|
|
55
|
-
const nextProps = { ...props };
|
|
56
|
-
const callbackMap = {};
|
|
57
|
-
for (const [key, inputCount] of Object.entries(callbacks)) {
|
|
58
|
-
const callback = nextProps[key];
|
|
59
|
-
Reflect.deleteProperty(nextProps, key);
|
|
60
|
-
if (typeof callback !== "function") {
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
const eventName = toCallbackEventName(key);
|
|
64
|
-
callbackMap[eventName] = { callback: key, inputCount };
|
|
65
|
-
nextProps[toEventProp(eventName)] = (event) => {
|
|
66
|
-
callback(...(event.detail ?? []).slice(0, inputCount));
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
if (Object.keys(callbackMap).length > 0) {
|
|
70
|
-
nextProps["data-tailorkit-callbacks"] = JSON.stringify(callbackMap);
|
|
71
|
-
}
|
|
72
|
-
return h(tagName, nextProps, children);
|
|
73
|
-
};
|
|
74
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
ClientProvider,
|
|
3
|
+
createApi,
|
|
4
|
+
createClient,
|
|
5
|
+
createRemoteComponent,
|
|
6
|
+
createSessionProvider,
|
|
7
|
+
defineClient,
|
|
8
|
+
defineView,
|
|
9
|
+
reference,
|
|
10
|
+
useAction,
|
|
11
|
+
useMutation,
|
|
12
|
+
useQuery
|
|
13
|
+
} from "./chunk-RHCGWGSG.js";
|
|
14
|
+
import {
|
|
15
|
+
action,
|
|
16
|
+
and,
|
|
17
|
+
asc,
|
|
18
|
+
boolean,
|
|
19
|
+
count,
|
|
20
|
+
defineServer,
|
|
21
|
+
desc,
|
|
22
|
+
eq,
|
|
23
|
+
gt,
|
|
24
|
+
gte,
|
|
25
|
+
inArray,
|
|
26
|
+
integer,
|
|
27
|
+
isNotNull,
|
|
28
|
+
isNull,
|
|
29
|
+
lt,
|
|
30
|
+
lte,
|
|
31
|
+
mutation,
|
|
32
|
+
ne,
|
|
33
|
+
or,
|
|
34
|
+
query,
|
|
35
|
+
real,
|
|
36
|
+
table,
|
|
37
|
+
text,
|
|
38
|
+
tk,
|
|
39
|
+
withInstanceResolvers
|
|
40
|
+
} from "./chunk-7NOEYJOB.js";
|
|
41
|
+
import {
|
|
42
|
+
AppError,
|
|
43
|
+
appError
|
|
44
|
+
} from "./chunk-IJBQ77AH.js";
|
|
75
45
|
export {
|
|
46
|
+
AppError,
|
|
47
|
+
ClientProvider,
|
|
48
|
+
action,
|
|
49
|
+
and,
|
|
50
|
+
appError,
|
|
51
|
+
asc,
|
|
52
|
+
boolean,
|
|
53
|
+
count,
|
|
54
|
+
createApi,
|
|
55
|
+
createClient,
|
|
76
56
|
createRemoteComponent,
|
|
77
|
-
|
|
78
|
-
defineClient
|
|
57
|
+
createSessionProvider,
|
|
58
|
+
defineClient,
|
|
59
|
+
defineServer,
|
|
60
|
+
defineView,
|
|
61
|
+
desc,
|
|
62
|
+
eq,
|
|
63
|
+
gt,
|
|
64
|
+
gte,
|
|
65
|
+
inArray,
|
|
66
|
+
integer,
|
|
67
|
+
isNotNull,
|
|
68
|
+
isNull,
|
|
69
|
+
lt,
|
|
70
|
+
lte,
|
|
71
|
+
mutation,
|
|
72
|
+
ne,
|
|
73
|
+
or,
|
|
74
|
+
query,
|
|
75
|
+
real,
|
|
76
|
+
reference,
|
|
77
|
+
table,
|
|
78
|
+
text,
|
|
79
|
+
tk,
|
|
80
|
+
useAction,
|
|
81
|
+
useMutation,
|
|
82
|
+
useQuery,
|
|
83
|
+
withInstanceResolvers
|
|
79
84
|
};
|
package/dist/preact-version.d.ts
CHANGED
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 type { Reference } from "./client/reference";
|
|
4
|
+
import { QueryStore } from "./client/query-store";
|
|
5
|
+
import type { QueryState } from "./client/query-store";
|
|
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 function 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 function 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 function 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 function useAction<I, O>(ref: Reference<"action", I, O>, options?: CallOptions<I, O>): ActionResult<I, O>;
|
|
52
|
+
export {};
|