@orion-js/components 3.11.15 → 4.0.0-alpha.3

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 CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@orion-js/components",
3
- "version": "3.11.15",
4
- "main": "lib/index.js",
3
+ "version": "4.0.0-alpha.3",
4
+ "main": "./dist/index.cjs",
5
5
  "author": "nicolaslopezj",
6
6
  "license": "MIT",
7
7
  "scripts": {
8
- "test": "ORION_DEV=1 jest",
8
+ "test": "bun test",
9
9
  "prepare": "yarn run build",
10
- "clean": "rm -rf ./lib",
11
- "build": "yarn run clean && tsc",
10
+ "clean": "rm -rf ./dist",
11
+ "build": "bun run build.ts",
12
12
  "watch": "tsc -w",
13
- "upgrade-interactive": "yarn upgrade-interactive"
13
+ "upgrade-interactive": "yarn upgrade-interactive",
14
+ "dev": "bun --watch src/index.ts"
14
15
  },
15
16
  "peerDependencies": {
16
17
  "@orion-js/dogs": "^3.2.33",
@@ -22,21 +23,30 @@
22
23
  "@orion-js/services": "^3.2.21"
23
24
  },
24
25
  "devDependencies": {
25
- "@orion-js/dogs": "^3.11.15",
26
- "@orion-js/echoes": "^3.11.15",
27
- "@orion-js/graphql": "^3.11.15",
28
- "@orion-js/helpers": "^3.11.15",
29
- "@orion-js/http": "^3.11.15",
30
- "@orion-js/models": "^3.11.15",
31
- "@orion-js/services": "^3.11.15",
32
- "@types/jest": "^29.2.5",
33
- "jest": "29.3.1",
26
+ "@orion-js/dogs": "^4.0.0-alpha.2",
27
+ "@orion-js/echoes": "^4.0.0-alpha.2",
28
+ "@orion-js/graphql": "^4.0.0-alpha.2",
29
+ "@orion-js/helpers": "^4.0.0-alpha.2",
30
+ "@orion-js/http": "^4.0.0-alpha.2",
31
+ "@orion-js/models": "^4.0.0-alpha.2",
32
+ "@orion-js/services": "^4.0.0-alpha.2",
34
33
  "reflect-metadata": "0.1.13",
35
- "ts-jest": "29.0.3",
36
- "typescript": "^4.9.4"
34
+ "typescript": "^5.4.5",
35
+ "@types/bun": "^1.2.4"
37
36
  },
38
37
  "publishConfig": {
39
38
  "access": "public"
40
39
  },
41
- "gitHead": "a5c95d9fd18f779c834644eb757928cdb840643c"
42
- }
40
+ "gitHead": "9fd28b6f6b348cebc9f0dc207805647969277372",
41
+ "type": "module",
42
+ "module": "./dist/index.js",
43
+ "types": "./dist/index.d.ts",
44
+ "exports": {
45
+ "types": "./dist/index.d.ts",
46
+ "import": "./dist/index.js",
47
+ "require": "./dist/index.cjs"
48
+ },
49
+ "files": [
50
+ "dist"
51
+ ]
52
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Orionjs Team
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
package/jest.config.js DELETED
@@ -1,8 +0,0 @@
1
- module.exports = {
2
- roots: ['./src'],
3
- testMatch: ['**/__tests__/**/*.+(ts|tsx|js)', '**/?(*.)+(spec|test).+(ts|tsx|js)'],
4
- transform: {
5
- '^.+\\.(ts|tsx)$': 'ts-jest'
6
- },
7
- verbose: true
8
- }
@@ -1,30 +0,0 @@
1
- export type EchoesController = {
2
- new (...args: any[]): any;
3
- };
4
- export type ResolversController = {
5
- new (...args: any[]): any;
6
- };
7
- export type SubscriptionsController = {
8
- new (...args: any[]): any;
9
- };
10
- export type JobsController = {
11
- new (...args: any[]): any;
12
- };
13
- export type RoutesController = {
14
- new (...args: any[]): any;
15
- };
16
- export type ModelResolversController = {
17
- new (...args: any[]): any;
18
- };
19
- export interface ComponentControllers {
20
- echoes?: EchoesController[];
21
- routes?: RoutesController[];
22
- jobs?: JobsController[];
23
- resolvers?: ResolversController[];
24
- subscriptions?: SubscriptionsController[];
25
- modelResolvers?: ModelResolversController[];
26
- }
27
- export interface Component {
28
- controllers: ComponentControllers;
29
- }
30
- export declare function component(controllers: ComponentControllers): Component;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.component = void 0;
4
- function component(controllers) {
5
- return { controllers };
6
- }
7
- exports.component = component;
@@ -1 +0,0 @@
1
- export {};
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const _1 = require(".");
4
- describe('Components', () => {
5
- it('should force the correct type of component', () => {
6
- class ExampleEchoes {
7
- }
8
- (0, _1.component)({
9
- echoes: [ExampleEchoes]
10
- });
11
- });
12
- });
package/lib/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './components';
2
- export * from './mergeComponents';
package/lib/index.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./components"), exports);
18
- __exportStar(require("./mergeComponents"), exports);
@@ -1,16 +0,0 @@
1
- import { Component } from '../components';
2
- import { EchoesMap } from '@orion-js/echoes';
3
- import { OrionSubscriptionsMap, ModelsResolversMap } from '@orion-js/graphql';
4
- import { RoutesMap } from '@orion-js/http';
5
- import { JobsDefinition } from '@orion-js/dogs';
6
- import { GlobalResolversMap } from '@orion-js/models';
7
- export interface MergedComponentControllers {
8
- echoes: EchoesMap;
9
- resolvers: GlobalResolversMap;
10
- modelResolvers: ModelsResolversMap;
11
- subscriptions: OrionSubscriptionsMap;
12
- routes: RoutesMap;
13
- jobs: JobsDefinition;
14
- }
15
- export declare function mergeComponentControllers(component: Component): MergedComponentControllers;
16
- export declare function mergeComponents(components: Component[]): MergedComponentControllers;
@@ -1,126 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeComponents = exports.mergeComponentControllers = void 0;
4
- const echoes_1 = require("@orion-js/echoes");
5
- const graphql_1 = require("@orion-js/graphql");
6
- const http_1 = require("@orion-js/http");
7
- const dogs_1 = require("@orion-js/dogs");
8
- const helpers_1 = require("@orion-js/helpers");
9
- function mergeComponentControllers(component) {
10
- const echoes = {};
11
- if (component.controllers.echoes) {
12
- component.controllers.echoes.forEach(Controller => {
13
- const serviceEchoes = (0, echoes_1.getServiceEchoes)(Controller);
14
- for (const echoName in serviceEchoes) {
15
- const echo = serviceEchoes[echoName];
16
- echoes[echoName] = echo;
17
- }
18
- });
19
- }
20
- const resolvers = {};
21
- if (component.controllers.resolvers) {
22
- component.controllers.resolvers.forEach(Controller => {
23
- const serviceResolvers = (0, graphql_1.getServiceResolvers)(Controller);
24
- for (const resolverName in serviceResolvers) {
25
- const resolver = serviceResolvers[resolverName];
26
- resolvers[resolverName] = resolver;
27
- }
28
- });
29
- }
30
- const modelResolvers = {};
31
- if (component.controllers.modelResolvers) {
32
- component.controllers.modelResolvers.forEach(Controller => {
33
- const serviceModelResolvers = (0, graphql_1.getServiceModelResolvers)(Controller);
34
- for (const modelName in serviceModelResolvers) {
35
- const resolversForModel = serviceModelResolvers[modelName];
36
- modelResolvers[modelName] = modelResolvers[modelName] || {};
37
- for (const resolverName in resolversForModel) {
38
- modelResolvers[modelName][resolverName] = resolversForModel[resolverName];
39
- }
40
- }
41
- });
42
- }
43
- const subscriptions = {};
44
- if (component.controllers.subscriptions) {
45
- component.controllers.subscriptions.forEach(Controller => {
46
- const serviceResolvers = (0, graphql_1.getServiceSubscriptions)(Controller);
47
- for (const subsrcriptionName in serviceResolvers) {
48
- const subsrcription = serviceResolvers[subsrcriptionName];
49
- subscriptions[subsrcriptionName] = subsrcription;
50
- }
51
- });
52
- }
53
- const routes = {};
54
- if (component.controllers.routes) {
55
- component.controllers.routes.forEach(Controller => {
56
- const serviceRoutes = (0, http_1.getServiceRoutes)(Controller);
57
- for (const routeName in serviceRoutes) {
58
- const resolver = serviceRoutes[routeName];
59
- if (routes[routeName]) {
60
- routes[routeName + (0, helpers_1.generateId)()] = resolver;
61
- }
62
- else {
63
- routes[routeName] = resolver;
64
- }
65
- }
66
- });
67
- }
68
- const jobs = {};
69
- if (component.controllers.jobs) {
70
- component.controllers.jobs.forEach(Controller => {
71
- const serviceJobs = (0, dogs_1.getServiceJobs)(Controller);
72
- for (const jobName in serviceJobs) {
73
- const resolver = serviceJobs[jobName];
74
- jobs[jobName] = resolver;
75
- }
76
- });
77
- }
78
- return {
79
- echoes,
80
- resolvers,
81
- modelResolvers,
82
- subscriptions,
83
- routes,
84
- jobs
85
- };
86
- }
87
- exports.mergeComponentControllers = mergeComponentControllers;
88
- function mergeComponents(components) {
89
- const mergedControllers = {
90
- echoes: {},
91
- resolvers: {},
92
- modelResolvers: {},
93
- subscriptions: {},
94
- routes: {},
95
- jobs: {}
96
- };
97
- components.forEach(component => {
98
- const componentControllers = mergeComponentControllers(component);
99
- mergedControllers.echoes = {
100
- ...mergedControllers.echoes,
101
- ...componentControllers.echoes
102
- };
103
- mergedControllers.resolvers = {
104
- ...mergedControllers.resolvers,
105
- ...componentControllers.resolvers
106
- };
107
- mergedControllers.modelResolvers = {
108
- ...mergedControllers.modelResolvers,
109
- ...componentControllers.modelResolvers
110
- };
111
- mergedControllers.subscriptions = {
112
- ...mergedControllers.subscriptions,
113
- ...componentControllers.subscriptions
114
- };
115
- mergedControllers.routes = {
116
- ...mergedControllers.routes,
117
- ...componentControllers.routes
118
- };
119
- mergedControllers.jobs = {
120
- ...mergedControllers.jobs,
121
- ...componentControllers.jobs
122
- };
123
- });
124
- return mergedControllers;
125
- }
126
- exports.mergeComponents = mergeComponents;
@@ -1 +0,0 @@
1
- export {};
@@ -1,78 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const http_1 = require("@orion-js/http");
13
- const _1 = require(".");
14
- const components_1 = require("../components");
15
- describe('Merge components', () => {
16
- it('should return merged components', () => {
17
- let TestRoutes1 = class TestRoutes1 {
18
- async test() { }
19
- async test2() { }
20
- };
21
- __decorate([
22
- (0, http_1.Route)({ path: '/test', method: 'get' }),
23
- __metadata("design:type", Function),
24
- __metadata("design:paramtypes", []),
25
- __metadata("design:returntype", Promise)
26
- ], TestRoutes1.prototype, "test", null);
27
- __decorate([
28
- (0, http_1.Route)({ path: '/test', method: 'get' }),
29
- __metadata("design:type", Function),
30
- __metadata("design:paramtypes", []),
31
- __metadata("design:returntype", Promise)
32
- ], TestRoutes1.prototype, "test2", null);
33
- TestRoutes1 = __decorate([
34
- (0, http_1.Routes)()
35
- ], TestRoutes1);
36
- let TestRoutes2 = class TestRoutes2 {
37
- async test3() { }
38
- async test4() { }
39
- };
40
- __decorate([
41
- (0, http_1.Route)({ path: '/test', method: 'get' }),
42
- __metadata("design:type", Function),
43
- __metadata("design:paramtypes", []),
44
- __metadata("design:returntype", Promise)
45
- ], TestRoutes2.prototype, "test3", null);
46
- __decorate([
47
- (0, http_1.Route)({ path: '/test', method: 'get' }),
48
- __metadata("design:type", Function),
49
- __metadata("design:paramtypes", []),
50
- __metadata("design:returntype", Promise)
51
- ], TestRoutes2.prototype, "test4", null);
52
- TestRoutes2 = __decorate([
53
- (0, http_1.Routes)()
54
- ], TestRoutes2);
55
- const component1 = (0, components_1.component)({
56
- routes: [TestRoutes1, TestRoutes2]
57
- });
58
- const mergedComponent = (0, _1.mergeComponentControllers)(component1);
59
- const aRoute = {
60
- path: '/test',
61
- method: 'get',
62
- resolve: expect.any(Function)
63
- };
64
- expect(mergedComponent).toEqual({
65
- echoes: {},
66
- jobs: {},
67
- modelResolvers: {},
68
- resolvers: {},
69
- subscriptions: {},
70
- routes: {
71
- test: aRoute,
72
- test2: aRoute,
73
- test3: aRoute,
74
- test4: aRoute
75
- }
76
- });
77
- });
78
- });
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "strict": false,
4
- "outDir": "./lib",
5
- "rootDir": "./src",
6
- "module": "commonjs",
7
- "target": "es2020",
8
- "moduleResolution": "node",
9
- "lib": ["es2020"],
10
- "declaration": true,
11
-
12
- "esModuleInterop": true,
13
- "skipLibCheck": true,
14
- "forceConsistentCasingInFileNames": true,
15
-
16
- // required for ioc
17
- "experimentalDecorators": true,
18
- "emitDecoratorMetadata": true
19
- }
20
- }