Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the library #557

Merged
merged 23 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8e19813
docs: add package documentation
Ja7ad Aug 4, 2024
2544334
fix: refactor fasthttp client to http client
Ja7ad Aug 4, 2024
6859a7f
chore: add general errors
Ja7ad Aug 4, 2024
9ed1483
feat: add option pattern for make optional client
Ja7ad Aug 4, 2024
96e9a18
docs: update documentation of types
Ja7ad Aug 4, 2024
bb59fa3
chore: add example test for function New and Connect
Ja7ad Aug 4, 2024
794b6ad
docs: update readme for new meilisearch
Ja7ad Aug 4, 2024
b94d7f1
chore: add helper function with test
Ja7ad Aug 4, 2024
af7e8b8
feat: add service manager to manage index, key, task and other operation
Ja7ad Aug 4, 2024
ded6cec
feat: add index manager to manage index and search
Ja7ad Aug 4, 2024
f526c9a
fix: update module version to 1.17 for fix issue testify
Ja7ad Aug 4, 2024
67c39c8
fix: update go module
Ja7ad Aug 4, 2024
3daaca6
fix: change testify version to stable and support go 1.16
Ja7ad Aug 4, 2024
621feaf
docs: update example documentation
Ja7ad Aug 4, 2024
2afede6
chore: update many for coverage
Ja7ad Aug 4, 2024
ea75d08
fix: improved coverage test of client
Ja7ad Aug 4, 2024
f059542
fix: client test except on pool
Ja7ad Aug 4, 2024
a1e7862
fix: change old client example to new
Ja7ad Aug 7, 2024
a023417
fix: add test for RawType to improve coverage
Ja7ad Aug 12, 2024
cb933a8
fix: add update documents test for improve coverage
Ja7ad Aug 12, 2024
427b126
fix: improved coverage test of client with some scenarios
Ja7ad Aug 12, 2024
d6d1254
Merge #556
meili-bors[bot] Aug 14, 2024
077eaf1
Merge branch 'main' into refactor
curquiza Aug 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs: update documentation of types
  • Loading branch information
Ja7ad committed Aug 4, 2024
commit 96e9a18feb65379cf5bbe5115126a99f5e37669f
65 changes: 34 additions & 31 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,45 @@ import (
"time"

"github.com/golang-jwt/jwt/v4"
"github.com/valyala/fasthttp"
)

//
// Internal types to Meilisearch
//
const (
DefaultLimit int64 = 20

contentTypeJSON string = "application/json"
contentTypeNDJSON string = "application/x-ndjson"
contentTypeCSV string = "text/csv"
)

// Client is a structure that give you the power for interacting with an high-level api with Meilisearch.
type Client struct {
config ClientConfig
httpClient *fasthttp.Client
type IndexConfig struct {
// Uid is the unique identifier of a given index.
Uid string
// PrimaryKey is optional
PrimaryKey string
}

// Index is the type that represent an index in Meilisearch
type Index struct {
type IndexResult struct {
UID string `json:"uid"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
PrimaryKey string `json:"primaryKey,omitempty"`
client *Client
IndexManager
}

// Return of multiple indexes is wrap in a IndexesResults
// IndexesResults return of multiple indexes is wrap in a IndexesResults
type IndexesResults struct {
Results []Index `json:"results"`
Offset int64 `json:"offset"`
Limit int64 `json:"limit"`
Total int64 `json:"total"`
Results []*IndexResult `json:"results"`
Offset int64 `json:"offset"`
Limit int64 `json:"limit"`
Total int64 `json:"total"`
}

type IndexesQuery struct {
Limit int64
Offset int64
}

// Settings is the type that represents the settings in Meilisearch
// Settings is the type that represents the settings in meilisearch
type Settings struct {
RankingRules []string `json:"rankingRules,omitempty"`
DistinctAttribute *string `json:"distinctAttribute,omitempty"`
Expand All @@ -56,26 +59,26 @@ type Settings struct {
Embedders map[string]Embedder `json:"embedders,omitempty"`
}

// TypoTolerance is the type that represents the typo tolerance setting in Meilisearch
// TypoTolerance is the type that represents the typo tolerance setting in meilisearch
type TypoTolerance struct {
Enabled bool `json:"enabled"`
MinWordSizeForTypos MinWordSizeForTypos `json:"minWordSizeForTypos,omitempty"`
DisableOnWords []string `json:"disableOnWords,omitempty"`
DisableOnAttributes []string `json:"disableOnAttributes,omitempty"`
}

// MinWordSizeForTypos is the type that represents the minWordSizeForTypos setting in the typo tolerance setting in Meilisearch
// MinWordSizeForTypos is the type that represents the minWordSizeForTypos setting in the typo tolerance setting in meilisearch
type MinWordSizeForTypos struct {
OneTypo int64 `json:"oneTypo,omitempty"`
TwoTypos int64 `json:"twoTypos,omitempty"`
}

// Pagination is the type that represents the pagination setting in Meilisearch
// Pagination is the type that represents the pagination setting in meilisearch
type Pagination struct {
MaxTotalHits int64 `json:"maxTotalHits"`
}

// Faceting is the type that represents the faceting setting in Meilisearch
// Faceting is the type that represents the faceting setting in meilisearch
type Faceting struct {
MaxValuesPerFacet int64 `json:"maxValuesPerFacet"`
}
Expand All @@ -88,14 +91,14 @@ type Embedder struct {
DocumentTemplate string `json:"documentTemplate,omitempty"`
}

// Version is the type that represents the versions in Meilisearch
// Version is the type that represents the versions in meilisearch
type Version struct {
CommitSha string `json:"commitSha"`
CommitDate string `json:"commitDate"`
PkgVersion string `json:"pkgVersion"`
}

// StatsIndex is the type that represent the stats of an index in Meilisearch
// StatsIndex is the type that represent the stats of an index in meilisearch
type StatsIndex struct {
NumberOfDocuments int64 `json:"numberOfDocuments"`
IsIndexing bool `json:"isIndexing"`
Expand Down Expand Up @@ -253,7 +256,7 @@ type Details struct {
DumpUid string `json:"dumpUid,omitempty"`
}

// Return of multiple tasks is wrap in a TaskResult
// TaskResult return of multiple tasks is wrap in a TaskResult
type TaskResult struct {
Results []Task `json:"results"`
Limit int64 `json:"limit"`
Expand All @@ -262,7 +265,7 @@ type TaskResult struct {
Total int64 `json:"total"`
}

// Keys allow the user to connect to the Meilisearch instance
// Key allow the user to connect to the meilisearch instance
//
// Documentation: https://www.meilisearch.com/docs/learn/security/master_api_keys#protecting-a-meilisearch-instance
type Key struct {
Expand All @@ -277,7 +280,7 @@ type Key struct {
ExpiresAt time.Time `json:"expiresAt"`
}

// This structure is used to send the exact ISO-8601 time format managed by Meilisearch
// KeyParsed this structure is used to send the exact ISO-8601 time format managed by meilisearch
type KeyParsed struct {
Name string `json:"name"`
Description string `json:"description"`
Expand All @@ -287,13 +290,13 @@ type KeyParsed struct {
ExpiresAt *string `json:"expiresAt"`
}

// This structure is used to update a Key
// KeyUpdate this structure is used to update a Key
type KeyUpdate struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
}

// Return of multiple keys is wrap in a KeysResults
// KeysResults return of multiple keys is wrap in a KeysResults
type KeysResults struct {
Results []Key `json:"results"`
Offset int64 `json:"offset"`
Expand All @@ -306,7 +309,7 @@ type KeysQuery struct {
Offset int64
}

// Information to create a tenant token
// TenantTokenOptions information to create a tenant token
//
// ExpiresAt is a time.Time when the key will expire.
// Note that if an ExpiresAt value is included it should be in UTC time.
Expand All @@ -316,7 +319,7 @@ type TenantTokenOptions struct {
ExpiresAt time.Time
}

// Custom Claims structure to create a Tenant Token
// TenantTokenClaims custom Claims structure to create a Tenant Token
type TenantTokenClaims struct {
APIKeyUID string `json:"apiKeyUid"`
SearchRules interface{} `json:"searchRules"`
Expand Down Expand Up @@ -466,7 +469,7 @@ type SwapIndexesParams struct {
// RawType is an alias for raw byte[]
type RawType []byte

// Health is the request body for set Meilisearch health
// Health is the request body for set meilisearch health
type Health struct {
Status string `json:"status"`
}
Expand Down
Loading