@ords/core
Version:
Microservice architecture with service proposals in nodejs and typescript
162 lines (161 loc) • 4.12 kB
TypeScript
import { main } from './main.proposal';
export declare namespace auth {
/**
* Flags used in module to explain interactions
*/
namespace flag {
/**
* Error codes in module
*/
namespace error {
/**
* User was not found when a login was attempted
*/
const NO_USER_FOUND = "No user was found";
/**
* User allready exists when one was trying to be created
*/
const USER_EXISTS = "User already exists";
/**
* No valid auth information provided
*/
const NO_VALID_AUTH = "The auth information is not valid";
}
}
/**
* Datatypes used for authentication
*/
namespace types {
/**
* Usermeta describing a user
*/
type UserMeta = {
/**
* Can contain all sorts of keys with meta data
*/
[meta: string]: any;
/**
* Identifier of user is used to identify user
*/
id?: string;
};
/**
* Identifier of a active signed in session
*/
type SessionId = any;
/**
* User account identifier
*/
type AccountId = any;
}
/**
* Contets of the packet field in request
*/
namespace packages {
/**
* Existing meta data to match if a user already exist and new meta data
*/
type SignUp = {
[key: string]: any;
/**
* Existing metadata to verify do not exist on a user
*/
existing: types.UserMeta;
/**
* Meta to be used in a creation of a user
*/
meta: types.UserMeta;
};
/**
* Usermeta to be used for identification of a user
*/
type SignIn = types.UserMeta;
/**
* Validate a user sessions
*/
type Validate = {
session: types.SessionId;
};
/**
* Session id to be destroyed
*/
type SignOut = {
session: types.SessionId;
};
/**
* Identifier of what acount to remove
*/
type Remove = {
account: types.AccountId;
};
/**
* Patch of new meta and the target account
*/
type Patch = {
[key: string]: any;
/**
* Accout of user
*/
user: types.AccountId;
/**
* The key with values to be patched
*/
meta: types.UserMeta;
};
}
/**
* Expected returns from auth operations
*/
namespace Returns {
/**
* Give back an account identifier
*/
type SignUp = types.AccountId;
/**
* Passes the session
*/
type SignIn = types.SessionId;
/**
* Validated account id belonning to session
*/
type Validate = types.AccountId;
/**
* Success of operation
*/
type SignOut = Boolean;
/**
* Success of operation
*/
type Remove = Boolean;
/**
* Success of operation
*/
type Patch = Boolean;
}
interface Proposal {
/**
* Sign up a user if a specfic query is not met
*/
signUp: main.types.MicroService;
/**
* Sign in the specified user
*/
signIn: main.types.MicroService;
/**
* Sign out specific user session
*/
signOut: main.types.MicroService;
/**
* Removes a specfic user account from the system
*/
remove: main.types.MicroService;
/**
* Patch a user account with updated meta
*/
patch: main.types.MicroService;
/**
* Validate a session
*/
validate: main.types.MicroService;
}
}