typekro 0.38.2 → 0.40.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/.tsbuildinfo +1 -1
- package/dist/core/aspects/values-merge.d.ts +14 -0
- package/dist/core/aspects/values-merge.d.ts.map +1 -1
- package/dist/core/aspects/values-merge.js +27 -0
- package/dist/core/aspects/values-merge.js.map +1 -1
- package/dist/factories/clickhouse/utils/helm-values-mapper.d.ts.map +1 -1
- package/dist/factories/clickhouse/utils/helm-values-mapper.js +7 -8
- package/dist/factories/clickhouse/utils/helm-values-mapper.js.map +1 -1
- package/dist/factories/clickstack/compositions/clickstack-bootstrap.d.ts +29 -2
- package/dist/factories/clickstack/compositions/clickstack-bootstrap.d.ts.map +1 -1
- package/dist/factories/clickstack/compositions/clickstack-bootstrap.js +298 -46
- package/dist/factories/clickstack/compositions/clickstack-bootstrap.js.map +1 -1
- package/dist/factories/clickstack/hyperdx-oidc/index.d.ts +2 -2
- package/dist/factories/clickstack/hyperdx-oidc/index.d.ts.map +1 -1
- package/dist/factories/clickstack/hyperdx-oidc/index.js +25 -8
- package/dist/factories/clickstack/hyperdx-oidc/index.js.map +1 -1
- package/dist/factories/clickstack/hyperdx-oidc/plugin-bundle.generated.d.ts.map +1 -1
- package/dist/factories/clickstack/hyperdx-oidc/plugin-bundle.generated.js +4 -4
- package/dist/factories/clickstack/hyperdx-oidc/plugin-bundle.generated.js.map +1 -1
- package/dist/factories/clickstack/types.d.ts +159 -1
- package/dist/factories/clickstack/types.d.ts.map +1 -1
- package/dist/factories/clickstack/types.js +123 -1
- package/dist/factories/clickstack/types.js.map +1 -1
- package/dist/factories/clickstack/utils/helm-values-mapper.d.ts +71 -2
- package/dist/factories/clickstack/utils/helm-values-mapper.d.ts.map +1 -1
- package/dist/factories/clickstack/utils/helm-values-mapper.js +149 -121
- package/dist/factories/clickstack/utils/helm-values-mapper.js.map +1 -1
- package/dist/factories/clickstack/utils/storage.d.ts +76 -0
- package/dist/factories/clickstack/utils/storage.d.ts.map +1 -1
- package/dist/factories/clickstack/utils/storage.js +167 -1
- package/dist/factories/clickstack/utils/storage.js.map +1 -1
- package/dist/factories/clickstack/utils/team-defaults.d.ts +87 -0
- package/dist/factories/clickstack/utils/team-defaults.d.ts.map +1 -0
- package/dist/factories/clickstack/utils/team-defaults.js +462 -0
- package/dist/factories/clickstack/utils/team-defaults.js.map +1 -0
- package/dist/factories/inngest/utils/helm-values-mapper.d.ts.map +1 -1
- package/dist/factories/inngest/utils/helm-values-mapper.js +16 -10
- package/dist/factories/inngest/utils/helm-values-mapper.js.map +1 -1
- package/dist/factories/rook/utils/helm-values-mapper.d.ts.map +1 -1
- package/dist/factories/rook/utils/helm-values-mapper.js +7 -8
- package/dist/factories/rook/utils/helm-values-mapper.js.map +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
// HyperDX Team defaults: the ClickHouse connection and the log / trace /
|
|
2
|
+
// metric / session sources a Team needs before HyperDX's UI stops showing its
|
|
3
|
+
// "set up your connection to ClickHouse" onboarding modal.
|
|
4
|
+
//
|
|
5
|
+
// HOW HYPERDX DOES IT (read from the published hyperdx:2.35.0 image,
|
|
6
|
+
// /app/packages/api/build):
|
|
7
|
+
//
|
|
8
|
+
// - `setupDefaults.js` / `setupTeamDefaults(teamId)` parses the
|
|
9
|
+
// `DEFAULT_CONNECTIONS` / `DEFAULT_SOURCES` env (`config.js`). It creates the
|
|
10
|
+
// connections when the Team has none, then the sources when the Team has
|
|
11
|
+
// none. A source's `connection` names a connection, which it resolves to that
|
|
12
|
+
// connection's `_id`. A second pass writes `logSourceId` / `traceSourceId` /
|
|
13
|
+
// `sessionSourceId` / `metricSourceId` as the referenced source's `_id` as a
|
|
14
|
+
// hex STRING.
|
|
15
|
+
// - It is called from exactly two places: `routers/api/root.js`
|
|
16
|
+
// (`POST /register/password`, right after `createTeam`) and `server.js` (local
|
|
17
|
+
// app mode only). A Team created any other way, such as the Team this
|
|
18
|
+
// composition inserts when `initialUser` is not configured, never gets
|
|
19
|
+
// defaults. That is the empty Team, and the onboarding modal, this module
|
|
20
|
+
// fixes.
|
|
21
|
+
// - `models/connection.js`: collection `connections`, fields `team`
|
|
22
|
+
// (ObjectId), `name`, `host`, `username`, `password` (a PLAIN string, stored
|
|
23
|
+
// as given; `select: false` only hides it from reads), timestamps. No `port`
|
|
24
|
+
// field: `DEFAULT_CONNECTIONS`' `port` is dropped by Mongoose's strict mode.
|
|
25
|
+
// Index `{team: 1, _id: 1}`.
|
|
26
|
+
// - `models/source.js`: collection `sources`, discriminated on `kind`. Base
|
|
27
|
+
// fields `team`, `connection` (ObjectId), `name`, `section`, `disabled`
|
|
28
|
+
// (default false), `from {databaseName, tableName}`,
|
|
29
|
+
// `timestampValueExpression`, `querySettings` (array, so default []). Each
|
|
30
|
+
// kind declares its own fields and strict mode drops the rest, so the session
|
|
31
|
+
// source keeps only `traceSourceId` and `resourceAttributesExpression`.
|
|
32
|
+
// `metricTables` is a nested schema with `_id: false`. Index
|
|
33
|
+
// `{team: 1, _id: 1}`.
|
|
34
|
+
// - The frontend's `OnboardingModal` opens its "connection" step when
|
|
35
|
+
// `GET /api/connections` returns [] and its source step when
|
|
36
|
+
// `GET /api/sources` returns [].
|
|
37
|
+
//
|
|
38
|
+
// WHY THE BOOTSTRAP WRITES THE DOCUMENTS, not HyperDX's own function: it can
|
|
39
|
+
// only be called from inside the HyperDX API process. The OIDC plugin runs
|
|
40
|
+
// there, but only when OIDC is configured, and the empty Team exists in every
|
|
41
|
+
// deployment. Running it from a CronJob would mean a second copy of the HyperDX
|
|
42
|
+
// image, pinned to whatever tag the chart resolved. So the CronJob writes
|
|
43
|
+
// exactly what `setupTeamDefaults` writes for the same input (the real-image
|
|
44
|
+
// integration test compares the two field by field), and `HYPERDX_SOURCE_FIELDS`
|
|
45
|
+
// below records the 2.35.0 schema it mirrors.
|
|
46
|
+
import { CLICKSTACK_CLICKHOUSE_HOST_URL_CHECK_SOURCE } from '../types.js';
|
|
47
|
+
/** Name of the HyperDX connection emitted into `defaultConnections`/`defaultSources`. */
|
|
48
|
+
export const CLICKSTACK_CONNECTION_NAME = 'External ClickHouse';
|
|
49
|
+
/**
|
|
50
|
+
* The HyperDX default sources TypeKro renders into the chart's `defaultSources`
|
|
51
|
+
* and seeds into an empty Team. They mirror the chart defaults (chart 3.2.0),
|
|
52
|
+
* with the connection renamed and the database left as a placeholder.
|
|
53
|
+
*/
|
|
54
|
+
export const CLICKSTACK_DEFAULT_SOURCES = [
|
|
55
|
+
{
|
|
56
|
+
from: { databaseName: '%s', tableName: 'otel_logs' },
|
|
57
|
+
kind: 'log',
|
|
58
|
+
timestampValueExpression: 'Timestamp',
|
|
59
|
+
name: 'Logs',
|
|
60
|
+
displayedTimestampValueExpression: 'Timestamp',
|
|
61
|
+
implicitColumnExpression: 'Body',
|
|
62
|
+
serviceNameExpression: 'ServiceName',
|
|
63
|
+
bodyExpression: 'Body',
|
|
64
|
+
eventAttributesExpression: 'LogAttributes',
|
|
65
|
+
resourceAttributesExpression: 'ResourceAttributes',
|
|
66
|
+
defaultTableSelectExpression: 'Timestamp,ServiceName,SeverityText,Body',
|
|
67
|
+
severityTextExpression: 'SeverityText',
|
|
68
|
+
traceIdExpression: 'TraceId',
|
|
69
|
+
spanIdExpression: 'SpanId',
|
|
70
|
+
connection: CLICKSTACK_CONNECTION_NAME,
|
|
71
|
+
traceSourceId: 'Traces',
|
|
72
|
+
sessionSourceId: 'Sessions',
|
|
73
|
+
metricSourceId: 'Metrics',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
from: { databaseName: '%s', tableName: 'otel_traces' },
|
|
77
|
+
kind: 'trace',
|
|
78
|
+
timestampValueExpression: 'Timestamp',
|
|
79
|
+
name: 'Traces',
|
|
80
|
+
displayedTimestampValueExpression: 'Timestamp',
|
|
81
|
+
implicitColumnExpression: 'SpanName',
|
|
82
|
+
serviceNameExpression: 'ServiceName',
|
|
83
|
+
bodyExpression: 'SpanName',
|
|
84
|
+
eventAttributesExpression: 'SpanAttributes',
|
|
85
|
+
resourceAttributesExpression: 'ResourceAttributes',
|
|
86
|
+
defaultTableSelectExpression: 'Timestamp,ServiceName,StatusCode,round(Duration/1e6),SpanName',
|
|
87
|
+
traceIdExpression: 'TraceId',
|
|
88
|
+
spanIdExpression: 'SpanId',
|
|
89
|
+
durationExpression: 'Duration',
|
|
90
|
+
durationPrecision: 9,
|
|
91
|
+
parentSpanIdExpression: 'ParentSpanId',
|
|
92
|
+
spanNameExpression: 'SpanName',
|
|
93
|
+
spanKindExpression: 'SpanKind',
|
|
94
|
+
statusCodeExpression: 'StatusCode',
|
|
95
|
+
statusMessageExpression: 'StatusMessage',
|
|
96
|
+
connection: CLICKSTACK_CONNECTION_NAME,
|
|
97
|
+
logSourceId: 'Logs',
|
|
98
|
+
sessionSourceId: 'Sessions',
|
|
99
|
+
metricSourceId: 'Metrics',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
from: { databaseName: '%s', tableName: '' },
|
|
103
|
+
kind: 'metric',
|
|
104
|
+
timestampValueExpression: 'TimeUnix',
|
|
105
|
+
name: 'Metrics',
|
|
106
|
+
resourceAttributesExpression: 'ResourceAttributes',
|
|
107
|
+
metricTables: {
|
|
108
|
+
gauge: 'otel_metrics_gauge',
|
|
109
|
+
histogram: 'otel_metrics_histogram',
|
|
110
|
+
sum: 'otel_metrics_sum',
|
|
111
|
+
_id: '682586a8b1f81924e628e808',
|
|
112
|
+
id: '682586a8b1f81924e628e808',
|
|
113
|
+
},
|
|
114
|
+
connection: CLICKSTACK_CONNECTION_NAME,
|
|
115
|
+
logSourceId: 'Logs',
|
|
116
|
+
traceSourceId: 'Traces',
|
|
117
|
+
sessionSourceId: 'Sessions',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
from: { databaseName: '%s', tableName: 'hyperdx_sessions' },
|
|
121
|
+
kind: 'session',
|
|
122
|
+
timestampValueExpression: 'TimestampTime',
|
|
123
|
+
name: 'Sessions',
|
|
124
|
+
displayedTimestampValueExpression: 'Timestamp',
|
|
125
|
+
implicitColumnExpression: 'Body',
|
|
126
|
+
serviceNameExpression: 'ServiceName',
|
|
127
|
+
bodyExpression: 'Body',
|
|
128
|
+
eventAttributesExpression: 'LogAttributes',
|
|
129
|
+
resourceAttributesExpression: 'ResourceAttributes',
|
|
130
|
+
defaultTableSelectExpression: 'Timestamp,ServiceName,SeverityText,Body',
|
|
131
|
+
severityTextExpression: 'SeverityText',
|
|
132
|
+
traceIdExpression: 'TraceId',
|
|
133
|
+
spanIdExpression: 'SpanId',
|
|
134
|
+
connection: CLICKSTACK_CONNECTION_NAME,
|
|
135
|
+
logSourceId: 'Logs',
|
|
136
|
+
traceSourceId: 'Traces',
|
|
137
|
+
metricSourceId: 'Metrics',
|
|
138
|
+
},
|
|
139
|
+
];
|
|
140
|
+
// Environment the Team-bootstrap CronJob carries the seed connection in. The
|
|
141
|
+
// password is a `secretKeyRef` to the chart-owned Secret, never a value.
|
|
142
|
+
export const HYPERDX_DEFAULT_CONNECTION_HOST_ENV = 'HYPERDX_DEFAULT_CONNECTION_HOST';
|
|
143
|
+
export const HYPERDX_DEFAULT_CONNECTION_USERNAME_ENV = 'HYPERDX_DEFAULT_CONNECTION_USERNAME';
|
|
144
|
+
export const HYPERDX_DEFAULT_CONNECTION_PASSWORD_ENV = 'HYPERDX_DEFAULT_CONNECTION_PASSWORD';
|
|
145
|
+
export const HYPERDX_DEFAULT_SOURCES_DATABASE_ENV = 'HYPERDX_DEFAULT_SOURCES_DATABASE';
|
|
146
|
+
/** The chart version the release runs, for the seed's runtime version check. */
|
|
147
|
+
export const CLICKSTACK_CHART_VERSION_ENV = 'CLICKSTACK_CHART_VERSION';
|
|
148
|
+
/** Key of the chart-owned `clickstack-secret` holding the HyperDX UI user's ClickHouse password. */
|
|
149
|
+
export const CLICKSTACK_APP_PASSWORD_SECRET_KEY = 'CLICKHOUSE_APP_PASSWORD';
|
|
150
|
+
// The Mongoose schema of HyperDX 2.35.0's sources (models/source.js), per kind:
|
|
151
|
+
// the fields strict mode keeps. Anything else in a source definition is dropped
|
|
152
|
+
// on write by HyperDX, so the seed drops it too.
|
|
153
|
+
const SOURCE_BASE_FIELDS = [
|
|
154
|
+
'name',
|
|
155
|
+
'kind',
|
|
156
|
+
'section',
|
|
157
|
+
'disabled',
|
|
158
|
+
'from',
|
|
159
|
+
'timestampValueExpression',
|
|
160
|
+
'querySettings',
|
|
161
|
+
];
|
|
162
|
+
const SEARCHABLE_SOURCE_FIELDS = [
|
|
163
|
+
'defaultTableSelectExpression',
|
|
164
|
+
'serviceNameExpression',
|
|
165
|
+
'serviceVersionExpression',
|
|
166
|
+
'resourceAttributesExpression',
|
|
167
|
+
'eventAttributesExpression',
|
|
168
|
+
'displayedTimestampValueExpression',
|
|
169
|
+
'traceIdExpression',
|
|
170
|
+
'spanIdExpression',
|
|
171
|
+
'implicitColumnExpression',
|
|
172
|
+
'knownColumnsListExpression',
|
|
173
|
+
'useTextIndexForImplicitColumn',
|
|
174
|
+
'highlightedTraceAttributeExpressions',
|
|
175
|
+
'highlightedRowAttributeExpressions',
|
|
176
|
+
'materializedViews',
|
|
177
|
+
'metadataMaterializedViews',
|
|
178
|
+
'orderByExpression',
|
|
179
|
+
'metricSourceId',
|
|
180
|
+
];
|
|
181
|
+
const HYPERDX_SOURCE_FIELDS = {
|
|
182
|
+
log: [
|
|
183
|
+
...SEARCHABLE_SOURCE_FIELDS,
|
|
184
|
+
'severityTextExpression',
|
|
185
|
+
'bodyExpression',
|
|
186
|
+
'traceSourceId',
|
|
187
|
+
'tableFilterExpression',
|
|
188
|
+
],
|
|
189
|
+
trace: [
|
|
190
|
+
...SEARCHABLE_SOURCE_FIELDS,
|
|
191
|
+
'durationExpression',
|
|
192
|
+
'durationPrecision',
|
|
193
|
+
'parentSpanIdExpression',
|
|
194
|
+
'spanNameExpression',
|
|
195
|
+
'spanKindExpression',
|
|
196
|
+
'sampleRateExpression',
|
|
197
|
+
'logSourceId',
|
|
198
|
+
'sessionSourceId',
|
|
199
|
+
'statusCodeExpression',
|
|
200
|
+
'statusMessageExpression',
|
|
201
|
+
'spanEventsValueExpression',
|
|
202
|
+
'spanLinksValueExpression',
|
|
203
|
+
],
|
|
204
|
+
session: ['traceSourceId', 'resourceAttributesExpression'],
|
|
205
|
+
metric: [
|
|
206
|
+
'metricTables',
|
|
207
|
+
'resourceAttributesExpression',
|
|
208
|
+
'serviceNameExpression',
|
|
209
|
+
'logSourceId',
|
|
210
|
+
'seriesTable',
|
|
211
|
+
],
|
|
212
|
+
};
|
|
213
|
+
// Untyped `Schema.Types.Array` paths: Mongoose defaults them to [] on create.
|
|
214
|
+
const ARRAY_DEFAULT_FIELDS = {
|
|
215
|
+
log: [
|
|
216
|
+
'highlightedTraceAttributeExpressions',
|
|
217
|
+
'highlightedRowAttributeExpressions',
|
|
218
|
+
'materializedViews',
|
|
219
|
+
],
|
|
220
|
+
trace: [
|
|
221
|
+
'highlightedTraceAttributeExpressions',
|
|
222
|
+
'highlightedRowAttributeExpressions',
|
|
223
|
+
'materializedViews',
|
|
224
|
+
],
|
|
225
|
+
};
|
|
226
|
+
// `MetricTablesSchema` (`_id: false`): the `MetricsDataType` keys only.
|
|
227
|
+
const METRIC_TABLE_KEYS = [
|
|
228
|
+
'gauge',
|
|
229
|
+
'histogram',
|
|
230
|
+
'sum',
|
|
231
|
+
'summary',
|
|
232
|
+
'exponential histogram',
|
|
233
|
+
];
|
|
234
|
+
const SOURCE_REFERENCE_FIELDS = [
|
|
235
|
+
'logSourceId',
|
|
236
|
+
'traceSourceId',
|
|
237
|
+
'sessionSourceId',
|
|
238
|
+
'metricSourceId',
|
|
239
|
+
];
|
|
240
|
+
/**
|
|
241
|
+
* Turn source definitions (the `DEFAULT_SOURCES` shape) into the documents
|
|
242
|
+
* HyperDX 2.35.0's `setupTeamDefaults` would store for them.
|
|
243
|
+
*
|
|
244
|
+
* @throws Error for a source kind this schema mirror does not know
|
|
245
|
+
*/
|
|
246
|
+
export function renderHyperdxSeedSources(sources = CLICKSTACK_DEFAULT_SOURCES) {
|
|
247
|
+
const names = new Set(sources.map((source) => String(source.name)));
|
|
248
|
+
return sources.map((source) => {
|
|
249
|
+
const kind = String(source.kind);
|
|
250
|
+
const kindFields = HYPERDX_SOURCE_FIELDS[kind];
|
|
251
|
+
if (kindFields === undefined) {
|
|
252
|
+
throw new Error(`HyperDX source kind ${JSON.stringify(kind)} is not one TypeKro can seed`);
|
|
253
|
+
}
|
|
254
|
+
const document = { disabled: false, querySettings: [] };
|
|
255
|
+
for (const field of ARRAY_DEFAULT_FIELDS[kind] ?? [])
|
|
256
|
+
document[field] = [];
|
|
257
|
+
const references = {};
|
|
258
|
+
for (const [field, value] of Object.entries(source)) {
|
|
259
|
+
if (SOURCE_REFERENCE_FIELDS.includes(field)) {
|
|
260
|
+
// setupTeamDefaults' second pass: only a field the kind declares, and
|
|
261
|
+
// only to a source created in the same run.
|
|
262
|
+
if (kindFields.includes(field) && names.has(String(value)))
|
|
263
|
+
references[field] = String(value);
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
if (field === 'from') {
|
|
267
|
+
const from = value;
|
|
268
|
+
document.from = { databaseName: from.databaseName, tableName: from.tableName };
|
|
269
|
+
}
|
|
270
|
+
else if (field === 'metricTables') {
|
|
271
|
+
const tables = value;
|
|
272
|
+
document.metricTables = Object.fromEntries(METRIC_TABLE_KEYS.filter((key) => tables[key] !== undefined).map((key) => [
|
|
273
|
+
key,
|
|
274
|
+
tables[key],
|
|
275
|
+
]));
|
|
276
|
+
}
|
|
277
|
+
else if (SOURCE_BASE_FIELDS.includes(field) ||
|
|
278
|
+
kindFields.includes(field)) {
|
|
279
|
+
document[field] = value;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return { name: String(source.name), document, references };
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
/** Marker `_id` prefixes in the TypeKro-owned bootstrap collection. */
|
|
286
|
+
const TEAM_DEFAULTS_MARKER_PREFIX = 'team-defaults:';
|
|
287
|
+
const TEAM_NAME_MARKER_PREFIX = 'team-name:';
|
|
288
|
+
/**
|
|
289
|
+
* HyperDX seeds a Team it creates within the request that creates it. A Team
|
|
290
|
+
* TypeKro did not create is left alone for this long before TypeKro concludes
|
|
291
|
+
* HyperDX did not seed it, so the two never write at the same time.
|
|
292
|
+
*/
|
|
293
|
+
export const CLICKSTACK_TEAM_DEFAULTS_GRACE_SECONDS = 60;
|
|
294
|
+
/**
|
|
295
|
+
* SHA-256 of the one Team name earlier releases hard-coded into the degraded
|
|
296
|
+
* script, which never renamed a Team afterwards. A Team TypeKro has no name
|
|
297
|
+
* record for is therefore renamed only when it still carries THAT name: any
|
|
298
|
+
* other name was set by a human. Kept as a hash so the old name itself does not
|
|
299
|
+
* reappear in the source.
|
|
300
|
+
*/
|
|
301
|
+
export const CLICKSTACK_LEGACY_TEAM_NAME_SHA256 = 'ab4a37c600c179cb4094b35819aa5cd4eedb50ee36ff0ddbbf2bccb3061a767d';
|
|
302
|
+
/**
|
|
303
|
+
* The mongosh helpers both Team-bootstrap scripts share: `reconcileTeamName`
|
|
304
|
+
* and `seedTeamDefaults`. Expects `database` (the HyperDX db) and
|
|
305
|
+
* `bootstrapMarkers` (the TypeKro-owned collection) in scope.
|
|
306
|
+
*
|
|
307
|
+
* - `recordTeamName(teamId, name)` records that TypeKro set (and owns) the
|
|
308
|
+
* name; the degraded path calls it BEFORE inserting a Team it creates.
|
|
309
|
+
* - `reconcileTeamName(team, name)` renames the Team only while TypeKro owns
|
|
310
|
+
* its name: the recorded name, or, with no record, the untouched default.
|
|
311
|
+
* Anything else is recorded as a person's name (`null`), and stays theirs.
|
|
312
|
+
* The update is conditional on the name it read, so a concurrent rename in
|
|
313
|
+
* the UI wins.
|
|
314
|
+
* - `seedTeamDefaults(team, createdByTypekro)` seeds the connection and the
|
|
315
|
+
* sources ONCE per Team, and only into a Team that has neither.
|
|
316
|
+
*/
|
|
317
|
+
export function renderTeamBootstrapHelpers(options) {
|
|
318
|
+
const { exact, sha256 } = options.untouchedName;
|
|
319
|
+
const untouched = `const isUntouchedTeamName = (name) => typeof name === 'string' && (${exact === undefined ? '' : `name === ${JSON.stringify(exact)} || `}${JSON.stringify(sha256)}.indexOf(require('crypto').createHash('sha256').update(name).digest('hex')) !== -1);`;
|
|
320
|
+
const nameHelper = [
|
|
321
|
+
untouched,
|
|
322
|
+
`const teamNameMarkerId = (teamId) => ${JSON.stringify(TEAM_NAME_MARKER_PREFIX)} + String(teamId);`,
|
|
323
|
+
// `appliedName` is the name TypeKro set and still owns; `null` means a
|
|
324
|
+
// person owns the name, for good.
|
|
325
|
+
'const recordTeamName = (teamId, appliedName) => bootstrapMarkers.updateOne({ _id: teamNameMarkerId(teamId) }, { $set: { appliedName, appliedAt: new Date() } }, { upsert: true });',
|
|
326
|
+
'const reconcileTeamName = (team, desiredName) => {',
|
|
327
|
+
' const marker = bootstrapMarkers.findOne({ _id: teamNameMarkerId(team._id) });',
|
|
328
|
+
' if (marker !== null && marker.appliedName === null) return;',
|
|
329
|
+
' if (marker === null) {',
|
|
330
|
+
// No record: TypeKro owns the name only if it is still the default the
|
|
331
|
+
// Team was created with. Anything else, even today's `teamName`, is a
|
|
332
|
+
// person's choice.
|
|
333
|
+
' if (!isUntouchedTeamName(team.name)) {',
|
|
334
|
+
' recordTeamName(team._id, null);',
|
|
335
|
+
" print('ClickStack team name: the Team is named ' + JSON.stringify(team.name) + ' by someone else, so TypeKro leaves it.');",
|
|
336
|
+
' return;',
|
|
337
|
+
' }',
|
|
338
|
+
' } else if (marker.appliedName !== team.name) {',
|
|
339
|
+
' recordTeamName(team._id, null);',
|
|
340
|
+
" print('ClickStack team name: the Team was renamed to ' + JSON.stringify(team.name) + ' in HyperDX, so TypeKro leaves it from now on.');",
|
|
341
|
+
' return;',
|
|
342
|
+
' }',
|
|
343
|
+
' if (team.name === desiredName) {',
|
|
344
|
+
' if (marker === null) recordTeamName(team._id, desiredName);',
|
|
345
|
+
' return;',
|
|
346
|
+
' }',
|
|
347
|
+
// Only the name changes: `_id`, the apiKey and the users' `team` refs stay.
|
|
348
|
+
// Filtered on the name read above: a rename in the UI since then wins, and
|
|
349
|
+
// the next run records it as a person's.
|
|
350
|
+
' const result = database.teams.updateOne({ _id: team._id, name: team.name }, { $set: { name: desiredName, updatedAt: new Date() } });',
|
|
351
|
+
' if (result.matchedCount !== 1) {',
|
|
352
|
+
" print('ClickStack team name: the Team was renamed while TypeKro was renaming it, so TypeKro leaves it.');",
|
|
353
|
+
' return;',
|
|
354
|
+
' }',
|
|
355
|
+
' recordTeamName(team._id, desiredName);',
|
|
356
|
+
" print('ClickStack team name: renamed the Team from ' + JSON.stringify(team.name) + ' to ' + JSON.stringify(desiredName) + '.');",
|
|
357
|
+
'};',
|
|
358
|
+
];
|
|
359
|
+
if (!options.seed)
|
|
360
|
+
return [...nameHelper, 'const seedTeamDefaults = () => {};'];
|
|
361
|
+
const seedSources = renderHyperdxSeedSources();
|
|
362
|
+
return [
|
|
363
|
+
...nameHelper,
|
|
364
|
+
`const seedConnectionName = ${JSON.stringify(CLICKSTACK_CONNECTION_NAME)};`,
|
|
365
|
+
`const seedSources = ${JSON.stringify(seedSources)};`,
|
|
366
|
+
`const clickhouseHostProblem = ${CLICKSTACK_CLICKHOUSE_HOST_URL_CHECK_SOURCE};`,
|
|
367
|
+
// Insert by a RESERVED `_id`: a retried run fills in what an interrupted
|
|
368
|
+
// one did not, and never writes a document twice or over an existing one.
|
|
369
|
+
'const insertIfAbsent = (collection, document, what) => {',
|
|
370
|
+
' try {',
|
|
371
|
+
' collection.insertOne(document);',
|
|
372
|
+
' } catch (error) {',
|
|
373
|
+
// Re-thrown WITHOUT the error's own text: it could echo the document, and
|
|
374
|
+
// the connection document carries the password.
|
|
375
|
+
" if (error.code !== 11000) throw new Error('ClickStack team defaults: inserting the ' + what + ' failed (' + (error.codeName || error.code || error.name) + ').');",
|
|
376
|
+
' }',
|
|
377
|
+
'};',
|
|
378
|
+
'const seedTeamDefaults = (team, createdByTypekro) => {',
|
|
379
|
+
` const markerId = ${JSON.stringify(TEAM_DEFAULTS_MARKER_PREFIX)} + String(team._id);`,
|
|
380
|
+
' let marker = bootstrapMarkers.findOne({ _id: markerId });',
|
|
381
|
+
" if (marker !== null && marker.state === 'complete') return;",
|
|
382
|
+
...(options.validatedChartVersions === undefined
|
|
383
|
+
? []
|
|
384
|
+
: [
|
|
385
|
+
` const chartVersion = process.env.${CLICKSTACK_CHART_VERSION_ENV};`,
|
|
386
|
+
` if (${JSON.stringify(options.validatedChartVersions)}.indexOf(chartVersion) === -1) {`,
|
|
387
|
+
` print('ClickStack team defaults: chart version ' + JSON.stringify(chartVersion) + ' is not one TypeKro has audited HyperDX\\'s connections/sources schema on (${options.validatedChartVersions.join(', ')}), so TypeKro seeds nothing. Set teamDefaults: { allowUnvalidatedChartVersion: true } once you have checked it.');`,
|
|
388
|
+
' return;',
|
|
389
|
+
' }',
|
|
390
|
+
]),
|
|
391
|
+
` const host = process.env.${HYPERDX_DEFAULT_CONNECTION_HOST_ENV};`,
|
|
392
|
+
` const username = process.env.${HYPERDX_DEFAULT_CONNECTION_USERNAME_ENV};`,
|
|
393
|
+
` const sourceDatabase = process.env.${HYPERDX_DEFAULT_SOURCES_DATABASE_ENV};`,
|
|
394
|
+
` const password = process.env.${HYPERDX_DEFAULT_CONNECTION_PASSWORD_ENV};`,
|
|
395
|
+
` if (typeof host !== 'string' || host.length === 0 || typeof username !== 'string' || typeof sourceDatabase !== 'string') throw new Error('${HYPERDX_DEFAULT_CONNECTION_HOST_ENV}, ${HYPERDX_DEFAULT_CONNECTION_USERNAME_ENV} and ${HYPERDX_DEFAULT_SOURCES_DATABASE_ENV} are required to seed the HyperDX Team defaults.');`,
|
|
396
|
+
// The Secret key is referenced `optional: true`, so a MISSING key arrives
|
|
397
|
+
// as an unset variable: seed nothing and say why, with no marker, so the
|
|
398
|
+
// seed happens once the key exists. A key that exists but is EMPTY is a
|
|
399
|
+
// passwordless ClickHouse user and is seeded as '', as HyperDX does.
|
|
400
|
+
" if (typeof password !== 'string') {",
|
|
401
|
+
` print('ClickStack team defaults: the ClickHouse password Secret key is missing, so TypeKro seeds nothing until it exists (${HYPERDX_DEFAULT_CONNECTION_PASSWORD_ENV} is unset).');`,
|
|
402
|
+
' return;',
|
|
403
|
+
' }',
|
|
404
|
+
// The host the CRD rule would have refused, on a KRO CRD that predates
|
|
405
|
+
// the rule: seed nothing, no marker. Prints the host, never the password.
|
|
406
|
+
' const hostProblem = clickhouseHostProblem(host);',
|
|
407
|
+
' if (hostProblem !== null) {',
|
|
408
|
+
" print('ClickStack team defaults: the ClickHouse connection ' + JSON.stringify(host) + ' ' + hostProblem + ', so TypeKro seeds nothing. Fix spec.clickhouse.host; the seed runs once it is valid.');",
|
|
409
|
+
' return;',
|
|
410
|
+
' }',
|
|
411
|
+
' if (marker === null) {',
|
|
412
|
+
` if (!createdByTypekro && team.createdAt instanceof Date && Date.now() - team.createdAt.getTime() < ${CLICKSTACK_TEAM_DEFAULTS_GRACE_SECONDS * 1000}) {`,
|
|
413
|
+
" print('ClickStack team defaults: the Team is new and HyperDX may still be setting it up; checking again next run.');",
|
|
414
|
+
' return;',
|
|
415
|
+
' }',
|
|
416
|
+
// Anything already there is someone else's configuration: never touch it.
|
|
417
|
+
' if (database.connections.countDocuments({ team: team._id }, { limit: 1 }) > 0 || database.sources.countDocuments({ team: team._id }, { limit: 1 }) > 0) {',
|
|
418
|
+
" bootstrapMarkers.updateOne({ _id: markerId }, { $setOnInsert: { state: 'complete', seeded: false, completedAt: new Date() } }, { upsert: true });",
|
|
419
|
+
" print('ClickStack team defaults: the Team already has a connection or a source, so TypeKro seeds nothing.');",
|
|
420
|
+
' return;',
|
|
421
|
+
' }',
|
|
422
|
+
' const sourceIds = {};',
|
|
423
|
+
' for (const source of seedSources) sourceIds[source.name] = new ObjectId();',
|
|
424
|
+
" insertIfAbsent(bootstrapMarkers, { _id: markerId, state: 'seeding', connectionId: new ObjectId(), sourceIds, inserted: {}, startedAt: new Date() }, 'seed plan');",
|
|
425
|
+
' marker = bootstrapMarkers.findOne({ _id: markerId });',
|
|
426
|
+
" if (marker.state === 'complete') return;",
|
|
427
|
+
' }',
|
|
428
|
+
// Once per run, just before this run's writes (so also when a run resumes
|
|
429
|
+
// an interrupted seed): a connection or source that is not one of ours
|
|
430
|
+
// means someone else is configuring the Team, so stop and keep what exists.
|
|
431
|
+
// One added during this run's own writes is caught by the next run only
|
|
432
|
+
// if the seed is still incomplete; a completed seed leaves it untouched.
|
|
433
|
+
' const planned = [String(marker.connectionId)].concat(Object.keys(marker.sourceIds).map((name) => String(marker.sourceIds[name])));',
|
|
434
|
+
' const foreign = database.connections.find({ team: team._id }).toArray().concat(database.sources.find({ team: team._id }).toArray()).filter((document) => planned.indexOf(String(document._id)) === -1);',
|
|
435
|
+
' if (foreign.length > 0) {',
|
|
436
|
+
" bootstrapMarkers.updateOne({ _id: markerId }, { $set: { state: 'complete', seeded: false, stoppedBecause: 'foreign-configuration', completedAt: new Date() } });",
|
|
437
|
+
" print('ClickStack team defaults: someone else added a connection or a source while TypeKro was seeding, so TypeKro stops and keeps what exists.');",
|
|
438
|
+
' return;',
|
|
439
|
+
' }',
|
|
440
|
+
// Each document is recorded once inserted, so a resume never re-creates a
|
|
441
|
+
// planned document that a user deleted after it was written.
|
|
442
|
+
' const inserted = marker.inserted || {};',
|
|
443
|
+
' const insertPlanned = (key, collection, document, what) => {',
|
|
444
|
+
' if (inserted[key] === true) return;',
|
|
445
|
+
' insertIfAbsent(collection, document, what);',
|
|
446
|
+
" bootstrapMarkers.updateOne({ _id: markerId }, { $set: { ['inserted.' + key]: true } });",
|
|
447
|
+
' };',
|
|
448
|
+
' const now = new Date();',
|
|
449
|
+
// Exactly what `createConnection` stores for a DEFAULT_CONNECTIONS entry:
|
|
450
|
+
// no `port` (not in the schema), the password as given.
|
|
451
|
+
" insertPlanned('connection', database.connections, { _id: marker.connectionId, team: team._id, name: seedConnectionName, host, username, password, createdAt: now, updatedAt: now, __v: 0 }, 'connection');",
|
|
452
|
+
' for (const source of seedSources) {',
|
|
453
|
+
' const document = Object.assign({}, source.document, { _id: marker.sourceIds[source.name], team: team._id, connection: marker.connectionId, from: { databaseName: sourceDatabase, tableName: source.document.from.tableName }, createdAt: now, updatedAt: now, __v: 0 });',
|
|
454
|
+
' for (const field of Object.keys(source.references)) document[field] = String(marker.sourceIds[source.references[field]]);',
|
|
455
|
+
" insertPlanned('source:' + source.name, database.sources, document, 'source ' + JSON.stringify(source.name));",
|
|
456
|
+
' }',
|
|
457
|
+
" bootstrapMarkers.updateOne({ _id: markerId }, { $set: { state: 'complete', seeded: true, completedAt: new Date() } });",
|
|
458
|
+
" print('ClickStack team defaults: seeded the ' + JSON.stringify(seedConnectionName) + ' connection and ' + seedSources.length + ' sources.');",
|
|
459
|
+
'};',
|
|
460
|
+
];
|
|
461
|
+
}
|
|
462
|
+
//# sourceMappingURL=team-defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"team-defaults.js","sourceRoot":"","sources":["../../../../src/factories/clickstack/utils/team-defaults.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,8EAA8E;AAC9E,2DAA2D;AAC3D,EAAE;AACF,qEAAqE;AACrE,4BAA4B;AAC5B,EAAE;AACF,gEAAgE;AAChE,gFAAgF;AAChF,2EAA2E;AAC3E,gFAAgF;AAChF,+EAA+E;AAC/E,+EAA+E;AAC/E,gBAAgB;AAChB,gEAAgE;AAChE,iFAAiF;AACjF,wEAAwE;AACxE,yEAAyE;AACzE,4EAA4E;AAC5E,WAAW;AACX,oEAAoE;AACpE,+EAA+E;AAC/E,+EAA+E;AAC/E,+EAA+E;AAC/E,+BAA+B;AAC/B,4EAA4E;AAC5E,0EAA0E;AAC1E,uDAAuD;AACvD,6EAA6E;AAC7E,gFAAgF;AAChF,0EAA0E;AAC1E,+DAA+D;AAC/D,yBAAyB;AACzB,s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E,qEAAqE;QACrE,uCAAuC;QACvC,iIAAiI,uCAAuC,gBAAgB;QACxL,aAAa;QACb,KAAK;QACL,uEAAuE;QACvE,0EAA0E;QAC1E,oDAAoD;QACpD,+BAA+B;QAC/B,yMAAyM;QACzM,aAAa;QACb,KAAK;QACL,0BAA0B;QAC1B,0GAA0G,sCAAsC,GAAG,IAAI,KAAK;QAC5J,4HAA4H;QAC5H,eAAe;QACf,OAAO;QACP,0EAA0E;QAC1E,+JAA+J;QAC/J,yJAAyJ;QACzJ,oHAAoH;QACpH,eAAe;QACf,OAAO;QACP,2BAA2B;QAC3B,gFAAgF;QAChF,uKAAuK;QACvK,2DAA2D;QAC3D,8CAA8C;QAC9C,KAAK;QACL,0EAA0E;QAC1E,uEAAuE;QACvE,4EAA4E;QAC5E,wEAAwE;QACxE,yEAAyE;QACzE,sIAAsI;QACtI,2MAA2M;QAC3M,6BAA6B;QAC7B,sKAAsK;QACtK,wJAAwJ;QACxJ,aAAa;QACb,KAAK;QACL,0EAA0E;QAC1E,6DAA6D;QAC7D,2CAA2C;QAC3C,gEAAgE;QAChE,yCAAyC;QACzC,iDAAiD;QACjD,6FAA6F;QAC7F,MAAM;QACN,2BAA2B;QAC3B,0EAA0E;QAC1E,wDAAwD;QACxD,8MAA8M;QAC9M,uCAAuC;QACvC,8QAA8Q;QAC9Q,+HAA+H;QAC/H,kHAAkH;QAClH,KAAK;QACL,0HAA0H;QAC1H,gJAAgJ;QAChJ,IAAI;KACL,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helm-values-mapper.d.ts","sourceRoot":"","sources":["../../../../src/factories/inngest/utils/helm-values-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"helm-values-mapper.d.ts","sourceRoot":"","sources":["../../../../src/factories/inngest/utils/helm-values-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,sBAA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G,CAAC,EAAE,KAAK,CAAC;YAAE,UAAU,CAAC,EAAE,MAAM,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE,CAAC,CAAC;KACxD,CAAC;IACF,IAAI,CAAC,EAAE;QACL,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;IACF,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,WAAW,CAAC,EAAE,KAAK,CAAC;QAClB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B,CAAC,CAAC;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,sBAAsB,GAC7B,iBAAiB,CA6CnB"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @see https://github.com/inngest/inngest-helm
|
|
7
7
|
*/
|
|
8
|
+
import { isMergeableValuesObject } from '../../../core/aspects/values-merge.js';
|
|
8
9
|
/**
|
|
9
10
|
* Map InngestBootstrapConfig to Helm chart values.
|
|
10
11
|
*
|
|
@@ -77,7 +78,9 @@ function removeUndefinedValues(obj) {
|
|
|
77
78
|
for (const [key, value] of Object.entries(obj)) {
|
|
78
79
|
if (value === undefined)
|
|
79
80
|
continue;
|
|
80
|
-
if (
|
|
81
|
+
if (isMergeableValuesObject(value)) {
|
|
82
|
+
// Opaque leaves (references, CEL expressions, symbol-branded markers)
|
|
83
|
+
// are kept whole: rebuilding one from its string keys drops its brand.
|
|
81
84
|
const cleaned = removeUndefinedValues(value);
|
|
82
85
|
if (Object.keys(cleaned).length > 0) {
|
|
83
86
|
result[key] = cleaned;
|
|
@@ -90,9 +93,11 @@ function removeUndefinedValues(obj) {
|
|
|
90
93
|
return result;
|
|
91
94
|
}
|
|
92
95
|
/**
|
|
93
|
-
* Recursively deep merge `source` into `target`
|
|
96
|
+
* Recursively deep merge `source` into `target`. Only `target` itself is
|
|
97
|
+
* written: nested objects are copied before they are merged into.
|
|
94
98
|
* - Plain objects are merged key-by-key at arbitrary depth.
|
|
95
|
-
* - Arrays
|
|
99
|
+
* - Arrays, primitives and opaque leaves (references, CEL expressions,
|
|
100
|
+
* symbol-branded markers) in source replace the target value.
|
|
96
101
|
* - null and undefined in source replace the target value.
|
|
97
102
|
*/
|
|
98
103
|
function deepMerge(target, source) {
|
|
@@ -100,13 +105,14 @@ function deepMerge(target, source) {
|
|
|
100
105
|
if (key === '__proto__' || key === 'constructor' || key === 'prototype')
|
|
101
106
|
continue;
|
|
102
107
|
const targetValue = target[key];
|
|
103
|
-
if (sourceValue
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
deepMerge(
|
|
108
|
+
if (isMergeableValuesObject(sourceValue) && isMergeableValuesObject(targetValue)) {
|
|
109
|
+
// Copy before merging: the nested object can be the caller's own (a typed
|
|
110
|
+
// field such as `nodeSelector` is mapped by reference), and merging into
|
|
111
|
+
// it in place mutated it. References, CEL expressions and other branded
|
|
112
|
+
// leaves are never merged into, so the spread never flattens one.
|
|
113
|
+
const next = { ...targetValue };
|
|
114
|
+
deepMerge(next, sourceValue);
|
|
115
|
+
target[key] = next;
|
|
110
116
|
}
|
|
111
117
|
else {
|
|
112
118
|
target[key] = sourceValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helm-values-mapper.js","sourceRoot":"","sources":["../../../../src/factories/inngest/utils/helm-values-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"helm-values-mapper.js","sourceRoot":"","sources":["../../../../src/factories/inngest/utils/helm-values-mapper.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAqEhF;;;;;;;;GAQG;AACH,MAAM,UAAU,4BAA4B,CAC1C,MAA8B;IAE9B,MAAM,MAAM,GAAsB,EAAE,CAAC;IAErC,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACtC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;IAC5C,CAAC;IAED,kCAAkC;IAClC,MAAM,CAAC,OAAO,GAAG;QACf,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ;QACjC,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU;KACtC,CAAC;IACF,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ;QAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/E,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK;QAAE,MAAM,CAAC,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;IACtE,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI;QAAE,MAAM,CAAC,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;IACnE,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM;QAAE,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;IACzE,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS;QAAE,MAAM,CAAC,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;IACjF,IAAI,MAA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AChC,IAAI,uBAAuB,CAAC,WAAW,CAAC,IAAI,uBAAuB,CAAC,WAAW,CAAC,EAAE,CAAC;YACjF,0EAA0E;YAC1E,yEAAyE;YACzE,wEAAwE;YACxE,kEAAkE;YAClE,MAAM,IAAI,GAAG,EAAE,GAAG,WAAW,EAAE,CAAC;YAChC,SAAS,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;YAC7B,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC;QAC5B,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helm-values-mapper.d.ts","sourceRoot":"","sources":["../../../../src/factories/rook/utils/helm-values-mapper.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,OAAO,
|
|
1
|
+
{"version":3,"file":"helm-values-mapper.d.ts","sourceRoot":"","sources":["../../../../src/factories/rook/utils/helm-values-mapper.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAE1E,OAAO,EAIL,KAAK,qBAAqB,EAC3B,MAAM,uCAAuC,CAAC;AAO/C,OAAO,KAAK,EACV,qBAAqB,EACrB,+BAA+B,EAC/B,gCAAgC,EAChC,gCAAgC,EACjC,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;IAClD,+BAA+B,CAAC,EAAE,OAAO,CAAC;IAC1C,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACxC,SAAS,CAAC,EAAE;QACV,QAAQ,CAAC,EAAE;YAAE,GAAG,CAAC,EAAE,MAAM,CAAC;YAAC,MAAM,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QAC7C,MAAM,CAAC,EAAE;YAAE,GAAG,CAAC,EAAE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O,CAAC;CACxB;AAwCD,sFAAsF;AACtF,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,gCAAgC,GACvC,qBAAqB,CAAC,MAAM,CAAC,CAc/B;AAED,qFAAqF;AACrF,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,gCAAgC,GACvC,qBAAqB,CAAC,MAAM,CAAC,CAa/B;AAkCD,mFAAmF;AACnF,wBAAgB,yCAAyC,CACvD,MAAM,EAAE,gCAAgC,EACxC,WAAW,GAAE,MAAoC,GAChD,0BAA0B,GAAG,qBAAqB,CA+DpD;AAED,2EAA2E;AAC3E,wBAAgB,yCAAyC,CACvD,MAAM,EAAE,gCAAgC,GACvC,0BAA0B,GAAG,qBAAqB,CAkEpD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Map typed bootstrap options into official `rook-ceph` chart values. */
|
|
2
|
-
import { isValuesMergeExpression, mergeValuesExpression, } from '../../../core/aspects/values-merge.js';
|
|
2
|
+
import { isMergeableValuesObject, isValuesMergeExpression, mergeValuesExpression, } from '../../../core/aspects/values-merge.js';
|
|
3
3
|
import { Cel } from '../../../core/references/cel.js';
|
|
4
4
|
import { containsKubernetesRefs, isCelExpression, isKubernetesRef, } from '../../../utils/type-guards.js';
|
|
5
5
|
/**
|
|
@@ -39,12 +39,7 @@ function mergeValuesLast(base, overrides) {
|
|
|
39
39
|
return base;
|
|
40
40
|
}
|
|
41
41
|
function isPlainObject(value) {
|
|
42
|
-
return (
|
|
43
|
-
typeof value === 'object' &&
|
|
44
|
-
!Array.isArray(value) &&
|
|
45
|
-
!isKubernetesRef(value) &&
|
|
46
|
-
!isCelExpression(value) &&
|
|
47
|
-
!isValuesMergeExpression(value));
|
|
42
|
+
return isMergeableValuesObject(value);
|
|
48
43
|
}
|
|
49
44
|
function deepMerge(target, source) {
|
|
50
45
|
for (const [key, sourceValue] of Object.entries(source)) {
|
|
@@ -52,7 +47,11 @@ function deepMerge(target, source) {
|
|
|
52
47
|
continue;
|
|
53
48
|
const targetValue = target[key];
|
|
54
49
|
if (isPlainObject(targetValue) && isPlainObject(sourceValue)) {
|
|
55
|
-
|
|
50
|
+
// Copy before merging: the nested object can be the caller's own (a typed
|
|
51
|
+
// field mapped by reference), and merging into it in place mutated it.
|
|
52
|
+
const next = { ...targetValue };
|
|
53
|
+
deepMerge(next, sourceValue);
|
|
54
|
+
target[key] = next;
|
|
56
55
|
}
|
|
57
56
|
else {
|
|
58
57
|
target[key] = sourceValue;
|