Skip to content

Commit

Permalink
fixed formatting and typos
Browse files Browse the repository at this point in the history
  • Loading branch information
ganigeorgiev committed Feb 23, 2023
1 parent aa4e405 commit 21b152b
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 50 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

- **!** Repurposed the Authentik integration as a more generic "OpenID Connect" provider (`oidc`) to support any OIDC provider (Okta, Keycloak, etc.).
_If you've previously used Authentik, make sure to rename the provider key in your code to `oidc`._
_For more than one OIDC provider you can use the additional `oidc2` and `oidc3` settings._
_To enable more than one OIDC provider you can use the additional `oidc2` and `oidc3` provider keys._
- **!** Removed the previously deprecated `Dao.Block()` and `Dao.Continue()` helpers in favor of `Dao.NonconcurrentDB()`.
Expand Down
1 change: 1 addition & 0 deletions daos/base_retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func execLockRetry(timeout time.Duration, maxRetries int) dbx.ExecHookFunc {
cancelCtx, cancel := context.WithTimeout(context.Background(), timeout)
defer func() {
cancel()
//nolint:staticcheck
q.WithContext(nil) // reset
}()
q.WithContext(cancelCtx)
Expand Down
4 changes: 2 additions & 2 deletions daos/external_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ func (dao *Dao) ExternalAuthQuery() *dbx.SelectQuery {
return dao.ModelQuery(&models.ExternalAuth{})
}

/// FindAllExternalAuthsByRecord returns all ExternalAuth models
/// linked to the provided auth record.
// FindAllExternalAuthsByRecord returns all ExternalAuth models
// linked to the provided auth record.
func (dao *Dao) FindAllExternalAuthsByRecord(authRecord *models.Record) ([]*models.ExternalAuth, error) {
auths := []*models.ExternalAuth{}

Expand Down
13 changes: 0 additions & 13 deletions forms/record_upsert.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ func (form *RecordUpsert) LoadData(requestData map[string]any) error {
if len(submittedNames) == 0 && len(oldNames) > 0 {
form.RemoveFiles(key)
} else if len(oldNames) > 0 {

toDelete := []string{}

for _, name := range oldNames {
Expand Down Expand Up @@ -763,18 +762,6 @@ func (form *RecordUpsert) Submit(interceptors ...InterceptorFunc[*models.Record]
}, interceptors...)
}

func (form *RecordUpsert) getFilesToUploadNames() []string {
names := []string{}

for fieldKey := range form.filesToUpload {
for _, file := range form.filesToUpload[fieldKey] {
names = append(names, file.Name)
}
}

return names
}

func (form *RecordUpsert) processFilesToUpload() error {
if len(form.filesToUpload) == 0 {
return nil // no parsed file fields
Expand Down
4 changes: 3 additions & 1 deletion forms/validators/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
// size is no more than the provided maxBytes.
//
// Example:
//
// validation.Field(&form.File, validation.By(validators.UploadedFileSize(1000)))
func UploadedFileSize(maxBytes int) validation.RuleFunc {
return func(value any) error {
Expand All @@ -36,7 +37,8 @@ func UploadedFileSize(maxBytes int) validation.RuleFunc {
// mimetype is within the provided allowed mime types.
//
// Example:
// validMimeTypes := []string{"test/plain","image/jpeg"}
//
// validMimeTypes := []string{"test/plain","image/jpeg"}
// validation.Field(&form.File, validation.By(validators.UploadedFileMimeType(validMimeTypes)))
func UploadedFileMimeType(validTypes []string) validation.RuleFunc {
return func(value any) error {
Expand Down
1 change: 1 addition & 0 deletions forms/validators/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
// Compare checks whether the provided model id exists.
//
// Example:
//
// validation.Field(&form.Id, validation.By(validators.UniqueId(form.dao, tableName)))
func UniqueId(dao *daos.Dao, tableName string) validation.RuleFunc {
return func(value any) error {
Expand Down
1 change: 1 addition & 0 deletions forms/validators/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
// Compare checks whether the validated value matches another string.
//
// Example:
//
// validation.Field(&form.PasswordConfirm, validation.By(validators.Compare(form.Password)))
func Compare(valueToCompare string) validation.RuleFunc {
return func(value any) error {
Expand Down
2 changes: 1 addition & 1 deletion models/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ func (m *Record) ReplaceModifers(data map[string]any) map[string]any {
}

// -----------------------------------------------------------
// legacy file field modifiers (kept for backward compatability)
// legacy file field modifiers (kept for backward compatibility)
// -----------------------------------------------------------

var oldNames []string
Expand Down
3 changes: 1 addition & 2 deletions models/schema/schema_field.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,7 @@ func (f *SchemaField) PrepareValueWithModifier(baseValue any, modifier string, m
}
case FieldTypeFile:
// note: file for now supports only the subtract modifier
switch modifier {
case FieldValueModifierSubtract:
if modifier == FieldValueModifierSubtract {
resolvedValue = list.SubtractSlice(
list.ToUniqueStringSlice(baseValue),
list.ToUniqueStringSlice(modifierValue),
Expand Down
6 changes: 3 additions & 3 deletions plugins/jsvm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
//
// 1. JS Migrations loader:
//
// jsvm.MustRegisterMigrations(app, &jsvm.MigrationsOptions{
// Dir: "custom_js_migrations_dir_path", // default to "pb_data/../pb_migrations"
// })
// jsvm.MustRegisterMigrations(app, &jsvm.MigrationsOptions{
// Dir: "custom_js_migrations_dir_path", // default to "pb_data/../pb_migrations"
// })
package jsvm

import (
Expand Down
14 changes: 7 additions & 7 deletions plugins/migratecmd/migratecmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
//
// Example usage:
//
// migratecmd.MustRegister(app, app.RootCmd, &migratecmd.Options{
// TemplateLang: migratecmd.TemplateLangJS, // default to migratecmd.TemplateLangGo
// Automigrate: true,
// Dir: "migrations_dir_path", // optional template migrations path; default to "pb_migrations" (for JS) and "migrations" (for Go)
// })
// migratecmd.MustRegister(app, app.RootCmd, &migratecmd.Options{
// TemplateLang: migratecmd.TemplateLangJS, // default to migratecmd.TemplateLangGo
// Automigrate: true,
// Dir: "migrations_dir_path", // optional template migrations path; default to "pb_migrations" (for JS) and "migrations" (for Go)
// })
//
// Note: To allow running JS migrations you'll need to enable first
// [jsvm.MustRegisterMigrations].
// Note: To allow running JS migrations you'll need to enable first
// [jsvm.MustRegisterMigrations].
package migratecmd

import (
Expand Down
42 changes: 22 additions & 20 deletions resolvers/record_field_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ var _ search.FieldResolver = (*RecordFieldResolver)(nil)
// RecordFieldResolver defines a custom search resolver struct for
// managing Record model search fields.
//
// Usually used together with `search.Provider`. Example:
// resolver := resolvers.NewRecordFieldResolver(
// app.Dao(),
// myCollection,
// &models.RequestData{...},
// true,
// )
// provider := search.NewProvider(resolver)
// ...
// Usually used together with `search.Provider`.
// Example:
//
// resolver := resolvers.NewRecordFieldResolver(
// app.Dao(),
// myCollection,
// &models.RequestData{...},
// true,
// )
// provider := search.NewProvider(resolver)
// ...
type RecordFieldResolver struct {
dao *daos.Dao
baseCollection *models.Collection
Expand Down Expand Up @@ -125,17 +127,17 @@ func (r *RecordFieldResolver) UpdateQuery(query *dbx.SelectQuery) error {
//
// Example of some resolvable fieldName formats:
//
// id
// someSelect.each
// project.screen.status
// @request.status
// @request.query.filter
// @request.auth.someRelation.name
// @request.data.someRelation.name
// @request.data.someField
// @request.data.someSelect:each
// @request.data.someField:isset
// @collection.product.name
// id
// someSelect.each
// project.screen.status
// @request.status
// @request.query.filter
// @request.auth.someRelation.name
// @request.data.someRelation.name
// @request.data.someField
// @request.data.someSelect:each
// @request.data.someField:isset
// @collection.product.name
func (r *RecordFieldResolver) Resolve(fieldName string) (*search.ResolverResult, error) {
return parseAndRun(fieldName, r)
}
Expand Down
1 change: 1 addition & 0 deletions tests/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
// MockMultipartData creates a mocked multipart/form-data payload.
//
// Example
//
// data, mp, err := tests.MockMultipartData(
// map[string]string{"title": "new"},
// "file1",
Expand Down
1 change: 1 addition & 0 deletions tools/search/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (s *SortField) BuildExpr(fieldResolver FieldResolver) (string, error) {
// into a slice of SortFields.
//
// Example:
//
// fields := search.ParseSortFromString("-name,+created")
func ParseSortFromString(str string) (fields []SortField) {
data := strings.Split(str, ",")
Expand Down

0 comments on commit 21b152b

Please sign in to comment.