@contember/engine-panel 2.2.0-alpha.17 → 2.2.0-alpha.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/src/PanelMount.cjs +2 -2
- package/dist/development/src/PanelMount.cjs.map +1 -1
- package/dist/development/src/PanelMount.js +2 -2
- package/dist/development/src/PanelMount.js.map +1 -1
- package/dist/development/src/PanelPlugin.cjs +3 -1
- package/dist/development/src/PanelPlugin.cjs.map +1 -1
- package/dist/development/src/PanelPlugin.js +3 -1
- package/dist/development/src/PanelPlugin.js.map +1 -1
- package/dist/development/src/generated/assets.cjs +38 -38
- package/dist/development/src/generated/assets.cjs.map +1 -1
- package/dist/development/src/generated/assets.js +38 -38
- package/dist/development/src/generated/assets.js.map +1 -1
- package/dist/production/src/PanelMount.cjs +2 -2
- package/dist/production/src/PanelMount.cjs.map +1 -1
- package/dist/production/src/PanelMount.js +2 -2
- package/dist/production/src/PanelMount.js.map +1 -1
- package/dist/production/src/PanelPlugin.cjs +3 -1
- package/dist/production/src/PanelPlugin.cjs.map +1 -1
- package/dist/production/src/PanelPlugin.js +3 -1
- package/dist/production/src/PanelPlugin.js.map +1 -1
- package/dist/production/src/generated/assets.cjs +38 -38
- package/dist/production/src/generated/assets.cjs.map +1 -1
- package/dist/production/src/generated/assets.js +38 -38
- package/dist/production/src/generated/assets.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/PanelMount.d.ts +1 -1
- package/dist/types/PanelMount.d.ts.map +1 -1
- package/dist/types/PanelPlugin.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/PanelMount.ts +2 -2
- package/src/PanelPlugin.ts +3 -1
- package/tests/cases/unit/panelMount.test.ts +13 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/engine-panel",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "2.2.0-alpha.
|
|
4
|
+
"version": "2.2.0-alpha.18",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/production/index.js",
|
|
7
7
|
"typings": "./dist/types/index.d.ts",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"directory": "packages/engine-panel"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@contember/engine-http": "2.2.0-alpha.
|
|
35
|
+
"@contember/engine-http": "2.2.0-alpha.18"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^24.12.0"
|
package/src/PanelMount.ts
CHANGED
|
@@ -18,8 +18,8 @@ export class PanelMount implements PanelApiMount {
|
|
|
18
18
|
) {
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
public mount(application: PanelApiMountTarget, { name, path, controller }: PanelApiMountArgs): void {
|
|
22
|
-
application.addRoute('panel-api', `${this.basePath}/api/${path}`, this.api.create(controller, { allowAnonymous: false }))
|
|
21
|
+
public mount(application: PanelApiMountTarget, { name, path, controller, carriesCredentials }: PanelApiMountArgs): void {
|
|
22
|
+
application.addRoute('panel-api', `${this.basePath}/api/${path}`, this.api.create(controller, { allowAnonymous: false }), { carriesCredentials })
|
|
23
23
|
this.pluginApiNames.add(name)
|
|
24
24
|
}
|
|
25
25
|
|
package/src/PanelPlugin.ts
CHANGED
|
@@ -45,7 +45,9 @@ export class PanelPlugin implements Plugin {
|
|
|
45
45
|
// building (`${apiBaseUrl}${path}`) needs no special cases. Only tenant takes anonymous
|
|
46
46
|
// callers — it is the one the sign-in screen talks to before there is a session.
|
|
47
47
|
// Content and system have no pre-sign-in consumer.
|
|
48
|
-
it.addRoute('panel-api', `${basePath}/api/tenant`, api.create(tenantApiMiddlewareFactory.create(), { allowAnonymous: true })
|
|
48
|
+
it.addRoute('panel-api', `${basePath}/api/tenant`, api.create(tenantApiMiddlewareFactory.create(), { allowAnonymous: true }), {
|
|
49
|
+
carriesCredentials: true,
|
|
50
|
+
})
|
|
49
51
|
it.addRoute(
|
|
50
52
|
'panel-api',
|
|
51
53
|
`${basePath}/api/content/:projectSlug/:stageSlug`,
|
|
@@ -2,11 +2,13 @@ import type { HttpController, PanelApiMountTarget } from '@contember/engine-http
|
|
|
2
2
|
import { describe, expect, test } from 'bun:test'
|
|
3
3
|
import { ConfiguredPanelAccessCheck, PanelApiControllerFactory, PanelAssetStore, PanelMount } from '../../../src/index.js'
|
|
4
4
|
|
|
5
|
-
type RegisteredRoute = { module: string; mask: string; controller: HttpController }
|
|
5
|
+
type RegisteredRoute = { module: string; mask: string; controller: HttpController; carriesCredentials?: boolean }
|
|
6
6
|
|
|
7
7
|
const createTarget = () => {
|
|
8
8
|
const routes: RegisteredRoute[] = []
|
|
9
|
-
const target: PanelApiMountTarget = {
|
|
9
|
+
const target: PanelApiMountTarget = {
|
|
10
|
+
addRoute: (module, mask, controller, options) => void routes.push({ module, mask, controller, carriesCredentials: options?.carriesCredentials }),
|
|
11
|
+
}
|
|
10
12
|
return { routes, target }
|
|
11
13
|
}
|
|
12
14
|
|
|
@@ -25,6 +27,15 @@ describe('panel mount', () => {
|
|
|
25
27
|
expect(routes[0].mask).toBe('/panel/api/actions/:projectSlug')
|
|
26
28
|
})
|
|
27
29
|
|
|
30
|
+
// The flag decides whether the request bodies of the mounted API are masked in logs.
|
|
31
|
+
test('passes on whether the mounted API receives credentials', () => {
|
|
32
|
+
const { routes, target } = createTarget()
|
|
33
|
+
createMount().mount(target, { name: 'actions', path: 'actions/:projectSlug', controller, carriesCredentials: true })
|
|
34
|
+
createMount().mount(target, { name: 'other', path: 'other', controller })
|
|
35
|
+
|
|
36
|
+
expect(routes.map(it => it.carriesCredentials)).toEqual([true, undefined])
|
|
37
|
+
})
|
|
38
|
+
|
|
28
39
|
test('follows the configured mount path', () => {
|
|
29
40
|
const { routes, target } = createTarget()
|
|
30
41
|
createMount('/admin-console').mount(target, { name: 'actions', path: 'actions/:projectSlug', controller })
|