Skip to content

Commit 53c5348

Browse files
committed
feat: add support for ListObjects API endpoint
1 parent 39701a2 commit 53c5348

File tree

9 files changed

+1734
-1967
lines changed

9 files changed

+1734
-1967
lines changed

.openapi-generator/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.0.0
1+
6.1.0-SNAPSHOT

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Changelog
22

3+
## v0.0.2
4+
5+
### [0.0.2](https://github.com/openfga/js-sdk/compare/v0.0.1...v0.0.2) (2022-08-15)
6+
7+
Support for [ListObjects API]](https://openfga.dev/api/service#/Relationship%20Queries/ListObjects)
8+
9+
You call the API and receive the list of object ids from a particular type that the user has a certain relation with.
10+
11+
For example, to find the list of documents that Anne can read:
12+
13+
```javascript
14+
const response = await openFgaApi.listObjects({
15+
user: "anne",
16+
relation: "can_read",
17+
type: "document"
18+
});
19+
20+
// response.object_ids = ["roadmap"]
21+
```
22+
323
## v0.0.1
424

525
### [0.0.1](https://github.com/openfga/js-sdk/releases/tag/v0.0.1) (2022-06-15)

README.md

Lines changed: 81 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,30 @@ This is an autogenerated JavaScript SDK for OpenFGA. It provides a wrapper aroun
3131
- [Expand](#expand)
3232
- [Read Tuples](#read-tuples)
3333
- [Read Changes (Watch)](#read-changes-watch)
34+
- [List Objects](#list-objects)
3435
- [API Endpoints](#api-endpoints)
3536
- [Models](#models)
3637
- [Contributing](#contributing)
3738
- [Issues](#issues)
3839
- [Pull Requests](#pull-requests)
3940
- [License](#license)
4041

41-
## <a id="about">About OpenFGA</a>
42+
## About
4243

4344
[OpenFGA](https://openfga.dev) is an open source Fine-Grained Authorization solution inspired by [Google's Zanzibar paper](https://research.google/pubs/pub48190/). It was created by the FGA team at [Auth0](https://auth0.com) based on [Auth0 Fine-Grained Authorization (FGA)](https://fga.dev), available under [a permissive license (Apache-2)](https://github.com/openfga/rfcs/blob/main/LICENSE) and welcomes community contributions.
4445

4546
OpenFGA is designed to make it easy for application builders to model their permission layer, and to add and integrate fine-grained authorization into their applications. OpenFGA’s design is optimized for reliability and low latency at a high scale.
4647

4748
It allows in-memory data storage for quick development, as well as pluggable database modules - with initial support for PostgreSQL.
4849

49-
It offers an [HTTP API](https://openfga.dev/api) and has SDKs for programming languages including [Node.js/JavaScript](https://github.com/openfga/js-sdk), [GoLang](https://github.com/openfga/go-sdk) and [.NET](https://github.com/openfga/dotnet-sdk).
50+
It offers an [HTTP API](https://openfga.dev/api/service) and has SDKs for programming languages including [Node.js/JavaScript](https://github.com/openfga/js-sdk), [GoLang](https://github.com/openfga/go-sdk) and [.NET](https://github.com/openfga/dotnet-sdk).
5051

5152
More SDKs and integrations such as Rego are planned for the future.
5253

5354
## Resources
5455

5556
- [OpenFGA Documentation](https://openfga.dev/docs)
56-
- [OpenFGA API Documentation](https://openfga.dev/api)
57+
- [OpenFGA API Documentation](https://openfga.dev/api/service)
5758
- [Twitter](https://twitter.com/openfga)
5859
- [OpenFGA Discord Community](https://discord.gg/8naAwJfWN6)
5960
- [Zanzibar Academy](https://zanzibar.academy)
@@ -120,7 +121,7 @@ If your server is configured with [authentication enabled](https://openfga.dev/d
120121

121122
#### List Stores
122123

123-
[API Documentation](https://openfga.dev/api#/Stores/ListStores)
124+
[API Documentation](https://openfga.dev/api/service#/Stores/ListStores)
124125

125126
```javascript
126127
const { stores } = await openFga.listStores();
@@ -130,7 +131,7 @@ const { stores } = await openFga.listStores();
130131

131132
#### Create Store
132133

133-
[API Documentation](https://openfga.dev/api#/Stores/CreateStore)
134+
[API Documentation](https://openfga.dev/api/service#/Stores/CreateStore)
134135

135136
```javascript
136137
const { id: storeId } = await openFga.createStore({
@@ -142,7 +143,7 @@ const { id: storeId } = await openFga.createStore({
142143

143144
#### Get Store
144145

145-
[API Documentation](https://openfga.dev/api#/Stores/GetStore)
146+
[API Documentation](https://openfga.dev/api/service#/Stores/GetStore)
146147

147148
> Requires a client initialized with a storeId
148149
@@ -156,7 +157,7 @@ const store = await openFga.getStore({
156157

157158
#### Delete Store
158159

159-
[API Documentation](https://openfga.dev/api#/Stores/DeleteStore)
160+
[API Documentation](https://openfga.dev/api/service#/Stores/DeleteStore)
160161

161162
> Requires a client initialized with a storeId
162163
@@ -166,7 +167,7 @@ await openFga.deleteStore();
166167

167168
#### Write Authorization Model
168169

169-
[API Documentation](https://openfga.dev/api#/Authorization%20Models/WriteAuthorizationModel)
170+
[API Documentation](https://openfga.dev/api/service#/Authorization%20Models/WriteAuthorizationModel)
170171

171172
> Requires a client initialized with a storeId
172173
@@ -199,7 +200,7 @@ const { authorization_model_id: id } = await openFga.writeAuthorizationModel({
199200

200201
#### Read a Single Authorization Model
201202

202-
[API Documentation](https://openfga.dev/api#/Authorization%20Models/ReadAuthorizationModel)
203+
[API Documentation](https://openfga.dev/api/service#/Authorization%20Models/ReadAuthorizationModel)
203204

204205
> Requires a client initialized with a storeId
205206
@@ -212,7 +213,7 @@ const { authorization_model: authorizationModel } = await openFga.readAuthorizat
212213

213214
#### Read Authorization Model IDs
214215

215-
[API Documentation](https://openfga.dev/api#/Authorization%20Models/ReadAuthorizationModels)
216+
[API Documentation](https://openfga.dev/api/service#/Authorization%20Models/ReadAuthorizationModels)
216217

217218
```javascript
218219
const { authorization_model_ids: authorizationModelIds } = await openFga.readAuthorizationModels();
@@ -222,7 +223,7 @@ const { authorization_model_ids: authorizationModelIds } = await openFga.readAut
222223

223224
#### Check
224225

225-
[API Documentation](https://openfga.dev/api#/Relationship%20Queries/Check)
226+
[API Documentation](https://openfga.dev/api/service#/Relationship%20Queries/Check)
226227

227228
> Requires a client initialized with a storeId
228229
@@ -242,7 +243,7 @@ const result = await openFga.check({
242243

243244
#### Write Tuples
244245

245-
[API Documentation](https://openfga.dev/api#/Relationship%20Tuples/Write)
246+
[API Documentation](https://openfga.dev/api/service#/Relationship%20Tuples/Write)
246247

247248
> Requires a client initialized with a storeId
248249
@@ -257,7 +258,7 @@ await openFga.write({
257258

258259
#### Delete Tuples
259260

260-
[API Documentation](https://openfga.dev/api#/Relationship%20Tuples/Write)
261+
[API Documentation](https://openfga.dev/api/service#/Relationship%20Tuples/Write)
261262

262263
> Requires a client initialized with a storeId
263264
@@ -272,7 +273,7 @@ await openFga.write({
272273

273274
#### Expand
274275

275-
[API Documentation](https://openfga.dev/api#/Relationship%20Queries/Expand)
276+
[API Documentation](https://openfga.dev/api/service#/Relationship%20Queries/Expand)
276277

277278
> Requires a client initialized with a storeId
278279
@@ -289,7 +290,7 @@ const { tree } = await openFga.expand({
289290

290291
#### Read Tuples
291292

292-
[API Documentation](https://openfga.dev/api#/Relationship%20Tuples/Read)
293+
[API Documentation](https://openfga.dev/api/service#/Relationship%20Tuples/Read)
293294

294295
> Requires a client initialized with a storeId
295296
@@ -337,7 +338,7 @@ const { tuples } = await openFga.read(body);
337338

338339
> Requires a client initialized with a storeId
339340
340-
[API Documentation](https://openfga.dev/api#/Relationship%20Tuples/ReadChanges)
341+
[API Documentation](https://openfga.dev/api/service#/Relationship%20Tuples/ReadChanges)
341342

342343
```javascript
343344
const type = 'workspace';
@@ -352,6 +353,35 @@ const response = await openFga.readChanges(type, pageSize, continuationToken);
352353
// ]
353354
```
354355

356+
#### List Objects
357+
358+
> Requires a client initialized with a storeId
359+
360+
[API Documentation](https://openfga.dev/api/service#/Relationship%20Queries/ListObjects)
361+
362+
```javascript
363+
const response = await openFgaApi.listObjects({
364+
authorization_model_id: "01GAHCE4YVKPQEKZQHT2R89MQV",
365+
user: "anne",
366+
relation: "can_read",
367+
type: "document",
368+
contextual_tuples: {
369+
tuple_keys:
370+
[{
371+
user: "anne",
372+
relation: "editor",
373+
object: "folder:product"
374+
}, {
375+
user: "folder:product",
376+
relation: "parent",
377+
object: "document:roadmap"
378+
}]
379+
}
380+
});
381+
382+
// response.object_ids = ["roadmap"]
383+
```
384+
355385

356386
### API Endpoints
357387

@@ -362,6 +392,7 @@ const response = await openFga.readChanges(type, pageSize, continuationToken);
362392
| [**deleteStore**](#deletestore) | **DELETE** /stores/{store_id} | Delete a store |
363393
| [**expand**](#expand) | **POST** /stores/{store_id}/expand | Expand all relationships in userset tree format, and following userset rewrite rules. Useful to reason about and debug a certain relationship |
364394
| [**getStore**](#getstore) | **GET** /stores/{store_id} | Get a store |
395+
| [**listObjects**](#listobjects) | **POST** /stores/{store_id}/list-objects | ListObjects lists all of the object ids for objects of the provided type that the given user has a specific relation with. |
365396
| [**listStores**](#liststores) | **GET** /stores | Get all stores |
366397
| [**read**](#read) | **POST** /stores/{store_id}/read | Get tuples from the store that matches a query, without following userset rewrite rules |
367398
| [**readAssertions**](#readassertions) | **GET** /stores/{store_id}/assertions/{authorization_model_id} | Read assertions for an authorization model ID |
@@ -432,6 +463,18 @@ const response = await openFga.readChanges(type, pageSize, continuationToken);
432463
[**GetStoreResponse**](#GetStoreResponse)
433464

434465

466+
#### listObjects
467+
468+
469+
| Name | Type | Description | Notes |
470+
| ------------- | ------------- | ------------- | ------------- |
471+
| **body** | [**ListObjectsRequest**](#ListObjectsRequest) | | |
472+
473+
##### Return type
474+
475+
[**ListObjectsResponse**](#ListObjectsResponse)
476+
477+
435478
#### listStores
436479

437480

@@ -559,6 +602,8 @@ const response = await openFga.readChanges(type, pageSize, continuationToken);
559602
- [InternalErrorCode](#InternalErrorCode)
560603
- [InternalErrorMessageResponse](#InternalErrorMessageResponse)
561604
- [Leaf](#Leaf)
605+
- [ListObjectsRequest](#ListObjectsRequest)
606+
- [ListObjectsResponse](#ListObjectsResponse)
562607
- [ListStoresResponse](#ListStoresResponse)
563608
- [Node](#Node)
564609
- [Nodes](#Nodes)
@@ -856,6 +901,26 @@ Name | Type | Description | Notes
856901
**computed** | [**Computed**](#Computed) | | [optional] [default to undefined]
857902
**tupleToUserset** | [**UsersetTreeTupleToUserset**](#UsersetTreeTupleToUserset) | | [optional] [default to undefined]
858903

904+
#### ListObjectsRequest
905+
906+
##### Properties
907+
908+
Name | Type | Description | Notes
909+
------------ | ------------- | ------------- | -------------
910+
**authorization_model_id** | **string** | | [optional] [default to undefined]
911+
**type** | **string** | | [optional] [default to undefined]
912+
**relation** | **string** | | [optional] [default to undefined]
913+
**user** | **string** | | [optional] [default to undefined]
914+
**contextual_tuples** | [**ContextualTupleKeys**](#ContextualTupleKeys) | | [optional] [default to undefined]
915+
916+
#### ListObjectsResponse
917+
918+
##### Properties
919+
920+
Name | Type | Description | Notes
921+
------------ | ------------- | ------------- | -------------
922+
**object_ids** | **string** | | [optional] [default to undefined]
923+
859924
#### ListStoresResponse
860925

861926
##### Properties

0 commit comments

Comments
 (0)