edgedb-js icon indicating copy to clipboard operation
edgedb-js copied to clipboard

ext::auth::ClientTokenIdentity has wrong cardinality type and type does not exist error

Open voxspox opened this issue 6 months ago • 4 comments

Code

The code causing the error.

const query = 
    e.insert(e.User, {
      name: "user",
      identity: e.ext.auth.ClientTokenIdentity,
    })

Schema

Your application schema.

using extension auth;

module default {
  type User {
    required name: str;
    identity: ext::auth::Identity {
      constraint exclusive;
    };
  }
}

Error or desired behavior

For identity in the e.insert() statement, Typescript complains about:

Type 'Cardinality.Many' is not assignable to type 'Cardinality.AtMostOne | Cardinality.One | Cardinality.Empty

Expected behavior: According to its definition, I think ClientTokenIdentity should have Cardinality.AtMostOne instead of Many:

<project>/dbschema/edgeql-js/modules/ext/auth.ts

const ClientTokenIdentity: $.$expr_PathNode<$.TypeSet<$ClientTokenIdentity, $.Cardinality.Many>, null> = _.syntax.$PathNode($.$toSet($ClientTokenIdentity, $.Cardinality.Many), null);

<gel-source>/edb/lib/ext/auth.edgeql

    create single global ext::auth::ClientTokenIdentity := (
        with
            ...
        select
            ext::auth::Identity
        filter
            .id = <uuid>json_get(jwt.claims, "sub")
    );

Versions:

voxspox avatar Apr 07 '25 10:04 voxspox