diff --git a/CHANGELOG.md b/CHANGELOG.md index 5aa27c50..6144f929 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +31,7 @@ ``` app.Dao().FindRecordsByFilter("posts", "title ~ 'lorem ipsum' && visible = true", "-created", 10) app.Dao().FindFirstRecordByFilter("posts", "slug='test' && active=true") - app.Dao().CanAccessRecord(record, requestData, rule) + app.Dao().CanAccessRecord(record, requestInfo, rule) ``` - (@todo docs) Added `Dao.WithoutHooks()` helper to create a new `Dao` from the current one but without the create/update/delete hooks. @@ -84,6 +84,9 @@ - (@todo docs) Added `record.ExpandedOne(rel)` and `record.ExpandedAll(rel)` helpers to retrieve casted single or multiple expand relations from the already loaded "expand" Record data. +- **!** renamed `models.RequestData` to `models.RequestInfo` and soft-deprecated `apis.RequestData(c)` to `apis.RequestInfo(c)` to avoid the stuttering with the `Data` field. + _The old `apis.RequestData()` method still works to minimize the breaking changes but it is recommended to replace it with `apis.RequestInfo(c)`._ + ## v0.16.10 @@ -92,7 +95,7 @@ ## v0.16.9 -- Register the `eagerRequestDataCache` middleware only for the internal `api` group routes to avoid conflicts with custom route handlers ([#2914](https://github.com/pocketbase/pocketbase/issues/2914)). +- Register the `eagerRequestInfoCache` middleware only for the internal `api` group routes to avoid conflicts with custom route handlers ([#2914](https://github.com/pocketbase/pocketbase/issues/2914)). ## v0.16.8 diff --git a/apis/base.go b/apis/base.go index b06a53e7..e9438bc3 100644 --- a/apis/base.go +++ b/apis/base.go @@ -120,7 +120,7 @@ func InitApi(app core.App) (*echo.Echo, error) { bindStaticAdminUI(app, e) // default routes - api := e.Group("/api", eagerRequestDataCache(app)) + api := e.Group("/api", eagerRequestInfoCache(app)) bindSettingsApi(app, api) bindAdminApi(app, api) bindCollectionApi(app, api) diff --git a/apis/base_test.go b/apis/base_test.go index ba2dd0b6..2dfbd2b2 100644 --- a/apis/base_test.go +++ b/apis/base_test.go @@ -213,7 +213,7 @@ func TestRemoveTrailingSlashMiddleware(t *testing.T) { } } -func TestEagerRequestDataCache(t *testing.T) { +func TestEagerRequestInfoCache(t *testing.T) { scenarios := []tests.ApiScenario{ { @@ -236,7 +236,7 @@ func TestEagerRequestDataCache(t *testing.T) { // since the unknown method is not eager cache support // it should fail reading the json body twice - r := apis.RequestData(c) + r := apis.RequestInfo(c) if v := cast.ToString(r.Data["name"]); v != "" { t.Fatalf("Expected empty request data body, got, %v", r.Data) } @@ -256,7 +256,7 @@ func TestEagerRequestDataCache(t *testing.T) { e.Use(func(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { // it is not important whether the route handler return an error since - // we just need to ensure that the eagerRequestDataCache was registered + // we just need to ensure that the eagerRequestInfoCache was registered next(c) // ensure that the body was read at least once @@ -267,7 +267,7 @@ func TestEagerRequestDataCache(t *testing.T) { // since the unknown method is not eager cache support // it should fail reading the json body twice - r := apis.RequestData(c) + r := apis.RequestInfo(c) if v := cast.ToString(r.Data["name"]); v != "" { t.Fatalf("Expected empty request data body, got, %v", r.Data) } @@ -287,7 +287,7 @@ func TestEagerRequestDataCache(t *testing.T) { e.Use(func(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { // it is not important whether the route handler return an error since - // we just need to ensure that the eagerRequestDataCache was registered + // we just need to ensure that the eagerRequestInfoCache was registered next(c) // ensure that the body was read at least once @@ -297,7 +297,7 @@ func TestEagerRequestDataCache(t *testing.T) { c.Bind(data) // try to read the body again - r := apis.RequestData(c) + r := apis.RequestInfo(c) fmt.Println(r) if v := cast.ToString(r.Data["name"]); v != "test123" { t.Fatalf("Expected request data with name %q, got, %q", "test123", v) diff --git a/apis/file.go b/apis/file.go index 596c7cd8..c994566a 100644 --- a/apis/file.go +++ b/apis/file.go @@ -95,18 +95,18 @@ func (api *fileApi) download(c echo.Context) error { adminOrAuthRecord, _ := api.findAdminOrAuthRecordByFileToken(token) // create a copy of the cached request data and adjust it for the current auth model - requestData := *RequestData(c) - requestData.Admin = nil - requestData.AuthRecord = nil + requestInfo := *RequestInfo(c) + requestInfo.Admin = nil + requestInfo.AuthRecord = nil if adminOrAuthRecord != nil { if admin, _ := adminOrAuthRecord.(*models.Admin); admin != nil { - requestData.Admin = admin + requestInfo.Admin = admin } else if record, _ := adminOrAuthRecord.(*models.Record); record != nil { - requestData.AuthRecord = record + requestInfo.AuthRecord = record } } - if ok, _ := api.app.Dao().CanAccessRecord(record, &requestData, record.Collection().ViewRule); !ok { + if ok, _ := api.app.Dao().CanAccessRecord(record, &requestInfo, record.Collection().ViewRule); !ok { return NewForbiddenError("Insufficient permissions to access the file resource.", nil) } } diff --git a/apis/middlewares.go b/apis/middlewares.go index 05e1d0ff..7607465a 100644 --- a/apis/middlewares.go +++ b/apis/middlewares.go @@ -393,15 +393,15 @@ func realUserIp(r *http.Request, fallbackIp string) string { return fallbackIp } -// eagerRequestDataCache ensures that the request data is cached in the request +// eagerRequestInfoCache ensures that the request data is cached in the request // context to allow reading for example the json request body data more than once. -func eagerRequestDataCache(app core.App) echo.MiddlewareFunc { +func eagerRequestInfoCache(app core.App) echo.MiddlewareFunc { return func(next echo.HandlerFunc) echo.HandlerFunc { return func(c echo.Context) error { switch c.Request().Method { // currently we are eagerly caching only the requests with body case "POST", "PUT", "PATCH", "DELETE": - RequestData(c) + RequestInfo(c) } return next(c) diff --git a/apis/realtime.go b/apis/realtime.go index 699b5209..9523d2c6 100644 --- a/apis/realtime.go +++ b/apis/realtime.go @@ -347,12 +347,12 @@ func (api *realtimeApi) canAccessRecord(client subscriptions.Client, record *mod } // mock request data - requestData := &models.RequestData{ + requestInfo := &models.RequestInfo{ Method: "GET", } - requestData.AuthRecord, _ = client.Get(ContextAuthRecordKey).(*models.Record) + requestInfo.AuthRecord, _ = client.Get(ContextAuthRecordKey).(*models.Record) - resolver := resolvers.NewRecordFieldResolver(api.app.Dao(), record.Collection(), requestData, true) + resolver := resolvers.NewRecordFieldResolver(api.app.Dao(), record.Collection(), requestInfo, true) expr, err := search.FilterData(*accessRule).BuildExpr(resolver) if err != nil { return err diff --git a/apis/record_auth.go b/apis/record_auth.go index daea8f59..9cfe73a6 100644 --- a/apis/record_auth.go +++ b/apis/record_auth.go @@ -191,8 +191,8 @@ func (api *recordAuthApi) authWithOAuth2(c echo.Context) error { return createForm.DrySubmit(func(txDao *daos.Dao) error { event.IsNewRecord = true // clone the current request data and assign the form create data as its body data - requestData := *RequestData(c) - requestData.Data = form.CreateData + requestInfo := *RequestInfo(c) + requestInfo.Data = form.CreateData createRuleFunc := func(q *dbx.SelectQuery) error { admin, _ := c.Get(ContextAdminKey).(*models.Admin) @@ -205,7 +205,7 @@ func (api *recordAuthApi) authWithOAuth2(c echo.Context) error { } if *collection.CreateRule != "" { - resolver := resolvers.NewRecordFieldResolver(txDao, collection, &requestData, true) + resolver := resolvers.NewRecordFieldResolver(txDao, collection, &requestInfo, true) expr, err := search.FilterData(*collection.CreateRule).BuildExpr(resolver) if err != nil { return err diff --git a/apis/record_crud.go b/apis/record_crud.go index e54098ae..5a4ace23 100644 --- a/apis/record_crud.go +++ b/apis/record_crud.go @@ -50,9 +50,9 @@ func (api *recordApi) list(c echo.Context) error { return err } - requestData := RequestData(c) + requestInfo := RequestInfo(c) - if requestData.Admin == nil && collection.ListRule == nil { + if requestInfo.Admin == nil && collection.ListRule == nil { // only admins can access if the rule is nil return NewForbiddenError("Only admins can perform this action.", nil) } @@ -60,9 +60,9 @@ func (api *recordApi) list(c echo.Context) error { fieldsResolver := resolvers.NewRecordFieldResolver( api.app.Dao(), collection, - requestData, + requestInfo, // hidden fields are searchable only by admins - requestData.Admin != nil, + requestInfo.Admin != nil, ) searchProvider := search.NewProvider(fieldsResolver). @@ -73,7 +73,7 @@ func (api *recordApi) list(c echo.Context) error { searchProvider.CountCol("id") } - if requestData.Admin == nil && collection.ListRule != nil { + if requestInfo.Admin == nil && collection.ListRule != nil { searchProvider.AddFilter(search.FilterData(*collection.ListRule)) } @@ -110,16 +110,16 @@ func (api *recordApi) view(c echo.Context) error { return NewNotFoundError("", nil) } - requestData := RequestData(c) + requestInfo := RequestInfo(c) - if requestData.Admin == nil && collection.ViewRule == nil { + if requestInfo.Admin == nil && collection.ViewRule == nil { // only admins can access if the rule is nil return NewForbiddenError("Only admins can perform this action.", nil) } ruleFunc := func(q *dbx.SelectQuery) error { - if requestData.Admin == nil && collection.ViewRule != nil && *collection.ViewRule != "" { - resolver := resolvers.NewRecordFieldResolver(api.app.Dao(), collection, requestData, true) + if requestInfo.Admin == nil && collection.ViewRule != nil && *collection.ViewRule != "" { + resolver := resolvers.NewRecordFieldResolver(api.app.Dao(), collection, requestInfo, true) expr, err := search.FilterData(*collection.ViewRule).BuildExpr(resolver) if err != nil { return err @@ -155,23 +155,23 @@ func (api *recordApi) create(c echo.Context) error { return NewNotFoundError("", "Missing collection context.") } - requestData := RequestData(c) + requestInfo := RequestInfo(c) - if requestData.Admin == nil && collection.CreateRule == nil { + if requestInfo.Admin == nil && collection.CreateRule == nil { // only admins can access if the rule is nil return NewForbiddenError("Only admins can perform this action.", nil) } - hasFullManageAccess := requestData.Admin != nil + hasFullManageAccess := requestInfo.Admin != nil // temporary save the record and check it against the create rule - if requestData.Admin == nil && collection.CreateRule != nil { + if requestInfo.Admin == nil && collection.CreateRule != nil { testRecord := models.NewRecord(collection) // replace modifiers fields so that the resolved value is always - // available when accessing requestData.Data using just the field name - if requestData.HasModifierDataKeys() { - requestData.Data = testRecord.ReplaceModifers(requestData.Data) + // available when accessing requestInfo.Data using just the field name + if requestInfo.HasModifierDataKeys() { + requestInfo.Data = testRecord.ReplaceModifers(requestInfo.Data) } testForm := forms.NewRecordUpsert(api.app, testRecord) @@ -185,7 +185,7 @@ func (api *recordApi) create(c echo.Context) error { return nil // no create rule to resolve } - resolver := resolvers.NewRecordFieldResolver(api.app.Dao(), collection, requestData, true) + resolver := resolvers.NewRecordFieldResolver(api.app.Dao(), collection, requestInfo, true) expr, err := search.FilterData(*collection.CreateRule).BuildExpr(resolver) if err != nil { return err @@ -200,7 +200,7 @@ func (api *recordApi) create(c echo.Context) error { if err != nil { return fmt.Errorf("DrySubmit create rule failure: %w", err) } - hasFullManageAccess = hasAuthManageAccess(txDao, foundRecord, requestData) + hasFullManageAccess = hasAuthManageAccess(txDao, foundRecord, requestInfo) return nil }) @@ -259,26 +259,26 @@ func (api *recordApi) update(c echo.Context) error { return NewNotFoundError("", nil) } - requestData := RequestData(c) + requestInfo := RequestInfo(c) - if requestData.Admin == nil && collection.UpdateRule == nil { + if requestInfo.Admin == nil && collection.UpdateRule == nil { // only admins can access if the rule is nil return NewForbiddenError("Only admins can perform this action.", nil) } // eager fetch the record so that the modifier field values are replaced - // and available when accessing requestData.Data using just the field name - if requestData.HasModifierDataKeys() { + // and available when accessing requestInfo.Data using just the field name + if requestInfo.HasModifierDataKeys() { record, err := api.app.Dao().FindRecordById(collection.Id, recordId) if err != nil || record == nil { return NewNotFoundError("", err) } - requestData.Data = record.ReplaceModifers(requestData.Data) + requestInfo.Data = record.ReplaceModifers(requestInfo.Data) } ruleFunc := func(q *dbx.SelectQuery) error { - if requestData.Admin == nil && collection.UpdateRule != nil && *collection.UpdateRule != "" { - resolver := resolvers.NewRecordFieldResolver(api.app.Dao(), collection, requestData, true) + if requestInfo.Admin == nil && collection.UpdateRule != nil && *collection.UpdateRule != "" { + resolver := resolvers.NewRecordFieldResolver(api.app.Dao(), collection, requestInfo, true) expr, err := search.FilterData(*collection.UpdateRule).BuildExpr(resolver) if err != nil { return err @@ -296,7 +296,7 @@ func (api *recordApi) update(c echo.Context) error { } form := forms.NewRecordUpsert(api.app, record) - form.SetFullManageAccess(requestData.Admin != nil || hasAuthManageAccess(api.app.Dao(), record, requestData)) + form.SetFullManageAccess(requestInfo.Admin != nil || hasAuthManageAccess(api.app.Dao(), record, requestInfo)) // load request if err := form.LoadRequest(c.Request(), ""); err != nil { @@ -344,16 +344,16 @@ func (api *recordApi) delete(c echo.Context) error { return NewNotFoundError("", nil) } - requestData := RequestData(c) + requestInfo := RequestInfo(c) - if requestData.Admin == nil && collection.DeleteRule == nil { + if requestInfo.Admin == nil && collection.DeleteRule == nil { // only admins can access if the rule is nil return NewForbiddenError("Only admins can perform this action.", nil) } ruleFunc := func(q *dbx.SelectQuery) error { - if requestData.Admin == nil && collection.DeleteRule != nil && *collection.DeleteRule != "" { - resolver := resolvers.NewRecordFieldResolver(api.app.Dao(), collection, requestData, true) + if requestInfo.Admin == nil && collection.DeleteRule != nil && *collection.DeleteRule != "" { + resolver := resolvers.NewRecordFieldResolver(api.app.Dao(), collection, requestInfo, true) expr, err := search.FilterData(*collection.DeleteRule).BuildExpr(resolver) if err != nil { return err diff --git a/apis/record_helpers.go b/apis/record_helpers.go index d8d033d0..33b28f25 100644 --- a/apis/record_helpers.go +++ b/apis/record_helpers.go @@ -17,14 +17,20 @@ import ( "github.com/pocketbase/pocketbase/tools/search" ) -const ContextRequestDataKey = "requestData" +const ContextRequestInfoKey = "requestInfo" -// RequestData exports cached common request data fields +// Deprecated: Use RequestInfo instead. +func RequestData(c echo.Context) *models.RequestInfo { + log.Println("RequestInfo(c) is depracated and will be removed in the future! You can replace it with RequestInfo(c).") + return RequestInfo(c) +} + +// RequestInfo exports cached common request data fields // (query, body, logged auth state, etc.) from the provided context. -func RequestData(c echo.Context) *models.RequestData { +func RequestInfo(c echo.Context) *models.RequestInfo { // return cached to avoid copying the body multiple times - if v := c.Get(ContextRequestDataKey); v != nil { - if data, ok := v.(*models.RequestData); ok { + if v := c.Get(ContextRequestInfoKey); v != nil { + if data, ok := v.(*models.RequestInfo); ok { // refresh auth state data.AuthRecord, _ = c.Get(ContextAuthRecordKey).(*models.Record) data.Admin, _ = c.Get(ContextAdminKey).(*models.Admin) @@ -32,7 +38,7 @@ func RequestData(c echo.Context) *models.RequestData { } } - result := &models.RequestData{ + result := &models.RequestInfo{ Method: c.Request().Method, Query: map[string]any{}, Data: map[string]any{}, @@ -52,7 +58,7 @@ func RequestData(c echo.Context) *models.RequestData { echo.BindQueryParams(c, &result.Query) rest.BindBody(c, &result.Data) - c.Set(ContextRequestDataKey, result) + c.Set(ContextRequestInfoKey, result) return result } @@ -86,13 +92,13 @@ func RecordAuthResponse( expands := strings.Split(c.QueryParam(expandQueryParam), ",") if len(expands) > 0 { // create a copy of the cached request data and adjust it to the current auth record - requestData := *RequestData(e.HttpContext) - requestData.Admin = nil - requestData.AuthRecord = e.Record + requestInfo := *RequestInfo(e.HttpContext) + requestInfo.Admin = nil + requestInfo.AuthRecord = e.Record failed := app.Dao().ExpandRecord( e.Record, expands, - expandFetch(app.Dao(), &requestData), + expandFetch(app.Dao(), &requestInfo), ) if len(failed) > 0 && app.IsDebug() { log.Println("Failed to expand relations: ", failed) @@ -131,9 +137,9 @@ func EnrichRecord(c echo.Context, dao *daos.Dao, record *models.Record, defaultE // - ensures that the emails of the auth records and their expanded auth relations // are visibe only for the current logged admin, record owner or record with manage access func EnrichRecords(c echo.Context, dao *daos.Dao, records []*models.Record, defaultExpands ...string) error { - requestData := RequestData(c) + requestInfo := RequestInfo(c) - if err := autoIgnoreAuthRecordsEmailVisibility(dao, records, requestData); err != nil { + if err := autoIgnoreAuthRecordsEmailVisibility(dao, records, requestInfo); err != nil { return fmt.Errorf("Failed to resolve email visibility: %w", err) } @@ -145,7 +151,7 @@ func EnrichRecords(c echo.Context, dao *daos.Dao, records []*models.Record, defa return nil // nothing to expand } - errs := dao.ExpandRecords(records, expands, expandFetch(dao, requestData)) + errs := dao.ExpandRecords(records, expands, expandFetch(dao, requestInfo)) if len(errs) > 0 { return fmt.Errorf("Failed to expand: %v", errs) } @@ -156,11 +162,11 @@ func EnrichRecords(c echo.Context, dao *daos.Dao, records []*models.Record, defa // expandFetch is the records fetch function that is used to expand related records. func expandFetch( dao *daos.Dao, - requestData *models.RequestData, + requestInfo *models.RequestInfo, ) daos.ExpandFetchFunc { return func(relCollection *models.Collection, relIds []string) ([]*models.Record, error) { records, err := dao.FindRecordsByIds(relCollection.Id, relIds, func(q *dbx.SelectQuery) error { - if requestData.Admin != nil { + if requestInfo.Admin != nil { return nil // admins can access everything } @@ -169,7 +175,7 @@ func expandFetch( } if *relCollection.ViewRule != "" { - resolver := resolvers.NewRecordFieldResolver(dao, relCollection, requestData, true) + resolver := resolvers.NewRecordFieldResolver(dao, relCollection, requestInfo, true) expr, err := search.FilterData(*(relCollection.ViewRule)).BuildExpr(resolver) if err != nil { return err @@ -182,7 +188,7 @@ func expandFetch( }) if err == nil && len(records) > 0 { - autoIgnoreAuthRecordsEmailVisibility(dao, records, requestData) + autoIgnoreAuthRecordsEmailVisibility(dao, records, requestInfo) } return records, err @@ -196,13 +202,13 @@ func expandFetch( func autoIgnoreAuthRecordsEmailVisibility( dao *daos.Dao, records []*models.Record, - requestData *models.RequestData, + requestInfo *models.RequestInfo, ) error { if len(records) == 0 || !records[0].Collection().IsAuth() { return nil // nothing to check } - if requestData.Admin != nil { + if requestInfo.Admin != nil { for _, rec := range records { rec.IgnoreEmailVisibility(true) } @@ -218,8 +224,8 @@ func autoIgnoreAuthRecordsEmailVisibility( recordIds[i] = rec.Id } - if requestData != nil && requestData.AuthRecord != nil && mappedRecords[requestData.AuthRecord.Id] != nil { - mappedRecords[requestData.AuthRecord.Id].IgnoreEmailVisibility(true) + if requestInfo != nil && requestInfo.AuthRecord != nil && mappedRecords[requestInfo.AuthRecord.Id] != nil { + mappedRecords[requestInfo.AuthRecord.Id].IgnoreEmailVisibility(true) } authOptions := collection.AuthOptions() @@ -235,7 +241,7 @@ func autoIgnoreAuthRecordsEmailVisibility( Select(dao.DB().QuoteSimpleColumnName(collection.Name) + ".id"). AndWhere(dbx.In(dao.DB().QuoteSimpleColumnName(collection.Name)+".id", recordIds...)) - resolver := resolvers.NewRecordFieldResolver(dao, collection, requestData, true) + resolver := resolvers.NewRecordFieldResolver(dao, collection, requestInfo, true) expr, err := search.FilterData(*authOptions.ManageRule).BuildExpr(resolver) if err != nil { return err @@ -264,7 +270,7 @@ func autoIgnoreAuthRecordsEmailVisibility( func hasAuthManageAccess( dao *daos.Dao, record *models.Record, - requestData *models.RequestData, + requestInfo *models.RequestInfo, ) bool { if !record.Collection().IsAuth() { return false @@ -276,12 +282,12 @@ func hasAuthManageAccess( return false // only for admins (manageRule can't be empty) } - if requestData == nil || requestData.AuthRecord == nil { + if requestInfo == nil || requestInfo.AuthRecord == nil { return false // no auth record } ruleFunc := func(q *dbx.SelectQuery) error { - resolver := resolvers.NewRecordFieldResolver(dao, record.Collection(), requestData, true) + resolver := resolvers.NewRecordFieldResolver(dao, record.Collection(), requestInfo, true) expr, err := search.FilterData(*manageRule).BuildExpr(resolver) if err != nil { return err diff --git a/apis/record_helpers_test.go b/apis/record_helpers_test.go index 765182ce..70506c78 100644 --- a/apis/record_helpers_test.go +++ b/apis/record_helpers_test.go @@ -13,7 +13,7 @@ import ( "github.com/pocketbase/pocketbase/tests" ) -func TestRequestData(t *testing.T) { +func TestRequestInfo(t *testing.T) { e := echo.New() req := httptest.NewRequest(http.MethodPost, "/?test=123", strings.NewReader(`{"test":456}`)) req.Header.Set(echo.HeaderContentType, echo.MIMEApplicationJSON) @@ -29,10 +29,10 @@ func TestRequestData(t *testing.T) { dummyAdmin.Id = "id2" c.Set(apis.ContextAdminKey, dummyAdmin) - result := apis.RequestData(c) + result := apis.RequestInfo(c) if result == nil { - t.Fatal("Expected *models.RequestData instance, got nil") + t.Fatal("Expected *models.RequestInfo instance, got nil") } if result.Method != http.MethodPost { diff --git a/daos/record.go b/daos/record.go index 302a4eee..72855d8e 100644 --- a/daos/record.go +++ b/daos/record.go @@ -520,9 +520,9 @@ func (dao *Dao) SuggestUniqueAuthRecordUsername( } // CanAccessRecord checks if a record is allowed to be accessed by the -// specified requestData and accessRule. +// specified requestInfo and accessRule. // -// Rule and db checks are ignored in case requestData.Admin is set. +// Rule and db checks are ignored in case requestInfo.Admin is set. // // The returned error indicate that something unexpected happened during // the check (eg. invalid rule or db error). @@ -531,14 +531,14 @@ func (dao *Dao) SuggestUniqueAuthRecordUsername( // // Example: // -// requestData := apis.RequestData(c /* echo.Context */) +// requestInfo := apis.RequestInfo(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 { ... } -func (dao *Dao) CanAccessRecord(record *models.Record, requestData *models.RequestData, accessRule *string) (bool, error) { - if requestData.Admin != nil { +// if ok, _ := dao.CanAccessRecord(record, requestInfo, rule); ok { ... } +func (dao *Dao) CanAccessRecord(record *models.Record, requestInfo *models.RequestInfo, accessRule *string) (bool, error) { + if requestInfo.Admin != nil { // admins can access everything return true, nil } @@ -560,7 +560,7 @@ func (dao *Dao) CanAccessRecord(record *models.Record, requestData *models.Reque AndWhere(dbx.HashExp{record.Collection().Name + ".id": record.Id}) // parse and apply the access rule filter - resolver := resolvers.NewRecordFieldResolver(dao, record.Collection(), requestData, true) + resolver := resolvers.NewRecordFieldResolver(dao, record.Collection(), requestInfo, true) expr, err := search.FilterData(*accessRule).BuildExpr(resolver) if err != nil { return false, err diff --git a/daos/record_test.go b/daos/record_test.go index 6578ec1a..ebe2fbeb 100644 --- a/daos/record_test.go +++ b/daos/record_test.go @@ -625,7 +625,7 @@ func TestCanAccessRecord(t *testing.T) { scenarios := []struct { name string record *models.Record - requestData *models.RequestData + requestInfo *models.RequestInfo rule *string expected bool expectError bool @@ -633,7 +633,7 @@ func TestCanAccessRecord(t *testing.T) { { "as admin with nil rule", record, - &models.RequestData{ + &models.RequestInfo{ Admin: admin, }, nil, @@ -643,7 +643,7 @@ func TestCanAccessRecord(t *testing.T) { { "as admin with non-empty rule", record, - &models.RequestData{ + &models.RequestInfo{ Admin: admin, }, types.Pointer("id = ''"), // the filter rule should be ignored @@ -653,7 +653,7 @@ func TestCanAccessRecord(t *testing.T) { { "as admin with invalid rule", record, - &models.RequestData{ + &models.RequestInfo{ Admin: admin, }, types.Pointer("id ?!@ 1"), // the filter rule should be ignored @@ -663,7 +663,7 @@ func TestCanAccessRecord(t *testing.T) { { "as guest with nil rule", record, - &models.RequestData{}, + &models.RequestInfo{}, nil, false, false, @@ -671,7 +671,7 @@ func TestCanAccessRecord(t *testing.T) { { "as guest with empty rule", record, - &models.RequestData{}, + &models.RequestInfo{}, types.Pointer(""), true, false, @@ -679,7 +679,7 @@ func TestCanAccessRecord(t *testing.T) { { "as guest with invalid rule", record, - &models.RequestData{}, + &models.RequestInfo{}, types.Pointer("id ?!@ 1"), false, true, @@ -687,7 +687,7 @@ func TestCanAccessRecord(t *testing.T) { { "as guest with mismatched rule", record, - &models.RequestData{}, + &models.RequestInfo{}, types.Pointer("@request.auth.id != ''"), false, false, @@ -695,7 +695,7 @@ func TestCanAccessRecord(t *testing.T) { { "as guest with matched rule", record, - &models.RequestData{ + &models.RequestInfo{ Data: map[string]any{"test": 1}, }, types.Pointer("@request.auth.id != '' || @request.data.test = 1"), @@ -705,7 +705,7 @@ func TestCanAccessRecord(t *testing.T) { { "as auth record with nil rule", record, - &models.RequestData{ + &models.RequestInfo{ AuthRecord: authRecord, }, nil, @@ -715,7 +715,7 @@ func TestCanAccessRecord(t *testing.T) { { "as auth record with empty rule", record, - &models.RequestData{ + &models.RequestInfo{ AuthRecord: authRecord, }, types.Pointer(""), @@ -725,7 +725,7 @@ func TestCanAccessRecord(t *testing.T) { { "as auth record with invalid rule", record, - &models.RequestData{ + &models.RequestInfo{ AuthRecord: authRecord, }, types.Pointer("id ?!@ 1"), @@ -735,7 +735,7 @@ func TestCanAccessRecord(t *testing.T) { { "as auth record with mismatched rule", record, - &models.RequestData{ + &models.RequestInfo{ AuthRecord: authRecord, Data: map[string]any{"test": 1}, }, @@ -746,7 +746,7 @@ func TestCanAccessRecord(t *testing.T) { { "as auth record with matched rule", record, - &models.RequestData{ + &models.RequestInfo{ AuthRecord: authRecord, Data: map[string]any{"test": 2}, }, @@ -757,7 +757,7 @@ func TestCanAccessRecord(t *testing.T) { } for _, s := range scenarios { - result, err := app.Dao().CanAccessRecord(s.record, s.requestData, s.rule) + result, err := app.Dao().CanAccessRecord(s.record, s.requestInfo, s.rule) if result != s.expected { t.Errorf("[%s] Expected %v, got %v", s.name, s.expected, result) diff --git a/forms/record_upsert.go b/forms/record_upsert.go index 80cfe842..4ddb24c5 100644 --- a/forms/record_upsert.go +++ b/forms/record_upsert.go @@ -117,7 +117,7 @@ func (form *RecordUpsert) getContentType(r *http.Request) string { return t } -func (form *RecordUpsert) extractRequestData( +func (form *RecordUpsert) extractRequestInfo( r *http.Request, keyPrefix string, ) (map[string]any, map[string][]*filesystem.File, error) { @@ -219,12 +219,12 @@ func (form *RecordUpsert) extractMultipartFormData( // // File upload is supported only via multipart/form-data. func (form *RecordUpsert) LoadRequest(r *http.Request, keyPrefix string) error { - requestData, uploadedFiles, err := form.extractRequestData(r, keyPrefix) + requestInfo, uploadedFiles, err := form.extractRequestInfo(r, keyPrefix) if err != nil { return err } - if err := form.LoadData(requestData); err != nil { + if err := form.LoadData(requestInfo); err != nil { return err } @@ -349,39 +349,39 @@ func (form *RecordUpsert) RemoveFiles(key string, toDelete ...string) error { } // LoadData loads and normalizes the provided regular record data fields into the form. -func (form *RecordUpsert) LoadData(requestData map[string]any) error { +func (form *RecordUpsert) LoadData(requestInfo map[string]any) error { // load base system fields - if v, ok := requestData[schema.FieldNameId]; ok { + if v, ok := requestInfo[schema.FieldNameId]; ok { form.Id = cast.ToString(v) } // load auth system fields if form.record.Collection().IsAuth() { - if v, ok := requestData[schema.FieldNameUsername]; ok { + if v, ok := requestInfo[schema.FieldNameUsername]; ok { form.Username = cast.ToString(v) } - if v, ok := requestData[schema.FieldNameEmail]; ok { + if v, ok := requestInfo[schema.FieldNameEmail]; ok { form.Email = cast.ToString(v) } - if v, ok := requestData[schema.FieldNameEmailVisibility]; ok { + if v, ok := requestInfo[schema.FieldNameEmailVisibility]; ok { form.EmailVisibility = cast.ToBool(v) } - if v, ok := requestData[schema.FieldNameVerified]; ok { + if v, ok := requestInfo[schema.FieldNameVerified]; ok { form.Verified = cast.ToBool(v) } - if v, ok := requestData["password"]; ok { + if v, ok := requestInfo["password"]; ok { form.Password = cast.ToString(v) } - if v, ok := requestData["passwordConfirm"]; ok { + if v, ok := requestInfo["passwordConfirm"]; ok { form.PasswordConfirm = cast.ToString(v) } - if v, ok := requestData["oldPassword"]; ok { + if v, ok := requestInfo["oldPassword"]; ok { form.OldPassword = cast.ToString(v) } } // replace modifiers (if any) - requestData = form.record.ReplaceModifers(requestData) + requestInfo = form.record.ReplaceModifers(requestInfo) // create a shallow copy of form.data var extendedData = make(map[string]any, len(form.data)) @@ -390,7 +390,7 @@ func (form *RecordUpsert) LoadData(requestData map[string]any) error { } // extend form.data with the request data - rawData, err := json.Marshal(requestData) + rawData, err := json.Marshal(requestInfo) if err != nil { return err } diff --git a/models/request_data.go b/models/request_info.go similarity index 69% rename from models/request_data.go rename to models/request_info.go index 594c49ce..d8388521 100644 --- a/models/request_data.go +++ b/models/request_info.go @@ -6,12 +6,11 @@ import ( "github.com/pocketbase/pocketbase/models/schema" ) -// RequestData defines a HTTP request data struct, usually used +// RequestInfo defines a HTTP request data struct, usually used // as part of the `@request.*` filter resolver. -type RequestData struct { - Method string `json:"method"` - Query map[string]any `json:"query"` - // @todo consider changing to Body? +type RequestInfo struct { + Method string `json:"method"` + Query map[string]any `json:"query"` Data map[string]any `json:"data"` Headers map[string]any `json:"headers"` AuthRecord *Record `json:"authRecord"` @@ -19,7 +18,7 @@ type RequestData struct { } // HasModifierDataKeys loosely checks if the current struct has any modifier Data keys. -func (r *RequestData) HasModifierDataKeys() bool { +func (r *RequestInfo) HasModifierDataKeys() bool { allModifiers := schema.FieldValueModifiers() for key := range r.Data { diff --git a/models/request_data_test.go b/models/request_info_test.go similarity index 77% rename from models/request_data_test.go rename to models/request_info_test.go index 5acedc12..bc5be1e5 100644 --- a/models/request_data_test.go +++ b/models/request_info_test.go @@ -6,20 +6,20 @@ import ( "github.com/pocketbase/pocketbase/models" ) -func TestRequestDataHasModifierDataKeys(t *testing.T) { +func TestRequestInfoHasModifierDataKeys(t *testing.T) { scenarios := []struct { name string - requestData *models.RequestData + requestInfo *models.RequestInfo expected bool }{ { "empty", - &models.RequestData{}, + &models.RequestInfo{}, false, }, { "Data with regular fields", - &models.RequestData{ + &models.RequestInfo{ Query: map[string]any{"data+": "demo"}, // should be ignored Data: map[string]any{"a": 123, "b": "test", "c.d": false}, }, @@ -27,21 +27,21 @@ func TestRequestDataHasModifierDataKeys(t *testing.T) { }, { "Data with +modifier fields", - &models.RequestData{ + &models.RequestInfo{ Data: map[string]any{"a+": 123, "b": "test", "c.d": false}, }, true, }, { "Data with -modifier fields", - &models.RequestData{ + &models.RequestInfo{ Data: map[string]any{"a": 123, "b-": "test", "c.d": false}, }, true, }, { "Data with mixed modifier fields", - &models.RequestData{ + &models.RequestInfo{ Data: map[string]any{"a": 123, "b-": "test", "c.d+": false}, }, true, @@ -49,7 +49,7 @@ func TestRequestDataHasModifierDataKeys(t *testing.T) { } for _, s := range scenarios { - result := s.requestData.HasModifierDataKeys() + result := s.requestInfo.HasModifierDataKeys() if result != s.expected { t.Fatalf("[%s] Expected %v, got %v", s.name, s.expected, result) diff --git a/plugins/jsvm/binds.go b/plugins/jsvm/binds.go index e9db5775..08c5b070 100644 --- a/plugins/jsvm/binds.go +++ b/plugins/jsvm/binds.go @@ -319,6 +319,25 @@ func baseBinds(vm *goja.Runtime) { return structConstructor(vm, call, instance) }) + vm.Set("RequestInfo", func(call goja.ConstructorCall) *goja.Object { + instance := &models.RequestInfo{} + return structConstructor(vm, call, instance) + }) + + vm.Set("DateTime", func(call goja.ConstructorCall) *goja.Object { + instance := types.NowDateTime() + + val, _ := call.Argument(0).Export().(string) + if val != "" { + instance, _ = types.ParseDateTime(val) + } + + instanceValue := vm.ToValue(instance).(*goja.Object) + instanceValue.SetPrototype(call.This.Prototype()) + + return structConstructor(vm, call, instance) + }) + vm.Set("ValidationError", func(call goja.ConstructorCall) *goja.Object { code, _ := call.Argument(0).Export().(string) message, _ := call.Argument(1).Export().(string) @@ -462,7 +481,7 @@ func apisBinds(vm *goja.Runtime) { obj.Set("activityLogger", apis.ActivityLogger) // record helpers - obj.Set("requestData", apis.RequestData) + obj.Set("requestInfo", apis.RequestInfo) obj.Set("recordAuthResponse", apis.RecordAuthResponse) obj.Set("enrichRecord", apis.EnrichRecord) obj.Set("enrichRecords", apis.EnrichRecords) diff --git a/plugins/jsvm/binds_test.go b/plugins/jsvm/binds_test.go index 38ae9001..e6cfaa27 100644 --- a/plugins/jsvm/binds_test.go +++ b/plugins/jsvm/binds_test.go @@ -45,7 +45,7 @@ func TestBaseBindsCount(t *testing.T) { vm := goja.New() baseBinds(vm) - testBindsCount(vm, "this", 14, t) + testBindsCount(vm, "this", 16, t) } func TestBaseBindsRecord(t *testing.T) { @@ -248,6 +248,50 @@ func TestBaseBindsCommand(t *testing.T) { } } +func TestBaseBindsRequestInfo(t *testing.T) { + vm := goja.New() + baseBinds(vm) + + _, err := vm.RunString(` + let info = new RequestInfo({ + admin: new Admin({id: "test1"}), + data: {"name": "test2"} + }); + + if (info.admin?.id != "test1") { + throw new Error('Expected info.admin.id to be test1, got: ' + info.admin?.id); + } + + if (info.data?.name != "test2") { + throw new Error('Expected info.data.name to be test2, got: ' + info.data?.name); + } + `) + if err != nil { + t.Fatal(err) + } +} + +func TestBaseBindsDateTime(t *testing.T) { + vm := goja.New() + baseBinds(vm) + + _, err := vm.RunString(` + const v0 = new DateTime(); + if (v0.isZero()) { + throw new Error('Expected to fallback to now, got zero value'); + } + + const v1 = new DateTime('2023-01-01 00:00:00.000Z'); + const expected = "2023-01-01 00:00:00.000Z" + if (v1.string() != expected) { + throw new Error('Expected ' + expected + ', got ', v1.string()); + } + `) + if err != nil { + t.Fatal(err) + } +} + func TestBaseBindsValidationError(t *testing.T) { vm := goja.New() baseBinds(vm) diff --git a/plugins/jsvm/internal/types/generated/types.d.ts b/plugins/jsvm/internal/types/generated/types.d.ts index 2bc884fa..bb662016 100644 --- a/plugins/jsvm/internal/types/generated/types.d.ts +++ b/plugins/jsvm/internal/types/generated/types.d.ts @@ -293,6 +293,8 @@ interface Command extends cobra.Command{} // merge /** * Command defines a single console command. * + * Example: + * * ```js * const command = new Command({ * use: "hello", @@ -308,6 +310,51 @@ declare class Command implements cobra.Command { constructor(cmd?: Partial) } +interface RequestInfo extends models.RequestInfo{} // merge +/** + * RequestInfo defines a single models.RequestInfo instance, usually used + * as part of various filter checks. + * + * Example: + * + * ```js + * const authRecord = $app.dao().findAuthRecordByEmail("users", "test@example.com") + * + * const info = new RequestInfo({ + * authRecord: authRecord, + * data: {"name": 123}, + * headers: {"x-token": "..."}, + * }) + * + * const record = $app.dao().findFirstRecordByData("articles", "slug", "hello") + * + * const canAccess = $app.dao().canAccessRecord(record, info, "@request.auth.id != '' && @request.data.name = 123") + * ``` + * + * @group PocketBase + */ +declare class RequestInfo implements models.RequestInfo { + constructor(date?: Partial) +} + +interface DateTime extends types.DateTime{} // merge +/** + * DateTime defines a single DateTime type instance. + * + * Example: + * + * ```js + * const dt0 = new DateTime() // now + * + * const dt1 = new DateTime('2023-07-01 00:00:00.000Z') + * ``` + * + * @group PocketBase + */ +declare class DateTime implements types.DateTime { + constructor(date?: string) +} + interface ValidationError extends ozzo_validation.Error{} // merge /** * ValidationError defines a single formatted data validation error, @@ -675,7 +722,7 @@ declare namespace $apis { let requireAdminOrRecordAuth: apis.requireAdminOrRecordAuth let requireAdminOrOwnerAuth: apis.requireAdminOrOwnerAuth let activityLogger: apis.activityLogger - let requestData: apis.requestData + let requestInfo: apis.requestInfo let recordAuthResponse: apis.recordAuthResponse let enrichRecord: apis.enrichRecord let enrichRecords: apis.enrichRecords @@ -1162,14 +1209,14 @@ namespace dbx { /** * MssqlBuilder is the builder for SQL Server databases. */ - type _subhTwHb = BaseBuilder - interface MssqlBuilder extends _subhTwHb { + type _subAkUvq = BaseBuilder + interface MssqlBuilder extends _subAkUvq { } /** * MssqlQueryBuilder is the query builder for SQL Server databases. */ - type _subSFdQZ = BaseQueryBuilder - interface MssqlQueryBuilder extends _subSFdQZ { + type _subdzmCM = BaseQueryBuilder + interface MssqlQueryBuilder extends _subdzmCM { } interface newMssqlBuilder { /** @@ -1240,8 +1287,8 @@ namespace dbx { /** * MysqlBuilder is the builder for MySQL databases. */ - type _subyQJBY = BaseBuilder - interface MysqlBuilder extends _subyQJBY { + type _subtIIBc = BaseBuilder + interface MysqlBuilder extends _subtIIBc { } interface newMysqlBuilder { /** @@ -1316,14 +1363,14 @@ namespace dbx { /** * OciBuilder is the builder for Oracle databases. */ - type _subQRkKI = BaseBuilder - interface OciBuilder extends _subQRkKI { + type _subonuRB = BaseBuilder + interface OciBuilder extends _subonuRB { } /** * OciQueryBuilder is the query builder for Oracle databases. */ - type _subZOEFS = BaseQueryBuilder - interface OciQueryBuilder extends _subZOEFS { + type _subGMElI = BaseQueryBuilder + interface OciQueryBuilder extends _subGMElI { } interface newOciBuilder { /** @@ -1386,8 +1433,8 @@ namespace dbx { /** * PgsqlBuilder is the builder for PostgreSQL databases. */ - type _subTFpHm = BaseBuilder - interface PgsqlBuilder extends _subTFpHm { + type _subeZwqB = BaseBuilder + interface PgsqlBuilder extends _subeZwqB { } interface newPgsqlBuilder { /** @@ -1454,8 +1501,8 @@ namespace dbx { /** * SqliteBuilder is the builder for SQLite databases. */ - type _subTCgBN = BaseBuilder - interface SqliteBuilder extends _subTCgBN { + type _subQFvWV = BaseBuilder + interface SqliteBuilder extends _subQFvWV { } interface newSqliteBuilder { /** @@ -1554,8 +1601,8 @@ namespace dbx { /** * StandardBuilder is the builder that is used by DB for an unknown driver. */ - type _subaDaOx = BaseBuilder - interface StandardBuilder extends _subaDaOx { + type _subByRrQ = BaseBuilder + interface StandardBuilder extends _subByRrQ { } interface newStandardBuilder { /** @@ -1621,8 +1668,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 _subgOxIk = Builder - interface DB extends _subgOxIk { + type _subISBjp = Builder + interface DB extends _subISBjp { /** * FieldMapper maps struct fields to DB columns. Defaults to DefaultFieldMapFunc. */ @@ -2420,8 +2467,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 _subiXsFy = sql.Rows - interface Rows extends _subiXsFy { + type _subzAzDq = sql.Rows + interface Rows extends _subzAzDq { } interface Rows { /** @@ -2778,8 +2825,8 @@ namespace dbx { }): string } interface structInfo { } - type _subMgNPp = structInfo - interface structValue extends _subMgNPp { + type _subKpwkL = structInfo + interface structValue extends _subKpwkL { } interface fieldInfo { } @@ -2817,8 +2864,8 @@ namespace dbx { /** * Tx enhances sql.Tx with additional querying methods. */ - type _subiJXLn = Builder - interface Tx extends _subiJXLn { + type _subiDfNy = Builder + interface Tx extends _subiDfNy { } interface Tx { /** @@ -3002,8 +3049,8 @@ namespace filesystem { */ open(): io.ReadSeekCloser } - type _subxGCDv = bytes.Reader - interface bytesReadSeekCloser extends _subxGCDv { + type _subQYXQU = bytes.Reader + interface bytesReadSeekCloser extends _subQYXQU { } interface bytesReadSeekCloser { /** @@ -3965,7 +4012,7 @@ namespace forms { /** * LoadData loads and normalizes the provided regular record data fields into the form. */ - loadData(requestData: _TygojaDict): void + loadData(requestInfo: _TygojaDict): void } interface RecordUpsert { /** @@ -4075,8 +4122,8 @@ namespace forms { /** * SettingsUpsert is a [settings.Settings] upsert (create/update) form. */ - type _subvjsVi = settings.Settings - interface SettingsUpsert extends _subvjsVi { + type _subPQrmU = settings.Settings + interface SettingsUpsert extends _subPQrmU { } interface newSettingsUpsert { /** @@ -4393,10 +4440,16 @@ namespace apis { } interface requestData { /** - * RequestData exports cached common request data fields + * Deprecated: Use RequestInfo instead. + */ + (c: echo.Context): (models.RequestInfo | undefined) + } + interface requestInfo { + /** + * RequestInfo exports cached common request data fields * (query, body, logged auth state, etc.) from the provided context. */ - (c: echo.Context): (models.RequestData | undefined) + (c: echo.Context): (models.RequestInfo | undefined) } interface recordAuthResponse { /** @@ -4466,8 +4519,8 @@ namespace pocketbase { /** * appWrapper serves as a private core.App instance wrapper. */ - type _subMxGWY = core.App - interface appWrapper extends _subMxGWY { + type _subQpBgz = core.App + interface appWrapper extends _subQpBgz { } /** * PocketBase defines a PocketBase app launcher. @@ -4475,8 +4528,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 _subQqRpc = appWrapper - interface PocketBase extends _subQqRpc { + type _subaABeV = appWrapper + interface PocketBase extends _subaABeV { /** * RootCmd is the main console command */ @@ -4799,6 +4852,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 @@ -4956,1068 +5038,59 @@ 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. + * 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 fs { +namespace jwt { /** - * 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. + * 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 FS { + interface MapClaims extends _TygojaDict{} + interface MapClaims { /** - * 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. + * VerifyAudience Compares the aud claim against cmp. + * If required is false, this method will return true if the value matches or is unset */ - open(name: string): File + verifyAudience(cmp: string, req: boolean): boolean } -} - -/** - * 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. - */ -namespace cobra { - interface Command { + interface MapClaims { /** - * GenBashCompletion generates bash completion file and writes to the passed writer. + * VerifyExpiresAt compares the exp claim against cmp (cmp <= exp). + * If req is false, it will return true, if exp is unset. */ - genBashCompletion(w: io.Writer): void + verifyExpiresAt(cmp: number, req: boolean): boolean } - interface Command { + interface MapClaims { /** - * GenBashCompletionFile generates bash completion file. + * VerifyIssuedAt compares the exp claim against cmp (cmp >= iat). + * If req is false, it will return true, if iat is unset. */ - genBashCompletionFile(filename: string): void + verifyIssuedAt(cmp: number, req: boolean): boolean } - interface Command { + interface MapClaims { /** - * GenBashCompletionFileV2 generates Bash completion version 2. + * VerifyNotBefore compares the nbf claim against cmp (cmp >= nbf). + * If req is false, it will return true, if nbf is unset. */ - genBashCompletionFileV2(filename: string, includeDesc: boolean): void + verifyNotBefore(cmp: number, req: boolean): boolean } - interface Command { + interface MapClaims { /** - * GenBashCompletionV2 generates Bash completion file version 2 - * and writes it to the passed writer. + * VerifyIssuer compares the iss claim against cmp. + * If required is false, this method will return true if the value matches or is unset */ - genBashCompletionV2(w: io.Writer, includeDesc: boolean): void + verifyIssuer(cmp: string, req: boolean): boolean } - // @ts-ignore - import flag = pflag - /** - * Command is just that, a command for your application. - * E.g. 'go run ...' - 'run' is the command. Cobra requires - * you to define the usage and description as part of your command - * definition to ensure usability. - */ - interface Command { + interface MapClaims { /** - * Use is the one-line usage message. - * Recommended syntax is as follows: - * ``` - * [ ] identifies an optional argument. Arguments that are not enclosed in brackets are required. - * ... indicates that you can specify multiple values for the previous argument. - * | indicates mutually exclusive information. You can use the argument to the left of the separator or the - * argument to the right of the separator. You cannot use both arguments in a single use of the command. - * { } delimits a set of mutually exclusive arguments when one of the arguments is required. If the arguments are - * optional, they are enclosed in brackets ([ ]). - * ``` - * Example: add [-F file | -D dir]... [-f format] profile + * 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. */ - use: string - /** - * Aliases is an array of aliases that can be used instead of the first word in Use. - */ - aliases: Array - /** - * SuggestFor is an array of command names for which this command will be suggested - - * similar to aliases but only suggests. - */ - suggestFor: Array - /** - * Short is the short description shown in the 'help' output. - */ - short: string - /** - * The group id under which this subcommand is grouped in the 'help' output of its parent. - */ - groupID: string - /** - * Long is the long message shown in the 'help ' output. - */ - long: string - /** - * Example is examples of how to use the command. - */ - example: string - /** - * ValidArgs is list of all valid non-flag arguments that are accepted in shell completions - */ - validArgs: Array - /** - * ValidArgsFunction is an optional function that provides valid non-flag arguments for shell completion. - * It is a dynamic version of using ValidArgs. - * Only one of ValidArgs and ValidArgsFunction can be used for a command. - */ - validArgsFunction: (cmd: Command, args: Array, toComplete: string) => [Array, ShellCompDirective] - /** - * Expected arguments - */ - args: PositionalArgs - /** - * ArgAliases is List of aliases for ValidArgs. - * These are not suggested to the user in the shell completion, - * but accepted if entered manually. - */ - argAliases: Array - /** - * BashCompletionFunction is custom bash functions used by the legacy bash autocompletion generator. - * For portability with other shells, it is recommended to instead use ValidArgsFunction - */ - bashCompletionFunction: string - /** - * Deprecated defines, if this command is deprecated and should print this string when used. - */ - deprecated: string - /** - * Annotations are key/value pairs that can be used by applications to identify or - * group commands. - */ - annotations: _TygojaDict - /** - * Version defines the version for this command. If this value is non-empty and the command does not - * define a "version" flag, a "version" boolean flag will be added to the command and, if specified, - * will print content of the "Version" variable. A shorthand "v" flag will also be added if the - * command does not define one. - */ - version: string - /** - * The *Run functions are executed in the following order: - * ``` - * * PersistentPreRun() - * * PreRun() - * * Run() - * * PostRun() - * * PersistentPostRun() - * ``` - * All functions get the same args, the arguments after the command name. - * - * PersistentPreRun: children of this command will inherit and execute. - */ - persistentPreRun: (cmd: Command, args: Array) => void - /** - * PersistentPreRunE: PersistentPreRun but returns an error. - */ - persistentPreRunE: (cmd: Command, args: Array) => void - /** - * PreRun: children of this command will not inherit. - */ - preRun: (cmd: Command, args: Array) => void - /** - * PreRunE: PreRun but returns an error. - */ - preRunE: (cmd: Command, args: Array) => void - /** - * Run: Typically the actual work function. Most commands will only implement this. - */ - run: (cmd: Command, args: Array) => void - /** - * RunE: Run but returns an error. - */ - runE: (cmd: Command, args: Array) => void - /** - * PostRun: run after the Run command. - */ - postRun: (cmd: Command, args: Array) => void - /** - * PostRunE: PostRun but returns an error. - */ - postRunE: (cmd: Command, args: Array) => void - /** - * PersistentPostRun: children of this command will inherit and execute after PostRun. - */ - persistentPostRun: (cmd: Command, args: Array) => void - /** - * PersistentPostRunE: PersistentPostRun but returns an error. - */ - persistentPostRunE: (cmd: Command, args: Array) => void - /** - * FParseErrWhitelist flag parse errors to be ignored - */ - fParseErrWhitelist: FParseErrWhitelist - /** - * CompletionOptions is a set of options to control the handling of shell completion - */ - completionOptions: CompletionOptions - /** - * TraverseChildren parses flags on all parents before executing child command. - */ - traverseChildren: boolean - /** - * Hidden defines, if this command is hidden and should NOT show up in the list of available commands. - */ - hidden: boolean - /** - * SilenceErrors is an option to quiet errors down stream. - */ - silenceErrors: boolean - /** - * SilenceUsage is an option to silence usage when an error occurs. - */ - silenceUsage: boolean - /** - * DisableFlagParsing disables the flag parsing. - * If this is true all flags will be passed to the command as arguments. - */ - disableFlagParsing: boolean - /** - * DisableAutoGenTag defines, if gen tag ("Auto generated by spf13/cobra...") - * will be printed by generating docs for this command. - */ - disableAutoGenTag: boolean - /** - * DisableFlagsInUseLine will disable the addition of [flags] to the usage - * line of a command when printing help or generating docs - */ - disableFlagsInUseLine: boolean - /** - * DisableSuggestions disables the suggestions based on Levenshtein distance - * that go along with 'unknown command' messages. - */ - disableSuggestions: boolean - /** - * SuggestionsMinimumDistance defines minimum levenshtein distance to display suggestions. - * Must be > 0. - */ - suggestionsMinimumDistance: number - } - interface Command { - /** - * Context returns underlying command context. If command was executed - * with ExecuteContext or the context was set with SetContext, the - * previously set context will be returned. Otherwise, nil is returned. - * - * Notice that a call to Execute and ExecuteC will replace a nil context of - * a command with a context.Background, so a background context will be - * returned by Context after one of these functions has been called. - */ - context(): context.Context - } - interface Command { - /** - * SetContext sets context for the command. This context will be overwritten by - * Command.ExecuteContext or Command.ExecuteContextC. - */ - setContext(ctx: context.Context): void - } - interface Command { - /** - * SetArgs sets arguments for the command. It is set to os.Args[1:] by default, if desired, can be overridden - * particularly useful when testing. - */ - setArgs(a: Array): void - } - interface Command { - /** - * SetOutput sets the destination for usage and error messages. - * If output is nil, os.Stderr is used. - * Deprecated: Use SetOut and/or SetErr instead - */ - setOutput(output: io.Writer): void - } - interface Command { - /** - * SetOut sets the destination for usage messages. - * If newOut is nil, os.Stdout is used. - */ - setOut(newOut: io.Writer): void - } - interface Command { - /** - * SetErr sets the destination for error messages. - * If newErr is nil, os.Stderr is used. - */ - setErr(newErr: io.Writer): void - } - interface Command { - /** - * SetIn sets the source for input data - * If newIn is nil, os.Stdin is used. - */ - setIn(newIn: io.Reader): void - } - interface Command { - /** - * SetUsageFunc sets usage function. Usage can be defined by application. - */ - setUsageFunc(f: (_arg0: Command) => void): void - } - interface Command { - /** - * SetUsageTemplate sets usage template. Can be defined by Application. - */ - setUsageTemplate(s: string): void - } - interface Command { - /** - * SetFlagErrorFunc sets a function to generate an error when flag parsing - * fails. - */ - setFlagErrorFunc(f: (_arg0: Command, _arg1: Error) => void): void - } - interface Command { - /** - * SetHelpFunc sets help function. Can be defined by Application. - */ - setHelpFunc(f: (_arg0: Command, _arg1: Array) => void): void - } - interface Command { - /** - * SetHelpCommand sets help command. - */ - setHelpCommand(cmd: Command): void - } - interface Command { - /** - * SetHelpCommandGroupID sets the group id of the help command. - */ - setHelpCommandGroupID(groupID: string): void - } - interface Command { - /** - * SetCompletionCommandGroupID sets the group id of the completion command. - */ - setCompletionCommandGroupID(groupID: string): void - } - interface Command { - /** - * SetHelpTemplate sets help template to be used. Application can use it to set custom template. - */ - setHelpTemplate(s: string): void - } - interface Command { - /** - * SetVersionTemplate sets version template to be used. Application can use it to set custom template. - */ - setVersionTemplate(s: string): void - } - interface Command { - /** - * SetGlobalNormalizationFunc sets a normalization function to all flag sets and also to child commands. - * The user should not have a cyclic dependency on commands. - */ - setGlobalNormalizationFunc(n: (f: flag.FlagSet, name: string) => flag.NormalizedName): void - } - interface Command { - /** - * OutOrStdout returns output to stdout. - */ - outOrStdout(): io.Writer - } - interface Command { - /** - * OutOrStderr returns output to stderr - */ - outOrStderr(): io.Writer - } - interface Command { - /** - * ErrOrStderr returns output to stderr - */ - errOrStderr(): io.Writer - } - interface Command { - /** - * InOrStdin returns input to stdin - */ - inOrStdin(): io.Reader - } - interface Command { - /** - * UsageFunc returns either the function set by SetUsageFunc for this command - * or a parent, or it returns a default usage function. - */ - usageFunc(): (_arg0: Command) => void - } - interface Command { - /** - * Usage puts out the usage for the command. - * Used when a user provides invalid input. - * Can be defined by user by overriding UsageFunc. - */ - usage(): void - } - interface Command { - /** - * HelpFunc returns either the function set by SetHelpFunc for this command - * or a parent, or it returns a function with default help behavior. - */ - helpFunc(): (_arg0: Command, _arg1: Array) => void - } - interface Command { - /** - * Help puts out the help for the command. - * Used when a user calls help [command]. - * Can be defined by user by overriding HelpFunc. - */ - help(): void - } - interface Command { - /** - * UsageString returns usage string. - */ - usageString(): string - } - interface Command { - /** - * FlagErrorFunc returns either the function set by SetFlagErrorFunc for this - * command or a parent, or it returns a function which returns the original - * error. - */ - flagErrorFunc(): (_arg0: Command, _arg1: Error) => void - } - interface Command { - /** - * UsagePadding return padding for the usage. - */ - usagePadding(): number - } - interface Command { - /** - * CommandPathPadding return padding for the command path. - */ - commandPathPadding(): number - } - interface Command { - /** - * NamePadding returns padding for the name. - */ - namePadding(): number - } - interface Command { - /** - * UsageTemplate returns usage template for the command. - */ - usageTemplate(): string - } - interface Command { - /** - * HelpTemplate return help template for the command. - */ - helpTemplate(): string - } - interface Command { - /** - * VersionTemplate return version template for the command. - */ - versionTemplate(): string - } - interface Command { - /** - * Find the target command given the args and command tree - * Meant to be run on the highest node. Only searches down. - */ - find(args: Array): [(Command | undefined), Array] - } - interface Command { - /** - * Traverse the command tree to find the command, and parse args for - * each parent. - */ - traverse(args: Array): [(Command | undefined), Array] - } - interface Command { - /** - * SuggestionsFor provides suggestions for the typedName. - */ - suggestionsFor(typedName: string): Array - } - interface Command { - /** - * VisitParents visits all parents of the command and invokes fn on each parent. - */ - visitParents(fn: (_arg0: Command) => void): void - } - interface Command { - /** - * Root finds root command. - */ - root(): (Command | undefined) - } - interface Command { - /** - * ArgsLenAtDash will return the length of c.Flags().Args at the moment - * when a -- was found during args parsing. - */ - argsLenAtDash(): number - } - interface Command { - /** - * ExecuteContext is the same as Execute(), but sets the ctx on the command. - * Retrieve ctx by calling cmd.Context() inside your *Run lifecycle or ValidArgs - * functions. - */ - executeContext(ctx: context.Context): void - } - interface Command { - /** - * Execute uses the args (os.Args[1:] by default) - * and run through the command tree finding appropriate matches - * for commands and then corresponding flags. - */ - execute(): void - } - interface Command { - /** - * ExecuteContextC is the same as ExecuteC(), but sets the ctx on the command. - * Retrieve ctx by calling cmd.Context() inside your *Run lifecycle or ValidArgs - * functions. - */ - executeContextC(ctx: context.Context): (Command | undefined) - } - interface Command { - /** - * ExecuteC executes the command. - */ - executeC(): (Command | undefined) - } - interface Command { - validateArgs(args: Array): void - } - interface Command { - /** - * ValidateRequiredFlags validates all required flags are present and returns an error otherwise - */ - validateRequiredFlags(): void - } - interface Command { - /** - * InitDefaultHelpFlag adds default help flag to c. - * It is called automatically by executing the c or by calling help and usage. - * If c already has help flag, it will do nothing. - */ - initDefaultHelpFlag(): void - } - interface Command { - /** - * InitDefaultVersionFlag adds default version flag to c. - * It is called automatically by executing the c. - * If c already has a version flag, it will do nothing. - * If c.Version is empty, it will do nothing. - */ - initDefaultVersionFlag(): void - } - interface Command { - /** - * InitDefaultHelpCmd adds default help command to c. - * It is called automatically by executing the c or by calling help and usage. - * If c already has help command or c has no subcommands, it will do nothing. - */ - initDefaultHelpCmd(): void - } - interface Command { - /** - * ResetCommands delete parent, subcommand and help command from c. - */ - resetCommands(): void - } - interface Command { - /** - * Commands returns a sorted slice of child commands. - */ - commands(): Array<(Command | undefined)> - } - interface Command { - /** - * AddCommand adds one or more commands to this parent command. - */ - addCommand(...cmds: (Command | undefined)[]): void - } - interface Command { - /** - * Groups returns a slice of child command groups. - */ - groups(): Array<(Group | undefined)> - } - interface Command { - /** - * AllChildCommandsHaveGroup returns if all subcommands are assigned to a group - */ - allChildCommandsHaveGroup(): boolean - } - interface Command { - /** - * ContainsGroup return if groupID exists in the list of command groups. - */ - containsGroup(groupID: string): boolean - } - interface Command { - /** - * AddGroup adds one or more command groups to this parent command. - */ - addGroup(...groups: (Group | undefined)[]): void - } - interface Command { - /** - * RemoveCommand removes one or more commands from a parent command. - */ - removeCommand(...cmds: (Command | undefined)[]): void - } - interface Command { - /** - * Print is a convenience method to Print to the defined output, fallback to Stderr if not set. - */ - print(...i: { - }[]): void - } - interface Command { - /** - * Println is a convenience method to Println to the defined output, fallback to Stderr if not set. - */ - println(...i: { - }[]): void - } - interface Command { - /** - * Printf is a convenience method to Printf to the defined output, fallback to Stderr if not set. - */ - printf(format: string, ...i: { - }[]): void - } - interface Command { - /** - * PrintErr is a convenience method to Print to the defined Err output, fallback to Stderr if not set. - */ - printErr(...i: { - }[]): void - } - interface Command { - /** - * PrintErrln is a convenience method to Println to the defined Err output, fallback to Stderr if not set. - */ - printErrln(...i: { - }[]): void - } - interface Command { - /** - * PrintErrf is a convenience method to Printf to the defined Err output, fallback to Stderr if not set. - */ - printErrf(format: string, ...i: { - }[]): void - } - interface Command { - /** - * CommandPath returns the full path to this command. - */ - commandPath(): string - } - interface Command { - /** - * UseLine puts out the full usage for a given command (including parents). - */ - useLine(): string - } - interface Command { - /** - * DebugFlags used to determine which flags have been assigned to which commands - * and which persist. - */ - debugFlags(): void - } - interface Command { - /** - * Name returns the command's name: the first word in the use line. - */ - name(): string - } - interface Command { - /** - * HasAlias determines if a given string is an alias of the command. - */ - hasAlias(s: string): boolean - } - interface Command { - /** - * CalledAs returns the command name or alias that was used to invoke - * this command or an empty string if the command has not been called. - */ - calledAs(): string - } - interface Command { - /** - * NameAndAliases returns a list of the command name and all aliases - */ - nameAndAliases(): string - } - interface Command { - /** - * HasExample determines if the command has example. - */ - hasExample(): boolean - } - interface Command { - /** - * Runnable determines if the command is itself runnable. - */ - runnable(): boolean - } - interface Command { - /** - * HasSubCommands determines if the command has children commands. - */ - hasSubCommands(): boolean - } - interface Command { - /** - * IsAvailableCommand determines if a command is available as a non-help command - * (this includes all non deprecated/hidden commands). - */ - isAvailableCommand(): boolean - } - interface Command { - /** - * IsAdditionalHelpTopicCommand determines if a command is an additional - * help topic command; additional help topic command is determined by the - * fact that it is NOT runnable/hidden/deprecated, and has no sub commands that - * are runnable/hidden/deprecated. - * Concrete example: https://github.com/spf13/cobra/issues/393#issuecomment-282741924. - */ - isAdditionalHelpTopicCommand(): boolean - } - interface Command { - /** - * HasHelpSubCommands determines if a command has any available 'help' sub commands - * that need to be shown in the usage/help default template under 'additional help - * topics'. - */ - hasHelpSubCommands(): boolean - } - interface Command { - /** - * HasAvailableSubCommands determines if a command has available sub commands that - * need to be shown in the usage/help default template under 'available commands'. - */ - hasAvailableSubCommands(): boolean - } - interface Command { - /** - * HasParent determines if the command is a child command. - */ - hasParent(): boolean - } - interface Command { - /** - * GlobalNormalizationFunc returns the global normalization function or nil if it doesn't exist. - */ - globalNormalizationFunc(): (f: flag.FlagSet, name: string) => flag.NormalizedName - } - interface Command { - /** - * Flags returns the complete FlagSet that applies - * to this command (local and persistent declared here and by all parents). - */ - flags(): (flag.FlagSet | undefined) - } - interface Command { - /** - * LocalNonPersistentFlags are flags specific to this command which will NOT persist to subcommands. - */ - localNonPersistentFlags(): (flag.FlagSet | undefined) - } - interface Command { - /** - * LocalFlags returns the local FlagSet specifically set in the current command. - */ - localFlags(): (flag.FlagSet | undefined) - } - interface Command { - /** - * InheritedFlags returns all flags which were inherited from parent commands. - */ - inheritedFlags(): (flag.FlagSet | undefined) - } - interface Command { - /** - * NonInheritedFlags returns all flags which were not inherited from parent commands. - */ - nonInheritedFlags(): (flag.FlagSet | undefined) - } - interface Command { - /** - * PersistentFlags returns the persistent FlagSet specifically set in the current command. - */ - persistentFlags(): (flag.FlagSet | undefined) - } - interface Command { - /** - * ResetFlags deletes all flags from command. - */ - resetFlags(): void - } - interface Command { - /** - * HasFlags checks if the command contains any flags (local plus persistent from the entire structure). - */ - hasFlags(): boolean - } - interface Command { - /** - * HasPersistentFlags checks if the command contains persistent flags. - */ - hasPersistentFlags(): boolean - } - interface Command { - /** - * HasLocalFlags checks if the command has flags specifically declared locally. - */ - hasLocalFlags(): boolean - } - interface Command { - /** - * HasInheritedFlags checks if the command has flags inherited from its parent command. - */ - hasInheritedFlags(): boolean - } - interface Command { - /** - * HasAvailableFlags checks if the command contains any flags (local plus persistent from the entire - * structure) which are not hidden or deprecated. - */ - hasAvailableFlags(): boolean - } - interface Command { - /** - * HasAvailablePersistentFlags checks if the command contains persistent flags which are not hidden or deprecated. - */ - hasAvailablePersistentFlags(): boolean - } - interface Command { - /** - * HasAvailableLocalFlags checks if the command has flags specifically declared locally which are not hidden - * or deprecated. - */ - hasAvailableLocalFlags(): boolean - } - interface Command { - /** - * HasAvailableInheritedFlags checks if the command has flags inherited from its parent command which are - * not hidden or deprecated. - */ - hasAvailableInheritedFlags(): boolean - } - interface Command { - /** - * Flag climbs up the command tree looking for matching flag. - */ - flag(name: string): (flag.Flag | undefined) - } - interface Command { - /** - * ParseFlags parses persistent flag tree and local flags. - */ - parseFlags(args: Array): void - } - interface Command { - /** - * Parent returns a commands parent command. - */ - parent(): (Command | undefined) - } - interface Command { - /** - * RegisterFlagCompletionFunc should be called to register a function to provide completion for a flag. - */ - registerFlagCompletionFunc(flagName: string, f: (cmd: Command, args: Array, toComplete: string) => [Array, ShellCompDirective]): void - } - interface Command { - /** - * InitDefaultCompletionCmd adds a default 'completion' command to c. - * This function will do nothing if any of the following is true: - * 1- the feature has been explicitly disabled by the program, - * 2- c has no subcommands (to avoid creating one), - * 3- c already has a 'completion' command provided by the program. - */ - initDefaultCompletionCmd(): void - } - interface Command { - /** - * GenFishCompletion generates fish completion file and writes to the passed writer. - */ - genFishCompletion(w: io.Writer, includeDesc: boolean): void - } - interface Command { - /** - * GenFishCompletionFile generates fish completion file. - */ - genFishCompletionFile(filename: string, includeDesc: boolean): void - } - interface Command { - /** - * MarkFlagsRequiredTogether marks the given flags with annotations so that Cobra errors - * if the command is invoked with a subset (but not all) of the given flags. - */ - markFlagsRequiredTogether(...flagNames: string[]): void - } - interface Command { - /** - * MarkFlagsMutuallyExclusive marks the given flags with annotations so that Cobra errors - * if the command is invoked with more than one flag from the given set of flags. - */ - markFlagsMutuallyExclusive(...flagNames: string[]): void - } - interface Command { - /** - * ValidateFlagGroups validates the mutuallyExclusive/requiredAsGroup logic and returns the - * first error encountered. - */ - validateFlagGroups(): void - } - interface Command { - /** - * GenPowerShellCompletionFile generates powershell completion file without descriptions. - */ - genPowerShellCompletionFile(filename: string): void - } - interface Command { - /** - * GenPowerShellCompletion generates powershell completion file without descriptions - * and writes it to the passed writer. - */ - genPowerShellCompletion(w: io.Writer): void - } - interface Command { - /** - * GenPowerShellCompletionFileWithDesc generates powershell completion file with descriptions. - */ - genPowerShellCompletionFileWithDesc(filename: string): void - } - interface Command { - /** - * GenPowerShellCompletionWithDesc generates powershell completion file with descriptions - * and writes it to the passed writer. - */ - genPowerShellCompletionWithDesc(w: io.Writer): void - } - interface Command { - /** - * MarkFlagRequired instructs the various shell completion implementations to - * prioritize the named flag when performing completion, - * and causes your command to report an error if invoked without the flag. - */ - markFlagRequired(name: string): void - } - interface Command { - /** - * MarkPersistentFlagRequired instructs the various shell completion implementations to - * prioritize the named persistent flag when performing completion, - * and causes your command to report an error if invoked without the flag. - */ - markPersistentFlagRequired(name: string): void - } - interface Command { - /** - * MarkFlagFilename instructs the various shell completion implementations to - * limit completions for the named flag to the specified file extensions. - */ - markFlagFilename(name: string, ...extensions: string[]): void - } - interface Command { - /** - * MarkFlagCustom adds the BashCompCustom annotation to the named flag, if it exists. - * The bash completion script will call the bash function f for the flag. - * - * This will only work for bash completion. - * It is recommended to instead use c.RegisterFlagCompletionFunc(...) which allows - * to register a Go function which will work across all shells. - */ - markFlagCustom(name: string, f: string): void - } - interface Command { - /** - * MarkPersistentFlagFilename instructs the various shell completion - * implementations to limit completions for the named persistent flag to the - * specified file extensions. - */ - markPersistentFlagFilename(name: string, ...extensions: string[]): void - } - interface Command { - /** - * MarkFlagDirname instructs the various shell completion implementations to - * limit completions for the named flag to directory names. - */ - markFlagDirname(name: string): void - } - interface Command { - /** - * MarkPersistentFlagDirname instructs the various shell completion - * implementations to limit completions for the named persistent flag to - * directory names. - */ - markPersistentFlagDirname(name: string): void - } - interface Command { - /** - * GenZshCompletionFile generates zsh completion file including descriptions. - */ - genZshCompletionFile(filename: string): void - } - interface Command { - /** - * GenZshCompletion generates zsh completion file including descriptions - * and writes it to the passed writer. - */ - genZshCompletion(w: io.Writer): void - } - interface Command { - /** - * GenZshCompletionFileNoDesc generates zsh completion file without descriptions. - */ - genZshCompletionFileNoDesc(filename: string): void - } - interface Command { - /** - * GenZshCompletionNoDesc generates zsh completion file without descriptions - * and writes it to the passed writer. - */ - genZshCompletionNoDesc(w: io.Writer): void - } - interface Command { - /** - * MarkZshCompPositionalArgumentFile only worked for zsh and its behavior was - * not consistent with Bash completion. It has therefore been disabled. - * Instead, when no other completion is specified, file completion is done by - * default for every argument. One can disable file completion on a per-argument - * basis by using ValidArgsFunction and ShellCompDirectiveNoFileComp. - * To achieve file extension filtering, one can use ValidArgsFunction and - * ShellCompDirectiveFilterFileExt. - * - * Deprecated - */ - markZshCompPositionalArgumentFile(argPosition: number, ...patterns: string[]): void - } - interface Command { - /** - * MarkZshCompPositionalArgumentWords only worked for zsh. It has therefore - * been disabled. - * To achieve the same behavior across all shells, one can use - * ValidArgs (for the first argument only) or ValidArgsFunction for - * any argument (can include the first one also). - * - * Deprecated - */ - markZshCompPositionalArgumentWords(argPosition: number, ...words: string[]): void + valid(): void } } @@ -6941,231 +6014,112 @@ namespace http { } } -/** - * 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 { +namespace auth { /** - * Reader reads bytes from a blob. - * It implements io.ReadSeekCloser, and must be closed after - * reads are finished. + * AuthUser defines a standardized oauth2 user data structure. */ - 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 + interface AuthUser { + id: string + name: string + username: string + email: string + avatarUrl: string + rawUser: _TygojaDict + accessToken: string + refreshToken: string } /** - * Attributes contains attributes about a blob. + * Provider defines a common interface for an OAuth2 client. */ - interface Attributes { + interface Provider { /** - * CacheControl specifies caching attributes that services may use - * when serving the blob. - * https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control + * Scopes returns the context associated with the provider (if any). */ - cacheControl: string + context(): context.Context /** - * 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 assigns the specified context to the current provider. */ - contentDisposition: string + setContext(ctx: context.Context): void /** - * 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 returns the provider access permissions that will be requested. */ - contentEncoding: string + scopes(): Array /** - * 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 sets the provider access permissions that will be requested later. */ - contentLanguage: string + setScopes(scopes: Array): void /** - * 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 returns the provider client's app ID. */ - contentType: string + clientId(): 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. + * SetClientId sets the provider client's ID. */ - metadata: _TygojaDict + setClientId(clientId: string): void /** - * CreateTime is the time the blob was created, if available. If not available, - * CreateTime will be the zero time. + * ClientSecret returns the provider client's app secret. */ - createTime: time.Time + clientSecret(): string /** - * ModTime is the time the blob was last modified. + * SetClientSecret sets the provider client's app secret. */ - modTime: time.Time + setClientSecret(secret: string): void /** - * Size is the size of the blob's content in bytes. + * RedirectUrl returns the end address to redirect the user + * going through the OAuth flow. */ - size: number + redirectUrl(): string /** - * MD5 is an MD5 hash of the blob contents or nil if not available. + * SetRedirectUrl sets the provider's RedirectUrl. */ - md5: string + setRedirectUrl(url: string): void /** - * ETag for the blob; see https://en.wikipedia.org/wiki/HTTP_ETag. + * AuthUrl returns the provider's authorization service url. */ - eTag: string - } - interface Attributes { + authUrl(): string /** - * 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 sets the provider's AuthUrl. */ - as(i: { - }): boolean - } - /** - * ListObject represents a single blob returned from List. - */ - interface ListObject { + setAuthUrl(url: string): void /** - * Key is the key for this blob. + * TokenUrl returns the provider's token exchange service url. */ - key: string + tokenUrl(): string /** - * ModTime is the time the blob was last modified. + * SetTokenUrl sets the provider's TokenUrl. */ - modTime: time.Time + setTokenUrl(url: string): void /** - * Size is the size of the blob's content in bytes. + * UserApiUrl returns the provider's user info api url. */ - size: number + userApiUrl(): string /** - * MD5 is an MD5 hash of the blob contents or nil if not available. + * SetUserApiUrl sets the provider's UserApiUrl. */ - md5: string + setUserApiUrl(url: string): void /** - * 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 returns an http client using the provided token. */ - isDir: boolean - } - interface ListObject { + client(token: oauth2.Token): (http.Client | undefined) /** - * 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 returns a URL to the provider's consent page + * that asks for permissions for the required scopes explicitly. */ - as(i: { - }): boolean + 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) } } @@ -7723,6 +6677,234 @@ namespace echo { } } +/** + * 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 { + /** + * Reader reads bytes from a blob. + * It implements io.ReadSeekCloser, and must be closed after + * reads are finished. + */ + 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 + } + /** + * 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 sql provides a generic interface around SQL (or SQL-like) * databases. @@ -8357,202 +7539,6 @@ namespace sql { } } -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 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 - } -} - -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 types implements some commonly used db serializable types * like datetime, json, etc. @@ -8624,6 +7610,86 @@ namespace types { } } +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 schema implements custom Schema and SchemaField datatypes * for handling the Collection schema definitions. @@ -8734,8 +7800,8 @@ namespace schema { * Package models implements all PocketBase DB models and DTOs. */ namespace models { - type _subgAKbW = BaseModel - interface Admin extends _subgAKbW { + type _subFNoQV = BaseModel + interface Admin extends _subFNoQV { avatar: number email: string tokenKey: string @@ -8770,8 +7836,8 @@ namespace models { } // @ts-ignore import validation = ozzo_validation - type _subQOfDe = BaseModel - interface Collection extends _subQOfDe { + type _subzdgTt = BaseModel + interface Collection extends _subzdgTt { name: string type: string system: boolean @@ -8864,8 +7930,8 @@ namespace models { */ setOptions(typedOptions: any): void } - type _subVwUWg = BaseModel - interface ExternalAuth extends _subVwUWg { + type _subRDXLH = BaseModel + interface ExternalAuth extends _subRDXLH { collectionId: string recordId: string provider: string @@ -8874,8 +7940,8 @@ namespace models { interface ExternalAuth { tableName(): string } - type _subHvpye = BaseModel - interface Record extends _subHvpye { + type _subKKnAv = BaseModel + interface Record extends _subKKnAv { } interface Record { /** @@ -9253,21 +8319,18 @@ namespace models { setPassword(password: string): void } /** - * RequestData defines a HTTP request data struct, usually used + * RequestInfo defines a HTTP request data struct, usually used * as part of the `@request.*` filter resolver. */ - interface RequestData { + interface RequestInfo { method: string query: _TygojaDict - /** - * @todo consider changing to Body? - */ data: _TygojaDict headers: _TygojaDict authRecord?: Record admin?: Admin } - interface RequestData { + interface RequestInfo { /** * HasModifierDataKeys loosely checks if the current struct has any modifier Data keys. */ @@ -9275,86 +8338,6 @@ namespace models { } } -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. * @@ -9791,9 +8774,9 @@ namespace daos { interface Dao { /** * CanAccessRecord checks if a record is allowed to be accessed by the - * specified requestData and accessRule. + * specified requestInfo and accessRule. * - * Rule and db checks are ignored in case requestData.Admin is set. + * Rule and db checks are ignored in case requestInfo.Admin is set. * * The returned error indicate that something unexpected happened during * the check (eg. invalid rule or db error). @@ -9803,15 +8786,15 @@ namespace daos { * Example: * * ``` - * requestData := apis.RequestData(c /* echo.Context *\/) + * requestInfo := apis.RequestInfo(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 { ... } + * if ok, _ := dao.CanAccessRecord(record, requestInfo, rule); ok { ... } * ``` */ - canAccessRecord(record: models.Record, requestData: models.RequestData, accessRule: string): boolean + canAccessRecord(record: models.Record, requestInfo: models.RequestInfo, accessRule: string): boolean } interface Dao { /** @@ -10872,6 +9855,1073 @@ namespace core { } } +/** + * 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. + */ +namespace cobra { + interface Command { + /** + * GenBashCompletion generates bash completion file and writes to the passed writer. + */ + genBashCompletion(w: io.Writer): void + } + interface Command { + /** + * GenBashCompletionFile generates bash completion file. + */ + genBashCompletionFile(filename: string): void + } + interface Command { + /** + * GenBashCompletionFileV2 generates Bash completion version 2. + */ + genBashCompletionFileV2(filename: string, includeDesc: boolean): void + } + interface Command { + /** + * GenBashCompletionV2 generates Bash completion file version 2 + * and writes it to the passed writer. + */ + genBashCompletionV2(w: io.Writer, includeDesc: boolean): void + } + // @ts-ignore + import flag = pflag + /** + * Command is just that, a command for your application. + * E.g. 'go run ...' - 'run' is the command. Cobra requires + * you to define the usage and description as part of your command + * definition to ensure usability. + */ + interface Command { + /** + * Use is the one-line usage message. + * Recommended syntax is as follows: + * ``` + * [ ] identifies an optional argument. Arguments that are not enclosed in brackets are required. + * ... indicates that you can specify multiple values for the previous argument. + * | indicates mutually exclusive information. You can use the argument to the left of the separator or the + * argument to the right of the separator. You cannot use both arguments in a single use of the command. + * { } delimits a set of mutually exclusive arguments when one of the arguments is required. If the arguments are + * optional, they are enclosed in brackets ([ ]). + * ``` + * Example: add [-F file | -D dir]... [-f format] profile + */ + use: string + /** + * Aliases is an array of aliases that can be used instead of the first word in Use. + */ + aliases: Array + /** + * SuggestFor is an array of command names for which this command will be suggested - + * similar to aliases but only suggests. + */ + suggestFor: Array + /** + * Short is the short description shown in the 'help' output. + */ + short: string + /** + * The group id under which this subcommand is grouped in the 'help' output of its parent. + */ + groupID: string + /** + * Long is the long message shown in the 'help ' output. + */ + long: string + /** + * Example is examples of how to use the command. + */ + example: string + /** + * ValidArgs is list of all valid non-flag arguments that are accepted in shell completions + */ + validArgs: Array + /** + * ValidArgsFunction is an optional function that provides valid non-flag arguments for shell completion. + * It is a dynamic version of using ValidArgs. + * Only one of ValidArgs and ValidArgsFunction can be used for a command. + */ + validArgsFunction: (cmd: Command, args: Array, toComplete: string) => [Array, ShellCompDirective] + /** + * Expected arguments + */ + args: PositionalArgs + /** + * ArgAliases is List of aliases for ValidArgs. + * These are not suggested to the user in the shell completion, + * but accepted if entered manually. + */ + argAliases: Array + /** + * BashCompletionFunction is custom bash functions used by the legacy bash autocompletion generator. + * For portability with other shells, it is recommended to instead use ValidArgsFunction + */ + bashCompletionFunction: string + /** + * Deprecated defines, if this command is deprecated and should print this string when used. + */ + deprecated: string + /** + * Annotations are key/value pairs that can be used by applications to identify or + * group commands. + */ + annotations: _TygojaDict + /** + * Version defines the version for this command. If this value is non-empty and the command does not + * define a "version" flag, a "version" boolean flag will be added to the command and, if specified, + * will print content of the "Version" variable. A shorthand "v" flag will also be added if the + * command does not define one. + */ + version: string + /** + * The *Run functions are executed in the following order: + * ``` + * * PersistentPreRun() + * * PreRun() + * * Run() + * * PostRun() + * * PersistentPostRun() + * ``` + * All functions get the same args, the arguments after the command name. + * + * PersistentPreRun: children of this command will inherit and execute. + */ + persistentPreRun: (cmd: Command, args: Array) => void + /** + * PersistentPreRunE: PersistentPreRun but returns an error. + */ + persistentPreRunE: (cmd: Command, args: Array) => void + /** + * PreRun: children of this command will not inherit. + */ + preRun: (cmd: Command, args: Array) => void + /** + * PreRunE: PreRun but returns an error. + */ + preRunE: (cmd: Command, args: Array) => void + /** + * Run: Typically the actual work function. Most commands will only implement this. + */ + run: (cmd: Command, args: Array) => void + /** + * RunE: Run but returns an error. + */ + runE: (cmd: Command, args: Array) => void + /** + * PostRun: run after the Run command. + */ + postRun: (cmd: Command, args: Array) => void + /** + * PostRunE: PostRun but returns an error. + */ + postRunE: (cmd: Command, args: Array) => void + /** + * PersistentPostRun: children of this command will inherit and execute after PostRun. + */ + persistentPostRun: (cmd: Command, args: Array) => void + /** + * PersistentPostRunE: PersistentPostRun but returns an error. + */ + persistentPostRunE: (cmd: Command, args: Array) => void + /** + * FParseErrWhitelist flag parse errors to be ignored + */ + fParseErrWhitelist: FParseErrWhitelist + /** + * CompletionOptions is a set of options to control the handling of shell completion + */ + completionOptions: CompletionOptions + /** + * TraverseChildren parses flags on all parents before executing child command. + */ + traverseChildren: boolean + /** + * Hidden defines, if this command is hidden and should NOT show up in the list of available commands. + */ + hidden: boolean + /** + * SilenceErrors is an option to quiet errors down stream. + */ + silenceErrors: boolean + /** + * SilenceUsage is an option to silence usage when an error occurs. + */ + silenceUsage: boolean + /** + * DisableFlagParsing disables the flag parsing. + * If this is true all flags will be passed to the command as arguments. + */ + disableFlagParsing: boolean + /** + * DisableAutoGenTag defines, if gen tag ("Auto generated by spf13/cobra...") + * will be printed by generating docs for this command. + */ + disableAutoGenTag: boolean + /** + * DisableFlagsInUseLine will disable the addition of [flags] to the usage + * line of a command when printing help or generating docs + */ + disableFlagsInUseLine: boolean + /** + * DisableSuggestions disables the suggestions based on Levenshtein distance + * that go along with 'unknown command' messages. + */ + disableSuggestions: boolean + /** + * SuggestionsMinimumDistance defines minimum levenshtein distance to display suggestions. + * Must be > 0. + */ + suggestionsMinimumDistance: number + } + interface Command { + /** + * Context returns underlying command context. If command was executed + * with ExecuteContext or the context was set with SetContext, the + * previously set context will be returned. Otherwise, nil is returned. + * + * Notice that a call to Execute and ExecuteC will replace a nil context of + * a command with a context.Background, so a background context will be + * returned by Context after one of these functions has been called. + */ + context(): context.Context + } + interface Command { + /** + * SetContext sets context for the command. This context will be overwritten by + * Command.ExecuteContext or Command.ExecuteContextC. + */ + setContext(ctx: context.Context): void + } + interface Command { + /** + * SetArgs sets arguments for the command. It is set to os.Args[1:] by default, if desired, can be overridden + * particularly useful when testing. + */ + setArgs(a: Array): void + } + interface Command { + /** + * SetOutput sets the destination for usage and error messages. + * If output is nil, os.Stderr is used. + * Deprecated: Use SetOut and/or SetErr instead + */ + setOutput(output: io.Writer): void + } + interface Command { + /** + * SetOut sets the destination for usage messages. + * If newOut is nil, os.Stdout is used. + */ + setOut(newOut: io.Writer): void + } + interface Command { + /** + * SetErr sets the destination for error messages. + * If newErr is nil, os.Stderr is used. + */ + setErr(newErr: io.Writer): void + } + interface Command { + /** + * SetIn sets the source for input data + * If newIn is nil, os.Stdin is used. + */ + setIn(newIn: io.Reader): void + } + interface Command { + /** + * SetUsageFunc sets usage function. Usage can be defined by application. + */ + setUsageFunc(f: (_arg0: Command) => void): void + } + interface Command { + /** + * SetUsageTemplate sets usage template. Can be defined by Application. + */ + setUsageTemplate(s: string): void + } + interface Command { + /** + * SetFlagErrorFunc sets a function to generate an error when flag parsing + * fails. + */ + setFlagErrorFunc(f: (_arg0: Command, _arg1: Error) => void): void + } + interface Command { + /** + * SetHelpFunc sets help function. Can be defined by Application. + */ + setHelpFunc(f: (_arg0: Command, _arg1: Array) => void): void + } + interface Command { + /** + * SetHelpCommand sets help command. + */ + setHelpCommand(cmd: Command): void + } + interface Command { + /** + * SetHelpCommandGroupID sets the group id of the help command. + */ + setHelpCommandGroupID(groupID: string): void + } + interface Command { + /** + * SetCompletionCommandGroupID sets the group id of the completion command. + */ + setCompletionCommandGroupID(groupID: string): void + } + interface Command { + /** + * SetHelpTemplate sets help template to be used. Application can use it to set custom template. + */ + setHelpTemplate(s: string): void + } + interface Command { + /** + * SetVersionTemplate sets version template to be used. Application can use it to set custom template. + */ + setVersionTemplate(s: string): void + } + interface Command { + /** + * SetGlobalNormalizationFunc sets a normalization function to all flag sets and also to child commands. + * The user should not have a cyclic dependency on commands. + */ + setGlobalNormalizationFunc(n: (f: flag.FlagSet, name: string) => flag.NormalizedName): void + } + interface Command { + /** + * OutOrStdout returns output to stdout. + */ + outOrStdout(): io.Writer + } + interface Command { + /** + * OutOrStderr returns output to stderr + */ + outOrStderr(): io.Writer + } + interface Command { + /** + * ErrOrStderr returns output to stderr + */ + errOrStderr(): io.Writer + } + interface Command { + /** + * InOrStdin returns input to stdin + */ + inOrStdin(): io.Reader + } + interface Command { + /** + * UsageFunc returns either the function set by SetUsageFunc for this command + * or a parent, or it returns a default usage function. + */ + usageFunc(): (_arg0: Command) => void + } + interface Command { + /** + * Usage puts out the usage for the command. + * Used when a user provides invalid input. + * Can be defined by user by overriding UsageFunc. + */ + usage(): void + } + interface Command { + /** + * HelpFunc returns either the function set by SetHelpFunc for this command + * or a parent, or it returns a function with default help behavior. + */ + helpFunc(): (_arg0: Command, _arg1: Array) => void + } + interface Command { + /** + * Help puts out the help for the command. + * Used when a user calls help [command]. + * Can be defined by user by overriding HelpFunc. + */ + help(): void + } + interface Command { + /** + * UsageString returns usage string. + */ + usageString(): string + } + interface Command { + /** + * FlagErrorFunc returns either the function set by SetFlagErrorFunc for this + * command or a parent, or it returns a function which returns the original + * error. + */ + flagErrorFunc(): (_arg0: Command, _arg1: Error) => void + } + interface Command { + /** + * UsagePadding return padding for the usage. + */ + usagePadding(): number + } + interface Command { + /** + * CommandPathPadding return padding for the command path. + */ + commandPathPadding(): number + } + interface Command { + /** + * NamePadding returns padding for the name. + */ + namePadding(): number + } + interface Command { + /** + * UsageTemplate returns usage template for the command. + */ + usageTemplate(): string + } + interface Command { + /** + * HelpTemplate return help template for the command. + */ + helpTemplate(): string + } + interface Command { + /** + * VersionTemplate return version template for the command. + */ + versionTemplate(): string + } + interface Command { + /** + * Find the target command given the args and command tree + * Meant to be run on the highest node. Only searches down. + */ + find(args: Array): [(Command | undefined), Array] + } + interface Command { + /** + * Traverse the command tree to find the command, and parse args for + * each parent. + */ + traverse(args: Array): [(Command | undefined), Array] + } + interface Command { + /** + * SuggestionsFor provides suggestions for the typedName. + */ + suggestionsFor(typedName: string): Array + } + interface Command { + /** + * VisitParents visits all parents of the command and invokes fn on each parent. + */ + visitParents(fn: (_arg0: Command) => void): void + } + interface Command { + /** + * Root finds root command. + */ + root(): (Command | undefined) + } + interface Command { + /** + * ArgsLenAtDash will return the length of c.Flags().Args at the moment + * when a -- was found during args parsing. + */ + argsLenAtDash(): number + } + interface Command { + /** + * ExecuteContext is the same as Execute(), but sets the ctx on the command. + * Retrieve ctx by calling cmd.Context() inside your *Run lifecycle or ValidArgs + * functions. + */ + executeContext(ctx: context.Context): void + } + interface Command { + /** + * Execute uses the args (os.Args[1:] by default) + * and run through the command tree finding appropriate matches + * for commands and then corresponding flags. + */ + execute(): void + } + interface Command { + /** + * ExecuteContextC is the same as ExecuteC(), but sets the ctx on the command. + * Retrieve ctx by calling cmd.Context() inside your *Run lifecycle or ValidArgs + * functions. + */ + executeContextC(ctx: context.Context): (Command | undefined) + } + interface Command { + /** + * ExecuteC executes the command. + */ + executeC(): (Command | undefined) + } + interface Command { + validateArgs(args: Array): void + } + interface Command { + /** + * ValidateRequiredFlags validates all required flags are present and returns an error otherwise + */ + validateRequiredFlags(): void + } + interface Command { + /** + * InitDefaultHelpFlag adds default help flag to c. + * It is called automatically by executing the c or by calling help and usage. + * If c already has help flag, it will do nothing. + */ + initDefaultHelpFlag(): void + } + interface Command { + /** + * InitDefaultVersionFlag adds default version flag to c. + * It is called automatically by executing the c. + * If c already has a version flag, it will do nothing. + * If c.Version is empty, it will do nothing. + */ + initDefaultVersionFlag(): void + } + interface Command { + /** + * InitDefaultHelpCmd adds default help command to c. + * It is called automatically by executing the c or by calling help and usage. + * If c already has help command or c has no subcommands, it will do nothing. + */ + initDefaultHelpCmd(): void + } + interface Command { + /** + * ResetCommands delete parent, subcommand and help command from c. + */ + resetCommands(): void + } + interface Command { + /** + * Commands returns a sorted slice of child commands. + */ + commands(): Array<(Command | undefined)> + } + interface Command { + /** + * AddCommand adds one or more commands to this parent command. + */ + addCommand(...cmds: (Command | undefined)[]): void + } + interface Command { + /** + * Groups returns a slice of child command groups. + */ + groups(): Array<(Group | undefined)> + } + interface Command { + /** + * AllChildCommandsHaveGroup returns if all subcommands are assigned to a group + */ + allChildCommandsHaveGroup(): boolean + } + interface Command { + /** + * ContainsGroup return if groupID exists in the list of command groups. + */ + containsGroup(groupID: string): boolean + } + interface Command { + /** + * AddGroup adds one or more command groups to this parent command. + */ + addGroup(...groups: (Group | undefined)[]): void + } + interface Command { + /** + * RemoveCommand removes one or more commands from a parent command. + */ + removeCommand(...cmds: (Command | undefined)[]): void + } + interface Command { + /** + * Print is a convenience method to Print to the defined output, fallback to Stderr if not set. + */ + print(...i: { + }[]): void + } + interface Command { + /** + * Println is a convenience method to Println to the defined output, fallback to Stderr if not set. + */ + println(...i: { + }[]): void + } + interface Command { + /** + * Printf is a convenience method to Printf to the defined output, fallback to Stderr if not set. + */ + printf(format: string, ...i: { + }[]): void + } + interface Command { + /** + * PrintErr is a convenience method to Print to the defined Err output, fallback to Stderr if not set. + */ + printErr(...i: { + }[]): void + } + interface Command { + /** + * PrintErrln is a convenience method to Println to the defined Err output, fallback to Stderr if not set. + */ + printErrln(...i: { + }[]): void + } + interface Command { + /** + * PrintErrf is a convenience method to Printf to the defined Err output, fallback to Stderr if not set. + */ + printErrf(format: string, ...i: { + }[]): void + } + interface Command { + /** + * CommandPath returns the full path to this command. + */ + commandPath(): string + } + interface Command { + /** + * UseLine puts out the full usage for a given command (including parents). + */ + useLine(): string + } + interface Command { + /** + * DebugFlags used to determine which flags have been assigned to which commands + * and which persist. + */ + debugFlags(): void + } + interface Command { + /** + * Name returns the command's name: the first word in the use line. + */ + name(): string + } + interface Command { + /** + * HasAlias determines if a given string is an alias of the command. + */ + hasAlias(s: string): boolean + } + interface Command { + /** + * CalledAs returns the command name or alias that was used to invoke + * this command or an empty string if the command has not been called. + */ + calledAs(): string + } + interface Command { + /** + * NameAndAliases returns a list of the command name and all aliases + */ + nameAndAliases(): string + } + interface Command { + /** + * HasExample determines if the command has example. + */ + hasExample(): boolean + } + interface Command { + /** + * Runnable determines if the command is itself runnable. + */ + runnable(): boolean + } + interface Command { + /** + * HasSubCommands determines if the command has children commands. + */ + hasSubCommands(): boolean + } + interface Command { + /** + * IsAvailableCommand determines if a command is available as a non-help command + * (this includes all non deprecated/hidden commands). + */ + isAvailableCommand(): boolean + } + interface Command { + /** + * IsAdditionalHelpTopicCommand determines if a command is an additional + * help topic command; additional help topic command is determined by the + * fact that it is NOT runnable/hidden/deprecated, and has no sub commands that + * are runnable/hidden/deprecated. + * Concrete example: https://github.com/spf13/cobra/issues/393#issuecomment-282741924. + */ + isAdditionalHelpTopicCommand(): boolean + } + interface Command { + /** + * HasHelpSubCommands determines if a command has any available 'help' sub commands + * that need to be shown in the usage/help default template under 'additional help + * topics'. + */ + hasHelpSubCommands(): boolean + } + interface Command { + /** + * HasAvailableSubCommands determines if a command has available sub commands that + * need to be shown in the usage/help default template under 'available commands'. + */ + hasAvailableSubCommands(): boolean + } + interface Command { + /** + * HasParent determines if the command is a child command. + */ + hasParent(): boolean + } + interface Command { + /** + * GlobalNormalizationFunc returns the global normalization function or nil if it doesn't exist. + */ + globalNormalizationFunc(): (f: flag.FlagSet, name: string) => flag.NormalizedName + } + interface Command { + /** + * Flags returns the complete FlagSet that applies + * to this command (local and persistent declared here and by all parents). + */ + flags(): (flag.FlagSet | undefined) + } + interface Command { + /** + * LocalNonPersistentFlags are flags specific to this command which will NOT persist to subcommands. + */ + localNonPersistentFlags(): (flag.FlagSet | undefined) + } + interface Command { + /** + * LocalFlags returns the local FlagSet specifically set in the current command. + */ + localFlags(): (flag.FlagSet | undefined) + } + interface Command { + /** + * InheritedFlags returns all flags which were inherited from parent commands. + */ + inheritedFlags(): (flag.FlagSet | undefined) + } + interface Command { + /** + * NonInheritedFlags returns all flags which were not inherited from parent commands. + */ + nonInheritedFlags(): (flag.FlagSet | undefined) + } + interface Command { + /** + * PersistentFlags returns the persistent FlagSet specifically set in the current command. + */ + persistentFlags(): (flag.FlagSet | undefined) + } + interface Command { + /** + * ResetFlags deletes all flags from command. + */ + resetFlags(): void + } + interface Command { + /** + * HasFlags checks if the command contains any flags (local plus persistent from the entire structure). + */ + hasFlags(): boolean + } + interface Command { + /** + * HasPersistentFlags checks if the command contains persistent flags. + */ + hasPersistentFlags(): boolean + } + interface Command { + /** + * HasLocalFlags checks if the command has flags specifically declared locally. + */ + hasLocalFlags(): boolean + } + interface Command { + /** + * HasInheritedFlags checks if the command has flags inherited from its parent command. + */ + hasInheritedFlags(): boolean + } + interface Command { + /** + * HasAvailableFlags checks if the command contains any flags (local plus persistent from the entire + * structure) which are not hidden or deprecated. + */ + hasAvailableFlags(): boolean + } + interface Command { + /** + * HasAvailablePersistentFlags checks if the command contains persistent flags which are not hidden or deprecated. + */ + hasAvailablePersistentFlags(): boolean + } + interface Command { + /** + * HasAvailableLocalFlags checks if the command has flags specifically declared locally which are not hidden + * or deprecated. + */ + hasAvailableLocalFlags(): boolean + } + interface Command { + /** + * HasAvailableInheritedFlags checks if the command has flags inherited from its parent command which are + * not hidden or deprecated. + */ + hasAvailableInheritedFlags(): boolean + } + interface Command { + /** + * Flag climbs up the command tree looking for matching flag. + */ + flag(name: string): (flag.Flag | undefined) + } + interface Command { + /** + * ParseFlags parses persistent flag tree and local flags. + */ + parseFlags(args: Array): void + } + interface Command { + /** + * Parent returns a commands parent command. + */ + parent(): (Command | undefined) + } + interface Command { + /** + * RegisterFlagCompletionFunc should be called to register a function to provide completion for a flag. + */ + registerFlagCompletionFunc(flagName: string, f: (cmd: Command, args: Array, toComplete: string) => [Array, ShellCompDirective]): void + } + interface Command { + /** + * InitDefaultCompletionCmd adds a default 'completion' command to c. + * This function will do nothing if any of the following is true: + * 1- the feature has been explicitly disabled by the program, + * 2- c has no subcommands (to avoid creating one), + * 3- c already has a 'completion' command provided by the program. + */ + initDefaultCompletionCmd(): void + } + interface Command { + /** + * GenFishCompletion generates fish completion file and writes to the passed writer. + */ + genFishCompletion(w: io.Writer, includeDesc: boolean): void + } + interface Command { + /** + * GenFishCompletionFile generates fish completion file. + */ + genFishCompletionFile(filename: string, includeDesc: boolean): void + } + interface Command { + /** + * MarkFlagsRequiredTogether marks the given flags with annotations so that Cobra errors + * if the command is invoked with a subset (but not all) of the given flags. + */ + markFlagsRequiredTogether(...flagNames: string[]): void + } + interface Command { + /** + * MarkFlagsMutuallyExclusive marks the given flags with annotations so that Cobra errors + * if the command is invoked with more than one flag from the given set of flags. + */ + markFlagsMutuallyExclusive(...flagNames: string[]): void + } + interface Command { + /** + * ValidateFlagGroups validates the mutuallyExclusive/requiredAsGroup logic and returns the + * first error encountered. + */ + validateFlagGroups(): void + } + interface Command { + /** + * GenPowerShellCompletionFile generates powershell completion file without descriptions. + */ + genPowerShellCompletionFile(filename: string): void + } + interface Command { + /** + * GenPowerShellCompletion generates powershell completion file without descriptions + * and writes it to the passed writer. + */ + genPowerShellCompletion(w: io.Writer): void + } + interface Command { + /** + * GenPowerShellCompletionFileWithDesc generates powershell completion file with descriptions. + */ + genPowerShellCompletionFileWithDesc(filename: string): void + } + interface Command { + /** + * GenPowerShellCompletionWithDesc generates powershell completion file with descriptions + * and writes it to the passed writer. + */ + genPowerShellCompletionWithDesc(w: io.Writer): void + } + interface Command { + /** + * MarkFlagRequired instructs the various shell completion implementations to + * prioritize the named flag when performing completion, + * and causes your command to report an error if invoked without the flag. + */ + markFlagRequired(name: string): void + } + interface Command { + /** + * MarkPersistentFlagRequired instructs the various shell completion implementations to + * prioritize the named persistent flag when performing completion, + * and causes your command to report an error if invoked without the flag. + */ + markPersistentFlagRequired(name: string): void + } + interface Command { + /** + * MarkFlagFilename instructs the various shell completion implementations to + * limit completions for the named flag to the specified file extensions. + */ + markFlagFilename(name: string, ...extensions: string[]): void + } + interface Command { + /** + * MarkFlagCustom adds the BashCompCustom annotation to the named flag, if it exists. + * The bash completion script will call the bash function f for the flag. + * + * This will only work for bash completion. + * It is recommended to instead use c.RegisterFlagCompletionFunc(...) which allows + * to register a Go function which will work across all shells. + */ + markFlagCustom(name: string, f: string): void + } + interface Command { + /** + * MarkPersistentFlagFilename instructs the various shell completion + * implementations to limit completions for the named persistent flag to the + * specified file extensions. + */ + markPersistentFlagFilename(name: string, ...extensions: string[]): void + } + interface Command { + /** + * MarkFlagDirname instructs the various shell completion implementations to + * limit completions for the named flag to directory names. + */ + markFlagDirname(name: string): void + } + interface Command { + /** + * MarkPersistentFlagDirname instructs the various shell completion + * implementations to limit completions for the named persistent flag to + * directory names. + */ + markPersistentFlagDirname(name: string): void + } + interface Command { + /** + * GenZshCompletionFile generates zsh completion file including descriptions. + */ + genZshCompletionFile(filename: string): void + } + interface Command { + /** + * GenZshCompletion generates zsh completion file including descriptions + * and writes it to the passed writer. + */ + genZshCompletion(w: io.Writer): void + } + interface Command { + /** + * GenZshCompletionFileNoDesc generates zsh completion file without descriptions. + */ + genZshCompletionFileNoDesc(filename: string): void + } + interface Command { + /** + * GenZshCompletionNoDesc generates zsh completion file without descriptions + * and writes it to the passed writer. + */ + genZshCompletionNoDesc(w: io.Writer): void + } + interface Command { + /** + * MarkZshCompPositionalArgumentFile only worked for zsh and its behavior was + * not consistent with Bash completion. It has therefore been disabled. + * Instead, when no other completion is specified, file completion is done by + * default for every argument. One can disable file completion on a per-argument + * basis by using ValidArgsFunction and ShellCompDirectiveNoFileComp. + * To achieve file extension filtering, one can use ValidArgsFunction and + * ShellCompDirectiveFilterFileExt. + * + * Deprecated + */ + markZshCompPositionalArgumentFile(argPosition: number, ...patterns: string[]): void + } + interface Command { + /** + * MarkZshCompPositionalArgumentWords only worked for zsh. It has therefore + * been disabled. + * To achieve the same behavior across all shells, one can use + * ValidArgs (for the first argument only) or ValidArgsFunction for + * any argument (can include the first one also). + * + * Deprecated + */ + markZshCompPositionalArgumentWords(argPosition: number, ...words: string[]): void + } +} + +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 io provides basic interfaces to I/O primitives. * Its primary job is to wrap existing implementations of such primitives, @@ -11638,6 +11688,77 @@ namespace net { } } +/** + * Package textproto implements generic support for text-based request/response + * protocols in the style of HTTP, NNTP, and SMTP. + * + * The package provides: + * + * Error, which represents a numeric error response from + * a server. + * + * Pipeline, to manage pipelined requests and responses + * in a client. + * + * Reader, to read numeric response code lines, + * key: value headers, lines wrapped with leading spaces + * on continuation lines, and whole text blocks ending + * with a dot on a line by itself. + * + * Writer, to write dot-encoded text blocks. + * + * Conn, a convenient packaging of Reader, Writer, and Pipeline for use + * with a single network connection. + */ +namespace textproto { + /** + * A MIMEHeader represents a MIME-style header mapping + * keys to sets of values. + */ + interface MIMEHeader extends _TygojaDict{} + interface MIMEHeader { + /** + * Add adds the key, value pair to the header. + * It appends to any existing values associated with key. + */ + add(key: string): void + } + interface MIMEHeader { + /** + * Set sets the header entries associated with key to + * the single element value. It replaces any existing + * values associated with key. + */ + set(key: string): void + } + interface MIMEHeader { + /** + * Get gets the first value associated with the given key. + * It is case insensitive; CanonicalMIMEHeaderKey is used + * to canonicalize the provided key. + * If there are no values associated with the key, Get returns "". + * To use non-canonical keys, access the map directly. + */ + get(key: string): string + } + interface MIMEHeader { + /** + * Values returns all values associated with the given key. + * It is case insensitive; CanonicalMIMEHeaderKey is + * used to canonicalize the provided key. To use non-canonical + * keys, access the map directly. + * The returned slice is not a copy. + */ + values(key: string): Array + } + interface MIMEHeader { + /** + * Del deletes the values associated with key. + */ + del(key: string): void + } +} + /** * Package url parses URLs and implements query escaping. */ @@ -12230,151 +12351,6 @@ namespace tls { } } -/** - * Package textproto implements generic support for text-based request/response - * protocols in the style of HTTP, NNTP, and SMTP. - * - * The package provides: - * - * Error, which represents a numeric error response from - * a server. - * - * Pipeline, to manage pipelined requests and responses - * in a client. - * - * Reader, to read numeric response code lines, - * key: value headers, lines wrapped with leading spaces - * on continuation lines, and whole text blocks ending - * with a dot on a line by itself. - * - * Writer, to write dot-encoded text blocks. - * - * Conn, a convenient packaging of Reader, Writer, and Pipeline for use - * with a single network connection. - */ -namespace textproto { - /** - * A MIMEHeader represents a MIME-style header mapping - * keys to sets of values. - */ - interface MIMEHeader extends _TygojaDict{} - interface MIMEHeader { - /** - * Add adds the key, value pair to the header. - * It appends to any existing values associated with key. - */ - add(key: string): void - } - interface MIMEHeader { - /** - * Set sets the header entries associated with key to - * the single element value. It replaces any existing - * values associated with key. - */ - set(key: string): void - } - interface MIMEHeader { - /** - * Get gets the first value associated with the given key. - * It is case insensitive; CanonicalMIMEHeaderKey is used - * to canonicalize the provided key. - * If there are no values associated with the key, Get returns "". - * To use non-canonical keys, access the map directly. - */ - get(key: string): string - } - interface MIMEHeader { - /** - * Values returns all values associated with the given key. - * It is case insensitive; CanonicalMIMEHeaderKey is - * used to canonicalize the provided key. To use non-canonical - * keys, access the map directly. - * The returned slice is not a copy. - */ - values(key: string): Array - } - interface MIMEHeader { - /** - * Del deletes the values associated with key. - */ - del(key: string): void - } -} - -/** - * Package multipart implements MIME multipart parsing, as defined in RFC - * 2046. - * - * The implementation is sufficient for HTTP (RFC 2388) and the multipart - * bodies generated by popular browsers. - */ -namespace multipart { - interface Reader { - /** - * ReadForm parses an entire multipart message whose parts have - * a Content-Disposition of "form-data". - * It stores up to maxMemory bytes + 10MB (reserved for non-file parts) - * in memory. File parts which can't be stored in memory will be stored on - * disk in temporary files. - * It returns ErrMessageTooLarge if all non-file parts can't be stored in - * memory. - */ - readForm(maxMemory: number): (Form | undefined) - } - /** - * Form is a parsed multipart form. - * Its File parts are stored either in memory or on disk, - * and are accessible via the *FileHeader's Open method. - * Its Value parts are stored as strings. - * Both are keyed by field name. - */ - interface Form { - value: _TygojaDict - file: _TygojaDict - } - interface Form { - /** - * RemoveAll removes any temporary files associated with a Form. - */ - removeAll(): void - } - /** - * File is an interface to access the file part of a multipart message. - * Its contents may be either stored in memory or on disk. - * If stored on disk, the File's underlying concrete type will be an *os.File. - */ - interface File { - } - /** - * Reader is an iterator over parts in a MIME multipart body. - * Reader's underlying parser consumes its input as needed. Seeking - * isn't supported. - */ - interface Reader { - } - interface Reader { - /** - * NextPart returns the next part in the multipart or an error. - * When there are no more parts, the error io.EOF is returned. - * - * As a special case, if the "Content-Transfer-Encoding" header - * has a value of "quoted-printable", that header is instead - * hidden and the body is transparently decoded during Read calls. - */ - nextPart(): (Part | undefined) - } - interface Reader { - /** - * NextRawPart returns the next part in the multipart or an error. - * When there are no more parts, the error io.EOF is returned. - * - * Unlike NextPart, it does not have special handling for - * "Content-Transfer-Encoding: quoted-printable". - */ - nextRawPart(): (Part | undefined) - } -} - /** * Package log implements a simple logging package. It defines a type, Logger, * with methods for formatting output. It also has a predefined 'standard' @@ -12504,6 +12480,80 @@ namespace log { } } +/** + * Package multipart implements MIME multipart parsing, as defined in RFC + * 2046. + * + * The implementation is sufficient for HTTP (RFC 2388) and the multipart + * bodies generated by popular browsers. + */ +namespace multipart { + interface Reader { + /** + * ReadForm parses an entire multipart message whose parts have + * a Content-Disposition of "form-data". + * It stores up to maxMemory bytes + 10MB (reserved for non-file parts) + * in memory. File parts which can't be stored in memory will be stored on + * disk in temporary files. + * It returns ErrMessageTooLarge if all non-file parts can't be stored in + * memory. + */ + readForm(maxMemory: number): (Form | undefined) + } + /** + * Form is a parsed multipart form. + * Its File parts are stored either in memory or on disk, + * and are accessible via the *FileHeader's Open method. + * Its Value parts are stored as strings. + * Both are keyed by field name. + */ + interface Form { + value: _TygojaDict + file: _TygojaDict + } + interface Form { + /** + * RemoveAll removes any temporary files associated with a Form. + */ + removeAll(): void + } + /** + * File is an interface to access the file part of a multipart message. + * Its contents may be either stored in memory or on disk. + * If stored on disk, the File's underlying concrete type will be an *os.File. + */ + interface File { + } + /** + * Reader is an iterator over parts in a MIME multipart body. + * Reader's underlying parser consumes its input as needed. Seeking + * isn't supported. + */ + interface Reader { + } + interface Reader { + /** + * NextPart returns the next part in the multipart or an error. + * When there are no more parts, the error io.EOF is returned. + * + * As a special case, if the "Content-Transfer-Encoding" header + * has a value of "quoted-printable", that header is instead + * hidden and the body is transparently decoded during Read calls. + */ + nextPart(): (Part | undefined) + } + interface Reader { + /** + * NextRawPart returns the next part in the multipart or an error. + * When there are no more parts, the error io.EOF is returned. + * + * Unlike NextPart, it does not have special handling for + * "Content-Transfer-Encoding: quoted-printable". + */ + nextRawPart(): (Part | undefined) + } +} + /** * Package http provides HTTP client and server implementations. * @@ -13149,86 +13199,92 @@ namespace http { } } -namespace store { +/** + * 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 { /** - * Store defines a concurrent safe in memory key-value data store. + * An AuthCodeOption is passed to Config.AuthCodeURL. */ - interface Store { + interface AuthCodeOption { } - interface Store { - /** - * Reset clears the store and replaces the store data with a - * shallow copy of the provided newData. - */ - reset(newData: _TygojaDict): void - } - interface Store { - /** - * Length returns the current number of elements in the store. - */ - length(): number - } - interface Store { - /** - * RemoveAll removes all the existing store entries. - */ - removeAll(): void - } - interface Store { - /** - * Remove removes a single entry from the store. - * - * Remove does nothing if key doesn't exist in the store. - */ - remove(key: string): void - } - interface Store { - /** - * Has checks if element with the specified key exist or not. - */ - has(key: string): boolean - } - interface Store { - /** - * Get returns a single element value from the store. - * - * If key is not set, the zero T value is returned. - */ - get(key: string): T - } - interface Store { - /** - * GetAll returns a shallow copy of the current store data. - */ - getAll(): _TygojaDict - } - interface Store { - /** - * Set sets (or overwrite if already exist) a new value for key. - */ - set(key: string, value: T): void - } - interface Store { - /** - * SetIfLessThanLimit sets (or overwrite if already exist) a new value for key. - * - * This method is similar to Set() but **it will skip adding new elements** - * to the store if the store length has reached the specified limit. - * false is returned if maxAllowedElements limit is reached. - */ - setIfLessThanLimit(key: string, value: T, maxAllowedElements: number): boolean - } -} - -namespace mailer { /** - * Mailer defines a base mail client interface. + * 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 Mailer { + interface Token { /** - * Send sends an email with the provided Message. + * AccessToken is the token that authorizes and authenticates + * the requests. */ - send(message: Message): void + 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 } } @@ -13536,6 +13592,77 @@ namespace migrate { } } +namespace store { + /** + * Store defines a concurrent safe in memory key-value data store. + */ + interface Store { + } + interface Store { + /** + * Reset clears the store and replaces the store data with a + * shallow copy of the provided newData. + */ + reset(newData: _TygojaDict): void + } + interface Store { + /** + * Length returns the current number of elements in the store. + */ + length(): number + } + interface Store { + /** + * RemoveAll removes all the existing store entries. + */ + removeAll(): void + } + interface Store { + /** + * Remove removes a single entry from the store. + * + * Remove does nothing if key doesn't exist in the store. + */ + remove(key: string): void + } + interface Store { + /** + * Has checks if element with the specified key exist or not. + */ + has(key: string): boolean + } + interface Store { + /** + * Get returns a single element value from the store. + * + * If key is not set, the zero T value is returned. + */ + get(key: string): T + } + interface Store { + /** + * GetAll returns a shallow copy of the current store data. + */ + getAll(): _TygojaDict + } + interface Store { + /** + * Set sets (or overwrite if already exist) a new value for key. + */ + set(key: string, value: T): void + } + interface Store { + /** + * SetIfLessThanLimit sets (or overwrite if already exist) a new value for key. + * + * This method is similar to Set() but **it will skip adding new elements** + * to the store if the store length has reached the specified limit. + * false is returned if maxAllowedElements limit is reached. + */ + setIfLessThanLimit(key: string, value: T, maxAllowedElements: number): boolean + } +} + /** * Package types implements some commonly used db serializable types * like datetime, json, etc. @@ -13823,16 +13950,16 @@ namespace models { */ validate(): void } - type _subGRUuB = BaseModel - interface Param extends _subGRUuB { + type _subXeIhq = BaseModel + interface Param extends _subXeIhq { key: string value: types.JsonRaw } interface Param { tableName(): string } - type _subJDmVe = BaseModel - interface Request extends _subJDmVe { + type _subxXqxL = BaseModel + interface Request extends _subxXqxL { url: string method: string status: number @@ -13860,6 +13987,18 @@ namespace models { } } +namespace mailer { + /** + * Mailer defines a base mail client interface. + */ + interface Mailer { + /** + * Send sends an email with the provided Message. + */ + send(message: Message): void + } +} + /** * Package echo implements high performance, minimalist Go web framework. * @@ -14298,95 +14437,6 @@ namespace echo { } } -/** - * 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 settings { // @ts-ignore import validation = ozzo_validation @@ -14597,8 +14647,8 @@ namespace hook { * 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 _subGNDdN = mainHook - interface TaggedHook extends _subGNDdN { + type _subZfBkn = mainHook + interface TaggedHook extends _subZfBkn { } interface TaggedHook { /** @@ -14684,12 +14734,12 @@ namespace core { httpContext: echo.Context error: Error } - type _subXskBJ = BaseModelEvent - interface ModelEvent extends _subXskBJ { + type _subOUrjX = BaseModelEvent + interface ModelEvent extends _subOUrjX { dao?: daos.Dao } - type _subYlIos = BaseCollectionEvent - interface MailerRecordEvent extends _subYlIos { + type _subaFJhR = BaseCollectionEvent + interface MailerRecordEvent extends _subaFJhR { mailClient: mailer.Mailer message?: mailer.Message record?: models.Record @@ -14728,50 +14778,50 @@ namespace core { oldSettings?: settings.Settings newSettings?: settings.Settings } - type _subUASMa = BaseCollectionEvent - interface RecordsListEvent extends _subUASMa { + type _subtWPgW = BaseCollectionEvent + interface RecordsListEvent extends _subtWPgW { httpContext: echo.Context records: Array<(models.Record | undefined)> result?: search.Result } - type _subQLlti = BaseCollectionEvent - interface RecordViewEvent extends _subQLlti { + type _subOeThX = BaseCollectionEvent + interface RecordViewEvent extends _subOeThX { httpContext: echo.Context record?: models.Record } - type _subafMcU = BaseCollectionEvent - interface RecordCreateEvent extends _subafMcU { + type _subiWJQn = BaseCollectionEvent + interface RecordCreateEvent extends _subiWJQn { httpContext: echo.Context record?: models.Record uploadedFiles: _TygojaDict } - type _subAbvxm = BaseCollectionEvent - interface RecordUpdateEvent extends _subAbvxm { + type _subTLiKU = BaseCollectionEvent + interface RecordUpdateEvent extends _subTLiKU { httpContext: echo.Context record?: models.Record uploadedFiles: _TygojaDict } - type _subezArM = BaseCollectionEvent - interface RecordDeleteEvent extends _subezArM { + type _subgyGJy = BaseCollectionEvent + interface RecordDeleteEvent extends _subgyGJy { httpContext: echo.Context record?: models.Record } - type _subDAzkU = BaseCollectionEvent - interface RecordAuthEvent extends _subDAzkU { + type _subkwFjG = BaseCollectionEvent + interface RecordAuthEvent extends _subkwFjG { httpContext: echo.Context record?: models.Record token: string meta: any } - type _subpNCMb = BaseCollectionEvent - interface RecordAuthWithPasswordEvent extends _subpNCMb { + type _subjVHmB = BaseCollectionEvent + interface RecordAuthWithPasswordEvent extends _subjVHmB { httpContext: echo.Context record?: models.Record identity: string password: string } - type _subPFzCX = BaseCollectionEvent - interface RecordAuthWithOAuth2Event extends _subPFzCX { + type _subtFNVQ = BaseCollectionEvent + interface RecordAuthWithOAuth2Event extends _subtFNVQ { httpContext: echo.Context providerName: string providerClient: auth.Provider @@ -14779,49 +14829,49 @@ namespace core { oAuth2User?: auth.AuthUser isNewRecord: boolean } - type _subuVcEL = BaseCollectionEvent - interface RecordAuthRefreshEvent extends _subuVcEL { + type _subfjVyU = BaseCollectionEvent + interface RecordAuthRefreshEvent extends _subfjVyU { httpContext: echo.Context record?: models.Record } - type _subVNzno = BaseCollectionEvent - interface RecordRequestPasswordResetEvent extends _subVNzno { + type _subTZJCW = BaseCollectionEvent + interface RecordRequestPasswordResetEvent extends _subTZJCW { httpContext: echo.Context record?: models.Record } - type _sublpewg = BaseCollectionEvent - interface RecordConfirmPasswordResetEvent extends _sublpewg { + type _subeWnCy = BaseCollectionEvent + interface RecordConfirmPasswordResetEvent extends _subeWnCy { httpContext: echo.Context record?: models.Record } - type _subdnBpr = BaseCollectionEvent - interface RecordRequestVerificationEvent extends _subdnBpr { + type _subfeZNe = BaseCollectionEvent + interface RecordRequestVerificationEvent extends _subfeZNe { httpContext: echo.Context record?: models.Record } - type _subfIECD = BaseCollectionEvent - interface RecordConfirmVerificationEvent extends _subfIECD { + type _subUezaI = BaseCollectionEvent + interface RecordConfirmVerificationEvent extends _subUezaI { httpContext: echo.Context record?: models.Record } - type _subtMMey = BaseCollectionEvent - interface RecordRequestEmailChangeEvent extends _subtMMey { + type _subazSSA = BaseCollectionEvent + interface RecordRequestEmailChangeEvent extends _subazSSA { httpContext: echo.Context record?: models.Record } - type _subWZErX = BaseCollectionEvent - interface RecordConfirmEmailChangeEvent extends _subWZErX { + type _subdHlrB = BaseCollectionEvent + interface RecordConfirmEmailChangeEvent extends _subdHlrB { httpContext: echo.Context record?: models.Record } - type _subQTWxd = BaseCollectionEvent - interface RecordListExternalAuthsEvent extends _subQTWxd { + type _subbhgkh = BaseCollectionEvent + interface RecordListExternalAuthsEvent extends _subbhgkh { httpContext: echo.Context record?: models.Record externalAuths: Array<(models.ExternalAuth | undefined)> } - type _subYKXBw = BaseCollectionEvent - interface RecordUnlinkExternalAuthEvent extends _subYKXBw { + type _subqXGfX = BaseCollectionEvent + interface RecordUnlinkExternalAuthEvent extends _subqXGfX { httpContext: echo.Context record?: models.Record externalAuth?: models.ExternalAuth @@ -14875,33 +14925,33 @@ namespace core { collections: Array<(models.Collection | undefined)> result?: search.Result } - type _subSEtSL = BaseCollectionEvent - interface CollectionViewEvent extends _subSEtSL { + type _subxXngt = BaseCollectionEvent + interface CollectionViewEvent extends _subxXngt { httpContext: echo.Context } - type _subBEbOd = BaseCollectionEvent - interface CollectionCreateEvent extends _subBEbOd { + type _subsFOmC = BaseCollectionEvent + interface CollectionCreateEvent extends _subsFOmC { httpContext: echo.Context } - type _subgybca = BaseCollectionEvent - interface CollectionUpdateEvent extends _subgybca { + type _subElrYz = BaseCollectionEvent + interface CollectionUpdateEvent extends _subElrYz { httpContext: echo.Context } - type _subzLgCr = BaseCollectionEvent - interface CollectionDeleteEvent extends _subzLgCr { + type _subsXwsO = BaseCollectionEvent + interface CollectionDeleteEvent extends _subsXwsO { httpContext: echo.Context } interface CollectionsImportEvent { httpContext: echo.Context collections: Array<(models.Collection | undefined)> } - type _subGsarQ = BaseModelEvent - interface FileTokenEvent extends _subGsarQ { + type _subcprnW = BaseModelEvent + interface FileTokenEvent extends _subcprnW { httpContext: echo.Context token: string } - type _subhNSaq = BaseCollectionEvent - interface FileDownloadEvent extends _subhNSaq { + type _subesHtH = BaseCollectionEvent + interface FileDownloadEvent extends _subesHtH { httpContext: echo.Context record?: models.Record fileField?: schema.SchemaField @@ -16518,6 +16568,152 @@ namespace cobra { } } +/** + * Package time provides functionality for measuring and displaying time. + * + * The calendrical calculations always assume a Gregorian calendar, with + * no leap seconds. + * + * Monotonic Clocks + * + * Operating systems provide both a “wall clock,” which is subject to + * changes for clock synchronization, and a “monotonic clock,” which is + * not. The general rule is that the wall clock is for telling time and + * the monotonic clock is for measuring time. Rather than split the API, + * in this package the Time returned by time.Now contains both a wall + * clock reading and a monotonic clock reading; later time-telling + * operations use the wall clock reading, but later time-measuring + * operations, specifically comparisons and subtractions, use the + * monotonic clock reading. + * + * For example, this code always computes a positive elapsed time of + * approximately 20 milliseconds, even if the wall clock is changed during + * the operation being timed: + * + * ``` + * start := time.Now() + * ... operation that takes 20 milliseconds ... + * t := time.Now() + * elapsed := t.Sub(start) + * ``` + * + * Other idioms, such as time.Since(start), time.Until(deadline), and + * time.Now().Before(deadline), are similarly robust against wall clock + * resets. + * + * The rest of this section gives the precise details of how operations + * use monotonic clocks, but understanding those details is not required + * to use this package. + * + * The Time returned by time.Now contains a monotonic clock reading. + * If Time t has a monotonic clock reading, t.Add adds the same duration to + * both the wall clock and monotonic clock readings to compute the result. + * Because t.AddDate(y, m, d), t.Round(d), and t.Truncate(d) are wall time + * computations, they always strip any monotonic clock reading from their results. + * Because t.In, t.Local, and t.UTC are used for their effect on the interpretation + * of the wall time, they also strip any monotonic clock reading from their results. + * The canonical way to strip a monotonic clock reading is to use t = t.Round(0). + * + * If Times t and u both contain monotonic clock readings, the operations + * t.After(u), t.Before(u), t.Equal(u), and t.Sub(u) are carried out + * using the monotonic clock readings alone, ignoring the wall clock + * readings. If either t or u contains no monotonic clock reading, these + * operations fall back to using the wall clock readings. + * + * On some systems the monotonic clock will stop if the computer goes to sleep. + * On such a system, t.Sub(u) may not accurately reflect the actual + * time that passed between t and u. + * + * Because the monotonic clock reading has no meaning outside + * the current process, the serialized forms generated by t.GobEncode, + * t.MarshalBinary, t.MarshalJSON, and t.MarshalText omit the monotonic + * clock reading, and t.Format provides no format for it. Similarly, the + * constructors time.Date, time.Parse, time.ParseInLocation, and time.Unix, + * as well as the unmarshalers t.GobDecode, t.UnmarshalBinary. + * t.UnmarshalJSON, and t.UnmarshalText always create times with + * no monotonic clock reading. + * + * Note that the Go == operator compares not just the time instant but + * also the Location and the monotonic clock reading. See the + * documentation for the Time type for a discussion of equality + * testing for Time values. + * + * For debugging, the result of t.String does include the monotonic + * clock reading if present. If t != u because of different monotonic clock readings, + * that difference will be visible when printing t.String() and u.String(). + */ +namespace time { + /** + * A Month specifies a month of the year (January = 1, ...). + */ + interface Month extends Number{} + interface Month { + /** + * String returns the English name of the month ("January", "February", ...). + */ + string(): string + } + /** + * A Weekday specifies a day of the week (Sunday = 0, ...). + */ + interface Weekday extends Number{} + interface Weekday { + /** + * String returns the English name of the day ("Sunday", "Monday", ...). + */ + string(): string + } + /** + * A Location maps time instants to the zone in use at that time. + * Typically, the Location represents the collection of time offsets + * in use in a geographical area. For many Locations the time offset varies + * depending on whether daylight savings time is in use at the time instant. + */ + interface Location { + } + interface Location { + /** + * String returns a descriptive name for the time zone information, + * corresponding to the name argument to LoadLocation or FixedZone. + */ + string(): string + } +} + +/** + * 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 { + /** + * A FileInfo describes a file and is returned by Stat. + */ + interface FileInfo { + name(): string // base name of the file + size(): number // length in bytes for regular files; system-dependent for others + mode(): FileMode // file mode bits + modTime(): time.Time // modification time + isDir(): boolean // abbreviation for Mode().IsDir() + sys(): any // underlying data source (can return nil) + } +} + +/** + * 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 _subshkId = Reader&Writer + interface ReadWriter extends _subshkId { + } +} + /** * Package reflect implements run-time reflection, allowing a program to * manipulate objects with arbitrary types. The typical use is to take a value @@ -16745,152 +16941,6 @@ namespace reflect { } } -/** - * Package time provides functionality for measuring and displaying time. - * - * The calendrical calculations always assume a Gregorian calendar, with - * no leap seconds. - * - * Monotonic Clocks - * - * Operating systems provide both a “wall clock,” which is subject to - * changes for clock synchronization, and a “monotonic clock,” which is - * not. The general rule is that the wall clock is for telling time and - * the monotonic clock is for measuring time. Rather than split the API, - * in this package the Time returned by time.Now contains both a wall - * clock reading and a monotonic clock reading; later time-telling - * operations use the wall clock reading, but later time-measuring - * operations, specifically comparisons and subtractions, use the - * monotonic clock reading. - * - * For example, this code always computes a positive elapsed time of - * approximately 20 milliseconds, even if the wall clock is changed during - * the operation being timed: - * - * ``` - * start := time.Now() - * ... operation that takes 20 milliseconds ... - * t := time.Now() - * elapsed := t.Sub(start) - * ``` - * - * Other idioms, such as time.Since(start), time.Until(deadline), and - * time.Now().Before(deadline), are similarly robust against wall clock - * resets. - * - * The rest of this section gives the precise details of how operations - * use monotonic clocks, but understanding those details is not required - * to use this package. - * - * The Time returned by time.Now contains a monotonic clock reading. - * If Time t has a monotonic clock reading, t.Add adds the same duration to - * both the wall clock and monotonic clock readings to compute the result. - * Because t.AddDate(y, m, d), t.Round(d), and t.Truncate(d) are wall time - * computations, they always strip any monotonic clock reading from their results. - * Because t.In, t.Local, and t.UTC are used for their effect on the interpretation - * of the wall time, they also strip any monotonic clock reading from their results. - * The canonical way to strip a monotonic clock reading is to use t = t.Round(0). - * - * If Times t and u both contain monotonic clock readings, the operations - * t.After(u), t.Before(u), t.Equal(u), and t.Sub(u) are carried out - * using the monotonic clock readings alone, ignoring the wall clock - * readings. If either t or u contains no monotonic clock reading, these - * operations fall back to using the wall clock readings. - * - * On some systems the monotonic clock will stop if the computer goes to sleep. - * On such a system, t.Sub(u) may not accurately reflect the actual - * time that passed between t and u. - * - * Because the monotonic clock reading has no meaning outside - * the current process, the serialized forms generated by t.GobEncode, - * t.MarshalBinary, t.MarshalJSON, and t.MarshalText omit the monotonic - * clock reading, and t.Format provides no format for it. Similarly, the - * constructors time.Date, time.Parse, time.ParseInLocation, and time.Unix, - * as well as the unmarshalers t.GobDecode, t.UnmarshalBinary. - * t.UnmarshalJSON, and t.UnmarshalText always create times with - * no monotonic clock reading. - * - * Note that the Go == operator compares not just the time instant but - * also the Location and the monotonic clock reading. See the - * documentation for the Time type for a discussion of equality - * testing for Time values. - * - * For debugging, the result of t.String does include the monotonic - * clock reading if present. If t != u because of different monotonic clock readings, - * that difference will be visible when printing t.String() and u.String(). - */ -namespace time { - /** - * A Month specifies a month of the year (January = 1, ...). - */ - interface Month extends Number{} - interface Month { - /** - * String returns the English name of the month ("January", "February", ...). - */ - string(): string - } - /** - * A Weekday specifies a day of the week (Sunday = 0, ...). - */ - interface Weekday extends Number{} - interface Weekday { - /** - * String returns the English name of the day ("Sunday", "Monday", ...). - */ - string(): string - } - /** - * A Location maps time instants to the zone in use at that time. - * Typically, the Location represents the collection of time offsets - * in use in a geographical area. For many Locations the time offset varies - * depending on whether daylight savings time is in use at the time instant. - */ - interface Location { - } - interface Location { - /** - * String returns a descriptive name for the time zone information, - * corresponding to the name argument to LoadLocation or FixedZone. - */ - string(): string - } -} - -/** - * 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 { - /** - * A FileInfo describes a file and is returned by Stat. - */ - interface FileInfo { - name(): string // base name of the file - size(): number // length in bytes for regular files; system-dependent for others - mode(): FileMode // file mode bits - modTime(): time.Time // modification time - isDir(): boolean // abbreviation for Mode().IsDir() - sys(): any // underlying data source (can return nil) - } -} - -/** - * 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 _subqqWpg = Reader&Writer - interface ReadWriter extends _subqqWpg { - } -} - /** * Package net provides a portable interface for network I/O, including * TCP/IP, UDP, domain name resolution, and Unix domain sockets. @@ -17658,6 +17708,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 multipart implements MIME multipart parsing, as defined in RFC * 2046. @@ -17704,21 +17769,6 @@ namespace multipart { } } -/** - * 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 http provides HTTP client and server implementations. * @@ -17908,152 +17958,6 @@ namespace http { import urlpkg = url } -namespace store { -} - -namespace mailer { - /** - * Message defines a generic email message struct. - */ - interface Message { - from: mail.Address - to: Array - bcc: Array - cc: Array - subject: string - html: string - text: string - headers: _TygojaDict - attachments: _TygojaDict - } -} - -/** - * 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 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 - } -} - -namespace search { - /** - * Result defines the returned search result structure. - */ - interface Result { - page: number - perPage: number - totalItems: number - totalPages: number - items: any - } -} - /** * Package echo implements high performance, minimalist Go web framework. * @@ -18168,6 +18072,152 @@ 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 { + /** + * 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 + } +} + +namespace store { +} + +namespace mailer { + /** + * Message defines a generic email message struct. + */ + interface Message { + from: mail.Address + to: Array + bcc: Array + cc: Array + subject: string + html: string + text: string + headers: _TygojaDict + attachments: _TygojaDict + } +} + +/** + * 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 + } +} + +namespace search { + /** + * Result defines the returned search result structure. + */ + interface Result { + page: number + perPage: number + totalItems: number + totalPages: number + items: any + } +} + namespace settings { // @ts-ignore import validation = ozzo_validation @@ -18191,19 +18241,6 @@ namespace settings { } } -namespace hook { - /** - * Handler defines a hook handler function. - */ - interface Handler {(e: T): void } - /** - * wrapped local Hook embedded struct to limit the public API surface. - */ - type _subMhVBX = Hook - interface mainHook extends _subMhVBX { - } -} - namespace subscriptions { /** * Message defines a client's channel data. @@ -18267,6 +18304,19 @@ namespace subscriptions { } } +namespace hook { + /** + * Handler defines a hook handler function. + */ + interface Handler {(e: T): void } + /** + * wrapped local Hook embedded struct to limit the public API surface. + */ + type _subYZxIY = Hook + interface mainHook extends _subYZxIY { + } +} + /** * Package autocert provides automatic access to certificates from Let's Encrypt * and any other ACME-based CA. @@ -18434,26 +18484,6 @@ namespace autocert { } } -/** - * Package core is the backbone of PocketBase. - * - * It defines the main PocketBase App interface and its base implementation. - */ -namespace core { - interface BaseModelEvent { - model: models.Model - } - interface BaseModelEvent { - tags(): Array - } - interface BaseCollectionEvent { - collection?: models.Collection - } - interface BaseCollectionEvent { - tags(): Array - } -} - /** * ``` * Package flag implements command-line flag parsing. @@ -18930,47 +18960,22 @@ namespace pflag { } /** - * 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. + * Package core is the backbone of PocketBase. + * + * It defines the main PocketBase App interface and its base implementation. */ -namespace fs { - /** - * A FileMode represents a file's mode and permission bits. - * The bits have the same definition on all systems, so that - * information about files can be moved from one system - * to another portably. Not all bits apply to all systems. - * The only required bit is ModeDir for directories. - */ - interface FileMode extends Number{} - interface FileMode { - string(): string +namespace core { + interface BaseModelEvent { + model: models.Model } - interface FileMode { - /** - * IsDir reports whether m describes a directory. - * That is, it tests for the ModeDir bit being set in m. - */ - isDir(): boolean + interface BaseModelEvent { + tags(): Array } - interface FileMode { - /** - * IsRegular reports whether m describes a regular file. - * That is, it tests that no mode type bits are set. - */ - isRegular(): boolean + interface BaseCollectionEvent { + collection?: models.Collection } - interface FileMode { - /** - * Perm returns the Unix permission bits in m (m & ModePerm). - */ - perm(): FileMode - } - interface FileMode { - /** - * Type returns type bits in m (m & ModeType). - */ - type(): FileMode + interface BaseCollectionEvent { + tags(): Array } } @@ -19083,6 +19088,313 @@ namespace reflect { } } +/** + * 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). + * At EOF, the count will be zero and err will be io.EOF. + */ + 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 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 { + /** + * A FileMode represents a file's mode and permission bits. + * The bits have the same definition on all systems, so that + * information about files can be moved from one system + * to another portably. Not all bits apply to all systems. + * The only required bit is ModeDir for directories. + */ + interface FileMode extends Number{} + interface FileMode { + string(): string + } + interface FileMode { + /** + * IsDir reports whether m describes a directory. + * That is, it tests for the ModeDir bit being set in m. + */ + isDir(): boolean + } + interface FileMode { + /** + * IsRegular reports whether m describes a regular file. + * That is, it tests that no mode type bits are set. + */ + isRegular(): boolean + } + interface FileMode { + /** + * Perm returns the Unix permission bits in m (m & ModePerm). + */ + perm(): FileMode + } + interface FileMode { + /** + * Type returns type bits in m (m & ModeType). + */ + type(): FileMode + } +} + /** * Package big implements arbitrary-precision arithmetic (big numbers). * The following numeric types are supported: @@ -19717,268 +20029,6 @@ namespace big { } } -/** - * 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). - * At EOF, the count will be zero and err will be io.EOF. - */ - 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 asn1 implements parsing of DER-encoded ASN.1 data structures, * as defined in ITU-T Rec X.690. @@ -20171,41 +20221,6 @@ namespace x509 { interface ExtKeyUsage extends Number{} } -/** - * Package mail implements parsing of mail messages. - * - * For the most part, this package follows the syntax as specified by RFC 5322 and - * extended by RFC 6532. - * Notable divergences: - * ``` - * * Obsolete address formats are not parsed, including addresses with - * embedded route information. - * * The full range of spacing (the CFWS syntax element) is not supported, - * such as breaking addresses across lines. - * * No unicode normalization is performed. - * * The special characters ()[]:;@\, are allowed to appear unquoted in names. - * ``` - */ -namespace mail { - /** - * Address represents a single mail address. - * An address such as "Barry Gibbs " is represented - * as Address{Name: "Barry Gibbs", Address: "bg@example.com"}. - */ - interface Address { - name: string // Proper name; may be empty. - address: string // user@domain - } - interface Address { - /** - * String formats the address as a valid RFC 5322 address. - * If the address's name contains non-ASCII characters - * the name will be rendered according to RFC 2047. - */ - string(): string - } -} - /** * Package tls partially implements TLS 1.2, as specified in RFC 5246, * and TLS 1.3, as specified in RFC 8446. @@ -20653,91 +20668,38 @@ namespace acme { } /** + * Package mail implements parsing of mail messages. + * + * For the most part, this package follows the syntax as specified by RFC 5322 and + * extended by RFC 6532. + * Notable divergences: * ``` - * 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=x - * -flag x // non-boolean flags only - * One or two minus signs 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. + * * Obsolete address formats are not parsed, including addresses with + * embedded route information. + * * The full range of spacing (the CFWS syntax element) is not supported, + * such as breaking addresses across lines. + * * No unicode normalization is performed. + * * The special characters ()[]:;@\, are allowed to appear unquoted in names. * ``` */ -namespace flag { +namespace mail { /** - * Value is the interface to the dynamic value stored in a flag. - * (The default value is represented as a string.) - * - * If a Value has an IsBoolFlag() bool method returning true, - * the command-line parser makes -name equivalent to -name=true - * rather than using the next command-line argument. - * - * Set is called once, in command line order, for each flag present. - * The flag package may call the String method with a zero-valued receiver, - * such as a nil pointer. + * Address represents a single mail address. + * An address such as "Barry Gibbs " is represented + * as Address{Name: "Barry Gibbs", Address: "bg@example.com"}. */ - interface Value { - string(): string - set(_arg0: string): void + interface Address { + name: string // Proper name; may be empty. + address: string // user@domain + } + interface Address { + /** + * String formats the address as a valid RFC 5322 address. + * If the address's name contains non-ASCII characters + * the name will be rendered according to RFC 2047. + */ + string(): string } - /** - * ErrorHandling defines how FlagSet.Parse behaves if the parse fails. - */ - interface ErrorHandling extends Number{} } /** @@ -20827,6 +20789,97 @@ namespace driver { } } +namespace search { +} + +/** + * ``` + * 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=x + * -flag x // non-boolean flags only + * One or two minus signs 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 { + /** + * Value is the interface to the dynamic value stored in a flag. + * (The default value is represented as a string.) + * + * If a Value has an IsBoolFlag() bool method returning true, + * the command-line parser makes -name equivalent to -name=true + * rather than using the next command-line argument. + * + * Set is called once, in command line order, for each flag present. + * The flag package may call the String method with a zero-valued receiver, + * such as a nil pointer. + */ + interface Value { + string(): string + set(_arg0: string): void + } + /** + * ErrorHandling defines how FlagSet.Parse behaves if the parse fails. + */ + interface ErrorHandling extends Number{} +} + namespace subscriptions { } @@ -20873,9 +20926,6 @@ namespace autocert { } } -namespace search { -} - /** * Package reflect implements run-time reflection, allowing a program to * manipulate objects with arbitrary types. The typical use is to take a value @@ -20945,8 +20995,8 @@ namespace reflect { * Using == on two Values does not compare the underlying values * they represent. */ - type _subSDNEa = flag - interface Value extends _subSDNEa { + type _subMaYIE = flag + interface Value extends _subMaYIE { } interface Value { /** @@ -22226,6 +22276,39 @@ namespace big { interface Word extends Number{} } +/** + * Package crypto collects common cryptographic constants. + */ +namespace crypto { + /** + * 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 asn1 implements parsing of DER-encoded ASN.1 data structures, * as defined in ITU-T Rec X.690. @@ -22259,6 +22342,88 @@ namespace asn1 { } } +/** + * 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 { + /** + * Result is the result of a query execution. + */ + interface Result { + /** + * LastInsertId returns the database's auto-generated ID + * after, for example, an INSERT into a table with primary + * key. + */ + lastInsertId(): number + /** + * RowsAffected returns the number of rows affected by the + * query. + */ + rowsAffected(): number + } + /** + * Rows is an iterator over an executed query's results. + */ + interface Rows { + /** + * Columns returns the names of the columns. The number of + * columns of the result is inferred from the length of the + * slice. If a particular column name isn't known, an empty + * string should be returned for that entry. + */ + columns(): Array + /** + * Close closes the rows iterator. + */ + close(): void + /** + * Next is called to populate the next row of data into + * the provided slice. The provided slice will be the same + * size as the Columns() are wide. + * + * Next should return io.EOF when there are no more rows. + * + * The dest should not be written to outside of Next. Care + * should be taken when closing Rows not to modify + * a buffer held in dest. + */ + next(dest: Array): void + } +} + /** * Package pkix contains shared, low level structures used for ASN.1 parsing * and serialization of X.509 certificates, CRL and OCSP. @@ -22304,39 +22469,6 @@ namespace pkix { } } -/** - * Package crypto collects common cryptographic constants. - */ -namespace crypto { - /** - * 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 acme provides an implementation of the * Automatic Certificate Management Environment (ACME) spec, @@ -22666,84 +22798,34 @@ namespace acme { } /** - * 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. + * Package crypto collects common cryptographic constants. */ -namespace driver { +namespace crypto { /** - * Result is the result of a query execution. + * 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 Result { - /** - * LastInsertId returns the database's auto-generated ID - * after, for example, an INSERT into a table with primary - * key. - */ - lastInsertId(): number - /** - * RowsAffected returns the number of rows affected by the - * query. - */ - rowsAffected(): number - } + interface PublicKey extends _TygojaAny{} /** - * Rows is an iterator over an executed query's results. + * SignerOpts contains options for signing with a Signer. */ - interface Rows { + interface SignerOpts { /** - * Columns returns the names of the columns. The number of - * columns of the result is inferred from the length of the - * slice. If a particular column name isn't known, an empty - * string should be returned for that entry. + * 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. */ - columns(): Array - /** - * Close closes the rows iterator. - */ - close(): void - /** - * Next is called to populate the next row of data into - * the provided slice. The provided slice will be the same - * size as the Columns() are wide. - * - * Next should return io.EOF when there are no more rows. - * - * The dest should not be written to outside of Next. Care - * should be taken when closing Rows not to modify - * a buffer held in dest. - */ - next(dest: Array): void + hashFunc(): Hash } } @@ -22824,38 +22906,6 @@ namespace asn1 { interface RawContent extends String{} } -/** - * 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 pkix contains shared, low level structures used for ASN.1 parsing * and serialization of X.509 certificates, CRL and OCSP. diff --git a/plugins/jsvm/internal/types/types.go b/plugins/jsvm/internal/types/types.go index 07500293..e79a95bc 100644 --- a/plugins/jsvm/internal/types/types.go +++ b/plugins/jsvm/internal/types/types.go @@ -308,6 +308,8 @@ interface Command extends cobra.Command{} // merge /** * Command defines a single console command. * + * Example: + * * ` + "```" + `js * const command = new Command({ * use: "hello", @@ -323,6 +325,51 @@ declare class Command implements cobra.Command { constructor(cmd?: Partial) } +interface RequestInfo extends models.RequestInfo{} // merge +/** + * RequestInfo defines a single models.RequestInfo instance, usually used + * as part of various filter checks. + * + * Example: + * + * ` + "```" + `js + * const authRecord = $app.dao().findAuthRecordByEmail("users", "test@example.com") + * + * const info = new RequestInfo({ + * authRecord: authRecord, + * data: {"name": 123}, + * headers: {"x-token": "..."}, + * }) + * + * const record = $app.dao().findFirstRecordByData("articles", "slug", "hello") + * + * const canAccess = $app.dao().canAccessRecord(record, info, "@request.auth.id != '' && @request.data.name = 123") + * ` + "```" + ` + * + * @group PocketBase + */ +declare class RequestInfo implements models.RequestInfo { + constructor(date?: Partial) +} + +interface DateTime extends types.DateTime{} // merge +/** + * DateTime defines a single DateTime type instance. + * + * Example: + * + * ` + "```" + `js + * const dt0 = new DateTime() // now + * + * const dt1 = new DateTime('2023-07-01 00:00:00.000Z') + * ` + "```" + ` + * + * @group PocketBase + */ +declare class DateTime implements types.DateTime { + constructor(date?: string) +} + interface ValidationError extends ozzo_validation.Error{} // merge /** * ValidationError defines a single formatted data validation error, @@ -690,7 +737,7 @@ declare namespace $apis { let requireAdminOrRecordAuth: apis.requireAdminOrRecordAuth let requireAdminOrOwnerAuth: apis.requireAdminOrOwnerAuth let activityLogger: apis.activityLogger - let requestData: apis.requestData + let requestInfo: apis.requestInfo let recordAuthResponse: apis.recordAuthResponse let enrichRecord: apis.enrichRecord let enrichRecords: apis.enrichRecords diff --git a/resolvers/record_field_resolve_runner.go b/resolvers/record_field_resolve_runner.go index 9ed37aa4..d3bede86 100644 --- a/resolvers/record_field_resolve_runner.go +++ b/resolvers/record_field_resolve_runner.go @@ -64,7 +64,7 @@ func (r *runner) run() (*search.ResolverResult, error) { } if r.activeProps[0] == "@request" { - if r.resolver.requestData == nil { + if r.resolver.requestInfo == nil { return &search.ResolverResult{Identifier: "NULL"}, nil } @@ -87,17 +87,17 @@ func (r *runner) run() (*search.ResolverResult, error) { // check for data relation field if dataField.Type == schema.FieldTypeRelation && len(r.activeProps) > 3 { - return r.processRequestDataRelationField(dataField) + return r.processRequestInfoRelationField(dataField) } // check for select:each field if modifier == eachModifier && dataField.Type == schema.FieldTypeSelect && len(r.activeProps) == 3 { - return r.processRequestDataSelectEachModifier(dataField) + return r.processRequestInfoSelectEachModifier(dataField) } // check for data arrayble fields ":length" modifier if modifier == lengthModifier && list.ExistInSlice(dataField.Type, schema.ArraybleFieldTypes()) && len(r.activeProps) == 3 { - return r.processRequestDataLengthModifier(dataField) + return r.processRequestInfoLengthModifier(dataField) } } @@ -177,11 +177,11 @@ func (r *runner) processRequestAuthField() (*search.ResolverResult, error) { // resolve the auth collection field // --- - if r.resolver.requestData == nil || r.resolver.requestData.AuthRecord == nil || r.resolver.requestData.AuthRecord.Collection() == nil { + if r.resolver.requestInfo == nil || r.resolver.requestInfo.AuthRecord == nil || r.resolver.requestInfo.AuthRecord.Collection() == nil { return &search.ResolverResult{Identifier: "NULL"}, nil } - collection := r.resolver.requestData.AuthRecord.Collection() + collection := r.resolver.requestInfo.AuthRecord.Collection() r.resolver.loadedCollections = append(r.resolver.loadedCollections, collection) r.activeCollectionName = collection.Name @@ -193,7 +193,7 @@ func (r *runner) processRequestAuthField() (*search.ResolverResult, error) { r.activeTableAlias, dbx.HashExp{ // aka. __auth_users.id = :userId - (r.activeTableAlias + ".id"): r.resolver.requestData.AuthRecord.Id, + (r.activeTableAlias + ".id"): r.resolver.requestInfo.AuthRecord.Id, }, ) @@ -205,7 +205,7 @@ func (r *runner) processRequestAuthField() (*search.ResolverResult, error) { tableName: inflector.Columnify(r.activeCollectionName), tableAlias: r.multiMatchActiveTableAlias, on: dbx.HashExp{ - (r.multiMatchActiveTableAlias + ".id"): r.resolver.requestData.AuthRecord.Id, + (r.multiMatchActiveTableAlias + ".id"): r.resolver.requestInfo.AuthRecord.Id, }, }, ) @@ -217,8 +217,8 @@ func (r *runner) processRequestAuthField() (*search.ResolverResult, error) { return r.processActiveProps() } -func (r *runner) processRequestDataLengthModifier(dataField *schema.SchemaField) (*search.ResolverResult, error) { - dataItems := list.ToUniqueStringSlice(r.resolver.requestData.Data[dataField.Name]) +func (r *runner) processRequestInfoLengthModifier(dataField *schema.SchemaField) (*search.ResolverResult, error) { + dataItems := list.ToUniqueStringSlice(r.resolver.requestInfo.Data[dataField.Name]) result := &search.ResolverResult{ Identifier: fmt.Sprintf("%d", len(dataItems)), @@ -227,13 +227,13 @@ func (r *runner) processRequestDataLengthModifier(dataField *schema.SchemaField) return result, nil } -func (r *runner) processRequestDataSelectEachModifier(dataField *schema.SchemaField) (*search.ResolverResult, error) { +func (r *runner) processRequestInfoSelectEachModifier(dataField *schema.SchemaField) (*search.ResolverResult, error) { options, ok := dataField.Options.(*schema.SelectOptions) if !ok { return nil, fmt.Errorf("failed to initialize field %q options", dataField.Name) } - dataItems := list.ToUniqueStringSlice(r.resolver.requestData.Data[dataField.Name]) + dataItems := list.ToUniqueStringSlice(r.resolver.requestInfo.Data[dataField.Name]) rawJson, err := json.Marshal(dataItems) if err != nil { return nil, fmt.Errorf("cannot marshalize the data select item for field %q", r.activeProps[2]) @@ -272,7 +272,7 @@ func (r *runner) processRequestDataSelectEachModifier(dataField *schema.SchemaFi return result, nil } -func (r *runner) processRequestDataRelationField(dataField *schema.SchemaField) (*search.ResolverResult, error) { +func (r *runner) processRequestInfoRelationField(dataField *schema.SchemaField) (*search.ResolverResult, error) { options, ok := dataField.Options.(*schema.RelationOptions) if !ok { return nil, fmt.Errorf("failed to initialize data field %q options", dataField.Name) @@ -284,8 +284,8 @@ func (r *runner) processRequestDataRelationField(dataField *schema.SchemaField) } var dataRelIds []string - if r.resolver.requestData != nil && len(r.resolver.requestData.Data) != 0 { - dataRelIds = list.ToUniqueStringSlice(r.resolver.requestData.Data[dataField.Name]) + if r.resolver.requestInfo != nil && len(r.resolver.requestInfo.Data) != 0 { + dataRelIds = list.ToUniqueStringSlice(r.resolver.requestInfo.Data[dataField.Name]) } if len(dataRelIds) == 0 { return &search.ResolverResult{Identifier: "NULL"}, nil diff --git a/resolvers/record_field_resolver.go b/resolvers/record_field_resolver.go index 48c238ca..f938c664 100644 --- a/resolvers/record_field_resolver.go +++ b/resolvers/record_field_resolver.go @@ -56,7 +56,7 @@ type CollectionsFinder interface { // resolver := resolvers.NewRecordFieldResolver( // app.Dao(), // myCollection, -// &models.RequestData{...}, +// &models.RequestInfo{...}, // true, // ) // provider := search.NewProvider(resolver) @@ -68,21 +68,21 @@ type RecordFieldResolver struct { allowedFields []string loadedCollections []*models.Collection joins []*join // we cannot use a map because the insertion order is not preserved - requestData *models.RequestData - staticRequestData map[string]any + requestInfo *models.RequestInfo + staticRequestInfo map[string]any } // NewRecordFieldResolver creates and initializes a new `RecordFieldResolver`. func NewRecordFieldResolver( dao CollectionsFinder, baseCollection *models.Collection, - requestData *models.RequestData, + requestInfo *models.RequestInfo, allowHiddenFields bool, ) *RecordFieldResolver { r := &RecordFieldResolver{ dao: dao, baseCollection: baseCollection, - requestData: requestData, + requestInfo: requestInfo, allowHiddenFields: allowHiddenFields, joins: []*join{}, loadedCollections: []*models.Collection{baseCollection}, @@ -97,17 +97,17 @@ func NewRecordFieldResolver( }, } - r.staticRequestData = map[string]any{} - if r.requestData != nil { - r.staticRequestData["method"] = r.requestData.Method - r.staticRequestData["query"] = r.requestData.Query - r.staticRequestData["headers"] = r.requestData.Headers - r.staticRequestData["data"] = r.requestData.Data - r.staticRequestData["auth"] = nil - if r.requestData.AuthRecord != nil { - r.requestData.AuthRecord.IgnoreEmailVisibility(true) - r.staticRequestData["auth"] = r.requestData.AuthRecord.PublicExport() - r.requestData.AuthRecord.IgnoreEmailVisibility(false) + r.staticRequestInfo = map[string]any{} + if r.requestInfo != nil { + r.staticRequestInfo["method"] = r.requestInfo.Method + r.staticRequestInfo["query"] = r.requestInfo.Query + r.staticRequestInfo["headers"] = r.requestInfo.Headers + r.staticRequestInfo["data"] = r.requestInfo.Data + r.staticRequestInfo["auth"] = nil + if r.requestInfo.AuthRecord != nil { + r.requestInfo.AuthRecord.IgnoreEmailVisibility(true) + r.staticRequestInfo["auth"] = r.requestInfo.AuthRecord.PublicExport() + r.requestInfo.AuthRecord.IgnoreEmailVisibility(false) } } @@ -166,7 +166,7 @@ func (r *RecordFieldResolver) resolveStaticRequestField(path ...string) (*search path[len(path)-1] = lastProp // extract value - resultVal, err := extractNestedMapVal(r.staticRequestData, path...) + resultVal, err := extractNestedMapVal(r.staticRequestInfo, path...) if modifier == issetModifier { if err != nil { @@ -175,7 +175,7 @@ func (r *RecordFieldResolver) resolveStaticRequestField(path ...string) (*search return &search.ResolverResult{Identifier: "TRUE"}, nil } - // note: we are ignoring the error because requestData is dynamic + // note: we are ignoring the error because requestInfo is dynamic // and some of the lookup keys may not be defined for the request switch v := resultVal.(type) { diff --git a/resolvers/record_field_resolver_test.go b/resolvers/record_field_resolver_test.go index 21e7d24b..be28996c 100644 --- a/resolvers/record_field_resolver_test.go +++ b/resolvers/record_field_resolver_test.go @@ -22,7 +22,7 @@ func TestRecordFieldResolverUpdateQuery(t *testing.T) { t.Fatal(err) } - requestData := &models.RequestData{ + requestInfo := &models.RequestInfo{ Headers: map[string]any{ "a": "123", "b": "456", @@ -313,7 +313,7 @@ func TestRecordFieldResolverUpdateQuery(t *testing.T) { query := app.Dao().RecordQuery(collection) - r := resolvers.NewRecordFieldResolver(app.Dao(), collection, requestData, s.allowHiddenFields) + r := resolvers.NewRecordFieldResolver(app.Dao(), collection, requestInfo, s.allowHiddenFields) expr, err := search.FilterData(s.rule).BuildExpr(r) if err != nil { @@ -353,11 +353,11 @@ func TestRecordFieldResolverResolveSchemaFields(t *testing.T) { t.Fatal(err) } - requestData := &models.RequestData{ + requestInfo := &models.RequestInfo{ AuthRecord: authRecord, } - r := resolvers.NewRecordFieldResolver(app.Dao(), collection, requestData, true) + r := resolvers.NewRecordFieldResolver(app.Dao(), collection, requestInfo, true) scenarios := []struct { fieldName string @@ -424,7 +424,7 @@ func TestRecordFieldResolverResolveSchemaFields(t *testing.T) { } } -func TestRecordFieldResolverResolveStaticRequestDataFields(t *testing.T) { +func TestRecordFieldResolverResolveStaticRequestInfoFields(t *testing.T) { app, _ := tests.NewTestApp() defer app.Cleanup() @@ -438,7 +438,7 @@ func TestRecordFieldResolverResolveStaticRequestDataFields(t *testing.T) { t.Fatal(err) } - requestData := &models.RequestData{ + requestInfo := &models.RequestInfo{ Method: "get", Query: map[string]any{ "a": 123, @@ -455,7 +455,7 @@ func TestRecordFieldResolverResolveStaticRequestDataFields(t *testing.T) { AuthRecord: authRecord, } - r := resolvers.NewRecordFieldResolver(app.Dao(), collection, requestData, true) + r := resolvers.NewRecordFieldResolver(app.Dao(), collection, requestInfo, true) scenarios := []struct { fieldName string