effect-orpc 0.0.1
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/.cursor/hooks.json +10 -0
- package/.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc +111 -0
- package/.github/workflows/publish.yml +45 -0
- package/.oxfmtrc.jsonc +23 -0
- package/.oxlintrc.json +4 -0
- package/.vscode/settings.json +59 -0
- package/LICENSE +21 -0
- package/README.md +538 -0
- package/bun.lock +403 -0
- package/package.json +55 -0
- package/src/effect-builder.ts +680 -0
- package/src/effect-procedure.ts +354 -0
- package/src/index.ts +36 -0
- package/src/tagged-error.ts +515 -0
- package/src/tests/effect-builder.test.ts +488 -0
- package/src/tests/effect-error-map.test.ts +313 -0
- package/src/tests/effect-procedure.test.ts +213 -0
- package/src/tests/shared.ts +79 -0
- package/src/tests/tagged-error.test.ts +311 -0
- package/tsconfig.json +30 -0
- package/tsup.config.ts +8 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Use Bun instead of Node.js, npm, pnpm, or vite.
|
|
3
|
+
globs: "*.ts, *.tsx, *.html, *.css, *.js, *.jsx, package.json"
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Default to using Bun instead of Node.js.
|
|
8
|
+
|
|
9
|
+
- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
|
|
10
|
+
- Use `bun test` instead of `jest` or `vitest`
|
|
11
|
+
- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
|
|
12
|
+
- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
|
|
13
|
+
- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
|
|
14
|
+
- Bun automatically loads .env, so don't use dotenv.
|
|
15
|
+
|
|
16
|
+
## APIs
|
|
17
|
+
|
|
18
|
+
- `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
|
|
19
|
+
- `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
|
|
20
|
+
- `Bun.redis` for Redis. Don't use `ioredis`.
|
|
21
|
+
- `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
|
|
22
|
+
- `WebSocket` is built-in. Don't use `ws`.
|
|
23
|
+
- Prefer `Bun.file` over `node:fs`'s readFile/writeFile
|
|
24
|
+
- Bun.$`ls` instead of execa.
|
|
25
|
+
|
|
26
|
+
## Testing
|
|
27
|
+
|
|
28
|
+
Use `bun test` to run tests.
|
|
29
|
+
|
|
30
|
+
```ts#index.test.ts
|
|
31
|
+
import { test, expect } from "bun:test";
|
|
32
|
+
|
|
33
|
+
test("hello world", () => {
|
|
34
|
+
expect(1).toBe(1);
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Frontend
|
|
39
|
+
|
|
40
|
+
Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind.
|
|
41
|
+
|
|
42
|
+
Server:
|
|
43
|
+
|
|
44
|
+
```ts#index.ts
|
|
45
|
+
import index from "./index.html"
|
|
46
|
+
|
|
47
|
+
Bun.serve({
|
|
48
|
+
routes: {
|
|
49
|
+
"/": index,
|
|
50
|
+
"/api/users/:id": {
|
|
51
|
+
GET: (req) => {
|
|
52
|
+
return new Response(JSON.stringify({ id: req.params.id }));
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
// optional websocket support
|
|
57
|
+
websocket: {
|
|
58
|
+
open: (ws) => {
|
|
59
|
+
ws.send("Hello, world!");
|
|
60
|
+
},
|
|
61
|
+
message: (ws, message) => {
|
|
62
|
+
ws.send(message);
|
|
63
|
+
},
|
|
64
|
+
close: (ws) => {
|
|
65
|
+
// handle close
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
development: {
|
|
69
|
+
hmr: true,
|
|
70
|
+
console: true,
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
HTML files can import .tsx, .jsx or .js files directly and Bun's bundler will transpile & bundle automatically. `<link>` tags can point to stylesheets and Bun's CSS bundler will bundle.
|
|
76
|
+
|
|
77
|
+
```html#index.html
|
|
78
|
+
<html>
|
|
79
|
+
<body>
|
|
80
|
+
<h1>Hello, world!</h1>
|
|
81
|
+
<script type="module" src="./frontend.tsx"></script>
|
|
82
|
+
</body>
|
|
83
|
+
</html>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
With the following `frontend.tsx`:
|
|
87
|
+
|
|
88
|
+
```tsx#frontend.tsx
|
|
89
|
+
import React from "react";
|
|
90
|
+
|
|
91
|
+
// import .css files directly and it works
|
|
92
|
+
import './index.css';
|
|
93
|
+
|
|
94
|
+
import { createRoot } from "react-dom/client";
|
|
95
|
+
|
|
96
|
+
const root = createRoot(document.body);
|
|
97
|
+
|
|
98
|
+
export default function Frontend() {
|
|
99
|
+
return <h1>Hello, world!</h1>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
root.render(<Frontend />);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Then, run index.ts
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
bun --hot ./index.ts
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
For more information, read the Bun API docs in `node_modules/bun-types/docs/**.md`.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
inputs:
|
|
8
|
+
version:
|
|
9
|
+
description: "Version to publish (e.g., 1.0.0)"
|
|
10
|
+
required: true
|
|
11
|
+
type: string
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
publish:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
permissions:
|
|
17
|
+
contents: write
|
|
18
|
+
id-token: write
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- name: Checkout code
|
|
22
|
+
uses: actions/checkout@v4
|
|
23
|
+
|
|
24
|
+
- name: Setup Bun
|
|
25
|
+
uses: oven-sh/setup-bun@v2
|
|
26
|
+
with:
|
|
27
|
+
bun-version: latest
|
|
28
|
+
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
run: bun install --frozen-lockfile
|
|
31
|
+
|
|
32
|
+
- name: Run checks
|
|
33
|
+
run: bun run check
|
|
34
|
+
|
|
35
|
+
- name: Run tests
|
|
36
|
+
run: bun run test
|
|
37
|
+
|
|
38
|
+
- name: Build
|
|
39
|
+
run: bun run build
|
|
40
|
+
|
|
41
|
+
- name: Publish to npm
|
|
42
|
+
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
|
|
43
|
+
run: |
|
|
44
|
+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
|
|
45
|
+
npm publish --access public
|
package/.oxfmtrc.jsonc
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Ultracite oxfmt Configuration
|
|
2
|
+
// https://oxc.rs/docs/guide/usage/formatter/config-file-reference.html
|
|
3
|
+
{
|
|
4
|
+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
|
|
5
|
+
"printWidth": 80,
|
|
6
|
+
"tabWidth": 2,
|
|
7
|
+
"useTabs": false,
|
|
8
|
+
"semi": true,
|
|
9
|
+
"singleQuote": false,
|
|
10
|
+
"quoteProps": "as-needed",
|
|
11
|
+
"jsxSingleQuote": false,
|
|
12
|
+
"trailingComma": "all",
|
|
13
|
+
"bracketSpacing": true,
|
|
14
|
+
"bracketSameLine": false,
|
|
15
|
+
"arrowParens": "always",
|
|
16
|
+
"endOfLine": "lf",
|
|
17
|
+
"experimentalSortPackageJson": true,
|
|
18
|
+
"experimentalSortImports": {
|
|
19
|
+
"ignoreCase": true,
|
|
20
|
+
"newlinesBetween": true,
|
|
21
|
+
"order": "asc",
|
|
22
|
+
},
|
|
23
|
+
}
|
package/.oxlintrc.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
3
|
+
"typescript.tsdk": "node_modules/typescript/lib",
|
|
4
|
+
"editor.formatOnSave": true,
|
|
5
|
+
"editor.formatOnPaste": true,
|
|
6
|
+
"emmet.showExpandedAbbreviation": "never",
|
|
7
|
+
"[javascript]": {
|
|
8
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
9
|
+
},
|
|
10
|
+
"[javascriptreact]": {
|
|
11
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
12
|
+
},
|
|
13
|
+
"[typescript]": {
|
|
14
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
15
|
+
},
|
|
16
|
+
"[typescriptreact]": {
|
|
17
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
18
|
+
},
|
|
19
|
+
"[json]": {
|
|
20
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
21
|
+
},
|
|
22
|
+
"[jsonc]": {
|
|
23
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
24
|
+
},
|
|
25
|
+
"[yaml]": {
|
|
26
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
27
|
+
},
|
|
28
|
+
"[html]": {
|
|
29
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
30
|
+
},
|
|
31
|
+
"[vue]": {
|
|
32
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
33
|
+
},
|
|
34
|
+
"[vue-html]": {
|
|
35
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
36
|
+
},
|
|
37
|
+
"[handlebars]": {
|
|
38
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
39
|
+
},
|
|
40
|
+
"[css]": {
|
|
41
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
42
|
+
},
|
|
43
|
+
"[scss]": {
|
|
44
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
45
|
+
},
|
|
46
|
+
"[less]": {
|
|
47
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
48
|
+
},
|
|
49
|
+
"[graphql]": {
|
|
50
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
51
|
+
},
|
|
52
|
+
"[markdown]": {
|
|
53
|
+
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
54
|
+
},
|
|
55
|
+
"editor.codeActionsOnSave": {
|
|
56
|
+
"source.fixAll.oxc": "explicit"
|
|
57
|
+
},
|
|
58
|
+
"oxc.enable": true
|
|
59
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MATTEO SCOTTO (UTOPY)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|