@contember/engine-panel 2.2.0-alpha.16 → 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
|
@@ -10,8 +10,8 @@ class PanelMount {
|
|
|
10
10
|
this.api = api;
|
|
11
11
|
__publicField(this, "pluginApiNames", /* @__PURE__ */ new Set());
|
|
12
12
|
}
|
|
13
|
-
mount(application, { name, path, controller }) {
|
|
14
|
-
application.addRoute("panel-api", `${this.basePath}/api/${path}`, this.api.create(controller, { allowAnonymous: false }));
|
|
13
|
+
mount(application, { name, path, controller, carriesCredentials }) {
|
|
14
|
+
application.addRoute("panel-api", `${this.basePath}/api/${path}`, this.api.create(controller, { allowAnonymous: false }), { carriesCredentials });
|
|
15
15
|
this.pluginApiNames.add(name);
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelMount.cjs","sources":["../../../../packages/engine-panel/src/PanelMount.ts"],"sourcesContent":["import type { PanelApiMount, PanelApiMountArgs, PanelApiMountTarget } from '@contember/engine-http'\nimport type { PanelApiControllerFactory } from './PanelApiController.js'\nimport type { PanelAssetStore } from './PanelAssets.js'\n\n/**\n * Everything needed to serve the panel, resolved once. It exists only when the panel really is\n * served — enabled *and* built into this binary — so a plugin can read \"this resolved\" as \"there is\n * a panel to mount into\" and skip its panel route otherwise.\n */\nexport class PanelMount implements PanelApiMount {\n\tprivate readonly pluginApiNames = new Set<string>()\n\n\tconstructor(\n\t\tpublic readonly basePath: string,\n\t\tpublic readonly assets: PanelAssetStore,\n\t\t/** Shared with the panel's own routes: one factory means one access-check cache for all of them. */\n\t\tpublic readonly api: PanelApiControllerFactory,\n\t) {\n\t}\n\n\tpublic mount(application: PanelApiMountTarget, { name, path, controller }: PanelApiMountArgs): void {\n\t\tapplication.addRoute('panel-api', `${this.basePath}/api/${path}`, this.api.create(controller, { allowAnonymous: false }))\n\t\tthis.pluginApiNames.add(name)\n\t}\n\n\t/**\n\t * APIs plugins have mounted, reported to the UI so a module can hide itself when the plugin that\n\t * backs it is not installed. Read when the shell is rendered, not when it is constructed, so a\n\t * plugin registering after the panel is still counted.\n\t */\n\tpublic get pluginApis(): readonly string[] {\n\t\treturn [...this.pluginApiNames].sort()\n\t}\n}\n"],"names":[],"mappings":";;;;;AASO,MAAM,WAAoC;AAAA,EAGhD,YACiB,UACA,QAEA,KACf;AAJe,SAAA,WAAA;AACA,SAAA,SAAA;AAEA,SAAA,MAAA;AANjB,kBAAA,MAAiB,sCAAqB,IAAA,CAAY;AAAA,EAQlD;AAAA,EAEO,MAAM,aAAkC,EAAE,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"PanelMount.cjs","sources":["../../../../packages/engine-panel/src/PanelMount.ts"],"sourcesContent":["import type { PanelApiMount, PanelApiMountArgs, PanelApiMountTarget } from '@contember/engine-http'\nimport type { PanelApiControllerFactory } from './PanelApiController.js'\nimport type { PanelAssetStore } from './PanelAssets.js'\n\n/**\n * Everything needed to serve the panel, resolved once. It exists only when the panel really is\n * served — enabled *and* built into this binary — so a plugin can read \"this resolved\" as \"there is\n * a panel to mount into\" and skip its panel route otherwise.\n */\nexport class PanelMount implements PanelApiMount {\n\tprivate readonly pluginApiNames = new Set<string>()\n\n\tconstructor(\n\t\tpublic readonly basePath: string,\n\t\tpublic readonly assets: PanelAssetStore,\n\t\t/** Shared with the panel's own routes: one factory means one access-check cache for all of them. */\n\t\tpublic readonly api: PanelApiControllerFactory,\n\t) {\n\t}\n\n\tpublic mount(application: PanelApiMountTarget, { name, path, controller, carriesCredentials }: PanelApiMountArgs): void {\n\t\tapplication.addRoute('panel-api', `${this.basePath}/api/${path}`, this.api.create(controller, { allowAnonymous: false }), { carriesCredentials })\n\t\tthis.pluginApiNames.add(name)\n\t}\n\n\t/**\n\t * APIs plugins have mounted, reported to the UI so a module can hide itself when the plugin that\n\t * backs it is not installed. Read when the shell is rendered, not when it is constructed, so a\n\t * plugin registering after the panel is still counted.\n\t */\n\tpublic get pluginApis(): readonly string[] {\n\t\treturn [...this.pluginApiNames].sort()\n\t}\n}\n"],"names":[],"mappings":";;;;;AASO,MAAM,WAAoC;AAAA,EAGhD,YACiB,UACA,QAEA,KACf;AAJe,SAAA,WAAA;AACA,SAAA,SAAA;AAEA,SAAA,MAAA;AANjB,kBAAA,MAAiB,sCAAqB,IAAA,CAAY;AAAA,EAQlD;AAAA,EAEO,MAAM,aAAkC,EAAE,MAAM,MAAM,YAAY,sBAA+C;AACvH,gBAAY,SAAS,aAAa,GAAG,KAAK,QAAQ,QAAQ,IAAI,IAAI,KAAK,IAAI,OAAO,YAAY,EAAE,gBAAgB,OAAO,GAAG,EAAE,oBAAoB;AAChJ,SAAK,eAAe,IAAI,IAAI;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAW,aAAgC;AAC1C,WAAO,CAAC,GAAG,KAAK,cAAc,EAAE,KAAA;AAAA,EACjC;AACD;;"}
|
|
@@ -8,8 +8,8 @@ class PanelMount {
|
|
|
8
8
|
this.api = api;
|
|
9
9
|
__publicField(this, "pluginApiNames", /* @__PURE__ */ new Set());
|
|
10
10
|
}
|
|
11
|
-
mount(application, { name, path, controller }) {
|
|
12
|
-
application.addRoute("panel-api", `${this.basePath}/api/${path}`, this.api.create(controller, { allowAnonymous: false }));
|
|
11
|
+
mount(application, { name, path, controller, carriesCredentials }) {
|
|
12
|
+
application.addRoute("panel-api", `${this.basePath}/api/${path}`, this.api.create(controller, { allowAnonymous: false }), { carriesCredentials });
|
|
13
13
|
this.pluginApiNames.add(name);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelMount.js","sources":["../../../../packages/engine-panel/src/PanelMount.ts"],"sourcesContent":["import type { PanelApiMount, PanelApiMountArgs, PanelApiMountTarget } from '@contember/engine-http'\nimport type { PanelApiControllerFactory } from './PanelApiController.js'\nimport type { PanelAssetStore } from './PanelAssets.js'\n\n/**\n * Everything needed to serve the panel, resolved once. It exists only when the panel really is\n * served — enabled *and* built into this binary — so a plugin can read \"this resolved\" as \"there is\n * a panel to mount into\" and skip its panel route otherwise.\n */\nexport class PanelMount implements PanelApiMount {\n\tprivate readonly pluginApiNames = new Set<string>()\n\n\tconstructor(\n\t\tpublic readonly basePath: string,\n\t\tpublic readonly assets: PanelAssetStore,\n\t\t/** Shared with the panel's own routes: one factory means one access-check cache for all of them. */\n\t\tpublic readonly api: PanelApiControllerFactory,\n\t) {\n\t}\n\n\tpublic mount(application: PanelApiMountTarget, { name, path, controller }: PanelApiMountArgs): void {\n\t\tapplication.addRoute('panel-api', `${this.basePath}/api/${path}`, this.api.create(controller, { allowAnonymous: false }))\n\t\tthis.pluginApiNames.add(name)\n\t}\n\n\t/**\n\t * APIs plugins have mounted, reported to the UI so a module can hide itself when the plugin that\n\t * backs it is not installed. Read when the shell is rendered, not when it is constructed, so a\n\t * plugin registering after the panel is still counted.\n\t */\n\tpublic get pluginApis(): readonly string[] {\n\t\treturn [...this.pluginApiNames].sort()\n\t}\n}\n"],"names":[],"mappings":";;;AASO,MAAM,WAAoC;AAAA,EAGhD,YACiB,UACA,QAEA,KACf;AAJe,SAAA,WAAA;AACA,SAAA,SAAA;AAEA,SAAA,MAAA;AANjB,kBAAA,MAAiB,sCAAqB,IAAA,CAAY;AAAA,EAQlD;AAAA,EAEO,MAAM,aAAkC,EAAE,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"PanelMount.js","sources":["../../../../packages/engine-panel/src/PanelMount.ts"],"sourcesContent":["import type { PanelApiMount, PanelApiMountArgs, PanelApiMountTarget } from '@contember/engine-http'\nimport type { PanelApiControllerFactory } from './PanelApiController.js'\nimport type { PanelAssetStore } from './PanelAssets.js'\n\n/**\n * Everything needed to serve the panel, resolved once. It exists only when the panel really is\n * served — enabled *and* built into this binary — so a plugin can read \"this resolved\" as \"there is\n * a panel to mount into\" and skip its panel route otherwise.\n */\nexport class PanelMount implements PanelApiMount {\n\tprivate readonly pluginApiNames = new Set<string>()\n\n\tconstructor(\n\t\tpublic readonly basePath: string,\n\t\tpublic readonly assets: PanelAssetStore,\n\t\t/** Shared with the panel's own routes: one factory means one access-check cache for all of them. */\n\t\tpublic readonly api: PanelApiControllerFactory,\n\t) {\n\t}\n\n\tpublic mount(application: PanelApiMountTarget, { name, path, controller, carriesCredentials }: PanelApiMountArgs): void {\n\t\tapplication.addRoute('panel-api', `${this.basePath}/api/${path}`, this.api.create(controller, { allowAnonymous: false }), { carriesCredentials })\n\t\tthis.pluginApiNames.add(name)\n\t}\n\n\t/**\n\t * APIs plugins have mounted, reported to the UI so a module can hide itself when the plugin that\n\t * backs it is not installed. Read when the shell is rendered, not when it is constructed, so a\n\t * plugin registering after the panel is still counted.\n\t */\n\tpublic get pluginApis(): readonly string[] {\n\t\treturn [...this.pluginApiNames].sort()\n\t}\n}\n"],"names":[],"mappings":";;;AASO,MAAM,WAAoC;AAAA,EAGhD,YACiB,UACA,QAEA,KACf;AAJe,SAAA,WAAA;AACA,SAAA,SAAA;AAEA,SAAA,MAAA;AANjB,kBAAA,MAAiB,sCAAqB,IAAA,CAAY;AAAA,EAQlD;AAAA,EAEO,MAAM,aAAkC,EAAE,MAAM,MAAM,YAAY,sBAA+C;AACvH,gBAAY,SAAS,aAAa,GAAG,KAAK,QAAQ,QAAQ,IAAI,IAAI,KAAK,IAAI,OAAO,YAAY,EAAE,gBAAgB,OAAO,GAAG,EAAE,oBAAoB;AAChJ,SAAK,eAAe,IAAI,IAAI;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAW,aAAgC;AAC1C,WAAO,CAAC,GAAG,KAAK,cAAc,EAAE,KAAA;AAAA,EACjC;AACD;"}
|
|
@@ -37,7 +37,9 @@ class PanelPlugin {
|
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
39
|
const { basePath, api } = panelApiMount;
|
|
40
|
-
it.addRoute("panel-api", `${basePath}/api/tenant`, api.create(tenantApiMiddlewareFactory.create(), { allowAnonymous: true })
|
|
40
|
+
it.addRoute("panel-api", `${basePath}/api/tenant`, api.create(tenantApiMiddlewareFactory.create(), { allowAnonymous: true }), {
|
|
41
|
+
carriesCredentials: true
|
|
42
|
+
});
|
|
41
43
|
it.addRoute(
|
|
42
44
|
"panel-api",
|
|
43
45
|
`${basePath}/api/content/:projectSlug/:stageSlug`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelPlugin.cjs","sources":["../../../../packages/engine-panel/src/PanelPlugin.ts"],"sourcesContent":["import type { MasterContainerBuilder, MasterContainerHook, Plugin } from '@contember/engine-http'\nimport { panelAssets } from './generated/assets.js'\nimport { ConfiguredPanelAccessCheck } from './PanelAccessCheck.js'\nimport { PanelApiControllerFactory } from './PanelApiController.js'\nimport { PanelAssetStore } from './PanelAssets.js'\nimport { PanelController } from './PanelController.js'\nimport { PanelMount } from './PanelMount.js'\n\nconst defaultBasePath = '/panel'\n\nexport class PanelPlugin implements Plugin {\n\tname = 'contember/panel'\n\n\tgetMasterContainerHook(): MasterContainerHook {\n\t\treturn (builder: MasterContainerBuilder) =>\n\t\t\tbuilder\n\t\t\t\t.replaceService('panelApiMount', ({ serverConfig, logger, inner }) => {\n\t\t\t\t\tif (serverConfig.panel?.enabled !== true) {\n\t\t\t\t\t\treturn inner\n\t\t\t\t\t}\n\t\t\t\t\tconst assets = new PanelAssetStore(panelAssets)\n\t\t\t\t\tif (assets.isEmpty()) {\n\t\t\t\t\t\t// Running from source without the build step. A released build cannot get here —\n\t\t\t\t\t\t// `scripts/buildAssets.ts` fails when the panel produced nothing — so this is a\n\t\t\t\t\t\t// developer's checkout, and refusing to start would be a poor trade.\n\t\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t'The panel is enabled but this build contains no panel assets — run `bun run --filter=@contember/engine-panel build:assets`. Not serving the panel.',\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\t\t\treturn inner\n\t\t\t\t\t}\n\t\t\t\t\tconst basePath = normalizeBasePath(serverConfig.panel.path ?? defaultBasePath)\n\t\t\t\t\treturn new PanelMount(basePath, assets, new PanelApiControllerFactory(new ConfiguredPanelAccessCheck()))\n\t\t\t\t})\n\t\t\t\t.setupService(\n\t\t\t\t\t'application',\n\t\t\t\t\t(it, { panelApiMount, tenantApiMiddlewareFactory, contentApiMiddlewareFactory, systemApiMiddlewareFactory }) => {\n\t\t\t\t\t\tif (!(panelApiMount instanceof PanelMount)) {\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst { basePath, api } = panelApiMount\n\n\t\t\t\t\t\t// The panel's own API mount, mirroring the public paths so the client's existing URL\n\t\t\t\t\t\t// building (`${apiBaseUrl}${path}`) needs no special cases. Only tenant takes anonymous\n\t\t\t\t\t\t// callers — it is the one the sign-in screen talks to before there is a session.\n\t\t\t\t\t\t// Content and system have no pre-sign-in consumer.\n\t\t\t\t\t\tit.addRoute('panel-api', `${basePath}/api/tenant`, api.create(tenantApiMiddlewareFactory.create(), { allowAnonymous: true }))\n\t\t\t\t\t\tit.addRoute(\n\t\t\t\t\t\t\t'panel-api',\n\t\t\t\t\t\t\t`${basePath}/api/content/:projectSlug/:stageSlug`,\n\t\t\t\t\t\t\tapi.create(contentApiMiddlewareFactory.create(), { allowAnonymous: false }),\n\t\t\t\t\t\t)\n\t\t\t\t\t\tit.addRoute('panel-api', `${basePath}/api/system/:projectSlug`, api.create(systemApiMiddlewareFactory.create(), { allowAnonymous: false }))\n\n\t\t\t\t\t\tconst controller = new PanelController({\n\t\t\t\t\t\t\tbasePath,\n\t\t\t\t\t\t\tapiBaseUrl: `${basePath}/api`,\n\t\t\t\t\t\t\tassets: panelApiMount.assets,\n\t\t\t\t\t\t\tpluginApis: () => panelApiMount.pluginApis,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t// Optional trailing group so both `/panel` and `/panel/anything` are served. An API route\n\t\t\t\t\t\t// is a regular route and the shell an internal one, so `/panel/api/...` is matched first\n\t\t\t\t\t\t// however late a plugin registers it.\n\t\t\t\t\t\tit.addInternalRoute('panel', `${basePath}{/*path}`, controller.create())\n\t\t\t\t\t},\n\t\t\t\t)\n\t}\n}\n\nconst normalizeBasePath = (path: string): string => {\n\tconst trimmed = path.trim().replace(/\\/+$/, '')\n\tif (!trimmed.startsWith('/') || trimmed.length < 2) {\n\t\tthrow new Error(`Invalid CONTEMBER_PANEL_PATH ${JSON.stringify(path)}: expecting an absolute path like \"/panel\".`)\n\t}\n\treturn trimmed\n}\n"],"names":["assets","PanelAssetStore","panelAssets","PanelMount","PanelApiControllerFactory","ConfiguredPanelAccessCheck","PanelController"],"mappings":";;;;;;;;;;;AAQA,MAAM,kBAAkB;AAEjB,MAAM,YAA8B;AAAA,EAApC,cAAA;AACN,kBAAA,MAAA,QAAO,iBAAA;AAAA,EAAA;AAAA,EAEP,yBAA8C;AAC7C,WAAO,CAAC,YACP,QACE,eAAe,iBAAiB,CAAC,EAAE,cAAc,QAAQ,YAAY;AACrE,UAAI,aAAa,OAAO,YAAY,MAAM;AACzC,eAAO;AAAA,MACR;AACA,YAAMA,WAAS,IAAIC,YAAAA,gBAAgBC,kBAAW;AAC9C,UAAIF,SAAO,WAAW;AAIrB,eAAO;AAAA,UACN,IAAI;AAAA,YACH;AAAA,UAAA;AAAA,QACD;AAED,eAAO;AAAA,MACR;AACA,YAAM,WAAW,kBAAkB,aAAa,MAAM,QAAQ,eAAe;AAC7E,aAAO,IAAIG,WAAAA,WAAW,UAAUH,UAAQ,IAAII,6CAA0B,IAAIC,iBAAAA,2BAAA,CAA4B,CAAC;AAAA,IACxG,CAAC,EACA;AAAA,MACA;AAAA,MACA,CAAC,IAAI,EAAE,eAAe,4BAA4B,6BAA6B,iCAAiC;AAC/G,YAAI,EAAE,yBAAyBF,WAAAA,aAAa;AAC3C;AAAA,QACD;AACA,cAAM,EAAE,UAAU,IAAA,IAAQ;AAM1B,WAAG,SAAS,aAAa,GAAG,QAAQ,eAAe,IAAI,OAAO,2BAA2B,OAAA,GAAU,EAAE,gBAAgB,KAAA,CAAM,
|
|
1
|
+
{"version":3,"file":"PanelPlugin.cjs","sources":["../../../../packages/engine-panel/src/PanelPlugin.ts"],"sourcesContent":["import type { MasterContainerBuilder, MasterContainerHook, Plugin } from '@contember/engine-http'\nimport { panelAssets } from './generated/assets.js'\nimport { ConfiguredPanelAccessCheck } from './PanelAccessCheck.js'\nimport { PanelApiControllerFactory } from './PanelApiController.js'\nimport { PanelAssetStore } from './PanelAssets.js'\nimport { PanelController } from './PanelController.js'\nimport { PanelMount } from './PanelMount.js'\n\nconst defaultBasePath = '/panel'\n\nexport class PanelPlugin implements Plugin {\n\tname = 'contember/panel'\n\n\tgetMasterContainerHook(): MasterContainerHook {\n\t\treturn (builder: MasterContainerBuilder) =>\n\t\t\tbuilder\n\t\t\t\t.replaceService('panelApiMount', ({ serverConfig, logger, inner }) => {\n\t\t\t\t\tif (serverConfig.panel?.enabled !== true) {\n\t\t\t\t\t\treturn inner\n\t\t\t\t\t}\n\t\t\t\t\tconst assets = new PanelAssetStore(panelAssets)\n\t\t\t\t\tif (assets.isEmpty()) {\n\t\t\t\t\t\t// Running from source without the build step. A released build cannot get here —\n\t\t\t\t\t\t// `scripts/buildAssets.ts` fails when the panel produced nothing — so this is a\n\t\t\t\t\t\t// developer's checkout, and refusing to start would be a poor trade.\n\t\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t'The panel is enabled but this build contains no panel assets — run `bun run --filter=@contember/engine-panel build:assets`. Not serving the panel.',\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\t\t\treturn inner\n\t\t\t\t\t}\n\t\t\t\t\tconst basePath = normalizeBasePath(serverConfig.panel.path ?? defaultBasePath)\n\t\t\t\t\treturn new PanelMount(basePath, assets, new PanelApiControllerFactory(new ConfiguredPanelAccessCheck()))\n\t\t\t\t})\n\t\t\t\t.setupService(\n\t\t\t\t\t'application',\n\t\t\t\t\t(it, { panelApiMount, tenantApiMiddlewareFactory, contentApiMiddlewareFactory, systemApiMiddlewareFactory }) => {\n\t\t\t\t\t\tif (!(panelApiMount instanceof PanelMount)) {\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst { basePath, api } = panelApiMount\n\n\t\t\t\t\t\t// The panel's own API mount, mirroring the public paths so the client's existing URL\n\t\t\t\t\t\t// building (`${apiBaseUrl}${path}`) needs no special cases. Only tenant takes anonymous\n\t\t\t\t\t\t// callers — it is the one the sign-in screen talks to before there is a session.\n\t\t\t\t\t\t// Content and system have no pre-sign-in consumer.\n\t\t\t\t\t\tit.addRoute('panel-api', `${basePath}/api/tenant`, api.create(tenantApiMiddlewareFactory.create(), { allowAnonymous: true }), {\n\t\t\t\t\t\t\tcarriesCredentials: true,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tit.addRoute(\n\t\t\t\t\t\t\t'panel-api',\n\t\t\t\t\t\t\t`${basePath}/api/content/:projectSlug/:stageSlug`,\n\t\t\t\t\t\t\tapi.create(contentApiMiddlewareFactory.create(), { allowAnonymous: false }),\n\t\t\t\t\t\t)\n\t\t\t\t\t\tit.addRoute('panel-api', `${basePath}/api/system/:projectSlug`, api.create(systemApiMiddlewareFactory.create(), { allowAnonymous: false }))\n\n\t\t\t\t\t\tconst controller = new PanelController({\n\t\t\t\t\t\t\tbasePath,\n\t\t\t\t\t\t\tapiBaseUrl: `${basePath}/api`,\n\t\t\t\t\t\t\tassets: panelApiMount.assets,\n\t\t\t\t\t\t\tpluginApis: () => panelApiMount.pluginApis,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t// Optional trailing group so both `/panel` and `/panel/anything` are served. An API route\n\t\t\t\t\t\t// is a regular route and the shell an internal one, so `/panel/api/...` is matched first\n\t\t\t\t\t\t// however late a plugin registers it.\n\t\t\t\t\t\tit.addInternalRoute('panel', `${basePath}{/*path}`, controller.create())\n\t\t\t\t\t},\n\t\t\t\t)\n\t}\n}\n\nconst normalizeBasePath = (path: string): string => {\n\tconst trimmed = path.trim().replace(/\\/+$/, '')\n\tif (!trimmed.startsWith('/') || trimmed.length < 2) {\n\t\tthrow new Error(`Invalid CONTEMBER_PANEL_PATH ${JSON.stringify(path)}: expecting an absolute path like \"/panel\".`)\n\t}\n\treturn trimmed\n}\n"],"names":["assets","PanelAssetStore","panelAssets","PanelMount","PanelApiControllerFactory","ConfiguredPanelAccessCheck","PanelController"],"mappings":";;;;;;;;;;;AAQA,MAAM,kBAAkB;AAEjB,MAAM,YAA8B;AAAA,EAApC,cAAA;AACN,kBAAA,MAAA,QAAO,iBAAA;AAAA,EAAA;AAAA,EAEP,yBAA8C;AAC7C,WAAO,CAAC,YACP,QACE,eAAe,iBAAiB,CAAC,EAAE,cAAc,QAAQ,YAAY;AACrE,UAAI,aAAa,OAAO,YAAY,MAAM;AACzC,eAAO;AAAA,MACR;AACA,YAAMA,WAAS,IAAIC,YAAAA,gBAAgBC,kBAAW;AAC9C,UAAIF,SAAO,WAAW;AAIrB,eAAO;AAAA,UACN,IAAI;AAAA,YACH;AAAA,UAAA;AAAA,QACD;AAED,eAAO;AAAA,MACR;AACA,YAAM,WAAW,kBAAkB,aAAa,MAAM,QAAQ,eAAe;AAC7E,aAAO,IAAIG,WAAAA,WAAW,UAAUH,UAAQ,IAAII,6CAA0B,IAAIC,iBAAAA,2BAAA,CAA4B,CAAC;AAAA,IACxG,CAAC,EACA;AAAA,MACA;AAAA,MACA,CAAC,IAAI,EAAE,eAAe,4BAA4B,6BAA6B,iCAAiC;AAC/G,YAAI,EAAE,yBAAyBF,WAAAA,aAAa;AAC3C;AAAA,QACD;AACA,cAAM,EAAE,UAAU,IAAA,IAAQ;AAM1B,WAAG,SAAS,aAAa,GAAG,QAAQ,eAAe,IAAI,OAAO,2BAA2B,OAAA,GAAU,EAAE,gBAAgB,KAAA,CAAM,GAAG;AAAA,UAC7H,oBAAoB;AAAA,QAAA,CACpB;AACD,WAAG;AAAA,UACF;AAAA,UACA,GAAG,QAAQ;AAAA,UACX,IAAI,OAAO,4BAA4B,OAAA,GAAU,EAAE,gBAAgB,OAAO;AAAA,QAAA;AAE3E,WAAG,SAAS,aAAa,GAAG,QAAQ,4BAA4B,IAAI,OAAO,2BAA2B,OAAA,GAAU,EAAE,gBAAgB,MAAA,CAAO,CAAC;AAE1I,cAAM,aAAa,IAAIG,gCAAgB;AAAA,UACtC;AAAA,UACA,YAAY,GAAG,QAAQ;AAAA,UACvB,QAAQ,cAAc;AAAA,UACtB,YAAY,MAAM,cAAc;AAAA,QAAA,CAChC;AAID,WAAG,iBAAiB,SAAS,GAAG,QAAQ,YAAY,WAAW,QAAQ;AAAA,MACxE;AAAA,IAAA;AAAA,EAEJ;AACD;AAEA,MAAM,oBAAoB,CAAC,SAAyB;AACnD,QAAM,UAAU,KAAK,KAAA,EAAO,QAAQ,QAAQ,EAAE;AAC9C,MAAI,CAAC,QAAQ,WAAW,GAAG,KAAK,QAAQ,SAAS,GAAG;AACnD,UAAM,IAAI,MAAM,gCAAgC,KAAK,UAAU,IAAI,CAAC,6CAA6C;AAAA,EAClH;AACA,SAAO;AACR;;"}
|
|
@@ -35,7 +35,9 @@ class PanelPlugin {
|
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
const { basePath, api } = panelApiMount;
|
|
38
|
-
it.addRoute("panel-api", `${basePath}/api/tenant`, api.create(tenantApiMiddlewareFactory.create(), { allowAnonymous: true })
|
|
38
|
+
it.addRoute("panel-api", `${basePath}/api/tenant`, api.create(tenantApiMiddlewareFactory.create(), { allowAnonymous: true }), {
|
|
39
|
+
carriesCredentials: true
|
|
40
|
+
});
|
|
39
41
|
it.addRoute(
|
|
40
42
|
"panel-api",
|
|
41
43
|
`${basePath}/api/content/:projectSlug/:stageSlug`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelPlugin.js","sources":["../../../../packages/engine-panel/src/PanelPlugin.ts"],"sourcesContent":["import type { MasterContainerBuilder, MasterContainerHook, Plugin } from '@contember/engine-http'\nimport { panelAssets } from './generated/assets.js'\nimport { ConfiguredPanelAccessCheck } from './PanelAccessCheck.js'\nimport { PanelApiControllerFactory } from './PanelApiController.js'\nimport { PanelAssetStore } from './PanelAssets.js'\nimport { PanelController } from './PanelController.js'\nimport { PanelMount } from './PanelMount.js'\n\nconst defaultBasePath = '/panel'\n\nexport class PanelPlugin implements Plugin {\n\tname = 'contember/panel'\n\n\tgetMasterContainerHook(): MasterContainerHook {\n\t\treturn (builder: MasterContainerBuilder) =>\n\t\t\tbuilder\n\t\t\t\t.replaceService('panelApiMount', ({ serverConfig, logger, inner }) => {\n\t\t\t\t\tif (serverConfig.panel?.enabled !== true) {\n\t\t\t\t\t\treturn inner\n\t\t\t\t\t}\n\t\t\t\t\tconst assets = new PanelAssetStore(panelAssets)\n\t\t\t\t\tif (assets.isEmpty()) {\n\t\t\t\t\t\t// Running from source without the build step. A released build cannot get here —\n\t\t\t\t\t\t// `scripts/buildAssets.ts` fails when the panel produced nothing — so this is a\n\t\t\t\t\t\t// developer's checkout, and refusing to start would be a poor trade.\n\t\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t'The panel is enabled but this build contains no panel assets — run `bun run --filter=@contember/engine-panel build:assets`. Not serving the panel.',\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\t\t\treturn inner\n\t\t\t\t\t}\n\t\t\t\t\tconst basePath = normalizeBasePath(serverConfig.panel.path ?? defaultBasePath)\n\t\t\t\t\treturn new PanelMount(basePath, assets, new PanelApiControllerFactory(new ConfiguredPanelAccessCheck()))\n\t\t\t\t})\n\t\t\t\t.setupService(\n\t\t\t\t\t'application',\n\t\t\t\t\t(it, { panelApiMount, tenantApiMiddlewareFactory, contentApiMiddlewareFactory, systemApiMiddlewareFactory }) => {\n\t\t\t\t\t\tif (!(panelApiMount instanceof PanelMount)) {\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst { basePath, api } = panelApiMount\n\n\t\t\t\t\t\t// The panel's own API mount, mirroring the public paths so the client's existing URL\n\t\t\t\t\t\t// building (`${apiBaseUrl}${path}`) needs no special cases. Only tenant takes anonymous\n\t\t\t\t\t\t// callers — it is the one the sign-in screen talks to before there is a session.\n\t\t\t\t\t\t// Content and system have no pre-sign-in consumer.\n\t\t\t\t\t\tit.addRoute('panel-api', `${basePath}/api/tenant`, api.create(tenantApiMiddlewareFactory.create(), { allowAnonymous: true }))\n\t\t\t\t\t\tit.addRoute(\n\t\t\t\t\t\t\t'panel-api',\n\t\t\t\t\t\t\t`${basePath}/api/content/:projectSlug/:stageSlug`,\n\t\t\t\t\t\t\tapi.create(contentApiMiddlewareFactory.create(), { allowAnonymous: false }),\n\t\t\t\t\t\t)\n\t\t\t\t\t\tit.addRoute('panel-api', `${basePath}/api/system/:projectSlug`, api.create(systemApiMiddlewareFactory.create(), { allowAnonymous: false }))\n\n\t\t\t\t\t\tconst controller = new PanelController({\n\t\t\t\t\t\t\tbasePath,\n\t\t\t\t\t\t\tapiBaseUrl: `${basePath}/api`,\n\t\t\t\t\t\t\tassets: panelApiMount.assets,\n\t\t\t\t\t\t\tpluginApis: () => panelApiMount.pluginApis,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t// Optional trailing group so both `/panel` and `/panel/anything` are served. An API route\n\t\t\t\t\t\t// is a regular route and the shell an internal one, so `/panel/api/...` is matched first\n\t\t\t\t\t\t// however late a plugin registers it.\n\t\t\t\t\t\tit.addInternalRoute('panel', `${basePath}{/*path}`, controller.create())\n\t\t\t\t\t},\n\t\t\t\t)\n\t}\n}\n\nconst normalizeBasePath = (path: string): string => {\n\tconst trimmed = path.trim().replace(/\\/+$/, '')\n\tif (!trimmed.startsWith('/') || trimmed.length < 2) {\n\t\tthrow new Error(`Invalid CONTEMBER_PANEL_PATH ${JSON.stringify(path)}: expecting an absolute path like \"/panel\".`)\n\t}\n\treturn trimmed\n}\n"],"names":[],"mappings":";;;;;;;;;AAQA,MAAM,kBAAkB;AAEjB,MAAM,YAA8B;AAAA,EAApC,cAAA;AACN,kBAAA,MAAA,QAAO,iBAAA;AAAA,EAAA;AAAA,EAEP,yBAA8C;AAC7C,WAAO,CAAC,YACP,QACE,eAAe,iBAAiB,CAAC,EAAE,cAAc,QAAQ,YAAY;AACrE,UAAI,aAAa,OAAO,YAAY,MAAM;AACzC,eAAO;AAAA,MACR;AACA,YAAM,SAAS,IAAI,gBAAgB,WAAW;AAC9C,UAAI,OAAO,WAAW;AAIrB,eAAO;AAAA,UACN,IAAI;AAAA,YACH;AAAA,UAAA;AAAA,QACD;AAED,eAAO;AAAA,MACR;AACA,YAAM,WAAW,kBAAkB,aAAa,MAAM,QAAQ,eAAe;AAC7E,aAAO,IAAI,WAAW,UAAU,QAAQ,IAAI,0BAA0B,IAAI,2BAAA,CAA4B,CAAC;AAAA,IACxG,CAAC,EACA;AAAA,MACA;AAAA,MACA,CAAC,IAAI,EAAE,eAAe,4BAA4B,6BAA6B,iCAAiC;AAC/G,YAAI,EAAE,yBAAyB,aAAa;AAC3C;AAAA,QACD;AACA,cAAM,EAAE,UAAU,IAAA,IAAQ;AAM1B,WAAG,SAAS,aAAa,GAAG,QAAQ,eAAe,IAAI,OAAO,2BAA2B,OAAA,GAAU,EAAE,gBAAgB,KAAA,CAAM,
|
|
1
|
+
{"version":3,"file":"PanelPlugin.js","sources":["../../../../packages/engine-panel/src/PanelPlugin.ts"],"sourcesContent":["import type { MasterContainerBuilder, MasterContainerHook, Plugin } from '@contember/engine-http'\nimport { panelAssets } from './generated/assets.js'\nimport { ConfiguredPanelAccessCheck } from './PanelAccessCheck.js'\nimport { PanelApiControllerFactory } from './PanelApiController.js'\nimport { PanelAssetStore } from './PanelAssets.js'\nimport { PanelController } from './PanelController.js'\nimport { PanelMount } from './PanelMount.js'\n\nconst defaultBasePath = '/panel'\n\nexport class PanelPlugin implements Plugin {\n\tname = 'contember/panel'\n\n\tgetMasterContainerHook(): MasterContainerHook {\n\t\treturn (builder: MasterContainerBuilder) =>\n\t\t\tbuilder\n\t\t\t\t.replaceService('panelApiMount', ({ serverConfig, logger, inner }) => {\n\t\t\t\t\tif (serverConfig.panel?.enabled !== true) {\n\t\t\t\t\t\treturn inner\n\t\t\t\t\t}\n\t\t\t\t\tconst assets = new PanelAssetStore(panelAssets)\n\t\t\t\t\tif (assets.isEmpty()) {\n\t\t\t\t\t\t// Running from source without the build step. A released build cannot get here —\n\t\t\t\t\t\t// `scripts/buildAssets.ts` fails when the panel produced nothing — so this is a\n\t\t\t\t\t\t// developer's checkout, and refusing to start would be a poor trade.\n\t\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t\t'The panel is enabled but this build contains no panel assets — run `bun run --filter=@contember/engine-panel build:assets`. Not serving the panel.',\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\t\t\treturn inner\n\t\t\t\t\t}\n\t\t\t\t\tconst basePath = normalizeBasePath(serverConfig.panel.path ?? defaultBasePath)\n\t\t\t\t\treturn new PanelMount(basePath, assets, new PanelApiControllerFactory(new ConfiguredPanelAccessCheck()))\n\t\t\t\t})\n\t\t\t\t.setupService(\n\t\t\t\t\t'application',\n\t\t\t\t\t(it, { panelApiMount, tenantApiMiddlewareFactory, contentApiMiddlewareFactory, systemApiMiddlewareFactory }) => {\n\t\t\t\t\t\tif (!(panelApiMount instanceof PanelMount)) {\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst { basePath, api } = panelApiMount\n\n\t\t\t\t\t\t// The panel's own API mount, mirroring the public paths so the client's existing URL\n\t\t\t\t\t\t// building (`${apiBaseUrl}${path}`) needs no special cases. Only tenant takes anonymous\n\t\t\t\t\t\t// callers — it is the one the sign-in screen talks to before there is a session.\n\t\t\t\t\t\t// Content and system have no pre-sign-in consumer.\n\t\t\t\t\t\tit.addRoute('panel-api', `${basePath}/api/tenant`, api.create(tenantApiMiddlewareFactory.create(), { allowAnonymous: true }), {\n\t\t\t\t\t\t\tcarriesCredentials: true,\n\t\t\t\t\t\t})\n\t\t\t\t\t\tit.addRoute(\n\t\t\t\t\t\t\t'panel-api',\n\t\t\t\t\t\t\t`${basePath}/api/content/:projectSlug/:stageSlug`,\n\t\t\t\t\t\t\tapi.create(contentApiMiddlewareFactory.create(), { allowAnonymous: false }),\n\t\t\t\t\t\t)\n\t\t\t\t\t\tit.addRoute('panel-api', `${basePath}/api/system/:projectSlug`, api.create(systemApiMiddlewareFactory.create(), { allowAnonymous: false }))\n\n\t\t\t\t\t\tconst controller = new PanelController({\n\t\t\t\t\t\t\tbasePath,\n\t\t\t\t\t\t\tapiBaseUrl: `${basePath}/api`,\n\t\t\t\t\t\t\tassets: panelApiMount.assets,\n\t\t\t\t\t\t\tpluginApis: () => panelApiMount.pluginApis,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t// Optional trailing group so both `/panel` and `/panel/anything` are served. An API route\n\t\t\t\t\t\t// is a regular route and the shell an internal one, so `/panel/api/...` is matched first\n\t\t\t\t\t\t// however late a plugin registers it.\n\t\t\t\t\t\tit.addInternalRoute('panel', `${basePath}{/*path}`, controller.create())\n\t\t\t\t\t},\n\t\t\t\t)\n\t}\n}\n\nconst normalizeBasePath = (path: string): string => {\n\tconst trimmed = path.trim().replace(/\\/+$/, '')\n\tif (!trimmed.startsWith('/') || trimmed.length < 2) {\n\t\tthrow new Error(`Invalid CONTEMBER_PANEL_PATH ${JSON.stringify(path)}: expecting an absolute path like \"/panel\".`)\n\t}\n\treturn trimmed\n}\n"],"names":[],"mappings":";;;;;;;;;AAQA,MAAM,kBAAkB;AAEjB,MAAM,YAA8B;AAAA,EAApC,cAAA;AACN,kBAAA,MAAA,QAAO,iBAAA;AAAA,EAAA;AAAA,EAEP,yBAA8C;AAC7C,WAAO,CAAC,YACP,QACE,eAAe,iBAAiB,CAAC,EAAE,cAAc,QAAQ,YAAY;AACrE,UAAI,aAAa,OAAO,YAAY,MAAM;AACzC,eAAO;AAAA,MACR;AACA,YAAM,SAAS,IAAI,gBAAgB,WAAW;AAC9C,UAAI,OAAO,WAAW;AAIrB,eAAO;AAAA,UACN,IAAI;AAAA,YACH;AAAA,UAAA;AAAA,QACD;AAED,eAAO;AAAA,MACR;AACA,YAAM,WAAW,kBAAkB,aAAa,MAAM,QAAQ,eAAe;AAC7E,aAAO,IAAI,WAAW,UAAU,QAAQ,IAAI,0BAA0B,IAAI,2BAAA,CAA4B,CAAC;AAAA,IACxG,CAAC,EACA;AAAA,MACA;AAAA,MACA,CAAC,IAAI,EAAE,eAAe,4BAA4B,6BAA6B,iCAAiC;AAC/G,YAAI,EAAE,yBAAyB,aAAa;AAC3C;AAAA,QACD;AACA,cAAM,EAAE,UAAU,IAAA,IAAQ;AAM1B,WAAG,SAAS,aAAa,GAAG,QAAQ,eAAe,IAAI,OAAO,2BAA2B,OAAA,GAAU,EAAE,gBAAgB,KAAA,CAAM,GAAG;AAAA,UAC7H,oBAAoB;AAAA,QAAA,CACpB;AACD,WAAG;AAAA,UACF;AAAA,UACA,GAAG,QAAQ;AAAA,UACX,IAAI,OAAO,4BAA4B,OAAA,GAAU,EAAE,gBAAgB,OAAO;AAAA,QAAA;AAE3E,WAAG,SAAS,aAAa,GAAG,QAAQ,4BAA4B,IAAI,OAAO,2BAA2B,OAAA,GAAU,EAAE,gBAAgB,MAAA,CAAO,CAAC;AAE1I,cAAM,aAAa,IAAI,gBAAgB;AAAA,UACtC;AAAA,UACA,YAAY,GAAG,QAAQ;AAAA,UACvB,QAAQ,cAAc;AAAA,UACtB,YAAY,MAAM,cAAc;AAAA,QAAA,CAChC;AAID,WAAG,iBAAiB,SAAS,GAAG,QAAQ,YAAY,WAAW,QAAQ;AAAA,MACxE;AAAA,IAAA;AAAA,EAEJ;AACD;AAEA,MAAM,oBAAoB,CAAC,SAAyB;AACnD,QAAM,UAAU,KAAK,KAAA,EAAO,QAAQ,QAAQ,EAAE;AAC9C,MAAI,CAAC,QAAQ,WAAW,GAAG,KAAK,QAAQ,SAAS,GAAG;AACnD,UAAM,IAAI,MAAM,gCAAgC,KAAK,UAAU,IAAI,CAAC,6CAA6C;AAAA,EAClH;AACA,SAAO;AACR;"}
|