@cybearl/cypack 1.11.9 → 1.11.11

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/frontend.d.ts CHANGED
@@ -1,23 +1,14 @@
1
1
  import { ClassValue } from 'clsx';
2
2
 
3
3
  /**
4
- * The type for the CGAS status string, it can either be:
5
- * - `enabled`: The application is enabled and available to the public.
6
- * - `disabled`: The application is disabled and not available to the public.
7
- * - `in-maintenance`: The application is in maintenance mode and not available to the public.
8
- * - `in-development`: The application is in development mode and not available to the public.
4
+ * The type for the CGAS status string, only "enabled" makes the application available
5
+ * to the public, "disabled", "in-maintenance" and "in-development" do not.
9
6
  */
10
7
  type CGASStatusString = "enabled" | "disabled" | "in-maintenance" | "in-development"
11
8
 
12
9
  /**
13
- * The Cybearl General API System (CGAS) status response.
14
- *
15
- * About the status of the application (allows to enable/disable the application),
16
- * it can either be:
17
- * - `enabled`: The application is enabled and available to the public.
18
- * - `disabled`: The application is disabled and not available to the public.
19
- * - `in-maintenance`: The application is in maintenance mode and not available to the public.
20
- * - `in-development`: The application is in development mode and not available to the public.
10
+ * The Cybearl General API System (CGAS) status response, its status allows to
11
+ * enable/disable the application (see "CGASStatusString").
21
12
  */
22
13
  type CGASStatus = {
23
14
  status: CGASStatusString
@@ -66,13 +57,6 @@ type FailedRequest = {
66
57
  /**
67
58
  * Returns a failed request in case the `success` field is set to `false`,
68
59
  * otherwise returns a successful request with a data object of type T.
69
- *
70
- * **Example**:
71
- * ```ts
72
- * export async function inviteUser(): Promise<RequestResult<Access>>
73
- * ```
74
- * - Will return the "Access" type if result.success is true.
75
- * - Otherwise, will return the "FailedRequest" type.
76
60
  */
77
61
  type RequestResult<T> = ({ success: true } & SuccessfulRequest<T>) | ({ success: false } & FailedRequest)
78
62
 
package/frontend.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/frontend/cgas/status.ts","../src/frontend/styling.ts","../src/frontend/urls.ts"],"names":["getCGASStatus","markerOnly","baseUrl","fallbackCGASStatus","cn","inputs","twMerge","clsx","convertCssDelayToMs","delay","match","value","addParamsToUrl","params","url","key","currentUrlOrigin"],"mappings":"6DAWA,eAAsBA,EAClBC,CAAAA,CAAa,KAAA,CACbC,CAAAA,CAAU,WAAA,CACiC,CAG3C,OADe,KAAA,CADE,MAAM,KAAA,CAAM,GAAGA,CAAO,CAAA,mBAAA,EAAsBD,CAAU,CAAA,CAAE,GAC3C,IAAA,EAElC,CAKO,IAAME,EAAiC,CAC1C,MAAA,CAAQ,UAAA,CACR,MAAA,CAAQ,kBACR,SAAA,CAAW,IAAI,IAAA,EAAK,CAAE,aAAY,CAClC,OAAA,CAAS,CACL,GAAA,CAAK,cACL,SAAA,CAAW,aACf,CAAA,CACA,OAAA,CAAS,oDACb,ECxBO,SAASC,CAAAA,CAAAA,GAAMC,CAAAA,CAAsB,CACxC,OAAOC,QAAQC,IAAAA,CAAKF,CAAM,CAAC,CAC/B,CAYO,SAASG,CAAAA,CAAoBC,CAAAA,CAAyB,CACzD,GAAI,OAAOA,CAAAA,EAAU,QAAA,CAAU,OAAOA,EAEtC,IAAMC,CAAAA,CAAQD,CAAAA,CAAM,KAAA,CAAM,qBAAqB,CAAA,CAC/C,GAAI,CAACC,CAAAA,CAAO,OAAO,CAAA,CAEnB,IAAMC,CAAAA,CAAQ,MAAA,CAAO,WAAWD,CAAAA,CAAM,CAAC,CAAC,CAAA,CAGxC,OAFaA,CAAAA,CAAM,CAAC,CAAA,GAEJ,GAAA,CAAMC,EAAQ,GAAA,CAAOA,CACzC,CC1BO,SAASC,EACZV,CAAAA,CACAW,CAAAA,CAGF,CACE,IAAIC,EAAMZ,CAAAA,CAEV,IAAA,GAAW,CAACa,CAAAA,CAAKJ,CAAK,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQE,CAAM,EACjBF,CAAAA,EAAU,IAAA,EAAQA,CAAAA,GAAU,EAAA,EAAMA,IAAU,MAAA,EAAUA,CAAAA,GAAU,WAAA,GAI3FG,CAAAA,EAAO,GAAGA,CAAAA,CAAI,QAAA,CAAS,GAAG,CAAA,CAAI,IAAM,GAAG,CAAA,EAAG,kBAAA,CAAmBC,CAAG,CAAC,CAAA,CAAA,EAAI,kBAAA,CAAmBJ,CAAAA,CAAM,QAAA,EAAU,CAAC,CAAA,CAAA,CAAA,CAG7G,OAAOG,CACX,CAMO,IAAME,CAAAA,CAAmB,OAAO,MAAA,CAAW,KAAe,MAAA,CAAO,QAAA,CAAS,MAAA,CAAS,MAAA,CAAO,SAAS,MAAA,CAAS","file":"frontend.js","sourcesContent":["import type { CGASStatus } from \"@/main/types/cgas\"\nimport type { RequestResult } from \"@/main/types/requests\"\n\n/**\n * Get the status of the application via the CGAS API endpoint (that itself uses the `getCGASStatus` function).\n * @param markerOnly Whether to only return the marker (optional, defaults to false).\n * @param baseUrl The base URL of the CGAS API (optional, defaults to \"/api/cgas\").\n * @returns The status of the application, or the marker if `markerOnly` is true.\n */\nexport async function getCGASStatus(markerOnly: true, baseUrl?: string): Promise<RequestResult<string>>\nexport async function getCGASStatus(markerOnly?: false, baseUrl?: string): Promise<RequestResult<CGASStatus>>\nexport async function getCGASStatus(\n markerOnly = false,\n baseUrl = \"/api/cgas\",\n): Promise<RequestResult<CGASStatus | string>> {\n const response = await fetch(`${baseUrl}/status?markerOnly=${markerOnly}`)\n const result = await response.json()\n return result as RequestResult<CGASStatus | string>\n}\n\n/**\n * The fallback CGAS status, used when the CGAS API is not available.\n */\nexport const fallbackCGASStatus: CGASStatus = {\n status: \"disabled\",\n marker: \"fallback-marker\",\n timestamp: new Date().toISOString(),\n version: {\n raw: \"unavailable\",\n formatted: \"unavailable\",\n },\n message: \"This API is not available, please try again later.\",\n}\n","import { type ClassValue, clsx } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\n/**\n * Merges Tailwind CSS class names without style conflicts.\n * @param inputs The Tailwind CSS classes to merge.\n * @returns The merged class string.\n */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n\n/**\n * The type for a CSS delay value, either a number (milliseconds) or a CSS string (\"1s\", \"500ms\").\n */\nexport type CSSDelay = `${number}s` | `${number}ms` | number\n\n/**\n * Converts a CSS delay string to milliseconds.\n * @param delay A CSS delay string (\"1s\", \"500ms\") or a number already in milliseconds.\n * @returns The delay in milliseconds, or 0 if the format is unrecognized.\n */\nexport function convertCssDelayToMs(delay: CSSDelay): number {\n if (typeof delay === \"number\") return delay\n\n const match = delay.match(/(\\d+(\\.\\d+)?)(s|ms)/)\n if (!match) return 0\n\n const value = Number.parseFloat(match[1])\n const unit = match[3]\n\n return unit === \"s\" ? value * 1000 : value\n}\n","/**\n * Allows to add query parameters to a URL.\n * @param baseUrl The base URL to add parameters to.\n * @param params The parameters to add, note that each parameter will be URL-encoded.\n * @returns The URL with the parameters added.\n */\nexport function addParamsToUrl(\n baseUrl: string,\n params: {\n [key: string]: string | number | boolean | undefined | null\n },\n) {\n let url = baseUrl\n\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined || value === null || value === \"\" || value === \"null\" || value === \"undefined\") {\n continue\n }\n\n url += `${url.includes(\"?\") ? \"&\" : \"?\"}${encodeURIComponent(key)}=${encodeURIComponent(value.toString())}`\n }\n\n return url\n}\n\n/**\n * Get the current URL origin or null if it's not available.\n */\n// biome-ignore lint/complexity/useOptionalChain: Frontend code, optional chaining would cause issues with window being undefined\nexport const currentUrlOrigin = typeof window !== \"undefined\" && window.location.origin ? window.location.origin : null\n"]}
1
+ {"version":3,"sources":["../src/frontend/cgas/status.ts","../src/frontend/styling.ts","../src/frontend/urls.ts"],"names":["getCGASStatus","markerOnly","baseUrl","fallbackCGASStatus","cn","inputs","twMerge","clsx","convertCssDelayToMs","delay","match","value","addParamsToUrl","params","url","key","currentUrlOrigin"],"mappings":"6DAiBA,eAAsBA,EAClBC,CAAAA,CAAa,KAAA,CACbC,CAAAA,CAAU,WAAA,CACiC,CAG3C,OADe,KAAA,CADE,MAAM,KAAA,CAAM,GAAGA,CAAO,CAAA,mBAAA,EAAsBD,CAAU,CAAA,CAAE,GAC3C,IAAA,EAElC,CAKO,IAAME,EAAiC,CAC1C,MAAA,CAAQ,UAAA,CACR,MAAA,CAAQ,kBACR,SAAA,CAAW,IAAI,IAAA,EAAK,CAAE,aAAY,CAClC,OAAA,CAAS,CACL,GAAA,CAAK,cACL,SAAA,CAAW,aACf,CAAA,CACA,OAAA,CAAS,oDACb,EC9BO,SAASC,CAAAA,CAAAA,GAAMC,CAAAA,CAAsB,CACxC,OAAOC,QAAQC,IAAAA,CAAKF,CAAM,CAAC,CAC/B,CAYO,SAASG,CAAAA,CAAoBC,CAAAA,CAAyB,CACzD,GAAI,OAAOA,CAAAA,EAAU,QAAA,CAAU,OAAOA,EAEtC,IAAMC,CAAAA,CAAQD,CAAAA,CAAM,KAAA,CAAM,qBAAqB,CAAA,CAC/C,GAAI,CAACC,CAAAA,CAAO,OAAO,CAAA,CAEnB,IAAMC,CAAAA,CAAQ,MAAA,CAAO,WAAWD,CAAAA,CAAM,CAAC,CAAC,CAAA,CAGxC,OAFaA,CAAAA,CAAM,CAAC,CAAA,GAEJ,GAAA,CAAMC,EAAQ,GAAA,CAAOA,CACzC,CC1BO,SAASC,EACZV,CAAAA,CACAW,CAAAA,CAGF,CACE,IAAIC,EAAMZ,CAAAA,CAEV,IAAA,GAAW,CAACa,CAAAA,CAAKJ,CAAK,CAAA,GAAK,MAAA,CAAO,OAAA,CAAQE,CAAM,EACjBF,CAAAA,EAAU,IAAA,EAAQA,CAAAA,GAAU,EAAA,EAAMA,IAAU,MAAA,EAAUA,CAAAA,GAAU,WAAA,GAI3FG,CAAAA,EAAO,GAAGA,CAAAA,CAAI,QAAA,CAAS,GAAG,CAAA,CAAI,IAAM,GAAG,CAAA,EAAG,kBAAA,CAAmBC,CAAG,CAAC,CAAA,CAAA,EAAI,kBAAA,CAAmBJ,CAAAA,CAAM,QAAA,EAAU,CAAC,CAAA,CAAA,CAAA,CAG7G,OAAOG,CACX,CAKO,IAAME,CAAAA,CAAmB,OAAO,MAAA,CAAW,KAAe,MAAA,CAAO,QAAA,CAAS,MAAA,CAAS,MAAA,CAAO,SAAS,MAAA,CAAS","file":"frontend.js","sourcesContent":["import type { CGASStatus } from \"@/main/types/cgas\"\nimport type { RequestResult } from \"@/main/types/requests\"\n\n/**\n * Get the status of the application via the CGAS API endpoint (that itself uses the `getCGASStatus` function).\n * @param markerOnly Whether to only return the marker (optional, defaults to false).\n * @param baseUrl The base URL of the CGAS API (optional, defaults to \"/api/cgas\").\n * @returns The status of the application, or the marker if `markerOnly` is true.\n */\nexport async function getCGASStatus(markerOnly: true, baseUrl?: string): Promise<RequestResult<string>>\nexport async function getCGASStatus(markerOnly?: false, baseUrl?: string): Promise<RequestResult<CGASStatus>>\n/**\n * Implementation of the \"getCGASStatus\" overloads.\n * @param markerOnly Whether to only return the marker (optional, defaults to false).\n * @param baseUrl The base URL of the CGAS API (optional, defaults to \"/api/cgas\").\n * @returns The status of the application, or the marker if \"markerOnly\" is true.\n */\nexport async function getCGASStatus(\n markerOnly = false,\n baseUrl = \"/api/cgas\",\n): Promise<RequestResult<CGASStatus | string>> {\n const response = await fetch(`${baseUrl}/status?markerOnly=${markerOnly}`)\n const result = await response.json()\n return result as RequestResult<CGASStatus | string>\n}\n\n/**\n * The fallback CGAS status, used when the CGAS API is not available.\n */\nexport const fallbackCGASStatus: CGASStatus = {\n status: \"disabled\",\n marker: \"fallback-marker\",\n timestamp: new Date().toISOString(),\n version: {\n raw: \"unavailable\",\n formatted: \"unavailable\",\n },\n message: \"This API is not available, please try again later.\",\n}\n","import { type ClassValue, clsx } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\n/**\n * Merges Tailwind CSS class names without style conflicts.\n * @param inputs The Tailwind CSS classes to merge.\n * @returns The merged class string.\n */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n\n/**\n * The type for a CSS delay value, either a number (milliseconds) or a CSS string (\"1s\", \"500ms\").\n */\nexport type CSSDelay = `${number}s` | `${number}ms` | number\n\n/**\n * Converts a CSS delay string to milliseconds.\n * @param delay A CSS delay string (\"1s\", \"500ms\") or a number already in milliseconds.\n * @returns The delay in milliseconds, or 0 if the format is unrecognized.\n */\nexport function convertCssDelayToMs(delay: CSSDelay): number {\n if (typeof delay === \"number\") return delay\n\n const match = delay.match(/(\\d+(\\.\\d+)?)(s|ms)/)\n if (!match) return 0\n\n const value = Number.parseFloat(match[1])\n const unit = match[3]\n\n return unit === \"s\" ? value * 1000 : value\n}\n","/**\n * Allows to add query parameters to a URL.\n * @param baseUrl The base URL to add parameters to.\n * @param params The parameters to add, note that each parameter will be URL-encoded.\n * @returns The URL with the parameters added.\n */\nexport function addParamsToUrl(\n baseUrl: string,\n params: {\n [key: string]: string | number | boolean | undefined | null\n },\n) {\n let url = baseUrl\n\n for (const [key, value] of Object.entries(params)) {\n if (value === undefined || value === null || value === \"\" || value === \"null\" || value === \"undefined\") {\n continue\n }\n\n url += `${url.includes(\"?\") ? \"&\" : \"?\"}${encodeURIComponent(key)}=${encodeURIComponent(value.toString())}`\n }\n\n return url\n}\n\n/**\n * Get the current URL origin or null if it's not available.\n */\nexport const currentUrlOrigin = typeof window !== \"undefined\" && window.location.origin ? window.location.origin : null\n"]}
package/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  /**
2
2
  * Returns true if the code is running in a server environment.
3
+ * @returns True if running on the server, false otherwise.
3
4
  */
4
5
  declare function isServer(): boolean;
5
6
  /**
6
7
  * Returns true if the code is running in a client environment.
8
+ * @returns True if running on the client, false otherwise.
7
9
  */
8
10
  declare function isClient(): boolean;
9
11
  /**
@@ -35,6 +37,7 @@ declare const CyCONSTANTS: {
35
37
  MAX_EXTERNAL_LINKS_COUNT: number;
36
38
  USERNAME_REGEX: RegExp;
37
39
  SLUG_REGEX: RegExp;
40
+ NO_BODY_HTTP_STATUSES: number[];
38
41
  IMG_SIZES_HIGH_QUALITY: string;
39
42
  IMG_SIZES_MEDIUM_QUALITY: string;
40
43
  IMG_SIZES_BASE_QUALITY: string;
@@ -336,13 +339,10 @@ type RequiredEnvVars = {
336
339
  /**
337
340
  * Checks for required environment variables and warns or throws if any are missing
338
341
  * or if private variables are leaking into the client bundle.
339
- *
340
- * Pass your app's required-var names as `requiredVars` and a flat record of their
341
- * actual runtime values as `runtimeValues`. The `runtimeValues` object must inline
342
- * `process.env.X` calls directly, dynamic key access (`process.env[name]`) is
343
- * dead-code eliminated by most bundlers and will not work.
344
342
  * @param requiredVars The required variable names split into `public` and `private`.
345
- * @param runtimeValues A flat map of the variable names.
343
+ * @param runtimeValues A flat map of the variable names to their runtime values, it must inline
344
+ * `process.env.X` calls directly as dynamic key access (`process.env[name]`) is
345
+ * dead-code eliminated by most bundlers and will not work.
346
346
  */
347
347
  declare function checkEnvironmentVariables(requiredVars: RequiredEnvVars, runtimeValues: Record<string, string | undefined>): void;
348
348
 
@@ -382,18 +382,15 @@ type FailedRequest = {
382
382
  /**
383
383
  * Returns a failed request in case the `success` field is set to `false`,
384
384
  * otherwise returns a successful request with a data object of type T.
385
- *
386
- * **Example**:
387
- * ```ts
388
- * export async function inviteUser(): Promise<RequestResult<Access>>
389
- * ```
390
- * - Will return the "Access" type if result.success is true.
391
- * - Otherwise, will return the "FailedRequest" type.
392
385
  */
393
386
  type RequestResult<T> = ({ success: true } & SuccessfulRequest<T>) | ({ success: false } & FailedRequest)
394
387
 
395
388
  /**
396
389
  * Formats an `ErrorObj` into a standard error sent back by an API endpoint.
390
+ * @param error The `ErrorObj` object to format.
391
+ * @param customMessage Replaces the standard error message with a custom one (optional).
392
+ * @param additionalData Additional data to include in the error (optional).
393
+ * @returns The formatted error response.
397
394
  */
398
395
  declare function formatErrorResponse(error: ErrorObj, customMessage?: string, additionalData?: unknown): {
399
396
  success: boolean;
@@ -425,26 +422,7 @@ declare function parseCRUDError(error: unknown): FailedRequest;
425
422
  declare function formatMessageAsStringifiedError(message: string, error?: unknown): string;
426
423
  /**
427
424
  * Contains all the standard available errors for the application, it serves as a base
428
- * to extend with your custom errors.
429
- *
430
- * The recommended way is to create an `AppErrors` object that extends this one, preferably
431
- * at a place similar to `lib/utils/errors.ts`:
432
- * ```typescript
433
- * import { BaseErrors } from "..."
434
- *
435
- * export const AppErrors = {
436
- * ...BaseErrors,
437
- * //=====//
438
- * // 401 //
439
- * //=====//
440
- * BLAH_BLAH: {
441
- * status: 401,
442
- * name: "BlahBlah",
443
- * message: "Blah blah blah.",
444
- * data: null,
445
- * },
446
- * }
447
- * ```
425
+ * to extend with your custom errors (e.g. an "AppErrors" object spreading "BaseErrors").
448
426
  */
449
427
  declare const BaseErrors: {
450
428
  readonly BAD_REQUEST: {
@@ -610,11 +588,9 @@ declare function formatDate(date: Date): string;
610
588
  /**
611
589
  * Formats a bigint as scientific notation using only integer arithmetic,
612
590
  * supporting arbitrarily large values (e.g., up to 2^256).
613
- *
614
- * Returns a tuple `[coefficient, exponent]` so callers can render the
615
- * exponent as a superscript (e.g., `["4.61", 18]` for ~4.61 × 10^18).
616
591
  * @param value The bigint to format.
617
592
  * @param precision Number of decimal digits in the coefficient (default 2).
593
+ * @returns A tuple `[coefficient, exponent]` (e.g., `["4.61", 18]` for ~4.61 × 10^18).
618
594
  */
619
595
  declare function bigintToScientific(value: bigint, precision?: number): [coefficient: string, exponent: number];
620
596
  /**
@@ -668,10 +644,8 @@ declare function mapRange(value: number, inMin: number, inMax: number, outMin: n
668
644
  declare function safeAverage(total?: string | number, count?: string | number, decimalPlaces?: number): number;
669
645
  /**
670
646
  * Safely creates a percentage based on a numerator and denominator coming from
671
- * a Lucid ORM / SQL query result.
672
- *
673
- * Note: If the denominator is zero, this function will return `-1` if the
674
- * numerator is greater than zero, showing it as a growth from nothing to something.
647
+ * a Lucid ORM / SQL query result, returning `-1` for a zero denominator with a
648
+ * positive numerator (growth from nothing to something).
675
649
  * @param numerator The numerator value.
676
650
  * @param denominator The denominator value.
677
651
  * @param decimalPlaces The number of decimal places to round to (optional, defaults to 2).
@@ -699,19 +673,48 @@ declare const NEXT_LOG_INDICATORS: {
699
673
  * Options accepted by each log method.
700
674
  */
701
675
  type NextLoggerOptions = {
702
- /** Overrides the logger's default prefix for this call. */
676
+ /**
677
+ * Overrides the logger's default prefix for this call.
678
+ */
703
679
  prefix?: string;
704
- /** Additional data to log alongside the message (e.g., an Error object). */
680
+ /**
681
+ * Additional data to log alongside the message (e.g., an Error object).
682
+ */
705
683
  data?: unknown;
706
684
  };
707
685
  /**
708
686
  * A logger instance returned by `createNextLogger` or `withPrefix`.
709
687
  */
710
688
  type NextLoggerInstance = {
689
+ /**
690
+ * Logs a success message.
691
+ * @param message The message to log.
692
+ * @param options The logging options (optional).
693
+ */
711
694
  success: (message: string, options?: NextLoggerOptions) => void;
695
+ /**
696
+ * Logs a warning message.
697
+ * @param message The message to log.
698
+ * @param options The logging options (optional).
699
+ */
712
700
  warn: (message: string, options?: NextLoggerOptions) => void;
701
+ /**
702
+ * Logs an error message.
703
+ * @param message The message to log.
704
+ * @param options The logging options (optional).
705
+ */
713
706
  error: (message: string, options?: NextLoggerOptions) => void;
707
+ /**
708
+ * Logs an info message.
709
+ * @param message The message to log.
710
+ * @param options The logging options (optional).
711
+ */
714
712
  info: (message: string, options?: NextLoggerOptions) => void;
713
+ /**
714
+ * Logs a debug message.
715
+ * @param message The message to log.
716
+ * @param options The logging options (optional).
717
+ */
715
718
  debug: (message: string, options?: NextLoggerOptions) => void;
716
719
  /**
717
720
  * Returns a new logger instance with the given prefix fixed as its default.
@@ -728,7 +731,7 @@ type NextLoggerInstance = {
728
731
  * @param defaultPrefix An optional prefix prepended to all messages as `[prefix]`.
729
732
  * @param prefixColumnWidth Total character width reserved for the `[prefix]` block (brackets included),
730
733
  * used to align messages across loggers with different prefix lengths (optional, defaults to 10).
731
- * For example, with a width of 10, `[success] A` and `[error] A` line up on the `A`.
734
+ * @returns A new logger instance.
732
735
  */
733
736
  declare function createNextLogger(defaultPrefix?: string, prefixColumnWidth?: number): NextLoggerInstance;
734
737
  /**
@@ -782,23 +785,14 @@ declare function applyHexColorOpacity(hexColor: string, opacity: number): string
782
785
  declare function shadeColor(color: string, percent: number): string;
783
786
 
784
787
  /**
785
- * The type for the CGAS status string, it can either be:
786
- * - `enabled`: The application is enabled and available to the public.
787
- * - `disabled`: The application is disabled and not available to the public.
788
- * - `in-maintenance`: The application is in maintenance mode and not available to the public.
789
- * - `in-development`: The application is in development mode and not available to the public.
788
+ * The type for the CGAS status string, only "enabled" makes the application available
789
+ * to the public, "disabled", "in-maintenance" and "in-development" do not.
790
790
  */
791
791
  type CGASStatusString = "enabled" | "disabled" | "in-maintenance" | "in-development"
792
792
 
793
793
  /**
794
- * The Cybearl General API System (CGAS) status response.
795
- *
796
- * About the status of the application (allows to enable/disable the application),
797
- * it can either be:
798
- * - `enabled`: The application is enabled and available to the public.
799
- * - `disabled`: The application is disabled and not available to the public.
800
- * - `in-maintenance`: The application is in maintenance mode and not available to the public.
801
- * - `in-development`: The application is in development mode and not available to the public.
794
+ * The Cybearl General API System (CGAS) status response, its status allows to
795
+ * enable/disable the application (see "CGASStatusString").
802
796
  */
803
797
  type CGASStatus = {
804
798
  status: CGASStatusString
package/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import I from'slugify';function M(){return typeof window>"u"}function R(){return !M()}function h(i,t){if(i===t)return true;let{length:r}=i;if(r!==t.length)return false;for(let a=0;a<r;a++)if(i[a]!==t[a])return false;return true}var D={HASH_SALT_ROUNDS:12,MIN_USERNAME_LENGTH:4,MAX_USERNAME_LENGTH:36,MIN_PASSWORD_LENGTH:8,MAX_PASSWORD_LENGTH:255,MAX_NAME_LENGTH:255,MAX_SLUG_LENGTH:255,MIN_FIRST_NAME_LENGTH:1,MAX_FIRST_NAME_LENGTH:36,MIN_LAST_NAME_LENGTH:1,MAX_LAST_NAME_LENGTH:36,MAX_DESCRIPTION_LENGTH:1024,MAX_URL_LENGTH:2048,MAX_MIME_TYPE_LENGTH:255,MAX_EXTERNAL_LINKS_COUNT:6,USERNAME_REGEX:/^[a-zA-Z0-9_.-]+$/,SLUG_REGEX:/^[a-zA-Z0-9-]+$/,IMG_SIZES_HIGH_QUALITY:"(max-width: 768px) 100vw, (max-width: 1200px) 75vw, 50vw",IMG_SIZES_MEDIUM_QUALITY:"(max-width: 768px) 100vw, (max-width: 1200px) 60vw, 40vw",IMG_SIZES_BASE_QUALITY:"(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw",IMG_SIZES_LOW_QUALITY:"(max-width: 768px) 100vw, (max-width: 1200px) 40vw, 25vw"},E=D;var N=(e=>(e.Afghanistan="AF",e.AlandIslands="AX",e.Albania="AL",e.Algeria="DZ",e.AmericanSamoa="AS",e.Andorra="AD",e.Angola="AO",e.Anguilla="AI",e.Antarctica="AQ",e.AntiguaAndBarbuda="AG",e.Argentina="AR",e.Armenia="AM",e.Aruba="AW",e.Australia="AU",e.Austria="AT",e.Azerbaijan="AZ",e.Bahamas="BS",e.Bahrain="BH",e.Bangladesh="BD",e.Barbados="BB",e.Belarus="BY",e.Belgium="BE",e.Belize="BZ",e.Benin="BJ",e.Bermuda="BM",e.Bhutan="BT",e.Bolivia="BO",e.BonaireSintEustatiusSaba="BQ",e.BosniaAndHerzegovina="BA",e.Botswana="BW",e.BouvetIsland="BV",e.Brazil="BR",e.BritishIndianOceanTerritory="IO",e.BruneiDarussalam="BN",e.Bulgaria="BG",e.BurkinaFaso="BF",e.Burundi="BI",e.Cambodia="KH",e.Cameroon="CM",e.Canada="CA",e.CapeVerde="CV",e.CaymanIslands="KY",e.CentralAfricanRepublic="CF",e.Chad="TD",e.Chile="CL",e.China="CN",e.ChristmasIsland="CX",e.CocosKeelingIslands="CC",e.Colombia="CO",e.Comoros="KM",e.Congo="CG",e.CongoDemocraticRepublic="CD",e.CookIslands="CK",e.CostaRica="CR",e.CoteDIvoire="CI",e.Croatia="HR",e.Cuba="CU",e.Curacao="CW",e.Cyprus="CY",e.CzechRepublic="CZ",e.Denmark="DK",e.Djibouti="DJ",e.Dominica="DM",e.DominicanRepublic="DO",e.Ecuador="EC",e.Egypt="EG",e.ElSalvador="SV",e.EquatorialGuinea="GQ",e.Eritrea="ER",e.Estonia="EE",e.Ethiopia="ET",e.FalklandIslands="FK",e.FaroeIslands="FO",e.Fiji="FJ",e.Finland="FI",e.France="FR",e.FrenchGuiana="GF",e.FrenchPolynesia="PF",e.FrenchSouthernTerritories="TF",e.Gabon="GA",e.Gambia="GM",e.Georgia="GE",e.Germany="DE",e.Ghana="GH",e.Gibraltar="GI",e.Greece="GR",e.Greenland="GL",e.Grenada="GD",e.Guadeloupe="GP",e.Guam="GU",e.Guatemala="GT",e.Guernsey="GG",e.Guinea="GN",e.GuineaBissau="GW",e.Guyana="GY",e.Haiti="HT",e.HeardIslandMcdonaldIslands="HM",e.HolySeeVaticanCityState="VA",e.Honduras="HN",e.HongKong="HK",e.Hungary="HU",e.Iceland="IS",e.India="IN",e.Indonesia="ID",e.Iran="IR",e.Iraq="IQ",e.Ireland="IE",e.IsleOfMan="IM",e.Israel="IL",e.Italy="IT",e.Jamaica="JM",e.Japan="JP",e.Jersey="JE",e.Jordan="JO",e.Kazakhstan="KZ",e.Kenya="KE",e.Kiribati="KI",e.Korea="KR",e.KoreaDemocraticPeoplesRepublic="KP",e.Kuwait="KW",e.Kyrgyzstan="KG",e.LaoPeoplesDemocraticRepublic="LA",e.Latvia="LV",e.Lebanon="LB",e.Lesotho="LS",e.Liberia="LR",e.LibyanArabJamahiriya="LY",e.Liechtenstein="LI",e.Lithuania="LT",e.Luxembourg="LU",e.Macao="MO",e.Macedonia="MK",e.Madagascar="MG",e.Malawi="MW",e.Malaysia="MY",e.Maldives="MV",e.Mali="ML",e.Malta="MT",e.MarshallIslands="MH",e.Martinique="MQ",e.Mauritania="MR",e.Mauritius="MU",e.Mayotte="YT",e.Mexico="MX",e.Micronesia="FM",e.Moldova="MD",e.Monaco="MC",e.Mongolia="MN",e.Montenegro="ME",e.Montserrat="MS",e.Morocco="MA",e.Mozambique="MZ",e.Myanmar="MM",e.Namibia="NA",e.Nauru="NR",e.Nepal="NP",e.Netherlands="NL",e.NewCaledonia="NC",e.NewZealand="NZ",e.Nicaragua="NI",e.Niger="NE",e.Nigeria="NG",e.Niue="NU",e.NorfolkIsland="NF",e.NorthernMarianaIslands="MP",e.Norway="NO",e.Oman="OM",e.Pakistan="PK",e.Palau="PW",e.PalestinianTerritory="PS",e.Panama="PA",e.PapuaNewGuinea="PG",e.Paraguay="PY",e.Peru="PE",e.Philippines="PH",e.Pitcairn="PN",e.Poland="PL",e.Portugal="PT",e.PuertoRico="PR",e.Qatar="QA",e.Reunion="RE",e.Romania="RO",e.RussianFederation="RU",e.Rwanda="RW",e.SaintBarthelemy="BL",e.SaintHelena="SH",e.SaintKittsAndNevis="KN",e.SaintLucia="LC",e.SaintMartin="MF",e.SaintPierreAndMiquelon="PM",e.SaintVincentAndGrenadines="VC",e.Samoa="WS",e.SanMarino="SM",e.SaoTomeAndPrincipe="ST",e.SaudiArabia="SA",e.Senegal="SN",e.Serbia="RS",e.Seychelles="SC",e.SierraLeone="SL",e.Singapore="SG",e.SintMaarten="SX",e.Slovakia="SK",e.Slovenia="SI",e.SolomonIslands="SB",e.Somalia="SO",e.SouthAfrica="ZA",e.SouthGeorgiaAndSandwichIsl="GS",e.SouthSudan="SS",e.Spain="ES",e.SriLanka="LK",e.Sudan="SD",e.Suriname="SR",e.SvalbardAndJanMayen="SJ",e.Swaziland="SZ",e.Sweden="SE",e.Switzerland="CH",e.SyrianArabRepublic="SY",e.Taiwan="TW",e.Tajikistan="TJ",e.Tanzania="TZ",e.Thailand="TH",e.TimorLeste="TL",e.Togo="TG",e.Tokelau="TK",e.Tonga="TO",e.TrinidadAndTobago="TT",e.Tunisia="TN",e.Turkey="TR",e.Turkmenistan="TM",e.TurksAndCaicosIslands="TC",e.Tuvalu="TV",e.Uganda="UG",e.Ukraine="UA",e.UnitedArabEmirates="AE",e.UnitedKingdom="GB",e.UnitedStates="US",e.UnitedStatesOutlyingIslands="UM",e.Uruguay="UY",e.Uzbekistan="UZ",e.Vanuatu="VU",e.Venezuela="VE",e.Vietnam="VN",e.VirginIslandsBritish="VG",e.VirginIslandsUS="VI",e.WallisAndFutuna="WF",e.WesternSahara="EH",e.Yemen="YE",e.Zambia="ZM",e.Zimbabwe="ZW",e))(N||{});function x(i){return i==="CoteDIvoire"?"Cote D'Ivoire":i==="VirginIslandsUS"?"Virgin Islands US":i.replace(/([A-Z])/g," $1").trim()}var F=Object.entries(N).map(([i,t])=>({label:x(i),value:t}));function G(i){let t=Object.entries(N).find(([,r])=>r===i);return t?x(t[0]):void 0}var O=N;function _(i){return JSON.stringify(JSON.parse(i),null,4)}function g(i,t=4){return JSON.stringify(i,(r,a)=>typeof a=="function"||typeof a=="bigint"?a.toString():a,t)}var l={success:"\x1B[32m \u2713 \x1B[0m",warning:"\x1B[35m \u26A0 \x1B[0m",error:"\x1B[31m \u2717 \x1B[0m",info:"\x1B[33m \u25CB \x1B[0m",debug:"\x1B[34m \u25B7 \x1B[0m"};function A(i,t=10){function r(a,n,s,o){let m=typeof window<"u",b="",c=o?.prefix??i,p=Math.max(t-(c?.length??0)-2,0);c&&(b=`[${c}]${m?" ":" ".repeat(p)}`);let f=`${m?"":a}${b}${s}`;if(o?.data===void 0)n(f);else {let u=g(o.data,2).split(`
1
+ import T from'slugify';function M(){return typeof window>"u"}function h(){return !M()}function R(i,t){if(i===t)return true;if(i.length!==t.length)return false;for(let r=0;r<i.length;r++)if(i[r]!==t[r])return false;return true}var D={HASH_SALT_ROUNDS:12,MIN_USERNAME_LENGTH:4,MAX_USERNAME_LENGTH:36,MIN_PASSWORD_LENGTH:8,MAX_PASSWORD_LENGTH:255,MAX_NAME_LENGTH:255,MAX_SLUG_LENGTH:255,MIN_FIRST_NAME_LENGTH:1,MAX_FIRST_NAME_LENGTH:36,MIN_LAST_NAME_LENGTH:1,MAX_LAST_NAME_LENGTH:36,MAX_DESCRIPTION_LENGTH:1024,MAX_URL_LENGTH:2048,MAX_MIME_TYPE_LENGTH:255,MAX_EXTERNAL_LINKS_COUNT:6,USERNAME_REGEX:/^[a-zA-Z0-9_.-]+$/,SLUG_REGEX:/^[a-zA-Z0-9-]+$/,NO_BODY_HTTP_STATUSES:[204,304],IMG_SIZES_HIGH_QUALITY:"(max-width: 768px) 100vw, (max-width: 1200px) 75vw, 50vw",IMG_SIZES_MEDIUM_QUALITY:"(max-width: 768px) 100vw, (max-width: 1200px) 60vw, 40vw",IMG_SIZES_BASE_QUALITY:"(max-width: 768px) 100vw, (max-width: 1200px) 50vw, 33vw",IMG_SIZES_LOW_QUALITY:"(max-width: 768px) 100vw, (max-width: 1200px) 40vw, 25vw"},E=D;var N=(e=>(e.Afghanistan="AF",e.AlandIslands="AX",e.Albania="AL",e.Algeria="DZ",e.AmericanSamoa="AS",e.Andorra="AD",e.Angola="AO",e.Anguilla="AI",e.Antarctica="AQ",e.AntiguaAndBarbuda="AG",e.Argentina="AR",e.Armenia="AM",e.Aruba="AW",e.Australia="AU",e.Austria="AT",e.Azerbaijan="AZ",e.Bahamas="BS",e.Bahrain="BH",e.Bangladesh="BD",e.Barbados="BB",e.Belarus="BY",e.Belgium="BE",e.Belize="BZ",e.Benin="BJ",e.Bermuda="BM",e.Bhutan="BT",e.Bolivia="BO",e.BonaireSintEustatiusSaba="BQ",e.BosniaAndHerzegovina="BA",e.Botswana="BW",e.BouvetIsland="BV",e.Brazil="BR",e.BritishIndianOceanTerritory="IO",e.BruneiDarussalam="BN",e.Bulgaria="BG",e.BurkinaFaso="BF",e.Burundi="BI",e.Cambodia="KH",e.Cameroon="CM",e.Canada="CA",e.CapeVerde="CV",e.CaymanIslands="KY",e.CentralAfricanRepublic="CF",e.Chad="TD",e.Chile="CL",e.China="CN",e.ChristmasIsland="CX",e.CocosKeelingIslands="CC",e.Colombia="CO",e.Comoros="KM",e.Congo="CG",e.CongoDemocraticRepublic="CD",e.CookIslands="CK",e.CostaRica="CR",e.CoteDIvoire="CI",e.Croatia="HR",e.Cuba="CU",e.Curacao="CW",e.Cyprus="CY",e.CzechRepublic="CZ",e.Denmark="DK",e.Djibouti="DJ",e.Dominica="DM",e.DominicanRepublic="DO",e.Ecuador="EC",e.Egypt="EG",e.ElSalvador="SV",e.EquatorialGuinea="GQ",e.Eritrea="ER",e.Estonia="EE",e.Ethiopia="ET",e.FalklandIslands="FK",e.FaroeIslands="FO",e.Fiji="FJ",e.Finland="FI",e.France="FR",e.FrenchGuiana="GF",e.FrenchPolynesia="PF",e.FrenchSouthernTerritories="TF",e.Gabon="GA",e.Gambia="GM",e.Georgia="GE",e.Germany="DE",e.Ghana="GH",e.Gibraltar="GI",e.Greece="GR",e.Greenland="GL",e.Grenada="GD",e.Guadeloupe="GP",e.Guam="GU",e.Guatemala="GT",e.Guernsey="GG",e.Guinea="GN",e.GuineaBissau="GW",e.Guyana="GY",e.Haiti="HT",e.HeardIslandMcdonaldIslands="HM",e.HolySeeVaticanCityState="VA",e.Honduras="HN",e.HongKong="HK",e.Hungary="HU",e.Iceland="IS",e.India="IN",e.Indonesia="ID",e.Iran="IR",e.Iraq="IQ",e.Ireland="IE",e.IsleOfMan="IM",e.Israel="IL",e.Italy="IT",e.Jamaica="JM",e.Japan="JP",e.Jersey="JE",e.Jordan="JO",e.Kazakhstan="KZ",e.Kenya="KE",e.Kiribati="KI",e.Korea="KR",e.KoreaDemocraticPeoplesRepublic="KP",e.Kuwait="KW",e.Kyrgyzstan="KG",e.LaoPeoplesDemocraticRepublic="LA",e.Latvia="LV",e.Lebanon="LB",e.Lesotho="LS",e.Liberia="LR",e.LibyanArabJamahiriya="LY",e.Liechtenstein="LI",e.Lithuania="LT",e.Luxembourg="LU",e.Macao="MO",e.Macedonia="MK",e.Madagascar="MG",e.Malawi="MW",e.Malaysia="MY",e.Maldives="MV",e.Mali="ML",e.Malta="MT",e.MarshallIslands="MH",e.Martinique="MQ",e.Mauritania="MR",e.Mauritius="MU",e.Mayotte="YT",e.Mexico="MX",e.Micronesia="FM",e.Moldova="MD",e.Monaco="MC",e.Mongolia="MN",e.Montenegro="ME",e.Montserrat="MS",e.Morocco="MA",e.Mozambique="MZ",e.Myanmar="MM",e.Namibia="NA",e.Nauru="NR",e.Nepal="NP",e.Netherlands="NL",e.NewCaledonia="NC",e.NewZealand="NZ",e.Nicaragua="NI",e.Niger="NE",e.Nigeria="NG",e.Niue="NU",e.NorfolkIsland="NF",e.NorthernMarianaIslands="MP",e.Norway="NO",e.Oman="OM",e.Pakistan="PK",e.Palau="PW",e.PalestinianTerritory="PS",e.Panama="PA",e.PapuaNewGuinea="PG",e.Paraguay="PY",e.Peru="PE",e.Philippines="PH",e.Pitcairn="PN",e.Poland="PL",e.Portugal="PT",e.PuertoRico="PR",e.Qatar="QA",e.Reunion="RE",e.Romania="RO",e.RussianFederation="RU",e.Rwanda="RW",e.SaintBarthelemy="BL",e.SaintHelena="SH",e.SaintKittsAndNevis="KN",e.SaintLucia="LC",e.SaintMartin="MF",e.SaintPierreAndMiquelon="PM",e.SaintVincentAndGrenadines="VC",e.Samoa="WS",e.SanMarino="SM",e.SaoTomeAndPrincipe="ST",e.SaudiArabia="SA",e.Senegal="SN",e.Serbia="RS",e.Seychelles="SC",e.SierraLeone="SL",e.Singapore="SG",e.SintMaarten="SX",e.Slovakia="SK",e.Slovenia="SI",e.SolomonIslands="SB",e.Somalia="SO",e.SouthAfrica="ZA",e.SouthGeorgiaAndSandwichIsl="GS",e.SouthSudan="SS",e.Spain="ES",e.SriLanka="LK",e.Sudan="SD",e.Suriname="SR",e.SvalbardAndJanMayen="SJ",e.Swaziland="SZ",e.Sweden="SE",e.Switzerland="CH",e.SyrianArabRepublic="SY",e.Taiwan="TW",e.Tajikistan="TJ",e.Tanzania="TZ",e.Thailand="TH",e.TimorLeste="TL",e.Togo="TG",e.Tokelau="TK",e.Tonga="TO",e.TrinidadAndTobago="TT",e.Tunisia="TN",e.Turkey="TR",e.Turkmenistan="TM",e.TurksAndCaicosIslands="TC",e.Tuvalu="TV",e.Uganda="UG",e.Ukraine="UA",e.UnitedArabEmirates="AE",e.UnitedKingdom="GB",e.UnitedStates="US",e.UnitedStatesOutlyingIslands="UM",e.Uruguay="UY",e.Uzbekistan="UZ",e.Vanuatu="VU",e.Venezuela="VE",e.Vietnam="VN",e.VirginIslandsBritish="VG",e.VirginIslandsUS="VI",e.WallisAndFutuna="WF",e.WesternSahara="EH",e.Yemen="YE",e.Zambia="ZM",e.Zimbabwe="ZW",e))(N||{});function x(i){return i==="CoteDIvoire"?"Cote D'Ivoire":i==="VirginIslandsUS"?"Virgin Islands US":i.replace(/([A-Z])/g," $1").trim()}var F=Object.entries(N).map(([i,t])=>({label:x(i),value:t}));function G(i){let t=Object.entries(N).find(([,r])=>r===i);return t?x(t[0]):void 0}var O=N;function _(i){return JSON.stringify(JSON.parse(i),null,4)}function g(i,t=4){return JSON.stringify(i,(r,a)=>typeof a=="function"||typeof a=="bigint"?a.toString():a,t)}var l={success:"\x1B[32m \u2713 \x1B[0m",warning:"\x1B[35m \u26A0 \x1B[0m",error:"\x1B[31m \u2717 \x1B[0m",info:"\x1B[33m \u25CB \x1B[0m",debug:"\x1B[34m \u25B7 \x1B[0m"};function A(i,t=10){function r(a,n,s,o){let m=typeof window<"u",b="",c=o?.prefix??i,p=Math.max(t-(c?.length??0)-2,1);c&&(b=`[${c}]${m?" ":" ".repeat(p)}`);let f=`${m?"":a}${b}${s}`;if(o?.data===void 0)n(f);else {let u=g(o.data,2).split(`
2
2
  `).map(d=>m?d:` ${d}`).join(`
3
3
  `);n(`${f}:`,`
4
- ${u}`);}}return {success:(a,n)=>r(l.success,console.log,a,n),warn:(a,n)=>r(l.warning,console.warn,a,n),error:(a,n)=>r(l.error,console.error,a,n),info:(a,n)=>r(l.info,console.log,a,n),debug:(a,n)=>r(l.debug,console.debug,a,n),withPrefix:(a,n)=>A(a,n??t)}}var S=A();function $(i,t){return `${t?`${t}-`:""}${i.replaceAll("-","").slice(0,3)}`}function U(i,t){if(i.public.length===0&&i.private.length===0)return;let r=typeof window>"u"?"server":"client",n=(r==="server"?i.private:i.public).filter(s=>t[s]===void 0);if(n.length>0){let s=`Missing required environment variables: ${n.join(", ")}`;if(process.env.NODE_ENV==="production")S.error(s);else throw new Error(s)}else S.success(`All required environment variables are set for the '${r}' environment.`);if(r==="client"){let s=i.private.filter(o=>t[o]!==void 0);if(s.length>0){let o=`Private environment variables exposed to the client: ${s.join(", ")}`;if(process.env.NODE_ENV==="production")S.error(o);else throw new Error(o)}}}function w(i,t,r){let a;return r?a={...i,data:r}:a=i,{success:false,message:t||i.message,error:a}}function B(i,t,r){t&&(i.message=t);let a;return r?a={...i,data:r}:a=i,JSON.stringify(a,(s,o)=>typeof o=="function"||typeof o=="bigint"?o.toString():o,4)}function v(i){let t="";try{try{t=i.toString();}catch{t=g(i);}}catch{t="Unknown error";}return {success:false,message:"An error occurred while performing a CRUD operation.",error:{status:500,name:"CRUD_ERROR",message:"CRUD operation failed.",data:{rawError:i,error:t}}}}function P(i,t){let r={status:500,name:"UNKNOWN_ERROR",message:"An unknown error occurred.",data:null};if(t)try{g(t,4),r=t;}catch{r={...r,data:{rawError:`${t}`}};}return g({success:false,message:i,error:r}).replaceAll("Error: ","").replaceAll(`
5
- `," ")}var H={BAD_REQUEST:{status:400,name:"BadRequest",message:"Bad request.",data:null},UNAUTHORIZED:{status:401,name:"Unauthorized",message:"Unauthorized.",data:null},PAYMENT_REQUIRED:{status:402,name:"PaymentRequired",message:"Payment required.",data:null},FORBIDDEN:{status:403,name:"Forbidden",message:"Forbidden.",data:null},NOT_FOUND:{status:404,name:"NotFound",message:"Not found.",data:null},METHOD_NOT_ALLOWED:{status:405,name:"MethodNotAllowed",message:"Method not allowed.",data:null},REQUEST_TIMEOUT:{status:408,name:"RequestTimeout",message:"Request timed out.",data:null},CONFLICT:{status:409,name:"Conflict",message:"Conflict.",data:null},INTERNAL_SERVER_ERROR:{status:500,name:"InternalServerError",message:"Internal server error.",data:null},BACKEND_FUNCTION_RUNNING_ON_CLIENT:{status:500,name:"BackendFunctionRunningOnClient",message:"A function reserved for the backend is running on the client.",data:null},NOT_IMPLEMENTED:{status:501,name:"NotImplemented",message:"Not implemented.",data:null},BANDWIDTH_LIMIT_EXCEEDED:{status:509,name:"BandwidthLimitExceeded",message:"Bandwidth limit exceeded.",data:null}};var T=I.default||I;function k(i){return typeof i=="string"&&i.length>0&&Number.isInteger(Number(i))&&Number(i)>=0}function K(i){return typeof i=="string"&&i.length>0&&E.SLUG_REGEX.test(i)}function V(i,t="Op",r="s",a=12,n=true){let s;typeof t=="string"&&typeof r=="string"?s=`${t}/${r}`:typeof t=="string"?s=t:s="";let o=n?" ":"";return i>=10**24?`${(i/10**24).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${o}Y${s}`.padStart(a," "):i>=10**18?`${(i/10**18).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${o}E${s}`.padStart(a," "):i>=10**15?`${(i/10**15).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${o}P${s}`.padStart(a," "):i>=10**12?`${(i/10**12).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${o}T${s}`.padStart(a," "):i>=10**9?`${(i/10**9).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${o}G${s}`.padStart(a," "):i>=10**6?`${(i/10**6).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${o}M${s}`.padStart(a," "):i>=10**3?`${(i/10**3).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${o}k${s}`.padStart(a," "):`${i.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${o}${s}`.padStart(a," ")}function Z(i,t=8){return i>=3600000000000000n?`${(Number(i)/36e14).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}h`.padStart(t," "):i>=60000000000n?`${(Number(i)/6e10).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}m`.padStart(t," "):i>=1000000000n?`${(Number(i)/1e9).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}s`.padStart(t," "):i>=1000000n?`${(Number(i)/1e6).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}ms`.padStart(t," "):i>=1000n?`${(Number(i)/1e3).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}\xB5s`.padStart(t," "):`${i.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}ns`.padStart(t," ")}function J(i,t=10){return i>=36e5?`${(i/36e5).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}h`.padStart(t," "):i>=6e4?`${(i/6e4).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}m`.padStart(t," "):i>=1e3?`${(i/1e3).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}s`.padStart(t," "):`${i.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}ms`.padStart(t," ")}function q(i,t=7){return `${i.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}%`.padStart(t," ")}function X(i,t){return i.length<=t?i:`${i.slice(0,t)}...`}function j(i){let t=[],r=Array.isArray(i)?i:i.split(",").map(a=>a.trim());for(let a of r){let n=Number.parseInt(a,10);Number.isNaN(n)||t.push(n);}return t}function W(i){let t=[],r=Array.isArray(i)?i:i.split(",").map(a=>a.trim());for(let a of r)a.length>0&&t.push(a);return t}var L={lower:true,strict:true};function Y(i,t){if(t){let r=t.match(/-(\d+)$/);if(r){let a=Number.parseInt(r[1],10),n=t.slice(0,-r[0].length);return T(`${n}-${a+1}`,L)}}return T(i,L)}function z(i){let t=Math.floor((Date.now()-i.getTime())/1e3);if(t<60)return "just now";let r=Math.floor(t/60);if(r<60)return `${r}m ago`;let a=Math.floor(r/60);return a<24?`${a}h ago`:i.toLocaleDateString()}function Q(i){return i.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:true})}function y(i,t=2){if(i===0n)return ["0",0];let r=i.toString(),a=r.length-1;return a===0?[r,0]:[`${r[0]}.${r.slice(1,t+1).padEnd(t,"0")}`.replace(/\.?0+$/,""),a]}function C(i){let t=i<0n,r=i<0n?-i:i,a=["","k","M","G","T","P","E"],n=r.toString(),s=Math.floor((n.length-1)/3);if(s>=a.length&&(s=a.length-1),s<=0)return i.toString();let o=1000n**BigInt(s),c=(r*10n/o).toString().padStart(2,"0"),p=c.slice(0,-1)||"0",f=c.slice(-1),u=t?"-":"",d=a[s];return f==="0"?`${u}${p}${d}`:`${u}${p}.${f}${d}`}function ee(i,t=2){if(i===0)return "0 Bytes";let r=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],a=Math.floor(Math.log(i)/Math.log(1024));return `${parseFloat((i/1024**a).toFixed(t<0?0:t))} ${r[a]}`}function ie(i,t,r,a,n,s=true){let o=(i-t)*(n-a)/(r-t)+a;return s?Math.min(Math.max(o,a),n):o}function te(i,t,r=2){if(!t)return 0;let a=typeof i=="string"?parseFloat(i):i,n=typeof t=="string"?parseFloat(t):t;return parseFloat(((a||0)/(n||1)).toFixed(r))}function ae(i,t,r=2){if(!t)return 0;let a=typeof i=="string"?parseFloat(i):i,n=typeof t=="string"?parseFloat(t):t;return n?parseFloat((((a||0)-(n||0))/(n||1)*100).toFixed(r)):a&&a>0?-1:0}var re=`
4
+ ${u}`);}}return {success:(a,n)=>r(l.success,console.log,a,n),warn:(a,n)=>r(l.warning,console.warn,a,n),error:(a,n)=>r(l.error,console.error,a,n),info:(a,n)=>r(l.info,console.log,a,n),debug:(a,n)=>r(l.debug,console.debug,a,n),withPrefix:(a,n)=>A(a,n??t)}}var S=A();function U(i,t){return `${t?`${t}-`:""}${i.replaceAll("-","").slice(0,3)}`}function $(i,t){if(i.public.length===0&&i.private.length===0)return;let r=typeof window>"u"?"server":"client",n=(r==="server"?i.private:i.public).filter(s=>t[s]===void 0);if(n.length>0){let s=`Missing required environment variables: ${n.join(", ")}`;if(process.env.NODE_ENV==="production")S.error(s);else throw new Error(s)}else S.success(`All required environment variables are set for the '${r}' environment.`);if(r==="client"){let s=i.private.filter(o=>t[o]!==void 0);if(s.length>0){let o=`Private environment variables exposed to the client: ${s.join(", ")}`;if(process.env.NODE_ENV==="production")S.error(o);else throw new Error(o)}}}function w(i,t,r){let a;return r?a={...i,data:r}:a=i,{success:false,message:t||i.message,error:a}}function B(i,t,r){t&&(i.message=t);let a;return r?a={...i,data:r}:a=i,JSON.stringify(a,(s,o)=>typeof o=="function"||typeof o=="bigint"?o.toString():o,4)}function v(i){let t="";try{try{t=i.toString();}catch{t=g(i);}}catch{t="Unknown error";}return {success:false,message:"An error occurred while performing a CRUD operation.",error:{status:500,name:"CRUD_ERROR",message:"CRUD operation failed.",data:{rawError:i,error:t}}}}function P(i,t){let r={status:500,name:"UNKNOWN_ERROR",message:"An unknown error occurred.",data:null};if(t)try{g(t,4),r=t;}catch{r={...r,data:{rawError:`${t}`}};}return g({success:false,message:i,error:r}).replaceAll("Error: ","").replaceAll(`
5
+ `," ")}var H={BAD_REQUEST:{status:400,name:"BadRequest",message:"Bad request.",data:null},UNAUTHORIZED:{status:401,name:"Unauthorized",message:"Unauthorized.",data:null},PAYMENT_REQUIRED:{status:402,name:"PaymentRequired",message:"Payment required.",data:null},FORBIDDEN:{status:403,name:"Forbidden",message:"Forbidden.",data:null},NOT_FOUND:{status:404,name:"NotFound",message:"Not found.",data:null},METHOD_NOT_ALLOWED:{status:405,name:"MethodNotAllowed",message:"Method not allowed.",data:null},REQUEST_TIMEOUT:{status:408,name:"RequestTimeout",message:"Request timed out.",data:null},CONFLICT:{status:409,name:"Conflict",message:"Conflict.",data:null},INTERNAL_SERVER_ERROR:{status:500,name:"InternalServerError",message:"Internal server error.",data:null},BACKEND_FUNCTION_RUNNING_ON_CLIENT:{status:500,name:"BackendFunctionRunningOnClient",message:"A function reserved for the backend is running on the client.",data:null},NOT_IMPLEMENTED:{status:501,name:"NotImplemented",message:"Not implemented.",data:null},BANDWIDTH_LIMIT_EXCEEDED:{status:509,name:"BandwidthLimitExceeded",message:"Bandwidth limit exceeded.",data:null}};var I=T.default||T;function k(i){return typeof i=="string"&&i.length>0&&Number.isInteger(Number(i))&&Number(i)>=0}function K(i){return typeof i=="string"&&i.length>0&&E.SLUG_REGEX.test(i)}function V(i,t="Op",r="s",a=12,n=true){let s;typeof t=="string"&&typeof r=="string"?s=`${t}/${r}`:typeof t=="string"?s=t:s="";let o=n?" ":"";return i>=10**24?`${(i/10**24).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${o}Y${s}`.padStart(a," "):i>=10**18?`${(i/10**18).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${o}E${s}`.padStart(a," "):i>=10**15?`${(i/10**15).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${o}P${s}`.padStart(a," "):i>=10**12?`${(i/10**12).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${o}T${s}`.padStart(a," "):i>=10**9?`${(i/10**9).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${o}G${s}`.padStart(a," "):i>=10**6?`${(i/10**6).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${o}M${s}`.padStart(a," "):i>=10**3?`${(i/10**3).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${o}k${s}`.padStart(a," "):`${i.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}${o}${s}`.padStart(a," ")}function Z(i,t=8){return i>=3600000000000000n?`${(Number(i)/36e14).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}h`.padStart(t," "):i>=60000000000n?`${(Number(i)/6e10).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}m`.padStart(t," "):i>=1000000000n?`${(Number(i)/1e9).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}s`.padStart(t," "):i>=1000000n?`${(Number(i)/1e6).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}ms`.padStart(t," "):i>=1000n?`${(Number(i)/1e3).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}\xB5s`.padStart(t," "):`${i.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}ns`.padStart(t," ")}function J(i,t=10){return i>=36e5?`${(i/36e5).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}h`.padStart(t," "):i>=6e4?`${(i/6e4).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}m`.padStart(t," "):i>=1e3?`${(i/1e3).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}s`.padStart(t," "):`${i.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}ms`.padStart(t," ")}function q(i,t=7){return `${i.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}%`.padStart(t," ")}function X(i,t){return i.length<=t?i:`${i.slice(0,t)}...`}function Y(i){let t=[],r=Array.isArray(i)?i:i.split(",").map(a=>a.trim());for(let a of r){let n=Number.parseInt(a,10);Number.isNaN(n)||t.push(n);}return t}function j(i){let t=[],r=Array.isArray(i)?i:i.split(",").map(a=>a.trim());for(let a of r)a.length>0&&t.push(a);return t}var L={lower:true,strict:true};function W(i,t){if(t){let r=t.match(/-(\d+)$/);if(r){let a=Number.parseInt(r[1],10),n=t.slice(0,-r[0].length);return I(`${n}-${a+1}`,L)}}return I(i,L)}function z(i){let t=Math.floor((Date.now()-i.getTime())/1e3);if(t<60)return "just now";let r=Math.floor(t/60);if(r<60)return `${r}m ago`;let a=Math.floor(r/60);return a<24?`${a}h ago`:i.toLocaleDateString()}function Q(i){return i.toLocaleString(void 0,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:true})}function y(i,t=2){if(i===0n)return ["0",0];let r=i.toString(),a=r.length-1;return a===0?[r,0]:[`${r[0]}.${r.slice(1,t+1).padEnd(t,"0")}`.replace(/\.?0+$/,""),a]}function C(i){let t=i<0n,r=i<0n?-i:i,a=["","k","M","G","T","P","E"],n=r.toString(),s=Math.floor((n.length-1)/3);if(s>=a.length&&(s=a.length-1),s<=0)return i.toString();let o=1000n**BigInt(s),c=(r*10n/o).toString().padStart(2,"0"),p=c.slice(0,-1)||"0",f=c.slice(-1),u=t?"-":"",d=a[s];return f==="0"?`${u}${p}${d}`:`${u}${p}.${f}${d}`}function ee(i,t=2){if(i===0)return "0 Bytes";let r=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],a=Math.floor(Math.log(i)/Math.log(1024));return `${parseFloat((i/1024**a).toFixed(t<0?0:t))} ${r[a]}`}function ie(i,t,r,a,n,s=true){let o=(i-t)*(n-a)/(r-t)+a;return s?Math.min(Math.max(o,a),n):o}function te(i,t,r=2){if(!t)return 0;let a=typeof i=="string"?parseFloat(i):i,n=typeof t=="string"?parseFloat(t):t;return parseFloat(((a||0)/(n||1)).toFixed(r))}function ae(i,t,r=2){if(!t)return 0;let a=typeof i=="string"?parseFloat(i):i,n=typeof t=="string"?parseFloat(t):t;return n?parseFloat((((a||0)-(n||0))/(n||1)*100).toFixed(r)):a&&a>0?-1:0}var re=`
6
6
  default-src * data: mediastream: blob: filesystem: about: ws: wss: 'unsafe-eval' 'wasm-unsafe-eval' 'unsafe-inline';
7
7
  script-src * data: blob: 'unsafe-inline' 'unsafe-eval';
8
8
  script-src-elem * data: blob: 'unsafe-inline';
@@ -13,5 +13,5 @@ ${u}`);}}return {success:(a,n)=>r(l.success,console.log,a,n),warn:(a,n)=>r(l.war
13
13
  style-src * data: blob: 'unsafe-inline';
14
14
  font-src * data: blob: 'unsafe-inline';
15
15
  frame-ancestors * data: blob:;
16
- `.replace(/\s{2,}/g," ").trim();function ne(i){if(typeof i=="string")return i;let t="";try{t=JSON.stringify(i);}catch{}return (t===""||t==="{}")&&(t=`${i}`),t}function se(i){for(let t in i)try{i[t]=decodeURIComponent(String(i[t]));}catch{}return i}function oe(i){let t=i.replace(/^#/,"");if(t.length!==6)return i;let r=(255-parseInt(t.slice(0,2),16)).toString(16).padStart(2,"0"),a=(255-parseInt(t.slice(2,4),16)).toString(16).padStart(2,"0"),n=(255-parseInt(t.slice(4,6),16)).toString(16).padStart(2,"0");return `#${r}${a}${n}`}function ge(i,t){let r=Math.min(Math.max(t,0),1),a=i.replace(/^#/,"");if(a.length!==6)return i;let n=Math.round(r*255).toString(16).padStart(2,"0");return `#${a}${n}`}function me(i,t){let r=Number.parseInt(i.substring(1,3),16),a=Number.parseInt(i.substring(3,5),16),n=Number.parseInt(i.substring(5,7),16);r=Math.round(r*(100+t)/100),a=Math.round(a*(100+t)/100),n=Math.round(n*(100+t)/100),r=r<255?r:255,a=a<255?a:255,n=n<255?n:255,r=Math.round(r),a=Math.round(a),n=Math.round(n);let s=r.toString(16).length===1?`0${r.toString(16)}`:r.toString(16),o=a.toString(16).length===1?`0${a.toString(16)}`:a.toString(16),m=n.toString(16).length===1?`0${n.toString(16)}`:n.toString(16);return `#${s}${o}${m}`}export{H as BaseErrors,F as COUNTRIES_SELECT_FIELD,O as Country,E as CyCONSTANTS,l as NEXT_LOG_INDICATORS,ge as applyHexColorOpacity,h as arrayEqual,C as bigintToMetricFormatted,y as bigintToScientific,U as checkEnvironmentVariables,ne as convertErrorToString,A as createNextLogger,se as decodeObjectURIComponents,ee as formatBytes,x as formatCountryName,Q as formatDate,w as formatErrorResponse,Z as formatHRTime,_ as formatJson,P as formatMessageAsStringifiedError,q as formatPercentage,z as formatRelativeTime,J as formatTime,V as formatUnit,re as fullyPermissiveCspHeader,$ as generateNextLoggerPrefix,G as getCountryNameFromCode,oe as invertHexColor,R as isClient,M as isServer,k as isValidIntId,K as isValidSlug,ie as mapRange,S as nextLogger,v as parseCRUDError,j as parseQueryNumberArray,W as parseQueryStringArray,te as safeAverage,ae as safePercentage,me as shadeColor,Y as slugifyName,g as stringify,B as stringifyError,X as truncateString};//# sourceMappingURL=index.js.map
16
+ `.replace(/\s{2,}/g," ").trim();function ne(i){if(typeof i=="string")return i;let t="";try{t=JSON.stringify(i);}catch{}return (t===""||t==="{}")&&(t=`${i}`),t}function se(i){for(let t in i)try{i[t]=decodeURIComponent(String(i[t]));}catch{}return i}function oe(i){let t=i.replace(/^#/,"");if(t.length!==6)return i;let r=(255-parseInt(t.slice(0,2),16)).toString(16).padStart(2,"0"),a=(255-parseInt(t.slice(2,4),16)).toString(16).padStart(2,"0"),n=(255-parseInt(t.slice(4,6),16)).toString(16).padStart(2,"0");return `#${r}${a}${n}`}function ge(i,t){let r=Math.min(Math.max(t,0),1),a=i.replace(/^#/,"");if(a.length!==6)return i;let n=Math.round(r*255).toString(16).padStart(2,"0");return `#${a}${n}`}function me(i,t){let r=Number.parseInt(i.substring(1,3),16),a=Number.parseInt(i.substring(3,5),16),n=Number.parseInt(i.substring(5,7),16);r=Math.round(r*(100+t)/100),a=Math.round(a*(100+t)/100),n=Math.round(n*(100+t)/100),r=r<255?r:255,a=a<255?a:255,n=n<255?n:255,r=Math.round(r),a=Math.round(a),n=Math.round(n);let s=r.toString(16).length===1?`0${r.toString(16)}`:r.toString(16),o=a.toString(16).length===1?`0${a.toString(16)}`:a.toString(16),m=n.toString(16).length===1?`0${n.toString(16)}`:n.toString(16);return `#${s}${o}${m}`}export{H as BaseErrors,F as COUNTRIES_SELECT_FIELD,O as Country,E as CyCONSTANTS,l as NEXT_LOG_INDICATORS,ge as applyHexColorOpacity,R as arrayEqual,C as bigintToMetricFormatted,y as bigintToScientific,$ as checkEnvironmentVariables,ne as convertErrorToString,A as createNextLogger,se as decodeObjectURIComponents,ee as formatBytes,x as formatCountryName,Q as formatDate,w as formatErrorResponse,Z as formatHRTime,_ as formatJson,P as formatMessageAsStringifiedError,q as formatPercentage,z as formatRelativeTime,J as formatTime,V as formatUnit,re as fullyPermissiveCspHeader,U as generateNextLoggerPrefix,G as getCountryNameFromCode,oe as invertHexColor,h as isClient,M as isServer,k as isValidIntId,K as isValidSlug,ie as mapRange,S as nextLogger,v as parseCRUDError,Y as parseQueryNumberArray,j as parseQueryStringArray,te as safeAverage,ae as safePercentage,me as shadeColor,W as slugifyName,g as stringify,B as stringifyError,X as truncateString};//# sourceMappingURL=index.js.map
17
17
  //# sourceMappingURL=index.js.map