@camunda/ccma-shared-types 7.3.0 → 7.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/_tests/constants/custom-hardware-sizing.const.spec.d.ts +1 -0
  2. package/dist/approvals/policy.js +2 -1
  3. package/dist/approvals/policy.js.map +2 -2
  4. package/dist/approvals/use-cases.const.d.ts +5 -2
  5. package/dist/approvals/use-cases.const.js +12 -4
  6. package/dist/approvals/use-cases.const.js.map +2 -2
  7. package/dist/constants/custom-generation.const.d.ts +28 -0
  8. package/dist/constants/custom-generation.const.js +67 -0
  9. package/dist/constants/custom-generation.const.js.map +7 -0
  10. package/dist/constants/{customer-hardware-sizing.const.d.ts → custom-hardware-sizing.const.d.ts} +18 -18
  11. package/dist/constants/{customer-hardware-sizing.const.js → custom-hardware-sizing.const.js} +35 -35
  12. package/dist/constants/custom-hardware-sizing.const.js.map +7 -0
  13. package/dist/dtos/ApprovalJob.dto.d.ts +15 -2
  14. package/dist/dtos/ApprovalJob.dto.js.map +1 -1
  15. package/dist/dtos/SalesPlan.dto.d.ts +5 -0
  16. package/dist/dtos/SalesPlan.dto.js +8 -0
  17. package/dist/dtos/SalesPlan.dto.js.map +2 -2
  18. package/dist/index.d.ts +4 -3
  19. package/dist/index.js +41 -25
  20. package/dist/index.js.map +2 -2
  21. package/dist/permissions/console.permissions.d.ts +7 -0
  22. package/dist/permissions/console.permissions.js +7 -0
  23. package/dist/permissions/console.permissions.js.map +2 -2
  24. package/dist/types/ClusterPlanTypeCategory.type.d.ts +1 -1
  25. package/dist/types/ClusterTtl.type.d.ts +27 -0
  26. package/dist/types/ClusterTtl.type.js.map +1 -1
  27. package/package.json +1 -1
  28. package/dist/constants/customer-hardware-sizing.const.js.map +0 -7
  29. /package/dist/_tests/constants/{customer-hardware-sizing.const.spec.d.ts → custom-generation.const.spec.d.ts} +0 -0
@@ -63,7 +63,8 @@ function canCreate(actor, useCase, request = {}) {
63
63
  );
64
64
  }
65
65
  const toRun = request.requiredPermissions ?? [useCase.requiredPermission];
66
- if (resolveRequiredAcks(useCase, request.requiredAcks) === 0 && !useCase.openToEveryone && !hasEveryPermission(actor, toRun)) {
66
+ const openedBySystem = useCase.openedBySystem && !!useCase.createPermission;
67
+ if (resolveRequiredAcks(useCase, request.requiredAcks) === 0 && !useCase.openToEveryone && !openedBySystem && !hasEveryPermission(actor, toRun)) {
67
68
  return deny(
68
69
  "forbidden",
69
70
  `This request needs no approval, so opening it runs it. That needs ${toRun.join(" and ")}, and you do not hold it.`
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/approvals/policy.ts"],
4
- "sourcesContent": ["/*\n * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH\n * under one or more contributor license agreements. Licensed under a commercial license.\n * You may not use this file except in compliance with the commercial license.\n */\n\nimport { UNKNOWN_ACTOR_EMAIL } from '../constants/misc.const.js'\nimport type {\n ApprovalJobDto,\n ApprovalUseCaseDto,\n} from '../dtos/ApprovalJob.dto.js'\nimport { ConsolePermissions } from '../permissions/console.permissions.js'\n\n/**\n * The rules of the approval mechanism, as pure functions.\n *\n * Three consumers run this file: control-backend decides whether to reject a\n * request, control-frontend decides whether to disable a button, and cloudbot\n * decides whether to answer. One copy means the button and the endpoint can\n * never disagree.\n *\n * Two choices in the signatures carry the design:\n *\n * - The actor is an interface with a `has` method. The backend holds an array\n * of Auth0 claims, and `useSession()` in the frontend gives a flat record of\n * booleans. Neither side has to convert to the shape of the other.\n * - `now` is a parameter. The expiry is lazy, so a stored `pending` request can\n * be expired already. A parameter makes a difference between the two clocks\n * an input that a test can set, and not a silent disagreement.\n *\n * No function here does I/O or returns a promise. The browser call site is what\n * enforces that, and it also stops a later use case from turning a list of 50\n * rows into 200 network calls.\n */\n\n/** Who is asking. See the note above on why this is an interface. */\nexport interface ApprovalActorView {\n userId: string\n /**\n * The email of the actor. It is the SECOND identity of the four-eyes rule.\n *\n * `userId` alone is not enough. One person can hold more than one identity in\n * Auth0 \u2014 a connection through SSO and a connection through a database, or an\n * account that was made again \u2014 and each one carries a different `sub`. The\n * same human then opens a request with one identity and approves it with the\n * other, which is the rule defeated.\n *\n * It is optional because a token can carry no email. See\n * `isSameActorEmail` for what that means for the comparison.\n */\n email?: string\n has(permission: string): boolean\n}\n\n/**\n * Builds the `has` of an actor from the permissions that the actor holds.\n *\n * `ConsolePermissions.APPROVALS_ALL_USE_CASES` stands in for every permission\n * that a use case asks for. Both actor builders call this function, the one of\n * control-backend and the one of the browser, so the button and the route\n * agree on it. A rule that reads `actor.has` needs no change for it, and nor\n * does a use case that a later change adds.\n */\nexport function approvalPermissionCheck(\n held: ReadonlySet<string>,\n): (permission: string) => boolean {\n const all = held.has(ConsolePermissions.APPROVALS_ALL_USE_CASES)\n return (permission) => all || held.has(permission)\n}\n\n/**\n * Reports whether two email addresses name one person.\n *\n * Two values that are absent, empty, or `UNKNOWN_ACTOR_EMAIL` are NOT one\n * person. A token with no email would otherwise make every actor equal to\n * every other actor, and the rule would refuse everybody.\n *\n * The comparison removes the spaces and the case. Auth0 gives the address as\n * the identity provider wrote it, so `A.B@camunda.com` and `a.b@camunda.com`\n * are one mailbox and must not pass as two people.\n */\nexport function isSameActorEmail(one?: string, other?: string): boolean {\n const left = comparableActorEmail(one)\n return left.length > 0 && left === comparableActorEmail(other)\n}\n\n/**\n * The address in the one form that a comparison may use.\n *\n * An absent address, an empty one and `UNKNOWN_ACTOR_EMAIL` all become an\n * empty string, because none of the three names a person. The spaces and the\n * case go as well: Auth0 gives the address as the identity provider wrote it.\n */\nfunction comparableActorEmail(value?: string): string {\n const trimmed = value?.trim().toLowerCase() ?? ''\n return trimmed === UNKNOWN_ACTOR_EMAIL ? '' : trimmed\n}\n\n/**\n * Reports whether one identity of a request names the actor.\n *\n * The `sub` of the token OR the email, because one person can hold more than\n * one Auth0 identity. Every rule that asks \"is this the same human?\" reads both\n * through this function, so a rule cannot forget the second half: `canWithdraw`\n * did, and it refused a creator whose browser and whose service resolved the\n * id from two different tokens.\n */\nexport function isSameActor(\n identity: { userId: string; email?: string },\n actor: ApprovalActorView,\n): boolean {\n return (\n identity.userId === actor.userId ||\n isSameActorEmail(identity.email, actor.email)\n )\n}\n\n/**\n * Reports whether this actor carries an address that names a person.\n *\n * A machine-to-machine token carries none: accounts-backend builds the\n * permissions of such a token from its `permissions` claim alone, and there is\n * no person behind it. See `creatorEmailRequired` of the use case.\n */\nexport function hasActorEmail(actor: ApprovalActorView): boolean {\n return comparableActorEmail(actor.email).length > 0\n}\n\n/**\n * Why an action is not allowed.\n *\n * The code is for a program: control-backend maps it to a status, and the\n * frontend can branch on it. The message is for a person, and it is shown as\n * written.\n */\nexport type ApprovalDenialCode =\n | 'forbidden'\n | 'not-pending'\n | 'self-approval'\n | 'self-rejection'\n | 'already-acknowledged'\n | 'expired'\n | 'not-creator'\n | 'not-executable'\n | 'no-reason'\n | 'too-few-acks'\n | 'no-creator-email'\n\nexport type ApprovalDecision =\n | { allowed: true }\n | { allowed: false; code: ApprovalDenialCode; message: string }\n\nconst ALLOWED: ApprovalDecision = { allowed: true }\n\nfunction deny(code: ApprovalDenialCode, message: string): ApprovalDecision {\n return { allowed: false, code, message }\n}\n\n/**\n * Reports whether the time to answer a request has passed.\n *\n * Only a `pending` request expires. A request that already reached an end state\n * keeps that state, because \"expired\" would lose the answer that was given.\n */\nexport function isExpired(job: ApprovalJobDto, now: Date): boolean {\n return (\n job.status === 'pending' &&\n new Date(job.expiresAt).getTime() <= now.getTime()\n )\n}\n\n/** Reports the status to show, which is `expired` once the time has passed. */\nexport function effectiveStatus(\n job: ApprovalJobDto,\n now: Date,\n): ApprovalJobDto['status'] {\n return isExpired(job, now) ? 'expired' : job.status\n}\n\n/** Reports how many more acknowledgements the request needs. */\nexport function remainingAcks(job: ApprovalJobDto): number {\n return Math.max(0, job.requiredAcks - job.acks.length)\n}\n\n/**\n * Reports whether the actor holds EVERY permission of the set.\n *\n * Every, and not one of them. A payload that raises the guard adds a\n * permission, so \"one of them\" would let the base permission alone carry a\n * request that the extra permission exists to stop.\n *\n * An EMPTY set is held by nobody. That is the opposite of what `Array.every`\n * answers, and it is deliberate: this function guards a privileged action, so\n * the empty case must fail closed. A row with no permissions is not a row that\n * everybody may run \u2014 it is a row that lost its guard, through a migration\n * that did not backfill it or a write that went around the service. Every use\n * case builds a set of at least one, so no real request meets this branch.\n */\nexport function hasEveryPermission(\n actor: ApprovalActorView,\n permissions: string[],\n): boolean {\n if (permissions.length === 0) {\n return false\n }\n return permissions.every((permission) => actor.has(permission))\n}\n\n/**\n * What a person must hold to act on a request.\n *\n * A request carries its own set, because a payload can raise the guard. A use\n * case that never does has a set of one, and it is the base permission.\n */\nexport function requiredPermissionsOf(job: ApprovalJobDto): string[] {\n return job.requiredPermissions\n}\n\n/**\n * Who can READ a request.\n *\n * Two people: one who can act on it, and the one who opened it. A Camundi who\n * holds neither has no reason to read which customer somebody proposed to\n * expire, so the list and the detail both hide it.\n *\n * The rule reads the BASE permission of the use case and not the effective set\n * of the request. A payload that raises the guard raises who can APPROVE, and\n * not who can look: a generation update with the yolo flag is visible to\n * everybody who can approve a plain one, and only the yolo permission runs it.\n * The list filters by use case in SQL, which is what makes one page of rows\n * the same page that a person is allowed to read.\n */\nexport function canView(\n job: ApprovalJobDto,\n actor: ApprovalActorView,\n useCase: ApprovalUseCaseDto,\n): ApprovalDecision {\n if (\n actor.has(useCase.requiredPermission) ||\n isSameActor(job.createdBy, actor)\n ) {\n return ALLOWED\n }\n return deny('forbidden', 'You cannot see this request.')\n}\n\n/**\n * Who can OPEN a request, and with what.\n *\n * `createPermission` is what keeps the pool that asks as small as the pool that\n * approves. A use case that leaves it absent says the opposite on purpose: the\n * approvals are the guard, and anybody signed in can propose the action.\n *\n * The two checks after it are about the request and not about the person. A\n * count below the floor of the use case, and a missing reason, are both a 400\n * and not a 403, so the words say which one the caller must repair.\n */\nexport function canCreate(\n actor: ApprovalActorView,\n useCase: ApprovalUseCaseDto,\n request: {\n reason?: string\n requiredAcks?: number\n /**\n * The effective permissions of the payload, from `permissionsFor`.\n *\n * Absent means \"the base permission alone\", which is what most use cases\n * build. Only the permissions ABOVE the base one gate opening a request:\n * see the note in the body.\n */\n requiredPermissions?: string[]\n } = {},\n): ApprovalDecision {\n // The message NAMES the permission. \"You cannot open this request\" is true\n // and useless: a Camundi who reads it cannot tell a missing permission from\n // a rule they never heard of, and the detail page already names a permission\n // the same way (\"Approving needs aacp\").\n if (useCase.createPermission && !actor.has(useCase.createPermission)) {\n return deny(\n 'forbidden',\n `Opening this request needs ${useCase.createPermission}, and you do not hold it.`,\n )\n }\n // What the PAYLOAD raised, on top of the base permission of the use case.\n // A bulk generation update with the yolo flag needs the yolo permission, and\n // without this check a person who holds the base permission alone could open\n // one. They could not approve it and could not run it, so it is not an\n // escalation \u2014 it is a request that its own author is not allowed to make,\n // waiting in the queue of the people who are.\n //\n // The BASE permission is deliberately not checked here. `createPermission`\n // above is the only gate on the person, and a use case that leaves it absent\n // means that anybody signed in can propose the action. Checking the base\n // permission too would take that choice away from every use case.\n const raised = (request.requiredPermissions ?? []).filter(\n (permission) => permission !== useCase.requiredPermission,\n )\n if (raised.length > 0 && !hasEveryPermission(actor, raised)) {\n return deny(\n 'forbidden',\n `This payload needs ${raised.join(' and ')}, and you do not hold it.`,\n )\n }\n // A request that needs no approval RUNS when it is opened, so the person who\n // opens it must hold what running it needs. Every other use case leaves this\n // to the approvals, which is why the base permission is not checked above.\n // With a floor of zero there is no approval to leave it to.\n const toRun = request.requiredPermissions ?? [useCase.requiredPermission]\n if (\n resolveRequiredAcks(useCase, request.requiredAcks) === 0 &&\n !useCase.openToEveryone &&\n !hasEveryPermission(actor, toRun)\n ) {\n // The message NAMES the permission, and it says why opening needs it. A\n // Camundi who reads \"you cannot open this request\" for an action that\n // needs no approval cannot tell which of the two rules refused them.\n return deny(\n 'forbidden',\n `This request needs no approval, so opening it runs it. That needs ` +\n `${toRun.join(' and ')}, and you do not hold it.`,\n )\n }\n // The action of this use case carries the address of the person who asked,\n // so a caller with no address must be refused HERE. The alternative is a\n // request that looks ordinary, collects its approvals over days, and then\n // fails because the other service cannot find a user called \"unknown\".\n if (useCase.creatorEmailRequired && !hasActorEmail(actor)) {\n return deny(\n 'no-creator-email',\n 'This action needs the email address of the person who asks for it, ' +\n 'and your session carries none. Sign in as a person to open this ' +\n 'request.',\n )\n }\n if (useCase.reasonRequired && (request.reason ?? '').trim().length === 0) {\n return deny('no-reason', 'Give a reason to open this request.')\n }\n if (\n request.requiredAcks !== undefined &&\n request.requiredAcks < useCase.minAcks\n ) {\n return deny(\n 'too-few-acks',\n `This action needs at least ${useCase.minAcks} approvals.`,\n )\n }\n return ALLOWED\n}\n\n/**\n * The approvals that a new request asks for.\n *\n * The caller names a number or names none. A number below the floor is refused\n * by `canCreate`, and this function holds the answer inside the range anyway:\n * the two run in the same call, and a floor that only one of them knows is a\n * floor that a later caller can step over.\n */\nexport function resolveRequiredAcks(\n useCase: ApprovalUseCaseDto,\n requested?: number,\n): number {\n if (requested === undefined) {\n return Math.max(useCase.defaultAcks, useCase.minAcks)\n }\n return Math.max(Math.trunc(requested), useCase.minAcks)\n}\n\n/**\n * The four-eyes rule.\n *\n * The bans are in the order a person meets them, and each one has its own\n * message: \"you already approved this\" and \"you cannot approve your own\n * request\" are different mistakes, and one message for both helps nobody.\n *\n * Each of the two bans on a person reads BOTH identities: the `sub` of the\n * token, and the email. See `ApprovalActorView.email` for why one of them is\n * not enough.\n */\nexport function canAcknowledge(\n job: ApprovalJobDto,\n actor: ApprovalActorView,\n now: Date,\n): ApprovalDecision {\n if (!hasEveryPermission(actor, job.requiredPermissions)) {\n return deny('forbidden', 'You cannot approve this request.')\n }\n if (isExpired(job, now)) {\n return deny(\n 'expired',\n 'This request expired and can no longer be approved.',\n )\n }\n if (job.status !== 'pending') {\n return deny(\n 'not-pending',\n `This request is ${job.status} and can no longer be approved.`,\n )\n }\n if (isSameActor(job.createdBy, actor)) {\n return deny(\n 'self-approval',\n 'You opened this request, so you cannot approve it.',\n )\n }\n if (job.acks.some((ack) => isSameActor(ack, actor))) {\n return deny('already-acknowledged', 'You already approved this request.')\n }\n return ALLOWED\n}\n\n/**\n * A rejection needs the same permission as an acknowledgement, and a reason.\n *\n * Two people answer a request, and each one has ONE verb. Somebody else\n * approves or rejects it; the person who opened it withdraws it. The creator is\n * refused here for the same reason `canAcknowledge` refuses them: one person\n * must not be both sides of a four-eyes decision. The message names the button\n * that they do have, and the trail loses nothing, because a withdrawal writes\n * its reason into the same field.\n *\n * The ORDER of the checks is the order that a person meets them, and the state\n * of the request comes before the reason. A closed request must answer\n * \"already closed\" whatever the caller typed: with the reason first, a page\n * that had no reason yet read `no-reason` from a rejected request, and the\n * Reject button of control-frontend stayed enabled on a request that nothing\n * could reject any more.\n */\nexport function canReject(\n job: ApprovalJobDto,\n actor: ApprovalActorView,\n now: Date,\n reason: string,\n): ApprovalDecision {\n if (!hasEveryPermission(actor, job.requiredPermissions)) {\n return deny('forbidden', 'You cannot reject this request.')\n }\n if (isExpired(job, now)) {\n return deny(\n 'expired',\n 'This request expired and can no longer be rejected.',\n )\n }\n if (job.status !== 'pending') {\n return deny(\n 'not-pending',\n `This request is ${job.status} and can no longer be rejected.`,\n )\n }\n if (isSameActor(job.createdBy, actor)) {\n return deny(\n 'self-rejection',\n 'You opened this request, so withdraw it instead of rejecting it.',\n )\n }\n if (reason.trim().length === 0) {\n return deny('no-reason', 'Give a reason to reject this request.')\n }\n return ALLOWED\n}\n\n/**\n * Only the person who opened a request can take it back.\n *\n * BOTH identities, as every other rule of this file reads them. One person can\n * hold two Auth0 identities with two different `sub` values, and a rule that\n * read the id alone refused the creator their own withdrawal as soon as the\n * browser and the service resolved that id from two different tokens.\n */\nexport function canWithdraw(\n job: ApprovalJobDto,\n actor: ApprovalActorView,\n now: Date,\n): ApprovalDecision {\n if (!isSameActor(job.createdBy, actor)) {\n return deny(\n 'not-creator',\n 'Only the person who opened a request can withdraw it.',\n )\n }\n if (isExpired(job, now)) {\n return deny(\n 'expired',\n 'This request expired and can no longer be withdrawn.',\n )\n }\n if (job.status !== 'pending') {\n return deny(\n 'not-pending',\n `This request is ${job.status} and can no longer be withdrawn.`,\n )\n }\n return ALLOWED\n}\n\n/**\n * Runs a request that has its approvals.\n *\n * This is the button of the explicit mode. `failed` is executable again,\n * because a failure is often a problem of the system that is now repaired, and\n * asking for the approvals a second time helps nobody.\n *\n * ANY holder of the permission may press it, and not only the person who\n * opened the request. The decision was made when the request reached\n * `approved`: `canAcknowledge` refuses the creator, so the approvals on the\n * row came from other people, and the button only carries out what they\n * already agreed to. Holding the button to the creator would let one Camundi\n * on holiday freeze an approved action, and a use case that must not run\n * without its author has `executionMode: 'auto'` instead.\n *\n * Who PRESSED it and who ASKED for it are two different facts, and both are\n * kept: the audit trail of control-backend records the actor of the run, and\n * an action that names a person to another service names the creator. See\n * `onBehalfOf` of `extend-trial`.\n */\nexport function canExecute(\n job: ApprovalJobDto,\n actor: ApprovalActorView,\n): ApprovalDecision {\n if (!hasEveryPermission(actor, job.requiredPermissions)) {\n return deny('forbidden', 'You cannot run this request.')\n }\n if (job.status !== 'approved' && job.status !== 'failed') {\n return deny(\n 'not-executable',\n `This request is ${job.status} and cannot be run.`,\n )\n }\n return ALLOWED\n}\n"],
5
- "mappings": "AAMA,SAAS,2BAA2B;AAKpC,SAAS,0BAA0B;AAoD5B,SAAS,wBACd,MACiC;AACjC,QAAM,MAAM,KAAK,IAAI,mBAAmB,uBAAuB;AAC/D,SAAO,CAAC,eAAe,OAAO,KAAK,IAAI,UAAU;AACnD;AAaO,SAAS,iBAAiB,KAAc,OAAyB;AACtE,QAAM,OAAO,qBAAqB,GAAG;AACrC,SAAO,KAAK,SAAS,KAAK,SAAS,qBAAqB,KAAK;AAC/D;AASA,SAAS,qBAAqB,OAAwB;AACpD,QAAM,UAAU,OAAO,KAAK,EAAE,YAAY,KAAK;AAC/C,SAAO,YAAY,sBAAsB,KA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,MAAI,CAAC,mBAAmB,OAAO,IAAI,mBAAmB,GAAG;AACvD,WAAO,KAAK,aAAa,8BAA8B;AAAA,EACzD;AACA,MAAI,IAAI,WAAW,cAAc,IAAI,WAAW,UAAU;AACxD,WAAO;AAAA,MACL;AAAA,MACA,mBAAmB,IAAI,MAAM;AAAA,IAC/B;AAAA,EACF;AACA,SAAO;AACT;",
4
+ "sourcesContent": ["/*\n * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH\n * under one or more contributor license agreements. Licensed under a commercial license.\n * You may not use this file except in compliance with the commercial license.\n */\n\nimport { UNKNOWN_ACTOR_EMAIL } from '../constants/misc.const.js'\nimport type {\n ApprovalJobDto,\n ApprovalUseCaseDto,\n} from '../dtos/ApprovalJob.dto.js'\nimport { ConsolePermissions } from '../permissions/console.permissions.js'\n\n/**\n * The rules of the approval mechanism, as pure functions.\n *\n * Three consumers run this file: control-backend decides whether to reject a\n * request, control-frontend decides whether to disable a button, and cloudbot\n * decides whether to answer. One copy means the button and the endpoint can\n * never disagree.\n *\n * Two choices in the signatures carry the design:\n *\n * - The actor is an interface with a `has` method. The backend holds an array\n * of Auth0 claims, and `useSession()` in the frontend gives a flat record of\n * booleans. Neither side has to convert to the shape of the other.\n * - `now` is a parameter. The expiry is lazy, so a stored `pending` request can\n * be expired already. A parameter makes a difference between the two clocks\n * an input that a test can set, and not a silent disagreement.\n *\n * No function here does I/O or returns a promise. The browser call site is what\n * enforces that, and it also stops a later use case from turning a list of 50\n * rows into 200 network calls.\n */\n\n/** Who is asking. See the note above on why this is an interface. */\nexport interface ApprovalActorView {\n userId: string\n /**\n * The email of the actor. It is the SECOND identity of the four-eyes rule.\n *\n * `userId` alone is not enough. One person can hold more than one identity in\n * Auth0 \u2014 a connection through SSO and a connection through a database, or an\n * account that was made again \u2014 and each one carries a different `sub`. The\n * same human then opens a request with one identity and approves it with the\n * other, which is the rule defeated.\n *\n * It is optional because a token can carry no email. See\n * `isSameActorEmail` for what that means for the comparison.\n */\n email?: string\n has(permission: string): boolean\n}\n\n/**\n * Builds the `has` of an actor from the permissions that the actor holds.\n *\n * `ConsolePermissions.APPROVALS_ALL_USE_CASES` stands in for every permission\n * that a use case asks for. Both actor builders call this function, the one of\n * control-backend and the one of the browser, so the button and the route\n * agree on it. A rule that reads `actor.has` needs no change for it, and nor\n * does a use case that a later change adds.\n */\nexport function approvalPermissionCheck(\n held: ReadonlySet<string>,\n): (permission: string) => boolean {\n const all = held.has(ConsolePermissions.APPROVALS_ALL_USE_CASES)\n return (permission) => all || held.has(permission)\n}\n\n/**\n * Reports whether two email addresses name one person.\n *\n * Two values that are absent, empty, or `UNKNOWN_ACTOR_EMAIL` are NOT one\n * person. A token with no email would otherwise make every actor equal to\n * every other actor, and the rule would refuse everybody.\n *\n * The comparison removes the spaces and the case. Auth0 gives the address as\n * the identity provider wrote it, so `A.B@camunda.com` and `a.b@camunda.com`\n * are one mailbox and must not pass as two people.\n */\nexport function isSameActorEmail(one?: string, other?: string): boolean {\n const left = comparableActorEmail(one)\n return left.length > 0 && left === comparableActorEmail(other)\n}\n\n/**\n * The address in the one form that a comparison may use.\n *\n * An absent address, an empty one and `UNKNOWN_ACTOR_EMAIL` all become an\n * empty string, because none of the three names a person. The spaces and the\n * case go as well: Auth0 gives the address as the identity provider wrote it.\n */\nfunction comparableActorEmail(value?: string): string {\n const trimmed = value?.trim().toLowerCase() ?? ''\n return trimmed === UNKNOWN_ACTOR_EMAIL ? '' : trimmed\n}\n\n/**\n * Reports whether one identity of a request names the actor.\n *\n * The `sub` of the token OR the email, because one person can hold more than\n * one Auth0 identity. Every rule that asks \"is this the same human?\" reads both\n * through this function, so a rule cannot forget the second half: `canWithdraw`\n * did, and it refused a creator whose browser and whose service resolved the\n * id from two different tokens.\n */\nexport function isSameActor(\n identity: { userId: string; email?: string },\n actor: ApprovalActorView,\n): boolean {\n return (\n identity.userId === actor.userId ||\n isSameActorEmail(identity.email, actor.email)\n )\n}\n\n/**\n * Reports whether this actor carries an address that names a person.\n *\n * A machine-to-machine token carries none: accounts-backend builds the\n * permissions of such a token from its `permissions` claim alone, and there is\n * no person behind it. See `creatorEmailRequired` of the use case.\n */\nexport function hasActorEmail(actor: ApprovalActorView): boolean {\n return comparableActorEmail(actor.email).length > 0\n}\n\n/**\n * Why an action is not allowed.\n *\n * The code is for a program: control-backend maps it to a status, and the\n * frontend can branch on it. The message is for a person, and it is shown as\n * written.\n */\nexport type ApprovalDenialCode =\n | 'forbidden'\n | 'not-pending'\n | 'self-approval'\n | 'self-rejection'\n | 'already-acknowledged'\n | 'expired'\n | 'not-creator'\n | 'not-executable'\n | 'no-reason'\n | 'too-few-acks'\n | 'no-creator-email'\n\nexport type ApprovalDecision =\n | { allowed: true }\n | { allowed: false; code: ApprovalDenialCode; message: string }\n\nconst ALLOWED: ApprovalDecision = { allowed: true }\n\nfunction deny(code: ApprovalDenialCode, message: string): ApprovalDecision {\n return { allowed: false, code, message }\n}\n\n/**\n * Reports whether the time to answer a request has passed.\n *\n * Only a `pending` request expires. A request that already reached an end state\n * keeps that state, because \"expired\" would lose the answer that was given.\n */\nexport function isExpired(job: ApprovalJobDto, now: Date): boolean {\n return (\n job.status === 'pending' &&\n new Date(job.expiresAt).getTime() <= now.getTime()\n )\n}\n\n/** Reports the status to show, which is `expired` once the time has passed. */\nexport function effectiveStatus(\n job: ApprovalJobDto,\n now: Date,\n): ApprovalJobDto['status'] {\n return isExpired(job, now) ? 'expired' : job.status\n}\n\n/** Reports how many more acknowledgements the request needs. */\nexport function remainingAcks(job: ApprovalJobDto): number {\n return Math.max(0, job.requiredAcks - job.acks.length)\n}\n\n/**\n * Reports whether the actor holds EVERY permission of the set.\n *\n * Every, and not one of them. A payload that raises the guard adds a\n * permission, so \"one of them\" would let the base permission alone carry a\n * request that the extra permission exists to stop.\n *\n * An EMPTY set is held by nobody. That is the opposite of what `Array.every`\n * answers, and it is deliberate: this function guards a privileged action, so\n * the empty case must fail closed. A row with no permissions is not a row that\n * everybody may run \u2014 it is a row that lost its guard, through a migration\n * that did not backfill it or a write that went around the service. Every use\n * case builds a set of at least one, so no real request meets this branch.\n */\nexport function hasEveryPermission(\n actor: ApprovalActorView,\n permissions: string[],\n): boolean {\n if (permissions.length === 0) {\n return false\n }\n return permissions.every((permission) => actor.has(permission))\n}\n\n/**\n * What a person must hold to act on a request.\n *\n * A request carries its own set, because a payload can raise the guard. A use\n * case that never does has a set of one, and it is the base permission.\n */\nexport function requiredPermissionsOf(job: ApprovalJobDto): string[] {\n return job.requiredPermissions\n}\n\n/**\n * Who can READ a request.\n *\n * Two people: one who can act on it, and the one who opened it. A Camundi who\n * holds neither has no reason to read which customer somebody proposed to\n * expire, so the list and the detail both hide it.\n *\n * The rule reads the BASE permission of the use case and not the effective set\n * of the request. A payload that raises the guard raises who can APPROVE, and\n * not who can look: a generation update with the yolo flag is visible to\n * everybody who can approve a plain one, and only the yolo permission runs it.\n * The list filters by use case in SQL, which is what makes one page of rows\n * the same page that a person is allowed to read.\n */\nexport function canView(\n job: ApprovalJobDto,\n actor: ApprovalActorView,\n useCase: ApprovalUseCaseDto,\n): ApprovalDecision {\n if (\n actor.has(useCase.requiredPermission) ||\n isSameActor(job.createdBy, actor)\n ) {\n return ALLOWED\n }\n return deny('forbidden', 'You cannot see this request.')\n}\n\n/**\n * Who can OPEN a request, and with what.\n *\n * `createPermission` is what keeps the pool that asks as small as the pool that\n * approves. A use case that leaves it absent says the opposite on purpose: the\n * approvals are the guard, and anybody signed in can propose the action.\n *\n * The two checks after it are about the request and not about the person. A\n * count below the floor of the use case, and a missing reason, are both a 400\n * and not a 403, so the words say which one the caller must repair.\n */\nexport function canCreate(\n actor: ApprovalActorView,\n useCase: ApprovalUseCaseDto,\n request: {\n reason?: string\n requiredAcks?: number\n /**\n * The effective permissions of the payload, from `permissionsFor`.\n *\n * Absent means \"the base permission alone\", which is what most use cases\n * build. Only the permissions ABOVE the base one gate opening a request:\n * see the note in the body.\n */\n requiredPermissions?: string[]\n } = {},\n): ApprovalDecision {\n // The message NAMES the permission. \"You cannot open this request\" is true\n // and useless: a Camundi who reads it cannot tell a missing permission from\n // a rule they never heard of, and the detail page already names a permission\n // the same way (\"Approving needs aacp\").\n if (useCase.createPermission && !actor.has(useCase.createPermission)) {\n return deny(\n 'forbidden',\n `Opening this request needs ${useCase.createPermission}, and you do not hold it.`,\n )\n }\n // What the PAYLOAD raised, on top of the base permission of the use case.\n // A bulk generation update with the yolo flag needs the yolo permission, and\n // without this check a person who holds the base permission alone could open\n // one. They could not approve it and could not run it, so it is not an\n // escalation \u2014 it is a request that its own author is not allowed to make,\n // waiting in the queue of the people who are.\n //\n // The BASE permission is deliberately not checked here. `createPermission`\n // above is the only gate on the person, and a use case that leaves it absent\n // means that anybody signed in can propose the action. Checking the base\n // permission too would take that choice away from every use case.\n const raised = (request.requiredPermissions ?? []).filter(\n (permission) => permission !== useCase.requiredPermission,\n )\n if (raised.length > 0 && !hasEveryPermission(actor, raised)) {\n return deny(\n 'forbidden',\n `This payload needs ${raised.join(' and ')}, and you do not hold it.`,\n )\n }\n // A request that needs no approval RUNS when it is opened, so the person who\n // opens it must hold what running it needs. Every other use case leaves this\n // to the approvals, which is why the base permission is not checked above.\n // With a floor of zero there is no approval to leave it to.\n const toRun = request.requiredPermissions ?? [useCase.requiredPermission]\n // A service that opens a request of its own use case holds the\n // `createPermission` checked above, and that is the guard of the run. Without\n // a `createPermission` there is no such guard, so the flag lifts nothing.\n const openedBySystem = useCase.openedBySystem && !!useCase.createPermission\n if (\n resolveRequiredAcks(useCase, request.requiredAcks) === 0 &&\n !useCase.openToEveryone &&\n !openedBySystem &&\n !hasEveryPermission(actor, toRun)\n ) {\n // The message NAMES the permission, and it says why opening needs it. A\n // Camundi who reads \"you cannot open this request\" for an action that\n // needs no approval cannot tell which of the two rules refused them.\n return deny(\n 'forbidden',\n `This request needs no approval, so opening it runs it. That needs ` +\n `${toRun.join(' and ')}, and you do not hold it.`,\n )\n }\n // The action of this use case carries the address of the person who asked,\n // so a caller with no address must be refused HERE. The alternative is a\n // request that looks ordinary, collects its approvals over days, and then\n // fails because the other service cannot find a user called \"unknown\".\n if (useCase.creatorEmailRequired && !hasActorEmail(actor)) {\n return deny(\n 'no-creator-email',\n 'This action needs the email address of the person who asks for it, ' +\n 'and your session carries none. Sign in as a person to open this ' +\n 'request.',\n )\n }\n if (useCase.reasonRequired && (request.reason ?? '').trim().length === 0) {\n return deny('no-reason', 'Give a reason to open this request.')\n }\n if (\n request.requiredAcks !== undefined &&\n request.requiredAcks < useCase.minAcks\n ) {\n return deny(\n 'too-few-acks',\n `This action needs at least ${useCase.minAcks} approvals.`,\n )\n }\n return ALLOWED\n}\n\n/**\n * The approvals that a new request asks for.\n *\n * The caller names a number or names none. A number below the floor is refused\n * by `canCreate`, and this function holds the answer inside the range anyway:\n * the two run in the same call, and a floor that only one of them knows is a\n * floor that a later caller can step over.\n */\nexport function resolveRequiredAcks(\n useCase: ApprovalUseCaseDto,\n requested?: number,\n): number {\n if (requested === undefined) {\n return Math.max(useCase.defaultAcks, useCase.minAcks)\n }\n return Math.max(Math.trunc(requested), useCase.minAcks)\n}\n\n/**\n * The four-eyes rule.\n *\n * The bans are in the order a person meets them, and each one has its own\n * message: \"you already approved this\" and \"you cannot approve your own\n * request\" are different mistakes, and one message for both helps nobody.\n *\n * Each of the two bans on a person reads BOTH identities: the `sub` of the\n * token, and the email. See `ApprovalActorView.email` for why one of them is\n * not enough.\n */\nexport function canAcknowledge(\n job: ApprovalJobDto,\n actor: ApprovalActorView,\n now: Date,\n): ApprovalDecision {\n if (!hasEveryPermission(actor, job.requiredPermissions)) {\n return deny('forbidden', 'You cannot approve this request.')\n }\n if (isExpired(job, now)) {\n return deny(\n 'expired',\n 'This request expired and can no longer be approved.',\n )\n }\n if (job.status !== 'pending') {\n return deny(\n 'not-pending',\n `This request is ${job.status} and can no longer be approved.`,\n )\n }\n if (isSameActor(job.createdBy, actor)) {\n return deny(\n 'self-approval',\n 'You opened this request, so you cannot approve it.',\n )\n }\n if (job.acks.some((ack) => isSameActor(ack, actor))) {\n return deny('already-acknowledged', 'You already approved this request.')\n }\n return ALLOWED\n}\n\n/**\n * A rejection needs the same permission as an acknowledgement, and a reason.\n *\n * Two people answer a request, and each one has ONE verb. Somebody else\n * approves or rejects it; the person who opened it withdraws it. The creator is\n * refused here for the same reason `canAcknowledge` refuses them: one person\n * must not be both sides of a four-eyes decision. The message names the button\n * that they do have, and the trail loses nothing, because a withdrawal writes\n * its reason into the same field.\n *\n * The ORDER of the checks is the order that a person meets them, and the state\n * of the request comes before the reason. A closed request must answer\n * \"already closed\" whatever the caller typed: with the reason first, a page\n * that had no reason yet read `no-reason` from a rejected request, and the\n * Reject button of control-frontend stayed enabled on a request that nothing\n * could reject any more.\n */\nexport function canReject(\n job: ApprovalJobDto,\n actor: ApprovalActorView,\n now: Date,\n reason: string,\n): ApprovalDecision {\n if (!hasEveryPermission(actor, job.requiredPermissions)) {\n return deny('forbidden', 'You cannot reject this request.')\n }\n if (isExpired(job, now)) {\n return deny(\n 'expired',\n 'This request expired and can no longer be rejected.',\n )\n }\n if (job.status !== 'pending') {\n return deny(\n 'not-pending',\n `This request is ${job.status} and can no longer be rejected.`,\n )\n }\n if (isSameActor(job.createdBy, actor)) {\n return deny(\n 'self-rejection',\n 'You opened this request, so withdraw it instead of rejecting it.',\n )\n }\n if (reason.trim().length === 0) {\n return deny('no-reason', 'Give a reason to reject this request.')\n }\n return ALLOWED\n}\n\n/**\n * Only the person who opened a request can take it back.\n *\n * BOTH identities, as every other rule of this file reads them. One person can\n * hold two Auth0 identities with two different `sub` values, and a rule that\n * read the id alone refused the creator their own withdrawal as soon as the\n * browser and the service resolved that id from two different tokens.\n */\nexport function canWithdraw(\n job: ApprovalJobDto,\n actor: ApprovalActorView,\n now: Date,\n): ApprovalDecision {\n if (!isSameActor(job.createdBy, actor)) {\n return deny(\n 'not-creator',\n 'Only the person who opened a request can withdraw it.',\n )\n }\n if (isExpired(job, now)) {\n return deny(\n 'expired',\n 'This request expired and can no longer be withdrawn.',\n )\n }\n if (job.status !== 'pending') {\n return deny(\n 'not-pending',\n `This request is ${job.status} and can no longer be withdrawn.`,\n )\n }\n return ALLOWED\n}\n\n/**\n * Runs a request that has its approvals.\n *\n * This is the button of the explicit mode. `failed` is executable again,\n * because a failure is often a problem of the system that is now repaired, and\n * asking for the approvals a second time helps nobody.\n *\n * ANY holder of the permission may press it, and not only the person who\n * opened the request. The decision was made when the request reached\n * `approved`: `canAcknowledge` refuses the creator, so the approvals on the\n * row came from other people, and the button only carries out what they\n * already agreed to. Holding the button to the creator would let one Camundi\n * on holiday freeze an approved action, and a use case that must not run\n * without its author has `executionMode: 'auto'` instead.\n *\n * Who PRESSED it and who ASKED for it are two different facts, and both are\n * kept: the audit trail of control-backend records the actor of the run, and\n * an action that names a person to another service names the creator. See\n * `onBehalfOf` of `extend-trial`.\n */\nexport function canExecute(\n job: ApprovalJobDto,\n actor: ApprovalActorView,\n): ApprovalDecision {\n if (!hasEveryPermission(actor, job.requiredPermissions)) {\n return deny('forbidden', 'You cannot run this request.')\n }\n if (job.status !== 'approved' && job.status !== 'failed') {\n return deny(\n 'not-executable',\n `This request is ${job.status} and cannot be run.`,\n )\n }\n return ALLOWED\n}\n"],
5
+ "mappings": "AAMA,SAAS,2BAA2B;AAKpC,SAAS,0BAA0B;AAoD5B,SAAS,wBACd,MACiC;AACjC,QAAM,MAAM,KAAK,IAAI,mBAAmB,uBAAuB;AAC/D,SAAO,CAAC,eAAe,OAAO,KAAK,IAAI,UAAU;AACnD;AAaO,SAAS,iBAAiB,KAAc,OAAyB;AACtE,QAAM,OAAO,qBAAqB,GAAG;AACrC,SAAO,KAAK,SAAS,KAAK,SAAS,qBAAqB,KAAK;AAC/D;AASA,SAAS,qBAAqB,OAAwB;AACpD,QAAM,UAAU,OAAO,KAAK,EAAE,YAAY,KAAK;AAC/C,SAAO,YAAY,sBAAsB,KAAK;AAChD;AAWO,SAAS,YACd,UACA,OACS;AACT,SACE,SAAS,WAAW,MA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ACkB;AAClB,MAAI,CAAC,mBAAmB,OAAO,IAAI,mBAAmB,GAAG;AACvD,WAAO,KAAK,aAAa,8BAA8B;AAAA,EACzD;AACA,MAAI,IAAI,WAAW,cAAc,IAAI,WAAW,UAAU;AACxD,WAAO;AAAA,MACL;AAAA,MACA,mBAAmB,IAAI,MAAM;AAAA,IAC/B;AAAA,EACF;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -35,10 +35,13 @@ export declare const APPROVAL_USE_CASE_TYPES: {
35
35
  readonly updateUserMetadata: "update-user-metadata";
36
36
  readonly changeFeatureFlag: "change-feature-flag";
37
37
  readonly createPersonalOrganisation: "create-personal-organisation";
38
- readonly createCustomerHardwareSizing: "create-customer-hardware-sizing";
39
- readonly removeCustomerHardwareSizing: "remove-customer-hardware-sizing";
38
+ readonly createCustomHardwareSizing: "create-custom-hardware-sizing";
39
+ readonly removeCustomHardwareSizing: "remove-custom-hardware-sizing";
40
+ readonly createCustomGeneration: "create-custom-generation";
41
+ readonly removeCustomGeneration: "remove-custom-generation";
40
42
  readonly onboardToEnterprise: "onboard-to-enterprise";
41
43
  readonly changeClusterPlanType: "change-cluster-plan-type";
44
+ readonly clusterTtlDeletion: "cluster-ttl-deletion";
42
45
  };
43
46
  /**
44
47
  * The approvals that a change of the feature flag table needs on prod.
@@ -30,9 +30,13 @@ const APPROVAL_USE_CASE_TYPES = {
30
30
  // Open to every Camundi, and it needs no approval on any stage.
31
31
  createPersonalOrganisation: "create-personal-organisation",
32
32
  // Open to every Camundi, runs on dev only, and needs no approval. The two
33
- // use cases of customer hardware sizing.
34
- createCustomerHardwareSizing: "create-customer-hardware-sizing",
35
- removeCustomerHardwareSizing: "remove-customer-hardware-sizing",
33
+ // use cases of custom hardware sizing.
34
+ createCustomHardwareSizing: "create-custom-hardware-sizing",
35
+ removeCustomHardwareSizing: "remove-custom-hardware-sizing",
36
+ // Open to every Camundi, runs on dev only, and needs no approval. The two
37
+ // use cases of custom generations.
38
+ createCustomGeneration: "create-custom-generation",
39
+ removeCustomGeneration: "remove-custom-generation",
36
40
  // The enterprise onboarding of one organization, behind
37
41
  // `control.onboardToEnterpriseApproval`: the contract, the plan type of
38
42
  // each cluster, and the reservations, in one request.
@@ -41,7 +45,11 @@ const APPROVAL_USE_CASE_TYPES = {
41
45
  // `control.changeClusterPlanType`. The bulk plan type update beside it
42
46
  // checks no reservation and moves no cluster plan, so this one is not a
43
47
  // duplicate of it. See `change-cluster-plan-type.ts` in control-backend.
44
- changeClusterPlanType: "change-cluster-plan-type"
48
+ changeClusterPlanType: "change-cluster-plan-type",
49
+ // The deletion of one cluster whose TTL ran out. Only the delete cron of
50
+ // console-backend opens it, and it needs no approval. It is a record of the
51
+ // deletion. See `cluster-ttl-deletion.ts` in control-backend.
52
+ clusterTtlDeletion: "cluster-ttl-deletion"
45
53
  };
46
54
  const FEATURE_FLAG_MIN_ACKS_PROD = 2;
47
55
  const PERSONAL_ORGANIZATION_MAX_PER_REQUESTER = 10;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/approvals/use-cases.const.ts"],
4
- "sourcesContent": ["/*\n * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH\n * under one or more contributor license agreements. Licensed under a commercial license.\n * You may not use this file except in compliance with the commercial license.\n */\n\nimport { AccountsPermissions } from '../permissions/accounts.permissions.js'\n\n/**\n * The names and the value ranges of the registered use cases.\n *\n * control-backend owns the registry, and a frontend reads it at run time\n * (`GET /api/approvals/use-cases`). Two things cannot wait for that answer:\n *\n * - **The identifier**, because a caller must NAME a use case to find it in the\n * registry, and to open a request of it.\n * - **The range of a payload field**, because a form holds the value before any\n * call goes out.\n *\n * Both live here, so the schema of the service and the form of the browser can\n * never hold different numbers.\n */\n\n/** The identifier of each use case, on the wire and in the table. */\nexport const APPROVAL_USE_CASE_TYPES = {\n sendToExpiredTrial: 'send-to-expired-trial',\n extendTrial: 'extend-trial',\n moveClusterOrg: 'move-cluster-org',\n // One use case for each type of a cluster bulk operation. The types need\n // different permissions and different approval counts, and a use case holds\n // one of each. See `cluster-bulk-operation.ts` beside this file.\n clusterBulkGenerationUpdate: 'cluster-bulk-generation-update',\n clusterBulkPlanUpdate: 'cluster-bulk-plan-update',\n clusterBulkPlanTypeUpdate: 'cluster-bulk-plan-type-update',\n clusterBulkSleepWakeup: 'cluster-bulk-sleep-wakeup',\n clusterBulkDeletion: 'cluster-bulk-deletion',\n clusterBulkSpecUpdate: 'cluster-bulk-spec-update',\n // The second group, behind `control.approvalAdminActions`.\n changePlatformRoles: 'change-platform-roles',\n deleteInternalBackup: 'delete-internal-backup',\n changeOrgLimits: 'change-org-limits',\n deleteSsoConnection: 'delete-sso-connection',\n changeSalesPlan: 'change-sales-plan',\n // The third group, behind `control.approvalAccountActions`.\n deleteOrganization: 'delete-organization',\n deleteUser: 'delete-user',\n changeUserEmail: 'change-user-email',\n purgeUsers: 'purge-users',\n updateUserMetadata: 'update-user-metadata',\n // A change of the feature flag table, on a stage where\n // `isFeatureFlagApprovalRequired` is true.\n changeFeatureFlag: 'change-feature-flag',\n // Open to every Camundi, and it needs no approval on any stage.\n createPersonalOrganisation: 'create-personal-organisation',\n // Open to every Camundi, runs on dev only, and needs no approval. The two\n // use cases of customer hardware sizing.\n createCustomerHardwareSizing: 'create-customer-hardware-sizing',\n removeCustomerHardwareSizing: 'remove-customer-hardware-sizing',\n // The enterprise onboarding of one organization, behind\n // `control.onboardToEnterpriseApproval`: the contract, the plan type of\n // each cluster, and the reservations, in one request.\n onboardToEnterprise: 'onboard-to-enterprise',\n // The plan type and the hardware packages of ONE cluster, behind\n // `control.changeClusterPlanType`. The bulk plan type update beside it\n // checks no reservation and moves no cluster plan, so this one is not a\n // duplicate of it. See `change-cluster-plan-type.ts` in control-backend.\n changeClusterPlanType: 'change-cluster-plan-type',\n} as const\n\n/**\n * The approvals that a change of the feature flag table needs on prod.\n *\n * A flag there turns a feature on or off for every customer, and a person who\n * holds `aafw` could do it alone. Two other Camundis stand in every change,\n * the same floor as a cluster bulk operation on prod\n * (`CLUSTER_BULK_OPERATION_MIN_ACKS`). Int needs one.\n */\nexport const FEATURE_FLAG_MIN_ACKS_PROD = 2\n\n/**\n * The most personal organizations that one Camundi can request.\n *\n * The request runs with no approval, so this cap is the only guard against a\n * loop that creates organizations without end. It counts the requests that a\n * Camundi opened, and a person who needs more asks a Camundi who holds\n * `AccountsPermissions.CREATE_ORG`.\n */\nexport const PERSONAL_ORGANIZATION_MAX_PER_REQUESTER = 10\n\n/** The shortest and longest name of a personal organization. */\nexport const PERSONAL_ORGANIZATION_NAME_MIN_LENGTH = 3\nexport const PERSONAL_ORGANIZATION_NAME_MAX_LENGTH = 100\n\nexport type ApprovalUseCaseType =\n (typeof APPROVAL_USE_CASE_TYPES)[keyof typeof APPROVAL_USE_CASE_TYPES]\n\n/**\n * The shortest extension that accounts-backend accepts.\n *\n * `POST /:orgId/extendtrial` refuses a date that is less than 14 days away\n * when the body carries `onBehalfOf`, and it measures those 14 days when the\n * CALL arrives. The floor here is 15 and not 14, for two reasons:\n *\n * - The two clocks are not the same instant. Accounts builds its own \"14 days\n * from now\" a few milliseconds after control-backend builds the date, so a\n * date of exactly 14 days is already in the past for the comparison.\n * - Accounts counts with `setDate`, which is calendar arithmetic. A change of\n * the daylight saving time moves its limit by an hour.\n */\nexport const EXTEND_TRIAL_MIN_DAYS = 15\n\n/**\n * The longest extension that accounts-backend accepts.\n *\n * The same route refuses a date more than 62 days away. 61 keeps the same\n * margin as the floor above.\n */\nexport const EXTEND_TRIAL_MAX_DAYS = 61\n\n/**\n * The most roles that one change-platform-roles request adds, or removes.\n *\n * The form of control-frontend offers every platform role, and a person who\n * gives a Camundi a new position rarely changes more than a few. A request with\n * more roles than this is a request that nobody reads before they approve it.\n */\nexport const PLATFORM_ROLE_CHANGE_MAX_ROLES = 10\n\n/**\n * The longest text value that one change-org-limits request writes.\n *\n * A text limit holds a short value, such as a list of regions. The bound keeps\n * a request readable for the person who approves it.\n */\nexport const ORG_LIMIT_TEXT_MAX_LENGTH = 2000\n\n/**\n * The most users that one purge-users request deletes.\n *\n * The God Mode purge deletes one user after the other, and Auth0 limits how\n * fast that goes. A list longer than this is also a list that no approver\n * reads before they agree.\n */\nexport const PURGE_USERS_MAX_USERS = 1000\n\n/**\n * What a person must hold to open or to approve a purge-users request.\n *\n * The purge of God Mode is behind `GOD_PURGE_USERS`, and each deletion calls a\n * route behind `DELETE_USER`. The use case of control-backend returns this\n * list from `permissionsFor`, and the form passes it to `canCreate`, so the\n * button and the server never disagree.\n */\nexport const PURGE_USERS_REQUIRED_PERMISSIONS: readonly string[] = [\n AccountsPermissions.GOD_PURGE_USERS,\n AccountsPermissions.DELETE_USER,\n]\n\n/**\n * The largest metadata object that one update-user-metadata request writes,\n * in characters of its JSON text.\n *\n * This is a bound of the product, and not the limit of Auth0, which is far\n * larger. The approvers read the whole object before they agree, and an\n * object that is longer than this is an object that nobody reads.\n */\nexport const USER_METADATA_MAX_LENGTH = 16_000\n\n/**\n * The largest metadata object that a request carries as the object that the\n * person who asked READ.\n *\n * It is larger than `USER_METADATA_MAX_LENGTH`, so a user whose metadata grew\n * past that bound can still get an edit that makes it smaller. It still has a\n * bound, because the request keeps the copy in its row.\n */\nexport const USER_METADATA_EXPECTED_MAX_LENGTH = 500_000\n\n/** The longest email address that a change-user-email request carries. */\nexport const APPROVAL_EMAIL_MAX_LENGTH = 320\n\n/**\n * The email addresses that a change-user-email request accepts.\n *\n * It is the email pattern of zod 4.6. The pattern is here, so the schema of\n * control-backend and the form of control-frontend accept the same addresses,\n * and a form never sends an address that the service refuses.\n */\nexport const APPROVAL_EMAIL_PATTERN =\n // biome-ignore lint/complexity/noUselessEscapeInRegex: the same source as zod, character for character\n /^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$/\n"],
5
- "mappings": "AAMA,SAAS,2BAA2B;AAkB7B,MAAM,0BAA0B;AAAA,EACrC,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,gBAAgB;AAAA;AAAA;AAAA;AAAA,EAIhB,6BAA6B;AAAA,EAC7B,uBAAuB;AAAA,EACvB,2BAA2B;AAAA,EAC3B,wBAAwB;AAAA,EACxB,qBAAqB;AAAA,EACrB,uBAAuB;AAAA;AAAA,EAEvB,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,iBAAiB;AAAA,EACjB,qBAAqB;AAAA,EACrB,iBAAiB;AAAA;AAAA,EAEjB,oBAAoB;AAAA,EACpB,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,oBAAoB;AAAA;AAAA;AAAA,EAGpB,mBAAmB;AAAA;AAAA,EAEnB,4BAA4B;AAAA;AAAA;AAAA,EAG5B,8BAA8B;AAAA,EAC9B,8BAA8B;AAAA;AAAA;AAAA;AAAA,EAI9B,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrB,uBAAuB;AACzB;AAUO,MAAM,6BAA6B;AAUnC,MAAM,0CAA0C;AAGhD,MAAM,wCAAwC;AAC9C,MAAM,wCAAwC;AAkB9C,MAAM,wBAAwB;AAQ9B,MAAM,wBAAwB;AAS9B,MAAM,iCAAiC;AAQvC,MAAM,4BAA4B;AASlC,MAAM,wBAAwB;AAU9B,MAAM,mCAAsD;AAAA,EACjE,oBAAoB;AAAA,EACpB,oBAAoB;AACtB;AAUO,MAAM,2BAA2B;AAUjC,MAAM,oCAAoC;AAG1C,MAAM,4BAA4B;AASlC,MAAM;AAAA;AAAA,EAEX;AAAA;",
4
+ "sourcesContent": ["/*\n * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH\n * under one or more contributor license agreements. Licensed under a commercial license.\n * You may not use this file except in compliance with the commercial license.\n */\n\nimport { AccountsPermissions } from '../permissions/accounts.permissions.js'\n\n/**\n * The names and the value ranges of the registered use cases.\n *\n * control-backend owns the registry, and a frontend reads it at run time\n * (`GET /api/approvals/use-cases`). Two things cannot wait for that answer:\n *\n * - **The identifier**, because a caller must NAME a use case to find it in the\n * registry, and to open a request of it.\n * - **The range of a payload field**, because a form holds the value before any\n * call goes out.\n *\n * Both live here, so the schema of the service and the form of the browser can\n * never hold different numbers.\n */\n\n/** The identifier of each use case, on the wire and in the table. */\nexport const APPROVAL_USE_CASE_TYPES = {\n sendToExpiredTrial: 'send-to-expired-trial',\n extendTrial: 'extend-trial',\n moveClusterOrg: 'move-cluster-org',\n // One use case for each type of a cluster bulk operation. The types need\n // different permissions and different approval counts, and a use case holds\n // one of each. See `cluster-bulk-operation.ts` beside this file.\n clusterBulkGenerationUpdate: 'cluster-bulk-generation-update',\n clusterBulkPlanUpdate: 'cluster-bulk-plan-update',\n clusterBulkPlanTypeUpdate: 'cluster-bulk-plan-type-update',\n clusterBulkSleepWakeup: 'cluster-bulk-sleep-wakeup',\n clusterBulkDeletion: 'cluster-bulk-deletion',\n clusterBulkSpecUpdate: 'cluster-bulk-spec-update',\n // The second group, behind `control.approvalAdminActions`.\n changePlatformRoles: 'change-platform-roles',\n deleteInternalBackup: 'delete-internal-backup',\n changeOrgLimits: 'change-org-limits',\n deleteSsoConnection: 'delete-sso-connection',\n changeSalesPlan: 'change-sales-plan',\n // The third group, behind `control.approvalAccountActions`.\n deleteOrganization: 'delete-organization',\n deleteUser: 'delete-user',\n changeUserEmail: 'change-user-email',\n purgeUsers: 'purge-users',\n updateUserMetadata: 'update-user-metadata',\n // A change of the feature flag table, on a stage where\n // `isFeatureFlagApprovalRequired` is true.\n changeFeatureFlag: 'change-feature-flag',\n // Open to every Camundi, and it needs no approval on any stage.\n createPersonalOrganisation: 'create-personal-organisation',\n // Open to every Camundi, runs on dev only, and needs no approval. The two\n // use cases of custom hardware sizing.\n createCustomHardwareSizing: 'create-custom-hardware-sizing',\n removeCustomHardwareSizing: 'remove-custom-hardware-sizing',\n // Open to every Camundi, runs on dev only, and needs no approval. The two\n // use cases of custom generations.\n createCustomGeneration: 'create-custom-generation',\n removeCustomGeneration: 'remove-custom-generation',\n // The enterprise onboarding of one organization, behind\n // `control.onboardToEnterpriseApproval`: the contract, the plan type of\n // each cluster, and the reservations, in one request.\n onboardToEnterprise: 'onboard-to-enterprise',\n // The plan type and the hardware packages of ONE cluster, behind\n // `control.changeClusterPlanType`. The bulk plan type update beside it\n // checks no reservation and moves no cluster plan, so this one is not a\n // duplicate of it. See `change-cluster-plan-type.ts` in control-backend.\n changeClusterPlanType: 'change-cluster-plan-type',\n // The deletion of one cluster whose TTL ran out. Only the delete cron of\n // console-backend opens it, and it needs no approval. It is a record of the\n // deletion. See `cluster-ttl-deletion.ts` in control-backend.\n clusterTtlDeletion: 'cluster-ttl-deletion',\n} as const\n\n/**\n * The approvals that a change of the feature flag table needs on prod.\n *\n * A flag there turns a feature on or off for every customer, and a person who\n * holds `aafw` could do it alone. Two other Camundis stand in every change,\n * the same floor as a cluster bulk operation on prod\n * (`CLUSTER_BULK_OPERATION_MIN_ACKS`). Int needs one.\n */\nexport const FEATURE_FLAG_MIN_ACKS_PROD = 2\n\n/**\n * The most personal organizations that one Camundi can request.\n *\n * The request runs with no approval, so this cap is the only guard against a\n * loop that creates organizations without end. It counts the requests that a\n * Camundi opened, and a person who needs more asks a Camundi who holds\n * `AccountsPermissions.CREATE_ORG`.\n */\nexport const PERSONAL_ORGANIZATION_MAX_PER_REQUESTER = 10\n\n/** The shortest and longest name of a personal organization. */\nexport const PERSONAL_ORGANIZATION_NAME_MIN_LENGTH = 3\nexport const PERSONAL_ORGANIZATION_NAME_MAX_LENGTH = 100\n\nexport type ApprovalUseCaseType =\n (typeof APPROVAL_USE_CASE_TYPES)[keyof typeof APPROVAL_USE_CASE_TYPES]\n\n/**\n * The shortest extension that accounts-backend accepts.\n *\n * `POST /:orgId/extendtrial` refuses a date that is less than 14 days away\n * when the body carries `onBehalfOf`, and it measures those 14 days when the\n * CALL arrives. The floor here is 15 and not 14, for two reasons:\n *\n * - The two clocks are not the same instant. Accounts builds its own \"14 days\n * from now\" a few milliseconds after control-backend builds the date, so a\n * date of exactly 14 days is already in the past for the comparison.\n * - Accounts counts with `setDate`, which is calendar arithmetic. A change of\n * the daylight saving time moves its limit by an hour.\n */\nexport const EXTEND_TRIAL_MIN_DAYS = 15\n\n/**\n * The longest extension that accounts-backend accepts.\n *\n * The same route refuses a date more than 62 days away. 61 keeps the same\n * margin as the floor above.\n */\nexport const EXTEND_TRIAL_MAX_DAYS = 61\n\n/**\n * The most roles that one change-platform-roles request adds, or removes.\n *\n * The form of control-frontend offers every platform role, and a person who\n * gives a Camundi a new position rarely changes more than a few. A request with\n * more roles than this is a request that nobody reads before they approve it.\n */\nexport const PLATFORM_ROLE_CHANGE_MAX_ROLES = 10\n\n/**\n * The longest text value that one change-org-limits request writes.\n *\n * A text limit holds a short value, such as a list of regions. The bound keeps\n * a request readable for the person who approves it.\n */\nexport const ORG_LIMIT_TEXT_MAX_LENGTH = 2000\n\n/**\n * The most users that one purge-users request deletes.\n *\n * The God Mode purge deletes one user after the other, and Auth0 limits how\n * fast that goes. A list longer than this is also a list that no approver\n * reads before they agree.\n */\nexport const PURGE_USERS_MAX_USERS = 1000\n\n/**\n * What a person must hold to open or to approve a purge-users request.\n *\n * The purge of God Mode is behind `GOD_PURGE_USERS`, and each deletion calls a\n * route behind `DELETE_USER`. The use case of control-backend returns this\n * list from `permissionsFor`, and the form passes it to `canCreate`, so the\n * button and the server never disagree.\n */\nexport const PURGE_USERS_REQUIRED_PERMISSIONS: readonly string[] = [\n AccountsPermissions.GOD_PURGE_USERS,\n AccountsPermissions.DELETE_USER,\n]\n\n/**\n * The largest metadata object that one update-user-metadata request writes,\n * in characters of its JSON text.\n *\n * This is a bound of the product, and not the limit of Auth0, which is far\n * larger. The approvers read the whole object before they agree, and an\n * object that is longer than this is an object that nobody reads.\n */\nexport const USER_METADATA_MAX_LENGTH = 16_000\n\n/**\n * The largest metadata object that a request carries as the object that the\n * person who asked READ.\n *\n * It is larger than `USER_METADATA_MAX_LENGTH`, so a user whose metadata grew\n * past that bound can still get an edit that makes it smaller. It still has a\n * bound, because the request keeps the copy in its row.\n */\nexport const USER_METADATA_EXPECTED_MAX_LENGTH = 500_000\n\n/** The longest email address that a change-user-email request carries. */\nexport const APPROVAL_EMAIL_MAX_LENGTH = 320\n\n/**\n * The email addresses that a change-user-email request accepts.\n *\n * It is the email pattern of zod 4.6. The pattern is here, so the schema of\n * control-backend and the form of control-frontend accept the same addresses,\n * and a form never sends an address that the service refuses.\n */\nexport const APPROVAL_EMAIL_PATTERN =\n // biome-ignore lint/complexity/noUselessEscapeInRegex: the same source as zod, character for character\n /^(?:[A-Za-z0-9_'+\\-]+\\.)*[A-Za-z0-9_'+\\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$/\n"],
5
+ "mappings": "AAMA,SAAS,2BAA2B;AAkB7B,MAAM,0BAA0B;AAAA,EACrC,oBAAoB;AAAA,EACpB,aAAa;AAAA,EACb,gBAAgB;AAAA;AAAA;AAAA;AAAA,EAIhB,6BAA6B;AAAA,EAC7B,uBAAuB;AAAA,EACvB,2BAA2B;AAAA,EAC3B,wBAAwB;AAAA,EACxB,qBAAqB;AAAA,EACrB,uBAAuB;AAAA;AAAA,EAEvB,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,iBAAiB;AAAA,EACjB,qBAAqB;AAAA,EACrB,iBAAiB;AAAA;AAAA,EAEjB,oBAAoB;AAAA,EACpB,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,oBAAoB;AAAA;AAAA;AAAA,EAGpB,mBAAmB;AAAA;AAAA,EAEnB,4BAA4B;AAAA;AAAA;AAAA,EAG5B,4BAA4B;AAAA,EAC5B,4BAA4B;AAAA;AAAA;AAAA,EAG5B,wBAAwB;AAAA,EACxB,wBAAwB;AAAA;AAAA;AAAA;AAAA,EAIxB,qBAAqB;AAAA;AAAA;AAAA;AAAA;AAAA,EAKrB,uBAAuB;AAAA;AAAA;AAAA;AAAA,EAIvB,oBAAoB;AACtB;AAUO,MAAM,6BAA6B;AAUnC,MAAM,0CAA0C;AAGhD,MAAM,wCAAwC;AAC9C,MAAM,wCAAwC;AAkB9C,MAAM,wBAAwB;AAQ9B,MAAM,wBAAwB;AAS9B,MAAM,iCAAiC;AAQvC,MAAM,4BAA4B;AASlC,MAAM,wBAAwB;AAU9B,MAAM,mCAAsD;AAAA,EACjE,oBAAoB;AAAA,EACpB,oBAAoB;AACtB;AAUO,MAAM,2BAA2B;AAUjC,MAAM,oCAAoC;AAG1C,MAAM,4BAA4B;AASlC,MAAM;AAAA;AAAA,EAEX;AAAA;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Custom generation: a bespoke generation that a Camundi creates for an
3
+ * organization of their own, with no admin permission. The approval use cases
4
+ * `create-custom-generation` and `remove-custom-generation` run on dev only.
5
+ */
6
+ /** The stage where custom generations run. */
7
+ export declare const isCustomGenerationStage: (stage: string) => boolean;
8
+ /**
9
+ * The most custom generations that one Camundi can own. The count is the
10
+ * bespoke generations that the Camundi created and did not delete. A bespoke
11
+ * generation that the Camundi created in the admin tool counts too.
12
+ */
13
+ export declare const CUSTOM_GENERATION_MAX_PER_REQUESTER = 50;
14
+ /** The most generations that a custom generation can list in `upgradeableFrom`. */
15
+ export declare const CUSTOM_GENERATION_MAX_UPGRADEABLE_FROM = 50;
16
+ export declare const CUSTOM_GENERATION_NAME_MIN_LENGTH = 3;
17
+ export declare const CUSTOM_GENERATION_NAME_MAX_LENGTH = 100;
18
+ /**
19
+ * Returns what is wrong with the versions of a new generation, or an empty
20
+ * list. It is the check of the admin route and of the custom generation
21
+ * request, thus both give the same messages. The admin route throws the first
22
+ * message.
23
+ *
24
+ * It does not change `versions`. A caller that saves the versions must still
25
+ * set the blank optional fields to `undefined`. Here a blank text in one of
26
+ * those fields counts as no value.
27
+ */
28
+ export declare function checkNewGenerationVersions(versions: Record<string, unknown>): string[];
@@ -0,0 +1,67 @@
1
+ import {
2
+ ImmutableThings,
3
+ MutableThings
4
+ } from "../types/C8ClusterComponentVersions.type.js";
5
+ import {
6
+ generationImageErrorMessage,
7
+ isValidGenerationImage
8
+ } from "../utils/versionCheck.utils.js";
9
+ const isCustomGenerationStage = (stage) => stage === "dev";
10
+ const CUSTOM_GENERATION_MAX_PER_REQUESTER = 50;
11
+ const CUSTOM_GENERATION_MAX_UPGRADEABLE_FROM = 50;
12
+ const CUSTOM_GENERATION_NAME_MIN_LENGTH = 3;
13
+ const CUSTOM_GENERATION_NAME_MAX_LENGTH = 100;
14
+ const REQUIRED_IMAGES = ["zeebe", "elasticSearchCurator", "elasticSearchOss"];
15
+ const OPTIONAL_IMAGES = [
16
+ "operate",
17
+ "tasklist",
18
+ "optimize",
19
+ "connectorBridge",
20
+ "zeebeAnalytics"
21
+ ];
22
+ const BLANK_IS_ABSENT = [
23
+ "operate",
24
+ "tasklist",
25
+ "connectorBridge",
26
+ "zeebeAnalytics",
27
+ "elasticSearchCurator"
28
+ ];
29
+ const imageProblem = (field, value) => typeof value === "string" && isValidGenerationImage(value) ? void 0 : generationImageErrorMessage(field, value);
30
+ function checkNewGenerationVersions(versions) {
31
+ const valueOf = (field) => {
32
+ const value = versions[field];
33
+ return BLANK_IS_ABSENT.includes(field) && typeof value === "string" && value.trim() === "" ? void 0 : value;
34
+ };
35
+ const problems = [];
36
+ for (const field of REQUIRED_IMAGES) {
37
+ const problem = imageProblem(field, valueOf(field));
38
+ if (problem) {
39
+ problems.push(problem);
40
+ }
41
+ }
42
+ for (const field of OPTIONAL_IMAGES) {
43
+ const value = valueOf(field);
44
+ if (value === void 0 || value === "") {
45
+ continue;
46
+ }
47
+ const problem = imageProblem(field, value);
48
+ if (problem) {
49
+ problems.push(problem);
50
+ }
51
+ }
52
+ for (const key of Object.keys(versions)) {
53
+ if (!MutableThings.includes(key) && !ImmutableThings.includes(key)) {
54
+ problems.push(`${key} is not a valid thing`);
55
+ }
56
+ }
57
+ return problems;
58
+ }
59
+ export {
60
+ CUSTOM_GENERATION_MAX_PER_REQUESTER,
61
+ CUSTOM_GENERATION_MAX_UPGRADEABLE_FROM,
62
+ CUSTOM_GENERATION_NAME_MAX_LENGTH,
63
+ CUSTOM_GENERATION_NAME_MIN_LENGTH,
64
+ checkNewGenerationVersions,
65
+ isCustomGenerationStage
66
+ };
67
+ //# sourceMappingURL=custom-generation.const.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/constants/custom-generation.const.ts"],
4
+ "sourcesContent": ["/*\n * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH\n * under one or more contributor license agreements. Licensed under a commercial license.\n * You may not use this file except in compliance with the commercial license.\n */\n\nimport {\n ImmutableThings,\n MutableThings,\n} from '../types/C8ClusterComponentVersions.type.js'\nimport {\n generationImageErrorMessage,\n isValidGenerationImage,\n} from '../utils/versionCheck.utils.js'\n\n/**\n * Custom generation: a bespoke generation that a Camundi creates for an\n * organization of their own, with no admin permission. The approval use cases\n * `create-custom-generation` and `remove-custom-generation` run on dev only.\n */\n\n/** The stage where custom generations run. */\nexport const isCustomGenerationStage = (stage: string): boolean =>\n stage === 'dev'\n\n/**\n * The most custom generations that one Camundi can own. The count is the\n * bespoke generations that the Camundi created and did not delete. A bespoke\n * generation that the Camundi created in the admin tool counts too.\n */\nexport const CUSTOM_GENERATION_MAX_PER_REQUESTER = 50\n\n/** The most generations that a custom generation can list in `upgradeableFrom`. */\nexport const CUSTOM_GENERATION_MAX_UPGRADEABLE_FROM = 50\n\nexport const CUSTOM_GENERATION_NAME_MIN_LENGTH = 3\nexport const CUSTOM_GENERATION_NAME_MAX_LENGTH = 100\n\n/** Images that every generation must have. */\nconst REQUIRED_IMAGES = ['zeebe', 'elasticSearchCurator', 'elasticSearchOss']\n\n/**\n * Images that a generation can have. `undefined` and an empty text mean no\n * image. Any other value, `null` too, must be a valid image, because\n * `ZeebeClusterVersionsDto` types these fields as text.\n */\nconst OPTIONAL_IMAGES = [\n 'operate',\n 'tasklist',\n 'optimize',\n 'connectorBridge',\n 'zeebeAnalytics',\n]\n\n/** Fields where a blank text means no value. */\nconst BLANK_IS_ABSENT = [\n 'operate',\n 'tasklist',\n 'connectorBridge',\n 'zeebeAnalytics',\n 'elasticSearchCurator',\n]\n\nconst imageProblem = (field: string, value: unknown): string | undefined =>\n typeof value === 'string' && isValidGenerationImage(value)\n ? undefined\n : generationImageErrorMessage(field, value)\n\n/**\n * Returns what is wrong with the versions of a new generation, or an empty\n * list. It is the check of the admin route and of the custom generation\n * request, thus both give the same messages. The admin route throws the first\n * message.\n *\n * It does not change `versions`. A caller that saves the versions must still\n * set the blank optional fields to `undefined`. Here a blank text in one of\n * those fields counts as no value.\n */\nexport function checkNewGenerationVersions(\n versions: Record<string, unknown>,\n): string[] {\n const valueOf = (field: string): unknown => {\n const value = versions[field]\n return BLANK_IS_ABSENT.includes(field) &&\n typeof value === 'string' &&\n value.trim() === ''\n ? undefined\n : value\n }\n\n const problems: string[] = []\n for (const field of REQUIRED_IMAGES) {\n const problem = imageProblem(field, valueOf(field))\n if (problem) {\n problems.push(problem)\n }\n }\n for (const field of OPTIONAL_IMAGES) {\n const value = valueOf(field)\n if (value === undefined || value === '') {\n continue\n }\n const problem = imageProblem(field, value)\n if (problem) {\n problems.push(problem)\n }\n }\n for (const key of Object.keys(versions)) {\n if (!MutableThings.includes(key) && !ImmutableThings.includes(key)) {\n problems.push(`${key} is not a valid thing`)\n }\n }\n return problems\n}\n"],
5
+ "mappings": "AAMA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OACK;AASA,MAAM,0BAA0B,CAAC,UACtC,UAAU;AAOL,MAAM,sCAAsC;AAG5C,MAAM,yCAAyC;AAE/C,MAAM,oCAAoC;AAC1C,MAAM,oCAAoC;AAGjD,MAAM,kBAAkB,CAAC,SAAS,wBAAwB,kBAAkB;AAO5E,MAAM,kBAAkB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGA,MAAM,kBAAkB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,eAAe,CAAC,OAAe,UACnC,OAAO,UAAU,YAAY,uBAAuB,KAAK,IACrD,SACA,4BAA4B,OAAO,KAAK;AAYvC,SAAS,2BACd,UACU;AACV,QAAM,UAAU,CAAC,UAA2B;AAC1C,UAAM,QAAQ,SAAS,KAAK;AAC5B,WAAO,gBAAgB,SAAS,KAAK,KACnC,OAAO,UAAU,YACjB,MAAM,KAAK,MAAM,KACf,SACA;AAAA,EACN;AAEA,QAAM,WAAqB,CAAC;AAC5B,aAAW,SAAS,iBAAiB;AACnC,UAAM,UAAU,aAAa,OAAO,QAAQ,KAAK,CAAC;AAClD,QAAI,SAAS;AACX,eAAS,KAAK,OAAO;AAAA,IACvB;AAAA,EACF;AACA,aAAW,SAAS,iBAAiB;AACnC,UAAM,QAAQ,QAAQ,KAAK;AAC3B,QAAI,UAAU,UAAa,UAAU,IAAI;AACvC;AAAA,IACF;AACA,UAAM,UAAU,aAAa,OAAO,KAAK;AACzC,QAAI,SAAS;AACX,eAAS,KAAK,OAAO;AAAA,IACvB;AAAA,EACF;AACA,aAAW,OAAO,OAAO,KAAK,QAAQ,GAAG;AACvC,QAAI,CAAC,cAAc,SAAS,GAAG,KAAK,CAAC,gBAAgB,SAAS,GAAG,GAAG;AAClE,eAAS,KAAK,GAAG,GAAG,uBAAuB;AAAA,IAC7C;AAAA,EACF;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Customer hardware sizing: a cluster plan that a Camundi creates for an
2
+ * Custom hardware sizing: a cluster plan that a Camundi creates for an
3
3
  * organization of their own, with no admin permission. The approval use cases
4
- * `create-customer-hardware-sizing` and `remove-customer-hardware-sizing` run
4
+ * `create-custom-hardware-sizing` and `remove-custom-hardware-sizing` run
5
5
  * on dev only, and the limits in this file keep one plan from asking for a
6
6
  * machine park.
7
7
  *
@@ -11,23 +11,23 @@
11
11
  * `G3-M (adapted for Cisco load test)` ask for 10 TB on purpose, and a cap
12
12
  * from them would be 100 TB.
13
13
  */
14
- /** The stage where customer hardware sizing runs. */
15
- export declare const isCustomerHardwareSizingStage: (stage: string) => boolean;
14
+ /** The stage where custom hardware sizing runs. */
15
+ export declare const isCustomHardwareSizingStage: (stage: string) => boolean;
16
16
  /**
17
- * The most plans that one Camundi can own through customer hardware sizing.
17
+ * The most plans that one Camundi can own through custom hardware sizing.
18
18
  *
19
19
  * The count is the number of plans the Camundi created. A plan that the
20
20
  * Camundi deleted does not count.
21
21
  */
22
- export declare const CUSTOMER_HARDWARE_SIZING_MAX_PLANS_PER_REQUESTER = 10;
23
- /** The shortest and longest name of a customer hardware sizing plan. */
24
- export declare const CUSTOMER_HARDWARE_SIZING_NAME_MIN_LENGTH = 3;
25
- export declare const CUSTOMER_HARDWARE_SIZING_NAME_MAX_LENGTH = 100;
22
+ export declare const CUSTOM_HARDWARE_SIZING_MAX_PLANS_PER_REQUESTER = 10;
23
+ /** The shortest and longest name of a custom hardware sizing plan. */
24
+ export declare const CUSTOM_HARDWARE_SIZING_NAME_MIN_LENGTH = 3;
25
+ export declare const CUSTOM_HARDWARE_SIZING_NAME_MAX_LENGTH = 100;
26
26
  /**
27
27
  * The longest plan, as JSON text. The largest plan of prod is about 6000
28
28
  * characters. The cap stops a request that carries a huge object.
29
29
  */
30
- export declare const CUSTOMER_HARDWARE_SIZING_MAX_PLAN_JSON_LENGTH = 50000;
30
+ export declare const CUSTOM_HARDWARE_SIZING_MAX_PLAN_JSON_LENGTH = 50000;
31
31
  /**
32
32
  * Caps for the requests and the limits of one component.
33
33
  *
@@ -40,7 +40,7 @@ export declare const CUSTOMER_HARDWARE_SIZING_MAX_PLAN_JSON_LENGTH = 50000;
40
40
  * - Elasticsearch: 30 CPU, 100 GiB, 3000 GiB of storage (no load test)
41
41
  * - other: 6 CPU, 30 GiB, no storage
42
42
  */
43
- export declare const CUSTOMER_HARDWARE_SIZING_RESOURCE_CAPS: {
43
+ export declare const CUSTOM_HARDWARE_SIZING_RESOURCE_CAPS: {
44
44
  readonly broker: {
45
45
  readonly cpu: 160;
46
46
  readonly memoryGi: 500;
@@ -58,7 +58,7 @@ export declare const CUSTOMER_HARDWARE_SIZING_RESOURCE_CAPS: {
58
58
  };
59
59
  };
60
60
  /** Caps for the count fields of a plan. Prod maximum is in the comments. */
61
- export declare const CUSTOMER_HARDWARE_SIZING_COUNT_CAPS: {
61
+ export declare const CUSTOM_HARDWARE_SIZING_COUNT_CAPS: {
62
62
  readonly clusterSize: 70;
63
63
  readonly partitionsCount: 500;
64
64
  readonly replicationFactor: 30;
@@ -66,7 +66,7 @@ export declare const CUSTOMER_HARDWARE_SIZING_COUNT_CAPS: {
66
66
  readonly replicas: 30;
67
67
  };
68
68
  /** `zeebe.broker.storage.autoResizing.increase`. Prod maximum is 18 GiB. */
69
- export declare const CUSTOMER_HARDWARE_SIZING_MAX_AUTO_RESIZE_INCREASE_GI = 180;
69
+ export declare const CUSTOM_HARDWARE_SIZING_MAX_AUTO_RESIZE_INCREASE_GI = 180;
70
70
  /**
71
71
  * The caps over the whole broker set, which the caps for one broker do not
72
72
  * give. A plan with 70 brokers of 160 CPU passes every cap above, and it asks
@@ -74,7 +74,7 @@ export declare const CUSTOMER_HARDWARE_SIZING_MAX_AUTO_RESIZE_INCREASE_GI = 180;
74
74
  * 250 GiB of memory (5 brokers, `GLS HA`) and 2500 GiB of storage (5 brokers,
75
75
  * `GLS HA`, no load test).
76
76
  */
77
- export declare const CUSTOMER_HARDWARE_SIZING_BROKER_TOTAL_CAPS: {
77
+ export declare const CUSTOM_HARDWARE_SIZING_BROKER_TOTAL_CAPS: {
78
78
  readonly cpu: 840;
79
79
  readonly memoryGi: 2500;
80
80
  readonly storageGi: 25000;
@@ -85,7 +85,7 @@ export declare const CUSTOMER_HARDWARE_SIZING_BROKER_TOTAL_CAPS: {
85
85
  * (5 nodes, `CCL G3L HA`). The storage of one node is a claim of one volume,
86
86
  * so the total is the claim times the number of nodes.
87
87
  */
88
- export declare const CUSTOMER_HARDWARE_SIZING_ELASTICSEARCH_TOTAL_CAPS: {
88
+ export declare const CUSTOM_HARDWARE_SIZING_ELASTICSEARCH_TOTAL_CAPS: {
89
89
  readonly cpu: 900;
90
90
  readonly memoryGi: 3000;
91
91
  readonly storageGi: 100000;
@@ -98,7 +98,7 @@ export declare const CUSTOMER_HARDWARE_SIZING_ELASTICSEARCH_TOTAL_CAPS: {
98
98
  * the cap for one pod, 10 times over. The check counts a storage request of a
99
99
  * pod in `resources` against it.
100
100
  */
101
- export declare const CUSTOMER_HARDWARE_SIZING_REPLICA_SET_TOTAL_CAPS: {
101
+ export declare const CUSTOM_HARDWARE_SIZING_REPLICA_SET_TOTAL_CAPS: {
102
102
  readonly cpu: 120;
103
103
  readonly memoryGi: 600;
104
104
  readonly storageGi: 50000;
@@ -112,7 +112,7 @@ export declare const CUSTOMER_HARDWARE_SIZING_REPLICA_SET_TOTAL_CAPS: {
112
112
  */
113
113
  export declare function parseKubernetesQuantity(value: unknown): number | undefined;
114
114
  /**
115
- * Checks a cluster plan against the caps of customer hardware sizing.
115
+ * Checks a cluster plan against the caps of custom hardware sizing.
116
116
  *
117
117
  * Returns the list of violations, and an empty list when the plan is within
118
118
  * the caps. It checks the size only. The shape of the plan is the job of the
@@ -121,4 +121,4 @@ export declare function parseKubernetesQuantity(value: unknown): number | undefi
121
121
  * A value that this function cannot read is a violation too: a cap that the
122
122
  * plan can skip with a strange spelling is no cap.
123
123
  */
124
- export declare function checkCustomerHardwareSizing(plan: unknown): string[];
124
+ export declare function checkCustomHardwareSizing(plan: unknown): string[];
@@ -1,15 +1,15 @@
1
1
  import { canonicalPlan } from "../utils/elasticsearchPlanPath.utils.js";
2
- const isCustomerHardwareSizingStage = (stage) => stage === "dev";
3
- const CUSTOMER_HARDWARE_SIZING_MAX_PLANS_PER_REQUESTER = 10;
4
- const CUSTOMER_HARDWARE_SIZING_NAME_MIN_LENGTH = 3;
5
- const CUSTOMER_HARDWARE_SIZING_NAME_MAX_LENGTH = 100;
6
- const CUSTOMER_HARDWARE_SIZING_MAX_PLAN_JSON_LENGTH = 5e4;
7
- const CUSTOMER_HARDWARE_SIZING_RESOURCE_CAPS = {
2
+ const isCustomHardwareSizingStage = (stage) => stage === "dev";
3
+ const CUSTOM_HARDWARE_SIZING_MAX_PLANS_PER_REQUESTER = 10;
4
+ const CUSTOM_HARDWARE_SIZING_NAME_MIN_LENGTH = 3;
5
+ const CUSTOM_HARDWARE_SIZING_NAME_MAX_LENGTH = 100;
6
+ const CUSTOM_HARDWARE_SIZING_MAX_PLAN_JSON_LENGTH = 5e4;
7
+ const CUSTOM_HARDWARE_SIZING_RESOURCE_CAPS = {
8
8
  broker: { cpu: 160, memoryGi: 500, storageGi: 5e3 },
9
9
  elasticsearch: { cpu: 300, memoryGi: 1e3, storageGi: 3e4 },
10
10
  other: { cpu: 60, memoryGi: 300, storageGi: 5e3 }
11
11
  };
12
- const CUSTOMER_HARDWARE_SIZING_COUNT_CAPS = {
12
+ const CUSTOM_HARDWARE_SIZING_COUNT_CAPS = {
13
13
  // 7
14
14
  clusterSize: 70,
15
15
  // 50
@@ -21,18 +21,18 @@ const CUSTOMER_HARDWARE_SIZING_COUNT_CAPS = {
21
21
  // `replicas` of any component. 3.
22
22
  replicas: 30
23
23
  };
24
- const CUSTOMER_HARDWARE_SIZING_MAX_AUTO_RESIZE_INCREASE_GI = 180;
25
- const CUSTOMER_HARDWARE_SIZING_BROKER_TOTAL_CAPS = {
24
+ const CUSTOM_HARDWARE_SIZING_MAX_AUTO_RESIZE_INCREASE_GI = 180;
25
+ const CUSTOM_HARDWARE_SIZING_BROKER_TOTAL_CAPS = {
26
26
  cpu: 840,
27
27
  memoryGi: 2500,
28
28
  storageGi: 25e3
29
29
  };
30
- const CUSTOMER_HARDWARE_SIZING_ELASTICSEARCH_TOTAL_CAPS = {
30
+ const CUSTOM_HARDWARE_SIZING_ELASTICSEARCH_TOTAL_CAPS = {
31
31
  cpu: 900,
32
32
  memoryGi: 3e3,
33
33
  storageGi: 1e5
34
34
  };
35
- const CUSTOMER_HARDWARE_SIZING_REPLICA_SET_TOTAL_CAPS = {
35
+ const CUSTOM_HARDWARE_SIZING_REPLICA_SET_TOTAL_CAPS = {
36
36
  cpu: 120,
37
37
  memoryGi: 600,
38
38
  storageGi: 5e4
@@ -87,7 +87,7 @@ function checkNumberCap(violations, path, value, cap) {
87
87
  }
88
88
  function checkResource(violations, path, value, kind) {
89
89
  const name = path.join(".");
90
- const caps = CUSTOMER_HARDWARE_SIZING_RESOURCE_CAPS[componentOf(path)];
90
+ const caps = CUSTOM_HARDWARE_SIZING_RESOURCE_CAPS[componentOf(path)];
91
91
  const parsed = parseKubernetesQuantity(value);
92
92
  if (parsed === void 0) {
93
93
  violations.push(`${name} is not a quantity that can be checked`);
@@ -115,12 +115,12 @@ function walk(violations, node, path) {
115
115
  const next = [...path, key];
116
116
  const parent = path.at(-1);
117
117
  const grandParent = path.at(-2);
118
- if (Object.hasOwn(CUSTOMER_HARDWARE_SIZING_COUNT_CAPS, key) && !isRecord(value)) {
118
+ if (Object.hasOwn(CUSTOM_HARDWARE_SIZING_COUNT_CAPS, key) && !isRecord(value)) {
119
119
  checkNumberCap(
120
120
  violations,
121
121
  next,
122
122
  value,
123
- CUSTOMER_HARDWARE_SIZING_COUNT_CAPS[key]
123
+ CUSTOM_HARDWARE_SIZING_COUNT_CAPS[key]
124
124
  );
125
125
  } else if ((parent === "limits" || parent === "requests") && grandParent === "resources" && (key === "cpu" || key === "memory" || key === "storage")) {
126
126
  checkResource(violations, next, value, key);
@@ -130,9 +130,9 @@ function walk(violations, node, path) {
130
130
  checkResource(violations, next, value, "storage");
131
131
  } else if (parent === "autoResizing" && key === "increase") {
132
132
  const parsed = parseKubernetesQuantity(value);
133
- if (parsed === void 0 || parsed / GIBIBYTE > CUSTOMER_HARDWARE_SIZING_MAX_AUTO_RESIZE_INCREASE_GI) {
133
+ if (parsed === void 0 || parsed / GIBIBYTE > CUSTOM_HARDWARE_SIZING_MAX_AUTO_RESIZE_INCREASE_GI) {
134
134
  violations.push(
135
- `${next.join(".")} is not a quantity of at most ${CUSTOMER_HARDWARE_SIZING_MAX_AUTO_RESIZE_INCREASE_GI} GiB`
135
+ `${next.join(".")} is not a quantity of at most ${CUSTOM_HARDWARE_SIZING_MAX_AUTO_RESIZE_INCREASE_GI} GiB`
136
136
  );
137
137
  }
138
138
  } else {
@@ -191,7 +191,7 @@ function checkReplicaSets(violations, node, path) {
191
191
  storageResources: podResources,
192
192
  legacyStorage: void 0
193
193
  },
194
- CUSTOMER_HARDWARE_SIZING_REPLICA_SET_TOTAL_CAPS
194
+ CUSTOM_HARDWARE_SIZING_REPLICA_SET_TOTAL_CAPS
195
195
  );
196
196
  }
197
197
  for (const [key, value] of Object.entries(node)) {
@@ -212,7 +212,7 @@ function checkNodeSetTotals(violations, plan) {
212
212
  storageResources: storage?.resources,
213
213
  legacyStorage: broker.persistentStorageCapacity
214
214
  },
215
- CUSTOMER_HARDWARE_SIZING_BROKER_TOTAL_CAPS
215
+ CUSTOM_HARDWARE_SIZING_BROKER_TOTAL_CAPS
216
216
  );
217
217
  }
218
218
  checkReplicaSets(violations, plan, []);
@@ -229,17 +229,17 @@ function checkNodeSetTotals(violations, plan) {
229
229
  storageResources: storage?.resources,
230
230
  legacyStorage: elasticsearch.persistentStorageCapacity
231
231
  },
232
- CUSTOMER_HARDWARE_SIZING_ELASTICSEARCH_TOTAL_CAPS
232
+ CUSTOM_HARDWARE_SIZING_ELASTICSEARCH_TOTAL_CAPS
233
233
  );
234
234
  }
235
235
  }
236
- function checkCustomerHardwareSizing(plan) {
236
+ function checkCustomHardwareSizing(plan) {
237
237
  if (!isRecord(plan)) {
238
238
  return ["the plan is not an object"];
239
239
  }
240
- if (JSON.stringify(plan).length > CUSTOMER_HARDWARE_SIZING_MAX_PLAN_JSON_LENGTH) {
240
+ if (JSON.stringify(plan).length > CUSTOM_HARDWARE_SIZING_MAX_PLAN_JSON_LENGTH) {
241
241
  return [
242
- `the plan is longer than ${CUSTOMER_HARDWARE_SIZING_MAX_PLAN_JSON_LENGTH} characters`
242
+ `the plan is longer than ${CUSTOM_HARDWARE_SIZING_MAX_PLAN_JSON_LENGTH} characters`
243
243
  ];
244
244
  }
245
245
  const canonical = canonicalPlan(plan);
@@ -249,18 +249,18 @@ function checkCustomerHardwareSizing(plan) {
249
249
  return violations;
250
250
  }
251
251
  export {
252
- CUSTOMER_HARDWARE_SIZING_BROKER_TOTAL_CAPS,
253
- CUSTOMER_HARDWARE_SIZING_COUNT_CAPS,
254
- CUSTOMER_HARDWARE_SIZING_ELASTICSEARCH_TOTAL_CAPS,
255
- CUSTOMER_HARDWARE_SIZING_MAX_AUTO_RESIZE_INCREASE_GI,
256
- CUSTOMER_HARDWARE_SIZING_MAX_PLANS_PER_REQUESTER,
257
- CUSTOMER_HARDWARE_SIZING_MAX_PLAN_JSON_LENGTH,
258
- CUSTOMER_HARDWARE_SIZING_NAME_MAX_LENGTH,
259
- CUSTOMER_HARDWARE_SIZING_NAME_MIN_LENGTH,
260
- CUSTOMER_HARDWARE_SIZING_REPLICA_SET_TOTAL_CAPS,
261
- CUSTOMER_HARDWARE_SIZING_RESOURCE_CAPS,
262
- checkCustomerHardwareSizing,
263
- isCustomerHardwareSizingStage,
252
+ CUSTOM_HARDWARE_SIZING_BROKER_TOTAL_CAPS,
253
+ CUSTOM_HARDWARE_SIZING_COUNT_CAPS,
254
+ CUSTOM_HARDWARE_SIZING_ELASTICSEARCH_TOTAL_CAPS,
255
+ CUSTOM_HARDWARE_SIZING_MAX_AUTO_RESIZE_INCREASE_GI,
256
+ CUSTOM_HARDWARE_SIZING_MAX_PLANS_PER_REQUESTER,
257
+ CUSTOM_HARDWARE_SIZING_MAX_PLAN_JSON_LENGTH,
258
+ CUSTOM_HARDWARE_SIZING_NAME_MAX_LENGTH,
259
+ CUSTOM_HARDWARE_SIZING_NAME_MIN_LENGTH,
260
+ CUSTOM_HARDWARE_SIZING_REPLICA_SET_TOTAL_CAPS,
261
+ CUSTOM_HARDWARE_SIZING_RESOURCE_CAPS,
262
+ checkCustomHardwareSizing,
263
+ isCustomHardwareSizingStage,
264
264
  parseKubernetesQuantity
265
265
  };
266
- //# sourceMappingURL=customer-hardware-sizing.const.js.map
266
+ //# sourceMappingURL=custom-hardware-sizing.const.js.map