@atlassianlabs/jira-pi-common-models
Advanced tools
Comparing version 0.1.5 to 0.1.7
@@ -1,1 +0,12 @@ | ||
export declare function getEpicFieldInfo(fields: any): [string, string]; | ||
export declare const epicsDisabled: EpicFieldInfo; | ||
export interface CFIdName { | ||
id: string; | ||
name: string; | ||
cfid: number; | ||
} | ||
export interface EpicFieldInfo { | ||
epicName: CFIdName; | ||
epicLink: CFIdName; | ||
epicsEnabled: boolean; | ||
} | ||
export declare function getEpicFieldInfo(fields: any): EpicFieldInfo; |
@@ -7,10 +7,26 @@ "use strict"; | ||
exports.getEpicFieldInfo = getEpicFieldInfo; | ||
exports.epicsDisabled = void 0; | ||
var epicsDisabled = { | ||
epicLink: { | ||
name: "", | ||
id: "", | ||
cfid: 0 | ||
}, | ||
epicName: { | ||
name: "", | ||
id: "", | ||
cfid: 0 | ||
}, | ||
epicsEnabled: false | ||
}; | ||
exports.epicsDisabled = epicsDisabled; | ||
function getEpicFieldInfo(fields) { | ||
var epicLinkId = ''; | ||
var epicNameId = ''; | ||
var epicInfo = epicsDisabled; | ||
var epicName = undefined; | ||
var epicLink = undefined; | ||
if (Object.keys(fields).length > 0) { | ||
Object.values(fields).filter(function (field) { | ||
if (field.schema && field.schema.custom && (field.schema.custom === 'com.pyxis.greenhopper.jira:gh-epic-label' || field.schema.custom === 'com.pyxis.greenhopper.jira:gh-epic-link')) { | ||
if (field && field.schema && field.schema.custom && (field.schema.custom === 'com.pyxis.greenhopper.jira:gh-epic-label' || field.schema.custom === 'com.pyxis.greenhopper.jira:gh-epic-link')) { | ||
return field; | ||
@@ -23,5 +39,13 @@ } | ||
if (field.schema && field.schema.custom === 'com.pyxis.greenhopper.jira:gh-epic-label') { | ||
epicNameId = field.id; | ||
epicName = { | ||
name: field.name, | ||
id: field.key, | ||
cfid: parseInt(field.key.substr(12)) | ||
}; | ||
} else if (field.schema && field.schema.custom === 'com.pyxis.greenhopper.jira:gh-epic-link') { | ||
epicLinkId = field.id; | ||
epicLink = { | ||
name: field.name, | ||
id: field.key, | ||
cfid: parseInt(field.key.substr(12)) | ||
}; | ||
} | ||
@@ -31,3 +55,9 @@ }); | ||
return [epicLinkId, epicNameId]; | ||
if (epicName && epicLink) { | ||
epicInfo.epicName = epicName; | ||
epicInfo.epicLink = epicLink; | ||
epicInfo.epicsEnabled = true; | ||
} | ||
return epicInfo; | ||
} |
@@ -0,8 +1,22 @@ | ||
export var epicsDisabled = { | ||
epicLink: { | ||
name: "", | ||
id: "", | ||
cfid: 0 | ||
}, | ||
epicName: { | ||
name: "", | ||
id: "", | ||
cfid: 0 | ||
}, | ||
epicsEnabled: false | ||
}; | ||
export function getEpicFieldInfo(fields) { | ||
var epicLinkId = ''; | ||
var epicNameId = ''; | ||
var epicInfo = epicsDisabled; | ||
var epicName = undefined; | ||
var epicLink = undefined; | ||
if (Object.keys(fields).length > 0) { | ||
Object.values(fields).filter(function (field) { | ||
if (field.schema && field.schema.custom && (field.schema.custom === 'com.pyxis.greenhopper.jira:gh-epic-label' || field.schema.custom === 'com.pyxis.greenhopper.jira:gh-epic-link')) { | ||
if (field && field.schema && field.schema.custom && (field.schema.custom === 'com.pyxis.greenhopper.jira:gh-epic-label' || field.schema.custom === 'com.pyxis.greenhopper.jira:gh-epic-link')) { | ||
return field; | ||
@@ -15,5 +29,13 @@ } | ||
if (field.schema && field.schema.custom === 'com.pyxis.greenhopper.jira:gh-epic-label') { | ||
epicNameId = field.id; | ||
epicName = { | ||
name: field.name, | ||
id: field.key, | ||
cfid: parseInt(field.key.substr(12)) | ||
}; | ||
} else if (field.schema && field.schema.custom === 'com.pyxis.greenhopper.jira:gh-epic-link') { | ||
epicLinkId = field.id; | ||
epicLink = { | ||
name: field.name, | ||
id: field.key, | ||
cfid: parseInt(field.key.substr(12)) | ||
}; | ||
} | ||
@@ -23,3 +45,9 @@ }); | ||
return [epicLinkId, epicNameId]; | ||
if (epicName && epicLink) { | ||
epicInfo.epicName = epicName; | ||
epicInfo.epicLink = epicLink; | ||
epicInfo.epicsEnabled = true; | ||
} | ||
return epicInfo; | ||
} |
@@ -1,6 +0,4 @@ | ||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
import { createEmptyMinimalIssue, emptyIssueType, emptyPriority, emptyStatus, emptyTransition } from "./emptyEntities"; | ||
import { isIssueLinkType, isIssueType, isPriority, isStatus, isTransition, readIssueLinkIssue } from "./entities"; | ||
import { getEpicFieldInfo } from "./epicFieldInfo"; | ||
export function minimalIssueFromJsonObject(issueJson, siteDetails) { | ||
export function minimalIssueFromJsonObject(issueJson, siteDetails, epicFieldInfo) { | ||
if (!issueJson || !issueJson.fields) { | ||
@@ -21,8 +19,2 @@ return createEmptyMinimalIssue(siteDetails); | ||
var updated = issueJson.fields.updated ? new Date(Date.parse(issueJson.fields.updated)) : new Date(); | ||
var _getEpicFieldInfo = getEpicFieldInfo(issueJson.fields), | ||
_getEpicFieldInfo2 = _slicedToArray(_getEpicFieldInfo, 2), | ||
epicLinkId = _getEpicFieldInfo2[0], | ||
epicNameId = _getEpicFieldInfo2[1]; | ||
var thisIssue = { | ||
@@ -45,5 +37,5 @@ key: issueJson.key, | ||
siteDetails: siteDetails, | ||
isEpic: issueJson.fields[epicNameId] && issueJson.fields[epicNameId] !== '', | ||
epicName: issueJson.fields[epicNameId], | ||
epicLink: issueJson.fields[epicLinkId], | ||
isEpic: issueJson.fields[epicFieldInfo.epicName.id] && issueJson.fields[epicFieldInfo.epicName.id] !== '', | ||
epicName: issueJson.fields[epicFieldInfo.epicName.id], | ||
epicLink: issueJson.fields[epicFieldInfo.epicLink.id], | ||
epicChildren: [] | ||
@@ -50,0 +42,0 @@ }; |
@@ -76,3 +76,3 @@ import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
} | ||
export function readSearchResults(params, site) { | ||
export function readSearchResults(params, site, epicFieldInfo) { | ||
return _regeneratorRuntime.async(function readSearchResults$(_context) { | ||
@@ -87,3 +87,3 @@ while (1) { | ||
issues: Array.isArray(params.issues) ? params.issues.map(function (i) { | ||
return minimalIssueFromJsonObject(i, site); | ||
return minimalIssueFromJsonObject(i, site, epicFieldInfo); | ||
}) : [] | ||
@@ -90,0 +90,0 @@ }); |
import { MinimalIssue } from "./entities"; | ||
import { EpicFieldInfo } from "./epicFieldInfo"; | ||
import { JiraSiteInfo } from "./JiraSiteInfo"; | ||
export declare function minimalIssueFromJsonObject<S extends JiraSiteInfo>(issueJson: any, siteDetails: S): MinimalIssue<S>; | ||
export declare function minimalIssueFromJsonObject<S extends JiraSiteInfo>(issueJson: any, siteDetails: S, epicFieldInfo: EpicFieldInfo): MinimalIssue<S>; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -10,4 +8,2 @@ value: true | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var _emptyEntities = require("./emptyEntities"); | ||
@@ -17,5 +13,3 @@ | ||
var _epicFieldInfo = require("./epicFieldInfo"); | ||
function minimalIssueFromJsonObject(issueJson, siteDetails) { | ||
function minimalIssueFromJsonObject(issueJson, siteDetails, epicFieldInfo) { | ||
if (!issueJson || !issueJson.fields) { | ||
@@ -36,8 +30,2 @@ return (0, _emptyEntities.createEmptyMinimalIssue)(siteDetails); | ||
var updated = issueJson.fields.updated ? new Date(Date.parse(issueJson.fields.updated)) : new Date(); | ||
var _getEpicFieldInfo = (0, _epicFieldInfo.getEpicFieldInfo)(issueJson.fields), | ||
_getEpicFieldInfo2 = (0, _slicedToArray2["default"])(_getEpicFieldInfo, 2), | ||
epicLinkId = _getEpicFieldInfo2[0], | ||
epicNameId = _getEpicFieldInfo2[1]; | ||
var thisIssue = { | ||
@@ -60,5 +48,5 @@ key: issueJson.key, | ||
siteDetails: siteDetails, | ||
isEpic: issueJson.fields[epicNameId] && issueJson.fields[epicNameId] !== '', | ||
epicName: issueJson.fields[epicNameId], | ||
epicLink: issueJson.fields[epicLinkId], | ||
isEpic: issueJson.fields[epicFieldInfo.epicName.id] && issueJson.fields[epicFieldInfo.epicName.id] !== '', | ||
epicName: issueJson.fields[epicFieldInfo.epicName.id], | ||
epicLink: issueJson.fields[epicFieldInfo.epicLink.id], | ||
epicChildren: [] | ||
@@ -65,0 +53,0 @@ }; |
{ | ||
"name": "@atlassianlabs/jira-pi-common-models", | ||
"version": "0.1.5", | ||
"version": "0.1.7", | ||
"description": "Common Jira models for related jira-pi-clients", | ||
@@ -14,6 +14,6 @@ "repository": { | ||
"module": "./esm/index.js", | ||
"main": "./index.js", | ||
"sideEffects": false, | ||
"gitHead": "06dbd322dd33485ac1b18742f8f99bd841238e87", | ||
"main": "./index.js", | ||
"gitHead": "922580cca9491674a27fc82ef418eab1cd82fb84", | ||
"typings": "./index.d.ts" | ||
} |
import { MinimalIssue, Project } from "./entities"; | ||
import { EpicFieldInfo } from "./epicFieldInfo"; | ||
import { JiraSiteInfo } from "./JiraSiteInfo"; | ||
@@ -56,3 +57,3 @@ export interface CreatedIssue { | ||
} | ||
export declare function readSearchResults<S extends JiraSiteInfo>(params: any, site: S): Promise<SearchResults<S>>; | ||
export declare function readSearchResults<S extends JiraSiteInfo>(params: any, site: S, epicFieldInfo: EpicFieldInfo): Promise<SearchResults<S>>; | ||
export interface ProjectResult { | ||
@@ -59,0 +60,0 @@ readonly maxResults: number; |
@@ -122,3 +122,3 @@ "use strict"; | ||
function readSearchResults(params, site) { | ||
function readSearchResults(params, site, epicFieldInfo) { | ||
return _regenerator["default"].async(function readSearchResults$(_context) { | ||
@@ -133,3 +133,3 @@ while (1) { | ||
issues: Array.isArray(params.issues) ? params.issues.map(function (i) { | ||
return (0, _issueFromJson.minimalIssueFromJsonObject)(i, site); | ||
return (0, _issueFromJson.minimalIssueFromJsonObject)(i, site, epicFieldInfo); | ||
}) : [] | ||
@@ -136,0 +136,0 @@ }); |
51035
1626