@bmstravel/nvp-plop-templates 0.2.65 → 0.2.67

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,4 +1,4 @@
1
- import { IBaseActionSchema, IBaseAdapter, I{{pascalCase serviceName}}Service, UserAuthMeta } from "@src/types";
1
+ import { IBaseActionSchema, IBaseAdapter } from "@src/types";
2
2
  import { Context } from "moleculer";
3
3
  import { VISIBILITY, ERR_SYSTEM } from "@src/common";
4
4
  import { MoleculerRegularError } from "@src/errors";
@@ -7,8 +7,8 @@ export type {{pascalCase actionName}}Params = {
7
7
 
8
8
  }
9
9
 
10
- async function handler(ctx: Context<{{pascalCase actionName}}Params, UserAuthMeta>) {
11
- const $this: I{{pascalCase serviceName}}Service = this;
10
+ async function handler(ctx: Context<{{pascalCase actionName}}Params, UserService.UserAuthMeta>) {
11
+ const $this: {{pascalCase serviceName}}Service.I{{pascalCase serviceName}}Service = this;
12
12
  const $adapter: IBaseAdapter = $this.adapter;
13
13
  const i18next = ctx.broker.i18next
14
14
  try {
@@ -53,7 +53,7 @@ async function handler(ctx: Context<{{pascalCase actionName}}Params, UserAuthMet
53
53
  * @example
54
54
  * rest: "POST {{pascalCase serviceName}}/{{pascalCase actionName}}",
55
55
  */
56
- const {{pascalCase actionName}}Action: IBaseActionSchema<ReturnType<typeof handler>, {{pascalCase actionName}}Params, UserAuthMeta> = {
56
+ const {{pascalCase actionName}}Action: IBaseActionSchema<ReturnType<typeof handler>, {{pascalCase actionName}}Params, UserService.UserAuthMeta> = {
57
57
  {{#if actionPath}}
58
58
  rest: "{{method}} {{actionPath}}",
59
59
  {{/if}}
@@ -1,11 +1,11 @@
1
- import { I{{pascalCase serviceName}}Service, IBaseAdapter } from "@src/types";
1
+ import { IBaseAdapter } from "@src/types";
2
2
 
3
3
  export type {{pascalCase methodName}}Params = {
4
4
 
5
5
  }
6
6
 
7
7
  async function {{camelCase methodName}}(payload: {{pascalCase methodName}}Params) {
8
- const $this: I{{pascalCase serviceName}}Service = this;
8
+ const $this: {{pascalCase serviceName}}Service.I{{pascalCase serviceName}}Service = this;
9
9
  const $adapter: IBaseAdapter = $this.adapter
10
10
  const $cacher = $this.broker.cacher
11
11
  return new $this.Promise((resolve, _reject) => {
@@ -1,37 +1,11 @@
1
1
  import { DataTypes } from "sequelize";
2
- import dayjs from "dayjs";
3
2
  {{#eq dataTypeId "uuid"}}
4
3
  import { generateUuid } from '@bmstravel/nvp-utils'
5
4
  {{/eq}}
6
5
  import { ISequelizeModel } from '@src/types'
7
6
  import { STATUS } from "@src/common"
8
7
 
9
- export interface I{{pascalCase name}} {
10
- {{#if hasId}}
11
- {{#eq dataTypeId "integer"}}
12
- id: number;
13
- {{/eq}}
14
- {{#eq dataTypeId "uuid"}}
15
- id: string;
16
- {{/eq}}
17
- {{/if}}
18
- // BEGIN addition here
19
-
20
- // END addition here
21
- {{#if hasId}}
22
- status: STATUS
23
- creator?: string
24
- createdBy?: any
25
- updatedBy?: any
26
- deleteBy?: any
27
- isDelete?: boolean
28
- createdAt: number;
29
- updatedAt: number;
30
- deletedAt?: number;
31
- {{/if}}
32
- }
33
-
34
- const {{pascalCase name}}Model: ISequelizeModel<I{{pascalCase name}}> = {
8
+ const {{pascalCase name}}Model: ISequelizeModel<{{pascalCase name}}Service.I{{pascalCase name}}> = {
35
9
  name: "{{camelCase name}}",
36
10
  define: {
37
11
  {{#if hasId}}
@@ -63,15 +37,15 @@ const {{pascalCase name}}Model: ISequelizeModel<I{{pascalCase name}}> = {
63
37
  allowNull: true,
64
38
  },
65
39
  createdBy: {
66
- type: DataTypes.STRING(15),
40
+ type: DataTypes.STRING(50),
67
41
  allowNull: true,
68
42
  },
69
43
  updatedBy: {
70
- type: DataTypes.STRING(15),
44
+ type: DataTypes.STRING(50),
71
45
  allowNull: true,
72
46
  },
73
47
  deleteBy: {
74
- type: DataTypes.STRING(15),
48
+ type: DataTypes.STRING(50),
75
49
  allowNull: true,
76
50
  },
77
51
  isDelete: {
@@ -104,7 +78,7 @@ const {{pascalCase name}}Model: ISequelizeModel<I{{pascalCase name}}> = {
104
78
  if (value == null || typeof value == "undefined") {
105
79
  this.setDataValue("updatedAt", new Date().getTime())
106
80
  } else {
107
- this.setDataValue("updatedAt", value)
81
+ this.setDataValue("updatedAt", value || new Date().getTime())
108
82
  }
109
83
  },
110
84
  },
@@ -0,0 +1,24 @@
1
+ export interface I{{pascalCase name}} {
2
+ {{#if hasId}}
3
+ {{#eq dataTypeId "integer"}}
4
+ id: number;
5
+ {{/eq}}
6
+ {{#eq dataTypeId "uuid"}}
7
+ id: string;
8
+ {{/eq}}
9
+ {{/if}}
10
+ // BEGIN addition here
11
+
12
+ // END addition here
13
+ {{#if hasId}}
14
+ status: STATUS
15
+ creator?: string
16
+ createdBy?: any
17
+ updatedBy?: any
18
+ deleteBy?: any
19
+ isDelete?: boolean
20
+ createdAt: number;
21
+ updatedAt: number;
22
+ deletedAt?: number;
23
+ {{/if}}
24
+ }
@@ -16,17 +16,12 @@ import {
16
16
  EventService,
17
17
  HookService,
18
18
  } from '@bmstravel/nvp-decorator'
19
- import {
20
- MoleculerDBService,
21
- I{{pascalCase serviceName}},
22
- {{pascalCase serviceName}}ServiceSettingsOptions,
23
- {{pascalCase serviceName}}ServiceOptions,
24
- } from "@src/types";
19
+ import { MoleculerDBService } from "@src/types";
25
20
  import { VERSION{{#if hasHelloAction}} , Config, VISIBILITY{{/if}} } from "@src/common";
26
21
  import {{camelCase model}}Model from '@src/models/sequelize/{{camelCase model}}'
27
22
 
28
23
  const serviceName = '{{camelCase serviceName}}'
29
- @Service<{{pascalCase serviceName}}ServiceOptions>({
24
+ @Service<{{pascalCase serviceName}}Service.{{pascalCase serviceName}}ServiceOptions>({
30
25
  name: serviceName,
31
26
  {{#eq serviceVersion "none"}}{{/eq}}
32
27
  {{#unlessEq serviceVersion "none"}}
@@ -95,8 +90,8 @@ const serviceName = '{{camelCase serviceName}}'
95
90
  {{/unlessEq}}
96
91
  {{/unlessEq}}
97
92
  export default class {{pascalCase serviceName}}Service extends MoleculerDBService<
98
- {{pascalCase serviceName}}ServiceSettingsOptions,
99
- I{{pascalCase serviceName}}
93
+ {{pascalCase serviceName}}Service.{{pascalCase serviceName}}ServiceSettingsOptions,
94
+ {{pascalCase serviceName}}Service.I{{pascalCase serviceName}}
100
95
  > {
101
96
  public constructor(
102
97
  public broker: moleculer.ServiceBroker,
@@ -1,42 +1,26 @@
1
- import { Options } from '@bmstravel/nvp-decorator';
2
- import {{pascalCase serviceName}}Service from "@src/services/{{camelCase serviceName}}.service"
3
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
4
- import { ServiceActionsSchema } from "moleculer";
5
- import {
6
- IBaseService,
7
- IBaseServiceActions,
8
- IBaseServiceMethods,
9
- } from "./db.service-interface";
10
- /* MOL_METHOD_INJECT */
1
+ export interface {{pascalCase serviceName}}ServiceSettingsOptions {
2
+ rest?: "/{{camelCase serviceName}}";
3
+ [x: string]: any;
4
+ }
11
5
 
12
- /* MOL_METHOD_TYPE */
6
+ export interface {{pascalCase serviceName}}ServiceOptions extends Options {
7
+ name: '{{camelCase serviceName}}';
8
+ settings: {{pascalCase serviceName}}ServiceSettingsOptions;
9
+ }
13
10
 
14
- export interface {{pascalCase serviceName}}ServiceSettingsOptions {
15
- /**
16
- * if implements will replace /v1/{{camelCase serviceName}}/* to /{{camelCase serviceName}}/*
17
- */
18
- rest?: "/{{camelCase serviceName}}";
19
- [x: string]: any;
20
- }
11
+ export type I{{pascalCase serviceName}}Actions = IBaseServiceActions & {
12
+ /* MOL_ACTION */
13
+ {{#if hasHelloAction}}
14
+ hello: ServiceActionsSchema;
15
+ {{/if}}
16
+ }
21
17
 
22
- export interface {{pascalCase serviceName}}ServiceOptions extends Options {
23
- name: '{{camelCase serviceName}}';
24
- settings: {{pascalCase serviceName}}ServiceSettingsOptions;
25
- }
18
+ type {{pascalCase serviceName}}Methods = InstanceType<typeof {{pascalCase serviceName}}Service>
19
+ export type I{{pascalCase serviceName}}Methods = IBaseServiceMethods & Partial<{{pascalCase serviceName}}Methods> & {
20
+ /* MOL_METHOD */
21
+ }
26
22
 
27
- export type I{{pascalCase serviceName}}Actions = IBaseServiceActions & {
28
- /* MOL_ACTION */
29
- {{#if hasHelloAction}}
30
- hello: ServiceActionsSchema;
31
- {{/if}}
32
- }
33
-
34
- type {{pascalCase serviceName}}Methods = InstanceType<typeof {{pascalCase serviceName}}Service>
35
- export type I{{pascalCase serviceName}}Methods = IBaseServiceMethods & Partial<{{pascalCase serviceName}}Methods> & {
36
- /* MOL_METHOD */
37
- }
38
-
39
- export type I{{pascalCase serviceName}}Service = IBaseService<I{{pascalCase serviceName}}Actions, I{{pascalCase serviceName}}Methods> & I{{pascalCase serviceName}}Methods & {
40
- actions: I{{pascalCase serviceName}}Actions;
41
- methods: I{{pascalCase serviceName}}Methods;
42
- }
23
+ export type I{{pascalCase serviceName}}Service = IBaseService<I{{pascalCase serviceName}}Actions, I{{pascalCase serviceName}}Methods> & I{{pascalCase serviceName}}Methods & {
24
+ actions: I{{pascalCase serviceName}}Actions;
25
+ methods: I{{pascalCase serviceName}}Methods;
26
+ }
@@ -0,0 +1,7 @@
1
+ import { Options } from '@bmstravel/nvp-decorator';
2
+ import {{pascalCase serviceName}}ServicePrototype from "@src/services/{{camelCase serviceName}}.service"
3
+ import { DbServiceSettings } from 'moleculer-db';
4
+ import { IBaseService, IBaseServiceActions, IBaseServiceMethods } from "../db.service-interface"
5
+ /* MOL_METHOD_INJECT */
6
+
7
+ /* MOL_METHOD_TYPE */
@@ -1,45 +1,28 @@
1
- import { Options } from '@bmstravel/nvp-decorator';
2
- import {{pascalCase serviceName}}Service from "@src/services/{{camelCase serviceName}}.service"
3
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
4
- import { ServiceActionsSchema } from "moleculer";
5
- import { DbServiceSettings } from 'moleculer-db';
6
- import {
7
- IBaseService,
8
- IBaseServiceActions,
9
- IBaseServiceMethods,
10
- } from "./db.service-interface";
11
- /* MOL_METHOD_INJECT */
1
+ export interface {{pascalCase serviceName}}ServiceSettingsOptions extends Omit<DbServiceSettings, "fields"> {
2
+ rest?: "/{{camelCase serviceName}}";
3
+ fields?: (keyof Required<any>)[];
4
+ populates?: any;
5
+ [x: string]: any;
6
+ }
12
7
 
13
- /* MOL_METHOD_TYPE */
8
+ export interface {{pascalCase serviceName}}ServiceOptions extends Options {
9
+ name: '{{camelCase serviceName}}';
10
+ settings: {{pascalCase serviceName}}ServiceSettingsOptions;
11
+ }
14
12
 
15
- export interface {{pascalCase serviceName}}ServiceSettingsOptions extends Omit<DbServiceSettings, "fields"> {
16
- /**
17
- * if implements will replace /v1/{{camelCase serviceName}}/* to /{{camelCase serviceName}}/*
18
- */
19
- rest?: "/{{camelCase serviceName}}";
20
- fields?: (keyof Required<any>)[];
21
- populates?: any;
22
- [x: string]: any;
23
- }
13
+ export type I{{pascalCase serviceName}}Actions = IBaseServiceActions & {
14
+ /* MOL_ACTION */
15
+ {{#if hasHelloAction}}
16
+ hello: ServiceActionsSchema;
17
+ {{/if}}
18
+ }
24
19
 
25
- export interface {{pascalCase serviceName}}ServiceOptions extends Options {
26
- name: '{{camelCase serviceName}}';
27
- settings: {{pascalCase serviceName}}ServiceSettingsOptions;
28
- }
20
+ type {{pascalCase serviceName}}Methods = InstanceType<typeof {{pascalCase serviceName}}ServicePrototype>
21
+ export type I{{pascalCase serviceName}}Methods = IBaseServiceMethods & Partial<{{pascalCase serviceName}}Methods> & {
22
+ /* MOL_METHOD */
23
+ }
29
24
 
30
- export type I{{pascalCase serviceName}}Actions = IBaseServiceActions & {
31
- /* MOL_ACTION */
32
- {{#if hasHelloAction}}
33
- hello: ServiceActionsSchema;
34
- {{/if}}
35
- }
36
-
37
- type {{pascalCase serviceName}}Methods = InstanceType<typeof {{pascalCase serviceName}}Service>
38
- export type I{{pascalCase serviceName}}Methods = IBaseServiceMethods & Partial<{{pascalCase serviceName}}Methods> & {
39
- /* MOL_METHOD */
40
- }
41
-
42
- export type I{{pascalCase serviceName}}Service = IBaseService<I{{pascalCase serviceName}}Actions, I{{pascalCase serviceName}}Methods> & I{{pascalCase serviceName}}Methods & {
43
- actions: I{{pascalCase serviceName}}Actions;
44
- methods: I{{pascalCase serviceName}}Methods;
45
- }
25
+ export type I{{pascalCase serviceName}}Service = IBaseService<I{{pascalCase serviceName}}Actions, I{{pascalCase serviceName}}Methods> & I{{pascalCase serviceName}}Methods & {
26
+ actions: I{{pascalCase serviceName}}Actions;
27
+ methods: I{{pascalCase serviceName}}Methods;
28
+ }
@@ -0,0 +1,7 @@
1
+ import { Options } from '@bmstravel/nvp-decorator';
2
+ import {{pascalCase serviceName}}ServicePrototype from "@src/services/{{camelCase serviceName}}.service"
3
+ import { DbServiceSettings } from 'moleculer-db';
4
+ import { IBaseService, IBaseServiceActions, IBaseServiceMethods } from "../db.service-interface"
5
+ /* MOL_METHOD_INJECT */
6
+
7
+ /* MOL_METHOD_TYPE */
@@ -0,0 +1,55 @@
1
+
2
+ /* PLOP_INJECT_IMPORT */
3
+
4
+ declare global {
5
+ {{#if name}}
6
+ namespace {{pascalCase name}}Service {
7
+ {{/if}}
8
+ {{#if serviceName}}
9
+ namespace {{pascalCase serviceName}}Service {
10
+ {{/if}}
11
+
12
+ /* ------------------------------ START MODEL ZONE ----------------------------- */
13
+ /* MOL_MODEL_ZONE */
14
+
15
+ /* ------------------------------- END MODEL ZONE ------------------------------ */
16
+
17
+ /* ------------------------------ START SERVICE ZONE ----------------------------- */
18
+ /* MOL_SERVICE_ZONE */
19
+
20
+ /* ------------------------------- END SERVICE ZONE ------------------------------ */
21
+
22
+ /* ------------------------------ START ACTION ZONE ----------------------------- */
23
+ /* MOL_ACTION_ZONE */
24
+
25
+ /* ------------------------------- END ACTION ZONE ------------------------------ */
26
+
27
+ /* ------------------------------ START METHOD ZONE ----------------------------- */
28
+ /* MOL_METHOD_ZONE */
29
+
30
+ /* ------------------------------- END METHOD ZONE ------------------------------ */
31
+
32
+ /* ------------------------------ START EVENT ZONE ----------------------------- */
33
+ /* MOL_EVENT_ZONE */
34
+
35
+ /* ------------------------------- END EVENT ZONE ------------------------------ */
36
+
37
+ /* ------------------------------ START HOOK ZONE ----------------------------- */
38
+ /* MOL_HOOK_ZONE */
39
+
40
+ /* ------------------------------- END HOOK ZONE ------------------------------ */
41
+
42
+ /* ------------------------------ START MIXIN ZONE ----------------------------- */
43
+ /* MOL_MIXIN_ZONE */
44
+
45
+ /* ------------------------------- END MIXIN ZONE ------------------------------ */
46
+
47
+ /* ------------------------------ START OTHER ZONE ----------------------------- */
48
+
49
+ /* ----------------------------- OTHER ZONE ----------------------------- */
50
+ /* MOL_OTHER_ZONE */
51
+
52
+ /* ------------------------------- END OTHER ZONE ------------------------------ */
53
+
54
+ }
55
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bmstravel/nvp-plop-templates",
3
- "version": "0.2.65",
3
+ "version": "0.2.67",
4
4
  "description": "🏆 Using for plop templates",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -15,5 +15,5 @@
15
15
  "phongnv86 <phongnguyenvan86@gmail.com>",
16
16
  "phongnv86 <phongnv@media-one.vn>"
17
17
  ],
18
- "gitHead": "c01878afc3b49fe4d74de8665708ae673ba811de"
18
+ "gitHead": "bfe05d7c60e8b7ce2586a2d21f75c3c6fd0e335b"
19
19
  }