working commit

This commit is contained in:
2026-02-21 12:31:39 +02:00
parent 3220e2d78f
commit cd37a4508c
37 changed files with 354 additions and 319 deletions
+4 -6
View File
@@ -7,16 +7,14 @@
* Distribution of this work is permitted, but commercial use and
* modifications are strictly prohibited.
*/
package uuid
package auxuuid
import (
"github.com/google/uuid"
)
type UUID string
const ZeroUUID string = "00000000-0000-0000-0000-000000000000"
const ZeroUUID UUID = "00000000-0000-0000-0000-000000000000"
func NewUUID() UUID {
return UUID(uuid.New().String())
func NewUUID() string {
return uuid.New().String()
}
+8 -9
View File
@@ -17,12 +17,11 @@ import (
"mstore/app/handler"
"mstore/app/operator"
"mstore/pkg/descr"
"mstore/pkg/auxid"
)
func (cli *Client) CreateAccount(ctx context.Context, hosturi, username, password string) (uint64, error) {
func (cli *Client) CreateAccount(ctx context.Context, hosturi, username, password string) (string, error) {
var err error
var res uint64
var res string
apiuri, err := setApiPath(hosturi, "/v3/api/account/create")
if err != nil {
@@ -54,7 +53,7 @@ func (cli *Client) CreateAccount(ctx context.Context, hosturi, username, passwor
return res, err
}
func (cli *Client) GetAccountByID(ctx context.Context, hosturi string, id uint64) (*descr.AccountShort, error) {
func (cli *Client) GetAccountByID(ctx context.Context, hosturi, accountID string) (*descr.AccountShort, error) {
var err error
res := &descr.AccountShort{}
@@ -64,7 +63,7 @@ func (cli *Client) GetAccountByID(ctx context.Context, hosturi string, id uint64
}
operParams := operator.GetAccountParams{
AccountID: id,
AccountID: accountID,
}
paramsJson, err := json.Marshal(operParams)
if err != nil {
@@ -121,7 +120,7 @@ func (cli *Client) GetAccountByName(ctx context.Context, hosturi, username strin
return res, err
}
func (cli *Client) UpdateAccountByID(ctx context.Context, hosturi string, id uint64, newUsername, newPassword string) error {
func (cli *Client) UpdateAccountByID(ctx context.Context, hosturi string, accountID, newUsername, newPassword string) error {
var err error
apipath, err := setApiPath(hosturi, "/v3/api/account/update")
@@ -129,7 +128,7 @@ func (cli *Client) UpdateAccountByID(ctx context.Context, hosturi string, id uin
return err
}
operParams := operator.UpdateAccountParams{
AccountID: id,
AccountID: accountID,
NewUsername: newUsername,
NewPassword: newPassword,
}
@@ -215,7 +214,7 @@ func (cli *Client) DeleteAccountByName(ctx context.Context, hosturi, username st
return err
}
func (cli *Client) DeleteAccountByID(ctx context.Context, hosturi string, id uint64) error {
func (cli *Client) DeleteAccountByID(ctx context.Context, hosturi, accountID string) error {
var err error
apipath, err := setApiPath(hosturi, "/v3/api/account/delete")
@@ -223,7 +222,7 @@ func (cli *Client) DeleteAccountByID(ctx context.Context, hosturi string, id uin
return err
}
operParams := operator.DeleteAccountParams{
AccountID: id,
AccountID: accountID,
}
paramsJson, err := json.Marshal(operParams)
if err != nil {
+3 -4
View File
@@ -23,7 +23,6 @@ import (
"mstore/pkg/auxhttp"
"mstore/pkg/descr"
"mstore/pkg/term"
)
func (cli *Client) FileInfo(ctx context.Context, fileuri string) (bool, *descr.File, error) {
@@ -209,7 +208,7 @@ func (cli *Client) DeleteFile(ctx context.Context, fileuri string) error {
return err
}
func (cli *Client) ListFiles(ctx context.Context, catalogURI string, usePathAs term.PathUsage) ([]descr.File, error) {
func (cli *Client) ListFiles(ctx context.Context, catalogURI, usePathAs string) ([]descr.File, error) {
var err error
res := make([]descr.File, 0)
@@ -277,7 +276,7 @@ func (cli *Client) ListFiles(ctx context.Context, catalogURI string, usePathAs t
return res, err
}
func (cli *Client) ListCollections(ctx context.Context, catalogURI string, usePathAs term.PathUsage) ([]string, error) {
func (cli *Client) ListCollections(ctx context.Context, catalogURI, usePathAs string) ([]string, error) {
var err error
res := make([]string, 0)
@@ -346,7 +345,7 @@ func (cli *Client) ListCollections(ctx context.Context, catalogURI string, usePa
return res, err
}
func (cli *Client) DeleteCollection(ctx context.Context, catalogURI string, usePathAs term.PathUsage, dryRun bool) ([]descr.File, error) {
func (cli *Client) DeleteCollection(ctx context.Context, catalogURI, usePathAs string, dryRun bool) ([]descr.File, error) {
var err error
res := make([]descr.File, 0)
+9 -11
View File
@@ -17,13 +17,11 @@ import (
"mstore/app/handler"
"mstore/app/operator"
"mstore/pkg/descr"
"mstore/pkg/term"
"mstore/pkg/auxid"
)
func (cli *Client) CreateGrantByAccountID(ctx context.Context, hosturi string, accountID uint64, right term.Right, pattern string) (uint64, error) {
func (cli *Client) CreateGrantByAccountID(ctx context.Context, hosturi string, accountID, right, pattern string) (string, error) {
var err error
var res uint64
var res string
apiuri, err := setApiPath(hosturi, "/v3/api/grant/create")
if err != nil {
@@ -56,9 +54,9 @@ func (cli *Client) CreateGrantByAccountID(ctx context.Context, hosturi string, a
return res, err
}
func (cli *Client) CreateGrantByUsername(ctx context.Context, hosturi, username string, right term.Right, pattern string) (uint64, error) {
func (cli *Client) CreateGrantByUsername(ctx context.Context, hosturi, username string, right string, pattern string) (string, error) {
var err error
var res uint64
var res string
apiuri, err := setApiPath(hosturi, "/v3/api/grant/create")
if err != nil {
@@ -91,7 +89,7 @@ func (cli *Client) CreateGrantByUsername(ctx context.Context, hosturi, username
return res, err
}
func (cli *Client) GetGrant(ctx context.Context, hosturi string, id uint64) (*descr.Grant, error) {
func (cli *Client) GetGrant(ctx context.Context, hosturi, grantID string) (*descr.Grant, error) {
var err error
res := &descr.Grant{}
@@ -100,7 +98,7 @@ func (cli *Client) GetGrant(ctx context.Context, hosturi string, id uint64) (*de
return res, err
}
operParams := operator.GetGrantParams{
GrantID: id,
GrantID: grantID,
}
paramsJson, err := json.Marshal(operParams)
if err != nil {
@@ -124,7 +122,7 @@ func (cli *Client) GetGrant(ctx context.Context, hosturi string, id uint64) (*de
return res, err
}
func (cli *Client) UpdateGrant(ctx context.Context, hosturi string, grantID uint64, newPattern string) error {
func (cli *Client) UpdateGrant(ctx context.Context, hosturi, grantID, newPattern string) error {
var err error
apipath, err := setApiPath(hosturi, "/v3/api/grant/update")
@@ -155,7 +153,7 @@ func (cli *Client) UpdateGrant(ctx context.Context, hosturi string, grantID uint
return err
}
func (cli *Client) DeleteGrant(ctx context.Context, hosturi string, grantID uint64) error {
func (cli *Client) DeleteGrant(ctx context.Context, hosturi, grantID string) error {
var err error
apipath, err := setApiPath(hosturi, "/v3/api/grant/delete")
@@ -186,7 +184,7 @@ func (cli *Client) DeleteGrant(ctx context.Context, hosturi string, grantID uint
return err
}
func (cli *Client) ListGrantsByAccountID(ctx context.Context, hosturi string, accountID uint64) ([]descr.Grant, error) {
func (cli *Client) ListGrantsByAccountID(ctx context.Context, hosturi, accountID string) ([]descr.Grant, error) {
var err error
res := make([]descr.Grant, 0)
+16 -17
View File
@@ -9,25 +9,24 @@
*/
package descr
type Account struct {
ID uint64 `json:"id" db:"id"`
Username string `json:"username" db:"username"`
Passhash string `json:"passhash" db:"passhash"`
Disabled bool `json:"disabled" db:"disabled"`
CreatedAt string `json:"createdAt" db:"created_at"`
UpdatedAt string `json:"updatedAt" db:"updated_at"`
CreatedBy uint64 `json:"createdBy" db:"created_by"`
UpdatedBy uint64 `json:"updatedBy" db:"updated_by"`
ID string `json:"id" db:"id"`
Username string `json:"username" db:"username"`
Passhash string `json:"passhash" db:"passhash"`
Disabled bool `json:"disabled" db:"disabled"`
CreatedAt string `json:"createdAt" db:"created_at"`
UpdatedAt string `json:"updatedAt" db:"updated_at"`
CreatedBy string `json:"createdBy" db:"created_by"`
UpdatedBy string `json:"updatedBy" db:"updated_by"`
}
type AccountShort struct {
ID uint64 `json:"id"`
Username string `json:"username"`
Disabled bool `json:"disabled"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
CreatedBy uint64 `json:"createdBy"`
UpdatedBy uint64 `json:"updatedBy"`
Grants []Grant `json:"grants"`
ID string `json:"id"`
Username string `json:"username"`
Disabled bool `json:"disabled"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
CreatedBy string `json:"createdBy"`
UpdatedBy string `json:"updatedBy"`
Grants []Grant `json:"grants"`
}
+10 -10
View File
@@ -10,14 +10,14 @@
package descr
type Blob struct {
ID uint64 `db:"id" json:"id"`
Name string `db:"name" json:"name"`
Reference string `db:"reference" json:"reference"`
MediaType string `db:"mediaType" json:"mediaType"`
Digest string `db:"digest" json:"digest"`
Size int64 `db:"size" json:"size"`
CreatedAt string `db:"created_at" json:"createdAt"`
UpdatedAt string `db:"updated_at" json:"updatedAt"`
CreatedBy uint64 `db:"created_by" json:"createdBy,omitempty"`
UpdatedBy uint64 `db:"updated_by" json:"updatedBy,omitempty"`
ID string `db:"id" json:"id"`
Name string `db:"name" json:"name"`
Reference string `db:"reference" json:"reference"`
MediaType string `db:"mediaType" json:"mediaType"`
Digest string `db:"digest" json:"digest"`
Size int64 `db:"size" json:"size"`
CreatedAt string `db:"created_at" json:"createdAt"`
UpdatedAt string `db:"updated_at" json:"updatedAt"`
CreatedBy string `db:"created_by" json:"createdBy,omitempty"`
UpdatedBy string `db:"updated_by" json:"updatedBy,omitempty"`
}
+10 -10
View File
@@ -10,14 +10,14 @@
package descr
type File struct {
ID uint64 `db:"id" json:"id,omitempty" yaml:"id,omitempty"`
Collection string `db:"collection" json:"collection,omitempty" yaml:"collection,omitempty"`
Name string `db:"name" json:"name,omitempty" yaml:"name,omitempty"`
Type string `db:"type" json:"type,omitempty" yaml:"type,omitempty"`
Checksum string `db:"checksum" json:"checksum,omitempty" yaml:"checksum,omitempty"`
Size int64 `db:"size" json:"size,omitempty" yaml:"size,omitempty"`
CreatedAt string `db:"created_at" json:"createdAt,omitempty" yaml:"createdAt,omitempty"`
UpdatedAt string `db:"updated_at" json:"updatedAt,omitempty" yaml:"updatedAt,omitempty"`
CreatedBy uint64 `db:"created_by" json:"createdBy,omitempty" yaml:"createdBy,omitempty"`
UpdatedBy uint64 `db:"updated_by" json:"updatedBy,omitempty" yaml:"updatedBy,omitempty"`
ID string `db:"id" json:"id,omitempty" yaml:"id,omitempty"`
Collection string `db:"collection" json:"collection,omitempty" yaml:"collection,omitempty"`
Name string `db:"name" json:"name,omitempty" yaml:"name,omitempty"`
Type string `db:"type" json:"type,omitempty" yaml:"type,omitempty"`
Checksum string `db:"checksum" json:"checksum,omitempty" yaml:"checksum,omitempty"`
Size int64 `db:"size" json:"size,omitempty" yaml:"size,omitempty"`
CreatedAt string `db:"created_at" json:"createdAt,omitempty" yaml:"createdAt,omitempty"`
UpdatedAt string `db:"updated_at" json:"updatedAt,omitempty" yaml:"updatedAt,omitempty"`
CreatedBy string `db:"created_by" json:"createdBy,omitempty" yaml:"createdBy,omitempty"`
UpdatedBy string `db:"updated_by" json:"updatedBy,omitempty" yaml:"updatedBy,omitempty"`
}
+8 -12
View File
@@ -10,17 +10,13 @@
package descr
import (
"mstore/pkg/term"
)
type Grant struct {
ID uint64 `json:"id" db:"id"`
AccountID uint64 `json:"accountID" db:"account_id"`
Right term.Right `json:"right" db:"right"`
Pattern string `json:"pattern" db:"pattern"`
CreatedAt string `json:"createdAt" db:"created_at"`
UpdatedAt string `json:"updatedAt" db:"updated_at"`
CreatedBy uint64 `json:"createdBy" db:"created_by"`
UpdatedBy uint64 `json:"updatedBy" db:"updated_by"`
ID string `json:"id" db:"id"`
AccountID string `json:"accountID" db:"account_id"`
Right string `json:"right" db:"right"`
Pattern string `json:"pattern" db:"pattern"`
CreatedAt string `json:"createdAt" db:"created_at"`
UpdatedAt string `json:"updatedAt" db:"updated_at"`
CreatedBy string `json:"createdBy" db:"created_by"`
UpdatedBy string `json:"updatedBy" db:"updated_by"`
}
+10 -10
View File
@@ -10,16 +10,16 @@
package descr
type Manifest struct {
ID uint64 `db:"id" json:"id"`
Name string `db:"name" json:"name"`
Reference string `db:"reference" json:"reference"`
ContentType string `db:"contentType" json:"contentType"`
Payload string `db:"payload" json:"-"`
Digest string `db:"digest" json:"digest"`
CreatedAt string `db:"created_at" json:"createdAt"`
UpdatedAt string `db:"updated_at" json:"updatedAt"`
CreatedBy uint64 `db:"created_by" json:"createdBy,omitempty"`
UpdatedBy uint64 `db:"updated_by" json:"updatedBy,omitempty"`
ID string `db:"id" json:"id"`
Name string `db:"name" json:"name"`
Reference string `db:"reference" json:"reference"`
ContentType string `db:"contentType" json:"contentType"`
Payload string `db:"payload" json:"-"`
Digest string `db:"digest" json:"digest"`
CreatedAt string `db:"created_at" json:"createdAt"`
UpdatedAt string `db:"updated_at" json:"updatedAt"`
CreatedBy string `db:"created_by" json:"createdBy,omitempty"`
UpdatedBy string `db:"updated_by" json:"updatedBy,omitempty"`
}
type Tags struct {
+18 -22
View File
@@ -11,34 +11,30 @@
package term
import (
//"mstore/pkg/auxid"
)
type PathUsage string
const (
AsFinePath PathUsage = "asFinePath"
AsPrefix PathUsage = "asPrefix"
AsRegexp PathUsage = "asRegexp"
//"mstore/pkg/auxuuid"
)
const (
AnonimousUsername string = "anonymous"
AnonymousID uint64 = 1
ServerUsername string = "server"
ServerID uint64 = 2
InitUsername string = "mstore"
InitID uint64 = 5
AsFinePath string = "asFinePath"
AsPrefix string = "asPrefix"
AsRegexp string = "asRegexp"
)
type Right string
const (
AnonimousUsername string = "anonymous"
AnonymousID string = "0000000-0000-0000-0000-000000000001"
ServerUsername string = "server"
ServerID string = "0000000-0000-0000-0000-000000000002"
InitUsername string = "mstore"
InitID string = "0000000-0000-0000-0000-000000000005"
)
const (
// Accounts, grants
RightReadAccounts Right = "readAccounts" // GetAccount, ListAccounts
RightWriteAccounts Right = "writeAccounts" // CreateAccount, UpdateAccount, DeleteAccount
RightWriteFiles Right = "writeFiles" // FileInfo, GetFile, ListFiles
RightReadFiles Right = "readFiles" // PutFile, DeleteFile
RightReadImages Right = "readImages" // ManifestInfo, GetManifest, BlobInfo, GetBlob
RightWriteImages Right = "writeImages" // other opearion
RightReadAccounts string = "readAccounts" // GetAccount, ListAccounts
RightWriteAccounts string = "writeAccounts" // CreateAccount, UpdateAccount, DeleteAccount
RightWriteFiles string = "writeFiles" // FileInfo, GetFile, ListFiles
RightReadFiles string = "readFiles" // PutFile, DeleteFile
RightReadImages string = "readImages" // ManifestInfo, GetManifest, BlobInfo, GetBlob
RightWriteImages string = "writeImages" // other opearion
)