Dictionary
markdown-reader-web
sdk-api
sdk-api-keys
sdk-db
This operation is used to collect all typebase database models in the entire project, and export them, wrapped in a DbModels
interface. This is needed for creating a function that can access the entire database (see database operation)
sdk-env-private
This operation contains all private environment variables that can be used on the frontend and backend of your application(s).
Generated for bundles (to be set in BundleConfig), manually set for King OS.
NB: make sure not to import this in any frontend operations, because it may contain private keys and other secrets!
sdk-env-public
This operation contains all public environment variables that can be used on the frontend and backend of your application(s).
Generated for bundles (to be set in BundleConfig), manually set for King OS.
sdk-function-paths
sdk-interface-paths
sdk-js
operation that imports all js
functions and variables in the entire project (OS or bundle) and exports an object that has all of them.
can be generated
sdk-operations
Generated operation that exports an object that contains all names of all operations as keys, and all project relative paths to those operations as values.
Needed to find files more quickly in a more performant way.
When moving operations around, ensure to regenerate this to avoid conflicts.
sdk-ui
react-with-native
HTML elements with React Native capabilities.
react-with-native-alert
TODO: NB: seems not to work right now in a new template! Fix it
react-with-native-form
Create forms, fast
react-with-native-form-inputs
react-with-native-modal
react-with-native-notification
Makes it possible to receive notifications in both react and react-native.
react-with-native-router
react-with-native-select
react-with-native-store
Simple localStorage/asyncStorage-based and fully typed redux replacement with global persisted storage by default for react and react-native apps.
react-with-native-table
react-with-native-ui
Simple basic Tailwind class strings for sensible UI components
use-url-store
ai-functions-node
ai-types
all
This operation contains a lot of different functions that can help you to execute different things on all operations.
api
This object contains an api function for every function in the backend
NB: only use this if you can access localStorage of the browser or the app. This means this won't work in node or in getStaticProps functions or so
api-store
api-types
api-related types needed for the api operation
asset-functions-js
Please set a description for this operation in OPERATION.md
This is a js operation. This means you cannot use any react or node, it's pure typescript, compiled to javascript, and can be used anywhere.
asset-functions-node
asset-input
This component lets you easily add asset input that includes upload with the typerepo
server standard (function-server
)
Add the css to your web project: import "asset-input/css.css";
asset-type
All types related to asset upload
asset-view
AssetView
shows an asset. Every file-format has a different way to be rendered.
augmented-word-node
augmented-word-types
auth-types
authentication
big-button
breadcrumbs
frontend component to show a file location in a nice way (breadcrumbs)
bundle-types
bundle-util
cleanup-typescript-database
Collection of functions to cleanup the typescript database (all typescript related models)
clickable-icon
code-types
collect-static-assets
comment-util
compile-typescript
context-menu
convert-case
cool-toast
csv-util
database
db-crud
db-recipes
Useful library of functions that wrap the fs-orm database.
TODO: should probably be split up further to differentiate between db-ui functions and a more general purpose library
db-util
encrypt-password
explore-project
explore-project explores the whole OS or project, so information about the project can be shown in a UI or used in another way
fancy-loader
ffmpeg-util
file-search
Exposes functions to easily create a file-search menu in your react-app
filename-conventions
Any functions and variables related to filename conventions
find-all-dependency-operations
folder-get-updated-at
Get last updated file updatedAt time in whole folder, recursively
frontmatter-util
fs-orm
ORM that lets you create a database with models that are stored on the file system in multiple formats that are easy to understand and well structured.
fs-util
General purpose wrapper around node:fs
and node:path
that should be used instead of those, because it removes some of its painpoints, removes unneeded stuff, and adds some other useful functions.
fs-util-js
function-context-type
function-form
Component that lets you easily create a frontend form for any function in your project (both backend and frontend functions)
function-functions-node
function-server-types
function-types
generate-index
geo-types
get-imported-dependencies
get-imports-exports
get-package-json
get-package-source-paths
Returns an array of absolute file paths of (typescript) files in the src of your operation
get-path
Useful functions to get paths within King OS.
Depends on sdk-operations, which makes it only work inside of a typerepo.
get-ts-config
Gets the TsConfig given a path to an operation
hotkeys
Operation exposing any utility function related to hotkeys in the browser
index-typescript
This repo is used to generate the typescript index.
Some important conventions I'm applying:
-
The generated index doesn't know the absolute location, which makes it possible to move around the Project in the OS
-
The generated index only tells you information about this very operation. All links with other operations should be done in postprocessing
-
Every generated index has an
IndexId
js-util
json-util
k-explore
exploration functions for exploring files within King OS
Currently has a thin dependency on get-path, but this can probably be removed to make this operation more general purpose (and work outside of King OS too)
k-test
key-value-markdown-js
labeled-button
language-types
layout
lint
log
Log a message with a special type
make-test
markdown
this uses react-markdown
to render markdown in the browser with react...
This is a ui-esm operation. This means it's a ui operation that builds to javascript with ESM module resolving... It was based on this example: https://prateeksurana.me/blog/react-library-with-typescript/
markdown-parse-js
js-only operation containing all kinds of functions that help parsing markdown
markdown-parsings
markdown-reader-functions
markdown-reader-functions-js
markdown-reader-types
markdown-types
marked-util
matter-types
measure-performance
menu
minify-build
model-types
name-conventions
Any functions and variables related to variable declaration naming conventions
nested-menu
nested-menu-types
next-a-link
next-types
one-by-one
operation-util
Operation with utility functions to calculate things about operations and alter operation-index.
parse-primitive
path-util
Gets insightful information about any file or folder (path)
peer-types
persona-functions-node
pluralize
KISS; fuck grammar
If we are going to apply grammar here, it becomes impossible to create typescript rules that can detect and convert plural/singular parameter names.
To pluralize any word we simply attach an "s" at the end
port-conventions
Any functions and variables related to port conventions
prompt-components
react-with-native-form-asset-input
Please set a description for this operation in OPERATION.md
read-csv-file
read-json-file
read-kvmd-file
read-markdown-file
read-typescript-file
reader-ui
rebuild-operation
Operation that makes it possible to rebuild an operation (re-index, re-build, etc.)
recursive-types
recursive-util
rest-util
run-child-process
say
Operation that contains multiple functions that wrap the say cli on MacOS to let the device speak out text.
Can later be extended to wrap other clis or even api's.
Should also be extended to work on multiple operating systems.
schema-util
It's hard to work with them if you don't know what means what. In this operation I'll summarize everything and give examples.
server-api-url
Operation that exports the api url that the api should be able to be found at, according to the users environment, the typerepo convention and your public environment variables.
server-login
This operation exposes rudimentary functions to set cookies from the backend. We require cookies in order to authenticate a user for GET requests. Cookies are sent to the server for every request and are a safer way, because they are not part of the URL that can be found in the browser history.
This thing is far from finished, see todo/
for what needs to be done.
set-json-key
Useful functions to alter JSON files (can be used both with node or with a CLI)
share
short-markdown-parser-js
short-markdown-parser-node
short-markdown-types
short-markdown-writer-input
simplified-schema-form
component that generates a form using react-with-native and a SimplifiedSchema. Can obtain any JSON object from the user.
sms
social-media-types
I want a type interface collection that is able to collect all data from all social networks and put them together.
string-to-json
Parser functions to parse strings (that can be inputted in the command-line) into objects (that can be read in functions)
text-or-binary
This operation provides handy functions to check whether the contents of a file are of a text or binary format...
This is a js operation. This means you cannot use any react or node, it's pure typescript, compiled to javascript, and can be used anywhere.
todo-types
types related to the upcoming todo-ui
This is a js operation. This means you cannot use any react or node, it's pure typescript, compiled to javascript, and can be used anywhere.
tooltip
Please set a description for this operation in OPERATION.md
try-parse-json
ts-morph-util
ui-util
use-on-screen
watch-types
webpage-types
write-to-assets
Function to write anything to assets.
writer-functions
writer-input
component to create a writer input
This is a ui-esm operation. This means it's a ui operation that builds to javascript with ESM module resolving... It was based on this example: https://prateeksurana.me/blog/react-library-with-typescript/
writer-types
getStaticPaths
getStaticProps
progress
queryClient
A
ActivityIndicator
Aside
Button
Div
Form
Form is just a html form on web. On react-native, it's a View
getTailwindModules
H2
I
Image
Input
joinClassNames
Label
Li
Nav
Ol
P
Pressable
button on web, pressable on react-native
PureAside
PureDiv
PureNav
Select
renders either a SelectDropdown or SelectDrawer, based on screensize
Span
Strong
Svg
TextArea
Text
if there is a data model with just a single text and it is clear from the name of the model what it should be, better call it either text or markdown.
Toggle
TouchableOpacity
button on web, pressable on react-native
trimClassName
in react-native not all classNames are supported
Ul
wrapInTextIfNeeded
NB: figure out a way to do the styles of the text right.
AlertContext
AlertProvider
useAlert
DataForm
DefaultInputContainer
DefaultTitle
errorOnField
getPlugin
GLOBAL_PROPERTY_PATH
inputClassWithoutWidth
isWeb
makeInputField
sameFieldArray
setConfig
castToNumber
DateInput
CSS Modules, react-datepicker-cssmodules.css
DatetimeInput
defaultLatidue
defaultLongitude
defaultZoom
FileInput
isNumber
LabelsInput
MapInput
NumberInput
PasswordInput
PhoneInput
SelectInput
SelectMultipleInput
StarsInput
TextAreaInput
TextInput
TimeInput
CSS Modules, react-datepicker-cssmodules.css
ToggleInput
ModalContext
ModalProvider
{ Provider }
useModalState
useModal
ToastContainer
toast
title is only shown on native
useRouter
getRealValue
useSelectMultiple
Create a value selector in a single line of code, including its state!
useSelect
Create a value selector in a single line of code, including its state!
const [SelectView, view, setView] = useSelect(views);
contextKey
contexts
createStoreProvider
Function to create the StoreProvider
NB: this function uses a local variable on the main scope of javascript in order to create the Context components dynamically. Beware!
createStore
One function is all you need to make a new store!
Example:
import { createStore } from "react-with-native-store";
import { TypeA, TypeB } from "your-types";
export const writerInitialValues: {
itemA: TypeA;
itemB: TypeB;
} = {
itemA: "",
itemB: {},
};
export const { useStore, StoreProvider } = createStore(writerInitialValues);
Simple as pie 🍰
createUseStore
Function to create a hook for accessing the store
debug
getContext
Gets the current word you are typing from a text and the cursor position.
Takes into account multiple word separators: tabs, newlines, and spaces.
getItem
If you don't have access to the useStore
hook, maybe because you're doing something outside of react... you can directly use the storage with javascript using this function
getKey
setItem
If you don't have access to the useStore
hook, maybe because you're doing something outside of react... you can directly use the storage with javascript using this function
BEWARE! Updating this won't update your react components!
StoreContextProvider
getColumns
gets all columns you can present based on a modelname, the interfaces of that model, and the data
renderColumn
Skeleton
TableHeadItem
TableRow
Table
tdClassName
bareInputClass
inputClass
UI
useCustomUrlStore
Hook to store simple data in the URL
I spent the last 4 hours on this: I think it's pretty useful. It's a hook that makes it possible to use your URL as a state store. It works with arrays and single values of strings, booleans and numbers. It's a drop in replacement of useStore or useState. The advantage is that the user can share the URL which will also share their state. Usage in a component looks like this:
const [name, setName] = useUrl("name");
I was looking for ways to make the api more straightforward, especially the stuff in useUrl seems a bit messy. However, I couldn't find any way to make it better. Any tips are welcome!
TODO: make it work in react-native as well, either via a wrapper around useStore or via using the react-navigation param-store
import {useCustomUrlStore}from "use-url-store";
export const useUrl = <T extends keyof typeof queryStore>(queryKey: T) => {
const queryStore = {
"type-index-type": useCustomUrlStore<string | undefined>("type-index-type", {
type: "string",
}),
"has-comment-types": useCustomUrlStore<string[]>("has-comment-types", {
type: "string",
isArray: true,
}),
"interface-is-db-model": useCustomUrlStore<boolean>("interface-is-db-model", {
type: "boolean",
}),
path: useCustomUrlStore<string | undefined>("path", { type: "string" }),
name: useCustomUrlStore<string | undefined>("name", { type: "string" }),
type: useCustomUrlStore<string | undefined>("type", { type: "string" }),
};
return queryStore[queryKey];
};
controlChatGptCli
controlChatGpt
getContextualPromptResults
Gets all contextualPromptResults, but only if specific things are true
TODO:
- For any prompt we have for this filetype: get it from the database
- For prompts about a folder: path/to/folder/.index/prompt-results.json
- For prompts about a file or a selection thereof: path/to/folder/.index/[filename]/prompt-results.json
NB: the slug of the ones in index should be the ID, and does not need to be set by the user, because we cannot guarantee that it's no duplicate.
getContextualPrompt
getContextualPromptsArray
Wrapper around the database to support the usecase of storing a file in a custom location for contextualPrompts.
getContextualPrompts
Returns all contextual prompts for the selection and for the page with the right context type
getFolderRelativeScopeDbFilePath
Function to centralise the convention of the db file location of a scoped prompt
processChatGptPrompt
allOperationsRemoveJsSrc
BEWARE! This removes all .d.ts, .js, and .d.ts.map files in your source folder!
allOperationsToMarkdown
clearAllTsDatabases
codeAll
opens all files in vscode
[debug]
[folderName, basePath]
forAllFiles
executes a command or callback for every file
in commands, $LOCATION is provided as env variable, and command is executed in the dir of the file
forAllFolders
executes a command or callback in every folder of a certain type. Supports git repos and operations now
getAllOperationClassifications
gitShipAllRepos
gitShipAllPackages
Just ships code everywhere to github, wherever there's a git folder and there are changes.
mdAllOperations
minifyAllOperations
minify all operations everywhere. optionally:
- enable the shell
- specify a basepath (tools by default)
publishAllOperations
Script to publish all packages everywhere (that also runs prepublish). Only src in git, only build in npm.
removeAllFiles
removes all files that have an exact match of the location (folders not because we use rm without -rf)
removeAllFoldersCli
removeAllFolders
removeAll
removes all xyz for a folder
make sure to specify which type you want.... folder or file most likely
renameAll
renames all files to a new name (optionally a func, based on the old path)
runScriptEverywhere
runs a package script in all tools operations
NB: uses npm insead of yarn, but for scripts this shouldn't matter
[script, startIndex]
[search]
setScriptEverywhere
set package.json script to another value in all operations in tools folder
test
[type, command, fileName, basePath, folderName, shellString]
API_NO_RESPONSE_TIME_KEY
apiWithConfig
This object contains a api function for every function in the backend
The difference from api is that it allows you to also insert custom api configurations
AUTH_TOKEN_STORAGE_KEY
fn1
There is probably some doc-comments available for the function, maybe we can fix this with proxies to pass those comments... that would be insane.
fn2
fn3
getGetApiUrl
gets an api url for a context get api
returns something like [apiUrl]/[apiFunctionName][queryString]
queries
This object contains a react-query useQuery
hook for every api function
sdkExample
untypedApiFunction
Used for calling the actual api for a function with some config
NB: this is not a typed function as we are just overwriting it so we don't need any inference on this
apiStoreInitialValues
{ StoreProvider, useStore }
apiConventions
API conventions:
xyzGetApi
is only available via GET, the rest is only available with POST.xyzWithContext
is taking FunctionContext as its first parameterxyzWithContextRaw
is taking FunctionContext as its first parameter, and is expected to return the raw return type the function returns.
contextFunctionConventionSuffix
getFunctionConventionSuffix
rawFunctionConventionSuffix
addToken
If previousToken is not present, will be generated randomly
ensureToken
Remove the token (if present), then add it again
findAssetParametersRecursively
Recursively finds all asset parameters in an object (for example in a database model item)
getAssetDirectlyApiUrl
getConversionInfoFromType
Received files contain a "type" like "audio/mp3" or "image/jpeg", etc...
Here the extension is decided.
NB: we also need to convert the file itself in case of mp3
getExtensionFromAsset
Returns a preliminary filename, based on the Asset
getNameFromRelativePath
getNameWithTokenFromRelativePath
first gets the name from the relativePath
then ensures the token is attached (if not already there)
getReferencedAssetApiUrl
getTypeFromUrlOrPath
We are assuming the asset name and extsion appear at the end of the URL
readableSize
removeTokenIfPresent
tokenPrefix
NB: any filename should not be expected to enter this as part of its name. Otherwise it breaks the code and the filename will be changed to the thing before this string.
NB: don't put any things inhere that are different, slugified, as the name will be slugified!
compressAsset
Audio, image, video can be compressed. This should be done to logical defaults, can be turned off, or can be specifically set to other dimensions using a doc-comment on the model.
- audio: bitrate
- video: fps and resolution
- image: resolution
Returns the new absolute path of the compressed asset (which can be the same as the initial path)
deleteReferencedAsset
downloadRemoteAsset
Download a remote asset to the assets
folder (temporary location)
used for:
- giphy
- google images
- unsplashed
- p2p
- youtube to mp3 picker
- youtube to mp4 picker
- project assets (via api)
findAbsoluteAssetPathFromReference
findAllProjectMedia
Media:png, mp4, mp3, zip, pdf
- finds all media in all
db
folders. Can be anywhere, so an explore will probably be best. - finds all media in every operation in any folder except for
node_modules
,db
,src
,build
, [anything]. (so mostly intodo
,docs
andassets
) - find all media in every other folder that is not an operation
Return all of this as project relative path array
getAssetDirectlyGetApi
Useful for getting assets directly, for example for the SelectMedia
component for project
-media
Requires more access rights
getReferencedAssetGetApi
Function to get a referenced asset that has been referenced from any db-model or any ts, tsx or md file, anywhere in the project.
Assets should only be exposed if you have access to the model they are referenced in or to the md file they are referenced in.
Exposes all assets like /asset?path=/text/interests/programming/storage-of-data/best-storage-methods.md&asset=./audio-is-amazing.m4a
Assets are only exposed if they are referenced in a markdown file that is accessible to the user. So when looking up the asset, make sure there's a link to it via []()
or ![]()
in the markdown that is connected to it in the URL. If not, don't expose it!
This can be used for any ui that has the functions backend available.
The advantage is that we don't need to build it, this works in dev
mode. there is no asset duplication.
since the name is getReferencedAssetGetApi this should be exposed on getReferencedAsset
IMPLEMENTATION NOW:
-
check referencing file to find the reference.
-
for markdown, typescript:
](./xyz)
-
for json:
"relativePath": "./xyz"
-
If this occurs, calculate abosolute asset path from referencing file folder + relative path
-
If this asset exists, expose it.
getStorageLocationInfo
returns the type of file the asset is referenced from, and the baseFolderPath
where the asset
should be stored
getTemporaryAssetsFolderPath
mediaExtensions
processAsset
Processes an asset by moving the file in the right location, if needed...
- Alt is kept, nothing to do with it
- Giving a different name will change the new path
- relativePath is checked if it exists (if temporaryDestination is undefined). It is used to obtain the extension.
- temporaryDestination must be checked. if it exists, must replace the file on relativePath calculated from name
After processing, this function should return a BackendAsset without the non-storable parameters
BEWARE: absoluteReferencingFilePath
, and for db-models also modelName
, need to be given here! Otherwise this won't work!
processItemAssets
processes all assets in an item and returns the new item
removeOldTemporaryAssets
All temporary assets that were created more than 24 hours ago and are still there, will be removed by this function.
This allows us to easily delete assets without concequences and also if the user closes a form without submitting it, these assets uploaded will go away.
This function should be executed using a daily CRON
serverDownloadReply
Returns a server.reply.download
or server.reply.file
but also sets the Content-Disposition
header correctly and the Content-Type
For this I finally ended up using builtin server.js stuff, we don't need to set those manually...
See https://serverjs.io/documentation/reply/#file- And https://serverjs.io/documentation/reply/#download-
See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
NB: ensure to return the result of this function in your endpoint, otherwise it won't work
uploadAssetWithContext
Uploads an asset to the server, and puts it in a temporary location in the assets folder of function-server
. It returns the filename of the file in the temporary location.
It can only be accessed through that random name. This random name has 32 characters so cannot be easily guessed. This should be secure enough. The file should be moved to the final destination in the actual function that needs the file.
NB: this function only works by providing a file as blobs under the "file" property name!
ASPECT_RATIO
AssetInput
Audio
base64UrltoBlob
Taken from https://github.com/mozmorris/react-webcam/issues/65#issuecomment-385126201
There are probably much better solutions
getTypeFromFileBlob
HEIGHT
makeBackendAsset
MediaRecorderComponent
MediaRecorder
ReactMediaRecorder
SelectMedia
videoConstraints
VideoPreview
Video
WebcamCapture
WIDTH
AssetView
defaultClassName
getSrc
InteractiveAsset
shows an Asset with interactivity
- Any file shows the name of the file, the size, and a link to open it in a new tab in the browser
- Images show thumbnail
- Audio show duration and amplitude
- Video/screen show thumbnail and duration
itemGetBackendAssetUrl
Get remote url for a BackendAsset in an AugmentedAnyModelType
database model item.
If you provide an array it'll take the first asset.
ModelItemAssetView
useAssetInfo
useAsset
cache
getAugmentedWordObject
getAugmentedWords
Gets all augmented words of the entire project
- words with their definitions, if available (
/dictionary?word=x
) - functions, interfaces, variables, operations (
/[operation-path]#name
) - if this is an OS-project, also bundles (
/[docs-path]
)
getBundleAugmentedWords
NB: should only be executed if this is not a sensible-project, as it might not have BundleConfig otherwise
AuthenticationMethodsCrud
LoginForm
LoginWrapper
ensures the auth-token is set
MeAuthenticationInfo
little component for in banner that shows your info on top, and links to signup/login etc
PersonProfileDetailsForm
PictureWithInfoDropdown
Dumb (presentational) component for a picture with info and a dropdown
PublicPersonComponent
PublicProfile
SignupForm
UpdateMeForm
BigButton
BreadCrumbs
Shows where we are in the filesystem
renderBreadCrumbs
getBundleSummary
Summarizes a bundle config so it can be used easily in things like explore project
getDbModelsForBundle
Gets all TsInterface's that are used in a bundle according to a BundleConfig
cleanupTsDatabase
From all Ts Index Models, removes the instances that refer to a ts file that doesn't exist anymore in the operation.
shouldDeleteTsModel
ClickableIcon
Renders a simple clickable icon with some styling
Icon can be either an icon (Svg src) or emoji (string)
abc
commentTypesConst
commentTypes
contentTypeConst
Improves the convention for parameter names that refer to models. probably it's better to do this: slug/id/index
are reserved on every model, let's call them "Ref". modelNameRef
refers to modelName. But what if you want to call it differently? Then you'd need to distinguish a prefix from the modelName. Let's do this with a underscore (no dash because underscore preserves ability to dotting on the object). If you want a reference to a user be called author, you'd name it author_userSlug
.
TODO: reduce all TsInterfaces and functions into their parameters :D
datasetConfigKeys
datasetFilterOperatorConst
NB: keys are made humanCase
and used in UI, so keep a readable name
dbStorageMethodsConst
dbStorageMethods
getExamples
getFunctionExersize
indexDbModelFolders
indexDbModels
All type interfaces that are used to index stuff, which are added to the database
NB: It's not handy to get this from the database because this is used to generate the database xD
modelViews
operationClassificationConst
runEveryPeriodReadonlyArray
runEveryPeriodStringArray
typescriptIndexModels
copyCopyPairs
copyReaderStaticAssets
findReaderStaticAssets
markdown-renderer turns a relative link into this: ?mdpath=x&relativePath=y
for static, we need to turn it into something similar, but we need to guarantee no file collisions. simple!
we can just take the project-relative file path of the asset, and put it in /public/images in next.js. the final url of the asset in public next.js then becomes images/[path/to/asset.jpg]
findStaticAssets
Returns the absolute paths of all static assets (embeds and links) in a markdown file of which the path is provided.
stripCommentEnd
only strip slahes for single-line comments
stripCommentStart
stripComment
parses comments (single line, multiline and doc) and removes the comment syntax
- removes slashes
- removes multiline comment prefix
- removes multiline comment suffix
- removes doccomment stars
example input: // comment
, output: comment
example input:
some
multiline
comment *~/
output:
some
multiline
comment
stripSlashes
stripStar
trimSurroundingNewlines
removes new lines at beginning and end
NB: This function uses a small recursion! I don't know if this is very efficient, but shouldn't be too deep!
NB: it should be noted that a newline apparently seems to be counting as a single character! Strange.
trim
getCompileErrors
gets compileErrors of an operation. if it has no errors, it also check all dependants to see if they have errors, possibly because we changed this one
- get buildErrors for all src files of current operation
- if build doesn't succeed, only check for build errors in current operation
- if build succeeds, check iffor build errors in all files in all operations that depend on this one. this means we need compile to be ran for every operation
TODO: Later, only check all build errors of all dependants if and only if an export blueprint (io) has changed and if this export was imported there
[ operationBasePath, operationManualProjectRoot, typerepoManualProjectRoot, ]
writeBuildErrors
ContextMenuItemComponent
useContextMenu
Use this if you want to render a context menu where the menu closes if you click one of the items.
Optionally, you can create a custom renderer for it.
useContextPopper
Use this hook if you want to create your own custom render that opens on the right location once the onContextMenu is fired.
useContext
Use this if you want to create a completely custom behavior from a context action. On top of the default onContextMenu behavior, this hook enables the possibility for a custom hold duration on mobile.
camelCase
capitalCase
capitaliseFirstLetter
convertCase
convertToTargetCasing
getDelimiter
humanCase
kebabCase
lowerCaseArray
converts any string to an array of lowercase words
format ["word1","word2","word3"] from a string of any casing.
nonCasingDelimiters
pascalCase
snakeCase
splitCasingDelimiters
errorToast
infoToast
showStandardResponse
Useful to show if the api has a standard response
successToast
warningToast
csvItemArrayToCsvString
make csv string from a csv model type
exampleCsvItems
the same as exampleCsvString
exampleCsvString__OLD
exampleCsvString
exuivalent to exampleCsvItems
tryParseCsv
This function parses a CSV into the object it says it has in the header
dbConfig
db
generateCsvInstance
generateJsonSingleInstance
generateKvmdInstance
generateMarkdownInstance
generateSlugTestModel
getCli
getMergedQueryConfig
getRanomAge
get
main
migration
randomName
removeCli
runModelEndToEndTest
NB: we can't do a maketest because this thing relies on logging and we don't want to auto-run it
set
Can set a markdown item into a subfolder in the db model folder
testDb
a db is created with models from all different db storage methods
testOperationModels
Test if it can find all OperationIndex
, OperationConfig
, PackageJson
, TsConfig
testPerformance
updateCli
upsertCli
upsert
Takes stored data and an item
- updates the data and sets some rows to "item" if the item is found (through the id or slug)
- otherwise inserts
NB: this function works for any storage method except for key value markdown
CrudGrid
CrudTable
CrudTimeline
CrudTree
DatasetForm
dbCrudInitialValues
DbPage
defaultLimit
{ deleteDbModel }
{ getDbModel }
getPropertiesDataParameterNames
IndexInstanceContainer
container for any index instance that needs to be rendered in the explore page
ModelComponent
In the table headings, all xxxSlug, xxxId etc should be called xxx.
In the table values, all slugs and ids should show the name of the instance of the refered model.
It has to be possible to navigate to an id or slug using #[id] or #[slug]
in the URL, just add div ids to all rows
openWhatsapp
SearchBar
shimmer
SimplifiedSchemaFormDebug
sortToItem
SpaceCard
toBase64
{ upsertDbModel }
UpsertForm
TODO: Provide all the fetched data with hasMore
and fetchAll
to the SimplifiedJsonForm
UpsertPage
useInfiniteGetDbModel
useModelFromUrl
takes the model from the url
useUrl
cacheLookup
Wrapper function to cache any function and invalidate it, in some way
caching automatic cache invalidation if data sources are updated optimistic caching after cache invalidation
calculateOperatingSystemBundle
This function should calculate a giant bundle for the whole operating system. This should include everything, public.
Used to show the whole os as a bundle.
deleteDbModel
deletes an instance of an db data interface from the db in a typesafe way
functions
getCachedFunctions
TODO: it would probably be good to create a more general purpose caching function
getDatabaseMenu
Finds all relevant Db models to show in the menu
- for a bundleId, it gets all models from the bundleSummary
- for a bundled project (bundled) gets all models from the packages
- for the main project, gets all models from sdk-db directly
TODO: NB: the first and the second are not the same, so this needs to be cleaned up.
getDbModelMetadata
getDbModelNames
getDbModel
gets all instances of an db data interface from the db in a typesafe way
getFunctionIndex
finds function indexation from database
TODO: this should be used!
getNestedDatabaseMenu
TODO: support search for bundles (but this can be augmented word based)
getReferencableModelData
Get referencableModelData for a single DbModel.
NB: this does not get the items that can be referenced in that model!
For getting all required ReferencableModelData
for the prop in SimplifiedSchemaForm, use useGetReferencableModelData
.
hasDbRecipes
Simple function to test whether or not the DbRecipes endpoints are available. If it returns true through the api, the other ones are also available.
makeSrcRelativeFolder
gets a src relative folder path (so maybe "" for a file src/util.ts
or "util" for a file src/util/thing.ts
)
testFnWrapped
testFn
tsInterfaceToDbMenu
upsertDbModel
upserts an instance of an db data interface from the db in a typesafe way
validateInput
wrapper function that takes that data but also the interface of the function and validates the parameters before it executes the function.
validateResult
wrapper function that takes that data but also the interface of the function and validates the parameters before it executes the function.
wrapFunction
filterInterfacesFromOperationNames
getDbModelsFromOperations
comparePassword
Method to check if a raw password should be the same as the encrypted variant. Uses bcrypt
encryptPassword
Method to encrypt any password. Uses bcrypt
exploreOperation
for every package.json it finds, it explores the root, src, and docs.
- in src, index is ignored
- in docs, only md is found
- in the root, only md is found
- for every file in src, it shows and finds all functions, interfaces and variables, through the indexation from it
exploreProject
TODO: still needs to be cleaned up. It's a huge function now with many useful components. Split it up!
- explores all files and folders until it finds a package.json.
all items in the explore tree are clickable in the ui, and lead to different pages
- a folder leads to a summary of what the folder holds
- a operation leads to a summary of the operation
- a ts file leads to all functions, variables, and interfaces in that file
- a function, variable, or interface leads to specific pages for those things. the data, if available, is attached to the interfaces.
- a md file leads to the editing user interface (with context) of that file
- a json file leads to a CRUD for it...
In the end the data it generates should stay up to date, so it's important this exploration happens fast enough. The data involved is simply walking the filesystem once (a small subset of it) and opening some index files (fun)
LATER: some more things that would be useful:
- watching all files that are also explored for changes using some watcher
- if something changes, recalculating that part and pushing it to the UI, making the thing going over the line small so it'll be super fast, even over slow internet.
however, this is premature optimisation. on my m1, locally, it's probably fine to just recalculate every second ^^ and send a couple megabytes over the line.
getExplorationType
gets the exploration type from an absolute type
getFileWithExtension
getFolderExplorationDetails
getFrontmattersMappedObject
getInstanceNames
returns the paths of instances in a file, like functions, variables or interfaces
getProjectRelativePaths
get file paths within your project
getTodoPages
getTodoPages(): WebPage[]
function:
- use getProjectRelativePaths, map the result to a queryPath + file
- [operation-name]/[todo-relative-file-id] for operations
- [folder-name]/[todo-relative-file-id] for todos within folders
getTodoPaths
hasSameProjectPath
function that returns a filter function that can check if some object (that extends an TsIndexModelType) has the same relative file path from the project root
FancyLoader
compressImage
compressImagesCli
compressImages
searches the folder recursively for all images and converts them to webp
convertToMp3
Uses ffmpeg to convert a file to mp3
Returns the new file path on success
convertToMp4
Uses ffmpeg to convert a file to mp3
Returns the new file path on success
MatchingText
Component that highlights the matching text
PathSearchResults
allowedSearchContentExtensions
buildFolderName
databaseFolderName
extensions
fileTypes
frontendOptionalFileSubExtensions
these special operations are generated, so should not be copied, but should be generated in the bundle after everything is copied
generatedFolders
getFileTypeFromPath
getWriterType
Gets the writer type based on the extension
hasSubExtension
Returns true if a fileid includes one of the specified subextensions.
isGeneratedOperationName
isGeneratedOperation
isIndexableFileId
jsonExtensionsConst
jsonExtensions
markdownExtensionsConst
markdownExtensions
operationUnindexableNamesOrSubExtensions
projectRelativeGeneratedOperationsFolder
sourceFolderName
typescriptExtensionsConst
typescriptExtensions
findAllDependencyOperations
to be used when you need to know all dependencies for multiple operation names at once
TODO: NB: this breaks with circular dependencies
findDependantsRecursivelyTest
findDependantsRecursively
findDependants({
operationName: "js-util",
importName: "notEmpty",
returnOperationName: false,
}).then(console.log);
findDependants
getDependencyTree(["k-types", "fs-orm"], []).then((res) =>
console.dir(res, { depth: 999 })
);
finds all dependants of an operation or a specific import from that operation
normally returns the files where the operation or function is used, unless you specify to return the operationNames only.
findDependenciesRecursively
finds all dependencies of an operation name
findMonorepoModules
finds all dependencies of an operation name
getDependencyObject
findAllDependencyOperations(["fs-orm"]).then(console.log);
how do I get a format like this?
const x = {
"fs-orm": ["js-util"],
"js-util": [],
}
getDependencyTree
test2
folderGetUpdatedAt
get last updated file updatedAt time in whole folder, recursively
frontmatterParseToString
Parses frontmatter object into a frontmatter string
frontmatterToObject
getFrontmatterValueString
objectToFrontmatter
parseFrontmatterString
Parse a string as stored in frontmatter back to the original string
quotedOrNot
For now, simply quote a string if it contains commas
There are probably more edgecases that need to be fixed here
stringifyNewlines
addDefaultValues
Adds timestamps, id, and a slug IF these things are not already present
NB: slugs will be slugified here! NB: if there is a name present, slug will be added here!
NB: for kvmd storage, id will be set to a kebab-case of the name
NB: does not add the ModelLocation parameters
alterAny
low level function that alters data from any storage method at a certain location
comprises all dbStorageMethods
alterCsv
Alters a csv
alterJsonMultiple
Alters a json multiple file
alterJsonSingle
Alters a json single file
alterKeyValueMarkdown
alterMarkdown
Alters a markdown file
augmentItemWithReferencedDataRecursively
calculateOperationsObject
relative
Needed in case of manual project root, otherwise use SDK!
Returns project relative operation base paths
categoryStackCalculated
createDb
Create your database by passing your models as a generic and some optional configuration
findParent
this location matches any category that equals the categorystack
getAugmentedData
Gets the stored data from any file with any storage method, and augments the modelLocation onto it...
Also augments the name
, slug
and categoryStackCalculated
onto this if the dbStorageMethod
is markdown or jsonSingle
and if operationRelativePath
is not set
getDatabaseFiles
This function gets the files that the data can be stored, by convention, based on the model and the config
Only returns the file paths that actually exist.
CONVENTION:
When searching for data, fs-orm will look in:
db/
in your project rootdb/
in any operation
In these folders, fs-orm will search for files based on your storage method. @see DbStorageMethod for more info
Returns not only the file paths, but also where they were found (operationName, projectRelativePath, operationRelativePath
)
getDatabaseRootFolder
Tries to get the root folder where the database folder can be found.
If an operationName is specified, this will be the operation base path If not, this will be the project root.
getDbFileLocation
Used by groupByFile, which is used for set (and thus, also update
) and upsert: determines the new file location.
Applies the convention to get the db-file-location of an item
Based on the merged config:
- if
operationRelativePath
is specified, gets a filePath in the operation - if
projectRelativePath
is specified, gets a filepath in the project - otherwise gets the pattern and replaces "*" with the slug (or id if slug is not available)
Besides the absolute path, the operationName, projectRelativePath and operationRelativePath are also supplied.
NB: currently, the item's operationName
, operationRelativePath
or projectRelativePath
is not taken into account. It will simply look at the convention to see where it should be saved, and apply the MergedQueryConfig...
getDbStorageMethodExtension
getDefaultLocationPattern
DB main storage convention
getItemModelLocation
getLength
Safely gets the length of something
getLocationPattern
Returns the pattern or an exact relative path that the file(s) should be stored at.
If a pattern contains a star at the place of the filename, it will search the folder recursively for all files with the extension in the pattern.
Returning relative path has no preceding slash
getMergedConfigOperationPath
NB: returns 3 things:
- false: no operation path
- undefined: operation path undefined
- path: the specific operation path
getParentSlug
get a parent slug without the parent_xxxSlug reference (uses the categoryStackCalculated)
can be undefined if the item has no parent
getRootFolders
Gets all root folders where db folders can be located inside of
NB: Before november '22, this function is quite slow if it needs to find all operation folders becuase this takes at least 60ms.
getWildcardDbFileLocations__OLD
If it all seems good, I can delete this. This is the old method of looking just in the folder itself, it's replaced by looking in all subfolders as well, recursively.
getWildcardDbFileLocations
groupByFile
makeStoringItem
Three things need to happen in order to store an item
- keys that can be inferred from the file path are omitted
- referenced data is omitted
- calculated data is omitted
maxConcurrency
Crashes for upsert at 1024 on m2. It would be good to find a way to ensure we never crash here, or at least report where the out of memory bug came from.
maxQueryTimeSeconds
mergeConfigs
removeKeyValueMarkdown
Takes stored data and a slug to remove
removeMultiple
Function that lets you remove items from one specific file, for any storage method
upsertItems
upsert an item into storage in any storage method
upsertKeyValueMarkdown
Takes stored data and an item
-
updates the data and sets some rows to "item" if the item is found (through the slug). this works almost the same as the regular upsert function
-
otherwise inserts, at the right category, in the right place in the array
BEWARE:
- the categoryStackCalculated must be existing in the markdownfile.
- you cannot insert a header, always insert an item with
isHeaderCalculated:false
waitForLockfile
access
appendFile
canAccessSync
uses fs.access to determine if something can be accessed
Check File access constants for possible values of mode. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g. fs.constants.W_OK | fs.constants.R_OK).
canAccess
uses fs.access to determine if something can be accessed
Check File access constants for possible values of mode. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g. fs.constants.W_OK | fs.constants.R_OK).
canExecuteSync
File is executable to the calling process
canExecute
File is executable to the calling process
canReadSync
File is readable to the calling process
canRead
File is readable to the calling process
canSeeSync
File is visible to the calling process
canSee
File is visible to the calling process
canWriteSync
File is writable to the calling process
canWrite
File is writable to the calling process
chmod
chown
copyAllRelativeFiles
copy a bunch of relative files from one root folder to another
copyFile
cp
findFileNameCaseInsensitive
returns a path of a fileName
fsPromises
fs
NB: for some reason some of the graceful-fs functions aren't complete. For example, I can't seem to copy folders with cp from graceful-fs (cp)
For that one I added cpAsync.
getAllFoldersUntilFolder
NB: I already have this somewhere else but couldn't find it!
If the path is /a/random/path
The result of this function will be:
['/a', '/a/random', '/a/random/path']
getFileName
removes everything before the last slash to get file name
getFirstAvailableFilename
getFolderSizeObject
returns an object with all sizes of all folders and files, recursively
getFolderSize
getFolder
if the path exists:
- if the pathString is a folder, that is returned.
- if the pathstring is not a folder, returns the pathstring without the file suffix
if the path doesn't exist: returns pathString witout last chunk (this would only work for file paths)
getLastFolder
removes everything after the last slash to get folder path
input: /Users/king/Documents/some/folder/xyz output: xyz
input: /Users/king/Documents/some/folder/xyz.txt output: folder
getOneFolderUpPath
Takes a folder path and returns a path that is one folder up
getPathCombinations
gets combinations for paths
input: [["operation1","operation2"], "db/value-export", ["index.ts","test.ts","cli.ts"]] output: ["operation1/db/value-export/index.ts","operation2/db/value-export/index.ts","operation1/db/value-export/test.ts","operation2/db/value-export/test.ts","operation1/db/value-export/cli.ts","operation2/db/value-export/cli.ts"]
gracefulFsConstants
gracefulFsPromises
mkdir
oneUp
Finds the number at the end of a filename and increases it If there is no number yet, concatenates '1' to a string
E.g.
hello-world
becomeshello-world1
hello36
becomeshello37
parseMd
DEPRECATED: just use md-to-json-parse
parse a md file to all the needed info @param mdFilePath path to a md file @returns Md
path
readFileSync
readFile
readdirSync
readdir
realpath
removeAllExcept
Removes everything inside a folder except some files and folders that can, optionally, be ignored for removal. does not remove the folder itself
NB: make this work with subdirectories!
renameAndCreate
rename
rm
stat
watch
writeFileSync
writeFile
writeJsonToFile
write json to a file
makes the dir and file if they don't exist
writeStringToFile
write string to a file
makes the dir and file if they don't exist
writeToFiles
writes all values in an object to the file that should be specified as key of that value
getExtension
returns the extension of the filename or path WITHOUT dot
NB: not sure, but could be nice to replace this with path.extname(pathString)
getFileOrFolderName
getFolderJs
getSubExtension
Provide a filename including its extension, to get the subextension.
isPathRelative
join
removeTrailingSlash
withoutExtension
removes extension from the filename
FunctionForm
FunctionForm is a very easy way to create a frontend component that is connected with an api that is connected with a function on your backend (that can do anything)
All you need to provide is a TsFunction
This component only works if your api is up-to-date and your function is succesfully indexed using typerepo
. For authentication, the api convention is used. See the api docs.
@see TsFunction
getFunctionExecutions
getFunctionQueryPaths
Calculate all required query paths for the function UI menu...
- bundles + main project as root folders (
["main project", ...bundleNames]
) - per folder all operations it contains, nested, in the project relative folder where it should be ending up
- per operation all functions it contains, nested, relative to the src folder. not file, only folders should become menu
Example:
- main
- modules
- packages
- db-ui
- components
<IndexInstanceContainer>
<Layout>
<UpsertForm>
- hooks
useGetDbModelQuery
useReferencableModelDataQuery
- pages
- Page
- Page
- Page
- getPageTitle
- generated
- himalayajeep-functions
- apps
- bundle A
- bundle B
NB: if possible, rename the menu items if the items in a folder are not unique (use file-name to replace item name if this happens)
getPublicBundleConfig
getSrcRelativeFolderPath
getTsFunction
generateNamedIndex
Generates an index.ts file based on named statements in the operation. Also generates test array. Not used currently.
NB: This overwrites the indexfile of the operation in the src folder! Make sure you don't have anything there still.. All functions should be in other filenames.
Should be ran every time an operation changes
generateSimpleIndex
generates operation index and writes it to index.ts in src of the operation.
NB: This overwrites the indexfile of the operation in the src folder! Make sure you don't have anything there still.. All functions should be in other filenames.
Should be ran every time an operation changes
isTestFn
mapToImportStatement
[operationName]
getImportedDependencies
DEPRECATED: should use generated index files with imports instead!
gets all imported packages (dependencies) in a project doesn't take into account the fact that someone can set up a rule for absolute imports within the package. this assumes that any absolute package comes from node_modules.
getPackage
only the first part
isAbsoluteImport
calculatePackageJsonDependencies
Calculates new packageJson dependencies object based on imports found in the whole operation.
For monorepo modules, uses the version inside its packagejson (Uses the database to obtain the package.json)
Generated packages are not added to dependencies. Instead a config is added saying this operation only works within a monorepo since it has generated operation deps that are not on the npm registry
For external modules, uses the version that was already present in dependencies, or uses "*"
Also keeps the dependencies that were already there, nothing is removed.
CONCURRENTLY_INDEXED_FILES_AMOUNT
findAndWriteImportsExports
takes an operation base path and finds all imports and exports in all the files, and writes it to the ts-imports/ts-exports indexes
NB: has a side effect: it also updates the package.json to include all needed dependencies.
getDefaultSymbolType
gets type of a symbol and if the type has a generic, without recursing.
getExportSpecifierNames
getExportSymbolTypeRecursive
gets type of exportSymbols. recurses if it's an exportsymbol
TODO: NB: exports that come from a destructured initialiser aren't found! fix it
getImportSpecifiersWithNames
get the ImportSpecifier(s) of with a certain name.
getImportsExportsTest
getImportsExports
Uses ts-morph to get all exports inside all files in a project or an array of source files. Doesn't use index, it actually looks in all files except index, so some of them may not be exported from the package itself depending on your indexing strategy!
NB: uses a lot of memory!
#performance
getPackageNameFromAbsoluteImport
parses the absolute import name into the actual package name
- removes internal navigation in the package (everything after the package name)
- assumes packages don't have slashes in their names, execpt that it takes into account scoped packages (e.g.
@company/package
) - removes things that come before any column (
:
) e.g.node:fs
becomes fs
getSymbolDeclarationsOfKind
getSymbolTypeDeclarations
getTypeFromImportSpecifierRecursive
Recursive function that gets the type specifier from an import specifier
isAbsoluteImportBuiltin
returns true if the absolute import is built in into node
isImportFromOptionalFile
returns true if the import was found in an optional file, e.g. this import is not always included in the bundle, so should not be a dependency
isImportGenerated
[operationBasePath, manualProjectRoot]
writeResult
getOperationBins
returns array of bins. by convention, these bins should also be exported from operation index file
getOperationPackageName
getPackageJson
getPackageSourcePaths
Returns an array of absolute file paths of (typescript) files in the src of your operation
TODO: we need a way to explore these glob patterns inside of tsConfig.include. until then, just assume we use "src" as the only folder
findFolderWhereMatch
recursive. goes up a folder until it finds a package.json
findOperationBasePathWithClassification
recursive. goes up until it finds a folder that's an operation
because it had to read the package.json anyway, it's returning the operation classification as well
findOperationBasePath
getAllPackageJsonDependencies
getCommonAncestor
Finds the common ancestor for two absolute pahts
getOperationClassificationObject
getOperationClassification
Returns OperationClassification if it's an operation, or undefined if it's not
NB: don't confuse this with ImportClassification
getOperationPathParse
get all operation-related path information that can be inferred from the path
NB: currently it also looks up the operation name from its packagejson
getOperationPath
Gets a path of any operation in the project
TODO: IDEA: maybe auto-generate key-value JSON where keys are the package-names of all operations and values are paths of their locations in the file system. we can easily generate this ourselves, but maybe it's also easy to use the npm yarn workspace for this, although it may not be available in all circumstances, so better not rely on it. The advantage of this would be that this function becomes sync and is much more efficient. The disadvantage is that every time you move something or add something new, this indexation has to happen, otherwise it fails.
getOperationRelativePath
something like src/xxx/xxx/x.ts (no slash at start)
getPathParse
gets all kinds of information that can be inferred from any path (file or folder).
getPathsWithOperations
returns an array of all (absolute) paths containing operations
for a bundled project, that means /apps, /packages, /modules
for the OS project, that means /operations/tools and /operations/niches
getProjectRoot
returns project root folder path
recursive. goes up until it finds a folder that's the project root
if no source path is given, uses the directory name where the function is executed from as a starting point
getRelativeLinkPath
returns a relative link between two files
getRelativePath
gets the relative path from a specified root
will start with "/"
getRootPath
Gets project path, or a folder in the root that is convention
getSrcRelativeFileId
returns a file id (path without extension) relative to the src folder of an operation
e.g. "general" for src/general.ts
NB: assumes all src is in the src folder
NB: removes "/" in the beginning, if found
hasDependency
hasProjectRootFile
isBundle
isOperation
Checks whether or not an absolute path contains an operation. The only check it's doing is that the folder must contain both a package.json as well as a tsconfig.json
isUiOperation
isWorkspaceRoot
simple sync function to check if a folder is the root of a workspace (not operation but a workspace)
makeRelative
Makes a path relative using proper parsing
Resulting path will apply the paths conventions
- no slash at the end
- no slash at the beginning
osRootFoldersConst
can only be accessed in the OS
osRootFolders
packageCompilesTs
projectRootFoldersConst
can be accessed in projects as well as in the OS
projectRootFolders
tsconfigCompilesEsm
getTsConfig
isAltB
⎇ B
isAltN
isAltO
isAltW
isCtrlBacktick
^ `
isCtrlP
^ P
isCtrlS
^ S
isCtrlSpace
^ `
useHotkey
hook that creates an eventlistener for keydown and cleans it up when needed
useHotkeys
hook that creates an eventlistener for keydown and cleans it up when needed
ajvMap
cli
definitions
findAndUpsertTsInterfaces
findCommentTypes
returns all types that are found as start of a line in the comment (capitalised, with a ":" behind)
generateSchema
If existing schema is not stale, just require it. Otherwise, generate it for a file
NB: The createGenerator
function finds also imported TsInterfaces, which leads to duplicate TsInterfaces. With pushing the interfaces to the slug filename, this is no problem though, there should not be any duplication!
getAllComments
gets all leading comments and trailing comments raw text, put together, separated with newlines
getDbStorageMethod
Gets db storage method for indexation
- Frontmatter overrules everything
- Special extensions are looked at
getFrontmatterDbStorageMethod
if isDbModel is specifically set to false, this will return null (which means this should overwrite other things)
getFrontmatterFunctionParameters
getIndexId
getMaxIndentationDepth
gets the maximum indentation depth of any piece of code
does this simply by splitting up the piece of code into lines and checking the indentation of every line, finding the highest one.
assumes an indentation contains 2 spaces.
getMinMaxValidation
getNumberOfLines
getObjectSchema
getParamSchema
getParametersFromInterfaces
getPossibleRefs
getSizeSummary
gets a size summary for a file path
Does not calculate this for files that are too big (bigger than 1MB)
getSpecialExtensionDbStorageMethod
returns undefined if there is not a special extension. if there is, it returns the dbStorageMethod
getTsStatements
Gets functions and variables from a tsmorph sourcefile
getTypeInfo
takes a ts morph type and returns all info about it
if available, a schema should be provided about the type because it's hard to infer it (probably buggy)
getValidatedOperationPathParse
hasTypescriptFileChanged
indexImportsExportsForFilePath
indexTypescriptFilePath
Index a single typescript file
indexTypescriptFile
indexTypescript
Creates a typescript file index in 3 steps
- Introspects the file
- Calculates all needed information about it
- Saves the result to /db/******.json in the operation root
NB: Build errors are done separately as this is done operation-wide, everything else is done for each file
NB: I don't think this is super efficient, because the project is taken to just index a single file. It's probably better to pass the project and the sourcefile in here, right?
TODO: if a typescript file starst with a comment before any statements (but possibly after the #!/usr/bin/env xyz
statement), this should be indexed as the main file comment... This can be shown when opening the file in the admin... It should also check if there is an associated md file for that in src, so that can also be added in the index.
isPrimitive
export const getDefinitions = () => definitions;
export const getClass = (name) => allClasses[name];
makeTsComment
this is actually a fundamental part of the OS. How should comments be structured?
I think, in general, that we should make it look as much as possible at markdown, because it should always be able to have markdown anyway.
removeTypescriptIndex
schemaToTsInterface
make a tsInterface from a schema generated from the file
symbols
toSnack
tryCreateSchema
Try because sometimes generateSchema fails
typeToSchema
calculates the schema of a type
this is great for types inside of parameters of variables that are not declared separately, however, it's probably not as good as vega's json schema generator... therefore, it would be great to always prefer vega's way above this.
NB: this method throws sometimes if it can't find some stuff, so make sure to try/catch it.
TODO: Test and improve this one
apply
sum([1, 2, 3]);
function that takes an array of functions and applies them one by one, on the value or the result of the previous function. Only possible if the type of the value stays the same.
concatenate
createEnum
const taskNames = ["a","b","c"] as const; type TaskNames = typeof taskNames[number]; const enummm = createEnum(taskNames); (value of enummm: { a: "a", b: "b", c: "c" })
createMappedObject
Creates a MappedObject
of an array of any type. MappedObject
s are great for increasing efficiency to get an item from an array. Especially useful when finds are needed on a specific key match for huge arrays. Instead of finding on the array you can simply get the right property from this object.
NB: Don't use this inside of render functions, it's a very slow function, the whole idea is that this makes it faster, so just do it once!
destructureOptionalObject
Easy way to destructure your object even if it may be undefined
or null
.
Have you ever had a function with an optional configuration parameter, but you want to access all its properties? It's a hassle. This function lets you turn doSomething
into doSomethingBetter
. Check the code.
const doSomething = (config?: { a: string; b: boolean; c: number }) => {
const a = config?.a;
const b = config?.b;
const c = config?.c;
return "something" + a + b + c;
};
const doSomethingBetter = (config?: { a: string; b: boolean; c: number }) => {
const { a, b, c } = destructureOptionalObject(config);
return "something" + a + b + c;
};
findLastIndex
finds the last index of an array where a certain filter holds true
getObjectFromParamsString
useful for cli's that only take strings. This creates an object from a string
input: "x:a, y:b, z:c" output: { x: "a", y: "b", z: "c" }
TODO: would be nice if we can validate this string immediately using a JSON SCHEMA
getObjectKeysArray
Handy function to get the keys of an object, but typed.
NB: The only difference from Object.keys is that this returns the keys in a typesafe manner
getParameterAtLocation
utility function to get a parameter inside of a nested object
getSubsetFromObject
takes an object and a subset of its keys and returns a subset of that object
input: { x: "a", y: "b", z: "c" } and ["x"]
output: { x: "a" }
groupByKey
key should be of type string!
input = [{path:"xyz"},{path:"xyz"},{path:"abc"}] groupByKey(input, "path") ouput: { xyz: [{path:"xyz"},{path:"xyz"}], abc: [{path:"abc"}]}
hasAllLetters
all letters of b can be found in a, in order (but other letters in between are allowed)
insertAt
Insert an array or item inside of an array before a certain index
Example:
const testArray = [1, 2, 3, 4, 5];
const result = insertAt(testArray, [99, 100], 2);
console.log({ testArray, result });
isAllTrue
checks if all items in an array are true
makeArray
if something is not an array, returns it as the first element of an array
if the input is undefined, an empty array will be returned.
NB: TODO: find out the workings of the array constructor (Array("any value")
), because maybe it does something very similar. No need to have a dependency then if it's similar.
mapAsync
mapAsync makes it possible to map over an array async without having to do the promise.all afterwards
It saves a lot of lines of code, and makes it more readable Example usage:
const myNumbers = [1, 2, 3, 4, 5];
const doubleAsync = (num) => Promise.resolve(num + num);
const sqrtAsync = (sum) => Promise.resolve(sum * sum);
const halfAsync = (time) => Promise.resolve(time / 2);
const doubleSqrtHalfs = await mapAsync(myNumbers, doubleAsync)
.then((sums) => mapAsync(sums, sqrtAsync))
.then((times) => mapAsync(times, halfAsync));
mapItem
mapKeys
maps over all keys in an object and replaces them using a mapfn
mapMany
Lets you map over any array with a async function while setting a max. concurrency
Taken and improved from https://codeburst.io/async-map-with-limited-parallelism-in-node-js-2b91bd47af70
mapValuesSync
maps over all values in an object and replaces them using a mapfn
sync
mergeNestedObjectTest
mergeNestedObject
type X = IsOptional<string|undefined>;
Merges an object into an object, ensuring typesafety. The second object needs to be a recursive subset of the first.
LIMITATION: When you set a value to undefined, ensure that it is allowed by the original object, we are not checking for this!
TODO: is it possible to remove this type unsafety? It would be nice to only be able to set it to undefined if that is allowed by T. Not sure if it's possible to check the difference bewteen a key not being present and a key being present and the value being undefined... Look it up!
Example:
const testObject: {
a: string;
b: number;
c: { x: string; y: number; z: { a: string; b: number; c: { x: "wow" } } };
} = {
a: "lol",
b: 8,
c: { x: "lol", y: 88, z: { a: "wow", b: 888, c: { x: "wow" } } },
};
const result = mergeNestedObject(testObject, {
c: { z: { c: { x: undefined }, b: 999 } },
});
console.dir({ testObject, result }, { depth: 10 });
result will be: { a: 'lol', b: 8, c: { x: 'lol', y: 88, z: { a: 'wow', b: 999, c: { x: undefined } } }
}
It's great, because you can't make any type mistakes, and your code becomes much shorter for altering an object
mergeObjectParameters
merges two objects: a config object and a defaults object. If the config object has something missing, a default will be used from the defaults object.
In short: merges two objects, for every parameter, use the default as a fallback
DEPRECATED: in favor of mergeObjects
mergeObjectsArray
TODO: find a way to return the correct type interface
mergeObjects
merges multiple objects, overwriting the previous one with the next. Can be useful for configs where there are multiple layers of configs that overwrite each other.
Please note though, that only the root keys of the object are overwriting each other, so if there is nested datastructures, the last one with a specific key overwrites the previous ones copletely
Please note that you can provide partial objects as well, as long as you are sure that the final object is full, the type interface is correct.
Please note that if a latter object has a key which holds "undefined", it will NOT overwrite it. Anything else WILL
noEmptyString
objectMapAsync
Map an object asynchronously and return the same object with the mapped result in its values
Example usage:
const srcFileContentObject = {
"index.ts": indexString,
"public-local.ts": publicLocalTypescriptFileString,
"public.ts": publicTypescriptFileString,
};
const srcFileWriteSuccessObject = await objectMapAsync(srcFileContentObject, async (operationRelativeTypescriptFilePath,content)=>{
try {
await fs.writeFile(
path.join(operationBasePath, "src", operationRelativeTypescriptFilePath),
content,
"utf8"
);
return true;
} catch {
return false;
}
});
objectMapSync
maps over all values in an object and replaces them using a mapfn
Example usage:
const result = objectMapSync({ hello: "world", isTrue: true }, (key,value) => {
return `${value}123`;
});
objectValuesMap
not sure if this is the best way, but it does save some lines of code!
maps over an object's values with a map function
DEPRECATED in favour of objectMapSync and objectMapAsync
omitUndefinedValues
onlyUnique2
function that returns a filter function that can be used as a filter for any array. removes duplicates.
optionally takes a compare function that should return a "true" if two instances are equal. if you use this function, make sure to pass a generic of the type the items will have, in order to make this equality function type safe as well
pickRandomArrayItem
putIndexAtIndex
Takes an item from an index of an array and put it somewhere at another index
removeIndexFromArray
removes an index from an array
example:
const exampleArray = ["a", "b", "c", "d", "e"];
console.log(removeIndexFromArray(exampleArray, 2)); //c should be removed
removeOptionalKeysFromObjectStrings
removeOptionalKeysFromObject
replaceLastOccurence
Replaces the last occerence of something in a string by something else
Example:
const result = replaceLastOccurence("theBestSlugSlugSlug", "Slug", "Slack");
console.log(result); // returns theBestSlugSlugSlack
NB: this is not the most efficient method, as it reverses the string by making it an array, twice. It can probably be done more efficiently by using String.lastIndexOf
reverseString
sumAllKeys
sums all keys of an array of objects, assuming the objects have the same datastructure and assuming the values contain either numbers or undefined
sumObjectParameters
sums all parameters in two objects together
sum
NB: Tried, but doesn't work, probably because it only invalidates cache for one file, not all the files that are required by that file... we need a separate process
const requireWithoutCache = (filePath: string) => {
delete require.cache[path.resolve(filePath)];
return require(filePath);
};
example function that can be tested
takeFirst
takes any type T or an array of T and returns T or the first of the array (which is T)
trimSlashes
Trims a slash on both sides in any path
getSimpleJsonString
stringifies simple json things if the json is one of them, otherwise returns undefined
arg1
arg2
benchmark
determineFileType
returns the file type or null if it's unknown
exploreGitRepoFolders
find all active git folders (folders having git)
exploreMultiple
DEPRECATED: not sure if we still need it, look up usecases, can prob be replaced now
exploreOperationFolders
find all active operations (folders having package.json
but also tsconfig.json
)
returns folder path array
explorePreset
explore
This is the safe and friendly version of findFilesRecursively
findAllDocsFolderPaths
Returns absolute paths for all docs folders (not the files inside)
findAllDotGitFolders
findAllFoldersWithName
findAllPackages
findAllTodoFolderPaths
findFilesRecursively
Explores your files with many possibilities.
NB: this function only searches one basePath, while explore can do multiple
TODO: since this not only finds files but also explores them, naming should be exploreFilesRecursively, probably.
TODO: TextJson[] is a bit weird name for the resulting type interface...
getArgument
getContents
gets needed contents of file path, based on the extension
returns a markdownparse if it's markdown, a json parse for json, or a file content string for anything else
getOutline
low-level function that gets the outline for MarkdownParse
NB: with books usually the pages are referred in the outline. Since that depends on the font size and dimensions, this cannot be done straight from the markdown parse. Eventually we probably need to check the made pdf for its content, maybe there is even a pdf feature that creates an outline for you. There must be more people having this problem.
isMatch
isSearchContentExtension
type checker for a string to be an extension that can be searched for
pathArrayIsOperation
Checks if pathArray contains a package.json and a tsconfig.json and thus should be an operation
Handy for cancelRecursionOn
in explore
[operationName, manualProjectRoot]
runTestsForOperation
runTestsForOperation(operationName) runs all tests that can be found in an operation. nicely logs and returns which funtions are working or not and why
this assumes the index file exports all tests under the test
constant, which should be done using this framework
this also assumes your tests are exported from build/index.js (which means you need to build your code, not transpile, so it's not possible for every type of operation)
runTests
run tests and log the results.
input: Test
output: isAllValid (boolean)
exampleKeyValueMarkdownParse
exampleKvMdString
exampleLine
flattenMarkdownChunks
Flatten markdown content into an array of paragraphs
getKvmdItemsRecursively
recursively dives into the Chunk to get all kvmd items
NB: this doesn't have a reference to its parent yet, but this will be added in fs-orm on the fly because the key for that is based on the model name
getParagraphsRecursively
recursively dives into the Chunk to get all paragraphs inside
kvmdDataMap
DEPRECATED: probably never needed, unless I make it useful
mapper function to give a kvmd data object other parameters.
NB: not sure if this is useful. it would be useful if we could auto-generate the application of this function for multiple db models.
kvmdDataToString
parses KeyValueMarkdownModelType into a string which can be part of a new markdown file
NB: we need to know the previous line as well because the header we need to print depends on it
kvmdParseToMarkdownString
parses KeyValueMarkdownParse into a markdown string so it can be saved as a markdown file
markdownStringToKvmdParse
parses a key value md string (with support for headings and frontmatter)
parseKvmdLine
parses a kv md line with data into a key, value, and comment (if available)
if the key is an empty string, the line will return undefined
LabeledButton
AuthenticationLayout
Layout that includes default pages and header for authentication
Header
LayoutGrid
Style for creating a grid for the layout that is mobile friendly and has menu support
I run into this problem all the time
https://stackoverflow.com/questions/71616561/css-tailwind-grid-height-100vh-not-working
final solution came from here
Unfortunately, I can't seem to hide stuff anymore for some reason on non-mobile. "lg:flex hidden" just doesn't work, just hides!
My elegant solution was to just use visible/invisible and make the mobile layout hover over the invisible one in case of a small screen, it works!
PingApi
timeBeforeNotOffline
preIndexLint
Should be a collection of small functions that check if all conventions are used and if there isn't used anything that should NOT be used. this can later become a linter. make sure to research how eslint works first
Plan:
- just use my own sdk's as much as possible to provide some handy convention checks in a package
- later integrate this into vscode, i'm sure this is how it's done
this lint can be done before indexation
DEBUG
if true, also shows debug messages
getCallerFileName
TODO: this is great. now also get the operationName. If the operationName appears in the config, for debug, show the log, otherwise don't show
options
special character combinations that make the console message be printed differently
parseTitle
TODO: Should parse a title from markdown
resetString
sendMail
Sends email(s) using sendgrid
Ensure your OS config is there
isResultOfInterface
TODO: need validate-json-schema. also this can be its own little package, as it can be used in many other places
not sure if this should be part of make-test at all, because we want operations to be able to operate independently without the os, right? so then it won't work because you don't always have indexes...
makeTest
create a test that is testable with runAllTests
...
defaultExpandedMode
defaultMinimalMode
getRealSrc
Based on markdown info, gest the real source for an asset
getUrlFromRelativeUrl
gets the renderable asset url from the relative url
getYoutubeId
HtmlHeader
MarkdownCodeblock
Parameter
In markdown, if you wish to refer to a parameter, you can backtick it and put a "." in front. You can also add a value to it if you wish, by adding the ":" and the value afterwards.
renderFrontmatter
Renders markdown frontmatter parameters (and optionally a spacer)
renderMarkdownChunk
renders a MarkdownChunk interface
renderMarkdownContent
Renders a markdown string (without frontmatter)
TODO:
- Show selection prompt-results In renderMarkdownContent, augment the alineas with the ContextualPromptResult. Would be great to see the results when hovering over the selected thing, or maybe showing it with a button, or inline, even.
renderMarkdownParse
renders the MardkownParse interface (including frontmatter)
renderMarkdownTitle
renders a markdown title (level should be 1 for h1 and 6 for h6)
useOpenHashDetails
chunkToStringRecursively
exampleMarkdownFileContents
getChunkParagraphsRecursively
Get all paragraphs (content
values) recursively from a MarkdownChunk
getImplicitId
Implicit ids are a convention in markdown. A title gets an implicit id by removing spaces and making the title lowercase.
See https://stackoverflow.com/questions/6695439/how-to-link-to-a-named-anchor-in-multimarkdown
getMarkdownIntro
This function takes a markdown parse and gets the first paragraph and a title from it, if available.
Currently assumes that the first paragraph starts directly after the title or there is no title and the content is at the beginning.
TODO: It would be better to find the first paragraph based on the level.
getMarkdownParseParagraphs
Gets all paragraphs (recursively) from a MarkdownParse
getMarkdownReferencePaths
getMarkdownReferencesFromParagraph
Gets all markdown references from a paragraph
markdownParseToMarkdownStringFromContent
markdownParseToMarkdownString
NB: this just uses RAW!
Use markdownParseToMarkdownStringFromContent
for the real deal
mdContentParseRecursively
recursively parses a string containing markdown (without frontmatter) into a MarkdownChunk[]
Improve:
- include the comment-type (TODO/NB/etc), both on a chunk level and on root level
- parse paragraphs further around the assets
mdToJsonParse
makes a markdown parse from a markdown string
TODO: markdownStringToMarkdownParse
is a better name. First make a refactor script for this, because it is too hard to rename stuff that is used a lot.
TODO: BUG: it doesn't take into account triple backticks! if there is markdown inside of the triple backticks, it can still be seen as main markdown. Triple backticks are stronger!
parseFrontmatterMarkdownString
splits a markdown string into its frontmatter object and the raw content (without frontmatter)
parseMarkdownParagraph
Parse markdown paragraph
Should split it up for every thing it encounters...
parseMdToChunks
should get chunks recursively. first just look for every h1 line. everything after the h1 line is the children until there's another h1 line, then do this recursivley for h2, h3, etc.
removeHeaderPrefix
removes header prefix (##### etc) and trims whats behind that
addDependantCount
Double arrow function to get the count for the item
bundleFolderWithMarkdown
Finds all md files in a folder and creates a single MarkdownParse
handy for creating a single documentation file or other things that have to include multiple markdown files in a structured way
NB: it recursively structures the files and folders with headings
bundleToBookMarkdown
Input: BundleConfig (one or more folder(s), readme, operations with a docs folder)
Output should be all md files concatenated in the right order with the right titles
bundleToMarkdown
creates a summary for a whole bundle
NB: Related to bundleToBookMd
concatMarkdownFiles
createMinimizedSectionMarkdown
createMinimizedSection
deployToVercel
NB: Obviously, this is not the right place for this function, but none of these functions are properly located yet...
should deploy any bundle or next project folder project to Vercel by first creating and pushing it into git, and then creating it in vercel through their api
should return an url where the project will be served and the estimated time when it will be live
emailMarkdownParse
should email a markdown parse to some email (or multiple)
flattenNestedObject
Flattens a nested object by returning an object that hasa the nested path as the key and the leaf as the value
TODO: Finish, if needed. seems hard!
generateStaticSite
generates static site from a markdown file, with a menu on the right by default
uses next.js
because it is static, the markdown can be in the frontend assets and there is no need for a backend
getJsonSchemaSummary
Generates short markdown summary
getMarkdownContents
getMergedMarkdownOutlineUrl
getOperationSummary
Summarises operation into useful information about it. Especially useful for generating docs.
getPublicMarkdownNestedPathObject
Recursively searches a folder for public markdown files, and returns a NestedObject
with the keys being the file or folder names, and the leafs being the absolute file paths.
File and folder names are stripped (number prefixes are removed, )
example:
{
"README": "path/path/README.md"
"folder1":{
"README": "path/path/folder1/REAMDE.md"
"file1": "path/path/folder1/file1.md",
}
}
getTitlesRecursively
helper function to get a nested array of the titles and its subtitles
getTypeDescriptorRecursive
Returns a single line descriptor of the type of a json schema. Can be used in markdown tables.
isConventionFileStatement
isUpperCase
makeOutlineMarkdownString
makePropertiesTable
markdownChunkToMarkdownStringRecursive
markdownChunksToMarkdownStringRecursive
markdownToSayable
all mp3s should be stored in a separate location because we don't need them in the file system and we don't reference them, as they are data that is located by convention. all markdowns should have a linked TextToSpeechAudio[]
which is auto updated every time dev
is ran. TextToSpeechAudio
also includes infromation about the duration
, voice
and more...
a bigger md.mp3 file is auto-created for every markdown file that concatenates all sayable
audio pieces in the right order, but also includes the audio pieces in between.
mdToPdf
Have function mdToPdf like the vscode plugin. Probably exists.
However, may be good to do it myself since I want different renderings
mergeMarkdownParse
Merges multiple markdown parses to create a new markdown parse
noNewlines
Replaces newlines with a
operationRadio
randomly plays mp3 summaries of operations on the project
operationToMarkdown
converts an operation and all its contents into a flat markdown file that contains the needed information. configurable.
markdown for reading (so there are no links)
printNestedTitles
helper function (recursive) that prints nested titles with .. as prefix and a newline after every title
TODO: allow for numbering titles
should print any file using a preconfigured printer (which can be local or remote. if remote and there is no connection, it should save the task for later)
this function maybe needs "generateStaticSite"
projectToMarkdown
summarizes the whole OS project into a markdown string
propertyToTableRow
sayablesToMp3
Creates a single audiofile of a Sayable[] and stores that in a configured location
selectRandomOperation
selects a random operation
simplifiedSchemaToMarkdownString
Should render a string with one or more markdown tables to represent the simplifiedSchema
statementItemToMarkdown
tsFunctionToMarkdownString
TsFunction:
- name and operation
- size
- description (doc-comment)
- input, output
tsInterfaceToMarkdownString
properties, their type, and their description
use simplifiedJsonSchema, but split up nested things into multiple tables (ive written a thing for splitting up nested objects before, use that)
tsVariableToMarkdownString
upMarkdownChunkLevelRecursively
Ups the levels of the markdownChunk array, recursively.
Can be useful for merging multiple markdown sources
availableExtensions
copyStaticAssetsCli
copyStaticAssets
uses getMarkdownReferencePaths
for all markdown files in the markdown-reader-ui
and copies them into the markdown-reader-web/public
folder, keeping the original folder structure.
NB: Removes all files in the public folder first.
To get a file from public assets after running this function, you need to get it from the projectRelativeFilePath
, not the file relative, so you need to render it differently.
docsGetPages
docsGetStaticPaths
Function that tells Next.js what the pages are that need to be statically generated
docsGetStaticProps
getAllMarkdownReaderPages
....? I should've commented this
const hasDocs = !!relativeDocsPages.find(
(x) => x.queryPath.toLowerCase() === "docs/readme"
);
if (!hasDocs) {
const hasRootReadme = fs.existsSync(path.join(projectRoot, "README.md"));
if (hasRootReadme) {
relativeDocsPages.unshift({
queryPath: "docs/readme",
filePath: "README.md",
isMenuItem: true,
});
}
}
Gets all pages of a bundle based on the fs and database
Pages it finds:
- operation-readmes
- multiple docs basePaths with all folders and markdown pages there in (
/[project-relative-path]
) /dictionary
- all markdown model types we have in the db-sdk, optionally, depending on config
Requirements:
- README should always be on top in a folder.
- numbers and extensions are omitted from paths, but still connected to the right file
- If the docs doesn't have a readme, the /docs/readme path shows the root readme.
Does not include AugmentedWord. Just the main pages, not with queries and hashes
Used to generate the menu
getChildren
getFolderExplorationInfo
Gets exploration information about a folder
- reads README.md in current folder
- reads OPERATION.md in child folders, or README.md if that doesn't exist
- gets an intro from those markdown files and returns that (uses getMarkdownIntro)
getMarkdownModelPages
Transforms all your markdown models into markdown reader pages
Steps:
- Finds all markdown model types from the database config
- Gets their basepaths according to fs-orm convention
- Checks if they actually exist
- Finds all markdown therein
- Makess markdown reader pages out of them
getMarkdownPageInfo
If a markdown page is found, this function fetches all metadata needed to render that markdown page
getMarkdownReaderPages
Gets all markdownreader pages for multiple basePaths. Can add a prefix, can also remove the last folder of basePath from the suffix.
getMarkdownReaderQueryPaths
getOperationPages
getPublicMarkdownFilePaths
Returns all absolute markdown file paths within a basePath which are not drafts and which are not marked private (through frontmatter)
Readme is put on top!
getReaderTodoPages
gets all todo pages as markdownreader pages
markdownReaderGetStaticPaths
Function that tells Next.js what the pages are that need to be statically generated
markdownReaderGetStaticPropsFromPages
Takes the routes and pages you want to show, and returns the MarkdownReaderPageProps you need to render the reader page.
markdownReaderGetStaticProps
putReadmeOnTop
removeExtensionsFromPath
- Removes numbers from file or foldernames in a path.
- Removes extension of files
- Returns the new path without numbers and without extension
Works for files and folders
removeNumberPrefix
removes number prefixes from a file or folder name. Does not remove extension
defaults to untitled if the file or folder has no name after removing numbers.
shouldExposeMarkdownFile
markdown file should only be exposed if it doesn't say privacy: private
or isDraft: true
in your frontmatter.
stripReadmeFromFolder
To get the queryPath, we need to strip the README.md so we get the folder as URL instead of the attached README.md
getQueryPath
markdownParseToMarkdownModelType
makes a markdownModelType from a markdownParse.
parseMarkdownModelTimestamp
First tries to look at the frontmatter value, this is leading because it is what the user sees and the file system of the os could be inconsistent
If this frontmatter doesn't exist, the markdownParse is checked for a date. This should be information collected from the file system
If that doesn't succeed, sometimes we'll set it to the current timestamp
tryParseDate
Tries to parse a date from a string
- implements default behavior of
new Date
with a try catch - returns a unix timestamp (ms since 1970 AD)
TODO: put in a better location... date-util?
findCodespans
find all codespans
findEmbedsTest
findEmbeds
find all embedded assets
findLinks
find all links
flattenMarkdownString
find all items that match a token, recursively in all nested things
flattenMarkedTokenRecursive
Recursively flatten a marked token and return something if a find function is met
cleanupTimer
Ensure you run this after finishing the measurement, or you'll run into memory leaks!
generateUniqueId
Bit annoying that we need to use all model-types here xD.
TODO: Let's extrahere this
getNewPerformance
Function that lets you measure performance inside any function with ease.
Usage:
Firstly, make a performance array, and a unique execution id, and start the measurement, like so:
import { generateUniqueId, getNewPerformance, PerformanceItem, cleanupTimer } from "measure-performance";
at the start of your function
const executionId = generateUniqueId();
const performance: (PerformanceItem | undefined)[] = [];
getNewPerformance("start", executionId, true)
After that, push a new performance item at every step you want to measure. Provide your label describing what happened before this (the step you are measuring).
performance.push(getNewPerformance("your label", executionId));
At the end of your function, you can view your performance array by printing it on the console (or store it somewhere if you like)
Don't forget to run cleanupTimer, or you'll run into memory leaks!
cleanupTimer(executionId);
timer
TODO: This stores into memory. May cause memory leaks in the long run if not cleaned up!
getLegacyMenu
Menu
"wise"
component that lets you render a menu easily, including search
TODO:
- provide menu with NestedWebPage
[]
minifyBuild
takes an operation name or build folder path, then explores all ts files in src folder, finds the matching js file in the build folder, and executes terser from dependency, not from cli
generateId
24 characters of the alphabet provides 9E33 combinations, wont be possible to brute-force in centuries, even if there are billions of entries
generateRandomString
generateTime
languages
keys are the iso codes which will be saved in the db, the values are values which can be shown to the user in any UI
markdownModelTypeToMarkdownString
assetsFolders
generatedParameterNames
getAssetInputType
Convention parameters for assets: [name], [name]s, xyz[Name], xyz[Name]s
Different ways to name assets: image
, video
, audio
, file
or just asset
, which is everything together
getParameterContentType
isCalculatedParameter
this is part of the database convention
isGeneratedParameterName
markdownTextParameterNames
Any parameter names that should render a textArea
parameterNames
How do we show different UI's based on certain things we know about some parameter (name + type)? There are many things
- All "image" or "xxxImage" should be Image + camera inputs
- All "asset" or "xxxAsset" should be File inputs
- All "recording" or "xxxAudio" should be mic inputs
- All "position" or "xxxPosition" should be coordinates which should be pickable on the map
- All "path" or "xxxPath" should be an input where you can select a relative path from project root or operation src root, depending on what we need. It needs to be clear what kind of paths are allowed, so we need to think about all the options and if we can all put that in the parameter name (would be best) or if we need to use the description...
passwordTextParameterNames
patternMatchers
referenceParameterNames
referencePluralParameterNames
getRealItemRecursive
getTitle
NestedMenuItem
TODO:
- tooltip support
nestedMenuStoreInitialValues
NestedMenu
General purpose nested menu component
Please make sure that you also wrap your app with MenuStoreProvider
, or this will crash...!
useExpanded
ALink
A simple wrapper around react-with-native A and next-link
All links you make with this component are SEO-ready
oneByOne
for every item in an array, executes an async callback, one by one. promises an array of the results of every callback once it's done
getDependenciesSummary
getOperationMetaData
gets a whole bunch of metadata about an operation, mainly filepath related, but it also reads the operation index json file
recalculateOperationIndexJson
Recalculates some operation indexable things and updates that into the database
parsePrimitiveArray
parsePrimitiveBoolean
parsePrimitiveString
parsePrimitive
parses a string into the value it should be
if you provide a simplifiedSchema
, that will be used to parse according to the shape of the schema
calculatePathMetaData
for folders: finds all files used for calculation and uses sumPathMetaData to create a new PathMetaData. for files: just calculates the path metadata
categorizeFiles
explores files in an operation within a specified location or from a specified type
getFolderSummary
calculates folder summary from a categorized file paths object
getPathMainComment
export const sumFolderSummary = ( firstFolderSummary: FolderSummary, secondFolderSummary: FolderSummary ): FolderSummary => { const folderSummaryKeys = Object.keys( firstFolderSummary ) as (keyof FolderSummary)[]; const sum = mergeObjectsArray( folderSummaryKeys.map((keyName) => { return { [keyName]: sumAllKeys([ firstFolderSummary[keyName], secondFolderSummary[keyName], ],["bytes","characters","lines","numberOfFiles"]), }; }) ) as FolderSummary;
return sum; };
takes all PathMetaData of an array that contains all child files, and merges them, taking the newest update date, the earliest created-date, and summing size
export const sumFileGeneralMetaData = async ( childrenMetaDataArray: PathGeneralMetaData[] ): Promise<PathGeneralMetaData | null> => { const sum = childrenMetaDataArray.reduce( (sumMetaData, pathMetaData: PathGeneralMetaData) => { const newPathMetaData: PathGeneralMetaData = { createdAt: !sumMetaData || pathMetaData.createdAt < sumMetaData.createdAt ? pathMetaData.createdAt : sumMetaData.createdAt, updatedAt: !sumMetaData || pathMetaData.updatedAt > sumMetaData.updatedAt ? pathMetaData.updatedAt : sumMetaData.updatedAt, sizes: !sumMetaData ? pathMetaData.sizes : sumFolderSummary(sumMetaData.sizes, pathMetaData.sizes), };
return newPathMetaData; }, null as PathGeneralMetaData | null );
return sum; };
sumSizeSummary
achievements
developers
englishMethod
levelNames
publicPersonKeys
Can be seen for every person, without authentication
NB: I wish it were possible to ensure these keys exist on the person here, but we can't validate that while still keeping it a const I guess
getPrimaryPersona
isPlural
isSingular
singularize
Removes the 's' if it is found at the end of the parameter name
ports
See https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers for available ports
Range 42000-42080 seems to have no ports. There are many more ranges
When creating a new app, ensure you not only define the port here, but also in
InputSize
Inheritance of different button themes
InputTheme
Inheritance of different button themes
readCsvFileSync
Reads and parses CSV file
specify a generic of what type of item the file contains an array of
readCsvFile
Reads and parses CSV file
specify a generic of what type of item the file contains an array of
readJsonFileSync
Reads and parses JSON file
make sure to specify what type the file contains as a generic!
readJsonFile
Reads and parses JSON file
make sure to specify what type the file contains as a generic!
readProjectRelativeJsonFile
readKvmdFile
Reads and parses a markdown file
readMarkdownFileToModel
Reads a markdown absolute path to a WebMarkdownFile model
Attaches default calls to action and header
readMarkdownFile
Reads and parses a markdown file
getFolderTypescriptIndex
get a Typescript index for all that is found in a folder
getOperationIndexModel
readTypescriptFile
Reads and parses a markdown file
uniqueNames
AugmentedWordComponent
Dictionary
DocsReaderLayout
Layout
ReaderPageContent
This is rendering a WebMarkdownFile and optionally navigation.
ReaderPageHeader
{ useStore, StoreProvider }
clearTsDatabase
Clears all typescript indexation models, and removes all indexation from the oprations
TODO: test first, not sure about the Operation one
cwdProjectRoot
executeCommandQuietUnlessFail
Executes a command without showing the result, unless the command fails, then it will log the output.,
exitIfProcessDependenciesChanged
exits the process if our own dependencies change
generateJsonSchemas
generates schemas for db models
Is done every time you run rebuildOperation and generateSdkOperations
TODO: there are some problems with references that cannot be found with references to generic types... This can probably be solved, but it's not going to be easy!
IDEA:
- find all referencing definitions in the main schema
- find those in all other interfaces
- recursively find references in those as well
- if you can't find the reference, remove the reference and replace type to "any" (add WARNING to description "reference not found")
This will result in a valid schema that has no unresolved references
TODO: apply Storage
TODO: apply Array
TODO: apply special config conventions (MergedDbConfig) like tsconfig.json and package.json
TODO: Make a validator that validates the whole database to this schema.
getAllDbModels
getFileIds
gets all identifiers of files, which are the relative path to a file without the extension
getIndexFileIds
gets identifiers of ts and tsx files, which are the relative path to a file without the extension
getSrcIds
gets identifiers of ts and tsx files, which are the relative path to a file without the extension
in order for them to be unique, we assume here that there's never a file with the ts extension when there's also a tsx file in the same folder with the same name. This would create duplicate ids.
isOperationBuildNeeded
returns a boolean indicating whether or not the operation should be able to be built, based on the OperationClassification
isRebuildingProcessUpdated
isSdkOperation
[isUpdatedString]
manualProjectRoot
rebuildAllOperations
Rebuilds all operations that are needed to be rebuilt
rebuildOperationCli
rebuildOperation CLI syntax:
rebuildOperation [...operations]
Operations can be a list of differnt operation names you want to rebuild. It's also possible to specify a relative path instead of an operation name.
for example:
rebuildOperation ./packages/operation-x
would rebuild operation-x
in your packages folder
another handy one is rebuildOperation .
because it will rebuild the operation in your current folder.
rebuildOperation
This function rebuilds an operation and re-indexes (part of) its files.
shouldSkip
if you don't force it, there's an operation index, there's an index folder, the src has not been touched since hte last indexation, and there's a buildfolder (if needed), then the rebuildOperation can be skipped
thisProjectRoot
yarnBuild
Builds and minifies the src
getKeysAtPathFromNestedObject
Gets all children keys of a nested object at a certain (nested) location in the nested object
nestedObject
should extend the NestedObject
.
The reduce is a bit vague, I need to test this function further to make sure it does exactly what I want.
getMenuPagesObject
makeNestedObjectFromQueryPathObject
nestedObjectToChildObject
if T is an object, provide __check as one of its properties, to make it possible to check that it's a leaf. This property will be omitted in the ChildObject array
nestedPathObjectToNestedMenuRecursive
Transform a nested path object into a nested menu (MenuType), recursively
nestifyQueryPathObjectRecursive
queryPathsArrayToNestedPathObject
Handy function to transform an array of querypaths
into a nested menu, assuming you want to create a new sub-menu for every path
May also work for relative filePaths
Input:
["hello/world","hello/moon","hello/sun"]
Output:
{ "hello":{ "moon":null, "world":null, "sun":null } }
reduceQueryPathsRecursively
bodyFromQueryString
converts a query string into an object that can be used as a body
getFirstQueryStrings
Query keys can be string or string[] or undefined.
This function takes only the first string if it's an array...
getQueryPart
creates a query-string with one key for all strings in an array
isValidEntry
toQueryString
returns something like ?x=a&y=b&z=c
[argument]
runChildProcess
spawns a child process and returns its output after it's done
sayDutch
sayLanguage
sayNepali
saySomething
TODO: do research what else is out there
say [-v voice] [-r rate] [-o outfile [aud io format options] | -n name:port | -a device] [-f f ile | string ...]
DESCRIPTION This tool uses the Speech Synthesis manager to convert input text to audible speech and either play it through the sound output device chosen in System Preferences or save it to an AIFF file.
for usage, see man say
shorthands
textToMp3
findFirstCommentTypes
Tries to find tie first appearing special comment line and parses it and returns it as part of the CommentTypeObject
getDataParameterNames
Finds all the data parameter names that might be there on an item, based on the item object keys and the convention
getPossibleReferenceParameterNames
returns the reference parameterNames...
e.g.:
todos -> todoSlugs + todoIds
todo -> todoSlug + todoId
getProperties
Gets all the properties of a schema
getRefLink
gets the $ref from a schema and parses the interface name from it
getReferencableModels
based on the object properties in SimplifiedSchema, returns the model names that can be referenced
getReferenceParameterInfo
Takes a parameterName and returns information about it according to the convention {descriptorName}_{modelName}{referenceKey}
where:
- descriptorName with the suffixing underscore is optional
- referenceKey can be slug, index, or id (or there plural variants)
- modelName should refer to a database model
getSchemaItems
==========
Since JSONSchema7
's property items
is fairly hard to use, this function gets that property in an easier to use way.
getSchema
parses a JSONSchema7Definition to JSONSchema7|undefined so we can use it
simplifiedSchemaToTypeDefinitionString
Converts a simplifiedSchema definition back into a type interface string
With this, types can be generated in different ways
simplifySchema
Return a SimplifiedSchema by giving the JSONSchema7 schema, its name and a list of possible references in the JSONSchema.
A SimplifiedSchema is a data structure that allows you to easily define type interfaces that need to build out forms.
Dual types aren't done right yet. I probably don't look at anyOf
yet, which makes it result in an empty object.
For example, this one is problematic:
INPUT:
{
"schema": {
"anyOf": [
{"type": "string"},
{"type": "array","items": {"type": "string"}}
]
},
Output:
{
"simplifiedSchema": {
"properties": [],
"type": "object"
},
}
To test this one, test npx rebuildOperation filename-conventions
apiUrl
hostname
isDev
localhostServer
runRemoteServer
addAuthenticationMethod
sends an email or sms, or already confirms in case of emailPassword
core function for addPersonAuthenticationMethod
and addDeviceAuthenticatedMethod
addDeviceAuthenticationMethodConfirm
adds an authenticatedMethod
to Device after the OTP is correct
For now, only handles methods phoneNumber
and email
TODO: extrahere the core into addAuthenticationMethodConfirm
and use it in this one and make also addPersonAuthenticationMethodConfirm
addDeviceAuthenticationMethodWithContext
returns new function context with added authenticationmethod
addPersonAuthenticationMethodWithContext
findAuthenticatedPersonWithHandle
Check if the handle is already taken by some person in the system
findLoggedinPersonsWithContext
This finds all persons you should be logged in as according to all your device's Authentication Methods.
Does not update your device to add the found persons.
getMeWithContext
Get all relevant information about yourself, including all persons that are attached to you.
NB: probably need to omit some fields later, but for now it's fine
getPublicPerson
getPublicPersons
isPhoneNumber
TODO: Implement this
isValidPassword
loginWithContext
loginWithPasswordWithContext
Login with username and password
- Adds an username/password combo as auth-method to the device,
- Checks the persons to match the auth
- In case of match, moves the method to the person and connects the device
logoutWithContext
Uses cookies (https://serverjs.io/documentation/reply/#cookie-) to logout
Needed for having authToken
with GET as well in a safe manner (e.g. for images)
removeDeviceAuthenticationMethodWithContext
removes an authenticatedMethod
from Device
Usually the authentication methods are an attempt to login into a new account, so if you remove something it doesnt have impact on the accounts you already logged into, because these authentications are not stored on the device but on the person.
We can therefore remove it without much validation
removePersonAuthenticationMethodWithContext
removes an authenticationMethod
from Person from currentPerson from authenticated device
signupWithContext
signupWithPasswordWithContext
For now only username/pass is supported due to direct verification
This function makes an authenticationmethod for the device and then signs up by creating a person for it and attaching it to the device.
switchCurrentPersonWithContext
updateMeWithContext
setJsonKey
npx setjsonkey [json-path] key1.key2.[index/latest/push].key3 "value"
collect arguments 1 2 and 3 find file (arg1) in path, import json (or start with empty object in a new file) reduce keys (arg2) to go deeper into the object and create keys as they don't exist make sure it works with arrays too convert value string (arg3) to number, boolean if they seem to be like that
Share
and
useAllText
useLastSelection
findAudioWithViewsArray
markdownParseToShortMarkdown
shortMarkdownToMarkdownParse
augmentShortMarkdown
fetchVoicesTest
fetchVoices
generateAugmentedShortMarkdownTest
generateAugmentedShortMarkdown
The first step is to ensure that this would actually work. It needs to generate the MP3s and refer to them correctly in the file.
getOrGenerateShortMarkdown
MINIMUM_DURATION_MS
parseDialogue
uberduckApiKey
uberduckGetPath
uberduckSecret
uberduckSpeak
voiceCloneDialogue
ShortMarkdownPlayer
ShortMarkdownSlide
Duration is required, and either title or viewPath must be there
ShortStudio
the newer one, eventually to replace ContextTextArea
useMultiAudio
- Implement a component that preloads all audios for the
ShortMarkdown
and lets you play one with a callback (look at https://stackoverflow.com/questions/47686345/playing-sound-in-react-js) - If slide has audio belonging to it, find it and play it. Start at certain point, depending on which part you are at.
- Select the correct audio for every slide, and get the API url for it. Load it in into an
<audio>
element once you go to the slide.
ArrayForm
Component to render a parameter that holds an array
This is simply a wrapper around another SimplifiedSchemaForm where the onChange
and values
are slightly different
This component renders a SimplifiedSchemaForm for every item in the array, and adds buttons to insert/remove new items.
FormContainer
A FormContainer is a simple container that can wrap your SimplifiedSchemaForm to give it a button that also sends when hitting enter on your keyboard. To achieve this, a <form>
is created in this component.
Besides this, you can also add some texts, but styling is not possible to change for this component at this point (except for the form className). If you want a completely different style, it's probably better to build it yourself.
NB: TODO: There is a bug now where onSubmit gets called too often. Not sure how to fix this. Because of this, I'll simply remove the onSubmit action in the onsubmit for now, and prevent the default.
getReferencedModelDataItem
ObjectForm
Component to render a parameter that holds an object
This is simply a wrapper around another SimplifiedSchemaForm where the onChange and values are slightly different
ReferenceInput
This component renders an input to select an item to reference from another model (or multiple)
renderParameterTitle
SimplifiedSchemaForm
Recursive component that renders a form for a SimplifiedSchema
useReferencableModelData
Hook to retreive ReferencableModelData
to supply to SimplifiedSchemaForm.
Underwater, this calculates all referencableModelNames for a schema, and then it fetches the ReferencableItem
[] for every one of those models, using react-query
useQuery
hooks
NB: be careful, not to change the simplifiedSchema after using this hook for the first time. This will change the amount of hooks and this can break react!
(it will give Error: Rendered more hooks than during the previous render
)
useTsInterfaceForm
hook to create a form for a TsInterface
import { useTsInterfaceForm } from "simplified-schema-form";
import DatasetConfigJson from "code-types/db/ts-interfaces/datasetconfig.json";
import { DatasetConfig, TsInterface } from "code-types";
import { Storing } from "model-types";
in your component:
const initialValue:DatasetConfig = {} as any;
const [Form, value, onChange] = useTsInterfaceForm(DatasetConfigJson as Storing<TsInterface>,initialValue);
sendSms
Send sms
Requires OS Config to have Twilio sid and auth token.
Reqruired options: to
and body
to
is not required, but will overwrite the one you specified in your OsConfig
objectStringToJson
takes an object string and parses it to JSON
Instead of requiring objects to be in JSON format, they can be in the following format:
key1: value, key2: another value, key3: 9, key4: false, key5: null, key6: { subkey: true, subkey2: 0 }
NB: you can have objects in parameters of objects by surrounding the same syntax with {
and }
parseIfJson
if it's a string with a parsable JSON inside, parse it and return the object/array
parsePrimitiveJson
parses a string to a string, number, boolean, null or undefined.
optionally you can chooose to force a type...
TODO: figure out how I can do this without ts-ignores
stringToJson
takes any string, and parses it to JSON
if you provide (nested) objects, make sure to use the following format:
key1: value, key2: another value, key3: 9, key4: false, key5: null, key6: { subkey: true, subkey2: 0 }
binaryExtensions
List of binary file extensions
textExtensions
List of text file extensions
todoPagesConfigRecencysConst
todoPagesConfigRecencys
Tooltip
removeCommentsRegex
tryParseJson
if text isn't json, returns null
getAllTsMorphSourceFiles
getHasGeneric
returns a boolean indicating whether an interface or type has one or more generic arguments
getTsMorphProject
returns a ts-morph Project given a operationFolderPath, if a tsconfig.json can be found
createCodeblockMarkdown
small util function to create a markdown for a string.
crudPageToWebPages
functionFormPageToWebPage
writeToAssets
Writes anything (string or json) the assets folder of the operation of the caller function of this function
Useful for testing
getFileContents
Gets the contents of a file in the project
getFrontmatterSchema
Gets the frontmatterSchema of any markdown model. This should contain all elements that are required to be in the frontmatter of the markdown
getWriterWebPagesMenu
getWriterWebPages
moveFile
newFile
newFolder
processAssetUpload
Used for the markdown reader to immediately process a asset upload. If we want to validate this, it would be good to allow a second parameter that checks if you have access to the file
renameFilename
saveFileContents
add
The ultimate typescript database stores data in typescript
Completion
ContentEditableDivInput
Div that is contentEditable
by default and has possibilities for color/style highlighting, autocomplete, subtexts and tooltips
ContextTextArea
TextArea with ability to enhance personal database and execute prompts
QUESTION:
How to make color highlighting?
I guess we need to wrap all words with a span and make it contenteditable, so we can create a editor where we are styling all words that are written
We can then also change the value of the word if you are NOT editing that word.
So you would only see the true value of a word when your cursor is on that word
TODO:
- replace the textarea with a div contenteditable
- make selectionStart and selectionEnd still working (on the original text)
- whenever you stop editing a word, it needs to be wrapped with a span and styled with a function taking that word and returning a style
- whenver you start a new word through a separator, an empty span should be created
- the span of the current word being edited must have a location (x,y). get that exact location so we can render an autocompletion intellisense
depthFontSizes
DivContentEditable
editSubtextSubwordConfig
Interesting... In order to auto-generate a form for this, we need to combine the two into a simple function that does NOTHING. Why? Because we can't store it in the database, it is better to keep this in the frontend...
NB: DEPRECATED: TODO: function isn't used. Since the indexation didn't go right, the solution with a SimplifiedSchemaForm ended up being easier. Keeping it here because I need to fix the indexation nonetheless.
EditWriterInput
the newer one, eventually to replace ContextTextArea
FrontmatterForm
Renders a form for frontmatter without save button
getSubtext
make a subtext text based on the text of a complete paragraph (may contain single newlines and other markdown stuff, but never double newlines)
Returns either the subtext string or a HTML string with a container around the subtext, depending on if you provide withContainer
getTextSegments
Iterates over all child-nodes in the editor, replaces text with a segment, and replaces nodes with a flat list of segments
Returns all textSegments in an array
getWriterTypeFromContent
isAugmentedWordMatch
isTypescript
only detect typescript if the string starts with import
. must be improved later on. It would be great to be able to detect that it's a typescript file even if it contains syntax errors.
MarkdownCompletions
MarkdownParsePresentation
MarkdownView
MarkedParagraph
MarkedText
MarkedToken
Function that can be used to iterate over the marked parse and style every token, recursively
NB: this returns a regular react component, and should, for setting it as InnerHTML, be parsed with the ReactDOMServer
MAX_COMPLETIONS_AMOUNT
metaClickableClassName
omitSpecialCharactersFromStart
Omits all special characters from the start of a word for the first special character it finds. The other special characters found after that won't be trimmed.
parseTextContentToHtmlString
Returns a html string from a text string that can be rendered in the dom
NB: because we're parsing text from div.innerText, sometimes there are two newlines when there should be one break.
Three newlines means there should be two breaks...
SmartContentEditableDivInput
Uses ContentEditableDivInput, and attaches the Completions to it based on the content type. Also all other data required...
NB: TODO: once the autocomplete inside the contentEditable is done, these things should move inside of there. I need a component that has lots of UI/UX but isn't very smart. This will be able to be re-used in many usecases...
SpannedSentence
Needs to be done for every text that can have potential interactions
specialCharacters
SubtextContainer
Returns a string with HTML for the subtext container, given you already have
Subword
testAllContentEditableRenderComponents
Can be used to test all ContentEditableRenderComponent
s with example inputs
Instead you can also enable devmode and just check it on the live examples
testContentEditableRenderComponent
Creates an element from the markdown input, and then uses the toMarkdownString
function to make it markdown again.
TODO: use
TitleContainer
container for any index instance that needs to be rendered in the explore page
trimAround
Removes x amount of characters from both sides of a word
trimLeft
Trims a character from a word at the left until that character is not found anymore (recursive)
TypescriptCompletions
In typescript
, every word should be autocompletable with the typescript stuff, without backticks.
{ vscodeOpen }
WriterConfigForm
writerInitialValues
WriterInput
Writer input for any utf8 based text, file or no file
MyApp
isObject
notEmpty
/**
- Removes empty values (null or undefined) from your arrays in a type-safe way */
Modal
useNavigation
useIsInViewport
useReactMediaRecorder
getTypescriptErrorsFromFiles
/**
- uses official typescript compiler to check all given files for compilation errors */
slugify
/**
- this function does the same as kebabCase but it also does some more transformation on top
- useful for making simple URLs and filenames. Kebacase is not enough
- NB: this is no two way transformation. When slugifying something, information is lost and it cannot be converted back in the original name.
- TODO: make the tranformations that are done here into smaller util functions and make a clean function that can be ran before running every casing conversion (maybe in a config) */
handleExplicitValidation
hasDefinition
arrayGenerator
/**
- NB: Do I really need this? Would be nice not to use generators. */
onlyUnique
/**
- DEPRECATED: should refactor everything to use onlyUnique2 and call it onlyUnique again
- to be used as a filter. removes duplicates */
worker
generatePassword
/**
- generates a password. By default, uses a length of 14 */
isEmail
byteCount
/**
- This function will return the byte size of any UTF-8 string you pass to it. */
setKeyAtLocation
getChunkBegin
getChunkEnd
getEncoding
/**
- Get the encoding of a buffer.
- Checks the start, middle, and end of the buffer for characters that are unrecognized within UTF8 encoding.
- History has shown that inspection at all three locations is necessary.
- @returns Will be
null
ifbuffer
was not provided. Otherwise will be either'utf8'
or'binary'
*/
isBinary
/**
- Determine if the filename and/or buffer is binary.
- Determined by extension checks first (if filename is available), otherwise if unknown extension or no filename, will perform a slower buffer encoding detection.
- This order is done, as extension checks are quicker, and also because encoding checks cannot guarantee accuracy for chars between utf8 and utf16.
- The extension checks are performed using the resources https://github.com/bevry/textextensions and https://github.com/bevry/binaryextensions
- @param filename The filename for the file/buffer if available
- @param buffer The buffer for the file if available
- @returns Will be
null
if neitherfilename
norbuffer
were provided. Otherwise will be a boolean value with the detection result. */
isFirstByteOf2ByteChar
isFirstByteOf3ByteChar
isFirstByteOf4ByteChar
isLaterByteOfUtf8
isText
/**
- Determine if the filename and/or buffer is text.
- Determined by extension checks first (if filename is available), otherwise if unknown extension or no filename, will perform a slower buffer encoding detection.
- This order is done, as extension checks are quicker, and also because encoding checks cannot guarantee accuracy for chars between utf8 and utf16.
- The extension checks are performed using the resources https://github.com/bevry/textextensions and https://github.com/bevry/binaryextensions
- @param filename The filename for the file/buffer if available
- @param buffer The buffer for the file if available
- @returns Will be
null
if neitherfilename
norbuffer
were provided. Otherwise will be a boolean value with the detection result. */
useOnScreen
/**
- checks wheter or not a certain element is in the browsers screen view, or not. */
NamedParameters<typeof getTailwindModules>
NamedParameters<typeof joinClassNames>
NamedParameters<typeof Svg>
NamedParameters<typeof trimClassName>
NamedParameters<typeof wrapInTextIfNeeded>
SvgType
NamedParameters<typeof AlertProvider>
NamedParameters<typeof useAlert>
MapLocation
PluginInputType
Suggestion
ViewPort
NamedParameters<typeof Modal>
NamedParameters<typeof ModalProvider>
NamedParameters<typeof useModal>
NamedParameters<typeof useModalState>
NamedParameters<typeof useNavigation>
NamedParameters<typeof useRouter>
ID
NamedParameters<typeof getItem>
NamedParameters<typeof setItem>
CustomUrlStoreConfig
NamedParameters<typeof useCustomUrlStore>
ContextualPrompt
Model for prompting information from third party sources
ContextualPromptsObject
FileType
NamedParameters<typeof controlChatGpt>
NamedParameters<typeof controlChatGptCli>
NamedParameters<typeof getContextualPrompt>
NamedParameters<typeof getContextualPromptResults>
NamedParameters<typeof getContextualPrompts>
NamedParameters<typeof getContextualPromptsArray>
NamedParameters<typeof getFolderRelativeScopeDbFilePath>
NamedParameters<typeof processChatGptPrompt>
AiDemoApp
BackendAsset
Part of the asset that should be sent to the backend. The rest should frontend-only
Some values are stored, some are not
ContextualContent
ContextualPromptResult
A result from a contextual prompt. Doesn't include the full context, for that you can find all results for a certain thread
NamedParameters<typeof allOperationsRemoveJsSrc>
NamedParameters<typeof allOperationsToMarkdown>
NamedParameters<typeof clearAllTsDatabases>
NamedParameters<typeof codeAll>
NamedParameters<typeof getAllOperationClassifications>
NamedParameters<typeof mdAllOperations>
NamedParameters<typeof minifyAllOperations>
NamedParameters<typeof removeAllFiles>
NamedParameters<typeof removeAllFolders>
NamedParameters<typeof removeAllFoldersCli>
NamedParameters<typeof runScriptEverywhere>
NamedParameters<typeof setScriptEverywhere>
ApiConfig
NamedParameters<typeof fn1>
NamedParameters<typeof fn2>
NamedParameters<typeof fn3>
NamedParameters<typeof getGetApiUrl>
NamedParameters<typeof untypedApiFunction>
Asset
Asset you can upload
This is not a database model, it can exist in properties of any db model or type interface.
Only alt
and relativePath
are stored, the other parameters are optionally required for uploading and user interfaces, and are not always there
NB: don't use this in your model, use StoredAsset
instead.
AssetInputType
AssetParameter
NamedParameters<typeof addToken>
NamedParameters<typeof ensureToken>
NamedParameters<typeof findAssetParametersRecursively>
NamedParameters<typeof getAssetDirectlyApiUrl>
NamedParameters<typeof getConversionInfoFromType>
NamedParameters<typeof getExtensionFromAsset>
NamedParameters<typeof getNameFromRelativePath>
NamedParameters<typeof getNameWithTokenFromRelativePath>
NamedParameters<typeof getReferencedAssetApiUrl>
NamedParameters<typeof getTypeFromUrlOrPath>
NamedParameters<typeof readableSize>
NamedParameters<typeof removeTokenIfPresent>
NamedParameters<typeof test>
CompressionConfig
FunctionContext
Should be attached as first argument of the function, if the name of the function is in the format of:
xyzWithContext
: attaches all contextxyzWithContextRaw
: attaches all context, api returns just the result of the function without wrapping it in theRealApiReturnType
. Needed in case you have a different server.jsserver.reply
For more info see apiConvention
NamedParameters<typeof compressAsset>
NamedParameters<typeof downloadRemoteAsset>
NamedParameters<typeof deleteReferencedAsset>
NamedParameters<typeof findAbsoluteAssetPathFromReference>
NamedParameters<typeof findAllProjectMedia>
NamedParameters<typeof getStorageLocationInfo>
NamedParameters<typeof getTemporaryAssetsFolderPath>
NamedParameters<typeof processAsset>
NamedParameters<typeof removeOldTemporaryAssets>
NamedParameters<typeof serverDownloadReply>
NamedParameters<typeof uploadAssetWithContext>
ReceivedFile
This is the format that I receive for a file with server.js, even though they say it's a formidable.file, which it's not...
MediaSourceEnum
google: remote image urls giphy: remote image urls unsplashed: remote image urls youtube: remote video urls (selectable as mp3, mp4, or url)
NamedParameters<typeof getTypeFromFileBlob>
NamedParameters<typeof makeBackendAsset>
NamedParameters<typeof SelectMedia>
AssetType
Possible Asset Types
Later, maybe also support: "markdown","json","typescript"
CompressionOption
CompressionOption should be able to be applied on the model parameter through frontmatter
- default (default option): Default OS wide compression. User can make customize it within a logical limit
- none: no compression applied by default (user can optionally compress it)
- high: compressed bigtime by default (user cannot make it be compressed less)
- low: compressed just a little (user cannot make it be compressed less, but can optionally compress it more)
NewAssetType
Possible types for new asset upload in the frontend
UploadAssetBody
NB: other things like alt, final destination etc, should not be sent with the upload, but instead with the function
UploadAssetResult
AugmentedAnyModelType
NamedParameters<typeof AssetView>
NamedParameters<typeof getSrc>
NamedParameters<typeof itemGetBackendAssetUrl>
NamedParameters<typeof useAsset>
NamedParameters<typeof useAssetInfo>
NamedParameters<typeof getAugmentedWordObject>
NamedParameters<typeof getAugmentedWords>
NamedParameters<typeof getBundleAugmentedWords>
AugmentedWord
AugmentedWords should have a small footprint since there can be many of them
Words with a specific affix (backticks, bolded, italic) will match against these.
Used to link automatically to functionNames, InterfaceNames, operation-names, words, and more..
TODO: This is a much more general purpose thing than just markdown-reader-types
. Move to it's own package
AugmentedWordObject
This datastructure is probably needed to make it more efficient.
Should be a lookup table for the querypath for every word
AugmentedWordTypeEnum
NB: can later be replaced with a string enum type: person, definition, variable, function, type interface, operation, bundle (but there may be much more)
Authorization
Authorization helps you provide certain access to files, data, functionality, and code. Authorization can be provided custom, or by indexation. The indexation of the codebase and text-files overwrites the custom authorization in the Group-model.
For files (ts, md, json, etc...):
- canWriteCreate
- canWriteUpdate
- canWriteDelete
- canRead
- canSearch (only search index)
For db model data subsets:
- canWriteUpdate
- canWriteCreate
- canWriteDelete
- canRead
- canSearch (only search index)
For functions:
- canExecute
For functions, interfaces, variables:
- canRead (reading docs only. for source, you need to provide the file auth)
- canSearch (only search index)
AuthorizationModel
Authorization model for indexed authorizations
Don't edit this! If you wish to add authorizations to a group, either edit the code or text-files, or provide custom authorizations to the Group.
Id
Should be an unique string By default, you can use generateId()
to generate a random string of 16 characters. If you wish, you can also use any other string, as long as you are sure it's unique.
azAZ09 characters are easy to copy and provide 62 characters. the goal of an id is to be unique.
the advantage of a random id compared to an numeric id starting with 1 with auto increment is that you can set them up decentralised.
the change of duplicate ids gets bigger once you make them shorter the change of finding an existing id gets bigger once you make them shorter
An Id with 12 characters would provide 3.22e21 combinations.
What is the change of duplicate ids? This depends on the amount of identifyable items in the data What is the change of guessing an id? This depends on speed of a brute force attack and the amount of available datapoints. If you can guess 10000 times per second, you can make 864.000.000 guesses. A billion guesses on a dataset of a billion datapoints yields 3226 correct ids on average.
Why make an id short? I don't know if there's an important reason.
All in all, I think we should make ids 24 characters by default. This would make it very easy to store, yet, with more than E42 combinations, make it nearly impossible to get duplication or brute force hits.
An id would look like this:
{ "id": "sk2EcW9AkZpksk2EcW9AkZpk" }
Looks good to me! Don't think about it and just keep it simple. We can always migrate later to a bigger amount, but I don't see good reason to keep it smaller than this.
Device
A Device that accesses any King OS api.
A device can be connected to a person. A person can have multiple Devices.
A Device does not necissarily have King OS installed themselves, they can also be a visitor to another King OS app of someone else.
NamedParameters<typeof AuthenticationMethodsCrud>
NamedParameters<typeof LoginForm>
NamedParameters<typeof LoginWrapper>
NamedParameters<typeof MeAuthenticationInfo>
NamedParameters<typeof PersonProfileDetailsForm>
NamedParameters<typeof PublicPersonComponent>
NamedParameters<typeof PublicProfile>
NamedParameters<typeof SignupForm>
NamedParameters<typeof UpdateMeForm>
PersonInfo
PersonProfileDetails
Things the user can fill in about themselves on their profile
PublicPerson
NamedParameters<typeof BreadCrumbs>
NamedParameters<typeof renderBreadCrumbs>
AppShell
BundleConfig
Configuration options for bundles. Used with generateBundle
Everything in this model will be copied over to the created bundle, except for createBundleConfig
and customisableBundleConfig
.
BundleMarkdownReaderConfig
CreateBundleConfig
CustomisableBundleConfig
configuration that can be applied when generating a new bundle
It can be put in the BundleConfig, but it can also be set manually for an individual Bundle Generation.
EnvironmentVariableObject
FinalBundleConfig
FinalCreateBundleConfig
CreateBundleConfig after applying the defaults
FinalCustomisableBundleConfig
FrontBackBundle
This type can specify a frontend and backend that belong to each other. it doesn't include all operations that the ui or server are dependent on, they are calculated separately
InformationStrategy
push (default): take needed information from project and push to bundle (removing the existing info)
pullReplace: pull bundle and keep its information intact, not taking anything new from the OS, replacing all the information we had from these models in the OS
pullMerge: pull bundle and use its information in conjunction with the information we had in the OS. This option will merge both information sources, removing duplicate IDs
ignore: don't put any data in the bundle!
Json
OperationName
later we can make this an enum! it can be auto-generated along with enums for the operation paths, and more things alike.
if it's an enum it will automatically be possible to select a value from it in the simplified schema form :D
besides simply having OperationName, we can have specific operation classification operation names:
- JsOperationName (js)
- NodeOperationName (node)
- ServerOperationName (server)
- AppShellOperationName (web, app, etc.)
- UiOperationName (ui-es6 and ui-es5)
OperationPrivacy
ProjectRelativeFilePath
ProjectRelativeFolderPath
later this could be known by the frontend so it will render a ui to select a folder
We need to figure out how we can know all type types in between when getting the type definition schema, not only the final type. If I'm lucky there is a way to find it as a #ref in a consistent way.
PublicBundleConfig
ServerOperationName
Slug
use this for any identifier that's not an Id-type. Usually this is a kebab-case version of a written text, but it can also be a file path, for example.
SlugModelType
use this model for things with a name that have an unique slug that can be used to identify the model
BundleSummary
NamedParameters<typeof getBundleSummary>
NamedParameters<typeof getDbModelsForBundle>
NamedParameters<typeof cleanupTsDatabase>
NamedParameters<typeof shouldDeleteTsModel>
TsBuildError
TsComment
comments are basically one-or-multi-line human content inside of typescript files, so it's a very important to do something useful with them.
The convention should be that single-line comments should start with that. This then becomes the type of the comment. You can also put multiple prefixes at the start.
Example:
// TODO: NB: this is a todo but its also important
Multiline comments can also have one or multiple types in their text, but they should not be split into multiple comments as the context could be needed some times.
There are also some other things comments can say about statements, but these should be inside the frontmatter, and are much more flexible.
- classified[0-10] indicating level of classification. This way I can share subsets of the codebase, maybe...
- privacy
- ...?
NB: with the current setup we can also parse md files as being a TsComment, keep it that way!
NB: comments are part of the code, so they should always be in English!
TsExport
TsFunction
Interface for arrow functions and normal functions
TsImport
TsInterface
TODO: Just like parameters, this should be linted for. If you define an interface that's not declared here, that should ring a bell.
TsLintWarning
TsVariable
AnyModelType
Parameters that every model will always have.
NB: TimeTypes (createdAt, updatedAt, etc.) are not always included because the kvmd-model doesn't have them.
NB: RelationTypes are also not always included for the same reason
CategorizedFilePaths
filepaths categorized based on the filetype. With king os there are only these filetypes:
- code: ts, tsx
- data: json
- text: md, mdx
CommentType
special line prefixes:
Developer related comments*
- TODO: for developer to know what to do
- DISCUSSION: for developer to state that discussion is needed
- IDEA: for developer to state ideas
- LATER: for developer to mark as thing that needs to be done later
- NB: for developer to add a note
Form related comments*
- TITLE: if available, will be used as title of form input (overwrites humanCase version of the property-name itself in that case)
- SECTION: start a new section in the form from this point, the value behind here can be the title
- DESCRIPTION: if available, will be used as description of the form input
CommentTypeObject
Every CommentType can be a key in the SimplifiedSchema, if available.
CommitInfo
CompilerOptions
ContributorPersonInfo
Dataset
Model
Make subsets of models that can be used for authorising someone for a subset of data, or transfering (or filtering out) subsets of data to a bundle.
DatasetConfig
The part of dataset that can be used in certain functions
DatasetConfigKey
DatasetConfigShape
DatasetFilter
Can be better, see https://www.w3schools.com/js/js_comparisons.asp
DatasetFilterOperator
DatasetSort
Sort by comparing the two values using the Array.sort
method and Greater than and Less than operators.
DbStorageMethod
The following strategies are available to store the data.
-
jsonMultiple (default): stores the data in a json file which is an array of this data structure. This file will be located in
db/[pluralized-kebab-case-model-name].json
-
jsonSingle: stores the data in a json file which is of this data structure (single object) These files will be located in
db/[pluralized-kebab-case-model-name]/[instance-slug-or-id].json
-
markdown: stores the data in a markdown file. Takes "markdown" parameter as the main markdown. The other parameters are stored as front-matter. This these files will be located in
db/[pluralized-kebab-case-model-name]/[instance-slug-or-id].md
-
keyValueMarkdown: stores the data in key value markdown format. This file will be located in
db/[pluralized-kebab-case-model-name].md
-
csv: stores the data in a csv file (only possible for flat object datastructures). This file will be located in
db/[pluralized-kebab-case-model-name].csv
- [pluralized-kebab-case-model-name]: e.g.
StudentUser
becomesstudent-users
- [instance-slug-or-id]: For all models with a slug parameter, the filename will be that slug of that instance. Otherwise,
id
will be used
DefaultModelType
Use this model by default
ExplorationDetails
FileContentInfo
Stuff you can find by reading the file
FolderExploration
suggested type for menu is FolderExploration[]
NB: recursive!
FolderSummary
objective size measurements of all files in a folder
summary for a folder should contain file-summaries for different filetypes and an overal file summary
Frontmatter
Our version of frontmatter is a bit simpler than regular frontmatter
Not sure if this is a good idea, but it keeps it simple for our OS
all values parse in a similar way to csv
make sure that you use quotes if you want to store a string with commas, because commas in a parameter indicate that it is a string array
NB: string arrays are comma separated values, where you can put values with special characters in between quotes
FunctionClassification
-
react
: The core library that should always be used that wraps react and react native. -
dumb
: Presentational components that only care about how things look, and have no idea about the type of information that they will contain (data-agnostic), nor their context they're used in. -
smart
: Presentational components that may contain getters and setters for global state. This means they're still easy enough to set up, but -
wise
: stateful components that use the backend as well to do things. for example, simplified-schema-form -
genius
: blocks of components that have certain functionality. Example:file-writer
orcrud
FunctionExecution
Model for tests, examples, cache, and recent executions of any function
Requirement for tifo-stitching
Example:
const someFunction = (inputA: string, inputB:string):string => {
return ${inputA} != ${inputB}
}
find this in the database after executing the function
const functionExecution1 = { .... functionName: "someFunction", inputParameters: ["hello", "world"], output: "hello != world", isTest: false, isExample: false, isResultFromCache: false, performance: [....], }
FunctionParameter
ImportClassification
node: node core packages like fs and path
react: react standard packages like react, react-native, expo, react-dom, etc.
package: packages from npm that are not classified as operations
operation: operations from our monorepo
internal: imports from other places in the same operation
NB: don't confuse this with OperationClassification
IndexModels
JSONSchema7Type
Primitive type
Markdown
a string that is known to contain markdown.
MaybeInteface
at some point in processing we need this interface where definition can also be null
ModelInfo
used to show a list of models available in a menu structure
ModelView
ModelViewEnum
Models should be able to be shown in multiple different views:
- Table: useful to show models with much details
- Grid: useful to show models with a visual aspect and less details
- Timeline: useful to show text-related models
- Tree: useful to show a hierarchy
NamedParameters<typeof abc>
NamedParameters<typeof getExamples>
NamedParameters<typeof getFunctionExersize>
Operation
Model for typerepo
operations. Stored in package.json
in every package (compatible with regular npm package.json data structure). An Operation is a NPM Package that applies the typerepo
convention.
TODO: add a validation to package.json files for the whole project, to ensure i can apply fs-orm convention
OperationClassification
TODO: Ensure embedding this will embed the actual docs in my markdown renderer. I guess it might already do so!
TODO: It would be great to learn more about this topic and see if I can make more cross-environment packages. A great use case would be to create a wrapper around the current fs-orm to enable using it at the frontend too.
OperationPathParse
OperationRepositoryInfo
PackageInfoObject
ParameterName
PathMetaData
All interesting metadata about any path (files and folders)
PathParse
object to represent a folder or file path in different ways
NB: doesn't include the absolute path so the indexes can be exported easily witout creating incorrect paths
PathStats
Information which can be found by fs.stat
PerformanceItem
Price
TLDR;EUROS
A price is a number indicating the relative cost. Absolute cost is calculated by many other factors
For now, we're going to keep it simple: 1 Price is equal to 1 Eurocent.
Later we can add all kinds of extra conversion:
- currency support
- king os currency
- lower cost for poorer people
etc...
First we need to start making sales before we can add such complexity.
RunEveryPeriodEnum
Used to specify functions that need to run every time with a specific interval
All times are at at the server timezone time
minute
: every minute at 0 seconds5-mintues
: every 5 minutes, starting at the first minute of the hourquarter-hour
: every 15 minutes, starting at the first minute of the hourhour
: every hour, starting at the first minute of the hour6-hours
: every 6 hours, starting at midnightmidnight
: every midnight (00:00:00)week
: every week at sundaynight (sunday, 1 second after 23:59:59 PM)month
: at the first second of the first day of the month (0:00:00)3-months
: every start of the quarter: january 1st (0:00:00), april 1st, july 1st, october 1styear
: every new year at january 1st at 0:00:00
Schema
schema type interface we use in TsInterface
NB: don't export because this would make this type exist twice.
SimplifiedSchema
JSONSchema7 derivative that has the following capabilities and and characteristics...
- does not include objects in objects that are also referenced to using xxxSlug or xxxId
- recursively finds the references and expands them, unless the references are circular
- easier to read
- has all the information we need
- is able to generate an object with values in the exact format the function needs it
- is able to easily generate a form
SimplifiedSchemaItem
SimplifiedSchemaProperty
SimplifiedSchemaType
SizeSummary
type interface that can be used to summarize multiple files
TsConfig
would be nice if we have a type interface for this, just like package.json for now just type the stuff we need
TsFunctionFrontmatterConfig
Everything you can do with frontmatter on a TsFunction
TsFunctionIndex
TsIndexModelType
identifier of any index type interface
TypeCoverage
quantification of coverage of the specified type or subtypes in our database.
TypeInfo
all info that should always be collected when indexing any type interface
TypescriptFile
IDEA: What if we could make a custom db storage method for a typescript file, so you can read and write typescript with the database?
The first thing I can do, is to generate all typescript stuff using a model like this:
Later, I can read a typescript file with a rust parser to get it into this model again.
This is actually super useful for metacoding and coding GUI's
Also a great start for making my own programming language ;)
There are multiple ways of describing a typescript file I guess. This is one of them. Another one could be a definition where you put the required context in the statements and types themselves.
TypescriptIndex
Typescript file metadata (all indexes from typescript files, together)
TypescriptScopeContent
TypescriptScopeContext
TypescriptScopeStatementContext
TypescriptScopeTypeContext
CopyPair
NamedParameters<typeof copyCopyPairs>
NamedParameters<typeof copyReaderStaticAssets>
NamedParameters<typeof findReaderStaticAssets>
NamedParameters<typeof findStaticAssets>
ReaderWebPage
specifically always a markdown page
NamedParameters<typeof stripComment>
NamedParameters<typeof stripCommentEnd>
NamedParameters<typeof stripCommentStart>
NamedParameters<typeof stripSlashes>
NamedParameters<typeof stripStar>
NamedParameters<typeof trim>
NamedParameters<typeof trimSurroundingNewlines>
NamedParameters<typeof getCompileErrors>
NamedParameters<typeof getTypescriptErrorsFromFiles>
NamedParameters<typeof writeBuildErrors>
PackageJson
Casing
NamedParameters<typeof camelCase>
NamedParameters<typeof capitalCase>
NamedParameters<typeof capitaliseFirstLetter>
NamedParameters<typeof convertCase>
NamedParameters<typeof convertToTargetCasing>
NamedParameters<typeof getDelimiter>
NamedParameters<typeof humanCase>
NamedParameters<typeof kebabCase>
NamedParameters<typeof lowerCaseArray>
NamedParameters<typeof pascalCase>
NamedParameters<typeof slugify>
NamedParameters<typeof snakeCase>
NamedParameters<typeof splitCasingDelimiters>
NamedParameters<typeof errorToast>
NamedParameters<typeof infoToast>
NamedParameters<typeof showStandardResponse>
NamedParameters<typeof successToast>
NamedParameters<typeof warningToast>
StandardizedApiReturnType
Handy type interface for rendering response
CsvItemType
NamedParameters<typeof tryParseCsv>
CsvModelType
Use this model for things you want to store in CSV format
TODO: add support for numbers, booleans, null, undefined
CsvTestModel
CustomQueryConfig
NB: the dbStorageMethod cannot be specified here because this is a static configuration per db-model and cannot be specified on a per-query basis.
Also you can't specify projectRelativePath and operationRelativePath. It should not be needed, you should specify the db storage locations in the createDb config.
DefaultTestModel
KeyValueMarkdownModelType
handy model type for storing stuff in a KeyValue Markdown file. empty lines are omitted
all you need to specify in the kvmd is the key and the value, separated by ":"
NB: there can be a parent_modelNameSlug
key exposed that should refer to the parent slug
KvmdTestModel
MarkdownModelType
Handy model type for storing stuff in a Markdown file.
1 markdown file will represent 1 MarkdownModelType extended instance
another option could be to parse the markdown file, but to KISS we are going to just return markdown with the full markdown content
TODO: see how this relates to MarkdownFile. Make this very clear!
MarkdownTestModel
NamedParameters<typeof generateCsvInstance>
NamedParameters<typeof generateJsonSingleInstance>
NamedParameters<typeof generateKvmdInstance>
NamedParameters<typeof generateMarkdownInstance>
NamedParameters<typeof generateSlugTestModel>
NamedParameters<typeof get>
NamedParameters<typeof getCli>
NamedParameters<typeof getMergedQueryConfig>
NamedParameters<typeof getRanomAge>
NamedParameters<typeof main>
NamedParameters<typeof migration>
NamedParameters<typeof randomName>
NamedParameters<typeof removeCli>
NamedParameters<typeof set>
NamedParameters<typeof testOperationModels>
NamedParameters<typeof testPerformance>
NamedParameters<typeof updateCli>
NamedParameters<typeof upsert>
NamedParameters<typeof upsertCli>
SlugTestModel
TestModels
DbCrudStore
NamedParameters<typeof DatasetForm>
NamedParameters<typeof getPropertiesDataParameterNames>
NamedParameters<typeof ModelComponent>
NamedParameters<typeof openWhatsapp>
NamedParameters<typeof SearchBar>
NamedParameters<typeof shimmer>
NamedParameters<typeof SimplifiedSchemaFormDebug>
NamedParameters<typeof sortToItem>
NamedParameters<typeof toBase64>
NamedParameters<typeof UpsertForm>
NamedParameters<typeof UpsertPage>
NamedParameters<typeof useInfiniteGetDbModel>
NamedParameters<typeof useModelFromUrl>
SchemaProperty
CacheLookupResult
NamedParameters<typeof cacheLookup>
NamedParameters<typeof calculateOperatingSystemBundle>
NamedParameters<typeof getCachedFunctions>
NamedParameters<typeof getDatabaseMenu>
NamedParameters<typeof getDbModelMetadata>
NamedParameters<typeof getDbModelNames>
NamedParameters<typeof getFunctionIndex>
NamedParameters<typeof getNestedDatabaseMenu>
NamedParameters<typeof hasDbRecipes>
NamedParameters<typeof makeSrcRelativeFolder>
NamedParameters<typeof tsInterfaceToDbMenu>
NamedParameters<typeof filterInterfacesFromOperationNames>
NamedParameters<typeof getDbModelsFromOperations>
NamedParameters<typeof comparePassword>
NamedParameters<typeof encryptPassword>
NamedParameters<typeof exploreOperation>
NamedParameters<typeof exploreProject>
NamedParameters<typeof getExplorationType>
NamedParameters<typeof getFileWithExtension>
NamedParameters<typeof getFolderExplorationDetails>
NamedParameters<typeof getFrontmattersMappedObject>
NamedParameters<typeof getInstanceNames>
NamedParameters<typeof getProjectRelativePaths>
NamedParameters<typeof getTodoPages>
NamedParameters<typeof getTodoPaths>
NamedParameters<typeof hasSameProjectPath>
RelativePathType
TodoPagesConfig
NamedParameters<typeof FancyLoader>
NamedParameters<typeof compressImage>
NamedParameters<typeof compressImages>
NamedParameters<typeof compressImagesCli>
NamedParameters<typeof convertToMp3>
NamedParameters<typeof convertToMp4>
NamedParameters<typeof MatchingText>
NamedParameters<typeof PathSearchResults>
DropboxExtension
these filetypes should never be opened with explore. They should be processed and either indexed or converted. This creates a md or json with the proper metadata, which, in turn, can be explored.
JsonExtension
MarkdownExtension
NamedParameters<typeof getFileTypeFromPath>
NamedParameters<typeof getWriterType>
NamedParameters<typeof hasSubExtension>
NamedParameters<typeof isGeneratedOperation>
NamedParameters<typeof isGeneratedOperationName>
NamedParameters<typeof isIndexableFileId>
SearchableExtension
SearchLevel
TypescriptExtension
WriterType
Type of content that can be interpreted by the writer-input
NamedParameters<typeof findDependantsRecursivelyTest>
NamedParameters<typeof test2>
NamedParameters<typeof folderGetUpdatedAt>
FrontmatterParse
FrontmatterValue
NamedParameters<typeof frontmatterParseToString>
NamedParameters<typeof frontmatterToObject>
NamedParameters<typeof getFrontmatterValueString>
NamedParameters<typeof objectToFrontmatter>
NamedParameters<typeof parseFrontmatterString>
NamedParameters<typeof quotedOrNot>
NamedParameters<typeof stringifyNewlines>
AnyModelObject
CategoryStack
Taken from the location in the folder of the db-model.
NB: Changing this value when updating/upserting, changes where the item is located!
DbFileLocation
Object used to hand over all information about the location of a db-file in a structured way
DbQueryResult
TODO: return the inserted id or other reference
Result of any query except get
. Will not always provide all parameters (depends on the type of query you do)
IncludeConfig
All possible ways to include items from references into a get query
IncludeDataObject
Include
MergedQueryConfig
ModelLocation
Parameters that tell you about the location an instance of a model.
Models can be tied to an operation. They always have a projectRelativePath
, and if they are tied to an operation, also an operationRelativePath
.
NamedParameters<typeof augmentItemWithReferencedDataRecursively>
NamedParameters<typeof findParent>
NamedParameters<typeof getAugmentedData>
NamedParameters<typeof getDatabaseFiles>
NamedParameters<typeof getDatabaseRootFolder>
NamedParameters<typeof getDbFileLocation>
NamedParameters<typeof getDbStorageMethodExtension>
NamedParameters<typeof getLocationPattern>
NamedParameters<typeof getParentSlug>
NamedParameters<typeof getWildcardDbFileLocations__OLD>
NamedParameters<typeof getWildcardDbFileLocations>
NamedParameters<typeof removeKeyValueMarkdown>
NamedParameters<typeof upsertKeyValueMarkdown>
NamedParameters<typeof addDefaultValues>
NamedParameters<typeof calculateOperationsObject>
NamedParameters<typeof createDb>
NamedParameters<typeof getDefaultLocationPattern>
NamedParameters<typeof getMergedConfigOperationPath>
NamedParameters<typeof getRootFolders>
NamedParameters<typeof waitForLockfile>
QueryConfig
RootDbFolder
UpsertKeyValueMarkdownItem
UpsertQueryConfig
Dir
A class representing a directory stream.
Created by {@link opendir } , {@link opendirSync } , or fsPromises.opendir()
.
try { const dir = await opendir('./'); for await (const dirent of dir) console.log(dirent.name); } catch (err) { console.error(err); } ```
When using the async iterator, the `fs.Dir` object will be automatically closed after the iterator exits.
Dirent
A representation of a directory entry, which can be a file or a subdirectory within the directory, as returned by reading from an fs.Dir
. The directory entry is a combination of the file name and file type pairs.
Additionally, when {@link readdir } or {@link readdirSync } is called with the withFileTypes
option set to true
, the resulting array is filled with fs.Dirent
objects, rather than strings or Buffer
s.
FolderPath
DEPRECATED: just use ParsedPath
Fs
all handy Fs types
MarkdownContent
NamedParameters<typeof findFileNameCaseInsensitive>
NamedParameters<typeof getFileName>
NamedParameters<typeof getFolder>
NamedParameters<typeof getLastFolder>
NamedParameters<typeof getPathCombinations>
NamedParameters<typeof parseMd>
NamedParameters<typeof removeAllExcept>
NamedParameters<typeof copyAllRelativeFiles>
NamedParameters<typeof getAllFoldersUntilFolder>
NamedParameters<typeof getFirstAvailableFilename>
NamedParameters<typeof getFolderSize>
NamedParameters<typeof getFolderSizeObject>
NamedParameters<typeof getOneFolderUpPath>
NamedParameters<typeof oneUp>
NamedParameters<typeof renameAndCreate>
PathLike
Valid types for path values in "fs".
Path
unlike PathLike, this is only a string
For now, we don't have a clear convention whether or not this string should be absolute or anything.
Stats
A fs.Stats
object provides information about a file.
Objects returned from {@link stat } , {@link lstat } and {@link fstat } and their synchronous counterparts are of this type. If bigint
in the options passed to those methods is true, the numeric values will be bigint
instead of number
, and the object will contain additional nanosecond-precision properties suffixed with Ns
.
console Stats { dev: 2114, ino: 48064969, mode: 33188, nlink: 1, uid: 85, gid: 100, rdev: 0, size: 527, blksize: 4096, blocks: 8, atimeMs: 1318289051000.1, mtimeMs: 1318289051000.1, ctimeMs: 1318289051000.1, birthtimeMs: 1318289051000.1, atime: Mon, 10 Oct 2011 23:24:11 GMT, mtime: Mon, 10 Oct 2011 23:24:11 GMT, ctime: Mon, 10 Oct 2011 23:24:11 GMT, birthtime: Mon, 10 Oct 2011 23:24:11 GMT }
bigint
version:
console BigIntStats { dev: 2114n, ino: 48064969n, mode: 33188n, nlink: 1n, uid: 85n, gid: 100n, rdev: 0n, size: 527n, blksize: 4096n, blocks: 8n, atimeMs: 1318289051000n, mtimeMs: 1318289051000n, ctimeMs: 1318289051000n, birthtimeMs: 1318289051000n, atimeNs: 1318289051000000000n, mtimeNs: 1318289051000000000n, ctimeNs: 1318289051000000000n, birthtimeNs: 1318289051000000000n, atime: Mon, 10 Oct 2011 23:24:11 GMT, mtime: Mon, 10 Oct 2011 23:24:11 GMT, ctime: Mon, 10 Oct 2011 23:24:11 GMT, birthtime: Mon, 10 Oct 2011 23:24:11 GMT }
UnixTimestamp
NamedParameters<typeof join>
Group
NamedParameters<typeof getFunctionExecutions>
NamedParameters<typeof getFunctionQueryPaths>
NamedParameters<typeof getPublicBundleConfig>
NamedParameters<typeof getSrcRelativeFolderPath>
NamedParameters<typeof getTsFunction>
ApiFunction
FunctionData
ImportStatement
NamedParameters<typeof generateNamedIndex>
NamedParameters<typeof generateSimpleIndex>
NamedParameters<typeof isTestFn>
NamedParameters<typeof mapToImportStatement>
Address
The old location interface I made up had multiple references, but I don't think this is needed. We can simply use the category interface
export interface Location extends SlugModelType { continent_locationSlug: Slug; country_locationSlug?: Slug; regionProvinceState_locationSlug?: Slug; city_locationSlug?: Slug; }
Area
in the UI this should be a special input type, where you can draw a polygon or circles on the map and the center will be calculated
Circle
City
Country
DistantObject
Location
locations are hierarchically categorized pieces of information.
a city can refer to the area, the area can refer the the country, the country to the continent, etc.
there are multiple ways to categorize it, but this depends on the application.
Polygon
Position
SpacePosition
IDK HOW TO DO DIS :(
NamedParameters<typeof getImportedDependencies>
NamedParameters<typeof getPackage>
NamedParameters<typeof isAbsoluteImport>
NamedParameters<typeof calculatePackageJsonDependencies>
NamedParameters<typeof findAndWriteImportsExports>
NamedParameters<typeof getImportsExportsTest>
NamedParameters<typeof getPackageNameFromAbsoluteImport>
NamedParameters<typeof isAbsoluteImportBuiltin>
NamedParameters<typeof isImportFromOptionalFile>
NamedParameters<typeof isImportGenerated>
NamedParameters<typeof writeResult>
NamedParameters<typeof getOperationBins>
NamedParameters<typeof getOperationPackageName>
NamedParameters<typeof getPackageJson>
NamedParameters<typeof getPackageSourcePaths>
ModuleKind
ModuleResolutionKind
NamedParameters<typeof findOperationBasePath>
NamedParameters<typeof findOperationBasePathWithClassification>
NamedParameters<typeof getAllPackageJsonDependencies>
NamedParameters<typeof getCommonAncestor>
NamedParameters<typeof getOperationClassification>
NamedParameters<typeof getOperationClassificationObject>
NamedParameters<typeof getOperationPath>
NamedParameters<typeof getOperationPathParse>
NamedParameters<typeof getOperationRelativePath>
NamedParameters<typeof getPathParse>
NamedParameters<typeof getPathsWithOperations>
NamedParameters<typeof getProjectRoot>
NamedParameters<typeof getRelativeLinkPath>
NamedParameters<typeof getRelativePath>
NamedParameters<typeof getSrcRelativeFileId>
NamedParameters<typeof hasDependency>
NamedParameters<typeof hasProjectRootFile>
NamedParameters<typeof isBundle>
NamedParameters<typeof isOperation>
NamedParameters<typeof isUiOperation>
NamedParameters<typeof isWorkspaceRoot>
NamedParameters<typeof makeRelative>
NamedParameters<typeof packageCompilesTs>
NamedParameters<typeof tsconfigCompilesEsm>
OperationClassificationObject
NamedParameters<typeof getTsConfig>
CommentRange
CompleteOperationPathParse
Config
JSONSchema7
MorphInterfaceInfo
NamedParameters<typeof cli>
NamedParameters<typeof findCommentTypes>
NamedParameters<typeof generateSchema>
NamedParameters<typeof getDbStorageMethod>
NamedParameters<typeof getFrontmatterDbStorageMethod>
NamedParameters<typeof getIndexId>
NamedParameters<typeof getMaxIndentationDepth>
NamedParameters<typeof getNumberOfLines>
NamedParameters<typeof getParametersFromInterfaces>
NamedParameters<typeof getPossibleRefs>
NamedParameters<typeof getSizeSummary>
NamedParameters<typeof getSpecialExtensionDbStorageMethod>
NamedParameters<typeof getValidatedOperationPathParse>
NamedParameters<typeof hasDefinition>
NamedParameters<typeof hasTypescriptFileChanged>
NamedParameters<typeof indexTypescript>
NamedParameters<typeof indexTypescriptFile>
NamedParameters<typeof makeTsComment>
NamedParameters<typeof schemaToTsInterface>
NamedParameters<typeof tryCreateSchema>
Project
Project that holds source files.
WatchEventType
Different event types for the watcher of the file system (chokidar)
- add: a file got created
- addDir: a folder got created
- change: a file changed
- unlink: a file got removed
- unlinkDir: a folder got removed
NamedParameters<typeof concatenate>
NamedParameters<typeof getParameterAtLocation>
NamedParameters<typeof hasAllLetters>
NamedParameters<typeof mergeNestedObjectTest>
NamedParameters<typeof replaceLastOccurence>
NamedParameters<typeof reverseString>
NamedParameters<typeof trimSlashes>
O
NamedParameters<typeof getSimpleJsonString>
NamedParameters<typeof benchmark>
NamedParameters<typeof exploreOperationFolders>
NamedParameters<typeof findAllDocsFolderPaths>
NamedParameters<typeof findAllFoldersWithName>
NamedParameters<typeof findAllPackages>
NamedParameters<typeof findAllTodoFolderPaths>
NamedParameters<typeof getArgument>
NamedParameters<typeof pathArrayIsOperation>
NamedParameters<typeof runTestsForOperation>
NamedParameters<typeof sum>
KeyValueMarkdownParse
MarkdownChunk
NamedParameters<typeof flattenMarkdownChunks>
NamedParameters<typeof getKvmdItemsRecursively>
NamedParameters<typeof getParagraphsRecursively>
NamedParameters<typeof kvmdDataMap>
NamedParameters<typeof kvmdDataToString>
NamedParameters<typeof kvmdParseToMarkdownString>
NamedParameters<typeof markdownStringToKvmdParse>
NamedParameters<typeof parseKvmdLine>
CoreWordMatrixWord
KvmdWord
Should later be migrated to WordMatrix
Language
all currently supported languages
MappedWordMatrix
Mapped Object for performance reasons
MarkdownWord
Should later be migrated to WordMatrix
NepaliEnglishTranslationMatrix
Statement
TokiPonaMatrix
DEPRECATED: to be migrated to WordMatrix
Translation
We could have a Translation model that collects any translation for any key for any model for any language. The original source text is still stored in the models itself, and every model has just one language.
If you want a markdown or text key to be translated, add {parameter}_TranslationId
to the model. The translation can then be generated on-demand and improved afterwards.
Word
The goal of the words model is to provide a definition for every word we use, in any language.
DEPRECATED: Should be replaced with WordMatrix
WordCategory
Different ways to categorise a word semantically
WordCombination
Best way to combine words if you don't want to specify all language specific info for a new word. You can refer to words from the WordMatrix instead!
WordConjucation
In linguistics, conjugation is the creation of derived forms of a verb from its principal parts by inflection
Besides this, there are also other ways to alter a word to add/change meaning, this should be summed up using this enum.
WordInfo
WordLanguageInfo
Language specific word information
WordLanguageInfoObject
WordMatrix
WordMatrix is a matrix that contains as much information about a word as possible in as many languages as possible. Easy to use for 1:1 translation
@see Language
WordPriority
WordType
NamedParameters<typeof Header>
NamedParameters<typeof PingApi>
NamedParameters<typeof preIndexLint>
GlobalLogConfig
a logging configuration object that you can set using a file in the root of your operation or project.
LogConfig
LogType
how should it look and feel?
NamedParameters<typeof getCallerFileName>
NamedParameters<typeof log>
NamedParameters<typeof parseTitle>
OperationLogConfig
ProjectLogConfig
MailDataFromOptional
From is optional for sending an email because it will be filled in by the OsConfig default.
NamedParameters<typeof sendMail>
CodeblockMode
MarkdownParse
MarkdownParseRenderConfig
NamedParameters<typeof getRealSrc>
NamedParameters<typeof getUrlFromRelativeUrl>
NamedParameters<typeof getYoutubeId>
NamedParameters<typeof MarkdownCodeblock>
NamedParameters<typeof Parameter>
NamedParameters<typeof renderFrontmatter>
NamedParameters<typeof renderMarkdownChunk>
NamedParameters<typeof renderMarkdownContent>
NamedParameters<typeof renderMarkdownParse>
NamedParameters<typeof renderMarkdownTitle>
NamedParameters<typeof useOpenHashDetails>
MarkdownParagraphChunk
MarkdownParseConfig
MarkdownReference
NamedParameters<typeof chunkToStringRecursively>
NamedParameters<typeof getChunkParagraphsRecursively>
NamedParameters<typeof getImplicitId>
NamedParameters<typeof getMarkdownIntro>
NamedParameters<typeof getMarkdownParseParagraphs>
NamedParameters<typeof getMarkdownReferencePaths>
NamedParameters<typeof getMarkdownReferencesFromParagraph>
NamedParameters<typeof markdownParseToMarkdownString>
NamedParameters<typeof markdownParseToMarkdownStringFromContent>
NamedParameters<typeof mdContentParseRecursively>
NamedParameters<typeof mdToJsonParse>
NamedParameters<typeof parseFrontmatterMarkdownString>
NamedParameters<typeof parseMarkdownParagraph>
NamedParameters<typeof parseMdToChunks>
NamedParameters<typeof removeHeaderPrefix>
DependantCountObject
interface that lets us count the amount of dependant files in different item types
JsonPart
MergedMarkdownOutlineUrl
NamedParameters<typeof addDependantCount>
NamedParameters<typeof bundleFolderWithMarkdown>
NamedParameters<typeof bundleToBookMarkdown>
NamedParameters<typeof bundleToMarkdown>
NamedParameters<typeof concatMarkdownFiles>
NamedParameters<typeof createMinimizedSection>
NamedParameters<typeof createMinimizedSectionMarkdown>
NamedParameters<typeof deployToVercel>
NamedParameters<typeof emailMarkdownParse>
NamedParameters<typeof generateStaticSite>
NamedParameters<typeof getJsonSchemaSummary>
NamedParameters<typeof getMarkdownContents>
NamedParameters<typeof getMergedMarkdownOutlineUrl>
NamedParameters<typeof getOperationSummary>
NamedParameters<typeof getOutline>
NamedParameters<typeof getPublicMarkdownNestedPathObject>
NamedParameters<typeof getTitlesRecursively>
NamedParameters<typeof getTypeDescriptorRecursive>
NamedParameters<typeof isConventionFileStatement>
NamedParameters<typeof isUpperCase>
NamedParameters<typeof makeOutlineMarkdownString>
NamedParameters<typeof makePropertiesTable>
NamedParameters<typeof markdownChunksToMarkdownStringRecursive>
NamedParameters<typeof markdownChunkToMarkdownStringRecursive>
NamedParameters<typeof markdownToSayable>
NamedParameters<typeof mdToPdf>
NamedParameters<typeof mergeMarkdownParse>
NamedParameters<typeof noNewlines>
NamedParameters<typeof operationRadio>
NamedParameters<typeof operationToMarkdown>
NamedParameters<typeof print>
NamedParameters<typeof printNestedTitles>
NamedParameters<typeof projectToMarkdown>
NamedParameters<typeof propertyToTableRow>
NamedParameters<typeof sayablesToMp3>
NamedParameters<typeof selectRandomOperation>
NamedParameters<typeof simplifiedSchemaToMarkdownString>
NamedParameters<typeof statementItemToMarkdown>
NamedParameters<typeof tsFunctionToMarkdownString>
NamedParameters<typeof tsInterfaceToMarkdownString>
NamedParameters<typeof tsVariableToMarkdownString>
NamedParameters<typeof upMarkdownChunkLevelRecursively>
NestedTitle
OperationSummary
Sayable
GOAL:
- distribute read only (and audio only) material of my codebase
- it is also a fundament for other applications in the future
StatementItem
GetStaticPathsContext
GetStaticPropsContext
MarkdownCallToAction
NamedParameters<typeof copyStaticAssets>
NamedParameters<typeof copyStaticAssetsCli>
NamedParameters<typeof docsGetPages>
NamedParameters<typeof docsGetStaticPaths>
NamedParameters<typeof docsGetStaticProps>
NamedParameters<typeof getAllMarkdownReaderPages>
NamedParameters<typeof getChildren>
NamedParameters<typeof getFolderExplorationInfo>
NamedParameters<typeof getMarkdownModelPages>
NamedParameters<typeof getMarkdownPageInfo>
NamedParameters<typeof getMarkdownReaderQueryPaths>
NamedParameters<typeof getOperationPages>
NamedParameters<typeof getPublicMarkdownFilePaths>
NamedParameters<typeof getReaderTodoPages>
NamedParameters<typeof markdownReaderGetStaticPaths>
NamedParameters<typeof markdownReaderGetStaticProps>
NamedParameters<typeof markdownReaderGetStaticPropsFromPages>
NamedParameters<typeof removeExtensionsFromPath>
NamedParameters<typeof removeNumberPrefix>
NamedParameters<typeof shouldExposeMarkdownFile>
NamedParameters<typeof stripReadmeFromFolder>
NamedParameters<typeof getQueryPath>
ParsedUrlQuery
MarkdownReaderPageProps
NestedWebPage
Only used for menu, so can be undefined because it shouldn't be available
ReaderPageContentProps
ExtendedMarkdownProperties
Some properties for on any MarkdownModelType model that are quite general purpose and yet aren't included into the MarkdownModel
because we may not always want them.
MarkdownContentLevel
0 is a paragraph 1-6 is h1 until h6
MarkdownEmbed
Anything in the format 
NB: I need to be very clear how this one works
MarkdownHeader
MarkdownLink
Anything in the format [alt](href)
It needs to be clear how this works. There is a convention for this, and I should implement that as good as possible, and document it here
MarkdownParagraph
NamedParameters<typeof markdownParseToMarkdownModelType>
NamedParameters<typeof parseMarkdownModelTimestamp>
NamedParameters<typeof tryParseDate>
PostableProperties
Postable
is not extending a modeltype anymore, it can be attached to any MarkdownModelType model
TextJson
TODO: Rename
WebMarkdownFile
Every markdown file meant for the web, should have these optional parameters that can be declared as its frontmatter
NB: This is not part of MarkdownModelType, because MarkdownModelType is very barebones general purpose, not only for the web!
WebMarkdownProperties
WebsiteHeader
WebsiteHeaderProperties
NamedParameters<typeof findCodespans>
NamedParameters<typeof findEmbeds>
NamedParameters<typeof findEmbedsTest>
NamedParameters<typeof findLinks>
NamedParameters<typeof cleanupTimer>
NamedParameters<typeof generateUniqueId>
NamedParameters<typeof getNewPerformance>
NamedParameters<typeof minifyBuild>
CategoryModelType
TODO: make this be able to hold more than just the KV. If that's not really needed just throw this away...
Simple recursive data structure for hierarchical categories. Should be used to make any category model
Make sure, when extending this, to provide a reference xxxSlug
and its content xxx
as optional parameters to its parent categories.
E.g. for a CountryCategory
, you should provide countryCategorySlug
and countryCategory
CreatedAt
CreatedFirstAt
in some cases, data can be created before it was created in our system. In this case, use CreatedFirstAt if this information is important.
Credit
DeletedAt
Euro
Index
used for md files. index is the line
KvmdLine
all things that can be parsed from a single line
NamedParameters<typeof generateId>
NamedParameters<typeof generatePassword>
NamedParameters<typeof generateRandomString>
NamedParameters<typeof generateTime>
NamedParameters<typeof isEmail>
PhoneNumber
country code without +
RelationType
This probably doesn't work, but it would be great if it would. This way I'd like to say that any model can have keys that end with "Id". These keys should always refer to Ids from other models. Also, if a model has a key like this, it is inferred that there is also a key without the Id suffix which does or doesn't cointain the actual model specified by the id.
If this cannot be done in typescript, it can be convention, and we can create a linter for this.
Wooh!
const relations: RelationType = {
helloId: "hoi",
byeId: "bye",
};
The above seems to be working fine, so it IS possible!
TODO: think about it... should the name of the parameter be dependent on the strategy of how the model is stored? Maybe just call it all id, right? We can also make the index a string by just prepending a string to it.
ShouldNotBeStored
Parameters that should not be stored into the database
SlugModelProperties
Time
Time
Time can be stored in various ways but in my experience it is, again, best to keep it simple and just have one way to store time. I can think about this for hours, but my intuition goes towards using the same format as Date.now() because it is a very small format and is easy to read.
It is the amount of ms since 1970.
I could argue to store it in seconds since 1970 since there are few applications of doing ms, but maybe we do, and it's just 30% bigger. No problem.
Therefore, let's store all time values in the format Date.now()
TimeTypes
TimeTypes is often extended with modelTypes.
UpdatedAt
Url
valid url, can be validated
NamedParameters<typeof getAssetInputType>
NamedParameters<typeof getParameterContentType>
NamedParameters<typeof isCalculatedParameter>
NamedParameters<typeof isGeneratedParameterName>
PatternMatcher
ExpandedObject
NamedParameters<typeof useExpanded>
PreviewData
NamedParameters<typeof getDependenciesSummary>
NamedParameters<typeof getOperationMetaData>
NamedParameters<typeof recalculateOperationIndexJson>
OperationMetaData
NamedParameters<typeof parsePrimitive>
NamedParameters<typeof parsePrimitiveArray>
NamedParameters<typeof parsePrimitiveBoolean>
NamedParameters<typeof parsePrimitiveString>
PrimitiveResult
NamedParameters<typeof byteCount>
NamedParameters<typeof getFolderSummary>
NamedParameters<typeof sumSizeSummary>
NamedParameters<typeof calculatePathMetaData>
NamedParameters<typeof categorizeFiles>
NamedParameters<typeof getPathMainComment>
Achievement
AppOperation
AuthenticationMethod
AuthenticationMethodMethod
Username + password should be the default
Email OTP, phone number OTP (sms or call or whatsapp), should be optional 2FA methods
All others can also act as authentication methods, but the token shouldn't be stored
Developer
HandleObject
can be used on multiple models.
IBrowser
NB: copied from ua-parser-js ^1.0.32 because they weren't indexed
ICPU
IDevice
IEngine
Interest
IOS
IPInfo
Information that is inferred from an IP
IResult
MediaCredential
PageVisit
Any visit tracked based on a server request
NB: TODO: it might occur that a page fetches multiple api endpoints, which will create duplicate data here. How do I fix that?
PeerMessage
DEPRECTATED: should be replaced by MediaPost. MediaPost can have many channels, and this is just one of them
Person
Model to describe a human person. This model gathers and stores all persons around the world, except for yourself. Kind of a user-like model...
The data inside this model is coming from the Person itself but also from the owner of the OS server. It should be possible for the person to automatically push information into any of their instances on any server, but the OS owner can augment this.
NB: This is a DefaultModelType, which means name and slug need not to be unique, but it is highly preferred.
Persona
Highly private model.
Configuration for a person identity that you say that is you.
As a OS user you can have multiple personas between which you can easily switch.
The difference from Person is that Person stores other people, whereas Persona stores different identities you give to yourself.
NB: brands should also be able to be personas, and since some brands are shared between people, you should be able to share Persona's with other Persons into their OS...
Persona: A persona, depending on the context, is the public image of one's personality, the social role that one adopts, or simply a fictional character. The word derives from Latin, where it originally referred to a theatrical mask. On the social web, users develop virtual personas as online identities. (Wikipedia)
PersonInformation
categorisation model for informormation about a person
- the keys are the things you want to store
- the values are the descriptions of the thing to be stored
- the categories can organise the things you want to store better
PersonInformationValue
key value data storage model for information about a person
- the filename must identify the person this is about (
personSlug
) - the categories are the different people and the person information categories
- the keys are the person information datapoints
- the values are the values of the datapoints that you stored about this user
Example:
the file person-information-values/abraham-lincoln.md
could contain something like this:
# life
born: 11-01-1777
died: 20-12-1812
# identification
firstName: Abraham
lastName: Lincoln
NB: It's not going to be easy to keep this model in sync with the model it relies on!
TODO: figure out if this kan be a KeyValueMarkdownModelType or MarkdownModelType
PersonPlatformConnection
Forgive the long name, but this model connects the user with the people they have a connection with on specific platforms
e.g. John Doe is connected with me on LinkedIn with the handle johndoe123
Not sure if this is the best way to do this, there may be limitations... For example, both I and the other person can have multiple social media accounts on a single platform
PersonSocialMedia
media (mediums) that a person uses, e.g. linkedin, twitter, whatsapp, sms, calling, and irl
Platform
Collection of platforms that can be found on the internet
e.g. linkedin would have userUrlPrefix: https://linkedin.com/in/
and userUrlSuffix:""
PublicPersonKeys
NamedParameters<typeof getPrimaryPersona>
NamedParameters<typeof isPlural>
NamedParameters<typeof isSingular>
NamedParameters<typeof pluralize>
NamedParameters<typeof singularize>
NamedParameters<typeof readCsvFile>
NamedParameters<typeof readCsvFileSync>
NamedParameters<typeof readJsonFile>
NamedParameters<typeof readJsonFileSync>
NamedParameters<typeof readProjectRelativeJsonFile>
NamedParameters<typeof readKvmdFile>
NamedParameters<typeof readMarkdownFile>
NamedParameters<typeof readMarkdownFileToModel>
IndexFilter
NamedParameters<typeof getFolderTypescriptIndex>
NamedParameters<typeof getOperationIndexModel>
NamedParameters<typeof readTypescriptFile>
NamedParameters<typeof uniqueNames>
FilePage
NamedParameters<typeof AugmentedWordComponent>
NamedParameters<typeof Dictionary>
NamedParameters<typeof DocsReaderLayout>
NamedParameters<typeof Layout>
NamedParameters<typeof ReaderPageContent>
NamedParameters<typeof ReaderPageHeader>
NamedParameters<typeof clearTsDatabase>
NamedParameters<typeof executeCommandQuietUnlessFail>
NamedParameters<typeof exitIfProcessDependenciesChanged>
NamedParameters<typeof generateJsonSchemas>
NamedParameters<typeof getAllDbModels>
NamedParameters<typeof getFileIds>
NamedParameters<typeof getIndexFileIds>
NamedParameters<typeof getSrcIds>
NamedParameters<typeof isOperationBuildNeeded>
NamedParameters<typeof isSdkOperation>
NamedParameters<typeof rebuildAllOperations>
NamedParameters<typeof rebuildOperation>
NamedParameters<typeof rebuildOperationCli>
NamedParameters<typeof shouldSkip>
NamedParameters<typeof yarnBuild>
NamedParameters<typeof getMenuPagesObject>
NamedParameters<typeof queryPathsArrayToNestedPathObject>
NamedParameters<typeof reduceQueryPathsRecursively>
NestedPathObject
A different way to represent a path array in a nested object of folders
{ "folderName": { "file1": null, "file2": null }, "folderName2": { "file1": null, "file2": null } }
NamedParameters<typeof bodyFromQueryString>
NamedParameters<typeof getFirstQueryStrings>
NamedParameters<typeof getQueryPart>
NamedParameters<typeof isValidEntry>
NamedParameters<typeof toQueryString>
QueryableObject
NamedParameters<typeof runChildProcess>
NamedParameters<typeof sayDutch>
NamedParameters<typeof sayLanguage>
NamedParameters<typeof sayNepali>
NamedParameters<typeof saySomething>
NamedParameters<typeof textToMp3>
SayLanguageEnum
SayOptions
JSONSchema7Definition
JSON Schema v7
NamedParameters<typeof findFirstCommentTypes>
NamedParameters<typeof getDataParameterNames>
NamedParameters<typeof getPossibleReferenceParameterNames>
NamedParameters<typeof getProperties>
NamedParameters<typeof getReferencableModels>
NamedParameters<typeof getReferenceParameterInfo>
NamedParameters<typeof getRefLink>
NamedParameters<typeof getSchema>
NamedParameters<typeof getSchemaItems>
NamedParameters<typeof simplifiedSchemaToTypeDefinitionString>
NamedParameters<typeof simplifySchema>
ReferenceParameterInfo
SchemaItem
NamedParameters<typeof addAuthenticationMethod>
NamedParameters<typeof addDeviceAuthenticationMethodConfirm>
NamedParameters<typeof addDeviceAuthenticationMethodWithContext>
NamedParameters<typeof addPersonAuthenticationMethodWithContext>
NamedParameters<typeof findAuthenticatedPersonWithHandle>
NamedParameters<typeof findLoggedinPersonsWithContext>
NamedParameters<typeof getMeWithContext>
NamedParameters<typeof getPublicPerson>
NamedParameters<typeof getPublicPersons>
NamedParameters<typeof isPhoneNumber>
NamedParameters<typeof isValidPassword>
NamedParameters<typeof loginWithContext>
NamedParameters<typeof loginWithPasswordWithContext>
NamedParameters<typeof logoutWithContext>
NamedParameters<typeof removeDeviceAuthenticationMethodWithContext>
NamedParameters<typeof removePersonAuthenticationMethodWithContext>
NamedParameters<typeof signupWithContext>
NamedParameters<typeof signupWithPasswordWithContext>
NamedParameters<typeof switchCurrentPersonWithContext>
NamedParameters<typeof updateMeWithContext>
SignupPersonData
NamedParameters<typeof setJsonKey>
NamedParameters<typeof setKeyAtLocation>
NamedParameters<typeof Share>
NamedParameters<typeof useAllText>
NamedParameters<typeof useLastSelection>
NamedParameters<typeof findAudioWithViewsArray>
NamedParameters<typeof markdownParseToShortMarkdown>
NamedParameters<typeof shortMarkdownToMarkdownParse>
AudioWithViews
DialogueSentence
NamedParameters<typeof augmentShortMarkdown>
NamedParameters<typeof fetchVoices>
NamedParameters<typeof fetchVoicesTest>
NamedParameters<typeof generateAugmentedShortMarkdown>
NamedParameters<typeof generateAugmentedShortMarkdownTest>
NamedParameters<typeof getOrGenerateShortMarkdown>
NamedParameters<typeof parseDialogue>
NamedParameters<typeof uberduckGetPath>
NamedParameters<typeof uberduckSpeak>
NamedParameters<typeof voiceCloneDialogue>
ShortMarkdown
AudioTrackItem
ViewEmbed
NamedParameters<typeof ShortMarkdownPlayer>
NamedParameters<typeof useMultiAudio>
NamedParameters<typeof getReferencedModelDataItem>
NamedParameters<typeof useReferencableModelData>
ReferencedModelDataItem
ReferenceItem
ReferenceItemsObject
NamedParameters<typeof sendSms>
MediaChannel
channel where messages can be posted to
examples:
- facebook group
- slack channel
- whatsapp pm
- facebook pm
MediaPlatformEnum
MediaPost
Post/message on any medium.
SocialMediaPostTypeReturnType
JSONValue
NamedParameters<typeof objectStringToJson>
NamedParameters<typeof parseIfJson>
NamedParameters<typeof parsePrimitiveJson>
NamedParameters<typeof stringToJson>
EncodingOpts
NamedParameters<typeof getChunkBegin>
NamedParameters<typeof getChunkEnd>
NamedParameters<typeof getEncoding>
NamedParameters<typeof isBinary>
NamedParameters<typeof isFirstByteOf2ByteChar>
NamedParameters<typeof isFirstByteOf3ByteChar>
NamedParameters<typeof isFirstByteOf4ByteChar>
NamedParameters<typeof isLaterByteOfUtf8>
NamedParameters<typeof isText>
ReviewSummary
SelfSprintReview
GOAL:
- provide a good way for freelancers and students to self-assess
- structure the data to provide tools for self-analysis
TODO: PREREQUISITE:
- auth layer
- p2p
- create a model-agnostic-ui that renders this type of models nicely (many checkmarks, some sliders, some descriptions). can simply be converted into text for the most part
- make the DB crud component
- which also allows extra columns
- which also has an option to use the model-agnostic-ui
- add Datasets support to DB crud
- make sure the form shows nicely
- slider component and convention
- show description by ensuring that, if the trimmed description is an empty string, it shows everything on all lines after, until the next variable
- monetisation
THOUGHTS:
- this was just one hour of work, and it kind of is a product (given I make all the general purpose prerequisites). I can make it a bundle that devs can install and BOOM! you got a SaaS... just charge 1$ per entry xD
- think about other things that can be assessed, can/should they be automated too? not only for teams, also for intimate groups of people to assess private things, also for yourself completely
- if I have more things like this, which are basically scoring sheets, I can easily reuse the statistics part of the UI that I make for this
TODO: CUSTOM:
- make a
ui-web
operation that has just this crud (or add to the Todo UI) - add nice flow for showing the "coder of the week"
- add a column to share an item on social media if it's your own (may be super reusable too)
- later add things like summaries, history, comparisons, insights (but do it as generic as possible)
- later provide more auto-filled datapoints (xyzIndexed) for different things
- later let user auto-share things with the marketstack xD
SpecialKvmdModelType
Should be a model that can be taken from the database like kvmd, but for parsing, it needs its own parse methods (from and to json)
These methods can be given in the configuration of createDb.
These methods can be found.
Todo
TodoFile
Any markdown file in the todo folder should become this model
TodoFileProperties
TodoOffer
Freelancers can offer their services for a todofile
TodoOfferStatus
Status of an offer to do some todolist
offered
: offer placed, has not been accepted yet. freelancer can still edit offer or remove itrejected
: offer can be rejected by admin (before accepting)canceled
: freelancer and admin can cancel an previously accepted offeraccepted
: offer is accepted by admintodo
: freelancer has said it still needs to be donedoing
freelancer has said it's in progressdone
freelancer said it's doneapproved
approved by admin, offer should become archived
TodoPriority
NamedParameters<typeof tryParseJson>
NamedParameters<typeof getAllTsMorphSourceFiles>
NamedParameters<typeof getTsMorphProject>
NamedParameters<typeof createCodeblockMarkdown>
CrudPage
Data needed to make a WebPage
CustomWebPage
different kinds of WebPages
FileWebPage
FunctionFormPage
Data needed to make a WebPage
NamedParameters<typeof crudPageToWebPages>
NamedParameters<typeof functionFormPageToWebPage>
WriterWebPage
NamedParameters<typeof writeToAssets>
NamedParameters<typeof getFileContents>
NamedParameters<typeof getWriterWebPages>
NamedParameters<typeof getWriterWebPagesMenu>
NamedParameters<typeof moveFile>
NamedParameters<typeof newFile>
NamedParameters<typeof newFolder>
NamedParameters<typeof processAssetUpload>
NamedParameters<typeof renameFilename>
NamedParameters<typeof saveFileContents>
NamedParameters<typeof Completion>
NamedParameters<typeof editSubtextSubwordConfig>
NamedParameters<typeof getContext>
NamedParameters<typeof getSubtext>
NamedParameters<typeof getWriterTypeFromContent>
NamedParameters<typeof isAugmentedWordMatch>
NamedParameters<typeof isTypescript>
NamedParameters<typeof MarkdownCompletions>
NamedParameters<typeof MarkdownParsePresentation>
NamedParameters<typeof MarkdownView>
NamedParameters<typeof MarkedToken>
NamedParameters<typeof omitSpecialCharactersFromStart>
NamedParameters<typeof SpannedSentence>
NamedParameters<typeof SubtextContainer>
NamedParameters<typeof testAllContentEditableRenderComponents>
NamedParameters<typeof trimAround>
NamedParameters<typeof trimLeft>
NamedParameters<typeof TypescriptCompletions>
NamedParameters<typeof WriterConfigForm>
SubtextConfig
Configuration of what should be shown in the subtext
SubwordConfig
Configurate what should be shown about words
TextEditingContext
WriterConfigFormValue
SubtextRelatedThing
SubwordViewMode
WriterViewEnum
Dictionary
markdown-reader-web
sdk-api
sdk-api-keys
sdk-db
This operation is used to collect all typebase database models in the entire project, and export them, wrapped in a DbModels
interface. This is needed for creating a function that can access the entire database (see database operation)
sdk-env-private
This operation contains all private environment variables that can be used on the frontend and backend of your application(s).
Generated for bundles (to be set in BundleConfig), manually set for King OS.
NB: make sure not to import this in any frontend operations, because it may contain private keys and other secrets!
sdk-env-public
This operation contains all public environment variables that can be used on the frontend and backend of your application(s).
Generated for bundles (to be set in BundleConfig), manually set for King OS.
sdk-function-paths
sdk-interface-paths
sdk-js
operation that imports all js
functions and variables in the entire project (OS or bundle) and exports an object that has all of them.
can be generated
sdk-operations
Generated operation that exports an object that contains all names of all operations as keys, and all project relative paths to those operations as values.
Needed to find files more quickly in a more performant way.
When moving operations around, ensure to regenerate this to avoid conflicts.
sdk-ui
react-with-native
HTML elements with React Native capabilities.
react-with-native-alert
TODO: NB: seems not to work right now in a new template! Fix it
react-with-native-form
Create forms, fast
react-with-native-form-inputs
react-with-native-modal
react-with-native-notification
Makes it possible to receive notifications in both react and react-native.
react-with-native-router
react-with-native-select
react-with-native-store
Simple localStorage/asyncStorage-based and fully typed redux replacement with global persisted storage by default for react and react-native apps.
react-with-native-table
react-with-native-ui
Simple basic Tailwind class strings for sensible UI components
use-url-store
ai-functions-node
ai-types
all
This operation contains a lot of different functions that can help you to execute different things on all operations.
api
This object contains an api function for every function in the backend
NB: only use this if you can access localStorage of the browser or the app. This means this won't work in node or in getStaticProps functions or so
api-store
api-types
api-related types needed for the api operation
asset-functions-js
Please set a description for this operation in OPERATION.md
This is a js operation. This means you cannot use any react or node, it's pure typescript, compiled to javascript, and can be used anywhere.
asset-functions-node
asset-input
This component lets you easily add asset input that includes upload with the typerepo
server standard (function-server
)
Add the css to your web project: import "asset-input/css.css";
asset-type
All types related to asset upload
asset-view
AssetView
shows an asset. Every file-format has a different way to be rendered.
augmented-word-node
augmented-word-types
auth-types
authentication
big-button
breadcrumbs
frontend component to show a file location in a nice way (breadcrumbs)
bundle-types
bundle-util
cleanup-typescript-database
Collection of functions to cleanup the typescript database (all typescript related models)
clickable-icon
code-types
collect-static-assets
comment-util
compile-typescript
context-menu
convert-case
cool-toast
csv-util
database
db-crud
db-recipes
Useful library of functions that wrap the fs-orm database.
TODO: should probably be split up further to differentiate between db-ui functions and a more general purpose library
db-util
encrypt-password
explore-project
explore-project explores the whole OS or project, so information about the project can be shown in a UI or used in another way
fancy-loader
ffmpeg-util
file-search
Exposes functions to easily create a file-search menu in your react-app
filename-conventions
Any functions and variables related to filename conventions
find-all-dependency-operations
folder-get-updated-at
Get last updated file updatedAt time in whole folder, recursively
frontmatter-util
fs-orm
ORM that lets you create a database with models that are stored on the file system in multiple formats that are easy to understand and well structured.
fs-util
General purpose wrapper around node:fs
and node:path
that should be used instead of those, because it removes some of its painpoints, removes unneeded stuff, and adds some other useful functions.
fs-util-js
function-context-type
function-form
Component that lets you easily create a frontend form for any function in your project (both backend and frontend functions)
function-functions-node
function-server-types
function-types
generate-index
geo-types
get-imported-dependencies
get-imports-exports
get-package-json
get-package-source-paths
Returns an array of absolute file paths of (typescript) files in the src of your operation
get-path
Useful functions to get paths within King OS.
Depends on sdk-operations, which makes it only work inside of a typerepo.
get-ts-config
Gets the TsConfig given a path to an operation
hotkeys
Operation exposing any utility function related to hotkeys in the browser
index-typescript
This repo is used to generate the typescript index.
Some important conventions I'm applying:
-
The generated index doesn't know the absolute location, which makes it possible to move around the Project in the OS
-
The generated index only tells you information about this very operation. All links with other operations should be done in postprocessing
-
Every generated index has an
IndexId
js-util
json-util
k-explore
exploration functions for exploring files within King OS
Currently has a thin dependency on get-path, but this can probably be removed to make this operation more general purpose (and work outside of King OS too)
k-test
key-value-markdown-js
labeled-button
language-types
layout
lint
log
Log a message with a special type
make-test
markdown
this uses react-markdown
to render markdown in the browser with react...
This is a ui-esm operation. This means it's a ui operation that builds to javascript with ESM module resolving... It was based on this example: https://prateeksurana.me/blog/react-library-with-typescript/
markdown-parse-js
js-only operation containing all kinds of functions that help parsing markdown
markdown-parsings
markdown-reader-functions
markdown-reader-functions-js
markdown-reader-types
markdown-types
marked-util
matter-types
measure-performance
menu
minify-build
model-types
name-conventions
Any functions and variables related to variable declaration naming conventions
nested-menu
nested-menu-types
next-a-link
next-types
one-by-one
operation-util
Operation with utility functions to calculate things about operations and alter operation-index.
parse-primitive
path-util
Gets insightful information about any file or folder (path)
peer-types
persona-functions-node
pluralize
KISS; fuck grammar
If we are going to apply grammar here, it becomes impossible to create typescript rules that can detect and convert plural/singular parameter names.
To pluralize any word we simply attach an "s" at the end
port-conventions
Any functions and variables related to port conventions
prompt-components
react-with-native-form-asset-input
Please set a description for this operation in OPERATION.md
read-csv-file
read-json-file
read-kvmd-file
read-markdown-file
read-typescript-file
reader-ui
rebuild-operation
Operation that makes it possible to rebuild an operation (re-index, re-build, etc.)
recursive-types
recursive-util
rest-util
run-child-process
say
Operation that contains multiple functions that wrap the say cli on MacOS to let the device speak out text.
Can later be extended to wrap other clis or even api's.
Should also be extended to work on multiple operating systems.
schema-util
It's hard to work with them if you don't know what means what. In this operation I'll summarize everything and give examples.
server-api-url
Operation that exports the api url that the api should be able to be found at, according to the users environment, the typerepo convention and your public environment variables.
server-login
This operation exposes rudimentary functions to set cookies from the backend. We require cookies in order to authenticate a user for GET requests. Cookies are sent to the server for every request and are a safer way, because they are not part of the URL that can be found in the browser history.
This thing is far from finished, see todo/
for what needs to be done.
set-json-key
Useful functions to alter JSON files (can be used both with node or with a CLI)
share
short-markdown-parser-js
short-markdown-parser-node
short-markdown-types
short-markdown-writer-input
simplified-schema-form
component that generates a form using react-with-native and a SimplifiedSchema. Can obtain any JSON object from the user.
sms
social-media-types
I want a type interface collection that is able to collect all data from all social networks and put them together.
string-to-json
Parser functions to parse strings (that can be inputted in the command-line) into objects (that can be read in functions)
text-or-binary
This operation provides handy functions to check whether the contents of a file are of a text or binary format...
This is a js operation. This means you cannot use any react or node, it's pure typescript, compiled to javascript, and can be used anywhere.
todo-types
types related to the upcoming todo-ui
This is a js operation. This means you cannot use any react or node, it's pure typescript, compiled to javascript, and can be used anywhere.
tooltip
Please set a description for this operation in OPERATION.md
try-parse-json
ts-morph-util
ui-util
use-on-screen
watch-types
webpage-types
write-to-assets
Function to write anything to assets.
writer-functions
writer-input
component to create a writer input
This is a ui-esm operation. This means it's a ui operation that builds to javascript with ESM module resolving... It was based on this example: https://prateeksurana.me/blog/react-library-with-typescript/
writer-types
getStaticPaths
getStaticProps
progress
queryClient
A
ActivityIndicator
Aside
Button
Div
Form
Form is just a html form on web. On react-native, it's a View
getTailwindModules
H2
I
Image
Input
joinClassNames
Label
Li
Nav
Ol
P
Pressable
button on web, pressable on react-native
PureAside
PureDiv
PureNav
Select
renders either a SelectDropdown or SelectDrawer, based on screensize
Span
Strong
Svg
TextArea
Text
if there is a data model with just a single text and it is clear from the name of the model what it should be, better call it either text or markdown.
Toggle
TouchableOpacity
button on web, pressable on react-native
trimClassName
in react-native not all classNames are supported
Ul
wrapInTextIfNeeded
NB: figure out a way to do the styles of the text right.
AlertContext
AlertProvider
useAlert
DataForm
DefaultInputContainer
DefaultTitle
errorOnField
getPlugin
GLOBAL_PROPERTY_PATH
inputClassWithoutWidth
isWeb
makeInputField
sameFieldArray
setConfig
castToNumber
DateInput
CSS Modules, react-datepicker-cssmodules.css
DatetimeInput
defaultLatidue
defaultLongitude
defaultZoom
FileInput
isNumber
LabelsInput
MapInput
NumberInput
PasswordInput
PhoneInput
SelectInput
SelectMultipleInput
StarsInput
TextAreaInput
TextInput
TimeInput
CSS Modules, react-datepicker-cssmodules.css
ToggleInput
ModalContext
ModalProvider
{ Provider }
useModalState
useModal
ToastContainer
toast
title is only shown on native
useRouter
getRealValue
useSelectMultiple
Create a value selector in a single line of code, including its state!
useSelect
Create a value selector in a single line of code, including its state!
const [SelectView, view, setView] = useSelect(views);
contextKey
contexts
createStoreProvider
Function to create the StoreProvider
NB: this function uses a local variable on the main scope of javascript in order to create the Context components dynamically. Beware!
createStore
One function is all you need to make a new store!
Example:
import { createStore } from "react-with-native-store";
import { TypeA, TypeB } from "your-types";
export const writerInitialValues: {
itemA: TypeA;
itemB: TypeB;
} = {
itemA: "",
itemB: {},
};
export const { useStore, StoreProvider } = createStore(writerInitialValues);
Simple as pie 🍰
createUseStore
Function to create a hook for accessing the store
debug
getContext
Gets the current word you are typing from a text and the cursor position.
Takes into account multiple word separators: tabs, newlines, and spaces.
getItem
If you don't have access to the useStore
hook, maybe because you're doing something outside of react... you can directly use the storage with javascript using this function
getKey
setItem
If you don't have access to the useStore
hook, maybe because you're doing something outside of react... you can directly use the storage with javascript using this function
BEWARE! Updating this won't update your react components!
StoreContextProvider
getColumns
gets all columns you can present based on a modelname, the interfaces of that model, and the data
renderColumn
Skeleton
TableHeadItem
TableRow
Table
tdClassName
bareInputClass
inputClass
UI
useCustomUrlStore
Hook to store simple data in the URL
I spent the last 4 hours on this: I think it's pretty useful. It's a hook that makes it possible to use your URL as a state store. It works with arrays and single values of strings, booleans and numbers. It's a drop in replacement of useStore or useState. The advantage is that the user can share the URL which will also share their state. Usage in a component looks like this:
const [name, setName] = useUrl("name");
I was looking for ways to make the api more straightforward, especially the stuff in useUrl seems a bit messy. However, I couldn't find any way to make it better. Any tips are welcome!
TODO: make it work in react-native as well, either via a wrapper around useStore or via using the react-navigation param-store
import {useCustomUrlStore}from "use-url-store";
export const useUrl = <T extends keyof typeof queryStore>(queryKey: T) => {
const queryStore = {
"type-index-type": useCustomUrlStore<string | undefined>("type-index-type", {
type: "string",
}),
"has-comment-types": useCustomUrlStore<string[]>("has-comment-types", {
type: "string",
isArray: true,
}),
"interface-is-db-model": useCustomUrlStore<boolean>("interface-is-db-model", {
type: "boolean",
}),
path: useCustomUrlStore<string | undefined>("path", { type: "string" }),
name: useCustomUrlStore<string | undefined>("name", { type: "string" }),
type: useCustomUrlStore<string | undefined>("type", { type: "string" }),
};
return queryStore[queryKey];
};
controlChatGptCli
controlChatGpt
getContextualPromptResults
Gets all contextualPromptResults, but only if specific things are true
TODO:
- For any prompt we have for this filetype: get it from the database
- For prompts about a folder: path/to/folder/.index/prompt-results.json
- For prompts about a file or a selection thereof: path/to/folder/.index/[filename]/prompt-results.json
NB: the slug of the ones in index should be the ID, and does not need to be set by the user, because we cannot guarantee that it's no duplicate.
getContextualPrompt
getContextualPromptsArray
Wrapper around the database to support the usecase of storing a file in a custom location for contextualPrompts.
getContextualPrompts
Returns all contextual prompts for the selection and for the page with the right context type
getFolderRelativeScopeDbFilePath
Function to centralise the convention of the db file location of a scoped prompt
processChatGptPrompt
allOperationsRemoveJsSrc
BEWARE! This removes all .d.ts, .js, and .d.ts.map files in your source folder!
allOperationsToMarkdown
clearAllTsDatabases
codeAll
opens all files in vscode
[debug]
[folderName, basePath]
forAllFiles
executes a command or callback for every file
in commands, $LOCATION is provided as env variable, and command is executed in the dir of the file
forAllFolders
executes a command or callback in every folder of a certain type. Supports git repos and operations now
getAllOperationClassifications
gitShipAllRepos
gitShipAllPackages
Just ships code everywhere to github, wherever there's a git folder and there are changes.
mdAllOperations
minifyAllOperations
minify all operations everywhere. optionally:
- enable the shell
- specify a basepath (tools by default)
publishAllOperations
Script to publish all packages everywhere (that also runs prepublish). Only src in git, only build in npm.
removeAllFiles
removes all files that have an exact match of the location (folders not because we use rm without -rf)
removeAllFoldersCli
removeAllFolders
removeAll
removes all xyz for a folder
make sure to specify which type you want.... folder or file most likely
renameAll
renames all files to a new name (optionally a func, based on the old path)
runScriptEverywhere
runs a package script in all tools operations
NB: uses npm insead of yarn, but for scripts this shouldn't matter
[script, startIndex]
[search]
setScriptEverywhere
set package.json script to another value in all operations in tools folder
test
[type, command, fileName, basePath, folderName, shellString]
API_NO_RESPONSE_TIME_KEY
apiWithConfig
This object contains a api function for every function in the backend
The difference from api is that it allows you to also insert custom api configurations
AUTH_TOKEN_STORAGE_KEY
fn1
There is probably some doc-comments available for the function, maybe we can fix this with proxies to pass those comments... that would be insane.
fn2
fn3
getGetApiUrl
gets an api url for a context get api
returns something like [apiUrl]/[apiFunctionName][queryString]
queries
This object contains a react-query useQuery
hook for every api function
sdkExample
untypedApiFunction
Used for calling the actual api for a function with some config
NB: this is not a typed function as we are just overwriting it so we don't need any inference on this
apiStoreInitialValues
{ StoreProvider, useStore }
apiConventions
API conventions:
xyzGetApi
is only available via GET, the rest is only available with POST.xyzWithContext
is taking FunctionContext as its first parameterxyzWithContextRaw
is taking FunctionContext as its first parameter, and is expected to return the raw return type the function returns.
contextFunctionConventionSuffix
getFunctionConventionSuffix
rawFunctionConventionSuffix
addToken
If previousToken is not present, will be generated randomly
ensureToken
Remove the token (if present), then add it again
findAssetParametersRecursively
Recursively finds all asset parameters in an object (for example in a database model item)
getAssetDirectlyApiUrl
getConversionInfoFromType
Received files contain a "type" like "audio/mp3" or "image/jpeg", etc...
Here the extension is decided.
NB: we also need to convert the file itself in case of mp3
getExtensionFromAsset
Returns a preliminary filename, based on the Asset
getNameFromRelativePath
getNameWithTokenFromRelativePath
first gets the name from the relativePath
then ensures the token is attached (if not already there)
getReferencedAssetApiUrl
getTypeFromUrlOrPath
We are assuming the asset name and extsion appear at the end of the URL
readableSize
removeTokenIfPresent
tokenPrefix
NB: any filename should not be expected to enter this as part of its name. Otherwise it breaks the code and the filename will be changed to the thing before this string.
NB: don't put any things inhere that are different, slugified, as the name will be slugified!
compressAsset
Audio, image, video can be compressed. This should be done to logical defaults, can be turned off, or can be specifically set to other dimensions using a doc-comment on the model.
- audio: bitrate
- video: fps and resolution
- image: resolution
Returns the new absolute path of the compressed asset (which can be the same as the initial path)
deleteReferencedAsset
downloadRemoteAsset
Download a remote asset to the assets
folder (temporary location)
used for:
- giphy
- google images
- unsplashed
- p2p
- youtube to mp3 picker
- youtube to mp4 picker
- project assets (via api)
findAbsoluteAssetPathFromReference
findAllProjectMedia
Media:png, mp4, mp3, zip, pdf
- finds all media in all
db
folders. Can be anywhere, so an explore will probably be best. - finds all media in every operation in any folder except for
node_modules
,db
,src
,build
, [anything]. (so mostly intodo
,docs
andassets
) - find all media in every other folder that is not an operation
Return all of this as project relative path array
getAssetDirectlyGetApi
Useful for getting assets directly, for example for the SelectMedia
component for project
-media
Requires more access rights
getReferencedAssetGetApi
Function to get a referenced asset that has been referenced from any db-model or any ts, tsx or md file, anywhere in the project.
Assets should only be exposed if you have access to the model they are referenced in or to the md file they are referenced in.
Exposes all assets like /asset?path=/text/interests/programming/storage-of-data/best-storage-methods.md&asset=./audio-is-amazing.m4a
Assets are only exposed if they are referenced in a markdown file that is accessible to the user. So when looking up the asset, make sure there's a link to it via []()
or ![]()
in the markdown that is connected to it in the URL. If not, don't expose it!
This can be used for any ui that has the functions backend available.
The advantage is that we don't need to build it, this works in dev
mode. there is no asset duplication.
since the name is getReferencedAssetGetApi this should be exposed on getReferencedAsset
IMPLEMENTATION NOW:
-
check referencing file to find the reference.
-
for markdown, typescript:
](./xyz)
-
for json:
"relativePath": "./xyz"
-
If this occurs, calculate abosolute asset path from referencing file folder + relative path
-
If this asset exists, expose it.
getStorageLocationInfo
returns the type of file the asset is referenced from, and the baseFolderPath
where the asset
should be stored
getTemporaryAssetsFolderPath
mediaExtensions
processAsset
Processes an asset by moving the file in the right location, if needed...
- Alt is kept, nothing to do with it
- Giving a different name will change the new path
- relativePath is checked if it exists (if temporaryDestination is undefined). It is used to obtain the extension.
- temporaryDestination must be checked. if it exists, must replace the file on relativePath calculated from name
After processing, this function should return a BackendAsset without the non-storable parameters
BEWARE: absoluteReferencingFilePath
, and for db-models also modelName
, need to be given here! Otherwise this won't work!
processItemAssets
processes all assets in an item and returns the new item
removeOldTemporaryAssets
All temporary assets that were created more than 24 hours ago and are still there, will be removed by this function.
This allows us to easily delete assets without concequences and also if the user closes a form without submitting it, these assets uploaded will go away.
This function should be executed using a daily CRON
serverDownloadReply
Returns a server.reply.download
or server.reply.file
but also sets the Content-Disposition
header correctly and the Content-Type
For this I finally ended up using builtin server.js stuff, we don't need to set those manually...
See https://serverjs.io/documentation/reply/#file- And https://serverjs.io/documentation/reply/#download-
See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition
NB: ensure to return the result of this function in your endpoint, otherwise it won't work
uploadAssetWithContext
Uploads an asset to the server, and puts it in a temporary location in the assets folder of function-server
. It returns the filename of the file in the temporary location.
It can only be accessed through that random name. This random name has 32 characters so cannot be easily guessed. This should be secure enough. The file should be moved to the final destination in the actual function that needs the file.
NB: this function only works by providing a file as blobs under the "file" property name!
ASPECT_RATIO
AssetInput
Audio
base64UrltoBlob
Taken from https://github.com/mozmorris/react-webcam/issues/65#issuecomment-385126201
There are probably much better solutions
getTypeFromFileBlob
HEIGHT
makeBackendAsset
MediaRecorderComponent
MediaRecorder
ReactMediaRecorder
SelectMedia
videoConstraints
VideoPreview
Video
WebcamCapture
WIDTH
AssetView
defaultClassName
getSrc
InteractiveAsset
shows an Asset with interactivity
- Any file shows the name of the file, the size, and a link to open it in a new tab in the browser
- Images show thumbnail
- Audio show duration and amplitude
- Video/screen show thumbnail and duration
itemGetBackendAssetUrl
Get remote url for a BackendAsset in an AugmentedAnyModelType
database model item.
If you provide an array it'll take the first asset.
ModelItemAssetView
useAssetInfo
useAsset
cache
getAugmentedWordObject
getAugmentedWords
Gets all augmented words of the entire project
- words with their definitions, if available (
/dictionary?word=x
) - functions, interfaces, variables, operations (
/[operation-path]#name
) - if this is an OS-project, also bundles (
/[docs-path]
)
getBundleAugmentedWords
NB: should only be executed if this is not a sensible-project, as it might not have BundleConfig otherwise
AuthenticationMethodsCrud
LoginForm
LoginWrapper
ensures the auth-token is set
MeAuthenticationInfo
little component for in banner that shows your info on top, and links to signup/login etc
PersonProfileDetailsForm
PictureWithInfoDropdown
Dumb (presentational) component for a picture with info and a dropdown
PublicPersonComponent
PublicProfile
SignupForm
UpdateMeForm
BigButton
BreadCrumbs
Shows where we are in the filesystem
renderBreadCrumbs
getBundleSummary
Summarizes a bundle config so it can be used easily in things like explore project
getDbModelsForBundle
Gets all TsInterface's that are used in a bundle according to a BundleConfig
cleanupTsDatabase
From all Ts Index Models, removes the instances that refer to a ts file that doesn't exist anymore in the operation.
shouldDeleteTsModel
ClickableIcon
Renders a simple clickable icon with some styling
Icon can be either an icon (Svg src) or emoji (string)
abc
commentTypesConst
commentTypes
contentTypeConst
Improves the convention for parameter names that refer to models. probably it's better to do this: slug/id/index
are reserved on every model, let's call them "Ref". modelNameRef
refers to modelName. But what if you want to call it differently? Then you'd need to distinguish a prefix from the modelName. Let's do this with a underscore (no dash because underscore preserves ability to dotting on the object). If you want a reference to a user be called author, you'd name it author_userSlug
.
TODO: reduce all TsInterfaces and functions into their parameters :D
datasetConfigKeys
datasetFilterOperatorConst
NB: keys are made humanCase
and used in UI, so keep a readable name
dbStorageMethodsConst
dbStorageMethods
getExamples
getFunctionExersize
indexDbModelFolders
indexDbModels
All type interfaces that are used to index stuff, which are added to the database
NB: It's not handy to get this from the database because this is used to generate the database xD
modelViews
operationClassificationConst
runEveryPeriodReadonlyArray
runEveryPeriodStringArray
typescriptIndexModels
copyCopyPairs
copyReaderStaticAssets
findReaderStaticAssets
markdown-renderer turns a relative link into this: ?mdpath=x&relativePath=y
for static, we need to turn it into something similar, but we need to guarantee no file collisions. simple!
we can just take the project-relative file path of the asset, and put it in /public/images in next.js. the final url of the asset in public next.js then becomes images/[path/to/asset.jpg]
findStaticAssets
Returns the absolute paths of all static assets (embeds and links) in a markdown file of which the path is provided.
stripCommentEnd
only strip slahes for single-line comments
stripCommentStart
stripComment
parses comments (single line, multiline and doc) and removes the comment syntax
- removes slashes
- removes multiline comment prefix
- removes multiline comment suffix
- removes doccomment stars
example input: // comment
, output: comment
example input:
some
multiline
comment *~/
output:
some
multiline
comment
stripSlashes
stripStar
trimSurroundingNewlines
removes new lines at beginning and end
NB: This function uses a small recursion! I don't know if this is very efficient, but shouldn't be too deep!
NB: it should be noted that a newline apparently seems to be counting as a single character! Strange.
trim
getCompileErrors
gets compileErrors of an operation. if it has no errors, it also check all dependants to see if they have errors, possibly because we changed this one
- get buildErrors for all src files of current operation
- if build doesn't succeed, only check for build errors in current operation
- if build succeeds, check iffor build errors in all files in all operations that depend on this one. this means we need compile to be ran for every operation
TODO: Later, only check all build errors of all dependants if and only if an export blueprint (io) has changed and if this export was imported there
[ operationBasePath, operationManualProjectRoot, typerepoManualProjectRoot, ]
writeBuildErrors
ContextMenuItemComponent
useContextMenu
Use this if you want to render a context menu where the menu closes if you click one of the items.
Optionally, you can create a custom renderer for it.
useContextPopper
Use this hook if you want to create your own custom render that opens on the right location once the onContextMenu is fired.
useContext
Use this if you want to create a completely custom behavior from a context action. On top of the default onContextMenu behavior, this hook enables the possibility for a custom hold duration on mobile.
camelCase
capitalCase
capitaliseFirstLetter
convertCase
convertToTargetCasing
getDelimiter
humanCase
kebabCase
lowerCaseArray
converts any string to an array of lowercase words
format ["word1","word2","word3"] from a string of any casing.
nonCasingDelimiters
pascalCase
snakeCase
splitCasingDelimiters
errorToast
infoToast
showStandardResponse
Useful to show if the api has a standard response
successToast
warningToast
csvItemArrayToCsvString
make csv string from a csv model type
exampleCsvItems
the same as exampleCsvString
exampleCsvString__OLD
exampleCsvString
exuivalent to exampleCsvItems
tryParseCsv
This function parses a CSV into the object it says it has in the header
dbConfig
db
generateCsvInstance
generateJsonSingleInstance
generateKvmdInstance
generateMarkdownInstance
generateSlugTestModel
getCli
getMergedQueryConfig
getRanomAge
get
main
migration
randomName
removeCli
runModelEndToEndTest
NB: we can't do a maketest because this thing relies on logging and we don't want to auto-run it
set
Can set a markdown item into a subfolder in the db model folder
testDb
a db is created with models from all different db storage methods
testOperationModels
Test if it can find all OperationIndex
, OperationConfig
, PackageJson
, TsConfig
testPerformance
updateCli
upsertCli
upsert
Takes stored data and an item
- updates the data and sets some rows to "item" if the item is found (through the id or slug)
- otherwise inserts
NB: this function works for any storage method except for key value markdown
CrudGrid
CrudTable
CrudTimeline
CrudTree
DatasetForm
dbCrudInitialValues
DbPage
defaultLimit
{ deleteDbModel }
{ getDbModel }
getPropertiesDataParameterNames
IndexInstanceContainer
container for any index instance that needs to be rendered in the explore page
ModelComponent
In the table headings, all xxxSlug, xxxId etc should be called xxx.
In the table values, all slugs and ids should show the name of the instance of the refered model.
It has to be possible to navigate to an id or slug using #[id] or #[slug]
in the URL, just add div ids to all rows
openWhatsapp
SearchBar
shimmer
SimplifiedSchemaFormDebug
sortToItem
SpaceCard
toBase64
{ upsertDbModel }
UpsertForm
TODO: Provide all the fetched data with hasMore
and fetchAll
to the SimplifiedJsonForm
UpsertPage
useInfiniteGetDbModel
useModelFromUrl
takes the model from the url
useUrl
cacheLookup
Wrapper function to cache any function and invalidate it, in some way
caching automatic cache invalidation if data sources are updated optimistic caching after cache invalidation
calculateOperatingSystemBundle
This function should calculate a giant bundle for the whole operating system. This should include everything, public.
Used to show the whole os as a bundle.
deleteDbModel
deletes an instance of an db data interface from the db in a typesafe way
functions
getCachedFunctions
TODO: it would probably be good to create a more general purpose caching function
getDatabaseMenu
Finds all relevant Db models to show in the menu
- for a bundleId, it gets all models from the bundleSummary
- for a bundled project (bundled) gets all models from the packages
- for the main project, gets all models from sdk-db directly
TODO: NB: the first and the second are not the same, so this needs to be cleaned up.
getDbModelMetadata
getDbModelNames
getDbModel
gets all instances of an db data interface from the db in a typesafe way
getFunctionIndex
finds function indexation from database
TODO: this should be used!
getNestedDatabaseMenu
TODO: support search for bundles (but this can be augmented word based)
getReferencableModelData
Get referencableModelData for a single DbModel.
NB: this does not get the items that can be referenced in that model!
For getting all required ReferencableModelData
for the prop in SimplifiedSchemaForm, use useGetReferencableModelData
.
hasDbRecipes
Simple function to test whether or not the DbRecipes endpoints are available. If it returns true through the api, the other ones are also available.
makeSrcRelativeFolder
gets a src relative folder path (so maybe "" for a file src/util.ts
or "util" for a file src/util/thing.ts
)
testFnWrapped
testFn
tsInterfaceToDbMenu
upsertDbModel
upserts an instance of an db data interface from the db in a typesafe way
validateInput
wrapper function that takes that data but also the interface of the function and validates the parameters before it executes the function.
validateResult
wrapper function that takes that data but also the interface of the function and validates the parameters before it executes the function.
wrapFunction
filterInterfacesFromOperationNames
getDbModelsFromOperations
comparePassword
Method to check if a raw password should be the same as the encrypted variant. Uses bcrypt
encryptPassword
Method to encrypt any password. Uses bcrypt
exploreOperation
for every package.json it finds, it explores the root, src, and docs.
- in src, index is ignored
- in docs, only md is found
- in the root, only md is found
- for every file in src, it shows and finds all functions, interfaces and variables, through the indexation from it
exploreProject
TODO: still needs to be cleaned up. It's a huge function now with many useful components. Split it up!
- explores all files and folders until it finds a package.json.
all items in the explore tree are clickable in the ui, and lead to different pages
- a folder leads to a summary of what the folder holds
- a operation leads to a summary of the operation
- a ts file leads to all functions, variables, and interfaces in that file
- a function, variable, or interface leads to specific pages for those things. the data, if available, is attached to the interfaces.
- a md file leads to the editing user interface (with context) of that file
- a json file leads to a CRUD for it...
In the end the data it generates should stay up to date, so it's important this exploration happens fast enough. The data involved is simply walking the filesystem once (a small subset of it) and opening some index files (fun)
LATER: some more things that would be useful:
- watching all files that are also explored for changes using some watcher
- if something changes, recalculating that part and pushing it to the UI, making the thing going over the line small so it'll be super fast, even over slow internet.
however, this is premature optimisation. on my m1, locally, it's probably fine to just recalculate every second ^^ and send a couple megabytes over the line.
getExplorationType
gets the exploration type from an absolute type
getFileWithExtension
getFolderExplorationDetails
getFrontmattersMappedObject
getInstanceNames
returns the paths of instances in a file, like functions, variables or interfaces
getProjectRelativePaths
get file paths within your project
getTodoPages
getTodoPages(): WebPage[]
function:
- use getProjectRelativePaths, map the result to a queryPath + file
- [operation-name]/[todo-relative-file-id] for operations
- [folder-name]/[todo-relative-file-id] for todos within folders
getTodoPaths
hasSameProjectPath
function that returns a filter function that can check if some object (that extends an TsIndexModelType) has the same relative file path from the project root
FancyLoader
compressImage
compressImagesCli
compressImages
searches the folder recursively for all images and converts them to webp
convertToMp3
Uses ffmpeg to convert a file to mp3
Returns the new file path on success
convertToMp4
Uses ffmpeg to convert a file to mp3
Returns the new file path on success
MatchingText
Component that highlights the matching text
PathSearchResults
allowedSearchContentExtensions
buildFolderName
databaseFolderName
extensions
fileTypes
frontendOptionalFileSubExtensions
these special operations are generated, so should not be copied, but should be generated in the bundle after everything is copied
generatedFolders
getFileTypeFromPath
getWriterType
Gets the writer type based on the extension
hasSubExtension
Returns true if a fileid includes one of the specified subextensions.
isGeneratedOperationName
isGeneratedOperation
isIndexableFileId
jsonExtensionsConst
jsonExtensions
markdownExtensionsConst
markdownExtensions
operationUnindexableNamesOrSubExtensions
projectRelativeGeneratedOperationsFolder
sourceFolderName
typescriptExtensionsConst
typescriptExtensions
findAllDependencyOperations
to be used when you need to know all dependencies for multiple operation names at once
TODO: NB: this breaks with circular dependencies
findDependantsRecursivelyTest
findDependantsRecursively
findDependants({
operationName: "js-util",
importName: "notEmpty",
returnOperationName: false,
}).then(console.log);
findDependants
getDependencyTree(["k-types", "fs-orm"], []).then((res) =>
console.dir(res, { depth: 999 })
);
finds all dependants of an operation or a specific import from that operation
normally returns the files where the operation or function is used, unless you specify to return the operationNames only.
findDependenciesRecursively
finds all dependencies of an operation name
findMonorepoModules
finds all dependencies of an operation name
getDependencyObject
findAllDependencyOperations(["fs-orm"]).then(console.log);
how do I get a format like this?
const x = {
"fs-orm": ["js-util"],
"js-util": [],
}
getDependencyTree
test2
folderGetUpdatedAt
get last updated file updatedAt time in whole folder, recursively
frontmatterParseToString
Parses frontmatter object into a frontmatter string
frontmatterToObject
getFrontmatterValueString
objectToFrontmatter
parseFrontmatterString
Parse a string as stored in frontmatter back to the original string
quotedOrNot
For now, simply quote a string if it contains commas
There are probably more edgecases that need to be fixed here
stringifyNewlines
addDefaultValues
Adds timestamps, id, and a slug IF these things are not already present
NB: slugs will be slugified here! NB: if there is a name present, slug will be added here!
NB: for kvmd storage, id will be set to a kebab-case of the name
NB: does not add the ModelLocation parameters
alterAny
low level function that alters data from any storage method at a certain location
comprises all dbStorageMethods
alterCsv
Alters a csv
alterJsonMultiple
Alters a json multiple file
alterJsonSingle
Alters a json single file
alterKeyValueMarkdown
alterMarkdown
Alters a markdown file
augmentItemWithReferencedDataRecursively
calculateOperationsObject
relative
Needed in case of manual project root, otherwise use SDK!
Returns project relative operation base paths
categoryStackCalculated
createDb
Create your database by passing your models as a generic and some optional configuration
findParent
this location matches any category that equals the categorystack
getAugmentedData
Gets the stored data from any file with any storage method, and augments the modelLocation onto it...
Also augments the name
, slug
and categoryStackCalculated
onto this if the dbStorageMethod
is markdown or jsonSingle
and if operationRelativePath
is not set
getDatabaseFiles
This function gets the files that the data can be stored, by convention, based on the model and the config
Only returns the file paths that actually exist.
CONVENTION:
When searching for data, fs-orm will look in:
db/
in your project rootdb/
in any operation
In these folders, fs-orm will search for files based on your storage method. @see DbStorageMethod for more info
Returns not only the file paths, but also where they were found (operationName, projectRelativePath, operationRelativePath
)
getDatabaseRootFolder
Tries to get the root folder where the database folder can be found.
If an operationName is specified, this will be the operation base path If not, this will be the project root.
getDbFileLocation
Used by groupByFile, which is used for set (and thus, also update
) and upsert: determines the new file location.
Applies the convention to get the db-file-location of an item
Based on the merged config:
- if
operationRelativePath
is specified, gets a filePath in the operation - if
projectRelativePath
is specified, gets a filepath in the project - otherwise gets the pattern and replaces "*" with the slug (or id if slug is not available)
Besides the absolute path, the operationName, projectRelativePath and operationRelativePath are also supplied.
NB: currently, the item's operationName
, operationRelativePath
or projectRelativePath
is not taken into account. It will simply look at the convention to see where it should be saved, and apply the MergedQueryConfig...
getDbStorageMethodExtension
getDefaultLocationPattern
DB main storage convention
getItemModelLocation
getLength
Safely gets the length of something
getLocationPattern
Returns the pattern or an exact relative path that the file(s) should be stored at.
If a pattern contains a star at the place of the filename, it will search the folder recursively for all files with the extension in the pattern.
Returning relative path has no preceding slash
getMergedConfigOperationPath
NB: returns 3 things:
- false: no operation path
- undefined: operation path undefined
- path: the specific operation path
getParentSlug
get a parent slug without the parent_xxxSlug reference (uses the categoryStackCalculated)
can be undefined if the item has no parent
getRootFolders
Gets all root folders where db folders can be located inside of
NB: Before november '22, this function is quite slow if it needs to find all operation folders becuase this takes at least 60ms.
getWildcardDbFileLocations__OLD
If it all seems good, I can delete this. This is the old method of looking just in the folder itself, it's replaced by looking in all subfolders as well, recursively.
getWildcardDbFileLocations
groupByFile
makeStoringItem
Three things need to happen in order to store an item
- keys that can be inferred from the file path are omitted
- referenced data is omitted
- calculated data is omitted
maxConcurrency
Crashes for upsert at 1024 on m2. It would be good to find a way to ensure we never crash here, or at least report where the out of memory bug came from.
maxQueryTimeSeconds
mergeConfigs
removeKeyValueMarkdown
Takes stored data and a slug to remove
removeMultiple
Function that lets you remove items from one specific file, for any storage method
upsertItems
upsert an item into storage in any storage method
upsertKeyValueMarkdown
Takes stored data and an item
-
updates the data and sets some rows to "item" if the item is found (through the slug). this works almost the same as the regular upsert function
-
otherwise inserts, at the right category, in the right place in the array
BEWARE:
- the categoryStackCalculated must be existing in the markdownfile.
- you cannot insert a header, always insert an item with
isHeaderCalculated:false
waitForLockfile
access
appendFile
canAccessSync
uses fs.access to determine if something can be accessed
Check File access constants for possible values of mode. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g. fs.constants.W_OK | fs.constants.R_OK).
canAccess
uses fs.access to determine if something can be accessed
Check File access constants for possible values of mode. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g. fs.constants.W_OK | fs.constants.R_OK).
canExecuteSync
File is executable to the calling process
canExecute
File is executable to the calling process
canReadSync
File is readable to the calling process
canRead
File is readable to the calling process
canSeeSync
File is visible to the calling process
canSee
File is visible to the calling process
canWriteSync
File is writable to the calling process
canWrite
File is writable to the calling process
chmod
chown
copyAllRelativeFiles
copy a bunch of relative files from one root folder to another
copyFile
cp
findFileNameCaseInsensitive
returns a path of a fileName
fsPromises
fs
NB: for some reason some of the graceful-fs functions aren't complete. For example, I can't seem to copy folders with cp from graceful-fs (cp)
For that one I added cpAsync.
getAllFoldersUntilFolder
NB: I already have this somewhere else but couldn't find it!
If the path is /a/random/path
The result of this function will be:
['/a', '/a/random', '/a/random/path']
getFileName
removes everything before the last slash to get file name
getFirstAvailableFilename
getFolderSizeObject
returns an object with all sizes of all folders and files, recursively
getFolderSize
getFolder
if the path exists:
- if the pathString is a folder, that is returned.
- if the pathstring is not a folder, returns the pathstring without the file suffix
if the path doesn't exist: returns pathString witout last chunk (this would only work for file paths)
getLastFolder
removes everything after the last slash to get folder path
input: /Users/king/Documents/some/folder/xyz output: xyz
input: /Users/king/Documents/some/folder/xyz.txt output: folder
getOneFolderUpPath
Takes a folder path and returns a path that is one folder up
getPathCombinations
gets combinations for paths
input: [["operation1","operation2"], "db/value-export", ["index.ts","test.ts","cli.ts"]] output: ["operation1/db/value-export/index.ts","operation2/db/value-export/index.ts","operation1/db/value-export/test.ts","operation2/db/value-export/test.ts","operation1/db/value-export/cli.ts","operation2/db/value-export/cli.ts"]
gracefulFsConstants
gracefulFsPromises
mkdir
oneUp
Finds the number at the end of a filename and increases it If there is no number yet, concatenates '1' to a string
E.g.
hello-world
becomeshello-world1
hello36
becomeshello37
parseMd
DEPRECATED: just use md-to-json-parse
parse a md file to all the needed info @param mdFilePath path to a md file @returns Md
path
readFileSync
readFile
readdirSync
readdir
realpath
removeAllExcept
Removes everything inside a folder except some files and folders that can, optionally, be ignored for removal. does not remove the folder itself
NB: make this work with subdirectories!
renameAndCreate
rename
rm
stat
watch
writeFileSync
writeFile
writeJsonToFile
write json to a file
makes the dir and file if they don't exist
writeStringToFile
write string to a file
makes the dir and file if they don't exist
writeToFiles
writes all values in an object to the file that should be specified as key of that value
getExtension
returns the extension of the filename or path WITHOUT dot
NB: not sure, but could be nice to replace this with path.extname(pathString)
getFileOrFolderName
getFolderJs
getSubExtension
Provide a filename including its extension, to get the subextension.
isPathRelative
join
removeTrailingSlash
withoutExtension
removes extension from the filename
FunctionForm
FunctionForm is a very easy way to create a frontend component that is connected with an api that is connected with a function on your backend (that can do anything)
All you need to provide is a TsFunction
This component only works if your api is up-to-date and your function is succesfully indexed using typerepo
. For authentication, the api convention is used. See the api docs.
@see TsFunction
getFunctionExecutions
getFunctionQueryPaths
Calculate all required query paths for the function UI menu...
- bundles + main project as root folders (
["main project", ...bundleNames]
) - per folder all operations it contains, nested, in the project relative folder where it should be ending up
- per operation all functions it contains, nested, relative to the src folder. not file, only folders should become menu
Example:
- main
- modules
- packages
- db-ui
- components
<IndexInstanceContainer>
<Layout>
<UpsertForm>
- hooks
useGetDbModelQuery
useReferencableModelDataQuery
- pages
- Page
- Page
- Page
- getPageTitle
- generated
- himalayajeep-functions
- apps
- bundle A
- bundle B
NB: if possible, rename the menu items if the items in a folder are not unique (use file-name to replace item name if this happens)
getPublicBundleConfig
getSrcRelativeFolderPath
getTsFunction
generateNamedIndex
Generates an index.ts file based on named statements in the operation. Also generates test array. Not used currently.
NB: This overwrites the indexfile of the operation in the src folder! Make sure you don't have anything there still.. All functions should be in other filenames.
Should be ran every time an operation changes
generateSimpleIndex
generates operation index and writes it to index.ts in src of the operation.
NB: This overwrites the indexfile of the operation in the src folder! Make sure you don't have anything there still.. All functions should be in other filenames.
Should be ran every time an operation changes
isTestFn
mapToImportStatement
[operationName]
getImportedDependencies
DEPRECATED: should use generated index files with imports instead!
gets all imported packages (dependencies) in a project doesn't take into account the fact that someone can set up a rule for absolute imports within the package. this assumes that any absolute package comes from node_modules.
getPackage
only the first part
isAbsoluteImport
calculatePackageJsonDependencies
Calculates new packageJson dependencies object based on imports found in the whole operation.
For monorepo modules, uses the version inside its packagejson (Uses the database to obtain the package.json)
Generated packages are not added to dependencies. Instead a config is added saying this operation only works within a monorepo since it has generated operation deps that are not on the npm registry
For external modules, uses the version that was already present in dependencies, or uses "*"
Also keeps the dependencies that were already there, nothing is removed.
CONCURRENTLY_INDEXED_FILES_AMOUNT
findAndWriteImportsExports
takes an operation base path and finds all imports and exports in all the files, and writes it to the ts-imports/ts-exports indexes
NB: has a side effect: it also updates the package.json to include all needed dependencies.
getDefaultSymbolType
gets type of a symbol and if the type has a generic, without recursing.
getExportSpecifierNames
getExportSymbolTypeRecursive
gets type of exportSymbols. recurses if it's an exportsymbol
TODO: NB: exports that come from a destructured initialiser aren't found! fix it
getImportSpecifiersWithNames
get the ImportSpecifier(s) of with a certain name.
getImportsExportsTest
getImportsExports
Uses ts-morph to get all exports inside all files in a project or an array of source files. Doesn't use index, it actually looks in all files except index, so some of them may not be exported from the package itself depending on your indexing strategy!
NB: uses a lot of memory!
#performance
getPackageNameFromAbsoluteImport
parses the absolute import name into the actual package name
- removes internal navigation in the package (everything after the package name)
- assumes packages don't have slashes in their names, execpt that it takes into account scoped packages (e.g.
@company/package
) - removes things that come before any column (
:
) e.g.node:fs
becomes fs
getSymbolDeclarationsOfKind
getSymbolTypeDeclarations
getTypeFromImportSpecifierRecursive
Recursive function that gets the type specifier from an import specifier
isAbsoluteImportBuiltin
returns true if the absolute import is built in into node
isImportFromOptionalFile
returns true if the import was found in an optional file, e.g. this import is not always included in the bundle, so should not be a dependency
isImportGenerated
[operationBasePath, manualProjectRoot]
writeResult
getOperationBins
returns array of bins. by convention, these bins should also be exported from operation index file
getOperationPackageName
getPackageJson
getPackageSourcePaths
Returns an array of absolute file paths of (typescript) files in the src of your operation
TODO: we need a way to explore these glob patterns inside of tsConfig.include. until then, just assume we use "src" as the only folder
findFolderWhereMatch
recursive. goes up a folder until it finds a package.json
findOperationBasePathWithClassification
recursive. goes up until it finds a folder that's an operation
because it had to read the package.json anyway, it's returning the operation classification as well
findOperationBasePath
getAllPackageJsonDependencies
getCommonAncestor
Finds the common ancestor for two absolute pahts
getOperationClassificationObject
getOperationClassification
Returns OperationClassification if it's an operation, or undefined if it's not
NB: don't confuse this with ImportClassification
getOperationPathParse
get all operation-related path information that can be inferred from the path
NB: currently it also looks up the operation name from its packagejson
getOperationPath
Gets a path of any operation in the project
TODO: IDEA: maybe auto-generate key-value JSON where keys are the package-names of all operations and values are paths of their locations in the file system. we can easily generate this ourselves, but maybe it's also easy to use the npm yarn workspace for this, although it may not be available in all circumstances, so better not rely on it. The advantage of this would be that this function becomes sync and is much more efficient. The disadvantage is that every time you move something or add something new, this indexation has to happen, otherwise it fails.
getOperationRelativePath
something like src/xxx/xxx/x.ts (no slash at start)
getPathParse
gets all kinds of information that can be inferred from any path (file or folder).
getPathsWithOperations
returns an array of all (absolute) paths containing operations
for a bundled project, that means /apps, /packages, /modules
for the OS project, that means /operations/tools and /operations/niches
getProjectRoot
returns project root folder path
recursive. goes up until it finds a folder that's the project root
if no source path is given, uses the directory name where the function is executed from as a starting point
getRelativeLinkPath
returns a relative link between two files
getRelativePath
gets the relative path from a specified root
will start with "/"
getRootPath
Gets project path, or a folder in the root that is convention
getSrcRelativeFileId
returns a file id (path without extension) relative to the src folder of an operation
e.g. "general" for src/general.ts
NB: assumes all src is in the src folder
NB: removes "/" in the beginning, if found
hasDependency
hasProjectRootFile
isBundle
isOperation
Checks whether or not an absolute path contains an operation. The only check it's doing is that the folder must contain both a package.json as well as a tsconfig.json
isUiOperation
isWorkspaceRoot
simple sync function to check if a folder is the root of a workspace (not operation but a workspace)
makeRelative
Makes a path relative using proper parsing
Resulting path will apply the paths conventions
- no slash at the end
- no slash at the beginning
osRootFoldersConst
can only be accessed in the OS
osRootFolders
packageCompilesTs
projectRootFoldersConst
can be accessed in projects as well as in the OS
projectRootFolders
tsconfigCompilesEsm
getTsConfig
isAltB
⎇ B
isAltN
isAltO
isAltW
isCtrlBacktick
^ `
isCtrlP
^ P
isCtrlS
^ S
isCtrlSpace
^ `
useHotkey
hook that creates an eventlistener for keydown and cleans it up when needed
useHotkeys
hook that creates an eventlistener for keydown and cleans it up when needed
ajvMap
cli
definitions
findAndUpsertTsInterfaces
findCommentTypes
returns all types that are found as start of a line in the comment (capitalised, with a ":" behind)
generateSchema
If existing schema is not stale, just require it. Otherwise, generate it for a file
NB: The createGenerator
function finds also imported TsInterfaces, which leads to duplicate TsInterfaces. With pushing the interfaces to the slug filename, this is no problem though, there should not be any duplication!
getAllComments
gets all leading comments and trailing comments raw text, put together, separated with newlines
getDbStorageMethod
Gets db storage method for indexation
- Frontmatter overrules everything
- Special extensions are looked at
getFrontmatterDbStorageMethod
if isDbModel is specifically set to false, this will return null (which means this should overwrite other things)
getFrontmatterFunctionParameters
getIndexId
getMaxIndentationDepth
gets the maximum indentation depth of any piece of code
does this simply by splitting up the piece of code into lines and checking the indentation of every line, finding the highest one.
assumes an indentation contains 2 spaces.
getMinMaxValidation
getNumberOfLines
getObjectSchema
getParamSchema
getParametersFromInterfaces
getPossibleRefs
getSizeSummary
gets a size summary for a file path
Does not calculate this for files that are too big (bigger than 1MB)
getSpecialExtensionDbStorageMethod
returns undefined if there is not a special extension. if there is, it returns the dbStorageMethod
getTsStatements
Gets functions and variables from a tsmorph sourcefile
getTypeInfo
takes a ts morph type and returns all info about it
if available, a schema should be provided about the type because it's hard to infer it (probably buggy)
getValidatedOperationPathParse
hasTypescriptFileChanged
indexImportsExportsForFilePath
indexTypescriptFilePath
Index a single typescript file
indexTypescriptFile
indexTypescript
Creates a typescript file index in 3 steps
- Introspects the file
- Calculates all needed information about it
- Saves the result to /db/******.json in the operation root
NB: Build errors are done separately as this is done operation-wide, everything else is done for each file
NB: I don't think this is super efficient, because the project is taken to just index a single file. It's probably better to pass the project and the sourcefile in here, right?
TODO: if a typescript file starst with a comment before any statements (but possibly after the #!/usr/bin/env xyz
statement), this should be indexed as the main file comment... This can be shown when opening the file in the admin... It should also check if there is an associated md file for that in src, so that can also be added in the index.
isPrimitive
export const getDefinitions = () => definitions;
export const getClass = (name) => allClasses[name];
makeTsComment
this is actually a fundamental part of the OS. How should comments be structured?
I think, in general, that we should make it look as much as possible at markdown, because it should always be able to have markdown anyway.
removeTypescriptIndex
schemaToTsInterface
make a tsInterface from a schema generated from the file
symbols
toSnack
tryCreateSchema
Try because sometimes generateSchema fails
typeToSchema
calculates the schema of a type
this is great for types inside of parameters of variables that are not declared separately, however, it's probably not as good as vega's json schema generator... therefore, it would be great to always prefer vega's way above this.
NB: this method throws sometimes if it can't find some stuff, so make sure to try/catch it.
TODO: Test and improve this one
apply
sum([1, 2, 3]);
function that takes an array of functions and applies them one by one, on the value or the result of the previous function. Only possible if the type of the value stays the same.
concatenate
createEnum
const taskNames = ["a","b","c"] as const; type TaskNames = typeof taskNames[number]; const enummm = createEnum(taskNames); (value of enummm: { a: "a", b: "b", c: "c" })
createMappedObject
Creates a MappedObject
of an array of any type. MappedObject
s are great for increasing efficiency to get an item from an array. Especially useful when finds are needed on a specific key match for huge arrays. Instead of finding on the array you can simply get the right property from this object.
NB: Don't use this inside of render functions, it's a very slow function, the whole idea is that this makes it faster, so just do it once!
destructureOptionalObject
Easy way to destructure your object even if it may be undefined
or null
.
Have you ever had a function with an optional configuration parameter, but you want to access all its properties? It's a hassle. This function lets you turn doSomething
into doSomethingBetter
. Check the code.
const doSomething = (config?: { a: string; b: boolean; c: number }) => {
const a = config?.a;
const b = config?.b;
const c = config?.c;
return "something" + a + b + c;
};
const doSomethingBetter = (config?: { a: string; b: boolean; c: number }) => {
const { a, b, c } = destructureOptionalObject(config);
return "something" + a + b + c;
};
findLastIndex
finds the last index of an array where a certain filter holds true
getObjectFromParamsString
useful for cli's that only take strings. This creates an object from a string
input: "x:a, y:b, z:c" output: { x: "a", y: "b", z: "c" }
TODO: would be nice if we can validate this string immediately using a JSON SCHEMA
getObjectKeysArray
Handy function to get the keys of an object, but typed.
NB: The only difference from Object.keys is that this returns the keys in a typesafe manner
getParameterAtLocation
utility function to get a parameter inside of a nested object
getSubsetFromObject
takes an object and a subset of its keys and returns a subset of that object
input: { x: "a", y: "b", z: "c" } and ["x"]
output: { x: "a" }
groupByKey
key should be of type string!
input = [{path:"xyz"},{path:"xyz"},{path:"abc"}] groupByKey(input, "path") ouput: { xyz: [{path:"xyz"},{path:"xyz"}], abc: [{path:"abc"}]}
hasAllLetters
all letters of b can be found in a, in order (but other letters in between are allowed)
insertAt
Insert an array or item inside of an array before a certain index
Example:
const testArray = [1, 2, 3, 4, 5];
const result = insertAt(testArray, [99, 100], 2);
console.log({ testArray, result });
isAllTrue
checks if all items in an array are true
makeArray
if something is not an array, returns it as the first element of an array
if the input is undefined, an empty array will be returned.
NB: TODO: find out the workings of the array constructor (Array("any value")
), because maybe it does something very similar. No need to have a dependency then if it's similar.
mapAsync
mapAsync makes it possible to map over an array async without having to do the promise.all afterwards
It saves a lot of lines of code, and makes it more readable Example usage:
const myNumbers = [1, 2, 3, 4, 5];
const doubleAsync = (num) => Promise.resolve(num + num);
const sqrtAsync = (sum) => Promise.resolve(sum * sum);
const halfAsync = (time) => Promise.resolve(time / 2);
const doubleSqrtHalfs = await mapAsync(myNumbers, doubleAsync)
.then((sums) => mapAsync(sums, sqrtAsync))
.then((times) => mapAsync(times, halfAsync));
mapItem
mapKeys
maps over all keys in an object and replaces them using a mapfn
mapMany
Lets you map over any array with a async function while setting a max. concurrency
Taken and improved from https://codeburst.io/async-map-with-limited-parallelism-in-node-js-2b91bd47af70
mapValuesSync
maps over all values in an object and replaces them using a mapfn
sync
mergeNestedObjectTest
mergeNestedObject
type X = IsOptional<string|undefined>;
Merges an object into an object, ensuring typesafety. The second object needs to be a recursive subset of the first.
LIMITATION: When you set a value to undefined, ensure that it is allowed by the original object, we are not checking for this!
TODO: is it possible to remove this type unsafety? It would be nice to only be able to set it to undefined if that is allowed by T. Not sure if it's possible to check the difference bewteen a key not being present and a key being present and the value being undefined... Look it up!
Example:
const testObject: {
a: string;
b: number;
c: { x: string; y: number; z: { a: string; b: number; c: { x: "wow" } } };
} = {
a: "lol",
b: 8,
c: { x: "lol", y: 88, z: { a: "wow", b: 888, c: { x: "wow" } } },
};
const result = mergeNestedObject(testObject, {
c: { z: { c: { x: undefined }, b: 999 } },
});
console.dir({ testObject, result }, { depth: 10 });
result will be: { a: 'lol', b: 8, c: { x: 'lol', y: 88, z: { a: 'wow', b: 999, c: { x: undefined } } }
}
It's great, because you can't make any type mistakes, and your code becomes much shorter for altering an object
mergeObjectParameters
merges two objects: a config object and a defaults object. If the config object has something missing, a default will be used from the defaults object.
In short: merges two objects, for every parameter, use the default as a fallback
DEPRECATED: in favor of mergeObjects
mergeObjectsArray
TODO: find a way to return the correct type interface
mergeObjects
merges multiple objects, overwriting the previous one with the next. Can be useful for configs where there are multiple layers of configs that overwrite each other.
Please note though, that only the root keys of the object are overwriting each other, so if there is nested datastructures, the last one with a specific key overwrites the previous ones copletely
Please note that you can provide partial objects as well, as long as you are sure that the final object is full, the type interface is correct.
Please note that if a latter object has a key which holds "undefined", it will NOT overwrite it. Anything else WILL
noEmptyString
objectMapAsync
Map an object asynchronously and return the same object with the mapped result in its values
Example usage:
const srcFileContentObject = {
"index.ts": indexString,
"public-local.ts": publicLocalTypescriptFileString,
"public.ts": publicTypescriptFileString,
};
const srcFileWriteSuccessObject = await objectMapAsync(srcFileContentObject, async (operationRelativeTypescriptFilePath,content)=>{
try {
await fs.writeFile(
path.join(operationBasePath, "src", operationRelativeTypescriptFilePath),
content,
"utf8"
);
return true;
} catch {
return false;
}
});
objectMapSync
maps over all values in an object and replaces them using a mapfn
Example usage:
const result = objectMapSync({ hello: "world", isTrue: true }, (key,value) => {
return `${value}123`;
});
objectValuesMap
not sure if this is the best way, but it does save some lines of code!
maps over an object's values with a map function
DEPRECATED in favour of objectMapSync and objectMapAsync
omitUndefinedValues
onlyUnique2
function that returns a filter function that can be used as a filter for any array. removes duplicates.
optionally takes a compare function that should return a "true" if two instances are equal. if you use this function, make sure to pass a generic of the type the items will have, in order to make this equality function type safe as well
pickRandomArrayItem
putIndexAtIndex
Takes an item from an index of an array and put it somewhere at another index
removeIndexFromArray
removes an index from an array
example:
const exampleArray = ["a", "b", "c", "d", "e"];
console.log(removeIndexFromArray(exampleArray, 2)); //c should be removed
removeOptionalKeysFromObjectStrings
removeOptionalKeysFromObject
replaceLastOccurence
Replaces the last occerence of something in a string by something else
Example:
const result = replaceLastOccurence("theBestSlugSlugSlug", "Slug", "Slack");
console.log(result); // returns theBestSlugSlugSlack
NB: this is not the most efficient method, as it reverses the string by making it an array, twice. It can probably be done more efficiently by using String.lastIndexOf
reverseString
sumAllKeys
sums all keys of an array of objects, assuming the objects have the same datastructure and assuming the values contain either numbers or undefined
sumObjectParameters
sums all parameters in two objects together
sum
NB: Tried, but doesn't work, probably because it only invalidates cache for one file, not all the files that are required by that file... we need a separate process
const requireWithoutCache = (filePath: string) => {
delete require.cache[path.resolve(filePath)];
return require(filePath);
};
example function that can be tested
takeFirst
takes any type T or an array of T and returns T or the first of the array (which is T)
trimSlashes
Trims a slash on both sides in any path
getSimpleJsonString
stringifies simple json things if the json is one of them, otherwise returns undefined
arg1
arg2
benchmark
determineFileType
returns the file type or null if it's unknown
exploreGitRepoFolders
find all active git folders (folders having git)
exploreMultiple
DEPRECATED: not sure if we still need it, look up usecases, can prob be replaced now
exploreOperationFolders
find all active operations (folders having package.json
but also tsconfig.json
)
returns folder path array
explorePreset
explore
This is the safe and friendly version of findFilesRecursively
findAllDocsFolderPaths
Returns absolute paths for all docs folders (not the files inside)
findAllDotGitFolders
findAllFoldersWithName
findAllPackages
findAllTodoFolderPaths
findFilesRecursively
Explores your files with many possibilities.
NB: this function only searches one basePath, while explore can do multiple
TODO: since this not only finds files but also explores them, naming should be exploreFilesRecursively, probably.
TODO: TextJson[] is a bit weird name for the resulting type interface...
getArgument
getContents
gets needed contents of file path, based on the extension
returns a markdownparse if it's markdown, a json parse for json, or a file content string for anything else
getOutline
low-level function that gets the outline for MarkdownParse
NB: with books usually the pages are referred in the outline. Since that depends on the font size and dimensions, this cannot be done straight from the markdown parse. Eventually we probably need to check the made pdf for its content, maybe there is even a pdf feature that creates an outline for you. There must be more people having this problem.
isMatch
isSearchContentExtension
type checker for a string to be an extension that can be searched for
pathArrayIsOperation
Checks if pathArray contains a package.json and a tsconfig.json and thus should be an operation
Handy for cancelRecursionOn
in explore
[operationName, manualProjectRoot]
runTestsForOperation
runTestsForOperation(operationName) runs all tests that can be found in an operation. nicely logs and returns which funtions are working or not and why
this assumes the index file exports all tests under the test
constant, which should be done using this framework
this also assumes your tests are exported from build/index.js (which means you need to build your code, not transpile, so it's not possible for every type of operation)
runTests
run tests and log the results.
input: Test
output: isAllValid (boolean)
exampleKeyValueMarkdownParse
exampleKvMdString
exampleLine
flattenMarkdownChunks
Flatten markdown content into an array of paragraphs
getKvmdItemsRecursively
recursively dives into the Chunk to get all kvmd items
NB: this doesn't have a reference to its parent yet, but this will be added in fs-orm on the fly because the key for that is based on the model name
getParagraphsRecursively
recursively dives into the Chunk to get all paragraphs inside
kvmdDataMap
DEPRECATED: probably never needed, unless I make it useful
mapper function to give a kvmd data object other parameters.
NB: not sure if this is useful. it would be useful if we could auto-generate the application of this function for multiple db models.
kvmdDataToString
parses KeyValueMarkdownModelType into a string which can be part of a new markdown file
NB: we need to know the previous line as well because the header we need to print depends on it
kvmdParseToMarkdownString
parses KeyValueMarkdownParse into a markdown string so it can be saved as a markdown file
markdownStringToKvmdParse
parses a key value md string (with support for headings and frontmatter)
parseKvmdLine
parses a kv md line with data into a key, value, and comment (if available)
if the key is an empty string, the line will return undefined
LabeledButton
AuthenticationLayout
Layout that includes default pages and header for authentication
Header
LayoutGrid
Style for creating a grid for the layout that is mobile friendly and has menu support
I run into this problem all the time
https://stackoverflow.com/questions/71616561/css-tailwind-grid-height-100vh-not-working
final solution came from here
Unfortunately, I can't seem to hide stuff anymore for some reason on non-mobile. "lg:flex hidden" just doesn't work, just hides!
My elegant solution was to just use visible/invisible and make the mobile layout hover over the invisible one in case of a small screen, it works!
PingApi
timeBeforeNotOffline
preIndexLint
Should be a collection of small functions that check if all conventions are used and if there isn't used anything that should NOT be used. this can later become a linter. make sure to research how eslint works first
Plan:
- just use my own sdk's as much as possible to provide some handy convention checks in a package
- later integrate this into vscode, i'm sure this is how it's done
this lint can be done before indexation
DEBUG
if true, also shows debug messages
getCallerFileName
TODO: this is great. now also get the operationName. If the operationName appears in the config, for debug, show the log, otherwise don't show
options
special character combinations that make the console message be printed differently
parseTitle
TODO: Should parse a title from markdown
resetString
sendMail
Sends email(s) using sendgrid
Ensure your OS config is there
isResultOfInterface
TODO: need validate-json-schema. also this can be its own little package, as it can be used in many other places
not sure if this should be part of make-test at all, because we want operations to be able to operate independently without the os, right? so then it won't work because you don't always have indexes...
makeTest
create a test that is testable with runAllTests
...
defaultExpandedMode
defaultMinimalMode
getRealSrc
Based on markdown info, gest the real source for an asset
getUrlFromRelativeUrl
gets the renderable asset url from the relative url
getYoutubeId
HtmlHeader
MarkdownCodeblock
Parameter
In markdown, if you wish to refer to a parameter, you can backtick it and put a "." in front. You can also add a value to it if you wish, by adding the ":" and the value afterwards.
renderFrontmatter
Renders markdown frontmatter parameters (and optionally a spacer)
renderMarkdownChunk
renders a MarkdownChunk interface
renderMarkdownContent
Renders a markdown string (without frontmatter)
TODO:
- Show selection prompt-results In renderMarkdownContent, augment the alineas with the ContextualPromptResult. Would be great to see the results when hovering over the selected thing, or maybe showing it with a button, or inline, even.
renderMarkdownParse
renders the MardkownParse interface (including frontmatter)
renderMarkdownTitle
renders a markdown title (level should be 1 for h1 and 6 for h6)
useOpenHashDetails
chunkToStringRecursively
exampleMarkdownFileContents
getChunkParagraphsRecursively
Get all paragraphs (content
values) recursively from a MarkdownChunk
getImplicitId
Implicit ids are a convention in markdown. A title gets an implicit id by removing spaces and making the title lowercase.
See https://stackoverflow.com/questions/6695439/how-to-link-to-a-named-anchor-in-multimarkdown
getMarkdownIntro
This function takes a markdown parse and gets the first paragraph and a title from it, if available.
Currently assumes that the first paragraph starts directly after the title or there is no title and the content is at the beginning.
TODO: It would be better to find the first paragraph based on the level.
getMarkdownParseParagraphs
Gets all paragraphs (recursively) from a MarkdownParse
getMarkdownReferencePaths
getMarkdownReferencesFromParagraph
Gets all markdown references from a paragraph
markdownParseToMarkdownStringFromContent
markdownParseToMarkdownString
NB: this just uses RAW!
Use markdownParseToMarkdownStringFromContent
for the real deal
mdContentParseRecursively
recursively parses a string containing markdown (without frontmatter) into a MarkdownChunk[]
Improve:
- include the comment-type (TODO/NB/etc), both on a chunk level and on root level
- parse paragraphs further around the assets
mdToJsonParse
makes a markdown parse from a markdown string
TODO: markdownStringToMarkdownParse
is a better name. First make a refactor script for this, because it is too hard to rename stuff that is used a lot.
TODO: BUG: it doesn't take into account triple backticks! if there is markdown inside of the triple backticks, it can still be seen as main markdown. Triple backticks are stronger!
parseFrontmatterMarkdownString
splits a markdown string into its frontmatter object and the raw content (without frontmatter)
parseMarkdownParagraph
Parse markdown paragraph
Should split it up for every thing it encounters...
parseMdToChunks
should get chunks recursively. first just look for every h1 line. everything after the h1 line is the children until there's another h1 line, then do this recursivley for h2, h3, etc.
removeHeaderPrefix
removes header prefix (##### etc) and trims whats behind that
addDependantCount
Double arrow function to get the count for the item
bundleFolderWithMarkdown
Finds all md files in a folder and creates a single MarkdownParse
handy for creating a single documentation file or other things that have to include multiple markdown files in a structured way
NB: it recursively structures the files and folders with headings
bundleToBookMarkdown
Input: BundleConfig (one or more folder(s), readme, operations with a docs folder)
Output should be all md files concatenated in the right order with the right titles
bundleToMarkdown
creates a summary for a whole bundle
NB: Related to bundleToBookMd
concatMarkdownFiles
createMinimizedSectionMarkdown
createMinimizedSection
deployToVercel
NB: Obviously, this is not the right place for this function, but none of these functions are properly located yet...
should deploy any bundle or next project folder project to Vercel by first creating and pushing it into git, and then creating it in vercel through their api
should return an url where the project will be served and the estimated time when it will be live
emailMarkdownParse
should email a markdown parse to some email (or multiple)
flattenNestedObject
Flattens a nested object by returning an object that hasa the nested path as the key and the leaf as the value
TODO: Finish, if needed. seems hard!
generateStaticSite
generates static site from a markdown file, with a menu on the right by default
uses next.js
because it is static, the markdown can be in the frontend assets and there is no need for a backend
getJsonSchemaSummary
Generates short markdown summary
getMarkdownContents
getMergedMarkdownOutlineUrl
getOperationSummary
Summarises operation into useful information about it. Especially useful for generating docs.
getPublicMarkdownNestedPathObject
Recursively searches a folder for public markdown files, and returns a NestedObject
with the keys being the file or folder names, and the leafs being the absolute file paths.
File and folder names are stripped (number prefixes are removed, )
example:
{
"README": "path/path/README.md"
"folder1":{
"README": "path/path/folder1/REAMDE.md"
"file1": "path/path/folder1/file1.md",
}
}
getTitlesRecursively
helper function to get a nested array of the titles and its subtitles
getTypeDescriptorRecursive
Returns a single line descriptor of the type of a json schema. Can be used in markdown tables.
isConventionFileStatement
isUpperCase
makeOutlineMarkdownString
makePropertiesTable
markdownChunkToMarkdownStringRecursive
markdownChunksToMarkdownStringRecursive
markdownToSayable
all mp3s should be stored in a separate location because we don't need them in the file system and we don't reference them, as they are data that is located by convention. all markdowns should have a linked TextToSpeechAudio[]
which is auto updated every time dev
is ran. TextToSpeechAudio
also includes infromation about the duration
, voice
and more...
a bigger md.mp3 file is auto-created for every markdown file that concatenates all sayable
audio pieces in the right order, but also includes the audio pieces in between.
mdToPdf
Have function mdToPdf like the vscode plugin. Probably exists.
However, may be good to do it myself since I want different renderings
mergeMarkdownParse
Merges multiple markdown parses to create a new markdown parse
noNewlines
Replaces newlines with a
operationRadio
randomly plays mp3 summaries of operations on the project
operationToMarkdown
converts an operation and all its contents into a flat markdown file that contains the needed information. configurable.
markdown for reading (so there are no links)
printNestedTitles
helper function (recursive) that prints nested titles with .. as prefix and a newline after every title
TODO: allow for numbering titles
should print any file using a preconfigured printer (which can be local or remote. if remote and there is no connection, it should save the task for later)
this function maybe needs "generateStaticSite"
projectToMarkdown
summarizes the whole OS project into a markdown string
propertyToTableRow
sayablesToMp3
Creates a single audiofile of a Sayable[] and stores that in a configured location
selectRandomOperation
selects a random operation
simplifiedSchemaToMarkdownString
Should render a string with one or more markdown tables to represent the simplifiedSchema
statementItemToMarkdown
tsFunctionToMarkdownString
TsFunction:
- name and operation
- size
- description (doc-comment)
- input, output
tsInterfaceToMarkdownString
properties, their type, and their description
use simplifiedJsonSchema, but split up nested things into multiple tables (ive written a thing for splitting up nested objects before, use that)
tsVariableToMarkdownString
upMarkdownChunkLevelRecursively
Ups the levels of the markdownChunk array, recursively.
Can be useful for merging multiple markdown sources
availableExtensions
copyStaticAssetsCli
copyStaticAssets
uses getMarkdownReferencePaths
for all markdown files in the markdown-reader-ui
and copies them into the markdown-reader-web/public
folder, keeping the original folder structure.
NB: Removes all files in the public folder first.
To get a file from public assets after running this function, you need to get it from the projectRelativeFilePath
, not the file relative, so you need to render it differently.
docsGetPages
docsGetStaticPaths
Function that tells Next.js what the pages are that need to be statically generated
docsGetStaticProps
getAllMarkdownReaderPages
....? I should've commented this
const hasDocs = !!relativeDocsPages.find(
(x) => x.queryPath.toLowerCase() === "docs/readme"
);
if (!hasDocs) {
const hasRootReadme = fs.existsSync(path.join(projectRoot, "README.md"));
if (hasRootReadme) {
relativeDocsPages.unshift({
queryPath: "docs/readme",
filePath: "README.md",
isMenuItem: true,
});
}
}
Gets all pages of a bundle based on the fs and database
Pages it finds:
- operation-readmes
- multiple docs basePaths with all folders and markdown pages there in (
/[project-relative-path]
) /dictionary
- all markdown model types we have in the db-sdk, optionally, depending on config
Requirements:
- README should always be on top in a folder.
- numbers and extensions are omitted from paths, but still connected to the right file
- If the docs doesn't have a readme, the /docs/readme path shows the root readme.
Does not include AugmentedWord. Just the main pages, not with queries and hashes
Used to generate the menu
getChildren
getFolderExplorationInfo
Gets exploration information about a folder
- reads README.md in current folder
- reads OPERATION.md in child folders, or README.md if that doesn't exist
- gets an intro from those markdown files and returns that (uses getMarkdownIntro)
getMarkdownModelPages
Transforms all your markdown models into markdown reader pages
Steps:
- Finds all markdown model types from the database config
- Gets their basepaths according to fs-orm convention
- Checks if they actually exist
- Finds all markdown therein
- Makess markdown reader pages out of them
getMarkdownPageInfo
If a markdown page is found, this function fetches all metadata needed to render that markdown page
getMarkdownReaderPages
Gets all markdownreader pages for multiple basePaths. Can add a prefix, can also remove the last folder of basePath from the suffix.
getMarkdownReaderQueryPaths
getOperationPages
getPublicMarkdownFilePaths
Returns all absolute markdown file paths within a basePath which are not drafts and which are not marked private (through frontmatter)
Readme is put on top!
getReaderTodoPages
gets all todo pages as markdownreader pages
markdownReaderGetStaticPaths
Function that tells Next.js what the pages are that need to be statically generated
markdownReaderGetStaticPropsFromPages
Takes the routes and pages you want to show, and returns the MarkdownReaderPageProps you need to render the reader page.
markdownReaderGetStaticProps
putReadmeOnTop
removeExtensionsFromPath
- Removes numbers from file or foldernames in a path.
- Removes extension of files
- Returns the new path without numbers and without extension
Works for files and folders
removeNumberPrefix
removes number prefixes from a file or folder name. Does not remove extension
defaults to untitled if the file or folder has no name after removing numbers.
shouldExposeMarkdownFile
markdown file should only be exposed if it doesn't say privacy: private
or isDraft: true
in your frontmatter.
stripReadmeFromFolder
To get the queryPath, we need to strip the README.md so we get the folder as URL instead of the attached README.md
getQueryPath
markdownParseToMarkdownModelType
makes a markdownModelType from a markdownParse.
parseMarkdownModelTimestamp
First tries to look at the frontmatter value, this is leading because it is what the user sees and the file system of the os could be inconsistent
If this frontmatter doesn't exist, the markdownParse is checked for a date. This should be information collected from the file system
If that doesn't succeed, sometimes we'll set it to the current timestamp
tryParseDate
Tries to parse a date from a string
- implements default behavior of
new Date
with a try catch - returns a unix timestamp (ms since 1970 AD)
TODO: put in a better location... date-util?
findCodespans
find all codespans
findEmbedsTest
findEmbeds
find all embedded assets
findLinks
find all links
flattenMarkdownString
find all items that match a token, recursively in all nested things
flattenMarkedTokenRecursive
Recursively flatten a marked token and return something if a find function is met
cleanupTimer
Ensure you run this after finishing the measurement, or you'll run into memory leaks!
generateUniqueId
Bit annoying that we need to use all model-types here xD.
TODO: Let's extrahere this
getNewPerformance
Function that lets you measure performance inside any function with ease.
Usage:
Firstly, make a performance array, and a unique execution id, and start the measurement, like so:
import { generateUniqueId, getNewPerformance, PerformanceItem, cleanupTimer } from "measure-performance";
at the start of your function
const executionId = generateUniqueId();
const performance: (PerformanceItem | undefined)[] = [];
getNewPerformance("start", executionId, true)
After that, push a new performance item at every step you want to measure. Provide your label describing what happened before this (the step you are measuring).
performance.push(getNewPerformance("your label", executionId));
At the end of your function, you can view your performance array by printing it on the console (or store it somewhere if you like)
Don't forget to run cleanupTimer, or you'll run into memory leaks!
cleanupTimer(executionId);
timer
TODO: This stores into memory. May cause memory leaks in the long run if not cleaned up!
getLegacyMenu
Menu
"wise"
component that lets you render a menu easily, including search
TODO:
- provide menu with NestedWebPage
[]
minifyBuild
takes an operation name or build folder path, then explores all ts files in src folder, finds the matching js file in the build folder, and executes terser from dependency, not from cli
generateId
24 characters of the alphabet provides 9E33 combinations, wont be possible to brute-force in centuries, even if there are billions of entries
generateRandomString
generateTime
languages
keys are the iso codes which will be saved in the db, the values are values which can be shown to the user in any UI
markdownModelTypeToMarkdownString
assetsFolders
generatedParameterNames
getAssetInputType
Convention parameters for assets: [name], [name]s, xyz[Name], xyz[Name]s
Different ways to name assets: image
, video
, audio
, file
or just asset
, which is everything together
getParameterContentType
isCalculatedParameter
this is part of the database convention
isGeneratedParameterName
markdownTextParameterNames
Any parameter names that should render a textArea
parameterNames
How do we show different UI's based on certain things we know about some parameter (name + type)? There are many things
- All "image" or "xxxImage" should be Image + camera inputs
- All "asset" or "xxxAsset" should be File inputs
- All "recording" or "xxxAudio" should be mic inputs
- All "position" or "xxxPosition" should be coordinates which should be pickable on the map
- All "path" or "xxxPath" should be an input where you can select a relative path from project root or operation src root, depending on what we need. It needs to be clear what kind of paths are allowed, so we need to think about all the options and if we can all put that in the parameter name (would be best) or if we need to use the description...
passwordTextParameterNames
patternMatchers
referenceParameterNames
referencePluralParameterNames
getRealItemRecursive
getTitle
NestedMenuItem
TODO:
- tooltip support
nestedMenuStoreInitialValues
NestedMenu
General purpose nested menu component
Please make sure that you also wrap your app with MenuStoreProvider
, or this will crash...!
useExpanded
ALink
A simple wrapper around react-with-native A and next-link
All links you make with this component are SEO-ready
oneByOne
for every item in an array, executes an async callback, one by one. promises an array of the results of every callback once it's done
getDependenciesSummary
getOperationMetaData
gets a whole bunch of metadata about an operation, mainly filepath related, but it also reads the operation index json file
recalculateOperationIndexJson
Recalculates some operation indexable things and updates that into the database
parsePrimitiveArray
parsePrimitiveBoolean
parsePrimitiveString
parsePrimitive
parses a string into the value it should be
if you provide a simplifiedSchema
, that will be used to parse according to the shape of the schema
calculatePathMetaData
for folders: finds all files used for calculation and uses sumPathMetaData to create a new PathMetaData. for files: just calculates the path metadata
categorizeFiles
explores files in an operation within a specified location or from a specified type
getFolderSummary
calculates folder summary from a categorized file paths object
getPathMainComment
export const sumFolderSummary = ( firstFolderSummary: FolderSummary, secondFolderSummary: FolderSummary ): FolderSummary => { const folderSummaryKeys = Object.keys( firstFolderSummary ) as (keyof FolderSummary)[]; const sum = mergeObjectsArray( folderSummaryKeys.map((keyName) => { return { [keyName]: sumAllKeys([ firstFolderSummary[keyName], secondFolderSummary[keyName], ],["bytes","characters","lines","numberOfFiles"]), }; }) ) as FolderSummary;
return sum; };
takes all PathMetaData of an array that contains all child files, and merges them, taking the newest update date, the earliest created-date, and summing size
export const sumFileGeneralMetaData = async ( childrenMetaDataArray: PathGeneralMetaData[] ): Promise<PathGeneralMetaData | null> => { const sum = childrenMetaDataArray.reduce( (sumMetaData, pathMetaData: PathGeneralMetaData) => { const newPathMetaData: PathGeneralMetaData = { createdAt: !sumMetaData || pathMetaData.createdAt < sumMetaData.createdAt ? pathMetaData.createdAt : sumMetaData.createdAt, updatedAt: !sumMetaData || pathMetaData.updatedAt > sumMetaData.updatedAt ? pathMetaData.updatedAt : sumMetaData.updatedAt, sizes: !sumMetaData ? pathMetaData.sizes : sumFolderSummary(sumMetaData.sizes, pathMetaData.sizes), };
return newPathMetaData; }, null as PathGeneralMetaData | null );
return sum; };
sumSizeSummary
achievements
developers
englishMethod
levelNames
publicPersonKeys
Can be seen for every person, without authentication
NB: I wish it were possible to ensure these keys exist on the person here, but we can't validate that while still keeping it a const I guess
getPrimaryPersona
isPlural
isSingular
singularize
Removes the 's' if it is found at the end of the parameter name
ports
See https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers for available ports
Range 42000-42080 seems to have no ports. There are many more ranges
When creating a new app, ensure you not only define the port here, but also in
InputSize
Inheritance of different button themes
InputTheme
Inheritance of different button themes
readCsvFileSync
Reads and parses CSV file
specify a generic of what type of item the file contains an array of
readCsvFile
Reads and parses CSV file
specify a generic of what type of item the file contains an array of
readJsonFileSync
Reads and parses JSON file
make sure to specify what type the file contains as a generic!
readJsonFile
Reads and parses JSON file
make sure to specify what type the file contains as a generic!
readProjectRelativeJsonFile
readKvmdFile
Reads and parses a markdown file
readMarkdownFileToModel
Reads a markdown absolute path to a WebMarkdownFile model
Attaches default calls to action and header
readMarkdownFile
Reads and parses a markdown file
getFolderTypescriptIndex
get a Typescript index for all that is found in a folder
getOperationIndexModel
readTypescriptFile
Reads and parses a markdown file
uniqueNames
AugmentedWordComponent
Dictionary
DocsReaderLayout
Layout
ReaderPageContent
This is rendering a WebMarkdownFile and optionally navigation.
ReaderPageHeader
{ useStore, StoreProvider }
clearTsDatabase
Clears all typescript indexation models, and removes all indexation from the oprations
TODO: test first, not sure about the Operation one
cwdProjectRoot
executeCommandQuietUnlessFail
Executes a command without showing the result, unless the command fails, then it will log the output.,
exitIfProcessDependenciesChanged
exits the process if our own dependencies change
generateJsonSchemas
generates schemas for db models
Is done every time you run rebuildOperation and generateSdkOperations
TODO: there are some problems with references that cannot be found with references to generic types... This can probably be solved, but it's not going to be easy!
IDEA:
- find all referencing definitions in the main schema
- find those in all other interfaces
- recursively find references in those as well
- if you can't find the reference, remove the reference and replace type to "any" (add WARNING to description "reference not found")
This will result in a valid schema that has no unresolved references
TODO: apply Storage
TODO: apply Array
TODO: apply special config conventions (MergedDbConfig) like tsconfig.json and package.json
TODO: Make a validator that validates the whole database to this schema.
getAllDbModels
getFileIds
gets all identifiers of files, which are the relative path to a file without the extension
getIndexFileIds
gets identifiers of ts and tsx files, which are the relative path to a file without the extension
getSrcIds
gets identifiers of ts and tsx files, which are the relative path to a file without the extension
in order for them to be unique, we assume here that there's never a file with the ts extension when there's also a tsx file in the same folder with the same name. This would create duplicate ids.
isOperationBuildNeeded
returns a boolean indicating whether or not the operation should be able to be built, based on the OperationClassification
isRebuildingProcessUpdated
isSdkOperation
[isUpdatedString]
manualProjectRoot
rebuildAllOperations
Rebuilds all operations that are needed to be rebuilt
rebuildOperationCli
rebuildOperation CLI syntax:
rebuildOperation [...operations]
Operations can be a list of differnt operation names you want to rebuild. It's also possible to specify a relative path instead of an operation name.
for example:
rebuildOperation ./packages/operation-x
would rebuild operation-x
in your packages folder
another handy one is rebuildOperation .
because it will rebuild the operation in your current folder.
rebuildOperation
This function rebuilds an operation and re-indexes (part of) its files.
shouldSkip
if you don't force it, there's an operation index, there's an index folder, the src has not been touched since hte last indexation, and there's a buildfolder (if needed), then the rebuildOperation can be skipped
thisProjectRoot
yarnBuild
Builds and minifies the src
getKeysAtPathFromNestedObject
Gets all children keys of a nested object at a certain (nested) location in the nested object
nestedObject
should extend the NestedObject
.
The reduce is a bit vague, I need to test this function further to make sure it does exactly what I want.
getMenuPagesObject
makeNestedObjectFromQueryPathObject
nestedObjectToChildObject
if T is an object, provide __check as one of its properties, to make it possible to che