From 1296ee92038097318943327b15c25e32e1d478c1 Mon Sep 17 00:00:00 2001 From: Ryan Quinn Date: Fri, 15 Nov 2024 11:11:06 -0600 Subject: [PATCH] fix: update SDK contributing docs --- CONTRIBUTING.md | 2 +- README.md | 60 ++++++++++++++++++++++++------------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 82cac46..47cff81 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 diff --git a/README.md b/README.md index 1ef3d37..c610327 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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 ``` @@ -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: } }], + 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: } }], }; */ ``` @@ -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 } @@ -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); @@ -477,14 +477,14 @@ 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: }, { @@ -492,11 +492,11 @@ responses = [{ _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" }], }}, ] @@ -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 @@ -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 @@ -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); @@ -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); @@ -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, }]; */ @@ -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); ``` @@ -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