@camunda/ccma-shared-types 7.4.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.
- package/dist/_tests/constants/custom-generation.const.spec.d.ts +1 -0
- package/dist/approvals/policy.js +2 -1
- package/dist/approvals/policy.js.map +2 -2
- package/dist/approvals/use-cases.const.d.ts +3 -0
- package/dist/approvals/use-cases.const.js +9 -1
- package/dist/approvals/use-cases.const.js.map +2 -2
- package/dist/constants/custom-generation.const.d.ts +28 -0
- package/dist/constants/custom-generation.const.js +67 -0
- package/dist/constants/custom-generation.const.js.map +7 -0
- package/dist/dtos/ApprovalJob.dto.d.ts +13 -0
- package/dist/dtos/ApprovalJob.dto.js.map +1 -1
- package/dist/dtos/SalesPlan.dto.d.ts +5 -0
- package/dist/dtos/SalesPlan.dto.js +8 -0
- package/dist/dtos/SalesPlan.dto.js.map +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +16 -0
- package/dist/index.js.map +2 -2
- package/dist/permissions/console.permissions.d.ts +7 -0
- package/dist/permissions/console.permissions.js +7 -0
- package/dist/permissions/console.permissions.js.map +2 -2
- package/dist/types/ClusterPlanTypeCategory.type.d.ts +1 -1
- package/dist/types/ClusterTtl.type.d.ts +27 -0
- package/dist/types/ClusterTtl.type.js.map +1 -1
- package/package.json +1 -1
|
@@ -94,3 +94,30 @@ export declare function validateClusterTtlUnlimited(input: {
|
|
|
94
94
|
reason?: unknown;
|
|
95
95
|
link?: unknown;
|
|
96
96
|
}): string | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* ClusterTtlDeletionPayload is the payload of a `cluster-ttl-deletion`
|
|
99
|
+
* approval request. The action reads `clusterId` and `orgId`: console-backend
|
|
100
|
+
* tests the TTL again, and keeps a cluster that another org owns now. The
|
|
101
|
+
* name, the expiry and `ttlSetBy` are copies for a reader.
|
|
102
|
+
*/
|
|
103
|
+
export interface ClusterTtlDeletionPayload {
|
|
104
|
+
clusterId: string;
|
|
105
|
+
clusterName?: string;
|
|
106
|
+
/** The org that owned the cluster when the cron read it. The delete demands it. */
|
|
107
|
+
orgId: string;
|
|
108
|
+
/** The end of the TTL, as an ISO date. */
|
|
109
|
+
ttlExpiresAt: string;
|
|
110
|
+
/** The email of the person who set the expiry. See `ttlSetBy` of a cluster. */
|
|
111
|
+
ttlSetBy?: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* ClusterTtlDeletionResult is what console-backend answers when a
|
|
115
|
+
* `cluster-ttl-deletion` request runs. `kept` means that the cluster does not
|
|
116
|
+
* pass the TTL rules any more, and console-backend did not delete it. An
|
|
117
|
+
* extension, a move, the flag, or a failover sibling that is not healthy can
|
|
118
|
+
* each be the cause.
|
|
119
|
+
*/
|
|
120
|
+
export interface ClusterTtlDeletionResult {
|
|
121
|
+
clusterId: string;
|
|
122
|
+
outcome: 'deleted' | 'kept';
|
|
123
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/types/ClusterTtl.type.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 { DAY, WEEK } from '../constants/duration.const.js'\n\n/**\n * CLUSTER_TTL_FEATURE_FLAG gates the TTL of a single cluster. It is not the\n * org-level `preprodClusterTtlHours` limit: both apply, and the earlier one\n * deletes the cluster.\n */\nexport const CLUSTER_TTL_FEATURE_FLAG = 'console.clusterTtl'\n\n/**\n * isClusterTtlStage tells if the cluster TTL can be on at the stage `stage`.\n * That is only dev and int. On prod, and on each other stage, the feature is\n * off for every reader, also when the flag is on.\n */\nexport const isClusterTtlStage = (stage: string | undefined): boolean =>\n stage === 'dev' || stage === 'int'\n\n/** CLUSTER_TTL_DURATIONS are the TTLs that end at a time. */\nexport const CLUSTER_TTL_DURATIONS = ['24h', '3d', '1w', '4w'] as const\n\nexport type ClusterTtlDuration = (typeof CLUSTER_TTL_DURATIONS)[number]\n\n/** CLUSTER_TTL_OPTIONS are the choices of the create form, in display order. */\nexport const CLUSTER_TTL_OPTIONS = [\n ...CLUSTER_TTL_DURATIONS,\n 'unlimited',\n] as const\n\nexport type ClusterTtlOption = (typeof CLUSTER_TTL_OPTIONS)[number]\n\n/** DEFAULT_CLUSTER_TTL_OPTION applies when an eligible create sends no `ttl`. */\nexport const DEFAULT_CLUSTER_TTL_OPTION: ClusterTtlOption = '24h'\n\nexport const CLUSTER_TTL_DURATION_MS: Readonly<\n Record<ClusterTtlDuration, number>\n> = {\n '24h': DAY,\n '3d': 3 * DAY,\n '1w': WEEK,\n '4w': 4 * WEEK,\n}\n\nexport const CLUSTER_TTL_UNLIMITED_REASON_MAX_LENGTH = 500\nexport const CLUSTER_TTL_UNLIMITED_LINK_MAX_LENGTH = 2048\n\n/**\n * CLUSTER_TTL_BACKFILL_REASON is the reason that the schema migration wrote\n * for each cluster that existed before the TTL. These rows are the only\n * unlimited TTLs with a reason and no link.\n */\nexport const CLUSTER_TTL_BACKFILL_REASON = 'Created before cluster TTL existed'\n\n/**\n * ClusterTtlDto is the TTL of one cluster. A response carries it only when\n * the reader may see the feature, thus an absent `ttl` means \"not shown\", not\n * \"unlimited\".\n */\nexport interface ClusterTtlDto {\n /** ISO-8601. Absent when the TTL is unlimited. */\n expiresAt?: string\n /**\n * Why the TTL is unlimited. Absent for a cluster that got no TTL, for\n * example one that a failover or a customer org created.\n */\n unlimitedReason?: string\n /** An http(s) URL, for example a GitHub issue. */\n unlimitedLink?: string\n}\n\n/** ClusterTtlUnlimited is the input that sets an unlimited TTL. */\nexport interface ClusterTtlUnlimited {\n reason: string\n link: string\n}\n\n/**\n * UpdateClusterTtlBody is the body of `PATCH api/admin/clusters/:clusterId/ttl`.\n * Give exactly one of the two fields.\n */\nexport type UpdateClusterTtlBody =\n | { extend: ClusterTtlDuration; unlimited?: never }\n | { unlimited: ClusterTtlUnlimited; extend?: never }\n\nexport const isClusterTtlDuration = (\n value: unknown,\n): value is ClusterTtlDuration =>\n (CLUSTER_TTL_DURATIONS as readonly unknown[]).includes(value)\n\nexport const isClusterTtlOption = (value: unknown): value is ClusterTtlOption =>\n (CLUSTER_TTL_OPTIONS as readonly unknown[]).includes(value)\n\n/** clusterTtlExpiresAt gives the expiry of a new TTL that starts at `now`. */\nexport function clusterTtlExpiresAt(\n duration: ClusterTtlDuration,\n now: Date = new Date(),\n): Date {\n return new Date(now.getTime() + CLUSTER_TTL_DURATION_MS[duration])\n}\n\n/**\n * extendClusterTtl gives the expiry after an extension. The extension starts\n * at the current expiry, or at `now` when that is in the past or when the TTL\n * is unlimited (`currentExpiresAt` undefined). Thus an extension never makes\n * the TTL shorter.\n */\nexport function extendClusterTtl({\n currentExpiresAt,\n duration,\n now = new Date(),\n}: {\n currentExpiresAt: Date | string | undefined\n duration: ClusterTtlDuration\n now?: Date\n}): Date {\n const currentMs =\n currentExpiresAt === undefined\n ? Number.NaN\n : new Date(currentExpiresAt).getTime()\n const startMs = Number.isNaN(currentMs)\n ? now.getTime()\n : Math.max(now.getTime(), currentMs)\n return new Date(startMs + CLUSTER_TTL_DURATION_MS[duration])\n}\n\n/**\n * isPastClusterTtl tells if the TTL of a cluster ran out. An unlimited TTL\n * (`expiresAt` undefined) or a value that is not a date never runs out.\n */\nexport function isPastClusterTtl({\n expiresAt,\n now = new Date(),\n}: {\n expiresAt: Date | string | undefined\n now?: Date\n}): boolean {\n if (expiresAt === undefined) return false\n const expiresMs = new Date(expiresAt).getTime()\n if (Number.isNaN(expiresMs)) return false\n return expiresMs < now.getTime()\n}\n\n/** isHttpUrl accepts an absolute `http:` or `https:` URL with a host. */\nexport function isHttpUrl(value: unknown): value is string {\n if (typeof value !== 'string' || /\\s/.test(value)) return false\n try {\n const url = new URL(value)\n return (\n (url.protocol === 'http:' || url.protocol === 'https:') &&\n url.hostname.length > 0\n )\n } catch {\n return false\n }\n}\n\n/**\n * validateClusterTtlUnlimited gives the first problem of an unlimited TTL\n * input as a message for the caller, or `undefined` when the input is valid.\n * The reason must hold text, and the link must be an http(s) URL. The length\n * limits apply to the trimmed values, because the server stores those.\n */\nexport function validateClusterTtlUnlimited(input: {\n reason?: unknown\n link?: unknown\n}): string | undefined {\n const reason =\n typeof input.reason === 'string' ? input.reason.trim() : undefined\n const link = typeof input.link === 'string' ? input.link.trim() : undefined\n if (!reason) {\n return 'An unlimited TTL needs a reason.'\n }\n if (reason.length > CLUSTER_TTL_UNLIMITED_REASON_MAX_LENGTH) {\n return `The reason must not be longer than ${CLUSTER_TTL_UNLIMITED_REASON_MAX_LENGTH} characters.`\n }\n if (!link) {\n return 'An unlimited TTL needs a link.'\n }\n if (link.length > CLUSTER_TTL_UNLIMITED_LINK_MAX_LENGTH) {\n return `The link must not be longer than ${CLUSTER_TTL_UNLIMITED_LINK_MAX_LENGTH} characters.`\n }\n if (!isHttpUrl(link)) {\n return 'The link must be an http or https URL.'\n }\n return undefined\n}\n"],
|
|
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 { DAY, WEEK } from '../constants/duration.const.js'\n\n/**\n * CLUSTER_TTL_FEATURE_FLAG gates the TTL of a single cluster. It is not the\n * org-level `preprodClusterTtlHours` limit: both apply, and the earlier one\n * deletes the cluster.\n */\nexport const CLUSTER_TTL_FEATURE_FLAG = 'console.clusterTtl'\n\n/**\n * isClusterTtlStage tells if the cluster TTL can be on at the stage `stage`.\n * That is only dev and int. On prod, and on each other stage, the feature is\n * off for every reader, also when the flag is on.\n */\nexport const isClusterTtlStage = (stage: string | undefined): boolean =>\n stage === 'dev' || stage === 'int'\n\n/** CLUSTER_TTL_DURATIONS are the TTLs that end at a time. */\nexport const CLUSTER_TTL_DURATIONS = ['24h', '3d', '1w', '4w'] as const\n\nexport type ClusterTtlDuration = (typeof CLUSTER_TTL_DURATIONS)[number]\n\n/** CLUSTER_TTL_OPTIONS are the choices of the create form, in display order. */\nexport const CLUSTER_TTL_OPTIONS = [\n ...CLUSTER_TTL_DURATIONS,\n 'unlimited',\n] as const\n\nexport type ClusterTtlOption = (typeof CLUSTER_TTL_OPTIONS)[number]\n\n/** DEFAULT_CLUSTER_TTL_OPTION applies when an eligible create sends no `ttl`. */\nexport const DEFAULT_CLUSTER_TTL_OPTION: ClusterTtlOption = '24h'\n\nexport const CLUSTER_TTL_DURATION_MS: Readonly<\n Record<ClusterTtlDuration, number>\n> = {\n '24h': DAY,\n '3d': 3 * DAY,\n '1w': WEEK,\n '4w': 4 * WEEK,\n}\n\nexport const CLUSTER_TTL_UNLIMITED_REASON_MAX_LENGTH = 500\nexport const CLUSTER_TTL_UNLIMITED_LINK_MAX_LENGTH = 2048\n\n/**\n * CLUSTER_TTL_BACKFILL_REASON is the reason that the schema migration wrote\n * for each cluster that existed before the TTL. These rows are the only\n * unlimited TTLs with a reason and no link.\n */\nexport const CLUSTER_TTL_BACKFILL_REASON = 'Created before cluster TTL existed'\n\n/**\n * ClusterTtlDto is the TTL of one cluster. A response carries it only when\n * the reader may see the feature, thus an absent `ttl` means \"not shown\", not\n * \"unlimited\".\n */\nexport interface ClusterTtlDto {\n /** ISO-8601. Absent when the TTL is unlimited. */\n expiresAt?: string\n /**\n * Why the TTL is unlimited. Absent for a cluster that got no TTL, for\n * example one that a failover or a customer org created.\n */\n unlimitedReason?: string\n /** An http(s) URL, for example a GitHub issue. */\n unlimitedLink?: string\n}\n\n/** ClusterTtlUnlimited is the input that sets an unlimited TTL. */\nexport interface ClusterTtlUnlimited {\n reason: string\n link: string\n}\n\n/**\n * UpdateClusterTtlBody is the body of `PATCH api/admin/clusters/:clusterId/ttl`.\n * Give exactly one of the two fields.\n */\nexport type UpdateClusterTtlBody =\n | { extend: ClusterTtlDuration; unlimited?: never }\n | { unlimited: ClusterTtlUnlimited; extend?: never }\n\nexport const isClusterTtlDuration = (\n value: unknown,\n): value is ClusterTtlDuration =>\n (CLUSTER_TTL_DURATIONS as readonly unknown[]).includes(value)\n\nexport const isClusterTtlOption = (value: unknown): value is ClusterTtlOption =>\n (CLUSTER_TTL_OPTIONS as readonly unknown[]).includes(value)\n\n/** clusterTtlExpiresAt gives the expiry of a new TTL that starts at `now`. */\nexport function clusterTtlExpiresAt(\n duration: ClusterTtlDuration,\n now: Date = new Date(),\n): Date {\n return new Date(now.getTime() + CLUSTER_TTL_DURATION_MS[duration])\n}\n\n/**\n * extendClusterTtl gives the expiry after an extension. The extension starts\n * at the current expiry, or at `now` when that is in the past or when the TTL\n * is unlimited (`currentExpiresAt` undefined). Thus an extension never makes\n * the TTL shorter.\n */\nexport function extendClusterTtl({\n currentExpiresAt,\n duration,\n now = new Date(),\n}: {\n currentExpiresAt: Date | string | undefined\n duration: ClusterTtlDuration\n now?: Date\n}): Date {\n const currentMs =\n currentExpiresAt === undefined\n ? Number.NaN\n : new Date(currentExpiresAt).getTime()\n const startMs = Number.isNaN(currentMs)\n ? now.getTime()\n : Math.max(now.getTime(), currentMs)\n return new Date(startMs + CLUSTER_TTL_DURATION_MS[duration])\n}\n\n/**\n * isPastClusterTtl tells if the TTL of a cluster ran out. An unlimited TTL\n * (`expiresAt` undefined) or a value that is not a date never runs out.\n */\nexport function isPastClusterTtl({\n expiresAt,\n now = new Date(),\n}: {\n expiresAt: Date | string | undefined\n now?: Date\n}): boolean {\n if (expiresAt === undefined) return false\n const expiresMs = new Date(expiresAt).getTime()\n if (Number.isNaN(expiresMs)) return false\n return expiresMs < now.getTime()\n}\n\n/** isHttpUrl accepts an absolute `http:` or `https:` URL with a host. */\nexport function isHttpUrl(value: unknown): value is string {\n if (typeof value !== 'string' || /\\s/.test(value)) return false\n try {\n const url = new URL(value)\n return (\n (url.protocol === 'http:' || url.protocol === 'https:') &&\n url.hostname.length > 0\n )\n } catch {\n return false\n }\n}\n\n/**\n * validateClusterTtlUnlimited gives the first problem of an unlimited TTL\n * input as a message for the caller, or `undefined` when the input is valid.\n * The reason must hold text, and the link must be an http(s) URL. The length\n * limits apply to the trimmed values, because the server stores those.\n */\nexport function validateClusterTtlUnlimited(input: {\n reason?: unknown\n link?: unknown\n}): string | undefined {\n const reason =\n typeof input.reason === 'string' ? input.reason.trim() : undefined\n const link = typeof input.link === 'string' ? input.link.trim() : undefined\n if (!reason) {\n return 'An unlimited TTL needs a reason.'\n }\n if (reason.length > CLUSTER_TTL_UNLIMITED_REASON_MAX_LENGTH) {\n return `The reason must not be longer than ${CLUSTER_TTL_UNLIMITED_REASON_MAX_LENGTH} characters.`\n }\n if (!link) {\n return 'An unlimited TTL needs a link.'\n }\n if (link.length > CLUSTER_TTL_UNLIMITED_LINK_MAX_LENGTH) {\n return `The link must not be longer than ${CLUSTER_TTL_UNLIMITED_LINK_MAX_LENGTH} characters.`\n }\n if (!isHttpUrl(link)) {\n return 'The link must be an http or https URL.'\n }\n return undefined\n}\n\n/**\n * ClusterTtlDeletionPayload is the payload of a `cluster-ttl-deletion`\n * approval request. The action reads `clusterId` and `orgId`: console-backend\n * tests the TTL again, and keeps a cluster that another org owns now. The\n * name, the expiry and `ttlSetBy` are copies for a reader.\n */\nexport interface ClusterTtlDeletionPayload {\n clusterId: string\n clusterName?: string\n /** The org that owned the cluster when the cron read it. The delete demands it. */\n orgId: string\n /** The end of the TTL, as an ISO date. */\n ttlExpiresAt: string\n /** The email of the person who set the expiry. See `ttlSetBy` of a cluster. */\n ttlSetBy?: string\n}\n\n/**\n * ClusterTtlDeletionResult is what console-backend answers when a\n * `cluster-ttl-deletion` request runs. `kept` means that the cluster does not\n * pass the TTL rules any more, and console-backend did not delete it. An\n * extension, a move, the flag, or a failover sibling that is not healthy can\n * each be the cause.\n */\nexport interface ClusterTtlDeletionResult {\n clusterId: string\n outcome: 'deleted' | 'kept'\n}\n"],
|
|
5
5
|
"mappings": "AAMA,SAAS,KAAK,YAAY;AAOnB,MAAM,2BAA2B;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