generate frontend entities

This commit is contained in:
opbnq-q
2025-03-09 08:07:26 -07:00
parent 447cc06876
commit c1dde79c7e
10 changed files with 318 additions and 35 deletions

View File

@@ -20,7 +20,7 @@ export function Count(): Promise<number> & { cancel(): void } {
export function Create(item: $models.Author): Promise<$models.Author> & { cancel(): void } {
let $resultPromise = $Call.ByID(3684602449, item) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -34,7 +34,7 @@ export function Delete(id: number): Promise<void> & { cancel(): void } {
export function GetAll(): Promise<($models.Author | null)[]> & { cancel(): void } {
let $resultPromise = $Call.ByID(3248293926) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -43,7 +43,7 @@ export function GetAll(): Promise<($models.Author | null)[]> & { cancel(): void
export function GetById(id: number): Promise<$models.Author | null> & { cancel(): void } {
let $resultPromise = $Call.ByID(1703016211, id) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType1($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -52,7 +52,7 @@ export function GetById(id: number): Promise<$models.Author | null> & { cancel()
export function Update(item: $models.Author): Promise<$models.Author> & { cancel(): void } {
let $resultPromise = $Call.ByID(2240704960, item) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);

View File

@@ -20,7 +20,7 @@ export function Count(): Promise<number> & { cancel(): void } {
export function Create(item: $models.Comment): Promise<$models.Comment> & { cancel(): void } {
let $resultPromise = $Call.ByID(4239106089, item) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -34,7 +34,7 @@ export function Delete(id: number): Promise<void> & { cancel(): void } {
export function GetAll(): Promise<($models.Comment | null)[]> & { cancel(): void } {
let $resultPromise = $Call.ByID(1805763390) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -43,7 +43,7 @@ export function GetAll(): Promise<($models.Comment | null)[]> & { cancel(): void
export function GetById(id: number): Promise<$models.Comment | null> & { cancel(): void } {
let $resultPromise = $Call.ByID(3217823099, id) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType1($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -52,7 +52,7 @@ export function GetById(id: number): Promise<$models.Comment | null> & { cancel(
export function Update(item: $models.Comment): Promise<$models.Comment> & { cancel(): void } {
let $resultPromise = $Call.ByID(3080970936, item) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);

View File

@@ -20,7 +20,7 @@ export function Count(): Promise<number> & { cancel(): void } {
export function Create(item: $models.Post): Promise<$models.Post> & { cancel(): void } {
let $resultPromise = $Call.ByID(1443399856, item) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -39,7 +39,7 @@ export function ExportToExcel(): Promise<void> & { cancel(): void } {
export function GetAll(): Promise<($models.Post | null)[]> & { cancel(): void } {
let $resultPromise = $Call.ByID(65691059) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -48,7 +48,7 @@ export function GetAll(): Promise<($models.Post | null)[]> & { cancel(): void }
export function GetById(id: number): Promise<$models.Post | null> & { cancel(): void } {
let $resultPromise = $Call.ByID(4074736792, id) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType1($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -57,7 +57,7 @@ export function GetById(id: number): Promise<$models.Post | null> & { cancel():
export function Update(item: $models.Post): Promise<$models.Post> & { cancel(): void } {
let $resultPromise = $Call.ByID(137798821, item) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);

View File

@@ -20,7 +20,7 @@ export function Count(): Promise<number> & { cancel(): void } {
export function Create(item: $models.PostType): Promise<$models.PostType> & { cancel(): void } {
let $resultPromise = $Call.ByID(1092898136, item) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -34,7 +34,7 @@ export function Delete(id: number): Promise<void> & { cancel(): void } {
export function GetAll(): Promise<($models.PostType | null)[]> & { cancel(): void } {
let $resultPromise = $Call.ByID(416231387) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -43,7 +43,7 @@ export function GetAll(): Promise<($models.PostType | null)[]> & { cancel(): voi
export function GetById(id: number): Promise<$models.PostType | null> & { cancel(): void } {
let $resultPromise = $Call.ByID(3237123344, id) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType1($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
@@ -52,7 +52,7 @@ export function GetById(id: number): Promise<$models.PostType | null> & { cancel
export function Update(item: $models.PostType): Promise<$models.PostType> & { cancel(): void } {
let $resultPromise = $Call.ByID(2773888269, item) as any;
let $typingPromise = $resultPromise.then(($result) => {
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType0($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);

View File

@@ -1,31 +1,40 @@
<script setup lang="ts">
import Table from "../table/Table.vue";
import { onMounted, reactive, ref } from "vue";
import { onMounted, reactive } from "vue";
import { getDefaultValues } from "../utils/structs/defaults.util";
import Service from "./author.service.ts";
import type { Scheme } from "../types/scheme.type";
import { Author } from "../../bindings/app/internal/services";
import { ref } from "vue";
import type { Validate } from "../types/validate.type";
import PostService from "../post/post.service.ts";
import type { Validate } from "../types/validate.type.ts";
const postService = new PostService();
import CommentService from "../comment/comment.service.ts";
const commentService = new CommentService();
const service = new Service();
const items = ref<Author[]>([])
const items = ref<Author[]>([]);
async function load() {
const load = async () => {
(scheme as any).Posts.type!.nested!.values = await postService.readAll();
(scheme as any).Comments.type!.nested!.values =
await commentService.readAll();
items.value = await service.readAll();
return items.value;
}
};
onMounted(async () => {
load()
load();
});
const scheme: Scheme<Author> = reactive({
entityId: "AuthorId",
Id: {
hidden: true,
type: {
@@ -50,19 +59,30 @@ const scheme: Scheme<Author> = reactive({
},
},
},
Comments: {
russian: "Комментарии",
many: true,
type: {
nested: {
values: [],
field: ["Text"],
},
},
},
});
const getDefaults = () => getDefaultValues(scheme);
const validate: Validate<Author> = (data, mode): ReturnType<Validate<Author>> => {
const validate: Validate<Author> = (entity) => {
return {
status: 'success',
}
}
status: "success",
};
};
</script>
<template>
<main class="w-screen h-screen">
<Table :scheme :service :get-defaults :validate :items :load></Table>
<Table :scheme :service :get-defaults :load :items :validate></Table>
</main>
</template>

View File

@@ -0,0 +1,93 @@
<script setup lang="ts">
import Table from "../table/Table.vue";
import { onMounted, reactive } from "vue";
import { getDefaultValues } from "../utils/structs/defaults.util";
import Service from "./comment.service.ts";
import type { Scheme } from "../types/scheme.type";
import { Comment } from "../../bindings/app/internal/services";
import { ref } from "vue";
import type { Validate } from "../types/validate.type";
import AuthorService from "../author/author.service.ts";
const authorService = new AuthorService();
import PostService from "../post/post.service.ts";
const postService = new PostService();
const service = new Service();
const items = ref<Comment[]>([]);
const load = async () => {
(scheme as any).Author.type!.nested!.values = await authorService.readAll();
(scheme as any).Posts.type!.nested!.values = await postService.readAll();
items.value = await service.readAll();
return items.value;
};
onMounted(async () => {
load();
});
const scheme: Scheme<Comment> = reactive({
entityId: "CommentId",
Id: {
hidden: true,
type: {
primitive: "number",
},
},
Text: {
russian: "Текст",
type: {
primitive: "string",
},
},
AuthorId: {
hidden: true,
type: {
primitive: "number",
},
},
Author: {
russian: "Автор",
type: {
nested: {
values: [],
field: ["Name"],
},
},
},
Posts: {
russian: "Посты",
many: true,
type: {
nested: {
values: [],
field: ["Text"],
},
},
},
});
const getDefaults = () => getDefaultValues(scheme);
const validate: Validate<Comment> = (entity) => {
return {
status: "success",
};
};
</script>
<template>
<main class="w-screen h-screen">
<Table :scheme :service :get-defaults :load :items :validate></Table>
</main>
</template>

View File

@@ -0,0 +1,36 @@
import {
GetAll,
Create,
Delete,
GetById,
Update,
Count,
} from "../../bindings/app/internal/services/commentservice.ts";
import type { Comment } from "../../bindings/app/internal/services";
import type { IService } from "../types/service.type.ts";
export default class CommentService implements IService<Comment> {
async read(id: number) {
return (await GetById(id)) as Comment;
}
async readAll() {
return (await GetAll()) as Comment[];
}
async create(item: Comment) {
await Create(item);
}
async delete(id: number) {
return await Delete(id);
}
async update(item: Comment) {
await Update(item);
}
async count() {
return await Count();
}
}

View File

@@ -1,26 +1,41 @@
<script setup lang="ts">
import Table from "../table/Table.vue";
import { onMounted, reactive, ref } from "vue";
import { onMounted, reactive } from "vue";
import { getDefaultValues } from "../utils/structs/defaults.util";
import Service from "./post.service.ts";
import type { Scheme } from "../types/scheme.type";
import { Post } from "../../bindings/app/internal/services";
import { ref } from "vue";
import type { Validate } from "../types/validate.type";
import AuthorService from "../author/author.service.ts";
import type { Validate } from "../types/validate.type.ts";
const authorService = new AuthorService();
import PosttypeService from "../posttype/posttype.service.ts";
const posttypeService = new PosttypeService();
import CommentService from "../comment/comment.service.ts";
const commentService = new CommentService();
const service = new Service();
const items = ref<Post[]>([]);
const load = async () => {
(scheme as any).Author.type!.nested!.values = await authorService.readAll();
(scheme as any).PostType.type!.nested!.values =
await posttypeService.readAll();
(scheme as any).Comments.type!.nested!.values =
await commentService.readAll();
items.value = await service.readAll();
return items.value;
};
const items = ref<Post[]>([]);
onMounted(async () => {
load()
load();
});
const scheme: Scheme<Post> = reactive({
@@ -72,19 +87,47 @@ const scheme: Scheme<Post> = reactive({
},
},
},
PostTypeId: {
hidden: true,
type: {
primitive: "number",
},
},
PostType: {
russian: "Тип",
type: {
nested: {
values: [],
field: ["Name"],
},
},
},
Comments: {
russian: "Комментарии",
many: true,
type: {
nested: {
values: [],
field: ["Text"],
},
},
},
});
const getDefaults = () => getDefaultValues(scheme);
const validate: Validate<Post> = (entity) => {
return {
status: 'success'
}
status: "success",
};
};
</script>
<template>
<main class="w-screen h-screen">
<Table :scheme :service :get-defaults :validate :load :items></Table>
<Table :scheme :service :get-defaults :load :items :validate></Table>
</main>
</template>

View File

@@ -0,0 +1,55 @@
<script setup lang="ts">
import Table from "../table/Table.vue";
import { onMounted, reactive } from "vue";
import { getDefaultValues } from "../utils/structs/defaults.util";
import Service from "./posttype.service.ts";
import type { Scheme } from "../types/scheme.type";
import { PostType } from "../../bindings/app/internal/services";
import { ref } from "vue";
import type { Validate } from "../types/validate.type";
const service = new Service();
const items = ref<PostType[]>([]);
const load = async () => {
items.value = await service.readAll();
return items.value;
};
onMounted(async () => {
load();
});
const scheme: Scheme<PostType> = reactive({
entityId: "PostTypeId",
Id: {
hidden: true,
type: {
primitive: "number",
},
},
Name: {
russian: "Название",
type: {
primitive: "string",
},
},
});
const getDefaults = () => getDefaultValues(scheme);
const validate: Validate<PostType> = (entity) => {
return {
status: "success",
};
};
</script>
<template>
<main class="w-screen h-screen">
<Table :scheme :service :get-defaults :load :items :validate></Table>
</main>
</template>

View File

@@ -0,0 +1,36 @@
import {
GetAll,
Create,
Delete,
GetById,
Update,
Count,
} from "../../bindings/app/internal/services/posttypeservice.ts";
import type { PostType } from "../../bindings/app/internal/services";
import type { IService } from "../types/service.type.ts";
export default class PostTypeService implements IService<PostType> {
async read(id: number) {
return (await GetById(id)) as PostType;
}
async readAll() {
return (await GetAll()) as PostType[];
}
async create(item: PostType) {
await Create(item);
}
async delete(id: number) {
return await Delete(id);
}
async update(item: PostType) {
await Update(item);
}
async count() {
return await Count();
}
}