generated from tpl/purs
feat: add node-stream-pipes support
This commit is contained in:
parent
adb414662e
commit
b3806d5f6e
119
spago.lock
119
spago.lock
@ -3,47 +3,50 @@ workspace:
|
|||||||
postgresql:
|
postgresql:
|
||||||
path: ./
|
path: ./
|
||||||
dependencies:
|
dependencies:
|
||||||
- aff: ">=7.1.0 <8.0.0"
|
- aff
|
||||||
- aff-promise: ">=4.0.0 <5.0.0"
|
- aff-promise
|
||||||
- arrays: ">=7.3.0 <8.0.0"
|
- arrays
|
||||||
- bifunctors: ">=6.0.0 <7.0.0"
|
- bifunctors
|
||||||
- control: ">=6.0.0 <7.0.0"
|
- control
|
||||||
- datetime: ">=6.1.0 <7.0.0"
|
- datetime
|
||||||
- effect: ">=4.0.0 <5.0.0"
|
- effect
|
||||||
- either: ">=6.1.0 <7.0.0"
|
- either
|
||||||
- exceptions: ">=6.0.0 <7.0.0"
|
- exceptions
|
||||||
- foldable-traversable: ">=6.0.0 <7.0.0"
|
- foldable-traversable
|
||||||
- foreign: ">=7.0.0 <8.0.0"
|
- foreign
|
||||||
- fork: ">=6.0.0 <7.0.0"
|
- fork
|
||||||
- integers: ">=6.0.0 <7.0.0"
|
- integers
|
||||||
- js-bigints: ">=2.2.1 <3.0.0"
|
- js-bigints
|
||||||
- lists: ">=7.0.0 <8.0.0"
|
- lists
|
||||||
- maybe: ">=6.0.0 <7.0.0"
|
- maybe
|
||||||
- mmorph: ">=7.0.0 <8.0.0"
|
- mmorph
|
||||||
- newtype: ">=5.0.0 <6.0.0"
|
- newtype
|
||||||
- node-buffer: ">=9.0.0 <10.0.0"
|
- node-buffer
|
||||||
- node-event-emitter: ">=3.0.0 <4.0.0"
|
- node-event-emitter
|
||||||
- node-streams: ">=9.0.0 <10.0.0"
|
- node-stream-pipes
|
||||||
- nullable: ">=6.0.0 <7.0.0"
|
- node-streams
|
||||||
- parallel: ">=6.0.0 <7.0.0"
|
- nullable
|
||||||
- partial: ">=4.0.0 <5.0.0"
|
- parallel
|
||||||
- precise-datetime: ">=7.0.0 <8.0.0"
|
- partial
|
||||||
- prelude: ">=6.0.1 <7.0.0"
|
- pipes
|
||||||
- profunctor: ">=6.0.1 <7.0.0"
|
- precise-datetime
|
||||||
- record: ">=4.0.0 <5.0.0"
|
- prelude
|
||||||
- simple-json: ">=9.0.0 <10.0.0"
|
- profunctor
|
||||||
- strings: ">=6.0.1 <7.0.0"
|
- record
|
||||||
- tailrec: ">=6.1.0 <7.0.0"
|
- simple-json
|
||||||
- transformers: ">=6.0.0 <7.0.0"
|
- strings
|
||||||
- tuples: ">=7.0.0 <8.0.0"
|
- tailrec
|
||||||
- typelevel-prelude: ">=7.0.0 <8.0.0"
|
- transformers
|
||||||
- unlift: ">=1.0.1 <2.0.0"
|
- tuples
|
||||||
- unsafe-coerce: ">=6.0.0 <7.0.0"
|
- typelevel-prelude
|
||||||
|
- unlift
|
||||||
|
- unsafe-coerce
|
||||||
test_dependencies:
|
test_dependencies:
|
||||||
- filterable
|
- filterable
|
||||||
- foreign-object
|
- foreign-object
|
||||||
- node-child-process
|
- node-child-process
|
||||||
- node-process
|
- node-process
|
||||||
|
- precise-datetime
|
||||||
- quickcheck
|
- quickcheck
|
||||||
- spec
|
- spec
|
||||||
- spec-quickcheck
|
- spec-quickcheck
|
||||||
@ -99,7 +102,9 @@ workspace:
|
|||||||
- node-os
|
- node-os
|
||||||
- node-path
|
- node-path
|
||||||
- node-process
|
- node-process
|
||||||
|
- node-stream-pipes
|
||||||
- node-streams
|
- node-streams
|
||||||
|
- node-zlib
|
||||||
- nonempty
|
- nonempty
|
||||||
- now
|
- now
|
||||||
- nullable
|
- nullable
|
||||||
@ -720,6 +725,35 @@ packages:
|
|||||||
- posix-types
|
- posix-types
|
||||||
- prelude
|
- prelude
|
||||||
- unsafe-coerce
|
- 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:
|
node-streams:
|
||||||
type: registry
|
type: registry
|
||||||
version: 9.0.0
|
version: 9.0.0
|
||||||
@ -733,6 +767,19 @@ packages:
|
|||||||
- node-event-emitter
|
- node-event-emitter
|
||||||
- nullable
|
- nullable
|
||||||
- prelude
|
- 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:
|
nonempty:
|
||||||
type: registry
|
type: registry
|
||||||
version: 7.0.0
|
version: 7.0.0
|
||||||
|
75
spago.yaml
75
spago.yaml
@ -13,42 +13,44 @@ package:
|
|||||||
strict: true
|
strict: true
|
||||||
pedanticPackages: true
|
pedanticPackages: true
|
||||||
dependencies:
|
dependencies:
|
||||||
- aff: ">=7.1.0 <8.0.0"
|
- aff
|
||||||
- aff-promise: ">=4.0.0 <5.0.0"
|
- aff-promise
|
||||||
- arrays: ">=7.3.0 <8.0.0"
|
- arrays
|
||||||
- bifunctors: ">=6.0.0 <7.0.0"
|
- bifunctors
|
||||||
- control: ">=6.0.0 <7.0.0"
|
- control
|
||||||
- datetime: ">=6.1.0 <7.0.0"
|
- datetime
|
||||||
- effect: ">=4.0.0 <5.0.0"
|
- effect
|
||||||
- either: ">=6.1.0 <7.0.0"
|
- either
|
||||||
- exceptions: ">=6.0.0 <7.0.0"
|
- exceptions
|
||||||
- foldable-traversable: ">=6.0.0 <7.0.0"
|
- foldable-traversable
|
||||||
- foreign: ">=7.0.0 <8.0.0"
|
- foreign
|
||||||
- fork: ">=6.0.0 <7.0.0"
|
- fork
|
||||||
- integers: ">=6.0.0 <7.0.0"
|
- integers
|
||||||
- js-bigints: ">=2.2.1 <3.0.0"
|
- js-bigints
|
||||||
- lists: ">=7.0.0 <8.0.0"
|
- lists
|
||||||
- maybe: ">=6.0.0 <7.0.0"
|
- maybe
|
||||||
- mmorph: ">=7.0.0 <8.0.0"
|
- mmorph
|
||||||
- newtype: ">=5.0.0 <6.0.0"
|
- newtype
|
||||||
- node-buffer: ">=9.0.0 <10.0.0"
|
- node-buffer
|
||||||
- node-event-emitter: ">=3.0.0 <4.0.0"
|
- node-event-emitter
|
||||||
- node-streams: ">=9.0.0 <10.0.0"
|
- node-stream-pipes
|
||||||
- nullable: ">=6.0.0 <7.0.0"
|
- node-streams
|
||||||
- parallel: ">=6.0.0 <7.0.0"
|
- nullable
|
||||||
- partial: ">=4.0.0 <5.0.0"
|
- parallel
|
||||||
- precise-datetime: ">=7.0.0 <8.0.0"
|
- partial
|
||||||
- prelude: ">=6.0.1 <7.0.0"
|
- pipes
|
||||||
- profunctor: ">=6.0.1 <7.0.0"
|
- precise-datetime
|
||||||
- record: ">=4.0.0 <5.0.0"
|
- prelude
|
||||||
- simple-json: ">=9.0.0 <10.0.0"
|
- profunctor
|
||||||
- strings: ">=6.0.1 <7.0.0"
|
- record
|
||||||
- tailrec: ">=6.1.0 <7.0.0"
|
- simple-json
|
||||||
- transformers: ">=6.0.0 <7.0.0"
|
- strings
|
||||||
- tuples: ">=7.0.0 <8.0.0"
|
- tailrec
|
||||||
- typelevel-prelude: ">=7.0.0 <8.0.0"
|
- transformers
|
||||||
- unlift: ">=1.0.1 <2.0.0"
|
- tuples
|
||||||
- unsafe-coerce: ">=6.0.0 <7.0.0"
|
- typelevel-prelude
|
||||||
|
- unlift
|
||||||
|
- unsafe-coerce
|
||||||
test:
|
test:
|
||||||
main: Test.Main
|
main: Test.Main
|
||||||
dependencies:
|
dependencies:
|
||||||
@ -56,6 +58,7 @@ package:
|
|||||||
- foreign-object
|
- foreign-object
|
||||||
- node-child-process
|
- node-child-process
|
||||||
- node-process
|
- node-process
|
||||||
|
- precise-datetime
|
||||||
- quickcheck
|
- quickcheck
|
||||||
- spec
|
- spec
|
||||||
- spec-quickcheck
|
- spec-quickcheck
|
||||||
|
@ -2,20 +2,13 @@ module Data.Postgres.Custom where
|
|||||||
|
|
||||||
import Prelude
|
import Prelude
|
||||||
|
|
||||||
import Control.Monad.Except (ExceptT)
|
|
||||||
import Data.Either (hush)
|
import Data.Either (hush)
|
||||||
import Data.List.NonEmpty (NonEmptyList)
|
import Data.Maybe (fromJust)
|
||||||
import Data.Maybe (Maybe, fromJust)
|
|
||||||
import Data.Postgres.Raw (Raw)
|
|
||||||
import Data.String as String
|
import Data.String as String
|
||||||
import Data.String.Regex (Regex)
|
import Data.String.Regex (Regex)
|
||||||
import Data.String.Regex as Regex
|
import Data.String.Regex as Regex
|
||||||
import Data.String.Regex.Flags as Regex.Flags
|
import Data.String.Regex.Flags as Regex.Flags
|
||||||
import Effect (Effect)
|
|
||||||
import Foreign (ForeignError)
|
|
||||||
import Partial.Unsafe (unsafePartial)
|
import Partial.Unsafe (unsafePartial)
|
||||||
import Type.Data.Symbol (reflectSymbol)
|
|
||||||
import Type.Prelude (class IsSymbol, Proxy(..))
|
|
||||||
|
|
||||||
quoted :: String -> String
|
quoted :: String -> String
|
||||||
quoted s = "'" <> s <> "'"
|
quoted s = "'" <> s <> "'"
|
||||||
|
23
src/Pipes.Postgres.purs
Normal file
23
src/Pipes.Postgres.purs
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user