Skip to content

Commit

Permalink
+++
Browse files Browse the repository at this point in the history
  • Loading branch information
Offirmo committed Oct 12, 2024
1 parent 967d0f4 commit c9e4041
Show file tree
Hide file tree
Showing 6 changed files with 200 additions and 46 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { type URI‿x } from '@offirmo-private/ts-types-web'
import { type Hyperlink } from '@offirmo-private/ts-types-web'

import {
BaseRenderingOptions,
OnConcatenateStringParams,
Expand All @@ -11,33 +14,82 @@ import { Node, CheckedNode } from '../types.js'

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

interface Action {
$node: CheckedNode
type: 'link' | undefined
data: any
// priority ?
// TODO more
interface BaseAction {
$node: CheckedNode // the node where this action was found
}

interface HyperlinkAction extends BaseAction {
type: 'hyperlink'
data: Hyperlink
}

interface EmbeddedReducerAction {
cta?: string // optional bc should ideally be derived from the action (esp. for i18n) BUT same action could have different CTA following the context (ex. equip best equipment)
data: any // the data of the action, could be anything
}
interface ReducerAction extends BaseAction, EmbeddedReducerAction {
type: 'action' // in the sense of reducer(action)
}

type Action =
| HyperlinkAction
| ReducerAction

interface RenderingOptionsⵧToActions extends BaseRenderingOptions {
getꓽactions: (node: CheckedNode) => Action[] // will be executed on every node
}

interface RenderingOptionsⵧToActions extends BaseRenderingOptions {}
const DEFAULT_RENDERING_OPTIONSⵧToActions= Object.freeze<RenderingOptionsⵧToActions>({
shouldꓽrecover_from_unknown_sub_nodes: false,
getꓽactions: ($node: CheckedNode): Action[] => {
const actions: Action[] = []

if ($node.$hints['href']) {
actions.push({
$node,
type: 'hyperlink',
data: {
// TODO default CTA from $node itself?
href: $node.$hints['href'], // TODO escaping for security? (This is debug, see React renderer which will do)
rel: [],
},
})
}

if ($node.$hints['actions']) {
actions.push(...$node.$hints['actions'].map((action: EmbeddedReducerAction): ReducerAction => {
return {
// TODO default CTA from $node itself?
...action,
$node,
type: 'action',
}
}))
}

if ($node.$hints['links']) {
actions.push(...Object.values<any>($node.$hints['links']).map((link: Hyperlink): HyperlinkAction => {
return {
$node,
type: 'hyperlink',
data: link,
}
}))
}

return actions
},
})

type State = {
actions: Action[],
}

const on_type: WalkerReducer<State, OnTypeParams<State>, RenderingOptionsⵧToActions> = ({$type, state, $node, depth}) => {

const on_type: WalkerReducer<State, OnTypeParams<State>, RenderingOptionsⵧToActions> = ({$type, state, $node, depth}, { getꓽactions }) => {
//console.log('[on_type]', { $type, state })

if ($node.$hints.href) {
state.actions.push({
$node,
type: 'link',
data: $node.$hints.href, // TODO escaping for security? (This is debug, see React renderer which will do)
})
}
state.actions.push(...getꓽactions($node))

return state
}
Expand Down Expand Up @@ -67,9 +119,14 @@ function renderⵧto_actions($doc: Node, options: RenderingOptionsⵧToActions =
/////////////////////////////////////////////////

export {
type HyperlinkAction,
type ReducerAction, type EmbeddedReducerAction,
type Action,
type RenderingOptionsⵧToActions,

DEFAULT_RENDERING_OPTIONSⵧToActions,

renderⵧto_actions,

callbacksⵧto_actions,
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ interface SchemeSpecificURIPart {
/** (optional) the immediate parent in the cascade. Useful to resolve the full URI IF NEEDED
* TODO clarify how to set a "encapsulating URI" for properly detecting and resolving relative URIs
*/
parent?: SchemeSpecificURIPart
//parent?: SchemeSpecificURIPart
}

type URI‿x = Uri‿str | SchemeSpecificURIPart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
[ ] https://www.managingtheunmanageable.net/morerulesofthumb.html
[ ] https://www.tedinski.com/archive/
[ ] https://zknill.io/posts/every-programmer-should-know/
[ ] SWE at Google https://abseil.io/resources/swe-book/html/toc.html
[ ] technical things every software developer should know https://github.com/mtdvio/every-programmer-should-know
abstraction https://www.merrickchristensen.com/articles/abstraction/
access control -- Role-Based (RBAC)
Expand Down Expand Up @@ -89,6 +90,7 @@ commits -- conventional https://www.conventionalcommits.org/ https://gist.gith
compile to js
compiler
compiler -- stanford course http://openclassroom.stanford.edu/MainFolder/CoursePage.php?course=Compilers
complexity budget https://htmx.org/essays/complexity-budget/
compute
compute -- hosted compute
concurrency -- ABA problem
Expand Down Expand Up @@ -290,6 +292,7 @@ linked list
linting
locality
locality -- conflict locality = reducing conflicts on close changes, ex. enforcing trailing commas, sorting...
locality -- of behaviour "LoB" https://htmx.org/essays/locality-of-behaviour/
lodash
log
loop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
3 nines / 4 nines / 5 nines -- 3 nines == 99.9% uptime 5 nines == 99.999% uptime, this means your service is down less than 6 min in a year!
[ ] +++ https://github.com/donnemartin/system-design-primer
[ ] +++ https://lethain.com/distributed-systems-vocabulary/
[ ] API guidelines https://github.com/microsoft/api-guidelines/blob/vNext/graph/Guidelines-deprecated.md
[ ] architecture https://engineering.fb.com/2020/08/17/production-engineering/async/
[ ] client side API gateway "egress" TODO
[ ] concepts https://dgraph.io/docs/design-concepts/
[ ] great articles https://dgraph.io/blog/
[ ] https://carloarg02.medium.com/how-i-scaled-amazons-load-generator-to-run-on-1000s-of-machines-4ca8f53812cf
[ ] https://discord.com/blog/how-discord-stores-trillions-of-messages
[ ] https://github.com/microsoft/api-guidelines/blob/vNext/azure/ConsiderationsForServiceDesign.md
[ ] https://htmx.org/essays/
[ ] https://medium.com/@sureshpodeti/system-design-twitter-a98e7d134634
[ ] https://newsletter.pragmaticengineer.com/p/building-the-threads-app
[ ] https://slack.engineering/scaling-datastores-at-slack-with-vitess/
[ ] https://www.infoq.com/news/2024/01/discord-midjourney-performance/
[ ] https://www.youtube.com/watch?v=paTtLhZFsGE
[ ] kubernetes
[ ] microservice -- design -- https://www.salesforce.com/blog/microservice-design-principles/
[ ] paper "Adding new protocols to the cloud native ecosystem" https://docs.google.com/document/d/13wFFC7vIdB2hkxdyT0dSiGgkZTXCDDBeW_GBPqy9Jy0/edit
[ ] paper https://research.google/pubs/large-scale-cluster-management-at-google-with-borg/
Expand All @@ -37,6 +39,7 @@ ACID = a set of properties of database transactions intended to guarantee data v
API -- contracts
API -- Diogo Lucas classification = far-team, near-team and inner-team. inner team = used within a team or between partner teams, near team = "Conway APIs" between teams that don't always communicate with each other, Far-team API = between teams that have low-bandwidth communications
API -- hybrids = reconcile the need for a stable public API that will not constantly disrupt your carefully tended ecosystem with your team’s ability to move fast and (eventually) break stuff? cater for different requirements regarding security and SLAs or to radically different client natures? https://www.youtube.com/watch?v=eqy609JleoE
API -- REST -- POST https://www.tbray.org/ongoing/When/200x/2009/03/20/Rest-Casuistry
API -- visibility = public/external > internal > team > private beta. Guidelines: Consider a public-by-default approach, even if you are starting at a lower level of access (helps dogfooding, new use cases. Treat your internal APIs as candidates for Public level access (bc happens quickly, sometimes for merging with a public one)
API gateway
API-First = Built with APIs from the ground up. All functionality is exposed through an API
Expand Down Expand Up @@ -252,6 +255,7 @@ infrastructure as code (IaC) https://bluelight.co/blog/best-infrastructure-as-co
ingress/egress = “the act of entering”, “the right of entering”, or “the means of entering”
integrity
kafka = pub/sub + store + process
kubernetes
lambdalith https://rehanvdm.com/blog/should-you-use-a-lambda-monolith-lambdalith-for-the-api
latency = the time that passes between an action and the resulting response
latency https://www.a10networks.com/glossary/osi-network-model-and-types-of-load-balancers/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ hawks and doves https://seldo.com/posts/the_case_for_frameworks
helicopter parent
herbe toujours plus verte
Hickam’s Dictum: The opposite of Occam’s Razor. In a complex system, problems usually have more than one cause. For example, in medicine, people can have many diseases at the same time.
high school "What You'll Wish You'd Known" https://paulgraham.com/hs.html
high/low functioning human
Hock Principle: Simple, clear purpose and principles give rise to complex and intelligent behavior. Complex rules and regulations give rise to simple and stupid behavior.
Hofstede's cultural dimensions theory https://en.wikipedia.org/wiki/Hofstede%27s_cultural_dimensions_theory
Expand Down
Loading

0 comments on commit c9e4041

Please sign in to comment.