Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracting primitives inspired by ATMP #119

Merged
merged 41 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3d74187
Import code from atmp library. Add `all` combinator and change interface
diogob Oct 31, 2023
956fe85
Using constructors for success and errors
diogob Nov 4, 2023
a031160
derive DF result from atmp result
diogob Nov 4, 2023
4f32623
remove cause field from error since we already preserve the original …
diogob Nov 4, 2023
99319fc
Unify types deriving from atmp when needed.
diogob Nov 4, 2023
b9bda3c
Add function to convert from atmp failure to DF ErrorResult
diogob Nov 4, 2023
d2da482
Implement all in terms of atmp
diogob Nov 7, 2023
aaef1c0
Implement sequence (and therefore pipe) in terms of atmp.
diogob Nov 7, 2023
1f38de4
mergeObjects for now resides in atmp
diogob Nov 7, 2023
e43eaaa
Reimplement map in terms of atmp
diogob Nov 7, 2023
e40dd48
Rewrite safeResult in terms of atmp
diogob Nov 7, 2023
ebbc374
move formatSchemaErrors closer to the constructor (its only dependendet)
diogob Nov 7, 2023
bd80af8
Unify toErrorWithMessage
diogob Nov 7, 2023
3ac66b9
We don't need util in atmp anymore. objHasKey is used only in error m…
diogob Nov 7, 2023
538aaaf
Tidy up imports
diogob Nov 7, 2023
342e97f
Move safeResult to simplify imports since it was not used in construc…
diogob Nov 7, 2023
5276c0d
Fix error case in tracing function
diogob Nov 15, 2023
3b16189
Rewrite contructor in terms of fromAtmp
diogob Nov 15, 2023
2df3e3a
Eta reduce
diogob Nov 15, 2023
ea64c68
Use test-prelude instead of importing dependencies directly
diogob Nov 15, 2023
1e20c94
Remove unused dependencies
diogob Nov 15, 2023
643e5b4
Move zod import to test-prelude
diogob Nov 15, 2023
d008db5
Rename atmp to composable and Attempt to Composable
diogob Nov 15, 2023
143a7cd
Add cf alias for composable
diogob Nov 15, 2023
c111da5
Add lambda alias
diogob Nov 15, 2023
f0efaed
Properly capitalize fromComposable
diogob Nov 15, 2023
cbbcee6
WIP - toComposable (todo: write some tests)
diogob Nov 15, 2023
2b332d4
Use lambda inside package to call composable
diogob Nov 16, 2023
52db44f
Fix toComposable typing and error results
diogob Nov 16, 2023
ec436fe
Allow custom type for input and environment when converting to compos…
diogob Nov 16, 2023
c219717
Add command to generate docs and add composable namespace to public i…
diogob Nov 16, 2023
5bf8407
Add some jsdocs
diogob Nov 16, 2023
1b74c26
Allow mapError to map entire error type (except for its tag) so its a…
diogob Nov 16, 2023
6972608
fix mapError example
diogob Nov 16, 2023
5ce385f
add example to map
diogob Nov 16, 2023
47afa06
remove reference to all to not confuse the reader since all runs in p…
diogob Nov 16, 2023
80012fa
Add jsdoc to pipe
diogob Nov 16, 2023
ed3b872
Add all JSDoc
diogob Nov 16, 2023
c9887a3
Fix some JSDocs comments
diogob Nov 16, 2023
f03c0cc
Add docs for collect
diogob Nov 16, 2023
1215cc2
Add doc to contructor
diogob Nov 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
dist/
npm
npm
docs
3 changes: 2 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"tasks": {
"test": "deno test --allow-env --allow-net --unstable src",
"publish": "deno task build-npm && cd npm/ && npm publish",
"build-npm": "deno run -A scripts/build-npm.ts"
"build-npm": "deno run -A scripts/build-npm.ts",
"docs": "deno doc --html --name='domain-functions' ./mod.ts"
}
}
92 changes: 48 additions & 44 deletions deno.lock

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

2 changes: 1 addition & 1 deletion src/all.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
assertEquals,
assertObjectMatch,
} from './test-prelude.ts'
import { z } from 'https://deno.land/x/[email protected]/mod.ts'
import { z } from './test-prelude.ts'

import { mdf } from './constructor.ts'
import { all } from './domain-functions.ts'
Expand Down
46 changes: 46 additions & 0 deletions src/apply-environment.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { assertEquals, describe, it } from './test-prelude.ts'
import { z } from './test-prelude.ts'

import { mdf } from './constructor.ts'
import { applyEnvironment } from './domain-functions.ts'

describe('applyEnvironment', () => {
it('fails when environment fails parser', async () => {
const getEnv = mdf(z.unknown(), z.number())((_, e) => e)

const getEnvWithEnvironment = applyEnvironment(
getEnv,
'invalid environment',
)

assertEquals(await getEnvWithEnvironment('some input'), {
success: false,
errors: [],
inputErrors: [],
environmentErrors: [
{
message: 'Expected number, received string',
path: [],
},
],
})
})

it('should apply environment', async () => {
const getEnv = mdf(z.unknown(), z.string())((_, e) => e)

const getEnvWithEnvironment = applyEnvironment(
getEnv,
'constant environment',
)

assertEquals(await getEnvWithEnvironment('some input'), {
success: true,
data: 'constant environment',
errors: [],
inputErrors: [],
environmentErrors: [],
})
})
})

2 changes: 1 addition & 1 deletion src/branch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
assertEquals,
assertObjectMatch,
} from './test-prelude.ts'
import { z } from 'https://deno.land/x/[email protected]/mod.ts'
import { z } from './test-prelude.ts'

import { mdf } from './constructor.ts'
import { branch, pipe, all } from './domain-functions.ts'
Expand Down
2 changes: 1 addition & 1 deletion src/collect-sequence.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, assertEquals } from './test-prelude.ts'
import { z } from 'https://deno.land/x/[email protected]/mod.ts'
import { z } from './test-prelude.ts'

import { mdf } from './constructor.ts'
import { collectSequence } from './domain-functions.ts'
Expand Down
2 changes: 1 addition & 1 deletion src/collect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
assertObjectMatch,
assertEquals,
} from './test-prelude.ts'
import { z } from 'https://deno.land/x/[email protected]/mod.ts'
import { z } from './test-prelude.ts'

import { mdf } from './constructor.ts'
import { collect } from './domain-functions.ts'
Expand Down
Loading
Loading