Skip to content

Commit

Permalink
Changes for 1.4 (#12)
Browse files Browse the repository at this point in the history
* initial dev branch

* ignoring ci for some prs
  • Loading branch information
ASRagab authored Aug 22, 2023
1 parent 77ba7bf commit 5a3d846
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 35 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@ name: ci

on:
pull_request:
types:
- assigned
- opened
- synchronize
- reopened
branches-ignore:
- main
- gh-pages

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
ci:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions:

jobs:
publish:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[![Scala Steward badge](https://img.shields.io/badge/Scala_Steward-helping-blue.svg?style=flat&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAQCAMAAAARSr4IAAAAVFBMVEUAAACHjojlOy5NWlrKzcYRKjGFjIbp293YycuLa3pYY2LSqql4f3pCUFTgSjNodYRmcXUsPD/NTTbjRS+2jomhgnzNc223cGvZS0HaSD0XLjbaSjElhIr+AAAAAXRSTlMAQObYZgAAAHlJREFUCNdNyosOwyAIhWHAQS1Vt7a77/3fcxxdmv0xwmckutAR1nkm4ggbyEcg/wWmlGLDAA3oL50xi6fk5ffZ3E2E3QfZDCcCN2YtbEWZt+Drc6u6rlqv7Uk0LdKqqr5rk2UCRXOk0vmQKGfc94nOJyQjouF9H/wCc9gECEYfONoAAAAASUVORK5CYII=)](https://scala-steward.org)
[![ci](https://github.com/ASRagab/unstructured4s/workflows/ci/badge.svg)](https://github.com/ASRagab/unstructured4s/actions)
[![Maven Central](https://img.shields.io/maven-central/v/org.twelvehart/unstructured4s-core_3.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.twelvehart%22%20AND%20a:%22unstructured4s-core_3%22)
[![Scaladoc](https://javadoc.io/badge2/org.twelvehart/unstructured4s-core_3/javadoc.svg)](https://javadoc.io/doc/org.twelvehart/unstructured4s-core_3)
[![Sonatype Snapshots](https://img.shields.io/nexus/s/https/s01.oss.sonatype.org/org.twelvehart/unstructured4s-core_3.svg?label=Sonatype%20Snapshot)](https://s01.oss.sonatype.org/content/repositories/snapshots/org/twelvehart/unstructured4s-core_3)
[![Scaladoc](https://www.javadoc.io/badge/org.twelvehart/unstructured4s-core_3.svg)](https://javadoc.io/doc/org.twelvehart/unstructured4s-core_3)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

# unstructured4s
Expand Down
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ lazy val unstructured4s = (project in file("."))
uri("https://fosstodon.org/@traversable")
),
Compile / paradoxProperties ++= Map(
"snip.core.base_dir" -> ((ThisBuild / baseDirectory).value / "core").getAbsolutePath
"snip.core.base_dir" -> ((ThisBuild / baseDirectory).value / "core").getAbsolutePath,
"sttp.version" -> V.sttp,
"zio_cats.version" -> V.zioCats
),
paradox / sourceDirectory := sourceDirectory.value / "paradox",
git.remoteRepo := scmInfo.value.get.connection.replace("scm:git:", ""),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import sttp.client3.*
import sttp.client3.circe.*
import sttp.model.*

class Unstructured4s[F[_]: Functor, P](backend: SttpBackend[F, P], apiKey: ApiKey):
class Unstructured4s[F[_]: Functor, P](backend: SttpBackend[F, P], apiKey: ApiKey)
extends Unstructured4sAlg[F, PartitionResponse]:
def partition(
file: UnstructuredFile,
request: Unstructured4sRequestFields = GeneralRequestFields(),
Expand Down Expand Up @@ -55,8 +56,8 @@ class Unstructured4s[F[_]: Functor, P](backend: SttpBackend[F, P], apiKey: ApiKe
end Unstructured4s

object Unstructured4s:
def make[F[_]: Monad, P](backend: SttpBackend[F, P], apiKey: ApiKey): F[Unstructured4s[F, P]] =
summon[Monad[F]].pure(Unstructured4s(backend, apiKey))
def make[F[_]: Functor, P](backend: SttpBackend[F, P], apiKey: ApiKey): Unstructured4s[F, P] =
Unstructured4s(backend, apiKey)

def apiKeyHeader(apiKey: ApiKey): Header = Header("unstructured-api-key", apiKey)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.twelvehart.unstructured4s

import org.twelvehart.unstructured4s.model.*
import sttp.model.*

trait Unstructured4sAlg[F[_], A]:
def partition(
file: UnstructuredFile,
request: Unstructured4sRequestFields,
customHeaders: List[Header]
): F[Unstructured4sResponse[A]]

def partitionMultiple(
files: Seq[UnstructuredFile],
request: Unstructured4sRequestFields,
customHeaders: List[Header]
): F[Unstructured4sResponse[List[A]]]
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ object CatsEffectApp extends IOApp.Simple:
backendResource.use { backend =>
for
apiKey <- IO.fromEither(apiKeyEnv)
client <- Unstructured4s.make(backend, ApiKey(apiKey))
client = Unstructured4s.make(backend, ApiKey(apiKey))
file <- IO.fromEither(pdfEither)
response <- client.partition(file, HiResRequestFields())
_ <- IO.println(response.result.bimap(_.getMessage, _.mkString("\n")).merge)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ object ZIOApp extends ZIOAppDefault:
private def program: ZIO[SttpClient, Throwable, Unit] =
ZIO.scoped {
for
apiKey <- ZIO.fromEither(apiKeyEnv)
files <- ZIO.fromEither(filesEither)
backend <- ZIO.service[SttpClient]
unstructuredClient <- Unstructured4s.make(backend, ApiKey(apiKey))
response <- unstructuredClient.partitionMultiple(files)
result = response.result.bimap(_.getMessage, _.mkString("\n")).merge
_ <- Console.printLine(result)
apiKey <- ZIO.fromEither(apiKeyEnv)
files <- ZIO.fromEither(filesEither)
backend <- ZIO.service[SttpClient]
unstructuredClient = Unstructured4s.make(backend, ApiKey(apiKey))
response <- unstructuredClient.partitionMultiple(files)
result = response.result.bimap(_.getMessage, _.mkString("\n")).merge
_ <- Console.printLine(result)
yield ()
}

Expand Down
10 changes: 5 additions & 5 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import sbt.*

object V {
lazy val zio = "2.0.15"
lazy val sttp = "3.9.0"
lazy val circe = "0.14.5"
lazy val zio = "2.0.15"
lazy val zioCats = "23.0.0.8"
lazy val sttp = "3.9.0"
lazy val circe = "0.14.5"
}

object Dependencies {
Expand All @@ -26,12 +27,11 @@ object Dependencies {
lazy val zioTest = "dev.zio" %% "zio-test" % V.zio
lazy val zio = "dev.zio" %% "zio" % V.zio
lazy val zioTestSbt = "dev.zio" %% "zio-test-sbt" % V.zio
lazy val zioCats = "dev.zio" %% "zio-interop-cats" % "23.0.0.8"
lazy val zioCats = "dev.zio" %% "zio-interop-cats" % V.zioCats
lazy val zioSlf4j = "dev.zio" %% "zio-logging-slf4j" % "2.1.14"

lazy val loggingFrontend = "ch.qos.logback" % "logback-classic" % "1.4.7"


lazy val core: Seq[ModuleID] = Seq(
cats,
catsEffect,
Expand Down
14 changes: 8 additions & 6 deletions src/main/paradox/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ also be provided a separate apikey, which will override the default, when passed

In addition to the `unstructured4s-core` module, you will need to provide an `sttp` backend, you can use any of the backends provided by [sttp]
as long as you can provide a client with the effect capability `F[_]` that has a `Functor` instance (this will typical require some kind of
interoperability module with the `cats` typeclass hierarchy)
interoperability module with the `cats` typeclass hierarchy if you aren't using cats-effect)

[sttp]: https://sttp.softwaremill.com/en/latest/backends/summary.html

Expand All @@ -25,8 +25,8 @@ First obtain the necessary dependencies for sttp, here are the ones for `ZIO`:


@@dependency[sbt,Maven,Gradle] {
group="com.softwaremill.sttp.client3" artifact="async-http-client-backend-zio_3" version="latest"
group2="dev.zio" artifact2="zio-interop-cats_3" version2="latest"
group="com.softwaremill.sttp.client3" artifact="async-http-client-backend-zio_3" version="$sttp.version$"
group2="dev.zio" artifact2="zio-interop-cats_3" version2="$zio_cats.version$"
}

<br/>
Expand All @@ -37,7 +37,7 @@ Here is the one for the `fs2` backend:
@@dependency[sbt,Maven,Gradle] {
group="com.softwaremill.sttp.client3"
artifact="async-http-client-backend-fs2_3"
version="latest"
version="$sttp.version$"
}


Expand Down Expand Up @@ -76,7 +76,8 @@ object ZIOApp extends ZIOAppDefault {
def program: ZIO[SttpClient, Throwable, Unit] =
for {
backend <- ZIO.service[SttpClient]
_ <- Unstructured4s.make(backend, ApiKey(apiKey))
apiKey <- ZIO.fromEither(apiKeyEnv)
client = Unstructured4s.make(backend, ApiKey(apiKey))
} yield ()
}
```
Expand Down Expand Up @@ -110,7 +111,8 @@ object CatsEffectApp extends IOApp.Simple {
override def run: IO[Unit] =
backendResource.use { backend =>
for {
client <- Unstructured4s.make(backend, ApiKey(apiKey))
apiKey <- IO.fromEither(apiKeyEnv)
client = Unstructured4s.make(backend, ApiKey(apiKey))
} yield ()
}
```
4 changes: 2 additions & 2 deletions src/main/paradox/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ The library is published to [Sonatype] and [Maven Central].

<br/>

See the @link:[Unstructured4s Examples](https://github.com/ASRagab/unstructured4s/tree/main/examples/src/main/scala/org/twelvehart/unstructured4s/examples) { open=new } for an even quicker start.
See the @link:[Unstructured4s examples] { open=new } for an even quicker start.

[Sonatype]: https://s01.oss.sonatype.org/content/repositories/releases/org/twelvehart/unstructured4s-core_3/
[Maven Central]: https://search.maven.org/artifact/org/twelvehart/unstructured4s-core_3

[Unstructured4s examples]: https://github.com/ASRagab/unstructured4s/tree/main/examples/src/main/scala/org/twelvehart/unstructured4s/examples

@@@ index

Expand Down
4 changes: 4 additions & 0 deletions src/main/paradox/making-requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ A hopefully sensible default with all necessary parameters for each is provided

<br/>

### `GeneralRequestFields`

@@snip [domain.scala]($core$/src/main/scala/org/twelvehart/unstructured4s/model/domain.scala) { #general_request_fields }


<br/>

### `HiResRequestFields`

@@snip [domain.scala]($core$/src/main/scala/org/twelvehart/unstructured4s/model/domain.scala) { #hires_request_fields }

<br/>
Expand Down
2 changes: 1 addition & 1 deletion src/main/paradox/responses.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ which depends on whether you called `partition` or `partitionMultiple` respectiv
There exists an implicit conversion between this error type and `ResponseException[String, io.circe.Error]` which is
error return type from `sttp` there are two kinds of `Unstructured4sError`s

* `JsonParsingError` - This is returned when the response from the [Unstructured] is not valid json.
* `JsonParsingError` - This is returned when the response from [Unstructured] is not valid json.
* `HttpResponseError` - This is returned when the response is not `200 OK`.


Expand Down
1 change: 0 additions & 1 deletion version.sbt

This file was deleted.

0 comments on commit 5a3d846

Please sign in to comment.