Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/dhis2-verify-lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
with:
node-version: 20.x

- uses: actions/cache@v2
- uses: actions/cache@v4
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: '**/node_modules'
Expand All @@ -44,7 +44,7 @@ jobs:
with:
node-version: 20.x

- uses: actions/cache@v2
- uses: actions/cache@v4
id: yarn-cache
with:
path: '**/node_modules'
Expand All @@ -71,7 +71,7 @@ jobs:
with:
node-version: 20.x

- uses: actions/cache@v2
- uses: actions/cache@v4
id: yarn-cache
with:
path: '**/node_modules'
Expand All @@ -98,7 +98,7 @@ jobs:
with:
node-version: 20.x

- uses: actions/cache@v2
- uses: actions/cache@v4
id: yarn-cache
with:
path: '**/node_modules'
Expand Down
20 changes: 20 additions & 0 deletions services/data/src/links/RestAPILink/queryToResourcePath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,26 @@ describe('queryToResourcePath', () => {
)
})
})
describe('legacy', () => {
it('should return the apps bundle url if using `legacy::bundledApps`', () => {
const query: ResolvedResourceQuery = {
resource: 'legacy::bundledApps',
}
expect(queryToResourcePath(link, query, 'read')).toBe(
'dhis-web-apps/apps-bundle.json'
)
console.log({ apiPath })
})
it('should return the specified path if using `legacy::<customPath>`', () => {
const query: ResolvedResourceQuery = {
resource: 'legacy::dhis-web-apps',
}
expect(queryToResourcePath(link, query, 'read')).toBe(
'dhis-web-apps'
)
console.log({ apiPath })
})
})
describe('resource with dot', () => {
it('should leave dots in resources', () => {
const query: ResolvedResourceQuery = {
Expand Down
17 changes: 17 additions & 0 deletions services/data/src/links/RestAPILink/queryToResourcePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ const makeActionPath = (resource: string) =>
`${resource.substr(actionPrefix.length)}.action`
)

const legacyPrefix = 'legacy::'
const isLegacy = (resource: string) => resource.startsWith(legacyPrefix)
const makeLegacyPath = (resource: string) => {
switch (resource) {
case 'legacy::bundledApps': {
return 'dhis-web-apps/apps-bundle.json'
}
// Not necessary here, but brainstorming:
// you can use whatever path you want 🤷
default: {
return resource.replace(legacyPrefix, '')
}
}
}

const skipApiVersion = (resource: string, config: Config): boolean => {
if (resource === 'tracker' || resource.startsWith('tracker/')) {
if (!config.serverVersion?.minor || config.serverVersion?.minor < 38) {
Expand Down Expand Up @@ -99,6 +114,8 @@ export const queryToResourcePath = (

const base = isAction(resource)
? makeActionPath(resource)
: isLegacy(resource)
? makeLegacyPath(resource)
: joinPath(apiBase, resource, id)

validateResourceQuery(query, type)
Expand Down
Loading