Skip to content

Instantly share code, notes, and snippets.

@escherize
Created January 18, 2024 19:57
Show Gist options
  • Save escherize/f042cc8b9358ec41d3effdc9ea051948 to your computer and use it in GitHub Desktop.
Save escherize/f042cc8b9358ec41d3effdc9ea051948 to your computer and use it in GitHub Desktop.
;; (record!)
(defn check-sample [sample]
(let [{:keys [api-perms data-perms]} sample]
[[::data-perms (fmt data-perms)]
[::data->api (fmt (:groups (data-perms.graph/db-graph->api-graph data-perms)))]
[::api (fmt (:groups api-perms))]
[::equal? (= (:groups (data-perms.graph/db-graph->api-graph data-perms))
(:groups api-perms))]]))
(mapv check-sample (samples))
;;=>
[[[:dev.nocommit.data-permissions-rename/data-perms
{:data-access
{"PUBLIC"
{4 :no-self-service,
6 :no-self-service,
2 :no-self-service,
1 :no-self-service,
8 :no-self-service,
7 :no-self-service,
3 :no-self-service,
5 :unrestricted}},
:download-results {"PUBLIC" {4 :no, 6 :no, 2 :no, 1 :no, 8 :no, 7 :no, 3 :no, 5 :one-million-rows}},
:manage-table-metadata {"PUBLIC" {1 :yes, 2 :yes, 3 :yes, 4 :yes, 5 :yes, 6 :no, 7 :yes, 8 :yes}},
:native-query-editing :no}]
[:dev.nocommit.data-permissions-rename/data->api
{:data {:native nil, :schemas {"PUBLIC" {4 nil, 6 nil, 2 nil, 1 nil, 8 nil, 7 nil, 3 nil}}},
:data-model {:schemas {"PUBLIC" {6 nil}}},
:download {:schemas {"PUBLIC" {4 nil, 6 nil, 2 nil, 1 nil, 8 nil, 7 nil, 3 nil}}}}]
[:dev.nocommit.data-permissions-rename/api
{:data {:schemas {"PUBLIC" {5 :all}}},
:data-model {:schemas {"PUBLIC" {8 :all, 7 :all, 5 :all, 4 :all, 3 :all, 2 :all, 1 :all}}},
:download {:schemas {"PUBLIC" {5 :full}}}}]
[:dev.nocommit.data-permissions-rename/equal? false]]
[[:dev.nocommit.data-permissions-rename/data-perms
{:data-access :unrestricted,
:download-results :ten-thousand-rows,
:manage-database :yes,
:manage-table-metadata :yes,
:native-query-editing :yes}]
[:dev.nocommit.data-permissions-rename/data->api {:details :yes, :download {:schemas :limited}}]
[:dev.nocommit.data-permissions-rename/api
{:data {:native :write, :schemas :all},
:data-model {:schemas :all},
:details :yes,
:download {:native :limited, :schemas :limited}}]
[:dev.nocommit.data-permissions-rename/equal? false]]
[[:dev.nocommit.data-permissions-rename/data-perms
{:data-access :no-self-service,
:download-results :ten-thousand-rows,
:manage-database :yes,
:manage-table-metadata :yes,
:native-query-editing :no}]
[:dev.nocommit.data-permissions-rename/data->api
{:data {:native nil, :schemas nil}, :details :yes, :download {:schemas :limited}}]
[:dev.nocommit.data-permissions-rename/api
{:data-model {:schemas :all}, :details :yes, :download {:native :limited, :schemas :limited}}]
[:dev.nocommit.data-permissions-rename/equal? false]]
[[:dev.nocommit.data-permissions-rename/data-perms
{:data-access :unrestricted,
:download-results :ten-thousand-rows,
:manage-database :yes,
:manage-table-metadata :yes,
:native-query-editing :no}]
[:dev.nocommit.data-permissions-rename/data->api
{:data {:native nil}, :details :yes, :download {:schemas :limited}}]
[:dev.nocommit.data-permissions-rename/api
{:data {:schemas :all},
:data-model {:schemas :all},
:details :yes,
:download {:native :limited, :schemas :limited}}]
[:dev.nocommit.data-permissions-rename/equal? false]]
[[:dev.nocommit.data-permissions-rename/data-perms
{:data-access :unrestricted,
:download-results :ten-thousand-rows,
:manage-database :yes,
:manage-table-metadata :yes,
:native-query-editing :no}]
[:dev.nocommit.data-permissions-rename/data->api
{:data {:native nil}, :details :yes, :download {:schemas :limited}}]
[:dev.nocommit.data-permissions-rename/api
{:data {:schemas :all},
:data-model {:schemas :all},
:details :yes,
:download {:native :limited, :schemas :limited}}]
[:dev.nocommit.data-permissions-rename/equal? false]]
[[:dev.nocommit.data-permissions-rename/data-perms
{:data-access :unrestricted,
:download-results :ten-thousand-rows,
:manage-database :yes,
:manage-table-metadata :yes,
:native-query-editing :yes}]
[:dev.nocommit.data-permissions-rename/data->api {:details :yes, :download {:schemas :limited}}]
[:dev.nocommit.data-permissions-rename/api
{:data {:native :write, :schemas :all},
:data-model {:schemas :all},
:details :yes,
:download {:native :limited, :schemas :limited}}]
[:dev.nocommit.data-permissions-rename/equal? false]]
[[:dev.nocommit.data-permissions-rename/data-perms
{:data-access :unrestricted,
:download-results :no,
:manage-database :yes,
:manage-table-metadata :yes,
:native-query-editing :yes}]
[:dev.nocommit.data-permissions-rename/data->api {:details :yes, :download {:schemas nil}}]
[:dev.nocommit.data-permissions-rename/api
{:data {:native :write, :schemas :all}, :data-model {:schemas :all}, :details :yes}]
[:dev.nocommit.data-permissions-rename/equal? false]]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment