{"version":3,"file":"publish-manifest.mjs","names":[],"sources":["../../src/schemes/publish-manifest.ts"],"sourcesContent":["import type { JSONSchemaType } from 'ajv';\nimport Ajv from 'ajv';\n\nconst ajv = new Ajv();\n\n// FIXME: this could extend from @verdaccio/types but we need\n// schemas from @verdaccio/types to be able to validate them\ninterface Manifest {\n  name: string;\n  versions: object;\n  _attachments: object;\n}\n\nconst schema: JSONSchemaType<Manifest> = {\n  type: 'object',\n  properties: {\n    name: { type: 'string' },\n    versions: { type: 'object', maxProperties: 1 },\n    _attachments: { type: 'object', maxProperties: 1 },\n  },\n  required: ['name', 'versions', '_attachments'],\n  additionalProperties: true,\n};\n\n// validate is a type guard for MyData - type is inferred from schema type\nconst validate = ajv.compile(schema);\n\n/**\n * Validate if a manifest has the correct structure when a new package\n * is being created. The properties name, versions and _attachments must contain 1 element.\n * @param data a manifest object\n * @returns boolean\n */\nexport function validatePublishSingleVersion(manifest: any) {\n  if (!manifest) {\n    return false;\n  }\n  return validate(manifest);\n}\n"],"mappings":";;AAyBA,IAAM,WAAW,IAtBD,IAsBC,CAAA,CAAI,QAAQ;CAX3B,MAAM;CACN,YAAY;EACV,MAAM,EAAE,MAAM,SAAS;EACvB,UAAU;GAAE,MAAM;GAAU,eAAe;EAAE;EAC7C,cAAc;GAAE,MAAM;GAAU,eAAe;EAAE;CACnD;CACA,UAAU;EAAC;EAAQ;EAAY;CAAc;CAC7C,sBAAsB;AAIK,CAAM;;;;;;;AAQnC,SAAgB,6BAA6B,UAAe;CAC1D,IAAI,CAAC,UACH,OAAO;CAET,OAAO,SAAS,QAAQ;AAC1B"}