Skip to content
Draft
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
13 changes: 12 additions & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
org.clojure/tools.logging {:mvn/version "0.5.0"}
org.clojure/data.json {:mvn/version "0.2.7"}
org.clojure/data.xml {:mvn/version "0.2.0-alpha6"}
com.cognitect/http-client {:mvn/version "0.1.101"}}
com.cognitect/http-client {:mvn/version "0.1.101"}


;; CLJS support
com.andrewmcveigh/cljs-time {:mvn/version "0.5.2"}


}
:aliases {:update-versions {:extra-paths ["build/src"]
:main-opts ["-m" "cognitect.aws.version-updater"]}
:dev {:extra-paths ["dev/src" "dev/resources" "test/src" "test/resources"]
Expand All @@ -18,6 +25,10 @@
:test {:extra-deps {com.cognitect/test-runner {:git/url "https://github.com/cognitect-labs/test-runner.git"
:sha "cb96e80f6f3d3b307c59cbeb49bb0dcb3a2a780b"}}
:main-opts ["-m" "cognitect.test-runner"]}

:cljs-build
{:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.520"}}
:main-opts ["-m" "cljs.main" "-co" "min.js.edn" "-c"]}
:examples {:extra-paths ["examples" "examples/resources" "dev/resources"]
:extra-deps {org.clojure/test.check {:mvn/version "0.10.0"}
org.slf4j/slf4j-log4j12 {:mvn/version "1.7.28"}
Expand Down
66 changes: 66 additions & 0 deletions min.js.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
;; borrowed from axel-f with lots of with gratitute
;; https://github.com/xapix-io/axel-f/blob/9bb72e13699b9559142392c4fa19041b1d072244/axel_f.min.js.edn
{:output-to "out/min/sci.min.js"
:output-dir "out/min"
:optimizations :advanced
:main "sci.impl.js"
:aot-cache true
:compiler-stats true
:pretty-print false
:elide-asserts true
:parallel-build true
:checked-arrays :warn
:static-fns true
:fn-invoke-direct true
:warnings {:fn-deprecated false}
:optimize-constants true
:output-wrapper "/**
* Small Clojure Compiler v0.0.9-alpha
*
* Copyright 2019 Michiel Borkent
*
* Licensed under Eclipse Public License;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://github.com/borkdude/sci/blob/master/LICENSE
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an \"AS IS\" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

(function (definition) {
// This file will function properly as a <script> tag, or a module
// using CommonJS and NodeJS or RequireJS module formats. In
// Common/Node/RequireJS, the module exports the sci API and when
// executed as a simple <script>, it creates a sci global
// instead.

// Wrapper gratefully adapted from:
// https://github.com/kriskowal/q/blob/v1/q.js
// https://github.com/swannodette/mori/blob/master/support/wrapper.js
// https://github.com/tonsky/datascript/tree/master/release-js

// CommonJS
if (typeof exports === \"object\") {
module.exports = definition();

// RequireJS
} else if (typeof define === \"function\" && define.amd) {
define(definition);

// <script>
} else {
sci = definition();
}
})(function () {
return function () {

%s
return this.sci.impl.js;

}.call({});

});"}
5 changes: 5 additions & 0 deletions script/compile-js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -Eeo pipefail

clojure -A:cljs-build
10 changes: 10 additions & 0 deletions src/clojure/data/json.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(ns clojure.data.json)

;; TODO implemenent necessary API

(defn read-str [s & {:keys [key-fn]}]
;; FIXME key-fn is not exactly keywordize-keys?
(js->clj (.parse js/JSON) (if key-fn true false)))

(defn write-str [data]
(.stringify js/JSON (clj->js data)))
110 changes: 0 additions & 110 deletions src/cognitect/aws/client.clj

This file was deleted.

59 changes: 59 additions & 0 deletions src/cognitect/aws/client.cljc
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
;; Copyright (c) Cognitect, Inc.
;; All rights reserved.

(ns ^:skip-wiki cognitect.aws.client
"Impl, don't call directly."
(:require [clojure.core.async :as a]
[cognitect.aws.util :as util]))

#?(:clj (set! *warn-on-reflection* true))

(defprotocol ClientSPI
(-get-info [_] "Intended for internal use only"))

(deftype Client [client-meta info]
clojure.lang.IObj
(meta [_] @client-meta)
(withMeta [this m] (swap! client-meta merge m) this)

ClientSPI
(-get-info [_] info))

(defmulti build-http-request
"AWS request -> HTTP request."
(fn [service op-map]
(get-in service [:metadata :protocol])))

(defmulti parse-http-response
"HTTP response -> AWS response"
(fn [service op-map http-response]
(get-in service [:metadata :protocol])))

(defmulti sign-http-request
"Sign the HTTP request."
(fn [service endpoint credentials http-request]
(get-in service [:metadata :signatureVersion])))

;; TODO convey throwable back from impl
(defn ^:private handle-http-response
[service op-map http-response]
(try
(if (:cognitect.anomalies/category http-response)
http-response
(parse-http-response service op-map http-response))
(catch Throwable t
{:cognitect.anomalies/category :cognitect.anomalies/fault
::throwable t})))

(defn ^:private with-endpoint [req {:keys [protocol
hostname
port
path]
:as endpoint}]
(cond-> (-> req
(assoc-in [:headers "host"] hostname)
(assoc :server-name hostname))
protocol (assoc :scheme protocol)
port (assoc :server-port port)
path (assoc :uri path)))

Loading