generated from tpl/purs
Upgarde to purs-15
This commit is contained in:
parent
0019baea2f
commit
343ea87283
78
flake.lock
Normal file
78
flake.lock
Normal file
@ -0,0 +1,78 @@
|
||||
{
|
||||
"nodes": {
|
||||
"easyPSSrc": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1671011575,
|
||||
"narHash": "sha256-tESal32bcqqdZO+aKnBzc1GoL2mtnaDtj2y7ociCRGA=",
|
||||
"owner": "justinwoo",
|
||||
"repo": "easy-purescript-nix",
|
||||
"rev": "11d3bd58ce6e32703bf69cec04dc7c38eabe14ba",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "justinwoo",
|
||||
"repo": "easy-purescript-nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1644229661,
|
||||
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flakeUtils": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1657226504,
|
||||
"narHash": "sha256-GIYNjuq4mJlFgqKsZ+YrgzWm0IpA4axA3MCrdKYj7gs=",
|
||||
"owner": "gytis-ivaskevicius",
|
||||
"repo": "flake-utils-plus",
|
||||
"rev": "2bf0f91643c2e5ae38c1b26893ac2927ac9bd82a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "gytis-ivaskevicius",
|
||||
"repo": "flake-utils-plus",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1669809720,
|
||||
"narHash": "sha256-RMT77f6CPOYtLLQ2esj+EJ1BPVWxf4RDidjrSvA5OhI=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "227de2b3bbec142f912c09d5e8a1b4e778aa54fb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"easyPSSrc": "easyPSSrc",
|
||||
"flakeUtils": "flakeUtils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
62
flake.nix
Normal file
62
flake.nix
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
# nixConfig = {
|
||||
# bash-prompt-suffix = "[dev]";
|
||||
# };
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||
flakeUtils.url = "github:gytis-ivaskevicius/flake-utils-plus";
|
||||
easyPSSrc = {
|
||||
flake = false;
|
||||
url = "github:justinwoo/easy-purescript-nix";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flakeUtils, easyPSSrc }:
|
||||
flakeUtils.lib.eachSystem ["x86_64-linux"] (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
easyPS = pkgs.callPackage easyPSSrc { inherit pkgs; };
|
||||
nodejs-16 = pkgs.writeShellScriptBin "nodejs-16" ''
|
||||
${ pkgs.nodejs-16_x.out}/bin/node $@
|
||||
'';
|
||||
in {
|
||||
devShell = pkgs.mkShell {
|
||||
buildInputs = [
|
||||
|
||||
# Please update spago and purescript in `package.json` `scripts` section
|
||||
easyPS."purs-0_15_7"
|
||||
easyPS.purescript-language-server
|
||||
easyPS.pscid
|
||||
easyPS.purs-tidy
|
||||
easyPS.pulp
|
||||
easyPS.spago
|
||||
|
||||
pkgs.jq
|
||||
pkgs.docker
|
||||
pkgs.nodePackages.bower
|
||||
pkgs.nodePackages.jshint
|
||||
pkgs.nodePackages.nodemon
|
||||
pkgs.nodePackages.yarn
|
||||
pkgs.nodePackages.webpack
|
||||
pkgs.nodePackages.webpack-cli
|
||||
pkgs.nodePackages.webpack-dev-server
|
||||
pkgs.dhall
|
||||
pkgs.nodejs-18_x
|
||||
nodejs-16
|
||||
pkgs.pkgconfig
|
||||
pkgs.postgresql
|
||||
pkgs.python27
|
||||
pkgs.python37
|
||||
pkgs.unzip
|
||||
pkgs.nixpacks
|
||||
];
|
||||
shellHook = ''
|
||||
npm install
|
||||
NODE_OPTIONS=--experimental-fetch --trace-warnings
|
||||
export PATH=$PATH:./node_modules/.bin/:./bin
|
||||
export PS1="\n\[\033[1;32m\][nix develop:\w]\$\[\033[0m\] ";
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
@ -2,7 +2,8 @@
|
||||
"name": "purescript-postgresql-client",
|
||||
"dependencies": {
|
||||
"decimal.js": "^10.0.0",
|
||||
"pg": "^6.4.2",
|
||||
"pg": "^8.9.0",
|
||||
"pg-native": "^3.0.1",
|
||||
"postgres": "^1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
175
packages.dhall
175
packages.dhall
@ -1,75 +1,106 @@
|
||||
let mkPackage =
|
||||
https://raw.githubusercontent.com/purescript/package-sets/psc-0.13.0-20190626/src/mkPackage.dhall sha256:0b197efa1d397ace6eb46b243ff2d73a3da5638d8d0ac8473e8e4a8fc528cf57
|
||||
|
||||
let upstream =
|
||||
https://github.com/purescript/package-sets/releases/download/psc-0.14.1-20210506/packages.dhall sha256:d199e142515f9cc15838d8e6d724a98cd0ca776ceb426b7b36e841311643e3ef
|
||||
https://github.com/purescript/package-sets/releases/download/psc-0.15.4-20221201/packages.dhall
|
||||
sha256:d1a68fa15709eaa686515eb5b9950d82c743f7bf73e3d87a4abe9e1be6fda571
|
||||
|
||||
in upstream
|
||||
with polyform =
|
||||
{ dependencies =
|
||||
[ "arrays"
|
||||
, "bifunctors"
|
||||
, "control"
|
||||
, "effect"
|
||||
, "either"
|
||||
, "enums"
|
||||
, "functors"
|
||||
, "identity"
|
||||
, "invariant"
|
||||
, "lists"
|
||||
, "maybe"
|
||||
, "newtype"
|
||||
, "parallel"
|
||||
, "partial"
|
||||
, "prelude"
|
||||
, "profunctor"
|
||||
, "psci-support"
|
||||
, "quickcheck"
|
||||
, "quickcheck-laws"
|
||||
, "record"
|
||||
, "transformers"
|
||||
, "tuples"
|
||||
, "typelevel-prelude"
|
||||
, "unsafe-coerce"
|
||||
, "validation"
|
||||
, "variant"
|
||||
]
|
||||
, repo = "https://github.com/purescript-polyform/polyform.git"
|
||||
, version = "v0.9.0"
|
||||
}
|
||||
with polyform-batteries-core =
|
||||
{ dependencies =
|
||||
[ "arrays"
|
||||
, "decimals"
|
||||
, "effect"
|
||||
, "enums"
|
||||
, "integers"
|
||||
, "lazy"
|
||||
, "maybe"
|
||||
, "numbers"
|
||||
, "partial"
|
||||
, "polyform"
|
||||
, "prelude"
|
||||
, "psci-support"
|
||||
, "quickcheck"
|
||||
, "strings"
|
||||
, "test-unit"
|
||||
, "typelevel-prelude"
|
||||
, "validation"
|
||||
, "variant"
|
||||
]
|
||||
, repo = "https://github.com/purescript-polyform/batteries-core.git"
|
||||
, version = "v0.2.0"
|
||||
}
|
||||
with polyform-batteries-env =
|
||||
{ dependencies =
|
||||
[ "arrays"
|
||||
, "identity"
|
||||
, "maybe"
|
||||
, "ordered-collections"
|
||||
, "polyform"
|
||||
, "polyform-batteries-core"
|
||||
, "prelude"
|
||||
, "psci-support"
|
||||
, "typelevel-prelude"
|
||||
]
|
||||
, repo = "https://github.com/purescript-polyform/batteries-env.git"
|
||||
, version = "v0.1.0"
|
||||
}
|
||||
with
|
||||
polyform =
|
||||
mkPackage
|
||||
[ "heterogeneous", "js-unsafe-stringify", "newtype" ,"ordered-collections"
|
||||
, "variant", "profunctor", "invariant", "foreign-object"
|
||||
, "run", "transformers","validation", "foreign"
|
||||
]
|
||||
"https://github.com/purescript-polyform/polyform.git"
|
||||
"v0.9.2"
|
||||
|
||||
with
|
||||
polyform-batteries-core = mkPackage
|
||||
[ "debug", "decimals", "filterable", "numbers"
|
||||
, "polyform", "prelude", "record-extra", "test-unit"
|
||||
]
|
||||
"https://github.com/purescript-polyform/batteries-core.git"
|
||||
"v0.3.0"
|
||||
with
|
||||
polyform-batteries-urlencoded =
|
||||
mkPackage
|
||||
[ "argonaut" , "console" , "debug" , "effect" , "form-urlencoded"
|
||||
, "polyform-batteries-core" , "psci-support" , "spec"
|
||||
]
|
||||
"https://github.com/purescript-polyform/batteries-urlencoded.git"
|
||||
"v0.4.1"
|
||||
with polyform-batteries-env =
|
||||
{ dependencies =
|
||||
[ "arrays"
|
||||
, "identity"
|
||||
, "maybe"
|
||||
, "ordered-collections"
|
||||
, "polyform"
|
||||
, "polyform-batteries-core"
|
||||
, "prelude"
|
||||
, "psci-support"
|
||||
, "typelevel-prelude"
|
||||
]
|
||||
, repo = "https://github.com/purescript-polyform/batteries-env.git"
|
||||
, version = "v0.2.0"
|
||||
}
|
||||
with bytestrings =
|
||||
mkPackage
|
||||
[ "arrays"
|
||||
, "console"
|
||||
, "effect"
|
||||
, "exceptions"
|
||||
, "foldable-traversable"
|
||||
, "integers"
|
||||
, "leibniz"
|
||||
, "maybe"
|
||||
, "newtype"
|
||||
, "node-buffer"
|
||||
, "partial"
|
||||
, "prelude"
|
||||
, "quickcheck"
|
||||
, "quickcheck-laws"
|
||||
, "quotient"
|
||||
, "unsafe-coerce"
|
||||
]
|
||||
"https://github.com/martyall/purescript-bytestrings.git"
|
||||
"e51cf868a4137c1c48c98d32115bb2014c9f7624"
|
||||
with quotient =
|
||||
mkPackage
|
||||
[ "prelude", "quickcheck" ]
|
||||
"https://github.com/rightfold/purescript-quotient.git"
|
||||
"v3.0.0"
|
||||
with foreign-generic =
|
||||
mkPackage
|
||||
[ "arrays"
|
||||
, "assert"
|
||||
, "bifunctors"
|
||||
, "console"
|
||||
, "control"
|
||||
, "effect"
|
||||
, "either"
|
||||
, "exceptions"
|
||||
, "foldable-traversable"
|
||||
, "foreign"
|
||||
, "foreign-object"
|
||||
, "identity"
|
||||
, "lists"
|
||||
, "maybe"
|
||||
, "newtype"
|
||||
, "partial"
|
||||
, "prelude"
|
||||
, "record"
|
||||
, "strings"
|
||||
, "transformers"
|
||||
, "tuples"
|
||||
, "unsafe-coerce"
|
||||
]
|
||||
"https://github.com/paluh/purescript-foreign-generic.git"
|
||||
"a5c23d29e72619624978446293ac9bb45ccd2fde"
|
||||
with js-unsafe-stringify =
|
||||
mkPackage
|
||||
([] : List Text)
|
||||
"https://github.com/paluh/purescript-js-unsafe-stringify.git"
|
||||
"master"
|
||||
|
@ -8,6 +8,7 @@
|
||||
, "bifunctors"
|
||||
, "bytestrings"
|
||||
, "datetime"
|
||||
, "debug"
|
||||
, "decimals"
|
||||
, "dotenv"
|
||||
, "effect"
|
||||
@ -21,12 +22,13 @@
|
||||
, "identity"
|
||||
, "integers"
|
||||
, "js-date"
|
||||
, "js-unsafe-stringify"
|
||||
, "lists"
|
||||
, "math"
|
||||
, "maybe"
|
||||
, "newtype"
|
||||
, "node-process"
|
||||
, "nullable"
|
||||
, "numbers"
|
||||
, "ordered-collections"
|
||||
, "partial"
|
||||
, "polyform"
|
||||
|
@ -1,21 +1,19 @@
|
||||
/* global exports, require */
|
||||
/* jshint -W097 */
|
||||
|
||||
'use strict';
|
||||
|
||||
// `pg related code/bindings are done here as we want to
|
||||
// allow frontend modules to access `PostgreSQL.*` classes too.
|
||||
// Putting this import into `PostgreSQL/Value.js` caused is a problem
|
||||
// for the web bundlers etc.
|
||||
|
||||
var pg = require('pg');
|
||||
import pg from 'pg';
|
||||
|
||||
// pg does strange thing converting DATE
|
||||
// value to js Date, so we have
|
||||
// to prevent this craziness
|
||||
pg.types.setTypeParser(1082 /* DATE_OID */, function(dateString) { return dateString; });
|
||||
|
||||
exports.ffiConnect = function (config) {
|
||||
export const ffiConnect = function (config) {
|
||||
return function (pool) {
|
||||
return function (onError, onSuccess) {
|
||||
var p = pool.connect().then(function(client) {
|
||||
@ -42,7 +40,7 @@ exports.ffiConnect = function (config) {
|
||||
};
|
||||
};
|
||||
|
||||
exports.ffiUnsafeQuery = function(config) {
|
||||
export const ffiUnsafeQuery = function(config) {
|
||||
// Either `Pool` or `Client` instance
|
||||
return function(dbHandle) {
|
||||
return function(sql) {
|
||||
@ -73,11 +71,11 @@ exports.ffiUnsafeQuery = function(config) {
|
||||
};
|
||||
};
|
||||
|
||||
exports.ffiSQLState = function (error) {
|
||||
export const ffiSQLState = function (error) {
|
||||
return error.code || null;
|
||||
};
|
||||
|
||||
exports.ffiErrorDetail = function (error) {
|
||||
export const ffiErrorDetail = function (error) {
|
||||
return {
|
||||
error: error,
|
||||
severity: error.severity || '',
|
||||
|
@ -34,7 +34,6 @@ import Data.Profunctor (lcmap)
|
||||
import Data.Show.Generic (genericShow)
|
||||
import Data.String (Pattern(..))
|
||||
import Data.String as String
|
||||
import Data.Symbol (SProxy(..))
|
||||
import Data.Traversable (traverse)
|
||||
import Database.PostgreSQL.Pool (Pool)
|
||||
import Database.PostgreSQL.Row (class FromSQLRow, class ToSQLRow, Row0(..), Row1(..), fromSQLRow, toSQLRow)
|
||||
@ -46,6 +45,7 @@ import Effect.Class (liftEffect)
|
||||
import Effect.Exception (Error)
|
||||
import Foreign (Foreign)
|
||||
import Record (delete) as Record
|
||||
import Type.Proxy (Proxy(..))
|
||||
import Unsafe.Coerce (unsafeCoerce)
|
||||
|
||||
-- | PostgreSQL connection.
|
||||
@ -303,7 +303,7 @@ instance eqPGError :: Eq PGError where
|
||||
where
|
||||
eqErr err1 err2 =
|
||||
let
|
||||
_error = SProxy :: SProxy "error"
|
||||
_error = Proxy :: Proxy "error"
|
||||
in
|
||||
eq (Record.delete _error err1) (Record.delete _error err2)
|
||||
|
||||
|
@ -1,27 +1,25 @@
|
||||
var pg = require('pg');
|
||||
import pg from 'pg';
|
||||
|
||||
"use sctrict";
|
||||
|
||||
exports.ffiNew = function(config) {
|
||||
export const ffiNew = function(config) {
|
||||
return function() {
|
||||
return new pg.Pool(config);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
exports.totalCount = function(pool) {
|
||||
export const totalCount = function(pool) {
|
||||
return function() {
|
||||
return pool.totalCount;
|
||||
};
|
||||
};
|
||||
|
||||
exports.idleCount = function(pool) {
|
||||
export const idleCount = function(pool) {
|
||||
return function() {
|
||||
return pool.idleCount;
|
||||
};
|
||||
};
|
||||
|
||||
exports.waitingCount = function(pool) {
|
||||
export const waitingCount = function(pool) {
|
||||
return function() {
|
||||
return pool.waitingCount;
|
||||
};
|
||||
|
@ -21,9 +21,9 @@ import Data.Nullable (Nullable, toNullable)
|
||||
import Data.String.CodeUnits (singleton)
|
||||
import Data.Traversable (foldMap)
|
||||
import Effect (Effect)
|
||||
import Text.Parsing.StringParser (runParser)
|
||||
import Text.Parsing.StringParser.CodePoints (anyChar, char, string)
|
||||
import Text.Parsing.StringParser.Combinators (many, manyTill)
|
||||
import StringParser (runParser)
|
||||
import StringParser.CodePoints (anyChar, char, string)
|
||||
import StringParser.Combinators (many, manyTill)
|
||||
|
||||
-- | PostgreSQL connection pool.
|
||||
foreign import data Pool :: Type
|
||||
|
@ -1,15 +1,13 @@
|
||||
/* global Buffer, exports, require */
|
||||
/* jshint -W097 */
|
||||
|
||||
'use strict';
|
||||
export const null_ = null;
|
||||
|
||||
exports['null'] = null;
|
||||
|
||||
exports.instantToString = function(i) {
|
||||
export const instantToString = function(i) {
|
||||
return new Date(i).toUTCString();
|
||||
};
|
||||
|
||||
exports.instantFromString = function(Left) {
|
||||
export const instantFromString = function(Left) {
|
||||
return function(Right) {
|
||||
return function(s) {
|
||||
try {
|
||||
@ -21,6 +19,6 @@ exports.instantFromString = function(Left) {
|
||||
};
|
||||
};
|
||||
|
||||
exports.unsafeIsBuffer = function(x) {
|
||||
export const unsafeIsBuffer = function(x) {
|
||||
return x instanceof Buffer;
|
||||
};
|
||||
|
@ -183,7 +183,10 @@ else instance toSQLValueJson :: ToSQLValue Json where
|
||||
newtypeToSQLValue ∷ ∀ a b. Newtype a b ⇒ ToSQLValue b ⇒ a → Foreign
|
||||
newtypeToSQLValue = unwrap >>> toSQLValue
|
||||
|
||||
foreign import null :: Foreign
|
||||
null :: Foreign
|
||||
null = null_
|
||||
|
||||
foreign import null_ :: Foreign
|
||||
foreign import instantToString :: Instant -> Foreign
|
||||
foreign import instantFromString :: (String -> Either String Number) -> (Number -> Either String Number) -> Foreign -> Either String Number
|
||||
foreign import unsafeIsBuffer :: ∀ a. a -> Boolean
|
||||
|
@ -1,5 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
exports.unsafeStringify = function (x) {
|
||||
return JSON.stringify(x);
|
||||
}
|
@ -3,6 +3,7 @@ module Test.Main
|
||||
) where
|
||||
|
||||
import Prelude
|
||||
|
||||
import Control.Monad.Error.Class (throwError, try)
|
||||
import Control.Monad.Except.Trans (runExceptT)
|
||||
import Control.Monad.Trans.Class (lift)
|
||||
@ -19,19 +20,21 @@ import Data.JSDate (JSDate, jsdate, toInstant)
|
||||
import Data.JSDate as JSDate
|
||||
import Data.Maybe (Maybe(..), fromJust)
|
||||
import Data.Newtype (unwrap)
|
||||
import Data.Number ((%))
|
||||
import Data.Tuple (Tuple(..))
|
||||
import Data.Tuple.Nested ((/\))
|
||||
import Database.PostgreSQL (Client, Configuration, Connection(..), PGConnectionURI, PGError(..), Pool, Query(Query), Row0(Row0), Row1(Row1), Row2(Row2), Row3(Row3), Row9(Row9), fromClient, fromPool, parseURI)
|
||||
import Database.PostgreSQL.PG (command, execute, onIntegrityError, query, scalar)
|
||||
import Database.PostgreSQL.PG (withClient, withClientTransaction) as PG
|
||||
import Database.PostgreSQL.Pool (new) as Pool
|
||||
import Debug (traceM)
|
||||
import Effect (Effect)
|
||||
import Effect.Aff (Aff, error, launchAff)
|
||||
import Effect.Class (liftEffect)
|
||||
import Effect.Exception (message)
|
||||
import Foreign.Object (Object)
|
||||
import Foreign.Object (fromFoldable) as Object
|
||||
import Math ((%))
|
||||
import JS.Unsafe.Stringify (unsafeStringify)
|
||||
import Partial.Unsafe (unsafePartial)
|
||||
import Test.Assert (assert)
|
||||
import Test.Config (load) as Config
|
||||
@ -504,4 +507,3 @@ validUriToPoolConfigs =
|
||||
notValidConnUri :: PGConnectionURI
|
||||
notValidConnUri = "postgres://urllgqrivcyakoc52275a95b7f177e2850c49de9bfa8bedc457ce860ccca664cb15db973554969@ec2-79-124-25-231.eu-west-1.compute.amazonaws.com:5432/e7cecg4nirunpo"
|
||||
|
||||
foreign import unsafeStringify :: forall a. a -> String
|
||||
|
Loading…
Reference in New Issue
Block a user