| 5 | |
| 6 | export default class Application extends JSONAPIAdapter { |
| 7 | currentProject = ''; |
| 8 | currentProjectVersion = ''; |
| 9 | |
| 10 | @service |
| 11 | metaStore; |
| 12 | |
| 13 | @service('project') |
| 14 | projectService; |
| 15 | |
| 16 | ids = null; |
| 17 | |
| 18 | shouldReloadRecord(store, { modelName, id }) { |
| 19 | if (modelName === 'project') { |
| 20 | this.currentProject = id; |
| 21 | } else if (modelName === 'project-version') { |
| 22 | this.currentProjectVersion = id; |
| 23 | } |
| 24 | return; // return undefined so auto determinated |
| 25 | } |
| 26 | |
| 27 | shouldBackgroundReloadAll() { |
| 28 | return false; |
| 29 | } |
| 30 | |
| 31 | shouldBackgroundReloadRecord() { |
| 32 | return false; |
| 33 | } |
| 34 | |
| 35 | constructor() { |
| 36 | super(...arguments); |
| 37 | this.ids = {}; |
| 38 | } |
| 39 | |
| 40 | async findRecord(store, { modelName }, id) { |
| 41 | let url; |
| 42 | let projectName = this.currentProject; |
| 43 | |
| 44 | if (['namespace', 'class', 'module'].indexOf(modelName) > -1) { |
| 45 | let [version] = |
| 46 | id |
| 47 | .replace(`${projectName}-`, '') |
| 48 | .match(/^(\d+\.\d+\.\d+(?:-[a-z]+\.\d+)?)/i) || []; |
| 49 | let revId = this.metaStore.getRevId(projectName, version, modelName, id); |
| 50 | |
| 51 | let modelNameToUse = modelName; |
| 52 | // To account for namespaces that are also classes but not defined properly in yuidocs |
| 53 | if (isBlank(revId) && modelNameToUse === 'class') { |
| 54 | revId = this.metaStore.getRevId(projectName, version, 'namespace', id); |
| 55 | modelNameToUse = 'namespace'; |
| 56 | } |
| 57 | |
| 58 | if (typeof revId !== 'undefined') { |
| 59 | let encodedRevId = encodeURIComponent(revId); |
| 60 | url = `json-docs/${projectName}/${version}/${pluralize( |
| 61 | modelNameToUse, |
| 62 | )}/${encodedRevId}`; |
| 63 | } else { |
| 64 | throw new Error('Documentation item not found'); |
nothing calls this directly
no outgoing calls
no test coverage detected