Last active
November 22, 2024 18:24
-
-
Save urbushey/cb093b57aa8f57e25cde316a6dd68091 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type GeneralCollaboratorType = "all" | "none"; | |
type SpecificCollaboratorType = "inclusion" | "exclusion"; | |
type NonAuthenticatedCollaborator = { | |
type: "anonymous"; | |
}; | |
type CollaboratorList = { | |
type: SpecificCollaboratorType, | |
company_ids: number[] | |
} | |
type GeneralCollaborator = { | |
type: GeneralCollaboratorType | |
} | |
type QueryCollaborator = CollaboratorList | GeneralCollaborator; // non-authenticated-users not allowed here | |
type ViewCollaborator = CollaboratorList | GeneralCollaborator | NonAuthenticatedCollaborator; // non-authenticated-users only allowed here | |
type QueryAccess = QueryCollaborator; | |
type ViewAccess = ViewCollaborator; | |
type CollaboratorConfig = { | |
query: QueryAccess; | |
view: ViewAccess; | |
} | |
// example type usage | |
const exampleConfig: CollaboratorConfig = { | |
query: { | |
type: "inclusion", | |
company_ids: [1, 2, 3] // Specific companies can query | |
}, | |
view: { | |
type: "anonymous" // Anyone, even unauthenticated users, can view | |
} | |
}; | |
const anotherConfig: CollaboratorConfig = { | |
query: { | |
type: "none" // No one can query | |
}, | |
view: { | |
type: "all" // All authenticated users can view | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment