{"version":3,"file":"labels-router-DWXBHCOP.mjs","names":["request: HttpRequest","context: InvocationContext","options: RouterOptions"],"sources":["../src/components/label-form.tsx","../src/handlers/label-handlers.tsx","../src/routers/labels-router.ts"],"sourcesContent":["import { labelTypes, type LabelType } from \"../models/labels\";\nimport { urlBuilder } from \"../utils/url-builder\";\nimport { ErrorMessage } from \"./error-message\";\n\nexport interface LabelFormProps {\n  projectId: string;\n  label: LabelType | undefined;\n}\n\nexport async function LabelForm({ label, projectId }: LabelFormProps) {\n  return (\n    <form\n      hx-ext=\"response-targets\"\n      hx-patch={label ? urlBuilder.labelSlug(projectId, label.slug) : undefined}\n      hx-post={label ? undefined : urlBuilder.allLabels(projectId)}\n      hx-target-error=\"#form-error\"\n      style={{ maxWidth: \"60ch\" }}\n    >\n      <fieldset>\n        <legend>Details</legend>\n\n        {label ? <input type=\"hidden\" name=\"slug\" value={label.slug} /> : null}\n\n        <div class=\"field\">\n          <label for=\"value\">Label</label>\n          <input id=\"value\" name=\"value\" required value={label?.value} />\n        </div>\n      </fieldset>\n\n      <fieldset>\n        <legend>Type</legend>\n\n        <div\n          style={{\n            display: \"grid\",\n            gridTemplateColumns: \"repeat(3,1fr)\",\n            gap: \"0.5rem\",\n          }}\n        >\n          {labelTypes.map((type) => {\n            const id = `type-${type}`;\n            return (\n              <div>\n                <input\n                  id={id}\n                  name=\"type\"\n                  type=\"radio\"\n                  required\n                  value={type}\n                  checked={type === label?.type}\n                />\n                <label for={id}>{type}</label>\n              </div>\n            );\n          })}\n        </div>\n\n        <span class=\"description\">\n          Type of label defines behaviour of the label.\n        </span>\n      </fieldset>\n\n      <div style={{ display: \"flex\", gap: \"1rem\" }}>\n        <button type=\"submit\">{label ? \"Update\" : \"Create\"} Label</button>\n        <button type=\"reset\">Reset</button>\n      </div>\n\n      <ErrorMessage id=\"form-error\" />\n    </form>\n  );\n}\n","import type {\n  HttpRequest,\n  HttpResponseInit,\n  InvocationContext,\n} from \"@azure/functions\";\nimport {\n  responseError,\n  responseHTML,\n  responseRedirect,\n} from \"../utils/response-utils\";\nimport { DocumentLayout } from \"../components/layout\";\nimport { RawDataPreview } from \"../components/raw-data\";\nimport { getStore } from \"../utils/store\";\nimport { BuildTable } from \"../components/builds-table\";\nimport { LabelsTable } from \"../components/labels-table\";\nimport {\n  LabelCreateSchema,\n  LabelModel,\n  LabelUpdateSchema,\n} from \"../models/labels\";\nimport { urlBuilder } from \"../utils/url-builder\";\nimport {\n  checkIsEditMode,\n  checkIsHTMLRequest,\n  checkIsHXRequest,\n  checkIsNewMode,\n} from \"../utils/request-utils\";\nimport { LabelForm } from \"../components/label-form\";\nimport { CONTENT_TYPES } from \"../utils/constants\";\nimport { urlSearchParamsToObject } from \"../utils/url-utils\";\n\nexport async function listLabels(\n  request: HttpRequest,\n  context: InvocationContext\n): Promise<HttpResponseInit> {\n  const { projectId = \"\" } = request.params;\n\n  try {\n    if (checkIsNewMode()) {\n      return responseHTML(\n        <DocumentLayout\n          title=\"Create Label\"\n          breadcrumbs={[\n            { label: projectId, href: urlBuilder.projectId(projectId) },\n            { label: \"Labels\", href: urlBuilder.allLabels(projectId) },\n          ]}\n        >\n          <LabelForm projectId={projectId} label={undefined} />\n        </DocumentLayout>\n      );\n    }\n\n    const { connectionString } = getStore();\n    const labelModel = new LabelModel(context, connectionString, projectId);\n    const labels = await labelModel.list();\n\n    if (checkIsHTMLRequest()) {\n      return responseHTML(\n        <DocumentLayout\n          title=\"All Labels\"\n          breadcrumbs={[projectId]}\n          toolbar={<a href={urlBuilder.labelCreate(projectId)}>+ Create</a>}\n        >\n          <LabelsTable\n            labels={labels}\n            projectId={projectId}\n            caption={`Labels (${labels.length})`}\n          />\n        </DocumentLayout>\n      );\n    }\n\n    return { status: 200, jsonBody: labels };\n  } catch (error) {\n    return responseError(error, context);\n  }\n}\n\nexport async function createLabel(\n  request: HttpRequest,\n  context: InvocationContext\n): Promise<HttpResponseInit> {\n  try {\n    const { projectId = \"\" } = request.params;\n    const { connectionString } = getStore();\n    const model = new LabelModel(context, connectionString, projectId);\n\n    if (!(await model.projectModel.has(projectId))) {\n      return responseError(\n        `The project '${projectId}' does not exist.`,\n        context,\n        404\n      );\n    }\n\n    const contentType = request.headers.get(\"content-type\");\n    if (!contentType) {\n      return responseError(\"Content-Type header is required\", context, 400);\n    }\n    if (!contentType.includes(CONTENT_TYPES.FORM_ENCODED)) {\n      return responseError(\n        `Invalid Content-Type, expected ${CONTENT_TYPES.FORM_ENCODED}`,\n        context,\n        415\n      );\n    }\n\n    const data = LabelCreateSchema.parse(\n      urlSearchParamsToObject(await request.formData())\n    );\n\n    await model.create(data);\n\n    const labelUrl = urlBuilder.labelSlug(\n      projectId,\n      LabelModel.createSlug(data.value)\n    );\n\n    if (checkIsHTMLRequest() || checkIsHXRequest()) {\n      return responseRedirect(labelUrl, 303);\n    }\n\n    return {\n      status: 201,\n      headers: { Location: labelUrl },\n      jsonBody: { data, links: { self: labelUrl } },\n    };\n  } catch (error) {\n    return responseError(error, context);\n  }\n}\n\nexport async function getLabel(\n  request: HttpRequest,\n  context: InvocationContext\n): Promise<HttpResponseInit> {\n  const { projectId = \"\", labelSlug = \"\" } = request.params;\n\n  try {\n    const { connectionString } = getStore();\n    const labelModel = new LabelModel(context, connectionString, projectId);\n    const label = await labelModel.get(labelSlug);\n\n    if (checkIsEditMode()) {\n      return responseHTML(\n        <DocumentLayout\n          title=\"Edit Label\"\n          breadcrumbs={[\n            { label: projectId, href: urlBuilder.projectId(projectId) },\n            { label: \"Labels\", href: urlBuilder.allLabels(projectId) },\n            {\n              label: label.slug,\n              href: urlBuilder.labelSlug(projectId, labelSlug),\n            },\n          ]}\n        >\n          <LabelForm projectId={projectId} label={label} />\n        </DocumentLayout>\n      );\n    }\n\n    const projectModel = labelModel.projectModel;\n    const project = await projectModel.get(projectId);\n    const builds = await projectModel.buildModel(projectId).list({\n      filter: `PartitionKey eq '${labelSlug}'`,\n    });\n\n    if (checkIsHTMLRequest()) {\n      return responseHTML(\n        <DocumentLayout\n          title={`[${label.type}] ${label.value}`}\n          breadcrumbs={[projectId, \"Labels\"]}\n          toolbar={\n            <div style={{ display: \"flex\", gap: \"1rem\", alignItems: \"center\" }}>\n              <a href={urlBuilder.labelSlugEdit(projectId, labelSlug)}>Edit</a>\n              <form\n                hx-delete={request.url}\n                hx-confirm=\"Are you sure about deleting the label?\"\n              >\n                <button>Delete</button>\n              </form>\n            </div>\n          }\n        >\n          <>\n            <RawDataPreview data={label} summary={\"Label details\"} />\n            <BuildTable\n              caption={`Builds (${builds.length})`}\n              builds={builds}\n              labels={undefined}\n              project={project}\n            />\n          </>\n        </DocumentLayout>\n      );\n    }\n\n    return { status: 202, jsonBody: { ...label, builds } };\n  } catch (error) {\n    return responseError(error, context);\n  }\n}\n\nexport async function updateLabel(\n  request: HttpRequest,\n  context: InvocationContext\n): Promise<HttpResponseInit> {\n  const { projectId = \"\", labelSlug = \"\" } = request.params;\n\n  try {\n    const { connectionString } = getStore();\n    const contentType = request.headers.get(\"content-type\");\n    if (!contentType) {\n      return responseError(\"Content-Type header is required\", context, 400);\n    }\n    if (!contentType.includes(CONTENT_TYPES.FORM_ENCODED)) {\n      return responseError(\n        `Invalid Content-Type, expected ${CONTENT_TYPES.FORM_ENCODED}`,\n        context,\n        415\n      );\n    }\n\n    const data = LabelUpdateSchema.partial().parse(\n      urlSearchParamsToObject(await request.formData())\n    );\n\n    const labelModel = new LabelModel(context, connectionString, projectId);\n    await labelModel.update(labelSlug, data);\n\n    const labelUrl = urlBuilder.labelSlug(projectId, labelSlug);\n\n    if (checkIsHTMLRequest() || checkIsHXRequest()) {\n      return responseRedirect(request.url, 303);\n    }\n\n    return {\n      status: 202,\n      headers: { Location: labelUrl },\n      jsonBody: {\n        data: await labelModel.get(labelSlug),\n        links: { self: request.url },\n      },\n    };\n  } catch (error) {\n    return responseError(error, context);\n  }\n}\n\nexport async function deleteLabel(\n  request: HttpRequest,\n  context: InvocationContext\n): Promise<HttpResponseInit> {\n  const { projectId = \"\", labelSlug = \"\" } = request.params;\n\n  try {\n    const { connectionString } = getStore();\n    const labelModel = new LabelModel(context, connectionString, projectId);\n    await labelModel.delete(labelSlug);\n\n    const labelsUrl = urlBuilder.allLabels(projectId);\n\n    if (checkIsHTMLRequest() || checkIsHXRequest()) {\n      return responseRedirect(labelsUrl, 303);\n    }\n\n    return { status: 204, headers: { Location: labelsUrl } };\n  } catch (error) {\n    return responseError(error, context);\n  }\n}\n\nexport async function getLabelLatestBuild(\n  request: HttpRequest,\n  context: InvocationContext\n): Promise<HttpResponseInit> {\n  const { projectId = \"\", labelSlug = \"\" } = request.params;\n  context.log(\n    \"Getting latest build for label '%s' in project '%s'...\",\n    labelSlug,\n    projectId\n  );\n\n  try {\n    const { connectionString } = getStore();\n    const labelModel = new LabelModel(context, connectionString, projectId);\n    const { buildSHA: latestBuildSHA } = await labelModel.get(labelSlug);\n\n    if (!latestBuildSHA) {\n      return {\n        status: 404,\n        jsonBody: { error: \"No builds found for this label.\" },\n      };\n    }\n\n    return {\n      status: 303,\n      headers: { Location: urlBuilder.buildSHA(projectId, latestBuildSHA) },\n    };\n  } catch (error) {\n    return responseError(error, context);\n  }\n}\n","import { app } from \"@azure/functions\";\nimport { commonErrorResponses, CONTENT_TYPES } from \"../utils/constants\";\nimport { openAPITags, registerOpenAPIPath } from \"../utils/openapi-utils\";\nimport type { RouterOptions } from \"../utils/types\";\nimport z from \"zod\";\nimport { joinUrl } from \"../utils/url-utils\";\nimport * as handlers from \"../handlers/label-handlers\";\nimport { LabelSlugSchema } from \"../models/shared\";\nimport { LabelSchema } from \"../models/labels\";\n\nconst TAG = openAPITags.labels.name;\n\nexport function registerLabelsRouter(options: RouterOptions) {\n  const {\n    authLevel,\n    baseRoute,\n    basePathParamsSchema,\n    handlerWrapper,\n    openAPIEnabled,\n    serviceName,\n  } = options;\n\n  app.get(`${serviceName}-labels-list`, {\n    authLevel,\n    route: baseRoute,\n    handler: handlerWrapper(handlers.listLabels, [\n      { resource: \"label\", action: \"read\" },\n      { resource: \"ui\", action: \"read\" },\n    ]),\n  });\n\n  app.post(`${serviceName}-label-create`, {\n    authLevel,\n    route: baseRoute,\n    handler: handlerWrapper(handlers.createLabel, [\n      { resource: \"label\", action: \"create\" },\n    ]),\n  });\n\n  const routeWithLabel = joinUrl(baseRoute, \"{labelSlug}\");\n  app.get(`${serviceName}-label-get`, {\n    authLevel,\n    route: routeWithLabel,\n    handler: handlerWrapper(handlers.getLabel, [\n      { resource: \"label\", action: \"read\" },\n      { resource: \"ui\", action: \"read\" },\n    ]),\n  });\n  app.patch(`${serviceName}-label-update`, {\n    authLevel,\n    route: routeWithLabel,\n    handler: handlerWrapper(handlers.updateLabel, [\n      { resource: \"label\", action: \"update\" },\n    ]),\n  });\n  app.deleteRequest(`${serviceName}-label-delete`, {\n    authLevel,\n    route: routeWithLabel,\n    handler: handlerWrapper(handlers.deleteLabel, [\n      { resource: \"label\", action: \"delete\" },\n    ]),\n  });\n\n  const routeWithLabelLatest = joinUrl(routeWithLabel, \"latest\");\n  app.get(`${serviceName}-label-latest`, {\n    authLevel,\n    route: routeWithLabelLatest,\n    handler: handlerWrapper(handlers.getLabelLatestBuild, [\n      { resource: \"label\", action: \"read\" },\n    ]),\n  });\n\n  if (openAPIEnabled) {\n    const labelPathParameterSchema = basePathParamsSchema.extend({\n      labelSlug: LabelSlugSchema,\n    });\n\n    registerOpenAPIPath(baseRoute, {\n      get: {\n        tags: [TAG],\n        summary: \"List all labels for the project.\",\n        description: \"Retrieves a list of labels.\",\n        requestParams: { path: basePathParamsSchema },\n        responses: {\n          ...commonErrorResponses,\n          200: {\n            description: \"A list of labels.\",\n            content: {\n              [CONTENT_TYPES.JSON]: {\n                schema: LabelSchema.array(),\n                example: [{ slug: \"label-slug\", value: \"label/slug\" }],\n              },\n              [CONTENT_TYPES.HTML]: { example: \"<!DOCTYPE html>\" },\n            },\n          },\n        },\n      },\n      post: {\n        tags: [TAG],\n        summary: \"Create a new label.\",\n        description: \"Create a new label with slug and type.\",\n        requestParams: { path: basePathParamsSchema },\n        responses: {\n          ...commonErrorResponses,\n          202: {\n            description: \"Data about label\",\n            content: { [CONTENT_TYPES.JSON]: { schema: LabelSchema } },\n          },\n          303: {\n            description: \"Label created, redirecting...\",\n            headers: { Location: z.url() },\n          },\n        },\n      },\n    });\n\n    registerOpenAPIPath(routeWithLabel, {\n      get: {\n        tags: [TAG],\n        summary: \"Get label details\",\n        description:\n          \"Retrieves the details of a specific label and all builds associated with it.\",\n        requestParams: { path: labelPathParameterSchema },\n        responses: {\n          ...commonErrorResponses,\n          200: {\n            description: \"Label details retrieved successfully\",\n            content: {\n              [CONTENT_TYPES.JSON]: { schema: LabelSchema },\n              [CONTENT_TYPES.HTML]: { example: \"<!DOCTYPE html>\" },\n            },\n          },\n          404: { description: \"Matching label not found.\" },\n        },\n      },\n      delete: {\n        tags: [TAG],\n        summary: \"Delete a label\",\n        description: \"Deletes a specific label and builds associated with it.\",\n        requestParams: { path: labelPathParameterSchema },\n        responses: {\n          ...commonErrorResponses,\n          204: { description: \"Label deleted successfully\" },\n          404: { description: \"Matching label not found.\" },\n        },\n      },\n    });\n\n    registerOpenAPIPath(routeWithLabelLatest, {\n      get: {\n        tags: [TAG],\n        summary: \"Redirect to latest build for a label\",\n        description:\n          \"Redirects to the latest build associated with a specific label.\",\n        requestParams: { path: labelPathParameterSchema },\n        responses: {\n          ...commonErrorResponses,\n          308: {\n            description: \"Redirecting to latest build.\",\n            headers: {\n              Location: {\n                content: z\n                  .string()\n                  .meta({ description: \"URL of the latest build\" }),\n              },\n            },\n          },\n          404: { description: \"Matching label or build not found.\" },\n        },\n      },\n    });\n  }\n}\n"],"mappings":";;;;;;;;;;;;;AASA,eAAsB,UAAU,EAAE,OAAO,WAA2B,EAAE;AACpE,uDACG;EACC,UAAO;EACP,YAAU,QAAQ,WAAW,UAAU,WAAW,MAAM,KAAK,GAAG;EAChE,WAAS,QAAQ,SAAY,WAAW,UAAU,UAAU;EAC5D,mBAAgB;EAChB,OAAO,EA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