Skip to content

Commit

Permalink
Moving package to a monorepo (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
cohitre authored Feb 23, 2024
1 parent f159774 commit cb4dbe1
Show file tree
Hide file tree
Showing 30 changed files with 310 additions and 429 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"overrides": [
{
"files": ["tests/**/*"],
"files": ["*.spec.ts", "*.spec.tsx"],
"rules": {
"@typescript-eslint/no-explicit-any": ["off"]
},
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ jobs:
- run: npm ci
- run: npx eslint .
- run: npx prettier . --check
- run: npx tsc --noEmit
- run: npm test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

dist
dist
3 changes: 0 additions & 3 deletions README.md

This file was deleted.

128 changes: 81 additions & 47 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "@usewaypoint/document",
"name": "@usewaypoint-monorepo",
"version": "0.0.6",
"description": "Tools to render waypoint-style documents.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"target": "ES2022",
Expand All @@ -10,7 +9,6 @@
],
"scripts": {
"build": "npx tsc",
"prepublish": "npx tsc --project tsconfig.build.json",
"test": "npx jest"
},
"author": "carlos@usewaypoint.com",
Expand All @@ -29,10 +27,7 @@
"react-test-renderer": "^18.2.0",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
},
"dependencies": {
"react": "^18.2.0",
"typescript": "^5.3.3",
"zod": "^3.22.4"
}
}
File renamed without changes.
19 changes: 19 additions & 0 deletions packages/document/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2024 Carlos Rodriguez-Rosario

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.
53 changes: 53 additions & 0 deletions packages/document/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# @usewaypoint/document

This is the core library used to build the email messages at [Waypoint](https://www.usewaypoint.com). It is non-opinionated and light on dependencies so that it can be used to compose complex documents.

> [!WARNING]
> This library is still under development and the final interface is subject
> to change
## Installation

**Installation with npm**

```
npm install --save @usewaypoint/document
```

## Usage

The root of the library is the `DocumentBlocksDictionary` dictionary. This is a mapping of block names to an object with a zod schema and a corresponding React Component.

```
const dictionary = {
Alert: {
schema: z.object({
message: z.string(),
}),
Component: ({ message }: { message: string }) => {
return <div>{message.toUpperCase()}</div>
}
}
}
```

This dictionary object is passed as an argument to the builder functions.

### `buildBlockComponent`

```
const Block = buildBlockComponent(dictionary);
<Block type="Alert" data={{message: 'Hello World' }} />
```

### `buildBlockConfigurationSchema`

```
const Schema = buildBlockConfigurationSchema(dictionary);
const parsedData = Schema.safeParse({
type: 'Alert',
data: { message: 'Hello World' },
});
```
Loading

0 comments on commit cb4dbe1

Please sign in to comment.