janus-idp / backstage-plugins

Plugins for Backstage
https://janus-idp.io
Apache License 2.0
145 stars 147 forks source link

Typescript compilation errors for keycloak plugin #1002

Closed awsjim closed 2 weeks ago

awsjim commented 10 months ago

Describe the bug

I'm following the documentation to setup authn/authz with the janus-idp keycloak plugin as described at https://janus-idp.io/plugins/keycloak. After installing the plugin and modifying the catalog plugin file, typescript compilation fails to find a declaration of types for the plugins

Expected Behavior

yarn tsc should complete with no errors

What are the steps to reproduce this bug?

  1. Install a fresh Backstage: BACKSTAGE_APP_NAME=backstage npx -y -q @backstage/create-app@0.5.7 --path backstage
  2. Install the keycloak plugin: cd backstage && yarn --cwd packages/backend add @janus-idp/backstage-plugin-keycloak-backend
  3. Modify the packages/backend/src/plugins/catalog.ts file as described at https://janus-idp.io/plugins/keycloak
    
    import { CatalogBuilder } from '@backstage/plugin-catalog-backend';
    import { ScaffolderEntitiesProcessor } from '@backstage/plugin-catalog-backend-module-scaffolder-entity-model';
    import { Router } from 'express';
    import { PluginEnvironment } from '../types';
    + import { KeycloakOrgEntityProvider } from '@janus-idp/backstage-plugin-keycloak-backend';

export default async function createPlugin( env: PluginEnvironment, ): Promise { const builder = await CatalogBuilder.create(env); builder.addProcessor(new ScaffolderEntitiesProcessor());

Typescript compilation results:

yarn run v1.22.21
$ tsc
packages/backend/src/plugins/catalog.ts:5:43 - error TS7016: Could not find a declaration file for module '@janus-idp/backstage-plugin-keycloak-backend'. '/Users/username/tmp/backstage/node_modules/@janus-idp/backstage-plugin-keycloak-backend/dist/index.cjs.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/janus-idp__backstage-plugin-keycloak-backend` if it exists or add a new declaration (.d.ts) file containing `declare module '@janus-idp/backstage-plugin-keycloak-backend';`

5 import { KeycloakOrgEntityProvider } from '@janus-idp/backstage-plugin-keycloak-backend';
                                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 1 error in packages/backend/src/plugins/catalog.ts:5

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Versions of software used and environment

mikkeschiren commented 9 months ago

Confirmed here also.

oliverp commented 8 months ago

I double checked the versions and the 1.7.5 is introducing this effect. As workaround you can switch to 1.7.4 and it will compile just fine. I also recently saw the @redhat/backstage-plugin-keycloak-backend offer but noticed it's an outdated version containing a bug fetching only 100 rows. This is already fixed in the janus-idp version since 1.5 something. So keep away from that as well.

invincibleJai commented 8 months ago

yeah, it seems there is some issue with publishing

for 1.7.4, type definitions are generated and I can see index.d.ts https://www.npmjs.com/package/@janus-idp/backstage-plugin-keycloak-backend/v/1.7.4?activeTab=code

but from 1.7.5 onwards it's not there https://www.npmjs.com/package/@janus-idp/backstage-plugin-keycloak-backend/v/1.7.5?activeTab=code

mikkeschiren commented 4 months ago

Confirmed still missing in 1.9.9.

youngyol commented 3 months ago

It looks like the index.d.ts file is available from version 1.9.13. You can find more details and the latest version here: npm package link.

rhdh-bot commented 1 month ago

This issue has been closed due to the fact that the Janus community is being sunset.

For future plugin issues, please use https://github.com/backstage/community-plugins/issues

For future showcase issues, please use https://issues.redhat.com/browse/RHIDP

For more information on the sunset, see:

https://janus-idp.io/blog/2024/07/05/future-of-janus-community https://issues.redhat.com/browse/RHIDP-3690 https://issues.redhat.com/browse/RHIDP-1018