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

docs: restructure docs layout, add additional content #1207

Merged
merged 33 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c0312a5
continue docs
ssalbdivad Nov 11, 2024
87ab3ec
fix
ssalbdivad Nov 11, 2024
16cbab4
upDeps, fix test
ssalbdivad Nov 11, 2024
88eab86
add docs reference for prioritizing arktypes type import
ssalbdivad Nov 11, 2024
9335ba1
more docs structure iteration
ssalbdivad Nov 12, 2024
2937f56
fix date capitalization
ssalbdivad Nov 12, 2024
8fb8653
continuu
ssalbdivad Nov 13, 2024
f5b98a7
initial structure for docs
ssalbdivad Nov 13, 2024
71d934c
add new sidebar structure
ssalbdivad Nov 13, 2024
3f89ef3
ok
ssalbdivad Nov 14, 2024
b9de4dd
flesh out docs sections more and init to 39
ssalbdivad Nov 15, 2024
3e6cd42
fix traversalpath
ssalbdivad Nov 15, 2024
9f40fdf
make completions unwrappable
ssalbdivad Nov 15, 2024
20d9b75
no more
ssalbdivad Nov 15, 2024
90c26a5
continu
ssalbdivad Nov 16, 2024
def6458
38
ssalbdivad Nov 16, 2024
3693551
hack hack
ssalbdivad Nov 16, 2024
2577bb3
continuuu
ssalbdivad Nov 17, 2024
82290f9
hackiest of all time
ssalbdivad Nov 17, 2024
3a9de15
remove temp html
ssalbdivad Nov 17, 2024
b9b7a59
continuuu
ssalbdivad Nov 18, 2024
e44c16a
ok links
ssalbdivad Nov 18, 2024
1dba2a5
fix some links
ssalbdivad Nov 18, 2024
6bd349c
add distill export
ssalbdivad Nov 19, 2024
7556304
more link improvements
ssalbdivad Nov 19, 2024
8456096
add note on standard-schema
ssalbdivad Nov 19, 2024
accaaef
add more docs
ssalbdivad Nov 19, 2024
6ee2db6
add more notes on optionality
ssalbdivad Nov 19, 2024
932a2a3
replace todo comments with coming soon
ssalbdivad Nov 19, 2024
af3519c
bump versions
ssalbdivad Nov 19, 2024
b126296
add packageManager field for pnpm
ssalbdivad Nov 19, 2024
920e261
Merge branch 'main' into rc24
ssalbdivad Nov 19, 2024
5255c29
merge main and format FUNDING
ssalbdivad Nov 19, 2024
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
4 changes: 2 additions & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github: [arktypeio]
drips:
ethereum:
ownedBy: "0xD5c5Fe5DF95adf8DA1Ae640fCAE8f72795657fa5"
ethereum:
ownedBy: "0xD5c5Fe5DF95adf8DA1Ae640fCAE8f72795657fa5"
15 changes: 6 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,12 @@ In the meantime, check out the examples here and use the type hints you get to l
ArkType can easily be used with tRPC via the `assert` prop:

```ts
...
t.procedure
.input(
type({
name: "string",
"age?": "number"
}).assert
)
...
t.procedure.input(
type({
name: "string",
"age?": "number"
}).assert
)
```

## How?
Expand Down
20 changes: 16 additions & 4 deletions ark/attest/__tests__/unwrap.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
import { attest, contextualize } from "@ark/attest"
import type { Completions } from "@ark/attest/internal/cache/writeAssertionCache.js"
import type { autocomplete } from "@ark/util"

contextualize(() => {
it("unwraps unversioned", () => {
attest(attest({ foo: "bar" }).unwrap()).equals({
const unwrapped = attest({ foo: "bar" }).unwrap()
attest<{ foo: string }>(unwrapped).equals({
foo: "bar"
})
})

it("unwraps serialized", () => {
attest(
attest({ foo: Symbol("unwrappedSymbol") }).unwrap({ serialize: true })
).snap({ foo: "Symbol(unwrappedSymbol)" })
const unwrapped = attest({ foo: Symbol("unwrappedSymbol") }).unwrap({
serialize: true
})
attest(unwrapped).snap({ foo: "Symbol(unwrappedSymbol)" })
})

it("unwraps completions", () => {
const unwrapped = attest({ foo: "b" } satisfies {
foo: autocomplete<"bar">
}).completions.unwrap()

attest<Completions>(unwrapped).snap({ b: ["bar"] })
})
})
19 changes: 15 additions & 4 deletions ark/attest/assert/chainableAssertions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,10 @@ export class ChainableAssertions implements AssertionRecord {

return this
}
return Object.assign(inline, { toFile })
return Object.assign(inline, {
toFile,
unwrap: this.unwrap.bind(this)
})
}

private immediateOrChained() {
Expand Down Expand Up @@ -314,18 +317,26 @@ type snapProperty<expected, kind extends AssertionKind> = {
id: string,
options?: ExternalSnapshotOptions
) => nextAssertions<kind>
unwrap: Unwrapper<expected>
}

export type Unwrapper<expected = unknown> = (opts?: UnwrapOptions) => expected

export type comparableValueAssertion<expected, kind extends AssertionKind> = {
snap: snapProperty<expected, kind>
equals: (value: expected) => nextAssertions<kind>
instanceOf: (constructor: Constructor) => nextAssertions<kind>
is: (value: expected) => nextAssertions<kind>
completions: (value?: Completions) => void
completions: CompletionsSnap
satisfies: <def>(def: type.validate<def>) => nextAssertions<kind>
// This can be used to assert values without type constraints
unknown: Omit<comparableValueAssertion<unknown, kind>, "unknown">
unwrap: (opts?: UnwrapOptions) => unknown
unwrap: Unwrapper<expected>
}

export interface CompletionsSnap {
(value?: Completions): void
unwrap: Unwrapper<Completions>
}

export type TypeAssertionsRoot = {
Expand All @@ -335,7 +346,7 @@ export type TypeAssertionsRoot = {
export type TypeAssertionProps = {
toString: valueFromTypeAssertion<string | RegExp>
errors: valueFromTypeAssertion<string | RegExp, string>
completions: (value?: Completions) => void
completions: CompletionsSnap
}

export type ExternalSnapshotOptions = {
Expand Down
2 changes: 1 addition & 1 deletion ark/attest/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ark/attest",
"version": "0.27.0",
"version": "0.28.0",
"license": "MIT",
"author": {
"name": "David Blass",
Expand Down
110 changes: 110 additions & 0 deletions ark/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,113 @@
Source code for ArkType's docs at [arktype.io](https://arktype.io)

Built with [Starlight](https://starlight.astro.build/)

# Definitions

- Primitives

- string
- keywords
- Autogenerate from JSDoc
- literals
- patterns
- lengths
- number
- keywords
- Autogenerate from JSDoc
- literals
- ranges
- divisors
- more
- bigint
- boolean
- symbol
- null
- undefined

- Objects

- properties
- required
- optional
- defaultable
- index
- undeclared
- more
- merge
- keyof
- get
- map
- arrays
- lengths
- tuples
- prefix
- optional
- variadic
- postfix
- dates
- keywords
- Autogenerate from JSDoc
- literals
- ranges
- instanceOf
- keywords
- Autogenerate from JSDoc

- Expressions

- intersection
- union
- brand
- narrow
- morph
- more
- unit
- enumerated
- meta
- cast
- parenthetical
- this

# Other stuff

- Types (how you can use existing types)

- Top-level type invocation

- Autogenerate from JSDoc <!-- properties of a Type instance -->

- define <!-- type utilities not attached to a type instance -->
- raw

- Configuration

- errors
- clone
- onUndeclaredKey
- jitless

- Scopes (advanced)

- syntax
- modules
- visibility
- submodules
- thunks

- Generics (advanced)

- keywords
- Autogenerate from JSDoc
- syntax
- hkt (advanced++)

- Integrations

- Standard Schema
- tRPC
- react-hook-form
- hono

- FAQ
- About the project
Loading