@camunda/ccma-shared-types 0.4.0 → 0.5.1
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/failoverRegionPairs.const.spec.d.ts +1 -0
- package/dist/_tests/search/compiler.spec.d.ts +1 -0
- package/dist/_tests/search/parser.spec.d.ts +1 -0
- package/dist/_tests/search/registry.spec.d.ts +1 -0
- package/dist/_tests/types/ClusterPlanFields.type.spec.d.ts +1 -0
- package/dist/_tests/utils/failoverKeyPolicy.utils.spec.d.ts +1 -0
- package/dist/constants/failoverRegionPairs.const.d.ts +8 -1
- package/dist/constants/failoverRegionPairs.const.js +9 -4
- package/dist/constants/failoverRegionPairs.const.js.map +2 -2
- package/dist/constants/misc.const.d.ts +0 -55
- package/dist/constants/misc.const.js +0 -82
- package/dist/constants/misc.const.js.map +2 -2
- package/dist/dtos/Backup.dto.d.ts +5 -0
- package/dist/dtos/ClusterPlan.dto.d.ts +5 -0
- package/dist/dtos/ClusterPlanType.dto.d.ts +6 -0
- package/dist/dtos/CommonCluster.dto.d.ts +18 -0
- package/dist/dtos/ControlV2.dto.d.ts +62 -14
- package/dist/dtos/K8sContext.dto.d.ts +6 -0
- package/dist/dtos/Organization.dto.d.ts +2 -0
- package/dist/dtos/Organization.dto.js.map +1 -1
- package/dist/dtos/ReleaseTrainSanity.dto.d.ts +51 -0
- package/dist/dtos/ReleaseTrainSanity.dto.js +1 -0
- package/dist/dtos/ReleaseTrainSanity.dto.js.map +7 -0
- package/dist/dtos/SalesPlan.dto.d.ts +11 -0
- package/dist/dtos/SalesPlan.dto.js +14 -0
- package/dist/dtos/SalesPlan.dto.js.map +2 -2
- package/dist/enums/OrganizationRole.enum.d.ts +1 -0
- package/dist/enums/OrganizationRole.enum.js +7 -0
- package/dist/enums/OrganizationRole.enum.js.map +2 -2
- package/dist/enums/SystemAuditEntity.enum.d.ts +7 -2
- package/dist/enums/SystemAuditEntity.enum.js +5 -0
- package/dist/enums/SystemAuditEntity.enum.js.map +2 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +48 -2
- package/dist/index.js.map +2 -2
- package/dist/permissions/combo.js +3 -0
- package/dist/permissions/combo.js.map +2 -2
- package/dist/permissions/console.permissions.d.ts +2 -0
- package/dist/permissions/console.permissions.js +7 -0
- package/dist/permissions/console.permissions.js.map +2 -2
- package/dist/search/ast.d.ts +52 -0
- package/dist/search/ast.js +18 -0
- package/dist/search/ast.js.map +7 -0
- package/dist/search/cluster-search-fields.d.ts +11 -0
- package/dist/search/cluster-search-fields.js +136 -0
- package/dist/search/cluster-search-fields.js.map +7 -0
- package/dist/search/compiler.d.ts +48 -0
- package/dist/search/compiler.js +217 -0
- package/dist/search/compiler.js.map +7 -0
- package/dist/search/fields.d.ts +24 -0
- package/dist/search/fields.js +5 -0
- package/dist/search/fields.js.map +7 -0
- package/dist/search/index.d.ts +6 -0
- package/dist/search/index.js +33 -0
- package/dist/search/index.js.map +7 -0
- package/dist/search/organization-search-fields.d.ts +9 -0
- package/dist/search/organization-search-fields.js +50 -0
- package/dist/search/organization-search-fields.js.map +7 -0
- package/dist/search/parser.d.ts +7 -0
- package/dist/search/parser.js +324 -0
- package/dist/search/parser.js.map +7 -0
- package/dist/types/ClusterModification.type.d.ts +1 -0
- package/dist/types/ClusterPlanFields.type.d.ts +24 -0
- package/dist/types/ClusterPlanFields.type.js +591 -0
- package/dist/types/ClusterPlanFields.type.js.map +7 -0
- package/dist/types/ClusterPlanModification.type.d.ts +3 -0
- package/dist/types/EnterpriseIncludingValueMetrics.type.d.ts +1 -0
- package/dist/types/HdpTenantUsage.type.d.ts +4 -0
- package/dist/types/HdpTenantUsage.type.js +1 -0
- package/dist/types/HdpTenantUsage.type.js.map +7 -0
- package/dist/utils/enterpriseTerm.utils.d.ts +78 -0
- package/dist/utils/enterpriseTerm.utils.js +69 -0
- package/dist/utils/enterpriseTerm.utils.js.map +7 -0
- package/dist/utils/enterpriseTerm.utils.spec.d.ts +1 -0
- package/dist/utils/failoverKeyPolicy.utils.d.ts +26 -0
- package/dist/utils/failoverKeyPolicy.utils.js +15 -0
- package/dist/utils/failoverKeyPolicy.utils.js.map +7 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=HdpTenantUsage.type.js.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The enterprise contract period a usage figure belongs to.
|
|
3
|
+
*
|
|
4
|
+
* An enterprise contract starts at `enterpriseStartDate` and renews every
|
|
5
|
+
* `enterpriseDurationInMonth` months. Usage is measured against the *current*
|
|
6
|
+
* period's included quota, so anything summed or peaked over a wider window
|
|
7
|
+
* bills a previous term's usage against this term's inclusions.
|
|
8
|
+
*
|
|
9
|
+
* Extracted from c4's billing tab so that surface, control-frontend and
|
|
10
|
+
* accounts-frontend cannot disagree about which days a figure covers — three
|
|
11
|
+
* copies of this arithmetic is how the same metric ends up with three different
|
|
12
|
+
* values depending on where a Camundi reads it.
|
|
13
|
+
*/
|
|
14
|
+
export interface EnterpriseTermWindow {
|
|
15
|
+
/** First day of the current period. Keeps the wall-clock time of the start date. */
|
|
16
|
+
periodStart: Date;
|
|
17
|
+
/** Last day of the current period (inclusive). */
|
|
18
|
+
periodEnd: Date;
|
|
19
|
+
/** How many full periods have elapsed since the contract started. */
|
|
20
|
+
completedPeriods: number;
|
|
21
|
+
/** First day of the next period. */
|
|
22
|
+
nextRenewal: Date;
|
|
23
|
+
/** Months elapsed at `periodStart`, i.e. the first month index of this period. */
|
|
24
|
+
startMonth: number;
|
|
25
|
+
/** Last month index of this period. */
|
|
26
|
+
endMonth: number;
|
|
27
|
+
}
|
|
28
|
+
/** Default contract length when the org carries no explicit duration. */
|
|
29
|
+
export declare const DEFAULT_ENTERPRISE_DURATION_IN_MONTHS = 12;
|
|
30
|
+
/**
|
|
31
|
+
* Add months, clamping to the end of the target month rather than rolling into
|
|
32
|
+
* the next one — `addMonthsClamped(Jan 31, 1)` is Feb 28/29, not Mar 2/3.
|
|
33
|
+
*
|
|
34
|
+
* Deliberately local-time (`getMonth`/`setMonth`), matching how contract dates
|
|
35
|
+
* are compared elsewhere; only the day-bucket comparison against HDP rows
|
|
36
|
+
* switches to UTC, via `toUtcDayStartMs`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function addMonthsClamped(date: Date, months: number): Date;
|
|
39
|
+
/** Whole months between two dates, ignoring the day of month. */
|
|
40
|
+
export declare function diffInWholeMonths(start: Date, end: Date): number;
|
|
41
|
+
/**
|
|
42
|
+
* The UTC day `date` falls on, as epoch millis.
|
|
43
|
+
*
|
|
44
|
+
* HDP buckets usage per UTC day (a BigQuery DATE column, so every row's ts is
|
|
45
|
+
* UTC midnight), whereas a contract bound keeps the wall-clock time it was
|
|
46
|
+
* created at. Comparing the two directly drops the term's first day whenever the
|
|
47
|
+
* plan was created after midnight, so both sides collapse to a UTC day first.
|
|
48
|
+
*/
|
|
49
|
+
export declare function toUtcDayStartMs(date: Date): number;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve the contract period that `now` falls in.
|
|
52
|
+
*
|
|
53
|
+
* `durationInMonths` falls back to 12 for anything non-positive or absent,
|
|
54
|
+
* matching what the billing surfaces already assumed. `null` is accepted as well
|
|
55
|
+
* as `undefined` because the accounts MobX model stores the field as
|
|
56
|
+
* `types.maybeNull(types.number)` while the DTO has it optional — callers
|
|
57
|
+
* shouldn't have to normalise that difference at every call site.
|
|
58
|
+
*
|
|
59
|
+
* A contract dated in the future resolves to its first period — nothing has been
|
|
60
|
+
* used before it starts, so there is no earlier window to report on.
|
|
61
|
+
*/
|
|
62
|
+
export declare function getCurrentEnterpriseTerm(options: {
|
|
63
|
+
startDate: Date;
|
|
64
|
+
durationInMonths?: number | null;
|
|
65
|
+
now?: Date;
|
|
66
|
+
}): EnterpriseTermWindow;
|
|
67
|
+
/**
|
|
68
|
+
* Peak value among the points inside `term`, or 0 when none fall in it.
|
|
69
|
+
*
|
|
70
|
+
* For a gauge like tenants the org's figure for a period is its highest daily
|
|
71
|
+
* reading, never a sum — and the reading has to come from *this* period. Both
|
|
72
|
+
* ends are inclusive and compared as UTC days, so the term's first and last day
|
|
73
|
+
* count regardless of the time of day the contract was created at.
|
|
74
|
+
*/
|
|
75
|
+
export declare function peakWithinTerm(points: readonly {
|
|
76
|
+
ts: number;
|
|
77
|
+
value: number;
|
|
78
|
+
}[], term: Pick<EnterpriseTermWindow, 'periodStart' | 'periodEnd'>): number;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const DAY_MS = 24 * 60 * 60 * 1e3;
|
|
2
|
+
const DEFAULT_ENTERPRISE_DURATION_IN_MONTHS = 12;
|
|
3
|
+
function addMonthsClamped(date, months) {
|
|
4
|
+
const next = new Date(date.getTime());
|
|
5
|
+
const originalDay = next.getDate();
|
|
6
|
+
next.setMonth(next.getMonth() + months);
|
|
7
|
+
if (next.getDate() !== originalDay) {
|
|
8
|
+
next.setDate(0);
|
|
9
|
+
}
|
|
10
|
+
return next;
|
|
11
|
+
}
|
|
12
|
+
function diffInWholeMonths(start, end) {
|
|
13
|
+
return (end.getFullYear() - start.getFullYear()) * 12 + (end.getMonth() - start.getMonth());
|
|
14
|
+
}
|
|
15
|
+
function toUtcDayStartMs(date) {
|
|
16
|
+
return Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
|
|
17
|
+
}
|
|
18
|
+
function getCurrentEnterpriseTerm(options) {
|
|
19
|
+
const now = options.now ?? /* @__PURE__ */ new Date();
|
|
20
|
+
const durationInMonths = typeof options.durationInMonths === "number" && options.durationInMonths > 0 ? options.durationInMonths : DEFAULT_ENTERPRISE_DURATION_IN_MONTHS;
|
|
21
|
+
let completedPeriods = Math.max(
|
|
22
|
+
0,
|
|
23
|
+
Math.floor(
|
|
24
|
+
Math.abs(diffInWholeMonths(options.startDate, now)) / durationInMonths
|
|
25
|
+
)
|
|
26
|
+
);
|
|
27
|
+
const nowDay = toUtcDayStartMs(now);
|
|
28
|
+
const periodStartDay = (periods) => toUtcDayStartMs(
|
|
29
|
+
addMonthsClamped(options.startDate, periods * durationInMonths)
|
|
30
|
+
);
|
|
31
|
+
while (completedPeriods > 0 && periodStartDay(completedPeriods) > nowDay) {
|
|
32
|
+
completedPeriods -= 1;
|
|
33
|
+
}
|
|
34
|
+
while (periodStartDay(completedPeriods + 1) <= nowDay) {
|
|
35
|
+
completedPeriods += 1;
|
|
36
|
+
}
|
|
37
|
+
const periodStart = addMonthsClamped(
|
|
38
|
+
options.startDate,
|
|
39
|
+
completedPeriods * durationInMonths
|
|
40
|
+
);
|
|
41
|
+
const nextRenewal = addMonthsClamped(periodStart, durationInMonths);
|
|
42
|
+
const periodEnd = new Date(nextRenewal.getTime() - DAY_MS);
|
|
43
|
+
const startMonth = completedPeriods * durationInMonths;
|
|
44
|
+
return {
|
|
45
|
+
periodStart,
|
|
46
|
+
periodEnd,
|
|
47
|
+
completedPeriods,
|
|
48
|
+
nextRenewal,
|
|
49
|
+
startMonth,
|
|
50
|
+
endMonth: startMonth + (durationInMonths - 1)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function peakWithinTerm(points, term) {
|
|
54
|
+
const from = toUtcDayStartMs(term.periodStart);
|
|
55
|
+
const to = toUtcDayStartMs(term.periodEnd);
|
|
56
|
+
return points.reduce(
|
|
57
|
+
(peak, point) => point.ts >= from && point.ts <= to ? Math.max(peak, point.value) : peak,
|
|
58
|
+
0
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
DEFAULT_ENTERPRISE_DURATION_IN_MONTHS,
|
|
63
|
+
addMonthsClamped,
|
|
64
|
+
diffInWholeMonths,
|
|
65
|
+
getCurrentEnterpriseTerm,
|
|
66
|
+
peakWithinTerm,
|
|
67
|
+
toUtcDayStartMs
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=enterpriseTerm.utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/enterpriseTerm.utils.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\n/**\n * The enterprise contract period a usage figure belongs to.\n *\n * An enterprise contract starts at `enterpriseStartDate` and renews every\n * `enterpriseDurationInMonth` months. Usage is measured against the *current*\n * period's included quota, so anything summed or peaked over a wider window\n * bills a previous term's usage against this term's inclusions.\n *\n * Extracted from c4's billing tab so that surface, control-frontend and\n * accounts-frontend cannot disagree about which days a figure covers \u2014 three\n * copies of this arithmetic is how the same metric ends up with three different\n * values depending on where a Camundi reads it.\n */\nexport interface EnterpriseTermWindow {\n /** First day of the current period. Keeps the wall-clock time of the start date. */\n periodStart: Date\n /** Last day of the current period (inclusive). */\n periodEnd: Date\n /** How many full periods have elapsed since the contract started. */\n completedPeriods: number\n /** First day of the next period. */\n nextRenewal: Date\n /** Months elapsed at `periodStart`, i.e. the first month index of this period. */\n startMonth: number\n /** Last month index of this period. */\n endMonth: number\n}\n\nconst DAY_MS = 24 * 60 * 60 * 1000\n\n/** Default contract length when the org carries no explicit duration. */\nexport const DEFAULT_ENTERPRISE_DURATION_IN_MONTHS = 12\n\n/**\n * Add months, clamping to the end of the target month rather than rolling into\n * the next one \u2014 `addMonthsClamped(Jan 31, 1)` is Feb 28/29, not Mar 2/3.\n *\n * Deliberately local-time (`getMonth`/`setMonth`), matching how contract dates\n * are compared elsewhere; only the day-bucket comparison against HDP rows\n * switches to UTC, via `toUtcDayStartMs`.\n */\nexport function addMonthsClamped(date: Date, months: number): Date {\n const next = new Date(date.getTime())\n const originalDay = next.getDate()\n next.setMonth(next.getMonth() + months)\n\n if (next.getDate() !== originalDay) {\n next.setDate(0)\n }\n\n return next\n}\n\n/** Whole months between two dates, ignoring the day of month. */\nexport function diffInWholeMonths(start: Date, end: Date): number {\n return (\n (end.getFullYear() - start.getFullYear()) * 12 +\n (end.getMonth() - start.getMonth())\n )\n}\n\n/**\n * The UTC day `date` falls on, as epoch millis.\n *\n * HDP buckets usage per UTC day (a BigQuery DATE column, so every row's ts is\n * UTC midnight), whereas a contract bound keeps the wall-clock time it was\n * created at. Comparing the two directly drops the term's first day whenever the\n * plan was created after midnight, so both sides collapse to a UTC day first.\n */\nexport function toUtcDayStartMs(date: Date): number {\n return Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate())\n}\n\n/**\n * Resolve the contract period that `now` falls in.\n *\n * `durationInMonths` falls back to 12 for anything non-positive or absent,\n * matching what the billing surfaces already assumed. `null` is accepted as well\n * as `undefined` because the accounts MobX model stores the field as\n * `types.maybeNull(types.number)` while the DTO has it optional \u2014 callers\n * shouldn't have to normalise that difference at every call site.\n *\n * A contract dated in the future resolves to its first period \u2014 nothing has been\n * used before it starts, so there is no earlier window to report on.\n */\nexport function getCurrentEnterpriseTerm(options: {\n startDate: Date\n durationInMonths?: number | null\n now?: Date\n}): EnterpriseTermWindow {\n const now = options.now ?? new Date()\n const durationInMonths =\n typeof options.durationInMonths === 'number' && options.durationInMonths > 0\n ? options.durationInMonths\n : DEFAULT_ENTERPRISE_DURATION_IN_MONTHS\n\n // `diffInWholeMonths` ignores the day of month, so this is only an estimate:\n // for a contract starting the 15th, `now` on the 1st of an anniversary month\n // counts a full extra month and the estimate overshoots into a period that\n // hasn't started yet. `abs` keeps a future-dated contract off a negative index.\n let completedPeriods = Math.max(\n 0,\n Math.floor(\n Math.abs(diffInWholeMonths(options.startDate, now)) / durationInMonths,\n ),\n )\n\n // Correct the estimate against the real dates until `now` actually sits in the\n // period. Compared as UTC days so the renewal day belongs to the new period\n // rather than to neither \u2014 the same day granularity `peakWithinTerm` uses.\n // Both loops are bounded: the day-of-month error is under one month, so the\n // estimate is at most one period out either way.\n const nowDay = toUtcDayStartMs(now)\n const periodStartDay = (periods: number): number =>\n toUtcDayStartMs(\n addMonthsClamped(options.startDate, periods * durationInMonths),\n )\n\n while (completedPeriods > 0 && periodStartDay(completedPeriods) > nowDay) {\n completedPeriods -= 1\n }\n while (periodStartDay(completedPeriods + 1) <= nowDay) {\n completedPeriods += 1\n }\n\n const periodStart = addMonthsClamped(\n options.startDate,\n completedPeriods * durationInMonths,\n )\n const nextRenewal = addMonthsClamped(periodStart, durationInMonths)\n const periodEnd = new Date(nextRenewal.getTime() - DAY_MS)\n const startMonth = completedPeriods * durationInMonths\n\n return {\n periodStart,\n periodEnd,\n completedPeriods,\n nextRenewal,\n startMonth,\n endMonth: startMonth + (durationInMonths - 1),\n }\n}\n\n/**\n * Peak value among the points inside `term`, or 0 when none fall in it.\n *\n * For a gauge like tenants the org's figure for a period is its highest daily\n * reading, never a sum \u2014 and the reading has to come from *this* period. Both\n * ends are inclusive and compared as UTC days, so the term's first and last day\n * count regardless of the time of day the contract was created at.\n */\nexport function peakWithinTerm(\n points: readonly { ts: number; value: number }[],\n term: Pick<EnterpriseTermWindow, 'periodStart' | 'periodEnd'>,\n): number {\n const from = toUtcDayStartMs(term.periodStart)\n const to = toUtcDayStartMs(term.periodEnd)\n\n return points.reduce(\n (peak, point) =>\n point.ts >= from && point.ts <= to ? Math.max(peak, point.value) : peak,\n 0,\n )\n}\n"],
|
|
5
|
+
"mappings": "AAkCA,MAAM,SAAS,KAAK,KAAK,KAAK;AAGvB,MAAM,wCAAwC;AAU9C,SAAS,iBAAiB,MAAY,QAAsB;AACjE,QAAM,OAAO,IAAI,KAAK,KAAK,QAAQ,CAAC;AACpC,QAAM,cAAc,KAAK,QAAQ;AACjC,OAAK,SAAS,KAAK,SAAS,IAAI,MAAM;AAEtC,MAAI,KAAK,QAAQ,MAAM,aAAa;AAClC,SAAK,QAAQ,CAAC;AAAA,EAChB;AAEA,SAAO;AACT;AAGO,SAAS,kBAAkB,OAAa,KAAmB;AAChE,UACG,IAAI,YAAY,IAAI,MAAM,YAAY,KAAK,MAC3C,IAAI,SAAS,IAAI,MAAM,SAAS;AAErC;AAUO,SAAS,gBAAgB,MAAoB;AAClD,SAAO,KAAK,IAAI,KAAK,eAAe,GAAG,KAAK,YAAY,GAAG,KAAK,WAAW,CAAC;AAC9E;AAcO,SAAS,yBAAyB,SAIhB;AACvB,QAAM,MAAM,QAAQ,OAAO,oBAAI,KAAK;AACpC,QAAM,mBACJ,OAAO,QAAQ,qBAAqB,YAAY,QAAQ,mBAAmB,IACvE,QAAQ,mBACR;AAMN,MAAI,mBAAmB,KAAK;AAAA,IAC1B;AAAA,IACA,KAAK;AAAA,MACH,KAAK,IAAI,kBAAkB,QAAQ,WAAW,GAAG,CAAC,IAAI;AAAA,IACxD;AAAA,EACF;AAOA,QAAM,SAAS,gBAAgB,GAAG;AAClC,QAAM,iBAAiB,CAAC,YACtB;AAAA,IACE,iBAAiB,QAAQ,WAAW,UAAU,gBAAgB;AAAA,EAChE;AAEF,SAAO,mBAAmB,KAAK,eAAe,gBAAgB,IAAI,QAAQ;AACxE,wBAAoB;AAAA,EACtB;AACA,SAAO,eAAe,mBAAmB,CAAC,KAAK,QAAQ;AACrD,wBAAoB;AAAA,EACtB;AAEA,QAAM,cAAc;AAAA,IAClB,QAAQ;AAAA,IACR,mBAAmB;AAAA,EACrB;AACA,QAAM,cAAc,iBAAiB,aAAa,gBAAgB;AAClE,QAAM,YAAY,IAAI,KAAK,YAAY,QAAQ,IAAI,MAAM;AACzD,QAAM,aAAa,mBAAmB;AAEtC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU,cAAc,mBAAmB;AAAA,EAC7C;AACF;AAUO,SAAS,eACd,QACA,MACQ;AACR,QAAM,OAAO,gBAAgB,KAAK,WAAW;AAC7C,QAAM,KAAK,gBAAgB,KAAK,SAAS;AAEzC,SAAO,OAAO;AAAA,IACZ,CAAC,MAAM,UACL,MAAM,MAAM,QAAQ,MAAM,MAAM,KAAK,KAAK,IAAI,MAAM,MAAM,KAAK,IAAI;AAAA,IACrE;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The three IAM principals that need access to a BYOK cluster's KMS keys after
|
|
3
|
+
* a failover. All three live in the failover region's account — the same
|
|
4
|
+
* account as the failover cluster's own role.
|
|
5
|
+
*/
|
|
6
|
+
export interface FailoverKeyPolicyPrincipals {
|
|
7
|
+
/** Reads the source cluster's secondary bucket during the BucketClone. */
|
|
8
|
+
cloneRole: string;
|
|
9
|
+
/** The failover cluster's own access to its new primary bucket. */
|
|
10
|
+
clusterRole: string;
|
|
11
|
+
/** Replicates the new primary bucket back out to its secondary. */
|
|
12
|
+
replicationRole: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Derive the three principals a customer must add to both KMS key policies
|
|
16
|
+
* after a failover, from the failover cluster's own role ARN and the stableId
|
|
17
|
+
* carried over from its source.
|
|
18
|
+
*
|
|
19
|
+
* The clone role is pre-staged as `clone-backup-<stableId>`, and the
|
|
20
|
+
* replication role is the cluster role with a `-replication` suffix — so the
|
|
21
|
+
* account parsed out of the cluster role ARN is all that is needed.
|
|
22
|
+
*
|
|
23
|
+
* Returns `undefined` when either input is missing or the role ARN is not in
|
|
24
|
+
* the expected shape, so callers render nothing rather than a wrong ARN.
|
|
25
|
+
*/
|
|
26
|
+
export declare function deriveFailoverKeyPolicyPrincipals(clusterRoleArn: string | undefined, stableId: string | undefined): FailoverKeyPolicyPrincipals | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const CLUSTER_ROLE_ARN = /^arn:aws:iam::(?<account>\d{12}):role\/c8-cluster\/c8-apps-(?<uuid>[0-9a-f-]{36})$/u;
|
|
2
|
+
function deriveFailoverKeyPolicyPrincipals(clusterRoleArn, stableId) {
|
|
3
|
+
if (!clusterRoleArn || !stableId) return void 0;
|
|
4
|
+
const account = CLUSTER_ROLE_ARN.exec(clusterRoleArn)?.groups?.account;
|
|
5
|
+
if (!account) return void 0;
|
|
6
|
+
return {
|
|
7
|
+
cloneRole: `arn:aws:iam::${account}:role/c8-cluster/clone-backup-${stableId}`,
|
|
8
|
+
clusterRole: clusterRoleArn,
|
|
9
|
+
replicationRole: `${clusterRoleArn}-replication`
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
deriveFailoverKeyPolicyPrincipals
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=failoverKeyPolicy.utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/failoverKeyPolicy.utils.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\n/**\n * The cluster's own IAM role ARN, surfaced by the operator on the ZeebeCluster\n * `status.accountId` field (the name is historical \u2014 the value is a role ARN,\n * not a bare account id):\n *\n * arn:aws:iam::<account>:role/c8-cluster/c8-apps-<clusterUuid>\n */\nconst CLUSTER_ROLE_ARN =\n /^arn:aws:iam::(?<account>\\d{12}):role\\/c8-cluster\\/c8-apps-(?<uuid>[0-9a-f-]{36})$/u\n\n/**\n * The three IAM principals that need access to a BYOK cluster's KMS keys after\n * a failover. All three live in the failover region's account \u2014 the same\n * account as the failover cluster's own role.\n */\nexport interface FailoverKeyPolicyPrincipals {\n /** Reads the source cluster's secondary bucket during the BucketClone. */\n cloneRole: string\n /** The failover cluster's own access to its new primary bucket. */\n clusterRole: string\n /** Replicates the new primary bucket back out to its secondary. */\n replicationRole: string\n}\n\n/**\n * Derive the three principals a customer must add to both KMS key policies\n * after a failover, from the failover cluster's own role ARN and the stableId\n * carried over from its source.\n *\n * The clone role is pre-staged as `clone-backup-<stableId>`, and the\n * replication role is the cluster role with a `-replication` suffix \u2014 so the\n * account parsed out of the cluster role ARN is all that is needed.\n *\n * Returns `undefined` when either input is missing or the role ARN is not in\n * the expected shape, so callers render nothing rather than a wrong ARN.\n */\nexport function deriveFailoverKeyPolicyPrincipals(\n clusterRoleArn: string | undefined,\n stableId: string | undefined,\n): FailoverKeyPolicyPrincipals | undefined {\n if (!clusterRoleArn || !stableId) return undefined\n\n const account = CLUSTER_ROLE_ARN.exec(clusterRoleArn)?.groups?.account\n if (!account) return undefined\n\n return {\n cloneRole: `arn:aws:iam::${account}:role/c8-cluster/clone-backup-${stableId}`,\n clusterRole: clusterRoleArn,\n replicationRole: `${clusterRoleArn}-replication`,\n }\n}\n"],
|
|
5
|
+
"mappings": "AAaA,MAAM,mBACJ;AA4BK,SAAS,kCACd,gBACA,UACyC;AACzC,MAAI,CAAC,kBAAkB,CAAC,SAAU,QAAO;AAEzC,QAAM,UAAU,iBAAiB,KAAK,cAAc,GAAG,QAAQ;AAC/D,MAAI,CAAC,QAAS,QAAO;AAErB,SAAO;AAAA,IACL,WAAW,gBAAgB,OAAO,iCAAiC,QAAQ;AAAA,IAC3E,aAAa;AAAA,IACb,iBAAiB,GAAG,cAAc;AAAA,EACpC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camunda/ccma-shared-types",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Shared TypeScript types for Camunda Cloud Management Apps",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/camunda/camunda-cloud-management-apps/issues"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"registry": "https://registry.npmjs.org/"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"semver": "7.8.
|
|
26
|
+
"semver": "7.8.5"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "node esbuild.mjs && tsc --emitDeclarationOnly --outDir dist",
|