Skip to content

Commit 26ceb5f

Browse files
authored
Merge pull request #1 from jaeyson/move-from-ex_typesense
Move from ex typesense
2 parents e32ce67 + eca955f commit 26ceb5f

74 files changed

Lines changed: 3863 additions & 511 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.credo.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
#
9595
## Readability Checks
9696
#
97-
{Credo.Check.Readability.AliasOrder, []},
97+
# {Credo.Check.Readability.AliasOrder, []},
9898
{Credo.Check.Readability.FunctionNames, []},
9999
{Credo.Check.Readability.LargeNumbers, []},
100100
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
@@ -113,7 +113,7 @@
113113
{Credo.Check.Readability.TrailingBlankLine, []},
114114
{Credo.Check.Readability.TrailingWhiteSpace, []},
115115
{Credo.Check.Readability.UnnecessaryAliasExpansion, []},
116-
{Credo.Check.Readability.VariableNames, []},
116+
# {Credo.Check.Readability.VariableNames, []}, # needs to raise PR in :oapi_generator
117117
{Credo.Check.Readability.WithSingleClause, []},
118118

119119
#

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "mix" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"
12+
labels:
13+
- "hex"
14+
- "dependencies"

.github/workflows/ci.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Continuous Integration (CI)
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
8+
jobs:
9+
# https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs
10+
# Workflows that would otherwise be triggered using `on: push` or
11+
# `on: pull_request` won't be triggered if you add any of the
12+
# following strings to the commit message in a push, or the HEAD
13+
# commit of a pull request:
14+
# - [skip ci]
15+
# - [ci skip]
16+
# - [no ci]
17+
# - [skip actions]
18+
# - [actions skip]
19+
20+
test:
21+
runs-on: ubuntu-latest
22+
23+
env:
24+
MIX_ENV: test
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
LATEST_TYPESENSE: '27.1'
27+
28+
strategy:
29+
matrix:
30+
include:
31+
- typesense: '0.25.2'
32+
otp: '25'
33+
elixir: '1.14'
34+
- typesense: '26.0'
35+
otp: '25'
36+
elixir: '1.14'
37+
- typesense: '27.1'
38+
otp: '25'
39+
elixir: '1.14'
40+
- typesense: '0.25.2'
41+
otp: '27'
42+
elixir: '1.17'
43+
- typesense: '26.0'
44+
otp: '27'
45+
elixir: '1.17'
46+
- typesense: '27.1'
47+
otp: '27'
48+
elixir: '1.17'
49+
lint: true
50+
51+
services:
52+
typesense:
53+
image: typesense/typesense:${{ matrix.typesense }}
54+
55+
steps:
56+
- name: Checkout repo
57+
uses: actions/checkout@v4
58+
59+
- name: Check for misspellings
60+
uses: codespell-project/actions-codespell@v2
61+
62+
- name: Start Typesense
63+
run: |
64+
docker run -d \
65+
-p 8108:8108 \
66+
--name typesense \
67+
-v /tmp/typesense-data:/data \
68+
-v /tmp/typesense-analytics-data:/analytics-data \
69+
typesense/typesense:${{ matrix.typesense}} \
70+
--api-key=xyz \
71+
--data-dir=/data \
72+
--enable-search-analytics=true \
73+
--analytics-dir=/analytics-data \
74+
--analytics-flush-interval=60 \
75+
--analytics-minute-rate-limit=100 \
76+
--enable-cors
77+
78+
- name: Curl Typesense
79+
run: sleep 1 && curl http://localhost:8108/health
80+
81+
- name: Setup Elixir/OTP
82+
uses: erlef/setup-beam@v1
83+
with:
84+
otp-version: ${{matrix.otp}}
85+
elixir-version: ${{matrix.elixir}}
86+
87+
- name: Install Dependencies
88+
run: |
89+
mix local.rebar --if-missing
90+
mix local.hex --if-missing
91+
mix deps.get
92+
93+
- name: Compile
94+
run: mix compile
95+
96+
- name: Cache dependencies/builds
97+
uses: actions/cache@v4
98+
with:
99+
path: |
100+
deps
101+
_build
102+
key: ${{ runner.os }}-typesense-${{ matrix.typesense}}-${{ matrix.otp}}-${{ matrix.elixir}}-mix-${{ hashFiles('**/mix.lock') }}
103+
restore-keys: |
104+
${{ runner.os }}-typesense-${{ matrix.typesense}}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-
105+
106+
- name: Find unused dependencies
107+
run: mix deps.unlock --check-unused
108+
if: ${{ matrix.lint }}
109+
110+
- name: Check retired dependencies
111+
run: mix hex.audit
112+
if: ${{ matrix.lint }}
113+
114+
- name: Security audit of dependencies
115+
run: mix deps.audit
116+
if: ${{ matrix.lint }}
117+
118+
- name: Compile project
119+
run: mix compile --all-warnings
120+
121+
- name: Run static analysis
122+
run: mix credo --all --strict
123+
if: ${{ matrix.lint }}
124+
125+
- name: Check format files
126+
run: mix format --check-formatted
127+
if: ${{ matrix.lint }}
128+
129+
- name: Run tests
130+
run: mix test --only ${{ matrix.typesense }}:true --trace
131+
132+
- name: Post test coverage to Coveralls
133+
run: mix coveralls.github
134+
if: ${{ matrix.typesense == env.LATEST_TYPESENSE }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ open_api_typesense-*.tar
3030

3131
# Typesense local dev data folder.
3232
/typesense-data
33+
/typesense-analytics-data
3334

3435
# Misc.
3536
.elixir_ls

.iex.exs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
alias OpenApiTypesense.Client
1+
alias OpenApiTypesense.Client
2+
alias OpenApiTypesense.Connection
3+
4+
alias OpenApiTypesense.Analytics
5+
alias OpenApiTypesense.Collections
6+
alias OpenApiTypesense.Curation
7+
alias OpenApiTypesense.Debug
8+
alias OpenApiTypesense.Documents
9+
alias OpenApiTypesense.Health
10+
alias OpenApiTypesense.Keys
11+
alias OpenApiTypesense.Operations
12+
alias OpenApiTypesense.Override
13+
alias OpenApiTypesense.Presets
14+
alias OpenApiTypesense.Stopwords
15+
alias OpenApiTypesense.Synonyms

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## major.minor.patch (yyyy.mm.dd)
99

10+
## 0.2.0 (2024.12.14)
11+
12+
### Changed
13+
14+
* Bumped dependencies
15+
16+
### Added
17+
18+
* Default client, currently using [`Req`](https://hexdocs.pm/req).
19+
* `Connection` module, which is taken from [`ExTypesense`](https://hexdocs.pm/ex_typesense) because someone requested for loading of credentials at runtime.
20+
* `defstruct` in Modules `Debug`, `Documents` and `Stopwords` because it is throwing undefined struct error.
21+
* Few descriptions in `priv/open_api.yml` for 4XX response.
22+
1023
## 0.1.0 (2024.11.08)
1124

1225
* Initial release

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# OpenApiTypesense
22

3-
**TODO: Add description**
3+
Restful client for Typesense with adherence to Open API spec 3 (formerly Swagger)
4+
5+
[![Hex.pm](https://img.shields.io/hexpm/v/open_api_typesense)](https://hex.pm/packages/open_api_typesense)
6+
[![Hexdocs.pm](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/open_api_typesense)
7+
[![Hex.pm](https://img.shields.io/hexpm/l/open_api_typesense)](https://hexdocs.pm/open_api_typesense/license.html)
8+
[![Typesense badge](https://img.shields.io/badge/Typesense-v27.1-darkblue)](https://typesense.org/docs/27.1/api)
9+
[![Coverage Status](https://coveralls.io/repos/github/jaeyson/open_api_typesense/badge.svg?branch=main)](https://coveralls.io/github/jaeyson/open_api_typesense?branch=main)
10+
11+
## TODO
12+
- Custom Http client adapter (currently [`Req`](https://hexdocs.pm/req))
13+
414

515
## Installation
616

@@ -10,7 +20,7 @@ by adding `open_api_typesense` to your list of dependencies in `mix.exs`:
1020
```elixir
1121
def deps do
1222
[
13-
{:open_api_typesense, "~> 0.1.0"}
23+
{:open_api_typesense, "~> 0.2"}
1424
]
1525
end
1626
```

config/config.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ if Mix.env() in [:dev, :test] do
66
host: "localhost",
77
port: 8108,
88
scheme: "http"
9+
end
910

11+
if Mix.env() == :dev do
1012
config :oapi_generator,
1113
default: [
1214
output: [
1315
base_module: OpenApiTypesense,
16+
processor: OpenAPI.Processor,
17+
renderer: OpenAPI.Renderer,
1418
location: "lib/open_api_typesense",
1519
operation_subdirectory: "operations/",
1620
schema_subdirectory: "schemas/"

coveralls.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"skip_files": [
33
"test",
4-
"deps"
4+
"deps",
5+
"lib/open_api_typesense/schemas",
6+
"lib/open_api_typesense.ex"
57
]
68
}

docker-compose.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
services:
22
typesense:
3-
image: docker.io/typesense/typesense:26.0
3+
image: docker.io/typesense/typesense:27.1
44
container_name: typesense
55
restart: on-failure
66
ports:
77
- 8107:8107 # internal status
88
- 8108:8108 # typesense server
99
volumes:
1010
- ./typesense-data:/data
11-
command: "--data-dir /data --api-key=xyz --enable-cors"
11+
- ./typesense-analytics-data:/analytics-data
12+
command: |
13+
--data-dir=/data
14+
--api-key=xyz
15+
--enable-search-analytics=true
16+
--analytics-dir=/analytics-data
17+
--analytics-flush-interval=60
18+
--analytics-minute-rate-limit=100
19+
--enable-cors
1220
typesense_dashboard:
13-
image: ghcr.io/bfritscher/typesense-dashboard:latest
21+
image: ghcr.io/bfritscher/typesense-dashboard:1.9.3
1422
container_name: typesense_dashboard
1523
restart: on-failure
1624
ports:

0 commit comments

Comments
 (0)