@tsed/cli-plugin-typegraphql 3.20.13

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.
@@ -0,0 +1,5 @@
1
+ import { ProjectPackageJson } from "@tsed/cli-core";
2
+ export declare class TypeGraphqlModule {
3
+ packageJson: ProjectPackageJson;
4
+ install(): void;
5
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeGraphqlModule = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const cli_core_1 = require("@tsed/cli-core");
6
+ const di_1 = require("@tsed/di");
7
+ const TypeGraphqlInitHook_1 = require("./hooks/TypeGraphqlInitHook");
8
+ let TypeGraphqlModule = class TypeGraphqlModule {
9
+ install() {
10
+ this.packageJson.addDependencies({
11
+ "@tsed/graphql": "{{tsedVersion}}",
12
+ "apollo-datasource": "^3.3.1",
13
+ "apollo-datasource-rest": "^3.5.1",
14
+ "apollo-server-core": "^3.6.2",
15
+ "type-graphql": "^1.1.1",
16
+ "class-validator": "^0.13.2",
17
+ graphql: "^15.7.2"
18
+ });
19
+ this.packageJson.addDevDependencies({
20
+ "@types/validator": "latest",
21
+ "apollo-server-testing": "latest"
22
+ });
23
+ }
24
+ };
25
+ tslib_1.__decorate([
26
+ (0, di_1.Inject)(),
27
+ tslib_1.__metadata("design:type", cli_core_1.ProjectPackageJson)
28
+ ], TypeGraphqlModule.prototype, "packageJson", void 0);
29
+ tslib_1.__decorate([
30
+ (0, cli_core_1.OnAdd)("@tsed/cli-plugin-typegraphql"),
31
+ tslib_1.__metadata("design:type", Function),
32
+ tslib_1.__metadata("design:paramtypes", []),
33
+ tslib_1.__metadata("design:returntype", void 0)
34
+ ], TypeGraphqlModule.prototype, "install", null);
35
+ TypeGraphqlModule = tslib_1.__decorate([
36
+ (0, cli_core_1.Module)({
37
+ imports: [TypeGraphqlInitHook_1.TypeGraphqlInitHook]
38
+ })
39
+ ], TypeGraphqlModule);
40
+ exports.TypeGraphqlModule = TypeGraphqlModule;
41
+ //# sourceMappingURL=TypeGraphqlModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypeGraphqlModule.js","sourceRoot":"","sources":["../src/TypeGraphqlModule.ts"],"names":[],"mappings":";;;;AAAA,6CAAiE;AACjE,iCAAgC;AAChC,qEAAgE;AAKhE,IAAa,iBAAiB,GAA9B,MAAa,iBAAiB;IAK5B,OAAO;QACL,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC;YAC/B,eAAe,EAAE,iBAAiB;YAClC,mBAAmB,EAAE,QAAQ;YAC7B,wBAAwB,EAAE,QAAQ;YAClC,oBAAoB,EAAE,QAAQ;YAC9B,cAAc,EAAE,QAAQ;YACxB,iBAAiB,EAAE,SAAS;YAC5B,OAAO,EAAE,SAAS;SACnB,CAAC,CAAC;QACH,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC;YAClC,kBAAkB,EAAE,QAAQ;YAC5B,uBAAuB,EAAE,QAAQ;SAClC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAlBC;IADC,IAAA,WAAM,GAAE;sCACI,6BAAkB;sDAAC;AAGhC;IADC,IAAA,gBAAK,EAAC,8BAA8B,CAAC;;;;gDAerC;AAnBU,iBAAiB;IAH7B,IAAA,iBAAM,EAAC;QACN,OAAO,EAAE,CAAC,yCAAmB,CAAC;KAC/B,CAAC;GACW,iBAAiB,CAoB7B;AApBY,8CAAiB","sourcesContent":["import {Module, OnAdd, ProjectPackageJson} from \"@tsed/cli-core\";\nimport {Inject} from \"@tsed/di\";\nimport {TypeGraphqlInitHook} from \"./hooks/TypeGraphqlInitHook\";\n\n@Module({\n imports: [TypeGraphqlInitHook]\n})\nexport class TypeGraphqlModule {\n @Inject()\n packageJson: ProjectPackageJson;\n\n @OnAdd(\"@tsed/cli-plugin-typegraphql\")\n install() {\n this.packageJson.addDependencies({\n \"@tsed/graphql\": \"{{tsedVersion}}\",\n \"apollo-datasource\": \"^3.3.1\",\n \"apollo-datasource-rest\": \"^3.5.1\",\n \"apollo-server-core\": \"^3.6.2\",\n \"type-graphql\": \"^1.1.1\",\n \"class-validator\": \"^0.13.2\",\n graphql: \"^15.7.2\"\n });\n this.packageJson.addDevDependencies({\n \"@types/validator\": \"latest\",\n \"apollo-server-testing\": \"latest\"\n });\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import { InitCmdContext } from "@tsed/cli";
2
+ import { ProjectPackageJson, RootRendererService, SrcRendererService } from "@tsed/cli-core";
3
+ export declare class TypeGraphqlInitHook {
4
+ protected packageJson: ProjectPackageJson;
5
+ protected rootRenderer: RootRendererService;
6
+ protected srcRenderer: SrcRendererService;
7
+ onExec(ctx: InitCmdContext): {
8
+ title: string;
9
+ task: () => Promise<import("rxjs").Observable<unknown>>;
10
+ }[];
11
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TypeGraphqlInitHook = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const cli_core_1 = require("@tsed/cli-core");
6
+ const di_1 = require("@tsed/di");
7
+ const templateDir_1 = require("../utils/templateDir");
8
+ let TypeGraphqlInitHook = class TypeGraphqlInitHook {
9
+ onExec(ctx) {
10
+ return [
11
+ {
12
+ title: "Generate files",
13
+ task: async () => this.rootRenderer.renderAll([
14
+ "/src/datasources/index.ts",
15
+ "/src/datasources/MyDataSource",
16
+ "/src/resolvers/recipes/Recipe.ts",
17
+ "/src/resolvers/recipes/RecipeNotFoundError.ts",
18
+ "/src/resolvers/recipes/RecipeResolver.ts",
19
+ "/src/resolvers/index.ts"
20
+ ], ctx, {
21
+ templateDir: `${templateDir_1.TEMPLATE_DIR}/init`
22
+ })
23
+ }
24
+ ];
25
+ }
26
+ };
27
+ tslib_1.__decorate([
28
+ (0, cli_core_1.Inject)(),
29
+ tslib_1.__metadata("design:type", cli_core_1.ProjectPackageJson)
30
+ ], TypeGraphqlInitHook.prototype, "packageJson", void 0);
31
+ tslib_1.__decorate([
32
+ (0, cli_core_1.Inject)(),
33
+ tslib_1.__metadata("design:type", cli_core_1.RootRendererService)
34
+ ], TypeGraphqlInitHook.prototype, "rootRenderer", void 0);
35
+ tslib_1.__decorate([
36
+ (0, cli_core_1.Inject)(),
37
+ tslib_1.__metadata("design:type", cli_core_1.SrcRendererService)
38
+ ], TypeGraphqlInitHook.prototype, "srcRenderer", void 0);
39
+ tslib_1.__decorate([
40
+ (0, cli_core_1.OnExec)("init"),
41
+ tslib_1.__metadata("design:type", Function),
42
+ tslib_1.__metadata("design:paramtypes", [Object]),
43
+ tslib_1.__metadata("design:returntype", void 0)
44
+ ], TypeGraphqlInitHook.prototype, "onExec", null);
45
+ TypeGraphqlInitHook = tslib_1.__decorate([
46
+ (0, di_1.Injectable)()
47
+ ], TypeGraphqlInitHook);
48
+ exports.TypeGraphqlInitHook = TypeGraphqlInitHook;
49
+ //# sourceMappingURL=TypeGraphqlInitHook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TypeGraphqlInitHook.js","sourceRoot":"","sources":["../../src/hooks/TypeGraphqlInitHook.ts"],"names":[],"mappings":";;;;AACA,6CAA2G;AAC3G,iCAAoC;AACpC,sDAAkD;AAGlD,IAAa,mBAAmB,GAAhC,MAAa,mBAAmB;IAW9B,MAAM,CAAC,GAAmB;QACxB,OAAO;YACL;gBACE,KAAK,EAAE,gBAAgB;gBACvB,IAAI,EAAE,KAAK,IAAI,EAAE,CACf,IAAI,CAAC,YAAY,CAAC,SAAS,CACzB;oBACE,2BAA2B;oBAC3B,+BAA+B;oBAC/B,kCAAkC;oBAClC,+CAA+C;oBAC/C,0CAA0C;oBAC1C,yBAAyB;iBAC1B,EACD,GAAG,EACH;oBACE,WAAW,EAAE,GAAG,0BAAY,OAAO;iBACpC,CACF;aACJ;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA/BC;IADC,IAAA,iBAAM,GAAE;sCACc,6BAAkB;wDAAC;AAG1C;IADC,IAAA,iBAAM,GAAE;sCACe,8BAAmB;yDAAC;AAG5C;IADC,IAAA,iBAAM,GAAE;sCACc,6BAAkB;wDAAC;AAG1C;IADC,IAAA,iBAAM,EAAC,MAAM,CAAC;;;;iDAsBd;AAhCU,mBAAmB;IAD/B,IAAA,eAAU,GAAE;GACA,mBAAmB,CAiC/B;AAjCY,kDAAmB","sourcesContent":["import {InitCmdContext} from \"@tsed/cli\";\nimport {Inject, OnExec, ProjectPackageJson, RootRendererService, SrcRendererService} from \"@tsed/cli-core\";\nimport {Injectable} from \"@tsed/di\";\nimport {TEMPLATE_DIR} from \"../utils/templateDir\";\n\n@Injectable()\nexport class TypeGraphqlInitHook {\n @Inject()\n protected packageJson: ProjectPackageJson;\n\n @Inject()\n protected rootRenderer: RootRendererService;\n\n @Inject()\n protected srcRenderer: SrcRendererService;\n\n @OnExec(\"init\")\n onExec(ctx: InitCmdContext) {\n return [\n {\n title: \"Generate files\",\n task: async () =>\n this.rootRenderer.renderAll(\n [\n \"/src/datasources/index.ts\",\n \"/src/datasources/MyDataSource\",\n \"/src/resolvers/recipes/Recipe.ts\",\n \"/src/resolvers/recipes/RecipeNotFoundError.ts\",\n \"/src/resolvers/recipes/RecipeResolver.ts\",\n \"/src/resolvers/index.ts\"\n ],\n ctx,\n {\n templateDir: `${TEMPLATE_DIR}/init`\n }\n )\n }\n ];\n }\n}\n"]}
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { TypeGraphqlModule } from "./TypeGraphqlModule";
2
+ export * from "./hooks/TypeGraphqlInitHook";
3
+ export default TypeGraphqlModule;
package/lib/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const TypeGraphqlModule_1 = require("./TypeGraphqlModule");
5
+ tslib_1.__exportStar(require("./hooks/TypeGraphqlInitHook"), exports);
6
+ exports.default = TypeGraphqlModule_1.TypeGraphqlModule;
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAAsD;AAEtD,sEAA4C;AAE5C,kBAAe,qCAAiB,CAAC","sourcesContent":["import {TypeGraphqlModule} from \"./TypeGraphqlModule\";\n\nexport * from \"./hooks/TypeGraphqlInitHook\";\n\nexport default TypeGraphqlModule;\n"]}
@@ -0,0 +1 @@
1
+ export declare const TEMPLATE_DIR: string;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TEMPLATE_DIR = void 0;
4
+ const path_1 = require("path");
5
+ exports.TEMPLATE_DIR = (0, path_1.resolve)(__dirname, "..", "..", "templates");
6
+ //# sourceMappingURL=templateDir.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templateDir.js","sourceRoot":"","sources":["../../src/utils/templateDir.ts"],"names":[],"mappings":";;;AAAA,+BAA6B;AAEhB,QAAA,YAAY,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import {resolve} from \"path\";\n\nexport const TEMPLATE_DIR = resolve(__dirname, \"..\", \"..\", \"templates\");\n"]}
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@tsed/cli-plugin-typegraphql",
3
+ "version": "3.20.13",
4
+ "main": "./lib/index.js",
5
+ "typings": "./lib/index.d.ts",
6
+ "description": "Ts.ED CLI plugin. Add TypeGraphql support.",
7
+ "scripts": {
8
+ "build": "tsc --build tsconfig.compile.json",
9
+ "build:doc": "tsc --build tsconfig.doc.json"
10
+ },
11
+ "files": [
12
+ "lib",
13
+ "templates"
14
+ ],
15
+ "dependencies": {
16
+ "tslib": "2.3.1"
17
+ },
18
+ "devDependencies": {
19
+ "@tsed/cli": "3.20.13",
20
+ "@tsed/cli-core": "3.20.13"
21
+ },
22
+ "peerDependencies": {
23
+ "@tsed/cli": "^3.20.13",
24
+ "@tsed/cli-core": "^3.20.13"
25
+ },
26
+ "repository": "https://github.com/tsedio/tsed-cli",
27
+ "bugs": {
28
+ "url": "https://github.com/tsedio/tsed-cli/issues"
29
+ },
30
+ "homepage": "https://github.com/tsedio/tsed-cli/tree/master/packages/cli-plugin-typegraphql",
31
+ "author": "Romain Lenzotti",
32
+ "license": "MIT"
33
+ }
package/readme.md ADDED
@@ -0,0 +1,73 @@
1
+ <p style="text-align: center" align="center">
2
+ <a href="https://tsed.io" target="_blank"><img src="https://tsed.io/tsed-og.png" width="200" alt="Ts.ED logo"/></a>
3
+ </p>
4
+
5
+ <div align="center">
6
+ <h1>@tsed/cli-plugin-oidc-provider</h1>
7
+
8
+ [![Build & Release](https://github.com/tsedio/tsed-cli/workflows/Build%20&%20Release/badge.svg?branch=master)](https://github.com/tsedio/tsed-cli/actions?query=workflow%3A%22Build+%26+Release%22)
9
+ [![PR Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/tsedio/tsed-cli/blob/master/CONTRIBUTING.md)
10
+ [![Coverage Status](https://coveralls.io/repos/github/tsedio/tsed-cli/badge.svg?branch=master)](https://coveralls.io/github/tsedio/tsed-cli?branch=master)
11
+ [![npm version](https://badge.fury.io/js/%40tsed%2Fcli.svg)](https://badge.fury.io/js/%40tsed%2Fcli)
12
+ [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
13
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
14
+ [![backers](https://opencollective.com/tsed/tiers/badge.svg)](https://opencollective.com/tsed)
15
+
16
+
17
+ <br />
18
+ <div align="center">
19
+ <a href="https://cli.tsed.io/">Website</a>
20
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
21
+ <a href="https://cli.tsed.io/getting-started.html">Getting started</a>
22
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
23
+ <a href="https://api.tsed.io/rest/slack/tsedio/tsed">Slack</a>
24
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
25
+ <a href="https://twitter.com/TsED_io">Twitter</a>
26
+ </div>
27
+ <hr />
28
+ </div>
29
+
30
+
31
+ [![Build & Release](https://github.com/tsedio/tsed-cli/workflows/Build%20&%20Release/badge.svg?branch=master)](https://github.com/tsedio/tsed-cli/actions?query=workflow%3A%22Build+%26+Release%22)
32
+
33
+ > Plugin to generate an OIDC project with Ts.ED
34
+
35
+ ## Features
36
+
37
+ Please refer to the [documentation](https://cli.tsed.io/) for more details.
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ npm install @tsed/cli-plugin-oidc-provider
43
+ ```
44
+
45
+ ## Contributors
46
+
47
+ Please read [contributing guidelines here](https://tsed.io/CONTRIBUTING.html)
48
+
49
+ <a href="https://github.com/tsedio/ts-express-decorators/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>
50
+
51
+
52
+ ## Backers
53
+
54
+ Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/tsed#backer)]
55
+
56
+ <a href="https://opencollective.com/tsed#backers" target="_blank"><img src="https://opencollective.com/tsed/tiers/backer.svg?width=890"></a>
57
+
58
+
59
+ ## Sponsors
60
+
61
+ Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/tsed#sponsor)]
62
+
63
+ ## License
64
+
65
+ The MIT License (MIT)
66
+
67
+ Copyright (c) 2016 - 2018 Romain Lenzotti
68
+
69
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
70
+
71
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ import {DataSourceService} from "@tsed/typegraphql";
2
+ import {RESTDataSource} from "apollo-datasource-rest";
3
+
4
+ @DataSourceService()
5
+ export class MyDataSource extends RESTDataSource {
6
+ constructor() {
7
+ super();
8
+ this.baseURL = "http://localhost:8001";
9
+ }
10
+
11
+ willSendRequest(request: any) {
12
+ request.headers.set("Authorization", this.context.token);
13
+ }
14
+
15
+ getMyData(id: string) {
16
+ return this.get(`/rest/calendars/${id}`);
17
+ }
18
+ }
@@ -0,0 +1 @@
1
+ export * from "./MyDataSource";
@@ -0,0 +1,3 @@
1
+ export * from "./recipes/Recipe";
2
+ export * from "./recipes/RecipeNotFoundError";
3
+ export * from "./recipes/RecipeResolver";
@@ -0,0 +1,27 @@
1
+ import {Field, ID, ObjectType} from "type-graphql";
2
+
3
+ @ObjectType({description: "Object representing cooking recipe"})
4
+ export class Recipe {
5
+ @Field((type) => ID)
6
+ id: string;
7
+
8
+ @Field()
9
+ title: string;
10
+
11
+ @Field({nullable: true})
12
+ description?: string;
13
+
14
+ @Field()
15
+ creationDate: Date;
16
+
17
+ @Field((type) => [String])
18
+ ingredients: string[];
19
+
20
+ constructor(options: Partial<Recipe> = {}) {
21
+ options.id && (this.id = options.id);
22
+ options.title && (this.title = options.title);
23
+ options.description && (this.description = options.description);
24
+ options.creationDate && (this.creationDate = options.creationDate);
25
+ options.ingredients && (this.ingredients = options.ingredients);
26
+ }
27
+ }
@@ -0,0 +1,7 @@
1
+ import {NotFound} from "@tsed/exceptions";
2
+
3
+ export class RecipeNotFoundError extends NotFound {
4
+ constructor(private id: string) {
5
+ super("Recipe not found");
6
+ }
7
+ }
@@ -0,0 +1,26 @@
1
+ import {ResolverService} from "@tsed/typegraphql";
2
+ import {Arg, Query} from "type-graphql";
3
+ import {RecipeService} from "../../services/RecipeService";
4
+ import {Recipe} from "./Recipe";
5
+ import {RecipeNotFoundError} from "./RecipeNotFoundError";
6
+
7
+ @ResolverService(Recipe)
8
+ export class RecipeResolver {
9
+ constructor(private recipeService: RecipeService) {}
10
+
11
+ @Query((returns) => Recipe)
12
+ async recipe(@Arg("id") id: string) {
13
+ const recipe = await this.recipeService.findById(id);
14
+
15
+ if (recipe === undefined) {
16
+ throw new RecipeNotFoundError(id);
17
+ }
18
+
19
+ return recipe;
20
+ }
21
+
22
+ @Query((returns) => [Recipe], {description: "Get all the recipes from around the world "})
23
+ async recipes(): Promise<Recipe[]> {
24
+ return this.recipeService.findAll({});
25
+ }
26
+ }