fix(core): update
This commit is contained in:
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@apiclient.xyz/zitadel',
|
||||
version: '1.0.2',
|
||||
description: 'an unofficial zitadel client'
|
||||
}
|
47
ts/classes.zitadelclient.ts
Normal file
47
ts/classes.zitadelclient.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import { ZitaldelUser } from './classes.zitadeluser.js';
|
||||
import * as plugins from './zitadel.plugins.js';
|
||||
|
||||
export interface IZitadelContructorOptions {
|
||||
url: string;
|
||||
accessToken: string;
|
||||
}
|
||||
|
||||
export class ZitaldelClient {
|
||||
private options: IZitadelContructorOptions;
|
||||
public authClient: plugins.zitadel.AuthServiceClient;
|
||||
public userClient: plugins.zitadel.UserServiceClient;
|
||||
|
||||
constructor(optionsArg: IZitadelContructorOptions) {
|
||||
this.options = optionsArg;
|
||||
console.log(this.options);
|
||||
this.authClient = plugins.zitadel.createAuthClient(
|
||||
this.options.url,
|
||||
plugins.zitadel.createAccessTokenInterceptor(this.options.accessToken)
|
||||
);
|
||||
this.userClient = plugins.zitadel.createUserClient(
|
||||
this.options.url,
|
||||
plugins.zitadel.createAccessTokenInterceptor(this.options.accessToken)
|
||||
);
|
||||
}
|
||||
|
||||
public async listOwnUser() {
|
||||
const response = await this.authClient.getMyUser({});
|
||||
console.log(response.user)
|
||||
}
|
||||
|
||||
public async listUsers() {
|
||||
const response = await this.userClient.listUsers({});
|
||||
const returnArray: ZitaldelUser[] = [];
|
||||
for (const userObject of response.result) {
|
||||
returnArray.push(await ZitaldelUser.fromApiUserObject(userObject));
|
||||
}
|
||||
return returnArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* invites a new user by email
|
||||
*/
|
||||
public async inviteNewUserByEmail() {
|
||||
|
||||
}
|
||||
}
|
17
ts/classes.zitadeluser.ts
Normal file
17
ts/classes.zitadeluser.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import * as plugins from './zitadel.plugins.js';
|
||||
|
||||
export type IZitadelApiUserObject = plugins.tsclass.typeFest.AsyncReturnType<
|
||||
plugins.zitadel.UserServiceClient['listUsers']
|
||||
>['result'][0];
|
||||
|
||||
export class ZitaldelUser {
|
||||
// STATIC
|
||||
static async fromApiUserObject(apiUserObject: IZitadelApiUserObject) {
|
||||
const newUser = new ZitaldelUser();
|
||||
newUser.data = apiUserObject;
|
||||
return newUser;
|
||||
}
|
||||
|
||||
// INSTANCE
|
||||
data: IZitadelApiUserObject;
|
||||
}
|
2
ts/index.ts
Normal file
2
ts/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './classes.zitadelclient.js';
|
||||
export * from './classes.zitadeluser.js';
|
13
ts/zitadel.plugins.ts
Normal file
13
ts/zitadel.plugins.ts
Normal file
@ -0,0 +1,13 @@
|
||||
// @tsclass scope
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
||||
export {
|
||||
tsclass,
|
||||
}
|
||||
|
||||
// third party scope
|
||||
import * as zitadel from '@zitadel/node/api';
|
||||
|
||||
export {
|
||||
zitadel,
|
||||
}
|
Reference in New Issue
Block a user