Operation util
operation-util (OperationClassification
OperationClassification
tells you to what kind of environment the operation can be exposed to. It tells you things about how it will be built. There are three categories: Full stack, frontend only, and backend only. The aim is to do as much as possible in the full stack realm so it can be reused anywhere. If that is not possible, ui-esm
is preferred for the frontend, or node-esm
for things that require backend.
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.
Possible values
FULL STACK
-
cjs
: only js (no node) (well, ts of course, but it gets built into common js)
-
ts
: non-built typescript code (needs to be transpiled, not recommended)
TODO: esm
: builds to ESM module resolved Javascript
FRONTEND ONLY (cannot be used within backend-only operations)
-
ui-web
: has next.config.js and thus exposes something on some port when it is ran. next.js + react-based...
-
ui-app
: uses react-native and exposes something on some port when it is ran
-
ui-ts
: uses react (with (native)), which main entry points to typescript es6 files (this ui package cannot be built, should be transpiled. Primarily used for big ui libraries tied to a ui-web
and ui-app
for convenience. For other things, it is highly discouraged, please use ui-cjs
or ui-esm
)
-
ui-cjs
: ui which main entry points to javascript es5 files (this ui package can be built). don't import ESM packages in here, this may give problems.
-
ui-esm
: ui which builds to ESM module resolved Javascript. All packages that use ui-esm
packages, need to be ui-esm
, ui-es6
, ui-web
, or ui-app
in order to work properly. It seems to have difficulties using this in ui-cjs
BACKEND ONLY (cannot be used within frontend-only operations)
node-cjs
: includes other node packages, operations, core-imports, and globals.
TODO: node-esm
: Typescript package that is built to ESM Javascript which also includes all node packages, operations, core-imports and globals.
TODO: node-ts
: transpilable node package
server-cjs
: exposes something on some port when it is ran and uses node code
Indexation
Operations will be classified automatically. It is good to remember that:
- It will be classified as UI if
isUiOperation
resolves to true
- It will be classified as Node if
Operation
has a (dev)dependency on @types/node
.
- Otherwise, it will be classified as base typescript (full stack)
- It will be classified to an ESM operation if
tsconfigCompilesEsm
resolves to true.
- It will be classified to a TS operation if
packageCompilesTs
resolves to true
- In order for it to be classified as a server, you must set
isNodeServer
to true in the operation config object of Operation
OperationClassification cjs)
Operation with utility functions to calculate things about operations and alter operation-index.
Api reference
recalculateOperationIndexJson()
Recalculates some operation indexable things and updates that into the database
Input | | |
---|
operationBasePath | string | |
Output | | |
📄 recalculateOperationIndexJson (exported const)
Recalculates some operation indexable things and updates that into the database
Internal
Show internal (5)
getDependenciesSummary()
Input | | |
---|
operationName | string | |
Output | | |
getOperationMetaData()
gets a whole bunch of metadata about an operation, mainly filepath related, but it also reads the operation index json file
Input | | |
---|
operationBasePath | string | any path in an operation |
Output | | |
🔹 OperationMetaData
Properties:
Name | Type | Description |
---|
operationBasePath | string | |
operation (optional) | object | |
operationName | string | |
srcPath | string | |
operationFolderName | string | |
relativeOperationLocationPath | string | |
📄 getDependenciesSummary (exported const)
📄 getOperationMetaData (exported const)
gets a whole bunch of metadata about an operation, mainly filepath related, but it also reads the operation index json file