Skip to content

Commit

Permalink
+++
Browse files Browse the repository at this point in the history
  • Loading branch information
Offirmo committed Sep 22, 2024
1 parent 446fd8e commit 7f6ffd2
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"_build:dev:watch": "monorepo-script--build-typescript-package --watch --module=esm",
"dev": "run-s clean _build:dev:watch",

"demo": "node ./dist/src.es2023.esm/demo/index.js"
"demo": "node ./dist/src.es2023.esm/demo/index.js",
"demoh": "node ./dist/src.es2023.esm/hateoas/index.js"
},

"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function loop() {
console.log('/////////////////////////////////////////////////')
// always first
const $doc = State.getꓽrecap(state.u_state) // TODO clarify recap/mode
console.log(prettifyꓽjson($doc))
console.log(to_terminal($doc))

console.log('/////////////////////////////////////////////////')
Expand Down Expand Up @@ -73,45 +74,7 @@ function loop() {
}

/////////////////////////////////////////////////
/*

loop()
state = State.play(state)
loop()
*/
/////////////////////////////////////////////////
// https://github.com/kevinswiber/siren

interface Link {
rel: string // https://www.iana.org/assignments/link-relations/link-relations.xhtml TODO array?

cta: string
href: string
}

interface Response {
data: {

$doc: RichText.Document

}

links: {
// self must be present


[rel: string]: Link
}
}


function HATEOASᐧGETꓽⳇmodeⳇ() {

}

function HATEOASᐧGET(link: string = '/'): Response {

switch (link) {
default:
throw new Error(`Unknown resource "${link}"!`)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Immutable } from '@offirmo-private/state-utils'
import { type Hyperlink } from '@offirmo-private/ts-types-web'
import * as RichText from '@offirmo-private/rich-text-format'

import to_terminal from '@offirmo-private/rich-text-format--to-terminal'

import * as State from '@tbrpg/state'
import * as RRT from '@tbrpg/ui--rich-text'

import { prettifyꓽjson } from '../services/misc.js'

/////////////////////////////////////////////////

let state = State.create()
// TODO reseed
state = State.on_start_session(state, true)
state = State.update_to_now(state)

/////////////////////////////////////////////////

function HATEOASᐧGET(state: Immutable<State.State>, link: Hyperlink['href'] = ''): RichText.Document {
console.log(`HATEOASᐧGET("${link}")`)

// const $doc = State.getꓽrecap(state.u_state) // TODO clarify recap/mode


switch (link) {
case '':
return State.getꓽrecap(state.u_state)
default:
throw new Error(`Unknown resource "${link}"!`)
}
}

console.log('/////////////////////////////////////////////////')
let current_uri: Hyperlink['href'] = ''
const $doc = HATEOASᐧGET(state, current_uri)
console.log(prettifyꓽjson($doc))
//console.log(to_terminal($doc))
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@ root_logger.setLevel('silly')


import chalk from 'chalk'
import { injectꓽlibꓽchalk } from '@offirmo-private/prettify-any'
import { injectꓽlibꓽchalk, prettifyꓽjson } from '@offirmo-private/prettify-any'
injectꓽlibꓽchalk(chalk)

export {
prettifyꓽjson,
}

0 comments on commit 7f6ffd2

Please sign in to comment.