import { NAME_MAX_LENGTH, NAME_MIN_LENGTH } from "./base";
import { LambdaInvoker } from "./LambdaInvoker";

const getScript = new LambdaInvoker("script", "get", {
  type: "object",
  properties: {
    package: {
      type: "object",
      properties: {
        name: {
          type: "string",
          format: "name",
          maxLength: NAME_MAX_LENGTH,
          minLength: NAME_MIN_LENGTH,
        },
        namespace: {
          type: "string",
          format: "name",
          maxLength: NAME_MAX_LENGTH,
          minLength: NAME_MIN_LENGTH,
        },
      },
      required: ["name"],
    },
    version: { type: "version", format: "semver" },
  },
  required: ["package", "version"],
});

const getScriptMetadata = new LambdaInvoker("script", "getMetadata", {
  type: "object",
  properties: {
    package: {
      type: "object",
      properties: {
        name: {
          type: "string",
          maxLength: NAME_MAX_LENGTH,
          minLength: NAME_MIN_LENGTH,
        },
        namespace: {
          type: "string",
          maxLength: NAME_MAX_LENGTH,
          minLength: NAME_MIN_LENGTH,
        },
      },
      required: ["name"],
    },
  },
  required: ["package"],
});

export { getScript, getScriptMetadata };
