import { PASSWORD_MAX_LENGTH, TOKEN_MAX_LENGTH } from "./base";
import { LambdaInvoker } from "./LambdaInvoker";

const setNewPassword = new LambdaInvoker("user", "setNewPassword", {
  type: "object",
  properties: {
    username: { type: "string", format: "email" },
    password: { type: "string", maxLength: PASSWORD_MAX_LENGTH },
    session: { type: "string", maxLength: TOKEN_MAX_LENGTH },
  },
  required: ["username", "password"],
});

const userSignUp = new LambdaInvoker("user", "signUp", {
  type: "object",
  properties: {
    username: { type: "string", format: "email" },
    password: { type: "string", maxLength: PASSWORD_MAX_LENGTH },
  },
  required: ["username", "password"],
});

const confirmSignUp = new LambdaInvoker("user", "confirmSignUp", {
  type: "object",
  properties: {
    username: { type: "string", format: "email" },
    confirmationCode: { type: "string", maxLength: TOKEN_MAX_LENGTH },
  },
  required: ["username", "confirmationCode"],
});

const refreshAccessToken = new LambdaInvoker("user", "refreshAccessToken", {
  type: "object",
  properties: {
    refreshToken: { type: "string", maxLength: TOKEN_MAX_LENGTH },
  },
  required: ["refreshToken"],
});

const getAccessToken = new LambdaInvoker("user", "getAccessToken", {
  type: "object",
  properties: {
    username: { type: "string", format: "email" },
    password: { type: "string", maxLength: PASSWORD_MAX_LENGTH },
  },
  required: ["username", "password"],
});

const getUser = new LambdaInvoker("user", "get", {
  type: "object",
  properties: {
    accessToken: { type: "string", maxLength: TOKEN_MAX_LENGTH },
  },
  required: ["accessToken"],
});

const getUserGroups = new LambdaInvoker("user", "getGroups", {
  type: "object",
  properties: {
    username: { type: "string" },
  },
  required: ["username"],
});

export {
  setNewPassword,
  userSignUp,
  confirmSignUp,
  refreshAccessToken,
  getAccessToken,
  getUser,
  getUserGroups,
};
