namirasoft-field-node 1.4.0 → 1.4.2
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/package.json +28 -28
- package/src/NSFApplication.ts +42 -42
- package/src/controller/BaseEntityFieldController.ts +22 -22
- package/src/controller/BaseEntityFieldControllerProps.ts +4 -4
- package/src/controller/BaseEntityFieldControllerState.ts +4 -4
- package/src/controller/NSFListController.ts +39 -39
- package/src/controller/entity_category/Create.ts +52 -52
- package/src/controller/entity_category/Delete.ts +49 -49
- package/src/controller/entity_category/Get.ts +51 -51
- package/src/controller/entity_category/List.ts +58 -58
- package/src/controller/entity_field/Create.ts +53 -53
- package/src/controller/entity_field/Delete.ts +49 -49
- package/src/controller/entity_field/Get.ts +51 -51
- package/src/controller/entity_field/List.ts +58 -58
- package/src/controller/entity_field/Update.ts +55 -55
- package/src/controller/entity_tag/Create.ts +53 -53
- package/src/controller/entity_tag/Delete.ts +49 -49
- package/src/controller/entity_tag/Get.ts +51 -51
- package/src/controller/entity_tag/List.ts +58 -58
- package/src/controller/entity_tag/Update.ts +55 -55
- package/src/database/FieldDatabaseTables.ts +45 -45
- package/src/database/attributes/EntityCategoryAttributes.ts +11 -11
- package/src/database/attributes/EntityFieldAttributes.ts +13 -13
- package/src/database/attributes/EntityTagAttributes.ts +13 -13
- package/src/database/model/EntityCategoryModel.ts +8 -8
- package/src/database/model/EntityFieldModel.ts +10 -10
- package/src/database/model/EntityTagModel.ts +10 -10
- package/src/database/table/EntityCategoryTable.ts +60 -60
- package/src/database/table/EntityFieldTable.ts +65 -65
- package/src/database/table/EntityTagTable.ts +65 -65
- package/src/enum/EntityCategoryNames.ts +3 -3
- package/src/enum/EntityFieldNames.ts +3 -3
- package/src/enum/EntityTagNames.ts +3 -3
- package/src/index.ts +2 -2
- package/dist/controller/entity_category/Update.d.ts +0 -22
- package/dist/controller/entity_category/Update.js +0 -68
- package/dist/controller/entity_category/Update.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "namirasoft-field-node",
|
|
3
|
-
"title": "Namirasoft Field Node NPM Package",
|
|
4
|
-
"description": "Namira Software Corporation Field Node NPM Package",
|
|
5
|
-
"icon": "logo.png",
|
|
6
|
-
"logo": "https://static.namirasoft.com/image/namirasoft/field/logo/base.png",
|
|
7
|
-
"language": "ts",
|
|
8
|
-
"framework": "npm",
|
|
9
|
-
"application": "package",
|
|
10
|
-
"private": false,
|
|
11
|
-
"version": "1.4.
|
|
12
|
-
"author": "Amir Abolhasani",
|
|
13
|
-
"license": "MIT",
|
|
14
|
-
"main": "./dist/index.js",
|
|
15
|
-
"types": "./dist/index.d.ts",
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": ""
|
|
18
|
-
},
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"namirasoft-access": "^1.4.
|
|
21
|
-
"namirasoft-account-node": "^1.4.
|
|
22
|
-
"namirasoft-core": "^1.4.
|
|
23
|
-
"namirasoft-node": "^1.4.16",
|
|
24
|
-
"namirasoft-node-mysql": "^1.4.
|
|
25
|
-
},
|
|
26
|
-
"bin": {
|
|
27
|
-
"ns-field": "./dist/command/cli.js"
|
|
28
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "namirasoft-field-node",
|
|
3
|
+
"title": "Namirasoft Field Node NPM Package",
|
|
4
|
+
"description": "Namira Software Corporation Field Node NPM Package",
|
|
5
|
+
"icon": "logo.png",
|
|
6
|
+
"logo": "https://static.namirasoft.com/image/namirasoft/field/logo/base.png",
|
|
7
|
+
"language": "ts",
|
|
8
|
+
"framework": "npm",
|
|
9
|
+
"application": "package",
|
|
10
|
+
"private": false,
|
|
11
|
+
"version": "1.4.2",
|
|
12
|
+
"author": "Amir Abolhasani",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": ""
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"namirasoft-access": "^1.4.24",
|
|
21
|
+
"namirasoft-account-node": "^1.4.39",
|
|
22
|
+
"namirasoft-core": "^1.4.15",
|
|
23
|
+
"namirasoft-node": "^1.4.16",
|
|
24
|
+
"namirasoft-node-mysql": "^1.4.7"
|
|
25
|
+
},
|
|
26
|
+
"bin": {
|
|
27
|
+
"ns-field": "./dist/command/cli.js"
|
|
28
|
+
}
|
|
29
29
|
}
|
package/src/NSFApplication.ts
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
|
-
import { NSABaseApplication } from 'namirasoft-account-node';
|
|
3
|
-
import { BaseMySqlDatabase } from 'namirasoft-node-mysql';
|
|
4
|
-
import { FieldDatabaseTables } from './database/FieldDatabaseTables';
|
|
5
|
-
import { Create as EntityCategoryCreate } from './controller/entity_category/Create';
|
|
6
|
-
import { Delete as EntityCategoryDelete } from './controller/entity_category/Delete';
|
|
7
|
-
import { Get as EntityCategoryGet } from './controller/entity_category/Get';
|
|
8
|
-
import { List as EntityCategoryList } from './controller/entity_category/List';
|
|
9
|
-
import { Create as EntityFieldCreate } from './controller/entity_field/Create';
|
|
10
|
-
import { Delete as EntityFieldDelete } from './controller/entity_field/Delete';
|
|
11
|
-
import { Get as EntityFieldGet } from './controller/entity_field/Get';
|
|
12
|
-
import { List as EntityFieldList } from './controller/entity_field/List';
|
|
13
|
-
import { Update as EntityFieldUpdate } from './controller/entity_field/Update';
|
|
14
|
-
import { Create as EntityTagCreate } from './controller/entity_tag/Create';
|
|
15
|
-
import { Delete as EntityTagDelete } from './controller/entity_tag/Delete';
|
|
16
|
-
import { Get as EntityTagGet } from './controller/entity_tag/Get';
|
|
17
|
-
import { List as EntityTagList } from './controller/entity_tag/List';
|
|
18
|
-
import { Update as EntityTagUpdate } from './controller/entity_tag/Update';
|
|
19
|
-
|
|
20
|
-
export class NSFApplication
|
|
21
|
-
{
|
|
22
|
-
static getControllers(tables: FieldDatabaseTables<BaseMySqlDatabase>): ((app: NSABaseApplication<BaseMySqlDatabase>, req: express.Request, res: express.Response) => any)[]
|
|
23
|
-
{
|
|
24
|
-
return [
|
|
25
|
-
(app, req, res) => new EntityCategoryList(app, req, res, tables),
|
|
26
|
-
(app, req, res) => new EntityCategoryGet(app, req, res, tables),
|
|
27
|
-
(app, req, res) => new EntityCategoryCreate(app, req, res, tables),
|
|
28
|
-
(app, req, res) => new EntityCategoryDelete(app, req, res, tables),
|
|
29
|
-
|
|
30
|
-
(app, req, res) => new EntityFieldList(app, req, res, tables),
|
|
31
|
-
(app, req, res) => new EntityFieldGet(app, req, res, tables),
|
|
32
|
-
(app, req, res) => new EntityFieldCreate(app, req, res, tables),
|
|
33
|
-
(app, req, res) => new EntityFieldUpdate(app, req, res, tables),
|
|
34
|
-
(app, req, res) => new EntityFieldDelete(app, req, res, tables),
|
|
35
|
-
|
|
36
|
-
(app, req, res) => new EntityTagList(app, req, res, tables),
|
|
37
|
-
(app, req, res) => new EntityTagGet(app, req, res, tables),
|
|
38
|
-
(app, req, res) => new EntityTagCreate(app, req, res, tables),
|
|
39
|
-
(app, req, res) => new EntityTagUpdate(app, req, res, tables),
|
|
40
|
-
(app, req, res) => new EntityTagDelete(app, req, res, tables),
|
|
41
|
-
];
|
|
42
|
-
}
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { NSABaseApplication } from 'namirasoft-account-node';
|
|
3
|
+
import { BaseMySqlDatabase } from 'namirasoft-node-mysql';
|
|
4
|
+
import { FieldDatabaseTables } from './database/FieldDatabaseTables';
|
|
5
|
+
import { Create as EntityCategoryCreate } from './controller/entity_category/Create';
|
|
6
|
+
import { Delete as EntityCategoryDelete } from './controller/entity_category/Delete';
|
|
7
|
+
import { Get as EntityCategoryGet } from './controller/entity_category/Get';
|
|
8
|
+
import { List as EntityCategoryList } from './controller/entity_category/List';
|
|
9
|
+
import { Create as EntityFieldCreate } from './controller/entity_field/Create';
|
|
10
|
+
import { Delete as EntityFieldDelete } from './controller/entity_field/Delete';
|
|
11
|
+
import { Get as EntityFieldGet } from './controller/entity_field/Get';
|
|
12
|
+
import { List as EntityFieldList } from './controller/entity_field/List';
|
|
13
|
+
import { Update as EntityFieldUpdate } from './controller/entity_field/Update';
|
|
14
|
+
import { Create as EntityTagCreate } from './controller/entity_tag/Create';
|
|
15
|
+
import { Delete as EntityTagDelete } from './controller/entity_tag/Delete';
|
|
16
|
+
import { Get as EntityTagGet } from './controller/entity_tag/Get';
|
|
17
|
+
import { List as EntityTagList } from './controller/entity_tag/List';
|
|
18
|
+
import { Update as EntityTagUpdate } from './controller/entity_tag/Update';
|
|
19
|
+
|
|
20
|
+
export class NSFApplication
|
|
21
|
+
{
|
|
22
|
+
static getControllers(tables: FieldDatabaseTables<BaseMySqlDatabase>): ((app: NSABaseApplication<BaseMySqlDatabase>, req: express.Request, res: express.Response) => any)[]
|
|
23
|
+
{
|
|
24
|
+
return [
|
|
25
|
+
(app, req, res) => new EntityCategoryList(app, req, res, tables),
|
|
26
|
+
(app, req, res) => new EntityCategoryGet(app, req, res, tables),
|
|
27
|
+
(app, req, res) => new EntityCategoryCreate(app, req, res, tables),
|
|
28
|
+
(app, req, res) => new EntityCategoryDelete(app, req, res, tables),
|
|
29
|
+
|
|
30
|
+
(app, req, res) => new EntityFieldList(app, req, res, tables),
|
|
31
|
+
(app, req, res) => new EntityFieldGet(app, req, res, tables),
|
|
32
|
+
(app, req, res) => new EntityFieldCreate(app, req, res, tables),
|
|
33
|
+
(app, req, res) => new EntityFieldUpdate(app, req, res, tables),
|
|
34
|
+
(app, req, res) => new EntityFieldDelete(app, req, res, tables),
|
|
35
|
+
|
|
36
|
+
(app, req, res) => new EntityTagList(app, req, res, tables),
|
|
37
|
+
(app, req, res) => new EntityTagGet(app, req, res, tables),
|
|
38
|
+
(app, req, res) => new EntityTagCreate(app, req, res, tables),
|
|
39
|
+
(app, req, res) => new EntityTagUpdate(app, req, res, tables),
|
|
40
|
+
(app, req, res) => new EntityTagDelete(app, req, res, tables),
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
43
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { NSABaseApplication, NSABaseController } from "namirasoft-account-node";
|
|
2
|
-
import { BaseEntityFieldControllerState } from "./BaseEntityFieldControllerState";
|
|
3
|
-
import { BaseEntityFieldControllerProps } from "./BaseEntityFieldControllerProps";
|
|
4
|
-
import { BaseMySqlDatabase } from "namirasoft-node-mysql";
|
|
5
|
-
import express from "express";
|
|
6
|
-
import { FieldDatabaseTables } from "../database/FieldDatabaseTables";
|
|
7
|
-
import { NamingConvention } from "namirasoft-core";
|
|
8
|
-
|
|
9
|
-
export abstract class BaseEntityFieldController<Output> extends NSABaseController<BaseMySqlDatabase, BaseEntityFieldControllerState, BaseEntityFieldControllerProps, Output>
|
|
10
|
-
{
|
|
11
|
-
protected tables: FieldDatabaseTables<BaseMySqlDatabase>;
|
|
12
|
-
protected tagPrefix: string;
|
|
13
|
-
protected pathPrefix: string;
|
|
14
|
-
protected namePrefix: string;
|
|
15
|
-
constructor(app: NSABaseApplication<BaseMySqlDatabase>, req: express.Request, res: express.Response, tables: FieldDatabaseTables<BaseMySqlDatabase>)
|
|
16
|
-
{
|
|
17
|
-
super(app, req, res)
|
|
18
|
-
this.tables = tables;
|
|
19
|
-
this.tagPrefix = NamingConvention.lower_case_underscore.convert(this.tables.name, NamingConvention.Pascal_Case);
|
|
20
|
-
this.pathPrefix = this.tables.name.replace(/_/gm, "/");
|
|
21
|
-
this.namePrefix = this.tables.name.replace(/_/gm, " ");
|
|
22
|
-
}
|
|
1
|
+
import { NSABaseApplication, NSABaseController } from "namirasoft-account-node";
|
|
2
|
+
import { BaseEntityFieldControllerState } from "./BaseEntityFieldControllerState";
|
|
3
|
+
import { BaseEntityFieldControllerProps } from "./BaseEntityFieldControllerProps";
|
|
4
|
+
import { BaseMySqlDatabase } from "namirasoft-node-mysql";
|
|
5
|
+
import express from "express";
|
|
6
|
+
import { FieldDatabaseTables } from "../database/FieldDatabaseTables";
|
|
7
|
+
import { NamingConvention } from "namirasoft-core";
|
|
8
|
+
|
|
9
|
+
export abstract class BaseEntityFieldController<Output> extends NSABaseController<BaseMySqlDatabase, BaseEntityFieldControllerState, BaseEntityFieldControllerProps, Output>
|
|
10
|
+
{
|
|
11
|
+
protected tables: FieldDatabaseTables<BaseMySqlDatabase>;
|
|
12
|
+
protected tagPrefix: string;
|
|
13
|
+
protected pathPrefix: string;
|
|
14
|
+
protected namePrefix: string;
|
|
15
|
+
constructor(app: NSABaseApplication<BaseMySqlDatabase>, req: express.Request, res: express.Response, tables: FieldDatabaseTables<BaseMySqlDatabase>)
|
|
16
|
+
{
|
|
17
|
+
super(app, req, res)
|
|
18
|
+
this.tables = tables;
|
|
19
|
+
this.tagPrefix = NamingConvention.lower_case_underscore.convert(this.tables.name, NamingConvention.Pascal_Case);
|
|
20
|
+
this.pathPrefix = this.tables.name.replace(/_/gm, "/");
|
|
21
|
+
this.namePrefix = this.tables.name.replace(/_/gm, " ");
|
|
22
|
+
}
|
|
23
23
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NSABaseControllerProps } from "namirasoft-account-node";
|
|
2
|
-
|
|
3
|
-
export interface BaseEntityFieldControllerProps extends NSABaseControllerProps
|
|
4
|
-
{
|
|
1
|
+
import { NSABaseControllerProps } from "namirasoft-account-node";
|
|
2
|
+
|
|
3
|
+
export interface BaseEntityFieldControllerProps extends NSABaseControllerProps
|
|
4
|
+
{
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NSABaseControllerState } from "namirasoft-account-node";
|
|
2
|
-
|
|
3
|
-
export interface BaseEntityFieldControllerState extends NSABaseControllerState
|
|
4
|
-
{
|
|
1
|
+
import { NSABaseControllerState } from "namirasoft-account-node";
|
|
2
|
+
|
|
3
|
+
export interface BaseEntityFieldControllerState extends NSABaseControllerState
|
|
4
|
+
{
|
|
5
5
|
}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { Op } from "sequelize";
|
|
2
|
-
import { Includeable, WhereOptions } from "sequelize";
|
|
3
|
-
import { FieldDatabaseTables } from "../database/FieldDatabaseTables";
|
|
4
|
-
import { BaseMySqlDatabase } from "namirasoft-node-mysql";
|
|
5
|
-
|
|
6
|
-
export class NSFListController
|
|
7
|
-
{
|
|
8
|
-
static handle_getTables(name: string, tables: { [table: string]: string[]; }): { [table: string]: string[]; }
|
|
9
|
-
{
|
|
10
|
-
let ans = { ...tables };
|
|
11
|
-
ans[name] = [];
|
|
12
|
-
ans[`${name}_category`] = [`${name}.id`, `${name}_category.entity_id`];
|
|
13
|
-
ans[`${name}_field`] = [`${name}.id`, `${name}_field.entity_id`];
|
|
14
|
-
ans[`${name}_tag`] = [`${name}.id`, `${name}_tag.entity_id`];
|
|
15
|
-
return ans;
|
|
16
|
-
}
|
|
17
|
-
static handle_getIncludes<D extends BaseMySqlDatabase>(name: string, includes: Includeable[], conditions: { [table: string]: WhereOptions[]; }, tables: FieldDatabaseTables<D>): Includeable[]
|
|
18
|
-
{
|
|
19
|
-
let ans = [...includes];
|
|
20
|
-
if (conditions[`${name}_category`].length > 0)
|
|
21
|
-
ans.push({
|
|
22
|
-
model: tables.entity_category.model,
|
|
23
|
-
attributes: [],
|
|
24
|
-
where: { [Op.and]: conditions[`${name}_category`] }
|
|
25
|
-
});
|
|
26
|
-
if (conditions[`${name}_field`].length > 0)
|
|
27
|
-
ans.push({
|
|
28
|
-
model: tables.entity_field.model,
|
|
29
|
-
attributes: [],
|
|
30
|
-
where: { [Op.and]: conditions[`${name}_field`] }
|
|
31
|
-
});
|
|
32
|
-
if (conditions[`${name}_tag`].length > 0)
|
|
33
|
-
ans.push({
|
|
34
|
-
model: tables.entity_tag.model,
|
|
35
|
-
attributes: [],
|
|
36
|
-
where: { [Op.and]: conditions[`${name}_tag`] }
|
|
37
|
-
});
|
|
38
|
-
return ans;
|
|
39
|
-
}
|
|
1
|
+
import { Op } from "sequelize";
|
|
2
|
+
import { Includeable, WhereOptions } from "sequelize";
|
|
3
|
+
import { FieldDatabaseTables } from "../database/FieldDatabaseTables";
|
|
4
|
+
import { BaseMySqlDatabase } from "namirasoft-node-mysql";
|
|
5
|
+
|
|
6
|
+
export class NSFListController
|
|
7
|
+
{
|
|
8
|
+
static handle_getTables(name: string, tables: { [table: string]: string[]; }): { [table: string]: string[]; }
|
|
9
|
+
{
|
|
10
|
+
let ans = { ...tables };
|
|
11
|
+
ans[name] = [];
|
|
12
|
+
ans[`${name}_category`] = [`${name}.id`, `${name}_category.entity_id`];
|
|
13
|
+
ans[`${name}_field`] = [`${name}.id`, `${name}_field.entity_id`];
|
|
14
|
+
ans[`${name}_tag`] = [`${name}.id`, `${name}_tag.entity_id`];
|
|
15
|
+
return ans;
|
|
16
|
+
}
|
|
17
|
+
static handle_getIncludes<D extends BaseMySqlDatabase>(name: string, includes: Includeable[], conditions: { [table: string]: WhereOptions[]; }, tables: FieldDatabaseTables<D>): Includeable[]
|
|
18
|
+
{
|
|
19
|
+
let ans = [...includes];
|
|
20
|
+
if (conditions[`${name}_category`].length > 0)
|
|
21
|
+
ans.push({
|
|
22
|
+
model: tables.entity_category.model,
|
|
23
|
+
attributes: [],
|
|
24
|
+
where: { [Op.and]: conditions[`${name}_category`] }
|
|
25
|
+
});
|
|
26
|
+
if (conditions[`${name}_field`].length > 0)
|
|
27
|
+
ans.push({
|
|
28
|
+
model: tables.entity_field.model,
|
|
29
|
+
attributes: [],
|
|
30
|
+
where: { [Op.and]: conditions[`${name}_field`] }
|
|
31
|
+
});
|
|
32
|
+
if (conditions[`${name}_tag`].length > 0)
|
|
33
|
+
ans.push({
|
|
34
|
+
model: tables.entity_tag.model,
|
|
35
|
+
attributes: [],
|
|
36
|
+
where: { [Op.and]: conditions[`${name}_tag`] }
|
|
37
|
+
});
|
|
38
|
+
return ans;
|
|
39
|
+
}
|
|
40
40
|
}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { HTTPMethod, ObjectService } from "namirasoft-core";
|
|
2
|
-
import { EntityCategoryModel } from "../../database/model/EntityCategoryModel";
|
|
3
|
-
import { BaseEntityFieldController } from "../BaseEntityFieldController";
|
|
4
|
-
import { EntityCategoryNames } from "../../enum/EntityCategoryNames";
|
|
5
|
-
|
|
6
|
-
export class Create extends BaseEntityFieldController<EntityCategoryModel>
|
|
7
|
-
{
|
|
8
|
-
override getInfo()
|
|
9
|
-
{
|
|
10
|
-
return {
|
|
11
|
-
name: "Create",
|
|
12
|
-
tag: this.tagPrefix + "Category",
|
|
13
|
-
method: HTTPMethod.POST,
|
|
14
|
-
path: this.pathPrefix + "/category",
|
|
15
|
-
summary: `Creates a new ${this.namePrefix} category`
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
override async getParametersSchema()
|
|
19
|
-
{
|
|
20
|
-
return [];
|
|
21
|
-
}
|
|
22
|
-
override async getQueriesSchema()
|
|
23
|
-
{
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
override async getBodySchema()
|
|
27
|
-
{
|
|
28
|
-
return this.tables.entity_category.getSchemaByName(true, EntityCategoryNames.EntityCategoryInput);
|
|
29
|
-
}
|
|
30
|
-
override async getOutputSchema()
|
|
31
|
-
{
|
|
32
|
-
return this.tables.entity_category.getSchemaByName(true);
|
|
33
|
-
}
|
|
34
|
-
override async getState()
|
|
35
|
-
{
|
|
36
|
-
return {
|
|
37
|
-
check_auth: true,
|
|
38
|
-
auth_optional: false
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
override getID()
|
|
42
|
-
{
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
override async handle()
|
|
46
|
-
{
|
|
47
|
-
let entity_id = new ObjectService(this.req.body.entity_id).getString();
|
|
48
|
-
let category_id = new ObjectService(this.req.body.category_id).getString();
|
|
49
|
-
|
|
50
|
-
let ans = await this.tables.entity_category.create(this.props.access, this.props.session, this.props.access.owner_id, entity_id, category_id, null);
|
|
51
|
-
return await this.tables.entity_category.secure(ans);
|
|
52
|
-
}
|
|
1
|
+
import { HTTPMethod, ObjectService } from "namirasoft-core";
|
|
2
|
+
import { EntityCategoryModel } from "../../database/model/EntityCategoryModel";
|
|
3
|
+
import { BaseEntityFieldController } from "../BaseEntityFieldController";
|
|
4
|
+
import { EntityCategoryNames } from "../../enum/EntityCategoryNames";
|
|
5
|
+
|
|
6
|
+
export class Create extends BaseEntityFieldController<EntityCategoryModel>
|
|
7
|
+
{
|
|
8
|
+
override getInfo()
|
|
9
|
+
{
|
|
10
|
+
return {
|
|
11
|
+
name: "Create",
|
|
12
|
+
tag: this.tagPrefix + "Category",
|
|
13
|
+
method: HTTPMethod.POST,
|
|
14
|
+
path: this.pathPrefix + "/category",
|
|
15
|
+
summary: `Creates a new ${this.namePrefix} category`
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
override async getParametersSchema()
|
|
19
|
+
{
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
override async getQueriesSchema()
|
|
23
|
+
{
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
override async getBodySchema()
|
|
27
|
+
{
|
|
28
|
+
return this.tables.entity_category.getSchemaByName(true, EntityCategoryNames.EntityCategoryInput);
|
|
29
|
+
}
|
|
30
|
+
override async getOutputSchema()
|
|
31
|
+
{
|
|
32
|
+
return this.tables.entity_category.getSchemaByName(true);
|
|
33
|
+
}
|
|
34
|
+
override async getState()
|
|
35
|
+
{
|
|
36
|
+
return {
|
|
37
|
+
check_auth: true,
|
|
38
|
+
auth_optional: false
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
override getID()
|
|
42
|
+
{
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
override async handle()
|
|
46
|
+
{
|
|
47
|
+
let entity_id = new ObjectService(this.req.body.entity_id).getString();
|
|
48
|
+
let category_id = new ObjectService(this.req.body.category_id).getString();
|
|
49
|
+
|
|
50
|
+
let ans = await this.tables.entity_category.create(this.props.access, this.props.session, this.props.access.owner_id, entity_id, category_id, null);
|
|
51
|
+
return await this.tables.entity_category.secure(ans);
|
|
52
|
+
}
|
|
53
53
|
}
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { HTTPMethod, ObjectService } from "namirasoft-core";
|
|
2
|
-
import { BaseEntityFieldController } from "../BaseEntityFieldController";
|
|
3
|
-
import { StringSchema, BaseVariableSchema } from "namirasoft-schema";
|
|
4
|
-
|
|
5
|
-
export class Delete extends BaseEntityFieldController<void>
|
|
6
|
-
{
|
|
7
|
-
override getInfo()
|
|
8
|
-
{
|
|
9
|
-
return {
|
|
10
|
-
name: "Delete",
|
|
11
|
-
tag: this.tagPrefix + "Category",
|
|
12
|
-
method: HTTPMethod.DELETE,
|
|
13
|
-
path: this.pathPrefix + "/category/{id}",
|
|
14
|
-
summary: `Deletes a ${this.namePrefix} category by an id.`
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
override async getParametersSchema()
|
|
18
|
-
{
|
|
19
|
-
return [new BaseVariableSchema("id", new StringSchema(true))];
|
|
20
|
-
}
|
|
21
|
-
override async getQueriesSchema()
|
|
22
|
-
{
|
|
23
|
-
return [];
|
|
24
|
-
}
|
|
25
|
-
override async getBodySchema()
|
|
26
|
-
{
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
override async getOutputSchema()
|
|
30
|
-
{
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
override async getState()
|
|
34
|
-
{
|
|
35
|
-
return {
|
|
36
|
-
check_auth: true,
|
|
37
|
-
auth_optional: false
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
override getID()
|
|
41
|
-
{
|
|
42
|
-
return new ObjectService(this.req.params.id).getString();
|
|
43
|
-
}
|
|
44
|
-
override async handle()
|
|
45
|
-
{
|
|
46
|
-
let id = new ObjectService(this.req.params.id).getString();
|
|
47
|
-
|
|
48
|
-
await this.tables.entity_category.delete(this.props.access, this.props.session, this.props.access.owner_id, id, null);
|
|
49
|
-
}
|
|
1
|
+
import { HTTPMethod, ObjectService } from "namirasoft-core";
|
|
2
|
+
import { BaseEntityFieldController } from "../BaseEntityFieldController";
|
|
3
|
+
import { StringSchema, BaseVariableSchema } from "namirasoft-schema";
|
|
4
|
+
|
|
5
|
+
export class Delete extends BaseEntityFieldController<void>
|
|
6
|
+
{
|
|
7
|
+
override getInfo()
|
|
8
|
+
{
|
|
9
|
+
return {
|
|
10
|
+
name: "Delete",
|
|
11
|
+
tag: this.tagPrefix + "Category",
|
|
12
|
+
method: HTTPMethod.DELETE,
|
|
13
|
+
path: this.pathPrefix + "/category/{id}",
|
|
14
|
+
summary: `Deletes a ${this.namePrefix} category by an id.`
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
override async getParametersSchema()
|
|
18
|
+
{
|
|
19
|
+
return [new BaseVariableSchema("id", new StringSchema(true))];
|
|
20
|
+
}
|
|
21
|
+
override async getQueriesSchema()
|
|
22
|
+
{
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
override async getBodySchema()
|
|
26
|
+
{
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
override async getOutputSchema()
|
|
30
|
+
{
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
override async getState()
|
|
34
|
+
{
|
|
35
|
+
return {
|
|
36
|
+
check_auth: true,
|
|
37
|
+
auth_optional: false
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
override getID()
|
|
41
|
+
{
|
|
42
|
+
return new ObjectService(this.req.params.id).getString();
|
|
43
|
+
}
|
|
44
|
+
override async handle()
|
|
45
|
+
{
|
|
46
|
+
let id = new ObjectService(this.req.params.id).getString();
|
|
47
|
+
|
|
48
|
+
await this.tables.entity_category.delete(this.props.access, this.props.session, this.props.access.owner_id, id, null);
|
|
49
|
+
}
|
|
50
50
|
}
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import { HTTPMethod, ObjectService } from "namirasoft-core";
|
|
2
|
-
import { BaseEntityFieldController } from "../BaseEntityFieldController";
|
|
3
|
-
import { EntityCategoryModel } from "../../database/model/EntityCategoryModel";
|
|
4
|
-
import { StringSchema, BaseVariableSchema } from "namirasoft-schema";
|
|
5
|
-
|
|
6
|
-
export class Get extends BaseEntityFieldController<EntityCategoryModel>
|
|
7
|
-
{
|
|
8
|
-
override getInfo()
|
|
9
|
-
{
|
|
10
|
-
return {
|
|
11
|
-
name: "Get",
|
|
12
|
-
tag: this.tagPrefix + "Category",
|
|
13
|
-
method: HTTPMethod.GET,
|
|
14
|
-
path: this.pathPrefix + "/category/{id}",
|
|
15
|
-
summary: `Returns a ${this.namePrefix} category by id.`
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
override async getParametersSchema()
|
|
19
|
-
{
|
|
20
|
-
return [new BaseVariableSchema("id", new StringSchema(true))];
|
|
21
|
-
}
|
|
22
|
-
override async getQueriesSchema()
|
|
23
|
-
{
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
override async getBodySchema()
|
|
27
|
-
{
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
override async getOutputSchema()
|
|
31
|
-
{
|
|
32
|
-
return this.tables.entity_category.getSchemaByName(true);
|
|
33
|
-
}
|
|
34
|
-
override async getState()
|
|
35
|
-
{
|
|
36
|
-
return {
|
|
37
|
-
check_auth: true,
|
|
38
|
-
auth_optional: false
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
override getID()
|
|
42
|
-
{
|
|
43
|
-
return new ObjectService(this.req.params.id).getString();
|
|
44
|
-
}
|
|
45
|
-
override async handle()
|
|
46
|
-
{
|
|
47
|
-
let id = new ObjectService(this.req.params.id).getString();
|
|
48
|
-
|
|
49
|
-
let ans = await this.tables.entity_category.get(this.props.access.owner_id, id, null);
|
|
50
|
-
return await this.tables.entity_category.secure(ans);
|
|
51
|
-
}
|
|
1
|
+
import { HTTPMethod, ObjectService } from "namirasoft-core";
|
|
2
|
+
import { BaseEntityFieldController } from "../BaseEntityFieldController";
|
|
3
|
+
import { EntityCategoryModel } from "../../database/model/EntityCategoryModel";
|
|
4
|
+
import { StringSchema, BaseVariableSchema } from "namirasoft-schema";
|
|
5
|
+
|
|
6
|
+
export class Get extends BaseEntityFieldController<EntityCategoryModel>
|
|
7
|
+
{
|
|
8
|
+
override getInfo()
|
|
9
|
+
{
|
|
10
|
+
return {
|
|
11
|
+
name: "Get",
|
|
12
|
+
tag: this.tagPrefix + "Category",
|
|
13
|
+
method: HTTPMethod.GET,
|
|
14
|
+
path: this.pathPrefix + "/category/{id}",
|
|
15
|
+
summary: `Returns a ${this.namePrefix} category by id.`
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
override async getParametersSchema()
|
|
19
|
+
{
|
|
20
|
+
return [new BaseVariableSchema("id", new StringSchema(true))];
|
|
21
|
+
}
|
|
22
|
+
override async getQueriesSchema()
|
|
23
|
+
{
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
override async getBodySchema()
|
|
27
|
+
{
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
override async getOutputSchema()
|
|
31
|
+
{
|
|
32
|
+
return this.tables.entity_category.getSchemaByName(true);
|
|
33
|
+
}
|
|
34
|
+
override async getState()
|
|
35
|
+
{
|
|
36
|
+
return {
|
|
37
|
+
check_auth: true,
|
|
38
|
+
auth_optional: false
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
override getID()
|
|
42
|
+
{
|
|
43
|
+
return new ObjectService(this.req.params.id).getString();
|
|
44
|
+
}
|
|
45
|
+
override async handle()
|
|
46
|
+
{
|
|
47
|
+
let id = new ObjectService(this.req.params.id).getString();
|
|
48
|
+
|
|
49
|
+
let ans = await this.tables.entity_category.get(this.props.access.owner_id, id, null);
|
|
50
|
+
return await this.tables.entity_category.secure(ans);
|
|
51
|
+
}
|
|
52
52
|
}
|