Skip to content

Commit

Permalink
initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
menduz committed Feb 11, 2021
1 parent a029247 commit cf01cab
Show file tree
Hide file tree
Showing 16 changed files with 1,469 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
report/* @menduz
29 changes: 29 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
push:
branches:
- master
- main
release:
types:
- created

name: Publish NPM package
jobs:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: install
run: npm ci
- name: build
run: npm run build
- name: test
run: npm run test
- name: Publish
uses: menduz/oddish-action@master
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on:
push:
branches-ignore:
- "master"
- "main"
pull_request:

name: PR Validation
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: install
run: npm ci
- name: build
run: npm run build
- name: test
run: npm run test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
node_modules/
8 changes: 8 additions & 0 deletions .mocharc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require:
- 'test/index'
reporter:
- 'spec'
watch-files:
- 'dist/**/*.js'
- 'test/**/*.ts'
spec: 'test/**/*.spec.ts'
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
# common-schemas

```
npm i @dcl/shemas
```

### Design considerations

- The main entrypoint of the library export namespaces only
- Every namespace is a domain `MetaTransactions`
- Type names are PascalCase
- Validators and schemas are camelCase


## Generating types, validators and schemas

We will export types that act as values. We do that using the "namespaces" of typescript.

```ts
// Declare type
export type MyType = {
value: number
}
// Declare namespace
export namespace MyType {
export const schema: Schema<MyType> = {
type: "object",
properties: {
value: { type: number }
},
additionalProperties: false,
required: ["value"]
}

export const validate = generateValidator<MyType>(schema)
}
```

In that sense, MyType can be both used as type `const a: MyType` and as object `MyType.validate(a)`.
Loading

0 comments on commit cf01cab

Please sign in to comment.