appflare 0.1.13 → 0.2.1

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.
@@ -1,112 +1 @@
1
- export function generateClientAppflareSource(): string {
2
- return `import { createAuthClient, type BetterAuthClientOptions } from "better-auth/client";
3
- import type {
4
- AppflareAuth,
5
- AppflareAuthTokenResolver,
6
- AppflareOptions,
7
- InferredAuthOptions,
8
- StorageClient,
9
- } from "./types";
10
- import type { MutationsClient, QueriesClient } from "./handlers";
11
- import { createStorageClient } from "./storage";
12
- import { createMutationsClient, createQueriesClient } from "./handlers";
13
-
14
- export class Appflare<Options extends BetterAuthClientOptions = InferredAuthOptions> {
15
- public readonly endpoint: string;
16
- public readonly wsEndpoint: string;
17
- public readonly auth: AppflareAuth<Options>;
18
- public readonly storage: StorageClient;
19
- public readonly queries: QueriesClient;
20
- public readonly mutations: MutationsClient;
21
-
22
- public constructor(options: AppflareOptions<Options>) {
23
- this.endpoint = options.endpoint.replace(/\\/$/, "");
24
- this.wsEndpoint = (options.wsEndpoint ?? this.endpoint).replace(/\\/$/, "");
25
- const authOptions = (options.authOptions ?? {}) as Options;
26
- const request = options.fetch ?? fetch;
27
- const onSetAuthToken = options.onSetAuthToken;
28
- const onGetAuthToken: AppflareAuthTokenResolver =
29
- options.onGetAuthToken ?? (() => "");
30
-
31
- const authFetchOptions =
32
- (authOptions as { fetchOptions?: Record<string, unknown> }).fetchOptions ??
33
- {};
34
- const mergedAuthOptions = {
35
- ...(authOptions as Record<string, unknown>),
36
- fetchOptions: {
37
- ...authFetchOptions,
38
- onSuccess: async (ctx: {
39
- response: { headers: { get: (name: string) => string | null } };
40
- }) => {
41
- if (
42
- typeof (authFetchOptions as { onSuccess?: unknown }).onSuccess ===
43
- "function"
44
- ) {
45
- await (
46
- (authFetchOptions as { onSuccess: (ctx: unknown) => unknown }).onSuccess
47
- )(ctx);
48
- }
49
-
50
- const authToken = ctx.response.headers.get("set-auth-token");
51
- if (authToken && onSetAuthToken) {
52
- await onSetAuthToken(authToken);
53
- }
54
- },
55
- onRequest: async (ctx: {
56
- headers: Headers;
57
- }) => {
58
- let nextCtx = ctx;
59
- if (
60
- typeof (authFetchOptions as { onRequest?: unknown }).onRequest ===
61
- "function"
62
- ) {
63
- const maybeCtx = await (
64
- (authFetchOptions as { onRequest: (ctx: unknown) => unknown }).onRequest
65
- )(ctx);
66
- if (
67
- typeof maybeCtx === "object" &&
68
- maybeCtx !== null &&
69
- "headers" in maybeCtx
70
- ) {
71
- nextCtx = maybeCtx as typeof ctx;
72
- }
73
- }
74
-
75
- const authToken = await onGetAuthToken();
76
- if (typeof authToken === "string" && authToken.trim().length > 0) {
77
- nextCtx.headers.set("Authorization", \`Bearer \${authToken.trim()}\`);
78
- }
79
-
80
- return nextCtx;
81
- },
82
- },
83
- };
84
-
85
- this.auth = createAuthClient<Options>({
86
- ...(mergedAuthOptions as Options),
87
- baseURL: \`\${this.endpoint}\${options.authPath ?? "/api/auth"}\`,
88
- fetch: request,
89
- });
90
-
91
- this.storage = createStorageClient(this.endpoint, request, onGetAuthToken);
92
- this.queries = createQueriesClient(
93
- this.endpoint,
94
- options.requestOptions,
95
- this.wsEndpoint,
96
- onGetAuthToken,
97
- );
98
- this.mutations = createMutationsClient(
99
- this.endpoint,
100
- options.requestOptions,
101
- onGetAuthToken,
102
- );
103
- }
104
- }
105
-
106
- export function createAppflare<Options extends BetterAuthClientOptions = InferredAuthOptions>(
107
- options: AppflareOptions<Options>,
108
- ): Appflare<Options> {
109
- return new Appflare(options);
110
- }
111
- `;
112
- }
1
+ export { generateClientAppflareSource } from "../client/appflare";
@@ -1 +1 @@
1
- export { generateClientHandlersSource } from "./handlers/index";
1
+ export { generateClientHandlersSource } from "../client/handlers";
@@ -1,7 +1 @@
1
- export function generateClientIndexSource(): string {
2
- return `export * from "./types";
3
- export * from "./appflare";
4
- export * from "./storage";
5
- export * from "./handlers";
6
- `;
7
- }
1
+ export { generateClientIndexSource } from "../client/index";
@@ -1,180 +1 @@
1
- export function generateClientStorageSource(): string {
2
- return `import type { StorageClient, StorageSignedUrlResponse, StorageListResponse } from "./types";
3
-
4
- type AuthTokenResolver = (() => string | Promise<string>) | undefined;
5
-
6
- function toHeaderRecord(headers: HeadersInit | undefined): Record<string, string> {
7
- const result: Record<string, string> = {};
8
- if (!headers) {
9
- return result;
10
- }
11
-
12
- if (Array.isArray(headers)) {
13
- for (const entry of headers) {
14
- if (!Array.isArray(entry) || entry.length < 2) {
15
- continue;
16
- }
17
- result[String(entry[0])] = String(entry[1]);
18
- }
19
- return result;
20
- }
21
-
22
- if (typeof (headers as { forEach?: unknown }).forEach === "function") {
23
- (headers as Headers).forEach((value, key) => {
24
- result[key] = String(value);
25
- });
26
- return result;
27
- }
28
-
29
- for (const [key, value] of Object.entries(headers as Record<string, unknown>)) {
30
- result[key] = String(value ?? "");
31
- }
32
-
33
- return result;
34
- }
35
-
36
- function hasAuthorizationHeader(headers: Record<string, string>): boolean {
37
- for (const key of Object.keys(headers)) {
38
- if (key.toLowerCase() === "authorization") {
39
- return true;
40
- }
41
- }
42
-
43
- return false;
44
- }
45
-
46
- async function createAuthorizedHeaders(
47
- headers: HeadersInit | undefined,
48
- onGetAuthToken: AuthTokenResolver,
49
- ): Promise<HeadersInit | undefined> {
50
- const resolvedHeaders = toHeaderRecord(headers);
51
- if (onGetAuthToken) {
52
- const authToken = await onGetAuthToken();
53
- if (typeof authToken === "string" && authToken.trim().length > 0) {
54
- if (!hasAuthorizationHeader(resolvedHeaders)) {
55
- resolvedHeaders.authorization = \`Bearer \${authToken.trim()}\`;
56
- }
57
- }
58
- }
59
-
60
- return resolvedHeaders;
61
- }
62
-
63
- export function createStorageClient(
64
- endpoint: string,
65
- request: typeof fetch = fetch,
66
- onGetAuthToken?: () => string | Promise<string>,
67
- ): StorageClient {
68
- return {
69
- upload: async (args) => {
70
- const headers = await createAuthorizedHeaders(
71
- {
72
- "content-type": "application/json",
73
- },
74
- onGetAuthToken,
75
- );
76
-
77
- const response = await request(\`\${endpoint}/storage/upload\`, {
78
- method: "POST",
79
- headers,
80
- body: JSON.stringify(args),
81
- });
82
- if (!response.ok) {
83
- throw new Error(await response.text());
84
- }
85
-
86
- return (await response.json()) as StorageSignedUrlResponse;
87
- },
88
- download: async (args) => {
89
- const query = new URLSearchParams({
90
- path: args.path,
91
- ...(args.fileName ? { fileName: args.fileName } : {}),
92
- ...(typeof args.expiresIn === "number"
93
- ? { expiresIn: String(args.expiresIn) }
94
- : {}),
95
- });
96
- const response = await request(
97
- \`\${endpoint}/storage/download?\${query.toString()}\`,
98
- {
99
- headers: await createAuthorizedHeaders(undefined, onGetAuthToken),
100
- },
101
- );
102
- if (!response.ok) {
103
- throw new Error(await response.text());
104
- }
105
-
106
- return (await response.json()) as StorageSignedUrlResponse;
107
- },
108
- preview: async (args) => {
109
- const query = new URLSearchParams({
110
- path: args.path,
111
- ...(typeof args.expiresIn === "number"
112
- ? { expiresIn: String(args.expiresIn) }
113
- : {}),
114
- });
115
- const response = await request(
116
- \`\${endpoint}/storage/preview?\${query.toString()}\`,
117
- {
118
- headers: await createAuthorizedHeaders(undefined, onGetAuthToken),
119
- },
120
- );
121
- if (!response.ok) {
122
- throw new Error(await response.text());
123
- }
124
-
125
- return (await response.json()) as StorageSignedUrlResponse;
126
- },
127
- delete: async (args) => {
128
- const query = new URLSearchParams({
129
- path: args.path,
130
- });
131
- const response = await request(
132
- \`\${endpoint}/storage/object?\${query.toString()}\`,
133
- {
134
- method: "DELETE",
135
- headers: await createAuthorizedHeaders(undefined, onGetAuthToken),
136
- },
137
- );
138
- if (!response.ok) {
139
- throw new Error(await response.text());
140
- }
141
-
142
- return (await response.json()) as { ok: boolean; path: string };
143
- },
144
- list: async (args = {}) => {
145
- const query = new URLSearchParams();
146
- if (args.prefix) {
147
- query.set("prefix", args.prefix);
148
- }
149
- if (args.cursor) {
150
- query.set("cursor", args.cursor);
151
- }
152
- if (typeof args.limit === "number") {
153
- query.set("limit", String(args.limit));
154
- }
155
- if (args.delimiter) {
156
- query.set("delimiter", args.delimiter);
157
- }
158
- if (args.method) {
159
- query.set("method", args.method);
160
- }
161
-
162
- const querySuffix = query.toString();
163
- const response = await request(
164
- querySuffix.length > 0
165
- ? \`\${endpoint}/storage/list?\${querySuffix}\`
166
- : \`\${endpoint}/storage/list\`,
167
- {
168
- headers: await createAuthorizedHeaders(undefined, onGetAuthToken),
169
- },
170
- );
171
- if (!response.ok) {
172
- throw new Error(await response.text());
173
- }
174
-
175
- return (await response.json()) as StorageListResponse;
176
- },
177
- };
178
- }
179
- `;
180
- }
1
+ export { generateClientStorageSource } from "../client/storage";
@@ -1,145 +1 @@
1
- export function generateClientTypesSource(configPathImport: string): string {
2
- return `import { createAuthClient, type BetterAuthClientOptions } from "better-auth/client";
3
- import type appflareConfig from "${configPathImport}";
4
-
5
- export type AppflareConfig = typeof appflareConfig;
6
- export type InferredAuthOptions = AppflareConfig["auth"]["clientOptions"];
7
-
8
- export type AppflareAuth<Options extends BetterAuthClientOptions = InferredAuthOptions> = ReturnType<
9
- typeof createAuthClient<Options>
10
- >;
11
-
12
- export type AppflareAuthTokenResolver = () => string | Promise<string>;
13
-
14
- export type AppflareOptions<Options extends BetterAuthClientOptions = InferredAuthOptions> = {
15
- endpoint: string;
16
- wsEndpoint?: string;
17
- authPath?: string;
18
- authOptions?: Options;
19
- fetch?: typeof fetch;
20
- requestOptions?: AppflareResultRouteCallOptions;
21
- onSetAuthToken?: (token: string) => void | Promise<void>;
22
- onGetAuthToken?: AppflareAuthTokenResolver;
23
- };
24
-
25
- export type AppflareErrorMode = "throw" | "return";
26
-
27
- export type AppflareRequestError = {
28
- route: string;
29
- method: "GET" | "POST";
30
- status: number;
31
- message: string;
32
- body?: unknown;
33
- responseText?: string;
34
- };
35
-
36
- export type AppflareRequestResult<TData> = {
37
- data: TData | null;
38
- error: AppflareRequestError | null;
39
- };
40
-
41
- export type AppflareRouteCallOptions<
42
- Mode extends AppflareErrorMode = "throw",
43
- > = {
44
- errorMode?: Mode;
45
- headers?: HeadersInit;
46
- signal?: AbortSignal;
47
- onError?: (error: AppflareRequestError) => void;
48
- };
49
-
50
- export type AppflareResultRouteCallOptions = Omit<
51
- AppflareRouteCallOptions<"return">,
52
- "errorMode"
53
- >;
54
-
55
- export type AppflareRouteClient<
56
- TSchema extends import("zod").ZodObject<import("zod").ZodRawShape>,
57
- TOutput,
58
- > = {
59
- schema: TSchema;
60
- run(
61
- args: import("zod").input<TSchema>,
62
- options?: AppflareResultRouteCallOptions,
63
- ): Promise<AppflareRequestResult<TOutput>>;
64
- };
65
-
66
- export type AppflareRealtimeSubscription = {
67
- remove: () => void;
68
- };
69
-
70
- export type AppflareRealtimeQueryUpdate<TOutput> = {
71
- event: "query:update";
72
- payload: {
73
- queryName: string;
74
- signature: string;
75
- data: TOutput;
76
- };
77
- };
78
-
79
- export type AppflareQuerySubscribeOptions<TInput, TOutput> = {
80
- args?: TInput;
81
- authToken?: string;
82
- onChange: (data: TOutput, update: AppflareRealtimeQueryUpdate<TOutput>) => void;
83
- onError?: (error: unknown) => void;
84
- requestOptions?: AppflareRouteCallOptions;
85
- signal?: AbortSignal;
86
- };
87
-
88
- export type AppflareQueryRouteClient<
89
- TSchema extends import("zod").ZodObject<import("zod").ZodRawShape>,
90
- TOutput,
91
- > = AppflareRouteClient<TSchema, TOutput> & {
92
- subscribe: (
93
- options: AppflareQuerySubscribeOptions<import("zod").input<TSchema>, TOutput>,
94
- ) => AppflareRealtimeSubscription;
95
- };
96
-
97
- export type StorageSignedUrlResponse = {
98
- url: string;
99
- method: "GET" | "PUT" | "DELETE";
100
- path: string;
101
- disposition?: "attachment" | "inline";
102
- expiresIn?: number;
103
- };
104
-
105
- export type StorageListResponse = unknown;
106
-
107
- export type StorageClient = {
108
- upload: (args: {
109
- path: string;
110
- contentType?: string;
111
- expiresIn?: number;
112
- }) => Promise<StorageSignedUrlResponse>;
113
- download: (args: {
114
- path: string;
115
- expiresIn?: number;
116
- fileName?: string;
117
- }) => Promise<StorageSignedUrlResponse>;
118
- preview: (args: {
119
- path: string;
120
- expiresIn?: number;
121
- }) => Promise<StorageSignedUrlResponse>;
122
- delete: (args: { path: string }) => Promise<{ ok: boolean; path: string }>;
123
- list: (args?: {
124
- prefix?: string;
125
- cursor?: string;
126
- limit?: number;
127
- delimiter?: string;
128
- method?: "download" | "get" | "delete" | "list" | "put" | "preview";
129
- }) => Promise<StorageListResponse>;
130
- };
131
-
132
- export type RealtimeSubscriptionResponse = {
133
- token: string;
134
- signature: string;
135
- websocket: {
136
- url: string;
137
- protocol: string;
138
- params: {
139
- tokenParam: "token";
140
- authTokenParam: "authToken";
141
- };
142
- };
143
- };
144
- `;
145
- }
1
+ export { generateClientTypesSource } from "../client/types";
@@ -0,0 +1,39 @@
1
+ import { generateClientAppflareSource } from "./client/appflare";
2
+ import { generateClientHandlersSource } from "./client/handlers";
3
+ import { generateClientIndexSource } from "./client/index";
4
+ import { generateClientStorageSource } from "./client/storage";
5
+ import { generateClientTypesSource } from "./client/types";
6
+ import type { DiscoveredHandlerOperation } from "../../utils/handler-discovery";
7
+
8
+ export type GeneratedClientArtifact = {
9
+ relativePath: string;
10
+ source: string;
11
+ };
12
+
13
+ export function generateClientArtifacts(
14
+ configPathImport: string,
15
+ operations: DiscoveredHandlerOperation[],
16
+ ): GeneratedClientArtifact[] {
17
+ return [
18
+ {
19
+ relativePath: "client/index.ts",
20
+ source: generateClientIndexSource(),
21
+ },
22
+ {
23
+ relativePath: "client/types.ts",
24
+ source: generateClientTypesSource(configPathImport),
25
+ },
26
+ {
27
+ relativePath: "client/storage.ts",
28
+ source: generateClientStorageSource(),
29
+ },
30
+ {
31
+ relativePath: "client/handlers.ts",
32
+ source: generateClientHandlersSource(operations),
33
+ },
34
+ {
35
+ relativePath: "client/appflare.ts",
36
+ source: generateClientAppflareSource(),
37
+ },
38
+ ];
39
+ }
@@ -1,39 +1,4 @@
1
- import { generateClientAppflareSource } from "./client-modules/appflare";
2
- import { generateClientHandlersSource } from "./client-modules/handlers";
3
- import { generateClientIndexSource } from "./client-modules/index";
4
- import { generateClientStorageSource } from "./client-modules/storage";
5
- import { generateClientTypesSource } from "./client-modules/types";
6
- import type { DiscoveredHandlerOperation } from "../../utils/handler-discovery";
7
-
8
- export type GeneratedClientArtifact = {
9
- relativePath: string;
10
- source: string;
11
- };
12
-
13
- export function generateClientArtifacts(
14
- configPathImport: string,
15
- operations: DiscoveredHandlerOperation[],
16
- ): GeneratedClientArtifact[] {
17
- return [
18
- {
19
- relativePath: "client/index.ts",
20
- source: generateClientIndexSource(),
21
- },
22
- {
23
- relativePath: "client/types.ts",
24
- source: generateClientTypesSource(configPathImport),
25
- },
26
- {
27
- relativePath: "client/storage.ts",
28
- source: generateClientStorageSource(),
29
- },
30
- {
31
- relativePath: "client/handlers.ts",
32
- source: generateClientHandlersSource(operations),
33
- },
34
- {
35
- relativePath: "client/appflare.ts",
36
- source: generateClientAppflareSource(),
37
- },
38
- ];
39
- }
1
+ export {
2
+ generateClientArtifacts,
3
+ type GeneratedClientArtifact,
4
+ } from "./client.artifacts";
@@ -1,7 +1,7 @@
1
1
  import { generateAuthRoute } from "../auth/route";
2
2
  import { generateAppCreation } from "./app-creation";
3
3
  import { generateExport } from "./export";
4
- import { generateHandlersRoute } from "./handlers-route";
4
+ import { generateHandlersRoute } from "./handlers.route";
5
5
  import { generateImports } from "./imports";
6
6
  import { generateTypes } from "./types";
7
7
 
@@ -17,21 +17,83 @@ type TableFindManyArgs<TName extends TableName> = TableQuery<TName> extends {
17
17
  }
18
18
  ? TArgs
19
19
  : never;
20
- type TableFindManyResult<TName extends TableName> = TableQuery<TName> extends {
21
- findMany: (args?: unknown) => infer TResult;
20
+ type TableFindManyMethod<TName extends TableName> = TableQuery<TName> extends {
21
+ findMany: infer TMethod;
22
22
  }
23
+ ? TMethod
24
+ : never;
25
+ type NativeFindManyWith<TName extends TableName> =
26
+ NonNullable<TableFindManyArgs<TName>> extends { with?: infer TWith }
27
+ ? TWith
28
+ : never;
29
+ type ResolveNativeFindManyWith<
30
+ TName extends TableName,
31
+ TArgs extends QueryFindManyArgs<TName> | undefined,
32
+ > = TArgs extends { with?: infer TWith }
33
+ ? Extract<TWith, NativeFindManyWith<TName>>
34
+ : never;
35
+ type ResolveTableFindManyArgs<
36
+ TName extends TableName,
37
+ TArgs extends QueryFindManyArgs<TName> | undefined,
38
+ > = TArgs extends undefined
39
+ ? undefined
40
+ : Omit<NonNullable<TableFindManyArgs<TName>>, "where" | "with"> &
41
+ (ResolveNativeFindManyWith<TName, TArgs> extends never
42
+ ? {}
43
+ : { with?: ResolveNativeFindManyWith<TName, TArgs> });
44
+ type TableFindManyResult<
45
+ TName extends TableName,
46
+ TArgs extends QueryFindManyArgs<TName> | undefined =
47
+ | QueryFindManyArgs<TName>
48
+ | undefined,
49
+ > = TableFindManyMethod<TName> extends (
50
+ args?: ResolveTableFindManyArgs<TName, TArgs>,
51
+ ) => infer TResult
23
52
  ? TResult
24
- : Promise<Array<TableModel<TName>>>;
53
+ : TableFindManyMethod<TName> extends (args?: unknown) => infer TResult
54
+ ? TResult
55
+ : Promise<Array<TableModel<TName>>>;
25
56
  type TableFindFirstArgs<TName extends TableName> = TableQuery<TName> extends {
26
57
  findFirst: (args?: infer TArgs) => Promise<unknown>;
27
58
  }
28
59
  ? TArgs
29
60
  : never;
30
- type TableFindFirstResult<TName extends TableName> = TableQuery<TName> extends {
31
- findFirst: (args?: unknown) => infer TResult;
61
+ type TableFindFirstMethod<TName extends TableName> = TableQuery<TName> extends {
62
+ findFirst: infer TMethod;
32
63
  }
64
+ ? TMethod
65
+ : never;
66
+ type NativeFindFirstWith<TName extends TableName> =
67
+ NonNullable<TableFindFirstArgs<TName>> extends { with?: infer TWith }
68
+ ? TWith
69
+ : never;
70
+ type ResolveNativeFindFirstWith<
71
+ TName extends TableName,
72
+ TArgs extends QueryFindFirstArgs<TName> | undefined,
73
+ > = TArgs extends { with?: infer TWith }
74
+ ? Extract<TWith, NativeFindFirstWith<TName>>
75
+ : never;
76
+ type ResolveTableFindFirstArgs<
77
+ TName extends TableName,
78
+ TArgs extends QueryFindFirstArgs<TName> | undefined,
79
+ > = TArgs extends undefined
80
+ ? undefined
81
+ : Omit<NonNullable<TableFindFirstArgs<TName>>, "where" | "with"> &
82
+ (ResolveNativeFindFirstWith<TName, TArgs> extends never
83
+ ? {}
84
+ : { with?: ResolveNativeFindFirstWith<TName, TArgs> });
85
+ type TableFindFirstResult<
86
+ TName extends TableName,
87
+ TArgs extends QueryFindFirstArgs<TName> | undefined =
88
+ | QueryFindFirstArgs<TName>
89
+ | undefined,
90
+ > = TableFindFirstMethod<TName> extends (
91
+ args?: ResolveTableFindFirstArgs<TName, TArgs>,
92
+ ) => infer TResult
33
93
  ? TResult
34
- : Promise<TableModel<TName> | null>;
94
+ : TableFindFirstMethod<TName> extends (args?: unknown) => infer TResult
95
+ ? TResult
96
+ : Promise<TableModel<TName> | null>;
35
97
  type TableModel<TName extends TableName> = InferSelectModel<
36
98
  (typeof mergedSchema)[TName]
37
99
  >;
@@ -176,22 +238,16 @@ type QueryWithInput<TWith> = TWith extends Record<string, unknown>
176
238
 
177
239
  export type QueryFindManyArgs<TName extends TableName> = Omit<
178
240
  NonNullable<TableFindManyArgs<TName>>,
179
- "where" | "with"
241
+ "where"
180
242
  > & {
181
243
  where?: WhereInput<TableModel<TName>>;
182
- with?: TableFindManyArgs<TName> extends { with?: infer TWith }
183
- ? QueryWithInput<TWith>
184
- : never;
185
244
  };
186
245
 
187
246
  export type QueryFindFirstArgs<TName extends TableName> = Omit<
188
247
  NonNullable<TableFindFirstArgs<TName>>,
189
- "where" | "with"
248
+ "where"
190
249
  > & {
191
250
  where?: WhereInput<TableModel<TName>>;
192
- with?: TableFindFirstArgs<TName> extends { with?: infer TWith }
193
- ? QueryWithInput<TWith>
194
- : never;
195
251
  };
196
252
 
197
253
  export type QueryInsertArgs<TName extends TableName> = {
@@ -303,20 +359,20 @@ export type QueryUpsertArgs<TName extends TableName> = {
303
359
  };
304
360
 
305
361
  export type QueryTableApi<TName extends TableName> = {
306
- findMany: <
362
+ findMany: TableFindManyMethod<TName> & (<
307
363
  TArgs extends QueryFindManyArgs<TName> | undefined =
308
364
  | QueryFindManyArgs<TName>
309
365
  | undefined,
310
366
  >(
311
367
  args?: TArgs,
312
- ) => ApplyFindManyWithAggregateResult<TableFindManyResult<TName>, TArgs>;
313
- findFirst: <
368
+ ) => ApplyFindManyWithAggregateResult<TableFindManyResult<TName, TArgs>, TArgs>);
369
+ findFirst: TableFindFirstMethod<TName> & (<
314
370
  TArgs extends QueryFindFirstArgs<TName> | undefined =
315
371
  | QueryFindFirstArgs<TName>
316
372
  | undefined,
317
373
  >(
318
374
  args?: TArgs,
319
- ) => ApplyFindFirstWithAggregateResult<TableFindFirstResult<TName>, TArgs>;
375
+ ) => ApplyFindFirstWithAggregateResult<TableFindFirstResult<TName, TArgs>, TArgs>);
320
376
  insert: (args: QueryInsertArgs<TName>) => Promise<Array<TableModel<TName>>>;
321
377
  update: (args: QueryUpdateArgs<TName>) => Promise<Array<TableModel<TName>>>;
322
378
  upsert: (args: QueryUpsertArgs<TName>) => Promise<Array<TableModel<TName>>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appflare",
3
- "version": "0.1.13",
3
+ "version": "0.2.1",
4
4
  "bin": {
5
5
  "appflare": "./cli/index.ts"
6
6
  },