@innet/server 2.0.0-alpha.4 → 2.0.0-alpha.5

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 CHANGED
@@ -396,22 +396,29 @@ export default (
396
396
  )
397
397
  ```
398
398
 
399
- > You MUST add some [endpoint](#endpoint) with some schema otherwise you get the `Error: There is no schema in the input contents`.
400
-
399
+ You do not need to import types, use `Api` namespace everywhere.
401
400
  Here is an example of generated types usage.
402
401
 
403
- *src/GetPartner.tsx*
404
402
  ```typescript jsx
405
403
  import { useParams } from '@innet/server'
406
404
 
407
- export function GetPartner () {
408
- const { id } = useParams<Paths.Partners$Id.Get.PathParameters>()
409
- return <success>{{ id }}</success>
405
+ import { todos } from '../todos'
406
+
407
+ export function DeleteTodo () {
408
+ const { todoId } = useParams<Api.Endpoints['DELETE:/todos/{todoId}']['Params']>()
409
+
410
+ const todoIndex = todos.findIndex(({ id }) => id === todoId)
411
+
412
+ if (todoIndex === -1) {
413
+ return <error code='todoNotFound' status={404} />
414
+ }
415
+
416
+ todos.splice(todoIndex, 1)
417
+
418
+ return <success />
410
419
  }
411
420
  ```
412
421
 
413
- You do not need to import types, they generate as namespaces.
414
-
415
422
  ## API Info
416
423
 
417
424
  The API information elements are here.
@@ -1,4 +1,4 @@
1
1
  export interface TodoSchemaProps {
2
- add?: boolean;
2
+ body?: boolean;
3
3
  }
4
- export declare function TodoSchema(props: TodoSchemaProps): any;
4
+ export declare function TodoSchema({ body }?: TodoSchemaProps): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innet/server",
3
- "version": "2.0.0-alpha.4",
3
+ "version": "2.0.0-alpha.5",
4
4
  "description": "Create server-side application with innet",
5
5
  "main": "index.js",
6
6
  "module": "index.es6.js",
@@ -9,7 +9,16 @@ function generateSchemaTypes(schema, spaces = 2) {
9
9
  if (schema.type === 'integer') {
10
10
  return `${schema.format === 'int64' ? 'bigint' : 'number'}\n`;
11
11
  }
12
- if (['string', 'boolean', 'number', 'null'].includes(schema.type)) {
12
+ if (schema.type === 'string') {
13
+ if (schema.format === 'date-time') {
14
+ return 'Date\n';
15
+ }
16
+ if (schema.format === 'binary') {
17
+ return 'Bin\n';
18
+ }
19
+ return 'string\n';
20
+ }
21
+ if (['boolean', 'number', 'null'].includes(schema.type)) {
13
22
  return `${schema.type}\n`;
14
23
  }
15
24
  if (schema.type === 'array') {
@@ -34,7 +43,7 @@ function generateSchemaTypes(schema, spaces = 2) {
34
43
  }
35
44
  function generateTypes(docs) {
36
45
  var _a;
37
- let result = 'declare namespace Api {\n';
46
+ let result = 'declare namespace Api {\n export interface Bin {\n filename: string\n fieldName: string\n originalFilename: string\n path: string\n type: string\n disposition: string\n size: number\n extension?: string\n }\n';
38
47
  const schemas = (_a = docs.components) === null || _a === void 0 ? void 0 : _a.schemas;
39
48
  const paths = docs.paths;
40
49
  if (schemas) {
@@ -13,7 +13,16 @@ function generateSchemaTypes(schema, spaces = 2) {
13
13
  if (schema.type === 'integer') {
14
14
  return `${schema.format === 'int64' ? 'bigint' : 'number'}\n`;
15
15
  }
16
- if (['string', 'boolean', 'number', 'null'].includes(schema.type)) {
16
+ if (schema.type === 'string') {
17
+ if (schema.format === 'date-time') {
18
+ return 'Date\n';
19
+ }
20
+ if (schema.format === 'binary') {
21
+ return 'Bin\n';
22
+ }
23
+ return 'string\n';
24
+ }
25
+ if (['boolean', 'number', 'null'].includes(schema.type)) {
17
26
  return `${schema.type}\n`;
18
27
  }
19
28
  if (schema.type === 'array') {
@@ -38,7 +47,7 @@ function generateSchemaTypes(schema, spaces = 2) {
38
47
  }
39
48
  function generateTypes(docs) {
40
49
  var _a;
41
- let result = 'declare namespace Api {\n';
50
+ let result = 'declare namespace Api {\n export interface Bin {\n filename: string\n fieldName: string\n originalFilename: string\n path: string\n type: string\n disposition: string\n size: number\n extension?: string\n }\n';
42
51
  const schemas = (_a = docs.components) === null || _a === void 0 ? void 0 : _a.schemas;
43
52
  const paths = docs.paths;
44
53
  if (schemas) {