From 2fa1e0ac76846fb6c5366507f1badd51a82c06a3 Mon Sep 17 00:00:00 2001 From: pjdotson Date: Thu, 26 Sep 2024 09:32:53 -0700 Subject: [PATCH] Update pnpm, delete users from console, refactor actions, and make default permission "ALLOW_ALL" --- client/ts/src/access/payload.ts | 8 +- client/ts/src/ranger/payload.ts | 8 +- console/src/link/link.tsx | 61 +++---- console/src/ontology/external.ts | 1 + console/src/permissions/migrations/v0.ts | 2 +- console/src/user/services/ontology.tsx | 60 ++++-- pnpm-lock.yaml | 222 +++++++++++------------ synnax/pkg/api/ranger.go | 56 ++++-- synnax/pkg/ranger/action.go | 10 +- synnax/pkg/ranger/alias.go | 11 +- 10 files changed, 238 insertions(+), 201 deletions(-) diff --git a/client/ts/src/access/payload.ts b/client/ts/src/access/payload.ts index 7c713daac3..4a5534747d 100644 --- a/client/ts/src/access/payload.ts +++ b/client/ts/src/access/payload.ts @@ -16,18 +16,12 @@ export const actionZ = z.union([ z.literal("copy"), z.literal("create"), z.literal("delete"), - z.literal("delete_alias"), - z.literal("delete_key_value"), - z.literal("get_key_value"), - z.literal("list_aliases"), z.literal("move_children"), z.literal("remove_children"), z.literal("remove_label"), z.literal("rename"), - z.literal("resolve_alias"), + z.literal("resolve"), z.literal("retrieve"), - z.literal("set_alias"), - z.literal("set_key_value"), z.literal("update"), ]); export type Action = z.infer; diff --git a/client/ts/src/ranger/payload.ts b/client/ts/src/ranger/payload.ts index 26f8f4db75..c9fd0c24b9 100644 --- a/client/ts/src/ranger/payload.ts +++ b/client/ts/src/ranger/payload.ts @@ -85,10 +85,4 @@ export const rangeOntologyID = (key: Key): ontology.ID => export const rangeAliasOntologyID = (key: Key): ontology.ID => new ontology.ID({ type: ALIAS_ONTOLOGY_TYPE, key: key }); -export const SET_KV_ACTION: access.Action = "set_key_value"; -export const GET_KV_ACTION: access.Action = "get_key_value"; -export const DELETE_KV_ACTION: access.Action = "delete_key_value"; -export const LIST_ALIASES_ACTION: access.Action = "list_aliases"; -export const SET_ALIAS_ACTION: access.Action = "set_alias"; -export const DELETE_ALIAS_ACTION: access.Action = "delete_alias"; -export const RESOLVE_ALIAS_ACTION: access.Action = "resolve_alias"; +export const RESOLVE_ALIAS_ACTION: access.Action = "resolve"; diff --git a/console/src/link/link.tsx b/console/src/link/link.tsx index a0e9975e31..21cbf98831 100644 --- a/console/src/link/link.tsx +++ b/console/src/link/link.tsx @@ -7,8 +7,8 @@ // License, use of this software will be governed by the Apache License, Version 2.0, // included in the file licenses/APL.txt. -import { Dispatch, UnknownAction } from "@reduxjs/toolkit"; -import { ontology, Synnax } from "@synnaxlabs/client"; +import { type Dispatch, type UnknownAction } from "@reduxjs/toolkit"; +import { type ontology, Synnax, user } from "@synnaxlabs/client"; import { Drift } from "@synnaxlabs/drift"; import { useSelectWindowKey } from "@synnaxlabs/drift/react"; import { Icon } from "@synnaxlabs/media"; @@ -20,11 +20,13 @@ import { useSyncedRef, } from "@synnaxlabs/pluto"; import { onOpenUrl } from "@tauri-apps/plugin-deep-link"; -import { ReactElement } from "react"; +import { type ReactElement } from "react"; import { useDispatch, useStore } from "react-redux"; import { Cluster } from "@/cluster"; import { Layout } from "@/layout"; +import { Permissions } from "@/permissions"; +import { type RootState } from "@/store"; export interface HandlerProps { addStatus: (status: Status.CrudeSpec) => void; @@ -44,6 +46,7 @@ export interface UseDeepProps { const openUrlErrorMessage = "Cannot open URL, URLs must be of the form synnax://cluster/ or synnax://cluster///"; +const scheme = "synnax://"; export const useDeep = ({ handlers }: UseDeepProps): void => { const client = PSynnax.use(); @@ -51,57 +54,43 @@ export const useDeep = ({ handlers }: UseDeepProps): void => { const addStatus = Status.useAggregator(); const dispatch = useDispatch(); const placer = Layout.usePlacer(); - const store = useStore(); + const store = useStore(); const windowKey = useSelectWindowKey() as string; - const addOpenUrlErrorStatus = () => { + const addOpenUrlErrorStatus = () => addStatus({ variant: "error", message: openUrlErrorMessage, }); - }; useAsyncEffect(async () => { const unlisten = await onOpenUrl(async (urls) => { dispatch(Drift.focusWindow({})); // Processing URL, making sure is has valid form - const scheme = "synnax://"; - if (urls.length === 0 || !urls[0].startsWith(scheme)) { - addOpenUrlErrorStatus(); - return; - } + if (urls.length === 0 || !urls[0].startsWith(scheme)) + return addOpenUrlErrorStatus(); const urlParts = urls[0].slice(scheme.length).split("/"); - if (urlParts.length !== 2 && urlParts.length !== 4) { - addOpenUrlErrorStatus(); - return; - } - if (urlParts[0] !== "cluster") { - addOpenUrlErrorStatus(); - return; - } + if ((urlParts.length !== 2 && urlParts.length !== 4) || urlParts[0] !== "cluster") + return addOpenUrlErrorStatus(); // Connecting to the cluster const clusterKey = urlParts[1]; - const connParams = Cluster.select( - store.getState() as Cluster.StoreState, - clusterKey, - )?.props; - const addClusterErrorStatus = () => { + const connParams = Cluster.select(store.getState(), clusterKey)?.props; + const addClusterErrorStatus = () => addStatus({ variant: "error", message: `Cannot open URL, Cluster with key ${clusterKey} not found`, }); - }; - if (connParams == null) { - addClusterErrorStatus(); - return; - } + if (connParams == null) return addClusterErrorStatus(); dispatch(Cluster.setActive(clusterKey)); clientRef.current = new Synnax(connParams); - if (clientRef.current == null) { - addClusterErrorStatus(); - return; - } + if (clientRef.current == null) return addClusterErrorStatus(); + const username = clientRef.current.props.username; + const user_ = await clientRef.current.user.retrieveByName(username); + const policies = await clientRef.current.access.policy.retrieveFor( + user.ontologyID(user_.key), + ); + dispatch(Permissions.set({ policies })); if (urlParts.length === 2) return; // Processing the resource part of URL @@ -147,14 +136,12 @@ export const useCopyToClipboard = (): ((props: CopyToClipboardProps) => void) => return ({ ontologyID, name, clusterKey }) => { let url = "synnax://cluster/"; const key = clusterKey ?? activeClusterKey; - if (key == null) { - addStatus({ + if (key == null) + return addStatus({ variant: "error", message: `Failed to copy link to ${name} to clipboard`, description: "No active cluster found", }); - return; - } url += key; if (ontologyID != undefined) url += `/${ontologyID.type}/${ontologyID.key}`; navigator.clipboard.writeText(url).then( diff --git a/console/src/ontology/external.ts b/console/src/ontology/external.ts index e4d39ec7bd..e0494acd4d 100644 --- a/console/src/ontology/external.ts +++ b/console/src/ontology/external.ts @@ -8,6 +8,7 @@ // included in the file licenses/APL.txt. export * from "@/ontology/ContextMenu"; +export * from "@/ontology/hooks"; export * from "@/ontology/service"; export * from "@/ontology/ServicesProvider"; export * from "@/ontology/Toolbar"; diff --git a/console/src/permissions/migrations/v0.ts b/console/src/permissions/migrations/v0.ts index 34e97b1980..a414cb195a 100644 --- a/console/src/permissions/migrations/v0.ts +++ b/console/src/permissions/migrations/v0.ts @@ -20,5 +20,5 @@ export type State = z.infer; export const ZERO_STATE: State = { version: "0.0.0", - policies: [], + policies: ALLOW_ALL, }; diff --git a/console/src/user/services/ontology.tsx b/console/src/user/services/ontology.tsx index 1efe62975e..7e53fe1cde 100644 --- a/console/src/user/services/ontology.tsx +++ b/console/src/user/services/ontology.tsx @@ -10,6 +10,8 @@ import { user } from "@synnaxlabs/client"; import { Icon } from "@synnaxlabs/media"; import { Menu as PMenu, Tree } from "@synnaxlabs/pluto"; +import { errors } from "@synnaxlabs/x"; +import { useMutation } from "@tanstack/react-query"; import { type ReactElement } from "react"; import { Menu } from "@/components/menu"; @@ -17,38 +19,68 @@ import { Ontology } from "@/ontology"; import { Permissions } from "@/permissions"; import { useSelectHasPermission } from "@/user/selectors"; -const useSetPermissions = +const useEditPermissions = (): ((props: Ontology.TreeContextMenuProps) => void) => ({ placeLayout, selection }) => placeLayout( Permissions.editLayout({ user: selection.resources[0].data as user.User }), ); +const useDelete = (): ((props: Ontology.TreeContextMenuProps) => void) => { + const confirm = Ontology.useConfirmDelete({ type: user.ONTOLOGY_TYPE }); + return useMutation({ + onMutate: async ({ state: { nodes, setNodes }, selection: { resources } }) => { + if (!(await confirm(resources))) throw errors.CANCELED; + const prevNodes = Tree.deepCopy(nodes); + setNodes([ + ...Tree.removeNode({ + tree: nodes, + keys: resources.map(({ id }) => id.toString()), + }), + ]); + return prevNodes; + }, + mutationFn: async ({ selection: { resources }, client }) => + await client.user.delete(resources.map(({ id }) => id.key)), + onError: (e, { addStatus, state: { setNodes } }, prevNodes) => { + if (prevNodes != null) setNodes(prevNodes); + if (errors.CANCELED.matches(e)) return; + addStatus({ + variant: "error", + message: "Failed to delete users.", + description: e.message, + }); + }, + }).mutate; +}; + const TreeContextMenu: Ontology.TreeContextMenu = (props): ReactElement => { const { client, selection: { nodes, resources }, } = props; - const setPermissions = useSetPermissions(); + const editPermissions = useEditPermissions(); + const handleDelete = useDelete(); const handleSelect = { - permissions: () => setPermissions(props), + permissions: () => editPermissions(props), rename: () => Tree.startRenaming(nodes[0].key), + delete: () => handleDelete(props), }; const singleResource = resources.length === 1; const isNotCurrentUser = resources[0].name !== client.props.username; - const canSetPermissions = Permissions.useSelectCanEditPolicies(); - const canEdit = useSelectHasPermission(); + const canEditPermissions = Permissions.useSelectCanEditPolicies(); + const canEditOrDelete = useSelectHasPermission(); return ( {singleResource && isNotCurrentUser && ( <> - {canSetPermissions && ( + {canEditPermissions && ( }> Edit Permissions )} - {canEdit && ( + {canEditOrDelete && ( }> Change Username @@ -56,6 +88,12 @@ const TreeContextMenu: Ontology.TreeContextMenu = (props): ReactElement => { )} + {canEditOrDelete && ( + <> + + + + )} ); @@ -66,17 +104,11 @@ const handleRename: Ontology.HandleTreeRename = { await client.user.changeUsername(id.key, name), }; -const allowRename: Ontology.AllowRename = (props): boolean => { - console.log("allowRename"); - console.log(props); - return true; -}; - export const ONTOLOGY_SERVICE: Ontology.Service = { type: user.ONTOLOGY_TYPE, icon: , hasChildren: true, - allowRename, + allowRename: () => true, onRename: handleRename, haulItems: () => [], canDrop: () => false, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 10fbc9a0a5..14344caff0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -31,7 +31,7 @@ importers: devDependencies: '@microsoft/api-extractor': specifier: ^7.47.9 - version: 7.47.9(@types/node@22.6.1) + version: 7.47.9(@types/node@22.7.2) prettier: specifier: 3.3.3 version: 3.3.3 @@ -71,7 +71,7 @@ importers: version: link:../../configs/vite '@vitest/coverage-v8': specifier: ^2.1.0 - version: 2.1.1(vitest@2.1.1(@types/node@22.6.1)(jsdom@25.0.0)) + version: 2.1.1(vitest@2.1.1(@types/node@22.7.2)(jsdom@25.0.0)) eslint-config-synnaxlabs: specifier: workspace:* version: link:../../configs/eslint @@ -80,10 +80,10 @@ importers: version: 5.6.2 vite: specifier: 5.4.4 - version: 5.4.4(@types/node@22.6.1) + version: 5.4.4(@types/node@22.7.2) vitest: specifier: ^2.1.0 - version: 2.1.1(@types/node@22.6.1)(jsdom@25.0.0) + version: 2.1.1(@types/node@22.7.2)(jsdom@25.0.0) client/ts: dependencies: @@ -184,13 +184,13 @@ importers: version: 5.6.2 vite: specifier: 5.4.4 - version: 5.4.4(@types/node@22.6.1) + version: 5.4.4(@types/node@22.7.2) vite-plugin-dts: specifier: 4.2.1 - version: 4.2.1(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2)(vite@5.4.4(@types/node@22.6.1)) + version: 4.2.1(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2)(vite@5.4.4(@types/node@22.7.2)) vite-tsconfig-paths: specifier: 5.0.1 - version: 5.0.1(typescript@5.6.2)(vite@5.4.4(@types/node@22.6.1)) + version: 5.0.1(typescript@5.6.2)(vite@5.4.4(@types/node@22.7.2)) console: dependencies: @@ -284,7 +284,7 @@ importers: version: 10.0.0 '@vitejs/plugin-react': specifier: ^4.3.1 - version: 4.3.1(vite@5.4.4(@types/node@22.6.1)) + version: 4.3.1(vite@5.4.4(@types/node@22.7.2)) eslint-config-synnaxlabs: specifier: workspace:* version: link:../configs/eslint @@ -296,25 +296,25 @@ importers: version: 5.6.2 vite: specifier: 5.4.4 - version: 5.4.4(@types/node@22.6.1) + version: 5.4.4(@types/node@22.7.2) vite-tsconfig-paths: specifier: 5.0.1 - version: 5.0.1(typescript@5.6.2)(vite@5.4.4(@types/node@22.6.1)) + version: 5.0.1(typescript@5.6.2)(vite@5.4.4(@types/node@22.7.2)) vitest: specifier: ^2.1.0 - version: 2.1.1(@types/node@22.6.1)(jsdom@25.0.0) + version: 2.1.1(@types/node@22.7.2)(jsdom@25.0.0) docs/site: dependencies: '@astrojs/mdx': specifier: ^3.1.4 - version: 3.1.4(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2)) + version: 3.1.4(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2)) '@astrojs/react': specifier: ^3.6.2 - version: 3.6.2(@types/react-dom@18.2.25)(@types/react@18.2.79)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(vite@5.4.4(@types/node@22.6.1)) + version: 3.6.2(@types/react-dom@18.2.25)(@types/react@18.2.79)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(vite@5.4.4(@types/node@22.7.2)) '@astrojs/vercel': specifier: ^7.8.0 - version: 7.8.0(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2))(react@18.2.0) + version: 7.8.0(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2))(react@18.2.0) '@synnaxlabs/client': specifier: workspace:* version: link:../../client/ts @@ -332,10 +332,10 @@ importers: version: 2019.7.3 astro: specifier: ^4.14.5 - version: 4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2) + version: 4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2) astro-embed: specifier: ^0.7.1 - version: 0.7.1(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2)) + version: 0.7.1(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2)) astro-seo: specifier: ^0.8.3 version: 0.8.3(prettier@3.3.3)(typescript@5.6.2) @@ -406,7 +406,7 @@ importers: version: 18.3.6 '@vitest/coverage-v8': specifier: ^2.1.0 - version: 2.1.1(vitest@2.1.1(@types/node@22.6.1)(jsdom@25.0.0)) + version: 2.1.1(vitest@2.1.1(@types/node@22.7.2)(jsdom@25.0.0)) electron: specifier: ^32.1.0 version: 32.1.0 @@ -430,10 +430,10 @@ importers: version: 5.6.2 vite: specifier: 5.4.4 - version: 5.4.4(@types/node@22.6.1) + version: 5.4.4(@types/node@22.7.2) vitest: specifier: ^2.1.0 - version: 2.1.1(@types/node@22.6.1)(jsdom@25.0.0) + version: 2.1.1(@types/node@22.7.2)(jsdom@25.0.0) drift/examples/tauri: dependencies: @@ -464,16 +464,16 @@ importers: version: 18.2.25 '@vitejs/plugin-react': specifier: ^4.3.1 - version: 4.3.1(vite@5.4.4(@types/node@22.6.1)) + version: 4.3.1(vite@5.4.4(@types/node@22.7.2)) typescript: specifier: ^5.6.2 version: 5.6.2 vite: specifier: 5.4.4 - version: 5.4.4(@types/node@22.6.1) + version: 5.4.4(@types/node@22.7.2) vite-tsconfig-paths: specifier: 5.0.1 - version: 5.0.1(typescript@5.6.2)(vite@5.4.4(@types/node@22.6.1)) + version: 5.0.1(typescript@5.6.2)(vite@5.4.4(@types/node@22.7.2)) freighter/ts: dependencies: @@ -650,10 +650,10 @@ importers: version: 0.0.11 '@vitejs/plugin-react': specifier: ^4.3.1 - version: 4.3.1(vite@5.4.4(@types/node@22.6.1)) + version: 4.3.1(vite@5.4.4(@types/node@22.7.2)) '@vitest/coverage-v8': specifier: ^2.1.0 - version: 2.1.1(vitest@2.1.1(@types/node@22.6.1)(jsdom@25.0.0)) + version: 2.1.1(vitest@2.1.1(@types/node@22.7.2)(jsdom@25.0.0)) eslint-config-synnaxlabs: specifier: workspace:* version: link:../configs/eslint @@ -671,10 +671,10 @@ importers: version: 5.6.2 vite: specifier: 5.4.4 - version: 5.4.4(@types/node@22.6.1) + version: 5.4.4(@types/node@22.7.2) vitest: specifier: ^2.1.0 - version: 2.1.1(@types/node@22.6.1)(jsdom@25.0.0) + version: 2.1.1(@types/node@22.7.2)(jsdom@25.0.0) pluto/examples: dependencies: @@ -702,7 +702,7 @@ importers: version: 7.11.0(eslint@9.10.0)(typescript@5.6.2) '@vitejs/plugin-react': specifier: ^4.3.1 - version: 4.3.1(vite@5.4.4(@types/node@22.6.1)) + version: 4.3.1(vite@5.4.4(@types/node@22.7.2)) eslint: specifier: ^9.10.0 version: 9.10.0 @@ -717,7 +717,7 @@ importers: version: 5.6.2 vite: specifier: 5.4.4 - version: 5.4.4(@types/node@22.6.1) + version: 5.4.4(@types/node@22.7.2) x/media: dependencies: @@ -2912,8 +2912,8 @@ packages: '@types/node@22.5.5': resolution: {integrity: sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA==} - '@types/node@22.6.1': - resolution: {integrity: sha512-V48tCfcKb/e6cVUigLAaJDAILdMP0fUW6BidkPK4GpGjXcfbnoHasCZDwz3N3yVt5we2RHm4XTQCpv0KJz9zqw==} + '@types/node@22.7.2': + resolution: {integrity: sha512-866lXSrpGpgyHBZUa2m9YNWqHDjjM0aBTJlNtYaGEw4rqY/dcD7deRVTbBBAJelfA7oaGDbNftXF/TL/A6RgoA==} '@types/offscreencanvas@2019.7.3': resolution: {integrity: sha512-ieXiYmgSRXUDeOntE1InxjWyvEelZGP63M+cGuquuRLuIKKT1osnkXjxev9B7d1nXSug5vpunx+gNlbVxMlC9A==} @@ -6725,15 +6725,15 @@ snapshots: '@jridgewell/gen-mapping': 0.3.5 '@jridgewell/trace-mapping': 0.3.25 - '@astro-community/astro-embed-integration@0.7.1(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2))': + '@astro-community/astro-embed-integration@0.7.1(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2))': dependencies: '@astro-community/astro-embed-link-preview': 0.2.0 - '@astro-community/astro-embed-twitter': 0.5.4(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2)) - '@astro-community/astro-embed-vimeo': 0.3.7(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2)) - '@astro-community/astro-embed-youtube': 0.5.2(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2)) + '@astro-community/astro-embed-twitter': 0.5.4(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2)) + '@astro-community/astro-embed-vimeo': 0.3.7(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2)) + '@astro-community/astro-embed-youtube': 0.5.2(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2)) '@types/unist': 2.0.10 - astro: 4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2) - astro-auto-import: 0.4.2(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2)) + astro: 4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2) + astro-auto-import: 0.4.2(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2)) unist-util-select: 4.0.3 '@astro-community/astro-embed-link-preview@0.1.0': @@ -6744,23 +6744,23 @@ snapshots: dependencies: '@astro-community/astro-embed-utils': 0.1.2 - '@astro-community/astro-embed-twitter@0.5.4(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2))': + '@astro-community/astro-embed-twitter@0.5.4(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2))': dependencies: '@astro-community/astro-embed-utils': 0.1.2 - astro: 4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2) + astro: 4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2) '@astro-community/astro-embed-utils@0.1.2': dependencies: linkedom: 0.14.26 - '@astro-community/astro-embed-vimeo@0.3.7(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2))': + '@astro-community/astro-embed-vimeo@0.3.7(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2))': dependencies: '@astro-community/astro-embed-utils': 0.1.2 - astro: 4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2) + astro: 4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2) - '@astro-community/astro-embed-youtube@0.5.2(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2))': + '@astro-community/astro-embed-youtube@0.5.2(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2))': dependencies: - astro: 4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2) + astro: 4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2) lite-youtube-embed: 0.3.2 '@astrojs/check@0.5.10(prettier@3.3.3)(typescript@5.6.2)': @@ -6827,12 +6827,12 @@ snapshots: transitivePeerDependencies: - supports-color - '@astrojs/mdx@3.1.4(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2))': + '@astrojs/mdx@3.1.4(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2))': dependencies: '@astrojs/markdown-remark': 5.2.0 '@mdx-js/mdx': 3.0.1 acorn: 8.12.1 - astro: 4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2) + astro: 4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2) es-module-lexer: 1.5.4 estree-util-visit: 2.0.0 gray-matter: 4.0.3 @@ -6851,11 +6851,11 @@ snapshots: dependencies: prismjs: 1.29.0 - '@astrojs/react@3.6.2(@types/react-dom@18.2.25)(@types/react@18.2.79)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(vite@5.4.4(@types/node@22.6.1))': + '@astrojs/react@3.6.2(@types/react-dom@18.2.25)(@types/react@18.2.79)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(vite@5.4.4(@types/node@22.7.2))': dependencies: '@types/react': 18.2.79 '@types/react-dom': 18.2.25 - '@vitejs/plugin-react': 4.3.1(vite@5.4.4(@types/node@22.6.1)) + '@vitejs/plugin-react': 4.3.1(vite@5.4.4(@types/node@22.7.2)) react: 18.2.0 react-dom: 18.2.0(react@18.2.0) ultrahtml: 1.5.3 @@ -6875,13 +6875,13 @@ snapshots: transitivePeerDependencies: - supports-color - '@astrojs/vercel@7.8.0(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2))(react@18.2.0)': + '@astrojs/vercel@7.8.0(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2))(react@18.2.0)': dependencies: '@astrojs/internal-helpers': 0.4.1 '@vercel/analytics': 1.3.1(react@18.2.0) '@vercel/edge': 1.1.2 '@vercel/nft': 0.27.3 - astro: 4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2) + astro: 4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2) esbuild: 0.21.5 fast-glob: 3.3.2 web-vitals: 3.5.2 @@ -7549,31 +7549,31 @@ snapshots: transitivePeerDependencies: - supports-color - '@microsoft/api-extractor-model@7.29.6(@types/node@22.6.1)': + '@microsoft/api-extractor-model@7.29.6(@types/node@22.7.2)': dependencies: '@microsoft/tsdoc': 0.15.0 '@microsoft/tsdoc-config': 0.17.0 - '@rushstack/node-core-library': 5.7.0(@types/node@22.6.1) + '@rushstack/node-core-library': 5.7.0(@types/node@22.7.2) transitivePeerDependencies: - '@types/node' - '@microsoft/api-extractor-model@7.29.8(@types/node@22.6.1)': + '@microsoft/api-extractor-model@7.29.8(@types/node@22.7.2)': dependencies: '@microsoft/tsdoc': 0.15.0 '@microsoft/tsdoc-config': 0.17.0 - '@rushstack/node-core-library': 5.9.0(@types/node@22.6.1) + '@rushstack/node-core-library': 5.9.0(@types/node@22.7.2) transitivePeerDependencies: - '@types/node' - '@microsoft/api-extractor@7.47.7(@types/node@22.6.1)': + '@microsoft/api-extractor@7.47.7(@types/node@22.7.2)': dependencies: - '@microsoft/api-extractor-model': 7.29.6(@types/node@22.6.1) + '@microsoft/api-extractor-model': 7.29.6(@types/node@22.7.2) '@microsoft/tsdoc': 0.15.0 '@microsoft/tsdoc-config': 0.17.0 - '@rushstack/node-core-library': 5.7.0(@types/node@22.6.1) + '@rushstack/node-core-library': 5.7.0(@types/node@22.7.2) '@rushstack/rig-package': 0.5.3 - '@rushstack/terminal': 0.14.0(@types/node@22.6.1) - '@rushstack/ts-command-line': 4.22.6(@types/node@22.6.1) + '@rushstack/terminal': 0.14.0(@types/node@22.7.2) + '@rushstack/ts-command-line': 4.22.6(@types/node@22.7.2) lodash: 4.17.21 minimatch: 3.0.8 resolve: 1.22.8 @@ -7583,15 +7583,15 @@ snapshots: transitivePeerDependencies: - '@types/node' - '@microsoft/api-extractor@7.47.9(@types/node@22.6.1)': + '@microsoft/api-extractor@7.47.9(@types/node@22.7.2)': dependencies: - '@microsoft/api-extractor-model': 7.29.8(@types/node@22.6.1) + '@microsoft/api-extractor-model': 7.29.8(@types/node@22.7.2) '@microsoft/tsdoc': 0.15.0 '@microsoft/tsdoc-config': 0.17.0 - '@rushstack/node-core-library': 5.9.0(@types/node@22.6.1) + '@rushstack/node-core-library': 5.9.0(@types/node@22.7.2) '@rushstack/rig-package': 0.5.3 - '@rushstack/terminal': 0.14.2(@types/node@22.6.1) - '@rushstack/ts-command-line': 4.22.8(@types/node@22.6.1) + '@rushstack/terminal': 0.14.2(@types/node@22.7.2) + '@rushstack/ts-command-line': 4.22.8(@types/node@22.7.2) lodash: 4.17.21 minimatch: 3.0.8 resolve: 1.22.8 @@ -8681,7 +8681,7 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.20.0': optional: true - '@rushstack/node-core-library@5.7.0(@types/node@22.6.1)': + '@rushstack/node-core-library@5.7.0(@types/node@22.7.2)': dependencies: ajv: 8.13.0 ajv-draft-04: 1.0.0(ajv@8.13.0) @@ -8692,9 +8692,9 @@ snapshots: resolve: 1.22.8 semver: 7.5.4 optionalDependencies: - '@types/node': 22.6.1 + '@types/node': 22.7.2 - '@rushstack/node-core-library@5.9.0(@types/node@22.6.1)': + '@rushstack/node-core-library@5.9.0(@types/node@22.7.2)': dependencies: ajv: 8.13.0 ajv-draft-04: 1.0.0(ajv@8.13.0) @@ -8705,39 +8705,39 @@ snapshots: resolve: 1.22.8 semver: 7.5.4 optionalDependencies: - '@types/node': 22.6.1 + '@types/node': 22.7.2 '@rushstack/rig-package@0.5.3': dependencies: resolve: 1.22.8 strip-json-comments: 3.1.1 - '@rushstack/terminal@0.14.0(@types/node@22.6.1)': + '@rushstack/terminal@0.14.0(@types/node@22.7.2)': dependencies: - '@rushstack/node-core-library': 5.7.0(@types/node@22.6.1) + '@rushstack/node-core-library': 5.7.0(@types/node@22.7.2) supports-color: 8.1.1 optionalDependencies: - '@types/node': 22.6.1 + '@types/node': 22.7.2 - '@rushstack/terminal@0.14.2(@types/node@22.6.1)': + '@rushstack/terminal@0.14.2(@types/node@22.7.2)': dependencies: - '@rushstack/node-core-library': 5.9.0(@types/node@22.6.1) + '@rushstack/node-core-library': 5.9.0(@types/node@22.7.2) supports-color: 8.1.1 optionalDependencies: - '@types/node': 22.6.1 + '@types/node': 22.7.2 - '@rushstack/ts-command-line@4.22.6(@types/node@22.6.1)': + '@rushstack/ts-command-line@4.22.6(@types/node@22.7.2)': dependencies: - '@rushstack/terminal': 0.14.0(@types/node@22.6.1) + '@rushstack/terminal': 0.14.0(@types/node@22.7.2) '@types/argparse': 1.0.38 argparse: 1.0.10 string-argv: 0.3.2 transitivePeerDependencies: - '@types/node' - '@rushstack/ts-command-line@4.22.8(@types/node@22.6.1)': + '@rushstack/ts-command-line@4.22.8(@types/node@22.7.2)': dependencies: - '@rushstack/terminal': 0.14.2(@types/node@22.6.1) + '@rushstack/terminal': 0.14.2(@types/node@22.7.2) '@types/argparse': 1.0.38 argparse: 1.0.10 string-argv: 0.3.2 @@ -9166,7 +9166,7 @@ snapshots: '@types/ioredis@4.28.10': dependencies: - '@types/node': 22.6.1 + '@types/node': 22.7.2 '@types/keygrip@1.0.6': {} @@ -9233,7 +9233,7 @@ snapshots: dependencies: undici-types: 6.19.8 - '@types/node@22.6.1': + '@types/node@22.7.2': dependencies: undici-types: 6.19.8 @@ -9488,14 +9488,14 @@ snapshots: transitivePeerDependencies: - supports-color - '@vitejs/plugin-react@4.3.1(vite@5.4.4(@types/node@22.6.1))': + '@vitejs/plugin-react@4.3.1(vite@5.4.4(@types/node@22.7.2))': dependencies: '@babel/core': 7.24.7 '@babel/plugin-transform-react-jsx-self': 7.24.7(@babel/core@7.24.7) '@babel/plugin-transform-react-jsx-source': 7.24.7(@babel/core@7.24.7) '@types/babel__core': 7.20.5 react-refresh: 0.14.2 - vite: 5.4.4(@types/node@22.6.1) + vite: 5.4.4(@types/node@22.7.2) transitivePeerDependencies: - supports-color @@ -9535,7 +9535,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@vitest/coverage-v8@2.1.1(vitest@2.1.1(@types/node@22.6.1)(jsdom@25.0.0))': + '@vitest/coverage-v8@2.1.1(vitest@2.1.1(@types/node@22.7.2)(jsdom@25.0.0))': dependencies: '@ampproject/remapping': 2.3.0 '@bcoe/v8-coverage': 0.2.3 @@ -9549,7 +9549,7 @@ snapshots: std-env: 3.7.0 test-exclude: 7.0.1 tinyrainbow: 1.2.0 - vitest: 2.1.1(@types/node@22.6.1)(jsdom@25.0.0) + vitest: 2.1.1(@types/node@22.7.2)(jsdom@25.0.0) transitivePeerDependencies: - supports-color @@ -9576,13 +9576,13 @@ snapshots: optionalDependencies: vite: 5.4.4(@types/node@22.5.5) - '@vitest/mocker@2.1.1(@vitest/spy@2.1.1)(vite@5.4.4(@types/node@22.6.1))': + '@vitest/mocker@2.1.1(@vitest/spy@2.1.1)(vite@5.4.4(@types/node@22.7.2))': dependencies: '@vitest/spy': 2.1.1 estree-walker: 3.0.3 magic-string: 0.30.11 optionalDependencies: - vite: 5.4.4(@types/node@22.6.1) + vite: 5.4.4(@types/node@22.7.2) '@vitest/pretty-format@2.1.1': dependencies: @@ -9913,20 +9913,20 @@ snapshots: astring@1.8.6: {} - astro-auto-import@0.4.2(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2)): + astro-auto-import@0.4.2(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2)): dependencies: '@types/node': 18.19.44 acorn: 8.12.0 - astro: 4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2) + astro: 4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2) - astro-embed@0.7.1(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2)): + astro-embed@0.7.1(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2)): dependencies: - '@astro-community/astro-embed-integration': 0.7.1(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2)) + '@astro-community/astro-embed-integration': 0.7.1(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2)) '@astro-community/astro-embed-link-preview': 0.1.0 - '@astro-community/astro-embed-twitter': 0.5.4(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2)) - '@astro-community/astro-embed-vimeo': 0.3.7(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2)) - '@astro-community/astro-embed-youtube': 0.5.2(astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2)) - astro: 4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2) + '@astro-community/astro-embed-twitter': 0.5.4(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2)) + '@astro-community/astro-embed-vimeo': 0.3.7(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2)) + '@astro-community/astro-embed-youtube': 0.5.2(astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2)) + astro: 4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2) astro-seo@0.8.3(prettier@3.3.3)(typescript@5.6.2): dependencies: @@ -9936,7 +9936,7 @@ snapshots: - prettier-plugin-astro - typescript - astro@4.14.5(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2): + astro@4.14.5(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2): dependencies: '@astrojs/compiler': 2.10.3 '@astrojs/internal-helpers': 0.4.1 @@ -9997,8 +9997,8 @@ snapshots: tsconfck: 3.1.1(typescript@5.6.2) unist-util-visit: 5.0.0 vfile: 6.0.2 - vite: 5.4.4(@types/node@22.6.1) - vitefu: 0.2.5(vite@5.4.4(@types/node@22.6.1)) + vite: 5.4.4(@types/node@22.7.2) + vitefu: 0.2.5(vite@5.4.4(@types/node@22.7.2)) which-pm: 3.0.0 xxhash-wasm: 1.0.2 yargs-parser: 21.1.1 @@ -13628,12 +13628,12 @@ snapshots: - supports-color - terser - vite-node@2.1.1(@types/node@22.6.1): + vite-node@2.1.1(@types/node@22.7.2): dependencies: cac: 6.7.14 debug: 4.3.6 pathe: 1.1.2 - vite: 5.4.4(@types/node@22.6.1) + vite: 5.4.4(@types/node@22.7.2) transitivePeerDependencies: - '@types/node' - less @@ -13645,9 +13645,9 @@ snapshots: - supports-color - terser - vite-plugin-dts@4.2.1(@types/node@22.6.1)(rollup@4.20.0)(typescript@5.6.2)(vite@5.4.4(@types/node@22.6.1)): + vite-plugin-dts@4.2.1(@types/node@22.7.2)(rollup@4.20.0)(typescript@5.6.2)(vite@5.4.4(@types/node@22.7.2)): dependencies: - '@microsoft/api-extractor': 7.47.7(@types/node@22.6.1) + '@microsoft/api-extractor': 7.47.7(@types/node@22.7.2) '@rollup/pluginutils': 5.1.0(rollup@4.20.0) '@volar/typescript': 2.4.5 '@vue/language-core': 2.1.6(typescript@5.6.2) @@ -13658,19 +13658,19 @@ snapshots: magic-string: 0.30.11 typescript: 5.6.2 optionalDependencies: - vite: 5.4.4(@types/node@22.6.1) + vite: 5.4.4(@types/node@22.7.2) transitivePeerDependencies: - '@types/node' - rollup - supports-color - vite-tsconfig-paths@5.0.1(typescript@5.6.2)(vite@5.4.4(@types/node@22.6.1)): + vite-tsconfig-paths@5.0.1(typescript@5.6.2)(vite@5.4.4(@types/node@22.7.2)): dependencies: debug: 4.3.6 globrex: 0.1.2 tsconfck: 3.1.1(typescript@5.6.2) optionalDependencies: - vite: 5.4.4(@types/node@22.6.1) + vite: 5.4.4(@types/node@22.7.2) transitivePeerDependencies: - supports-color - typescript @@ -13693,18 +13693,18 @@ snapshots: '@types/node': 22.5.5 fsevents: 2.3.3 - vite@5.4.4(@types/node@22.6.1): + vite@5.4.4(@types/node@22.7.2): dependencies: esbuild: 0.21.5 postcss: 8.4.47 rollup: 4.20.0 optionalDependencies: - '@types/node': 22.6.1 + '@types/node': 22.7.2 fsevents: 2.3.3 - vitefu@0.2.5(vite@5.4.4(@types/node@22.6.1)): + vitefu@0.2.5(vite@5.4.4(@types/node@22.7.2)): optionalDependencies: - vite: 5.4.4(@types/node@22.6.1) + vite: 5.4.4(@types/node@22.7.2) vitest@2.1.1(@types/node@20.14.9)(jsdom@25.0.0): dependencies: @@ -13776,10 +13776,10 @@ snapshots: - supports-color - terser - vitest@2.1.1(@types/node@22.6.1)(jsdom@25.0.0): + vitest@2.1.1(@types/node@22.7.2)(jsdom@25.0.0): dependencies: '@vitest/expect': 2.1.1 - '@vitest/mocker': 2.1.1(@vitest/spy@2.1.1)(vite@5.4.4(@types/node@22.6.1)) + '@vitest/mocker': 2.1.1(@vitest/spy@2.1.1)(vite@5.4.4(@types/node@22.7.2)) '@vitest/pretty-format': 2.1.1 '@vitest/runner': 2.1.1 '@vitest/snapshot': 2.1.1 @@ -13794,11 +13794,11 @@ snapshots: tinyexec: 0.3.0 tinypool: 1.0.0 tinyrainbow: 1.2.0 - vite: 5.4.4(@types/node@22.6.1) - vite-node: 2.1.1(@types/node@22.6.1) + vite: 5.4.4(@types/node@22.7.2) + vite-node: 2.1.1(@types/node@22.7.2) why-is-node-running: 2.3.0 optionalDependencies: - '@types/node': 22.6.1 + '@types/node': 22.7.2 jsdom: 25.0.0 transitivePeerDependencies: - less diff --git a/synnax/pkg/api/ranger.go b/synnax/pkg/api/ranger.go index bccebfe523..880743887e 100644 --- a/synnax/pkg/api/ranger.go +++ b/synnax/pkg/api/ranger.go @@ -184,7 +184,7 @@ func (s *RangeService) KVGet(ctx context.Context, req RangeKVGetRequest) (res Ra } if err = s.access.Enforce(ctx, access.Request{ Subject: getSubject(ctx), - Action: ranger.GetKVAction, + Action: action.Retrieve, Objects: []ontology.ID{ranger.OntologyID(req.Range)}, }); err != nil { return RangeKVGetResponse{}, err @@ -211,7 +211,7 @@ type RangeKVSetRequest struct { func (s *RangeService) KVSet(ctx context.Context, req RangeKVSetRequest) (res types.Nil, _ error) { if err := s.access.Enforce(ctx, access.Request{ Subject: getSubject(ctx), - Action: ranger.SetKVAction, + Action: action.Update, Objects: []ontology.ID{ranger.OntologyID(req.Range)}, }); err != nil { return res, err @@ -236,7 +236,7 @@ type RangeKVDeleteRequest struct { func (s *RangeService) KVDelete(ctx context.Context, req RangeKVDeleteRequest) (res types.Nil, _ error) { if err := s.access.Enforce(ctx, access.Request{ Subject: getSubject(ctx), - Action: ranger.DeleteKVAction, + Action: action.Update, Objects: []ontology.ID{ranger.OntologyID(req.Range)}, }); err != nil { return res, err @@ -264,10 +264,14 @@ type RangeAliasSetRequest struct { } func (s *RangeService) AliasSet(ctx context.Context, req RangeAliasSetRequest) (res types.Nil, _ error) { + keys := make([]channel.Key, 0, len(req.Aliases)) + for k := range req.Aliases { + keys = append(keys, k) + } if err := s.access.Enforce(ctx, access.Request{ Subject: getSubject(ctx), - Action: ranger.SetAliasAction, - Objects: []ontology.ID{ranger.OntologyID(req.Range)}, + Action: action.Create, + Objects: ranger.AliasOntologyIDs(req.Range, keys), }); err != nil { return res, err } @@ -314,6 +318,7 @@ func (s *RangeService) AliasResolve(ctx context.Context, req RangeAliasResolveRe return res, err } aliases := make(map[string]channel.Key, len(req.Aliases)) + for _, alias := range req.Aliases { ch, err := r.ResolveAlias(ctx, alias) if err != nil && !errors.Is(err, query.NotFound) { @@ -323,6 +328,20 @@ func (s *RangeService) AliasResolve(ctx context.Context, req RangeAliasResolveRe aliases[alias] = ch } } + + keys := make([]channel.Key, 0, len(aliases)) + for a := range aliases { + keys = append(keys, aliases[a]) + } + + if err := s.access.Enforce(ctx, access.Request{ + Subject: getSubject(ctx), + Action: ranger.ResolveAliasAction, + Objects: ranger.AliasOntologyIDs(req.Range, keys), + }); err != nil { + return res, err + } + return RangeAliasResolveResponse{Aliases: aliases}, nil } @@ -334,8 +353,8 @@ type RangeAliasDeleteRequest struct { func (s *RangeService) AliasDelete(ctx context.Context, req RangeAliasDeleteRequest) (res types.Nil, _ error) { if err := s.access.Enforce(ctx, access.Request{ Subject: getSubject(ctx), - Action: ranger.DeleteAliasAction, - Objects: []ontology.ID{ranger.OntologyID(req.Range)}, + Action: action.Delete, + Objects: ranger.AliasOntologyIDs(req.Range, req.Channels), }); err != nil { return res, err } @@ -366,13 +385,6 @@ type ( ) func (s *RangeService) AliasList(ctx context.Context, req RangeAliasListRequest) (res RangeAliasListResponse, _ error) { - if err := s.access.Enforce(ctx, access.Request{ - Subject: getSubject(ctx), - Action: ranger.ListAliasesAction, - Objects: []ontology.ID{ranger.OntologyID(req.Range)}, - }); err != nil { - return res, err - } var r ranger.Range if err := s.internal.NewRetrieve().Entry(&r). WhereKeys(req.Range). @@ -380,5 +392,21 @@ func (s *RangeService) AliasList(ctx context.Context, req RangeAliasListRequest) return res, err } aliases, err := r.ListAliases(ctx) + if err != nil { + return res, err + } + + keys := make([]channel.Key, 0, len(aliases)) + for k := range aliases { + keys = append(keys, k) + } + if err := s.access.Enforce(ctx, access.Request{ + Subject: getSubject(ctx), + Action: action.Retrieve, + Objects: ranger.AliasOntologyIDs(req.Range, keys), + }); err != nil { + return res, err + } + return RangeAliasListResponse{Aliases: aliases}, err } diff --git a/synnax/pkg/ranger/action.go b/synnax/pkg/ranger/action.go index 10a41c589e..27eb72e52a 100644 --- a/synnax/pkg/ranger/action.go +++ b/synnax/pkg/ranger/action.go @@ -11,12 +11,4 @@ package ranger import "github.com/synnaxlabs/synnax/pkg/access/action" -const ( - SetKVAction action.Action = "set_key_value" - GetKVAction action.Action = "get_key_value" - DeleteKVAction action.Action = "delete_key_value" - SetAliasAction action.Action = "set_alias" - ResolveAliasAction action.Action = "resolve_alias" - ListAliasesAction action.Action = "list_aliases" - DeleteAliasAction action.Action = "delete_alias" -) +const ResolveAliasAction action.Action = "resolve" diff --git a/synnax/pkg/ranger/alias.go b/synnax/pkg/ranger/alias.go index eee402fdb6..71a3a83089 100644 --- a/synnax/pkg/ranger/alias.go +++ b/synnax/pkg/ranger/alias.go @@ -12,6 +12,8 @@ package ranger import ( "context" "fmt" + "strings" + "github.com/google/uuid" "github.com/synnaxlabs/synnax/pkg/distribution/channel" "github.com/synnaxlabs/synnax/pkg/distribution/ontology" @@ -21,7 +23,6 @@ import ( "github.com/synnaxlabs/x/gorp" "github.com/synnaxlabs/x/iter" "github.com/synnaxlabs/x/observe" - "strings" ) const aliasKeySeparator = "---" @@ -69,6 +70,14 @@ func AliasOntologyID(r uuid.UUID, c channel.Key) ontology.ID { return ontology.ID{Type: aliasOntologyType, Key: aliasKey(r, c)} } +func AliasOntologyIDs(r uuid.UUID, chs []channel.Key) []ontology.ID { + ids := make([]ontology.ID, 0, len(chs)) + for _, ch := range chs { + ids = append(ids, AliasOntologyID(r, ch)) + } + return ids +} + var _aliasSchema = &ontology.Schema{ Type: aliasOntologyType, Fields: map[string]schema.Field{