diff --git a/spago.lock b/spago.lock index fc21f73..6bf3b55 100644 --- a/spago.lock +++ b/spago.lock @@ -3,47 +3,50 @@ workspace: postgresql: path: ./ dependencies: - - aff: ">=7.1.0 <8.0.0" - - aff-promise: ">=4.0.0 <5.0.0" - - arrays: ">=7.3.0 <8.0.0" - - bifunctors: ">=6.0.0 <7.0.0" - - control: ">=6.0.0 <7.0.0" - - datetime: ">=6.1.0 <7.0.0" - - effect: ">=4.0.0 <5.0.0" - - either: ">=6.1.0 <7.0.0" - - exceptions: ">=6.0.0 <7.0.0" - - foldable-traversable: ">=6.0.0 <7.0.0" - - foreign: ">=7.0.0 <8.0.0" - - fork: ">=6.0.0 <7.0.0" - - integers: ">=6.0.0 <7.0.0" - - js-bigints: ">=2.2.1 <3.0.0" - - lists: ">=7.0.0 <8.0.0" - - maybe: ">=6.0.0 <7.0.0" - - mmorph: ">=7.0.0 <8.0.0" - - newtype: ">=5.0.0 <6.0.0" - - node-buffer: ">=9.0.0 <10.0.0" - - node-event-emitter: ">=3.0.0 <4.0.0" - - node-streams: ">=9.0.0 <10.0.0" - - nullable: ">=6.0.0 <7.0.0" - - parallel: ">=6.0.0 <7.0.0" - - partial: ">=4.0.0 <5.0.0" - - precise-datetime: ">=7.0.0 <8.0.0" - - prelude: ">=6.0.1 <7.0.0" - - profunctor: ">=6.0.1 <7.0.0" - - record: ">=4.0.0 <5.0.0" - - simple-json: ">=9.0.0 <10.0.0" - - strings: ">=6.0.1 <7.0.0" - - tailrec: ">=6.1.0 <7.0.0" - - transformers: ">=6.0.0 <7.0.0" - - tuples: ">=7.0.0 <8.0.0" - - typelevel-prelude: ">=7.0.0 <8.0.0" - - unlift: ">=1.0.1 <2.0.0" - - unsafe-coerce: ">=6.0.0 <7.0.0" + - aff + - aff-promise + - arrays + - bifunctors + - control + - datetime + - effect + - either + - exceptions + - foldable-traversable + - foreign + - fork + - integers + - js-bigints + - lists + - maybe + - mmorph + - newtype + - node-buffer + - node-event-emitter + - node-stream-pipes + - node-streams + - nullable + - parallel + - partial + - pipes + - precise-datetime + - prelude + - profunctor + - record + - simple-json + - strings + - tailrec + - transformers + - tuples + - typelevel-prelude + - unlift + - unsafe-coerce test_dependencies: - filterable - foreign-object - node-child-process - node-process + - precise-datetime - quickcheck - spec - spec-quickcheck @@ -99,7 +102,9 @@ workspace: - node-os - node-path - node-process + - node-stream-pipes - node-streams + - node-zlib - nonempty - now - nullable @@ -720,6 +725,35 @@ packages: - posix-types - prelude - unsafe-coerce + node-stream-pipes: + type: registry + version: 1.0.2 + integrity: sha256-JC5eIR1mFq3wuALBwezoQnJdXw4a4XoHfu8vtMu8xUI= + dependencies: + - aff + - arrays + - effect + - either + - exceptions + - foldable-traversable + - maybe + - mmorph + - newtype + - node-buffer + - node-event-emitter + - node-fs + - node-path + - node-streams + - node-zlib + - parallel + - pipes + - prelude + - st + - strings + - tailrec + - transformers + - tuples + - unsafe-coerce node-streams: type: registry version: 9.0.0 @@ -733,6 +767,19 @@ packages: - node-event-emitter - nullable - prelude + node-zlib: + type: registry + version: 0.4.0 + integrity: sha256-kYSajFQFzWVg71l5/y4w4kXdTr5EJoqyV3D2RqmAjQ4= + dependencies: + - aff + - effect + - either + - functions + - node-buffer + - node-streams + - prelude + - unsafe-coerce nonempty: type: registry version: 7.0.0 diff --git a/spago.yaml b/spago.yaml index da68115..d07ff3b 100644 --- a/spago.yaml +++ b/spago.yaml @@ -13,42 +13,44 @@ package: strict: true pedanticPackages: true dependencies: - - aff: ">=7.1.0 <8.0.0" - - aff-promise: ">=4.0.0 <5.0.0" - - arrays: ">=7.3.0 <8.0.0" - - bifunctors: ">=6.0.0 <7.0.0" - - control: ">=6.0.0 <7.0.0" - - datetime: ">=6.1.0 <7.0.0" - - effect: ">=4.0.0 <5.0.0" - - either: ">=6.1.0 <7.0.0" - - exceptions: ">=6.0.0 <7.0.0" - - foldable-traversable: ">=6.0.0 <7.0.0" - - foreign: ">=7.0.0 <8.0.0" - - fork: ">=6.0.0 <7.0.0" - - integers: ">=6.0.0 <7.0.0" - - js-bigints: ">=2.2.1 <3.0.0" - - lists: ">=7.0.0 <8.0.0" - - maybe: ">=6.0.0 <7.0.0" - - mmorph: ">=7.0.0 <8.0.0" - - newtype: ">=5.0.0 <6.0.0" - - node-buffer: ">=9.0.0 <10.0.0" - - node-event-emitter: ">=3.0.0 <4.0.0" - - node-streams: ">=9.0.0 <10.0.0" - - nullable: ">=6.0.0 <7.0.0" - - parallel: ">=6.0.0 <7.0.0" - - partial: ">=4.0.0 <5.0.0" - - precise-datetime: ">=7.0.0 <8.0.0" - - prelude: ">=6.0.1 <7.0.0" - - profunctor: ">=6.0.1 <7.0.0" - - record: ">=4.0.0 <5.0.0" - - simple-json: ">=9.0.0 <10.0.0" - - strings: ">=6.0.1 <7.0.0" - - tailrec: ">=6.1.0 <7.0.0" - - transformers: ">=6.0.0 <7.0.0" - - tuples: ">=7.0.0 <8.0.0" - - typelevel-prelude: ">=7.0.0 <8.0.0" - - unlift: ">=1.0.1 <2.0.0" - - unsafe-coerce: ">=6.0.0 <7.0.0" + - aff + - aff-promise + - arrays + - bifunctors + - control + - datetime + - effect + - either + - exceptions + - foldable-traversable + - foreign + - fork + - integers + - js-bigints + - lists + - maybe + - mmorph + - newtype + - node-buffer + - node-event-emitter + - node-stream-pipes + - node-streams + - nullable + - parallel + - partial + - pipes + - precise-datetime + - prelude + - profunctor + - record + - simple-json + - strings + - tailrec + - transformers + - tuples + - typelevel-prelude + - unlift + - unsafe-coerce test: main: Test.Main dependencies: @@ -56,6 +58,7 @@ package: - foreign-object - node-child-process - node-process + - precise-datetime - quickcheck - spec - spec-quickcheck diff --git a/src/Data.Postgres.Custom.purs b/src/Data.Postgres.Custom.purs index aae6826..b6164e0 100644 --- a/src/Data.Postgres.Custom.purs +++ b/src/Data.Postgres.Custom.purs @@ -2,20 +2,13 @@ module Data.Postgres.Custom where import Prelude -import Control.Monad.Except (ExceptT) import Data.Either (hush) -import Data.List.NonEmpty (NonEmptyList) -import Data.Maybe (Maybe, fromJust) -import Data.Postgres.Raw (Raw) +import Data.Maybe (fromJust) import Data.String as String import Data.String.Regex (Regex) import Data.String.Regex as Regex import Data.String.Regex.Flags as Regex.Flags -import Effect (Effect) -import Foreign (ForeignError) import Partial.Unsafe (unsafePartial) -import Type.Data.Symbol (reflectSymbol) -import Type.Prelude (class IsSymbol, Proxy(..)) quoted :: String -> String quoted s = "'" <> s <> "'" diff --git a/src/Pipes.Postgres.purs b/src/Pipes.Postgres.purs new file mode 100644 index 0000000..3b4e248 --- /dev/null +++ b/src/Pipes.Postgres.purs @@ -0,0 +1,23 @@ +module Pipes.Postgres where + +import Prelude + +import Control.Monad.Morph (hoist) +import Control.Monad.Postgres.Session (class MonadSession, streamIn, streamOut) +import Control.Monad.Trans.Class (lift) +import Data.Maybe (Maybe) +import Effect.Aff.Class (liftAff) +import Node.Buffer (Buffer) +import Node.Stream.Object as O +import Pipes.Core (Consumer, Producer) +import Pipes.Node.Stream (fromReadable, fromWritable) + +stdin :: forall m. MonadSession m => String -> Consumer (Maybe Buffer) m Unit +stdin q = do + stream <- lift $ streamIn q + hoist liftAff $ fromWritable $ O.fromBufferWritable stream + +stdout :: forall m. MonadSession m => String -> Producer (Maybe Buffer) m Unit +stdout q = do + stream <- lift $ streamOut q + hoist liftAff $ fromReadable $ O.fromBufferReadable stream