@aventusjs/cli 0.0.14 → 0.0.15

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.
@@ -0,0 +1,58 @@
1
+ // Avonis:1.0.0
2
+ //#region js def //
3
+ declare global {
4
+
5
+ namespace Avonis{
6
+ function extractFieldsError(error: Aventus.GenericError): {
7
+ fieldName: string;
8
+ messages: string[];
9
+ }[];
10
+
11
+ abstract class AventusResource {
12
+ static get Fullname(): string;
13
+ }
14
+
15
+ abstract class AventusModelResource<T extends Aventus.IData> extends Avonis.AventusResource {
16
+ }
17
+
18
+ class AventusRequest {
19
+ }
20
+
21
+ abstract class ModelController<T extends Aventus.IData, U extends Avonis.AventusRequest = any, R extends Avonis.AventusResource = any, S extends R = R> extends Aventus.HttpRoute {
22
+
23
+ abstract getUri(): string;
24
+ abstract getRequest(): new () => U;
25
+ abstract getResource(): new () => R;
26
+ getResourceDetails(): (new () => S) | undefined;
27
+ protected normalizeUri(uri: string): any;
28
+ @BindThis()
29
+ index(): Promise<Aventus.ResultWithError<R[]>>;
30
+ @BindThis()
31
+ store(body: U): Promise<Aventus.ResultWithError<S>>;
32
+ @BindThis()
33
+ show(id: string | number): Promise<Aventus.ResultWithError<S>>;
34
+ @BindThis()
35
+ update(id: string | number, body: U): Promise<Aventus.ResultWithError<S>>;
36
+ @BindThis()
37
+ destroy(id: string | number): Promise<Aventus.ResultWithError<boolean>>;
38
+ toRequest(resource: R | S): U;
39
+ }
40
+
41
+ }
42
+ }
43
+ //#endregion js def //
44
+ //#region js src //
45
+ {"namespace":"Avonis","available":[{"code":"let extractFieldsError=function extractFieldsError(error) {\n const result = [];\n if (Array.isArray(error.details)) {\n for (let detail of error.details) {\n if (Object.hasOwn(detail, \"field\")) {\n result.push({\n fieldName: detail.field,\n messages: [detail.message]\n });\n }\n }\n }\n return result;\n}\n__as1(_, 'extractFieldsError', extractFieldsError);\r\n","dependencies":[{"fullName":"Aventus.GenericError","isStrong":false}],"fullName":"Avonis.extractFieldsError","required":false,"type":4,"isExported":true,"convertibleName":""},{"code":"let AventusResource=class AventusResource {\n static get Fullname() { return \"Avonis.AventusResource\"; }\n}\nAventusResource.Namespace=`Avonis`;\r\n__as1(_, 'AventusResource', AventusResource);\r\n","dependencies":[],"fullName":"Avonis.AventusResource","required":false,"type":1,"isExported":true,"convertibleName":""},{"code":"let AventusModelResource=class AventusModelResource extends AventusResource {\n}\nAventusModelResource.Namespace=`Avonis`;\r\n__as1(_, 'AventusModelResource', AventusModelResource);\r\n","dependencies":[{"fullName":"Avonis.AventusResource","isStrong":true},{"fullName":"Aventus.IData","isStrong":false}],"fullName":"Avonis.AventusModelResource","required":false,"type":1,"isExported":true,"convertibleName":""},{"code":"let AventusRequest=class AventusRequest {\n}\nAventusRequest.Namespace=`Avonis`;\r\n__as1(_, 'AventusRequest', AventusRequest);\r\n","dependencies":[],"fullName":"Avonis.AventusRequest","required":false,"type":1,"isExported":true,"convertibleName":""},{"code":"let ModelController=class ModelController extends Aventus.HttpRoute {\n constructor(router) {\n super(router);\n this.index = this.index.bind(this);\n this.store = this.store.bind(this);\n this.show = this.show.bind(this);\n this.update = this.update.bind(this);\n this.destroy = this.destroy.bind(this);\n }\n getResourceDetails() {\n return undefined;\n }\n normalizeUri(uri) {\n return uri.replace(/\\/\\/+/g, \"/\");\n }\n async index() {\n const uri = this.normalizeUri(`${this.getPrefix()}/${this.getUri()}`);\n const request = new Aventus.HttpRequest(uri, Aventus.HttpMethod.GET);\n return await request.queryJSON(this.router);\n }\n async store(body) {\n const uri = this.normalizeUri(`${this.getPrefix()}/${this.getUri()}`);\n const request = new Aventus.HttpRequest(uri, Aventus.HttpMethod.POST);\n request.setBody(body);\n return await request.queryJSON(this.router);\n }\n // @BindThis()\n // public async storeMany(body: U[]): Promise<Aventus.ResultWithError<S[]>> {\n // const requestBody = new ItemsManyRequest<T>();\n // const request = new Aventus.HttpRequest(`${this.getPrefix()}/${this.getUri()}/many`, Aventus.HttpMethod.POST);\n // request.setBody(requestBody);\n // return await request.queryJSON<S[]>(this.router);\n async show(id) {\n const uri = this.normalizeUri(`${this.getPrefix()}/${this.getUri()}/${id}`);\n const request = new Aventus.HttpRequest(uri, Aventus.HttpMethod.GET);\n return await request.queryJSON(this.router);\n }\n // @BindThis()\n // public async showMany(ids: (string | number)[]): Promise<Aventus.ResultWithError<S[]>> {\n // const requestBody = new IdsManyRequest();\n // const request = new Aventus.HttpRequest(`${this.getPrefix()}/${this.getUri()}/show_many`, Aventus.HttpMethod.POST);\n // request.setBody(requestBody);\n // return await request.queryJSON<S[]>(this.router);\n async update(id, body) {\n const uri = this.normalizeUri(`${this.getPrefix()}/${this.getUri()}/${id}`);\n const request = new Aventus.HttpRequest(uri, Aventus.HttpMethod.PUT);\n request.enableMethodSpoofing();\n request.setBody(body);\n return await request.queryJSON(this.router);\n }\n // @BindThis()\n // public async updateMany(body: U[]): Promise<Aventus.ResultWithError<S[]>> {\n // const requestBody = new ItemsManyRequest<T>();\n // const request = new Aventus.HttpRequest(`${this.getPrefix()}/${this.getUri()}/many`, Aventus.HttpMethod.PUT);\n // request.enableMethodSpoofing();\n // request.setBody(requestBody);\n // return await request.queryJSON<S[]>(this.router);\n async destroy(id) {\n const uri = this.normalizeUri(`${this.getPrefix()}/${this.getUri()}/${id}`);\n const request = new Aventus.HttpRequest(uri, Aventus.HttpMethod.DELETE);\n return await request.queryJSON(this.router);\n }\n // @BindThis()\n // public async destroyMany(ids: (string | number)[]): Promise<Aventus.ResultWithError<boolean>> {\n // const requestBody = new IdsManyRequest();\n // const request = new Aventus.HttpRequest(`${this.getPrefix()}/${this.getUri()}/many`, Aventus.HttpMethod.DELETE);\n // request.enableMethodSpoofing();\n // request.setBody(requestBody);\n // return await request.queryJSON<boolean>(this.router);\n toRequest(resource) {\n const Request = this.getRequest();\n const result = new Request();\n const resourceClone = Aventus.clone(resource);\n Aventus.Json.classFromJson(result, resourceClone, {\n replaceUndefined: true\n });\n return result;\n }\n}\nModelController.Namespace=`Avonis`;\r\n__as1(_, 'ModelController', ModelController);\r\n","dependencies":[{"fullName":"Aventus.HttpRoute","isStrong":true},{"fullName":"Aventus.IData","isStrong":false},{"fullName":"Avonis.AventusRequest","isStrong":false},{"fullName":"Avonis.AventusResource","isStrong":false},{"fullName":"BindThis","isStrong":false},{"fullName":"Promise","isStrong":false},{"fullName":"Aventus.ResultWithError","isStrong":false},{"fullName":"Aventus.HttpRequest","isStrong":false},{"fullName":"Aventus.HttpMethod","isStrong":false},{"fullName":"Aventus.clone","isStrong":false},{"fullName":"Aventus.Json","isStrong":false}],"fullName":"Avonis.ModelController","required":false,"type":1,"isExported":true,"convertibleName":""}],"existing":[]}
46
+ //#endregion js src //
47
+ //#region css def //
48
+ {}
49
+ //#endregion css def //
50
+ //#region css //
51
+ {}
52
+ //#endregion css //
53
+ //#region html //
54
+ {}
55
+ //#endregion html //
56
+ //#region dependencies //
57
+ {}
58
+ //#endregion dependencies //