c8y-nitro 0.10.4 → 0.11.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 (41) hide show
  1. package/README.md +2 -0
  2. package/dist/{apiClient-kxv5KHYJ.mjs → apiClient-GMQqcgQe.mjs} +2 -3
  3. package/dist/{autoBootstrap-CElU3xv-.mjs → autoBootstrap-D4vEytWW.mjs} +6 -8
  4. package/dist/{bootstrap-hV_pJO5R.mjs → bootstrap-DpYAhM7C.mjs} +6 -7
  5. package/dist/cli/index.mjs +6 -7
  6. package/dist/{config-4Ju9safS.mjs → config-Dozrdw3A.mjs} +2 -3
  7. package/dist/{credentials-eKnJ7m9Y.d.mts → credentials-C_3m4LVX.d.mts} +0 -2
  8. package/dist/defaults-CrrCinRJ.mjs +20 -0
  9. package/dist/{env-CM-t7BwA.mjs → env-fUAhIWsI.mjs} +3 -5
  10. package/dist/{env-file-BrOTmVjA.mjs → env-file-DWbaFlIp.mjs} +1 -2
  11. package/dist/{index-BOaWGoaf.d.mts → index-CmIQfBpj.d.mts} +38 -22
  12. package/dist/index.d.mts +4 -6
  13. package/dist/index.mjs +16 -22
  14. package/dist/{logging-BUYT8Z2V.mjs → logging-B1PuWdiF.mjs} +1 -2
  15. package/dist/{manifest-DV3UW9Dl.mjs → manifest-BhrHDm8Y.mjs} +4 -6
  16. package/dist/{options-Bif4gAIp.mjs → options-CgTptIpI.mjs} +5 -6
  17. package/dist/{package-WtwC9ClY.mjs → package-y3p_br3i.mjs} +2 -3
  18. package/dist/{roles-D08LKKLI.mjs → roles-DEIHe2Xt.mjs} +4 -5
  19. package/dist/runtime/handlers/invalidateTenantOptions.mjs +2 -408
  20. package/dist/runtime/handlers/liveness-readiness.mjs +1 -2
  21. package/dist/runtime/handlers/openapi.mjs +4 -5
  22. package/dist/runtime/handlers/rewriteRequestUrl.mjs +3 -4
  23. package/dist/runtime/middlewares/c8y-client.mjs +3 -4
  24. package/dist/runtime/middlewares/dev-user.dev.mjs +2 -3
  25. package/dist/runtime/plugins/c8y-variables.dev.mjs +2 -3
  26. package/dist/runtime/plugins/enrich-logs.mjs +2 -3
  27. package/dist/scope-CxEPZ74p.mjs +2763 -0
  28. package/dist/{client-D8DbCxT6.mjs → tenant-0MBgBY_o.mjs} +114 -138
  29. package/dist/testing/setup.d.mts +1 -0
  30. package/dist/testing/setup.mjs +62 -0
  31. package/dist/testing/vite.d.mts +26 -0
  32. package/dist/testing/vite.mjs +58 -0
  33. package/dist/testing-D5VjeD-F.mjs +14 -0
  34. package/dist/testing.d.mts +521 -0
  35. package/dist/testing.mjs +494 -0
  36. package/dist/{typegen-BO_AkyNc.mjs → typegen-Bw4VxFmA.mjs} +4 -5
  37. package/dist/types-D663gk80.d.mts +140 -0
  38. package/dist/types.d.mts +3 -3
  39. package/dist/utils.d.mts +48 -66
  40. package/dist/utils.mjs +15 -26
  41. package/package.json +36 -19
@@ -1,412 +1,7 @@
1
- import { t as createError } from "../../logging-BUYT8Z2V.mjs";
2
- import { t as useDeployedTenantClient } from "../../client-D8DbCxT6.mjs";
3
1
  import { c8yTenantOptionKeys } from "c8y-nitro/runtime";
4
- import { defineCachedFunction } from "nitro/cache";
5
- import { useRuntimeConfig } from "nitro/runtime-config";
2
+ import { createError, useDeployedTenantClient, useTenantOption, useTenantOptions } from "c8y-nitro/utils";
6
3
  import { defineEventHandler, getQuery } from "nitro/h3";
7
- //#region src/utils/internal/tenantOptionFetchers.ts
8
- /**
9
- * Internal storage for cached option fetchers, keyed by
10
- * `${tenant}::${category}::${key}`.
11
- *
12
- * Including the tenant and category in the key keeps options from different
13
- * tenants (multi-tenancy) and settings categories from colliding on a shared
14
- * `key`.
15
- */
16
- const tenantOptionFetchers = {};
17
- /**
18
- * Builds the composite store key for a tenant/category/key triple.
19
- * @param tenant - The tenant id owning the option
20
- * @param category - The settings category
21
- * @param key - The tenant option key
22
- */
23
- function fetcherStoreKey(tenant, category, key) {
24
- return `${tenant}::${category}::${key}`;
25
- }
26
- //#endregion
27
- //#region src/utils/tenantOptions.ts
28
- /**
29
- * The microservice's own settings category, resolved once from runtime config
30
- * (`manifest.settingsCategory` → `contextPath` → `name`). This is independent of
31
- * which tenant is targeted.
32
- */
33
- function getOwnCategory() {
34
- return useRuntimeConfig().c8ySettingsCategory;
35
- }
36
- /**
37
- * Resolves the tenant id a client operates on, used for per-tenant cache keys.
38
- *
39
- * Prefers the stamped `client.core.tenant` (set by the `use*Client` helpers);
40
- * otherwise resolves it on demand via `/tenant/currentTenant` and memoizes it
41
- * back onto the client.
42
- * @param client - The Cumulocity client
43
- */
44
- async function resolveClientTenant(client) {
45
- if (client.core.tenant) return client.core.tenant;
46
- const res = await client.core.fetch("/tenant/currentTenant", {
47
- method: "GET",
48
- headers: { Accept: "application/json" }
49
- });
50
- const tenant = res.ok ? (await res.json())?.name : void 0;
51
- if (!tenant) throw createError({
52
- status: 500,
53
- message: "Could not determine the target tenant",
54
- fix: "This is unexpected. Retry the request, and contact the microservice operator if it keeps happening.",
55
- internal: {
56
- reason: res.ok ? "GET /tenant/currentTenant returned no tenant name" : "GET /tenant/currentTenant failed",
57
- upstreamStatus: res.status
58
- }
59
- });
60
- client.core.tenant = tenant;
61
- return tenant;
62
- }
63
- /**
64
- * Builds the Cumulocity Options API path for a category (and optional key).
65
- * @param category - The settings category
66
- * @param key - The tenant option key (omit for category-level operations)
67
- */
68
- function optionsPath(category, key) {
69
- const base = `/tenant/options/${encodeURIComponent(category)}`;
70
- return key === void 0 ? base : `${base}/${encodeURIComponent(key)}`;
71
- }
72
- /**
73
- * Cumulocity role required to read tenant options.
74
- */
75
- const OPTION_READ_ROLE = "ROLE_OPTION_MANAGEMENT_READ";
76
- /**
77
- * Cumulocity role required to create, update or delete tenant options.
78
- */
79
- const OPTION_ADMIN_ROLE = "ROLE_OPTION_MANAGEMENT_ADMIN";
80
- /**
81
- * Builds a structured error for a failed Options API request.
82
- *
83
- * A failed options request is a microservice/config problem (e.g. a missing
84
- * `ROLE_OPTION_MANAGEMENT_*` role), not something the frontend caller can act on
85
- * — so the response is a **generic 500** that reveals nothing about tenant
86
- * options. All the diagnostic detail (which operation, upstream status, internal
87
- * endpoint/method, and the Cumulocity role it needs) goes into `internal`, which
88
- * is logged for debugging but never serialized to the HTTP response.
89
- * @param status - The upstream HTTP status (for `internal`)
90
- * @param operation - A human-readable summary of the failed operation (for `internal`)
91
- * @param internal - Backend-only debugging context (endpoint, method, required role)
92
- */
93
- function optionRequestError(status, operation, internal) {
94
- return createError({
95
- status: 500,
96
- message: "Internal Server Error",
97
- internal: {
98
- operation,
99
- upstreamStatus: status,
100
- ...internal
101
- }
102
- });
103
- }
104
- /**
105
- * Reads a single option value directly from the Options API.
106
- * Returns `undefined` when the option is not set (404).
107
- * @param client - The Cumulocity client (determines tenant + auth)
108
- * @param category - The settings category
109
- * @param key - The tenant option key
110
- */
111
- async function fetchOptionValue(client, category, key) {
112
- const endpoint = optionsPath(category, key);
113
- const res = await client.core.fetch(endpoint, {
114
- method: "GET",
115
- headers: { Accept: "application/json" }
116
- });
117
- if (res.status === 404) return;
118
- if (!res.ok) throw optionRequestError(res.status, `Failed to read tenant option '${key}'`, {
119
- method: "GET",
120
- endpoint,
121
- requiredRole: OPTION_READ_ROLE
122
- });
123
- return (await res.json())?.value;
124
- }
125
- /**
126
- * Creates or updates a single option value (upsert) via the Options API.
127
- * @param client - The Cumulocity client (determines tenant + auth)
128
- * @param category - The settings category
129
- * @param key - The tenant option key
130
- * @param value - The value to store
131
- */
132
- async function putOptionValue(client, category, key, value) {
133
- const endpoint = optionsPath(category, key);
134
- const res = await client.core.fetch(endpoint, {
135
- method: "PUT",
136
- headers: {
137
- "Content-Type": "application/json",
138
- "Accept": "application/json"
139
- },
140
- body: JSON.stringify({ value })
141
- });
142
- if (!res.ok) throw optionRequestError(res.status, `Failed to set tenant option '${key}'`, {
143
- method: "PUT",
144
- endpoint,
145
- requiredRole: OPTION_ADMIN_ROLE
146
- });
147
- }
148
- /**
149
- * Deletes a single option via the Options API. Idempotent: a 404 resolves.
150
- * @param client - The Cumulocity client (determines tenant + auth)
151
- * @param category - The settings category
152
- * @param key - The tenant option key
153
- */
154
- async function deleteOptionValue(client, category, key) {
155
- const endpoint = optionsPath(category, key);
156
- const res = await client.core.fetch(endpoint, {
157
- method: "DELETE",
158
- headers: { Accept: "application/json" }
159
- });
160
- if (res.status === 404) return;
161
- if (!res.ok) throw optionRequestError(res.status, `Failed to delete tenant option '${key}'`, {
162
- method: "DELETE",
163
- endpoint,
164
- requiredRole: OPTION_ADMIN_ROLE
165
- });
166
- }
167
- /**
168
- * Updates the `editable` flag of a single option (management tenant only).
169
- * @param client - The Cumulocity client (must be the management tenant)
170
- * @param category - The settings category
171
- * @param key - The tenant option key
172
- * @param editable - Whether the option may be edited
173
- * @param targetTenant - The tenant whose option flag is updated
174
- */
175
- async function putOptionEditable(client, category, key, editable, targetTenant) {
176
- const endpoint = `${optionsPath(category, key)}/editable`;
177
- const res = await client.core.fetch(`${endpoint}?targetTenant=${encodeURIComponent(targetTenant)}`, {
178
- method: "PUT",
179
- headers: {
180
- "Content-Type": "application/json",
181
- "Accept": "application/json"
182
- },
183
- body: JSON.stringify({ editable })
184
- });
185
- if (!res.ok) throw optionRequestError(res.status, `Failed to update editable flag for tenant option '${key}'`, {
186
- method: "PUT",
187
- endpoint,
188
- targetTenant,
189
- requiredRole: `${OPTION_ADMIN_ROLE} (management tenant only)`
190
- });
191
- }
192
- /**
193
- * Lists all options set in a category as a key/value map.
194
- * @param client - The Cumulocity client (determines tenant + auth)
195
- * @param category - The settings category
196
- */
197
- async function listCategoryOptions(client, category) {
198
- const endpoint = optionsPath(category);
199
- const res = await client.core.fetch(endpoint, {
200
- method: "GET",
201
- headers: { Accept: "application/json" }
202
- });
203
- if (res.status === 404) return {};
204
- if (!res.ok) throw optionRequestError(res.status, `Failed to list tenant options for category '${category}'`, {
205
- method: "GET",
206
- endpoint,
207
- requiredRole: OPTION_READ_ROLE
208
- });
209
- return { ...await res.json() };
210
- }
211
- /**
212
- * Gets the cache TTL for a specific tenant option key.
213
- * Uses per-key override if defined, otherwise falls back to the default TTL.
214
- * @param key - The tenant option key
215
- */
216
- function getTenantOptionCacheTTL(key) {
217
- const config = useRuntimeConfig();
218
- return config.c8yTenantOptionsPerKeyTTL?.[key] ?? config.c8yDefaultTenantOptionsTTL ?? 600;
219
- }
220
- /**
221
- * Factory that creates a cached read fetcher for a specific tenant/category/key.
222
- * All fetchers share the same cache group so they can be invalidated together.
223
- * @param client - The Cumulocity client (determines tenant + auth)
224
- * @param tenant - The tenant id (for the cache key)
225
- * @param category - The settings category
226
- * @param key - The tenant option key
227
- */
228
- function createCachedTenantOptionFetcher(client, tenant, category, key) {
229
- const cacheName = `_c8y_nitro_tenant_option_${fetcherStoreKey(tenant, category, key).replace(/[^a-zA-Z0-9]/g, "_")}`;
230
- const cachedFetcher = defineCachedFunction(async () => fetchOptionValue(client, category, key), {
231
- maxAge: getTenantOptionCacheTTL(key),
232
- name: cacheName,
233
- group: "c8y_nitro",
234
- swr: false
235
- });
236
- return Object.assign(cachedFetcher, { refresh: async () => {
237
- await cachedFetcher.invalidate();
238
- return await cachedFetcher();
239
- } });
240
- }
241
- /**
242
- * Gets or creates the cached read fetcher for a tenant/category/key triple.
243
- * @param client - The Cumulocity client (determines tenant + auth)
244
- * @param tenant - The resolved tenant id
245
- * @param category - The settings category
246
- * @param key - The tenant option key
247
- */
248
- function getOrCreateFetcher(client, tenant, category, key) {
249
- const storeKey = fetcherStoreKey(tenant, category, key);
250
- let fetcher = tenantOptionFetchers[storeKey];
251
- if (!fetcher) {
252
- fetcher = createCachedTenantOptionFetcher(client, tenant, category, key);
253
- tenantOptionFetchers[storeKey] = fetcher;
254
- }
255
- return fetcher;
256
- }
257
- /**
258
- * Invalidates the cached read for a store key, if one has been created.
259
- * @param storeKey - The composite `${tenant}::${category}::${key}` store key
260
- */
261
- async function invalidateStoreKey(storeKey) {
262
- const fetcher = tenantOptionFetchers[storeKey];
263
- if (fetcher) await fetcher.invalidate();
264
- }
265
- /**
266
- * Invalidates every created fetcher whose store key matches the predicate.
267
- * @param predicate - Selects store keys to invalidate
268
- */
269
- async function invalidateFetchers(predicate) {
270
- await Promise.all(Object.entries(tenantOptionFetchers).filter(([storeKey]) => predicate(storeKey)).map(([, fetcher]) => fetcher.invalidate()));
271
- }
272
- /**
273
- * Refreshes every created fetcher whose store key matches the predicate.
274
- * @param predicate - Selects store keys to refresh
275
- * @returns Map of matched store keys to their refreshed values
276
- */
277
- async function refreshFetchers(predicate) {
278
- const entries = Object.entries(tenantOptionFetchers).filter(([storeKey]) => predicate(storeKey));
279
- const values = await Promise.all(entries.map(([, fetcher]) => fetcher.refresh()));
280
- return Object.fromEntries(entries.map(([storeKey], i) => [storeKey, values[i]]));
281
- }
282
- /**
283
- * Builds a single-option handle for a client/category/key.
284
- * @param client - The Cumulocity client (determines tenant + auth)
285
- * @param category - The settings category
286
- * @param key - The tenant option key
287
- */
288
- function makeTenantOption(client, category, key) {
289
- const currentStoreKey = async () => fetcherStoreKey(await resolveClientTenant(client), category, key);
290
- const readFetcher = async () => getOrCreateFetcher(client, await resolveClientTenant(client), category, key);
291
- return {
292
- read: async () => (await readFetcher())(),
293
- set: async (value) => {
294
- await putOptionValue(client, category, key, value);
295
- await invalidateStoreKey(await currentStoreKey());
296
- },
297
- getOrInsert: async (fallback) => {
298
- const current = await (await readFetcher())();
299
- if (current !== void 0) return current;
300
- await putOptionValue(client, category, key, fallback);
301
- await invalidateStoreKey(await currentStoreKey());
302
- return fallback;
303
- },
304
- delete: async () => {
305
- await deleteOptionValue(client, category, key);
306
- await invalidateStoreKey(await currentStoreKey());
307
- },
308
- setEditable: async (editable, options) => {
309
- await putOptionEditable(client, category, key, editable, options.targetTenant);
310
- await invalidateStoreKey(await currentStoreKey());
311
- },
312
- refresh: async () => (await readFetcher()).refresh(),
313
- invalidate: async () => invalidateStoreKey(await currentStoreKey())
314
- };
315
- }
316
- /**
317
- * Builds a category handle. The runtime shape is identical for the own and
318
- * foreign categories; the public overloads differ only at the type level.
319
- * @param client - The Cumulocity client (determines tenant + auth)
320
- * @param category - The settings category
321
- */
322
- function makeTenantOptionCategory(client, category) {
323
- const categoryPrefix = async () => `${await resolveClientTenant(client)}::${category}::`;
324
- return {
325
- option: (key) => makeTenantOption(client, category, key),
326
- list: () => listCategoryOptions(client, category),
327
- setAll: async (values) => {
328
- const entries = Object.entries(values);
329
- await Promise.all(entries.map(([key, value]) => putOptionValue(client, category, key, value)));
330
- const tenant = await resolveClientTenant(client);
331
- await Promise.all(entries.map(([key]) => invalidateStoreKey(fetcherStoreKey(tenant, category, key))));
332
- },
333
- invalidateAll: async () => {
334
- const prefix = await categoryPrefix();
335
- await invalidateFetchers((storeKey) => storeKey.startsWith(prefix));
336
- },
337
- refreshAll: async () => {
338
- const prefix = await categoryPrefix();
339
- const refreshed = await refreshFetchers((storeKey) => storeKey.startsWith(prefix));
340
- return Object.fromEntries(Object.entries(refreshed).map(([storeKey, value]) => [storeKey.slice(prefix.length), value]));
341
- }
342
- };
343
- }
344
- /**
345
- * Gets a handle for a single tenant option in the microservice's **own** settings
346
- * category, targeting the tenant of the given `client`.\
347
- * Reads are cached per tenant, using the client's service user credentials.
348
- *
349
- * This is a shortcut for `useTenantOptions(client).option(key)` — it only drops
350
- * the category argument. For a single option in a **foreign** category, use
351
- * `useTenantOptions(client, category).option(key)`.
352
- *
353
- * Manifest-declared keys are offered via autocomplete, but any dynamic string
354
- * is accepted too (e.g. `encrypted.password.${hash}`).
355
- *
356
- * @param client - The Cumulocity client that determines the target tenant
357
- * @param key - The tenant option key
358
- *
359
- * @config Cache TTL can be configured via:
360
- * - `c8y.cache.defaultTenantOptionsTTL` — Default TTL for all keys (in seconds)
361
- * - `c8y.cache.tenantOptions` — Per-key TTL overrides
362
- * - `NITRO_C8Y_DEFAULT_TENANT_OPTIONS_TTL` — Environment variable for default TTL
363
- *
364
- * @example
365
- * // Read the owner tenant's config:
366
- * const value = await useTenantOption(await useDeployedTenantClient(), 'featureMode').read()
367
- *
368
- * // Read the current request tenant's config (multi-tenant):
369
- * const value = await useTenantOption(await useUserTenantClient(event), 'featureMode').read()
370
- *
371
- * // Create or update, or seed a dynamic key:
372
- * await useTenantOption(client, 'featureMode').set('advanced')
373
- * const token = await useTenantOption(client, `encrypted.password.${hash}`).getOrInsert('')
374
- */
375
- function useTenantOption(client, key) {
376
- return makeTenantOption(client, getOwnCategory(), key);
377
- }
378
- const useTenantOptionsBase = ((client, category) => makeTenantOptionCategory(client, category ?? getOwnCategory()));
379
- /**
380
- * Gets a handle for a whole settings category, targeting the tenant of the given
381
- * `client`.\
382
- * Omit the category (or pass the own {@link C8YSettingsCategory}) for the
383
- * microservice's own category; pass any other category to read/write options in
384
- * a foreign category (where `credentials.*` keys are rejected).
385
- *
386
- * @param client - The Cumulocity client that determines the target tenant
387
- *
388
- * @example
389
- * const client = await useUserTenantClient(event)
390
- *
391
- * // Own category:
392
- * const values = await useTenantOptions(client).list()
393
- * await useTenantOptions(client).option('featureMode').set('advanced')
394
- *
395
- * // Foreign category:
396
- * const value = await useTenantOptions(client, 'other-service').option('someKey').read()
397
- *
398
- * // Invalidate all cached options of one tenant + category:
399
- * await useTenantOptions(client, 'other-service').invalidateAll()
400
- *
401
- * // Invalidate everything, across all tenants and categories:
402
- * await useTenantOptions.invalidateAll()
403
- */
404
- const useTenantOptions = Object.assign(useTenantOptionsBase, {
405
- invalidateAll: () => invalidateFetchers(() => true),
406
- refreshAll: () => refreshFetchers(() => true)
407
- });
408
- //#endregion
409
- //#region src/module/runtime/handlers/invalidateTenantOptions.ts
4
+ // src/module/runtime/handlers/invalidateTenantOptions.ts
410
5
  var invalidateTenantOptions_default = defineEventHandler(async (event) => {
411
6
  const query = getQuery(event);
412
7
  if ("all" in query) {
@@ -429,5 +24,4 @@ var invalidateTenantOptions_default = defineEventHandler(async (event) => {
429
24
  await useTenantOption(await useDeployedTenantClient(), key).invalidate();
430
25
  return { message: "success" };
431
26
  });
432
- //#endregion
433
27
  export { invalidateTenantOptions_default as default };
@@ -1,7 +1,6 @@
1
1
  import { defineEventHandler } from "nitro/h3";
2
- //#region src/module/runtime/handlers/liveness-readiness.ts
2
+ // src/module/runtime/handlers/liveness-readiness.ts
3
3
  var liveness_readiness_default = defineEventHandler(async () => {
4
4
  return { status: "OK" };
5
5
  });
6
- //#endregion
7
6
  export { liveness_readiness_default as default };
@@ -1,9 +1,9 @@
1
- import { r as tryGetUserTenantDomainFast } from "../../client-D8DbCxT6.mjs";
1
+ import { n as tryGetUserTenantDomainFast } from "../../tenant-0MBgBY_o.mjs";
2
+ import { defineMiddleware } from "nitro";
2
3
  import { c8yManifest } from "c8y-nitro/runtime";
3
- import { useRuntimeConfig } from "nitro/runtime-config";
4
4
  import { getRequestURL } from "nitro/h3";
5
- import { defineMiddleware } from "nitro";
6
- //#region src/module/runtime/handlers/openapi.ts
5
+ import { useRuntimeConfig } from "nitro/runtime-config";
6
+ // src/module/runtime/handlers/openapi.ts
7
7
  function isOpenAPIDocument(value) {
8
8
  return Boolean(value) && typeof value === "object" && "openapi" in value;
9
9
  }
@@ -53,5 +53,4 @@ var openapi_default = defineMiddleware(async (event, next) => {
53
53
  body.servers = [await resolveServer(event)];
54
54
  return body;
55
55
  });
56
- //#endregion
57
56
  export { openapi_default as default };
@@ -1,7 +1,7 @@
1
- import { n as buildPublicRequestUrl, r as tryGetUserTenantDomainFast } from "../../client-D8DbCxT6.mjs";
2
- import { c8yManifest } from "c8y-nitro/runtime";
1
+ import { n as tryGetUserTenantDomainFast, t as buildPublicRequestUrl } from "../../tenant-0MBgBY_o.mjs";
3
2
  import { defineMiddleware } from "nitro";
4
- //#region src/module/runtime/handlers/rewriteRequestUrl.ts
3
+ import { c8yManifest } from "c8y-nitro/runtime";
4
+ // src/module/runtime/handlers/rewriteRequestUrl.ts
5
5
  /**
6
6
  * Rewrites the incoming request URL to the public tenant endpoint.
7
7
  *
@@ -34,5 +34,4 @@ var rewriteRequestUrl_default = defineMiddleware(async (event, next) => {
34
34
  }
35
35
  return next();
36
36
  });
37
- //#endregion
38
37
  export { rewriteRequestUrl_default as default };
@@ -1,7 +1,7 @@
1
- import { t as createError } from "../../logging-BUYT8Z2V.mjs";
2
- import process from "node:process";
1
+ import { t as createError } from "../../logging-B1PuWdiF.mjs";
3
2
  import { defineMiddleware } from "nitro";
4
- //#region src/module/runtime/middlewares/c8y-client.ts
3
+ import process from "node:process";
4
+ // src/module/runtime/middlewares/c8y-client.ts
5
5
  function isC8yClientThrownResponse(error) {
6
6
  if (!error || typeof error !== "object") return false;
7
7
  if (!("res" in error) || !error.res || typeof error.res !== "object") return false;
@@ -39,5 +39,4 @@ var c8y_client_default = defineMiddleware(async (_event, next) => {
39
39
  });
40
40
  }
41
41
  });
42
- //#endregion
43
42
  export { c8y_client_default as default };
@@ -1,8 +1,8 @@
1
- import { Buffer } from "node:buffer";
2
1
  import process from "node:process";
3
2
  import { defineHandler } from "nitro/h3";
3
+ import { Buffer } from "node:buffer";
4
4
  import consola from "consola";
5
- //#region src/module/runtime/middlewares/dev-user.dev.ts
5
+ // src/module/runtime/middlewares/dev-user.dev.ts
6
6
  var dev_user_dev_default = defineHandler((event) => {
7
7
  if (import.meta.dev) {
8
8
  const missingDevVars = [
@@ -19,5 +19,4 @@ var dev_user_dev_default = defineHandler((event) => {
19
19
  if (event.req.headers.has("cookie")) event.req.headers.delete("cookie");
20
20
  }
21
21
  });
22
- //#endregion
23
22
  export { dev_user_dev_default as default };
@@ -1,6 +1,6 @@
1
- import process from "node:process";
2
1
  import { definePlugin } from "nitro";
3
- //#region src/module/runtime/plugins/c8y-variables.dev.ts
2
+ import process from "node:process";
3
+ // src/module/runtime/plugins/c8y-variables.dev.ts
4
4
  var c8y_variables_dev_default = definePlugin(() => {
5
5
  if (import.meta.dev) {
6
6
  const env = process.env;
@@ -13,5 +13,4 @@ var c8y_variables_dev_default = definePlugin(() => {
13
13
  if (missingVars.length > 0) throw new Error(`Missing required environment variables for development: ${missingVars.join(", ")}\n\nTo set up your development environment, run:\n npx c8y-nitro bootstrap\n\nThis command will:\n 1. Require your development tenant credentials (C8Y_BASEURL C8Y_DEVELOPMENT_TENANT, C8Y_DEVELOPMENT_USER, C8Y_DEVELOPMENT_PASSWORD)\n 2. Register your microservice on the tenant\n 3. Generate the necessary bootstrap credentials in a .env file\n\nMake sure you have your development tenant credentials configured first.`);
14
14
  }
15
15
  });
16
- //#endregion
17
16
  export { c8y_variables_dev_default as default };
@@ -1,6 +1,6 @@
1
- import { c8yManifest } from "c8y-nitro/runtime";
2
1
  import { definePlugin } from "nitro";
3
- //#region src/module/runtime/plugins/enrich-logs.ts
2
+ import { c8yManifest } from "c8y-nitro/runtime";
3
+ // src/module/runtime/plugins/enrich-logs.ts
4
4
  var enrich_logs_default = definePlugin(async (nitroApp) => {
5
5
  nitroApp.hooks.hook("evlog:enrich", (enrichContext) => {
6
6
  enrichContext.event.microservice = {
@@ -11,5 +11,4 @@ var enrich_logs_default = definePlugin(async (nitroApp) => {
11
11
  };
12
12
  });
13
13
  });
14
- //#endregion
15
14
  export { enrich_logs_default as default };