Skip to content

Commit

Permalink
Add types for "/lib/xp/project"
Browse files Browse the repository at this point in the history
  • Loading branch information
tajakobsen committed Sep 10, 2020
1 parent 6a7e8bd commit 60f8ba4
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "enonic-types",
"sideEffects": false,
"version": "0.1.0-beta1",
"version": "0.1.0",
"description": "TypeScript types for Enonic XP",
"typings": "index.d.ts",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface EnonicLibraryMap {
"/lib/menu": import("./menu").MenuLibrary;
"/lib/xp/node": import("./node").NodeLibrary;
"/lib/xp/portal": import("./portal").PortalLibrary;
"/lib/xp/project": import("./project").ProjectLibrary;
"/lib/recaptcha": import("./recaptcha").RecaptchaLibrary;
"/lib/xp/repo": import("./repo").RepoLibrary;
"/lib/router": import("./router").RouterLib;
Expand Down
61 changes: 61 additions & 0 deletions src/project.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
export interface ProjectLibrary {
addPermissions(params: AddPermissionsParams): boolean;
create(params: CreateProjectParams): Project;
delete(params: DeleteProjectParams): boolean;
get(params: GetProjectParams): Project | null;
list(): ReadonlyArray<Project>;
modify(params: ModifyProjectParams): Project;
modifyReadAccess(params: ModifyReadAccessParams): ModifyReadAccessResult;
removePermissions(params: RemovePermissionsParams): boolean;
}

type ProjectRole = "owner" | "editor" | "author" | "contributor" | "viewer";

type ProjectPermissions = Record<ProjectRole, ReadonlyArray<string>>;

export interface ReadAccess {
readonly public: boolean;
}

export interface Project {
readonly id: string;
readonly displayName: string;
readonly description?: string;
readonly language?: string;
readonly permissions?: ProjectPermissions;
readonly readAccess: ReadAccess;
}

export type CreateProjectParams = Project;

export interface DeleteProjectParams {
readonly id: string;
}

export interface GetProjectParams {
readonly id: string;
}

export interface ModifyProjectParams {
readonly id: string;
readonly displayName: string;
readonly description?: string;
readonly language?: string;
}

export interface ModifyReadAccessParams {
readonly id: string;
readonly readAccess: ReadAccess;
}

export type ModifyReadAccessResult = ModifyReadAccessParams;

export interface AddPermissionsParams {
readonly id: string;
readonly permissions: ProjectPermissions;
}

export interface RemovePermissionsParams {
readonly id: string;
readonly permissions: ProjectPermissions;
}

0 comments on commit 60f8ba4

Please sign in to comment.