Skip to content

Commit

Permalink
feat(private): scaffold packages for schema parser (emberjs#8955)
Browse files Browse the repository at this point in the history
* feat(private): implement schema parser

* dont build in ci
  • Loading branch information
runspired authored and BoussonKarel committed Oct 6, 2023
1 parent 222948b commit 0304a36
Show file tree
Hide file tree
Showing 17 changed files with 243 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
/packages/data-worker/addon/
/packages/holodeck/
/packages/schema-record/
/packages/schema/
/tests/schema/

**/DEBUG/

Expand Down
1 change: 1 addition & 0 deletions packages/schema/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
12 changes: 12 additions & 0 deletions packages/schema/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
The MIT License (MIT)

Copyright (C) 2023 EmberData and WarpDrive contributors
Copyright (C) 2017-2022 Ember.js contributors
Portions Copyright (C) 2011-2017 Tilde, Inc. and contributors.
Portions Copyright (C) 2011 LivingSocial Inc.

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:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

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.
4 changes: 4 additions & 0 deletions packages/schema/NCC-1701-a-blue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions packages/schema/NCC-1701-a.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
120 changes: 120 additions & 0 deletions packages/schema/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<p align="center">
<img
class="project-logo"
src="./NCC-1701-a-blue.svg#gh-light-mode-only"
alt="WarpDrive"
width="120px"
title="WarpDrive" />
<img
class="project-logo"
src="./NCC-1701-a.svg#gh-dark-mode-only"
alt="WarpDrive"
width="120px"
title="WarpDrive" />
</p>

<h3 align="center">:electron: Declarative Schema Parser</h3>
<p align="center">Build faster with better DX</p>

<p align="center">
<img
src="./parse-usage.png"
alt="WarpDrive Schema"
width="400px"
title="WarpDrive Schema" />
</p>

`@warp-drive/schema` allows you to easily use the typescript you already know as a statically analyzable schema language.

Its like GraphQL, RPC, or Protobuf... but for anything!

## Usage

> ⚠️ Private
This package may currently only be used within EmberData. A public version is coming soon 💜

#### 🔜 Soon

Scaffold the schema for a `User` resource

```no-highlight
npx -p @warp-drive-schema resource user
```

Parse Schemas

```no-highlight
npx -p @warp-drive/schema parse <path/to/schema.json>
```

## How it works

The parser expects a json config file.

```ts
{
"schemas": "./src/schemas",
"dest": "./dist",
}
```

### ♥️ Credits

<details>
<summary>Brought to you with ♥️ love by <a href="https://emberjs.com" title="EmberJS">🐹 Ember</a></summary>

<style type="text/css">
img.project-logo {
padding: 0 5em 1em 5em;
width: 100px;
border-bottom: 2px solid #0969da;
margin: 0 auto;
display: block;
}
details > summary {
font-size: 1.1rem;
line-height: 1rem;
margin-bottom: 1rem;
}
details {
font-size: 1rem;
}
details > summary strong {
display: inline-block;
padding: .2rem 0;
color: #000;
border-bottom: 3px solid #0969da;
}

details > details {
margin-left: 2rem;
}
details > details > summary {
font-size: 1rem;
line-height: 1rem;
margin-bottom: 1rem;
}
details > details > summary strong {
display: inline-block;
padding: .2rem 0;
color: #555;
border-bottom: 2px solid #555;
}
details > details {
font-size: .85rem;
}

@media (prefers-color-scheme: dark) {
details > summary strong {
color: #fff;
}
}
@media (prefers-color-scheme: dark) {
details > details > summary strong {
color: #afaba0;
border-bottom: 2px solid #afaba0;
}
}
</style>
</details>
56 changes: 56 additions & 0 deletions packages/schema/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "@warp-drive/schema",
"version": "5.5.0-alpha.11",
"private": true,
"description": "Parse Declarative Typescript into JSON Schemas",
"keywords": [
"typescript",
"schema",
"parser",
"GraphQL",
"tRPC",
"MSW",
"EmberData",
"Tanstack"
],
"repository": {
"type": "git",
"url": "git+ssh://git@github.com:emberjs/data.git",
"directory": "packages/schema"
},
"license": "MIT",
"author": "Chris Thoburn <runspired@users.noreply.github.com>",
"scripts": {
"build:parse": "bun build src/parse.ts --compile --outfile parse",
"build:scaffold": "bun build src/scaffold.ts --compile --outfile scaffold",
"build": "pnpm run build:parse && pnpm run build:scaffold",
"prepack": "pnpm build"
},
"files": [
"README.md",
"LICENSE.md",
"NCC-1701-a.svg",
"NCC-1701-a-blue.svg"
],
"bin": {
"parse": "./parse",
"resource": "./scaffold resource"
},
"main": "src/index.ts",
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"chalk": "^5.3.0"
},
"devDependencies": {
"bun-types": "1.0.4-canary.20231004T140131"
},
"engines": {
"node": ">= 18.*"
},
"volta": {
"extends": "../../package.json"
},
"packageManager": "pnpm@8.8.0"
}
Binary file added packages/schema/parse
Binary file not shown.
Binary file added packages/schema/parse-usage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/schema/scaffold
Binary file not shown.
Binary file added packages/schema/scaffold-resource.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions packages/schema/src/parse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
async function main() {}

await main();
3 changes: 3 additions & 0 deletions packages/schema/src/scaffold.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
async function main() {}

await main();
17 changes: 17 additions & 0 deletions packages/schema/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"module": "esnext",
"target": "esnext",
"moduleResolution": "bundler",
"moduleDetection": "force",
"allowImportingTsExtensions": true,
"strict": true,
"downlevelIteration": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"allowJs": true,
"noEmit": true
}
}
Loading

0 comments on commit 0304a36

Please sign in to comment.