diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ed0ceace..ac7ff013 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -29,6 +29,11 @@ jobs: - name: Build Admin dashboard UI run: npm --prefix=./ui ci && npm --prefix=./ui run build + # Similar to the above, the jsvm docs are pregenerated locally + # but its here to ensure that it wasn't forgotten to be executed. + - name: Generate jsvm types + run: go run ./plugins/jsvm/internal/docs.go + # The prebuilt golangci-lint doesn't support go 1.18+ yet # https://github.com/golangci/golangci-lint/issues/2649 # - name: Run linter diff --git a/CHANGELOG.md b/CHANGELOG.md index ebc96ae9..199d2e69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,8 @@ - Allowed `0` as `RelationOptions.MinSelect` value to avoid the ambiguity between 0 and non-filled input value ([#2817](https://github.com/pocketbase/pocketbase/discussions/2817)). +- Minor Admin UI fixes (typos, grammar fixes, removed unnecessary 404 error check, etc.). + ## v0.16.8 diff --git a/Makefile b/Makefile index 8dfe9041..0dc94032 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,9 @@ lint: test: go test ./... -v --cover +jsvmdocs: + go run ./plugins/jsvm/internal/docs/docs.go + test-report: go test ./... -v --cover -coverprofile=coverage.out go tool cover -html=coverage.out diff --git a/examples/base/main.go b/examples/base/main.go index fa25643d..3afc13ed 100644 --- a/examples/base/main.go +++ b/examples/base/main.go @@ -42,7 +42,7 @@ func main() { app.RootCmd.PersistentFlags().IntVar( &hooksPool, "hooksPool", - 120, + 100, "the total prewarm goja.Runtime instances for the JS app hooks execution", ) diff --git a/plugins/jsvm/binds.go b/plugins/jsvm/binds.go index 3efe8e55..59dfe89d 100644 --- a/plugins/jsvm/binds.go +++ b/plugins/jsvm/binds.go @@ -1,10 +1,16 @@ package jsvm import ( + "bytes" + "context" "encoding/json" "errors" + "fmt" + "io" + "net/http" "reflect" "strings" + "time" "github.com/dop251/goja" validation "github.com/go-ozzo/ozzo-validation/v4" @@ -72,16 +78,21 @@ func hooksBinds(app core.App, loader *goja.Runtime, executors *vmsPool) { // check for returned hook.StopPropagation if res != nil { - if v, ok := res.Export().(error); ok { - return v + exported := res.Export() + if exported != nil { + if v, ok := exported.(error); ok { + return v + } } } // check for throwed hook.StopPropagation if err != nil { - exception, ok := err.(*goja.Exception) - if ok && errors.Is(exception.Value().Export().(error), hook.StopPropagation) { - return hook.StopPropagation + if exception, ok := err.(*goja.Exception); ok { + v, ok := exception.Value().Export().(error) + if ok && errors.Is(v, hook.StopPropagation) { + return hook.StopPropagation + } } } @@ -463,6 +474,100 @@ func apisBinds(vm *goja.Runtime) { registerFactoryAsConstructor(vm, "UnauthorizedError", apis.NewUnauthorizedError) } +func httpClientBinds(vm *goja.Runtime) { + obj := vm.NewObject() + vm.Set("$http", obj) + + type sendResult struct { + StatusCode int + Raw string + Json any + } + + type sendConfig struct { + Method string + Url string + Data map[string]any + Headers map[string]string + Timeout int // seconds (default to 120) + } + + obj.Set("send", func(params map[string]any) (*sendResult, error) { + rawParams, err := json.Marshal(params) + if err != nil { + return nil, err + } + + config := sendConfig{ + Method: "GET", + } + if err := json.Unmarshal(rawParams, &config); err != nil { + return nil, err + } + + if config.Timeout <= 0 { + config.Timeout = 120 + } + + ctx, cancel := context.WithTimeout(context.Background(), time.Duration(config.Timeout)*time.Second) + defer cancel() + + var reqBody io.Reader + if len(config.Data) != 0 { + encoded, err := json.Marshal(config.Data) + if err != nil { + return nil, err + } + reqBody = bytes.NewReader(encoded) + } + + req, err := http.NewRequestWithContext(ctx, strings.ToUpper(config.Method), config.Url, reqBody) + if err != nil { + return nil, err + } + + for k, v := range config.Headers { + req.Header.Add(k, v) + } + + // set default content-type header (if missing) + if req.Header.Get("content-type") == "" { + req.Header.Set("content-type", "application/json") + } + + res, err := http.DefaultClient.Do(req) + if err != nil { + return nil, err + } + defer res.Body.Close() + + if res.StatusCode < 200 || res.StatusCode >= 400 { + return nil, fmt.Errorf("request failed with status %d", res.StatusCode) + } + + bodyRaw, _ := io.ReadAll(res.Body) + + result := &sendResult{ + StatusCode: res.StatusCode, + Raw: string(bodyRaw), + } + + if len(result.Raw) != 0 { + // try as map + result.Json = map[string]any{} + if err := json.Unmarshal(bodyRaw, &result.Json); err != nil { + // try as slice + result.Json = []any{} + if err := json.Unmarshal(bodyRaw, &result.Json); err != nil { + result.Json = nil + } + } + } + + return result, nil + }) +} + // ------------------------------------------------------------------- // registerFactoryAsConstructor registers the factory function as native JS constructor. diff --git a/plugins/jsvm/binds_test.go b/plugins/jsvm/binds_test.go index f8c0bf63..72fe78cb 100644 --- a/plugins/jsvm/binds_test.go +++ b/plugins/jsvm/binds_test.go @@ -2,9 +2,15 @@ package jsvm import ( "encoding/json" + "io" "mime/multipart" + "net/http" + "net/http/httptest" "path/filepath" + "strconv" + "strings" "testing" + "time" "github.com/dop251/goja" validation "github.com/go-ozzo/ozzo-validation/v4" @@ -760,11 +766,11 @@ func TestLoadingDynamicModel(t *testing.T) { }) $app.dao().db() - .select("text", "bool", "number", "select_many", "json", "('{\"test\": 1}') as obj") - .from("demo1") - .where($dbx.hashExp({"id": "84nmscqy84lsi1t"})) - .limit(1) - .one(result) + .select("text", "bool", "number", "select_many", "json", "('{\"test\": 1}') as obj") + .from("demo1") + .where($dbx.hashExp({"id": "84nmscqy84lsi1t"})) + .limit(1) + .one(result) if (result.text != "test") { throw new Error('Expected text "test", got ' + result.text); @@ -811,12 +817,12 @@ func TestLoadingArrayOf(t *testing.T) { })) $app.dao().db() - .select("id", "text") - .from("demo1") - .where($dbx.exp("id='84nmscqy84lsi1t' OR id='al1h9ijdeojtsjy'")) - .limit(2) - .orderBy("text ASC") - .all(result) + .select("id", "text") + .from("demo1") + .where($dbx.exp("id='84nmscqy84lsi1t' OR id='al1h9ijdeojtsjy'")) + .limit(2) + .orderBy("text ASC") + .all(result) if (result.length != 2) { throw new Error('Expected 2 list items, got ' + result.length); @@ -840,3 +846,144 @@ func TestLoadingArrayOf(t *testing.T) { t.Fatal(err) } } + +func TestHttpClientBindsCount(t *testing.T) { + app, _ := tests.NewTestApp() + defer app.Cleanup() + + vm := goja.New() + httpClientBinds(vm) + + testBindsCount(vm, "$http", 1, t) +} + +func TestHttpClientBindsSend(t *testing.T) { + // start a test server + server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { + if req.URL.Query().Get("testError") != "" { + rw.WriteHeader(400) + return + } + + timeoutStr := req.URL.Query().Get("testTimeout") + timeout, _ := strconv.Atoi(timeoutStr) + if timeout > 0 { + time.Sleep(time.Duration(timeout) * time.Second) + } + + bodyRaw, _ := io.ReadAll(req.Body) + defer req.Body.Close() + body := map[string]any{} + json.Unmarshal(bodyRaw, &body) + + // normalize headers + headers := make(map[string]string, len(req.Header)) + for k, v := range req.Header { + if len(v) > 0 { + headers[strings.ToLower(strings.ReplaceAll(k, "-", "_"))] = v[0] + } + } + + info := map[string]any{ + "method": req.Method, + "headers": headers, + "body": body, + } + + infoRaw, _ := json.Marshal(info) + + // write back the submitted request + rw.Write(infoRaw) + })) + defer server.Close() + + vm := goja.New() + baseBinds(vm) + httpClientBinds(vm) + vm.Set("testUrl", server.URL) + + _, err := vm.RunString(` + function getNestedVal(data, path) { + let result = data || {}; + let parts = path.split("."); + + for (const part of parts) { + if ( + result == null || + typeof result !== "object" || + typeof result[part] === "undefined" + ) { + return null; + } + + result = result[part]; + } + + return result; + } + + let testErr; + try { + $http.send({ url: testUrl + "?testError=1" }) + } catch (err) { + testErr = err + } + if (!testErr) { + throw new Error("Expected an error") + } + + let testTimeout; + try { + $http.send({ + url: testUrl + "?testTimeout=3", + timeout: 1 + }) + } catch (err) { + testTimeout = err + } + if (!testTimeout) { + throw new Error("Expected timeout error") + } + + // basic fields check + const test1 = $http.send({ + method: "post", + url: testUrl, + data: {"data": "example"}, + headers: {"header1": "123", "header2": "456"} + }) + + // with custom content-type header + const test2 = $http.send({ + url: testUrl, + headers: {"content-type": "text/plain"} + }) + + const scenarios = [ + [test1, { + "json.method": "POST", + "json.headers.header1": "123", + "json.headers.header2": "456", + "json.headers.content_type": "application/json", // default + }], + [test2, { + "json.method": "GET", + "json.headers.content_type": "text/plain", + }], + ] + + for (let scenario in scenarios) { + const result = scenario[0]; + const expectations = scenario[1]; + + for (let key in expectations) { + if (getNestedVal(result, key) != expectations[key]) { + throw new Error('Expected ' + key + ' ' + expectations[key] + ', got: ' + result.raw); + } + } + } + `) + if err != nil { + t.Fatal(err) + } +} diff --git a/plugins/jsvm/internal/docs/docs.go b/plugins/jsvm/internal/docs/docs.go index 2778fc8f..a68521d5 100644 --- a/plugins/jsvm/internal/docs/docs.go +++ b/plugins/jsvm/internal/docs/docs.go @@ -3,7 +3,9 @@ package main import ( "log" "os" + "path/filepath" "reflect" + "runtime" "strings" "github.com/pocketbase/pocketbase/core" @@ -646,6 +648,29 @@ declare namespace $apis { let enrichRecords: apis.enrichRecords } +// ------------------------------------------------------------------- +// httpClientBinds +// ------------------------------------------------------------------- + +declare namespace $http { + /** + * Sends a single HTTP request (_currently only json and plain text requests_). + * + * @group PocketBase + */ + function send(params: { + url: string, + method?: string, // default to "GET" + data?: { [key:string]: any }, + headers?: { [key:string]: string }, + timeout?: number // default to 120 + }): { + statusCode: number + raw: string + json: any + }; +} + // ------------------------------------------------------------------- // migrate only // ------------------------------------------------------------------- @@ -695,7 +720,15 @@ func main() { log.Fatal(err) } - if err := os.WriteFile("./generated/types.d.ts", []byte(result), 0644); err != nil { + _, filename, _, ok := runtime.Caller(0) + if !ok { + log.Fatal("Failed to get the current docs directory") + } + + parentDir := filepath.Dir(filename) + typesFile := filepath.Join(parentDir, "generated", "types.d.ts") + + if err := os.WriteFile(typesFile, []byte(result), 0644); err != nil { log.Fatal(err) } } diff --git a/plugins/jsvm/internal/docs/generated/types.d.ts b/plugins/jsvm/internal/docs/generated/types.d.ts index 58426985..e25bbc80 100644 --- a/plugins/jsvm/internal/docs/generated/types.d.ts +++ b/plugins/jsvm/internal/docs/generated/types.d.ts @@ -82,7 +82,7 @@ declare function routerPre(...middlewares: Array): v type appWithoutHooks = Omit /** - * $app is the current running PocketBase instance that is globally + * `$app` is the current running PocketBase instance that is globally * available in each .pb.js file. * * @namespace @@ -289,7 +289,7 @@ declare class Dao implements daos.Dao { // ------------------------------------------------------------------- /** - * $dbx defines common utility for working with the DB abstraction. + * `$dbx` defines common utility for working with the DB abstraction. * For examples and guides please check the [Database guide](https://pocketbase.io/docs/js-database). * * @group PocketBase @@ -633,6 +633,29 @@ declare namespace $apis { let enrichRecords: apis.enrichRecords } +// ------------------------------------------------------------------- +// httpClientBinds +// ------------------------------------------------------------------- + +declare namespace $http { + /** + * Sends a single HTTP request (_currently only json and plain text requests_). + * + * @group PocketBase + */ + function send(params: { + url: string, + method?: string, // default to "GET" + data?: { [key:string]: any }, + headers?: { [key:string]: string }, + timeout?: number // default to 120 + }): { + statusCode: number + raw: string + json: any + }; +} + // ------------------------------------------------------------------- // migrate only // ------------------------------------------------------------------- @@ -739,6 +762,23 @@ declare function migrate( type _TygojaDict = { [key:string | number | symbol]: any; } type _TygojaAny = any +/** + * Package validation provides configurable and extensible rules for validating data of various types. + */ +namespace ozzo_validation { + /** + * Error interface represents an validation error + */ + interface Error { + error(): string + code(): string + message(): string + setMessage(_arg0: string): Error + params(): _TygojaDict + setParams(_arg0: _TygojaDict): Error + } +} + /** * Package dbx provides a set of DB-agnostic and easy-to-use query building methods for relational databases. */ @@ -1074,14 +1114,14 @@ namespace dbx { /** * MssqlBuilder is the builder for SQL Server databases. */ - type _subRwVZc = BaseBuilder - interface MssqlBuilder extends _subRwVZc { + type _subqtYZD = BaseBuilder + interface MssqlBuilder extends _subqtYZD { } /** * MssqlQueryBuilder is the query builder for SQL Server databases. */ - type _subjDXIu = BaseQueryBuilder - interface MssqlQueryBuilder extends _subjDXIu { + type _subUGoRL = BaseQueryBuilder + interface MssqlQueryBuilder extends _subUGoRL { } interface newMssqlBuilder { /** @@ -1152,8 +1192,8 @@ namespace dbx { /** * MysqlBuilder is the builder for MySQL databases. */ - type _subihLpJ = BaseBuilder - interface MysqlBuilder extends _subihLpJ { + type _subekZiI = BaseBuilder + interface MysqlBuilder extends _subekZiI { } interface newMysqlBuilder { /** @@ -1228,14 +1268,14 @@ namespace dbx { /** * OciBuilder is the builder for Oracle databases. */ - type _subVGAih = BaseBuilder - interface OciBuilder extends _subVGAih { + type _subicixw = BaseBuilder + interface OciBuilder extends _subicixw { } /** * OciQueryBuilder is the query builder for Oracle databases. */ - type _subHUgjY = BaseQueryBuilder - interface OciQueryBuilder extends _subHUgjY { + type _subgVgiv = BaseQueryBuilder + interface OciQueryBuilder extends _subgVgiv { } interface newOciBuilder { /** @@ -1298,8 +1338,8 @@ namespace dbx { /** * PgsqlBuilder is the builder for PostgreSQL databases. */ - type _subvSAyY = BaseBuilder - interface PgsqlBuilder extends _subvSAyY { + type _subKmbTo = BaseBuilder + interface PgsqlBuilder extends _subKmbTo { } interface newPgsqlBuilder { /** @@ -1366,8 +1406,8 @@ namespace dbx { /** * SqliteBuilder is the builder for SQLite databases. */ - type _subpUhEg = BaseBuilder - interface SqliteBuilder extends _subpUhEg { + type _subegumr = BaseBuilder + interface SqliteBuilder extends _subegumr { } interface newSqliteBuilder { /** @@ -1466,8 +1506,8 @@ namespace dbx { /** * StandardBuilder is the builder that is used by DB for an unknown driver. */ - type _subDyAUh = BaseBuilder - interface StandardBuilder extends _subDyAUh { + type _subTfEWs = BaseBuilder + interface StandardBuilder extends _subTfEWs { } interface newStandardBuilder { /** @@ -1533,8 +1573,8 @@ namespace dbx { * DB enhances sql.DB by providing a set of DB-agnostic query building methods. * DB allows easier query building and population of data into Go variables. */ - type _subNjulM = Builder - interface DB extends _subNjulM { + type _subaNIyW = Builder + interface DB extends _subaNIyW { /** * FieldMapper maps struct fields to DB columns. Defaults to DefaultFieldMapFunc. */ @@ -2332,8 +2372,8 @@ namespace dbx { * Rows enhances sql.Rows by providing additional data query methods. * Rows can be obtained by calling Query.Rows(). It is mainly used to populate data row by row. */ - type _subqbsqX = sql.Rows - interface Rows extends _subqbsqX { + type _suboQmda = sql.Rows + interface Rows extends _suboQmda { } interface Rows { /** @@ -2690,8 +2730,8 @@ namespace dbx { }): string } interface structInfo { } - type _subNEFLd = structInfo - interface structValue extends _subNEFLd { + type _subtLdZe = structInfo + interface structValue extends _subtLdZe { } interface fieldInfo { } @@ -2729,8 +2769,8 @@ namespace dbx { /** * Tx enhances sql.Tx with additional querying methods. */ - type _subABUGx = Builder - interface Tx extends _subABUGx { + type _subvlQPy = Builder + interface Tx extends _subvlQPy { } interface Tx { /** @@ -2914,8 +2954,8 @@ namespace filesystem { */ open(): io.ReadSeekCloser } - type _subHuHWJ = bytes.Reader - interface bytesReadSeekCloser extends _subHuHWJ { + type _subfPdNz = bytes.Reader + interface bytesReadSeekCloser extends _subfPdNz { } interface bytesReadSeekCloser { /** @@ -3032,23 +3072,6 @@ namespace filesystem { } } -/** - * Package validation provides configurable and extensible rules for validating data of various types. - */ -namespace ozzo_validation { - /** - * Error interface represents an validation error - */ - interface Error { - error(): string - code(): string - message(): string - setMessage(_arg0: string): Error - params(): _TygojaDict - setParams(_arg0: _TygojaDict): Error - } -} - /** * Package tokens implements various user and admin tokens generation methods. */ @@ -3987,8 +4010,8 @@ namespace forms { /** * SettingsUpsert is a [settings.Settings] upsert (create/update) form. */ - type _subNcyzX = settings.Settings - interface SettingsUpsert extends _subNcyzX { + type _subJQksV = settings.Settings + interface SettingsUpsert extends _subJQksV { } interface newSettingsUpsert { /** @@ -4378,8 +4401,8 @@ namespace pocketbase { /** * appWrapper serves as a private core.App instance wrapper. */ - type _subHwICq = core.App - interface appWrapper extends _subHwICq { + type _subINXvZ = core.App + interface appWrapper extends _subINXvZ { } /** * PocketBase defines a PocketBase app launcher. @@ -4387,8 +4410,8 @@ namespace pocketbase { * It implements [core.App] via embedding and all of the app interface methods * could be accessed directly through the instance (eg. PocketBase.DataDir()). */ - type _subrjcAX = appWrapper - interface PocketBase extends _subrjcAX { + type _subKEMwG = appWrapper + interface PocketBase extends _subKEMwG { /** * RootCmd is the main console command */ @@ -4721,6 +4744,35 @@ namespace time { } } +/** + * Package fs defines basic interfaces to a file system. + * A file system can be provided by the host operating system + * but also by other packages. + */ +namespace fs { + /** + * An FS provides access to a hierarchical file system. + * + * The FS interface is the minimum implementation required of the file system. + * A file system may implement additional interfaces, + * such as ReadFileFS, to provide additional or optimized functionality. + */ + interface FS { + /** + * Open opens the named file. + * + * When Open returns an error, it should be of type *PathError + * with the Op field set to "open", the Path field set to name, + * and the Err field describing the problem. + * + * Open should reject attempts to open names that do not satisfy + * ValidPath(name), returning a *PathError with Err set to + * ErrInvalid or ErrNotExist. + */ + open(name: string): File + } +} + /** * Package context defines the Context type, which carries deadlines, * cancellation signals, and other request-scoped values across API boundaries @@ -4877,92 +4929,6 @@ namespace context { } } -/** - * Package fs defines basic interfaces to a file system. - * A file system can be provided by the host operating system - * but also by other packages. - */ -namespace fs { - /** - * An FS provides access to a hierarchical file system. - * - * The FS interface is the minimum implementation required of the file system. - * A file system may implement additional interfaces, - * such as ReadFileFS, to provide additional or optimized functionality. - */ - interface FS { - /** - * Open opens the named file. - * - * When Open returns an error, it should be of type *PathError - * with the Op field set to "open", the Path field set to name, - * and the Err field describing the problem. - * - * Open should reject attempts to open names that do not satisfy - * ValidPath(name), returning a *PathError with Err set to - * ErrInvalid or ErrNotExist. - */ - open(name: string): File - } -} - -/** - * Package jwt is a Go implementation of JSON Web Tokens: http://self-issued.info/docs/draft-jones-json-web-token.html - * - * See README.md for more info. - */ -namespace jwt { - /** - * MapClaims is a claims type that uses the map[string]interface{} for JSON decoding. - * This is the default claims type if you don't supply one - */ - interface MapClaims extends _TygojaDict{} - interface MapClaims { - /** - * VerifyAudience Compares the aud claim against cmp. - * If required is false, this method will return true if the value matches or is unset - */ - verifyAudience(cmp: string, req: boolean): boolean - } - interface MapClaims { - /** - * VerifyExpiresAt compares the exp claim against cmp (cmp <= exp). - * If req is false, it will return true, if exp is unset. - */ - verifyExpiresAt(cmp: number, req: boolean): boolean - } - interface MapClaims { - /** - * VerifyIssuedAt compares the exp claim against cmp (cmp >= iat). - * If req is false, it will return true, if iat is unset. - */ - verifyIssuedAt(cmp: number, req: boolean): boolean - } - interface MapClaims { - /** - * VerifyNotBefore compares the nbf claim against cmp (cmp >= nbf). - * If req is false, it will return true, if nbf is unset. - */ - verifyNotBefore(cmp: number, req: boolean): boolean - } - interface MapClaims { - /** - * VerifyIssuer compares the iss claim against cmp. - * If required is false, this method will return true if the value matches or is unset - */ - verifyIssuer(cmp: string, req: boolean): boolean - } - interface MapClaims { - /** - * Valid validates time based claims "exp, iat, nbf". - * There is no accounting for clock skew. - * As well, if any of the above claims are not in the token, it will still - * be considered a valid claim. - */ - valid(): void - } -} - /** * Package multipart implements MIME multipart parsing, as defined in RFC * 2046. @@ -5659,112 +5625,302 @@ namespace http { } } -namespace auth { +/** + * Package blob provides an easy and portable way to interact with blobs + * within a storage location. Subpackages contain driver implementations of + * blob for supported services. + * + * See https://gocloud.dev/howto/blob/ for a detailed how-to guide. + * + * # Errors + * + * The errors returned from this package can be inspected in several ways: + * + * The Code function from gocloud.dev/gcerrors will return an error code, also + * defined in that package, when invoked on an error. + * + * The Bucket.ErrorAs method can retrieve the driver error underlying the returned + * error. + * + * # OpenCensus Integration + * + * OpenCensus supports tracing and metric collection for multiple languages and + * backend providers. See https://opencensus.io. + * + * This API collects OpenCensus traces and metrics for the following methods: + * ``` + * - Attributes + * - Copy + * - Delete + * - ListPage + * - NewRangeReader, from creation until the call to Close. (NewReader and ReadAll + * are included because they call NewRangeReader.) + * - NewWriter, from creation until the call to Close. + * ``` + * + * All trace and metric names begin with the package import path. + * The traces add the method name. + * For example, "gocloud.dev/blob/Attributes". + * The metrics are "completed_calls", a count of completed method calls by driver, + * method and status (error code); and "latency", a distribution of method latency + * by driver and method. + * For example, "gocloud.dev/blob/latency". + * + * It also collects the following metrics: + * ``` + * - gocloud.dev/blob/bytes_read: the total number of bytes read, by driver. + * - gocloud.dev/blob/bytes_written: the total number of bytes written, by driver. + * ``` + * + * To enable trace collection in your application, see "Configure Exporter" at + * https://opencensus.io/quickstart/go/tracing. + * To enable metric collection in your application, see "Exporting stats" at + * https://opencensus.io/quickstart/go/metrics. + */ +namespace blob { /** - * AuthUser defines a standardized oauth2 user data structure. + * Reader reads bytes from a blob. + * It implements io.ReadSeekCloser, and must be closed after + * reads are finished. */ - interface AuthUser { - id: string - name: string - username: string - email: string - avatarUrl: string - rawUser: _TygojaDict - accessToken: string - refreshToken: string + interface Reader { + } + interface Reader { + /** + * Read implements io.Reader (https://golang.org/pkg/io/#Reader). + */ + read(p: string): number + } + interface Reader { + /** + * Seek implements io.Seeker (https://golang.org/pkg/io/#Seeker). + */ + seek(offset: number, whence: number): number + } + interface Reader { + /** + * Close implements io.Closer (https://golang.org/pkg/io/#Closer). + */ + close(): void + } + interface Reader { + /** + * ContentType returns the MIME type of the blob. + */ + contentType(): string + } + interface Reader { + /** + * ModTime returns the time the blob was last modified. + */ + modTime(): time.Time + } + interface Reader { + /** + * Size returns the size of the blob content in bytes. + */ + size(): number + } + interface Reader { + /** + * As converts i to driver-specific types. + * See https://gocloud.dev/concepts/as/ for background information, the "As" + * examples in this package for examples, and the driver package + * documentation for the specific types supported for that driver. + */ + as(i: { + }): boolean + } + interface Reader { + /** + * WriteTo reads from r and writes to w until there's no more data or + * an error occurs. + * The return value is the number of bytes written to w. + * + * It implements the io.WriterTo interface. + */ + writeTo(w: io.Writer): number } /** - * Provider defines a common interface for an OAuth2 client. + * Attributes contains attributes about a blob. */ - interface Provider { + interface Attributes { /** - * Scopes returns the context associated with the provider (if any). + * CacheControl specifies caching attributes that services may use + * when serving the blob. + * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control */ - context(): context.Context + cacheControl: string /** - * SetContext assigns the specified context to the current provider. + * ContentDisposition specifies whether the blob content is expected to be + * displayed inline or as an attachment. + * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition */ - setContext(ctx: context.Context): void + contentDisposition: string /** - * Scopes returns the provider access permissions that will be requested. + * ContentEncoding specifies the encoding used for the blob's content, if any. + * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding */ - scopes(): Array + contentEncoding: string /** - * SetScopes sets the provider access permissions that will be requested later. + * ContentLanguage specifies the language used in the blob's content, if any. + * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Language */ - setScopes(scopes: Array): void + contentLanguage: string /** - * ClientId returns the provider client's app ID. + * ContentType is the MIME type of the blob. It will not be empty. + * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type */ - clientId(): string + contentType: string /** - * SetClientId sets the provider client's ID. + * Metadata holds key/value pairs associated with the blob. + * Keys are guaranteed to be in lowercase, even if the backend service + * has case-sensitive keys (although note that Metadata written via + * this package will always be lowercased). If there are duplicate + * case-insensitive keys (e.g., "foo" and "FOO"), only one value + * will be kept, and it is undefined which one. */ - setClientId(clientId: string): void + metadata: _TygojaDict /** - * ClientSecret returns the provider client's app secret. + * CreateTime is the time the blob was created, if available. If not available, + * CreateTime will be the zero time. */ - clientSecret(): string + createTime: time.Time /** - * SetClientSecret sets the provider client's app secret. + * ModTime is the time the blob was last modified. */ - setClientSecret(secret: string): void + modTime: time.Time /** - * RedirectUrl returns the end address to redirect the user - * going through the OAuth flow. + * Size is the size of the blob's content in bytes. */ - redirectUrl(): string + size: number /** - * SetRedirectUrl sets the provider's RedirectUrl. + * MD5 is an MD5 hash of the blob contents or nil if not available. */ - setRedirectUrl(url: string): void + md5: string /** - * AuthUrl returns the provider's authorization service url. + * ETag for the blob; see https://en.wikipedia.org/wiki/HTTP_ETag. */ - authUrl(): string + eTag: string + } + interface Attributes { /** - * SetAuthUrl sets the provider's AuthUrl. + * As converts i to driver-specific types. + * See https://gocloud.dev/concepts/as/ for background information, the "As" + * examples in this package for examples, and the driver package + * documentation for the specific types supported for that driver. */ - setAuthUrl(url: string): void + as(i: { + }): boolean + } + /** + * ListObject represents a single blob returned from List. + */ + interface ListObject { /** - * TokenUrl returns the provider's token exchange service url. + * Key is the key for this blob. */ - tokenUrl(): string + key: string /** - * SetTokenUrl sets the provider's TokenUrl. + * ModTime is the time the blob was last modified. */ - setTokenUrl(url: string): void + modTime: time.Time /** - * UserApiUrl returns the provider's user info api url. + * Size is the size of the blob's content in bytes. */ - userApiUrl(): string + size: number /** - * SetUserApiUrl sets the provider's UserApiUrl. + * MD5 is an MD5 hash of the blob contents or nil if not available. */ - setUserApiUrl(url: string): void + md5: string /** - * Client returns an http client using the provided token. + * IsDir indicates that this result represents a "directory" in the + * hierarchical namespace, ending in ListOptions.Delimiter. Key can be + * passed as ListOptions.Prefix to list items in the "directory". + * Fields other than Key and IsDir will not be set if IsDir is true. */ - client(token: oauth2.Token): (http.Client | undefined) + isDir: boolean + } + interface ListObject { /** - * BuildAuthUrl returns a URL to the provider's consent page - * that asks for permissions for the required scopes explicitly. + * As converts i to driver-specific types. + * See https://gocloud.dev/concepts/as/ for background information, the "As" + * examples in this package for examples, and the driver package + * documentation for the specific types supported for that driver. */ - buildAuthUrl(state: string, ...opts: oauth2.AuthCodeOption[]): string + as(i: { + }): boolean + } +} + +/** + * Package types implements some commonly used db serializable types + * like datetime, json, etc. + */ +namespace types { + /** + * JsonArray defines a slice that is safe for json and db read/write. + */ + interface JsonArray extends Array{} + interface JsonArray { /** - * FetchToken converts an authorization code to token. + * MarshalJSON implements the [json.Marshaler] interface. */ - fetchToken(code: string, ...opts: oauth2.AuthCodeOption[]): (oauth2.Token | undefined) + marshalJSON(): string + } + interface JsonArray { /** - * FetchRawUserData requests and marshalizes into `result` the - * the OAuth user api response. + * Value implements the [driver.Valuer] interface. */ - fetchRawUserData(token: oauth2.Token): string + value(): driver.Value + } + interface JsonArray { /** - * FetchAuthUser is similar to FetchRawUserData, but normalizes and - * marshalizes the user api response into a standardized AuthUser struct. + * Scan implements [sql.Scanner] interface to scan the provided value + * into the current JsonArray[T] instance. */ - fetchAuthUser(token: oauth2.Token): (AuthUser | undefined) + scan(value: any): void + } + /** + * JsonMap defines a map that is safe for json and db read/write. + */ + interface JsonMap extends _TygojaDict{} + interface JsonMap { + /** + * MarshalJSON implements the [json.Marshaler] interface. + */ + marshalJSON(): string + } + interface JsonMap { + /** + * Get retrieves a single value from the current JsonMap. + * + * This helper was added primarily to assist the goja integration since custom map types + * don't have direct access to the map keys (https://pkg.go.dev/github.com/dop251/goja#hdr-Maps_with_methods). + */ + get(key: string): any + } + interface JsonMap { + /** + * Set sets a single value in the current JsonMap. + * + * This helper was added primarily to assist the goja integration since custom map types + * don't have direct access to the map keys (https://pkg.go.dev/github.com/dop251/goja#hdr-Maps_with_methods). + */ + set(key: string, value: any): void + } + interface JsonMap { + /** + * Value implements the [driver.Valuer] interface. + */ + value(): driver.Value + } + interface JsonMap { + /** + * Scan implements [sql.Scanner] interface to scan the provided value + * into the current `JsonMap` instance. + */ + scan(value: any): void } } @@ -6411,301 +6567,59 @@ namespace sql { } /** - * Package blob provides an easy and portable way to interact with blobs - * within a storage location. Subpackages contain driver implementations of - * blob for supported services. + * Package jwt is a Go implementation of JSON Web Tokens: http://self-issued.info/docs/draft-jones-json-web-token.html * - * See https://gocloud.dev/howto/blob/ for a detailed how-to guide. - * - * # Errors - * - * The errors returned from this package can be inspected in several ways: - * - * The Code function from gocloud.dev/gcerrors will return an error code, also - * defined in that package, when invoked on an error. - * - * The Bucket.ErrorAs method can retrieve the driver error underlying the returned - * error. - * - * # OpenCensus Integration - * - * OpenCensus supports tracing and metric collection for multiple languages and - * backend providers. See https://opencensus.io. - * - * This API collects OpenCensus traces and metrics for the following methods: - * ``` - * - Attributes - * - Copy - * - Delete - * - ListPage - * - NewRangeReader, from creation until the call to Close. (NewReader and ReadAll - * are included because they call NewRangeReader.) - * - NewWriter, from creation until the call to Close. - * ``` - * - * All trace and metric names begin with the package import path. - * The traces add the method name. - * For example, "gocloud.dev/blob/Attributes". - * The metrics are "completed_calls", a count of completed method calls by driver, - * method and status (error code); and "latency", a distribution of method latency - * by driver and method. - * For example, "gocloud.dev/blob/latency". - * - * It also collects the following metrics: - * ``` - * - gocloud.dev/blob/bytes_read: the total number of bytes read, by driver. - * - gocloud.dev/blob/bytes_written: the total number of bytes written, by driver. - * ``` - * - * To enable trace collection in your application, see "Configure Exporter" at - * https://opencensus.io/quickstart/go/tracing. - * To enable metric collection in your application, see "Exporting stats" at - * https://opencensus.io/quickstart/go/metrics. + * See README.md for more info. */ -namespace blob { +namespace jwt { /** - * Reader reads bytes from a blob. - * It implements io.ReadSeekCloser, and must be closed after - * reads are finished. + * MapClaims is a claims type that uses the map[string]interface{} for JSON decoding. + * This is the default claims type if you don't supply one */ - interface Reader { + interface MapClaims extends _TygojaDict{} + interface MapClaims { + /** + * VerifyAudience Compares the aud claim against cmp. + * If required is false, this method will return true if the value matches or is unset + */ + verifyAudience(cmp: string, req: boolean): boolean } - interface Reader { + interface MapClaims { /** - * Read implements io.Reader (https://golang.org/pkg/io/#Reader). + * VerifyExpiresAt compares the exp claim against cmp (cmp <= exp). + * If req is false, it will return true, if exp is unset. */ - read(p: string): number + verifyExpiresAt(cmp: number, req: boolean): boolean } - interface Reader { + interface MapClaims { /** - * Seek implements io.Seeker (https://golang.org/pkg/io/#Seeker). + * VerifyIssuedAt compares the exp claim against cmp (cmp >= iat). + * If req is false, it will return true, if iat is unset. */ - seek(offset: number, whence: number): number + verifyIssuedAt(cmp: number, req: boolean): boolean } - interface Reader { + interface MapClaims { /** - * Close implements io.Closer (https://golang.org/pkg/io/#Closer). + * VerifyNotBefore compares the nbf claim against cmp (cmp >= nbf). + * If req is false, it will return true, if nbf is unset. */ - close(): void + verifyNotBefore(cmp: number, req: boolean): boolean } - interface Reader { + interface MapClaims { /** - * ContentType returns the MIME type of the blob. + * VerifyIssuer compares the iss claim against cmp. + * If required is false, this method will return true if the value matches or is unset */ - contentType(): string + verifyIssuer(cmp: string, req: boolean): boolean } - interface Reader { + interface MapClaims { /** - * ModTime returns the time the blob was last modified. + * Valid validates time based claims "exp, iat, nbf". + * There is no accounting for clock skew. + * As well, if any of the above claims are not in the token, it will still + * be considered a valid claim. */ - modTime(): time.Time - } - interface Reader { - /** - * Size returns the size of the blob content in bytes. - */ - size(): number - } - interface Reader { - /** - * As converts i to driver-specific types. - * See https://gocloud.dev/concepts/as/ for background information, the "As" - * examples in this package for examples, and the driver package - * documentation for the specific types supported for that driver. - */ - as(i: { - }): boolean - } - interface Reader { - /** - * WriteTo reads from r and writes to w until there's no more data or - * an error occurs. - * The return value is the number of bytes written to w. - * - * It implements the io.WriterTo interface. - */ - writeTo(w: io.Writer): number - } - /** - * Attributes contains attributes about a blob. - */ - interface Attributes { - /** - * CacheControl specifies caching attributes that services may use - * when serving the blob. - * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control - */ - cacheControl: string - /** - * ContentDisposition specifies whether the blob content is expected to be - * displayed inline or as an attachment. - * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition - */ - contentDisposition: string - /** - * ContentEncoding specifies the encoding used for the blob's content, if any. - * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding - */ - contentEncoding: string - /** - * ContentLanguage specifies the language used in the blob's content, if any. - * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Language - */ - contentLanguage: string - /** - * ContentType is the MIME type of the blob. It will not be empty. - * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type - */ - contentType: string - /** - * Metadata holds key/value pairs associated with the blob. - * Keys are guaranteed to be in lowercase, even if the backend service - * has case-sensitive keys (although note that Metadata written via - * this package will always be lowercased). If there are duplicate - * case-insensitive keys (e.g., "foo" and "FOO"), only one value - * will be kept, and it is undefined which one. - */ - metadata: _TygojaDict - /** - * CreateTime is the time the blob was created, if available. If not available, - * CreateTime will be the zero time. - */ - createTime: time.Time - /** - * ModTime is the time the blob was last modified. - */ - modTime: time.Time - /** - * Size is the size of the blob's content in bytes. - */ - size: number - /** - * MD5 is an MD5 hash of the blob contents or nil if not available. - */ - md5: string - /** - * ETag for the blob; see https://en.wikipedia.org/wiki/HTTP_ETag. - */ - eTag: string - } - interface Attributes { - /** - * As converts i to driver-specific types. - * See https://gocloud.dev/concepts/as/ for background information, the "As" - * examples in this package for examples, and the driver package - * documentation for the specific types supported for that driver. - */ - as(i: { - }): boolean - } - /** - * ListObject represents a single blob returned from List. - */ - interface ListObject { - /** - * Key is the key for this blob. - */ - key: string - /** - * ModTime is the time the blob was last modified. - */ - modTime: time.Time - /** - * Size is the size of the blob's content in bytes. - */ - size: number - /** - * MD5 is an MD5 hash of the blob contents or nil if not available. - */ - md5: string - /** - * IsDir indicates that this result represents a "directory" in the - * hierarchical namespace, ending in ListOptions.Delimiter. Key can be - * passed as ListOptions.Prefix to list items in the "directory". - * Fields other than Key and IsDir will not be set if IsDir is true. - */ - isDir: boolean - } - interface ListObject { - /** - * As converts i to driver-specific types. - * See https://gocloud.dev/concepts/as/ for background information, the "As" - * examples in this package for examples, and the driver package - * documentation for the specific types supported for that driver. - */ - as(i: { - }): boolean - } -} - -/** - * Package types implements some commonly used db serializable types - * like datetime, json, etc. - */ -namespace types { - /** - * JsonArray defines a slice that is safe for json and db read/write. - */ - interface JsonArray extends Array{} - interface JsonArray { - /** - * MarshalJSON implements the [json.Marshaler] interface. - */ - marshalJSON(): string - } - interface JsonArray { - /** - * Value implements the [driver.Valuer] interface. - */ - value(): driver.Value - } - interface JsonArray { - /** - * Scan implements [sql.Scanner] interface to scan the provided value - * into the current JsonArray[T] instance. - */ - scan(value: any): void - } - /** - * JsonMap defines a map that is safe for json and db read/write. - */ - interface JsonMap extends _TygojaDict{} - interface JsonMap { - /** - * MarshalJSON implements the [json.Marshaler] interface. - */ - marshalJSON(): string - } - interface JsonMap { - /** - * Get retrieves a single value from the current JsonMap. - * - * This helper was added primarily to assist the goja integration since custom map types - * don't have direct access to the map keys (https://pkg.go.dev/github.com/dop251/goja#hdr-Maps_with_methods). - */ - get(key: string): any - } - interface JsonMap { - /** - * Set sets a single value in the current JsonMap. - * - * This helper was added primarily to assist the goja integration since custom map types - * don't have direct access to the map keys (https://pkg.go.dev/github.com/dop251/goja#hdr-Maps_with_methods). - */ - set(key: string, value: any): void - } - interface JsonMap { - /** - * Value implements the [driver.Valuer] interface. - */ - value(): driver.Value - } - interface JsonMap { - /** - * Scan implements [sql.Scanner] interface to scan the provided value - * into the current `JsonMap` instance. - */ - scan(value: any): void + valid(): void } } @@ -6819,8 +6733,8 @@ namespace schema { * Package models implements all PocketBase DB models and DTOs. */ namespace models { - type _subhAtFF = BaseModel - interface Admin extends _subhAtFF { + type _subTOUbc = BaseModel + interface Admin extends _subTOUbc { avatar: number email: string tokenKey: string @@ -6855,8 +6769,8 @@ namespace models { } // @ts-ignore import validation = ozzo_validation - type _suboJYxt = BaseModel - interface Collection extends _suboJYxt { + type _subrIsxO = BaseModel + interface Collection extends _subrIsxO { name: string type: string system: boolean @@ -6949,8 +6863,8 @@ namespace models { */ setOptions(typedOptions: any): void } - type _subrTQwj = BaseModel - interface ExternalAuth extends _subrTQwj { + type _subdWgFP = BaseModel + interface ExternalAuth extends _subdWgFP { collectionId: string recordId: string provider: string @@ -6959,8 +6873,8 @@ namespace models { interface ExternalAuth { tableName(): string } - type _subwQaAd = BaseModel - interface Record extends _subwQaAd { + type _subRmImM = BaseModel + interface Record extends _subRmImM { } interface Record { /** @@ -7336,6 +7250,2284 @@ namespace models { } } +namespace auth { + /** + * AuthUser defines a standardized oauth2 user data structure. + */ + interface AuthUser { + id: string + name: string + username: string + email: string + avatarUrl: string + rawUser: _TygojaDict + accessToken: string + refreshToken: string + } + /** + * Provider defines a common interface for an OAuth2 client. + */ + interface Provider { + /** + * Scopes returns the context associated with the provider (if any). + */ + context(): context.Context + /** + * SetContext assigns the specified context to the current provider. + */ + setContext(ctx: context.Context): void + /** + * Scopes returns the provider access permissions that will be requested. + */ + scopes(): Array + /** + * SetScopes sets the provider access permissions that will be requested later. + */ + setScopes(scopes: Array): void + /** + * ClientId returns the provider client's app ID. + */ + clientId(): string + /** + * SetClientId sets the provider client's ID. + */ + setClientId(clientId: string): void + /** + * ClientSecret returns the provider client's app secret. + */ + clientSecret(): string + /** + * SetClientSecret sets the provider client's app secret. + */ + setClientSecret(secret: string): void + /** + * RedirectUrl returns the end address to redirect the user + * going through the OAuth flow. + */ + redirectUrl(): string + /** + * SetRedirectUrl sets the provider's RedirectUrl. + */ + setRedirectUrl(url: string): void + /** + * AuthUrl returns the provider's authorization service url. + */ + authUrl(): string + /** + * SetAuthUrl sets the provider's AuthUrl. + */ + setAuthUrl(url: string): void + /** + * TokenUrl returns the provider's token exchange service url. + */ + tokenUrl(): string + /** + * SetTokenUrl sets the provider's TokenUrl. + */ + setTokenUrl(url: string): void + /** + * UserApiUrl returns the provider's user info api url. + */ + userApiUrl(): string + /** + * SetUserApiUrl sets the provider's UserApiUrl. + */ + setUserApiUrl(url: string): void + /** + * Client returns an http client using the provided token. + */ + client(token: oauth2.Token): (http.Client | undefined) + /** + * BuildAuthUrl returns a URL to the provider's consent page + * that asks for permissions for the required scopes explicitly. + */ + buildAuthUrl(state: string, ...opts: oauth2.AuthCodeOption[]): string + /** + * FetchToken converts an authorization code to token. + */ + fetchToken(code: string, ...opts: oauth2.AuthCodeOption[]): (oauth2.Token | undefined) + /** + * FetchRawUserData requests and marshalizes into `result` the + * the OAuth user api response. + */ + fetchRawUserData(token: oauth2.Token): string + /** + * FetchAuthUser is similar to FetchRawUserData, but normalizes and + * marshalizes the user api response into a standardized AuthUser struct. + */ + fetchAuthUser(token: oauth2.Token): (AuthUser | undefined) + } +} + +/** + * Package echo implements high performance, minimalist Go web framework. + * + * Example: + * + * ``` + * package main + * + * import ( + * "github.com/labstack/echo/v5" + * "github.com/labstack/echo/v5/middleware" + * "log" + * "net/http" + * ) + * + * // Handler + * func hello(c echo.Context) error { + * return c.String(http.StatusOK, "Hello, World!") + * } + * + * func main() { + * // Echo instance + * e := echo.New() + * + * // Middleware + * e.Use(middleware.Logger()) + * e.Use(middleware.Recover()) + * + * // Routes + * e.GET("/", hello) + * + * // Start server + * if err := e.Start(":8080"); err != http.ErrServerClosed { + * log.Fatal(err) + * } + * } + * ``` + * + * Learn more at https://echo.labstack.com + */ +namespace echo { + /** + * Context represents the context of the current HTTP request. It holds request and + * response objects, path, path parameters, data and registered handler. + */ + interface Context { + /** + * Request returns `*http.Request`. + */ + request(): (http.Request | undefined) + /** + * SetRequest sets `*http.Request`. + */ + setRequest(r: http.Request): void + /** + * SetResponse sets `*Response`. + */ + setResponse(r: Response): void + /** + * Response returns `*Response`. + */ + response(): (Response | undefined) + /** + * IsTLS returns true if HTTP connection is TLS otherwise false. + */ + isTLS(): boolean + /** + * IsWebSocket returns true if HTTP connection is WebSocket otherwise false. + */ + isWebSocket(): boolean + /** + * Scheme returns the HTTP protocol scheme, `http` or `https`. + */ + scheme(): string + /** + * RealIP returns the client's network address based on `X-Forwarded-For` + * or `X-Real-IP` request header. + * The behavior can be configured using `Echo#IPExtractor`. + */ + realIP(): string + /** + * RouteInfo returns current request route information. Method, Path, Name and params if they exist for matched route. + * In case of 404 (route not found) and 405 (method not allowed) RouteInfo returns generic struct for these cases. + */ + routeInfo(): RouteInfo + /** + * Path returns the registered path for the handler. + */ + path(): string + /** + * PathParam returns path parameter by name. + */ + pathParam(name: string): string + /** + * PathParamDefault returns the path parameter or default value for the provided name. + * + * Notes for DefaultRouter implementation: + * Path parameter could be empty for cases like that: + * * route `/release-:version/bin` and request URL is `/release-/bin` + * * route `/api/:version/image.jpg` and request URL is `/api//image.jpg` + * but not when path parameter is last part of route path + * * route `/download/file.:ext` will not match request `/download/file.` + */ + pathParamDefault(name: string, defaultValue: string): string + /** + * PathParams returns path parameter values. + */ + pathParams(): PathParams + /** + * SetPathParams sets path parameters for current request. + */ + setPathParams(params: PathParams): void + /** + * QueryParam returns the query param for the provided name. + */ + queryParam(name: string): string + /** + * QueryParamDefault returns the query param or default value for the provided name. + */ + queryParamDefault(name: string): string + /** + * QueryParams returns the query parameters as `url.Values`. + */ + queryParams(): url.Values + /** + * QueryString returns the URL query string. + */ + queryString(): string + /** + * FormValue returns the form field value for the provided name. + */ + formValue(name: string): string + /** + * FormValueDefault returns the form field value or default value for the provided name. + */ + formValueDefault(name: string): string + /** + * FormValues returns the form field values as `url.Values`. + */ + formValues(): url.Values + /** + * FormFile returns the multipart form file for the provided name. + */ + formFile(name: string): (multipart.FileHeader | undefined) + /** + * MultipartForm returns the multipart form. + */ + multipartForm(): (multipart.Form | undefined) + /** + * Cookie returns the named cookie provided in the request. + */ + cookie(name: string): (http.Cookie | undefined) + /** + * SetCookie adds a `Set-Cookie` header in HTTP response. + */ + setCookie(cookie: http.Cookie): void + /** + * Cookies returns the HTTP cookies sent with the request. + */ + cookies(): Array<(http.Cookie | undefined)> + /** + * Get retrieves data from the context. + */ + get(key: string): { + } + /** + * Set saves data in the context. + */ + set(key: string, val: { + }): void + /** + * Bind binds the request body into provided type `i`. The default binder + * does it based on Content-Type header. + */ + bind(i: { + }): void + /** + * Validate validates provided `i`. It is usually called after `Context#Bind()`. + * Validator must be registered using `Echo#Validator`. + */ + validate(i: { + }): void + /** + * Render renders a template with data and sends a text/html response with status + * code. Renderer must be registered using `Echo.Renderer`. + */ + render(code: number, name: string, data: { + }): void + /** + * HTML sends an HTTP response with status code. + */ + html(code: number, html: string): void + /** + * HTMLBlob sends an HTTP blob response with status code. + */ + htmlBlob(code: number, b: string): void + /** + * String sends a string response with status code. + */ + string(code: number, s: string): void + /** + * JSON sends a JSON response with status code. + */ + json(code: number, i: { + }): void + /** + * JSONPretty sends a pretty-print JSON with status code. + */ + jsonPretty(code: number, i: { + }, indent: string): void + /** + * JSONBlob sends a JSON blob response with status code. + */ + jsonBlob(code: number, b: string): void + /** + * JSONP sends a JSONP response with status code. It uses `callback` to construct + * the JSONP payload. + */ + jsonp(code: number, callback: string, i: { + }): void + /** + * JSONPBlob sends a JSONP blob response with status code. It uses `callback` + * to construct the JSONP payload. + */ + jsonpBlob(code: number, callback: string, b: string): void + /** + * XML sends an XML response with status code. + */ + xml(code: number, i: { + }): void + /** + * XMLPretty sends a pretty-print XML with status code. + */ + xmlPretty(code: number, i: { + }, indent: string): void + /** + * XMLBlob sends an XML blob response with status code. + */ + xmlBlob(code: number, b: string): void + /** + * Blob sends a blob response with status code and content type. + */ + blob(code: number, contentType: string, b: string): void + /** + * Stream sends a streaming response with status code and content type. + */ + stream(code: number, contentType: string, r: io.Reader): void + /** + * File sends a response with the content of the file. + */ + file(file: string): void + /** + * FileFS sends a response with the content of the file from given filesystem. + */ + fileFS(file: string, filesystem: fs.FS): void + /** + * Attachment sends a response as attachment, prompting client to save the + * file. + */ + attachment(file: string, name: string): void + /** + * Inline sends a response as inline, opening the file in the browser. + */ + inline(file: string, name: string): void + /** + * NoContent sends a response with no body and a status code. + */ + noContent(code: number): void + /** + * Redirect redirects the request to a provided URL with status code. + */ + redirect(code: number, url: string): void + /** + * Echo returns the `Echo` instance. + * + * WARNING: Remember that Echo public fields and methods are coroutine safe ONLY when you are NOT mutating them + * anywhere in your code after Echo server has started. + */ + echo(): (Echo | undefined) + } + // @ts-ignore + import stdContext = context + /** + * Echo is the top-level framework instance. + * + * Note: replacing/nilling public fields is not coroutine/thread-safe and can cause data-races/panics. This is very likely + * to happen when you access Echo instances through Context.Echo() method. + */ + interface Echo { + /** + * NewContextFunc allows using custom context implementations, instead of default *echo.context + */ + newContextFunc: (e: Echo, pathParamAllocSize: number) => ServableContext + debug: boolean + httpErrorHandler: HTTPErrorHandler + binder: Binder + jsonSerializer: JSONSerializer + validator: Validator + renderer: Renderer + logger: Logger + ipExtractor: IPExtractor + /** + * Filesystem is file system used by Static and File handlers to access files. + * Defaults to os.DirFS(".") + * + * When dealing with `embed.FS` use `fs := echo.MustSubFS(fs, "rootDirectory") to create sub fs which uses necessary + * prefix for directory path. This is necessary as `//go:embed assets/images` embeds files with paths + * including `assets/images` as their prefix. + */ + filesystem: fs.FS + } + /** + * HandlerFunc defines a function to serve HTTP requests. + */ + interface HandlerFunc {(c: Context): void } + /** + * MiddlewareFunc defines a function to process middleware. + */ + interface MiddlewareFunc {(next: HandlerFunc): HandlerFunc } + interface Echo { + /** + * NewContext returns a new Context instance. + * + * Note: both request and response can be left to nil as Echo.ServeHTTP will call c.Reset(req,resp) anyway + * these arguments are useful when creating context for tests and cases like that. + */ + newContext(r: http.Request, w: http.ResponseWriter): Context + } + interface Echo { + /** + * Router returns the default router. + */ + router(): Router + } + interface Echo { + /** + * Routers returns the map of host => router. + */ + routers(): _TygojaDict + } + interface Echo { + /** + * RouterFor returns Router for given host. + */ + routerFor(host: string): Router + } + interface Echo { + /** + * ResetRouterCreator resets callback for creating new router instances. + * Note: current (default) router is immediately replaced with router created with creator func and vhost routers are cleared. + */ + resetRouterCreator(creator: (e: Echo) => Router): void + } + interface Echo { + /** + * Pre adds middleware to the chain which is run before router tries to find matching route. + * Meaning middleware is executed even for 404 (not found) cases. + */ + pre(...middleware: MiddlewareFunc[]): void + } + interface Echo { + /** + * Use adds middleware to the chain which is run after router has found matching route and before route/request handler method is executed. + */ + use(...middleware: MiddlewareFunc[]): void + } + interface Echo { + /** + * CONNECT registers a new CONNECT route for a path with matching handler in the + * router with optional route-level middleware. Panics on error. + */ + connect(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo + } + interface Echo { + /** + * DELETE registers a new DELETE route for a path with matching handler in the router + * with optional route-level middleware. Panics on error. + */ + delete(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo + } + interface Echo { + /** + * GET registers a new GET route for a path with matching handler in the router + * with optional route-level middleware. Panics on error. + */ + get(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo + } + interface Echo { + /** + * HEAD registers a new HEAD route for a path with matching handler in the + * router with optional route-level middleware. Panics on error. + */ + head(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo + } + interface Echo { + /** + * OPTIONS registers a new OPTIONS route for a path with matching handler in the + * router with optional route-level middleware. Panics on error. + */ + options(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo + } + interface Echo { + /** + * PATCH registers a new PATCH route for a path with matching handler in the + * router with optional route-level middleware. Panics on error. + */ + patch(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo + } + interface Echo { + /** + * POST registers a new POST route for a path with matching handler in the + * router with optional route-level middleware. Panics on error. + */ + post(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo + } + interface Echo { + /** + * PUT registers a new PUT route for a path with matching handler in the + * router with optional route-level middleware. Panics on error. + */ + put(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo + } + interface Echo { + /** + * TRACE registers a new TRACE route for a path with matching handler in the + * router with optional route-level middleware. Panics on error. + */ + trace(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo + } + interface Echo { + /** + * RouteNotFound registers a special-case route which is executed when no other route is found (i.e. HTTP 404 cases) + * for current request URL. + * Path supports static and named/any parameters just like other http method is defined. Generally path is ended with + * wildcard/match-any character (`/*`, `/download/*` etc). + * + * Example: `e.RouteNotFound("/*", func(c echo.Context) error { return c.NoContent(http.StatusNotFound) })` + */ + routeNotFound(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo + } + interface Echo { + /** + * Any registers a new route for all supported HTTP methods and path with matching handler + * in the router with optional route-level middleware. Panics on error. + */ + any(path: string, handler: HandlerFunc, ...middleware: MiddlewareFunc[]): Routes + } + interface Echo { + /** + * Match registers a new route for multiple HTTP methods and path with matching + * handler in the router with optional route-level middleware. Panics on error. + */ + match(methods: Array, path: string, handler: HandlerFunc, ...middleware: MiddlewareFunc[]): Routes + } + interface Echo { + /** + * Static registers a new route with path prefix to serve static files from the provided root directory. + */ + static(pathPrefix: string): RouteInfo + } + interface Echo { + /** + * StaticFS registers a new route with path prefix to serve static files from the provided file system. + * + * When dealing with `embed.FS` use `fs := echo.MustSubFS(fs, "rootDirectory") to create sub fs which uses necessary + * prefix for directory path. This is necessary as `//go:embed assets/images` embeds files with paths + * including `assets/images` as their prefix. + */ + staticFS(pathPrefix: string, filesystem: fs.FS): RouteInfo + } + interface Echo { + /** + * FileFS registers a new route with path to serve file from the provided file system. + */ + fileFS(path: string, filesystem: fs.FS, ...m: MiddlewareFunc[]): RouteInfo + } + interface Echo { + /** + * File registers a new route with path to serve a static file with optional route-level middleware. Panics on error. + */ + file(path: string, ...middleware: MiddlewareFunc[]): RouteInfo + } + interface Echo { + /** + * AddRoute registers a new Route with default host Router + */ + addRoute(route: Routable): RouteInfo + } + interface Echo { + /** + * Add registers a new route for an HTTP method and path with matching handler + * in the router with optional route-level middleware. + */ + add(method: string, handler: HandlerFunc, ...middleware: MiddlewareFunc[]): RouteInfo + } + interface Echo { + /** + * Host creates a new router group for the provided host and optional host-level middleware. + */ + host(name: string, ...m: MiddlewareFunc[]): (Group | undefined) + } + interface Echo { + /** + * Group creates a new router group with prefix and optional group-level middleware. + */ + group(prefix: string, ...m: MiddlewareFunc[]): (Group | undefined) + } + interface Echo { + /** + * AcquireContext returns an empty `Context` instance from the pool. + * You must return the context by calling `ReleaseContext()`. + */ + acquireContext(): Context + } + interface Echo { + /** + * ReleaseContext returns the `Context` instance back to the pool. + * You must call it after `AcquireContext()`. + */ + releaseContext(c: Context): void + } + interface Echo { + /** + * ServeHTTP implements `http.Handler` interface, which serves HTTP requests. + */ + serveHTTP(w: http.ResponseWriter, r: http.Request): void + } + interface Echo { + /** + * Start stars HTTP server on given address with Echo as a handler serving requests. The server can be shutdown by + * sending os.Interrupt signal with `ctrl+c`. + * + * Note: this method is created for use in examples/demos and is deliberately simple without providing configuration + * options. + * + * In need of customization use: + * ``` + * sc := echo.StartConfig{Address: ":8080"} + * if err := sc.Start(e); err != http.ErrServerClosed { + * log.Fatal(err) + * } + * ``` + * // or standard library `http.Server` + * ``` + * s := http.Server{Addr: ":8080", Handler: e} + * if err := s.ListenAndServe(); err != http.ErrServerClosed { + * log.Fatal(err) + * } + * ``` + */ + start(address: string): void + } +} + +namespace settings { + // @ts-ignore + import validation = ozzo_validation + /** + * Settings defines common app configuration options. + */ + interface Settings { + meta: MetaConfig + logs: LogsConfig + smtp: SmtpConfig + s3: S3Config + backups: BackupsConfig + adminAuthToken: TokenConfig + adminPasswordResetToken: TokenConfig + adminFileToken: TokenConfig + recordAuthToken: TokenConfig + recordPasswordResetToken: TokenConfig + recordEmailChangeToken: TokenConfig + recordVerificationToken: TokenConfig + recordFileToken: TokenConfig + /** + * Deprecated: Will be removed in v0.9+ + */ + emailAuth: EmailAuthConfig + googleAuth: AuthProviderConfig + facebookAuth: AuthProviderConfig + githubAuth: AuthProviderConfig + gitlabAuth: AuthProviderConfig + discordAuth: AuthProviderConfig + twitterAuth: AuthProviderConfig + microsoftAuth: AuthProviderConfig + spotifyAuth: AuthProviderConfig + kakaoAuth: AuthProviderConfig + twitchAuth: AuthProviderConfig + stravaAuth: AuthProviderConfig + giteeAuth: AuthProviderConfig + livechatAuth: AuthProviderConfig + giteaAuth: AuthProviderConfig + oidcAuth: AuthProviderConfig + oidc2Auth: AuthProviderConfig + oidc3Auth: AuthProviderConfig + appleAuth: AuthProviderConfig + instagramAuth: AuthProviderConfig + vkAuth: AuthProviderConfig + yandexAuth: AuthProviderConfig + } + interface Settings { + /** + * Validate makes Settings validatable by implementing [validation.Validatable] interface. + */ + validate(): void + } + interface Settings { + /** + * Merge merges `other` settings into the current one. + */ + merge(other: Settings): void + } + interface Settings { + /** + * Clone creates a new deep copy of the current settings. + */ + clone(): (Settings | undefined) + } + interface Settings { + /** + * RedactClone creates a new deep copy of the current settings, + * while replacing the secret values with `******`. + */ + redactClone(): (Settings | undefined) + } + interface Settings { + /** + * NamedAuthProviderConfigs returns a map with all registered OAuth2 + * provider configurations (indexed by their name identifier). + */ + namedAuthProviderConfigs(): _TygojaDict + } +} + +/** + * Package daos handles common PocketBase DB model manipulations. + * + * Think of daos as DB repository and service layer in one. + */ +namespace daos { + interface Dao { + /** + * AdminQuery returns a new Admin select query. + */ + adminQuery(): (dbx.SelectQuery | undefined) + } + interface Dao { + /** + * FindAdminById finds the admin with the provided id. + */ + findAdminById(id: string): (models.Admin | undefined) + } + interface Dao { + /** + * FindAdminByEmail finds the admin with the provided email address. + */ + findAdminByEmail(email: string): (models.Admin | undefined) + } + interface Dao { + /** + * FindAdminByToken finds the admin associated with the provided JWT token. + * + * Returns an error if the JWT token is invalid or expired. + */ + findAdminByToken(token: string, baseTokenKey: string): (models.Admin | undefined) + } + interface Dao { + /** + * TotalAdmins returns the number of existing admin records. + */ + totalAdmins(): number + } + interface Dao { + /** + * IsAdminEmailUnique checks if the provided email address is not + * already in use by other admins. + */ + isAdminEmailUnique(email: string, ...excludeIds: string[]): boolean + } + interface Dao { + /** + * DeleteAdmin deletes the provided Admin model. + * + * Returns an error if there is only 1 admin. + */ + deleteAdmin(admin: models.Admin): void + } + interface Dao { + /** + * SaveAdmin upserts the provided Admin model. + */ + saveAdmin(admin: models.Admin): void + } + /** + * Dao handles various db operations. + * + * You can think of Dao as a repository and service layer in one. + */ + interface Dao { + /** + * MaxLockRetries specifies the default max "database is locked" auto retry attempts. + */ + maxLockRetries: number + /** + * ModelQueryTimeout is the default max duration of a running ModelQuery(). + * + * This field has no effect if an explicit query context is already specified. + */ + modelQueryTimeout: time.Duration + /** + * write hooks + */ + beforeCreateFunc: (eventDao: Dao, m: models.Model) => void + afterCreateFunc: (eventDao: Dao, m: models.Model) => void + beforeUpdateFunc: (eventDao: Dao, m: models.Model) => void + afterUpdateFunc: (eventDao: Dao, m: models.Model) => void + beforeDeleteFunc: (eventDao: Dao, m: models.Model) => void + afterDeleteFunc: (eventDao: Dao, m: models.Model) => void + } + interface Dao { + /** + * DB returns the default dao db builder (*dbx.DB or *dbx.TX). + * + * Currently the default db builder is dao.concurrentDB but that may change in the future. + */ + db(): dbx.Builder + } + interface Dao { + /** + * ConcurrentDB returns the dao concurrent (aka. multiple open connections) + * db builder (*dbx.DB or *dbx.TX). + * + * In a transaction the concurrentDB and nonconcurrentDB refer to the same *dbx.TX instance. + */ + concurrentDB(): dbx.Builder + } + interface Dao { + /** + * NonconcurrentDB returns the dao nonconcurrent (aka. single open connection) + * db builder (*dbx.DB or *dbx.TX). + * + * In a transaction the concurrentDB and nonconcurrentDB refer to the same *dbx.TX instance. + */ + nonconcurrentDB(): dbx.Builder + } + interface Dao { + /** + * Clone returns a new Dao with the same configuration options as the current one. + */ + clone(): (Dao | undefined) + } + interface Dao { + /** + * WithoutHooks returns a new Dao with the same configuration options + * as the current one, but without create/update/delete hooks. + */ + withoutHooks(): (Dao | undefined) + } + interface Dao { + /** + * ModelQuery creates a new preconfigured select query with preset + * SELECT, FROM and other common fields based on the provided model. + */ + modelQuery(m: models.Model): (dbx.SelectQuery | undefined) + } + interface Dao { + /** + * FindById finds a single db record with the specified id and + * scans the result into m. + */ + findById(m: models.Model, id: string): void + } + interface Dao { + /** + * RunInTransaction wraps fn into a transaction. + * + * It is safe to nest RunInTransaction calls as long as you use the txDao. + */ + runInTransaction(fn: (txDao: Dao) => void): void + } + interface Dao { + /** + * Delete deletes the provided model. + */ + delete(m: models.Model): void + } + interface Dao { + /** + * Save persists the provided model in the database. + * + * If m.IsNew() is true, the method will perform a create, otherwise an update. + * To explicitly mark a model for update you can use m.MarkAsNotNew(). + */ + save(m: models.Model): void + } + interface Dao { + /** + * CollectionQuery returns a new Collection select query. + */ + collectionQuery(): (dbx.SelectQuery | undefined) + } + interface Dao { + /** + * FindCollectionsByType finds all collections by the given type. + */ + findCollectionsByType(collectionType: string): Array<(models.Collection | undefined)> + } + interface Dao { + /** + * FindCollectionByNameOrId finds a single collection by its name (case insensitive) or id. + */ + findCollectionByNameOrId(nameOrId: string): (models.Collection | undefined) + } + interface Dao { + /** + * IsCollectionNameUnique checks that there is no existing collection + * with the provided name (case insensitive!). + * + * Note: case insensitive check because the name is used also as a table name for the records. + */ + isCollectionNameUnique(name: string, ...excludeIds: string[]): boolean + } + interface Dao { + /** + * FindCollectionReferences returns information for all + * relation schema fields referencing the provided collection. + * + * If the provided collection has reference to itself then it will be + * also included in the result. To exclude it, pass the collection id + * as the excludeId argument. + */ + findCollectionReferences(collection: models.Collection, ...excludeIds: string[]): _TygojaDict + } + interface Dao { + /** + * DeleteCollection deletes the provided Collection model. + * This method automatically deletes the related collection records table. + * + * NB! The collection cannot be deleted, if: + * - is system collection (aka. collection.System is true) + * - is referenced as part of a relation field in another collection + */ + deleteCollection(collection: models.Collection): void + } + interface Dao { + /** + * SaveCollection persists the provided Collection model and updates + * its related records table schema. + * + * If collecction.IsNew() is true, the method will perform a create, otherwise an update. + * To explicitly mark a collection for update you can use collecction.MarkAsNotNew(). + */ + saveCollection(collection: models.Collection): void + } + interface Dao { + /** + * ImportCollections imports the provided collections list within a single transaction. + * + * NB1! If deleteMissing is set, all local collections and schema fields, that are not present + * in the imported configuration, WILL BE DELETED (including their related records data). + * + * NB2! This method doesn't perform validations on the imported collections data! + * If you need validations, use [forms.CollectionsImport]. + */ + importCollections(importedCollections: Array<(models.Collection | undefined)>, deleteMissing: boolean, afterSync: (txDao: Dao, mappedImported: _TygojaDict) => void): void + } + interface Dao { + /** + * ExternalAuthQuery returns a new ExternalAuth select query. + */ + externalAuthQuery(): (dbx.SelectQuery | undefined) + } + interface Dao { + /** + * FindAllExternalAuthsByRecord returns all ExternalAuth models + * linked to the provided auth record. + */ + findAllExternalAuthsByRecord(authRecord: models.Record): Array<(models.ExternalAuth | undefined)> + } + interface Dao { + /** + * FindExternalAuthByProvider returns the first available + * ExternalAuth model for the specified provider and providerId. + */ + findExternalAuthByProvider(provider: string): (models.ExternalAuth | undefined) + } + interface Dao { + /** + * FindExternalAuthByRecordAndProvider returns the first available + * ExternalAuth model for the specified record data and provider. + */ + findExternalAuthByRecordAndProvider(authRecord: models.Record, provider: string): (models.ExternalAuth | undefined) + } + interface Dao { + /** + * SaveExternalAuth upserts the provided ExternalAuth model. + */ + saveExternalAuth(model: models.ExternalAuth): void + } + interface Dao { + /** + * DeleteExternalAuth deletes the provided ExternalAuth model. + */ + deleteExternalAuth(model: models.ExternalAuth): void + } + interface Dao { + /** + * ParamQuery returns a new Param select query. + */ + paramQuery(): (dbx.SelectQuery | undefined) + } + interface Dao { + /** + * FindParamByKey finds the first Param model with the provided key. + */ + findParamByKey(key: string): (models.Param | undefined) + } + interface Dao { + /** + * SaveParam creates or updates a Param model by the provided key-value pair. + * The value argument will be encoded as json string. + * + * If `optEncryptionKey` is provided it will encrypt the value before storing it. + */ + saveParam(key: string, value: any, ...optEncryptionKey: string[]): void + } + interface Dao { + /** + * DeleteParam deletes the provided Param model. + */ + deleteParam(param: models.Param): void + } + interface Dao { + /** + * RecordQuery returns a new Record select query. + */ + recordQuery(collection: models.Collection): (dbx.SelectQuery | undefined) + } + interface Dao { + /** + * FindRecordById finds the Record model by its id. + */ + findRecordById(collectionNameOrId: string, recordId: string, ...optFilters: ((q: dbx.SelectQuery) => void)[]): (models.Record | undefined) + } + interface Dao { + /** + * FindRecordsByIds finds all Record models by the provided ids. + * If no records are found, returns an empty slice. + */ + findRecordsByIds(collectionNameOrId: string, recordIds: Array, ...optFilters: ((q: dbx.SelectQuery) => void)[]): Array<(models.Record | undefined)> + } + interface Dao { + /** + * FindRecordsByExpr finds all records by the specified db expression. + * + * Returns all collection records if no expressions are provided. + * + * Returns an empty slice if no records are found. + * + * Example: + * + * ``` + * expr1 := dbx.HashExp{"email": "test@example.com"} + * expr2 := dbx.NewExp("LOWER(username) = {:username}", dbx.Params{"username": "test"}) + * dao.FindRecordsByExpr("example", expr1, expr2) + * ``` + */ + findRecordsByExpr(collectionNameOrId: string, ...exprs: dbx.Expression[]): Array<(models.Record | undefined)> + } + interface Dao { + /** + * FindFirstRecordByData returns the first found record matching + * the provided key-value pair. + */ + findFirstRecordByData(collectionNameOrId: string, key: string, value: any): (models.Record | undefined) + } + interface Dao { + /** + * FindRecordsByFilter returns limit number of records matching the + * provided string filter. + * + * The sort argument is optional and can be empty string OR the same format + * used in the web APIs, eg. "-created,title". + * + * If the limit argument is <= 0, no limit is applied to the query and + * all matching records are returned. + * + * NB! Don't put untrusted user input in the filter string as it + * practically would allow the users to inject their own custom filter. + * + * Example: + * + * ``` + * dao.FindRecordsByFilter("posts", "title ~ 'lorem ipsum' && visible = true", "-created", 10) + * ``` + */ + findRecordsByFilter(collectionNameOrId: string, filter: string, sort: string, limit: number): Array<(models.Record | undefined)> + } + interface Dao { + /** + * FindFirstRecordByFilter returns the first available record matching the provided filter. + * + * NB! Don't put untrusted user input in the filter string as it + * practically would allow the users to inject their own custom filter. + * + * Example: + * + * ``` + * dao.FindFirstRecordByFilter("posts", "slug='test'") + * ``` + */ + findFirstRecordByFilter(collectionNameOrId: string, filter: string): (models.Record | undefined) + } + interface Dao { + /** + * IsRecordValueUnique checks if the provided key-value pair is a unique Record value. + * + * For correctness, if the collection is "auth" and the key is "username", + * the unique check will be case insensitive. + * + * NB! Array values (eg. from multiple select fields) are matched + * as a serialized json strings (eg. `["a","b"]`), so the value uniqueness + * depends on the elements order. Or in other words the following values + * are considered different: `[]string{"a","b"}` and `[]string{"b","a"}` + */ + isRecordValueUnique(collectionNameOrId: string, key: string, value: any, ...excludeIds: string[]): boolean + } + interface Dao { + /** + * FindAuthRecordByToken finds the auth record associated with the provided JWT token. + * + * Returns an error if the JWT token is invalid, expired or not associated to an auth collection record. + */ + findAuthRecordByToken(token: string, baseTokenKey: string): (models.Record | undefined) + } + interface Dao { + /** + * FindAuthRecordByEmail finds the auth record associated with the provided email. + * + * Returns an error if it is not an auth collection or the record is not found. + */ + findAuthRecordByEmail(collectionNameOrId: string, email: string): (models.Record | undefined) + } + interface Dao { + /** + * FindAuthRecordByUsername finds the auth record associated with the provided username (case insensitive). + * + * Returns an error if it is not an auth collection or the record is not found. + */ + findAuthRecordByUsername(collectionNameOrId: string, username: string): (models.Record | undefined) + } + interface Dao { + /** + * SuggestUniqueAuthRecordUsername checks if the provided username is unique + * and return a new "unique" username with appended random numeric part + * (eg. "existingName" -> "existingName583"). + * + * The same username will be returned if the provided string is already unique. + */ + suggestUniqueAuthRecordUsername(collectionNameOrId: string, baseUsername: string, ...excludeIds: string[]): string + } + interface Dao { + /** + * CanAccessRecord checks if a record is allowed to be accessed by the + * specified requestData and accessRule. + * + * Rule and db checks are ignored in case requestData.Admin is set. + * + * The returned error indicate that something unexpected happened during + * the check (eg. invalid rule or db error). + * + * The method always return false on invalid access rule or db error. + * + * Example: + * + * ``` + * requestData := apis.RequestData(c /* echo.Context *\/) + * record, _ := dao.FindRecordById("example", "RECORD_ID") + * rule := types.Pointer("@request.auth.id != '' || status = 'public'") + * // ... or use one of the record collection's rule, eg. record.Collection().ViewRule + * + * if ok, _ := dao.CanAccessRecord(record, requestData, rule); ok { ... } + * ``` + */ + canAccessRecord(record: models.Record, requestData: models.RequestData, accessRule: string): boolean + } + interface Dao { + /** + * SaveRecord persists the provided Record model in the database. + * + * If record.IsNew() is true, the method will perform a create, otherwise an update. + * To explicitly mark a record for update you can use record.MarkAsNotNew(). + */ + saveRecord(record: models.Record): void + } + interface Dao { + /** + * DeleteRecord deletes the provided Record model. + * + * This method will also cascade the delete operation to all linked + * relational records (delete or unset, depending on the rel settings). + * + * The delete operation may fail if the record is part of a required + * reference in another record (aka. cannot be deleted or unset). + */ + deleteRecord(record: models.Record): void + } + interface Dao { + /** + * ExpandRecord expands the relations of a single Record model. + * + * Returns a map with the failed expand parameters and their errors. + */ + expandRecord(record: models.Record, expands: Array, fetchFunc: ExpandFetchFunc): _TygojaDict + } + interface Dao { + /** + * ExpandRecords expands the relations of the provided Record models list. + * + * Returns a map with the failed expand parameters and their errors. + */ + expandRecords(records: Array<(models.Record | undefined)>, expands: Array, fetchFunc: ExpandFetchFunc): _TygojaDict + } + // @ts-ignore + import validation = ozzo_validation + interface Dao { + /** + * SyncRecordTableSchema compares the two provided collections + * and applies the necessary related record table changes. + * + * If `oldCollection` is null, then only `newCollection` is used to create the record table. + */ + syncRecordTableSchema(newCollection: models.Collection, oldCollection: models.Collection): void + } + interface Dao { + /** + * RequestQuery returns a new Request logs select query. + */ + requestQuery(): (dbx.SelectQuery | undefined) + } + interface Dao { + /** + * FindRequestById finds a single Request log by its id. + */ + findRequestById(id: string): (models.Request | undefined) + } + interface Dao { + /** + * RequestsStats returns hourly grouped requests logs statistics. + */ + requestsStats(expr: dbx.Expression): Array<(RequestsStatsItem | undefined)> + } + interface Dao { + /** + * DeleteOldRequests delete all requests that are created before createdBefore. + */ + deleteOldRequests(createdBefore: time.Time): void + } + interface Dao { + /** + * SaveRequest upserts the provided Request model. + */ + saveRequest(request: models.Request): void + } + interface Dao { + /** + * FindSettings returns and decode the serialized app settings param value. + * + * The method will first try to decode the param value without decryption. + * If it fails and optEncryptionKey is set, it will try again by first + * decrypting the value and then decode it again. + * + * Returns an error if it fails to decode the stored serialized param value. + */ + findSettings(...optEncryptionKey: string[]): (settings.Settings | undefined) + } + interface Dao { + /** + * SaveSettings persists the specified settings configuration. + * + * If optEncryptionKey is set, then the stored serialized value will be encrypted with it. + */ + saveSettings(newSettings: settings.Settings, ...optEncryptionKey: string[]): void + } + interface Dao { + /** + * HasTable checks if a table (or view) with the provided name exists (case insensitive). + */ + hasTable(tableName: string): boolean + } + interface Dao { + /** + * TableColumns returns all column names of a single table by its name. + */ + tableColumns(tableName: string): Array + } + interface Dao { + /** + * TableInfo returns the `table_info` pragma result for the specified table. + */ + tableInfo(tableName: string): Array<(models.TableInfoRow | undefined)> + } + interface Dao { + /** + * TableIndexes returns a name grouped map with all non empty index of the specified table. + * + * Note: This method doesn't return an error on nonexisting table. + */ + tableIndexes(tableName: string): _TygojaDict + } + interface Dao { + /** + * DeleteTable drops the specified table. + * + * This method is a no-op if a table with the provided name doesn't exist. + * + * Be aware that this method is vulnerable to SQL injection and the + * "tableName" argument must come only from trusted input! + */ + deleteTable(tableName: string): void + } + interface Dao { + /** + * Vacuum executes VACUUM on the current dao.DB() instance in order to + * reclaim unused db disk space. + */ + vacuum(): void + } + interface Dao { + /** + * DeleteView drops the specified view name. + * + * This method is a no-op if a view with the provided name doesn't exist. + * + * Be aware that this method is vulnerable to SQL injection and the + * "name" argument must come only from trusted input! + */ + deleteView(name: string): void + } + interface Dao { + /** + * SaveView creates (or updates already existing) persistent SQL view. + * + * Be aware that this method is vulnerable to SQL injection and the + * "selectQuery" argument must come only from trusted input! + */ + saveView(name: string, selectQuery: string): void + } + interface Dao { + /** + * CreateViewSchema creates a new view schema from the provided select query. + * + * There are some caveats: + * - The select query must have an "id" column. + * - Wildcard ("*") columns are not supported to avoid accidentally leaking sensitive data. + */ + createViewSchema(selectQuery: string): schema.Schema + } + interface Dao { + /** + * FindRecordByViewFile returns the original models.Record of the + * provided view collection file. + */ + findRecordByViewFile(viewCollectionNameOrId: string, fileFieldName: string, filename: string): (models.Record | undefined) + } +} + +namespace migrate { + /** + * MigrationsList defines a list with migration definitions + */ + interface MigrationsList { + } + interface MigrationsList { + /** + * Item returns a single migration from the list by its index. + */ + item(index: number): (Migration | undefined) + } + interface MigrationsList { + /** + * Items returns the internal migrations list slice. + */ + items(): Array<(Migration | undefined)> + } + interface MigrationsList { + /** + * Register adds new migration definition to the list. + * + * If `optFilename` is not provided, it will try to get the name from its .go file. + * + * The list will be sorted automatically based on the migrations file name. + */ + register(up: (db: dbx.Builder) => void, down: (db: dbx.Builder) => void, ...optFilename: string[]): void + } +} + +/** + * Package core is the backbone of PocketBase. + * + * It defines the main PocketBase App interface and its base implementation. + */ +namespace core { + /** + * App defines the main PocketBase app interface. + */ + interface App { + /** + * Deprecated: + * This method may get removed in the near future. + * It is recommended to access the app db instance from app.Dao().DB() or + * if you want more flexibility - app.Dao().ConcurrentDB() and app.Dao().NonconcurrentDB(). + * + * DB returns the default app database instance. + */ + db(): (dbx.DB | undefined) + /** + * Dao returns the default app Dao instance. + * + * This Dao could operate only on the tables and models + * associated with the default app database. For example, + * trying to access the request logs table will result in error. + */ + dao(): (daos.Dao | undefined) + /** + * Deprecated: + * This method may get removed in the near future. + * It is recommended to access the logs db instance from app.LogsDao().DB() or + * if you want more flexibility - app.LogsDao().ConcurrentDB() and app.LogsDao().NonconcurrentDB(). + * + * LogsDB returns the app logs database instance. + */ + logsDB(): (dbx.DB | undefined) + /** + * LogsDao returns the app logs Dao instance. + * + * This Dao could operate only on the tables and models + * associated with the logs database. For example, trying to access + * the users table from LogsDao will result in error. + */ + logsDao(): (daos.Dao | undefined) + /** + * DataDir returns the app data directory path. + */ + dataDir(): string + /** + * EncryptionEnv returns the name of the app secret env key + * (used for settings encryption). + */ + encryptionEnv(): string + /** + * IsDebug returns whether the app is in debug mode + * (showing more detailed error logs, executed sql statements, etc.). + */ + isDebug(): boolean + /** + * Settings returns the loaded app settings. + */ + settings(): (settings.Settings | undefined) + /** + * Cache returns the app internal cache store. + */ + cache(): (store.Store | undefined) + /** + * SubscriptionsBroker returns the app realtime subscriptions broker instance. + */ + subscriptionsBroker(): (subscriptions.Broker | undefined) + /** + * NewMailClient creates and returns a configured app mail client. + */ + newMailClient(): mailer.Mailer + /** + * NewFilesystem creates and returns a configured filesystem.System instance + * for managing regular app files (eg. collection uploads). + * + * NB! Make sure to call Close() on the returned result + * after you are done working with it. + */ + newFilesystem(): (filesystem.System | undefined) + /** + * NewBackupsFilesystem creates and returns a configured filesystem.System instance + * for managing app backups. + * + * NB! Make sure to call Close() on the returned result + * after you are done working with it. + */ + newBackupsFilesystem(): (filesystem.System | undefined) + /** + * RefreshSettings reinitializes and reloads the stored application settings. + */ + refreshSettings(): void + /** + * IsBootstrapped checks if the application was initialized + * (aka. whether Bootstrap() was called). + */ + isBootstrapped(): boolean + /** + * Bootstrap takes care for initializing the application + * (open db connections, load settings, etc.). + * + * It will call ResetBootstrapState() if the application was already bootstrapped. + */ + bootstrap(): void + /** + * ResetBootstrapState takes care for releasing initialized app resources + * (eg. closing db connections). + */ + resetBootstrapState(): void + /** + * CreateBackup creates a new backup of the current app pb_data directory. + * + * Backups can be stored on S3 if it is configured in app.Settings().Backups. + * + * Please refer to the godoc of the specific core.App implementation + * for details on the backup procedures. + */ + createBackup(ctx: context.Context, name: string): void + /** + * RestoreBackup restores the backup with the specified name and restarts + * the current running application process. + * + * The safely perform the restore it is recommended to have free disk space + * for at least 2x the size of the restored pb_data backup. + * + * Please refer to the godoc of the specific core.App implementation + * for details on the restore procedures. + * + * NB! This feature is experimental and currently is expected to work only on UNIX based systems. + */ + restoreBackup(ctx: context.Context, name: string): void + /** + * Restart restarts the current running application process. + * + * Currently it is relying on execve so it is supported only on UNIX based systems. + */ + restart(): void + /** + * OnBeforeBootstrap hook is triggered before initializing the main + * application resources (eg. before db open and initial settings load). + */ + onBeforeBootstrap(): (hook.Hook | undefined) + /** + * OnAfterBootstrap hook is triggered after initializing the main + * application resources (eg. after db open and initial settings load). + */ + onAfterBootstrap(): (hook.Hook | undefined) + /** + * OnBeforeServe hook is triggered before serving the internal router (echo), + * allowing you to adjust its options and attach new routes or middlewares. + */ + onBeforeServe(): (hook.Hook | undefined) + /** + * OnBeforeApiError hook is triggered right before sending an error API + * response to the client, allowing you to further modify the error data + * or to return a completely different API response. + */ + onBeforeApiError(): (hook.Hook | undefined) + /** + * OnAfterApiError hook is triggered right after sending an error API + * response to the client. + * It could be used to log the final API error in external services. + */ + onAfterApiError(): (hook.Hook | undefined) + /** + * OnTerminate hook is triggered when the app is in the process + * of being terminated (eg. on SIGTERM signal). + */ + onTerminate(): (hook.Hook | undefined) + /** + * OnModelBeforeCreate hook is triggered before inserting a new + * entry in the DB, allowing you to modify or validate the stored data. + * + * If the optional "tags" list (table names and/or the Collection id for Record models) + * is specified, then all event handlers registered via the created hook + * will be triggered and called only if their event data origin matches the tags. + */ + onModelBeforeCreate(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnModelAfterCreate hook is triggered after successfully + * inserting a new entry in the DB. + * + * If the optional "tags" list (table names and/or the Collection id for Record models) + * is specified, then all event handlers registered via the created hook + * will be triggered and called only if their event data origin matches the tags. + */ + onModelAfterCreate(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnModelBeforeUpdate hook is triggered before updating existing + * entry in the DB, allowing you to modify or validate the stored data. + * + * If the optional "tags" list (table names and/or the Collection id for Record models) + * is specified, then all event handlers registered via the created hook + * will be triggered and called only if their event data origin matches the tags. + */ + onModelBeforeUpdate(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnModelAfterUpdate hook is triggered after successfully updating + * existing entry in the DB. + * + * If the optional "tags" list (table names and/or the Collection id for Record models) + * is specified, then all event handlers registered via the created hook + * will be triggered and called only if their event data origin matches the tags. + */ + onModelAfterUpdate(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnModelBeforeDelete hook is triggered before deleting an + * existing entry from the DB. + * + * If the optional "tags" list (table names and/or the Collection id for Record models) + * is specified, then all event handlers registered via the created hook + * will be triggered and called only if their event data origin matches the tags. + */ + onModelBeforeDelete(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnModelAfterDelete hook is triggered after successfully deleting an + * existing entry from the DB. + * + * If the optional "tags" list (table names and/or the Collection id for Record models) + * is specified, then all event handlers registered via the created hook + * will be triggered and called only if their event data origin matches the tags. + */ + onModelAfterDelete(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnMailerBeforeAdminResetPasswordSend hook is triggered right + * before sending a password reset email to an admin, allowing you + * to inspect and customize the email message that is being sent. + */ + onMailerBeforeAdminResetPasswordSend(): (hook.Hook | undefined) + /** + * OnMailerAfterAdminResetPasswordSend hook is triggered after + * admin password reset email was successfully sent. + */ + onMailerAfterAdminResetPasswordSend(): (hook.Hook | undefined) + /** + * OnMailerBeforeRecordResetPasswordSend hook is triggered right + * before sending a password reset email to an auth record, allowing + * you to inspect and customize the email message that is being sent. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onMailerBeforeRecordResetPasswordSend(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnMailerAfterRecordResetPasswordSend hook is triggered after + * an auth record password reset email was successfully sent. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onMailerAfterRecordResetPasswordSend(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnMailerBeforeRecordVerificationSend hook is triggered right + * before sending a verification email to an auth record, allowing + * you to inspect and customize the email message that is being sent. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onMailerBeforeRecordVerificationSend(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnMailerAfterRecordVerificationSend hook is triggered after a + * verification email was successfully sent to an auth record. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onMailerAfterRecordVerificationSend(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnMailerBeforeRecordChangeEmailSend hook is triggered right before + * sending a confirmation new address email to an auth record, allowing + * you to inspect and customize the email message that is being sent. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onMailerBeforeRecordChangeEmailSend(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnMailerAfterRecordChangeEmailSend hook is triggered after a + * verification email was successfully sent to an auth record. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onMailerAfterRecordChangeEmailSend(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRealtimeConnectRequest hook is triggered right before establishing + * the SSE client connection. + */ + onRealtimeConnectRequest(): (hook.Hook | undefined) + /** + * OnRealtimeDisconnectRequest hook is triggered on disconnected/interrupted + * SSE client connection. + */ + onRealtimeDisconnectRequest(): (hook.Hook | undefined) + /** + * OnRealtimeBeforeMessage hook is triggered right before sending + * an SSE message to a client. + * + * Returning [hook.StopPropagation] will prevent sending the message. + * Returning any other non-nil error will close the realtime connection. + */ + onRealtimeBeforeMessageSend(): (hook.Hook | undefined) + /** + * OnRealtimeBeforeMessage hook is triggered right after sending + * an SSE message to a client. + */ + onRealtimeAfterMessageSend(): (hook.Hook | undefined) + /** + * OnRealtimeBeforeSubscribeRequest hook is triggered before changing + * the client subscriptions, allowing you to further validate and + * modify the submitted change. + */ + onRealtimeBeforeSubscribeRequest(): (hook.Hook | undefined) + /** + * OnRealtimeAfterSubscribeRequest hook is triggered after the client + * subscriptions were successfully changed. + */ + onRealtimeAfterSubscribeRequest(): (hook.Hook | undefined) + /** + * OnSettingsListRequest hook is triggered on each successful + * API Settings list request. + * + * Could be used to validate or modify the response before + * returning it to the client. + */ + onSettingsListRequest(): (hook.Hook | undefined) + /** + * OnSettingsBeforeUpdateRequest hook is triggered before each API + * Settings update request (after request data load and before settings persistence). + * + * Could be used to additionally validate the request data or + * implement completely different persistence behavior. + */ + onSettingsBeforeUpdateRequest(): (hook.Hook | undefined) + /** + * OnSettingsAfterUpdateRequest hook is triggered after each + * successful API Settings update request. + */ + onSettingsAfterUpdateRequest(): (hook.Hook | undefined) + /** + * OnFileDownloadRequest hook is triggered before each API File download request. + * + * Could be used to validate or modify the file response before + * returning it to the client. + */ + onFileDownloadRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnFileBeforeTokenRequest hook is triggered before each file + * token API request. + * + * If no token or model was submitted, e.Model and e.Token will be empty, + * allowing you to implement your own custom model file auth implementation. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onFileBeforeTokenRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnFileAfterTokenRequest hook is triggered after each + * successful file token API request. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onFileAfterTokenRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnAdminsListRequest hook is triggered on each API Admins list request. + * + * Could be used to validate or modify the response before returning it to the client. + */ + onAdminsListRequest(): (hook.Hook | undefined) + /** + * OnAdminViewRequest hook is triggered on each API Admin view request. + * + * Could be used to validate or modify the response before returning it to the client. + */ + onAdminViewRequest(): (hook.Hook | undefined) + /** + * OnAdminBeforeCreateRequest hook is triggered before each API + * Admin create request (after request data load and before model persistence). + * + * Could be used to additionally validate the request data or implement + * completely different persistence behavior. + */ + onAdminBeforeCreateRequest(): (hook.Hook | undefined) + /** + * OnAdminAfterCreateRequest hook is triggered after each + * successful API Admin create request. + */ + onAdminAfterCreateRequest(): (hook.Hook | undefined) + /** + * OnAdminBeforeUpdateRequest hook is triggered before each API + * Admin update request (after request data load and before model persistence). + * + * Could be used to additionally validate the request data or implement + * completely different persistence behavior. + */ + onAdminBeforeUpdateRequest(): (hook.Hook | undefined) + /** + * OnAdminAfterUpdateRequest hook is triggered after each + * successful API Admin update request. + */ + onAdminAfterUpdateRequest(): (hook.Hook | undefined) + /** + * OnAdminBeforeDeleteRequest hook is triggered before each API + * Admin delete request (after model load and before actual deletion). + * + * Could be used to additionally validate the request data or implement + * completely different delete behavior. + */ + onAdminBeforeDeleteRequest(): (hook.Hook | undefined) + /** + * OnAdminAfterDeleteRequest hook is triggered after each + * successful API Admin delete request. + */ + onAdminAfterDeleteRequest(): (hook.Hook | undefined) + /** + * OnAdminAuthRequest hook is triggered on each successful API Admin + * authentication request (sign-in, token refresh, etc.). + * + * Could be used to additionally validate or modify the + * authenticated admin data and token. + */ + onAdminAuthRequest(): (hook.Hook | undefined) + /** + * OnAdminBeforeAuthWithPasswordRequest hook is triggered before each Admin + * auth with password API request (after request data load and before password validation). + * + * Could be used to implement for example a custom password validation + * or to locate a different Admin identity (by assigning [AdminAuthWithPasswordEvent.Admin]). + */ + onAdminBeforeAuthWithPasswordRequest(): (hook.Hook | undefined) + /** + * OnAdminAfterAuthWithPasswordRequest hook is triggered after each + * successful Admin auth with password API request. + */ + onAdminAfterAuthWithPasswordRequest(): (hook.Hook | undefined) + /** + * OnAdminBeforeAuthRefreshRequest hook is triggered before each Admin + * auth refresh API request (right before generating a new auth token). + * + * Could be used to additionally validate the request data or implement + * completely different auth refresh behavior. + */ + onAdminBeforeAuthRefreshRequest(): (hook.Hook | undefined) + /** + * OnAdminAfterAuthRefreshRequest hook is triggered after each + * successful auth refresh API request (right after generating a new auth token). + */ + onAdminAfterAuthRefreshRequest(): (hook.Hook | undefined) + /** + * OnAdminBeforeRequestPasswordResetRequest hook is triggered before each Admin + * request password reset API request (after request data load and before sending the reset email). + * + * Could be used to additionally validate the request data or implement + * completely different password reset behavior. + */ + onAdminBeforeRequestPasswordResetRequest(): (hook.Hook | undefined) + /** + * OnAdminAfterRequestPasswordResetRequest hook is triggered after each + * successful request password reset API request. + */ + onAdminAfterRequestPasswordResetRequest(): (hook.Hook | undefined) + /** + * OnAdminBeforeConfirmPasswordResetRequest hook is triggered before each Admin + * confirm password reset API request (after request data load and before persistence). + * + * Could be used to additionally validate the request data or implement + * completely different persistence behavior. + */ + onAdminBeforeConfirmPasswordResetRequest(): (hook.Hook | undefined) + /** + * OnAdminAfterConfirmPasswordResetRequest hook is triggered after each + * successful confirm password reset API request. + */ + onAdminAfterConfirmPasswordResetRequest(): (hook.Hook | undefined) + /** + * OnRecordAuthRequest hook is triggered on each successful API + * record authentication request (sign-in, token refresh, etc.). + * + * Could be used to additionally validate or modify the authenticated + * record data and token. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordAuthRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordBeforeAuthWithPasswordRequest hook is triggered before each Record + * auth with password API request (after request data load and before password validation). + * + * Could be used to implement for example a custom password validation + * or to locate a different Record model (by reassigning [RecordAuthWithPasswordEvent.Record]). + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordBeforeAuthWithPasswordRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordAfterAuthWithPasswordRequest hook is triggered after each + * successful Record auth with password API request. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordAfterAuthWithPasswordRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordBeforeAuthWithOAuth2Request hook is triggered before each Record + * OAuth2 sign-in/sign-up API request (after token exchange and before external provider linking). + * + * If the [RecordAuthWithOAuth2Event.Record] is not set, then the OAuth2 + * request will try to create a new auth Record. + * + * To assign or link a different existing record model you can + * change the [RecordAuthWithOAuth2Event.Record] field. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordBeforeAuthWithOAuth2Request(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordAfterAuthWithOAuth2Request hook is triggered after each + * successful Record OAuth2 API request. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordAfterAuthWithOAuth2Request(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordBeforeAuthRefreshRequest hook is triggered before each Record + * auth refresh API request (right before generating a new auth token). + * + * Could be used to additionally validate the request data or implement + * completely different auth refresh behavior. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordBeforeAuthRefreshRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordAfterAuthRefreshRequest hook is triggered after each + * successful auth refresh API request (right after generating a new auth token). + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordAfterAuthRefreshRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordListExternalAuthsRequest hook is triggered on each API record external auths list request. + * + * Could be used to validate or modify the response before returning it to the client. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordListExternalAuthsRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordBeforeUnlinkExternalAuthRequest hook is triggered before each API record + * external auth unlink request (after models load and before the actual relation deletion). + * + * Could be used to additionally validate the request data or implement + * completely different delete behavior. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordBeforeUnlinkExternalAuthRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordAfterUnlinkExternalAuthRequest hook is triggered after each + * successful API record external auth unlink request. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordAfterUnlinkExternalAuthRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordBeforeRequestPasswordResetRequest hook is triggered before each Record + * request password reset API request (after request data load and before sending the reset email). + * + * Could be used to additionally validate the request data or implement + * completely different password reset behavior. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordBeforeRequestPasswordResetRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordAfterRequestPasswordResetRequest hook is triggered after each + * successful request password reset API request. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordAfterRequestPasswordResetRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordBeforeConfirmPasswordResetRequest hook is triggered before each Record + * confirm password reset API request (after request data load and before persistence). + * + * Could be used to additionally validate the request data or implement + * completely different persistence behavior. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordBeforeConfirmPasswordResetRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordAfterConfirmPasswordResetRequest hook is triggered after each + * successful confirm password reset API request. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordAfterConfirmPasswordResetRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordBeforeRequestVerificationRequest hook is triggered before each Record + * request verification API request (after request data load and before sending the verification email). + * + * Could be used to additionally validate the loaded request data or implement + * completely different verification behavior. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordBeforeRequestVerificationRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordAfterRequestVerificationRequest hook is triggered after each + * successful request verification API request. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordAfterRequestVerificationRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordBeforeConfirmVerificationRequest hook is triggered before each Record + * confirm verification API request (after request data load and before persistence). + * + * Could be used to additionally validate the request data or implement + * completely different persistence behavior. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordBeforeConfirmVerificationRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordAfterConfirmVerificationRequest hook is triggered after each + * successful confirm verification API request. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordAfterConfirmVerificationRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordBeforeRequestEmailChangeRequest hook is triggered before each Record request email change API request + * (after request data load and before sending the email link to confirm the change). + * + * Could be used to additionally validate the request data or implement + * completely different request email change behavior. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordBeforeRequestEmailChangeRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordAfterRequestEmailChangeRequest hook is triggered after each + * successful request email change API request. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordAfterRequestEmailChangeRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordBeforeConfirmEmailChangeRequest hook is triggered before each Record + * confirm email change API request (after request data load and before persistence). + * + * Could be used to additionally validate the request data or implement + * completely different persistence behavior. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordBeforeConfirmEmailChangeRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordAfterConfirmEmailChangeRequest hook is triggered after each + * successful confirm email change API request. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordAfterConfirmEmailChangeRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordsListRequest hook is triggered on each API Records list request. + * + * Could be used to validate or modify the response before returning it to the client. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordsListRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordViewRequest hook is triggered on each API Record view request. + * + * Could be used to validate or modify the response before returning it to the client. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordViewRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordBeforeCreateRequest hook is triggered before each API Record + * create request (after request data load and before model persistence). + * + * Could be used to additionally validate the request data or implement + * completely different persistence behavior. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordBeforeCreateRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordAfterCreateRequest hook is triggered after each + * successful API Record create request. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordAfterCreateRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordBeforeUpdateRequest hook is triggered before each API Record + * update request (after request data load and before model persistence). + * + * Could be used to additionally validate the request data or implement + * completely different persistence behavior. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordBeforeUpdateRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordAfterUpdateRequest hook is triggered after each + * successful API Record update request. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordAfterUpdateRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordBeforeDeleteRequest hook is triggered before each API Record + * delete request (after model load and before actual deletion). + * + * Could be used to additionally validate the request data or implement + * completely different delete behavior. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordBeforeDeleteRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnRecordAfterDeleteRequest hook is triggered after each + * successful API Record delete request. + * + * If the optional "tags" list (Collection ids or names) is specified, + * then all event handlers registered via the created hook will be + * triggered and called only if their event data origin matches the tags. + */ + onRecordAfterDeleteRequest(...tags: string[]): (hook.TaggedHook | undefined) + /** + * OnCollectionsListRequest hook is triggered on each API Collections list request. + * + * Could be used to validate or modify the response before returning it to the client. + */ + onCollectionsListRequest(): (hook.Hook | undefined) + /** + * OnCollectionViewRequest hook is triggered on each API Collection view request. + * + * Could be used to validate or modify the response before returning it to the client. + */ + onCollectionViewRequest(): (hook.Hook | undefined) + /** + * OnCollectionBeforeCreateRequest hook is triggered before each API Collection + * create request (after request data load and before model persistence). + * + * Could be used to additionally validate the request data or implement + * completely different persistence behavior. + */ + onCollectionBeforeCreateRequest(): (hook.Hook | undefined) + /** + * OnCollectionAfterCreateRequest hook is triggered after each + * successful API Collection create request. + */ + onCollectionAfterCreateRequest(): (hook.Hook | undefined) + /** + * OnCollectionBeforeUpdateRequest hook is triggered before each API Collection + * update request (after request data load and before model persistence). + * + * Could be used to additionally validate the request data or implement + * completely different persistence behavior. + */ + onCollectionBeforeUpdateRequest(): (hook.Hook | undefined) + /** + * OnCollectionAfterUpdateRequest hook is triggered after each + * successful API Collection update request. + */ + onCollectionAfterUpdateRequest(): (hook.Hook | undefined) + /** + * OnCollectionBeforeDeleteRequest hook is triggered before each API + * Collection delete request (after model load and before actual deletion). + * + * Could be used to additionally validate the request data or implement + * completely different delete behavior. + */ + onCollectionBeforeDeleteRequest(): (hook.Hook | undefined) + /** + * OnCollectionAfterDeleteRequest hook is triggered after each + * successful API Collection delete request. + */ + onCollectionAfterDeleteRequest(): (hook.Hook | undefined) + /** + * OnCollectionsBeforeImportRequest hook is triggered before each API + * collections import request (after request data load and before the actual import). + * + * Could be used to additionally validate the imported collections or + * to implement completely different import behavior. + */ + onCollectionsBeforeImportRequest(): (hook.Hook | undefined) + /** + * OnCollectionsAfterImportRequest hook is triggered after each + * successful API collections import request. + */ + onCollectionsAfterImportRequest(): (hook.Hook | undefined) + } +} + /** * Package cobra is a commander providing a simple interface to create powerful modern CLI interfaces. * In addition to providing an interface, Cobra simultaneously provides a controller to organize your application code. @@ -8374,2167 +10566,67 @@ namespace cobra { } /** - * Package echo implements high performance, minimalist Go web framework. + * Package io provides basic interfaces to I/O primitives. + * Its primary job is to wrap existing implementations of such primitives, + * such as those in package os, into shared public interfaces that + * abstract the functionality, plus some other related primitives. * - * Example: - * - * ``` - * package main - * - * import ( - * "github.com/labstack/echo/v5" - * "github.com/labstack/echo/v5/middleware" - * "log" - * "net/http" - * ) - * - * // Handler - * func hello(c echo.Context) error { - * return c.String(http.StatusOK, "Hello, World!") - * } - * - * func main() { - * // Echo instance - * e := echo.New() - * - * // Middleware - * e.Use(middleware.Logger()) - * e.Use(middleware.Recover()) - * - * // Routes - * e.GET("/", hello) - * - * // Start server - * if err := e.Start(":8080"); err != http.ErrServerClosed { - * log.Fatal(err) - * } - * } - * ``` - * - * Learn more at https://echo.labstack.com + * Because these interfaces and primitives wrap lower-level operations with + * various implementations, unless otherwise informed clients should not + * assume they are safe for parallel execution. */ -namespace echo { +namespace io { /** - * Context represents the context of the current HTTP request. It holds request and - * response objects, path, path parameters, data and registered handler. - */ - interface Context { - /** - * Request returns `*http.Request`. - */ - request(): (http.Request | undefined) - /** - * SetRequest sets `*http.Request`. - */ - setRequest(r: http.Request): void - /** - * SetResponse sets `*Response`. - */ - setResponse(r: Response): void - /** - * Response returns `*Response`. - */ - response(): (Response | undefined) - /** - * IsTLS returns true if HTTP connection is TLS otherwise false. - */ - isTLS(): boolean - /** - * IsWebSocket returns true if HTTP connection is WebSocket otherwise false. - */ - isWebSocket(): boolean - /** - * Scheme returns the HTTP protocol scheme, `http` or `https`. - */ - scheme(): string - /** - * RealIP returns the client's network address based on `X-Forwarded-For` - * or `X-Real-IP` request header. - * The behavior can be configured using `Echo#IPExtractor`. - */ - realIP(): string - /** - * RouteInfo returns current request route information. Method, Path, Name and params if they exist for matched route. - * In case of 404 (route not found) and 405 (method not allowed) RouteInfo returns generic struct for these cases. - */ - routeInfo(): RouteInfo - /** - * Path returns the registered path for the handler. - */ - path(): string - /** - * PathParam returns path parameter by name. - */ - pathParam(name: string): string - /** - * PathParamDefault returns the path parameter or default value for the provided name. - * - * Notes for DefaultRouter implementation: - * Path parameter could be empty for cases like that: - * * route `/release-:version/bin` and request URL is `/release-/bin` - * * route `/api/:version/image.jpg` and request URL is `/api//image.jpg` - * but not when path parameter is last part of route path - * * route `/download/file.:ext` will not match request `/download/file.` - */ - pathParamDefault(name: string, defaultValue: string): string - /** - * PathParams returns path parameter values. - */ - pathParams(): PathParams - /** - * SetPathParams sets path parameters for current request. - */ - setPathParams(params: PathParams): void - /** - * QueryParam returns the query param for the provided name. - */ - queryParam(name: string): string - /** - * QueryParamDefault returns the query param or default value for the provided name. - */ - queryParamDefault(name: string): string - /** - * QueryParams returns the query parameters as `url.Values`. - */ - queryParams(): url.Values - /** - * QueryString returns the URL query string. - */ - queryString(): string - /** - * FormValue returns the form field value for the provided name. - */ - formValue(name: string): string - /** - * FormValueDefault returns the form field value or default value for the provided name. - */ - formValueDefault(name: string): string - /** - * FormValues returns the form field values as `url.Values`. - */ - formValues(): url.Values - /** - * FormFile returns the multipart form file for the provided name. - */ - formFile(name: string): (multipart.FileHeader | undefined) - /** - * MultipartForm returns the multipart form. - */ - multipartForm(): (multipart.Form | undefined) - /** - * Cookie returns the named cookie provided in the request. - */ - cookie(name: string): (http.Cookie | undefined) - /** - * SetCookie adds a `Set-Cookie` header in HTTP response. - */ - setCookie(cookie: http.Cookie): void - /** - * Cookies returns the HTTP cookies sent with the request. - */ - cookies(): Array<(http.Cookie | undefined)> - /** - * Get retrieves data from the context. - */ - get(key: string): { - } - /** - * Set saves data in the context. - */ - set(key: string, val: { - }): void - /** - * Bind binds the request body into provided type `i`. The default binder - * does it based on Content-Type header. - */ - bind(i: { - }): void - /** - * Validate validates provided `i`. It is usually called after `Context#Bind()`. - * Validator must be registered using `Echo#Validator`. - */ - validate(i: { - }): void - /** - * Render renders a template with data and sends a text/html response with status - * code. Renderer must be registered using `Echo.Renderer`. - */ - render(code: number, name: string, data: { - }): void - /** - * HTML sends an HTTP response with status code. - */ - html(code: number, html: string): void - /** - * HTMLBlob sends an HTTP blob response with status code. - */ - htmlBlob(code: number, b: string): void - /** - * String sends a string response with status code. - */ - string(code: number, s: string): void - /** - * JSON sends a JSON response with status code. - */ - json(code: number, i: { - }): void - /** - * JSONPretty sends a pretty-print JSON with status code. - */ - jsonPretty(code: number, i: { - }, indent: string): void - /** - * JSONBlob sends a JSON blob response with status code. - */ - jsonBlob(code: number, b: string): void - /** - * JSONP sends a JSONP response with status code. It uses `callback` to construct - * the JSONP payload. - */ - jsonp(code: number, callback: string, i: { - }): void - /** - * JSONPBlob sends a JSONP blob response with status code. It uses `callback` - * to construct the JSONP payload. - */ - jsonpBlob(code: number, callback: string, b: string): void - /** - * XML sends an XML response with status code. - */ - xml(code: number, i: { - }): void - /** - * XMLPretty sends a pretty-print XML with status code. - */ - xmlPretty(code: number, i: { - }, indent: string): void - /** - * XMLBlob sends an XML blob response with status code. - */ - xmlBlob(code: number, b: string): void - /** - * Blob sends a blob response with status code and content type. - */ - blob(code: number, contentType: string, b: string): void - /** - * Stream sends a streaming response with status code and content type. - */ - stream(code: number, contentType: string, r: io.Reader): void - /** - * File sends a response with the content of the file. - */ - file(file: string): void - /** - * FileFS sends a response with the content of the file from given filesystem. - */ - fileFS(file: string, filesystem: fs.FS): void - /** - * Attachment sends a response as attachment, prompting client to save the - * file. - */ - attachment(file: string, name: string): void - /** - * Inline sends a response as inline, opening the file in the browser. - */ - inline(file: string, name: string): void - /** - * NoContent sends a response with no body and a status code. - */ - noContent(code: number): void - /** - * Redirect redirects the request to a provided URL with status code. - */ - redirect(code: number, url: string): void - /** - * Echo returns the `Echo` instance. - * - * WARNING: Remember that Echo public fields and methods are coroutine safe ONLY when you are NOT mutating them - * anywhere in your code after Echo server has started. - */ - echo(): (Echo | undefined) - } - // @ts-ignore - import stdContext = context - /** - * Echo is the top-level framework instance. + * Reader is the interface that wraps the basic Read method. * - * Note: replacing/nilling public fields is not coroutine/thread-safe and can cause data-races/panics. This is very likely - * to happen when you access Echo instances through Context.Echo() method. - */ - interface Echo { - /** - * NewContextFunc allows using custom context implementations, instead of default *echo.context - */ - newContextFunc: (e: Echo, pathParamAllocSize: number) => ServableContext - debug: boolean - httpErrorHandler: HTTPErrorHandler - binder: Binder - jsonSerializer: JSONSerializer - validator: Validator - renderer: Renderer - logger: Logger - ipExtractor: IPExtractor - /** - * Filesystem is file system used by Static and File handlers to access files. - * Defaults to os.DirFS(".") - * - * When dealing with `embed.FS` use `fs := echo.MustSubFS(fs, "rootDirectory") to create sub fs which uses necessary - * prefix for directory path. This is necessary as `//go:embed assets/images` embeds files with paths - * including `assets/images` as their prefix. - */ - filesystem: fs.FS - } - /** - * HandlerFunc defines a function to serve HTTP requests. - */ - interface HandlerFunc {(c: Context): void } - /** - * MiddlewareFunc defines a function to process middleware. - */ - interface MiddlewareFunc {(next: HandlerFunc): HandlerFunc } - interface Echo { - /** - * NewContext returns a new Context instance. - * - * Note: both request and response can be left to nil as Echo.ServeHTTP will call c.Reset(req,resp) anyway - * these arguments are useful when creating context for tests and cases like that. - */ - newContext(r: http.Request, w: http.ResponseWriter): Context - } - interface Echo { - /** - * Router returns the default router. - */ - router(): Router - } - interface Echo { - /** - * Routers returns the map of host => router. - */ - routers(): _TygojaDict - } - interface Echo { - /** - * RouterFor returns Router for given host. - */ - routerFor(host: string): Router - } - interface Echo { - /** - * ResetRouterCreator resets callback for creating new router instances. - * Note: current (default) router is immediately replaced with router created with creator func and vhost routers are cleared. - */ - resetRouterCreator(creator: (e: Echo) => Router): void - } - interface Echo { - /** - * Pre adds middleware to the chain which is run before router tries to find matching route. - * Meaning middleware is executed even for 404 (not found) cases. - */ - pre(...middleware: MiddlewareFunc[]): void - } - interface Echo { - /** - * Use adds middleware to the chain which is run after router has found matching route and before route/request handler method is executed. - */ - use(...middleware: MiddlewareFunc[]): void - } - interface Echo { - /** - * CONNECT registers a new CONNECT route for a path with matching handler in the - * router with optional route-level middleware. Panics on error. - */ - connect(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo - } - interface Echo { - /** - * DELETE registers a new DELETE route for a path with matching handler in the router - * with optional route-level middleware. Panics on error. - */ - delete(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo - } - interface Echo { - /** - * GET registers a new GET route for a path with matching handler in the router - * with optional route-level middleware. Panics on error. - */ - get(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo - } - interface Echo { - /** - * HEAD registers a new HEAD route for a path with matching handler in the - * router with optional route-level middleware. Panics on error. - */ - head(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo - } - interface Echo { - /** - * OPTIONS registers a new OPTIONS route for a path with matching handler in the - * router with optional route-level middleware. Panics on error. - */ - options(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo - } - interface Echo { - /** - * PATCH registers a new PATCH route for a path with matching handler in the - * router with optional route-level middleware. Panics on error. - */ - patch(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo - } - interface Echo { - /** - * POST registers a new POST route for a path with matching handler in the - * router with optional route-level middleware. Panics on error. - */ - post(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo - } - interface Echo { - /** - * PUT registers a new PUT route for a path with matching handler in the - * router with optional route-level middleware. Panics on error. - */ - put(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo - } - interface Echo { - /** - * TRACE registers a new TRACE route for a path with matching handler in the - * router with optional route-level middleware. Panics on error. - */ - trace(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo - } - interface Echo { - /** - * RouteNotFound registers a special-case route which is executed when no other route is found (i.e. HTTP 404 cases) - * for current request URL. - * Path supports static and named/any parameters just like other http method is defined. Generally path is ended with - * wildcard/match-any character (`/*`, `/download/*` etc). - * - * Example: `e.RouteNotFound("/*", func(c echo.Context) error { return c.NoContent(http.StatusNotFound) })` - */ - routeNotFound(path: string, h: HandlerFunc, ...m: MiddlewareFunc[]): RouteInfo - } - interface Echo { - /** - * Any registers a new route for all supported HTTP methods and path with matching handler - * in the router with optional route-level middleware. Panics on error. - */ - any(path: string, handler: HandlerFunc, ...middleware: MiddlewareFunc[]): Routes - } - interface Echo { - /** - * Match registers a new route for multiple HTTP methods and path with matching - * handler in the router with optional route-level middleware. Panics on error. - */ - match(methods: Array, path: string, handler: HandlerFunc, ...middleware: MiddlewareFunc[]): Routes - } - interface Echo { - /** - * Static registers a new route with path prefix to serve static files from the provided root directory. - */ - static(pathPrefix: string): RouteInfo - } - interface Echo { - /** - * StaticFS registers a new route with path prefix to serve static files from the provided file system. - * - * When dealing with `embed.FS` use `fs := echo.MustSubFS(fs, "rootDirectory") to create sub fs which uses necessary - * prefix for directory path. This is necessary as `//go:embed assets/images` embeds files with paths - * including `assets/images` as their prefix. - */ - staticFS(pathPrefix: string, filesystem: fs.FS): RouteInfo - } - interface Echo { - /** - * FileFS registers a new route with path to serve file from the provided file system. - */ - fileFS(path: string, filesystem: fs.FS, ...m: MiddlewareFunc[]): RouteInfo - } - interface Echo { - /** - * File registers a new route with path to serve a static file with optional route-level middleware. Panics on error. - */ - file(path: string, ...middleware: MiddlewareFunc[]): RouteInfo - } - interface Echo { - /** - * AddRoute registers a new Route with default host Router - */ - addRoute(route: Routable): RouteInfo - } - interface Echo { - /** - * Add registers a new route for an HTTP method and path with matching handler - * in the router with optional route-level middleware. - */ - add(method: string, handler: HandlerFunc, ...middleware: MiddlewareFunc[]): RouteInfo - } - interface Echo { - /** - * Host creates a new router group for the provided host and optional host-level middleware. - */ - host(name: string, ...m: MiddlewareFunc[]): (Group | undefined) - } - interface Echo { - /** - * Group creates a new router group with prefix and optional group-level middleware. - */ - group(prefix: string, ...m: MiddlewareFunc[]): (Group | undefined) - } - interface Echo { - /** - * AcquireContext returns an empty `Context` instance from the pool. - * You must return the context by calling `ReleaseContext()`. - */ - acquireContext(): Context - } - interface Echo { - /** - * ReleaseContext returns the `Context` instance back to the pool. - * You must call it after `AcquireContext()`. - */ - releaseContext(c: Context): void - } - interface Echo { - /** - * ServeHTTP implements `http.Handler` interface, which serves HTTP requests. - */ - serveHTTP(w: http.ResponseWriter, r: http.Request): void - } - interface Echo { - /** - * Start stars HTTP server on given address with Echo as a handler serving requests. The server can be shutdown by - * sending os.Interrupt signal with `ctrl+c`. - * - * Note: this method is created for use in examples/demos and is deliberately simple without providing configuration - * options. - * - * In need of customization use: - * ``` - * sc := echo.StartConfig{Address: ":8080"} - * if err := sc.Start(e); err != http.ErrServerClosed { - * log.Fatal(err) - * } - * ``` - * // or standard library `http.Server` - * ``` - * s := http.Server{Addr: ":8080", Handler: e} - * if err := s.ListenAndServe(); err != http.ErrServerClosed { - * log.Fatal(err) - * } - * ``` - */ - start(address: string): void - } -} - -namespace settings { - // @ts-ignore - import validation = ozzo_validation - /** - * Settings defines common app configuration options. - */ - interface Settings { - meta: MetaConfig - logs: LogsConfig - smtp: SmtpConfig - s3: S3Config - backups: BackupsConfig - adminAuthToken: TokenConfig - adminPasswordResetToken: TokenConfig - adminFileToken: TokenConfig - recordAuthToken: TokenConfig - recordPasswordResetToken: TokenConfig - recordEmailChangeToken: TokenConfig - recordVerificationToken: TokenConfig - recordFileToken: TokenConfig - /** - * Deprecated: Will be removed in v0.9+ - */ - emailAuth: EmailAuthConfig - googleAuth: AuthProviderConfig - facebookAuth: AuthProviderConfig - githubAuth: AuthProviderConfig - gitlabAuth: AuthProviderConfig - discordAuth: AuthProviderConfig - twitterAuth: AuthProviderConfig - microsoftAuth: AuthProviderConfig - spotifyAuth: AuthProviderConfig - kakaoAuth: AuthProviderConfig - twitchAuth: AuthProviderConfig - stravaAuth: AuthProviderConfig - giteeAuth: AuthProviderConfig - livechatAuth: AuthProviderConfig - giteaAuth: AuthProviderConfig - oidcAuth: AuthProviderConfig - oidc2Auth: AuthProviderConfig - oidc3Auth: AuthProviderConfig - appleAuth: AuthProviderConfig - instagramAuth: AuthProviderConfig - vkAuth: AuthProviderConfig - yandexAuth: AuthProviderConfig - } - interface Settings { - /** - * Validate makes Settings validatable by implementing [validation.Validatable] interface. - */ - validate(): void - } - interface Settings { - /** - * Merge merges `other` settings into the current one. - */ - merge(other: Settings): void - } - interface Settings { - /** - * Clone creates a new deep copy of the current settings. - */ - clone(): (Settings | undefined) - } - interface Settings { - /** - * RedactClone creates a new deep copy of the current settings, - * while replacing the secret values with `******`. - */ - redactClone(): (Settings | undefined) - } - interface Settings { - /** - * NamedAuthProviderConfigs returns a map with all registered OAuth2 - * provider configurations (indexed by their name identifier). - */ - namedAuthProviderConfigs(): _TygojaDict - } -} - -/** - * Package daos handles common PocketBase DB model manipulations. - * - * Think of daos as DB repository and service layer in one. - */ -namespace daos { - interface Dao { - /** - * AdminQuery returns a new Admin select query. - */ - adminQuery(): (dbx.SelectQuery | undefined) - } - interface Dao { - /** - * FindAdminById finds the admin with the provided id. - */ - findAdminById(id: string): (models.Admin | undefined) - } - interface Dao { - /** - * FindAdminByEmail finds the admin with the provided email address. - */ - findAdminByEmail(email: string): (models.Admin | undefined) - } - interface Dao { - /** - * FindAdminByToken finds the admin associated with the provided JWT token. - * - * Returns an error if the JWT token is invalid or expired. - */ - findAdminByToken(token: string, baseTokenKey: string): (models.Admin | undefined) - } - interface Dao { - /** - * TotalAdmins returns the number of existing admin records. - */ - totalAdmins(): number - } - interface Dao { - /** - * IsAdminEmailUnique checks if the provided email address is not - * already in use by other admins. - */ - isAdminEmailUnique(email: string, ...excludeIds: string[]): boolean - } - interface Dao { - /** - * DeleteAdmin deletes the provided Admin model. - * - * Returns an error if there is only 1 admin. - */ - deleteAdmin(admin: models.Admin): void - } - interface Dao { - /** - * SaveAdmin upserts the provided Admin model. - */ - saveAdmin(admin: models.Admin): void - } - /** - * Dao handles various db operations. + * Read reads up to len(p) bytes into p. It returns the number of bytes + * read (0 <= n <= len(p)) and any error encountered. Even if Read + * returns n < len(p), it may use all of p as scratch space during the call. + * If some data is available but not len(p) bytes, Read conventionally + * returns what is available instead of waiting for more. * - * You can think of Dao as a repository and service layer in one. + * When Read encounters an error or end-of-file condition after + * successfully reading n > 0 bytes, it returns the number of + * bytes read. It may return the (non-nil) error from the same call + * or return the error (and n == 0) from a subsequent call. + * An instance of this general case is that a Reader returning + * a non-zero number of bytes at the end of the input stream may + * return either err == EOF or err == nil. The next Read should + * return 0, EOF. + * + * Callers should always process the n > 0 bytes returned before + * considering the error err. Doing so correctly handles I/O errors + * that happen after reading some bytes and also both of the + * allowed EOF behaviors. + * + * Implementations of Read are discouraged from returning a + * zero byte count with a nil error, except when len(p) == 0. + * Callers should treat a return of 0 and nil as indicating that + * nothing happened; in particular it does not indicate EOF. + * + * Implementations must not retain p. */ - interface Dao { - /** - * MaxLockRetries specifies the default max "database is locked" auto retry attempts. - */ - maxLockRetries: number - /** - * ModelQueryTimeout is the default max duration of a running ModelQuery(). - * - * This field has no effect if an explicit query context is already specified. - */ - modelQueryTimeout: time.Duration - /** - * write hooks - */ - beforeCreateFunc: (eventDao: Dao, m: models.Model) => void - afterCreateFunc: (eventDao: Dao, m: models.Model) => void - beforeUpdateFunc: (eventDao: Dao, m: models.Model) => void - afterUpdateFunc: (eventDao: Dao, m: models.Model) => void - beforeDeleteFunc: (eventDao: Dao, m: models.Model) => void - afterDeleteFunc: (eventDao: Dao, m: models.Model) => void + interface Reader { + read(p: string): number } - interface Dao { - /** - * DB returns the default dao db builder (*dbx.DB or *dbx.TX). - * - * Currently the default db builder is dao.concurrentDB but that may change in the future. - */ - db(): dbx.Builder - } - interface Dao { - /** - * ConcurrentDB returns the dao concurrent (aka. multiple open connections) - * db builder (*dbx.DB or *dbx.TX). - * - * In a transaction the concurrentDB and nonconcurrentDB refer to the same *dbx.TX instance. - */ - concurrentDB(): dbx.Builder - } - interface Dao { - /** - * NonconcurrentDB returns the dao nonconcurrent (aka. single open connection) - * db builder (*dbx.DB or *dbx.TX). - * - * In a transaction the concurrentDB and nonconcurrentDB refer to the same *dbx.TX instance. - */ - nonconcurrentDB(): dbx.Builder - } - interface Dao { - /** - * Clone returns a new Dao with the same configuration options as the current one. - */ - clone(): (Dao | undefined) - } - interface Dao { - /** - * WithoutHooks returns a new Dao with the same configuration options - * as the current one, but without create/update/delete hooks. - */ - withoutHooks(): (Dao | undefined) - } - interface Dao { - /** - * ModelQuery creates a new preconfigured select query with preset - * SELECT, FROM and other common fields based on the provided model. - */ - modelQuery(m: models.Model): (dbx.SelectQuery | undefined) - } - interface Dao { - /** - * FindById finds a single db record with the specified id and - * scans the result into m. - */ - findById(m: models.Model, id: string): void - } - interface Dao { - /** - * RunInTransaction wraps fn into a transaction. - * - * It is safe to nest RunInTransaction calls as long as you use the txDao. - */ - runInTransaction(fn: (txDao: Dao) => void): void - } - interface Dao { - /** - * Delete deletes the provided model. - */ - delete(m: models.Model): void - } - interface Dao { - /** - * Save persists the provided model in the database. - * - * If m.IsNew() is true, the method will perform a create, otherwise an update. - * To explicitly mark a model for update you can use m.MarkAsNotNew(). - */ - save(m: models.Model): void - } - interface Dao { - /** - * CollectionQuery returns a new Collection select query. - */ - collectionQuery(): (dbx.SelectQuery | undefined) - } - interface Dao { - /** - * FindCollectionsByType finds all collections by the given type. - */ - findCollectionsByType(collectionType: string): Array<(models.Collection | undefined)> - } - interface Dao { - /** - * FindCollectionByNameOrId finds a single collection by its name (case insensitive) or id. - */ - findCollectionByNameOrId(nameOrId: string): (models.Collection | undefined) - } - interface Dao { - /** - * IsCollectionNameUnique checks that there is no existing collection - * with the provided name (case insensitive!). - * - * Note: case insensitive check because the name is used also as a table name for the records. - */ - isCollectionNameUnique(name: string, ...excludeIds: string[]): boolean - } - interface Dao { - /** - * FindCollectionReferences returns information for all - * relation schema fields referencing the provided collection. - * - * If the provided collection has reference to itself then it will be - * also included in the result. To exclude it, pass the collection id - * as the excludeId argument. - */ - findCollectionReferences(collection: models.Collection, ...excludeIds: string[]): _TygojaDict - } - interface Dao { - /** - * DeleteCollection deletes the provided Collection model. - * This method automatically deletes the related collection records table. - * - * NB! The collection cannot be deleted, if: - * - is system collection (aka. collection.System is true) - * - is referenced as part of a relation field in another collection - */ - deleteCollection(collection: models.Collection): void - } - interface Dao { - /** - * SaveCollection persists the provided Collection model and updates - * its related records table schema. - * - * If collecction.IsNew() is true, the method will perform a create, otherwise an update. - * To explicitly mark a collection for update you can use collecction.MarkAsNotNew(). - */ - saveCollection(collection: models.Collection): void - } - interface Dao { - /** - * ImportCollections imports the provided collections list within a single transaction. - * - * NB1! If deleteMissing is set, all local collections and schema fields, that are not present - * in the imported configuration, WILL BE DELETED (including their related records data). - * - * NB2! This method doesn't perform validations on the imported collections data! - * If you need validations, use [forms.CollectionsImport]. - */ - importCollections(importedCollections: Array<(models.Collection | undefined)>, deleteMissing: boolean, afterSync: (txDao: Dao, mappedImported: _TygojaDict) => void): void - } - interface Dao { - /** - * ExternalAuthQuery returns a new ExternalAuth select query. - */ - externalAuthQuery(): (dbx.SelectQuery | undefined) - } - interface Dao { - /** - * FindAllExternalAuthsByRecord returns all ExternalAuth models - * linked to the provided auth record. - */ - findAllExternalAuthsByRecord(authRecord: models.Record): Array<(models.ExternalAuth | undefined)> - } - interface Dao { - /** - * FindExternalAuthByProvider returns the first available - * ExternalAuth model for the specified provider and providerId. - */ - findExternalAuthByProvider(provider: string): (models.ExternalAuth | undefined) - } - interface Dao { - /** - * FindExternalAuthByRecordAndProvider returns the first available - * ExternalAuth model for the specified record data and provider. - */ - findExternalAuthByRecordAndProvider(authRecord: models.Record, provider: string): (models.ExternalAuth | undefined) - } - interface Dao { - /** - * SaveExternalAuth upserts the provided ExternalAuth model. - */ - saveExternalAuth(model: models.ExternalAuth): void - } - interface Dao { - /** - * DeleteExternalAuth deletes the provided ExternalAuth model. - */ - deleteExternalAuth(model: models.ExternalAuth): void - } - interface Dao { - /** - * ParamQuery returns a new Param select query. - */ - paramQuery(): (dbx.SelectQuery | undefined) - } - interface Dao { - /** - * FindParamByKey finds the first Param model with the provided key. - */ - findParamByKey(key: string): (models.Param | undefined) - } - interface Dao { - /** - * SaveParam creates or updates a Param model by the provided key-value pair. - * The value argument will be encoded as json string. - * - * If `optEncryptionKey` is provided it will encrypt the value before storing it. - */ - saveParam(key: string, value: any, ...optEncryptionKey: string[]): void - } - interface Dao { - /** - * DeleteParam deletes the provided Param model. - */ - deleteParam(param: models.Param): void - } - interface Dao { - /** - * RecordQuery returns a new Record select query. - */ - recordQuery(collection: models.Collection): (dbx.SelectQuery | undefined) - } - interface Dao { - /** - * FindRecordById finds the Record model by its id. - */ - findRecordById(collectionNameOrId: string, recordId: string, ...optFilters: ((q: dbx.SelectQuery) => void)[]): (models.Record | undefined) - } - interface Dao { - /** - * FindRecordsByIds finds all Record models by the provided ids. - * If no records are found, returns an empty slice. - */ - findRecordsByIds(collectionNameOrId: string, recordIds: Array, ...optFilters: ((q: dbx.SelectQuery) => void)[]): Array<(models.Record | undefined)> - } - interface Dao { - /** - * FindRecordsByExpr finds all records by the specified db expression. - * - * Returns all collection records if no expressions are provided. - * - * Returns an empty slice if no records are found. - * - * Example: - * - * ``` - * expr1 := dbx.HashExp{"email": "test@example.com"} - * expr2 := dbx.NewExp("LOWER(username) = {:username}", dbx.Params{"username": "test"}) - * dao.FindRecordsByExpr("example", expr1, expr2) - * ``` - */ - findRecordsByExpr(collectionNameOrId: string, ...exprs: dbx.Expression[]): Array<(models.Record | undefined)> - } - interface Dao { - /** - * FindFirstRecordByData returns the first found record matching - * the provided key-value pair. - */ - findFirstRecordByData(collectionNameOrId: string, key: string, value: any): (models.Record | undefined) - } - interface Dao { - /** - * FindRecordsByFilter returns limit number of records matching the - * provided string filter. - * - * The sort argument is optional and can be empty string OR the same format - * used in the web APIs, eg. "-created,title". - * - * If the limit argument is <= 0, no limit is applied to the query and - * all matching records are returned. - * - * NB Don't put untrusted user input in the filter string as it - * practically would allow the users to inject their own custom filter. - * - * Example: - * - * ``` - * dao.FindRecordsByFilter("posts", "title ~ 'lorem ipsum' && visible = true", "-created", 10) - * ``` - */ - findRecordsByFilter(collectionNameOrId: string, filter: string, sort: string, limit: number): Array<(models.Record | undefined)> - } - interface Dao { - /** - * FindFirstRecordByFilter returns the first available record matching the provided filter. - * - * NB Don't put untrusted user input in the filter string as it - * practically would allow the users to inject their own custom filter. - * - * Example: - * - * ``` - * dao.FindFirstRecordByFilter("posts", "slug='test'") - * ``` - */ - findFirstRecordByFilter(collectionNameOrId: string, filter: string): (models.Record | undefined) - } - interface Dao { - /** - * IsRecordValueUnique checks if the provided key-value pair is a unique Record value. - * - * For correctness, if the collection is "auth" and the key is "username", - * the unique check will be case insensitive. - * - * NB! Array values (eg. from multiple select fields) are matched - * as a serialized json strings (eg. `["a","b"]`), so the value uniqueness - * depends on the elements order. Or in other words the following values - * are considered different: `[]string{"a","b"}` and `[]string{"b","a"}` - */ - isRecordValueUnique(collectionNameOrId: string, key: string, value: any, ...excludeIds: string[]): boolean - } - interface Dao { - /** - * FindAuthRecordByToken finds the auth record associated with the provided JWT token. - * - * Returns an error if the JWT token is invalid, expired or not associated to an auth collection record. - */ - findAuthRecordByToken(token: string, baseTokenKey: string): (models.Record | undefined) - } - interface Dao { - /** - * FindAuthRecordByEmail finds the auth record associated with the provided email. - * - * Returns an error if it is not an auth collection or the record is not found. - */ - findAuthRecordByEmail(collectionNameOrId: string, email: string): (models.Record | undefined) - } - interface Dao { - /** - * FindAuthRecordByUsername finds the auth record associated with the provided username (case insensitive). - * - * Returns an error if it is not an auth collection or the record is not found. - */ - findAuthRecordByUsername(collectionNameOrId: string, username: string): (models.Record | undefined) - } - interface Dao { - /** - * SuggestUniqueAuthRecordUsername checks if the provided username is unique - * and return a new "unique" username with appended random numeric part - * (eg. "existingName" -> "existingName583"). - * - * The same username will be returned if the provided string is already unique. - */ - suggestUniqueAuthRecordUsername(collectionNameOrId: string, baseUsername: string, ...excludeIds: string[]): string - } - interface Dao { - /** - * CanAccessRecord checks if a record is allowed to be accessed by the - * specified requestData and accessRule. - * - * Always return false on invalid access rule or db error. - * - * Example: - * - * ``` - * requestData := apis.RequestData(c /* echo.Context *\/) - * record, _ := dao.FindRecordById("example", "RECORD_ID") - * // custom rule - * // or use one of the record collection's, eg. record.Collection().ViewRule - * rule := types.Pointer("@request.auth.id != '' || status = 'public'") - * - * canAccess := dao.CanAccessRecord(record, requestData, rule) - * ``` - */ - canAccessRecord(record: models.Record, requestData: models.RequestData, accessRule: string): boolean - } - interface Dao { - /** - * SaveRecord persists the provided Record model in the database. - * - * If record.IsNew() is true, the method will perform a create, otherwise an update. - * To explicitly mark a record for update you can use record.MarkAsNotNew(). - */ - saveRecord(record: models.Record): void - } - interface Dao { - /** - * DeleteRecord deletes the provided Record model. - * - * This method will also cascade the delete operation to all linked - * relational records (delete or unset, depending on the rel settings). - * - * The delete operation may fail if the record is part of a required - * reference in another record (aka. cannot be deleted or unset). - */ - deleteRecord(record: models.Record): void - } - interface Dao { - /** - * ExpandRecord expands the relations of a single Record model. - * - * Returns a map with the failed expand parameters and their errors. - */ - expandRecord(record: models.Record, expands: Array, fetchFunc: ExpandFetchFunc): _TygojaDict - } - interface Dao { - /** - * ExpandRecords expands the relations of the provided Record models list. - * - * Returns a map with the failed expand parameters and their errors. - */ - expandRecords(records: Array<(models.Record | undefined)>, expands: Array, fetchFunc: ExpandFetchFunc): _TygojaDict - } - // @ts-ignore - import validation = ozzo_validation - interface Dao { - /** - * SyncRecordTableSchema compares the two provided collections - * and applies the necessary related record table changes. - * - * If `oldCollection` is null, then only `newCollection` is used to create the record table. - */ - syncRecordTableSchema(newCollection: models.Collection, oldCollection: models.Collection): void - } - interface Dao { - /** - * RequestQuery returns a new Request logs select query. - */ - requestQuery(): (dbx.SelectQuery | undefined) - } - interface Dao { - /** - * FindRequestById finds a single Request log by its id. - */ - findRequestById(id: string): (models.Request | undefined) - } - interface Dao { - /** - * RequestsStats returns hourly grouped requests logs statistics. - */ - requestsStats(expr: dbx.Expression): Array<(RequestsStatsItem | undefined)> - } - interface Dao { - /** - * DeleteOldRequests delete all requests that are created before createdBefore. - */ - deleteOldRequests(createdBefore: time.Time): void - } - interface Dao { - /** - * SaveRequest upserts the provided Request model. - */ - saveRequest(request: models.Request): void - } - interface Dao { - /** - * FindSettings returns and decode the serialized app settings param value. - * - * The method will first try to decode the param value without decryption. - * If it fails and optEncryptionKey is set, it will try again by first - * decrypting the value and then decode it again. - * - * Returns an error if it fails to decode the stored serialized param value. - */ - findSettings(...optEncryptionKey: string[]): (settings.Settings | undefined) - } - interface Dao { - /** - * SaveSettings persists the specified settings configuration. - * - * If optEncryptionKey is set, then the stored serialized value will be encrypted with it. - */ - saveSettings(newSettings: settings.Settings, ...optEncryptionKey: string[]): void - } - interface Dao { - /** - * HasTable checks if a table (or view) with the provided name exists (case insensitive). - */ - hasTable(tableName: string): boolean - } - interface Dao { - /** - * TableColumns returns all column names of a single table by its name. - */ - tableColumns(tableName: string): Array - } - interface Dao { - /** - * TableInfo returns the `table_info` pragma result for the specified table. - */ - tableInfo(tableName: string): Array<(models.TableInfoRow | undefined)> - } - interface Dao { - /** - * TableIndexes returns a name grouped map with all non empty index of the specified table. - * - * Note: This method doesn't return an error on nonexisting table. - */ - tableIndexes(tableName: string): _TygojaDict - } - interface Dao { - /** - * DeleteTable drops the specified table. - * - * This method is a no-op if a table with the provided name doesn't exist. - * - * Be aware that this method is vulnerable to SQL injection and the - * "tableName" argument must come only from trusted input! - */ - deleteTable(tableName: string): void - } - interface Dao { - /** - * Vacuum executes VACUUM on the current dao.DB() instance in order to - * reclaim unused db disk space. - */ - vacuum(): void - } - interface Dao { - /** - * DeleteView drops the specified view name. - * - * This method is a no-op if a view with the provided name doesn't exist. - * - * Be aware that this method is vulnerable to SQL injection and the - * "name" argument must come only from trusted input! - */ - deleteView(name: string): void - } - interface Dao { - /** - * SaveView creates (or updates already existing) persistent SQL view. - * - * Be aware that this method is vulnerable to SQL injection and the - * "selectQuery" argument must come only from trusted input! - */ - saveView(name: string, selectQuery: string): void - } - interface Dao { - /** - * CreateViewSchema creates a new view schema from the provided select query. - * - * There are some caveats: - * - The select query must have an "id" column. - * - Wildcard ("*") columns are not supported to avoid accidentally leaking sensitive data. - */ - createViewSchema(selectQuery: string): schema.Schema - } - interface Dao { - /** - * FindRecordByViewFile returns the original models.Record of the - * provided view collection file. - */ - findRecordByViewFile(viewCollectionNameOrId: string, fileFieldName: string, filename: string): (models.Record | undefined) - } -} - -/** - * Package core is the backbone of PocketBase. - * - * It defines the main PocketBase App interface and its base implementation. - */ -namespace core { /** - * App defines the main PocketBase app interface. + * Writer is the interface that wraps the basic Write method. + * + * Write writes len(p) bytes from p to the underlying data stream. + * It returns the number of bytes written from p (0 <= n <= len(p)) + * and any error encountered that caused the write to stop early. + * Write must return a non-nil error if it returns n < len(p). + * Write must not modify the slice data, even temporarily. + * + * Implementations must not retain p. */ - interface App { - /** - * Deprecated: - * This method may get removed in the near future. - * It is recommended to access the app db instance from app.Dao().DB() or - * if you want more flexibility - app.Dao().ConcurrentDB() and app.Dao().NonconcurrentDB(). - * - * DB returns the default app database instance. - */ - db(): (dbx.DB | undefined) - /** - * Dao returns the default app Dao instance. - * - * This Dao could operate only on the tables and models - * associated with the default app database. For example, - * trying to access the request logs table will result in error. - */ - dao(): (daos.Dao | undefined) - /** - * Deprecated: - * This method may get removed in the near future. - * It is recommended to access the logs db instance from app.LogsDao().DB() or - * if you want more flexibility - app.LogsDao().ConcurrentDB() and app.LogsDao().NonconcurrentDB(). - * - * LogsDB returns the app logs database instance. - */ - logsDB(): (dbx.DB | undefined) - /** - * LogsDao returns the app logs Dao instance. - * - * This Dao could operate only on the tables and models - * associated with the logs database. For example, trying to access - * the users table from LogsDao will result in error. - */ - logsDao(): (daos.Dao | undefined) - /** - * DataDir returns the app data directory path. - */ - dataDir(): string - /** - * EncryptionEnv returns the name of the app secret env key - * (used for settings encryption). - */ - encryptionEnv(): string - /** - * IsDebug returns whether the app is in debug mode - * (showing more detailed error logs, executed sql statements, etc.). - */ - isDebug(): boolean - /** - * Settings returns the loaded app settings. - */ - settings(): (settings.Settings | undefined) - /** - * Cache returns the app internal cache store. - */ - cache(): (store.Store | undefined) - /** - * SubscriptionsBroker returns the app realtime subscriptions broker instance. - */ - subscriptionsBroker(): (subscriptions.Broker | undefined) - /** - * NewMailClient creates and returns a configured app mail client. - */ - newMailClient(): mailer.Mailer - /** - * NewFilesystem creates and returns a configured filesystem.System instance - * for managing regular app files (eg. collection uploads). - * - * NB! Make sure to call Close() on the returned result - * after you are done working with it. - */ - newFilesystem(): (filesystem.System | undefined) - /** - * NewBackupsFilesystem creates and returns a configured filesystem.System instance - * for managing app backups. - * - * NB! Make sure to call Close() on the returned result - * after you are done working with it. - */ - newBackupsFilesystem(): (filesystem.System | undefined) - /** - * RefreshSettings reinitializes and reloads the stored application settings. - */ - refreshSettings(): void - /** - * IsBootstrapped checks if the application was initialized - * (aka. whether Bootstrap() was called). - */ - isBootstrapped(): boolean - /** - * Bootstrap takes care for initializing the application - * (open db connections, load settings, etc.). - * - * It will call ResetBootstrapState() if the application was already bootstrapped. - */ - bootstrap(): void - /** - * ResetBootstrapState takes care for releasing initialized app resources - * (eg. closing db connections). - */ - resetBootstrapState(): void - /** - * CreateBackup creates a new backup of the current app pb_data directory. - * - * Backups can be stored on S3 if it is configured in app.Settings().Backups. - * - * Please refer to the godoc of the specific core.App implementation - * for details on the backup procedures. - */ - createBackup(ctx: context.Context, name: string): void - /** - * RestoreBackup restores the backup with the specified name and restarts - * the current running application process. - * - * The safely perform the restore it is recommended to have free disk space - * for at least 2x the size of the restored pb_data backup. - * - * Please refer to the godoc of the specific core.App implementation - * for details on the restore procedures. - * - * NB! This feature is experimental and currently is expected to work only on UNIX based systems. - */ - restoreBackup(ctx: context.Context, name: string): void - /** - * Restart restarts the current running application process. - * - * Currently it is relying on execve so it is supported only on UNIX based systems. - */ - restart(): void - /** - * OnBeforeBootstrap hook is triggered before initializing the main - * application resources (eg. before db open and initial settings load). - */ - onBeforeBootstrap(): (hook.Hook | undefined) - /** - * OnAfterBootstrap hook is triggered after initializing the main - * application resources (eg. after db open and initial settings load). - */ - onAfterBootstrap(): (hook.Hook | undefined) - /** - * OnBeforeServe hook is triggered before serving the internal router (echo), - * allowing you to adjust its options and attach new routes or middlewares. - */ - onBeforeServe(): (hook.Hook | undefined) - /** - * OnBeforeApiError hook is triggered right before sending an error API - * response to the client, allowing you to further modify the error data - * or to return a completely different API response. - */ - onBeforeApiError(): (hook.Hook | undefined) - /** - * OnAfterApiError hook is triggered right after sending an error API - * response to the client. - * It could be used to log the final API error in external services. - */ - onAfterApiError(): (hook.Hook | undefined) - /** - * OnTerminate hook is triggered when the app is in the process - * of being terminated (eg. on SIGTERM signal). - */ - onTerminate(): (hook.Hook | undefined) - /** - * OnModelBeforeCreate hook is triggered before inserting a new - * entry in the DB, allowing you to modify or validate the stored data. - * - * If the optional "tags" list (table names and/or the Collection id for Record models) - * is specified, then all event handlers registered via the created hook - * will be triggered and called only if their event data origin matches the tags. - */ - onModelBeforeCreate(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnModelAfterCreate hook is triggered after successfully - * inserting a new entry in the DB. - * - * If the optional "tags" list (table names and/or the Collection id for Record models) - * is specified, then all event handlers registered via the created hook - * will be triggered and called only if their event data origin matches the tags. - */ - onModelAfterCreate(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnModelBeforeUpdate hook is triggered before updating existing - * entry in the DB, allowing you to modify or validate the stored data. - * - * If the optional "tags" list (table names and/or the Collection id for Record models) - * is specified, then all event handlers registered via the created hook - * will be triggered and called only if their event data origin matches the tags. - */ - onModelBeforeUpdate(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnModelAfterUpdate hook is triggered after successfully updating - * existing entry in the DB. - * - * If the optional "tags" list (table names and/or the Collection id for Record models) - * is specified, then all event handlers registered via the created hook - * will be triggered and called only if their event data origin matches the tags. - */ - onModelAfterUpdate(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnModelBeforeDelete hook is triggered before deleting an - * existing entry from the DB. - * - * If the optional "tags" list (table names and/or the Collection id for Record models) - * is specified, then all event handlers registered via the created hook - * will be triggered and called only if their event data origin matches the tags. - */ - onModelBeforeDelete(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnModelAfterDelete hook is triggered after successfully deleting an - * existing entry from the DB. - * - * If the optional "tags" list (table names and/or the Collection id for Record models) - * is specified, then all event handlers registered via the created hook - * will be triggered and called only if their event data origin matches the tags. - */ - onModelAfterDelete(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnMailerBeforeAdminResetPasswordSend hook is triggered right - * before sending a password reset email to an admin, allowing you - * to inspect and customize the email message that is being sent. - */ - onMailerBeforeAdminResetPasswordSend(): (hook.Hook | undefined) - /** - * OnMailerAfterAdminResetPasswordSend hook is triggered after - * admin password reset email was successfully sent. - */ - onMailerAfterAdminResetPasswordSend(): (hook.Hook | undefined) - /** - * OnMailerBeforeRecordResetPasswordSend hook is triggered right - * before sending a password reset email to an auth record, allowing - * you to inspect and customize the email message that is being sent. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onMailerBeforeRecordResetPasswordSend(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnMailerAfterRecordResetPasswordSend hook is triggered after - * an auth record password reset email was successfully sent. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onMailerAfterRecordResetPasswordSend(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnMailerBeforeRecordVerificationSend hook is triggered right - * before sending a verification email to an auth record, allowing - * you to inspect and customize the email message that is being sent. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onMailerBeforeRecordVerificationSend(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnMailerAfterRecordVerificationSend hook is triggered after a - * verification email was successfully sent to an auth record. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onMailerAfterRecordVerificationSend(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnMailerBeforeRecordChangeEmailSend hook is triggered right before - * sending a confirmation new address email to an auth record, allowing - * you to inspect and customize the email message that is being sent. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onMailerBeforeRecordChangeEmailSend(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnMailerAfterRecordChangeEmailSend hook is triggered after a - * verification email was successfully sent to an auth record. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onMailerAfterRecordChangeEmailSend(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRealtimeConnectRequest hook is triggered right before establishing - * the SSE client connection. - */ - onRealtimeConnectRequest(): (hook.Hook | undefined) - /** - * OnRealtimeDisconnectRequest hook is triggered on disconnected/interrupted - * SSE client connection. - */ - onRealtimeDisconnectRequest(): (hook.Hook | undefined) - /** - * OnRealtimeBeforeMessage hook is triggered right before sending - * an SSE message to a client. - * - * Returning [hook.StopPropagation] will prevent sending the message. - * Returning any other non-nil error will close the realtime connection. - */ - onRealtimeBeforeMessageSend(): (hook.Hook | undefined) - /** - * OnRealtimeBeforeMessage hook is triggered right after sending - * an SSE message to a client. - */ - onRealtimeAfterMessageSend(): (hook.Hook | undefined) - /** - * OnRealtimeBeforeSubscribeRequest hook is triggered before changing - * the client subscriptions, allowing you to further validate and - * modify the submitted change. - */ - onRealtimeBeforeSubscribeRequest(): (hook.Hook | undefined) - /** - * OnRealtimeAfterSubscribeRequest hook is triggered after the client - * subscriptions were successfully changed. - */ - onRealtimeAfterSubscribeRequest(): (hook.Hook | undefined) - /** - * OnSettingsListRequest hook is triggered on each successful - * API Settings list request. - * - * Could be used to validate or modify the response before - * returning it to the client. - */ - onSettingsListRequest(): (hook.Hook | undefined) - /** - * OnSettingsBeforeUpdateRequest hook is triggered before each API - * Settings update request (after request data load and before settings persistence). - * - * Could be used to additionally validate the request data or - * implement completely different persistence behavior. - */ - onSettingsBeforeUpdateRequest(): (hook.Hook | undefined) - /** - * OnSettingsAfterUpdateRequest hook is triggered after each - * successful API Settings update request. - */ - onSettingsAfterUpdateRequest(): (hook.Hook | undefined) - /** - * OnFileDownloadRequest hook is triggered before each API File download request. - * - * Could be used to validate or modify the file response before - * returning it to the client. - */ - onFileDownloadRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnFileBeforeTokenRequest hook is triggered before each file - * token API request. - * - * If no token or model was submitted, e.Model and e.Token will be empty, - * allowing you to implement your own custom model file auth implementation. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onFileBeforeTokenRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnFileAfterTokenRequest hook is triggered after each - * successful file token API request. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onFileAfterTokenRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnAdminsListRequest hook is triggered on each API Admins list request. - * - * Could be used to validate or modify the response before returning it to the client. - */ - onAdminsListRequest(): (hook.Hook | undefined) - /** - * OnAdminViewRequest hook is triggered on each API Admin view request. - * - * Could be used to validate or modify the response before returning it to the client. - */ - onAdminViewRequest(): (hook.Hook | undefined) - /** - * OnAdminBeforeCreateRequest hook is triggered before each API - * Admin create request (after request data load and before model persistence). - * - * Could be used to additionally validate the request data or implement - * completely different persistence behavior. - */ - onAdminBeforeCreateRequest(): (hook.Hook | undefined) - /** - * OnAdminAfterCreateRequest hook is triggered after each - * successful API Admin create request. - */ - onAdminAfterCreateRequest(): (hook.Hook | undefined) - /** - * OnAdminBeforeUpdateRequest hook is triggered before each API - * Admin update request (after request data load and before model persistence). - * - * Could be used to additionally validate the request data or implement - * completely different persistence behavior. - */ - onAdminBeforeUpdateRequest(): (hook.Hook | undefined) - /** - * OnAdminAfterUpdateRequest hook is triggered after each - * successful API Admin update request. - */ - onAdminAfterUpdateRequest(): (hook.Hook | undefined) - /** - * OnAdminBeforeDeleteRequest hook is triggered before each API - * Admin delete request (after model load and before actual deletion). - * - * Could be used to additionally validate the request data or implement - * completely different delete behavior. - */ - onAdminBeforeDeleteRequest(): (hook.Hook | undefined) - /** - * OnAdminAfterDeleteRequest hook is triggered after each - * successful API Admin delete request. - */ - onAdminAfterDeleteRequest(): (hook.Hook | undefined) - /** - * OnAdminAuthRequest hook is triggered on each successful API Admin - * authentication request (sign-in, token refresh, etc.). - * - * Could be used to additionally validate or modify the - * authenticated admin data and token. - */ - onAdminAuthRequest(): (hook.Hook | undefined) - /** - * OnAdminBeforeAuthWithPasswordRequest hook is triggered before each Admin - * auth with password API request (after request data load and before password validation). - * - * Could be used to implement for example a custom password validation - * or to locate a different Admin identity (by assigning [AdminAuthWithPasswordEvent.Admin]). - */ - onAdminBeforeAuthWithPasswordRequest(): (hook.Hook | undefined) - /** - * OnAdminAfterAuthWithPasswordRequest hook is triggered after each - * successful Admin auth with password API request. - */ - onAdminAfterAuthWithPasswordRequest(): (hook.Hook | undefined) - /** - * OnAdminBeforeAuthRefreshRequest hook is triggered before each Admin - * auth refresh API request (right before generating a new auth token). - * - * Could be used to additionally validate the request data or implement - * completely different auth refresh behavior. - */ - onAdminBeforeAuthRefreshRequest(): (hook.Hook | undefined) - /** - * OnAdminAfterAuthRefreshRequest hook is triggered after each - * successful auth refresh API request (right after generating a new auth token). - */ - onAdminAfterAuthRefreshRequest(): (hook.Hook | undefined) - /** - * OnAdminBeforeRequestPasswordResetRequest hook is triggered before each Admin - * request password reset API request (after request data load and before sending the reset email). - * - * Could be used to additionally validate the request data or implement - * completely different password reset behavior. - */ - onAdminBeforeRequestPasswordResetRequest(): (hook.Hook | undefined) - /** - * OnAdminAfterRequestPasswordResetRequest hook is triggered after each - * successful request password reset API request. - */ - onAdminAfterRequestPasswordResetRequest(): (hook.Hook | undefined) - /** - * OnAdminBeforeConfirmPasswordResetRequest hook is triggered before each Admin - * confirm password reset API request (after request data load and before persistence). - * - * Could be used to additionally validate the request data or implement - * completely different persistence behavior. - */ - onAdminBeforeConfirmPasswordResetRequest(): (hook.Hook | undefined) - /** - * OnAdminAfterConfirmPasswordResetRequest hook is triggered after each - * successful confirm password reset API request. - */ - onAdminAfterConfirmPasswordResetRequest(): (hook.Hook | undefined) - /** - * OnRecordAuthRequest hook is triggered on each successful API - * record authentication request (sign-in, token refresh, etc.). - * - * Could be used to additionally validate or modify the authenticated - * record data and token. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordAuthRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordBeforeAuthWithPasswordRequest hook is triggered before each Record - * auth with password API request (after request data load and before password validation). - * - * Could be used to implement for example a custom password validation - * or to locate a different Record model (by reassigning [RecordAuthWithPasswordEvent.Record]). - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordBeforeAuthWithPasswordRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordAfterAuthWithPasswordRequest hook is triggered after each - * successful Record auth with password API request. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordAfterAuthWithPasswordRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordBeforeAuthWithOAuth2Request hook is triggered before each Record - * OAuth2 sign-in/sign-up API request (after token exchange and before external provider linking). - * - * If the [RecordAuthWithOAuth2Event.Record] is not set, then the OAuth2 - * request will try to create a new auth Record. - * - * To assign or link a different existing record model you can - * change the [RecordAuthWithOAuth2Event.Record] field. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordBeforeAuthWithOAuth2Request(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordAfterAuthWithOAuth2Request hook is triggered after each - * successful Record OAuth2 API request. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordAfterAuthWithOAuth2Request(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordBeforeAuthRefreshRequest hook is triggered before each Record - * auth refresh API request (right before generating a new auth token). - * - * Could be used to additionally validate the request data or implement - * completely different auth refresh behavior. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordBeforeAuthRefreshRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordAfterAuthRefreshRequest hook is triggered after each - * successful auth refresh API request (right after generating a new auth token). - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordAfterAuthRefreshRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordListExternalAuthsRequest hook is triggered on each API record external auths list request. - * - * Could be used to validate or modify the response before returning it to the client. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordListExternalAuthsRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordBeforeUnlinkExternalAuthRequest hook is triggered before each API record - * external auth unlink request (after models load and before the actual relation deletion). - * - * Could be used to additionally validate the request data or implement - * completely different delete behavior. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordBeforeUnlinkExternalAuthRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordAfterUnlinkExternalAuthRequest hook is triggered after each - * successful API record external auth unlink request. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordAfterUnlinkExternalAuthRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordBeforeRequestPasswordResetRequest hook is triggered before each Record - * request password reset API request (after request data load and before sending the reset email). - * - * Could be used to additionally validate the request data or implement - * completely different password reset behavior. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordBeforeRequestPasswordResetRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordAfterRequestPasswordResetRequest hook is triggered after each - * successful request password reset API request. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordAfterRequestPasswordResetRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordBeforeConfirmPasswordResetRequest hook is triggered before each Record - * confirm password reset API request (after request data load and before persistence). - * - * Could be used to additionally validate the request data or implement - * completely different persistence behavior. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordBeforeConfirmPasswordResetRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordAfterConfirmPasswordResetRequest hook is triggered after each - * successful confirm password reset API request. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordAfterConfirmPasswordResetRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordBeforeRequestVerificationRequest hook is triggered before each Record - * request verification API request (after request data load and before sending the verification email). - * - * Could be used to additionally validate the loaded request data or implement - * completely different verification behavior. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordBeforeRequestVerificationRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordAfterRequestVerificationRequest hook is triggered after each - * successful request verification API request. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordAfterRequestVerificationRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordBeforeConfirmVerificationRequest hook is triggered before each Record - * confirm verification API request (after request data load and before persistence). - * - * Could be used to additionally validate the request data or implement - * completely different persistence behavior. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordBeforeConfirmVerificationRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordAfterConfirmVerificationRequest hook is triggered after each - * successful confirm verification API request. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordAfterConfirmVerificationRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordBeforeRequestEmailChangeRequest hook is triggered before each Record request email change API request - * (after request data load and before sending the email link to confirm the change). - * - * Could be used to additionally validate the request data or implement - * completely different request email change behavior. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordBeforeRequestEmailChangeRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordAfterRequestEmailChangeRequest hook is triggered after each - * successful request email change API request. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordAfterRequestEmailChangeRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordBeforeConfirmEmailChangeRequest hook is triggered before each Record - * confirm email change API request (after request data load and before persistence). - * - * Could be used to additionally validate the request data or implement - * completely different persistence behavior. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordBeforeConfirmEmailChangeRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordAfterConfirmEmailChangeRequest hook is triggered after each - * successful confirm email change API request. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordAfterConfirmEmailChangeRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordsListRequest hook is triggered on each API Records list request. - * - * Could be used to validate or modify the response before returning it to the client. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordsListRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordViewRequest hook is triggered on each API Record view request. - * - * Could be used to validate or modify the response before returning it to the client. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordViewRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordBeforeCreateRequest hook is triggered before each API Record - * create request (after request data load and before model persistence). - * - * Could be used to additionally validate the request data or implement - * completely different persistence behavior. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordBeforeCreateRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordAfterCreateRequest hook is triggered after each - * successful API Record create request. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordAfterCreateRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordBeforeUpdateRequest hook is triggered before each API Record - * update request (after request data load and before model persistence). - * - * Could be used to additionally validate the request data or implement - * completely different persistence behavior. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordBeforeUpdateRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordAfterUpdateRequest hook is triggered after each - * successful API Record update request. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordAfterUpdateRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordBeforeDeleteRequest hook is triggered before each API Record - * delete request (after model load and before actual deletion). - * - * Could be used to additionally validate the request data or implement - * completely different delete behavior. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordBeforeDeleteRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnRecordAfterDeleteRequest hook is triggered after each - * successful API Record delete request. - * - * If the optional "tags" list (Collection ids or names) is specified, - * then all event handlers registered via the created hook will be - * triggered and called only if their event data origin matches the tags. - */ - onRecordAfterDeleteRequest(...tags: string[]): (hook.TaggedHook | undefined) - /** - * OnCollectionsListRequest hook is triggered on each API Collections list request. - * - * Could be used to validate or modify the response before returning it to the client. - */ - onCollectionsListRequest(): (hook.Hook | undefined) - /** - * OnCollectionViewRequest hook is triggered on each API Collection view request. - * - * Could be used to validate or modify the response before returning it to the client. - */ - onCollectionViewRequest(): (hook.Hook | undefined) - /** - * OnCollectionBeforeCreateRequest hook is triggered before each API Collection - * create request (after request data load and before model persistence). - * - * Could be used to additionally validate the request data or implement - * completely different persistence behavior. - */ - onCollectionBeforeCreateRequest(): (hook.Hook | undefined) - /** - * OnCollectionAfterCreateRequest hook is triggered after each - * successful API Collection create request. - */ - onCollectionAfterCreateRequest(): (hook.Hook | undefined) - /** - * OnCollectionBeforeUpdateRequest hook is triggered before each API Collection - * update request (after request data load and before model persistence). - * - * Could be used to additionally validate the request data or implement - * completely different persistence behavior. - */ - onCollectionBeforeUpdateRequest(): (hook.Hook | undefined) - /** - * OnCollectionAfterUpdateRequest hook is triggered after each - * successful API Collection update request. - */ - onCollectionAfterUpdateRequest(): (hook.Hook | undefined) - /** - * OnCollectionBeforeDeleteRequest hook is triggered before each API - * Collection delete request (after model load and before actual deletion). - * - * Could be used to additionally validate the request data or implement - * completely different delete behavior. - */ - onCollectionBeforeDeleteRequest(): (hook.Hook | undefined) - /** - * OnCollectionAfterDeleteRequest hook is triggered after each - * successful API Collection delete request. - */ - onCollectionAfterDeleteRequest(): (hook.Hook | undefined) - /** - * OnCollectionsBeforeImportRequest hook is triggered before each API - * collections import request (after request data load and before the actual import). - * - * Could be used to additionally validate the imported collections or - * to implement completely different import behavior. - */ - onCollectionsBeforeImportRequest(): (hook.Hook | undefined) - /** - * OnCollectionsAfterImportRequest hook is triggered after each - * successful API collections import request. - */ - onCollectionsAfterImportRequest(): (hook.Hook | undefined) + interface Writer { + write(p: string): number } -} - -namespace migrate { /** - * MigrationsList defines a list with migration definitions + * ReadCloser is the interface that groups the basic Read and Close methods. */ - interface MigrationsList { - } - interface MigrationsList { - /** - * Item returns a single migration from the list by its index. - */ - item(index: number): (Migration | undefined) - } - interface MigrationsList { - /** - * Items returns the internal migrations list slice. - */ - items(): Array<(Migration | undefined)> - } - interface MigrationsList { - /** - * Register adds new migration definition to the list. - * - * If `optFilename` is not provided, it will try to get the name from its .go file. - * - * The list will be sorted automatically based on the migrations file name. - */ - register(up: (db: dbx.Builder) => void, down: (db: dbx.Builder) => void, ...optFilename: string[]): void + interface ReadCloser { } } @@ -11063,71 +11155,6 @@ namespace time { namespace context { } -/** - * Package io provides basic interfaces to I/O primitives. - * Its primary job is to wrap existing implementations of such primitives, - * such as those in package os, into shared public interfaces that - * abstract the functionality, plus some other related primitives. - * - * Because these interfaces and primitives wrap lower-level operations with - * various implementations, unless otherwise informed clients should not - * assume they are safe for parallel execution. - */ -namespace io { - /** - * Reader is the interface that wraps the basic Read method. - * - * Read reads up to len(p) bytes into p. It returns the number of bytes - * read (0 <= n <= len(p)) and any error encountered. Even if Read - * returns n < len(p), it may use all of p as scratch space during the call. - * If some data is available but not len(p) bytes, Read conventionally - * returns what is available instead of waiting for more. - * - * When Read encounters an error or end-of-file condition after - * successfully reading n > 0 bytes, it returns the number of - * bytes read. It may return the (non-nil) error from the same call - * or return the error (and n == 0) from a subsequent call. - * An instance of this general case is that a Reader returning - * a non-zero number of bytes at the end of the input stream may - * return either err == EOF or err == nil. The next Read should - * return 0, EOF. - * - * Callers should always process the n > 0 bytes returned before - * considering the error err. Doing so correctly handles I/O errors - * that happen after reading some bytes and also both of the - * allowed EOF behaviors. - * - * Implementations of Read are discouraged from returning a - * zero byte count with a nil error, except when len(p) == 0. - * Callers should treat a return of 0 and nil as indicating that - * nothing happened; in particular it does not indicate EOF. - * - * Implementations must not retain p. - */ - interface Reader { - read(p: string): number - } - /** - * Writer is the interface that wraps the basic Write method. - * - * Write writes len(p) bytes from p to the underlying data stream. - * It returns the number of bytes written from p (0 <= n <= len(p)) - * and any error encountered that caused the write to stop early. - * Write must return a non-nil error if it returns n < len(p). - * Write must not modify the slice data, even temporarily. - * - * Implementations must not retain p. - */ - interface Writer { - write(p: string): number - } - /** - * ReadCloser is the interface that groups the basic Read and Close methods. - */ - interface ReadCloser { - } -} - /** * Package fs defines basic interfaces to a file system. * A file system can be provided by the host operating system @@ -11147,302 +11174,6 @@ namespace fs { } } -/** - * Package driver defines interfaces to be implemented by database - * drivers as used by package sql. - * - * Most code should use package sql. - * - * The driver interface has evolved over time. Drivers should implement - * Connector and DriverContext interfaces. - * The Connector.Connect and Driver.Open methods should never return ErrBadConn. - * ErrBadConn should only be returned from Validator, SessionResetter, or - * a query method if the connection is already in an invalid (e.g. closed) state. - * - * All Conn implementations should implement the following interfaces: - * Pinger, SessionResetter, and Validator. - * - * If named parameters or context are supported, the driver's Conn should implement: - * ExecerContext, QueryerContext, ConnPrepareContext, and ConnBeginTx. - * - * To support custom data types, implement NamedValueChecker. NamedValueChecker - * also allows queries to accept per-query options as a parameter by returning - * ErrRemoveArgument from CheckNamedValue. - * - * If multiple result sets are supported, Rows should implement RowsNextResultSet. - * If the driver knows how to describe the types present in the returned result - * it should implement the following interfaces: RowsColumnTypeScanType, - * RowsColumnTypeDatabaseTypeName, RowsColumnTypeLength, RowsColumnTypeNullable, - * and RowsColumnTypePrecisionScale. A given row value may also return a Rows - * type, which may represent a database cursor value. - * - * Before a connection is returned to the connection pool after use, IsValid is - * called if implemented. Before a connection is reused for another query, - * ResetSession is called if implemented. If a connection is never returned to the - * connection pool but immediately reused, then ResetSession is called prior to - * reuse but IsValid is not called. - */ -namespace driver { - /** - * Value is a value that drivers must be able to handle. - * It is either nil, a type handled by a database driver's NamedValueChecker - * interface, or an instance of one of these types: - * - * ``` - * int64 - * float64 - * bool - * []byte - * string - * time.Time - * ``` - * - * If the driver supports cursors, a returned Value may also implement the Rows interface - * in this package. This is used, for example, when a user selects a cursor - * such as "select cursor(select * from my_table) from dual". If the Rows - * from the select is closed, the cursor Rows will also be closed. - */ - interface Value extends _TygojaAny{} - /** - * Driver is the interface that must be implemented by a database - * driver. - * - * Database drivers may implement DriverContext for access - * to contexts and to parse the name only once for a pool of connections, - * instead of once per connection. - */ - interface Driver { - /** - * Open returns a new connection to the database. - * The name is a string in a driver-specific format. - * - * Open may return a cached connection (one previously - * closed), but doing so is unnecessary; the sql package - * maintains a pool of idle connections for efficient re-use. - * - * The returned connection is only used by one goroutine at a - * time. - */ - open(name: string): Conn - } -} - -/** - * Package sql provides a generic interface around SQL (or SQL-like) - * databases. - * - * The sql package must be used in conjunction with a database driver. - * See https://golang.org/s/sqldrivers for a list of drivers. - * - * Drivers that do not support context cancellation will not return until - * after the query is completed. - * - * For usage examples, see the wiki page at - * https://golang.org/s/sqlwiki. - */ -namespace sql { - /** - * IsolationLevel is the transaction isolation level used in TxOptions. - */ - interface IsolationLevel extends Number{} - interface IsolationLevel { - /** - * String returns the name of the transaction isolation level. - */ - string(): string - } - /** - * DBStats contains database statistics. - */ - interface DBStats { - maxOpenConnections: number // Maximum number of open connections to the database. - /** - * Pool Status - */ - openConnections: number // The number of established connections both in use and idle. - inUse: number // The number of connections currently in use. - idle: number // The number of idle connections. - /** - * Counters - */ - waitCount: number // The total number of connections waited for. - waitDuration: time.Duration // The total time blocked waiting for a new connection. - maxIdleClosed: number // The total number of connections closed due to SetMaxIdleConns. - maxIdleTimeClosed: number // The total number of connections closed due to SetConnMaxIdleTime. - maxLifetimeClosed: number // The total number of connections closed due to SetConnMaxLifetime. - } - /** - * Conn represents a single database connection rather than a pool of database - * connections. Prefer running queries from DB unless there is a specific - * need for a continuous single database connection. - * - * A Conn must call Close to return the connection to the database pool - * and may do so concurrently with a running query. - * - * After a call to Close, all operations on the - * connection fail with ErrConnDone. - */ - interface Conn { - } - interface Conn { - /** - * PingContext verifies the connection to the database is still alive. - */ - pingContext(ctx: context.Context): void - } - interface Conn { - /** - * ExecContext executes a query without returning any rows. - * The args are for any placeholder parameters in the query. - */ - execContext(ctx: context.Context, query: string, ...args: any[]): Result - } - interface Conn { - /** - * QueryContext executes a query that returns rows, typically a SELECT. - * The args are for any placeholder parameters in the query. - */ - queryContext(ctx: context.Context, query: string, ...args: any[]): (Rows | undefined) - } - interface Conn { - /** - * QueryRowContext executes a query that is expected to return at most one row. - * QueryRowContext always returns a non-nil value. Errors are deferred until - * Row's Scan method is called. - * If the query selects no rows, the *Row's Scan will return ErrNoRows. - * Otherwise, the *Row's Scan scans the first selected row and discards - * the rest. - */ - queryRowContext(ctx: context.Context, query: string, ...args: any[]): (Row | undefined) - } - interface Conn { - /** - * PrepareContext creates a prepared statement for later queries or executions. - * Multiple queries or executions may be run concurrently from the - * returned statement. - * The caller must call the statement's Close method - * when the statement is no longer needed. - * - * The provided context is used for the preparation of the statement, not for the - * execution of the statement. - */ - prepareContext(ctx: context.Context, query: string): (Stmt | undefined) - } - interface Conn { - /** - * Raw executes f exposing the underlying driver connection for the - * duration of f. The driverConn must not be used outside of f. - * - * Once f returns and err is not driver.ErrBadConn, the Conn will continue to be usable - * until Conn.Close is called. - */ - raw(f: (driverConn: any) => void): void - } - interface Conn { - /** - * BeginTx starts a transaction. - * - * The provided context is used until the transaction is committed or rolled back. - * If the context is canceled, the sql package will roll back - * the transaction. Tx.Commit will return an error if the context provided to - * BeginTx is canceled. - * - * The provided TxOptions is optional and may be nil if defaults should be used. - * If a non-default isolation level is used that the driver doesn't support, - * an error will be returned. - */ - beginTx(ctx: context.Context, opts: TxOptions): (Tx | undefined) - } - interface Conn { - /** - * Close returns the connection to the connection pool. - * All operations after a Close will return with ErrConnDone. - * Close is safe to call concurrently with other operations and will - * block until all other operations finish. It may be useful to first - * cancel any used context and then call close directly after. - */ - close(): void - } - /** - * ColumnType contains the name and type of a column. - */ - interface ColumnType { - } - interface ColumnType { - /** - * Name returns the name or alias of the column. - */ - name(): string - } - interface ColumnType { - /** - * Length returns the column type length for variable length column types such - * as text and binary field types. If the type length is unbounded the value will - * be math.MaxInt64 (any database limits will still apply). - * If the column type is not variable length, such as an int, or if not supported - * by the driver ok is false. - */ - length(): [number, boolean] - } - interface ColumnType { - /** - * DecimalSize returns the scale and precision of a decimal type. - * If not applicable or if not supported ok is false. - */ - decimalSize(): [number, boolean] - } - interface ColumnType { - /** - * ScanType returns a Go type suitable for scanning into using Rows.Scan. - * If a driver does not support this property ScanType will return - * the type of an empty interface. - */ - scanType(): reflect.Type - } - interface ColumnType { - /** - * Nullable reports whether the column may be null. - * If a driver does not support this property ok will be false. - */ - nullable(): boolean - } - interface ColumnType { - /** - * DatabaseTypeName returns the database system name of the column type. If an empty - * string is returned, then the driver type name is not supported. - * Consult your driver documentation for a list of driver data types. Length specifiers - * are not included. - * Common type names include "VARCHAR", "TEXT", "NVARCHAR", "DECIMAL", "BOOL", - * "INT", and "BIGINT". - */ - databaseTypeName(): string - } - /** - * Row is the result of calling QueryRow to select a single row. - */ - interface Row { - } - interface Row { - /** - * Scan copies the columns from the matched row into the values - * pointed at by dest. See the documentation on Rows.Scan for details. - * If more than one row matches the query, - * Scan uses the first row and discards the rest. If no row matches - * the query, Scan returns ErrNoRows. - */ - scan(...dest: any[]): void - } - interface Row { - /** - * Err provides a way for wrapping packages to check for - * query errors without calling Scan. - * Err returns the error, if any, that was encountered while running the query. - * If this error is not nil, this error will also be returned from Scan. - */ - err(): void - } -} - /** * Package url parses URLs and implements query escaping. */ @@ -12521,6 +12252,95 @@ namespace http { } } +/** + * Package oauth2 provides support for making + * OAuth2 authorized and authenticated HTTP requests, + * as specified in RFC 6749. + * It can additionally grant authorization with Bearer JWT. + */ +namespace oauth2 { + /** + * An AuthCodeOption is passed to Config.AuthCodeURL. + */ + interface AuthCodeOption { + } + /** + * Token represents the credentials used to authorize + * the requests to access protected resources on the OAuth 2.0 + * provider's backend. + * + * Most users of this package should not access fields of Token + * directly. They're exported mostly for use by related packages + * implementing derivative OAuth2 flows. + */ + interface Token { + /** + * AccessToken is the token that authorizes and authenticates + * the requests. + */ + accessToken: string + /** + * TokenType is the type of token. + * The Type method returns either this or "Bearer", the default. + */ + tokenType: string + /** + * RefreshToken is a token that's used by the application + * (as opposed to the user) to refresh the access token + * if it expires. + */ + refreshToken: string + /** + * Expiry is the optional expiration time of the access token. + * + * If zero, TokenSource implementations will reuse the same + * token forever and RefreshToken or equivalent + * mechanisms for that TokenSource will not be used. + */ + expiry: time.Time + } + interface Token { + /** + * Type returns t.TokenType if non-empty, else "Bearer". + */ + type(): string + } + interface Token { + /** + * SetAuthHeader sets the Authorization header to r using the access + * token in t. + * + * This method is unnecessary when using Transport or an HTTP Client + * returned by this package. + */ + setAuthHeader(r: http.Request): void + } + interface Token { + /** + * WithExtra returns a new Token that's a clone of t, but using the + * provided raw extra map. This is only intended for use by packages + * implementing derivative OAuth2 flows. + */ + withExtra(extra: { + }): (Token | undefined) + } + interface Token { + /** + * Extra returns an extra field. + * Extra fields are key-value pairs returned by the server as a + * part of the token retrieval response. + */ + extra(key: string): { + } + } + interface Token { + /** + * Valid reports whether t is non-nil, has an AccessToken, and is not expired. + */ + valid(): boolean + } +} + /** * Package echo implements high performance, minimalist Go web framework. * @@ -12959,6 +12779,302 @@ namespace echo { } } +/** + * Package driver defines interfaces to be implemented by database + * drivers as used by package sql. + * + * Most code should use package sql. + * + * The driver interface has evolved over time. Drivers should implement + * Connector and DriverContext interfaces. + * The Connector.Connect and Driver.Open methods should never return ErrBadConn. + * ErrBadConn should only be returned from Validator, SessionResetter, or + * a query method if the connection is already in an invalid (e.g. closed) state. + * + * All Conn implementations should implement the following interfaces: + * Pinger, SessionResetter, and Validator. + * + * If named parameters or context are supported, the driver's Conn should implement: + * ExecerContext, QueryerContext, ConnPrepareContext, and ConnBeginTx. + * + * To support custom data types, implement NamedValueChecker. NamedValueChecker + * also allows queries to accept per-query options as a parameter by returning + * ErrRemoveArgument from CheckNamedValue. + * + * If multiple result sets are supported, Rows should implement RowsNextResultSet. + * If the driver knows how to describe the types present in the returned result + * it should implement the following interfaces: RowsColumnTypeScanType, + * RowsColumnTypeDatabaseTypeName, RowsColumnTypeLength, RowsColumnTypeNullable, + * and RowsColumnTypePrecisionScale. A given row value may also return a Rows + * type, which may represent a database cursor value. + * + * Before a connection is returned to the connection pool after use, IsValid is + * called if implemented. Before a connection is reused for another query, + * ResetSession is called if implemented. If a connection is never returned to the + * connection pool but immediately reused, then ResetSession is called prior to + * reuse but IsValid is not called. + */ +namespace driver { + /** + * Value is a value that drivers must be able to handle. + * It is either nil, a type handled by a database driver's NamedValueChecker + * interface, or an instance of one of these types: + * + * ``` + * int64 + * float64 + * bool + * []byte + * string + * time.Time + * ``` + * + * If the driver supports cursors, a returned Value may also implement the Rows interface + * in this package. This is used, for example, when a user selects a cursor + * such as "select cursor(select * from my_table) from dual". If the Rows + * from the select is closed, the cursor Rows will also be closed. + */ + interface Value extends _TygojaAny{} + /** + * Driver is the interface that must be implemented by a database + * driver. + * + * Database drivers may implement DriverContext for access + * to contexts and to parse the name only once for a pool of connections, + * instead of once per connection. + */ + interface Driver { + /** + * Open returns a new connection to the database. + * The name is a string in a driver-specific format. + * + * Open may return a cached connection (one previously + * closed), but doing so is unnecessary; the sql package + * maintains a pool of idle connections for efficient re-use. + * + * The returned connection is only used by one goroutine at a + * time. + */ + open(name: string): Conn + } +} + +/** + * Package sql provides a generic interface around SQL (or SQL-like) + * databases. + * + * The sql package must be used in conjunction with a database driver. + * See https://golang.org/s/sqldrivers for a list of drivers. + * + * Drivers that do not support context cancellation will not return until + * after the query is completed. + * + * For usage examples, see the wiki page at + * https://golang.org/s/sqlwiki. + */ +namespace sql { + /** + * IsolationLevel is the transaction isolation level used in TxOptions. + */ + interface IsolationLevel extends Number{} + interface IsolationLevel { + /** + * String returns the name of the transaction isolation level. + */ + string(): string + } + /** + * DBStats contains database statistics. + */ + interface DBStats { + maxOpenConnections: number // Maximum number of open connections to the database. + /** + * Pool Status + */ + openConnections: number // The number of established connections both in use and idle. + inUse: number // The number of connections currently in use. + idle: number // The number of idle connections. + /** + * Counters + */ + waitCount: number // The total number of connections waited for. + waitDuration: time.Duration // The total time blocked waiting for a new connection. + maxIdleClosed: number // The total number of connections closed due to SetMaxIdleConns. + maxIdleTimeClosed: number // The total number of connections closed due to SetConnMaxIdleTime. + maxLifetimeClosed: number // The total number of connections closed due to SetConnMaxLifetime. + } + /** + * Conn represents a single database connection rather than a pool of database + * connections. Prefer running queries from DB unless there is a specific + * need for a continuous single database connection. + * + * A Conn must call Close to return the connection to the database pool + * and may do so concurrently with a running query. + * + * After a call to Close, all operations on the + * connection fail with ErrConnDone. + */ + interface Conn { + } + interface Conn { + /** + * PingContext verifies the connection to the database is still alive. + */ + pingContext(ctx: context.Context): void + } + interface Conn { + /** + * ExecContext executes a query without returning any rows. + * The args are for any placeholder parameters in the query. + */ + execContext(ctx: context.Context, query: string, ...args: any[]): Result + } + interface Conn { + /** + * QueryContext executes a query that returns rows, typically a SELECT. + * The args are for any placeholder parameters in the query. + */ + queryContext(ctx: context.Context, query: string, ...args: any[]): (Rows | undefined) + } + interface Conn { + /** + * QueryRowContext executes a query that is expected to return at most one row. + * QueryRowContext always returns a non-nil value. Errors are deferred until + * Row's Scan method is called. + * If the query selects no rows, the *Row's Scan will return ErrNoRows. + * Otherwise, the *Row's Scan scans the first selected row and discards + * the rest. + */ + queryRowContext(ctx: context.Context, query: string, ...args: any[]): (Row | undefined) + } + interface Conn { + /** + * PrepareContext creates a prepared statement for later queries or executions. + * Multiple queries or executions may be run concurrently from the + * returned statement. + * The caller must call the statement's Close method + * when the statement is no longer needed. + * + * The provided context is used for the preparation of the statement, not for the + * execution of the statement. + */ + prepareContext(ctx: context.Context, query: string): (Stmt | undefined) + } + interface Conn { + /** + * Raw executes f exposing the underlying driver connection for the + * duration of f. The driverConn must not be used outside of f. + * + * Once f returns and err is not driver.ErrBadConn, the Conn will continue to be usable + * until Conn.Close is called. + */ + raw(f: (driverConn: any) => void): void + } + interface Conn { + /** + * BeginTx starts a transaction. + * + * The provided context is used until the transaction is committed or rolled back. + * If the context is canceled, the sql package will roll back + * the transaction. Tx.Commit will return an error if the context provided to + * BeginTx is canceled. + * + * The provided TxOptions is optional and may be nil if defaults should be used. + * If a non-default isolation level is used that the driver doesn't support, + * an error will be returned. + */ + beginTx(ctx: context.Context, opts: TxOptions): (Tx | undefined) + } + interface Conn { + /** + * Close returns the connection to the connection pool. + * All operations after a Close will return with ErrConnDone. + * Close is safe to call concurrently with other operations and will + * block until all other operations finish. It may be useful to first + * cancel any used context and then call close directly after. + */ + close(): void + } + /** + * ColumnType contains the name and type of a column. + */ + interface ColumnType { + } + interface ColumnType { + /** + * Name returns the name or alias of the column. + */ + name(): string + } + interface ColumnType { + /** + * Length returns the column type length for variable length column types such + * as text and binary field types. If the type length is unbounded the value will + * be math.MaxInt64 (any database limits will still apply). + * If the column type is not variable length, such as an int, or if not supported + * by the driver ok is false. + */ + length(): [number, boolean] + } + interface ColumnType { + /** + * DecimalSize returns the scale and precision of a decimal type. + * If not applicable or if not supported ok is false. + */ + decimalSize(): [number, boolean] + } + interface ColumnType { + /** + * ScanType returns a Go type suitable for scanning into using Rows.Scan. + * If a driver does not support this property ScanType will return + * the type of an empty interface. + */ + scanType(): reflect.Type + } + interface ColumnType { + /** + * Nullable reports whether the column may be null. + * If a driver does not support this property ok will be false. + */ + nullable(): boolean + } + interface ColumnType { + /** + * DatabaseTypeName returns the database system name of the column type. If an empty + * string is returned, then the driver type name is not supported. + * Consult your driver documentation for a list of driver data types. Length specifiers + * are not included. + * Common type names include "VARCHAR", "TEXT", "NVARCHAR", "DECIMAL", "BOOL", + * "INT", and "BIGINT". + */ + databaseTypeName(): string + } + /** + * Row is the result of calling QueryRow to select a single row. + */ + interface Row { + } + interface Row { + /** + * Scan copies the columns from the matched row into the values + * pointed at by dest. See the documentation on Rows.Scan for details. + * If more than one row matches the query, + * Scan uses the first row and discards the rest. If no row matches + * the query, Scan returns ErrNoRows. + */ + scan(...dest: any[]): void + } + interface Row { + /** + * Err provides a way for wrapping packages to check for + * query errors without calling Scan. + * Err returns the error, if any, that was encountered while running the query. + * If this error is not nil, this error will also be returned from Scan. + */ + err(): void + } +} + namespace store { /** * Store defines a concurrent safe in memory key-value data store. @@ -13317,16 +13433,16 @@ namespace models { */ validate(): void } - type _subSadpX = BaseModel - interface Param extends _subSadpX { + type _subEdykk = BaseModel + interface Param extends _subEdykk { key: string value: types.JsonRaw } interface Param { tableName(): string } - type _subaRlaX = BaseModel - interface Request extends _subaRlaX { + type _subOKrKJ = BaseModel + interface Request extends _subOKrKJ { url: string method: string status: number @@ -13354,95 +13470,6 @@ namespace models { } } -/** - * Package oauth2 provides support for making - * OAuth2 authorized and authenticated HTTP requests, - * as specified in RFC 6749. - * It can additionally grant authorization with Bearer JWT. - */ -namespace oauth2 { - /** - * An AuthCodeOption is passed to Config.AuthCodeURL. - */ - interface AuthCodeOption { - } - /** - * Token represents the credentials used to authorize - * the requests to access protected resources on the OAuth 2.0 - * provider's backend. - * - * Most users of this package should not access fields of Token - * directly. They're exported mostly for use by related packages - * implementing derivative OAuth2 flows. - */ - interface Token { - /** - * AccessToken is the token that authorizes and authenticates - * the requests. - */ - accessToken: string - /** - * TokenType is the type of token. - * The Type method returns either this or "Bearer", the default. - */ - tokenType: string - /** - * RefreshToken is a token that's used by the application - * (as opposed to the user) to refresh the access token - * if it expires. - */ - refreshToken: string - /** - * Expiry is the optional expiration time of the access token. - * - * If zero, TokenSource implementations will reuse the same - * token forever and RefreshToken or equivalent - * mechanisms for that TokenSource will not be used. - */ - expiry: time.Time - } - interface Token { - /** - * Type returns t.TokenType if non-empty, else "Bearer". - */ - type(): string - } - interface Token { - /** - * SetAuthHeader sets the Authorization header to r using the access - * token in t. - * - * This method is unnecessary when using Transport or an HTTP Client - * returned by this package. - */ - setAuthHeader(r: http.Request): void - } - interface Token { - /** - * WithExtra returns a new Token that's a clone of t, but using the - * provided raw extra map. This is only intended for use by packages - * implementing derivative OAuth2 flows. - */ - withExtra(extra: { - }): (Token | undefined) - } - interface Token { - /** - * Extra returns an extra field. - * Extra fields are key-value pairs returned by the server as a - * part of the token retrieval response. - */ - extra(key: string): { - } - } - interface Token { - /** - * Valid reports whether t is non-nil, has an AccessToken, and is not expired. - */ - valid(): boolean - } -} - namespace mailer { /** * Mailer defines a base mail client interface. @@ -13612,374 +13639,6 @@ namespace daos { } } -namespace hook { - /** - * Hook defines a concurrent safe structure for handling event hooks - * (aka. callbacks propagation). - */ - interface Hook { - } - interface Hook { - /** - * PreAdd registers a new handler to the hook by prepending it to the existing queue. - * - * Returns an autogenerated hook id that could be used later to remove the hook with Hook.Remove(id). - */ - preAdd(fn: Handler): string - } - interface Hook { - /** - * Add registers a new handler to the hook by appending it to the existing queue. - * - * Returns an autogenerated hook id that could be used later to remove the hook with Hook.Remove(id). - */ - add(fn: Handler): string - } - interface Hook { - /** - * @todo add also to TaggedHook - * Remove removes a single hook handler by its id. - */ - remove(id: string): void - } - interface Hook { - /** - * @todo add also to TaggedHook - * RemoveAll removes all registered handlers. - */ - removeAll(): void - } - interface Hook { - /** - * Trigger executes all registered hook handlers one by one - * with the specified `data` as an argument. - * - * Optionally, this method allows also to register additional one off - * handlers that will be temporary appended to the handlers queue. - * - * The execution stops when: - * - hook.StopPropagation is returned in one of the handlers - * - any non-nil error is returned in one of the handlers - */ - trigger(data: T, ...oneOffHandlers: Handler[]): void - } - /** - * TaggedHook defines a proxy hook which register handlers that are triggered only - * if the TaggedHook.tags are empty or includes at least one of the event data tag(s). - */ - type _subskCTo = mainHook - interface TaggedHook extends _subskCTo { - } - interface TaggedHook { - /** - * CanTriggerOn checks if the current TaggedHook can be triggered with - * the provided event data tags. - */ - canTriggerOn(tags: Array): boolean - } - interface TaggedHook { - /** - * PreAdd registers a new handler to the hook by prepending it to the existing queue. - * - * The fn handler will be called only if the event data tags satisfy h.CanTriggerOn. - */ - preAdd(fn: Handler): string - } - interface TaggedHook { - /** - * Add registers a new handler to the hook by appending it to the existing queue. - * - * The fn handler will be called only if the event data tags satisfy h.CanTriggerOn. - */ - add(fn: Handler): string - } -} - -namespace subscriptions { - /** - * Broker defines a struct for managing subscriptions clients. - */ - interface Broker { - } - interface Broker { - /** - * Clients returns a shallow copy of all registered clients indexed - * with their connection id. - */ - clients(): _TygojaDict - } - interface Broker { - /** - * ClientById finds a registered client by its id. - * - * Returns non-nil error when client with clientId is not registered. - */ - clientById(clientId: string): Client - } - interface Broker { - /** - * Register adds a new client to the broker instance. - */ - register(client: Client): void - } - interface Broker { - /** - * Unregister removes a single client by its id. - * - * If client with clientId doesn't exist, this method does nothing. - */ - unregister(clientId: string): void - } -} - -/** - * Package core is the backbone of PocketBase. - * - * It defines the main PocketBase App interface and its base implementation. - */ -namespace core { - interface BootstrapEvent { - app: App - } - interface TerminateEvent { - app: App - } - interface ServeEvent { - app: App - router?: echo.Echo - server?: http.Server - certManager?: autocert.Manager - } - interface ApiErrorEvent { - httpContext: echo.Context - error: Error - } - type _subBTEfC = BaseModelEvent - interface ModelEvent extends _subBTEfC { - dao?: daos.Dao - } - type _subreEfP = BaseCollectionEvent - interface MailerRecordEvent extends _subreEfP { - mailClient: mailer.Mailer - message?: mailer.Message - record?: models.Record - meta: _TygojaDict - } - interface MailerAdminEvent { - mailClient: mailer.Mailer - message?: mailer.Message - admin?: models.Admin - meta: _TygojaDict - } - interface RealtimeConnectEvent { - httpContext: echo.Context - client: subscriptions.Client - } - interface RealtimeDisconnectEvent { - httpContext: echo.Context - client: subscriptions.Client - } - interface RealtimeMessageEvent { - httpContext: echo.Context - client: subscriptions.Client - message?: subscriptions.Message - } - interface RealtimeSubscribeEvent { - httpContext: echo.Context - client: subscriptions.Client - subscriptions: Array - } - interface SettingsListEvent { - httpContext: echo.Context - redactedSettings?: settings.Settings - } - interface SettingsUpdateEvent { - httpContext: echo.Context - oldSettings?: settings.Settings - newSettings?: settings.Settings - } - type _subEMkZr = BaseCollectionEvent - interface RecordsListEvent extends _subEMkZr { - httpContext: echo.Context - records: Array<(models.Record | undefined)> - result?: search.Result - } - type _subexKgL = BaseCollectionEvent - interface RecordViewEvent extends _subexKgL { - httpContext: echo.Context - record?: models.Record - } - type _sublLpof = BaseCollectionEvent - interface RecordCreateEvent extends _sublLpof { - httpContext: echo.Context - record?: models.Record - uploadedFiles: _TygojaDict - } - type _subaBlEv = BaseCollectionEvent - interface RecordUpdateEvent extends _subaBlEv { - httpContext: echo.Context - record?: models.Record - uploadedFiles: _TygojaDict - } - type _subCtZIU = BaseCollectionEvent - interface RecordDeleteEvent extends _subCtZIU { - httpContext: echo.Context - record?: models.Record - } - type _subsESFM = BaseCollectionEvent - interface RecordAuthEvent extends _subsESFM { - httpContext: echo.Context - record?: models.Record - token: string - meta: any - } - type _sublSAdl = BaseCollectionEvent - interface RecordAuthWithPasswordEvent extends _sublSAdl { - httpContext: echo.Context - record?: models.Record - identity: string - password: string - } - type _subUjoUu = BaseCollectionEvent - interface RecordAuthWithOAuth2Event extends _subUjoUu { - httpContext: echo.Context - providerName: string - providerClient: auth.Provider - record?: models.Record - oAuth2User?: auth.AuthUser - isNewRecord: boolean - } - type _subsszTF = BaseCollectionEvent - interface RecordAuthRefreshEvent extends _subsszTF { - httpContext: echo.Context - record?: models.Record - } - type _subpDfQH = BaseCollectionEvent - interface RecordRequestPasswordResetEvent extends _subpDfQH { - httpContext: echo.Context - record?: models.Record - } - type _subNsSXu = BaseCollectionEvent - interface RecordConfirmPasswordResetEvent extends _subNsSXu { - httpContext: echo.Context - record?: models.Record - } - type _subkSgpz = BaseCollectionEvent - interface RecordRequestVerificationEvent extends _subkSgpz { - httpContext: echo.Context - record?: models.Record - } - type _subIxbXq = BaseCollectionEvent - interface RecordConfirmVerificationEvent extends _subIxbXq { - httpContext: echo.Context - record?: models.Record - } - type _subDeJhA = BaseCollectionEvent - interface RecordRequestEmailChangeEvent extends _subDeJhA { - httpContext: echo.Context - record?: models.Record - } - type _subiAiiB = BaseCollectionEvent - interface RecordConfirmEmailChangeEvent extends _subiAiiB { - httpContext: echo.Context - record?: models.Record - } - type _subxmEiW = BaseCollectionEvent - interface RecordListExternalAuthsEvent extends _subxmEiW { - httpContext: echo.Context - record?: models.Record - externalAuths: Array<(models.ExternalAuth | undefined)> - } - type _subzLoZK = BaseCollectionEvent - interface RecordUnlinkExternalAuthEvent extends _subzLoZK { - httpContext: echo.Context - record?: models.Record - externalAuth?: models.ExternalAuth - } - interface AdminsListEvent { - httpContext: echo.Context - admins: Array<(models.Admin | undefined)> - result?: search.Result - } - interface AdminViewEvent { - httpContext: echo.Context - admin?: models.Admin - } - interface AdminCreateEvent { - httpContext: echo.Context - admin?: models.Admin - } - interface AdminUpdateEvent { - httpContext: echo.Context - admin?: models.Admin - } - interface AdminDeleteEvent { - httpContext: echo.Context - admin?: models.Admin - } - interface AdminAuthEvent { - httpContext: echo.Context - admin?: models.Admin - token: string - } - interface AdminAuthWithPasswordEvent { - httpContext: echo.Context - admin?: models.Admin - identity: string - password: string - } - interface AdminAuthRefreshEvent { - httpContext: echo.Context - admin?: models.Admin - } - interface AdminRequestPasswordResetEvent { - httpContext: echo.Context - admin?: models.Admin - } - interface AdminConfirmPasswordResetEvent { - httpContext: echo.Context - admin?: models.Admin - } - interface CollectionsListEvent { - httpContext: echo.Context - collections: Array<(models.Collection | undefined)> - result?: search.Result - } - type _subRkChx = BaseCollectionEvent - interface CollectionViewEvent extends _subRkChx { - httpContext: echo.Context - } - type _subbDnXD = BaseCollectionEvent - interface CollectionCreateEvent extends _subbDnXD { - httpContext: echo.Context - } - type _subzIbMF = BaseCollectionEvent - interface CollectionUpdateEvent extends _subzIbMF { - httpContext: echo.Context - } - type _subSHZAF = BaseCollectionEvent - interface CollectionDeleteEvent extends _subSHZAF { - httpContext: echo.Context - } - interface CollectionsImportEvent { - httpContext: echo.Context - collections: Array<(models.Collection | undefined)> - } - type _subcOcDT = BaseModelEvent - interface FileTokenEvent extends _subcOcDT { - httpContext: echo.Context - token: string - } - type _subHfAHi = BaseCollectionEvent - interface FileDownloadEvent extends _subHfAHi { - httpContext: echo.Context - record?: models.Record - fileField?: schema.SchemaField - servedPath: string - servedName: string - } -} - /** * Package pflag is a drop-in replacement for Go's flag package, implementing * POSIX/GNU-style --flags. @@ -15539,14 +15198,6 @@ namespace pflag { } } -namespace migrate { - interface Migration { - file: string - up: (db: dbx.Builder) => void - down: (db: dbx.Builder) => void - } -} - /** * Package cobra is a commander providing a simple interface to create powerful modern CLI interfaces. * In addition to providing an interface, Cobra simultaneously provides a controller to organize your application code. @@ -15596,6 +15247,382 @@ namespace cobra { } } +namespace migrate { + interface Migration { + file: string + up: (db: dbx.Builder) => void + down: (db: dbx.Builder) => void + } +} + +namespace subscriptions { + /** + * Broker defines a struct for managing subscriptions clients. + */ + interface Broker { + } + interface Broker { + /** + * Clients returns a shallow copy of all registered clients indexed + * with their connection id. + */ + clients(): _TygojaDict + } + interface Broker { + /** + * ClientById finds a registered client by its id. + * + * Returns non-nil error when client with clientId is not registered. + */ + clientById(clientId: string): Client + } + interface Broker { + /** + * Register adds a new client to the broker instance. + */ + register(client: Client): void + } + interface Broker { + /** + * Unregister removes a single client by its id. + * + * If client with clientId doesn't exist, this method does nothing. + */ + unregister(clientId: string): void + } +} + +namespace hook { + /** + * Hook defines a concurrent safe structure for handling event hooks + * (aka. callbacks propagation). + */ + interface Hook { + } + interface Hook { + /** + * PreAdd registers a new handler to the hook by prepending it to the existing queue. + * + * Returns an autogenerated hook id that could be used later to remove the hook with Hook.Remove(id). + */ + preAdd(fn: Handler): string + } + interface Hook { + /** + * Add registers a new handler to the hook by appending it to the existing queue. + * + * Returns an autogenerated hook id that could be used later to remove the hook with Hook.Remove(id). + */ + add(fn: Handler): string + } + interface Hook { + /** + * @todo add also to TaggedHook + * Remove removes a single hook handler by its id. + */ + remove(id: string): void + } + interface Hook { + /** + * @todo add also to TaggedHook + * RemoveAll removes all registered handlers. + */ + removeAll(): void + } + interface Hook { + /** + * Trigger executes all registered hook handlers one by one + * with the specified `data` as an argument. + * + * Optionally, this method allows also to register additional one off + * handlers that will be temporary appended to the handlers queue. + * + * The execution stops when: + * - hook.StopPropagation is returned in one of the handlers + * - any non-nil error is returned in one of the handlers + */ + trigger(data: T, ...oneOffHandlers: Handler[]): void + } + /** + * TaggedHook defines a proxy hook which register handlers that are triggered only + * if the TaggedHook.tags are empty or includes at least one of the event data tag(s). + */ + type _subRfQNA = mainHook + interface TaggedHook extends _subRfQNA { + } + interface TaggedHook { + /** + * CanTriggerOn checks if the current TaggedHook can be triggered with + * the provided event data tags. + */ + canTriggerOn(tags: Array): boolean + } + interface TaggedHook { + /** + * PreAdd registers a new handler to the hook by prepending it to the existing queue. + * + * The fn handler will be called only if the event data tags satisfy h.CanTriggerOn. + */ + preAdd(fn: Handler): string + } + interface TaggedHook { + /** + * Add registers a new handler to the hook by appending it to the existing queue. + * + * The fn handler will be called only if the event data tags satisfy h.CanTriggerOn. + */ + add(fn: Handler): string + } +} + +/** + * Package core is the backbone of PocketBase. + * + * It defines the main PocketBase App interface and its base implementation. + */ +namespace core { + interface BootstrapEvent { + app: App + } + interface TerminateEvent { + app: App + } + interface ServeEvent { + app: App + router?: echo.Echo + server?: http.Server + certManager?: autocert.Manager + } + interface ApiErrorEvent { + httpContext: echo.Context + error: Error + } + type _subVJKiP = BaseModelEvent + interface ModelEvent extends _subVJKiP { + dao?: daos.Dao + } + type _subGZryQ = BaseCollectionEvent + interface MailerRecordEvent extends _subGZryQ { + mailClient: mailer.Mailer + message?: mailer.Message + record?: models.Record + meta: _TygojaDict + } + interface MailerAdminEvent { + mailClient: mailer.Mailer + message?: mailer.Message + admin?: models.Admin + meta: _TygojaDict + } + interface RealtimeConnectEvent { + httpContext: echo.Context + client: subscriptions.Client + } + interface RealtimeDisconnectEvent { + httpContext: echo.Context + client: subscriptions.Client + } + interface RealtimeMessageEvent { + httpContext: echo.Context + client: subscriptions.Client + message?: subscriptions.Message + } + interface RealtimeSubscribeEvent { + httpContext: echo.Context + client: subscriptions.Client + subscriptions: Array + } + interface SettingsListEvent { + httpContext: echo.Context + redactedSettings?: settings.Settings + } + interface SettingsUpdateEvent { + httpContext: echo.Context + oldSettings?: settings.Settings + newSettings?: settings.Settings + } + type _subTYfSK = BaseCollectionEvent + interface RecordsListEvent extends _subTYfSK { + httpContext: echo.Context + records: Array<(models.Record | undefined)> + result?: search.Result + } + type _subWVzos = BaseCollectionEvent + interface RecordViewEvent extends _subWVzos { + httpContext: echo.Context + record?: models.Record + } + type _subafNoq = BaseCollectionEvent + interface RecordCreateEvent extends _subafNoq { + httpContext: echo.Context + record?: models.Record + uploadedFiles: _TygojaDict + } + type _subBrERj = BaseCollectionEvent + interface RecordUpdateEvent extends _subBrERj { + httpContext: echo.Context + record?: models.Record + uploadedFiles: _TygojaDict + } + type _subsDviH = BaseCollectionEvent + interface RecordDeleteEvent extends _subsDviH { + httpContext: echo.Context + record?: models.Record + } + type _subOMkzs = BaseCollectionEvent + interface RecordAuthEvent extends _subOMkzs { + httpContext: echo.Context + record?: models.Record + token: string + meta: any + } + type _subvNpRR = BaseCollectionEvent + interface RecordAuthWithPasswordEvent extends _subvNpRR { + httpContext: echo.Context + record?: models.Record + identity: string + password: string + } + type _subZwaqX = BaseCollectionEvent + interface RecordAuthWithOAuth2Event extends _subZwaqX { + httpContext: echo.Context + providerName: string + providerClient: auth.Provider + record?: models.Record + oAuth2User?: auth.AuthUser + isNewRecord: boolean + } + type _subbSlSy = BaseCollectionEvent + interface RecordAuthRefreshEvent extends _subbSlSy { + httpContext: echo.Context + record?: models.Record + } + type _sublEBOk = BaseCollectionEvent + interface RecordRequestPasswordResetEvent extends _sublEBOk { + httpContext: echo.Context + record?: models.Record + } + type _subzOxDh = BaseCollectionEvent + interface RecordConfirmPasswordResetEvent extends _subzOxDh { + httpContext: echo.Context + record?: models.Record + } + type _subcVymS = BaseCollectionEvent + interface RecordRequestVerificationEvent extends _subcVymS { + httpContext: echo.Context + record?: models.Record + } + type _subCgJzD = BaseCollectionEvent + interface RecordConfirmVerificationEvent extends _subCgJzD { + httpContext: echo.Context + record?: models.Record + } + type _subyxJre = BaseCollectionEvent + interface RecordRequestEmailChangeEvent extends _subyxJre { + httpContext: echo.Context + record?: models.Record + } + type _subZbEub = BaseCollectionEvent + interface RecordConfirmEmailChangeEvent extends _subZbEub { + httpContext: echo.Context + record?: models.Record + } + type _subhLOSu = BaseCollectionEvent + interface RecordListExternalAuthsEvent extends _subhLOSu { + httpContext: echo.Context + record?: models.Record + externalAuths: Array<(models.ExternalAuth | undefined)> + } + type _subAuUrW = BaseCollectionEvent + interface RecordUnlinkExternalAuthEvent extends _subAuUrW { + httpContext: echo.Context + record?: models.Record + externalAuth?: models.ExternalAuth + } + interface AdminsListEvent { + httpContext: echo.Context + admins: Array<(models.Admin | undefined)> + result?: search.Result + } + interface AdminViewEvent { + httpContext: echo.Context + admin?: models.Admin + } + interface AdminCreateEvent { + httpContext: echo.Context + admin?: models.Admin + } + interface AdminUpdateEvent { + httpContext: echo.Context + admin?: models.Admin + } + interface AdminDeleteEvent { + httpContext: echo.Context + admin?: models.Admin + } + interface AdminAuthEvent { + httpContext: echo.Context + admin?: models.Admin + token: string + } + interface AdminAuthWithPasswordEvent { + httpContext: echo.Context + admin?: models.Admin + identity: string + password: string + } + interface AdminAuthRefreshEvent { + httpContext: echo.Context + admin?: models.Admin + } + interface AdminRequestPasswordResetEvent { + httpContext: echo.Context + admin?: models.Admin + } + interface AdminConfirmPasswordResetEvent { + httpContext: echo.Context + admin?: models.Admin + } + interface CollectionsListEvent { + httpContext: echo.Context + collections: Array<(models.Collection | undefined)> + result?: search.Result + } + type _subPSZcY = BaseCollectionEvent + interface CollectionViewEvent extends _subPSZcY { + httpContext: echo.Context + } + type _subtrePc = BaseCollectionEvent + interface CollectionCreateEvent extends _subtrePc { + httpContext: echo.Context + } + type _subqhrrJ = BaseCollectionEvent + interface CollectionUpdateEvent extends _subqhrrJ { + httpContext: echo.Context + } + type _subPMxvV = BaseCollectionEvent + interface CollectionDeleteEvent extends _subPMxvV { + httpContext: echo.Context + } + interface CollectionsImportEvent { + httpContext: echo.Context + collections: Array<(models.Collection | undefined)> + } + type _subFyXlB = BaseModelEvent + interface FileTokenEvent extends _subFyXlB { + httpContext: echo.Context + token: string + } + type _sublZIFc = BaseCollectionEvent + interface FileDownloadEvent extends _sublZIFc { + httpContext: echo.Context + record?: models.Record + fileField?: schema.SchemaField + servedPath: string + servedName: string + } +} + /** * Package time provides functionality for measuring and displaying time. * @@ -15712,6 +15739,235 @@ namespace time { } } +/** + * Package reflect implements run-time reflection, allowing a program to + * manipulate objects with arbitrary types. The typical use is to take a value + * with static type interface{} and extract its dynamic type information by + * calling TypeOf, which returns a Type. + * + * A call to ValueOf returns a Value representing the run-time data. + * Zero takes a Type and returns a Value representing a zero value + * for that type. + * + * See "The Laws of Reflection" for an introduction to reflection in Go: + * https://golang.org/doc/articles/laws_of_reflection.html + */ +namespace reflect { + /** + * Type is the representation of a Go type. + * + * Not all methods apply to all kinds of types. Restrictions, + * if any, are noted in the documentation for each method. + * Use the Kind method to find out the kind of type before + * calling kind-specific methods. Calling a method + * inappropriate to the kind of type causes a run-time panic. + * + * Type values are comparable, such as with the == operator, + * so they can be used as map keys. + * Two Type values are equal if they represent identical types. + */ + interface Type { + /** + * Align returns the alignment in bytes of a value of + * this type when allocated in memory. + */ + align(): number + /** + * FieldAlign returns the alignment in bytes of a value of + * this type when used as a field in a struct. + */ + fieldAlign(): number + /** + * Method returns the i'th method in the type's method set. + * It panics if i is not in the range [0, NumMethod()). + * + * For a non-interface type T or *T, the returned Method's Type and Func + * fields describe a function whose first argument is the receiver, + * and only exported methods are accessible. + * + * For an interface type, the returned Method's Type field gives the + * method signature, without a receiver, and the Func field is nil. + * + * Methods are sorted in lexicographic order. + */ + method(_arg0: number): Method + /** + * MethodByName returns the method with that name in the type's + * method set and a boolean indicating if the method was found. + * + * For a non-interface type T or *T, the returned Method's Type and Func + * fields describe a function whose first argument is the receiver. + * + * For an interface type, the returned Method's Type field gives the + * method signature, without a receiver, and the Func field is nil. + */ + methodByName(_arg0: string): [Method, boolean] + /** + * NumMethod returns the number of methods accessible using Method. + * + * For a non-interface type, it returns the number of exported methods. + * + * For an interface type, it returns the number of exported and unexported methods. + */ + numMethod(): number + /** + * Name returns the type's name within its package for a defined type. + * For other (non-defined) types it returns the empty string. + */ + name(): string + /** + * PkgPath returns a defined type's package path, that is, the import path + * that uniquely identifies the package, such as "encoding/base64". + * If the type was predeclared (string, error) or not defined (*T, struct{}, + * []int, or A where A is an alias for a non-defined type), the package path + * will be the empty string. + */ + pkgPath(): string + /** + * Size returns the number of bytes needed to store + * a value of the given type; it is analogous to unsafe.Sizeof. + */ + size(): number + /** + * String returns a string representation of the type. + * The string representation may use shortened package names + * (e.g., base64 instead of "encoding/base64") and is not + * guaranteed to be unique among types. To test for type identity, + * compare the Types directly. + */ + string(): string + /** + * Kind returns the specific kind of this type. + */ + kind(): Kind + /** + * Implements reports whether the type implements the interface type u. + */ + implements(u: Type): boolean + /** + * AssignableTo reports whether a value of the type is assignable to type u. + */ + assignableTo(u: Type): boolean + /** + * ConvertibleTo reports whether a value of the type is convertible to type u. + * Even if ConvertibleTo returns true, the conversion may still panic. + * For example, a slice of type []T is convertible to *[N]T, + * but the conversion will panic if its length is less than N. + */ + convertibleTo(u: Type): boolean + /** + * Comparable reports whether values of this type are comparable. + * Even if Comparable returns true, the comparison may still panic. + * For example, values of interface type are comparable, + * but the comparison will panic if their dynamic type is not comparable. + */ + comparable(): boolean + /** + * Bits returns the size of the type in bits. + * It panics if the type's Kind is not one of the + * sized or unsized Int, Uint, Float, or Complex kinds. + */ + bits(): number + /** + * ChanDir returns a channel type's direction. + * It panics if the type's Kind is not Chan. + */ + chanDir(): ChanDir + /** + * IsVariadic reports whether a function type's final input parameter + * is a "..." parameter. If so, t.In(t.NumIn() - 1) returns the parameter's + * implicit actual type []T. + * + * For concreteness, if t represents func(x int, y ... float64), then + * + * ``` + * t.NumIn() == 2 + * t.In(0) is the reflect.Type for "int" + * t.In(1) is the reflect.Type for "[]float64" + * t.IsVariadic() == true + * ``` + * + * IsVariadic panics if the type's Kind is not Func. + */ + isVariadic(): boolean + /** + * Elem returns a type's element type. + * It panics if the type's Kind is not Array, Chan, Map, Pointer, or Slice. + */ + elem(): Type + /** + * Field returns a struct type's i'th field. + * It panics if the type's Kind is not Struct. + * It panics if i is not in the range [0, NumField()). + */ + field(i: number): StructField + /** + * FieldByIndex returns the nested field corresponding + * to the index sequence. It is equivalent to calling Field + * successively for each index i. + * It panics if the type's Kind is not Struct. + */ + fieldByIndex(index: Array): StructField + /** + * FieldByName returns the struct field with the given name + * and a boolean indicating if the field was found. + */ + fieldByName(name: string): [StructField, boolean] + /** + * FieldByNameFunc returns the struct field with a name + * that satisfies the match function and a boolean indicating if + * the field was found. + * + * FieldByNameFunc considers the fields in the struct itself + * and then the fields in any embedded structs, in breadth first order, + * stopping at the shallowest nesting depth containing one or more + * fields satisfying the match function. If multiple fields at that depth + * satisfy the match function, they cancel each other + * and FieldByNameFunc returns no match. + * This behavior mirrors Go's handling of name lookup in + * structs containing embedded fields. + */ + fieldByNameFunc(match: (_arg0: string) => boolean): [StructField, boolean] + /** + * In returns the type of a function type's i'th input parameter. + * It panics if the type's Kind is not Func. + * It panics if i is not in the range [0, NumIn()). + */ + in(i: number): Type + /** + * Key returns a map type's key type. + * It panics if the type's Kind is not Map. + */ + key(): Type + /** + * Len returns an array type's length. + * It panics if the type's Kind is not Array. + */ + len(): number + /** + * NumField returns a struct type's field count. + * It panics if the type's Kind is not Struct. + */ + numField(): number + /** + * NumIn returns a function type's input parameter count. + * It panics if the type's Kind is not Func. + */ + numIn(): number + /** + * NumOut returns a function type's output parameter count. + * It panics if the type's Kind is not Func. + */ + numOut(): number + /** + * Out returns the type of a function type's i'th output parameter. + * It panics if the type's Kind is not Func. + * It panics if i is not in the range [0, NumOut()). + */ + out(i: number): Type + } +} + /** * Package fs defines basic interfaces to a file system. * A file system can be provided by the host operating system @@ -15731,6 +15987,167 @@ namespace fs { } } +/** + * Package driver defines interfaces to be implemented by database + * drivers as used by package sql. + * + * Most code should use package sql. + * + * The driver interface has evolved over time. Drivers should implement + * Connector and DriverContext interfaces. + * The Connector.Connect and Driver.Open methods should never return ErrBadConn. + * ErrBadConn should only be returned from Validator, SessionResetter, or + * a query method if the connection is already in an invalid (e.g. closed) state. + * + * All Conn implementations should implement the following interfaces: + * Pinger, SessionResetter, and Validator. + * + * If named parameters or context are supported, the driver's Conn should implement: + * ExecerContext, QueryerContext, ConnPrepareContext, and ConnBeginTx. + * + * To support custom data types, implement NamedValueChecker. NamedValueChecker + * also allows queries to accept per-query options as a parameter by returning + * ErrRemoveArgument from CheckNamedValue. + * + * If multiple result sets are supported, Rows should implement RowsNextResultSet. + * If the driver knows how to describe the types present in the returned result + * it should implement the following interfaces: RowsColumnTypeScanType, + * RowsColumnTypeDatabaseTypeName, RowsColumnTypeLength, RowsColumnTypeNullable, + * and RowsColumnTypePrecisionScale. A given row value may also return a Rows + * type, which may represent a database cursor value. + * + * Before a connection is returned to the connection pool after use, IsValid is + * called if implemented. Before a connection is reused for another query, + * ResetSession is called if implemented. If a connection is never returned to the + * connection pool but immediately reused, then ResetSession is called prior to + * reuse but IsValid is not called. + */ +namespace driver { + /** + * Conn is a connection to a database. It is not used concurrently + * by multiple goroutines. + * + * Conn is assumed to be stateful. + */ + interface Conn { + /** + * Prepare returns a prepared statement, bound to this connection. + */ + prepare(query: string): Stmt + /** + * Close invalidates and potentially stops any current + * prepared statements and transactions, marking this + * connection as no longer in use. + * + * Because the sql package maintains a free pool of + * connections and only calls Close when there's a surplus of + * idle connections, it shouldn't be necessary for drivers to + * do their own connection caching. + * + * Drivers must ensure all network calls made by Close + * do not block indefinitely (e.g. apply a timeout). + */ + close(): void + /** + * Begin starts and returns a new transaction. + * + * Deprecated: Drivers should implement ConnBeginTx instead (or additionally). + */ + begin(): Tx + } +} + +/** + * Package url parses URLs and implements query escaping. + */ +namespace url { + /** + * The Userinfo type is an immutable encapsulation of username and + * password details for a URL. An existing Userinfo value is guaranteed + * to have a username set (potentially empty, as allowed by RFC 2396), + * and optionally a password. + */ + interface Userinfo { + } + interface Userinfo { + /** + * Username returns the username. + */ + username(): string + } + interface Userinfo { + /** + * Password returns the password in case it is set, and whether it is set. + */ + password(): [string, boolean] + } + interface Userinfo { + /** + * String returns the encoded userinfo information in the standard form + * of "username[:password]". + */ + string(): string + } +} + +/** + * Package types implements some commonly used db serializable types + * like datetime, json, etc. + */ +namespace types { + /** + * JsonRaw defines a json value type that is safe for db read/write. + */ + interface JsonRaw extends String{} + interface JsonRaw { + /** + * String returns the current JsonRaw instance as a json encoded string. + */ + string(): string + } + interface JsonRaw { + /** + * MarshalJSON implements the [json.Marshaler] interface. + */ + marshalJSON(): string + } + interface JsonRaw { + /** + * UnmarshalJSON implements the [json.Unmarshaler] interface. + */ + unmarshalJSON(b: string): void + } + interface JsonRaw { + /** + * Value implements the [driver.Valuer] interface. + */ + value(): driver.Value + } + interface JsonRaw { + /** + * Scan implements [sql.Scanner] interface to scan the provided value + * into the current JsonRaw instance. + */ + scan(value: { + }): void + } +} + +/** + * Package bufio implements buffered I/O. It wraps an io.Reader or io.Writer + * object, creating another object (Reader or Writer) that also implements + * the interface but provides buffering and some help for textual I/O. + */ +namespace bufio { + /** + * ReadWriter stores pointers to a Reader and a Writer. + * It implements io.ReadWriter. + */ + type _subpmnlf = Reader&Writer + interface ReadWriter extends _subpmnlf { + } +} + /** * Package net provides a portable interface for network I/O, including * TCP/IP, UDP, domain name resolution, and Unix domain sockets. @@ -16071,268 +16488,6 @@ namespace net { } } -/** - * Package reflect implements run-time reflection, allowing a program to - * manipulate objects with arbitrary types. The typical use is to take a value - * with static type interface{} and extract its dynamic type information by - * calling TypeOf, which returns a Type. - * - * A call to ValueOf returns a Value representing the run-time data. - * Zero takes a Type and returns a Value representing a zero value - * for that type. - * - * See "The Laws of Reflection" for an introduction to reflection in Go: - * https://golang.org/doc/articles/laws_of_reflection.html - */ -namespace reflect { - /** - * Type is the representation of a Go type. - * - * Not all methods apply to all kinds of types. Restrictions, - * if any, are noted in the documentation for each method. - * Use the Kind method to find out the kind of type before - * calling kind-specific methods. Calling a method - * inappropriate to the kind of type causes a run-time panic. - * - * Type values are comparable, such as with the == operator, - * so they can be used as map keys. - * Two Type values are equal if they represent identical types. - */ - interface Type { - /** - * Align returns the alignment in bytes of a value of - * this type when allocated in memory. - */ - align(): number - /** - * FieldAlign returns the alignment in bytes of a value of - * this type when used as a field in a struct. - */ - fieldAlign(): number - /** - * Method returns the i'th method in the type's method set. - * It panics if i is not in the range [0, NumMethod()). - * - * For a non-interface type T or *T, the returned Method's Type and Func - * fields describe a function whose first argument is the receiver, - * and only exported methods are accessible. - * - * For an interface type, the returned Method's Type field gives the - * method signature, without a receiver, and the Func field is nil. - * - * Methods are sorted in lexicographic order. - */ - method(_arg0: number): Method - /** - * MethodByName returns the method with that name in the type's - * method set and a boolean indicating if the method was found. - * - * For a non-interface type T or *T, the returned Method's Type and Func - * fields describe a function whose first argument is the receiver. - * - * For an interface type, the returned Method's Type field gives the - * method signature, without a receiver, and the Func field is nil. - */ - methodByName(_arg0: string): [Method, boolean] - /** - * NumMethod returns the number of methods accessible using Method. - * - * For a non-interface type, it returns the number of exported methods. - * - * For an interface type, it returns the number of exported and unexported methods. - */ - numMethod(): number - /** - * Name returns the type's name within its package for a defined type. - * For other (non-defined) types it returns the empty string. - */ - name(): string - /** - * PkgPath returns a defined type's package path, that is, the import path - * that uniquely identifies the package, such as "encoding/base64". - * If the type was predeclared (string, error) or not defined (*T, struct{}, - * []int, or A where A is an alias for a non-defined type), the package path - * will be the empty string. - */ - pkgPath(): string - /** - * Size returns the number of bytes needed to store - * a value of the given type; it is analogous to unsafe.Sizeof. - */ - size(): number - /** - * String returns a string representation of the type. - * The string representation may use shortened package names - * (e.g., base64 instead of "encoding/base64") and is not - * guaranteed to be unique among types. To test for type identity, - * compare the Types directly. - */ - string(): string - /** - * Kind returns the specific kind of this type. - */ - kind(): Kind - /** - * Implements reports whether the type implements the interface type u. - */ - implements(u: Type): boolean - /** - * AssignableTo reports whether a value of the type is assignable to type u. - */ - assignableTo(u: Type): boolean - /** - * ConvertibleTo reports whether a value of the type is convertible to type u. - * Even if ConvertibleTo returns true, the conversion may still panic. - * For example, a slice of type []T is convertible to *[N]T, - * but the conversion will panic if its length is less than N. - */ - convertibleTo(u: Type): boolean - /** - * Comparable reports whether values of this type are comparable. - * Even if Comparable returns true, the comparison may still panic. - * For example, values of interface type are comparable, - * but the comparison will panic if their dynamic type is not comparable. - */ - comparable(): boolean - /** - * Bits returns the size of the type in bits. - * It panics if the type's Kind is not one of the - * sized or unsized Int, Uint, Float, or Complex kinds. - */ - bits(): number - /** - * ChanDir returns a channel type's direction. - * It panics if the type's Kind is not Chan. - */ - chanDir(): ChanDir - /** - * IsVariadic reports whether a function type's final input parameter - * is a "..." parameter. If so, t.In(t.NumIn() - 1) returns the parameter's - * implicit actual type []T. - * - * For concreteness, if t represents func(x int, y ... float64), then - * - * ``` - * t.NumIn() == 2 - * t.In(0) is the reflect.Type for "int" - * t.In(1) is the reflect.Type for "[]float64" - * t.IsVariadic() == true - * ``` - * - * IsVariadic panics if the type's Kind is not Func. - */ - isVariadic(): boolean - /** - * Elem returns a type's element type. - * It panics if the type's Kind is not Array, Chan, Map, Pointer, or Slice. - */ - elem(): Type - /** - * Field returns a struct type's i'th field. - * It panics if the type's Kind is not Struct. - * It panics if i is not in the range [0, NumField()). - */ - field(i: number): StructField - /** - * FieldByIndex returns the nested field corresponding - * to the index sequence. It is equivalent to calling Field - * successively for each index i. - * It panics if the type's Kind is not Struct. - */ - fieldByIndex(index: Array): StructField - /** - * FieldByName returns the struct field with the given name - * and a boolean indicating if the field was found. - */ - fieldByName(name: string): [StructField, boolean] - /** - * FieldByNameFunc returns the struct field with a name - * that satisfies the match function and a boolean indicating if - * the field was found. - * - * FieldByNameFunc considers the fields in the struct itself - * and then the fields in any embedded structs, in breadth first order, - * stopping at the shallowest nesting depth containing one or more - * fields satisfying the match function. If multiple fields at that depth - * satisfy the match function, they cancel each other - * and FieldByNameFunc returns no match. - * This behavior mirrors Go's handling of name lookup in - * structs containing embedded fields. - */ - fieldByNameFunc(match: (_arg0: string) => boolean): [StructField, boolean] - /** - * In returns the type of a function type's i'th input parameter. - * It panics if the type's Kind is not Func. - * It panics if i is not in the range [0, NumIn()). - */ - in(i: number): Type - /** - * Key returns a map type's key type. - * It panics if the type's Kind is not Map. - */ - key(): Type - /** - * Len returns an array type's length. - * It panics if the type's Kind is not Array. - */ - len(): number - /** - * NumField returns a struct type's field count. - * It panics if the type's Kind is not Struct. - */ - numField(): number - /** - * NumIn returns a function type's input parameter count. - * It panics if the type's Kind is not Func. - */ - numIn(): number - /** - * NumOut returns a function type's output parameter count. - * It panics if the type's Kind is not Func. - */ - numOut(): number - /** - * Out returns the type of a function type's i'th output parameter. - * It panics if the type's Kind is not Func. - * It panics if i is not in the range [0, NumOut()). - */ - out(i: number): Type - } -} - -/** - * Package url parses URLs and implements query escaping. - */ -namespace url { - /** - * The Userinfo type is an immutable encapsulation of username and - * password details for a URL. An existing Userinfo value is guaranteed - * to have a username set (potentially empty, as allowed by RFC 2396), - * and optionally a password. - */ - interface Userinfo { - } - interface Userinfo { - /** - * Username returns the username. - */ - username(): string - } - interface Userinfo { - /** - * Password returns the password in case it is set, and whether it is set. - */ - password(): [string, boolean] - } - interface Userinfo { - /** - * String returns the encoded userinfo information in the standard form - * of "username[:password]". - */ - string(): string - } -} - /** * Copyright 2021 The Go Authors. All rights reserved. * Use of this source code is governed by a BSD-style @@ -16538,598 +16693,6 @@ namespace x509 { } } -namespace subscriptions { - /** - * Message defines a client's channel data. - */ - interface Message { - name: string - data: string - } - /** - * Client is an interface for a generic subscription client. - */ - interface Client { - /** - * Id Returns the unique id of the client. - */ - id(): string - /** - * Channel returns the client's communication channel. - */ - channel(): undefined - /** - * Subscriptions returns all subscriptions to which the client has subscribed to. - */ - subscriptions(): _TygojaDict - /** - * Subscribe subscribes the client to the provided subscriptions list. - */ - subscribe(...subs: string[]): void - /** - * Unsubscribe unsubscribes the client from the provided subscriptions list. - */ - unsubscribe(...subs: string[]): void - /** - * HasSubscription checks if the client is subscribed to `sub`. - */ - hasSubscription(sub: string): boolean - /** - * Set stores any value to the client's context. - */ - set(key: string, value: any): void - /** - * Unset removes a single value from the client's context. - */ - unset(key: string): void - /** - * Get retrieves the key value from the client's context. - */ - get(key: string): any - /** - * Discard marks the client as "discarded", meaning that it - * shouldn't be used anymore for sending new messages. - * - * It is safe to call Discard() multiple times. - */ - discard(): void - /** - * IsDiscarded indicates whether the client has been "discarded" - * and should no longer be used. - */ - isDiscarded(): boolean - } -} - -/** - * Package bufio implements buffered I/O. It wraps an io.Reader or io.Writer - * object, creating another object (Reader or Writer) that also implements - * the interface but provides buffering and some help for textual I/O. - */ -namespace bufio { - /** - * ReadWriter stores pointers to a Reader and a Writer. - * It implements io.ReadWriter. - */ - type _subySylR = Reader&Writer - interface ReadWriter extends _subySylR { - } -} - -/** - * Package flag implements command-line flag parsing. - * - * # Usage - * - * Define flags using flag.String(), Bool(), Int(), etc. - * - * This declares an integer flag, -n, stored in the pointer nFlag, with type *int: - * - * ``` - * import "flag" - * var nFlag = flag.Int("n", 1234, "help message for flag n") - * ``` - * - * If you like, you can bind the flag to a variable using the Var() functions. - * - * ``` - * var flagvar int - * func init() { - * flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname") - * } - * ``` - * - * Or you can create custom flags that satisfy the Value interface (with - * pointer receivers) and couple them to flag parsing by - * - * ``` - * flag.Var(&flagVal, "name", "help message for flagname") - * ``` - * - * For such flags, the default value is just the initial value of the variable. - * - * After all flags are defined, call - * - * ``` - * flag.Parse() - * ``` - * - * to parse the command line into the defined flags. - * - * Flags may then be used directly. If you're using the flags themselves, - * they are all pointers; if you bind to variables, they're values. - * - * ``` - * fmt.Println("ip has value ", *ip) - * fmt.Println("flagvar has value ", flagvar) - * ``` - * - * After parsing, the arguments following the flags are available as the - * slice flag.Args() or individually as flag.Arg(i). - * The arguments are indexed from 0 through flag.NArg()-1. - * - * # Command line flag syntax - * - * The following forms are permitted: - * - * ``` - * -flag - * --flag // double dashes are also permitted - * -flag=x - * -flag x // non-boolean flags only - * ``` - * - * One or two dashes may be used; they are equivalent. - * The last form is not permitted for boolean flags because the - * meaning of the command - * - * ``` - * cmd -x * - * ``` - * - * where * is a Unix shell wildcard, will change if there is a file - * called 0, false, etc. You must use the -flag=false form to turn - * off a boolean flag. - * - * Flag parsing stops just before the first non-flag argument - * ("-" is a non-flag argument) or after the terminator "--". - * - * Integer flags accept 1234, 0664, 0x1234 and may be negative. - * Boolean flags may be: - * - * ``` - * 1, 0, t, f, T, F, true, false, TRUE, FALSE, True, False - * ``` - * - * Duration flags accept any input valid for time.ParseDuration. - * - * The default set of command-line flags is controlled by - * top-level functions. The FlagSet type allows one to define - * independent sets of flags, such as to implement subcommands - * in a command-line interface. The methods of FlagSet are - * analogous to the top-level functions for the command-line - * flag set. - */ -namespace flag { - /** - * A FlagSet represents a set of defined flags. The zero value of a FlagSet - * has no name and has ContinueOnError error handling. - * - * Flag names must be unique within a FlagSet. An attempt to define a flag whose - * name is already in use will cause a panic. - */ - interface FlagSet { - /** - * Usage is the function called when an error occurs while parsing flags. - * The field is a function (not a method) that may be changed to point to - * a custom error handler. What happens after Usage is called depends - * on the ErrorHandling setting; for the command line, this defaults - * to ExitOnError, which exits the program after calling Usage. - */ - usage: () => void - } - /** - * A Flag represents the state of a flag. - */ - interface Flag { - name: string // name as it appears on command line - usage: string // help message - value: Value // value as set - defValue: string // default value (as text); for usage message - } - interface FlagSet { - /** - * Output returns the destination for usage and error messages. os.Stderr is returned if - * output was not set or was set to nil. - */ - output(): io.Writer - } - interface FlagSet { - /** - * Name returns the name of the flag set. - */ - name(): string - } - interface FlagSet { - /** - * ErrorHandling returns the error handling behavior of the flag set. - */ - errorHandling(): ErrorHandling - } - interface FlagSet { - /** - * SetOutput sets the destination for usage and error messages. - * If output is nil, os.Stderr is used. - */ - setOutput(output: io.Writer): void - } - interface FlagSet { - /** - * VisitAll visits the flags in lexicographical order, calling fn for each. - * It visits all flags, even those not set. - */ - visitAll(fn: (_arg0: Flag) => void): void - } - interface FlagSet { - /** - * Visit visits the flags in lexicographical order, calling fn for each. - * It visits only those flags that have been set. - */ - visit(fn: (_arg0: Flag) => void): void - } - interface FlagSet { - /** - * Lookup returns the Flag structure of the named flag, returning nil if none exists. - */ - lookup(name: string): (Flag | undefined) - } - interface FlagSet { - /** - * Set sets the value of the named flag. - */ - set(name: string): void - } - interface FlagSet { - /** - * PrintDefaults prints, to standard error unless configured otherwise, the - * default values of all defined command-line flags in the set. See the - * documentation for the global function PrintDefaults for more information. - */ - printDefaults(): void - } - interface FlagSet { - /** - * NFlag returns the number of flags that have been set. - */ - nFlag(): number - } - interface FlagSet { - /** - * Arg returns the i'th argument. Arg(0) is the first remaining argument - * after flags have been processed. Arg returns an empty string if the - * requested element does not exist. - */ - arg(i: number): string - } - interface FlagSet { - /** - * NArg is the number of arguments remaining after flags have been processed. - */ - nArg(): number - } - interface FlagSet { - /** - * Args returns the non-flag arguments. - */ - args(): Array - } - interface FlagSet { - /** - * BoolVar defines a bool flag with specified name, default value, and usage string. - * The argument p points to a bool variable in which to store the value of the flag. - */ - boolVar(p: boolean, name: string, value: boolean, usage: string): void - } - interface FlagSet { - /** - * Bool defines a bool flag with specified name, default value, and usage string. - * The return value is the address of a bool variable that stores the value of the flag. - */ - bool(name: string, value: boolean, usage: string): (boolean | undefined) - } - interface FlagSet { - /** - * IntVar defines an int flag with specified name, default value, and usage string. - * The argument p points to an int variable in which to store the value of the flag. - */ - intVar(p: number, name: string, value: number, usage: string): void - } - interface FlagSet { - /** - * Int defines an int flag with specified name, default value, and usage string. - * The return value is the address of an int variable that stores the value of the flag. - */ - int(name: string, value: number, usage: string): (number | undefined) - } - interface FlagSet { - /** - * Int64Var defines an int64 flag with specified name, default value, and usage string. - * The argument p points to an int64 variable in which to store the value of the flag. - */ - int64Var(p: number, name: string, value: number, usage: string): void - } - interface FlagSet { - /** - * Int64 defines an int64 flag with specified name, default value, and usage string. - * The return value is the address of an int64 variable that stores the value of the flag. - */ - int64(name: string, value: number, usage: string): (number | undefined) - } - interface FlagSet { - /** - * UintVar defines a uint flag with specified name, default value, and usage string. - * The argument p points to a uint variable in which to store the value of the flag. - */ - uintVar(p: number, name: string, value: number, usage: string): void - } - interface FlagSet { - /** - * Uint defines a uint flag with specified name, default value, and usage string. - * The return value is the address of a uint variable that stores the value of the flag. - */ - uint(name: string, value: number, usage: string): (number | undefined) - } - interface FlagSet { - /** - * Uint64Var defines a uint64 flag with specified name, default value, and usage string. - * The argument p points to a uint64 variable in which to store the value of the flag. - */ - uint64Var(p: number, name: string, value: number, usage: string): void - } - interface FlagSet { - /** - * Uint64 defines a uint64 flag with specified name, default value, and usage string. - * The return value is the address of a uint64 variable that stores the value of the flag. - */ - uint64(name: string, value: number, usage: string): (number | undefined) - } - interface FlagSet { - /** - * StringVar defines a string flag with specified name, default value, and usage string. - * The argument p points to a string variable in which to store the value of the flag. - */ - stringVar(p: string, name: string, value: string, usage: string): void - } - interface FlagSet { - /** - * String defines a string flag with specified name, default value, and usage string. - * The return value is the address of a string variable that stores the value of the flag. - */ - string(name: string, value: string, usage: string): (string | undefined) - } - interface FlagSet { - /** - * Float64Var defines a float64 flag with specified name, default value, and usage string. - * The argument p points to a float64 variable in which to store the value of the flag. - */ - float64Var(p: number, name: string, value: number, usage: string): void - } - interface FlagSet { - /** - * Float64 defines a float64 flag with specified name, default value, and usage string. - * The return value is the address of a float64 variable that stores the value of the flag. - */ - float64(name: string, value: number, usage: string): (number | undefined) - } - interface FlagSet { - /** - * DurationVar defines a time.Duration flag with specified name, default value, and usage string. - * The argument p points to a time.Duration variable in which to store the value of the flag. - * The flag accepts a value acceptable to time.ParseDuration. - */ - durationVar(p: time.Duration, name: string, value: time.Duration, usage: string): void - } - interface FlagSet { - /** - * Duration defines a time.Duration flag with specified name, default value, and usage string. - * The return value is the address of a time.Duration variable that stores the value of the flag. - * The flag accepts a value acceptable to time.ParseDuration. - */ - duration(name: string, value: time.Duration, usage: string): (time.Duration | undefined) - } - interface FlagSet { - /** - * TextVar defines a flag with a specified name, default value, and usage string. - * The argument p must be a pointer to a variable that will hold the value - * of the flag, and p must implement encoding.TextUnmarshaler. - * If the flag is used, the flag value will be passed to p's UnmarshalText method. - * The type of the default value must be the same as the type of p. - */ - textVar(p: encoding.TextUnmarshaler, name: string, value: encoding.TextMarshaler, usage: string): void - } - interface FlagSet { - /** - * Func defines a flag with the specified name and usage string. - * Each time the flag is seen, fn is called with the value of the flag. - * If fn returns a non-nil error, it will be treated as a flag value parsing error. - */ - func(name: string, fn: (_arg0: string) => void): void - } - interface FlagSet { - /** - * Var defines a flag with the specified name and usage string. The type and - * value of the flag are represented by the first argument, of type Value, which - * typically holds a user-defined implementation of Value. For instance, the - * caller could create a flag that turns a comma-separated string into a slice - * of strings by giving the slice the methods of Value; in particular, Set would - * decompose the comma-separated string into the slice. - */ - var(value: Value, name: string, usage: string): void - } - interface FlagSet { - /** - * Parse parses flag definitions from the argument list, which should not - * include the command name. Must be called after all flags in the FlagSet - * are defined and before flags are accessed by the program. - * The return value will be ErrHelp if -help or -h were set but not defined. - */ - parse(arguments: Array): void - } - interface FlagSet { - /** - * Parsed reports whether f.Parse has been called. - */ - parsed(): boolean - } - interface FlagSet { - /** - * Init sets the name and error handling property for a flag set. - * By default, the zero FlagSet uses an empty name and the - * ContinueOnError error handling policy. - */ - init(name: string, errorHandling: ErrorHandling): void - } -} - -/** - * Package pflag is a drop-in replacement for Go's flag package, implementing - * POSIX/GNU-style --flags. - * - * pflag is compatible with the GNU extensions to the POSIX recommendations - * for command-line options. See - * http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html - * - * Usage: - * - * pflag is a drop-in replacement of Go's native flag package. If you import - * pflag under the name "flag" then all code should continue to function - * with no changes. - * - * ``` - * import flag "github.com/spf13/pflag" - * ``` - * - * There is one exception to this: if you directly instantiate the Flag struct - * there is one more field "Shorthand" that you will need to set. - * Most code never instantiates this struct directly, and instead uses - * functions such as String(), BoolVar(), and Var(), and is therefore - * unaffected. - * - * Define flags using flag.String(), Bool(), Int(), etc. - * - * This declares an integer flag, -flagname, stored in the pointer ip, with type *int. - * ``` - * var ip = flag.Int("flagname", 1234, "help message for flagname") - * ``` - * If you like, you can bind the flag to a variable using the Var() functions. - * ``` - * var flagvar int - * func init() { - * flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname") - * } - * ``` - * Or you can create custom flags that satisfy the Value interface (with - * pointer receivers) and couple them to flag parsing by - * ``` - * flag.Var(&flagVal, "name", "help message for flagname") - * ``` - * For such flags, the default value is just the initial value of the variable. - * - * After all flags are defined, call - * ``` - * flag.Parse() - * ``` - * to parse the command line into the defined flags. - * - * Flags may then be used directly. If you're using the flags themselves, - * they are all pointers; if you bind to variables, they're values. - * ``` - * fmt.Println("ip has value ", *ip) - * fmt.Println("flagvar has value ", flagvar) - * ``` - * - * After parsing, the arguments after the flag are available as the - * slice flag.Args() or individually as flag.Arg(i). - * The arguments are indexed from 0 through flag.NArg()-1. - * - * The pflag package also defines some new functions that are not in flag, - * that give one-letter shorthands for flags. You can use these by appending - * 'P' to the name of any function that defines a flag. - * ``` - * var ip = flag.IntP("flagname", "f", 1234, "help message") - * var flagvar bool - * func init() { - * flag.BoolVarP(&flagvar, "boolname", "b", true, "help message") - * } - * flag.VarP(&flagval, "varname", "v", "help message") - * ``` - * Shorthand letters can be used with single dashes on the command line. - * Boolean shorthand flags can be combined with other shorthand flags. - * - * Command line flag syntax: - * ``` - * --flag // boolean flags only - * --flag=x - * ``` - * - * Unlike the flag package, a single dash before an option means something - * different than a double dash. Single dashes signify a series of shorthand - * letters for flags. All but the last shorthand letter must be boolean flags. - * ``` - * // boolean flags - * -f - * -abc - * // non-boolean flags - * -n 1234 - * -Ifile - * // mixed - * -abcs "hello" - * -abcn1234 - * ``` - * - * Flag parsing stops after the terminator "--". Unlike the flag package, - * flags can be interspersed with arguments anywhere on the command line - * before this terminator. - * - * Integer flags accept 1234, 0664, 0x1234 and may be negative. - * Boolean flags (in their long form) accept 1, 0, t, f, true, false, - * TRUE, FALSE, True, False. - * Duration flags accept any input valid for time.ParseDuration. - * - * The default set of command-line flags is controlled by - * top-level functions. The FlagSet type allows one to define - * independent sets of flags, such as to implement subcommands - * in a command-line interface. The methods of FlagSet are - * analogous to the top-level functions for the command-line - * flag set. - */ -namespace pflag { - // @ts-ignore - import goflag = flag - /** - * ErrorHandling defines how to handle flag parsing errors. - */ - interface ErrorHandling extends Number{} - /** - * ParseErrorsWhitelist defines the parsing errors that can be ignored - */ - interface ParseErrorsWhitelist { - /** - * UnknownFlags will ignore unknown flags errors and continue parsing rest of the flags - */ - unknownFlags: boolean - } - /** - * Value is the interface to the dynamic value stored in a flag. - * (The default value is represented as a string.) - */ - interface Value { - string(): string - set(_arg0: string): void - type(): string - } -} - /** * Package multipart implements MIME multipart parsing, as defined in RFC * 2046. @@ -17731,116 +17294,39 @@ namespace mailer { } } -/** - * Package driver defines interfaces to be implemented by database - * drivers as used by package sql. - * - * Most code should use package sql. - * - * The driver interface has evolved over time. Drivers should implement - * Connector and DriverContext interfaces. - * The Connector.Connect and Driver.Open methods should never return ErrBadConn. - * ErrBadConn should only be returned from Validator, SessionResetter, or - * a query method if the connection is already in an invalid (e.g. closed) state. - * - * All Conn implementations should implement the following interfaces: - * Pinger, SessionResetter, and Validator. - * - * If named parameters or context are supported, the driver's Conn should implement: - * ExecerContext, QueryerContext, ConnPrepareContext, and ConnBeginTx. - * - * To support custom data types, implement NamedValueChecker. NamedValueChecker - * also allows queries to accept per-query options as a parameter by returning - * ErrRemoveArgument from CheckNamedValue. - * - * If multiple result sets are supported, Rows should implement RowsNextResultSet. - * If the driver knows how to describe the types present in the returned result - * it should implement the following interfaces: RowsColumnTypeScanType, - * RowsColumnTypeDatabaseTypeName, RowsColumnTypeLength, RowsColumnTypeNullable, - * and RowsColumnTypePrecisionScale. A given row value may also return a Rows - * type, which may represent a database cursor value. - * - * Before a connection is returned to the connection pool after use, IsValid is - * called if implemented. Before a connection is reused for another query, - * ResetSession is called if implemented. If a connection is never returned to the - * connection pool but immediately reused, then ResetSession is called prior to - * reuse but IsValid is not called. - */ -namespace driver { +namespace search { /** - * Conn is a connection to a database. It is not used concurrently - * by multiple goroutines. - * - * Conn is assumed to be stateful. + * Result defines the returned search result structure. */ - interface Conn { - /** - * Prepare returns a prepared statement, bound to this connection. - */ - prepare(query: string): Stmt - /** - * Close invalidates and potentially stops any current - * prepared statements and transactions, marking this - * connection as no longer in use. - * - * Because the sql package maintains a free pool of - * connections and only calls Close when there's a surplus of - * idle connections, it shouldn't be necessary for drivers to - * do their own connection caching. - * - * Drivers must ensure all network calls made by Close - * do not block indefinitely (e.g. apply a timeout). - */ - close(): void - /** - * Begin starts and returns a new transaction. - * - * Deprecated: Drivers should implement ConnBeginTx instead (or additionally). - */ - begin(): Tx + interface Result { + page: number + perPage: number + totalItems: number + totalPages: number + items: any } } -/** - * Package types implements some commonly used db serializable types - * like datetime, json, etc. - */ -namespace types { - /** - * JsonRaw defines a json value type that is safe for db read/write. - */ - interface JsonRaw extends String{} - interface JsonRaw { - /** - * String returns the current JsonRaw instance as a json encoded string. - */ - string(): string +namespace settings { + // @ts-ignore + import validation = ozzo_validation + interface EmailTemplate { + body: string + subject: string + actionUrl: string } - interface JsonRaw { + interface EmailTemplate { /** - * MarshalJSON implements the [json.Marshaler] interface. + * Validate makes EmailTemplate validatable by implementing [validation.Validatable] interface. */ - marshalJSON(): string + validate(): void } - interface JsonRaw { + interface EmailTemplate { /** - * UnmarshalJSON implements the [json.Unmarshaler] interface. + * Resolve replaces the placeholder parameters in the current email + * template and returns its components as ready-to-use strings. */ - unmarshalJSON(b: string): void - } - interface JsonRaw { - /** - * Value implements the [driver.Valuer] interface. - */ - value(): driver.Value - } - interface JsonRaw { - /** - * Scan implements [sql.Scanner] interface to scan the provided value - * into the current JsonRaw instance. - */ - scan(value: { - }): void + resolve(appName: string, appUrl: string): string } } @@ -17852,21 +17338,71 @@ namespace hook { /** * wrapped local Hook embedded struct to limit the public API surface. */ - type _subqpZpu = Hook - interface mainHook extends _subqpZpu { + type _subAUkZj = Hook + interface mainHook extends _subAUkZj { } } -namespace search { +namespace subscriptions { /** - * Result defines the returned search result structure. + * Message defines a client's channel data. */ - interface Result { - page: number - perPage: number - totalItems: number - totalPages: number - items: any + interface Message { + name: string + data: string + } + /** + * Client is an interface for a generic subscription client. + */ + interface Client { + /** + * Id Returns the unique id of the client. + */ + id(): string + /** + * Channel returns the client's communication channel. + */ + channel(): undefined + /** + * Subscriptions returns all subscriptions to which the client has subscribed to. + */ + subscriptions(): _TygojaDict + /** + * Subscribe subscribes the client to the provided subscriptions list. + */ + subscribe(...subs: string[]): void + /** + * Unsubscribe unsubscribes the client from the provided subscriptions list. + */ + unsubscribe(...subs: string[]): void + /** + * HasSubscription checks if the client is subscribed to `sub`. + */ + hasSubscription(sub: string): boolean + /** + * Set stores any value to the client's context. + */ + set(key: string, value: any): void + /** + * Unset removes a single value from the client's context. + */ + unset(key: string): void + /** + * Get retrieves the key value from the client's context. + */ + get(key: string): any + /** + * Discard marks the client as "discarded", meaning that it + * shouldn't be used anymore for sending new messages. + * + * It is safe to call Discard() multiple times. + */ + discard(): void + /** + * IsDiscarded indicates whether the client has been "discarded" + * and should no longer be used. + */ + isDiscarded(): boolean } } @@ -18037,29 +17573,6 @@ namespace autocert { } } -namespace settings { - // @ts-ignore - import validation = ozzo_validation - interface EmailTemplate { - body: string - subject: string - actionUrl: string - } - interface EmailTemplate { - /** - * Validate makes EmailTemplate validatable by implementing [validation.Validatable] interface. - */ - validate(): void - } - interface EmailTemplate { - /** - * Resolve replaces the placeholder parameters in the current email - * template and returns its components as ready-to-use strings. - */ - resolve(appName: string, appUrl: string): string - } -} - /** * Package core is the backbone of PocketBase. * @@ -18080,6 +17593,520 @@ namespace core { } } +/** + * Package flag implements command-line flag parsing. + * + * # Usage + * + * Define flags using flag.String(), Bool(), Int(), etc. + * + * This declares an integer flag, -n, stored in the pointer nFlag, with type *int: + * + * ``` + * import "flag" + * var nFlag = flag.Int("n", 1234, "help message for flag n") + * ``` + * + * If you like, you can bind the flag to a variable using the Var() functions. + * + * ``` + * var flagvar int + * func init() { + * flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname") + * } + * ``` + * + * Or you can create custom flags that satisfy the Value interface (with + * pointer receivers) and couple them to flag parsing by + * + * ``` + * flag.Var(&flagVal, "name", "help message for flagname") + * ``` + * + * For such flags, the default value is just the initial value of the variable. + * + * After all flags are defined, call + * + * ``` + * flag.Parse() + * ``` + * + * to parse the command line into the defined flags. + * + * Flags may then be used directly. If you're using the flags themselves, + * they are all pointers; if you bind to variables, they're values. + * + * ``` + * fmt.Println("ip has value ", *ip) + * fmt.Println("flagvar has value ", flagvar) + * ``` + * + * After parsing, the arguments following the flags are available as the + * slice flag.Args() or individually as flag.Arg(i). + * The arguments are indexed from 0 through flag.NArg()-1. + * + * # Command line flag syntax + * + * The following forms are permitted: + * + * ``` + * -flag + * --flag // double dashes are also permitted + * -flag=x + * -flag x // non-boolean flags only + * ``` + * + * One or two dashes may be used; they are equivalent. + * The last form is not permitted for boolean flags because the + * meaning of the command + * + * ``` + * cmd -x * + * ``` + * + * where * is a Unix shell wildcard, will change if there is a file + * called 0, false, etc. You must use the -flag=false form to turn + * off a boolean flag. + * + * Flag parsing stops just before the first non-flag argument + * ("-" is a non-flag argument) or after the terminator "--". + * + * Integer flags accept 1234, 0664, 0x1234 and may be negative. + * Boolean flags may be: + * + * ``` + * 1, 0, t, f, T, F, true, false, TRUE, FALSE, True, False + * ``` + * + * Duration flags accept any input valid for time.ParseDuration. + * + * The default set of command-line flags is controlled by + * top-level functions. The FlagSet type allows one to define + * independent sets of flags, such as to implement subcommands + * in a command-line interface. The methods of FlagSet are + * analogous to the top-level functions for the command-line + * flag set. + */ +namespace flag { + /** + * A FlagSet represents a set of defined flags. The zero value of a FlagSet + * has no name and has ContinueOnError error handling. + * + * Flag names must be unique within a FlagSet. An attempt to define a flag whose + * name is already in use will cause a panic. + */ + interface FlagSet { + /** + * Usage is the function called when an error occurs while parsing flags. + * The field is a function (not a method) that may be changed to point to + * a custom error handler. What happens after Usage is called depends + * on the ErrorHandling setting; for the command line, this defaults + * to ExitOnError, which exits the program after calling Usage. + */ + usage: () => void + } + /** + * A Flag represents the state of a flag. + */ + interface Flag { + name: string // name as it appears on command line + usage: string // help message + value: Value // value as set + defValue: string // default value (as text); for usage message + } + interface FlagSet { + /** + * Output returns the destination for usage and error messages. os.Stderr is returned if + * output was not set or was set to nil. + */ + output(): io.Writer + } + interface FlagSet { + /** + * Name returns the name of the flag set. + */ + name(): string + } + interface FlagSet { + /** + * ErrorHandling returns the error handling behavior of the flag set. + */ + errorHandling(): ErrorHandling + } + interface FlagSet { + /** + * SetOutput sets the destination for usage and error messages. + * If output is nil, os.Stderr is used. + */ + setOutput(output: io.Writer): void + } + interface FlagSet { + /** + * VisitAll visits the flags in lexicographical order, calling fn for each. + * It visits all flags, even those not set. + */ + visitAll(fn: (_arg0: Flag) => void): void + } + interface FlagSet { + /** + * Visit visits the flags in lexicographical order, calling fn for each. + * It visits only those flags that have been set. + */ + visit(fn: (_arg0: Flag) => void): void + } + interface FlagSet { + /** + * Lookup returns the Flag structure of the named flag, returning nil if none exists. + */ + lookup(name: string): (Flag | undefined) + } + interface FlagSet { + /** + * Set sets the value of the named flag. + */ + set(name: string): void + } + interface FlagSet { + /** + * PrintDefaults prints, to standard error unless configured otherwise, the + * default values of all defined command-line flags in the set. See the + * documentation for the global function PrintDefaults for more information. + */ + printDefaults(): void + } + interface FlagSet { + /** + * NFlag returns the number of flags that have been set. + */ + nFlag(): number + } + interface FlagSet { + /** + * Arg returns the i'th argument. Arg(0) is the first remaining argument + * after flags have been processed. Arg returns an empty string if the + * requested element does not exist. + */ + arg(i: number): string + } + interface FlagSet { + /** + * NArg is the number of arguments remaining after flags have been processed. + */ + nArg(): number + } + interface FlagSet { + /** + * Args returns the non-flag arguments. + */ + args(): Array + } + interface FlagSet { + /** + * BoolVar defines a bool flag with specified name, default value, and usage string. + * The argument p points to a bool variable in which to store the value of the flag. + */ + boolVar(p: boolean, name: string, value: boolean, usage: string): void + } + interface FlagSet { + /** + * Bool defines a bool flag with specified name, default value, and usage string. + * The return value is the address of a bool variable that stores the value of the flag. + */ + bool(name: string, value: boolean, usage: string): (boolean | undefined) + } + interface FlagSet { + /** + * IntVar defines an int flag with specified name, default value, and usage string. + * The argument p points to an int variable in which to store the value of the flag. + */ + intVar(p: number, name: string, value: number, usage: string): void + } + interface FlagSet { + /** + * Int defines an int flag with specified name, default value, and usage string. + * The return value is the address of an int variable that stores the value of the flag. + */ + int(name: string, value: number, usage: string): (number | undefined) + } + interface FlagSet { + /** + * Int64Var defines an int64 flag with specified name, default value, and usage string. + * The argument p points to an int64 variable in which to store the value of the flag. + */ + int64Var(p: number, name: string, value: number, usage: string): void + } + interface FlagSet { + /** + * Int64 defines an int64 flag with specified name, default value, and usage string. + * The return value is the address of an int64 variable that stores the value of the flag. + */ + int64(name: string, value: number, usage: string): (number | undefined) + } + interface FlagSet { + /** + * UintVar defines a uint flag with specified name, default value, and usage string. + * The argument p points to a uint variable in which to store the value of the flag. + */ + uintVar(p: number, name: string, value: number, usage: string): void + } + interface FlagSet { + /** + * Uint defines a uint flag with specified name, default value, and usage string. + * The return value is the address of a uint variable that stores the value of the flag. + */ + uint(name: string, value: number, usage: string): (number | undefined) + } + interface FlagSet { + /** + * Uint64Var defines a uint64 flag with specified name, default value, and usage string. + * The argument p points to a uint64 variable in which to store the value of the flag. + */ + uint64Var(p: number, name: string, value: number, usage: string): void + } + interface FlagSet { + /** + * Uint64 defines a uint64 flag with specified name, default value, and usage string. + * The return value is the address of a uint64 variable that stores the value of the flag. + */ + uint64(name: string, value: number, usage: string): (number | undefined) + } + interface FlagSet { + /** + * StringVar defines a string flag with specified name, default value, and usage string. + * The argument p points to a string variable in which to store the value of the flag. + */ + stringVar(p: string, name: string, value: string, usage: string): void + } + interface FlagSet { + /** + * String defines a string flag with specified name, default value, and usage string. + * The return value is the address of a string variable that stores the value of the flag. + */ + string(name: string, value: string, usage: string): (string | undefined) + } + interface FlagSet { + /** + * Float64Var defines a float64 flag with specified name, default value, and usage string. + * The argument p points to a float64 variable in which to store the value of the flag. + */ + float64Var(p: number, name: string, value: number, usage: string): void + } + interface FlagSet { + /** + * Float64 defines a float64 flag with specified name, default value, and usage string. + * The return value is the address of a float64 variable that stores the value of the flag. + */ + float64(name: string, value: number, usage: string): (number | undefined) + } + interface FlagSet { + /** + * DurationVar defines a time.Duration flag with specified name, default value, and usage string. + * The argument p points to a time.Duration variable in which to store the value of the flag. + * The flag accepts a value acceptable to time.ParseDuration. + */ + durationVar(p: time.Duration, name: string, value: time.Duration, usage: string): void + } + interface FlagSet { + /** + * Duration defines a time.Duration flag with specified name, default value, and usage string. + * The return value is the address of a time.Duration variable that stores the value of the flag. + * The flag accepts a value acceptable to time.ParseDuration. + */ + duration(name: string, value: time.Duration, usage: string): (time.Duration | undefined) + } + interface FlagSet { + /** + * TextVar defines a flag with a specified name, default value, and usage string. + * The argument p must be a pointer to a variable that will hold the value + * of the flag, and p must implement encoding.TextUnmarshaler. + * If the flag is used, the flag value will be passed to p's UnmarshalText method. + * The type of the default value must be the same as the type of p. + */ + textVar(p: encoding.TextUnmarshaler, name: string, value: encoding.TextMarshaler, usage: string): void + } + interface FlagSet { + /** + * Func defines a flag with the specified name and usage string. + * Each time the flag is seen, fn is called with the value of the flag. + * If fn returns a non-nil error, it will be treated as a flag value parsing error. + */ + func(name: string, fn: (_arg0: string) => void): void + } + interface FlagSet { + /** + * Var defines a flag with the specified name and usage string. The type and + * value of the flag are represented by the first argument, of type Value, which + * typically holds a user-defined implementation of Value. For instance, the + * caller could create a flag that turns a comma-separated string into a slice + * of strings by giving the slice the methods of Value; in particular, Set would + * decompose the comma-separated string into the slice. + */ + var(value: Value, name: string, usage: string): void + } + interface FlagSet { + /** + * Parse parses flag definitions from the argument list, which should not + * include the command name. Must be called after all flags in the FlagSet + * are defined and before flags are accessed by the program. + * The return value will be ErrHelp if -help or -h were set but not defined. + */ + parse(arguments: Array): void + } + interface FlagSet { + /** + * Parsed reports whether f.Parse has been called. + */ + parsed(): boolean + } + interface FlagSet { + /** + * Init sets the name and error handling property for a flag set. + * By default, the zero FlagSet uses an empty name and the + * ContinueOnError error handling policy. + */ + init(name: string, errorHandling: ErrorHandling): void + } +} + +/** + * Package pflag is a drop-in replacement for Go's flag package, implementing + * POSIX/GNU-style --flags. + * + * pflag is compatible with the GNU extensions to the POSIX recommendations + * for command-line options. See + * http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html + * + * Usage: + * + * pflag is a drop-in replacement of Go's native flag package. If you import + * pflag under the name "flag" then all code should continue to function + * with no changes. + * + * ``` + * import flag "github.com/spf13/pflag" + * ``` + * + * There is one exception to this: if you directly instantiate the Flag struct + * there is one more field "Shorthand" that you will need to set. + * Most code never instantiates this struct directly, and instead uses + * functions such as String(), BoolVar(), and Var(), and is therefore + * unaffected. + * + * Define flags using flag.String(), Bool(), Int(), etc. + * + * This declares an integer flag, -flagname, stored in the pointer ip, with type *int. + * ``` + * var ip = flag.Int("flagname", 1234, "help message for flagname") + * ``` + * If you like, you can bind the flag to a variable using the Var() functions. + * ``` + * var flagvar int + * func init() { + * flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname") + * } + * ``` + * Or you can create custom flags that satisfy the Value interface (with + * pointer receivers) and couple them to flag parsing by + * ``` + * flag.Var(&flagVal, "name", "help message for flagname") + * ``` + * For such flags, the default value is just the initial value of the variable. + * + * After all flags are defined, call + * ``` + * flag.Parse() + * ``` + * to parse the command line into the defined flags. + * + * Flags may then be used directly. If you're using the flags themselves, + * they are all pointers; if you bind to variables, they're values. + * ``` + * fmt.Println("ip has value ", *ip) + * fmt.Println("flagvar has value ", flagvar) + * ``` + * + * After parsing, the arguments after the flag are available as the + * slice flag.Args() or individually as flag.Arg(i). + * The arguments are indexed from 0 through flag.NArg()-1. + * + * The pflag package also defines some new functions that are not in flag, + * that give one-letter shorthands for flags. You can use these by appending + * 'P' to the name of any function that defines a flag. + * ``` + * var ip = flag.IntP("flagname", "f", 1234, "help message") + * var flagvar bool + * func init() { + * flag.BoolVarP(&flagvar, "boolname", "b", true, "help message") + * } + * flag.VarP(&flagval, "varname", "v", "help message") + * ``` + * Shorthand letters can be used with single dashes on the command line. + * Boolean shorthand flags can be combined with other shorthand flags. + * + * Command line flag syntax: + * ``` + * --flag // boolean flags only + * --flag=x + * ``` + * + * Unlike the flag package, a single dash before an option means something + * different than a double dash. Single dashes signify a series of shorthand + * letters for flags. All but the last shorthand letter must be boolean flags. + * ``` + * // boolean flags + * -f + * -abc + * // non-boolean flags + * -n 1234 + * -Ifile + * // mixed + * -abcs "hello" + * -abcn1234 + * ``` + * + * Flag parsing stops after the terminator "--". Unlike the flag package, + * flags can be interspersed with arguments anywhere on the command line + * before this terminator. + * + * Integer flags accept 1234, 0664, 0x1234 and may be negative. + * Boolean flags (in their long form) accept 1, 0, t, f, true, false, + * TRUE, FALSE, True, False. + * Duration flags accept any input valid for time.ParseDuration. + * + * The default set of command-line flags is controlled by + * top-level functions. The FlagSet type allows one to define + * independent sets of flags, such as to implement subcommands + * in a command-line interface. The methods of FlagSet are + * analogous to the top-level functions for the command-line + * flag set. + */ +namespace pflag { + // @ts-ignore + import goflag = flag + /** + * ErrorHandling defines how to handle flag parsing errors. + */ + interface ErrorHandling extends Number{} + /** + * ParseErrorsWhitelist defines the parsing errors that can be ignored + */ + interface ParseErrorsWhitelist { + /** + * UnknownFlags will ignore unknown flags errors and continue parsing rest of the flags + */ + unknownFlags: boolean + } + /** + * Value is the interface to the dynamic value stored in a flag. + * (The default value is represented as a string.) + */ + interface Value { + string(): string + set(_arg0: string): void + type(): string + } +} + /** * Package reflect implements run-time reflection, allowing a program to * manipulate objects with arbitrary types. The typical use is to take a value @@ -18211,135 +18238,6 @@ namespace fs { } } -/** - * Package log implements a simple logging package. It defines a type, Logger, - * with methods for formatting output. It also has a predefined 'standard' - * Logger accessible through helper functions Print[f|ln], Fatal[f|ln], and - * Panic[f|ln], which are easier to use than creating a Logger manually. - * That logger writes to standard error and prints the date and time - * of each logged message. - * Every log message is output on a separate line: if the message being - * printed does not end in a newline, the logger will add one. - * The Fatal functions call os.Exit(1) after writing the log message. - * The Panic functions call panic after writing the log message. - */ -namespace log { - /** - * A Logger represents an active logging object that generates lines of - * output to an io.Writer. Each logging operation makes a single call to - * the Writer's Write method. A Logger can be used simultaneously from - * multiple goroutines; it guarantees to serialize access to the Writer. - */ - interface Logger { - } - interface Logger { - /** - * SetOutput sets the output destination for the logger. - */ - setOutput(w: io.Writer): void - } - interface Logger { - /** - * Output writes the output for a logging event. The string s contains - * the text to print after the prefix specified by the flags of the - * Logger. A newline is appended if the last character of s is not - * already a newline. Calldepth is used to recover the PC and is - * provided for generality, although at the moment on all pre-defined - * paths it will be 2. - */ - output(calldepth: number, s: string): void - } - interface Logger { - /** - * Printf calls l.Output to print to the logger. - * Arguments are handled in the manner of fmt.Printf. - */ - printf(format: string, ...v: any[]): void - } - interface Logger { - /** - * Print calls l.Output to print to the logger. - * Arguments are handled in the manner of fmt.Print. - */ - print(...v: any[]): void - } - interface Logger { - /** - * Println calls l.Output to print to the logger. - * Arguments are handled in the manner of fmt.Println. - */ - println(...v: any[]): void - } - interface Logger { - /** - * Fatal is equivalent to l.Print() followed by a call to os.Exit(1). - */ - fatal(...v: any[]): void - } - interface Logger { - /** - * Fatalf is equivalent to l.Printf() followed by a call to os.Exit(1). - */ - fatalf(format: string, ...v: any[]): void - } - interface Logger { - /** - * Fatalln is equivalent to l.Println() followed by a call to os.Exit(1). - */ - fatalln(...v: any[]): void - } - interface Logger { - /** - * Panic is equivalent to l.Print() followed by a call to panic(). - */ - panic(...v: any[]): void - } - interface Logger { - /** - * Panicf is equivalent to l.Printf() followed by a call to panic(). - */ - panicf(format: string, ...v: any[]): void - } - interface Logger { - /** - * Panicln is equivalent to l.Println() followed by a call to panic(). - */ - panicln(...v: any[]): void - } - interface Logger { - /** - * Flags returns the output flags for the logger. - * The flag bits are Ldate, Ltime, and so on. - */ - flags(): number - } - interface Logger { - /** - * SetFlags sets the output flags for the logger. - * The flag bits are Ldate, Ltime, and so on. - */ - setFlags(flag: number): void - } - interface Logger { - /** - * Prefix returns the output prefix for the logger. - */ - prefix(): string - } - interface Logger { - /** - * SetPrefix sets the output prefix for the logger. - */ - setPrefix(prefix: string): void - } - interface Logger { - /** - * Writer returns the output destination for the logger. - */ - writer(): io.Writer - } -} - /** * Package big implements arbitrary-precision arithmetic (big numbers). * The following numeric types are supported: @@ -19099,6 +18997,269 @@ namespace pkix { } } +/** + * Package bufio implements buffered I/O. It wraps an io.Reader or io.Writer + * object, creating another object (Reader or Writer) that also implements + * the interface but provides buffering and some help for textual I/O. + */ +namespace bufio { + /** + * Reader implements buffering for an io.Reader object. + */ + interface Reader { + } + interface Reader { + /** + * Size returns the size of the underlying buffer in bytes. + */ + size(): number + } + interface Reader { + /** + * Reset discards any buffered data, resets all state, and switches + * the buffered reader to read from r. + * Calling Reset on the zero value of Reader initializes the internal buffer + * to the default size. + */ + reset(r: io.Reader): void + } + interface Reader { + /** + * Peek returns the next n bytes without advancing the reader. The bytes stop + * being valid at the next read call. If Peek returns fewer than n bytes, it + * also returns an error explaining why the read is short. The error is + * ErrBufferFull if n is larger than b's buffer size. + * + * Calling Peek prevents a UnreadByte or UnreadRune call from succeeding + * until the next read operation. + */ + peek(n: number): string + } + interface Reader { + /** + * Discard skips the next n bytes, returning the number of bytes discarded. + * + * If Discard skips fewer than n bytes, it also returns an error. + * If 0 <= n <= b.Buffered(), Discard is guaranteed to succeed without + * reading from the underlying io.Reader. + */ + discard(n: number): number + } + interface Reader { + /** + * Read reads data into p. + * It returns the number of bytes read into p. + * The bytes are taken from at most one Read on the underlying Reader, + * hence n may be less than len(p). + * To read exactly len(p) bytes, use io.ReadFull(b, p). + * If the underlying Reader can return a non-zero count with io.EOF, + * then this Read method can do so as well; see the [io.Reader] docs. + */ + read(p: string): number + } + interface Reader { + /** + * ReadByte reads and returns a single byte. + * If no byte is available, returns an error. + */ + readByte(): string + } + interface Reader { + /** + * UnreadByte unreads the last byte. Only the most recently read byte can be unread. + * + * UnreadByte returns an error if the most recent method called on the + * Reader was not a read operation. Notably, Peek, Discard, and WriteTo are not + * considered read operations. + */ + unreadByte(): void + } + interface Reader { + /** + * ReadRune reads a single UTF-8 encoded Unicode character and returns the + * rune and its size in bytes. If the encoded rune is invalid, it consumes one byte + * and returns unicode.ReplacementChar (U+FFFD) with a size of 1. + */ + readRune(): [string, number] + } + interface Reader { + /** + * UnreadRune unreads the last rune. If the most recent method called on + * the Reader was not a ReadRune, UnreadRune returns an error. (In this + * regard it is stricter than UnreadByte, which will unread the last byte + * from any read operation.) + */ + unreadRune(): void + } + interface Reader { + /** + * Buffered returns the number of bytes that can be read from the current buffer. + */ + buffered(): number + } + interface Reader { + /** + * ReadSlice reads until the first occurrence of delim in the input, + * returning a slice pointing at the bytes in the buffer. + * The bytes stop being valid at the next read. + * If ReadSlice encounters an error before finding a delimiter, + * it returns all the data in the buffer and the error itself (often io.EOF). + * ReadSlice fails with error ErrBufferFull if the buffer fills without a delim. + * Because the data returned from ReadSlice will be overwritten + * by the next I/O operation, most clients should use + * ReadBytes or ReadString instead. + * ReadSlice returns err != nil if and only if line does not end in delim. + */ + readSlice(delim: string): string + } + interface Reader { + /** + * ReadLine is a low-level line-reading primitive. Most callers should use + * ReadBytes('\n') or ReadString('\n') instead or use a Scanner. + * + * ReadLine tries to return a single line, not including the end-of-line bytes. + * If the line was too long for the buffer then isPrefix is set and the + * beginning of the line is returned. The rest of the line will be returned + * from future calls. isPrefix will be false when returning the last fragment + * of the line. The returned buffer is only valid until the next call to + * ReadLine. ReadLine either returns a non-nil line or it returns an error, + * never both. + * + * The text returned from ReadLine does not include the line end ("\r\n" or "\n"). + * No indication or error is given if the input ends without a final line end. + * Calling UnreadByte after ReadLine will always unread the last byte read + * (possibly a character belonging to the line end) even if that byte is not + * part of the line returned by ReadLine. + */ + readLine(): [string, boolean] + } + interface Reader { + /** + * ReadBytes reads until the first occurrence of delim in the input, + * returning a slice containing the data up to and including the delimiter. + * If ReadBytes encounters an error before finding a delimiter, + * it returns the data read before the error and the error itself (often io.EOF). + * ReadBytes returns err != nil if and only if the returned data does not end in + * delim. + * For simple uses, a Scanner may be more convenient. + */ + readBytes(delim: string): string + } + interface Reader { + /** + * ReadString reads until the first occurrence of delim in the input, + * returning a string containing the data up to and including the delimiter. + * If ReadString encounters an error before finding a delimiter, + * it returns the data read before the error and the error itself (often io.EOF). + * ReadString returns err != nil if and only if the returned data does not end in + * delim. + * For simple uses, a Scanner may be more convenient. + */ + readString(delim: string): string + } + interface Reader { + /** + * WriteTo implements io.WriterTo. + * This may make multiple calls to the Read method of the underlying Reader. + * If the underlying reader supports the WriteTo method, + * this calls the underlying WriteTo without buffering. + */ + writeTo(w: io.Writer): number + } + /** + * Writer implements buffering for an io.Writer object. + * If an error occurs writing to a Writer, no more data will be + * accepted and all subsequent writes, and Flush, will return the error. + * After all data has been written, the client should call the + * Flush method to guarantee all data has been forwarded to + * the underlying io.Writer. + */ + interface Writer { + } + interface Writer { + /** + * Size returns the size of the underlying buffer in bytes. + */ + size(): number + } + interface Writer { + /** + * Reset discards any unflushed buffered data, clears any error, and + * resets b to write its output to w. + * Calling Reset on the zero value of Writer initializes the internal buffer + * to the default size. + */ + reset(w: io.Writer): void + } + interface Writer { + /** + * Flush writes any buffered data to the underlying io.Writer. + */ + flush(): void + } + interface Writer { + /** + * Available returns how many bytes are unused in the buffer. + */ + available(): number + } + interface Writer { + /** + * AvailableBuffer returns an empty buffer with b.Available() capacity. + * This buffer is intended to be appended to and + * passed to an immediately succeeding Write call. + * The buffer is only valid until the next write operation on b. + */ + availableBuffer(): string + } + interface Writer { + /** + * Buffered returns the number of bytes that have been written into the current buffer. + */ + buffered(): number + } + interface Writer { + /** + * Write writes the contents of p into the buffer. + * It returns the number of bytes written. + * If nn < len(p), it also returns an error explaining + * why the write is short. + */ + write(p: string): number + } + interface Writer { + /** + * WriteByte writes a single byte. + */ + writeByte(c: string): void + } + interface Writer { + /** + * WriteRune writes a single Unicode code point, returning + * the number of bytes written and any error. + */ + writeRune(r: string): number + } + interface Writer { + /** + * WriteString writes a string. + * It returns the number of bytes written. + * If the count is less than len(s), it also returns an error explaining + * why the write is short. + */ + writeString(s: string): number + } + interface Writer { + /** + * ReadFrom implements io.ReaderFrom. If the underlying writer + * supports the ReadFrom method, this calls the underlying ReadFrom. + * If there is buffered data and an underlying ReadFrom, this fills + * the buffer and writes it before calling ReadFrom. + */ + readFrom(r: io.Reader): number + } +} + /** * Package net provides a portable interface for network I/O, including * TCP/IP, UDP, domain name resolution, and Unix domain sockets. @@ -19686,297 +19847,131 @@ namespace tls { } /** - * Package encoding defines interfaces shared by other packages that - * convert data to and from byte-level and textual representations. - * Packages that check for these interfaces include encoding/gob, - * encoding/json, and encoding/xml. As a result, implementing an - * interface once can make a type useful in multiple encodings. - * Standard types that implement these interfaces include time.Time and net.IP. - * The interfaces come in pairs that produce and consume encoded data. + * Package log implements a simple logging package. It defines a type, Logger, + * with methods for formatting output. It also has a predefined 'standard' + * Logger accessible through helper functions Print[f|ln], Fatal[f|ln], and + * Panic[f|ln], which are easier to use than creating a Logger manually. + * That logger writes to standard error and prints the date and time + * of each logged message. + * Every log message is output on a separate line: if the message being + * printed does not end in a newline, the logger will add one. + * The Fatal functions call os.Exit(1) after writing the log message. + * The Panic functions call panic after writing the log message. */ -namespace encoding { +namespace log { /** - * TextMarshaler is the interface implemented by an object that can - * marshal itself into a textual form. - * - * MarshalText encodes the receiver into UTF-8-encoded text and returns the result. + * A Logger represents an active logging object that generates lines of + * output to an io.Writer. Each logging operation makes a single call to + * the Writer's Write method. A Logger can be used simultaneously from + * multiple goroutines; it guarantees to serialize access to the Writer. */ - interface TextMarshaler { - marshalText(): string + interface Logger { } - /** - * TextUnmarshaler is the interface implemented by an object that can - * unmarshal a textual representation of itself. - * - * UnmarshalText must be able to decode the form generated by MarshalText. - * UnmarshalText must copy the text if it wishes to retain the text - * after returning. - */ - interface TextUnmarshaler { - unmarshalText(text: string): void - } -} - -/** - * Package bufio implements buffered I/O. It wraps an io.Reader or io.Writer - * object, creating another object (Reader or Writer) that also implements - * the interface but provides buffering and some help for textual I/O. - */ -namespace bufio { - /** - * Reader implements buffering for an io.Reader object. - */ - interface Reader { - } - interface Reader { + interface Logger { /** - * Size returns the size of the underlying buffer in bytes. + * SetOutput sets the output destination for the logger. */ - size(): number + setOutput(w: io.Writer): void } - interface Reader { + interface Logger { /** - * Reset discards any buffered data, resets all state, and switches - * the buffered reader to read from r. - * Calling Reset on the zero value of Reader initializes the internal buffer - * to the default size. + * Output writes the output for a logging event. The string s contains + * the text to print after the prefix specified by the flags of the + * Logger. A newline is appended if the last character of s is not + * already a newline. Calldepth is used to recover the PC and is + * provided for generality, although at the moment on all pre-defined + * paths it will be 2. */ - reset(r: io.Reader): void + output(calldepth: number, s: string): void } - interface Reader { + interface Logger { /** - * Peek returns the next n bytes without advancing the reader. The bytes stop - * being valid at the next read call. If Peek returns fewer than n bytes, it - * also returns an error explaining why the read is short. The error is - * ErrBufferFull if n is larger than b's buffer size. - * - * Calling Peek prevents a UnreadByte or UnreadRune call from succeeding - * until the next read operation. + * Printf calls l.Output to print to the logger. + * Arguments are handled in the manner of fmt.Printf. */ - peek(n: number): string + printf(format: string, ...v: any[]): void } - interface Reader { + interface Logger { /** - * Discard skips the next n bytes, returning the number of bytes discarded. - * - * If Discard skips fewer than n bytes, it also returns an error. - * If 0 <= n <= b.Buffered(), Discard is guaranteed to succeed without - * reading from the underlying io.Reader. + * Print calls l.Output to print to the logger. + * Arguments are handled in the manner of fmt.Print. */ - discard(n: number): number + print(...v: any[]): void } - interface Reader { + interface Logger { /** - * Read reads data into p. - * It returns the number of bytes read into p. - * The bytes are taken from at most one Read on the underlying Reader, - * hence n may be less than len(p). - * To read exactly len(p) bytes, use io.ReadFull(b, p). - * If the underlying Reader can return a non-zero count with io.EOF, - * then this Read method can do so as well; see the [io.Reader] docs. + * Println calls l.Output to print to the logger. + * Arguments are handled in the manner of fmt.Println. */ - read(p: string): number + println(...v: any[]): void } - interface Reader { + interface Logger { /** - * ReadByte reads and returns a single byte. - * If no byte is available, returns an error. + * Fatal is equivalent to l.Print() followed by a call to os.Exit(1). */ - readByte(): string + fatal(...v: any[]): void } - interface Reader { + interface Logger { /** - * UnreadByte unreads the last byte. Only the most recently read byte can be unread. - * - * UnreadByte returns an error if the most recent method called on the - * Reader was not a read operation. Notably, Peek, Discard, and WriteTo are not - * considered read operations. + * Fatalf is equivalent to l.Printf() followed by a call to os.Exit(1). */ - unreadByte(): void + fatalf(format: string, ...v: any[]): void } - interface Reader { + interface Logger { /** - * ReadRune reads a single UTF-8 encoded Unicode character and returns the - * rune and its size in bytes. If the encoded rune is invalid, it consumes one byte - * and returns unicode.ReplacementChar (U+FFFD) with a size of 1. + * Fatalln is equivalent to l.Println() followed by a call to os.Exit(1). */ - readRune(): [string, number] + fatalln(...v: any[]): void } - interface Reader { + interface Logger { /** - * UnreadRune unreads the last rune. If the most recent method called on - * the Reader was not a ReadRune, UnreadRune returns an error. (In this - * regard it is stricter than UnreadByte, which will unread the last byte - * from any read operation.) + * Panic is equivalent to l.Print() followed by a call to panic(). */ - unreadRune(): void + panic(...v: any[]): void } - interface Reader { + interface Logger { /** - * Buffered returns the number of bytes that can be read from the current buffer. + * Panicf is equivalent to l.Printf() followed by a call to panic(). */ - buffered(): number + panicf(format: string, ...v: any[]): void } - interface Reader { + interface Logger { /** - * ReadSlice reads until the first occurrence of delim in the input, - * returning a slice pointing at the bytes in the buffer. - * The bytes stop being valid at the next read. - * If ReadSlice encounters an error before finding a delimiter, - * it returns all the data in the buffer and the error itself (often io.EOF). - * ReadSlice fails with error ErrBufferFull if the buffer fills without a delim. - * Because the data returned from ReadSlice will be overwritten - * by the next I/O operation, most clients should use - * ReadBytes or ReadString instead. - * ReadSlice returns err != nil if and only if line does not end in delim. + * Panicln is equivalent to l.Println() followed by a call to panic(). */ - readSlice(delim: string): string + panicln(...v: any[]): void } - interface Reader { + interface Logger { /** - * ReadLine is a low-level line-reading primitive. Most callers should use - * ReadBytes('\n') or ReadString('\n') instead or use a Scanner. - * - * ReadLine tries to return a single line, not including the end-of-line bytes. - * If the line was too long for the buffer then isPrefix is set and the - * beginning of the line is returned. The rest of the line will be returned - * from future calls. isPrefix will be false when returning the last fragment - * of the line. The returned buffer is only valid until the next call to - * ReadLine. ReadLine either returns a non-nil line or it returns an error, - * never both. - * - * The text returned from ReadLine does not include the line end ("\r\n" or "\n"). - * No indication or error is given if the input ends without a final line end. - * Calling UnreadByte after ReadLine will always unread the last byte read - * (possibly a character belonging to the line end) even if that byte is not - * part of the line returned by ReadLine. + * Flags returns the output flags for the logger. + * The flag bits are Ldate, Ltime, and so on. */ - readLine(): [string, boolean] + flags(): number } - interface Reader { + interface Logger { /** - * ReadBytes reads until the first occurrence of delim in the input, - * returning a slice containing the data up to and including the delimiter. - * If ReadBytes encounters an error before finding a delimiter, - * it returns the data read before the error and the error itself (often io.EOF). - * ReadBytes returns err != nil if and only if the returned data does not end in - * delim. - * For simple uses, a Scanner may be more convenient. + * SetFlags sets the output flags for the logger. + * The flag bits are Ldate, Ltime, and so on. */ - readBytes(delim: string): string + setFlags(flag: number): void } - interface Reader { + interface Logger { /** - * ReadString reads until the first occurrence of delim in the input, - * returning a string containing the data up to and including the delimiter. - * If ReadString encounters an error before finding a delimiter, - * it returns the data read before the error and the error itself (often io.EOF). - * ReadString returns err != nil if and only if the returned data does not end in - * delim. - * For simple uses, a Scanner may be more convenient. + * Prefix returns the output prefix for the logger. */ - readString(delim: string): string + prefix(): string } - interface Reader { + interface Logger { /** - * WriteTo implements io.WriterTo. - * This may make multiple calls to the Read method of the underlying Reader. - * If the underlying reader supports the WriteTo method, - * this calls the underlying WriteTo without buffering. + * SetPrefix sets the output prefix for the logger. */ - writeTo(w: io.Writer): number + setPrefix(prefix: string): void } - /** - * Writer implements buffering for an io.Writer object. - * If an error occurs writing to a Writer, no more data will be - * accepted and all subsequent writes, and Flush, will return the error. - * After all data has been written, the client should call the - * Flush method to guarantee all data has been forwarded to - * the underlying io.Writer. - */ - interface Writer { - } - interface Writer { + interface Logger { /** - * Size returns the size of the underlying buffer in bytes. + * Writer returns the output destination for the logger. */ - size(): number - } - interface Writer { - /** - * Reset discards any unflushed buffered data, clears any error, and - * resets b to write its output to w. - * Calling Reset on the zero value of Writer initializes the internal buffer - * to the default size. - */ - reset(w: io.Writer): void - } - interface Writer { - /** - * Flush writes any buffered data to the underlying io.Writer. - */ - flush(): void - } - interface Writer { - /** - * Available returns how many bytes are unused in the buffer. - */ - available(): number - } - interface Writer { - /** - * AvailableBuffer returns an empty buffer with b.Available() capacity. - * This buffer is intended to be appended to and - * passed to an immediately succeeding Write call. - * The buffer is only valid until the next write operation on b. - */ - availableBuffer(): string - } - interface Writer { - /** - * Buffered returns the number of bytes that have been written into the current buffer. - */ - buffered(): number - } - interface Writer { - /** - * Write writes the contents of p into the buffer. - * It returns the number of bytes written. - * If nn < len(p), it also returns an error explaining - * why the write is short. - */ - write(p: string): number - } - interface Writer { - /** - * WriteByte writes a single byte. - */ - writeByte(c: string): void - } - interface Writer { - /** - * WriteRune writes a single Unicode code point, returning - * the number of bytes written and any error. - */ - writeRune(r: string): number - } - interface Writer { - /** - * WriteString writes a string. - * It returns the number of bytes written. - * If the count is less than len(s), it also returns an error explaining - * why the write is short. - */ - writeString(s: string): number - } - interface Writer { - /** - * ReadFrom implements io.ReaderFrom. If the underlying writer - * supports the ReadFrom method, this calls the underlying ReadFrom. - * If there is buffered data and an underlying ReadFrom, this fills - * the buffer and writes it before calling ReadFrom. - */ - readFrom(r: io.Reader): number + writer(): io.Writer } } @@ -20139,6 +20134,38 @@ namespace http { } } +/** + * Package encoding defines interfaces shared by other packages that + * convert data to and from byte-level and textual representations. + * Packages that check for these interfaces include encoding/gob, + * encoding/json, and encoding/xml. As a result, implementing an + * interface once can make a type useful in multiple encodings. + * Standard types that implement these interfaces include time.Time and net.IP. + * The interfaces come in pairs that produce and consume encoded data. + */ +namespace encoding { + /** + * TextMarshaler is the interface implemented by an object that can + * marshal itself into a textual form. + * + * MarshalText encodes the receiver into UTF-8-encoded text and returns the result. + */ + interface TextMarshaler { + marshalText(): string + } + /** + * TextUnmarshaler is the interface implemented by an object that can + * unmarshal a textual representation of itself. + * + * UnmarshalText must be able to decode the form generated by MarshalText. + * UnmarshalText must copy the text if it wishes to retain the text + * after returning. + */ + interface TextUnmarshaler { + unmarshalText(text: string): void + } +} + /** * Package acme provides an implementation of the * Automatic Certificate Management Environment (ACME) spec, @@ -20564,6 +20591,49 @@ namespace acme { } } +/** + * Package autocert provides automatic access to certificates from Let's Encrypt + * and any other ACME-based CA. + * + * This package is a work in progress and makes no API stability promises. + */ +namespace autocert { + // @ts-ignore + import mathrand = rand + /** + * HostPolicy specifies which host names the Manager is allowed to respond to. + * It returns a non-nil error if the host should be rejected. + * The returned error is accessible via tls.Conn.Handshake and its callers. + * See Manager's HostPolicy field and GetCertificate method docs for more details. + */ + interface HostPolicy {(ctx: context.Context, host: string): void } + /** + * Cache is used by Manager to store and retrieve previously obtained certificates + * and other account data as opaque blobs. + * + * Cache implementations should not rely on the key naming pattern. Keys can + * include any printable ASCII characters, except the following: \/:*?"<>| + */ + interface Cache { + /** + * Get returns a certificate data for the specified key. + * If there's no such key, Get returns ErrCacheMiss. + */ + get(ctx: context.Context, key: string): string + /** + * Put stores the data in the cache under the specified key. + * Underlying implementations may use any data storage format, + * as long as the reverse operation, Get, results in the original data. + */ + put(ctx: context.Context, key: string, data: string): void + /** + * Delete removes a certificate data from the cache under the specified key. + * If there's no such key in the cache, Delete returns nil. + */ + delete(ctx: context.Context, key: string): void + } +} + /** * Package driver defines interfaces to be implemented by database * drivers as used by package sql. @@ -20651,50 +20721,7 @@ namespace driver { } } -namespace search { -} - -/** - * Package autocert provides automatic access to certificates from Let's Encrypt - * and any other ACME-based CA. - * - * This package is a work in progress and makes no API stability promises. - */ -namespace autocert { - // @ts-ignore - import mathrand = rand - /** - * HostPolicy specifies which host names the Manager is allowed to respond to. - * It returns a non-nil error if the host should be rejected. - * The returned error is accessible via tls.Conn.Handshake and its callers. - * See Manager's HostPolicy field and GetCertificate method docs for more details. - */ - interface HostPolicy {(ctx: context.Context, host: string): void } - /** - * Cache is used by Manager to store and retrieve previously obtained certificates - * and other account data as opaque blobs. - * - * Cache implementations should not rely on the key naming pattern. Keys can - * include any printable ASCII characters, except the following: \/:*?"<>| - */ - interface Cache { - /** - * Get returns a certificate data for the specified key. - * If there's no such key, Get returns ErrCacheMiss. - */ - get(ctx: context.Context, key: string): string - /** - * Put stores the data in the cache under the specified key. - * Underlying implementations may use any data storage format, - * as long as the reverse operation, Get, results in the original data. - */ - put(ctx: context.Context, key: string, data: string): void - /** - * Delete removes a certificate data from the cache under the specified key. - * If there's no such key in the cache, Delete returns nil. - */ - delete(ctx: context.Context, key: string): void - } +namespace subscriptions { } /** @@ -20732,7 +20759,7 @@ namespace mail { } } -namespace subscriptions { +namespace search { } /** @@ -20921,8 +20948,8 @@ namespace reflect { * Using == on two Values does not compare the underlying values * they represent. */ - type _subVsdaq = flag - interface Value extends _subVsdaq { + type _subGvkYZ = flag + interface Value extends _subGvkYZ { } interface Value { /** @@ -22033,71 +22060,6 @@ namespace fmt { } } -/** - * Package log implements a simple logging package. It defines a type, Logger, - * with methods for formatting output. It also has a predefined 'standard' - * Logger accessible through helper functions Print[f|ln], Fatal[f|ln], and - * Panic[f|ln], which are easier to use than creating a Logger manually. - * That logger writes to standard error and prints the date and time - * of each logged message. - * Every log message is output on a separate line: if the message being - * printed does not end in a newline, the logger will add one. - * The Fatal functions call os.Exit(1) after writing the log message. - * The Panic functions call panic after writing the log message. - */ -namespace log { -} - -/** - * Package crypto collects common cryptographic constants. - */ -namespace crypto { - /** - * PrivateKey represents a private key using an unspecified algorithm. - * - * Although this type is an empty interface for backwards compatibility reasons, - * all private key types in the standard library implement the following interface - * - * ``` - * interface{ - * Public() crypto.PublicKey - * Equal(x crypto.PrivateKey) bool - * } - * ``` - * - * as well as purpose-specific interfaces such as Signer and Decrypter, which - * can be used for increased type safety within applications. - */ - interface PrivateKey extends _TygojaAny{} - /** - * Signer is an interface for an opaque private key that can be used for - * signing operations. For example, an RSA key kept in a hardware module. - */ - interface Signer { - /** - * Public returns the public key corresponding to the opaque, - * private key. - */ - public(): PublicKey - /** - * Sign signs digest with the private key, possibly using entropy from - * rand. For an RSA key, the resulting signature should be either a - * PKCS #1 v1.5 or PSS signature (as indicated by opts). For an (EC)DSA - * key, it should be a DER-serialised, ASN.1 signature structure. - * - * Hash implements the SignerOpts interface and, in most cases, one can - * simply pass in the hash function used as opts. Sign may also attempt - * to type assert opts to other types in order to obtain algorithm - * specific values. See the documentation in each package for details. - * - * Note that when a signature of a hash of a larger message is needed, - * the caller is responsible for hashing the larger message and passing - * the hash (as digest) and the hash function (as opts) to Sign. - */ - sign(rand: io.Reader, digest: string, opts: SignerOpts): string - } -} - /** * Package rand implements pseudo-random number generators unsuitable for * security-sensitive work. @@ -22441,6 +22403,56 @@ namespace pkix { } } +/** + * Package crypto collects common cryptographic constants. + */ +namespace crypto { + /** + * PrivateKey represents a private key using an unspecified algorithm. + * + * Although this type is an empty interface for backwards compatibility reasons, + * all private key types in the standard library implement the following interface + * + * ``` + * interface{ + * Public() crypto.PublicKey + * Equal(x crypto.PrivateKey) bool + * } + * ``` + * + * as well as purpose-specific interfaces such as Signer and Decrypter, which + * can be used for increased type safety within applications. + */ + interface PrivateKey extends _TygojaAny{} + /** + * Signer is an interface for an opaque private key that can be used for + * signing operations. For example, an RSA key kept in a hardware module. + */ + interface Signer { + /** + * Public returns the public key corresponding to the opaque, + * private key. + */ + public(): PublicKey + /** + * Sign signs digest with the private key, possibly using entropy from + * rand. For an RSA key, the resulting signature should be either a + * PKCS #1 v1.5 or PSS signature (as indicated by opts). For an (EC)DSA + * key, it should be a DER-serialised, ASN.1 signature structure. + * + * Hash implements the SignerOpts interface and, in most cases, one can + * simply pass in the hash function used as opts. Sign may also attempt + * to type assert opts to other types in order to obtain algorithm + * specific values. See the documentation in each package for details. + * + * Note that when a signature of a hash of a larger message is needed, + * the caller is responsible for hashing the larger message and passing + * the hash (as digest) and the hash function (as opts) to Sign. + */ + sign(rand: io.Reader, digest: string, opts: SignerOpts): string + } +} + /** * Copyright 2021 The Go Authors. All rights reserved. * Use of this source code is governed by a BSD-style @@ -22610,6 +22622,21 @@ namespace tls { } } +/** + * Package log implements a simple logging package. It defines a type, Logger, + * with methods for formatting output. It also has a predefined 'standard' + * Logger accessible through helper functions Print[f|ln], Fatal[f|ln], and + * Panic[f|ln], which are easier to use than creating a Logger manually. + * That logger writes to standard error and prints the date and time + * of each logged message. + * Every log message is output on a separate line: if the message being + * printed does not end in a newline, the logger will add one. + * The Fatal functions call os.Exit(1) after writing the log message. + * The Panic functions call panic after writing the log message. + */ +namespace log { +} + /** * Package acme provides an implementation of the * Automatic Certificate Management Environment (ACME) spec, @@ -23020,6 +23047,38 @@ namespace driver { } } +/** + * Package crypto collects common cryptographic constants. + */ +namespace crypto { + /** + * PublicKey represents a public key using an unspecified algorithm. + * + * Although this type is an empty interface for backwards compatibility reasons, + * all public key types in the standard library implement the following interface + * + * ``` + * interface{ + * Equal(x crypto.PublicKey) bool + * } + * ``` + * + * which can be used for increased type safety within applications. + */ + interface PublicKey extends _TygojaAny{} + /** + * SignerOpts contains options for signing with a Signer. + */ + interface SignerOpts { + /** + * HashFunc returns an identifier for the hash function used to produce + * the message passed to Signer.Sign, or else zero to indicate that no + * hashing was done. + */ + hashFunc(): Hash + } +} + /** * Package reflect implements run-time reflection, allowing a program to * manipulate objects with arbitrary types. The typical use is to take a value @@ -23105,38 +23164,6 @@ namespace pkix { interface RelativeDistinguishedNameSET extends Array{} } -/** - * Package crypto collects common cryptographic constants. - */ -namespace crypto { - /** - * PublicKey represents a public key using an unspecified algorithm. - * - * Although this type is an empty interface for backwards compatibility reasons, - * all public key types in the standard library implement the following interface - * - * ``` - * interface{ - * Equal(x crypto.PublicKey) bool - * } - * ``` - * - * which can be used for increased type safety within applications. - */ - interface PublicKey extends _TygojaAny{} - /** - * SignerOpts contains options for signing with a Signer. - */ - interface SignerOpts { - /** - * HashFunc returns an identifier for the hash function used to produce - * the message passed to Signer.Sign, or else zero to indicate that no - * hashing was done. - */ - hashFunc(): Hash - } -} - /** * Package tls partially implements TLS 1.2, as specified in RFC 5246, * and TLS 1.3, as specified in RFC 8446. diff --git a/plugins/jsvm/jsvm.go b/plugins/jsvm/jsvm.go index a4e3cb82..0ace4b3a 100644 --- a/plugins/jsvm/jsvm.go +++ b/plugins/jsvm/jsvm.go @@ -162,13 +162,14 @@ func (p *plugin) registerHooks() error { return err } - // prepend the types reference directive to empty files + // prepend the types reference directive // // note: it is loaded during startup to handle conveniently also // the case when the HooksWatch option is enabled and the application // restart on newly created file for name, content := range files { if len(content) != 0 { + // skip non-empty files for now to prevent accidental overwrite continue } path := filepath.Join(p.config.HooksDir, name) @@ -178,6 +179,18 @@ func (p *plugin) registerHooks() error { } } + // initialize the hooks dir watcher + if p.config.HooksWatch { + if err := p.watchHooks(); err != nil { + return err + } + } + + if len(files) == 0 { + // no need to register the vms since there are no entrypoint files anyway + return nil + } + // this is safe to be shared across multiple vms registry := new(require.Registry) @@ -191,6 +204,7 @@ func (p *plugin) registerHooks() error { securityBinds(vm) formsBinds(vm) apisBinds(vm) + httpClientBinds(vm) vm.Set("$app", p.app) } @@ -219,20 +233,21 @@ func (p *plugin) registerHooks() error { } } - p.app.OnTerminate().Add(func(e *core.TerminateEvent) error { - return nil - }) - - if p.config.HooksWatch { - return p.watchHooks() - } - return nil } // watchHooks initializes a hooks file watcher that will restart the // application (*if possible) in case of a change in the hooks directory. +// +// This method does nothing if the hooks directory is missing. func (p *plugin) watchHooks() error { + if _, err := os.Stat(p.config.HooksDir); err != nil { + if os.IsNotExist(err) { + return nil // no hooks dir to watch + } + return err + } + watcher, err := fsnotify.NewWatcher() if err != nil { return err