dark icon indicating copy to clipboard operation
dark copied to clipboard

Rewrite static assets feature in Dark

Open pbiggar opened this issue 3 years ago • 7 comments
trafficstars

  • remove remaining OCaml editor-servers

pbiggar avatar May 25 '22 18:05 pbiggar

(WIP research brain-dump)

Relevant files in code (all in fsharp-backend):

  • src/ApiServer/Api/APIInitialLoad.fs
  • src/BackendOnlyStdLib/LibStaticAssets.fs
  • src/LibBackend/Config.fs
  • src/LibBackend/Pusher.fs
  • src/LibBackend/StaticAssets.fs
  • src/LibBackend/webserver_apiserver.ml.unported
  • tests/httptestfiles/serve-latest.test
  • tests/staticassets-tests/README.md
  • tests/testfiles/staticassets.tests
  • tests/Tests/ApiServer.Tests.fs
  • tests/Tests/LibExecution.Tests.fs
  • tests/TestUtils/TestUtils.fs

Edit: there may be some upload-related stuff in webserver.ml, not in the F# project at all. Need to study more here.

Existing Functionality

  • upload static assets
    • external upload script
    • backend stuff that handles the uploads by the script
  • access via StdLib fns in BwdServer (list them out here)
  • display the static asset deploys within the Editor
    • ApiServer gathers this during initial_load
    • ui.html and the client code coordinate to display such
  • upload static assets (currently only in OCaml)
    • call Pusher when performed so client gets notification of new assets

Questions:

  • ~Should StaticAssets should be a Package wholly outside of the Dark repo?~ no

Research TODOs

  • [ ] list out the stdlib fns here
  • [ ] read through those code files and expand upon this document
  • [ ] think through impl.
  • [ ] think through testing

StachuDotNet avatar Jun 30 '22 18:06 StachuDotNet

Should StaticAssets should be a Package wholly outside of the Dark repo?

No. Packages don't have the ability to dip into the runtime like StdLib functions do (and they're not intended to).

pbiggar avatar Jun 30 '22 18:06 pbiggar

external upload script

This is https://github.com/darklang/dark-cli

pbiggar avatar Jun 30 '22 18:06 pbiggar

What do you mean by "dip into the runtime"?

StachuDotNet avatar Jul 01 '22 20:07 StachuDotNet

A stdlib function is written in F#, so it can call functions and use types from LibBackend. But a package can only call things already exposed as Stdlib functions.

pbiggar avatar Jul 01 '22 21:07 pbiggar

I'll be continuing this work in #4259 for a while, focusing specifically on the upload of static assets. Eventually we may circle back to rewriting the whole thing in Dark.

Note that while there's some discussion about needing to dip into the runtime, we likely don't need to - we can simply replace our "internal" Postgres table with a Dark datastore in a canvas.

StachuDotNet avatar Jul 12 '22 14:07 StachuDotNet

There's some related discussion in #4278 worth reading. (all future-thinking, not planning per se)

StachuDotNet avatar Jul 14 '22 21:07 StachuDotNet

Not applicable in darklang-next.

pbiggar avatar Mar 06 '23 00:03 pbiggar