Skip to content

Commit

Permalink
temp fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zth committed May 2, 2024
1 parent a535f18 commit 1b6dd26
Show file tree
Hide file tree
Showing 3 changed files with 206 additions and 102 deletions.
2 changes: 2 additions & 0 deletions packages/cli/src/parseRescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export function parseCode(
.toString(),
);

content.reverse();

const queries: Array<string> = [];

content.forEach((v) => {
Expand Down
142 changes: 122 additions & 20 deletions packages/example/src/books/BookService__sql.gen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,47 @@ import type {t as JSON_t} from './JSON.gen';

export type category = "novel" | "science-fiction" | "thriller";

export type notification_type = "deadline" | "notification" | "reminder";

export type arrayJSON_t = JSON_t[];

export type categoryArray = category[];

/** 'BooksByAuthor' parameters type */
export type booksByAuthorParams = { readonly authorName: string };
export type query1Params_notification = {
readonly payload?: JSON_t;
readonly user_id?: number;
readonly type: (undefined | notification_type)
};

/** 'Query1' parameters type */
export type query1Params = { readonly notification: query1Params_notification };

/** 'Query1' return type */
export type query1Result = void;

/** 'Query1' query type */
export type query1Query = { readonly params: query1Params; readonly result: query1Result };

export type query2Params_notification = {
readonly payload?: JSON_t;
readonly user_id?: number;
readonly type: (undefined | notification_type)
};

/** 'Query2' parameters type */
export type query2Params = { readonly notification: query2Params_notification };

/** 'Query2' return type */
export type query2Result = void;

/** 'Query2' query type */
export type query2Query = { readonly params: query2Params; readonly result: query2Result };

/** 'Query3' parameters type */
export type query3Params = { readonly authorName: string };

/** 'BooksByAuthor' return type */
export type booksByAuthorResult = {
/** 'Query3' return type */
export type query3Result = {
readonly author_id: (undefined | number);
readonly big_int: (undefined | bigint);
readonly categories: (undefined | categoryArray);
Expand All @@ -29,8 +61,8 @@ export type booksByAuthorResult = {
readonly rank: (undefined | number)
};

/** 'BooksByAuthor' query type */
export type booksByAuthorQuery = { readonly params: booksByAuthorParams; readonly result: booksByAuthorResult };
/** 'Query3' query type */
export type query3Query = { readonly params: query3Params; readonly result: query3Result };

/** 'FindBookById' parameters type */
export type findBookByIdParams = { readonly id?: number };
Expand All @@ -50,20 +82,52 @@ export type findBookByIdResult = {
export type findBookByIdQuery = { readonly params: findBookByIdParams; readonly result: findBookByIdResult };

/** Returns an array of all matched results. */
export const BooksByAuthor_many: (_1:PgTyped_Pg_Client_t, _2:booksByAuthorParams) => Promise<booksByAuthorResult[]> = BookService__sqlJS.BooksByAuthor.many as any;
export const Query1_many: (_1:PgTyped_Pg_Client_t, _2:query1Params) => Promise<query1Result[]> = BookService__sqlJS.Query1.many as any;

/** Returns exactly 1 result. Returns `None` if more or less than exactly 1 result is returned. */
export const BooksByAuthor_one: (_1:PgTyped_Pg_Client_t, _2:booksByAuthorParams) => Promise<(undefined | booksByAuthorResult)> = BookService__sqlJS.BooksByAuthor.one as any;
export const Query1_one: (_1:PgTyped_Pg_Client_t, _2:query1Params) => Promise<(undefined | query1Result)> = BookService__sqlJS.Query1.one as any;

/** Returns exactly 1 result. Returns `Error` (with an optionally provided `errorMessage`) if more or less than exactly 1 result is returned. */
export const BooksByAuthor_expectOne: (_1:PgTyped_Pg_Client_t, _2:booksByAuthorParams, errorMessage:(undefined | string)) => Promise<
{ TAG: "Ok"; _0: booksByAuthorResult }
| { TAG: "Error"; _0: string }> = BookService__sqlJS.BooksByAuthor.expectOne as any;
export const Query1_expectOne: (_1:PgTyped_Pg_Client_t, _2:query1Params, errorMessage:(undefined | string)) => Promise<
{ TAG: "Ok"; _0: query1Result }
| { TAG: "Error"; _0: string }> = BookService__sqlJS.Query1.expectOne as any;

/** Executes the query, but ignores whatever is returned by it. */
export const BooksByAuthor_execute: (_1:PgTyped_Pg_Client_t, _2:booksByAuthorParams) => Promise<void> = BookService__sqlJS.BooksByAuthor.execute as any;
export const Query1_execute: (_1:PgTyped_Pg_Client_t, _2:query1Params) => Promise<void> = BookService__sqlJS.Query1.execute as any;

export const booksByAuthor: (params:booksByAuthorParams, client:PgTyped_Pg_Client_t) => Promise<booksByAuthorResult[]> = BookService__sqlJS.booksByAuthor as any;
export const query1: (params:query1Params, client:PgTyped_Pg_Client_t) => Promise<query1Result[]> = BookService__sqlJS.query1 as any;

/** Returns an array of all matched results. */
export const Query2_many: (_1:PgTyped_Pg_Client_t, _2:query2Params) => Promise<query2Result[]> = BookService__sqlJS.Query2.many as any;

/** Returns exactly 1 result. Returns `None` if more or less than exactly 1 result is returned. */
export const Query2_one: (_1:PgTyped_Pg_Client_t, _2:query2Params) => Promise<(undefined | query2Result)> = BookService__sqlJS.Query2.one as any;

/** Returns exactly 1 result. Returns `Error` (with an optionally provided `errorMessage`) if more or less than exactly 1 result is returned. */
export const Query2_expectOne: (_1:PgTyped_Pg_Client_t, _2:query2Params, errorMessage:(undefined | string)) => Promise<
{ TAG: "Ok"; _0: query2Result }
| { TAG: "Error"; _0: string }> = BookService__sqlJS.Query2.expectOne as any;

/** Executes the query, but ignores whatever is returned by it. */
export const Query2_execute: (_1:PgTyped_Pg_Client_t, _2:query2Params) => Promise<void> = BookService__sqlJS.Query2.execute as any;

export const query2: (params:query2Params, client:PgTyped_Pg_Client_t) => Promise<query2Result[]> = BookService__sqlJS.query2 as any;

/** Returns an array of all matched results. */
export const Query3_many: (_1:PgTyped_Pg_Client_t, _2:query3Params) => Promise<query3Result[]> = BookService__sqlJS.Query3.many as any;

/** Returns exactly 1 result. Returns `None` if more or less than exactly 1 result is returned. */
export const Query3_one: (_1:PgTyped_Pg_Client_t, _2:query3Params) => Promise<(undefined | query3Result)> = BookService__sqlJS.Query3.one as any;

/** Returns exactly 1 result. Returns `Error` (with an optionally provided `errorMessage`) if more or less than exactly 1 result is returned. */
export const Query3_expectOne: (_1:PgTyped_Pg_Client_t, _2:query3Params, errorMessage:(undefined | string)) => Promise<
{ TAG: "Ok"; _0: query3Result }
| { TAG: "Error"; _0: string }> = BookService__sqlJS.Query3.expectOne as any;

/** Executes the query, but ignores whatever is returned by it. */
export const Query3_execute: (_1:PgTyped_Pg_Client_t, _2:query3Params) => Promise<void> = BookService__sqlJS.Query3.execute as any;

export const query3: (params:query3Params, client:PgTyped_Pg_Client_t) => Promise<query3Result[]> = BookService__sqlJS.query3 as any;

/** Returns an array of all matched results. */
export const FindBookById_many: (_1:PgTyped_Pg_Client_t, _2:findBookByIdParams) => Promise<findBookByIdResult[]> = BookService__sqlJS.FindBookById.many as any;
Expand Down Expand Up @@ -100,21 +164,59 @@ export const FindBookById: {
execute: (_1:PgTyped_Pg_Client_t, _2:findBookByIdParams) => Promise<void>
} = BookService__sqlJS.FindBookById as any;

export const BooksByAuthor: {
export const Query1: {
/** Returns exactly 1 result. Returns `Error` (with an optionally provided `errorMessage`) if more or less than exactly 1 result is returned. */
expectOne: (_1:PgTyped_Pg_Client_t, _2:query1Params, errorMessage:(undefined | string)) => Promise<
{
TAG: "Ok";
_0: query1Result
}
| {
TAG: "Error";
_0: string
}>;
/** Returns exactly 1 result. Returns `None` if more or less than exactly 1 result is returned. */
one: (_1:PgTyped_Pg_Client_t, _2:query1Params) => Promise<(undefined | query1Result)>;
/** Returns an array of all matched results. */
many: (_1:PgTyped_Pg_Client_t, _2:query1Params) => Promise<query1Result[]>;
/** Executes the query, but ignores whatever is returned by it. */
execute: (_1:PgTyped_Pg_Client_t, _2:query1Params) => Promise<void>
} = BookService__sqlJS.Query1 as any;

export const Query2: {
/** Returns exactly 1 result. Returns `Error` (with an optionally provided `errorMessage`) if more or less than exactly 1 result is returned. */
expectOne: (_1:PgTyped_Pg_Client_t, _2:query2Params, errorMessage:(undefined | string)) => Promise<
{
TAG: "Ok";
_0: query2Result
}
| {
TAG: "Error";
_0: string
}>;
/** Returns exactly 1 result. Returns `None` if more or less than exactly 1 result is returned. */
one: (_1:PgTyped_Pg_Client_t, _2:query2Params) => Promise<(undefined | query2Result)>;
/** Returns an array of all matched results. */
many: (_1:PgTyped_Pg_Client_t, _2:query2Params) => Promise<query2Result[]>;
/** Executes the query, but ignores whatever is returned by it. */
execute: (_1:PgTyped_Pg_Client_t, _2:query2Params) => Promise<void>
} = BookService__sqlJS.Query2 as any;

export const Query3: {
/** Returns exactly 1 result. Returns `Error` (with an optionally provided `errorMessage`) if more or less than exactly 1 result is returned. */
expectOne: (_1:PgTyped_Pg_Client_t, _2:booksByAuthorParams, errorMessage:(undefined | string)) => Promise<
expectOne: (_1:PgTyped_Pg_Client_t, _2:query3Params, errorMessage:(undefined | string)) => Promise<
{
TAG: "Ok";
_0: booksByAuthorResult
_0: query3Result
}
| {
TAG: "Error";
_0: string
}>;
/** Returns exactly 1 result. Returns `None` if more or less than exactly 1 result is returned. */
one: (_1:PgTyped_Pg_Client_t, _2:booksByAuthorParams) => Promise<(undefined | booksByAuthorResult)>;
one: (_1:PgTyped_Pg_Client_t, _2:query3Params) => Promise<(undefined | query3Result)>;
/** Returns an array of all matched results. */
many: (_1:PgTyped_Pg_Client_t, _2:booksByAuthorParams) => Promise<booksByAuthorResult[]>;
many: (_1:PgTyped_Pg_Client_t, _2:query3Params) => Promise<query3Result[]>;
/** Executes the query, but ignores whatever is returned by it. */
execute: (_1:PgTyped_Pg_Client_t, _2:booksByAuthorParams) => Promise<void>
} = BookService__sqlJS.BooksByAuthor as any;
execute: (_1:PgTyped_Pg_Client_t, _2:query3Params) => Promise<void>
} = BookService__sqlJS.Query3 as any;
Loading

0 comments on commit 1b6dd26

Please sign in to comment.