@pjts/schema 0.0.109

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 ADDED
@@ -0,0 +1,3 @@
1
+ # Domain-Driven Design TypeScript Utilities / Schema
2
+
3
+ Module generating API json schema based on annotations generated by `@pjts/core` to be used by `@pjts/client`
@@ -0,0 +1,5 @@
1
+ export declare const HttpModule: () => (_target: any) => void;
2
+ export declare function AppService(_target: any): void;
3
+ export declare function Param(_target: any, _key: any, _descriptor: any): void;
4
+ export declare function File(_target: any, _key: any, _descriptor: any): void;
5
+ export declare function Ip(_target: any, _key: any, _descriptor: any): void;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Ip = exports.File = exports.Param = exports.AppService = exports.HttpModule = void 0;
4
+ const HttpModule = () => (_target) => { };
5
+ exports.HttpModule = HttpModule;
6
+ function AppService(_target) { }
7
+ exports.AppService = AppService;
8
+ function Param(_target, _key, _descriptor) { }
9
+ exports.Param = Param;
10
+ function File(_target, _key, _descriptor) { }
11
+ exports.File = File;
12
+ function Ip(_target, _key, _descriptor) { }
13
+ exports.Ip = Ip;
14
+ //# sourceMappingURL=decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../src/__test__/decorator.ts"],"names":[],"mappings":";;;AAAO,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,CAAC,OAAY,EAAE,EAAE,GAAE,CAAC,CAAA;AAAvC,QAAA,UAAU,cAA6B;AAEpD,SAAgB,UAAU,CAAC,OAAY,IAAG,CAAC;AAA3C,gCAA2C;AAE3C,SAAgB,KAAK,CAAC,OAAY,EAAE,IAAS,EAAE,WAAgB,IAAG,CAAC;AAAnE,sBAAmE;AAEnE,SAAgB,IAAI,CAAC,OAAY,EAAE,IAAS,EAAE,WAAgB,IAAG,CAAC;AAAlE,oBAAkE;AAElE,SAAgB,EAAE,CAAC,OAAY,EAAE,IAAS,EAAE,WAAgB,IAAG,CAAC;AAAhE,gBAAgE"}
@@ -0,0 +1,115 @@
1
+ import { NullStr } from '@pjts/core';
2
+ export interface IndexedType {
3
+ [key: string]: number;
4
+ }
5
+ export declare class FileDto {
6
+ readonly data: string;
7
+ constructor(data: string);
8
+ }
9
+ export declare class MyDto {
10
+ name?: NullStr;
11
+ }
12
+ export declare class NestedItem {
13
+ value: string;
14
+ }
15
+ export declare class NestedDto {
16
+ items: NestedItem[];
17
+ }
18
+ export interface ListResult<T> {
19
+ whatever: T;
20
+ }
21
+ export interface Nested {
22
+ test: string;
23
+ vo: OtherVO;
24
+ }
25
+ export interface ComplexType {
26
+ nested1: import('./domain').Nested;
27
+ }
28
+ export declare class OtherVO {
29
+ private readonly x;
30
+ constructor(x: string);
31
+ toJSON(): {
32
+ one: number;
33
+ x: string;
34
+ };
35
+ }
36
+ export declare class MyClass {
37
+ private x;
38
+ toJSON(): {
39
+ one: number;
40
+ x: string;
41
+ };
42
+ }
43
+ export type MyClass2Data = string;
44
+ export declare class MyClass2 {
45
+ private x;
46
+ toJSON(): import('./domain').MyClass2Data;
47
+ }
48
+ export declare class DomainPrimitive {
49
+ readonly value: string;
50
+ constructor(value: string);
51
+ toJSON(): number;
52
+ }
53
+ export declare class ComposedDomainPrimitive extends DomainPrimitive {
54
+ readonly value: string;
55
+ constructor(value: string);
56
+ }
57
+ declare enum EntityStatus {
58
+ On = "ON",
59
+ Off = "OFF"
60
+ }
61
+ export interface EntityData {
62
+ item: DomainPrimitive;
63
+ items: DomainPrimitive[];
64
+ primitive: number;
65
+ primitives: number[];
66
+ complex: ComplexType;
67
+ complexes: import('./domain').ComplexType[];
68
+ }
69
+ export declare class ComplexEntity {
70
+ readonly data: import('./domain').EntityData;
71
+ private readonly _status;
72
+ constructor(data: import('./domain').EntityData);
73
+ get status(): EntityStatus;
74
+ toJSON(): {
75
+ status: EntityStatus;
76
+ item: DomainPrimitive;
77
+ items: DomainPrimitive[];
78
+ primitive: number;
79
+ primitives: number[];
80
+ complex: ComplexType;
81
+ complexes: ComplexType[];
82
+ };
83
+ }
84
+ interface ValueObjectData {
85
+ one: DomainPrimitive;
86
+ two: number;
87
+ }
88
+ export declare class ValueObject {
89
+ readonly data: ValueObjectData;
90
+ constructor(data: ValueObjectData);
91
+ }
92
+ export declare class Token {
93
+ private readonly value;
94
+ constructor(value: string);
95
+ toJSON(): {
96
+ value: string;
97
+ date: Date;
98
+ };
99
+ }
100
+ interface ComplexInterfaceItem {
101
+ name: string;
102
+ quantity: number;
103
+ }
104
+ export interface ComplexInterface {
105
+ name: string;
106
+ version: number;
107
+ items: ComplexInterfaceItem[];
108
+ }
109
+ interface UnusedElse {
110
+ name: string;
111
+ }
112
+ export interface ExtendedComplexInterface extends UnusedElse {
113
+ description: string;
114
+ }
115
+ export {};
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Token = exports.ValueObject = exports.ComplexEntity = exports.ComposedDomainPrimitive = exports.DomainPrimitive = exports.MyClass2 = exports.MyClass = exports.OtherVO = exports.NestedDto = exports.NestedItem = exports.MyDto = exports.FileDto = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@pjts/core");
6
+ class FileDto {
7
+ data;
8
+ constructor(data) {
9
+ this.data = data;
10
+ }
11
+ }
12
+ exports.FileDto = FileDto;
13
+ let MyDto = class MyDto {
14
+ name = core_1.$;
15
+ };
16
+ MyDto = tslib_1.__decorate([
17
+ core_1.Dto
18
+ ], MyDto);
19
+ exports.MyDto = MyDto;
20
+ let NestedItem = class NestedItem {
21
+ value;
22
+ };
23
+ NestedItem = tslib_1.__decorate([
24
+ core_1.Dto
25
+ ], NestedItem);
26
+ exports.NestedItem = NestedItem;
27
+ let NestedDto = class NestedDto {
28
+ items;
29
+ };
30
+ NestedDto = tslib_1.__decorate([
31
+ core_1.Dto
32
+ ], NestedDto);
33
+ exports.NestedDto = NestedDto;
34
+ class OtherVO {
35
+ x;
36
+ constructor(x) {
37
+ this.x = x;
38
+ }
39
+ toJSON() {
40
+ return {
41
+ one: 1,
42
+ x: this.x,
43
+ };
44
+ }
45
+ }
46
+ exports.OtherVO = OtherVO;
47
+ class MyClass {
48
+ x = 'two';
49
+ toJSON() {
50
+ return {
51
+ one: 1,
52
+ x: this.x,
53
+ };
54
+ }
55
+ }
56
+ exports.MyClass = MyClass;
57
+ class MyClass2 {
58
+ x = 'two';
59
+ toJSON() {
60
+ return this.x;
61
+ }
62
+ }
63
+ exports.MyClass2 = MyClass2;
64
+ class DomainPrimitive {
65
+ value;
66
+ constructor(value) {
67
+ this.value = value;
68
+ }
69
+ toJSON() {
70
+ return Number(this.value);
71
+ }
72
+ }
73
+ exports.DomainPrimitive = DomainPrimitive;
74
+ class ComposedDomainPrimitive extends DomainPrimitive {
75
+ value;
76
+ constructor(value) {
77
+ super(value);
78
+ this.value = value;
79
+ }
80
+ }
81
+ exports.ComposedDomainPrimitive = ComposedDomainPrimitive;
82
+ var EntityStatus;
83
+ (function (EntityStatus) {
84
+ EntityStatus["On"] = "ON";
85
+ EntityStatus["Off"] = "OFF";
86
+ })(EntityStatus || (EntityStatus = {}));
87
+ class ComplexEntity {
88
+ data;
89
+ _status;
90
+ constructor(data) {
91
+ this.data = data;
92
+ this._status = EntityStatus.On;
93
+ }
94
+ get status() {
95
+ return this._status;
96
+ }
97
+ toJSON() {
98
+ return {
99
+ ...this.data,
100
+ status: this.status,
101
+ };
102
+ }
103
+ }
104
+ exports.ComplexEntity = ComplexEntity;
105
+ class ValueObject {
106
+ data;
107
+ constructor(data) {
108
+ this.data = data;
109
+ }
110
+ }
111
+ exports.ValueObject = ValueObject;
112
+ class Token {
113
+ value;
114
+ constructor(value) {
115
+ this.value = value;
116
+ }
117
+ toJSON() {
118
+ return {
119
+ value: this.value,
120
+ date: new Date(),
121
+ };
122
+ }
123
+ }
124
+ exports.Token = Token;
125
+ //# sourceMappingURL=domain.js.map
@@ -0,0 +1 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AAC;CACF;AAND,0CAMC;AAED,MAAa,uBAAwB,SAAQ,eAAe;IAC9B;IAA5B,YAA4B,KAAa;QACvC,KAAK,CAAC,KAAK,CAAC,CAAA;QADc,UAAK,GAAL,KAAK,CAAQ;IAEzC,CAAC;CACF;AAJD,0DAIC;AAED,IAAK,YAGJ;AAHD,WAAK,YAAY;IACf,yBAAS,CAAA;IACT,2BAAW,CAAA;AACb,CAAC,EAHI,YAAY,KAAZ,YAAY,QAGhB;AAWD,MAAa,aAAa;IAGI;IAFX,OAAO,CAAc;IAEtC,YAA4B,IAAmC;QAAnC,SAAI,GAAJ,IAAI,CAA+B;QAC7D,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC,EAAE,CAAA;IAChC,CAAC;IAED,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAEM,MAAM;QACX,OAAO;YACL,GAAG,IAAI,CAAC,IAAI;YACZ,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAA;IACH,CAAC;CACF;AAjBD,sCAiBC;AAOD,MAAa,WAAW;IACM;IAA5B,YAA4B,IAAqB;QAArB,SAAI,GAAJ,IAAI,CAAiB;IAAI,CAAC;CACvD;AAFD,kCAEC;AAED,MAAa,KAAK;IACa;IAA7B,YAA6B,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAI,CAAC;IAExC,MAAM;QACX,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,IAAI,EAAE;SACjB,CAAA;IACH,CAAC;CACF;AATD,sBASC"}
@@ -0,0 +1,7 @@
1
+ import { AliasedService, MyService } from "./service";
2
+ export declare class MyModule {
3
+ get myService(): MyService;
4
+ get aliasedService(): AliasedService;
5
+ whatever: string;
6
+ private other;
7
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MyModule = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const decorator_1 = require("./decorator");
6
+ const service_1 = require("./service");
7
+ let MyModule = class MyModule {
8
+ get myService() {
9
+ this.other = true;
10
+ return new service_1.MyService();
11
+ }
12
+ get aliasedService() {
13
+ return new service_1.AliasedService();
14
+ }
15
+ whatever = 'x';
16
+ // @ts-ignore
17
+ other = false;
18
+ };
19
+ MyModule = tslib_1.__decorate([
20
+ (0, decorator_1.HttpModule)()
21
+ ], MyModule);
22
+ exports.MyModule = MyModule;
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/__test__/index.ts"],"names":[],"mappings":";;;;AAAA,2CAAuC;AACvC,uCAAoD;AAG7C,IAAM,QAAQ,GAAd,MAAM,QAAQ;IACnB,IAAW,SAAS;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,OAAO,IAAI,mBAAS,EAAE,CAAA;IACxB,CAAC;IAED,IAAW,cAAc;QACvB,OAAO,IAAI,wBAAc,EAAE,CAAA;IAC7B,CAAC;IAEM,QAAQ,GAAG,GAAG,CAAA;IACrB,aAAa;IACL,KAAK,GAAG,KAAK,CAAA;CACtB,CAAA;AAbY,QAAQ;IADpB,IAAA,sBAAU,GAAE;GACA,QAAQ,CAapB;AAbY,4BAAQ"}
@@ -0,0 +1,36 @@
1
+ import { ComplexEntity, ComplexInterface, ComplexType, ComposedDomainPrimitive, DomainPrimitive, IndexedType, ListResult, MyClass, MyDto, NestedDto, Token, ValueObject, FileDto, OtherVO, ExtendedComplexInterface } from "./domain";
2
+ interface CustomType {
3
+ name: string;
4
+ }
5
+ export declare class MyService {
6
+ test1(_dto: ValueObject): Promise<{
7
+ one: number;
8
+ x: string;
9
+ }>;
10
+ test2(_one: DomainPrimitive): Promise<ListResult<number>>;
11
+ test3(): Promise<{
12
+ one: number;
13
+ x: string;
14
+ }[]>;
15
+ test4(): Promise<import("./domain").ListResult<string>>;
16
+ test5(_x: ComposedDomainPrimitive): Promise<ListResult<MyClass>>;
17
+ test6(): Promise<import('./domain').MyClass>;
18
+ test7(): Promise<CustomType[]>;
19
+ test8(): Promise<ComplexType[]>;
20
+ test9(_dto: MyDto): Promise<ComplexEntity[]>;
21
+ test10(_param: Token): Promise<Token>;
22
+ test11(): Promise<ComplexInterface[]>;
23
+ test12(): Promise<IndexedType>;
24
+ test13(_dto: NestedDto): Promise<void>;
25
+ upload(_file: FileDto): Promise<void>;
26
+ middleware(_ipAddress: OtherVO): Promise<void>;
27
+ extended(_ipAddress: OtherVO): Promise<ExtendedComplexInterface[]>;
28
+ private secretMethod;
29
+ }
30
+ export declare class MyService2 {
31
+ baseMethod(): Promise<string>;
32
+ }
33
+ export declare class AliasedService extends MyService2 {
34
+ extensionMethod(): Promise<string>;
35
+ }
36
+ export {};
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AliasedService = exports.MyService2 = exports.MyService = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const domain_1 = require("./domain");
6
+ const decorator_1 = require("./decorator");
7
+ let MyService = class MyService {
8
+ async test1(_dto) {
9
+ const instance = new domain_1.MyClass();
10
+ return instance.toJSON();
11
+ }
12
+ async test2(_one) {
13
+ return {
14
+ whatever: 1,
15
+ };
16
+ }
17
+ async test3() {
18
+ const instance = new domain_1.MyClass();
19
+ return [
20
+ instance.toJSON(),
21
+ instance.toJSON(),
22
+ ];
23
+ }
24
+ async test4() {
25
+ return {
26
+ whatever: 'two'
27
+ };
28
+ }
29
+ async test5(_x) {
30
+ return {
31
+ whatever: new domain_1.MyClass()
32
+ };
33
+ }
34
+ async test6() {
35
+ this.secretMethod();
36
+ return new domain_1.MyClass();
37
+ }
38
+ async test7() {
39
+ return [{
40
+ name: 'test'
41
+ }];
42
+ }
43
+ async test8() {
44
+ return [];
45
+ }
46
+ async test9(_dto) {
47
+ return [];
48
+ }
49
+ async test10(_param) {
50
+ return _param;
51
+ }
52
+ async test11() {
53
+ return [];
54
+ }
55
+ async test12() {
56
+ return {};
57
+ }
58
+ async test13(_dto) {
59
+ //
60
+ }
61
+ async upload(_file) {
62
+ //
63
+ }
64
+ async middleware(_ipAddress) {
65
+ }
66
+ async extended(_ipAddress) {
67
+ return [];
68
+ }
69
+ secretMethod() {
70
+ //
71
+ }
72
+ };
73
+ tslib_1.__decorate([
74
+ tslib_1.__param(0, decorator_1.Param),
75
+ tslib_1.__metadata("design:type", Function),
76
+ tslib_1.__metadata("design:paramtypes", [domain_1.ValueObject]),
77
+ tslib_1.__metadata("design:returntype", Promise)
78
+ ], MyService.prototype, "test1", null);
79
+ tslib_1.__decorate([
80
+ tslib_1.__param(0, decorator_1.Param),
81
+ tslib_1.__metadata("design:type", Function),
82
+ tslib_1.__metadata("design:paramtypes", [domain_1.DomainPrimitive]),
83
+ tslib_1.__metadata("design:returntype", Promise)
84
+ ], MyService.prototype, "test2", null);
85
+ tslib_1.__decorate([
86
+ tslib_1.__param(0, decorator_1.File),
87
+ tslib_1.__metadata("design:type", Function),
88
+ tslib_1.__metadata("design:paramtypes", [domain_1.FileDto]),
89
+ tslib_1.__metadata("design:returntype", Promise)
90
+ ], MyService.prototype, "upload", null);
91
+ tslib_1.__decorate([
92
+ tslib_1.__param(0, decorator_1.Ip),
93
+ tslib_1.__metadata("design:type", Function),
94
+ tslib_1.__metadata("design:paramtypes", [domain_1.OtherVO]),
95
+ tslib_1.__metadata("design:returntype", Promise)
96
+ ], MyService.prototype, "middleware", null);
97
+ tslib_1.__decorate([
98
+ tslib_1.__param(0, decorator_1.Ip),
99
+ tslib_1.__metadata("design:type", Function),
100
+ tslib_1.__metadata("design:paramtypes", [domain_1.OtherVO]),
101
+ tslib_1.__metadata("design:returntype", Promise)
102
+ ], MyService.prototype, "extended", null);
103
+ MyService = tslib_1.__decorate([
104
+ decorator_1.AppService
105
+ ], MyService);
106
+ exports.MyService = MyService;
107
+ class MyService2 {
108
+ async baseMethod() {
109
+ return '';
110
+ }
111
+ }
112
+ exports.MyService2 = MyService2;
113
+ let AliasedService = class AliasedService extends MyService2 {
114
+ async extensionMethod() {
115
+ return '';
116
+ }
117
+ };
118
+ AliasedService = tslib_1.__decorate([
119
+ decorator_1.AppService
120
+ ], AliasedService);
121
+ exports.AliasedService = AliasedService;
122
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/__test__/service.ts"],"names":[],"mappings":";;;;AAAA,qCAUkB;AAClB,2CAAwD;AAOjD,IAAM,SAAS,GAAf,MAAM,SAAS;IACP,AAAN,KAAK,CAAC,KAAK,CAAQ,IAAiB;QACzC,MAAM,QAAQ,GAAG,IAAI,gBAAO,EAAE,CAAA;QAC9B,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAA;IAC1B,CAAC;IAEY,AAAN,KAAK,CAAC,KAAK,CAAQ,IAAqB;QAC7C,OAAO;YACL,QAAQ,EAAE,CAAC;SACZ,CAAA;IACH,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,MAAM,QAAQ,GAAG,IAAI,gBAAO,EAAE,CAAA;QAC9B,OAAO;YACL,QAAQ,CAAC,MAAM,EAAE;YACjB,QAAQ,CAAC,MAAM,EAAE;SAClB,CAAA;IACH,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,OAAO;YACL,QAAQ,EAAE,KAAK;SAChB,CAAA;IACH,CAAC;IAEM,KAAK,CAAC,KAAK,CAAC,EAA2B;QAC5C,OAAO;YACL,QAAQ,EAAE,IAAI,gBAAO,EAAE;SACxB,CAAA;IACH,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,IAAI,CAAC,YAAY,EAAE,CAAA;QACnB,OAAO,IAAI,gBAAO,EAAE,CAAA;IACtB,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,OAAO,CAAC;gBACN,IAAI,EAAE,MAAM;aACb,CAAC,CAAA;IACJ,CAAC;IAEM,KAAK,CAAC,KAAK;QAChB,OAAO,EAAE,CAAA;IACX,CAAC;IAEM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ointDescriptor } from '@pjts/core';
2
+ interface ServiceEndpoint {
3
+ url: string;
4
+ method: string;
5
+ status: number;
6
+ httpMethod: string;
7
+ headers: Record<string, string>;
8
+ params: EndpointDescriptor['params'];
9
+ }
10
+ export interface ServiceConfig {
11
+ name: string;
12
+ endpoints: ServiceEndpoint[];
13
+ }
14
+ export declare const buildClientConfig: <T extends AppModule<T>>(appModule: T) => ServiceConfig[];
15
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildClientConfig = void 0;
4
+ const core_1 = require("@pjts/core");
5
+ const buildClientConfig = (appModule) => {
6
+ const serviceConfigs = {};
7
+ const moduleDescriptor = (0, core_1.getModuleDescriptor)(appModule);
8
+ moduleDescriptor.routes.forEach(route => {
9
+ route.endpoints.forEach(endpoint => {
10
+ const key = moduleDescriptor.prefix + route.name;
11
+ if (!serviceConfigs[key]) {
12
+ serviceConfigs[key] = {
13
+ name: (0, core_1.getServiceMethodName)(route),
14
+ endpoints: [],
15
+ };
16
+ }
17
+ const serviceEndpoint = {
18
+ url: (0, core_1.buildUrl)(moduleDescriptor, route, endpoint, '/'),
19
+ params: endpoint.params,
20
+ httpMethod: endpoint.httpMethod,
21
+ method: endpoint.method,
22
+ status: endpoint.status,
23
+ headers: {
24
+ 'Content-Type': 'application/json',
25
+ },
26
+ };
27
+ serviceConfigs[key].endpoints.push(serviceEndpoint);
28
+ });
29
+ });
30
+ return Object.values(serviceConfigs);
31
+ };
32
+ exports.buildClientConfig = buildClientConfig;
33
+ //# sourceMappingURL=client-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-config.js","sourceRoot":"","sources":["../src/client-config.ts"],"names":[],"mappings":";;;AAAA,qCAMmB;AAgBZ,MAAM,iBAAiB,GAAG,CAAyB,SAAY,EAAmB,EAAE;IACzF,MAAM,cAAc,GAAkC,EAAE,CAAA;IAExD,MAAM,gBAAgB,GAAG,IAAA,0BAAmB,EAAC,SAAS,CAAC,CAAA;IACvD,gBAAgB,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACtC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YACjC,MAAM,GAAG,GAAG,gBAAgB,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAA;YAChD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;gBACxB,cAAc,CAAC,GAAG,CAAC,GAAG;oBACpB,IAAI,EAAE,IAAA,2BAAoB,EAAC,KAAK,CAAC;oBACjC,SAAS,EAAE,EAAE;iBACd,CAAA;aACF;YACD,MAAM,eAAe,GAAoB;gBACvC,GAAG,EAAE,IAAA,eAAQ,EAAC,gBAAgB,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,CAAC;gBACrD,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,UAAU,EAAE,QAAQ,CAAC,UAAU;gBAC/B,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,MAAM,EAAE,QAAQ,CAAC,MAAM;gBACvB,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;iBACnC;aACF,CAAA;YACD,cAAc,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QACrD,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,OAAO,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;AACtC,CAAC,CAAA;AA3BY,QAAA,iBAAiB,qBA2B7B"}
@@ -0,0 +1,2 @@
1
+ import * as ts from 'typescript';
2
+ export declare const buildClientTypes: (rootNames: string[], include: string[], options: ts.CompilerOptions) => string;
@@ -0,0 +1,361 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildClientTypes = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const ts = tslib_1.__importStar(require("typescript"));
6
+ const core_1 = require("@pjts/core");
7
+ const APP_MODULE_DECORATOR = core_1.HttpModule.name;
8
+ const APP_SERVICE_DECORATOR = core_1.AppService.name;
9
+ const ENTITY_SERIALIZE_METHOD = 'toJSON';
10
+ const isBuiltInType = (objName) => {
11
+ try {
12
+ eval(objName);
13
+ return true;
14
+ }
15
+ catch {
16
+ return false;
17
+ }
18
+ };
19
+ const log = (...args) => {
20
+ if (process.env.DEBUG === 'true') {
21
+ console.log(...args);
22
+ }
23
+ };
24
+ log('APP_MODULE_DECORATOR: ', APP_MODULE_DECORATOR);
25
+ log('APP_SERVICE_DECORATOR: ', APP_SERVICE_DECORATOR);
26
+ log('ENTITY_SERIALIZE_METHOD: ', ENTITY_SERIALIZE_METHOD);
27
+ const registeredModules = {};
28
+ const declarations = {};
29
+ const toLowerCase = (val) => val[0].toLowerCase() + val.slice(1);
30
+ let lines = [`/* PJX generated types */\n`];
31
+ const addedDeclarations = new Set();
32
+ const isDeclared = (name) => addedDeclarations.has(name);
33
+ const addTopLevelDeclaration = (name, declaration) => {
34
+ if (!isDeclared(name)) {
35
+ lines.push(declaration.trim() + '\n');
36
+ addedDeclarations.add(name);
37
+ }
38
+ };
39
+ const getTypeDeclarations = () => {
40
+ Object.entries(registeredModules).forEach(([moduleName, appModule]) => {
41
+ lines.push(`export interface ${moduleName} {`);
42
+ Object.entries(appModule).forEach(([serviceName, appService]) => {
43
+ lines.push(` ${toLowerCase(serviceName)}: {`);
44
+ Object.entries(appService).forEach(([methodName, methodType]) => {
45
+ lines.push(` ${methodName}: ${methodType}`);
46
+ });
47
+ lines.push(' }');
48
+ });
49
+ lines.push('}\n');
50
+ });
51
+ console.log(`PJX generating types:`);
52
+ for (const moduleName of Object.keys(registeredModules)) {
53
+ console.log('- ' + moduleName);
54
+ }
55
+ return lines.join('\n');
56
+ };
57
+ const buildClientTypes = (rootNames, include, options) => {
58
+ const program = ts.createProgram(rootNames, {
59
+ ...options,
60
+ noErrorTruncation: true,
61
+ });
62
+ const sourceFiles = program.getSourceFiles().filter(file => file.fileName.match(include.join('|')));
63
+ log('source files: ', sourceFiles.length);
64
+ const checker = program.getTypeChecker();
65
+ const classDeclarations = [];
66
+ sourceFiles.forEach((file) => {
67
+ file.statements.forEach((node) => {
68
+ if (ts.isClassDeclaration(node) && node.name) {
69
+ log('class: ', node.name.getText());
70
+ declarations[sanitizeTypeName(node.name.getText())] = node;
71
+ classDeclarations.push(node);
72
+ }
73
+ if (ts.isInterfaceDeclaration(node) && node.name) {
74
+ log('interface: ', node.name.getText());
75
+ declarations[sanitizeTypeName(node.name.getText())] = node;
76
+ }
77
+ if (ts.isEnumDeclaration(node) && node.name) {
78
+ log('enum: ', node.name.getText());
79
+ declarations[sanitizeTypeName(node.name.getText())] = node;
80
+ }
81
+ if (ts.isTypeAliasDeclaration(node) && node.name) {
82
+ log('type alias: ', node.name.getText());
83
+ declarations[sanitizeTypeName(node.name.getText())] = node;
84
+ }
85
+ });
86
+ });
87
+ classDeclarations.forEach((node) => {
88
+ if (isDecoratedWith(node, APP_MODULE_DECORATOR)) {
89
+ log('app module: ', node.name.getText());
90
+ handleAppModule(checker, node);
91
+ }
92
+ });
93
+ return getTypeDeclarations();
94
+ };
95
+ exports.buildClientTypes = buildClientTypes;
96
+ const sanitizeTypeName = (typeName) => (typeName || '').replaceAll(/(?=import)(.*?)(?=)\)\./g, '').trim();
97
+ const getGenericTypeRef = (name) => {
98
+ const chunks = name.split(/<|>|\[|\]/g).filter(Boolean).map(sanitizeTypeName);
99
+ if (chunks[0] === 'Promise') {
100
+ return chunks.slice(1);
101
+ }
102
+ return chunks;
103
+ };
104
+ const getGenericName = (typeName) => {
105
+ const [genericName] = typeName.match(/(?<=interface|type|class|enum)(.*?)(?=extends|{|=)/g) || [];
106
+ return sanitizeTypeName(genericName || typeName);
107
+ };
108
+ const formatBody = (propertyTypes) => {
109
+ return `{ ${propertyTypes.map(arg => arg.join(': ')).join(', ')} }`;
110
+ };
111
+ const formatFunctionParameters = (argumentTypes) => {
112
+ return '(' + argumentTypes.map(arg => arg.join(': ')).join(', ') + ')';
113
+ };
114
+ const resolveInterfaceDeclarationType = (checker, declaration) => {
115
+ const propertyTypes = [];
116
+ declaration.members.forEach(member => {
117
+ if (ts.isPropertySignature(member)) {
118
+ propertyTypes.push([member.name.getText(), resolveDeclarationType(checker, member)]);
119
+ }
120
+ if (ts.isIndexSignatureDeclaration(member)) {
121
+ const [indexType, valueType] = member.getText().split(']: ');
122
+ propertyTypes.push([indexType + ']', valueType]);
123
+ }
124
+ });
125
+ return formatBody(propertyTypes);
126
+ };
127
+ const resolveDtoDeclarationType = (checker, declaration) => {
128
+ const propertyTypes = [];
129
+ declaration.members.forEach(member => {
130
+ if (ts.isPropertyDeclaration(member)) {
131
+ const returnType = resolveDeclarationType(checker, member);
132
+ const [sanitizedReturnType] = getGenericTypeRef(returnType);
133
+ if (declarations[sanitizedReturnType]) {
134
+ handleReferenceType(checker, declarations[sanitizedReturnType]);
135
+ }
136
+ propertyTypes.push([member.name.getText() + '?', returnType]);
137
+ }
138
+ });
139
+ return formatBody(propertyTypes);
140
+ };
141
+ const getClassConstructorParameter = (declaration) => {
142
+ const constructorDeclaration = declaration.members.find(ts.isConstructorDeclaration);
143
+ const className = declaration.name.getText();
144
+ if (!constructorDeclaration) {
145
+ throw new Error(`${className} class without constructor arguments cannot be used as application service input.`);
146
+ }
147
+ const constructorParameters = constructorDeclaration.parameters.filter(ts.isParameter);
148
+ if (constructorParameters.length > 1) {
149
+ throw new Error(`${className} contains multiple constructor arguments. Use single object argument instead.`);
150
+ }
151
+ return constructorParameters[0];
152
+ };
153
+ const getReferencedType = (declaration) => {
154
+ return sanitizeTypeName(declaration.type?.getText());
155
+ };
156
+ const resolveDeclarationType = (checker, declaration) => {
157
+ const name = sanitizeTypeName(declaration.name.getText());
158
+ if (ts.isEnumDeclaration(declaration)) {
159
+ return 'string';
160
+ }
161
+ if (isBuiltInType(name)) {
162
+ return name;
163
+ }
164
+ if (ts.isClassDeclaration(declaration) && isDecoratedWith(declaration, 'Dto')) {
165
+ return resolveDtoDeclarationType(checker, declaration);
166
+ }
167
+ if (ts.isClassDeclaration(declaration)) {
168
+ // TODO: if it's class, always extract constructor parameter type as input type
169
+ return resolveDeclarationType(checker, getClassConstructorParameter(declaration));
170
+ }
171
+ if (ts.isInterfaceDeclaration(declaration)) {
172
+ return resolveInterfaceDeclarationType(checker, declaration);
173
+ }
174
+ const refType = getReferencedType(declaration);
175
+ if (!isDeclared(refType) && declarations[refType]) {
176
+ return resolveDeclarationType(checker, declarations[refType]);
177
+ }
178
+ return refType;
179
+ };
180
+ /**
181
+ * Resolves new type and creates declaration
182
+ */
183
+ const handleReferenceType = (checker, declaration) => {
184
+ const name = sanitizeTypeName(declaration.name.getText());
185
+ const type = resolveDeclarationType(checker, declaration);
186
+ if (type) {
187
+ if (ts.isInterfaceDeclaration(declaration) && declaration.getText().includes('extends')) {
188
+ const base = declaration.getText().split('extends ')[1].split(' ')[0];
189
+ registerOutputType(checker, base);
190
+ addTopLevelDeclaration(name, `export type ${getGenericName(declaration.getFullText())} = ${type} & ${base};`);
191
+ }
192
+ else {
193
+ addTopLevelDeclaration(name, `export type ${getGenericName(declaration.getFullText())} = ${type};`);
194
+ }
195
+ }
196
+ };
197
+ const getMethodParamsType = (checker, method) => {
198
+ const argumentTypes = [];
199
+ method.parameters.forEach(parameter => {
200
+ if (isDecoratedWith(parameter, 'Middleware') || isDecoratedWith(parameter, 'Ip')) {
201
+ // Remove middleware params from argument list
202
+ return;
203
+ }
204
+ const methodKey = parameter.name.getText();
205
+ const isFile = isDecoratedWith(parameter, 'File');
206
+ if (isFile) {
207
+ argumentTypes.push([methodKey, 'File']);
208
+ }
209
+ else if (ts.isTypeReferenceNode(parameter.type)) {
210
+ const valueObjectName = parameter.type.typeName.getText();
211
+ if (!declarations[valueObjectName]) {
212
+ throw new Error(`${valueObjectName}: Unregistered class value object`);
213
+ }
214
+ handleReferenceType(checker, declarations[valueObjectName]);
215
+ argumentTypes.push([methodKey, valueObjectName]);
216
+ }
217
+ });
218
+ return formatFunctionParameters(argumentTypes);
219
+ };
220
+ // Output
221
+ const appendToJSONSuffix = (typeDeclaration, typeName) => typeDeclaration.replace(typeName, typeName + 'JSON');
222
+ const getClassOutputType = (checker, declaration) => {
223
+ const typeName = declaration.name?.getText();
224
+ const serializableDeclaration = declaration.members.find(member => member.name?.getText() === ENTITY_SERIALIZE_METHOD);
225
+ if (!serializableDeclaration) {
226
+ throw new Error(`${typeName} is used in return statement but doesn't implement ${ENTITY_SERIALIZE_METHOD} method`);
227
+ }
228
+ const _type = checker.getTypeAtLocation(serializableDeclaration.name);
229
+ const toJSONSignatures = checker.getSignaturesOfType(_type, ts.SignatureKind.Call);
230
+ const toJSONReturnType = toJSONSignatures[0].getReturnType();
231
+ toJSONReturnType.getProperties().forEach(property => {
232
+ if (property.valueDeclaration && (ts.isPropertySignature(property.valueDeclaration) || ts.isPropertyAssignment(property.valueDeclaration))) {
233
+ const [name] = getGenericTypeRef(resolveDeclarationType(checker, property.valueDeclaration));
234
+ if (declarations[name]) {
235
+ if (ts.isClassDeclaration(declarations[name])) {
236
+ addTopLevelDeclaration(name, getClassOutputType(checker, declarations[name]));
237
+ }
238
+ else {
239
+ handleReferenceType(checker, declarations[name]);
240
+ }
241
+ }
242
+ else {
243
+ const resolvedType = sanitizeTypeName(checker.typeToString(property.type, property.valueDeclaration, ts.TypeFormatFlags.UseFullyQualifiedType));
244
+ if (declarations[resolvedType]) {
245
+ handleReferenceType(checker, declarations[resolvedType]);
246
+ }
247
+ }
248
+ }
249
+ });
250
+ const returnType = sanitizeTypeName(checker.typeToString(toJSONReturnType, serializableDeclaration, ts.TypeFormatFlags.UseFullyQualifiedType));
251
+ if (!isDeclared(returnType) && declarations[returnType]) {
252
+ return `export type ${typeName} = ${resolveDeclarationType(checker, declarations[returnType])}`;
253
+ }
254
+ return appendToJSONSuffix(`export type ${typeName} = ${returnType}`, typeName);
255
+ };
256
+ const getInterfaceOutputType = (checker, declaration) => {
257
+ declaration.members.forEach(member => {
258
+ if (ts.isPropertySignature(member)) {
259
+ const [name] = getGenericTypeRef(resolveDeclarationType(checker, member));
260
+ if (declarations[name]) {
261
+ if (ts.isClassDeclaration(declarations[name])) {
262
+ addTopLevelDeclaration(name, getClassOutputType(checker, declarations[name]));
263
+ }
264
+ else {
265
+ handleReferenceType(checker, declarations[name]);
266
+ }
267
+ }
268
+ }
269
+ });
270
+ return sanitizeTypeName(declaration.getFullText());
271
+ };
272
+ const registerOutputType = (checker, typeName) => {
273
+ const sanitizedTypeName = sanitizeTypeName(typeName);
274
+ const node = declarations[sanitizedTypeName];
275
+ if (!node) {
276
+ // Output type is primitive, does not have to be registered
277
+ return;
278
+ }
279
+ if (ts.isClassDeclaration(node)) {
280
+ addTopLevelDeclaration(node.name.getText() + 'JSON', getClassOutputType(checker, node));
281
+ }
282
+ else if (ts.isInterfaceDeclaration(node)) {
283
+ handleReferenceType(checker, node);
284
+ addTopLevelDeclaration(sanitizedTypeName, getInterfaceOutputType(checker, node));
285
+ }
286
+ else {
287
+ handleReferenceType(checker, node);
288
+ addTopLevelDeclaration(sanitizedTypeName, sanitizeTypeName(node.getFullText()));
289
+ }
290
+ };
291
+ const getMethodReturnType = (checker, method) => {
292
+ const type = checker.getTypeAtLocation(method.name);
293
+ const signatures = checker.getSignaturesOfType(type, ts.SignatureKind.Call);
294
+ const returnType = sanitizeTypeName(checker.typeToString(signatures[0].getReturnType(), method, ts.TypeFormatFlags.UseFullyQualifiedType));
295
+ const chunks = getGenericTypeRef(returnType);
296
+ chunks.forEach(chunk => {
297
+ registerOutputType(checker, chunk);
298
+ });
299
+ const lastChunk = chunks[chunks.length - 1];
300
+ if (declarations[lastChunk] && ts.isClassDeclaration(declarations[lastChunk])) {
301
+ return appendToJSONSuffix(returnType, lastChunk);
302
+ }
303
+ return returnType;
304
+ };
305
+ // Application service
306
+ const handleApplicationService = (checker, moduleName, appService, alias) => {
307
+ const appServiceName = alias || appService.name.escapedText;
308
+ if (!registeredModules[moduleName][appServiceName]) {
309
+ registeredModules[moduleName][appServiceName] = {};
310
+ }
311
+ appService.members
312
+ .filter((member) => member.kind === ts.SyntaxKind.MethodDeclaration)
313
+ .filter(member => member.modifiers?.some(modifier => modifier.kind === ts.SyntaxKind.PublicKeyword))
314
+ .forEach((member) => {
315
+ const paramsType = getMethodParamsType(checker, member);
316
+ const returnType = getMethodReturnType(checker, member);
317
+ const methodType = `${paramsType} => ${returnType}`;
318
+ const methodName = member.name.escapedText;
319
+ registeredModules[moduleName][appServiceName][methodName] = methodType;
320
+ log('app service method: ', methodName, ' ', methodType);
321
+ });
322
+ };
323
+ // Application module
324
+ const handleAppModule = (checker, appModule) => {
325
+ const moduleName = appModule.name.escapedText;
326
+ registeredModules[moduleName] = {};
327
+ appModule.members
328
+ .filter((member) => member.kind === ts.SyntaxKind.GetAccessor)
329
+ .forEach((member) => {
330
+ member.body?.statements?.forEach(stmt => {
331
+ if (ts.isReturnStatement(stmt) && ts.isNewExpression(stmt.expression)) {
332
+ const identifier = stmt.expression;
333
+ const serviceNode = declarations[identifier.expression.escapedText];
334
+ if (serviceNode && isDecoratedWith(serviceNode, APP_SERVICE_DECORATOR)) {
335
+ log('app service: ', identifier.expression.escapedText);
336
+ const appServiceDeclaration = declarations[identifier.expression.escapedText];
337
+ handleApplicationService(checker, moduleName, appServiceDeclaration);
338
+ serviceNode.heritageClauses?.forEach(heritageClause => {
339
+ heritageClause.types.forEach(type => {
340
+ if (ts.isIdentifier(type.expression)) {
341
+ const extensionCandidate = type.expression.escapedText;
342
+ if (declarations[extensionCandidate] && ts.isClassDeclaration(declarations[extensionCandidate])) {
343
+ log('app service extension: ', extensionCandidate);
344
+ handleApplicationService(checker, moduleName, declarations[extensionCandidate], appServiceDeclaration.name?.escapedText);
345
+ }
346
+ }
347
+ });
348
+ });
349
+ }
350
+ }
351
+ });
352
+ });
353
+ };
354
+ // Helpers
355
+ const isDecoratedWith = (stmt, expectedName) => {
356
+ return (ts.getDecorators(stmt) || []).some(decorator => {
357
+ const name = decorator.expression.escapedText || decorator.expression.expression.escapedText;
358
+ return decorator.kind === ts.SyntaxKind.Decorator && name === expectedName;
359
+ });
360
+ };
361
+ //# sourceMappingURL=generate-client-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-client-types.js","sourceRoot":"","sources":["../src/generate-client-types.ts"],"names":[],"mappings":";;;;AAAA,uDAAiC;AACjC,qCAAmD;AAEnD,MAAM,oBAAoB,GAAG,iBAAU,CAAC,IAAI,CAAA;AAC5C,MAAM,qBAAqB,GAAG,iBAAU,CAAC,IAAI,CAAA;AAC7C,MAAM,uBAAuB,GAAG,QAAQ,CAAA;AAExC,MAAM,aAAa,GAAG,CAAC,OAAe,EAAW,EAAE;IACjD,IAAI;QACF,IAAI,CAAC,OAAO,CAAC,CAAA;QACb,OAAO,IAAI,CAAA;KACZ;IAAC,MAAM;QACN,OAAO,KAAK,CAAA;KACb;AACH,CAAC,CAAA;AAED,MAAM,GAAG,GAAG,CAAC,GAAG,IAAyB,EAAE,EAAE;IAC3C,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,MAAM,EAAE;QAChC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;KACrB;AACH,CAAC,CAAA;AAED,GAAG,CAAC,wBAAwB,EAAE,oBAAoB,CAAC,CAAA;AACnD,GAAG,CAAC,yBAAyB,EAAE,qBAAqB,CAAC,CAAA;AACrD,GAAG,CAAC,2BAA2B,EAAE,uBAAuB,CAAC,CAAA;AAMzD,MAAM,iBAAiB,GAAQ,EAAE,CAAA;AACjC,MAAM,YAAY,GAAgC,EAAE,CAAA;AAEpD,MAAM,WAAW,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAExE,IAAI,KAAK,GAAa,CAAC,6BAA6B,CAAC,CAAA;AACrD,MAAM,iBAAiB,GAAG,IAAI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AAE;IACvE,OAAO,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QACrD,MAAM,IAAI,GAAI,SAAS,CAAC,UAAkB,CAAC,WAAW,IAAK,SAAS,CAAC,UAAkB,CAAC,UAAU,CAAC,WAAW,CAAA;QAC9G,OAAO,SAAS,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,SAAS,IAAI,IAAI,KAAK,YAAY,CAAA;IAC5E,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './client-config';
2
+ export * from './generate-client-types';
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./client-config"), exports);
5
+ tslib_1.__exportStar(require("./generate-client-types"), exports);
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,0DAA+B;AAC/B,kEAAuC"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@pjts/schema",
3
+ "version": "0.0.109",
4
+ "description": "Piotr Józefów DDD utility package",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "author": "Piotr Józefów",
8
+ "license": "MIT",
9
+ "engines": {
10
+ "node": "^18.14.0"
11
+ },
12
+ "engineStrict": true,
13
+ "scripts": {
14
+ "lint": "eslint src/ --ext .js,.jsx,.ts,.tsx",
15
+ "test": "NODE_ENV=test jest --coverage=false --verbose",
16
+ "test:watch": "NODE_ENV=test jest --coverage=false --watchAll --testNamePattern=",
17
+ "test:coverage": "npm test --collectCoverage",
18
+ "build": "rm -rf ./dist && tsc",
19
+ "package": "npm run build && npm publish --access=public",
20
+ "prepare": "npm install @pjts/fastify@latest & npm version patch"
21
+ },
22
+ "bin": {
23
+ "pjx-config": "./scripts/run-build-config.js",
24
+ "pjx-types": "./scripts/run-build-types.js"
25
+ },
26
+ "devDependencies": {
27
+ "@pjts/fastify": "^0.0.77",
28
+ "@types/jest": "29.4.0",
29
+ "@types/node": "18.13.0",
30
+ "jest": "29.4.2",
31
+ "prettier": "2.8.4",
32
+ "ts-jest": "29.0.5",
33
+ "ts-node": "10.9.1",
34
+ "tsconfig-paths": "3.11.0",
35
+ "typescript": "4.9.5"
36
+ },
37
+ "dependencies": {
38
+ "@types/isomorphic-fetch": "^0.0.36",
39
+ "isomorphic-fetch": "^3.0.0"
40
+ },
41
+ "publishConfig": {
42
+ "registry": "https://registry.npmjs.org"
43
+ }
44
+ }
@@ -0,0 +1,32 @@
1
+ #! /usr/bin/env node
2
+ const { buildClientConfig } = require('@pjts/schema')
3
+ const path = require('path')
4
+ const fs = require('fs')
5
+
6
+ const projectPath = __dirname.split('node_modules')[0]
7
+ const configPath = path.join(projectPath, process.argv[2] || './pjx.config')
8
+ let pjxConfig;
9
+ try {
10
+ pjxConfig = require(configPath)
11
+ } catch {
12
+ console.error(`pjx.config.js configuration file not found at "${configPath}"`)
13
+ process.exit(1)
14
+ }
15
+
16
+ const modules = pjxConfig.modules.map(appModule => {
17
+ const filePath = path.join(projectPath, pjxConfig.rootPath, appModule.path)
18
+ return new (require(filePath)[appModule.name])({})
19
+ })
20
+
21
+ console.log(`PJX generating config:`);
22
+ modules.forEach(_module => {
23
+ const config = buildClientConfig(_module)
24
+
25
+ fs.writeFileSync(path.join(projectPath, `${pjxConfig.outputPath}/${_module.constructor.name}.json`), JSON.stringify(config, null, 2))
26
+
27
+ console.log(`- ${_module.constructor.name}.json`)
28
+ })
29
+
30
+ console.log(`Done`);
31
+
32
+ process.exit(0)
@@ -0,0 +1,35 @@
1
+ #! /usr/bin/env node
2
+ const { buildClientTypes } = require('@pjts/schema')
3
+ const path = require('path')
4
+ const fs = require('fs')
5
+
6
+ const projectPath = __dirname.split('node_modules')[0]
7
+ const configPath = path.join(projectPath, process.argv[2] || './pjx.config')
8
+ let pjxConfig;
9
+ try {
10
+ pjxConfig = require(configPath)
11
+ } catch {
12
+ console.error(`pjx.config.js configuration file not found at "${configPath}"`)
13
+ process.exit(1)
14
+ }
15
+
16
+ const { compilerOptions } = require(path.join(projectPath, pjxConfig.tsconfigPath || 'tsconfig.json'))
17
+
18
+ const rootNames = pjxConfig.modules.map(appModule => path.join(projectPath, pjxConfig.rootPath, appModule.path))
19
+
20
+ const typesystem = buildClientTypes(rootNames,
21
+ [
22
+ 'src',
23
+ '@piotrjozefow'
24
+ ],
25
+ {
26
+ ...compilerOptions,
27
+ noErrorTruncation: true,
28
+ }
29
+ )
30
+
31
+ fs.writeFileSync(path.join(projectPath, `${pjxConfig.outputPath}/types.d.ts`), typesystem)
32
+
33
+ console.log(`Done`);
34
+
35
+ process.exit(0)
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ const {exec} = require('child_process');
3
+ const path = require('path')
4
+
5
+ const tsNodePath = './node_modules/.bin/ts-node'
6
+ const scriptPath = path.resolve(__dirname, './build-config.ts')
7
+
8
+ exec(tsNodePath + ' -r tsconfig-paths/register ' + scriptPath + ' "$@"', (err, stdout, stderr) => {
9
+ if (err) {
10
+ console.error(err)
11
+ process.exit(1)
12
+ return;
13
+ }
14
+ console.log(stdout);
15
+ process.exit(0)
16
+ })
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ const {exec} = require('child_process');
3
+ const path = require('path')
4
+
5
+ const tsNodePath = './node_modules/.bin/ts-node'
6
+ const scriptPath = path.resolve(__dirname, './build-types.ts')
7
+
8
+ exec(tsNodePath + ' -r tsconfig-paths/register ' + scriptPath + ' "$@"', (err, stdout, stderr) => {
9
+ if (err) {
10
+ console.error(err)
11
+ process.exit(1)
12
+ return;
13
+ }
14
+ console.log(stdout);
15
+ process.exit(0)
16
+ })