Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ executors:
IN_DEV_CONTAINER: true
docker:
# DOCKERFILE_REPO: see Dockerfile note about how this is built.
- image: darklang/dark-base:55da9ca
- image: darklang/dark-base:c14da19
# Rust is so big we create a separate container for it and only use that
# for rust builds
in-rust-container:
Expand All @@ -24,7 +24,7 @@ executors:
IN_DEV_CONTAINER: true
docker:
# DOCKERFILE_REPO: see Dockerfile note about how this is built.
- image: darklang/dark-rust:55da9ca
- image: darklang/dark-rust:c14da19

commands:
show-large-files-and-directories:
Expand Down
5 changes: 3 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ionide.ionide-fsharp@5.5.5",
"ionide.ionide-fsharp@5.6.0",
"shuumatsu.vscode-ocamlformat",
"esbenp.prettier-vscode",
"ms-python.python",
"ms-azuretools.vscode-docker",
"editorconfig.editorconfig"
"editorconfig.editorconfig",
"[email protected]"
],

/////////////////////////////////////////////////
Expand Down
8 changes: 7 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ indent_size=2
max_line_length=85
fsharp_align_function_signature_to_indentation=false
fsharp_alternative_long_member_definitions=false
fsharp_bar_before_discriminated_union_declaration=false
fsharp_blank_lines_around_nested_multiline_expressions=false
fsharp_array_or_list_multiline_formatter=character_width
fsharp_indent_on_try_with=false
fsharp_keep_if_then_in_same_line=false
fsharp_keep_indent_in_branch=false
fsharp_max_array_or_list_size=3
fsharp_max_array_or_list_width=85
fsharp_max_dot_get_expression_width=85
Expand All @@ -24,9 +27,12 @@ fsharp_max_function_binding_width=85
fsharp_max_if_then_else_short_width=80
fsharp_max_infix_operator_expression=80
fsharp_max_record_width=85
#fsharp_max_record_number_of_items=1 # does nothing, due to character_width
fsharp_max_value_binding_width=85
fsharp_multiline_block_brackets_on_same_column=false
fsharp_multi_line_lambda_closing_newline=false
fsharp_newline_between_type_definition_and_members=true
fsharp_record_multiline_formatter=character_width
fsharp_semicolon_at_end_of_line=false
fsharp_single_argument_web_mode=false
fsharp_space_after_comma=true
Expand All @@ -39,4 +45,4 @@ fsharp_space_before_member=false
fsharp_space_before_parameter=true
fsharp_space_before_semicolon=false
fsharp_space_before_uppercase_invocation=false
fsharp_strict_mode=false
fsharp_strict_mode=false
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ RUN echo "plugin load /home/dark/.dotnet/tools/.store/dotnet-sos/5.0.160202/dotn

# formatting
ENV PATH "$PATH:/home/dark/bin"
RUN dotnet tool install fantomas-tool --version 4.4.0 --tool-path ~/bin
RUN dotnet tool install fantomas-tool --version 4.5.0 --tool-path ~/bin
RUN curl https://raw.githubusercontent.com/darklang/build-files/main/ocamlformat --output ~/bin/ocamlformat && chmod +x ~/bin/ocamlformat

#############
Expand Down
8 changes: 4 additions & 4 deletions fsharp-backend/src/ApiServer/Api/APIOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ let addOp (ctx : HttpContext) : Task<T> =
match Map.get tlid toplevels with
| Some tl -> tl, C.NotDeleted
| None ->
match Map.get tlid deletedToplevels with
| Some tl -> tl, C.Deleted
| None ->
failwith "couldn't find the TL we supposedly just looked up"
match Map.get tlid deletedToplevels with
| Some tl -> tl, C.Deleted
| None ->
failwith "couldn't find the TL we supposedly just looked up"

(tlid, oplists, tl, deleted))
|> C.saveTLIDs canvasInfo
Expand Down
3 changes: 2 additions & 1 deletion fsharp-backend/src/ApiServer/Api/APISecrets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ module Insert =

return result

with e ->
with
| e ->
let msg = e.ToString()

// FSTODO: does this error trigger correctly
Expand Down
32 changes: 16 additions & 16 deletions fsharp-backend/src/ApiServer/Api/APITraces.fs
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,29 @@ module TraceData =
match handler with
| Some h -> Traces.handlerTrace c.meta.id p.trace_id h |> Task.map Some
| None ->
match c.userFunctions |> Map.get p.tlid with
| Some u -> Traces.userfnTrace c.meta.id p.trace_id u |> Task.map Some
| None -> task { return None }
match c.userFunctions |> Map.get p.tlid with
| Some u -> Traces.userfnTrace c.meta.id p.trace_id u |> Task.map Some
| None -> task { return None }

t "load-trace"

// CLEANUP, this is shimming an RT.Dval into an ORT.dval. Nightmare.
let (trace : Option<Trace>) =
match trace with
| Some (id, (traceData : AT.TraceData)) ->
Some(
id,
{ input =
List.map
(fun (s, dv) -> (s, Convert.rt2ocamlDval dv))
traceData.input
timestamp = traceData.timestamp
function_results =
List.map
(fun (r1, r2, r3, r4, dv) ->
(r1, r2, r3, r4, Convert.rt2ocamlDval dv))
traceData.function_results }
)
Some(
id,
{ input =
List.map
(fun (s, dv) -> (s, Convert.rt2ocamlDval dv))
traceData.input
timestamp = traceData.timestamp
function_results =
List.map
(fun (r1, r2, r3, r4, dv) ->
(r1, r2, r3, r4, Convert.rt2ocamlDval dv))
traceData.function_results }
)
| None -> None

t "write-api"
Expand Down
27 changes: 14 additions & 13 deletions fsharp-backend/src/ApiServer/Login.fs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ let logout : HttpHandler =
// if no session data, continue without deleting it
let sessionData = Middleware.loadSessionData ctx
do! Session.clear sessionData.key
with _ -> ()
with
| _ -> ()

ctx.Response.Cookies.Delete(Session.cookieKey, cookieOptionsFor ctx)

Expand Down Expand Up @@ -96,20 +97,20 @@ let loginHandler : HttpHandler =

match! Account.authenticate usernameOrEmail password with
| None ->
let redirect = if redirect = "" then [] else [ "redirect", redirect ]
let error = [ "error", "Invalid username or password" ]
let qs = Middleware.queryString (redirect @ error)
let redirect = if redirect = "" then [] else [ "redirect", redirect ]
let error = [ "error", "Invalid username or password" ]
let qs = Middleware.queryString (redirect @ error)

return! redirectTo false $"/login?{qs}" earlyReturn ctx
return! redirectTo false $"/login?{qs}" earlyReturn ctx
| Some username ->
let! sessionData = Session.insert username
let! sessionData = Session.insert username

ctx.Response.Cookies.Append(
Session.cookieKey,
sessionData.sessionKey,
cookieOptionsFor ctx
)
ctx.Response.Cookies.Append(
Session.cookieKey,
sessionData.sessionKey,
cookieOptionsFor ctx
)

let location = if redirect = "" then $"/a/{username}" else redirect
return! redirectTo false location earlyReturn ctx
let location = if redirect = "" then $"/a/{username}" else redirect
return! redirectTo false location earlyReturn ctx
})
36 changes: 18 additions & 18 deletions fsharp-backend/src/ApiServer/Middleware.fs
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ let jsonOptionHandler (f : HttpContext -> Task<Option<'a>>) : HttpHandler =
task {
match! f ctx with
| Some result ->
let t = startTimer ctx
let! newCtx = ctx.WriteJsonAsync result
t "serialize-to-json"
return newCtx
let t = startTimer ctx
let! newCtx = ctx.WriteJsonAsync result
t "serialize-to-json"
return newCtx
| None ->
ctx.SetStatusCode 404
return! ctx.WriteJsonAsync "Not found"
ctx.SetStatusCode 404
return! ctx.WriteJsonAsync "Not found"
})

// Either redirect to a login page, or apply the passed function if a
Expand Down Expand Up @@ -216,12 +216,12 @@ let sessionDataMiddleware : HttpHandler =

match session with
| None ->
t "session-data-middleware"
return! redirectOr unauthorized ctx
t "session-data-middleware"
return! redirectOr unauthorized ctx
| Some sessionData ->
let newCtx = saveSessionData sessionData ctx
t "session-data-middleware"
return! next newCtx
let newCtx = saveSessionData sessionData ctx
t "session-data-middleware"
return! next newCtx
})


Expand All @@ -233,14 +233,14 @@ let userInfoMiddleware : HttpHandler =

match! Account.getUser (UserName.create sessionData.username) with
| None ->
t "user-info-middleware"
return! redirectOr notFound ctx
t "user-info-middleware"
return! redirectOr notFound ctx
| Some user ->
// FSTODO: add canvas to tracing
ctx.SetHttpHeader("x-dark-username", user.username)
let newCtx = saveUserInfo user ctx
t "user-info-middleware"
return! next newCtx
// FSTODO: add canvas to tracing
ctx.SetHttpHeader("x-dark-username", user.username)
let newCtx = saveUserInfo user ctx
t "user-info-middleware"
return! next newCtx
})

// checks permission on the canvas and continues. As a safety check, we add the
Expand Down
Loading