Skip to content

Commit 4f91c02

Browse files
committed
packages
1 parent 022f9de commit 4f91c02

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1305
-783
lines changed

.eslintrc.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es2021: true,
5+
node: true,
6+
jest: true
7+
},
8+
extends: [
9+
'eslint:recommended',
10+
'plugin:@typescript-eslint/recommended'
11+
],
12+
overrides: [],
13+
parser: '@typescript-eslint/parser',
14+
parserOptions: {
15+
ecmaVersion: 'latest',
16+
sourceType: 'module'
17+
},
18+
plugins: [
19+
'@typescript-eslint',
20+
'simple-import-sort',
21+
'unused-imports'
22+
],
23+
rules: {
24+
indent: [
25+
'error',
26+
2
27+
],
28+
quotes: [
29+
'error',
30+
'single',
31+
{
32+
avoidEscape: true,
33+
allowTemplateLiterals: true
34+
}
35+
],
36+
'quote-props': [
37+
'error',
38+
'as-needed'
39+
],
40+
semi: [
41+
'error',
42+
'always'
43+
],
44+
'simple-import-sort/imports': 1,
45+
'simple-import-sort/exports': 1,
46+
'unused-imports/no-unused-imports': 1,
47+
'@typescript-eslint/no-unused-vars': [
48+
1,
49+
{
50+
argsIgnorePattern: 'React|res|next|^_'
51+
}
52+
],
53+
'@typescript-eslint/no-explicit-any': 0,
54+
'@typescript-eslint/no-var-requires': 0,
55+
'no-console': 0,
56+
'@typescript-eslint/ban-ts-comment': 0,
57+
'prefer-const': 0,
58+
'no-case-declarations': 0,
59+
'no-implicit-globals': 0,
60+
'@typescript-eslint/no-unsafe-declaration-merging': 0
61+
},
62+
ignorePatterns: [
63+
'node_modules/',
64+
'dist/',
65+
'**/node_modules/',
66+
'**/dist/'
67+
]
68+
};

.eslintrc.json

Lines changed: 0 additions & 50 deletions
This file was deleted.

.prettierrc.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
2-
"trailingComma": "es5",
3-
"tabWidth": 2,
4-
"semi": true,
5-
"useTabs": false,
6-
"singleQuote": false
7-
}
2+
"trailingComma": "es5",
3+
"tabWidth": 2,
4+
"semi": true,
5+
"useTabs": false,
6+
"singleQuote": true
7+
}
8+

README.md

Lines changed: 19 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,34 @@
11
# schema-typescript
22

33
<p align="center" width="100%">
4-
<a href="https://github.com/pyramation/schema-typescript/actions/workflows/run-tests.yaml">
5-
<img height="20" src="https://github.com/pyramation/schema-typescript/actions/workflows/run-tests.yaml/badge.svg" />
4+
<img src="https://github.com/cosmology-tech/interweb-utils/assets/545047/89c743c4-be88-409f-9a77-4b02cd7fe9a4" width="80">
5+
<br/>
6+
JSON Schema TypeScript utilities for the Interweb
7+
<br />
8+
<a href="https://github.com/cosmology-tech/schema-typescript/actions/workflows/run-tests.yaml">
9+
<img height="20" src="https://github.com/cosmology-tech/schema-typescript/actions/workflows/run-tests.yaml/badge.svg" />
10+
</a>
11+
<a href="https://github.com/cosmology-tech/schema-typescript/blob/main/LICENSE-MIT">
12+
<img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/>
613
</a>
7-
<a href="https://github.com/pyramation/schema-typescript/blob/main/LICENSE-MIT"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
814
</p>
915

10-
Welcome to _schema-typescript_! This project provides robust tools for handling JSON schemas and converting them to TypeScript interfaces with ease and efficiency.
11-
12-
## Features
13-
14-
- **🔧 JSON Schema to TypeScript**: Convert JSON schemas into TypeScript interfaces automatically.
15-
16-
- **📦 Modular**: Designed to be reusable with minimal dependencies.
17-
18-
- **🔍 Supports `$ref` and `$defs`**: Fully supports JSON Schema references, allowing you to define complex schemas modularly.
19-
20-
- **🐕 Multiple Entities Handling**: Handles arrays of defined types, such as multiple dogs or cats, seamlessly in your schemas.
21-
22-
## Getting Started 🏁
23-
24-
To get started with _schema-typescript_, simply run:
25-
26-
```bash
27-
npm install schema-typescript
28-
```
29-
30-
## Usage 📘
16+
## Packages
3117

32-
Here's a quick example to show you how to convert a JSON schema into TypeScript interfaces:
18+
This repository contains the following packages:
3319

34-
```javascript
35-
import { generateTypeScript } from 'schema-typescript';
20+
- [`schema-typescript`](https://github.com/cosmology-tech/schema-typescript/tree/main/packages/schema-typescript)
21+
Provides robust tools for handling JSON schemas and converting them to TypeScript interfaces with ease and efficiency.
3622

37-
const schema = {
38-
"$id": "https://example.com/person.schema.json",
39-
"$schema": "https://json-schema.org/draft-07/schema#",
40-
"title": "Person",
41-
"type": "object",
42-
"properties": {
43-
"firstName": { "type": "string" },
44-
"pets": {
45-
"type": "array",
46-
"items": { "$ref": "#/$defs/pet" }
47-
}
48-
},
49-
"required": ["firstName", "pets"],
50-
"$defs": {
51-
"pet": {
52-
"type": "object",
53-
"properties": {
54-
"name": { "type": "string" },
55-
"type": { "type": "string" }
56-
},
57-
"required": ["name", "type"]
58-
}
59-
}
60-
};
23+
- [`@schema-typescript/cli`](https://github.com/cosmology-tech/schema-typescript/tree/main/packages/cli)
24+
CLI is the command line utility for `schema-typescript`.
6125

62-
console.log(generateTypeScript(schema));
63-
// OUTPUT:
64-
interface Pet {
65-
name: string;
66-
type: string;
67-
}
68-
interface Person {
69-
firstName: string;
70-
pets: Pet[];
71-
}
72-
```
26+
- [`schema-sdk`](https://github.com/cosmology-tech/schema-typescript/tree/main/packages/schema-sdk)
27+
Provides robust tools for handling OpenAPI schemas and converting them to TypeScript clients with ease and efficiency.
7328

74-
## Contributing 🤝
29+
- [`node-api-client`](https://github.com/cosmology-tech/schema-typescript/tree/main/packages/node-api-client)
30+
A lightweight and flexible HTTP client for interacting with RESTful APIs in Node.js, supporting common HTTP methods and customizable options.
7531

76-
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
7732

7833
## Need Help?
7934

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
"@typescript-eslint/eslint-plugin": "^7.10.0",
2828
"@typescript-eslint/parser": "^7.10.0",
2929
"copyfiles": "^2.4.1",
30+
"eslint": "^8.56.0",
3031
"eslint-config-prettier": "^9.1.0",
3132
"eslint-plugin-simple-import-sort": "^12.1.0",
3233
"eslint-plugin-unused-imports": "^4.0.0",
33-
"eslint": "^8.56.0",
3434
"jest": "^29.6.2",
3535
"lerna": "^6",
3636
"prettier": "^3.0.2",
@@ -41,4 +41,4 @@
4141
"ts-node": "^10.9.2",
4242
"typescript": "^5.1.6"
4343
}
44-
}
44+
}

packages/cli/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ module.exports = {
1414
transformIgnorePatterns: [`/node_modules/*`],
1515
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
1616
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
17-
modulePathIgnorePatterns: ['dist/*']
17+
modulePathIgnorePatterns: ['dist/*'],
1818
};

packages/cli/src/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
export default () => {
2-
3-
};
1+
export default () => {};

packages/node-api-client/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# node-api-client
2+
3+
<p align="center">
4+
<img src="https://user-images.githubusercontent.com/545047/188804067-28e67e5e-0214-4449-ab04-2e0c564a6885.svg" width="80"><br />
5+
Node.js API Client
6+
</p>
7+
8+
`node-api-client` is a lightweight and flexible HTTP client for interacting with RESTful APIs in Node.js. It supports common HTTP methods such as GET, POST, PUT, PATCH, and DELETE, with customizable options for headers, query parameters, and timeouts.
9+
10+
## install
11+
12+
```sh
13+
npm install node-api-client
14+
```
15+
16+
## Usage
17+
18+
Here's an example of how to use node-api-client:
19+
20+
```js
21+
import { APIClient, APIClientOptions } from 'node-api-client';
22+
23+
const options: APIClientOptions = {
24+
restEndpoint: 'http://localhost:8001/api'
25+
};
26+
27+
const client = new APIClient(options);
28+
29+
// GET request
30+
client.get('/endpoint')
31+
.then(response => console.log(response))
32+
.catch(error => console.error(error));
33+
34+
// POST request with JSON body
35+
client.post('/endpoint', { key: 'value' })
36+
.then(response => console.log(response))
37+
.catch(error => console.error(error));
38+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
it('works', () => {
2+
console.log('hello test world!');
3+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/** @type {import('ts-jest').JestConfigWithTsJest} */
2+
module.exports = {
3+
preset: 'ts-jest',
4+
testEnvironment: 'node',
5+
transform: {
6+
'^.+\\.tsx?$': [
7+
'ts-jest',
8+
{
9+
babelConfig: false,
10+
tsconfig: 'tsconfig.json',
11+
},
12+
],
13+
},
14+
transformIgnorePatterns: [`/node_modules/*`],
15+
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
16+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
17+
modulePathIgnorePatterns: ['dist/*'],
18+
};

0 commit comments

Comments
 (0)