UNPKG

@azure-utils/storybooks

Version:

Utils to upload and manage Storybooks via Azure Functions and storage.

1 lines 2.83 kB
{"version":3,"file":"openapi-utils-CAJ85ahl.mjs","names":["openAPIPaths: ZodOpenApiPathsObject","path: string","input: ZodOpenApiPathItemObject","openAPISchemas: Record<string, ZodOpenApiSchemaObject>"],"sources":["../src/utils/openapi-utils.ts"],"sourcesContent":["import type {\n ZodOpenApiPathItemObject,\n ZodOpenApiPathsObject,\n ZodOpenApiSchemaObject,\n ZodOpenApiSecuritySchemeObject,\n} from \"zod-openapi\";\nimport { ProjectCreateSchema, ProjectSchema } from \"../models/projects\";\nimport { BuildSchema, BuildUploadSchema } from \"../models/builds\";\nimport { LabelSchema } from \"../models/labels\";\n\nexport const openAPIPaths: ZodOpenApiPathsObject = {};\n\nexport function registerOpenAPIPath(\n path: string,\n input: ZodOpenApiPathItemObject\n) {\n path ||= \"/\";\n if (!path.startsWith(\"/\")) {\n path = `/${path}`;\n }\n\n const value = openAPIPaths[path];\n\n if (value) {\n openAPIPaths[path] = { ...value, ...input };\n } else {\n openAPIPaths[path] = input;\n }\n}\n\nexport const openAPITags = {\n projects: {\n name: \"Projects\",\n description:\n \"A project manages a single Storybook instance across multiple builds.\",\n },\n builds: {\n name: \"Builds\",\n description: \"A build is a specific version of a Storybook instance.\",\n },\n labels: {\n name: \"Labels\",\n description:\n \"Labels can be used to manage multiple Storybook instances. Labels can be git-branches or Pull Requests.\",\n },\n storybook: {\n name: \"Storybook\",\n description: \"View storybook files for a specific project and build.\",\n },\n webUI: {\n name: \"Web UI\",\n description: \"Serves static files for web-ui.\",\n },\n} satisfies Record<string, { name: string; description?: string }>;\n\nexport const openAPISchemas: Record<string, ZodOpenApiSchemaObject> = {\n ProjectSchema,\n BuildSchema,\n LabelSchema,\n BuildUploadSchema,\n ProjectCreateSchema,\n};\n\nexport const openAPISecuritySchemas = {\n functionsKey: {\n type: \"apiKey\",\n in: \"header\",\n name: \"x-functions-key\",\n description:\n \"Azure Admin Functions key for authentication if authLevel is set to 'admin'.\",\n },\n} satisfies Record<string, ZodOpenApiSecuritySchemeObject>;\n"],"mappings":";;;AAUA,MAAaA,eAAsC,CAAE;AAErD,SAAgB,oBACdC,MACAC,OACA;CACA,SAAS;AACT,KAAI,CAAC,KAAK,WAAW,IAAI,EACvB,OAAO,CAAC,CAAC,EAAE,MAAM;CAGnB,MAAM,QAAQ,aAAa;AAE3B,KAAI,OACF,aAAa,QAAQ;EAAE,GAAG;EAAO,GAAG;CAAO;MAE3C,aAAa,QAAQ;AAExB;AAED,MAAa,cAAc;CACzB,UAAU;EACR,MAAM;EACN,aACE;CACH;CACD,QAAQ;EACN,MAAM;EACN,aAAa;CACd;CACD,QAAQ;EACN,MAAM;EACN,aACE;CACH;CACD,WAAW;EACT,MAAM;EACN,aAAa;CACd;CACD,OAAO;EACL,MAAM;EACN,aAAa;CACd;AACF;AAED,MAAaC,iBAAyD;CACpE;CACA;CACA;CACA;CACA;AACD;AAED,MAAa,yBAAyB,EACpC,cAAc;CACZ,MAAM;CACN,IAAI;CACJ,MAAM;CACN,aACE;AACH,EACF"}