@equinor/fusion
Advanced tools
Comparing version 2.3.1 to 2.3.2
@@ -5,33 +5,36 @@ import BaseApiClient from './BaseApiClient'; | ||
import Position from './models/org/Position'; | ||
import { HttpResponse } from '../HttpClient'; | ||
export default class OrgClient extends BaseApiClient { | ||
getProjectsAsync(): Promise<import("../HttpClient").HttpResponse<OrgProject[]>>; | ||
getProjectAsync(projectId: string): Promise<import("../HttpClient").HttpResponse<OrgProject>>; | ||
searchProjectsAsync(query: string, apiVersion?: string): Promise<import("../HttpClient").HttpResponse<OrgProject[]>>; | ||
newProjectAsync(newProject: CreateOrgProject): Promise<import("../HttpClient").HttpResponse<OrgProject>>; | ||
getPositionsAsync(projectId: string, expandProperties?: string[]): Promise<import("../HttpClient").HttpResponse<Position[]>>; | ||
getPositionAsync(projectId: string, positionId: string): Promise<import("../HttpClient").HttpResponse<Position>>; | ||
updatePositionAsync(projectId: string, position: Position, edit?: boolean): Promise<import("../HttpClient").HttpResponse<Position>>; | ||
updatePositionPropertyAsync(projectId: string, positionId: string, positionProperties: Partial<Position>, edit?: boolean): Promise<import("../HttpClient").HttpResponse<Position>>; | ||
getProjectsAsync(): Promise<HttpResponse<OrgProject[]>>; | ||
getProjectAsync(projectId: string, snapshotId?: string): Promise<HttpResponse<OrgProject>>; | ||
searchProjectsAsync(query: string, apiVersion?: string): Promise<HttpResponse<OrgProject[]>>; | ||
newProjectAsync(newProject: CreateOrgProject): Promise<HttpResponse<OrgProject>>; | ||
getPositionsAsync(projectId: string, expandProperties?: string[], snapshotId?: string): Promise<HttpResponse<Position[]>>; | ||
getPositionAsync(projectId: string, positionId: string, snapshotId?: string): Promise<HttpResponse<Position>>; | ||
updatePositionAsync(projectId: string, position: Position, edit?: boolean): Promise<HttpResponse<Position>>; | ||
updatePositionPropertyAsync(projectId: string, positionId: string, positionProperties: Partial<Position>, edit?: boolean): Promise<HttpResponse<Position>>; | ||
updateInstancePropertyAsync(projectId: string, positionId: string, instanceId: string, instanceProperties: Partial<PositionInstance> & { | ||
id: string; | ||
}, edit?: boolean): Promise<import("../HttpClient").HttpResponse<PositionInstance>>; | ||
publishAsync(projectId: string, draftId: string, apiVersion?: string): Promise<import("../HttpClient").HttpResponse<PublishDetails>>; | ||
deleteDraftAsync(projectId: string, draftId: string, apiVersion?: string): Promise<import("../HttpClient").HttpResponse<void>>; | ||
getPublishStatusAsync(draftId: string, apiVersion?: string): Promise<import("../HttpClient").HttpResponse<PublishDetails>>; | ||
getPositionReportPathAsync(projectId: string, positionId: string, date: string): Promise<import("../HttpClient").HttpResponse<PositionReportPath>>; | ||
getRoleDescriptionAsync(projectId: string, positionId: string): Promise<import("../HttpClient").HttpResponse<string>>; | ||
getBasePositionRoleDescriptionAsync(basePositionId: string): Promise<import("../HttpClient").HttpResponse<string>>; | ||
getRoleDescriptionV2Async(projectId: string, positionId: string): Promise<import("../HttpClient").HttpResponse<RoleDescription>>; | ||
updatePersonalTaskDescriptionAsync(projectId: string, azureUniqueId: string, description: string): Promise<import("../HttpClient").HttpResponse<string>>; | ||
}, edit?: boolean): Promise<HttpResponse<PositionInstance>>; | ||
publishAsync(projectId: string, draftId: string, apiVersion?: string): Promise<HttpResponse<PublishDetails>>; | ||
deleteDraftAsync(projectId: string, draftId: string, apiVersion?: string): Promise<HttpResponse<void>>; | ||
getPublishStatusAsync(draftId: string, apiVersion?: string): Promise<HttpResponse<PublishDetails>>; | ||
getPositionReportPathAsync(projectId: string, positionId: string, date: string, snapshotId?: string): Promise<HttpResponse<PositionReportPath>>; | ||
getRoleDescriptionAsync(projectId: string, positionId: string): Promise<HttpResponse<string>>; | ||
getBasePositionRoleDescriptionAsync(basePositionId: string): Promise<HttpResponse<string>>; | ||
getRoleDescriptionV2Async(projectId: string, positionId: string, snapshotId?: string): Promise<HttpResponse<RoleDescription>>; | ||
updatePersonalTaskDescriptionAsync(projectId: string, azureUniqueId: string, description: string): Promise<HttpResponse<string>>; | ||
canEditPersonalTaskDescriptionAsync(projectId: string, azureUniqueId: string): Promise<boolean>; | ||
getDisciplineNetworkAsync(projectId: string, discipline: string): Promise<import("../HttpClient").HttpResponse<Position[]>>; | ||
getDisciplineNetworkAsync(projectId: string, discipline: string): Promise<HttpResponse<Position[]>>; | ||
canEditPosition(projectId: string, positionId: string): Promise<boolean>; | ||
getDisciplines(): Promise<false | string[]>; | ||
getContractsAsync(projectId: string): Promise<import("../HttpClient").HttpResponse<Contract[]>>; | ||
getContractPositionsAsync(projectId: string, contractId: string): Promise<import("../HttpClient").HttpResponse<Position[]>>; | ||
getSnapshotsAsync(projectId: string): Promise<import("../HttpClient").HttpResponse<OrgSnapshot[]>>; | ||
getSnapshotAsync(projectId: string, snapshotId: string): Promise<import("../HttpClient").HttpResponse<OrgSnapshot>>; | ||
createSnapshotAsync(projectId: string, snapshotRequest: CreateSnapshotRequest): Promise<import("../HttpClient").HttpResponse<OrgSnapshot>>; | ||
approveSnapshotAsync(projectId: string, snapshotId: string, approvePayload: ApproveSnapshotRequest): Promise<import("../HttpClient").HttpResponse<OrgSnapshot>>; | ||
getContractsAsync(projectId: string): Promise<HttpResponse<Contract[]>>; | ||
getContractPositionsAsync(projectId: string, contractId: string): Promise<HttpResponse<Position[]>>; | ||
canReadSnapshotsAsync(projectId: string): Promise<boolean>; | ||
getSnapshotsAsync(projectId: string): Promise<HttpResponse<OrgSnapshot[]>>; | ||
getSnapshotAsync(projectId: string, snapshotId: string): Promise<HttpResponse<OrgSnapshot>>; | ||
createSnapshotAsync(projectId: string, snapshotRequest: CreateSnapshotRequest): Promise<HttpResponse<OrgSnapshot>>; | ||
canApproveSnapshotAsync(projectId: string, snapshotId: string): Promise<boolean>; | ||
approveSnapshotAsync(projectId: string, snapshotId: string, approvePayload: ApproveSnapshotRequest): Promise<HttpResponse<OrgSnapshot>>; | ||
protected getBaseUrl(): string; | ||
} |
@@ -7,4 +7,5 @@ import BaseApiClient from './BaseApiClient'; | ||
} | ||
async getProjectAsync(projectId) { | ||
const url = this.resourceCollections.org.project(projectId); | ||
async getProjectAsync(projectId, snapshotId) { | ||
const { project, snapshotProject } = this.resourceCollections.org; | ||
const url = snapshotId ? snapshotProject(snapshotId) : project(projectId); | ||
return this.httpClient.getAsync(url, { | ||
@@ -30,4 +31,7 @@ headers: { | ||
} | ||
async getPositionsAsync(projectId, expandProperties) { | ||
const url = this.resourceCollections.org.positions(projectId, expandProperties); | ||
async getPositionsAsync(projectId, expandProperties, snapshotId) { | ||
const { positions, snapshotPositions } = this.resourceCollections.org; | ||
const url = snapshotId | ||
? snapshotPositions(snapshotId, expandProperties) | ||
: positions(projectId, expandProperties); | ||
return this.httpClient.getAsync(url, { | ||
@@ -39,4 +43,7 @@ headers: { | ||
} | ||
async getPositionAsync(projectId, positionId) { | ||
const url = this.resourceCollections.org.position(projectId, positionId); | ||
async getPositionAsync(projectId, positionId, snapshotId) { | ||
const { position, snapshotPosition } = this.resourceCollections.org; | ||
const url = snapshotId | ||
? snapshotPosition(snapshotId, positionId) | ||
: position(projectId, positionId); | ||
return this.httpClient.getAsync(url, { | ||
@@ -105,4 +112,7 @@ headers: { | ||
} | ||
async getPositionReportPathAsync(projectId, positionId, date) { | ||
const url = this.resourceCollections.org.reportsTo(projectId, positionId, date); | ||
async getPositionReportPathAsync(projectId, positionId, date, snapshotId) { | ||
const { reportsTo, snapshotReportsTo } = this.resourceCollections.org; | ||
const url = snapshotId | ||
? snapshotReportsTo(projectId, positionId, date) | ||
: reportsTo(projectId, positionId, date); | ||
return this.httpClient.getAsync(url, { | ||
@@ -126,4 +136,7 @@ headers: { | ||
} | ||
async getRoleDescriptionV2Async(projectId, positionId) { | ||
const url = this.resourceCollections.org.roleDescriptionV2(projectId, positionId); | ||
async getRoleDescriptionV2Async(projectId, positionId, snapshotId) { | ||
const { roleDescriptionV2, snapshotRoleDescription } = this.resourceCollections.org; | ||
const url = snapshotId | ||
? snapshotRoleDescription(snapshotId, positionId) | ||
: roleDescriptionV2(projectId, positionId); | ||
return this.httpClient.getAsync(url, { | ||
@@ -219,2 +232,20 @@ headers: { | ||
} | ||
async canReadSnapshotsAsync(projectId) { | ||
const url = this.resourceCollections.org.snapshots(projectId); | ||
try { | ||
const response = await this.httpClient.optionsAsync(url, { | ||
headers: { | ||
'api-version': '2.0', | ||
}, | ||
}, () => Promise.resolve()); | ||
const allowHeader = response.headers.get('Allow'); | ||
if (allowHeader !== null && allowHeader.indexOf('GET') !== -1) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
catch (e) { | ||
return false; | ||
} | ||
} | ||
async getSnapshotsAsync(projectId) { | ||
@@ -232,2 +263,20 @@ const url = this.resourceCollections.org.snapshots(projectId); | ||
} | ||
async canApproveSnapshotAsync(projectId, snapshotId) { | ||
const url = this.resourceCollections.org.approveSnapshot(projectId, snapshotId); | ||
try { | ||
const response = await this.httpClient.optionsAsync(url, { | ||
headers: { | ||
'api-version': '2.0', | ||
}, | ||
}, () => Promise.resolve()); | ||
const allowHeader = response.headers.get('Allow'); | ||
if (allowHeader !== null && allowHeader.indexOf('PUT') !== -1) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
catch (e) { | ||
return false; | ||
} | ||
} | ||
async approveSnapshotAsync(projectId, snapshotId, approvePayload) { | ||
@@ -234,0 +283,0 @@ const url = this.resourceCollections.org.approveSnapshot(projectId, snapshotId); |
@@ -26,2 +26,8 @@ import BaseResourceCollection from './BaseResourceCollection'; | ||
approveSnapshot(projectId: string, snapshotId: string): string; | ||
snapshotBase(snapshotId: string): string; | ||
snapshotProject(snapshotId: string): string; | ||
snapshotPositions(snapshotId: string, expandProperties?: string[]): string; | ||
snapshotPosition(snapshotId: string, positionId: string): string; | ||
snapshotRoleDescription(snapshotId: string, positionId: string): string; | ||
snapshotReportsTo(snapshotId: string, positionId: string, date: string): string; | ||
} |
@@ -91,2 +91,26 @@ import BaseResourceCollection from './BaseResourceCollection'; | ||
} | ||
snapshotBase(snapshotId) { | ||
return combineUrls(this.getBaseUrl(), 'snapshots', snapshotId); | ||
} | ||
snapshotProject(snapshotId) { | ||
return combineUrls(this.snapshotBase(snapshotId), 'project'); | ||
} | ||
snapshotPositions(snapshotId, expandProperties) { | ||
const url = combineUrls(this.snapshotBase(snapshotId), 'positions'); | ||
if (!expandProperties || !expandProperties.length) { | ||
return url; | ||
} | ||
const expand = `?$expand=${expandProperties.join(',')}`; | ||
return `${url}${expand}`; | ||
} | ||
snapshotPosition(snapshotId, positionId) { | ||
return combineUrls(this.snapshotPositions(snapshotId), positionId); | ||
} | ||
snapshotRoleDescription(snapshotId, positionId) { | ||
return combineUrls(this.snapshotPosition(snapshotId, positionId), 'role-description'); | ||
} | ||
snapshotReportsTo(snapshotId, positionId, date) { | ||
const url = combineUrls(this.snapshotPosition(snapshotId, positionId), 'reports-to'); | ||
return `${url}?date=${date}`; | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
declare const _default: "2.3.1"; | ||
declare const _default: "2.3.2"; | ||
export default _default; |
@@ -1,1 +0,1 @@ | ||
export default '2.3.1'; | ||
export default '2.3.2'; |
{ | ||
"name": "@equinor/fusion", | ||
"version": "2.3.1", | ||
"version": "2.3.2", | ||
"description": "Everything a Fusion app needs to communicate with the core", | ||
@@ -30,2 +30,13 @@ "main": "lib/index.js", | ||
"homepage": "https://github.com/equinor/fusion-api#readme", | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
"./src/**/*.{js,ts,tsx}": [ | ||
"prettier --write ", | ||
"eslint --quiet --fix" | ||
] | ||
}, | ||
"dependencies": { | ||
@@ -53,2 +64,4 @@ "@microsoft/applicationinsights-web": "^2.4.3", | ||
"history": "^4.9.0", | ||
"husky": "^4.3.0", | ||
"lint-staged": "^10.3.0", | ||
"prettier": "^2.1.1", | ||
@@ -55,0 +68,0 @@ "react": "^16.13.1", |
318753
7533
25