pwi-plata-type 0.4.201 → 0.4.202

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.
Files changed (94) hide show
  1. package/README.md +2 -2
  2. package/package.json +58 -58
  3. package/src/@types/build.d.ts +26 -26
  4. package/src/@types/cluster.actions.d.ts +27 -27
  5. package/src/@types/cluster.d.ts +55 -55
  6. package/src/@types/create-cli.d.ts +8 -8
  7. package/src/@types/exported.d.ts +34 -31
  8. package/src/@types/fs.d.ts +6 -6
  9. package/src/@types/global.d.ts +131 -131
  10. package/src/@types/knex.d.ts +13 -13
  11. package/src/@types/model.d.ts +143 -143
  12. package/src/@types/router.d.ts +107 -107
  13. package/src/@types/sql.d.ts +120 -120
  14. package/src/@types/swagger.d.ts +22 -22
  15. package/src/bin/extras/create-api-cli.ts +218 -218
  16. package/src/bin/extras/create-cluster-cli.ts +160 -160
  17. package/src/bin/extras/create-lib-cli.ts +84 -84
  18. package/src/bin/extras/plata-create-tools.ts +97 -97
  19. package/src/bin/plata-api.ts +189 -189
  20. package/src/bin/plata-build.ts +19 -19
  21. package/src/bin/plata-cluster.ts +42 -42
  22. package/src/bin/plata-cmd.ts +19 -19
  23. package/src/bin/plata-create.ts +50 -50
  24. package/src/bin/plata-runtime.ts +110 -110
  25. package/src/bin/plata-swagger.ts +104 -104
  26. package/src/index.ts +20 -20
  27. package/src/libs/axios.ts +32 -32
  28. package/src/libs/build.ts +234 -234
  29. package/src/libs/build_wasm.ts +169 -169
  30. package/src/libs/cluster/cluster-controller.ts +93 -93
  31. package/src/libs/cluster.ts +319 -319
  32. package/src/libs/custom.ts +21 -21
  33. package/src/libs/env.ts +10 -10
  34. package/src/libs/fs.ts +399 -399
  35. package/src/libs/hot-reload.ts +63 -63
  36. package/src/libs/job.ts +32 -32
  37. package/src/libs/models/index.ts +4 -4
  38. package/src/libs/models/model-template-combine.ts +93 -93
  39. package/src/libs/models/model-template-env.ts +58 -58
  40. package/src/libs/models/model-template-union.ts +87 -87
  41. package/src/libs/models/model-template.ts +111 -111
  42. package/src/libs/models/model-validations.ts +453 -453
  43. package/src/libs/models/tools.ts +196 -196
  44. package/src/libs/router.ts +184 -184
  45. package/src/libs/runtime.ts +328 -328
  46. package/src/libs/sql.ts +931 -931
  47. package/src/libs/swagger.ts +81 -81
  48. package/src/libs/tools.ts +236 -236
  49. package/src/misc/golang/wasm_exec.js +574 -574
  50. package/src/scripts/post-install/api.ts +32 -32
  51. package/src/scripts/post-install/cluster.ts +28 -28
  52. package/src/scripts/post-install/lib.ts +25 -25
  53. package/src/scripts/post-install.ts +64 -64
  54. package/src/scripts/pre-test.ts +33 -33
  55. package/src/tests/1-config.test.ts +12 -12
  56. package/src/tests/2-effect.test.ts +107 -107
  57. package/src/tests/3-model.env.test.ts +66 -66
  58. package/src/tests/4-model.test.ts +150 -150
  59. package/src/tests/5-model.union.test.ts +160 -160
  60. package/src/tests/6-router.test.ts +44 -44
  61. package/src/tests/7-switch.test.ts +75 -75
  62. package/src/tests/8-brands.test.ts +52 -52
  63. package/src/tests/9-sql.test.ts +639 -639
  64. package/src/tests/assets/sql/example.sql +94 -94
  65. package/templates/create-cli/class.ts +13 -13
  66. package/templates/create-cli/cluster.ts +14 -14
  67. package/templates/create-cli/cmd.ts +3 -3
  68. package/templates/create-cli/config.ts +2 -2
  69. package/templates/create-cli/lib.ts +3 -3
  70. package/templates/create-cli/model.ts +14 -14
  71. package/templates/create-cli/route.ts +8 -8
  72. package/templates/create-cli/task.ts +13 -13
  73. package/templates/postinstall/api/.vscode/launch.json +20 -20
  74. package/templates/postinstall/api/Dockerfile +22 -22
  75. package/templates/postinstall/api/configs/env.ts +2 -2
  76. package/templates/postinstall/api/envs/debug.env +15 -15
  77. package/templates/postinstall/api/envs/homolog.env +15 -15
  78. package/templates/postinstall/api/envs/prod.env +15 -15
  79. package/templates/postinstall/api/tsconfig.json +24 -24
  80. package/templates/postinstall/cluster/.vscode/launch.json +20 -20
  81. package/templates/postinstall/cluster/Dockerfile +24 -24
  82. package/templates/postinstall/cluster/configs/env.ts +2 -2
  83. package/templates/postinstall/cluster/envs/debug.env +10 -10
  84. package/templates/postinstall/cluster/envs/homolog.env +10 -10
  85. package/templates/postinstall/cluster/envs/prod.env +10 -10
  86. package/templates/postinstall/cluster/tsconfig.json +24 -24
  87. package/templates/postinstall/lib/postinstall-tools.mjs +111 -111
  88. package/templates/postinstall/lib/postinstall.js +33 -33
  89. package/templates/postinstall/lib/tsconfig.json +22 -22
  90. package/templates/swagger-cli/header.json +21 -21
  91. package/templates/swagger-cli/route/body.json +14 -14
  92. package/templates/swagger-cli/route/header.json +18 -18
  93. package/templates/swagger-cli/route/response.json +53 -53
  94. package/tsconfig.json +28 -28
package/README.md CHANGED
@@ -1,2 +1,2 @@
1
- # ModeloNodejs
2
-
1
+ # ModeloNodejs
2
+
package/package.json CHANGED
@@ -1,58 +1,58 @@
1
- {
2
- "name": "pwi-plata-type",
3
- "version": "0.4.201",
4
- "main": "__BUILD__/index",
5
- "types": "src/@types/exported.d.ts",
6
- "bin": {
7
- "plata-runtime": "__BUILD__/bin/plata-runtime.js"
8
- },
9
- "scripts": {
10
- "build": "tsc -p .",
11
- "clean": "rimraf __BUILD__ ",
12
- "clean:tests": "rimraf __BUILD__/tests",
13
- "prepack": "npm run clean && npm run build && npm run clean:tests",
14
- "pretest": "npm run clean && npm run build && node __BUILD__/scripts/pre-test.js",
15
- "postinstall": "node __BUILD__/scripts/post-install.js",
16
- "test": "node --test __BUILD__/tests/**/*.test.js"
17
- },
18
- "keywords": [],
19
- "author": "",
20
- "license": "UNLICENSED",
21
- "dependencies": {
22
- "@babel/plugin-transform-arrow-functions": "^7.27.1",
23
- "@babel/preset-typescript": "^7.28.5",
24
- "@total-typescript/ts-reset": "^0.6.1",
25
- "@types/express": "^4.17.21",
26
- "@types/glob": "^7.2.0",
27
- "@types/node-schedule": "^2.1.8",
28
- "@types/swagger-ui-express": "^4.1.8",
29
- "axios": "^1.13.4",
30
- "bytenode": "^1.5.7",
31
- "commander": "^14.0.3",
32
- "effect": "^3.19.16",
33
- "esbuild-plugin-babel": "^0.2.3",
34
- "express": "^4.22.1",
35
- "glob": "^8.0.3",
36
- "knex": "^3.1.0",
37
- "knex-schema-inspector": "^3.1.0",
38
- "moment": "^2.30.1",
39
- "node-schedule": "^2.1.1",
40
- "node-watch": "^0.7.4",
41
- "swagger-ui-express": "^5.0.1",
42
- "tsup": "^8.5.1",
43
- "typescript": "^5.9.3"
44
- },
45
- "devDependencies": {
46
- "@types/golang-wasm-exec": "^1.15.2",
47
- "nodemon": "^3.1.11",
48
- "rimraf": "^6.1.2",
49
- "sqlite3": "^5.1.7"
50
- },
51
- "description": "",
52
- "files": [
53
- "__BUILD__",
54
- "src",
55
- "templates",
56
- "tsconfig.json"
57
- ]
58
- }
1
+ {
2
+ "name": "pwi-plata-type",
3
+ "version": "0.4.202",
4
+ "main": "__BUILD__/index",
5
+ "types": "src/@types/exported.d.ts",
6
+ "bin": {
7
+ "plata-runtime": "__BUILD__/bin/plata-runtime.js"
8
+ },
9
+ "scripts": {
10
+ "build": "tsc -p .",
11
+ "clean": "rimraf __BUILD__ ",
12
+ "clean:tests": "rimraf __BUILD__/tests",
13
+ "prepack": "npm run clean && npm run build && npm run clean:tests",
14
+ "pretest": "npm run clean && npm run build && node __BUILD__/scripts/pre-test.js",
15
+ "postinstall": "node __BUILD__/scripts/post-install.js",
16
+ "test": "node --test __BUILD__/tests/**/*.test.js"
17
+ },
18
+ "keywords": [],
19
+ "author": "",
20
+ "license": "UNLICENSED",
21
+ "dependencies": {
22
+ "@babel/plugin-transform-arrow-functions": "^7.27.1",
23
+ "@babel/preset-typescript": "^7.28.5",
24
+ "@total-typescript/ts-reset": "^0.6.1",
25
+ "@types/express": "^4.17.21",
26
+ "@types/glob": "^7.2.0",
27
+ "@types/node-schedule": "^2.1.8",
28
+ "@types/swagger-ui-express": "^4.1.8",
29
+ "axios": "^1.13.4",
30
+ "bytenode": "^1.5.7",
31
+ "commander": "^14.0.3",
32
+ "effect": "^3.19.16",
33
+ "esbuild-plugin-babel": "^0.2.3",
34
+ "express": "^4.22.1",
35
+ "glob": "^8.0.3",
36
+ "knex": "^3.1.0",
37
+ "knex-schema-inspector": "^3.1.0",
38
+ "moment": "^2.30.1",
39
+ "node-schedule": "^2.1.1",
40
+ "node-watch": "^0.7.4",
41
+ "swagger-ui-express": "^5.0.1",
42
+ "tsup": "^8.5.1",
43
+ "typescript": "^5.9.3"
44
+ },
45
+ "devDependencies": {
46
+ "@types/golang-wasm-exec": "^1.15.2",
47
+ "nodemon": "^3.1.11",
48
+ "rimraf": "^6.1.2",
49
+ "sqlite3": "^5.1.7"
50
+ },
51
+ "description": "",
52
+ "files": [
53
+ "__BUILD__",
54
+ "src",
55
+ "templates",
56
+ "tsconfig.json"
57
+ ]
58
+ }
@@ -1,27 +1,27 @@
1
- import { Command } from 'commander'
2
- declare global {
3
- namespace Build {
4
- interface Plugin {
5
- name: string
6
- posBuild?: (config: Build.CompilerConfigs, outDir: string) => Promise<void>
7
- cliCreate?: (program: Command) => Promise<Command>
8
- }
9
-
10
- interface Config {
11
- env?: PlataEnv
12
- copyFolderToRoot?: string[]
13
- mapFiles?: boolean
14
- otimizar?: boolean
15
- plugins?: Plugin[]
16
- dropLabels?: string[]
17
- }
18
-
19
-
20
-
21
- interface CompilerConfigs extends Config {
22
- basePath: string
23
- packageJsonSetup: boolean
24
- }
25
- }
26
-
1
+ import { Command } from 'commander'
2
+ declare global {
3
+ namespace Build {
4
+ interface Plugin {
5
+ name: string
6
+ posBuild?: (config: Build.CompilerConfigs, outDir: string) => Promise<void>
7
+ cliCreate?: (program: Command) => Promise<Command>
8
+ }
9
+
10
+ interface Config {
11
+ env?: PlataEnv
12
+ copyFolderToRoot?: string[]
13
+ mapFiles?: boolean
14
+ otimizar?: boolean
15
+ plugins?: Plugin[]
16
+ dropLabels?: string[]
17
+ }
18
+
19
+
20
+
21
+ interface CompilerConfigs extends Config {
22
+ basePath: string
23
+ packageJsonSetup: boolean
24
+ }
25
+ }
26
+
27
27
  }
@@ -1,27 +1,27 @@
1
- interface PlataProcess extends Cluster.PlataEvents {}
2
-
3
- declare namespace Cluster {
4
- type GetActionsObject<T extends Dictionary<any>> = {
5
- [K in keyof T]: { action: K, msg: T[K] }
6
- }
7
-
8
- type GetActions<T extends Dictionary<any>> = GetActionsObject<T>[keyof T]
9
-
10
- type GetEmitFuncionsArgs<T extends Dictionary<any>> = {
11
- [K in keyof T]: [event: K, response: T[K]]
12
- }[keyof T]
13
-
14
- type GetOnFuncionsArgs<T extends Dictionary<any>> = {
15
- [K in keyof T]: [event: K, listener: (r: T[K]) => void | Promise<void>]
16
- }[keyof T]
17
-
18
-
19
- interface PlataEvents {
20
- emit(...args: GetEmitFuncionsArgs<PlataClusterActions> | Cluster.UserActions)
21
- on(...args: GetOnFuncionsArgs<PlataClusterActions> | GetOnFuncionsArgs<UserClusterActions>)
22
- once(...args: GetOnFuncionsArgs<PlataClusterActions> | GetOnFuncionsArgs<UserClusterActions>)
23
- }
24
-
25
- type Actions = GetActions<PlataClusterActions> | GetActions<UserClusterActions>
26
- type UserActions = GetActions<UserClusterActions>
27
- }
1
+ interface PlataProcess extends Cluster.PlataEvents {}
2
+
3
+ declare namespace Cluster {
4
+ type GetActionsObject<T extends Dictionary<any>> = {
5
+ [K in keyof T]: { action: K, msg: T[K] }
6
+ }
7
+
8
+ type GetActions<T extends Dictionary<any>> = GetActionsObject<T>[keyof T]
9
+
10
+ type GetEmitFuncionsArgs<T extends Dictionary<any>> = {
11
+ [K in keyof T]: [event: K, response: T[K]]
12
+ }[keyof T]
13
+
14
+ type GetOnFuncionsArgs<T extends Dictionary<any>> = {
15
+ [K in keyof T]: [event: K, listener: (r: T[K]) => void | Promise<void>]
16
+ }[keyof T]
17
+
18
+
19
+ interface PlataEvents {
20
+ emit(...args: GetEmitFuncionsArgs<PlataClusterActions> | Cluster.UserActions)
21
+ on(...args: GetOnFuncionsArgs<PlataClusterActions> | GetOnFuncionsArgs<UserClusterActions>)
22
+ once(...args: GetOnFuncionsArgs<PlataClusterActions> | GetOnFuncionsArgs<UserClusterActions>)
23
+ }
24
+
25
+ type Actions = GetActions<PlataClusterActions> | GetActions<UserClusterActions>
26
+ type UserActions = GetActions<UserClusterActions>
27
+ }
@@ -1,56 +1,56 @@
1
- /// <reference path="cluster.actions.d.ts" />
2
-
3
- import { ClusterController } from '++/libs/cluster/cluster-controller'
4
- import * as cluster from 'node:cluster'
5
-
6
- declare global {
7
- namespace Cluster {
8
- interface Worker extends cluster.Worker {}
9
-
10
- interface WorkerConfig {
11
- name: string,
12
- env: PlataEnv,
13
- onStart: () => Promise<void>
14
- controller?: (controller: ClusterController) => Promise<void>
15
- workers?: number,
16
- workersEnv?: any,
17
- onExit?: (worker: cluster.Worker, code: number, signal: string) => void,
18
- }
19
-
20
- interface ClusterConfig {
21
- controllerPid?: number
22
- pids: number[]
23
- config: WorkerConfig
24
- }
25
-
26
- interface PlataClusterActions {
27
- KILL: string
28
- ECHO: Cluster.UserActions
29
- 'ECHO-CLUSTER': {
30
- name: string
31
- data: Cluster.UserActions
32
- }
33
- 'ECHO-PID': {
34
- pid: number
35
- data: Cluster.UserActions
36
- }
37
- 'GET-PIDS-CLUSTER': {
38
- name: LooseAutocomplete<'__PLATA_EXPRESS__'>
39
- id: string
40
- }
41
-
42
- 'DEAD-WORKER-NOTIFY': {
43
- clusterName: string
44
- pidDead: number
45
- newPid: number
46
- }
47
-
48
- RELOAD: true
49
-
50
- [K: `GET-PIDS-CLUSTER-RESULT-${string}`]: PlataResult<number[]>
51
- }
52
- }
53
-
54
- interface UserClusterActions {}
55
-
1
+ /// <reference path="cluster.actions.d.ts" />
2
+
3
+ import { ClusterController } from '++/libs/cluster/cluster-controller'
4
+ import * as cluster from 'node:cluster'
5
+
6
+ declare global {
7
+ namespace Cluster {
8
+ interface Worker extends cluster.Worker {}
9
+
10
+ interface WorkerConfig {
11
+ name: string,
12
+ env: PlataEnv,
13
+ onStart: () => Promise<void>
14
+ controller?: (controller: ClusterController) => Promise<void>
15
+ workers?: number,
16
+ workersEnv?: any,
17
+ onExit?: (worker: cluster.Worker, code: number, signal: string) => void,
18
+ }
19
+
20
+ interface ClusterConfig {
21
+ controllerPid?: number
22
+ pids: number[]
23
+ config: WorkerConfig
24
+ }
25
+
26
+ interface PlataClusterActions {
27
+ KILL: string
28
+ ECHO: Cluster.UserActions
29
+ 'ECHO-CLUSTER': {
30
+ name: string
31
+ data: Cluster.UserActions
32
+ }
33
+ 'ECHO-PID': {
34
+ pid: number
35
+ data: Cluster.UserActions
36
+ }
37
+ 'GET-PIDS-CLUSTER': {
38
+ name: LooseAutocomplete<'__PLATA_EXPRESS__'>
39
+ id: string
40
+ }
41
+
42
+ 'DEAD-WORKER-NOTIFY': {
43
+ clusterName: string
44
+ pidDead: number
45
+ newPid: number
46
+ }
47
+
48
+ RELOAD: true
49
+
50
+ [K: `GET-PIDS-CLUSTER-RESULT-${string}`]: PlataResult<number[]>
51
+ }
52
+ }
53
+
54
+ interface UserClusterActions {}
55
+
56
56
  }
@@ -1,9 +1,9 @@
1
- import { Command } from 'commander'
2
-
3
- declare global {
4
- namespace CreateCli {
5
- interface ImportedCreateCli {
6
- cli: Command
7
- }
8
- }
1
+ import { Command } from 'commander'
2
+
3
+ declare global {
4
+ namespace CreateCli {
5
+ interface ImportedCreateCli {
6
+ cli: Command
7
+ }
8
+ }
9
9
  }
@@ -1,32 +1,35 @@
1
- /// <reference path="global.d.ts" />
2
- /// <reference path="model.d.ts" />
3
- /// <reference path="cluster.d.ts" />
4
- /// <reference path="router.d.ts" />
5
- /// <reference path="fs.d.ts" />
6
- /// <reference path="sql.d.ts" />
7
- /// <reference path="../libs/runtime.ts" />
8
- /// <reference path="knex.d.ts" />
9
- /// <reference path="build.d.ts" />
10
-
11
- import * as PlataCluster from '../libs/cluster'
12
- import * as PlataRoutes from '../libs/router'
13
- import * as PlataTools from '../libs/tools'
14
- import * as PlataModels from '../libs/models'
15
- import * as PlataTasks from '../libs/tasks'
16
- import * as PlataSwagger from '../libs/swagger'
17
- import * as PlataSql from '../libs/sql'
18
- import { PlataFs } from '../libs/fs'
19
- import { PlataAxios, PlataAxiosUnsafe } from '../libs/axios'
20
-
21
- export {
22
- PlataCluster,
23
- PlataRoutes,
24
- PlataTools,
25
- PlataModels,
26
- PlataSwagger,
27
- PlataTasks,
28
- PlataAxios,
29
- PlataAxiosUnsafe,
30
- PlataSql,
31
- PlataFs
1
+ /// <reference path="global.d.ts" />
2
+ /// <reference path="model.d.ts" />
3
+ /// <reference path="cluster.d.ts" />
4
+ /// <reference path="router.d.ts" />
5
+ /// <reference path="fs.d.ts" />
6
+ /// <reference path="sql.d.ts" />
7
+ /// <reference path="../libs/runtime.ts" />
8
+ /// <reference path="knex.d.ts" />
9
+ /// <reference path="build.d.ts" />
10
+
11
+ import * as PlataCluster from '../libs/cluster'
12
+ import * as PlataRoutes from '../libs/router'
13
+ import * as PlataTools from '../libs/tools'
14
+ import * as PlataModels from '../libs/models'
15
+ import * as PlataTasks from '../libs/tasks'
16
+ import * as PlataSwagger from '../libs/swagger'
17
+ import * as PlataSql from '../libs/sql'
18
+ import * as PlataJob from './libs/job'
19
+
20
+ import { PlataFs } from '../libs/fs'
21
+ import { PlataAxios, PlataAxiosUnsafe } from '../libs/axios'
22
+
23
+ export {
24
+ PlataCluster,
25
+ PlataRoutes,
26
+ PlataTools,
27
+ PlataModels,
28
+ PlataSwagger,
29
+ PlataTasks,
30
+ PlataAxios,
31
+ PlataAxiosUnsafe,
32
+ PlataSql,
33
+ PlataFs,
34
+ PlataJob
32
35
  }
@@ -1,7 +1,7 @@
1
- declare namespace Fs {
2
- interface ProcessExit {
3
- exitCode: number,
4
- stdout: string,
5
- stderr: string
6
- }
1
+ declare namespace Fs {
2
+ interface ProcessExit {
3
+ exitCode: number,
4
+ stdout: string,
5
+ stderr: string
6
+ }
7
7
  }