nestia 2.1.0-dev.20220504 → 2.1.0-dev.20220505

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 (34) hide show
  1. package/.github/ISSUE_TEMPLATE/BUG_REPORT.md +42 -0
  2. package/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md +13 -0
  3. package/.github/ISSUE_TEMPLATE/QUESTION.md +11 -0
  4. package/.github/PULL_REQUEST_TEMPLATE.md +13 -0
  5. package/CODE_OF_CONDUCT.md +133 -0
  6. package/README.md +248 -2
  7. package/lib/analyses/ControllerAnalyzer.d.ts.map +1 -1
  8. package/lib/analyses/ControllerAnalyzer.js +3 -1
  9. package/lib/factories/CommentFactory.d.ts +5 -0
  10. package/lib/factories/CommentFactory.d.ts.map +1 -0
  11. package/lib/factories/CommentFactory.js +14 -0
  12. package/lib/factories/MetadataCollection.d.ts +14 -0
  13. package/lib/factories/MetadataCollection.d.ts.map +1 -0
  14. package/lib/factories/MetadataCollection.js +83 -0
  15. package/lib/factories/MetadataFactory.d.ts +8 -0
  16. package/lib/factories/MetadataFactory.d.ts.map +1 -0
  17. package/lib/factories/MetadataFactory.js +255 -0
  18. package/lib/factories/SchemaFactory.d.ts +9 -0
  19. package/lib/factories/SchemaFactory.d.ts.map +1 -0
  20. package/lib/factories/SchemaFactory.js +179 -0
  21. package/lib/factories/TypeFactry.d.ts +7 -0
  22. package/lib/factories/TypeFactry.d.ts.map +1 -0
  23. package/lib/factories/TypeFactry.js +76 -0
  24. package/lib/generates/SwaggerGenerator.d.ts.map +1 -1
  25. package/lib/generates/SwaggerGenerator.js +62 -22
  26. package/lib/structures/IMetadata.d.ts +21 -0
  27. package/lib/structures/IMetadata.d.ts.map +1 -0
  28. package/lib/structures/IMetadata.js +3 -0
  29. package/lib/structures/ISwagger.d.ts +3 -1
  30. package/lib/structures/ISwagger.d.ts.map +1 -1
  31. package/lib/structures/TypeEntry.d.ts +10 -0
  32. package/lib/structures/TypeEntry.d.ts.map +1 -0
  33. package/lib/structures/TypeEntry.js +22 -0
  34. package/package.json +1 -1
@@ -0,0 +1,42 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+
5
+ ---
6
+
7
+ ## Bug Report
8
+ Note that, the bug you're reporting may have registered in the [issues](https://github.com/samchon/nestia/search?type=issues) by another user. Even the bug you're reporting may have been fixed in the `@next` version. In such reasons, I recommend you to check the old [issues](https://github.com/samchon/nestia/search?type=issues) and reproduct your code with the `@next` version before publishing the bug reporting issue.
9
+
10
+ ```bash
11
+ `npm install --save-dev nestia@next`
12
+ ```
13
+
14
+ When the same error occurs even in the `@next` version, then please fill the below template:
15
+
16
+ ### Summary
17
+ Write a short summary of the bug in here.
18
+
19
+ - **SDK Version**: 2.1.0-dev.20220505
20
+ - **Expected behavior**:
21
+ - **Actual behavior**:
22
+
23
+ Write detailed description in here.
24
+
25
+
26
+
27
+ ### Code occuring the bug
28
+ ```typescript
29
+ /* Demonstration code occuring the bug you're reporting */
30
+ ```
31
+
32
+ Write the demonstration code occuring the bug you're reporting.
33
+
34
+ However, as the `nestia` is not a typical library who being used by the `import` statement but a executable program generating the SDK (Software Development Kit), it would be difficult to describe the bug with only the demonstration code.
35
+
36
+ In that case, you'd better to make a demonstration project occuring the bug to report. After the demonstration repository composition, fill the below `bash` script section. Of course, if you can describe the bug clearly, without the demonstration project construction, just skip it. Creating the demonstration repository is not essential.
37
+
38
+ ```bash
39
+ git clone https://github.com/someone/nestia-bug-report-xxx
40
+ cd nestia-bug-report-xxx
41
+ npx nestia sdk
42
+ ```
@@ -0,0 +1,13 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+
5
+ ---
6
+
7
+ ## Feature Request
8
+ Thanks for your suggestion. Feel free to just state your idea. Writing the issue, it would better to filling the below items:
9
+
10
+ - A description of the problem you're trying to solve.
11
+ - An overview of the suggested solution.
12
+ - Examples of how the suggestion whould work in various places.
13
+ - Code examples showing the expected behavior.
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: Question
3
+ about: What do you want to know?
4
+
5
+ ---
6
+
7
+ ## Question
8
+ I always welcome any questions about this backend proejct. However, half of questions can be solved by traveling [README.md](https://github.com/samchon/nestia) or old [issues](https://github.com/samchon/nestia/search?type=issues). Therefore, I recommend you to visit them before. If you have a question that has not been treated and you're extremely urgently, just contact me.
9
+
10
+ - E-mail: samchon.github@gmail.com
11
+ - Mobile: 82-10-3627-0016
@@ -0,0 +1,13 @@
1
+ Before submitting a Pull Request, please test your code.
2
+
3
+ If you created a new created a new feature, then create the unit test function, too.
4
+
5
+ ```bash
6
+ # COMPILE THE BACKEND SERVER
7
+ npm run build
8
+
9
+ # RUN THE TEST AUTOMATION PROGRAM
10
+ npm run test
11
+ ```
12
+
13
+ Learn more about the [CONTRIBUTING](CONTRIBUTING.md)
@@ -0,0 +1,133 @@
1
+
2
+ # Contributor Covenant Code of Conduct
3
+
4
+ ## Our Pledge
5
+
6
+ We as members, contributors, and leaders pledge to make participation in our
7
+ community a harassment-free experience for everyone, regardless of age, body
8
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
9
+ identity and expression, level of experience, education, socio-economic status,
10
+ nationality, personal appearance, race, caste, color, religion, or sexual identity
11
+ and orientation.
12
+
13
+ We pledge to act and interact in ways that contribute to an open, welcoming,
14
+ diverse, inclusive, and healthy community.
15
+
16
+ ## Our Standards
17
+
18
+ Examples of behavior that contributes to a positive environment for our
19
+ community include:
20
+
21
+ * Demonstrating empathy and kindness toward other people
22
+ * Being respectful of differing opinions, viewpoints, and experiences
23
+ * Giving and gracefully accepting constructive feedback
24
+ * Accepting responsibility and apologizing to those affected by our mistakes,
25
+ and learning from the experience
26
+ * Focusing on what is best not just for us as individuals, but for the
27
+ overall community
28
+
29
+ Examples of unacceptable behavior include:
30
+
31
+ * The use of sexualized language or imagery, and sexual attention or
32
+ advances of any kind
33
+ * Trolling, insulting or derogatory comments, and personal or political attacks
34
+ * Public or private harassment
35
+ * Publishing others' private information, such as a physical or email
36
+ address, without their explicit permission
37
+ * Other conduct which could reasonably be considered inappropriate in a
38
+ professional setting
39
+
40
+ ## Enforcement Responsibilities
41
+
42
+ Community leaders are responsible for clarifying and enforcing our standards of
43
+ acceptable behavior and will take appropriate and fair corrective action in
44
+ response to any behavior that they deem inappropriate, threatening, offensive,
45
+ or harmful.
46
+
47
+ Community leaders have the right and responsibility to remove, edit, or reject
48
+ comments, commits, code, wiki edits, issues, and other contributions that are
49
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
50
+ decisions when appropriate.
51
+
52
+ ## Scope
53
+
54
+ This Code of Conduct applies within all community spaces, and also applies when
55
+ an individual is officially representing the community in public spaces.
56
+ Examples of representing our community include using an official e-mail address,
57
+ posting via an official social media account, or acting as an appointed
58
+ representative at an online or offline event.
59
+
60
+ ## Enforcement
61
+
62
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
63
+ reported to the community leaders responsible for enforcement at
64
+ [INSERT CONTACT METHOD].
65
+ All complaints will be reviewed and investigated promptly and fairly.
66
+
67
+ All community leaders are obligated to respect the privacy and security of the
68
+ reporter of any incident.
69
+
70
+ ## Enforcement Guidelines
71
+
72
+ Community leaders will follow these Community Impact Guidelines in determining
73
+ the consequences for any action they deem in violation of this Code of Conduct:
74
+
75
+ ### 1. Correction
76
+
77
+ **Community Impact**: Use of inappropriate language or other behavior deemed
78
+ unprofessional or unwelcome in the community.
79
+
80
+ **Consequence**: A private, written warning from community leaders, providing
81
+ clarity around the nature of the violation and an explanation of why the
82
+ behavior was inappropriate. A public apology may be requested.
83
+
84
+ ### 2. Warning
85
+
86
+ **Community Impact**: A violation through a single incident or series
87
+ of actions.
88
+
89
+ **Consequence**: A warning with consequences for continued behavior. No
90
+ interaction with the people involved, including unsolicited interaction with
91
+ those enforcing the Code of Conduct, for a specified period of time. This
92
+ includes avoiding interactions in community spaces as well as external channels
93
+ like social media. Violating these terms may lead to a temporary or
94
+ permanent ban.
95
+
96
+ ### 3. Temporary Ban
97
+
98
+ **Community Impact**: A serious violation of community standards, including
99
+ sustained inappropriate behavior.
100
+
101
+ **Consequence**: A temporary ban from any sort of interaction or public
102
+ communication with the community for a specified period of time. No public or
103
+ private interaction with the people involved, including unsolicited interaction
104
+ with those enforcing the Code of Conduct, is allowed during this period.
105
+ Violating these terms may lead to a permanent ban.
106
+
107
+ ### 4. Permanent Ban
108
+
109
+ **Community Impact**: Demonstrating a pattern of violation of community
110
+ standards, including sustained inappropriate behavior, harassment of an
111
+ individual, or aggression toward or disparagement of classes of individuals.
112
+
113
+ **Consequence**: A permanent ban from any sort of public interaction within
114
+ the community.
115
+
116
+ ## Attribution
117
+
118
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119
+ version 2.0, available at
120
+ [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
121
+
122
+ Community Impact Guidelines were inspired by
123
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
124
+
125
+ For answers to common questions about this code of conduct, see the FAQ at
126
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available
127
+ at [https://www.contributor-covenant.org/translations][translations].
128
+
129
+ [homepage]: https://www.contributor-covenant.org
130
+ [v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
131
+ [Mozilla CoC]: https://github.com/mozilla/diversity
132
+ [FAQ]: https://www.contributor-covenant.org/faq
133
+ [translations]: https://www.contributor-covenant.org/translations
package/README.md CHANGED
@@ -20,9 +20,15 @@ npx nestia sdk "src/**/*.controller.ts" --out "src/api"
20
20
  npx nestia swagger "src/controller" -- out "swagger.json"
21
21
  ```
22
22
 
23
- Don't write any `swagger` comment. Just deliver the SDK.
23
+ Don't write any `swagger` comment or decorator. Just deliver the SDK.
24
24
 
25
- When you're developing a backend server using the `NestJS`, you don't need any extra dedication, for delivering the Rest API to the client developers, like writing the `swagger` comments. You just run this **Nestia** up, then **Nestia** would generate the SDK automatically, by analyzing your controller classes in the compliation and runtime level.
25
+ - No swagger comment/decorator
26
+ - No DTO comment/decorator
27
+ - Only pure NestJS source code and interface structures are required
28
+
29
+ When you're developing a backend server using the `NestJS`, you don't need any extra dedication, for delivering the Rest API to the client developers, like writing the `swagger` comments or decorators.
30
+
31
+ You just run this **Nestia** up, then **Nestia** would generate the SDK automatically, by analyzing your controller classes in the compliation and runtime level. Even generating the `swagger.json` without any swagger comment or decorator is also possible. When generating the SDK or `swwagger.json`, no DTO comment or decorator is required. Use only the pure interface definitions.
26
32
 
27
33
  With the automatically generated SDK through this **Nestia**, client developer also does not need any extra work, like reading `swagger` and writing the duplicated interaction code. Client developer only needs to import the SDK and calls matched function with the `await` symbol.
28
34
 
@@ -81,6 +87,22 @@ Just type the `nestia sdk <input> --out <output>` command in the console. When t
81
87
 
82
88
  Also, when generating a SDK using the cli options, `compilerOptions` would follow the `tsconfig.json`, that is configured for the backend server. If no `tsconfig.json` file exists in your project, the configuration would be default option (`ES5` with `strict` mode). If you want to use different `compilerOptions` with the `tsconfig.json`, you should configure the [nestia.config.ts](#nestiaconfigts).
83
89
 
90
+ ### Swagger generation
91
+ ```bash
92
+ npx nestia <source_controller_of_directory> --out <output_path>
93
+
94
+ npx nestia swagger "src/**/*.controller.ts" --out "./"
95
+ npx nestia swagger "src/controllers" --out "./swagger.json"
96
+ npx nestia swagger "src/consumers" "src/sellers" --out "actors.json"
97
+ npx nestia swagger "src/controllers" --exclude "src/**/Fake*.ts" -out "./"
98
+ ```
99
+
100
+ The **Nestia** even supports the `swagger.json` generation and it's also extermely easy.
101
+
102
+ Jsut type the `nestia swagger <input> --out <output>` command in the console. When there're multiple source directories containing the NestJS controller classes, type all of them separating by a `space` word. If you want to exclude some directories or files from the `swagger.json` generation, the `--exclude` option would be useful.
103
+
104
+ Also, when generating a SDK using the cli options, `compilerOptions` would follow the `tsconfig.json`, that is configured for the backend server. If no `tsconfig.json` file exists in your project, the configuration would be default option (`ES5` with `strict` mode). If you want to use different `compilerOptions` with the `tsconfig.json`, you should configure the [nestia.config.ts](#nestiaconfigts).
105
+
84
106
  ### Dependencies
85
107
  ```bash
86
108
  npx nestia install
@@ -260,6 +282,77 @@ To demonstrate which SDK codes would be generated by this **Nestia**:
260
282
  - [reference](https://github.com/samchon/nestia/tree/master/src/test/demonstrations/reference): Configured input files as `src/**/*.controller.ts`
261
283
  - [tsconfig.json](https://github.com/samchon/nestia/tree/master/src/test/demonstrations/tsconfig.json): Special configuration through the `tsconfig.json`
262
284
 
285
+ ### DTO
286
+ As you can see from the below code, the **Nestia** can use the interface directory.
287
+
288
+ You dont' need to define any extra comment or decorator function to make the DTO (Data Transfer Object). Just define the DTO as a pure interface structure, then **Nestia** will do everything instead of you.
289
+
290
+ If you're afraiding because your type is union or intersection, I can say that it does not matter. Even when generic or conditional type comes, it does not matter. Just enjoy the pure TypeScript type.
291
+
292
+ ```typescript
293
+ /**
294
+ * Comment wrote on an article.
295
+ *
296
+ * @author Jeongho Nam - https://github.com/samchon
297
+ */
298
+ export interface ISaleComment
299
+ {
300
+ /**
301
+ * Primary Key.
302
+ */
303
+ id: number;
304
+
305
+ /**
306
+ * Type of the writer.
307
+ */
308
+ writer_type: "seller" | "consumer";
309
+
310
+ /**
311
+ * Name of the writer.
312
+ */
313
+ writer_name: string;
314
+
315
+ /**
316
+ * Contents of the comments.
317
+ *
318
+ * When the comment writer tries to modify content, it would not modify the comment
319
+ * content but would be accumulated. Therefore, all of the people can read how
320
+ * the content has been changed.
321
+ */
322
+ contents: ISaleComment.IContent[];
323
+
324
+ /**
325
+ * Creation time.
326
+ */
327
+ created_at: string;
328
+ }
329
+
330
+ export namespace ISaleComment
331
+ {
332
+ /**
333
+ * Store info.
334
+ */
335
+ export interface IStore
336
+ {
337
+ /**
338
+ * Body of the content.
339
+ */
340
+ body: string;
341
+ }
342
+
343
+ /**
344
+ * Content info.
345
+ */
346
+ export interface IContent extends IStore
347
+ {
348
+ /**
349
+ * Creation time.
350
+ */
351
+ created_at: string;
352
+ }
353
+ }
354
+ ```
355
+
263
356
  ### Controller
264
357
  If you've decided to adapt this **Nestia** and you want to generate the SDK directly, you don't need any extra work. Just keep you controller class down and do noting. The only one exceptional case that you need an extra dedication is, when you want to explain about the API function to the client developers through the comments.
265
358
 
@@ -348,6 +441,159 @@ export namespace store
348
441
  }
349
442
  ```
350
443
 
444
+ ### `swagger.json`
445
+ Even the `swagger.json` does not require any swagger comment or decorator function.
446
+
447
+ The **Nestia** will generate the perfect `swagger.json` automatically, by analyzing your source code (DTO interface and controller class) in the compilation and runtime level. Even your descriptive comments would be placed into the adequate `description` property in the `swagger.json`.
448
+
449
+ ```json
450
+ {
451
+ "paths": {
452
+ "/consumers/{section}/sales/{saleId}/comments/{articleId}": {
453
+ "post": {
454
+ "tags": [],
455
+ "parameters": [
456
+ {
457
+ "name": "section",
458
+ "in": "path",
459
+ "description": "Code of the target section",
460
+ "schema": {
461
+ "type": "string",
462
+ "nullable": false
463
+ },
464
+ "required": true
465
+ },
466
+ {
467
+ "name": "saleId",
468
+ "in": "path",
469
+ "description": "ID of the target sale",
470
+ "schema": {
471
+ "type": "number",
472
+ "nullable": false
473
+ },
474
+ "required": true
475
+ },
476
+ {
477
+ "name": "articleId",
478
+ "in": "path",
479
+ "description": "ID of the target article",
480
+ "schema": {
481
+ "type": "number",
482
+ "nullable": false
483
+ },
484
+ "required": true
485
+ }
486
+ ],
487
+ "requestBody": {
488
+ "description": "Content to write",
489
+ "content": {
490
+ "application/json": {
491
+ "schema": {
492
+ "$ref": "#/components/schemas/ISaleComment.IStore"
493
+ }
494
+ }
495
+ },
496
+ "required": true
497
+ },
498
+ "responses": {
499
+ "201": {
500
+ "description": "Newly archived comment",
501
+ "content": {
502
+ "application/json": {
503
+ "schema": {
504
+ "$ref": "#/components/schemas/ISaleComment"
505
+ }
506
+ }
507
+ }
508
+ },
509
+ "400": {
510
+ "description": "bad request error when type of the input data is not valid"
511
+ },
512
+ "401": {
513
+ "description": "unauthorized error when you've not logged in yet"
514
+ },
515
+ "403": {
516
+ "description": "forbidden error when you're a seller and the sale is not yours"
517
+ },
518
+ "404": {
519
+ "description": "not found error when unable to find the matched record"
520
+ }
521
+ },
522
+ "description": "Store a new comment."
523
+ }
524
+ }
525
+ },
526
+ "components": {
527
+ "schemas": {
528
+ "ISaleComment": {
529
+ "type": "object",
530
+ "properties": {
531
+ "id": {
532
+ "description": "Primary Key.",
533
+ "type": "number",
534
+ "nullable": false
535
+ },
536
+ "writer_type": {
537
+ "description": "Type of the writer.",
538
+ "type": "string",
539
+ "nullable": false
540
+ },
541
+ "writer_name": {
542
+ "description": "Name of the writer.",
543
+ "type": "string",
544
+ "nullable": false
545
+ },
546
+ "contents": {
547
+ "description": "Contents of the comments.\n\nWhen the comment writer tries to modify content, it would not modify the comment\ncontent but would be accumulated. Therefore, all of the people can read how\nthe content has been changed.",
548
+ "type": "array",
549
+ "items": {
550
+ "$ref": "#/components/schemas/ISaleComment.IContent"
551
+ },
552
+ "nullable": false
553
+ },
554
+ "created_at": {
555
+ "description": "Creation time.",
556
+ "type": "string",
557
+ "nullable": false
558
+ }
559
+ },
560
+ "nullable": false,
561
+ "required": [
562
+ "id",
563
+ "writer_type",
564
+ "writer_name",
565
+ "contents",
566
+ "created_at"
567
+ ],
568
+ "description": "Comment wrote on an article."
569
+ },
570
+ "ISaleComment.IContent": {
571
+ "type": "object",
572
+ "properties": {
573
+ "created_at": {
574
+ "description": "Creation time.",
575
+ "type": "string",
576
+ "nullable": false
577
+ },
578
+ "body": {
579
+ "description": "Body of the content.",
580
+ "type": "string",
581
+ "nullable": false
582
+ }
583
+ },
584
+ "nullable": false,
585
+ "required": [
586
+ "created_at",
587
+ "body"
588
+ ],
589
+ "description": "Content info."
590
+ }
591
+ }
592
+ }
593
+ }
594
+ ```
595
+
596
+
351
597
 
352
598
 
353
599
 
@@ -1 +1 @@
1
- {"version":3,"file":"ControllerAnalyzer.d.ts","sourceRoot":"","sources":["../../src/analyses/ControllerAnalyzer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAM9C,yBAAiB,kBAAkB,CACnC;IACI,SAAgB,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,GAAG,MAAM,EAAE,CAc7G;CAyIJ"}
1
+ {"version":3,"file":"ControllerAnalyzer.d.ts","sourceRoot":"","sources":["../../src/analyses/ControllerAnalyzer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAM9C,yBAAiB,kBAAkB,CACnC;IACI,SAAgB,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,GAAG,MAAM,EAAE,CAc7G;CA2IJ"}
@@ -134,7 +134,9 @@ var ControllerAnalyzer;
134
134
  // EXPLORE CHILDREN TYPES
135
135
  var parameters = func.parameters.map(function (param) { return _Analyze_parameter(checker, genericDict, importDict, controller, func.name, param, declaration.parameters[param.index]); });
136
136
  var output = ImportAnalyzer_1.ImportAnalyzer.analyze(checker, genericDict, importDict, checker.getReturnTypeOfSignature(signature));
137
- var imports = importDict.toJSON().map(function (pair) { return [pair.first, pair.second.toJSON()]; });
137
+ var imports = importDict
138
+ .toJSON()
139
+ .map(function (pair) { return [pair.first, pair.second.toJSON()]; });
138
140
  // CONFIGURE PATH
139
141
  var path = _Normalize_path(path_1.default.join(controller.path, func.path)
140
142
  .split("\\")
@@ -0,0 +1,5 @@
1
+ import ts from "typescript";
2
+ export declare namespace CommentFactory {
3
+ function generate(comments: ts.SymbolDisplayPart[]): string;
4
+ }
5
+ //# sourceMappingURL=CommentFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommentFactory.d.ts","sourceRoot":"","sources":["../../src/factories/CommentFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,yBAAiB,cAAc,CAC/B;IACI,SAAgB,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,iBAAiB,EAAE,GAAG,MAAM,CAMjE;CACJ"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommentFactory = void 0;
4
+ var CommentFactory;
5
+ (function (CommentFactory) {
6
+ function generate(comments) {
7
+ return comments
8
+ .map(function (part) { return "".concat(part.kind === "linkText" ? " " : "").concat(part.text); })
9
+ .map(function (str) { return str.split("\r\n").join("\n"); })
10
+ .join("");
11
+ }
12
+ CommentFactory.generate = generate;
13
+ })(CommentFactory = exports.CommentFactory || (exports.CommentFactory = {}));
14
+ //# sourceMappingURL=CommentFactory.js.map
@@ -0,0 +1,14 @@
1
+ import ts from "typescript";
2
+ import { IMetadata } from "../structures/IMetadata";
3
+ export declare class MetadataCollection {
4
+ readonly inline: boolean;
5
+ private readonly dict_;
6
+ private readonly names_;
7
+ constructor(inline: boolean);
8
+ storage(): IMetadata.IStorage;
9
+ emplace(checker: ts.TypeChecker, type: ts.Type, nullable: boolean): [string, IMetadata.IObject | null];
10
+ private get_name;
11
+ }
12
+ export declare namespace MetadataCollection {
13
+ }
14
+ //# sourceMappingURL=MetadataCollection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetadataCollection.d.ts","sourceRoot":"","sources":["../../src/factories/MetadataCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAK5B,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAIpD,qBAAa,kBAAkB;aAOH,MAAM,EAAE,OAAO;IALvC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA+D;IACrF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;gBAInC,MAAM,EAAE,OAAO;IAOhC,OAAO,IAAI,SAAS,CAAC,QAAQ;IAQ7B,OAAO,CAEN,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,QAAQ,EAAE,OAAO,GAClB,CAAC,MAAM,EAAE,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC;IAqBzC,OAAO,CAAC,QAAQ;CA4BnB;AACD,yBAAiB,kBAAkB,CACnC;CACC"}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __values = (this && this.__values) || function(o) {
3
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
+ if (m) return m.call(o);
5
+ if (o && typeof o.length === "number") return {
6
+ next: function () {
7
+ if (o && i >= o.length) o = void 0;
8
+ return { value: o && o[i++], done: !o };
9
+ }
10
+ };
11
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.MetadataCollection = void 0;
15
+ var HashMap_1 = require("tstl/container/HashMap");
16
+ var Pair_1 = require("tstl/utility/Pair");
17
+ var TypeFactry_1 = require("./TypeFactry");
18
+ var MapUtil_1 = require("../utils/MapUtil");
19
+ var CommentFactory_1 = require("./CommentFactory");
20
+ var MetadataCollection = /** @class */ (function () {
21
+ function MetadataCollection(inline) {
22
+ this.inline = inline;
23
+ this.dict_ = new HashMap_1.HashMap();
24
+ this.names_ = new Map();
25
+ }
26
+ MetadataCollection.prototype.storage = function () {
27
+ var e_1, _a;
28
+ var storage = {};
29
+ try {
30
+ for (var _b = __values(this.dict_), _c = _b.next(); !_c.done; _c = _b.next()) {
31
+ var it = _c.value;
32
+ storage[it.second[0]] = it.second[1];
33
+ }
34
+ }
35
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
36
+ finally {
37
+ try {
38
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
39
+ }
40
+ finally { if (e_1) throw e_1.error; }
41
+ }
42
+ return storage;
43
+ };
44
+ MetadataCollection.prototype.emplace = function (checker, type, nullable) {
45
+ var key = new Pair_1.Pair(type, nullable);
46
+ var it = this.dict_.find(key);
47
+ if (it.equals(this.dict_.end()) === false)
48
+ return [it.second[0], null];
49
+ var id = this.get_name(checker, type, nullable);
50
+ var obj = {
51
+ nullable: nullable,
52
+ properties: {},
53
+ description: type.symbol
54
+ ? CommentFactory_1.CommentFactory.generate(type.symbol.getDocumentationComment(checker))
55
+ : ""
56
+ };
57
+ this.dict_.emplace(key, [id, obj]);
58
+ return [id, obj];
59
+ };
60
+ MetadataCollection.prototype.get_name = function (checker, type, nullable) {
61
+ var name = "".concat(TypeFactry_1.TypeFactory.full_name(checker, type)).concat(nullable ? ".Nullable" : "")
62
+ .split("&").join("-and-")
63
+ .split("|").join("-or-")
64
+ .split("<").join("-lt-")
65
+ .split(">").join("-gt-")
66
+ .split(",").join("-comma-")
67
+ .split("'").join("")
68
+ .split('"').join("")
69
+ .split(" ").join("");
70
+ var duplicates = MapUtil_1.MapUtil.take(this.names_, name, function () { return new Map(); });
71
+ var oldbie = duplicates.get(type);
72
+ if (oldbie)
73
+ return oldbie;
74
+ var emended = duplicates.size
75
+ ? "".concat(name, ".o").concat(duplicates.size)
76
+ : name;
77
+ duplicates.set(type, emended);
78
+ return emended;
79
+ };
80
+ return MetadataCollection;
81
+ }());
82
+ exports.MetadataCollection = MetadataCollection;
83
+ //# sourceMappingURL=MetadataCollection.js.map
@@ -0,0 +1,8 @@
1
+ import ts from "typescript";
2
+ import { IMetadata } from "../structures/IMetadata";
3
+ import { MetadataCollection } from "./MetadataCollection";
4
+ export declare namespace MetadataFactory {
5
+ export import Collection = MetadataCollection;
6
+ function generate(checker: ts.TypeChecker, type: ts.Type | null, collection?: Collection): IMetadata.IApplication | null;
7
+ }
8
+ //# sourceMappingURL=MetadataFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MetadataFactory.d.ts","sourceRoot":"","sources":["../../src/factories/MetadataFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAG5B,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,yBAAiB,eAAe,CAChC;IACI,MAAM,QAAQ,UAAU,GAAG,kBAAkB,CAAC;IAE9C,SAAgB,QAAQ,CAEhB,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,IAAI,EACpB,UAAU,GAAE,UAAiC,GAC9C,SAAS,CAAC,YAAY,GAAG,IAAI,CAenC;CA6NJ"}