repo stringlengths 6 47 | file_url stringlengths 77 269 | file_path stringlengths 5 186 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-07 08:35:43 2026-01-07 08:55:24 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/archive/create.go | tools/archive/create.go | package archive
import (
"archive/zip"
"compress/flate"
"errors"
"io"
"io/fs"
"os"
"path/filepath"
"strings"
)
// Create creates a new zip archive from src dir content and saves it in dest path.
//
// You can specify skipPaths to skip/ignore certain directories and files (relative to src)
// preventing adding... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/archive/create_test.go | tools/archive/create_test.go | package archive_test
import (
"os"
"path/filepath"
"testing"
"github.com/pocketbase/pocketbase/tools/archive"
)
func TestCreateFailure(t *testing.T) {
testDir := createTestDir(t)
defer os.RemoveAll(testDir)
zipPath := filepath.Join(os.TempDir(), "pb_test.zip")
defer os.RemoveAll(zipPath)
missingDir := fil... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/archive/extract.go | tools/archive/extract.go | package archive
import (
"archive/zip"
"fmt"
"io"
"os"
"path/filepath"
"strings"
)
// Extract extracts the zip archive at "src" to "dest".
//
// Note that only dirs and regular files will be extracted.
// Symbolic links, named pipes, sockets, or any other irregular files
// are skipped because they come with to... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/archive/extract_test.go | tools/archive/extract_test.go | package archive_test
import (
"io/fs"
"os"
"path/filepath"
"testing"
"github.com/pocketbase/pocketbase/tools/archive"
)
func TestExtractFailure(t *testing.T) {
testDir := createTestDir(t)
defer os.RemoveAll(testDir)
missingZipPath := filepath.Join(os.TempDir(), "pb_missing_test.zip")
extractedPath := filep... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/inflector/singularize_test.go | tools/inflector/singularize_test.go | package inflector_test
import (
"testing"
"github.com/pocketbase/pocketbase/tools/inflector"
)
func TestSingularize(t *testing.T) {
scenarios := []struct {
word string
expected string
}{
{"abcnese", "abcnese"},
{"deer", "deer"},
{"sheep", "sheep"},
{"measles", "measles"},
{"pox", "pox"},
{"me... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/inflector/inflector_test.go | tools/inflector/inflector_test.go | package inflector_test
import (
"fmt"
"testing"
"github.com/pocketbase/pocketbase/tools/inflector"
)
func TestUcFirst(t *testing.T) {
scenarios := []struct {
val string
expected string
}{
{"", ""},
{" ", " "},
{"Test", "Test"},
{"test", "Test"},
{"test test2", "Test test2"},
}
for i, s := ... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/inflector/inflector.go | tools/inflector/inflector.go | package inflector
import (
"regexp"
"strings"
"unicode"
)
var columnifyRemoveRegex = regexp.MustCompile(`[^\w\.\*\-\_\@\#]+`)
var snakecaseSplitRegex = regexp.MustCompile(`[\W_]+`)
// UcFirst converts the first character of a string into uppercase.
func UcFirst(str string) string {
if str == "" {
return ""
}
... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/inflector/singularize.go | tools/inflector/singularize.go | package inflector
import (
"log"
"regexp"
"github.com/pocketbase/pocketbase/tools/store"
)
var compiledPatterns = store.New[string, *regexp.Regexp](nil)
// note: the patterns are extracted from popular Ruby/PHP/Node.js inflector packages
var singularRules = []struct {
pattern string // lazily compiled
repl... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/tokenizer/tokenizer.go | tools/tokenizer/tokenizer.go | // Package tokenizer implements a rudimentary tokens parser of buffered
// io.Reader while respecting quotes and parenthesis boundaries.
//
// Example
//
// tk := tokenizer.NewFromString("a, b, (c, d)")
// result, _ := tk.ScanAll() // ["a", "b", "(c, d)"]
package tokenizer
import (
"bufio"
"bytes"
"fmt"
"io"
"str... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/tokenizer/tokenizer_test.go | tools/tokenizer/tokenizer_test.go | package tokenizer
import (
"io"
"strings"
"testing"
)
func TestFactories(t *testing.T) {
expectedContent := "test"
scenarios := []struct {
name string
tk *Tokenizer
}{
{
"New()",
New(strings.NewReader(expectedContent)),
},
{
"NewFromString()",
NewFromString(expectedContent),
},
{
... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/cron/job_test.go | tools/cron/job_test.go | package cron
import (
"encoding/json"
"testing"
)
func TestJobId(t *testing.T) {
expected := "test"
j := Job{id: expected}
if j.Id() != expected {
t.Fatalf("Expected job with id %q, got %q", expected, j.Id())
}
}
func TestJobExpr(t *testing.T) {
expected := "1 2 3 4 5"
s, err := NewSchedule(expected)
i... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/cron/job.go | tools/cron/job.go | package cron
import "encoding/json"
// Job defines a single registered cron job.
type Job struct {
fn func()
schedule *Schedule
id string
}
// Id returns the cron job id.
func (j *Job) Id() string {
return j.id
}
// Expression returns the plain cron job schedule expression.
func (j *Job) Expression(... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/cron/cron.go | tools/cron/cron.go | // Package cron implements a crontab-like service to execute and schedule
// repeative tasks/jobs.
//
// Example:
//
// c := cron.New()
// c.MustAdd("dailyReport", "0 0 * * *", func() { ... })
// c.Start()
package cron
import (
"errors"
"fmt"
"slices"
"sync"
"time"
)
// Cron is a crontab-like struct for tasks/jo... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/cron/schedule_test.go | tools/cron/schedule_test.go | package cron_test
import (
"encoding/json"
"fmt"
"testing"
"time"
"github.com/pocketbase/pocketbase/tools/cron"
)
func TestNewMoment(t *testing.T) {
t.Parallel()
date, err := time.Parse("2006-01-02 15:04", "2023-05-09 15:20")
if err != nil {
t.Fatal(err)
}
m := cron.NewMoment(date)
if m.Minute != 20 ... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/cron/schedule.go | tools/cron/schedule.go | package cron
import (
"errors"
"fmt"
"strconv"
"strings"
"time"
)
// Moment represents a parsed single time moment.
type Moment struct {
Minute int `json:"minute"`
Hour int `json:"hour"`
Day int `json:"day"`
Month int `json:"month"`
DayOfWeek int `json:"dayOfWeek"`
}
// NewMoment creates ... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/cron/cron_test.go | tools/cron/cron_test.go | package cron
import (
"encoding/json"
"slices"
"testing"
"time"
)
func TestCronNew(t *testing.T) {
t.Parallel()
c := New()
expectedInterval := 1 * time.Minute
if c.interval != expectedInterval {
t.Fatalf("Expected default interval %v, got %v", expectedInterval, c.interval)
}
expectedTimezone := time.UT... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/file.go | tools/filesystem/file.go | package filesystem
import (
"bytes"
"context"
"errors"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
"path"
"regexp"
"strings"
"github.com/gabriel-vasile/mimetype"
"github.com/pocketbase/pocketbase/tools/inflector"
"github.com/pocketbase/pocketbase/tools/security"
)
// FileReader defines an interface for... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/file_test.go | tools/filesystem/file_test.go | package filesystem_test
import (
"context"
"fmt"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"regexp"
"strconv"
"strings"
"testing"
"github.com/pocketbase/pocketbase/tests"
"github.com/pocketbase/pocketbase/tools/filesystem"
)
func TestFileAsMap(t *testing.T) {
file, err := filesystem.NewFileFro... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/filesystem_test.go | tools/filesystem/filesystem_test.go | package filesystem_test
import (
"bytes"
"errors"
"image"
"image/jpeg"
"image/png"
"io"
"mime/multipart"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"strings"
"testing"
"github.com/gabriel-vasile/mimetype"
"github.com/pocketbase/pocketbase/tools/filesystem"
)
func TestFileSystemExists(t *testi... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/filesystem.go | tools/filesystem/filesystem.go | package filesystem
import (
"context"
"errors"
"image"
"io"
"mime/multipart"
"net/http"
"os"
"path"
"path/filepath"
"regexp"
"sort"
"strconv"
"strings"
"github.com/disintegration/imaging"
"github.com/fatih/color"
"github.com/gabriel-vasile/mimetype"
"github.com/pocketbase/pocketbase/tools/filesystem/... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/blob/driver.go | tools/filesystem/blob/driver.go | package blob
import (
"context"
"io"
"time"
)
// ReaderAttributes contains a subset of attributes about a blob that are
// accessible from Reader.
type ReaderAttributes struct {
// ContentType is the MIME type of the blob object. It must not be empty.
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/blob/bucket.go | tools/filesystem/blob/bucket.go | // Package blob defines a lightweight abstration for interacting with
// various storage services (local filesystem, S3, etc.).
//
// NB!
// For compatibility with earlier PocketBase versions and to prevent
// unnecessary breaking changes, this package is based and implemented
// as a minimal, stripped down version of ... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/blob/writer.go | tools/filesystem/blob/writer.go | package blob
import (
"bytes"
"context"
"fmt"
"hash"
"io"
"net/http"
)
// Largely copied from gocloud.dev/blob.Writer to minimize breaking changes.
//
// -------------------------------------------------------------------
// Copyright 2019 The Go Cloud Development Kit Authors
//
// Licensed under the Apache Lic... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/blob/reader.go | tools/filesystem/blob/reader.go | package blob
import (
"context"
"fmt"
"io"
"log"
"time"
)
// Largely copied from gocloud.dev/blob.Reader to minimize breaking changes.
//
// -------------------------------------------------------------------
// Copyright 2019 The Go Cloud Development Kit Authors
//
// Licensed under the Apache License, Version ... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/blob/hex.go | tools/filesystem/blob/hex.go | package blob
import (
"fmt"
"strconv"
)
// Copied from gocloud.dev/blob to avoid nuances around the specific
// HEX escaping/unescaping rules.
//
// -------------------------------------------------------------------
// Copyright 2019 The Go Cloud Development Kit Authors
//
// Licensed under the Apache License, Ver... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3blob_test.go | tools/filesystem/internal/s3blob/s3blob_test.go | package s3blob_test
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"strings"
"testing"
"github.com/pocketbase/pocketbase/tools/filesystem/blob"
"github.com/pocketbase/pocketbase/tools/filesystem/internal/s3blob"
"github.com/pocketbase/pocketbase/tools/filesystem/internal/s3blob/s3"
"git... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3blob.go | tools/filesystem/internal/s3blob/s3blob.go | // Package s3blob provides a blob.Bucket S3 driver implementation.
//
// NB! To minimize breaking changes with older PocketBase releases,
// the driver is based of the previously used gocloud.dev/blob/s3blob,
// hence many of the below doc comments, struct options and interface
// implementations are the same.
//
// Th... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/head_object_test.go | tools/filesystem/internal/s3blob/s3/head_object_test.go | package s3_test
import (
"context"
"encoding/json"
"net/http"
"testing"
"github.com/pocketbase/pocketbase/tools/filesystem/internal/s3blob/s3"
"github.com/pocketbase/pocketbase/tools/filesystem/internal/s3blob/s3/tests"
)
func TestS3HeadObject(t *testing.T) {
t.Parallel()
httpClient := tests.NewClient(
&t... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/copy_object_test.go | tools/filesystem/internal/s3blob/s3/copy_object_test.go | package s3_test
import (
"context"
"io"
"net/http"
"strings"
"testing"
"github.com/pocketbase/pocketbase/tools/filesystem/internal/s3blob/s3"
"github.com/pocketbase/pocketbase/tools/filesystem/internal/s3blob/s3/tests"
)
func TestS3CopyObject(t *testing.T) {
t.Parallel()
httpClient := tests.NewClient(
&t... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/s3_test.go | tools/filesystem/internal/s3blob/s3/s3_test.go | package s3_test
import (
"io"
"net/http"
"strings"
"testing"
"github.com/pocketbase/pocketbase/tools/filesystem/internal/s3blob/s3"
"github.com/pocketbase/pocketbase/tools/filesystem/internal/s3blob/s3/tests"
)
func TestS3URL(t *testing.T) {
t.Parallel()
path := "/test_key/a/b c@d?a=@1&b=!2#@a b c"
// not... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/delete_object_test.go | tools/filesystem/internal/s3blob/s3/delete_object_test.go | package s3_test
import (
"context"
"net/http"
"testing"
"github.com/pocketbase/pocketbase/tools/filesystem/internal/s3blob/s3"
"github.com/pocketbase/pocketbase/tools/filesystem/internal/s3blob/s3/tests"
)
func TestS3DeleteObject(t *testing.T) {
t.Parallel()
httpClient := tests.NewClient(
&tests.RequestStu... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/error.go | tools/filesystem/internal/s3blob/s3/error.go | package s3
import (
"encoding/xml"
"strconv"
"strings"
)
var _ error = (*ResponseError)(nil)
// ResponseError defines a general S3 response error.
//
// https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html
type ResponseError struct {
XMLName xml.Name `json:"-" xml:"Error"`
Code string `j... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/s3.go | tools/filesystem/internal/s3blob/s3/s3.go | // Package s3 implements a lightweight client for interacting with the
// REST APIs of any S3 compatible service.
//
// It implements only the minimal functionality required by PocketBase
// such as objects list, get, copy, delete and upload.
//
// For more details why we don't use the official aws-sdk-go-v2, you could... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/get_object_test.go | tools/filesystem/internal/s3blob/s3/get_object_test.go | package s3_test
import (
"context"
"encoding/json"
"io"
"net/http"
"strings"
"testing"
"github.com/pocketbase/pocketbase/tools/filesystem/internal/s3blob/s3"
"github.com/pocketbase/pocketbase/tools/filesystem/internal/s3blob/s3/tests"
)
func TestS3GetObject(t *testing.T) {
t.Parallel()
httpClient := tests... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/list_objects.go | tools/filesystem/internal/s3blob/s3/list_objects.go | package s3
import (
"context"
"encoding/xml"
"net/http"
"net/url"
"strconv"
"time"
)
// ListParams defines optional parameters for the ListObject request.
type ListParams struct {
// ContinuationToken indicates that the list is being continued on this bucket with a token.
// ContinuationToken is obfuscated an... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/list_objects_test.go | tools/filesystem/internal/s3blob/s3/list_objects_test.go | package s3_test
import (
"context"
"encoding/json"
"io"
"net/http"
"strings"
"testing"
"github.com/pocketbase/pocketbase/tools/filesystem/internal/s3blob/s3"
"github.com/pocketbase/pocketbase/tools/filesystem/internal/s3blob/s3/tests"
)
func TestS3ListParamsEncode(t *testing.T) {
t.Parallel()
scenarios :=... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/get_object.go | tools/filesystem/internal/s3blob/s3/get_object.go | package s3
import (
"context"
"io"
"net/http"
)
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html#API_GetObject_ResponseElements
type GetObjectResponse struct {
Body io.ReadCloser `json:"-" xml:"-"`
HeadObjectResponse
}
// GetObject retrieves a single object by its key.
//
// NB! Make sure ... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/error_test.go | tools/filesystem/internal/s3blob/s3/error_test.go | package s3_test
import (
"encoding/json"
"encoding/xml"
"testing"
"github.com/pocketbase/pocketbase/tools/filesystem/internal/s3blob/s3"
)
func TestResponseErrorSerialization(t *testing.T) {
raw := `
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>test_code</Code>
<Message>test_message</Message... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/uploader_test.go | tools/filesystem/internal/s3blob/s3/uploader_test.go | package s3_test
import (
"context"
"io"
"net/http"
"strconv"
"strings"
"testing"
"github.com/pocketbase/pocketbase/tools/filesystem/internal/s3blob/s3"
"github.com/pocketbase/pocketbase/tools/filesystem/internal/s3blob/s3/tests"
)
func TestUploaderRequiredFields(t *testing.T) {
t.Parallel()
s3Client := &s... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/uploader.go | tools/filesystem/internal/s3blob/s3/uploader.go | package s3
import (
"bytes"
"context"
"encoding/xml"
"errors"
"fmt"
"io"
"net/http"
"net/url"
"slices"
"strconv"
"strings"
"sync"
"golang.org/x/sync/errgroup"
)
var ErrUsedUploader = errors.New("the Uploader has been already used")
const (
defaultMaxConcurrency int = 5
defaultMinPartSize int = 6 <... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/s3_escape_test.go | tools/filesystem/internal/s3blob/s3/s3_escape_test.go | package s3
import (
"net/url"
"testing"
)
func TestEscapePath(t *testing.T) {
t.Parallel()
escaped := escapePath("/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_.~ !@#$%^&*()+={}[]?><\\|,`'\"/@sub1/@sub2/a/b/c/1/2/3")
expected := "/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345678... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/copy_object.go | tools/filesystem/internal/s3blob/s3/copy_object.go | package s3
import (
"context"
"encoding/xml"
"net/http"
"net/url"
"strings"
"time"
)
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_CopyObject.html#API_CopyObject_ResponseSyntax
type CopyObjectResponse struct {
CopyObjectResult xml.Name `json:"copyObjectResult" xml:"CopyObjectResult"`
ETag ... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/head_object.go | tools/filesystem/internal/s3blob/s3/head_object.go | package s3
import (
"context"
"net/http"
"strconv"
"time"
)
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html#API_HeadObject_ResponseElements
type HeadObjectResponse struct {
// Metadata is the extra data that is stored with the S3 object (aka. the "x-amz-meta-*" header values).
//
// The ... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/delete_object.go | tools/filesystem/internal/s3blob/s3/delete_object.go | package s3
import (
"context"
"net/http"
)
// DeleteObject deletes a single object by its key.
//
// https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html
func (s3 *S3) DeleteObject(ctx context.Context, key string, optFuncs ...func(*http.Request)) error {
req, err := http.NewRequestWithContext(ctx,... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/tests/client.go | tools/filesystem/internal/s3blob/s3/tests/client.go | // Package tests contains various tests helpers and utilities to assist
// with the S3 client testing.
package tests
import (
"errors"
"fmt"
"io"
"net/http"
"regexp"
"slices"
"strings"
"sync"
)
// NewClient creates a new test Client loaded with the specified RequestStubs.
func NewClient(stubs ...*RequestStub)... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/s3blob/s3/tests/headers.go | tools/filesystem/internal/s3blob/s3/tests/headers.go | package tests
import (
"net/http"
"regexp"
"strings"
)
// ExpectHeaders checks whether specified headers match the expectations.
// The expectations map entry key is the header name.
// The expectations map entry value is the first header value. If wrapped with `^...$`
// it is compared as regular expression.
func... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/fileblob/attrs.go | tools/filesystem/internal/fileblob/attrs.go | package fileblob
import (
"encoding/json"
"fmt"
"os"
)
// Largely copied from gocloud.dev/blob/fileblob to apply the same
// retrieve and write side-car .attrs rules.
//
// -------------------------------------------------------------------
// Copyright 2018 The Go Cloud Development Kit Authors
//
// Licensed unde... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/filesystem/internal/fileblob/fileblob.go | tools/filesystem/internal/fileblob/fileblob.go | // Package fileblob provides a blob.Bucket driver implementation.
//
// NB! To minimize breaking changes with older PocketBase releases,
// the driver is a stripped down and adapted version of the previously
// used gocloud.dev/blob/fileblob, hence many of the below doc comments,
// struct options and interface impleme... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/types/types_test.go | tools/types/types_test.go | package types_test
import (
"testing"
"github.com/pocketbase/pocketbase/tools/types"
)
func TestPointer(t *testing.T) {
s1 := types.Pointer("")
if s1 == nil || *s1 != "" {
t.Fatalf("Expected empty string pointer, got %#v", s1)
}
s2 := types.Pointer("test")
if s2 == nil || *s2 != "test" {
t.Fatalf("Expect... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/types/types.go | tools/types/types.go | // Package types implements some commonly used db serializable types
// like datetime, json, etc.
package types
// Pointer is a generic helper that returns val as *T.
func Pointer[T any](val T) *T {
return &val
}
| go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/types/json_map_test.go | tools/types/json_map_test.go | package types_test
import (
"database/sql/driver"
"fmt"
"testing"
"github.com/pocketbase/pocketbase/tools/types"
)
func TestJSONMapMarshalJSON(t *testing.T) {
scenarios := []struct {
json types.JSONMap[any]
expected string
}{
{nil, "{}"},
{types.JSONMap[any]{}, `{}`},
{types.JSONMap[any]{"test1":... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/types/datetime.go | tools/types/datetime.go | package types
import (
"database/sql/driver"
"encoding/json"
"time"
"github.com/spf13/cast"
)
// DefaultDateLayout specifies the default app date strings layout.
const DefaultDateLayout = "2006-01-02 15:04:05.000Z"
// NowDateTime returns new DateTime instance with the current local time.
func NowDateTime() Date... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/types/geo_point_test.go | tools/types/geo_point_test.go | package types_test
import (
"fmt"
"testing"
"github.com/pocketbase/pocketbase/tools/types"
)
func TestGeoPointAsMap(t *testing.T) {
t.Parallel()
scenarios := []struct {
name string
point types.GeoPoint
expected map[string]any
}{
{"zero", types.GeoPoint{}, map[string]any{"lon": 0.0, "lat": 0.0}}... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/types/json_raw.go | tools/types/json_raw.go | package types
import (
"database/sql/driver"
"encoding/json"
"errors"
)
// JSONRaw defines a json value type that is safe for db read/write.
type JSONRaw []byte
// ParseJSONRaw creates a new JSONRaw instance from the provided value
// (could be JSONRaw, int, float, string, []byte, etc.).
func ParseJSONRaw(value a... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/types/json_map.go | tools/types/json_map.go | package types
import (
"database/sql/driver"
"encoding/json"
"fmt"
)
// JSONMap defines a map that is safe for json and db read/write.
type JSONMap[T any] map[string]T
// MarshalJSON implements the [json.Marshaler] interface.
func (m JSONMap[T]) MarshalJSON() ([]byte, error) {
type alias JSONMap[T] // prevent re... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/types/json_raw_test.go | tools/types/json_raw_test.go | package types_test
import (
"database/sql/driver"
"fmt"
"testing"
"github.com/pocketbase/pocketbase/tools/types"
)
func TestParseJSONRaw(t *testing.T) {
scenarios := []struct {
value any
expectError bool
expectJSON string
}{
{nil, false, `null`},
{``, false, `null`},
{[]byte{}, false, `null`... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/types/geo_point.go | tools/types/geo_point.go | package types
import (
"database/sql/driver"
"encoding/json"
"fmt"
)
// GeoPoint defines a struct for storing geo coordinates as serialized json object
// (e.g. {lon:0,lat:0}).
//
// Note: using object notation and not a plain array to avoid the confusion
// as there doesn't seem to be a fixed standard for the coo... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/types/datetime_test.go | tools/types/datetime_test.go | package types_test
import (
"fmt"
"strings"
"testing"
"time"
"github.com/pocketbase/pocketbase/tools/types"
)
func TestNowDateTime(t *testing.T) {
now := time.Now().UTC().Format("2006-01-02 15:04:05") // without ms part for test consistency
dt := types.NowDateTime()
if !strings.Contains(dt.String(), now) {
... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/types/json_array_test.go | tools/types/json_array_test.go | package types_test
import (
"database/sql/driver"
"encoding/json"
"fmt"
"testing"
"github.com/pocketbase/pocketbase/tools/types"
)
func TestJSONArrayMarshalJSON(t *testing.T) {
scenarios := []struct {
json json.Marshaler
expected string
}{
{new(types.JSONArray[any]), "[]"},
{types.JSONArray[any]{}... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/types/json_array.go | tools/types/json_array.go | package types
import (
"database/sql/driver"
"encoding/json"
"fmt"
)
// JSONArray defines a slice that is safe for json and db read/write.
type JSONArray[T any] []T
// internal alias to prevent recursion during marshalization.
type jsonArrayAlias[T any] JSONArray[T]
// MarshalJSON implements the [json.Marshaler]... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/security/random_test.go | tools/security/random_test.go | package security_test
import (
"fmt"
"regexp"
"slices"
"testing"
"github.com/pocketbase/pocketbase/tools/security"
)
func TestRandomString(t *testing.T) {
testRandomString(t, security.RandomString)
}
func TestRandomStringWithAlphabet(t *testing.T) {
testRandomStringWithAlphabet(t, security.RandomStringWithAl... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/security/jwt_test.go | tools/security/jwt_test.go | package security_test
import (
"testing"
"time"
"github.com/golang-jwt/jwt/v5"
"github.com/pocketbase/pocketbase/tools/security"
)
func TestParseUnverifiedJWT(t *testing.T) {
// invalid formatted JWT
result1, err1 := security.ParseUnverifiedJWT("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoidGVzdCJ9")
if e... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/security/crypto_test.go | tools/security/crypto_test.go | package security_test
import (
"fmt"
"testing"
"github.com/pocketbase/pocketbase/tools/security"
)
func TestS256Challenge(t *testing.T) {
scenarios := []struct {
code string
expected string
}{
{"", "47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU"},
{"123", "pmWkWSBCL51Bfkhn79xPuKBKHz__H6B-mY6G9_eieuM"}... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/security/encrypt_test.go | tools/security/encrypt_test.go | package security_test
import (
"fmt"
"testing"
"github.com/pocketbase/pocketbase/tools/security"
)
func TestEncrypt(t *testing.T) {
scenarios := []struct {
data string
key string
expectError bool
}{
{"", "", true},
{"123", "test", true}, // key must be valid 32 char aes string
{"123",... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/security/encrypt.go | tools/security/encrypt.go | package security
import (
"crypto/aes"
"crypto/cipher"
crand "crypto/rand"
"encoding/base64"
"io"
)
// Encrypt encrypts "data" with the specified "key" (must be valid 32 char AES key).
//
// This method uses AES-256-GCM block cypher mode.
func Encrypt(data []byte, key string) (string, error) {
block, err := aes... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/security/random_by_regex_test.go | tools/security/random_by_regex_test.go | package security_test
import (
"fmt"
"regexp"
"regexp/syntax"
"slices"
"testing"
"github.com/pocketbase/pocketbase/tools/security"
)
func TestRandomStringByRegex(t *testing.T) {
generated := []string{}
scenarios := []struct {
pattern string
flags []syntax.Flags
expectError bool
}{
{``, ni... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/security/jwt.go | tools/security/jwt.go | package security
import (
"errors"
"time"
"github.com/golang-jwt/jwt/v5"
)
// ParseUnverifiedJWT parses JWT and returns its claims
// but DOES NOT verify the signature.
//
// It verifies only the exp, iat and nbf claims.
func ParseUnverifiedJWT(token string) (jwt.MapClaims, error) {
claims := jwt.MapClaims{}
p... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/security/crypto.go | tools/security/crypto.go | package security
import (
"crypto/hmac"
"crypto/md5"
"crypto/sha256"
"crypto/sha512"
"crypto/subtle"
"encoding/base64"
"fmt"
"strings"
)
// S256Challenge creates base64 encoded sha256 challenge string derived from code.
// The padding of the result base64 string is stripped per [RFC 7636].
//
// [RFC 7636]: h... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/security/random_by_regex.go | tools/security/random_by_regex.go | package security
import (
cryptoRand "crypto/rand"
"errors"
"fmt"
"math/big"
"regexp/syntax"
"strings"
)
const defaultMaxRepeat = 6
var anyCharNotNLPairs = []rune{'A', 'Z', 'a', 'z', '0', '9'}
// RandomStringByRegex generates a random string matching the regex pattern.
// If optFlags is not set, fallbacks to ... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/security/random.go | tools/security/random.go | package security
import (
cryptoRand "crypto/rand"
"math/big"
mathRand "math/rand/v2"
)
const defaultRandomAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
// RandomString generates a cryptographically random string with the specified length.
//
// The generated string matches [A-Za-z0-... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/template/registry.go | tools/template/registry.go | // Package template is a thin wrapper around the standard html/template
// and text/template packages that implements a convenient registry to
// load and cache templates on the fly concurrently.
//
// It was created to assist the JSVM plugin HTML rendering, but could be used in other Go code.
//
// Example:
//
// regi... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/template/renderer.go | tools/template/renderer.go | package template
import (
"bytes"
"errors"
"html/template"
)
// Renderer defines a single parsed template.
type Renderer struct {
template *template.Template
parseError error
}
// Render executes the template with the specified data as the dot object
// and returns the result as plain string.
func (r *Rendere... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/template/renderer_test.go | tools/template/renderer_test.go | package template
import (
"errors"
"html/template"
"testing"
)
func TestRendererRender(t *testing.T) {
tpl, _ := template.New("").Parse("Hello {{.Name}}!")
tpl.Option("missingkey=error") // enforce execute errors
scenarios := map[string]struct {
renderer *Renderer
data any
expectedHasErr ... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/template/registry_test.go | tools/template/registry_test.go | package template
import (
"fmt"
"os"
"path/filepath"
"strings"
"testing"
)
func checkRegistryFuncs(t *testing.T, r *Registry, expectedFuncs ...string) {
if v := len(r.funcs); v != len(expectedFuncs) {
t.Fatalf("Expected total %d funcs, got %d", len(expectedFuncs), v)
}
for _, name := range expectedFuncs {
... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/search/token_functions_test.go | tools/search/token_functions_test.go | package search
import (
"errors"
"fmt"
"strings"
"testing"
"github.com/ganigeorgiev/fexpr"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/tools/security"
)
func TestTokenFunctionsGeoDistance(t *testing.T) {
t.Parallel()
testDB, err := createTestDB()
if err != nil {
t.Fatal(err)
}
defer ... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/search/sort.go | tools/search/sort.go | package search
import (
"fmt"
"strings"
)
const (
randomSortKey string = "@random"
rowidSortKey string = "@rowid"
)
// sort field directions
const (
SortAsc string = "ASC"
SortDesc string = "DESC"
)
// SortField defines a single search sort field.
type SortField struct {
Name string `json:"name"`
Dir... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/search/identifier_macros.go | tools/search/identifier_macros.go | package search
import (
"fmt"
"time"
"github.com/pocketbase/pocketbase/tools/types"
)
// note: used primarily for the tests
var timeNow = func() time.Time {
return time.Now()
}
var identifierMacros = map[string]func() (any, error){
"@now": func() (any, error) {
today := timeNow().UTC()
d, err := types.Par... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/search/simple_field_resolver_test.go | tools/search/simple_field_resolver_test.go | package search_test
import (
"fmt"
"testing"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/tools/search"
)
func TestSimpleFieldResolverUpdateQuery(t *testing.T) {
r := search.NewSimpleFieldResolver("test")
scenarios := []struct {
fieldName string
expectQuery string
}{
// missing field... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/search/filter.go | tools/search/filter.go | package search
import (
"encoding/json"
"errors"
"fmt"
"strconv"
"strings"
"github.com/ganigeorgiev/fexpr"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/tools/security"
"github.com/pocketbase/pocketbase/tools/store"
"github.com/spf13/cast"
)
// FilterData is a filter expression string follo... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/search/filter_test.go | tools/search/filter_test.go | package search_test
import (
"context"
"database/sql"
"fmt"
"regexp"
"strings"
"testing"
"time"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/tools/search"
)
func TestFilterDataBuildExpr(t *testing.T) {
resolver := search.NewSimpleFieldResolver("test1", "test2", "test3", `^test4_\w+$`, `^te... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/search/simple_field_resolver.go | tools/search/simple_field_resolver.go | package search
import (
"fmt"
"strconv"
"strings"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/tools/inflector"
"github.com/pocketbase/pocketbase/tools/list"
)
// ResolverResult defines a single FieldResolver.Resolve() successfully parsed result.
type ResolverResult struct {
// Identifier is ... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/search/identifier_macros_test.go | tools/search/identifier_macros_test.go | package search
import (
"testing"
"time"
)
func TestIdentifierMacros(t *testing.T) {
originalTimeNow := timeNow
timeNow = func() time.Time {
return time.Date(2023, 2, 3, 4, 5, 6, 7, time.UTC)
}
testMacros := map[string]any{
"@now": "2023-02-03 04:05:06.000Z",
"@yesterday": "2023-02-02 04:05:06.0... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/search/token_functions.go | tools/search/token_functions.go | package search
import (
"fmt"
"github.com/ganigeorgiev/fexpr"
)
var TokenFunctions = map[string]func(
argTokenResolverFunc func(fexpr.Token) (*ResolverResult, error),
args ...fexpr.Token,
) (*ResolverResult, error){
// geoDistance(lonA, latA, lonB, latB) calculates the Haversine
// distance between 2 points in... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/search/provider.go | tools/search/provider.go | package search
import (
"errors"
"math"
"net/url"
"strconv"
"strings"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/tools/inflector"
"golang.org/x/sync/errgroup"
)
const (
// DefaultPerPage specifies the default number of returned search result items.
DefaultPerPage int = 30
// DefaultFil... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/search/provider_test.go | tools/search/provider_test.go | package search
import (
"context"
"database/sql"
"encoding/json"
"errors"
"fmt"
"strconv"
"strings"
"testing"
"time"
"github.com/pocketbase/dbx"
"github.com/pocketbase/pocketbase/tools/list"
_ "modernc.org/sqlite"
)
func TestNewProvider(t *testing.T) {
r := &testFieldResolver{}
p := NewProvider(r)
if... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/search/sort_test.go | tools/search/sort_test.go | package search_test
import (
"encoding/json"
"fmt"
"testing"
"github.com/pocketbase/pocketbase/tools/search"
)
func TestSortFieldBuildExpr(t *testing.T) {
resolver := search.NewSimpleFieldResolver("test1", "test2", "test3", "test4.sub")
scenarios := []struct {
sortField search.SortField
expectError... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/router/rereadable_read_closer_test.go | tools/router/rereadable_read_closer_test.go | package router_test
import (
"io"
"strings"
"testing"
"github.com/pocketbase/pocketbase/tools/router"
)
func TestRereadableReadCloser(t *testing.T) {
content := "test"
rereadable := &router.RereadableReadCloser{
ReadCloser: io.NopCloser(strings.NewReader(content)),
}
// read multiple times
for i := 0; i... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/router/error.go | tools/router/error.go | package router
import (
"database/sql"
"errors"
"io/fs"
"net/http"
"strings"
validation "github.com/go-ozzo/ozzo-validation/v4"
"github.com/pocketbase/pocketbase/tools/inflector"
)
// SafeErrorItem defines a common error interface for a printable public safe error.
type SafeErrorItem interface {
// Code repr... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/router/group.go | tools/router/group.go | package router
import (
"net/http"
"regexp"
"strings"
"github.com/pocketbase/pocketbase/tools/hook"
)
// (note: the struct is named RouterGroup instead of Group so that it can
// be embedded in the Router without conflicting with the Group method)
// RouterGroup represents a collection of routes and other sub g... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/router/route_test.go | tools/router/route_test.go | package router
import (
"slices"
"testing"
"github.com/pocketbase/pocketbase/tools/hook"
)
func TestRouteBindFunc(t *testing.T) {
t.Parallel()
r := Route[*Event]{}
calls := ""
// append one function
r.BindFunc(func(e *Event) error {
calls += "a"
return nil
})
// append multiple functions
r.BindFun... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/router/group_test.go | tools/router/group_test.go | package router
import (
"errors"
"fmt"
"net/http"
"slices"
"testing"
"github.com/pocketbase/pocketbase/tools/hook"
)
func TestRouterGroupGroup(t *testing.T) {
t.Parallel()
g0 := RouterGroup[*Event]{}
g1 := g0.Group("test1")
g2 := g0.Group("test2")
if total := len(g0.children); total != 2 {
t.Fatalf("... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/router/error_test.go | tools/router/error_test.go | package router_test
import (
"database/sql"
"encoding/json"
"errors"
"fmt"
"io/fs"
"strconv"
"testing"
validation "github.com/go-ozzo/ozzo-validation/v4"
"github.com/pocketbase/pocketbase/tools/router"
)
func TestNewApiErrorWithRawData(t *testing.T) {
t.Parallel()
e := router.NewApiError(
300,
"messa... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/router/router.go | tools/router/router.go | package router
import (
"bufio"
"encoding/json"
"errors"
"io"
"log"
"net"
"net/http"
"github.com/pocketbase/pocketbase/tools/hook"
)
type EventCleanupFunc func()
// EventFactoryFunc defines the function responsible for creating a Route specific event
// based on the provided request handler ServeHTTP data.
... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/router/unmarshal_request_data_test.go | tools/router/unmarshal_request_data_test.go | package router_test
import (
"bytes"
"encoding/json"
"testing"
"time"
"github.com/pocketbase/pocketbase/tools/router"
)
func pointer[T any](val T) *T {
return &val
}
func TestUnmarshalRequestData(t *testing.T) {
t.Parallel()
mapData := map[string][]string{
"number1": {"1"},
"number2": {"2", "3"},
"nu... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/router/event_test.go | tools/router/event_test.go | package router_test
import (
"bytes"
"crypto/tls"
"encoding/json"
"encoding/xml"
"errors"
"fmt"
"io"
"mime/multipart"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"regexp"
"strconv"
"strings"
"testing"
validation "github.com/go-ozzo/ozzo-validation/v4"
"github.com/pocketbase/pocketbase/tools/... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/router/unmarshal_request_data.go | tools/router/unmarshal_request_data.go | package router
import (
"encoding"
"encoding/json"
"errors"
"reflect"
"regexp"
"strconv"
)
var textUnmarshalerType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem()
// JSONPayloadKey is the key for the special UnmarshalRequestData case
// used for reading serialized json payload without normalization.
... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/router/router_test.go | tools/router/router_test.go | package router_test
import (
"errors"
"net/http"
"net/http/httptest"
"testing"
"github.com/pocketbase/pocketbase/tools/hook"
"github.com/pocketbase/pocketbase/tools/router"
)
func TestRouter(t *testing.T) {
calls := ""
r := router.NewRouter(func(w http.ResponseWriter, r *http.Request) (*router.Event, router... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/router/event.go | tools/router/event.go | package router
import (
"encoding/json"
"encoding/xml"
"errors"
"io"
"io/fs"
"net"
"net/http"
"net/netip"
"path/filepath"
"strings"
"github.com/pocketbase/pocketbase/tools/filesystem"
"github.com/pocketbase/pocketbase/tools/hook"
"github.com/pocketbase/pocketbase/tools/picker"
"github.com/pocketbase/poc... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/router/rereadable_read_closer.go | tools/router/rereadable_read_closer.go | package router
import (
"bytes"
"io"
)
var (
_ io.ReadCloser = (*RereadableReadCloser)(nil)
_ Rereader = (*RereadableReadCloser)(nil)
)
// Rereader defines an interface for rewindable readers.
type Rereader interface {
Reread()
}
// RereadableReadCloser defines a wrapper around a io.ReadCloser reader
// a... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
pocketbase/pocketbase | https://github.com/pocketbase/pocketbase/blob/b1da83e5165f938453fbb21e748bca317b08239d/tools/router/route.go | tools/router/route.go | package router
import "github.com/pocketbase/pocketbase/tools/hook"
type Route[T hook.Resolver] struct {
excludedMiddlewares map[string]struct{}
Action func(e T) error
Method string
Path string
Middlewares []*hook.Handler[T]
}
// BindFunc registers one or multiple middleware functions to the c... | go | MIT | b1da83e5165f938453fbb21e748bca317b08239d | 2026-01-07T08:35:43.517402Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.