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: more work and reorg #373

Merged
merged 10 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ We are only supporting the latest version at this point.

Please email [email protected]

We appreciate your secure disclusures. We don't have much money right now but will make our best effort to find a reward or other consideration.
We appreciate your secure disclosures. We don't have much money right now but will make our best effort to find a reward or other consideration.

Thank You
42 changes: 42 additions & 0 deletions docs/code/flow/examples/tasks/prompt/example.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package prompt

import "encoding/json"

test: {
@flow()

prompt: {
@task(prompt.Prompt)

Input: {
name: string
repo: string
releases: bool | *false
}

Questions: [{
Name: "name"
Type: "input"
Prompt: "What is your project named"
Required: true
}, {
Name: "repo"
Type: "input"
Prompt: "Git repository"
Default: "github.com/user/repo"
}, {
Name: "releases"
Type: "confirm"
Prompt: "Enable release tooling"
Default: true
}]

Output: _
}

output: {
@task(os.Stdout)
text: json.Indent(json.Marshal(prompt.Output), "", " ")
}

}
75 changes: 75 additions & 0 deletions docs/code/hof-schemas/flow/tasks/api/schema.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package api

Method: *"GET" | "POST" | "PUT" | "DELETE" | "OPTIONS" | "HEAD" | "CONNECT" | "TRACE" | "PATCH"

Call: {
@task(api.Call)

req: {
method: Method
host: string
path: string | *""
auth?: string
headers?: [string]: string
query?: [string]: string
form?: [string]: string
data?: string | {...}
timeout?: string
// curl?: string
retry?: {
count: int | *3
timer: string | *"6s"
codes: [...int]
}
}

// filled by task
resp: {
status: string
statusCode: int

body: *{} | bytes | string
header: [string]: string | [...string]
trailer: [string]: string | [...string]
}

}

Serve: {
@task(api.Serve)

port: string
quitMailbox: string

routes: [...{
// @flow() is needed to run sub-tasks per request, which is more typical
// you can omit if you only need to reshape the data with CUE code

// filled by hof/flow on each request
req: {
method: Method
url: string

headers: [string]: string
query: [string]: string

body: bytes | string | *{} // assumed json body if object
}

// any tasks you may need to convert the req -> resp
// these will be run after the `req` fields has been filled

// you construct the resp value which is sent back to the client
// (todo, make this include headers, code, etc
// for now, this is a value which will be turned into a JSON body for the response
resp: {
status: int

// one of, if none -> NoContent
json?: {}
html?: string
body?: string
}

}]
}
50 changes: 50 additions & 0 deletions docs/code/hof-schemas/flow/tasks/csp/schema.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// CSP (Communicating Sequential Processes)
// Named channels (mailboxes) and send/recv messages
// Similar to Go / Erlang concurrency
// Can be accessed from different flows/tasks
package csp

// Chan is a named mailbox
Chan: {
@task(csp.Chan)

// the name of the channel
mailbox: string

// how many messages can queue
// defaults to a blocking send / recv
buf: int | *0
}

// Send a message to a mailbox
Send: {
@task(csp.Send)

// the name of the channel
mailbox: string

// an optional key
key?: string

// the message value
val: _
}

// Recv is a coroutine which runs indefinitely
Recv: {
@task(csp.Recv)

// the name of the channel
mailbox: string

// the name of a second mailbox to quit on any message received
quitMailbox?: string

// the handler for a message, run as a flow per message
handler: {
// filled when a message is received
msg: _

// do whatever you like in here
}
}
21 changes: 21 additions & 0 deletions docs/code/hof-schemas/flow/tasks/cue/schema.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package hof

Format: {
@task(cue.Format)

value: _

Package: string | *""
Raw: bool | *false
Final: bool | *false
Concrete: bool | *true
Definitions: bool | *true
Optional: bool | *true
Hidden: bool | *true
Attributes: bool | *true
Docs: bool | *true
InlineImports: bool | *false
ErrorsAsValues: bool | *false

out: string
}
37 changes: 37 additions & 0 deletions docs/code/hof-schemas/flow/tasks/db/schema.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package db

// need to figure out how to separate out the connection
// so it can be create once and reused by queries
// possibly how to pool connections as well

// only SQLite supported currently

// Call a database
Call: {
@task(db.Call)

// db connection
conn: {
sqlite?: string // db name
postgres?: string
}

// args to Call
args: [...]

// Use only one of [query,exec,stmts]
query: string
exec: string

stmts: [...{
// Use only one of [query,exec,stmts]
query: string
exec: string
// args to statement, merged with top-level
args: string

results: _
}]

results: _
}
35 changes: 35 additions & 0 deletions docs/code/hof-schemas/flow/tasks/gen/schema.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package gen

// Seed the Range
Seed: {
@task(gen.Seed)

// only set to ensure consistent output while testing
seed?: int // defaults to time.Now()
}

Int: {
@task(gen.Int)
max?: int // max value if set

// the random val returned
val: int
}

Str: {
@task(gen.Str)

// number of runes to generate
n: int | *12

// possible runes, defaults to [a-zA-Z]
runes?: string
}

// the other tasks don't really have schema or input
c: string @task(gen.CUID) // like UUID, but for cloud
f: float @task(gen.Float)
n: float @task(gen.Norm)
t: string @task(gen.Now) // RFC-3339
s: string @task(gen.Slug) // related to CUID
u: string @task(gen.UUID)
13 changes: 13 additions & 0 deletions docs/code/hof-schemas/flow/tasks/hof/schema.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package hof

Tempate: {
@task(hof.Template)

name: string | *""
data: _

template: string
partials: [string]: string

out: string
}
25 changes: 25 additions & 0 deletions docs/code/hof-schemas/flow/tasks/kv/schema.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package kv

// in memory cue.Value storage
Mem: {
@task(kv.Mem)

// key to store under
key: string

// if specified, value to store
// otherwise the value in memory as filled in
val?: _

// delete the key & value
delete: bool | *false

// boolean for if the value was loaded
loaded: bool
}

// redis, etcd

// obj Stores (here?)
// mongo, couch, elastic
// s3 / gcs
8 changes: 8 additions & 0 deletions docs/code/hof-schemas/flow/tasks/msg/schema.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package msg

// todo, abstract message type 'Any'
// add more like rabbit, kafka, nats

IrcClient: {
// see github.com/verdverm/streamer-tools for an example
}
Loading
Loading