Skip to content

Commit afb2bda

Browse files
authored
Always use container relative urls (#207)
* ActionURL: Always use container relative urls * ExperimentalFeatures: remove containerRelativeURL * Add justfile
1 parent 9ee0ef4 commit afb2bda

11 files changed

Lines changed: 132 additions & 30 deletions

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### 1.47.0 - 2026-02-24
2+
- Always use container relative URLs
3+
- Remove ExperimentalFeatures.containerRelativeURL
4+
- Update tests to assume container relative URLs
5+
- Add justfile
6+
17
### 1.46.1 - 2026-02-17
28
- Update Array filter multi-value delimiter to ';' to match IN/NOT IN filter types to allow filter type conversion
39

justfile

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Note: this justfile should work for anyone using MacOS, however with some work we can probably get it to also work on
2+
# Windows if we use the [unix] and [windows] attributes on the commands that execute shell scripts:
3+
# https://just.systems/man/en/attributes.html#enabling-and-disabling-recipes180
4+
5+
[private]
6+
default:
7+
just --list
8+
9+
currentBranch := `git branch --show-current`
10+
branchAsTag := replace(currentBranch, '_', '-')
11+
packageName := '@labkey/api'
12+
pwd := `pwd`
13+
14+
# We quote the paths from our environment variables so these variables will work even if the paths contains spaces
15+
# We trim the trailing / from our environment variables so we can treat them consistently with our other paths
16+
components := quote(trim_end_match(env('LABKEY_UI_COMPONENTS_HOME'), '/') / 'packages/components')
17+
premium := quote(trim_end_match(env('LABKEY_UI_PREMIUM_HOME'), '/'))
18+
distPath := 'node_modules' / packageName / 'dist'
19+
sourceDist := pwd / 'dist/'
20+
modulesToBump := components + ' ' + premium
21+
copyLocations := append('/' + distPath, modulesToBump)
22+
23+
# Builds the package
24+
build:
25+
npm run build
26+
27+
# Copies built package to NODE_MODULES directory for every module listed in copyLocations
28+
copy:
29+
#!/usr/bin/env zsh
30+
set -euo pipefail
31+
for module in {{ copyLocations }}; do
32+
echo '{{ GREEN }}'Copying built package to '{{CYAN}}'$module'{{ NORMAL }}'
33+
rsync -ra {{ sourceDist }} $module
34+
done
35+
36+
# Builds the package and copies it to NODE_MODULES for every module listed in copyLocations
37+
bc: build copy
38+
39+
# Bumps version to a prerelease version based on the current branch name
40+
preVersion:
41+
@echo {{ GREEN }}Bumping prerelease version with preid='{{CYAN}}'{{ branchAsTag }}{{ NORMAL }}
42+
@npm version prerelease --preid {{ branchAsTag }} --no-git-tag-version
43+
44+
# Publishes the current version with the current branch name as a tag
45+
publishPreVersion:
46+
@echo {{ GREEN }}Publishing prerelease package{{ NORMAL }}
47+
@npm publish --tag {{ branchAsTag }}
48+
49+
[private]
50+
sleep:
51+
@echo {{ GREEN }}"Sleeping so artifactory doesn't return 404"{{ NORMAL }}
52+
@sleep 6
53+
54+
# Lists the modules in the 'modulesToBump' variable
55+
listModules:
56+
#!/usr/bin/env zsh
57+
set -euo pipefail
58+
for module in {{ modulesToBump }}; do
59+
echo $module
60+
done
61+
62+
# Stored as a string because we want to execute this when scripts are run, not when the justfile is evaluated, so we
63+
# always have the most up to date version.
64+
currentVersionImport := quote("require('./package.json').version")
65+
66+
# lists the current package version
67+
version:
68+
@echo $(node -p -e {{ currentVersionImport }})
69+
70+
# Bumps the @labkey/premium package to the current version in every module listed in the modulesToBump variable
71+
bump:
72+
#!/usr/bin/env zsh
73+
set -euo pipefail
74+
v=$(node -p -e {{ currentVersionImport }})
75+
echo '{{ GREEN }}'Bumping {{ packageName }} to '{{CYAN}}'$v'{{ NORMAL }}'
76+
for module in {{ modulesToBump }}; do
77+
pushd $module
78+
echo '{{ GREEN }}'Bumping {{ packageName }} in '{{CYAN}}'$(pwd)'{{ NORMAL }}'
79+
npm install --legacy-peer-deps --save-exact {{ packageName }}@$v
80+
popd
81+
done
82+
83+
# Bumps the version to a prerelease version based on the current branch name, publishes the version, and bumps it in every module listed in modulesToBump
84+
release: preVersion publishPreVersion sleep bump
85+
86+
# Bumps the major version
87+
major:
88+
npm version major --no-git-tag-version
89+
90+
# Bumps the minor version
91+
minor:
92+
npm version minor --no-git-tag-version
93+
94+
# Bumps the patch version
95+
patch:
96+
npm version patch --no-git-tag-version
97+
98+
# Publishes the current version, must be a production version
99+
publish:
100+
npm publish
101+
102+
pb: publish sleep bump

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@labkey/api",
3-
"version": "1.46.1",
3+
"version": "1.47.0",
44
"description": "JavaScript client API for LabKey Server",
55
"scripts": {
66
"build": "npm run build:dist && npm run build:docs",

src/labkey/ActionURL.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ describe('ActionURL', () => {
3131

3232
it('should build the correct URL', () => {
3333
const url = ActionURL.buildURL('project', 'getWebPart', 'MyContainer');
34-
expect(url).toEqual('/project/MyContainer/getWebPart.view');
34+
expect(url).toEqual('/MyContainer/project-getWebPart.view');
3535
});
3636

3737
it('should build the correct URL with optional parameters', () => {
3838
const params = { listId: 50, returnUrl: 'home', array: [10, 'li'] };
3939
const url = ActionURL.buildURL('project', 'getWebPart', 'MyContainer', params);
40-
expect(url).toEqual('/project/MyContainer/getWebPart.view?listId=50&returnUrl=home&array=10&array=li');
40+
expect(url).toEqual('/MyContainer/project-getWebPart.view?listId=50&returnUrl=home&array=10&array=li');
4141
});
4242
});
4343

src/labkey/ActionURL.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,10 @@ export function buildURL(
120120
if (action.indexOf('.') == -1) {
121121
action += '.view';
122122
}
123-
const query = queryString(parameters);
124123

125-
let newURL: string;
126-
const { contextPath, experimental } = getServerContext();
127-
if (experimental && experimental.containerRelativeURL) {
128-
newURL = contextPath + containerPath + controller + '-' + action;
129-
} else {
130-
newURL = contextPath + '/' + controller + containerPath + action;
131-
}
124+
const query = queryString(parameters);
125+
const { contextPath } = getServerContext();
126+
let newURL = contextPath + containerPath + controller + '-' + action;
132127

133128
if (query) {
134129
newURL += '?' + query;

src/labkey/Assay.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('assayList.api requests', () => {
4040
// Assert
4141
expect(requestSpy).toHaveBeenCalledWith(
4242
expect.objectContaining({
43-
url: '/assay/my/special/folder/assayList.api',
43+
url: '/my/special/folder/assay-assayList.api',
4444
})
4545
);
4646
});
@@ -59,7 +59,7 @@ describe('assayList.api requests', () => {
5959
expect(requestSpy).toHaveBeenCalledWith(
6060
expect.objectContaining({
6161
jsonData: { id: assayId },
62-
url: '/assay/my/special/folder/assayList.api',
62+
url: '/my/special/folder/assay-assayList.api',
6363
})
6464
);
6565
});
@@ -78,7 +78,7 @@ describe('assayList.api requests', () => {
7878
expect(requestSpy).toHaveBeenCalledWith(
7979
expect.objectContaining({
8080
jsonData: { name: assayName },
81-
url: '/assay/my/special/folder/assayList.api',
81+
url: '/my/special/folder/assay-assayList.api',
8282
})
8383
);
8484
});
@@ -97,7 +97,7 @@ describe('assayList.api requests', () => {
9797
expect(requestSpy).toHaveBeenCalledWith(
9898
expect.objectContaining({
9999
jsonData: { type: assayType },
100-
url: '/assay/my/special/folder/assayList.api',
100+
url: '/my/special/folder/assay-assayList.api',
101101
})
102102
);
103103
});
@@ -117,7 +117,7 @@ describe('assayList.api requests', () => {
117117
expect(requestSpy).toHaveBeenCalledWith(
118118
expect.objectContaining({
119119
jsonData: { id, name, plateEnabled, status, type },
120-
url: '/assay/assayList.api',
120+
url: '/assay-assayList.api',
121121
})
122122
);
123123
});

src/labkey/Report.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('execute', () => {
3535
// Assert
3636
expect(requestSpy).toHaveBeenCalledWith(
3737
expect.objectContaining({
38-
url: '/reports/execute.api',
38+
url: '/reports-execute.api',
3939
method: 'POST',
4040
jsonData: {
4141
reportId: 'db:123',

src/labkey/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ export interface Project {
7474
}
7575

7676
export enum ExperimentalFeatures {
77-
containerRelativeURL = 'containerRelativeURL',
7877
disableGuestAccount = 'disableGuestAccount',
7978
}
8079

src/labkey/query/Rows.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('deleteRows', () => {
4040
rows,
4141
schemaName,
4242
}),
43-
url: '/query/deleteRows.api',
43+
url: '/query-deleteRows.api',
4444
})
4545
);
4646
});
@@ -69,7 +69,7 @@ describe('insertRows', () => {
6969
rows,
7070
schemaName,
7171
}),
72-
url: '/query/insertRows.api',
72+
url: '/query-insertRows.api',
7373
})
7474
);
7575
});
@@ -92,7 +92,7 @@ describe('insertRows', () => {
9292
expect.objectContaining({
9393
method: 'POST',
9494
form: expect.anything(),
95-
url: '/query/insertRows.api',
95+
url: '/query-insertRows.api',
9696
})
9797
);
9898
expect(requestSpy).toHaveBeenCalledWith(
@@ -117,7 +117,7 @@ describe('insertRows', () => {
117117
expect.objectContaining({
118118
method: 'POST',
119119
form: expect.anything(),
120-
url: '/query/insertRows.api',
120+
url: '/query-insertRows.api',
121121
})
122122
);
123123
});
@@ -146,7 +146,7 @@ describe('updateRows', () => {
146146
rows,
147147
schemaName,
148148
}),
149-
url: '/query/updateRows.api',
149+
url: '/query-updateRows.api',
150150
})
151151
);
152152
});
@@ -169,7 +169,7 @@ describe('updateRows', () => {
169169
expect.objectContaining({
170170
method: 'POST',
171171
form: expect.anything(),
172-
url: '/query/updateRows.api',
172+
url: '/query-updateRows.api',
173173
})
174174
);
175175
expect(requestSpy).toHaveBeenCalledWith(
@@ -224,7 +224,7 @@ describe('saveRows', () => {
224224
jsonData: expect.objectContaining({
225225
commands,
226226
}),
227-
url: '/query/saveRows.api',
227+
url: '/query-saveRows.api',
228228
})
229229
);
230230
});
@@ -267,7 +267,7 @@ describe('saveRows', () => {
267267
expect(requestSpy).toHaveBeenCalledWith(
268268
expect.objectContaining({
269269
method: 'POST',
270-
url: '/query/saveRows.api',
270+
url: '/query-saveRows.api',
271271
})
272272
);
273273
const form = requestSpy.mock.lastCall[0].form;

0 commit comments

Comments
 (0)