@x-fiber-sys/dev-tool 0.1.0
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/README.md +11 -0
- package/dist/_cjs/common/action-kind.js +17 -0
- package/dist/_cjs/common/constants.js +8 -0
- package/dist/_cjs/common/document-kind.js +32 -0
- package/dist/_cjs/common/envs-kind.js +142 -0
- package/dist/_cjs/common/index.js +25 -0
- package/dist/_cjs/common/libraries-kind.js +116 -0
- package/dist/_cjs/common/menu-items.js +8 -0
- package/dist/_cjs/common/protocol-kind.js +62 -0
- package/dist/_cjs/common/symbols-kind.js +45 -0
- package/dist/_cjs/common/typings-kind.js +9 -0
- package/dist/_cjs/debug.js +195 -0
- package/dist/_cjs/index.js +5 -0
- package/dist/_cjs/initiator.js +28 -0
- package/dist/_cjs/schemas/generate.schema.js +2 -0
- package/dist/_cjs/schemas/index.js +18 -0
- package/dist/_cjs/schemas/row.schema.js +2 -0
- package/dist/_cjs/services/generator.js +107 -0
- package/dist/_cjs/services/index.js +19 -0
- package/dist/_cjs/services/installer.js +46 -0
- package/dist/_cjs/services/navigator.js +69 -0
- package/dist/_cjs/services/runner.js +20 -0
- package/dist/_cjs/templates/cache.template.js +58 -0
- package/dist/_cjs/templates/envs.template.js +115 -0
- package/dist/_cjs/templates/index.js +26 -0
- package/dist/_cjs/templates/index.template.js +38 -0
- package/dist/_cjs/templates/initiator.template.js +750 -0
- package/dist/_cjs/templates/ioc.template.js +107 -0
- package/dist/_cjs/templates/module.template.js +132 -0
- package/dist/_cjs/templates/pg-repository.template.js +432 -0
- package/dist/_cjs/templates/sys.template.js +110 -0
- package/dist/_cjs/templates/transport.template.js +490 -0
- package/dist/_cjs/templates/validator.template.js +16 -0
- package/dist/_cjs/types/index.js +2 -0
- package/dist/_cjs/types/module.js +2 -0
- package/dist/_cjs/types/service.js +2 -0
- package/dist/_cjs/utils/hello.js +17 -0
- package/dist/_cjs/utils/index.js +18 -0
- package/dist/_cjs/utils/ts-utils.js +7 -0
- package/dist/_types/common/action-kind.d.ts +15 -0
- package/dist/_types/common/constants.d.ts +5 -0
- package/dist/_types/common/document-kind.d.ts +29 -0
- package/dist/_types/common/envs-kind.d.ts +390 -0
- package/dist/_types/common/index.d.ts +9 -0
- package/dist/_types/common/libraries-kind.d.ts +115 -0
- package/dist/_types/common/menu-items.d.ts +7 -0
- package/dist/_types/common/protocol-kind.d.ts +59 -0
- package/dist/_types/common/symbols-kind.d.ts +44 -0
- package/dist/_types/common/typings-kind.d.ts +6 -0
- package/dist/_types/debug.d.ts +19 -0
- package/dist/_types/index.d.ts +2 -0
- package/dist/_types/initiator.d.ts +7 -0
- package/dist/_types/schemas/generate.schema.d.ts +38 -0
- package/dist/_types/schemas/index.d.ts +2 -0
- package/dist/_types/schemas/row.schema.d.ts +20 -0
- package/dist/_types/services/generator.d.ts +15 -0
- package/dist/_types/services/index.d.ts +3 -0
- package/dist/_types/services/installer.d.ts +5 -0
- package/dist/_types/services/navigator.d.ts +10 -0
- package/dist/_types/services/runner.d.ts +3 -0
- package/dist/_types/templates/cache.template.d.ts +8 -0
- package/dist/_types/templates/envs.template.d.ts +5 -0
- package/dist/_types/templates/index.d.ts +10 -0
- package/dist/_types/templates/index.template.d.ts +7 -0
- package/dist/_types/templates/initiator.template.d.ts +33 -0
- package/dist/_types/templates/ioc.template.d.ts +9 -0
- package/dist/_types/templates/module.template.d.ts +8 -0
- package/dist/_types/templates/pg-repository.template.d.ts +19 -0
- package/dist/_types/templates/sys.template.d.ts +23 -0
- package/dist/_types/templates/transport.template.d.ts +15 -0
- package/dist/_types/templates/validator.template.d.ts +7 -0
- package/dist/_types/types/index.d.ts +2 -0
- package/dist/_types/types/module.d.ts +10 -0
- package/dist/_types/types/service.d.ts +21 -0
- package/dist/_types/utils/hello.d.ts +1 -0
- package/dist/_types/utils/index.d.ts +2 -0
- package/dist/_types/utils/ts-utils.d.ts +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DomainConcept } from './schemas';
|
|
2
|
+
import { Static } from '@sinclair/typebox';
|
|
3
|
+
declare const AlertValidationSchema: import("@sinclair/typebox").TObject<{
|
|
4
|
+
name: import("@sinclair/typebox").TString;
|
|
5
|
+
sysCode: import("@sinclair/typebox").TString;
|
|
6
|
+
cooldownSeconds: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TNull, import("@sinclair/typebox").TNumber]>;
|
|
7
|
+
severity: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"critical" | "error" | "warning" | "info">, ...import("@sinclair/typebox").TLiteral<"critical" | "error" | "warning" | "info">[]]>;
|
|
8
|
+
description: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
9
|
+
createdAt: import("@sinclair/typebox").TUnsafe<Date>;
|
|
10
|
+
updatedAt: import("@sinclair/typebox").TUnsafe<Date>;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const concept: DomainConcept<{
|
|
13
|
+
Service: 'alerts';
|
|
14
|
+
Domain: 'alerts';
|
|
15
|
+
Class: 'Alerts';
|
|
16
|
+
Item: 'alert';
|
|
17
|
+
Entity: 'alt_alerts';
|
|
18
|
+
}, Static<typeof AlertValidationSchema>>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ActionKind } from '../common';
|
|
2
|
+
import { RowSchema } from './row.schema';
|
|
3
|
+
import type { DomainObject } from '@harvestgate/contract';
|
|
4
|
+
export type AbstractDomainReference = {
|
|
5
|
+
Service: string;
|
|
6
|
+
Domain: string;
|
|
7
|
+
Class: string;
|
|
8
|
+
Item: string;
|
|
9
|
+
Entity: string;
|
|
10
|
+
};
|
|
11
|
+
export type DomainRef<Ref extends AbstractDomainReference = AbstractDomainReference> = {
|
|
12
|
+
service: Ref['Service'];
|
|
13
|
+
domain: Ref['Domain'];
|
|
14
|
+
class: Ref['Class'];
|
|
15
|
+
item: Ref['Item'];
|
|
16
|
+
entity: Ref['Entity'];
|
|
17
|
+
};
|
|
18
|
+
export type DomainActionModule = {
|
|
19
|
+
transport?: boolean;
|
|
20
|
+
controller?: boolean;
|
|
21
|
+
postresRepository?: boolean;
|
|
22
|
+
};
|
|
23
|
+
export type CreateActionProperties = {
|
|
24
|
+
withIdReturn?: boolean;
|
|
25
|
+
};
|
|
26
|
+
export type DomainActions = {
|
|
27
|
+
[K in ActionKind]?: {
|
|
28
|
+
properties: CreateActionProperties;
|
|
29
|
+
modules: DomainActionModule;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export type DomainPgEntity = {};
|
|
33
|
+
export type DomainConcept<Ref extends AbstractDomainReference = AbstractDomainReference, O extends DomainObject = DomainObject> = {
|
|
34
|
+
ref: DomainRef<Ref>;
|
|
35
|
+
actions: DomainActions;
|
|
36
|
+
pgEntity?: DomainPgEntity;
|
|
37
|
+
item: RowSchema<O>;
|
|
38
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type DomainObject, Row } from '@harvestgate/contract';
|
|
2
|
+
export type HttpClause = 'body' | 'querystring' | 'params' | 'headers';
|
|
3
|
+
export type RowSchema<O extends DomainObject, R extends Row<O> = Row<O>> = {
|
|
4
|
+
[key in keyof R]: {
|
|
5
|
+
structure: R[key];
|
|
6
|
+
generator: {
|
|
7
|
+
sqlAlias: string;
|
|
8
|
+
httpClause?: HttpClause;
|
|
9
|
+
isTimestampGenerate?: boolean;
|
|
10
|
+
isNullGenerate?: boolean;
|
|
11
|
+
isNullable?: boolean;
|
|
12
|
+
isOptional?: boolean;
|
|
13
|
+
isUpdated?: boolean;
|
|
14
|
+
partition?: {
|
|
15
|
+
key: string;
|
|
16
|
+
httpClause: HttpClause;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class Generator {
|
|
2
|
+
private readonly _navigator;
|
|
3
|
+
private readonly _runner;
|
|
4
|
+
private _kind;
|
|
5
|
+
private readonly _formatConfig;
|
|
6
|
+
constructor();
|
|
7
|
+
private get _cwd();
|
|
8
|
+
private get _schema();
|
|
9
|
+
private get _types();
|
|
10
|
+
createService(): Promise<void>;
|
|
11
|
+
private _format;
|
|
12
|
+
private _walk;
|
|
13
|
+
help(): void;
|
|
14
|
+
exit(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ServiceConcept } from '../types';
|
|
2
|
+
export type XFiberPackage = '@x-fiber-sys/be-common' | '@x-fiber-sys/be-config' | '@x-fiber-sys/context' | '@x-fiber-sys/contract' | '@x-fiber-sys/github' | '@x-fiber-sys/metrics' | '@x-fiber-sys/morphix' | '@x-fiber-sys/performance' | '@x-fiber-sys/reflection' | '@x-fiber-sys/trigger' | '@x-fiber-sys/be-axios' | '@x-fiber-sys/click-house' | '@x-fiber-sys/docs' | '@x-fiber-sys/emails' | '@x-fiber-sys/http-server' | '@x-fiber-sys/kafka' | '@x-fiber-sys/logger' | '@x-fiber-sys/manager' | '@x-fiber-sys/meteo' | '@x-fiber-sys/neura' | '@x-fiber-sys/queue' | '@x-fiber-sys/redis' | '@x-fiber-sys/scrambler' | '@x-fiber-sys/slack' | '@x-fiber-sys/sql' | '@x-fiber-sys/storix' | '@x-fiber-sys/telegram' | '@x-fiber-sys/tracer' | '@x-fiber-sys/ws-server';
|
|
3
|
+
export declare class Installer {
|
|
4
|
+
packages({ libraries }: ServiceConcept): XFiberPackage[];
|
|
5
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './cache.template';
|
|
2
|
+
export * from './module.template';
|
|
3
|
+
export * from './pg-repository.template';
|
|
4
|
+
export * from './transport.template';
|
|
5
|
+
export * from './validator.template';
|
|
6
|
+
export * from './index.template';
|
|
7
|
+
export * from './ioc.template';
|
|
8
|
+
export * from './initiator.template';
|
|
9
|
+
export * from './sys.template';
|
|
10
|
+
export * from './envs.template';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { WriterFunction } from 'ts-morph';
|
|
2
|
+
import { SymbolsAliasMapping, SymbolsKindMapping } from '../common';
|
|
3
|
+
import { ServiceConcept } from '../types';
|
|
4
|
+
export type ModuleRef = {
|
|
5
|
+
name: (typeof SymbolsAliasMapping)[keyof typeof SymbolsAliasMapping];
|
|
6
|
+
sym: (typeof SymbolsKindMapping)[keyof typeof SymbolsKindMapping];
|
|
7
|
+
type: WriterFunction;
|
|
8
|
+
};
|
|
9
|
+
export declare class InitiatorTemplate {
|
|
10
|
+
private readonly _imports;
|
|
11
|
+
private readonly _class;
|
|
12
|
+
private readonly _path;
|
|
13
|
+
private readonly _concept;
|
|
14
|
+
constructor(path: string, concept: ServiceConcept);
|
|
15
|
+
generate(): void;
|
|
16
|
+
private _applyModule;
|
|
17
|
+
private _envs;
|
|
18
|
+
private _addLogger;
|
|
19
|
+
private _addTracer;
|
|
20
|
+
private _addScrambler;
|
|
21
|
+
private _addEmails;
|
|
22
|
+
private _addSlack;
|
|
23
|
+
private _addTelegram;
|
|
24
|
+
private _addRedis;
|
|
25
|
+
private _addBroker;
|
|
26
|
+
private _addClickHouse;
|
|
27
|
+
private _addPostgres;
|
|
28
|
+
private _addTimescale;
|
|
29
|
+
private _addStorix;
|
|
30
|
+
private _addManager;
|
|
31
|
+
private _addHttpServer;
|
|
32
|
+
private _addWsServer;
|
|
33
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DomainObject } from '@harvestgate/contract';
|
|
2
|
+
import type { ClassMethod } from '@terra-versity/morphix';
|
|
3
|
+
import type { DomainConcept, DomainRef, RowSchema } from '../schemas';
|
|
4
|
+
export declare class PostgresRepositoryTemplate {
|
|
5
|
+
private _imports;
|
|
6
|
+
private _class;
|
|
7
|
+
constructor();
|
|
8
|
+
content(concept: DomainConcept): string;
|
|
9
|
+
private _publicCreateOne;
|
|
10
|
+
private _privateCreateOne;
|
|
11
|
+
_publicUpdateById(ref: DomainRef): ClassMethod;
|
|
12
|
+
private _privateUpdateById;
|
|
13
|
+
_publicPatchById(ref: DomainRef): ClassMethod;
|
|
14
|
+
private _privatePatchById;
|
|
15
|
+
_publicDeleteModifyById(ref: DomainRef): ClassMethod;
|
|
16
|
+
_privateDeleteModifyById(ref: DomainRef, item: RowSchema<DomainObject>): ClassMethod;
|
|
17
|
+
_publicArchiveModifyById(ref: DomainRef): ClassMethod;
|
|
18
|
+
_privateArchiveModifyById(ref: DomainRef, item: RowSchema<DomainObject>): ClassMethod;
|
|
19
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare class SysTemplate {
|
|
2
|
+
private readonly _variables;
|
|
3
|
+
constructor();
|
|
4
|
+
package({ name, description }: {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
}): object;
|
|
8
|
+
nodemon(): {
|
|
9
|
+
watch: string[];
|
|
10
|
+
ext: string;
|
|
11
|
+
ignore: string[];
|
|
12
|
+
exec: string;
|
|
13
|
+
restartable: string;
|
|
14
|
+
};
|
|
15
|
+
dockerfileDev({ kind, name, path }: {
|
|
16
|
+
kind: string;
|
|
17
|
+
name: string;
|
|
18
|
+
path: string;
|
|
19
|
+
}): void;
|
|
20
|
+
eslintrc(path: string): void;
|
|
21
|
+
project(name: string): object;
|
|
22
|
+
tsconfig(name: string): object;
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DomainConcept } from '../schemas';
|
|
2
|
+
export declare class TransportTemplate {
|
|
3
|
+
private _imports;
|
|
4
|
+
private _class;
|
|
5
|
+
constructor();
|
|
6
|
+
content(concept: DomainConcept): string;
|
|
7
|
+
private _getById;
|
|
8
|
+
private _createOne;
|
|
9
|
+
private _updateById;
|
|
10
|
+
private _softDeleteById;
|
|
11
|
+
private _restoreById;
|
|
12
|
+
private _archiveById;
|
|
13
|
+
private _unarchiveById;
|
|
14
|
+
private _deleteById;
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type ServiceConcept = {
|
|
2
|
+
service: string;
|
|
3
|
+
libraries: {
|
|
4
|
+
axios?: boolean;
|
|
5
|
+
scrambler?: boolean;
|
|
6
|
+
emails?: boolean;
|
|
7
|
+
slack?: boolean;
|
|
8
|
+
telegram?: boolean;
|
|
9
|
+
redis?: boolean;
|
|
10
|
+
broker?: boolean;
|
|
11
|
+
clickHouse?: boolean;
|
|
12
|
+
postgres?: boolean;
|
|
13
|
+
timescale?: boolean;
|
|
14
|
+
storix?: boolean;
|
|
15
|
+
manager?: boolean;
|
|
16
|
+
queue?: boolean;
|
|
17
|
+
httpServer?: boolean;
|
|
18
|
+
wsServer?: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type ServiceLibraryKey = keyof ServiceConcept['libraries'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hello: () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getTypeAlias: (service: string, file: string) => string;
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@x-fiber-sys/dev-tool",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Command line interface for generating and managing microservices in a monorepo",
|
|
5
|
+
"author": "pestsov-v <pestsov.js@gmail.com>",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"main": "dist/_cjs/index.js",
|
|
9
|
+
"types": "dist/_types/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/_types/index.d.ts",
|
|
13
|
+
"default": "./dist/_cjs/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"bin": {
|
|
17
|
+
"xfs-dev-tool": "dist/_cjs/index.js"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist/_cjs",
|
|
21
|
+
"dist/_types",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/pestsov-v/c-argo-back-mono.git"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"dev": "nodemon ./src/index.ts",
|
|
33
|
+
"start": "ts-node -r tsconfig-paths/register --files ./src/index.ts",
|
|
34
|
+
"packages": "rm -rf dist && tsc -p tsconfig.cjs.json && tsc -p tsconfig.types.json",
|
|
35
|
+
"build": "npm run packages",
|
|
36
|
+
"serve": "node ./dist/_cjs/index.js"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@x-fiber-sys/morphix": "^0.1.0",
|
|
40
|
+
"cfonts": "^3.3.1",
|
|
41
|
+
"commander": "^14.0.1",
|
|
42
|
+
"fs-extra": "^11.3.2",
|
|
43
|
+
"ts-morph": "^27.0.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/fs-extra": "^11.0.4"
|
|
47
|
+
}
|
|
48
|
+
}
|