From f1dc95c6bb378ae9868124877d9c40eb8f44dac0 Mon Sep 17 00:00:00 2001 From: Simon Esposito Date: Fri, 8 Sep 2023 16:53:29 +0100 Subject: [PATCH] Add storageList caller id param --- index.d.ts | 6 ++++-- runtime/runtime.go | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index 65dd2e1..3362948 100644 --- a/index.d.ts +++ b/index.d.ts @@ -4091,10 +4091,11 @@ declare namespace nkruntime { * @param collection - Opt. Storage collection. * @param limit - Opt. Maximum number of items to list. Defaults to 100. * @param cursor - Opt. Pagination cursor. + * @param callerId - Opt. User ID of the caller, will apply permissions checks of the user. If empty defaults to system user and permissions are bypassed. * @returns Object containing an array of storage objects and a cursor for the next page of results, if there is one. * @throws {TypeError, GoError} */ - storageList(userId: string | null | undefined, collection: string, limit?: number, cursor?: string): StorageObjectList; + storageList(userId: string | void, collection: string, limit?: number, cursor?: string, callerId?: string | void): StorageObjectList; /** * Get all storage objects matching the parameters. @@ -4790,10 +4791,11 @@ declare namespace nkruntime { * @param indexName - Index to query. * @param query - The query to specify the index lookup criteria. * @param limit - The maximum number of results to retrieve from the index. + * @param callerId - Opt. User ID of the caller, will apply permissions checks of the user. If empty defaults to system user and permissions are bypassed. * @returns A list of storage objects matching the query criteria. * @throws {TypeError, GoError} */ - storageIndexList(idnexName: string, query: string, limit: number): StorageObject[]; + storageIndexList(indexName: string, query: string, limit: number, callerId?: string | void): StorageObject[]; /** * Get Satori object. diff --git a/runtime/runtime.go b/runtime/runtime.go index acd2b02..c0db3a7 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -1066,11 +1066,11 @@ type NakamaModule interface { WalletLedgerUpdate(ctx context.Context, itemID string, metadata map[string]interface{}) (WalletLedgerItem, error) WalletLedgerList(ctx context.Context, userID string, limit int, cursor string) ([]WalletLedgerItem, string, error) - StorageList(ctx context.Context, userID, collection string, limit int, cursor string) ([]*api.StorageObject, string, error) + StorageList(ctx context.Context, callerID, userID, collection string, limit int, cursor string) ([]*api.StorageObject, string, error) StorageRead(ctx context.Context, reads []*StorageRead) ([]*api.StorageObject, error) StorageWrite(ctx context.Context, writes []*StorageWrite) ([]*api.StorageObjectAck, error) StorageDelete(ctx context.Context, deletes []*StorageDelete) error - StorageIndexList(ctx context.Context, indexName, query string, limit int) (*api.StorageObjects, error) + StorageIndexList(ctx context.Context, callerID, indexName, query string, limit int) (*api.StorageObjects, error) MultiUpdate(ctx context.Context, accountUpdates []*AccountUpdate, storageWrites []*StorageWrite, walletUpdates []*WalletUpdate, updateLedger bool) ([]*api.StorageObjectAck, []*WalletUpdateResult, error)