Skip to content

Commit

Permalink
fix: update SDK contributing docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanpq committed Nov 15, 2024
1 parent 8152446 commit 1296ee9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ That repo includes an issue template that will walk through all the places to ch

### Submitting Pull Requests

Considering that the SDKs are autogenerated, please make sure to submit your Pull Requests to the [sdk-generator](https://github.com/openfga/sdk-generator). We will not accept PRs to this repository because they will be overwritten on the next sdk generation.
While we accept Pull Requests on this repository, the SDKs are autogenerated so please consider additionally submitting your Pull Requests to the [sdk-generator](https://github.com/openfga/sdk-generator) and linking the two PRs together and to the corresponding issue. This will greatly assist the OpenFGA team in being able to give timely reviews as well as deploying fixes and updates to our other SDKs as well.

## Getting in touch

Expand Down
60 changes: 30 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,13 @@ Reads the relationship tuples stored in the database. It does not evaluate nor e
const body = {
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation: "viewer",
object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
object: "document:roadmap",
};

// Find all relationship tuples where a certain user has any relation to a certain document
const body = {
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
object: "document:roadmap",
};

// Find all relationship tuples where a certain user is a viewer of any document
Expand All @@ -354,7 +354,7 @@ const body = {

// Find all relationship tuples where any user has any relation with a particular document
const body = {
object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
object: "document:roadmap",
};

// Read all stored relationship tuples
Expand Down Expand Up @@ -383,13 +383,13 @@ const options = {};
options.authorizationModelId = "01GXSA8YR785C4FYS3C0RTG7B1";

await fgaClient.write({
writes: [{ user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "viewer", object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a" }],
deletes: [{ user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "editor", object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a" }],
writes: [{ user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "viewer", object: "document:roadmap" }],
deletes: [{ user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "editor", object: "document:roadmap" }],
}, options);

// Convenience functions are available
await fgaClient.writeTuples([{ user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "viewer", object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a" }], options);
await fgaClient.deleteTuples([{ user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "editor", object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a" }], options);
await fgaClient.writeTuples([{ user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "viewer", object: "document:roadmap" }], options);
await fgaClient.deleteTuples([{ user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "editor", object: "document:roadmap" }], options);

// if any error is encountered in the transaction mode, an error will be thrown
```
Expand All @@ -407,14 +407,14 @@ options.transaction = {
};
const response = await fgaClient.write({
writes: [{ user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "viewer", object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a" }],
deletes: [{ user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "editor", object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a" }],
writes: [{ user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "viewer", object: "document:roadmap" }],
deletes: [{ user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "editor", object: "document:roadmap" }],
}, options);
/*
response = {
writes: [{ tuple_key: { user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "viewer", object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a", status: "success" } }],
deletes: [{ tuple_key: { user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "editor", object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a", status: "failure", err: <FgaError ...> } }],
writes: [{ tuple_key: { user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "viewer", object: "document:roadmap", status: "success" } }],
deletes: [{ tuple_key: { user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation: "editor", object: "document:roadmap", status: "failure", err: <FgaError ...> } }],
};
*/
```
Expand All @@ -436,7 +436,7 @@ const options = {
const result = await fgaClient.check({
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation: "viewer",
object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
object: "document:roadmap",
}, options);

// result = { allowed: true }
Expand All @@ -455,19 +455,19 @@ const options = {
const { responses } = await fgaClient.batchCheck([{
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation: "viewer",
object: "document:0192ab2d-d36e-7cb3-a4a8-5d1d67a300c5",
object: "document:budget",
}, {
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation: "member",
object: "document:0192ab2d-d36e-7cb3-a4a8-5d1d67a300c5",
object: "document:budget",
}, {
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation: "viewer",
object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
object: "document:roadmap",
contextualTuples: [{
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation: "writer",
object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"
object: "document:roadmap"
}],
}], options);

Expand All @@ -477,26 +477,26 @@ responses = [{
_request: {
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation: "viewer",
object: "document:0192ab2d-d36e-7cb3-a4a8-5d1d67a300c5",
object: "document:budget",
}
}, {
allowed: false,
_request: {
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation: "member",
object: "document:0192ab2d-d36e-7cb3-a4a8-5d1d67a300c5",
object: "document:budget",
},
err: <FgaError ...>
}, {
allowed: true,
_request: {
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation: "viewer",
object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
object: "document:roadmap",
contextualTuples: [{
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation: "writer",
object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"
object: "document:roadmap"
}],
}},
]
Expand All @@ -517,10 +517,10 @@ options.authorizationModelId = "01GXSA8YR785C4FYS3C0RTG7B1";

const { tree } = await fgaClient.expand({
relation: "viewer",
object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
object: "document:roadmap",
}, options);

// tree = { root: { name: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a#viewer", leaf: { users: { users: ["user:81684243-9356-4421-8fbf-a4f8d36aa31b", "user:f52a4f7a-054d-47ff-bb6e-3ac81269988f"] } } } }
// tree = { root: { name: "document:roadmap#viewer", leaf: { users: { users: ["user:81684243-9356-4421-8fbf-a4f8d36aa31b", "user:f52a4f7a-054d-47ff-bb6e-3ac81269988f"] } } } }
```

##### List Objects
Expand All @@ -542,11 +542,11 @@ const response = await fgaClient.listObjects({
contextualTuples: [{
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation: "writer",
object: "document:0192ab2d-d36e-7cb3-a4a8-5d1d67a300c5"
object: "document:budget"
}],
}, options);

// response.objects = ["document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"]
// response.objects = ["document:roadmap"]
```

##### List Relations
Expand All @@ -563,12 +563,12 @@ options.authorization_model_id = "1uHxCSuTP0VKPYSnkq1pbb1jeZw";

const response = await fgaClient.listRelations({
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
object: "document:roadmap",
relations: ["can_view", "can_edit", "can_delete"],
contextualTuples: [{
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation: "writer",
object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"
object: "document:roadmap"
}],
}, options);

Expand Down Expand Up @@ -610,7 +610,7 @@ const response = await fgaClient.listUsers({
}, {
user: "folder:product",
relation: "parent",
object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a"
object: "document:roadmap"
}]
}, options);

Expand All @@ -637,7 +637,7 @@ const response = await fgaClient.readAssertions(options);
response.assertions = [{
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation: "viewer",
object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
object: "document:roadmap",
expectation: true,
}];
*/
Expand All @@ -658,7 +658,7 @@ options.authorizationModelId = "01GXSA8YR785C4FYS3C0RTG7B1";
const response = await fgaClient.writeAssertions([{
user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b",
relation: "viewer",
object: "document:0192ab2a-d83f-756d-9397-c5ed9f3cb69a",
object: "document:roadmap",
expectation: true,
}], options);
```
Expand Down Expand Up @@ -724,7 +724,7 @@ If you have found a bug or if you have a feature request, please report them on

### Pull Requests

All changes made to this repo will be overwritten on the next generation, so we kindly ask that you send all pull requests related to the SDKs to the [sdk-generator repo](https://github.com/openfga/sdk-generator) instead.
While we accept Pull Requests on this repository, the SDKs are autogenerated so please consider additionally submitting your Pull Requests to the [sdk-generator](https://github.com/openfga/sdk-generator) and linking the two PRs together and to the corresponding issue. This will greatly assist the OpenFGA team in being able to give timely reviews as well as deploying fixes and updates to our other SDKs as well.

## Author

Expand Down

0 comments on commit 1296ee9

Please sign in to comment.